@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.
@@ -314,8 +314,28 @@ function rules(review) {
314
314
  LINK_RULE,
315
315
  ].join('\n');
316
316
  }
317
- /** The final-message contract of remote (cloud sandbox) runs: the runner completes or fails the task from it. */
317
+ /** 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. */
318
318
  export const REMOTE_FAILED_PREFIX = 'FAILED:';
319
+ /** JUDGMENT for a run without `ach`: the same lines of decision, said in the final message instead of through commands. */
320
+ export const JUDGMENT_REPORT = [
321
+ 'How to decide (AgentChannel\'s default for every agent):',
322
+ '- Do it yourself when all of these hold: it is within this task and this repository; it can be undone or reviewed (a branch, a pull request, a draft), not production, money, deleting data or a message outside the team; you already have what it needs (no new secret, permission or network access); its cost is within what was granted.',
323
+ `- You cannot ask anyone during this run. When something is missing (information another agent has, a secret, a permission, network access), or the step is irreversible or outside (production, merging to main, deleting, paying, contacting someone outside), or it is a choice of direction: do not guess and do not do it. Start your final message with "${REMOTE_FAILED_PREFIX}" and say exactly what is missing or who decides, what is done and what is not.`,
324
+ "- Your owner's notes and the project's instructions (below, when present) say how this owner and this project work: follow them. When two of them disagree, follow the more specific one unless it would loosen a rule in this list, and say so in your final message.",
325
+ "- Never copy what your owner's notes say about secrets, accounts, machines or people into results, messages or files that others read.",
326
+ '',
327
+ ].join('\n');
328
+ /** The rules of a run that works on this machine without `ach`: the runner commits, delivers and reports. */
329
+ const LOCAL_REPORT_RULES = [
330
+ 'Rules:',
331
+ "- Work only inside the current directory. Do not commit or push: when your run ends, the runner commits your changes on this task's branch and, when the repository is on GitHub, pushes it and opens the task's pull request (the deliverable).",
332
+ '- There is no `ach` CLI and there are no AgentChannel credentials in this run, and commands may have no network: do not try to reach AgentChannel or to install anything from the network. The runner reports your final message to the task.',
333
+ "- Before you finish, run the project's own checks (build, type check, tests: what its CLAUDE.md, AGENTS.md, Makefile or package scripts say) on what you changed, when this run may run commands. Put the commands you ran and their outcome in the final message. Checks that fail mean the work is not done: fix it, or say so.",
334
+ `- ${UNTRUSTED_RULE}`,
335
+ '- When you answer a question, answer only with evidence: files, commands, outputs.',
336
+ LINK_RULE,
337
+ `- End with your final message: what you did and how you verified it (it becomes the task's result and the pull request's description). If the task cannot be done, or a step it requires could not be done or checked, start the final message with "${REMOTE_FAILED_PREFIX}" and the reason, what is done and what is missing. Anything about money, product direction or irreversible actions: do not do it; say so in the final message.`,
338
+ ].join('\n');
319
339
  const REMOTE_RULES = [
320
340
  'Rules:',
321
341
  '- You run in a cloud sandbox on a fresh clone of this repository. There is no `ach` CLI and there are no AgentChannel credentials here: do not try to reach AgentChannel. The runner reports your final message to the task.',
@@ -354,7 +374,7 @@ export function buildTaskPrompt(c) {
354
374
  '',
355
375
  ...langText(c.lang),
356
376
  ...(c.remote ? [] : readReposText(c.readRepos)),
357
- ...(c.remote ? [] : [JUDGMENT]),
377
+ ...(c.remote ? [] : [c.report ? JUDGMENT_REPORT : JUDGMENT]),
358
378
  ...conventionsText(c.judgment, c.ownerName),
359
379
  ...projectText(c.project),
360
380
  ...(c.remote ? [] : ownerMemoryText(c.ownerMemory)),
@@ -367,10 +387,10 @@ export function buildTaskPrompt(c) {
367
387
  'Task data:',
368
388
  untrustedBlock(data),
369
389
  '',
370
- c.remote ? REMOTE_RULES : rules(!!c.task.review),
390
+ c.remote ? REMOTE_RULES : c.report ? LOCAL_REPORT_RULES : rules(!!c.task.review),
371
391
  githubRule(c.taskUrl),
372
392
  '',
373
- c.remote ? 'Finish with your final message.' : 'Finish by calling `ach complete`.',
393
+ c.remote || c.report ? 'Finish with your final message.' : 'Finish by calling `ach complete`.',
374
394
  ].join('\n');
375
395
  }
376
396
  /** Resume prompt after a parked run: new answers / decisions arrived, the handoff changed, or (nudge) the agent stopped without finishing. */
@@ -398,7 +418,7 @@ export function buildResumePrompt(c) {
398
418
  if (c.handoffChanged !== undefined) {
399
419
  lines.push(`- The sender updated the task (now handoff v${c.handoffVersion}): follow the new handoff and header (priority, purpose, money, key question) above.`);
400
420
  }
401
- lines.push(c.remote
421
+ lines.push(c.remote || c.report
402
422
  ? `Continue the task. End with your final message (start it with "${REMOTE_FAILED_PREFIX}" if it cannot be done).`
403
423
  : 'Continue the task. Use `ach ask` / `ach ask-human` again if needed. Finish by calling `ach complete`.');
404
424
  return lines.join('\n');
@@ -18,7 +18,7 @@ export interface ProjectFile {
18
18
  text: string;
19
19
  }
20
20
  /**
21
- * The project's instructions at the root of the work dir. CLAUDE.md always; AGENTS.md except for Codex, which reads it itself.
21
+ * The project's instructions at the root of the work dir. CLAUDE.md and AGENTS.md, without the ones the runtime loads by itself (`ownFiles` of its spec: Codex reads AGENTS.md).
22
22
  * Trusted like the code: a sender-chosen base that changes them waits for the owner's approval (S1).
23
23
  */
24
- export declare function projectInstructions(workdir: string, runtime: string): ProjectFile[];
24
+ export declare function projectInstructions(workdir: string, ownFiles?: readonly string[]): ProjectFile[];
@@ -40,11 +40,11 @@ export function memoryIndex(dir) {
40
40
  }
41
41
  }
42
42
  /**
43
- * The project's instructions at the root of the work dir. CLAUDE.md always; AGENTS.md except for Codex, which reads it itself.
43
+ * The project's instructions at the root of the work dir. CLAUDE.md and AGENTS.md, without the ones the runtime loads by itself (`ownFiles` of its spec: Codex reads AGENTS.md).
44
44
  * Trusted like the code: a sender-chosen base that changes them waits for the owner's approval (S1).
45
45
  */
46
- export function projectInstructions(workdir, runtime) {
47
- const names = runtime === 'codex' ? ['CLAUDE.md'] : ['CLAUDE.md', 'AGENTS.md'];
46
+ export function projectInstructions(workdir, ownFiles = []) {
47
+ const names = ['CLAUDE.md', 'AGENTS.md'].filter((f) => !ownFiles.includes(f));
48
48
  const out = [];
49
49
  for (const file of names) {
50
50
  const p = join(workdir, file);
@@ -318,6 +318,10 @@ export declare class Runner {
318
318
  private postStructuredAnswer;
319
319
  /** Readable roots for the spawned agent besides its cwd (S4). */
320
320
  private readRoots;
321
+ /** The run works elsewhere (a cloud sandbox): nothing of this machine (files, memory, capabilities) reaches it. */
322
+ private get cloud();
323
+ /** Short runs return JSON by a schema and the runner posts it: the runtime's way, and the only way without `ach` in the run. */
324
+ private get structured();
321
325
  /** Owned by no one person (the system agent, or a team agent such as one that does a channel mechanism for the team). */
322
326
  private teamOwned;
323
327
  /** What a full task prompt carries besides the task: the owner's memory for this project and the project's instructions. */
@@ -9,6 +9,7 @@ import { capsPath, capsPromptText, capsServeArgs, loadCaps } from '../caps.js';
9
9
  import { autorunPath, loadAutorun, ruleName, smallRule } from '../autorun.js';
10
10
  import { toolchainReadRoots } from '../adapters/paths.js';
11
11
  import { developerDir } from '../adapters/scope.js';
12
+ import { isRuntime, runRefusal } from '../adapters/spec.js';
12
13
  import { modelId } from '../adapters/types.js';
13
14
  import { Client as HubClient, HubError, isTerminal } from '../client.js';
14
15
  import { taskFiles } from '../attachments.js';
@@ -408,7 +409,7 @@ export class Runner {
408
409
  if (!billing && !(result.ok && this.account))
409
410
  return;
410
411
  const was = this.account;
411
- const tool = ['claude', 'codex', 'kiro'].find((x) => x === this.o.adapter.name) ?? 'claude';
412
+ const tool = this.o.adapter.name;
412
413
  if (billing) {
413
414
  const st = { tool, ok: false, problem: 'billing', detail: summarizeRuntimeError(result.error ?? '').slice(0, 300) };
414
415
  st.fix = sandboxFix(st, detectHost(process.env, process.platform));
@@ -458,7 +459,7 @@ export class Runner {
458
459
  describeNextAt = 0;
459
460
  async describeAgent() {
460
461
  const { adapter, client, workspace } = this.o;
461
- if (this.describeDone || this.describeBusy || Date.now() < this.describeNextAt || adapter.remote || !client.reportDescription || !workspace.repoDirs)
462
+ if (this.describeDone || this.describeBusy || Date.now() < this.describeNextAt || this.cloud || !client.reportDescription || !workspace.repoDirs)
462
463
  return;
463
464
  this.describeBusy = true;
464
465
  try {
@@ -477,6 +478,9 @@ export class Runner {
477
478
  const ctl = new AbortController();
478
479
  const timer = setTimeout(() => ctl.abort(), 3 * 60_000);
479
480
  try {
481
+ const refused = runRefusal(adapter.spec, { perm: 'read', ...(Array.isArray(me.net_allow) ? { netAllow: me.net_allow } : {}) });
482
+ if (refused)
483
+ return { ok: false, finalText: '', error: `not run: ${refused}` };
480
484
  return await adapter.run({
481
485
  ...(pick ? { model: pick.model, effort: pick.effort } : {}),
482
486
  prompt: describePrompt(me.name, dirs),
@@ -491,8 +495,8 @@ export class Runner {
491
495
  readRoots: dirs.map(([, d]) => d),
492
496
  ...(env.TMPDIR ? { tmpDir: env.TMPDIR } : {}),
493
497
  ...(Array.isArray(me.net_allow) ? { netAllow: me.net_allow } : {}),
494
- ...(adapter.name === 'claude' ? { maxBudgetUsd: 0.05 } : {}),
495
- ...(adapter.structuredAnswers ? { outputSchema: DESCRIBE_SCHEMA } : {}),
498
+ ...(adapter.spec.budget ? { maxBudgetUsd: 0.05 } : {}),
499
+ ...(this.structured ? { outputSchema: DESCRIBE_SCHEMA } : {}),
496
500
  onEvent: () => { },
497
501
  });
498
502
  }
@@ -501,7 +505,7 @@ export class Runner {
501
505
  }
502
506
  };
503
507
  // the light model where the runtime has one; a model the account cannot use falls back to the runtime's default
504
- const light = DESCRIBE_MODELS[adapter.name];
508
+ const light = adapter.spec.lightModel;
505
509
  let r = await run(light);
506
510
  if (!r.ok && light)
507
511
  r = await run(undefined);
@@ -541,12 +545,12 @@ export class Runner {
541
545
  if (!this.o.client.reportRunner)
542
546
  return;
543
547
  // the names and descriptions only, never the commands: teammates see them in the agent directory
544
- const capabilities = this.o.adapter.remote ? [] : loadCaps(this.o.capsFile ?? capsPath(this.o.home)).caps.map((c) => ({ name: c.name, description: c.description.slice(0, 300) }));
548
+ const capabilities = this.cloud ? [] : loadCaps(this.o.capsFile ?? capsPath(this.o.home)).caps.map((c) => ({ name: c.name, description: c.description.slice(0, 300) }));
545
549
  const sig = JSON.stringify(capabilities);
546
550
  if (this.runnerReported && sig === this.capsReported)
547
551
  return;
548
552
  const runtime = this.o.adapter.name;
549
- if (runtime !== 'claude' && runtime !== 'codex' && runtime !== 'kiro') {
553
+ if (!isRuntime(runtime)) {
550
554
  this.runnerReported = true;
551
555
  this.capsReported = sig;
552
556
  return;
@@ -850,7 +854,7 @@ export class Runner {
850
854
  /** Whether this runner reads new tasks ahead: a local runtime in a git checkout that delivers pull requests, and a hub that knows how. */
851
855
  readsAhead(me) {
852
856
  const { client, workspace, adapter } = this.o;
853
- return !!this.o.readAhead && !this.noReadAhead && me.role !== 'system' && !adapter.remote && !!workspace.deliverable && !!client.prepareRun && !!client.prepared;
857
+ return !!this.o.readAhead && !this.noReadAhead && me.role !== 'system' && !this.cloud && !!workspace.deliverable && !!client.prepareRun && !!client.prepared;
854
858
  }
855
859
  /**
856
860
  * The read-ahead (owner-pulls-tasks.md): a short read-only run on a task nobody took yet. It reports whether the task changes code,
@@ -1032,7 +1036,8 @@ export class Runner {
1032
1036
  channel: await this.channelContext(claim.task),
1033
1037
  wiki: claim.wiki,
1034
1038
  judgment: claim.judgment,
1035
- remote: !!this.o.adapter.remote,
1039
+ remote: !!this.cloud,
1040
+ report: !this.o.adapter.spec.ach,
1036
1041
  ...this.runContext(workdir),
1037
1042
  });
1038
1043
  this.reportPromptSize(taskId, rec.runId, prompt);
@@ -1116,7 +1121,8 @@ export class Runner {
1116
1121
  handoffChanged,
1117
1122
  files: files.filter((f) => !shown.has(f.key)).map(promptFile),
1118
1123
  nudge,
1119
- remote: !!this.o.adapter.remote,
1124
+ remote: !!this.cloud,
1125
+ report: !this.o.adapter.spec.ach,
1120
1126
  })
1121
1127
  : buildTaskPrompt({
1122
1128
  agentName: me.name,
@@ -1133,7 +1139,8 @@ export class Runner {
1133
1139
  channel: await this.channelContext(bundle.task),
1134
1140
  wiki: bundle.wiki,
1135
1141
  judgment: bundle.judgment,
1136
- remote: !!this.o.adapter.remote,
1142
+ remote: !!this.cloud,
1143
+ report: !this.o.adapter.spec.ach,
1137
1144
  ...this.runContext(rec.workdir),
1138
1145
  });
1139
1146
  if (!resume)
@@ -1321,9 +1328,15 @@ export class Runner {
1321
1328
  this.state.drop(taskId);
1322
1329
  return;
1323
1330
  }
1324
- // A remote (cloud sandbox) agent has no `ach`: its final message is the result, reported here.
1325
- if (this.o.adapter.remote && task.status === 'working') {
1331
+ // A run without `ach` (a cloud sandbox, a local tool that gets none): its final message is the result, reported here.
1332
+ if (!this.o.adapter.spec.ach && task.status === 'working') {
1326
1333
  await this.reportRemote(rec, result);
1334
+ // a run that worked here left its changes in the task's branch (committed above): now that the task is finished, deliver them
1335
+ if (!this.cloud) {
1336
+ const after = await client.getTask(taskId).catch(() => undefined);
1337
+ if (after)
1338
+ await this.deliverPr(rec, after.task, after.messages);
1339
+ }
1327
1340
  this.state.drop(taskId);
1328
1341
  return;
1329
1342
  }
@@ -1419,7 +1432,7 @@ export class Runner {
1419
1432
  const key = `mention-${mid}`;
1420
1433
  const threadId = run.thread.id;
1421
1434
  const rec = { taskId: key, runId, phase: 'running', workdir: this.o.dir, runToken: run.run_token, tokenAt: Date.now(), seen: [] };
1422
- const structured = !!this.o.adapter.structuredAnswers;
1435
+ const structured = !!this.structured;
1423
1436
  // how it went, told to the hub when the mention is closed: a run that ends with nothing said in the thread is made visible there
1424
1437
  let outcome = { ok: false, error: 'the run did not finish' };
1425
1438
  let recorded;
@@ -1505,7 +1518,7 @@ export class Runner {
1505
1518
  const bundle = await this.o.client.getTask(taskId);
1506
1519
  const cwd = this.state.get(taskId)?.workdir ?? this.o.dir;
1507
1520
  const rec = { taskId, runId, phase: 'running', workdir: cwd, runToken: token, tokenAt: Date.now(), seen: [] };
1508
- const structured = !!this.o.adapter.structuredAnswers;
1521
+ const structured = !!this.structured;
1509
1522
  const prompt = buildAnswerPrompt({
1510
1523
  agentName: me.name,
1511
1524
  ownerName: me.owner_name,
@@ -1565,19 +1578,28 @@ export class Runner {
1565
1578
  ...(this.teamOwned() ? [] : [ownerMemoryDir(cwd, home)].filter((d) => !!d)),
1566
1579
  ];
1567
1580
  }
1581
+ /** The run works elsewhere (a cloud sandbox): nothing of this machine (files, memory, capabilities) reaches it. */
1582
+ get cloud() {
1583
+ return this.o.adapter.spec.where === 'cloud';
1584
+ }
1585
+ /** Short runs return JSON by a schema and the runner posts it: the runtime's way, and the only way without `ach` in the run. */
1586
+ get structured() {
1587
+ const spec = this.o.adapter.spec;
1588
+ return spec.structuredAnswers || !spec.ach;
1589
+ }
1568
1590
  /** Owned by no one person (the system agent, or a team agent such as one that does a channel mechanism for the team). */
1569
1591
  teamOwned() {
1570
1592
  return this.me?.kind === 'team';
1571
1593
  }
1572
1594
  /** What a full task prompt carries besides the task: the owner's memory for this project and the project's instructions. */
1573
1595
  runContext(workdir) {
1574
- if (this.o.adapter.remote)
1596
+ if (this.cloud)
1575
1597
  return { project: [] };
1576
1598
  // a team agent (the system agent too) works for the team: no person's memory, whatever machine it runs on (docs/mechanisms.md)
1577
1599
  const dir = this.teamOwned() ? undefined : ownerMemoryDir(workdir, realHomeOf(this.o.baseEnv ?? process.env));
1578
1600
  // Claude Code shows the index itself (it keys memory by the repository); other runtimes get it in the prompt
1579
- const ownerMemory = dir ? { dir, ...(this.o.adapter.name === 'claude' ? {} : { index: memoryIndex(dir) }) } : undefined;
1580
- return { ownerMemory, project: projectInstructions(workdir, this.o.adapter.name) };
1601
+ const ownerMemory = dir ? { dir, ...(this.o.adapter.spec.ownerMemory === 'native' ? {} : { index: memoryIndex(dir) }) } : undefined;
1602
+ return { ownerMemory, project: projectInstructions(workdir, this.o.adapter.spec.ownFiles) };
1581
1603
  }
1582
1604
  /** Where a task's attachments are downloaded for its agents (readable, outside the worktree). */
1583
1605
  filesDir(taskId) {
@@ -1748,7 +1770,13 @@ export class Runner {
1748
1770
  });
1749
1771
  let m = model;
1750
1772
  let ef = effort;
1751
- result = await go(m, ef);
1773
+ // fail closed (docs/specs/runtimes.md §4): what the tool cannot enforce for this run is not allowed to happen
1774
+ const refused = runRefusal(this.o.adapter.spec, { perm, ...(Array.isArray(me.net_allow) ? { netAllow: me.net_allow } : {}) });
1775
+ if (refused) {
1776
+ recorder.event({ type: 'error', data: `not run: ${refused}` });
1777
+ this.taskLog(taskId, `not run: ${refused}`);
1778
+ }
1779
+ result = refused ? { ok: false, finalText: '', error: `not run: ${refused}` } : await go(m, ef);
1752
1780
  // the runtime's program was not there: most often another ach on this machine is installing a new release into the npx
1753
1781
  // cache they share, which takes seconds. Once more after a wait; only a second miss reaches the hub as a broken install.
1754
1782
  if (!result.ok && !toolsRan && !entry.controller.signal.aborted && programMissing(result.error)) {
@@ -1816,7 +1844,7 @@ export class Runner {
1816
1844
  }
1817
1845
  /** decisions §34: the capabilities server of one run, or undefined when nothing is declared (or the run is in the cloud). */
1818
1846
  capsFor(taskId, runId, realHome, tmpDir) {
1819
- if (this.o.adapter.remote)
1847
+ if (this.cloud)
1820
1848
  return undefined;
1821
1849
  const file = this.o.capsFile ?? capsPath(this.o.home);
1822
1850
  const { caps, problems } = loadCaps(file);
@@ -1932,10 +1960,6 @@ function promptFile(f) {
1932
1960
  }
1933
1961
  /** The light model that writes an agent's description, per runtime (none listed: the runtime's default). A runtime that does not
1934
1962
  * take it runs the default instead. */
1935
- const DESCRIBE_MODELS = {
1936
- claude: { model: 'claude-haiku-5-5', effort: 'low' },
1937
- codex: { model: 'gpt-6.1-sol', effort: 'medium' },
1938
- };
1939
1963
  const DESCRIBE_SCHEMA = { type: 'object', properties: { description: { type: 'string' } }, required: ['description'], additionalProperties: false };
1940
1964
  function describePrompt(name, dirs) {
1941
1965
  const where = dirs.map(([n, d]) => `- ${n}: ${d}`).join('\n');
@@ -0,0 +1,26 @@
1
+ import { RUNTIME_SPECS, type RuntimeName } from './adapters/spec.js';
2
+ import type { SandboxStatus } from './sandboxcheck.js';
3
+ /**
4
+ * What a runtime needs on this machine before its runner takes a task (docs/specs/runtimes.md, `check`): for a tool with a
5
+ * local sandbox, its login and a real sandbox probe; for any other, the runtime's own probe (binary, version, key).
6
+ */
7
+ export interface ToolCheck {
8
+ /** The tool is on this machine (doctor then checks it even when the agent's runtime is another one). */
9
+ installed(env: NodeJS.ProcessEnv): Promise<boolean>;
10
+ probe(o: {
11
+ env: NodeJS.ProcessEnv;
12
+ }): Promise<SandboxStatus>;
13
+ }
14
+ type ToolRuntime = {
15
+ [K in RuntimeName]: (typeof RUNTIME_SPECS)[K]['check'] extends 'tool' ? K : never;
16
+ }[RuntimeName];
17
+ /** The probes of the runtimes whose spec says `check: 'tool'`: one entry each (a missing one does not compile). */
18
+ export declare const TOOL_CHECKS: Record<ToolRuntime, ToolCheck>;
19
+ export declare const toolCheck: (name: string) => ToolCheck | undefined;
20
+ /** The machine check `ach run` does when it starts, and again while a problem lasts. */
21
+ export declare function probeRuntime(name: RuntimeName, o: {
22
+ env: NodeJS.ProcessEnv;
23
+ hub?: string;
24
+ runEnv?: NodeJS.ProcessEnv;
25
+ }): Promise<SandboxStatus>;
26
+ export {};
@@ -0,0 +1,20 @@
1
+ /** The probes of the runtimes whose spec says `check: 'tool'`: one entry each (a missing one does not compile). */
2
+ export const TOOL_CHECKS = {
3
+ kiro: {
4
+ installed: async (env) => !!(await import('./kirocheck.js')).kiroBin(env),
5
+ probe: async (o) => (await import('./kirocheck.js')).probeKiro(o),
6
+ },
7
+ antigravity: {
8
+ installed: async (env) => !!(await import('./agycheck.js')).agyPathOf(env),
9
+ probe: async (o) => (await import('./agycheck.js')).probeAgy(o),
10
+ },
11
+ };
12
+ export const toolCheck = (name) => (Object.hasOwn(TOOL_CHECKS, name) ? TOOL_CHECKS[name] : undefined);
13
+ /** The machine check `ach run` does when it starts, and again while a problem lasts. */
14
+ export async function probeRuntime(name, o) {
15
+ const tool = toolCheck(name);
16
+ if (tool)
17
+ return tool.probe({ env: o.env });
18
+ const { probeEnvironment } = await import('./envcheck.js');
19
+ return probeEnvironment(name, o);
20
+ }
@@ -39,7 +39,8 @@ export interface SandboxFix {
39
39
  commands: string[];
40
40
  }
41
41
  export interface SandboxStatus {
42
- tool: SandboxTool | 'kiro';
42
+ /** the runtime's name (adapters/spec.ts) */
43
+ tool: string;
43
44
  ok: boolean;
44
45
  /** ok, but the probe could not run (an older Codex without `codex sandbox`): not blocking, doctor warns. */
45
46
  unverified?: boolean;
@@ -1,4 +1,5 @@
1
1
  import { execFile } from 'node:child_process';
2
+ import { runtimeLabel, runtimeSpec } from './adapters/spec.js';
2
3
  import { randomBytes } from 'node:crypto';
3
4
  import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
4
5
  import { createRequire } from 'node:module';
@@ -361,7 +362,11 @@ export const BWRAP_APPARMOR = `printf '%s\\n' 'abi <abi/4.0>,' 'include <tunable
361
362
  `| sudo tee /etc/apparmor.d/bwrap >/dev/null && sudo apparmor_parser -r /etc/apparmor.d/bwrap`;
362
363
  /** The fix for a failed probe on this host. */
363
364
  export function sandboxFix(st, host) {
364
- const name = st.tool === 'claude' ? 'Claude Code' : st.tool === 'kiro' ? 'Kiro' : 'Codex';
365
+ const name = runtimeLabel(st.tool);
366
+ // how this tool is logged in (its spec): a command a person runs, or a key in the runner's environment
367
+ const login = runtimeSpec(st.tool)?.login;
368
+ const cmd = login && 'command' in login ? login.command : undefined;
369
+ const key = login && 'key' in login ? login.key : undefined;
365
370
  // the Codex package came without its platform binary (an optional dependency npm skipped): runs cannot start either
366
371
  if (st.tool === 'codex' && /Missing optional dependency @openai\/codex-/i.test(st.detail ?? '')) {
367
372
  const cmd = 'npm install -g @koalaauto/agentchannel@latest';
@@ -393,15 +398,15 @@ export function sandboxFix(st, host) {
393
398
  }
394
399
  switch (st.problem) {
395
400
  case 'not-logged-in': {
396
- const cmd = st.tool === 'claude' ? 'claude auth login' : 'codex login';
401
+ if (!cmd)
402
+ return { en: `${name} is not logged in on this machine${key ? `: set ${key} in the runner's environment` : ''}.`, zh: `${name} 在这台机器上没有登录${key ? `:在 runner 的环境变量里设置 ${key}` : ''}。`, commands: [] };
397
403
  return { en: `${name} is not logged in on this machine: run \`${cmd}\` as the user that runs this agent.`, zh: `${name} 在这台机器上没有登录:以运行这个智能体的用户身份执行 \`${cmd}\`。`, commands: [cmd] };
398
404
  }
399
405
  case 'billing': {
400
406
  const en = `The account ${name} uses on this machine cannot run: its plan or credit is not usable (a payment past due, no credit left).`;
401
407
  const zh = `这台机器上 ${name} 用的账号用不了:订阅或余额不可用(付款逾期、余额用完)。`;
402
- if (st.tool === 'kiro')
403
- return { en: `${en} Renew it, or set another KIRO_API_KEY.`, zh: `${zh}续费,或换一个 KIRO_API_KEY。`, commands: [] };
404
- const cmd = st.tool === 'claude' ? 'claude auth login' : 'codex login';
408
+ if (!cmd)
409
+ return { en: `${en} Renew it${key ? `, or set another ${key}` : ''}.`, zh: `${zh}续费${key ? `,或换一个 ${key}` : ''}。`, commands: [] };
405
410
  return {
406
411
  en: `${en} Renew it, or log in with another account: run \`${cmd}\` as the user that runs this agent.`,
407
412
  zh: `${zh}续费,或换一个账号:以运行这个智能体的用户身份执行 \`${cmd}\`。`,
@@ -1,4 +1,4 @@
1
- export declare const VERSION = "3.53.4";
1
+ export declare const VERSION = "3.54.0";
2
2
  /** The npm package (scripts/release.mjs keeps it and VERSION in step with package.json). */
3
3
  export declare const PKG_NAME = "@koalaauto/agentchannel";
4
4
  /**
@@ -1,4 +1,4 @@
1
- export const VERSION = '3.53.4';
1
+ export const VERSION = '3.54.0';
2
2
  /** The npm package (scripts/release.mjs keeps it and VERSION in step with package.json). */
3
3
  export const PKG_NAME = '@koalaauto/agentchannel';
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koalaauto/agentchannel",
3
- "version": "3.53.4",
3
+ "version": "3.54.0",
4
4
  "description": "Hand work between your team's agents (Claude Code, Codex) and follow it in one panel: the ach CLI, MCP server and runner for AgentChannel v2",
5
5
  "keywords": [
6
6
  "agentchannel",