@byollm/protocol 0.1.0-alpha.98 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -9,14 +9,45 @@ import {
9
9
  ConsoleStdout,
10
10
  ENVELOPE_BODY_VERSION,
11
11
  PublicIdentity,
12
+ consoleDataBytes,
12
13
  consoleEnvelope,
13
14
  consoleOrder,
15
+ decodeConsoleData,
14
16
  decodeEnvelopeInner,
17
+ encodeConsoleData,
15
18
  encodeEnvelopeInner,
16
19
  envelopeSignedBody,
17
20
  fromBase64Url,
18
21
  toBase64Url
19
- } from "./chunk-W7Q7DKQ6.js";
22
+ } from "./chunk-J3HTAGMX.js";
23
+
24
+ // src/hub-fence.ts
25
+ var HUB_FENCE = "byollm.cloud sees only what routing and metering need: which devices and sites are connected, each job's kind, size, and outcome, and timestamps. Never prompts, never answers, never credentials.";
26
+ var HUB_FENCE_CLAUSES = Object.freeze([
27
+ {
28
+ says: "which devices and sites are connected",
29
+ covers: Object.freeze(["owner_id", "site_id", "member_id"])
30
+ },
31
+ {
32
+ says: "each job's kind, size, and outcome",
33
+ covers: Object.freeze(["kind", "size_class", "disposition", "bytes"])
34
+ },
35
+ {
36
+ says: "and timestamps",
37
+ covers: Object.freeze(["at", "month", "updated_at"])
38
+ },
39
+ /*
40
+ * Ruled plumbing, not a new fact about a person — Todd, 2026-09-04.
41
+ *
42
+ * Named here rather than silently tolerated. A column exempted by a ruling
43
+ * and a column nobody noticed look identical to a check that just skips
44
+ * them, and only one of those is a decision.
45
+ */
46
+ {
47
+ says: "(metering plumbing, ruled unenumerated)",
48
+ covers: Object.freeze(["id", "job_id", "price_version"])
49
+ }
50
+ ]);
20
51
 
21
52
  // src/wire.ts
22
53
  import { z as z9 } from "zod";
@@ -885,6 +916,12 @@ var ClaimedJob = z7.object({
885
916
  deadlineAt: z7.number().int().positive().optional(),
886
917
  lease: Lease
887
918
  }).strict();
919
+ var StopReasonSchema = z7.enum([
920
+ "end",
921
+ "length",
922
+ "stop-sequence",
923
+ "unknown"
924
+ ]);
888
925
  var ResultProvenance = z7.object({
889
926
  /** The audience the job ran under. */
890
927
  audience: Audience,
@@ -897,10 +934,33 @@ var ResultProvenance = z7.object({
897
934
  /** The model the runner reports having used. */
898
935
  model: z7.string().min(1),
899
936
  /**
900
- * False only for `self` jobs. When true the app MUST treat `text` as
937
+ * False only for `private` jobs. When true the app MUST treat `text` as
901
938
  * untrusted third-party content.
902
939
  */
903
- untrusted: z7.boolean()
940
+ untrusted: z7.boolean(),
941
+ /**
942
+ * Why generation stopped, carried from the sealed `ran` — B260.
943
+ *
944
+ * It was sealed by the device, opened at the site, used to build this
945
+ * object, and **dropped**: `provenanceFor` took five fields and `stop` was
946
+ * not one of them, on either lane. So no site could ever see it, and a
947
+ * `length` result — an answer cut off mid-thought — arrived
948
+ * indistinguishable from a complete one. Kevin's team found it on a
949
+ * book-translation pipeline, which is the difference between shipping a
950
+ * chapter and shipping half of one without knowing.
951
+ *
952
+ * Optional here because it is optional there, and for the same reason:
953
+ * absent exactly where it would be a fact about nothing.
954
+ */
955
+ stop: StopReasonSchema.optional(),
956
+ /**
957
+ * Whether the adapter could report a stop signal at all — carried for the
958
+ * reason {@link RunMetadata.stopReported} gives: `unknown` is two facts,
959
+ * and a site told only `unknown` says "we do not know why this stopped"
960
+ * for a `claude-cli` job forever, which is true, and for a
961
+ * `content_filter` result, which is not the same thing at all.
962
+ */
963
+ stopReported: z7.boolean().optional()
904
964
  }).strict();
905
965
  function provenanceFor(input) {
906
966
  return {
@@ -909,15 +969,14 @@ function provenanceFor(input) {
909
969
  runnerOwner: input.runnerOwner,
910
970
  backendClass: input.backendClass,
911
971
  model: input.model,
912
- untrusted: input.audience !== "private"
972
+ untrusted: input.audience !== "private",
973
+ /* Spread rather than assigned: `exactOptionalPropertyTypes` makes an
974
+ explicit `undefined` a different thing from an absent key, and this
975
+ object is `.strict()`. */
976
+ ...input.stop === void 0 ? {} : { stop: input.stop },
977
+ ...input.stopReported === void 0 ? {} : { stopReported: input.stopReported }
913
978
  };
914
979
  }
915
- var StopReasonSchema = z7.enum([
916
- "end",
917
- "length",
918
- "stop-sequence",
919
- "unknown"
920
- ]);
921
980
  var RunMetadata = z7.object({
922
981
  /** Which model actually served it. */
923
982
  model: z7.string().min(1),
@@ -1270,7 +1329,7 @@ async function open(input) {
1270
1329
  }
1271
1330
 
1272
1331
  // src/wire.ts
1273
- var PROTOCOL_VERSION = "1";
1332
+ var PROTOCOL_VERSION = "2";
1274
1333
  var SUPPORTED_PROTOCOL_VERSIONS = Object.freeze([
1275
1334
  PROTOCOL_VERSION
1276
1335
  ]);
@@ -1507,9 +1566,7 @@ var HeartbeatRequest = z9.object({
1507
1566
  * Lease ids rather than job ids, so a replayed heartbeat cannot renew a
1508
1567
  * grant the runner no longer holds — see {@link Lease.id}.
1509
1568
  */
1510
- activeLeases: z9.array(GrantRef),
1511
- /** True while the owner has the daemon paused; the server stops offering work. */
1512
- paused: z9.boolean()
1569
+ activeLeases: z9.array(GrantRef)
1513
1570
  }).strict();
1514
1571
  var HeartbeatResponse = z9.object({
1515
1572
  /**
@@ -2178,6 +2235,15 @@ var PurposeKey = z11.string().regex(
2178
2235
  /^[a-z0-9][a-z0-9-]*$/,
2179
2236
  "a purpose key is a lowercase slug \u2014 letters, digits and hyphens"
2180
2237
  ).max(64);
2238
+ var PurposeRouting = z11.enum([
2239
+ "user-choice",
2240
+ "site-fixed",
2241
+ "user-first-with-fallback"
2242
+ ]);
2243
+ var DEFAULT_ROUTING = "user-choice";
2244
+ function routingOf(purpose) {
2245
+ return purpose.routing ?? DEFAULT_ROUTING;
2246
+ }
2181
2247
  var Purpose = z11.object({
2182
2248
  /**
2183
2249
  * What a person reads on the consent screen. The only rendered field.
@@ -2198,7 +2264,16 @@ var Purpose = z11.object({
2198
2264
  */
2199
2265
  kinds: z11.array(JobKind).min(1).max(JOB_KINDS.length).refine((kinds) => new Set(kinds).size === kinds.length, {
2200
2266
  message: "a purpose lists each kind once"
2201
- })
2267
+ }),
2268
+ /**
2269
+ * How this purpose is routed — RESERVED, validated, not acted on (B236).
2270
+ *
2271
+ * Optional rather than defaulted, so that a manifest without it parses to
2272
+ * a manifest without it. See {@link PurposeRouting} for why a key nothing
2273
+ * reads is worth adding before launch, and {@link routingOf} for the one
2274
+ * place "not stated" is answered.
2275
+ */
2276
+ routing: PurposeRouting.optional()
2202
2277
  }).strict();
2203
2278
  var MAX_PURPOSES = 32;
2204
2279
  var Manifest = z11.record(PurposeKey, Purpose).refine((manifest) => Object.keys(manifest).length > 0, {
@@ -2680,6 +2755,7 @@ export {
2680
2755
  ConsoleResize,
2681
2756
  ConsoleStdin,
2682
2757
  ConsoleStdout,
2758
+ DEFAULT_ROUTING,
2683
2759
  DeliveredResult,
2684
2760
  ENCRYPTION_KEY_CONTEXT,
2685
2761
  ENDPOINTS,
@@ -2694,6 +2770,8 @@ export {
2694
2770
  GRANT_SIGNED_FIELDS,
2695
2771
  GeneratePayload,
2696
2772
  GrantRef,
2773
+ HUB_FENCE,
2774
+ HUB_FENCE_CLAUSES,
2697
2775
  HeartbeatRequest,
2698
2776
  HeartbeatResponse,
2699
2777
  JOB_KINDS,
@@ -2729,6 +2807,7 @@ export {
2729
2807
  PairStartResponse,
2730
2808
  PublicIdentity,
2731
2809
  Purpose,
2810
+ PurposeRouting,
2732
2811
  REFUSAL_MESSAGES,
2733
2812
  REFUSAL_TEXT,
2734
2813
  RESERVED_PURPOSE,
@@ -2767,13 +2846,16 @@ export {
2767
2846
  checkProtocolVersion,
2768
2847
  classifyCost,
2769
2848
  compareVersions,
2849
+ consoleDataBytes,
2770
2850
  consoleEnvelope,
2771
2851
  consoleOrder,
2772
2852
  cryptoReady,
2773
2853
  declaredVersion,
2854
+ decodeConsoleData,
2774
2855
  decodeEnvelopeInner,
2775
2856
  describeBytes,
2776
2857
  effectiveOfferScope,
2858
+ encodeConsoleData,
2777
2859
  encodeEnvelopeInner,
2778
2860
  envelopeBytes,
2779
2861
  envelopeSignedBody,
@@ -2797,6 +2879,7 @@ export {
2797
2879
  provenanceFor,
2798
2880
  publicIdentityOf,
2799
2881
  resolveCost,
2882
+ routingOf,
2800
2883
  seal,
2801
2884
  signGrant,
2802
2885
  signRequest,