@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.
package/dist/index.d.ts CHANGED
@@ -13,21 +13,24 @@ export { AgentEgressPolicySchema, AgentEgressActivityPolicySchema, AgentReliable
13
13
  export type { AgentEgressPolicy, AgentEgressActivityPolicy, AgentReliableQuotaPolicy, ContentReadPolicy, AgentEgressLane, AgentEgressDropReason, AgentMessageContentType, AgentMessageEgressRequirement, AgentMessageServerContext, AgentContentReadSurface, AgentContentActorKind, AgentContentActor, AgentContentDecodeAs, AgentContentReadDecision, AgentContentReadDenialReason, } from './agent-egress';
14
14
  export { AGENT_HOME_PROJECTION_CAPABILITY, AGENT_HOME_PROJECTION_MAX_BYTES, AGENT_HOME_PROJECTION_PROFILE_REVISION_MAXIMUM, AgentHomeProjectionProfileRevisionSchema, AgentHomeProjectionHashSchema, AgentHomeProjectionOutcomeSchema, AgentHomeProjectionValueSchema, } from './agent-home-projection';
15
15
  export type { AgentHomeProjectionProfileRevision, AgentHomeProjectionHash, AgentHomeProjectionOutcome, AgentHomeProjectionValue, } from './agent-home-projection';
16
+ export { AGENT_INPUT_PREPARATION_CAPABILITY, INPUT_PREPARATION_WIRE_VERSION, InputPreparationContentHashSchema, InputPreparationPermissionModeSchema, InputPreparationPolicyRevisionSchema, InputPreparationProfileIdSchema, InputPreparationSourceSchema, InputPreparationModelCostSchema, InputPreparationModelSchema, InputPreparationOptionsSchema, InputPreparationSelectionSchema, InputPreparationContextFileSchema, InputPreparationDocsPathsSchema, InputPreparationSkillSchema, InputPreparationPromptSnapshotSchema, InputPreparationUserMessageSchema, InputPreparationHostCanonicalAssistantMessageSchema, InputPreparationMessageSchema, InputPreparationContextDocumentSchema, InputPreparationStateSchema, InputPreparationReadinessReasonSchema, InputPreparationRuntimeIdentitySchema, InputPreparationCounterTargetSchema, InputPreparationAccountingPolicyRefSchema, InputPreparationCounterProviderEvidenceSchema, InputPreparationCounterEvidenceSchema, InputPreparationResidualValueClassSchema, InputPreparationResidualKeySchema, InputPreparationProjectionSchema, InputPreparationToolImplementationKindSchema, InputPreparationArtifactSummarySchema, InputPreparationBindingSchema, InputPreparationReceiptSummarySchema, InputPreparationReferenceSchema, InputPreparationOfferBindingSchema, InputPreparationRejectionReasonSchema, } from './input-preparation';
17
+ export type { InputPreparationPermissionMode, InputPreparationSource, InputPreparationModel, InputPreparationOptions, InputPreparationSelection, InputPreparationSkill, InputPreparationMessage, InputPreparationContextDocument, InputPreparationState, InputPreparationReadinessReason, InputPreparationAccountingPolicyRef, InputPreparationResidualValueClass, InputPreparationRuntimeIdentity, InputPreparationReceiptSummary, InputPreparationOfferBinding, InputPreparationRejectionReason, } from './input-preparation';
16
18
  export { AGENT_MEMORY_PROJECTION_CAPABILITY, AGENT_MEMORY_PROJECTION_MAX_REDACTED_BYTES, AGENT_MEMORY_PROJECTION_MAX_ORDERING_VALUE, AgentMemoryProjectionGrantRefSchema, AgentMemoryProjectionSessionRefSchema, AgentMemoryProjectionWriterEpochSchema, AgentMemoryProjectionSourceSeqSchema, AgentMemoryProjectionSnapshotSchema, AgentMemoryProjectionMeteringReceiptSchema, AgentMemoryProjectionMutationSchema, AgentMemoryProjectionReceiptSchema, AgentMemoryProjectionEraseResultSchema, agentMemoryProjectionBase64UrlByteLength, } from './agent-memory-projection';
17
19
  export type { AgentMemoryProjectionGrantRef, AgentMemoryProjectionSessionRef, AgentMemoryProjectionWriterEpoch, AgentMemoryProjectionSourceSeq, AgentMemoryProjectionSnapshot, AgentMemoryProjectionMeteringReceipt, AgentMemoryProjectionMutation, AgentMemoryProjectionReceipt, AgentMemoryProjectionEraseResult, } from './agent-memory-projection';
20
+ export { HOST_MCP_TASK_CONTEXT_CAPABILITY } from './task-assertion';
18
21
  export { TERMINAL_PROJECTION_SELECTION_CAPABILITY, TerminalProjectionContractSchema, TerminalProjectionSelectionSchema, } from './terminal-projection';
19
22
  export type { TerminalProjectionSelection } from './terminal-projection';
20
23
  export { TASK_STATES, TASK_TRANSITIONS, canTransition } from './task-state';
21
24
  export type { TaskState } from './task-state';
22
- export { MESSAGE_TYPES, TASK_OFFER_TYPES, isTaskOfferType, MESSAGE_PAYLOAD_SCHEMAS, SERVER_TO_DAEMON_TYPES, DAEMON_TO_SERVER_TYPES, RuntimeIdSchema, ProtocolVersionNumberSchema, RuntimeInfoSchema, HarnessIdSchema, HarnessInfoSchema, HarnessInventorySchema, RuntimeCapabilitiesSchema, AgentRefSchema, AgentHomeProjectionAgentRefSchema, AGENT_REF_MAX_BYTES, DispatchSelectionSchema, ToolsetIdSchema, ConfiguredToolsetsSchema, RequiredToolsetsSchema, CONFIGURED_TOOLSETS_MAX_ITEMS, ConnHelloPayloadSchema, ConnAckPayloadSchema, TaskOfferPayloadSchema, TaskOfferWithToolsetsPayloadSchema, TaskOfferForAgentPayloadSchema, TaskOfferForAgentWithEgressPayloadSchema, TaskOfferForAgentWithEgressFreshPayloadSchema, AgentEgressReliablePayloadSchema, AgentEgressAckPayloadSchema, AgentMessagePublishPayloadSchema, AgentMessageDispositionPayloadSchema, AgentContentReadPayloadSchema, AgentContentReceiptPayloadSchema, AgentHomeProjectionPayloadSchema, TaskApprovePayloadSchema, TaskRejectPayloadSchema, TaskCancelPayloadSchema, TaskSteerPayloadSchema, TaskClaimPayloadSchema, TaskStartedPayloadSchema, TaskDeclinePayloadSchema, TaskProgressPayloadSchema, TaskArtifactPayloadSchema, TaskAwaitApprovalPayloadSchema, TaskCompletePayloadSchema, TaskFailPayloadSchema, TaskCancelledPayloadSchema, TaskApprovalResolvedPayloadSchema, RESULT_DOCUMENT_MAX_BYTES, checkResultDocument, TerminalInferenceUsageSchema, TERMINAL_INFERENCE_USAGE_MAX_TOKENS, TERMINAL_INFERENCE_USAGE_MAX_DURATION_MS, TERMINAL_INFERENCE_USAGE_PROVIDER_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_MODEL_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_CLIENT_VERSION_MAX_LENGTH, } from './messages';
23
- export type { ResultDocumentCheck, MessageType, RuntimeId, RuntimeInfo, RuntimeCapabilities, AgentRef, AgentHomeProjectionAgentRef, DispatchSelection, ToolsetId, ConnHelloPayload, ConnAckPayload, TaskOfferPayload, TaskOfferWithToolsetsPayload, TaskOfferForAgentPayload, TaskOfferForAgentWithEgressPayload, TaskOfferForAgentWithEgressFreshPayload, AgentEgressReliablePayload, AgentEgressAckPayload, AgentMessagePublishPayload, AgentMessageDispositionPayload, AgentContentReadPayload, AgentContentReceiptPayload, AgentHomeProjectionPayload, TaskApprovePayload, TaskRejectPayload, TaskCancelPayload, TaskSteerPayload, TaskClaimPayload, TaskStartedPayload, TaskDeclinePayload, TaskProgressPayload, TaskArtifactPayload, TaskAwaitApprovalPayload, TaskCompletePayload, TaskFailPayload, TaskCancelledPayload, TaskApprovalResolvedPayload, TerminalInferenceUsage, } from './messages';
25
+ export { MESSAGE_TYPES, TASK_OFFER_TYPES, isTaskOfferType, MESSAGE_PAYLOAD_SCHEMAS, SERVER_TO_DAEMON_TYPES, DAEMON_TO_SERVER_TYPES, RuntimeIdSchema, ProtocolVersionNumberSchema, RuntimeInfoSchema, HarnessIdSchema, HarnessInfoSchema, HarnessInventorySchema, RuntimeCapabilitiesSchema, AgentRefSchema, AgentHomeProjectionAgentRefSchema, AGENT_REF_MAX_BYTES, DispatchSelectionSchema, ToolsetIdSchema, ConfiguredToolsetsSchema, RequiredToolsetsSchema, CONFIGURED_TOOLSETS_MAX_ITEMS, ConnHelloPayloadSchema, ConnAckPayloadSchema, TaskOfferPayloadSchema, TaskOfferWithToolsetsPayloadSchema, TaskOfferForAgentPayloadSchema, TaskOfferForAgentWithEgressPayloadSchema, TaskOfferForAgentWithEgressFreshPayloadSchema, TaskOfferPreparedPayloadSchema, AgentEgressReliablePayloadSchema, AgentEgressAckPayloadSchema, AgentMessagePublishPayloadSchema, AgentMessageDispositionPayloadSchema, AgentContentReadPayloadSchema, AgentContentReceiptPayloadSchema, AgentHomeProjectionPayloadSchema, AgentInputPreparationPayloadSchema, TaskApprovePayloadSchema, TaskRejectPayloadSchema, TaskCancelPayloadSchema, TaskSteerPayloadSchema, TaskClaimPayloadSchema, TaskStartedPayloadSchema, TaskDeclinePayloadSchema, TaskProgressPayloadSchema, TaskArtifactPayloadSchema, TaskAwaitApprovalPayloadSchema, TaskCompletePayloadSchema, TaskFailPayloadSchema, TaskCancelledPayloadSchema, TaskApprovalResolvedPayloadSchema, RESULT_DOCUMENT_MAX_BYTES, checkResultDocument, TerminalInferenceUsageSchema, TerminalPreparedObservationSchema, TERMINAL_INFERENCE_USAGE_MAX_TOKENS, TERMINAL_INFERENCE_USAGE_MAX_DURATION_MS, TERMINAL_INFERENCE_USAGE_PROVIDER_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_MODEL_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_CLIENT_VERSION_MAX_LENGTH, } from './messages';
26
+ export type { ResultDocumentCheck, MessageType, RuntimeId, RuntimeInfo, RuntimeCapabilities, AgentRef, AgentHomeProjectionAgentRef, DispatchSelection, ToolsetId, ConnHelloPayload, ConnAckPayload, TaskOfferPayload, TaskOfferWithToolsetsPayload, TaskOfferForAgentPayload, TaskOfferForAgentWithEgressPayload, TaskOfferForAgentWithEgressFreshPayload, TaskOfferPreparedPayload, AgentEgressReliablePayload, AgentEgressAckPayload, AgentMessagePublishPayload, AgentMessageDispositionPayload, AgentContentReadPayload, AgentContentReceiptPayload, AgentHomeProjectionPayload, AgentInputPreparationPayload, TaskApprovePayload, TaskRejectPayload, TaskCancelPayload, TaskSteerPayload, TaskClaimPayload, TaskStartedPayload, TaskDeclinePayload, TaskProgressPayload, TaskArtifactPayload, TaskAwaitApprovalPayload, TaskCompletePayload, TaskFailPayload, TaskCancelledPayload, TaskApprovalResolvedPayload, TerminalInferenceUsage, TerminalPreparedObservation, } from './messages';
24
27
  export { EnvelopeSchema, isServerToDaemonType } from './envelope';
25
28
  export type { Envelope } from './envelope';
26
29
  export { ProtocolError, EnvelopeParseError, UnknownMessageTypeError, EnvelopeValidationError, } from './errors';
27
30
  export { encodeEnvelope, decodeEnvelope, createEnvelope, parseMessage } from './codec';
28
31
  export type { CreateEnvelopeOptions } from './codec';
29
- export { PairRequestSchema, PairResponseTenantIdSchema, PAIR_RESPONSE_TENANT_ID_MAX_LENGTH, PairResponseSchema, ChallengeRequestSchema, ChallengeResponseSchema, TokenRequestSchema, TokenResponseSchema, PresencePublishRequestSchema, CreateBlobRequestSchema, CreateBlobResponseSchema, BlobDownloadUrlResponseSchema, EventsPollQuerySchema, EventsPollResponseSchema, MessagesSendRequestSchema, MessagesSendResponseSchema, AgentHomeProjectionCompletionRequestSchema, AgentHomeProjectionStatusSchema, AgentHomeProjectionReadbackSchema, AgentMemoryProjectionCommitRequestSchema, AgentMemoryProjectionCommitResponseSchema, MAX_MESSAGES_PER_BATCH, BYOK_PAIR_PATH, BYOK_CHALLENGE_PATH, BYOK_TOKEN_PATH, BYOK_CAPABILITIES_PATH, BYOK_EVENTS_PATH, BYOK_MESSAGES_PATH, BYOK_AGENT_HOME_PROJECTIONS_PATH, BYOK_AGENT_HOME_PROJECTION_COMPLETION_ROUTE, byokAgentHomeProjectionCompletionPath, BYOK_AGENT_MEMORY_PROJECTIONS_PATH, BYOK_PRESENCE_PATH, BYOK_ACTIVITY_PATH, BYOK_BOARD_PATH, BYOK_BOARD_STREAM_PATH, BYOK_BOARD_CLAIM_ROUTE, BYOK_BOARD_UNCLAIM_ROUTE, BYOK_BOARD_STATUS_ROUTE, BYOK_RECORDS_PATH, BYOK_RECORD_ROUTE, byokRecordPath, BYOK_SKILL_PACKS_PATH, BYOK_SKILL_PACK_FILE_ROUTE, byokSkillPackFilePath, BYOK_BLOBS_PATH, BYOK_BLOB_FINALIZE_ROUTE, BYOK_BLOB_URL_ROUTE, BYOK_BLOB_CONTENT_ROUTE, byokBlobFinalizePath, byokBlobUrlPath, byokBlobContentPath, } from './http-api';
30
- export type { PairRequest, PairResponse, ChallengeRequest, ChallengeResponse, TokenRequest, TokenResponse, PresencePublishRequest, CreateBlobRequest, CreateBlobResponse, BlobDownloadUrlResponse, EventsPollQuery, EventsPollResponse, MessagesSendRequest, MessagesSendResponse, AgentHomeProjectionCompletionRequest, AgentHomeProjectionStatus, AgentHomeProjectionReadback, AgentMemoryProjectionCommitRequest, AgentMemoryProjectionCommitResponse, } from './http-api';
32
+ export { PairRequestSchema, PairResponseTenantIdSchema, PAIR_RESPONSE_TENANT_ID_MAX_LENGTH, PairResponseSchema, ChallengeRequestSchema, ChallengeResponseSchema, TokenRequestSchema, TokenResponseSchema, PresencePublishRequestSchema, CreateBlobRequestSchema, CreateBlobResponseSchema, BlobDownloadUrlResponseSchema, EventsPollQuerySchema, EventsPollResponseSchema, MessagesSendRequestSchema, MessagesSendResponseSchema, AgentHomeProjectionCompletionRequestSchema, AgentHomeProjectionStatusSchema, AgentHomeProjectionReadbackSchema, AgentMemoryProjectionCommitRequestSchema, AgentMemoryProjectionCommitResponseSchema, MAX_MESSAGES_PER_BATCH, BYOK_PAIR_PATH, BYOK_CHALLENGE_PATH, BYOK_TOKEN_PATH, BYOK_CAPABILITIES_PATH, BYOK_EVENTS_PATH, BYOK_MESSAGES_PATH, BYOK_AGENT_HOME_PROJECTIONS_PATH, BYOK_AGENT_HOME_PROJECTION_COMPLETION_ROUTE, byokAgentHomeProjectionCompletionPath, BYOK_AGENT_MEMORY_PROJECTIONS_PATH, BYOK_PRESENCE_PATH, BYOK_ACTIVITY_PATH, BYOK_BOARD_PATH, BYOK_BOARD_STREAM_PATH, BYOK_BOARD_CLAIM_ROUTE, BYOK_BOARD_UNCLAIM_ROUTE, BYOK_BOARD_STATUS_ROUTE, BYOK_RECORDS_PATH, BYOK_RECORD_ROUTE, byokRecordPath, BYOK_SKILL_PACKS_PATH, BYOK_SKILL_PACK_FILE_ROUTE, byokSkillPackFilePath, BYOK_BLOBS_PATH, BYOK_BLOB_FINALIZE_ROUTE, BYOK_BLOB_URL_ROUTE, BYOK_BLOB_CONTENT_ROUTE, byokBlobFinalizePath, byokBlobUrlPath, byokBlobContentPath, BYOK_INPUT_PREPARATIONS_PATH, BYOK_INPUT_PREPARATION_COMPLETION_ROUTE, BYOK_INPUT_PREPARATION_STATUS_ROUTE, byokInputPreparationCompletionPath, byokInputPreparationStatusPath, InputPreparationCompletionRequestSchema, InputPreparationStatusSchema, InputPreparationReadbackSchema, InputPreparationStatusQuerySchema, } from './http-api';
33
+ export type { PairRequest, PairResponse, ChallengeRequest, ChallengeResponse, TokenRequest, TokenResponse, PresencePublishRequest, CreateBlobRequest, CreateBlobResponse, BlobDownloadUrlResponse, EventsPollQuery, EventsPollResponse, MessagesSendRequest, MessagesSendResponse, AgentHomeProjectionCompletionRequest, AgentHomeProjectionStatus, AgentHomeProjectionReadback, AgentMemoryProjectionCommitRequest, AgentMemoryProjectionCommitResponse, InputPreparationCompletionRequest, InputPreparationStatus, InputPreparationReadback, InputPreparationStatusQuery, } from './http-api';
31
34
  export type { TaskOfferType } from './messages';
32
35
  export type { HarnessId, HarnessInfo } from './messages';
33
36
  export { CUSTOM_HARNESS_CAPABILITY } from './version';
package/dist/index.js CHANGED
@@ -113,6 +113,356 @@ var AgentHomeProjectionValueSchema = z.json().refine(
113
113
  (value) => new TextEncoder().encode(JSON.stringify(value)).byteLength <= AGENT_HOME_PROJECTION_MAX_BYTES,
114
114
  `projection must not exceed ${AGENT_HOME_PROJECTION_MAX_BYTES} UTF-8 JSON bytes`
115
115
  );
116
+ var PERMISSION_MODES = ["auto", "confirm", "readonly", "plan"];
117
+ var PermissionPolicySchema = z.object({
118
+ mode: z.enum(PERMISSION_MODES),
119
+ allowTools: z.array(z.string()).optional(),
120
+ denyTools: z.array(z.string()).optional(),
121
+ workspaceRoot: z.string().optional(),
122
+ network: z.boolean().optional()
123
+ }).strict();
124
+
125
+ // src/input-preparation.ts
126
+ var INPUT_PREPARATION_WIRE_VERSION = 5;
127
+ var AGENT_INPUT_PREPARATION_CAPABILITY = `agent-input-preparation-v${INPUT_PREPARATION_WIRE_VERSION}`;
128
+ var InputPreparationContentHashSchema = AgentEgressContentHashSchema;
129
+ var OPAQUE_ID = z.string().min(1).max(512).regex(/^[^\u0000-\u001f\u007f]+$/u, "control identifiers must not contain control characters");
130
+ var OPAQUE_TEXT = z.string().min(1).max(2048).regex(/^[^\u0000-\u001f\u007f]+$/u, "control text must not contain control characters");
131
+ var InputPreparationPolicyRevisionSchema = OPAQUE_ID;
132
+ var InputPreparationProfileIdSchema = OPAQUE_ID;
133
+ var InputPreparationPermissionModeSchema = z.enum(PERMISSION_MODES);
134
+ var InputPreparationSourceSchema = z.object({ revision: OPAQUE_ID, digest: OPAQUE_ID }).strict();
135
+ var InputPreparationModelCostSchema = z.object({
136
+ input: z.number().finite(),
137
+ output: z.number().finite(),
138
+ cacheRead: z.number().finite(),
139
+ cacheWrite: z.number().finite()
140
+ }).strict();
141
+ var THINKING_EFFORT = z.string().min(1).max(64).regex(/^[a-zA-Z0-9_-]+$/u).nullable();
142
+ var InputPreparationThinkingLevelMapSchema = z.object({
143
+ off: THINKING_EFFORT,
144
+ minimal: THINKING_EFFORT,
145
+ low: THINKING_EFFORT,
146
+ medium: THINKING_EFFORT,
147
+ high: THINKING_EFFORT,
148
+ xhigh: THINKING_EFFORT,
149
+ max: THINKING_EFFORT
150
+ }).strict();
151
+ var InputPreparationModelCompatSchema = z.object({
152
+ supportsStore: z.boolean().optional(),
153
+ supportsDeveloperRole: z.boolean().optional(),
154
+ supportsReasoningEffort: z.boolean().optional(),
155
+ supportsUsageInStreaming: z.boolean().optional(),
156
+ maxTokensField: z.enum(["max_completion_tokens", "max_tokens"]).optional(),
157
+ thinkingFormat: z.enum([
158
+ "openai",
159
+ "openrouter",
160
+ "deepseek",
161
+ "together",
162
+ "baseten",
163
+ "zai",
164
+ "qwen",
165
+ "chat-template",
166
+ "qwen-chat-template",
167
+ "string-thinking",
168
+ "ant-ling"
169
+ ]).optional(),
170
+ zaiToolStream: z.boolean().optional()
171
+ }).strict();
172
+ var InputPreparationModelSchema = z.object({
173
+ id: OPAQUE_ID,
174
+ name: OPAQUE_ID,
175
+ api: z.literal("openai-completions"),
176
+ provider: OPAQUE_ID,
177
+ baseUrl: OPAQUE_TEXT,
178
+ reasoning: z.boolean(),
179
+ input: z.array(z.enum(["text", "image"])).min(1).max(8),
180
+ cost: InputPreparationModelCostSchema,
181
+ contextWindow: z.number().int().positive(),
182
+ maxTokens: z.number().int().positive(),
183
+ thinkingLevelMap: InputPreparationThinkingLevelMapSchema.optional(),
184
+ compat: InputPreparationModelCompatSchema.optional()
185
+ }).strict();
186
+ var InputPreparationOptionsSchema = z.object({
187
+ cacheRetention: z.enum(["none", "short", "long"]),
188
+ maxTokens: z.number().int().positive(),
189
+ temperature: z.number().finite().optional(),
190
+ toolChoice: z.enum(["auto", "none"]).optional(),
191
+ reasoningEffort: z.enum(["minimal", "low", "medium", "high", "xhigh", "max"]).optional()
192
+ }).strict();
193
+ var InputPreparationSelectionSchema = z.object({ model: InputPreparationModelSchema, options: InputPreparationOptionsSchema }).strict();
194
+ var CONTEXT_PATH = z.string().max(4096).regex(/^[^\u0000]*$/u, "paths must not contain a NUL character");
195
+ var InputPreparationContextFileSchema = z.object({ path: CONTEXT_PATH, content: z.string() }).strict();
196
+ var InputPreparationDocsPathsSchema = z.object({ readmePath: CONTEXT_PATH, docsPath: CONTEXT_PATH, examplesPath: CONTEXT_PATH }).strict();
197
+ var InputPreparationSkillSchema = z.object({
198
+ name: OPAQUE_ID,
199
+ description: z.string().max(4096),
200
+ filePath: CONTEXT_PATH,
201
+ disableModelInvocation: z.boolean()
202
+ }).strict();
203
+ var InputPreparationPromptSnapshotSchema = z.object({
204
+ customPrompt: z.string().optional(),
205
+ appendSystemPrompt: z.string().optional(),
206
+ cwd: CONTEXT_PATH,
207
+ toolSnippets: z.record(z.string(), z.string()),
208
+ toolGuidelines: z.record(z.string(), z.array(z.string()).max(512)),
209
+ promptGuidelines: z.array(z.string()).max(512),
210
+ contextFiles: z.array(InputPreparationContextFileSchema).max(512),
211
+ skills: z.array(InputPreparationSkillSchema).max(512),
212
+ docsPaths: InputPreparationDocsPathsSchema
213
+ }).strict();
214
+ var InputPreparationUserMessageSchema = z.object({
215
+ role: z.literal("user"),
216
+ content: z.string(),
217
+ timestamp: z.number().int()
218
+ }).strict();
219
+ var InputPreparationHostCanonicalAssistantMessageSchema = z.object({
220
+ role: z.literal("assistant"),
221
+ origin: z.literal("host_canonical"),
222
+ content: z.string(),
223
+ timestamp: z.number().int()
224
+ }).strict();
225
+ var InputPreparationMessageSchema = z.discriminatedUnion("role", [
226
+ InputPreparationUserMessageSchema,
227
+ InputPreparationHostCanonicalAssistantMessageSchema
228
+ ]);
229
+ var InputPreparationContextDocumentSchema = z.object({
230
+ prompt: InputPreparationPromptSnapshotSchema,
231
+ messages: z.array(InputPreparationMessageSchema).max(4096)
232
+ }).strict();
233
+ var InputPreparationStateSchema = z.enum([
234
+ "reserved",
235
+ "counting",
236
+ "prepared",
237
+ "cancelled",
238
+ "failed",
239
+ "counter_interrupted"
240
+ ]);
241
+ var InputPreparationReadinessReasonSchema = z.enum([
242
+ /** The record has not reached `prepared` (it is `reserved` or `counting`). */
243
+ "not_prepared",
244
+ "counter_interrupted",
245
+ "cancelled",
246
+ "failed",
247
+ "artifact_expired",
248
+ /** A counter IS present and its authority is not `provider` (a fixture never reaches ready). */
249
+ "counter_authority_not_production",
250
+ /** A counter IS present and it reported its projection as not covered. */
251
+ "counter_coverage_incomplete",
252
+ /**
253
+ * D, the frozen provider request, carries a message content part whose
254
+ * `type` is not `text`. The first release admits text-only D; a multimodal
255
+ * part is not sized by `requestBytes` in any way the Host's ruling covers.
256
+ */
257
+ "request_content_not_text",
258
+ /** The native compiler's projection kind is not `content_complete`. */
259
+ "projection_unknown",
260
+ /** The artifact carries a residual key the accounting policy does not rule on. */
261
+ "residual_not_ruled",
262
+ /** The request named no accounting policy. There is no default. */
263
+ "accounting_policy_missing",
264
+ /** The named policy was ruled for a different runtime, endpoint or model. */
265
+ "accounting_policy_inapplicable",
266
+ "executor_identity_unproven",
267
+ /**
268
+ * The record was prepared against a runtime contract this build no longer
269
+ * speaks: its binding declares a prepared-compiler version other than the one
270
+ * this build prepares and consumes against. The artifact is not re-read
271
+ * through the current contract and is not translated — a projection frozen
272
+ * under another compiler's classification table is evidence about a request
273
+ * this build cannot re-derive.
274
+ */
275
+ "runtime_contract_superseded"
276
+ ]);
277
+ var InputPreparationRuntimeIdentitySchema = z.object({
278
+ packageName: OPAQUE_ID,
279
+ packageVersion: OPAQUE_ID,
280
+ upstreamBase: OPAQUE_ID,
281
+ upstreamCommit: OPAQUE_ID,
282
+ forkBuild: z.number().int().nonnegative(),
283
+ envelopeFormat: OPAQUE_ID,
284
+ requestFormat: OPAQUE_ID,
285
+ compilerVersion: z.number().int().nonnegative()
286
+ }).strict();
287
+ var InputPreparationCounterTargetSchema = z.object({ endpoint: OPAQUE_TEXT, modelId: OPAQUE_ID }).strict();
288
+ var InputPreparationAccountingPolicyRefSchema = z.object({
289
+ revision: OPAQUE_ID,
290
+ /** The runtime identity string this ruling was made for. */
291
+ ruledRuntime: OPAQUE_ID,
292
+ /** The endpoint/model this ruling was made for. */
293
+ ruledTarget: InputPreparationCounterTargetSchema,
294
+ /** Every residual key the Host's accounting already accounts for. */
295
+ ruledResidualKeys: z.array(OPAQUE_ID).max(64)
296
+ }).strict();
297
+ var InputPreparationCounterProviderEvidenceSchema = z.object({
298
+ projectionDigest: z.string().regex(/^[0-9a-f]{64}$/u, "a projection digest is lowercase sha-256 hex"),
299
+ endpoint: OPAQUE_TEXT,
300
+ modelId: OPAQUE_ID,
301
+ asserted: z.object({
302
+ httpStatus: z.number().int(),
303
+ usageFields: z.record(OPAQUE_ID, z.number().finite()),
304
+ responseDigest: OPAQUE_ID
305
+ }).strict()
306
+ }).strict();
307
+ var InputPreparationCounterEvidenceSchema = z.object({
308
+ method: OPAQUE_ID,
309
+ methodVersion: OPAQUE_ID,
310
+ authority: z.enum(["provider", "test_fixture"]),
311
+ value: z.number().int().nonnegative(),
312
+ coverage: z.object({ covered: z.boolean(), reason: z.string().max(512).optional() }).strict(),
313
+ providerEvidence: InputPreparationCounterProviderEvidenceSchema,
314
+ target: InputPreparationCounterTargetSchema,
315
+ calledAt: z.iso.datetime({ offset: true }),
316
+ completedAt: z.iso.datetime({ offset: true })
317
+ }).strict();
318
+ var InputPreparationToolImplementationKindSchema = z.string().regex(/^(?:attested|unavailable:[a-z_]{1,64})$/u, 'a tool implementation kind is "attested" or "unavailable:<reason>"');
319
+ var InputPreparationResidualValueClassSchema = z.enum([
320
+ "constant",
321
+ "boolean",
322
+ "bounded_integer",
323
+ "bounded_number",
324
+ "finite_number",
325
+ "closed_enum",
326
+ "nonempty_string",
327
+ "object_shape"
328
+ ]);
329
+ var InputPreparationResidualKeySchema = z.object({ key: OPAQUE_ID, valueClass: InputPreparationResidualValueClassSchema }).strict();
330
+ var InputPreparationProjectionSchema = z.object({
331
+ version: z.literal(3),
332
+ kind: z.enum(["content_complete", "unknown"]),
333
+ digest: z.string().regex(/^[0-9a-f]{64}$/u, "a projection digest is lowercase sha-256 hex")
334
+ }).strict();
335
+ var InputPreparationArtifactSummarySchema = z.object({
336
+ requestDigest: OPAQUE_ID,
337
+ envelopeDigest: OPAQUE_ID,
338
+ toolManifestDigest: OPAQUE_ID,
339
+ /**
340
+ * The exact UTF-8 byte length of the frozen provider request D, measured
341
+ * by the device's own compiler. The ONE size evidence a receipt carries:
342
+ * the Host rules the budget (`requestBytes + C + max_tokens <= window`)
343
+ * against it. Never a token count and never an estimate.
344
+ */
345
+ requestBytes: z.number().int().nonnegative(),
346
+ projectionBytes: z.number().int().nonnegative(),
347
+ projection: InputPreparationProjectionSchema,
348
+ residual: z.array(InputPreparationResidualKeySchema).max(64),
349
+ observationDigest: OPAQUE_ID,
350
+ toolBindingDigest: OPAQUE_ID,
351
+ toolImplementationKinds: z.record(OPAQUE_ID, InputPreparationToolImplementationKindSchema)
352
+ }).strict();
353
+ var InputPreparationBindingSchema = z.object({
354
+ scopeId: OPAQUE_ID,
355
+ deviceId: OPAQUE_ID,
356
+ agentRef: OPAQUE_ID,
357
+ profileId: OPAQUE_ID,
358
+ profileRevision: OPAQUE_ID,
359
+ source: InputPreparationSourceSchema,
360
+ target: InputPreparationCounterTargetSchema,
361
+ policyRevision: OPAQUE_ID,
362
+ /**
363
+ * The mode the counted manifest was filtered for. Recorded on the binding
364
+ * rather than only inside the request digest so a consumer can COMPARE it
365
+ * without re-deriving the digest: an Execution offered under a different
366
+ * mode is an Execution whose registered tool set differs from the one
367
+ * these tokens were counted for.
368
+ */
369
+ permissionMode: InputPreparationPermissionModeSchema,
370
+ runtime: InputPreparationRuntimeIdentitySchema,
371
+ requestDigest: OPAQUE_ID,
372
+ /**
373
+ * The Host's accounting ruling this preparation was requested under,
374
+ * copied verbatim. Absent when the request named none — never filled in,
375
+ * and never narrowed to one the device would have chosen.
376
+ */
377
+ accountingPolicyRef: InputPreparationAccountingPolicyRefSchema.optional()
378
+ }).strict();
379
+ var InputPreparationReceiptSummarySchema = z.object({
380
+ reference: OPAQUE_ID,
381
+ state: InputPreparationStateSchema,
382
+ binding: InputPreparationBindingSchema,
383
+ artifact: InputPreparationArtifactSummarySchema.optional(),
384
+ counter: InputPreparationCounterEvidenceSchema.optional(),
385
+ ready: z.boolean(),
386
+ readinessReasons: z.array(InputPreparationReadinessReasonSchema).max(16),
387
+ detail: OPAQUE_ID.optional(),
388
+ artifactExpiresAt: z.iso.datetime({ offset: true })
389
+ }).strict().superRefine((value, ctx) => {
390
+ if (value.ready !== (value.readinessReasons.length === 0)) {
391
+ ctx.addIssue({
392
+ code: "custom",
393
+ path: ["ready"],
394
+ message: "ready must be true exactly when readinessReasons is empty"
395
+ });
396
+ }
397
+ });
398
+ var InputPreparationReferenceSchema = OPAQUE_ID;
399
+ var InputPreparationOfferBindingSchema = z.object({
400
+ reference: InputPreparationReferenceSchema,
401
+ /** `InputPreparationBindingSchema.requestDigest`, as the receipt reported it. */
402
+ requestDigest: OPAQUE_ID,
403
+ /** `InputPreparationArtifactSummarySchema.envelopeDigest`, when the receipt carried one. */
404
+ artifactDigest: OPAQUE_ID.optional()
405
+ }).strict();
406
+ var InputPreparationRejectionReasonSchema = z.enum([
407
+ "input_preparation_unconfigured",
408
+ "bad_request",
409
+ "authority_unavailable",
410
+ "scope_denied",
411
+ "policy_revision_mismatch",
412
+ "runtime_identity_unavailable",
413
+ "unsupported_input",
414
+ "limit_exceeded",
415
+ "request_conflict",
416
+ "not_found",
417
+ "counter_unavailable",
418
+ "counter_interrupted",
419
+ "durable_write_failed",
420
+ "cancelled",
421
+ "context_unresolvable",
422
+ "context_hash_mismatch",
423
+ "toolsets_unobservable",
424
+ "deadline_elapsed",
425
+ /**
426
+ * The device could not prove a non-writable launch directory (or a trusted
427
+ * launcher) for the MCP toolset servers this preparation names, so it
428
+ * refused rather than observing them in a directory the agent's own uid can
429
+ * write. The specific `TrustedLaunchCwdUnavailableReason` travels in the
430
+ * receipt's `detail`; it is not widened into a spawn.
431
+ */
432
+ "launch_boundary_unavailable",
433
+ /**
434
+ * A repeat of an already-recorded `requestId` arrived after the facts its
435
+ * executor fingerprints were frozen against changed — a toolset definition
436
+ * revision, the launch attestation, or an implementation identity that no
437
+ * longer measures the same. The recorded receipt is not re-derived and no
438
+ * server is re-probed; the repeat is refused so the caller mints a new
439
+ * preparation instead of silently receiving one bound to stale evidence.
440
+ */
441
+ "observation_drift",
442
+ /**
443
+ * The declared `permissionMode` is not one this device admits: it exceeds
444
+ * the operator's configured ceiling. The requester's declaration is INTENT,
445
+ * not authorization — it goes through the same merge that admits a task
446
+ * offer's `policy.mode` — and an unadmitted mode refuses rather than being
447
+ * silently narrowed to one the device would allow.
448
+ */
449
+ "permission_mode_denied",
450
+ /**
451
+ * The device compiled the input, then found that the `prompt_prepared` frame
452
+ * the runtime would have to be handed exceeds the single-frame byte cap that
453
+ * runtime enforces. The bound belongs to the runtime, not to the operator's
454
+ * retention policy, so it is decided first and nothing is retained: a
455
+ * preparation that could never be delivered is not a smaller preparation.
456
+ */
457
+ "rpc_frame_too_large",
458
+ /**
459
+ * The device's input-preparation lane is off because its durable record log
460
+ * holds a record from an older record schema version. The rest of the
461
+ * device runs; this lane refuses until an operator archives that log. No
462
+ * record is migrated, read forward or deleted.
463
+ */
464
+ "input_preparation_record_log_unsupported"
465
+ ]);
116
466
  var TERMINAL_PROJECTION_SELECTION_CAPABILITY = "terminal-projection-selection";
117
467
  var TerminalProjectionContractSchema = z.string().min(1).max(128).regex(/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/u, "terminal projection contracts must be opaque lowercase ids");
118
468
  var TerminalProjectionSelectionSchema = z.discriminatedUnion("mode", [
@@ -122,6 +472,9 @@ var TerminalProjectionSelectionSchema = z.discriminatedUnion("mode", [
122
472
  contract: TerminalProjectionContractSchema
123
473
  }).strict()
124
474
  ]);
475
+
476
+ // src/task-assertion.ts
477
+ var HOST_MCP_TASK_CONTEXT_CAPABILITY = "host-mcp-task-context";
125
478
  var PROVIDER_PROFILE_BINDING_CAPABILITY = "provider-profile-binding";
126
479
  var ProviderProfileRefSchema = z.string().min(1).max(64).regex(/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/u, "provider profile refs must be lowercase portable identifiers");
127
480
  var ProviderProfileRevisionSchema = z.string().regex(/^(?:0|[1-9][0-9]{0,19})$/u, "provider profile revision must be canonical decimal");
@@ -166,7 +519,9 @@ var CAPABILITY_FLAGS = [
166
519
  AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY,
167
520
  AGENT_CONTENT_ARTIFACT_READ_CAPABILITY,
168
521
  AGENT_HOME_PROJECTION_CAPABILITY,
522
+ AGENT_INPUT_PREPARATION_CAPABILITY,
169
523
  TERMINAL_PROJECTION_SELECTION_CAPABILITY,
524
+ HOST_MCP_TASK_CONTEXT_CAPABILITY,
170
525
  CUSTOM_HARNESS_CAPABILITY,
171
526
  MAILBOX_READ_AHEAD_CAPABILITY
172
527
  ];
@@ -178,14 +533,6 @@ var BlobRefSchema = z.object({
178
533
  contentType: z.string(),
179
534
  url: z.string().optional()
180
535
  });
181
- var PERMISSION_MODES = ["auto", "confirm", "readonly", "plan"];
182
- var PermissionPolicySchema = z.object({
183
- mode: z.enum(PERMISSION_MODES),
184
- allowTools: z.array(z.string()).optional(),
185
- denyTools: z.array(z.string()).optional(),
186
- workspaceRoot: z.string().optional(),
187
- network: z.boolean().optional()
188
- }).strict();
189
536
  var AGENT_EVENT_SPILL_UNSTORED_REASON_MAX_LENGTH = 512;
190
537
  var AgentEventSpillSchema = z.object({
191
538
  /** Which field of the event was replaced by a preview. */
@@ -410,6 +757,10 @@ var TaskOfferForAgentWithEgressFreshPayloadSchema = TaskOfferForAgentPayloadSche
410
757
  egressPolicy: AgentEgressPolicySchema,
411
758
  messageEgress: AgentMessageEgressRequirementSchema.optional()
412
759
  }).strict();
760
+ var TaskOfferPreparedPayloadSchema = TaskOfferForAgentPayloadSchema.omit({
761
+ instruction: true,
762
+ sessionRef: true
763
+ }).extend({ preparation: InputPreparationOfferBindingSchema }).strict();
413
764
  var EGRESS_SAFE_VALUE = z.json().refine(
414
765
  (value) => new TextEncoder().encode(JSON.stringify(value)).byteLength <= 256 * 1024,
415
766
  "sanitized egress payload exceeds 256KiB"
@@ -541,6 +892,37 @@ var AgentHomeProjectionPayloadSchema = z.object({
541
892
  projectionHash: AgentHomeProjectionHashSchema,
542
893
  projection: AgentHomeProjectionValueSchema
543
894
  }).strict();
895
+ var InputPreparationInlineContextSchema = z.object({
896
+ inline: z.string().refine(isWithinInlineByteLimit, `inline context must not exceed ${MAX_INLINE_BYTES} UTF-8 bytes`)
897
+ }).strict();
898
+ var InputPreparationBlobContextSchema = z.object({ blobRef: BlobRefSchema, contentHash: InputPreparationContentHashSchema }).strict().superRefine((value, ctx) => {
899
+ if (value.blobRef.contentHash !== value.contentHash) {
900
+ ctx.addIssue({
901
+ code: "custom",
902
+ path: ["blobRef", "contentHash"],
903
+ message: "blobRef contentHash must equal contentHash"
904
+ });
905
+ }
906
+ });
907
+ var AgentInputPreparationPayloadSchema = z.object({
908
+ requestId: z.uuid(),
909
+ agentRef: AgentRefSchema,
910
+ profileId: InputPreparationProfileIdSchema,
911
+ policyRevision: InputPreparationPolicyRevisionSchema,
912
+ source: InputPreparationSourceSchema,
913
+ selection: InputPreparationSelectionSchema,
914
+ deadlineAt: z.iso.datetime({ offset: true }),
915
+ context: z.union([InputPreparationInlineContextSchema, InputPreparationBlobContextSchema]),
916
+ requiredToolsets: RequiredToolsetsSchema,
917
+ permissionMode: InputPreparationPermissionModeSchema,
918
+ /**
919
+ * The Host's accounting ruling for this preparation, carried verbatim onto
920
+ * the receipt's binding. Optional and defaulted NOWHERE: a payload that
921
+ * omits it produces a receipt that says `accounting_policy_missing`, which
922
+ * is the honest answer — the device rules on no residual key by itself.
923
+ */
924
+ accountingPolicyRef: InputPreparationAccountingPolicyRefSchema.optional()
925
+ }).strict();
544
926
  var TaskApprovePayloadSchema = z.object({
545
927
  approvalId: z.string().optional()
546
928
  });
@@ -658,6 +1040,14 @@ var TerminalInferenceUsageSchema = z.object({
658
1040
  /** Device observation time, never server receipt time. */
659
1041
  reportedAt: TerminalInferenceReportedAtSchema
660
1042
  });
1043
+ var TerminalPreparedObservationSchema = z.object({
1044
+ requestDigest: InputPreparationArtifactSummarySchema.shape.requestDigest,
1045
+ initialPromptTokens: TerminalInferenceUsageNumberSchema,
1046
+ maxPromptTokens: TerminalInferenceUsageNumberSchema
1047
+ }).strict().refine((value) => value.maxPromptTokens >= value.initialPromptTokens, {
1048
+ message: "maxPromptTokens must not be below initialPromptTokens",
1049
+ path: ["maxPromptTokens"]
1050
+ });
661
1051
  var TaskCompletePayloadSchema = z.object({
662
1052
  harnessId: HarnessIdSchema.optional(),
663
1053
  summary: z.string(),
@@ -667,6 +1057,8 @@ var TaskCompletePayloadSchema = z.object({
667
1057
  message: `task.complete.document must be plain JSON data (equal to its own JSON round trip) and at most ${RESULT_DOCUMENT_MAX_BYTES} bytes as canonical JSON (UTF-8)`
668
1058
  }),
669
1059
  usage: TerminalInferenceUsageSchema.optional(),
1060
+ /** Present on a prepared Execution only — see {@link TerminalPreparedObservationSchema}. */
1061
+ preparedObservation: TerminalPreparedObservationSchema.optional(),
670
1062
  agentRef: AgentRefSchema.optional()
671
1063
  });
672
1064
  var TaskFailPayloadSchema = z.object({
@@ -676,6 +1068,8 @@ var TaskFailPayloadSchema = z.object({
676
1068
  reason: z.string(),
677
1069
  retryable: z.boolean().optional(),
678
1070
  usage: TerminalInferenceUsageSchema.optional(),
1071
+ /** Present on a prepared Execution that observed provider usage before failing. */
1072
+ preparedObservation: TerminalPreparedObservationSchema.optional(),
679
1073
  agentRef: AgentRefSchema.optional()
680
1074
  });
681
1075
  var TaskCancelledPayloadSchema = z.object({
@@ -695,7 +1089,8 @@ var TASK_OFFER_PAYLOAD_SCHEMAS = {
695
1089
  "task.offer_with_toolsets": TaskOfferWithToolsetsPayloadSchema,
696
1090
  "task.offer_for_agent": TaskOfferForAgentPayloadSchema,
697
1091
  "task.offer_for_agent_with_egress": TaskOfferForAgentWithEgressPayloadSchema,
698
- "task.offer_for_agent_with_egress_fresh": TaskOfferForAgentWithEgressFreshPayloadSchema
1092
+ "task.offer_for_agent_with_egress_fresh": TaskOfferForAgentWithEgressFreshPayloadSchema,
1093
+ "task.offer_prepared": TaskOfferPreparedPayloadSchema
699
1094
  };
700
1095
  var TASK_OFFER_TYPES = Object.freeze(
701
1096
  Object.keys(TASK_OFFER_PAYLOAD_SCHEMAS)
@@ -714,6 +1109,7 @@ var MESSAGE_PAYLOAD_SCHEMAS = {
714
1109
  "agent.content.read": AgentContentReadPayloadSchema,
715
1110
  "agent.content.receipt": AgentContentReceiptPayloadSchema,
716
1111
  "agent.home.projection": AgentHomeProjectionPayloadSchema,
1112
+ "agent.input.preparation": AgentInputPreparationPayloadSchema,
717
1113
  "task.approve": TaskApprovePayloadSchema,
718
1114
  "task.reject": TaskRejectPayloadSchema,
719
1115
  "task.cancel": TaskCancelPayloadSchema,
@@ -737,10 +1133,12 @@ var SERVER_TO_DAEMON_TYPES = [
737
1133
  "task.offer_for_agent",
738
1134
  "task.offer_for_agent_with_egress",
739
1135
  "task.offer_for_agent_with_egress_fresh",
1136
+ "task.offer_prepared",
740
1137
  "agent.egress.ack",
741
1138
  "agent.message.disposition",
742
1139
  "agent.content.read",
743
1140
  "agent.home.projection",
1141
+ "agent.input.preparation",
744
1142
  "task.approve",
745
1143
  "task.reject",
746
1144
  "task.cancel",
@@ -890,10 +1288,12 @@ var EnvelopeSchema = z.discriminatedUnion("type", [
890
1288
  envelopeShape("task.offer_for_agent", REQUIRED_TASK_ID, REQUIRED_SEQ),
891
1289
  envelopeShape("task.offer_for_agent_with_egress", REQUIRED_TASK_ID, REQUIRED_SEQ),
892
1290
  envelopeShape("task.offer_for_agent_with_egress_fresh", REQUIRED_TASK_ID, REQUIRED_SEQ),
1291
+ envelopeShape("task.offer_prepared", REQUIRED_TASK_ID, REQUIRED_SEQ),
893
1292
  envelopeShape("agent.egress.ack", OPTIONAL_TASK_ID, REQUIRED_SEQ),
894
1293
  envelopeShape("agent.message.disposition", REQUIRED_TASK_ID, REQUIRED_SEQ),
895
1294
  envelopeShape("agent.content.read", OPTIONAL_TASK_ID, REQUIRED_SEQ),
896
1295
  envelopeShape("agent.home.projection", FORBIDDEN_TASK_ID, REQUIRED_SEQ),
1296
+ envelopeShape("agent.input.preparation", FORBIDDEN_TASK_ID, REQUIRED_SEQ),
897
1297
  envelopeShape("task.approve", REQUIRED_TASK_ID, REQUIRED_SEQ),
898
1298
  envelopeShape("task.reject", REQUIRED_TASK_ID, REQUIRED_SEQ),
899
1299
  envelopeShape("task.cancel", REQUIRED_TASK_ID, REQUIRED_SEQ),
@@ -1123,6 +1523,53 @@ var AgentHomeProjectionReadbackSchema = z.object({
1123
1523
  status: AgentHomeProjectionStatusSchema,
1124
1524
  completedAt: z.iso.datetime({ offset: true }).optional()
1125
1525
  }).strict();
1526
+ var InputPreparationCompletionRequestSchema = z.discriminatedUnion("outcome", [
1527
+ z.object({
1528
+ outcome: z.literal("prepared"),
1529
+ requestId: z.uuid(),
1530
+ agentRef: AgentRefSchema,
1531
+ profileId: InputPreparationProfileIdSchema,
1532
+ policyRevision: InputPreparationPolicyRevisionSchema,
1533
+ receipt: InputPreparationReceiptSummarySchema
1534
+ }).strict(),
1535
+ z.object({
1536
+ outcome: z.literal("rejected"),
1537
+ requestId: z.uuid(),
1538
+ agentRef: AgentRefSchema,
1539
+ profileId: InputPreparationProfileIdSchema,
1540
+ policyRevision: InputPreparationPolicyRevisionSchema,
1541
+ reason: InputPreparationRejectionReasonSchema
1542
+ }).strict()
1543
+ ]);
1544
+ var InputPreparationStatusSchema = z.enum(["pending", "prepared", "rejected"]);
1545
+ var InputPreparationReadbackSchema = z.object({
1546
+ tenantId: z.string().min(1),
1547
+ deviceId: z.string().min(1),
1548
+ requestId: z.uuid(),
1549
+ agentRef: AgentRefSchema,
1550
+ profileId: InputPreparationProfileIdSchema,
1551
+ policyRevision: InputPreparationPolicyRevisionSchema,
1552
+ status: InputPreparationStatusSchema,
1553
+ receipt: InputPreparationReceiptSummarySchema.optional(),
1554
+ reason: InputPreparationRejectionReasonSchema.optional(),
1555
+ completedAt: z.iso.datetime({ offset: true }).optional()
1556
+ }).strict().superRefine((value, ctx) => {
1557
+ const expectsReceipt = value.status === "prepared";
1558
+ const expectsReason = value.status === "rejected";
1559
+ if (expectsReceipt !== (value.receipt !== void 0)) {
1560
+ ctx.addIssue({ code: "custom", path: ["receipt"], message: 'receipt is present exactly when status is "prepared"' });
1561
+ }
1562
+ if (expectsReason !== (value.reason !== void 0)) {
1563
+ ctx.addIssue({ code: "custom", path: ["reason"], message: 'reason is present exactly when status is "rejected"' });
1564
+ }
1565
+ if (value.status !== "pending" !== (value.completedAt !== void 0)) {
1566
+ ctx.addIssue({ code: "custom", path: ["completedAt"], message: "completedAt is present exactly when the status is terminal" });
1567
+ }
1568
+ });
1569
+ var InputPreparationStatusQuerySchema = z.object({
1570
+ agentId: z.string().min(1),
1571
+ profileRevision: z.string().min(1)
1572
+ }).strict();
1126
1573
  var AgentMemoryProjectionCommitRequestSchema = AgentMemoryProjectionMutationSchema;
1127
1574
  var AgentMemoryProjectionCommitResponseSchema = AgentMemoryProjectionReceiptSchema;
1128
1575
  var BYOK_PAIR_PATH = "/byok/pair";
@@ -1136,6 +1583,15 @@ var BYOK_AGENT_HOME_PROJECTION_COMPLETION_ROUTE = "/byok/agent-home-projections/
1136
1583
  function byokAgentHomeProjectionCompletionPath(requestId) {
1137
1584
  return `${BYOK_AGENT_HOME_PROJECTIONS_PATH}/${encodeURIComponent(requestId)}/completion`;
1138
1585
  }
1586
+ var BYOK_INPUT_PREPARATIONS_PATH = "/byok/input-preparations";
1587
+ var BYOK_INPUT_PREPARATION_COMPLETION_ROUTE = "/byok/input-preparations/:requestId/completion";
1588
+ var BYOK_INPUT_PREPARATION_STATUS_ROUTE = "/byok/input-preparations/:requestId";
1589
+ function byokInputPreparationCompletionPath(requestId) {
1590
+ return `${BYOK_INPUT_PREPARATIONS_PATH}/${encodeURIComponent(requestId)}/completion`;
1591
+ }
1592
+ function byokInputPreparationStatusPath(requestId) {
1593
+ return `${BYOK_INPUT_PREPARATIONS_PATH}/${encodeURIComponent(requestId)}`;
1594
+ }
1139
1595
  var BYOK_AGENT_MEMORY_PROJECTIONS_PATH = "/byok/agent-memory-projections";
1140
1596
  var BYOK_PRESENCE_PATH = "/byok/presence";
1141
1597
  var BYOK_ACTIVITY_PATH = "/byok/activity";
@@ -1168,6 +1624,6 @@ function byokBlobContentPath(blobId) {
1168
1624
  return `/byok/blobs/${blobId}/content`;
1169
1625
  }
1170
1626
 
1171
- export { AGENT_CONTENT_ARTIFACT_READ_CAPABILITY, AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY, AGENT_CONTENT_WORKSPACE_READ_CAPABILITY, AGENT_EGRESS_FRESH_SESSION_CAPABILITY, AGENT_EGRESS_POLICY_CAPABILITY, AGENT_EGRESS_RELIABLE_ACK_CAPABILITY, AGENT_EVENT_SPILL_UNSTORED_REASON_MAX_LENGTH, AGENT_HOME_PROJECTION_CAPABILITY, AGENT_HOME_PROJECTION_MAX_BYTES, AGENT_HOME_PROJECTION_PROFILE_REVISION_MAXIMUM, AGENT_MEMORY_PROJECTION_CAPABILITY, AGENT_MEMORY_PROJECTION_MAX_ORDERING_VALUE, AGENT_MEMORY_PROJECTION_MAX_REDACTED_BYTES, AGENT_MESSAGE_EGRESS_CAPABILITY, AGENT_MESSAGE_MAX_BYTES, AGENT_REF_MAX_BYTES, AgentContentActorKindSchema, AgentContentActorSchema, AgentContentDecodeAsSchema, AgentContentMimeTypeSchema, AgentContentReadDecisionSchema, AgentContentReadDenialReasonSchema, AgentContentReadPayloadSchema, AgentContentReadSurfaceSchema, AgentContentReceiptPayloadSchema, AgentEgressAckPayloadSchema, AgentEgressActivityPolicySchema, AgentEgressContentHashSchema, AgentEgressDropReasonSchema, AgentEgressLaneSchema, AgentEgressPolicyRevisionSchema, AgentEgressPolicySchema, AgentEgressReliablePayloadSchema, AgentEventOrUnknownSchema, AgentEventSchema, AgentEventSpillSchema, AgentHomeProjectionAgentRefSchema, AgentHomeProjectionCompletionRequestSchema, AgentHomeProjectionHashSchema, AgentHomeProjectionOutcomeSchema, AgentHomeProjectionPayloadSchema, AgentHomeProjectionProfileRevisionSchema, AgentHomeProjectionReadbackSchema, AgentHomeProjectionStatusSchema, AgentHomeProjectionValueSchema, AgentMemoryProjectionCommitRequestSchema, AgentMemoryProjectionCommitResponseSchema, AgentMemoryProjectionEraseResultSchema, AgentMemoryProjectionGrantRefSchema, AgentMemoryProjectionMeteringReceiptSchema, AgentMemoryProjectionMutationSchema, AgentMemoryProjectionReceiptSchema, AgentMemoryProjectionSessionRefSchema, AgentMemoryProjectionSnapshotSchema, AgentMemoryProjectionSourceSeqSchema, AgentMemoryProjectionWriterEpochSchema, AgentMessageContentTypeSchema, AgentMessageContractSchema, AgentMessageDestinationBindingSchema, AgentMessageDispositionPayloadSchema, AgentMessageEgressRequirementSchema, AgentMessageFreshnessCursorSchema, AgentMessagePublishPayloadSchema, AgentMessageServerContextSchema, AgentRefSchema, AgentReliableQuotaPolicySchema, BYOK_ACTIVITY_PATH, BYOK_AGENT_HOME_PROJECTIONS_PATH, BYOK_AGENT_HOME_PROJECTION_COMPLETION_ROUTE, BYOK_AGENT_MEMORY_PROJECTIONS_PATH, BYOK_BLOBS_PATH, BYOK_BLOB_CONTENT_ROUTE, BYOK_BLOB_FINALIZE_ROUTE, BYOK_BLOB_URL_ROUTE, BYOK_BOARD_CLAIM_ROUTE, BYOK_BOARD_PATH, BYOK_BOARD_STATUS_ROUTE, BYOK_BOARD_STREAM_PATH, BYOK_BOARD_UNCLAIM_ROUTE, BYOK_CAPABILITIES_PATH, BYOK_CHALLENGE_PATH, BYOK_EVENTS_PATH, BYOK_MESSAGES_PATH, BYOK_PAIR_PATH, BYOK_PRESENCE_PATH, BYOK_RECORDS_PATH, BYOK_RECORD_ROUTE, BYOK_SKILL_PACKS_PATH, BYOK_SKILL_PACK_FILE_ROUTE, BYOK_TOKEN_PATH, BlobDownloadUrlResponseSchema, BlobRefSchema, CAPABILITY_FLAGS, CONFIGURED_TOOLSETS_MAX_ITEMS, CONTENT_HASH_RE, CUSTOM_HARNESS_CAPABILITY, ChallengeRequestSchema, ChallengeResponseSchema, ConfiguredToolsetsSchema, ConnAckPayloadSchema, ConnHelloPayloadSchema, ContentReadPolicySchema, CreateBlobRequestSchema, CreateBlobResponseSchema, DAEMON_TO_SERVER_TYPES, DispatchSelectionSchema, EnvelopeParseError, EnvelopeSchema, EnvelopeValidationError, EventsPollQuerySchema, EventsPollResponseSchema, HarnessIdSchema, HarnessInfoSchema, HarnessInventorySchema, KNOWN_AGENT_EVENT_TYPES, MAILBOX_READ_AHEAD_CAPABILITY, MAILBOX_READ_AHEAD_MAX_SEQS, MAX_MESSAGES_PER_BATCH, MESSAGE_PAYLOAD_SCHEMAS, MESSAGE_TYPES, MessagesSendRequestSchema, MessagesSendResponseSchema, PAIR_RESPONSE_TENANT_ID_MAX_LENGTH, PERMISSION_MODES, PROTOCOL_VERSION, PROVIDER_MODEL_CAPABILITIES, PROVIDER_PROFILE_BINDING_CAPABILITY, PairRequestSchema, PairResponseSchema, PairResponseTenantIdSchema, PermissionPolicySchema, PresencePublishRequestSchema, ProtocolError, ProtocolVersionNumberSchema, ProviderModelCapabilitySchema, ProviderProfileBindingSchema, ProviderProfileHashSchema, ProviderProfileRefSchema, ProviderProfileRevisionSchema, RESULT_DOCUMENT_MAX_BYTES, RequiredToolsetsSchema, RuntimeCapabilitiesSchema, RuntimeIdSchema, RuntimeInfoSchema, SERVER_TO_DAEMON_TYPES, STRICT_AGENT_ONLY_CAPABILITY, TASK_OFFER_TYPES, TASK_STATES, TASK_TRANSITIONS, TERMINAL_INFERENCE_USAGE_CLIENT_VERSION_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_MAX_DURATION_MS, TERMINAL_INFERENCE_USAGE_MAX_TOKENS, TERMINAL_INFERENCE_USAGE_MODEL_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_PROVIDER_MAX_LENGTH, TERMINAL_PROJECTION_SELECTION_CAPABILITY, TaskApprovalResolvedPayloadSchema, TaskApprovePayloadSchema, TaskArtifactPayloadSchema, TaskAwaitApprovalPayloadSchema, TaskCancelPayloadSchema, TaskCancelledPayloadSchema, TaskClaimPayloadSchema, TaskCompletePayloadSchema, TaskDeclinePayloadSchema, TaskFailPayloadSchema, TaskOfferForAgentPayloadSchema, TaskOfferForAgentWithEgressFreshPayloadSchema, TaskOfferForAgentWithEgressPayloadSchema, TaskOfferPayloadSchema, TaskOfferWithToolsetsPayloadSchema, TaskProgressPayloadSchema, TaskRejectPayloadSchema, TaskStartedPayloadSchema, TaskSteerPayloadSchema, TerminalInferenceUsageSchema, TerminalProjectionContractSchema, TerminalProjectionSelectionSchema, TokenRequestSchema, TokenResponseSchema, ToolsetIdSchema, UnknownAgentEventSchema, UnknownMessageTypeError, agentMemoryProjectionBase64UrlByteLength, byokAgentHomeProjectionCompletionPath, byokBlobContentPath, byokBlobFinalizePath, byokBlobUrlPath, byokRecordPath, byokSkillPackFilePath, canTransition, checkResultDocument, createEnvelope, decodeEnvelope, encodeEnvelope, isKnownAgentEvent, isServerToDaemonType, isTaskOfferType, parseMessage, partitionAgentEvents };
1627
+ export { AGENT_CONTENT_ARTIFACT_READ_CAPABILITY, AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY, AGENT_CONTENT_WORKSPACE_READ_CAPABILITY, AGENT_EGRESS_FRESH_SESSION_CAPABILITY, AGENT_EGRESS_POLICY_CAPABILITY, AGENT_EGRESS_RELIABLE_ACK_CAPABILITY, AGENT_EVENT_SPILL_UNSTORED_REASON_MAX_LENGTH, AGENT_HOME_PROJECTION_CAPABILITY, AGENT_HOME_PROJECTION_MAX_BYTES, AGENT_HOME_PROJECTION_PROFILE_REVISION_MAXIMUM, AGENT_INPUT_PREPARATION_CAPABILITY, AGENT_MEMORY_PROJECTION_CAPABILITY, AGENT_MEMORY_PROJECTION_MAX_ORDERING_VALUE, AGENT_MEMORY_PROJECTION_MAX_REDACTED_BYTES, AGENT_MESSAGE_EGRESS_CAPABILITY, AGENT_MESSAGE_MAX_BYTES, AGENT_REF_MAX_BYTES, AgentContentActorKindSchema, AgentContentActorSchema, AgentContentDecodeAsSchema, AgentContentMimeTypeSchema, AgentContentReadDecisionSchema, AgentContentReadDenialReasonSchema, AgentContentReadPayloadSchema, AgentContentReadSurfaceSchema, AgentContentReceiptPayloadSchema, AgentEgressAckPayloadSchema, AgentEgressActivityPolicySchema, AgentEgressContentHashSchema, AgentEgressDropReasonSchema, AgentEgressLaneSchema, AgentEgressPolicyRevisionSchema, AgentEgressPolicySchema, AgentEgressReliablePayloadSchema, AgentEventOrUnknownSchema, AgentEventSchema, AgentEventSpillSchema, AgentHomeProjectionAgentRefSchema, AgentHomeProjectionCompletionRequestSchema, AgentHomeProjectionHashSchema, AgentHomeProjectionOutcomeSchema, AgentHomeProjectionPayloadSchema, AgentHomeProjectionProfileRevisionSchema, AgentHomeProjectionReadbackSchema, AgentHomeProjectionStatusSchema, AgentHomeProjectionValueSchema, AgentInputPreparationPayloadSchema, AgentMemoryProjectionCommitRequestSchema, AgentMemoryProjectionCommitResponseSchema, AgentMemoryProjectionEraseResultSchema, AgentMemoryProjectionGrantRefSchema, AgentMemoryProjectionMeteringReceiptSchema, AgentMemoryProjectionMutationSchema, AgentMemoryProjectionReceiptSchema, AgentMemoryProjectionSessionRefSchema, AgentMemoryProjectionSnapshotSchema, AgentMemoryProjectionSourceSeqSchema, AgentMemoryProjectionWriterEpochSchema, AgentMessageContentTypeSchema, AgentMessageContractSchema, AgentMessageDestinationBindingSchema, AgentMessageDispositionPayloadSchema, AgentMessageEgressRequirementSchema, AgentMessageFreshnessCursorSchema, AgentMessagePublishPayloadSchema, AgentMessageServerContextSchema, AgentRefSchema, AgentReliableQuotaPolicySchema, BYOK_ACTIVITY_PATH, BYOK_AGENT_HOME_PROJECTIONS_PATH, BYOK_AGENT_HOME_PROJECTION_COMPLETION_ROUTE, BYOK_AGENT_MEMORY_PROJECTIONS_PATH, BYOK_BLOBS_PATH, BYOK_BLOB_CONTENT_ROUTE, BYOK_BLOB_FINALIZE_ROUTE, BYOK_BLOB_URL_ROUTE, BYOK_BOARD_CLAIM_ROUTE, BYOK_BOARD_PATH, BYOK_BOARD_STATUS_ROUTE, BYOK_BOARD_STREAM_PATH, BYOK_BOARD_UNCLAIM_ROUTE, BYOK_CAPABILITIES_PATH, BYOK_CHALLENGE_PATH, BYOK_EVENTS_PATH, BYOK_INPUT_PREPARATIONS_PATH, BYOK_INPUT_PREPARATION_COMPLETION_ROUTE, BYOK_INPUT_PREPARATION_STATUS_ROUTE, BYOK_MESSAGES_PATH, BYOK_PAIR_PATH, BYOK_PRESENCE_PATH, BYOK_RECORDS_PATH, BYOK_RECORD_ROUTE, BYOK_SKILL_PACKS_PATH, BYOK_SKILL_PACK_FILE_ROUTE, BYOK_TOKEN_PATH, BlobDownloadUrlResponseSchema, BlobRefSchema, CAPABILITY_FLAGS, CONFIGURED_TOOLSETS_MAX_ITEMS, CONTENT_HASH_RE, CUSTOM_HARNESS_CAPABILITY, ChallengeRequestSchema, ChallengeResponseSchema, ConfiguredToolsetsSchema, ConnAckPayloadSchema, ConnHelloPayloadSchema, ContentReadPolicySchema, CreateBlobRequestSchema, CreateBlobResponseSchema, DAEMON_TO_SERVER_TYPES, DispatchSelectionSchema, EnvelopeParseError, EnvelopeSchema, EnvelopeValidationError, EventsPollQuerySchema, EventsPollResponseSchema, HOST_MCP_TASK_CONTEXT_CAPABILITY, HarnessIdSchema, HarnessInfoSchema, HarnessInventorySchema, INPUT_PREPARATION_WIRE_VERSION, InputPreparationAccountingPolicyRefSchema, InputPreparationArtifactSummarySchema, InputPreparationBindingSchema, InputPreparationCompletionRequestSchema, InputPreparationContentHashSchema, InputPreparationContextDocumentSchema, InputPreparationContextFileSchema, InputPreparationCounterEvidenceSchema, InputPreparationCounterProviderEvidenceSchema, InputPreparationCounterTargetSchema, InputPreparationDocsPathsSchema, InputPreparationHostCanonicalAssistantMessageSchema, InputPreparationMessageSchema, InputPreparationModelCostSchema, InputPreparationModelSchema, InputPreparationOfferBindingSchema, InputPreparationOptionsSchema, InputPreparationPermissionModeSchema, InputPreparationPolicyRevisionSchema, InputPreparationProfileIdSchema, InputPreparationProjectionSchema, InputPreparationPromptSnapshotSchema, InputPreparationReadbackSchema, InputPreparationReadinessReasonSchema, InputPreparationReceiptSummarySchema, InputPreparationReferenceSchema, InputPreparationRejectionReasonSchema, InputPreparationResidualKeySchema, InputPreparationResidualValueClassSchema, InputPreparationRuntimeIdentitySchema, InputPreparationSelectionSchema, InputPreparationSkillSchema, InputPreparationSourceSchema, InputPreparationStateSchema, InputPreparationStatusQuerySchema, InputPreparationStatusSchema, InputPreparationToolImplementationKindSchema, InputPreparationUserMessageSchema, KNOWN_AGENT_EVENT_TYPES, MAILBOX_READ_AHEAD_CAPABILITY, MAILBOX_READ_AHEAD_MAX_SEQS, MAX_MESSAGES_PER_BATCH, MESSAGE_PAYLOAD_SCHEMAS, MESSAGE_TYPES, MessagesSendRequestSchema, MessagesSendResponseSchema, PAIR_RESPONSE_TENANT_ID_MAX_LENGTH, PERMISSION_MODES, PROTOCOL_VERSION, PROVIDER_MODEL_CAPABILITIES, PROVIDER_PROFILE_BINDING_CAPABILITY, PairRequestSchema, PairResponseSchema, PairResponseTenantIdSchema, PermissionPolicySchema, PresencePublishRequestSchema, ProtocolError, ProtocolVersionNumberSchema, ProviderModelCapabilitySchema, ProviderProfileBindingSchema, ProviderProfileHashSchema, ProviderProfileRefSchema, ProviderProfileRevisionSchema, RESULT_DOCUMENT_MAX_BYTES, RequiredToolsetsSchema, RuntimeCapabilitiesSchema, RuntimeIdSchema, RuntimeInfoSchema, SERVER_TO_DAEMON_TYPES, STRICT_AGENT_ONLY_CAPABILITY, TASK_OFFER_TYPES, TASK_STATES, TASK_TRANSITIONS, TERMINAL_INFERENCE_USAGE_CLIENT_VERSION_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_MAX_DURATION_MS, TERMINAL_INFERENCE_USAGE_MAX_TOKENS, TERMINAL_INFERENCE_USAGE_MODEL_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_PROVIDER_MAX_LENGTH, TERMINAL_PROJECTION_SELECTION_CAPABILITY, TaskApprovalResolvedPayloadSchema, TaskApprovePayloadSchema, TaskArtifactPayloadSchema, TaskAwaitApprovalPayloadSchema, TaskCancelPayloadSchema, TaskCancelledPayloadSchema, TaskClaimPayloadSchema, TaskCompletePayloadSchema, TaskDeclinePayloadSchema, TaskFailPayloadSchema, TaskOfferForAgentPayloadSchema, TaskOfferForAgentWithEgressFreshPayloadSchema, TaskOfferForAgentWithEgressPayloadSchema, TaskOfferPayloadSchema, TaskOfferPreparedPayloadSchema, TaskOfferWithToolsetsPayloadSchema, TaskProgressPayloadSchema, TaskRejectPayloadSchema, TaskStartedPayloadSchema, TaskSteerPayloadSchema, TerminalInferenceUsageSchema, TerminalPreparedObservationSchema, TerminalProjectionContractSchema, TerminalProjectionSelectionSchema, TokenRequestSchema, TokenResponseSchema, ToolsetIdSchema, UnknownAgentEventSchema, UnknownMessageTypeError, agentMemoryProjectionBase64UrlByteLength, byokAgentHomeProjectionCompletionPath, byokBlobContentPath, byokBlobFinalizePath, byokBlobUrlPath, byokInputPreparationCompletionPath, byokInputPreparationStatusPath, byokRecordPath, byokSkillPackFilePath, canTransition, checkResultDocument, createEnvelope, decodeEnvelope, encodeEnvelope, isKnownAgentEvent, isServerToDaemonType, isTaskOfferType, parseMessage, partitionAgentEvents };
1172
1628
  //# sourceMappingURL=index.js.map
1173
1629
  //# sourceMappingURL=index.js.map