@koalaauto/agentchannel 3.50.0 → 3.52.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.
@@ -65,6 +65,8 @@ export declare class KiroOutput {
65
65
  finalText(): string;
66
66
  private flushMessage;
67
67
  private flushThought;
68
+ /** What a runError event said: the reason the run failed. */
69
+ runError?: string;
68
70
  private setSession;
69
71
  private line;
70
72
  }
@@ -85,7 +87,7 @@ export declare class KiroAdapter implements RuntimeAdapter {
85
87
  readonly remote = true;
86
88
  constructor(o?: KiroAdapterOptions);
87
89
  run(opts: AdapterRunOptions): Promise<AdapterResult>;
88
- /** `kiro-cli chat --list-models --format json`: the models this key may use, their credit rate, and default_model. */
90
+ /** 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`. */
89
91
  listModels(o: {
90
92
  env: Record<string, string>;
91
93
  cwd: string;
@@ -1,6 +1,6 @@
1
1
  import { execFileSync } from 'node:child_process';
2
2
  import { spawnGroup } from './procgroup.js';
3
- import { ask, kiroModels } from './models.js';
3
+ import { ask, KIRO_ACP_INPUT, kiroAcpModels, kiroModels } from './models.js';
4
4
  import { modelId } from './types.js';
5
5
  /**
6
6
  * Kiro runtime: each run is a Kiro cloud session started headlessly with
@@ -140,6 +140,8 @@ export class KiroOutput {
140
140
  this.onEvent({ type: 'thinking', data: this.thought });
141
141
  this.thought = '';
142
142
  }
143
+ /** What a runError event said: the reason the run failed. */
144
+ runError;
143
145
  setSession(id) {
144
146
  if (typeof id !== 'string' || !id || id === this.sessionId)
145
147
  return;
@@ -203,6 +205,17 @@ export class KiroOutput {
203
205
  else
204
206
  this.onEvent({ type: 'tool', data: { type: kind } });
205
207
  break;
208
+ case 'config_option_update':
209
+ // the options kiro offers for this session (model, effort levels): kept in the trace so the levels each model takes can be read
210
+ this.onEvent({ type: 'tool', data: { type: kind, options: JSON.stringify(u.configOptions ?? u.options ?? u).slice(0, 1500) } });
211
+ break;
212
+ case 'runError': {
213
+ // the run itself failed: keep what kiro says, it is the reason (stderr only carries warnings)
214
+ const m = p.error ?? p.message ?? p.reason ?? p.data ?? p;
215
+ this.runError = (typeof m === 'string' ? m : (m?.message ?? JSON.stringify(m))).slice(0, 600);
216
+ this.onEvent({ type: 'error', data: `kiro run error: ${this.runError}` });
217
+ break;
218
+ }
206
219
  case 'tool_call_update':
207
220
  if (u.status === 'completed' || u.status === 'failed') {
208
221
  this.onEvent({ type: 'tool_end', data: { id: String(u.toolCallId ?? u.id ?? ''), is_error: u.status === 'failed', output: contentText(u.content) || (u.rawOutput ? JSON.stringify(u.rawOutput) : '') } });
@@ -273,7 +286,7 @@ export class KiroAdapter {
273
286
  }
274
287
  return first.result;
275
288
  }
276
- /** `kiro-cli chat --list-models --format json`: the models this key may use, their credit rate, and default_model. */
289
+ /** 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`. */
277
290
  async listModels(o) {
278
291
  const env = this.o.env ?? process.env;
279
292
  const bin = this.o.bin ?? env.ACH_KIRO_BIN ?? 'kiro-cli';
@@ -285,7 +298,14 @@ export class KiroAdapter {
285
298
  return undefined; // not all of it yet
286
299
  }
287
300
  };
288
- return ask(bin, ['chat', '--list-models', '--format', 'json'], kiroEnv(o.env, { realHome: o.realHome, apiKey: this.o.apiKey ?? env.KIRO_API_KEY }), { cwd: o.cwd, timeoutMs: 30_000, done });
301
+ const kenv = kiroEnv(o.env, { realHome: o.realHome, apiKey: this.o.apiKey ?? env.KIRO_API_KEY });
302
+ // an ACP session lists the effort levels each model takes; --list-models does not: asked second, for the models alone
303
+ try {
304
+ return await ask(bin, ['acp'], kenv, { cwd: o.cwd, timeoutMs: 30_000, input: KIRO_ACP_INPUT, done: kiroAcpModels });
305
+ }
306
+ catch {
307
+ return ask(bin, ['chat', '--list-models', '--format', 'json'], kenv, { cwd: o.cwd, timeoutMs: 30_000, done });
308
+ }
289
309
  }
290
310
  runOnce(opts, repo, format) {
291
311
  const env = this.o.env ?? process.env;
@@ -325,8 +345,8 @@ export class KiroAdapter {
325
345
  done = true;
326
346
  out.end();
327
347
  const finalText = out.finalText();
328
- const ok = !err && code === 0 && !opts.signal.aborted;
329
- const error = ok ? undefined : opts.signal.aborted ? 'aborted' : err ?? (stripAnsi(stderr).trim().split('\n').slice(-3).join(' ') || `kiro-cli exited ${code}`);
348
+ const ok = !err && code === 0 && !out.runError && !opts.signal.aborted;
349
+ const error = ok ? undefined : opts.signal.aborted ? 'aborted' : err ?? (out.runError ? `kiro run error: ${out.runError}` : stripAnsi(stderr).split('\n').map((l) => l.trim()).filter((l) => l && !/^\[warn\]/.test(l)).slice(-3).join(' ') || `kiro-cli exited ${code}${out.runError === undefined ? ' without saying why' : ''}`);
330
350
  // Kiro bills credits, not dollars, and the CLI does not print them (2.37.1): the cost stays unknown, never guessed.
331
351
  resolve({ result: { finalText, sessionId: out.sessionId, ok, error, estimated: true, ...(modelId((opts.model ?? this.o.model)) ? { model: (opts.model ?? this.o.model) } : {}) }, progressed });
332
352
  };
@@ -22,6 +22,13 @@ export declare function claudeModels(raw: unknown): RuntimeModels;
22
22
  export declare function codexModels(raw: unknown): RuntimeModels;
23
23
  /** `kiro-cli chat --list-models --format json`: {models: [{model_id, description, rate_multiplier}], default_model}. Pure. */
24
24
  export declare function kiroModels(raw: unknown): RuntimeModels;
25
+ /** The JSON-RPC lines that open an ACP session in `kiro-cli acp` (no prompt is sent, nothing is spent): its answer lists the models. */
26
+ export declare const KIRO_ACP_INPUT: string;
27
+ /**
28
+ * The session/new answer among `kiro-cli acp` output lines, once it is there: its "model" config option lists each model with
29
+ * the effort levels it takes (_meta.kiro.effortLevels; none for Auto), its credit rate and the model the session starts on. Pure.
30
+ */
31
+ export declare function kiroAcpModels(out: string): RuntimeModels | undefined;
25
32
  /** Run `cmd args`, feed it `input`, and resolve with what `done` makes of its stdout so far (or reject on timeout / exit). */
26
33
  export declare function ask<T>(cmd: string, args: string[], env: Record<string, string>, o: {
27
34
  input?: string;
@@ -51,6 +51,42 @@ export function kiroModels(raw) {
51
51
  models: list(xs.map((x) => entry(x?.model_id, { label: x?.model_name !== x?.model_id ? x?.model_name : undefined, description: x?.description, rate: x?.rate_multiplier }))),
52
52
  };
53
53
  }
54
+ /** The JSON-RPC lines that open an ACP session in `kiro-cli acp` (no prompt is sent, nothing is spent): its answer lists the models. */
55
+ export const KIRO_ACP_INPUT = [
56
+ { jsonrpc: '2.0', id: 1, method: 'initialize', params: { protocolVersion: 1, clientCapabilities: {} } },
57
+ { jsonrpc: '2.0', id: 2, method: 'session/new', params: { cwd: '/tmp', mcpServers: [] } },
58
+ ].map((x) => JSON.stringify(x)).join('\n') + '\n';
59
+ /**
60
+ * The session/new answer among `kiro-cli acp` output lines, once it is there: its "model" config option lists each model with
61
+ * the effort levels it takes (_meta.kiro.effortLevels; none for Auto), its credit rate and the model the session starts on. Pure.
62
+ */
63
+ export function kiroAcpModels(out) {
64
+ for (const line of out.split('\n')) {
65
+ if (!line.startsWith('{'))
66
+ continue;
67
+ let j;
68
+ try {
69
+ j = JSON.parse(line);
70
+ }
71
+ catch {
72
+ continue;
73
+ }
74
+ if (j?.id !== 2)
75
+ continue;
76
+ if (j.error)
77
+ throw new Error(`kiro-cli acp: ${String(j.error?.message ?? 'session/new failed').slice(0, 200)}`);
78
+ const opt = (Array.isArray(j.result?.configOptions) ? j.result.configOptions : []).find((c) => c?.id === 'model');
79
+ const xs = Array.isArray(opt?.options) ? opt.options : [];
80
+ return {
81
+ ...(modelId(opt?.currentValue) ? { default: opt.currentValue } : {}),
82
+ models: list(xs.map((x) => {
83
+ const k = x?._meta?.kiro;
84
+ return entry(x?.value, { label: x?.name !== x?.value ? x?.name : undefined, description: x?.description, efforts: k?.hasEffort === false ? undefined : k?.effortLevels, rate: k?.rateMultiplier });
85
+ })),
86
+ };
87
+ }
88
+ return undefined;
89
+ }
54
90
  /** Run `cmd args`, feed it `input`, and resolve with what `done` makes of its stdout so far (or reject on timeout / exit). */
55
91
  export function ask(cmd, args, env, o) {
56
92
  return new Promise((resolve, reject) => {
@@ -30,6 +30,8 @@ export interface Agent {
30
30
  name: string;
31
31
  owner?: string;
32
32
  owner_name?: string;
33
+ /** The hub's default language: what the agent writes for people (ACH_DEFAULT_LANG). Only on an agent's own /me. */
34
+ lang?: 'en' | 'zh';
33
35
  /** Who it belongs to (docs/mechanisms.md): a person (personal) or the team (team: no one person, the admins look after it). */
34
36
  kind?: 'personal' | 'team';
35
37
  /** system: the team's one system agent (a team agent that does the hub's own work). */
@@ -558,6 +560,11 @@ export declare class Client {
558
560
  release(taskId: string, reason: string, run_id?: string): Promise<any>;
559
561
  /** The repo names this runner can work in (never local paths): the directory shows them, and the hub refuses a task for another repo. */
560
562
  reportRepos(repos: string[], remotes?: Record<string, string>): Promise<any>;
563
+ /** A description the runner wrote from the repository it works in; the hub keeps it only if the agent's description is still empty. */
564
+ reportDescription(description: string): Promise<{
565
+ ok: boolean;
566
+ set: boolean;
567
+ }>;
561
568
  /** How this runner runs tasks: its --perm, the tool, and the NAMES of the variables it hands its agents (never values); and how
562
569
  * it was started (directory, home, --repo paths, its supervisor), which the owner's page turns into the line that restarts it. */
563
570
  /** The models the runtime offers on the runner's machine and the one a run uses when none is picked (the agent's settings list them). */
@@ -396,6 +396,10 @@ export class Client {
396
396
  async reportRepos(repos, remotes) {
397
397
  return this.ach('PUT', '/me/repos', { repos, ...(remotes ? { remotes } : {}) });
398
398
  }
399
+ /** A description the runner wrote from the repository it works in; the hub keeps it only if the agent's description is still empty. */
400
+ async reportDescription(description) {
401
+ return this.ach('PUT', '/me/description', { description });
402
+ }
399
403
  /** How this runner runs tasks: its --perm, the tool, and the NAMES of the variables it hands its agents (never values); and how
400
404
  * it was started (directory, home, --repo paths, its supervisor), which the owner's page turns into the line that restarts it. */
401
405
  /** The models the runtime offers on the runner's machine and the one a run uses when none is picked (the agent's settings list them). */
@@ -18,14 +18,20 @@ export declare function probeEnvironment(tool: SandboxTool, o?: ProbeOptions & {
18
18
  * lines that look like a cause come first (at most 3), then the first remaining line; capped at 600 characters.
19
19
  */
20
20
  export declare function summarizeRuntimeError(raw: string): string;
21
- /** Does a run's error say the tool is not logged in (or its key was refused)? */
22
21
  /**
23
- * The account behind the runtime has no budget left right now (a weekly or daily usage limit, rate limit or overload), so the next
24
- * task would fail the same way. `pauseMs` is how long to wait: a usage limit lasts until it resets, a rate limit or overload is short.
22
+ * The account behind the runtime cannot run anything right now, so the next task would fail the same way. `pauseMs` is how long the
23
+ * runner takes nothing new before it tries again.
24
+ * - billing: the account's plan or credit is not usable (a payment past due, an ended subscription, no credit left). It does not
25
+ * come back by itself: a person pays or logs in with another account, so the owner is told. A run that fails this way costs
26
+ * nothing, so the retry is the check.
27
+ * - limit: a usage or rate limit, or an overload. It resets by itself: a usage limit after a while, a rate limit or overload soon.
25
28
  */
26
- export declare function quotaProblem(s: string): {
29
+ export type AccountProblem = {
30
+ kind: 'billing' | 'limit';
27
31
  pauseMs: number;
28
- } | null;
32
+ };
33
+ export declare const BILLING_ERROR: RegExp;
34
+ export declare function accountProblem(s: string): AccountProblem | null;
29
35
  /**
30
36
  * The runtime refused the model it was asked for (a typo, one the account cannot use): Claude Code's "issue with the selected
31
37
  * model (x). It may not exist or you may not have access to it", the API's not_found_error on a model, Codex's "model `x` does
@@ -34,4 +40,5 @@ export declare function quotaProblem(s: string): {
34
40
  /** The runtime refused the effort level it was asked for (one the model does not take). */
35
41
  export declare function effortRejected(s: string | undefined): boolean;
36
42
  export declare function modelRejected(s: string | undefined): boolean;
43
+ /** Does a run's error say the tool is not logged in (or its key was refused)? */
37
44
  export declare function looksLikeLoginError(s: string): boolean;
@@ -92,16 +92,14 @@ export function summarizeRuntimeError(raw) {
92
92
  picked.unshift(lines[0]);
93
93
  return picked.join(' | ').slice(0, 600);
94
94
  }
95
- /** Does a run's error say the tool is not logged in (or its key was refused)? */
96
- /**
97
- * The account behind the runtime has no budget left right now (a weekly or daily usage limit, rate limit or overload), so the next
98
- * task would fail the same way. `pauseMs` is how long to wait: a usage limit lasts until it resets, a rate limit or overload is short.
99
- */
100
- export function quotaProblem(s) {
101
- if (/hit your (weekly |daily |monthly |usage |5-hour |session )?limit|usage limit|weekly limit|session limit|5-hour limit|limit reached|quota (exceeded|reached)|insufficient (credit|quota)|credit balance/i.test(s))
102
- return { pauseMs: 30 * 60_000 };
95
+ export const BILLING_ERROR = /can[’']?t use your (claude )?subscription|payment (is )?past due|pay or renew|credit balance is too low|insufficient[ _](credit|quota)|subscription (has )?(expired|ended|lapsed|been cancell?ed)|no active subscription/i;
96
+ export function accountProblem(s) {
97
+ if (BILLING_ERROR.test(s))
98
+ return { kind: 'billing', pauseMs: 10 * 60_000 };
99
+ if (/hit your (weekly |daily |monthly |usage |5-hour |session )?limit|usage limit|weekly limit|session limit|5-hour limit|limit reached|quota (exceeded|reached)/i.test(s))
100
+ return { kind: 'limit', pauseMs: 30 * 60_000 };
103
101
  if (/rate.?limit|\b429\b|overloaded|too many requests/i.test(s))
104
- return { pauseMs: 5 * 60_000 };
102
+ return { kind: 'limit', pauseMs: 5 * 60_000 };
105
103
  return null;
106
104
  }
107
105
  /**
@@ -113,13 +111,14 @@ export function quotaProblem(s) {
113
111
  export function effortRejected(s) {
114
112
  if (!s)
115
113
  return false;
116
- return /\b(reasoning[ _.]?)?effort\b[^\n]{0,80}\b(invalid|not supported|unsupported|unknown|must be one of|is not (a )?valid|not allowed)|\b(invalid|unsupported|unknown) (value for )?(reasoning[ _.]?)?effort/i.test(s);
114
+ return /\b(reasoning[ _.]?)?effort\b[^\n]{0,80}\b(invalid|not supported|unsupported|unknown|must be one of|is not (a )?valid|not allowed)|\bno (reasoning[ _.]?)?effort levels\b|\b(invalid|unsupported|unknown) (value for )?(reasoning[ _.]?)?effort/i.test(s);
117
115
  }
118
116
  export function modelRejected(s) {
119
117
  if (!s)
120
118
  return false;
121
- return /issue with the selected model|\bmodel\b[^\n]{0,80}\b(does not exist|not found|not available|not supported|is not (a )?valid|unknown|invalid|you do not have access)|\b(invalid|unknown|unsupported) model\b|not_found_error[^\n]{0,40}model/i.test(s);
119
+ return /issue with the selected model|failed to set model|\bmodel\b[^\n]{0,80}\b(does not exist|not found|not available|not supported|is not (a )?valid|unknown|invalid|you do not have access)|\b(invalid|unknown|unsupported) model\b|not_found_error[^\n]{0,40}model/i.test(s);
122
120
  }
121
+ /** Does a run's error say the tool is not logged in (or its key was refused)? */
123
122
  export function looksLikeLoginError(s) {
124
123
  return /\b401\b|unauthori[sz]ed|not logged in|please (run|log)[^.\n]*login|invalid (api )?key|authentication (failed|required|error)|credentials? (expired|missing|invalid)/i.test(s);
125
124
  }
package/dist/src/mcp.js CHANGED
@@ -188,7 +188,7 @@ export function buildMcpServer(client, o = {}) {
188
188
  }
189
189
  return task.run_id;
190
190
  }
191
- server.registerTool('list_agents', { description: 'List the team\'s agents (name, owner, runtime, what they are good at, the repos their runner works in). Use it to pick who to hand work to; a task\'s repo must be one of the receiver\'s repos when it lists any.', inputSchema: {} }, async () => wrap(() => client.agents()));
191
+ server.registerTool('list_agents', { description: 'List the team\'s agents (name, owner, runtime, description, the repos their runner works in, capabilities, when the runner was last seen, blockers). Use it to pick who to hand work to or ask: read the description and repos for what each is for, runner_at for whether it is running, blockers for what it cannot do right now. A task\'s repo must be one of the receiver\'s repos when it lists any.', inputSchema: {} }, async () => wrap(() => client.agents()));
192
192
  server.registerTool('send_task', {
193
193
  description: `Hand a piece of work to another agent as a task. The receiving agent is woken on its machine (or its owner picks it up interactively) and works in a fresh git worktree. ${TASK_FIELDS_HELP} ${HANDOFF_HELP}`,
194
194
  inputSchema: {
@@ -38,7 +38,11 @@ export interface PromptCtx {
38
38
  }[];
39
39
  /** The layers people add to the default judgment: the team's conventions, then the owner's own. */
40
40
  judgment?: Judgment;
41
+ /** The hub's default language: what people read (replies, posts, results) is written in it. */
42
+ lang?: 'en' | 'zh';
41
43
  }
44
+ /** Trusted: the language the people on this hub read; the instructions around it stay English. Nothing for a hub that sends none. */
45
+ export declare function langText(lang?: 'en' | 'zh'): string[];
42
46
  /**
43
47
  * Trusted: the team's conventions (admins; they only tighten the default) and the owner's own (for all their agents), in that
44
48
  * order, each with who wrote it and when.
@@ -214,4 +218,5 @@ export declare function buildMentionPrompt(c: {
214
218
  recent: Post[];
215
219
  threadUrl?: string;
216
220
  structured?: boolean;
221
+ lang?: 'en' | 'zh';
217
222
  }): string;
@@ -1,4 +1,11 @@
1
1
  import { wikiPromptParts } from './wiki.js';
2
+ /** Trusted: the language the people on this hub read; the instructions around it stay English. Nothing for a hub that sends none. */
3
+ export function langText(lang) {
4
+ if (!lang)
5
+ return [];
6
+ const name = lang === 'zh' ? 'Chinese (简体中文)' : 'English';
7
+ return [`Language: write everything people will read (replies, posts, progress notes, results, drafts, questions) in ${name}, whatever language these instructions are in. Code, commands, file paths and names stay as they are. If the person you are answering wrote in another language, answer in theirs.`, ''];
8
+ }
2
9
  /**
3
10
  * Trusted: the team's conventions (admins; they only tighten the default) and the owner's own (for all their agents), in that
4
11
  * order, each with who wrote it and when.
@@ -339,6 +346,7 @@ export function buildTaskPrompt(c) {
339
346
  return [
340
347
  header(c),
341
348
  '',
349
+ ...langText(c.lang),
342
350
  ...(c.remote ? [] : readReposText(c.readRepos)),
343
351
  ...(c.remote ? [] : [JUDGMENT]),
344
352
  ...conventionsText(c.judgment, c.ownerName),
@@ -422,6 +430,7 @@ export function buildAnswerPrompt(c) {
422
430
  return [
423
431
  `You are agent "${c.agentName}"${c.ownerName ? `, owned by ${c.ownerName}` : ''}. Another agent asked you question ${q.id} (from ${author(q)}) on AgentChannel task ${c.task.id}. This is a short, read-only run.`,
424
432
  '',
433
+ ...langText(c.lang),
425
434
  HUMAN_HEADING,
426
435
  formatHumanDecisions(c.messages),
427
436
  '',
@@ -445,6 +454,7 @@ export function buildPreparePrompt(c) {
445
454
  return [
446
455
  `You are agent "${c.agentName}"${c.ownerName ? `, owned by ${c.ownerName}` : ''}. Task ${c.task.id} was sent to you on AgentChannel. Nobody works it yet. This is a short, read-only run: read the task and the code, and write a draft for whoever does the work, most likely your owner in their own session.`,
447
456
  '',
457
+ ...langText(c.lang),
448
458
  HUMAN_HEADING,
449
459
  formatHumanDecisions(c.messages),
450
460
  '',
@@ -482,6 +492,7 @@ export function buildMentionPrompt(c) {
482
492
  return [
483
493
  `You are agent "${c.agentName}"${c.ownerName ? `, owned by ${c.ownerName}` : ''}. You were mentioned by ${c.mention.by_type === 'human' ? 'a person' : 'another agent'} in channel #${c.channel} on AgentChannel (post ${c.post.id}${c.threadUrl ? `, thread ${c.threadUrl}` : ''}). This is a short, read-only run.`,
484
494
  '',
495
+ ...langText(c.lang),
485
496
  'Human posts in this thread and channel (from the hub; these come from people):',
486
497
  formatHumanPosts(all.filter((p, i) => all.findIndex((x) => x.id === p.id) === i)),
487
498
  '',
@@ -7,7 +7,7 @@ import { TraceRecorder } from '../trace.js';
7
7
  import { type SandboxStatus } from '../sandboxcheck.js';
8
8
  export * from './home.js';
9
9
  export * from './structured.js';
10
- export type RunnerClient = Pick<Client, 'me' | 'inbox' | 'claim' | 'getTask' | 'postMessage' | 'complete' | 'fail' | 'usage' | 'heartbeat' | 'answerRun' | 'endRun'> & Partial<Pick<Client, 'download' | 'githubToken' | 'channelPosts' | 'mentionRun' | 'mentionEnd' | 'mentionUsage' | 'promptSize' | 'reportSetup' | 'reportRepos' | 'reportRunner' | 'reportModels' | 'release' | 'putTrace' | 'pushToken' | 'taskPr' | 'prepareRun' | 'prepared'>>;
10
+ export type RunnerClient = Pick<Client, 'me' | 'inbox' | 'claim' | 'getTask' | 'postMessage' | 'complete' | 'fail' | 'usage' | 'heartbeat' | 'answerRun' | 'endRun'> & Partial<Pick<Client, 'download' | 'githubToken' | 'channelPosts' | 'mentionRun' | 'mentionEnd' | 'mentionUsage' | 'promptSize' | 'reportSetup' | 'reportRepos' | 'reportDescription' | 'reportRunner' | 'reportModels' | 'release' | 'putTrace' | 'pushToken' | 'taskPr' | 'prepareRun' | 'prepared'>>;
11
11
  export interface RunnerOptions {
12
12
  client: RunnerClient;
13
13
  adapter: RuntimeAdapter;
@@ -143,10 +143,12 @@ export declare class Runner {
143
143
  private githubOffUntil;
144
144
  /** When old work dirs were last cleaned up (ms); the first prune of a process does it. */
145
145
  private lastGc;
146
- /** No new task is taken before this time (ms): the account behind the runtime is out of budget. */
147
- private quotaUntil;
148
- /** How often each task was handed back for an account limit (in this process). */
149
- private quotaReleases;
146
+ /** No new task is taken before this time (ms): the account behind the runtime cannot run (a limit, or its plan or credit). */
147
+ private accountPausedUntil;
148
+ /** The account's plan or credit was not usable in the last run (the owner hears it as a setup problem); cleared by a run that works. */
149
+ private account?;
150
+ /** How often each task was handed back for an account problem (in this process). */
151
+ private accountReleases;
150
152
  /** When each parked task was last looked at on the hub (ms). */
151
153
  private parkedChecked;
152
154
  private o;
@@ -166,7 +168,7 @@ export declare class Runner {
166
168
  st: SandboxStatus;
167
169
  at: number;
168
170
  };
169
- private sandboxReported?;
171
+ private setupReported?;
170
172
  private sandboxRecheck;
171
173
  /** Execution traces the hub has not taken yet (kept on disk too), and the last trace of each task (a commit joins it). */
172
174
  private traces;
@@ -186,11 +188,25 @@ export declare class Runner {
186
188
  tick(): Promise<void>;
187
189
  /** decisions §27: probe the sandbox when due, tell the hub when the answer changes; true = take nothing new. */
188
190
  private sandboxBlocked;
191
+ /** Tell the hub what keeps this runner from working, when that changed: a failed check first, else an account that cannot run. */
192
+ private reportSetup;
193
+ /**
194
+ * What a run says about the account behind the runtime: a limit or a plan that is not usable pauses new work (whatever the run
195
+ * was for: a task, an answer, a mention), and the plan problem is the owner's to fix, so it is reported like a broken sandbox.
196
+ * A run that works clears it.
197
+ */
198
+ private noteAccount;
189
199
  /** Tell the hub which repo names this runner knows, so a task for another repo is refused when it is sent. Tried on every
190
200
  * poll until the hub has it: a hub that was unreachable at start would otherwise keep the previous list until a restart. */
191
201
  private reposReported;
192
202
  private reportRepos;
193
203
  private reposLogged;
204
+ /** An agent with no description gets one, once: a short read-only run on a light model reads the repositories it works in and
205
+ * writes a sentence or two. The hub keeps it only while the description is empty, so a person's own text is never replaced, and
206
+ * the owner edits it like any other. Tried again at the next start when it could not be had. */
207
+ private describeDone;
208
+ private describeBusy;
209
+ private describeAgent;
194
210
  /** Tell the hub how this runner runs tasks (its --perm, the tool, the names it passes with --pass-env), once, so the agent's
195
211
  * owner sees on its page what a task sent to it can reach. Tried on every poll until the hub has it; an older hub (404) is left alone. */
196
212
  private runnerReported;
@@ -321,3 +337,5 @@ export declare function gcWorktrees(client: Pick<Client, 'getTask'>, ws: Workspa
321
337
  log?: (s: string) => void;
322
338
  keepFailed?: boolean;
323
339
  }): Promise<string[]>;
340
+ /** The model's text as a description: its first paragraph, without markdown marks or wrapping quotes, at most 300 characters. */
341
+ export declare function cleanDescription(raw: string): string;
@@ -18,10 +18,10 @@ import { effectivePerm } from '../perm.js';
18
18
  import { ANSWER_SCHEMA, buildAnswerPrompt, buildMentionPrompt, buildPreparePrompt, buildResumePrompt, buildTaskPrompt, postUrl, refOf, REMOTE_FAILED_PREFIX, taskUrl } from '../prompts.js';
19
19
  import { RunnerState } from './state.js';
20
20
  import { isGitRepo } from './workspace.js';
21
- import { effortRejected, looksLikeLoginError, modelRejected, quotaProblem, summarizeRuntimeError } from '../envcheck.js';
21
+ import { accountProblem, effortRejected, looksLikeLoginError, modelRejected, summarizeRuntimeError } from '../envcheck.js';
22
22
  import { redact } from '../redact.js';
23
23
  import { TraceRecorder } from '../trace.js';
24
- import { looksLikeSandboxError } from '../sandboxcheck.js';
24
+ import { detectHost, looksLikeSandboxError, sandboxFix } from '../sandboxcheck.js';
25
25
  import { prepareAgentHome, realHomeOf, secretPaths } from './home.js';
26
26
  import { draftText, parsePrepared, parseStructured } from './structured.js';
27
27
  import { TraceQueue } from './traces.js';
@@ -104,8 +104,8 @@ export function unseenReplies(messages, myId, seen) {
104
104
  return messages.filter((m) => !seenSet.has(m.id) &&
105
105
  (((m.kind === 'answer' || m.kind === 'decision') && ((m.reply_to && mine.has(m.reply_to)) || m.to_agent === myId)) || isHumanNoteTo(m, myId)));
106
106
  }
107
- /** A task handed back this many times for an account limit then fails normally. */
108
- const QUOTA_RELEASES = 3;
107
+ /** A task handed back this many times for an account's usage or rate limit then fails normally. */
108
+ const ACCOUNT_RELEASES = 3;
109
109
  export function budgetBlocked(me) {
110
110
  const budget = Number(me.budget_usd ?? 0);
111
111
  return budget > 0 && Number(me.spent_usd ?? 0) >= budget;
@@ -123,10 +123,12 @@ export class Runner {
123
123
  githubOffUntil = 0;
124
124
  /** When old work dirs were last cleaned up (ms); the first prune of a process does it. */
125
125
  lastGc = 0;
126
- /** No new task is taken before this time (ms): the account behind the runtime is out of budget. */
127
- quotaUntil = 0;
128
- /** How often each task was handed back for an account limit (in this process). */
129
- quotaReleases = new Map();
126
+ /** No new task is taken before this time (ms): the account behind the runtime cannot run (a limit, or its plan or credit). */
127
+ accountPausedUntil = 0;
128
+ /** The account's plan or credit was not usable in the last run (the owner hears it as a setup problem); cleared by a run that works. */
129
+ account;
130
+ /** How often each task was handed back for an account problem (in this process). */
131
+ accountReleases = new Map();
130
132
  /** When each parked task was last looked at on the hub (ms). */
131
133
  parkedChecked = new Map();
132
134
  o;
@@ -143,7 +145,7 @@ export class Runner {
143
145
  wake;
144
146
  /** decisions §27: the last sandbox probe, when it ran, and what the hub was last told (a JSON key). */
145
147
  sandbox;
146
- sandboxReported;
148
+ setupReported;
147
149
  sandboxRecheck = false;
148
150
  /** Execution traces the hub has not taken yet (kept on disk too), and the last trace of each task (a commit joins it). */
149
151
  traces;
@@ -250,8 +252,8 @@ export class Runner {
250
252
  await this.notifyBudget(t, me);
251
253
  continue;
252
254
  }
253
- if (now < this.quotaUntil)
254
- continue; // out of usage at the provider: the pause is over soon enough
255
+ if (now < this.accountPausedUntil)
256
+ continue; // the account cannot run: it is tried again when the pause is over
255
257
  // a code task waits for its owner to take it over (owner-pulls-tasks.md): read each new one ahead first, then work only what
256
258
  // is not code, or one of the owner's declared small jobs; what the owner sent themselves is theirs to hand to the runner
257
259
  if (this.readsAhead(me) && !t.from_owner) {
@@ -317,25 +319,56 @@ export class Runner {
317
319
  this.log(`sandbox: ${st.fix?.en ?? st.detail ?? st.problem} Taking no tasks until it works.${st.fix?.commands.length ? `\n fix:\n${st.fix.commands.map((c) => ` ${c}`).join('\n')}` : ''}`);
318
320
  }
319
321
  }
320
- const st = this.sandbox.st;
321
- const report = st.ok ? null : { tool: st.tool, problem: st.problem ?? 'failed', ...(st.detail ? { detail: st.detail } : {}), ...(st.fix ? { fix: st.fix } : {}) };
322
+ await this.reportSetup();
323
+ return !this.sandbox.st.ok;
324
+ }
325
+ /** Tell the hub what keeps this runner from working, when that changed: a failed check first, else an account that cannot run. */
326
+ async reportSetup() {
327
+ const st = this.sandbox && !this.sandbox.st.ok ? this.sandbox.st : this.account;
328
+ const report = !st ? null : { tool: st.tool, problem: st.problem ?? 'failed', ...(st.detail ? { detail: st.detail } : {}), ...(st.fix ? { fix: st.fix } : {}) };
322
329
  const key = JSON.stringify(report);
323
- if (key !== this.sandboxReported && this.o.client.reportSetup) {
330
+ if (key !== this.setupReported && this.o.client.reportSetup) {
324
331
  try {
325
332
  await this.o.client.reportSetup(report);
326
- this.sandboxReported = key;
333
+ this.setupReported = key;
327
334
  }
328
335
  catch (e) {
329
336
  if (is401(e))
330
337
  this.authFailed('setup');
331
338
  // an older hub without /me/setup: the log above is all there is
332
339
  else if (e instanceof HubError && e.status === 404)
333
- this.sandboxReported = key;
340
+ this.setupReported = key;
334
341
  else
335
342
  this.log(`setup report: ${e?.message ?? e}`);
336
343
  }
337
344
  }
338
- return !st.ok;
345
+ }
346
+ /**
347
+ * What a run says about the account behind the runtime: a limit or a plan that is not usable pauses new work (whatever the run
348
+ * was for: a task, an answer, a mention), and the plan problem is the owner's to fix, so it is reported like a broken sandbox.
349
+ * A run that works clears it.
350
+ */
351
+ async noteAccount(result) {
352
+ const problem = result.ok ? null : accountProblem(result.error ?? '');
353
+ if (problem)
354
+ this.accountPausedUntil = Math.max(this.accountPausedUntil, Date.now() + problem.pauseMs);
355
+ const billing = problem?.kind === 'billing';
356
+ if (!billing && !(result.ok && this.account))
357
+ return;
358
+ const was = this.account;
359
+ const tool = ['claude', 'codex', 'kiro'].find((x) => x === this.o.adapter.name) ?? 'claude';
360
+ if (billing) {
361
+ const st = { tool, ok: false, problem: 'billing', detail: summarizeRuntimeError(result.error ?? '').slice(0, 300) };
362
+ st.fix = sandboxFix(st, detectHost(process.env, process.platform));
363
+ this.account = st;
364
+ if (!was)
365
+ this.log(`account: ${st.fix.en} Taking no tasks until a run works; trying again every ${problem.pauseMs / 60_000} min.`);
366
+ }
367
+ else {
368
+ this.account = undefined;
369
+ this.log('account: runs work again');
370
+ }
371
+ await this.reportSetup();
339
372
  }
340
373
  /** Tell the hub which repo names this runner knows, so a task for another repo is refused when it is sent. Tried on every
341
374
  * poll until the hub has it: a hub that was unreachable at start would otherwise keep the previous list until a restart. */
@@ -364,6 +397,77 @@ export class Runner {
364
397
  }
365
398
  }
366
399
  reposLogged = false;
400
+ /** An agent with no description gets one, once: a short read-only run on a light model reads the repositories it works in and
401
+ * writes a sentence or two. The hub keeps it only while the description is empty, so a person's own text is never replaced, and
402
+ * the owner edits it like any other. Tried again at the next start when it could not be had. */
403
+ describeDone = false;
404
+ describeBusy = false;
405
+ async describeAgent() {
406
+ const { adapter, client, workspace } = this.o;
407
+ if (this.describeDone || this.describeBusy || adapter.remote || !client.reportDescription || !workspace.repoDirs)
408
+ return;
409
+ this.describeBusy = true;
410
+ try {
411
+ const me = await this.ensureMe();
412
+ if (me.role === 'system' || String(me.description ?? '').trim()) {
413
+ this.describeDone = true;
414
+ return;
415
+ }
416
+ const dirs = Object.entries(await workspace.repoDirs()).slice(0, 4);
417
+ if (!dirs.length)
418
+ return;
419
+ const baseEnv = this.o.baseEnv ?? process.env;
420
+ const realHome = realHomeOf(baseEnv);
421
+ const { env } = prepareAgentHome(this.o.agentHomesDir ?? join(tmpdir(), 'ach-homes'), me.name, 'describe', realHome, baseEnv.CODEX_HOME || undefined);
422
+ const run = async (pick) => {
423
+ const ctl = new AbortController();
424
+ const timer = setTimeout(() => ctl.abort(), 3 * 60_000);
425
+ try {
426
+ return await adapter.run({
427
+ ...(pick ? { model: pick.model, effort: pick.effort } : {}),
428
+ prompt: describePrompt(me.name, dirs),
429
+ cwd: dirs[0][1],
430
+ perm: 'read',
431
+ mode: 'answer',
432
+ env: { ...inheritedEnv(baseEnv, this.o.passEnv), ...env },
433
+ signal: ctl.signal,
434
+ hub: this.o.hub,
435
+ denyReadPaths: secretPaths(this.o.home),
436
+ ...(realHome ? { realHome } : {}),
437
+ readRoots: dirs.map(([, d]) => d),
438
+ ...(env.TMPDIR ? { tmpDir: env.TMPDIR } : {}),
439
+ ...(Array.isArray(me.net_allow) ? { netAllow: me.net_allow } : {}),
440
+ ...(adapter.name === 'claude' ? { maxBudgetUsd: 0.05 } : {}),
441
+ ...(adapter.structuredAnswers ? { outputSchema: DESCRIBE_SCHEMA } : {}),
442
+ onEvent: () => { },
443
+ });
444
+ }
445
+ finally {
446
+ clearTimeout(timer);
447
+ }
448
+ };
449
+ // the light model where the runtime has one; a model the account cannot use falls back to the runtime's default
450
+ const light = DESCRIBE_MODELS[adapter.name];
451
+ let r = await run(light);
452
+ if (!r.ok && light)
453
+ r = await run(undefined);
454
+ const text = cleanDescription(r.finalText);
455
+ if (!r.ok || !text)
456
+ throw new Error(r.error ? summarizeRuntimeError(r.error).slice(0, 160) : 'no description came back');
457
+ await client.reportDescription(text);
458
+ this.describeDone = true;
459
+ this.log(`description: ${text.slice(0, 120)}`);
460
+ }
461
+ catch (e) {
462
+ // once per start, whatever the outcome; an older hub without /me/description (404) says nothing
463
+ if (!(e instanceof HubError && e.status === 404))
464
+ this.log(`description: ${String(e?.message ?? e).slice(0, 200)} (trying again at the next start)`);
465
+ this.describeDone = true;
466
+ }
467
+ finally {
468
+ this.describeBusy = false;
469
+ }
470
+ }
367
471
  /** Tell the hub how this runner runs tasks (its --perm, the tool, the names it passes with --pass-env), once, so the agent's
368
472
  * owner sees on its page what a task sent to it can reach. Tried on every poll until the hub has it; an older hub (404) is left alone. */
369
473
  runnerReported = false;
@@ -635,7 +739,7 @@ export class Runner {
635
739
  }
636
740
  async runJob(job, entry) {
637
741
  // queued before the account ran out: it stays on the hub (submitted) and is taken again after the pause
638
- if (job.kind === 'work' && Date.now() < this.quotaUntil)
742
+ if (job.kind === 'work' && Date.now() < this.accountPausedUntil)
639
743
  return;
640
744
  if (job.kind === 'work')
641
745
  return this.runWork(job.taskId, entry);
@@ -737,6 +841,7 @@ export class Runner {
737
841
  const prompt = buildPreparePrompt({
738
842
  agentName: me.name,
739
843
  ownerName: me.owner_name,
844
+ lang: me.lang,
740
845
  senderName: bundle.task.from_agent_name,
741
846
  task: bundle.task,
742
847
  handoff: bundle.handoff,
@@ -853,6 +958,7 @@ export class Runner {
853
958
  const prompt = buildTaskPrompt({
854
959
  agentName: me.name,
855
960
  ownerName: me.owner_name,
961
+ lang: me.lang,
856
962
  kind: me.kind, role: me.role,
857
963
  senderName: claim.task.from_agent_name,
858
964
  task: claim.task,
@@ -953,6 +1059,7 @@ export class Runner {
953
1059
  : buildTaskPrompt({
954
1060
  agentName: me.name,
955
1061
  ownerName: me.owner_name,
1062
+ lang: me.lang,
956
1063
  kind: me.kind, role: me.role,
957
1064
  senderName: bundle.task.from_agent_name,
958
1065
  task: bundle.task,
@@ -1114,16 +1221,18 @@ export class Runner {
1114
1221
  }
1115
1222
  if (!result.ok) {
1116
1223
  const err = result.error ?? 'unknown';
1117
- // The account has no budget left (a usage or rate limit): the task goes back to the queue untouched and this runner takes
1118
- // nothing new until the pause is over, instead of failing every queued task one by one for the same reason.
1119
- const quota = quotaProblem(err);
1120
- // released for this at most QUOTA_RELEASES times: a task whose own failure text mentions a rate limit (a third-party 429) must
1121
- // still be able to fail
1122
- const quotaTimes = (this.quotaReleases.get(taskId) ?? 0) + 1;
1123
- if (quota && client.release && quotaTimes <= QUOTA_RELEASES) {
1124
- this.quotaReleases.set(taskId, quotaTimes);
1125
- this.quotaUntil = Math.max(this.quotaUntil, Date.now() + quota.pauseMs);
1126
- const why = `the account behind ${this.o.adapter.name} hit a usage or rate limit (${summarizeRuntimeError(err).slice(0, 160)}); this runner takes no new task until ${new Date(this.quotaUntil).toISOString().slice(11, 16)} UTC`;
1224
+ // The account cannot run (a usage or rate limit, or its plan or credit is not usable): the task goes back to the queue
1225
+ // untouched and this runner takes nothing new until the pause is over (execute() set it), instead of failing every queued
1226
+ // task one by one for the same reason.
1227
+ const account = accountProblem(err);
1228
+ // released for a limit at most ACCOUNT_RELEASES times: a task whose own failure text mentions a rate limit (a third-party 429)
1229
+ // must still be able to fail. A billing error is the tool's own refusal to start: the task waits like it does for a broken
1230
+ // sandbox, and the owner has been told.
1231
+ const times = (this.accountReleases.get(taskId) ?? 0) + 1;
1232
+ if (account && client.release && (account.kind === 'billing' || times <= ACCOUNT_RELEASES)) {
1233
+ this.accountReleases.set(taskId, times);
1234
+ const what = account.kind === 'billing' ? 'cannot run: its plan or credit is not usable' : 'hit a usage or rate limit';
1235
+ const why = `the account behind ${this.o.adapter.name} ${what} (${summarizeRuntimeError(err).slice(0, 160)}); this runner takes no new task until ${new Date(this.accountPausedUntil).toISOString().slice(11, 16)} UTC`;
1127
1236
  const done = await client.release(taskId, why, rec.runId).then(() => true, (e) => { this.log(`release ${taskId}: ${e?.message ?? e}`); return false; });
1128
1237
  if (done) {
1129
1238
  this.log(why);
@@ -1256,6 +1365,7 @@ export class Runner {
1256
1365
  const prompt = buildMentionPrompt({
1257
1366
  agentName: me.name,
1258
1367
  ownerName: me.owner_name,
1368
+ lang: me.lang,
1259
1369
  channel: run.channel_name,
1260
1370
  mention: run.mention,
1261
1371
  post: run.post,
@@ -1336,6 +1446,7 @@ export class Runner {
1336
1446
  const prompt = buildAnswerPrompt({
1337
1447
  agentName: me.name,
1338
1448
  ownerName: me.owner_name,
1449
+ lang: me.lang,
1339
1450
  task: bundle.task,
1340
1451
  handoff: bundle.handoff,
1341
1452
  messages: bundle.messages,
@@ -1618,6 +1729,8 @@ export class Runner {
1618
1729
  if (!this.fatal)
1619
1730
  await usage(runCost, !!result.estimated, { model: result.model, effort: result.effort }).catch((e) => this.log(`usage ${taskId}: ${e?.message ?? e}`));
1620
1731
  this.taskLog(taskId, `${mode} run end ok=${result.ok} cost=${result.costUsd ?? 0} model=${result.model ?? '?'} effort=${result.effort ?? '?'} err=${result.error ?? ''}`);
1732
+ if (!this.fatal)
1733
+ await this.noteAccount(result);
1621
1734
  if (mode !== 'mention' && !this.o.noTrace)
1622
1735
  await this.traces.add(taskId, rec.runId, mode, startedAt, result, recorder, !this.fatal);
1623
1736
  return result;
@@ -1655,6 +1768,7 @@ export class Runner {
1655
1768
  await this.reportRunner();
1656
1769
  // not awaited: listing starts the tool (up to a few seconds), and claiming work must not wait for it
1657
1770
  void this.reportModels();
1771
+ void this.describeAgent();
1658
1772
  await this.tick();
1659
1773
  }
1660
1774
  catch (e) {
@@ -1737,3 +1851,34 @@ function promptFile(f) {
1737
1851
  const { key: _key, ...rest } = f;
1738
1852
  return rest;
1739
1853
  }
1854
+ /** The light model that writes an agent's description, per runtime (none listed: the runtime's default). A runtime that does not
1855
+ * take it runs the default instead. */
1856
+ const DESCRIBE_MODELS = {
1857
+ claude: { model: 'claude-haiku-5-5', effort: 'low' },
1858
+ codex: { model: 'gpt-6.1-sol', effort: 'medium' },
1859
+ };
1860
+ const DESCRIBE_SCHEMA = { type: 'object', properties: { description: { type: 'string' } }, required: ['description'], additionalProperties: false };
1861
+ function describePrompt(name, dirs) {
1862
+ const where = dirs.map(([n, d]) => `- ${n}: ${d}`).join('\n');
1863
+ return [
1864
+ `You are writing the one-paragraph profile of the agent "${name}" for the team directory. Teammates and other agents read it to decide whether to send this agent a piece of work.`,
1865
+ `The agent works in these repositories (read-only for you; start with README, CLAUDE.md, AGENTS.md and the top-level layout, do not read everything):`,
1866
+ where,
1867
+ `Write one or two sentences in Chinese: what the repository is for and what kind of work belongs with this agent. Be specific (name the main parts or systems), not generic. At most 160 characters. Plain text only: no markdown, no quotes, no list, no preface.`,
1868
+ 'Answer with the profile text only.',
1869
+ ].filter(Boolean).join('\n\n');
1870
+ }
1871
+ /** The model's text as a description: its first paragraph, without markdown marks or wrapping quotes, at most 300 characters. */
1872
+ export function cleanDescription(raw) {
1873
+ let t = String(raw ?? '').trim();
1874
+ try {
1875
+ const j = JSON.parse(t);
1876
+ if (j && typeof j.description === 'string')
1877
+ t = j.description;
1878
+ }
1879
+ catch {
1880
+ /* plain text */
1881
+ }
1882
+ t = t.split(/\n\s*\n/)[0].replace(/[`*_#>]/g, '').replace(/\s+/g, ' ').trim().replace(/^["'“”「」]+|["'“”「」]+$/g, '').trim();
1883
+ return t.slice(0, 300);
1884
+ }
@@ -18,6 +18,8 @@ export interface Workspace {
18
18
  /** The repo names a task may name (links.repo, links.repos): the runner tells the hub, which refuses others when sent.
19
19
  * Only git checkouts: a task that names a plain directory would get an empty work dir. */
20
20
  repoNames?(): string[] | Promise<string[]>;
21
+ /** Where each of those repos is on this machine: {name: absolute path}. Read by the runner itself, never sent to the hub. */
22
+ repoDirs?(): Promise<Record<string, string>>;
21
23
  /** Where each of those comes from: {name: "owner/name"} of its origin (never a local path). The hub tells a sender whose handoff names another repository. */
22
24
  repoRemotes?(): Promise<Record<string, string>>;
23
25
  /**
@@ -65,6 +67,7 @@ export declare class GitWorkspace implements Workspace {
65
67
  /** The local repo a task works in (P3). */
66
68
  repoDir(task: Task): string;
67
69
  repoNames(): Promise<string[]>;
70
+ repoDirs(): Promise<Record<string, string>>;
68
71
  repoRemotes(): Promise<Record<string, string>>;
69
72
  /** Map a repo name to its local path, or fail with the names this runner knows. */
70
73
  lookup(r: unknown, what: string): string;
@@ -86,6 +86,12 @@ export class GitWorkspace {
86
86
  }
87
87
  return out;
88
88
  }
89
+ async repoDirs() {
90
+ const out = {};
91
+ for (const n of await this.repoNames())
92
+ out[n] = this.lookup(n, 'repo');
93
+ return out;
94
+ }
89
95
  async repoRemotes() {
90
96
  const out = {};
91
97
  for (const n of await this.repoNames()) {
@@ -25,6 +25,8 @@ export type SandboxProblem =
25
25
  | 'unsupported'
26
26
  /** the tool is not logged in on this machine (envcheck.ts): not the sandbox, but the same "takes no tasks" state */
27
27
  | 'not-logged-in'
28
+ /** the account the tool is logged in with cannot run (a payment past due, no credit left), seen in a run's error (envcheck.ts) */
29
+ | 'billing'
28
30
  /** Codex's sandbox starts but has no network although the runner asks for it: the agent's `ach` cannot reach the hub (`detail`: the host) */
29
31
  | 'no-network'
30
32
  /** anything else: `detail` has the first line of the error */
@@ -361,7 +361,7 @@ export const BWRAP_APPARMOR = `printf '%s\\n' 'abi <abi/4.0>,' 'include <tunable
361
361
  `| sudo tee /etc/apparmor.d/bwrap >/dev/null && sudo apparmor_parser -r /etc/apparmor.d/bwrap`;
362
362
  /** The fix for a failed probe on this host. */
363
363
  export function sandboxFix(st, host) {
364
- const name = st.tool === 'claude' ? 'Claude Code' : 'Codex';
364
+ const name = st.tool === 'claude' ? 'Claude Code' : st.tool === 'kiro' ? 'Kiro' : 'Codex';
365
365
  // the Codex package came without its platform binary (an optional dependency npm skipped): runs cannot start either
366
366
  if (st.tool === 'codex' && /Missing optional dependency @openai\/codex-/i.test(st.detail ?? '')) {
367
367
  const cmd = 'npm install -g @koalaauto/agentchannel@latest';
@@ -396,6 +396,18 @@ export function sandboxFix(st, host) {
396
396
  const cmd = st.tool === 'claude' ? 'claude auth login' : 'codex login';
397
397
  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
398
  }
399
+ case 'billing': {
400
+ 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
+ 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';
405
+ return {
406
+ en: `${en} Renew it, or log in with another account: run \`${cmd}\` as the user that runs this agent.`,
407
+ zh: `${zh}续费,或换一个账号:以运行这个智能体的用户身份执行 \`${cmd}\`。`,
408
+ commands: [cmd],
409
+ };
410
+ }
399
411
  case 'windows-native':
400
412
  return {
401
413
  en: 'Claude Code has no sandbox on native Windows: run this agent inside WSL2 (wsl --install, then join again there).',
@@ -1,4 +1,4 @@
1
- export declare const VERSION = "3.50.0";
1
+ export declare const VERSION = "3.52.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.50.0';
1
+ export const VERSION = '3.52.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.50.0",
3
+ "version": "3.52.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",