@byok-sdk/protocol 0.6.0 → 0.7.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.d.ts CHANGED
@@ -6,14 +6,16 @@ export { PermissionPolicySchema, PERMISSION_MODES } from './permission';
6
6
  export type { PermissionPolicy, PermissionMode } from './permission';
7
7
  export { AgentEventSchema, UnknownAgentEventSchema, AgentEventOrUnknownSchema, KNOWN_AGENT_EVENT_TYPES, isKnownAgentEvent, partitionAgentEvents, } from './agent-event';
8
8
  export type { AgentEvent, UnknownAgentEvent, AgentEventOrUnknown } from './agent-event';
9
+ export { AgentEgressPolicySchema, AgentEgressActivityPolicySchema, AgentReliableQuotaPolicySchema, ContentReadPolicySchema, AgentEgressLaneSchema, AgentEgressDropReasonSchema, AgentContentReadSurfaceSchema, AgentContentActorKindSchema, AgentContentActorSchema, AgentContentDecodeAsSchema, AgentContentMimeTypeSchema, AgentContentReadDecisionSchema, AgentContentReadDenialReasonSchema, AgentEgressContentHashSchema, AgentEgressPolicyRevisionSchema, AGENT_EGRESS_POLICY_CAPABILITY, AGENT_EGRESS_RELIABLE_ACK_CAPABILITY, AGENT_CONTENT_WORKSPACE_READ_CAPABILITY, AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY, AGENT_CONTENT_ARTIFACT_READ_CAPABILITY, } from './agent-egress';
10
+ export type { AgentEgressPolicy, AgentEgressActivityPolicy, AgentReliableQuotaPolicy, ContentReadPolicy, AgentEgressLane, AgentEgressDropReason, AgentContentReadSurface, AgentContentActorKind, AgentContentActor, AgentContentDecodeAs, AgentContentReadDecision, AgentContentReadDenialReason, } from './agent-egress';
9
11
  export { TASK_STATES, TASK_TRANSITIONS, canTransition } from './task-state';
10
12
  export type { TaskState } from './task-state';
11
- export { MESSAGE_TYPES, MESSAGE_PAYLOAD_SCHEMAS, SERVER_TO_DAEMON_TYPES, DAEMON_TO_SERVER_TYPES, RuntimeIdSchema, ProtocolVersionNumberSchema, RuntimeInfoSchema, RuntimeCapabilitiesSchema, DispatchSelectionSchema, ToolsetIdSchema, ConfiguredToolsetsSchema, RequiredToolsetsSchema, CONFIGURED_TOOLSETS_MAX_ITEMS, ConnHelloPayloadSchema, ConnAckPayloadSchema, TaskOfferPayloadSchema, TaskOfferWithToolsetsPayloadSchema, TaskApprovePayloadSchema, TaskRejectPayloadSchema, TaskCancelPayloadSchema, TaskSteerPayloadSchema, TaskClaimPayloadSchema, TaskStartedPayloadSchema, TaskDeclinePayloadSchema, TaskProgressPayloadSchema, TaskArtifactPayloadSchema, TaskAwaitApprovalPayloadSchema, TaskCompletePayloadSchema, TaskFailPayloadSchema, TaskCancelledPayloadSchema, TaskApprovalResolvedPayloadSchema, RESULT_DOCUMENT_MAX_BYTES, checkResultDocument, TerminalInferenceUsageSchema, TERMINAL_INFERENCE_USAGE_MAX_TOKENS, TERMINAL_INFERENCE_USAGE_MAX_DURATION_MS, TERMINAL_INFERENCE_USAGE_PROVIDER_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_MODEL_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_CLIENT_VERSION_MAX_LENGTH, } from './messages';
12
- export type { ResultDocumentCheck, MessageType, RuntimeId, RuntimeInfo, RuntimeCapabilities, DispatchSelection, ToolsetId, ConnHelloPayload, ConnAckPayload, TaskOfferPayload, TaskOfferWithToolsetsPayload, TaskApprovePayload, TaskRejectPayload, TaskCancelPayload, TaskSteerPayload, TaskClaimPayload, TaskStartedPayload, TaskDeclinePayload, TaskProgressPayload, TaskArtifactPayload, TaskAwaitApprovalPayload, TaskCompletePayload, TaskFailPayload, TaskCancelledPayload, TaskApprovalResolvedPayload, TerminalInferenceUsage, } from './messages';
13
+ export { MESSAGE_TYPES, MESSAGE_PAYLOAD_SCHEMAS, SERVER_TO_DAEMON_TYPES, DAEMON_TO_SERVER_TYPES, RuntimeIdSchema, ProtocolVersionNumberSchema, RuntimeInfoSchema, RuntimeCapabilitiesSchema, AgentRefSchema, AGENT_REF_MAX_BYTES, DispatchSelectionSchema, ToolsetIdSchema, ConfiguredToolsetsSchema, RequiredToolsetsSchema, CONFIGURED_TOOLSETS_MAX_ITEMS, ConnHelloPayloadSchema, ConnAckPayloadSchema, TaskOfferPayloadSchema, TaskOfferWithToolsetsPayloadSchema, TaskOfferForAgentPayloadSchema, TaskOfferForAgentWithEgressPayloadSchema, AgentEgressReliablePayloadSchema, AgentEgressAckPayloadSchema, AgentContentReadPayloadSchema, AgentContentReceiptPayloadSchema, TaskApprovePayloadSchema, TaskRejectPayloadSchema, TaskCancelPayloadSchema, TaskSteerPayloadSchema, TaskClaimPayloadSchema, TaskStartedPayloadSchema, TaskDeclinePayloadSchema, TaskProgressPayloadSchema, TaskArtifactPayloadSchema, TaskAwaitApprovalPayloadSchema, TaskCompletePayloadSchema, TaskFailPayloadSchema, TaskCancelledPayloadSchema, TaskApprovalResolvedPayloadSchema, RESULT_DOCUMENT_MAX_BYTES, checkResultDocument, TerminalInferenceUsageSchema, TERMINAL_INFERENCE_USAGE_MAX_TOKENS, TERMINAL_INFERENCE_USAGE_MAX_DURATION_MS, TERMINAL_INFERENCE_USAGE_PROVIDER_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_MODEL_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_CLIENT_VERSION_MAX_LENGTH, } from './messages';
14
+ export type { ResultDocumentCheck, MessageType, RuntimeId, RuntimeInfo, RuntimeCapabilities, AgentRef, DispatchSelection, ToolsetId, ConnHelloPayload, ConnAckPayload, TaskOfferPayload, TaskOfferWithToolsetsPayload, TaskOfferForAgentPayload, TaskOfferForAgentWithEgressPayload, AgentEgressReliablePayload, AgentEgressAckPayload, AgentContentReadPayload, AgentContentReceiptPayload, TaskApprovePayload, TaskRejectPayload, TaskCancelPayload, TaskSteerPayload, TaskClaimPayload, TaskStartedPayload, TaskDeclinePayload, TaskProgressPayload, TaskArtifactPayload, TaskAwaitApprovalPayload, TaskCompletePayload, TaskFailPayload, TaskCancelledPayload, TaskApprovalResolvedPayload, TerminalInferenceUsage, } from './messages';
13
15
  export { EnvelopeSchema, isServerToDaemonType } from './envelope';
14
16
  export type { Envelope } from './envelope';
15
17
  export { ProtocolError, EnvelopeParseError, UnknownMessageTypeError, EnvelopeValidationError, } from './errors';
16
18
  export { encodeEnvelope, decodeEnvelope, createEnvelope, parseMessage } from './codec';
17
19
  export type { CreateEnvelopeOptions } from './codec';
18
- export { PairRequestSchema, PairResponseSchema, ChallengeRequestSchema, ChallengeResponseSchema, TokenRequestSchema, TokenResponseSchema, PresencePublishRequestSchema, CreateBlobRequestSchema, CreateBlobResponseSchema, BlobDownloadUrlResponseSchema, EventsPollQuerySchema, EventsPollResponseSchema, MessagesSendRequestSchema, MessagesSendResponseSchema, MAX_MESSAGES_PER_BATCH, BYOK_WS_PATH, BYOK_PAIR_PATH, BYOK_CHALLENGE_PATH, BYOK_TOKEN_PATH, BYOK_CAPABILITIES_PATH, BYOK_EVENTS_PATH, BYOK_MESSAGES_PATH, BYOK_PRESENCE_PATH, BYOK_ACTIVITY_PATH, BYOK_BOARD_PATH, BYOK_BOARD_STREAM_PATH, BYOK_BOARD_CLAIM_ROUTE, BYOK_BOARD_UNCLAIM_ROUTE, BYOK_BOARD_STATUS_ROUTE, BYOK_RECORDS_PATH, BYOK_RECORD_ROUTE, byokRecordPath, BYOK_SKILL_PACKS_PATH, BYOK_SKILL_PACK_FILE_ROUTE, byokSkillPackFilePath, BYOK_BLOBS_PATH, BYOK_BLOB_FINALIZE_ROUTE, BYOK_BLOB_URL_ROUTE, BYOK_BLOB_CONTENT_ROUTE, byokBlobFinalizePath, byokBlobUrlPath, byokBlobContentPath, } from './http-api';
20
+ export { PairRequestSchema, PairResponseTenantIdSchema, PAIR_RESPONSE_TENANT_ID_MAX_LENGTH, PairResponseSchema, ChallengeRequestSchema, ChallengeResponseSchema, TokenRequestSchema, TokenResponseSchema, PresencePublishRequestSchema, CreateBlobRequestSchema, CreateBlobResponseSchema, BlobDownloadUrlResponseSchema, EventsPollQuerySchema, EventsPollResponseSchema, MessagesSendRequestSchema, MessagesSendResponseSchema, MAX_MESSAGES_PER_BATCH, BYOK_WS_PATH, BYOK_PAIR_PATH, BYOK_CHALLENGE_PATH, BYOK_TOKEN_PATH, BYOK_CAPABILITIES_PATH, BYOK_EVENTS_PATH, BYOK_MESSAGES_PATH, BYOK_PRESENCE_PATH, BYOK_ACTIVITY_PATH, BYOK_BOARD_PATH, BYOK_BOARD_STREAM_PATH, BYOK_BOARD_CLAIM_ROUTE, BYOK_BOARD_UNCLAIM_ROUTE, BYOK_BOARD_STATUS_ROUTE, BYOK_RECORDS_PATH, BYOK_RECORD_ROUTE, byokRecordPath, BYOK_SKILL_PACKS_PATH, BYOK_SKILL_PACK_FILE_ROUTE, byokSkillPackFilePath, BYOK_BLOBS_PATH, BYOK_BLOB_FINALIZE_ROUTE, BYOK_BLOB_URL_ROUTE, BYOK_BLOB_CONTENT_ROUTE, byokBlobFinalizePath, byokBlobUrlPath, byokBlobContentPath, } from './http-api';
19
21
  export type { PairRequest, PairResponse, ChallengeRequest, ChallengeResponse, TokenRequest, TokenResponse, PresencePublishRequest, CreateBlobRequest, CreateBlobResponse, BlobDownloadUrlResponse, EventsPollQuery, EventsPollResponse, MessagesSendRequest, MessagesSendResponse, } from './http-api';
package/dist/index.js CHANGED
@@ -1,5 +1,89 @@
1
1
  import { z } from 'zod';
2
2
 
3
+ // src/agent-egress.ts
4
+ var AGENT_EGRESS_POLICY_CAPABILITY = "agent-egress-policy";
5
+ var AGENT_EGRESS_RELIABLE_ACK_CAPABILITY = "agent-egress-reliable-ack";
6
+ var AGENT_CONTENT_WORKSPACE_READ_CAPABILITY = "agent-content-workspace-read";
7
+ var AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY = "agent-content-transcript-read";
8
+ var AGENT_CONTENT_ARTIFACT_READ_CAPABILITY = "agent-content-artifact-read";
9
+ var POLICY_REVISION = z.string().min(1).max(160).regex(/^[^\u0000-\u001f\u007f\r\n]+$/u, "policyRevision must not contain control characters");
10
+ var POSITIVE_LIMIT = z.number().int().positive().max(2147483647);
11
+ var AgentContentMimeTypeSchema = z.string().min(3).max(255).regex(/^[a-z0-9!#$&^_.+-]+\/[a-z0-9!#$&^_.+-]+$/iu, "MIME types must be explicit type/subtype values");
12
+ var ContentReadPolicySchema = z.object({
13
+ maxBytes: POSITIVE_LIMIT,
14
+ allowedMimeTypes: z.array(AgentContentMimeTypeSchema).min(1).max(32)
15
+ }).strict();
16
+ var AgentEgressActivityPolicySchema = z.discriminatedUnion("mode", [
17
+ z.object({
18
+ mode: z.literal("metadata-status"),
19
+ delivery: z.literal("latest-value")
20
+ }).strict(),
21
+ z.object({
22
+ mode: z.literal("contentful-trajectory"),
23
+ delivery: z.literal("latest-value"),
24
+ maxCoalesceMs: POSITIVE_LIMIT,
25
+ maxEventBytes: POSITIVE_LIMIT
26
+ }).strict()
27
+ ]);
28
+ var AgentReliableQuotaPolicySchema = z.object({
29
+ maxPendingEventsPerAgent: POSITIVE_LIMIT,
30
+ maxPendingBytesPerAgent: POSITIVE_LIMIT,
31
+ maxPendingBytesPerTenant: POSITIVE_LIMIT
32
+ }).strict();
33
+ var AgentEgressPolicySchema = z.object({
34
+ policyRevision: POLICY_REVISION,
35
+ activity: AgentEgressActivityPolicySchema,
36
+ reliable: AgentReliableQuotaPolicySchema,
37
+ transfers: z.object({
38
+ workspace: z.union([z.literal("disabled"), ContentReadPolicySchema]),
39
+ transcript: z.union([z.literal("disabled"), ContentReadPolicySchema]),
40
+ artifact: z.union([z.literal("disabled"), ContentReadPolicySchema])
41
+ }).strict()
42
+ }).strict();
43
+ var AgentEgressLaneSchema = z.enum(["reliable", "latest-value"]);
44
+ var AgentEgressDropReasonSchema = z.enum([
45
+ "policy_denied",
46
+ "capability_missing",
47
+ "sanitizer_rejected",
48
+ "quota_exceeded",
49
+ "backpressure",
50
+ "coalesced",
51
+ "disconnected",
52
+ "invalid_envelope",
53
+ "ack_mismatch"
54
+ ]);
55
+ var AgentContentReadSurfaceSchema = z.enum(["workspace", "transcript", "artifact"]);
56
+ var AgentContentActorKindSchema = z.enum(["user", "agent", "system"]);
57
+ var AgentContentActorSchema = z.object({
58
+ kind: AgentContentActorKindSchema,
59
+ id: z.string().min(1).max(512).regex(/^[^\u0000-\u001f\u007f]+$/u, "actor id must not contain control characters")
60
+ }).strict();
61
+ var AgentContentDecodeAsSchema = z.enum(["bytes", "utf8"]);
62
+ var AgentContentReadDecisionSchema = z.enum(["allowed", "denied"]);
63
+ var AgentContentReadDenialReasonSchema = z.enum([
64
+ "invalid-request",
65
+ "policy-disabled",
66
+ "capability-missing",
67
+ "policy-revision-mismatch",
68
+ "absolute-target",
69
+ "non-relative-target",
70
+ "dot-segment",
71
+ "sensitive-name",
72
+ "root-not-allowlisted",
73
+ "root-invalid",
74
+ "path-escape",
75
+ "target-missing",
76
+ "symlink",
77
+ "not-regular-file",
78
+ "byte-limit",
79
+ "mime-not-allowlisted",
80
+ "text-not-allowlisted",
81
+ "text-decode-failed",
82
+ "identity-mismatch"
83
+ ]);
84
+ var AgentEgressContentHashSchema = z.string().regex(/^sha256:[a-f0-9]{64}$/u, "contentHash must be a lowercase SHA-256 digest");
85
+ var AgentEgressPolicyRevisionSchema = POLICY_REVISION;
86
+
3
87
  // src/version.ts
4
88
  var PROTOCOL_VERSION = 1;
5
89
  var CAPABILITY_FLAGS = [
@@ -10,7 +94,13 @@ var CAPABILITY_FLAGS = [
10
94
  "approval-targeting",
11
95
  "result-document",
12
96
  "dispatch-selection",
13
- "toolset-selection"
97
+ "toolset-selection",
98
+ "agent-home-contract",
99
+ AGENT_EGRESS_POLICY_CAPABILITY,
100
+ AGENT_EGRESS_RELIABLE_ACK_CAPABILITY,
101
+ AGENT_CONTENT_WORKSPACE_READ_CAPABILITY,
102
+ AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY,
103
+ AGENT_CONTENT_ARTIFACT_READ_CAPABILITY
14
104
  ];
15
105
  var CONTENT_HASH_RE = /^sha256:[0-9a-f]{64}$/;
16
106
  var BlobRefSchema = z.object({
@@ -129,6 +219,21 @@ var RuntimeInfoSchema = z.object({
129
219
  });
130
220
  var CONFIGURED_TOOLSETS_MAX_ITEMS = 64;
131
221
  var ToolsetIdSchema = z.string().min(1).max(128).regex(/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/u, "toolset ids must be lowercase logical identifiers");
222
+ var AGENT_REF_MAX_BYTES = 160;
223
+ var AGENT_REF_VALUE = z.string().min(1).max(AGENT_REF_MAX_BYTES).refine((value) => new TextEncoder().encode(value).byteLength <= AGENT_REF_MAX_BYTES, {
224
+ message: `AgentRef values must not exceed ${AGENT_REF_MAX_BYTES} UTF-8 bytes`
225
+ }).regex(/^[^\u0000-\u001f\u007f\r\n]+$/u, "AgentRef values must not contain control characters");
226
+ var WINDOWS_RESERVED_AGENT_SEGMENT = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\..*)?$/iu;
227
+ var AgentRefSchema = z.object({
228
+ agentId: AGENT_REF_VALUE.regex(/^[^\\/:<>"|?*]+$/u, "agentId must be one portable pathname segment").refine(
229
+ (value) => value !== "." && value !== "..",
230
+ "agentId must not be a dot segment"
231
+ ).refine(
232
+ (value) => !/[. ]$/u.test(value) && !WINDOWS_RESERVED_AGENT_SEGMENT.test(value),
233
+ "agentId must be a portable Windows-safe pathname segment"
234
+ ),
235
+ profileRevision: AGENT_REF_VALUE
236
+ }).strict();
132
237
  function rejectDuplicateToolsets(ids, ctx, label) {
133
238
  const seen = /* @__PURE__ */ new Set();
134
239
  for (const [index, id] of ids.entries()) {
@@ -195,6 +300,117 @@ var RequiredToolsetsSchema = z.array(ToolsetIdSchema).min(1).max(16).superRefine
195
300
  var TaskOfferWithToolsetsPayloadSchema = TaskOfferPayloadSchema.extend({
196
301
  requiredToolsets: RequiredToolsetsSchema
197
302
  }).strict();
303
+ var TaskOfferForAgentPayloadSchema = z.object({
304
+ instruction: z.union([z.string(), InstructionBlobRefSchema]),
305
+ policy: PermissionPolicySchema,
306
+ agentRef: AgentRefSchema,
307
+ requiredToolsets: RequiredToolsetsSchema.optional(),
308
+ runtime: RuntimeIdSchema.optional(),
309
+ dispatchSelection: DispatchSelectionSchema.optional(),
310
+ sessionRef: z.string().optional(),
311
+ limits: z.object({
312
+ maxDurationMs: z.number().int().positive().optional(),
313
+ maxTokens: z.number().int().positive().optional()
314
+ }).optional()
315
+ }).strict();
316
+ var TaskOfferForAgentWithEgressPayloadSchema = TaskOfferForAgentPayloadSchema.extend({
317
+ sessionRef: z.string().min(1).max(512),
318
+ egressPolicy: AgentEgressPolicySchema
319
+ }).strict();
320
+ var EGRESS_SAFE_VALUE = z.json().refine(
321
+ (value) => new TextEncoder().encode(JSON.stringify(value)).byteLength <= 256 * 1024,
322
+ "sanitized egress payload exceeds 256KiB"
323
+ );
324
+ var EGRESS_SESSION_REF = z.string().min(1).max(512);
325
+ var AgentEgressReliablePayloadSchema = z.object({
326
+ agentRef: AgentRefSchema,
327
+ sessionRef: EGRESS_SESSION_REF,
328
+ policyRevision: AgentEgressPolicyRevisionSchema,
329
+ eventId: z.uuid(),
330
+ cursor: z.number().int().positive(),
331
+ payload: EGRESS_SAFE_VALUE,
332
+ contentHash: AgentEgressContentHashSchema,
333
+ byteCount: z.number().int().nonnegative().max(256 * 1024)
334
+ }).strict();
335
+ var AgentEgressAckPayloadSchema = z.object({
336
+ agentRef: AgentRefSchema,
337
+ sessionRef: EGRESS_SESSION_REF,
338
+ policyRevision: AgentEgressPolicyRevisionSchema,
339
+ eventId: z.uuid(),
340
+ cursor: z.number().int().positive(),
341
+ receiptId: z.uuid()
342
+ }).strict();
343
+ var AGENT_CONTENT_TARGET = z.string().min(1).max(1024).regex(/^[^\u0000-\u001f\u007f]+$/u, "content target must not contain control characters").refine(
344
+ (value) => !value.startsWith("/") && !value.includes("\\") && value.split("/").every((segment) => segment.length > 0 && segment !== "." && segment !== ".."),
345
+ "content target must be a portable relative path without dot segments"
346
+ );
347
+ var AGENT_CONTENT_CWD = z.string().min(1).max(4096).regex(/^[^\u0000-\u001f\u007f]+$/u, "cwd must not contain control characters").regex(/^(?:\/|[A-Za-z]:[\\/])/u, "cwd must be absolute");
348
+ var AgentContentReadPayloadSchema = z.object({
349
+ requestId: z.uuid(),
350
+ surface: AgentContentReadSurfaceSchema,
351
+ actor: AgentContentActorSchema,
352
+ agentRef: AgentRefSchema,
353
+ sessionRef: EGRESS_SESSION_REF,
354
+ runtime: RuntimeIdSchema,
355
+ cwd: AGENT_CONTENT_CWD,
356
+ policyRevision: AgentEgressPolicyRevisionSchema,
357
+ target: AGENT_CONTENT_TARGET,
358
+ mimeType: AgentContentMimeTypeSchema,
359
+ decodeAs: AgentContentDecodeAsSchema,
360
+ policy: ContentReadPolicySchema
361
+ }).strict();
362
+ var AgentContentReceiptPayloadSchema = z.discriminatedUnion("decision", [
363
+ z.object({
364
+ requestId: z.uuid(),
365
+ /** Stable reliable-delivery identity. Content receipts use their requestId. */
366
+ eventId: z.uuid(),
367
+ /** Stable positive cursor allocated by the durable Agent spool. */
368
+ cursor: z.number().int().positive(),
369
+ surface: AgentContentReadSurfaceSchema,
370
+ actor: AgentContentActorSchema,
371
+ agentRef: AgentRefSchema,
372
+ sessionRef: EGRESS_SESSION_REF,
373
+ runtime: RuntimeIdSchema,
374
+ cwd: AGENT_CONTENT_CWD,
375
+ policyRevision: AgentEgressPolicyRevisionSchema,
376
+ target: AGENT_CONTENT_TARGET,
377
+ mimeType: AgentContentMimeTypeSchema,
378
+ decodeAs: AgentContentDecodeAsSchema,
379
+ decision: z.literal("allowed"),
380
+ byteCount: z.number().int().nonnegative(),
381
+ contentHash: AgentEgressContentHashSchema,
382
+ blobRef: BlobRefSchema
383
+ }).strict(),
384
+ z.object({
385
+ requestId: z.uuid(),
386
+ eventId: z.uuid(),
387
+ cursor: z.number().int().positive(),
388
+ surface: AgentContentReadSurfaceSchema,
389
+ actor: AgentContentActorSchema,
390
+ agentRef: AgentRefSchema,
391
+ sessionRef: EGRESS_SESSION_REF,
392
+ runtime: RuntimeIdSchema,
393
+ cwd: AGENT_CONTENT_CWD,
394
+ policyRevision: AgentEgressPolicyRevisionSchema,
395
+ target: AGENT_CONTENT_TARGET,
396
+ mimeType: AgentContentMimeTypeSchema,
397
+ decodeAs: AgentContentDecodeAsSchema,
398
+ decision: z.literal("denied"),
399
+ byteCount: z.literal(0),
400
+ reason: AgentContentReadDenialReasonSchema
401
+ }).strict()
402
+ ]).superRefine((value, ctx) => {
403
+ if (value.decision !== "allowed") return;
404
+ if (value.blobRef.size !== value.byteCount) {
405
+ ctx.addIssue({ code: "custom", path: ["blobRef", "size"], message: "blobRef size must equal byteCount" });
406
+ }
407
+ if (value.blobRef.contentHash !== value.contentHash) {
408
+ ctx.addIssue({ code: "custom", path: ["blobRef", "contentHash"], message: "blobRef contentHash must equal contentHash" });
409
+ }
410
+ if (value.blobRef.contentType !== value.mimeType) {
411
+ ctx.addIssue({ code: "custom", path: ["blobRef", "contentType"], message: "blobRef contentType must equal mimeType" });
412
+ }
413
+ });
198
414
  var TaskApprovePayloadSchema = z.object({
199
415
  approvalId: z.string().optional()
200
416
  });
@@ -211,13 +427,15 @@ var TaskSteerPayloadSchema = z.object({
211
427
  var TaskClaimPayloadSchema = z.object({
212
428
  deviceId: z.string(),
213
429
  agentId: z.string().optional(),
430
+ agentRef: AgentRefSchema.optional(),
214
431
  runtime: RuntimeIdSchema.optional(),
215
432
  capabilities: RuntimeCapabilitiesSchema.optional()
216
433
  });
217
434
  var TaskStartedPayloadSchema = z.object({});
218
435
  var TaskDeclinePayloadSchema = z.object({
219
436
  reason: z.string(),
220
- retryable: z.boolean().optional()
437
+ retryable: z.boolean().optional(),
438
+ agentRef: AgentRefSchema.optional()
221
439
  });
222
440
  var TaskProgressPayloadSchema = z.object({
223
441
  seq: z.number().int(),
@@ -316,16 +534,19 @@ var TaskCompletePayloadSchema = z.object({
316
534
  document: z.unknown().optional().refine((value) => value === void 0 || checkResultDocument(value).ok, {
317
535
  message: `task.complete.document must be plain JSON data (equal to its own JSON round trip) and at most ${RESULT_DOCUMENT_MAX_BYTES} bytes as canonical JSON (UTF-8)`
318
536
  }),
319
- usage: TerminalInferenceUsageSchema.optional()
537
+ usage: TerminalInferenceUsageSchema.optional(),
538
+ agentRef: AgentRefSchema.optional()
320
539
  });
321
540
  var TaskFailPayloadSchema = z.object({
322
541
  reason: z.string(),
323
542
  retryable: z.boolean().optional(),
324
- usage: TerminalInferenceUsageSchema.optional()
543
+ usage: TerminalInferenceUsageSchema.optional(),
544
+ agentRef: AgentRefSchema.optional()
325
545
  });
326
546
  var TaskCancelledPayloadSchema = z.object({
327
547
  reason: z.string().optional(),
328
- usage: TerminalInferenceUsageSchema.optional()
548
+ usage: TerminalInferenceUsageSchema.optional(),
549
+ agentRef: AgentRefSchema.optional()
329
550
  });
330
551
  var TaskApprovalResolvedPayloadSchema = z.object({
331
552
  approvalId: z.string(),
@@ -338,6 +559,12 @@ var MESSAGE_PAYLOAD_SCHEMAS = {
338
559
  "conn.ack": ConnAckPayloadSchema,
339
560
  "task.offer": TaskOfferPayloadSchema,
340
561
  "task.offer_with_toolsets": TaskOfferWithToolsetsPayloadSchema,
562
+ "task.offer_for_agent": TaskOfferForAgentPayloadSchema,
563
+ "task.offer_for_agent_with_egress": TaskOfferForAgentWithEgressPayloadSchema,
564
+ "agent.egress.reliable": AgentEgressReliablePayloadSchema,
565
+ "agent.egress.ack": AgentEgressAckPayloadSchema,
566
+ "agent.content.read": AgentContentReadPayloadSchema,
567
+ "agent.content.receipt": AgentContentReceiptPayloadSchema,
341
568
  "task.approve": TaskApprovePayloadSchema,
342
569
  "task.reject": TaskRejectPayloadSchema,
343
570
  "task.cancel": TaskCancelPayloadSchema,
@@ -358,6 +585,10 @@ var SERVER_TO_DAEMON_TYPES = [
358
585
  "conn.ack",
359
586
  "task.offer",
360
587
  "task.offer_with_toolsets",
588
+ "task.offer_for_agent",
589
+ "task.offer_for_agent_with_egress",
590
+ "agent.egress.ack",
591
+ "agent.content.read",
361
592
  "task.approve",
362
593
  "task.reject",
363
594
  "task.cancel",
@@ -373,7 +604,9 @@ var DAEMON_TO_SERVER_TYPES = [
373
604
  "task.complete",
374
605
  "task.fail",
375
606
  "task.cancelled",
376
- "task.approval_resolved"
607
+ "task.approval_resolved",
608
+ "agent.egress.reliable",
609
+ "agent.content.receipt"
377
610
  ];
378
611
  var REQUIRED_TASK_ID = z.string().min(1);
379
612
  var OPTIONAL_TASK_ID = REQUIRED_TASK_ID.optional();
@@ -401,6 +634,10 @@ var EnvelopeSchema = z.discriminatedUnion("type", [
401
634
  // (per-device redelivery cursor).
402
635
  envelopeShape("task.offer", REQUIRED_TASK_ID, REQUIRED_SEQ),
403
636
  envelopeShape("task.offer_with_toolsets", REQUIRED_TASK_ID, REQUIRED_SEQ),
637
+ envelopeShape("task.offer_for_agent", REQUIRED_TASK_ID, REQUIRED_SEQ),
638
+ envelopeShape("task.offer_for_agent_with_egress", REQUIRED_TASK_ID, REQUIRED_SEQ),
639
+ envelopeShape("agent.egress.ack", OPTIONAL_TASK_ID, REQUIRED_SEQ),
640
+ envelopeShape("agent.content.read", OPTIONAL_TASK_ID, REQUIRED_SEQ),
404
641
  envelopeShape("task.approve", REQUIRED_TASK_ID, REQUIRED_SEQ),
405
642
  envelopeShape("task.reject", REQUIRED_TASK_ID, REQUIRED_SEQ),
406
643
  envelopeShape("task.cancel", REQUIRED_TASK_ID, REQUIRED_SEQ),
@@ -417,7 +654,9 @@ var EnvelopeSchema = z.discriminatedUnion("type", [
417
654
  envelopeShape("task.complete", REQUIRED_TASK_ID, OPTIONAL_SEQ),
418
655
  envelopeShape("task.fail", REQUIRED_TASK_ID, OPTIONAL_SEQ),
419
656
  envelopeShape("task.cancelled", REQUIRED_TASK_ID, OPTIONAL_SEQ),
420
- envelopeShape("task.approval_resolved", REQUIRED_TASK_ID, OPTIONAL_SEQ)
657
+ envelopeShape("task.approval_resolved", REQUIRED_TASK_ID, OPTIONAL_SEQ),
658
+ envelopeShape("agent.egress.reliable", OPTIONAL_TASK_ID, OPTIONAL_SEQ),
659
+ envelopeShape("agent.content.receipt", OPTIONAL_TASK_ID, OPTIONAL_SEQ)
421
660
  ]);
422
661
  function isServerToDaemonType(type) {
423
662
  return SERVER_TO_DAEMON_TYPES.includes(type);
@@ -510,12 +749,20 @@ var PairRequestSchema = z.object({
510
749
  /** Ed25519 public key, base64url-encoded. Private key stays device-local (OS keychain or 0600 file). */
511
750
  devicePublicKey: z.string()
512
751
  });
752
+ var PAIR_RESPONSE_TENANT_ID_MAX_LENGTH = 200;
753
+ var PairResponseTenantIdSchema = z.string().min(1).max(PAIR_RESPONSE_TENANT_ID_MAX_LENGTH).refine((value) => value.trim() === value, {
754
+ message: "tenantId must not have leading or trailing whitespace"
755
+ }).refine((value) => !value.includes("\0"), {
756
+ message: "tenantId must not contain a NUL character"
757
+ });
513
758
  var PairResponseSchema = z.object({
514
759
  deviceId: z.string(),
515
760
  /** JWT, ~1h lifetime. */
516
761
  accessToken: z.string(),
517
762
  /** Opaque hint for when/how to renew (e.g. an ISO timestamp); not itself a credential. */
518
- refreshHint: z.string().optional()
763
+ refreshHint: z.string().optional(),
764
+ /** Exact opaque, non-secret tenant binding from the authenticated device row. */
765
+ tenantId: PairResponseTenantIdSchema
519
766
  });
520
767
  var ChallengeRequestSchema = z.object({
521
768
  deviceId: z.string()
@@ -624,6 +871,6 @@ function byokBlobContentPath(blobId) {
624
871
  return `/byok/blobs/${blobId}/content`;
625
872
  }
626
873
 
627
- export { AgentEventOrUnknownSchema, AgentEventSchema, BYOK_ACTIVITY_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_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, BYOK_WS_PATH, BlobDownloadUrlResponseSchema, BlobRefSchema, CAPABILITY_FLAGS, CONFIGURED_TOOLSETS_MAX_ITEMS, CONTENT_HASH_RE, ChallengeRequestSchema, ChallengeResponseSchema, ConfiguredToolsetsSchema, ConnAckPayloadSchema, ConnHelloPayloadSchema, CreateBlobRequestSchema, CreateBlobResponseSchema, DAEMON_TO_SERVER_TYPES, DispatchSelectionSchema, EnvelopeParseError, EnvelopeSchema, EnvelopeValidationError, EventsPollQuerySchema, EventsPollResponseSchema, KNOWN_AGENT_EVENT_TYPES, MAX_MESSAGES_PER_BATCH, MESSAGE_PAYLOAD_SCHEMAS, MESSAGE_TYPES, MessagesSendRequestSchema, MessagesSendResponseSchema, PERMISSION_MODES, PROTOCOL_VERSION, PairRequestSchema, PairResponseSchema, PermissionPolicySchema, PresencePublishRequestSchema, ProtocolError, ProtocolVersionNumberSchema, RESULT_DOCUMENT_MAX_BYTES, RequiredToolsetsSchema, RuntimeCapabilitiesSchema, RuntimeIdSchema, RuntimeInfoSchema, SERVER_TO_DAEMON_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, TaskApprovalResolvedPayloadSchema, TaskApprovePayloadSchema, TaskArtifactPayloadSchema, TaskAwaitApprovalPayloadSchema, TaskCancelPayloadSchema, TaskCancelledPayloadSchema, TaskClaimPayloadSchema, TaskCompletePayloadSchema, TaskDeclinePayloadSchema, TaskFailPayloadSchema, TaskOfferPayloadSchema, TaskOfferWithToolsetsPayloadSchema, TaskProgressPayloadSchema, TaskRejectPayloadSchema, TaskStartedPayloadSchema, TaskSteerPayloadSchema, TerminalInferenceUsageSchema, TokenRequestSchema, TokenResponseSchema, ToolsetIdSchema, UnknownAgentEventSchema, UnknownMessageTypeError, byokBlobContentPath, byokBlobFinalizePath, byokBlobUrlPath, byokRecordPath, byokSkillPackFilePath, canTransition, checkResultDocument, createEnvelope, decodeEnvelope, encodeEnvelope, isKnownAgentEvent, isServerToDaemonType, parseMessage, partitionAgentEvents };
874
+ export { AGENT_CONTENT_ARTIFACT_READ_CAPABILITY, AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY, AGENT_CONTENT_WORKSPACE_READ_CAPABILITY, AGENT_EGRESS_POLICY_CAPABILITY, AGENT_EGRESS_RELIABLE_ACK_CAPABILITY, AGENT_REF_MAX_BYTES, AgentContentActorKindSchema, AgentContentActorSchema, AgentContentDecodeAsSchema, AgentContentMimeTypeSchema, AgentContentReadDecisionSchema, AgentContentReadDenialReasonSchema, AgentContentReadPayloadSchema, AgentContentReadSurfaceSchema, AgentContentReceiptPayloadSchema, AgentEgressAckPayloadSchema, AgentEgressActivityPolicySchema, AgentEgressContentHashSchema, AgentEgressDropReasonSchema, AgentEgressLaneSchema, AgentEgressPolicyRevisionSchema, AgentEgressPolicySchema, AgentEgressReliablePayloadSchema, AgentEventOrUnknownSchema, AgentEventSchema, AgentRefSchema, AgentReliableQuotaPolicySchema, BYOK_ACTIVITY_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_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, BYOK_WS_PATH, BlobDownloadUrlResponseSchema, BlobRefSchema, CAPABILITY_FLAGS, CONFIGURED_TOOLSETS_MAX_ITEMS, CONTENT_HASH_RE, ChallengeRequestSchema, ChallengeResponseSchema, ConfiguredToolsetsSchema, ConnAckPayloadSchema, ConnHelloPayloadSchema, ContentReadPolicySchema, CreateBlobRequestSchema, CreateBlobResponseSchema, DAEMON_TO_SERVER_TYPES, DispatchSelectionSchema, EnvelopeParseError, EnvelopeSchema, EnvelopeValidationError, EventsPollQuerySchema, EventsPollResponseSchema, KNOWN_AGENT_EVENT_TYPES, MAX_MESSAGES_PER_BATCH, MESSAGE_PAYLOAD_SCHEMAS, MESSAGE_TYPES, MessagesSendRequestSchema, MessagesSendResponseSchema, PAIR_RESPONSE_TENANT_ID_MAX_LENGTH, PERMISSION_MODES, PROTOCOL_VERSION, PairRequestSchema, PairResponseSchema, PairResponseTenantIdSchema, PermissionPolicySchema, PresencePublishRequestSchema, ProtocolError, ProtocolVersionNumberSchema, RESULT_DOCUMENT_MAX_BYTES, RequiredToolsetsSchema, RuntimeCapabilitiesSchema, RuntimeIdSchema, RuntimeInfoSchema, SERVER_TO_DAEMON_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, TaskApprovalResolvedPayloadSchema, TaskApprovePayloadSchema, TaskArtifactPayloadSchema, TaskAwaitApprovalPayloadSchema, TaskCancelPayloadSchema, TaskCancelledPayloadSchema, TaskClaimPayloadSchema, TaskCompletePayloadSchema, TaskDeclinePayloadSchema, TaskFailPayloadSchema, TaskOfferForAgentPayloadSchema, TaskOfferForAgentWithEgressPayloadSchema, TaskOfferPayloadSchema, TaskOfferWithToolsetsPayloadSchema, TaskProgressPayloadSchema, TaskRejectPayloadSchema, TaskStartedPayloadSchema, TaskSteerPayloadSchema, TerminalInferenceUsageSchema, TokenRequestSchema, TokenResponseSchema, ToolsetIdSchema, UnknownAgentEventSchema, UnknownMessageTypeError, byokBlobContentPath, byokBlobFinalizePath, byokBlobUrlPath, byokRecordPath, byokSkillPackFilePath, canTransition, checkResultDocument, createEnvelope, decodeEnvelope, encodeEnvelope, isKnownAgentEvent, isServerToDaemonType, parseMessage, partitionAgentEvents };
628
875
  //# sourceMappingURL=index.js.map
629
876
  //# sourceMappingURL=index.js.map