agora.observe.commands

/agora <verb> <args> directive parser.

Human observers type commands in any room. The sync loop routes m.room.message events to parse_command(), which returns a ParsedCommand or None (for non-agora messages). The orchestrator registers a handler that maps verbs to side effects (notes, redirects, pause/resume/abort, review votes).

The grammar is forgiving:

  • /agora note <text> — attach a free-form note to the target room.

  • /agora pause / /agora resume — toggle the orchestrator’s run gate.

  • /agora abort [reason] — cancel the current project.

  • /agora redirect <agent_name> <new instructions> — update agent instructions.

  • /agora review <answer_id> — fallback for clients that can’t render polls.

  • /agora help — the renderer responds with a usage block.

Functions

as_dict(cmd)

parse_command(body[, sender])

Return a ParsedCommand if body starts with /agora, else None.

validate(cmd)

Return (ok, reason).

Classes

ParsedCommand

A parsed /agora <verb> <args> directive.

class agora.observe.commands.ParsedCommand[source]

Bases: object

A parsed /agora <verb> <args> directive. args is the whitespace split (kept for free-text verbs like note); argv is the shlex tokenization (for verbs with quoted arguments). raw/sender preserve provenance for the audit log.

verb: str
args: tuple[str, ...]
raw: str
sender: str
argv: tuple[str, ...] = ()
property argline: str

The raw argument string after the verb (useful for free-text args).

__init__(verb, args, raw, sender, argv=())
agora.observe.commands.parse_command(body, sender='')[source]

Return a ParsedCommand if body starts with /agora, else None.

Malformed commands (unknown verbs, missing required args) still return a ParsedCommand with verb=help-style fallback — the caller emits usage.

agora.observe.commands.validate(cmd)[source]

Return (ok, reason). Use in handlers to emit usage on failure.

agora.observe.commands.as_dict(cmd)[source]