@byok-sdk/protocol 0.26.1 → 0.27.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/dist/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import { z } from 'zod';
2
+ import { Validator } from '@cfworker/json-schema';
2
3
 
3
- // src/agent-egress.ts
4
+ // src/capability-constants.ts
5
+ var INPUT_PREPARATION_WIRE_VERSION = 9;
4
6
  var AGENT_EGRESS_POLICY_CAPABILITY = "agent-egress-policy";
5
7
  var AGENT_EGRESS_RELIABLE_ACK_CAPABILITY = "agent-egress-reliable-ack";
6
8
  var AGENT_EGRESS_FRESH_SESSION_CAPABILITY = "agent-egress-fresh-session";
@@ -8,8 +10,602 @@ var AGENT_MESSAGE_EGRESS_CAPABILITY = "agent-message-egress";
8
10
  var AGENT_CONTENT_WORKSPACE_READ_CAPABILITY = "agent-content-workspace-read";
9
11
  var AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY = "agent-content-transcript-read";
10
12
  var AGENT_CONTENT_ARTIFACT_READ_CAPABILITY = "agent-content-artifact-read";
13
+ var AGENT_HOME_PROJECTION_CAPABILITY = "agent-home-projection";
14
+ var TERMINAL_PROJECTION_SELECTION_CAPABILITY = "terminal-projection-selection";
15
+ var HOST_MCP_TASK_CONTEXT_CAPABILITY = "host-mcp-task-context";
16
+ var PROVIDER_PROFILE_BINDING_CAPABILITY = "provider-profile-binding";
17
+ var PROVIDER_PROVISIONING_CAPABILITY = "provider-provisioning.v1";
18
+ var AGENT_MEMORY_INTENT_CAPABILITY = "agent-memory-intent.v1";
19
+ var AGENT_MEMORY_PROJECTION_CAPABILITY = "agent.memory.projection";
20
+ var AGENT_INPUT_PREPARATION_CAPABILITY = `agent-input-preparation-v${INPUT_PREPARATION_WIRE_VERSION}`;
21
+ var PREPARED_AGENT_MEMORY_MODES = ["none", "read", "read-write"];
22
+ function isPreparedAgentMemoryMode(value) {
23
+ return typeof value === "string" && PREPARED_AGENT_MEMORY_MODES.some((mode) => mode === value);
24
+ }
25
+
26
+ // src/version.ts
27
+ var MAILBOX_READ_AHEAD_MAX_SEQS = 4096;
28
+ var MAILBOX_READ_AHEAD_CAPABILITY = "mailbox-read-ahead";
29
+ var PROTOCOL_VERSION = 3;
30
+ var STRICT_AGENT_ONLY_CAPABILITY = "strict-agent-only";
31
+ var AGENT_HOME_READERS_CAPABILITY = "agent-home-readers";
32
+ var CUSTOM_HARNESS_CAPABILITY = "custom-harness";
33
+ var CAPABILITY_FLAGS = [
34
+ "steer",
35
+ "blob-upload",
36
+ "interactive-approval",
37
+ "approval_resolved",
38
+ "approval-targeting",
39
+ "dispatch-selection",
40
+ PROVIDER_PROFILE_BINDING_CAPABILITY,
41
+ "toolset-selection",
42
+ "agent-home-contract",
43
+ AGENT_HOME_READERS_CAPABILITY,
44
+ STRICT_AGENT_ONLY_CAPABILITY,
45
+ AGENT_EGRESS_POLICY_CAPABILITY,
46
+ AGENT_EGRESS_RELIABLE_ACK_CAPABILITY,
47
+ AGENT_MESSAGE_EGRESS_CAPABILITY,
48
+ AGENT_EGRESS_FRESH_SESSION_CAPABILITY,
49
+ AGENT_CONTENT_WORKSPACE_READ_CAPABILITY,
50
+ AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY,
51
+ AGENT_CONTENT_ARTIFACT_READ_CAPABILITY,
52
+ AGENT_HOME_PROJECTION_CAPABILITY,
53
+ AGENT_INPUT_PREPARATION_CAPABILITY,
54
+ TERMINAL_PROJECTION_SELECTION_CAPABILITY,
55
+ HOST_MCP_TASK_CONTEXT_CAPABILITY,
56
+ CUSTOM_HARNESS_CAPABILITY,
57
+ MAILBOX_READ_AHEAD_CAPABILITY,
58
+ PROVIDER_PROVISIONING_CAPABILITY,
59
+ AGENT_MEMORY_INTENT_CAPABILITY,
60
+ "agent-message-draft"
61
+ ];
62
+
63
+ // src/task-state.ts
64
+ var TASK_STATES = [
65
+ "Offered",
66
+ "Claimed",
67
+ "Running",
68
+ "AwaitApproval",
69
+ "Complete",
70
+ "Failed",
71
+ "Cancelled"
72
+ ];
73
+ var TASK_TRANSITIONS = {
74
+ Offered: ["Claimed", "Cancelled", "Failed"],
75
+ Claimed: ["Running", "Failed", "Cancelled"],
76
+ Running: ["AwaitApproval", "Complete", "Failed", "Cancelled"],
77
+ AwaitApproval: ["Running", "Failed", "Cancelled"],
78
+ Complete: [],
79
+ Failed: [],
80
+ Cancelled: []
81
+ };
82
+ function canTransition(from, to) {
83
+ return TASK_TRANSITIONS[from].includes(to);
84
+ }
85
+
86
+ // src/wire-additions.ts
87
+ var AGENT_OFFER_FIELDS = (surface) => [
88
+ { kind: "envelope", rule: "gated", surface, field: "dispatchSelection", capability: "dispatch-selection", advertisedBy: "device" },
89
+ { kind: "envelope", rule: "gated", surface, field: "requiredToolsets", capability: "toolset-selection", advertisedBy: "device" },
90
+ { kind: "envelope", rule: "gated", surface, field: "terminalProjection", capability: "terminal-projection-selection", advertisedBy: "device" },
91
+ { kind: "envelope", rule: "gated", surface, field: "homeAccess", capability: "agent-home-readers", advertisedBy: "device" }
92
+ ];
93
+ var EGRESS_OFFER_FIELDS = (surface) => [
94
+ { kind: "envelope", rule: "gated", surface, field: "messageEgress", capability: "agent-message-egress", advertisedBy: "device" },
95
+ ...AGENT_OFFER_FIELDS(surface)
96
+ ];
97
+ var WIRE_ADDITIONS = Object.freeze([
98
+ // Server to daemon: offers.
99
+ { kind: "envelope", rule: "gated", surface: "task.offer", field: "harnessId", capability: "custom-harness", advertisedBy: "device" },
100
+ { kind: "envelope", rule: "gated", surface: "task.offer_with_toolsets", field: "harnessId", capability: "custom-harness", advertisedBy: "device" },
101
+ { kind: "envelope", rule: "gated", surface: "task.offer_for_agent", capability: "agent-home-contract", advertisedBy: "device" },
102
+ ...AGENT_OFFER_FIELDS("task.offer_for_agent"),
103
+ { kind: "envelope", rule: "gated", surface: "task.offer_for_agent_with_egress", capability: "agent-home-contract", advertisedBy: "device" },
104
+ { kind: "envelope", rule: "gated", surface: "task.offer_for_agent_with_egress", capability: "agent-egress-policy", advertisedBy: "device" },
105
+ { kind: "envelope", rule: "gated", surface: "task.offer_for_agent_with_egress", capability: "agent-egress-reliable-ack", advertisedBy: "device" },
106
+ ...EGRESS_OFFER_FIELDS("task.offer_for_agent_with_egress"),
107
+ { kind: "envelope", rule: "gated", surface: "task.offer_for_agent_with_egress_fresh", capability: "agent-home-contract", advertisedBy: "device" },
108
+ { kind: "envelope", rule: "gated", surface: "task.offer_for_agent_with_egress_fresh", capability: "agent-egress-policy", advertisedBy: "device" },
109
+ { kind: "envelope", rule: "gated", surface: "task.offer_for_agent_with_egress_fresh", capability: "agent-egress-reliable-ack", advertisedBy: "device" },
110
+ { kind: "envelope", rule: "gated", surface: "task.offer_for_agent_with_egress_fresh", capability: "agent-egress-fresh-session", advertisedBy: "device" },
111
+ ...EGRESS_OFFER_FIELDS("task.offer_for_agent_with_egress_fresh"),
112
+ { kind: "envelope", rule: "gated", surface: "task.offer_prepared", capability: "agent-home-contract", advertisedBy: "device" },
113
+ { kind: "envelope", rule: "gated", surface: "task.offer_prepared", capability: "agent-input-preparation-v9", advertisedBy: "device" },
114
+ { kind: "envelope", rule: "gated", surface: "task.offer_prepared", capability: "agent-egress-policy", advertisedBy: "device" },
115
+ { kind: "envelope", rule: "gated", surface: "task.offer_prepared", capability: "agent-egress-reliable-ack", advertisedBy: "device" },
116
+ { kind: "envelope", rule: "gated", surface: "task.offer_prepared", capability: "agent-egress-fresh-session", advertisedBy: "device" },
117
+ ...EGRESS_OFFER_FIELDS("task.offer_prepared"),
118
+ // Server to daemon: Agent control messages.
119
+ { kind: "envelope", rule: "gated", surface: "agent.content.read", capability: "agent-home-contract", advertisedBy: "device" },
120
+ { kind: "envelope", rule: "gated", surface: "agent.content.read", capability: "agent-egress-policy", advertisedBy: "device" },
121
+ { kind: "envelope", rule: "gated", surface: "agent.content.read", capability: "agent-egress-reliable-ack", advertisedBy: "device" },
122
+ { kind: "envelope", rule: "gated", surface: "agent.content.read", field: "surface", value: "workspace", capability: "agent-content-workspace-read", advertisedBy: "device" },
123
+ { kind: "envelope", rule: "gated", surface: "agent.content.read", field: "surface", value: "transcript", capability: "agent-content-transcript-read", advertisedBy: "device" },
124
+ { kind: "envelope", rule: "gated", surface: "agent.content.read", field: "surface", value: "artifact", capability: "agent-content-artifact-read", advertisedBy: "device" },
125
+ { kind: "envelope", rule: "gated", surface: "agent.home.projection", capability: "agent-home-contract", advertisedBy: "device" },
126
+ { kind: "envelope", rule: "gated", surface: "agent.home.projection", capability: "agent-home-projection", advertisedBy: "device" },
127
+ { kind: "envelope", rule: "gated", surface: "agent.input.preparation", capability: "agent-home-contract", advertisedBy: "device" },
128
+ { kind: "envelope", rule: "gated", surface: "agent.input.preparation", capability: "agent-input-preparation-v9", advertisedBy: "device" },
129
+ { kind: "envelope", rule: "gated", surface: "provider.provisioning.available", capability: "provider-provisioning.v1", advertisedBy: "device" },
130
+ { kind: "envelope", rule: "gated", surface: "agent.memory.intent.available", capability: "agent-memory-intent.v1", advertisedBy: "device" },
131
+ // One optional runtime capability, shared by discovery and the claim snapshot.
132
+ { kind: "envelope", rule: "strip-safe", surface: "conn.hello", field: "runtimes[].capabilities.messageDraft" },
133
+ { kind: "envelope", rule: "strip-safe", surface: "conn.hello", field: "harnesses[].capabilities.messageDraft" },
134
+ { kind: "envelope", rule: "strip-safe", surface: "task.claim", field: "capabilities.messageDraft" },
135
+ // Daemon to server.
136
+ { kind: "envelope", rule: "gated", surface: "agent.message.draft", capability: "agent-message-draft", advertisedBy: "server" },
137
+ { kind: "envelope", rule: "gated", surface: "task.approval_resolved", capability: "approval_resolved", advertisedBy: "server" }
138
+ ]);
139
+ function requiredReceiverCapabilities(type, payload) {
140
+ const fields = payload !== null && typeof payload === "object" ? payload : {};
141
+ const required = [];
142
+ for (const entry of WIRE_ADDITIONS) {
143
+ if (entry.kind !== "envelope" || entry.rule !== "gated" || entry.surface !== type) continue;
144
+ if (entry.field !== void 0) {
145
+ const value = fields[entry.field];
146
+ if (value === void 0) continue;
147
+ if (entry.value !== void 0 && value !== entry.value) continue;
148
+ }
149
+ if (!required.includes(entry.capability)) required.push(entry.capability);
150
+ }
151
+ return required;
152
+ }
153
+ var CONTENT_HASH_RE = /^sha256:[0-9a-f]{64}$/;
154
+ var BlobRefSchema = z.object({
155
+ blobId: z.string(),
156
+ contentHash: z.string().regex(CONTENT_HASH_RE, 'contentHash must be "sha256:<64 lowercase hex>"'),
157
+ size: z.number().int().nonnegative(),
158
+ contentType: z.string(),
159
+ url: z.string().optional()
160
+ });
161
+ var ProviderProfileRefSchema = z.string().min(1).max(64).regex(/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/u, "provider profile refs must be lowercase portable identifiers");
162
+ var ProviderProfileRevisionSchema = z.string().regex(/^(?:0|[1-9][0-9]{0,19})$/u, "provider profile revision must be canonical decimal");
163
+ var ProviderProfileHashSchema = z.string().regex(/^sha256:[0-9a-f]{64}$/u, "provider profile hash must be lowercase sha256");
164
+ var PROVIDER_MODEL_CAPABILITIES = ["image-input"];
165
+ var ProviderModelCapabilitySchema = z.enum(PROVIDER_MODEL_CAPABILITIES);
166
+ var ProviderProfileBindingSchema = z.object({
167
+ profileRef: ProviderProfileRefSchema,
168
+ profileRevision: ProviderProfileRevisionSchema,
169
+ profileHash: ProviderProfileHashSchema,
170
+ modelId: z.string().min(1).max(160).regex(/^[^\u0000\r\n]+$/u),
171
+ requiredCapabilities: z.array(ProviderModelCapabilitySchema).max(8)
172
+ }).strict().superRefine((binding, ctx) => {
173
+ if (new Set(binding.requiredCapabilities).size !== binding.requiredCapabilities.length) {
174
+ ctx.addIssue({ code: "custom", path: ["requiredCapabilities"], message: "duplicate provider capability" });
175
+ }
176
+ });
177
+ var PROVIDER_SECRET_SEALING_KEY_REGISTER_OPERATION = "provider-secret-sealing-key.register";
178
+ var ProviderProvisioningAvailablePayloadSchema = z.object({
179
+ requestId: z.uuid()
180
+ }).strict();
181
+ var PROVIDER_PROVISIONING_OPERATIONS = ["configure", "update_model", "replace_secret", "delete"];
182
+ var ProviderProvisioningOperationSchema = z.enum(PROVIDER_PROVISIONING_OPERATIONS);
183
+ var PROVIDER_PROVISIONING_OPERATION_GENERATION_MAXIMUM = "9223372036854775807";
184
+ var ProviderProvisioningOperationGenerationSchema = z.string().regex(/^[1-9][0-9]{0,18}$/u, "operationGeneration must be a canonical positive decimal string").refine(
185
+ (value) => value.length < PROVIDER_PROVISIONING_OPERATION_GENERATION_MAXIMUM.length || value <= PROVIDER_PROVISIONING_OPERATION_GENERATION_MAXIMUM,
186
+ `operationGeneration must not exceed ${PROVIDER_PROVISIONING_OPERATION_GENERATION_MAXIMUM}`
187
+ );
188
+ var ProviderProvisioningOperationDigestSchema = z.string().regex(/^sha256:[0-9a-f]{64}$/u, "operationDigest must be lowercase sha256");
189
+ var PROVIDER_PROVISIONING_REJECTION_CODES = [
190
+ "request_invalid",
191
+ "request_conflict",
192
+ "request_expired",
193
+ "request_not_yet_valid",
194
+ "request_window_invalid",
195
+ "sealing_key_rotated",
196
+ "enrollment_mismatch",
197
+ "agent_not_placed",
198
+ "config_digest_mismatch",
199
+ "operation_generation_stale",
200
+ "profile_changed",
201
+ "profile_not_found",
202
+ "credential_scope_mismatch",
203
+ "provider_kind_unsupported",
204
+ "pi_model_invalid",
205
+ "capabilities_invalid",
206
+ "seal_open_failed",
207
+ "secret_invalid",
208
+ "local_commit_interrupted",
209
+ "secret_store_unavailable"
210
+ ];
211
+ var ProviderProvisioningRejectionCodeSchema = z.enum(PROVIDER_PROVISIONING_REJECTION_CODES);
212
+ var PROVIDER_PROVISIONING_HOST_TERMINAL_CODES = ["request_expired", "sealing_key_rotated"];
213
+ var ProviderProvisioningProviderStatusSchema = z.object({
214
+ profileRef: ProviderProfileRefSchema,
215
+ providerKind: z.string().min(1).max(64).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/u, "providerKind must be a lowercase portable identifier"),
216
+ modelId: z.string().min(1).max(160).regex(/^[^\u0000\r\n]+$/u),
217
+ capabilities: z.array(ProviderModelCapabilitySchema).max(8),
218
+ secretConfigured: z.boolean()
219
+ }).strict().superRefine((status, ctx) => {
220
+ if (new Set(status.capabilities).size !== status.capabilities.length) {
221
+ ctx.addIssue({ code: "custom", path: ["capabilities"], message: "duplicate provider capability" });
222
+ }
223
+ });
224
+ var PROVIDER_PROVISIONING_KEY_CHECK_RESULTS = [
225
+ "ok",
226
+ "credential_rejected",
227
+ "rate_limited",
228
+ "quota_or_billing",
229
+ "model_not_permitted",
230
+ "provider_error",
231
+ "unreachable",
232
+ "timeout",
233
+ "not_run"
234
+ ];
235
+ var ProviderProvisioningKeyCheckResultSchema = z.enum(PROVIDER_PROVISIONING_KEY_CHECK_RESULTS);
236
+ var ProviderProvisioningKeyCheckSchema = z.object({
237
+ result: ProviderProvisioningKeyCheckResultSchema
238
+ }).strict();
239
+ var completionIdentity = {
240
+ requestId: z.uuid(),
241
+ operation: ProviderProvisioningOperationSchema,
242
+ operationGeneration: ProviderProvisioningOperationGenerationSchema,
243
+ operationDigest: ProviderProvisioningOperationDigestSchema
244
+ };
245
+ var AppliedCompletionSchema = z.object({
246
+ outcome: z.literal("applied"),
247
+ ...completionIdentity,
248
+ providerStatus: ProviderProvisioningProviderStatusSchema.nullable(),
249
+ binding: ProviderProfileBindingSchema.nullable(),
250
+ keyCheck: ProviderProvisioningKeyCheckSchema
251
+ }).strict();
252
+ var RejectedCompletionSchema = z.object({
253
+ outcome: z.literal("rejected"),
254
+ ...completionIdentity,
255
+ code: ProviderProvisioningRejectionCodeSchema
256
+ }).strict();
257
+ var ProviderProvisioningCompletionSchema = z.discriminatedUnion("outcome", [AppliedCompletionSchema, RejectedCompletionSchema]).superRefine((completion, ctx) => {
258
+ if (completion.outcome !== "applied") return;
259
+ const { operation, providerStatus, binding } = completion;
260
+ if (operation === "delete") {
261
+ if (completion.keyCheck.result !== "not_run") {
262
+ ctx.addIssue({ code: "custom", path: ["keyCheck", "result"], message: "an applied delete must report keyCheck not_run" });
263
+ }
264
+ if (providerStatus !== null) {
265
+ ctx.addIssue({ code: "custom", path: ["providerStatus"], message: "an applied delete reports no provider status" });
266
+ }
267
+ if (binding !== null) {
268
+ ctx.addIssue({ code: "custom", path: ["binding"], message: "an applied delete reports no binding" });
269
+ }
270
+ return;
271
+ }
272
+ if (providerStatus === null) {
273
+ ctx.addIssue({ code: "custom", path: ["providerStatus"], message: `an applied ${operation} must report provider status` });
274
+ }
275
+ if (binding === null) {
276
+ ctx.addIssue({ code: "custom", path: ["binding"], message: `an applied ${operation} must report its exact binding` });
277
+ }
278
+ if (providerStatus === null || binding === null) return;
279
+ if (providerStatus.profileRef !== binding.profileRef) {
280
+ ctx.addIssue({ code: "custom", path: ["binding", "profileRef"], message: "binding profileRef must equal providerStatus profileRef" });
281
+ }
282
+ if (providerStatus.modelId !== binding.modelId) {
283
+ ctx.addIssue({ code: "custom", path: ["binding", "modelId"], message: "binding modelId must equal providerStatus modelId" });
284
+ }
285
+ if ((operation === "configure" || operation === "replace_secret") && !providerStatus.secretConfigured) {
286
+ ctx.addIssue({
287
+ code: "custom",
288
+ path: ["providerStatus", "secretConfigured"],
289
+ message: `an applied ${operation} must report a configured secret`
290
+ });
291
+ }
292
+ });
293
+ var PROVIDER_PROVISIONING_DISPOSITIONS = ["recorded", "idempotent", "conflict", "host_terminal"];
294
+ var ProviderProvisioningDispositionSchema = z.enum(PROVIDER_PROVISIONING_DISPOSITIONS);
295
+ var ProviderProvisioningReadbackSchema = z.object({
296
+ tenantId: z.string().min(1),
297
+ deviceId: z.string().min(1),
298
+ requestId: z.uuid(),
299
+ disposition: ProviderProvisioningDispositionSchema,
300
+ completion: ProviderProvisioningCompletionSchema,
301
+ completedAt: z.iso.datetime({ offset: true })
302
+ }).strict().superRefine((readback, ctx) => {
303
+ if (readback.completion.requestId !== readback.requestId) {
304
+ ctx.addIssue({ code: "custom", path: ["completion", "requestId"], message: "completion requestId must equal readback requestId" });
305
+ }
306
+ if (readback.disposition === "host_terminal" && (readback.completion.outcome !== "rejected" || !PROVIDER_PROVISIONING_HOST_TERMINAL_CODES.includes(readback.completion.code))) {
307
+ ctx.addIssue({
308
+ code: "custom",
309
+ path: ["completion"],
310
+ message: `a host_terminal readback must carry a rejected completion with one of: ${PROVIDER_PROVISIONING_HOST_TERMINAL_CODES.join(", ")}`
311
+ });
312
+ }
313
+ });
314
+
315
+ // src/plain-json.ts
316
+ function isSameJsonData(a, b) {
317
+ if (a === null || b === null) return a === b;
318
+ const typeOfA = typeof a;
319
+ if (typeOfA !== typeof b) return false;
320
+ if (typeOfA !== "object") {
321
+ return a === b;
322
+ }
323
+ const aIsArray = Array.isArray(a);
324
+ if (aIsArray !== Array.isArray(b)) return false;
325
+ if (aIsArray) {
326
+ const arrayA = a;
327
+ const arrayB = b;
328
+ if (arrayA.length !== arrayB.length) return false;
329
+ for (let index = 0; index < arrayA.length; index += 1) {
330
+ if (!isSameJsonData(arrayA[index], arrayB[index])) return false;
331
+ }
332
+ return true;
333
+ }
334
+ const objectA = a;
335
+ const objectB = b;
336
+ const keysA = Object.keys(objectA);
337
+ const keysB = Object.keys(objectB);
338
+ if (keysA.length === 0) {
339
+ const prototypeA = Object.getPrototypeOf(objectA);
340
+ if (prototypeA !== Object.prototype && prototypeA !== null) return false;
341
+ }
342
+ if (keysA.length !== keysB.length) return false;
343
+ for (const key of keysA) {
344
+ if (!Object.prototype.hasOwnProperty.call(objectB, key)) return false;
345
+ if (!isSameJsonData(objectA[key], objectB[key])) return false;
346
+ }
347
+ return true;
348
+ }
349
+ function jsonDepthExceeds(value, limit) {
350
+ const stack = [{ node: value, depth: 0 }];
351
+ while (stack.length > 0) {
352
+ const { node, depth } = stack.pop();
353
+ if (node === null || typeof node !== "object") continue;
354
+ const next = depth + 1;
355
+ if (next > limit) return true;
356
+ const children = Array.isArray(node) ? node : Object.values(node);
357
+ for (const child of children) stack.push({ node: child, depth: next });
358
+ }
359
+ return false;
360
+ }
361
+ function canonicalizePlainJson(value, maxBytes, maxDepth) {
362
+ let json;
363
+ try {
364
+ json = JSON.stringify(value);
365
+ } catch {
366
+ return { ok: false, reason: "not-serializable" };
367
+ }
368
+ if (json === void 0) return { ok: false, reason: "not-serializable" };
369
+ const bytes = new TextEncoder().encode(json).length;
370
+ if (bytes > maxBytes) return { ok: false, reason: "over-cap", bytes };
371
+ const canonical = JSON.parse(json);
372
+ if (maxDepth !== void 0 && jsonDepthExceeds(canonical, maxDepth)) return { ok: false, reason: "too-deep", bytes };
373
+ if (!isSameJsonData(value, canonical)) return { ok: false, reason: "not-plain-json" };
374
+ return { ok: true, bytes, canonical };
375
+ }
376
+
377
+ // src/result-schema.ts
378
+ var RESULT_SCHEMA_MAX_BYTES = 16384;
379
+ var RESULT_OUTCOME_MAX_BYTES = 65536;
380
+ var RESULT_SCHEMA_MAX_DEPTH = 32;
381
+ var RESULT_JSON_MAX_DEPTH = 128;
382
+ var RESULT_ISSUES_MAX_COUNT = 20;
383
+ var RESULT_ISSUES_MAX_BYTES = 4096;
384
+ var ISSUE_STRING_MAX_LENGTH = 128;
385
+ var RESULT_SCHEMA_KEYWORDS = Object.freeze([
386
+ "type",
387
+ "properties",
388
+ "required",
389
+ "additionalProperties",
390
+ "items",
391
+ "enum",
392
+ "const",
393
+ "oneOf",
394
+ "minLength",
395
+ "maxLength",
396
+ "minItems",
397
+ "maxItems",
398
+ "minimum",
399
+ "maximum",
400
+ "description"
401
+ ]);
402
+ var RESULT_SCHEMA_INSTANCE_TYPES = Object.freeze([
403
+ "object",
404
+ "array",
405
+ "string",
406
+ "number",
407
+ "integer",
408
+ "boolean",
409
+ "null"
410
+ ]);
411
+ var KEYWORDS = new Set(RESULT_SCHEMA_KEYWORDS);
412
+ var INSTANCE_TYPES = new Set(RESULT_SCHEMA_INSTANCE_TYPES);
413
+ var encoder = new TextEncoder();
414
+ function cut(value) {
415
+ return value.length <= ISSUE_STRING_MAX_LENGTH ? value : `${value.slice(0, ISSUE_STRING_MAX_LENGTH - 1)}\u2026`;
416
+ }
417
+ var IssueSink = class {
418
+ issues = [];
419
+ truncated = false;
420
+ bytes = 2;
421
+ // "[]"
422
+ add(pointer, keyword, message) {
423
+ const issue = { pointer: cut(pointer), keyword: cut(keyword), message: cut(message) };
424
+ const size = encoder.encode(JSON.stringify(issue)).length + (this.issues.length === 0 ? 0 : 1);
425
+ if (this.issues.length >= RESULT_ISSUES_MAX_COUNT || this.bytes + size > RESULT_ISSUES_MAX_BYTES) {
426
+ this.truncated = true;
427
+ return;
428
+ }
429
+ this.issues.push(issue);
430
+ this.bytes += size;
431
+ }
432
+ get empty() {
433
+ return this.issues.length === 0 && !this.truncated;
434
+ }
435
+ };
436
+ function pointerTo(base, token) {
437
+ return `${base}/${String(token).replace(/~/g, "~0").replace(/\//g, "~1")}`;
438
+ }
439
+ function isObject(value) {
440
+ return value !== null && typeof value === "object" && !Array.isArray(value);
441
+ }
442
+ function isNonNegativeInteger(value) {
443
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
444
+ }
445
+ var LONE_SURROGATE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u;
446
+ function hasLoneSurrogate(value) {
447
+ const stack = [value];
448
+ while (stack.length > 0) {
449
+ const node = stack.pop();
450
+ if (typeof node === "string") {
451
+ if (LONE_SURROGATE.test(node)) return true;
452
+ } else if (Array.isArray(node)) {
453
+ for (const member of node) stack.push(member);
454
+ } else if (node !== null && typeof node === "object") {
455
+ for (const [key, member] of Object.entries(node)) {
456
+ if (LONE_SURROGATE.test(key)) return true;
457
+ stack.push(member);
458
+ }
459
+ }
460
+ }
461
+ return false;
462
+ }
463
+ function canonicalDocument(value, maxBytes) {
464
+ const check = canonicalizePlainJson(value, maxBytes, RESULT_JSON_MAX_DEPTH);
465
+ if (check.ok && hasLoneSurrogate(check.canonical)) return { ok: false, reason: "not-plain-json" };
466
+ return check;
467
+ }
468
+ function documentFailure(check, what, maxBytes) {
469
+ const sink = new IssueSink();
470
+ switch (check.reason) {
471
+ case "not-serializable":
472
+ sink.add("", check.reason, `${what} is not JSON-serializable`);
473
+ return { ok: false, reason: check.reason, issues: sink.issues, truncated: false };
474
+ case "not-plain-json":
475
+ sink.add("", check.reason, `${what} is not plain JSON data in well-formed Unicode`);
476
+ return { ok: false, reason: check.reason, issues: sink.issues, truncated: false };
477
+ case "over-cap":
478
+ sink.add("", check.reason, `${what} is ${check.bytes} bytes as canonical JSON (UTF-8); the cap is ${maxBytes}`);
479
+ return { ok: false, reason: check.reason, bytes: check.bytes, issues: sink.issues, truncated: false };
480
+ case "too-deep":
481
+ sink.add("", check.reason, `${what} nests JSON containers deeper than ${RESULT_JSON_MAX_DEPTH}`);
482
+ return { ok: false, reason: check.reason, bytes: check.bytes, issues: sink.issues, truncated: false };
483
+ }
484
+ }
485
+ function checkSubschema(node, pointer, depth, sink) {
486
+ if (!isObject(node)) {
487
+ sink.add(pointer, "schema", "a subschema must be a JSON object");
488
+ return;
489
+ }
490
+ if (depth > RESULT_SCHEMA_MAX_DEPTH) {
491
+ sink.add(pointer, "depth", `subschemas nest deeper than ${RESULT_SCHEMA_MAX_DEPTH} levels`);
492
+ return;
493
+ }
494
+ for (const key of Object.keys(node)) {
495
+ if (!KEYWORDS.has(key)) sink.add(pointerTo(pointer, key), key, "keyword is outside the result schema subset");
496
+ }
497
+ if (depth === 0 && node.type !== "object") {
498
+ sink.add(pointerTo(pointer, "type"), "type", "the root schema must declare type: 'object'");
499
+ }
500
+ if (Object.hasOwn(node, "type")) {
501
+ const type = node.type;
502
+ const valid = typeof type === "string" ? INSTANCE_TYPES.has(type) : Array.isArray(type) && type.length > 0 && type.every((member) => typeof member === "string" && INSTANCE_TYPES.has(member)) && new Set(type).size === type.length;
503
+ if (!valid) sink.add(pointerTo(pointer, "type"), "type", "must be a JSON type name or a non-empty array of unique type names");
504
+ }
505
+ if (Object.hasOwn(node, "properties")) {
506
+ const properties = node.properties;
507
+ const at = pointerTo(pointer, "properties");
508
+ if (!isObject(properties)) sink.add(at, "properties", "must be an object of subschemas");
509
+ else for (const [name, subschema] of Object.entries(properties)) checkSubschema(subschema, pointerTo(at, name), depth + 1, sink);
510
+ }
511
+ if (Object.hasOwn(node, "required")) {
512
+ const required = node.required;
513
+ if (!Array.isArray(required) || !required.every((name) => typeof name === "string") || new Set(required).size !== required.length) {
514
+ sink.add(pointerTo(pointer, "required"), "required", "must be an array of unique property names");
515
+ }
516
+ }
517
+ if (Object.hasOwn(node, "additionalProperties") && node.additionalProperties !== false) {
518
+ sink.add(pointerTo(pointer, "additionalProperties"), "additionalProperties", "only additionalProperties: false is allowed");
519
+ }
520
+ if (Object.hasOwn(node, "items")) {
521
+ if (!isObject(node.items)) sink.add(pointerTo(pointer, "items"), "items", "must be one subschema object");
522
+ else checkSubschema(node.items, pointerTo(pointer, "items"), depth + 1, sink);
523
+ }
524
+ if (Object.hasOwn(node, "enum") && (!Array.isArray(node.enum) || node.enum.length === 0)) {
525
+ sink.add(pointerTo(pointer, "enum"), "enum", "must be a non-empty array");
526
+ }
527
+ if (Object.hasOwn(node, "oneOf")) {
528
+ const oneOf = node.oneOf;
529
+ const at = pointerTo(pointer, "oneOf");
530
+ if (!Array.isArray(oneOf) || oneOf.length === 0) sink.add(at, "oneOf", "must be a non-empty array of subschemas");
531
+ else oneOf.forEach((subschema, index) => checkSubschema(subschema, pointerTo(at, index), depth + 1, sink));
532
+ }
533
+ for (const keyword of ["minLength", "maxLength", "minItems", "maxItems"]) {
534
+ if (Object.hasOwn(node, keyword) && !isNonNegativeInteger(node[keyword])) {
535
+ sink.add(pointerTo(pointer, keyword), keyword, "must be a non-negative integer");
536
+ }
537
+ }
538
+ for (const keyword of ["minimum", "maximum"]) {
539
+ if (Object.hasOwn(node, keyword) && typeof node[keyword] !== "number") {
540
+ sink.add(pointerTo(pointer, keyword), keyword, "must be a number");
541
+ }
542
+ }
543
+ if (Object.hasOwn(node, "description") && typeof node.description !== "string") {
544
+ sink.add(pointerTo(pointer, "description"), "description", "must be a string");
545
+ }
546
+ }
547
+ function checkResultSchema(schema) {
548
+ const document = canonicalDocument(schema, RESULT_SCHEMA_MAX_BYTES);
549
+ if (!document.ok) return documentFailure(document, "the result schema", RESULT_SCHEMA_MAX_BYTES);
550
+ const sink = new IssueSink();
551
+ checkSubschema(document.canonical, "", 0, sink);
552
+ if (!sink.empty) return { ok: false, reason: "not-subset", bytes: document.bytes, issues: sink.issues, truncated: sink.truncated };
553
+ return { ok: true, bytes: document.bytes, canonical: document.canonical };
554
+ }
555
+ function withoutPrototypes(value) {
556
+ if (value === null || typeof value !== "object") return value;
557
+ if (Array.isArray(value)) return value.map(withoutPrototypes);
558
+ const copy = /* @__PURE__ */ Object.create(null);
559
+ for (const [key, member] of Object.entries(value)) {
560
+ Object.defineProperty(copy, key, { value: withoutPrototypes(member), enumerable: true, writable: true, configurable: true });
561
+ }
562
+ return copy;
563
+ }
564
+ function fragmentToPointer(location) {
565
+ return decodeURI(location.startsWith("#") ? location.slice(1) : location);
566
+ }
567
+ function validateResultOutcome(schema, outcome) {
568
+ const admitted = checkResultSchema(schema);
569
+ if (!admitted.ok) {
570
+ return { ok: false, reason: "schema-not-admitted", bytes: admitted.bytes, issues: admitted.issues, truncated: admitted.truncated };
571
+ }
572
+ const document = canonicalDocument(outcome, RESULT_OUTCOME_MAX_BYTES);
573
+ if (!document.ok) return documentFailure(document, "the outcome", RESULT_OUTCOME_MAX_BYTES);
574
+ const validator = new Validator(withoutPrototypes(admitted.canonical), "2020-12", true);
575
+ const result = validator.validate(withoutPrototypes(document.canonical));
576
+ if (result.valid) return { ok: true, bytes: document.bytes, canonical: document.canonical };
577
+ const sink = new IssueSink();
578
+ for (const unit of result.errors) sink.add(fragmentToPointer(unit.instanceLocation), unit.keyword, unit.error);
579
+ return { ok: false, reason: "schema-mismatch", bytes: document.bytes, issues: sink.issues, truncated: sink.truncated };
580
+ }
581
+
582
+ // src/terminal-projection.ts
583
+ var TerminalProjectionContractSchema = z.string().min(1).max(128).regex(/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/u, "terminal projection contracts must be opaque lowercase ids");
584
+ var ResultDocumentSchemaSchema = z.custom().superRefine((value, ctx) => {
585
+ const check = checkResultSchema(value);
586
+ if (check.ok) return;
587
+ for (const issue of check.issues) {
588
+ ctx.addIssue({
589
+ code: "custom",
590
+ message: `result schema ${check.reason} at '${issue.pointer}' (${issue.keyword}): ${issue.message}`,
591
+ params: { reason: check.reason, pointer: issue.pointer, keyword: issue.keyword }
592
+ });
593
+ }
594
+ if (check.truncated) {
595
+ ctx.addIssue({ code: "custom", message: "result schema issues truncated", params: { reason: check.reason, truncated: true } });
596
+ }
597
+ });
598
+ var TerminalProjectionSelectionSchema = z.discriminatedUnion("mode", [
599
+ z.object({ mode: z.literal("none") }).strict(),
600
+ z.object({
601
+ mode: z.literal("result-document"),
602
+ contract: TerminalProjectionContractSchema,
603
+ schema: ResultDocumentSchemaSchema
604
+ }).strict()
605
+ ]);
11
606
  var POLICY_REVISION = z.string().min(1).max(160).regex(/^[^\u0000-\u001f\u007f\r\n]+$/u, "policyRevision must not contain control characters");
12
607
  var POSITIVE_LIMIT = z.number().int().positive().max(2147483647);
608
+ var AGENT_MESSAGE_DRAFT_FRAME_MAX_BYTES = 16 * 1024;
13
609
  var AGENT_MESSAGE_MAX_BYTES = 256 * 1024;
14
610
  var AgentMessageContractSchema = z.string().min(1).max(160).regex(/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/u, "message contract must be an opaque portable identifier");
15
611
  var AgentMessageContentTypeSchema = z.enum(["text/plain", "text/markdown"]);
@@ -92,31 +688,14 @@ var AgentContentReadDenialReasonSchema = z.enum([
92
688
  ]);
93
689
  var AgentEgressContentHashSchema = z.string().regex(/^sha256:[a-f0-9]{64}$/u, "contentHash must be a lowercase SHA-256 digest");
94
690
  var AgentEgressPolicyRevisionSchema = POLICY_REVISION;
95
- var AGENT_HOME_PROJECTION_CAPABILITY = "agent-home-projection";
96
- var AGENT_HOME_PROJECTION_MAX_BYTES = 64 * 1024;
97
- var AGENT_HOME_PROJECTION_PROFILE_REVISION_MAXIMUM = "9223372036854775807";
98
- var AgentHomeProjectionProfileRevisionSchema = z.string().regex(/^[1-9][0-9]{0,18}$/u, "profileRevision must be a canonical positive decimal string").refine(
99
- (value) => value.length < AGENT_HOME_PROJECTION_PROFILE_REVISION_MAXIMUM.length || value <= AGENT_HOME_PROJECTION_PROFILE_REVISION_MAXIMUM,
100
- `profileRevision must not exceed PostgreSQL BIGINT maximum ${AGENT_HOME_PROJECTION_PROFILE_REVISION_MAXIMUM}`
101
- );
102
- var AgentHomeProjectionHashSchema = AgentEgressContentHashSchema;
103
- var AgentHomeProjectionOutcomeSchema = z.enum(["applied", "idempotent", "stale", "conflict"]);
104
- var AgentHomeProjectionValueSchema = z.json().refine(
105
- (value) => new TextEncoder().encode(JSON.stringify(value)).byteLength <= AGENT_HOME_PROJECTION_MAX_BYTES,
106
- `projection must not exceed ${AGENT_HOME_PROJECTION_MAX_BYTES} UTF-8 JSON bytes`
107
- );
108
-
109
- // src/input-preparation-version.ts
110
- var INPUT_PREPARATION_WIRE_VERSION = 9;
111
691
 
112
692
  // src/input-preparation.ts
113
- var AGENT_INPUT_PREPARATION_CAPABILITY = `agent-input-preparation-v${INPUT_PREPARATION_WIRE_VERSION}`;
114
693
  var InputPreparationContentHashSchema = AgentEgressContentHashSchema;
115
694
  var OPAQUE_ID = z.string().min(1).max(512).regex(/^[^\u0000-\u001f\u007f]+$/u, "control identifiers must not contain control characters");
116
695
  var OPAQUE_TEXT = z.string().min(1).max(2048).regex(/^[^\u0000-\u001f\u007f]+$/u, "control text must not contain control characters");
117
696
  var InputPreparationPolicyRevisionSchema = OPAQUE_ID;
118
697
  var InputPreparationProfileIdSchema = OPAQUE_ID;
119
- var PreparedAgentMemoryModeSchema = z.enum(["none", "read", "read-write"]);
698
+ var PreparedAgentMemoryModeSchema = z.enum(PREPARED_AGENT_MEMORY_MODES);
120
699
  var InputPreparationSourceSchema = z.object({ revision: OPAQUE_ID, digest: OPAQUE_ID }).strict();
121
700
  var InputPreparationModelCostSchema = z.object({
122
701
  input: z.number().finite(),
@@ -317,6 +896,7 @@ var InputPreparationArtifactSummarySchema = z.object({
317
896
  toolNames: z.array(OPAQUE_ID)
318
897
  }).strict();
319
898
  var InputPreparationBindingSchema = z.object({
899
+ terminalProjection: TerminalProjectionSelectionSchema.optional(),
320
900
  agentMemory: PreparedAgentMemoryModeSchema,
321
901
  scopeId: OPAQUE_ID,
322
902
  deviceId: OPAQUE_ID,
@@ -327,259 +907,84 @@ var InputPreparationBindingSchema = z.object({
327
907
  target: InputPreparationCounterTargetSchema,
328
908
  policyRevision: OPAQUE_ID,
329
909
  runtime: InputPreparationRuntimeIdentitySchema,
330
- requestDigest: OPAQUE_ID,
331
- /**
332
- * The Host's accounting ruling this preparation was requested under,
333
- * copied verbatim. Absent when the request named none — never filled in,
334
- * and never narrowed to one the device would have chosen.
335
- */
336
- accountingPolicyRef: InputPreparationAccountingPolicyRefSchema.optional()
337
- }).strict();
338
- var InputPreparationReceiptSummarySchema = z.object({
339
- reference: OPAQUE_ID,
340
- state: InputPreparationStateSchema,
341
- binding: InputPreparationBindingSchema,
342
- artifact: InputPreparationArtifactSummarySchema.optional(),
343
- counter: InputPreparationCounterEvidenceSchema.optional(),
344
- ready: z.boolean(),
345
- readinessReasons: z.array(InputPreparationReadinessReasonSchema).max(16),
346
- detail: OPAQUE_ID.optional(),
347
- artifactExpiresAt: z.iso.datetime({ offset: true })
348
- }).strict().superRefine((value, ctx) => {
349
- if (value.ready !== (value.readinessReasons.length === 0)) {
350
- ctx.addIssue({
351
- code: "custom",
352
- path: ["ready"],
353
- message: "ready must be true exactly when readinessReasons is empty"
354
- });
355
- }
356
- });
357
- var InputPreparationReferenceSchema = OPAQUE_ID;
358
- var InputPreparationOfferBindingSchema = z.object({
359
- reference: InputPreparationReferenceSchema,
360
- /** `InputPreparationBindingSchema.requestDigest`, as the receipt reported it. */
361
- requestDigest: OPAQUE_ID,
362
- /** `InputPreparationArtifactSummarySchema.envelopeDigest`, when the receipt carried one. */
363
- artifactDigest: OPAQUE_ID.optional()
364
- }).strict();
365
- var InputPreparationRejectionReasonSchema = z.enum([
366
- "input_preparation_unconfigured",
367
- "bad_request",
368
- "authority_unavailable",
369
- "scope_denied",
370
- "policy_revision_mismatch",
371
- "runtime_identity_unavailable",
372
- "unsupported_input",
373
- "limit_exceeded",
374
- "request_conflict",
375
- "not_found",
376
- "counter_unavailable",
377
- "counter_interrupted",
378
- "durable_write_failed",
379
- "cancelled",
380
- "context_unresolvable",
381
- "context_hash_mismatch",
382
- "toolsets_unobservable",
383
- "deadline_elapsed",
384
- /**
385
- * A repeat of an already-recorded `requestId` arrived after the facts its
386
- * executor fingerprints were frozen against changed — a toolset definition
387
- * revision or a configured server argv. The recorded receipt is not re-derived and no
388
- * server is re-probed; the repeat is refused so the caller mints a new
389
- * preparation instead of silently receiving one bound to stale evidence.
390
- */
391
- "observation_drift",
392
- /**
393
- * The device compiled the input, then found that the `prompt_prepared` frame
394
- * the runtime would have to be handed exceeds the single-frame byte cap that
395
- * runtime enforces. The bound belongs to the runtime, not to the operator's
396
- * retention policy, so it is decided first and nothing is retained: a
397
- * preparation that could never be delivered is not a smaller preparation.
398
- */
399
- "rpc_frame_too_large",
400
- /**
401
- * The device's input-preparation lane is off because its durable record log
402
- * holds a record from an older record schema version. The rest of the
403
- * device runs; this lane refuses until an operator archives that log. No
404
- * record is migrated, read forward or deleted.
405
- */
406
- "input_preparation_record_log_unsupported"
407
- ]);
408
- var TERMINAL_PROJECTION_SELECTION_CAPABILITY = "terminal-projection-selection";
409
- var TerminalProjectionContractSchema = z.string().min(1).max(128).regex(/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/u, "terminal projection contracts must be opaque lowercase ids");
410
- var TerminalProjectionSelectionSchema = z.discriminatedUnion("mode", [
411
- z.object({ mode: z.literal("none") }).strict(),
412
- z.object({
413
- mode: z.literal("result-document"),
414
- contract: TerminalProjectionContractSchema
415
- }).strict()
416
- ]);
417
-
418
- // src/task-assertion.ts
419
- var HOST_MCP_TASK_CONTEXT_CAPABILITY = "host-mcp-task-context";
420
- var PROVIDER_PROFILE_BINDING_CAPABILITY = "provider-profile-binding";
421
- var ProviderProfileRefSchema = z.string().min(1).max(64).regex(/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/u, "provider profile refs must be lowercase portable identifiers");
422
- var ProviderProfileRevisionSchema = z.string().regex(/^(?:0|[1-9][0-9]{0,19})$/u, "provider profile revision must be canonical decimal");
423
- var ProviderProfileHashSchema = z.string().regex(/^sha256:[0-9a-f]{64}$/u, "provider profile hash must be lowercase sha256");
424
- var PROVIDER_MODEL_CAPABILITIES = ["image-input"];
425
- var ProviderModelCapabilitySchema = z.enum(PROVIDER_MODEL_CAPABILITIES);
426
- var ProviderProfileBindingSchema = z.object({
427
- profileRef: ProviderProfileRefSchema,
428
- profileRevision: ProviderProfileRevisionSchema,
429
- profileHash: ProviderProfileHashSchema,
430
- modelId: z.string().min(1).max(160).regex(/^[^\u0000\r\n]+$/u),
431
- requiredCapabilities: z.array(ProviderModelCapabilitySchema).max(8)
432
- }).strict().superRefine((binding, ctx) => {
433
- if (new Set(binding.requiredCapabilities).size !== binding.requiredCapabilities.length) {
434
- ctx.addIssue({ code: "custom", path: ["requiredCapabilities"], message: "duplicate provider capability" });
435
- }
436
- });
437
- var PROVIDER_PROVISIONING_CAPABILITY = "provider-provisioning.v1";
438
- var PROVIDER_SECRET_SEALING_KEY_REGISTER_OPERATION = "provider-secret-sealing-key.register";
439
- var ProviderProvisioningAvailablePayloadSchema = z.object({
440
- requestId: z.uuid()
441
- }).strict();
442
- var PROVIDER_PROVISIONING_OPERATIONS = ["configure", "update_model", "replace_secret", "delete"];
443
- var ProviderProvisioningOperationSchema = z.enum(PROVIDER_PROVISIONING_OPERATIONS);
444
- var PROVIDER_PROVISIONING_OPERATION_GENERATION_MAXIMUM = "9223372036854775807";
445
- var ProviderProvisioningOperationGenerationSchema = z.string().regex(/^[1-9][0-9]{0,18}$/u, "operationGeneration must be a canonical positive decimal string").refine(
446
- (value) => value.length < PROVIDER_PROVISIONING_OPERATION_GENERATION_MAXIMUM.length || value <= PROVIDER_PROVISIONING_OPERATION_GENERATION_MAXIMUM,
447
- `operationGeneration must not exceed ${PROVIDER_PROVISIONING_OPERATION_GENERATION_MAXIMUM}`
448
- );
449
- var ProviderProvisioningOperationDigestSchema = z.string().regex(/^sha256:[0-9a-f]{64}$/u, "operationDigest must be lowercase sha256");
450
- var PROVIDER_PROVISIONING_REJECTION_CODES = [
451
- "request_invalid",
452
- "request_conflict",
453
- "request_expired",
454
- "request_not_yet_valid",
455
- "request_window_invalid",
456
- "sealing_key_rotated",
457
- "enrollment_mismatch",
458
- "agent_not_placed",
459
- "config_digest_mismatch",
460
- "operation_generation_stale",
461
- "profile_changed",
462
- "profile_not_found",
463
- "credential_scope_mismatch",
464
- "provider_kind_unsupported",
465
- "pi_model_invalid",
466
- "capabilities_invalid",
467
- "seal_open_failed",
468
- "secret_invalid",
469
- "local_commit_interrupted",
470
- "secret_store_unavailable"
471
- ];
472
- var ProviderProvisioningRejectionCodeSchema = z.enum(PROVIDER_PROVISIONING_REJECTION_CODES);
473
- var PROVIDER_PROVISIONING_HOST_TERMINAL_CODES = ["request_expired", "sealing_key_rotated"];
474
- var ProviderProvisioningProviderStatusSchema = z.object({
475
- profileRef: ProviderProfileRefSchema,
476
- providerKind: z.string().min(1).max(64).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/u, "providerKind must be a lowercase portable identifier"),
477
- modelId: z.string().min(1).max(160).regex(/^[^\u0000\r\n]+$/u),
478
- capabilities: z.array(ProviderModelCapabilitySchema).max(8),
479
- secretConfigured: z.boolean()
480
- }).strict().superRefine((status, ctx) => {
481
- if (new Set(status.capabilities).size !== status.capabilities.length) {
482
- ctx.addIssue({ code: "custom", path: ["capabilities"], message: "duplicate provider capability" });
483
- }
484
- });
485
- var PROVIDER_PROVISIONING_KEY_CHECK_RESULTS = [
486
- "ok",
487
- "credential_rejected",
488
- "rate_limited",
489
- "quota_or_billing",
490
- "model_not_permitted",
491
- "provider_error",
492
- "unreachable",
493
- "timeout",
494
- "not_run"
495
- ];
496
- var ProviderProvisioningKeyCheckResultSchema = z.enum(PROVIDER_PROVISIONING_KEY_CHECK_RESULTS);
497
- var ProviderProvisioningKeyCheckSchema = z.object({
498
- result: ProviderProvisioningKeyCheckResultSchema
499
- }).strict();
500
- var completionIdentity = {
501
- requestId: z.uuid(),
502
- operation: ProviderProvisioningOperationSchema,
503
- operationGeneration: ProviderProvisioningOperationGenerationSchema,
504
- operationDigest: ProviderProvisioningOperationDigestSchema
505
- };
506
- var AppliedCompletionSchema = z.object({
507
- outcome: z.literal("applied"),
508
- ...completionIdentity,
509
- providerStatus: ProviderProvisioningProviderStatusSchema.nullable(),
510
- binding: ProviderProfileBindingSchema.nullable(),
511
- keyCheck: ProviderProvisioningKeyCheckSchema
512
- }).strict();
513
- var RejectedCompletionSchema = z.object({
514
- outcome: z.literal("rejected"),
515
- ...completionIdentity,
516
- code: ProviderProvisioningRejectionCodeSchema
910
+ requestDigest: OPAQUE_ID,
911
+ /**
912
+ * The Host's accounting ruling this preparation was requested under,
913
+ * copied verbatim. Absent when the request named none — never filled in,
914
+ * and never narrowed to one the device would have chosen.
915
+ */
916
+ accountingPolicyRef: InputPreparationAccountingPolicyRefSchema.optional()
517
917
  }).strict();
518
- var ProviderProvisioningCompletionSchema = z.discriminatedUnion("outcome", [AppliedCompletionSchema, RejectedCompletionSchema]).superRefine((completion, ctx) => {
519
- if (completion.outcome !== "applied") return;
520
- const { operation, providerStatus, binding } = completion;
521
- if (operation === "delete") {
522
- if (completion.keyCheck.result !== "not_run") {
523
- ctx.addIssue({ code: "custom", path: ["keyCheck", "result"], message: "an applied delete must report keyCheck not_run" });
524
- }
525
- if (providerStatus !== null) {
526
- ctx.addIssue({ code: "custom", path: ["providerStatus"], message: "an applied delete reports no provider status" });
527
- }
528
- if (binding !== null) {
529
- ctx.addIssue({ code: "custom", path: ["binding"], message: "an applied delete reports no binding" });
530
- }
531
- return;
532
- }
533
- if (providerStatus === null) {
534
- ctx.addIssue({ code: "custom", path: ["providerStatus"], message: `an applied ${operation} must report provider status` });
535
- }
536
- if (binding === null) {
537
- ctx.addIssue({ code: "custom", path: ["binding"], message: `an applied ${operation} must report its exact binding` });
538
- }
539
- if (providerStatus === null || binding === null) return;
540
- if (providerStatus.profileRef !== binding.profileRef) {
541
- ctx.addIssue({ code: "custom", path: ["binding", "profileRef"], message: "binding profileRef must equal providerStatus profileRef" });
542
- }
543
- if (providerStatus.modelId !== binding.modelId) {
544
- ctx.addIssue({ code: "custom", path: ["binding", "modelId"], message: "binding modelId must equal providerStatus modelId" });
545
- }
546
- if ((operation === "configure" || operation === "replace_secret") && !providerStatus.secretConfigured) {
547
- ctx.addIssue({
548
- code: "custom",
549
- path: ["providerStatus", "secretConfigured"],
550
- message: `an applied ${operation} must report a configured secret`
551
- });
552
- }
553
- });
554
- var PROVIDER_PROVISIONING_DISPOSITIONS = ["recorded", "idempotent", "conflict", "host_terminal"];
555
- var ProviderProvisioningDispositionSchema = z.enum(PROVIDER_PROVISIONING_DISPOSITIONS);
556
- var ProviderProvisioningReadbackSchema = z.object({
557
- tenantId: z.string().min(1),
558
- deviceId: z.string().min(1),
559
- requestId: z.uuid(),
560
- disposition: ProviderProvisioningDispositionSchema,
561
- completion: ProviderProvisioningCompletionSchema,
562
- completedAt: z.iso.datetime({ offset: true })
563
- }).strict().superRefine((readback, ctx) => {
564
- if (readback.completion.requestId !== readback.requestId) {
565
- ctx.addIssue({ code: "custom", path: ["completion", "requestId"], message: "completion requestId must equal readback requestId" });
566
- }
567
- if (readback.disposition === "host_terminal" && (readback.completion.outcome !== "rejected" || !PROVIDER_PROVISIONING_HOST_TERMINAL_CODES.includes(readback.completion.code))) {
918
+ var InputPreparationReceiptSummarySchema = z.object({
919
+ reference: OPAQUE_ID,
920
+ state: InputPreparationStateSchema,
921
+ binding: InputPreparationBindingSchema,
922
+ artifact: InputPreparationArtifactSummarySchema.optional(),
923
+ counter: InputPreparationCounterEvidenceSchema.optional(),
924
+ ready: z.boolean(),
925
+ readinessReasons: z.array(InputPreparationReadinessReasonSchema).max(16),
926
+ detail: OPAQUE_ID.optional(),
927
+ artifactExpiresAt: z.iso.datetime({ offset: true })
928
+ }).strict().superRefine((value, ctx) => {
929
+ if (value.ready !== (value.readinessReasons.length === 0)) {
568
930
  ctx.addIssue({
569
931
  code: "custom",
570
- path: ["completion"],
571
- message: `a host_terminal readback must carry a rejected completion with one of: ${PROVIDER_PROVISIONING_HOST_TERMINAL_CODES.join(", ")}`
932
+ path: ["ready"],
933
+ message: "ready must be true exactly when readinessReasons is empty"
572
934
  });
573
935
  }
574
936
  });
575
- var CONTENT_HASH_RE = /^sha256:[0-9a-f]{64}$/;
576
- var BlobRefSchema = z.object({
577
- blobId: z.string(),
578
- contentHash: z.string().regex(CONTENT_HASH_RE, 'contentHash must be "sha256:<64 lowercase hex>"'),
579
- size: z.number().int().nonnegative(),
580
- contentType: z.string(),
581
- url: z.string().optional()
582
- });
937
+ var InputPreparationReferenceSchema = OPAQUE_ID;
938
+ var InputPreparationOfferBindingSchema = z.object({
939
+ reference: InputPreparationReferenceSchema,
940
+ /** `InputPreparationBindingSchema.requestDigest`, as the receipt reported it. */
941
+ requestDigest: OPAQUE_ID,
942
+ /** `InputPreparationArtifactSummarySchema.envelopeDigest`, when the receipt carried one. */
943
+ artifactDigest: OPAQUE_ID.optional()
944
+ }).strict();
945
+ var InputPreparationRejectionReasonSchema = z.enum([
946
+ "input_preparation_unconfigured",
947
+ "bad_request",
948
+ "authority_unavailable",
949
+ "scope_denied",
950
+ "policy_revision_mismatch",
951
+ "runtime_identity_unavailable",
952
+ "unsupported_input",
953
+ "limit_exceeded",
954
+ "request_conflict",
955
+ "not_found",
956
+ "counter_unavailable",
957
+ "counter_interrupted",
958
+ "durable_write_failed",
959
+ "cancelled",
960
+ "context_unresolvable",
961
+ "context_hash_mismatch",
962
+ "toolsets_unobservable",
963
+ "deadline_elapsed",
964
+ /**
965
+ * A repeat of an already-recorded `requestId` arrived after the facts its
966
+ * executor fingerprints were frozen against changed — a toolset definition
967
+ * revision or a configured server argv. The recorded receipt is not re-derived and no
968
+ * server is re-probed; the repeat is refused so the caller mints a new
969
+ * preparation instead of silently receiving one bound to stale evidence.
970
+ */
971
+ "observation_drift",
972
+ /**
973
+ * The device compiled the input, then found that the `prompt_prepared` frame
974
+ * the runtime would have to be handed exceeds the single-frame byte cap that
975
+ * runtime enforces. The bound belongs to the runtime, not to the operator's
976
+ * retention policy, so it is decided first and nothing is retained: a
977
+ * preparation that could never be delivered is not a smaller preparation.
978
+ */
979
+ "rpc_frame_too_large",
980
+ /**
981
+ * The device's input-preparation lane is off because its durable record log
982
+ * holds a record from an older record schema version. The rest of the
983
+ * device runs; this lane refuses until an operator archives that log. No
984
+ * record is migrated, read forward or deleted.
985
+ */
986
+ "input_preparation_record_log_unsupported"
987
+ ]);
583
988
  var AGENT_EVENT_SPILL_UNSTORED_REASON_MAX_LENGTH = 512;
584
989
  var AgentEventSpillSchema = z.object({
585
990
  /** Which field of the event was replaced by a preview. */
@@ -661,6 +1066,18 @@ function partitionAgentEvents(events) {
661
1066
  }
662
1067
  return { known, unknown };
663
1068
  }
1069
+ var AGENT_HOME_PROJECTION_MAX_BYTES = 64 * 1024;
1070
+ var AGENT_HOME_PROJECTION_PROFILE_REVISION_MAXIMUM = "9223372036854775807";
1071
+ var AgentHomeProjectionProfileRevisionSchema = z.string().regex(/^[1-9][0-9]{0,18}$/u, "profileRevision must be a canonical positive decimal string").refine(
1072
+ (value) => value.length < AGENT_HOME_PROJECTION_PROFILE_REVISION_MAXIMUM.length || value <= AGENT_HOME_PROJECTION_PROFILE_REVISION_MAXIMUM,
1073
+ `profileRevision must not exceed PostgreSQL BIGINT maximum ${AGENT_HOME_PROJECTION_PROFILE_REVISION_MAXIMUM}`
1074
+ );
1075
+ var AgentHomeProjectionHashSchema = AgentEgressContentHashSchema;
1076
+ var AgentHomeProjectionOutcomeSchema = z.enum(["applied", "idempotent", "stale", "conflict"]);
1077
+ var AgentHomeProjectionValueSchema = z.json().refine(
1078
+ (value) => new TextEncoder().encode(JSON.stringify(value)).byteLength <= AGENT_HOME_PROJECTION_MAX_BYTES,
1079
+ `projection must not exceed ${AGENT_HOME_PROJECTION_MAX_BYTES} UTF-8 JSON bytes`
1080
+ );
664
1081
 
665
1082
  // src/messages.ts
666
1083
  var MAX_INLINE_BYTES = 64 * 1024;
@@ -674,7 +1091,8 @@ var RuntimeCapabilitiesSchema = z.object({
674
1091
  resume: z.boolean().optional(),
675
1092
  approvalInteractive: z.boolean().optional(),
676
1093
  /** Whether this runtime can project a locally configured MCP toolset into one task. */
677
- mcpToolsets: z.boolean().optional()
1094
+ mcpToolsets: z.boolean().optional(),
1095
+ messageDraft: z.boolean().optional()
678
1096
  });
679
1097
  var RuntimeInfoSchema = z.object({
680
1098
  id: RuntimeIdSchema,
@@ -845,6 +1263,16 @@ var AGENT_MESSAGE_BODY = z.string().min(1).refine(
845
1263
  (value) => new TextEncoder().encode(value).byteLength <= AGENT_MESSAGE_MAX_BYTES,
846
1264
  `Agent message body exceeds ${AGENT_MESSAGE_MAX_BYTES} bytes`
847
1265
  );
1266
+ var AgentMessageDraftPayloadSchema = z.object({
1267
+ agentRef: AgentRefSchema,
1268
+ revision: z.number().int().min(1),
1269
+ offset: z.number().int().nonnegative(),
1270
+ text: z.string().refine(
1271
+ (value) => new TextEncoder().encode(value).byteLength <= AGENT_MESSAGE_DRAFT_FRAME_MAX_BYTES,
1272
+ `Agent message draft frame exceeds ${AGENT_MESSAGE_DRAFT_FRAME_MAX_BYTES} bytes`
1273
+ ),
1274
+ overflow: z.literal(true).optional()
1275
+ }).strict();
848
1276
  var AgentMessagePublishPayloadSchema = z.object({
849
1277
  agentRef: AgentRefSchema,
850
1278
  sessionRef: EGRESS_SESSION_REF,
@@ -1009,7 +1437,8 @@ var TaskStartedPayloadSchema = z.object({});
1009
1437
  var TaskDeclinePayloadSchema = z.object({
1010
1438
  reason: z.string(),
1011
1439
  retryable: z.boolean().optional(),
1012
- agentRef: AgentRefSchema.optional()
1440
+ agentRef: AgentRefSchema.optional(),
1441
+ code: z.enum(["agent_home_writer_busy", "agent_home_reader_busy"]).optional()
1013
1442
  });
1014
1443
  var TaskProgressPayloadSchema = z.object({
1015
1444
  seq: z.number().int(),
@@ -1028,52 +1457,8 @@ var TaskAwaitApprovalPayloadSchema = z.object({
1028
1457
  approvalId: z.string().optional()
1029
1458
  });
1030
1459
  var RESULT_DOCUMENT_MAX_BYTES = 1048576;
1031
- function isSameJsonData(a, b) {
1032
- if (a === null || b === null) return a === b;
1033
- const typeOfA = typeof a;
1034
- if (typeOfA !== typeof b) return false;
1035
- if (typeOfA !== "object") {
1036
- return a === b;
1037
- }
1038
- const aIsArray = Array.isArray(a);
1039
- if (aIsArray !== Array.isArray(b)) return false;
1040
- if (aIsArray) {
1041
- const arrayA = a;
1042
- const arrayB = b;
1043
- if (arrayA.length !== arrayB.length) return false;
1044
- for (let index = 0; index < arrayA.length; index += 1) {
1045
- if (!isSameJsonData(arrayA[index], arrayB[index])) return false;
1046
- }
1047
- return true;
1048
- }
1049
- const objectA = a;
1050
- const objectB = b;
1051
- const keysA = Object.keys(objectA);
1052
- const keysB = Object.keys(objectB);
1053
- if (keysA.length === 0) {
1054
- const prototypeA = Object.getPrototypeOf(objectA);
1055
- if (prototypeA !== Object.prototype && prototypeA !== null) return false;
1056
- }
1057
- if (keysA.length !== keysB.length) return false;
1058
- for (const key of keysA) {
1059
- if (!Object.prototype.hasOwnProperty.call(objectB, key)) return false;
1060
- if (!isSameJsonData(objectA[key], objectB[key])) return false;
1061
- }
1062
- return true;
1063
- }
1064
1460
  function checkResultDocument(document) {
1065
- let json;
1066
- try {
1067
- json = JSON.stringify(document);
1068
- } catch {
1069
- return { ok: false, reason: "not-serializable" };
1070
- }
1071
- if (json === void 0) return { ok: false, reason: "not-serializable" };
1072
- const bytes = new TextEncoder().encode(json).length;
1073
- if (bytes > RESULT_DOCUMENT_MAX_BYTES) return { ok: false, reason: "over-cap", bytes };
1074
- const canonical = JSON.parse(json);
1075
- if (!isSameJsonData(document, canonical)) return { ok: false, reason: "not-plain-json" };
1076
- return { ok: true, bytes, canonical };
1461
+ return canonicalizePlainJson(document, RESULT_DOCUMENT_MAX_BYTES);
1077
1462
  }
1078
1463
  var TERMINAL_INFERENCE_USAGE_MAX_TOKENS = 1e9;
1079
1464
  var TERMINAL_INFERENCE_USAGE_MAX_DURATION_MS = 6048e5;
@@ -1194,6 +1579,7 @@ var MESSAGE_PAYLOAD_SCHEMAS = {
1194
1579
  ...TASK_OFFER_PAYLOAD_SCHEMAS,
1195
1580
  "agent.egress.reliable": AgentEgressReliablePayloadSchema,
1196
1581
  "agent.egress.ack": AgentEgressAckPayloadSchema,
1582
+ "agent.message.draft": AgentMessageDraftPayloadSchema,
1197
1583
  "agent.message.publish": AgentMessagePublishPayloadSchema,
1198
1584
  "agent.message.disposition": AgentMessageDispositionPayloadSchema,
1199
1585
  "agent.content.read": AgentContentReadPayloadSchema,
@@ -1250,12 +1636,12 @@ var DAEMON_TO_SERVER_TYPES = [
1250
1636
  "task.cancelled",
1251
1637
  "task.approval_resolved",
1252
1638
  "agent.egress.reliable",
1639
+ "agent.message.draft",
1253
1640
  "agent.message.publish",
1254
1641
  "agent.content.receipt"
1255
1642
  ];
1256
1643
 
1257
1644
  // src/agent-memory-intent.ts
1258
- var AGENT_MEMORY_INTENT_CAPABILITY = "agent-memory-intent.v1";
1259
1645
  var AGENT_MEMORY_INTENT_CONTENT_MAX_BYTES = 262144;
1260
1646
  var AGENT_MEMORY_INTENT_PATH_MAX_BYTES = 1024;
1261
1647
  var AGENT_MEMORY_INTENT_APPROVAL_REF_MAX_BYTES = 128;
@@ -1267,9 +1653,9 @@ var AgentMemoryIntentApprovalRefSchema = z.string().regex(
1267
1653
  new RegExp(`^[A-Za-z0-9._:-]{1,${AGENT_MEMORY_INTENT_APPROVAL_REF_MAX_BYTES}}$`, "u"),
1268
1654
  `approvalRef must be 1..${AGENT_MEMORY_INTENT_APPROVAL_REF_MAX_BYTES} characters of [A-Za-z0-9._:-]`
1269
1655
  );
1270
- var LONE_SURROGATE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u;
1656
+ var LONE_SURROGATE2 = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u;
1271
1657
  var utf8 = new TextEncoder();
1272
- var AgentMemoryIntentContentSchema = z.string().refine((value) => !LONE_SURROGATE.test(value), "content must be well-formed Unicode (encodable as UTF-8)").refine(
1658
+ var AgentMemoryIntentContentSchema = z.string().refine((value) => !LONE_SURROGATE2.test(value), "content must be well-formed Unicode (encodable as UTF-8)").refine(
1273
1659
  (value) => utf8.encode(value).byteLength <= AGENT_MEMORY_INTENT_CONTENT_MAX_BYTES,
1274
1660
  `content must not exceed ${AGENT_MEMORY_INTENT_CONTENT_MAX_BYTES} UTF-8 bytes`
1275
1661
  );
@@ -1417,44 +1803,6 @@ function agentMemoryIntentFetchResponseSchemaFor(reservation) {
1417
1803
  }
1418
1804
  });
1419
1805
  }
1420
-
1421
- // src/version.ts
1422
- var MAILBOX_READ_AHEAD_MAX_SEQS = 4096;
1423
- var MAILBOX_READ_AHEAD_CAPABILITY = "mailbox-read-ahead";
1424
- var PROTOCOL_VERSION = 2;
1425
- var STRICT_AGENT_ONLY_CAPABILITY = "strict-agent-only";
1426
- var AGENT_HOME_READERS_CAPABILITY = "agent-home-readers";
1427
- var CUSTOM_HARNESS_CAPABILITY = "custom-harness";
1428
- var CAPABILITY_FLAGS = [
1429
- "steer",
1430
- "blob-upload",
1431
- "interactive-approval",
1432
- "approval_resolved",
1433
- "approval-targeting",
1434
- "result-document",
1435
- "dispatch-selection",
1436
- PROVIDER_PROFILE_BINDING_CAPABILITY,
1437
- "toolset-selection",
1438
- "agent-home-contract",
1439
- AGENT_HOME_READERS_CAPABILITY,
1440
- STRICT_AGENT_ONLY_CAPABILITY,
1441
- AGENT_EGRESS_POLICY_CAPABILITY,
1442
- AGENT_EGRESS_RELIABLE_ACK_CAPABILITY,
1443
- AGENT_MESSAGE_EGRESS_CAPABILITY,
1444
- AGENT_EGRESS_FRESH_SESSION_CAPABILITY,
1445
- AGENT_CONTENT_WORKSPACE_READ_CAPABILITY,
1446
- AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY,
1447
- AGENT_CONTENT_ARTIFACT_READ_CAPABILITY,
1448
- AGENT_HOME_PROJECTION_CAPABILITY,
1449
- AGENT_INPUT_PREPARATION_CAPABILITY,
1450
- TERMINAL_PROJECTION_SELECTION_CAPABILITY,
1451
- HOST_MCP_TASK_CONTEXT_CAPABILITY,
1452
- CUSTOM_HARNESS_CAPABILITY,
1453
- MAILBOX_READ_AHEAD_CAPABILITY,
1454
- PROVIDER_PROVISIONING_CAPABILITY,
1455
- AGENT_MEMORY_INTENT_CAPABILITY
1456
- ];
1457
- var AGENT_MEMORY_PROJECTION_CAPABILITY = "agent.memory.projection";
1458
1806
  var AGENT_MEMORY_PROJECTION_MAX_REDACTED_BYTES = 512 * 1024;
1459
1807
  var AGENT_MEMORY_PROJECTION_MAX_ORDERING_VALUE = 2147483647;
1460
1808
  var OPAQUE_REFERENCE_MAX_BYTES = 512;
@@ -1524,29 +1872,6 @@ var AgentMemoryProjectionReceiptSchema = z.object({
1524
1872
  metering: AgentMemoryProjectionMeteringReceiptSchema
1525
1873
  }).strict();
1526
1874
  var AgentMemoryProjectionEraseResultSchema = z.object({ nextWriterEpoch: AgentMemoryProjectionWriterEpochSchema }).strict();
1527
-
1528
- // src/task-state.ts
1529
- var TASK_STATES = [
1530
- "Offered",
1531
- "Claimed",
1532
- "Running",
1533
- "AwaitApproval",
1534
- "Complete",
1535
- "Failed",
1536
- "Cancelled"
1537
- ];
1538
- var TASK_TRANSITIONS = {
1539
- Offered: ["Claimed", "Cancelled", "Failed"],
1540
- Claimed: ["Running", "Failed", "Cancelled"],
1541
- Running: ["AwaitApproval", "Complete", "Failed", "Cancelled"],
1542
- AwaitApproval: ["Running", "Failed", "Cancelled"],
1543
- Complete: [],
1544
- Failed: [],
1545
- Cancelled: []
1546
- };
1547
- function canTransition(from, to) {
1548
- return TASK_TRANSITIONS[from].includes(to);
1549
- }
1550
1875
  var REQUIRED_TASK_ID = z.string().min(1);
1551
1876
  var OPTIONAL_TASK_ID = REQUIRED_TASK_ID.optional();
1552
1877
  var FORBIDDEN_TASK_ID = z.never().optional();
@@ -1607,6 +1932,7 @@ var EnvelopeSchema = z.discriminatedUnion("type", [
1607
1932
  envelopeShape("task.cancelled", REQUIRED_TASK_ID, OPTIONAL_SEQ),
1608
1933
  envelopeShape("task.approval_resolved", REQUIRED_TASK_ID, OPTIONAL_SEQ),
1609
1934
  envelopeShape("agent.egress.reliable", OPTIONAL_TASK_ID, OPTIONAL_SEQ),
1935
+ envelopeShape("agent.message.draft", REQUIRED_TASK_ID, OPTIONAL_SEQ),
1610
1936
  envelopeShape("agent.message.publish", REQUIRED_TASK_ID, OPTIONAL_SEQ),
1611
1937
  envelopeShape("agent.content.receipt", OPTIONAL_TASK_ID, OPTIONAL_SEQ)
1612
1938
  ]);
@@ -1777,16 +2103,36 @@ var EventsPollQuerySchema = z.object({
1777
2103
  /** Last reliably processed seq; the only acknowledgement. Omitted on the first poll. */
1778
2104
  cursor: z.number().int().nonnegative().optional()
1779
2105
  });
2106
+ var ActivityIngressSchema = z.object({
2107
+ activityMaxEvents: z.number().int().positive(),
2108
+ activityMaxBytes: z.number().int().min(2)
2109
+ });
2110
+ var OUTBOUND_REFUSAL_REASONS = ["payload_invalid", "not_permitted", "limit_exceeded", "state_conflict", "unsupported"];
2111
+ function isOutboundRefusalCode(value) {
2112
+ return OUTBOUND_REFUSAL_REASONS.includes(value);
2113
+ }
2114
+ var MessageSendOutcomeSchema = z.object({
2115
+ id: z.uuid(),
2116
+ outcome: z.enum(["accepted", "duplicate", "rejected"]),
2117
+ /** Decodes to an {@link OutboundRefusalReason}; an unrecognized string becomes `unknown`. */
2118
+ reason: z.string().max(64).transform((value) => isOutboundRefusalCode(value) ? value : "unknown").optional()
2119
+ });
1780
2120
  var EventsPollResponseSchema = z.object({
1781
- events: z.array(EnvelopeSchema),
2121
+ /**
2122
+ * Not-yet-decoded entries (#386). This schema decodes the page only; each
2123
+ * entry is decoded on its own with `parseMessage`, so one unknown or invalid
2124
+ * entry stalls its own sequence instead of failing every entry in the page.
2125
+ */
2126
+ events: z.array(z.unknown()),
1782
2127
  cursor: z.number().int(),
1783
2128
  /**
1784
- * Server capabilities for THIS long-poll response. This is the HTTP
1785
- * transport's equivalent of `conn.ack.capabilities`: a new daemon treats
1786
- * absence as no advertised capabilities, so old responders remain
1787
- * fail-closed for gated daemon -> server fields and messages.
2129
+ * Required in v3: the server capabilities for THIS long-poll response, the
2130
+ * HTTP transport's equivalent of `conn.ack.capabilities`. Each page replaces
2131
+ * the daemon's advertisement; an empty list advertises nothing.
1788
2132
  */
1789
- capabilities: z.array(z.string()).optional()
2133
+ capabilities: z.array(z.string()),
2134
+ /** Required in v3: the activity limits that apply to new progress pushes. */
2135
+ ingress: ActivityIngressSchema
1790
2136
  });
1791
2137
  var MAX_MESSAGES_PER_BATCH = 256;
1792
2138
  var MessagesSendRequestSchema = z.object({
@@ -1794,7 +2140,10 @@ var MessagesSendRequestSchema = z.object({
1794
2140
  });
1795
2141
  var MessagesSendResponseSchema = z.object({
1796
2142
  accepted: z.number().int().nonnegative(),
1797
- rejected: z.number().int().nonnegative().optional()
2143
+ rejected: z.number().int().nonnegative().optional(),
2144
+ capabilities: z.array(z.string()).optional(),
2145
+ ingress: ActivityIngressSchema.optional(),
2146
+ outcomes: z.array(MessageSendOutcomeSchema).max(MAX_MESSAGES_PER_BATCH)
1798
2147
  });
1799
2148
  var AgentHomeProjectionCompletionRequestSchema = z.object({
1800
2149
  requestId: z.uuid(),
@@ -1919,6 +2268,6 @@ function byokBlobContentPath(blobId) {
1919
2268
  return `/byok/blobs/${blobId}/content`;
1920
2269
  }
1921
2270
 
1922
- export { AGENT_CONTENT_ARTIFACT_READ_CAPABILITY, AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY, AGENT_CONTENT_WORKSPACE_READ_CAPABILITY, AGENT_EGRESS_FRESH_SESSION_CAPABILITY, AGENT_EGRESS_POLICY_CAPABILITY, AGENT_EGRESS_RELIABLE_ACK_CAPABILITY, AGENT_EVENT_SPILL_UNSTORED_REASON_MAX_LENGTH, AGENT_HOME_MEMORY_DIGEST_MAX_BYTES, AGENT_HOME_MEMORY_DIGEST_MAX_FILES, AGENT_HOME_MEMORY_PATH_MAX_LENGTH, AGENT_HOME_PROJECTION_CAPABILITY, AGENT_HOME_PROJECTION_MAX_BYTES, AGENT_HOME_PROJECTION_PROFILE_REVISION_MAXIMUM, AGENT_HOME_READERS_CAPABILITY, AGENT_INPUT_PREPARATION_CAPABILITY, AGENT_MEMORY_INTENT_APPROVAL_REF_MAX_BYTES, AGENT_MEMORY_INTENT_CAPABILITY, AGENT_MEMORY_INTENT_CONTENT_MAX_BYTES, AGENT_MEMORY_INTENT_FETCH_DISPOSITIONS, AGENT_MEMORY_INTENT_FETCH_DISPOSITIONS_BY_RESERVATION, AGENT_MEMORY_INTENT_HOST_TERMINAL_CODES, AGENT_MEMORY_INTENT_OPERATIONS, AGENT_MEMORY_INTENT_PATH_MAX_BYTES, AGENT_MEMORY_INTENT_READBACK_DISPOSITIONS, AGENT_MEMORY_INTENT_REJECTION_CODES, AGENT_MEMORY_INTENT_RESERVATIONS, AGENT_MEMORY_PROJECTION_CAPABILITY, AGENT_MEMORY_PROJECTION_MAX_ORDERING_VALUE, AGENT_MEMORY_PROJECTION_MAX_REDACTED_BYTES, AGENT_MESSAGE_EGRESS_CAPABILITY, AGENT_MESSAGE_MAX_BYTES, AGENT_REF_MAX_BYTES, AgentContentActorKindSchema, AgentContentActorSchema, AgentContentDecodeAsSchema, AgentContentMimeTypeSchema, AgentContentReadDecisionSchema, AgentContentReadDenialReasonSchema, AgentContentReadPayloadSchema, AgentContentReadSurfaceSchema, AgentContentReceiptPayloadSchema, AgentEgressAckPayloadSchema, AgentEgressActivityPolicySchema, AgentEgressContentHashSchema, AgentEgressDropReasonSchema, AgentEgressLaneSchema, AgentEgressPolicyRevisionSchema, AgentEgressPolicySchema, AgentEgressReliablePayloadSchema, AgentEventOrUnknownSchema, AgentEventSchema, AgentEventSpillSchema, AgentHomeAccessSchema, AgentHomeProjectionAgentRefSchema, AgentHomeProjectionCompletionRequestSchema, AgentHomeProjectionHashSchema, AgentHomeProjectionOutcomeSchema, AgentHomeProjectionPayloadSchema, AgentHomeProjectionProfileRevisionSchema, AgentHomeProjectionReadbackSchema, AgentHomeProjectionStatusSchema, AgentHomeProjectionValueSchema, AgentInputPreparationPayloadSchema, AgentMemoryIntentApprovalRefSchema, AgentMemoryIntentAvailablePayloadSchema, AgentMemoryIntentCompletionSchema, AgentMemoryIntentContentSchema, AgentMemoryIntentFetchRequestSchema, AgentMemoryIntentFetchResponseSchema, AgentMemoryIntentFileObservationSchema, AgentMemoryIntentHostTerminalCodeSchema, AgentMemoryIntentOperationDigestSchema, AgentMemoryIntentOperationSchema, AgentMemoryIntentPathSchema, AgentMemoryIntentReadbackDispositionSchema, AgentMemoryIntentReadbackSchema, AgentMemoryIntentRejectionCodeSchema, AgentMemoryIntentReservationSchema, AgentMemoryIntentRevisionSchema, AgentMemoryIntentV1Schema, AgentMemoryProjectionCommitRequestSchema, AgentMemoryProjectionCommitResponseSchema, AgentMemoryProjectionEraseResultSchema, AgentMemoryProjectionGrantRefSchema, AgentMemoryProjectionMeteringReceiptSchema, AgentMemoryProjectionMutationSchema, AgentMemoryProjectionReceiptSchema, AgentMemoryProjectionSessionRefSchema, AgentMemoryProjectionSnapshotSchema, AgentMemoryProjectionSourceSeqSchema, AgentMemoryProjectionWriterEpochSchema, AgentMessageContentTypeSchema, AgentMessageContractSchema, AgentMessageDestinationBindingSchema, AgentMessageDispositionPayloadSchema, AgentMessageEgressRequirementSchema, AgentMessageFreshnessCursorSchema, AgentMessagePublishPayloadSchema, AgentMessageServerContextSchema, AgentRefSchema, AgentReliableQuotaPolicySchema, BYOK_ACTIVITY_PATH, BYOK_AGENT_HOME_PROJECTIONS_PATH, BYOK_AGENT_HOME_PROJECTION_COMPLETION_ROUTE, BYOK_AGENT_MEMORY_PROJECTIONS_PATH, BYOK_BLOBS_PATH, BYOK_BLOB_CONTENT_ROUTE, BYOK_BLOB_FINALIZE_ROUTE, BYOK_BLOB_URL_ROUTE, BYOK_BOARD_CLAIM_ROUTE, BYOK_BOARD_PATH, BYOK_BOARD_STATUS_ROUTE, BYOK_BOARD_STREAM_PATH, BYOK_BOARD_UNCLAIM_ROUTE, BYOK_CAPABILITIES_PATH, BYOK_CHALLENGE_PATH, BYOK_EVENTS_PATH, BYOK_INPUT_PREPARATIONS_PATH, BYOK_INPUT_PREPARATION_COMPLETION_ROUTE, BYOK_INPUT_PREPARATION_STATUS_ROUTE, BYOK_MESSAGES_PATH, BYOK_PAIR_PATH, BYOK_PRESENCE_PATH, BYOK_RECORDS_PATH, BYOK_RECORD_ROUTE, BYOK_SKILL_PACKS_PATH, BYOK_SKILL_PACK_FILE_ROUTE, BYOK_TOKEN_PATH, BlobDownloadUrlResponseSchema, BlobRefSchema, CAPABILITY_FLAGS, CONFIGURED_TOOLSETS_MAX_ITEMS, CONTENT_HASH_RE, CUSTOM_HARNESS_CAPABILITY, ChallengeRequestSchema, ChallengeResponseSchema, ConfiguredToolsetsSchema, ConnAckPayloadSchema, ConnHelloPayloadSchema, ContentReadPolicySchema, CreateBlobRequestSchema, CreateBlobResponseSchema, DAEMON_TO_SERVER_TYPES, DispatchSelectionSchema, EnvelopeParseError, EnvelopeSchema, EnvelopeValidationError, EventsPollQuerySchema, EventsPollResponseSchema, HOST_MCP_TASK_CONTEXT_CAPABILITY, HarnessIdSchema, HarnessInfoSchema, HarnessInventorySchema, INPUT_PREPARATION_WIRE_VERSION, InputPreparationAccountingPolicyRefSchema, InputPreparationArtifactSummarySchema, InputPreparationBindingSchema, InputPreparationCompletionRequestSchema, InputPreparationContentHashSchema, InputPreparationContextDocumentSchema, InputPreparationCounterEvidenceSchema, InputPreparationCounterProviderEvidenceSchema, InputPreparationCounterTargetSchema, InputPreparationHostCanonicalAssistantMessageSchema, InputPreparationMessageSchema, InputPreparationModelCostSchema, InputPreparationModelSchema, InputPreparationOfferBindingSchema, InputPreparationOptionsSchema, InputPreparationPolicyRevisionSchema, InputPreparationProfileIdSchema, InputPreparationProjectionSchema, InputPreparationPromptSnapshotSchema, InputPreparationReadbackSchema, InputPreparationReadinessReasonSchema, InputPreparationReceiptSummarySchema, InputPreparationReferenceSchema, InputPreparationRejectionReasonSchema, InputPreparationResidualKeySchema, InputPreparationResidualValueClassSchema, InputPreparationRuntimeIdentitySchema, InputPreparationSelectionSchema, InputPreparationSourceSchema, InputPreparationStateSchema, InputPreparationStatusQuerySchema, InputPreparationStatusSchema, InputPreparationUserMessageSchema, KNOWN_AGENT_EVENT_TYPES, MAILBOX_READ_AHEAD_CAPABILITY, MAILBOX_READ_AHEAD_MAX_SEQS, MAX_MESSAGES_PER_BATCH, MESSAGE_PAYLOAD_SCHEMAS, MESSAGE_TYPES, MessagesSendRequestSchema, MessagesSendResponseSchema, PAIR_RESPONSE_TENANT_ID_MAX_LENGTH, PROTOCOL_VERSION, PROVIDER_MODEL_CAPABILITIES, PROVIDER_PROFILE_BINDING_CAPABILITY, PROVIDER_PROVISIONING_CAPABILITY, PROVIDER_PROVISIONING_DISPOSITIONS, PROVIDER_PROVISIONING_HOST_TERMINAL_CODES, PROVIDER_PROVISIONING_KEY_CHECK_RESULTS, PROVIDER_PROVISIONING_OPERATIONS, PROVIDER_PROVISIONING_OPERATION_GENERATION_MAXIMUM, PROVIDER_PROVISIONING_REJECTION_CODES, PROVIDER_SECRET_SEALING_KEY_REGISTER_OPERATION, PairRequestSchema, PairResponseSchema, PairResponseTenantIdSchema, PreparedAgentMemoryModeSchema, PresencePublishRequestSchema, ProtocolError, ProtocolVersionNumberSchema, ProviderModelCapabilitySchema, ProviderProfileBindingSchema, ProviderProfileHashSchema, ProviderProfileRefSchema, ProviderProfileRevisionSchema, ProviderProvisioningAvailablePayloadSchema, ProviderProvisioningCompletionSchema, ProviderProvisioningDispositionSchema, ProviderProvisioningKeyCheckResultSchema, ProviderProvisioningKeyCheckSchema, ProviderProvisioningOperationDigestSchema, ProviderProvisioningOperationGenerationSchema, ProviderProvisioningOperationSchema, ProviderProvisioningProviderStatusSchema, ProviderProvisioningReadbackSchema, ProviderProvisioningRejectionCodeSchema, RESULT_DOCUMENT_MAX_BYTES, RequiredToolsetsSchema, RuntimeCapabilitiesSchema, RuntimeIdSchema, RuntimeInfoSchema, SERVER_TO_DAEMON_TYPES, STRICT_AGENT_ONLY_CAPABILITY, TASK_OFFER_TYPES, TASK_STATES, TASK_TRANSITIONS, TERMINAL_INFERENCE_USAGE_CLIENT_VERSION_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_MAX_DURATION_MS, TERMINAL_INFERENCE_USAGE_MAX_TOKENS, TERMINAL_INFERENCE_USAGE_MODEL_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_PROVIDER_MAX_LENGTH, TERMINAL_PROJECTION_SELECTION_CAPABILITY, TaskApprovalResolvedPayloadSchema, TaskApprovePayloadSchema, TaskArtifactPayloadSchema, TaskAwaitApprovalPayloadSchema, TaskCancelPayloadSchema, TaskCancelledPayloadSchema, TaskClaimPayloadSchema, TaskCompletePayloadSchema, TaskDeclinePayloadSchema, TaskFailPayloadSchema, TaskOfferForAgentPayloadSchema, TaskOfferForAgentWithEgressFreshPayloadSchema, TaskOfferForAgentWithEgressPayloadSchema, TaskOfferPayloadSchema, TaskOfferPreparedPayloadSchema, TaskOfferWithToolsetsPayloadSchema, TaskProgressPayloadSchema, TaskRejectPayloadSchema, TaskStartedPayloadSchema, TaskSteerPayloadSchema, TerminalAgentHomeMemoryChangeSchema, TerminalAgentHomeProjectionSchema, TerminalInferenceUsageSchema, TerminalPreparedObservationSchema, TerminalProjectionContractSchema, TerminalProjectionSelectionSchema, TokenRequestSchema, TokenResponseSchema, ToolsetIdSchema, UnknownAgentEventSchema, UnknownMessageTypeError, agentMemoryIntentFetchResponseSchemaFor, agentMemoryProjectionBase64UrlByteLength, byokAgentHomeProjectionCompletionPath, byokBlobContentPath, byokBlobFinalizePath, byokBlobUrlPath, byokInputPreparationCompletionPath, byokInputPreparationStatusPath, byokRecordPath, byokSkillPackFilePath, canTransition, checkResultDocument, createEnvelope, decodeEnvelope, encodeEnvelope, isKnownAgentEvent, isServerToDaemonType, isTaskOfferType, parseMessage, partitionAgentEvents };
2271
+ export { AGENT_CONTENT_ARTIFACT_READ_CAPABILITY, AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY, AGENT_CONTENT_WORKSPACE_READ_CAPABILITY, AGENT_EGRESS_FRESH_SESSION_CAPABILITY, AGENT_EGRESS_POLICY_CAPABILITY, AGENT_EGRESS_RELIABLE_ACK_CAPABILITY, AGENT_EVENT_SPILL_UNSTORED_REASON_MAX_LENGTH, AGENT_HOME_MEMORY_DIGEST_MAX_BYTES, AGENT_HOME_MEMORY_DIGEST_MAX_FILES, AGENT_HOME_MEMORY_PATH_MAX_LENGTH, AGENT_HOME_PROJECTION_CAPABILITY, AGENT_HOME_PROJECTION_MAX_BYTES, AGENT_HOME_PROJECTION_PROFILE_REVISION_MAXIMUM, AGENT_HOME_READERS_CAPABILITY, AGENT_INPUT_PREPARATION_CAPABILITY, AGENT_MEMORY_INTENT_APPROVAL_REF_MAX_BYTES, AGENT_MEMORY_INTENT_CAPABILITY, AGENT_MEMORY_INTENT_CONTENT_MAX_BYTES, AGENT_MEMORY_INTENT_FETCH_DISPOSITIONS, AGENT_MEMORY_INTENT_FETCH_DISPOSITIONS_BY_RESERVATION, AGENT_MEMORY_INTENT_HOST_TERMINAL_CODES, AGENT_MEMORY_INTENT_OPERATIONS, AGENT_MEMORY_INTENT_PATH_MAX_BYTES, AGENT_MEMORY_INTENT_READBACK_DISPOSITIONS, AGENT_MEMORY_INTENT_REJECTION_CODES, AGENT_MEMORY_INTENT_RESERVATIONS, AGENT_MEMORY_PROJECTION_CAPABILITY, AGENT_MEMORY_PROJECTION_MAX_ORDERING_VALUE, AGENT_MEMORY_PROJECTION_MAX_REDACTED_BYTES, AGENT_MESSAGE_DRAFT_FRAME_MAX_BYTES, AGENT_MESSAGE_EGRESS_CAPABILITY, AGENT_MESSAGE_MAX_BYTES, AGENT_REF_MAX_BYTES, ActivityIngressSchema, AgentContentActorKindSchema, AgentContentActorSchema, AgentContentDecodeAsSchema, AgentContentMimeTypeSchema, AgentContentReadDecisionSchema, AgentContentReadDenialReasonSchema, AgentContentReadPayloadSchema, AgentContentReadSurfaceSchema, AgentContentReceiptPayloadSchema, AgentEgressAckPayloadSchema, AgentEgressActivityPolicySchema, AgentEgressContentHashSchema, AgentEgressDropReasonSchema, AgentEgressLaneSchema, AgentEgressPolicyRevisionSchema, AgentEgressPolicySchema, AgentEgressReliablePayloadSchema, AgentEventOrUnknownSchema, AgentEventSchema, AgentEventSpillSchema, AgentHomeAccessSchema, AgentHomeProjectionAgentRefSchema, AgentHomeProjectionCompletionRequestSchema, AgentHomeProjectionHashSchema, AgentHomeProjectionOutcomeSchema, AgentHomeProjectionPayloadSchema, AgentHomeProjectionProfileRevisionSchema, AgentHomeProjectionReadbackSchema, AgentHomeProjectionStatusSchema, AgentHomeProjectionValueSchema, AgentInputPreparationPayloadSchema, AgentMemoryIntentApprovalRefSchema, AgentMemoryIntentAvailablePayloadSchema, AgentMemoryIntentCompletionSchema, AgentMemoryIntentContentSchema, AgentMemoryIntentFetchRequestSchema, AgentMemoryIntentFetchResponseSchema, AgentMemoryIntentFileObservationSchema, AgentMemoryIntentHostTerminalCodeSchema, AgentMemoryIntentOperationDigestSchema, AgentMemoryIntentOperationSchema, AgentMemoryIntentPathSchema, AgentMemoryIntentReadbackDispositionSchema, AgentMemoryIntentReadbackSchema, AgentMemoryIntentRejectionCodeSchema, AgentMemoryIntentReservationSchema, AgentMemoryIntentRevisionSchema, AgentMemoryIntentV1Schema, AgentMemoryProjectionCommitRequestSchema, AgentMemoryProjectionCommitResponseSchema, AgentMemoryProjectionEraseResultSchema, AgentMemoryProjectionGrantRefSchema, AgentMemoryProjectionMeteringReceiptSchema, AgentMemoryProjectionMutationSchema, AgentMemoryProjectionReceiptSchema, AgentMemoryProjectionSessionRefSchema, AgentMemoryProjectionSnapshotSchema, AgentMemoryProjectionSourceSeqSchema, AgentMemoryProjectionWriterEpochSchema, AgentMessageContentTypeSchema, AgentMessageContractSchema, AgentMessageDestinationBindingSchema, AgentMessageDispositionPayloadSchema, AgentMessageDraftPayloadSchema, AgentMessageEgressRequirementSchema, AgentMessageFreshnessCursorSchema, AgentMessagePublishPayloadSchema, AgentMessageServerContextSchema, AgentRefSchema, AgentReliableQuotaPolicySchema, BYOK_ACTIVITY_PATH, BYOK_AGENT_HOME_PROJECTIONS_PATH, BYOK_AGENT_HOME_PROJECTION_COMPLETION_ROUTE, BYOK_AGENT_MEMORY_PROJECTIONS_PATH, BYOK_BLOBS_PATH, BYOK_BLOB_CONTENT_ROUTE, BYOK_BLOB_FINALIZE_ROUTE, BYOK_BLOB_URL_ROUTE, BYOK_BOARD_CLAIM_ROUTE, BYOK_BOARD_PATH, BYOK_BOARD_STATUS_ROUTE, BYOK_BOARD_STREAM_PATH, BYOK_BOARD_UNCLAIM_ROUTE, BYOK_CAPABILITIES_PATH, BYOK_CHALLENGE_PATH, BYOK_EVENTS_PATH, BYOK_INPUT_PREPARATIONS_PATH, BYOK_INPUT_PREPARATION_COMPLETION_ROUTE, BYOK_INPUT_PREPARATION_STATUS_ROUTE, BYOK_MESSAGES_PATH, BYOK_PAIR_PATH, BYOK_PRESENCE_PATH, BYOK_RECORDS_PATH, BYOK_RECORD_ROUTE, BYOK_SKILL_PACKS_PATH, BYOK_SKILL_PACK_FILE_ROUTE, BYOK_TOKEN_PATH, BlobDownloadUrlResponseSchema, BlobRefSchema, CAPABILITY_FLAGS, CONFIGURED_TOOLSETS_MAX_ITEMS, CONTENT_HASH_RE, CUSTOM_HARNESS_CAPABILITY, ChallengeRequestSchema, ChallengeResponseSchema, ConfiguredToolsetsSchema, ConnAckPayloadSchema, ConnHelloPayloadSchema, ContentReadPolicySchema, CreateBlobRequestSchema, CreateBlobResponseSchema, DAEMON_TO_SERVER_TYPES, DispatchSelectionSchema, EnvelopeParseError, EnvelopeSchema, EnvelopeValidationError, EventsPollQuerySchema, EventsPollResponseSchema, HOST_MCP_TASK_CONTEXT_CAPABILITY, HarnessIdSchema, HarnessInfoSchema, HarnessInventorySchema, INPUT_PREPARATION_WIRE_VERSION, InputPreparationAccountingPolicyRefSchema, InputPreparationArtifactSummarySchema, InputPreparationBindingSchema, InputPreparationCompletionRequestSchema, InputPreparationContentHashSchema, InputPreparationContextDocumentSchema, InputPreparationCounterEvidenceSchema, InputPreparationCounterProviderEvidenceSchema, InputPreparationCounterTargetSchema, InputPreparationHostCanonicalAssistantMessageSchema, InputPreparationMessageSchema, InputPreparationModelCostSchema, InputPreparationModelSchema, InputPreparationOfferBindingSchema, InputPreparationOptionsSchema, InputPreparationPolicyRevisionSchema, InputPreparationProfileIdSchema, InputPreparationProjectionSchema, InputPreparationPromptSnapshotSchema, InputPreparationReadbackSchema, InputPreparationReadinessReasonSchema, InputPreparationReceiptSummarySchema, InputPreparationReferenceSchema, InputPreparationRejectionReasonSchema, InputPreparationResidualKeySchema, InputPreparationResidualValueClassSchema, InputPreparationRuntimeIdentitySchema, InputPreparationSelectionSchema, InputPreparationSourceSchema, InputPreparationStateSchema, InputPreparationStatusQuerySchema, InputPreparationStatusSchema, InputPreparationUserMessageSchema, KNOWN_AGENT_EVENT_TYPES, MAILBOX_READ_AHEAD_CAPABILITY, MAILBOX_READ_AHEAD_MAX_SEQS, MAX_MESSAGES_PER_BATCH, MESSAGE_PAYLOAD_SCHEMAS, MESSAGE_TYPES, MessageSendOutcomeSchema, MessagesSendRequestSchema, MessagesSendResponseSchema, OUTBOUND_REFUSAL_REASONS, PAIR_RESPONSE_TENANT_ID_MAX_LENGTH, PREPARED_AGENT_MEMORY_MODES, PROTOCOL_VERSION, PROVIDER_MODEL_CAPABILITIES, PROVIDER_PROFILE_BINDING_CAPABILITY, PROVIDER_PROVISIONING_CAPABILITY, PROVIDER_PROVISIONING_DISPOSITIONS, PROVIDER_PROVISIONING_HOST_TERMINAL_CODES, PROVIDER_PROVISIONING_KEY_CHECK_RESULTS, PROVIDER_PROVISIONING_OPERATIONS, PROVIDER_PROVISIONING_OPERATION_GENERATION_MAXIMUM, PROVIDER_PROVISIONING_REJECTION_CODES, PROVIDER_SECRET_SEALING_KEY_REGISTER_OPERATION, PairRequestSchema, PairResponseSchema, PairResponseTenantIdSchema, PreparedAgentMemoryModeSchema, PresencePublishRequestSchema, ProtocolError, ProtocolVersionNumberSchema, ProviderModelCapabilitySchema, ProviderProfileBindingSchema, ProviderProfileHashSchema, ProviderProfileRefSchema, ProviderProfileRevisionSchema, ProviderProvisioningAvailablePayloadSchema, ProviderProvisioningCompletionSchema, ProviderProvisioningDispositionSchema, ProviderProvisioningKeyCheckResultSchema, ProviderProvisioningKeyCheckSchema, ProviderProvisioningOperationDigestSchema, ProviderProvisioningOperationGenerationSchema, ProviderProvisioningOperationSchema, ProviderProvisioningProviderStatusSchema, ProviderProvisioningReadbackSchema, ProviderProvisioningRejectionCodeSchema, RESULT_DOCUMENT_MAX_BYTES, RESULT_ISSUES_MAX_BYTES, RESULT_ISSUES_MAX_COUNT, RESULT_JSON_MAX_DEPTH, RESULT_OUTCOME_MAX_BYTES, RESULT_SCHEMA_INSTANCE_TYPES, RESULT_SCHEMA_KEYWORDS, RESULT_SCHEMA_MAX_BYTES, RESULT_SCHEMA_MAX_DEPTH, RequiredToolsetsSchema, ResultDocumentSchemaSchema, RuntimeCapabilitiesSchema, RuntimeIdSchema, RuntimeInfoSchema, SERVER_TO_DAEMON_TYPES, STRICT_AGENT_ONLY_CAPABILITY, TASK_OFFER_TYPES, TASK_STATES, TASK_TRANSITIONS, TERMINAL_INFERENCE_USAGE_CLIENT_VERSION_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_MAX_DURATION_MS, TERMINAL_INFERENCE_USAGE_MAX_TOKENS, TERMINAL_INFERENCE_USAGE_MODEL_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_PROVIDER_MAX_LENGTH, TERMINAL_PROJECTION_SELECTION_CAPABILITY, TaskApprovalResolvedPayloadSchema, TaskApprovePayloadSchema, TaskArtifactPayloadSchema, TaskAwaitApprovalPayloadSchema, TaskCancelPayloadSchema, TaskCancelledPayloadSchema, TaskClaimPayloadSchema, TaskCompletePayloadSchema, TaskDeclinePayloadSchema, TaskFailPayloadSchema, TaskOfferForAgentPayloadSchema, TaskOfferForAgentWithEgressFreshPayloadSchema, TaskOfferForAgentWithEgressPayloadSchema, TaskOfferPayloadSchema, TaskOfferPreparedPayloadSchema, TaskOfferWithToolsetsPayloadSchema, TaskProgressPayloadSchema, TaskRejectPayloadSchema, TaskStartedPayloadSchema, TaskSteerPayloadSchema, TerminalAgentHomeMemoryChangeSchema, TerminalAgentHomeProjectionSchema, TerminalInferenceUsageSchema, TerminalPreparedObservationSchema, TerminalProjectionContractSchema, TerminalProjectionSelectionSchema, TokenRequestSchema, TokenResponseSchema, ToolsetIdSchema, UnknownAgentEventSchema, UnknownMessageTypeError, WIRE_ADDITIONS, agentMemoryIntentFetchResponseSchemaFor, agentMemoryProjectionBase64UrlByteLength, byokAgentHomeProjectionCompletionPath, byokBlobContentPath, byokBlobFinalizePath, byokBlobUrlPath, byokInputPreparationCompletionPath, byokInputPreparationStatusPath, byokRecordPath, byokSkillPackFilePath, canTransition, checkResultDocument, checkResultSchema, createEnvelope, decodeEnvelope, encodeEnvelope, isKnownAgentEvent, isPreparedAgentMemoryMode, isServerToDaemonType, isTaskOfferType, parseMessage, partitionAgentEvents, requiredReceiverCapabilities, validateResultOutcome };
1923
2272
  //# sourceMappingURL=index.js.map
1924
2273
  //# sourceMappingURL=index.js.map