@alpacakit/agents 0.1.0-beta.35 → 0.1.0-beta.37
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 +39 -10
- package/dist/agents/claude.d.ts +9 -2
- package/dist/agents/claude.d.ts.map +1 -1
- package/dist/agents/claude.js +46 -5
- package/dist/agents/codex.d.ts +1 -1
- package/dist/agents/codex.js +1 -1
- package/dist/agents/openai-compatible/engine.d.ts +5 -4
- package/dist/agents/openai-compatible/engine.d.ts.map +1 -1
- package/dist/agents/openai-compatible/engine.js +5 -4
- package/dist/config/agent-configs.d.ts +3 -1
- package/dist/config/agent-configs.d.ts.map +1 -1
- package/dist/config/agent-configs.js +23 -2
- package/dist/config/compose.d.ts.map +1 -1
- package/dist/config/compose.js +1 -0
- package/dist/config/index.d.ts +2 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +1 -1
- package/dist/config/model.d.ts +6 -0
- package/dist/config/model.d.ts.map +1 -1
- package/dist/config/values.d.ts +19 -0
- package/dist/config/values.d.ts.map +1 -1
- package/dist/config/values.js +18 -0
- package/dist/core/error.d.ts +25 -0
- package/dist/core/error.d.ts.map +1 -1
- package/dist/core/error.js +15 -0
- package/dist/core/node-controlled-exec.d.ts.map +1 -1
- package/dist/core/node-controlled-exec.js +31 -8
- package/dist/core/node-ports.d.ts.map +1 -1
- package/dist/core/node-ports.js +20 -0
- package/dist/core/ports.d.ts +5 -0
- package/dist/core/ports.d.ts.map +1 -1
- package/dist/fleet/policy.d.ts.map +1 -1
- package/dist/fleet/policy.js +3 -0
- package/dist/index.d.ts +5 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -5
- package/dist/internal/controlled-process/host-controller.d.ts +3 -2
- package/dist/internal/controlled-process/host-controller.d.ts.map +1 -1
- package/dist/internal/controlled-process/host-controller.js +63 -23
- package/dist/internal/controlled-process/input-transport.d.ts +17 -0
- package/dist/internal/controlled-process/input-transport.d.ts.map +1 -0
- package/dist/internal/controlled-process/input-transport.js +188 -0
- package/dist/internal/controlled-process/lifecycle.d.ts +1 -1
- package/dist/internal/controlled-process/lifecycle.d.ts.map +1 -1
- package/dist/internal/controlled-process/lifecycle.js +1 -0
- package/dist/internal/controlled-process/schema.d.ts +2 -2
- package/dist/internal/controlled-process/schema.js +1 -1
- package/dist/internal/controlled-process/shim-runtime.d.ts.map +1 -1
- package/dist/internal/controlled-process/shim-runtime.js +43 -4
- package/dist/internal/controlled-process/supervisor-coordinator.d.ts.map +1 -1
- package/dist/internal/controlled-process/supervisor-coordinator.js +4 -2
- package/dist/internal/controlled-process/supervisor-model.d.ts +24 -2
- package/dist/internal/controlled-process/supervisor-model.d.ts.map +1 -1
- package/dist/internal/controlled-process/supervisor-runtime.d.ts.map +1 -1
- package/dist/internal/controlled-process/supervisor-runtime.js +116 -15
- package/dist/internal/controlled-process/supervisor-schema.d.ts +66 -3
- package/dist/internal/controlled-process/supervisor-schema.d.ts.map +1 -1
- package/dist/internal/controlled-process/supervisor-schema.js +31 -3
- package/dist/internal/controlled-process/supervisor-values.d.ts +5 -0
- package/dist/internal/controlled-process/supervisor-values.d.ts.map +1 -1
- package/dist/internal/controlled-process/supervisor-values.js +5 -0
- package/dist/internal/controlled-process/values.d.ts +4 -4
- package/dist/internal/controlled-process/values.js +4 -4
- package/dist/structured/run-structured.d.ts.map +1 -1
- package/dist/structured/run-structured.js +2 -5
- package/package.json +3 -11
package/dist/core/error.js
CHANGED
|
@@ -13,6 +13,7 @@ export const AGENT_ERROR_CODE = {
|
|
|
13
13
|
limit: "limit",
|
|
14
14
|
cancelled: "cancelled",
|
|
15
15
|
outputRejected: "output_rejected",
|
|
16
|
+
controlledProcessLaunch: "controlled_process_launch",
|
|
16
17
|
failed: "failed",
|
|
17
18
|
};
|
|
18
19
|
export const AGENT_FAILURE_CLASS = {
|
|
@@ -21,6 +22,7 @@ export const AGENT_FAILURE_CLASS = {
|
|
|
21
22
|
};
|
|
22
23
|
export const AGENT_INFRASTRUCTURE_FAILURE_CODE = {
|
|
23
24
|
controlledProcessLifecycle: "controlled_process_lifecycle",
|
|
25
|
+
controlledProcessLaunch: "controlled_process_launch",
|
|
24
26
|
};
|
|
25
27
|
export function agentFailure(failureCode) {
|
|
26
28
|
return {
|
|
@@ -56,6 +58,19 @@ export const TIMEOUT_KIND = {
|
|
|
56
58
|
total: "total",
|
|
57
59
|
idle: "idle",
|
|
58
60
|
};
|
|
61
|
+
export const CONTROLLED_PROCESS_LAUNCH_FAILURE_CODE = {
|
|
62
|
+
inputEarlyEof: "input_early_eof",
|
|
63
|
+
inputOverrun: "input_overrun",
|
|
64
|
+
inputDigestMismatch: "input_digest_mismatch",
|
|
65
|
+
inputWriteFailed: "input_write_failed",
|
|
66
|
+
inputTransferTimeout: "input_transfer_timeout",
|
|
67
|
+
workerExited: "worker_exited_during_launch",
|
|
68
|
+
protocolViolation: "protocol_violation",
|
|
69
|
+
};
|
|
70
|
+
export const CONTROLLED_PROCESS_LAUNCH_FAILURE_RETRYABILITY = {
|
|
71
|
+
permanent: "permanent",
|
|
72
|
+
transient: "transient",
|
|
73
|
+
};
|
|
59
74
|
const AGENT_ERROR_BRAND = Symbol.for("@alpacakit/agents.AgentError");
|
|
60
75
|
export class AgentError extends Error {
|
|
61
76
|
code;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-controlled-exec.d.ts","sourceRoot":"","sources":["../../src/core/node-controlled-exec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node-controlled-exec.d.ts","sourceRoot":"","sources":["../../src/core/node-controlled-exec.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACtB,MAAM,yBAAyB,CAAC;AAmBjC,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,qBAAqB,GAC7B,cAAc,CAgDhB"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { launchControlledProcess, recoverControlledProcess, } from "../internal/controlled-process/host-controller.js";
|
|
3
|
+
import { ControlledProcessLaunchError } from "../internal/controlled-process/input-transport.js";
|
|
4
|
+
import { AGENT_ERROR_CODE, AGENT_INFRASTRUCTURE_FAILURE_CODE, AgentError, infrastructureFailure, } from "./error.js";
|
|
3
5
|
import { withNodeBinFirst } from "./node-ports.js";
|
|
4
6
|
const PACKAGE_ROOT = path.resolve(import.meta.dirname, "../..");
|
|
5
7
|
const SUPERVISOR_ENTRY_PATH = path.join(PACKAGE_ROOT, "dist/internal/controlled-process/supervisor-entry.js");
|
|
@@ -7,14 +9,35 @@ const SHIM_ENTRY_PATH = path.join(PACKAGE_ROOT, "dist/internal/controlled-proces
|
|
|
7
9
|
export function createControlledExec(options) {
|
|
8
10
|
return {
|
|
9
11
|
spawn: async (worker, lifecycle) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
let process;
|
|
13
|
+
try {
|
|
14
|
+
process = await launchControlledProcess({
|
|
15
|
+
supervisorEntryPath: SUPERVISOR_ENTRY_PATH,
|
|
16
|
+
shimEntryPath: SHIM_ENTRY_PATH,
|
|
17
|
+
runtimeDirectory: options.runtimeDirectory,
|
|
18
|
+
worker: { ...worker, env: withNodeBinFirst(worker.env) },
|
|
19
|
+
timing: options.termination,
|
|
20
|
+
lifecycle,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
if (!(error instanceof ControlledProcessLaunchError)) {
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
throw new AgentError({
|
|
28
|
+
code: AGENT_ERROR_CODE.controlledProcessLaunch,
|
|
29
|
+
classification: infrastructureFailure(AGENT_INFRASTRUCTURE_FAILURE_CODE.controlledProcessLaunch),
|
|
30
|
+
message: error.message,
|
|
31
|
+
data: {
|
|
32
|
+
failureCode: error.failure.code,
|
|
33
|
+
retryability: error.failure.retryability,
|
|
34
|
+
stage: error.failure.stage,
|
|
35
|
+
expectedBytes: error.failure.expectedBytes,
|
|
36
|
+
actualBytes: error.failure.actualBytes,
|
|
37
|
+
},
|
|
38
|
+
cause: error,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
18
41
|
return {
|
|
19
42
|
chunks: process.chunks,
|
|
20
43
|
completion: process.completion,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-ports.d.ts","sourceRoot":"","sources":["../../src/core/node-ports.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EACV,KAAK,EACL,IAAI,EAIJ,UAAU,EAGX,MAAM,YAAY,CAAC;AAOpB,eAAO,MAAM,WAAW,EAAE,KAOzB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,UAEvB,CAAC;AAoBF,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC1B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAUxB;
|
|
1
|
+
{"version":3,"file":"node-ports.d.ts","sourceRoot":"","sources":["../../src/core/node-ports.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EACV,KAAK,EACL,IAAI,EAIJ,UAAU,EAGX,MAAM,YAAY,CAAC;AAOpB,eAAO,MAAM,WAAW,EAAE,KAOzB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,UAEvB,CAAC;AAoBF,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC1B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAUxB;AA+HD,eAAO,MAAM,QAAQ,EAAE,IAGtB,CAAC"}
|
package/dist/core/node-ports.js
CHANGED
|
@@ -49,8 +49,12 @@ export function withNodeBinFirst(env) {
|
|
|
49
49
|
return { ...env, [key]: [nodeBinDir, ...rest].join(path.delimiter) };
|
|
50
50
|
}
|
|
51
51
|
function spawnProcess(options) {
|
|
52
|
+
if (options.processGroup === true && process.platform === "win32") {
|
|
53
|
+
throw new Error("Process-group execution is not supported on Windows.");
|
|
54
|
+
}
|
|
52
55
|
const child = spawn(options.command, options.args, {
|
|
53
56
|
cwd: options.cwd,
|
|
57
|
+
detached: options.processGroup === true,
|
|
54
58
|
env: withNodeBinFirst(options.env),
|
|
55
59
|
stdio: ["pipe", "pipe", "pipe"],
|
|
56
60
|
});
|
|
@@ -103,11 +107,27 @@ function spawnProcess(options) {
|
|
|
103
107
|
child.stdin.end();
|
|
104
108
|
},
|
|
105
109
|
kill: (signal) => {
|
|
110
|
+
if (options.processGroup === true && child.pid !== undefined) {
|
|
111
|
+
try {
|
|
112
|
+
process.kill(-child.pid, signal);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
if (!isErrnoCode(error, "ESRCH")) {
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
106
121
|
child.kill(signal);
|
|
107
122
|
},
|
|
108
123
|
awaitTerminationEscalation: () => termination,
|
|
109
124
|
};
|
|
110
125
|
}
|
|
126
|
+
function isErrnoCode(error, code) {
|
|
127
|
+
return (error instanceof Error &&
|
|
128
|
+
"code" in error &&
|
|
129
|
+
error.code === code);
|
|
130
|
+
}
|
|
111
131
|
function isExecutable(candidate) {
|
|
112
132
|
return new Promise((resolve) => {
|
|
113
133
|
access(candidate, constants.X_OK, (error) => {
|
package/dist/core/ports.d.ts
CHANGED
|
@@ -23,6 +23,11 @@ export type ExecSpawnOptions = {
|
|
|
23
23
|
cwd: string;
|
|
24
24
|
env: Record<string, string>;
|
|
25
25
|
stdin: string | null;
|
|
26
|
+
/**
|
|
27
|
+
* Start an independent process group and signal that group from kill().
|
|
28
|
+
* The built-in Node adapter rejects this option on Windows.
|
|
29
|
+
*/
|
|
30
|
+
processGroup?: boolean;
|
|
26
31
|
};
|
|
27
32
|
/** Interactive spawn: stdin stays open for incremental writes. */
|
|
28
33
|
export type InteractiveExecSpawnOptions = ExecSpawnOptions & {
|
package/dist/core/ports.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../src/core/ports.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEhE,YAAY,EACV,KAAK,EACL,UAAU,EACV,cAAc,EACd,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,SAAS,GAAG;IAAE,OAAO,EAAE,aAAa,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjE,MAAM,MAAM,QAAQ,GAAG;IAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAEtE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../src/core/ports.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,aA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O,mBAAmB,CAAC,CAAC;AAEjE,MAAM,MAAM,aAAa,GACrB;IACE,IAAI,EAAE,OAAO,mBAAmB,CAAC,QAAQ,CAAC;IAC1C,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,EAAE,aAAa,CAAC;CACtB,GACD;IAAE,IAAI,EAAE,OAAO,mBAAmB,CAAC,eAAe,CAAA;CAAE,GACpD;IAAE,IAAI,EAAE,OAAO,mBAAmB,CAAC,QAAQ,CAAA;CAAE,CAAC;AAElD,MAAM,MAAM,UAAU,GAAG,OAAO,CAC9B,cAAc,EACd,OAAO,gBAAgB,CAAC,YAAY,GAAG,OAAO,gBAAgB,CAAC,SAAS,CACzE,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;AAE9D,yEAAyE;AACzE,eAAO,MAAM,yBAAyB,UAAY,CAAC;AACnD,eAAO,MAAM,4BAA4B,SAAU,CAAC;AAEpD,eAAO,MAAM,oBAAoB,EAAE,aAoBlC,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,SAAS,GAC5C,aAAa,CAEf"}
|
package/dist/fleet/policy.js
CHANGED
|
@@ -44,6 +44,9 @@ export const defaultFailurePolicy = {
|
|
|
44
44
|
[AGENT_ERROR_CODE.limit]: { kind: FAILURE_ACTION_KIND.terminal },
|
|
45
45
|
[AGENT_ERROR_CODE.failed]: { kind: FAILURE_ACTION_KIND.terminal },
|
|
46
46
|
[AGENT_ERROR_CODE.outputRejected]: { kind: FAILURE_ACTION_KIND.terminal },
|
|
47
|
+
[AGENT_ERROR_CODE.controlledProcessLaunch]: {
|
|
48
|
+
kind: FAILURE_ACTION_KIND.terminal,
|
|
49
|
+
},
|
|
47
50
|
};
|
|
48
51
|
export function resolveFailurePolicy(overrides) {
|
|
49
52
|
return { ...defaultFailurePolicy, ...overrides };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* One root entry holds the whole surface: extension points must never
|
|
5
5
|
* require knowing which internal layer owns them. Only genuine isolation
|
|
6
6
|
* lives on a subpath — dev fakes (`/testing`), the codex app-server client
|
|
7
|
-
* (`/codex`),
|
|
8
|
-
*
|
|
7
|
+
* (`/codex`), and machine-local config storage (`/config`). The OS keychain
|
|
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 { claude, structuredQuotaMatcher } from "./agents/claude.js";
|
|
11
|
+
export { claude, type ClaudeOptions, structuredQuotaMatcher, } from "./agents/claude.js";
|
|
12
12
|
export { capacityTextMatcher, codex } from "./agents/codex.js";
|
|
13
13
|
export type { PiSessionEngineOptions } from "./agents/openai-compatible/pi/engine.js";
|
|
14
14
|
export { PI_DEFAULT_CONTEXT_WINDOW, PI_DEFAULT_MAX_TOKENS, piSessionEngine, } from "./agents/openai-compatible/pi/engine.js";
|
|
@@ -18,14 +18,13 @@ export type { LoginCapability, LoginContext, LoginEvent, LoginHandle, LoginHandl
|
|
|
18
18
|
export { LOGIN_EVENT_TYPE, LOGIN_METHOD } from "./auth/login.js";
|
|
19
19
|
export type { ApiKeyProfileOptions, AuthCapability, AuthMaterial, AuthMaterialDescriptor, AuthMaterialKind, AuthProfile, AuthStatus, HomeDirProfileOptions, MaterialHandler, MaterialHandlers, SecretRef, } from "./auth/material.js";
|
|
20
20
|
export { AUTH_MATERIAL_KIND, AUTH_STATUS, createApiKeyProfile, createHomeDirProfile, envVarAuthMaterial, } from "./auth/material.js";
|
|
21
|
-
export { fileProfileStore, type ProfileStore } from "./auth/profile-store.js";
|
|
22
21
|
export { envResolver, requireSecret } from "./auth/secrets.js";
|
|
23
22
|
export type { ChildProcessAbsenceProof, ChildProcessCompletion, ChildProcessIdentity, ChildProcessLifecycle, ChildProcessTerminationEvidence, ChildProcessTerminationPhase, ChildProcessTerminationResult, ChildProcessUnkillableReason, ControlledExec, ControlledExecOptions, ControlledExecProcess, ControlledProcessRecovery, } from "./core/controlled-process.js";
|
|
24
23
|
export { CHILD_PROCESS_ABSENCE_PROOF, CHILD_PROCESS_TERMINATION_EVIDENCE_KIND, CHILD_PROCESS_TERMINATION_KIND, CHILD_PROCESS_TERMINATION_PHASE, CHILD_PROCESS_UNKILLABLE_REASON, } from "./core/controlled-process.js";
|
|
25
24
|
export type { EnvPatch } from "./core/env.js";
|
|
26
25
|
export { applyEnvPatch, EMPTY_ENV_PATCH, mergeEnvPatches, processEnv, } from "./core/env.js";
|
|
27
|
-
export type { AgentErrorCode, AgentErrorData, AgentErrorOptions, AgentFailure, AgentFailureClass, AgentFailureCode, AgentInfrastructureFailureCode, AuthFailureReason, GuardViolation, Issue, NotAvailableCause, TimeoutKind, } from "./core/error.js";
|
|
28
|
-
export { AGENT_ERROR_CODE, AGENT_FAILURE_CLASS, AGENT_INFRASTRUCTURE_FAILURE_CODE, AgentError, AUTH_FAILURE_REASON, agentFailure, infrastructureFailure, isAgentError, NOT_AVAILABLE_CAUSE, TIMEOUT_KIND, } from "./core/error.js";
|
|
26
|
+
export type { AgentErrorCode, AgentErrorData, AgentErrorOptions, AgentFailure, AgentFailureClass, AgentFailureCode, AgentInfrastructureFailureCode, AuthFailureReason, ControlledProcessLaunchFailureCode, ControlledProcessLaunchFailureData, ControlledProcessLaunchFailureRetryability, GuardViolation, Issue, NotAvailableCause, TimeoutKind, } from "./core/error.js";
|
|
27
|
+
export { AGENT_ERROR_CODE, AGENT_FAILURE_CLASS, AGENT_INFRASTRUCTURE_FAILURE_CODE, AgentError, AUTH_FAILURE_REASON, agentFailure, CONTROLLED_PROCESS_LAUNCH_FAILURE_CODE, CONTROLLED_PROCESS_LAUNCH_FAILURE_RETRYABILITY, infrastructureFailure, isAgentError, NOT_AVAILABLE_CAUSE, TIMEOUT_KIND, } from "./core/error.js";
|
|
29
28
|
export { createControlledExec } from "./core/node-controlled-exec.js";
|
|
30
29
|
export type { Clock, Exec, ExecChunk, ExecExit, ExecProcess, ExecSpawnOptions, HttpClient, InteractiveExecProcess, InteractiveExecSpawnOptions, Logger, LogLevel, Ports, SecretResolver, SecretResolvers, TelemetrySink, } from "./core/ports.js";
|
|
31
30
|
export { LOG_LEVEL } from "./core/ports.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,
|
|
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,MAAM,EACN,KAAK,aAAa,EAClB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/D,YAAY,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,eAAe,GAChB,MAAM,yCAAyC,CAAC;AACjD,YAAY,EACV,SAAS,EACT,sBAAsB,EACtB,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,YAAY,EACV,eAAe,EACf,YAAY,EACZ,UAAU,EACV,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,QAAQ,GACT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EA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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
|
@@ -4,21 +4,20 @@
|
|
|
4
4
|
* One root entry holds the whole surface: extension points must never
|
|
5
5
|
* require knowing which internal layer owns them. Only genuine isolation
|
|
6
6
|
* lives on a subpath — dev fakes (`/testing`), the codex app-server client
|
|
7
|
-
* (`/codex`),
|
|
8
|
-
*
|
|
7
|
+
* (`/codex`), and machine-local config storage (`/config`). The OS keychain
|
|
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 { claude, structuredQuotaMatcher } from "./agents/claude.js";
|
|
11
|
+
export { claude, structuredQuotaMatcher, } from "./agents/claude.js";
|
|
12
12
|
export { capacityTextMatcher, codex } from "./agents/codex.js";
|
|
13
13
|
export { PI_DEFAULT_CONTEXT_WINDOW, PI_DEFAULT_MAX_TOKENS, piSessionEngine, } from "./agents/openai-compatible/pi/engine.js";
|
|
14
14
|
export { openaiCompatible } from "./agents/openai-compatible.js";
|
|
15
15
|
export { LOGIN_EVENT_TYPE, LOGIN_METHOD } from "./auth/login.js";
|
|
16
16
|
export { AUTH_MATERIAL_KIND, AUTH_STATUS, createApiKeyProfile, createHomeDirProfile, envVarAuthMaterial, } from "./auth/material.js";
|
|
17
|
-
export { fileProfileStore } from "./auth/profile-store.js";
|
|
18
17
|
export { envResolver, requireSecret } from "./auth/secrets.js";
|
|
19
18
|
export { CHILD_PROCESS_ABSENCE_PROOF, CHILD_PROCESS_TERMINATION_EVIDENCE_KIND, CHILD_PROCESS_TERMINATION_KIND, CHILD_PROCESS_TERMINATION_PHASE, CHILD_PROCESS_UNKILLABLE_REASON, } from "./core/controlled-process.js";
|
|
20
19
|
export { applyEnvPatch, EMPTY_ENV_PATCH, mergeEnvPatches, processEnv, } from "./core/env.js";
|
|
21
|
-
export { AGENT_ERROR_CODE, AGENT_FAILURE_CLASS, AGENT_INFRASTRUCTURE_FAILURE_CODE, AgentError, AUTH_FAILURE_REASON, agentFailure, infrastructureFailure, isAgentError, NOT_AVAILABLE_CAUSE, TIMEOUT_KIND, } from "./core/error.js";
|
|
20
|
+
export { AGENT_ERROR_CODE, AGENT_FAILURE_CLASS, AGENT_INFRASTRUCTURE_FAILURE_CODE, AgentError, AUTH_FAILURE_REASON, agentFailure, CONTROLLED_PROCESS_LAUNCH_FAILURE_CODE, CONTROLLED_PROCESS_LAUNCH_FAILURE_RETRYABILITY, infrastructureFailure, isAgentError, NOT_AVAILABLE_CAUSE, TIMEOUT_KIND, } from "./core/error.js";
|
|
22
21
|
export { createControlledExec } from "./core/node-controlled-exec.js";
|
|
23
22
|
export { LOG_LEVEL } from "./core/ports.js";
|
|
24
23
|
export { redactJsonSecrets, redactSecrets } from "./core/redact.js";
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { ChildProcessCompletion, ChildProcessIdentity, ChildProcessLifecycle, ChildProcessTerminationResult } from "../../core/controlled-process.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ExecSpawnOptions } from "../../core/ports.js";
|
|
3
|
+
import type { ControlledProcessOutput, SupervisorTimingOptions } from "./supervisor-model.js";
|
|
3
4
|
export type ControlledProcessLaunchInput = {
|
|
4
5
|
readonly supervisorEntryPath: string;
|
|
5
6
|
readonly shimEntryPath: string;
|
|
6
7
|
readonly runtimeDirectory: string;
|
|
7
|
-
readonly worker:
|
|
8
|
+
readonly worker: ExecSpawnOptions;
|
|
8
9
|
readonly timing: SupervisorTimingOptions;
|
|
9
10
|
readonly lifecycle: ChildProcessLifecycle;
|
|
10
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-controller.d.ts","sourceRoot":"","sources":["../../../src/internal/controlled-process/host-controller.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EAErB,6BAA6B,EAC9B,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"host-controller.d.ts","sourceRoot":"","sources":["../../../src/internal/controlled-process/host-controller.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EAErB,6BAA6B,EAC9B,MAAM,kCAAkC,CAAC;AAQ1C,OAAO,KAAK,EAAY,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AA6BtE,OAAO,KAAK,EACV,uBAAuB,EAEvB,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAqC/B,MAAM,MAAM,4BAA4B,GAAG;IACzC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,uBAAuB,CAAC;IACzC,QAAQ,CAAC,SAAS,EAAE,qBAAqB,CAAC;CAC3C,CAAC;AAEF,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,uBAAuB,CAAC,CAAC;IACxD,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACrD,kBAAkB,IAAI,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACvD;AAsED,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,4BAA4B,GAClC,OAAO,CAAC,2BAA2B,CAAC,CAoJtC;AAgnBD,wBAAsB,wBAAwB,CAAC,KAAK,EAAE;IACpD,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC;IACxC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,qBAAqB,EAAE,kBAAkB,CAAC,CAAC;CACrE,GAAG,OAAO,CAAC,6BAA6B,CAAC,CA4BzC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// biome-ignore-all lint/nursery/noExcessiveLinesPerFile: Section 5.103 confines the correction to this existing host lifecycle owner.
|
|
2
2
|
import { spawn } from "node:child_process";
|
|
3
3
|
import { CHILD_PROCESS_ABSENCE_PROOF, CHILD_PROCESS_TERMINATION_EVIDENCE_KIND, CHILD_PROCESS_TERMINATION_KIND, CHILD_PROCESS_UNKILLABLE_REASON, } from "../../core/controlled-process.js";
|
|
4
|
+
import { CONTROLLED_PROCESS_LAUNCH_FAILURE_RETRYABILITY } from "../../core/error.js";
|
|
4
5
|
import { readFramedRecords, readRequiredFrame, writeFramedRecord, } from "./framed-transport.js";
|
|
6
|
+
import { ControlledProcessLaunchError, workerInputManifest, writeWorkerInput, } from "./input-transport.js";
|
|
5
7
|
import { transitionControlledProcess } from "./lifecycle.js";
|
|
6
8
|
import { controlledProcessRecordMatchesToken, signControlledProcessRecord, verifySignedControlledProcessRecord, } from "./record.js";
|
|
7
9
|
import { assertSecureRuntimeDirectory, resolveSupervisorSocketNamespace, SignedRecordStore, supervisorSocketPath, } from "./record-store.js";
|
|
@@ -14,6 +16,7 @@ import { decodeProcessStartToken } from "./token.js";
|
|
|
14
16
|
import { CONTROLLED_PROCESS_STATE } from "./values.js";
|
|
15
17
|
const HOST_BOOTSTRAP_FD = 3;
|
|
16
18
|
const HOST_IDENTITY_FD = 4;
|
|
19
|
+
const HOST_INPUT_FD = 5;
|
|
17
20
|
const OUTPUT_QUEUE_HIGH_WATER_BYTES = 64 * 1024;
|
|
18
21
|
const OUTPUT_QUEUE_LOW_WATER_BYTES = 32 * 1024;
|
|
19
22
|
const PRE_READY_CLEANUP_AUTHORITY = {
|
|
@@ -29,8 +32,9 @@ const TERMINATION_OBSERVATION_SOURCE = {
|
|
|
29
32
|
supervisorClose: "supervisor_close",
|
|
30
33
|
offlineFallback: "offline_fallback",
|
|
31
34
|
};
|
|
32
|
-
class SupervisorReportedLaunchFailure extends
|
|
35
|
+
class SupervisorReportedLaunchFailure extends ControlledProcessLaunchError {
|
|
33
36
|
}
|
|
37
|
+
// biome-ignore lint/complexity/noExcessiveLinesPerFunction: Launch, readiness, and pre-ready cleanup share one custody scope.
|
|
34
38
|
export async function launchControlledProcess(input) {
|
|
35
39
|
const platform = createSupervisorPlatformAdapter();
|
|
36
40
|
const runtimeDirectory = await assertSecureRuntimeDirectory(input.runtimeDirectory, platform.uid);
|
|
@@ -39,6 +43,7 @@ export async function launchControlledProcess(input) {
|
|
|
39
43
|
void supervisorClose.promise.catch(() => undefined);
|
|
40
44
|
const control = supervisor.stdio[HOST_BOOTSTRAP_FD];
|
|
41
45
|
const identityStream = supervisor.stdio[HOST_IDENTITY_FD];
|
|
46
|
+
const inputStream = supervisor.stdio.at(HOST_INPUT_FD);
|
|
42
47
|
const identityFrames = readFramedRecords(identityStream)[Symbol.asyncIterator]();
|
|
43
48
|
let output = null;
|
|
44
49
|
let identity = null;
|
|
@@ -50,29 +55,52 @@ export async function launchControlledProcess(input) {
|
|
|
50
55
|
kind: SUPERVISOR_BOOTSTRAP_FRAME_KIND.bootstrap,
|
|
51
56
|
runtimeDirectory,
|
|
52
57
|
shimEntryPath: input.shimEntryPath,
|
|
53
|
-
worker:
|
|
58
|
+
worker: {
|
|
59
|
+
command: input.worker.command,
|
|
60
|
+
args: input.worker.args,
|
|
61
|
+
cwd: input.worker.cwd,
|
|
62
|
+
env: input.worker.env,
|
|
63
|
+
},
|
|
64
|
+
input: workerInputManifest(input.worker.stdin),
|
|
54
65
|
timing: input.timing,
|
|
55
66
|
});
|
|
67
|
+
const inputTransfer = writeWorkerInput(inputStream, input.worker.stdin);
|
|
68
|
+
void inputTransfer.catch(() => undefined);
|
|
56
69
|
identity = await readSupervisorIdentity(identityFrames);
|
|
57
|
-
let
|
|
58
|
-
const readinessObservation = observeSupervisorReadiness(identityFrames, () =>
|
|
70
|
+
let hostAckWriteStarted = false;
|
|
71
|
+
const readinessObservation = observeSupervisorReadiness(identityFrames, () => hostAckWriteStarted);
|
|
59
72
|
await input.lifecycle.beforeExec(identity);
|
|
60
73
|
descriptorCommitted = true;
|
|
74
|
+
hostAckWriteStarted = true;
|
|
61
75
|
await writeFramedRecord(control, {
|
|
62
76
|
kind: SUPERVISOR_BOOTSTRAP_FRAME_KIND.hostAck,
|
|
63
77
|
});
|
|
64
|
-
hostAckComplete = true;
|
|
65
78
|
control.end();
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
79
|
+
const [inputSettlement, readinessSettlement] = await Promise.allSettled([
|
|
80
|
+
inputTransfer,
|
|
81
|
+
concludeSupervisorReadiness({
|
|
82
|
+
observation: readinessObservation,
|
|
83
|
+
identity,
|
|
84
|
+
runtimeDirectory,
|
|
85
|
+
supervisorClose,
|
|
86
|
+
timing: input.timing,
|
|
87
|
+
}),
|
|
88
|
+
]);
|
|
89
|
+
if (readinessSettlement.status === "rejected") {
|
|
90
|
+
throw readinessSettlement.reason;
|
|
91
|
+
}
|
|
92
|
+
const readiness = readinessSettlement.value;
|
|
73
93
|
if (readiness.kind === "failure") {
|
|
74
94
|
cleanupAuthority = readiness.cleanupAuthority;
|
|
75
|
-
|
|
95
|
+
if (readiness.error instanceof SupervisorReportedLaunchFailure) {
|
|
96
|
+
throw readiness.error;
|
|
97
|
+
}
|
|
98
|
+
throw inputSettlement.status === "rejected"
|
|
99
|
+
? inputSettlement.reason
|
|
100
|
+
: readiness.error;
|
|
101
|
+
}
|
|
102
|
+
if (inputSettlement.status === "rejected") {
|
|
103
|
+
throw inputSettlement.reason;
|
|
76
104
|
}
|
|
77
105
|
const readyIdentity = identity;
|
|
78
106
|
let terminationRequested = false;
|
|
@@ -101,12 +129,14 @@ export async function launchControlledProcess(input) {
|
|
|
101
129
|
};
|
|
102
130
|
}
|
|
103
131
|
catch (primaryFailure) {
|
|
104
|
-
if (primaryFailure instanceof SupervisorReportedLaunchFailure
|
|
132
|
+
if (primaryFailure instanceof SupervisorReportedLaunchFailure &&
|
|
133
|
+
identity === null) {
|
|
105
134
|
cleanupAuthority = PRE_READY_CLEANUP_AUTHORITY.reportedFailure;
|
|
106
135
|
}
|
|
107
136
|
try {
|
|
108
137
|
await cleanupPreReadySupervisor({
|
|
109
138
|
control,
|
|
139
|
+
inputStream,
|
|
110
140
|
identity,
|
|
111
141
|
descriptorCommitted,
|
|
112
142
|
runtimeDirectory,
|
|
@@ -118,26 +148,32 @@ export async function launchControlledProcess(input) {
|
|
|
118
148
|
});
|
|
119
149
|
}
|
|
120
150
|
catch (cleanupFailure) {
|
|
151
|
+
if (primaryFailure instanceof ControlledProcessLaunchError) {
|
|
152
|
+
throw new ControlledProcessLaunchError({
|
|
153
|
+
...primaryFailure.failure,
|
|
154
|
+
retryability: CONTROLLED_PROCESS_LAUNCH_FAILURE_RETRYABILITY.permanent,
|
|
155
|
+
}, new AggregateError([primaryFailure, cleanupFailure], `Controlled process launch and pre-ready cleanup both failed (${cleanupAuthority}).`));
|
|
156
|
+
}
|
|
121
157
|
throw new AggregateError([primaryFailure, cleanupFailure], "Controlled process launch and pre-ready cleanup both failed.");
|
|
122
158
|
}
|
|
123
159
|
throw primaryFailure;
|
|
124
160
|
}
|
|
125
161
|
}
|
|
126
|
-
function observeSupervisorReadiness(frames,
|
|
162
|
+
function observeSupervisorReadiness(frames, hostAckWriteStarted) {
|
|
127
163
|
return frames.next().then((result) => ({
|
|
128
164
|
kind: "result",
|
|
129
165
|
result,
|
|
130
|
-
|
|
166
|
+
observedBeforeHostAckWrite: !hostAckWriteStarted(),
|
|
131
167
|
}), (error) => ({
|
|
132
168
|
kind: "failure",
|
|
133
169
|
error,
|
|
134
|
-
|
|
170
|
+
observedBeforeHostAckWrite: !hostAckWriteStarted(),
|
|
135
171
|
}));
|
|
136
172
|
}
|
|
137
173
|
async function concludeSupervisorReadiness(input) {
|
|
138
174
|
const observation = await input.observation;
|
|
139
|
-
if (observation.
|
|
140
|
-
return readinessFailure(new Error("Supervisor readiness arrived before host ACK
|
|
175
|
+
if (observation.observedBeforeHostAckWrite) {
|
|
176
|
+
return readinessFailure(new Error("Supervisor readiness arrived before the host ACK write began."), PRE_READY_CLEANUP_AUTHORITY.unprobed);
|
|
141
177
|
}
|
|
142
178
|
if (observation.kind === "failure") {
|
|
143
179
|
return readinessFailure(observation.error, PRE_READY_CLEANUP_AUTHORITY.unprobed);
|
|
@@ -145,7 +181,7 @@ async function concludeSupervisorReadiness(input) {
|
|
|
145
181
|
if (!observation.result.done) {
|
|
146
182
|
const failure = supervisorLaunchFailedFrameSchema.safeParse(observation.result.value);
|
|
147
183
|
if (failure.success) {
|
|
148
|
-
return readinessFailure(new
|
|
184
|
+
return readinessFailure(new SupervisorReportedLaunchFailure(failure.data.failure), PRE_READY_CLEANUP_AUTHORITY.live);
|
|
149
185
|
}
|
|
150
186
|
return readinessFailure(new Error("Supervisor readiness frame is invalid."), PRE_READY_CLEANUP_AUTHORITY.unprobed);
|
|
151
187
|
}
|
|
@@ -209,6 +245,9 @@ async function cleanupPreReadySupervisor(input) {
|
|
|
209
245
|
if (!input.control.destroyed && !input.control.writableEnded) {
|
|
210
246
|
input.control.end();
|
|
211
247
|
}
|
|
248
|
+
if (!input.inputStream.destroyed && !input.inputStream.writableEnded) {
|
|
249
|
+
input.inputStream.destroy();
|
|
250
|
+
}
|
|
212
251
|
if (input.output !== null) {
|
|
213
252
|
await input.output.queue[Symbol.asyncIterator]().return?.();
|
|
214
253
|
}
|
|
@@ -377,7 +416,8 @@ async function raceSupervisorRequestWithClose(input) {
|
|
|
377
416
|
return result;
|
|
378
417
|
}
|
|
379
418
|
function preReadyCleanupDeadline(timing) {
|
|
380
|
-
const budget = Math.min(Number.MAX_SAFE_INTEGER, timing.termGraceMs + timing.killProbeTimeoutMs + timing.probeIntervalMs)
|
|
419
|
+
const budget = Math.min(Number.MAX_SAFE_INTEGER, (timing.termGraceMs + timing.killProbeTimeoutMs + timing.probeIntervalMs) *
|
|
420
|
+
2);
|
|
381
421
|
return Math.min(Number.MAX_SAFE_INTEGER, Date.now() + budget);
|
|
382
422
|
}
|
|
383
423
|
function beforeDeadline(operation, deadline, message) {
|
|
@@ -716,7 +756,7 @@ function spawnSupervisor(entryPath) {
|
|
|
716
756
|
const child = spawn(process.execPath, [entryPath], {
|
|
717
757
|
detached: true,
|
|
718
758
|
env: {},
|
|
719
|
-
stdio: ["ignore", "pipe", "pipe", "pipe", "pipe"],
|
|
759
|
+
stdio: ["ignore", "pipe", "pipe", "pipe", "pipe", "pipe"],
|
|
720
760
|
});
|
|
721
761
|
containSupervisorStdioErrors(child);
|
|
722
762
|
child.once("error", () => { });
|
|
@@ -777,7 +817,7 @@ async function readSupervisorIdentity(frames) {
|
|
|
777
817
|
}
|
|
778
818
|
const failure = supervisorLaunchFailedFrameSchema.safeParse(frame);
|
|
779
819
|
if (failure.success) {
|
|
780
|
-
throw new SupervisorReportedLaunchFailure(failure.data.
|
|
820
|
+
throw new SupervisorReportedLaunchFailure(failure.data.failure);
|
|
781
821
|
}
|
|
782
822
|
throw new Error("Supervisor identity frame is invalid.");
|
|
783
823
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Readable, Writable } from "node:stream";
|
|
2
|
+
import type { ControlledProcessLaunchFailure, WorkerInputManifest } from "./supervisor-model.js";
|
|
3
|
+
export declare class ControlledProcessLaunchError extends Error {
|
|
4
|
+
readonly failure: ControlledProcessLaunchFailure;
|
|
5
|
+
constructor(failure: ControlledProcessLaunchFailure, cause?: unknown);
|
|
6
|
+
}
|
|
7
|
+
export declare function workerInputManifest(input: string | null): WorkerInputManifest;
|
|
8
|
+
export declare function writeWorkerInput(writable: Writable, input: string | null): Promise<void>;
|
|
9
|
+
export declare function transferWorkerInput(input: {
|
|
10
|
+
readonly readable: Readable;
|
|
11
|
+
readonly writable: Writable;
|
|
12
|
+
readonly manifest: WorkerInputManifest;
|
|
13
|
+
readonly stage: ControlledProcessLaunchFailure["stage"];
|
|
14
|
+
readonly timeoutMs: number;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
export declare function launchFailure(code: ControlledProcessLaunchFailure["code"], stage: ControlledProcessLaunchFailure["stage"], expectedBytes: number | null, actualBytes: number | null, message: string, cause?: unknown): ControlledProcessLaunchError;
|
|
17
|
+
//# sourceMappingURL=input-transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-transport.d.ts","sourceRoot":"","sources":["../../../src/internal/controlled-process/input-transport.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAKtD,OAAO,KAAK,EACV,8BAA8B,EAC9B,mBAAmB,EACpB,MAAM,uBAAuB,CAAC;AAK/B,qBAAa,4BAA6B,SAAQ,KAAK;IACrD,QAAQ,CAAC,OAAO,EAAE,8BAA8B,CAAC;gBAErC,OAAO,EAAE,8BAA8B,EAAE,KAAK,CAAC,EAAE,OAAO;CAKrE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,mBAAmB,CAU7E;AAED,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,MAAM,GAAG,IAAI,GACnB,OAAO,CAAC,IAAI,CAAC,CAiBf;AAED,wBAAsB,mBAAmB,CAAC,KAAK,EAAE;IAC/C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,8BAA8B,CAAC,OAAO,CAAC,CAAC;IACxD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,GAAG,OAAO,CAAC,IAAI,CAAC,CAuGhB;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,8BAA8B,CAAC,MAAM,CAAC,EAC5C,KAAK,EAAE,8BAA8B,CAAC,OAAO,CAAC,EAC9C,aAAa,EAAE,MAAM,GAAG,IAAI,EAC5B,WAAW,EAAE,MAAM,GAAG,IAAI,EAC1B,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,OAAO,GACd,4BAA4B,CAW9B"}
|