@zvada/agent-server 0.3.24 → 0.3.26
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/CHANGELOG.md +110 -0
- package/README.md +3 -0
- package/dist/client/client.js +93 -34
- package/dist/core/agents/acp/acp-agent.js +91 -14
- package/dist/core/agents/acp/mappings.js +5 -1
- package/dist/core/agents/claude-code/approvals.js +2 -1
- package/dist/core/agents/claude-code/claude-agent.js +12 -2
- package/dist/core/agents/claude-code/mcp.js +9 -1
- package/dist/core/agents/claude-code/models.js +16 -10
- package/dist/core/agents/claude-code/options.js +23 -2
- package/dist/core/agents/claude-code/session.js +21 -1
- package/dist/core/agents/claude-code/tools.js +9 -4
- package/dist/core/agents/claude-code/turn.js +2 -0
- package/dist/core/agents/codex-app-server/adapter.js +2 -0
- package/dist/core/agents/codex-app-server/client.js +8 -5
- package/dist/core/agents/codex-app-server/codex-agent.js +35 -2
- package/dist/core/agents/codex-app-server/effort.js +13 -6
- package/dist/core/agents/codex-app-server/mcp.js +35 -18
- package/dist/core/agents/codex-app-server/models.js +10 -10
- package/dist/core/agents/codex-app-server/options.js +11 -2
- package/dist/core/agents/codex-app-server/session.js +11 -4
- package/dist/core/agents/codex-app-server/thread-settings.js +30 -11
- package/dist/core/agents/host-tools.js +493 -0
- package/dist/core/agents/mcp-config.js +6 -2
- package/dist/core/agents/scripted/scripted-agent.js +11 -4
- package/dist/core/agents/scripted/steps.js +5 -1
- package/dist/core/agents/session-agent.js +70 -2
- package/dist/core/agents/thinking-levels.js +8 -5
- package/dist/core/index.js +1 -0
- package/dist/core/presets.js +12 -2
- package/dist/core/processes/identity.js +1 -0
- package/dist/core/processes/lifeline.js +13 -1
- package/dist/core/processes/process-table.js +1 -0
- package/dist/core/provision/extract.js +1 -0
- package/dist/core/provision/pins.js +7 -16
- package/dist/core/provision/releases.js +25 -25
- package/dist/core/proxy/loopback.js +22 -4
- package/dist/core/runtime/agent-runtime.js +6 -3
- package/dist/core/runtime/turn.js +20 -10
- package/dist/protocol/config.js +21 -1
- package/dist/protocol/credentials.js +2 -1
- package/dist/protocol/errors.js +12 -3
- package/dist/protocol/model-catalog.js +58 -18
- package/dist/protocol/models.js +6 -27
- package/dist/protocol/thinking.js +22 -9
- package/dist/protocol/wire-api.js +2 -2
- package/dist/server/bin.js +6 -4
- package/dist/server/routes.js +3 -2
- package/dist/types/client/client.d.ts +6 -1
- package/dist/types/client/client.d.ts.map +1 -1
- package/dist/types/core/agents/acp/acp-agent.d.ts +15 -0
- package/dist/types/core/agents/acp/acp-agent.d.ts.map +1 -1
- package/dist/types/core/agents/acp/mappings.d.ts +5 -1
- package/dist/types/core/agents/acp/mappings.d.ts.map +1 -1
- package/dist/types/core/agents/acp/requests.d.ts +2 -0
- package/dist/types/core/agents/acp/requests.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/approvals.d.ts +2 -1
- package/dist/types/core/agents/claude-code/approvals.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/claude-agent.d.ts +1 -0
- package/dist/types/core/agents/claude-code/claude-agent.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/mcp.d.ts +8 -1
- package/dist/types/core/agents/claude-code/mcp.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/models.d.ts +9 -5
- package/dist/types/core/agents/claude-code/models.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/options.d.ts +14 -1
- package/dist/types/core/agents/claude-code/options.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/session.d.ts +2 -0
- package/dist/types/core/agents/claude-code/session.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/tools.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/turn.d.ts +3 -0
- package/dist/types/core/agents/claude-code/turn.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/adapter.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/client.d.ts +2 -0
- package/dist/types/core/agents/codex-app-server/client.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts +11 -0
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/effort.d.ts +7 -7
- package/dist/types/core/agents/codex-app-server/effort.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/mcp.d.ts +11 -3
- package/dist/types/core/agents/codex-app-server/mcp.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/models.d.ts +4 -1
- package/dist/types/core/agents/codex-app-server/models.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/options.d.ts +9 -2
- package/dist/types/core/agents/codex-app-server/options.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/requests.d.ts +2 -0
- package/dist/types/core/agents/codex-app-server/requests.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/session.d.ts +6 -3
- package/dist/types/core/agents/codex-app-server/session.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts.map +1 -1
- package/dist/types/core/agents/host-tools.d.ts +162 -0
- package/dist/types/core/agents/host-tools.d.ts.map +1 -0
- package/dist/types/core/agents/mcp-config.d.ts +11 -2
- package/dist/types/core/agents/mcp-config.d.ts.map +1 -1
- package/dist/types/core/agents/scripted/scripted-agent.d.ts.map +1 -1
- package/dist/types/core/agents/scripted/steps.d.ts +1 -1
- package/dist/types/core/agents/scripted/steps.d.ts.map +1 -1
- package/dist/types/core/agents/session-agent.d.ts +2 -7
- package/dist/types/core/agents/session-agent.d.ts.map +1 -1
- package/dist/types/core/agents/thinking-levels.d.ts +7 -3
- package/dist/types/core/agents/thinking-levels.d.ts.map +1 -1
- package/dist/types/core/index.d.ts +1 -0
- package/dist/types/core/index.d.ts.map +1 -1
- package/dist/types/core/presets.d.ts +11 -1
- package/dist/types/core/presets.d.ts.map +1 -1
- package/dist/types/core/processes/identity.d.ts.map +1 -1
- package/dist/types/core/processes/lifeline.d.ts.map +1 -1
- package/dist/types/core/processes/process-table.d.ts.map +1 -1
- package/dist/types/core/provision/extract.d.ts.map +1 -1
- package/dist/types/core/provision/pins.d.ts +5 -4
- package/dist/types/core/provision/pins.d.ts.map +1 -1
- package/dist/types/core/proxy/loopback.d.ts.map +1 -1
- package/dist/types/core/runtime/agent-runtime.d.ts +4 -1
- package/dist/types/core/runtime/agent-runtime.d.ts.map +1 -1
- package/dist/types/core/runtime/turn.d.ts +12 -7
- package/dist/types/core/runtime/turn.d.ts.map +1 -1
- package/dist/types/protocol/clis.d.ts +3 -3
- package/dist/types/protocol/config.d.ts +12 -19
- package/dist/types/protocol/config.d.ts.map +1 -1
- package/dist/types/protocol/conversation.d.ts +10 -42
- package/dist/types/protocol/conversation.d.ts.map +1 -1
- package/dist/types/protocol/credentials.d.ts +13 -1
- package/dist/types/protocol/credentials.d.ts.map +1 -1
- package/dist/types/protocol/errors.d.ts +6 -4
- package/dist/types/protocol/errors.d.ts.map +1 -1
- package/dist/types/protocol/execution.d.ts +2 -18
- package/dist/types/protocol/execution.d.ts.map +1 -1
- package/dist/types/protocol/lifecycle.d.ts +12 -76
- package/dist/types/protocol/lifecycle.d.ts.map +1 -1
- package/dist/types/protocol/model-catalog.d.ts.map +1 -1
- package/dist/types/protocol/models.d.ts +4 -42
- package/dist/types/protocol/models.d.ts.map +1 -1
- package/dist/types/protocol/thinking.d.ts +19 -19
- package/dist/types/protocol/thinking.d.ts.map +1 -1
- package/dist/types/protocol/wire-api.d.ts +32 -117
- package/dist/types/protocol/wire-api.d.ts.map +1 -1
- package/dist/types/protocol/wire.d.ts +24 -125
- package/dist/types/protocol/wire.d.ts.map +1 -1
- package/dist/types/server/routes.d.ts.map +1 -1
- package/docs/consuming.md +92 -12
- package/docs/deploy.md +8 -0
- package/docs/harnesses.md +88 -27
- package/package.json +4 -4
- package/src/client/client.ts +114 -44
- package/src/core/agents/acp/acp-agent.ts +123 -17
- package/src/core/agents/acp/mappings.ts +5 -1
- package/src/core/agents/acp/requests.ts +2 -0
- package/src/core/agents/claude-code/approvals.ts +2 -1
- package/src/core/agents/claude-code/claude-agent.ts +14 -2
- package/src/core/agents/claude-code/mcp.ts +11 -1
- package/src/core/agents/claude-code/models.ts +15 -10
- package/src/core/agents/claude-code/options.ts +37 -3
- package/src/core/agents/claude-code/session.ts +26 -1
- package/src/core/agents/claude-code/tools.ts +10 -4
- package/src/core/agents/claude-code/turn.ts +4 -0
- package/src/core/agents/codex-app-server/adapter.ts +2 -0
- package/src/core/agents/codex-app-server/client.ts +11 -5
- package/src/core/agents/codex-app-server/codex-agent.ts +45 -1
- package/src/core/agents/codex-app-server/effort.ts +15 -20
- package/src/core/agents/codex-app-server/mcp.ts +46 -23
- package/src/core/agents/codex-app-server/models.ts +10 -10
- package/src/core/agents/codex-app-server/options.ts +16 -2
- package/src/core/agents/codex-app-server/requests.ts +2 -0
- package/src/core/agents/codex-app-server/session.ts +19 -4
- package/src/core/agents/codex-app-server/thread-settings.ts +31 -11
- package/src/core/agents/host-tools.ts +649 -0
- package/src/core/agents/mcp-config.ts +15 -3
- package/src/core/agents/scripted/scripted-agent.ts +11 -3
- package/src/core/agents/scripted/steps.ts +5 -1
- package/src/core/agents/session-agent.ts +78 -2
- package/src/core/agents/thinking-levels.ts +9 -6
- package/src/core/index.ts +9 -0
- package/src/core/presets.ts +24 -3
- package/src/core/processes/identity.ts +1 -0
- package/src/core/processes/lifeline.ts +14 -1
- package/src/core/processes/process-table.ts +1 -0
- package/src/core/provision/extract.ts +1 -0
- package/src/core/provision/pins.ts +7 -16
- package/src/core/provision/releases.ts +25 -25
- package/src/core/proxy/loopback.ts +25 -4
- package/src/core/runtime/agent-runtime.ts +6 -3
- package/src/core/runtime/turn.ts +21 -9
- package/src/protocol/config.ts +22 -1
- package/src/protocol/credentials.ts +19 -5
- package/src/protocol/errors.ts +12 -3
- package/src/protocol/model-catalog.ts +58 -18
- package/src/protocol/models.ts +6 -26
- package/src/protocol/thinking.ts +27 -14
- package/src/protocol/wire-api.ts +2 -2
- package/src/server/bin.ts +6 -4
- package/src/server/routes.ts +3 -2
|
@@ -2,6 +2,7 @@ import { withTimeout } from "../utils/deadline.js";
|
|
|
2
2
|
import { SessionResumeError, TurnActiveError } from "../utils/errors.js";
|
|
3
3
|
import { BaseAgent, CANCEL_CONFIRM_MS, } from "./base.js";
|
|
4
4
|
import { configFingerprint } from "./config-fingerprint.js";
|
|
5
|
+
import { withoutSecret } from "./host-tools.js";
|
|
5
6
|
/**
|
|
6
7
|
* The execution lifecycle the engine's own harnesses extend: one turn owns a
|
|
7
8
|
* logical session from preparation through native cleanup, with steering,
|
|
@@ -9,6 +10,43 @@ import { configFingerprint } from "./config-fingerprint.js";
|
|
|
9
10
|
* exported while its design is a Draft (LLP 0016); a product's own harness
|
|
10
11
|
* extends `BaseAgent`, the public base.
|
|
11
12
|
*/
|
|
13
|
+
// @ref LLP 0018#who-can-read-the-secret — the broker publishes a request's options too
|
|
14
|
+
/**
|
|
15
|
+
* A permission request as the broker publishes it: its tool call and its
|
|
16
|
+
* options (a harness's own labels and ids) without the secret, and the
|
|
17
|
+
* option picked mapped back to the harness's own id.
|
|
18
|
+
*/
|
|
19
|
+
async function permission(ask, scrub, call, rest) {
|
|
20
|
+
const [opts] = rest;
|
|
21
|
+
if (!opts)
|
|
22
|
+
return ask(scrub(call), ...rest);
|
|
23
|
+
const scrubbed = scrub(opts);
|
|
24
|
+
// A choice whose id held the secret gets an opaque id of its own, unique, so
|
|
25
|
+
// two redacted the same can never be taken for each other.
|
|
26
|
+
const used = new Set((scrubbed.options ?? []).flatMap((option, index) => opts.options?.[index]?.optionId === option.optionId ? [option.optionId] : []));
|
|
27
|
+
const opaque = (index) => {
|
|
28
|
+
let id = `redacted-option-${index}`;
|
|
29
|
+
while (used.has(id))
|
|
30
|
+
id += "-";
|
|
31
|
+
used.add(id);
|
|
32
|
+
return id;
|
|
33
|
+
};
|
|
34
|
+
const choices = (scrubbed.options ?? []).map((option, index) => {
|
|
35
|
+
const own = opts.options?.[index]?.optionId ?? option.optionId;
|
|
36
|
+
return {
|
|
37
|
+
option: own === option.optionId ? option : { ...option, optionId: opaque(index) },
|
|
38
|
+
own,
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
const native = new Map(choices.map(({ option, own }) => [option.optionId, own]));
|
|
42
|
+
const shown = scrubbed.options
|
|
43
|
+
? { ...scrubbed, options: choices.map(({ option }) => option) }
|
|
44
|
+
: scrubbed;
|
|
45
|
+
const decision = await ask(scrub(call), shown);
|
|
46
|
+
if (decision.decision === "cancel" || decision.optionId === undefined)
|
|
47
|
+
return decision;
|
|
48
|
+
return { ...decision, optionId: native.get(decision.optionId) ?? decision.optionId };
|
|
49
|
+
}
|
|
12
50
|
export class SessionAgent extends BaseAgent {
|
|
13
51
|
terminated = false;
|
|
14
52
|
/**
|
|
@@ -53,8 +91,33 @@ export class SessionAgent extends BaseAgent {
|
|
|
53
91
|
try {
|
|
54
92
|
// The adapter still produces its native cancellation result for an
|
|
55
93
|
// already-aborted turn. It must not select a conversation or do setup.
|
|
56
|
-
const
|
|
57
|
-
|
|
94
|
+
const ready = controller.signal.aborted ? options : this.prepareSessionOptions(options);
|
|
95
|
+
// @ref LLP 0018#who-can-read-the-secret — the session's own secret leaves in no text
|
|
96
|
+
// Kept for the turn once seen: its output may still drain after the session's release.
|
|
97
|
+
let secret;
|
|
98
|
+
const scrub = (value) => {
|
|
99
|
+
secret ??= this.hostSecret(sessionId);
|
|
100
|
+
return withoutSecret(value, secret);
|
|
101
|
+
};
|
|
102
|
+
const { onWarning, onPermissionRequest, onElicitationRequest } = ready;
|
|
103
|
+
const prepared = {
|
|
104
|
+
...ready,
|
|
105
|
+
...(onWarning && { onWarning: (warning) => onWarning(scrub(warning)) }),
|
|
106
|
+
// What the broker puts on the stream (a request's input, its title) is the agent's text too.
|
|
107
|
+
...(onPermissionRequest && {
|
|
108
|
+
onPermissionRequest: (call, ...rest) => permission(onPermissionRequest, scrub, call, rest),
|
|
109
|
+
}),
|
|
110
|
+
...(onElicitationRequest && {
|
|
111
|
+
onElicitationRequest: (request, ...rest) => onElicitationRequest(scrub(request), ...rest),
|
|
112
|
+
}),
|
|
113
|
+
};
|
|
114
|
+
try {
|
|
115
|
+
for await (const event of this.executeTurn(input, prepared, controller))
|
|
116
|
+
yield scrub(event);
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
throw scrub(error);
|
|
120
|
+
}
|
|
58
121
|
}
|
|
59
122
|
finally {
|
|
60
123
|
this.executed.set(sessionId, options.turnId);
|
|
@@ -167,6 +230,11 @@ export class SessionAgent extends BaseAgent {
|
|
|
167
230
|
if (turn?.turnId === options.turnId)
|
|
168
231
|
turn.deliver = undefined;
|
|
169
232
|
}
|
|
233
|
+
/** Native protocol execution; options are prepared and the session is exclusively owned. */
|
|
234
|
+
/** The session's host-tools secret, which no event, warning or error it lets out may hold. */
|
|
235
|
+
hostSecret(_sessionId) {
|
|
236
|
+
return undefined;
|
|
237
|
+
}
|
|
170
238
|
prepareSessionOptions(options) {
|
|
171
239
|
const boundary = configFingerprint({
|
|
172
240
|
cwd: options.cwd,
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The levels a harness lists: each non-blank string once, in the order given.
|
|
3
|
+
* The order is the harness's own (both CLIs list lowest first), and a name
|
|
4
|
+
* this build does not know is kept.
|
|
5
|
+
*/
|
|
6
|
+
export function listedThinkingLevels(values) {
|
|
4
7
|
const levels = new Set();
|
|
5
8
|
for (const value of values)
|
|
6
|
-
if (typeof value === "string" &&
|
|
9
|
+
if (typeof value === "string" && /\S/.test(value))
|
|
7
10
|
levels.add(value);
|
|
8
|
-
return
|
|
11
|
+
return [...levels];
|
|
9
12
|
}
|
package/dist/core/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { EventSinkError, callbackSink, CollectingSink, serialSink, teeSink, } fr
|
|
|
6
6
|
export { BaseAgent, } from "./agents/base.js";
|
|
7
7
|
export { AgentRegistry } from "./agents/registry.js";
|
|
8
8
|
export { credentialsFromUrl } from "./agents/credentials.js";
|
|
9
|
+
export { HOST_TOOL_TIMEOUT_MS, } from "./agents/host-tools.js";
|
|
9
10
|
export { INHERIT_CONFIGS, isInheritConfig, } from "./agents/inherit-config.js";
|
|
10
11
|
// Native processes: each CLI in a group of its own, held by the lifeline, recorded, swept at restart.
|
|
11
12
|
export { DEFAULT_GRACE_MS, NativeProcess, NativeProcesses, } from "./processes/native-processes.js";
|
package/dist/core/presets.js
CHANGED
|
@@ -21,6 +21,7 @@ const HARNESSES = {
|
|
|
21
21
|
onDiagnostic: opts.onDiagnostic,
|
|
22
22
|
...opts.claudeCode,
|
|
23
23
|
credentials: opts.credentials,
|
|
24
|
+
hostTools: opts.hostTools,
|
|
24
25
|
idleTimeoutMs: opts.idleTimeoutMs,
|
|
25
26
|
cancelConfirmMs: opts.cancelConfirmMs,
|
|
26
27
|
cancelGraceMs: opts.cancelGraceMs,
|
|
@@ -34,6 +35,7 @@ const HARNESSES = {
|
|
|
34
35
|
new CodexAppServerAgent({
|
|
35
36
|
...opts.codexAppServer,
|
|
36
37
|
credentials: opts.credentials,
|
|
38
|
+
hostTools: opts.hostTools,
|
|
37
39
|
idleTimeoutMs: opts.idleTimeoutMs,
|
|
38
40
|
cancelConfirmMs: opts.cancelConfirmMs,
|
|
39
41
|
cancelGraceMs: opts.cancelGraceMs,
|
|
@@ -47,9 +49,16 @@ const HARNESSES = {
|
|
|
47
49
|
if (!opts.acp) {
|
|
48
50
|
throw new Error("the acp harness requires CreateRegistryOptions.acp (resolveLaunch)");
|
|
49
51
|
}
|
|
50
|
-
const { idleTimeoutMs, cancelConfirmMs, cancelGraceMs } = opts;
|
|
52
|
+
const { idleTimeoutMs, cancelConfirmMs, cancelGraceMs, hostTools } = opts;
|
|
51
53
|
return [
|
|
52
|
-
new AcpAgent({
|
|
54
|
+
new AcpAgent({
|
|
55
|
+
...opts.acp,
|
|
56
|
+
idleTimeoutMs,
|
|
57
|
+
cancelConfirmMs,
|
|
58
|
+
cancelGraceMs,
|
|
59
|
+
hostTools,
|
|
60
|
+
processes,
|
|
61
|
+
}),
|
|
53
62
|
createAcpTransformer,
|
|
54
63
|
];
|
|
55
64
|
},
|
|
@@ -69,6 +78,7 @@ const SAID_ONCE = {
|
|
|
69
78
|
cancelConfirmMs: atTheTop("cancelConfirmMs"),
|
|
70
79
|
cancelGraceMs: atTheTop("cancelGraceMs"),
|
|
71
80
|
inheritConfig: atTheTop("inheritConfig"),
|
|
81
|
+
hostTools: atTheTop("hostTools"),
|
|
72
82
|
processes: "the registry gives every harness its processes; say how they are owned with nativeProcesses",
|
|
73
83
|
resolveCliPath: "the registry's provisioner finds each CLI; name one with provision.overrides",
|
|
74
84
|
};
|
|
@@ -85,6 +85,13 @@ const RESPAWN_WINDOW_MS = 1_000;
|
|
|
85
85
|
*/
|
|
86
86
|
function startShell(ticks, exited, failed) {
|
|
87
87
|
const args = ["-c", LIFELINE_SCRIPT, LIFELINE_NAME, ticks];
|
|
88
|
+
// @ref LLP 0007#the-environment-a-process-is-given — only what its script needs
|
|
89
|
+
// It lives as long as the engine, and any process of this user can read its
|
|
90
|
+
// environment (`/proc/<pid>/environ`): `PATH` finds its `sed`, `awk`, `cat`,
|
|
91
|
+
// `tr` and `sleep`. Nothing else of the engine's environment is given;
|
|
92
|
+
// Node itself adds `NODE_V8_COVERAGE` to every child when the engine runs
|
|
93
|
+
// with it set (Bun adds nothing).
|
|
94
|
+
const env = { PATH: process.env.PATH };
|
|
88
95
|
const bun = globalThis.Bun;
|
|
89
96
|
if (bun) {
|
|
90
97
|
// @ref LLP 0007#the-lifeline — registered before the CLI gets input
|
|
@@ -96,6 +103,7 @@ function startShell(ticks, exited, failed) {
|
|
|
96
103
|
stdout: "ignore",
|
|
97
104
|
stderr: "ignore",
|
|
98
105
|
detached: true,
|
|
106
|
+
env,
|
|
99
107
|
onExit: exited,
|
|
100
108
|
});
|
|
101
109
|
child.unref();
|
|
@@ -110,7 +118,11 @@ function startShell(ticks, exited, failed) {
|
|
|
110
118
|
};
|
|
111
119
|
}
|
|
112
120
|
// Node writes a pipe at once when it can (libuv's `uv_try_write`).
|
|
113
|
-
const child = spawn("/bin/sh", args, {
|
|
121
|
+
const child = spawn("/bin/sh", args, {
|
|
122
|
+
detached: true,
|
|
123
|
+
env,
|
|
124
|
+
stdio: ["pipe", "ignore", "ignore"],
|
|
125
|
+
});
|
|
114
126
|
child.unref();
|
|
115
127
|
child.stdin?.unref?.();
|
|
116
128
|
child.stdin?.on("error", () => { });
|
|
@@ -10,6 +10,7 @@ const EXTRACT_TIMEOUT_MS = 5 * 60_000;
|
|
|
10
10
|
export async function extractTarGz(tgzPath, destDir) {
|
|
11
11
|
await new Promise((resolve, reject) => {
|
|
12
12
|
const proc = spawn("tar", ["-xzf", tgzPath, "-C", destDir], {
|
|
13
|
+
env: process.env,
|
|
13
14
|
stdio: ["ignore", "ignore", "pipe"],
|
|
14
15
|
timeout: EXTRACT_TIMEOUT_MS,
|
|
15
16
|
});
|
|
@@ -14,22 +14,13 @@
|
|
|
14
14
|
* `auto` an installed `@openai/codex` package (a lockfile's) runs instead,
|
|
15
15
|
* and a `codex` on PATH only in `system` mode.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
17
|
+
* A bump is `bun run bump -- <tool>`: it writes what changed upstream, moves
|
|
18
|
+
* the pin, and runs both refreshes, `releases:refresh` (each platform's build
|
|
19
|
+
* and its checksums, `releases.ts`) and `models:refresh` (the model catalog,
|
|
20
|
+
* which records the versions that listed it); tests fail until both match
|
|
21
|
+
* these pins. The `bump-clis` skill says what to read and prove.
|
|
21
22
|
*/
|
|
22
23
|
export const DEFAULT_PINS = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// streamed token-estimate placeholders). Re-check thinking summaries on
|
|
26
|
-
// every bump (see options.ts extraArgs).
|
|
27
|
-
claude: "0.3.288",
|
|
28
|
-
// 0.160.0 re-verified 2026-10-03 against generate-ts: thread/turn/item
|
|
29
|
-
// methods, token usage, approvals, and host-managed ChatGPT auth changed
|
|
30
|
-
// only additively since 0.153.4. Of the GPT-6 family, 0.153.4 lists only
|
|
31
|
-
// gpt-6-astra; the rest needs 0.159 or newer.
|
|
32
|
-
// Since 0.160 a thread has one writer: resuming it from a second process
|
|
33
|
-
// fails until the first releases it.
|
|
34
|
-
codex: "0.160.0",
|
|
24
|
+
claude: "0.3.327",
|
|
25
|
+
codex: "0.169.1",
|
|
35
26
|
};
|
|
@@ -5,63 +5,63 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export const CLI_RELEASES = {
|
|
7
7
|
claude: {
|
|
8
|
-
version: "0.3.
|
|
9
|
-
cli: "2.1.
|
|
8
|
+
version: "0.3.327",
|
|
9
|
+
cli: "2.1.327",
|
|
10
10
|
builds: {
|
|
11
11
|
"darwin-arm64": {
|
|
12
|
-
integrity: "sha512-
|
|
13
|
-
sha256: "
|
|
12
|
+
integrity: "sha512-n+tQOPqz264l12BAKBcBPBbdB/bmZ2SfyONtEXQufTU6EeCoQMPS58RSt51Cxk5sDUme1hTF0vVAqRPdhq8tFg==",
|
|
13
|
+
sha256: "76d48205c926c8a6978cfc2171b631bcd01e20bbadd085638bb2ec57bea91c5b",
|
|
14
14
|
},
|
|
15
15
|
"darwin-x64": {
|
|
16
|
-
integrity: "sha512-
|
|
17
|
-
sha256: "
|
|
16
|
+
integrity: "sha512-u091X+eQIyqg8BIEYLWJ0o6U3BaivMcf8Im4hI3hti/NGJ6YC5sR+LLEa1RjSIKE+JoOfCxipdCNSKaEI+0d5Q==",
|
|
17
|
+
sha256: "1fe75c05df7be824af1ed80ff9ccdf2be991f3a2212b97e05fc9a3bff2f39ef9",
|
|
18
18
|
},
|
|
19
19
|
"linux-arm64": {
|
|
20
|
-
integrity: "sha512
|
|
21
|
-
sha256: "
|
|
20
|
+
integrity: "sha512-/k6BfV+L2er67UoLUabcp0w3L1DMemJjoijdxvXDiU8w81fGfHaKWKhRuhUQFmIrMLyMyQcBKaoyUNSLWovPnw==",
|
|
21
|
+
sha256: "acf0ef2f9da8d5ab08f193f007e19a06cbfb608b96a2f1f758d63a92a386cff8",
|
|
22
22
|
},
|
|
23
23
|
"linux-x64": {
|
|
24
|
-
integrity: "sha512-
|
|
25
|
-
sha256: "
|
|
24
|
+
integrity: "sha512-oAdL7KM9UVAZlATeSjh2haeEjex1N7ZcHzWO1tY2hgyhkyLNVw/tWUhITOucxMwokBx++h2dMVjxiPJiZ5uVOQ==",
|
|
25
|
+
sha256: "343c744baa14bfd38286a7cb90871051f04379956da6c5b803a9e66019a76ac9",
|
|
26
26
|
},
|
|
27
27
|
"linux-arm64-musl": {
|
|
28
|
-
integrity: "sha512-
|
|
29
|
-
sha256: "
|
|
28
|
+
integrity: "sha512-oV8/+ZixiPzEW1BStoP9FOXsHcznONaom6S2PwwIfhi5Pxa5fGuloy8TiOB9wK+03zavqt7jmzLgVPF2a2NsTA==",
|
|
29
|
+
sha256: "e44a59ef850788c578adaab7a6487d5d0af9c0844401da9d7263e7b41515754b",
|
|
30
30
|
},
|
|
31
31
|
"linux-x64-musl": {
|
|
32
|
-
integrity: "sha512-
|
|
33
|
-
sha256: "
|
|
32
|
+
integrity: "sha512-O0nDZ1gpXi83qAdd8SM0gTdjlzrqpOlW0M4W7PfHVrMXWLh9I+1tvHat+s17ehIW6A9VQIWIq4oMwq7jb708Dg==",
|
|
33
|
+
sha256: "d2b02e78664c1347aff8fcee045356ee044116be41d7f412721a6c50182b6d98",
|
|
34
34
|
},
|
|
35
35
|
"win32-arm64": {
|
|
36
|
-
integrity: "sha512-
|
|
37
|
-
sha256: "
|
|
36
|
+
integrity: "sha512-a5ju83mylDvUwvQyRt1E0TQ0ar2nzVMPeWZhjcmgpB1cNTjf+KT5jgUnLvxPOG2tyjhm8bYGysRMdgB+tVnhvw==",
|
|
37
|
+
sha256: "d2c3395d252007540a5662a2cfd4d8903a0beb5fa32c893cd13b81be427625a7",
|
|
38
38
|
},
|
|
39
39
|
"win32-x64": {
|
|
40
|
-
integrity: "sha512-
|
|
41
|
-
sha256: "
|
|
40
|
+
integrity: "sha512-bf52nw4j5RCvkXI5Poj5Qf0jWvuLQ/UPFqdav86UwaGTZZ0txNV33MKBIUoCyxXV6IC1/p2BNfkwmCAZ+Uc9pw==",
|
|
41
|
+
sha256: "d6c8075bfb3b87f1c1254e64b6c35dadc628d21e75930ae51e47047b3f05a4a2",
|
|
42
42
|
},
|
|
43
43
|
},
|
|
44
44
|
},
|
|
45
45
|
codex: {
|
|
46
|
-
version: "0.
|
|
46
|
+
version: "0.169.1",
|
|
47
47
|
builds: {
|
|
48
48
|
"darwin-arm64": {
|
|
49
|
-
integrity: "sha512-
|
|
49
|
+
integrity: "sha512-yOKvCJktlbxdETtXAidz2GcC4z/WMYPmu2plncYJtUI5AhnFIExen8n9eL/El6n9hYbzzZFf1JgyW7yHx6kwTw==",
|
|
50
50
|
},
|
|
51
51
|
"darwin-x64": {
|
|
52
|
-
integrity: "sha512-
|
|
52
|
+
integrity: "sha512-IbHIskdPWGAXFCdGiB8CosfXXtdvMmusrQ2AdW2kFHd6aSJZ+dvgalwjpxmAytalnNM3pQgXwS/6fU1OclFv8Q==",
|
|
53
53
|
},
|
|
54
54
|
"linux-arm64": {
|
|
55
|
-
integrity: "sha512-
|
|
55
|
+
integrity: "sha512-6vRE7ZxkngT6L5JQ9WUQ2UnztS6hqyfcQiFqvk0yhcvWsrZLJNiiDZcKzGbLfJK2sDy7tSt9uWdP1cIgMHIkaw==",
|
|
56
56
|
},
|
|
57
57
|
"linux-x64": {
|
|
58
|
-
integrity: "sha512-
|
|
58
|
+
integrity: "sha512-KmlHQ/lB9jcn8Yy5z/tWCpSPsqBvI3pU+0PUPccr+pKiiU2NJSCvZcAD7s3dmIFq5ZvGYtGcSn2KdFFdaPQICg==",
|
|
59
59
|
},
|
|
60
60
|
"win32-arm64": {
|
|
61
|
-
integrity: "sha512-
|
|
61
|
+
integrity: "sha512-EYXwgEdHHzwgA0nnDcK4pI98IdReB1aDebtOxcYixM1/GY2Y/76oDFYSs/u6DzA27f6Hhf5V92OwQFw/GLICUQ==",
|
|
62
62
|
},
|
|
63
63
|
"win32-x64": {
|
|
64
|
-
integrity: "sha512
|
|
64
|
+
integrity: "sha512-fImXWqxwxqHh9+FhJWsRRFiBzgBrSeN1bYTvtGZtUKGTPzHefYAL1agmlf5XScfwY5i5pHsExfdhFekzRBbqIw==",
|
|
65
65
|
},
|
|
66
66
|
},
|
|
67
67
|
},
|
|
@@ -35,31 +35,49 @@ async function bridge(handle, req, res) {
|
|
|
35
35
|
}
|
|
36
36
|
res.end();
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Bun's own `Response`. A product's process may have replaced the global one
|
|
40
|
+
* (Hono's Node server does, with a class of its own), and `Bun.serve` refuses
|
|
41
|
+
* any other ("Expected a Response object"); `fetch` still answers with Bun's.
|
|
42
|
+
*/
|
|
43
|
+
async function nativeResponse() {
|
|
44
|
+
return (await fetch("data:,")).constructor;
|
|
45
|
+
}
|
|
38
46
|
/**
|
|
39
47
|
* Serve `handle` on 127.0.0.1, on a port of its own: with `Bun.serve` under
|
|
40
48
|
* Bun, whose `node:http` says nothing of a client that left once its request
|
|
41
49
|
* body was read (a stopped turn's request would run on upstream), and with
|
|
42
50
|
* `node:http` under Node.
|
|
43
51
|
*/
|
|
44
|
-
export function serveLoopback(handle) {
|
|
52
|
+
export async function serveLoopback(handle) {
|
|
45
53
|
const bun = globalThis.Bun;
|
|
46
54
|
if (bun) {
|
|
55
|
+
const Native = await nativeResponse();
|
|
56
|
+
const native = (response) =>
|
|
57
|
+
// Not `instanceof`: Hono's class sets Bun's prototype under its own.
|
|
58
|
+
response.constructor === Native
|
|
59
|
+
? response
|
|
60
|
+
: new Native(response.body, {
|
|
61
|
+
status: response.status,
|
|
62
|
+
statusText: response.statusText,
|
|
63
|
+
headers: [...response.headers],
|
|
64
|
+
});
|
|
47
65
|
const server = bun.serve({
|
|
48
66
|
port: 0,
|
|
49
67
|
hostname: "127.0.0.1",
|
|
50
68
|
// A model can think longer than any idle limit between the events it streams.
|
|
51
69
|
idleTimeout: 0,
|
|
52
|
-
fetch: (request) => handle(request).
|
|
70
|
+
fetch: (request) => handle(request).then(native, () => new Native(null, { status: 502 })),
|
|
53
71
|
});
|
|
54
72
|
// Nothing on it keeps the process alive.
|
|
55
73
|
server.unref();
|
|
56
|
-
return
|
|
74
|
+
return {
|
|
57
75
|
url: `http://127.0.0.1:${server.port}`,
|
|
58
76
|
// Not waited for: with a client still connected, Bun's stop can take its time.
|
|
59
77
|
close: async () => {
|
|
60
78
|
server.stop(true);
|
|
61
79
|
},
|
|
62
|
-
}
|
|
80
|
+
};
|
|
63
81
|
}
|
|
64
82
|
const server = createServer((req, res) => {
|
|
65
83
|
bridge(handle, req, res).catch(() => {
|
|
@@ -283,11 +283,14 @@ export class AgentRuntime {
|
|
|
283
283
|
* Cancel the session's in-flight turn. An idle session is a clean no-op ack
|
|
284
284
|
* (`{confirmed: true, hadTurn: false}`); `confirmed: false` means a turn
|
|
285
285
|
* existed but the harness did not acknowledge the interrupt — the agent may
|
|
286
|
-
* still be running; `turn.ended` remains the source of truth.
|
|
286
|
+
* still be running; `turn.ended` remains the source of truth. A turn
|
|
287
|
+
* admitted but not yet on its harness answers `hadTurn: false` too (the
|
|
288
|
+
* harness had nothing to interrupt), and still ends `cancelled`: the turn
|
|
289
|
+
* keeps the cancel, and its harness begins it stopped.
|
|
287
290
|
*/
|
|
288
291
|
async cancel(harness, sessionId) {
|
|
289
|
-
//
|
|
290
|
-
// the agent-level abort.
|
|
292
|
+
// The turn keeps the cancel (its signal), and any harness parked on an
|
|
293
|
+
// approval is unblocked, before (and regardless of) the agent-level abort.
|
|
291
294
|
for (const turn of this.turnsOf(sessionId))
|
|
292
295
|
void turn.requestCancel();
|
|
293
296
|
return await this.registry.getAgent(harness).cancel(sessionId);
|
|
@@ -53,7 +53,6 @@ export class Turn {
|
|
|
53
53
|
request;
|
|
54
54
|
inputKey;
|
|
55
55
|
sink;
|
|
56
|
-
signal;
|
|
57
56
|
host;
|
|
58
57
|
sessionId;
|
|
59
58
|
turnId;
|
|
@@ -70,8 +69,14 @@ export class Turn {
|
|
|
70
69
|
processor;
|
|
71
70
|
/** Its durable sink failed: the turn stops, and every later write fails with it. */
|
|
72
71
|
sinkFailure;
|
|
73
|
-
/**
|
|
74
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Aborted when `cancel` or `closeSession` asks the turn to stop: part of
|
|
74
|
+
* the signal its harness is given, so a cancel that comes before the
|
|
75
|
+
* harness has the turn is not lost.
|
|
76
|
+
*/
|
|
77
|
+
cancelled = new AbortController();
|
|
78
|
+
/** The caller's signal, the runtime's shutdown and the turn's own cancel, together. */
|
|
79
|
+
signal;
|
|
75
80
|
nativeSessionId;
|
|
76
81
|
/** When the turn requested a resume: whether the harness honored it. */
|
|
77
82
|
resumed;
|
|
@@ -85,9 +90,9 @@ export class Turn {
|
|
|
85
90
|
this.request = request;
|
|
86
91
|
this.inputKey = inputKey;
|
|
87
92
|
this.sink = sink;
|
|
88
|
-
this.signal = signal;
|
|
89
93
|
this.host = host;
|
|
90
94
|
const { sessionId, turnId, config } = request;
|
|
95
|
+
this.signal = AbortSignal.any([signal, this.cancelled.signal]);
|
|
91
96
|
this.sessionId = sessionId;
|
|
92
97
|
this.turnId = turnId;
|
|
93
98
|
this.harness = config.harness;
|
|
@@ -106,14 +111,19 @@ export class Turn {
|
|
|
106
111
|
});
|
|
107
112
|
this.running = Promise.resolve().then(() => this.execute());
|
|
108
113
|
}
|
|
114
|
+
// @ref LLP 0001#d9--the-wire-is-quick-ack-json-rpc-requests-flow-one-way — a cancel before the harness has the turn
|
|
109
115
|
/**
|
|
110
|
-
* A cancel was asked for:
|
|
111
|
-
*
|
|
112
|
-
*
|
|
116
|
+
* A cancel was asked for: the turn's signal is aborted, so a harness that
|
|
117
|
+
* has not begun the turn yet begins it stopped; its open requests are
|
|
118
|
+
* answered as cancelled; and what the harness throws from now on is it
|
|
119
|
+
* stopping. Resolves once their `*.resolved` are written.
|
|
113
120
|
*/
|
|
114
121
|
requestCancel() {
|
|
115
|
-
|
|
116
|
-
|
|
122
|
+
// Taken before the abort, which settles each request bound to the turn's
|
|
123
|
+
// signal and takes it out of the broker: the cancel would not wait for it.
|
|
124
|
+
const answered = this.requests.cancelAll();
|
|
125
|
+
this.cancelled.abort();
|
|
126
|
+
return answered;
|
|
117
127
|
}
|
|
118
128
|
async execute() {
|
|
119
129
|
const { sessionId, turnId, input, config } = this.request;
|
|
@@ -176,7 +186,7 @@ export class Turn {
|
|
|
176
186
|
throw this.sinkFailure;
|
|
177
187
|
// A harness asked to stop throws as it stops, whatever its words say;
|
|
178
188
|
// one that was not is failing.
|
|
179
|
-
threw = this.
|
|
189
|
+
threw = this.signal.aborted ? "cancelled" : errorInfo(error);
|
|
180
190
|
if (threw !== "cancelled") {
|
|
181
191
|
await this.emit({
|
|
182
192
|
type: "error",
|
package/dist/protocol/config.js
CHANGED
|
@@ -19,7 +19,7 @@ export const PermissionModeSchema = z.enum([
|
|
|
19
19
|
"bypass_permissions",
|
|
20
20
|
]);
|
|
21
21
|
export const ReportedPermissionModeSchema = openVocabulary(PermissionModeSchema.options);
|
|
22
|
-
/** The longest `requestTimeoutMs`: a timer's own limit, about 24.8 days. */
|
|
22
|
+
/** The longest `requestTimeoutMs` and the longest MCP `timeoutMs`: a timer's own limit, about 24.8 days. */
|
|
23
23
|
export const MAX_REQUEST_TIMEOUT_MS = 2_147_483_647;
|
|
24
24
|
/**
|
|
25
25
|
* Whether a turn needs the server (default `true`). A turn fails before the
|
|
@@ -29,6 +29,23 @@ export const MAX_REQUEST_TIMEOUT_MS = 2_147_483_647;
|
|
|
29
29
|
* agent connects its servers itself and decides.
|
|
30
30
|
*/
|
|
31
31
|
const required = z.boolean().optional();
|
|
32
|
+
/**
|
|
33
|
+
* How long one call to one of the server's tools may run, in milliseconds,
|
|
34
|
+
* on any transport: past it the call fails, and the model is told it timed out.
|
|
35
|
+
* - Claude: the server's `timeout`. A value under 1000 is ignored, as if unset.
|
|
36
|
+
* Unset, a call to an HTTP or SSE server is cut at 60 s unless
|
|
37
|
+
* `MCP_TOOL_TIMEOUT` (ms) is in the turn's or the engine's environment; a
|
|
38
|
+
* call to a stdio server is not cut at 60 s (one ran 70 s), and Claude's
|
|
39
|
+
* own longer limits still apply.
|
|
40
|
+
* - Codex: the server's `tool_timeout_sec`, in whole seconds rounded up
|
|
41
|
+
* (1118 cuts a call at 2 s), as Codex reads a fraction back changed.
|
|
42
|
+
* Unset, a call is cut at 300 s.
|
|
43
|
+
* - An ACP agent is not given it (ACP v1 has no such field): the agent keeps
|
|
44
|
+
* its own limit, if it has one.
|
|
45
|
+
* At most `MAX_REQUEST_TIMEOUT_MS`, a timer's own limit; a larger value is refused.
|
|
46
|
+
* A changed value applies from the next turn of a warm session.
|
|
47
|
+
*/
|
|
48
|
+
const timeoutMs = z.number().int().positive().max(MAX_REQUEST_TIMEOUT_MS).optional();
|
|
32
49
|
/** Minimal external MCP server descriptor (stdio or http/sse). */
|
|
33
50
|
export const McpServerConfigSchema = z.discriminatedUnion("type", [
|
|
34
51
|
z.object({
|
|
@@ -37,18 +54,21 @@ export const McpServerConfigSchema = z.discriminatedUnion("type", [
|
|
|
37
54
|
args: z.array(z.string()).optional(),
|
|
38
55
|
env: z.record(z.string(), z.string()).optional(),
|
|
39
56
|
required,
|
|
57
|
+
timeoutMs,
|
|
40
58
|
}),
|
|
41
59
|
z.object({
|
|
42
60
|
type: z.literal("http"),
|
|
43
61
|
url: z.string(),
|
|
44
62
|
headers: z.record(z.string(), z.string()).optional(),
|
|
45
63
|
required,
|
|
64
|
+
timeoutMs,
|
|
46
65
|
}),
|
|
47
66
|
z.object({
|
|
48
67
|
type: z.literal("sse"),
|
|
49
68
|
url: z.string(),
|
|
50
69
|
headers: z.record(z.string(), z.string()).optional(),
|
|
51
70
|
required,
|
|
71
|
+
timeoutMs,
|
|
52
72
|
}),
|
|
53
73
|
]);
|
|
54
74
|
/** Everything needed to configure a turn against a harness. */
|
|
@@ -46,8 +46,9 @@ const RUNS_ON = {
|
|
|
46
46
|
"claude-code": ClaudeCredentialSchema,
|
|
47
47
|
"codex-app-server": CodexCredentialSchema,
|
|
48
48
|
};
|
|
49
|
-
/** The credential as the kind `harness` runs on, or why that harness cannot run it. */
|
|
50
49
|
export function credentialRunsOn(harness, credential) {
|
|
50
|
+
if (!Object.hasOwn(RUNS_ON, harness))
|
|
51
|
+
return { ok: false, error: `${harness} runs on no credential a product holds.` };
|
|
51
52
|
const parsed = RUNS_ON[harness].safeParse(credential);
|
|
52
53
|
if (parsed.success)
|
|
53
54
|
return { ok: true, credential: parsed.data };
|
package/dist/protocol/errors.js
CHANGED
|
@@ -8,7 +8,9 @@ import { openVocabulary } from "./vocabulary.js";
|
|
|
8
8
|
* unknown non-`_` values are reserved for this protocol.
|
|
9
9
|
* `usage_limit` (plan/quota exhausted) and `rate_limit` (429/backoff) are
|
|
10
10
|
* deliberately distinct — they need different user guidance; collapsing them
|
|
11
|
-
* is a display choice, never a wire merge.
|
|
11
|
+
* is a display choice, never a wire merge. So are `resume_failed` (the
|
|
12
|
+
* conversation is gone: offer a fresh start) and `resume_busy` (another
|
|
13
|
+
* process holds it now: try again once that one has let it go).
|
|
12
14
|
*/
|
|
13
15
|
export const ERROR_CATEGORIES = [
|
|
14
16
|
"auth",
|
|
@@ -21,6 +23,7 @@ export const ERROR_CATEGORIES = [
|
|
|
21
23
|
"invalid_request",
|
|
22
24
|
"process_exit",
|
|
23
25
|
"resume_failed",
|
|
26
|
+
"resume_busy",
|
|
24
27
|
"mcp_unavailable",
|
|
25
28
|
"server_restart",
|
|
26
29
|
"internal",
|
|
@@ -42,6 +45,8 @@ export const ErrorInfoSchema = z.object({
|
|
|
42
45
|
* classifier; lives in /protocol because categories are vocabulary.
|
|
43
46
|
*/
|
|
44
47
|
const RULES = [
|
|
48
|
+
// Codex 0.160 and newer: another app-server holds the thread warm.
|
|
49
|
+
["resume_busy", ["already has an active writer"]],
|
|
45
50
|
["resume_failed", ["no conversation found with session id", "no rollout found for thread id"]],
|
|
46
51
|
["abort", ["aborted", "aborterror", "cancelled", "canceled", "interrupted", "sigint"]],
|
|
47
52
|
[
|
|
@@ -133,14 +138,18 @@ export function classifyError(error) {
|
|
|
133
138
|
}
|
|
134
139
|
return "internal";
|
|
135
140
|
}
|
|
136
|
-
/**
|
|
141
|
+
/**
|
|
142
|
+
* A status code counts where it stands as a number of its own, never inside
|
|
143
|
+
* a longer number ("240129 tokens") or an identifier's alphanumeric run (a
|
|
144
|
+
* thread id's "-b401-" or "-a429-"): no letter or digit touches it.
|
|
145
|
+
*/
|
|
137
146
|
function mentions(message, needle) {
|
|
138
147
|
if (!/\d$/.test(needle))
|
|
139
148
|
return message.includes(needle);
|
|
140
149
|
for (let at = message.indexOf(needle); at >= 0; at = message.indexOf(needle, at + 1)) {
|
|
141
150
|
const before = message[at - 1] ?? "";
|
|
142
151
|
const after = message[at + needle.length] ?? "";
|
|
143
|
-
if (
|
|
152
|
+
if (!/[a-z0-9]/.test(before) && !/[a-z0-9]/.test(after))
|
|
144
153
|
return true;
|
|
145
154
|
}
|
|
146
155
|
return false;
|