@koalaauto/agentchannel 3.53.1 → 3.53.3
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/client.d.ts +8 -0
- package/dist/src/client.js +42 -16
- package/dist/src/prompts.d.ts +34 -0
- package/dist/src/prompts.js +30 -2
- package/dist/src/runner/runner.js +3 -3
- package/dist/src/runner/structured.d.ts +2 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
package/dist/src/client.d.ts
CHANGED
|
@@ -376,6 +376,11 @@ export declare const CLIENT_HEADERS: Record<string, string>;
|
|
|
376
376
|
/** The hub could not be reached at all (no answer, a refused connection, a DNS failure, or no answer within the time limit). */
|
|
377
377
|
export declare class NetworkError extends Error {
|
|
378
378
|
}
|
|
379
|
+
/**
|
|
380
|
+
* Whether a failed fetch is worth sending again: a passing fault on the way to the hub, not a wrong address
|
|
381
|
+
* (ENOTFOUND, ECONNREFUSED) or a hub that took the request and did not answer in time.
|
|
382
|
+
*/
|
|
383
|
+
export declare function retryable(method: string, e: any): boolean;
|
|
379
384
|
export declare class HubError extends Error {
|
|
380
385
|
status: number;
|
|
381
386
|
code?: string | undefined;
|
|
@@ -401,6 +406,8 @@ export interface ClientOptions {
|
|
|
401
406
|
role?: 'runner';
|
|
402
407
|
/** Called with the newest CLI release the hub names (`x-ach-latest-client`, on every answer, errors included). */
|
|
403
408
|
onLatestClient?: (latest: string) => void;
|
|
409
|
+
/** Waits before each retry of a passing network fault (tests pass short ones). */
|
|
410
|
+
retryDelaysMs?: number[];
|
|
404
411
|
}
|
|
405
412
|
/** Round 2: human-facing CLI text in Chinese when LANG/LC_ALL starts with zh. */
|
|
406
413
|
export declare function isZh(env: NodeJS.ProcessEnv): boolean;
|
|
@@ -420,6 +427,7 @@ export declare class Client {
|
|
|
420
427
|
private cfSecret?;
|
|
421
428
|
private fetchFn;
|
|
422
429
|
constructor(o: ClientOptions);
|
|
430
|
+
private retryDelaysMs;
|
|
423
431
|
private role?;
|
|
424
432
|
/** Set after construction when the listener needs the client first (the runner's updater is built later). */
|
|
425
433
|
onLatestClient?: (latest: string) => void;
|
package/dist/src/client.js
CHANGED
|
@@ -32,6 +32,22 @@ export class NetworkError extends Error {
|
|
|
32
32
|
}
|
|
33
33
|
/** How long an ordinary request waits for the hub (uploads, which may be big, have no limit of their own). */
|
|
34
34
|
const REQUEST_TIMEOUT_MS = 60_000;
|
|
35
|
+
/** Waits before each retry of a request that failed on a passing network fault (about 12 s in all). */
|
|
36
|
+
const RETRY_DELAYS_MS = [1_000, 3_000, 8_000];
|
|
37
|
+
/** Faults while connecting: the request never left this machine, so any method may be sent again. */
|
|
38
|
+
const CONNECT_FAULTS = new Set(['ETIMEDOUT', 'UND_ERR_CONNECT_TIMEOUT', 'EAI_AGAIN', 'ENETUNREACH', 'EHOSTUNREACH']);
|
|
39
|
+
/** Faults after connecting: the hub may have acted on the request, so only a read is sent again. */
|
|
40
|
+
const SOCKET_FAULTS = new Set(['ECONNRESET', 'EPIPE', 'UND_ERR_SOCKET']);
|
|
41
|
+
/**
|
|
42
|
+
* Whether a failed fetch is worth sending again: a passing fault on the way to the hub, not a wrong address
|
|
43
|
+
* (ENOTFOUND, ECONNREFUSED) or a hub that took the request and did not answer in time.
|
|
44
|
+
*/
|
|
45
|
+
export function retryable(method, e) {
|
|
46
|
+
const code = String(e?.cause?.code ?? e?.code ?? '');
|
|
47
|
+
if (CONNECT_FAULTS.has(code))
|
|
48
|
+
return true;
|
|
49
|
+
return (method === 'GET' || method === 'HEAD') && SOCKET_FAULTS.has(code);
|
|
50
|
+
}
|
|
35
51
|
export class HubError extends Error {
|
|
36
52
|
status;
|
|
37
53
|
code;
|
|
@@ -89,7 +105,9 @@ export class Client {
|
|
|
89
105
|
this.ownFetch = !!o.fetch;
|
|
90
106
|
this.role = o.role;
|
|
91
107
|
this.onLatestClient = o.onLatestClient;
|
|
108
|
+
this.retryDelaysMs = o.retryDelaysMs ?? RETRY_DELAYS_MS;
|
|
92
109
|
}
|
|
110
|
+
retryDelaysMs;
|
|
93
111
|
role;
|
|
94
112
|
/** Set after construction when the listener needs the client first (the runner's updater is built later). */
|
|
95
113
|
onLatestClient;
|
|
@@ -132,23 +150,31 @@ export class Client {
|
|
|
132
150
|
({ body, files } = await this.splitAttachments(path, body, files));
|
|
133
151
|
const multipart = !!files?.length;
|
|
134
152
|
let res;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
153
|
+
for (let attempt = 0;; attempt++) {
|
|
154
|
+
try {
|
|
155
|
+
res = await this.fetchFn(url, {
|
|
156
|
+
method,
|
|
157
|
+
headers: this.headers(!multipart),
|
|
158
|
+
body: multipart ? await attachmentForm(body, files) : body === undefined ? undefined : JSON.stringify(body),
|
|
159
|
+
...(multipart ? {} : { signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS) }),
|
|
160
|
+
});
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
catch (e) {
|
|
164
|
+
if (attempt < this.retryDelaysMs.length && retryable(method, e)) {
|
|
165
|
+
await new Promise((r) => setTimeout(r, this.retryDelaysMs[attempt]));
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
const host = (() => { try {
|
|
169
|
+
return new URL(url).host;
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
return url;
|
|
173
|
+
} })();
|
|
174
|
+
const why = e?.name === 'TimeoutError' ? `no answer within ${REQUEST_TIMEOUT_MS / 1000} s` : String(e?.cause?.code ?? e?.cause?.message ?? e?.message ?? e);
|
|
175
|
+
const tries = attempt > 0 ? `, ${attempt + 1} tries` : '';
|
|
176
|
+
throw new NetworkError(`cannot reach ${host} (${why}${tries}): check the hub address, your network, and whether a VPN or proxy is in the way. \`ach doctor\` checks each step.`);
|
|
146
177
|
}
|
|
147
|
-
catch {
|
|
148
|
-
return url;
|
|
149
|
-
} })();
|
|
150
|
-
const why = e?.name === 'TimeoutError' ? `no answer within ${REQUEST_TIMEOUT_MS / 1000} s` : String(e?.cause?.code ?? e?.cause?.message ?? e?.message ?? e);
|
|
151
|
-
throw new NetworkError(`cannot reach ${host} (${why}): check the hub address, your network, and whether a VPN or proxy is in the way. \`ach doctor\` checks each step.`);
|
|
152
178
|
}
|
|
153
179
|
// Cloudflare Access in front of the hub answers with its login page (a redirect followed to *.cloudflareaccess.com,
|
|
154
180
|
// or a challenge header) instead of the hub's JSON: say so, instead of failing later on a missing field
|
package/dist/src/prompts.d.ts
CHANGED
|
@@ -190,6 +190,40 @@ export declare const ANSWER_SCHEMA: {
|
|
|
190
190
|
};
|
|
191
191
|
};
|
|
192
192
|
};
|
|
193
|
+
/**
|
|
194
|
+
* Structured mention runs: an answer schema with the escalation's one-line ask and who it goes to. Strict output schemas need every
|
|
195
|
+
* property required, so an answer sends ask "" and to "asker".
|
|
196
|
+
*/
|
|
197
|
+
export declare const MENTION_SCHEMA: {
|
|
198
|
+
readonly type: "object";
|
|
199
|
+
readonly additionalProperties: false;
|
|
200
|
+
readonly required: readonly ["action", "text", "evidence", "ask", "to"];
|
|
201
|
+
readonly properties: {
|
|
202
|
+
readonly action: {
|
|
203
|
+
readonly type: "string";
|
|
204
|
+
readonly enum: readonly ["answer", "decide"];
|
|
205
|
+
};
|
|
206
|
+
readonly text: {
|
|
207
|
+
readonly type: "string";
|
|
208
|
+
};
|
|
209
|
+
readonly evidence: {
|
|
210
|
+
readonly type: "string";
|
|
211
|
+
};
|
|
212
|
+
readonly ask: {
|
|
213
|
+
readonly type: "string";
|
|
214
|
+
};
|
|
215
|
+
readonly to: {
|
|
216
|
+
readonly type: "string";
|
|
217
|
+
readonly enum: readonly ["asker", "owner"];
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* 2026-11-18: a post asked "Evan, please judge this yourself: which option do you prefer?" through @evan-reelworker-staging. The run
|
|
223
|
+
* dug up the facts and wrote "Evan makes the final call" in a plain reply, so it sat among the Inbox's replies, never a to-do, and
|
|
224
|
+
* Evan reads only to-dos. A question put to the owner in person is theirs even when the agent can find every fact.
|
|
225
|
+
*/
|
|
226
|
+
export declare function ownerAskedRule(owner: string | undefined, structured: boolean): string;
|
|
193
227
|
/**
|
|
194
228
|
* Live test (gpt-6-luna): without this, a Codex answer run replied "decide"
|
|
195
229
|
* after zero tool calls although the answer was in a file of its cwd.
|
package/dist/src/prompts.js
CHANGED
|
@@ -414,6 +414,32 @@ export const ANSWER_SCHEMA = {
|
|
|
414
414
|
evidence: { type: 'string' },
|
|
415
415
|
},
|
|
416
416
|
};
|
|
417
|
+
/**
|
|
418
|
+
* Structured mention runs: an answer schema with the escalation's one-line ask and who it goes to. Strict output schemas need every
|
|
419
|
+
* property required, so an answer sends ask "" and to "asker".
|
|
420
|
+
*/
|
|
421
|
+
export const MENTION_SCHEMA = {
|
|
422
|
+
type: 'object',
|
|
423
|
+
additionalProperties: false,
|
|
424
|
+
required: ['action', 'text', 'evidence', 'ask', 'to'],
|
|
425
|
+
properties: {
|
|
426
|
+
action: { type: 'string', enum: ['answer', 'decide'] },
|
|
427
|
+
text: { type: 'string' },
|
|
428
|
+
evidence: { type: 'string' },
|
|
429
|
+
ask: { type: 'string' },
|
|
430
|
+
to: { type: 'string', enum: ['asker', 'owner'] },
|
|
431
|
+
},
|
|
432
|
+
};
|
|
433
|
+
/**
|
|
434
|
+
* 2026-11-18: a post asked "Evan, please judge this yourself: which option do you prefer?" through @evan-reelworker-staging. The run
|
|
435
|
+
* dug up the facts and wrote "Evan makes the final call" in a plain reply, so it sat among the Inbox's replies, never a to-do, and
|
|
436
|
+
* Evan reads only to-dos. A question put to the owner in person is theirs even when the agent can find every fact.
|
|
437
|
+
*/
|
|
438
|
+
export function ownerAskedRule(owner, structured) {
|
|
439
|
+
const who = owner ? `your owner (${owner})` : 'your owner';
|
|
440
|
+
const how = structured ? 'answer with action "decide" and to "owner"' : 'reply with `--escalate --to owner`';
|
|
441
|
+
return `- If the post asks ${who} in person (names them, or wants their own judgment, choice or approval), the decision is theirs even when you can find every fact: put what you found in the reply and ${how}, with an ask naming the choice. Writing in a plain reply that they decide does not reach them; only an escalation lands in their Inbox to-dos.`;
|
|
442
|
+
}
|
|
417
443
|
/**
|
|
418
444
|
* Live test (gpt-6-luna): without this, a Codex answer run replied "decide"
|
|
419
445
|
* after zero tool calls although the answer was in a file of its cwd.
|
|
@@ -484,8 +510,9 @@ export function buildMentionPrompt(c) {
|
|
|
484
510
|
const how = c.structured
|
|
485
511
|
? [
|
|
486
512
|
'- Do not run `ach`; the runner posts your reply in the thread. End with a JSON object only:',
|
|
487
|
-
' {"action":"answer","text":"<reply>","evidence":"<files/commands you checked>"} if you can answer from evidence, or',
|
|
488
|
-
' {"action":"decide","ask":"<the one thing the person must decide, one line>","text":"<why a human must decide, with options and money impact>","evidence":"<what you checked; claims you relay without checking, and whose>"} if it needs a human.',
|
|
513
|
+
' {"action":"answer","text":"<reply>","evidence":"<files/commands you checked>","ask":"","to":"asker"} if you can answer from evidence, or',
|
|
514
|
+
' {"action":"decide","ask":"<the one thing the person must decide, one line>","text":"<why a human must decide, with options and money impact>","evidence":"<what you checked; claims you relay without checking, and whose>","to":"asker"} if it needs a human (money, product direction, anything irreversible, or you are not sure). It goes to whoever mentioned you; "to":"owner" sends it to your own owner instead.',
|
|
515
|
+
ownerAskedRule(c.ownerName, true),
|
|
489
516
|
]
|
|
490
517
|
: [
|
|
491
518
|
'- If you can answer from evidence, reply in the thread. Write the reply after `-` as a quoted heredoc, so backticks and quotes in it stay text (a reply in double quotes with a backtick in it is refused):',
|
|
@@ -493,6 +520,7 @@ export function buildMentionPrompt(c) {
|
|
|
493
520
|
' <reply, markdown>',
|
|
494
521
|
' EOF',
|
|
495
522
|
"- If it needs a human (money, product direction, anything irreversible, or you are not sure): `ach reply --escalate --evidence '<what you checked; claims you relay without checking, and whose>' --ask '<the one thing they must decide, one line>' - <<'EOF'`, the reply saying why, with options and money impact, then `EOF` (it goes to whoever mentioned you; add `--to owner` when the decision is your own owner's, e.g. your owner must approve something)",
|
|
523
|
+
ownerAskedRule(c.ownerName, false),
|
|
496
524
|
"- Flag values go in single quotes, with no backtick or `$` in them; the heredoc's last line is `EOF` alone.",
|
|
497
525
|
'- `ach thread` shows the whole thread; `ach channel` the channel. Reply once, then stop.',
|
|
498
526
|
'- Besides these three `ach` commands only `git log`, `git show`, `git diff`, `git blame` and `git status` run here, each as one plain command (no pipes, no `cd`); any other command is refused (that does not mean `ach reply` is). Read files with Read, Glob and Grep.',
|
|
@@ -15,7 +15,7 @@ import { taskFiles } from '../attachments.js';
|
|
|
15
15
|
import { buildAgentEnv, inheritedEnv } from '../env.js';
|
|
16
16
|
import { unlinkWindowsSandbox } from '../codexhome.js';
|
|
17
17
|
import { effectivePerm } from '../perm.js';
|
|
18
|
-
import { ANSWER_SCHEMA, buildAnswerPrompt, buildMentionPrompt, buildPreparePrompt, buildResumePrompt, buildTaskPrompt, postUrl, refOf, REMOTE_FAILED_PREFIX, taskUrl } from '../prompts.js';
|
|
18
|
+
import { ANSWER_SCHEMA, MENTION_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
21
|
import { accountProblem, effortRejected, looksLikeLoginError, modelRejected, summarizeRuntimeError } from '../envcheck.js';
|
|
@@ -1437,7 +1437,7 @@ export class Runner {
|
|
|
1437
1437
|
threadUrl: !this.o.publicUrl && typeof run.thread.url === 'string' && /^https?:\/\//.test(run.thread.url) ? run.thread.url : postUrl(this.base(), threadId),
|
|
1438
1438
|
structured,
|
|
1439
1439
|
});
|
|
1440
|
-
const result = await this.execute(rec, entry, prompt, undefined, 'mention', structured ?
|
|
1440
|
+
const result = await this.execute(rec, entry, prompt, undefined, 'mention', structured ? MENTION_SCHEMA : undefined, {
|
|
1441
1441
|
threadId,
|
|
1442
1442
|
usage: (cost, est, used) => client.mentionUsage(mid, runId, cost, est, used),
|
|
1443
1443
|
recorder: (r) => { recorded = r; },
|
|
@@ -1472,7 +1472,7 @@ export class Runner {
|
|
|
1472
1472
|
await c.reply(threadId, String(out.text), { evidence: String(out.evidence) });
|
|
1473
1473
|
}
|
|
1474
1474
|
else if (String(out.text ?? '').trim()) {
|
|
1475
|
-
await c.reply(threadId, String(out.text), { escalate: true, ...(String(out.evidence ?? '').trim() ? { evidence: String(out.evidence) } : {}), ...(String(out.ask ?? '').trim() ? { ask: String(out.ask).replace(/\s+/g, ' ').trim().slice(0, 200) } : {}) });
|
|
1475
|
+
await c.reply(threadId, String(out.text), { escalate: true, ...(out.to === 'owner' ? { escalateTo: 'owner' } : {}), ...(String(out.evidence ?? '').trim() ? { evidence: String(out.evidence) } : {}), ...(String(out.ask ?? '').trim() ? { ask: String(out.ask).replace(/\s+/g, ' ').trim().slice(0, 200) } : {}) });
|
|
1476
1476
|
}
|
|
1477
1477
|
}
|
|
1478
1478
|
catch (e) {
|
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.53.
|
|
3
|
+
"version": "3.53.3",
|
|
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",
|