@alpacakit/agents 0.2.0-beta.2 → 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 +21 -0
- 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-stream.js → claude/cli.js} +81 -10
- package/dist/agents/claude/host.d.ts +14 -0
- package/dist/agents/claude/host.d.ts.map +1 -0
- package/dist/agents/{claude.js → claude/host.js} +51 -174
- package/dist/agents/{claude.d.ts → claude/index.d.ts} +10 -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 → claude/session.d.ts} +3 -15
- 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.map +1 -1
- package/dist/codex/app-server.js +13 -42
- package/dist/codex/index.d.ts +1 -1
- package/dist/codex/index.d.ts.map +1 -1
- 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 +4 -0
- package/dist/core/session.d.ts.map +1 -1
- 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 +2 -1
- package/dist/host/session-files.d.ts.map +1 -1
- package/dist/host/session-files.js +2 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- 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/facets.d.ts +1 -1
- package/dist/kernel/facets.d.ts.map +1 -1
- 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/session.d.ts +46 -39
- package/dist/kernel/session.d.ts.map +1 -1
- package/dist/kernel/session.js +128 -69
- package/dist/testing/fake-exec.d.ts +9 -10
- package/dist/testing/fake-exec.d.ts.map +1 -1
- package/dist/testing/fake-exec.js +14 -1
- 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-session.d.ts.map +0 -1
- package/dist/agents/claude-session.js +0 -419
- package/dist/agents/claude-stream.d.ts +0 -65
- package/dist/agents/claude-stream.d.ts.map +0 -1
- package/dist/agents/claude.d.ts.map +0 -1
- package/dist/agents/codex-session.d.ts +0 -52
- package/dist/agents/codex-session.d.ts.map +0 -1
- package/dist/agents/codex-session.js +0 -495
- package/dist/agents/codex.d.ts +0 -20
- package/dist/agents/codex.d.ts.map +0 -1
- package/dist/agents/codex.js +0 -379
- package/dist/agents/openai-compatible/pi/session.d.ts.map +0 -1
- package/dist/core/process-close.d.ts +0 -11
- package/dist/core/process-close.d.ts.map +0 -1
- package/dist/core/process-close.js +0 -27
- /package/dist/agents/openai-compatible/pi/{session.js → run.js} +0 -0
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,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-login.d.ts","sourceRoot":"","sources":["../../src/kernel/cli-login.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EAIjB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli-login.d.ts","sourceRoot":"","sources":["../../src/kernel/cli-login.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EAIjB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,kBAAkB,CAAC;AAa1B,OAAO,EAAiB,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAsB9D,KAAK,sBAAsB,GAAG;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAC/C,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAuFF,wBAAuB,eAAe,CACpC,OAAO,EAAE,sBAAsB,GAC9B,QAAQ,CA6GV"}
|
package/dist/kernel/cli-login.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { LOGIN_EVENT_TYPE, LOGIN_METHOD, } from "../auth/login.js";
|
|
2
2
|
import { AUTH_MATERIAL_KIND, AUTH_STATUS, } from "../auth/material.js";
|
|
3
|
+
import { appendTail, escalateTermination, failureEvidence, RAW_OUTPUT_CAP_CHARS, resolveCommand, } from "../core/cli-child.js";
|
|
3
4
|
import { applyEnvPatch } from "../core/env.js";
|
|
4
|
-
import { AGENT_ERROR_CODE, AgentError,
|
|
5
|
+
import { AGENT_ERROR_CODE, AgentError, TIMEOUT_KIND } from "../core/error.js";
|
|
5
6
|
import { redactSecrets } from "../core/redact.js";
|
|
6
|
-
import { OUTPUT_CHANNEL
|
|
7
|
+
import { OUTPUT_CHANNEL } from "../core/values.js";
|
|
7
8
|
import { classifyFailure, sharedFailureMatchers } from "./classify.js";
|
|
8
9
|
const DEFAULT_CLI_LOGIN_TIMEOUT_MS = 20 * 60 * 1_000;
|
|
9
|
-
const SIGKILL_ESCALATION_MS = 5_000;
|
|
10
|
-
const RAW_OUTPUT_CAP_CHARS = 10 * 1024 * 1024;
|
|
11
|
-
const OUTPUT_TAIL_CHARS = 2_000;
|
|
12
10
|
const SCAN_BUFFER_CHARS = 12_000;
|
|
13
11
|
const MINUTE_MS = 60_000;
|
|
14
12
|
// Best-effort scanners over the accumulated (ANSI-stripped) CLI output, matching
|
|
@@ -21,12 +19,6 @@ const DEVICE_CODE_PATTERN = /\b[A-Z0-9]{4,}(?:-[A-Z0-9]{4,})+\b/u;
|
|
|
21
19
|
const URL_PATTERN = /https?:\/\/[^\s)]+/u;
|
|
22
20
|
// biome-ignore lint/suspicious/noControlCharactersInRegex: strips ANSI/CSI escape sequences from colorized CLI output.
|
|
23
21
|
const ANSI_PATTERN = /\x1b\[[0-?]*[ -/]*[@-~]/gu;
|
|
24
|
-
function boundedTail(current, text, capChars) {
|
|
25
|
-
const combined = current + text;
|
|
26
|
-
return combined.length > capChars
|
|
27
|
-
? combined.slice(combined.length - capChars)
|
|
28
|
-
: combined;
|
|
29
|
-
}
|
|
30
22
|
function stripAnsi(text) {
|
|
31
23
|
return text.replace(ANSI_PATTERN, "");
|
|
32
24
|
}
|
|
@@ -78,11 +70,7 @@ function loginExitError(input) {
|
|
|
78
70
|
code: AGENT_ERROR_CODE.failed,
|
|
79
71
|
classification: AgentError.agentFailure(AGENT_ERROR_CODE.failed),
|
|
80
72
|
message: redactSecrets(`Login command "${command}" exited with code ${exit.code ?? "null"}${signal}`),
|
|
81
|
-
data: {
|
|
82
|
-
exitCode: exit.code,
|
|
83
|
-
stdoutTail: redactSecrets(stdout.slice(-OUTPUT_TAIL_CHARS)) || null,
|
|
84
|
-
stderrTail: redactSecrets(stderr.slice(-OUTPUT_TAIL_CHARS)) || null,
|
|
85
|
-
},
|
|
73
|
+
data: failureEvidence({ stdout, stderr, exitCode: exit.code }),
|
|
86
74
|
});
|
|
87
75
|
}
|
|
88
76
|
function homeDirOutcome(request, status) {
|
|
@@ -94,15 +82,7 @@ function homeDirOutcome(request, status) {
|
|
|
94
82
|
export async function* cliLoginCommand(options) {
|
|
95
83
|
const timeoutMs = options.timeoutMs ?? DEFAULT_CLI_LOGIN_TIMEOUT_MS;
|
|
96
84
|
const env = applyEnvPatch(options.ctx.env, options.envPatch);
|
|
97
|
-
const command = await options.ctx.exec
|
|
98
|
-
if (command === null) {
|
|
99
|
-
throw new AgentError({
|
|
100
|
-
code: AGENT_ERROR_CODE.notAvailable,
|
|
101
|
-
classification: AgentError.agentFailure(AGENT_ERROR_CODE.notAvailable),
|
|
102
|
-
message: `Login command "${options.command}" was not found on PATH`,
|
|
103
|
-
data: { cause: NOT_AVAILABLE_CAUSE.notInstalled },
|
|
104
|
-
});
|
|
105
|
-
}
|
|
85
|
+
const command = await resolveCommand(options.ctx.exec, options.command, env, null);
|
|
106
86
|
const child = options.ctx.exec.spawn({
|
|
107
87
|
command,
|
|
108
88
|
args: [...options.args],
|
|
@@ -130,8 +110,7 @@ export async function* cliLoginCommand(options) {
|
|
|
130
110
|
return;
|
|
131
111
|
}
|
|
132
112
|
killed = true;
|
|
133
|
-
|
|
134
|
-
cancelKill.current = options.ctx.clock.setTimeout(() => child.kill(PROCESS_SIGNAL.sigkill), SIGKILL_ESCALATION_MS);
|
|
113
|
+
cancelKill.current = escalateTermination(child, options.ctx.clock);
|
|
135
114
|
};
|
|
136
115
|
const onAbort = () => escalateKill();
|
|
137
116
|
const cancelTimeout = options.ctx.clock.setTimeout(() => {
|
|
@@ -147,10 +126,10 @@ export async function* cliLoginCommand(options) {
|
|
|
147
126
|
try {
|
|
148
127
|
for await (const chunk of child.chunks) {
|
|
149
128
|
if (chunk.channel === OUTPUT_CHANNEL.stdout) {
|
|
150
|
-
stdout =
|
|
129
|
+
stdout = appendTail(stdout, chunk.text, RAW_OUTPUT_CAP_CHARS);
|
|
151
130
|
}
|
|
152
131
|
else {
|
|
153
|
-
stderr =
|
|
132
|
+
stderr = appendTail(stderr, chunk.text, RAW_OUTPUT_CAP_CHARS);
|
|
154
133
|
}
|
|
155
134
|
yield {
|
|
156
135
|
type: LOGIN_EVENT_TYPE.output,
|
|
@@ -158,7 +137,7 @@ export async function* cliLoginCommand(options) {
|
|
|
158
137
|
chunk: chunk.text,
|
|
159
138
|
};
|
|
160
139
|
if (!emitted) {
|
|
161
|
-
scanBuffer =
|
|
140
|
+
scanBuffer = appendTail(scanBuffer, stripAnsi(chunk.text), SCAN_BUFFER_CHARS);
|
|
162
141
|
const event = parseEvent(scanBuffer, options.ctx.clock.now());
|
|
163
142
|
if (event !== null) {
|
|
164
143
|
emitted = true;
|
package/dist/kernel/facets.d.ts
CHANGED
|
@@ -8,9 +8,9 @@ import { type LoginCapability, type LoginHandle, type LoginMethod, type LoginReq
|
|
|
8
8
|
import type { AuthCapability, AuthMaterial, AuthMaterialDescriptor, AuthMaterialKind, AuthStatus } from "../auth/material.js";
|
|
9
9
|
import { type EnvPatch } from "../core/env.js";
|
|
10
10
|
import type { Clock, Exec, HttpClient, Logger, SecretResolvers } from "../core/ports.js";
|
|
11
|
+
import type { Session, SessionFacts } from "../core/session.js";
|
|
11
12
|
import type { AgentAvailability, AgentAvailabilityCapability } from "../host/availability.js";
|
|
12
13
|
import type { DoctorCapability, DoctorReport, InstalledSkill, InstallOptions, InstallOutcome, McpCapability, McpScope, McpServerSpec, McpServerState, SkillSource, SkillsCapability } from "../host/capabilities.js";
|
|
13
|
-
import type { Session, SessionFacts } from "../core/session.js";
|
|
14
14
|
import type { HostLocation } from "../host/context.js";
|
|
15
15
|
import type { SessionCapability } from "./session.js";
|
|
16
16
|
export type AgentAuth = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facets.d.ts","sourceRoot":"","sources":["../../src/kernel/facets.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,WAAW,EAEhB,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EAGX,MAAM,qBAAqB,CAAC;AAM7B,OAAO,EAAkC,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/E,OAAO,KAAK,EACV,KAAK,EACL,IAAI,EACJ,UAAU,EACV,MAAM,EACN,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,iBAAiB,EACjB,2BAA2B,EAC5B,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,cAAc,EACd,aAAa,EACb,QAAQ,EACR,aAAa,EACb,cAAc,EACd,WAAW,EACX,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"facets.d.ts","sourceRoot":"","sources":["../../src/kernel/facets.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,WAAW,EAEhB,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EAGX,MAAM,qBAAqB,CAAC;AAM7B,OAAO,EAAkC,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/E,OAAO,KAAK,EACV,KAAK,EACL,IAAI,EACJ,UAAU,EACV,MAAM,EACN,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EA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"file":"login.d.ts","sourceRoot":"","sources":["../../src/kernel/login.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,WAAW,EACX,YAAY,EAEZ,YAAY,EACb,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/kernel/login.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,WAAW,EACX,YAAY,EAEZ,YAAY,EACb,MAAM,kBAAkB,CAAC;AAI1B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGtD,KAAK,eAAe,GAAG;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,oEAAoE;IACpE,QAAQ,CAAC,YAAY,EAAE,WAAW,GAAG,IAAI,CAAC;CAC3C,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,WAAW,CAW9D"}
|
package/dist/kernel/login.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NO_FAILURE_EVIDENCE } from "../core/cli-child.js";
|
|
1
2
|
import { AGENT_ERROR_CODE, AgentError, isAgentError } from "../core/error.js";
|
|
2
3
|
import { redactSecrets } from "../core/redact.js";
|
|
3
4
|
import { EventBroadcast } from "./handle.js";
|
|
@@ -59,7 +60,7 @@ function toLoginError(agentId, thrown) {
|
|
|
59
60
|
code: AGENT_ERROR_CODE.failed,
|
|
60
61
|
classification: AgentError.agentFailure(AGENT_ERROR_CODE.failed),
|
|
61
62
|
message: redactSecrets(message),
|
|
62
|
-
data:
|
|
63
|
+
data: NO_FAILURE_EVIDENCE,
|
|
63
64
|
cause: thrown,
|
|
64
65
|
agentId,
|
|
65
66
|
});
|
package/dist/kernel/options.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* normalized exactly once into the resolved twins (rule 2) — agent
|
|
4
4
|
* definitions only ever see the resolved types.
|
|
5
5
|
*/
|
|
6
|
-
import { type EnvPatch } from "../core/env.js";
|
|
7
6
|
import type { ChildProcessLifecycle, ControlledExec } from "../core/controlled-process.js";
|
|
7
|
+
import { type EnvPatch } from "../core/env.js";
|
|
8
8
|
import type { GuardFactory } from "./guard.js";
|
|
9
9
|
export declare const GRANT_KIND: {
|
|
10
10
|
readonly shell: "shell";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/kernel/options.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/kernel/options.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,cAAc,EACf,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAmB,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,eAAO,MAAM,UAAU;;;CAGb,CAAC;AAEX,MAAM,MAAM,KAAK,GACb;IAAE,IAAI,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,OAAO,UAAU,CAAC,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnD,eAAO,MAAM,YAAY;;;CAGf,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE3E,MAAM,MAAM,OAAO,GACf;IAAE,IAAI,EAAE,OAAO,YAAY,CAAC,IAAI,CAAA;CAAE,GAClC;IAAE,IAAI,EAA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C;IACzB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG;IACxC,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,eAAe,CAAC;IACzB,GAAG,EAAE,QAAQ,CAAC;IACd,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,EAAE,oBAAoB,CAAC;CACjC,CAAC;AAEF,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,eAAe,CAQ5E;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,cAAc,CAMxE;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,UAAU,GAAG,kBAAkB,CAazE"}
|
package/dist/kernel/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/kernel/run.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/kernel/run.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAaH,OAAO,KAAK,EAAU,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,KAAK,EAIV,SAAS,EAEV,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,eAAe,EAAc,MAAM,iBAAiB,CAAC;AAGnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAUvD,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,EAAE,eAAe,CAAC;IAC5B,OAAO,EAAE,kBAAkB,CAAC;IAC5B,YAAY,EAAE,WAAW,GAAG,IAAI,CAAC;IACjC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AA0RF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,CAExD"}
|
package/dist/kernel/run.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* stop on abort.
|
|
7
7
|
*/
|
|
8
8
|
import { randomUUID } from "node:crypto";
|
|
9
|
+
import { NO_FAILURE_EVIDENCE } from "../core/cli-child.js";
|
|
9
10
|
import { AGENT_ERROR_CODE, AgentError, isAgentError, TIMEOUT_KIND, withRunIdentity, } from "../core/error.js";
|
|
10
11
|
import { redactSecrets } from "../core/redact.js";
|
|
11
12
|
import { RUN_EVENT_TYPE, RUN_OUTCOME } from "../core/run.js";
|
|
@@ -245,7 +246,7 @@ class RunDriver {
|
|
|
245
246
|
code: AGENT_ERROR_CODE.failed,
|
|
246
247
|
classification: AgentError.agentFailure(AGENT_ERROR_CODE.failed),
|
|
247
248
|
message: redactSecrets(message),
|
|
248
|
-
data:
|
|
249
|
+
data: NO_FAILURE_EVIDENCE,
|
|
249
250
|
cause: thrown,
|
|
250
251
|
...this.identity(),
|
|
251
252
|
});
|
package/dist/kernel/session.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
2
|
+
* The session driver (design "Kernel", session plane): as `RunDriver`
|
|
3
|
+
* drives an adapter's generator, `driveSession` drives a host's
|
|
4
|
+
* `SessionProtocol`. The driver owns the conversation's lifecycle — one
|
|
5
|
+
* turn at a time, the approval registry and its lifetime, the event
|
|
6
|
+
* stream, and the end of it all when the child is gone. A protocol only
|
|
7
|
+
* encodes the five verbs for its host and decodes one incoming item into
|
|
8
|
+
* the neutral session signals; it never keeps turn or approval state.
|
|
7
9
|
*/
|
|
8
10
|
import { AGENT_ERROR_CODE, AgentError } from "../core/error.js";
|
|
9
11
|
import type { Clock, Exec, ExecExit, Logger } from "../core/ports.js";
|
|
10
|
-
import { type
|
|
12
|
+
import { type ApprovalDecision, type Session, type SessionFacts, type TurnOutcome } from "../core/session.js";
|
|
11
13
|
import type { HostContext } from "../host/context.js";
|
|
12
14
|
/** Resolved (rule 2): what a session adapter gets to open or resume. */
|
|
13
15
|
export type SessionContext = {
|
|
@@ -32,6 +34,37 @@ export type SessionCapability<Permissions> = {
|
|
|
32
34
|
resume(id: string, options: ResolvedSessionResumeOptions<Permissions>, ctx: SessionContext): Promise<Session>;
|
|
33
35
|
inspect(id: string, ctx: HostContext): Promise<SessionFacts<Permissions> | null>;
|
|
34
36
|
};
|
|
37
|
+
/** What a protocol's `decode` may tell the driver about the running turn. */
|
|
38
|
+
export type SessionSink<Payload> = {
|
|
39
|
+
/** The turn the driver currently holds; `null` between turns. */
|
|
40
|
+
readonly activeTurnId: string | null;
|
|
41
|
+
message(text: string): void;
|
|
42
|
+
tool(name: string): void;
|
|
43
|
+
/** `payload` is whatever the host needs back to answer this request. */
|
|
44
|
+
approvalRequested(requestId: string, summary: string, payload: Payload): void;
|
|
45
|
+
/** `text === null` falls back to the turn's collected messages. */
|
|
46
|
+
endTurn(outcome: TurnOutcome, text: string | null): void;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* A host's side of a Session: the encoding of each verb and the decoding
|
|
50
|
+
* of one incoming item. `incoming` ends when the child is gone; a
|
|
51
|
+
* protocol that correlates its own request/response pairs (Claude control
|
|
52
|
+
* requests) settles them inside `incoming`, before it ends.
|
|
53
|
+
*/
|
|
54
|
+
export interface SessionProtocol<Incoming, Payload> {
|
|
55
|
+
readonly incoming: AsyncIterable<Incoming>;
|
|
56
|
+
/** Settles when the child is gone; a rejection counts as an exit without code or signal. */
|
|
57
|
+
readonly exit: Promise<ExecExit>;
|
|
58
|
+
readonly stderrTail: string;
|
|
59
|
+
/** Ask the host to take a turn; resolves with the turn id once it has. */
|
|
60
|
+
startTurn(text: string): Promise<string>;
|
|
61
|
+
steer(turnId: string, text: string): Promise<void>;
|
|
62
|
+
interrupt(turnId: string): Promise<void>;
|
|
63
|
+
respond(payload: Payload, decision: ApprovalDecision): void;
|
|
64
|
+
decode(item: Incoming, sink: SessionSink<Payload>): void;
|
|
65
|
+
/** End the child: stdin EOF first, then signals. */
|
|
66
|
+
close(): Promise<void>;
|
|
67
|
+
}
|
|
35
68
|
export declare function assertHostSessionId(id: string, agentId: string): void;
|
|
36
69
|
export declare function sessionStateError(agentId: string, reason: string): AgentError<typeof AGENT_ERROR_CODE.invalidInput>;
|
|
37
70
|
export declare function sessionExitedError(agentId: string, exit: ExecExit | null, stderrTail: string): AgentError<typeof AGENT_ERROR_CODE.failed>;
|
|
@@ -61,37 +94,11 @@ export declare class SessionProcess {
|
|
|
61
94
|
lines(): AsyncGenerator<string, void, void>;
|
|
62
95
|
close(): Promise<ExecExit>;
|
|
63
96
|
}
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
private readonly broadcast;
|
|
72
|
-
private active;
|
|
73
|
-
/** A turn whose start the host has not acknowledged yet (Codex `turn/start` in flight). */
|
|
74
|
-
private starting;
|
|
75
|
-
private ended;
|
|
76
|
-
constructor(agentId: string);
|
|
77
|
-
get events(): AsyncIterable<SessionEvent>;
|
|
78
|
-
get activeTurnId(): string | null;
|
|
79
|
-
get isEnded(): boolean;
|
|
80
|
-
get isStarting(): boolean;
|
|
81
|
-
emit(event: SessionEvent): void;
|
|
82
|
-
/** Record a message for the turn's fallback text and publish it. */
|
|
83
|
-
message(text: string): void;
|
|
84
|
-
requireOpen(): void;
|
|
85
|
-
requireIdle(): void;
|
|
86
|
-
/** Reserve the idle slot while the host is asked to start the turn. */
|
|
87
|
-
markStarting(): void;
|
|
88
|
-
/** The host refused to start the turn; the slot is idle again. */
|
|
89
|
-
clearStarting(): void;
|
|
90
|
-
requireActive(): string;
|
|
91
|
-
beginTurn(turnId: string): Promise<TurnResult>;
|
|
92
|
-
/** `text === null` falls back to the turn's collected messages. */
|
|
93
|
-
endTurn(outcome: TurnOutcome, text: string | null): void;
|
|
94
|
-
/** The process is gone: fail the running turn, publish `exited`, end the stream. */
|
|
95
|
-
end(exit: ExecExit, stderrTail: string): void;
|
|
96
|
-
}
|
|
97
|
+
/** Bind a host protocol to the one Session lifecycle. */
|
|
98
|
+
export declare function driveSession<Incoming, Payload>(input: {
|
|
99
|
+
id: string;
|
|
100
|
+
agentId: string;
|
|
101
|
+
protocol: SessionProtocol<Incoming, Payload>;
|
|
102
|
+
logger: Logger;
|
|
103
|
+
}): Session;
|
|
97
104
|
//# sourceMappingURL=session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/kernel/session.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/kernel/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AASH,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,KAAK,EACV,KAAK,EACL,IAAI,EACJ,QAAQ,EAER,MAAM,EACP,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,KAAK,gBAAgB,EAErB,KAAK,OAAO,EAEZ,KAAK,YAAY,EAEjB,KAAK,WAAW,EAEjB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGtD,wEAAwE;AACxE,MAAM,MAAM,cAAc,GAAG;IAC3B,4CAA4C;IAC5C,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,IAAI,EAAE,IAAI,CAAC;I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