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