@byok-sdk/protocol 0.26.1 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,61 @@
1
+ /**
2
+ * The one table of receiver-capability gates and wire additions
3
+ * (docs/protocol.md "Freeze rule").
4
+ *
5
+ * A v3 change takes exactly one of three paths: a version bump, a gated
6
+ * addition, or a strip-safe addition. Envelope and HTTP rows have explicit
7
+ * kinds. The last two are declared here.
8
+ *
9
+ * - `gated`: the sender must not emit the surface unless the receiver
10
+ * durably advertised `capability`. A field entry applies when the payload
11
+ * carries the field (and, with `value`, when the field equals it); a type
12
+ * entry applies to every message of that type. Server-to-daemon surfaces
13
+ * are gated by a device flag, daemon-to-server surfaces by a server flag.
14
+ * - `strip-safe`: an optional field an older receiver drops without changing
15
+ * what it executes or acknowledges.
16
+ *
17
+ * v3 baseline: every v3 decoder reads every surface v2 had, so the v2
18
+ * strip-safe rows and the v2 `result-document` gate are gone. The device
19
+ * gates kept below name capabilities a daemon advertises only when it is
20
+ * configured for them (Agent home, egress, input preparation, provisioning,
21
+ * memory intents and so on): they gate on the receiver's configuration. The
22
+ * server-advertised `approval_resolved` gate is kept as the daemon's sending
23
+ * condition for `task.approval_resolved`. No v3 release has been
24
+ * published, so no row is proven against a published v3 decoder yet
25
+ * (`src/__tests__/compat.test.ts`).
26
+ *
27
+ * Senders derive their admission flags from {@link requiredReceiverCapabilities}
28
+ * and nowhere else, so a gate cannot exist in one place and be missing in
29
+ * another. This module imports no runtime code (types only) so it stays free
30
+ * of zod.
31
+ */
32
+ import type { MessageType } from './messages';
33
+ import type { CapabilityFlag } from './version';
34
+ type HttpWireSurface = 'ChallengeRequest' | 'ChallengeResponse' | 'TokenRequest' | 'TokenResponse' | 'EventsPollQuery' | 'EventsPollResponse' | 'MessagesSendRequest' | 'MessagesSendResponse';
35
+ export type WireAddition = {
36
+ readonly kind: 'envelope';
37
+ readonly rule: 'gated';
38
+ readonly surface: MessageType;
39
+ readonly field?: string;
40
+ readonly value?: string;
41
+ readonly capability: CapabilityFlag;
42
+ readonly advertisedBy: 'device' | 'server';
43
+ } | {
44
+ readonly kind: 'envelope';
45
+ readonly rule: 'strip-safe';
46
+ readonly surface: MessageType;
47
+ readonly field: string;
48
+ } | {
49
+ readonly kind: 'http';
50
+ readonly rule: 'strip-safe';
51
+ readonly surface: HttpWireSurface;
52
+ readonly field: string;
53
+ };
54
+ export declare const WIRE_ADDITIONS: readonly WireAddition[];
55
+ /**
56
+ * Every capability the receiver must have durably advertised before a sender
57
+ * may emit this message. Deduplicated, in table order. A sender refuses (before
58
+ * creating the task or appending to the mailbox) when any is missing.
59
+ */
60
+ export declare function requiredReceiverCapabilities(type: MessageType, payload: unknown): CapabilityFlag[];
61
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byok-sdk/protocol",
3
- "version": "0.26.1",
3
+ "version": "0.27.0",
4
4
  "description": "BYOK SDK wire protocol: envelope schema, message types, and codec helpers",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -26,9 +26,9 @@
26
26
  "import": "./dist/index.js"
27
27
  },
28
28
  "./package.json": "./package.json",
29
- "./input-preparation-version": {
30
- "types": "./dist/input-preparation-version.d.ts",
31
- "import": "./dist/input-preparation-version.js"
29
+ "./constants": {
30
+ "types": "./dist/constants.d.ts",
31
+ "import": "./dist/constants.js"
32
32
  }
33
33
  },
34
34
  "files": [
@@ -48,6 +48,10 @@
48
48
  "clean": "rm -rf dist"
49
49
  },
50
50
  "dependencies": {
51
+ "@cfworker/json-schema": "4.1.1",
51
52
  "zod": "^4.4.3"
53
+ },
54
+ "devDependencies": {
55
+ "byok-protocol-previous": "https://registry.npmjs.org/@byok-sdk/protocol/-/protocol-0.26.1.tgz"
52
56
  }
53
57
  }
@@ -1,12 +0,0 @@
1
- /**
2
- * The ONE version of the input-preparation contract, shared by this relay wire
3
- * (the `agent.input.preparation` payload and the completion receipt summary)
4
- * and by the device-local request, receipt and artifact
5
- * (`@byok-sdk/client`'s `INPUT_PREPARATION_VERSION`, which is this value).
6
- *
7
- * The relay wire carries no version field of its own, so a version change is
8
- * made visible where admission actually happens: in the capability token
9
- * below. See `INPUT_PREPARATION_VERSION` in the client for what each version
10
- * changed.
11
- */
12
- export declare const INPUT_PREPARATION_WIRE_VERSION: 9;
@@ -1,6 +0,0 @@
1
- // src/input-preparation-version.ts
2
- var INPUT_PREPARATION_WIRE_VERSION = 9;
3
-
4
- export { INPUT_PREPARATION_WIRE_VERSION };
5
- //# sourceMappingURL=input-preparation-version.js.map
6
- //# sourceMappingURL=input-preparation-version.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/input-preparation-version.ts"],"names":[],"mappings":";AAWO,IAAM,8BAAA,GAAiC","file":"input-preparation-version.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"]}