@byollm/protocol 0.1.0-alpha.1 → 0.1.0-alpha.100

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.d.ts CHANGED
@@ -1,771 +1,462 @@
1
1
  import { z } from 'zod';
2
+ import { S as StoredKeys, P as PublicIdentity } from './portable-C6rfiCXi.js';
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';
2
4
 
3
5
  /**
4
- * How a backend reaches its model the taxonomy introduced in byollm_001
5
- * Rev 1 §A, because the two classes have different threat surfaces.
6
+ * Protocol version carried on every request; servers refuse what they can't
7
+ * speak.
6
8
  *
7
- * - `http`: an OpenAI-compatible HTTP server (Ollama, `mlx_lm.server`,
8
- * llama.cpp server, vLLM). Spawns nothing, so byollm_004 §2's argv, stdin,
9
- * env and sandbox requirements are not applicable by construction. Its
10
- * threat surface is SSRF-shaped and bounded by {@link MUSTS.HTTP_BASE_URL_SAFE}.
11
- * - `process`: spawns a binary (`claude` CLI today, `mlx_lm.lora` for a
12
- * future `train.*` kind). All of byollm_004 §2 is mandatory here.
13
- */
14
- declare const BackendClass: z.ZodEnum<{
15
- http: "http";
16
- process: "process";
17
- }>;
18
- type BackendClass = z.infer<typeof BackendClass>;
19
- /**
20
- * Whose account pays for the inference.
9
+ * **`1` because byollm_016 changed the vocabulary** — byollm-review
10
+ * 2026-08-27. `OfferScope` lost `public`, `self|named` became
11
+ * `private|team`, `JobStub` lost `service` and gained `purpose`, and the
12
+ * grant's site field changed namespace. The version stayed `0` through all of
13
+ * it.
21
14
  *
22
- * `subscription` backends run against a vendor account belonging to the
23
- * machine's owner. They are hard-locked to an offer scope of `self`
24
- * ({@link MUSTS.SUBSCRIPTION_SELF_LOCK}) one account executes one person's
25
- * work. This is orthogonal to {@link BackendClass}: `claude-cli` is both
26
- * process-class and subscription-class, while a future local `mlx_lm.lora`
27
- * backend would be process-class and open.
28
- */
29
- declare const BackendAccount: z.ZodEnum<{
30
- open: "open";
31
- subscription: "subscription";
32
- }>;
33
- type BackendAccount = z.infer<typeof BackendAccount>;
34
- /** The immutable facts about a backend that the protocol reasons over. */
35
- interface BackendDescriptor {
36
- /** Stable backend id, as written in `byollm.config.json`. */
37
- readonly id: string;
38
- /** Human-readable name for the trust UI. */
39
- readonly label: string;
40
- /** Determines which isolation requirements apply. */
41
- readonly class: BackendClass;
42
- /** Determines whether the offer scope can be widened past `self`. */
43
- readonly account: BackendAccount;
44
- /**
45
- * Which adversarial corpus byollm_004 §5 runs against this backend. A
46
- * backend cannot be registered without one — the coverage check in the
47
- * adversarial suite enforces it.
48
- */
49
- readonly adversarialCorpus: "process" | "http";
50
- }
51
- /**
52
- * The v1 backend registry.
15
+ * The consequence was the failure the handshake exists to prevent, arriving
16
+ * around it: a pre-rip daemon declares `0`, passes the version check, and
17
+ * then fails whole-body schema validation with "request failed schema
18
+ * validation" no field named, no vocabulary named, no upgrade command. Once
19
+ * every ten seconds, forever, while its owner watches a device go stale for
20
+ * no stated reason. The check below was written because "a mismatch surfaced
21
+ * as a generic bad-request" and "an error a user cannot act on is barely
22
+ * better than a hang"; the number not moving is how that came back.
53
23
  *
54
- * byollm_001 Rev 1 §A collapses four planned backends into one HTTP-class
55
- * entry: Ollama, `mlx_lm.server`, llama.cpp server and vLLM all speak
56
- * OpenAI-compatible `/v1/chat/completions`, so they are one backend with N
57
- * owner-configured base URLs rather than four adapters. That is what puts
58
- * MLX inference in v1.
24
+ * A registry is a schema and an enum value is the contract — this project's
25
+ * own words, from the release that silenced a fleet by adding a backend id.
26
+ * The same sentence applies to removing an offer scope.
59
27
  */
60
- declare const BACKENDS: Readonly<{
61
- readonly "openai-http": BackendDescriptor;
62
- readonly "claude-cli": BackendDescriptor;
63
- }>;
64
- /** The id of a registered backend. */
65
- type BackendId = keyof typeof BACKENDS;
66
- /** All registered backend ids — the adversarial coverage check iterates this. */
67
- declare const BACKEND_IDS: readonly ("openai-http" | "claude-cli")[];
68
- declare const BackendIdSchema: z.ZodEnum<{
69
- "openai-http": "openai-http";
70
- "claude-cli": "claude-cli";
71
- }>;
72
- /** Narrow an arbitrary string to a registered backend id. */
73
- declare function isBackendId(value: string): value is BackendId;
28
+ declare const PROTOCOL_VERSION: "1";
74
29
  /**
75
- * Look up a backend descriptor.
30
+ * Every protocol version this build can serve, **oldest first**.
76
31
  *
77
- * @throws if the id is not registered an unregistered backend has no
78
- * adversarial corpus, so refusing is the safe direction.
32
+ * One entry today. It is a list rather than a constant because the shape of
33
+ * the check is the point: a server supporting two versions through a
34
+ * migration should not need a different code path from one supporting one.
79
35
  */
80
- declare function backendDescriptor(id: BackendId): BackendDescriptor;
81
-
82
36
  /**
83
- * Who may run a job, declared by the app that enqueued it.
37
+ * `0` is deliberately **not** here, though the list exists for exactly that.
84
38
  *
85
- * - `self` only the job owner's own daemon.
86
- * - `named` a daemon whose owner has explicitly allowed this (server, user)
87
- * pair in their *local* allowlist (byollm_001 Rev 1 §B).
88
- * - `public`any daemon offering `public` compute.
89
- */
90
- declare const Audience: z.ZodEnum<{
91
- self: "self";
92
- named: "named";
93
- public: "public";
94
- }>;
95
- type Audience = z.infer<typeof Audience>;
96
- /**
97
- * What a daemon backend is willing to run, declared by the machine's owner.
98
- * Same three values as {@link Audience}, but the two are independent axes —
99
- * a job runs only where both agree ({@link MUSTS.AUDIENCE_BOTH_SIDES}).
39
+ * Supporting two versions through a migration is the shape this was built
40
+ * for, and it is the wrong tool when the vocabularies are incompatible: a `0`
41
+ * daemon sends `offer: "public"` and a `service` on its stubs, so accepting
42
+ * its version only moves the refusal one layer down to the schema error
43
+ * that names nothing, which is the bug. Refusing the version is the whole
44
+ * point, because that refusal says what to do.
100
45
  */
101
- declare const OfferScope: z.ZodEnum<{
102
- self: "self";
103
- named: "named";
104
- public: "public";
105
- }>;
106
- type OfferScope = z.infer<typeof OfferScope>;
107
- /** All audience values, in widening order. */
108
- declare const AUDIENCES: readonly ("self" | "named" | "public")[];
109
- /** All offer scopes, in widening order. */
110
- declare const OFFER_SCOPES: readonly ("self" | "named" | "public")[];
46
+ declare const SUPPORTED_PROTOCOL_VERSIONS: readonly string[];
111
47
  /**
112
- * Why a job was refused. Distinct codes because byollm_002 requires that
113
- * different truths never share a message — "no matching work" and "refused on
114
- * principle" are not the same event, and a volunteer debugging their setup
115
- * needs to know which one happened.
48
+ * The oldest version this build will talk to derived, not declared.
49
+ *
50
+ * Stating it separately would be a second thing to keep in step with the list
51
+ * above, and the failure would be silent: a minimum that no longer matches
52
+ * what is supported produces a refusal naming a version the server would in
53
+ * fact have accepted.
116
54
  */
117
- declare const MatchRefusal: z.ZodEnum<{
118
- "no-capability": "no-capability";
119
- "audience-self-other-owner": "audience-self-other-owner";
120
- "not-locally-allowed": "not-locally-allowed";
121
- "not-in-server-allowlist": "not-in-server-allowlist";
122
- "offer-scope-too-narrow": "offer-scope-too-narrow";
123
- "subscription-self-lock": "subscription-self-lock";
124
- }>;
125
- type MatchRefusal = z.infer<typeof MatchRefusal>;
126
- /** The outcome of an audience match. */
127
- type MatchResult = {
128
- readonly ok: true;
129
- } | {
130
- readonly ok: false;
131
- readonly refusal: MatchRefusal;
132
- };
55
+ declare const MIN_PROTOCOL_VERSION: string;
56
+ /** A structured refusal, so a daemon can say something useful to its owner. */
57
+ interface VersionRefusal {
58
+ readonly error: "unsupported-protocol-version";
59
+ readonly message: string;
60
+ readonly supported: readonly string[];
61
+ readonly minimum: string;
62
+ }
133
63
  /**
134
- * The effective offer scope of a backend.
64
+ * The version a request declares, wherever it carries it.
65
+ *
66
+ * A POST declares it in its body, which is where every request schema has
67
+ * always put it. A GET has no body, and the relay has one — the site plane's
68
+ * `pending` read — so it declares it in the query string instead.
135
69
  *
136
- * A subscription-class backend is locked to `self` regardless of what config
137
- * requests ({@link MUSTS.SUBSCRIPTION_SELF_LOCK}). This is a protocol MUST,
138
- * not a setting: the lock is applied here, at the one place both the daemon's
139
- * config loader and its matcher call, so there is no code path that observes
140
- * a widened subscription scope.
70
+ * **Two carriers, one rule.** That asymmetry is HTTP's rather than ours, and
71
+ * the alternative was worse in both directions: a header for everything would
72
+ * change every existing daemon's request, and skipping GETs would leave an
73
+ * endpoint outside the handshake which is precisely the shape B.4 found,
74
+ * where a whole plane was outside it.
141
75
  */
142
- declare function effectiveOfferScope(configured: OfferScope, account: BackendAccount): OfferScope;
143
- /** The job-side facts a match needs. */
144
- interface MatchJob {
145
- /** The app's id for the user who enqueued the job. */
146
- readonly owner: string;
147
- /** Who the app says may run it. */
148
- readonly audience: Audience;
149
- /**
150
- * Optional server-side restriction on which runner owners may take a
151
- * `named` job. Defence in depth only — the daemon's local allowlist is the
152
- * enforcing side ({@link MUSTS.NAMED_LOCAL_ALLOWLIST}).
153
- */
154
- readonly audienceAllow?: readonly string[] | undefined;
155
- }
156
- /** The daemon-side facts a match needs. */
157
- interface MatchDaemon {
158
- /** The app's id for the user this daemon is paired to. */
159
- readonly owner: string;
160
- /** Effective scope of the backend that would run the job. */
161
- readonly offerScope: OfferScope;
162
- /** Account class of that backend. */
163
- readonly account: BackendAccount;
164
- /**
165
- * Does this daemon's *local* allowlist admit the given owner for the server
166
- * origin the job came from? Supplied as a predicate so the protocol package
167
- * stays free of file I/O; the daemon passes its allowlist, the server
168
- * passes a conservative `() => true` because it cannot know a remote
169
- * daemon's local list and must not pretend to.
170
- */
171
- readonly locallyAllows: (owner: string) => boolean;
172
- }
76
+ declare function declaredVersion(input: {
77
+ body?: unknown;
78
+ query?: URLSearchParams;
79
+ }): unknown;
173
80
  /**
174
- * Decide whether a job may run on a daemon.
81
+ * Check the protocol version on an incoming request
82
+ * ({@link MUSTS.VERSION_HANDSHAKE_REQUIRED}).
175
83
  *
176
- * Both sides must agree ({@link MUSTS.AUDIENCE_BOTH_SIDES}):
177
- * 1. the job's audience must admit the daemon's owner, and
178
- * 2. the backend's offer scope must admit the job's owner.
84
+ * Returns a refusal, or `null` to proceed.
179
85
  *
180
- * The full nine-way matrix (three audiences × three offer scopes) is asserted
181
- * by the conformance kit. The function is pure and total so both the daemon
182
- * and the server can run the identical rule the daemon refuses, and the
183
- * server refuses too (byollm_003 §Server-side MUSTs).
86
+ * **A missing version is refused the same way a wrong one is.** That is the
87
+ * half worth stating: before this existed, the version travelled as a
88
+ * `z.literal` inside each endpoint's schema, so a mismatch surfaced as a
89
+ * generic `bad-request` — a daemon and a server discovered they disagreed by
90
+ * failing, with nothing in the response naming the disagreement. An error a
91
+ * user cannot act on is barely better than a hang.
184
92
  *
185
- * @example
186
- * ```ts
187
- * const result = matchAudience(
188
- * { owner: "alice", audience: "named" },
189
- * {
190
- * owner: "bob",
191
- * offerScope: "named",
192
- * account: "open",
193
- * locallyAllows: (o) => o === "alice",
194
- * },
195
- * );
196
- * // result.ok === true
197
- * ```
93
+ * The message names the fix, because the person reading it is usually the one
94
+ * who has to apply it.
198
95
  */
199
- declare function matchAudience(job: MatchJob, daemon: MatchDaemon): MatchResult;
96
+ declare function checkProtocolVersion(body: unknown): VersionRefusal | null;
200
97
  /**
201
- * Human-readable refusal text for the daemon's log and the trust UI.
202
- * Each refusal reads as a distinct truth — byollm_002's "four different
203
- * truths that must never share a message" applied to the audience axis.
98
+ * How to upgrade a daemon, in one place.
99
+ *
100
+ * `@latest`, which is correct in both eras and therefore never has to be
101
+ * revisited: during a prerelease it resolves to the current alpha, and after
102
+ * one it resolves to the current stable.
103
+ *
104
+ * `@alpha` was considered and rejected. The argument for it was that `latest`
105
+ * is moved by hand — it needs a human with 2FA, deliberately — so it can lag
106
+ * the `alpha` tag. In practice that lag has been minutes, and the cost on the
107
+ * other side is permanent: the day this stops being a prerelease, `@alpha`
108
+ * starts meaning "the unstable one", and every user who followed this message
109
+ * is pinned to prereleases with nothing to tell them.
110
+ *
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.
204
116
  */
205
- declare const REFUSAL_MESSAGES: Readonly<Record<MatchRefusal, string>>;
206
-
117
+ declare const UPGRADE_COMMAND: "npm i -g byollm@latest";
118
+ /** The path prefix all endpoints mount under. */
119
+ declare const PROTOCOL_PREFIX: "/byollm";
207
120
  /**
208
- * Upper bounds on payload size, enforced at the schema so oversized input is
209
- * refused at parse time rather than somewhere deeper.
121
+ * The endpoint names, in the order byollm_001 lists them, plus `fetch`.
210
122
  *
211
- * byollm_004 §4 requires stricter limits for community (`named`/`public`)
212
- * jobs; those are applied on top of these by the daemon's budget check, which
213
- * knows the job's audience. These are the absolute ceilings for any job.
123
+ * `fetch` is byollm_009 §6's second phase: a claim returns a stub, and the
124
+ * payload is collected separately by the device that took it. Two steps
125
+ * rather than one because a payload can only be sealed once its recipient is
126
+ * known — which is also what makes multi-device free.
214
127
  */
215
- declare const PAYLOAD_LIMITS: Readonly<{
216
- /** Max characters in any single text field. */
217
- maxTextChars: 1000000;
218
- /** Max messages in an `llm.chat` conversation. */
219
- maxMessages: 256;
220
- /** Max characters across the whole payload. */
221
- maxTotalChars: 4000000;
222
- }>;
128
+ declare const ENDPOINTS: readonly ["pair", "claim", "fetch", "heartbeat", "result", "release"];
129
+ type Endpoint = (typeof ENDPOINTS)[number];
223
130
  /**
224
- * A conversation turn. `role` is a closed enum it is routing *within the
225
- * model call*, not routing of the call, so it cannot select a backend.
131
+ * One entry of the capability matrix: a kind this daemon can actually serve,
132
+ * right now, with the backend and model that would serve it.
133
+ *
134
+ * Derived from owner config intersected with detected reality
135
+ * ({@link MUSTS.CAPABILITY_IS_DETECTED}) — a configured-but-unreachable
136
+ * backend must not appear here. Carries `backendClass` so the app can tell
137
+ * whether a result came from a sandboxed spawn or an HTTP call
138
+ * (byollm_001 Rev 1 §A).
226
139
  */
227
- declare const ChatMessage: z.ZodObject<{
228
- role: z.ZodEnum<{
229
- system: "system";
230
- user: "user";
231
- assistant: "assistant";
140
+ declare const Capability: z.ZodObject<{
141
+ kind: z.ZodEnum<{
142
+ "llm.generate": "llm.generate";
143
+ "llm.chat": "llm.chat";
232
144
  }>;
233
- content: z.ZodString;
234
- }, z.core.$strip>;
235
- type ChatMessage = z.infer<typeof ChatMessage>;
145
+ service: z.ZodString;
146
+ backendId: z.ZodEnum<{
147
+ ollama: "ollama";
148
+ mlx: "mlx";
149
+ llamacpp: "llamacpp";
150
+ vllm: "vllm";
151
+ lmstudio: "lmstudio";
152
+ jan: "jan";
153
+ localai: "localai";
154
+ anthropic: "anthropic";
155
+ openai: "openai";
156
+ gemini: "gemini";
157
+ grok: "grok";
158
+ groq: "groq";
159
+ openrouter: "openrouter";
160
+ together: "together";
161
+ deepseek: "deepseek";
162
+ mistral: "mistral";
163
+ "openai-http": "openai-http";
164
+ "claude-cli": "claude-cli";
165
+ "codex-cli": "codex-cli";
166
+ }>;
167
+ backendClass: z.ZodEnum<{
168
+ http: "http";
169
+ process: "process";
170
+ }>;
171
+ model: z.ZodString;
172
+ knownModels: z.ZodOptional<z.ZodArray<z.ZodString>>;
173
+ offerScope: z.ZodEnum<{
174
+ private: "private";
175
+ team: "team";
176
+ }>;
177
+ }, z.core.$strict>;
178
+ type Capability = z.infer<typeof Capability>;
179
+ /** The capability matrix a daemon advertises. */
180
+ declare const CapabilityMatrix: z.ZodArray<z.ZodObject<{
181
+ kind: z.ZodEnum<{
182
+ "llm.generate": "llm.generate";
183
+ "llm.chat": "llm.chat";
184
+ }>;
185
+ service: z.ZodString;
186
+ backendId: z.ZodEnum<{
187
+ ollama: "ollama";
188
+ mlx: "mlx";
189
+ llamacpp: "llamacpp";
190
+ vllm: "vllm";
191
+ lmstudio: "lmstudio";
192
+ jan: "jan";
193
+ localai: "localai";
194
+ anthropic: "anthropic";
195
+ openai: "openai";
196
+ gemini: "gemini";
197
+ grok: "grok";
198
+ groq: "groq";
199
+ openrouter: "openrouter";
200
+ together: "together";
201
+ deepseek: "deepseek";
202
+ mistral: "mistral";
203
+ "openai-http": "openai-http";
204
+ "claude-cli": "claude-cli";
205
+ "codex-cli": "codex-cli";
206
+ }>;
207
+ backendClass: z.ZodEnum<{
208
+ http: "http";
209
+ process: "process";
210
+ }>;
211
+ model: z.ZodString;
212
+ knownModels: z.ZodOptional<z.ZodArray<z.ZodString>>;
213
+ offerScope: z.ZodEnum<{
214
+ private: "private";
215
+ team: "team";
216
+ }>;
217
+ }, z.core.$strict>>;
218
+ type CapabilityMatrix = z.infer<typeof CapabilityMatrix>;
236
219
  /**
237
- * Payload for `llm.generate`.
220
+ * A kind this device could serve and deliberately does not — byollm_016.
238
221
  *
239
- * @remarks
240
- * Text only, deliberately. byollm_004 §1 states the payload is "data handed
241
- * to a model, never configuration and never a command", so v0 carries no
242
- * sampling parameters, no model name, no base URL and no flags — those are
243
- * owner-side route config. A future `params` field with an explicit closed
244
- * allowlist and owner-set clamps is reserved; adding a field later is
245
- * non-breaking, removing one is not.
222
+ * Two services answer one kind and the owner has not said which wins, so the
223
+ * kind is not advertised. That is correct and, unsaid, invisible: the owner
224
+ * adds a second service, jobs stop matching, and no surface explains it.
225
+ *
226
+ * It travels because the surfaces that must say so are not all on the device.
227
+ * The owner's card names the claimants; a teammate's card says only that the
228
+ * owner has a choice to make. Claimant **offer scopes** ride along so the hub
229
+ * can compute that difference without the device deciding who is asking —
230
+ * carry for computation, filter for display, the same shape the effective
231
+ * offer already uses.
246
232
  */
247
- declare const GeneratePayload: z.ZodObject<{
248
- prompt: z.ZodString;
249
- system: z.ZodOptional<z.ZodString>;
250
- }, z.core.$strict>;
251
- type GeneratePayload = z.infer<typeof GeneratePayload>;
252
- /** Payload for `llm.chat`. Text only, for the same reason as {@link GeneratePayload}. */
253
- declare const ChatPayload: z.ZodObject<{
254
- messages: z.ZodArray<z.ZodObject<{
255
- role: z.ZodEnum<{
256
- system: "system";
257
- user: "user";
258
- assistant: "assistant";
233
+ declare const WithheldKind: z.ZodObject<{
234
+ kind: z.ZodEnum<{
235
+ "llm.generate": "llm.generate";
236
+ "llm.chat": "llm.chat";
237
+ }>;
238
+ claimants: z.ZodArray<z.ZodObject<{
239
+ service: z.ZodString;
240
+ offer: z.ZodEnum<{
241
+ private: "private";
242
+ team: "team";
259
243
  }>;
260
- content: z.ZodString;
261
- }, z.core.$strip>>;
262
- system: z.ZodOptional<z.ZodString>;
244
+ }, z.core.$strict>>;
263
245
  }, z.core.$strict>;
264
- type ChatPayload = z.infer<typeof ChatPayload>;
246
+ type WithheldKind = z.infer<typeof WithheldKind>;
265
247
  /**
266
- * The job kinds a v1 daemon has handlers for.
248
+ * One grant, named by both halves V1-3.
267
249
  *
268
- * Kinds are resolved against handlers baked into the daemon
269
- * ({@link MUSTS.KIND_TYPED_ONLY}); an unknown kind is refused, never guessed.
270
- * Adding a kind is a protocol change with its own spec and threat review —
271
- * notably any kind that needs tools, which byollm_004 §2 forbids as a payload
272
- * flag.
250
+ * A job id is chosen per site, so the lease id is the unique thing an upstream
251
+ * and a daemon can both point at. Anywhere a request says "this piece of work,
252
+ * held by me", it says it with both.
253
+ *
254
+ * Declared once because it was written out twice — `activeLeases` and
255
+ * `ReleaseRequest.leases` — and both needed the same `.strict()` added. Two
256
+ * copies of a shape are two places to forget it.
273
257
  */
274
- declare const JobKind: z.ZodEnum<{
275
- "llm.generate": "llm.generate";
276
- "llm.chat": "llm.chat";
277
- }>;
278
- type JobKind = z.infer<typeof JobKind>;
279
- /** All v1 job kinds. */
280
- declare const JOB_KINDS: readonly ("llm.generate" | "llm.chat")[];
281
- /** A payload discriminated by its kind. */
282
- declare const KindedPayload: z.ZodDiscriminatedUnion<[z.ZodObject<{
283
- kind: z.ZodLiteral<"llm.generate">;
284
- payload: z.ZodObject<{
285
- prompt: z.ZodString;
286
- system: z.ZodOptional<z.ZodString>;
287
- }, z.core.$strict>;
288
- }, z.core.$strip>, z.ZodObject<{
289
- kind: z.ZodLiteral<"llm.chat">;
290
- payload: z.ZodObject<{
291
- messages: z.ZodArray<z.ZodObject<{
292
- role: z.ZodEnum<{
293
- system: "system";
294
- user: "user";
295
- assistant: "assistant";
296
- }>;
297
- content: z.ZodString;
298
- }, z.core.$strip>>;
299
- system: z.ZodOptional<z.ZodString>;
300
- }, z.core.$strict>;
301
- }, z.core.$strip>], "kind">;
302
- type KindedPayload = z.infer<typeof KindedPayload>;
303
- /** The payload type for a given kind. */
304
- type PayloadFor<K extends JobKind> = K extends "llm.generate" ? GeneratePayload : ChatPayload;
305
- /** Narrow an arbitrary string to a known job kind. */
306
- declare function isJobKind(value: string): value is JobKind;
307
- /**
308
- * Total character weight of a payload, used by the daemon's community budget
309
- * check and by the server's payload-size limits.
310
- */
311
- declare function payloadTextLength(kinded: KindedPayload): number;
312
-
313
- /**
314
- * The job lifecycle, made explicit by byollm_001 Rev 1 §D because the most
315
- * user-visible failure mode — "nothing is running my job" — was previously
316
- * unspecified.
317
- *
318
- * ```text
319
- * queued ──claim──▶ claimed ──start──▶ running ──▶ ok | error | canceled
320
- * │ │ │
321
- * │ └──lease expiry─────┘
322
- * │ ▼
323
- * │ queued (reclaimable, no loss)
324
- * └──ttl elapsed──▶ expired
325
- * ```
326
- */
327
- declare const JobState: z.ZodEnum<{
328
- ok: "ok";
329
- error: "error";
330
- queued: "queued";
331
- claimed: "claimed";
332
- running: "running";
333
- canceled: "canceled";
334
- expired: "expired";
335
- }>;
336
- type JobState = z.infer<typeof JobState>;
337
- /** States from which a job never moves again. */
338
- declare const TERMINAL_STATES: readonly ["ok", "error", "canceled", "expired"];
339
- /** Is this a state the job can never leave? */
340
- declare function isTerminal(state: JobState): boolean;
341
- /** May a job move from `from` to `to`? */
342
- declare function canTransition(from: JobState, to: JobState): boolean;
343
- /** A lease: the right to work on a job until `expiresAt`. */
344
- declare const Lease: z.ZodObject<{
345
- runnerId: z.ZodString;
346
- expiresAt: z.ZodNumber;
347
- }, z.core.$strip>;
348
- type Lease = z.infer<typeof Lease>;
349
- /** Payload union as it appears on a job record. */
350
- declare const JobPayload: z.ZodUnion<readonly [z.ZodObject<{
351
- prompt: z.ZodString;
352
- system: z.ZodOptional<z.ZodString>;
353
- }, z.core.$strict>, z.ZodObject<{
354
- messages: z.ZodArray<z.ZodObject<{
355
- role: z.ZodEnum<{
356
- system: "system";
357
- user: "user";
358
- assistant: "assistant";
359
- }>;
360
- content: z.ZodString;
361
- }, z.core.$strip>>;
362
- system: z.ZodOptional<z.ZodString>;
363
- }, z.core.$strict>]>;
364
- type JobPayload = z.infer<typeof JobPayload>;
365
- /**
366
- * A job as the daemon receives it from `/byollm/claim`.
367
- *
368
- * Note what is absent: no model, no backend, no base URL, no flags, no path.
369
- * Those come from the machine owner's config only
370
- * ({@link MUSTS.NO_PAYLOAD_ROUTING}). The wire shape is the first place that
371
- * rule is enforced — there is no field to carry them.
372
- */
373
- declare const ClaimedJob: z.ZodObject<{
374
- id: z.ZodString;
375
- kind: z.ZodEnum<{
376
- "llm.generate": "llm.generate";
377
- "llm.chat": "llm.chat";
378
- }>;
379
- payload: z.ZodUnion<readonly [z.ZodObject<{
380
- prompt: z.ZodString;
381
- system: z.ZodOptional<z.ZodString>;
382
- }, z.core.$strict>, z.ZodObject<{
383
- messages: z.ZodArray<z.ZodObject<{
384
- role: z.ZodEnum<{
385
- system: "system";
386
- user: "user";
387
- assistant: "assistant";
388
- }>;
389
- content: z.ZodString;
390
- }, z.core.$strip>>;
391
- system: z.ZodOptional<z.ZodString>;
392
- }, z.core.$strict>]>;
393
- audience: z.ZodEnum<{
394
- self: "self";
395
- named: "named";
396
- public: "public";
397
- }>;
398
- owner: z.ZodString;
399
- audienceAllow: z.ZodOptional<z.ZodArray<z.ZodString>>;
400
- lease: z.ZodObject<{
401
- runnerId: z.ZodString;
402
- expiresAt: z.ZodNumber;
403
- }, z.core.$strip>;
404
- }, z.core.$strict>;
405
- type ClaimedJob = z.infer<typeof ClaimedJob>;
406
- /**
407
- * The provenance that travels with every result to the delivery seam.
408
- *
409
- * byollm_003 Rev 1: a `named`/`public` result is attacker-controlled text.
410
- * The app must never render volunteer output as its own AI's answer without
411
- * knowing that is what it is ({@link MUSTS.RESULT_PROVENANCE}).
412
- */
413
- declare const ResultProvenance: z.ZodObject<{
414
- audience: z.ZodEnum<{
415
- self: "self";
416
- named: "named";
417
- public: "public";
418
- }>;
419
- runnerId: z.ZodString;
420
- runnerOwner: z.ZodString;
421
- backendClass: z.ZodEnum<{
422
- http: "http";
423
- process: "process";
424
- }>;
425
- model: z.ZodString;
426
- untrusted: z.ZodBoolean;
258
+ declare const GrantRef: z.ZodObject<{
259
+ jobId: z.ZodString;
260
+ leaseId: z.ZodString;
427
261
  }, z.core.$strict>;
428
- type ResultProvenance = z.infer<typeof ResultProvenance>;
262
+ type GrantRef = z.infer<typeof GrantRef>;
429
263
  /**
430
- * Build provenance for a completed job. `untrusted` is derived, never
431
- * supplied, so no caller can mark volunteer output as first-party.
264
+ * Pairing is a device-code exchange, not a pasted secret
265
+ * ({@link MUSTS.PAIR_INTERACTIVE}). The daemon starts a pairing, shows the
266
+ * user a short code and a URL, and polls until the user approves it inside
267
+ * the app's own authenticated session. Nothing listens on the user's machine
268
+ * and nothing works over a copied string alone.
432
269
  */
433
- declare function provenanceFor(input: {
434
- audience: Audience;
435
- runnerId: string;
436
- runnerOwner: string;
437
- backendClass: BackendClass;
438
- model: string;
439
- }): ResultProvenance;
440
- /** Successful outcome. */
441
- declare const JobResultOk: z.ZodObject<{
442
- outcome: z.ZodLiteral<"ok">;
443
- text: z.ZodString;
444
- artifactUrl: z.ZodOptional<z.ZodURL>;
270
+ declare const PairStartRequest: z.ZodObject<{
271
+ protocolVersion: z.ZodLiteral<"1">;
272
+ action: z.ZodLiteral<"start">;
273
+ daemon: z.ZodObject<{
274
+ version: z.ZodString;
275
+ label: z.ZodString;
276
+ platform: z.ZodEnum<{
277
+ darwin: "darwin";
278
+ linux: "linux";
279
+ win32: "win32";
280
+ }>;
281
+ }, z.core.$strict>;
282
+ device: z.ZodObject<{
283
+ identity: z.ZodString;
284
+ encryption: z.ZodString;
285
+ encryptionSig: z.ZodString;
286
+ }, z.core.$strict>;
287
+ capabilities: z.ZodArray<z.ZodObject<{
288
+ kind: z.ZodEnum<{
289
+ "llm.generate": "llm.generate";
290
+ "llm.chat": "llm.chat";
291
+ }>;
292
+ service: z.ZodString;
293
+ backendId: z.ZodEnum<{
294
+ ollama: "ollama";
295
+ mlx: "mlx";
296
+ llamacpp: "llamacpp";
297
+ vllm: "vllm";
298
+ lmstudio: "lmstudio";
299
+ jan: "jan";
300
+ localai: "localai";
301
+ anthropic: "anthropic";
302
+ openai: "openai";
303
+ gemini: "gemini";
304
+ grok: "grok";
305
+ groq: "groq";
306
+ openrouter: "openrouter";
307
+ together: "together";
308
+ deepseek: "deepseek";
309
+ mistral: "mistral";
310
+ "openai-http": "openai-http";
311
+ "claude-cli": "claude-cli";
312
+ "codex-cli": "codex-cli";
313
+ }>;
314
+ backendClass: z.ZodEnum<{
315
+ http: "http";
316
+ process: "process";
317
+ }>;
318
+ model: z.ZodString;
319
+ knownModels: z.ZodOptional<z.ZodArray<z.ZodString>>;
320
+ offerScope: z.ZodEnum<{
321
+ private: "private";
322
+ team: "team";
323
+ }>;
324
+ }, z.core.$strict>>;
445
325
  }, z.core.$strict>;
446
- /** Failed outcome. `code` is a stable machine string; `message` is for humans. */
447
- declare const JobResultError: z.ZodObject<{
448
- outcome: z.ZodLiteral<"error">;
449
- code: z.ZodString;
450
- message: z.ZodString;
451
- retryable: z.ZodBoolean;
326
+ type PairStartRequest = z.infer<typeof PairStartRequest>;
327
+ declare const PairStartResponse: z.ZodObject<{
328
+ deviceCode: z.ZodString;
329
+ userCode: z.ZodString;
330
+ verificationUrl: z.ZodURL;
331
+ expiresAt: z.ZodNumber;
332
+ pollIntervalMs: z.ZodNumber;
452
333
  }, z.core.$strict>;
453
- /** Cancelled outcome, reported by the daemon after honoring a cancel. */
454
- declare const JobResultCanceled: z.ZodObject<{
455
- outcome: z.ZodLiteral<"canceled">;
334
+ type PairStartResponse = z.infer<typeof PairStartResponse>;
335
+ declare const PairPollRequest: z.ZodObject<{
336
+ protocolVersion: z.ZodLiteral<"1">;
337
+ action: z.ZodLiteral<"poll">;
338
+ deviceCode: z.ZodString;
456
339
  }, z.core.$strict>;
457
- declare const JobOutcome: z.ZodDiscriminatedUnion<[z.ZodObject<{
458
- outcome: z.ZodLiteral<"ok">;
459
- text: z.ZodString;
460
- artifactUrl: z.ZodOptional<z.ZodURL>;
340
+ type PairPollRequest = z.infer<typeof PairPollRequest>;
341
+ declare const PairPollResponse: z.ZodDiscriminatedUnion<[z.ZodObject<{
342
+ status: z.ZodLiteral<"pending">;
461
343
  }, z.core.$strict>, z.ZodObject<{
462
- outcome: z.ZodLiteral<"error">;
463
- code: z.ZodString;
464
- message: z.ZodString;
465
- retryable: z.ZodBoolean;
344
+ status: z.ZodLiteral<"denied">;
466
345
  }, z.core.$strict>, z.ZodObject<{
467
- outcome: z.ZodLiteral<"canceled">;
468
- }, z.core.$strict>], "outcome">;
469
- type JobOutcome = z.infer<typeof JobOutcome>;
470
- /** A completed job as delivered to the app, provenance attached. */
471
- declare const DeliveredResult: z.ZodObject<{
472
- jobId: z.ZodString;
473
- state: z.ZodEnum<{
474
- ok: "ok";
475
- error: "error";
476
- queued: "queued";
477
- claimed: "claimed";
478
- running: "running";
479
- canceled: "canceled";
480
- expired: "expired";
481
- }>;
482
- outcome: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
483
- outcome: z.ZodLiteral<"ok">;
484
- text: z.ZodString;
485
- artifactUrl: z.ZodOptional<z.ZodURL>;
486
- }, z.core.$strict>, z.ZodObject<{
487
- outcome: z.ZodLiteral<"error">;
488
- code: z.ZodString;
489
- message: z.ZodString;
490
- retryable: z.ZodBoolean;
491
- }, z.core.$strict>, z.ZodObject<{
492
- outcome: z.ZodLiteral<"canceled">;
493
- }, z.core.$strict>], "outcome">>;
494
- provenance: z.ZodOptional<z.ZodObject<{
495
- audience: z.ZodEnum<{
496
- self: "self";
497
- named: "named";
498
- public: "public";
499
- }>;
500
- runnerId: z.ZodString;
501
- runnerOwner: z.ZodString;
502
- backendClass: z.ZodEnum<{
503
- http: "http";
504
- process: "process";
505
- }>;
506
- model: z.ZodString;
507
- untrusted: z.ZodBoolean;
508
- }, z.core.$strict>>;
509
- }, z.core.$strict>;
510
- type DeliveredResult = z.infer<typeof DeliveredResult>;
511
-
512
- /**
513
- * The normative MUSTs of protocol v0, as data.
514
- *
515
- * byollm_001 requires that "every MUST above has a conformance test id
516
- * referenced inline". Keeping the MUSTs as a frozen registry rather than
517
- * prose is what makes that requirement *checkable*: the conformance kit
518
- * imports {@link MUSTS} and fails if any id has no test asserting it, so a
519
- * new MUST cannot be added without a test and a test cannot silently drift
520
- * away from the statement it claims to prove.
521
- *
522
- * Ids are stable and public — third-party servers cite them in their
523
- * certification output.
524
- */
525
- /** Which side of the wire is obliged to enforce a given MUST. */
526
- type MustEnforcer = "daemon" | "server" | "both";
527
- /** A single normative requirement of the protocol. */
528
- interface Must {
529
- /** Stable public id, cited by conformance output. */
530
- readonly id: string;
531
- /** The requirement, in MUST language. */
532
- readonly statement: string;
533
- /** Which implementation is obliged to enforce it. */
534
- readonly enforcedBy: MustEnforcer;
535
- /** Spec section this was adjudicated in. */
536
- readonly source: string;
537
- }
538
- /**
539
- * Every normative MUST in protocol v0.
540
- *
541
- * @remarks
542
- * Grouped by concern for readability; the conformance kit treats this as a
543
- * flat set. Adding an entry here without a corresponding conformance test is
544
- * a CI failure, by design.
545
- */
546
- declare const MUSTS: Readonly<{
547
- readonly PAIR_ONE_USER: Must;
548
- readonly PAIR_INTERACTIVE: Must;
549
- readonly PAIR_CODE_EXPIRES: Must;
550
- readonly KIND_TYPED_ONLY: Must;
551
- readonly KIND_NO_CODE: Must;
552
- readonly CLAIM_REQUIRES_CAPABILITY: Must;
553
- readonly CAPABILITY_IS_DETECTED: Must;
554
- readonly CLAIM_ATOMIC: Must;
555
- readonly LEASE_HONORED: Must;
556
- readonly LEASE_RECLAIMABLE: Must;
557
- readonly AUDIENCE_BOTH_SIDES: Must;
558
- readonly SUBSCRIPTION_SELF_LOCK: Must;
559
- readonly NAMED_LOCAL_ALLOWLIST: Must;
560
- readonly REFUSAL_NOT_REOFFERED: Must;
561
- readonly REVOCATION_HONORED: Must;
562
- readonly CANCEL_HONORED: Must;
563
- readonly DEPENDS_ON_GATING: Must;
564
- readonly TTL_EXPIRY: Must;
565
- readonly NO_RUNNER_SIGNAL: Must;
566
- readonly RESULT_IDEMPOTENT: Must;
567
- readonly RESULT_PROVENANCE: Must;
568
- readonly INGRESS_LOGGED_BEFORE_EXECUTION: Must;
569
- readonly NO_SHELL_INTERPOLATION: Must;
570
- readonly NO_PAYLOAD_ROUTING: Must;
571
- readonly STRIPPED_CHILD_ENV: Must;
572
- readonly HTTP_BASE_URL_SAFE: Must;
573
- readonly OUTPUT_INERT: Must;
574
- readonly COMMUNITY_BUDGETS: Must;
575
- }>;
576
- /** The id of any normative MUST. */
577
- type MustId = keyof typeof MUSTS;
578
- /** All MUST ids, for coverage checks. */
579
- declare const MUST_IDS: readonly ("PAIR_ONE_USER" | "PAIR_INTERACTIVE" | "PAIR_CODE_EXPIRES" | "KIND_TYPED_ONLY" | "KIND_NO_CODE" | "CLAIM_REQUIRES_CAPABILITY" | "CAPABILITY_IS_DETECTED" | "CLAIM_ATOMIC" | "LEASE_HONORED" | "LEASE_RECLAIMABLE" | "AUDIENCE_BOTH_SIDES" | "SUBSCRIPTION_SELF_LOCK" | "NAMED_LOCAL_ALLOWLIST" | "REFUSAL_NOT_REOFFERED" | "REVOCATION_HONORED" | "CANCEL_HONORED" | "DEPENDS_ON_GATING" | "TTL_EXPIRY" | "NO_RUNNER_SIGNAL" | "RESULT_IDEMPOTENT" | "RESULT_PROVENANCE" | "INGRESS_LOGGED_BEFORE_EXECUTION" | "NO_SHELL_INTERPOLATION" | "NO_PAYLOAD_ROUTING" | "STRIPPED_CHILD_ENV" | "HTTP_BASE_URL_SAFE" | "OUTPUT_INERT" | "COMMUNITY_BUDGETS")[];
580
-
581
- /** Protocol version carried on every request; servers refuse what they can't speak. */
582
- declare const PROTOCOL_VERSION: "0";
583
- /** The path prefix all endpoints mount under. */
584
- declare const PROTOCOL_PREFIX: "/byollm";
585
- /** The five endpoint names, in the order byollm_001 lists them. */
586
- declare const ENDPOINTS: readonly ["pair", "claim", "heartbeat", "result", "release"];
587
- type Endpoint = (typeof ENDPOINTS)[number];
588
- /**
589
- * One entry of the capability matrix: a kind this daemon can actually serve,
590
- * right now, with the backend and model that would serve it.
591
- *
592
- * Derived from owner config intersected with detected reality
593
- * ({@link MUSTS.CAPABILITY_IS_DETECTED}) — a configured-but-unreachable
594
- * backend must not appear here. Carries `backendClass` so the app can tell
595
- * whether a result came from a sandboxed spawn or an HTTP call
596
- * (byollm_001 Rev 1 §A).
597
- */
598
- declare const Capability: z.ZodObject<{
599
- kind: z.ZodEnum<{
600
- "llm.generate": "llm.generate";
601
- "llm.chat": "llm.chat";
602
- }>;
603
- backendId: z.ZodEnum<{
604
- "openai-http": "openai-http";
605
- "claude-cli": "claude-cli";
606
- }>;
607
- backendClass: z.ZodEnum<{
608
- http: "http";
609
- process: "process";
610
- }>;
611
- model: z.ZodString;
612
- offerScope: z.ZodEnum<{
613
- self: "self";
614
- named: "named";
615
- public: "public";
616
- }>;
617
- }, z.core.$strict>;
618
- type Capability = z.infer<typeof Capability>;
619
- /** The capability matrix a daemon advertises. */
620
- declare const CapabilityMatrix: z.ZodArray<z.ZodObject<{
621
- kind: z.ZodEnum<{
622
- "llm.generate": "llm.generate";
623
- "llm.chat": "llm.chat";
624
- }>;
625
- backendId: z.ZodEnum<{
626
- "openai-http": "openai-http";
627
- "claude-cli": "claude-cli";
628
- }>;
629
- backendClass: z.ZodEnum<{
630
- http: "http";
631
- process: "process";
632
- }>;
633
- model: z.ZodString;
634
- offerScope: z.ZodEnum<{
635
- self: "self";
636
- named: "named";
637
- public: "public";
638
- }>;
639
- }, z.core.$strict>>;
640
- type CapabilityMatrix = z.infer<typeof CapabilityMatrix>;
641
- /**
642
- * Pairing is a device-code exchange, not a pasted secret
643
- * ({@link MUSTS.PAIR_INTERACTIVE}). The daemon starts a pairing, shows the
644
- * user a short code and a URL, and polls until the user approves it inside
645
- * the app's own authenticated session. Nothing listens on the user's machine
646
- * and nothing works over a copied string alone.
647
- */
648
- declare const PairStartRequest: z.ZodObject<{
649
- protocolVersion: z.ZodLiteral<"0">;
650
- action: z.ZodLiteral<"start">;
651
- daemon: z.ZodObject<{
652
- version: z.ZodString;
653
- label: z.ZodString;
654
- platform: z.ZodEnum<{
655
- darwin: "darwin";
656
- linux: "linux";
657
- win32: "win32";
658
- }>;
659
- }, z.core.$strip>;
660
- capabilities: z.ZodArray<z.ZodObject<{
661
- kind: z.ZodEnum<{
662
- "llm.generate": "llm.generate";
663
- "llm.chat": "llm.chat";
664
- }>;
665
- backendId: z.ZodEnum<{
666
- "openai-http": "openai-http";
667
- "claude-cli": "claude-cli";
668
- }>;
669
- backendClass: z.ZodEnum<{
670
- http: "http";
671
- process: "process";
672
- }>;
673
- model: z.ZodString;
674
- offerScope: z.ZodEnum<{
675
- self: "self";
676
- named: "named";
677
- public: "public";
678
- }>;
679
- }, z.core.$strict>>;
680
- }, z.core.$strict>;
681
- type PairStartRequest = z.infer<typeof PairStartRequest>;
682
- declare const PairStartResponse: z.ZodObject<{
683
- deviceCode: z.ZodString;
684
- userCode: z.ZodString;
685
- verificationUrl: z.ZodURL;
686
- expiresAt: z.ZodNumber;
687
- pollIntervalMs: z.ZodNumber;
688
- }, z.core.$strict>;
689
- type PairStartResponse = z.infer<typeof PairStartResponse>;
690
- declare const PairPollRequest: z.ZodObject<{
691
- protocolVersion: z.ZodLiteral<"0">;
692
- action: z.ZodLiteral<"poll">;
693
- deviceCode: z.ZodString;
694
- }, z.core.$strict>;
695
- type PairPollRequest = z.infer<typeof PairPollRequest>;
696
- declare const PairPollResponse: z.ZodDiscriminatedUnion<[z.ZodObject<{
697
- status: z.ZodLiteral<"pending">;
698
- }, z.core.$strict>, z.ZodObject<{
699
- status: z.ZodLiteral<"denied">;
700
- }, z.core.$strict>, z.ZodObject<{
701
- status: z.ZodLiteral<"expired">;
702
- }, z.core.$strict>, z.ZodObject<{
703
- status: z.ZodLiteral<"approved">;
704
- runnerToken: z.ZodString;
705
- runnerId: z.ZodString;
706
- owner: z.ZodString;
707
- ownerLabel: z.ZodOptional<z.ZodString>;
708
- }, z.core.$strict>], "status">;
709
- type PairPollResponse = z.infer<typeof PairPollResponse>;
710
- declare const PairRequest: z.ZodDiscriminatedUnion<[z.ZodObject<{
711
- protocolVersion: z.ZodLiteral<"0">;
712
- action: z.ZodLiteral<"start">;
713
- daemon: z.ZodObject<{
714
- version: z.ZodString;
715
- label: z.ZodString;
716
- platform: z.ZodEnum<{
717
- darwin: "darwin";
718
- linux: "linux";
719
- win32: "win32";
720
- }>;
721
- }, z.core.$strip>;
722
- capabilities: z.ZodArray<z.ZodObject<{
723
- kind: z.ZodEnum<{
724
- "llm.generate": "llm.generate";
725
- "llm.chat": "llm.chat";
726
- }>;
727
- backendId: z.ZodEnum<{
728
- "openai-http": "openai-http";
729
- "claude-cli": "claude-cli";
346
+ status: z.ZodLiteral<"expired">;
347
+ }, z.core.$strict>, z.ZodObject<{
348
+ status: z.ZodLiteral<"approved">;
349
+ runnerId: z.ZodString;
350
+ owner: z.ZodString;
351
+ ownerLabel: z.ZodOptional<z.ZodString>;
352
+ sites: z.ZodRecord<z.ZodString, z.ZodObject<{
353
+ identity: z.ZodString;
354
+ encryption: z.ZodString;
355
+ encryptionSig: z.ZodString;
356
+ }, z.core.$strict>>;
357
+ controlPlanePublic: z.ZodOptional<z.ZodString>;
358
+ }, z.core.$strict>], "status">;
359
+ type PairPollResponse = z.infer<typeof PairPollResponse>;
360
+ declare const PairRequest: z.ZodDiscriminatedUnion<[z.ZodObject<{
361
+ protocolVersion: z.ZodLiteral<"1">;
362
+ action: z.ZodLiteral<"start">;
363
+ daemon: z.ZodObject<{
364
+ version: z.ZodString;
365
+ label: z.ZodString;
366
+ platform: z.ZodEnum<{
367
+ darwin: "darwin";
368
+ linux: "linux";
369
+ win32: "win32";
370
+ }>;
371
+ }, z.core.$strict>;
372
+ device: z.ZodObject<{
373
+ identity: z.ZodString;
374
+ encryption: z.ZodString;
375
+ encryptionSig: z.ZodString;
376
+ }, z.core.$strict>;
377
+ capabilities: z.ZodArray<z.ZodObject<{
378
+ kind: z.ZodEnum<{
379
+ "llm.generate": "llm.generate";
380
+ "llm.chat": "llm.chat";
381
+ }>;
382
+ service: z.ZodString;
383
+ backendId: z.ZodEnum<{
384
+ ollama: "ollama";
385
+ mlx: "mlx";
386
+ llamacpp: "llamacpp";
387
+ vllm: "vllm";
388
+ lmstudio: "lmstudio";
389
+ jan: "jan";
390
+ localai: "localai";
391
+ anthropic: "anthropic";
392
+ openai: "openai";
393
+ gemini: "gemini";
394
+ grok: "grok";
395
+ groq: "groq";
396
+ openrouter: "openrouter";
397
+ together: "together";
398
+ deepseek: "deepseek";
399
+ mistral: "mistral";
400
+ "openai-http": "openai-http";
401
+ "claude-cli": "claude-cli";
402
+ "codex-cli": "codex-cli";
730
403
  }>;
731
404
  backendClass: z.ZodEnum<{
732
405
  http: "http";
733
406
  process: "process";
734
407
  }>;
735
408
  model: z.ZodString;
409
+ knownModels: z.ZodOptional<z.ZodArray<z.ZodString>>;
736
410
  offerScope: z.ZodEnum<{
737
- self: "self";
738
- named: "named";
739
- public: "public";
411
+ private: "private";
412
+ team: "team";
740
413
  }>;
741
414
  }, z.core.$strict>>;
742
415
  }, z.core.$strict>, z.ZodObject<{
743
- protocolVersion: z.ZodLiteral<"0">;
416
+ protocolVersion: z.ZodLiteral<"1">;
744
417
  action: z.ZodLiteral<"poll">;
745
418
  deviceCode: z.ZodString;
746
419
  }, z.core.$strict>], "action">;
747
420
  type PairRequest = z.infer<typeof PairRequest>;
748
421
  declare const ClaimRequest: z.ZodObject<{
749
- protocolVersion: z.ZodLiteral<"0">;
422
+ protocolVersion: z.ZodLiteral<"1">;
750
423
  runnerId: z.ZodString;
751
424
  capabilities: z.ZodArray<z.ZodObject<{
752
425
  kind: z.ZodEnum<{
753
426
  "llm.generate": "llm.generate";
754
427
  "llm.chat": "llm.chat";
755
428
  }>;
429
+ service: z.ZodString;
756
430
  backendId: z.ZodEnum<{
431
+ ollama: "ollama";
432
+ mlx: "mlx";
433
+ llamacpp: "llamacpp";
434
+ vllm: "vllm";
435
+ lmstudio: "lmstudio";
436
+ jan: "jan";
437
+ localai: "localai";
438
+ anthropic: "anthropic";
439
+ openai: "openai";
440
+ gemini: "gemini";
441
+ grok: "grok";
442
+ groq: "groq";
443
+ openrouter: "openrouter";
444
+ together: "together";
445
+ deepseek: "deepseek";
446
+ mistral: "mistral";
757
447
  "openai-http": "openai-http";
758
448
  "claude-cli": "claude-cli";
449
+ "codex-cli": "codex-cli";
759
450
  }>;
760
451
  backendClass: z.ZodEnum<{
761
452
  http: "http";
762
453
  process: "process";
763
454
  }>;
764
455
  model: z.ZodString;
456
+ knownModels: z.ZodOptional<z.ZodArray<z.ZodString>>;
765
457
  offerScope: z.ZodEnum<{
766
- self: "self";
767
- named: "named";
768
- public: "public";
458
+ private: "private";
459
+ team: "team";
769
460
  }>;
770
461
  }, z.core.$strict>>;
771
462
  max: z.ZodNumber;
@@ -778,37 +469,44 @@ declare const ClaimResponse: z.ZodObject<{
778
469
  "llm.generate": "llm.generate";
779
470
  "llm.chat": "llm.chat";
780
471
  }>;
781
- payload: z.ZodUnion<readonly [z.ZodObject<{
782
- prompt: z.ZodString;
783
- system: z.ZodOptional<z.ZodString>;
784
- }, z.core.$strict>, z.ZodObject<{
785
- messages: z.ZodArray<z.ZodObject<{
786
- role: z.ZodEnum<{
787
- system: "system";
788
- user: "user";
789
- assistant: "assistant";
790
- }>;
791
- content: z.ZodString;
792
- }, z.core.$strip>>;
793
- system: z.ZodOptional<z.ZodString>;
794
- }, z.core.$strict>]>;
472
+ owner: z.ZodString;
473
+ site: z.ZodString;
795
474
  audience: z.ZodEnum<{
796
- self: "self";
797
- named: "named";
798
- public: "public";
475
+ private: "private";
476
+ team: "team";
799
477
  }>;
800
- owner: z.ZodString;
801
- audienceAllow: z.ZodOptional<z.ZodArray<z.ZodString>>;
478
+ purpose: z.ZodOptional<z.ZodString>;
479
+ sizeClass: z.ZodEnum<{
480
+ small: "small";
481
+ medium: "medium";
482
+ large: "large";
483
+ unbounded: "unbounded";
484
+ }>;
485
+ streaming: z.ZodBoolean;
486
+ deadlineAt: z.ZodNumber;
802
487
  lease: z.ZodObject<{
488
+ id: z.ZodString;
803
489
  runnerId: z.ZodString;
804
490
  expiresAt: z.ZodNumber;
805
- }, z.core.$strip>;
491
+ }, z.core.$strict>;
492
+ grant: z.ZodOptional<z.ZodObject<{
493
+ grantId: z.ZodString;
494
+ jobId: z.ZodString;
495
+ site: z.ZodString;
496
+ user: z.ZodString;
497
+ owner: z.ZodString;
498
+ purpose: z.ZodString;
499
+ kind: z.ZodString;
500
+ service: z.ZodString;
501
+ issuedAt: z.ZodNumber;
502
+ signature: z.ZodString;
503
+ }, z.core.$strict>>;
806
504
  }, z.core.$strict>>;
807
505
  leaseMs: z.ZodNumber;
808
506
  }, z.core.$strict>;
809
507
  type ClaimResponse = z.infer<typeof ClaimResponse>;
810
508
  declare const HeartbeatRequest: z.ZodObject<{
811
- protocolVersion: z.ZodLiteral<"0">;
509
+ protocolVersion: z.ZodLiteral<"1">;
812
510
  runnerId: z.ZodString;
813
511
  daemonVersion: z.ZodString;
814
512
  capabilities: z.ZodArray<z.ZodObject<{
@@ -816,75 +514,148 @@ declare const HeartbeatRequest: z.ZodObject<{
816
514
  "llm.generate": "llm.generate";
817
515
  "llm.chat": "llm.chat";
818
516
  }>;
517
+ service: z.ZodString;
819
518
  backendId: z.ZodEnum<{
519
+ ollama: "ollama";
520
+ mlx: "mlx";
521
+ llamacpp: "llamacpp";
522
+ vllm: "vllm";
523
+ lmstudio: "lmstudio";
524
+ jan: "jan";
525
+ localai: "localai";
526
+ anthropic: "anthropic";
527
+ openai: "openai";
528
+ gemini: "gemini";
529
+ grok: "grok";
530
+ groq: "groq";
531
+ openrouter: "openrouter";
532
+ together: "together";
533
+ deepseek: "deepseek";
534
+ mistral: "mistral";
820
535
  "openai-http": "openai-http";
821
536
  "claude-cli": "claude-cli";
537
+ "codex-cli": "codex-cli";
822
538
  }>;
823
539
  backendClass: z.ZodEnum<{
824
540
  http: "http";
825
541
  process: "process";
826
542
  }>;
827
543
  model: z.ZodString;
544
+ knownModels: z.ZodOptional<z.ZodArray<z.ZodString>>;
828
545
  offerScope: z.ZodEnum<{
829
- self: "self";
830
- named: "named";
831
- public: "public";
546
+ private: "private";
547
+ team: "team";
548
+ }>;
549
+ }, z.core.$strict>>;
550
+ withheld: z.ZodDefault<z.ZodArray<z.ZodObject<{
551
+ kind: z.ZodEnum<{
552
+ "llm.generate": "llm.generate";
553
+ "llm.chat": "llm.chat";
832
554
  }>;
555
+ claimants: z.ZodArray<z.ZodObject<{
556
+ service: z.ZodString;
557
+ offer: z.ZodEnum<{
558
+ private: "private";
559
+ team: "team";
560
+ }>;
561
+ }, z.core.$strict>>;
562
+ }, z.core.$strict>>>;
563
+ activeLeases: z.ZodArray<z.ZodObject<{
564
+ jobId: z.ZodString;
565
+ leaseId: z.ZodString;
833
566
  }, z.core.$strict>>;
834
- activeJobIds: z.ZodArray<z.ZodString>;
835
567
  paused: z.ZodBoolean;
836
568
  }, z.core.$strict>;
837
569
  type HeartbeatRequest = z.infer<typeof HeartbeatRequest>;
838
570
  declare const HeartbeatResponse: z.ZodObject<{
839
- revoked: z.ZodBoolean;
840
- cancel: z.ZodArray<z.ZodString>;
841
- leases: z.ZodArray<z.ZodObject<{
571
+ sites: z.ZodRecord<z.ZodString, z.ZodObject<{
572
+ identity: z.ZodString;
573
+ encryption: z.ZodString;
574
+ encryptionSig: z.ZodString;
575
+ }, z.core.$strict>>;
576
+ successions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
577
+ succeeds: z.ZodArray<z.ZodObject<{
578
+ identity: z.ZodObject<{
579
+ identity: z.ZodString;
580
+ encryption: z.ZodString;
581
+ encryptionSig: z.ZodString;
582
+ }, z.core.$strict>;
583
+ signature: z.ZodString;
584
+ }, z.core.$strict>>;
585
+ retiringUntil: z.ZodOptional<z.ZodNumber>;
586
+ }, z.core.$strict>>>;
587
+ cancel: z.ZodArray<z.ZodObject<{
842
588
  jobId: z.ZodString;
843
- expiresAt: z.ZodNumber;
589
+ leaseId: z.ZodString;
590
+ }, z.core.$strict>>;
591
+ lost: z.ZodArray<z.ZodObject<{
592
+ jobId: z.ZodString;
593
+ leaseId: z.ZodString;
844
594
  }, z.core.$strict>>;
845
- lost: z.ZodArray<z.ZodString>;
846
595
  serverTime: z.ZodNumber;
596
+ awaitingConsent: z.ZodArray<z.ZodString>;
597
+ updateTo: z.ZodOptional<z.ZodString>;
847
598
  }, z.core.$strict>;
848
599
  type HeartbeatResponse = z.infer<typeof HeartbeatResponse>;
600
+ /**
601
+ * What an intermediary learns about how a job ended — byollm_009 §6.
602
+ *
603
+ * The discriminator and nothing else. A relay has to know a job reached a
604
+ * terminal state, and whether it failed, because that decides whether the job
605
+ * leaves the queue or the app may re-enqueue. It does not have to know what
606
+ * the model said, or what an error said, and this is where that line is drawn.
607
+ *
608
+ * Kept identical to `JobOutcome`'s discriminator rather than coarsened to
609
+ * ok/not-ok: a cancelled job and a failed one are different routing outcomes,
610
+ * and collapsing them would make the relay guess.
611
+ */
612
+ declare const ResultDisposition: z.ZodEnum<{
613
+ error: "error";
614
+ ok: "ok";
615
+ canceled: "canceled";
616
+ }>;
617
+ type ResultDisposition = z.infer<typeof ResultDisposition>;
849
618
  declare const ResultRequest: z.ZodObject<{
850
- protocolVersion: z.ZodLiteral<"0">;
619
+ protocolVersion: z.ZodLiteral<"1">;
851
620
  runnerId: z.ZodString;
852
621
  jobId: z.ZodString;
853
- outcome: z.ZodDiscriminatedUnion<[z.ZodObject<{
854
- outcome: z.ZodLiteral<"ok">;
855
- text: z.ZodString;
856
- artifactUrl: z.ZodOptional<z.ZodURL>;
857
- }, z.core.$strict>, z.ZodObject<{
858
- outcome: z.ZodLiteral<"error">;
859
- code: z.ZodString;
860
- message: z.ZodString;
861
- retryable: z.ZodBoolean;
862
- }, z.core.$strict>, z.ZodObject<{
863
- outcome: z.ZodLiteral<"canceled">;
864
- }, z.core.$strict>], "outcome">;
865
- model: z.ZodString;
866
- backendClass: z.ZodEnum<{
867
- http: "http";
868
- process: "process";
622
+ leaseId: z.ZodString;
623
+ envelope: z.ZodObject<{
624
+ ciphertext: z.ZodString;
625
+ recipientKeyId: z.ZodString;
626
+ senderKeyId: z.ZodString;
627
+ direction: z.ZodEnum<{
628
+ payload: "payload";
629
+ result: "result";
630
+ }>;
631
+ deadlineAt: z.ZodNumber;
632
+ }, z.core.$strict>;
633
+ disposition: z.ZodEnum<{
634
+ error: "error";
635
+ ok: "ok";
636
+ canceled: "canceled";
869
637
  }>;
870
- durationMs: z.ZodNumber;
871
638
  }, z.core.$strict>;
872
639
  type ResultRequest = z.infer<typeof ResultRequest>;
873
640
  declare const ResultResponse: z.ZodObject<{
874
641
  accepted: z.ZodBoolean;
642
+ duplicate: z.ZodOptional<z.ZodBoolean>;
875
643
  state: z.ZodString;
876
644
  }, z.core.$strict>;
877
645
  type ResultResponse = z.infer<typeof ResultResponse>;
878
646
  declare const ReleaseRequest: z.ZodObject<{
879
- protocolVersion: z.ZodLiteral<"0">;
647
+ protocolVersion: z.ZodLiteral<"1">;
880
648
  runnerId: z.ZodString;
881
- jobIds: z.ZodArray<z.ZodString>;
649
+ leases: z.ZodArray<z.ZodObject<{
650
+ jobId: z.ZodString;
651
+ leaseId: z.ZodString;
652
+ }, z.core.$strict>>;
882
653
  reason: z.ZodEnum<{
883
- revoked: "revoked";
654
+ refused: "refused";
884
655
  shutdown: "shutdown";
885
656
  pause: "pause";
657
+ revoked: "revoked";
886
658
  "backend-down": "backend-down";
887
- refused: "refused";
888
659
  }>;
889
660
  }, z.core.$strict>;
890
661
  type ReleaseRequest = z.infer<typeof ReleaseRequest>;
@@ -901,30 +672,2138 @@ type ReleaseResponse = z.infer<typeof ReleaseResponse>;
901
672
  * with no response at all.
902
673
  */
903
674
  declare const WireErrorCode: z.ZodEnum<{
675
+ "unsupported-protocol-version": "unsupported-protocol-version";
904
676
  revoked: "revoked";
905
677
  "bad-request": "bad-request";
906
- "unsupported-protocol-version": "unsupported-protocol-version";
678
+ "daemon-below-floor": "daemon-below-floor";
907
679
  unauthorized: "unauthorized";
680
+ forbidden: "forbidden";
908
681
  "not-found": "not-found";
682
+ "not-ready": "not-ready";
683
+ "too-late": "too-late";
684
+ "clock-skew": "clock-skew";
909
685
  "rate-limited": "rate-limited";
910
686
  "server-error": "server-error";
911
687
  }>;
912
688
  type WireErrorCode = z.infer<typeof WireErrorCode>;
913
689
  declare const WireError: z.ZodObject<{
914
690
  error: z.ZodEnum<{
691
+ "unsupported-protocol-version": "unsupported-protocol-version";
915
692
  revoked: "revoked";
916
693
  "bad-request": "bad-request";
917
- "unsupported-protocol-version": "unsupported-protocol-version";
694
+ "daemon-below-floor": "daemon-below-floor";
918
695
  unauthorized: "unauthorized";
696
+ forbidden: "forbidden";
919
697
  "not-found": "not-found";
698
+ "not-ready": "not-ready";
699
+ "too-late": "too-late";
700
+ "clock-skew": "clock-skew";
920
701
  "rate-limited": "rate-limited";
921
702
  "server-error": "server-error";
922
703
  }>;
923
704
  message: z.ZodString;
705
+ supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
706
+ minimum: z.ZodOptional<z.ZodString>;
707
+ floor: z.ZodOptional<z.ZodString>;
924
708
  retryAfter: z.ZodOptional<z.ZodNumber>;
709
+ serverTime: z.ZodOptional<z.ZodNumber>;
710
+ maxSkewMs: z.ZodOptional<z.ZodNumber>;
925
711
  }, z.core.$strict>;
926
712
  type WireError = z.infer<typeof WireError>;
927
713
  /** HTTP status each error code is served with. */
928
714
  declare const ERROR_STATUS: Readonly<Record<WireErrorCode, number>>;
715
+ declare const FetchRequest: z.ZodObject<{
716
+ protocolVersion: z.ZodLiteral<"1">;
717
+ runnerId: z.ZodString;
718
+ jobId: z.ZodString;
719
+ leaseId: z.ZodString;
720
+ }, z.core.$strict>;
721
+ type FetchRequest = z.infer<typeof FetchRequest>;
722
+ declare const FetchResponse: z.ZodObject<{
723
+ envelope: z.ZodObject<{
724
+ ciphertext: z.ZodString;
725
+ recipientKeyId: z.ZodString;
726
+ senderKeyId: z.ZodString;
727
+ direction: z.ZodEnum<{
728
+ payload: "payload";
729
+ result: "result";
730
+ }>;
731
+ deadlineAt: z.ZodNumber;
732
+ }, z.core.$strict>;
733
+ }, z.core.$strict>;
734
+ type FetchResponse = z.infer<typeof FetchResponse>;
735
+
736
+ /**
737
+ * Who may be told about a new version — B053.
738
+ *
739
+ * `HeartbeatResponse.updateTo` is a new field on a `.strict()` schema, and
740
+ * strict means a daemon built before the field does not ignore it: it rejects
741
+ * the entire heartbeat. Send it to everybody and the message carrying the
742
+ * update is the message that takes offline the machines it was meant to
743
+ * update — the fleet-wide version of the failure this codebase keeps meeting
744
+ * one surface at a time.
745
+ *
746
+ * No handshake is needed to avoid that. `HeartbeatRequest.daemonVersion` is
747
+ * already on the wire, so the sender can simply decline to say anything a
748
+ * given listener cannot hear. The rule lives here, next to the field it
749
+ * governs, because a rule of this kind in a runbook is a rule that holds
750
+ * until the next person deploys.
751
+ *
752
+ * ## The other direction, deliberately not taken
753
+ *
754
+ * The tidier-looking design is a capability list on the request — the daemon
755
+ * says what it understands. It has a hole this one does not: that field is
756
+ * also new, the hub's schema is also strict, and an upgraded daemon sending
757
+ * it to a hub that has not deployed yet is refused outright. It makes the
758
+ * daemon's upgrade depend on the hub's, in a system where the daemon is the
759
+ * side we do not control the timing of.
760
+ *
761
+ * Reading a field that already exists has no such ordering problem: old
762
+ * daemons are never sent the new field, new daemons are, and neither needs
763
+ * the other to have moved first.
764
+ */
765
+ /**
766
+ * The first daemon version whose schema has `updateTo` in it.
767
+ *
768
+ * Raising this is safe and lowering it is not, which is worth knowing before
769
+ * anybody tidies it: too high means some daemons miss an update they could
770
+ * have taken, and too low means their heartbeats are refused.
771
+ */
772
+ declare const UPDATE_OFFER_SINCE = "0.1.0-alpha.83";
773
+ /**
774
+ * Semver ordering, only as far as this needs it.
775
+ *
776
+ * Numeric prerelease parts compare as numbers, which is the whole reason not
777
+ * to compare these as strings: `alpha.9` sorts after `alpha.83`
778
+ * lexicographically, and that mistake here means every daemon between .10 and
779
+ * .82 is treated as too old to hear about an update — or worse, in the other
780
+ * direction, sent a field it cannot parse.
781
+ */
782
+ declare function compareVersions(a: string, b: string): number | undefined;
783
+ /**
784
+ * May this daemon be told about a new version?
785
+ *
786
+ * **A version this cannot parse is a no.** Unreadable is not permission: the
787
+ * consequence of guessing wrong in that direction is the daemon's heartbeat
788
+ * being refused, which is worse than it missing one update cycle. The same
789
+ * rule the rest of this protocol applies to unreadable answers, on the one
790
+ * field where getting it wrong is fleet-shaped.
791
+ */
792
+ declare function mayOfferUpdate(daemonVersion: string): boolean;
793
+ /**
794
+ * The oldest daemon a hub will serve — B052, the floor.
795
+ *
796
+ * The updater's backstop and its opposite number. The updater moves machines
797
+ * that opted in; the floor is what moves the ones that did not, and it is the
798
+ * only mechanism that works on a daemon which is not listening for offers.
799
+ *
800
+ * Raising it is a deliberate act with a spec note, never automatic — a floor
801
+ * that followed `latest` would refuse every machine that had not updated in
802
+ * the last hour, which is the outage version of hygiene.
803
+ */
804
+ interface FloorRefusal {
805
+ readonly error: "daemon-below-floor";
806
+ readonly message: string;
807
+ readonly floor: string;
808
+ }
809
+ /**
810
+ * Is this daemon too old to serve?
811
+ *
812
+ * **An unreadable version is NOT refused**, and that is the deliberate
813
+ * asymmetry with {@link mayOfferUpdate}, which treats an unreadable version
814
+ * as "do not offer". The two point the same way once you ask what the
815
+ * mistake costs: there, guessing yes sends a field that breaks the
816
+ * heartbeat; here, guessing yes takes a working machine out of service over
817
+ * a string it could not parse. Both decline to act when they cannot tell,
818
+ * and declining to act means opposite booleans.
819
+ */
820
+ declare function checkDaemonFloor(input: {
821
+ readonly daemonVersion: string;
822
+ readonly floor: string;
823
+ /** How somebody fixes it. The floor is useless without the remedy. */
824
+ readonly upgradeCommand: string;
825
+ }): FloorRefusal | null;
826
+ /**
827
+ * The only way to put `updateTo` on a heartbeat — D1's first deploy
828
+ * condition, made structural.
829
+ *
830
+ * The condition was "the hub must not be ABLE to set `updateTo` raw". A rule
831
+ * that says "remember to call `mayOfferUpdate` first" is a rule that holds
832
+ * until somebody adds a second return site — and the heartbeat handler
833
+ * already has two. So the fence is not a thing to remember; it is the only
834
+ * function that produces the field, and it applies the check inside itself.
835
+ *
836
+ * Returns a spreadable object rather than a value, so the call site reads
837
+ * `...updateOfferFor(...)` and there is no `updateTo:` anywhere for a later
838
+ * hand to copy.
839
+ *
840
+ * Absent `offer` means this deployment is offering nothing, which is the
841
+ * default and the safe one: a hub that has not been told a version says
842
+ * nothing to anybody.
843
+ */
844
+ declare function updateOfferFor(input: {
845
+ readonly offer: string | undefined;
846
+ readonly daemonVersion: string;
847
+ }): {
848
+ readonly updateTo?: string;
849
+ };
850
+ /**
851
+ * Source with its comments removed, for the checks below.
852
+ *
853
+ * Comments go first because a rule about a field has to be explainable in
854
+ * prose beside the code it governs — and the first version of the relay's
855
+ * fence test flagged its own explanation, which was written to say there
856
+ * must be no such write anywhere.
857
+ */
858
+ declare function withoutComments(source: string): string;
859
+ /**
860
+ * Does this source mention a wire field at all?
861
+ *
862
+ * **A word, not a spelling.** The relay's fence test shipped scanning for
863
+ * `/\bupdateTo\s*:/`, which is one syntax of one way to set a property —
864
+ * `"updateTo": offer`, `res.updateTo = offer`, `res["updateTo"] = offer` and
865
+ * shorthand in a spread all walk straight past it. The check's claim was
866
+ * "there is nowhere else to call from"; what it enforced was a spelling.
867
+ * That is our own recurring law, and this is its sixth instance — the first
868
+ * inside a test written to be structural rather than remembered.
869
+ *
870
+ * So the question this asks is deliberately blunter than the rule it serves.
871
+ * A mention is not a write, and the false positives are the point: anything
872
+ * that names the field in code has to be looked at by a person, because the
873
+ * cost of the miss is every daemon that predates the field rejecting every
874
+ * heartbeat.
875
+ *
876
+ * Lives here, beside {@link updateOfferFor}, so the hub and the relay run one
877
+ * copy rather than two that drift — the field's hazard is fleet-wide and it
878
+ * crosses a repository boundary, which is exactly where a duplicated rule
879
+ * stops being the same rule.
880
+ */
881
+ declare function mentionsWireField(source: string, field: string): boolean;
882
+
883
+ /** The full description — five sections, plus why it matters. */
884
+ declare const ABOUT = "# About BYOLLM\n\n**What BYOLLM is**\n\nBYOLLM lets you use your own AI on websites. You install one small program on\nyour computer. Then, websites that support BYOLLM can use the AI you already\nhave \u2014 a free model running on your machine, or an AI service you already pay\nfor \u2014 instead of the website paying for AI and passing the cost to you.\n\n**Why it matters**\n\nFor you:\n\n- Your favorite model, everywhere you go.\n- New models the moment you get them \u2013 not when a site gets around to adding\n them.\n- Encrypted end-to-end. Your prompts go to your own device; byollm.cloud can't\n read them.\n- Sites never learn which model you use, and your subscriptions are never\n shared.\n- Pay less. Sites that don't pay for AI can charge you less \u2013 or nothing.\n\nFor sites and developers:\n\n- Zero AI bills. Your users bring their own compute.\n- No floating money \u2013 you don't pay LLM bills up front and hope to collect\n later, and you never ask people to prepay just to try you.\n- Free trials that cost you nothing to offer.\n- Ship the AI features you kept private for fear of the API bill.\n- One small integration. Your users choose the models.\n\n**Your device**\n\nThe `byollm` program runs on your computer. It knows which AI services you have\nset up: free open-source models on your machine, metered services you pay per\nuse, or your own subscriptions like Claude Pro/Max. When a website you have\nenabled sends work, your device runs it with the service you chose. Your\nprompts are encrypted end-to-end to your own device. byollm.cloud passes them\nalong and cannot read them.\n\n**Sites**\n\nA website that wants to use BYOLLM says what it needs \u2014 \"writing help,\" \"chat,\"\nand so on. When you connect the site, you pick which of your services answers\neach one. The site never learns which model you use. You can turn a site off at\nany time, and it stops getting your work.\n\n**Teams (optional)**\n\nA team lets you share what runs on your devices with people you name \u2014 the free\nopen-source models on your machine, or a metered service with a spending limit\nyou set. Your subscription accounts (like Claude Pro/Max) are never shared with\nanyone. That is a rule, not a setting.\n\n**byollm.cloud (or your own relay)**\n\nMany sites, many devices, many people. byollm.cloud keeps track of who has\nallowed what and sends each job to the right device. It never sees your\nprompts. If you would rather run this part yourself, the relay is open source \u2014\nyou can run your own instead of using byollm.cloud.";
885
+ /**
886
+ * The first paragraph, which stands alone.
887
+ *
888
+ * What the welcome screen shows: somebody deciding whether to trust a site's
889
+ * button needs the whole idea in one breath, not a page.
890
+ */
891
+ declare const ABOUT_SHORT_LEDE = "BYOLLM \u2013 Bring Your Own LLM \u2013 lets you use your own AI on websites you authorize. A small program installed on your machine lets you use your own models and subscriptions on any BYOLLM-integrated site, including new models the moment you get access \u2013 no site updates required. BYOLLM Cloud connects sites to your devices with end-to-end encryption, so no one, including us, can see your data.";
892
+ /** The rest, for surfaces with room. Shown before "Learn more →". */
893
+ declare const ABOUT_SHORT_TAIL = "Sites can charge you less because you bring your own \u2013 see why that matters \u2192. Teams can optionally share the free or metered services on their devices with people they name. Personal subscriptions are never shared.";
894
+ /** Both halves, for a surface that wants the paragraph entire. */
895
+ declare const ABOUT_SHORT = "BYOLLM \u2013 Bring Your Own LLM \u2013 lets you use your own AI on websites you authorize. A small program installed on your machine lets you use your own models and subscriptions on any BYOLLM-integrated site, including new models the moment you get access \u2013 no site updates required. BYOLLM Cloud connects sites to your devices with end-to-end encryption, so no one, including us, can see your data.\n\nSites can charge you less because you bring your own \u2013 see why that matters \u2192. Teams can optionally share the free or metered services on their devices with people they name. Personal subscriptions are never shared.";
896
+
897
+ /**
898
+ * Its members, for anything that has to report what it accepts.
899
+ *
900
+ * Derived from the enum for the reason `JOB_KINDS` and `OFFER_SCOPES` are: a
901
+ * second list of the same words is a second thing to keep in step, and this
902
+ * one is read by the promotion gate to compare a deployed hub against a
903
+ * version about to be promoted.
904
+ */
905
+ declare const BACKEND_CLASSES: readonly ("http" | "process")[];
906
+ /**
907
+ * How a backend reaches its model — the taxonomy introduced in byollm_001
908
+ * Rev 1 §A, because the two classes have different threat surfaces.
909
+ *
910
+ * - `http`: an OpenAI-compatible HTTP server (Ollama, `mlx_lm.server`,
911
+ * llama.cpp server, vLLM, and every hosted provider that speaks the same
912
+ * wire format). Spawns nothing, so byollm_004 §2's argv, stdin, env and
913
+ * sandbox requirements are not applicable by construction. Its threat
914
+ * surface is SSRF-shaped and bounded by {@link MUSTS.HTTP_BASE_URL_SAFE}.
915
+ * - `process`: spawns a binary (`claude` CLI today, `mlx_lm.lora` for a
916
+ * future `train.*` kind). All of byollm_004 §2 is mandatory here.
917
+ */
918
+ declare const BackendClass: z.ZodEnum<{
919
+ http: "http";
920
+ process: "process";
921
+ }>;
922
+ type BackendClass = z.infer<typeof BackendClass>;
923
+ /**
924
+ * Who pays, and how — byollm_007.
925
+ *
926
+ * This replaced a two-valued `account` field that conflated two unrelated
927
+ * constraints and, in doing so, left a hole: `openai-http` was "open", but it
928
+ * accepts an API key, so an owner could point it at a paid endpoint, share it,
929
+ * and donate their credit balance to strangers. The community budgets cap job
930
+ * *count*, not spend.
931
+ *
932
+ * - `free` — local compute. Costs electricity, not money. Shareable.
933
+ * - `metered` — per-token billing against the owner's account. Legal to
934
+ * share and ruinous to share by accident.
935
+ * - `subscription` — a vendor account whose terms forbid third-party work.
936
+ * Sharing is a terms violation, not merely expensive.
937
+ */
938
+ declare const BackendCost: z.ZodEnum<{
939
+ free: "free";
940
+ metered: "metered";
941
+ subscription: "subscription";
942
+ }>;
943
+ type BackendCost = z.infer<typeof BackendCost>;
944
+ /** The immutable facts about a backend that the protocol reasons over. */
945
+ interface BackendDescriptor {
946
+ /** Stable backend id, as written in `byollm.config.json`. */
947
+ readonly id: string;
948
+ /** Human-readable name for the trust UI. */
949
+ readonly label: string;
950
+ /** Determines which isolation requirements apply. */
951
+ readonly class: BackendClass;
952
+ /**
953
+ * Who pays. Fixed here for every named provider and **not overridable by
954
+ * configuration** ({@link MUSTS.COST_NOT_CONFIGURABLE}) — `openai` is
955
+ * metered because it is, and no setting changes that.
956
+ *
957
+ * `null` only for the generic {@link BACKENDS."openai-http"} entry, whose
958
+ * cost is inferred from its base URL instead
959
+ * ({@link MUSTS.REMOTE_IS_NEVER_FREE}).
960
+ */
961
+ readonly cost: BackendCost | null;
962
+ /**
963
+ * Which adversarial corpus byollm_004 §5 runs against this backend. A
964
+ * backend cannot be registered without one — the coverage check in the
965
+ * adversarial suite enforces it.
966
+ */
967
+ readonly adversarialCorpus: "process" | "http";
968
+ /**
969
+ * Where this provider lives, when that is knowable. Owner config may
970
+ * override it; a provider with no default requires one to be given.
971
+ */
972
+ readonly defaultBaseUrl?: string;
973
+ }
974
+ /**
975
+ * The backend registry.
976
+ *
977
+ * **Providers are entries, not implementations.** Every HTTP-class provider
978
+ * below shares the single `openai-http` transport, because they all speak
979
+ * OpenAI-compatible `/v1/chat/completions`. An entry adds a stable id, a cost
980
+ * class the owner cannot override, and a default base URL. Adding a provider
981
+ * is therefore one line and no new code — which is why the adversarial corpus
982
+ * still covers all of them, and why a PR adding one is reviewable at a glance.
983
+ */
984
+ declare const BACKENDS: Readonly<{
985
+ readonly ollama: BackendDescriptor;
986
+ readonly mlx: BackendDescriptor;
987
+ readonly llamacpp: BackendDescriptor;
988
+ readonly vllm: BackendDescriptor;
989
+ readonly lmstudio: BackendDescriptor;
990
+ readonly jan: BackendDescriptor;
991
+ readonly localai: BackendDescriptor;
992
+ /**
993
+ * Note the pair: `anthropic` and {@link BACKENDS."claude-cli"} reach the
994
+ * same vendor and land in different cost classes. That is not an
995
+ * inconsistency — it is the axis working. One bills a key per token, the
996
+ * other runs under a personal plan whose terms cover one person's work. Who
997
+ * pays and under what terms is the question; which company is not.
998
+ */
999
+ readonly anthropic: BackendDescriptor;
1000
+ readonly openai: BackendDescriptor;
1001
+ readonly gemini: BackendDescriptor;
1002
+ readonly grok: BackendDescriptor;
1003
+ readonly groq: BackendDescriptor;
1004
+ readonly openrouter: BackendDescriptor;
1005
+ readonly together: BackendDescriptor;
1006
+ readonly deepseek: BackendDescriptor;
1007
+ readonly mistral: BackendDescriptor;
1008
+ readonly "openai-http": BackendDescriptor;
1009
+ readonly "claude-cli": BackendDescriptor;
1010
+ /**
1011
+ * OpenAI's Codex CLI, on a ChatGPT plan — byollm_016 stage 3.
1012
+ *
1013
+ * `subscription`, so `SUBSCRIPTION_SELF_LOCK` pins it to its owner's own
1014
+ * work whatever the config says. That is load-bearing here in a way it is
1015
+ * not for `claude-cli`: Codex is an *agent*, and its default feature set
1016
+ * includes a shell tool, browser control and computer use. The daemon
1017
+ * disables every one of them, verified against the shipped binary rather
1018
+ * than assumed — see `codex-cli.ts` — but the self-lock is the floor under
1019
+ * that verification rather than a duplicate of it.
1020
+ */
1021
+ readonly "codex-cli": BackendDescriptor;
1022
+ }>;
1023
+ /** The id of a registered backend. */
1024
+ type BackendId = keyof typeof BACKENDS;
1025
+ /** All registered backend ids — the adversarial coverage check iterates this. */
1026
+ declare const BACKEND_IDS: readonly ("ollama" | "mlx" | "llamacpp" | "vllm" | "lmstudio" | "jan" | "localai" | "anthropic" | "openai" | "gemini" | "grok" | "groq" | "openrouter" | "together" | "deepseek" | "mistral" | "openai-http" | "claude-cli" | "codex-cli")[];
1027
+ declare const BackendIdSchema: z.ZodEnum<{
1028
+ ollama: "ollama";
1029
+ mlx: "mlx";
1030
+ llamacpp: "llamacpp";
1031
+ vllm: "vllm";
1032
+ lmstudio: "lmstudio";
1033
+ jan: "jan";
1034
+ localai: "localai";
1035
+ anthropic: "anthropic";
1036
+ openai: "openai";
1037
+ gemini: "gemini";
1038
+ grok: "grok";
1039
+ groq: "groq";
1040
+ openrouter: "openrouter";
1041
+ together: "together";
1042
+ deepseek: "deepseek";
1043
+ mistral: "mistral";
1044
+ "openai-http": "openai-http";
1045
+ "claude-cli": "claude-cli";
1046
+ "codex-cli": "codex-cli";
1047
+ }>;
1048
+ /** Narrow an arbitrary string to a registered backend id. */
1049
+ declare function isBackendId(value: string): value is BackendId;
1050
+ /**
1051
+ * Look up a backend descriptor.
1052
+ *
1053
+ * @throws if the id is not registered — an unregistered backend has no
1054
+ * adversarial corpus, so refusing is the safe direction.
1055
+ */
1056
+ declare function backendDescriptor(id: BackendId): BackendDescriptor;
1057
+ /**
1058
+ * Is this host local enough that compute there is free?
1059
+ *
1060
+ * Loopback and the private ranges only. This is the rule that makes
1061
+ * {@link MUSTS.REMOTE_IS_NEVER_FREE} enforceable rather than a promise: an
1062
+ * owner cannot reach a paid API through the generic backend and call it free,
1063
+ * because "free" is derived from the address, not from what the config claims.
1064
+ *
1065
+ * **What this cannot see.** The address is all it reads. A proxy on
1066
+ * `127.0.0.1` forwarding to a paid API classes as `free` and nothing
1067
+ * downstream will contradict it. That is deliberate: standing up a relay is
1068
+ * an act by the machine's owner against their own account, and the threat
1069
+ * model here is a hostile *job*, not an owner routing around a rule that
1070
+ * exists to protect them. What this catches is the accident — a remote paid
1071
+ * endpoint offered to a team because nobody thought about the bill. See
1072
+ * `docs/security.md` §4a.
1073
+ */
1074
+ declare function isLocalHost(hostname: string): boolean;
1075
+ /**
1076
+ * Is this model name a hosted one billed by its vendor?
1077
+ *
1078
+ * Ollama serves cloud models through the same local endpoint as local ones,
1079
+ * so the address says "free" about a model somebody is being charged for. The
1080
+ * only thing that distinguishes them is the name, and the distinguishing part
1081
+ * is the **tag** — everything after the last colon.
1082
+ *
1083
+ * End-anchored on the tag, which is what makes it decidable rather than a
1084
+ * guess about substrings:
1085
+ *
1086
+ * - `glm-5.2:cloud` → cloud
1087
+ * - `deepseek-v4-flash:0731-cloud` → cloud
1088
+ * - `x:cloudless` → not cloud, the tag ends in "less"
1089
+ * - `cloudmodel:7b` → not cloud, the tag is "7b"
1090
+ * - `llama3.2` → not cloud, there is no tag at all
1091
+ *
1092
+ * An oddball like `:xcloud` classifies as cloud, and that is the **only
1093
+ * permitted failure direction**: calling a free model metered narrows what an
1094
+ * owner may share and costs nobody money, while the reverse hands somebody
1095
+ * else's bill to a stranger.
1096
+ */
1097
+ declare function isCloudTaggedModel(model: string): boolean;
1098
+ /**
1099
+ * The cost class of a configured service.
1100
+ *
1101
+ * For every named provider this is whatever the registry says, full stop
1102
+ * ({@link MUSTS.COST_NOT_CONFIGURABLE}). For the generic `openai-http` entry
1103
+ * it is inferred from the base URL, and a base URL that cannot be parsed is
1104
+ * treated as `metered` — the expensive side, because guessing "free" wrong
1105
+ * costs the owner money.
1106
+ *
1107
+ * The model has the last word in one direction only. A local address with a
1108
+ * cloud-tagged model is `metered`: Ollama proxies hosted models through
1109
+ * `127.0.0.1`, so the endpoint is local and the bill is not. Read from the
1110
+ * **configured value**, never from what the server lists — the owner's config
1111
+ * is the thing they chose, and a server's catalogue is not theirs to be
1112
+ * classified by.
1113
+ */
1114
+ declare function resolveCost(id: BackendId, baseUrl: string | undefined,
1115
+ /**
1116
+ * **Required, and that is the fix.**
1117
+ *
1118
+ * This was optional, and the no-re-derivation law was breached through the
1119
+ * gap rather than by anybody copying the logic. `byollm offer` passed two of
1120
+ * three arguments and `resolveConfig` passed three, so the same service was
1121
+ * free to one and metered to the other: `glm-5.2:cloud` on a loopback
1122
+ * address looks local until you read the tag. The command wrote a share the
1123
+ * daemon then refused, and told its owner to run the command they had just
1124
+ * run.
1125
+ *
1126
+ * A shared rule's signature admits no partial askers. `undefined` is still a
1127
+ * legal *value* — a service genuinely without a model — but it has to be
1128
+ * passed, so choosing to omit the model is a decision at the call site
1129
+ * rather than a default nobody notices.
1130
+ */
1131
+ model: string | undefined): BackendCost;
1132
+ /**
1133
+ * Why a service costs what it costs — the same decision, said out loud.
1134
+ *
1135
+ * Consent has to name the rule that fired. The offer ceremony read
1136
+ * "Any OpenAI-compatible server ... bills your account per token", which is
1137
+ * false about the type — an owner's local qwen is `openai-http` and costs
1138
+ * nothing but electricity — and so it gave a reason that its reader could
1139
+ * check and find wrong. The thing that bills is the `:cloud` tag on one
1140
+ * model, not the transport that carries it.
1141
+ *
1142
+ * One function decides and one function explains, and the second calls the
1143
+ * first, so a message can never describe a classification the code did not
1144
+ * make. Splitting them would be the same defect this signature was just
1145
+ * hardened against, arriving as prose.
1146
+ */
1147
+ /**
1148
+ * The product's name alone, without the parenthetical that classifies it.
1149
+ *
1150
+ * Every label in this registry does two jobs: it names a product and says what
1151
+ * that product means for the person paying — "Claude CLI (your subscription)",
1152
+ * "Ollama (local)". That is right for a list, where the parenthetical is the
1153
+ * only classification on screen.
1154
+ *
1155
+ * It is wrong inside a sentence that states the classification itself, which
1156
+ * then stutters: "my-claude runs on Claude CLI (your subscription), a
1157
+ * subscription whose terms…". Prose wants the name; the sentence around it is
1158
+ * already carrying the meaning.
1159
+ *
1160
+ * One definition rather than a regex at each call site — and the place to
1161
+ * change if the registry ever splits the two facts into two fields, which is
1162
+ * the better shape and not worth a migration today.
1163
+ */
1164
+ declare function backendName(id: BackendId): string;
1165
+ interface CostReason {
1166
+ readonly cost: BackendCost;
1167
+ /** The rule, in the words a person consenting needs. */
1168
+ readonly because: string;
1169
+ }
1170
+ declare function classifyCost(id: BackendId, baseUrl: string | undefined, model: string | undefined): CostReason;
1171
+
1172
+ /**
1173
+ * Who may run a job, declared by the app that enqueued it.
1174
+ *
1175
+ * - `private` — only the job owner's own devices.
1176
+ * - `team` — a device whose owner admits this person.
1177
+ *
1178
+ * **One vocabulary, ruled 2026-08-24.** These were `self | named | public`
1179
+ * while {@link OfferScope} used different words for the same idea, which would
1180
+ * have left every seam where the two meet speaking two languages, and every
1181
+ * doc explaining "self versus private" for ever. They are still independent
1182
+ * axes — a job says who may run it, a service says who it will run for — and a
1183
+ * job runs only where both agree ({@link MUSTS.AUDIENCE_BOTH_SIDES}).
1184
+ *
1185
+ * **`public` is gone, ruled 2026-08-26 (byollm_016).** Not deprecated,
1186
+ * removed, and removed from the OSS daemon too rather than parked as a
1187
+ * community posture. The argument was a measurement rather than a preference:
1188
+ * device-side admission had never once been exercised end to end, because
1189
+ * every cross-user test ran against a publicly offered service and
1190
+ * {@link matchAudience} returned ALLOWED for those *without consulting the
1191
+ * device at all*. `public` was the off switch for admission, and an enum with
1192
+ * a value that skips verification is a fail-open waiting for the wiring bug
1193
+ * that reaches it. There is now no such value.
1194
+ */
1195
+ declare const Audience: z.ZodEnum<{
1196
+ private: "private";
1197
+ team: "team";
1198
+ }>;
1199
+ type Audience = z.infer<typeof Audience>;
1200
+ /**
1201
+ * What a device's owner is willing to run for other people, per service.
1202
+ *
1203
+ * - `private` — the owner's own work only.
1204
+ * - `team` — whoever the owner's authority admits. Membership is **central**,
1205
+ * not per-person: the device follows what it is told by a signature it can
1206
+ * check, rather than holding its own copy of who is in it (byollm_016).
1207
+ *
1208
+ * Two values, and no third that means "everyone". See {@link Audience} for
1209
+ * why `public` was removed rather than parked, and note the shape of the
1210
+ * remaining enum: **every value left requires the device to verify
1211
+ * something.** `private` checks the owner; `team` checks admission. That is
1212
+ * the property, not an accident of there being two.
1213
+ */
1214
+ declare const OfferScope: z.ZodEnum<{
1215
+ private: "private";
1216
+ team: "team";
1217
+ }>;
1218
+ type OfferScope = z.infer<typeof OfferScope>;
1219
+ /** All audience values, in widening order. */
1220
+ declare const AUDIENCES: readonly ("private" | "team")[];
1221
+ /** All offer scopes, in widening order. */
1222
+ declare const OFFER_SCOPES: readonly ("private" | "team")[];
1223
+ /**
1224
+ * Why a job was refused. Distinct codes because byollm_002 requires that
1225
+ * different truths never share a message — "no matching work" and "refused on
1226
+ * principle" are not the same event, and a volunteer debugging their setup
1227
+ * needs to know which one happened.
1228
+ */
1229
+ declare const MatchRefusal: z.ZodEnum<{
1230
+ "no-capability": "no-capability";
1231
+ "audience-self-other-owner": "audience-self-other-owner";
1232
+ "not-locally-allowed": "not-locally-allowed";
1233
+ "not-in-server-allowlist": "not-in-server-allowlist";
1234
+ "offer-scope-too-narrow": "offer-scope-too-narrow";
1235
+ "subscription-self-lock": "subscription-self-lock";
1236
+ "metered-no-spend-consent": "metered-no-spend-consent";
1237
+ "metered-ceiling-reached": "metered-ceiling-reached";
1238
+ }>;
1239
+ type MatchRefusal = z.infer<typeof MatchRefusal>;
1240
+ /** The outcome of an audience match. */
1241
+ type MatchResult = {
1242
+ readonly ok: true;
1243
+ } | {
1244
+ readonly ok: false;
1245
+ readonly refusal: MatchRefusal;
1246
+ };
1247
+ /** What the owner has agreed to spend on other people's work, if anything. */
1248
+ interface SpendConsent {
1249
+ /** The owner explicitly acknowledged that sharing this backend costs money. */
1250
+ readonly acknowledged: boolean;
1251
+ /** Their ceiling. Absent means no ceiling was set, which is not consent. */
1252
+ readonly ceilingReached?: boolean;
1253
+ }
1254
+ /**
1255
+ * The effective offer scope of a backend.
1256
+ *
1257
+ * Three rules, applied at the one place both the daemon's config loader and
1258
+ * its matcher call, so no code path can observe a scope wider than the cost
1259
+ * class allows:
1260
+ *
1261
+ * - `subscription` is locked to `private` regardless of config
1262
+ * ({@link MUSTS.SUBSCRIPTION_SELF_LOCK}) — someone else's terms.
1263
+ * - `metered` narrows to `private` unless the owner has explicitly acknowledged
1264
+ * the spend ({@link MUSTS.METERED_DEFAULTS_SELF}) — their money.
1265
+ * - `free` passes through — their electricity.
1266
+ *
1267
+ * Note the asymmetry: subscription can never be widened, metered can be
1268
+ * widened deliberately. Conflating those was byollm_007's bug.
1269
+ */
1270
+ declare function effectiveOfferScope(configured: OfferScope, cost: BackendCost, spend?: SpendConsent): OfferScope;
1271
+ /** The job-side facts a match needs. */
1272
+ interface MatchJob {
1273
+ /** The app's id for the user who enqueued the job. */
1274
+ readonly owner: string;
1275
+ /** Who the app says may run it. */
1276
+ readonly audience: Audience;
1277
+ /**
1278
+ * Optional server-side restriction on which runner owners may take a
1279
+ * `team` job. Defence in depth only, and direct-mode only — it never
1280
+ * reaches a daemon (cloud_008 §0.2), so the device's own admission is the
1281
+ * enforcing side ({@link MUSTS.NAMED_LOCAL_ALLOWLIST}).
1282
+ */
1283
+ readonly audienceAllow?: readonly string[] | undefined;
1284
+ }
1285
+ /** The daemon-side facts a match needs. */
1286
+ interface MatchDaemon {
1287
+ /** The app's id for the user this daemon is paired to. */
1288
+ readonly owner: string;
1289
+ /** Effective scope of the backend that would run the job. */
1290
+ readonly offerScope: OfferScope;
1291
+ /** Who pays for that backend's tokens. */
1292
+ readonly cost: BackendCost;
1293
+ /** What the owner agreed to spend on others, for a `metered` backend. */
1294
+ readonly spend?: SpendConsent | undefined;
1295
+ /**
1296
+ * Has something **this device verified** admitted the job's owner?
1297
+ *
1298
+ * A predicate rather than a value so the protocol package stays free of
1299
+ * both file I/O and signature state. What supplies it has changed twice and
1300
+ * will change again — a local allowlist, then a held roster, and now a
1301
+ * claim-time signed grant (Amendment J) — and the law it feeds has not
1302
+ * changed at all: a `team` service runs a stranger's work only when
1303
+ * somebody this device can check said so.
1304
+ *
1305
+ * The server passes a conservative `() => true`: it cannot know what a
1306
+ * remote device verified and must not pretend to. The device is the
1307
+ * enforcing side, which is the whole point of asking here.
1308
+ *
1309
+ * Named for the question, not for where the answer lives. This was called
1310
+ * `locallyAllows`, and "locally" stopped being true the moment the answer
1311
+ * came from a document somebody else signed.
1312
+ */
1313
+ readonly admits: (owner: string) => boolean;
1314
+ }
1315
+ /**
1316
+ * Decide whether a job may run on a daemon.
1317
+ *
1318
+ * Both sides must agree ({@link MUSTS.AUDIENCE_BOTH_SIDES}):
1319
+ * 1. the job's audience must admit the daemon's owner, and
1320
+ * 2. the backend's offer scope must admit the job's owner.
1321
+ *
1322
+ * The full four-way matrix (two audiences × two offer scopes) is asserted by
1323
+ * the conformance kit. The function is pure and total so both the daemon
1324
+ * and the server can run the identical rule — the daemon refuses, and the
1325
+ * server refuses too (byollm_003 §Server-side MUSTs).
1326
+ *
1327
+ * @example
1328
+ * ```ts
1329
+ * const result = matchAudience(
1330
+ * { owner: "alice", audience: "team" },
1331
+ * {
1332
+ * owner: "bob",
1333
+ * offerScope: "team",
1334
+ * cost: "free",
1335
+ * admits: (o) => o === "alice",
1336
+ * },
1337
+ * );
1338
+ * // result.ok === true
1339
+ * ```
1340
+ */
1341
+ declare function matchAudience(job: MatchJob, daemon: MatchDaemon): MatchResult;
1342
+ /**
1343
+ * Human-readable refusal text for the daemon's log and the trust UI.
1344
+ * Each refusal reads as a distinct truth — byollm_002's "four different
1345
+ * truths that must never share a message" applied to the audience axis.
1346
+ */
1347
+ declare const REFUSAL_MESSAGES: Readonly<Record<MatchRefusal, string>>;
1348
+
1349
+ /**
1350
+ * Upper bounds on payload size, enforced at the schema so oversized input is
1351
+ * refused at parse time rather than somewhere deeper.
1352
+ *
1353
+ * All three are enforced — cloud_008 Tier 4, finding 30. `maxTotalChars` was
1354
+ * declared here and referenced nowhere, under this docstring's claim that the
1355
+ * schema enforces them, so a chat payload of 256 messages at a million
1356
+ * characters each parsed cleanly at sixty-four times the stated ceiling. The
1357
+ * per-field limits were real and the aggregate one was a number in a frozen
1358
+ * object.
1359
+ *
1360
+ * byollm_004 §4 requires stricter limits for community (`team`) jobs; those
1361
+ * are applied on top of these by the daemon's budget check, which knows the
1362
+ * job's audience. These are the absolute ceilings for any job.
1363
+ */
1364
+ declare const PAYLOAD_LIMITS: Readonly<{
1365
+ /** Max characters in any single text field. */
1366
+ maxTextChars: 1000000;
1367
+ /** Max messages in an `llm.chat` conversation. */
1368
+ maxMessages: 256;
1369
+ /** Max characters across the whole payload. */
1370
+ maxTotalChars: 4000000;
1371
+ }>;
1372
+ /**
1373
+ * A conversation turn. `role` is a closed enum — it is routing *within the
1374
+ * model call*, not routing of the call, so it cannot select a backend.
1375
+ */
1376
+ declare const ChatMessage: z.ZodObject<{
1377
+ role: z.ZodEnum<{
1378
+ user: "user";
1379
+ system: "system";
1380
+ assistant: "assistant";
1381
+ }>;
1382
+ content: z.ZodString;
1383
+ }, z.core.$strict>;
1384
+ type ChatMessage = z.infer<typeof ChatMessage>;
1385
+ /**
1386
+ * Payload for `llm.generate`.
1387
+ *
1388
+ * @remarks
1389
+ * Text only, deliberately. byollm_004 §1 states the payload is "data handed
1390
+ * to a model, never configuration and never a command", so v0 carries no
1391
+ * sampling parameters, no model name, no base URL and no flags — those are
1392
+ * owner-side route config. A future `params` field with an explicit closed
1393
+ * allowlist and owner-set clamps is reserved; adding a field later is
1394
+ * non-breaking, removing one is not.
1395
+ */
1396
+ declare const GeneratePayload: z.ZodObject<{
1397
+ prompt: z.ZodString;
1398
+ system: z.ZodOptional<z.ZodString>;
1399
+ }, z.core.$strict>;
1400
+ type GeneratePayload = z.infer<typeof GeneratePayload>;
1401
+ /** Payload for `llm.chat`. Text only, for the same reason as {@link GeneratePayload}. */
1402
+ declare const ChatPayload: z.ZodObject<{
1403
+ messages: z.ZodArray<z.ZodObject<{
1404
+ role: z.ZodEnum<{
1405
+ user: "user";
1406
+ system: "system";
1407
+ assistant: "assistant";
1408
+ }>;
1409
+ content: z.ZodString;
1410
+ }, z.core.$strict>>;
1411
+ system: z.ZodOptional<z.ZodString>;
1412
+ }, z.core.$strict>;
1413
+ type ChatPayload = z.infer<typeof ChatPayload>;
1414
+ /**
1415
+ * The job kinds a v1 daemon has handlers for.
1416
+ *
1417
+ * Kinds are resolved against handlers baked into the daemon
1418
+ * ({@link MUSTS.KIND_TYPED_ONLY}); an unknown kind is refused, never guessed.
1419
+ * Adding a kind is a protocol change with its own spec and threat review —
1420
+ * notably any kind that needs tools, which byollm_004 §2 forbids as a payload
1421
+ * flag.
1422
+ */
1423
+ declare const JobKind: z.ZodEnum<{
1424
+ "llm.generate": "llm.generate";
1425
+ "llm.chat": "llm.chat";
1426
+ }>;
1427
+ type JobKind = z.infer<typeof JobKind>;
1428
+ /** All v1 job kinds. */
1429
+ declare const JOB_KINDS: readonly ("llm.generate" | "llm.chat")[];
1430
+ /** A payload discriminated by its kind. */
1431
+ declare const KindedPayload: z.ZodDiscriminatedUnion<[z.ZodObject<{
1432
+ kind: z.ZodLiteral<"llm.generate">;
1433
+ payload: z.ZodObject<{
1434
+ prompt: z.ZodString;
1435
+ system: z.ZodOptional<z.ZodString>;
1436
+ }, z.core.$strict>;
1437
+ }, z.core.$strict>, z.ZodObject<{
1438
+ kind: z.ZodLiteral<"llm.chat">;
1439
+ payload: z.ZodObject<{
1440
+ messages: z.ZodArray<z.ZodObject<{
1441
+ role: z.ZodEnum<{
1442
+ user: "user";
1443
+ system: "system";
1444
+ assistant: "assistant";
1445
+ }>;
1446
+ content: z.ZodString;
1447
+ }, z.core.$strict>>;
1448
+ system: z.ZodOptional<z.ZodString>;
1449
+ }, z.core.$strict>;
1450
+ }, z.core.$strict>], "kind">;
1451
+ type KindedPayload = z.infer<typeof KindedPayload>;
1452
+ /** The payload type for a given kind. */
1453
+ type PayloadFor<K extends JobKind> = K extends "llm.generate" ? GeneratePayload : ChatPayload;
1454
+ /** Narrow an arbitrary string to a known job kind. */
1455
+ declare function isJobKind(value: string): value is JobKind;
1456
+ /**
1457
+ * Total character weight of a payload, used by the daemon's community budget
1458
+ * check and by the server's payload-size limits.
1459
+ */
1460
+ declare function payloadTextLength(kinded: KindedPayload): number;
1461
+
1462
+ /**
1463
+ * The job lifecycle, made explicit by byollm_001 Rev 1 §D because the most
1464
+ * user-visible failure mode — "nothing is running my job" — was previously
1465
+ * unspecified.
1466
+ *
1467
+ * ```text
1468
+ * queued ──claim──▶ claimed ──start──▶ running ──▶ ok | error | canceled
1469
+ * │ │ │
1470
+ * │ └──lease expiry─────┘
1471
+ * │ ▼
1472
+ * │ queued (reclaimable, no loss)
1473
+ * └──ttl elapsed──▶ expired
1474
+ * ```
1475
+ */
1476
+ declare const JobState: z.ZodEnum<{
1477
+ error: "error";
1478
+ ok: "ok";
1479
+ expired: "expired";
1480
+ queued: "queued";
1481
+ claimed: "claimed";
1482
+ running: "running";
1483
+ canceled: "canceled";
1484
+ }>;
1485
+ type JobState = z.infer<typeof JobState>;
1486
+ /** States from which a job never moves again. */
1487
+ declare const TERMINAL_STATES: readonly ["ok", "error", "canceled", "expired"];
1488
+ /** Is this a state the job can never leave? */
1489
+ declare function isTerminal(state: JobState): boolean;
1490
+ /** May a job move from `from` to `to`? */
1491
+ declare function canTransition(from: JobState, to: JobState): boolean;
1492
+ /** A lease: the right to work on a job until `expiresAt`. */
1493
+ declare const Lease: z.ZodObject<{
1494
+ id: z.ZodString;
1495
+ runnerId: z.ZodString;
1496
+ expiresAt: z.ZodNumber;
1497
+ }, z.core.$strict>;
1498
+ type Lease = z.infer<typeof Lease>;
1499
+ /** Payload union as it appears on a job record. */
1500
+ declare const JobPayload: z.ZodUnion<readonly [z.ZodObject<{
1501
+ prompt: z.ZodString;
1502
+ system: z.ZodOptional<z.ZodString>;
1503
+ }, z.core.$strict>, z.ZodObject<{
1504
+ messages: z.ZodArray<z.ZodObject<{
1505
+ role: z.ZodEnum<{
1506
+ user: "user";
1507
+ system: "system";
1508
+ assistant: "assistant";
1509
+ }>;
1510
+ content: z.ZodString;
1511
+ }, z.core.$strict>>;
1512
+ system: z.ZodOptional<z.ZodString>;
1513
+ }, z.core.$strict>]>;
1514
+ type JobPayload = z.infer<typeof JobPayload>;
1515
+ /**
1516
+ * A job as the daemon receives it from `/byollm/claim`.
1517
+ *
1518
+ * Note what is absent: no model, no backend, no base URL, no flags, no path.
1519
+ * Those come from the machine owner's config only
1520
+ * ({@link MUSTS.NO_PAYLOAD_ROUTING}). The wire shape is the first place that
1521
+ * rule is enforced — there is no field to carry them.
1522
+ */
1523
+ declare const ClaimedJob: z.ZodObject<{
1524
+ id: z.ZodString;
1525
+ kind: z.ZodEnum<{
1526
+ "llm.generate": "llm.generate";
1527
+ "llm.chat": "llm.chat";
1528
+ }>;
1529
+ payload: z.ZodUnion<readonly [z.ZodObject<{
1530
+ prompt: z.ZodString;
1531
+ system: z.ZodOptional<z.ZodString>;
1532
+ }, z.core.$strict>, z.ZodObject<{
1533
+ messages: z.ZodArray<z.ZodObject<{
1534
+ role: z.ZodEnum<{
1535
+ user: "user";
1536
+ system: "system";
1537
+ assistant: "assistant";
1538
+ }>;
1539
+ content: z.ZodString;
1540
+ }, z.core.$strict>>;
1541
+ system: z.ZodOptional<z.ZodString>;
1542
+ }, z.core.$strict>]>;
1543
+ audience: z.ZodEnum<{
1544
+ private: "private";
1545
+ team: "team";
1546
+ }>;
1547
+ owner: z.ZodString;
1548
+ site: z.ZodOptional<z.ZodString>;
1549
+ service: z.ZodOptional<z.ZodString>;
1550
+ deadlineAt: z.ZodOptional<z.ZodNumber>;
1551
+ lease: z.ZodObject<{
1552
+ id: z.ZodString;
1553
+ runnerId: z.ZodString;
1554
+ expiresAt: z.ZodNumber;
1555
+ }, z.core.$strict>;
1556
+ }, z.core.$strict>;
1557
+ type ClaimedJob = z.infer<typeof ClaimedJob>;
1558
+ /**
1559
+ * The provenance that travels with every result to the delivery seam.
1560
+ *
1561
+ * byollm_003 Rev 1: a `team` result is attacker-controlled text.
1562
+ * The app must never render volunteer output as its own AI's answer without
1563
+ * knowing that is what it is ({@link MUSTS.PROVENANCE_NAMES_DEVICE}).
1564
+ */
1565
+ declare const ResultProvenance: z.ZodObject<{
1566
+ audience: z.ZodEnum<{
1567
+ private: "private";
1568
+ team: "team";
1569
+ }>;
1570
+ runnerId: z.ZodString;
1571
+ runnerOwner: z.ZodString;
1572
+ backendClass: z.ZodEnum<{
1573
+ http: "http";
1574
+ process: "process";
1575
+ }>;
1576
+ model: z.ZodString;
1577
+ untrusted: z.ZodBoolean;
1578
+ }, z.core.$strict>;
1579
+ type ResultProvenance = z.infer<typeof ResultProvenance>;
1580
+ /**
1581
+ * Build provenance for a completed job. `untrusted` is derived, never
1582
+ * supplied, so no caller can mark volunteer output as first-party.
1583
+ */
1584
+ declare function provenanceFor(input: {
1585
+ audience: Audience;
1586
+ runnerId: string;
1587
+ runnerOwner: string;
1588
+ backendClass: BackendClass;
1589
+ model: string;
1590
+ }): ResultProvenance;
1591
+ /**
1592
+ * What the daemon did, sealed with the answer — cloud_008 §2.5.
1593
+ *
1594
+ * These travelled in the clear on `ResultRequest`, which meant two things at
1595
+ * once. On the direct plane the site believed unauthenticated fields beside
1596
+ * an authenticated envelope — a daemon could seal one answer and *declare* it
1597
+ * came from a different model, and only the field it did not sign would be
1598
+ * recorded. Through a relay they reached a third party that acts on none of
1599
+ * them, and `model` in particular is the kind of detail Amendment A's rule
1600
+ * keeps off the wire.
1601
+ *
1602
+ * Sealed, they are the daemon's signed statement about its own run: the site
1603
+ * opens them, nothing in between sees them, and the disposition check that
1604
+ * already compares clear-text against ciphertext extends to cover them.
1605
+ */
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
+ declare const RunMetadata: z.ZodObject<{
1645
+ model: z.ZodString;
1646
+ backendClass: z.ZodEnum<{
1647
+ http: "http";
1648
+ process: "process";
1649
+ }>;
1650
+ durationMs: z.ZodNumber;
1651
+ stop: z.ZodOptional<z.ZodEnum<{
1652
+ length: "length";
1653
+ unknown: "unknown";
1654
+ end: "end";
1655
+ "stop-sequence": "stop-sequence";
1656
+ }>>;
1657
+ stopReported: z.ZodOptional<z.ZodBoolean>;
1658
+ }, z.core.$strict>;
1659
+ type RunMetadata = z.infer<typeof RunMetadata>;
1660
+ /** Successful outcome. */
1661
+ declare const JobResultOk: z.ZodObject<{
1662
+ outcome: z.ZodLiteral<"ok">;
1663
+ text: z.ZodString;
1664
+ artifactUrl: z.ZodOptional<z.ZodURL>;
1665
+ }, z.core.$strict>;
1666
+ /** Failed outcome. `code` is a stable machine string; `message` is for humans. */
1667
+ declare const JobResultError: z.ZodObject<{
1668
+ outcome: z.ZodLiteral<"error">;
1669
+ code: z.ZodString;
1670
+ message: z.ZodString;
1671
+ retryable: z.ZodBoolean;
1672
+ }, z.core.$strict>;
1673
+ /** Cancelled outcome, reported by the daemon after honoring a cancel. */
1674
+ declare const JobResultCanceled: z.ZodObject<{
1675
+ outcome: z.ZodLiteral<"canceled">;
1676
+ }, z.core.$strict>;
1677
+ declare const JobOutcome: z.ZodDiscriminatedUnion<[z.ZodObject<{
1678
+ outcome: z.ZodLiteral<"ok">;
1679
+ text: z.ZodString;
1680
+ artifactUrl: z.ZodOptional<z.ZodURL>;
1681
+ }, z.core.$strict>, z.ZodObject<{
1682
+ outcome: z.ZodLiteral<"error">;
1683
+ code: z.ZodString;
1684
+ message: z.ZodString;
1685
+ retryable: z.ZodBoolean;
1686
+ }, z.core.$strict>, z.ZodObject<{
1687
+ outcome: z.ZodLiteral<"canceled">;
1688
+ }, z.core.$strict>], "outcome">;
1689
+ type JobOutcome = z.infer<typeof JobOutcome>;
1690
+ /**
1691
+ * Why a job can never run — byollm_016 Phase B.
1692
+ *
1693
+ * Every one of these is **terminal**, and that is the whole point of naming
1694
+ * them. A job that cannot be matched used to sit queued until its deadline,
1695
+ * which reads exactly like a job that is merely waiting for a device to come
1696
+ * online — so an app could not tell "any moment now" from "never", and neither
1697
+ * could the person watching a spinner. Silence must never read as pending.
1698
+ *
1699
+ * They are decided by whoever knows first: the site's own SDK where it can see
1700
+ * the answer without asking, the router where matching happens, and the daemon
1701
+ * again on arrival under the both-sides rule. All three reason from the same
1702
+ * list rather than three private vocabularies.
1703
+ */
1704
+ declare const RefusalReason: z.ZodEnum<{
1705
+ "default-ambiguity": "default-ambiguity";
1706
+ "default-unusable": "default-unusable";
1707
+ }>;
1708
+ type RefusalReason = z.infer<typeof RefusalReason>;
1709
+ /**
1710
+ * A terminal outcome nobody sealed — byollm_016 Phase B.
1711
+ *
1712
+ * Every other finished job carries an envelope encrypted by the device that
1713
+ * ran it, which is what makes a result unforgeable. These have no device: the
1714
+ * job was refused *before* anything could run it, so there is nobody to seal
1715
+ * from and no content to seal.
1716
+ *
1717
+ * **What that costs, stated plainly.** This is the one terminal outcome a
1718
+ * router can author. It is worth being exact about the power that grants,
1719
+ * because "the relay can write this" sounds alarming until you compare it with
1720
+ * what a relay could already do: drop the job, never offer it, and let it
1721
+ * expire. A router-authored refusal is *denial of service by a shorter route*,
1722
+ * which is a power the router has always had and which the trust model has
1723
+ * always said it has. What it emphatically is **not** is forgery: this shape
1724
+ * carries no envelope and no output, so it can never be mistaken for an answer
1725
+ * a device produced. A relay still cannot fabricate a result, because that
1726
+ * needs a signature it does not hold.
1727
+ *
1728
+ * So the rule this shape enforces by construction: a refusal may deny, and may
1729
+ * never assert. Anything that claims work was *done* still comes sealed.
1730
+ */
1731
+ declare const JobRefused: z.ZodObject<{
1732
+ outcome: z.ZodLiteral<"refused">;
1733
+ reason: z.ZodEnum<{
1734
+ "default-ambiguity": "default-ambiguity";
1735
+ "default-unusable": "default-unusable";
1736
+ }>;
1737
+ message: z.ZodString;
1738
+ }, z.core.$strict>;
1739
+ type JobRefused = z.infer<typeof JobRefused>;
1740
+ /**
1741
+ * The outward text for each reason, so a message cannot vary by call site.
1742
+ *
1743
+ * The mirror image of `REFUSAL_MESSAGES` in `audience.ts`, and the contrast is
1744
+ * worth holding in one thought. That table is read by the **owner** of the
1745
+ * device, where byollm_002's rule applies — four different truths must never
1746
+ * share a message, because a person debugging their own machine needs to know
1747
+ * which one they hit. This table is read by a **requester**, where the rule
1748
+ * inverts: two different truths must share a message exactly, because the
1749
+ * difference between them is somebody else's inventory.
1750
+ *
1751
+ * Same project, opposite requirements, and confusing them is how the oracle
1752
+ * comes back. Hence a table rather than prose at the throw site: three
1753
+ * refusals written in three places drift into three slightly different
1754
+ * sentences, and "slightly different" is all an oracle needs.
1755
+ *
1756
+ * ## Published, because the drift it prevents happens outside this repo — B103
1757
+ *
1758
+ * `JobRefused` and `RefusalReason` were exported and **this was not**, so we
1759
+ * shipped the vocabulary and withheld the sentences. Nothing here constructs a
1760
+ * refusal; the producers are sites and the hub, and every one of them would
1761
+ * have written its own message for a reason code we defined.
1762
+ *
1763
+ * **That is the drift this table argues against, made inevitable by the export
1764
+ * list** — and `message` is a required field on the envelope, so each of them
1765
+ * had to write something.
1766
+ */
1767
+ declare const REFUSAL_TEXT: Readonly<Record<RefusalReason, string>>;
1768
+ /**
1769
+ * The plaintext inside a result envelope.
1770
+ *
1771
+ * The outcome and how it was produced, together, because they are one
1772
+ * statement by one signer. A site that opened only the outcome would be
1773
+ * trusting the envelope for the answer and the request body for everything
1774
+ * about it.
1775
+ */
1776
+ declare const SealedOutcome: z.ZodObject<{
1777
+ outcome: z.ZodDiscriminatedUnion<[z.ZodObject<{
1778
+ outcome: z.ZodLiteral<"ok">;
1779
+ text: z.ZodString;
1780
+ artifactUrl: z.ZodOptional<z.ZodURL>;
1781
+ }, z.core.$strict>, z.ZodObject<{
1782
+ outcome: z.ZodLiteral<"error">;
1783
+ code: z.ZodString;
1784
+ message: z.ZodString;
1785
+ retryable: z.ZodBoolean;
1786
+ }, z.core.$strict>, z.ZodObject<{
1787
+ outcome: z.ZodLiteral<"canceled">;
1788
+ }, z.core.$strict>], "outcome">;
1789
+ ran: z.ZodObject<{
1790
+ model: z.ZodString;
1791
+ backendClass: z.ZodEnum<{
1792
+ http: "http";
1793
+ process: "process";
1794
+ }>;
1795
+ durationMs: z.ZodNumber;
1796
+ stop: z.ZodOptional<z.ZodEnum<{
1797
+ length: "length";
1798
+ unknown: "unknown";
1799
+ end: "end";
1800
+ "stop-sequence": "stop-sequence";
1801
+ }>>;
1802
+ stopReported: z.ZodOptional<z.ZodBoolean>;
1803
+ }, z.core.$strict>;
1804
+ }, z.core.$strict>;
1805
+ type SealedOutcome = z.infer<typeof SealedOutcome>;
1806
+ /** A completed job as delivered to the app, provenance attached. */
1807
+ declare const DeliveredResult: z.ZodObject<{
1808
+ jobId: z.ZodString;
1809
+ state: z.ZodEnum<{
1810
+ error: "error";
1811
+ ok: "ok";
1812
+ expired: "expired";
1813
+ queued: "queued";
1814
+ claimed: "claimed";
1815
+ running: "running";
1816
+ canceled: "canceled";
1817
+ }>;
1818
+ outcome: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
1819
+ outcome: z.ZodLiteral<"ok">;
1820
+ text: z.ZodString;
1821
+ artifactUrl: z.ZodOptional<z.ZodURL>;
1822
+ }, z.core.$strict>, z.ZodObject<{
1823
+ outcome: z.ZodLiteral<"error">;
1824
+ code: z.ZodString;
1825
+ message: z.ZodString;
1826
+ retryable: z.ZodBoolean;
1827
+ }, z.core.$strict>, z.ZodObject<{
1828
+ outcome: z.ZodLiteral<"canceled">;
1829
+ }, z.core.$strict>], "outcome">>;
1830
+ provenance: z.ZodOptional<z.ZodObject<{
1831
+ audience: z.ZodEnum<{
1832
+ private: "private";
1833
+ team: "team";
1834
+ }>;
1835
+ runnerId: z.ZodString;
1836
+ runnerOwner: z.ZodString;
1837
+ backendClass: z.ZodEnum<{
1838
+ http: "http";
1839
+ process: "process";
1840
+ }>;
1841
+ model: z.ZodString;
1842
+ untrusted: z.ZodBoolean;
1843
+ }, z.core.$strict>>;
1844
+ fallback: z.ZodOptional<z.ZodLiteral<true>>;
1845
+ }, z.core.$strict>;
1846
+ type DeliveredResult = z.infer<typeof DeliveredResult>;
1847
+ /** Its members, derived — see {@link BACKEND_CLASSES} for why. */
1848
+ declare const SIZE_CLASSES: readonly ("small" | "medium" | "large" | "unbounded")[];
1849
+ /**
1850
+ * How big a payload is, in buckets — byollm_009 §6.
1851
+ *
1852
+ * A relay routes without reading, and matching a job to a machine needs some
1853
+ * notion of size. Buckets rather than byte counts because the exact figure is
1854
+ * a stronger fingerprint than the routing decision requires, and because a
1855
+ * bucket survives compression and encoding changes that an exact count does
1856
+ * not.
1857
+ *
1858
+ * **Two grains, on purpose — ratified 2026-08-28.** Metering a
1859
+ * GB-denominated plan needs real totals, and this is deliberately not where
1860
+ * they come from: exact bytes exist only as increment-only *monthly*
1861
+ * aggregates, and no per-job byte figure is ever persisted anywhere. The
1862
+ * record needs vagueness and the meter needs totals; neither borrows the
1863
+ * other's grain, which is why the consent screen's "roughly how big" stays
1864
+ * exactly true of everything retained about a job. If you are here because
1865
+ * you need a number, the aggregate is the one to reach for — adding a byte
1866
+ * count to this envelope would trade a promise for a convenience.
1867
+ *
1868
+ * `unbounded` exists for streamed jobs, which have no size when they start.
1869
+ * It is reserved now rather than added later: byollm_009 §8.1 — adding a
1870
+ * field to a published envelope is the v2 break all over again.
1871
+ */
1872
+ declare const SizeClass: z.ZodEnum<{
1873
+ small: "small";
1874
+ medium: "medium";
1875
+ large: "large";
1876
+ unbounded: "unbounded";
1877
+ }>;
1878
+ type SizeClass = z.infer<typeof SizeClass>;
1879
+ /**
1880
+ * The most one envelope may be, in bytes — **6 MiB, ruled 2026-09-10.**
1881
+ *
1882
+ * ## Why six, which is two sentences and neither is about capacity
1883
+ *
1884
+ * Todd, 09-10: *"6 MB solves for just text and people don't try to push
1885
+ * images. We will add R2 for multimodal later."* **The cap is a SHAPE
1886
+ * decision** — it makes the envelope the wrong tool for a photo, which is the
1887
+ * point, because the right tool for a photo is object storage and a reference
1888
+ * to it rather than a bigger pipe.
1889
+ *
1890
+ * And the half that makes it aligned rather than merely chosen: **6 MiB sits
1891
+ * under a hosted box's memory and bandwidth limits.** A box is 320 MiB of RAM;
1892
+ * a 10 MiB envelope buffered is a real fraction of it. **Six is the number at
1893
+ * which the smallest thing we sell can hold the largest thing we accept.**
1894
+ *
1895
+ * Both sentences are here because a number without them is a number the next
1896
+ * person rounds up. It was 10 MiB from 2026-08-28 until this ruling.
1897
+ *
1898
+ * A **relay-memory safety rail**, not a plan feature: every tier has the same
1899
+ * ceiling, and differentiating tiers on it would be selling a safety limit as
1900
+ * a benefit. What it bounds is any single job, so no one message can make the
1901
+ * relay hold an unbounded amount of somebody else's memory.
1902
+ *
1903
+ * ## It stores nothing, and that is the design
1904
+ *
1905
+ * Enforced at ingress by refusing before acceptance, in both directions. A
1906
+ * ceiling on what the relay already has in hand needs no schema and no record:
1907
+ * the size is known for the length of the check and then it is gone. This
1908
+ * matters because the alternative — recording a size to enforce a limit
1909
+ * against — is precisely the per-job byte figure the metering ruling exists to
1910
+ * not have.
1911
+ *
1912
+ * ## Measured on the serialised envelope
1913
+ *
1914
+ * The same quantity the monthly rollup counts, deliberately. The relay stores
1915
+ * the serialised envelope and the meter measures what it stored, so a cap on
1916
+ * anything else — the ciphertext alone, the decoded length — would mean the
1917
+ * limit and the bill disagreed about what a byte is, and a job could be small
1918
+ * enough to accept and larger than it was charged as.
1919
+ */
1920
+ declare const MAX_ENVELOPE_BYTES: number;
1921
+ /**
1922
+ * How big an envelope is, by the one measure that counts it.
1923
+ *
1924
+ * `JSON.stringify` because that is what the store persists and therefore what
1925
+ * the meter measures. Length in UTF-16 code units rather than encoded bytes:
1926
+ * it is the same number the store's own `HSTRLEN` reports, and the point of
1927
+ * this function is that one number answers both questions.
1928
+ */
1929
+ declare function envelopeBytes(envelope: unknown): number;
1930
+ /**
1931
+ * A size somebody can act on, rounded **up** and only ever up.
1932
+ *
1933
+ * The rounding rule, in one place, because it has now been got wrong twice —
1934
+ * B072. `toFixed` rounds to nearest, so a message one byte over the line
1935
+ * printed "this message is 10.5 MB and the limit is 10.5 MB": a refusal that
1936
+ * reads as a contradiction, given to somebody who now has no idea what to
1937
+ * change.
1938
+ *
1939
+ * The relay found that, fixed it, and wrote the reasoning down beside the
1940
+ * fix. The SDK's refusal then rediscovered the identical bug, because it
1941
+ * copied the SENTENCE rather than the function — which is the same shape as
1942
+ * `MAX_BODY_BYTES` diverging from `MAX_ENVELOPE_BYTES`, and the same answer:
1943
+ * neither side holds the rule.
1944
+ *
1945
+ * Up is also the honest direction. Understating how far over a message is
1946
+ * sends somebody to trim a hundred bytes off something that needs to lose a
1947
+ * megabyte; overstating by a tenth costs them nothing.
1948
+ */
1949
+ declare function describeBytes(bytes: number): string;
1950
+ /**
1951
+ * What a message that is too big is told, minus anything about pricing.
1952
+ *
1953
+ * Shared because both planes refuse the same thing for the same reason. What
1954
+ * is NOT shared is the relay's "every plan has the same ceiling" — a hosted
1955
+ * sentence, and meaningless to somebody self-hosting the direct lane, where
1956
+ * there are no plans. One rule, two audiences: the rule travels, the words
1957
+ * about our billing do not.
1958
+ */
1959
+ declare function tooLargeMessage(input: {
1960
+ readonly bytes: number;
1961
+ readonly limit: number;
1962
+ }): string;
1963
+ /** Where the bucket boundaries sit, in characters of payload text. */
1964
+ declare const SIZE_CLASS_LIMITS: Readonly<{
1965
+ small: 4000;
1966
+ medium: 64000;
1967
+ large: number;
1968
+ }>;
1969
+ /**
1970
+ * The most a payload in this bucket can be.
1971
+ *
1972
+ * Used where a decision must be made from a stub, before the payload has been
1973
+ * fetched — a budget check, for instance. Charging the bucket's ceiling is the
1974
+ * conservative direction: it refuses slightly too eagerly rather than
1975
+ * admitting work that turns out larger than the budget allowed.
1976
+ *
1977
+ * `unbounded` returns `Infinity`, which fails every ceiling. That is correct
1978
+ * until byollm_006 defines how a streamed job is budgeted — failing closed on
1979
+ * a case nobody has designed beats inventing an allowance for it.
1980
+ */
1981
+ declare function sizeClassCeiling(sizeClass: SizeClass): number;
1982
+ /** Bucket a payload by its text length. */
1983
+ declare function sizeClassOf(textChars: number): SizeClass;
1984
+ /**
1985
+ * Everything an upstream may see about a job — byollm_009 §6.
1986
+ *
1987
+ * **This list is exhaustive and normative.** It is a commitment about the
1988
+ * metadata surface, not an accident of what the implementation happens to
1989
+ * send: an upstream that requires more has exceeded the protocol, and an
1990
+ * endpoint that emits more has leaked past it
1991
+ * ({@link MUSTS.STUB_METADATA_EXHAUSTIVE}).
1992
+ *
1993
+ * What is absent is the point. No payload, no model, no prompt, no result.
1994
+ * `kind` is here because capability matching happens upstream; if a later
1995
+ * revision moves matching to the daemon, `kind` moves into the ciphertext.
1996
+ */
1997
+ declare const JobStub: z.ZodObject<{
1998
+ id: z.ZodString;
1999
+ kind: z.ZodEnum<{
2000
+ "llm.generate": "llm.generate";
2001
+ "llm.chat": "llm.chat";
2002
+ }>;
2003
+ owner: z.ZodString;
2004
+ site: z.ZodString;
2005
+ audience: z.ZodEnum<{
2006
+ private: "private";
2007
+ team: "team";
2008
+ }>;
2009
+ purpose: z.ZodOptional<z.ZodString>;
2010
+ sizeClass: z.ZodEnum<{
2011
+ small: "small";
2012
+ medium: "medium";
2013
+ large: "large";
2014
+ unbounded: "unbounded";
2015
+ }>;
2016
+ streaming: z.ZodBoolean;
2017
+ deadlineAt: z.ZodNumber;
2018
+ }, z.core.$strict>;
2019
+ type JobStub = z.infer<typeof JobStub>;
2020
+ /**
2021
+ * A stub, plus the lease the claiming runner now holds for it — and, on a
2022
+ * relayed route, the grant that says it may run at all.
2023
+ *
2024
+ * The grant lives here rather than on {@link JobStub} because of *when* it is
2025
+ * authored. A stub exists from enqueue; a grant is written at claim, against
2026
+ * the membership and mapping true at that moment. That timing is the whole of
2027
+ * Amendment J: a job queued yesterday for somebody removed this morning gets
2028
+ * no grant when it is finally claimed, and a roster held on the device could
2029
+ * never have known.
2030
+ *
2031
+ * Optional, and the absence is meaningful rather than lenient. A device that
2032
+ * pinned a control-plane key at pairing **requires** one — a claimed job
2033
+ * arriving without it is refused, not admitted by default. A device that
2034
+ * pinned none is in direct mode, where there is no control plane to author
2035
+ * anything and the owner's own work is the only work that runs.
2036
+ */
2037
+ declare const ClaimedStub: z.ZodObject<{
2038
+ id: z.ZodString;
2039
+ kind: z.ZodEnum<{
2040
+ "llm.generate": "llm.generate";
2041
+ "llm.chat": "llm.chat";
2042
+ }>;
2043
+ owner: z.ZodString;
2044
+ site: z.ZodString;
2045
+ audience: z.ZodEnum<{
2046
+ private: "private";
2047
+ team: "team";
2048
+ }>;
2049
+ purpose: z.ZodOptional<z.ZodString>;
2050
+ sizeClass: z.ZodEnum<{
2051
+ small: "small";
2052
+ medium: "medium";
2053
+ large: "large";
2054
+ unbounded: "unbounded";
2055
+ }>;
2056
+ streaming: z.ZodBoolean;
2057
+ deadlineAt: z.ZodNumber;
2058
+ lease: z.ZodObject<{
2059
+ id: z.ZodString;
2060
+ runnerId: z.ZodString;
2061
+ expiresAt: z.ZodNumber;
2062
+ }, z.core.$strict>;
2063
+ grant: z.ZodOptional<z.ZodObject<{
2064
+ grantId: z.ZodString;
2065
+ jobId: z.ZodString;
2066
+ site: z.ZodString;
2067
+ user: z.ZodString;
2068
+ owner: z.ZodString;
2069
+ purpose: z.ZodString;
2070
+ kind: z.ZodString;
2071
+ service: z.ZodString;
2072
+ issuedAt: z.ZodNumber;
2073
+ signature: z.ZodString;
2074
+ }, z.core.$strict>>;
2075
+ }, z.core.$strict>;
2076
+ type ClaimedStub = z.infer<typeof ClaimedStub>;
2077
+
2078
+ /**
2079
+ * Request signing — byollm_009 §4.2.
2080
+ *
2081
+ * Every authenticated call is signed by the calling device's identity key.
2082
+ * There is no bearer token on the daemon plane: possession of a file no
2083
+ * longer grants access, possession of a *key* does, and the key never leaves
2084
+ * the machine.
2085
+ *
2086
+ * ## Why this is not the server-issued nonce the spec first described
2087
+ *
2088
+ * byollm_009 §4.2 says "the upstream issues a nonce; the daemon signs it".
2089
+ * Implementing that costs one of two things: a round trip before every
2090
+ * request, or server-side session state — and sessions reintroduce a bearer
2091
+ * credential, which is the thing being removed.
2092
+ *
2093
+ * Signing *the request itself* gets the same property without either, because
2094
+ * of something the protocol already guarantees. A captured signature is valid
2095
+ * only for the exact request it covers — same endpoint, same runner, same
2096
+ * body — and every authenticated endpoint here is idempotent by design:
2097
+ * `RESULT_IDEMPOTENT` makes a replayed result a no-op, a replayed claim from
2098
+ * the same runner returns what that runner already holds, and heartbeat and
2099
+ * release are idempotent in effect. So a replay inside the freshness window
2100
+ * gains an attacker nothing they could not obtain by forwarding the original,
2101
+ * which a relay can do anyway.
2102
+ *
2103
+ * That is the whole argument, and it is worth stating because it rests
2104
+ * entirely on the endpoints being idempotent. Two ways that can fail, and the
2105
+ * second is the one that actually bit:
2106
+ *
2107
+ * 1. **A future endpoint that is not idempotent cannot use this scheme
2108
+ * unchanged** — it would need a server-issued nonce.
2109
+ * 2. **Idempotence must hold per *addressed instance*, not per endpoint.** A
2110
+ * request that names a mutable target — a lease, a session, a
2111
+ * subscription — must name the *instance*, or a replay lands on a
2112
+ * different one than the sender meant and the endpoint's idempotence buys
2113
+ * nothing. `release` was idempotent per lease and ambiguous across them:
2114
+ * it named a job and a runner, both of which survive a
2115
+ * claim-release-reclaim cycle, so a replayed release yanked a later grant.
2116
+ * Fixed by giving a lease its own id and requiring it.
2117
+ *
2118
+ * The rule for anything added later: if a signed request can be replayed onto
2119
+ * a target that has changed underneath it, the request has to say which
2120
+ * target it meant.
2121
+ */
2122
+ /** How far a request's timestamp may be from the server's clock. */
2123
+ declare const MAX_CLOCK_SKEW_MS = 120000;
2124
+ /** The signed material a request carries. */
2125
+ declare const RequestSignature: z.ZodObject<{
2126
+ runnerId: z.ZodString;
2127
+ issuedAt: z.ZodNumber;
2128
+ signature: z.ZodString;
2129
+ }, z.core.$strict>;
2130
+ type RequestSignature = z.infer<typeof RequestSignature>;
2131
+ /**
2132
+ * The exact bytes both sides sign and verify.
2133
+ *
2134
+ * Newline-separated with a version prefix and a domain separator. Every field
2135
+ * that decides what the request *does* is in here: leave one out and it
2136
+ * becomes something an intermediary can change without breaking the
2137
+ * signature.
2138
+ *
2139
+ * The body is included by hash rather than by value, so signing does not
2140
+ * depend on both sides serialising JSON identically — which they would not.
2141
+ */
2142
+ declare function canonicalRequest(input: {
2143
+ endpoint: string;
2144
+ runnerId: string;
2145
+ issuedAt: number;
2146
+ body: string;
2147
+ }): Buffer;
2148
+ /** Sign an outgoing request with this machine's identity key. */
2149
+ declare function signRequest(keys: StoredKeys, input: {
2150
+ endpoint: string;
2151
+ runnerId: string;
2152
+ issuedAt: number;
2153
+ body: string;
2154
+ }): RequestSignature;
2155
+ /**
2156
+ * The same scheme, for the party at the other end: a **site** calling a relay.
2157
+ *
2158
+ * A site talking to a relay is in exactly the daemon's position — an outbound
2159
+ * caller with an identity keypair the other side already pins — so it gets the
2160
+ * daemon's authentication rather than a second scheme. Bearer tokens for the
2161
+ * site plane were the alternative, and they would have reintroduced the
2162
+ * credential-in-a-file that §4.2 removed from the daemon plane, on the plane
2163
+ * that carries *every* site's traffic.
2164
+ *
2165
+ * Two things make this safe to build on the same canonical string:
2166
+ *
2167
+ * 1. **The endpoint is namespaced.** Site endpoints sign `site/enqueue`, never
2168
+ * `enqueue`. The daemon plane's `result` and the site plane's `results` are
2169
+ * one character apart, and a naming collision between planes must not be
2170
+ * what stands between a signature and a replay onto the wrong handler. The
2171
+ * prefix is applied *inside* these helpers, so the two ends cannot disagree
2172
+ * about it — the alternative is two implementations of one bound value,
2173
+ * which is this project's most-repeated bug.
2174
+ * 2. **The caller slot carries the site id.** `canonicalRequest` names that
2175
+ * field `runnerId` because the daemon plane got there first; here it holds
2176
+ * the site id, and the verifier looks the key up in the projection's site
2177
+ * registry rather than its device registry. The two registries never share
2178
+ * an entry, so a device signature cannot authenticate as a site.
2179
+ *
2180
+ * §4.2's replay argument carries over **only because the site plane's writes
2181
+ * are idempotent per addressed instance**, which is a property that had to be
2182
+ * built rather than found: `enqueue` reset a job of the same id, so a replayed
2183
+ * enqueue inside the freshness window returned a claimed job to the queue and
2184
+ * threw away a device's live lease. Identical in shape to the `release` bug
2185
+ * above, on the other plane. Anything added to the site plane later must be
2186
+ * idempotent by the instance it names, or this scheme does not cover it.
2187
+ */
2188
+ declare function signSiteRequest(keys: StoredKeys, input: {
2189
+ endpoint: string;
2190
+ siteId: string;
2191
+ issuedAt: number;
2192
+ body: string;
2193
+ }): RequestSignature;
2194
+ /** Verify a site's call against the identity the control plane registered. */
2195
+ declare function verifySiteRequest(input: {
2196
+ identityPublic: string;
2197
+ endpoint: string;
2198
+ body: string;
2199
+ signature: RequestSignature;
2200
+ now: number;
2201
+ maxSkewMs?: number;
2202
+ }): SignatureFailure | null;
2203
+ /**
2204
+ * Why a signed request was refused.
2205
+ *
2206
+ * **`bad-signature` is never returned verbatim; `stale` is, deliberately.**
2207
+ * They are different kinds of refusal and conflating them costs a real user
2208
+ * more than it costs an attacker.
2209
+ *
2210
+ * A bad signature is an authentication failure and the server says only
2211
+ * "unauthorized" — telling a prober which part they got wrong is free help.
2212
+ *
2213
+ * A stale timestamp is a **precondition** failure: the signature may be
2214
+ * perfectly valid and the caller's clock is simply wrong. Saying so reveals
2215
+ * nothing, for two reasons that both have to hold. The server's time is
2216
+ * already public — every response carries a `Date` header and the heartbeat
2217
+ * response returns `serverTime` outright. And freshness is checked *before*
2218
+ * the signature is verified, so a stale answer says nothing about whether the
2219
+ * signature was any good.
2220
+ *
2221
+ * What conflating them costs: a machine whose clock has drifted gets
2222
+ * `401 unauthorized` on every request, forever, with nothing anywhere pointing
2223
+ * at the clock. That is the shape byollm_013 was filed about — a refusal that
2224
+ * is correct, silent, and sends somebody to read our source.
2225
+ */
2226
+ type SignatureFailure = "stale" | "bad-signature";
2227
+ /**
2228
+ * Verify a signed request against a runner's pinned identity key.
2229
+ *
2230
+ * Freshness is checked in **both** directions. A clock far ahead is as much a
2231
+ * problem as one behind: it would let a captured request stay replayable long
2232
+ * after it was made, which is the one thing the window exists to bound.
2233
+ */
2234
+ declare function verifyRequest(input: {
2235
+ identityPublic: string;
2236
+ endpoint: string;
2237
+ body: string;
2238
+ signature: RequestSignature;
2239
+ now: number;
2240
+ maxSkewMs?: number;
2241
+ }): SignatureFailure | null;
2242
+
2243
+ /**
2244
+ * What a site says it needs — byollm_016 Amendment L.
2245
+ *
2246
+ * A site declares **purposes**, and each purpose lists the job kinds it uses.
2247
+ * A person then maps each purpose to one of their own services, on the consent
2248
+ * screen, and that mapping *is* the consent. The control plane joins the two
2249
+ * at claim time and signs the result into a grant.
2250
+ *
2251
+ * ## Why a site declares needs instead of naming services
2252
+ *
2253
+ * Because it cannot name one. The site's vocabulary is its own purposes; the
2254
+ * person's vocabulary is their services; and the two never meet. A site asks
2255
+ * for "writing assistant, llm.chat" and learns only whether that slot is
2256
+ * satisfiable — never which model answered, never whose machine, never even
2257
+ * the name of the service. Key-vs-value reaches its strongest form here: the
2258
+ * site cannot describe what it wants *or* name it, only ask for what it
2259
+ * declared.
2260
+ *
2261
+ * ## Keys are ids; labels are prose
2262
+ *
2263
+ * They are separate fields and nothing derives one from the other, which is
2264
+ * the amendment's ruling and worth restating where somebody will read it. A
2265
+ * key travels on every job and is what mappings are stored against, so it is
2266
+ * stable-or-nothing: renaming one deletes a purpose and creates another,
2267
+ * unmapping everybody who had chosen for it. A label is changeable whenever
2268
+ * the site likes and is the **only** thing a consent screen renders.
2269
+ */
2270
+ /**
2271
+ * The purpose a site gets when it declares no purposes of its own.
2272
+ *
2273
+ * Reserved, and refused by {@link Manifest} rather than by whatever handles
2274
+ * registration. A site with a single undifferentiated use has one purpose —
2275
+ * everything it does — and that purpose needs an id because mappings are
2276
+ * keyed by one. An id taken from the site's own vocabulary would collide the
2277
+ * day it declared a real purpose of the same name.
2278
+ *
2279
+ * **Never rendered.** "default → your Claude" tells a person nothing; a
2280
+ * consent screen shows the site's own name for this slot, because that is
2281
+ * what a single-purpose site's one purpose actually is.
2282
+ */
2283
+ declare const RESERVED_PURPOSE = "default";
2284
+ declare const Purpose: z.ZodObject<{
2285
+ label: z.ZodString;
2286
+ description: z.ZodOptional<z.ZodString>;
2287
+ kinds: z.ZodArray<z.ZodEnum<{
2288
+ "llm.generate": "llm.generate";
2289
+ "llm.chat": "llm.chat";
2290
+ }>>;
2291
+ }, z.core.$strict>;
2292
+ type Purpose = z.infer<typeof Purpose>;
2293
+ /**
2294
+ * Everything a site needs, by purpose key.
2295
+ *
2296
+ * At least one purpose: a site that declares none is a site that can enqueue
2297
+ * nothing, and accepting it would mean the first refusal a person saw came
2298
+ * from a job rather than from registration.
2299
+ */
2300
+ /**
2301
+ * How many purposes one site may declare.
2302
+ *
2303
+ * There was no bound at all: a site could declare fifty thousand, each one
2304
+ * individually valid, and the consent screen renders a slot per (purpose,
2305
+ * kind) — so the page that *is* the consent mechanism becomes unusable, and
2306
+ * the notification mail that enumerates slots grows with it.
2307
+ *
2308
+ * Thirty-two is chosen rather than derived, and the number is an argument: a
2309
+ * purpose is a thing a person reads and decides about one at a time, and a
2310
+ * screen asking more than about thirty separate questions has stopped being a
2311
+ * consent screen whatever it renders. Of Tomorrow Press declares five. A site
2312
+ * that genuinely needs more has a product question to answer before it has a
2313
+ * schema one.
2314
+ */
2315
+ declare const MAX_PURPOSES = 32;
2316
+ declare const Manifest: z.ZodRecord<z.ZodString, z.ZodObject<{
2317
+ label: z.ZodString;
2318
+ description: z.ZodOptional<z.ZodString>;
2319
+ kinds: z.ZodArray<z.ZodEnum<{
2320
+ "llm.generate": "llm.generate";
2321
+ "llm.chat": "llm.chat";
2322
+ }>>;
2323
+ }, z.core.$strict>>;
2324
+ type Manifest = z.infer<typeof Manifest>;
2325
+ /**
2326
+ * The manifest a site with no declared purposes is treated as having.
2327
+ *
2328
+ * The sugar in Amendment L, made explicit rather than special-cased
2329
+ * downstream: everything after this point sees a manifest with one purpose,
2330
+ * so no consent screen, mapping table or resolver needs a branch for the
2331
+ * flat-list case.
2332
+ *
2333
+ * The label is the caller's — a site's own name — because it is the one thing
2334
+ * that can make "everything this site does" read as a sentence about a
2335
+ * particular site rather than about software in general.
2336
+ */
2337
+ declare function singlePurposeManifest(input: {
2338
+ readonly label: string;
2339
+ readonly kinds: readonly JobKind[];
2340
+ }): Manifest;
2341
+
2342
+ /**
2343
+ * One job, one signature, one answer — byollm_016 Amendment J.
2344
+ *
2345
+ * A grant is the control plane's signed statement that a particular job may
2346
+ * run on a particular device, authored at claim time and verified against the
2347
+ * key that device pinned when it paired.
2348
+ *
2349
+ * ## What it replaced, and why the replacement is smaller
2350
+ *
2351
+ * Until 2026-08-26 a device held a signed **roster** and answered admission
2352
+ * from it. Amendment G's four properties were right and the mechanism was a
2353
+ * cache — one that bought nothing. On the cloud route the job path and the
2354
+ * roster path share fate: jobs arrive through the relay, so if the relay is
2355
+ * unreachable there are no jobs to admit and a locally held roster adds no
2356
+ * availability. What it did add was staleness, which is the only reason
2357
+ * `ROSTER_MAX_AGE_MS` existed: a bound on how long a removed person keeps
2358
+ * running. Authoring at claim collapses that bound to this document's own
2359
+ * lifetime — add somebody and their next job runs, remove them and their next
2360
+ * claim fails, including jobs already queued.
2361
+ *
2362
+ * It also collapses four questions into one signature. Consented, member,
2363
+ * admitted, and *which service* were four mechanisms answering separately;
2364
+ * they are now four fields of one statement, and the device verifies once.
2365
+ *
2366
+ * ## What it is not
2367
+ *
2368
+ * Amendment G property 1 outlawed admitting on a per-job assertion, and this
2369
+ * is per-job. The distinction is authorship: G outlawed trusting the
2370
+ * **relay's or site's unsigned** claim. A grant is signed by the control
2371
+ * plane with a key the device pinned at pairing, so the relay can withhold it
2372
+ * and cannot forge it — exactly the power a relay has over a job.
2373
+ * `RELAY_BLIND` is untouched: the relay delivers, it never authors.
2374
+ *
2375
+ * ## What the device still checks for itself
2376
+ *
2377
+ * A grant is necessary and not sufficient. Four checks stay on the device and
2378
+ * none of them is delegated:
2379
+ *
2380
+ * 1. the signature, against the pinned key;
2381
+ * 2. replay — {@link SignedGrant.grantId} is single-use;
2382
+ * 3. offer-consistency — the named service is one this device actually
2383
+ * offers, at a scope that includes this user;
2384
+ * 4. **private is absolute** — a `private` service runs for the paired owner
2385
+ * and nobody else, so no compromise of a control plane can grant somebody
2386
+ * else's job onto it.
2387
+ */
2388
+ /**
2389
+ * How long a grant is honoured after it was signed. Ruled 120s (2026-08-26).
2390
+ *
2391
+ * This bounds **acceptance**, not execution: a job admitted inside the window
2392
+ * runs to completion however long it takes. So the number only has to cover
2393
+ * the trip from the control plane signing to the device checking — claim,
2394
+ * deliver, verify — and every second past that is a second a captured grant
2395
+ * stays useful.
2396
+ *
2397
+ * Two minutes is generous for that trip and mean for the capture. It is also
2398
+ * the number ordinary clock drift is measured against, which is why
2399
+ * {@link CLOCK_SKEW_WARN_MS} sits well inside it: a device whose clock is off
2400
+ * by half the window would refuse real work, and must be told before it does.
2401
+ *
2402
+ * The verifier's policy, deliberately not a field on the document. An
2403
+ * `expiresAt` the signer chose would let whoever signs decide how long their
2404
+ * own statement stays good, and the party with the most reason to want a
2405
+ * longer window is the party being bounded.
2406
+ */
2407
+ declare const GRANT_MAX_AGE_MS = 120000;
2408
+ /**
2409
+ * Clock disagreement past which a device says so, before it starts refusing.
2410
+ *
2411
+ * Skew eats {@link GRANT_MAX_AGE_MS} directly — a device 60s behind its
2412
+ * relay's clock has half a window left, and one 120s behind has none and
2413
+ * refuses everything for a reason no refusal message would otherwise name.
2414
+ * Thirty seconds is a quarter of the window: far enough out to be a real
2415
+ * problem, early enough to be a warning rather than an outage.
2416
+ */
2417
+ declare const CLOCK_SKEW_WARN_MS = 30000;
2418
+ /**
2419
+ * Skew past which a freshness refusal names the clock instead of the grant.
2420
+ *
2421
+ * Five seconds, because below that the clock is not the story and saying so
2422
+ * would send somebody to check ntp about an unrelated failure. Above it, "this
2423
+ * grant expired" and "your clock is wrong" are the same event wearing
2424
+ * different words, and only one of them can be acted on.
2425
+ */
2426
+ declare const CLOCK_ATTRIBUTION_MS = 5000;
2427
+ /**
2428
+ * The domain separator.
2429
+ *
2430
+ * Every signature in this system says what kind of statement it is before it
2431
+ * says anything else. Without it, bytes signed for one purpose verify for
2432
+ * another — a grant and a request are both "bytes this key signed", and a
2433
+ * scheme that could not tell them apart would let one be replayed as the
2434
+ * other.
2435
+ */
2436
+ declare const GRANT_CONTEXT = "byollm/v1/grant";
2437
+ declare const SignedGrant: z.ZodObject<{
2438
+ grantId: z.ZodString;
2439
+ jobId: z.ZodString;
2440
+ site: z.ZodString;
2441
+ user: z.ZodString;
2442
+ owner: z.ZodString;
2443
+ purpose: z.ZodString;
2444
+ kind: z.ZodString;
2445
+ service: z.ZodString;
2446
+ issuedAt: z.ZodNumber;
2447
+ signature: z.ZodString;
2448
+ }, z.core.$strict>;
2449
+ type SignedGrant = z.infer<typeof SignedGrant>;
2450
+ /** Everything a grant says, before it is signed. */
2451
+ type GrantClaims = Omit<SignedGrant, "signature">;
2452
+ /**
2453
+ * Every field of {@link SignedGrant} except the signature, sorted.
2454
+ *
2455
+ * **Derived from the schema, never written out by hand.** The unsigned-field
2456
+ * attack is that somebody adds a field to the document, forgets to add it to
2457
+ * the bytes, and ships a value an intermediary can rewrite without breaking
2458
+ * any signature. A hand-maintained list is exactly the shape that fails: it
2459
+ * does not grow when the code does, and nothing about adding a field reminds
2460
+ * you it exists.
2461
+ *
2462
+ * Reading the shape closes it structurally rather than by review. A new field
2463
+ * is signed the moment it is declared, and grant.test.ts asserts this list
2464
+ * still covers the schema so a future zod version that hides `shape` fails
2465
+ * loudly instead of silently signing less.
2466
+ */
2467
+ declare const GRANT_SIGNED_FIELDS: readonly (keyof GrantClaims)[];
2468
+ /**
2469
+ * The exact bytes both sides sign and verify.
2470
+ *
2471
+ * JSON-encoded rather than joined with a separator, because a separator can
2472
+ * be imitated. Newline-joining `["a", "b\nc"]` and `["a\nb", "c"]` produces
2473
+ * identical bytes, so two different grants would share a signature — and the
2474
+ * values here include a site id and a user id, at least one of which comes
2475
+ * from somebody else's namespace. JSON escapes the separator it uses, so no
2476
+ * arrangement of field values can spell a different document.
2477
+ *
2478
+ * The context string leads, and the field order is the schema's own sorted
2479
+ * keys, so the encoding is canonical without anyone maintaining a list.
2480
+ */
2481
+ declare function grantStatement(claims: GrantClaims): Uint8Array;
2482
+ /** Sign a grant with the control plane's own key. */
2483
+ declare function signGrant(keys: Pick<StoredKeys, "identityPrivate">, claims: GrantClaims): SignedGrant;
2484
+ /**
2485
+ * Why a grant was refused.
2486
+ *
2487
+ * Split by remedy, because these send somebody to different places: fix your
2488
+ * clock, take it up with the relay, or nothing at all — you are being
2489
+ * attacked and the refusal worked.
2490
+ *
2491
+ * There is deliberately no `no-pinned-key` here. A device that pinned no
2492
+ * control-plane key never reaches this function: it is in direct mode, and
2493
+ * the question "is this grant good" does not arise. A value nothing can
2494
+ * return is a branch every caller has to handle and no test can reach.
2495
+ */
2496
+ type GrantRefusal =
2497
+ /** The signature does not verify against the pinned key. */
2498
+ "bad-signature"
2499
+ /** Genuine, and for a different device's owner. */
2500
+ | "wrong-owner"
2501
+ /** Genuine, and lifted from a different job. */
2502
+ | "wrong-job"
2503
+ /** Older than {@link GRANT_MAX_AGE_MS}. */
2504
+ | "expired"
2505
+ /**
2506
+ * Issued further in the future than clock drift explains.
2507
+ *
2508
+ * Checked, and not as pedantry: an `issuedAt` ahead of now extends a
2509
+ * grant's life past the bound, which is the whole thing being enforced.
2510
+ *
2511
+ * Tolerant by {@link CLOCK_SKEW_WARN_MS}, because it was tolerant by
2512
+ * nothing and that made ordinary drift a total outage — see
2513
+ * {@link verifyGrant}.
2514
+ */
2515
+ | "from-the-future";
2516
+ /**
2517
+ * Is this grant one this device may act on, right now?
2518
+ *
2519
+ * Document-level checks only. Replay, offer-consistency and the private rule
2520
+ * need state this function does not have and are the device's to apply — see
2521
+ * the class comment for the full list of four.
2522
+ */
2523
+ declare function verifyGrant(input: {
2524
+ grant: SignedGrant;
2525
+ owner: string;
2526
+ jobId: string;
2527
+ controlPlanePublic: string;
2528
+ now: number;
2529
+ maxAgeMs?: number;
2530
+ }): GrantRefusal | null;
2531
+
2532
+ /**
2533
+ * Rotation — byollm_009 Amendment C.
2534
+ *
2535
+ * A site holding identity key **K1** wants to be known by **K2**. It publishes
2536
+ * a *succession*: K2, plus a signature by K1 over a statement naming both key
2537
+ * ids. That signature is the entire mechanism, and the reason rotation can be
2538
+ * automatic without becoming a hole is that **the relay cannot mint one** — it
2539
+ * never holds K1. It is the same trust step a daemon already performs at
2540
+ * pairing, applied to the site's own succession.
2541
+ *
2542
+ * ## Why the statement names both keys
2543
+ *
2544
+ * A signature over K2 alone could be lifted from this site's record and
2545
+ * replayed into another site's, moving *that* site to K2 — a key the attacker
2546
+ * holds. Naming the predecessor binds the succession to one chain, and it is
2547
+ * the reason `verifyLink` takes the id it expects to be succeeding from
2548
+ * rather than reading it out of the statement it is checking.
2549
+ */
2550
+ /** The domain separator. Distinct from every other thing an identity signs. */
2551
+ declare const SUCCESSION_CONTEXT = "byollm/v1/site-succession";
2552
+ /**
2553
+ * How long a retired key may still sign work — Amendment C, ruling 2.
2554
+ *
2555
+ * A protocol constant and not the site's to choose. Per-site overlap
2556
+ * arithmetic is exactly the kind of number that has to mean one thing
2557
+ * everywhere, and a site that could choose it could choose *forever*, which is
2558
+ * a two-key site permanently and a second key nobody ever notices retiring.
2559
+ *
2560
+ * Seven days: long enough that a daemon which polls daily and a laptop shut
2561
+ * for a long weekend both see the new record before the old key stops working,
2562
+ * short enough that "which key is live" is never an interesting question.
2563
+ */
2564
+ declare const RETIREMENT_WINDOW_MS: number;
2565
+ /**
2566
+ * The longest chain a daemon will walk — Amendment C, ruling 1.
2567
+ *
2568
+ * **A denial-of-service guard, not policy.** The bound exists so a projection
2569
+ * cannot make a daemon verify ten thousand signatures, not to express an
2570
+ * opinion about how often a site may rotate. A site that legitimately exceeds
2571
+ * it has a re-pair ahead of it, which is why it is generous: at one rotation a
2572
+ * quarter this is sixteen years.
2573
+ */
2574
+ declare const MAX_SUCCESSION_CHAIN = 64;
2575
+ /** One step of a chain: a key, and the signature by it over its successor. */
2576
+ declare const Succession: z.ZodObject<{
2577
+ identity: z.ZodObject<{
2578
+ identity: z.ZodString;
2579
+ encryption: z.ZodString;
2580
+ encryptionSig: z.ZodString;
2581
+ }, z.core.$strict>;
2582
+ signature: z.ZodString;
2583
+ }, z.core.$strict>;
2584
+ type Succession = z.infer<typeof Succession>;
2585
+ /** The exact bytes signed. One definition; both sides call it. */
2586
+ declare function successionStatement(fromKeyId: string, toKeyId: string): Uint8Array;
2587
+ /**
2588
+ * Sign a succession from the keys being retired to the identity taking over.
2589
+ *
2590
+ * Takes `StoredKeys` for the predecessor because only the holder of K1's
2591
+ * private half can produce this, which is the property the whole design rests
2592
+ * on. A site calls this once, at rotation, on the machine holding its keys.
2593
+ */
2594
+ declare function signSuccession(previous: StoredKeys, next: PublicIdentity): Succession;
2595
+ /**
2596
+ * Check one link: did `link.identity` sign over succeeding to `toKeyId`?
2597
+ *
2598
+ * `toKeyId` is passed in rather than read from anywhere in `link`, and that is
2599
+ * the load-bearing detail. A verifier that recovered the successor from the
2600
+ * signed statement would accept a statement about *any* successor, which is
2601
+ * the replay this design names in C.1 — the signature is genuine, the
2602
+ * successor it names is not the one being installed.
2603
+ */
2604
+ declare function verifyLink(link: Succession, toKeyId: string): boolean;
2605
+ /** Why a chain was refused, in the words a log line uses. */
2606
+ type SuccessionFailure = "no-chain" | "too-long" | "unknown-origin" | "broken-link";
2607
+ interface SuccessionWalk {
2608
+ /** The ids the chain passes through, oldest first, ending at the current. */
2609
+ readonly path: string[];
2610
+ /** The approved id the chain reached, when it reached one. */
2611
+ readonly from?: string;
2612
+ readonly failure?: SuccessionFailure;
2613
+ }
2614
+ /**
2615
+ * Walk a chain from the key being presented back to a key already approved.
2616
+ *
2617
+ * `chain` is ordered oldest last, as the projection carries it — so walking it
2618
+ * means starting at the current key and stepping backwards, each link proving
2619
+ * that its holder signed for the id in front of it.
2620
+ *
2621
+ * Returns the approved id it reached, or why it did not. **Deliberately
2622
+ * returns rather than throws**: a chain that does not verify is ordinary
2623
+ * hostile input, and the caller's job is to keep its existing pin and say so.
2624
+ *
2625
+ * `approved` is asked as a predicate rather than taken as a set because the
2626
+ * daemon's notion of "already approved" includes tombstoned ids — a site that
2627
+ * left the allowlist and came back is still a site this machine has vouched
2628
+ * for, and rotation must not become a way to launder that distinction away.
2629
+ */
2630
+ declare function walkSuccession(input: {
2631
+ current: string;
2632
+ chain: readonly Succession[];
2633
+ approved: (keyId: string) => boolean;
2634
+ }): SuccessionWalk;
2635
+
2636
+ /**
2637
+ * The normative MUSTs of protocol v0, as data.
2638
+ *
2639
+ * byollm_001 requires that "every MUST above has a conformance test id
2640
+ * referenced inline". Keeping the MUSTs as a frozen registry rather than
2641
+ * prose is what makes that requirement *checkable*: the conformance kit
2642
+ * imports {@link MUSTS} and fails if any id has no test asserting it, so a
2643
+ * new MUST cannot be added without a test and a test cannot silently drift
2644
+ * away from the statement it claims to prove.
2645
+ *
2646
+ * Ids are stable and public — third-party servers cite them in their
2647
+ * certification output.
2648
+ */
2649
+ /** Which side of the wire is obliged to enforce a given MUST. */
2650
+ type MustEnforcer = "daemon" | "server" | "both";
2651
+ /**
2652
+ * How a MUST is actually verified — which is not the same question as who
2653
+ * enforces it, and is the one that decides what "byollm-compatible" means.
2654
+ *
2655
+ * The conformance kit's credibility rests on an implicit claim that every
2656
+ * MUST is checkable. Ten of them were not, and the kit reported that honestly
2657
+ * while nothing acted on it. Making the kind explicit turns "uncovered" from
2658
+ * a number needing a paragraph of explanation into a number that should be
2659
+ * zero.
2660
+ *
2661
+ * - `conformance` — the kit asserts it against *any* implementation. This is
2662
+ * the strong kind: a third party runs the suite and learns something.
2663
+ * - `adversarial` — proved by the reference daemon's own suites in this repo
2664
+ * (the hostile-payload corpus, or its unit tests). Real verification, and
2665
+ * it runs in CI — but it proves things about *our* daemon, not about
2666
+ * someone else's, so the kit cannot carry it.
2667
+ * - `construction` — true by the shape of the code, where a test could only
2668
+ * sample. A reviewer verifies it; a suite cannot.
2669
+ * ## When a MUST binds both sides — cloud_008 Tier 3
2670
+ *
2671
+ * `AUDIENCE_BOTH_SIDES` says the server and the daemon each enforce. The kit
2672
+ * passed **entirely** with the server's half deleted: every check drove a real
2673
+ * daemon, and a daemon refuses locally, so "the job did not run" looked
2674
+ * identical whichever side refused it. A full-honest-stack test proves only
2675
+ * the conjunction.
2676
+ *
2677
+ * So a `both`-enforced MUST needs **one check per party, each with the honest
2678
+ * counterpart removed** — C032 claims over the raw protocol precisely so no
2679
+ * daemon admission logic runs. Where a check strips one side, its comment
2680
+ * says which; where a MUST is enforced by both and only one side is checked,
2681
+ * that is a gap rather than coverage.
2682
+ *
2683
+ * - `operator` — a claim about how someone runs a deployment, verifiable only
2684
+ * by audit or by reading source. The honest category, and the one that
2685
+ * exists so a property nobody can check from outside is *labelled* as such
2686
+ * rather than laundered by association with the checkable ones.
2687
+ */
2688
+ type MustVerification = "conformance" | "adversarial" | "construction" | "operator";
2689
+ /**
2690
+ * How a MUST is verified — one kind, or several.
2691
+ *
2692
+ * Several is not hedging. `SITES_LOCALLY_APPROVED` is the case that forced it:
2693
+ * the fence is **construction** — a daemon cannot serve a site that is not in
2694
+ * its map, and admission refuses before a payload is fetched — while the
2695
+ * property that a *removed and re-offered* id is still refused needs a hostile
2696
+ * sequence of heartbeats no honest client would send, which is
2697
+ * **adversarial**. Recording one and dropping the other would either overstate
2698
+ * what a type check proves or understate what the suites do.
2699
+ *
2700
+ * The alternative was a second field for the second kind, which is two answers
2701
+ * to one question — the shape this project keeps deleting.
2702
+ */
2703
+ type MustVerifiedBy = MustVerification | readonly [MustVerification, ...MustVerification[]];
2704
+ /** The kinds a MUST claims, always as a list. */
2705
+ declare function kindsOf(must: {
2706
+ readonly verifiedBy: MustVerifiedBy;
2707
+ }): readonly MustVerification[];
2708
+ /** A single normative requirement of the protocol. */
2709
+ interface Must {
2710
+ /** Stable public id, cited by conformance output. */
2711
+ readonly id: string;
2712
+ /** The requirement, in MUST language. */
2713
+ readonly statement: string;
2714
+ /** Which implementation is obliged to enforce it. */
2715
+ readonly enforcedBy: MustEnforcer;
2716
+ /**
2717
+ * How this is verified. `conformance` is the only kind the kit can assert;
2718
+ * see {@link MustVerification} for why the others exist.
2719
+ */
2720
+ readonly verifiedBy: MustVerifiedBy;
2721
+ /** Spec section this was adjudicated in. */
2722
+ readonly source: string;
2723
+ }
2724
+ /**
2725
+ * Every normative MUST in protocol v0.
2726
+ *
2727
+ * @remarks
2728
+ * Grouped by concern for readability; the conformance kit treats this as a
2729
+ * flat set. Adding an entry here without a corresponding conformance test is
2730
+ * a CI failure, by design.
2731
+ */
2732
+ declare const MUSTS: Readonly<{
2733
+ readonly PAIR_ONE_USER: Must;
2734
+ readonly PAIR_INTERACTIVE: Must;
2735
+ readonly PAIR_CODE_EXPIRES: Must;
2736
+ readonly VERSION_HANDSHAKE_REQUIRED: Must;
2737
+ readonly SITE_KEY_BY_STUB: Must;
2738
+ readonly SITES_LOCALLY_APPROVED: Must;
2739
+ readonly KEYS_EXCHANGED_AT_CONSENT: Must;
2740
+ readonly REQUESTS_SIGNED_NOT_BEARER: Must;
2741
+ readonly LEASE_SCOPED_BY_GRANT: Must;
2742
+ readonly STUB_METADATA_EXHAUSTIVE: Must;
2743
+ readonly ENVELOPE_SEALED_AND_SIGNED: Must;
2744
+ readonly KIND_TYPED_ONLY: Must;
2745
+ readonly KIND_NO_CODE: Must;
2746
+ readonly CLAIM_REQUIRES_CAPABILITY: Must;
2747
+ readonly CAPABILITY_IS_DETECTED: Must;
2748
+ readonly CLAIM_ATOMIC: Must;
2749
+ readonly LEASE_HONORED: Must;
2750
+ readonly LEASE_RECLAIMABLE: Must;
2751
+ readonly AUDIENCE_BOTH_SIDES: Must;
2752
+ readonly SUBSCRIPTION_SELF_LOCK: Must;
2753
+ readonly METERED_DEFAULTS_SELF: Must;
2754
+ readonly METERED_REQUIRES_CEILING: Must;
2755
+ readonly COST_NOT_CONFIGURABLE: Must;
2756
+ readonly REMOTE_IS_NEVER_FREE: Must;
2757
+ readonly NAMED_LOCAL_ALLOWLIST: Must;
2758
+ readonly REFUSAL_NOT_REOFFERED: Must;
2759
+ readonly REVOCATION_HONORED: Must;
2760
+ readonly CANCEL_HONORED: Must;
2761
+ readonly DEPENDS_ON_GATING: Must;
2762
+ readonly TTL_EXPIRY: Must;
2763
+ readonly NO_RUNNER_SIGNAL: Must;
2764
+ readonly RESULT_IDEMPOTENT: Must;
2765
+ readonly PROVENANCE_NAMES_DEVICE: Must;
2766
+ readonly INGRESS_LOGGED_BEFORE_EXECUTION: Must;
2767
+ readonly NO_SHELL_INTERPOLATION: Must;
2768
+ /**
2769
+ * Amended for byollm_016 Phase B, and the amendment is deliberately narrow.
2770
+ *
2771
+ * A site may now name a **service** on the stub. The temptation is to read
2772
+ * that as a crack in this law, so the statement below says exactly where the
2773
+ * line is: a name selects from a menu the owner published, and resolves to a
2774
+ * model, backend, base URL and flags **only** through that owner's own
2775
+ * config. The site supplies a key; the owner supplies every value it maps
2776
+ * to. A name the owner does not advertise is refused rather than
2777
+ * substituted, because substitution is how "you may pick from my list" turns
2778
+ * into "you may ask for anything and get something".
2779
+ *
2780
+ * Two properties keep it from drifting into "sites demand models":
2781
+ *
2782
+ * 1. **Nothing the site sends is ever a value.** No model string, no URL,
2783
+ * no flag crosses the wire — only a key that means nothing off this
2784
+ * owner's machine.
2785
+ * 2. **It is a stub field, never a payload field.** The prompt cannot
2786
+ * reach it. That is unchanged and is the sentence the second clause
2787
+ * below still enforces verbatim.
2788
+ */
2789
+ readonly NO_PAYLOAD_ROUTING: Must;
2790
+ readonly STRIPPED_CHILD_ENV: Must;
2791
+ readonly HTTP_BASE_URL_SAFE: Must;
2792
+ readonly OUTPUT_INERT: Must;
2793
+ readonly COMMUNITY_BUDGETS: Must;
2794
+ readonly REVOCATION_IMMEDIATE: Must;
2795
+ readonly CONSENT_BEFORE_ROUTE: Must;
2796
+ readonly ROSTER_NOT_DISCLOSED: Must;
2797
+ readonly EFFECTIVE_OFFER_ONLY: Must;
2798
+ readonly FALLBACK_LABELED: Must;
2799
+ readonly RELAY_BLIND: Must;
2800
+ readonly SHARED_COMPUTE_DISCLOSED: Must;
2801
+ }>;
2802
+ /** The id of any normative MUST. */
2803
+ type MustId = keyof typeof MUSTS;
2804
+ /** All MUST ids, for coverage checks. */
2805
+ declare const MUST_IDS: readonly ("PAIR_ONE_USER" | "PAIR_INTERACTIVE" | "PAIR_CODE_EXPIRES" | "VERSION_HANDSHAKE_REQUIRED" | "SITE_KEY_BY_STUB" | "SITES_LOCALLY_APPROVED" | "KEYS_EXCHANGED_AT_CONSENT" | "REQUESTS_SIGNED_NOT_BEARER" | "LEASE_SCOPED_BY_GRANT" | "STUB_METADATA_EXHAUSTIVE" | "ENVELOPE_SEALED_AND_SIGNED" | "KIND_TYPED_ONLY" | "KIND_NO_CODE" | "CLAIM_REQUIRES_CAPABILITY" | "CAPABILITY_IS_DETECTED" | "CLAIM_ATOMIC" | "LEASE_HONORED" | "LEASE_RECLAIMABLE" | "AUDIENCE_BOTH_SIDES" | "SUBSCRIPTION_SELF_LOCK" | "METERED_DEFAULTS_SELF" | "METERED_REQUIRES_CEILING" | "COST_NOT_CONFIGURABLE" | "REMOTE_IS_NEVER_FREE" | "NAMED_LOCAL_ALLOWLIST" | "REFUSAL_NOT_REOFFERED" | "REVOCATION_HONORED" | "CANCEL_HONORED" | "DEPENDS_ON_GATING" | "TTL_EXPIRY" | "NO_RUNNER_SIGNAL" | "RESULT_IDEMPOTENT" | "PROVENANCE_NAMES_DEVICE" | "INGRESS_LOGGED_BEFORE_EXECUTION" | "NO_SHELL_INTERPOLATION" | "NO_PAYLOAD_ROUTING" | "STRIPPED_CHILD_ENV" | "HTTP_BASE_URL_SAFE" | "OUTPUT_INERT" | "COMMUNITY_BUDGETS" | "REVOCATION_IMMEDIATE" | "CONSENT_BEFORE_ROUTE" | "ROSTER_NOT_DISCLOSED" | "EFFECTIVE_OFFER_ONLY" | "FALLBACK_LABELED" | "RELAY_BLIND" | "SHARED_COMPUTE_DISCLOSED")[];
2806
+ /** Every MUST verified a particular way. */
2807
+ declare function mustsVerifiedBy(kind: MustVerification): MustId[];
929
2808
 
930
- export { AUDIENCES, Audience, BACKENDS, BACKEND_IDS, BackendAccount, BackendClass, type BackendDescriptor, type BackendId, BackendIdSchema, Capability, CapabilityMatrix, ChatMessage, ChatPayload, ClaimRequest, ClaimResponse, ClaimedJob, DeliveredResult, ENDPOINTS, ERROR_STATUS, type Endpoint, GeneratePayload, HeartbeatRequest, HeartbeatResponse, JOB_KINDS, JobKind, JobOutcome, JobPayload, JobResultCanceled, JobResultError, JobResultOk, JobState, KindedPayload, Lease, MUSTS, MUST_IDS, type MatchDaemon, type MatchJob, MatchRefusal, type MatchResult, type Must, type MustEnforcer, type MustId, OFFER_SCOPES, OfferScope, PAYLOAD_LIMITS, PROTOCOL_PREFIX, PROTOCOL_VERSION, PairPollRequest, PairPollResponse, PairRequest, PairStartRequest, PairStartResponse, type PayloadFor, REFUSAL_MESSAGES, ReleaseRequest, ReleaseResponse, ResultProvenance, ResultRequest, ResultResponse, TERMINAL_STATES, WireError, WireErrorCode, backendDescriptor, canTransition, effectiveOfferScope, isBackendId, isJobKind, isTerminal, matchAudience, payloadTextLength, provenanceFor };
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 };