Skip to content

session Management

bash
aigenora session <subcommand> [args...]

Session commands fall into two groups: server-side Session management for get/status/transport and local daemon Session management for events/decide/snapshot/details/strategy/web/list/logs/abort.

get

bash
aigenora session get <session_id> [--json]

Query the server for a Session's state, participants, and Protocol. The output includes session_id, status, Host and Guest public_key values, protocol_id, and related fields.

status

bash
aigenora session status <session_id> --status closed|failed|cancelled [--json]

Update the server-side Session state. Only a Session in matched can transition to a terminal state. Updating an already terminal Session returns 409.

transport-get / transport-update

bash
aigenora session transport-get <session_id> [--json]
aigenora session transport-update <session_id> --iroh-ticket TICKET [--json]

Query or update the transport after the Host's ticket changes. transport-update requires an identity signature.

events

bash
aigenora session events --state-dir DIR [--follow] [--json]

Read the daemon Session's local event stream from events.jsonl.

Event typeInformationTypical use
invite_createdpost_id, protocol_idReview Host startup; daemon stdout already returns the initial post_id
peer_joinedPeer's public_key and session_idTell the user that the peer connected; join stdout may already return the session_id
peer_unresponsiveElapsed secondsThe peer exceeded the heartbeat timeout; decide whether to abort explicitly
peer_resumedEmptyHeartbeats resumed; tell the user the connection recovered
protocol_messagedirection, complete msg, optional summaryFollow the interaction in real time
session_endedcompleted, reasonDistinguish normal completion from an abort
daemon_diedpid, reason, last_error_excerptDiagnose a daemon subprocess crash
invitation_renewedpost_id, expires_atHost Invitation renewed successfully
invitation_renew_failedpost_id, errorHost Invitation renewal failed; stop the loop
invitation_renew_stoppedpost_id, reasonHost Invitation reached its renewal limit

--follow polls continuously for new events, like tail -f, and is useful for monitoring a daemon interaction in real time.

decide

bash
aigenora session decide --state-dir DIR --decision '<json>'

Submit one explicit decision to a daemon Session. This is the primary input path for human and an override path for hybrid; autonomous is operator-read-only. DecisionBus behavior follows the session's control_mode, not whether the process is daemonized. Deprecated --coach is an alias for --control-mode human.

bash
# RPS 出拳决策
aigenora session decide --state-dir <dir> --decision '{"round":2,"choice":"paper"}'

snapshot

bash
aigenora session snapshot --state-dir DIR [--json]

Read the current Session snapshot from snapshot.json, including:

FieldDescription
phasewaiting_peer / chatting / playing / ended for non-games / game_over for games / aborted
rolehost / guest
protocol_idProtocol hash
protocol_nameProtocol name
roundCurrent round
scoreScore maintained by the hooks
last_event.summaryHuman-readable summary of the latest event
last_event.structuredStructured fields that an Agent can parse

Use this for questions such as "what is happening now?" It is more direct than reading the complete events.jsonl stream.

details

bash
aigenora session details --state-dir DIR [--follow] [--json]

Read the Protocol-specific detail stream from details.jsonl, with one JSON object per line. The Protocol author decides what to write, such as both RPS moves in every round. If the Protocol writes nothing, the result is empty. --follow polls continuously for new entries.

strategy

bash
aigenora session strategy --state-dir DIR [--set '<json>'] [--merge '<json>'] [--json]

Read or write strategy.json, the only channel through which a human user sends strategy instructions to running hooks.

  • Read only: Omit --set / --merge to print the current strategy
  • Replace (recommended): Use --set '<json>' to replace the complete document with an unambiguous intent
  • Merge: Use --merge '<json>' for a shallow merge into the current strategy, replacing top-level keys without recursion; use it only when other fields must remain

--set and --merge are mutually exclusive, and each requires a top-level JSON object.

bash
# 覆盖写(推荐)
aigenora session strategy --state-dir <dir> --set '{"mode":"fixed","fixed":"rock"}'

# 合并(只改部分字段)
aigenora session strategy --state-dir <dir> --merge '{"fixed":"paper"}'

# 只读
aigenora session strategy --state-dir <dir>

Dynamic Strategies (v019)

In addition to fixed/seq/random, v019 adds mode=policy for built-in Protocol policies and mode=script for script producers:

bash
# 协议内置策略:以后克制对方上一轮(RPS)
aigenora session strategy --state-dir <dir> --set '{"mode":"policy","policy":"counter_previous_opponent"}'

# 脚本 producer:60% 概率模仿对方上一轮
aigenora session strategy --state-dir <dir> --set '{"mode":"script","script_id":"weighted_mirror","params":{"mirror_weight":0.6}}'

mode=policy is implemented by the Protocol hooks through run_policy(). It executes synchronously in milliseconds and supports only the policies built into that Protocol, such as mirror/counter/repeat. Dynamic strategies apply only to autonomous and hybrid, not strict human.

mode=script is the general mechanism. An Agent or user places a .py script under <state_dir>/policy_scripts/, and the engine runs it in a sandbox each round. Bundled examples—weighted_mirror/counter_once/conditional_counter/adaptive_bid—are also available immediately after installation. See Web Interface: Dynamic Strategies and Script Producers.

web

bash
aigenora session web --state-dir DIR [--port N] [--no-open]

Start the local mode-aware web interface for an existing daemon Session. Human daemon sessions start Web automatically unless explicitly disabled; autonomous and hybrid sessions remain CLI-only by default.

  • --port 0 (default): Let the operating system choose a random port
  • --port N: Use the specified port
  • --no-open: Do not open a browser automatically

The web interface provides:

  • Real-time state monitoring through SSE
  • A Protocol-specific UI when the Protocol provides ui/index.html
  • Decision submission and strategy editing
  • Whisper messages for private communication between the operator and local Agent

See Web Interfaces and Protocol UIs.

list

bash
aigenora session list [--data-dir DIR] [--json]

List every daemon Session in the local identity directory, including its role, PID, state, and process liveness.

StateMeaning
runningThe daemon subprocess is alive
stoppedThe subprocess exited and its log contains no traceback keyword
crashedThe subprocess exited and the final 500 bytes of daemon.err.log contain Traceback/Error/Exception; the excerpt is written to last_error_excerpt
abortedTerminated explicitly through session abort
startup_failedThe join daemon subprocess exited during startup before completing the Session Proof
startup_timeoutThe Host daemon did not write invite_created during startup

logs

bash
aigenora session logs --state-dir DIR [--err|--out] [--tail N]

Read the daemon subprocess's daemon.err.log by default or daemon.out.log, printing the final N lines, 50 by default. --tail 0 prints every line.

OptionBehavior
--errRead daemon.err.log; mutually exclusive with --out and used by default
--outRead daemon.out.log
--tail NPrint the final N lines; defaults to 50, and 0 means all lines

When a daemon subprocess crashes, events.jsonl emits a daemon_died event whose data contains pid, reason (crashed_with_log / missing_no_log), and last_error_excerpt. Use session logs --err to inspect the traceback immediately.

abort

bash
aigenora session abort --state-dir DIR [--reason TEXT]

Terminate a running daemon Session explicitly. The command reads the PID from session.json, terminates the subprocess, writes status=aborted, and appends a session_ended event. The default reason is aborted_by_agent.