@byok-sdk/protocol 0.5.0 → 0.6.1

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.
@@ -5,6 +5,8 @@ export declare const RuntimeIdSchema: z.ZodEnum<{
5
5
  pi: "pi";
6
6
  }>;
7
7
  export type RuntimeId = z.infer<typeof RuntimeIdSchema>;
8
+ /** Wire-safe protocol version number: bounded before JSON reaches a store or comparison. */
9
+ export declare const ProtocolVersionNumberSchema: z.ZodNumber;
8
10
  /**
9
11
  * Per-runtime feature flags reported in `conn.hello.runtimes[].capabilities`
10
12
  * (pre-freeze addition). Distinct from the connection-level `CAPABILITY_FLAGS`
@@ -69,6 +71,17 @@ export declare const CONFIGURED_TOOLSETS_MAX_ITEMS = 64;
69
71
  */
70
72
  export declare const ToolsetIdSchema: z.ZodString;
71
73
  export type ToolsetId = z.infer<typeof ToolsetIdSchema>;
74
+ /** Stable Agent identity carried across transport and storage. */
75
+ export declare const AGENT_REF_MAX_BYTES = 160;
76
+ /**
77
+ * Agent ids are opaque to the SDK but must remain one safe pathname segment;
78
+ * the SDK owns the deterministic `<hostStorageRoot>/agents/<agentId>` mapping.
79
+ */
80
+ export declare const AgentRefSchema: z.ZodObject<{
81
+ agentId: z.ZodString;
82
+ profileRevision: z.ZodString;
83
+ }, z.core.$strict>;
84
+ export type AgentRef = z.infer<typeof AgentRefSchema>;
72
85
  /**
73
86
  * Device-local inventory projected for discovery. IDs only: executable MCP
74
87
  * definitions, arguments, environment and credentials never enter this shape.
@@ -81,6 +94,7 @@ export declare const ConnHelloPayloadSchema: z.ZodObject<{
81
94
  capabilities: z.ZodArray<z.ZodString>;
82
95
  deviceId: z.ZodString;
83
96
  productId: z.ZodString;
97
+ clientVersion: z.ZodOptional<z.ZodString>;
84
98
  runtimes: z.ZodOptional<z.ZodArray<z.ZodObject<{
85
99
  id: z.ZodEnum<{
86
100
  claude: "claude";
@@ -245,6 +259,327 @@ export declare const TaskOfferWithToolsetsPayloadSchema: z.ZodObject<{
245
259
  requiredToolsets: z.ZodArray<z.ZodString>;
246
260
  }, z.core.$strict>;
247
261
  export type TaskOfferWithToolsetsPayload = z.infer<typeof TaskOfferWithToolsetsPayloadSchema>;
262
+ /**
263
+ * Strict additive offer for a durable host-owned Agent. An older daemon that
264
+ * does not advertise `agent-home-contract` skips this distinct message type
265
+ * instead of stripping identity and applying legacy workspace semantics.
266
+ */
267
+ export declare const TaskOfferForAgentPayloadSchema: z.ZodObject<{
268
+ instruction: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
269
+ blobRef: z.ZodObject<{
270
+ blobId: z.ZodString;
271
+ contentHash: z.ZodString;
272
+ size: z.ZodNumber;
273
+ contentType: z.ZodString;
274
+ url: z.ZodOptional<z.ZodString>;
275
+ }, z.core.$strip>;
276
+ }, z.core.$strict>]>;
277
+ policy: z.ZodObject<{
278
+ mode: z.ZodEnum<{
279
+ auto: "auto";
280
+ confirm: "confirm";
281
+ plan: "plan";
282
+ readonly: "readonly";
283
+ }>;
284
+ allowTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
285
+ denyTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
286
+ workspaceRoot: z.ZodOptional<z.ZodString>;
287
+ network: z.ZodOptional<z.ZodBoolean>;
288
+ }, z.core.$strict>;
289
+ agentRef: z.ZodObject<{
290
+ agentId: z.ZodString;
291
+ profileRevision: z.ZodString;
292
+ }, z.core.$strict>;
293
+ requiredToolsets: z.ZodOptional<z.ZodArray<z.ZodString>>;
294
+ runtime: z.ZodOptional<z.ZodEnum<{
295
+ claude: "claude";
296
+ codex: "codex";
297
+ pi: "pi";
298
+ }>>;
299
+ dispatchSelection: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
300
+ lane: z.ZodLiteral<"subscription">;
301
+ runtimeId: z.ZodEnum<{
302
+ claude: "claude";
303
+ codex: "codex";
304
+ }>;
305
+ providerId: z.ZodNull;
306
+ modelId: z.ZodString;
307
+ }, z.core.$strict>, z.ZodObject<{
308
+ lane: z.ZodLiteral<"byok">;
309
+ runtimeId: z.ZodLiteral<"pi">;
310
+ providerId: z.ZodString;
311
+ modelId: z.ZodString;
312
+ }, z.core.$strict>], "lane">>;
313
+ sessionRef: z.ZodOptional<z.ZodString>;
314
+ limits: z.ZodOptional<z.ZodObject<{
315
+ maxDurationMs: z.ZodOptional<z.ZodNumber>;
316
+ maxTokens: z.ZodOptional<z.ZodNumber>;
317
+ }, z.core.$strip>>;
318
+ }, z.core.$strict>;
319
+ export type TaskOfferForAgentPayload = z.infer<typeof TaskOfferForAgentPayloadSchema>;
320
+ /**
321
+ * Strict Agent offer which consumes the typed egress policy. It is a distinct
322
+ * message so an older Agent-home daemon cannot strip control data and proceed
323
+ * with an unconsumed egress declaration.
324
+ */
325
+ export declare const TaskOfferForAgentWithEgressPayloadSchema: z.ZodObject<{
326
+ instruction: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
327
+ blobRef: z.ZodObject<{
328
+ blobId: z.ZodString;
329
+ contentHash: z.ZodString;
330
+ size: z.ZodNumber;
331
+ contentType: z.ZodString;
332
+ url: z.ZodOptional<z.ZodString>;
333
+ }, z.core.$strip>;
334
+ }, z.core.$strict>]>;
335
+ policy: z.ZodObject<{
336
+ mode: z.ZodEnum<{
337
+ auto: "auto";
338
+ confirm: "confirm";
339
+ plan: "plan";
340
+ readonly: "readonly";
341
+ }>;
342
+ allowTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
343
+ denyTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
344
+ workspaceRoot: z.ZodOptional<z.ZodString>;
345
+ network: z.ZodOptional<z.ZodBoolean>;
346
+ }, z.core.$strict>;
347
+ agentRef: z.ZodObject<{
348
+ agentId: z.ZodString;
349
+ profileRevision: z.ZodString;
350
+ }, z.core.$strict>;
351
+ requiredToolsets: z.ZodOptional<z.ZodArray<z.ZodString>>;
352
+ runtime: z.ZodOptional<z.ZodEnum<{
353
+ claude: "claude";
354
+ codex: "codex";
355
+ pi: "pi";
356
+ }>>;
357
+ dispatchSelection: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
358
+ lane: z.ZodLiteral<"subscription">;
359
+ runtimeId: z.ZodEnum<{
360
+ claude: "claude";
361
+ codex: "codex";
362
+ }>;
363
+ providerId: z.ZodNull;
364
+ modelId: z.ZodString;
365
+ }, z.core.$strict>, z.ZodObject<{
366
+ lane: z.ZodLiteral<"byok">;
367
+ runtimeId: z.ZodLiteral<"pi">;
368
+ providerId: z.ZodString;
369
+ modelId: z.ZodString;
370
+ }, z.core.$strict>], "lane">>;
371
+ limits: z.ZodOptional<z.ZodObject<{
372
+ maxDurationMs: z.ZodOptional<z.ZodNumber>;
373
+ maxTokens: z.ZodOptional<z.ZodNumber>;
374
+ }, z.core.$strip>>;
375
+ sessionRef: z.ZodString;
376
+ egressPolicy: z.ZodObject<{
377
+ policyRevision: z.ZodString;
378
+ activity: z.ZodDiscriminatedUnion<[z.ZodObject<{
379
+ mode: z.ZodLiteral<"metadata-status">;
380
+ delivery: z.ZodLiteral<"latest-value">;
381
+ }, z.core.$strict>, z.ZodObject<{
382
+ mode: z.ZodLiteral<"contentful-trajectory">;
383
+ delivery: z.ZodLiteral<"latest-value">;
384
+ maxCoalesceMs: z.ZodNumber;
385
+ maxEventBytes: z.ZodNumber;
386
+ }, z.core.$strict>], "mode">;
387
+ reliable: z.ZodObject<{
388
+ maxPendingEventsPerAgent: z.ZodNumber;
389
+ maxPendingBytesPerAgent: z.ZodNumber;
390
+ maxPendingBytesPerTenant: z.ZodNumber;
391
+ }, z.core.$strict>;
392
+ transfers: z.ZodObject<{
393
+ workspace: z.ZodUnion<readonly [z.ZodLiteral<"disabled">, z.ZodObject<{
394
+ maxBytes: z.ZodNumber;
395
+ allowedMimeTypes: z.ZodArray<z.ZodString>;
396
+ }, z.core.$strict>]>;
397
+ transcript: z.ZodUnion<readonly [z.ZodLiteral<"disabled">, z.ZodObject<{
398
+ maxBytes: z.ZodNumber;
399
+ allowedMimeTypes: z.ZodArray<z.ZodString>;
400
+ }, z.core.$strict>]>;
401
+ artifact: z.ZodUnion<readonly [z.ZodLiteral<"disabled">, z.ZodObject<{
402
+ maxBytes: z.ZodNumber;
403
+ allowedMimeTypes: z.ZodArray<z.ZodString>;
404
+ }, z.core.$strict>]>;
405
+ }, z.core.$strict>;
406
+ }, z.core.$strict>;
407
+ }, z.core.$strict>;
408
+ export type TaskOfferForAgentWithEgressPayload = z.infer<typeof TaskOfferForAgentWithEgressPayloadSchema>;
409
+ /** Daemon -> cloud: one durable reliable-lane item after local sanitization. */
410
+ export declare const AgentEgressReliablePayloadSchema: z.ZodObject<{
411
+ agentRef: z.ZodObject<{
412
+ agentId: z.ZodString;
413
+ profileRevision: z.ZodString;
414
+ }, z.core.$strict>;
415
+ sessionRef: z.ZodString;
416
+ policyRevision: z.ZodString;
417
+ eventId: z.ZodUUID;
418
+ cursor: z.ZodNumber;
419
+ payload: z.ZodJSONSchema;
420
+ contentHash: z.ZodString;
421
+ byteCount: z.ZodNumber;
422
+ }, z.core.$strict>;
423
+ export type AgentEgressReliablePayload = z.infer<typeof AgentEgressReliablePayloadSchema>;
424
+ /** Cloud -> daemon: exact acknowledgement for one reliable egress record. */
425
+ export declare const AgentEgressAckPayloadSchema: z.ZodObject<{
426
+ agentRef: z.ZodObject<{
427
+ agentId: z.ZodString;
428
+ profileRevision: z.ZodString;
429
+ }, z.core.$strict>;
430
+ sessionRef: z.ZodString;
431
+ policyRevision: z.ZodString;
432
+ eventId: z.ZodUUID;
433
+ cursor: z.ZodNumber;
434
+ receiptId: z.ZodUUID;
435
+ }, z.core.$strict>;
436
+ export type AgentEgressAckPayload = z.infer<typeof AgentEgressAckPayloadSchema>;
437
+ /** Server -> daemon: one exact, independently-capability-gated content read. */
438
+ export declare const AgentContentReadPayloadSchema: z.ZodObject<{
439
+ requestId: z.ZodUUID;
440
+ surface: z.ZodEnum<{
441
+ artifact: "artifact";
442
+ transcript: "transcript";
443
+ workspace: "workspace";
444
+ }>;
445
+ actor: z.ZodObject<{
446
+ kind: z.ZodEnum<{
447
+ agent: "agent";
448
+ system: "system";
449
+ user: "user";
450
+ }>;
451
+ id: z.ZodString;
452
+ }, z.core.$strict>;
453
+ agentRef: z.ZodObject<{
454
+ agentId: z.ZodString;
455
+ profileRevision: z.ZodString;
456
+ }, z.core.$strict>;
457
+ sessionRef: z.ZodString;
458
+ runtime: z.ZodEnum<{
459
+ claude: "claude";
460
+ codex: "codex";
461
+ pi: "pi";
462
+ }>;
463
+ cwd: z.ZodString;
464
+ policyRevision: z.ZodString;
465
+ target: z.ZodString;
466
+ mimeType: z.ZodString;
467
+ decodeAs: z.ZodEnum<{
468
+ bytes: "bytes";
469
+ utf8: "utf8";
470
+ }>;
471
+ policy: z.ZodObject<{
472
+ maxBytes: z.ZodNumber;
473
+ allowedMimeTypes: z.ZodArray<z.ZodString>;
474
+ }, z.core.$strict>;
475
+ }, z.core.$strict>;
476
+ export type AgentContentReadPayload = z.infer<typeof AgentContentReadPayloadSchema>;
477
+ /** Daemon -> cloud: durable, content-free content-read audit fact. */
478
+ export declare const AgentContentReceiptPayloadSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
479
+ requestId: z.ZodUUID;
480
+ eventId: z.ZodUUID;
481
+ cursor: z.ZodNumber;
482
+ surface: z.ZodEnum<{
483
+ artifact: "artifact";
484
+ transcript: "transcript";
485
+ workspace: "workspace";
486
+ }>;
487
+ actor: z.ZodObject<{
488
+ kind: z.ZodEnum<{
489
+ agent: "agent";
490
+ system: "system";
491
+ user: "user";
492
+ }>;
493
+ id: z.ZodString;
494
+ }, z.core.$strict>;
495
+ agentRef: z.ZodObject<{
496
+ agentId: z.ZodString;
497
+ profileRevision: z.ZodString;
498
+ }, z.core.$strict>;
499
+ sessionRef: z.ZodString;
500
+ runtime: z.ZodEnum<{
501
+ claude: "claude";
502
+ codex: "codex";
503
+ pi: "pi";
504
+ }>;
505
+ cwd: z.ZodString;
506
+ policyRevision: z.ZodString;
507
+ target: z.ZodString;
508
+ mimeType: z.ZodString;
509
+ decodeAs: z.ZodEnum<{
510
+ bytes: "bytes";
511
+ utf8: "utf8";
512
+ }>;
513
+ decision: z.ZodLiteral<"allowed">;
514
+ byteCount: z.ZodNumber;
515
+ contentHash: z.ZodString;
516
+ blobRef: z.ZodObject<{
517
+ blobId: z.ZodString;
518
+ contentHash: z.ZodString;
519
+ size: z.ZodNumber;
520
+ contentType: z.ZodString;
521
+ url: z.ZodOptional<z.ZodString>;
522
+ }, z.core.$strip>;
523
+ }, z.core.$strict>, z.ZodObject<{
524
+ requestId: z.ZodUUID;
525
+ eventId: z.ZodUUID;
526
+ cursor: z.ZodNumber;
527
+ surface: z.ZodEnum<{
528
+ artifact: "artifact";
529
+ transcript: "transcript";
530
+ workspace: "workspace";
531
+ }>;
532
+ actor: z.ZodObject<{
533
+ kind: z.ZodEnum<{
534
+ agent: "agent";
535
+ system: "system";
536
+ user: "user";
537
+ }>;
538
+ id: z.ZodString;
539
+ }, z.core.$strict>;
540
+ agentRef: z.ZodObject<{
541
+ agentId: z.ZodString;
542
+ profileRevision: z.ZodString;
543
+ }, z.core.$strict>;
544
+ sessionRef: z.ZodString;
545
+ runtime: z.ZodEnum<{
546
+ claude: "claude";
547
+ codex: "codex";
548
+ pi: "pi";
549
+ }>;
550
+ cwd: z.ZodString;
551
+ policyRevision: z.ZodString;
552
+ target: z.ZodString;
553
+ mimeType: z.ZodString;
554
+ decodeAs: z.ZodEnum<{
555
+ bytes: "bytes";
556
+ utf8: "utf8";
557
+ }>;
558
+ decision: z.ZodLiteral<"denied">;
559
+ byteCount: z.ZodLiteral<0>;
560
+ reason: z.ZodEnum<{
561
+ "absolute-target": "absolute-target";
562
+ "byte-limit": "byte-limit";
563
+ "capability-missing": "capability-missing";
564
+ "dot-segment": "dot-segment";
565
+ "identity-mismatch": "identity-mismatch";
566
+ "invalid-request": "invalid-request";
567
+ "mime-not-allowlisted": "mime-not-allowlisted";
568
+ "non-relative-target": "non-relative-target";
569
+ "not-regular-file": "not-regular-file";
570
+ "path-escape": "path-escape";
571
+ "policy-disabled": "policy-disabled";
572
+ "policy-revision-mismatch": "policy-revision-mismatch";
573
+ "root-invalid": "root-invalid";
574
+ "root-not-allowlisted": "root-not-allowlisted";
575
+ "sensitive-name": "sensitive-name";
576
+ symlink: "symlink";
577
+ "target-missing": "target-missing";
578
+ "text-decode-failed": "text-decode-failed";
579
+ "text-not-allowlisted": "text-not-allowlisted";
580
+ }>;
581
+ }, z.core.$strict>], "decision">;
582
+ export type AgentContentReceiptPayload = z.infer<typeof AgentContentReceiptPayloadSchema>;
248
583
  /**
249
584
  * server -> daemon: approve a pending `task.await_approval` request.
250
585
  *
@@ -334,9 +669,8 @@ export type TaskSteerPayload = z.infer<typeof TaskSteerPayloadSchema>;
334
669
  * (above) rather than introducing a second capability shape. Same source of
335
670
  * truth as `conn.hello.runtimes[].capabilities`, different scope: `conn.hello`
336
671
  * is CONNECTION-level discovery ("what could this device run"), which no
337
- * server-side control decision may read, because it is transport-shaped — a
338
- * long-poll-only daemon never sends `conn.hello` at all and it describes a
339
- * device, not a task. This field is task-shaped: it shares a lifecycle with
672
+ * server-side task control decision may read, because it describes a device,
673
+ * not the adapter that claimed this task. This field is task-shaped: it shares a lifecycle with
340
674
  * the task↔runtime binding the claim itself establishes, so a control gate
341
675
  * (`steerTask()`, `packages/server`'s `hub.ts`) can key off it and stay
342
676
  * correct across reconnects, adapter-set changes, and transports. Plain
@@ -347,6 +681,10 @@ export type TaskSteerPayload = z.infer<typeof TaskSteerPayloadSchema>;
347
681
  export declare const TaskClaimPayloadSchema: z.ZodObject<{
348
682
  deviceId: z.ZodString;
349
683
  agentId: z.ZodOptional<z.ZodString>;
684
+ agentRef: z.ZodOptional<z.ZodObject<{
685
+ agentId: z.ZodString;
686
+ profileRevision: z.ZodString;
687
+ }, z.core.$strict>>;
350
688
  runtime: z.ZodOptional<z.ZodEnum<{
351
689
  claude: "claude";
352
690
  codex: "codex";
@@ -387,6 +725,10 @@ export type TaskStartedPayload = z.infer<typeof TaskStartedPayloadSchema>;
387
725
  export declare const TaskDeclinePayloadSchema: z.ZodObject<{
388
726
  reason: z.ZodString;
389
727
  retryable: z.ZodOptional<z.ZodBoolean>;
728
+ agentRef: z.ZodOptional<z.ZodObject<{
729
+ agentId: z.ZodString;
730
+ profileRevision: z.ZodString;
731
+ }, z.core.$strict>>;
390
732
  }, z.core.$strip>;
391
733
  export type TaskDeclinePayload = z.infer<typeof TaskDeclinePayloadSchema>;
392
734
  /**
@@ -568,6 +910,35 @@ export type ResultDocumentCheck = {
568
910
  * agrees.
569
911
  */
570
912
  export declare function checkResultDocument(document: unknown): ResultDocumentCheck;
913
+ /** Maximum provider-reported prompt or completion token count retained in one terminal observation. */
914
+ export declare const TERMINAL_INFERENCE_USAGE_MAX_TOKENS = 1000000000;
915
+ /** Maximum device-observed elapsed duration retained in one terminal observation (seven days). */
916
+ export declare const TERMINAL_INFERENCE_USAGE_MAX_DURATION_MS = 604800000;
917
+ export declare const TERMINAL_INFERENCE_USAGE_PROVIDER_MAX_LENGTH = 160;
918
+ export declare const TERMINAL_INFERENCE_USAGE_MODEL_MAX_LENGTH = 160;
919
+ export declare const TERMINAL_INFERENCE_USAGE_CLIENT_VERSION_MAX_LENGTH = 128;
920
+ /**
921
+ * A bounded, non-billing observation associated with one terminal runtime
922
+ * outcome. It is optional on every terminal payload so a pre-U2 daemon remains
923
+ * a legal v1 peer. `promptTokens` and `completionTokens` are values a runtime
924
+ * reported for its final observed turn; they are not a storage-accounting or
925
+ * invoice authority.
926
+ */
927
+ export declare const TerminalInferenceUsageSchema: z.ZodObject<{
928
+ runtime: z.ZodEnum<{
929
+ claude: "claude";
930
+ codex: "codex";
931
+ pi: "pi";
932
+ }>;
933
+ provider: z.ZodOptional<z.ZodString>;
934
+ model: z.ZodOptional<z.ZodString>;
935
+ promptTokens: z.ZodOptional<z.ZodNumber>;
936
+ completionTokens: z.ZodOptional<z.ZodNumber>;
937
+ durationMs: z.ZodOptional<z.ZodNumber>;
938
+ clientVersion: z.ZodString;
939
+ reportedAt: z.ZodISODateTime;
940
+ }, z.core.$strip>;
941
+ export type TerminalInferenceUsage = z.infer<typeof TerminalInferenceUsageSchema>;
571
942
  /**
572
943
  * daemon -> server: task finished successfully.
573
944
  *
@@ -605,12 +976,48 @@ export declare const TaskCompletePayloadSchema: z.ZodObject<{
605
976
  url: z.ZodOptional<z.ZodString>;
606
977
  }, z.core.$strip>>>;
607
978
  document: z.ZodOptional<z.ZodUnknown>;
979
+ usage: z.ZodOptional<z.ZodObject<{
980
+ runtime: z.ZodEnum<{
981
+ claude: "claude";
982
+ codex: "codex";
983
+ pi: "pi";
984
+ }>;
985
+ provider: z.ZodOptional<z.ZodString>;
986
+ model: z.ZodOptional<z.ZodString>;
987
+ promptTokens: z.ZodOptional<z.ZodNumber>;
988
+ completionTokens: z.ZodOptional<z.ZodNumber>;
989
+ durationMs: z.ZodOptional<z.ZodNumber>;
990
+ clientVersion: z.ZodString;
991
+ reportedAt: z.ZodISODateTime;
992
+ }, z.core.$strip>>;
993
+ agentRef: z.ZodOptional<z.ZodObject<{
994
+ agentId: z.ZodString;
995
+ profileRevision: z.ZodString;
996
+ }, z.core.$strict>>;
608
997
  }, z.core.$strip>;
609
998
  export type TaskCompletePayload = z.infer<typeof TaskCompletePayloadSchema>;
610
999
  /** daemon -> server: task failed. */
611
1000
  export declare const TaskFailPayloadSchema: z.ZodObject<{
612
1001
  reason: z.ZodString;
613
1002
  retryable: z.ZodOptional<z.ZodBoolean>;
1003
+ usage: z.ZodOptional<z.ZodObject<{
1004
+ runtime: z.ZodEnum<{
1005
+ claude: "claude";
1006
+ codex: "codex";
1007
+ pi: "pi";
1008
+ }>;
1009
+ provider: z.ZodOptional<z.ZodString>;
1010
+ model: z.ZodOptional<z.ZodString>;
1011
+ promptTokens: z.ZodOptional<z.ZodNumber>;
1012
+ completionTokens: z.ZodOptional<z.ZodNumber>;
1013
+ durationMs: z.ZodOptional<z.ZodNumber>;
1014
+ clientVersion: z.ZodString;
1015
+ reportedAt: z.ZodISODateTime;
1016
+ }, z.core.$strip>>;
1017
+ agentRef: z.ZodOptional<z.ZodObject<{
1018
+ agentId: z.ZodString;
1019
+ profileRevision: z.ZodString;
1020
+ }, z.core.$strict>>;
614
1021
  }, z.core.$strip>;
615
1022
  export type TaskFailPayload = z.infer<typeof TaskFailPayloadSchema>;
616
1023
  /**
@@ -634,6 +1041,24 @@ export type TaskFailPayload = z.infer<typeof TaskFailPayloadSchema>;
634
1041
  */
635
1042
  export declare const TaskCancelledPayloadSchema: z.ZodObject<{
636
1043
  reason: z.ZodOptional<z.ZodString>;
1044
+ usage: z.ZodOptional<z.ZodObject<{
1045
+ runtime: z.ZodEnum<{
1046
+ claude: "claude";
1047
+ codex: "codex";
1048
+ pi: "pi";
1049
+ }>;
1050
+ provider: z.ZodOptional<z.ZodString>;
1051
+ model: z.ZodOptional<z.ZodString>;
1052
+ promptTokens: z.ZodOptional<z.ZodNumber>;
1053
+ completionTokens: z.ZodOptional<z.ZodNumber>;
1054
+ durationMs: z.ZodOptional<z.ZodNumber>;
1055
+ clientVersion: z.ZodString;
1056
+ reportedAt: z.ZodISODateTime;
1057
+ }, z.core.$strip>>;
1058
+ agentRef: z.ZodOptional<z.ZodObject<{
1059
+ agentId: z.ZodString;
1060
+ profileRevision: z.ZodString;
1061
+ }, z.core.$strict>>;
637
1062
  }, z.core.$strip>;
638
1063
  export type TaskCancelledPayload = z.infer<typeof TaskCancelledPayloadSchema>;
639
1064
  /**
@@ -690,6 +1115,7 @@ export declare const MESSAGE_PAYLOAD_SCHEMAS: {
690
1115
  capabilities: z.ZodArray<z.ZodString>;
691
1116
  deviceId: z.ZodString;
692
1117
  productId: z.ZodString;
1118
+ clientVersion: z.ZodOptional<z.ZodString>;
693
1119
  runtimes: z.ZodOptional<z.ZodArray<z.ZodObject<{
694
1120
  id: z.ZodEnum<{
695
1121
  claude: "claude";
@@ -811,6 +1237,307 @@ export declare const MESSAGE_PAYLOAD_SCHEMAS: {
811
1237
  }, z.core.$strip>>;
812
1238
  requiredToolsets: z.ZodArray<z.ZodString>;
813
1239
  }, z.core.$strict>;
1240
+ readonly 'task.offer_for_agent': z.ZodObject<{
1241
+ instruction: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1242
+ blobRef: z.ZodObject<{
1243
+ blobId: z.ZodString;
1244
+ contentHash: z.ZodString;
1245
+ size: z.ZodNumber;
1246
+ contentType: z.ZodString;
1247
+ url: z.ZodOptional<z.ZodString>;
1248
+ }, z.core.$strip>;
1249
+ }, z.core.$strict>]>;
1250
+ policy: z.ZodObject<{
1251
+ mode: z.ZodEnum<{
1252
+ auto: "auto";
1253
+ confirm: "confirm";
1254
+ plan: "plan";
1255
+ readonly: "readonly";
1256
+ }>;
1257
+ allowTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
1258
+ denyTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
1259
+ workspaceRoot: z.ZodOptional<z.ZodString>;
1260
+ network: z.ZodOptional<z.ZodBoolean>;
1261
+ }, z.core.$strict>;
1262
+ agentRef: z.ZodObject<{
1263
+ agentId: z.ZodString;
1264
+ profileRevision: z.ZodString;
1265
+ }, z.core.$strict>;
1266
+ requiredToolsets: z.ZodOptional<z.ZodArray<z.ZodString>>;
1267
+ runtime: z.ZodOptional<z.ZodEnum<{
1268
+ claude: "claude";
1269
+ codex: "codex";
1270
+ pi: "pi";
1271
+ }>>;
1272
+ dispatchSelection: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
1273
+ lane: z.ZodLiteral<"subscription">;
1274
+ runtimeId: z.ZodEnum<{
1275
+ claude: "claude";
1276
+ codex: "codex";
1277
+ }>;
1278
+ providerId: z.ZodNull;
1279
+ modelId: z.ZodString;
1280
+ }, z.core.$strict>, z.ZodObject<{
1281
+ lane: z.ZodLiteral<"byok">;
1282
+ runtimeId: z.ZodLiteral<"pi">;
1283
+ providerId: z.ZodString;
1284
+ modelId: z.ZodString;
1285
+ }, z.core.$strict>], "lane">>;
1286
+ sessionRef: z.ZodOptional<z.ZodString>;
1287
+ limits: z.ZodOptional<z.ZodObject<{
1288
+ maxDurationMs: z.ZodOptional<z.ZodNumber>;
1289
+ maxTokens: z.ZodOptional<z.ZodNumber>;
1290
+ }, z.core.$strip>>;
1291
+ }, z.core.$strict>;
1292
+ readonly 'task.offer_for_agent_with_egress': z.ZodObject<{
1293
+ instruction: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1294
+ blobRef: z.ZodObject<{
1295
+ blobId: z.ZodString;
1296
+ contentHash: z.ZodString;
1297
+ size: z.ZodNumber;
1298
+ contentType: z.ZodString;
1299
+ url: z.ZodOptional<z.ZodString>;
1300
+ }, z.core.$strip>;
1301
+ }, z.core.$strict>]>;
1302
+ policy: z.ZodObject<{
1303
+ mode: z.ZodEnum<{
1304
+ auto: "auto";
1305
+ confirm: "confirm";
1306
+ plan: "plan";
1307
+ readonly: "readonly";
1308
+ }>;
1309
+ allowTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
1310
+ denyTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
1311
+ workspaceRoot: z.ZodOptional<z.ZodString>;
1312
+ network: z.ZodOptional<z.ZodBoolean>;
1313
+ }, z.core.$strict>;
1314
+ agentRef: z.ZodObject<{
1315
+ agentId: z.ZodString;
1316
+ profileRevision: z.ZodString;
1317
+ }, z.core.$strict>;
1318
+ requiredToolsets: z.ZodOptional<z.ZodArray<z.ZodString>>;
1319
+ runtime: z.ZodOptional<z.ZodEnum<{
1320
+ claude: "claude";
1321
+ codex: "codex";
1322
+ pi: "pi";
1323
+ }>>;
1324
+ dispatchSelection: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
1325
+ lane: z.ZodLiteral<"subscription">;
1326
+ runtimeId: z.ZodEnum<{
1327
+ claude: "claude";
1328
+ codex: "codex";
1329
+ }>;
1330
+ providerId: z.ZodNull;
1331
+ modelId: z.ZodString;
1332
+ }, z.core.$strict>, z.ZodObject<{
1333
+ lane: z.ZodLiteral<"byok">;
1334
+ runtimeId: z.ZodLiteral<"pi">;
1335
+ providerId: z.ZodString;
1336
+ modelId: z.ZodString;
1337
+ }, z.core.$strict>], "lane">>;
1338
+ limits: z.ZodOptional<z.ZodObject<{
1339
+ maxDurationMs: z.ZodOptional<z.ZodNumber>;
1340
+ maxTokens: z.ZodOptional<z.ZodNumber>;
1341
+ }, z.core.$strip>>;
1342
+ sessionRef: z.ZodString;
1343
+ egressPolicy: z.ZodObject<{
1344
+ policyRevision: z.ZodString;
1345
+ activity: z.ZodDiscriminatedUnion<[z.ZodObject<{
1346
+ mode: z.ZodLiteral<"metadata-status">;
1347
+ delivery: z.ZodLiteral<"latest-value">;
1348
+ }, z.core.$strict>, z.ZodObject<{
1349
+ mode: z.ZodLiteral<"contentful-trajectory">;
1350
+ delivery: z.ZodLiteral<"latest-value">;
1351
+ maxCoalesceMs: z.ZodNumber;
1352
+ maxEventBytes: z.ZodNumber;
1353
+ }, z.core.$strict>], "mode">;
1354
+ reliable: z.ZodObject<{
1355
+ maxPendingEventsPerAgent: z.ZodNumber;
1356
+ maxPendingBytesPerAgent: z.ZodNumber;
1357
+ maxPendingBytesPerTenant: z.ZodNumber;
1358
+ }, z.core.$strict>;
1359
+ transfers: z.ZodObject<{
1360
+ workspace: z.ZodUnion<readonly [z.ZodLiteral<"disabled">, z.ZodObject<{
1361
+ maxBytes: z.ZodNumber;
1362
+ allowedMimeTypes: z.ZodArray<z.ZodString>;
1363
+ }, z.core.$strict>]>;
1364
+ transcript: z.ZodUnion<readonly [z.ZodLiteral<"disabled">, z.ZodObject<{
1365
+ maxBytes: z.ZodNumber;
1366
+ allowedMimeTypes: z.ZodArray<z.ZodString>;
1367
+ }, z.core.$strict>]>;
1368
+ artifact: z.ZodUnion<readonly [z.ZodLiteral<"disabled">, z.ZodObject<{
1369
+ maxBytes: z.ZodNumber;
1370
+ allowedMimeTypes: z.ZodArray<z.ZodString>;
1371
+ }, z.core.$strict>]>;
1372
+ }, z.core.$strict>;
1373
+ }, z.core.$strict>;
1374
+ }, z.core.$strict>;
1375
+ readonly 'agent.egress.reliable': z.ZodObject<{
1376
+ agentRef: z.ZodObject<{
1377
+ agentId: z.ZodString;
1378
+ profileRevision: z.ZodString;
1379
+ }, z.core.$strict>;
1380
+ sessionRef: z.ZodString;
1381
+ policyRevision: z.ZodString;
1382
+ eventId: z.ZodUUID;
1383
+ cursor: z.ZodNumber;
1384
+ payload: z.ZodJSONSchema;
1385
+ contentHash: z.ZodString;
1386
+ byteCount: z.ZodNumber;
1387
+ }, z.core.$strict>;
1388
+ readonly 'agent.egress.ack': z.ZodObject<{
1389
+ agentRef: z.ZodObject<{
1390
+ agentId: z.ZodString;
1391
+ profileRevision: z.ZodString;
1392
+ }, z.core.$strict>;
1393
+ sessionRef: z.ZodString;
1394
+ policyRevision: z.ZodString;
1395
+ eventId: z.ZodUUID;
1396
+ cursor: z.ZodNumber;
1397
+ receiptId: z.ZodUUID;
1398
+ }, z.core.$strict>;
1399
+ readonly 'agent.content.read': z.ZodObject<{
1400
+ requestId: z.ZodUUID;
1401
+ surface: z.ZodEnum<{
1402
+ artifact: "artifact";
1403
+ transcript: "transcript";
1404
+ workspace: "workspace";
1405
+ }>;
1406
+ actor: z.ZodObject<{
1407
+ kind: z.ZodEnum<{
1408
+ agent: "agent";
1409
+ system: "system";
1410
+ user: "user";
1411
+ }>;
1412
+ id: z.ZodString;
1413
+ }, z.core.$strict>;
1414
+ agentRef: z.ZodObject<{
1415
+ agentId: z.ZodString;
1416
+ profileRevision: z.ZodString;
1417
+ }, z.core.$strict>;
1418
+ sessionRef: z.ZodString;
1419
+ runtime: z.ZodEnum<{
1420
+ claude: "claude";
1421
+ codex: "codex";
1422
+ pi: "pi";
1423
+ }>;
1424
+ cwd: z.ZodString;
1425
+ policyRevision: z.ZodString;
1426
+ target: z.ZodString;
1427
+ mimeType: z.ZodString;
1428
+ decodeAs: z.ZodEnum<{
1429
+ bytes: "bytes";
1430
+ utf8: "utf8";
1431
+ }>;
1432
+ policy: z.ZodObject<{
1433
+ maxBytes: z.ZodNumber;
1434
+ allowedMimeTypes: z.ZodArray<z.ZodString>;
1435
+ }, z.core.$strict>;
1436
+ }, z.core.$strict>;
1437
+ readonly 'agent.content.receipt': z.ZodDiscriminatedUnion<[z.ZodObject<{
1438
+ requestId: z.ZodUUID;
1439
+ eventId: z.ZodUUID;
1440
+ cursor: z.ZodNumber;
1441
+ surface: z.ZodEnum<{
1442
+ artifact: "artifact";
1443
+ transcript: "transcript";
1444
+ workspace: "workspace";
1445
+ }>;
1446
+ actor: z.ZodObject<{
1447
+ kind: z.ZodEnum<{
1448
+ agent: "agent";
1449
+ system: "system";
1450
+ user: "user";
1451
+ }>;
1452
+ id: z.ZodString;
1453
+ }, z.core.$strict>;
1454
+ agentRef: z.ZodObject<{
1455
+ agentId: z.ZodString;
1456
+ profileRevision: z.ZodString;
1457
+ }, z.core.$strict>;
1458
+ sessionRef: z.ZodString;
1459
+ runtime: z.ZodEnum<{
1460
+ claude: "claude";
1461
+ codex: "codex";
1462
+ pi: "pi";
1463
+ }>;
1464
+ cwd: z.ZodString;
1465
+ policyRevision: z.ZodString;
1466
+ target: z.ZodString;
1467
+ mimeType: z.ZodString;
1468
+ decodeAs: z.ZodEnum<{
1469
+ bytes: "bytes";
1470
+ utf8: "utf8";
1471
+ }>;
1472
+ decision: z.ZodLiteral<"allowed">;
1473
+ byteCount: z.ZodNumber;
1474
+ contentHash: z.ZodString;
1475
+ blobRef: z.ZodObject<{
1476
+ blobId: z.ZodString;
1477
+ contentHash: z.ZodString;
1478
+ size: z.ZodNumber;
1479
+ contentType: z.ZodString;
1480
+ url: z.ZodOptional<z.ZodString>;
1481
+ }, z.core.$strip>;
1482
+ }, z.core.$strict>, z.ZodObject<{
1483
+ requestId: z.ZodUUID;
1484
+ eventId: z.ZodUUID;
1485
+ cursor: z.ZodNumber;
1486
+ surface: z.ZodEnum<{
1487
+ artifact: "artifact";
1488
+ transcript: "transcript";
1489
+ workspace: "workspace";
1490
+ }>;
1491
+ actor: z.ZodObject<{
1492
+ kind: z.ZodEnum<{
1493
+ agent: "agent";
1494
+ system: "system";
1495
+ user: "user";
1496
+ }>;
1497
+ id: z.ZodString;
1498
+ }, z.core.$strict>;
1499
+ agentRef: z.ZodObject<{
1500
+ agentId: z.ZodString;
1501
+ profileRevision: z.ZodString;
1502
+ }, z.core.$strict>;
1503
+ sessionRef: z.ZodString;
1504
+ runtime: z.ZodEnum<{
1505
+ claude: "claude";
1506
+ codex: "codex";
1507
+ pi: "pi";
1508
+ }>;
1509
+ cwd: z.ZodString;
1510
+ policyRevision: z.ZodString;
1511
+ target: z.ZodString;
1512
+ mimeType: z.ZodString;
1513
+ decodeAs: z.ZodEnum<{
1514
+ bytes: "bytes";
1515
+ utf8: "utf8";
1516
+ }>;
1517
+ decision: z.ZodLiteral<"denied">;
1518
+ byteCount: z.ZodLiteral<0>;
1519
+ reason: z.ZodEnum<{
1520
+ "absolute-target": "absolute-target";
1521
+ "byte-limit": "byte-limit";
1522
+ "capability-missing": "capability-missing";
1523
+ "dot-segment": "dot-segment";
1524
+ "identity-mismatch": "identity-mismatch";
1525
+ "invalid-request": "invalid-request";
1526
+ "mime-not-allowlisted": "mime-not-allowlisted";
1527
+ "non-relative-target": "non-relative-target";
1528
+ "not-regular-file": "not-regular-file";
1529
+ "path-escape": "path-escape";
1530
+ "policy-disabled": "policy-disabled";
1531
+ "policy-revision-mismatch": "policy-revision-mismatch";
1532
+ "root-invalid": "root-invalid";
1533
+ "root-not-allowlisted": "root-not-allowlisted";
1534
+ "sensitive-name": "sensitive-name";
1535
+ symlink: "symlink";
1536
+ "target-missing": "target-missing";
1537
+ "text-decode-failed": "text-decode-failed";
1538
+ "text-not-allowlisted": "text-not-allowlisted";
1539
+ }>;
1540
+ }, z.core.$strict>], "decision">;
814
1541
  readonly 'task.approve': z.ZodObject<{
815
1542
  approvalId: z.ZodOptional<z.ZodString>;
816
1543
  }, z.core.$strip>;
@@ -827,6 +1554,10 @@ export declare const MESSAGE_PAYLOAD_SCHEMAS: {
827
1554
  readonly 'task.claim': z.ZodObject<{
828
1555
  deviceId: z.ZodString;
829
1556
  agentId: z.ZodOptional<z.ZodString>;
1557
+ agentRef: z.ZodOptional<z.ZodObject<{
1558
+ agentId: z.ZodString;
1559
+ profileRevision: z.ZodString;
1560
+ }, z.core.$strict>>;
830
1561
  runtime: z.ZodOptional<z.ZodEnum<{
831
1562
  claude: "claude";
832
1563
  codex: "codex";
@@ -844,6 +1575,10 @@ export declare const MESSAGE_PAYLOAD_SCHEMAS: {
844
1575
  readonly 'task.decline': z.ZodObject<{
845
1576
  reason: z.ZodString;
846
1577
  retryable: z.ZodOptional<z.ZodBoolean>;
1578
+ agentRef: z.ZodOptional<z.ZodObject<{
1579
+ agentId: z.ZodString;
1580
+ profileRevision: z.ZodString;
1581
+ }, z.core.$strict>>;
847
1582
  }, z.core.$strip>;
848
1583
  readonly 'task.progress': z.ZodObject<{
849
1584
  seq: z.ZodNumber;
@@ -911,13 +1646,67 @@ export declare const MESSAGE_PAYLOAD_SCHEMAS: {
911
1646
  url: z.ZodOptional<z.ZodString>;
912
1647
  }, z.core.$strip>>>;
913
1648
  document: z.ZodOptional<z.ZodUnknown>;
1649
+ usage: z.ZodOptional<z.ZodObject<{
1650
+ runtime: z.ZodEnum<{
1651
+ claude: "claude";
1652
+ codex: "codex";
1653
+ pi: "pi";
1654
+ }>;
1655
+ provider: z.ZodOptional<z.ZodString>;
1656
+ model: z.ZodOptional<z.ZodString>;
1657
+ promptTokens: z.ZodOptional<z.ZodNumber>;
1658
+ completionTokens: z.ZodOptional<z.ZodNumber>;
1659
+ durationMs: z.ZodOptional<z.ZodNumber>;
1660
+ clientVersion: z.ZodString;
1661
+ reportedAt: z.ZodISODateTime;
1662
+ }, z.core.$strip>>;
1663
+ agentRef: z.ZodOptional<z.ZodObject<{
1664
+ agentId: z.ZodString;
1665
+ profileRevision: z.ZodString;
1666
+ }, z.core.$strict>>;
914
1667
  }, z.core.$strip>;
915
1668
  readonly 'task.fail': z.ZodObject<{
916
1669
  reason: z.ZodString;
917
1670
  retryable: z.ZodOptional<z.ZodBoolean>;
1671
+ usage: z.ZodOptional<z.ZodObject<{
1672
+ runtime: z.ZodEnum<{
1673
+ claude: "claude";
1674
+ codex: "codex";
1675
+ pi: "pi";
1676
+ }>;
1677
+ provider: z.ZodOptional<z.ZodString>;
1678
+ model: z.ZodOptional<z.ZodString>;
1679
+ promptTokens: z.ZodOptional<z.ZodNumber>;
1680
+ completionTokens: z.ZodOptional<z.ZodNumber>;
1681
+ durationMs: z.ZodOptional<z.ZodNumber>;
1682
+ clientVersion: z.ZodString;
1683
+ reportedAt: z.ZodISODateTime;
1684
+ }, z.core.$strip>>;
1685
+ agentRef: z.ZodOptional<z.ZodObject<{
1686
+ agentId: z.ZodString;
1687
+ profileRevision: z.ZodString;
1688
+ }, z.core.$strict>>;
918
1689
  }, z.core.$strip>;
919
1690
  readonly 'task.cancelled': z.ZodObject<{
920
1691
  reason: z.ZodOptional<z.ZodString>;
1692
+ usage: z.ZodOptional<z.ZodObject<{
1693
+ runtime: z.ZodEnum<{
1694
+ claude: "claude";
1695
+ codex: "codex";
1696
+ pi: "pi";
1697
+ }>;
1698
+ provider: z.ZodOptional<z.ZodString>;
1699
+ model: z.ZodOptional<z.ZodString>;
1700
+ promptTokens: z.ZodOptional<z.ZodNumber>;
1701
+ completionTokens: z.ZodOptional<z.ZodNumber>;
1702
+ durationMs: z.ZodOptional<z.ZodNumber>;
1703
+ clientVersion: z.ZodString;
1704
+ reportedAt: z.ZodISODateTime;
1705
+ }, z.core.$strip>>;
1706
+ agentRef: z.ZodOptional<z.ZodObject<{
1707
+ agentId: z.ZodString;
1708
+ profileRevision: z.ZodString;
1709
+ }, z.core.$strict>>;
921
1710
  }, z.core.$strip>;
922
1711
  readonly 'task.approval_resolved': z.ZodObject<{
923
1712
  approvalId: z.ZodString;
@@ -938,7 +1727,7 @@ export declare const MESSAGE_TYPES: MessageType[];
938
1727
  * (`envelope.ts`) to decide which branches require envelope `seq` (M1
939
1728
  * redelivery cursor).
940
1729
  */
941
- export declare const SERVER_TO_DAEMON_TYPES: readonly ["conn.ack", "task.offer", "task.offer_with_toolsets", "task.approve", "task.reject", "task.cancel", "task.steer"];
1730
+ export declare const SERVER_TO_DAEMON_TYPES: readonly ["conn.ack", "task.offer", "task.offer_with_toolsets", "task.offer_for_agent", "task.offer_for_agent_with_egress", "agent.egress.ack", "agent.content.read", "task.approve", "task.reject", "task.cancel", "task.steer"];
942
1731
  /**
943
1732
  * Message types the daemon sends to the server — the flip side of
944
1733
  * {@link SERVER_TO_DAEMON_TYPES}. `conn.hello` is deliberately excluded: it's
@@ -951,4 +1740,4 @@ export declare const SERVER_TO_DAEMON_TYPES: readonly ["conn.ack", "task.offer",
951
1740
  * or anything unrecognized — is rejected before it's dispatched to any
952
1741
  * handler or counted `accepted` on the `/byok/messages` wire.
953
1742
  */
954
- export declare const DAEMON_TO_SERVER_TYPES: readonly ["task.claim", "task.started", "task.decline", "task.progress", "task.artifact", "task.await_approval", "task.complete", "task.fail", "task.cancelled", "task.approval_resolved"];
1743
+ export declare const DAEMON_TO_SERVER_TYPES: readonly ["task.claim", "task.started", "task.decline", "task.progress", "task.artifact", "task.await_approval", "task.complete", "task.fail", "task.cancelled", "task.approval_resolved", "agent.egress.reliable", "agent.content.receipt"];