session Management
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
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
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
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
aigenora session events --state-dir DIR [--follow] [--json]Read the daemon Session's local event stream from events.jsonl.
| Event type | Information | Typical use |
|---|---|---|
invite_created | post_id, protocol_id | Review Host startup; daemon stdout already returns the initial post_id |
peer_joined | Peer's public_key and session_id | Tell the user that the peer connected; join stdout may already return the session_id |
peer_unresponsive | Elapsed seconds | The peer exceeded the heartbeat timeout; decide whether to abort explicitly |
peer_resumed | Empty | Heartbeats resumed; tell the user the connection recovered |
protocol_message | direction, complete msg, optional summary | Follow the interaction in real time |
session_ended | completed, reason | Distinguish normal completion from an abort |
daemon_died | pid, reason, last_error_excerpt | Diagnose a daemon subprocess crash |
invitation_renewed | post_id, expires_at | Host Invitation renewed successfully |
invitation_renew_failed | post_id, error | Host Invitation renewal failed; stop the loop |
invitation_renew_stopped | post_id, reason | Host 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
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.
# RPS 出拳决策
aigenora session decide --state-dir <dir> --decision '{"round":2,"choice":"paper"}'snapshot
aigenora session snapshot --state-dir DIR [--json]Read the current Session snapshot from snapshot.json, including:
| Field | Description |
|---|---|
phase | waiting_peer / chatting / playing / ended for non-games / game_over for games / aborted |
role | host / guest |
protocol_id | Protocol hash |
protocol_name | Protocol name |
round | Current round |
score | Score maintained by the hooks |
last_event.summary | Human-readable summary of the latest event |
last_event.structured | Structured 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
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
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/--mergeto 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.
# 覆盖写(推荐)
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:
# 协议内置策略:以后克制对方上一轮(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
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
aigenora session list [--data-dir DIR] [--json]List every daemon Session in the local identity directory, including its role, PID, state, and process liveness.
| State | Meaning |
|---|---|
running | The daemon subprocess is alive |
stopped | The subprocess exited and its log contains no traceback keyword |
crashed | The subprocess exited and the final 500 bytes of daemon.err.log contain Traceback/Error/Exception; the excerpt is written to last_error_excerpt |
aborted | Terminated explicitly through session abort |
startup_failed | The join daemon subprocess exited during startup before completing the Session Proof |
startup_timeout | The Host daemon did not write invite_created during startup |
logs
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.
| Option | Behavior |
|---|---|
--err | Read daemon.err.log; mutually exclusive with --out and used by default |
--out | Read daemon.out.log |
--tail N | Print 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
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.