@koalaauto/agentchannel 3.53.4 → 3.54.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.
@@ -83,8 +83,26 @@ export interface KiroAdapterOptions {
83
83
  export declare class KiroAdapter implements RuntimeAdapter {
84
84
  private o;
85
85
  readonly name = "kiro";
86
- readonly structuredAnswers = true;
87
- readonly remote = true;
86
+ readonly spec: {
87
+ readonly name: "kiro";
88
+ readonly label: "Kiro";
89
+ readonly where: "cloud";
90
+ readonly ach: false;
91
+ readonly structuredAnswers: true;
92
+ readonly perms: readonly import("../perm.js").Perm[];
93
+ readonly limits: {
94
+ readonly net: false;
95
+ readonly denyRead: false;
96
+ };
97
+ readonly reads: "scoped";
98
+ readonly budget: false;
99
+ readonly ownerMemory: "prompt";
100
+ readonly ownFiles: readonly [];
101
+ readonly login: {
102
+ readonly key: "KIRO_API_KEY";
103
+ };
104
+ readonly check: "tool";
105
+ };
88
106
  constructor(o?: KiroAdapterOptions);
89
107
  run(opts: AdapterRunOptions): Promise<AdapterResult>;
90
108
  /** the models this key may use, their credit rate, the effort levels each takes and the default: from an ACP session (`kiro-cli acp`), else `kiro-cli chat --list-models --format json`. */
@@ -1,4 +1,5 @@
1
1
  import { execFileSync } from 'node:child_process';
2
+ import { RUNTIME_SPECS } from './spec.js';
2
3
  import { spawnGroup } from './procgroup.js';
3
4
  import { ask, KIRO_ACP_INPUT, kiroAcpModels, kiroModels } from './models.js';
4
5
  import { modelId } from './types.js';
@@ -266,8 +267,7 @@ const FORMAT_REFUSED = /output[- ]format|stream-json|unexpected argument|not sup
266
267
  export class KiroAdapter {
267
268
  o;
268
269
  name = 'kiro';
269
- structuredAnswers = true;
270
- remote = true;
270
+ spec = RUNTIME_SPECS.kiro;
271
271
  constructor(o = {}) {
272
272
  this.o = o;
273
273
  }
@@ -0,0 +1,164 @@
1
+ import { type Perm } from '../perm.js';
2
+ /**
3
+ * What a runtime (the agent tool a runner drives) can and cannot do: docs/specs/runtimes.md. Data only, so the CLI, the
4
+ * checks and the tests read it without loading a tool's SDK. Nothing outside adapters/ and the checks branches on a
5
+ * runtime's name: it reads these fields. A field exists only when something reads it.
6
+ */
7
+ export interface RuntimeSpec {
8
+ /** The id the hub stores. */
9
+ name: string;
10
+ /** The name people read. */
11
+ label: string;
12
+ /** local: the run works on this machine's files. cloud: elsewhere, on its own clone (no local paths, memory, capabilities). */
13
+ where: 'local' | 'cloud';
14
+ /** The run can call `ach` itself. false: it gets no hub credentials; the runner reports the task from the run's final text. */
15
+ ach: boolean;
16
+ /** Short runs (answer, mention, description) return JSON by a schema and the runner posts it. Implied by `ach: false`. */
17
+ structuredAnswers: boolean;
18
+ /** The permission levels the tool can enforce. */
19
+ perms: readonly Perm[];
20
+ /** What a sandboxed (below `full`) local run can be held to. */
21
+ limits: {
22
+ /** the agent's `net_allow` */
23
+ net: boolean;
24
+ /** not reading the runner's secrets, by any route (commands included) */
25
+ denyRead: boolean;
26
+ };
27
+ /**
28
+ * What a sandboxed local run can read besides its work dir. scoped: only the read roots the runner names. machine: other
29
+ * files on the machine too (other checkouts, /tmp); said when the runner starts, because the owner chooses it knowingly.
30
+ */
31
+ reads: 'scoped' | 'machine';
32
+ /** A run can be stopped at a USD cap. */
33
+ budget: boolean;
34
+ /** native: the tool shows the owner's memory index itself. prompt: the runner puts it in the prompt. */
35
+ ownerMemory: 'native' | 'prompt';
36
+ /** Project instruction files the tool loads by itself; the runner puts the others in the prompt. */
37
+ ownFiles: readonly string[];
38
+ /** The cheap model for housekeeping runs (the agent's description); none: the runtime's default. */
39
+ lightModel?: {
40
+ model: string;
41
+ effort: string;
42
+ };
43
+ /** How the tool is logged in on a machine: the command a person runs, or the environment variable that holds its key. */
44
+ login: {
45
+ command: string;
46
+ } | {
47
+ key: string;
48
+ };
49
+ /** sandbox: login + a real sandbox probe (envcheck.ts). tool: the runtime's own probe (runtimecheck.ts). */
50
+ check: 'sandbox' | 'tool';
51
+ }
52
+ export declare const RUNTIME_SPECS: {
53
+ readonly claude: {
54
+ readonly name: "claude";
55
+ readonly label: "Claude Code";
56
+ readonly where: "local";
57
+ readonly ach: true;
58
+ readonly structuredAnswers: false;
59
+ readonly perms: readonly Perm[];
60
+ readonly limits: {
61
+ readonly net: true;
62
+ readonly denyRead: true;
63
+ };
64
+ readonly reads: "scoped";
65
+ readonly budget: true;
66
+ readonly ownerMemory: "native";
67
+ readonly ownFiles: readonly [];
68
+ readonly lightModel: {
69
+ readonly model: "claude-haiku-5-5";
70
+ readonly effort: "low";
71
+ };
72
+ readonly login: {
73
+ readonly command: "claude auth login";
74
+ };
75
+ readonly check: "sandbox";
76
+ };
77
+ readonly codex: {
78
+ readonly name: "codex";
79
+ readonly label: "Codex";
80
+ readonly where: "local";
81
+ readonly ach: true;
82
+ readonly structuredAnswers: true;
83
+ readonly perms: readonly Perm[];
84
+ readonly limits: {
85
+ readonly net: true;
86
+ readonly denyRead: true;
87
+ };
88
+ readonly reads: "scoped";
89
+ readonly budget: false;
90
+ readonly ownerMemory: "prompt";
91
+ readonly ownFiles: readonly ["AGENTS.md"];
92
+ readonly lightModel: {
93
+ readonly model: "gpt-6.1-sol";
94
+ readonly effort: "medium";
95
+ };
96
+ readonly login: {
97
+ readonly command: "codex login";
98
+ };
99
+ readonly check: "sandbox";
100
+ };
101
+ readonly kiro: {
102
+ readonly name: "kiro";
103
+ readonly label: "Kiro";
104
+ readonly where: "cloud";
105
+ readonly ach: false;
106
+ readonly structuredAnswers: true;
107
+ readonly perms: readonly Perm[];
108
+ readonly limits: {
109
+ readonly net: false;
110
+ readonly denyRead: false;
111
+ };
112
+ readonly reads: "scoped";
113
+ readonly budget: false;
114
+ readonly ownerMemory: "prompt";
115
+ readonly ownFiles: readonly [];
116
+ readonly login: {
117
+ readonly key: "KIRO_API_KEY";
118
+ };
119
+ readonly check: "tool";
120
+ };
121
+ readonly antigravity: {
122
+ readonly name: "antigravity";
123
+ readonly label: "Antigravity";
124
+ readonly where: "local";
125
+ readonly ach: false;
126
+ readonly structuredAnswers: true;
127
+ readonly perms: readonly Perm[];
128
+ readonly limits: {
129
+ readonly net: false;
130
+ readonly denyRead: true;
131
+ };
132
+ readonly reads: "machine";
133
+ readonly budget: false;
134
+ readonly ownerMemory: "prompt";
135
+ readonly ownFiles: readonly [];
136
+ readonly login: {
137
+ readonly command: "agy";
138
+ };
139
+ readonly check: "tool";
140
+ };
141
+ };
142
+ export type RuntimeName = keyof typeof RUNTIME_SPECS;
143
+ export declare const RUNTIME_NAMES: RuntimeName[];
144
+ /** "claude, codex or kiro": the names as a sentence part, for messages. */
145
+ export declare const runtimeList: () => string;
146
+ export declare function isRuntime(v: unknown): v is RuntimeName;
147
+ /** The spec of a runtime `ach run` drives; undefined for any other name (the hub's `other`, a test's fake). */
148
+ export declare function runtimeSpec(name: unknown): RuntimeSpec | undefined;
149
+ /** How people call a runtime: its label, else the name as it is. */
150
+ export declare const runtimeLabel: (name: string) => string;
151
+ /**
152
+ * The level a run gets on this runtime: the highest it can enforce that is not above `perm` (never raised). undefined:
153
+ * it can enforce none at or below it, so the runner must not start.
154
+ */
155
+ export declare function runtimePerm(spec: Pick<RuntimeSpec, 'perms'>, perm: Perm): Perm | undefined;
156
+ /**
157
+ * Why this run must not start on this runtime (fail closed), or undefined. A local run below `full` needs the tool to keep
158
+ * it from the runner's secrets, and to keep the network limit the hub promises unless the agent's `net_allow` is `*`.
159
+ * `full` is both sides' choice of no limits; a cloud run is not on this machine.
160
+ */
161
+ export declare function runRefusal(spec: Pick<RuntimeSpec, 'label' | 'where' | 'perms' | 'limits'>, run: {
162
+ perm: Perm;
163
+ netAllow?: readonly string[];
164
+ }): string | undefined;
@@ -0,0 +1,104 @@
1
+ import { PERMS, permRank } from '../perm.js';
2
+ const ALL = PERMS;
3
+ export const RUNTIME_SPECS = {
4
+ claude: {
5
+ name: 'claude',
6
+ label: 'Claude Code',
7
+ where: 'local',
8
+ ach: true,
9
+ structuredAnswers: false,
10
+ perms: ALL,
11
+ limits: { net: true, denyRead: true },
12
+ reads: 'scoped',
13
+ budget: true,
14
+ ownerMemory: 'native',
15
+ ownFiles: [],
16
+ lightModel: { model: 'claude-haiku-5-5', effort: 'low' },
17
+ login: { command: 'claude auth login' },
18
+ check: 'sandbox',
19
+ },
20
+ codex: {
21
+ name: 'codex',
22
+ label: 'Codex',
23
+ where: 'local',
24
+ ach: true,
25
+ structuredAnswers: true,
26
+ perms: ALL,
27
+ limits: { net: true, denyRead: true },
28
+ reads: 'scoped',
29
+ budget: false,
30
+ ownerMemory: 'prompt',
31
+ ownFiles: ['AGENTS.md'],
32
+ lightModel: { model: 'gpt-6.1-sol', effort: 'medium' },
33
+ login: { command: 'codex login' },
34
+ check: 'sandbox',
35
+ },
36
+ // each run is a Kiro cloud session: the permission level and the limits are the cloud sandbox's, not this machine's
37
+ kiro: {
38
+ name: 'kiro',
39
+ label: 'Kiro',
40
+ where: 'cloud',
41
+ ach: false,
42
+ structuredAnswers: true,
43
+ perms: ALL,
44
+ limits: { net: false, denyRead: false },
45
+ reads: 'scoped',
46
+ budget: false,
47
+ ownerMemory: 'prompt',
48
+ ownFiles: [],
49
+ login: { key: 'KIRO_API_KEY' },
50
+ check: 'tool',
51
+ },
52
+ // one headless `agy` per run on this machine, with its own sandbox (adapters/antigravity.ts says what was tried by hand): no
53
+ // `ach` in the run (a sandboxed command has no network), its web search cannot be turned off, and it reads outside HOME
54
+ antigravity: {
55
+ name: 'antigravity',
56
+ label: 'Antigravity',
57
+ where: 'local',
58
+ ach: false,
59
+ structuredAnswers: true,
60
+ perms: ALL,
61
+ limits: { net: false, denyRead: true },
62
+ reads: 'machine',
63
+ budget: false,
64
+ ownerMemory: 'prompt',
65
+ ownFiles: [],
66
+ login: { command: 'agy' },
67
+ check: 'tool',
68
+ },
69
+ };
70
+ export const RUNTIME_NAMES = Object.keys(RUNTIME_SPECS);
71
+ /** "claude, codex or kiro": the names as a sentence part, for messages. */
72
+ export const runtimeList = () => RUNTIME_NAMES.join(', ').replace(/, ([^,]*)$/, ' or $1');
73
+ export function isRuntime(v) {
74
+ return typeof v === 'string' && Object.hasOwn(RUNTIME_SPECS, v);
75
+ }
76
+ /** The spec of a runtime `ach run` drives; undefined for any other name (the hub's `other`, a test's fake). */
77
+ export function runtimeSpec(name) {
78
+ return isRuntime(name) ? RUNTIME_SPECS[name] : undefined;
79
+ }
80
+ /** How people call a runtime: its label, else the name as it is. */
81
+ export const runtimeLabel = (name) => runtimeSpec(name)?.label ?? name;
82
+ /**
83
+ * The level a run gets on this runtime: the highest it can enforce that is not above `perm` (never raised). undefined:
84
+ * it can enforce none at or below it, so the runner must not start.
85
+ */
86
+ export function runtimePerm(spec, perm) {
87
+ return [...spec.perms].filter((p) => permRank(p) <= permRank(perm)).sort((a, b) => permRank(b) - permRank(a))[0];
88
+ }
89
+ /**
90
+ * Why this run must not start on this runtime (fail closed), or undefined. A local run below `full` needs the tool to keep
91
+ * it from the runner's secrets, and to keep the network limit the hub promises unless the agent's `net_allow` is `*`.
92
+ * `full` is both sides' choice of no limits; a cloud run is not on this machine.
93
+ */
94
+ export function runRefusal(spec, run) {
95
+ if (!spec.perms.includes(run.perm))
96
+ return `${spec.label} cannot enforce the permission level "${run.perm}"`;
97
+ if (spec.where === 'cloud' || run.perm === 'full')
98
+ return undefined;
99
+ if (!spec.limits.denyRead)
100
+ return `${spec.label} cannot keep a run from reading the runner's secrets on this machine; it runs only with full access (the agent's permission level and the runner's --perm both full)`;
101
+ if (!spec.limits.net && !run.netAllow?.includes('*'))
102
+ return `${spec.label} cannot limit a run's network; it runs only for an agent whose network list allows any host (*)`;
103
+ return undefined;
104
+ }
@@ -1,5 +1,6 @@
1
1
  import type { Perm } from '../perm.js';
2
2
  import type { CapsServerSpec } from '../caps.js';
3
+ import type { RuntimeSpec } from './spec.js';
3
4
  /**
4
5
  * `tool_start` / `tool_end` (data: {id}) bracket one tool call; the runner's
5
6
  * idle watchdog is suspended while any call is in flight (C6). `tool_start` data: {id, name, input}; `tool_end` data: {id, is_error?,
@@ -71,14 +72,10 @@ export interface AdapterResult {
71
72
  error?: string;
72
73
  }
73
74
  export interface RuntimeAdapter {
75
+ /** The same as `spec.name`. */
74
76
  readonly name: string;
75
- /** True when answer runs return JSON (ANSWER_SCHEMA) and the runner posts it (codex). */
76
- readonly structuredAnswers?: boolean;
77
- /**
78
- * True when the agent runs somewhere else (a Kiro cloud sandbox) with no `ach` CLI and no hub credentials: the prompt
79
- * says so, and the runner completes or fails the task with the run's final text (it implies structuredAnswers).
80
- */
81
- readonly remote?: boolean;
77
+ /** What this runtime can and cannot do (docs/specs/runtimes.md): the runner reads this, never the name. */
78
+ readonly spec: RuntimeSpec;
82
79
  run(opts: AdapterRunOptions): Promise<AdapterResult>;
83
80
  /**
84
81
  * The models it offers with the environment a run gets (its login decides which), and the one a run uses when none is picked.
@@ -0,0 +1,21 @@
1
+ import { type Run, type SandboxStatus } from './sandboxcheck.js';
2
+ /** The release the adapter was written against (headless stream-json with tool start/end, `--settings`, `denied_actions`). */
3
+ export declare const AGY_MIN_VERSION = "1.5.13";
4
+ /** agy as the runner will start it: ACH_ANTIGRAVITY_BIN, else `agy` on PATH, else where its installer puts it (~/.local/bin). */
5
+ export declare function agyPathOf(env: NodeJS.ProcessEnv): string | undefined;
6
+ /** Linux: AppArmor stops unprivileged user namespaces and no profile lets agy make them (its sandbox then silently does not start). */
7
+ export declare function agySandboxBlocked(o?: {
8
+ platform?: NodeJS.Platform;
9
+ read?: (p: string) => string | undefined;
10
+ }): boolean;
11
+ /**
12
+ * What the antigravity runtime needs on this machine: agy new enough, logged in (its login file exists; never read), and a
13
+ * sandbox that can start (the default permission level runs commands in it).
14
+ */
15
+ export declare function probeAgy(o?: {
16
+ env?: NodeJS.ProcessEnv;
17
+ run?: Run;
18
+ platform?: NodeJS.Platform;
19
+ exists?: (p: string) => boolean;
20
+ read?: (p: string) => string | undefined;
21
+ }): Promise<SandboxStatus>;
@@ -0,0 +1,58 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { isAbsolute, join } from 'node:path';
3
+ import { AGY_APPARMOR, AGY_INSTALL, agyBin } from './adapters/antigravity.js';
4
+ import { parseKiroVersion as parseVersion, versionAtLeast } from './adapters/kiro.js';
5
+ import { defaultRun, onPath } from './sandboxcheck.js';
6
+ /** The release the adapter was written against (headless stream-json with tool start/end, `--settings`, `denied_actions`). */
7
+ export const AGY_MIN_VERSION = '1.5.13';
8
+ const home = (env) => env.HOME || '';
9
+ /** agy as the runner will start it: ACH_ANTIGRAVITY_BIN, else `agy` on PATH, else where its installer puts it (~/.local/bin). */
10
+ export function agyPathOf(env) {
11
+ const b = agyBin(env);
12
+ if (isAbsolute(b))
13
+ return existsSync(b) ? b : undefined;
14
+ const local = home(env) ? join(home(env), '.local', 'bin', b) : '';
15
+ return onPath(b, env) ?? (local && existsSync(local) ? local : undefined);
16
+ }
17
+ /** Linux: AppArmor stops unprivileged user namespaces and no profile lets agy make them (its sandbox then silently does not start). */
18
+ export function agySandboxBlocked(o = {}) {
19
+ if ((o.platform ?? process.platform) !== 'linux')
20
+ return false;
21
+ const read = o.read ??
22
+ ((p) => {
23
+ try {
24
+ return readFileSync(p, 'utf8');
25
+ }
26
+ catch {
27
+ return undefined;
28
+ }
29
+ });
30
+ if (read('/proc/sys/kernel/apparmor_restrict_unprivileged_userns')?.trim() !== '1')
31
+ return false;
32
+ return read('/etc/apparmor.d/agy') === undefined;
33
+ }
34
+ /**
35
+ * What the antigravity runtime needs on this machine: agy new enough, logged in (its login file exists; never read), and a
36
+ * sandbox that can start (the default permission level runs commands in it).
37
+ */
38
+ export async function probeAgy(o = {}) {
39
+ const env = o.env ?? process.env;
40
+ const tool = 'antigravity';
41
+ const bin = agyPathOf(env);
42
+ if (!bin) {
43
+ return { tool, ok: false, problem: 'missing', missing: ['agy'], detail: 'agy not found', fix: { en: `Install the Antigravity CLI (${AGY_INSTALL}), or set ACH_ANTIGRAVITY_BIN to its path.`, zh: `安装 Antigravity CLI(${AGY_INSTALL}),或用 ACH_ANTIGRAVITY_BIN 指定它的路径。`, commands: [AGY_INSTALL] } };
44
+ }
45
+ const r = await (o.run ?? defaultRun)(bin, ['--version'], { env });
46
+ const version = parseVersion(r.stdout || r.stderr);
47
+ if (!version || !versionAtLeast(version, AGY_MIN_VERSION)) {
48
+ return { tool, ok: false, problem: 'failed', detail: `agy ${version ?? '(unknown version)'}: needs ${AGY_MIN_VERSION} or later`, fix: { en: `Update agy to ${AGY_MIN_VERSION} or later.`, zh: `把 agy 升级到 ${AGY_MIN_VERSION} 或更新。`, commands: [`${bin} update`] } };
49
+ }
50
+ const token = join(home(env), '.gemini', 'antigravity-cli', 'antigravity-oauth-token');
51
+ if (!(o.exists ?? existsSync)(token)) {
52
+ return { tool, ok: false, problem: 'not-logged-in', detail: `agy ${version}; not logged in`, fix: { en: 'Antigravity is not logged in on this machine: run `agy` once as the user that runs this agent and sign in.', zh: 'Antigravity 在这台机器上没有登录:以运行这个智能体的用户身份执行一次 `agy` 并登录。', commands: ['agy'] } };
53
+ }
54
+ if (agySandboxBlocked({ platform: o.platform, read: o.read })) {
55
+ return { tool, ok: false, problem: 'userns-blocked', detail: `agy ${version}; its sandbox cannot start (AppArmor restricts unprivileged user namespaces)`, fix: { en: "AppArmor stops agy from creating the user namespaces its sandbox is made of: add a profile that lets it.", zh: 'AppArmor 不让 agy 创建沙箱需要的用户命名空间:加一条放行它的规则。', commands: [AGY_APPARMOR] } };
56
+ }
57
+ return { tool, ok: true, detail: `agy ${version}, logged in` };
58
+ }
@@ -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 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\",\"date\",\"summary\",\"by\":[logins],\"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; \"-\" reads the text from stdin, e.g. a quoted heredoc)\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 [--model m|default] [--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: string;
20
20
  export {};
package/dist/src/args.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { parseArgs } from 'node:util';
2
+ import { RUNTIME_NAMES } from './adapters/spec.js';
2
3
  const s = { type: 'string' };
3
4
  const b = { type: 'boolean' };
4
5
  const sm = { type: 'string', multiple: true };
@@ -216,7 +217,7 @@ Finishing: ach complete [--task <id>] [--run-id <r>] [--result-file <f> | "<tex
216
217
  Capabilities: ach caps (lists the host capabilities in <agent home>/capabilities.json: commands your runner's agents may run
217
218
  outside their sandbox, with no approval, for anyone who sends them a task or mentions them)
218
219
  ach caps run <name> [arg=value ...] (runs one here, as a run would: to check a declaration)
219
- Runner: ach run --dir <path> [--repo name=path ...] [--runtime claude|codex|kiro] [--interval 3] [--max 2]
220
+ Runner: ach run --dir <path> [--repo name=path ...] [--runtime ${RUNTIME_NAMES.join('|')}] [--interval 3] [--max 2]
220
221
  [--perm read|workdir|full] [--model m] [--pass-env NAME ...]
221
222
  [--claim-delay <sec> | --interactive-first] (default 0; --interactive-first = 60 s for you to claim first)
222
223
  [--no-trace] (keep execution traces on this machine; ACH_NO_TRACE=1 too)
@@ -230,7 +231,7 @@ Admin: ach admin login --link <login link>
230
231
  ach admin users | ach admin create-user --name <n> [--email <e>] [--admin] (prints a 24 h one-time join link)
231
232
  ach admin login-link <email|userId> (a new one-time login link for a new device)
232
233
  ach admin user <email|userId> [--deactivate [--reassign-to <user>] | --reactivate] [--admin true|false] [--confirm-name <name>] [--name n] [--email e]
233
- ach admin create-agent --name <slug> [--owner <email|userId>] --runtime claude|codex|kiro|other --description <d>
234
+ ach admin create-agent --name <slug> [--owner <email|userId>] --runtime ${RUNTIME_NAMES.join('|')}|other --description <d>
234
235
  [--perm read|workdir|full] [--budget <usd>] [--net-allow a.com,b.com] [--invite] [--cf-token]
235
236
  ach admin invite <agent> [--line] [--lang zh|en] [--cf-token] (rotates the key; prints a paragraph to paste into the engineer's
236
237
  Claude/Codex: join, background helper + notifications, a test notification, the inbox. --line: only
@@ -10,6 +10,7 @@ import { UsageError } from './args.js';
10
10
  import { Client, clientFromConfig, HubError, isZh } from './client.js';
11
11
  import { achHome, defaultHome, loadConfig, readFileConfig, resolveClaimDelay, writeFileConfig } from './config.js';
12
12
  import { isPerm } from './perm.js';
13
+ import { isRuntime, runtimePerm } from './adapters/spec.js';
13
14
  import { bootGuard, markHealthy, SelfUpdater, superviseSelf, UPDATE_EXIT_CODE, UPDATE_HANDOFF_EXIT_CODE, waitForWindowsUpdate } from './selfupdate.js';
14
15
  import { inheritedEnv } from './env.js';
15
16
  import { parseNum, splitList, str } from './cli-shared.js';
@@ -90,8 +91,8 @@ export async function runCommand(p, io) {
90
91
  io.out(removed.length ? `removed ${removed.length} worktree(s): ${removed.join(', ')}` : 'nothing to remove');
91
92
  return 0;
92
93
  }
93
- const perm = (str(v.perm) ?? 'workdir');
94
- if (!isPerm(perm))
94
+ const asked = (str(v.perm) ?? 'workdir');
95
+ if (!isPerm(asked))
95
96
  throw new UsageError('run: --perm must be read|workdir|full');
96
97
  const claimDelay = resolveClaimDelay({
97
98
  claimDelay: str(v['claim-delay']) ? parseNum(str(v['claim-delay']), 'claim-delay') : undefined,
@@ -113,9 +114,9 @@ export async function runCommand(p, io) {
113
114
  const moved = await moveOldService(io, me.name, home);
114
115
  if (moved)
115
116
  return UPDATE_EXIT_CODE;
116
- const runtime = str(v.runtime) ?? (me.runtime === 'codex' || me.runtime === 'kiro' ? me.runtime : 'claude');
117
+ const runtime = str(v.runtime) ?? (isRuntime(me.runtime) ? me.runtime : 'claude');
117
118
  // what the permission and the network list do not cover, said where the person starting the runner will read it
118
- if (perm === 'full')
119
+ if (asked === 'full')
119
120
  io.err('warning: --perm full runs commands with no sandbox (bypassPermissions): anything in a task that reaches the agent can run anything with your rights.');
120
121
  const { makeAdapter } = await import('./adapters/index.js');
121
122
  let adapter;
@@ -125,6 +126,15 @@ export async function runCommand(p, io) {
125
126
  catch (e) {
126
127
  throw new UsageError(`run: ${e.message}`);
127
128
  }
129
+ // the level this runtime can enforce, never above the one asked for (docs/specs/runtimes.md §4)
130
+ const perm = runtimePerm(adapter.spec, asked);
131
+ if (!perm)
132
+ throw new UsageError(`run: ${adapter.spec.label} cannot enforce --perm ${asked} (it enforces: ${adapter.spec.perms.join(', ')})`);
133
+ if (perm !== asked)
134
+ io.err(`ach run: ${adapter.spec.label} cannot enforce --perm ${asked}; running with ${perm}`);
135
+ // what this tool's sandbox does not hold, said where the person starting the runner reads it (docs/specs/runtimes.md §4)
136
+ if (adapter.spec.reads === 'machine' && perm !== 'full')
137
+ io.err(`warning: ${adapter.spec.label} can read files outside the task directory on this machine (other checkouts, /tmp); only your home directory is hidden from its commands.`);
128
138
  // keeps this runner on the hub's release: waits for the runs in flight, installs, exits UPDATE_EXIT_CODE so the service restarts
129
139
  const passEnv = (Array.isArray(v['pass-env']) ? v['pass-env'] : []).flatMap(splitList);
130
140
  const baseEnv = (() => {
@@ -168,14 +178,10 @@ export async function runCommand(p, io) {
168
178
  baseEnv,
169
179
  log: io.err,
170
180
  sandboxCheck: async () => {
171
- // kiro runs in Kiro's cloud sandbox: what this machine needs is kiro-cli and its key
172
- if (runtime === 'kiro')
173
- return (await import('./kirocheck.js')).probeKiro({ env });
174
- const { probeEnvironment } = await import('./envcheck.js');
175
181
  // the sandboxed command gets the env a run gets (inherited vars and a scratch home like a task's), so what a run cannot start
176
182
  // without shows here, not in the first task (TASK-59)
177
183
  const { env: homeEnv } = prepareAgentHome(join(tmpdir(), 'ach-homes'), me.name, 'startup-check', realHomeOf(baseEnv), baseEnv.CODEX_HOME || undefined);
178
- return probeEnvironment(runtime === 'codex' ? 'codex' : 'claude', { env, hub: cfg.hub, runEnv: { ...inheritedEnv(baseEnv, passEnv), ...homeEnv } });
184
+ return (await import('./runtimecheck.js')).probeRuntime(adapter.spec.name, { env, hub: cfg.hub, runEnv: { ...inheritedEnv(baseEnv, passEnv), ...homeEnv } });
179
185
  },
180
186
  });
181
187
  io.err(`ach run: agent ${me.name}, runtime ${runtime}, perm min(${me.perm_level}, ${perm}), model ${me.model || str(v.model) || 'default'}, dir ${dir}` +
@@ -54,10 +54,10 @@ export declare function runDoctor(o: {
54
54
  env: NodeJS.ProcessEnv;
55
55
  hub?: string;
56
56
  }) => Promise<import('./sandboxcheck.js').SandboxStatus>;
57
- /** Tests: the kiro runtime's machine check (kiro-cli and KIRO_API_KEY). */
58
- kiro?: (o: {
57
+ /** Tests: the machine check of a runtime that has its own (kiro: kiro-cli and KIRO_API_KEY), by runtime name. */
58
+ toolCheck?: Record<string, (o: {
59
59
  env: NodeJS.ProcessEnv;
60
- }) => Promise<import('./sandboxcheck.js').SandboxStatus>;
60
+ }) => Promise<import('./sandboxcheck.js').SandboxStatus>>;
61
61
  }): Promise<DoctorCheck[]>;
62
62
  /**
63
63
  * Command, args and AGENTCHANNEL_HOME of an MCP entry from `claude mcp get`
@@ -1,4 +1,5 @@
1
1
  import { execFile } from 'node:child_process';
2
+ import { runtimeSpec } from './adapters/spec.js';
2
3
  import { existsSync } from 'node:fs';
3
4
  import { createRequire } from 'node:module';
4
5
  import { dirname, join } from 'node:path';
@@ -316,18 +317,23 @@ export async function runDoctor(o) {
316
317
  if (codexPath)
317
318
  await mcpCheck('codex', codexPath);
318
319
  }
319
- // kiro: the agent runs in Kiro's cloud sandbox; this machine needs kiro-cli (new enough for headless --cloud) and KIRO_API_KEY
320
- const { kiroBin, probeKiro } = await import('./kirocheck.js');
321
- if (runtime === 'kiro' || kiroBin(env)) {
322
- const st = await (o.kiro ?? probeKiro)({ env });
320
+ // runtimes with their own machine check (kiro: kiro-cli new enough for headless --cloud and KIRO_API_KEY; the run itself is in
321
+ // Kiro's cloud sandbox): checked when it is this agent's runtime, or when the tool is on this machine
322
+ const { TOOL_CHECKS } = await import('./runtimecheck.js');
323
+ for (const [name, check] of Object.entries(TOOL_CHECKS)) {
324
+ const mine = runtime === name;
325
+ if (!mine && !(await check.installed(env)))
326
+ continue;
327
+ const spec = runtimeSpec(name);
328
+ const st = await (o.toolCheck?.[name] ?? check.probe)({ env });
323
329
  if (st.ok)
324
- add('kiro', 'ok', `${st.detail}; runs go to Kiro cloud sandboxes`);
330
+ add(name, 'ok', `${st.detail}${spec.where === 'cloud' ? `; runs go to ${spec.label} cloud sandboxes` : ''}`);
325
331
  else
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);
332
+ add(name, mine ? 'fail' : 'info', `${st.detail}.${mine ? ' The background runner takes no tasks until this is fixed.' : ` (needed only for the ${name} runtime)`}`, 'machine', st.fix?.commands.length ? st.fix.commands.join('\n ') : st.fix?.en);
327
333
  }
328
334
  // decisions §27: the agent tool's sandbox, probed for real (every run that answers a question or an @mention is sandboxed)
329
335
  const { probeSandbox } = await import('./sandboxcheck.js');
330
- const tools = runtime === 'kiro' ? [] : runtime === 'codex' ? ['codex'] : runtime === 'claude' ? ['claude'] : [...(claude ? ['claude'] : []), ...(codexPath || bundled ? ['codex'] : [])];
336
+ const tools = runtime && runtimeSpec(runtime)?.check !== 'sandbox' ? [] : runtime === 'codex' ? ['codex'] : runtime === 'claude' ? ['claude'] : [...(claude ? ['claude'] : []), ...(codexPath || bundled ? ['codex'] : [])];
331
337
  for (const t of tools) {
332
338
  const st = await (o.sandbox ?? probeSandbox)(t, { env, hub: cfg.hub });
333
339
  const name = `${t} sandbox`;
@@ -240,7 +240,7 @@ async function fixSandbox(io, s, before, probe, zh) {
240
240
  }
241
241
  let ok = true;
242
242
  for (const st of before.filter((x) => !x.ok)) {
243
- if (st.tool === 'kiro')
243
+ if (st.tool !== 'claude' && st.tool !== 'codex')
244
244
  continue; // onboarding probes only the local sandboxes
245
245
  const now = await probe(st.tool);
246
246
  if (now.ok)
@@ -26,6 +26,8 @@ export interface PromptCtx {
26
26
  wiki?: WikiContext | null;
27
27
  /** The agent runs in a cloud sandbox (kiro) without `ach` or this machine's files: the runner reports its final message. */
28
28
  remote?: boolean;
29
+ /** The run has no `ach` (spec `ach: false`): it ends with a final message the runner reports. With `remote` the cloud rules apply; without, it works here. */
30
+ report?: boolean;
29
31
  /** The owner's Claude Code memory for this project: its folder (readable) and, when the runtime does not load it itself, its index. */
30
32
  ownerMemory?: {
31
33
  dir: string;
@@ -150,8 +152,10 @@ export declare function githubRule(url?: string): string;
150
152
  * was not enough: what other agents state as fact has to be checked, or marked as theirs.
151
153
  */
152
154
  export declare const FACT_RULE = "What another agent states as fact (that something exists or not, works or not, a setting, a price, a result) is its claim, not evidence: check it at its source before you rely on it; when you cannot, say whose claim it is and that you did not check it. Never write a claim you relayed as something you found.";
153
- /** The final-message contract of remote (cloud sandbox) runs: the runner completes or fails the task from it. */
155
+ /** The final-message contract of runs without `ach` (a cloud sandbox, a local tool without it): the runner completes or fails the task from it. */
154
156
  export declare const REMOTE_FAILED_PREFIX = "FAILED:";
157
+ /** JUDGMENT for a run without `ach`: the same lines of decision, said in the final message instead of through commands. */
158
+ export declare const JUDGMENT_REPORT: string;
155
159
  /** Trusted text: where the other repos of a cross-repo task are (read-only). */
156
160
  export declare function readReposText(repos?: {
157
161
  name: string;
@@ -171,6 +175,8 @@ export declare function buildResumePrompt(c: {
171
175
  nudge?: boolean;
172
176
  /** cloud sandbox run (kiro): no `ach`; it ends with a final message the runner reports. */
173
177
  remote?: boolean;
178
+ /** a run without `ach` that works here: local files, a final message the runner reports. */
179
+ report?: boolean;
174
180
  }): string;
175
181
  /** JSON schema for structured answers (codex answer runs, S4): the runner posts the result. */
176
182
  export declare const ANSWER_SCHEMA: {