@koalaauto/agentchannel 3.53.3 → 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.
- package/dist/src/adapters/antigravity.d.ts +144 -0
- package/dist/src/adapters/antigravity.js +319 -0
- package/dist/src/adapters/claude.d.ts +24 -0
- package/dist/src/adapters/claude.js +2 -0
- package/dist/src/adapters/codex.d.ts +24 -1
- package/dist/src/adapters/codex.js +2 -1
- package/dist/src/adapters/fake.d.ts +6 -3
- package/dist/src/adapters/fake.js +21 -5
- package/dist/src/adapters/index.d.ts +2 -0
- package/dist/src/adapters/index.js +7 -1
- package/dist/src/adapters/kiro.d.ts +20 -2
- package/dist/src/adapters/kiro.js +2 -2
- package/dist/src/adapters/spec.d.ts +164 -0
- package/dist/src/adapters/spec.js +104 -0
- package/dist/src/adapters/types.d.ts +4 -7
- package/dist/src/agycheck.d.ts +21 -0
- package/dist/src/agycheck.js +58 -0
- package/dist/src/args.d.ts +1 -1
- package/dist/src/args.js +3 -2
- package/dist/src/cli-run.js +15 -9
- package/dist/src/doctor.d.ts +3 -3
- package/dist/src/doctor.js +13 -7
- package/dist/src/envcheck.d.ts +8 -0
- package/dist/src/envcheck.js +12 -0
- package/dist/src/onboard.js +1 -1
- package/dist/src/prompts.d.ts +7 -1
- package/dist/src/prompts.js +25 -5
- package/dist/src/runner/context.d.ts +2 -2
- package/dist/src/runner/context.js +3 -3
- package/dist/src/runner/runner.d.ts +6 -0
- package/dist/src/runner/runner.js +63 -25
- package/dist/src/runtimecheck.d.ts +26 -0
- package/dist/src/runtimecheck.js +20 -0
- package/dist/src/sandboxcheck.d.ts +2 -1
- package/dist/src/sandboxcheck.js +10 -5
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
package/dist/src/onboard.js
CHANGED
|
@@ -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
|
|
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)
|
package/dist/src/prompts.d.ts
CHANGED
|
@@ -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
|
|
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: {
|
package/dist/src/prompts.js
CHANGED
|
@@ -314,8 +314,28 @@ function rules(review) {
|
|
|
314
314
|
LINK_RULE,
|
|
315
315
|
].join('\n');
|
|
316
316
|
}
|
|
317
|
-
/** The final-message contract of
|
|
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
|
|
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,
|
|
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
|
|
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,
|
|
47
|
-
const names =
|
|
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);
|
|
@@ -24,6 +24,8 @@ export interface RunnerOptions {
|
|
|
24
24
|
/** The hub answered 426 client_too_old: this release is below its floor (the updater checks at once). */
|
|
25
25
|
onClientTooOld?: () => void;
|
|
26
26
|
heartbeatMs?: number;
|
|
27
|
+
/** How long a run whose runtime program was missing waits before it is tried once more (default 30 s: see programMissing). */
|
|
28
|
+
programRetryMs?: number;
|
|
27
29
|
/** Keep execution traces on this machine (`ach run --no-trace`, ACH_NO_TRACE=1): the task's readers see results, not commands and output. */
|
|
28
30
|
noTrace?: boolean;
|
|
29
31
|
/** How often a parked run is looked at on the hub (default 12 s; tests that drive the runner by hand use 0). */
|
|
@@ -316,6 +318,10 @@ export declare class Runner {
|
|
|
316
318
|
private postStructuredAnswer;
|
|
317
319
|
/** Readable roots for the spawned agent besides its cwd (S4). */
|
|
318
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();
|
|
319
325
|
/** Owned by no one person (the system agent, or a team agent such as one that does a channel mechanism for the team). */
|
|
320
326
|
private teamOwned;
|
|
321
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';
|
|
@@ -18,7 +19,7 @@ import { effectivePerm } from '../perm.js';
|
|
|
18
19
|
import { ANSWER_SCHEMA, MENTION_SCHEMA, buildAnswerPrompt, buildMentionPrompt, buildPreparePrompt, buildResumePrompt, buildTaskPrompt, postUrl, refOf, REMOTE_FAILED_PREFIX, taskUrl } from '../prompts.js';
|
|
19
20
|
import { RunnerState } from './state.js';
|
|
20
21
|
import { isGitRepo } from './workspace.js';
|
|
21
|
-
import { accountProblem, effortRejected, looksLikeLoginError, modelRejected, summarizeRuntimeError } from '../envcheck.js';
|
|
22
|
+
import { accountProblem, effortRejected, looksLikeLoginError, modelRejected, programMissing, summarizeRuntimeError } from '../envcheck.js';
|
|
22
23
|
import { redact } from '../redact.js';
|
|
23
24
|
import { TraceRecorder } from '../trace.js';
|
|
24
25
|
import { detectHost, looksLikeSandboxError, sandboxFix } from '../sandboxcheck.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 =
|
|
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 ||
|
|
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.
|
|
495
|
-
...(
|
|
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 =
|
|
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.
|
|
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
|
|
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' && !
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
1325
|
-
if (this.o.adapter.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
1580
|
-
return { ownerMemory, project: projectInstructions(workdir, this.o.adapter.
|
|
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,27 @@ export class Runner {
|
|
|
1748
1770
|
});
|
|
1749
1771
|
let m = model;
|
|
1750
1772
|
let ef = effort;
|
|
1751
|
-
|
|
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);
|
|
1780
|
+
// the runtime's program was not there: most often another ach on this machine is installing a new release into the npx
|
|
1781
|
+
// cache they share, which takes seconds. Once more after a wait; only a second miss reaches the hub as a broken install.
|
|
1782
|
+
if (!result.ok && !toolsRan && !entry.controller.signal.aborted && programMissing(result.error)) {
|
|
1783
|
+
const wait = this.o.programRetryMs ?? 30_000;
|
|
1784
|
+
const note = `the runtime's program was not found (${summarizeRuntimeError(result.error ?? '').slice(0, 160)}); trying once more in ${Math.round(wait / 1000)} s`;
|
|
1785
|
+
recorder.event({ type: 'error', data: note });
|
|
1786
|
+
this.taskLog(taskId, note);
|
|
1787
|
+
await new Promise((res) => {
|
|
1788
|
+
const t = setTimeout(res, wait);
|
|
1789
|
+
entry.controller.signal.addEventListener('abort', () => (clearTimeout(t), res()), { once: true });
|
|
1790
|
+
});
|
|
1791
|
+
if (!entry.controller.signal.aborted)
|
|
1792
|
+
result = await go(m, ef);
|
|
1793
|
+
}
|
|
1752
1794
|
// a model or an effort level the runtime does not take (a typo, one the account cannot use, a level the model lacks) must
|
|
1753
1795
|
// not stop the agent: run again on the default, and say so in the trace (the run's chip then shows what really answered)
|
|
1754
1796
|
for (let i = 0; i < 2 && !result.ok && !toolsRan && !entry.controller.signal.aborted; i++) {
|
|
@@ -1802,7 +1844,7 @@ export class Runner {
|
|
|
1802
1844
|
}
|
|
1803
1845
|
/** decisions §34: the capabilities server of one run, or undefined when nothing is declared (or the run is in the cloud). */
|
|
1804
1846
|
capsFor(taskId, runId, realHome, tmpDir) {
|
|
1805
|
-
if (this.
|
|
1847
|
+
if (this.cloud)
|
|
1806
1848
|
return undefined;
|
|
1807
1849
|
const file = this.o.capsFile ?? capsPath(this.o.home);
|
|
1808
1850
|
const { caps, problems } = loadCaps(file);
|
|
@@ -1918,10 +1960,6 @@ function promptFile(f) {
|
|
|
1918
1960
|
}
|
|
1919
1961
|
/** The light model that writes an agent's description, per runtime (none listed: the runtime's default). A runtime that does not
|
|
1920
1962
|
* take it runs the default instead. */
|
|
1921
|
-
const DESCRIBE_MODELS = {
|
|
1922
|
-
claude: { model: 'claude-haiku-5-5', effort: 'low' },
|
|
1923
|
-
codex: { model: 'gpt-6.1-sol', effort: 'medium' },
|
|
1924
|
-
};
|
|
1925
1963
|
const DESCRIBE_SCHEMA = { type: 'object', properties: { description: { type: 'string' } }, required: ['description'], additionalProperties: false };
|
|
1926
1964
|
function describePrompt(name, dirs) {
|
|
1927
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
|
-
|
|
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;
|
package/dist/src/sandboxcheck.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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 (
|
|
403
|
-
return { en: `${en} Renew it
|
|
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}\`。`,
|
package/dist/src/version.d.ts
CHANGED
package/dist/src/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koalaauto/agentchannel",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.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",
|