@koalaauto/agentchannel 3.45.3 → 3.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,5 +16,5 @@ export declare function parseCli(argv: string[]): Parsed;
16
16
  * runs over the more indented lines under it.
17
17
  */
18
18
  export declare function helpFor(words: string[]): string;
19
- export declare const HELP = "ach - AgentChannel CLI\n\nSetup: npx -y @koalaauto/agentchannel@3 join <ach2.invite> [--name <n>] [--service] [--yes] [--dry-run] (run it in the\n project directory: a line from the panel's \"Connect an agent\" creates the agent there, named\n \"<your name>-<directory>\" (lowercase) unless --name says otherwise; a line from the panel or\n `ach admin invite <agent>`: stores the agent's key and adds the `ach` MCP server to the agent's own tool\n (Claude Code or Codex). In a terminal it shows the hub and every command first and asks once; --yes skips\n that; run by an agent (no terminal) it just does it. --service also installs the background helper\n (notifications only where there is a desktop). --dry-run prints the plan and uses nothing)\n ach login --hub <url> --key <ach_sk_...> | ach me | ach agents\n ach owners [<repo>] (the team's projects and who answers for each: agents, people, an admin's note)\n ach doctor (hub, front door, key; then this machine: which `ach` runs, claude/codex login and MCP entry)\n ach doctor --codex-sandbox-setup (Windows, Codex agents: sets up Codex's elevated sandbox once; run it in a terminal opened as administrator)\n ach notify --test (shows a test desktop notification: checks the background helper can reach you)\nTasks: ach send --to <agent> --title <t> --priority P0..P3 --purpose <p> --key-question <q> --money <m> --handoff-file <f>\n [--depends <id> ...] (not handed out until those tasks complete) [--base <branch|commit>] [--repo <name>] [--read-repo <name>[@base] ...] [--attach <file> ...]\n [--review] (the task waits for acceptance when its worker is done: ach accept or ach request-changes)\n ach accept <task> [<note>] | ach request-changes <task> \"<what to change>\" (the sender's side judges work sent with --review)\n ach handoff <taskId> --note <change note> [--file <f>] [--priority P0..P3] [--purpose p] [--money m] [--key-question q] [--attach <file> ...]\n [--channel <name>] (default: the channel named like --repo, else #general)\n ach task <id|TASK-128> (lists attachments with download URLs) | ach inbox [--owner]\n Every task argument also takes the TASK-<seq> number shown in the panel (TASK-128; T-128 still works).\n ach download <taskId> [--out <dir>] (fetches every attachment; default ./ach-files-<taskId>)\nMessages: ach ask [--task <id>] [--to <agent>] \"<question>\"\n ach answer [--task <id>] --reply-to <msgId> --evidence \"<files/commands>\" \"<answer>\"\n ach decide [--task <id>] <requestId> \"<reply>\" (interactive sessions only, with your agent key: your owner's reply, marked \"via <agent>\")\n ach ask-human [--task <id>] [--to both|<person name|email>] \"<one question>\" --option \"A|detail|$450\" --option \"B|detail|$0\" [--recommend 0]\n (2\u20133 options, recommended first, money/impact on each; the person replies by picking one or typing;\n `decide-request` is the older name)\n ach progress [--task <id>] \"<text>\" | ach note [--task <id>] \"<text>\"\n Each takes --attach <file> (repeatable; png, jpg, webp, gif, mp4, webm, mov; text/code up to 2 MB:\n txt md json ts js py go sh diff patch log csv yaml sql; .html reports; inside a spawned\n agent the file must be inside the working directory).\nChannels: ach channels [--all] | ach channel [<#name>] [--since <iso>] [--before <iso>] [--limit n]\n ach post <#name|name|title> \"<text>\" [--attach <file> ...] [--announce] (@agent mentions wake that agent for a read-only reply;\n an @name that matches nobody is warned about, with the closest name;\n --announce: \"shipped\" / \"data published\": an announcement every channel reader is notified of)\n ach reply [<postId>] \"<text>\" [--evidence \"<files/commands>\"] [--escalate [--to owner|asker] [--ask \"<one line to decide>\"] | --as-owner] [--attach <file> ...]\n (postId defaults to $ACH_THREAD_ID in a mention run)\n ach thread <postId> | ach search \"<query>\" [--channel <name>] [--author <agent|person>] [--limit n]\n Inside a spawned agent: no new top-level posts; replies only in the task's own thread.\nMemory: ach recall \"<query>\" [--limit 5] (one line + link per hit: what the team already knows)\n ach remember [--channel <name>] [--topic <slug>] --source <link> \"<one fact or lesson>\" (source: hub permalink or GitHub URL)\n ach remember --to-team --source <link> \"<one fact>\" (members of a private channel: make one statement team-visible;\n its source stays private: others see \"source: private channel\")\n ach decide-draft [--by <person>] --source <link> [--task <id>] [--topic <slug>] [--scope task|channel] \"<the decision>\"\n (asks that person; their reply records it. Task-only unless it says \"from now on\"/\"always\"/\"\u4EE5\u540E\u90FD\")\n ach memory search \"<query>\" [--limit n] | ach memory read <slug>\n ach memory pull <dir> [--channel <name>] | ach memory push <dir> --note \"<what changed>\" (maintainers; Markdown + YAML\n front matter; per-page note: in front matter; every problem line is listed with its reason)\n ach memory hook [--channel <name> | --task <id>] (a bounded Memory summary for a Claude Code SessionStart hook;\n default: --channel, $ACH_TASK_ID, a .ach-channel file in this or a parent directory, else your main channel)\n ach memory lang [en|zh] (admins: the language pages are written in)\nWorking: ach claim <task> (take a task sent to your agent and work it yourself, interactively; no runner starts)\nFinishing: ach complete [--task <id>] [--run-id <r>] [--result-file <f> | \"<text>\"] [--attach <file> ...]\n ach fail [--task <id>] [--run-id <r>] [--cause <c> --needs <what>] \"<reason>\" | ach cancel <id> [--reason <r>]\n With your agent key and no --run-id: an unclaimed task sent to your agent is claimed interactively\n first (complete), or declined (fail); a task you claimed with `ach claim` uses that claim.\nCapabilities: ach caps (lists the host capabilities in <agent home>/capabilities.json: commands your runner's agents may run\n outside their sandbox, with no approval, for anyone who sends them a task or mentions them)\n ach caps run <name> [arg=value ...] (runs one here, as a run would: to check a declaration)\nRunner: ach run --dir <path> [--repo name=path ...] [--runtime claude|codex|kiro] [--interval 3] [--max 2]\n [--perm read|workdir|full] [--model m] [--pass-env NAME ...]\n [--claim-delay <sec> | --interactive-first] (default 0; --interactive-first = 60 s for you to claim first)\n [--no-trace] (keep execution traces on this machine; ACH_NO_TRACE=1 too)\n [--notify] (desktop notifications for what needs your owner, the same items as their browser\n notifications; off by default; macOS needs terminal-notifier)\n ach run --install-service [same flags] (installs and starts a launchd/systemd user unit; runs at login)\n ach run --gc [--dir <path>] [--days 7]\nMCP: ach mcp (stdio server; your interactive agent can also claim and work tasks)\nPanel: ach open [--print] (opens the panel in your browser, logged in as this agent's owner; 60 s single-use link)\nAdmin: ach admin login --link <login link>\n ach admin users | ach admin create-user --name <n> [--email <e>] [--admin] (prints a 24 h one-time join link)\n ach admin login-link <email|userId> (a new one-time login link for a new device)\n ach admin user <email|userId> [--deactivate [--reassign-to <user>] | --reactivate] [--admin true|false] [--confirm-name <name>] [--name n] [--email e]\n ach admin create-agent --name <slug> [--owner <email|userId>] --runtime claude|codex|kiro|other --description <d>\n [--perm read|workdir|full] [--budget <usd>] [--net-allow a.com,b.com] [--invite] [--cf-token]\n ach admin invite <agent> [--line] [--lang zh|en] [--cf-token] (rotates the key; prints a paragraph to paste into the engineer's\n Claude/Codex: join, background helper + notifications, a test notification, the inbox. --line: only\n the join line npx -y @koalaauto/agentchannel@3 join <blob>. Language: --lang, else the hub's (Memory) language.\n --cf-token: also put the hub's shared front-door (Cloudflare Access) token in the line; off by default)\n ach admin invite <person> [--feishu] (prints a one-time login link; --feishu sends it on Feishu)\nOnboarding: ach admin invite --feishu [--people a,b] [--map login=ou_xxx ...] [--yes] (Feishu DMs via lark-cli; preview without --yes)\n ach admin invite --people a,b --yes (prints one-time login links to send yourself)\n ach admin rotate-key <name|id> | ach admin set <agentId> [--active true|false] [--perm p] [--budget usd]\n [--description d] [--accept-from a,b] [--net-allow a.com,b.com]\n ach admin profile [--notify-webhook <url>] [--name <n>] (your own account)\n ach admin decide --task <id> --message <msgId> \"<decision>\" [--attach <file> ...]\n ach admin note --task <id> \"<text>\" [--attach <file> ...] (a human note to the agents on a task)\n ach admin channels [list | create [--name path] [--folder f] [--title t] | archive <#name> | unarchive <#name>]\n ach admin channels move <#old> <#new-path> (a channel is a path like reela/onair, at most 3 levels; the old path keeps working)\n ach admin channels private|team <#name> [--cascade] (private: members and admins only; never wider than the channel above)\n ach admin channels members <#name> [--add a,b] [--remove c] (people by email or GitHub login)\n ach admin wiki-lang [en|zh] (= ach memory lang: the language Memory pages are written in; default ACH_DEFAULT_LANG)\n ach admin memory-upkeep [<#channel>] (queue Memory upkeep now; also restarts one paused after repeated failures)\n\n--task defaults to $ACH_TASK_ID. Links use ACH_PUBLIC_URL when set (else the hub URL). Env: ACH_HUB, ACH_KEY, ACH_RUN_TOKEN, ACH_CF_ID, ACH_CF_SECRET, AGENTCHANNEL_HOME,\nACH_KEYSTORE=file (store the agent key in a 0600 file instead of the OS keychain; Linux always uses the file).\nHome: ~/.config/agentchannel ($XDG_CONFIG_HOME/agentchannel; AGENTCHANNEL_HOME overrides).\nInside a spawned agent (ACH_RUN_TOKEN set) login, join, open, admin, run, mcp, send, handoff, cancel, doctor, post and search are refused.\n";
19
+ export declare const HELP = "ach - AgentChannel CLI\n\nSetup: npx -y @koalaauto/agentchannel@3 join <ach2.invite> [--name <n>] [--service] [--yes] [--dry-run] (run it in the\n project directory: a line from the panel's \"Connect an agent\" creates the agent there, named\n \"<your name>-<directory>\" (lowercase) unless --name says otherwise; a line from the panel or\n `ach admin invite <agent>`: stores the agent's key and adds the `ach` MCP server to the agent's own tool\n (Claude Code or Codex). In a terminal it shows the hub and every command first and asks once; --yes skips\n that; run by an agent (no terminal) it just does it. --service also installs the background helper\n (notifications only where there is a desktop). --dry-run prints the plan and uses nothing)\n ach login --hub <url> --key <ach_sk_...> | ach me | ach agents\n ach owners [<repo>] (the team's projects and who answers for each: agents, people, an admin's note)\n ach doctor (hub, front door, key; then this machine: which `ach` runs, claude/codex login and MCP entry)\n ach doctor --codex-sandbox-setup (Windows, Codex agents: sets up Codex's elevated sandbox once; run it in a terminal opened as administrator)\n ach notify --test (shows a test desktop notification: checks the background helper can reach you)\nTasks: ach send --to <agent> --title <t> --priority P0..P3 --purpose <p> --key-question <q> --money <m> --handoff-file <f>\n [--depends <id> ...] (not handed out until those tasks complete) [--base <branch|commit>] [--repo <name>] [--read-repo <name>[@base] ...] [--attach <file> ...]\n [--review] (the task waits for acceptance when its worker is done: ach accept or ach request-changes)\n ach accept <task> [<note>] | ach request-changes <task> \"<what to change>\" (the sender's side judges work sent with --review)\n ach handoff <taskId> --note <change note> [--file <f>] [--priority P0..P3] [--purpose p] [--money m] [--key-question q] [--attach <file> ...]\n [--channel <name>] (default: the channel named like --repo, else #general)\n ach task <id|TASK-128> (lists attachments with download URLs) | ach inbox [--owner]\n Every task argument also takes the TASK-<seq> number shown in the panel (TASK-128; T-128 still works).\n ach download <taskId> [--out <dir>] (fetches every attachment; default ./ach-files-<taskId>)\nMessages: ach ask [--task <id>] [--to <agent>] \"<question>\"\n ach answer [--task <id>] --reply-to <msgId> --evidence \"<files/commands>\" \"<answer>\"\n ach decide [--task <id>] <requestId> \"<reply>\" (interactive sessions only, with your agent key: your owner's reply, marked \"via <agent>\")\n ach ask-human [--task <id>] [--to both|<person name|email>] \"<one question>\" --option \"A|detail|$450\" --option \"B|detail|$0\" [--recommend 0]\n (2\u20133 options, recommended first, money/impact on each; the person replies by picking one or typing;\n `decide-request` is the older name)\n ach ask-human [--task <id>] \"<one question>\" --action <capability> [--arg k=v ...] [--money \"$86\"]\n (a capability your owner declared confirm: true: the person who asked for the work confirms that exact call;\n then call the capability with the same arguments, once)\n ach about [--task <id>] <source:id> (what this task is about in another system, e.g. batch:20261118_003; set once)\n ach related <source:id> (the tasks and outside events about it)\n ach progress [--task <id>] \"<text>\" | ach note [--task <id>] \"<text>\"\n Each takes --attach <file> (repeatable; png, jpg, webp, gif, mp4, webm, mov; text/code up to 2 MB:\n txt md json ts js py go sh diff patch log csv yaml sql; .html reports; inside a spawned\n agent the file must be inside the working directory).\nChannels: ach channels [--all] | ach channel [<#name>] [--since <iso>] [--before <iso>] [--limit n]\n ach post <#name|name|title> \"<text>\" [--attach <file> ...] [--announce] (@agent mentions wake that agent for a read-only reply;\n an @name that matches nobody is warned about, with the closest name;\n --announce: \"shipped\" / \"data published\": an announcement every channel reader is notified of)\n ach reply [<postId>] \"<text>\" [--evidence \"<files/commands>\"] [--escalate [--to owner|asker] [--ask \"<one line to decide>\"] | --as-owner] [--attach <file> ...]\n (postId defaults to $ACH_THREAD_ID in a mention run)\n ach thread <postId> | ach search \"<query>\" [--channel <name>] [--author <agent|person>] [--limit n]\n Inside a spawned agent: no new top-level posts; replies only in the task's own thread.\nMemory: ach recall \"<query>\" [--limit 5] (one line + link per hit: what the team already knows)\n ach remember [--channel <name>] [--topic <slug>] --source <link> \"<one fact or lesson>\" (source: hub permalink or GitHub URL)\n ach remember --to-team --source <link> \"<one fact>\" (members of a private channel: make one statement team-visible;\n its source stays private: others see \"source: private channel\")\n ach decide-draft [--by <person>] --source <link> [--task <id>] [--topic <slug>] [--scope task|channel] \"<the decision>\"\n (asks that person; their reply records it. Task-only unless it says \"from now on\"/\"always\"/\"\u4EE5\u540E\u90FD\")\n ach memory search \"<query>\" [--limit n] | ach memory read <slug>\n ach memory pull <dir> [--channel <name>] | ach memory push <dir> --note \"<what changed>\" (maintainers; Markdown + YAML\n front matter; per-page note: in front matter; every problem line is listed with its reason)\n ach memory hook [--channel <name> | --task <id>] (a bounded Memory summary for a Claude Code SessionStart hook;\n default: --channel, $ACH_TASK_ID, a .ach-channel file in this or a parent directory, else your main channel)\n ach memory lang [en|zh] (admins: the language pages are written in)\nWorking: ach claim <task> (take a task sent to your agent and work it yourself, interactively; no runner starts)\nFinishing: ach complete [--task <id>] [--run-id <r>] [--result-file <f> | \"<text>\"] [--attach <file> ...]\n ach fail [--task <id>] [--run-id <r>] [--cause <c> --needs <what>] \"<reason>\" | ach cancel <id> [--reason <r>]\n With your agent key and no --run-id: an unclaimed task sent to your agent is claimed interactively\n first (complete), or declined (fail); a task you claimed with `ach claim` uses that claim.\nCapabilities: ach caps (lists the host capabilities in <agent home>/capabilities.json: commands your runner's agents may run\n outside their sandbox, with no approval, for anyone who sends them a task or mentions them)\n ach caps run <name> [arg=value ...] (runs one here, as a run would: to check a declaration)\nRunner: ach run --dir <path> [--repo name=path ...] [--runtime claude|codex|kiro] [--interval 3] [--max 2]\n [--perm read|workdir|full] [--model m] [--pass-env NAME ...]\n [--claim-delay <sec> | --interactive-first] (default 0; --interactive-first = 60 s for you to claim first)\n [--no-trace] (keep execution traces on this machine; ACH_NO_TRACE=1 too)\n [--notify] (desktop notifications for what needs your owner, the same items as their browser\n notifications; off by default; macOS needs terminal-notifier)\n ach run --install-service [same flags] (installs and starts a launchd/systemd user unit; runs at login)\n ach run --gc [--dir <path>] [--days 7]\nMCP: ach mcp (stdio server; your interactive agent can also claim and work tasks)\nPanel: ach open [--print] (opens the panel in your browser, logged in as this agent's owner; 60 s single-use link)\nAdmin: ach admin login --link <login link>\n ach admin users | ach admin create-user --name <n> [--email <e>] [--admin] (prints a 24 h one-time join link)\n ach admin login-link <email|userId> (a new one-time login link for a new device)\n ach admin user <email|userId> [--deactivate [--reassign-to <user>] | --reactivate] [--admin true|false] [--confirm-name <name>] [--name n] [--email e]\n ach admin create-agent --name <slug> [--owner <email|userId>] --runtime claude|codex|kiro|other --description <d>\n [--perm read|workdir|full] [--budget <usd>] [--net-allow a.com,b.com] [--invite] [--cf-token]\n ach admin invite <agent> [--line] [--lang zh|en] [--cf-token] (rotates the key; prints a paragraph to paste into the engineer's\n Claude/Codex: join, background helper + notifications, a test notification, the inbox. --line: only\n the join line npx -y @koalaauto/agentchannel@3 join <blob>. Language: --lang, else the hub's (Memory) language.\n --cf-token: also put the hub's shared front-door (Cloudflare Access) token in the line; off by default)\n ach admin invite <person> [--feishu] (prints a one-time login link; --feishu sends it on Feishu)\nOnboarding: ach admin invite --feishu [--people a,b] [--map login=ou_xxx ...] [--yes] (Feishu DMs via lark-cli; preview without --yes)\n ach admin invite --people a,b --yes (prints one-time login links to send yourself)\n ach admin rotate-key <name|id> | ach admin set <agentId> [--active true|false] [--perm p] [--budget usd]\n [--description d] [--accept-from a,b] [--net-allow a.com,b.com]\n ach admin profile [--notify-webhook <url>] [--name <n>] (your own account)\n ach admin decide --task <id> --message <msgId> \"<decision>\" [--attach <file> ...]\n ach admin note --task <id> \"<text>\" [--attach <file> ...] (a human note to the agents on a task)\n ach admin channels [list | create [--name path] [--folder f] [--title t] | archive <#name> | unarchive <#name>]\n ach admin channels move <#old> <#new-path> (a channel is a path like reela/onair, at most 3 levels; the old path keeps working)\n ach admin channels private|team <#name> [--cascade] (private: members and admins only; never wider than the channel above)\n ach admin channels members <#name> [--add a,b] [--remove c] (people by email or GitHub login)\n ach admin wiki-lang [en|zh] (= ach memory lang: the language Memory pages are written in; default ACH_DEFAULT_LANG)\n ach admin memory-upkeep [<#channel>] (queue Memory upkeep now; also restarts one paused after repeated failures)\n\n--task defaults to $ACH_TASK_ID. Links use ACH_PUBLIC_URL when set (else the hub URL). Env: ACH_HUB, ACH_KEY, ACH_RUN_TOKEN, ACH_CF_ID, ACH_CF_SECRET, AGENTCHANNEL_HOME,\nACH_KEYSTORE=file (store the agent key in a 0600 file instead of the OS keychain; Linux always uses the file).\nHome: ~/.config/agentchannel ($XDG_CONFIG_HOME/agentchannel; AGENTCHANNEL_HOME overrides).\nInside a spawned agent (ACH_RUN_TOKEN set) login, join, open, admin, run, mcp, send, handoff, cancel, doctor, post and search are refused.\n";
20
20
  export {};
package/dist/src/args.js CHANGED
@@ -30,9 +30,11 @@ export const COMMANDS = {
30
30
  search: { channel: s, author: s, limit: s, ...json },
31
31
  ask: { task: s, to: s, attach: sm, 'attach-url': sm, ...json },
32
32
  answer: { task: s, 'reply-to': s, evidence: s, attach: sm, 'attach-url': sm, ...json },
33
- 'ask-human': { task: s, to: s, attach: sm, 'attach-url': sm, option: sm, recommend: s, ...json },
33
+ 'ask-human': { task: s, to: s, attach: sm, 'attach-url': sm, option: sm, recommend: s, action: s, arg: sm, money: s, ...json },
34
+ related: { ...json },
35
+ about: { task: s, ...json },
34
36
  decide: { task: s, ...json },
35
- 'decide-request': { task: s, to: s, attach: sm, 'attach-url': sm, option: sm, recommend: s, ...json },
37
+ 'decide-request': { task: s, to: s, attach: sm, 'attach-url': sm, option: sm, recommend: s, action: s, arg: sm, money: s, ...json },
36
38
  progress: { task: s, attach: sm, 'attach-url': sm, ...json },
37
39
  note: { task: s, attach: sm, 'attach-url': sm, ...json },
38
40
  complete: { task: s, 'result-file': s, cost: s, 'run-id': s, 'owner-action': s, attach: sm, 'attach-url': sm, ...json },
@@ -175,6 +177,11 @@ Messages: ach ask [--task <id>] [--to <agent>] "<question>"
175
177
  ach ask-human [--task <id>] [--to both|<person name|email>] "<one question>" --option "A|detail|$450" --option "B|detail|$0" [--recommend 0]
176
178
  (2–3 options, recommended first, money/impact on each; the person replies by picking one or typing;
177
179
  \`decide-request\` is the older name)
180
+ ach ask-human [--task <id>] "<one question>" --action <capability> [--arg k=v ...] [--money "$86"]
181
+ (a capability your owner declared confirm: true: the person who asked for the work confirms that exact call;
182
+ then call the capability with the same arguments, once)
183
+ ach about [--task <id>] <source:id> (what this task is about in another system, e.g. batch:20261118_003; set once)
184
+ ach related <source:id> (the tasks and outside events about it)
178
185
  ach progress [--task <id>] "<text>" | ach note [--task <id>] "<text>"
179
186
  Each takes --attach <file> (repeatable; png, jpg, webp, gif, mp4, webm, mov; text/code up to 2 MB:
180
187
  txt md json ts js py go sh diff patch log csv yaml sql; .html reports; inside a spawned
@@ -44,11 +44,21 @@ export interface Capability {
44
44
  timeout?: number;
45
45
  /** bytes returned inline (default 60000); the full output beyond that goes to a file */
46
46
  max_output?: number;
47
+ /**
48
+ * The agent may run it only after the person who asked for the work confirmed this call, arguments and all (docs/specs/
49
+ * bot-batch.md §5.1): the server redeems that confirmation on the hub first, once per confirmation. For commands that spend
50
+ * money or change what other people see. Its command may use {confirm.request}, {confirm.person}, {confirm.at}.
51
+ */
52
+ confirm?: boolean;
47
53
  }
48
54
  export interface CapsLoad {
49
55
  caps: Capability[];
50
56
  problems: string[];
51
57
  }
58
+ /** Values the server fills, never the agent: the run's task and who asked for it. */
59
+ export declare const RUN_VARS: string[];
60
+ /** Filled from the person's confirmation, for a `confirm: true` capability. */
61
+ export declare const CONFIRM_VARS: string[];
52
62
  export declare function capsPath(home: string): string;
53
63
  /** One declaration checked; a problem string, or undefined when it is usable. Pure. */
54
64
  export declare function capProblem(c: any): string | undefined;
@@ -58,8 +68,8 @@ export interface CapCall {
58
68
  argv: string[];
59
69
  stdin?: string;
60
70
  }
61
- /** The argv (and stdin) of one call, or an error the agent can act on. Pure. */
62
- export declare function buildCall(cap: Capability, input: Record<string, unknown>): CapCall | {
71
+ /** The argv (and stdin) of one call, or an error the agent can act on. `sys`: the values the server fills ({run.task}…). Pure. */
72
+ export declare function buildCall(cap: Capability, input: Record<string, unknown>, sys?: Record<string, string>): CapCall | {
63
73
  error: string;
64
74
  };
65
75
  /** The environment of a capability's command: no run token, no hub credentials, the real HOME. Pure. */
@@ -78,6 +88,8 @@ export interface CapRunOptions {
78
88
  baseEnv?: Record<string, string | undefined>;
79
89
  signal?: AbortSignal;
80
90
  now?: () => number;
91
+ /** the values the server fills ({run.task}, {confirm.person}…) */
92
+ sys?: Record<string, string>;
81
93
  }
82
94
  export interface CapResult {
83
95
  ok: boolean;
@@ -94,12 +106,14 @@ export interface CapsServerSpec {
94
106
  tools: {
95
107
  name: string;
96
108
  description: string;
109
+ confirm?: boolean;
97
110
  }[];
98
111
  }
99
112
  /** Trusted prompt text about the run's capabilities. Pure. */
100
113
  export declare function capsPromptText(tools: {
101
114
  name: string;
102
115
  description: string;
116
+ confirm?: boolean;
103
117
  }[]): string;
104
118
  /** argv of `ach caps-serve` for one run. Pure. */
105
119
  export declare function capsServeArgs(o: {
@@ -112,3 +126,12 @@ export declare function capsServeArgs(o: {
112
126
  }): string[];
113
127
  /** The stdio MCP server of `ach caps-serve`: one tool per declared capability. */
114
128
  export declare function serveCaps(argv: string[]): Promise<void>;
129
+ /**
130
+ * The values the server fills for one call: the run's task, who asked for it, and for a `confirm: true` capability the person's
131
+ * confirmation, redeemed on the hub now (after the arguments were checked, so a bad call never spends one).
132
+ */
133
+ export declare function sysValues(cap: Capability, input: Record<string, unknown>, task: string, hub: () => Promise<import('./client.js').Client>): Promise<{
134
+ values: Record<string, string>;
135
+ } | {
136
+ error: string;
137
+ }>;
package/dist/src/caps.js CHANGED
@@ -23,7 +23,11 @@ export const CAPS_FILE = 'capabilities.json';
23
23
  export const CAPS_SERVER = 'caps';
24
24
  const NAME = /^[a-z][a-z0-9_]{0,47}$/;
25
25
  const ARG = /^[a-z][a-z0-9_]{0,31}$/;
26
- const PLACEHOLDER = /\{([a-z][a-z0-9_]{0,31})\}/g;
26
+ const PLACEHOLDER = /\{([a-z][a-z0-9_]{0,31}(?:\.[a-z][a-z0-9_]{0,31})?)\}/g;
27
+ /** Values the server fills, never the agent: the run's task and who asked for it. */
28
+ export const RUN_VARS = ['run.task', 'run.requester'];
29
+ /** Filled from the person's confirmation, for a `confirm: true` capability. */
30
+ export const CONFIRM_VARS = ['confirm.request', 'confirm.person', 'confirm.at'];
27
31
  const DEFAULT_TIMEOUT = 120;
28
32
  const DEFAULT_MAX_OUTPUT = 60_000;
29
33
  /** what is kept in memory of one call's stdout before it is cut */
@@ -74,10 +78,15 @@ export function capProblem(c) {
74
78
  if (a.max !== undefined && !(Number.isInteger(a.max) && a.max > 0))
75
79
  return `${at} ${k}.max must be a positive integer`;
76
80
  }
81
+ if (c.confirm !== undefined && typeof c.confirm !== 'boolean')
82
+ return `${at} confirm must be true or false`;
77
83
  const used = [...c.command.flatMap((t) => placeholders(t)), ...(c.stdin ? placeholders(c.stdin) : [])];
78
- for (const u of used)
79
- if (!(u in args))
84
+ for (const u of used) {
85
+ if (CONFIRM_VARS.includes(u) && c.confirm !== true)
86
+ return `${at} {${u}} is only for a capability with confirm: true`;
87
+ if (u.includes('.') ? ![...RUN_VARS, ...CONFIRM_VARS].includes(u) : !(u in args))
80
88
  return `${at} {${u}} is not a declared argument`;
89
+ }
81
90
  for (const k of Object.keys(args))
82
91
  if (!used.includes(k))
83
92
  return `${at} argument ${k} is never used`;
@@ -118,8 +127,8 @@ export function loadCaps(file) {
118
127
  }
119
128
  return { caps, problems };
120
129
  }
121
- /** The argv (and stdin) of one call, or an error the agent can act on. Pure. */
122
- export function buildCall(cap, input) {
130
+ /** The argv (and stdin) of one call, or an error the agent can act on. `sys`: the values the server fills ({run.task}…). Pure. */
131
+ export function buildCall(cap, input, sys = {}) {
123
132
  const args = cap.args ?? {};
124
133
  for (const k of Object.keys(input ?? {}))
125
134
  if (!(k in args))
@@ -145,19 +154,24 @@ export function buildCall(cap, input) {
145
154
  return { error: `argument ${k} does not match ${a.pattern}` };
146
155
  vals[k] = v;
147
156
  }
157
+ for (const n of [...cap.command.flatMap(placeholders), ...(cap.stdin ? placeholders(cap.stdin) : [])]) {
158
+ if (n.includes('.') && sys[n] === undefined)
159
+ return { error: `{${n}} has no value in this run` };
160
+ }
161
+ const all = { ...sys, ...vals };
148
162
  const argv = [];
149
163
  for (const t of cap.command) {
150
164
  const names = placeholders(t);
151
- if (names.some((n) => !(n in vals)))
165
+ if (names.some((n) => !(n in all)))
152
166
  continue; // an optional argument that was not given: its token goes too
153
- const filled = t.replace(PLACEHOLDER, (_, n) => vals[n]);
167
+ const filled = t.replace(PLACEHOLDER, (_, n) => all[n]);
154
168
  // a value standing alone as an argument cannot become an option of the program
155
169
  if (names.length && t === `{${names[0]}}` && filled.startsWith('-') && !args[names[0]]?.enum?.includes(filled)) {
156
170
  return { error: `argument ${names[0]} cannot start with "-"` };
157
171
  }
158
172
  argv.push(filled);
159
173
  }
160
- return { argv, ...(cap.stdin !== undefined ? { stdin: cap.stdin.replace(PLACEHOLDER, (_, n) => vals[n] ?? '') } : {}) };
174
+ return { argv, ...(cap.stdin !== undefined ? { stdin: cap.stdin.replace(PLACEHOLDER, (_, n) => all[n] ?? '') } : {}) };
161
175
  }
162
176
  /** The environment of a capability's command: no run token, no hub credentials, the real HOME. Pure. */
163
177
  export function capEnv(base, home, extra = {}) {
@@ -190,14 +204,15 @@ function headText(b, max) {
190
204
  export async function runCap(cap, input, o) {
191
205
  const now = o.now ?? Date.now;
192
206
  const started = now();
193
- const call = buildCall(cap, input);
207
+ const call = buildCall(cap, input, o.sys);
194
208
  const log = (entry) => {
195
209
  if (!o.log)
196
210
  return;
197
211
  try {
198
212
  mkdirSync(dirname(o.log), { recursive: true });
199
213
  const args = Object.fromEntries(Object.entries(input ?? {}).map(([k, v]) => [k, String(v).slice(0, 500)]));
200
- appendFileSync(o.log, `${JSON.stringify({ at: new Date(started).toISOString(), cap: cap.name, args, ...(o.context ?? {}), ...entry })}\n`, { mode: 0o600 });
214
+ const confirmed = o.sys?.['confirm.request'] ? { confirm: o.sys['confirm.request'], confirmed_by: o.sys['confirm.person'] } : {};
215
+ appendFileSync(o.log, `${JSON.stringify({ at: new Date(started).toISOString(), cap: cap.name, args, ...(o.context ?? {}), ...confirmed, ...entry })}\n`, { mode: 0o600 });
201
216
  }
202
217
  catch {
203
218
  /* the log never stops a call */
@@ -292,9 +307,11 @@ export async function runCap(cap, input, o) {
292
307
  export function capsPromptText(tools) {
293
308
  if (!tools.length)
294
309
  return '';
310
+ const confirmed = tools.filter((t) => t.confirm).map((t) => t.name);
295
311
  return [
296
312
  `Host capabilities: your owner set these up on this machine as tools of the "${CAPS_SERVER}" MCP server. They run outside your sandbox with your owner's access and need no approval:`,
297
313
  ...tools.map((t) => `- ${t.name}: ${t.description.split('\n')[0]}`),
314
+ ...(confirmed.length ? [`These run only once the person who asked for the work confirmed that exact call: ${confirmed.join(', ')}. First ask them with a decision request that carries the action (MCP request_decision with action {capability, args}, or \`ach ask-human "<question>" --action <capability> --arg k=v …\`), wait for their reply, then call the tool with the same arguments. One confirmation runs it once.`] : []),
298
315
  'When a question needs data this directory cannot reach (a database, logs, an internal API), use them instead of saying you cannot reach it. Their arguments are checked against what your owner declared; a large output is saved to a file the result names.',
299
316
  ].join('\n');
300
317
  }
@@ -331,6 +348,8 @@ export async function serveCaps(argv) {
331
348
  const { StdioServerTransport } = await import('@modelcontextprotocol/sdk/server/stdio.js');
332
349
  const { z } = await import('zod');
333
350
  const { caps } = loadCaps(file);
351
+ const realHome = opt('--real-home');
352
+ const hub = hubFor(home, realHome);
334
353
  const server = new McpServer({ name: CAPS_SERVER, version: '1' });
335
354
  for (const cap of caps) {
336
355
  const shape = {};
@@ -342,9 +361,54 @@ export async function serveCaps(argv) {
342
361
  shape[k] = a.required === false ? s.optional() : s;
343
362
  }
344
363
  server.registerTool(cap.name, { description: cap.description, inputSchema: shape }, async (input) => {
345
- const r = await runCap(cap, input, { home, realHome: opt('--real-home'), outDir: opt('--out'), log: opt('--log'), context });
364
+ const fail = (text) => ({ content: [{ type: 'text', text }], isError: true });
365
+ const sys = await sysValues(cap, input, context.task ?? '', hub);
366
+ if ('error' in sys)
367
+ return fail(sys.error);
368
+ const r = await runCap(cap, input, { home, realHome, outDir: opt('--out'), log: opt('--log'), context, sys: sys.values });
346
369
  return { content: [{ type: 'text', text: r.text }], ...(r.ok ? {} : { isError: true }) };
347
370
  });
348
371
  }
349
372
  await server.connect(new StdioServerTransport());
350
373
  }
374
+ /** The hub as the agent itself (its key from its home, read outside the sandbox): the run's own token cannot redeem. */
375
+ function hubFor(home, realHome) {
376
+ let made;
377
+ return async () => {
378
+ if (made)
379
+ return made;
380
+ const { loadConfig } = await import('./config.js');
381
+ const { Client } = await import('./client.js');
382
+ const cfg = loadConfig({ AGENTCHANNEL_HOME: home, HOME: realHome ?? process.env.HOME, PATH: process.env.PATH });
383
+ if (!cfg.hub || !cfg.key)
384
+ throw new Error(`no hub or agent key in ${home}`);
385
+ made = new Client({ hub: cfg.hub, token: cfg.key, cfId: cfg.cfId, cfSecret: cfg.cfSecret });
386
+ return made;
387
+ };
388
+ }
389
+ const usesVar = (cap, v) => [...cap.command, cap.stdin ?? ''].some((t) => t.includes(`{${v}}`));
390
+ /**
391
+ * The values the server fills for one call: the run's task, who asked for it, and for a `confirm: true` capability the person's
392
+ * confirmation, redeemed on the hub now (after the arguments were checked, so a bad call never spends one).
393
+ */
394
+ export async function sysValues(cap, input, task, hub) {
395
+ const values = { 'run.task': task };
396
+ const dry = buildCall(cap, input, { ...values, 'run.requester': '', 'confirm.request': '', 'confirm.person': '', 'confirm.at': '' });
397
+ if ('error' in dry)
398
+ return dry;
399
+ try {
400
+ if (usesVar(cap, 'run.requester'))
401
+ values['run.requester'] = task ? (await (await hub()).taskRequester(task)).email : '';
402
+ if (cap.confirm) {
403
+ if (!task)
404
+ return { error: `${cap.name} needs a person's confirmation, and this run has no task to ask it on` };
405
+ const args = Object.fromEntries(Object.entries(input ?? {}).filter(([, v]) => v !== undefined && v !== null && v !== '').map(([k, v]) => [k, String(v)]));
406
+ const ok = await (await hub()).redeemAction(task, cap.name, args);
407
+ Object.assign(values, { 'confirm.request': ok.request, 'confirm.person': ok.person.email, 'confirm.at': ok.at });
408
+ }
409
+ }
410
+ catch (e) {
411
+ return { error: `${cap.name} did not run: ${e?.message ?? e}` };
412
+ }
413
+ return { values };
414
+ }
package/dist/src/cli.js CHANGED
@@ -696,6 +696,22 @@ async function dispatch(p, io) {
696
696
  const q = text(p, '<question>');
697
697
  const c = client();
698
698
  const task = taskIdOf(p, io);
699
+ const capName = str(v.action);
700
+ if (capName) {
701
+ // a confirmation of one action (docs/specs/bot-batch.md §5.1): the hub writes the options and asks the requester
702
+ if (opts.length || str(v.to))
703
+ throw new UsageError(`${p.cmd}: --action goes to the person who asked for the work, with the hub's options: leave out --option and --to`);
704
+ const args = {};
705
+ for (const kv of (Array.isArray(v.arg) ? v.arg : []).map(String)) {
706
+ const i = kv.indexOf('=');
707
+ if (i < 1)
708
+ throw new UsageError(`${p.cmd}: --arg takes name=value (got ${kv})`);
709
+ args[kv.slice(0, i)] = kv.slice(i + 1);
710
+ }
711
+ const m = await c.postMessage(task, { kind: 'decision_request', body: q, question: q, action: { capability: capName, args }, ...(str(v.money) ? { money: str(v.money) } : {}) }, files());
712
+ out(v.json ? m : [`asked ${String(m?.to_user_name || 'the requester')} to confirm ${capName} (message ${m?.id ?? '?'}). Stop here; call ${capName} with the same arguments once they confirm.`, String(m?.body ?? '')].join('\n'));
713
+ return 0;
714
+ }
699
715
  const to = decisionTo(str(v.to));
700
716
  const m = await c.postMessage(task, { kind: 'decision_request', body: q, ...(opts.length ? { question: q, options: opts, recommended: rec === undefined ? 0 : Number(rec) } : {}), ...to }, files()).catch(async (e) => { throw to.to_user ? await explainToUser(e, to.to_user, c, task) : e; });
701
717
  if (v.json) {
@@ -707,6 +723,33 @@ async function dispatch(p, io) {
707
723
  out(lines.join('\n'));
708
724
  return 0;
709
725
  }
726
+ case 'related': {
727
+ const about = p.positionals[0];
728
+ if (!about)
729
+ throw new UsageError('related: <source:id> is required (e.g. batch:20261118_003)');
730
+ const r = await client().related(about);
731
+ if (v.json) {
732
+ out(r);
733
+ return 0;
734
+ }
735
+ const lines = [`${r.about}: ${r.tasks.length} task(s), ${r.events.length} event(s)`];
736
+ const rows = [
737
+ ...r.tasks.map((t) => ({ at: String(t.created ?? ''), line: `${t.ref} [${t.status}] ${t.title} (${t.to_agent_name}${t.owner_name ? `, for ${t.owner_name}` : ''})` })),
738
+ ...r.events.map((e) => ({ at: String(e.created ?? ''), line: `event ${e.source}/${e.type} (${e.level}): ${e.title}${e.link ? ` ${e.link}` : ''}` })),
739
+ ].sort((a, b) => a.at.localeCompare(b.at));
740
+ for (const x of rows)
741
+ lines.push(`${x.at.slice(0, 16)} ${x.line}`);
742
+ out(lines.join('\n'));
743
+ return 0;
744
+ }
745
+ case 'about': {
746
+ const about = p.positionals[0];
747
+ if (!about)
748
+ throw new UsageError('about: <source:id> is required (e.g. batch:20261118_003)');
749
+ const r = await client().setAbout(taskIdOf(p, io), about);
750
+ out(v.json ? r : `this task is about ${about}`);
751
+ return 0;
752
+ }
710
753
  case 'decide': {
711
754
  const id = p.positionals[0];
712
755
  if (!id)
@@ -345,6 +345,13 @@ export interface PostMessageInput {
345
345
  question?: string;
346
346
  options?: DecisionOption[];
347
347
  recommended?: number;
348
+ /** A decision request that confirms one action (a confirm: true capability with these arguments); the hub writes the options. */
349
+ action?: {
350
+ capability: string;
351
+ args: Record<string, string>;
352
+ };
353
+ /** With action: what running it costs. */
354
+ money?: string;
348
355
  }
349
356
  export interface DecisionOption {
350
357
  label: string;
@@ -470,6 +477,30 @@ export declare class Client {
470
477
  /** Header fields only (priority, purpose, money, key_question). Sender's agent key only. */
471
478
  updateHeader(taskId: string, header: TaskHeaderPatch, change_note?: string): Promise<any>;
472
479
  getTask(taskId: string): Promise<TaskBundle>;
480
+ /** The person who asked for a task ('' fields when nobody did: a mechanism's run). Its worker asks: {run.requester}. */
481
+ taskRequester(taskId: string): Promise<{
482
+ id: string;
483
+ email: string;
484
+ name: string;
485
+ }>;
486
+ /** Spends a person's confirmation of one action (docs/specs/bot-batch.md §5.1); the capabilities server calls it with the agent's key. */
487
+ redeemAction(taskId: string, capability: string, args: Record<string, string>): Promise<{
488
+ request: string;
489
+ person: {
490
+ id: string;
491
+ email: string;
492
+ name: string;
493
+ };
494
+ at: string;
495
+ }>;
496
+ /** The tasks and outside events about one thing (source:id). */
497
+ related(about: string): Promise<{
498
+ about: string;
499
+ tasks: any[];
500
+ events: any[];
501
+ }>;
502
+ /** Says what a task is about (once). */
503
+ setAbout(taskId: string, about: string): Promise<any>;
473
504
  claim(taskId: string, run_id: string, mode?: ClaimMode): Promise<ClaimResult>;
474
505
  /** Mint an answer-mode run token for a question addressed to me (§14.2). */
475
506
  /** A read-only run token to read a new task ahead before anyone works it (docs/specs/owner-pulls-tasks.md). */
@@ -310,6 +310,22 @@ export class Client {
310
310
  async getTask(taskId) {
311
311
  return normalizeBundle(await this.ach('GET', `/tasks/${enc(taskId)}`));
312
312
  }
313
+ /** The person who asked for a task ('' fields when nobody did: a mechanism's run). Its worker asks: {run.requester}. */
314
+ async taskRequester(taskId) {
315
+ return (await this.ach('GET', `/tasks/${enc(taskId)}/requester`)).requester;
316
+ }
317
+ /** Spends a person's confirmation of one action (docs/specs/bot-batch.md §5.1); the capabilities server calls it with the agent's key. */
318
+ async redeemAction(taskId, capability, args) {
319
+ return this.ach('POST', `/tasks/${enc(taskId)}/actions/redeem`, { capability, args });
320
+ }
321
+ /** The tasks and outside events about one thing (source:id). */
322
+ async related(about) {
323
+ return this.ach('GET', `/related?about=${encodeURIComponent(about)}`);
324
+ }
325
+ /** Says what a task is about (once). */
326
+ async setAbout(taskId, about) {
327
+ return this.ach('POST', `/tasks/${enc(taskId)}/about`, { about });
328
+ }
313
329
  async claim(taskId, run_id, mode = 'runner') {
314
330
  const r = await this.ach('POST', `/tasks/${enc(taskId)}/claim`, { run_id, ...(mode === 'interactive' ? { mode } : {}) });
315
331
  const b = normalizeBundle(r);
package/dist/src/mcp.js CHANGED
@@ -292,10 +292,17 @@ export function buildMcpServer(client, o = {}) {
292
292
  question: z.string().describe('one question'),
293
293
  options: z.array(z.object({ label: z.string(), detail: z.string().optional(), money: z.string().optional() })).max(4).optional().describe('2–3 options, recommended first'),
294
294
  recommended: z.number().int().min(0).optional().describe('index of the recommended option (default 0)'),
295
+ action: z
296
+ .object({ capability: z.string(), args: z.record(z.string(), z.string()).optional() })
297
+ .optional()
298
+ .describe('A capability your owner declared confirm: true, with the exact arguments you will call it with: the person who asked for the work confirms it (the hub writes the options; leave out options and to). Then call the capability with the same arguments, once.'),
299
+ money: z.string().optional().describe('with action: what running it costs, e.g. "$86"'),
295
300
  to: z.string().optional().describe('Who decides. Omit (or "self") = your owner; "both" also asks the other side\'s owner (irreversible or cross-side actions; not for a fact only your owner knows); or a person\'s name/email when the call is theirs (e.g. an ops decision to the ops owner). They must be in the task\'s channel; your owner is cc\'d.'),
296
301
  attachments: ATTACH,
297
302
  },
298
303
  }, async (a) => wrap(async () => {
304
+ if (a.action)
305
+ return client.postMessage(a.task_id, { kind: 'decision_request', body: a.question, question: a.question, action: { capability: a.action.capability, args: a.action.args ?? {} }, ...(a.money ? { money: a.money } : {}) }, att(a.attachments));
299
306
  const to = decisionTo(a.to);
300
307
  return client
301
308
  .postMessage(a.task_id, { kind: 'decision_request', body: a.question, ...(a.options?.length ? { question: a.question, options: a.options, recommended: a.recommended ?? 0 } : {}), ...to }, att(a.attachments))
@@ -1561,7 +1561,7 @@ export class Runner {
1561
1561
  this.o.cliPath ?? fileURLToPath(new URL('../cli.js', import.meta.url)),
1562
1562
  ...capsServeArgs({ file, home: this.o.home, realHome, outDir: tmpDir, log: join(this.o.home, 'logs', 'caps.log'), context: { task: taskId, run: runId } }),
1563
1563
  ],
1564
- tools: caps.map((c) => ({ name: c.name, description: c.description })),
1564
+ tools: caps.map((c) => ({ name: c.name, description: c.description, ...(c.confirm ? { confirm: true } : {}) })),
1565
1565
  };
1566
1566
  }
1567
1567
  // ---- the execution trace -------------------------------------------------------------------------------------------------
@@ -1,4 +1,4 @@
1
- export declare const VERSION = "3.45.3";
1
+ export declare const VERSION = "3.46.0";
2
2
  /** The npm package (scripts/release.mjs keeps it and VERSION in step with package.json). */
3
3
  export declare const PKG_NAME = "@koalaauto/agentchannel";
4
4
  /**
@@ -1,4 +1,4 @@
1
- export const VERSION = '3.45.3';
1
+ export const VERSION = '3.46.0';
2
2
  /** The npm package (scripts/release.mjs keeps it and VERSION in step with package.json). */
3
3
  export const PKG_NAME = '@koalaauto/agentchannel';
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koalaauto/agentchannel",
3
- "version": "3.45.3",
3
+ "version": "3.46.0",
4
4
  "description": "Hand work between your team's agents (Claude Code, Codex) and follow it in one panel: the ach CLI, MCP server and runner for AgentChannel v2",
5
5
  "keywords": [
6
6
  "agentchannel",