@alpacakit/agents 0.1.0-beta.20 → 0.1.0-beta.24
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 +60 -0
- package/dist/agents/claude.d.ts.map +1 -1
- package/dist/agents/claude.js +3 -0
- package/dist/agents/codex.d.ts.map +1 -1
- package/dist/agents/codex.js +4 -0
- package/dist/agents/openai-compatible/config.d.ts.map +1 -1
- package/dist/agents/openai-compatible/config.js +5 -0
- package/dist/agents/openai-compatible/fetch-engine.d.ts.map +1 -1
- package/dist/agents/openai-compatible/fetch-engine.js +6 -0
- package/dist/agents/openai-compatible/pi/module.d.ts.map +1 -1
- package/dist/agents/openai-compatible/pi/module.js +1 -0
- package/dist/agents/openai-compatible/pi/sandbox.js +2 -0
- package/dist/agents/openai-compatible/response.js +1 -0
- package/dist/auth/profile-store.d.ts.map +1 -1
- package/dist/auth/profile-store.js +1 -0
- package/dist/auth/secrets.d.ts.map +1 -1
- package/dist/auth/secrets.js +2 -0
- package/dist/codex/app-server.js +6 -0
- package/dist/core/controlled-process.d.ts +98 -0
- package/dist/core/controlled-process.d.ts.map +1 -0
- package/dist/core/controlled-process.js +29 -0
- package/dist/core/error.d.ts +25 -0
- package/dist/core/error.d.ts.map +1 -1
- package/dist/core/error.js +32 -0
- package/dist/core/node-controlled-exec.d.ts +3 -0
- package/dist/core/node-controlled-exec.d.ts.map +1 -0
- package/dist/core/node-controlled-exec.js +32 -0
- package/dist/core/node-ports.d.ts +1 -0
- package/dist/core/node-ports.d.ts.map +1 -1
- package/dist/core/node-ports.js +9 -1
- package/dist/core/ports.d.ts +5 -0
- package/dist/core/ports.d.ts.map +1 -1
- package/dist/fleet/fleet.d.ts.map +1 -1
- package/dist/fleet/fleet.js +5 -2
- package/dist/fleet/store.d.ts.map +1 -1
- package/dist/fleet/store.js +3 -0
- package/dist/host/github-dir.d.ts.map +1 -1
- package/dist/host/github-dir.js +5 -0
- package/dist/host/mcp-list.d.ts.map +1 -1
- package/dist/host/mcp-list.js +1 -0
- package/dist/host/run-command.d.ts.map +1 -1
- package/dist/host/run-command.js +2 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/internal/controlled-process/authentication.d.ts +13 -0
- package/dist/internal/controlled-process/authentication.d.ts.map +1 -0
- package/dist/internal/controlled-process/authentication.js +112 -0
- package/dist/internal/controlled-process/child-fd.d.ts +5 -0
- package/dist/internal/controlled-process/child-fd.d.ts.map +1 -0
- package/dist/internal/controlled-process/child-fd.js +47 -0
- package/dist/internal/controlled-process/framed-transport.d.ts +6 -0
- package/dist/internal/controlled-process/framed-transport.d.ts.map +1 -0
- package/dist/internal/controlled-process/framed-transport.js +117 -0
- package/dist/internal/controlled-process/host-controller.d.ts +23 -0
- package/dist/internal/controlled-process/host-controller.d.ts.map +1 -0
- package/dist/internal/controlled-process/host-controller.js +911 -0
- package/dist/internal/controlled-process/lifecycle.d.ts +5 -0
- package/dist/internal/controlled-process/lifecycle.d.ts.map +1 -0
- package/dist/internal/controlled-process/lifecycle.js +22 -0
- package/dist/internal/controlled-process/model.d.ts +99 -0
- package/dist/internal/controlled-process/model.d.ts.map +1 -0
- package/dist/internal/controlled-process/model.js +1 -0
- package/dist/internal/controlled-process/record-store.d.ts +17 -0
- package/dist/internal/controlled-process/record-store.d.ts.map +1 -0
- package/dist/internal/controlled-process/record-store.js +170 -0
- package/dist/internal/controlled-process/record.d.ts +12 -0
- package/dist/internal/controlled-process/record.d.ts.map +1 -0
- package/dist/internal/controlled-process/record.js +87 -0
- package/dist/internal/controlled-process/schema.d.ts +133 -0
- package/dist/internal/controlled-process/schema.d.ts.map +1 -0
- package/dist/internal/controlled-process/schema.js +99 -0
- package/dist/internal/controlled-process/shim-entry.d.ts +2 -0
- package/dist/internal/controlled-process/shim-entry.d.ts.map +1 -0
- package/dist/internal/controlled-process/shim-entry.js +2 -0
- package/dist/internal/controlled-process/shim-runtime.d.ts +2 -0
- package/dist/internal/controlled-process/shim-runtime.d.ts.map +1 -0
- package/dist/internal/controlled-process/shim-runtime.js +57 -0
- package/dist/internal/controlled-process/supervisor-coordinator.d.ts +67 -0
- package/dist/internal/controlled-process/supervisor-coordinator.d.ts.map +1 -0
- package/dist/internal/controlled-process/supervisor-coordinator.js +325 -0
- package/dist/internal/controlled-process/supervisor-entry.d.ts +2 -0
- package/dist/internal/controlled-process/supervisor-entry.d.ts.map +1 -0
- package/dist/internal/controlled-process/supervisor-entry.js +2 -0
- package/dist/internal/controlled-process/supervisor-model.d.ts +92 -0
- package/dist/internal/controlled-process/supervisor-model.d.ts.map +1 -0
- package/dist/internal/controlled-process/supervisor-model.js +1 -0
- package/dist/internal/controlled-process/supervisor-platform.d.ts +16 -0
- package/dist/internal/controlled-process/supervisor-platform.d.ts.map +1 -0
- package/dist/internal/controlled-process/supervisor-platform.js +104 -0
- package/dist/internal/controlled-process/supervisor-runtime.d.ts +11 -0
- package/dist/internal/controlled-process/supervisor-runtime.d.ts.map +1 -0
- package/dist/internal/controlled-process/supervisor-runtime.js +773 -0
- package/dist/internal/controlled-process/supervisor-schema.d.ts +100 -0
- package/dist/internal/controlled-process/supervisor-schema.d.ts.map +1 -0
- package/dist/internal/controlled-process/supervisor-schema.js +73 -0
- package/dist/internal/controlled-process/supervisor-transport.d.ts +46 -0
- package/dist/internal/controlled-process/supervisor-transport.d.ts.map +1 -0
- package/dist/internal/controlled-process/supervisor-transport.js +368 -0
- package/dist/internal/controlled-process/supervisor-values.d.ts +39 -0
- package/dist/internal/controlled-process/supervisor-values.d.ts.map +1 -0
- package/dist/internal/controlled-process/supervisor-values.js +38 -0
- package/dist/internal/controlled-process/token.d.ts +4 -0
- package/dist/internal/controlled-process/token.d.ts.map +1 -0
- package/dist/internal/controlled-process/token.js +38 -0
- package/dist/internal/controlled-process/values.d.ts +39 -0
- package/dist/internal/controlled-process/values.d.ts.map +1 -0
- package/dist/internal/controlled-process/values.js +38 -0
- package/dist/kernel/cli-agent.d.ts.map +1 -1
- package/dist/kernel/cli-agent.js +330 -34
- package/dist/kernel/cli-login.d.ts.map +1 -1
- package/dist/kernel/cli-login.js +5 -0
- package/dist/kernel/env-template.js +1 -0
- package/dist/kernel/facets.d.ts.map +1 -1
- package/dist/kernel/facets.js +1 -0
- package/dist/kernel/keyed.d.ts.map +1 -1
- package/dist/kernel/keyed.js +1 -0
- package/dist/kernel/login.js +2 -0
- package/dist/kernel/options.d.ts +14 -0
- package/dist/kernel/options.d.ts.map +1 -1
- package/dist/kernel/options.js +3 -0
- package/dist/kernel/process-lifecycle-failure.d.ts +5 -0
- package/dist/kernel/process-lifecycle-failure.d.ts.map +1 -0
- package/dist/kernel/process-lifecycle-failure.js +5 -0
- package/dist/kernel/run.d.ts.map +1 -1
- package/dist/kernel/run.js +11 -0
- package/dist/kernel/runtime.d.ts.map +1 -1
- package/dist/kernel/runtime.js +2 -0
- package/dist/keyring/resolver.d.ts.map +1 -1
- package/dist/keyring/resolver.js +2 -0
- package/dist/structured/run-structured.js +1 -0
- package/dist/testing/fake-controlled-exec.d.ts +21 -0
- package/dist/testing/fake-controlled-exec.d.ts.map +1 -0
- package/dist/testing/fake-controlled-exec.js +172 -0
- package/dist/testing/fake-exec.d.ts.map +1 -1
- package/dist/testing/fake-exec.js +64 -54
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../src/internal/controlled-process/token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAe7E,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,uBAAuB,GAC9B,iBAAiB,CAYnB;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,OAAO,GACb,uBAAuB,CAyBzB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { controlledProcessPlatformSchema, controlledProcessRecordIdSchema, processStartTokenSchema, supervisorBootIdSchema, supervisorCapabilitySchema, supervisorInstanceIdSchema, supervisorSocketLocatorSchema, } from "./schema.js";
|
|
2
|
+
import { CONTROLLED_PROCESS_PROTOCOL_VERSION } from "./values.js";
|
|
3
|
+
const TOKEN_SEPARATOR = ":";
|
|
4
|
+
const PROCESS_START_TOKEN_SEGMENT_COUNT = 7;
|
|
5
|
+
export function encodeProcessStartToken(fields) {
|
|
6
|
+
return processStartTokenSchema.parse([
|
|
7
|
+
fields.protocolVersion,
|
|
8
|
+
fields.platform,
|
|
9
|
+
fields.bootId,
|
|
10
|
+
fields.supervisorInstanceId,
|
|
11
|
+
fields.recordId,
|
|
12
|
+
fields.socketLocator,
|
|
13
|
+
fields.capability,
|
|
14
|
+
].join(TOKEN_SEPARATOR));
|
|
15
|
+
}
|
|
16
|
+
export function decodeProcessStartToken(value) {
|
|
17
|
+
const token = processStartTokenSchema.parse(value);
|
|
18
|
+
const segments = token.split(TOKEN_SEPARATOR);
|
|
19
|
+
if (segments.length !== PROCESS_START_TOKEN_SEGMENT_COUNT) {
|
|
20
|
+
throw new Error("Validated process-start token has invalid segment count.");
|
|
21
|
+
}
|
|
22
|
+
const [protocolVersion, platform, bootId, supervisorInstanceId, recordId, socketLocator, capability,] = segments;
|
|
23
|
+
return {
|
|
24
|
+
protocolVersion: parseProtocolVersion(protocolVersion),
|
|
25
|
+
platform: controlledProcessPlatformSchema.parse(platform),
|
|
26
|
+
bootId: supervisorBootIdSchema.parse(bootId),
|
|
27
|
+
supervisorInstanceId: supervisorInstanceIdSchema.parse(supervisorInstanceId),
|
|
28
|
+
recordId: controlledProcessRecordIdSchema.parse(recordId),
|
|
29
|
+
socketLocator: supervisorSocketLocatorSchema.parse(socketLocator),
|
|
30
|
+
capability: supervisorCapabilitySchema.parse(capability),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function parseProtocolVersion(value) {
|
|
34
|
+
if (value !== CONTROLLED_PROCESS_PROTOCOL_VERSION) {
|
|
35
|
+
throw new Error("Validated process-start token has invalid protocol version.");
|
|
36
|
+
}
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export declare const CONTROLLED_PROCESS_PROTOCOL_VERSION: "alpacakit-supervisor-v1";
|
|
2
|
+
export declare const CONTROLLED_PROCESS_PLATFORM: {
|
|
3
|
+
readonly darwin: "darwin";
|
|
4
|
+
readonly linux: "linux";
|
|
5
|
+
};
|
|
6
|
+
export declare const CONTROLLED_PROCESS_STATE: {
|
|
7
|
+
readonly reserved: "reserved";
|
|
8
|
+
readonly acked: "acked";
|
|
9
|
+
readonly running: "running";
|
|
10
|
+
readonly term: "term";
|
|
11
|
+
readonly killSent: "kill_sent";
|
|
12
|
+
readonly absent: "absent";
|
|
13
|
+
readonly released: "released";
|
|
14
|
+
};
|
|
15
|
+
export declare const SUPERVISOR_AUTHENTICATION_FRAME_KIND: {
|
|
16
|
+
readonly clientChallenge: "client_challenge";
|
|
17
|
+
readonly supervisorChallenge: "supervisor_challenge";
|
|
18
|
+
readonly clientProof: "client_proof";
|
|
19
|
+
};
|
|
20
|
+
export declare const SUPERVISOR_CHALLENGE_STATE_KIND: {
|
|
21
|
+
readonly awaitingClient: "awaiting_client";
|
|
22
|
+
readonly consumed: "consumed";
|
|
23
|
+
};
|
|
24
|
+
export declare const SUPERVISOR_AUTHENTICATION_RESULT_KIND: {
|
|
25
|
+
readonly accepted: "accepted";
|
|
26
|
+
readonly rejected: "rejected";
|
|
27
|
+
};
|
|
28
|
+
export declare const SUPERVISOR_AUTHENTICATION_REJECTION_REASON: {
|
|
29
|
+
readonly transcriptMismatch: "transcript_mismatch";
|
|
30
|
+
readonly invalidSupervisorMac: "invalid_supervisor_mac";
|
|
31
|
+
readonly invalidClientMac: "invalid_client_mac";
|
|
32
|
+
readonly replay: "replay";
|
|
33
|
+
};
|
|
34
|
+
export declare const SUPERVISOR_MAC_DOMAIN: {
|
|
35
|
+
readonly record: "alpacakit-supervisor-v1/record/v1";
|
|
36
|
+
readonly supervisorChallenge: "alpacakit-supervisor-v1/auth/supervisor/v1";
|
|
37
|
+
readonly clientProof: "alpacakit-supervisor-v1/auth/client/v1";
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=values.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../../../src/internal/controlled-process/values.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mCAAmC,EAC9C,yBAAkC,CAAC;AAErC,eAAO,MAAM,2BAA2B;;;CAG9B,CAAC;AAEX,eAAO,MAAM,wBAAwB;;;;;;;;CAQ3B,CAAC;AAEX,eAAO,MAAM,oCAAoC;;;;CAIvC,CAAC;AAEX,eAAO,MAAM,+BAA+B;;;CAGlC,CAAC;AAEX,eAAO,MAAM,qCAAqC;;;CAGxC,CAAC;AAEX,eAAO,MAAM,0CAA0C;;;;;CAK7C,CAAC;AAEX,eAAO,MAAM,qBAAqB;;;;CAIxB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const CONTROLLED_PROCESS_PROTOCOL_VERSION = "alpacakit-supervisor-v1";
|
|
2
|
+
export const CONTROLLED_PROCESS_PLATFORM = {
|
|
3
|
+
darwin: "darwin",
|
|
4
|
+
linux: "linux",
|
|
5
|
+
};
|
|
6
|
+
export const CONTROLLED_PROCESS_STATE = {
|
|
7
|
+
reserved: "reserved",
|
|
8
|
+
acked: "acked",
|
|
9
|
+
running: "running",
|
|
10
|
+
term: "term",
|
|
11
|
+
killSent: "kill_sent",
|
|
12
|
+
absent: "absent",
|
|
13
|
+
released: "released",
|
|
14
|
+
};
|
|
15
|
+
export const SUPERVISOR_AUTHENTICATION_FRAME_KIND = {
|
|
16
|
+
clientChallenge: "client_challenge",
|
|
17
|
+
supervisorChallenge: "supervisor_challenge",
|
|
18
|
+
clientProof: "client_proof",
|
|
19
|
+
};
|
|
20
|
+
export const SUPERVISOR_CHALLENGE_STATE_KIND = {
|
|
21
|
+
awaitingClient: "awaiting_client",
|
|
22
|
+
consumed: "consumed",
|
|
23
|
+
};
|
|
24
|
+
export const SUPERVISOR_AUTHENTICATION_RESULT_KIND = {
|
|
25
|
+
accepted: "accepted",
|
|
26
|
+
rejected: "rejected",
|
|
27
|
+
};
|
|
28
|
+
export const SUPERVISOR_AUTHENTICATION_REJECTION_REASON = {
|
|
29
|
+
transcriptMismatch: "transcript_mismatch",
|
|
30
|
+
invalidSupervisorMac: "invalid_supervisor_mac",
|
|
31
|
+
invalidClientMac: "invalid_client_mac",
|
|
32
|
+
replay: "replay",
|
|
33
|
+
};
|
|
34
|
+
export const SUPERVISOR_MAC_DOMAIN = {
|
|
35
|
+
record: "alpacakit-supervisor-v1/record/v1",
|
|
36
|
+
supervisorChallenge: "alpacakit-supervisor-v1/auth/supervisor/v1",
|
|
37
|
+
clientProof: "alpacakit-supervisor-v1/auth/client/v1",
|
|
38
|
+
};
|
|
@@ -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;AAoB5D,OAAO,KAAK,EACV,UAAU,EAGV,QAAQ,EACT,MAAM,gBAAgB,CAAC;AAOxB,OAAO,KAAK,EACV,gBAAgB,EAChB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AClC,uEAAuE;IACvE,QAAQ,CAAC,SAAS,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,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;AAqrBF,wBAAgB,cAAc,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EACpD,SAAS,EAAE,iBAAiB,CAAC,EAAE,CAAC,GAC/B,eAAe,CAAC,EAAE,CAAC,CAmDrB"}
|
package/dist/kernel/cli-agent.js
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* `codex` are built with this factory; a third-party adapter is the same
|
|
7
7
|
* ~20-line exercise.
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { CHILD_PROCESS_TERMINATION_KIND, } from "../core/controlled-process.js";
|
|
10
|
+
import { AGENT_ERROR_CODE, AGENT_INFRASTRUCTURE_FAILURE_CODE, AgentError, infrastructureFailure, NOT_AVAILABLE_CAUSE, } from "../core/error.js";
|
|
10
11
|
import { redactSecrets } from "../core/redact.js";
|
|
11
12
|
import { AGENT_EVENT_TYPE, RUN_COMPLETION_KIND } from "../core/run.js";
|
|
12
13
|
import { OUTPUT_CHANNEL, PROCESS_SIGNAL, } from "../core/values.js";
|
|
@@ -14,10 +15,8 @@ import { DOCTOR_CHECK_STATUS } from "../host/capabilities.js";
|
|
|
14
15
|
import { classifyFailure, sharedFailureMatchers, } from "./classify.js";
|
|
15
16
|
import { requireKeyedHandler } from "./keyed.js";
|
|
16
17
|
const SIGKILL_ESCALATION_MS = 5_000;
|
|
17
|
-
const DEFAULT_COMPLETION_GRACE_MS = 1_000;
|
|
18
18
|
const RAW_OUTPUT_CAP_BYTES = 10 * 1024 * 1024;
|
|
19
19
|
const OUTPUT_TAIL_CHARS = 2_000;
|
|
20
|
-
const CLASSIFIED_EVIDENCE_TAIL_CHARS = 2_000;
|
|
21
20
|
function appendCapped(current, text) {
|
|
22
21
|
const combined = current + text;
|
|
23
22
|
return combined.length > RAW_OUTPUT_CAP_BYTES
|
|
@@ -91,8 +90,8 @@ class CliOutput {
|
|
|
91
90
|
* they are born here together.
|
|
92
91
|
*/
|
|
93
92
|
function* raiseClassifiedFailure(classified, agentId, evidence) {
|
|
94
|
-
const stdoutTail = redactSecrets(evidence.stdout.slice(-
|
|
95
|
-
const stderrTail = redactSecrets(evidence.stderr.slice(-
|
|
93
|
+
const stdoutTail = redactSecrets(evidence.stdout.slice(-OUTPUT_TAIL_CHARS));
|
|
94
|
+
const stderrTail = redactSecrets(evidence.stderr.slice(-OUTPUT_TAIL_CHARS));
|
|
96
95
|
yield {
|
|
97
96
|
type: AGENT_EVENT_TYPE.failureClassified,
|
|
98
97
|
code: classified.code,
|
|
@@ -105,6 +104,7 @@ function* raiseClassifiedFailure(classified, agentId, evidence) {
|
|
|
105
104
|
};
|
|
106
105
|
throw new AgentError({
|
|
107
106
|
...classified,
|
|
107
|
+
classification: AgentError.agentFailure(classified.code),
|
|
108
108
|
message: redactSecrets(classified.message),
|
|
109
109
|
agentId,
|
|
110
110
|
started: true,
|
|
@@ -116,6 +116,7 @@ function* finishCliRun(input) {
|
|
|
116
116
|
if (ctx.signal.aborted) {
|
|
117
117
|
throw new AgentError({
|
|
118
118
|
code: AGENT_ERROR_CODE.cancelled,
|
|
119
|
+
classification: AgentError.agentFailure(AGENT_ERROR_CODE.cancelled),
|
|
119
120
|
message: "Run aborted",
|
|
120
121
|
data: { reason: null },
|
|
121
122
|
agentId,
|
|
@@ -154,6 +155,7 @@ function* finishCliRun(input) {
|
|
|
154
155
|
const stderrTail = redactSecrets(output.stderr.slice(-OUTPUT_TAIL_CHARS));
|
|
155
156
|
throw new AgentError({
|
|
156
157
|
code: AGENT_ERROR_CODE.failed,
|
|
158
|
+
classification: AgentError.agentFailure(AGENT_ERROR_CODE.failed),
|
|
157
159
|
message: redactSecrets(`Agent "${agentId}" exited with code ${exit.code ?? "null"}${exit.signal === null ? "" : ` (signal ${exit.signal})`}`),
|
|
158
160
|
data: {
|
|
159
161
|
exitCode: exit.code,
|
|
@@ -165,13 +167,14 @@ function* finishCliRun(input) {
|
|
|
165
167
|
});
|
|
166
168
|
}
|
|
167
169
|
function buildRun(blueprint, hooks, matchers, successMatchers) {
|
|
168
|
-
const graceMs = blueprint.completionGraceMs ??
|
|
170
|
+
const graceMs = blueprint.completionGraceMs ?? 1_000;
|
|
169
171
|
return async function* run(options, ctx) {
|
|
170
172
|
const argBuilder = requireKeyedHandler(blueprint.args, options.sandbox.mode, blueprint.id, `sandbox mode "${options.sandbox.mode}"`);
|
|
171
173
|
const command = await ctx.exec.which(blueprint.command, ctx.env);
|
|
172
174
|
if (command === null) {
|
|
173
175
|
throw new AgentError({
|
|
174
176
|
code: AGENT_ERROR_CODE.notAvailable,
|
|
177
|
+
classification: AgentError.agentFailure(AGENT_ERROR_CODE.notAvailable),
|
|
175
178
|
message: `Command "${blueprint.command}" was not found on PATH`,
|
|
176
179
|
data: { cause: NOT_AVAILABLE_CAUSE.notInstalled },
|
|
177
180
|
agentId: blueprint.id,
|
|
@@ -182,41 +185,54 @@ function buildRun(blueprint, hooks, matchers, successMatchers) {
|
|
|
182
185
|
effort: options.effort,
|
|
183
186
|
workspace: options.workspace,
|
|
184
187
|
});
|
|
185
|
-
const
|
|
188
|
+
const spawnOptions = {
|
|
186
189
|
command,
|
|
187
190
|
args: [...argv],
|
|
188
191
|
cwd: options.workspace,
|
|
189
192
|
env: ctx.env,
|
|
190
193
|
stdin: options.prompt,
|
|
191
|
-
}
|
|
194
|
+
};
|
|
195
|
+
const child = await spawnCliChild(spawnOptions, options, ctx);
|
|
192
196
|
const output = new CliOutput(hooks);
|
|
193
|
-
const
|
|
197
|
+
const completionCancels = [];
|
|
194
198
|
let completion = { kind: RUN_COMPLETION_KIND.natural };
|
|
195
199
|
const completionTimer = { graceArmed: false };
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
200
|
+
const termination = manageCliChildTermination(child, ctx);
|
|
201
|
+
let outcome;
|
|
202
|
+
let runFailure = null;
|
|
203
|
+
let childSettlementObserved = false;
|
|
204
|
+
const chunkIterator = child.process.chunks[Symbol.asyncIterator]();
|
|
205
|
+
const completionWatcher = createCompletionWatcher(child, termination);
|
|
206
|
+
let outputAbandoned = false;
|
|
207
|
+
const abandonOutput = async () => {
|
|
208
|
+
if (outputAbandoned)
|
|
209
|
+
return;
|
|
210
|
+
outputAbandoned = true;
|
|
211
|
+
await chunkIterator.return?.();
|
|
199
212
|
};
|
|
200
|
-
if (ctx.signal.aborted) {
|
|
201
|
-
onAbort();
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
ctx.signal.addEventListener("abort", onAbort, { once: true });
|
|
205
|
-
}
|
|
206
213
|
try {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
214
|
+
completion = yield* streamCliOutput({
|
|
215
|
+
child,
|
|
216
|
+
chunkIterator,
|
|
217
|
+
completionWatcher,
|
|
218
|
+
output,
|
|
219
|
+
completionTimer,
|
|
220
|
+
completionCancels,
|
|
221
|
+
termination,
|
|
222
|
+
clock: ctx.clock,
|
|
223
|
+
graceMs,
|
|
224
|
+
});
|
|
225
|
+
let exit;
|
|
226
|
+
try {
|
|
227
|
+
exit = await resolveCliChildExit(child, completionWatcher, completion, ctx.signal);
|
|
228
|
+
}
|
|
229
|
+
catch (error) {
|
|
230
|
+
throw processLifecycleFailure(blueprint.id, output, error);
|
|
216
231
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
232
|
+
finally {
|
|
233
|
+
childSettlementObserved = true;
|
|
234
|
+
}
|
|
235
|
+
outcome = yield* finishCliRun({
|
|
220
236
|
agentId: blueprint.id,
|
|
221
237
|
matchers,
|
|
222
238
|
successMatchers,
|
|
@@ -226,14 +242,295 @@ function buildRun(blueprint, hooks, matchers, successMatchers) {
|
|
|
226
242
|
ctx,
|
|
227
243
|
});
|
|
228
244
|
}
|
|
245
|
+
catch (error) {
|
|
246
|
+
const captured = await captureCliRunFailure({
|
|
247
|
+
error,
|
|
248
|
+
agentId: blueprint.id,
|
|
249
|
+
output,
|
|
250
|
+
childSettlementObserved,
|
|
251
|
+
termination,
|
|
252
|
+
abandonOutput,
|
|
253
|
+
});
|
|
254
|
+
runFailure = captured.failure;
|
|
255
|
+
childSettlementObserved = captured.childSettlementObserved;
|
|
256
|
+
}
|
|
229
257
|
finally {
|
|
230
|
-
|
|
231
|
-
for (const cancel of cancels.splice(0)) {
|
|
258
|
+
for (const cancel of completionCancels.splice(0)) {
|
|
232
259
|
cancel();
|
|
233
260
|
}
|
|
261
|
+
runFailure = await joinCliCleanup(blueprint.id, output, termination, runFailure);
|
|
262
|
+
}
|
|
263
|
+
if (runFailure !== null) {
|
|
264
|
+
throw runFailure.error;
|
|
265
|
+
}
|
|
266
|
+
return outcome;
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
async function* streamCliOutput(input) {
|
|
270
|
+
let completion = { kind: RUN_COMPLETION_KIND.natural };
|
|
271
|
+
for (;;) {
|
|
272
|
+
const next = await nextCliChunk(input.chunkIterator, input.completionWatcher);
|
|
273
|
+
if (next.done)
|
|
274
|
+
break;
|
|
275
|
+
yield* input.output.append(next.value.channel, next.value.text);
|
|
276
|
+
if (input.output.completionDetected && !input.completionTimer.graceArmed) {
|
|
277
|
+
input.completionTimer.graceArmed = true;
|
|
278
|
+
input.completionCancels.push(input.clock.setTimeout(() => {
|
|
279
|
+
completion = { kind: RUN_COMPLETION_KIND.earlyGrace };
|
|
280
|
+
input.termination.requestEarlyCompletion();
|
|
281
|
+
}, input.graceMs));
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
yield* input.output.flush();
|
|
285
|
+
return completion;
|
|
286
|
+
}
|
|
287
|
+
async function captureCliRunFailure(input) {
|
|
288
|
+
const spontaneous = input.error instanceof ControlledCompletionFailure;
|
|
289
|
+
const observed = input.childSettlementObserved || spontaneous;
|
|
290
|
+
let failure = {
|
|
291
|
+
error: spontaneous
|
|
292
|
+
? processLifecycleFailure(input.agentId, input.output, new Error(`Controlled process is unkillable: ${input.termination.claimUnkillable() ?? input.error.reason}`))
|
|
293
|
+
: input.error,
|
|
294
|
+
};
|
|
295
|
+
if (!observed)
|
|
296
|
+
input.termination.requestFailureCleanup();
|
|
297
|
+
if (spontaneous || !observed) {
|
|
298
|
+
try {
|
|
299
|
+
await input.abandonOutput();
|
|
234
300
|
}
|
|
301
|
+
catch (abandonFailure) {
|
|
302
|
+
failure = aggregateFailures(failure, abandonFailure, `Agent "${input.agentId}" output and abandonment both failed.`);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return { failure, childSettlementObserved: observed };
|
|
306
|
+
}
|
|
307
|
+
async function joinCliCleanup(agentId, output, termination, primary) {
|
|
308
|
+
try {
|
|
309
|
+
await termination.close();
|
|
310
|
+
return primary;
|
|
311
|
+
}
|
|
312
|
+
catch (error) {
|
|
313
|
+
const lifecycleFailure = processLifecycleFailure(agentId, output, error);
|
|
314
|
+
if (primary === null)
|
|
315
|
+
return { error: lifecycleFailure };
|
|
316
|
+
return {
|
|
317
|
+
error: processLifecycleFailure(agentId, output, new AggregateError([primary.error, lifecycleFailure], `Agent "${agentId}" run and controlled process cleanup both failed.`)),
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
function aggregateFailures(primary, cleanup, message) {
|
|
322
|
+
return primary === null
|
|
323
|
+
? { error: cleanup }
|
|
324
|
+
: { error: new AggregateError([primary.error, cleanup], message) };
|
|
325
|
+
}
|
|
326
|
+
class ControlledCompletionFailure extends Error {
|
|
327
|
+
reason;
|
|
328
|
+
constructor(reason) {
|
|
329
|
+
super(reason);
|
|
330
|
+
this.reason = reason;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
async function nextCliChunk(iterator, watcher) {
|
|
334
|
+
return watcher === null ? iterator.next() : watcher.next(iterator);
|
|
335
|
+
}
|
|
336
|
+
function createCompletionWatcher(child, termination) {
|
|
337
|
+
if (child.kind === CLI_CHILD_KIND.uncontrolled)
|
|
338
|
+
return null;
|
|
339
|
+
let unkillable = null;
|
|
340
|
+
let notify = null;
|
|
341
|
+
let settleCompletion = () => { };
|
|
342
|
+
let failCompletion = () => { };
|
|
343
|
+
const completionResult = new Promise((resolve, reject) => {
|
|
344
|
+
settleCompletion = resolve;
|
|
345
|
+
failCompletion = reject;
|
|
346
|
+
});
|
|
347
|
+
void completionResult.catch(() => undefined);
|
|
348
|
+
void child.process.completion.then((completion) => {
|
|
349
|
+
termination.observe(completion);
|
|
350
|
+
settleCompletion(completion);
|
|
351
|
+
if (completion.kind === CHILD_PROCESS_TERMINATION_KIND.unkillable) {
|
|
352
|
+
unkillable = completion;
|
|
353
|
+
notify?.();
|
|
354
|
+
}
|
|
355
|
+
}, failCompletion);
|
|
356
|
+
return {
|
|
357
|
+
completion: completionResult,
|
|
358
|
+
next: async (iterator) => {
|
|
359
|
+
if (unkillable !== null) {
|
|
360
|
+
throw new ControlledCompletionFailure(unkillable.reason);
|
|
361
|
+
}
|
|
362
|
+
const next = iterator.next();
|
|
363
|
+
return new Promise((resolve, reject) => {
|
|
364
|
+
notify = () => {
|
|
365
|
+
notify = null;
|
|
366
|
+
const observed = unkillable;
|
|
367
|
+
if (observed === null ||
|
|
368
|
+
observed.kind !== CHILD_PROCESS_TERMINATION_KIND.unkillable) {
|
|
369
|
+
reject(new Error("Controlled completion watcher lost evidence."));
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
reject(new ControlledCompletionFailure(observed.reason));
|
|
373
|
+
};
|
|
374
|
+
void next.then((result) => {
|
|
375
|
+
notify = null;
|
|
376
|
+
resolve(result);
|
|
377
|
+
}, (error) => {
|
|
378
|
+
notify = null;
|
|
379
|
+
reject(error);
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
},
|
|
235
383
|
};
|
|
236
384
|
}
|
|
385
|
+
const CLI_CHILD_KIND = {
|
|
386
|
+
controlled: "controlled",
|
|
387
|
+
uncontrolled: "uncontrolled",
|
|
388
|
+
};
|
|
389
|
+
async function spawnCliChild(spawnOptions, options, ctx) {
|
|
390
|
+
const resource = options.resources.childProcess;
|
|
391
|
+
if (resource === null) {
|
|
392
|
+
return {
|
|
393
|
+
kind: CLI_CHILD_KIND.uncontrolled,
|
|
394
|
+
process: ctx.exec.spawn(spawnOptions),
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
return {
|
|
398
|
+
kind: CLI_CHILD_KIND.controlled,
|
|
399
|
+
process: await resource.exec.spawn(spawnOptions, resource.lifecycle),
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
function manageCliChildTermination(child, ctx) {
|
|
403
|
+
let requested = null;
|
|
404
|
+
let observed = null;
|
|
405
|
+
let unkillableClaimed = false;
|
|
406
|
+
const observe = (completion) => {
|
|
407
|
+
observed = completion;
|
|
408
|
+
};
|
|
409
|
+
const requestControlled = () => {
|
|
410
|
+
if (child.kind !== CLI_CHILD_KIND.controlled || requested !== null) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
requested = child.process.requestTermination().then((completion) => {
|
|
414
|
+
observe(completion);
|
|
415
|
+
return completion;
|
|
416
|
+
});
|
|
417
|
+
void requested.catch(() => undefined);
|
|
418
|
+
};
|
|
419
|
+
const onAbort = () => {
|
|
420
|
+
if (requested !== null) {
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
if (child.kind === CLI_CHILD_KIND.controlled) {
|
|
424
|
+
requestControlled();
|
|
425
|
+
}
|
|
426
|
+
else {
|
|
427
|
+
requested = terminateUncontrolledChild(child.process, ctx.clock).then(() => undefined);
|
|
428
|
+
void requested.catch(() => undefined);
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
if (ctx.signal.aborted) {
|
|
432
|
+
onAbort();
|
|
433
|
+
}
|
|
434
|
+
else {
|
|
435
|
+
ctx.signal.addEventListener("abort", onAbort, { once: true });
|
|
436
|
+
}
|
|
437
|
+
return {
|
|
438
|
+
requestEarlyCompletion: () => {
|
|
439
|
+
if (child.kind === CLI_CHILD_KIND.controlled) {
|
|
440
|
+
requestControlled();
|
|
441
|
+
}
|
|
442
|
+
else {
|
|
443
|
+
child.process.kill(PROCESS_SIGNAL.sigterm);
|
|
444
|
+
}
|
|
445
|
+
},
|
|
446
|
+
requestFailureCleanup: requestControlled,
|
|
447
|
+
observe,
|
|
448
|
+
claimUnkillable: () => {
|
|
449
|
+
if (observed?.kind !== CHILD_PROCESS_TERMINATION_KIND.unkillable ||
|
|
450
|
+
unkillableClaimed) {
|
|
451
|
+
return null;
|
|
452
|
+
}
|
|
453
|
+
unkillableClaimed = true;
|
|
454
|
+
return observed.reason;
|
|
455
|
+
},
|
|
456
|
+
close: async () => {
|
|
457
|
+
ctx.signal.removeEventListener("abort", onAbort);
|
|
458
|
+
await requested;
|
|
459
|
+
if (observed?.kind === CHILD_PROCESS_TERMINATION_KIND.unkillable &&
|
|
460
|
+
!unkillableClaimed) {
|
|
461
|
+
unkillableClaimed = true;
|
|
462
|
+
throw new Error(`Controlled process is unkillable: ${observed.reason}`);
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
function terminateUncontrolledChild(child, clock) {
|
|
468
|
+
return new Promise((resolve, reject) => {
|
|
469
|
+
let termination;
|
|
470
|
+
try {
|
|
471
|
+
child.kill(PROCESS_SIGNAL.sigterm);
|
|
472
|
+
termination = child.awaitTerminationEscalation();
|
|
473
|
+
}
|
|
474
|
+
catch (error) {
|
|
475
|
+
reject(error);
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
let cancelEscalation = clock.setTimeout(() => {
|
|
479
|
+
cancelEscalation = null;
|
|
480
|
+
try {
|
|
481
|
+
child.kill(PROCESS_SIGNAL.sigkill);
|
|
482
|
+
}
|
|
483
|
+
catch (error) {
|
|
484
|
+
reject(error);
|
|
485
|
+
}
|
|
486
|
+
}, SIGKILL_ESCALATION_MS);
|
|
487
|
+
void termination.then(() => {
|
|
488
|
+
cancelEscalation?.();
|
|
489
|
+
cancelEscalation = null;
|
|
490
|
+
resolve();
|
|
491
|
+
}, (error) => {
|
|
492
|
+
cancelEscalation?.();
|
|
493
|
+
cancelEscalation = null;
|
|
494
|
+
reject(error);
|
|
495
|
+
});
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
async function resolveCliChildExit(child, watcher, completion, signal) {
|
|
499
|
+
if (child.kind === CLI_CHILD_KIND.uncontrolled) {
|
|
500
|
+
return child.process.exit;
|
|
501
|
+
}
|
|
502
|
+
if (watcher === null) {
|
|
503
|
+
throw new Error("Controlled completion watcher is unavailable.");
|
|
504
|
+
}
|
|
505
|
+
const result = await watcher.completion;
|
|
506
|
+
if (result.kind === CHILD_PROCESS_TERMINATION_KIND.unkillable) {
|
|
507
|
+
throw new Error(`Controlled process is unkillable: ${result.reason}`);
|
|
508
|
+
}
|
|
509
|
+
if (result.workerExit !== null) {
|
|
510
|
+
return result.workerExit;
|
|
511
|
+
}
|
|
512
|
+
if (completion.kind === RUN_COMPLETION_KIND.natural && !signal.aborted) {
|
|
513
|
+
throw new Error("Natural controlled process completion lacks worker exit evidence.");
|
|
514
|
+
}
|
|
515
|
+
return { code: null, signal: null };
|
|
516
|
+
}
|
|
517
|
+
function processLifecycleFailure(agentId, output, cause) {
|
|
518
|
+
const stdoutTail = redactSecrets(output.stdout.slice(-OUTPUT_TAIL_CHARS));
|
|
519
|
+
const stderrTail = redactSecrets(output.stderr.slice(-OUTPUT_TAIL_CHARS));
|
|
520
|
+
return new AgentError({
|
|
521
|
+
code: AGENT_ERROR_CODE.failed,
|
|
522
|
+
classification: infrastructureFailure(AGENT_INFRASTRUCTURE_FAILURE_CODE.controlledProcessLifecycle),
|
|
523
|
+
message: `Agent "${agentId}" process lifecycle failed`,
|
|
524
|
+
data: {
|
|
525
|
+
exitCode: null,
|
|
526
|
+
stdoutTail: stdoutTail === "" ? null : stdoutTail,
|
|
527
|
+
stderrTail: stderrTail === "" ? null : stderrTail,
|
|
528
|
+
},
|
|
529
|
+
cause,
|
|
530
|
+
agentId,
|
|
531
|
+
started: true,
|
|
532
|
+
});
|
|
533
|
+
}
|
|
237
534
|
export function defineCliAgent(blueprint) {
|
|
238
535
|
const hooks = {
|
|
239
536
|
parseLine: blueprint.parseLine?.bind(blueprint) ?? (() => []),
|
|
@@ -241,7 +538,6 @@ export function defineCliAgent(blueprint) {
|
|
|
241
538
|
detectCompletion: blueprint.detectCompletion?.bind(blueprint) ?? (() => false),
|
|
242
539
|
};
|
|
243
540
|
const matchers = [...(blueprint.classify ?? []), ...sharedFailureMatchers];
|
|
244
|
-
const successMatchers = blueprint.classifyOnSuccess ?? [];
|
|
245
541
|
const doctor = blueprint.doctor ??
|
|
246
542
|
{
|
|
247
543
|
probe: async (ctx) => {
|
|
@@ -262,7 +558,7 @@ export function defineCliAgent(blueprint) {
|
|
|
262
558
|
};
|
|
263
559
|
const definition = {
|
|
264
560
|
id: blueprint.id,
|
|
265
|
-
run: buildRun(blueprint, hooks, matchers,
|
|
561
|
+
run: buildRun(blueprint, hooks, matchers, blueprint.classifyOnSuccess ?? []),
|
|
266
562
|
doctor,
|
|
267
563
|
};
|
|
268
564
|
if (blueprint.auth !== undefined) {
|
|
@@ -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;AAM1B,OAAO,EAAiB,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AA8B9D,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;
|
|
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;AAM1B,OAAO,EAAiB,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AA8B9D,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;AAkGF,wBAAuB,eAAe,CACpC,OAAO,EAAE,sBAAsB,GAC9B,QAAQ,CAqHV"}
|
package/dist/kernel/cli-login.js
CHANGED
|
@@ -69,12 +69,14 @@ function loginExitError(input) {
|
|
|
69
69
|
if (classified !== null) {
|
|
70
70
|
return new AgentError({
|
|
71
71
|
...classified,
|
|
72
|
+
classification: AgentError.agentFailure(classified.code),
|
|
72
73
|
message: redactSecrets(classified.message),
|
|
73
74
|
});
|
|
74
75
|
}
|
|
75
76
|
const signal = exit.signal === null ? "" : ` (signal ${exit.signal})`;
|
|
76
77
|
return new AgentError({
|
|
77
78
|
code: AGENT_ERROR_CODE.failed,
|
|
79
|
+
classification: AgentError.agentFailure(AGENT_ERROR_CODE.failed),
|
|
78
80
|
message: redactSecrets(`Login command "${command}" exited with code ${exit.code ?? "null"}${signal}`),
|
|
79
81
|
data: {
|
|
80
82
|
exitCode: exit.code,
|
|
@@ -96,6 +98,7 @@ export async function* cliLoginCommand(options) {
|
|
|
96
98
|
if (command === null) {
|
|
97
99
|
throw new AgentError({
|
|
98
100
|
code: AGENT_ERROR_CODE.notAvailable,
|
|
101
|
+
classification: AgentError.agentFailure(AGENT_ERROR_CODE.notAvailable),
|
|
99
102
|
message: `Login command "${options.command}" was not found on PATH`,
|
|
100
103
|
data: { cause: NOT_AVAILABLE_CAUSE.notInstalled },
|
|
101
104
|
});
|
|
@@ -167,6 +170,7 @@ export async function* cliLoginCommand(options) {
|
|
|
167
170
|
if (signal.aborted) {
|
|
168
171
|
throw new AgentError({
|
|
169
172
|
code: AGENT_ERROR_CODE.cancelled,
|
|
173
|
+
classification: AgentError.agentFailure(AGENT_ERROR_CODE.cancelled),
|
|
170
174
|
message: `Login command "${options.command}" was cancelled`,
|
|
171
175
|
data: {
|
|
172
176
|
reason: typeof signal.reason === "string" ? signal.reason : null,
|
|
@@ -176,6 +180,7 @@ export async function* cliLoginCommand(options) {
|
|
|
176
180
|
if (timedOut) {
|
|
177
181
|
throw new AgentError({
|
|
178
182
|
code: AGENT_ERROR_CODE.timeout,
|
|
183
|
+
classification: AgentError.agentFailure(AGENT_ERROR_CODE.timeout),
|
|
179
184
|
message: `Login command "${options.command}" exceeded its total timeout of ${timeoutMs}ms`,
|
|
180
185
|
data: { kind: TIMEOUT_KIND.total, limitMs: timeoutMs },
|
|
181
186
|
});
|
|
@@ -72,6 +72,7 @@ function assertValidEnvTemplate(value) {
|
|
|
72
72
|
function invalidTemplateError(expression) {
|
|
73
73
|
return new AgentError({
|
|
74
74
|
code: AGENT_ERROR_CODE.invalidInput,
|
|
75
|
+
classification: AgentError.agentFailure(AGENT_ERROR_CODE.invalidInput),
|
|
75
76
|
message: `Invalid environment template: ${expression}`,
|
|
76
77
|
data: { reason: `invalid environment template: ${expression}` },
|
|
77
78
|
});
|
|
@@ -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,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,KAAK,EACV,KAAK,EACL,IAAI,EACJ,UAAU,EACV,MAAM,EACN,eAAe,EAChB,MAAM,kBAAkB,CA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