@koalaauto/agentchannel 3.45.0 → 3.45.2

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/README.md CHANGED
@@ -39,8 +39,8 @@ installed or changed.
39
39
  - Run by an agent (pasted into Claude Code / Codex), there is no one to ask:
40
40
  pasting the line was the consent, so it does the same and says what it ran.
41
41
  - `--service` also installs the background helper (`ach run --install-service
42
- --interactive-first` for the current directory; `--notify` only on a machine
43
- with a desktop), and starts it. Through npx the service runs the same pinned
42
+ --interactive-first` for the current directory, without desktop
43
+ notifications), and starts it. Through npx the service runs the same pinned
44
44
  npx spec as the MCP entry, so nothing is installed globally.
45
45
  - When the agent tool's sandbox does not work on this machine (on Linux: bubblewrap and
46
46
  socat missing, or Ubuntu's AppArmor rule), it shows the commands that fix it and runs
@@ -111,12 +111,15 @@ reminds you with one line, never the message itself:
111
111
  `codex queue --thread <session> --message "<the line>"` when Codex tells it
112
112
  the session id (`CODEX_THREAD_ID`; or set `ACH_CODEX_THREAD_ID`). Otherwise
113
113
  it does nothing and the desktop notification covers it.
114
- - **Desktop** (`ach run --notify`, on by default with `--install-service` on a
115
- machine with a desktop):
116
- an OS notification. Decision requests show their options as buttons where
114
+ - **Desktop** (`ach run --notify`, off by default; browser notifications from
115
+ the panel are the main way to be reached): an OS notification for the same
116
+ items the browser notification gets (a channel's plain news waits for the
117
+ digest). macOS needs `terminal-notifier` (`brew install terminal-notifier`);
118
+ without it nothing shows (osascript's notifications would carry Script
119
+ Editor's name and icon). Decision requests show their options as buttons where
117
120
  the OS can report the click: macOS with
118
121
  [`alerter`](https://github.com/vjeantet/alerter) installed (else
119
- terminal-notifier / osascript without buttons), Linux `notify-send` with
122
+ terminal-notifier without buttons), Linux `notify-send` with
120
123
  `--action` (libnotify 0.7.9+), Windows toast buttons. A click never answers for you:
121
124
  it opens the panel at the decision with that option preselected
122
125
  (`#/t/TASK-12/m/<id>?pick=<i>`), and you press Send there. The helper runs with
@@ -22,6 +22,17 @@ export declare const MENTION_GIT_TOOLS: string[];
22
22
  * run (`--ext-diff`, `-c`, `--exec`), and nothing before `git` (an environment variable can name a program too).
23
23
  */
24
24
  export declare function mentionGitDenied(command: string): string | undefined;
25
+ /**
26
+ * Whether a command is one plain `ach <sub> ...` call of an allowed subcommand: literal words only. Claude Code's own rule
27
+ * (`Bash(ach reply:*)`) gives up on a long quoted argument with `;` or a line break in it and asks, which a run that cannot ask
28
+ * reads as a refusal (2026-11-17: two replies with evidence were lost that way). Quoted text is literal here: nothing a shell
29
+ * would expand (`$`, a backtick), chain, redirect or glob outside quotes, and nothing before `ach`.
30
+ */
31
+ export declare function plainAchCommand(command: string, subs: string[]): boolean;
32
+ /** The subcommands of a list like `Bash(ach reply:*)`. */
33
+ export declare const achSubcommands: (tools: string[]) => string[];
34
+ /** PreToolUse for Bash: a plain call of one of the run's `ach` commands is allowed outright (see plainAchCommand). */
35
+ export declare function achCommandHook(tools: string[]): HookCallbackMatcher;
25
36
  /** PreToolUse for a mention run's Bash: the git rules above (a hook runs for pre-approved commands too). */
26
37
  export declare function mentionGitHook(): HookCallbackMatcher;
27
38
  /** canUseTool for workdir: path policy (reads under $HOME, writes outside cwd) plus the Bash deny list. */
@@ -75,7 +86,7 @@ export declare function sandboxNetwork(hubHost: string | undefined, netAllow?: s
75
86
  */
76
87
  export declare function claudePermOptions(perm: Perm, o: ClaudePermInput): Partial<Options>;
77
88
  /**
78
- * design §34: the run's host capabilities as Claude Code options: a stdio MCP server Claude Code starts itself, outside the
89
+ * decisions §34: the run's host capabilities as Claude Code options: a stdio MCP server Claude Code starts itself, outside the
79
90
  * sandbox that wraps the run's commands, and its tools pre-approved (read runs allow only listed tools). Pure.
80
91
  */
81
92
  export declare function claudeCapsOptions(caps?: CapsServerSpec): {
@@ -2,7 +2,7 @@ import { mkdtempSync, realpathSync, rmSync } from 'node:fs';
2
2
  import { homedir, tmpdir } from 'node:os';
3
3
  import { join } from 'node:path';
4
4
  import { CAPS_SERVER } from '../caps.js';
5
- import { toolDenied } from './paths.js';
5
+ import { isSessionToolResult, READ_TOOLS, toolDenied, toolPaths } from './paths.js';
6
6
  import { macTempPatterns, readable, systemPaths } from './scope.js';
7
7
  import { spawnGroup } from './procgroup.js';
8
8
  import { modelId } from './types.js';
@@ -66,6 +66,62 @@ export function mentionGitDenied(command) {
66
66
  return `this run reads the repository's history only: no ${args.find((a) => /^--(ext-diff|exec|no-index|textconv)\b/.test(a))}`;
67
67
  return undefined;
68
68
  }
69
+ /**
70
+ * Whether a command is one plain `ach <sub> ...` call of an allowed subcommand: literal words only. Claude Code's own rule
71
+ * (`Bash(ach reply:*)`) gives up on a long quoted argument with `;` or a line break in it and asks, which a run that cannot ask
72
+ * reads as a refusal (2026-11-17: two replies with evidence were lost that way). Quoted text is literal here: nothing a shell
73
+ * would expand (`$`, a backtick), chain, redirect or glob outside quotes, and nothing before `ach`.
74
+ */
75
+ export function plainAchCommand(command, subs) {
76
+ const cmd = command.trim();
77
+ const m = /^ach\s+([a-z][a-z-]*)(\s|$)/.exec(cmd);
78
+ if (!m || !subs.includes(m[1]))
79
+ return false;
80
+ let q = '';
81
+ for (let i = 0; i < cmd.length; i++) {
82
+ const ch = cmd[i];
83
+ if (q === "'") {
84
+ if (ch === "'")
85
+ q = '';
86
+ continue;
87
+ }
88
+ if (q === '"') {
89
+ if (ch === '\\') {
90
+ i++;
91
+ continue;
92
+ }
93
+ if (ch === '"')
94
+ q = '';
95
+ else if (ch === '$' || ch === '`')
96
+ return false;
97
+ continue;
98
+ }
99
+ if (ch === "'" || ch === '"') {
100
+ q = ch;
101
+ continue;
102
+ }
103
+ if (/[;&|<>(){}$`\\\n\r*?[\]~!]/.test(ch))
104
+ return false;
105
+ }
106
+ return q === '';
107
+ }
108
+ /** The subcommands of a list like `Bash(ach reply:*)`. */
109
+ export const achSubcommands = (tools) => tools.map((t) => /^Bash\(ach ([a-z-]+):\*\)$/.exec(t)?.[1]).filter((s) => !!s);
110
+ /** PreToolUse for Bash: a plain call of one of the run's `ach` commands is allowed outright (see plainAchCommand). */
111
+ export function achCommandHook(tools) {
112
+ const subs = achSubcommands(tools);
113
+ return {
114
+ hooks: [
115
+ async (input) => {
116
+ if (input.hook_event_name !== 'PreToolUse' || input.tool_name !== 'Bash')
117
+ return {};
118
+ if (!plainAchCommand(String((input.tool_input ?? {}).command ?? ''), subs))
119
+ return {};
120
+ return { hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: 'allow' } };
121
+ },
122
+ ],
123
+ };
124
+ }
69
125
  /** PreToolUse for a mention run's Bash: the git rules above (a hook runs for pre-approved commands too). */
70
126
  export function mentionGitHook() {
71
127
  return {
@@ -106,7 +162,15 @@ export function pathPolicyHook(pol) {
106
162
  async (input) => {
107
163
  if (input.hook_event_name !== 'PreToolUse')
108
164
  return {};
109
- const why = toolDenied(pol, input.tool_name, (input.tool_input ?? {}));
165
+ const args = (input.tool_input ?? {});
166
+ // what Claude Code saved for this session (a long tool result) is the run's own: readable, whatever the roots say
167
+ if (READ_TOOLS.has(input.tool_name)) {
168
+ const paths = toolPaths(input.tool_name, args);
169
+ if (paths.length && paths.every((p) => isSessionToolResult(pol.cwd, p, String(input.session_id ?? '')))) {
170
+ return { hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: 'allow' } };
171
+ }
172
+ }
173
+ const why = toolDenied(pol, input.tool_name, args);
110
174
  if (!why)
111
175
  return {};
112
176
  return { hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: 'deny', permissionDecisionReason: why } };
@@ -198,14 +262,14 @@ export function claudePermOptions(perm, o) {
198
262
  // test). The PreToolUse hook checks them; the SDK's notice that canUseTool is shadowed for them is expected.
199
263
  allowedTools: ['Read', 'Glob', 'Grep', ...achTools, ...(o.mode === 'mention' ? MENTION_GIT_TOOLS : [])],
200
264
  sandbox,
201
- hooks: { PreToolUse: [pathPolicyHook(pol), ...(o.mode === 'mention' ? [mentionGitHook()] : [])] },
265
+ hooks: { PreToolUse: [pathPolicyHook(pol), achCommandHook(achTools), ...(o.mode === 'mention' ? [mentionGitHook()] : [])] },
202
266
  };
203
267
  if (perm === 'read')
204
268
  return { ...common, permissionMode: 'dontAsk' };
205
269
  return { ...common, permissionMode: 'acceptEdits', canUseTool: workdirCanUseTool(pol) };
206
270
  }
207
271
  /**
208
- * design §34: the run's host capabilities as Claude Code options: a stdio MCP server Claude Code starts itself, outside the
272
+ * decisions §34: the run's host capabilities as Claude Code options: a stdio MCP server Claude Code starts itself, outside the
209
273
  * sandbox that wraps the run's commands, and its tools pre-approved (read runs allow only listed tools). Pure.
210
274
  */
211
275
  export function claudeCapsOptions(caps) {
@@ -68,7 +68,7 @@ export declare const WINDOWS_HOME_DENY: string[];
68
68
  */
69
69
  export declare function codexSandboxOverrides(o: CodexSandboxInput): string[];
70
70
  /**
71
- * design §34: the run's host capabilities as Codex `--config` overrides: a stdio MCP server Codex starts itself, outside the
71
+ * decisions §34: the run's host capabilities as Codex `--config` overrides: a stdio MCP server Codex starts itself, outside the
72
72
  * sandbox of the run's commands (approval_policy is never, so its tools run without asking). Pure.
73
73
  */
74
74
  export declare function codexCapsOverrides(caps?: CapsServerSpec): string[];
@@ -129,7 +129,7 @@ export function codexSandboxOverrides(o) {
129
129
  ];
130
130
  }
131
131
  /**
132
- * design §34: the run's host capabilities as Codex `--config` overrides: a stdio MCP server Codex starts itself, outside the
132
+ * decisions §34: the run's host capabilities as Codex `--config` overrides: a stdio MCP server Codex starts itself, outside the
133
133
  * sandbox of the run's commands (approval_policy is never, so its tools run without asking). Pure.
134
134
  */
135
135
  export function codexCapsOverrides(caps) {
@@ -44,6 +44,12 @@ export declare const READ_TOOLS: Set<string>;
44
44
  export declare const WRITE_TOOLS: Set<string>;
45
45
  /** File paths a tool call touches (relative paths are resolved against cwd by the policy). */
46
46
  export declare function toolPaths(toolName: string, input: Record<string, unknown>): string[];
47
+ /**
48
+ * A file Claude Code wrote for this very session: a tool result too long for the conversation is saved under
49
+ * `~/.claude/projects/<project>/<session>/tool-results/` and the agent is told to read it from there. Only this session's: the
50
+ * same folder holds the owner's other sessions.
51
+ */
52
+ export declare function isSessionToolResult(cwd: string, p: string, sessionId: string): boolean;
47
53
  /** Deny reason for a tool call under the policy, or undefined to allow. */
48
54
  export declare function toolDenied(pol: PathPolicy, toolName: string, input: Record<string, unknown>): string | undefined;
49
55
  export declare function existing(paths: string[]): string[];
@@ -116,6 +116,18 @@ export function toolPaths(toolName, input) {
116
116
  out.push('.');
117
117
  return out;
118
118
  }
119
+ /**
120
+ * A file Claude Code wrote for this very session: a tool result too long for the conversation is saved under
121
+ * `~/.claude/projects/<project>/<session>/tool-results/` and the agent is told to read it from there. Only this session's: the
122
+ * same folder holds the owner's other sessions.
123
+ */
124
+ export function isSessionToolResult(cwd, p, sessionId) {
125
+ if (!/^[A-Za-z0-9-]{8,64}$/.test(sessionId))
126
+ return false;
127
+ const parts = realish(resolve(cwd, p)).split(/[\\/]+/);
128
+ const i = parts.lastIndexOf('tool-results');
129
+ return i >= 4 && i < parts.length - 1 && parts[i - 1] === sessionId && parts[i - 3] === 'projects' && parts[i - 4] === '.claude' && !parts.slice(i).includes('..');
130
+ }
119
131
  /** Deny reason for a tool call under the policy, or undefined to allow. */
120
132
  export function toolDenied(pol, toolName, input) {
121
133
  const write = WRITE_TOOLS.has(toolName);
@@ -45,7 +45,7 @@ export interface AdapterRunOptions {
45
45
  maxBudgetUsd?: number;
46
46
  /** JSON schema the final message must follow (codex answer runs). */
47
47
  outputSchema?: unknown;
48
- /** design §34: the host capabilities server of this run (an MCP server outside the sandbox); absent = none declared. */
48
+ /** decisions §34: the host capabilities server of this run (an MCP server outside the sandbox); absent = none declared. */
49
49
  caps?: CapsServerSpec;
50
50
  }
51
51
  export interface AdapterResult {
@@ -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>)\nRecurring: ach schedule add --to <agent> --title <t> --money <m> --handoff-file <f> --every day|weekday|week|month --at HH:MM\n [--weekday 1..7] [--day 1..28] [--tz +08:00] [--purpose p] [--priority P0..P3] [--channel <name>]\n (a proposal: it runs only after your owner replies \"approve\"; {date} in the title/handoff becomes the run's date;\n a run is skipped while the previous one is still open)\n ach schedule add ... --on task_completed|task_failed|figure|post --match '<json>' (an event rule instead of a time:\n task: {\"to\":\"puller\",\"title\":\"pull\"} (its own tasks only); figure: {\"topic\":\"ads\",\"metric\":\"Meta daily spend\",\"op\":\">\",\"value\":5000};\n post: {\"channel\":\"ci\",\"contains\":\"failed\"}. {ref} {title} {link} {metric} {value} {unit} {text} fill the title/handoff)\n ach schedules | ach schedule pause <id> | ach schedule resume <id> | ach schedule rm <id> (resume: your owner, in the panel or with a person's session)\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 decide [--task <id>] <requestId> --grant <id> --option <n> (a runner, within an authorization grant)\nAuthorization: ach grant (--agent <name> | --person <who>) (--task <TASK-n> | --channel <name>) --cap <usd> [--until YYYY-MM-DD]\n [--note \"<guidance>\"] [--requester <agent|person>] (your agent key: you, present, grant it; never a run token)\n ach grants | ach revoke <grantId>\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 seed --from-imports (maintainers: one upkeep task per channel over its imported GitHub issues/PRs)\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 | --no-notify] (desktop notifications for your owner's important / needs-you items;\n default on for --install-service where there is a desktop, off otherwise)\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 import github --org <org> [--since 60d] --dry-run [--out plan.json] (reads GitHub with your gh login; writes a plan)\n ach admin import github --org <org> --link <one-time admin link> [--yes] (the line from the panel's Settings -> Import:\n logs in with the 15-minute link for this import only, shows the dry run, then imports on a yes / --yes)\n ach admin import github --org <org> [--plan plan.json] (channels, people, issues/PRs; idempotent, re-run updates)\n Two ranges: posted to channels = open items + items closed/merged in the last N days\n [--post-closed-days N (alias --closed-days), default 7 | --all]; used to seed Memory (links only) = closed\n items of the last M months [--seed-months M, default 6 | --seed-all]. The hub keeps both for sync.\n [--exclude security,secret,... | --no-exclude] (default exclusion:\n security, \u5B89\u5168, \u6F0F\u6D1E, secret, \u5BC6\u94A5 in labels or title: never sent, not even an excerpt)\n Plan: \"visibility\": \"private\" on a channel + people \"channels\" = members-only (the hub otherwise\n widens access: everyone on the hub reads team channels, even repos they cannot see on GitHub).\n ach admin sync github [--org <org>] [same range and --exclude flags] (issues/PRs updated since the last\n import/sync; items that closed since then still update their posts; releases too; cron-friendly)\n [--every 5m [--runs N]] (keep syncing in a loop; or cron: */5 * * * * ach admin sync github)\n 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 embeds [--set host1,host2] (embed allowlist; public suffixes are refused)\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-maintainers [<agent> ...] (who keeps Memory current; no name: show it. Default: the admin agent with no setup problem seen most recently)\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>)\nRecurring: ach schedule add --to <agent> --title <t> --money <m> --handoff-file <f> --every day|weekday|week|month --at HH:MM\n [--weekday 1..7] [--day 1..28] [--tz +08:00] [--purpose p] [--priority P0..P3] [--channel <name>]\n (a proposal: it runs only after your owner replies \"approve\"; {date} in the title/handoff becomes the run's date;\n a run is skipped while the previous one is still open)\n ach schedule add ... --on task_completed|task_failed|figure|post --match '<json>' (an event rule instead of a time:\n task: {\"to\":\"puller\",\"title\":\"pull\"} (its own tasks only); figure: {\"topic\":\"ads\",\"metric\":\"Meta daily spend\",\"op\":\">\",\"value\":5000};\n post: {\"channel\":\"ci\",\"contains\":\"failed\"}. {ref} {title} {link} {metric} {value} {unit} {text} fill the title/handoff)\n ach schedules | ach schedule pause <id> | ach schedule resume <id> | ach schedule rm <id> (resume: your owner, in the panel or with a person's session)\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 decide [--task <id>] <requestId> --grant <id> --option <n> (a runner, within an authorization grant)\nAuthorization: ach grant (--agent <name> | --person <who>) (--task <TASK-n> | --channel <name>) --cap <usd> [--until YYYY-MM-DD]\n [--note \"<guidance>\"] [--requester <agent|person>] (your agent key: you, present, grant it; never a run token)\n ach grants | ach revoke <grantId>\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 seed --from-imports (maintainers: one upkeep task per channel over its imported GitHub issues/PRs)\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 import github --org <org> [--since 60d] --dry-run [--out plan.json] (reads GitHub with your gh login; writes a plan)\n ach admin import github --org <org> --link <one-time admin link> [--yes] (the line from the panel's Settings -> Import:\n logs in with the 15-minute link for this import only, shows the dry run, then imports on a yes / --yes)\n ach admin import github --org <org> [--plan plan.json] (channels, people, issues/PRs; idempotent, re-run updates)\n Two ranges: posted to channels = open items + items closed/merged in the last N days\n [--post-closed-days N (alias --closed-days), default 7 | --all]; used to seed Memory (links only) = closed\n items of the last M months [--seed-months M, default 6 | --seed-all]. The hub keeps both for sync.\n [--exclude security,secret,... | --no-exclude] (default exclusion:\n security, \u5B89\u5168, \u6F0F\u6D1E, secret, \u5BC6\u94A5 in labels or title: never sent, not even an excerpt)\n Plan: \"visibility\": \"private\" on a channel + people \"channels\" = members-only (the hub otherwise\n widens access: everyone on the hub reads team channels, even repos they cannot see on GitHub).\n ach admin sync github [--org <org>] [same range and --exclude flags] (issues/PRs updated since the last\n import/sync; items that closed since then still update their posts; releases too; cron-friendly)\n [--every 5m [--runs N]] (keep syncing in a loop; or cron: */5 * * * * ach admin sync github)\n 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 embeds [--set host1,host2] (embed allowlist; public suffixes are refused)\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-maintainers [<agent> ...] (who keeps Memory current; no name: show it. Default: the admin agent with no setup problem seen most recently)\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
@@ -248,8 +248,8 @@ Runner: ach run --dir <path> [--repo name=path ...] [--runtime claude|codex|
248
248
  [--perm read|workdir|full] [--model m] [--pass-env NAME ...]
249
249
  [--claim-delay <sec> | --interactive-first] (default 0; --interactive-first = 60 s for you to claim first)
250
250
  [--no-trace] (keep execution traces on this machine; ACH_NO_TRACE=1 too)
251
- [--notify | --no-notify] (desktop notifications for your owner's important / needs-you items;
252
- default on for --install-service where there is a desktop, off otherwise)
251
+ [--notify] (desktop notifications for what needs your owner, the same items as their browser
252
+ notifications; off by default; macOS needs terminal-notifier)
253
253
  ach run --install-service [same flags] (installs and starts a launchd/systemd user unit; runs at login)
254
254
  ach run --gc [--dir <path>] [--days 7]
255
255
  MCP: ach mcp (stdio server; your interactive agent can also claim and work tasks)
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Host capabilities (design §34): commands the agent's owner declares in `<AGENTCHANNEL_HOME>/capabilities.json` so that the
2
+ * Host capabilities (decisions §34): commands the agent's owner declares in `<AGENTCHANNEL_HOME>/capabilities.json` so that the
3
3
  * agent's runs, which are sandboxed and see neither the home nor the machine's secrets, can still get data only this machine
4
4
  * reaches (a database behind a jump host, a log service, an internal API). The runner hands every Claude or Codex run an MCP
5
5
  * server (`ach caps-serve`) that runs OUTSIDE the sandbox and does exactly one thing: run a declared command with the
package/dist/src/caps.js CHANGED
@@ -3,7 +3,7 @@ import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } fr
3
3
  import { dirname, isAbsolute, join } from 'node:path';
4
4
  import { killGroup } from './adapters/procgroup.js';
5
5
  /**
6
- * Host capabilities (design §34): commands the agent's owner declares in `<AGENTCHANNEL_HOME>/capabilities.json` so that the
6
+ * Host capabilities (decisions §34): commands the agent's owner declares in `<AGENTCHANNEL_HOME>/capabilities.json` so that the
7
7
  * agent's runs, which are sandboxed and see neither the home nor the machine's secrets, can still get data only this machine
8
8
  * reaches (a database behind a jump host, a log service, an internal API). The runner hands every Claude or Codex run an MCP
9
9
  * server (`ach caps-serve`) that runs OUTSIDE the sandbox and does exactly one thing: run a declared command with the
package/dist/src/cli.js CHANGED
@@ -242,7 +242,7 @@ export async function main(argv, io = defaultIo()) {
242
242
  /* advisory only */
243
243
  }
244
244
  };
245
- // design §34: the capabilities server a runner hands its runs (stdio MCP); its arguments are the runner's, not a person's
245
+ // decisions §34: the capabilities server a runner hands its runs (stdio MCP); its arguments are the runner's, not a person's
246
246
  if (argv[0] === 'caps-serve') {
247
247
  await (await import('./caps.js')).serveCaps(argv.slice(1));
248
248
  return await new Promise(() => { });
@@ -504,7 +504,7 @@ async function dispatch(p, io) {
504
504
  else if (r.ok)
505
505
  out(isZh(env) ? `已发送测试通知(${r.cmd})。没看到?检查系统设置里的通知权限。` : `test notification sent (${r.cmd}). Did not see it? Check the notification permissions in your system settings.`);
506
506
  else
507
- io.err(`ach notify --test: ${r.error}${process.platform === 'darwin' ? ' (macOS: brew install terminal-notifier, or alerter for decision buttons)' : process.platform === 'linux' ? ' (Linux: install libnotify-bin for notify-send)' : ''}`);
507
+ io.err(`ach notify --test: ${r.error}${process.platform === 'darwin' ? ' (macOS: brew install terminal-notifier; alerter for decision buttons)' : process.platform === 'linux' ? ' (Linux: install libnotify-bin for notify-send)' : ''}`);
508
508
  return r.ok ? 0 : 1;
509
509
  }
510
510
  case 'me':
@@ -1782,7 +1782,7 @@ async function runCommand(p, io) {
1782
1782
  const dn = new DeskNotifier({ request: (m, path) => c.request(m, path), socket: () => c.eventsSocket(), home, hub: env.ACH_PUBLIC_URL || cfg.hub, env, log: io.err });
1783
1783
  dn.start();
1784
1784
  desk = dn;
1785
- io.err('ach run: desktop notifications on (--no-notify to turn off)');
1785
+ io.err('ach run: desktop notifications on');
1786
1786
  }
1787
1787
  updater = new SelfUpdater({
1788
1788
  fetchVersions: () => c.request('GET', '/api/ach/auth/config'),
@@ -1899,7 +1899,6 @@ export const AUTH_EXIT_MESSAGE = 'ach run: key rotated or agent deactivated —
1899
1899
  */
1900
1900
  async function installService(p, io, o) {
1901
1901
  const { serviceFile, writeServiceFile } = await import('./service.js');
1902
- const { hasDesktop } = await import('./onboard.js');
1903
1902
  const { isBundledBin, npmSpec, whichAll } = await import('./invite.js');
1904
1903
  const env = io.env;
1905
1904
  const platform = (env.ACH_SERVICE_PLATFORM || process.platform);
@@ -1914,8 +1913,8 @@ async function installService(p, io, o) {
1914
1913
  args.push(`--${f}`, str(v[f]));
1915
1914
  if (v['interactive-first'])
1916
1915
  args.push('--interactive-first');
1917
- // a service runs in the background: desktop notifications where there is a desktop, unless --no-notify
1918
- if (v.notify || (!v['no-notify'] && hasDesktop(env, platform)))
1916
+ // desktop notifications only when asked for: browser notifications are the main way to reach the person
1917
+ if (v.notify && !v['no-notify'])
1919
1918
  args.push('--notify');
1920
1919
  const passEnv = (Array.isArray(v['pass-env']) ? v['pass-env'] : []).flatMap(splitList);
1921
1920
  for (const n of passEnv)
@@ -530,7 +530,7 @@ export declare class Client {
530
530
  /** `used`: the model and the effort the run really ran with, when the tool said (the panel shows them on the run). */
531
531
  usage(taskId: string, run_id: string, cost_usd: number, estimated: boolean, used?: RunUsed): Promise<any>;
532
532
  /**
533
- * design §27: what keeps this agent's runner from taking tasks on its machine (null: nothing). The hub shows it as
533
+ * decisions §27: what keeps this agent's runner from taking tasks on its machine (null: nothing). The hub shows it as
534
534
  * "needs setup" with the fix.
535
535
  */
536
536
  /**
@@ -384,7 +384,7 @@ export class Client {
384
384
  return this.ach('POST', `/tasks/${enc(taskId)}/usage`, { run_id, cost_usd, estimated, ...usedBody(used) });
385
385
  }
386
386
  /**
387
- * design §27: what keeps this agent's runner from taking tasks on its machine (null: nothing). The hub shows it as
387
+ * decisions §27: what keeps this agent's runner from taking tasks on its machine (null: nothing). The hub shows it as
388
388
  * "needs setup" with the fix.
389
389
  */
390
390
  /**
@@ -4,20 +4,24 @@
4
4
  * person, important events) and shows an OS notification for each new event.
5
5
  * Clicking opens the deep link where the platform supports it.
6
6
  *
7
- * - macOS: terminal-notifier when installed (click opens the link), else osascript.
7
+ * - macOS: terminal-notifier (click opens the link). Without it nothing shows: osascript's notifications carry Script
8
+ * Editor's name and icon and a click opens Script Editor, so they are not used.
8
9
  * - Linux: notify-send.
9
10
  * - Windows: a PowerShell toast (click opens the link).
10
11
  * - ACH_NOTIFIER=<command>: run `<command> <title> <message> <url>` instead (tests, custom setups).
11
12
  *
12
13
  * Decision requests (multiple choice) get option buttons where the OS can
13
14
  * return the click: macOS `alerter` (when installed; terminal-notifier and
14
- * osascript cannot report a click), Linux `notify-send --action` (libnotify
15
+ * cannot report a click), Linux `notify-send --action` (libnotify
15
16
  * 0.7.9+), Windows toast buttons. A click never answers anything: it opens
16
17
  * the panel at the decision with that option preselected (`…?pick=<i>`), and
17
18
  * the person presses Send there. The helper runs with the agent key, so it
18
19
  * must not record the person's reply (no push action tokens, no /decide).
19
20
  * Without a click-capable notifier: a plain notification that opens the link.
20
21
  *
22
+ * Which items: the hub's `alert` flag, the same rule as the push to the person's browsers (a channel's plain news
23
+ * waits for the digest). Off unless asked for (`--notify`): browser notifications are the main way to be reached.
24
+ *
21
25
  * Changes arrive through the hub's change stream (long poll, see attention.ts),
22
26
  * with 15 s polling as the fallback.
23
27
  *
@@ -51,9 +55,6 @@ function onPath(name, env) {
51
55
  function oneLine(s, max = 200) {
52
56
  return String(s ?? '').replace(/\s+/g, ' ').trim().slice(0, max);
53
57
  }
54
- function appleQuote(s) {
55
- return '"' + s.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"';
56
- }
57
58
  function xmlEscape(s) {
58
59
  return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&apos;');
59
60
  }
@@ -68,7 +69,7 @@ export function notifyCommand(o, platform, env) {
68
69
  args.push('-group', o.group);
69
70
  return { cmd: 'terminal-notifier', args };
70
71
  }
71
- return { cmd: 'osascript', args: ['-e', `display notification ${appleQuote(o.message)} with title ${appleQuote(o.title)}`] };
72
+ return null;
72
73
  }
73
74
  if (platform === 'linux')
74
75
  return { cmd: 'notify-send', args: ['--app-name=AgentChannel', o.title, `${o.message}\n${o.url}`] };
@@ -232,7 +233,7 @@ export async function testNotification(o) {
232
233
  group: 'ach-test',
233
234
  }, o.platform ?? process.platform, env);
234
235
  if (!c)
235
- return { ok: false, error: `no desktop notifier for platform ${o.platform ?? process.platform}` };
236
+ return { ok: false, error: (o.platform ?? process.platform) === 'darwin' ? 'terminal-notifier is not installed' : `no desktop notifier for platform ${o.platform ?? process.platform}` };
236
237
  const r = await (o.exec ?? defaultExec)(c.cmd, c.args);
237
238
  return r.code === 0 ? { ok: true, cmd: c.cmd } : { ok: false, cmd: c.cmd, error: oneLine(r.stderr, 300) || `exit ${r.code}` };
238
239
  }
@@ -413,6 +414,9 @@ export class DeskNotifier {
413
414
  }
414
415
  /** Follows the hub's change stream (WebSocket, else long poll, else 15 s polling). */
415
416
  start() {
417
+ const platform = this.o.platform ?? process.platform;
418
+ if (platform === 'darwin' && !notifyCommand({ title: '', message: '', url: '' }, platform, this.o.env ?? process.env))
419
+ this.o.log?.('ach run --notify: terminal-notifier is not installed (brew install terminal-notifier): no desktop notifications');
416
420
  void import('./attention.js').then(({ ChangeFeed }) => {
417
421
  if (this.stopped)
418
422
  return;
@@ -325,7 +325,7 @@ export async function runDoctor(o) {
325
325
  else
326
326
  add('kiro', runtime === 'kiro' ? 'fail' : 'info', `${st.detail}.${runtime === 'kiro' ? ' The background runner takes no tasks until this is fixed.' : ' (needed only for the kiro runtime)'}`, 'machine', st.fix?.commands.length ? st.fix.commands.join('\n ') : st.fix?.en);
327
327
  }
328
- // design §27: the agent tool's sandbox, probed for real (every run that answers a question or an @mention is sandboxed)
328
+ // decisions §27: the agent tool's sandbox, probed for real (every run that answers a question or an @mention is sandboxed)
329
329
  const { probeSandbox } = await import('./sandboxcheck.js');
330
330
  const tools = runtime === 'kiro' ? [] : runtime === 'codex' ? ['codex'] : runtime === 'claude' ? ['claude'] : [...(claude ? ['claude'] : []), ...(codexPath || bundled ? ['codex'] : [])];
331
331
  for (const t of tools) {
@@ -1,4 +1,4 @@
1
- // The runner's check of the machine it runs on, before it takes a task (design §27, issue "出事没人知道"): the agent's own tool
1
+ // The runner's check of the machine it runs on, before it takes a task (decisions §27, issue "出事没人知道"): the agent's own tool
2
2
  // must be logged in and its sandbox must start. A failed check is the same state as a broken sandbox: the runner takes nothing,
3
3
  // tells the hub (PUT /me/setup), the owner hears once with the command to run, and it starts again by itself when the check passes.
4
4
  // Credential files are never read: login state comes from the tool's own status command.
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * GitHub is read on THIS machine with the admin's own `gh` login (gh also
10
10
  * honors GITHUB_TOKEN / GH_TOKEN). The hub never sees the admin's token (it holds
11
- * a read-only App key of its own for the runs of agents, docs/design.md §33): it gets a
11
+ * a read-only App key of its own for the runs of agents, docs/decisions.md §33): it gets a
12
12
  * plan (channels with repo mappings, people) and compact items (issues/PRs:
13
13
  * title, state, who, a short excerpt, the link; never comment threads).
14
14
  * Nothing here writes to GitHub. Feishu invites go through the local
@@ -5,11 +5,11 @@ import { type SandboxStatus, type SandboxTool } from './sandboxcheck.js';
5
5
  *
6
6
  * 1. connect: add the `ach` MCP server to the agent's own tool (Claude Code
7
7
  * for a claude agent, Codex for a codex one; both found ones for "other")
8
- * 2. sandbox (design §27): when the probe of the agent tool's sandbox fails, the
8
+ * 2. sandbox (decisions §27): when the probe of the agent tool's sandbox fails, the
9
9
  * commands that fix it (sudo included), run only after Enter in a terminal;
10
10
  * with no terminal they are printed and nothing runs
11
- * 3. background helper, only with --service: `ach run --install-service`
12
- * (+ --notify on a machine with a desktop), which installs and starts it.
11
+ * 3. background helper, only with --service: `ach run --install-service`,
12
+ * which installs and starts it (no desktop notifications: the browser's are the main ones).
13
13
  * Run through npx, the helper runs the same pinned npx spec as the MCP
14
14
  * entry, never a path in the npx cache.
15
15
  *
@@ -61,8 +61,6 @@ export interface Step {
61
61
  }
62
62
  /** The closing line: which tool to open and what to say to it. */
63
63
  export declare function doneLine(tools: ('claude' | 'codex')[], zh: boolean): string;
64
- /** A desktop to show notifications on: macOS, Windows, or Linux with a display. */
65
- export declare function hasDesktop(env: NodeJS.ProcessEnv, platform?: string): boolean;
66
64
  /** The tools an agent of this runtime is added to: its own; both for "other" or unknown. */
67
65
  export declare function toolsFor(runtime: string | undefined): ('claude' | 'codex')[];
68
66
  /** True when this CLI runs from the npx cache (it disappears; install it first). */
@@ -106,7 +104,6 @@ export declare function planSteps(d: Detected, o: {
106
104
  env?: NodeJS.ProcessEnv;
107
105
  runtime?: string;
108
106
  service?: boolean;
109
- desktop?: boolean;
110
107
  sandbox?: SandboxStatus[];
111
108
  }): Step[];
112
109
  export interface SetupResult {
@@ -8,12 +8,6 @@ export function doneLine(tools, zh) {
8
8
  const where = names.length ? names.join(zh ? ' 或 ' : ' or ') : zh ? '你的 Claude Code 或 Codex' : 'your Claude Code or Codex';
9
9
  return zh ? `完成。打开 ${where},对它说:看看我的 AgentChannel 收件箱` : `Done. Open ${where} and say: check my AgentChannel inbox`;
10
10
  }
11
- /** A desktop to show notifications on: macOS, Windows, or Linux with a display. */
12
- export function hasDesktop(env, platform = process.platform) {
13
- if (platform === 'darwin' || platform === 'win32')
14
- return true;
15
- return !!(env.DISPLAY || env.WAYLAND_DISPLAY);
16
- }
17
11
  /** The tools an agent of this runtime is added to: its own; both for "other" or unknown. */
18
12
  export function toolsFor(runtime) {
19
13
  return runtime === 'claude' ? ['claude'] : runtime === 'codex' ? ['codex'] : ['claude', 'codex'];
@@ -125,14 +119,13 @@ export function planSteps(d, o) {
125
119
  }
126
120
  // 3. background helper: only when asked for (--service)
127
121
  if (o.service) {
128
- const notify = o.desktop !== false;
129
- const helper = ['run', '--install-service', ...(notify ? ['--notify'] : []), '--interactive-first', '--dir', o.cwd];
122
+ const helper = ['run', '--install-service', '--interactive-first', '--dir', o.cwd];
130
123
  steps.push({
131
124
  id: 'service',
132
125
  question: [
133
126
  zh
134
- ? `安装后台小助手(在 ${o.cwd} 里自动领取任务${notify ? ',并弹出系统通知' : ''})?会运行:`
135
- : `Install the background helper (picks up tasks in ${o.cwd}${notify ? ' and shows desktop notifications' : ''})? This runs:`,
127
+ ? `安装后台小助手(在 ${o.cwd} 里自动领取任务)?会运行:`
128
+ : `Install the background helper (picks up tasks in ${o.cwd})? This runs:`,
136
129
  ` ${shellLine([...o.achCmd, ...helper])}`,
137
130
  ].join('\n') + '\n',
138
131
  commands: [[...o.achCmd, ...helper]],
@@ -152,11 +145,10 @@ export async function runSetup(io, o) {
152
145
  const home = env.AGENTCHANNEL_HOME || undefined;
153
146
  const result = { ran: [], skipped: [], failed: [], tools: [] };
154
147
  const zh = !!o.zh;
155
- const desktop = hasDesktop(env);
156
- // design §27: probe the sandbox of the tools this agent runs with (not in a dry run: it runs nothing)
148
+ // decisions §27: probe the sandbox of the tools this agent runs with (not in a dry run: it runs nothing)
157
149
  const probe = io.sandbox ?? ((t) => probeSandbox(t, { env }));
158
150
  const sandbox = o.dryRun ? [] : await Promise.all(toolsFor(o.runtime).map((t) => probe(t)));
159
- const plan = planSteps(d, { home, local: o.local, achCmd: d.achCmd, cwd: io.cwd, zh, env, runtime: o.runtime, service: o.service, desktop, sandbox });
151
+ const plan = planSteps(d, { home, local: o.local, achCmd: d.achCmd, cwd: io.cwd, zh, env, runtime: o.runtime, service: o.service, sandbox });
160
152
  if (o.dryRun) {
161
153
  printOnly(io, d, plan, { zh, join: o.join });
162
154
  return result;
@@ -232,7 +224,7 @@ export async function runSetup(io, o) {
232
224
  }
233
225
  if (!o.service) {
234
226
  // the home goes with the command: without it `ach run` starts the default home's agent
235
- const run = shellLine([...(home ? [`AGENTCHANNEL_HOME=${home}`] : []), ...(d.npx ? d.achCmd : ['ach']), 'run', '--install-service', ...(desktop ? ['--notify'] : []), '--dir', io.cwd]);
227
+ const run = shellLine([...(home ? [`AGENTCHANNEL_HOME=${home}`] : []), ...(d.npx ? d.achCmd : ['ach']), 'run', '--install-service', '--dir', io.cwd]);
236
228
  io.out(zh ? `可选:让它在后台自动领任务:${run}` : `Optional, to have it pick up tasks in the background: ${run}`);
237
229
  }
238
230
  return result;
@@ -53,7 +53,7 @@ export interface RunnerOptions {
53
53
  /** §16: how many recent channel posts work prompts carry (default 15; 0 = none). */
54
54
  channelContext?: number;
55
55
  /**
56
- * design §27: probes the agent tool's sandbox. While it fails the runner takes nothing new (tasks wait in the hub's
56
+ * decisions §27: probes the agent tool's sandbox. While it fails the runner takes nothing new (tasks wait in the hub's
57
57
  * inbox), reports why, and probes again every `sandboxRecheckMs`. Absent: no check (tests).
58
58
  */
59
59
  sandboxCheck?: () => Promise<SandboxStatus>;
@@ -62,7 +62,7 @@ export interface RunnerOptions {
62
62
  secrets?: string[];
63
63
  /** A machine that checked out is checked again this often (default 6 h), so a login that expired is found before a task is taken. */
64
64
  okRecheckMs?: number;
65
- /** design §34: the capabilities file (default <home>/capabilities.json). */
65
+ /** decisions §34: the capabilities file (default <home>/capabilities.json). */
66
66
  capsFile?: string;
67
67
  /** the `ach` entry point the capabilities server runs (default this package's cli.js) */
68
68
  cliPath?: string;
@@ -202,7 +202,7 @@ export declare class Runner {
202
202
  /** B7: set when the hub answered 401 (key rotated, agent or owner deactivated): the runner stops. */
203
203
  fatal?: 'unauthorized';
204
204
  private wake?;
205
- /** design §27: the last sandbox probe, when it ran, and what the hub was last told (a JSON key). */
205
+ /** decisions §27: the last sandbox probe, when it ran, and what the hub was last told (a JSON key). */
206
206
  sandbox?: {
207
207
  st: SandboxStatus;
208
208
  at: number;
@@ -226,7 +226,7 @@ export declare class Runner {
226
226
  authFailed(where: string): void;
227
227
  /** One poll cycle. */
228
228
  tick(): Promise<void>;
229
- /** design §27: probe the sandbox when due, tell the hub when the answer changes; true = take nothing new. */
229
+ /** decisions §27: probe the sandbox when due, tell the hub when the answer changes; true = take nothing new. */
230
230
  private sandboxBlocked;
231
231
  /** Tell the hub which repo names this runner knows, so a task for another repo is refused when it is sent. Tried on every
232
232
  * poll until the hub has it: a hub that was unreachable at start would otherwise keep the previous list until a restart. */
@@ -238,7 +238,7 @@ export declare class Runner {
238
238
  private runnerReported;
239
239
  /** the capabilities file problems last logged (logged again only when they change) */
240
240
  private capsProblems;
241
- /** the capabilities last told to the hub (design §34): an edit of the file is reported again on the next poll */
241
+ /** the capabilities last told to the hub (decisions §34): an edit of the file is reported again on the next poll */
242
242
  private capsReported;
243
243
  private reportRunner;
244
244
  private notifyBudget;
@@ -336,7 +336,7 @@ export declare class Runner {
336
336
  private githubToken;
337
337
  /** Run the adapter with heartbeat, idle watchdog, session persistence and usage posting. */
338
338
  private execute;
339
- /** design §34: the capabilities server of one run, or undefined when nothing is declared (or the run is in the cloud). */
339
+ /** decisions §34: the capabilities server of one run, or undefined when nothing is declared (or the run is in the cloud). */
340
340
  private capsFor;
341
341
  private traceDir;
342
342
  /** Traces an earlier process could not upload are tried again. */
@@ -277,7 +277,7 @@ export class Runner {
277
277
  /** B7: set when the hub answered 401 (key rotated, agent or owner deactivated): the runner stops. */
278
278
  fatal;
279
279
  wake;
280
- /** design §27: the last sandbox probe, when it ran, and what the hub was last told (a JSON key). */
280
+ /** decisions §27: the last sandbox probe, when it ran, and what the hub was last told (a JSON key). */
281
281
  sandbox;
282
282
  sandboxReported;
283
283
  sandboxRecheck = false;
@@ -365,7 +365,7 @@ export class Runner {
365
365
  if (this.paused)
366
366
  return; // heartbeats of parked runs went out in checkActive; nothing new is taken (it waits in the hub's inbox)
367
367
  if (await this.sandboxBlocked())
368
- return; // design §27: same, until the sandbox works
368
+ return; // decisions §27: same, until the sandbox works
369
369
  if (!this.me || inbox.tasks_to_me.length) {
370
370
  this.me = await this.o.client.me();
371
371
  this.meAt = Date.now();
@@ -429,7 +429,7 @@ export class Runner {
429
429
  }
430
430
  this.pump();
431
431
  }
432
- /** design §27: probe the sandbox when due, tell the hub when the answer changes; true = take nothing new. */
432
+ /** decisions §27: probe the sandbox when due, tell the hub when the answer changes; true = take nothing new. */
433
433
  async sandboxBlocked() {
434
434
  const check = this.o.sandboxCheck;
435
435
  if (!check)
@@ -505,7 +505,7 @@ export class Runner {
505
505
  runnerReported = false;
506
506
  /** the capabilities file problems last logged (logged again only when they change) */
507
507
  capsProblems = '';
508
- /** the capabilities last told to the hub (design §34): an edit of the file is reported again on the next poll */
508
+ /** the capabilities last told to the hub (decisions §34): an edit of the file is reported again on the next poll */
509
509
  capsReported = '';
510
510
  async reportRunner() {
511
511
  if (!this.o.client.reportRunner)
@@ -522,7 +522,7 @@ export class Runner {
522
522
  return;
523
523
  }
524
524
  try {
525
- // review: this runner knows the owner's review step (a task it finishes may wait in awaiting_review, design §36)
525
+ // review: this runner knows the owner's review step (a task it finishes may wait in awaiting_review, decisions §36)
526
526
  await this.o.client.reportRunner({ perm: this.o.perm, runtime, pass_env: [...new Set(this.o.passEnv ?? [])], capabilities, review: true, ...(this.o.startInfo ?? {}) });
527
527
  this.runnerReported = true;
528
528
  this.capsReported = sig;
@@ -1623,7 +1623,7 @@ export class Runner {
1623
1623
  entry.controller.abort();
1624
1624
  }
1625
1625
  }, Math.max(10, Math.min(60_000, Math.floor(this.o.idleMs / 4))));
1626
- // design §34: the host capabilities the owner declared on this machine, read for every run (an edit applies to the next run)
1626
+ // decisions §34: the host capabilities the owner declared on this machine, read for every run (an edit applies to the next run)
1627
1627
  const caps = this.capsFor(taskId, rec.runId, realHome, env.TMPDIR);
1628
1628
  this.taskLog(taskId, `${mode} run start perm=${perm} resume=${resume ?? '-'} cwd=${rec.workdir}${caps ? ` caps=${caps.tools.map((t) => t.name).join(',')}` : ''}`);
1629
1629
  let result;
@@ -1690,7 +1690,7 @@ export class Runner {
1690
1690
  await this.uploadTrace(taskId, rec.runId, mode, startedAt, result, recorder, !this.fatal);
1691
1691
  return result;
1692
1692
  }
1693
- /** design §34: the capabilities server of one run, or undefined when nothing is declared (or the run is in the cloud). */
1693
+ /** decisions §34: the capabilities server of one run, or undefined when nothing is declared (or the run is in the cloud). */
1694
1694
  capsFor(taskId, runId, realHome, tmpDir) {
1695
1695
  if (this.o.adapter.remote)
1696
1696
  return undefined;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * design §27: does the agent tool's sandbox work on this machine?
2
+ * decisions §27: does the agent tool's sandbox work on this machine?
3
3
  *
4
4
  * Probe, do not guess: run the mechanism the tool uses (bubblewrap on Linux for Claude Code, Seatbelt on macOS, `codex
5
5
  * sandbox` for Codex) on a throwaway directory, once with a command that must succeed (write inside it) and once with one
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * P4: `ach run --install-service` writes a macOS launchd agent or a Linux
3
3
  * systemd user unit that starts this runner at login and restarts it, then
4
- * loads it (startService). design §27, Windows: a script in the user's Startup
4
+ * loads it (startService). decisions §27, Windows: a script in the user's Startup
5
5
  * folder (no admin rights needed) that runs the runner hidden and restarts it.
6
6
  */
7
7
  export interface ServiceSpec {
@@ -1,4 +1,4 @@
1
- export declare const VERSION = "3.45.0";
1
+ export declare const VERSION = "3.45.2";
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.0';
1
+ export const VERSION = '3.45.2';
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.0",
3
+ "version": "3.45.2",
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",