@nifrajs/agent 3.1.0 → 3.2.0

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 CHANGED
@@ -18,6 +18,42 @@ const result = await runAgent(definition, { value: input }, ports, {
18
18
  The public in-memory adapters are for local development and tests. Durable state, provider
19
19
  credentials, and operated policy remain adapter concerns.
20
20
 
21
+ Gateway and deployment contracts are deliberately provider-neutral. Retry, fallback, budget,
22
+ deadline, workspace, and hostile-code isolation claims are admitted only from a host-approved
23
+ capability report. The local and replay reference profiles are not hostile-code sandboxes, and no
24
+ public package loads provider credentials or promises durable execution.
25
+
26
+ Several telemetry consumers can observe the same run: `combineAgentTelemetry(a, b, ...)` fans step
27
+ evidence out to every port in order, so an SSE evidence stream and an exporter (for example
28
+ `@nifrajs/agent-telemetry`'s `traceAgentRun`) compose instead of displacing each other. The HTTP
29
+ seams (`mountAgent`, `@nifrajs/a2a`, `@nifrajs/ag-ui`) compose their streaming evidence with any
30
+ telemetry port supplied through `ports`.
31
+
32
+ A model port can stream: when the caller wires an `AgentDeltaSink` into `ports.deltas`, every model
33
+ request carries an optional `onDelta` callback the port may call per chunk - user-visible text,
34
+ reasoning text, the raw argument text of the tool call being formed, or a `usage` delta reporting
35
+ the decision's settled token counts (optionally attributed to a provider and model, for observers
36
+ to sum across the run). Deltas are transient
37
+ observer data for live UIs (`@nifrajs/ag-ui` projects them onto `TEXT_MESSAGE_*`, `REASONING_*`,
38
+ and `TOOL_CALL_ARGS` frames): they are never validated, persisted, or replayed, and a failing sink
39
+ never fails the model step. `combineAgentDeltaSinks(a, b, ...)` fans deltas out the way
40
+ `combineAgentTelemetry` fans evidence.
41
+
42
+ `createAgentSharedState(initial)` is the run's shared UI state channel: a JSON document any port or
43
+ tool executor patches with RFC 6902 operations (`add`, `replace`, `remove`), with subscribers
44
+ observing every applied batch. Patches apply atomically - an invalid op rejects the whole batch -
45
+ and prototype-grafting pointer segments are refused. The document is per-run observer data, not
46
+ turn state: nothing in it is persisted by the runtime. `@nifrajs/ag-ui` projects the channel onto
47
+ AG-UI `STATE_SNAPSHOT`/`STATE_DELTA` events.
48
+
49
+ SSE streams are resumable: give `mountAgent` (or `@nifrajs/ag-ui`'s `mountAgUI`) an `evidenceLog`
50
+ and `step` frames carry `id: <seq>`. A client that loses the connection re-POSTs the same `turnId`
51
+ with a `Last-Event-ID` header and receives the missed evidence, rejoining a still-running turn live
52
+ or replaying the stored terminal frame - the run is never re-executed.
53
+ `createMemoryAgentEvidenceLog` (from `@nifrajs/agent/events`) is the single-process dev/test
54
+ reference; a durable, multi-process log is an adapter implementing the same `AgentEvidenceLog`
55
+ interface.
56
+
21
57
  Execution policies can be required by a tool contract. `createLocalProcessAdapter` applies cwd and
22
58
  environment filtering, timeouts, and cancellation to child processes. The local adapter is NOT a
23
59
  security boundary. Without OS-level sandboxing it contains crashes and accidents, not hostile code.
@@ -0,0 +1,157 @@
1
+ /**
2
+ * Provider-neutral deployment lifecycle contracts.
3
+ *
4
+ * A deployment adapter is an execution seam, not a sandbox claim. The host owns activation,
5
+ * authority, cancellation, and cleanup. Public reference adapters may be local, CI, or replay, but
6
+ * only a capability report declaring real OS isolation can admit a hostile-code plan.
7
+ */
8
+ export type DeploymentRuntime = "local" | "ci" | "replay" | "worker" | "unknown";
9
+ export type DeploymentNetwork = "none" | "outbound" | "inbound" | "unrestricted";
10
+ export type DeploymentFilesystem = "none" | "workspace" | "host";
11
+ export type DeploymentProcess = "none" | "child";
12
+ export type DeploymentSecrets = "none" | "caller";
13
+ export type DeploymentCancellation = "none" | "cooperative" | "forced";
14
+ export type HostileCodeIsolation = "none" | "os";
15
+ export interface DeploymentCapabilities {
16
+ readonly runtime: DeploymentRuntime;
17
+ readonly network: DeploymentNetwork;
18
+ readonly filesystem: DeploymentFilesystem;
19
+ readonly process: DeploymentProcess;
20
+ readonly secrets: DeploymentSecrets;
21
+ readonly workspace: {
22
+ readonly mode: "none" | "scoped";
23
+ readonly maxBytes: number;
24
+ };
25
+ readonly cancellation: DeploymentCancellation;
26
+ readonly hostileCodeIsolation: HostileCodeIsolation;
27
+ }
28
+ export interface DeploymentCapabilityReport {
29
+ readonly schemaVersion: 1;
30
+ readonly adapterId: string;
31
+ readonly capabilities: DeploymentCapabilities;
32
+ readonly limitations: readonly string[];
33
+ }
34
+ export interface DeploymentAuthority {
35
+ readonly workspaceMaxBytes: number;
36
+ readonly deadlineAt?: number;
37
+ readonly cancellation: DeploymentCancellation;
38
+ readonly hostileCodeIsolation: HostileCodeIsolation;
39
+ }
40
+ export interface DeploymentActivationOptions {
41
+ /** Host-owned approval obtained from a separately reviewed/certified isolation decision. */
42
+ readonly approved?: boolean;
43
+ }
44
+ export interface AgentDeploymentPlan {
45
+ readonly deploymentId: string;
46
+ readonly hostileCode?: boolean;
47
+ readonly workspaceMaxBytes?: number;
48
+ readonly deadlineAt?: number;
49
+ }
50
+ export interface DeploymentPrepareRequest {
51
+ readonly plan: AgentDeploymentPlan;
52
+ readonly authority: DeploymentAuthority;
53
+ readonly signal: AbortSignal;
54
+ }
55
+ export interface DeploymentPrepareResult {
56
+ readonly deploymentId: string;
57
+ readonly state: "prepared";
58
+ readonly preparedRef: string;
59
+ }
60
+ export interface DeploymentStartRequest {
61
+ readonly deploymentId: string;
62
+ readonly preparedRef: string;
63
+ readonly authority: DeploymentAuthority;
64
+ readonly signal: AbortSignal;
65
+ }
66
+ export interface DeploymentStartResult {
67
+ readonly deploymentId: string;
68
+ readonly state: "running";
69
+ readonly handleRef: string;
70
+ }
71
+ export interface DeploymentInspectRequest {
72
+ readonly deploymentId: string;
73
+ readonly handleRef?: string;
74
+ readonly signal: AbortSignal;
75
+ }
76
+ export type DeploymentState = "prepared" | "running" | "cancelled" | "disposed";
77
+ export interface DeploymentInspection {
78
+ readonly deploymentId: string;
79
+ readonly state: DeploymentState;
80
+ readonly handleRef?: string;
81
+ }
82
+ export interface DeploymentCancelRequest {
83
+ readonly deploymentId: string;
84
+ readonly preparedRef?: string;
85
+ readonly handleRef?: string;
86
+ readonly signal: AbortSignal;
87
+ }
88
+ export interface DeploymentCancelResult {
89
+ readonly deploymentId: string;
90
+ readonly state: "cancelled";
91
+ }
92
+ export interface DeploymentDisposeRequest {
93
+ readonly deploymentId: string;
94
+ readonly preparedRef?: string;
95
+ readonly handleRef?: string;
96
+ readonly signal: AbortSignal;
97
+ }
98
+ export interface DeploymentDisposeResult {
99
+ readonly deploymentId: string;
100
+ readonly state: "disposed";
101
+ }
102
+ export interface AgentDeploymentAdapter {
103
+ readonly id: string;
104
+ capabilityReport(): DeploymentCapabilityReport | PromiseLike<DeploymentCapabilityReport>;
105
+ prepare(request: DeploymentPrepareRequest): DeploymentPrepareResult | PromiseLike<DeploymentPrepareResult>;
106
+ start(request: DeploymentStartRequest): DeploymentStartResult | PromiseLike<DeploymentStartResult>;
107
+ inspect(request: DeploymentInspectRequest): DeploymentInspection | PromiseLike<DeploymentInspection>;
108
+ cancel(request: DeploymentCancelRequest): DeploymentCancelResult | PromiseLike<DeploymentCancelResult>;
109
+ dispose(request: DeploymentDisposeRequest): DeploymentDisposeResult | PromiseLike<DeploymentDisposeResult>;
110
+ }
111
+ export type DeploymentEvidence = {
112
+ readonly kind: "prepared" | "started" | "inspected" | "cancelled" | "disposed" | "failed";
113
+ readonly deploymentId: string;
114
+ readonly state: DeploymentState | "new";
115
+ readonly code?: DeploymentErrorCode;
116
+ };
117
+ export type DeploymentErrorCode = "invalid_capabilities" | "capability_denied" | "hostile_code_requires_isolation" | "authority_expanded" | "invalid_plan" | "invalid_transition" | "malformed_callback" | "adapter_error" | "cancelled";
118
+ export declare class DeploymentError extends Error {
119
+ readonly code: DeploymentErrorCode;
120
+ constructor(code: DeploymentErrorCode);
121
+ }
122
+ /** Parse an untrusted capability report before the host admits an adapter. */
123
+ export declare function parseDeploymentCapabilityReport(value: unknown): DeploymentCapabilityReport;
124
+ export declare function parseDeploymentPlan(value: unknown): AgentDeploymentPlan;
125
+ /** Prove a child deployment authority is a subset of its parent's authority. */
126
+ export declare function assertDeploymentAuthorityMonotonic(parent: DeploymentAuthority, child: DeploymentAuthority): void;
127
+ export declare function createDeploymentAuthority(input: {
128
+ readonly workspaceMaxBytes: number;
129
+ readonly deadlineAt?: number;
130
+ readonly cancellation?: DeploymentCancellation;
131
+ readonly hostileCodeIsolation?: HostileCodeIsolation;
132
+ }): DeploymentAuthority;
133
+ /** Host-owned deterministic lifecycle wrapper for an adapter. */
134
+ export declare class AgentDeployment {
135
+ private readonly adapter;
136
+ private readonly signal;
137
+ readonly id: string;
138
+ private deploymentId;
139
+ private state;
140
+ private preparedRef;
141
+ private handleRef;
142
+ private report;
143
+ private readonly evidence;
144
+ constructor(adapter: AgentDeploymentAdapter, authority: DeploymentAuthority, signal?: AbortSignal, options?: DeploymentActivationOptions);
145
+ private readonly authority;
146
+ private readonly approved;
147
+ get lifecycleState(): "new" | DeploymentState;
148
+ get evidenceRecords(): readonly DeploymentEvidence[];
149
+ capabilityReport(): Promise<DeploymentCapabilityReport>;
150
+ prepare(planInput: AgentDeploymentPlan | unknown): Promise<DeploymentPrepareResult>;
151
+ start(): Promise<DeploymentStartResult>;
152
+ inspect(): Promise<DeploymentInspection>;
153
+ cancel(): Promise<DeploymentCancelResult>;
154
+ dispose(): Promise<DeploymentDisposeResult>;
155
+ private fail;
156
+ }
157
+ //# sourceMappingURL=deployment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployment.d.ts","sourceRoot":"","sources":["../src/deployment.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,IAAI,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAA;AAChF,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,cAAc,CAAA;AAChF,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAA;AAChE,MAAM,MAAM,iBAAiB,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AAQ,CAAC,oBAAoB,CAAC,EAAE,oBAAoB,CAAA;CACrD,GAAG,mBAAmB,CAOtB;AAED,iEAAiE;AACjE,qBAAa,eAAe;IAUxB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAExB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAXzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,YAAY,CAAoB;IACxC,OAAO,CAAC,KAAK,CAAiC;IAC9C,OAAO,CAAC,WAAW,CAAoB;IACvC,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,MAAM,CAAwC;IACtD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA2B;gBAGjC,OAAO,EAAE,sBAAsB,EAChD,SAAS,EAAE,mBAAmB,EACb,MAAM,GAAE,WAA0C,EACnE,OAAO,GAAE,2BAAgC;IAO3C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;IAC/C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAElC,IAAI,cAAc,IAAI,KAAK,GAAG,eAAe,CAE5C;IAED,IAAI,eAAe,IAAI,SAAS,kBAAkB,EAAE,CAEnD;IAEK,gBAAgB,IAAI,OAAO,CAAC,0BAA0B,CAAC;IAWvD,OAAO,CAAC,SAAS,EAAE,mBAAmB,GAAG,OAAO,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAqBnF,KAAK,IAAI,OAAO,CAAC,qBAAqB,CAAC;IA2BvC,OAAO,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAuBxC,MAAM,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAsBzC,OAAO,IAAI,OAAO,CAAC,uBAAuB,CAAC;IA0BjD,OAAO,CAAC,IAAI;CASb"}
@@ -0,0 +1,374 @@
1
+ /**
2
+ * Provider-neutral deployment lifecycle contracts.
3
+ *
4
+ * A deployment adapter is an execution seam, not a sandbox claim. The host owns activation,
5
+ * authority, cancellation, and cleanup. Public reference adapters may be local, CI, or replay, but
6
+ * only a capability report declaring real OS isolation can admit a hostile-code plan.
7
+ */
8
+ const TOKEN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;
9
+ const MAX_LIMIT = 10_000_000_000;
10
+ export class DeploymentError extends Error {
11
+ code;
12
+ constructor(code) {
13
+ super(`deployment ${code}`);
14
+ this.code = code;
15
+ this.name = "DeploymentError";
16
+ }
17
+ }
18
+ function isRecord(value) {
19
+ return typeof value === "object" && value !== null && !Array.isArray(value);
20
+ }
21
+ function boundedToken(value, _label, code = "invalid_plan") {
22
+ if (typeof value !== "string" || !TOKEN.test(value))
23
+ throw new DeploymentError(code);
24
+ return value;
25
+ }
26
+ function boundedLimit(value, _label, code = "invalid_plan") {
27
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0 || value > MAX_LIMIT)
28
+ throw new DeploymentError(code);
29
+ return value;
30
+ }
31
+ function exactKeys(value, keys, code) {
32
+ for (const key of Object.keys(value))
33
+ if (!keys.has(key))
34
+ throw new DeploymentError(code);
35
+ }
36
+ const RUNTIMES = new Set(["local", "ci", "replay", "worker", "unknown"]);
37
+ const NETWORKS = new Set(["none", "outbound", "inbound", "unrestricted"]);
38
+ const FILESYSTEMS = new Set(["none", "workspace", "host"]);
39
+ const PROCESSES = new Set(["none", "child"]);
40
+ const SECRETS = new Set(["none", "caller"]);
41
+ const CANCELLATIONS = new Set(["none", "cooperative", "forced"]);
42
+ const ISOLATIONS = new Set(["none", "os"]);
43
+ function member(value, values) {
44
+ if (typeof value !== "string" || !values.has(value))
45
+ throw new DeploymentError("invalid_capabilities");
46
+ return value;
47
+ }
48
+ /** Parse an untrusted capability report before the host admits an adapter. */
49
+ export function parseDeploymentCapabilityReport(value) {
50
+ if (!isRecord(value))
51
+ throw new DeploymentError("invalid_capabilities");
52
+ exactKeys(value, new Set(["schemaVersion", "adapterId", "capabilities", "limitations"]), "invalid_capabilities");
53
+ if (value.schemaVersion !== 1)
54
+ throw new DeploymentError("invalid_capabilities");
55
+ const adapterId = boundedToken(value.adapterId, "adapterId", "invalid_capabilities");
56
+ if (!isRecord(value.capabilities))
57
+ throw new DeploymentError("invalid_capabilities");
58
+ const capabilities = value.capabilities;
59
+ exactKeys(capabilities, new Set([
60
+ "runtime",
61
+ "network",
62
+ "filesystem",
63
+ "process",
64
+ "secrets",
65
+ "workspace",
66
+ "cancellation",
67
+ "hostileCodeIsolation",
68
+ ]), "invalid_capabilities");
69
+ if (!isRecord(capabilities.workspace))
70
+ throw new DeploymentError("invalid_capabilities");
71
+ exactKeys(capabilities.workspace, new Set(["mode", "maxBytes"]), "invalid_capabilities");
72
+ const workspaceMode = member(capabilities.workspace.mode, new Set(["none", "scoped"]));
73
+ const maxBytes = boundedLimit(capabilities.workspace.maxBytes, "workspace.maxBytes", "invalid_capabilities");
74
+ if (workspaceMode === "none" && maxBytes !== 0)
75
+ throw new DeploymentError("invalid_capabilities");
76
+ const limitations = value.limitations;
77
+ if (!Array.isArray(limitations) ||
78
+ limitations.length > 32 ||
79
+ limitations.some((item) => typeof item !== "string" || !TOKEN.test(item)))
80
+ throw new DeploymentError("invalid_capabilities");
81
+ return Object.freeze({
82
+ schemaVersion: 1,
83
+ adapterId,
84
+ capabilities: Object.freeze({
85
+ runtime: member(capabilities.runtime, RUNTIMES),
86
+ network: member(capabilities.network, NETWORKS),
87
+ filesystem: member(capabilities.filesystem, FILESYSTEMS),
88
+ process: member(capabilities.process, PROCESSES),
89
+ secrets: member(capabilities.secrets, SECRETS),
90
+ workspace: Object.freeze({ mode: workspaceMode, maxBytes }),
91
+ cancellation: member(capabilities.cancellation, CANCELLATIONS),
92
+ hostileCodeIsolation: member(capabilities.hostileCodeIsolation, ISOLATIONS),
93
+ }),
94
+ limitations: Object.freeze([...limitations]),
95
+ });
96
+ }
97
+ export function parseDeploymentPlan(value) {
98
+ if (!isRecord(value))
99
+ throw new DeploymentError("invalid_plan");
100
+ exactKeys(value, new Set(["deploymentId", "hostileCode", "workspaceMaxBytes", "deadlineAt"]), "invalid_plan");
101
+ const deploymentId = boundedToken(value.deploymentId, "deploymentId");
102
+ if (value.hostileCode !== undefined && typeof value.hostileCode !== "boolean")
103
+ throw new DeploymentError("invalid_plan");
104
+ const workspaceMaxBytes = value.workspaceMaxBytes === undefined
105
+ ? undefined
106
+ : boundedLimit(value.workspaceMaxBytes, "workspaceMaxBytes", "invalid_plan");
107
+ const rawDeadlineAt = value.deadlineAt;
108
+ const deadlineAt = rawDeadlineAt === undefined
109
+ ? undefined
110
+ : typeof rawDeadlineAt === "number"
111
+ ? rawDeadlineAt
112
+ : null;
113
+ if (deadlineAt === null ||
114
+ (deadlineAt !== undefined && (!Number.isSafeInteger(deadlineAt) || deadlineAt <= 0)))
115
+ throw new DeploymentError("invalid_plan");
116
+ return Object.freeze({
117
+ deploymentId,
118
+ ...(value.hostileCode === undefined ? {} : { hostileCode: value.hostileCode }),
119
+ ...(workspaceMaxBytes === undefined ? {} : { workspaceMaxBytes }),
120
+ ...(deadlineAt === undefined ? {} : { deadlineAt }),
121
+ });
122
+ }
123
+ function parseRef(value) {
124
+ if (typeof value !== "string" || !TOKEN.test(value))
125
+ throw new DeploymentError("malformed_callback");
126
+ return value;
127
+ }
128
+ function parseCallbackState(value, expected) {
129
+ return isRecord(value) && value.state === expected;
130
+ }
131
+ function parsePrepare(value, deploymentId) {
132
+ if (!isRecord(value) ||
133
+ value.deploymentId !== deploymentId ||
134
+ !parseCallbackState(value, "prepared"))
135
+ throw new DeploymentError("malformed_callback");
136
+ return Object.freeze({
137
+ deploymentId,
138
+ state: "prepared",
139
+ preparedRef: parseRef(value.preparedRef),
140
+ });
141
+ }
142
+ function parseStart(value, deploymentId) {
143
+ if (!isRecord(value) ||
144
+ value.deploymentId !== deploymentId ||
145
+ !parseCallbackState(value, "running"))
146
+ throw new DeploymentError("malformed_callback");
147
+ return Object.freeze({ deploymentId, state: "running", handleRef: parseRef(value.handleRef) });
148
+ }
149
+ function parseInspection(value, deploymentId) {
150
+ if (!isRecord(value) || value.deploymentId !== deploymentId || typeof value.state !== "string")
151
+ throw new DeploymentError("malformed_callback");
152
+ if (!["prepared", "running", "cancelled", "disposed"].includes(value.state))
153
+ throw new DeploymentError("malformed_callback");
154
+ const handleRef = value.handleRef === undefined ? undefined : parseRef(value.handleRef);
155
+ return Object.freeze({
156
+ deploymentId,
157
+ state: value.state,
158
+ ...(handleRef === undefined ? {} : { handleRef }),
159
+ });
160
+ }
161
+ function parseTerminal(value, deploymentId, state) {
162
+ if (!isRecord(value) || value.deploymentId !== deploymentId || !parseCallbackState(value, state))
163
+ throw new DeploymentError("malformed_callback");
164
+ return Object.freeze({ deploymentId, state });
165
+ }
166
+ function validateAuthority(authority) {
167
+ const workspaceMaxBytes = boundedLimit(authority.workspaceMaxBytes, "authority.workspaceMaxBytes", "authority_expanded");
168
+ if (authority.deadlineAt !== undefined &&
169
+ (!Number.isSafeInteger(authority.deadlineAt) || authority.deadlineAt <= 0))
170
+ throw new DeploymentError("authority_expanded");
171
+ if (!CANCELLATIONS.has(authority.cancellation) || !ISOLATIONS.has(authority.hostileCodeIsolation))
172
+ throw new DeploymentError("authority_expanded");
173
+ return Object.freeze({ ...authority, workspaceMaxBytes });
174
+ }
175
+ /** Prove a child deployment authority is a subset of its parent's authority. */
176
+ export function assertDeploymentAuthorityMonotonic(parent, child) {
177
+ const p = validateAuthority(parent);
178
+ const c = validateAuthority(child);
179
+ if (c.workspaceMaxBytes > p.workspaceMaxBytes)
180
+ throw new DeploymentError("authority_expanded");
181
+ if (p.deadlineAt !== undefined && (c.deadlineAt === undefined || c.deadlineAt > p.deadlineAt))
182
+ throw new DeploymentError("authority_expanded");
183
+ if (p.cancellation === "none" && c.cancellation !== "none")
184
+ throw new DeploymentError("authority_expanded");
185
+ if (p.cancellation === "cooperative" && c.cancellation === "forced")
186
+ throw new DeploymentError("authority_expanded");
187
+ if (p.hostileCodeIsolation === "none" && c.hostileCodeIsolation !== "none")
188
+ throw new DeploymentError("authority_expanded");
189
+ }
190
+ function assertCapabilityPlan(report, plan, authority, approved) {
191
+ const capabilities = report.capabilities;
192
+ if (plan.hostileCode === true && capabilities.hostileCodeIsolation !== "os")
193
+ throw new DeploymentError("hostile_code_requires_isolation");
194
+ if (plan.hostileCode === true && authority.hostileCodeIsolation !== "os")
195
+ throw new DeploymentError("hostile_code_requires_isolation");
196
+ if (plan.hostileCode === true && !approved)
197
+ throw new DeploymentError("hostile_code_requires_isolation");
198
+ if (plan.workspaceMaxBytes !== undefined &&
199
+ (capabilities.workspace.mode !== "scoped" ||
200
+ plan.workspaceMaxBytes > capabilities.workspace.maxBytes))
201
+ throw new DeploymentError("capability_denied");
202
+ if (plan.workspaceMaxBytes !== undefined && plan.workspaceMaxBytes > authority.workspaceMaxBytes)
203
+ throw new DeploymentError("authority_expanded");
204
+ if (authority.cancellation !== "none" && capabilities.cancellation === "none")
205
+ throw new DeploymentError("capability_denied");
206
+ if (plan.deadlineAt !== undefined &&
207
+ authority.deadlineAt !== undefined &&
208
+ plan.deadlineAt > authority.deadlineAt)
209
+ throw new DeploymentError("authority_expanded");
210
+ }
211
+ export function createDeploymentAuthority(input) {
212
+ return validateAuthority({
213
+ workspaceMaxBytes: input.workspaceMaxBytes,
214
+ ...(input.deadlineAt === undefined ? {} : { deadlineAt: input.deadlineAt }),
215
+ cancellation: input.cancellation ?? "cooperative",
216
+ hostileCodeIsolation: input.hostileCodeIsolation ?? "none",
217
+ });
218
+ }
219
+ /** Host-owned deterministic lifecycle wrapper for an adapter. */
220
+ export class AgentDeployment {
221
+ adapter;
222
+ signal;
223
+ id;
224
+ deploymentId;
225
+ state = "new";
226
+ preparedRef;
227
+ handleRef;
228
+ report;
229
+ evidence = [];
230
+ constructor(adapter, authority, signal = new AbortController().signal, options = {}) {
231
+ this.adapter = adapter;
232
+ this.signal = signal;
233
+ this.id = boundedToken(adapter.id, "adapter.id");
234
+ this.authority = validateAuthority(authority);
235
+ this.approved = options.approved === true;
236
+ }
237
+ authority;
238
+ approved;
239
+ get lifecycleState() {
240
+ return this.state;
241
+ }
242
+ get evidenceRecords() {
243
+ return Object.freeze([...this.evidence]);
244
+ }
245
+ async capabilityReport() {
246
+ if (this.report !== undefined)
247
+ return this.report;
248
+ try {
249
+ this.report = parseDeploymentCapabilityReport(await this.adapter.capabilityReport());
250
+ if (this.report.adapterId !== this.id)
251
+ throw new DeploymentError("invalid_capabilities");
252
+ return this.report;
253
+ }
254
+ catch (error) {
255
+ throw asDeploymentError(error, "invalid_capabilities");
256
+ }
257
+ }
258
+ async prepare(planInput) {
259
+ if (this.state !== "new")
260
+ return this.fail("invalid_transition");
261
+ const plan = parseDeploymentPlan(planInput);
262
+ this.deploymentId = plan.deploymentId;
263
+ if (this.signal.aborted)
264
+ return this.fail("cancelled");
265
+ const report = await this.capabilityReport();
266
+ assertCapabilityPlan(report, plan, this.authority, this.approved);
267
+ try {
268
+ const result = parsePrepare(await this.adapter.prepare({ plan, authority: this.authority, signal: this.signal }), plan.deploymentId);
269
+ this.preparedRef = result.preparedRef;
270
+ this.state = "prepared";
271
+ this.evidence.push({ kind: "prepared", deploymentId: plan.deploymentId, state: "prepared" });
272
+ return result;
273
+ }
274
+ catch (error) {
275
+ return this.fail(asDeploymentError(error, "adapter_error").code);
276
+ }
277
+ }
278
+ async start() {
279
+ if (this.state !== "prepared" ||
280
+ this.preparedRef === undefined ||
281
+ this.deploymentId === undefined)
282
+ return this.fail("invalid_transition");
283
+ if (this.signal.aborted)
284
+ return this.fail("cancelled");
285
+ try {
286
+ const result = parseStart(await this.adapter.start({
287
+ deploymentId: this.deploymentId,
288
+ preparedRef: this.preparedRef,
289
+ authority: this.authority,
290
+ signal: this.signal,
291
+ }), this.deploymentId);
292
+ this.handleRef = result.handleRef;
293
+ this.state = "running";
294
+ this.evidence.push({ kind: "started", deploymentId: this.deploymentId, state: "running" });
295
+ return result;
296
+ }
297
+ catch (error) {
298
+ return this.fail(asDeploymentError(error, "adapter_error").code);
299
+ }
300
+ }
301
+ async inspect() {
302
+ if (this.state === "new" || this.state === "disposed" || this.deploymentId === undefined)
303
+ return this.fail("invalid_transition");
304
+ try {
305
+ const result = parseInspection(await this.adapter.inspect({
306
+ deploymentId: this.deploymentId,
307
+ ...(this.handleRef === undefined ? {} : { handleRef: this.handleRef }),
308
+ signal: this.signal,
309
+ }), this.deploymentId);
310
+ this.evidence.push({
311
+ kind: "inspected",
312
+ deploymentId: this.deploymentId,
313
+ state: result.state,
314
+ });
315
+ return result;
316
+ }
317
+ catch (error) {
318
+ return this.fail(asDeploymentError(error, "adapter_error").code);
319
+ }
320
+ }
321
+ async cancel() {
322
+ if ((this.state !== "prepared" && this.state !== "running") || this.deploymentId === undefined)
323
+ return this.fail("invalid_transition");
324
+ try {
325
+ const result = parseTerminal(await this.adapter.cancel({
326
+ deploymentId: this.deploymentId,
327
+ ...(this.preparedRef === undefined ? {} : { preparedRef: this.preparedRef }),
328
+ ...(this.handleRef === undefined ? {} : { handleRef: this.handleRef }),
329
+ signal: this.signal,
330
+ }), this.deploymentId, "cancelled");
331
+ this.state = "cancelled";
332
+ this.evidence.push({ kind: "cancelled", deploymentId: this.deploymentId, state: "cancelled" });
333
+ return result;
334
+ }
335
+ catch (error) {
336
+ return this.fail(asDeploymentError(error, "adapter_error").code);
337
+ }
338
+ }
339
+ async dispose() {
340
+ if (this.state === "disposed")
341
+ return { deploymentId: this.deploymentId ?? this.id, state: "disposed" };
342
+ try {
343
+ const result = parseTerminal(await this.adapter.dispose({
344
+ deploymentId: this.deploymentId ?? this.id,
345
+ ...(this.preparedRef === undefined ? {} : { preparedRef: this.preparedRef }),
346
+ ...(this.handleRef === undefined ? {} : { handleRef: this.handleRef }),
347
+ signal: this.signal,
348
+ }), this.deploymentId ?? this.id, "disposed");
349
+ this.state = "disposed";
350
+ this.evidence.push({
351
+ kind: "disposed",
352
+ deploymentId: this.deploymentId ?? this.id,
353
+ state: "disposed",
354
+ });
355
+ return result;
356
+ }
357
+ catch (error) {
358
+ return this.fail(asDeploymentError(error, "adapter_error").code);
359
+ }
360
+ }
361
+ fail(code) {
362
+ this.evidence.push({
363
+ kind: "failed",
364
+ deploymentId: this.deploymentId ?? this.id,
365
+ state: this.state,
366
+ code,
367
+ });
368
+ throw new DeploymentError(code);
369
+ }
370
+ }
371
+ function asDeploymentError(error, fallback) {
372
+ return error instanceof DeploymentError ? error : new DeploymentError(fallback);
373
+ }
374
+ //# sourceMappingURL=deployment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployment.js","sourceRoot":"","sources":["../src/deployment.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,KAAK,GAAG,qCAAqC,CAAA;AACnD,MAAM,SAAS,GAAG,cAAc,CAAA;AAqJhC,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACnB;IAArB,YAAqB,IAAyB;QAC5C,KAAK,CAAC,cAAc,IAAI,EAAE,CAAC,CAAA;QADR,SAAI,GAAJ,IAAI,CAAqB;QAE5C,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAA;IAC/B,CAAC;CACF;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC7E,CAAC;AAED,SAAS,YAAY,CACnB,KAAc,EACd,MAAc,EACd,OAA4B,cAAc;IAE1C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,eAAe,CAAC,IAAI,CAAC,CAAA;IACpF,OAAO,KAAK,CAAA;AACd,CAAC;AAED,SAAS,YAAY,CACnB,KAAc,EACd,MAAc,EACd,OAA4B,cAAc;IAE1C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,SAAS;QAC7F,MAAM,IAAI,eAAe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