@byok-sdk/protocol 0.19.0 → 0.20.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.
@@ -25,8 +25,41 @@ import { z } from 'zod';
25
25
  * freeze-rule asymmetry. Adding a field post-freeze is therefore a
26
26
  * breaking change, exactly like `PermissionPolicySchema`.
27
27
  */
28
- /** Capability required before a task-free remote input preparation is admitted. */
29
- export declare const AGENT_INPUT_PREPARATION_CAPABILITY: 'agent-input-preparation';
28
+ /**
29
+ * The ONE version of the input-preparation contract, shared by this relay wire
30
+ * (the `agent.input.preparation` payload and the completion receipt summary)
31
+ * and by the device-local request, receipt and artifact
32
+ * (`@byok-sdk/client`'s `INPUT_PREPARATION_VERSION`, which is this value).
33
+ *
34
+ * The relay wire carries no version field of its own, so a version change is
35
+ * made visible where admission actually happens: in the capability token
36
+ * below. See `INPUT_PREPARATION_VERSION` in the client for what each version
37
+ * changed.
38
+ */
39
+ export declare const INPUT_PREPARATION_WIRE_VERSION: 5;
40
+ /**
41
+ * Capability required before a task-free remote input preparation — or a
42
+ * prepared Execution — is admitted: `agent-input-preparation-v<N>`, where
43
+ * `<N>` is {@link INPUT_PREPARATION_WIRE_VERSION}.
44
+ *
45
+ * The version is IN the token because the relay wire has none. A device
46
+ * declares exactly the one token of the contract it speaks, and a cloud admits
47
+ * exactly the one token of the contract it speaks, so a device and a cloud on
48
+ * different contract versions never exchange a preparation at all: the cloud
49
+ * refuses at enqueue (`agent_capability_missing`, before any receipt or
50
+ * mailbox row) instead of relaying a payload the other side would refuse with
51
+ * a strict-schema 422 and a device would then redeliver forever. There is no
52
+ * dual token and no accepted older one. The retired unversioned token
53
+ * `agent-input-preparation` (versions up to 4) is admitted nowhere.
54
+ *
55
+ * The token gates NEW admissions only. A row enqueued before a version cut is
56
+ * still in flight afterwards, and its completion is accepted only by a cloud
57
+ * on the same version as the device answering it; across the cut it is a 422
58
+ * and a stalled device cursor. Draining in-flight rows and upgrading cloud and
59
+ * devices as a pair is the operator precondition for the cut (`docs/spec.md`,
60
+ * bounded admission); nothing here parses an older receipt.
61
+ */
62
+ export declare const AGENT_INPUT_PREPARATION_CAPABILITY: "agent-input-preparation-v5";
30
63
  /** The preparation surface uses the package-wide lowercase `sha256:<hex>` transport form. */
31
64
  export declare const InputPreparationContentHashSchema: z.ZodString;
32
65
  /**
@@ -424,13 +457,20 @@ export declare const InputPreparationContextDocumentSchema: z.ZodObject<{
424
457
  }, z.core.$strict>], "role">>;
425
458
  }, z.core.$strict>;
426
459
  export type InputPreparationContextDocument = z.infer<typeof InputPreparationContextDocumentSchema>;
427
- /** Durable lifecycle state of one local preparation record. */
460
+ /**
461
+ * Durable lifecycle state of one local preparation record.
462
+ *
463
+ * `prepared` is the one successful terminal state: the artifact is compiled,
464
+ * persisted, and — when the device has an optional counter configured — its
465
+ * counter answered. A device with no counter reaches `prepared` without ever
466
+ * entering `counting`.
467
+ */
428
468
  export declare const InputPreparationStateSchema: z.ZodEnum<{
429
469
  cancelled: "cancelled";
430
- counted: "counted";
431
470
  counter_interrupted: "counter_interrupted";
432
471
  counting: "counting";
433
472
  failed: "failed";
473
+ prepared: "prepared";
434
474
  reserved: "reserved";
435
475
  }>;
436
476
  export type InputPreparationState = z.infer<typeof InputPreparationStateSchema>;
@@ -440,11 +480,14 @@ export type InputPreparationState = z.infer<typeof InputPreparationStateSchema>;
440
480
  *
441
481
  * `ready` means the preparation CAN BE CONSUMED — the artifact is intact and
442
482
  * unexpired, the native compiler's projection is content-complete, every
443
- * residual key is ruled by an applicable Host accounting policy, the count is
444
- * present and bound to that exact projection, and every executor identity is
445
- * attested. It is deliberately NOT Host budget admission: the device performs
446
- * no budget arithmetic, so a ready receipt says the evidence holds, never that
447
- * the spend is allowed.
483
+ * residual key is ruled by an applicable Host accounting policy, D is text
484
+ * only, every executor identity is attested, and — only when the device has an
485
+ * optional counter configured — that count is provider-authoritative and
486
+ * covered. No count is required: the size evidence is
487
+ * `artifact.requestBytes`, the exact byte length of the frozen D. It is
488
+ * deliberately NOT Host budget admission: the device performs no budget
489
+ * arithmetic, so a ready receipt says the evidence holds, never that the
490
+ * spend fits a window.
448
491
  */
449
492
  export declare const InputPreparationReadinessReasonSchema: z.ZodEnum<{
450
493
  accounting_policy_inapplicable: "accounting_policy_inapplicable";
@@ -454,11 +497,11 @@ export declare const InputPreparationReadinessReasonSchema: z.ZodEnum<{
454
497
  counter_authority_not_production: "counter_authority_not_production";
455
498
  counter_coverage_incomplete: "counter_coverage_incomplete";
456
499
  counter_interrupted: "counter_interrupted";
457
- counter_missing: "counter_missing";
458
500
  executor_identity_unproven: "executor_identity_unproven";
459
501
  failed: "failed";
460
- not_counted: "not_counted";
502
+ not_prepared: "not_prepared";
461
503
  projection_unknown: "projection_unknown";
504
+ request_content_not_text: "request_content_not_text";
462
505
  residual_not_ruled: "residual_not_ruled";
463
506
  runtime_contract_superseded: "runtime_contract_superseded";
464
507
  }>;
@@ -529,7 +572,9 @@ export declare const InputPreparationCounterProviderEvidenceSchema: z.ZodObject<
529
572
  }, z.core.$strict>;
530
573
  }, z.core.$strict>;
531
574
  /**
532
- * Counter evidence exactly as the device's adapter reported it.
575
+ * Counter evidence exactly as the device's OPTIONAL adapter reported it.
576
+ * Absent when the device has no counter configured, which is a legal, ready-
577
+ * capable state: the size evidence is `artifact.requestBytes`.
533
578
  *
534
579
  * `authority: 'test_fixture'` is a first-class value, not a debug flag: a
535
580
  * fixture result can never produce a ready receipt, which is what keeps an
@@ -542,10 +587,6 @@ export declare const InputPreparationCounterEvidenceSchema: z.ZodObject<{
542
587
  provider: "provider";
543
588
  test_fixture: "test_fixture";
544
589
  }>;
545
- kind: z.ZodEnum<{
546
- bound: "bound";
547
- count: "count";
548
- }>;
549
590
  value: z.ZodNumber;
550
591
  coverage: z.ZodObject<{
551
592
  covered: z.ZodBoolean;
@@ -739,10 +780,10 @@ export declare const InputPreparationReceiptSummarySchema: z.ZodObject<{
739
780
  reference: z.ZodString;
740
781
  state: z.ZodEnum<{
741
782
  cancelled: "cancelled";
742
- counted: "counted";
743
783
  counter_interrupted: "counter_interrupted";
744
784
  counting: "counting";
745
785
  failed: "failed";
786
+ prepared: "prepared";
746
787
  reserved: "reserved";
747
788
  }>;
748
789
  binding: z.ZodObject<{
@@ -825,10 +866,6 @@ export declare const InputPreparationReceiptSummarySchema: z.ZodObject<{
825
866
  provider: "provider";
826
867
  test_fixture: "test_fixture";
827
868
  }>;
828
- kind: z.ZodEnum<{
829
- bound: "bound";
830
- count: "count";
831
- }>;
832
869
  value: z.ZodNumber;
833
870
  coverage: z.ZodObject<{
834
871
  covered: z.ZodBoolean;
@@ -860,11 +897,11 @@ export declare const InputPreparationReceiptSummarySchema: z.ZodObject<{
860
897
  counter_authority_not_production: "counter_authority_not_production";
861
898
  counter_coverage_incomplete: "counter_coverage_incomplete";
862
899
  counter_interrupted: "counter_interrupted";
863
- counter_missing: "counter_missing";
864
900
  executor_identity_unproven: "executor_identity_unproven";
865
901
  failed: "failed";
866
- not_counted: "not_counted";
902
+ not_prepared: "not_prepared";
867
903
  projection_unknown: "projection_unknown";
904
+ request_content_not_text: "request_content_not_text";
868
905
  residual_not_ruled: "residual_not_ruled";
869
906
  runtime_contract_superseded: "runtime_contract_superseded";
870
907
  }>>;
@@ -895,7 +932,7 @@ export declare const InputPreparationReferenceSchema: z.ZodString;
895
932
  * `artifactDigest` is optional for one structural reason, not as a compatibility
896
933
  * seam: a receipt discloses `artifact` only once there is one
897
934
  * ({@link InputPreparationArtifactSummarySchema} is optional on the receipt), so
898
- * a Host holding a not-yet-counted receipt has no envelope digest to re-present.
935
+ * a Host holding a not-yet-prepared receipt has no envelope digest to re-present.
899
936
  * When it is present it is compared like everything else.
900
937
  */
901
938
  export declare const InputPreparationOfferBindingSchema: z.ZodObject<{
@@ -922,6 +959,7 @@ export declare const InputPreparationRejectionReasonSchema: z.ZodEnum<{
922
959
  counter_unavailable: "counter_unavailable";
923
960
  deadline_elapsed: "deadline_elapsed";
924
961
  durable_write_failed: "durable_write_failed";
962
+ input_preparation_record_log_unsupported: "input_preparation_record_log_unsupported";
925
963
  input_preparation_unconfigured: "input_preparation_unconfigured";
926
964
  launch_boundary_unavailable: "launch_boundary_unavailable";
927
965
  limit_exceeded: "limit_exceeded";
@@ -1509,6 +1509,34 @@ export declare const TerminalInferenceUsageSchema: z.ZodObject<{
1509
1509
  reportedAt: z.ZodISODateTime;
1510
1510
  }, z.core.$strip>;
1511
1511
  export type TerminalInferenceUsage = z.infer<typeof TerminalInferenceUsageSchema>;
1512
+ /**
1513
+ * The prepared-only terminal observation: what the runtime reported about the
1514
+ * provider calls of ONE prepared Execution, bound to the frozen request it
1515
+ * launched.
1516
+ *
1517
+ * - `requestDigest` — the frozen artifact's own request digest
1518
+ * (`InputPreparationArtifactSummarySchema.requestDigest`), so the Host
1519
+ * compares these numbers against exactly the D whose `requestBytes` it
1520
+ * ruled on.
1521
+ * - `initialPromptTokens` — the prompt tokens of the FIRST provider call. It
1522
+ * is the only call whose request is D; every later call is an ordinary tool
1523
+ * continuation. Prompt tokens are the provider's whole prompt, cache reads
1524
+ * and writes included.
1525
+ * - `maxPromptTokens` — the largest prompt of any provider call of the
1526
+ * Execution, so `maxPromptTokens >= initialPromptTokens`.
1527
+ *
1528
+ * A separate field, deliberately NOT {@link TerminalInferenceUsageSchema}:
1529
+ * that one is telemetry and never task-state authority, while this one is the
1530
+ * evidence a Host checks its own budget ruling against. The device performs no
1531
+ * budget arithmetic over it. Strict, like every other control shape: an
1532
+ * unrecognized field is rejected, not stripped.
1533
+ */
1534
+ export declare const TerminalPreparedObservationSchema: z.ZodObject<{
1535
+ requestDigest: z.ZodString;
1536
+ initialPromptTokens: z.ZodNumber;
1537
+ maxPromptTokens: z.ZodNumber;
1538
+ }, z.core.$strict>;
1539
+ export type TerminalPreparedObservation = z.infer<typeof TerminalPreparedObservationSchema>;
1512
1540
  /**
1513
1541
  * daemon -> server: task finished successfully.
1514
1542
  *
@@ -1561,6 +1589,11 @@ export declare const TaskCompletePayloadSchema: z.ZodObject<{
1561
1589
  clientVersion: z.ZodString;
1562
1590
  reportedAt: z.ZodISODateTime;
1563
1591
  }, z.core.$strip>>;
1592
+ preparedObservation: z.ZodOptional<z.ZodObject<{
1593
+ requestDigest: z.ZodString;
1594
+ initialPromptTokens: z.ZodNumber;
1595
+ maxPromptTokens: z.ZodNumber;
1596
+ }, z.core.$strict>>;
1564
1597
  agentRef: z.ZodOptional<z.ZodObject<{
1565
1598
  agentId: z.ZodString;
1566
1599
  profileRevision: z.ZodString;
@@ -1590,6 +1623,11 @@ export declare const TaskFailPayloadSchema: z.ZodObject<{
1590
1623
  clientVersion: z.ZodString;
1591
1624
  reportedAt: z.ZodISODateTime;
1592
1625
  }, z.core.$strip>>;
1626
+ preparedObservation: z.ZodOptional<z.ZodObject<{
1627
+ requestDigest: z.ZodString;
1628
+ initialPromptTokens: z.ZodNumber;
1629
+ maxPromptTokens: z.ZodNumber;
1630
+ }, z.core.$strict>>;
1593
1631
  agentRef: z.ZodOptional<z.ZodObject<{
1594
1632
  agentId: z.ZodString;
1595
1633
  profileRevision: z.ZodString;
@@ -3183,6 +3221,11 @@ export declare const MESSAGE_PAYLOAD_SCHEMAS: {
3183
3221
  clientVersion: z.ZodString;
3184
3222
  reportedAt: z.ZodISODateTime;
3185
3223
  }, z.core.$strip>>;
3224
+ preparedObservation: z.ZodOptional<z.ZodObject<{
3225
+ requestDigest: z.ZodString;
3226
+ initialPromptTokens: z.ZodNumber;
3227
+ maxPromptTokens: z.ZodNumber;
3228
+ }, z.core.$strict>>;
3186
3229
  agentRef: z.ZodOptional<z.ZodObject<{
3187
3230
  agentId: z.ZodString;
3188
3231
  profileRevision: z.ZodString;
@@ -3210,6 +3253,11 @@ export declare const MESSAGE_PAYLOAD_SCHEMAS: {
3210
3253
  clientVersion: z.ZodString;
3211
3254
  reportedAt: z.ZodISODateTime;
3212
3255
  }, z.core.$strip>>;
3256
+ preparedObservation: z.ZodOptional<z.ZodObject<{
3257
+ requestDigest: z.ZodString;
3258
+ initialPromptTokens: z.ZodNumber;
3259
+ maxPromptTokens: z.ZodNumber;
3260
+ }, z.core.$strict>>;
3213
3261
  agentRef: z.ZodOptional<z.ZodObject<{
3214
3262
  agentId: z.ZodString;
3215
3263
  profileRevision: z.ZodString;
package/dist/version.d.ts CHANGED
@@ -107,5 +107,5 @@ export declare const STRICT_AGENT_ONLY_CAPABILITY: 'strict-agent-only';
107
107
  * cannot accidentally execute the instruction without the required tools.
108
108
  */
109
109
  export declare const CUSTOM_HARNESS_CAPABILITY: 'custom-harness';
110
- export declare const CAPABILITY_FLAGS: readonly ['steer', 'blob-upload', 'interactive-approval', 'approval_resolved', 'approval-targeting', 'result-document', 'dispatch-selection', "provider-profile-binding", 'toolset-selection', 'agent-home-contract', "strict-agent-only", "agent-egress-policy", "agent-egress-reliable-ack", "agent-message-egress", "agent-egress-fresh-session", "agent-content-workspace-read", "agent-content-transcript-read", "agent-content-artifact-read", "agent-home-projection", "agent-input-preparation", "terminal-projection-selection", "host-mcp-task-context", "custom-harness", "mailbox-read-ahead"];
110
+ export declare const CAPABILITY_FLAGS: readonly ['steer', 'blob-upload', 'interactive-approval', 'approval_resolved', 'approval-targeting', 'result-document', 'dispatch-selection', "provider-profile-binding", 'toolset-selection', 'agent-home-contract', "strict-agent-only", "agent-egress-policy", "agent-egress-reliable-ack", "agent-message-egress", "agent-egress-fresh-session", "agent-content-workspace-read", "agent-content-transcript-read", "agent-content-artifact-read", "agent-home-projection", "agent-input-preparation-v5", "terminal-projection-selection", "host-mcp-task-context", "custom-harness", "mailbox-read-ahead"];
111
111
  export type CapabilityFlag = (typeof CAPABILITY_FLAGS)[number];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byok-sdk/protocol",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "description": "BYOK SDK wire protocol: envelope schema, message types, and codec helpers",
5
5
  "type": "module",
6
6
  "license": "MIT",