@alpacakit/agents 0.1.0-beta.39 → 0.2.0-beta.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/README.md +142 -1
- package/dist/agents/builtin.d.ts +2 -2
- package/dist/agents/builtin.d.ts.map +1 -1
- package/dist/agents/builtin.js +6 -4
- package/dist/agents/claude/cli.d.ts +133 -0
- package/dist/agents/claude/cli.d.ts.map +1 -0
- package/dist/agents/claude/cli.js +182 -0
- package/dist/agents/claude/host.d.ts +14 -0
- package/dist/agents/claude/host.d.ts.map +1 -0
- package/dist/agents/claude/host.js +319 -0
- package/dist/agents/{claude.d.ts → claude/index.d.ts} +11 -11
- package/dist/agents/claude/index.d.ts.map +1 -0
- package/dist/agents/claude/index.js +134 -0
- package/dist/agents/claude/session.d.ts +25 -0
- package/dist/agents/claude/session.d.ts.map +1 -0
- package/dist/agents/claude/session.js +321 -0
- package/dist/agents/codex/cli.d.ts +132 -0
- package/dist/agents/codex/cli.d.ts.map +1 -0
- package/dist/agents/codex/cli.js +110 -0
- package/dist/agents/codex/host.d.ts +14 -0
- package/dist/agents/codex/host.d.ts.map +1 -0
- package/dist/agents/codex/host.js +221 -0
- package/dist/agents/codex/index.d.ts +14 -0
- package/dist/agents/codex/index.d.ts.map +1 -0
- package/dist/agents/codex/index.js +127 -0
- package/dist/agents/codex/session.d.ts +21 -0
- package/dist/agents/codex/session.d.ts.map +1 -0
- package/dist/agents/codex/session.js +390 -0
- package/dist/agents/openai-compatible/fetch-engine.d.ts.map +1 -1
- package/dist/agents/openai-compatible/fetch-engine.js +3 -2
- package/dist/agents/openai-compatible/pi/engine.js +1 -1
- package/dist/agents/openai-compatible/pi/{session.d.ts → run.d.ts} +1 -1
- package/dist/agents/openai-compatible/pi/run.d.ts.map +1 -0
- package/dist/agents/openai-compatible/pi/sandbox.d.ts.map +1 -1
- package/dist/auth/login-probe.d.ts +6 -4
- package/dist/auth/login-probe.d.ts.map +1 -1
- package/dist/auth/login-probe.js +19 -13
- package/dist/auth/material.d.ts +1 -1
- package/dist/auth/material.d.ts.map +1 -1
- package/dist/codex/app-server.d.ts +50 -1
- package/dist/codex/app-server.d.ts.map +1 -1
- package/dist/codex/app-server.js +140 -66
- package/dist/codex/index.d.ts +3 -2
- package/dist/codex/index.d.ts.map +1 -1
- package/dist/codex/index.js +2 -1
- package/dist/codex/protocol.d.ts +101 -0
- package/dist/codex/protocol.d.ts.map +1 -1
- package/dist/codex/protocol.js +78 -0
- package/dist/config/agent-config-validation.d.ts +1 -1
- package/dist/config/agent-config-validation.d.ts.map +1 -1
- package/dist/config/agent-configs.d.ts.map +1 -1
- package/dist/config/agent-configs.js +3 -3
- package/dist/config/compose.d.ts.map +1 -1
- package/dist/config/config.d.ts +1 -1
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +1 -1
- package/dist/config/model.d.ts +0 -1
- package/dist/config/model.d.ts.map +1 -1
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +1 -1
- package/dist/config/store.d.ts.map +1 -1
- package/dist/config/store.js +6 -24
- package/dist/config/support.d.ts +0 -1
- package/dist/config/support.d.ts.map +1 -1
- package/dist/config/support.js +0 -9
- package/dist/core/cli-child.d.ts +56 -0
- package/dist/core/cli-child.d.ts.map +1 -0
- package/dist/core/cli-child.js +105 -0
- package/dist/core/fs.d.ts +1 -1
- package/dist/core/fs.d.ts.map +1 -1
- package/dist/core/fs.js +10 -2
- package/dist/core/node-ports.d.ts.map +1 -1
- package/dist/core/node-ports.js +1 -5
- package/dist/core/session.d.ts +104 -0
- package/dist/core/session.d.ts.map +1 -0
- package/dist/core/session.js +29 -0
- package/dist/fleet/store.d.ts.map +1 -1
- package/dist/fleet/store.js +4 -3
- package/dist/host/availability.d.ts +2 -1
- package/dist/host/availability.d.ts.map +1 -1
- package/dist/host/github-dir.d.ts.map +1 -1
- package/dist/host/github-dir.js +2 -1
- package/dist/host/mcp-list.d.ts.map +1 -1
- package/dist/host/mcp-list.js +5 -6
- package/dist/host/run-command.d.ts +2 -1
- package/dist/host/run-command.d.ts.map +1 -1
- package/dist/host/run-command.js +10 -19
- package/dist/host/session-files.d.ts +23 -0
- package/dist/host/session-files.d.ts.map +1 -0
- package/dist/host/session-files.js +92 -0
- package/dist/index.d.ts +9 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/internal/controlled-process/supervisor-runtime.js +27 -1
- package/dist/kernel/classify.d.ts +1 -2
- package/dist/kernel/classify.d.ts.map +1 -1
- package/dist/kernel/classify.js +1 -1
- package/dist/kernel/cli-agent.d.ts.map +1 -1
- package/dist/kernel/cli-agent.js +26 -85
- package/dist/kernel/cli-login.d.ts.map +1 -1
- package/dist/kernel/cli-login.js +9 -30
- package/dist/kernel/definition.d.ts +11 -2
- package/dist/kernel/definition.d.ts.map +1 -1
- package/dist/kernel/facets.d.ts +38 -1
- package/dist/kernel/facets.d.ts.map +1 -1
- package/dist/kernel/facets.js +20 -0
- package/dist/kernel/login.d.ts.map +1 -1
- package/dist/kernel/login.js +2 -1
- package/dist/kernel/options.d.ts +1 -1
- package/dist/kernel/options.d.ts.map +1 -1
- package/dist/kernel/run.d.ts.map +1 -1
- package/dist/kernel/run.js +2 -1
- package/dist/kernel/runtime.d.ts +10 -6
- package/dist/kernel/runtime.d.ts.map +1 -1
- package/dist/kernel/runtime.js +4 -1
- package/dist/kernel/session.d.ts +104 -0
- package/dist/kernel/session.d.ts.map +1 -0
- package/dist/kernel/session.js +314 -0
- package/dist/testing/fake-exec.d.ts +10 -5
- package/dist/testing/fake-exec.d.ts.map +1 -1
- package/dist/testing/fake-exec.js +17 -2
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +1 -1
- package/package.json +2 -2
- package/dist/agents/claude.d.ts.map +0 -1
- package/dist/agents/claude.js +0 -543
- package/dist/agents/codex.d.ts +0 -19
- package/dist/agents/codex.d.ts.map +0 -1
- package/dist/agents/codex.js +0 -377
- package/dist/agents/openai-compatible/pi/session.d.ts.map +0 -1
- /package/dist/agents/openai-compatible/pi/{session.js → run.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-dir.d.ts","sourceRoot":"","sources":["../../src/host/github-dir.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"github-dir.d.ts","sourceRoot":"","sources":["../../src/host/github-dir.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAYH,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,MAAM,eAAe,GAAG,OAAO,CACnC,WAAW,EACX;IAAE,IAAI,EAAE,OAAO,iBAAiB,CAAC,SAAS,CAAA;CAAE,CAC7C,CAAC;AA+KF,qEAAqE;AACrE,wBAAsB,yBAAyB,CAAC,CAAC,EAC/C,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,eAAe,EACvB,GAAG,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GACrC,OAAO,CAAC,CAAC,CAAC,CAWZ"}
|
package/dist/host/github-dir.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
10
10
|
import os from "node:os";
|
|
11
11
|
import path from "node:path";
|
|
12
|
+
import { NO_FAILURE_EVIDENCE } from "../core/cli-child.js";
|
|
12
13
|
import { AGENT_ERROR_CODE, AgentError } from "../core/error.js";
|
|
13
14
|
import { readString, readUnknownRecord, } from "../core/json.js";
|
|
14
15
|
const GITHUB_CONTENTS_API = "https://api.github.com/repos";
|
|
@@ -115,7 +116,7 @@ async function writeGithubFile(ctx, entry, targetPath) {
|
|
|
115
116
|
code: AGENT_ERROR_CODE.failed,
|
|
116
117
|
classification: AgentError.agentFailure(AGENT_ERROR_CODE.failed),
|
|
117
118
|
message: "GitHub skill file is missing download_url",
|
|
118
|
-
data:
|
|
119
|
+
data: NO_FAILURE_EVIDENCE,
|
|
119
120
|
});
|
|
120
121
|
}
|
|
121
122
|
content = await fetchBytes(ctx, downloadUrl);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-list.d.ts","sourceRoot":"","sources":["../../src/host/mcp-list.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp-list.d.ts","sourceRoot":"","sources":["../../src/host/mcp-list.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAwGhD,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GACzB,OAAO,CAAC,cAAc,EAAE,CAAC,CAuB3B"}
|
package/dist/host/mcp-list.js
CHANGED
|
@@ -4,12 +4,11 @@
|
|
|
4
4
|
* claude/codex CLIs emit (array, `{servers: [...]}` or name-keyed maps),
|
|
5
5
|
* but non-JSON output is a typed failure, never a raw `SyntaxError`.
|
|
6
6
|
*/
|
|
7
|
+
import { failureEvidence } from "../core/cli-child.js";
|
|
7
8
|
import { AGENT_ERROR_CODE, AgentError } from "../core/error.js";
|
|
8
9
|
import { readString, readUnknownRecord, } from "../core/json.js";
|
|
9
|
-
import { redactSecrets } from "../core/redact.js";
|
|
10
10
|
import { MCP_TRANSPORT } from "./capabilities.js";
|
|
11
11
|
import { runHostCommand } from "./run-command.js";
|
|
12
|
-
const OUTPUT_TAIL_CHARS = 2_000;
|
|
13
12
|
const MCP_LIST_ARGS = ["mcp", "list", "--json"];
|
|
14
13
|
const MCP_LIST_FIELD = {
|
|
15
14
|
name: "name",
|
|
@@ -111,11 +110,11 @@ export async function listMcpServersViaCli(ctx, input) {
|
|
|
111
110
|
code: AGENT_ERROR_CODE.failed,
|
|
112
111
|
classification: AgentError.agentFailure(AGENT_ERROR_CODE.failed),
|
|
113
112
|
message: "MCP server list output is not valid JSON",
|
|
114
|
-
data: {
|
|
113
|
+
data: failureEvidence({
|
|
114
|
+
stdout: result.stdout,
|
|
115
|
+
stderr: result.stderr,
|
|
115
116
|
exitCode: result.exit.code,
|
|
116
|
-
|
|
117
|
-
stderrTail: result.stderr.slice(-OUTPUT_TAIL_CHARS) || null,
|
|
118
|
-
},
|
|
117
|
+
}),
|
|
119
118
|
cause: error,
|
|
120
119
|
});
|
|
121
120
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { AGENT_ERROR_CODE, AgentError } from "../core/error.js";
|
|
8
8
|
import type { HostContext } from "./context.js";
|
|
9
|
-
|
|
9
|
+
type HostCommandResult = {
|
|
10
10
|
stdout: string;
|
|
11
11
|
stderr: string;
|
|
12
12
|
exit: {
|
|
@@ -24,4 +24,5 @@ export declare function runHostCommand(ctx: HostContext, input: {
|
|
|
24
24
|
command: string;
|
|
25
25
|
args: readonly string[];
|
|
26
26
|
}): Promise<HostCommandResult>;
|
|
27
|
+
export {};
|
|
27
28
|
//# sourceMappingURL=run-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-command.d.ts","sourceRoot":"","sources":["../../src/host/run-command.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"run-command.d.ts","sourceRoot":"","sources":["../../src/host/run-command.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGhE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,KAAK,iBAAiB,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;CACtD,CAAC;AAEF,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAClD,OAAO,CAAC,iBAAiB,CAAC,CA2B5B;AAED,iEAAiE;AACjE,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,iBAAiB,GACxB,UAAU,CAAC,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAW5C;AAED,wBAAsB,cAAc,CAClC,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAClD,OAAO,CAAC,iBAAiB,CAAC,CAM5B"}
|
package/dist/host/run-command.js
CHANGED
|
@@ -4,20 +4,12 @@
|
|
|
4
4
|
* stderr capture, redaction, and the typed failure boundary — adapters
|
|
5
5
|
* only choose the command and argv.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { failureEvidence, resolveCommand } from "../core/cli-child.js";
|
|
8
|
+
import { AGENT_ERROR_CODE, AgentError } from "../core/error.js";
|
|
8
9
|
import { redactSecrets } from "../core/redact.js";
|
|
9
10
|
import { OUTPUT_CHANNEL } from "../core/values.js";
|
|
10
|
-
const OUTPUT_TAIL_CHARS = 2_000;
|
|
11
11
|
export async function runHostCommandResult(ctx, input) {
|
|
12
|
-
const command = await ctx.exec
|
|
13
|
-
if (command === null) {
|
|
14
|
-
throw new AgentError({
|
|
15
|
-
code: AGENT_ERROR_CODE.notAvailable,
|
|
16
|
-
classification: AgentError.agentFailure(AGENT_ERROR_CODE.notAvailable),
|
|
17
|
-
message: `Command "${input.command}" was not found on PATH`,
|
|
18
|
-
data: { cause: NOT_AVAILABLE_CAUSE.notInstalled },
|
|
19
|
-
});
|
|
20
|
-
}
|
|
12
|
+
const command = await resolveCommand(ctx.exec, input.command, ctx.env, null);
|
|
21
13
|
const process = ctx.exec.spawn({
|
|
22
14
|
command,
|
|
23
15
|
args: [...input.args],
|
|
@@ -38,25 +30,24 @@ export async function runHostCommandResult(ctx, input) {
|
|
|
38
30
|
const exit = await process.exit;
|
|
39
31
|
return {
|
|
40
32
|
stdout,
|
|
33
|
+
// stderr is handed to callers (plugin "already installed" detection),
|
|
34
|
+
// so it is redacted here at capture; stdout stays raw for parsers and
|
|
35
|
+
// is redacted only when it enters an error via `failureEvidence`.
|
|
41
36
|
stderr: redactSecrets(stderr),
|
|
42
37
|
exit,
|
|
43
38
|
};
|
|
44
39
|
}
|
|
45
40
|
/** The one way a non-zero host command becomes a typed error. */
|
|
46
41
|
export function hostCommandFailedError(command, result) {
|
|
47
|
-
// stdout is kept raw for parsing callers, so redact it here at the
|
|
48
|
-
// one place it can enter an error; stderr is redacted at capture.
|
|
49
|
-
const stdoutTail = redactSecrets(result.stdout.slice(-OUTPUT_TAIL_CHARS));
|
|
50
|
-
const stderrTail = result.stderr.slice(-OUTPUT_TAIL_CHARS);
|
|
51
42
|
return new AgentError({
|
|
52
43
|
code: AGENT_ERROR_CODE.failed,
|
|
53
44
|
classification: AgentError.agentFailure(AGENT_ERROR_CODE.failed),
|
|
54
45
|
message: `Host command "${command}" failed with exit code ${result.exit.code ?? "null"}`,
|
|
55
|
-
data: {
|
|
46
|
+
data: failureEvidence({
|
|
47
|
+
stdout: result.stdout,
|
|
48
|
+
stderr: result.stderr,
|
|
56
49
|
exitCode: result.exit.code,
|
|
57
|
-
|
|
58
|
-
stderrTail: stderrTail || null,
|
|
59
|
-
},
|
|
50
|
+
}),
|
|
60
51
|
});
|
|
61
52
|
}
|
|
62
53
|
export async function runHostCommand(ctx, input) {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-only helpers over the files a host writes about its conversations
|
|
3
|
+
* (Claude transcripts and session registry, Codex rollouts and writer
|
|
4
|
+
* locks). Nothing here decides paths: callers build them from
|
|
5
|
+
* `HostContext.location.homeDir`, never from `os.homedir()`.
|
|
6
|
+
*/
|
|
7
|
+
import { type UnknownRecord } from "../core/json.js";
|
|
8
|
+
type FirstAndLast<T> = {
|
|
9
|
+
first: T | null;
|
|
10
|
+
last: T | null;
|
|
11
|
+
};
|
|
12
|
+
/** Directory entry names; a missing directory reads as empty, anything else surfaces. */
|
|
13
|
+
export declare function readDirectoryNames(directory: string): Promise<string[]>;
|
|
14
|
+
export declare function fileExists(target: string): Promise<boolean>;
|
|
15
|
+
/** Parse one JSON file; `null` when it is absent or not a JSON object. */
|
|
16
|
+
export declare function readJsonFile(target: string): Promise<UnknownRecord | null>;
|
|
17
|
+
/**
|
|
18
|
+
* Stream a JSONL file once and keep the first and last non-null picks.
|
|
19
|
+
* Lines that are not JSON objects are skipped (hosts append other kinds).
|
|
20
|
+
*/
|
|
21
|
+
export declare function scanJsonlFirstLast<T>(file: string, pick: (record: UnknownRecord) => T | null): Promise<FirstAndLast<T>>;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=session-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-files.d.ts","sourceRoot":"","sources":["../../src/host/session-files.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,EAAkB,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrE,KAAK,YAAY,CAAC,CAAC,IAAI;IAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAA;CAAE,CAAC;AAY3D,yFAAyF;AACzF,wBAAsB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAS7E;AAED,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAUjE;AAED,0EAA0E;AAC1E,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAW/B;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EACxC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,CAAC,GAAG,IAAI,GACxC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAwB1B"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-only helpers over the files a host writes about its conversations
|
|
3
|
+
* (Claude transcripts and session registry, Codex rollouts and writer
|
|
4
|
+
* locks). Nothing here decides paths: callers build them from
|
|
5
|
+
* `HostContext.location.homeDir`, never from `os.homedir()`.
|
|
6
|
+
*/
|
|
7
|
+
import { createReadStream } from "node:fs";
|
|
8
|
+
import { access, readdir, readFile } from "node:fs/promises";
|
|
9
|
+
import { createInterface } from "node:readline";
|
|
10
|
+
import { NO_FAILURE_EVIDENCE } from "../core/cli-child.js";
|
|
11
|
+
import { AGENT_ERROR_CODE, AgentError } from "../core/error.js";
|
|
12
|
+
import { isErrnoCode } from "../core/fs.js";
|
|
13
|
+
import { readJsonRecord } from "../core/json.js";
|
|
14
|
+
import { TEXT_ENCODING } from "../core/values.js";
|
|
15
|
+
function hostFileReadError(target, cause) {
|
|
16
|
+
return new AgentError({
|
|
17
|
+
code: AGENT_ERROR_CODE.failed,
|
|
18
|
+
classification: AgentError.agentFailure(AGENT_ERROR_CODE.failed),
|
|
19
|
+
message: `Could not read host session file: ${target}`,
|
|
20
|
+
data: NO_FAILURE_EVIDENCE,
|
|
21
|
+
cause,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/** Directory entry names; a missing directory reads as empty, anything else surfaces. */
|
|
25
|
+
export async function readDirectoryNames(directory) {
|
|
26
|
+
try {
|
|
27
|
+
return await readdir(directory);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if (isErrnoCode(error, "ENOENT") || isErrnoCode(error, "ENOTDIR")) {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
throw hostFileReadError(directory, error);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export async function fileExists(target) {
|
|
37
|
+
try {
|
|
38
|
+
await access(target);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
if (isErrnoCode(error, "ENOENT") || isErrnoCode(error, "ENOTDIR")) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
throw hostFileReadError(target, error);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Parse one JSON file; `null` when it is absent or not a JSON object. */
|
|
49
|
+
export async function readJsonFile(target) {
|
|
50
|
+
let text;
|
|
51
|
+
try {
|
|
52
|
+
text = await readFile(target, TEXT_ENCODING);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
if (isErrnoCode(error, "ENOENT") || isErrnoCode(error, "ENOTDIR")) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
throw hostFileReadError(target, error);
|
|
59
|
+
}
|
|
60
|
+
return readJsonRecord(text.trim());
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Stream a JSONL file once and keep the first and last non-null picks.
|
|
64
|
+
* Lines that are not JSON objects are skipped (hosts append other kinds).
|
|
65
|
+
*/
|
|
66
|
+
export async function scanJsonlFirstLast(file, pick) {
|
|
67
|
+
const result = { first: null, last: null };
|
|
68
|
+
const stream = createReadStream(file, { encoding: TEXT_ENCODING });
|
|
69
|
+
const lines = createInterface({ input: stream, crlfDelay: Infinity });
|
|
70
|
+
try {
|
|
71
|
+
for await (const line of lines) {
|
|
72
|
+
const record = readJsonRecord(line.trim());
|
|
73
|
+
if (record === null) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const picked = pick(record);
|
|
77
|
+
if (picked === null) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
result.first ??= picked;
|
|
81
|
+
result.last = picked;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
throw hostFileReadError(file, error);
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
lines.close();
|
|
89
|
+
stream.destroy();
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,8 +8,10 @@
|
|
|
8
8
|
* is not here at all: it belongs to `@alpacakit/core/keyring`.
|
|
9
9
|
*/
|
|
10
10
|
export { BUILTIN_AGENT_ID, type BuiltinAgentId, builtinAgentFactories, } from "./agents/builtin.js";
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
11
|
+
export { CLAUDE_PERMISSION_MODE, type ClaudePermissionMode, type ClaudeSessionPermissions, } from "./agents/claude/cli.js";
|
|
12
|
+
export { type ClaudeOptions, claude, structuredQuotaMatcher, } from "./agents/claude/index.js";
|
|
13
|
+
export { CODEX_APPROVAL_POLICY, CODEX_APPROVALS_REVIEWER, type CodexApprovalPolicy, type CodexApprovalsReviewer, type CodexSandboxMode, type CodexSandboxPolicy, type CodexSessionPermissions, } from "./agents/codex/cli.js";
|
|
14
|
+
export { capacityTextMatcher, codex } from "./agents/codex/index.js";
|
|
13
15
|
export type { PiSessionEngineOptions } from "./agents/openai-compatible/pi/engine.js";
|
|
14
16
|
export { PI_DEFAULT_CONTEXT_WINDOW, PI_DEFAULT_MAX_TOKENS, piSessionEngine, } from "./agents/openai-compatible/pi/engine.js";
|
|
15
17
|
export type { JsonValue, OpenAiCompatibleConfig, OpenAiCompatibleConfigInput, OpenAiCompatibleEngine, } from "./agents/openai-compatible.js";
|
|
@@ -31,6 +33,8 @@ export { LOG_LEVEL } from "./core/ports.js";
|
|
|
31
33
|
export { redactJsonSecrets, redactSecrets } from "./core/redact.js";
|
|
32
34
|
export type { AgentEvent, AgentRunOutcome, RunCompletion, RunEvent, RunExit, RunHandle, RunResult, RunTelemetry, RunTiming, RunUsage, } from "./core/run.js";
|
|
33
35
|
export { AGENT_EVENT_TYPE, RUN_COMPLETION_KIND, RUN_EVENT_TYPE, RUN_OUTCOME, } from "./core/run.js";
|
|
36
|
+
export type { ApprovalDecision, Session, SessionEvent, SessionFacts, SessionOwner, TurnOutcome, TurnResult, } from "./core/session.js";
|
|
37
|
+
export { APPROVAL_DECISION, SESSION_EVENT_TYPE, SESSION_OWNER_KIND, TURN_OUTCOME, } from "./core/session.js";
|
|
34
38
|
export type { OutputChannel, ProcessSignal } from "./core/values.js";
|
|
35
39
|
export { OUTPUT_CHANNEL, PROCESS_SIGNAL } from "./core/values.js";
|
|
36
40
|
export type { FailureCorpusRecorder, FailureCorpusRecorderOptions, } from "./corpus/failure-corpus.js";
|
|
@@ -53,17 +57,18 @@ export type { ClassifiedFailure, FailureEvidence, FailureMatcher, } from "./kern
|
|
|
53
57
|
export { authIf, capacityIf, classifyFailure, parseCooldownHint, quotaIf, sharedFailureMatchers, } from "./kernel/classify.js";
|
|
54
58
|
export type { ArgContext, CliAgentBlueprint, CliResultCapture, OutputState, SandboxArgBuilders, } from "./kernel/cli-agent.js";
|
|
55
59
|
export { defineCliAgent } from "./kernel/cli-agent.js";
|
|
56
|
-
export type { AgentDefinition, AgentRun, RunContext, } from "./kernel/definition.js";
|
|
60
|
+
export type { AgentDefinition, AgentRun, RunContext, SessionPermissionsOf, } from "./kernel/definition.js";
|
|
57
61
|
export { defineAgent } from "./kernel/definition.js";
|
|
58
62
|
export type { EnvTemplate, EnvTemplateResolution, } from "./kernel/env-template.js";
|
|
59
63
|
export { referencedEnvNames, resolveEnvTemplate, } from "./kernel/env-template.js";
|
|
60
|
-
export type { AgentAuth, AgentAvailabilityProbe, AgentDoctor, AgentLogin, AgentMcp, AgentSkills, } from "./kernel/facets.js";
|
|
64
|
+
export type { AgentAuth, AgentAvailabilityProbe, AgentDoctor, AgentLogin, AgentMcp, AgentSessions, AgentSkills, SessionOpenOptions, SessionResumeOptions, } from "./kernel/facets.js";
|
|
61
65
|
export type { Guard, GuardContext, GuardFactory } from "./kernel/guard.js";
|
|
62
66
|
export { maxToolCalls, maxTurns, noProgress, repeatedOutput, } from "./kernel/guard.js";
|
|
63
67
|
export type { ControlledChildProcessResource, Grant, Limits, ResolvedLimits, ResolvedRunOptions, ResolvedRunResources, ResolvedSandbox, RunOptions, RunResources, Sandbox, SandboxMode, } from "./kernel/options.js";
|
|
64
68
|
export { GRANT_KIND, SANDBOX_MODE } from "./kernel/options.js";
|
|
65
69
|
export type { Agent, AgentRuntime, AgentRuntimeOptions, } from "./kernel/runtime.js";
|
|
66
70
|
export { createAgentRuntime, resolvePorts } from "./kernel/runtime.js";
|
|
71
|
+
export type { ResolvedSessionOpenOptions, ResolvedSessionResumeOptions, SessionCapability, SessionContext, } from "./kernel/session.js";
|
|
67
72
|
export { type RunAgentOptions, runAgent } from "./run-agent.js";
|
|
68
73
|
export type { ExtractionStrategy, JsonParseOutcome, Markers, } from "./structured/extract.js";
|
|
69
74
|
export { DEFAULT_MARKERS, defaultExtractionStrategies, extractBlock, parseJsonResilient, } from "./structured/extract.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,gBAAgB,EAChB,KAAK,cAAc,EACnB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,MAA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E,MAAM,qBAAqB,CAAC;AACvE,YAAY,EACV,0BAA0B,EAC1B,4BAA4B,EAC5B,iBAAiB,EACjB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,KAAK,eAAe,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEhE,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,OAAO,GACR,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,eAAe,EACf,2BAA2B,EAC3B,YAAY,EACZ,kBAAkB,GACnB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,uBAAuB,EACvB,cAAc,EACd,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,YAAY,EACV,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,iCAAiC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -8,8 +8,10 @@
|
|
|
8
8
|
* is not here at all: it belongs to `@alpacakit/core/keyring`.
|
|
9
9
|
*/
|
|
10
10
|
export { BUILTIN_AGENT_ID, builtinAgentFactories, } from "./agents/builtin.js";
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
11
|
+
export { CLAUDE_PERMISSION_MODE, } from "./agents/claude/cli.js";
|
|
12
|
+
export { claude, structuredQuotaMatcher, } from "./agents/claude/index.js";
|
|
13
|
+
export { CODEX_APPROVAL_POLICY, CODEX_APPROVALS_REVIEWER, } from "./agents/codex/cli.js";
|
|
14
|
+
export { capacityTextMatcher, codex } from "./agents/codex/index.js";
|
|
13
15
|
export { PI_DEFAULT_CONTEXT_WINDOW, PI_DEFAULT_MAX_TOKENS, piSessionEngine, } from "./agents/openai-compatible/pi/engine.js";
|
|
14
16
|
export { openaiCompatible } from "./agents/openai-compatible.js";
|
|
15
17
|
export { LOGIN_EVENT_TYPE, LOGIN_METHOD } from "./auth/login.js";
|
|
@@ -22,6 +24,7 @@ export { createControlledExec } from "./core/node-controlled-exec.js";
|
|
|
22
24
|
export { LOG_LEVEL } from "./core/ports.js";
|
|
23
25
|
export { redactJsonSecrets, redactSecrets } from "./core/redact.js";
|
|
24
26
|
export { AGENT_EVENT_TYPE, RUN_COMPLETION_KIND, RUN_EVENT_TYPE, RUN_OUTCOME, } from "./core/run.js";
|
|
27
|
+
export { APPROVAL_DECISION, SESSION_EVENT_TYPE, SESSION_OWNER_KIND, TURN_OUTCOME, } from "./core/session.js";
|
|
25
28
|
export { OUTPUT_CHANNEL, PROCESS_SIGNAL } from "./core/values.js";
|
|
26
29
|
export { createFailureCorpusRecorder } from "./corpus/failure-corpus.js";
|
|
27
30
|
export { ATTEMPT_STATUS, BLOCKER_REASON, candidateForAgent, candidateFromProfile, candidateKey, createFleet, FLEET_OUTCOME_STATUS, profileCooldownKey, } from "./fleet/fleet.js";
|
|
@@ -368,7 +368,28 @@ async function runSupervisorSession(input) {
|
|
|
368
368
|
await runCoordinatorOperation(async (current) => current.acknowledge());
|
|
369
369
|
coordinatorAckMayHaveCommitted = true;
|
|
370
370
|
await input.dependencies.writeShimAck(shimControl);
|
|
371
|
-
|
|
371
|
+
// The relay deadline is the supervisor's own decision: when it elapses
|
|
372
|
+
// before the shim has failed, it cuts the shim's input, and the early
|
|
373
|
+
// EOF the shim then reports is a consequence (seen on slow CI while the
|
|
374
|
+
// shim was still starting). Every other relay failure is itself a
|
|
375
|
+
// consequence of the shim side (a worker exit closes the pipe), so the
|
|
376
|
+
// shim's report keeps precedence there.
|
|
377
|
+
let firstFailure = null;
|
|
378
|
+
const [inputRelaySettlement, shimReadySettlement] = await Promise.allSettled([
|
|
379
|
+
inputRelay.catch((error) => {
|
|
380
|
+
firstFailure ??= "relay";
|
|
381
|
+
throw error;
|
|
382
|
+
}),
|
|
383
|
+
shimReady.catch((error) => {
|
|
384
|
+
firstFailure ??= "shim";
|
|
385
|
+
throw error;
|
|
386
|
+
}),
|
|
387
|
+
]);
|
|
388
|
+
if (inputRelaySettlement.status === "rejected" &&
|
|
389
|
+
firstFailure === "relay" &&
|
|
390
|
+
isInputTransferTimeout(inputRelaySettlement.reason)) {
|
|
391
|
+
throw inputRelaySettlement.reason;
|
|
392
|
+
}
|
|
372
393
|
if (shimReadySettlement.status === "rejected") {
|
|
373
394
|
throw shimReadySettlement.reason;
|
|
374
395
|
}
|
|
@@ -944,3 +965,8 @@ async function selfSigkill() {
|
|
|
944
965
|
function randomHex(bytes) {
|
|
945
966
|
return randomBytes(bytes).toString("hex");
|
|
946
967
|
}
|
|
968
|
+
function isInputTransferTimeout(error) {
|
|
969
|
+
return (error instanceof ControlledProcessLaunchError &&
|
|
970
|
+
error.failure.code ===
|
|
971
|
+
CONTROLLED_PROCESS_LAUNCH_FAILURE_CODE.inputTransferTimeout);
|
|
972
|
+
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* (v1 F3/F5 signals, kept verbatim). Provider-specific matchers live on
|
|
6
6
|
* their adapter modules and enter via the blueprints' `classify` arrays.
|
|
7
7
|
*/
|
|
8
|
-
import type { AgentErrorCode, AgentErrorData
|
|
8
|
+
import type { AgentErrorCode, AgentErrorData } from "../core/error.js";
|
|
9
9
|
export type FailureEvidence = {
|
|
10
10
|
stdout: string;
|
|
11
11
|
stderr: string;
|
|
@@ -32,7 +32,6 @@ export declare function parseCooldownHint(text: string, now: number): string | n
|
|
|
32
32
|
export declare function quotaIf(pattern: RegExp): FailureMatcher;
|
|
33
33
|
/** Matcher combinator: classify as capacity when the pattern matches. */
|
|
34
34
|
export declare function capacityIf(pattern: RegExp): FailureMatcher;
|
|
35
|
-
export declare function detectAuthReason(text: string): AuthFailureReason;
|
|
36
35
|
/** Matcher combinator: classify as auth when the pattern matches. */
|
|
37
36
|
export declare function authIf(pattern: RegExp): FailureMatcher;
|
|
38
37
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"classify.d.ts","sourceRoot":"","sources":["../../src/kernel/classify.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,cAAc,
|
|
1
|
+
{"version":3,"file":"classify.d.ts","sourceRoot":"","sources":["../../src/kernel/classify.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EAEf,MAAM,kBAAkB,CAAC;AAG1B,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,6DAA6D;IAC7D,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,IAAI;KACxE,CAAC,IAAI,CAAC,GAAG;QAAE,IAAI,EAAE,CAAC,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,CAAA;KAAE;CAChE,CAAC,CAAC,CAAC,CAAC;AAEL,MAAM,MAAM,cAAc,GAAG,CAC3B,QAAQ,EAAE,eAAe,KACtB,iBAAiB,GAAG,IAAI,CAAC;AAuB9B,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAoB1E;AAED,sEAAsE;AACtE,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,CAYvD;AAED,yEAAyE;AACzE,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,CAY1D;AA0BD,qEAAqE;AACrE,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,CAatD;AAQD;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,cAAc,EAG1D,CAAC;AAEF,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,SAAS,cAAc,EAAE,EACnC,QAAQ,EAAE,eAAe,GACxB,iBAAiB,GAAG,IAAI,CAQ1B"}
|
package/dist/kernel/classify.js
CHANGED
|
@@ -91,7 +91,7 @@ const AUTH_REASON_MARKERS = [
|
|
|
91
91
|
[/\bunauthorized\b/i, AUTH_FAILURE_REASON.unauthorized],
|
|
92
92
|
[/\bforbidden\b/i, AUTH_FAILURE_REASON.forbidden],
|
|
93
93
|
];
|
|
94
|
-
|
|
94
|
+
function detectAuthReason(text) {
|
|
95
95
|
for (const [pattern, reason] of AUTH_REASON_MARKERS) {
|
|
96
96
|
if (pattern.test(text)) {
|
|
97
97
|
return reason;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-agent.d.ts","sourceRoot":"","sources":["../../src/kernel/cli-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli-agent.d.ts","sourceRoot":"","sources":["../../src/kernel/cli-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AA2B5D,OAAO,KAAK,EACV,UAAU,EAGV,QAAQ,EACT,MAAM,gBAAgB,CAAC;AAOxB,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,gBAAgB,EAEtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EACjB,MAAM,yBA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S,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,UAAU,EAAE,CAAC;IAC7D,oEAAoE;IACpE,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,gBAAgB,GAAG,IAAI,CAAC;IACjE,yEAAyE;IACzE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC;IAC1E,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,kEAAkE;IAClE,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IAC9C;;;;OAIG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IACvD,QAAQ,CAAC,YAAY,CAAC,EAAE,2BAA2B,CAAC;IACpD,QAAQ,CAAC,yBAAyB,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC7D,QAAQ,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACjC,QAAQ,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CAAC,GAAG,CAAC,EAAE,aAAa,CAAC;CAC9B,CAAC;AA4nBF,wBAAgB,cAAc,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EACpD,SAAS,EAAE,iBAAiB,CAAC,EAAE,CAAC,GAC/B,eAAe,CAAC,EAAE,CAAC,CAsCrB"}
|
package/dist/kernel/cli-agent.js
CHANGED
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
* `codex` are built with this factory; a third-party adapter is the same
|
|
7
7
|
* ~20-line exercise.
|
|
8
8
|
*/
|
|
9
|
+
import { appendTail, escalateTermination, failureEvidence, LineBuffer, RAW_OUTPUT_CAP_CHARS, resolveCommand, } from "../core/cli-child.js";
|
|
9
10
|
import { CHILD_PROCESS_TERMINATION_KIND, } from "../core/controlled-process.js";
|
|
10
|
-
import { AGENT_ERROR_CODE, AGENT_INFRASTRUCTURE_FAILURE_CODE, AgentError, infrastructureFailure,
|
|
11
|
+
import { AGENT_ERROR_CODE, AGENT_INFRASTRUCTURE_FAILURE_CODE, AgentError, infrastructureFailure, } from "../core/error.js";
|
|
11
12
|
import { redactSecrets } from "../core/redact.js";
|
|
12
13
|
import { AGENT_EVENT_TYPE, RUN_COMPLETION_KIND } from "../core/run.js";
|
|
13
14
|
import { OUTPUT_CHANNEL, PROCESS_SIGNAL, } from "../core/values.js";
|
|
@@ -15,15 +16,6 @@ import { cliAvailability, } from "../host/availability.js";
|
|
|
15
16
|
import { cliCommandDoctor } from "../host/command-doctor.js";
|
|
16
17
|
import { classifyFailure, sharedFailureMatchers, } from "./classify.js";
|
|
17
18
|
import { requireKeyedHandler } from "./keyed.js";
|
|
18
|
-
const SIGKILL_ESCALATION_MS = 5_000;
|
|
19
|
-
const RAW_OUTPUT_CAP_BYTES = 10 * 1024 * 1024;
|
|
20
|
-
const OUTPUT_TAIL_CHARS = 2_000;
|
|
21
|
-
function appendCapped(current, text) {
|
|
22
|
-
const combined = current + text;
|
|
23
|
-
return combined.length > RAW_OUTPUT_CAP_BYTES
|
|
24
|
-
? combined.slice(combined.length - RAW_OUTPUT_CAP_BYTES)
|
|
25
|
-
: combined;
|
|
26
|
-
}
|
|
27
19
|
class CliOutput {
|
|
28
20
|
hooks;
|
|
29
21
|
stdout = "";
|
|
@@ -32,7 +24,7 @@ class CliOutput {
|
|
|
32
24
|
usage = null;
|
|
33
25
|
completionDetected = false;
|
|
34
26
|
messages = [];
|
|
35
|
-
|
|
27
|
+
lines = new LineBuffer();
|
|
36
28
|
constructor(hooks) {
|
|
37
29
|
this.hooks = hooks;
|
|
38
30
|
}
|
|
@@ -41,28 +33,19 @@ class CliOutput {
|
|
|
41
33
|
{ type: AGENT_EVENT_TYPE.output, channel, chunk: text },
|
|
42
34
|
];
|
|
43
35
|
if (channel === OUTPUT_CHANNEL.stderr) {
|
|
44
|
-
this.stderr =
|
|
36
|
+
this.stderr = appendTail(this.stderr, text, RAW_OUTPUT_CAP_CHARS);
|
|
45
37
|
return events;
|
|
46
38
|
}
|
|
47
|
-
this.stdout =
|
|
48
|
-
this.
|
|
49
|
-
const lines = this.pendingLine.split(/\r?\n/);
|
|
50
|
-
this.pendingLine = lines.pop() ?? "";
|
|
51
|
-
for (const line of lines) {
|
|
39
|
+
this.stdout = appendTail(this.stdout, text, RAW_OUTPUT_CAP_CHARS);
|
|
40
|
+
for (const line of this.lines.push(text)) {
|
|
52
41
|
events.push(...this.handleLine(line));
|
|
53
42
|
}
|
|
54
43
|
return events;
|
|
55
44
|
}
|
|
56
45
|
flush() {
|
|
57
|
-
|
|
58
|
-
this.pendingLine = "";
|
|
59
|
-
return this.handleLine(line);
|
|
46
|
+
return this.lines.flush().flatMap((line) => this.handleLine(line));
|
|
60
47
|
}
|
|
61
|
-
handleLine(
|
|
62
|
-
const trimmed = line.trim();
|
|
63
|
-
if (trimmed === "") {
|
|
64
|
-
return [];
|
|
65
|
-
}
|
|
48
|
+
handleLine(trimmed) {
|
|
66
49
|
const events = this.hooks.parseLine(trimmed);
|
|
67
50
|
for (const event of events) {
|
|
68
51
|
if (event.type === AGENT_EVENT_TYPE.message) {
|
|
@@ -91,17 +74,10 @@ class CliOutput {
|
|
|
91
74
|
* they are born here together.
|
|
92
75
|
*/
|
|
93
76
|
function* raiseClassifiedFailure(classified, agentId, evidence) {
|
|
94
|
-
const stdoutTail = redactSecrets(evidence.stdout.slice(-OUTPUT_TAIL_CHARS));
|
|
95
|
-
const stderrTail = redactSecrets(evidence.stderr.slice(-OUTPUT_TAIL_CHARS));
|
|
96
77
|
yield {
|
|
97
78
|
type: AGENT_EVENT_TYPE.failureClassified,
|
|
98
79
|
code: classified.code,
|
|
99
|
-
evidence: {
|
|
100
|
-
stdoutTail: stdoutTail === "" ? null : stdoutTail,
|
|
101
|
-
stderrTail: stderrTail === "" ? null : stderrTail,
|
|
102
|
-
exitCode: evidence.exitCode,
|
|
103
|
-
signal: evidence.signal,
|
|
104
|
-
},
|
|
80
|
+
evidence: { ...failureEvidence(evidence), signal: evidence.signal },
|
|
105
81
|
};
|
|
106
82
|
throw new AgentError({
|
|
107
83
|
...classified,
|
|
@@ -152,17 +128,15 @@ function* finishCliRun(input) {
|
|
|
152
128
|
if (classified !== null) {
|
|
153
129
|
yield* raiseClassifiedFailure(classified, agentId, evidence);
|
|
154
130
|
}
|
|
155
|
-
const stdoutTail = redactSecrets(output.stdout.slice(-OUTPUT_TAIL_CHARS));
|
|
156
|
-
const stderrTail = redactSecrets(output.stderr.slice(-OUTPUT_TAIL_CHARS));
|
|
157
131
|
throw new AgentError({
|
|
158
132
|
code: AGENT_ERROR_CODE.failed,
|
|
159
133
|
classification: AgentError.agentFailure(AGENT_ERROR_CODE.failed),
|
|
160
134
|
message: redactSecrets(`Agent "${agentId}" exited with code ${exit.code ?? "null"}${exit.signal === null ? "" : ` (signal ${exit.signal})`}`),
|
|
161
|
-
data: {
|
|
135
|
+
data: failureEvidence({
|
|
136
|
+
stdout: output.stdout,
|
|
137
|
+
stderr: output.stderr,
|
|
162
138
|
exitCode: exit.code,
|
|
163
|
-
|
|
164
|
-
stderrTail: stderrTail === "" ? null : stderrTail,
|
|
165
|
-
},
|
|
139
|
+
}),
|
|
166
140
|
agentId,
|
|
167
141
|
started: true,
|
|
168
142
|
});
|
|
@@ -171,16 +145,7 @@ function buildRun(blueprint, hooks, matchers, successMatchers) {
|
|
|
171
145
|
const graceMs = blueprint.completionGraceMs ?? 1_000;
|
|
172
146
|
return async function* run(options, ctx) {
|
|
173
147
|
const argBuilder = requireKeyedHandler(blueprint.args, options.sandbox.mode, blueprint.id, `sandbox mode "${options.sandbox.mode}"`);
|
|
174
|
-
const command = await ctx.exec
|
|
175
|
-
if (command === null) {
|
|
176
|
-
throw new AgentError({
|
|
177
|
-
code: AGENT_ERROR_CODE.notAvailable,
|
|
178
|
-
classification: AgentError.agentFailure(AGENT_ERROR_CODE.notAvailable),
|
|
179
|
-
message: `Command "${blueprint.command}" was not found on PATH`,
|
|
180
|
-
data: { cause: NOT_AVAILABLE_CAUSE.notInstalled },
|
|
181
|
-
agentId: blueprint.id,
|
|
182
|
-
});
|
|
183
|
-
}
|
|
148
|
+
const command = await resolveCommand(ctx.exec, blueprint.command, ctx.env, blueprint.id);
|
|
184
149
|
const argv = argBuilder(options.sandbox, {
|
|
185
150
|
model: options.model,
|
|
186
151
|
effort: options.effort,
|
|
@@ -465,36 +430,14 @@ function manageCliChildTermination(child, ctx) {
|
|
|
465
430
|
},
|
|
466
431
|
};
|
|
467
432
|
}
|
|
468
|
-
function terminateUncontrolledChild(child, clock) {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
reject(error);
|
|
477
|
-
return;
|
|
478
|
-
}
|
|
479
|
-
let cancelEscalation = clock.setTimeout(() => {
|
|
480
|
-
cancelEscalation = null;
|
|
481
|
-
try {
|
|
482
|
-
child.kill(PROCESS_SIGNAL.sigkill);
|
|
483
|
-
}
|
|
484
|
-
catch (error) {
|
|
485
|
-
reject(error);
|
|
486
|
-
}
|
|
487
|
-
}, SIGKILL_ESCALATION_MS);
|
|
488
|
-
void termination.then(() => {
|
|
489
|
-
cancelEscalation?.();
|
|
490
|
-
cancelEscalation = null;
|
|
491
|
-
resolve();
|
|
492
|
-
}, (error) => {
|
|
493
|
-
cancelEscalation?.();
|
|
494
|
-
cancelEscalation = null;
|
|
495
|
-
reject(error);
|
|
496
|
-
});
|
|
497
|
-
});
|
|
433
|
+
async function terminateUncontrolledChild(child, clock) {
|
|
434
|
+
const cancelEscalation = escalateTermination(child, clock);
|
|
435
|
+
try {
|
|
436
|
+
await child.awaitTerminationEscalation();
|
|
437
|
+
}
|
|
438
|
+
finally {
|
|
439
|
+
cancelEscalation();
|
|
440
|
+
}
|
|
498
441
|
}
|
|
499
442
|
async function resolveCliChildExit(child, watcher, completion, signal) {
|
|
500
443
|
if (child.kind === CLI_CHILD_KIND.uncontrolled) {
|
|
@@ -516,17 +459,15 @@ async function resolveCliChildExit(child, watcher, completion, signal) {
|
|
|
516
459
|
return { code: null, signal: null };
|
|
517
460
|
}
|
|
518
461
|
function processLifecycleFailure(agentId, output, cause) {
|
|
519
|
-
const stdoutTail = redactSecrets(output.stdout.slice(-OUTPUT_TAIL_CHARS));
|
|
520
|
-
const stderrTail = redactSecrets(output.stderr.slice(-OUTPUT_TAIL_CHARS));
|
|
521
462
|
return new AgentError({
|
|
522
463
|
code: AGENT_ERROR_CODE.failed,
|
|
523
464
|
classification: infrastructureFailure(AGENT_INFRASTRUCTURE_FAILURE_CODE.controlledProcessLifecycle),
|
|
524
465
|
message: `Agent "${agentId}" process lifecycle failed`,
|
|
525
|
-
data: {
|
|
466
|
+
data: failureEvidence({
|
|
467
|
+
stdout: output.stdout,
|
|
468
|
+
stderr: output.stderr,
|
|
526
469
|
exitCode: null,
|
|
527
|
-
|
|
528
|
-
stderrTail: stderrTail === "" ? null : stderrTail,
|
|
529
|
-
},
|
|
470
|
+
}),
|
|
530
471
|
cause,
|
|
531
472
|
agentId,
|
|
532
473
|
started: true,
|