@koalaauto/agentchannel 3.45.3 → 3.47.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.
- package/dist/src/args.d.ts +1 -1
- package/dist/src/args.js +13 -4
- package/dist/src/attachments.d.ts +1 -1
- package/dist/src/attachments.js +7 -4
- package/dist/src/caps.d.ts +25 -2
- package/dist/src/caps.js +75 -11
- package/dist/src/cli.js +58 -2
- package/dist/src/client.d.ts +33 -0
- package/dist/src/client.js +18 -1
- package/dist/src/mcp.js +29 -5
- package/dist/src/runner/runner.js +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
package/dist/src/args.d.ts
CHANGED
|
@@ -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, pdf, zip; 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 post <#name> --card '<json>' | --card @card.json (a card instead of text, e.g. a #product-log entry:\n {\"type\":\"change\",\"tag\":\"feature|fix|change\",\"title\",\"summary\",\"audience\",\"env\",\"refs\":[links]})\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
|
@@ -24,15 +24,17 @@ export const COMMANDS = {
|
|
|
24
24
|
inbox: { owner: b, ...json },
|
|
25
25
|
channels: { all: b, ...json },
|
|
26
26
|
channel: { since: s, before: s, limit: s, ...json },
|
|
27
|
-
post: { attach: sm, 'attach-url': sm, announce: b, ...json },
|
|
27
|
+
post: { attach: sm, 'attach-url': sm, announce: b, card: s, ...json },
|
|
28
28
|
reply: { evidence: s, escalate: b, to: s, ask: s, 'as-owner': b, attach: sm, 'attach-url': sm, ...json },
|
|
29
29
|
thread: { ...json },
|
|
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,14 +177,21 @@ 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
|
-
Each takes --attach <file> (repeatable; png, jpg, webp, gif, mp4, webm, mov; text/code up to 2 MB:
|
|
186
|
+
Each takes --attach <file> (repeatable; png, jpg, webp, gif, mp4, webm, mov, pdf, zip; 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
|
|
181
188
|
agent the file must be inside the working directory).
|
|
182
189
|
Channels: ach channels [--all] | ach channel [<#name>] [--since <iso>] [--before <iso>] [--limit n]
|
|
183
190
|
ach post <#name|name|title> "<text>" [--attach <file> ...] [--announce] (@agent mentions wake that agent for a read-only reply;
|
|
184
191
|
an @name that matches nobody is warned about, with the closest name;
|
|
185
192
|
--announce: "shipped" / "data published": an announcement every channel reader is notified of)
|
|
193
|
+
ach post <#name> --card '<json>' | --card @card.json (a card instead of text, e.g. a #product-log entry:
|
|
194
|
+
{"type":"change","tag":"feature|fix|change","title","summary","audience","env","refs":[links]})
|
|
186
195
|
ach reply [<postId>] "<text>" [--evidence "<files/commands>"] [--escalate [--to owner|asker] [--ask "<one line to decide>"] | --as-owner] [--attach <file> ...]
|
|
187
196
|
(postId defaults to $ACH_THREAD_ID in a mention run)
|
|
188
197
|
ach thread <postId> | ach search "<query>" [--channel <name>] [--author <agent|person>] [--limit n]
|
|
@@ -59,5 +59,5 @@ export interface StorageConfig {
|
|
|
59
59
|
}
|
|
60
60
|
/** The upload target for a hub route: task:<id>, post:<id>, channel:<name>, or new_task (POST /tasks). */
|
|
61
61
|
export declare function uploadTarget(path: string): string | null;
|
|
62
|
-
/** Files that should go straight to the bucket:
|
|
62
|
+
/** Files that should go straight to the bucket: binary files over the hub's threshold. */
|
|
63
63
|
export declare function bigFiles(files: string[], cfg: StorageConfig | null): string[];
|
package/dist/src/attachments.js
CHANGED
|
@@ -12,6 +12,8 @@ export const ATTACH_TYPES = {
|
|
|
12
12
|
mp4: 'video/mp4',
|
|
13
13
|
webm: 'video/webm',
|
|
14
14
|
mov: 'video/quicktime',
|
|
15
|
+
pdf: 'application/pdf',
|
|
16
|
+
zip: 'application/zip',
|
|
15
17
|
// §17: text and code (≤ 2 MB each, previewed as escaped text) and .html reports
|
|
16
18
|
// (previewed only in a sandboxed iframe; downloaded as text/plain).
|
|
17
19
|
txt: 'text/plain',
|
|
@@ -33,7 +35,8 @@ export const ATTACH_TYPES = {
|
|
|
33
35
|
htm: 'text/html',
|
|
34
36
|
};
|
|
35
37
|
export const TEXT_MAX_BYTES = 2 * 1024 * 1024;
|
|
36
|
-
|
|
38
|
+
/** Checked by content on the hub and held to the file cap, not the 2 MB text cap. */
|
|
39
|
+
const BINARY_EXT = new Set(['png', 'jpg', 'jpeg', 'webp', 'gif', 'mp4', 'webm', 'mov', 'pdf', 'zip']);
|
|
37
40
|
export const MAX_ATTACHMENTS = 10;
|
|
38
41
|
/** An `--attach`/`--attach-url` entry that references an object by URL instead of uploading it. */
|
|
39
42
|
export function isLinkRef(p) {
|
|
@@ -101,7 +104,7 @@ export function resolveAttachments(paths, io) {
|
|
|
101
104
|
if (!typeOf(real))
|
|
102
105
|
throw new AttachError(`attachment ${p}: only ${Object.keys(ATTACH_TYPES).join(', ')} files are accepted`);
|
|
103
106
|
const ext = (/\.([A-Za-z0-9]+)$/.exec(real)?.[1] ?? '').toLowerCase();
|
|
104
|
-
if (!
|
|
107
|
+
if (!BINARY_EXT.has(ext) && statSync(real).size > TEXT_MAX_BYTES)
|
|
105
108
|
throw new AttachError(`attachment ${p}: text files are limited to 2 MB`);
|
|
106
109
|
return real;
|
|
107
110
|
});
|
|
@@ -218,10 +221,10 @@ export function uploadTarget(path) {
|
|
|
218
221
|
return `channel:${decodeURIComponent(m[1])}`;
|
|
219
222
|
return null;
|
|
220
223
|
}
|
|
221
|
-
/** Files that should go straight to the bucket:
|
|
224
|
+
/** Files that should go straight to the bucket: binary files over the hub's threshold. */
|
|
222
225
|
export function bigFiles(files, cfg) {
|
|
223
226
|
if (!cfg || !cfg.direct_upload)
|
|
224
227
|
return [];
|
|
225
228
|
const min = cfg.direct_threshold_mb * 1048576;
|
|
226
|
-
return files.filter((f) => !isLinkRef(f) &&
|
|
229
|
+
return files.filter((f) => !isLinkRef(f) && BINARY_EXT.has((/\.([A-Za-z0-9]+)$/.exec(f)?.[1] ?? '').toLowerCase()) && statSync(f).size > min);
|
|
227
230
|
}
|
package/dist/src/caps.d.ts
CHANGED
|
@@ -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 (
|
|
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
|
|
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) =>
|
|
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) =>
|
|
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
|
-
|
|
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
|
|
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
|
@@ -602,7 +602,20 @@ async function dispatch(p, io) {
|
|
|
602
602
|
throw new UsageError('post: <#channel> is required');
|
|
603
603
|
const body = rest.join(' ').trim();
|
|
604
604
|
const att = files();
|
|
605
|
-
|
|
605
|
+
// --card '<json>' (or @file.json): a card instead of text (a #product-log entry); the hub writes the text from it
|
|
606
|
+
let card;
|
|
607
|
+
if (typeof v.card === 'string') {
|
|
608
|
+
const raw = v.card.startsWith('@') ? readFileSync(v.card.slice(1), 'utf8') : v.card;
|
|
609
|
+
try {
|
|
610
|
+
card = JSON.parse(raw);
|
|
611
|
+
}
|
|
612
|
+
catch {
|
|
613
|
+
throw new UsageError('post: --card is not JSON');
|
|
614
|
+
}
|
|
615
|
+
if (body)
|
|
616
|
+
throw new UsageError('post: a card post takes no text');
|
|
617
|
+
}
|
|
618
|
+
if (!body && !att.length && !card)
|
|
606
619
|
throw new UsageError('post: missing "<text>"');
|
|
607
620
|
const c = client();
|
|
608
621
|
// "#ops-data", "ops-data" or the channel's title ("Ops Data"); the hub's list decides
|
|
@@ -616,7 +629,7 @@ async function dispatch(p, io) {
|
|
|
616
629
|
const nearName = near && (chans.find((x) => x.name === near || x.title === near)?.name ?? near);
|
|
617
630
|
throw new UsageError(`post: no channel "${channelRef(name)}" you can post in${nearName ? ` (did you mean #${nearName}?)` : ''}. List them with \`ach channels\`.`);
|
|
618
631
|
}
|
|
619
|
-
const r = await c.post(hit?.name ?? name, body, att, { announce: !!v.announce });
|
|
632
|
+
const r = await c.post(hit?.name ?? name, body, att, { announce: !!v.announce, ...(card ? { card } : {}) });
|
|
620
633
|
out(v.json ? r : `posted ${r.id} in #${r.channel_name ?? hit?.name ?? channelRef(name)}${r.url ? `: ${absUrl(env, r.url)}` : ''}`);
|
|
621
634
|
// @names that wake nobody: say so (with the closest known name) instead of failing silently
|
|
622
635
|
if (mentionNames(body).length) {
|
|
@@ -696,6 +709,22 @@ async function dispatch(p, io) {
|
|
|
696
709
|
const q = text(p, '<question>');
|
|
697
710
|
const c = client();
|
|
698
711
|
const task = taskIdOf(p, io);
|
|
712
|
+
const capName = str(v.action);
|
|
713
|
+
if (capName) {
|
|
714
|
+
// a confirmation of one action (docs/specs/bot-batch.md §5.1): the hub writes the options and asks the requester
|
|
715
|
+
if (opts.length || str(v.to))
|
|
716
|
+
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`);
|
|
717
|
+
const args = {};
|
|
718
|
+
for (const kv of (Array.isArray(v.arg) ? v.arg : []).map(String)) {
|
|
719
|
+
const i = kv.indexOf('=');
|
|
720
|
+
if (i < 1)
|
|
721
|
+
throw new UsageError(`${p.cmd}: --arg takes name=value (got ${kv})`);
|
|
722
|
+
args[kv.slice(0, i)] = kv.slice(i + 1);
|
|
723
|
+
}
|
|
724
|
+
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());
|
|
725
|
+
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'));
|
|
726
|
+
return 0;
|
|
727
|
+
}
|
|
699
728
|
const to = decisionTo(str(v.to));
|
|
700
729
|
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
730
|
if (v.json) {
|
|
@@ -707,6 +736,33 @@ async function dispatch(p, io) {
|
|
|
707
736
|
out(lines.join('\n'));
|
|
708
737
|
return 0;
|
|
709
738
|
}
|
|
739
|
+
case 'related': {
|
|
740
|
+
const about = p.positionals[0];
|
|
741
|
+
if (!about)
|
|
742
|
+
throw new UsageError('related: <source:id> is required (e.g. batch:20261118_003)');
|
|
743
|
+
const r = await client().related(about);
|
|
744
|
+
if (v.json) {
|
|
745
|
+
out(r);
|
|
746
|
+
return 0;
|
|
747
|
+
}
|
|
748
|
+
const lines = [`${r.about}: ${r.tasks.length} task(s), ${r.events.length} event(s)`];
|
|
749
|
+
const rows = [
|
|
750
|
+
...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}` : ''})` })),
|
|
751
|
+
...r.events.map((e) => ({ at: String(e.created ?? ''), line: `event ${e.source}/${e.type} (${e.level}): ${e.title}${e.link ? ` ${e.link}` : ''}` })),
|
|
752
|
+
].sort((a, b) => a.at.localeCompare(b.at));
|
|
753
|
+
for (const x of rows)
|
|
754
|
+
lines.push(`${x.at.slice(0, 16)} ${x.line}`);
|
|
755
|
+
out(lines.join('\n'));
|
|
756
|
+
return 0;
|
|
757
|
+
}
|
|
758
|
+
case 'about': {
|
|
759
|
+
const about = p.positionals[0];
|
|
760
|
+
if (!about)
|
|
761
|
+
throw new UsageError('about: <source:id> is required (e.g. batch:20261118_003)');
|
|
762
|
+
const r = await client().setAbout(taskIdOf(p, io), about);
|
|
763
|
+
out(v.json ? r : `this task is about ${about}`);
|
|
764
|
+
return 0;
|
|
765
|
+
}
|
|
710
766
|
case 'decide': {
|
|
711
767
|
const id = p.positionals[0];
|
|
712
768
|
if (!id)
|
package/dist/src/client.d.ts
CHANGED
|
@@ -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). */
|
|
@@ -565,8 +596,10 @@ export declare class Client {
|
|
|
565
596
|
channel: Channel;
|
|
566
597
|
posts: Post[];
|
|
567
598
|
}>;
|
|
599
|
+
/** `card`: structured content drawn as a card (a #product-log entry); then body is empty, the hub writes the text. */
|
|
568
600
|
post(channel: string, body: string, files?: string[], o?: {
|
|
569
601
|
announce?: boolean;
|
|
602
|
+
card?: Record<string, unknown>;
|
|
570
603
|
}): Promise<Post>;
|
|
571
604
|
reply(postId: string, body: string, o?: {
|
|
572
605
|
evidence?: string;
|
package/dist/src/client.js
CHANGED
|
@@ -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);
|
|
@@ -429,8 +445,9 @@ export class Client {
|
|
|
429
445
|
const qs = q.toString();
|
|
430
446
|
return this.ach('GET', `/channels/${enc(channelRef(channel))}/posts${qs ? `?${qs}` : ''}`);
|
|
431
447
|
}
|
|
448
|
+
/** `card`: structured content drawn as a card (a #product-log entry); then body is empty, the hub writes the text. */
|
|
432
449
|
async post(channel, body, files, o = {}) {
|
|
433
|
-
const r = await this.ach('POST', `/channels/${enc(channelRef(channel))}/posts`, { body, ...(o.announce ? { announce: true } : {}) }, files);
|
|
450
|
+
const r = await this.ach('POST', `/channels/${enc(channelRef(channel))}/posts`, { body, ...(o.announce ? { announce: true } : {}), ...(o.card ? { card: o.card } : {}) }, files);
|
|
434
451
|
return r?.post ?? r;
|
|
435
452
|
}
|
|
436
453
|
async reply(postId, body, o = {}, files) {
|
package/dist/src/mcp.js
CHANGED
|
@@ -87,7 +87,7 @@ const ATTACH = z
|
|
|
87
87
|
.array(z.string())
|
|
88
88
|
.max(10)
|
|
89
89
|
.optional()
|
|
90
|
-
.describe('Local files to attach: images (png, jpg, webp, gif), videos (mp4, webm, mov), text/code up to 2 MB (txt md json ts js py go sh diff patch log csv yaml sql) or an .html report. To refer to something that lives elsewhere, put its link in the text.');
|
|
90
|
+
.describe('Local files to attach: images (png, jpg, webp, gif), videos (mp4, webm, mov), pdf, zip, text/code up to 2 MB (txt md json ts js py go sh diff patch log csv yaml sql) or an .html report. To refer to something that lives elsewhere, put its link in the text.');
|
|
91
91
|
const LINKS_HELP = 'Refer to tasks, posts and commits by link or ID (TASK-128, a post link, a commit URL) rather than "the one above". Task tools accept TASK-128 (or T-128) wherever a task id is asked for.';
|
|
92
92
|
const TASK_FIELDS_HELP = 'Fill all four header fields (the team convention): priority, purpose (why this task exists), key_question (the one question the work must answer) and money (cost before/after and budget impact, or "n/a").';
|
|
93
93
|
/**
|
|
@@ -262,7 +262,7 @@ export function buildMcpServer(client, o = {}) {
|
|
|
262
262
|
throw new Error('nothing to update: pass handoff and/or priority, purpose, money, key_question');
|
|
263
263
|
return client.updateHeader(a.task_id, header, a.change_note);
|
|
264
264
|
}));
|
|
265
|
-
server.registerTool('get_task', { description: 'Get a task: status, current handoff, messages (questions, answers, decisions, progress), handoff history and attached files (
|
|
265
|
+
server.registerTool('get_task', { description: 'Get a task: status, current handoff, messages (questions, answers, decisions, progress), handoff history and attached files (fetch them with download_files).', inputSchema: { task_id: z.string() } }, async (a) => wrap(async () => {
|
|
266
266
|
const b = await client.getTask(a.task_id);
|
|
267
267
|
return wrapUntrusted({ ...b, files: taskFiles(b).map((f) => ({ ...f, download_url: `${client.hub}${f.url}` })) });
|
|
268
268
|
}));
|
|
@@ -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))
|
|
@@ -376,7 +383,7 @@ export function buildMcpServer(client, o = {}) {
|
|
|
376
383
|
return `failed ${a.task_id}`;
|
|
377
384
|
}));
|
|
378
385
|
server.registerTool('download_files', {
|
|
379
|
-
description: 'Download every
|
|
386
|
+
description: 'Download every file attached to a task (handoff and messages) into a local directory and return their paths, so you can open them: images, videos, PDFs, ZIP archives, text and code.',
|
|
380
387
|
inputSchema: { task_id: z.string(), out_dir: z.string().optional().describe('Default: ./ach-files-<task_id>') },
|
|
381
388
|
}, async (a) => wrap(async () => {
|
|
382
389
|
const dir = a.out_dir ?? join(process.cwd(), `ach-files-${a.task_id.replace(/[^A-Za-z0-9_-]/g, '')}`);
|
|
@@ -399,8 +406,25 @@ export function buildMcpServer(client, o = {}) {
|
|
|
399
406
|
}, async (a) => wrap(async () => wrapUntrusted(a.post_id ? await client.thread(a.post_id) : await client.channelPosts(a.channel, { since: a.since, limit: a.limit }))));
|
|
400
407
|
server.registerTool('post', {
|
|
401
408
|
description: `Post to a channel: findings, cost data, screenshots, questions to the group. @agent-name in the text reaches that agent and its owner's Inbox (the person sees it there even if the agent is offline) and wakes the agent for a short read-only reply. To address someone, @ their agent: a name written without @ reaches no one. For handing off work use send_task instead. Set announce: true only for news everyone should hear about (shipped, released, data published): every channel reader is notified. ${LINKS_HELP}`,
|
|
402
|
-
inputSchema: {
|
|
403
|
-
|
|
409
|
+
inputSchema: {
|
|
410
|
+
channel: z.string(),
|
|
411
|
+
text: z.string().optional().describe('The post (required unless card is given)'),
|
|
412
|
+
attachments: ATTACH,
|
|
413
|
+
announce: z.boolean().optional().describe('An announcement (shipped / released / data published): notifies every reader of the channel'),
|
|
414
|
+
card: z
|
|
415
|
+
.object({
|
|
416
|
+
type: z.literal('change'),
|
|
417
|
+
tag: z.enum(['feature', 'fix', 'change']),
|
|
418
|
+
title: z.string().describe('What changed, one line'),
|
|
419
|
+
summary: z.string().optional().describe('One sentence on what it does; omit when the title says it all'),
|
|
420
|
+
audience: z.string().optional().describe('Who it affects'),
|
|
421
|
+
env: z.string().optional().describe('Where it is live, with versions; omit when not verified'),
|
|
422
|
+
refs: z.array(z.string()).optional().describe('Commit, PR, issue or task links'),
|
|
423
|
+
})
|
|
424
|
+
.optional()
|
|
425
|
+
.describe('Post a card instead of text, when the channel\'s brief asks for one (a #product-log entry). Leave text empty: the hub writes it from the card.'),
|
|
426
|
+
},
|
|
427
|
+
}, async (a) => wrap(async () => withMentionWarnings(await client.post(a.channel, a.text ?? '', att(a.attachments), { announce: !!a.announce, ...(a.card ? { card: a.card } : {}) }), a.text ?? '')));
|
|
404
428
|
server.registerTool('reply', {
|
|
405
429
|
description: `Reply in a post's thread (a reply to a reply goes to the same thread). Add evidence (files, commands, outputs) when you answer a question. ${LINKS_HELP}`,
|
|
406
430
|
inputSchema: {
|
|
@@ -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 -------------------------------------------------------------------------------------------------
|
package/dist/src/version.d.ts
CHANGED
package/dist/src/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koalaauto/agentchannel",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.47.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",
|