happy-imou-cloud 2.1.24 → 2.1.26

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 (37) hide show
  1. package/bin/happy-cloud.mjs +1 -1
  2. package/compat/acp-sdk-schema/index.d.ts +31 -0
  3. package/compat/acp-sdk-schema/index.js +4 -0
  4. package/compat/acp-sdk-schema/types.gen.d.ts +3761 -0
  5. package/compat/acp-sdk-schema/types.gen.js +2 -2
  6. package/compat/acp-sdk-schema/zod.gen.d.ts +6350 -0
  7. package/compat/acp-sdk-schema/zod.gen.js +883 -383
  8. package/dist/{BaseReasoningProcessor-C12000HQ.cjs → BaseReasoningProcessor-0e-Wwv5i.cjs} +2 -2
  9. package/dist/{BaseReasoningProcessor-BTf3r0UP.mjs → BaseReasoningProcessor-KMtgV6ap.mjs} +2 -2
  10. package/dist/{ProviderSelectionHandler-DXx9hcjB.mjs → ProviderSelectionHandler-CG8ktb5b.mjs} +2 -2
  11. package/dist/{ProviderSelectionHandler-BFdeV3Qi.cjs → ProviderSelectionHandler-CzRyfT1v.cjs} +2 -2
  12. package/dist/{api-DZeS3vrX.mjs → api-DugHuNd4.mjs} +36 -4
  13. package/dist/{api-Baax81ZI.cjs → api-hgzFUi7o.cjs} +36 -4
  14. package/dist/{command-B_RdbyPU.mjs → command-DU0KWNsf.mjs} +2 -2
  15. package/dist/{command-DOZYbypd.cjs → command-Dh8sawXu.cjs} +2 -2
  16. package/dist/{index-DA3m13mn.mjs → index-hj-qbq8Y.mjs} +309 -128
  17. package/dist/{index-BNqCQ-lZ.cjs → index-ythl_OD6.cjs} +313 -132
  18. package/dist/index.cjs +2 -2
  19. package/dist/index.mjs +2 -2
  20. package/dist/lib.cjs +1 -1
  21. package/dist/lib.d.cts +160 -159
  22. package/dist/lib.d.mts +160 -159
  23. package/dist/lib.mjs +1 -1
  24. package/dist/{registerKillSessionHandler-BiG3yHlk.mjs → registerKillSessionHandler-BNzbdofF.mjs} +22 -4
  25. package/dist/{registerKillSessionHandler-BtXtFnRx.cjs → registerKillSessionHandler-Q_rOuCNA.cjs} +22 -4
  26. package/dist/{runClaude-DGV1Dcv4.cjs → runClaude-BUi2fgRI.cjs} +4 -4
  27. package/dist/{runClaude-BqN1RhrO.mjs → runClaude-Y84RT6V0.mjs} +4 -4
  28. package/dist/{runCodex-C3htqAO7.mjs → runCodex-D2xIzHke.mjs} +28 -11
  29. package/dist/{runCodex-DQQkaW3Z.cjs → runCodex-vO3-iZ8E.cjs} +28 -11
  30. package/dist/{runGemini-CH9Cti4U.mjs → runGemini-CAotw19V.mjs} +4 -4
  31. package/dist/{runGemini-CmDSS8Qz.cjs → runGemini-DIKiIVdN.cjs} +4 -4
  32. package/package.json +3 -2
  33. package/scripts/release-smoke.mjs +22 -2
  34. package/skills/happy-cli-testing/SKILL.md +90 -0
  35. package/skills/happy-cli-testing/agents/openai.yaml +4 -0
  36. package/skills/hicloud-problem-investigation/SKILL.md +201 -0
  37. package/skills/hicloud-problem-investigation/agents/openai.yaml +4 -0
@@ -1,38 +1,146 @@
1
1
  // This file is auto-generated by @hey-api/openapi-ts
2
2
  import { z } from "zod/v4";
3
3
  /**
4
- * Describes an available authentication method.
4
+ * **UNSTABLE**
5
+ *
6
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
7
+ *
8
+ * Authentication capabilities supported by the client.
9
+ *
10
+ * Advertised during initialization to inform the agent which authentication
11
+ * method types the client can handle. This governs opt-in types that require
12
+ * additional client-side support.
13
+ *
14
+ * @experimental
15
+ */
16
+ export const zAuthCapabilities = z.looseObject({
17
+ _meta: z.record(z.string(), z.unknown()).nullish(),
18
+ terminal: z.boolean().optional().default(false),
19
+ });
20
+ /**
21
+ * **UNSTABLE**
22
+ *
23
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
24
+ *
25
+ * Describes a single environment variable for an [`AuthMethodEnvVar`] authentication method.
26
+ *
27
+ * @experimental
5
28
  */
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(),
29
+ export const zAuthEnvVar = z.looseObject({
30
+ _meta: z.record(z.string(), z.unknown()).nullish(),
31
+ label: z.string().nullish(),
32
+ name: z.string(),
33
+ optional: z.boolean().optional().default(false),
34
+ secret: z.boolean().optional().default(true),
35
+ });
36
+ /**
37
+ * Agent handles authentication itself.
38
+ *
39
+ * This is the default authentication method type.
40
+ */
41
+ export const zAuthMethodAgent = z.looseObject({
42
+ _meta: z.record(z.string(), z.unknown()).nullish(),
43
+ description: z.string().nullish(),
9
44
  id: z.string(),
10
45
  name: z.string(),
11
46
  });
47
+ /**
48
+ * **UNSTABLE**
49
+ *
50
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
51
+ *
52
+ * Environment variable authentication method.
53
+ *
54
+ * The user provides credentials that the client passes to the agent as environment variables.
55
+ *
56
+ * @experimental
57
+ */
58
+ export const zAuthMethodEnvVar = z.looseObject({
59
+ _meta: z.record(z.string(), z.unknown()).nullish(),
60
+ description: z.string().nullish(),
61
+ id: z.string(),
62
+ link: z.string().nullish(),
63
+ name: z.string(),
64
+ vars: z.array(zAuthEnvVar),
65
+ });
66
+ /**
67
+ * **UNSTABLE**
68
+ *
69
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
70
+ *
71
+ * Terminal-based authentication method.
72
+ *
73
+ * The client runs an interactive terminal for the user to authenticate via a TUI.
74
+ *
75
+ * @experimental
76
+ */
77
+ export const zAuthMethodTerminal = z.looseObject({
78
+ _meta: z.record(z.string(), z.unknown()).nullish(),
79
+ args: z.array(z.string()).optional(),
80
+ description: z.string().nullish(),
81
+ env: z.record(z.string(), z.string()).optional(),
82
+ id: z.string(),
83
+ name: z.string(),
84
+ });
85
+ /**
86
+ * Describes an available authentication method.
87
+ *
88
+ * The `type` field acts as the discriminator in the serialized JSON form.
89
+ * When no `type` is present, the method is treated as `agent`.
90
+ */
91
+ export const zAuthMethod = z.union([
92
+ zAuthMethodEnvVar.and(z.looseObject({
93
+ type: z.literal("env_var"),
94
+ })),
95
+ zAuthMethodTerminal.and(z.looseObject({
96
+ type: z.literal("terminal"),
97
+ })),
98
+ zAuthMethodAgent,
99
+ ]);
12
100
  /**
13
101
  * Request parameters for the authenticate method.
14
102
  *
15
103
  * Specifies which authentication method to use.
16
104
  */
17
- export const zAuthenticateRequest = z.object({
18
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
105
+ export const zAuthenticateRequest = z.looseObject({
106
+ _meta: z.record(z.string(), z.unknown()).nullish(),
19
107
  methodId: z.string(),
20
108
  });
21
109
  /**
22
110
  * Response to the `authenticate` method.
23
111
  */
24
- export const zAuthenticateResponse = z.object({
25
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
112
+ export const zAuthenticateResponse = z.looseObject({
113
+ _meta: z.record(z.string(), z.unknown()).nullish(),
26
114
  });
27
115
  /**
28
116
  * Binary resource contents.
29
117
  */
30
- export const zBlobResourceContents = z.object({
31
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
118
+ export const zBlobResourceContents = z.looseObject({
119
+ _meta: z.record(z.string(), z.unknown()).nullish(),
32
120
  blob: z.string(),
33
- mimeType: z.union([z.string(), z.null()]).optional(),
121
+ mimeType: z.string().nullish(),
34
122
  uri: z.string(),
35
123
  });
124
+ /**
125
+ * Schema for boolean properties in an elicitation form.
126
+ */
127
+ export const zBooleanPropertySchema = z.looseObject({
128
+ default: z.boolean().nullish(),
129
+ description: z.string().nullish(),
130
+ title: z.string().nullish(),
131
+ });
132
+ /**
133
+ * **UNSTABLE**
134
+ *
135
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
136
+ *
137
+ * Response from closing a session.
138
+ *
139
+ * @experimental
140
+ */
141
+ export const zCloseSessionResponse = z.looseObject({
142
+ _meta: z.record(z.string(), z.unknown()).nullish(),
143
+ });
36
144
  /**
37
145
  * **UNSTABLE**
38
146
  *
@@ -42,15 +150,15 @@ export const zBlobResourceContents = z.object({
42
150
  *
43
151
  * @experimental
44
152
  */
45
- export const zCost = z.object({
153
+ export const zCost = z.looseObject({
46
154
  amount: z.number(),
47
155
  currency: z.string(),
48
156
  });
49
157
  /**
50
158
  * Response containing the ID of the created terminal.
51
159
  */
52
- export const zCreateTerminalResponse = z.object({
53
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
160
+ export const zCreateTerminalResponse = z.looseObject({
161
+ _meta: z.record(z.string(), z.unknown()).nullish(),
54
162
  terminalId: z.string(),
55
163
  });
56
164
  /**
@@ -60,17 +168,158 @@ export const zCreateTerminalResponse = z.object({
60
168
  *
61
169
  * See protocol docs: [Content](https://agentclientprotocol.com/protocol/tool-calls#content)
62
170
  */
63
- export const zDiff = z.object({
64
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
171
+ export const zDiff = z.looseObject({
172
+ _meta: z.record(z.string(), z.unknown()).nullish(),
65
173
  newText: z.string(),
66
- oldText: z.union([z.string(), z.null()]).optional(),
174
+ oldText: z.string().nullish(),
67
175
  path: z.string(),
68
176
  });
177
+ export const zElicitationContentValue = z.union([
178
+ z.string(),
179
+ z.number(),
180
+ z.number(),
181
+ z.boolean(),
182
+ z.array(z.string()),
183
+ ]);
184
+ /**
185
+ * **UNSTABLE**
186
+ *
187
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
188
+ *
189
+ * The user accepted the elicitation and provided content.
190
+ *
191
+ * @experimental
192
+ */
193
+ export const zElicitationAcceptAction = z.looseObject({
194
+ content: z.record(z.string(), zElicitationContentValue).nullish(),
195
+ });
196
+ /**
197
+ * **UNSTABLE**
198
+ *
199
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
200
+ *
201
+ * The user's action in response to an elicitation.
202
+ *
203
+ * @experimental
204
+ */
205
+ export const zElicitationAction = z.union([
206
+ zElicitationAcceptAction.and(z.looseObject({
207
+ action: z.literal("accept"),
208
+ })),
209
+ z.looseObject({
210
+ action: z.literal("decline"),
211
+ }),
212
+ z.looseObject({
213
+ action: z.literal("cancel"),
214
+ }),
215
+ ]);
216
+ /**
217
+ * **UNSTABLE**
218
+ *
219
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
220
+ *
221
+ * Form-based elicitation capabilities.
222
+ *
223
+ * @experimental
224
+ */
225
+ export const zElicitationFormCapabilities = z.looseObject({
226
+ _meta: z.record(z.string(), z.unknown()).nullish(),
227
+ });
228
+ /**
229
+ * **UNSTABLE**
230
+ *
231
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
232
+ *
233
+ * Unique identifier for an elicitation.
234
+ *
235
+ * @experimental
236
+ */
237
+ export const zElicitationId = z.string();
238
+ /**
239
+ * **UNSTABLE**
240
+ *
241
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
242
+ *
243
+ * Notification sent by the agent when a URL-based elicitation is complete.
244
+ *
245
+ * @experimental
246
+ */
247
+ export const zElicitationCompleteNotification = z.looseObject({
248
+ _meta: z.record(z.string(), z.unknown()).nullish(),
249
+ elicitationId: zElicitationId,
250
+ });
251
+ /**
252
+ * **UNSTABLE**
253
+ *
254
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
255
+ *
256
+ * Response from the client to an elicitation request.
257
+ *
258
+ * @experimental
259
+ */
260
+ export const zElicitationResponse = z.looseObject({
261
+ _meta: z.record(z.string(), z.unknown()).nullish(),
262
+ action: zElicitationAction,
263
+ });
264
+ /**
265
+ * Object schema type.
266
+ */
267
+ export const zElicitationSchemaType = z.literal("object");
268
+ /**
269
+ * String schema type.
270
+ */
271
+ export const zElicitationStringType = z.literal("string");
272
+ /**
273
+ * **UNSTABLE**
274
+ *
275
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
276
+ *
277
+ * URL-based elicitation capabilities.
278
+ *
279
+ * @experimental
280
+ */
281
+ export const zElicitationUrlCapabilities = z.looseObject({
282
+ _meta: z.record(z.string(), z.unknown()).nullish(),
283
+ });
284
+ /**
285
+ * **UNSTABLE**
286
+ *
287
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
288
+ *
289
+ * Elicitation capabilities supported by the client.
290
+ *
291
+ * @experimental
292
+ */
293
+ export const zElicitationCapabilities = z.looseObject({
294
+ _meta: z.record(z.string(), z.unknown()).nullish(),
295
+ form: zElicitationFormCapabilities.nullish(),
296
+ url: zElicitationUrlCapabilities.nullish(),
297
+ });
298
+ /**
299
+ * **UNSTABLE**
300
+ *
301
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
302
+ *
303
+ * URL-based elicitation mode where the client directs the user to a URL.
304
+ *
305
+ * @experimental
306
+ */
307
+ export const zElicitationUrlMode = z.looseObject({
308
+ elicitationId: zElicitationId,
309
+ url: z.string().url(),
310
+ });
311
+ /**
312
+ * A titled enum option with a const value and human-readable title.
313
+ */
314
+ export const zEnumOption = z.looseObject({
315
+ const: z.string(),
316
+ title: z.string(),
317
+ });
69
318
  /**
70
319
  * An environment variable to set when launching an MCP server.
71
320
  */
72
- export const zEnvVariable = z.object({
73
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
321
+ export const zEnvVariable = z.looseObject({
322
+ _meta: z.record(z.string(), z.unknown()).nullish(),
74
323
  name: z.string(),
75
324
  value: z.string(),
76
325
  });
@@ -89,6 +338,7 @@ export const zErrorCode = z.union([
89
338
  z.literal(-32800),
90
339
  z.literal(-32000),
91
340
  z.literal(-32002),
341
+ z.literal(-32042),
92
342
  z
93
343
  .number()
94
344
  .int()
@@ -107,7 +357,7 @@ export const zErrorCode = z.union([
107
357
  *
108
358
  * See protocol docs: [JSON-RPC Error Object](https://www.jsonrpc.org/specification#error_object)
109
359
  */
110
- export const zError = z.object({
360
+ export const zError = z.looseObject({
111
361
  code: zErrorCode,
112
362
  data: z.unknown().optional(),
113
363
  message: z.string(),
@@ -137,13 +387,12 @@ export const zExtRequest = z.unknown();
137
387
  */
138
388
  export const zExtResponse = z.unknown();
139
389
  /**
140
- * Filesystem capabilities supported by the client.
141
390
  * File system capabilities that a client may support.
142
391
  *
143
392
  * See protocol docs: [FileSystem](https://agentclientprotocol.com/protocol/initialization#filesystem)
144
393
  */
145
- export const zFileSystemCapability = z.object({
146
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
394
+ export const zFileSystemCapabilities = z.looseObject({
395
+ _meta: z.record(z.string(), z.unknown()).nullish(),
147
396
  readTextFile: z.boolean().optional().default(false),
148
397
  writeTextFile: z.boolean().optional().default(false),
149
398
  });
@@ -155,9 +404,11 @@ export const zFileSystemCapability = z.object({
155
404
  *
156
405
  * See protocol docs: [Client Capabilities](https://agentclientprotocol.com/protocol/initialization#client-capabilities)
157
406
  */
158
- export const zClientCapabilities = z.object({
159
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
160
- fs: zFileSystemCapability
407
+ export const zClientCapabilities = z.looseObject({
408
+ _meta: z.record(z.string(), z.unknown()).nullish(),
409
+ auth: zAuthCapabilities.optional().default({ terminal: false }),
410
+ elicitation: zElicitationCapabilities.nullish(),
411
+ fs: zFileSystemCapabilities
161
412
  .optional()
162
413
  .default({ readTextFile: false, writeTextFile: false }),
163
414
  terminal: z.boolean().optional().default(false),
@@ -165,8 +416,8 @@ export const zClientCapabilities = z.object({
165
416
  /**
166
417
  * An HTTP header to set when making requests to the MCP server.
167
418
  */
168
- export const zHttpHeader = z.object({
169
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
419
+ export const zHttpHeader = z.looseObject({
420
+ _meta: z.record(z.string(), z.unknown()).nullish(),
170
421
  name: z.string(),
171
422
  value: z.string(),
172
423
  });
@@ -175,47 +426,104 @@ export const zHttpHeader = z.object({
175
426
  * Describes the name and version of an MCP implementation, with an optional
176
427
  * title for UI representation.
177
428
  */
178
- export const zImplementation = z.object({
179
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
429
+ export const zImplementation = z.looseObject({
430
+ _meta: z.record(z.string(), z.unknown()).nullish(),
180
431
  name: z.string(),
181
- title: z.union([z.string(), z.null()]).optional(),
432
+ title: z.string().nullish(),
182
433
  version: z.string(),
183
434
  });
184
435
  /**
185
- * Response to terminal/kill command method
436
+ * Schema for integer properties in an elicitation form.
437
+ */
438
+ export const zIntegerPropertySchema = z.looseObject({
439
+ default: z.number().nullish(),
440
+ description: z.string().nullish(),
441
+ maximum: z.number().nullish(),
442
+ minimum: z.number().nullish(),
443
+ title: z.string().nullish(),
444
+ });
445
+ /**
446
+ * Response to `terminal/kill` method
447
+ */
448
+ export const zKillTerminalResponse = z.looseObject({
449
+ _meta: z.record(z.string(), z.unknown()).nullish(),
450
+ });
451
+ /**
452
+ * Request parameters for listing existing sessions.
453
+ *
454
+ * Only available if the Agent supports the `sessionCapabilities.list` capability.
186
455
  */
187
- export const zKillTerminalCommandResponse = z.object({
188
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
456
+ export const zListSessionsRequest = z.looseObject({
457
+ _meta: z.record(z.string(), z.unknown()).nullish(),
458
+ cursor: z.string().nullish(),
459
+ cwd: z.string().nullish(),
189
460
  });
190
461
  /**
191
462
  * **UNSTABLE**
192
463
  *
193
464
  * This capability is not part of the spec yet, and may be removed or changed at any point.
194
465
  *
195
- * Request parameters for listing existing sessions.
466
+ * Logout capabilities supported by the agent.
467
+ *
468
+ * By supplying `{}` it means that the agent supports the logout method.
469
+ *
470
+ * @experimental
471
+ */
472
+ export const zLogoutCapabilities = z.looseObject({
473
+ _meta: z.record(z.string(), z.unknown()).nullish(),
474
+ });
475
+ /**
476
+ * **UNSTABLE**
477
+ *
478
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
479
+ *
480
+ * Authentication-related capabilities supported by the agent.
481
+ *
482
+ * @experimental
483
+ */
484
+ export const zAgentAuthCapabilities = z.looseObject({
485
+ _meta: z.record(z.string(), z.unknown()).nullish(),
486
+ logout: zLogoutCapabilities.nullish(),
487
+ });
488
+ /**
489
+ * **UNSTABLE**
490
+ *
491
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
492
+ *
493
+ * Request parameters for the logout method.
494
+ *
495
+ * Terminates the current authenticated session.
196
496
  *
197
- * Only available if the Agent supports the `listSessions` capability.
497
+ * @experimental
498
+ */
499
+ export const zLogoutRequest = z.looseObject({
500
+ _meta: z.record(z.string(), z.unknown()).nullish(),
501
+ });
502
+ /**
503
+ * **UNSTABLE**
504
+ *
505
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
506
+ *
507
+ * Response to the `logout` method.
198
508
  *
199
509
  * @experimental
200
510
  */
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(),
511
+ export const zLogoutResponse = z.looseObject({
512
+ _meta: z.record(z.string(), z.unknown()).nullish(),
205
513
  });
206
514
  /**
207
515
  * MCP capabilities supported by the agent
208
516
  */
209
- export const zMcpCapabilities = z.object({
210
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
517
+ export const zMcpCapabilities = z.looseObject({
518
+ _meta: z.record(z.string(), z.unknown()).nullish(),
211
519
  http: z.boolean().optional().default(false),
212
520
  sse: z.boolean().optional().default(false),
213
521
  });
214
522
  /**
215
523
  * HTTP transport configuration for MCP.
216
524
  */
217
- export const zMcpServerHttp = z.object({
218
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
525
+ export const zMcpServerHttp = z.looseObject({
526
+ _meta: z.record(z.string(), z.unknown()).nullish(),
219
527
  headers: z.array(zHttpHeader),
220
528
  name: z.string(),
221
529
  url: z.string(),
@@ -223,8 +531,8 @@ export const zMcpServerHttp = z.object({
223
531
  /**
224
532
  * SSE transport configuration for MCP.
225
533
  */
226
- export const zMcpServerSse = z.object({
227
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
534
+ export const zMcpServerSse = z.looseObject({
535
+ _meta: z.record(z.string(), z.unknown()).nullish(),
228
536
  headers: z.array(zHttpHeader),
229
537
  name: z.string(),
230
538
  url: z.string(),
@@ -232,8 +540,8 @@ export const zMcpServerSse = z.object({
232
540
  /**
233
541
  * Stdio transport configuration for MCP.
234
542
  */
235
- export const zMcpServerStdio = z.object({
236
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
543
+ export const zMcpServerStdio = z.looseObject({
544
+ _meta: z.record(z.string(), z.unknown()).nullish(),
237
545
  args: z.array(z.string()),
238
546
  command: z.string(),
239
547
  env: z.array(zEnvVariable),
@@ -248,10 +556,10 @@ export const zMcpServerStdio = z.object({
248
556
  * See protocol docs: [MCP Servers](https://agentclientprotocol.com/protocol/session-setup#mcp-servers)
249
557
  */
250
558
  export const zMcpServer = z.union([
251
- zMcpServerHttp.and(z.object({
559
+ zMcpServerHttp.and(z.looseObject({
252
560
  type: z.literal("http"),
253
561
  })),
254
- zMcpServerSse.and(z.object({
562
+ zMcpServerSse.and(z.looseObject({
255
563
  type: z.literal("sse"),
256
564
  })),
257
565
  zMcpServerStdio,
@@ -275,9 +583,9 @@ export const zModelId = z.string();
275
583
  *
276
584
  * @experimental
277
585
  */
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(),
586
+ export const zModelInfo = z.looseObject({
587
+ _meta: z.record(z.string(), z.unknown()).nullish(),
588
+ description: z.string().nullish(),
281
589
  modelId: zModelId,
282
590
  name: z.string(),
283
591
  });
@@ -286,11 +594,21 @@ export const zModelInfo = z.object({
286
594
  *
287
595
  * See protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol/session-setup#creating-a-session)
288
596
  */
289
- export const zNewSessionRequest = z.object({
290
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
597
+ export const zNewSessionRequest = z.looseObject({
598
+ _meta: z.record(z.string(), z.unknown()).nullish(),
291
599
  cwd: z.string(),
292
600
  mcpServers: z.array(zMcpServer),
293
601
  });
602
+ /**
603
+ * Schema for number (floating-point) properties in an elicitation form.
604
+ */
605
+ export const zNumberPropertySchema = z.looseObject({
606
+ default: z.number().nullish(),
607
+ description: z.string().nullish(),
608
+ maximum: z.number().nullish(),
609
+ minimum: z.number().nullish(),
610
+ title: z.string().nullish(),
611
+ });
294
612
  /**
295
613
  * Unique identifier for a permission option.
296
614
  */
@@ -309,8 +627,8 @@ export const zPermissionOptionKind = z.union([
309
627
  /**
310
628
  * An option presented to the user when requesting permission.
311
629
  */
312
- export const zPermissionOption = z.object({
313
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
630
+ export const zPermissionOption = z.looseObject({
631
+ _meta: z.record(z.string(), z.unknown()).nullish(),
314
632
  kind: zPermissionOptionKind,
315
633
  name: z.string(),
316
634
  optionId: zPermissionOptionId,
@@ -345,8 +663,8 @@ export const zPlanEntryStatus = z.union([
345
663
  * as part of fulfilling the user's request.
346
664
  * See protocol docs: [Plan Entries](https://agentclientprotocol.com/protocol/agent-plan#plan-entries)
347
665
  */
348
- export const zPlanEntry = z.object({
349
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
666
+ export const zPlanEntry = z.looseObject({
667
+ _meta: z.record(z.string(), z.unknown()).nullish(),
350
668
  content: z.string(),
351
669
  priority: zPlanEntryPriority,
352
670
  status: zPlanEntryStatus,
@@ -360,8 +678,8 @@ export const zPlanEntry = z.object({
360
678
  *
361
679
  * See protocol docs: [Agent Plan](https://agentclientprotocol.com/protocol/agent-plan)
362
680
  */
363
- export const zPlan = z.object({
364
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
681
+ export const zPlan = z.looseObject({
682
+ _meta: z.record(z.string(), z.unknown()).nullish(),
365
683
  entries: z.array(zPlanEntry),
366
684
  });
367
685
  /**
@@ -378,8 +696,8 @@ export const zPlan = z.object({
378
696
  *
379
697
  * See protocol docs: [Prompt Capabilities](https://agentclientprotocol.com/protocol/initialization#prompt-capabilities)
380
698
  */
381
- export const zPromptCapabilities = z.object({
382
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
699
+ export const zPromptCapabilities = z.looseObject({
700
+ _meta: z.record(z.string(), z.unknown()).nullish(),
383
701
  audio: z.boolean().optional().default(false),
384
702
  embeddedContext: z.boolean().optional().default(false),
385
703
  image: z.boolean().optional().default(false),
@@ -398,27 +716,28 @@ export const zProtocolVersion = z.number().int().gte(0).lte(65535);
398
716
  *
399
717
  * See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)
400
718
  */
401
- export const zInitializeRequest = z.object({
402
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
719
+ export const zInitializeRequest = z.looseObject({
720
+ _meta: z.record(z.string(), z.unknown()).nullish(),
403
721
  clientCapabilities: zClientCapabilities.optional().default({
722
+ auth: { terminal: false },
404
723
  fs: { readTextFile: false, writeTextFile: false },
405
724
  terminal: false,
406
725
  }),
407
- clientInfo: z.union([zImplementation, z.null()]).optional(),
726
+ clientInfo: zImplementation.nullish(),
408
727
  protocolVersion: zProtocolVersion,
409
728
  });
410
729
  /**
411
730
  * Response containing the contents of a text file.
412
731
  */
413
- export const zReadTextFileResponse = z.object({
414
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
732
+ export const zReadTextFileResponse = z.looseObject({
733
+ _meta: z.record(z.string(), z.unknown()).nullish(),
415
734
  content: z.string(),
416
735
  });
417
736
  /**
418
737
  * Response to terminal/release method
419
738
  */
420
- export const zReleaseTerminalResponse = z.object({
421
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
739
+ export const zReleaseTerminalResponse = z.looseObject({
740
+ _meta: z.record(z.string(), z.unknown()).nullish(),
422
741
  });
423
742
  /**
424
743
  * JSON RPC Request Id
@@ -431,7 +750,7 @@ export const zReleaseTerminalResponse = z.object({
431
750
  *
432
751
  * [2] Fractional parts may be problematic, since many decimal fractions cannot be represented exactly as binary fractions.
433
752
  */
434
- export const zRequestId = z.union([z.null(), z.number(), z.string()]);
753
+ export const zRequestId = z.union([z.number(), z.string()]).nullable();
435
754
  /**
436
755
  * **UNSTABLE**
437
756
  *
@@ -443,8 +762,8 @@ export const zRequestId = z.union([z.null(), z.number(), z.string()]);
443
762
  *
444
763
  * @experimental
445
764
  */
446
- export const zCancelRequestNotification = z.object({
447
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
765
+ export const zCancelRequestNotification = z.looseObject({
766
+ _meta: z.record(z.string(), z.unknown()).nullish(),
448
767
  requestId: zRequestId,
449
768
  });
450
769
  /**
@@ -454,69 +773,95 @@ export const zRole = z.enum(["assistant", "user"]);
454
773
  /**
455
774
  * Optional annotations for the client. The client can use annotations to inform how objects are used or displayed
456
775
  */
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(),
776
+ export const zAnnotations = z.looseObject({
777
+ _meta: z.record(z.string(), z.unknown()).nullish(),
778
+ audience: z.array(zRole).nullish(),
779
+ lastModified: z.string().nullish(),
780
+ priority: z.number().nullish(),
462
781
  });
463
782
  /**
464
783
  * Audio provided to or from an LLM.
465
784
  */
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(),
785
+ export const zAudioContent = z.looseObject({
786
+ _meta: z.record(z.string(), z.unknown()).nullish(),
787
+ annotations: zAnnotations.nullish(),
469
788
  data: z.string(),
470
789
  mimeType: z.string(),
471
790
  });
472
791
  /**
473
792
  * An image provided to or from an LLM.
474
793
  */
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(),
794
+ export const zImageContent = z.looseObject({
795
+ _meta: z.record(z.string(), z.unknown()).nullish(),
796
+ annotations: zAnnotations.nullish(),
478
797
  data: z.string(),
479
798
  mimeType: z.string(),
480
- uri: z.union([z.string(), z.null()]).optional(),
799
+ uri: z.string().nullish(),
481
800
  });
482
801
  /**
483
802
  * A resource that the server is capable of reading, included in a prompt or tool call result.
484
803
  */
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(),
804
+ export const zResourceLink = z.looseObject({
805
+ _meta: z.record(z.string(), z.unknown()).nullish(),
806
+ annotations: zAnnotations.nullish(),
807
+ description: z.string().nullish(),
808
+ mimeType: z.string().nullish(),
490
809
  name: z.string(),
491
- size: z.union([z.number(), z.null()]).optional(),
492
- title: z.union([z.string(), z.null()]).optional(),
810
+ size: z.number().nullish(),
811
+ title: z.string().nullish(),
493
812
  uri: z.string(),
494
813
  });
495
814
  /**
496
815
  * The user selected one of the provided options.
497
816
  */
498
- export const zSelectedPermissionOutcome = z.object({
499
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
817
+ export const zSelectedPermissionOutcome = z.looseObject({
818
+ _meta: z.record(z.string(), z.unknown()).nullish(),
500
819
  optionId: zPermissionOptionId,
501
820
  });
502
821
  /**
503
822
  * The outcome of a permission request.
504
823
  */
505
824
  export const zRequestPermissionOutcome = z.union([
506
- z.object({
825
+ z.looseObject({
507
826
  outcome: z.literal("cancelled"),
508
827
  }),
509
- zSelectedPermissionOutcome.and(z.object({
828
+ zSelectedPermissionOutcome.and(z.looseObject({
510
829
  outcome: z.literal("selected"),
511
830
  })),
512
831
  ]);
513
832
  /**
514
833
  * Response to a permission request.
515
834
  */
516
- export const zRequestPermissionResponse = z.object({
517
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
835
+ export const zRequestPermissionResponse = z.looseObject({
836
+ _meta: z.record(z.string(), z.unknown()).nullish(),
518
837
  outcome: zRequestPermissionOutcome,
519
838
  });
839
+ /**
840
+ * **UNSTABLE**
841
+ *
842
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
843
+ *
844
+ * Capabilities for the `session/close` method.
845
+ *
846
+ * By supplying `{}` it means that the agent supports closing of sessions.
847
+ *
848
+ * @experimental
849
+ */
850
+ export const zSessionCloseCapabilities = z.looseObject({
851
+ _meta: z.record(z.string(), z.unknown()).nullish(),
852
+ });
853
+ /**
854
+ * **UNSTABLE**
855
+ *
856
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
857
+ *
858
+ * A boolean on/off toggle session configuration option payload.
859
+ *
860
+ * @experimental
861
+ */
862
+ export const zSessionConfigBoolean = z.looseObject({
863
+ currentValue: z.boolean(),
864
+ });
520
865
  /**
521
866
  * Unique identifier for a session configuration option value group.
522
867
  */
@@ -549,17 +894,17 @@ export const zSessionConfigValueId = z.string();
549
894
  /**
550
895
  * A possible value for a session configuration option.
551
896
  */
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(),
897
+ export const zSessionConfigSelectOption = z.looseObject({
898
+ _meta: z.record(z.string(), z.unknown()).nullish(),
899
+ description: z.string().nullish(),
555
900
  name: z.string(),
556
901
  value: zSessionConfigValueId,
557
902
  });
558
903
  /**
559
904
  * A group of possible values for a session configuration option.
560
905
  */
561
- export const zSessionConfigSelectGroup = z.object({
562
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
906
+ export const zSessionConfigSelectGroup = z.looseObject({
907
+ _meta: z.record(z.string(), z.unknown()).nullish(),
563
908
  group: zSessionConfigGroupId,
564
909
  name: z.string(),
565
910
  options: z.array(zSessionConfigSelectOption),
@@ -574,26 +919,29 @@ export const zSessionConfigSelectOptions = z.union([
574
919
  /**
575
920
  * A single-value selector (dropdown) session configuration option payload.
576
921
  */
577
- export const zSessionConfigSelect = z.object({
922
+ export const zSessionConfigSelect = z.looseObject({
578
923
  currentValue: zSessionConfigValueId,
579
924
  options: zSessionConfigSelectOptions,
580
925
  });
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(),
926
+ export const zSessionConfigOption = z.intersection(z.union([
927
+ zSessionConfigSelect.and(z.looseObject({
928
+ type: z.literal("select"),
929
+ })),
930
+ zSessionConfigBoolean.and(z.looseObject({
931
+ type: z.literal("boolean"),
932
+ })),
933
+ ]), z.looseObject({
934
+ _meta: z.record(z.string(), z.unknown()).nullish(),
935
+ category: zSessionConfigOptionCategory.nullish(),
936
+ description: z.string().nullish(),
589
937
  id: zSessionConfigId,
590
938
  name: z.string(),
591
939
  }));
592
940
  /**
593
941
  * Session configuration options have been updated.
594
942
  */
595
- export const zConfigOptionUpdate = z.object({
596
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
943
+ export const zConfigOptionUpdate = z.looseObject({
944
+ _meta: z.record(z.string(), z.unknown()).nullish(),
597
945
  configOptions: z.array(zSessionConfigOption),
598
946
  });
599
947
  /**
@@ -607,8 +955,8 @@ export const zConfigOptionUpdate = z.object({
607
955
  *
608
956
  * @experimental
609
957
  */
610
- export const zSessionForkCapabilities = z.object({
611
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
958
+ export const zSessionForkCapabilities = z.looseObject({
959
+ _meta: z.record(z.string(), z.unknown()).nullish(),
612
960
  });
613
961
  /**
614
962
  * A unique identifier for a conversation session between a client and agent.
@@ -624,26 +972,43 @@ export const zSessionId = z.string();
624
972
  *
625
973
  * See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/prompt-turn#cancellation)
626
974
  */
627
- export const zCancelNotification = z.object({
628
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
975
+ export const zCancelNotification = z.looseObject({
976
+ _meta: z.record(z.string(), z.unknown()).nullish(),
629
977
  sessionId: zSessionId,
630
978
  });
631
- export const zClientNotification = z.object({
979
+ export const zClientNotification = z.looseObject({
632
980
  method: z.string(),
633
- params: z
634
- .union([z.union([zCancelNotification, zExtNotification]), z.null()])
635
- .optional(),
981
+ params: z.union([zCancelNotification, zExtNotification]).nullish(),
982
+ });
983
+ /**
984
+ * **UNSTABLE**
985
+ *
986
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
987
+ *
988
+ * Request parameters for closing an active session.
989
+ *
990
+ * If supported, the agent **must** cancel any ongoing work related to the session
991
+ * (treat it as if `session/cancel` was called) and then free up any resources
992
+ * associated with the session.
993
+ *
994
+ * Only available if the Agent supports the `session.close` capability.
995
+ *
996
+ * @experimental
997
+ */
998
+ export const zCloseSessionRequest = z.looseObject({
999
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1000
+ sessionId: zSessionId,
636
1001
  });
637
1002
  /**
638
1003
  * Request to create a new terminal and execute a command.
639
1004
  */
640
- export const zCreateTerminalRequest = z.object({
641
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1005
+ export const zCreateTerminalRequest = z.looseObject({
1006
+ _meta: z.record(z.string(), z.unknown()).nullish(),
642
1007
  args: z.array(z.string()).optional(),
643
1008
  command: z.string(),
644
- cwd: z.union([z.string(), z.null()]).optional(),
1009
+ cwd: z.string().nullish(),
645
1010
  env: z.array(zEnvVariable).optional(),
646
- outputByteLimit: z.union([z.number(), z.null()]).optional(),
1011
+ outputByteLimit: z.number().nullish(),
647
1012
  sessionId: zSessionId,
648
1013
  });
649
1014
  /**
@@ -660,17 +1025,17 @@ export const zCreateTerminalRequest = z.object({
660
1025
  *
661
1026
  * @experimental
662
1027
  */
663
- export const zForkSessionRequest = z.object({
664
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1028
+ export const zForkSessionRequest = z.looseObject({
1029
+ _meta: z.record(z.string(), z.unknown()).nullish(),
665
1030
  cwd: z.string(),
666
1031
  mcpServers: z.array(zMcpServer).optional(),
667
1032
  sessionId: zSessionId,
668
1033
  });
669
1034
  /**
670
- * Request to kill a terminal command without releasing the terminal.
1035
+ * Request to kill a terminal without releasing it.
671
1036
  */
672
- export const zKillTerminalCommandRequest = z.object({
673
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1037
+ export const zKillTerminalRequest = z.looseObject({
1038
+ _meta: z.record(z.string(), z.unknown()).nullish(),
674
1039
  sessionId: zSessionId,
675
1040
  terminalId: z.string(),
676
1041
  });
@@ -681,8 +1046,8 @@ export const zKillTerminalCommandRequest = z.object({
681
1046
  *
682
1047
  * See protocol docs: [Loading Sessions](https://agentclientprotocol.com/protocol/session-setup#loading-sessions)
683
1048
  */
684
- export const zLoadSessionRequest = z.object({
685
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1049
+ export const zLoadSessionRequest = z.looseObject({
1050
+ _meta: z.record(z.string(), z.unknown()).nullish(),
686
1051
  cwd: z.string(),
687
1052
  mcpServers: z.array(zMcpServer),
688
1053
  sessionId: zSessionId,
@@ -692,32 +1057,32 @@ export const zLoadSessionRequest = z.object({
692
1057
  *
693
1058
  * Only available if the client supports the `fs.readTextFile` capability.
694
1059
  */
695
- export const zReadTextFileRequest = z.object({
696
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1060
+ export const zReadTextFileRequest = z.looseObject({
1061
+ _meta: z.record(z.string(), z.unknown()).nullish(),
697
1062
  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(),
1063
+ .number()
1064
+ .int()
1065
+ .gte(0)
1066
+ .max(4294967295, {
1067
+ message: "Invalid value: Expected uint32 to be <= 4294967295",
1068
+ })
1069
+ .nullish(),
705
1070
  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(),
1071
+ .number()
1072
+ .int()
1073
+ .gte(0)
1074
+ .max(4294967295, {
1075
+ message: "Invalid value: Expected uint32 to be <= 4294967295",
1076
+ })
1077
+ .nullish(),
713
1078
  path: z.string(),
714
1079
  sessionId: zSessionId,
715
1080
  });
716
1081
  /**
717
1082
  * Request to release a terminal and free its resources.
718
1083
  */
719
- export const zReleaseTerminalRequest = z.object({
720
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1084
+ export const zReleaseTerminalRequest = z.looseObject({
1085
+ _meta: z.record(z.string(), z.unknown()).nullish(),
721
1086
  sessionId: zSessionId,
722
1087
  terminalId: z.string(),
723
1088
  });
@@ -735,40 +1100,28 @@ export const zReleaseTerminalRequest = z.object({
735
1100
  *
736
1101
  * @experimental
737
1102
  */
738
- export const zResumeSessionRequest = z.object({
739
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1103
+ export const zResumeSessionRequest = z.looseObject({
1104
+ _meta: z.record(z.string(), z.unknown()).nullish(),
740
1105
  cwd: z.string(),
741
1106
  mcpServers: z.array(zMcpServer).optional(),
742
1107
  sessionId: zSessionId,
743
1108
  });
744
1109
  /**
745
- * **UNSTABLE**
746
- *
747
- * This capability is not part of the spec yet, and may be removed or changed at any point.
748
- *
749
1110
  * Information about a session returned by session/list
750
- *
751
- * @experimental
752
1111
  */
753
- export const zSessionInfo = z.object({
754
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1112
+ export const zSessionInfo = z.looseObject({
1113
+ _meta: z.record(z.string(), z.unknown()).nullish(),
755
1114
  cwd: z.string(),
756
1115
  sessionId: zSessionId,
757
- title: z.union([z.string(), z.null()]).optional(),
758
- updatedAt: z.union([z.string(), z.null()]).optional(),
1116
+ title: z.string().nullish(),
1117
+ updatedAt: z.string().nullish(),
759
1118
  });
760
1119
  /**
761
- * **UNSTABLE**
762
- *
763
- * This capability is not part of the spec yet, and may be removed or changed at any point.
764
- *
765
1120
  * Response from listing sessions.
766
- *
767
- * @experimental
768
1121
  */
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(),
1122
+ export const zListSessionsResponse = z.looseObject({
1123
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1124
+ nextCursor: z.string().nullish(),
772
1125
  sessions: z.array(zSessionInfo),
773
1126
  });
774
1127
  /**
@@ -777,20 +1130,18 @@ export const zListSessionsResponse = z.object({
777
1130
  * Agents send this notification to update session information like title or custom metadata.
778
1131
  * This allows clients to display dynamic session names and track session state changes.
779
1132
  */
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(),
1133
+ export const zSessionInfoUpdate = z.looseObject({
1134
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1135
+ title: z.string().nullish(),
1136
+ updatedAt: z.string().nullish(),
784
1137
  });
785
1138
  /**
786
1139
  * Capabilities for the `session/list` method.
787
1140
  *
788
1141
  * 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
1142
  */
792
- export const zSessionListCapabilities = z.object({
793
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1143
+ export const zSessionListCapabilities = z.looseObject({
1144
+ _meta: z.record(z.string(), z.unknown()).nullish(),
794
1145
  });
795
1146
  /**
796
1147
  * Unique identifier for a Session Mode.
@@ -801,8 +1152,8 @@ export const zSessionModeId = z.string();
801
1152
  *
802
1153
  * See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)
803
1154
  */
804
- export const zCurrentModeUpdate = z.object({
805
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1155
+ export const zCurrentModeUpdate = z.looseObject({
1156
+ _meta: z.record(z.string(), z.unknown()).nullish(),
806
1157
  currentModeId: zSessionModeId,
807
1158
  });
808
1159
  /**
@@ -810,17 +1161,17 @@ export const zCurrentModeUpdate = z.object({
810
1161
  *
811
1162
  * See protocol docs: [Session Modes](https://agentclientprotocol.com/protocol/session-modes)
812
1163
  */
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(),
1164
+ export const zSessionMode = z.looseObject({
1165
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1166
+ description: z.string().nullish(),
816
1167
  id: zSessionModeId,
817
1168
  name: z.string(),
818
1169
  });
819
1170
  /**
820
1171
  * The set of modes and the one currently active.
821
1172
  */
822
- export const zSessionModeState = z.object({
823
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1173
+ export const zSessionModeState = z.looseObject({
1174
+ _meta: z.record(z.string(), z.unknown()).nullish(),
824
1175
  availableModes: z.array(zSessionMode),
825
1176
  currentModeId: zSessionModeId,
826
1177
  });
@@ -833,8 +1184,8 @@ export const zSessionModeState = z.object({
833
1184
  *
834
1185
  * @experimental
835
1186
  */
836
- export const zSessionModelState = z.object({
837
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1187
+ export const zSessionModelState = z.looseObject({
1188
+ _meta: z.record(z.string(), z.unknown()).nullish(),
838
1189
  availableModels: z.array(zModelInfo),
839
1190
  currentModelId: zModelId,
840
1191
  });
@@ -847,32 +1198,32 @@ export const zSessionModelState = z.object({
847
1198
  *
848
1199
  * @experimental
849
1200
  */
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(),
1201
+ export const zForkSessionResponse = z.looseObject({
1202
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1203
+ configOptions: z.array(zSessionConfigOption).nullish(),
1204
+ models: zSessionModelState.nullish(),
1205
+ modes: zSessionModeState.nullish(),
855
1206
  sessionId: zSessionId,
856
1207
  });
857
1208
  /**
858
1209
  * Response from loading an existing session.
859
1210
  */
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(),
1211
+ export const zLoadSessionResponse = z.looseObject({
1212
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1213
+ configOptions: z.array(zSessionConfigOption).nullish(),
1214
+ models: zSessionModelState.nullish(),
1215
+ modes: zSessionModeState.nullish(),
865
1216
  });
866
1217
  /**
867
1218
  * Response from creating a new session.
868
1219
  *
869
1220
  * See protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol/session-setup#creating-a-session)
870
1221
  */
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(),
1222
+ export const zNewSessionResponse = z.looseObject({
1223
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1224
+ configOptions: z.array(zSessionConfigOption).nullish(),
1225
+ models: zSessionModelState.nullish(),
1226
+ modes: zSessionModeState.nullish(),
876
1227
  sessionId: zSessionId,
877
1228
  });
878
1229
  /**
@@ -884,11 +1235,11 @@ export const zNewSessionResponse = z.object({
884
1235
  *
885
1236
  * @experimental
886
1237
  */
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(),
1238
+ export const zResumeSessionResponse = z.looseObject({
1239
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1240
+ configOptions: z.array(zSessionConfigOption).nullish(),
1241
+ models: zSessionModelState.nullish(),
1242
+ modes: zSessionModeState.nullish(),
892
1243
  });
893
1244
  /**
894
1245
  * **UNSTABLE**
@@ -901,8 +1252,8 @@ export const zResumeSessionResponse = z.object({
901
1252
  *
902
1253
  * @experimental
903
1254
  */
904
- export const zSessionResumeCapabilities = z.object({
905
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1255
+ export const zSessionResumeCapabilities = z.looseObject({
1256
+ _meta: z.record(z.string(), z.unknown()).nullish(),
906
1257
  });
907
1258
  /**
908
1259
  * Session capabilities supported by the agent.
@@ -915,11 +1266,12 @@ export const zSessionResumeCapabilities = z.object({
915
1266
  *
916
1267
  * See protocol docs: [Session Capabilities](https://agentclientprotocol.com/protocol/initialization#session-capabilities)
917
1268
  */
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(),
1269
+ export const zSessionCapabilities = z.looseObject({
1270
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1271
+ close: zSessionCloseCapabilities.nullish(),
1272
+ fork: zSessionForkCapabilities.nullish(),
1273
+ list: zSessionListCapabilities.nullish(),
1274
+ resume: zSessionResumeCapabilities.nullish(),
923
1275
  });
924
1276
  /**
925
1277
  * Capabilities supported by the agent.
@@ -929,8 +1281,9 @@ export const zSessionCapabilities = z.object({
929
1281
  *
930
1282
  * See protocol docs: [Agent Capabilities](https://agentclientprotocol.com/protocol/initialization#agent-capabilities)
931
1283
  */
932
- export const zAgentCapabilities = z.object({
933
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1284
+ export const zAgentCapabilities = z.looseObject({
1285
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1286
+ auth: zAgentAuthCapabilities.optional().default({}),
934
1287
  loadSession: z.boolean().optional().default(false),
935
1288
  mcpCapabilities: zMcpCapabilities
936
1289
  .optional()
@@ -949,9 +1302,10 @@ export const zAgentCapabilities = z.object({
949
1302
  *
950
1303
  * See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)
951
1304
  */
952
- export const zInitializeResponse = z.object({
953
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1305
+ export const zInitializeResponse = z.looseObject({
1306
+ _meta: z.record(z.string(), z.unknown()).nullish(),
954
1307
  agentCapabilities: zAgentCapabilities.optional().default({
1308
+ auth: {},
955
1309
  loadSession: false,
956
1310
  mcpCapabilities: { http: false, sse: false },
957
1311
  promptCapabilities: {
@@ -961,39 +1315,43 @@ export const zInitializeResponse = z.object({
961
1315
  },
962
1316
  sessionCapabilities: {},
963
1317
  }),
964
- agentInfo: z.union([zImplementation, z.null()]).optional(),
1318
+ agentInfo: zImplementation.nullish(),
965
1319
  authMethods: z.array(zAuthMethod).optional().default([]),
966
1320
  protocolVersion: zProtocolVersion,
967
1321
  });
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(),
1322
+ export const zSetSessionConfigOptionRequest = z.intersection(z.union([
1323
+ z.looseObject({
1324
+ type: z.literal("boolean"),
1325
+ value: z.boolean(),
1326
+ }),
1327
+ z.looseObject({
1328
+ value: zSessionConfigValueId,
1329
+ }),
1330
+ ]), z.looseObject({
1331
+ _meta: z.record(z.string(), z.unknown()).nullish(),
973
1332
  configId: zSessionConfigId,
974
1333
  sessionId: zSessionId,
975
- value: zSessionConfigValueId,
976
- });
1334
+ }));
977
1335
  /**
978
1336
  * Response to `session/set_config_option` method.
979
1337
  */
980
- export const zSetSessionConfigOptionResponse = z.object({
981
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1338
+ export const zSetSessionConfigOptionResponse = z.looseObject({
1339
+ _meta: z.record(z.string(), z.unknown()).nullish(),
982
1340
  configOptions: z.array(zSessionConfigOption),
983
1341
  });
984
1342
  /**
985
1343
  * Request parameters for setting a session mode.
986
1344
  */
987
- export const zSetSessionModeRequest = z.object({
988
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1345
+ export const zSetSessionModeRequest = z.looseObject({
1346
+ _meta: z.record(z.string(), z.unknown()).nullish(),
989
1347
  modeId: zSessionModeId,
990
1348
  sessionId: zSessionId,
991
1349
  });
992
1350
  /**
993
1351
  * Response to `session/set_mode` method.
994
1352
  */
995
- export const zSetSessionModeResponse = z.object({
996
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1353
+ export const zSetSessionModeResponse = z.looseObject({
1354
+ _meta: z.record(z.string(), z.unknown()).nullish(),
997
1355
  });
998
1356
  /**
999
1357
  * **UNSTABLE**
@@ -1004,8 +1362,8 @@ export const zSetSessionModeResponse = z.object({
1004
1362
  *
1005
1363
  * @experimental
1006
1364
  */
1007
- export const zSetSessionModelRequest = z.object({
1008
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1365
+ export const zSetSessionModelRequest = z.looseObject({
1366
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1009
1367
  modelId: zModelId,
1010
1368
  sessionId: zSessionId,
1011
1369
  });
@@ -1018,8 +1376,8 @@ export const zSetSessionModelRequest = z.object({
1018
1376
  *
1019
1377
  * @experimental
1020
1378
  */
1021
- export const zSetSessionModelResponse = z.object({
1022
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1379
+ export const zSetSessionModelResponse = z.looseObject({
1380
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1023
1381
  });
1024
1382
  /**
1025
1383
  * Reasons why an agent stops processing a prompt turn.
@@ -1033,6 +1391,46 @@ export const zStopReason = z.union([
1033
1391
  z.literal("refusal"),
1034
1392
  z.literal("cancelled"),
1035
1393
  ]);
1394
+ /**
1395
+ * String format types for string properties in elicitation schemas.
1396
+ */
1397
+ export const zStringFormat = z.union([
1398
+ z.literal("email"),
1399
+ z.literal("uri"),
1400
+ z.literal("date"),
1401
+ z.literal("date-time"),
1402
+ ]);
1403
+ /**
1404
+ * Schema for string properties in an elicitation form.
1405
+ *
1406
+ * When `enum` or `oneOf` is set, this represents a single-select enum
1407
+ * with `"type": "string"`.
1408
+ */
1409
+ export const zStringPropertySchema = z.looseObject({
1410
+ default: z.string().nullish(),
1411
+ description: z.string().nullish(),
1412
+ enum: z.array(z.string()).nullish(),
1413
+ format: zStringFormat.nullish(),
1414
+ maxLength: z
1415
+ .number()
1416
+ .int()
1417
+ .gte(0)
1418
+ .max(4294967295, {
1419
+ message: "Invalid value: Expected uint32 to be <= 4294967295",
1420
+ })
1421
+ .nullish(),
1422
+ minLength: z
1423
+ .number()
1424
+ .int()
1425
+ .gte(0)
1426
+ .max(4294967295, {
1427
+ message: "Invalid value: Expected uint32 to be <= 4294967295",
1428
+ })
1429
+ .nullish(),
1430
+ oneOf: z.array(zEnumOption).nullish(),
1431
+ pattern: z.string().nullish(),
1432
+ title: z.string().nullish(),
1433
+ });
1036
1434
  /**
1037
1435
  * Embed a terminal created with `terminal/create` by its id.
1038
1436
  *
@@ -1040,56 +1438,56 @@ export const zStopReason = z.union([
1040
1438
  *
1041
1439
  * See protocol docs: [Terminal](https://agentclientprotocol.com/protocol/terminals)
1042
1440
  */
1043
- export const zTerminal = z.object({
1044
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1441
+ export const zTerminal = z.looseObject({
1442
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1045
1443
  terminalId: z.string(),
1046
1444
  });
1047
1445
  /**
1048
1446
  * Exit status of a terminal command.
1049
1447
  */
1050
- export const zTerminalExitStatus = z.object({
1051
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1448
+ export const zTerminalExitStatus = z.looseObject({
1449
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1052
1450
  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(),
1451
+ .number()
1452
+ .int()
1453
+ .gte(0)
1454
+ .max(4294967295, {
1455
+ message: "Invalid value: Expected uint32 to be <= 4294967295",
1456
+ })
1457
+ .nullish(),
1458
+ signal: z.string().nullish(),
1061
1459
  });
1062
1460
  /**
1063
1461
  * Request to get the current output and status of a terminal.
1064
1462
  */
1065
- export const zTerminalOutputRequest = z.object({
1066
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1463
+ export const zTerminalOutputRequest = z.looseObject({
1464
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1067
1465
  sessionId: zSessionId,
1068
1466
  terminalId: z.string(),
1069
1467
  });
1070
1468
  /**
1071
1469
  * Response containing the terminal output and exit status.
1072
1470
  */
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(),
1471
+ export const zTerminalOutputResponse = z.looseObject({
1472
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1473
+ exitStatus: zTerminalExitStatus.nullish(),
1076
1474
  output: z.string(),
1077
1475
  truncated: z.boolean(),
1078
1476
  });
1079
1477
  /**
1080
1478
  * Text provided to or from an LLM.
1081
1479
  */
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(),
1480
+ export const zTextContent = z.looseObject({
1481
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1482
+ annotations: zAnnotations.nullish(),
1085
1483
  text: z.string(),
1086
1484
  });
1087
1485
  /**
1088
1486
  * Text-based resource contents.
1089
1487
  */
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(),
1488
+ export const zTextResourceContents = z.looseObject({
1489
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1490
+ mimeType: z.string().nullish(),
1093
1491
  text: z.string(),
1094
1492
  uri: z.string(),
1095
1493
  });
@@ -1103,9 +1501,9 @@ export const zEmbeddedResourceResource = z.union([
1103
1501
  /**
1104
1502
  * The contents of a resource, embedded into a prompt or tool call result.
1105
1503
  */
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(),
1504
+ export const zEmbeddedResource = z.looseObject({
1505
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1506
+ annotations: zAnnotations.nullish(),
1109
1507
  resource: zEmbeddedResourceResource,
1110
1508
  });
1111
1509
  /**
@@ -1125,35 +1523,36 @@ export const zEmbeddedResource = z.object({
1125
1523
  * See protocol docs: [Content](https://agentclientprotocol.com/protocol/content)
1126
1524
  */
1127
1525
  export const zContentBlock = z.union([
1128
- zTextContent.and(z.object({
1526
+ zTextContent.and(z.looseObject({
1129
1527
  type: z.literal("text"),
1130
1528
  })),
1131
- zImageContent.and(z.object({
1529
+ zImageContent.and(z.looseObject({
1132
1530
  type: z.literal("image"),
1133
1531
  })),
1134
- zAudioContent.and(z.object({
1532
+ zAudioContent.and(z.looseObject({
1135
1533
  type: z.literal("audio"),
1136
1534
  })),
1137
- zResourceLink.and(z.object({
1535
+ zResourceLink.and(z.looseObject({
1138
1536
  type: z.literal("resource_link"),
1139
1537
  })),
1140
- zEmbeddedResource.and(z.object({
1538
+ zEmbeddedResource.and(z.looseObject({
1141
1539
  type: z.literal("resource"),
1142
1540
  })),
1143
1541
  ]);
1144
1542
  /**
1145
1543
  * Standard content block (text, images, resources).
1146
1544
  */
1147
- export const zContent = z.object({
1148
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1545
+ export const zContent = z.looseObject({
1546
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1149
1547
  content: zContentBlock,
1150
1548
  });
1151
1549
  /**
1152
1550
  * A streamed item of content
1153
1551
  */
1154
- export const zContentChunk = z.object({
1155
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1552
+ export const zContentChunk = z.looseObject({
1553
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1156
1554
  content: zContentBlock,
1555
+ messageId: z.string().nullish(),
1157
1556
  });
1158
1557
  /**
1159
1558
  * Request parameters for sending a user prompt to the agent.
@@ -1162,33 +1561,39 @@ export const zContentChunk = z.object({
1162
1561
  *
1163
1562
  * See protocol docs: [User Message](https://agentclientprotocol.com/protocol/prompt-turn#1-user-message)
1164
1563
  */
1165
- export const zPromptRequest = z.object({
1166
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1564
+ export const zPromptRequest = z.looseObject({
1565
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1566
+ messageId: z.string().nullish(),
1167
1567
  prompt: z.array(zContentBlock),
1168
1568
  sessionId: zSessionId,
1169
1569
  });
1170
- export const zClientRequest = z.object({
1570
+ export const zClientRequest = z.looseObject({
1171
1571
  id: zRequestId,
1172
1572
  method: z.string(),
1173
1573
  params: z
1174
1574
  .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(),
1575
+ zInitializeRequest,
1576
+ zAuthenticateRequest,
1577
+ zLogoutRequest,
1578
+ zNewSessionRequest,
1579
+ zLoadSessionRequest,
1580
+ zListSessionsRequest,
1581
+ zForkSessionRequest,
1582
+ zResumeSessionRequest,
1583
+ zCloseSessionRequest,
1584
+ zSetSessionModeRequest,
1585
+ zSetSessionConfigOptionRequest,
1586
+ zPromptRequest,
1587
+ zSetSessionModelRequest,
1588
+ zExtRequest,
1190
1589
  ])
1191
- .optional(),
1590
+ .nullish(),
1591
+ });
1592
+ /**
1593
+ * Items definition for titled multi-select enum properties.
1594
+ */
1595
+ export const zTitledMultiSelectItems = z.looseObject({
1596
+ anyOf: z.array(zEnumOption),
1192
1597
  });
1193
1598
  /**
1194
1599
  * Content produced by a tool call.
@@ -1199,13 +1604,13 @@ export const zClientRequest = z.object({
1199
1604
  * See protocol docs: [Content](https://agentclientprotocol.com/protocol/tool-calls#content)
1200
1605
  */
1201
1606
  export const zToolCallContent = z.union([
1202
- zContent.and(z.object({
1607
+ zContent.and(z.looseObject({
1203
1608
  type: z.literal("content"),
1204
1609
  })),
1205
- zDiff.and(z.object({
1610
+ zDiff.and(z.looseObject({
1206
1611
  type: z.literal("diff"),
1207
1612
  })),
1208
- zTerminal.and(z.object({
1613
+ zTerminal.and(z.looseObject({
1209
1614
  type: z.literal("terminal"),
1210
1615
  })),
1211
1616
  ]);
@@ -1221,16 +1626,16 @@ export const zToolCallId = z.string();
1221
1626
  *
1222
1627
  * See protocol docs: [Following the Agent](https://agentclientprotocol.com/protocol/tool-calls#following-the-agent)
1223
1628
  */
1224
- export const zToolCallLocation = z.object({
1225
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1629
+ export const zToolCallLocation = z.looseObject({
1630
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1226
1631
  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(),
1632
+ .number()
1633
+ .int()
1634
+ .gte(0)
1635
+ .max(4294967295, {
1636
+ message: "Invalid value: Expected uint32 to be <= 4294967295",
1637
+ })
1638
+ .nullish(),
1234
1639
  path: z.string(),
1235
1640
  });
1236
1641
  /**
@@ -1274,8 +1679,8 @@ export const zToolKind = z.union([
1274
1679
  *
1275
1680
  * See protocol docs: [Tool Calls](https://agentclientprotocol.com/protocol/tool-calls)
1276
1681
  */
1277
- export const zToolCall = z.object({
1278
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1682
+ export const zToolCall = z.looseObject({
1683
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1279
1684
  content: z.array(zToolCallContent).optional(),
1280
1685
  kind: zToolKind.optional(),
1281
1686
  locations: z.array(zToolCallLocation).optional(),
@@ -1293,15 +1698,15 @@ export const zToolCall = z.object({
1293
1698
  *
1294
1699
  * See protocol docs: [Updating](https://agentclientprotocol.com/protocol/tool-calls#updating)
1295
1700
  */
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(),
1701
+ export const zToolCallUpdate = z.looseObject({
1702
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1703
+ content: z.array(zToolCallContent).nullish(),
1704
+ kind: zToolKind.nullish(),
1705
+ locations: z.array(zToolCallLocation).nullish(),
1301
1706
  rawInput: z.unknown().optional(),
1302
1707
  rawOutput: z.unknown().optional(),
1303
- status: z.union([zToolCallStatus, z.null()]).optional(),
1304
- title: z.union([z.string(), z.null()]).optional(),
1708
+ status: zToolCallStatus.nullish(),
1709
+ title: z.string().nullish(),
1305
1710
  toolCallId: zToolCallId,
1306
1711
  });
1307
1712
  /**
@@ -1311,8 +1716,8 @@ export const zToolCallUpdate = z.object({
1311
1716
  *
1312
1717
  * See protocol docs: [Requesting Permission](https://agentclientprotocol.com/protocol/tool-calls#requesting-permission)
1313
1718
  */
1314
- export const zRequestPermissionRequest = z.object({
1315
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1719
+ export const zRequestPermissionRequest = z.looseObject({
1720
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1316
1721
  options: z.array(zPermissionOption),
1317
1722
  sessionId: zSessionId,
1318
1723
  toolCall: zToolCallUpdate,
@@ -1320,8 +1725,8 @@ export const zRequestPermissionRequest = z.object({
1320
1725
  /**
1321
1726
  * All text that was typed after the command name is provided as input.
1322
1727
  */
1323
- export const zUnstructuredCommandInput = z.object({
1324
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1728
+ export const zUnstructuredCommandInput = z.looseObject({
1729
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1325
1730
  hint: z.string(),
1326
1731
  });
1327
1732
  /**
@@ -1333,19 +1738,108 @@ export const zAvailableCommandInput = zUnstructuredCommandInput;
1333
1738
  /**
1334
1739
  * Information about a command.
1335
1740
  */
1336
- export const zAvailableCommand = z.object({
1337
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1741
+ export const zAvailableCommand = z.looseObject({
1742
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1338
1743
  description: z.string(),
1339
- input: z.union([zAvailableCommandInput, z.null()]).optional(),
1744
+ input: zAvailableCommandInput.nullish(),
1340
1745
  name: z.string(),
1341
1746
  });
1342
1747
  /**
1343
1748
  * Available commands are ready or have changed
1344
1749
  */
1345
- export const zAvailableCommandsUpdate = z.object({
1346
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1750
+ export const zAvailableCommandsUpdate = z.looseObject({
1751
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1347
1752
  availableCommands: z.array(zAvailableCommand),
1348
1753
  });
1754
+ /**
1755
+ * Items definition for untitled multi-select enum properties.
1756
+ */
1757
+ export const zUntitledMultiSelectItems = z.looseObject({
1758
+ enum: z.array(z.string()),
1759
+ type: zElicitationStringType,
1760
+ });
1761
+ /**
1762
+ * Items for a multi-select (array) property schema.
1763
+ */
1764
+ export const zMultiSelectItems = z.union([
1765
+ zUntitledMultiSelectItems,
1766
+ zTitledMultiSelectItems,
1767
+ ]);
1768
+ /**
1769
+ * Schema for multi-select (array) properties in an elicitation form.
1770
+ */
1771
+ export const zMultiSelectPropertySchema = z.looseObject({
1772
+ default: z.array(z.string()).nullish(),
1773
+ description: z.string().nullish(),
1774
+ items: zMultiSelectItems,
1775
+ maxItems: z.number().nullish(),
1776
+ minItems: z.number().nullish(),
1777
+ title: z.string().nullish(),
1778
+ });
1779
+ /**
1780
+ * Property schema for elicitation form fields.
1781
+ *
1782
+ * Each variant corresponds to a JSON Schema `"type"` value.
1783
+ * Single-select enums use the `String` variant with `enum` or `oneOf` set.
1784
+ * Multi-select enums use the `Array` variant.
1785
+ */
1786
+ export const zElicitationPropertySchema = z.union([
1787
+ zStringPropertySchema.and(z.looseObject({
1788
+ type: z.literal("string"),
1789
+ })),
1790
+ zNumberPropertySchema.and(z.looseObject({
1791
+ type: z.literal("number"),
1792
+ })),
1793
+ zIntegerPropertySchema.and(z.looseObject({
1794
+ type: z.literal("integer"),
1795
+ })),
1796
+ zBooleanPropertySchema.and(z.looseObject({
1797
+ type: z.literal("boolean"),
1798
+ })),
1799
+ zMultiSelectPropertySchema.and(z.looseObject({
1800
+ type: z.literal("array"),
1801
+ })),
1802
+ ]);
1803
+ /**
1804
+ * Type-safe elicitation schema for requesting structured user input.
1805
+ *
1806
+ * This represents a JSON Schema object with primitive-typed properties,
1807
+ * as required by the elicitation specification.
1808
+ */
1809
+ export const zElicitationSchema = z.looseObject({
1810
+ description: z.string().nullish(),
1811
+ properties: z
1812
+ .record(z.string(), zElicitationPropertySchema)
1813
+ .optional()
1814
+ .default({}),
1815
+ required: z.array(z.string()).nullish(),
1816
+ title: z.string().nullish(),
1817
+ type: zElicitationSchemaType.optional().default("object"),
1818
+ });
1819
+ /**
1820
+ * **UNSTABLE**
1821
+ *
1822
+ * This capability is not part of the spec yet, and may be removed or changed at any point.
1823
+ *
1824
+ * Form-based elicitation mode where the client renders a form from the provided schema.
1825
+ *
1826
+ * @experimental
1827
+ */
1828
+ export const zElicitationFormMode = z.looseObject({
1829
+ requestedSchema: zElicitationSchema,
1830
+ });
1831
+ export const zElicitationRequest = z.intersection(z.union([
1832
+ zElicitationFormMode.and(z.looseObject({
1833
+ mode: z.literal("form"),
1834
+ })),
1835
+ zElicitationUrlMode.and(z.looseObject({
1836
+ mode: z.literal("url"),
1837
+ })),
1838
+ ]), z.looseObject({
1839
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1840
+ message: z.string(),
1841
+ sessionId: zSessionId,
1842
+ }));
1349
1843
  /**
1350
1844
  * **UNSTABLE**
1351
1845
  *
@@ -1355,12 +1849,12 @@ export const zAvailableCommandsUpdate = z.object({
1355
1849
  *
1356
1850
  * @experimental
1357
1851
  */
1358
- export const zUsage = z.object({
1359
- cachedReadTokens: z.union([z.number(), z.null()]).optional(),
1360
- cachedWriteTokens: z.union([z.number(), z.null()]).optional(),
1852
+ export const zUsage = z.looseObject({
1853
+ cachedReadTokens: z.number().nullish(),
1854
+ cachedWriteTokens: z.number().nullish(),
1361
1855
  inputTokens: z.number(),
1362
1856
  outputTokens: z.number(),
1363
- thoughtTokens: z.union([z.number(), z.null()]).optional(),
1857
+ thoughtTokens: z.number().nullish(),
1364
1858
  totalTokens: z.number(),
1365
1859
  });
1366
1860
  /**
@@ -1368,22 +1862,25 @@ export const zUsage = z.object({
1368
1862
  *
1369
1863
  * See protocol docs: [Check for Completion](https://agentclientprotocol.com/protocol/prompt-turn#4-check-for-completion)
1370
1864
  */
1371
- export const zPromptResponse = z.object({
1372
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1865
+ export const zPromptResponse = z.looseObject({
1866
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1373
1867
  stopReason: zStopReason,
1374
- usage: z.union([zUsage, z.null()]).optional(),
1868
+ usage: zUsage.nullish(),
1869
+ userMessageId: z.string().nullish(),
1375
1870
  });
1376
1871
  export const zAgentResponse = z.union([
1377
- z.object({
1872
+ z.looseObject({
1378
1873
  id: zRequestId,
1379
1874
  result: z.union([
1380
1875
  zInitializeResponse,
1381
1876
  zAuthenticateResponse,
1877
+ zLogoutResponse,
1382
1878
  zNewSessionResponse,
1383
1879
  zLoadSessionResponse,
1384
1880
  zListSessionsResponse,
1385
1881
  zForkSessionResponse,
1386
1882
  zResumeSessionResponse,
1883
+ zCloseSessionResponse,
1387
1884
  zSetSessionModeResponse,
1388
1885
  zSetSessionConfigOptionResponse,
1389
1886
  zPromptResponse,
@@ -1391,7 +1888,7 @@ export const zAgentResponse = z.union([
1391
1888
  zExtResponse,
1392
1889
  ]),
1393
1890
  }),
1394
- z.object({
1891
+ z.looseObject({
1395
1892
  error: zError,
1396
1893
  id: zRequestId,
1397
1894
  }),
@@ -1405,9 +1902,9 @@ export const zAgentResponse = z.union([
1405
1902
  *
1406
1903
  * @experimental
1407
1904
  */
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(),
1905
+ export const zUsageUpdate = z.looseObject({
1906
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1907
+ cost: zCost.nullish(),
1411
1908
  size: z.number(),
1412
1909
  used: z.number(),
1413
1910
  });
@@ -1419,37 +1916,37 @@ export const zUsageUpdate = z.object({
1419
1916
  * See protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/prompt-turn#3-agent-reports-output)
1420
1917
  */
1421
1918
  export const zSessionUpdate = z.union([
1422
- zContentChunk.and(z.object({
1919
+ zContentChunk.and(z.looseObject({
1423
1920
  sessionUpdate: z.literal("user_message_chunk"),
1424
1921
  })),
1425
- zContentChunk.and(z.object({
1922
+ zContentChunk.and(z.looseObject({
1426
1923
  sessionUpdate: z.literal("agent_message_chunk"),
1427
1924
  })),
1428
- zContentChunk.and(z.object({
1925
+ zContentChunk.and(z.looseObject({
1429
1926
  sessionUpdate: z.literal("agent_thought_chunk"),
1430
1927
  })),
1431
- zToolCall.and(z.object({
1928
+ zToolCall.and(z.looseObject({
1432
1929
  sessionUpdate: z.literal("tool_call"),
1433
1930
  })),
1434
- zToolCallUpdate.and(z.object({
1931
+ zToolCallUpdate.and(z.looseObject({
1435
1932
  sessionUpdate: z.literal("tool_call_update"),
1436
1933
  })),
1437
- zPlan.and(z.object({
1934
+ zPlan.and(z.looseObject({
1438
1935
  sessionUpdate: z.literal("plan"),
1439
1936
  })),
1440
- zAvailableCommandsUpdate.and(z.object({
1937
+ zAvailableCommandsUpdate.and(z.looseObject({
1441
1938
  sessionUpdate: z.literal("available_commands_update"),
1442
1939
  })),
1443
- zCurrentModeUpdate.and(z.object({
1940
+ zCurrentModeUpdate.and(z.looseObject({
1444
1941
  sessionUpdate: z.literal("current_mode_update"),
1445
1942
  })),
1446
- zConfigOptionUpdate.and(z.object({
1943
+ zConfigOptionUpdate.and(z.looseObject({
1447
1944
  sessionUpdate: z.literal("config_option_update"),
1448
1945
  })),
1449
- zSessionInfoUpdate.and(z.object({
1946
+ zSessionInfoUpdate.and(z.looseObject({
1450
1947
  sessionUpdate: z.literal("session_info_update"),
1451
1948
  })),
1452
- zUsageUpdate.and(z.object({
1949
+ zUsageUpdate.and(z.looseObject({
1453
1950
  sessionUpdate: z.literal("usage_update"),
1454
1951
  })),
1455
1952
  ]);
@@ -1460,79 +1957,81 @@ export const zSessionUpdate = z.union([
1460
1957
  *
1461
1958
  * See protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/prompt-turn#3-agent-reports-output)
1462
1959
  */
1463
- export const zSessionNotification = z.object({
1464
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1960
+ export const zSessionNotification = z.looseObject({
1961
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1465
1962
  sessionId: zSessionId,
1466
1963
  update: zSessionUpdate,
1467
1964
  });
1468
- export const zAgentNotification = z.object({
1965
+ export const zAgentNotification = z.looseObject({
1469
1966
  method: z.string(),
1470
1967
  params: z
1471
- .union([z.union([zSessionNotification, zExtNotification]), z.null()])
1472
- .optional(),
1968
+ .union([
1969
+ zSessionNotification,
1970
+ zElicitationCompleteNotification,
1971
+ zExtNotification,
1972
+ ])
1973
+ .nullish(),
1473
1974
  });
1474
1975
  /**
1475
1976
  * Request to wait for a terminal command to exit.
1476
1977
  */
1477
- export const zWaitForTerminalExitRequest = z.object({
1478
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1978
+ export const zWaitForTerminalExitRequest = z.looseObject({
1979
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1479
1980
  sessionId: zSessionId,
1480
1981
  terminalId: z.string(),
1481
1982
  });
1482
1983
  /**
1483
1984
  * Response containing the exit status of a terminal command.
1484
1985
  */
1485
- export const zWaitForTerminalExitResponse = z.object({
1486
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
1986
+ export const zWaitForTerminalExitResponse = z.looseObject({
1987
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1487
1988
  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(),
1989
+ .number()
1990
+ .int()
1991
+ .gte(0)
1992
+ .max(4294967295, {
1993
+ message: "Invalid value: Expected uint32 to be <= 4294967295",
1994
+ })
1995
+ .nullish(),
1996
+ signal: z.string().nullish(),
1496
1997
  });
1497
1998
  /**
1498
1999
  * Request to write content to a text file.
1499
2000
  *
1500
2001
  * Only available if the client supports the `fs.writeTextFile` capability.
1501
2002
  */
1502
- export const zWriteTextFileRequest = z.object({
1503
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
2003
+ export const zWriteTextFileRequest = z.looseObject({
2004
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1504
2005
  content: z.string(),
1505
2006
  path: z.string(),
1506
2007
  sessionId: zSessionId,
1507
2008
  });
1508
- export const zAgentRequest = z.object({
2009
+ export const zAgentRequest = z.looseObject({
1509
2010
  id: zRequestId,
1510
2011
  method: z.string(),
1511
2012
  params: z
1512
2013
  .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(),
2014
+ zWriteTextFileRequest,
2015
+ zReadTextFileRequest,
2016
+ zRequestPermissionRequest,
2017
+ zCreateTerminalRequest,
2018
+ zTerminalOutputRequest,
2019
+ zReleaseTerminalRequest,
2020
+ zWaitForTerminalExitRequest,
2021
+ zKillTerminalRequest,
2022
+ zElicitationRequest,
2023
+ zExtRequest,
1525
2024
  ])
1526
- .optional(),
2025
+ .nullish(),
1527
2026
  });
1528
2027
  /**
1529
2028
  * Response to `fs/write_text_file`
1530
2029
  */
1531
- export const zWriteTextFileResponse = z.object({
1532
- _meta: z.union([z.record(z.string(), z.unknown()), z.null()]).optional(),
2030
+ export const zWriteTextFileResponse = z.looseObject({
2031
+ _meta: z.record(z.string(), z.unknown()).nullish(),
1533
2032
  });
1534
2033
  export const zClientResponse = z.union([
1535
- z.object({
2034
+ z.looseObject({
1536
2035
  id: zRequestId,
1537
2036
  result: z.union([
1538
2037
  zWriteTextFileResponse,
@@ -1542,11 +2041,12 @@ export const zClientResponse = z.union([
1542
2041
  zTerminalOutputResponse,
1543
2042
  zReleaseTerminalResponse,
1544
2043
  zWaitForTerminalExitResponse,
1545
- zKillTerminalCommandResponse,
2044
+ zKillTerminalResponse,
2045
+ zElicitationResponse,
1546
2046
  zExtResponse,
1547
2047
  ]),
1548
2048
  }),
1549
- z.object({
2049
+ z.looseObject({
1550
2050
  error: zError,
1551
2051
  id: zRequestId,
1552
2052
  }),