@byollm/protocol 0.1.0-alpha.99 → 0.1.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.
package/README.md CHANGED
@@ -1,123 +1,11 @@
1
- > [!WARNING]
2
- > **Alpha (`0.1.0-alpha.99`) — under active development. Don't use this yet.**
1
+ <!-- release-note 0.1.1 -->
2
+ > **`0.1.1` is documentation only — nothing to upgrade.** `PROTOCOL_VERSION`
3
+ > is still `2`, so a 0.1.0 party and a 0.1.1 party talk to each other in both
4
+ > directions. No dependency, schema, wire field or on-disk shape moved.
3
5
  >
4
- > Install it deliberately: `npm install @byollm/protocol@alpha`.
5
- >
6
- > The protocol is v0 and **will** change without a deprecation path, this has
7
- > never run outside its own test suite, and nothing here has production miles.
8
- > Read it, take the ideas, tell us what's wrong — but don't put it in front of
9
- > your users.
10
- >
11
- > npm assigns `latest` on a first publish and won't let it be removed, so a
12
- > bare install resolves here too. This notice is the only guard — deliberately
13
- > not an npm deprecation, which would read as *abandoned* rather than *early*.
14
- > Ask for `@alpha` explicitly so your lockfile records that you meant to.>
15
- > **`alpha.15` is a breaking wire change, and it breaks daemons and relays —
16
- > not app authors.** If you call `app.enqueue(...)` and read results, nothing
17
- > in your code changes. If you run a daemon or an upstream, every package must
18
- > move together: a mixed pair refuses on both sides, because both ends parse
19
- > `.strict()`.
20
- >
21
- > What moved, all of it reconciling the frozen `byollm_009` with its code:
22
- > `JobStub` gains `site` (the site's identity key id) and loses
23
- > `audienceAllow`; `ResultRequest` gains `leaseId`; `HeartbeatResponse` loses
24
- > `leases`, which nothing read; `WireErrorCode` gains `not-ready`,
25
- > `clock-skew` and `forbidden`, and `403` is `forbidden` rather than
26
- > `unauthorized`. `RESULT_PROVENANCE` is superseded by
27
- > `PROVENANCE_NAMES_DEVICE`. See `byollm_009` Amendment A.>
28
- > **`alpha.16` is a breaking wire change — daemons and relays again, not app
29
- > authors.** `app.enqueue(...)` and reading results are unchanged. All five
30
- > packages move together: both ends parse `.strict()`, so a mixed pair
31
- > refuses.
32
- >
33
- > What moved, all of it Tier 2 of `cloud_008`: `model`, `backendClass` and
34
- > `durationMs` come off `ResultRequest` and are sealed **inside** the result
35
- > envelope as `SealedOutcome = { outcome, ran }` — so a daemon can no longer
36
- > declare a model it did not sign, and a relay carries neither.
37
- > `HeartbeatResponse` loses `leases` (nothing read it) and now reports real
38
- > cancellations instead of an empty list. `WireErrorCode` gains `forbidden`
39
- > for 403, leaving `unauthorized` at exactly 401. The relay gained a
40
- > site-plane `cancel` endpoint, honours `stub.deadlineAt`, honours
41
- > `stub.audience`, and remembers a refusal.>
42
- > **`alpha.17` is additive** — no wire change. It exports `ReleaseReason`,
43
- > which `RoutingStore.releaseLeases` names and the package did not export, so
44
- > the interface was unimplementable outside this repo.>
45
- > **`alpha.18` is a breaking wire change — daemons and relays, not app
46
- > authors.** `app.enqueue(...)` and reading results are unchanged. All five
47
- > packages move together.
48
- >
49
- > The **bearer token is gone**: off `PairPollResponse`, off the runner row,
50
- > off the daemon's pairings file, out of the adapter's schema. It was minted,
51
- > hashed and stored on two disks and never sent, looked up or compared —
52
- > `REQUESTS_SIGNED_NOT_BEARER` was enforced by signatures the whole time. If
53
- > you run the Supabase adapter, apply
54
- > `20260819000000_drop_runner_token.sql`; `byollm_approve_pairing` now takes
55
- > one argument. A pairings file written by an older daemon still loads.
56
- >
57
- > `model`, `backendClass` and `durationMs` moved **inside** the sealed result
58
- > (`SealedOutcome = { outcome, ran }`), so a daemon cannot declare a model it
59
- > did not sign and a relay carries none of them. Writing a `RoutingStore`?
60
- > `releaseLeases` takes an optional `reason` and `complete` requires
61
- > `leaseId`, and **an implementation that ignores either still typechecks** —
62
- > run the store contract tests.>
63
- > **`alpha.19` is additive on the wire and a behaviour change in every
64
- > store.** `ResultResponse` gains an optional `duplicate`. Nothing is removed,
65
- > so an older daemon keeps working — but the *order* two rules are checked in
66
- > has changed, and a `RoutingStore` implementation must change with it.
67
- >
68
- > `complete` now checks **terminal state before holder**, scoped to the device
69
- > that finished the job: a replay from that device is answered `duplicate:
70
- > true` with a 2xx, and anyone else gets exactly the refusal they would get
71
- > for a job that is not terminal. Previously `RESULT_IDEMPOTENT` held only
72
- > because the lease is nulled on success, so the holder check tripped first —
73
- > deleting the idempotency branch failed no test. Run the store contract
74
- > tests; the compiler cannot see this.
75
- >
76
- > **`alpha.3` is a breaking change.** `BackendDescriptor.account` is gone —
77
- > read `cost` (`free` / `metered` / `subscription`) instead. Four new MUSTs
78
- > come with it; see `byollm_007`.
79
-
80
- <!-- release-note 0.1.0-alpha.21 -->
81
- > [!NOTE]
82
- > **`0.1.0-alpha.20` is not a complete release — do not pin it.** Four
83
- > packages published and `@byollm/server` did not: a Sigstore
84
- > transparency-log 409 on its provenance attestation. The workflow's
85
- > "already published" guard correctly refuses to resume a partial publish,
86
- > so `0.1.0-alpha.21` is that release, whole.
87
- >
88
- > If you run the Supabase adapter, `alpha.21` needs
89
- > `20260819010000_completed_by_lease_id.sql`: alpha.19 shipped §3.6's
90
- > ordering without the column it stores the grant in.
91
-
92
- <!-- release-note 0.1.0-alpha.40 -->
93
- **`byollm start` — stop keeping a terminal open.** The daemon can now run
94
- under your computer's own supervisor and restart itself if it stops: a launchd
95
- agent on macOS, a `systemd --user` unit on Linux, a logon task on Windows. All
96
- user-level — no root, no system directories, and `byollm stop` takes it
97
- away. `byollm status` gained a line saying whether it is actually supervised
98
- right now, including the state that matters most: installed but not running,
99
- which looks fine from an app's dashboard and serves nothing.
100
-
101
- If you are running via `npx`, install properly first (`npm install -g
102
- byollm@latest`) — `install` refuses to supervise a copy in npx's cache, because
103
- npm deletes that directory and the service would fail at some later boot.
104
-
105
- <!-- release-note 0.1.0-alpha.41 -->
106
- **`onNoRunner` takes a string.** Your fallback answer is your own value, not
107
- wire data, and handing back a whole result record for it was ceremony — the
108
- README's own example got the shape wrong, which is how this was found.
109
-
110
- ```ts
111
- const { outcome, fallback } = await job.result({
112
- onNoRunner: () => runOnHostedModel(transcript),
113
- });
114
- ```
115
-
116
- Whatever you return, `result()` labels it `fallback: true` — the stamp is
117
- applied by the wait, not taken from you, so an answer that did not run on
118
- somebody's device cannot be reported as though it did (`FALLBACK_LABELED`).
119
- Both delivery channels do it, polling and Supabase Realtime. Records still
120
- work; they just get labelled too.
6
+ > This README used to open with a stack of release notes instead of with the
7
+ > package. The history moved to `docs/release-notes/` and `CHANGELOG.md`,
8
+ > where none of it was lost. Full note: `docs/release-notes/0.1.1.md`.
121
9
 
122
10
  # `@byollm/protocol`
123
11
 
@@ -183,7 +71,7 @@ to know which one happened.
183
71
 
184
72
  ## Normative spec
185
73
 
186
- [`docs/protocol.md`](../../docs/protocol.md). Every MUST there carries a
74
+ [`docs/protocol.md`](https://github.com/oftomorrowinc/byollm/blob/main/docs/protocol.md). Every MUST there carries a
187
75
  conformance id that appears in this package's `MUSTS` registry.
188
76
 
189
77
  MIT
@@ -200,4 +88,11 @@ Six packages, and they are only interesting together:
200
88
  - [`@byollm/control-plane`](https://www.npmjs.com/package/@byollm/control-plane) — who may ask whom, and the policy store behind it
201
89
  - [`@byollm/conformance`](https://www.npmjs.com/package/@byollm/conformance) — the kit that proves an implementation is one — including a posture audit that holds nothing but a URL
202
90
 
91
+ ### Where the rest lives
92
+
93
+ - [GitHub](https://github.com/oftomorrowinc/byollm) — the source, and where issues go
94
+ - [byo-llm.com](https://byo-llm.com) — what this is, and why
95
+ - [byollm.cloud](https://byollm.cloud) — the hosted relay — devices, consent and billing
96
+ - [docs.byollm.cloud](https://docs.byollm.cloud) — integrating a site, end to end
97
+
203
98
  <!-- family:end -->
package/dist/index.d.ts CHANGED
@@ -2,6 +2,84 @@ import { z } from 'zod';
2
2
  import { S as StoredKeys, P as PublicIdentity } from './portable-C6rfiCXi.js';
3
3
  export { C as CONSOLE_FRAME_VERSION, a as CONSOLE_MAX_DATA_BYTES, b as ConsoleBye, c as ConsoleFrame, d as ConsoleHello, e as ConsoleOrder, f as ConsoleOrderFault, g as ConsoleOrderResult, h as ConsoleResize, i as ConsoleStdin, j as ConsoleStdout, E as ENCRYPTION_KEY_CONTEXT, k as ENVELOPE_BODY_VERSION, l as ENVELOPE_MAX_AGE_MS, m as EnvelopeBodyContext, n as EnvelopeContext, o as EnvelopeDirection, p as EnvelopeFailure, q as EnvelopeInner, O as OpenResult, r as SealedEnvelope, s as consoleDataBytes, t as consoleEnvelope, u as consoleOrder, v as cryptoReady, w as decodeConsoleData, x as decodeEnvelopeInner, y as encodeConsoleData, z as encodeEnvelopeInner, A as envelopeSignedBody, B as fingerprint, D as fromBase64Url, F as generateKeys, G as keyId, H as open, I as publicIdentityOf, J as seal, K as signWith, L as toBase64Url, M as verifyPublicIdentity, N as verifyWith } from './portable-C6rfiCXi.js';
4
4
 
5
+ /**
6
+ * What byollm.cloud can see, in the words a person reads — B039.
7
+ *
8
+ * ## Why a sentence is in a published package
9
+ *
10
+ * This one sentence has to be true in three places at once: the privacy page
11
+ * that prints it, the check beside the hub's schema that proves every recorded
12
+ * column is claimed by one of its clauses, and the page test that pins the
13
+ * wording. Two of those live in `byollm-cloud`, one in `byollm-cloud-web`, and
14
+ * **a check cannot read another repository** — so until now the sentence was
15
+ * written out three times and nothing compared the copies.
16
+ *
17
+ * That is not a tidiness problem. An enumeration is a promise, and a promise
18
+ * kept in three places drifts in two of them: the copy beside the schema is
19
+ * the one that fails when a column is added, and if it is not the copy on the
20
+ * page, the page stays reassuring and stops being true. Which is worse than
21
+ * never having made the promise.
22
+ *
23
+ * `byollm_023` named the only two shapes — a copy per repository (they
24
+ * diverge, silently) or one source both import (it goes stale, loudly, as a
25
+ * version pin). **Todd ruled shape 2 on 2026-09-17**, and the reason is the
26
+ * one that decides it: staleness is a number somebody can compare, and B164's
27
+ * cross-repository pin comparison is the thing that compares it. Divergence
28
+ * has no such number.
29
+ *
30
+ * ## Why it lives in `@byollm/protocol` and not a package of its own
31
+ *
32
+ * It was one, for a day. **Todd ruled on 2026-09-19: no seventh package** —
33
+ * *"I do think just adding it to protocol and importing that makes a ton of
34
+ * sense"* — and `packages/agreements` was deleted rather than marked private.
35
+ * Both consuming repositories already pin `@byollm/protocol`, so the sentence
36
+ * arrives on a pin they carry instead of a name they would have to adopt, and
37
+ * the cut stops carrying a package that had never been published.
38
+ *
39
+ * ## Published, not internal
40
+ *
41
+ * It ships to npm rather than living in a private repository, and that is a
42
+ * property rather than an accident: a promise about what a hosted service can
43
+ * see is worth more when anybody can install the package, read the sentence,
44
+ * and check it against what the service does. Protocol is public, so that is
45
+ * unchanged by the move.
46
+ */
47
+ /**
48
+ * The hub fence, verbatim — ruled by Todd, 2026-09-04.
49
+ *
50
+ * Asserted whole rather than by keyword wherever it is checked: "close
51
+ * enough" is not a standard a page about what we can see gets to use, and a
52
+ * paraphrase that drifted would leave the other repository checking a sentence
53
+ * nobody ships.
54
+ */
55
+ declare const HUB_FENCE: string;
56
+ /**
57
+ * A clause of {@link HUB_FENCE}, and the columns it accounts for.
58
+ *
59
+ * The mapping is here rather than beside the schema for the same reason the
60
+ * sentence is: it is a fact about the sentence, and the sentence is shared.
61
+ * What stays beside the schema is the CHECK — every recorded column must be
62
+ * claimed by one of these before that suite passes — because the columns are
63
+ * the hub's and only the hub's repository can enumerate them.
64
+ *
65
+ * Coupling copy to columns by check rather than by convention is the whole of
66
+ * the ruling: the enumeration is only a promise if something fails when the
67
+ * code outgrows it.
68
+ */
69
+ interface FenceClause {
70
+ /** The clause as it appears in {@link HUB_FENCE}. */
71
+ readonly says: string;
72
+ /** The recorded columns this clause accounts for. */
73
+ readonly covers: readonly string[];
74
+ }
75
+ /**
76
+ * Every clause, with what it covers.
77
+ *
78
+ * A column not claimed by any clause is a fact about somebody that the page
79
+ * does not mention, which is what the check beside the schema refuses.
80
+ */
81
+ declare const HUB_FENCE_CLAUSES: readonly FenceClause[];
82
+
5
83
  /**
6
84
  * Protocol version carried on every request; servers refuse what they can't
7
85
  * speak.
@@ -25,7 +103,7 @@ export { C as CONSOLE_FRAME_VERSION, a as CONSOLE_MAX_DATA_BYTES, b as ConsoleBy
25
103
  * own words, from the release that silenced a fleet by adding a backend id.
26
104
  * The same sentence applies to removing an offer scope.
27
105
  */
28
- declare const PROTOCOL_VERSION: "1";
106
+ declare const PROTOCOL_VERSION: "2";
29
107
  /**
30
108
  * Every protocol version this build can serve, **oldest first**.
31
109
  *
@@ -108,11 +186,17 @@ declare function checkProtocolVersion(body: unknown): VersionRefusal | null;
108
186
  * starts meaning "the unstable one", and every user who followed this message
109
187
  * is pinned to prereleases with nothing to tell them.
110
188
  *
111
- * Note this is deliberately *not* the rule `scripts/check-site.mjs` enforces
112
- * on the docs, which requires `npx byollm@alpha`. That rule is about somebody
113
- * choosing to install a prerelease knowingly, with the warning in front of
114
- * them. This is an upgrade instruction handed to somebody who already has the
115
- * daemon and needs a newer one — a different question with a different answer.
189
+ * This once said `scripts/check-site.mjs` deliberately enforces the OPPOSITE
190
+ * on the docs — *"which requires `npx byollm@alpha`"* — and drew a careful
191
+ * distinction between choosing a prerelease knowingly and being handed an
192
+ * upgrade command. **That rule inverted at the flip and this paragraph did
193
+ * not.** check-site now refuses any pin but `@latest`, for the reason written
194
+ * beside it: *"the tag that moves first is reviewed last, so asking for it
195
+ * explicitly is asking for the build nobody has looked at yet."* Which is what
196
+ * this constant already said, so the distinction it drew no longer exists.
197
+ *
198
+ * Found sweeping B341 — the same decay as B336 and B339, a third time, and
199
+ * every one was prose left standing over a constant that moved beneath it.
116
200
  */
117
201
  declare const UPGRADE_COMMAND: "npm i -g byollm@latest";
118
202
  /** The path prefix all endpoints mount under. */
@@ -268,7 +352,7 @@ type GrantRef = z.infer<typeof GrantRef>;
268
352
  * and nothing works over a copied string alone.
269
353
  */
270
354
  declare const PairStartRequest: z.ZodObject<{
271
- protocolVersion: z.ZodLiteral<"1">;
355
+ protocolVersion: z.ZodLiteral<"2">;
272
356
  action: z.ZodLiteral<"start">;
273
357
  daemon: z.ZodObject<{
274
358
  version: z.ZodString;
@@ -333,7 +417,7 @@ declare const PairStartResponse: z.ZodObject<{
333
417
  }, z.core.$strict>;
334
418
  type PairStartResponse = z.infer<typeof PairStartResponse>;
335
419
  declare const PairPollRequest: z.ZodObject<{
336
- protocolVersion: z.ZodLiteral<"1">;
420
+ protocolVersion: z.ZodLiteral<"2">;
337
421
  action: z.ZodLiteral<"poll">;
338
422
  deviceCode: z.ZodString;
339
423
  }, z.core.$strict>;
@@ -358,7 +442,7 @@ declare const PairPollResponse: z.ZodDiscriminatedUnion<[z.ZodObject<{
358
442
  }, z.core.$strict>], "status">;
359
443
  type PairPollResponse = z.infer<typeof PairPollResponse>;
360
444
  declare const PairRequest: z.ZodDiscriminatedUnion<[z.ZodObject<{
361
- protocolVersion: z.ZodLiteral<"1">;
445
+ protocolVersion: z.ZodLiteral<"2">;
362
446
  action: z.ZodLiteral<"start">;
363
447
  daemon: z.ZodObject<{
364
448
  version: z.ZodString;
@@ -413,13 +497,13 @@ declare const PairRequest: z.ZodDiscriminatedUnion<[z.ZodObject<{
413
497
  }>;
414
498
  }, z.core.$strict>>;
415
499
  }, z.core.$strict>, z.ZodObject<{
416
- protocolVersion: z.ZodLiteral<"1">;
500
+ protocolVersion: z.ZodLiteral<"2">;
417
501
  action: z.ZodLiteral<"poll">;
418
502
  deviceCode: z.ZodString;
419
503
  }, z.core.$strict>], "action">;
420
504
  type PairRequest = z.infer<typeof PairRequest>;
421
505
  declare const ClaimRequest: z.ZodObject<{
422
- protocolVersion: z.ZodLiteral<"1">;
506
+ protocolVersion: z.ZodLiteral<"2">;
423
507
  runnerId: z.ZodString;
424
508
  capabilities: z.ZodArray<z.ZodObject<{
425
509
  kind: z.ZodEnum<{
@@ -506,7 +590,7 @@ declare const ClaimResponse: z.ZodObject<{
506
590
  }, z.core.$strict>;
507
591
  type ClaimResponse = z.infer<typeof ClaimResponse>;
508
592
  declare const HeartbeatRequest: z.ZodObject<{
509
- protocolVersion: z.ZodLiteral<"1">;
593
+ protocolVersion: z.ZodLiteral<"2">;
510
594
  runnerId: z.ZodString;
511
595
  daemonVersion: z.ZodString;
512
596
  capabilities: z.ZodArray<z.ZodObject<{
@@ -564,7 +648,6 @@ declare const HeartbeatRequest: z.ZodObject<{
564
648
  jobId: z.ZodString;
565
649
  leaseId: z.ZodString;
566
650
  }, z.core.$strict>>;
567
- paused: z.ZodBoolean;
568
651
  }, z.core.$strict>;
569
652
  type HeartbeatRequest = z.infer<typeof HeartbeatRequest>;
570
653
  declare const HeartbeatResponse: z.ZodObject<{
@@ -616,7 +699,7 @@ declare const ResultDisposition: z.ZodEnum<{
616
699
  }>;
617
700
  type ResultDisposition = z.infer<typeof ResultDisposition>;
618
701
  declare const ResultRequest: z.ZodObject<{
619
- protocolVersion: z.ZodLiteral<"1">;
702
+ protocolVersion: z.ZodLiteral<"2">;
620
703
  runnerId: z.ZodString;
621
704
  jobId: z.ZodString;
622
705
  leaseId: z.ZodString;
@@ -644,7 +727,7 @@ declare const ResultResponse: z.ZodObject<{
644
727
  }, z.core.$strict>;
645
728
  type ResultResponse = z.infer<typeof ResultResponse>;
646
729
  declare const ReleaseRequest: z.ZodObject<{
647
- protocolVersion: z.ZodLiteral<"1">;
730
+ protocolVersion: z.ZodLiteral<"2">;
648
731
  runnerId: z.ZodString;
649
732
  leases: z.ZodArray<z.ZodObject<{
650
733
  jobId: z.ZodString;
@@ -713,7 +796,7 @@ type WireError = z.infer<typeof WireError>;
713
796
  /** HTTP status each error code is served with. */
714
797
  declare const ERROR_STATUS: Readonly<Record<WireErrorCode, number>>;
715
798
  declare const FetchRequest: z.ZodObject<{
716
- protocolVersion: z.ZodLiteral<"1">;
799
+ protocolVersion: z.ZodLiteral<"2">;
717
800
  runnerId: z.ZodString;
718
801
  jobId: z.ZodString;
719
802
  leaseId: z.ZodString;
@@ -1555,6 +1638,44 @@ declare const ClaimedJob: z.ZodObject<{
1555
1638
  }, z.core.$strict>;
1556
1639
  }, z.core.$strict>;
1557
1640
  type ClaimedJob = z.infer<typeof ClaimedJob>;
1641
+ /**
1642
+ * The closed set, as a schema — so the values exist once.
1643
+ *
1644
+ * A bare union would mean anything that has to VALIDATE a stop reason (the
1645
+ * ingress log, and the wire when step 4 lands) retyping the four strings
1646
+ * beside it. Instruction 9: one definition, both ends, and where a consumer
1647
+ * needs a runtime check the definition has to be one it can run.
1648
+ *
1649
+ * The type below is inferred from this rather than written twice, so the
1650
+ * compiler and the validator cannot disagree about what a stop reason is.
1651
+ */
1652
+ declare const StopReasonSchema: z.ZodEnum<{
1653
+ length: "length";
1654
+ unknown: "unknown";
1655
+ end: "end";
1656
+ "stop-sequence": "stop-sequence";
1657
+ }>;
1658
+ type StopReason =
1659
+ /** The model finished on its own. */
1660
+ "end"
1661
+ /** The model stopped at its own output ceiling. */
1662
+ | "length"
1663
+ /** A configured stop token ended it. */
1664
+ | "stop-sequence"
1665
+ /**
1666
+ * The adapter cannot tell, and says so.
1667
+ *
1668
+ * **The default, and never `"end"`.** An adapter nobody has updated — or
1669
+ * one somebody adds next year — must not be able to claim completion by
1670
+ * saying nothing. If absence meant "end", every un-updated adapter would go
1671
+ * on telling exactly the lie this exists to fix, and every new adapter
1672
+ * would inherit it in silence.
1673
+ *
1674
+ * It is the opposite-boolean rule this codebase keeps arriving at: when you
1675
+ * cannot tell, guess toward silence rather than toward a claim. "We do not
1676
+ * know" is a thing a site can act on; "it finished" when it did not is not.
1677
+ */
1678
+ | "unknown";
1558
1679
  /**
1559
1680
  * The provenance that travels with every result to the delivery seam.
1560
1681
  *
@@ -1575,6 +1696,13 @@ declare const ResultProvenance: z.ZodObject<{
1575
1696
  }>;
1576
1697
  model: z.ZodString;
1577
1698
  untrusted: z.ZodBoolean;
1699
+ stop: z.ZodOptional<z.ZodEnum<{
1700
+ length: "length";
1701
+ unknown: "unknown";
1702
+ end: "end";
1703
+ "stop-sequence": "stop-sequence";
1704
+ }>>;
1705
+ stopReported: z.ZodOptional<z.ZodBoolean>;
1578
1706
  }, z.core.$strict>;
1579
1707
  type ResultProvenance = z.infer<typeof ResultProvenance>;
1580
1708
  /**
@@ -1587,6 +1715,9 @@ declare function provenanceFor(input: {
1587
1715
  runnerOwner: string;
1588
1716
  backendClass: BackendClass;
1589
1717
  model: string;
1718
+ /** From the sealed `ran`; absent on a cancelled or errored job — B260. */
1719
+ stop?: StopReason | undefined;
1720
+ stopReported?: boolean | undefined;
1590
1721
  }): ResultProvenance;
1591
1722
  /**
1592
1723
  * What the daemon did, sealed with the answer — cloud_008 §2.5.
@@ -1603,44 +1734,6 @@ declare function provenanceFor(input: {
1603
1734
  * opens them, nothing in between sees them, and the disposition check that
1604
1735
  * already compares clear-text against ciphertext extends to cover them.
1605
1736
  */
1606
- /**
1607
- * The closed set, as a schema — so the values exist once.
1608
- *
1609
- * A bare union would mean anything that has to VALIDATE a stop reason (the
1610
- * ingress log, and the wire when step 4 lands) retyping the four strings
1611
- * beside it. Instruction 9: one definition, both ends, and where a consumer
1612
- * needs a runtime check the definition has to be one it can run.
1613
- *
1614
- * The type below is inferred from this rather than written twice, so the
1615
- * compiler and the validator cannot disagree about what a stop reason is.
1616
- */
1617
- declare const StopReasonSchema: z.ZodEnum<{
1618
- length: "length";
1619
- unknown: "unknown";
1620
- end: "end";
1621
- "stop-sequence": "stop-sequence";
1622
- }>;
1623
- type StopReason =
1624
- /** The model finished on its own. */
1625
- "end"
1626
- /** The model stopped at its own output ceiling. */
1627
- | "length"
1628
- /** A configured stop token ended it. */
1629
- | "stop-sequence"
1630
- /**
1631
- * The adapter cannot tell, and says so.
1632
- *
1633
- * **The default, and never `"end"`.** An adapter nobody has updated — or
1634
- * one somebody adds next year — must not be able to claim completion by
1635
- * saying nothing. If absence meant "end", every un-updated adapter would go
1636
- * on telling exactly the lie this exists to fix, and every new adapter
1637
- * would inherit it in silence.
1638
- *
1639
- * It is the opposite-boolean rule this codebase keeps arriving at: when you
1640
- * cannot tell, guess toward silence rather than toward a claim. "We do not
1641
- * know" is a thing a site can act on; "it finished" when it did not is not.
1642
- */
1643
- | "unknown";
1644
1737
  declare const RunMetadata: z.ZodObject<{
1645
1738
  model: z.ZodString;
1646
1739
  backendClass: z.ZodEnum<{
@@ -1840,6 +1933,13 @@ declare const DeliveredResult: z.ZodObject<{
1840
1933
  }>;
1841
1934
  model: z.ZodString;
1842
1935
  untrusted: z.ZodBoolean;
1936
+ stop: z.ZodOptional<z.ZodEnum<{
1937
+ length: "length";
1938
+ unknown: "unknown";
1939
+ end: "end";
1940
+ "stop-sequence": "stop-sequence";
1941
+ }>>;
1942
+ stopReported: z.ZodOptional<z.ZodBoolean>;
1843
1943
  }, z.core.$strict>>;
1844
1944
  fallback: z.ZodOptional<z.ZodLiteral<true>>;
1845
1945
  }, z.core.$strict>;
@@ -2281,6 +2381,74 @@ declare function verifyRequest(input: {
2281
2381
  * what a single-purpose site's one purpose actually is.
2282
2382
  */
2283
2383
  declare const RESERVED_PURPOSE = "default";
2384
+ /**
2385
+ * How a purpose's work is routed — RESERVED at 0.1.0, not yet acted on (B236).
2386
+ *
2387
+ * ## Why a key nothing reads is the highest-leverage thing in this file
2388
+ *
2389
+ * {@link Purpose} is `.strict()`, and that is right: a manifest is written by
2390
+ * hand by a third party, and a typo'd key that is silently ignored is a site
2391
+ * whose consent screen quietly says something other than what its author
2392
+ * wrote. The cost of `.strict()` is that **there is no such thing as an
2393
+ * additive change to it.** A key added in 1.4 is rejected by every validator
2394
+ * built before 1.4, and the OSS repository ships the server — so those
2395
+ * validators will exist, on machines nobody can upgrade, run by people who
2396
+ * have no idea a key was added.
2397
+ *
2398
+ * The window in which this field can be introduced is therefore now: before
2399
+ * the wire is declared stable, while every validator in existence is ours.
2400
+ * After that the shape is load-bearing whether or not anything reads it.
2401
+ *
2402
+ * So the values are the ruled ones (B232 house lanes, B233 fallback lanes),
2403
+ * the schema refuses anything else, and no code branches on it. A site may
2404
+ * write `routing` today and get exactly the behaviour it gets without it,
2405
+ * which is the point: the manifest it writes today is still valid the day
2406
+ * the lanes land.
2407
+ *
2408
+ * ## What each value will mean, when something reads it
2409
+ *
2410
+ * - `user-choice` — the person maps this purpose to one of their own
2411
+ * services, and that mapping is the consent. Today's only behaviour, and
2412
+ * the default for a manifest that says nothing.
2413
+ * - `site-fixed` — the site pays for and pins the service (B232's house
2414
+ * lane). The person is told, and consents to that rather than to a mapping.
2415
+ * - `user-first-with-fallback` — the person's service if they have one, the
2416
+ * site's if they do not (B233).
2417
+ *
2418
+ * **The commitment attached to those last two** is written in the lock
2419
+ * document rather than here, because it binds behaviour this file cannot
2420
+ * enforce: a hub that does not implement a lane treats the purpose as
2421
+ * `user-choice` and SAYS SO in a field rather than silently downgrading it,
2422
+ * and a lane added later carries its own disclosure and never weakens an
2423
+ * existing lane's promise.
2424
+ */
2425
+ declare const PurposeRouting: z.ZodEnum<{
2426
+ "user-choice": "user-choice";
2427
+ "site-fixed": "site-fixed";
2428
+ "user-first-with-fallback": "user-first-with-fallback";
2429
+ }>;
2430
+ type PurposeRouting = z.infer<typeof PurposeRouting>;
2431
+ /**
2432
+ * What a purpose that does not say means.
2433
+ *
2434
+ * Named once, here, rather than written into the schema as `.default()`. A
2435
+ * zod default is applied at PARSE, which would mean every manifest read by
2436
+ * anything becomes a manifest with a `routing` key — and a hub that parses a
2437
+ * site's manifest, stores it and serves it back would be handing a key to
2438
+ * readers that predate it. The thing this field exists to avoid, performed by
2439
+ * the field itself.
2440
+ *
2441
+ * Parsing stays shape-preserving; the default is applied where the value is
2442
+ * USED, by {@link routingOf}.
2443
+ */
2444
+ declare const DEFAULT_ROUTING: PurposeRouting;
2445
+ /**
2446
+ * The routing a purpose asks for, defaulted.
2447
+ *
2448
+ * The one place the absent case is answered, so that when B232 and B233 do
2449
+ * act on this there is no second opinion about what "not stated" meant.
2450
+ */
2451
+ declare function routingOf(purpose: Purpose): PurposeRouting;
2284
2452
  declare const Purpose: z.ZodObject<{
2285
2453
  label: z.ZodString;
2286
2454
  description: z.ZodOptional<z.ZodString>;
@@ -2288,6 +2456,11 @@ declare const Purpose: z.ZodObject<{
2288
2456
  "llm.generate": "llm.generate";
2289
2457
  "llm.chat": "llm.chat";
2290
2458
  }>>;
2459
+ routing: z.ZodOptional<z.ZodEnum<{
2460
+ "user-choice": "user-choice";
2461
+ "site-fixed": "site-fixed";
2462
+ "user-first-with-fallback": "user-first-with-fallback";
2463
+ }>>;
2291
2464
  }, z.core.$strict>;
2292
2465
  type Purpose = z.infer<typeof Purpose>;
2293
2466
  /**
@@ -2320,6 +2493,11 @@ declare const Manifest: z.ZodRecord<z.ZodString, z.ZodObject<{
2320
2493
  "llm.generate": "llm.generate";
2321
2494
  "llm.chat": "llm.chat";
2322
2495
  }>>;
2496
+ routing: z.ZodOptional<z.ZodEnum<{
2497
+ "user-choice": "user-choice";
2498
+ "site-fixed": "site-fixed";
2499
+ "user-first-with-fallback": "user-first-with-fallback";
2500
+ }>>;
2323
2501
  }, z.core.$strict>>;
2324
2502
  type Manifest = z.infer<typeof Manifest>;
2325
2503
  /**
@@ -2806,4 +2984,4 @@ declare const MUST_IDS: readonly ("PAIR_ONE_USER" | "PAIR_INTERACTIVE" | "PAIR_C
2806
2984
  /** Every MUST verified a particular way. */
2807
2985
  declare function mustsVerifiedBy(kind: MustVerification): MustId[];
2808
2986
 
2809
- export { ABOUT, ABOUT_SHORT, ABOUT_SHORT_LEDE, ABOUT_SHORT_TAIL, AUDIENCES, Audience, BACKENDS, BACKEND_CLASSES, BACKEND_IDS, BackendClass, BackendCost, type BackendDescriptor, type BackendId, BackendIdSchema, CLOCK_ATTRIBUTION_MS, CLOCK_SKEW_WARN_MS, Capability, CapabilityMatrix, ChatMessage, ChatPayload, ClaimRequest, ClaimResponse, ClaimedJob, ClaimedStub, DeliveredResult, ENDPOINTS, ERROR_STATUS, type Endpoint, FetchRequest, FetchResponse, type FloorRefusal, GRANT_CONTEXT, GRANT_MAX_AGE_MS, GRANT_SIGNED_FIELDS, GeneratePayload, type GrantClaims, GrantRef, type GrantRefusal, HeartbeatRequest, HeartbeatResponse, JOB_KINDS, JobKind, JobOutcome, JobPayload, JobRefused, JobResultCanceled, JobResultError, JobResultOk, JobState, JobStub, KindedPayload, Lease, MAX_CLOCK_SKEW_MS, MAX_ENVELOPE_BYTES, MAX_PURPOSES, MAX_SUCCESSION_CHAIN, MIN_PROTOCOL_VERSION, MUSTS, MUST_IDS, Manifest, type MatchDaemon, type MatchJob, MatchRefusal, type MatchResult, type Must, type MustEnforcer, type MustId, type MustVerification, type MustVerifiedBy, OFFER_SCOPES, OfferScope, PAYLOAD_LIMITS, PROTOCOL_PREFIX, PROTOCOL_VERSION, PairPollRequest, PairPollResponse, PairRequest, PairStartRequest, PairStartResponse, type PayloadFor, PublicIdentity, Purpose, REFUSAL_MESSAGES, REFUSAL_TEXT, RESERVED_PURPOSE, RETIREMENT_WINDOW_MS, RefusalReason, ReleaseRequest, ReleaseResponse, RequestSignature, ResultDisposition, ResultProvenance, ResultRequest, ResultResponse, RunMetadata, SIZE_CLASSES, SIZE_CLASS_LIMITS, SUCCESSION_CONTEXT, SUPPORTED_PROTOCOL_VERSIONS, SealedOutcome, type SignatureFailure, SignedGrant, SizeClass, type SpendConsent, type StopReason, StopReasonSchema, StoredKeys, Succession, type SuccessionFailure, type SuccessionWalk, TERMINAL_STATES, UPDATE_OFFER_SINCE, UPGRADE_COMMAND, type VersionRefusal, WireError, WireErrorCode, WithheldKind, backendDescriptor, backendName, canTransition, canonicalRequest, checkDaemonFloor, checkProtocolVersion, classifyCost, compareVersions, declaredVersion, describeBytes, effectiveOfferScope, envelopeBytes, grantStatement, isBackendId, isCloudTaggedModel, isJobKind, isLocalHost, isTerminal, kindsOf, matchAudience, mayOfferUpdate, mentionsWireField, mustsVerifiedBy, payloadTextLength, provenanceFor, resolveCost, signGrant, signRequest, signSiteRequest, signSuccession, singlePurposeManifest, sizeClassCeiling, sizeClassOf, successionStatement, tooLargeMessage, updateOfferFor, verifyGrant, verifyLink, verifyRequest, verifySiteRequest, walkSuccession, withoutComments };
2987
+ export { ABOUT, ABOUT_SHORT, ABOUT_SHORT_LEDE, ABOUT_SHORT_TAIL, AUDIENCES, Audience, BACKENDS, BACKEND_CLASSES, BACKEND_IDS, BackendClass, BackendCost, type BackendDescriptor, type BackendId, BackendIdSchema, CLOCK_ATTRIBUTION_MS, CLOCK_SKEW_WARN_MS, Capability, CapabilityMatrix, ChatMessage, ChatPayload, ClaimRequest, ClaimResponse, ClaimedJob, ClaimedStub, DEFAULT_ROUTING, DeliveredResult, ENDPOINTS, ERROR_STATUS, type Endpoint, type FenceClause, FetchRequest, FetchResponse, type FloorRefusal, GRANT_CONTEXT, GRANT_MAX_AGE_MS, GRANT_SIGNED_FIELDS, GeneratePayload, type GrantClaims, GrantRef, type GrantRefusal, HUB_FENCE, HUB_FENCE_CLAUSES, HeartbeatRequest, HeartbeatResponse, JOB_KINDS, JobKind, JobOutcome, JobPayload, JobRefused, JobResultCanceled, JobResultError, JobResultOk, JobState, JobStub, KindedPayload, Lease, MAX_CLOCK_SKEW_MS, MAX_ENVELOPE_BYTES, MAX_PURPOSES, MAX_SUCCESSION_CHAIN, MIN_PROTOCOL_VERSION, MUSTS, MUST_IDS, Manifest, type MatchDaemon, type MatchJob, MatchRefusal, type MatchResult, type Must, type MustEnforcer, type MustId, type MustVerification, type MustVerifiedBy, OFFER_SCOPES, OfferScope, PAYLOAD_LIMITS, PROTOCOL_PREFIX, PROTOCOL_VERSION, PairPollRequest, PairPollResponse, PairRequest, PairStartRequest, PairStartResponse, type PayloadFor, PublicIdentity, Purpose, PurposeRouting, REFUSAL_MESSAGES, REFUSAL_TEXT, RESERVED_PURPOSE, RETIREMENT_WINDOW_MS, RefusalReason, ReleaseRequest, ReleaseResponse, RequestSignature, ResultDisposition, ResultProvenance, ResultRequest, ResultResponse, RunMetadata, SIZE_CLASSES, SIZE_CLASS_LIMITS, SUCCESSION_CONTEXT, SUPPORTED_PROTOCOL_VERSIONS, SealedOutcome, type SignatureFailure, SignedGrant, SizeClass, type SpendConsent, type StopReason, StopReasonSchema, StoredKeys, Succession, type SuccessionFailure, type SuccessionWalk, TERMINAL_STATES, UPDATE_OFFER_SINCE, UPGRADE_COMMAND, type VersionRefusal, WireError, WireErrorCode, WithheldKind, backendDescriptor, backendName, canTransition, canonicalRequest, checkDaemonFloor, checkProtocolVersion, classifyCost, compareVersions, declaredVersion, describeBytes, effectiveOfferScope, envelopeBytes, grantStatement, isBackendId, isCloudTaggedModel, isJobKind, isLocalHost, isTerminal, kindsOf, matchAudience, mayOfferUpdate, mentionsWireField, mustsVerifiedBy, payloadTextLength, provenanceFor, resolveCost, routingOf, signGrant, signRequest, signSiteRequest, signSuccession, singlePurposeManifest, sizeClassCeiling, sizeClassOf, successionStatement, tooLargeMessage, updateOfferFor, verifyGrant, verifyLink, verifyRequest, verifySiteRequest, walkSuccession, withoutComments };