@byollm/protocol 0.1.0-alpha.10 → 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,1675 +1,2809 @@
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
- *
7
- * - `http`: an OpenAI-compatible HTTP server (Ollama, `mlx_lm.server`,
8
- * llama.cpp server, vLLM, and every hosted provider that speaks the same
9
- * wire format). Spawns nothing, so byollm_004 §2's argv, stdin, env and
10
- * sandbox requirements are not applicable by construction. Its threat
11
- * surface is SSRF-shaped and bounded by {@link MUSTS.HTTP_BASE_URL_SAFE}.
12
- * - `process`: spawns a binary (`claude` CLI today, `mlx_lm.lora` for a
13
- * future `train.*` kind). All of byollm_004 §2 is mandatory here.
6
+ * Protocol version carried on every request; servers refuse what they can't
7
+ * speak.
8
+ *
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.
14
+ *
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.
23
+ *
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.
14
27
  */
15
- declare const BackendClass: z.ZodEnum<{
16
- http: "http";
17
- process: "process";
18
- }>;
19
- type BackendClass = z.infer<typeof BackendClass>;
28
+ declare const PROTOCOL_VERSION: "1";
20
29
  /**
21
- * Who pays, and how byollm_007.
22
- *
23
- * This replaced a two-valued `account` field that conflated two unrelated
24
- * constraints and, in doing so, left a hole: `openai-http` was "open", but it
25
- * accepts an API key, so an owner could point it at a paid endpoint, offer it
26
- * `public`, and donate their credit balance to strangers. The community
27
- * budgets cap job *count*, not spend.
30
+ * Every protocol version this build can serve, **oldest first**.
28
31
  *
29
- * - `free` local compute. Costs electricity, not money. Shareable.
30
- * - `metered` per-token billing against the owner's account. Legal to
31
- * share and ruinous to share by accident.
32
- * - `subscription` — a vendor account whose terms forbid third-party work.
33
- * Sharing is a terms violation, not merely expensive.
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.
34
35
  */
35
- declare const BackendCost: z.ZodEnum<{
36
- free: "free";
37
- metered: "metered";
38
- subscription: "subscription";
39
- }>;
40
- type BackendCost = z.infer<typeof BackendCost>;
41
- /** The immutable facts about a backend that the protocol reasons over. */
42
- interface BackendDescriptor {
43
- /** Stable backend id, as written in `byollm.config.json`. */
44
- readonly id: string;
45
- /** Human-readable name for the trust UI. */
46
- readonly label: string;
47
- /** Determines which isolation requirements apply. */
48
- readonly class: BackendClass;
49
- /**
50
- * Who pays. Fixed here for every named provider and **not overridable by
51
- * configuration** ({@link MUSTS.COST_NOT_CONFIGURABLE}) — `openai` is
52
- * metered because it is, and no setting changes that.
53
- *
54
- * `null` only for the generic {@link BACKENDS."openai-http"} entry, whose
55
- * cost is inferred from its base URL instead
56
- * ({@link MUSTS.REMOTE_IS_NEVER_FREE}).
57
- */
58
- readonly cost: BackendCost | null;
59
- /**
60
- * Which adversarial corpus byollm_004 §5 runs against this backend. A
61
- * backend cannot be registered without one — the coverage check in the
62
- * adversarial suite enforces it.
63
- */
64
- readonly adversarialCorpus: "process" | "http";
65
- /**
66
- * Where this provider lives, when that is knowable. Owner config may
67
- * override it; a provider with no default requires one to be given.
68
- */
69
- readonly defaultBaseUrl?: string;
70
- }
71
36
  /**
72
- * The backend registry.
73
- *
74
- * **Providers are entries, not implementations.** Every HTTP-class provider
75
- * below shares the single `openai-http` transport, because they all speak
76
- * OpenAI-compatible `/v1/chat/completions`. An entry adds a stable id, a cost
77
- * class the owner cannot override, and a default base URL. Adding a provider
78
- * is therefore one line and no new code which is why the adversarial corpus
79
- * still covers all of them, and why a PR adding one is reviewable at a glance.
37
+ * `0` is deliberately **not** here, though the list exists for exactly that.
38
+ *
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.
80
45
  */
81
- declare const BACKENDS: Readonly<{
82
- readonly ollama: BackendDescriptor;
83
- readonly mlx: BackendDescriptor;
84
- readonly llamacpp: BackendDescriptor;
85
- readonly vllm: BackendDescriptor;
86
- readonly lmstudio: BackendDescriptor;
87
- readonly jan: BackendDescriptor;
88
- readonly localai: BackendDescriptor;
89
- /**
90
- * Note the pair: `anthropic` and {@link BACKENDS."claude-cli"} reach the
91
- * same vendor and land in different cost classes. That is not an
92
- * inconsistency — it is the axis working. One bills a key per token, the
93
- * other runs under a personal plan whose terms cover one person's work. Who
94
- * pays and under what terms is the question; which company is not.
95
- */
96
- readonly anthropic: BackendDescriptor;
97
- readonly openai: BackendDescriptor;
98
- readonly gemini: BackendDescriptor;
99
- readonly grok: BackendDescriptor;
100
- readonly groq: BackendDescriptor;
101
- readonly openrouter: BackendDescriptor;
102
- readonly together: BackendDescriptor;
103
- readonly deepseek: BackendDescriptor;
104
- readonly mistral: BackendDescriptor;
105
- readonly "openai-http": BackendDescriptor;
106
- readonly "claude-cli": BackendDescriptor;
107
- }>;
108
- /** The id of a registered backend. */
109
- type BackendId = keyof typeof BACKENDS;
110
- /** All registered backend ids — the adversarial coverage check iterates this. */
111
- 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")[];
112
- declare const BackendIdSchema: z.ZodEnum<{
113
- ollama: "ollama";
114
- mlx: "mlx";
115
- llamacpp: "llamacpp";
116
- vllm: "vllm";
117
- lmstudio: "lmstudio";
118
- jan: "jan";
119
- localai: "localai";
120
- anthropic: "anthropic";
121
- openai: "openai";
122
- gemini: "gemini";
123
- grok: "grok";
124
- groq: "groq";
125
- openrouter: "openrouter";
126
- together: "together";
127
- deepseek: "deepseek";
128
- mistral: "mistral";
129
- "openai-http": "openai-http";
130
- "claude-cli": "claude-cli";
131
- }>;
132
- /** Narrow an arbitrary string to a registered backend id. */
133
- declare function isBackendId(value: string): value is BackendId;
46
+ declare const SUPPORTED_PROTOCOL_VERSIONS: readonly string[];
134
47
  /**
135
- * Look up a backend descriptor.
48
+ * The oldest version this build will talk to — derived, not declared.
136
49
  *
137
- * @throws if the id is not registered an unregistered backend has no
138
- * adversarial corpus, so refusing is the safe direction.
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.
139
54
  */
140
- declare function backendDescriptor(id: BackendId): BackendDescriptor;
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
+ }
141
63
  /**
142
- * Is this host local enough that compute there is free?
64
+ * The version a request declares, wherever it carries it.
143
65
  *
144
- * Loopback and the private ranges only. This is the rule that makes
145
- * {@link MUSTS.REMOTE_IS_NEVER_FREE} enforceable rather than a promise: an
146
- * owner cannot reach a paid API through the generic backend and call it free,
147
- * because "free" is derived from the address, not from what the config claims.
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.
148
69
  *
149
- * **What this cannot see.** The address is all it reads. A proxy on
150
- * `127.0.0.1` forwarding to a paid API classes as `free` and nothing
151
- * downstream will contradict it. That is deliberate: standing up a relay is
152
- * an act by the machine's owner against their own account, and the threat
153
- * model here is a hostile *job*, not an owner routing around a rule that
154
- * exists to protect them. What this catches is the accident — a remote paid
155
- * endpoint offered `public` because nobody thought about the bill. See
156
- * `docs/security.md` §4a.
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.
157
75
  */
158
- declare function isLocalHost(hostname: string): boolean;
76
+ declare function declaredVersion(input: {
77
+ body?: unknown;
78
+ query?: URLSearchParams;
79
+ }): unknown;
159
80
  /**
160
- * The cost class of a configured backend instance.
81
+ * Check the protocol version on an incoming request
82
+ * ({@link MUSTS.VERSION_HANDSHAKE_REQUIRED}).
161
83
  *
162
- * For every named provider this is whatever the registry says, full stop
163
- * ({@link MUSTS.COST_NOT_CONFIGURABLE}). For the generic `openai-http` entry
164
- * it is inferred from the base URL, and a base URL that cannot be parsed is
165
- * treated as `metered` the expensive side, because guessing "free" wrong
166
- * costs the owner money.
167
- */
168
- declare function resolveCost(id: BackendId, baseUrl: string | undefined): BackendCost;
169
-
170
- /**
171
- * Who may run a job, declared by the app that enqueued it.
84
+ * Returns a refusal, or `null` to proceed.
85
+ *
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.
172
92
  *
173
- * - `self` only the job owner's own daemon.
174
- * - `named` — a daemon whose owner has explicitly allowed this (server, user)
175
- * pair in their *local* allowlist (byollm_001 Rev 1 §B).
176
- * - `public` — any daemon offering `public` compute.
93
+ * The message names the fix, because the person reading it is usually the one
94
+ * who has to apply it.
177
95
  */
178
- declare const Audience: z.ZodEnum<{
179
- self: "self";
180
- named: "named";
181
- public: "public";
182
- }>;
183
- type Audience = z.infer<typeof Audience>;
96
+ declare function checkProtocolVersion(body: unknown): VersionRefusal | null;
184
97
  /**
185
- * What a daemon backend is willing to run, declared by the machine's owner.
186
- * Same three values as {@link Audience}, but the two are independent axes —
187
- * a job runs only where both agree ({@link MUSTS.AUDIENCE_BOTH_SIDES}).
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.
188
116
  */
189
- declare const OfferScope: z.ZodEnum<{
190
- self: "self";
191
- named: "named";
192
- public: "public";
193
- }>;
194
- type OfferScope = z.infer<typeof OfferScope>;
195
- /** All audience values, in widening order. */
196
- declare const AUDIENCES: readonly ("self" | "named" | "public")[];
197
- /** All offer scopes, in widening order. */
198
- declare const OFFER_SCOPES: readonly ("self" | "named" | "public")[];
117
+ declare const UPGRADE_COMMAND: "npm i -g byollm@latest";
118
+ /** The path prefix all endpoints mount under. */
119
+ declare const PROTOCOL_PREFIX: "/byollm";
199
120
  /**
200
- * Why a job was refused. Distinct codes because byollm_002 requires that
201
- * different truths never share a message — "no matching work" and "refused on
202
- * principle" are not the same event, and a volunteer debugging their setup
203
- * needs to know which one happened.
121
+ * The endpoint names, in the order byollm_001 lists them, plus `fetch`.
122
+ *
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.
204
127
  */
205
- declare const MatchRefusal: z.ZodEnum<{
206
- "no-capability": "no-capability";
207
- "audience-self-other-owner": "audience-self-other-owner";
208
- "not-locally-allowed": "not-locally-allowed";
209
- "not-in-server-allowlist": "not-in-server-allowlist";
210
- "offer-scope-too-narrow": "offer-scope-too-narrow";
211
- "subscription-self-lock": "subscription-self-lock";
212
- "metered-no-spend-consent": "metered-no-spend-consent";
213
- "metered-ceiling-reached": "metered-ceiling-reached";
214
- }>;
215
- type MatchRefusal = z.infer<typeof MatchRefusal>;
216
- /** The outcome of an audience match. */
217
- type MatchResult = {
218
- readonly ok: true;
219
- } | {
220
- readonly ok: false;
221
- readonly refusal: MatchRefusal;
222
- };
223
- /** What the owner has agreed to spend on other people's work, if anything. */
224
- interface SpendConsent {
225
- /** The owner explicitly acknowledged that sharing this backend costs money. */
226
- readonly acknowledged: boolean;
227
- /** Their ceiling. Absent means no ceiling was set, which is not consent. */
228
- readonly ceilingReached?: boolean;
229
- }
128
+ declare const ENDPOINTS: readonly ["pair", "claim", "fetch", "heartbeat", "result", "release"];
129
+ type Endpoint = (typeof ENDPOINTS)[number];
230
130
  /**
231
- * The effective offer scope of a backend.
232
- *
233
- * Three rules, applied at the one place both the daemon's config loader and
234
- * its matcher call, so no code path can observe a scope wider than the cost
235
- * class allows:
236
- *
237
- * - `subscription` is locked to `self` regardless of config
238
- * ({@link MUSTS.SUBSCRIPTION_SELF_LOCK}) — someone else's terms.
239
- * - `metered` narrows to `self` unless the owner has explicitly acknowledged
240
- * the spend ({@link MUSTS.METERED_DEFAULTS_SELF}) — their money.
241
- * - `free` passes through — their electricity.
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.
242
133
  *
243
- * Note the asymmetry: subscription can never be widened, metered can be
244
- * widened deliberately. Conflating those was byollm_007's bug.
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).
245
139
  */
246
- declare function effectiveOfferScope(configured: OfferScope, cost: BackendCost, spend?: SpendConsent): OfferScope;
247
- /** The job-side facts a match needs. */
248
- interface MatchJob {
249
- /** The app's id for the user who enqueued the job. */
250
- readonly owner: string;
251
- /** Who the app says may run it. */
252
- readonly audience: Audience;
253
- /**
254
- * Optional server-side restriction on which runner owners may take a
255
- * `named` job. Defence in depth only — the daemon's local allowlist is the
256
- * enforcing side ({@link MUSTS.NAMED_LOCAL_ALLOWLIST}).
257
- */
258
- readonly audienceAllow?: readonly string[] | undefined;
259
- }
260
- /** The daemon-side facts a match needs. */
261
- interface MatchDaemon {
262
- /** The app's id for the user this daemon is paired to. */
263
- readonly owner: string;
264
- /** Effective scope of the backend that would run the job. */
265
- readonly offerScope: OfferScope;
266
- /** Who pays for that backend's tokens. */
267
- readonly cost: BackendCost;
268
- /** What the owner agreed to spend on others, for a `metered` backend. */
269
- readonly spend?: SpendConsent | undefined;
270
- /**
271
- * Does this daemon's *local* allowlist admit the given owner for the server
272
- * origin the job came from? Supplied as a predicate so the protocol package
273
- * stays free of file I/O; the daemon passes its allowlist, the server
274
- * passes a conservative `() => true` because it cannot know a remote
275
- * daemon's local list and must not pretend to.
276
- */
277
- readonly locallyAllows: (owner: string) => boolean;
278
- }
279
- /**
280
- * Decide whether a job may run on a daemon.
281
- *
282
- * Both sides must agree ({@link MUSTS.AUDIENCE_BOTH_SIDES}):
283
- * 1. the job's audience must admit the daemon's owner, and
284
- * 2. the backend's offer scope must admit the job's owner.
285
- *
286
- * The full nine-way matrix (three audiences × three offer scopes) is asserted
287
- * by the conformance kit. The function is pure and total so both the daemon
288
- * and the server can run the identical rule — the daemon refuses, and the
289
- * server refuses too (byollm_003 §Server-side MUSTs).
290
- *
291
- * @example
292
- * ```ts
293
- * const result = matchAudience(
294
- * { owner: "alice", audience: "named" },
295
- * {
296
- * owner: "bob",
297
- * offerScope: "named",
298
- * cost: "free",
299
- * locallyAllows: (o) => o === "alice",
300
- * },
301
- * );
302
- * // result.ok === true
303
- * ```
304
- */
305
- declare function matchAudience(job: MatchJob, daemon: MatchDaemon): MatchResult;
306
- /**
307
- * Human-readable refusal text for the daemon's log and the trust UI.
308
- * Each refusal reads as a distinct truth — byollm_002's "four different
309
- * truths that must never share a message" applied to the audience axis.
310
- */
311
- declare const REFUSAL_MESSAGES: Readonly<Record<MatchRefusal, string>>;
312
-
313
- /**
314
- * Upper bounds on payload size, enforced at the schema so oversized input is
315
- * refused at parse time rather than somewhere deeper.
316
- *
317
- * byollm_004 §4 requires stricter limits for community (`named`/`public`)
318
- * jobs; those are applied on top of these by the daemon's budget check, which
319
- * knows the job's audience. These are the absolute ceilings for any job.
320
- */
321
- declare const PAYLOAD_LIMITS: Readonly<{
322
- /** Max characters in any single text field. */
323
- maxTextChars: 1000000;
324
- /** Max messages in an `llm.chat` conversation. */
325
- maxMessages: 256;
326
- /** Max characters across the whole payload. */
327
- maxTotalChars: 4000000;
328
- }>;
329
- /**
330
- * A conversation turn. `role` is a closed enum — it is routing *within the
331
- * model call*, not routing of the call, so it cannot select a backend.
332
- */
333
- declare const ChatMessage: z.ZodObject<{
334
- role: z.ZodEnum<{
335
- system: "system";
336
- user: "user";
337
- assistant: "assistant";
338
- }>;
339
- content: z.ZodString;
340
- }, z.core.$strip>;
341
- type ChatMessage = z.infer<typeof ChatMessage>;
342
- /**
343
- * Payload for `llm.generate`.
344
- *
345
- * @remarks
346
- * Text only, deliberately. byollm_004 §1 states the payload is "data handed
347
- * to a model, never configuration and never a command", so v0 carries no
348
- * sampling parameters, no model name, no base URL and no flags — those are
349
- * owner-side route config. A future `params` field with an explicit closed
350
- * allowlist and owner-set clamps is reserved; adding a field later is
351
- * non-breaking, removing one is not.
352
- */
353
- declare const GeneratePayload: z.ZodObject<{
354
- prompt: z.ZodString;
355
- system: z.ZodOptional<z.ZodString>;
356
- }, z.core.$strict>;
357
- type GeneratePayload = z.infer<typeof GeneratePayload>;
358
- /** Payload for `llm.chat`. Text only, for the same reason as {@link GeneratePayload}. */
359
- declare const ChatPayload: z.ZodObject<{
360
- messages: z.ZodArray<z.ZodObject<{
361
- role: z.ZodEnum<{
362
- system: "system";
363
- user: "user";
364
- assistant: "assistant";
365
- }>;
366
- content: z.ZodString;
367
- }, z.core.$strip>>;
368
- system: z.ZodOptional<z.ZodString>;
369
- }, z.core.$strict>;
370
- type ChatPayload = z.infer<typeof ChatPayload>;
371
- /**
372
- * The job kinds a v1 daemon has handlers for.
373
- *
374
- * Kinds are resolved against handlers baked into the daemon
375
- * ({@link MUSTS.KIND_TYPED_ONLY}); an unknown kind is refused, never guessed.
376
- * Adding a kind is a protocol change with its own spec and threat review —
377
- * notably any kind that needs tools, which byollm_004 §2 forbids as a payload
378
- * flag.
379
- */
380
- declare const JobKind: z.ZodEnum<{
381
- "llm.generate": "llm.generate";
382
- "llm.chat": "llm.chat";
383
- }>;
384
- type JobKind = z.infer<typeof JobKind>;
385
- /** All v1 job kinds. */
386
- declare const JOB_KINDS: readonly ("llm.generate" | "llm.chat")[];
387
- /** A payload discriminated by its kind. */
388
- declare const KindedPayload: z.ZodDiscriminatedUnion<[z.ZodObject<{
389
- kind: z.ZodLiteral<"llm.generate">;
390
- payload: z.ZodObject<{
391
- prompt: z.ZodString;
392
- system: z.ZodOptional<z.ZodString>;
393
- }, z.core.$strict>;
394
- }, z.core.$strip>, z.ZodObject<{
395
- kind: z.ZodLiteral<"llm.chat">;
396
- payload: z.ZodObject<{
397
- messages: z.ZodArray<z.ZodObject<{
398
- role: z.ZodEnum<{
399
- system: "system";
400
- user: "user";
401
- assistant: "assistant";
402
- }>;
403
- content: z.ZodString;
404
- }, z.core.$strip>>;
405
- system: z.ZodOptional<z.ZodString>;
406
- }, z.core.$strict>;
407
- }, z.core.$strip>], "kind">;
408
- type KindedPayload = z.infer<typeof KindedPayload>;
409
- /** The payload type for a given kind. */
410
- type PayloadFor<K extends JobKind> = K extends "llm.generate" ? GeneratePayload : ChatPayload;
411
- /** Narrow an arbitrary string to a known job kind. */
412
- declare function isJobKind(value: string): value is JobKind;
413
- /**
414
- * Total character weight of a payload, used by the daemon's community budget
415
- * check and by the server's payload-size limits.
416
- */
417
- declare function payloadTextLength(kinded: KindedPayload): number;
418
-
419
- /**
420
- * The job lifecycle, made explicit by byollm_001 Rev 1 §D because the most
421
- * user-visible failure mode — "nothing is running my job" — was previously
422
- * unspecified.
423
- *
424
- * ```text
425
- * queued ──claim──▶ claimed ──start──▶ running ──▶ ok | error | canceled
426
- * │ │ │
427
- * │ └──lease expiry─────┘
428
- * │ ▼
429
- * │ queued (reclaimable, no loss)
430
- * └──ttl elapsed──▶ expired
431
- * ```
432
- */
433
- declare const JobState: z.ZodEnum<{
434
- ok: "ok";
435
- error: "error";
436
- queued: "queued";
437
- claimed: "claimed";
438
- running: "running";
439
- canceled: "canceled";
440
- expired: "expired";
441
- }>;
442
- type JobState = z.infer<typeof JobState>;
443
- /** States from which a job never moves again. */
444
- declare const TERMINAL_STATES: readonly ["ok", "error", "canceled", "expired"];
445
- /** Is this a state the job can never leave? */
446
- declare function isTerminal(state: JobState): boolean;
447
- /** May a job move from `from` to `to`? */
448
- declare function canTransition(from: JobState, to: JobState): boolean;
449
- /** A lease: the right to work on a job until `expiresAt`. */
450
- declare const Lease: z.ZodObject<{
451
- id: z.ZodString;
452
- runnerId: z.ZodString;
453
- expiresAt: z.ZodNumber;
454
- }, z.core.$strip>;
455
- type Lease = z.infer<typeof Lease>;
456
- /** Payload union as it appears on a job record. */
457
- declare const JobPayload: z.ZodUnion<readonly [z.ZodObject<{
458
- prompt: z.ZodString;
459
- system: z.ZodOptional<z.ZodString>;
460
- }, z.core.$strict>, z.ZodObject<{
461
- messages: z.ZodArray<z.ZodObject<{
462
- role: z.ZodEnum<{
463
- system: "system";
464
- user: "user";
465
- assistant: "assistant";
466
- }>;
467
- content: z.ZodString;
468
- }, z.core.$strip>>;
469
- system: z.ZodOptional<z.ZodString>;
470
- }, z.core.$strict>]>;
471
- type JobPayload = z.infer<typeof JobPayload>;
472
- /**
473
- * A job as the daemon receives it from `/byollm/claim`.
474
- *
475
- * Note what is absent: no model, no backend, no base URL, no flags, no path.
476
- * Those come from the machine owner's config only
477
- * ({@link MUSTS.NO_PAYLOAD_ROUTING}). The wire shape is the first place that
478
- * rule is enforced — there is no field to carry them.
479
- */
480
- declare const ClaimedJob: z.ZodObject<{
481
- id: z.ZodString;
140
+ declare const Capability: z.ZodObject<{
482
141
  kind: z.ZodEnum<{
483
142
  "llm.generate": "llm.generate";
484
143
  "llm.chat": "llm.chat";
485
144
  }>;
486
- payload: z.ZodUnion<readonly [z.ZodObject<{
487
- prompt: z.ZodString;
488
- system: z.ZodOptional<z.ZodString>;
489
- }, z.core.$strict>, z.ZodObject<{
490
- messages: z.ZodArray<z.ZodObject<{
491
- role: z.ZodEnum<{
492
- system: "system";
493
- user: "user";
494
- assistant: "assistant";
495
- }>;
496
- content: z.ZodString;
497
- }, z.core.$strip>>;
498
- system: z.ZodOptional<z.ZodString>;
499
- }, z.core.$strict>]>;
500
- audience: z.ZodEnum<{
501
- self: "self";
502
- named: "named";
503
- public: "public";
504
- }>;
505
- owner: z.ZodString;
506
- audienceAllow: z.ZodOptional<z.ZodArray<z.ZodString>>;
507
- lease: z.ZodObject<{
508
- id: z.ZodString;
509
- runnerId: z.ZodString;
510
- expiresAt: z.ZodNumber;
511
- }, z.core.$strip>;
512
- }, z.core.$strict>;
513
- type ClaimedJob = z.infer<typeof ClaimedJob>;
514
- /**
515
- * The provenance that travels with every result to the delivery seam.
516
- *
517
- * byollm_003 Rev 1: a `named`/`public` result is attacker-controlled text.
518
- * The app must never render volunteer output as its own AI's answer without
519
- * knowing that is what it is ({@link MUSTS.RESULT_PROVENANCE}).
520
- */
521
- declare const ResultProvenance: z.ZodObject<{
522
- audience: z.ZodEnum<{
523
- self: "self";
524
- named: "named";
525
- public: "public";
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";
526
166
  }>;
527
- runnerId: z.ZodString;
528
- runnerOwner: z.ZodString;
529
167
  backendClass: z.ZodEnum<{
530
168
  http: "http";
531
169
  process: "process";
532
170
  }>;
533
171
  model: z.ZodString;
534
- untrusted: z.ZodBoolean;
172
+ knownModels: z.ZodOptional<z.ZodArray<z.ZodString>>;
173
+ offerScope: z.ZodEnum<{
174
+ private: "private";
175
+ team: "team";
176
+ }>;
535
177
  }, z.core.$strict>;
536
- type ResultProvenance = z.infer<typeof ResultProvenance>;
537
- /**
538
- * Build provenance for a completed job. `untrusted` is derived, never
539
- * supplied, so no caller can mark volunteer output as first-party.
540
- */
541
- declare function provenanceFor(input: {
542
- audience: Audience;
543
- runnerId: string;
544
- runnerOwner: string;
545
- backendClass: BackendClass;
546
- model: string;
547
- }): ResultProvenance;
548
- /** Successful outcome. */
549
- declare const JobResultOk: z.ZodObject<{
550
- outcome: z.ZodLiteral<"ok">;
551
- text: z.ZodString;
552
- artifactUrl: z.ZodOptional<z.ZodURL>;
553
- }, z.core.$strict>;
554
- /** Failed outcome. `code` is a stable machine string; `message` is for humans. */
555
- declare const JobResultError: z.ZodObject<{
556
- outcome: z.ZodLiteral<"error">;
557
- code: z.ZodString;
558
- message: z.ZodString;
559
- retryable: z.ZodBoolean;
560
- }, z.core.$strict>;
561
- /** Cancelled outcome, reported by the daemon after honoring a cancel. */
562
- declare const JobResultCanceled: z.ZodObject<{
563
- outcome: z.ZodLiteral<"canceled">;
564
- }, z.core.$strict>;
565
- declare const JobOutcome: z.ZodDiscriminatedUnion<[z.ZodObject<{
566
- outcome: z.ZodLiteral<"ok">;
567
- text: z.ZodString;
568
- artifactUrl: z.ZodOptional<z.ZodURL>;
569
- }, z.core.$strict>, z.ZodObject<{
570
- outcome: z.ZodLiteral<"error">;
571
- code: z.ZodString;
572
- message: z.ZodString;
573
- retryable: z.ZodBoolean;
574
- }, z.core.$strict>, z.ZodObject<{
575
- outcome: z.ZodLiteral<"canceled">;
576
- }, z.core.$strict>], "outcome">;
577
- type JobOutcome = z.infer<typeof JobOutcome>;
578
- /** A completed job as delivered to the app, provenance attached. */
579
- declare const DeliveredResult: z.ZodObject<{
580
- jobId: z.ZodString;
581
- state: z.ZodEnum<{
582
- ok: "ok";
583
- error: "error";
584
- queued: "queued";
585
- claimed: "claimed";
586
- running: "running";
587
- canceled: "canceled";
588
- expired: "expired";
589
- }>;
590
- outcome: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
591
- outcome: z.ZodLiteral<"ok">;
592
- text: z.ZodString;
593
- artifactUrl: z.ZodOptional<z.ZodURL>;
594
- }, z.core.$strict>, z.ZodObject<{
595
- outcome: z.ZodLiteral<"error">;
596
- code: z.ZodString;
597
- message: z.ZodString;
598
- retryable: z.ZodBoolean;
599
- }, z.core.$strict>, z.ZodObject<{
600
- outcome: z.ZodLiteral<"canceled">;
601
- }, z.core.$strict>], "outcome">>;
602
- provenance: z.ZodOptional<z.ZodObject<{
603
- audience: z.ZodEnum<{
604
- self: "self";
605
- named: "named";
606
- public: "public";
607
- }>;
608
- runnerId: z.ZodString;
609
- runnerOwner: z.ZodString;
610
- backendClass: z.ZodEnum<{
611
- http: "http";
612
- process: "process";
613
- }>;
614
- model: z.ZodString;
615
- untrusted: z.ZodBoolean;
616
- }, z.core.$strict>>;
617
- }, z.core.$strict>;
618
- type DeliveredResult = z.infer<typeof DeliveredResult>;
619
- /**
620
- * How big a payload is, in buckets — byollm_009 §6.
621
- *
622
- * A relay routes without reading, and matching a job to a machine needs some
623
- * notion of size. Buckets rather than byte counts because the exact figure is
624
- * a stronger fingerprint than the routing decision requires, and because a
625
- * bucket survives compression and encoding changes that an exact count does
626
- * not.
627
- *
628
- * `unbounded` exists for streamed jobs, which have no size when they start.
629
- * It is reserved now rather than added later: byollm_009 §8.1 — adding a
630
- * field to a published envelope is the v2 break all over again.
631
- */
632
- declare const SizeClass: z.ZodEnum<{
633
- small: "small";
634
- medium: "medium";
635
- large: "large";
636
- unbounded: "unbounded";
637
- }>;
638
- type SizeClass = z.infer<typeof SizeClass>;
639
- /** Where the bucket boundaries sit, in characters of payload text. */
640
- declare const SIZE_CLASS_LIMITS: Readonly<{
641
- small: 4000;
642
- medium: 64000;
643
- large: number;
644
- }>;
645
- /**
646
- * The most a payload in this bucket can be.
647
- *
648
- * Used where a decision must be made from a stub, before the payload has been
649
- * fetched — a budget check, for instance. Charging the bucket's ceiling is the
650
- * conservative direction: it refuses slightly too eagerly rather than
651
- * admitting work that turns out larger than the budget allowed.
652
- *
653
- * `unbounded` returns `Infinity`, which fails every ceiling. That is correct
654
- * until byollm_006 defines how a streamed job is budgeted — failing closed on
655
- * a case nobody has designed beats inventing an allowance for it.
656
- */
657
- declare function sizeClassCeiling(sizeClass: SizeClass): number;
658
- /** Bucket a payload by its text length. */
659
- declare function sizeClassOf(textChars: number): SizeClass;
660
- /**
661
- * Everything an upstream may see about a job — byollm_009 §6.
662
- *
663
- * **This list is exhaustive and normative.** It is a commitment about the
664
- * metadata surface, not an accident of what the implementation happens to
665
- * send: an upstream that requires more has exceeded the protocol, and an
666
- * endpoint that emits more has leaked past it
667
- * ({@link MUSTS.STUB_METADATA_EXHAUSTIVE}).
668
- *
669
- * What is absent is the point. No payload, no model, no prompt, no result.
670
- * `kind` is here because capability matching happens upstream; if a later
671
- * revision moves matching to the daemon, `kind` moves into the ciphertext.
672
- */
673
- declare const JobStub: z.ZodObject<{
674
- id: z.ZodString;
178
+ type Capability = z.infer<typeof Capability>;
179
+ /** The capability matrix a daemon advertises. */
180
+ declare const CapabilityMatrix: z.ZodArray<z.ZodObject<{
675
181
  kind: z.ZodEnum<{
676
182
  "llm.generate": "llm.generate";
677
183
  "llm.chat": "llm.chat";
678
184
  }>;
679
- owner: z.ZodString;
680
- audience: z.ZodEnum<{
681
- self: "self";
682
- named: "named";
683
- public: "public";
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";
684
206
  }>;
685
- audienceAllow: z.ZodOptional<z.ZodArray<z.ZodString>>;
686
- sizeClass: z.ZodEnum<{
687
- small: "small";
688
- medium: "medium";
689
- large: "large";
690
- unbounded: "unbounded";
207
+ backendClass: z.ZodEnum<{
208
+ http: "http";
209
+ process: "process";
691
210
  }>;
692
- streaming: z.ZodBoolean;
693
- deadlineAt: z.ZodNumber;
694
- }, z.core.$strict>;
695
- type JobStub = z.infer<typeof JobStub>;
696
- /** A stub, plus the lease the claiming runner now holds for it. */
697
- declare const ClaimedStub: z.ZodObject<{
698
- id: z.ZodString;
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>;
219
+ /**
220
+ * A kind this device could serve and deliberately does not — byollm_016.
221
+ *
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.
232
+ */
233
+ declare const WithheldKind: z.ZodObject<{
699
234
  kind: z.ZodEnum<{
700
235
  "llm.generate": "llm.generate";
701
236
  "llm.chat": "llm.chat";
702
237
  }>;
703
- owner: z.ZodString;
704
- audience: z.ZodEnum<{
705
- self: "self";
706
- named: "named";
707
- public: "public";
708
- }>;
709
- audienceAllow: z.ZodOptional<z.ZodArray<z.ZodString>>;
710
- sizeClass: z.ZodEnum<{
711
- small: "small";
712
- medium: "medium";
713
- large: "large";
714
- unbounded: "unbounded";
715
- }>;
716
- streaming: z.ZodBoolean;
717
- deadlineAt: z.ZodNumber;
718
- lease: z.ZodObject<{
719
- id: z.ZodString;
720
- runnerId: z.ZodString;
721
- expiresAt: z.ZodNumber;
722
- }, z.core.$strip>;
723
- }, z.core.$strict>;
724
- type ClaimedStub = z.infer<typeof ClaimedStub>;
725
-
726
- /**
727
- * Device and site keys — byollm_009 §3.
728
- *
729
- * **Two keypairs per party, and the split is load-bearing.** An Ed25519
730
- * *identity* key signs; an X25519 *encryption* key receives sealed envelopes.
731
- * The encryption key is signed by the identity key, and **the identity key is
732
- * what gets pinned**. So "who sent this" and "who can read this" are answered
733
- * by different keys — which is what lets an encryption key rotate without
734
- * re-establishing trust, and what byollm_009 §6's signed-then-sealed envelope
735
- * depends on.
736
- *
737
- * **No new dependency.** byollm_009 §2 says established primitives only, via
738
- * libsodium. Everything *this* module needs — Ed25519 signing, X25519 key
739
- * generation — Node provides natively, and using it costs nothing and adds no
740
- * install weight to a daemon that must land fast on a stranger's laptop.
741
- *
742
- * libsodium becomes necessary at envelope v2, where sealing does. That is a
743
- * real dependency decision and it belongs in the change that needs it: a
744
- * sealed box is a specific reviewed construction, and rebuilding it out of
745
- * Node primitives is exactly the "novel construction" §2 rules out. Deferring
746
- * the dependency is not the same as deferring the rule.
747
- */
748
- /** A public identity, as it travels on the wire. All values base64url. */
749
- declare const PublicIdentity: z.ZodObject<{
750
- identity: z.ZodString;
751
- encryption: z.ZodString;
752
- encryptionSig: z.ZodString;
753
- }, z.core.$strict>;
754
- type PublicIdentity = z.infer<typeof PublicIdentity>;
755
- /** Private key material, as stored on disk. Never leaves the machine. */
756
- declare const StoredKeys: z.ZodObject<{
757
- version: z.ZodLiteral<1>;
758
- identityPublic: z.ZodString;
759
- identityPrivate: z.ZodString;
760
- encryptionPublic: z.ZodString;
761
- encryptionPrivate: z.ZodString;
762
- encryptionSig: z.ZodString;
763
- createdAt: z.ZodNumber;
238
+ claimants: z.ZodArray<z.ZodObject<{
239
+ service: z.ZodString;
240
+ offer: z.ZodEnum<{
241
+ private: "private";
242
+ team: "team";
243
+ }>;
244
+ }, z.core.$strict>>;
764
245
  }, z.core.$strict>;
765
- type StoredKeys = z.infer<typeof StoredKeys>;
766
- /** Generate a fresh pair of keypairs and bind them together. */
767
- declare function generateKeys(now: number): StoredKeys;
768
- /** The public half, for the wire. */
769
- declare function publicIdentityOf(keys: StoredKeys): PublicIdentity;
770
- /**
771
- * Check that an encryption key really belongs to the identity presenting it.
772
- *
773
- * Called on everything received, including from an upstream we otherwise
774
- * trust — the point of pinning the identity is that nothing else needs to be
775
- * trusted, and that only holds if this is checked every time rather than at
776
- * first sight.
777
- */
778
- declare function verifyPublicIdentity(identity: PublicIdentity): boolean;
779
- /** Sign arbitrary bytes with an identity key. */
780
- declare function signWith(keys: StoredKeys, data: Uint8Array): string;
781
- /** Verify bytes against a raw Ed25519 public key. */
782
- declare function verifyWith(identityPublic: string, data: Uint8Array, signature: string): boolean;
783
- /**
784
- * A fingerprint a human can compare out loud.
785
- *
786
- * 120 bits of SHA-256 over the raw identity key, as six groups of four. Long
787
- * enough that grinding a colliding key is not worth anyone's afternoon, short
788
- * enough to read down a phone line — which is the whole point. A fingerprint
789
- * nobody can be bothered to compare provides no security at all, so
790
- * legibility is a security property here, not a nicety.
791
- *
792
- * Formatted with a `BYOLLM-` prefix so a pasted fingerprint is recognisable
793
- * out of context, in a support thread or a screenshot.
794
- */
795
- declare function fingerprint(identityPublic: string): string;
796
- /** The short id used in envelopes and provenance. Stable, and comparable. */
797
- declare const keyId: (identityPublic: string) => string;
798
-
799
- declare function cryptoReady(): Promise<void>;
246
+ type WithheldKind = z.infer<typeof WithheldKind>;
800
247
  /**
801
- * How long a sealed payload is worth keeping, from creation.
248
+ * One grant, named by both halves V1-3.
802
249
  *
803
- * Bound into every envelope and recomputed when one is opened, so it lives
804
- * here rather than in the two places that need it. Two copies of a value the
805
- * signature depends on is the same bug as two clock readings: it works until
806
- * they disagree, and then nothing can be opened.
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.
807
253
  *
808
- * Not a job's TTL. That answers how long the *work* is worth doing, belongs
809
- * to the app and the store, and may legitimately differ per deployment.
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.
810
257
  */
811
- declare const ENVELOPE_MAX_AGE_MS: number;
812
- /** Which leg an envelope belongs to. Bound into the signature. */
813
- declare const EnvelopeDirection: z.ZodEnum<{
814
- payload: "payload";
815
- result: "result";
816
- }>;
817
- type EnvelopeDirection = z.infer<typeof EnvelopeDirection>;
818
- declare const SealedEnvelope: z.ZodObject<{
819
- ciphertext: z.ZodString;
820
- recipientKeyId: z.ZodString;
821
- senderKeyId: z.ZodString;
822
- direction: z.ZodEnum<{
823
- payload: "payload";
824
- result: "result";
825
- }>;
826
- deadlineAt: z.ZodNumber;
258
+ declare const GrantRef: z.ZodObject<{
259
+ jobId: z.ZodString;
260
+ leaseId: z.ZodString;
827
261
  }, z.core.$strict>;
828
- type SealedEnvelope = z.infer<typeof SealedEnvelope>;
829
- /** Everything the signature covers besides the plaintext itself. */
830
- interface EnvelopeContext {
831
- readonly jobId: string;
832
- readonly senderKeyId: string;
833
- readonly recipientKeyId: string;
834
- readonly deadlineAt: number;
835
- readonly direction: EnvelopeDirection;
836
- }
837
- /** Seal a plaintext to a recipient, signed by the sender's identity. */
838
- declare function seal(input: {
839
- plaintext: string;
840
- senderKeys: StoredKeys;
841
- recipientEncryptionPublic: string;
842
- context: EnvelopeContext;
843
- }): Promise<SealedEnvelope>;
844
- /** Why an envelope was refused. Never distinguished to a remote caller. */
845
- type EnvelopeFailure = "not-for-us" | "unopenable" | "malformed" | "bad-signature" | "context-mismatch";
846
- type OpenResult = {
847
- readonly ok: true;
848
- readonly plaintext: string;
849
- } | {
850
- readonly ok: false;
851
- readonly reason: EnvelopeFailure;
852
- };
262
+ type GrantRef = z.infer<typeof GrantRef>;
853
263
  /**
854
- * Open an envelope and verify it came from the pinned sender.
855
- *
856
- * Every failure returns rather than throws: this runs on input from the
857
- * network, and a crash here is a denial of service on the delivery path.
858
- *
859
- * The context is checked against the signature, not merely read from the
860
- * envelope. An envelope carries its own claims about who sent it and to
861
- * whom — believing those would authenticate the attacker's assertion rather
862
- * than the sender's key.
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.
863
269
  */
864
- declare function open(input: {
865
- envelope: SealedEnvelope;
866
- recipientKeys: StoredKeys;
867
- senderIdentityPublic: string;
868
- /** The deadline is taken from the envelope and checked against its signature. */
869
- expected: Omit<EnvelopeContext, "deadlineAt">;
870
- }): Promise<OpenResult>;
871
-
872
- /**
873
- * Request signing — byollm_009 §4.2.
874
- *
875
- * Every authenticated call is signed by the calling device's identity key.
876
- * There is no bearer token on the daemon plane: possession of a file no
877
- * longer grants access, possession of a *key* does, and the key never leaves
878
- * the machine.
879
- *
880
- * ## Why this is not the server-issued nonce the spec first described
881
- *
882
- * byollm_009 §4.2 says "the upstream issues a nonce; the daemon signs it".
883
- * Implementing that costs one of two things: a round trip before every
884
- * request, or server-side session state — and sessions reintroduce a bearer
885
- * credential, which is the thing being removed.
886
- *
887
- * Signing *the request itself* gets the same property without either, because
888
- * of something the protocol already guarantees. A captured signature is valid
889
- * only for the exact request it covers — same endpoint, same runner, same
890
- * body — and every authenticated endpoint here is idempotent by design:
891
- * `RESULT_IDEMPOTENT` makes a replayed result a no-op, a replayed claim from
892
- * the same runner returns what that runner already holds, and heartbeat and
893
- * release are idempotent in effect. So a replay inside the freshness window
894
- * gains an attacker nothing they could not obtain by forwarding the original,
895
- * which a relay can do anyway.
896
- *
897
- * That is the whole argument, and it is worth stating because it rests
898
- * entirely on the endpoints being idempotent. Two ways that can fail, and the
899
- * second is the one that actually bit:
900
- *
901
- * 1. **A future endpoint that is not idempotent cannot use this scheme
902
- * unchanged** — it would need a server-issued nonce.
903
- * 2. **Idempotence must hold per *addressed instance*, not per endpoint.** A
904
- * request that names a mutable target — a lease, a session, a
905
- * subscription — must name the *instance*, or a replay lands on a
906
- * different one than the sender meant and the endpoint's idempotence buys
907
- * nothing. `release` was idempotent per lease and ambiguous across them:
908
- * it named a job and a runner, both of which survive a
909
- * claim-release-reclaim cycle, so a replayed release yanked a later grant.
910
- * Fixed by giving a lease its own id and requiring it.
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>>;
325
+ }, z.core.$strict>;
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;
333
+ }, z.core.$strict>;
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;
339
+ }, z.core.$strict>;
340
+ type PairPollRequest = z.infer<typeof PairPollRequest>;
341
+ declare const PairPollResponse: z.ZodDiscriminatedUnion<[z.ZodObject<{
342
+ status: z.ZodLiteral<"pending">;
343
+ }, z.core.$strict>, z.ZodObject<{
344
+ status: z.ZodLiteral<"denied">;
345
+ }, z.core.$strict>, z.ZodObject<{
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";
403
+ }>;
404
+ backendClass: z.ZodEnum<{
405
+ http: "http";
406
+ process: "process";
407
+ }>;
408
+ model: z.ZodString;
409
+ knownModels: z.ZodOptional<z.ZodArray<z.ZodString>>;
410
+ offerScope: z.ZodEnum<{
411
+ private: "private";
412
+ team: "team";
413
+ }>;
414
+ }, z.core.$strict>>;
415
+ }, z.core.$strict>, z.ZodObject<{
416
+ protocolVersion: z.ZodLiteral<"1">;
417
+ action: z.ZodLiteral<"poll">;
418
+ deviceCode: z.ZodString;
419
+ }, z.core.$strict>], "action">;
420
+ type PairRequest = z.infer<typeof PairRequest>;
421
+ declare const ClaimRequest: z.ZodObject<{
422
+ protocolVersion: z.ZodLiteral<"1">;
423
+ runnerId: z.ZodString;
424
+ capabilities: z.ZodArray<z.ZodObject<{
425
+ kind: z.ZodEnum<{
426
+ "llm.generate": "llm.generate";
427
+ "llm.chat": "llm.chat";
428
+ }>;
429
+ service: z.ZodString;
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";
447
+ "openai-http": "openai-http";
448
+ "claude-cli": "claude-cli";
449
+ "codex-cli": "codex-cli";
450
+ }>;
451
+ backendClass: z.ZodEnum<{
452
+ http: "http";
453
+ process: "process";
454
+ }>;
455
+ model: z.ZodString;
456
+ knownModels: z.ZodOptional<z.ZodArray<z.ZodString>>;
457
+ offerScope: z.ZodEnum<{
458
+ private: "private";
459
+ team: "team";
460
+ }>;
461
+ }, z.core.$strict>>;
462
+ max: z.ZodNumber;
463
+ }, z.core.$strict>;
464
+ type ClaimRequest = z.infer<typeof ClaimRequest>;
465
+ declare const ClaimResponse: z.ZodObject<{
466
+ jobs: z.ZodArray<z.ZodObject<{
467
+ id: z.ZodString;
468
+ kind: z.ZodEnum<{
469
+ "llm.generate": "llm.generate";
470
+ "llm.chat": "llm.chat";
471
+ }>;
472
+ owner: z.ZodString;
473
+ site: z.ZodString;
474
+ audience: z.ZodEnum<{
475
+ private: "private";
476
+ team: "team";
477
+ }>;
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;
487
+ lease: z.ZodObject<{
488
+ id: z.ZodString;
489
+ runnerId: z.ZodString;
490
+ expiresAt: z.ZodNumber;
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>>;
504
+ }, z.core.$strict>>;
505
+ leaseMs: z.ZodNumber;
506
+ }, z.core.$strict>;
507
+ type ClaimResponse = z.infer<typeof ClaimResponse>;
508
+ declare const HeartbeatRequest: z.ZodObject<{
509
+ protocolVersion: z.ZodLiteral<"1">;
510
+ runnerId: z.ZodString;
511
+ daemonVersion: z.ZodString;
512
+ capabilities: z.ZodArray<z.ZodObject<{
513
+ kind: z.ZodEnum<{
514
+ "llm.generate": "llm.generate";
515
+ "llm.chat": "llm.chat";
516
+ }>;
517
+ service: z.ZodString;
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";
535
+ "openai-http": "openai-http";
536
+ "claude-cli": "claude-cli";
537
+ "codex-cli": "codex-cli";
538
+ }>;
539
+ backendClass: z.ZodEnum<{
540
+ http: "http";
541
+ process: "process";
542
+ }>;
543
+ model: z.ZodString;
544
+ knownModels: z.ZodOptional<z.ZodArray<z.ZodString>>;
545
+ offerScope: z.ZodEnum<{
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";
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;
566
+ }, z.core.$strict>>;
567
+ paused: z.ZodBoolean;
568
+ }, z.core.$strict>;
569
+ type HeartbeatRequest = z.infer<typeof HeartbeatRequest>;
570
+ declare const HeartbeatResponse: 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<{
588
+ jobId: z.ZodString;
589
+ leaseId: z.ZodString;
590
+ }, z.core.$strict>>;
591
+ lost: z.ZodArray<z.ZodObject<{
592
+ jobId: z.ZodString;
593
+ leaseId: z.ZodString;
594
+ }, z.core.$strict>>;
595
+ serverTime: z.ZodNumber;
596
+ awaitingConsent: z.ZodArray<z.ZodString>;
597
+ updateTo: z.ZodOptional<z.ZodString>;
598
+ }, z.core.$strict>;
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>;
618
+ declare const ResultRequest: z.ZodObject<{
619
+ protocolVersion: z.ZodLiteral<"1">;
620
+ runnerId: z.ZodString;
621
+ jobId: z.ZodString;
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";
637
+ }>;
638
+ }, z.core.$strict>;
639
+ type ResultRequest = z.infer<typeof ResultRequest>;
640
+ declare const ResultResponse: z.ZodObject<{
641
+ accepted: z.ZodBoolean;
642
+ duplicate: z.ZodOptional<z.ZodBoolean>;
643
+ state: z.ZodString;
644
+ }, z.core.$strict>;
645
+ type ResultResponse = z.infer<typeof ResultResponse>;
646
+ declare const ReleaseRequest: z.ZodObject<{
647
+ protocolVersion: z.ZodLiteral<"1">;
648
+ runnerId: z.ZodString;
649
+ leases: z.ZodArray<z.ZodObject<{
650
+ jobId: z.ZodString;
651
+ leaseId: z.ZodString;
652
+ }, z.core.$strict>>;
653
+ reason: z.ZodEnum<{
654
+ refused: "refused";
655
+ shutdown: "shutdown";
656
+ pause: "pause";
657
+ revoked: "revoked";
658
+ "backend-down": "backend-down";
659
+ }>;
660
+ }, z.core.$strict>;
661
+ type ReleaseRequest = z.infer<typeof ReleaseRequest>;
662
+ declare const ReleaseResponse: z.ZodObject<{
663
+ released: z.ZodArray<z.ZodString>;
664
+ }, z.core.$strict>;
665
+ type ReleaseResponse = z.infer<typeof ReleaseResponse>;
666
+ /**
667
+ * Wire error codes.
668
+ *
669
+ * byollm_002 requires that "server unreachable", "revoked", "no matching
670
+ * work" and "backend down" never share a message. Distinct codes here are how
671
+ * the daemon can tell three of those apart; the fourth is a transport failure
672
+ * with no response at all.
673
+ */
674
+ declare const WireErrorCode: z.ZodEnum<{
675
+ "unsupported-protocol-version": "unsupported-protocol-version";
676
+ revoked: "revoked";
677
+ "bad-request": "bad-request";
678
+ "daemon-below-floor": "daemon-below-floor";
679
+ unauthorized: "unauthorized";
680
+ forbidden: "forbidden";
681
+ "not-found": "not-found";
682
+ "not-ready": "not-ready";
683
+ "too-late": "too-late";
684
+ "clock-skew": "clock-skew";
685
+ "rate-limited": "rate-limited";
686
+ "server-error": "server-error";
687
+ }>;
688
+ type WireErrorCode = z.infer<typeof WireErrorCode>;
689
+ declare const WireError: z.ZodObject<{
690
+ error: z.ZodEnum<{
691
+ "unsupported-protocol-version": "unsupported-protocol-version";
692
+ revoked: "revoked";
693
+ "bad-request": "bad-request";
694
+ "daemon-below-floor": "daemon-below-floor";
695
+ unauthorized: "unauthorized";
696
+ forbidden: "forbidden";
697
+ "not-found": "not-found";
698
+ "not-ready": "not-ready";
699
+ "too-late": "too-late";
700
+ "clock-skew": "clock-skew";
701
+ "rate-limited": "rate-limited";
702
+ "server-error": "server-error";
703
+ }>;
704
+ message: z.ZodString;
705
+ supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
706
+ minimum: z.ZodOptional<z.ZodString>;
707
+ floor: z.ZodOptional<z.ZodString>;
708
+ retryAfter: z.ZodOptional<z.ZodNumber>;
709
+ serverTime: z.ZodOptional<z.ZodNumber>;
710
+ maxSkewMs: z.ZodOptional<z.ZodNumber>;
711
+ }, z.core.$strict>;
712
+ type WireError = z.infer<typeof WireError>;
713
+ /** HTTP status each error code is served with. */
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.
911
1052
  *
912
- * The rule for anything added later: if a signed request can be replayed onto
913
- * a target that has changed underneath it, the request has to say which
914
- * target it meant.
1053
+ * @throws if the id is not registered an unregistered backend has no
1054
+ * adversarial corpus, so refusing is the safe direction.
915
1055
  */
916
- /** How far a request's timestamp may be from the server's clock. */
917
- declare const MAX_CLOCK_SKEW_MS = 120000;
918
- /** The signed material a request carries. */
919
- declare const RequestSignature: z.ZodObject<{
920
- runnerId: z.ZodString;
921
- issuedAt: z.ZodNumber;
922
- signature: z.ZodString;
923
- }, z.core.$strict>;
924
- type RequestSignature = z.infer<typeof RequestSignature>;
1056
+ declare function backendDescriptor(id: BackendId): BackendDescriptor;
925
1057
  /**
926
- * The exact bytes both sides sign and verify.
1058
+ * Is this host local enough that compute there is free?
927
1059
  *
928
- * Newline-separated with a version prefix and a domain separator. Every field
929
- * that decides what the request *does* is in here: leave one out and it
930
- * becomes something an intermediary can change without breaking the
931
- * signature.
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.
932
1064
  *
933
- * The body is included by hash rather than by value, so signing does not
934
- * depend on both sides serialising JSON identically which they would not.
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.
935
1073
  */
936
- declare function canonicalRequest(input: {
937
- endpoint: string;
938
- runnerId: string;
939
- issuedAt: number;
940
- body: string;
941
- }): Buffer;
942
- /** Sign an outgoing request with this machine's identity key. */
943
- declare function signRequest(keys: StoredKeys, input: {
944
- endpoint: string;
945
- runnerId: string;
946
- issuedAt: number;
947
- body: string;
948
- }): RequestSignature;
1074
+ declare function isLocalHost(hostname: string): boolean;
949
1075
  /**
950
- * The same scheme, for the party at the other end: a **site** calling a relay.
951
- *
952
- * A site talking to a relay is in exactly the daemon's position — an outbound
953
- * caller with an identity keypair the other side already pins so it gets the
954
- * daemon's authentication rather than a second scheme. Bearer tokens for the
955
- * site plane were the alternative, and they would have reintroduced the
956
- * credential-in-a-file that §4.2 removed from the daemon plane, on the plane
957
- * that carries *every* site's traffic.
958
- *
959
- * Two things make this safe to build on the same canonical string:
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.
960
1100
  *
961
- * 1. **The endpoint is namespaced.** Site endpoints sign `site/enqueue`, never
962
- * `enqueue`. The daemon plane's `result` and the site plane's `results` are
963
- * one character apart, and a naming collision between planes must not be
964
- * what stands between a signature and a replay onto the wrong handler. The
965
- * prefix is applied *inside* these helpers, so the two ends cannot disagree
966
- * about it — the alternative is two implementations of one bound value,
967
- * which is this project's most-repeated bug.
968
- * 2. **The caller slot carries the site id.** `canonicalRequest` names that
969
- * field `runnerId` because the daemon plane got there first; here it holds
970
- * the site id, and the verifier looks the key up in the projection's site
971
- * registry rather than its device registry. The two registries never share
972
- * an entry, so a device signature cannot authenticate as a site.
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.
973
1106
  *
974
- * §4.2's replay argument carries over **only because the site plane's writes
975
- * are idempotent per addressed instance**, which is a property that had to be
976
- * built rather than found: `enqueue` reset a job of the same id, so a replayed
977
- * enqueue inside the freshness window returned a claimed job to the queue and
978
- * threw away a device's live lease. Identical in shape to the `release` bug
979
- * above, on the other plane. Anything added to the site plane later must be
980
- * idempotent by the instance it names, or this scheme does not cover it.
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.
981
1113
  */
982
- declare function signSiteRequest(keys: StoredKeys, input: {
983
- endpoint: string;
984
- siteId: string;
985
- issuedAt: number;
986
- body: string;
987
- }): RequestSignature;
988
- /** Verify a site's call against the identity the control plane registered. */
989
- declare function verifySiteRequest(input: {
990
- identityPublic: string;
991
- endpoint: string;
992
- body: string;
993
- signature: RequestSignature;
994
- now: number;
995
- maxSkewMs?: number;
996
- }): SignatureFailure | null;
997
- /** Why a signed request was refused. Never returned to the caller verbatim. */
998
- type SignatureFailure = "stale" | "bad-signature";
1114
+ declare function resolveCost(id: BackendId, baseUrl: string | undefined,
999
1115
  /**
1000
- * Verify a signed request against a runner's pinned identity key.
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.
1001
1149
  *
1002
- * Freshness is checked in **both** directions. A clock far ahead is as much a
1003
- * problem as one behind: it would let a captured request stay replayable long
1004
- * after it was made, which is the one thing the window exists to bound.
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.
1005
1163
  */
1006
- declare function verifyRequest(input: {
1007
- identityPublic: string;
1008
- endpoint: string;
1009
- body: string;
1010
- signature: RequestSignature;
1011
- now: number;
1012
- maxSkewMs?: number;
1013
- }): SignatureFailure | null;
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;
1014
1171
 
1015
1172
  /**
1016
- * The normative MUSTs of protocol v0, as data.
1017
- *
1018
- * byollm_001 requires that "every MUST above has a conformance test id
1019
- * referenced inline". Keeping the MUSTs as a frozen registry rather than
1020
- * prose is what makes that requirement *checkable*: the conformance kit
1021
- * imports {@link MUSTS} and fails if any id has no test asserting it, so a
1022
- * new MUST cannot be added without a test and a test cannot silently drift
1023
- * away from the statement it claims to prove.
1173
+ * Who may run a job, declared by the app that enqueued it.
1024
1174
  *
1025
- * Ids are stable and public third-party servers cite them in their
1026
- * certification output.
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.
1027
1194
  */
1028
- /** Which side of the wire is obliged to enforce a given MUST. */
1029
- type MustEnforcer = "daemon" | "server" | "both";
1195
+ declare const Audience: z.ZodEnum<{
1196
+ private: "private";
1197
+ team: "team";
1198
+ }>;
1199
+ type Audience = z.infer<typeof Audience>;
1030
1200
  /**
1031
- * How a MUST is actually verified which is not the same question as who
1032
- * enforces it, and is the one that decides what "byollm-compatible" means.
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.
1033
1256
  *
1034
- * The conformance kit's credibility rests on an implicit claim that every
1035
- * MUST is checkable. Ten of them were not, and the kit reported that honestly
1036
- * while nothing acted on it. Making the kind explicit turns "uncovered" from
1037
- * a number needing a paragraph of explanation into a number that should be
1038
- * zero.
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:
1039
1260
  *
1040
- * - `conformance` the kit asserts it against *any* implementation. This is
1041
- * the strong kind: a third party runs the suite and learns something.
1042
- * - `adversarial` proved by the reference daemon's own suites in this repo
1043
- * (the hostile-payload corpus, or its unit tests). Real verification, and
1044
- * it runs in CIbut it proves things about *our* daemon, not about
1045
- * someone else's, so the kit cannot carry it.
1046
- * - `construction` true by the shape of the code, where a test could only
1047
- * sample. A reviewer verifies it; a suite cannot.
1048
- * - `operator` — a claim about how someone runs a deployment, verifiable only
1049
- * by audit or by reading source. The honest category, and the one that
1050
- * exists so a property nobody can check from outside is *labelled* as such
1051
- * rather than laundered by association with the checkable ones.
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.
1052
1269
  */
1053
- type MustVerification = "conformance" | "adversarial" | "construction" | "operator";
1054
- /** A single normative requirement of the protocol. */
1055
- interface Must {
1056
- /** Stable public id, cited by conformance output. */
1057
- readonly id: string;
1058
- /** The requirement, in MUST language. */
1059
- readonly statement: string;
1060
- /** Which implementation is obliged to enforce it. */
1061
- readonly enforcedBy: MustEnforcer;
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;
1062
1277
  /**
1063
- * How this is verified. `conformance` is the only kind the kit can assert;
1064
- * see {@link MustVerification} for why the others exist.
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.
1065
1312
  */
1066
- readonly verifiedBy: MustVerification;
1067
- /** Spec section this was adjudicated in. */
1068
- readonly source: string;
1313
+ readonly admits: (owner: string) => boolean;
1069
1314
  }
1070
1315
  /**
1071
- * Every normative MUST in protocol v0.
1316
+ * Decide whether a job may run on a daemon.
1072
1317
  *
1073
- * @remarks
1074
- * Grouped by concern for readability; the conformance kit treats this as a
1075
- * flat set. Adding an entry here without a corresponding conformance test is
1076
- * a CI failure, by design.
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
+ * ```
1077
1340
  */
1078
- declare const MUSTS: Readonly<{
1079
- readonly PAIR_ONE_USER: Must;
1080
- readonly PAIR_INTERACTIVE: Must;
1081
- readonly PAIR_CODE_EXPIRES: Must;
1082
- readonly VERSION_HANDSHAKE_REQUIRED: Must;
1083
- readonly KEYS_EXCHANGED_AT_CONSENT: Must;
1084
- readonly REQUESTS_SIGNED_NOT_BEARER: Must;
1085
- readonly LEASE_SCOPED_BY_GRANT: Must;
1086
- readonly STUB_METADATA_EXHAUSTIVE: Must;
1087
- readonly ENVELOPE_SEALED_AND_SIGNED: Must;
1088
- readonly KIND_TYPED_ONLY: Must;
1089
- readonly KIND_NO_CODE: Must;
1090
- readonly CLAIM_REQUIRES_CAPABILITY: Must;
1091
- readonly CAPABILITY_IS_DETECTED: Must;
1092
- readonly CLAIM_ATOMIC: Must;
1093
- readonly LEASE_HONORED: Must;
1094
- readonly LEASE_RECLAIMABLE: Must;
1095
- readonly AUDIENCE_BOTH_SIDES: Must;
1096
- readonly SUBSCRIPTION_SELF_LOCK: Must;
1097
- readonly METERED_DEFAULTS_SELF: Must;
1098
- readonly METERED_REQUIRES_CEILING: Must;
1099
- readonly COST_NOT_CONFIGURABLE: Must;
1100
- readonly REMOTE_IS_NEVER_FREE: Must;
1101
- readonly NAMED_LOCAL_ALLOWLIST: Must;
1102
- readonly REFUSAL_NOT_REOFFERED: Must;
1103
- readonly REVOCATION_HONORED: Must;
1104
- readonly CANCEL_HONORED: Must;
1105
- readonly DEPENDS_ON_GATING: Must;
1106
- readonly TTL_EXPIRY: Must;
1107
- readonly NO_RUNNER_SIGNAL: Must;
1108
- readonly RESULT_IDEMPOTENT: Must;
1109
- readonly RESULT_PROVENANCE: Must;
1110
- readonly INGRESS_LOGGED_BEFORE_EXECUTION: Must;
1111
- readonly NO_SHELL_INTERPOLATION: Must;
1112
- readonly NO_PAYLOAD_ROUTING: Must;
1113
- readonly STRIPPED_CHILD_ENV: Must;
1114
- readonly HTTP_BASE_URL_SAFE: Must;
1115
- readonly OUTPUT_INERT: Must;
1116
- readonly COMMUNITY_BUDGETS: Must;
1117
- }>;
1118
- /** The id of any normative MUST. */
1119
- type MustId = keyof typeof MUSTS;
1120
- /** All MUST ids, for coverage checks. */
1121
- declare const MUST_IDS: readonly ("PAIR_ONE_USER" | "PAIR_INTERACTIVE" | "PAIR_CODE_EXPIRES" | "VERSION_HANDSHAKE_REQUIRED" | "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" | "RESULT_PROVENANCE" | "INGRESS_LOGGED_BEFORE_EXECUTION" | "NO_SHELL_INTERPOLATION" | "NO_PAYLOAD_ROUTING" | "STRIPPED_CHILD_ENV" | "HTTP_BASE_URL_SAFE" | "OUTPUT_INERT" | "COMMUNITY_BUDGETS")[];
1122
- /** Every MUST verified a particular way. */
1123
- declare function mustsVerifiedBy(kind: MustVerification): MustId[];
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>>;
1124
1348
 
1125
- /** Protocol version carried on every request; servers refuse what they can't speak. */
1126
- declare const PROTOCOL_VERSION: "0";
1127
1349
  /**
1128
- * Every protocol version this build can serve, **oldest first**.
1350
+ * Upper bounds on payload size, enforced at the schema so oversized input is
1351
+ * refused at parse time rather than somewhere deeper.
1129
1352
  *
1130
- * One entry today. It is a list rather than a constant because the shape of
1131
- * the check is the point: a server supporting two versions through a
1132
- * migration should not need a different code path from one supporting one.
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.
1133
1363
  */
1134
- declare const SUPPORTED_PROTOCOL_VERSIONS: readonly string[];
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
+ }>;
1135
1372
  /**
1136
- * The oldest version this build will talk toderived, not declared.
1137
- *
1138
- * Stating it separately would be a second thing to keep in step with the list
1139
- * above, and the failure would be silent: a minimum that no longer matches
1140
- * what is supported produces a refusal naming a version the server would in
1141
- * fact have accepted.
1373
+ * A conversation turn. `role` is a closed enumit is routing *within the
1374
+ * model call*, not routing of the call, so it cannot select a backend.
1142
1375
  */
1143
- declare const MIN_PROTOCOL_VERSION: string;
1144
- /** A structured refusal, so a daemon can say something useful to its owner. */
1145
- interface VersionRefusal {
1146
- readonly error: "unsupported-protocol-version";
1147
- readonly message: string;
1148
- readonly supported: readonly string[];
1149
- readonly minimum: string;
1150
- }
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>;
1151
1385
  /**
1152
- * Check the protocol version on an incoming request
1153
- * ({@link MUSTS.VERSION_HANDSHAKE_REQUIRED}).
1154
- *
1155
- * Returns a refusal, or `null` to proceed.
1386
+ * Payload for `llm.generate`.
1156
1387
  *
1157
- * **A missing version is refused the same way a wrong one is.** That is the
1158
- * half worth stating: before this existed, the version travelled as a
1159
- * `z.literal` inside each endpoint's schema, so a mismatch surfaced as a
1160
- * generic `bad-request` a daemon and a server discovered they disagreed by
1161
- * failing, with nothing in the response naming the disagreement. An error a
1162
- * user cannot act on is barely better than a hang.
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.
1163
1416
  *
1164
- * The message names the fix, because the person reading it is usually the one
1165
- * who has to apply it.
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.
1166
1422
  */
1167
- declare function checkProtocolVersion(body: unknown): VersionRefusal | null;
1168
- /** The path prefix all endpoints mount under. */
1169
- declare const PROTOCOL_PREFIX: "/byollm";
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;
1170
1456
  /**
1171
- * The endpoint names, in the order byollm_001 lists them, plus `fetch`.
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.
1172
1466
  *
1173
- * `fetch` is byollm_009 §6's second phase: a claim returns a stub, and the
1174
- * payload is collected separately by the device that took it. Two steps
1175
- * rather than one because a payload can only be sealed once its recipient is
1176
- * known — which is also what makes multi-device free.
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
+ * ```
1177
1475
  */
1178
- declare const ENDPOINTS: readonly ["pair", "claim", "fetch", "heartbeat", "result", "release"];
1179
- type Endpoint = (typeof ENDPOINTS)[number];
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>;
1180
1515
  /**
1181
- * One entry of the capability matrix: a kind this daemon can actually serve,
1182
- * right now, with the backend and model that would serve it.
1516
+ * A job as the daemon receives it from `/byollm/claim`.
1183
1517
  *
1184
- * Derived from owner config intersected with detected reality
1185
- * ({@link MUSTS.CAPABILITY_IS_DETECTED}) a configured-but-unreachable
1186
- * backend must not appear here. Carries `backendClass` so the app can tell
1187
- * whether a result came from a sandboxed spawn or an HTTP call
1188
- * (byollm_001 Rev 1 §A).
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.
1189
1522
  */
1190
- declare const Capability: z.ZodObject<{
1523
+ declare const ClaimedJob: z.ZodObject<{
1524
+ id: z.ZodString;
1191
1525
  kind: z.ZodEnum<{
1192
1526
  "llm.generate": "llm.generate";
1193
1527
  "llm.chat": "llm.chat";
1194
1528
  }>;
1195
- backendId: z.ZodEnum<{
1196
- ollama: "ollama";
1197
- mlx: "mlx";
1198
- llamacpp: "llamacpp";
1199
- vllm: "vllm";
1200
- lmstudio: "lmstudio";
1201
- jan: "jan";
1202
- localai: "localai";
1203
- anthropic: "anthropic";
1204
- openai: "openai";
1205
- gemini: "gemini";
1206
- grok: "grok";
1207
- groq: "groq";
1208
- openrouter: "openrouter";
1209
- together: "together";
1210
- deepseek: "deepseek";
1211
- mistral: "mistral";
1212
- "openai-http": "openai-http";
1213
- "claude-cli": "claude-cli";
1214
- }>;
1215
- backendClass: z.ZodEnum<{
1216
- http: "http";
1217
- process: "process";
1218
- }>;
1219
- model: z.ZodString;
1220
- offerScope: z.ZodEnum<{
1221
- self: "self";
1222
- named: "named";
1223
- public: "public";
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";
1224
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>;
1225
1556
  }, z.core.$strict>;
1226
- type Capability = z.infer<typeof Capability>;
1227
- /** The capability matrix a daemon advertises. */
1228
- declare const CapabilityMatrix: z.ZodArray<z.ZodObject<{
1229
- kind: z.ZodEnum<{
1230
- "llm.generate": "llm.generate";
1231
- "llm.chat": "llm.chat";
1232
- }>;
1233
- backendId: z.ZodEnum<{
1234
- ollama: "ollama";
1235
- mlx: "mlx";
1236
- llamacpp: "llamacpp";
1237
- vllm: "vllm";
1238
- lmstudio: "lmstudio";
1239
- jan: "jan";
1240
- localai: "localai";
1241
- anthropic: "anthropic";
1242
- openai: "openai";
1243
- gemini: "gemini";
1244
- grok: "grok";
1245
- groq: "groq";
1246
- openrouter: "openrouter";
1247
- together: "together";
1248
- deepseek: "deepseek";
1249
- mistral: "mistral";
1250
- "openai-http": "openai-http";
1251
- "claude-cli": "claude-cli";
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";
1252
1569
  }>;
1570
+ runnerId: z.ZodString;
1571
+ runnerOwner: z.ZodString;
1253
1572
  backendClass: z.ZodEnum<{
1254
1573
  http: "http";
1255
1574
  process: "process";
1256
1575
  }>;
1257
1576
  model: z.ZodString;
1258
- offerScope: z.ZodEnum<{
1259
- self: "self";
1260
- named: "named";
1261
- public: "public";
1262
- }>;
1263
- }, z.core.$strict>>;
1264
- type CapabilityMatrix = z.infer<typeof CapabilityMatrix>;
1577
+ untrusted: z.ZodBoolean;
1578
+ }, z.core.$strict>;
1579
+ type ResultProvenance = z.infer<typeof ResultProvenance>;
1265
1580
  /**
1266
- * Pairing is a device-code exchange, not a pasted secret
1267
- * ({@link MUSTS.PAIR_INTERACTIVE}). The daemon starts a pairing, shows the
1268
- * user a short code and a URL, and polls until the user approves it inside
1269
- * the app's own authenticated session. Nothing listens on the user's machine
1270
- * and nothing works over a copied string alone.
1581
+ * Build provenance for a completed job. `untrusted` is derived, never
1582
+ * supplied, so no caller can mark volunteer output as first-party.
1271
1583
  */
1272
- declare const PairStartRequest: z.ZodObject<{
1273
- protocolVersion: z.ZodLiteral<"0">;
1274
- action: z.ZodLiteral<"start">;
1275
- daemon: z.ZodObject<{
1276
- version: z.ZodString;
1277
- label: z.ZodString;
1278
- platform: z.ZodEnum<{
1279
- darwin: "darwin";
1280
- linux: "linux";
1281
- win32: "win32";
1282
- }>;
1283
- }, z.core.$strip>;
1284
- device: z.ZodObject<{
1285
- identity: z.ZodString;
1286
- encryption: z.ZodString;
1287
- encryptionSig: z.ZodString;
1288
- }, z.core.$strict>;
1289
- capabilities: z.ZodArray<z.ZodObject<{
1290
- kind: z.ZodEnum<{
1291
- "llm.generate": "llm.generate";
1292
- "llm.chat": "llm.chat";
1293
- }>;
1294
- backendId: z.ZodEnum<{
1295
- ollama: "ollama";
1296
- mlx: "mlx";
1297
- llamacpp: "llamacpp";
1298
- vllm: "vllm";
1299
- lmstudio: "lmstudio";
1300
- jan: "jan";
1301
- localai: "localai";
1302
- anthropic: "anthropic";
1303
- openai: "openai";
1304
- gemini: "gemini";
1305
- grok: "grok";
1306
- groq: "groq";
1307
- openrouter: "openrouter";
1308
- together: "together";
1309
- deepseek: "deepseek";
1310
- mistral: "mistral";
1311
- "openai-http": "openai-http";
1312
- "claude-cli": "claude-cli";
1313
- }>;
1314
- backendClass: z.ZodEnum<{
1315
- http: "http";
1316
- process: "process";
1317
- }>;
1318
- model: z.ZodString;
1319
- offerScope: z.ZodEnum<{
1320
- self: "self";
1321
- named: "named";
1322
- public: "public";
1323
- }>;
1324
- }, z.core.$strict>>;
1325
- }, z.core.$strict>;
1326
- type PairStartRequest = z.infer<typeof PairStartRequest>;
1327
- declare const PairStartResponse: z.ZodObject<{
1328
- deviceCode: z.ZodString;
1329
- userCode: z.ZodString;
1330
- verificationUrl: z.ZodURL;
1331
- expiresAt: z.ZodNumber;
1332
- pollIntervalMs: z.ZodNumber;
1333
- }, z.core.$strict>;
1334
- type PairStartResponse = z.infer<typeof PairStartResponse>;
1335
- declare const PairPollRequest: z.ZodObject<{
1336
- protocolVersion: z.ZodLiteral<"0">;
1337
- action: z.ZodLiteral<"poll">;
1338
- deviceCode: z.ZodString;
1339
- }, z.core.$strict>;
1340
- type PairPollRequest = z.infer<typeof PairPollRequest>;
1341
- declare const PairPollResponse: z.ZodDiscriminatedUnion<[z.ZodObject<{
1342
- status: z.ZodLiteral<"pending">;
1343
- }, z.core.$strict>, z.ZodObject<{
1344
- status: z.ZodLiteral<"denied">;
1345
- }, z.core.$strict>, z.ZodObject<{
1346
- status: z.ZodLiteral<"expired">;
1347
- }, z.core.$strict>, z.ZodObject<{
1348
- status: z.ZodLiteral<"approved">;
1349
- runnerToken: z.ZodString;
1350
- runnerId: z.ZodString;
1351
- owner: z.ZodString;
1352
- ownerLabel: z.ZodOptional<z.ZodString>;
1353
- site: z.ZodObject<{
1354
- identity: z.ZodString;
1355
- encryption: z.ZodString;
1356
- encryptionSig: z.ZodString;
1357
- }, z.core.$strict>;
1358
- }, z.core.$strict>], "status">;
1359
- type PairPollResponse = z.infer<typeof PairPollResponse>;
1360
- declare const PairRequest: z.ZodDiscriminatedUnion<[z.ZodObject<{
1361
- protocolVersion: z.ZodLiteral<"0">;
1362
- action: z.ZodLiteral<"start">;
1363
- daemon: z.ZodObject<{
1364
- version: z.ZodString;
1365
- label: z.ZodString;
1366
- platform: z.ZodEnum<{
1367
- darwin: "darwin";
1368
- linux: "linux";
1369
- win32: "win32";
1370
- }>;
1371
- }, z.core.$strip>;
1372
- device: z.ZodObject<{
1373
- identity: z.ZodString;
1374
- encryption: z.ZodString;
1375
- encryptionSig: z.ZodString;
1376
- }, z.core.$strict>;
1377
- capabilities: z.ZodArray<z.ZodObject<{
1378
- kind: z.ZodEnum<{
1379
- "llm.generate": "llm.generate";
1380
- "llm.chat": "llm.chat";
1381
- }>;
1382
- backendId: z.ZodEnum<{
1383
- ollama: "ollama";
1384
- mlx: "mlx";
1385
- llamacpp: "llamacpp";
1386
- vllm: "vllm";
1387
- lmstudio: "lmstudio";
1388
- jan: "jan";
1389
- localai: "localai";
1390
- anthropic: "anthropic";
1391
- openai: "openai";
1392
- gemini: "gemini";
1393
- grok: "grok";
1394
- groq: "groq";
1395
- openrouter: "openrouter";
1396
- together: "together";
1397
- deepseek: "deepseek";
1398
- mistral: "mistral";
1399
- "openai-http": "openai-http";
1400
- "claude-cli": "claude-cli";
1401
- }>;
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;
1402
1791
  backendClass: z.ZodEnum<{
1403
1792
  http: "http";
1404
1793
  process: "process";
1405
1794
  }>;
1406
- model: z.ZodString;
1407
- offerScope: z.ZodEnum<{
1408
- self: "self";
1409
- named: "named";
1410
- public: "public";
1411
- }>;
1412
- }, z.core.$strict>>;
1413
- }, z.core.$strict>, z.ZodObject<{
1414
- protocolVersion: z.ZodLiteral<"0">;
1415
- action: z.ZodLiteral<"poll">;
1416
- deviceCode: z.ZodString;
1417
- }, z.core.$strict>], "action">;
1418
- type PairRequest = z.infer<typeof PairRequest>;
1419
- declare const ClaimRequest: z.ZodObject<{
1420
- protocolVersion: z.ZodLiteral<"0">;
1421
- runnerId: z.ZodString;
1422
- capabilities: z.ZodArray<z.ZodObject<{
1423
- kind: z.ZodEnum<{
1424
- "llm.generate": "llm.generate";
1425
- "llm.chat": "llm.chat";
1426
- }>;
1427
- backendId: z.ZodEnum<{
1428
- ollama: "ollama";
1429
- mlx: "mlx";
1430
- llamacpp: "llamacpp";
1431
- vllm: "vllm";
1432
- lmstudio: "lmstudio";
1433
- jan: "jan";
1434
- localai: "localai";
1435
- anthropic: "anthropic";
1436
- openai: "openai";
1437
- gemini: "gemini";
1438
- grok: "grok";
1439
- groq: "groq";
1440
- openrouter: "openrouter";
1441
- together: "together";
1442
- deepseek: "deepseek";
1443
- mistral: "mistral";
1444
- "openai-http": "openai-http";
1445
- "claude-cli": "claude-cli";
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";
1446
1834
  }>;
1835
+ runnerId: z.ZodString;
1836
+ runnerOwner: z.ZodString;
1447
1837
  backendClass: z.ZodEnum<{
1448
1838
  http: "http";
1449
1839
  process: "process";
1450
1840
  }>;
1451
1841
  model: z.ZodString;
1452
- offerScope: z.ZodEnum<{
1453
- self: "self";
1454
- named: "named";
1455
- public: "public";
1456
- }>;
1842
+ untrusted: z.ZodBoolean;
1457
1843
  }, z.core.$strict>>;
1458
- max: z.ZodNumber;
1844
+ fallback: z.ZodOptional<z.ZodLiteral<true>>;
1459
1845
  }, z.core.$strict>;
1460
- type ClaimRequest = z.infer<typeof ClaimRequest>;
1461
- declare const ClaimResponse: z.ZodObject<{
1462
- jobs: z.ZodArray<z.ZodObject<{
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<{
1463
2059
  id: z.ZodString;
1464
- kind: z.ZodEnum<{
1465
- "llm.generate": "llm.generate";
1466
- "llm.chat": "llm.chat";
1467
- }>;
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;
1468
2068
  owner: z.ZodString;
1469
- audience: z.ZodEnum<{
1470
- self: "self";
1471
- named: "named";
1472
- public: "public";
1473
- }>;
1474
- audienceAllow: z.ZodOptional<z.ZodArray<z.ZodString>>;
1475
- sizeClass: z.ZodEnum<{
1476
- small: "small";
1477
- medium: "medium";
1478
- large: "large";
1479
- unbounded: "unbounded";
1480
- }>;
1481
- streaming: z.ZodBoolean;
1482
- deadlineAt: z.ZodNumber;
1483
- lease: z.ZodObject<{
1484
- id: z.ZodString;
1485
- runnerId: z.ZodString;
1486
- expiresAt: z.ZodNumber;
1487
- }, z.core.$strip>;
2069
+ purpose: z.ZodString;
2070
+ kind: z.ZodString;
2071
+ service: z.ZodString;
2072
+ issuedAt: z.ZodNumber;
2073
+ signature: z.ZodString;
1488
2074
  }, z.core.$strict>>;
1489
- leaseMs: z.ZodNumber;
1490
2075
  }, z.core.$strict>;
1491
- type ClaimResponse = z.infer<typeof ClaimResponse>;
1492
- declare const HeartbeatRequest: z.ZodObject<{
1493
- protocolVersion: z.ZodLiteral<"0">;
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<{
1494
2126
  runnerId: z.ZodString;
1495
- daemonVersion: z.ZodString;
1496
- capabilities: z.ZodArray<z.ZodObject<{
1497
- kind: z.ZodEnum<{
1498
- "llm.generate": "llm.generate";
1499
- "llm.chat": "llm.chat";
1500
- }>;
1501
- backendId: z.ZodEnum<{
1502
- ollama: "ollama";
1503
- mlx: "mlx";
1504
- llamacpp: "llamacpp";
1505
- vllm: "vllm";
1506
- lmstudio: "lmstudio";
1507
- jan: "jan";
1508
- localai: "localai";
1509
- anthropic: "anthropic";
1510
- openai: "openai";
1511
- gemini: "gemini";
1512
- grok: "grok";
1513
- groq: "groq";
1514
- openrouter: "openrouter";
1515
- together: "together";
1516
- deepseek: "deepseek";
1517
- mistral: "mistral";
1518
- "openai-http": "openai-http";
1519
- "claude-cli": "claude-cli";
1520
- }>;
1521
- backendClass: z.ZodEnum<{
1522
- http: "http";
1523
- process: "process";
1524
- }>;
1525
- model: z.ZodString;
1526
- offerScope: z.ZodEnum<{
1527
- self: "self";
1528
- named: "named";
1529
- public: "public";
1530
- }>;
1531
- }, z.core.$strict>>;
1532
- activeLeases: z.ZodArray<z.ZodObject<{
1533
- jobId: z.ZodString;
1534
- leaseId: z.ZodString;
1535
- }, z.core.$strip>>;
1536
- paused: z.ZodBoolean;
2127
+ issuedAt: z.ZodNumber;
2128
+ signature: z.ZodString;
1537
2129
  }, z.core.$strict>;
1538
- type HeartbeatRequest = z.infer<typeof HeartbeatRequest>;
1539
- declare const HeartbeatResponse: z.ZodObject<{
1540
- revoked: z.ZodBoolean;
1541
- cancel: z.ZodArray<z.ZodString>;
1542
- leases: z.ZodArray<z.ZodObject<{
1543
- jobId: z.ZodString;
1544
- expiresAt: z.ZodNumber;
1545
- }, z.core.$strict>>;
1546
- lost: z.ZodArray<z.ZodString>;
1547
- serverTime: z.ZodNumber;
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
+ }>>;
1548
2291
  }, z.core.$strict>;
1549
- type HeartbeatResponse = z.infer<typeof HeartbeatResponse>;
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"
1550
2505
  /**
1551
- * What an intermediary learns about how a job ended — byollm_009 §6.
2506
+ * Issued further in the future than clock drift explains.
1552
2507
  *
1553
- * The discriminator and nothing else. A relay has to know a job reached a
1554
- * terminal state, and whether it failed, because that decides whether the job
1555
- * leaves the queue or the app may re-enqueue. It does not have to know what
1556
- * the model said, or what an error said, and this is where that line is drawn.
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.
1557
2510
  *
1558
- * Kept identical to `JobOutcome`'s discriminator rather than coarsened to
1559
- * ok/not-ok: a cancelled job and a failed one are different routing outcomes,
1560
- * and collapsing them would make the relay guess.
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}.
1561
2514
  */
1562
- declare const ResultDisposition: z.ZodEnum<{
1563
- ok: "ok";
1564
- error: "error";
1565
- canceled: "canceled";
1566
- }>;
1567
- type ResultDisposition = z.infer<typeof ResultDisposition>;
1568
- declare const ResultRequest: z.ZodObject<{
1569
- protocolVersion: z.ZodLiteral<"0">;
1570
- runnerId: z.ZodString;
1571
- jobId: z.ZodString;
1572
- envelope: z.ZodObject<{
1573
- ciphertext: z.ZodString;
1574
- recipientKeyId: z.ZodString;
1575
- senderKeyId: z.ZodString;
1576
- direction: z.ZodEnum<{
1577
- payload: "payload";
1578
- result: "result";
1579
- }>;
1580
- deadlineAt: z.ZodNumber;
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;
1581
2581
  }, z.core.$strict>;
1582
- disposition: z.ZodEnum<{
1583
- ok: "ok";
1584
- error: "error";
1585
- canceled: "canceled";
1586
- }>;
1587
- model: z.ZodString;
1588
- backendClass: z.ZodEnum<{
1589
- http: "http";
1590
- process: "process";
1591
- }>;
1592
- durationMs: z.ZodNumber;
1593
- }, z.core.$strict>;
1594
- type ResultRequest = z.infer<typeof ResultRequest>;
1595
- declare const ResultResponse: z.ZodObject<{
1596
- accepted: z.ZodBoolean;
1597
- state: z.ZodString;
1598
- }, z.core.$strict>;
1599
- type ResultResponse = z.infer<typeof ResultResponse>;
1600
- declare const ReleaseRequest: z.ZodObject<{
1601
- protocolVersion: z.ZodLiteral<"0">;
1602
- runnerId: z.ZodString;
1603
- leases: z.ZodArray<z.ZodObject<{
1604
- jobId: z.ZodString;
1605
- leaseId: z.ZodString;
1606
- }, z.core.$strip>>;
1607
- reason: z.ZodEnum<{
1608
- revoked: "revoked";
1609
- shutdown: "shutdown";
1610
- pause: "pause";
1611
- "backend-down": "backend-down";
1612
- refused: "refused";
1613
- }>;
1614
- }, z.core.$strict>;
1615
- type ReleaseRequest = z.infer<typeof ReleaseRequest>;
1616
- declare const ReleaseResponse: z.ZodObject<{
1617
- released: z.ZodArray<z.ZodString>;
2582
+ signature: z.ZodString;
1618
2583
  }, z.core.$strict>;
1619
- type ReleaseResponse = z.infer<typeof ReleaseResponse>;
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;
1620
2587
  /**
1621
- * Wire error codes.
2588
+ * Sign a succession from the keys being retired to the identity taking over.
1622
2589
  *
1623
- * byollm_002 requires that "server unreachable", "revoked", "no matching
1624
- * work" and "backend down" never share a message. Distinct codes here are how
1625
- * the daemon can tell three of those apart; the fourth is a transport failure
1626
- * with no response at all.
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.
1627
2593
  */
1628
- declare const WireErrorCode: z.ZodEnum<{
1629
- "unsupported-protocol-version": "unsupported-protocol-version";
1630
- revoked: "revoked";
1631
- "bad-request": "bad-request";
1632
- unauthorized: "unauthorized";
1633
- "not-found": "not-found";
1634
- "rate-limited": "rate-limited";
1635
- "server-error": "server-error";
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;
1636
2801
  }>;
1637
- type WireErrorCode = z.infer<typeof WireErrorCode>;
1638
- declare const WireError: z.ZodObject<{
1639
- error: z.ZodEnum<{
1640
- "unsupported-protocol-version": "unsupported-protocol-version";
1641
- revoked: "revoked";
1642
- "bad-request": "bad-request";
1643
- unauthorized: "unauthorized";
1644
- "not-found": "not-found";
1645
- "rate-limited": "rate-limited";
1646
- "server-error": "server-error";
1647
- }>;
1648
- message: z.ZodString;
1649
- retryAfter: z.ZodOptional<z.ZodNumber>;
1650
- }, z.core.$strict>;
1651
- type WireError = z.infer<typeof WireError>;
1652
- /** HTTP status each error code is served with. */
1653
- declare const ERROR_STATUS: Readonly<Record<WireErrorCode, number>>;
1654
- declare const FetchRequest: z.ZodObject<{
1655
- protocolVersion: z.ZodString;
1656
- runnerId: z.ZodString;
1657
- jobId: z.ZodString;
1658
- leaseId: z.ZodString;
1659
- }, z.core.$strict>;
1660
- type FetchRequest = z.infer<typeof FetchRequest>;
1661
- declare const FetchResponse: z.ZodObject<{
1662
- envelope: z.ZodObject<{
1663
- ciphertext: z.ZodString;
1664
- recipientKeyId: z.ZodString;
1665
- senderKeyId: z.ZodString;
1666
- direction: z.ZodEnum<{
1667
- payload: "payload";
1668
- result: "result";
1669
- }>;
1670
- deadlineAt: z.ZodNumber;
1671
- }, z.core.$strict>;
1672
- }, z.core.$strict>;
1673
- type FetchResponse = z.infer<typeof FetchResponse>;
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[];
1674
2808
 
1675
- export { AUDIENCES, Audience, BACKENDS, BACKEND_IDS, BackendClass, BackendCost, type BackendDescriptor, type BackendId, BackendIdSchema, Capability, CapabilityMatrix, ChatMessage, ChatPayload, ClaimRequest, ClaimResponse, ClaimedJob, ClaimedStub, DeliveredResult, ENDPOINTS, ENVELOPE_MAX_AGE_MS, ERROR_STATUS, type Endpoint, type EnvelopeContext, EnvelopeDirection, type EnvelopeFailure, FetchRequest, FetchResponse, GeneratePayload, HeartbeatRequest, HeartbeatResponse, JOB_KINDS, JobKind, JobOutcome, JobPayload, JobResultCanceled, JobResultError, JobResultOk, JobState, JobStub, KindedPayload, Lease, MAX_CLOCK_SKEW_MS, MIN_PROTOCOL_VERSION, MUSTS, MUST_IDS, type MatchDaemon, type MatchJob, MatchRefusal, type MatchResult, type Must, type MustEnforcer, type MustId, type MustVerification, OFFER_SCOPES, OfferScope, type OpenResult, PAYLOAD_LIMITS, PROTOCOL_PREFIX, PROTOCOL_VERSION, PairPollRequest, PairPollResponse, PairRequest, PairStartRequest, PairStartResponse, type PayloadFor, PublicIdentity, REFUSAL_MESSAGES, ReleaseRequest, ReleaseResponse, RequestSignature, ResultDisposition, ResultProvenance, ResultRequest, ResultResponse, SIZE_CLASS_LIMITS, SUPPORTED_PROTOCOL_VERSIONS, SealedEnvelope, type SignatureFailure, SizeClass, type SpendConsent, StoredKeys, TERMINAL_STATES, type VersionRefusal, WireError, WireErrorCode, backendDescriptor, canTransition, canonicalRequest, checkProtocolVersion, cryptoReady, effectiveOfferScope, fingerprint, generateKeys, isBackendId, isJobKind, isLocalHost, isTerminal, keyId, matchAudience, mustsVerifiedBy, open, payloadTextLength, provenanceFor, publicIdentityOf, resolveCost, seal, signRequest, signSiteRequest, signWith, sizeClassCeiling, sizeClassOf, verifyPublicIdentity, verifyRequest, verifySiteRequest, verifyWith };
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 };