@byok-sdk/protocol 0.29.0 → 0.30.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.
@@ -36,8 +36,37 @@ export declare const AGENT_MEMORY_INTENT_CAPABILITY: 'agent-memory-intent.v1';
36
36
  export declare const AGENT_MEMORY_PROJECTION_CAPABILITY: 'agent.memory.projection';
37
37
  /** Device capability required before an ordinary Agent offer may carry `agentMemory`. */
38
38
  export declare const AGENT_MEMORY_SELECTION_CAPABILITY: 'agent-memory-selection';
39
+ /** Device capability required before an ordinary Agent offer may carry `agentMemory: 'read-if-admitted'`. */
40
+ export declare const AGENT_MEMORY_READ_IF_ADMITTED_CAPABILITY: 'agent-memory-read-if-admitted';
41
+ /** Device capability required before an ordinary Agent offer may carry `agentMemory: 'read-write-if-admitted'`. */
42
+ export declare const AGENT_MEMORY_READ_WRITE_IF_ADMITTED_CAPABILITY: 'agent-memory-read-write-if-admitted';
39
43
  /** Exact capability of the single input-preparation wire authority. */
40
44
  export declare const AGENT_INPUT_PREPARATION_CAPABILITY: "agent-input-preparation-v9";
45
+ /**
46
+ * Sealed payload v1 (#654). A device advertises it before a Host may send it
47
+ * a sealed offer or steer; a server advertises it before a device may send it
48
+ * sealed task output or a sealed decline code. Both gates read
49
+ * `WIRE_ADDITIONS`.
50
+ */
51
+ export declare const SEALED_PAYLOAD_CAPABILITY: 'sealed-payload-v1';
52
+ /**
53
+ * A server advertises it before a device may send a sealed task output that
54
+ * names its ciphertext blob (`sealed.ciphertextRef`) instead of carrying it
55
+ * inline. The server then holds the blob for the life of the task.
56
+ */
57
+ export declare const SEALED_OUTPUT_CIPHERTEXT_REF_CAPABILITY: 'sealed-output-ciphertext-ref';
58
+ /**
59
+ * A server advertises it before a device may send `task.fail.failure`, the
60
+ * machine-readable runtime failure class (#869).
61
+ */
62
+ export declare const RUNTIME_FAILURE_CLASS_CAPABILITY: 'runtime-failure-class';
63
+ /**
64
+ * The closed classes of `task.fail.failure.class`: the vendored OAR
65
+ * `FailureClass` values. `unknown` means the runtime gave no structured
66
+ * evidence. Single value authority shared by schema validation and
67
+ * schema-free consumers.
68
+ */
69
+ export declare const RUNTIME_FAILURE_CLASSES: readonly ['auth', 'quota', 'rate_limited', 'billing', 'model_unavailable', 'input_too_large', 'invalid_request', 'overloaded', 'provider', 'runtime_exited', 'limit_reached', 'output_schema', 'unknown'];
41
70
  /** Single value authority shared by schema validation and schema-free consumers. */
42
71
  export declare const PREPARED_AGENT_MEMORY_MODES: readonly ['none', 'read', 'read-write'];
43
72
  export declare function isPreparedAgentMemoryMode(value: unknown): value is (typeof PREPARED_AGENT_MEMORY_MODES)[number];
package/dist/codec.d.ts CHANGED
@@ -90,6 +90,10 @@ interface EnvelopeShapeOptions {
90
90
  taskId?: never;
91
91
  seq: number;
92
92
  };
93
+ 'e2ee.key_package.available': {
94
+ taskId?: never;
95
+ seq: number;
96
+ };
93
97
  'agent.content.receipt': {
94
98
  taskId?: string;
95
99
  seq?: number;
@@ -150,6 +154,58 @@ interface EnvelopeShapeOptions {
150
154
  taskId: string;
151
155
  seq?: number;
152
156
  };
157
+ 'task.offer_sealed': {
158
+ taskId: string;
159
+ seq: number;
160
+ };
161
+ 'task.offer_with_toolsets_sealed': {
162
+ taskId: string;
163
+ seq: number;
164
+ };
165
+ 'task.offer_for_agent_sealed': {
166
+ taskId: string;
167
+ seq: number;
168
+ };
169
+ 'task.offer_for_agent_with_egress_sealed': {
170
+ taskId: string;
171
+ seq: number;
172
+ };
173
+ 'task.offer_for_agent_with_egress_fresh_sealed': {
174
+ taskId: string;
175
+ seq: number;
176
+ };
177
+ 'task.steer_sealed': {
178
+ taskId: string;
179
+ seq: number;
180
+ };
181
+ 'task.complete_sealed': {
182
+ taskId: string;
183
+ seq?: number;
184
+ };
185
+ 'task.fail_sealed': {
186
+ taskId: string;
187
+ seq?: number;
188
+ };
189
+ 'task.decline_sealed': {
190
+ taskId: string;
191
+ seq?: number;
192
+ };
193
+ 'task.cancelled_sealed': {
194
+ taskId: string;
195
+ seq?: number;
196
+ };
197
+ 'task.progress_sealed': {
198
+ taskId: string;
199
+ seq?: number;
200
+ };
201
+ 'task.artifact_sealed': {
202
+ taskId: string;
203
+ seq?: number;
204
+ };
205
+ 'task.await_approval_sealed': {
206
+ taskId: string;
207
+ seq?: number;
208
+ };
153
209
  }
154
210
  interface EnvelopeCommonOptions {
155
211
  id?: string;
package/dist/constants.js CHANGED
@@ -15,7 +15,27 @@ var PROVIDER_PROVISIONING_CAPABILITY = "provider-provisioning.v1";
15
15
  var AGENT_MEMORY_INTENT_CAPABILITY = "agent-memory-intent.v1";
16
16
  var AGENT_MEMORY_PROJECTION_CAPABILITY = "agent.memory.projection";
17
17
  var AGENT_MEMORY_SELECTION_CAPABILITY = "agent-memory-selection";
18
+ var AGENT_MEMORY_READ_IF_ADMITTED_CAPABILITY = "agent-memory-read-if-admitted";
19
+ var AGENT_MEMORY_READ_WRITE_IF_ADMITTED_CAPABILITY = "agent-memory-read-write-if-admitted";
18
20
  var AGENT_INPUT_PREPARATION_CAPABILITY = `agent-input-preparation-v${INPUT_PREPARATION_WIRE_VERSION}`;
21
+ var SEALED_PAYLOAD_CAPABILITY = "sealed-payload-v1";
22
+ var SEALED_OUTPUT_CIPHERTEXT_REF_CAPABILITY = "sealed-output-ciphertext-ref";
23
+ var RUNTIME_FAILURE_CLASS_CAPABILITY = "runtime-failure-class";
24
+ var RUNTIME_FAILURE_CLASSES = [
25
+ "auth",
26
+ "quota",
27
+ "rate_limited",
28
+ "billing",
29
+ "model_unavailable",
30
+ "input_too_large",
31
+ "invalid_request",
32
+ "overloaded",
33
+ "provider",
34
+ "runtime_exited",
35
+ "limit_reached",
36
+ "output_schema",
37
+ "unknown"
38
+ ];
19
39
  var PREPARED_AGENT_MEMORY_MODES = ["none", "read", "read-write"];
20
40
  function isPreparedAgentMemoryMode(value) {
21
41
  return typeof value === "string" && PREPARED_AGENT_MEMORY_MODES.some((mode) => mode === value);
@@ -56,7 +76,12 @@ var CAPABILITY_FLAGS = [
56
76
  PROVIDER_PROVISIONING_CAPABILITY,
57
77
  AGENT_MEMORY_INTENT_CAPABILITY,
58
78
  AGENT_MEMORY_SELECTION_CAPABILITY,
59
- "agent-message-draft"
79
+ AGENT_MEMORY_READ_IF_ADMITTED_CAPABILITY,
80
+ AGENT_MEMORY_READ_WRITE_IF_ADMITTED_CAPABILITY,
81
+ "agent-message-draft",
82
+ SEALED_PAYLOAD_CAPABILITY,
83
+ SEALED_OUTPUT_CIPHERTEXT_REF_CAPABILITY,
84
+ RUNTIME_FAILURE_CLASS_CAPABILITY
60
85
  ];
61
86
 
62
87
  // src/task-state.ts
@@ -87,6 +112,6 @@ var AGENT_MEMORY_MAX_SNAPSHOT_BYTES = 1024 * 1024;
87
112
  var AGENT_MEMORY_MAX_SNAPSHOT_FILES = 128;
88
113
  var RUNTIME_IDS = Object.freeze(["pi", "claude", "codex"]);
89
114
 
90
- 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_HOME_PROJECTION_CAPABILITY, AGENT_HOME_READERS_CAPABILITY, AGENT_INPUT_PREPARATION_CAPABILITY, AGENT_MEMORY_INTENT_CAPABILITY, AGENT_MEMORY_MAX_SNAPSHOT_BYTES, AGENT_MEMORY_MAX_SNAPSHOT_FILES, AGENT_MEMORY_PROJECTION_CAPABILITY, AGENT_MEMORY_SELECTION_CAPABILITY, AGENT_MESSAGE_EGRESS_CAPABILITY, CAPABILITY_FLAGS, CUSTOM_HARNESS_CAPABILITY, HOST_MCP_TASK_CONTEXT_CAPABILITY, INPUT_PREPARATION_WIRE_VERSION, MAILBOX_READ_AHEAD_CAPABILITY, MAILBOX_READ_AHEAD_MAX_SEQS, PREPARED_AGENT_MEMORY_MODES, PROTOCOL_VERSION, PROVIDER_PROFILE_BINDING_CAPABILITY, PROVIDER_PROVISIONING_CAPABILITY, RUNTIME_IDS, STRICT_AGENT_ONLY_CAPABILITY, TASK_STATES, TASK_TRANSITIONS, TERMINAL_PROJECTION_SELECTION_CAPABILITY, canTransition, isPreparedAgentMemoryMode };
115
+ 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_HOME_PROJECTION_CAPABILITY, AGENT_HOME_READERS_CAPABILITY, AGENT_INPUT_PREPARATION_CAPABILITY, AGENT_MEMORY_INTENT_CAPABILITY, AGENT_MEMORY_MAX_SNAPSHOT_BYTES, AGENT_MEMORY_MAX_SNAPSHOT_FILES, AGENT_MEMORY_PROJECTION_CAPABILITY, AGENT_MEMORY_READ_IF_ADMITTED_CAPABILITY, AGENT_MEMORY_READ_WRITE_IF_ADMITTED_CAPABILITY, AGENT_MEMORY_SELECTION_CAPABILITY, AGENT_MESSAGE_EGRESS_CAPABILITY, CAPABILITY_FLAGS, CUSTOM_HARNESS_CAPABILITY, HOST_MCP_TASK_CONTEXT_CAPABILITY, INPUT_PREPARATION_WIRE_VERSION, MAILBOX_READ_AHEAD_CAPABILITY, MAILBOX_READ_AHEAD_MAX_SEQS, PREPARED_AGENT_MEMORY_MODES, PROTOCOL_VERSION, PROVIDER_PROFILE_BINDING_CAPABILITY, PROVIDER_PROVISIONING_CAPABILITY, RUNTIME_FAILURE_CLASSES, RUNTIME_FAILURE_CLASS_CAPABILITY, RUNTIME_IDS, SEALED_OUTPUT_CIPHERTEXT_REF_CAPABILITY, SEALED_PAYLOAD_CAPABILITY, STRICT_AGENT_ONLY_CAPABILITY, TASK_STATES, TASK_TRANSITIONS, TERMINAL_PROJECTION_SELECTION_CAPABILITY, canTransition, isPreparedAgentMemoryMode };
91
116
  //# sourceMappingURL=constants.js.map
92
117
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/capability-constants.ts","../src/version.ts","../src/task-state.ts","../src/constants.ts"],"names":[],"mappings":";AAWO,IAAM,8BAAA,GAAiC;AAIvC,IAAM,8BAAA,GAAiC;AAEvC,IAAM,oCAAA,GAAuC;AAG7C,IAAM,qCAAA,GAAwC;AAG9C,IAAM,+BAAA,GAAkC;AAExC,IAAM,uCAAA,GAA0C;AAEhD,IAAM,wCAAA,GAA2C;AAEjD,IAAM,sCAAA,GAAyC;AAG/C,IAAM,gCAAA,GAAmC;AAGzC,IAAM,wCAAA,GAA2C;AAGjD,IAAM,gCAAA,GAAmC;AAGzC,IAAM,mCAAA,GAAsC;AAG5C,IAAM,gCAAA,GAAmC;AAGzC,IAAM,8BAAA,GAAiC;AAGvC,IAAM,kCAAA,GAAqC;AAG3C,IAAM,iCAAA,GAAoC;AAG1C,IAAM,kCAAA,GACX,4BAA4B,8BAA8B,CAAA;AAGrD,IAAM,2BAAA,GAA8B,CAAC,MAAA,EAAQ,MAAA,EAAQ,YAAY;AAEjE,SAAS,0BAA0B,KAAA,EAAuE;AAC/G,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,4BAA4B,IAAA,CAAK,CAAA,IAAA,KAAQ,SAAS,KAAK,CAAA;AAC7F;;;AC/DO,IAAM,2BAAA,GAA8B;AACpC,IAAM,6BAAA,GAAgC;AAgCtC,IAAM,gBAAA,GAAmB;AAGzB,IAAM,4BAAA,GAA+B;AASrC,IAAM,6BAAA,GAAgC;AA2DtC,IAAM,yBAAA,GAA4B;AAElC,IAAM,gBAAA,GAAmB;AAAA,EAC9B,OAAA;AAAA,EACA,aAAA;AAAA,EACA,sBAAA;AAAA,EACA,mBAAA;AAAA,EACA,oBAAA;AAAA,EACA,oBAAA;AAAA,EACA,mCAAA;AAAA,EACA,mBAAA;AAAA,EACA,qBAAA;AAAA,EACA,6BAAA;AAAA,EACA,4BAAA;AAAA,EACA,8BAAA;AAAA,EACA,oCAAA;AAAA,EACA,+BAAA;AAAA,EACA,qCAAA;AAAA,EACA,uCAAA;AAAA,EACA,wCAAA;AAAA,EACA,sCAAA;AAAA,EACA,gCAAA;AAAA,EACA,kCAAA;AAAA,EACA,wCAAA;AAAA,EACA,gCAAA;AAAA,EACA,yBAAA;AAAA,EACA,6BAAA;AAAA,EACA,gCAAA;AAAA,EACA,8BAAA;AAAA,EACA,iCAAA;AAAA,EACA;AACF;;;ACxIO,IAAM,WAAA,GAAc;AAAA,EACzB,SAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,eAAA;AAAA,EACA,UAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF;AAoBO,IAAM,gBAAA,GAAsE;AAAA,EACjF,OAAA,EAAS,CAAC,SAAA,EAAW,WAAA,EAAa,QAAQ,CAAA;AAAA,EAC1C,OAAA,EAAS,CAAC,SAAA,EAAW,QAAA,EAAU,WAAW,CAAA;AAAA,EAC1C,OAAA,EAAS,CAAC,eAAA,EAAiB,UAAA,EAAY,UAAU,WAAW,CAAA;AAAA,EAC5D,aAAA,EAAe,CAAC,SAAA,EAAW,QAAA,EAAU,WAAW,CAAA;AAAA,EAChD,UAAU,EAAC;AAAA,EACX,QAAQ,EAAC;AAAA,EACT,WAAW;AACb;AAGO,SAAS,aAAA,CAAc,MAAiB,EAAA,EAAwB;AACrE,EAAA,OAAO,gBAAA,CAAiB,IAAI,CAAA,CAAE,QAAA,CAAS,EAAE,CAAA;AAC3C;;;ACnCO,IAAM,kCAAkC,IAAA,GAAO;AAE/C,IAAM,+BAAA,GAAkC;AAGxC,IAAM,cAAc,MAAA,CAAO,MAAA,CAAO,CAAC,IAAA,EAAM,QAAA,EAAU,OAAO,CAAU","file":"constants.js","sourcesContent":["/**\n * The ONE version of the input-preparation contract, shared by this relay wire\n * (the `agent.input.preparation` payload and the completion receipt summary)\n * and by the device-local request, receipt and artifact\n * (`@byok-sdk/client`'s `INPUT_PREPARATION_VERSION`, which is this value).\n *\n * The relay wire carries no version field of its own, so a version change is\n * made visible where admission actually happens: in the capability token\n * below. See `INPUT_PREPARATION_VERSION` in the client for what each version\n * changed.\n */\nexport const INPUT_PREPARATION_WIRE_VERSION = 9 as const;\n\n\n/** Additive daemon capability names. Server/cloud admission consumes these exactly. */\nexport const AGENT_EGRESS_POLICY_CAPABILITY = 'agent-egress-policy' as const;\n\nexport const AGENT_EGRESS_RELIABLE_ACK_CAPABILITY = 'agent-egress-reliable-ack' as const;\n\n/** Admits the distinct offer whose runtime mints its session only after start. */\nexport const AGENT_EGRESS_FRESH_SESSION_CAPABILITY = 'agent-egress-fresh-session' as const;\n\n/** Admits the distinct Agent-authored message lane; activity policy remains independent. */\nexport const AGENT_MESSAGE_EGRESS_CAPABILITY = 'agent-message-egress' as const;\n\nexport const AGENT_CONTENT_WORKSPACE_READ_CAPABILITY = 'agent-content-workspace-read' as const;\n\nexport const AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY = 'agent-content-transcript-read' as const;\n\nexport const AGENT_CONTENT_ARTIFACT_READ_CAPABILITY = 'agent-content-artifact-read' as const;\n\n/** Capability required before a task-free Agent-home projection is admitted. */\nexport const AGENT_HOME_PROJECTION_CAPABILITY = 'agent-home-projection' as const;\n\n/** Capability required before an offer may select terminal projection behavior. */\nexport const TERMINAL_PROJECTION_SELECTION_CAPABILITY = 'terminal-projection-selection' as const;\n\n/** Contract §8.1's capability gate for `byok-task-assertion-v1` tool authority. */\nexport const HOST_MCP_TASK_CONTEXT_CAPABILITY = 'host-mcp-task-context' as const;\n\n/** Daemon capability required before an exact local provider profile may be offered. */\nexport const PROVIDER_PROFILE_BINDING_CAPABILITY = 'provider-profile-binding' as const;\n\n/** Device capability required before a Host may enqueue `provider.provisioning.available`. */\nexport const PROVIDER_PROVISIONING_CAPABILITY = 'provider-provisioning.v1' as const;\n\n/** Device capability required before a Host may enqueue `agent.memory.intent.available`. */\nexport const AGENT_MEMORY_INTENT_CAPABILITY = 'agent-memory-intent.v1' as const;\n\n/** Capability required before the optional hosted Agent-memory projection can be used. */\nexport const AGENT_MEMORY_PROJECTION_CAPABILITY = 'agent.memory.projection' as const;\n\n/** Device capability required before an ordinary Agent offer may carry `agentMemory`. */\nexport const AGENT_MEMORY_SELECTION_CAPABILITY = 'agent-memory-selection' as const;\n\n/** Exact capability of the single input-preparation wire authority. */\nexport const AGENT_INPUT_PREPARATION_CAPABILITY =\n `agent-input-preparation-v${INPUT_PREPARATION_WIRE_VERSION}` as const;\n\n/** Single value authority shared by schema validation and schema-free consumers. */\nexport const PREPARED_AGENT_MEMORY_MODES = ['none', 'read', 'read-write'] as const;\n\nexport function isPreparedAgentMemoryMode(value: unknown): value is (typeof PREPARED_AGENT_MEMORY_MODES)[number] {\n return typeof value === 'string' && PREPARED_AGENT_MEMORY_MODES.some(mode => mode === value);\n}\n","/** Bounded volatile navigation; only cursor is a durable acknowledgement. */\nexport const MAILBOX_READ_AHEAD_MAX_SEQS = 4096;\nexport const MAILBOX_READ_AHEAD_CAPABILITY = 'mailbox-read-ahead';\n\n/**\n * Wire protocol version. Every v3 change is a version bump, a gated addition\n * or a strip-safe addition: see docs/protocol.md \"Freeze rule\", which is the\n * one statement of the rule, and `src/wire-additions.ts`, which declares the\n * receiver-capability gates and additions. No v3 release has been published\n * yet, so `src/__tests__/compat.test.ts` has no published v3 decoder to prove\n * additions against; cross-release gates stay unproven until one exists.\n *\n * v3 makes `schema` required on the `terminalProjection.mode:\n * 'result-document'` arm (`terminal-projection.ts`, `result-schema.ts`): the\n * offer freezes the outcome schema, and the outcome reaches the Host only as\n * `task.complete.document`. That narrows a strict shape, so it is a wire\n * major. A v2 envelope is rejected; there is no v2 reader and no capability\n * negotiation between the two result-document shapes. Drain, then upgrade\n * server and client together. Every addition v2 declared is part of the v3\n * baseline, and the v2 `result-document` capability flag is gone: every v3\n * server keeps `task.complete.document`.\n *\n * v2 removed the task offer's `policy` (`PermissionPolicy`), the runtime\n * capability `permissionModes` and the input-preparation `permissionMode`.\n * Sessions run without an SDK permission gate; each local agent keeps its\n * own guardrails. A v1 envelope is rejected; there is no v1 reader.\n * v2 also removed the egress policy's `metadata-status` activity mode, its\n * `activity.mode` field and the `sanitizer_rejected` drop reason. Agent\n * egress goes to the Host as the runtime produced it.\n * v2 also removed the input-preparation artifact's `toolImplementationKinds`\n * and the readiness reason `executor_identity_unproven`. The SDK does not\n * attest tool executables. The artifact names its counted tools in\n * `toolNames`.\n */\nexport const PROTOCOL_VERSION = 3;\n\n/** Host declares that this device accepts only Agent-bound offer variants. */\nexport const STRICT_AGENT_ONLY_CAPABILITY = 'strict-agent-only' as const;\n\n/**\n * The device runs `homeAccess: 'memory-reader'` Agent offers: each reader\n * Attempt gets its own run directory under the Agent home, and readers are\n * counted apart from the one writer. The Agent offers are strict, so a host\n * must refuse a reader offer to a device without this flag before it creates\n * the task.\n */\nexport const AGENT_HOME_READERS_CAPABILITY = 'agent-home-readers' as const;\n\n/**\n * Capability flags exchanged during the connection handshake (`conn.hello` /\n * `conn.ack`). Additional flags may be introduced without a protocol version\n * bump; unrecognized flags must be ignored by both sides.\n *\n * `interactive-approval` is RESERVED as of this addition: it gates the\n * (currently unexercised) approval seam — a server must not route an\n * approval-requiring policy to a daemon that hasn't advertised this flag. No\n * bundled runtime adapter emits it yet; that's expected until interactive\n * approval is actually wired up in a later wave.\n *\n * `approval_resolved` (additive-minor): a SERVER-advertised flag meaning\n * \"I understand the `task.approval_resolved` message\" (`messages.ts`). This\n * is the N/N-1 answer for that new daemon -> server message: an old server's\n * `CAPABILITY_FLAGS`/`conn.ack.capabilities` never includes it, so a new\n * daemon talking to an old server never sends `task.approval_resolved` at\n * all (see `packages/client`'s `task-runner.ts`) and falls back to the\n * pre-existing implicit-resume inference\n * (`ConnectionHub.resumeIfImplicitlyApproved`, `packages/server/src/hub.ts`)\n * unconditionally, exactly as before this flag existed. Unlike\n * `interactive-approval`, this one IS exercised the moment both sides\n * support it — there is no reserved/dormant period for it.\n */\n/**\n * `approval-targeting` (M5, additive-minor): unlike `approval_resolved`\n * above, this flag is purely INFORMATIONAL/semantic, not a functional gate.\n * `task.await_approval`/`task.approve`/`task.reject` all carry their new\n * `approvalId` field UNCONDITIONALLY on both sides once each peer is\n * upgraded -- the wire is tolerant (a plain, non-`.strict()` `z.object()`\n * field, `messages.ts`), so no version/capability negotiation is needed just\n * to send it safely; an older peer that doesn't recognize the field simply\n * never reads it. Receivers decide whether to apply exact-match targeting\n * by FIELD PRESENCE on the specific message at hand (does this particular\n * `task.approve`/`task.reject`/`onApprovalResolved` payload carry an\n * `approvalId`, and does a stored one exist to compare it against?), never\n * by checking this flag -- see `ConnectionHub.approveTask`/`rejectTask`/\n * `onApprovalResolved` and `TaskRunner.handleApprove`/`handleReject`\n * (`packages/client`'s `task-runner.ts`). This flag exists only so each side\n * can advertise, and an embedder/operator can observe (`ConnectionHub.\n * getDeviceCapabilities`), whether the OTHER side is new enough to\n * participate in targeting at all -- the same N/N-1-safe shape as every\n * other flag here, just consumed for observability instead of gating.\n */\n/**\n * `dispatch-selection` (additive-minor) is a correctness gate for the\n * optional `task.offer.dispatchSelection` control field. An older v1 daemon\n * legally strips unknown optional fields, so a server must never send an\n * authoritative provider/model selection unless the target connection\n * advertises this flag. Absence means reject before task creation, not send\n * a legacy runtime-only offer that could reach a different provider.\n *\n * `toolset-selection` (additive-minor) means the daemon understands\n * `task.offer_with_toolsets` and can resolve its logical ids against local\n * MCP configuration. The distinct message type is also the N/N-1 safety\n * boundary for long-poll: an older daemon skips it as unknown and therefore\n * cannot accidentally execute the instruction without the required tools.\n */\nexport const CUSTOM_HARNESS_CAPABILITY = 'custom-harness' as const;\n\nexport const CAPABILITY_FLAGS = [\n 'steer',\n 'blob-upload',\n 'interactive-approval',\n 'approval_resolved',\n 'approval-targeting',\n 'dispatch-selection',\n PROVIDER_PROFILE_BINDING_CAPABILITY,\n 'toolset-selection',\n 'agent-home-contract',\n AGENT_HOME_READERS_CAPABILITY,\n STRICT_AGENT_ONLY_CAPABILITY,\n AGENT_EGRESS_POLICY_CAPABILITY,\n AGENT_EGRESS_RELIABLE_ACK_CAPABILITY,\n AGENT_MESSAGE_EGRESS_CAPABILITY,\n AGENT_EGRESS_FRESH_SESSION_CAPABILITY,\n AGENT_CONTENT_WORKSPACE_READ_CAPABILITY,\n AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY,\n AGENT_CONTENT_ARTIFACT_READ_CAPABILITY,\n AGENT_HOME_PROJECTION_CAPABILITY,\n AGENT_INPUT_PREPARATION_CAPABILITY,\n TERMINAL_PROJECTION_SELECTION_CAPABILITY,\n HOST_MCP_TASK_CONTEXT_CAPABILITY,\n CUSTOM_HARNESS_CAPABILITY,\n MAILBOX_READ_AHEAD_CAPABILITY,\n PROVIDER_PROVISIONING_CAPABILITY,\n AGENT_MEMORY_INTENT_CAPABILITY,\n AGENT_MEMORY_SELECTION_CAPABILITY,\n 'agent-message-draft',\n] as const;\n\nexport type CapabilityFlag = (typeof CAPABILITY_FLAGS)[number];\nimport {\n AGENT_EGRESS_POLICY_CAPABILITY,\n AGENT_EGRESS_RELIABLE_ACK_CAPABILITY,\n AGENT_EGRESS_FRESH_SESSION_CAPABILITY,\n AGENT_MESSAGE_EGRESS_CAPABILITY,\n AGENT_CONTENT_WORKSPACE_READ_CAPABILITY,\n AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY,\n AGENT_CONTENT_ARTIFACT_READ_CAPABILITY,\n AGENT_HOME_PROJECTION_CAPABILITY,\n TERMINAL_PROJECTION_SELECTION_CAPABILITY,\n HOST_MCP_TASK_CONTEXT_CAPABILITY,\n PROVIDER_PROFILE_BINDING_CAPABILITY,\n PROVIDER_PROVISIONING_CAPABILITY,\n AGENT_MEMORY_INTENT_CAPABILITY,\n AGENT_MEMORY_SELECTION_CAPABILITY,\n AGENT_INPUT_PREPARATION_CAPABILITY,\n} from './capability-constants';\n","export const TASK_STATES = [\n 'Offered',\n 'Claimed',\n 'Running',\n 'AwaitApproval',\n 'Complete',\n 'Failed',\n 'Cancelled',\n] as const;\n\nexport type TaskState = (typeof TASK_STATES)[number];\n\n/**\n * Legal state transitions for a task. `Complete` / `Failed` / `Cancelled` are\n * terminal (no outgoing edges). `Running` and `AwaitApproval` form a loop:\n * the daemon can request approval mid-run and resume once the server\n * approves (or fail/cancel out of the approval wait).\n *\n * `Offered -> Failed` (M1 gap #5, \"Declined vs. Failed\"): a daemon that\n * declines an offer pre-claim (`task.decline`) reports it through the\n * existing `Failed` state rather than a new `Declined` state. A decline and\n * a post-claim failure are the same outcome from the dispatcher's point of\n * view — this attempt produced no result, `reason`/`retryable` say why and\n * whether retrying elsewhere makes sense — so reusing `Failed` keeps the\n * state machine minimal instead of forking every terminal-state consumer\n * into \"Failed or Declined, handle both\". See docs/protocol.md for the full\n * writeup.\n */\nexport const TASK_TRANSITIONS: Readonly<Record<TaskState, readonly TaskState[]>> = {\n Offered: ['Claimed', 'Cancelled', 'Failed'],\n Claimed: ['Running', 'Failed', 'Cancelled'],\n Running: ['AwaitApproval', 'Complete', 'Failed', 'Cancelled'],\n AwaitApproval: ['Running', 'Failed', 'Cancelled'],\n Complete: [],\n Failed: [],\n Cancelled: [],\n};\n\n/** Whether `from -> to` is a legal transition per {@link TASK_TRANSITIONS}. */\nexport function canTransition(from: TaskState, to: TaskState): boolean {\n return TASK_TRANSITIONS[from].includes(to);\n}\n","/** Schema-free protocol values. Import this entry when runtime schemas are unnecessary. */\nexport * from './version';\nexport * from './task-state';\nexport * from './capability-constants';\n\n/** Maximum raw UTF-8 content bytes in one local Host Agent-memory export; no truncation. */\nexport const AGENT_MEMORY_MAX_SNAPSHOT_BYTES = 1024 * 1024;\n/** Maximum memory files in one local Host export, including MEMORY.md. */\nexport const AGENT_MEMORY_MAX_SNAPSHOT_FILES = 128;\n\n/** The frozen wire runtime ids. Any other adapter id is a custom harness (`harnessId`). */\nexport const RUNTIME_IDS = Object.freeze(['pi', 'claude', 'codex'] as const);\n"]}
1
+ {"version":3,"sources":["../src/capability-constants.ts","../src/version.ts","../src/task-state.ts","../src/constants.ts"],"names":[],"mappings":"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","file":"constants.js","sourcesContent":["/**\n * The ONE version of the input-preparation contract, shared by this relay wire\n * (the `agent.input.preparation` payload and the completion receipt summary)\n * and by the device-local request, receipt and artifact\n * (`@byok-sdk/client`'s `INPUT_PREPARATION_VERSION`, which is this value).\n *\n * The relay wire carries no version field of its own, so a version change is\n * made visible where admission actually happens: in the capability token\n * below. See `INPUT_PREPARATION_VERSION` in the client for what each version\n * changed.\n */\nexport const INPUT_PREPARATION_WIRE_VERSION = 9 as const;\n\n\n/** Additive daemon capability names. Server/cloud admission consumes these exactly. */\nexport const AGENT_EGRESS_POLICY_CAPABILITY = 'agent-egress-policy' as const;\n\nexport const AGENT_EGRESS_RELIABLE_ACK_CAPABILITY = 'agent-egress-reliable-ack' as const;\n\n/** Admits the distinct offer whose runtime mints its session only after start. */\nexport const AGENT_EGRESS_FRESH_SESSION_CAPABILITY = 'agent-egress-fresh-session' as const;\n\n/** Admits the distinct Agent-authored message lane; activity policy remains independent. */\nexport const AGENT_MESSAGE_EGRESS_CAPABILITY = 'agent-message-egress' as const;\n\nexport const AGENT_CONTENT_WORKSPACE_READ_CAPABILITY = 'agent-content-workspace-read' as const;\n\nexport const AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY = 'agent-content-transcript-read' as const;\n\nexport const AGENT_CONTENT_ARTIFACT_READ_CAPABILITY = 'agent-content-artifact-read' as const;\n\n/** Capability required before a task-free Agent-home projection is admitted. */\nexport const AGENT_HOME_PROJECTION_CAPABILITY = 'agent-home-projection' as const;\n\n/** Capability required before an offer may select terminal projection behavior. */\nexport const TERMINAL_PROJECTION_SELECTION_CAPABILITY = 'terminal-projection-selection' as const;\n\n/** Contract §8.1's capability gate for `byok-task-assertion-v1` tool authority. */\nexport const HOST_MCP_TASK_CONTEXT_CAPABILITY = 'host-mcp-task-context' as const;\n\n/** Daemon capability required before an exact local provider profile may be offered. */\nexport const PROVIDER_PROFILE_BINDING_CAPABILITY = 'provider-profile-binding' as const;\n\n/** Device capability required before a Host may enqueue `provider.provisioning.available`. */\nexport const PROVIDER_PROVISIONING_CAPABILITY = 'provider-provisioning.v1' as const;\n\n/** Device capability required before a Host may enqueue `agent.memory.intent.available`. */\nexport const AGENT_MEMORY_INTENT_CAPABILITY = 'agent-memory-intent.v1' as const;\n\n/** Capability required before the optional hosted Agent-memory projection can be used. */\nexport const AGENT_MEMORY_PROJECTION_CAPABILITY = 'agent.memory.projection' as const;\n\n/** Device capability required before an ordinary Agent offer may carry `agentMemory`. */\nexport const AGENT_MEMORY_SELECTION_CAPABILITY = 'agent-memory-selection' as const;\n\n/** Device capability required before an ordinary Agent offer may carry `agentMemory: 'read-if-admitted'`. */\nexport const AGENT_MEMORY_READ_IF_ADMITTED_CAPABILITY = 'agent-memory-read-if-admitted' as const;\n\n/** Device capability required before an ordinary Agent offer may carry `agentMemory: 'read-write-if-admitted'`. */\nexport const AGENT_MEMORY_READ_WRITE_IF_ADMITTED_CAPABILITY = 'agent-memory-read-write-if-admitted' as const;\n\n/** Exact capability of the single input-preparation wire authority. */\nexport const AGENT_INPUT_PREPARATION_CAPABILITY =\n `agent-input-preparation-v${INPUT_PREPARATION_WIRE_VERSION}` as const;\n\n/**\n * Sealed payload v1 (#654). A device advertises it before a Host may send it\n * a sealed offer or steer; a server advertises it before a device may send it\n * sealed task output or a sealed decline code. Both gates read\n * `WIRE_ADDITIONS`.\n */\nexport const SEALED_PAYLOAD_CAPABILITY = 'sealed-payload-v1' as const;\n\n/**\n * A server advertises it before a device may send a sealed task output that\n * names its ciphertext blob (`sealed.ciphertextRef`) instead of carrying it\n * inline. The server then holds the blob for the life of the task.\n */\nexport const SEALED_OUTPUT_CIPHERTEXT_REF_CAPABILITY = 'sealed-output-ciphertext-ref' as const;\n\n/**\n * A server advertises it before a device may send `task.fail.failure`, the\n * machine-readable runtime failure class (#869).\n */\nexport const RUNTIME_FAILURE_CLASS_CAPABILITY = 'runtime-failure-class' as const;\n\n/**\n * The closed classes of `task.fail.failure.class`: the vendored OAR\n * `FailureClass` values. `unknown` means the runtime gave no structured\n * evidence. Single value authority shared by schema validation and\n * schema-free consumers.\n */\nexport const RUNTIME_FAILURE_CLASSES = [\n 'auth', 'quota', 'rate_limited', 'billing', 'model_unavailable', 'input_too_large', 'invalid_request',\n 'overloaded', 'provider', 'runtime_exited', 'limit_reached', 'output_schema', 'unknown',\n] as const;\n\n/** Single value authority shared by schema validation and schema-free consumers. */\nexport const PREPARED_AGENT_MEMORY_MODES = ['none', 'read', 'read-write'] as const;\n\nexport function isPreparedAgentMemoryMode(value: unknown): value is (typeof PREPARED_AGENT_MEMORY_MODES)[number] {\n return typeof value === 'string' && PREPARED_AGENT_MEMORY_MODES.some(mode => mode === value);\n}\n","/** Bounded volatile navigation; only cursor is a durable acknowledgement. */\nexport const MAILBOX_READ_AHEAD_MAX_SEQS = 4096;\nexport const MAILBOX_READ_AHEAD_CAPABILITY = 'mailbox-read-ahead';\n\n/**\n * Wire protocol version. Every v3 change is a version bump, a gated addition\n * or a strip-safe addition: see docs/protocol.md \"Freeze rule\", which is the\n * one statement of the rule, and `src/wire-additions.ts`, which declares the\n * receiver-capability gates and additions. No v3 release has been published\n * yet, so `src/__tests__/compat.test.ts` has no published v3 decoder to prove\n * additions against; cross-release gates stay unproven until one exists.\n *\n * v3 makes `schema` required on the `terminalProjection.mode:\n * 'result-document'` arm (`terminal-projection.ts`, `result-schema.ts`): the\n * offer freezes the outcome schema, and the outcome reaches the Host only as\n * `task.complete.document`. That narrows a strict shape, so it is a wire\n * major. A v2 envelope is rejected; there is no v2 reader and no capability\n * negotiation between the two result-document shapes. Drain, then upgrade\n * server and client together. Every addition v2 declared is part of the v3\n * baseline, and the v2 `result-document` capability flag is gone: every v3\n * server keeps `task.complete.document`.\n *\n * v2 removed the task offer's `policy` (`PermissionPolicy`), the runtime\n * capability `permissionModes` and the input-preparation `permissionMode`.\n * Sessions run without an SDK permission gate; each local agent keeps its\n * own guardrails. A v1 envelope is rejected; there is no v1 reader.\n * v2 also removed the egress policy's `metadata-status` activity mode, its\n * `activity.mode` field and the `sanitizer_rejected` drop reason. Agent\n * egress goes to the Host as the runtime produced it.\n * v2 also removed the input-preparation artifact's `toolImplementationKinds`\n * and the readiness reason `executor_identity_unproven`. The SDK does not\n * attest tool executables. The artifact names its counted tools in\n * `toolNames`.\n */\nexport const PROTOCOL_VERSION = 3;\n\n/** Host declares that this device accepts only Agent-bound offer variants. */\nexport const STRICT_AGENT_ONLY_CAPABILITY = 'strict-agent-only' as const;\n\n/**\n * The device runs `homeAccess: 'memory-reader'` Agent offers: each reader\n * Attempt gets its own run directory under the Agent home, and readers are\n * counted apart from the one writer. The Agent offers are strict, so a host\n * must refuse a reader offer to a device without this flag before it creates\n * the task.\n */\nexport const AGENT_HOME_READERS_CAPABILITY = 'agent-home-readers' as const;\n\n/**\n * Capability flags exchanged during the connection handshake (`conn.hello` /\n * `conn.ack`). Additional flags may be introduced without a protocol version\n * bump; unrecognized flags must be ignored by both sides.\n *\n * `interactive-approval` is RESERVED as of this addition: it gates the\n * (currently unexercised) approval seam — a server must not route an\n * approval-requiring policy to a daemon that hasn't advertised this flag. No\n * bundled runtime adapter emits it yet; that's expected until interactive\n * approval is actually wired up in a later wave.\n *\n * `approval_resolved` (additive-minor): a SERVER-advertised flag meaning\n * \"I understand the `task.approval_resolved` message\" (`messages.ts`). This\n * is the N/N-1 answer for that new daemon -> server message: an old server's\n * `CAPABILITY_FLAGS`/`conn.ack.capabilities` never includes it, so a new\n * daemon talking to an old server never sends `task.approval_resolved` at\n * all (see `packages/client`'s `task-runner.ts`) and falls back to the\n * pre-existing implicit-resume inference\n * (`ConnectionHub.resumeIfImplicitlyApproved`, `packages/server/src/hub.ts`)\n * unconditionally, exactly as before this flag existed. Unlike\n * `interactive-approval`, this one IS exercised the moment both sides\n * support it — there is no reserved/dormant period for it.\n */\n/**\n * `approval-targeting` (M5, additive-minor): unlike `approval_resolved`\n * above, this flag is purely INFORMATIONAL/semantic, not a functional gate.\n * `task.await_approval`/`task.approve`/`task.reject` all carry their new\n * `approvalId` field UNCONDITIONALLY on both sides once each peer is\n * upgraded -- the wire is tolerant (a plain, non-`.strict()` `z.object()`\n * field, `messages.ts`), so no version/capability negotiation is needed just\n * to send it safely; an older peer that doesn't recognize the field simply\n * never reads it. Receivers decide whether to apply exact-match targeting\n * by FIELD PRESENCE on the specific message at hand (does this particular\n * `task.approve`/`task.reject`/`onApprovalResolved` payload carry an\n * `approvalId`, and does a stored one exist to compare it against?), never\n * by checking this flag -- see `ConnectionHub.approveTask`/`rejectTask`/\n * `onApprovalResolved` and `TaskRunner.handleApprove`/`handleReject`\n * (`packages/client`'s `task-runner.ts`). This flag exists only so each side\n * can advertise, and an embedder/operator can observe (`ConnectionHub.\n * getDeviceCapabilities`), whether the OTHER side is new enough to\n * participate in targeting at all -- the same N/N-1-safe shape as every\n * other flag here, just consumed for observability instead of gating.\n */\n/**\n * `dispatch-selection` (additive-minor) is a correctness gate for the\n * optional `task.offer.dispatchSelection` control field. An older v1 daemon\n * legally strips unknown optional fields, so a server must never send an\n * authoritative provider/model selection unless the target connection\n * advertises this flag. Absence means reject before task creation, not send\n * a legacy runtime-only offer that could reach a different provider.\n *\n * `toolset-selection` (additive-minor) means the daemon understands\n * `task.offer_with_toolsets` and can resolve its logical ids against local\n * MCP configuration. The distinct message type is also the N/N-1 safety\n * boundary for long-poll: an older daemon skips it as unknown and therefore\n * cannot accidentally execute the instruction without the required tools.\n */\nexport const CUSTOM_HARNESS_CAPABILITY = 'custom-harness' as const;\n\nexport const CAPABILITY_FLAGS = [\n 'steer',\n 'blob-upload',\n 'interactive-approval',\n 'approval_resolved',\n 'approval-targeting',\n 'dispatch-selection',\n PROVIDER_PROFILE_BINDING_CAPABILITY,\n 'toolset-selection',\n 'agent-home-contract',\n AGENT_HOME_READERS_CAPABILITY,\n STRICT_AGENT_ONLY_CAPABILITY,\n AGENT_EGRESS_POLICY_CAPABILITY,\n AGENT_EGRESS_RELIABLE_ACK_CAPABILITY,\n AGENT_MESSAGE_EGRESS_CAPABILITY,\n AGENT_EGRESS_FRESH_SESSION_CAPABILITY,\n AGENT_CONTENT_WORKSPACE_READ_CAPABILITY,\n AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY,\n AGENT_CONTENT_ARTIFACT_READ_CAPABILITY,\n AGENT_HOME_PROJECTION_CAPABILITY,\n AGENT_INPUT_PREPARATION_CAPABILITY,\n TERMINAL_PROJECTION_SELECTION_CAPABILITY,\n HOST_MCP_TASK_CONTEXT_CAPABILITY,\n CUSTOM_HARNESS_CAPABILITY,\n MAILBOX_READ_AHEAD_CAPABILITY,\n PROVIDER_PROVISIONING_CAPABILITY,\n AGENT_MEMORY_INTENT_CAPABILITY,\n AGENT_MEMORY_SELECTION_CAPABILITY,\n AGENT_MEMORY_READ_IF_ADMITTED_CAPABILITY,\n AGENT_MEMORY_READ_WRITE_IF_ADMITTED_CAPABILITY,\n 'agent-message-draft',\n SEALED_PAYLOAD_CAPABILITY,\n SEALED_OUTPUT_CIPHERTEXT_REF_CAPABILITY,\n RUNTIME_FAILURE_CLASS_CAPABILITY,\n] as const;\n\nexport type CapabilityFlag = (typeof CAPABILITY_FLAGS)[number];\nimport {\n AGENT_EGRESS_POLICY_CAPABILITY,\n AGENT_EGRESS_RELIABLE_ACK_CAPABILITY,\n AGENT_EGRESS_FRESH_SESSION_CAPABILITY,\n AGENT_MESSAGE_EGRESS_CAPABILITY,\n AGENT_CONTENT_WORKSPACE_READ_CAPABILITY,\n AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY,\n AGENT_CONTENT_ARTIFACT_READ_CAPABILITY,\n AGENT_HOME_PROJECTION_CAPABILITY,\n TERMINAL_PROJECTION_SELECTION_CAPABILITY,\n HOST_MCP_TASK_CONTEXT_CAPABILITY,\n PROVIDER_PROFILE_BINDING_CAPABILITY,\n PROVIDER_PROVISIONING_CAPABILITY,\n AGENT_MEMORY_INTENT_CAPABILITY,\n AGENT_MEMORY_SELECTION_CAPABILITY,\n AGENT_MEMORY_READ_IF_ADMITTED_CAPABILITY,\n AGENT_MEMORY_READ_WRITE_IF_ADMITTED_CAPABILITY,\n AGENT_INPUT_PREPARATION_CAPABILITY,\n SEALED_PAYLOAD_CAPABILITY,\n SEALED_OUTPUT_CIPHERTEXT_REF_CAPABILITY,\n RUNTIME_FAILURE_CLASS_CAPABILITY,\n} from './capability-constants';\n","export const TASK_STATES = [\n 'Offered',\n 'Claimed',\n 'Running',\n 'AwaitApproval',\n 'Complete',\n 'Failed',\n 'Cancelled',\n] as const;\n\nexport type TaskState = (typeof TASK_STATES)[number];\n\n/**\n * Legal state transitions for a task. `Complete` / `Failed` / `Cancelled` are\n * terminal (no outgoing edges). `Running` and `AwaitApproval` form a loop:\n * the daemon can request approval mid-run and resume once the server\n * approves (or fail/cancel out of the approval wait).\n *\n * `Offered -> Failed` (M1 gap #5, \"Declined vs. Failed\"): a daemon that\n * declines an offer pre-claim (`task.decline`) reports it through the\n * existing `Failed` state rather than a new `Declined` state. A decline and\n * a post-claim failure are the same outcome from the dispatcher's point of\n * view — this attempt produced no result, `reason`/`retryable` say why and\n * whether retrying elsewhere makes sense — so reusing `Failed` keeps the\n * state machine minimal instead of forking every terminal-state consumer\n * into \"Failed or Declined, handle both\". See docs/protocol.md for the full\n * writeup.\n */\nexport const TASK_TRANSITIONS: Readonly<Record<TaskState, readonly TaskState[]>> = {\n Offered: ['Claimed', 'Cancelled', 'Failed'],\n Claimed: ['Running', 'Failed', 'Cancelled'],\n Running: ['AwaitApproval', 'Complete', 'Failed', 'Cancelled'],\n AwaitApproval: ['Running', 'Failed', 'Cancelled'],\n Complete: [],\n Failed: [],\n Cancelled: [],\n};\n\n/** Whether `from -> to` is a legal transition per {@link TASK_TRANSITIONS}. */\nexport function canTransition(from: TaskState, to: TaskState): boolean {\n return TASK_TRANSITIONS[from].includes(to);\n}\n","/** Schema-free protocol values. Import this entry when runtime schemas are unnecessary. */\nexport * from './version';\nexport * from './task-state';\nexport * from './capability-constants';\n\n/** Maximum raw UTF-8 content bytes in one local Host Agent-memory export; no truncation. */\nexport const AGENT_MEMORY_MAX_SNAPSHOT_BYTES = 1024 * 1024;\n/** Maximum memory files in one local Host export, including MEMORY.md. */\nexport const AGENT_MEMORY_MAX_SNAPSHOT_FILES = 128;\n\n/** The frozen wire runtime ids. Any other adapter id is a custom harness (`harnessId`). */\nexport const RUNTIME_IDS = Object.freeze(['pi', 'claude', 'codex'] as const);\n"]}
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Member keys, the member chain and scope key packages as the Host stores
3
+ * them (#654 design §7.2–§7.4, E2c).
4
+ *
5
+ * The Host checks shapes only. It never hashes an entry or verifies a
6
+ * signature: members walk the chain themselves (§7.3), so a Host check adds
7
+ * no trust. `@byok-sdk/core/sealed-payload` creates and verifies these values.
8
+ * Protocol does not depend on core, so this module repeats core's shape
9
+ * rules; a cross-package test in `@byok-sdk/cloud` keeps the two equal.
10
+ */
11
+ import { z } from 'zod';
12
+ /** The most chain entries one append accepts. */
13
+ export declare const E2EE_MEMBER_CHAIN_APPEND_MAX_ENTRIES = 64;
14
+ /** The largest canonical JSON entry, in UTF-8 bytes. */
15
+ export declare const E2EE_MEMBER_CHAIN_ENTRY_MAX_BYTES = 65536;
16
+ /** The most chain entries one read returns. */
17
+ export declare const E2EE_MEMBER_CHAIN_READ_MAX_ENTRIES = 256;
18
+ /** The most scope key packages one put accepts. */
19
+ export declare const E2EE_SCOPE_KEY_PACKAGE_PUT_MAX = 256;
20
+ /**
21
+ * The longest scope id, in UTF-16 code units, as for other opaque Host ids.
22
+ * Core sets no maximum, so the scope key package shape (which the parity test
23
+ * compares with core) leaves it out, and the Host checks it on every put and
24
+ * read. The key package notice is Host-built wire, so its schema carries it.
25
+ */
26
+ export declare const E2EE_SCOPE_ID_MAX_LENGTH = 512;
27
+ /** Register the device's member key bundle and its device pairing MAC (§7.2 step 3). */
28
+ export declare const E2EE_MEMBER_KEY_REGISTER_OPERATION: 'e2ee-member-key.register';
29
+ /** Append member chain entries. */
30
+ export declare const E2EE_MEMBER_CHAIN_APPEND_OPERATION: 'e2ee-member-chain.append';
31
+ /** Put scope key packages. */
32
+ export declare const E2EE_SCOPE_KEY_PACKAGE_PUT_OPERATION: 'e2ee-scope-key-package.put';
33
+ /** A member's public key bundle. A device member names its SDK device id; a client member has none. */
34
+ export declare const E2eeMemberKeyBundleSchema: z.ZodObject<{
35
+ v: z.ZodLiteral<1>;
36
+ memberId: z.ZodString;
37
+ signingPublicJwk: z.ZodObject<{
38
+ kty: z.ZodLiteral<"EC">;
39
+ crv: z.ZodLiteral<"P-256">;
40
+ x: z.ZodString;
41
+ y: z.ZodString;
42
+ }, z.core.$strict>;
43
+ kemPublicJwk: z.ZodObject<{
44
+ kty: z.ZodLiteral<"EC">;
45
+ crv: z.ZodLiteral<"P-256">;
46
+ x: z.ZodString;
47
+ y: z.ZodString;
48
+ }, z.core.$strict>;
49
+ kemEpoch: z.ZodNumber;
50
+ kemSig: z.ZodString;
51
+ deviceId: z.ZodOptional<z.ZodString>;
52
+ }, z.core.$strict>;
53
+ export type E2eeMemberKeyBundle = z.infer<typeof E2eeMemberKeyBundleSchema>;
54
+ export declare const E2EE_MEMBER_CHAIN_OPS: readonly ['add', 'remove', 'rotate', 'scope-policy', 'shred'];
55
+ /**
56
+ * One signed member chain entry. `subject` must be a JSON object; the Host
57
+ * stores the entry as canonical JSON, which refuses any value outside JSON.
58
+ * A `shred` subject must also be exactly `{ scopeId }`.
59
+ */
60
+ export declare const E2eeMemberChainEntrySchema: z.ZodObject<{
61
+ v: z.ZodLiteral<1>;
62
+ tenantId: z.ZodString;
63
+ seq: z.ZodNumber;
64
+ prev: z.ZodUnion<readonly [z.ZodNull, z.ZodString]>;
65
+ op: z.ZodEnum<{
66
+ add: "add";
67
+ remove: "remove";
68
+ rotate: "rotate";
69
+ "scope-policy": "scope-policy";
70
+ shred: "shred";
71
+ }>;
72
+ subject: z.ZodCustom<Readonly<Record<string, unknown>>, Readonly<Record<string, unknown>>>;
73
+ signer: z.ZodString;
74
+ sig: z.ZodString;
75
+ }, z.core.$strict>;
76
+ export type E2eeMemberChainEntry = z.infer<typeof E2eeMemberChainEntrySchema>;
77
+ /** One scope key wrapped to one member (§7.4). */
78
+ export declare const E2eeScopeKeyPackageSchema: z.ZodObject<{
79
+ v: z.ZodLiteral<1>;
80
+ tenantId: z.ZodString;
81
+ scopeId: z.ZodString;
82
+ epoch: z.ZodNumber;
83
+ keyId: z.ZodString;
84
+ recipient: z.ZodString;
85
+ sender: z.ZodString;
86
+ enc: z.ZodString;
87
+ ciphertext: z.ZodString;
88
+ sig: z.ZodString;
89
+ }, z.core.$strict>;
90
+ export type E2eeScopeKeyPackage = z.infer<typeof E2eeScopeKeyPackageSchema>;
91
+ /** A pairing MAC (§7.2 steps 3 and 4): HMAC-SHA-256 under `pv`, which the Host never holds. */
92
+ export declare const E2eePairingMacSchema: z.ZodString;
93
+ /**
94
+ * The device registration body. `member` is the device's own bundle, so it
95
+ * names the device id; `mac` is the device pairing MAC over it under `pv`.
96
+ */
97
+ export declare const E2eeMemberKeyRegisterRequestSchema: z.ZodObject<{
98
+ member: z.ZodObject<{
99
+ v: z.ZodLiteral<1>;
100
+ memberId: z.ZodString;
101
+ signingPublicJwk: z.ZodObject<{
102
+ kty: z.ZodLiteral<"EC">;
103
+ crv: z.ZodLiteral<"P-256">;
104
+ x: z.ZodString;
105
+ y: z.ZodString;
106
+ }, z.core.$strict>;
107
+ kemPublicJwk: z.ZodObject<{
108
+ kty: z.ZodLiteral<"EC">;
109
+ crv: z.ZodLiteral<"P-256">;
110
+ x: z.ZodString;
111
+ y: z.ZodString;
112
+ }, z.core.$strict>;
113
+ kemEpoch: z.ZodNumber;
114
+ kemSig: z.ZodString;
115
+ deviceId: z.ZodOptional<z.ZodString>;
116
+ }, z.core.$strict>;
117
+ mac: z.ZodString;
118
+ }, z.core.$strict>;
119
+ export type E2eeMemberKeyRegisterRequest = z.infer<typeof E2eeMemberKeyRegisterRequestSchema>;
120
+ /** What the client relays to the device in pairing step 4. The client member has no device id. */
121
+ export declare const E2eeClientPairingMacSchema: z.ZodObject<{
122
+ mac: z.ZodString;
123
+ member: z.ZodObject<{
124
+ v: z.ZodLiteral<1>;
125
+ memberId: z.ZodString;
126
+ signingPublicJwk: z.ZodObject<{
127
+ kty: z.ZodLiteral<"EC">;
128
+ crv: z.ZodLiteral<"P-256">;
129
+ x: z.ZodString;
130
+ y: z.ZodString;
131
+ }, z.core.$strict>;
132
+ kemPublicJwk: z.ZodObject<{
133
+ kty: z.ZodLiteral<"EC">;
134
+ crv: z.ZodLiteral<"P-256">;
135
+ x: z.ZodString;
136
+ y: z.ZodString;
137
+ }, z.core.$strict>;
138
+ kemEpoch: z.ZodNumber;
139
+ kemSig: z.ZodString;
140
+ deviceId: z.ZodOptional<z.ZodString>;
141
+ }, z.core.$strict>;
142
+ chainHead: z.ZodObject<{
143
+ seq: z.ZodNumber;
144
+ hash: z.ZodString;
145
+ }, z.core.$strict>;
146
+ }, z.core.$strict>;
147
+ export type E2eeClientPairingMac = z.infer<typeof E2eeClientPairingMacSchema>;
148
+ /**
149
+ * Server -> daemon `e2ee.key_package.available` (E2c-3): the Host stored a
150
+ * scope key package for this device's member. The payload names only the
151
+ * scope epoch; the device fetches the package from its device route (§7.4,
152
+ * notice-and-fetch), so a mailbox row never holds key material. Gated by
153
+ * `sealed-payload-v1`.
154
+ */
155
+ export declare const E2eeKeyPackageAvailablePayloadSchema: z.ZodObject<{
156
+ scopeId: z.ZodString;
157
+ epoch: z.ZodNumber;
158
+ }, z.core.$strict>;
159
+ export type E2eeKeyPackageAvailablePayload = z.infer<typeof E2eeKeyPackageAvailablePayloadSchema>;