@byok-sdk/protocol 0.17.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,939 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Remote authenticated runtime input preparation — the wire half of
4
+ * `docs/researches/runtime-input-preparation-contract.md` §19 (channel shape)
5
+ * and the C07 G4 design decision §17 B.
6
+ *
7
+ * This module owns ONLY the leaf shapes. The server -> device payload lives in
8
+ * `messages.ts` beside every other message payload (so the one inline byte
9
+ * bound `MAX_INLINE_BYTES` stays a single module-local authority), and the two
10
+ * authenticated HTTP bodies live in `http-api.ts`.
11
+ *
12
+ * Three structural rules this surface exists to hold:
13
+ *
14
+ * 1. The request carries NO tools, NO tool executors and NO runtime identity.
15
+ * Those are LOCAL observations: only the device can honestly say which MCP
16
+ * toolsets it has, what schemas their servers publish, and which native
17
+ * package closure is installed. A Host that could state them would be
18
+ * stating an identity it cannot verify.
19
+ * 2. The receipt summary discloses identities, digests, sizes, counter
20
+ * evidence and readiness — never D, never P(D), never the snapshot. A
21
+ * digest proves content identity; it is not a disclosure channel and not a
22
+ * bearer token (§10.3.4).
23
+ * 3. Every shape here is `.strict()`. This is control data: an unrecognized
24
+ * field must be REJECTED, not silently stripped, per docs/protocol.md's
25
+ * freeze-rule asymmetry. Adding a field post-freeze is therefore a
26
+ * breaking change, exactly like `PermissionPolicySchema`.
27
+ */
28
+ /** Capability required before a task-free remote input preparation is admitted. */
29
+ export declare const AGENT_INPUT_PREPARATION_CAPABILITY: 'agent-input-preparation';
30
+ /** The preparation surface uses the package-wide lowercase `sha256:<hex>` transport form. */
31
+ export declare const InputPreparationContentHashSchema: z.ZodString;
32
+ /**
33
+ * The operator-assigned limits-policy revision a device must already hold. The
34
+ * SDK compares it for exact equality and never negotiates it: a device whose
35
+ * configured revision differs rejects rather than preparing under a policy the
36
+ * caller believed was in force.
37
+ */
38
+ export declare const InputPreparationPolicyRevisionSchema: z.ZodString;
39
+ /**
40
+ * Host-owned Profile identity. It rides beside `agentRef` rather than inside
41
+ * it because `AgentRefSchema` is the frozen generic Agent identity shared by
42
+ * every other message, and widening that would be a breaking change to all of
43
+ * them. The device never trusts this value directly — its configured local
44
+ * authority resolver validates it against trusted local Profile records before
45
+ * anything is compiled.
46
+ */
47
+ export declare const InputPreparationProfileIdSchema: z.ZodString;
48
+ /**
49
+ * The permission mode a preparation is compiled FOR.
50
+ *
51
+ * It is the same closed set every task policy uses (`permission.ts`'s
52
+ * `PERMISSION_MODES`), spelled here as its own schema because a preparation
53
+ * carries a mode without carrying a policy: there is no task, no grant and no
54
+ * approval seam on this wire. The mode selects which tools the device's own
55
+ * observation projects into the counted manifest, and nothing else.
56
+ *
57
+ * Declared by the requester rather than inferred by the device: a device that
58
+ * guessed would be counting a manifest the requester never asked for, and a
59
+ * device that defaulted would silently count the widest one.
60
+ */
61
+ export declare const InputPreparationPermissionModeSchema: z.ZodEnum<{
62
+ auto: "auto";
63
+ confirm: "confirm";
64
+ plan: "plan";
65
+ readonly: "readonly";
66
+ }>;
67
+ export type InputPreparationPermissionMode = z.infer<typeof InputPreparationPermissionModeSchema>;
68
+ /**
69
+ * The canonical Host source snapshot this input was assembled from. Both
70
+ * values are Host authority carried verbatim so the receipt binds the exact
71
+ * revision/digest a later consumer must re-present. The SDK interprets
72
+ * neither.
73
+ */
74
+ export declare const InputPreparationSourceSchema: z.ZodObject<{
75
+ revision: z.ZodString;
76
+ digest: z.ZodString;
77
+ }, z.core.$strict>;
78
+ export type InputPreparationSource = z.infer<typeof InputPreparationSourceSchema>;
79
+ export declare const InputPreparationModelCostSchema: z.ZodObject<{
80
+ input: z.ZodNumber;
81
+ output: z.ZodNumber;
82
+ cacheRead: z.ZodNumber;
83
+ cacheWrite: z.ZodNumber;
84
+ }, z.core.$strict>;
85
+ /**
86
+ * The exact model identity the request compiles for.
87
+ *
88
+ * `api` is a single literal, not an open enum: `openai-completions` is the one
89
+ * API the frozen B-P1 native validator admits, and widening it is a
90
+ * registration, not a parser relaxation.
91
+ *
92
+ * `thinkingLevelMap` and `compat` are the two body-affecting declarations a
93
+ * locally configured provider profile projects into the model entry the runtime
94
+ * is launched with. They are OPTIONAL because a model configuration may declare
95
+ * neither, and absent stays absent on every carrier: nothing here defaults,
96
+ * coerces or infers one, since a preparation whose model gained a field on the
97
+ * way through would no longer equal the session model it was counted for.
98
+ */
99
+ export declare const InputPreparationModelSchema: z.ZodObject<{
100
+ id: z.ZodString;
101
+ name: z.ZodString;
102
+ api: z.ZodLiteral<"openai-completions">;
103
+ provider: z.ZodString;
104
+ baseUrl: z.ZodString;
105
+ reasoning: z.ZodBoolean;
106
+ input: z.ZodArray<z.ZodEnum<{
107
+ image: "image";
108
+ text: "text";
109
+ }>>;
110
+ cost: z.ZodObject<{
111
+ input: z.ZodNumber;
112
+ output: z.ZodNumber;
113
+ cacheRead: z.ZodNumber;
114
+ cacheWrite: z.ZodNumber;
115
+ }, z.core.$strict>;
116
+ contextWindow: z.ZodNumber;
117
+ maxTokens: z.ZodNumber;
118
+ thinkingLevelMap: z.ZodOptional<z.ZodObject<{
119
+ off: z.ZodNullable<z.ZodString>;
120
+ minimal: z.ZodNullable<z.ZodString>;
121
+ low: z.ZodNullable<z.ZodString>;
122
+ medium: z.ZodNullable<z.ZodString>;
123
+ high: z.ZodNullable<z.ZodString>;
124
+ xhigh: z.ZodNullable<z.ZodString>;
125
+ max: z.ZodNullable<z.ZodString>;
126
+ }, z.core.$strict>>;
127
+ compat: z.ZodOptional<z.ZodObject<{
128
+ supportsStore: z.ZodOptional<z.ZodBoolean>;
129
+ supportsDeveloperRole: z.ZodOptional<z.ZodBoolean>;
130
+ supportsReasoningEffort: z.ZodOptional<z.ZodBoolean>;
131
+ supportsUsageInStreaming: z.ZodOptional<z.ZodBoolean>;
132
+ maxTokensField: z.ZodOptional<z.ZodEnum<{
133
+ max_completion_tokens: "max_completion_tokens";
134
+ max_tokens: "max_tokens";
135
+ }>>;
136
+ thinkingFormat: z.ZodOptional<z.ZodEnum<{
137
+ "ant-ling": "ant-ling";
138
+ baseten: "baseten";
139
+ "chat-template": "chat-template";
140
+ deepseek: "deepseek";
141
+ openai: "openai";
142
+ openrouter: "openrouter";
143
+ qwen: "qwen";
144
+ "qwen-chat-template": "qwen-chat-template";
145
+ "string-thinking": "string-thinking";
146
+ together: "together";
147
+ zai: "zai";
148
+ }>>;
149
+ zaiToolStream: z.ZodOptional<z.ZodBoolean>;
150
+ }, z.core.$strict>>;
151
+ }, z.core.$strict>;
152
+ export type InputPreparationModel = z.infer<typeof InputPreparationModelSchema>;
153
+ /**
154
+ * Body-affecting options only. Transport options are deliberately not on this wire.
155
+ *
156
+ * `toolChoice` admits `auto` and `none` and nothing else: the native prepared
157
+ * boundary compiles through the simple stream path, which cannot express
158
+ * `required`, so a Host stating it would be stating an option no compiler on
159
+ * the other side can produce. It is refused HERE, by the schema, rather than
160
+ * surviving to a native refusal nobody can read.
161
+ *
162
+ * `reasoningEffort` names a requested thinking level. The native compiler maps
163
+ * it through the launched model's own level map and clamps it exactly as the
164
+ * live session does, so the effort token that reaches the body is the model's,
165
+ * never this value verbatim.
166
+ */
167
+ export declare const InputPreparationOptionsSchema: z.ZodObject<{
168
+ cacheRetention: z.ZodEnum<{
169
+ long: "long";
170
+ none: "none";
171
+ short: "short";
172
+ }>;
173
+ maxTokens: z.ZodNumber;
174
+ temperature: z.ZodOptional<z.ZodNumber>;
175
+ toolChoice: z.ZodOptional<z.ZodEnum<{
176
+ auto: "auto";
177
+ none: "none";
178
+ }>>;
179
+ reasoningEffort: z.ZodOptional<z.ZodEnum<{
180
+ high: "high";
181
+ low: "low";
182
+ max: "max";
183
+ medium: "medium";
184
+ minimal: "minimal";
185
+ xhigh: "xhigh";
186
+ }>>;
187
+ }, z.core.$strict>;
188
+ export type InputPreparationOptions = z.infer<typeof InputPreparationOptionsSchema>;
189
+ export declare const InputPreparationSelectionSchema: z.ZodObject<{
190
+ model: z.ZodObject<{
191
+ id: z.ZodString;
192
+ name: z.ZodString;
193
+ api: z.ZodLiteral<"openai-completions">;
194
+ provider: z.ZodString;
195
+ baseUrl: z.ZodString;
196
+ reasoning: z.ZodBoolean;
197
+ input: z.ZodArray<z.ZodEnum<{
198
+ image: "image";
199
+ text: "text";
200
+ }>>;
201
+ cost: z.ZodObject<{
202
+ input: z.ZodNumber;
203
+ output: z.ZodNumber;
204
+ cacheRead: z.ZodNumber;
205
+ cacheWrite: z.ZodNumber;
206
+ }, z.core.$strict>;
207
+ contextWindow: z.ZodNumber;
208
+ maxTokens: z.ZodNumber;
209
+ thinkingLevelMap: z.ZodOptional<z.ZodObject<{
210
+ off: z.ZodNullable<z.ZodString>;
211
+ minimal: z.ZodNullable<z.ZodString>;
212
+ low: z.ZodNullable<z.ZodString>;
213
+ medium: z.ZodNullable<z.ZodString>;
214
+ high: z.ZodNullable<z.ZodString>;
215
+ xhigh: z.ZodNullable<z.ZodString>;
216
+ max: z.ZodNullable<z.ZodString>;
217
+ }, z.core.$strict>>;
218
+ compat: z.ZodOptional<z.ZodObject<{
219
+ supportsStore: z.ZodOptional<z.ZodBoolean>;
220
+ supportsDeveloperRole: z.ZodOptional<z.ZodBoolean>;
221
+ supportsReasoningEffort: z.ZodOptional<z.ZodBoolean>;
222
+ supportsUsageInStreaming: z.ZodOptional<z.ZodBoolean>;
223
+ maxTokensField: z.ZodOptional<z.ZodEnum<{
224
+ max_completion_tokens: "max_completion_tokens";
225
+ max_tokens: "max_tokens";
226
+ }>>;
227
+ thinkingFormat: z.ZodOptional<z.ZodEnum<{
228
+ "ant-ling": "ant-ling";
229
+ baseten: "baseten";
230
+ "chat-template": "chat-template";
231
+ deepseek: "deepseek";
232
+ openai: "openai";
233
+ openrouter: "openrouter";
234
+ qwen: "qwen";
235
+ "qwen-chat-template": "qwen-chat-template";
236
+ "string-thinking": "string-thinking";
237
+ together: "together";
238
+ zai: "zai";
239
+ }>>;
240
+ zaiToolStream: z.ZodOptional<z.ZodBoolean>;
241
+ }, z.core.$strict>>;
242
+ }, z.core.$strict>;
243
+ options: z.ZodObject<{
244
+ cacheRetention: z.ZodEnum<{
245
+ long: "long";
246
+ none: "none";
247
+ short: "short";
248
+ }>;
249
+ maxTokens: z.ZodNumber;
250
+ temperature: z.ZodOptional<z.ZodNumber>;
251
+ toolChoice: z.ZodOptional<z.ZodEnum<{
252
+ auto: "auto";
253
+ none: "none";
254
+ }>>;
255
+ reasoningEffort: z.ZodOptional<z.ZodEnum<{
256
+ high: "high";
257
+ low: "low";
258
+ max: "max";
259
+ medium: "medium";
260
+ minimal: "minimal";
261
+ xhigh: "xhigh";
262
+ }>>;
263
+ }, z.core.$strict>;
264
+ }, z.core.$strict>;
265
+ export type InputPreparationSelection = z.infer<typeof InputPreparationSelectionSchema>;
266
+ export declare const InputPreparationContextFileSchema: z.ZodObject<{
267
+ path: z.ZodString;
268
+ content: z.ZodString;
269
+ }, z.core.$strict>;
270
+ /**
271
+ * The three documentation locations the native prompt renderer names.
272
+ *
273
+ * The wire field names are this SDK's own and do not track upstream Pi's
274
+ * (`readme`/`docs`/`examples`): the contract a Host integrates against is this
275
+ * one, and renaming a frozen wire field because a runtime renamed a parameter
276
+ * would be a breaking change to every Host for no gain. The device adapter maps
277
+ * these onto whatever the pinned runtime calls them.
278
+ */
279
+ export declare const InputPreparationDocsPathsSchema: z.ZodObject<{
280
+ readmePath: z.ZodString;
281
+ docsPath: z.ZodString;
282
+ examplesPath: z.ZodString;
283
+ }, z.core.$strict>;
284
+ /**
285
+ * One skill the system prompt renders, stated as the closed set of fields the
286
+ * renderer actually reads.
287
+ *
288
+ * Not a preformatted string: the native renderer owns the skill block's
289
+ * markup, and a Host-rendered one would be a second renderer that could drift
290
+ * from what a live session emits. Loader bookkeeping the prompt never reads
291
+ * (`baseDir`, source info) is deliberately absent — the Host cannot know it and
292
+ * the device must never invent it.
293
+ */
294
+ export declare const InputPreparationSkillSchema: z.ZodObject<{
295
+ name: z.ZodString;
296
+ description: z.ZodString;
297
+ filePath: z.ZodString;
298
+ disableModelInvocation: z.ZodBoolean;
299
+ }, z.core.$strict>;
300
+ export type InputPreparationSkill = z.infer<typeof InputPreparationSkillSchema>;
301
+ /**
302
+ * Explicit, already-authorized inputs for the native system prompt renderer.
303
+ *
304
+ * `toolSnippets` is PROMPT TEXT the Host authored — it is not the
305
+ * model-visible tool schemas, which the device observes locally and the Host
306
+ * never states (see this module's rule 1). `toolGuidelines` is the same kind of
307
+ * value one level down: the guideline bullets a tool contributes, keyed by tool
308
+ * name and bounded exactly like `toolSnippets` and `promptGuidelines`.
309
+ *
310
+ * `selectedTools` is deliberately absent for the same reason one level up: the
311
+ * native contract requires that list to equal the model-visible manifest
312
+ * exactly, so a Host stating it would be stating the manifest. The device
313
+ * fills it from its own assembled tool surface.
314
+ */
315
+ export declare const InputPreparationPromptSnapshotSchema: z.ZodObject<{
316
+ customPrompt: z.ZodOptional<z.ZodString>;
317
+ appendSystemPrompt: z.ZodOptional<z.ZodString>;
318
+ cwd: z.ZodString;
319
+ toolSnippets: z.ZodRecord<z.ZodString, z.ZodString>;
320
+ toolGuidelines: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
321
+ promptGuidelines: z.ZodArray<z.ZodString>;
322
+ contextFiles: z.ZodArray<z.ZodObject<{
323
+ path: z.ZodString;
324
+ content: z.ZodString;
325
+ }, z.core.$strict>>;
326
+ skills: z.ZodArray<z.ZodObject<{
327
+ name: z.ZodString;
328
+ description: z.ZodString;
329
+ filePath: z.ZodString;
330
+ disableModelInvocation: z.ZodBoolean;
331
+ }, z.core.$strict>>;
332
+ docsPaths: z.ZodObject<{
333
+ readmePath: z.ZodString;
334
+ docsPath: z.ZodString;
335
+ examplesPath: z.ZodString;
336
+ }, z.core.$strict>;
337
+ }, z.core.$strict>;
338
+ /**
339
+ * One model-visible user message. Text-only: multimodal content and any extra
340
+ * field are not inferred, they reject.
341
+ */
342
+ export declare const InputPreparationUserMessageSchema: z.ZodObject<{
343
+ role: z.ZodLiteral<"user">;
344
+ content: z.ZodString;
345
+ timestamp: z.ZodNumber;
346
+ }, z.core.$strict>;
347
+ /**
348
+ * One host-canonical assistant text message.
349
+ *
350
+ * A different fact from a provider-generated assistant turn: the host asserts
351
+ * this text was already said, and nothing generated it here. It carries no
352
+ * `api`, `provider`, `model`, `usage` or `stopReason`, and `.strict()` is what
353
+ * keeps one from being fabricated on the way in — an assistant message with
354
+ * provenance fields, or without the `origin` discriminant, is a claim this
355
+ * surface cannot check, so it rejects rather than being narrowed to one it can.
356
+ */
357
+ export declare const InputPreparationHostCanonicalAssistantMessageSchema: z.ZodObject<{
358
+ role: z.ZodLiteral<"assistant">;
359
+ origin: z.ZodLiteral<"host_canonical">;
360
+ content: z.ZodString;
361
+ timestamp: z.ZodNumber;
362
+ }, z.core.$strict>;
363
+ /**
364
+ * The whole support set a caller may state: text-only user history,
365
+ * host-canonical assistant text history, and the current user message.
366
+ *
367
+ * A discriminated union on `role`, so an unsupported kind is refused by name
368
+ * rather than by a shape error on whichever member happened to be tried first.
369
+ * Provider-generated assistant turns, tool-result history and multimodal
370
+ * content are not members and are not inferred; adding one is a registration
371
+ * here AND in the device's hand-written parse, never a relaxation of either.
372
+ */
373
+ export declare const InputPreparationMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
374
+ role: z.ZodLiteral<"user">;
375
+ content: z.ZodString;
376
+ timestamp: z.ZodNumber;
377
+ }, z.core.$strict>, z.ZodObject<{
378
+ role: z.ZodLiteral<"assistant">;
379
+ origin: z.ZodLiteral<"host_canonical">;
380
+ content: z.ZodString;
381
+ timestamp: z.ZodNumber;
382
+ }, z.core.$strict>], "role">;
383
+ export type InputPreparationMessage = z.infer<typeof InputPreparationMessageSchema>;
384
+ /**
385
+ * What `context.inline` (or the referenced blob) decodes to.
386
+ *
387
+ * Deliberately NOT the whole compiled snapshot: `tools` is absent because the
388
+ * device adds it from its own MCP observation. A Host that could send `tools`
389
+ * could claim a toolset the device does not have.
390
+ */
391
+ export declare const InputPreparationContextDocumentSchema: z.ZodObject<{
392
+ prompt: z.ZodObject<{
393
+ customPrompt: z.ZodOptional<z.ZodString>;
394
+ appendSystemPrompt: z.ZodOptional<z.ZodString>;
395
+ cwd: z.ZodString;
396
+ toolSnippets: z.ZodRecord<z.ZodString, z.ZodString>;
397
+ toolGuidelines: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
398
+ promptGuidelines: z.ZodArray<z.ZodString>;
399
+ contextFiles: z.ZodArray<z.ZodObject<{
400
+ path: z.ZodString;
401
+ content: z.ZodString;
402
+ }, z.core.$strict>>;
403
+ skills: z.ZodArray<z.ZodObject<{
404
+ name: z.ZodString;
405
+ description: z.ZodString;
406
+ filePath: z.ZodString;
407
+ disableModelInvocation: z.ZodBoolean;
408
+ }, z.core.$strict>>;
409
+ docsPaths: z.ZodObject<{
410
+ readmePath: z.ZodString;
411
+ docsPath: z.ZodString;
412
+ examplesPath: z.ZodString;
413
+ }, z.core.$strict>;
414
+ }, z.core.$strict>;
415
+ messages: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
416
+ role: z.ZodLiteral<"user">;
417
+ content: z.ZodString;
418
+ timestamp: z.ZodNumber;
419
+ }, z.core.$strict>, z.ZodObject<{
420
+ role: z.ZodLiteral<"assistant">;
421
+ origin: z.ZodLiteral<"host_canonical">;
422
+ content: z.ZodString;
423
+ timestamp: z.ZodNumber;
424
+ }, z.core.$strict>], "role">>;
425
+ }, z.core.$strict>;
426
+ export type InputPreparationContextDocument = z.infer<typeof InputPreparationContextDocumentSchema>;
427
+ /** Durable lifecycle state of one local preparation record. */
428
+ export declare const InputPreparationStateSchema: z.ZodEnum<{
429
+ cancelled: "cancelled";
430
+ counted: "counted";
431
+ counter_interrupted: "counter_interrupted";
432
+ counting: "counting";
433
+ failed: "failed";
434
+ reserved: "reserved";
435
+ }>;
436
+ export type InputPreparationState = z.infer<typeof InputPreparationStateSchema>;
437
+ /**
438
+ * Why a receipt is not ready. An empty list is the only thing that makes
439
+ * `ready` true.
440
+ *
441
+ * `ready` means the preparation CAN BE CONSUMED — the artifact is intact and
442
+ * unexpired, the native compiler's projection is content-complete, every
443
+ * residual key is ruled by an applicable Host accounting policy, the count is
444
+ * present and bound to that exact projection, and every executor identity is
445
+ * attested. It is deliberately NOT Host budget admission: the device performs
446
+ * no budget arithmetic, so a ready receipt says the evidence holds, never that
447
+ * the spend is allowed.
448
+ */
449
+ export declare const InputPreparationReadinessReasonSchema: z.ZodEnum<{
450
+ accounting_policy_inapplicable: "accounting_policy_inapplicable";
451
+ accounting_policy_missing: "accounting_policy_missing";
452
+ artifact_expired: "artifact_expired";
453
+ cancelled: "cancelled";
454
+ counter_authority_not_production: "counter_authority_not_production";
455
+ counter_coverage_incomplete: "counter_coverage_incomplete";
456
+ counter_interrupted: "counter_interrupted";
457
+ counter_missing: "counter_missing";
458
+ executor_identity_unproven: "executor_identity_unproven";
459
+ failed: "failed";
460
+ not_counted: "not_counted";
461
+ projection_unknown: "projection_unknown";
462
+ residual_not_ruled: "residual_not_ruled";
463
+ runtime_contract_superseded: "runtime_contract_superseded";
464
+ }>;
465
+ export type InputPreparationReadinessReason = z.infer<typeof InputPreparationReadinessReasonSchema>;
466
+ /**
467
+ * Runtime/compiler identity derived from the VERIFIED installed package
468
+ * closure on the device. A Host never states it and cannot override it.
469
+ */
470
+ export declare const InputPreparationRuntimeIdentitySchema: z.ZodObject<{
471
+ packageName: z.ZodString;
472
+ packageVersion: z.ZodString;
473
+ upstreamBase: z.ZodString;
474
+ upstreamCommit: z.ZodString;
475
+ forkBuild: z.ZodNumber;
476
+ envelopeFormat: z.ZodString;
477
+ requestFormat: z.ZodString;
478
+ compilerVersion: z.ZodNumber;
479
+ }, z.core.$strict>;
480
+ export type InputPreparationRuntimeIdentity = z.infer<typeof InputPreparationRuntimeIdentitySchema>;
481
+ export declare const InputPreparationCounterTargetSchema: z.ZodObject<{
482
+ endpoint: z.ZodString;
483
+ modelId: z.ZodString;
484
+ }, z.core.$strict>;
485
+ /**
486
+ * The Host's ruling about which residual keys of D its accounting already
487
+ * accounts for.
488
+ *
489
+ * Host authority, carried verbatim. The device performs exactly one check
490
+ * against it — APPLICABILITY — and never any budget arithmetic: every residual
491
+ * key the artifact carries must be named here, and the ruling must have been
492
+ * made for this preparation's own runtime identity and endpoint/model. There
493
+ * is no default: a request that names none produces a receipt carrying
494
+ * `accounting_policy_missing`, because "nobody ruled" and "everything is
495
+ * ruled" are different facts.
496
+ */
497
+ export declare const InputPreparationAccountingPolicyRefSchema: z.ZodObject<{
498
+ revision: z.ZodString;
499
+ ruledRuntime: z.ZodString;
500
+ ruledTarget: z.ZodObject<{
501
+ endpoint: z.ZodString;
502
+ modelId: z.ZodString;
503
+ }, z.core.$strict>;
504
+ ruledResidualKeys: z.ZodArray<z.ZodString>;
505
+ }, z.core.$strict>;
506
+ export type InputPreparationAccountingPolicyRef = z.infer<typeof InputPreparationAccountingPolicyRefSchema>;
507
+ /**
508
+ * What the provider side of a count asserted, and which exact projection it
509
+ * was asserted about.
510
+ *
511
+ * Required, fixture included: a number without the identity of the bytes it
512
+ * was taken over is not evidence. The device compares `projectionDigest`
513
+ * against the artifact's own projection digest and `endpoint`/`modelId`
514
+ * against the counted target, and refuses the count outright on a mismatch.
515
+ *
516
+ * `asserted` is the provider's own answer, stored and never second-guessed —
517
+ * re-deriving a usage number locally is the shadow accounting this surface
518
+ * exists to avoid. It carries no output or whole-request field: the Host holds
519
+ * its own request, and `binding.requestDigest` is the check that ties the two.
520
+ */
521
+ export declare const InputPreparationCounterProviderEvidenceSchema: z.ZodObject<{
522
+ projectionDigest: z.ZodString;
523
+ endpoint: z.ZodString;
524
+ modelId: z.ZodString;
525
+ asserted: z.ZodObject<{
526
+ httpStatus: z.ZodNumber;
527
+ usageFields: z.ZodRecord<z.ZodString, z.ZodNumber>;
528
+ responseDigest: z.ZodString;
529
+ }, z.core.$strict>;
530
+ }, z.core.$strict>;
531
+ /**
532
+ * Counter evidence exactly as the device's adapter reported it.
533
+ *
534
+ * `authority: 'test_fixture'` is a first-class value, not a debug flag: a
535
+ * fixture result can never produce a ready receipt, which is what keeps an
536
+ * offline suite from ever looking like production accounting evidence.
537
+ */
538
+ export declare const InputPreparationCounterEvidenceSchema: z.ZodObject<{
539
+ method: z.ZodString;
540
+ methodVersion: z.ZodString;
541
+ authority: z.ZodEnum<{
542
+ provider: "provider";
543
+ test_fixture: "test_fixture";
544
+ }>;
545
+ kind: z.ZodEnum<{
546
+ bound: "bound";
547
+ count: "count";
548
+ }>;
549
+ value: z.ZodNumber;
550
+ coverage: z.ZodObject<{
551
+ covered: z.ZodBoolean;
552
+ reason: z.ZodOptional<z.ZodString>;
553
+ }, z.core.$strict>;
554
+ providerEvidence: z.ZodObject<{
555
+ projectionDigest: z.ZodString;
556
+ endpoint: z.ZodString;
557
+ modelId: z.ZodString;
558
+ asserted: z.ZodObject<{
559
+ httpStatus: z.ZodNumber;
560
+ usageFields: z.ZodRecord<z.ZodString, z.ZodNumber>;
561
+ responseDigest: z.ZodString;
562
+ }, z.core.$strict>;
563
+ }, z.core.$strict>;
564
+ target: z.ZodObject<{
565
+ endpoint: z.ZodString;
566
+ modelId: z.ZodString;
567
+ }, z.core.$strict>;
568
+ calledAt: z.ZodISODateTime;
569
+ completedAt: z.ZodISODateTime;
570
+ }, z.core.$strict>;
571
+ /**
572
+ * What the device established about the implementation behind ONE
573
+ * model-visible tool: `attested`, or `unavailable:<reason>` naming which of
574
+ * the SDK's closed unavailable reasons applies.
575
+ *
576
+ * A kind, never the identity itself: an install path, a closure digest or a
577
+ * stat tuple is device-local filesystem detail, and a receipt discloses
578
+ * identity facts, not the machine's layout.
579
+ */
580
+ export declare const InputPreparationToolImplementationKindSchema: z.ZodString;
581
+ /**
582
+ * What the native compiler proved about ONE top-level key of D that lies
583
+ * outside P(D).
584
+ *
585
+ * These classes describe STRUCTURE and nothing else. No class states, implies
586
+ * or denies that a key influences a provider's token count — that is an
587
+ * external accounting fact the compiler cannot prove — which is exactly why
588
+ * the device re-derives nothing from them and routes the question to the
589
+ * Host's own {@link InputPreparationAccountingPolicyRefSchema}.
590
+ */
591
+ export declare const InputPreparationResidualValueClassSchema: z.ZodEnum<{
592
+ boolean: "boolean";
593
+ bounded_integer: "bounded_integer";
594
+ bounded_number: "bounded_number";
595
+ closed_enum: "closed_enum";
596
+ constant: "constant";
597
+ finite_number: "finite_number";
598
+ nonempty_string: "nonempty_string";
599
+ object_shape: "object_shape";
600
+ }>;
601
+ export type InputPreparationResidualValueClass = z.infer<typeof InputPreparationResidualValueClassSchema>;
602
+ export declare const InputPreparationResidualKeySchema: z.ZodObject<{
603
+ key: z.ZodString;
604
+ valueClass: z.ZodEnum<{
605
+ boolean: "boolean";
606
+ bounded_integer: "bounded_integer";
607
+ bounded_number: "bounded_number";
608
+ closed_enum: "closed_enum";
609
+ constant: "constant";
610
+ finite_number: "finite_number";
611
+ nonempty_string: "nonempty_string";
612
+ object_shape: "object_shape";
613
+ }>;
614
+ }, z.core.$strict>;
615
+ /**
616
+ * What the native compiler proves about P(D), copied verbatim off the envelope.
617
+ *
618
+ * `content_complete` — every context-derived byte of D is byte-identically
619
+ * inside P(D), and every remaining top-level key was classified. `unknown` —
620
+ * the compiler failed closed, claims nothing, and leaves `residual` empty.
621
+ *
622
+ * `digest` is sha-256 over the exact counted-projection bytes. The device
623
+ * recomputes it and refuses the artifact on a mismatch; it never recomputes
624
+ * the KIND, because the classification table belongs to the compiler and a
625
+ * local copy of it would be a shadow parser for the same semantic fact.
626
+ */
627
+ export declare const InputPreparationProjectionSchema: z.ZodObject<{
628
+ version: z.ZodLiteral<3>;
629
+ kind: z.ZodEnum<{
630
+ content_complete: "content_complete";
631
+ unknown: "unknown";
632
+ }>;
633
+ digest: z.ZodString;
634
+ }, z.core.$strict>;
635
+ /**
636
+ * Identities, sizes and the native compiler's structural projection contract.
637
+ * Never D, never P(D), never the snapshot.
638
+ *
639
+ * The three tool-surface fields are what make drift between preparation and
640
+ * launch checkable rather than assumed:
641
+ *
642
+ * - `observationDigest` binds everything the device OBSERVED — the projected
643
+ * tools, their executor fingerprints, the launch attestation and the
644
+ * implementation identities — so a launch whose live observation differs is
645
+ * a different manifest, whatever the schemas say.
646
+ * - `toolBindingDigest` binds only the facts that can be re-derived WITHOUT
647
+ * spawning a server: the launch attestation, the toolset definition
648
+ * revisions and the implementation identities. It is what a replay of an
649
+ * already-recorded requestId compares against, because re-probing to detect
650
+ * drift would be the second executor fact the idempotency key exists to
651
+ * prevent.
652
+ * - `toolImplementationKinds` states, per model-visible tool name, whether the
653
+ * implementation behind it was attested. It is the evidence behind
654
+ * `executor_identity_unproven`, so a reader does not have to take that
655
+ * readiness reason on trust.
656
+ */
657
+ export declare const InputPreparationArtifactSummarySchema: z.ZodObject<{
658
+ requestDigest: z.ZodString;
659
+ envelopeDigest: z.ZodString;
660
+ toolManifestDigest: z.ZodString;
661
+ requestBytes: z.ZodNumber;
662
+ projectionBytes: z.ZodNumber;
663
+ projection: z.ZodObject<{
664
+ version: z.ZodLiteral<3>;
665
+ kind: z.ZodEnum<{
666
+ content_complete: "content_complete";
667
+ unknown: "unknown";
668
+ }>;
669
+ digest: z.ZodString;
670
+ }, z.core.$strict>;
671
+ residual: z.ZodArray<z.ZodObject<{
672
+ key: z.ZodString;
673
+ valueClass: z.ZodEnum<{
674
+ boolean: "boolean";
675
+ bounded_integer: "bounded_integer";
676
+ bounded_number: "bounded_number";
677
+ closed_enum: "closed_enum";
678
+ constant: "constant";
679
+ finite_number: "finite_number";
680
+ nonempty_string: "nonempty_string";
681
+ object_shape: "object_shape";
682
+ }>;
683
+ }, z.core.$strict>>;
684
+ observationDigest: z.ZodString;
685
+ toolBindingDigest: z.ZodString;
686
+ toolImplementationKinds: z.ZodRecord<z.ZodString, z.ZodString>;
687
+ }, z.core.$strict>;
688
+ /** The immutable binding a receipt carries and a later consumer must re-present. */
689
+ export declare const InputPreparationBindingSchema: z.ZodObject<{
690
+ scopeId: z.ZodString;
691
+ deviceId: z.ZodString;
692
+ agentRef: z.ZodString;
693
+ profileId: z.ZodString;
694
+ profileRevision: z.ZodString;
695
+ source: z.ZodObject<{
696
+ revision: z.ZodString;
697
+ digest: z.ZodString;
698
+ }, z.core.$strict>;
699
+ target: z.ZodObject<{
700
+ endpoint: z.ZodString;
701
+ modelId: z.ZodString;
702
+ }, z.core.$strict>;
703
+ policyRevision: z.ZodString;
704
+ permissionMode: z.ZodEnum<{
705
+ auto: "auto";
706
+ confirm: "confirm";
707
+ plan: "plan";
708
+ readonly: "readonly";
709
+ }>;
710
+ runtime: z.ZodObject<{
711
+ packageName: z.ZodString;
712
+ packageVersion: z.ZodString;
713
+ upstreamBase: z.ZodString;
714
+ upstreamCommit: z.ZodString;
715
+ forkBuild: z.ZodNumber;
716
+ envelopeFormat: z.ZodString;
717
+ requestFormat: z.ZodString;
718
+ compilerVersion: z.ZodNumber;
719
+ }, z.core.$strict>;
720
+ requestDigest: z.ZodString;
721
+ accountingPolicyRef: z.ZodOptional<z.ZodObject<{
722
+ revision: z.ZodString;
723
+ ruledRuntime: z.ZodString;
724
+ ruledTarget: z.ZodObject<{
725
+ endpoint: z.ZodString;
726
+ modelId: z.ZodString;
727
+ }, z.core.$strict>;
728
+ ruledResidualKeys: z.ZodArray<z.ZodString>;
729
+ }, z.core.$strict>>;
730
+ }, z.core.$strict>;
731
+ /**
732
+ * The exact receipt projection a device reports back.
733
+ *
734
+ * `reference` names the record inside the device-local authenticated scope
735
+ * that created it. It is not a capability: local lookup re-resolves authority
736
+ * on every call and derives the record key from the trusted grant.
737
+ */
738
+ export declare const InputPreparationReceiptSummarySchema: z.ZodObject<{
739
+ reference: z.ZodString;
740
+ state: z.ZodEnum<{
741
+ cancelled: "cancelled";
742
+ counted: "counted";
743
+ counter_interrupted: "counter_interrupted";
744
+ counting: "counting";
745
+ failed: "failed";
746
+ reserved: "reserved";
747
+ }>;
748
+ binding: z.ZodObject<{
749
+ scopeId: z.ZodString;
750
+ deviceId: z.ZodString;
751
+ agentRef: z.ZodString;
752
+ profileId: z.ZodString;
753
+ profileRevision: z.ZodString;
754
+ source: z.ZodObject<{
755
+ revision: z.ZodString;
756
+ digest: z.ZodString;
757
+ }, z.core.$strict>;
758
+ target: z.ZodObject<{
759
+ endpoint: z.ZodString;
760
+ modelId: z.ZodString;
761
+ }, z.core.$strict>;
762
+ policyRevision: z.ZodString;
763
+ permissionMode: z.ZodEnum<{
764
+ auto: "auto";
765
+ confirm: "confirm";
766
+ plan: "plan";
767
+ readonly: "readonly";
768
+ }>;
769
+ runtime: z.ZodObject<{
770
+ packageName: z.ZodString;
771
+ packageVersion: z.ZodString;
772
+ upstreamBase: z.ZodString;
773
+ upstreamCommit: z.ZodString;
774
+ forkBuild: z.ZodNumber;
775
+ envelopeFormat: z.ZodString;
776
+ requestFormat: z.ZodString;
777
+ compilerVersion: z.ZodNumber;
778
+ }, z.core.$strict>;
779
+ requestDigest: z.ZodString;
780
+ accountingPolicyRef: z.ZodOptional<z.ZodObject<{
781
+ revision: z.ZodString;
782
+ ruledRuntime: z.ZodString;
783
+ ruledTarget: z.ZodObject<{
784
+ endpoint: z.ZodString;
785
+ modelId: z.ZodString;
786
+ }, z.core.$strict>;
787
+ ruledResidualKeys: z.ZodArray<z.ZodString>;
788
+ }, z.core.$strict>>;
789
+ }, z.core.$strict>;
790
+ artifact: z.ZodOptional<z.ZodObject<{
791
+ requestDigest: z.ZodString;
792
+ envelopeDigest: z.ZodString;
793
+ toolManifestDigest: z.ZodString;
794
+ requestBytes: z.ZodNumber;
795
+ projectionBytes: z.ZodNumber;
796
+ projection: z.ZodObject<{
797
+ version: z.ZodLiteral<3>;
798
+ kind: z.ZodEnum<{
799
+ content_complete: "content_complete";
800
+ unknown: "unknown";
801
+ }>;
802
+ digest: z.ZodString;
803
+ }, z.core.$strict>;
804
+ residual: z.ZodArray<z.ZodObject<{
805
+ key: z.ZodString;
806
+ valueClass: z.ZodEnum<{
807
+ boolean: "boolean";
808
+ bounded_integer: "bounded_integer";
809
+ bounded_number: "bounded_number";
810
+ closed_enum: "closed_enum";
811
+ constant: "constant";
812
+ finite_number: "finite_number";
813
+ nonempty_string: "nonempty_string";
814
+ object_shape: "object_shape";
815
+ }>;
816
+ }, z.core.$strict>>;
817
+ observationDigest: z.ZodString;
818
+ toolBindingDigest: z.ZodString;
819
+ toolImplementationKinds: z.ZodRecord<z.ZodString, z.ZodString>;
820
+ }, z.core.$strict>>;
821
+ counter: z.ZodOptional<z.ZodObject<{
822
+ method: z.ZodString;
823
+ methodVersion: z.ZodString;
824
+ authority: z.ZodEnum<{
825
+ provider: "provider";
826
+ test_fixture: "test_fixture";
827
+ }>;
828
+ kind: z.ZodEnum<{
829
+ bound: "bound";
830
+ count: "count";
831
+ }>;
832
+ value: z.ZodNumber;
833
+ coverage: z.ZodObject<{
834
+ covered: z.ZodBoolean;
835
+ reason: z.ZodOptional<z.ZodString>;
836
+ }, z.core.$strict>;
837
+ providerEvidence: z.ZodObject<{
838
+ projectionDigest: z.ZodString;
839
+ endpoint: z.ZodString;
840
+ modelId: z.ZodString;
841
+ asserted: z.ZodObject<{
842
+ httpStatus: z.ZodNumber;
843
+ usageFields: z.ZodRecord<z.ZodString, z.ZodNumber>;
844
+ responseDigest: z.ZodString;
845
+ }, z.core.$strict>;
846
+ }, z.core.$strict>;
847
+ target: z.ZodObject<{
848
+ endpoint: z.ZodString;
849
+ modelId: z.ZodString;
850
+ }, z.core.$strict>;
851
+ calledAt: z.ZodISODateTime;
852
+ completedAt: z.ZodISODateTime;
853
+ }, z.core.$strict>>;
854
+ ready: z.ZodBoolean;
855
+ readinessReasons: z.ZodArray<z.ZodEnum<{
856
+ accounting_policy_inapplicable: "accounting_policy_inapplicable";
857
+ accounting_policy_missing: "accounting_policy_missing";
858
+ artifact_expired: "artifact_expired";
859
+ cancelled: "cancelled";
860
+ counter_authority_not_production: "counter_authority_not_production";
861
+ counter_coverage_incomplete: "counter_coverage_incomplete";
862
+ counter_interrupted: "counter_interrupted";
863
+ counter_missing: "counter_missing";
864
+ executor_identity_unproven: "executor_identity_unproven";
865
+ failed: "failed";
866
+ not_counted: "not_counted";
867
+ projection_unknown: "projection_unknown";
868
+ residual_not_ruled: "residual_not_ruled";
869
+ runtime_contract_superseded: "runtime_contract_superseded";
870
+ }>>;
871
+ detail: z.ZodOptional<z.ZodString>;
872
+ artifactExpiresAt: z.ZodISODateTime;
873
+ }, z.core.$strict>;
874
+ export type InputPreparationReceiptSummary = z.infer<typeof InputPreparationReceiptSummarySchema>;
875
+ /**
876
+ * The device-local reference one receipt answered with
877
+ * ({@link InputPreparationReceiptSummarySchema}'s `reference`).
878
+ *
879
+ * The same opaque identifier, spelled as its own schema so the offer wire and
880
+ * the receipt wire cannot drift into two definitions of one value. It is NOT a
881
+ * capability: the device re-resolves authority on every lookup and derives the
882
+ * record key from its own trusted grant, so presenting another scope's
883
+ * reference finds nothing.
884
+ */
885
+ export declare const InputPreparationReferenceSchema: z.ZodString;
886
+ /**
887
+ * The preparation a `task.offer_prepared` names, re-presented by the Host from
888
+ * the receipt it was given.
889
+ *
890
+ * Nothing here is authority. Every value is COMPARED against the device's own
891
+ * durable record before an Execution is admitted, and a difference declines the
892
+ * offer non-retryably — a Host that could state a binding would be stating what
893
+ * this device counted.
894
+ *
895
+ * `artifactDigest` is optional for one structural reason, not as a compatibility
896
+ * seam: a receipt discloses `artifact` only once there is one
897
+ * ({@link InputPreparationArtifactSummarySchema} is optional on the receipt), so
898
+ * a Host holding a not-yet-counted receipt has no envelope digest to re-present.
899
+ * When it is present it is compared like everything else.
900
+ */
901
+ export declare const InputPreparationOfferBindingSchema: z.ZodObject<{
902
+ reference: z.ZodString;
903
+ requestDigest: z.ZodString;
904
+ artifactDigest: z.ZodOptional<z.ZodString>;
905
+ }, z.core.$strict>;
906
+ export type InputPreparationOfferBinding = z.infer<typeof InputPreparationOfferBindingSchema>;
907
+ /**
908
+ * Why a device refused to prepare at all. These are the device-owned typed
909
+ * rejections; none of them ever accompanies an artifact.
910
+ *
911
+ * `input_preparation_unconfigured` is the answer from a device that advertised
912
+ * nothing: the whole surface is off there. It is reported rather than thrown so
913
+ * one mis-targeted request cannot freeze the device's mailbox cursor behind it.
914
+ */
915
+ export declare const InputPreparationRejectionReasonSchema: z.ZodEnum<{
916
+ authority_unavailable: "authority_unavailable";
917
+ bad_request: "bad_request";
918
+ cancelled: "cancelled";
919
+ context_hash_mismatch: "context_hash_mismatch";
920
+ context_unresolvable: "context_unresolvable";
921
+ counter_interrupted: "counter_interrupted";
922
+ counter_unavailable: "counter_unavailable";
923
+ deadline_elapsed: "deadline_elapsed";
924
+ durable_write_failed: "durable_write_failed";
925
+ input_preparation_unconfigured: "input_preparation_unconfigured";
926
+ launch_boundary_unavailable: "launch_boundary_unavailable";
927
+ limit_exceeded: "limit_exceeded";
928
+ not_found: "not_found";
929
+ observation_drift: "observation_drift";
930
+ permission_mode_denied: "permission_mode_denied";
931
+ policy_revision_mismatch: "policy_revision_mismatch";
932
+ request_conflict: "request_conflict";
933
+ rpc_frame_too_large: "rpc_frame_too_large";
934
+ runtime_identity_unavailable: "runtime_identity_unavailable";
935
+ scope_denied: "scope_denied";
936
+ toolsets_unobservable: "toolsets_unobservable";
937
+ unsupported_input: "unsupported_input";
938
+ }>;
939
+ export type InputPreparationRejectionReason = z.infer<typeof InputPreparationRejectionReasonSchema>;