happy-imou-cloud 2.1.0 → 2.1.1

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.
Files changed (47) hide show
  1. package/bin/happy-cloud.mjs +21 -17
  2. package/compat/acp-sdk-schema/index.js +28 -0
  3. package/compat/acp-sdk-schema/types.gen.js +3 -0
  4. package/compat/acp-sdk-schema/zod.gen.js +1554 -0
  5. package/compat/ink-build/components/Cursor.d.ts +83 -0
  6. package/compat/ink-build/components/Cursor.js +53 -0
  7. package/compat/ink-build/components/CursorContext.d.ts +11 -0
  8. package/compat/ink-build/components/CursorContext.js +8 -0
  9. package/compat/ink-build/components/ErrorBoundary.d.ts +18 -0
  10. package/compat/ink-build/components/ErrorBoundary.js +23 -0
  11. package/compat/ink-build/hooks/use-cursor.d.ts +12 -0
  12. package/compat/ink-build/hooks/use-cursor.js +29 -0
  13. package/dist/{BaseReasoningProcessor-C9mH8EVn.cjs → BaseReasoningProcessor-CBMK-8Gi.cjs} +3 -3
  14. package/dist/{BaseReasoningProcessor-DQkzwRuf.mjs → BaseReasoningProcessor-Dn9FxfxU.mjs} +3 -3
  15. package/dist/ProviderSelectionHandler-BuXk-8ji.cjs +680 -0
  16. package/dist/ProviderSelectionHandler-CMaQThYO.mjs +673 -0
  17. package/dist/{api-w_CUxb9Q.mjs → api-DBy5lPZw.mjs} +5 -4
  18. package/dist/{api-Bd-MnOS4.cjs → api-DId_j3C2.cjs} +4 -3
  19. package/dist/{command-mTWwCqTY.mjs → command-CeaBwYCW.mjs} +3 -3
  20. package/dist/{command-DoDmHNxR.cjs → command-DwfUpmId.cjs} +3 -3
  21. package/dist/{index-GuXV-pxB.mjs → index-66vjECEd.mjs} +72 -165
  22. package/dist/{index-BQmJ4NAa.cjs → index-CuuYSKiv.cjs} +75 -168
  23. package/dist/index.cjs +3 -3
  24. package/dist/index.mjs +3 -3
  25. package/dist/lib.cjs +1 -1
  26. package/dist/lib.d.cts +52 -51
  27. package/dist/lib.d.mts +52 -51
  28. package/dist/lib.mjs +1 -1
  29. package/dist/{persistence-MSy70is3.mjs → persistence-BOWh1NER.mjs} +1 -1
  30. package/dist/{persistence-BL06LLVz.cjs → persistence-Dzr6sFwD.cjs} +1 -1
  31. package/dist/{registerKillSessionHandler-CjWfUfc3.mjs → registerKillSessionHandler-D4_wpN18.mjs} +5 -417
  32. package/dist/{registerKillSessionHandler-D9kwxy6B.cjs → registerKillSessionHandler-Dg_iRBPm.cjs} +4 -419
  33. package/dist/{runClaude-DpZ95Twb.mjs → runClaude-B74dHAnQ.mjs} +5 -5
  34. package/dist/{runClaude-D2ZEXue8.cjs → runClaude-oIFzkfuU.cjs} +8 -8
  35. package/dist/{runCodex-Dz_1ho8d.cjs → runCodex-D_9CuL6M.cjs} +9 -9
  36. package/dist/{runCodex-CJwaep2R.mjs → runCodex-mLHjsgVj.mjs} +6 -6
  37. package/dist/{runGemini-BehqjM73.mjs → runGemini-BMiho2ab.mjs} +70 -189
  38. package/dist/{runGemini-Dfu6LltX.cjs → runGemini-CcWGezMt.cjs} +70 -189
  39. package/package.json +9 -8
  40. package/scripts/build.mjs +68 -66
  41. package/scripts/devtools/README.md +9 -9
  42. package/scripts/e2e/fake-codex-acp-agent.mjs +139 -139
  43. package/scripts/e2e/local-server-session-roundtrip.mjs +1063 -1063
  44. package/scripts/ensureAcpSdkCompat.mjs +173 -0
  45. package/scripts/release-smoke.mjs +35 -24
  46. package/dist/ProviderSelectionHandler-5Dedbm8j.cjs +0 -265
  47. package/dist/ProviderSelectionHandler-BlrrLPlo.mjs +0 -261
@@ -0,0 +1,1554 @@
1
+ // This file is auto-generated by @hey-api/openapi-ts
2
+ import { z } from "zod/v4";
3
+ /**
4
+ * Describes an available authentication method.
5
+ */
6
+ export const zAuthMethod = z.object({
7
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
8
+ description: z.union([z.string(), z.null()]).optional(),
9
+ id: z.string(),
10
+ name: z.string(),
11
+ });
12
+ /**
13
+ * Request parameters for the authenticate method.
14
+ *
15
+ * Specifies which authentication method to use.
16
+ */
17
+ export const zAuthenticateRequest = z.object({
18
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
19
+ methodId: z.string(),
20
+ });
21
+ /**
22
+ * Response to the `authenticate` method.
23
+ */
24
+ export const zAuthenticateResponse = z.object({
25
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
26
+ });
27
+ /**
28
+ * Binary resource contents.
29
+ */
30
+ export const zBlobResourceContents = z.object({
31
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
32
+ blob: z.string(),
33
+ mimeType: z.union([z.string(), z.null()]).optional(),
34
+ uri: z.string(),
35
+ });
36
+ /**
37
+ * **UNSTABLE**
38
+ *
39
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
40
+ *
41
+ * Cost information for a session.
42
+ *
43
+ * @experimental
44
+ */
45
+ export const zCost = z.object({
46
+ amount: z.number(),
47
+ currency: z.string(),
48
+ });
49
+ /**
50
+ * Response containing the ID of the created terminal.
51
+ */
52
+ export const zCreateTerminalResponse = z.object({
53
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
54
+ terminalId: z.string(),
55
+ });
56
+ /**
57
+ * A diff representing file modifications.
58
+ *
59
+ * Shows changes to files in a format suitable for display in the client UI.
60
+ *
61
+ * See protocol docs: [Content](https://agentclientprotocol.com/protocol/tool-calls#content)
62
+ */
63
+ export const zDiff = z.object({
64
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
65
+ newText: z.string(),
66
+ oldText: z.union([z.string(), z.null()]).optional(),
67
+ path: z.string(),
68
+ });
69
+ /**
70
+ * An environment variable to set when launching an MCP server.
71
+ */
72
+ export const zEnvVariable = z.object({
73
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
74
+ name: z.string(),
75
+ value: z.string(),
76
+ });
77
+ /**
78
+ * Predefined error codes for common JSON-RPC and ACP-specific errors.
79
+ *
80
+ * These codes follow the JSON-RPC 2.0 specification for standard errors
81
+ * and use the reserved range (-32000 to -32099) for protocol-specific errors.
82
+ */
83
+ export const zErrorCode = z.union([
84
+ z.literal(-32700),
85
+ z.literal(-32600),
86
+ z.literal(-32601),
87
+ z.literal(-32602),
88
+ z.literal(-32603),
89
+ z.literal(-32800),
90
+ z.literal(-32000),
91
+ z.literal(-32002),
92
+ z
93
+ .number()
94
+ .int()
95
+ .min(-2147483648, {
96
+ message: "Invalid value: Expected int32 to be >= -2147483648",
97
+ })
98
+ .max(2147483647, {
99
+ message: "Invalid value: Expected int32 to be <= 2147483647",
100
+ }),
101
+ ]);
102
+ /**
103
+ * JSON-RPC error object.
104
+ *
105
+ * Represents an error that occurred during method execution, following the
106
+ * JSON-RPC 2.0 error object specification with optional additional data.
107
+ *
108
+ * See protocol docs: [JSON-RPC Error Object](https://www.jsonrpc.org/specification#error_object)
109
+ */
110
+ export const zError = z.object({
111
+ code: zErrorCode,
112
+ data: z.unknown().optional(),
113
+ message: z.string(),
114
+ });
115
+ /**
116
+ * Allows the Agent to send an arbitrary notification that is not part of the ACP spec.
117
+ * Extension notifications provide a way to send one-way messages for custom functionality
118
+ * while maintaining protocol compatibility.
119
+ *
120
+ * See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
121
+ */
122
+ export const zExtNotification = z.unknown();
123
+ /**
124
+ * Allows for sending an arbitrary request that is not part of the ACP spec.
125
+ * Extension methods provide a way to add custom functionality while maintaining
126
+ * protocol compatibility.
127
+ *
128
+ * See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
129
+ */
130
+ export const zExtRequest = z.unknown();
131
+ /**
132
+ * Allows for sending an arbitrary response to an [`ExtRequest`] that is not part of the ACP spec.
133
+ * Extension methods provide a way to add custom functionality while maintaining
134
+ * protocol compatibility.
135
+ *
136
+ * See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
137
+ */
138
+ export const zExtResponse = z.unknown();
139
+ /**
140
+ * Filesystem capabilities supported by the client.
141
+ * File system capabilities that a client may support.
142
+ *
143
+ * See protocol docs: [FileSystem](https://agentclientprotocol.com/protocol/initialization#filesystem)
144
+ */
145
+ export const zFileSystemCapability = z.object({
146
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
147
+ readTextFile: z.boolean().optional().default(false),
148
+ writeTextFile: z.boolean().optional().default(false),
149
+ });
150
+ /**
151
+ * Capabilities supported by the client.
152
+ *
153
+ * Advertised during initialization to inform the agent about
154
+ * available features and methods.
155
+ *
156
+ * See protocol docs: [Client Capabilities](https://agentclientprotocol.com/protocol/initialization#client-capabilities)
157
+ */
158
+ export const zClientCapabilities = z.object({
159
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
160
+ fs: zFileSystemCapability
161
+ .optional()
162
+ .default({ readTextFile: false, writeTextFile: false }),
163
+ terminal: z.boolean().optional().default(false),
164
+ });
165
+ /**
166
+ * An HTTP header to set when making requests to the MCP server.
167
+ */
168
+ export const zHttpHeader = z.object({
169
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
170
+ name: z.string(),
171
+ value: z.string(),
172
+ });
173
+ /**
174
+ * Metadata about the implementation of the client or agent.
175
+ * Describes the name and version of an MCP implementation, with an optional
176
+ * title for UI representation.
177
+ */
178
+ export const zImplementation = z.object({
179
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
180
+ name: z.string(),
181
+ title: z.union([z.string(), z.null()]).optional(),
182
+ version: z.string(),
183
+ });
184
+ /**
185
+ * Response to terminal/kill command method
186
+ */
187
+ export const zKillTerminalCommandResponse = z.object({
188
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
189
+ });
190
+ /**
191
+ * **UNSTABLE**
192
+ *
193
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
194
+ *
195
+ * Request parameters for listing existing sessions.
196
+ *
197
+ * Only available if the Agent supports the `listSessions` capability.
198
+ *
199
+ * @experimental
200
+ */
201
+ export const zListSessionsRequest = z.object({
202
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
203
+ cursor: z.union([z.string(), z.null()]).optional(),
204
+ cwd: z.union([z.string(), z.null()]).optional(),
205
+ });
206
+ /**
207
+ * MCP capabilities supported by the agent
208
+ */
209
+ export const zMcpCapabilities = z.object({
210
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
211
+ http: z.boolean().optional().default(false),
212
+ sse: z.boolean().optional().default(false),
213
+ });
214
+ /**
215
+ * HTTP transport configuration for MCP.
216
+ */
217
+ export const zMcpServerHttp = z.object({
218
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
219
+ headers: z.array(zHttpHeader),
220
+ name: z.string(),
221
+ url: z.string(),
222
+ });
223
+ /**
224
+ * SSE transport configuration for MCP.
225
+ */
226
+ export const zMcpServerSse = z.object({
227
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
228
+ headers: z.array(zHttpHeader),
229
+ name: z.string(),
230
+ url: z.string(),
231
+ });
232
+ /**
233
+ * Stdio transport configuration for MCP.
234
+ */
235
+ export const zMcpServerStdio = z.object({
236
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
237
+ args: z.array(z.string()),
238
+ command: z.string(),
239
+ env: z.array(zEnvVariable),
240
+ name: z.string(),
241
+ });
242
+ /**
243
+ * Configuration for connecting to an MCP (Model Context Protocol) server.
244
+ *
245
+ * MCP servers provide tools and context that the agent can use when
246
+ * processing prompts.
247
+ *
248
+ * See protocol docs: [MCP Servers](https://agentclientprotocol.com/protocol/session-setup#mcp-servers)
249
+ */
250
+ export const zMcpServer = z.union([
251
+ zMcpServerHttp.and(z.object({
252
+ type: z.literal("http"),
253
+ })),
254
+ zMcpServerSse.and(z.object({
255
+ type: z.literal("sse"),
256
+ })),
257
+ zMcpServerStdio,
258
+ ]);
259
+ /**
260
+ * **UNSTABLE**
261
+ *
262
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
263
+ *
264
+ * A unique identifier for a model.
265
+ *
266
+ * @experimental
267
+ */
268
+ export const zModelId = z.string();
269
+ /**
270
+ * **UNSTABLE**
271
+ *
272
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
273
+ *
274
+ * Information about a selectable model.
275
+ *
276
+ * @experimental
277
+ */
278
+ export const zModelInfo = z.object({
279
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
280
+ description: z.union([z.string(), z.null()]).optional(),
281
+ modelId: zModelId,
282
+ name: z.string(),
283
+ });
284
+ /**
285
+ * Request parameters for creating a new session.
286
+ *
287
+ * See protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol/session-setup#creating-a-session)
288
+ */
289
+ export const zNewSessionRequest = z.object({
290
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
291
+ cwd: z.string(),
292
+ mcpServers: z.array(zMcpServer),
293
+ });
294
+ /**
295
+ * Unique identifier for a permission option.
296
+ */
297
+ export const zPermissionOptionId = z.string();
298
+ /**
299
+ * The type of permission option being presented to the user.
300
+ *
301
+ * Helps clients choose appropriate icons and UI treatment.
302
+ */
303
+ export const zPermissionOptionKind = z.union([
304
+ z.literal("allow_once"),
305
+ z.literal("allow_always"),
306
+ z.literal("reject_once"),
307
+ z.literal("reject_always"),
308
+ ]);
309
+ /**
310
+ * An option presented to the user when requesting permission.
311
+ */
312
+ export const zPermissionOption = z.object({
313
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
314
+ kind: zPermissionOptionKind,
315
+ name: z.string(),
316
+ optionId: zPermissionOptionId,
317
+ });
318
+ /**
319
+ * Priority levels for plan entries.
320
+ *
321
+ * Used to indicate the relative importance or urgency of different
322
+ * tasks in the execution plan.
323
+ * See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries)
324
+ */
325
+ export const zPlanEntryPriority = z.union([
326
+ z.literal("high"),
327
+ z.literal("medium"),
328
+ z.literal("low"),
329
+ ]);
330
+ /**
331
+ * Status of a plan entry in the execution flow.
332
+ *
333
+ * Tracks the lifecycle of each task from planning through completion.
334
+ * See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries)
335
+ */
336
+ export const zPlanEntryStatus = z.union([
337
+ z.literal("pending"),
338
+ z.literal("in_progress"),
339
+ z.literal("completed"),
340
+ ]);
341
+ /**
342
+ * A single entry in the execution plan.
343
+ *
344
+ * Represents a task or goal that the assistant intends to accomplish
345
+ * as part of fulfilling the user's request.
346
+ * See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries)
347
+ */
348
+ export const zPlanEntry = z.object({
349
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
350
+ content: z.string(),
351
+ priority: zPlanEntryPriority,
352
+ status: zPlanEntryStatus,
353
+ });
354
+ /**
355
+ * An execution plan for accomplishing complex tasks.
356
+ *
357
+ * Plans consist of multiple entries representing individual tasks or goals.
358
+ * Agents report plans to clients to provide visibility into their execution strategy.
359
+ * Plans can evolve during execution as the agent discovers new requirements or completes tasks.
360
+ *
361
+ * See protocol docs: [Agent Plan](https://agentclientprotocol.com/protocol/agent-plan)
362
+ */
363
+ export const zPlan = z.object({
364
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
365
+ entries: z.array(zPlanEntry),
366
+ });
367
+ /**
368
+ * Prompt capabilities supported by the agent in `session/prompt` requests.
369
+ *
370
+ * Baseline agent functionality requires support for [`ContentBlock::Text`]
371
+ * and [`ContentBlock::ResourceLink`] in prompt requests.
372
+ *
373
+ * Other variants must be explicitly opted in to.
374
+ * Capabilities for different types of content in prompt requests.
375
+ *
376
+ * Indicates which content types beyond the baseline (text and resource links)
377
+ * the agent can process.
378
+ *
379
+ * See protocol docs: [Prompt Capabilities](https://agentclientprotocol.com/protocol/initialization#prompt-capabilities)
380
+ */
381
+ export const zPromptCapabilities = z.object({
382
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
383
+ audio: z.boolean().optional().default(false),
384
+ embeddedContext: z.boolean().optional().default(false),
385
+ image: z.boolean().optional().default(false),
386
+ });
387
+ /**
388
+ * Protocol version identifier.
389
+ *
390
+ * This version is only bumped for breaking changes.
391
+ * Non-breaking changes should be introduced via capabilities.
392
+ */
393
+ export const zProtocolVersion = z.number().int().gte(0).lte(65535);
394
+ /**
395
+ * Request parameters for the initialize method.
396
+ *
397
+ * Sent by the client to establish connection and negotiate capabilities.
398
+ *
399
+ * See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)
400
+ */
401
+ export const zInitializeRequest = z.object({
402
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
403
+ clientCapabilities: zClientCapabilities.optional().default({
404
+ fs: { readTextFile: false, writeTextFile: false },
405
+ terminal: false,
406
+ }),
407
+ clientInfo: z.union([zImplementation, z.null()]).optional(),
408
+ protocolVersion: zProtocolVersion,
409
+ });
410
+ /**
411
+ * Response containing the contents of a text file.
412
+ */
413
+ export const zReadTextFileResponse = z.object({
414
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
415
+ content: z.string(),
416
+ });
417
+ /**
418
+ * Response to terminal/release method
419
+ */
420
+ export const zReleaseTerminalResponse = z.object({
421
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
422
+ });
423
+ /**
424
+ * JSON RPC Request Id
425
+ *
426
+ * An identifier established by the Client that MUST contain a String, Number, or NULL value if included. If it is not included it is assumed to be a notification. The value SHOULD normally not be Null [1] and Numbers SHOULD NOT contain fractional parts [2]
427
+ *
428
+ * The Server MUST reply with the same value in the Response object if included. This member is used to correlate the context between the two objects.
429
+ *
430
+ * [1] The use of Null as a value for the id member in a Request object is discouraged, because this specification uses a value of Null for Responses with an unknown id. Also, because JSON-RPC 1.0 uses an id value of Null for Notifications this could cause confusion in handling.
431
+ *
432
+ * [2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions.
433
+ */
434
+ export const zRequestId = z.union([z.null(), z.number(), z.string()]);
435
+ /**
436
+ * **UNSTABLE**
437
+ *
438
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
439
+ *
440
+ * Notification to cancel an ongoing request.
441
+ *
442
+ * See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/cancellation)
443
+ *
444
+ * @experimental
445
+ */
446
+ export const zCancelRequestNotification = z.object({
447
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
448
+ requestId: zRequestId,
449
+ });
450
+ /**
451
+ * The sender or recipient of messages and data in a conversation.
452
+ */
453
+ export const zRole = z.enum(["assistant", "user"]);
454
+ /**
455
+ * Optional annotations for the client. The client can use annotations to inform how objects are used or displayed
456
+ */
457
+ export const zAnnotations = z.object({
458
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
459
+ audience: z.union([z.array(zRole), z.null()]).optional(),
460
+ lastModified: z.union([z.string(), z.null()]).optional(),
461
+ priority: z.union([z.number(), z.null()]).optional(),
462
+ });
463
+ /**
464
+ * Audio provided to or from an LLM.
465
+ */
466
+ export const zAudioContent = z.object({
467
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
468
+ annotations: z.union([zAnnotations, z.null()]).optional(),
469
+ data: z.string(),
470
+ mimeType: z.string(),
471
+ });
472
+ /**
473
+ * An image provided to or from an LLM.
474
+ */
475
+ export const zImageContent = z.object({
476
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
477
+ annotations: z.union([zAnnotations, z.null()]).optional(),
478
+ data: z.string(),
479
+ mimeType: z.string(),
480
+ uri: z.union([z.string(), z.null()]).optional(),
481
+ });
482
+ /**
483
+ * A resource that the server is capable of reading, included in a prompt or tool call result.
484
+ */
485
+ export const zResourceLink = z.object({
486
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
487
+ annotations: z.union([zAnnotations, z.null()]).optional(),
488
+ description: z.union([z.string(), z.null()]).optional(),
489
+ mimeType: z.union([z.string(), z.null()]).optional(),
490
+ name: z.string(),
491
+ size: z.union([z.number(), z.null()]).optional(),
492
+ title: z.union([z.string(), z.null()]).optional(),
493
+ uri: z.string(),
494
+ });
495
+ /**
496
+ * The user selected one of the provided options.
497
+ */
498
+ export const zSelectedPermissionOutcome = z.object({
499
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
500
+ optionId: zPermissionOptionId,
501
+ });
502
+ /**
503
+ * The outcome of a permission request.
504
+ */
505
+ export const zRequestPermissionOutcome = z.union([
506
+ z.object({
507
+ outcome: z.literal("cancelled"),
508
+ }),
509
+ zSelectedPermissionOutcome.and(z.object({
510
+ outcome: z.literal("selected"),
511
+ })),
512
+ ]);
513
+ /**
514
+ * Response to a permission request.
515
+ */
516
+ export const zRequestPermissionResponse = z.object({
517
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
518
+ outcome: zRequestPermissionOutcome,
519
+ });
520
+ /**
521
+ * Unique identifier for a session configuration option value group.
522
+ */
523
+ export const zSessionConfigGroupId = z.string();
524
+ /**
525
+ * Unique identifier for a session configuration option.
526
+ */
527
+ export const zSessionConfigId = z.string();
528
+ /**
529
+ * Semantic category for a session configuration option.
530
+ *
531
+ * This is intended to help Clients distinguish broadly common selectors (e.g. model selector vs
532
+ * session mode selector vs thought/reasoning level) for UX purposes (keyboard shortcuts, icons,
533
+ * placement). It MUST NOT be required for correctness. Clients MUST handle missing or unknown
534
+ * categories gracefully.
535
+ *
536
+ * Category names beginning with `_` are free for custom use, like other ACP extension methods.
537
+ * Category names that do not begin with `_` are reserved for the ACP spec.
538
+ */
539
+ export const zSessionConfigOptionCategory = z.union([
540
+ z.literal("mode"),
541
+ z.literal("model"),
542
+ z.literal("thought_level"),
543
+ z.string(),
544
+ ]);
545
+ /**
546
+ * Unique identifier for a session configuration option value.
547
+ */
548
+ export const zSessionConfigValueId = z.string();
549
+ /**
550
+ * A possible value for a session configuration option.
551
+ */
552
+ export const zSessionConfigSelectOption = z.object({
553
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
554
+ description: z.union([z.string(), z.null()]).optional(),
555
+ name: z.string(),
556
+ value: zSessionConfigValueId,
557
+ });
558
+ /**
559
+ * A group of possible values for a session configuration option.
560
+ */
561
+ export const zSessionConfigSelectGroup = z.object({
562
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
563
+ group: zSessionConfigGroupId,
564
+ name: z.string(),
565
+ options: z.array(zSessionConfigSelectOption),
566
+ });
567
+ /**
568
+ * Possible values for a session configuration option.
569
+ */
570
+ export const zSessionConfigSelectOptions = z.union([
571
+ z.array(zSessionConfigSelectOption),
572
+ z.array(zSessionConfigSelectGroup),
573
+ ]);
574
+ /**
575
+ * A single-value selector (dropdown) session configuration option payload.
576
+ */
577
+ export const zSessionConfigSelect = z.object({
578
+ currentValue: zSessionConfigValueId,
579
+ options: zSessionConfigSelectOptions,
580
+ });
581
+ export const zSessionConfigOption = zSessionConfigSelect
582
+ .and(z.object({
583
+ type: z.literal("select"),
584
+ }))
585
+ .and(z.object({
586
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
587
+ category: z.union([zSessionConfigOptionCategory, z.null()]).optional(),
588
+ description: z.union([z.string(), z.null()]).optional(),
589
+ id: zSessionConfigId,
590
+ name: z.string(),
591
+ }));
592
+ /**
593
+ * Session configuration options have been updated.
594
+ */
595
+ export const zConfigOptionUpdate = z.object({
596
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
597
+ configOptions: z.array(zSessionConfigOption),
598
+ });
599
+ /**
600
+ * **UNSTABLE**
601
+ *
602
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
603
+ *
604
+ * Capabilities for the `session/fork` method.
605
+ *
606
+ * By supplying `{}` it means that the agent supports forking of sessions.
607
+ *
608
+ * @experimental
609
+ */
610
+ export const zSessionForkCapabilities = z.object({
611
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
612
+ });
613
+ /**
614
+ * A unique identifier for a conversation session between a client and agent.
615
+ *
616
+ * Sessions maintain their own context, conversation history, and state,
617
+ * allowing multiple independent interactions with the same agent.
618
+ *
619
+ * See protocol docs: [Session ID](https://agentclientprotocol.com/protocol/session-setup#session-id)
620
+ */
621
+ export const zSessionId = z.string();
622
+ /**
623
+ * Notification to cancel ongoing operations for a session.
624
+ *
625
+ * See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/prompt-turn#cancellation)
626
+ */
627
+ export const zCancelNotification = z.object({
628
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
629
+ sessionId: zSessionId,
630
+ });
631
+ export const zClientNotification = z.object({
632
+ method: z.string(),
633
+ params: z
634
+ .union([z.union([zCancelNotification, zExtNotification]), z.null()])
635
+ .optional(),
636
+ });
637
+ /**
638
+ * Request to create a new terminal and execute a command.
639
+ */
640
+ export const zCreateTerminalRequest = z.object({
641
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
642
+ args: z.array(z.string()).optional(),
643
+ command: z.string(),
644
+ cwd: z.union([z.string(), z.null()]).optional(),
645
+ env: z.array(zEnvVariable).optional(),
646
+ outputByteLimit: z.union([z.number(), z.null()]).optional(),
647
+ sessionId: zSessionId,
648
+ });
649
+ /**
650
+ * **UNSTABLE**
651
+ *
652
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
653
+ *
654
+ * Request parameters for forking an existing session.
655
+ *
656
+ * Creates a new session based on the context of an existing one, allowing
657
+ * operations like generating summaries without affecting the original session's history.
658
+ *
659
+ * Only available if the Agent supports the `session.fork` capability.
660
+ *
661
+ * @experimental
662
+ */
663
+ export const zForkSessionRequest = z.object({
664
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
665
+ cwd: z.string(),
666
+ mcpServers: z.array(zMcpServer).optional(),
667
+ sessionId: zSessionId,
668
+ });
669
+ /**
670
+ * Request to kill a terminal command without releasing the terminal.
671
+ */
672
+ export const zKillTerminalCommandRequest = z.object({
673
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
674
+ sessionId: zSessionId,
675
+ terminalId: z.string(),
676
+ });
677
+ /**
678
+ * Request parameters for loading an existing session.
679
+ *
680
+ * Only available if the Agent supports the `loadSession` capability.
681
+ *
682
+ * See protocol docs: [Loading Sessions](https://agentclientprotocol.com/protocol/session-setup#loading-sessions)
683
+ */
684
+ export const zLoadSessionRequest = z.object({
685
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
686
+ cwd: z.string(),
687
+ mcpServers: z.array(zMcpServer),
688
+ sessionId: zSessionId,
689
+ });
690
+ /**
691
+ * Request to read content from a text file.
692
+ *
693
+ * Only available if the client supports the `fs.readTextFile` capability.
694
+ */
695
+ export const zReadTextFileRequest = z.object({
696
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
697
+ limit: z
698
+ .union([
699
+ z.number().int().gte(0).max(4294967295, {
700
+ message: "Invalid value: Expected uint32 to be <= 4294967295",
701
+ }),
702
+ z.null(),
703
+ ])
704
+ .optional(),
705
+ line: z
706
+ .union([
707
+ z.number().int().gte(0).max(4294967295, {
708
+ message: "Invalid value: Expected uint32 to be <= 4294967295",
709
+ }),
710
+ z.null(),
711
+ ])
712
+ .optional(),
713
+ path: z.string(),
714
+ sessionId: zSessionId,
715
+ });
716
+ /**
717
+ * Request to release a terminal and free its resources.
718
+ */
719
+ export const zReleaseTerminalRequest = z.object({
720
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
721
+ sessionId: zSessionId,
722
+ terminalId: z.string(),
723
+ });
724
+ /**
725
+ * **UNSTABLE**
726
+ *
727
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
728
+ *
729
+ * Request parameters for resuming an existing session.
730
+ *
731
+ * Resumes an existing session without returning previous messages (unlike `session/load`).
732
+ * This is useful for agents that can resume sessions but don't implement full session loading.
733
+ *
734
+ * Only available if the Agent supports the `session.resume` capability.
735
+ *
736
+ * @experimental
737
+ */
738
+ export const zResumeSessionRequest = z.object({
739
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
740
+ cwd: z.string(),
741
+ mcpServers: z.array(zMcpServer).optional(),
742
+ sessionId: zSessionId,
743
+ });
744
+ /**
745
+ * **UNSTABLE**
746
+ *
747
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
748
+ *
749
+ * Information about a session returned by session/list
750
+ *
751
+ * @experimental
752
+ */
753
+ export const zSessionInfo = z.object({
754
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
755
+ cwd: z.string(),
756
+ sessionId: zSessionId,
757
+ title: z.union([z.string(), z.null()]).optional(),
758
+ updatedAt: z.union([z.string(), z.null()]).optional(),
759
+ });
760
+ /**
761
+ * **UNSTABLE**
762
+ *
763
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
764
+ *
765
+ * Response from listing sessions.
766
+ *
767
+ * @experimental
768
+ */
769
+ export const zListSessionsResponse = z.object({
770
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
771
+ nextCursor: z.union([z.string(), z.null()]).optional(),
772
+ sessions: z.array(zSessionInfo),
773
+ });
774
+ /**
775
+ * Update to session metadata. All fields are optional to support partial updates.
776
+ *
777
+ * Agents send this notification to update session information like title or custom metadata.
778
+ * This allows clients to display dynamic session names and track session state changes.
779
+ */
780
+ export const zSessionInfoUpdate = z.object({
781
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
782
+ title: z.union([z.string(), z.null()]).optional(),
783
+ updatedAt: z.union([z.string(), z.null()]).optional(),
784
+ });
785
+ /**
786
+ * Capabilities for the `session/list` method.
787
+ *
788
+ * By supplying `{}` it means that the agent supports listing of sessions.
789
+ *
790
+ * Further capabilities can be added in the future for other means of filtering or searching the list.
791
+ */
792
+ export const zSessionListCapabilities = z.object({
793
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
794
+ });
795
+ /**
796
+ * Unique identifier for a Session Mode.
797
+ */
798
+ export const zSessionModeId = z.string();
799
+ /**
800
+ * The current mode of the session has changed
801
+ *
802
+ * See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)
803
+ */
804
+ export const zCurrentModeUpdate = z.object({
805
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
806
+ currentModeId: zSessionModeId,
807
+ });
808
+ /**
809
+ * A mode the agent can operate in.
810
+ *
811
+ * See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)
812
+ */
813
+ export const zSessionMode = z.object({
814
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
815
+ description: z.union([z.string(), z.null()]).optional(),
816
+ id: zSessionModeId,
817
+ name: z.string(),
818
+ });
819
+ /**
820
+ * The set of modes and the one currently active.
821
+ */
822
+ export const zSessionModeState = z.object({
823
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
824
+ availableModes: z.array(zSessionMode),
825
+ currentModeId: zSessionModeId,
826
+ });
827
+ /**
828
+ * **UNSTABLE**
829
+ *
830
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
831
+ *
832
+ * The set of models and the one currently active.
833
+ *
834
+ * @experimental
835
+ */
836
+ export const zSessionModelState = z.object({
837
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
838
+ availableModels: z.array(zModelInfo),
839
+ currentModelId: zModelId,
840
+ });
841
+ /**
842
+ * **UNSTABLE**
843
+ *
844
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
845
+ *
846
+ * Response from forking an existing session.
847
+ *
848
+ * @experimental
849
+ */
850
+ export const zForkSessionResponse = z.object({
851
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
852
+ configOptions: z.union([z.array(zSessionConfigOption), z.null()]).optional(),
853
+ models: z.union([zSessionModelState, z.null()]).optional(),
854
+ modes: z.union([zSessionModeState, z.null()]).optional(),
855
+ sessionId: zSessionId,
856
+ });
857
+ /**
858
+ * Response from loading an existing session.
859
+ */
860
+ export const zLoadSessionResponse = z.object({
861
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
862
+ configOptions: z.union([z.array(zSessionConfigOption), z.null()]).optional(),
863
+ models: z.union([zSessionModelState, z.null()]).optional(),
864
+ modes: z.union([zSessionModeState, z.null()]).optional(),
865
+ });
866
+ /**
867
+ * Response from creating a new session.
868
+ *
869
+ * See protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol/session-setup#creating-a-session)
870
+ */
871
+ export const zNewSessionResponse = z.object({
872
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
873
+ configOptions: z.union([z.array(zSessionConfigOption), z.null()]).optional(),
874
+ models: z.union([zSessionModelState, z.null()]).optional(),
875
+ modes: z.union([zSessionModeState, z.null()]).optional(),
876
+ sessionId: zSessionId,
877
+ });
878
+ /**
879
+ * **UNSTABLE**
880
+ *
881
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
882
+ *
883
+ * Response from resuming an existing session.
884
+ *
885
+ * @experimental
886
+ */
887
+ export const zResumeSessionResponse = z.object({
888
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
889
+ configOptions: z.union([z.array(zSessionConfigOption), z.null()]).optional(),
890
+ models: z.union([zSessionModelState, z.null()]).optional(),
891
+ modes: z.union([zSessionModeState, z.null()]).optional(),
892
+ });
893
+ /**
894
+ * **UNSTABLE**
895
+ *
896
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
897
+ *
898
+ * Capabilities for the `session/resume` method.
899
+ *
900
+ * By supplying `{}` it means that the agent supports resuming of sessions.
901
+ *
902
+ * @experimental
903
+ */
904
+ export const zSessionResumeCapabilities = z.object({
905
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
906
+ });
907
+ /**
908
+ * Session capabilities supported by the agent.
909
+ *
910
+ * As a baseline, all Agents **MUST** support `session/new`, `session/prompt`, `session/cancel`, and `session/update`.
911
+ *
912
+ * Optionally, they **MAY** support other session methods and notifications by specifying additional capabilities.
913
+ *
914
+ * Note: `session/load` is still handled by the top-level `load_session` capability. This will be unified in future versions of the protocol.
915
+ *
916
+ * See protocol docs: [Session Capabilities](https://agentclientprotocol.com/protocol/initialization#session-capabilities)
917
+ */
918
+ export const zSessionCapabilities = z.object({
919
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
920
+ fork: z.union([zSessionForkCapabilities, z.null()]).optional(),
921
+ list: z.union([zSessionListCapabilities, z.null()]).optional(),
922
+ resume: z.union([zSessionResumeCapabilities, z.null()]).optional(),
923
+ });
924
+ /**
925
+ * Capabilities supported by the agent.
926
+ *
927
+ * Advertised during initialization to inform the client about
928
+ * available features and content types.
929
+ *
930
+ * See protocol docs: [Agent Capabilities](https://agentclientprotocol.com/protocol/initialization#agent-capabilities)
931
+ */
932
+ export const zAgentCapabilities = z.object({
933
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
934
+ loadSession: z.boolean().optional().default(false),
935
+ mcpCapabilities: zMcpCapabilities
936
+ .optional()
937
+ .default({ http: false, sse: false }),
938
+ promptCapabilities: zPromptCapabilities.optional().default({
939
+ audio: false,
940
+ embeddedContext: false,
941
+ image: false,
942
+ }),
943
+ sessionCapabilities: zSessionCapabilities.optional().default({}),
944
+ });
945
+ /**
946
+ * Response to the `initialize` method.
947
+ *
948
+ * Contains the negotiated protocol version and agent capabilities.
949
+ *
950
+ * See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)
951
+ */
952
+ export const zInitializeResponse = z.object({
953
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
954
+ agentCapabilities: zAgentCapabilities.optional().default({
955
+ loadSession: false,
956
+ mcpCapabilities: { http: false, sse: false },
957
+ promptCapabilities: {
958
+ audio: false,
959
+ embeddedContext: false,
960
+ image: false,
961
+ },
962
+ sessionCapabilities: {},
963
+ }),
964
+ agentInfo: z.union([zImplementation, z.null()]).optional(),
965
+ authMethods: z.array(zAuthMethod).optional().default([]),
966
+ protocolVersion: zProtocolVersion,
967
+ });
968
+ /**
969
+ * Request parameters for setting a session configuration option.
970
+ */
971
+ export const zSetSessionConfigOptionRequest = z.object({
972
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
973
+ configId: zSessionConfigId,
974
+ sessionId: zSessionId,
975
+ value: zSessionConfigValueId,
976
+ });
977
+ /**
978
+ * Response to `session/set_config_option` method.
979
+ */
980
+ export const zSetSessionConfigOptionResponse = z.object({
981
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
982
+ configOptions: z.array(zSessionConfigOption),
983
+ });
984
+ /**
985
+ * Request parameters for setting a session mode.
986
+ */
987
+ export const zSetSessionModeRequest = z.object({
988
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
989
+ modeId: zSessionModeId,
990
+ sessionId: zSessionId,
991
+ });
992
+ /**
993
+ * Response to `session/set_mode` method.
994
+ */
995
+ export const zSetSessionModeResponse = z.object({
996
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
997
+ });
998
+ /**
999
+ * **UNSTABLE**
1000
+ *
1001
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
1002
+ *
1003
+ * Request parameters for setting a session model.
1004
+ *
1005
+ * @experimental
1006
+ */
1007
+ export const zSetSessionModelRequest = z.object({
1008
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1009
+ modelId: zModelId,
1010
+ sessionId: zSessionId,
1011
+ });
1012
+ /**
1013
+ * **UNSTABLE**
1014
+ *
1015
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
1016
+ *
1017
+ * Response to `session/set_model` method.
1018
+ *
1019
+ * @experimental
1020
+ */
1021
+ export const zSetSessionModelResponse = z.object({
1022
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1023
+ });
1024
+ /**
1025
+ * Reasons why an agent stops processing a prompt turn.
1026
+ *
1027
+ * See protocol docs: [Stop Reasons](https://agentclientprotocol.com/protocol/prompt-turn#stop-reasons)
1028
+ */
1029
+ export const zStopReason = z.union([
1030
+ z.literal("end_turn"),
1031
+ z.literal("max_tokens"),
1032
+ z.literal("max_turn_requests"),
1033
+ z.literal("refusal"),
1034
+ z.literal("cancelled"),
1035
+ ]);
1036
+ /**
1037
+ * Embed a terminal created with `terminal/create` by its id.
1038
+ *
1039
+ * The terminal must be added before calling `terminal/release`.
1040
+ *
1041
+ * See protocol docs: [Terminal](https://agentclientprotocol.com/protocol/terminals)
1042
+ */
1043
+ export const zTerminal = z.object({
1044
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1045
+ terminalId: z.string(),
1046
+ });
1047
+ /**
1048
+ * Exit status of a terminal command.
1049
+ */
1050
+ export const zTerminalExitStatus = z.object({
1051
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1052
+ exitCode: z
1053
+ .union([
1054
+ z.number().int().gte(0).max(4294967295, {
1055
+ message: "Invalid value: Expected uint32 to be <= 4294967295",
1056
+ }),
1057
+ z.null(),
1058
+ ])
1059
+ .optional(),
1060
+ signal: z.union([z.string(), z.null()]).optional(),
1061
+ });
1062
+ /**
1063
+ * Request to get the current output and status of a terminal.
1064
+ */
1065
+ export const zTerminalOutputRequest = z.object({
1066
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1067
+ sessionId: zSessionId,
1068
+ terminalId: z.string(),
1069
+ });
1070
+ /**
1071
+ * Response containing the terminal output and exit status.
1072
+ */
1073
+ export const zTerminalOutputResponse = z.object({
1074
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1075
+ exitStatus: z.union([zTerminalExitStatus, z.null()]).optional(),
1076
+ output: z.string(),
1077
+ truncated: z.boolean(),
1078
+ });
1079
+ /**
1080
+ * Text provided to or from an LLM.
1081
+ */
1082
+ export const zTextContent = z.object({
1083
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1084
+ annotations: z.union([zAnnotations, z.null()]).optional(),
1085
+ text: z.string(),
1086
+ });
1087
+ /**
1088
+ * Text-based resource contents.
1089
+ */
1090
+ export const zTextResourceContents = z.object({
1091
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1092
+ mimeType: z.union([z.string(), z.null()]).optional(),
1093
+ text: z.string(),
1094
+ uri: z.string(),
1095
+ });
1096
+ /**
1097
+ * Resource content that can be embedded in a message.
1098
+ */
1099
+ export const zEmbeddedResourceResource = z.union([
1100
+ zTextResourceContents,
1101
+ zBlobResourceContents,
1102
+ ]);
1103
+ /**
1104
+ * The contents of a resource, embedded into a prompt or tool call result.
1105
+ */
1106
+ export const zEmbeddedResource = z.object({
1107
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1108
+ annotations: z.union([zAnnotations, z.null()]).optional(),
1109
+ resource: zEmbeddedResourceResource,
1110
+ });
1111
+ /**
1112
+ * Content blocks represent displayable information in the Agent Client Protocol.
1113
+ *
1114
+ * They provide a structured way to handle various types of user-facing content—whether
1115
+ * it's text from language models, images for analysis, or embedded resources for context.
1116
+ *
1117
+ * Content blocks appear in:
1118
+ * - User prompts sent via `session/prompt`
1119
+ * - Language model output streamed through `session/update` notifications
1120
+ * - Progress updates and results from tool calls
1121
+ *
1122
+ * This structure is compatible with the Model Context Protocol (MCP), enabling
1123
+ * agents to seamlessly forward content from MCP tool outputs without transformation.
1124
+ *
1125
+ * See protocol docs: [Content](https://agentclientprotocol.com/protocol/content)
1126
+ */
1127
+ export const zContentBlock = z.union([
1128
+ zTextContent.and(z.object({
1129
+ type: z.literal("text"),
1130
+ })),
1131
+ zImageContent.and(z.object({
1132
+ type: z.literal("image"),
1133
+ })),
1134
+ zAudioContent.and(z.object({
1135
+ type: z.literal("audio"),
1136
+ })),
1137
+ zResourceLink.and(z.object({
1138
+ type: z.literal("resource_link"),
1139
+ })),
1140
+ zEmbeddedResource.and(z.object({
1141
+ type: z.literal("resource"),
1142
+ })),
1143
+ ]);
1144
+ /**
1145
+ * Standard content block (text, images, resources).
1146
+ */
1147
+ export const zContent = z.object({
1148
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1149
+ content: zContentBlock,
1150
+ });
1151
+ /**
1152
+ * A streamed item of content
1153
+ */
1154
+ export const zContentChunk = z.object({
1155
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1156
+ content: zContentBlock,
1157
+ });
1158
+ /**
1159
+ * Request parameters for sending a user prompt to the agent.
1160
+ *
1161
+ * Contains the user's message and any additional context.
1162
+ *
1163
+ * See protocol docs: [User Message](https://agentclientprotocol.com/protocol/prompt-turn#1-user-message)
1164
+ */
1165
+ export const zPromptRequest = z.object({
1166
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1167
+ prompt: z.array(zContentBlock),
1168
+ sessionId: zSessionId,
1169
+ });
1170
+ export const zClientRequest = z.object({
1171
+ id: zRequestId,
1172
+ method: z.string(),
1173
+ params: z
1174
+ .union([
1175
+ z.union([
1176
+ zInitializeRequest,
1177
+ zAuthenticateRequest,
1178
+ zNewSessionRequest,
1179
+ zLoadSessionRequest,
1180
+ zListSessionsRequest,
1181
+ zForkSessionRequest,
1182
+ zResumeSessionRequest,
1183
+ zSetSessionModeRequest,
1184
+ zSetSessionConfigOptionRequest,
1185
+ zPromptRequest,
1186
+ zSetSessionModelRequest,
1187
+ zExtRequest,
1188
+ ]),
1189
+ z.null(),
1190
+ ])
1191
+ .optional(),
1192
+ });
1193
+ /**
1194
+ * Content produced by a tool call.
1195
+ *
1196
+ * Tool calls can produce different types of content including
1197
+ * standard content blocks (text, images) or file diffs.
1198
+ *
1199
+ * See protocol docs: [Content](https://agentclientprotocol.com/protocol/tool-calls#content)
1200
+ */
1201
+ export const zToolCallContent = z.union([
1202
+ zContent.and(z.object({
1203
+ type: z.literal("content"),
1204
+ })),
1205
+ zDiff.and(z.object({
1206
+ type: z.literal("diff"),
1207
+ })),
1208
+ zTerminal.and(z.object({
1209
+ type: z.literal("terminal"),
1210
+ })),
1211
+ ]);
1212
+ /**
1213
+ * Unique identifier for a tool call within a session.
1214
+ */
1215
+ export const zToolCallId = z.string();
1216
+ /**
1217
+ * A file location being accessed or modified by a tool.
1218
+ *
1219
+ * Enables clients to implement "follow-along" features that track
1220
+ * which files the agent is working with in real-time.
1221
+ *
1222
+ * See protocol docs: [Following the Agent](https://agentclientprotocol.com/protocol/tool-calls#following-the-agent)
1223
+ */
1224
+ export const zToolCallLocation = z.object({
1225
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1226
+ line: z
1227
+ .union([
1228
+ z.number().int().gte(0).max(4294967295, {
1229
+ message: "Invalid value: Expected uint32 to be <= 4294967295",
1230
+ }),
1231
+ z.null(),
1232
+ ])
1233
+ .optional(),
1234
+ path: z.string(),
1235
+ });
1236
+ /**
1237
+ * Execution status of a tool call.
1238
+ *
1239
+ * Tool calls progress through different statuses during their lifecycle.
1240
+ *
1241
+ * See protocol docs: [Status](https://agentclientprotocol.com/protocol/tool-calls#status)
1242
+ */
1243
+ export const zToolCallStatus = z.union([
1244
+ z.literal("pending"),
1245
+ z.literal("in_progress"),
1246
+ z.literal("completed"),
1247
+ z.literal("failed"),
1248
+ ]);
1249
+ /**
1250
+ * Categories of tools that can be invoked.
1251
+ *
1252
+ * Tool kinds help clients choose appropriate icons and optimize how they
1253
+ * display tool execution progress.
1254
+ *
1255
+ * See protocol docs: [Creating](https://agentclientprotocol.com/protocol/tool-calls#creating)
1256
+ */
1257
+ export const zToolKind = z.union([
1258
+ z.literal("read"),
1259
+ z.literal("edit"),
1260
+ z.literal("delete"),
1261
+ z.literal("move"),
1262
+ z.literal("search"),
1263
+ z.literal("execute"),
1264
+ z.literal("think"),
1265
+ z.literal("fetch"),
1266
+ z.literal("switch_mode"),
1267
+ z.literal("other"),
1268
+ ]);
1269
+ /**
1270
+ * Represents a tool call that the language model has requested.
1271
+ *
1272
+ * Tool calls are actions that the agent executes on behalf of the language model,
1273
+ * such as reading files, executing code, or fetching data from external sources.
1274
+ *
1275
+ * See protocol docs: [Tool Calls](https://agentclientprotocol.com/protocol/tool-calls)
1276
+ */
1277
+ export const zToolCall = z.object({
1278
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1279
+ content: z.array(zToolCallContent).optional(),
1280
+ kind: zToolKind.optional(),
1281
+ locations: z.array(zToolCallLocation).optional(),
1282
+ rawInput: z.unknown().optional(),
1283
+ rawOutput: z.unknown().optional(),
1284
+ status: zToolCallStatus.optional(),
1285
+ title: z.string(),
1286
+ toolCallId: zToolCallId,
1287
+ });
1288
+ /**
1289
+ * An update to an existing tool call.
1290
+ *
1291
+ * Used to report progress and results as tools execute. All fields except
1292
+ * the tool call ID are optional - only changed fields need to be included.
1293
+ *
1294
+ * See protocol docs: [Updating](https://agentclientprotocol.com/protocol/tool-calls#updating)
1295
+ */
1296
+ export const zToolCallUpdate = z.object({
1297
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1298
+ content: z.union([z.array(zToolCallContent), z.null()]).optional(),
1299
+ kind: z.union([zToolKind, z.null()]).optional(),
1300
+ locations: z.union([z.array(zToolCallLocation), z.null()]).optional(),
1301
+ rawInput: z.unknown().optional(),
1302
+ rawOutput: z.unknown().optional(),
1303
+ status: z.union([zToolCallStatus, z.null()]).optional(),
1304
+ title: z.union([z.string(), z.null()]).optional(),
1305
+ toolCallId: zToolCallId,
1306
+ });
1307
+ /**
1308
+ * Request for user permission to execute a tool call.
1309
+ *
1310
+ * Sent when the agent needs authorization before performing a sensitive operation.
1311
+ *
1312
+ * See protocol docs: [Requesting Permission](https://agentclientprotocol.com/protocol/tool-calls#requesting-permission)
1313
+ */
1314
+ export const zRequestPermissionRequest = z.object({
1315
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1316
+ options: z.array(zPermissionOption),
1317
+ sessionId: zSessionId,
1318
+ toolCall: zToolCallUpdate,
1319
+ });
1320
+ /**
1321
+ * All text that was typed after the command name is provided as input.
1322
+ */
1323
+ export const zUnstructuredCommandInput = z.object({
1324
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1325
+ hint: z.string(),
1326
+ });
1327
+ /**
1328
+ * unstructured
1329
+ *
1330
+ * All text that was typed after the command name is provided as input.
1331
+ */
1332
+ export const zAvailableCommandInput = zUnstructuredCommandInput;
1333
+ /**
1334
+ * Information about a command.
1335
+ */
1336
+ export const zAvailableCommand = z.object({
1337
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1338
+ description: z.string(),
1339
+ input: z.union([zAvailableCommandInput, z.null()]).optional(),
1340
+ name: z.string(),
1341
+ });
1342
+ /**
1343
+ * Available commands are ready or have changed
1344
+ */
1345
+ export const zAvailableCommandsUpdate = z.object({
1346
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1347
+ availableCommands: z.array(zAvailableCommand),
1348
+ });
1349
+ /**
1350
+ * **UNSTABLE**
1351
+ *
1352
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
1353
+ *
1354
+ * Token usage information for a prompt turn.
1355
+ *
1356
+ * @experimental
1357
+ */
1358
+ export const zUsage = z.object({
1359
+ cachedReadTokens: z.union([z.number(), z.null()]).optional(),
1360
+ cachedWriteTokens: z.union([z.number(), z.null()]).optional(),
1361
+ inputTokens: z.number(),
1362
+ outputTokens: z.number(),
1363
+ thoughtTokens: z.union([z.number(), z.null()]).optional(),
1364
+ totalTokens: z.number(),
1365
+ });
1366
+ /**
1367
+ * Response from processing a user prompt.
1368
+ *
1369
+ * See protocol docs: [Check for Completion](https://agentclientprotocol.com/protocol/prompt-turn#4-check-for-completion)
1370
+ */
1371
+ export const zPromptResponse = z.object({
1372
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1373
+ stopReason: zStopReason,
1374
+ usage: z.union([zUsage, z.null()]).optional(),
1375
+ });
1376
+ export const zAgentResponse = z.union([
1377
+ z.object({
1378
+ id: zRequestId,
1379
+ result: z.union([
1380
+ zInitializeResponse,
1381
+ zAuthenticateResponse,
1382
+ zNewSessionResponse,
1383
+ zLoadSessionResponse,
1384
+ zListSessionsResponse,
1385
+ zForkSessionResponse,
1386
+ zResumeSessionResponse,
1387
+ zSetSessionModeResponse,
1388
+ zSetSessionConfigOptionResponse,
1389
+ zPromptResponse,
1390
+ zSetSessionModelResponse,
1391
+ zExtResponse,
1392
+ ]),
1393
+ }),
1394
+ z.object({
1395
+ error: zError,
1396
+ id: zRequestId,
1397
+ }),
1398
+ ]);
1399
+ /**
1400
+ * **UNSTABLE**
1401
+ *
1402
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
1403
+ *
1404
+ * Context window and cost update for a session.
1405
+ *
1406
+ * @experimental
1407
+ */
1408
+ export const zUsageUpdate = z.object({
1409
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1410
+ cost: z.union([zCost, z.null()]).optional(),
1411
+ size: z.number(),
1412
+ used: z.number(),
1413
+ });
1414
+ /**
1415
+ * Different types of updates that can be sent during session processing.
1416
+ *
1417
+ * These updates provide real-time feedback about the agent's progress.
1418
+ *
1419
+ * See protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/prompt-turn#3-agent-reports-output)
1420
+ */
1421
+ export const zSessionUpdate = z.union([
1422
+ zContentChunk.and(z.object({
1423
+ sessionUpdate: z.literal("user_message_chunk"),
1424
+ })),
1425
+ zContentChunk.and(z.object({
1426
+ sessionUpdate: z.literal("agent_message_chunk"),
1427
+ })),
1428
+ zContentChunk.and(z.object({
1429
+ sessionUpdate: z.literal("agent_thought_chunk"),
1430
+ })),
1431
+ zToolCall.and(z.object({
1432
+ sessionUpdate: z.literal("tool_call"),
1433
+ })),
1434
+ zToolCallUpdate.and(z.object({
1435
+ sessionUpdate: z.literal("tool_call_update"),
1436
+ })),
1437
+ zPlan.and(z.object({
1438
+ sessionUpdate: z.literal("plan"),
1439
+ })),
1440
+ zAvailableCommandsUpdate.and(z.object({
1441
+ sessionUpdate: z.literal("available_commands_update"),
1442
+ })),
1443
+ zCurrentModeUpdate.and(z.object({
1444
+ sessionUpdate: z.literal("current_mode_update"),
1445
+ })),
1446
+ zConfigOptionUpdate.and(z.object({
1447
+ sessionUpdate: z.literal("config_option_update"),
1448
+ })),
1449
+ zSessionInfoUpdate.and(z.object({
1450
+ sessionUpdate: z.literal("session_info_update"),
1451
+ })),
1452
+ zUsageUpdate.and(z.object({
1453
+ sessionUpdate: z.literal("usage_update"),
1454
+ })),
1455
+ ]);
1456
+ /**
1457
+ * Notification containing a session update from the agent.
1458
+ *
1459
+ * Used to stream real-time progress and results during prompt processing.
1460
+ *
1461
+ * See protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/prompt-turn#3-agent-reports-output)
1462
+ */
1463
+ export const zSessionNotification = z.object({
1464
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1465
+ sessionId: zSessionId,
1466
+ update: zSessionUpdate,
1467
+ });
1468
+ export const zAgentNotification = z.object({
1469
+ method: z.string(),
1470
+ params: z
1471
+ .union([z.union([zSessionNotification, zExtNotification]), z.null()])
1472
+ .optional(),
1473
+ });
1474
+ /**
1475
+ * Request to wait for a terminal command to exit.
1476
+ */
1477
+ export const zWaitForTerminalExitRequest = z.object({
1478
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1479
+ sessionId: zSessionId,
1480
+ terminalId: z.string(),
1481
+ });
1482
+ /**
1483
+ * Response containing the exit status of a terminal command.
1484
+ */
1485
+ export const zWaitForTerminalExitResponse = z.object({
1486
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1487
+ exitCode: z
1488
+ .union([
1489
+ z.number().int().gte(0).max(4294967295, {
1490
+ message: "Invalid value: Expected uint32 to be <= 4294967295",
1491
+ }),
1492
+ z.null(),
1493
+ ])
1494
+ .optional(),
1495
+ signal: z.union([z.string(), z.null()]).optional(),
1496
+ });
1497
+ /**
1498
+ * Request to write content to a text file.
1499
+ *
1500
+ * Only available if the client supports the `fs.writeTextFile` capability.
1501
+ */
1502
+ export const zWriteTextFileRequest = z.object({
1503
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1504
+ content: z.string(),
1505
+ path: z.string(),
1506
+ sessionId: zSessionId,
1507
+ });
1508
+ export const zAgentRequest = z.object({
1509
+ id: zRequestId,
1510
+ method: z.string(),
1511
+ params: z
1512
+ .union([
1513
+ z.union([
1514
+ zWriteTextFileRequest,
1515
+ zReadTextFileRequest,
1516
+ zRequestPermissionRequest,
1517
+ zCreateTerminalRequest,
1518
+ zTerminalOutputRequest,
1519
+ zReleaseTerminalRequest,
1520
+ zWaitForTerminalExitRequest,
1521
+ zKillTerminalCommandRequest,
1522
+ zExtRequest,
1523
+ ]),
1524
+ z.null(),
1525
+ ])
1526
+ .optional(),
1527
+ });
1528
+ /**
1529
+ * Response to `fs/write_text_file`
1530
+ */
1531
+ export const zWriteTextFileResponse = z.object({
1532
+ _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1533
+ });
1534
+ export const zClientResponse = z.union([
1535
+ z.object({
1536
+ id: zRequestId,
1537
+ result: z.union([
1538
+ zWriteTextFileResponse,
1539
+ zReadTextFileResponse,
1540
+ zRequestPermissionResponse,
1541
+ zCreateTerminalResponse,
1542
+ zTerminalOutputResponse,
1543
+ zReleaseTerminalResponse,
1544
+ zWaitForTerminalExitResponse,
1545
+ zKillTerminalCommandResponse,
1546
+ zExtResponse,
1547
+ ]),
1548
+ }),
1549
+ z.object({
1550
+ error: zError,
1551
+ id: zRequestId,
1552
+ }),
1553
+ ]);
1554
+ //# sourceMappingURL=zod.gen.js.map