agenthooksprotocol 0.0.0-bootstrap.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +29 -0
  3. package/dist/src/client/auth.d.ts +147 -0
  4. package/dist/src/client/auth.d.ts.map +1 -0
  5. package/dist/src/client/auth.js +629 -0
  6. package/dist/src/client/auth.js.map +1 -0
  7. package/dist/src/client/composition.d.ts +42 -0
  8. package/dist/src/client/composition.d.ts.map +1 -0
  9. package/dist/src/client/composition.js +523 -0
  10. package/dist/src/client/composition.js.map +1 -0
  11. package/dist/src/client/content.d.ts +73 -0
  12. package/dist/src/client/content.d.ts.map +1 -0
  13. package/dist/src/client/content.js +404 -0
  14. package/dist/src/client/content.js.map +1 -0
  15. package/dist/src/client/hooks.d.ts +62 -0
  16. package/dist/src/client/hooks.d.ts.map +1 -0
  17. package/dist/src/client/hooks.js +997 -0
  18. package/dist/src/client/hooks.js.map +1 -0
  19. package/dist/src/client/index.d.ts +11 -0
  20. package/dist/src/client/index.d.ts.map +1 -0
  21. package/dist/src/client/index.js +9 -0
  22. package/dist/src/client/index.js.map +1 -0
  23. package/dist/src/client/transport.d.ts +12 -0
  24. package/dist/src/client/transport.d.ts.map +1 -0
  25. package/dist/src/client/transport.js +347 -0
  26. package/dist/src/client/transport.js.map +1 -0
  27. package/dist/src/client/types.d.ts +117 -0
  28. package/dist/src/client/types.d.ts.map +1 -0
  29. package/dist/src/client/types.js +10 -0
  30. package/dist/src/client/types.js.map +1 -0
  31. package/dist/src/client/validation.d.ts +3 -0
  32. package/dist/src/client/validation.d.ts.map +1 -0
  33. package/dist/src/client/validation.js +25 -0
  34. package/dist/src/client/validation.js.map +1 -0
  35. package/dist/src/compaction.d.ts +27 -0
  36. package/dist/src/compaction.d.ts.map +1 -0
  37. package/dist/src/compaction.js +155 -0
  38. package/dist/src/compaction.js.map +1 -0
  39. package/dist/src/content-upload.d.ts +60 -0
  40. package/dist/src/content-upload.d.ts.map +1 -0
  41. package/dist/src/content-upload.js +129 -0
  42. package/dist/src/content-upload.js.map +1 -0
  43. package/dist/src/draft/generated.d.ts +3085 -0
  44. package/dist/src/draft/generated.d.ts.map +1 -0
  45. package/dist/src/draft/generated.js +15372 -0
  46. package/dist/src/draft/generated.js.map +1 -0
  47. package/dist/src/draft/index.d.ts +31 -0
  48. package/dist/src/draft/index.d.ts.map +1 -0
  49. package/dist/src/draft/index.js +129 -0
  50. package/dist/src/draft/index.js.map +1 -0
  51. package/dist/src/draft/schemas.d.ts +8848 -0
  52. package/dist/src/draft/schemas.d.ts.map +1 -0
  53. package/dist/src/draft/schemas.js +9219 -0
  54. package/dist/src/draft/schemas.js.map +1 -0
  55. package/dist/src/draft-atomic.d.ts +18 -0
  56. package/dist/src/draft-atomic.d.ts.map +1 -0
  57. package/dist/src/draft-atomic.js +102 -0
  58. package/dist/src/draft-atomic.js.map +1 -0
  59. package/dist/src/draft-runtime.d.ts +89 -0
  60. package/dist/src/draft-runtime.d.ts.map +1 -0
  61. package/dist/src/draft-runtime.js +242 -0
  62. package/dist/src/draft-runtime.js.map +1 -0
  63. package/dist/src/elicitation.d.ts +18 -0
  64. package/dist/src/elicitation.d.ts.map +1 -0
  65. package/dist/src/elicitation.js +191 -0
  66. package/dist/src/elicitation.js.map +1 -0
  67. package/dist/src/errors.d.ts +7 -0
  68. package/dist/src/errors.d.ts.map +1 -0
  69. package/dist/src/errors.js +15 -0
  70. package/dist/src/errors.js.map +1 -0
  71. package/dist/src/framing.d.ts +7 -0
  72. package/dist/src/framing.d.ts.map +1 -0
  73. package/dist/src/framing.js +39 -0
  74. package/dist/src/framing.js.map +1 -0
  75. package/dist/src/generated.d.ts +304 -0
  76. package/dist/src/generated.d.ts.map +1 -0
  77. package/dist/src/generated.js +1885 -0
  78. package/dist/src/generated.js.map +1 -0
  79. package/dist/src/hook-runner.d.ts +11 -0
  80. package/dist/src/hook-runner.d.ts.map +1 -0
  81. package/dist/src/hook-runner.js +223 -0
  82. package/dist/src/hook-runner.js.map +1 -0
  83. package/dist/src/index.d.ts +8 -0
  84. package/dist/src/index.d.ts.map +1 -0
  85. package/dist/src/index.js +8 -0
  86. package/dist/src/index.js.map +1 -0
  87. package/dist/src/observation.d.ts +26 -0
  88. package/dist/src/observation.d.ts.map +1 -0
  89. package/dist/src/observation.js +28 -0
  90. package/dist/src/observation.js.map +1 -0
  91. package/dist/src/server/attachments.d.ts +29 -0
  92. package/dist/src/server/attachments.d.ts.map +1 -0
  93. package/dist/src/server/attachments.js +112 -0
  94. package/dist/src/server/attachments.js.map +1 -0
  95. package/dist/src/server/hooks.d.ts +20 -0
  96. package/dist/src/server/hooks.d.ts.map +1 -0
  97. package/dist/src/server/hooks.js +129 -0
  98. package/dist/src/server/hooks.js.map +1 -0
  99. package/dist/src/server/index.d.ts +7 -0
  100. package/dist/src/server/index.d.ts.map +1 -0
  101. package/dist/src/server/index.js +4 -0
  102. package/dist/src/server/index.js.map +1 -0
  103. package/dist/src/server/stdio.d.ts +15 -0
  104. package/dist/src/server/stdio.d.ts.map +1 -0
  105. package/dist/src/server/stdio.js +69 -0
  106. package/dist/src/server/stdio.js.map +1 -0
  107. package/dist/src/transport.d.ts +7 -0
  108. package/dist/src/transport.d.ts.map +1 -0
  109. package/dist/src/transport.js +195 -0
  110. package/dist/src/transport.js.map +1 -0
  111. package/dist/src/types.d.ts +116 -0
  112. package/dist/src/types.d.ts.map +1 -0
  113. package/dist/src/types.js +14 -0
  114. package/dist/src/types.js.map +1 -0
  115. package/dist/src/validation.d.ts +7 -0
  116. package/dist/src/validation.d.ts.map +1 -0
  117. package/dist/src/validation.js +209 -0
  118. package/dist/src/validation.js.map +1 -0
  119. package/package.json +64 -0
  120. package/src/client/auth.ts +1076 -0
  121. package/src/client/composition.ts +708 -0
  122. package/src/client/content.ts +510 -0
  123. package/src/client/hooks.ts +1368 -0
  124. package/src/client/index.ts +28 -0
  125. package/src/client/transport.ts +408 -0
  126. package/src/client/types.ts +173 -0
  127. package/src/client/validation.ts +24 -0
  128. package/src/compaction.ts +196 -0
  129. package/src/content-upload.ts +205 -0
  130. package/src/draft/README.md +16 -0
  131. package/src/draft/ahp-codegen.lock.json +123 -0
  132. package/src/draft/generated.ts +19143 -0
  133. package/src/draft/index.ts +246 -0
  134. package/src/draft/schemas.ts +9413 -0
  135. package/src/draft-atomic.ts +119 -0
  136. package/src/draft-runtime.ts +365 -0
  137. package/src/elicitation.ts +254 -0
  138. package/src/errors.ts +30 -0
  139. package/src/framing.ts +56 -0
  140. package/src/generated.ts +2408 -0
  141. package/src/hook-runner.ts +310 -0
  142. package/src/index.ts +8 -0
  143. package/src/observation.ts +65 -0
  144. package/src/server/attachments.ts +128 -0
  145. package/src/server/hooks.ts +205 -0
  146. package/src/server/index.ts +18 -0
  147. package/src/server/node-crypto.d.ts +7 -0
  148. package/src/server/stdio.ts +81 -0
  149. package/src/transport.ts +273 -0
  150. package/src/types.ts +124 -0
  151. package/src/validation.ts +372 -0
@@ -0,0 +1,2408 @@
1
+ // Generated by ahp-codegen. DO NOT EDIT.
2
+ // Generated from AHP schema draft.
3
+ // The source schema is authoritative if this output conflicts with it.
4
+
5
+ export const SCHEMA_REVISION = "draft" as const;
6
+ export const PROTOCOL_VERSION = "draft" as const;
7
+
8
+ export type JsonPrimitive = null | boolean | number | string;
9
+ export type JsonValue =
10
+ | JsonPrimitive
11
+ | JsonValue[]
12
+ | { [key: string]: JsonValue };
13
+ export type AdditionalProperties = { [key: string]: JsonValue };
14
+ export type OpenString<Known extends string> = Known | (string & {});
15
+ export type UnknownVariant<Discriminator extends string> =
16
+ AdditionalProperties & { [Key in Discriminator]: string };
17
+
18
+ export interface ParseDiagnostic {
19
+ readonly path: string;
20
+ readonly code:
21
+ | "invalid_type"
22
+ | "missing_required"
23
+ | "literal_mismatch"
24
+ | "unknown_enum"
25
+ | "unknown_variant"
26
+ | "invalid_known_variant"
27
+ | "no_union_match"
28
+ | "ambiguous_union"
29
+ | "invalid_json";
30
+ readonly severity: "error" | "warning";
31
+ readonly message: string;
32
+ }
33
+
34
+ export type ParseResult<T> =
35
+ | {
36
+ readonly ok: true;
37
+ readonly value: T;
38
+ readonly raw: JsonValue;
39
+ readonly diagnostics: readonly ParseDiagnostic[];
40
+ }
41
+ | {
42
+ readonly ok: false;
43
+ readonly raw?: JsonValue;
44
+ readonly diagnostics: readonly ParseDiagnostic[];
45
+ };
46
+
47
+ type SchemaNode =
48
+ | {
49
+ kind:
50
+ | "any"
51
+ | "never"
52
+ | "null"
53
+ | "boolean"
54
+ | "integer"
55
+ | "number"
56
+ | "string";
57
+ }
58
+ | { kind: "literal"; value: JsonValue }
59
+ | { kind: "enum"; values: JsonValue[]; open_strings: boolean }
60
+ | { kind: "array"; items: SchemaNode }
61
+ | {
62
+ kind: "object";
63
+ properties: Array<{
64
+ wire_name: string;
65
+ required: boolean;
66
+ shape: SchemaNode;
67
+ }>;
68
+ forbidden_property_sets: string[][];
69
+ additional: unknown;
70
+ }
71
+ | {
72
+ kind: "union";
73
+ mode: "anyOf" | "oneOf";
74
+ variants: SchemaNode[];
75
+ discriminator?: string;
76
+ }
77
+ | { kind: "intersection"; variants: SchemaNode[] }
78
+ | { kind: "ref"; name: string };
79
+
80
+ /** Source: schema/draft/registration.schema.json#/$defs/authentication */
81
+ export type Authentication = {
82
+ tokenEnv: string;
83
+ type: "bearer";
84
+ } & AdditionalProperties;
85
+
86
+ /** Source: schema/draft/registration.schema.json#/$defs/backend */
87
+ export type Backend = {
88
+ authentication?: Authentication;
89
+ id: ReverseDnsName;
90
+ subscriptions: Array<
91
+ InterceptSubscription | ObserveSubscription | UnknownVariant<"mode">
92
+ >;
93
+ transport: StdioTransport | HttpTransport | UnknownVariant<"type">;
94
+ } & AdditionalProperties;
95
+
96
+ /** Source: schema/draft/capabilities.schema.json# */
97
+ export type Capabilities = {
98
+ effects: Array<"deny" | string>;
99
+ } & AdditionalProperties;
100
+
101
+ /** Source: schema/draft/deny-effect.schema.json# */
102
+ export type DenyEffect = {
103
+ code?: string;
104
+ extensions?: Extensions;
105
+ reason: string;
106
+ type: "deny";
107
+ } & AdditionalProperties;
108
+
109
+ /** Source: schema/draft/extensions.schema.json# */
110
+ export type Extensions = {} & AdditionalProperties;
111
+
112
+ /** Source: schema/draft/registration.schema.json#/$defs/httpTransport */
113
+ export type HttpTransport = {
114
+ type: "http";
115
+ url: string;
116
+ } & AdditionalProperties;
117
+
118
+ /** Source: schema/draft/intercept-deny-response.schema.json# */
119
+ export type InterceptDenyResponse = JsonRpcSuccessResponse & {
120
+ result?: {
121
+ effects: Array<DenyEffect>;
122
+ extensions?: Extensions;
123
+ protocolVersion: ProtocolVersion;
124
+ } & AdditionalProperties;
125
+ } & AdditionalProperties;
126
+
127
+ /** Source: schema/draft/intercept-no-effect-response.schema.json# */
128
+ export type InterceptNoEffectResponse = JsonRpcSuccessResponse & {
129
+ result?: {
130
+ effects: Array<JsonValue>;
131
+ extensions?: Extensions;
132
+ protocolVersion: ProtocolVersion;
133
+ } & AdditionalProperties;
134
+ } & AdditionalProperties;
135
+
136
+ /** Source: schema/draft/intercept-request.schema.json# */
137
+ export type InterceptRequest = JsonRpcRequest & {
138
+ method?: "hooks/intercept";
139
+ params?: {
140
+ capabilities: Capabilities & {
141
+ effects?: JsonValue;
142
+ } & AdditionalProperties;
143
+ event: ToolBeforeEvent;
144
+ extensions?: Extensions;
145
+ protocolVersion: ProtocolVersion;
146
+ } & AdditionalProperties;
147
+ } & AdditionalProperties;
148
+
149
+ /** Source: schema/draft/registration.schema.json#/$defs/interceptSubscription */
150
+ export type InterceptSubscription = {
151
+ events: Array<"tool.before">;
152
+ failurePolicy: OpenString<"fail-open" | "fail-closed">;
153
+ includeNative?: boolean;
154
+ mode: "intercept";
155
+ timeoutMs: number;
156
+ } & AdditionalProperties;
157
+
158
+ /** Source: schema/draft/common.schema.json#/$defs/errorResponse */
159
+ export type JsonRpcErrorResponse = {
160
+ error: {
161
+ code: number;
162
+ data?: JsonValue;
163
+ message: string;
164
+ } & AdditionalProperties;
165
+ id: JsonRpcResponseId;
166
+ jsonrpc: "2.0";
167
+ } & AdditionalProperties;
168
+
169
+ /** Source: schema/draft/common.schema.json#/$defs/jsonRpcId */
170
+ export type JsonRpcId = string | number;
171
+
172
+ /** Source: schema/draft/json-rpc-message.schema.json# */
173
+ export type JsonRpcMessage =
174
+ | JsonRpcRequest
175
+ | JsonRpcNotification
176
+ | JsonRpcSuccessResponse
177
+ | JsonRpcErrorResponse;
178
+
179
+ /** Source: schema/draft/common.schema.json#/$defs/notification */
180
+ export type JsonRpcNotification = {
181
+ jsonrpc: "2.0";
182
+ method: string;
183
+ params: {} & AdditionalProperties;
184
+ } & AdditionalProperties;
185
+
186
+ /** Source: schema/draft/common.schema.json#/$defs/request */
187
+ export type JsonRpcRequest = {
188
+ id: JsonRpcId;
189
+ jsonrpc: "2.0";
190
+ method: string;
191
+ params: {} & AdditionalProperties;
192
+ } & AdditionalProperties;
193
+
194
+ /** Source: schema/draft/common.schema.json#/$defs/jsonRpcResponseId */
195
+ export type JsonRpcResponseId = JsonRpcId | null;
196
+
197
+ /** Source: schema/draft/common.schema.json#/$defs/successResponse */
198
+ export type JsonRpcSuccessResponse = {
199
+ id: JsonRpcResponseId;
200
+ jsonrpc: "2.0";
201
+ result: {} & AdditionalProperties;
202
+ } & AdditionalProperties;
203
+
204
+ /** Source: schema/draft/common.schema.json#/$defs/native */
205
+ export type NativeEvent = {
206
+ eventName: string;
207
+ payload: {} & AdditionalProperties;
208
+ provider: string;
209
+ } & AdditionalProperties;
210
+
211
+ /** Source: schema/draft/observe-notification.schema.json# */
212
+ export type ObserveNotification = JsonRpcNotification & {
213
+ method?: "hooks/observe";
214
+ params?: {
215
+ event:
216
+ | ToolBeforeEvent
217
+ | ToolAfterEvent
218
+ | ToolErrorEvent
219
+ | SessionStartEvent
220
+ | SessionEndEvent
221
+ | UnknownVariant<"type">;
222
+ protocolVersion: ProtocolVersion;
223
+ } & AdditionalProperties;
224
+ } & AdditionalProperties;
225
+
226
+ /** Source: schema/draft/registration.schema.json#/$defs/observeSubscription */
227
+ export type ObserveSubscription = {
228
+ events: Array<
229
+ OpenString<
230
+ | "tool.before"
231
+ | "tool.after"
232
+ | "tool.error"
233
+ | "session.start"
234
+ | "session.end"
235
+ >
236
+ >;
237
+ includeNative?: boolean;
238
+ mode: "observe";
239
+ } & AdditionalProperties;
240
+
241
+ /** Source: schema/draft/common.schema.json#/$defs/protocolVersion */
242
+ export type ProtocolVersion = "draft";
243
+
244
+ /** Source: schema/draft/registration.schema.json# */
245
+ export type Registration = {
246
+ hooks: Array<Backend>;
247
+ protocolVersion: ProtocolVersion;
248
+ } & AdditionalProperties;
249
+
250
+ /** Source: schema/draft/registration.schema.json#/$defs/reverseDns */
251
+ export type ReverseDnsName = string;
252
+
253
+ /** Source: schema/draft/common.schema.json#/$defs/session */
254
+ export type Session = {
255
+ agent?: {
256
+ id: string;
257
+ type?: string;
258
+ } & AdditionalProperties;
259
+ cwd?: string;
260
+ id: string;
261
+ model?: string;
262
+ workspaceRoots?: Array<string>;
263
+ } & AdditionalProperties;
264
+
265
+ /** Source: schema/draft/session-end.schema.json# */
266
+ export type SessionEndEvent = {
267
+ extensions?: Extensions;
268
+ id: string;
269
+ native?: NativeEvent;
270
+ outcome?: OpenString<"completed" | "cancelled" | "error" | "unknown">;
271
+ session: Session;
272
+ source: string;
273
+ time: string;
274
+ type: "session.end";
275
+ } & AdditionalProperties;
276
+
277
+ /** Source: schema/draft/session-start.schema.json# */
278
+ export type SessionStartEvent = {
279
+ extensions?: Extensions;
280
+ id: string;
281
+ native?: NativeEvent;
282
+ session: Session;
283
+ source: string;
284
+ time: string;
285
+ type: "session.start";
286
+ } & AdditionalProperties;
287
+
288
+ /** Source: schema/draft/registration.schema.json#/$defs/stdioTransport */
289
+ export type StdioTransport = {
290
+ args?: Array<string>;
291
+ command: string;
292
+ cwd?: string;
293
+ lifecycle: OpenString<"persistent" | "per_event">;
294
+ type: "stdio";
295
+ } & AdditionalProperties;
296
+
297
+ /** Source: schema/draft/tool-after.schema.json# */
298
+ export type ToolAfterEvent = {
299
+ extensions?: Extensions;
300
+ id: string;
301
+ native?: NativeEvent;
302
+ session: Session;
303
+ source: string;
304
+ time: string;
305
+ tool: {
306
+ callId: string;
307
+ input: {} & AdditionalProperties;
308
+ kind: OpenString<
309
+ | "shell"
310
+ | "file_read"
311
+ | "file_write"
312
+ | "file_edit"
313
+ | "search"
314
+ | "fetch"
315
+ | "task"
316
+ | "mcp"
317
+ | "other"
318
+ >;
319
+ mcp?: {} & AdditionalProperties;
320
+ name: string;
321
+ output?: JsonValue;
322
+ } & AdditionalProperties;
323
+ type: "tool.after";
324
+ } & AdditionalProperties;
325
+
326
+ /** Source: schema/draft/tool-before.schema.json# */
327
+ export type ToolBeforeEvent = {
328
+ extensions?: Extensions;
329
+ id: string;
330
+ native?: NativeEvent;
331
+ session: Session;
332
+ source: string;
333
+ time: string;
334
+ tool: {
335
+ callId: string;
336
+ input: {} & AdditionalProperties;
337
+ kind: OpenString<
338
+ | "shell"
339
+ | "file_read"
340
+ | "file_write"
341
+ | "file_edit"
342
+ | "search"
343
+ | "fetch"
344
+ | "task"
345
+ | "mcp"
346
+ | "other"
347
+ >;
348
+ mcp?: {} & AdditionalProperties;
349
+ name: string;
350
+ } & AdditionalProperties;
351
+ type: "tool.before";
352
+ } & AdditionalProperties;
353
+
354
+ /** Source: schema/draft/tool-error.schema.json# */
355
+ export type ToolErrorEvent = {
356
+ extensions?: Extensions;
357
+ id: string;
358
+ native?: NativeEvent;
359
+ session: Session;
360
+ source: string;
361
+ time: string;
362
+ tool: {
363
+ callId: string;
364
+ error: {
365
+ category?: JsonValue;
366
+ code?: JsonValue;
367
+ message: JsonValue;
368
+ } & AdditionalProperties;
369
+ input: {} & AdditionalProperties;
370
+ kind: OpenString<
371
+ | "shell"
372
+ | "file_read"
373
+ | "file_write"
374
+ | "file_edit"
375
+ | "search"
376
+ | "fetch"
377
+ | "task"
378
+ | "mcp"
379
+ | "other"
380
+ >;
381
+ mcp?: {} & AdditionalProperties;
382
+ name: string;
383
+ } & AdditionalProperties;
384
+ type: "tool.error";
385
+ } & AdditionalProperties;
386
+
387
+ /** Source: schema/draft/schema.json# */
388
+ export type WireMessage =
389
+ | InterceptRequest
390
+ | InterceptNoEffectResponse
391
+ | InterceptDenyResponse
392
+ | JsonRpcErrorResponse
393
+ | ObserveNotification;
394
+
395
+ const SCHEMAS: Record<string, SchemaNode> = {
396
+ Authentication: {
397
+ additional: {
398
+ kind: "allowed",
399
+ },
400
+ forbidden_property_sets: [["bearerToken"], ["token"], ["value"]],
401
+ kind: "object",
402
+ properties: [
403
+ {
404
+ required: true,
405
+ shape: {
406
+ kind: "string",
407
+ },
408
+ wire_name: "tokenEnv",
409
+ },
410
+ {
411
+ required: true,
412
+ shape: {
413
+ kind: "literal",
414
+ value: "bearer",
415
+ },
416
+ wire_name: "type",
417
+ },
418
+ ],
419
+ },
420
+ Backend: {
421
+ additional: {
422
+ kind: "allowed",
423
+ },
424
+ forbidden_property_sets: [],
425
+ kind: "object",
426
+ properties: [
427
+ {
428
+ required: false,
429
+ shape: {
430
+ kind: "ref",
431
+ name: "Authentication",
432
+ },
433
+ wire_name: "authentication",
434
+ },
435
+ {
436
+ required: true,
437
+ shape: {
438
+ kind: "ref",
439
+ name: "ReverseDnsName",
440
+ },
441
+ wire_name: "id",
442
+ },
443
+ {
444
+ required: true,
445
+ shape: {
446
+ items: {
447
+ discriminator: "mode",
448
+ kind: "union",
449
+ mode: "oneOf",
450
+ variants: [
451
+ {
452
+ kind: "ref",
453
+ name: "InterceptSubscription",
454
+ },
455
+ {
456
+ kind: "ref",
457
+ name: "ObserveSubscription",
458
+ },
459
+ ],
460
+ },
461
+ kind: "array",
462
+ },
463
+ wire_name: "subscriptions",
464
+ },
465
+ {
466
+ required: true,
467
+ shape: {
468
+ discriminator: "type",
469
+ kind: "union",
470
+ mode: "oneOf",
471
+ variants: [
472
+ {
473
+ kind: "ref",
474
+ name: "StdioTransport",
475
+ },
476
+ {
477
+ kind: "ref",
478
+ name: "HttpTransport",
479
+ },
480
+ ],
481
+ },
482
+ wire_name: "transport",
483
+ },
484
+ ],
485
+ },
486
+ Capabilities: {
487
+ additional: {
488
+ kind: "allowed",
489
+ },
490
+ forbidden_property_sets: [],
491
+ kind: "object",
492
+ properties: [
493
+ {
494
+ required: true,
495
+ shape: {
496
+ items: {
497
+ kind: "union",
498
+ mode: "anyOf",
499
+ variants: [
500
+ {
501
+ kind: "literal",
502
+ value: "deny",
503
+ },
504
+ {
505
+ kind: "string",
506
+ },
507
+ ],
508
+ },
509
+ kind: "array",
510
+ },
511
+ wire_name: "effects",
512
+ },
513
+ ],
514
+ },
515
+ DenyEffect: {
516
+ additional: {
517
+ kind: "allowed",
518
+ },
519
+ forbidden_property_sets: [],
520
+ kind: "object",
521
+ properties: [
522
+ {
523
+ required: false,
524
+ shape: {
525
+ kind: "string",
526
+ },
527
+ wire_name: "code",
528
+ },
529
+ {
530
+ required: false,
531
+ shape: {
532
+ kind: "ref",
533
+ name: "Extensions",
534
+ },
535
+ wire_name: "extensions",
536
+ },
537
+ {
538
+ required: true,
539
+ shape: {
540
+ kind: "string",
541
+ },
542
+ wire_name: "reason",
543
+ },
544
+ {
545
+ required: true,
546
+ shape: {
547
+ kind: "literal",
548
+ value: "deny",
549
+ },
550
+ wire_name: "type",
551
+ },
552
+ ],
553
+ },
554
+ Extensions: {
555
+ additional: {
556
+ kind: "allowed",
557
+ },
558
+ forbidden_property_sets: [],
559
+ kind: "object",
560
+ properties: [],
561
+ },
562
+ HttpTransport: {
563
+ additional: {
564
+ kind: "allowed",
565
+ },
566
+ forbidden_property_sets: [],
567
+ kind: "object",
568
+ properties: [
569
+ {
570
+ required: true,
571
+ shape: {
572
+ kind: "literal",
573
+ value: "http",
574
+ },
575
+ wire_name: "type",
576
+ },
577
+ {
578
+ required: true,
579
+ shape: {
580
+ kind: "string",
581
+ },
582
+ wire_name: "url",
583
+ },
584
+ ],
585
+ },
586
+ InterceptDenyResponse: {
587
+ kind: "intersection",
588
+ variants: [
589
+ {
590
+ kind: "ref",
591
+ name: "JsonRpcSuccessResponse",
592
+ },
593
+ {
594
+ additional: {
595
+ kind: "allowed",
596
+ },
597
+ forbidden_property_sets: [],
598
+ kind: "object",
599
+ properties: [
600
+ {
601
+ required: false,
602
+ shape: {
603
+ additional: {
604
+ kind: "allowed",
605
+ },
606
+ forbidden_property_sets: [],
607
+ kind: "object",
608
+ properties: [
609
+ {
610
+ required: true,
611
+ shape: {
612
+ items: {
613
+ kind: "ref",
614
+ name: "DenyEffect",
615
+ },
616
+ kind: "array",
617
+ },
618
+ wire_name: "effects",
619
+ },
620
+ {
621
+ required: false,
622
+ shape: {
623
+ kind: "ref",
624
+ name: "Extensions",
625
+ },
626
+ wire_name: "extensions",
627
+ },
628
+ {
629
+ required: true,
630
+ shape: {
631
+ kind: "ref",
632
+ name: "ProtocolVersion",
633
+ },
634
+ wire_name: "protocolVersion",
635
+ },
636
+ ],
637
+ },
638
+ wire_name: "result",
639
+ },
640
+ ],
641
+ },
642
+ ],
643
+ },
644
+ InterceptNoEffectResponse: {
645
+ kind: "intersection",
646
+ variants: [
647
+ {
648
+ kind: "ref",
649
+ name: "JsonRpcSuccessResponse",
650
+ },
651
+ {
652
+ additional: {
653
+ kind: "allowed",
654
+ },
655
+ forbidden_property_sets: [],
656
+ kind: "object",
657
+ properties: [
658
+ {
659
+ required: false,
660
+ shape: {
661
+ additional: {
662
+ kind: "allowed",
663
+ },
664
+ forbidden_property_sets: [],
665
+ kind: "object",
666
+ properties: [
667
+ {
668
+ required: true,
669
+ shape: {
670
+ items: {
671
+ kind: "any",
672
+ },
673
+ kind: "array",
674
+ },
675
+ wire_name: "effects",
676
+ },
677
+ {
678
+ required: false,
679
+ shape: {
680
+ kind: "ref",
681
+ name: "Extensions",
682
+ },
683
+ wire_name: "extensions",
684
+ },
685
+ {
686
+ required: true,
687
+ shape: {
688
+ kind: "ref",
689
+ name: "ProtocolVersion",
690
+ },
691
+ wire_name: "protocolVersion",
692
+ },
693
+ ],
694
+ },
695
+ wire_name: "result",
696
+ },
697
+ ],
698
+ },
699
+ ],
700
+ },
701
+ InterceptRequest: {
702
+ kind: "intersection",
703
+ variants: [
704
+ {
705
+ kind: "ref",
706
+ name: "JsonRpcRequest",
707
+ },
708
+ {
709
+ additional: {
710
+ kind: "allowed",
711
+ },
712
+ forbidden_property_sets: [],
713
+ kind: "object",
714
+ properties: [
715
+ {
716
+ required: false,
717
+ shape: {
718
+ kind: "literal",
719
+ value: "hooks/intercept",
720
+ },
721
+ wire_name: "method",
722
+ },
723
+ {
724
+ required: false,
725
+ shape: {
726
+ additional: {
727
+ kind: "allowed",
728
+ },
729
+ forbidden_property_sets: [],
730
+ kind: "object",
731
+ properties: [
732
+ {
733
+ required: true,
734
+ shape: {
735
+ kind: "intersection",
736
+ variants: [
737
+ {
738
+ kind: "ref",
739
+ name: "Capabilities",
740
+ },
741
+ {
742
+ additional: {
743
+ kind: "allowed",
744
+ },
745
+ forbidden_property_sets: [],
746
+ kind: "object",
747
+ properties: [
748
+ {
749
+ required: false,
750
+ shape: {
751
+ kind: "any",
752
+ },
753
+ wire_name: "effects",
754
+ },
755
+ ],
756
+ },
757
+ ],
758
+ },
759
+ wire_name: "capabilities",
760
+ },
761
+ {
762
+ required: true,
763
+ shape: {
764
+ kind: "ref",
765
+ name: "ToolBeforeEvent",
766
+ },
767
+ wire_name: "event",
768
+ },
769
+ {
770
+ required: false,
771
+ shape: {
772
+ kind: "ref",
773
+ name: "Extensions",
774
+ },
775
+ wire_name: "extensions",
776
+ },
777
+ {
778
+ required: true,
779
+ shape: {
780
+ kind: "ref",
781
+ name: "ProtocolVersion",
782
+ },
783
+ wire_name: "protocolVersion",
784
+ },
785
+ ],
786
+ },
787
+ wire_name: "params",
788
+ },
789
+ ],
790
+ },
791
+ ],
792
+ },
793
+ InterceptSubscription: {
794
+ additional: {
795
+ kind: "allowed",
796
+ },
797
+ forbidden_property_sets: [],
798
+ kind: "object",
799
+ properties: [
800
+ {
801
+ required: true,
802
+ shape: {
803
+ items: {
804
+ kind: "literal",
805
+ value: "tool.before",
806
+ },
807
+ kind: "array",
808
+ },
809
+ wire_name: "events",
810
+ },
811
+ {
812
+ required: true,
813
+ shape: {
814
+ kind: "enum",
815
+ open_strings: true,
816
+ values: ["fail-open", "fail-closed"],
817
+ },
818
+ wire_name: "failurePolicy",
819
+ },
820
+ {
821
+ required: false,
822
+ shape: {
823
+ kind: "boolean",
824
+ },
825
+ wire_name: "includeNative",
826
+ },
827
+ {
828
+ required: true,
829
+ shape: {
830
+ kind: "literal",
831
+ value: "intercept",
832
+ },
833
+ wire_name: "mode",
834
+ },
835
+ {
836
+ required: true,
837
+ shape: {
838
+ kind: "integer",
839
+ },
840
+ wire_name: "timeoutMs",
841
+ },
842
+ ],
843
+ },
844
+ JsonRpcErrorResponse: {
845
+ additional: {
846
+ kind: "allowed",
847
+ },
848
+ forbidden_property_sets: [["result"]],
849
+ kind: "object",
850
+ properties: [
851
+ {
852
+ required: true,
853
+ shape: {
854
+ additional: {
855
+ kind: "allowed",
856
+ },
857
+ forbidden_property_sets: [],
858
+ kind: "object",
859
+ properties: [
860
+ {
861
+ required: true,
862
+ shape: {
863
+ kind: "integer",
864
+ },
865
+ wire_name: "code",
866
+ },
867
+ {
868
+ required: false,
869
+ shape: {
870
+ kind: "any",
871
+ },
872
+ wire_name: "data",
873
+ },
874
+ {
875
+ required: true,
876
+ shape: {
877
+ kind: "string",
878
+ },
879
+ wire_name: "message",
880
+ },
881
+ ],
882
+ },
883
+ wire_name: "error",
884
+ },
885
+ {
886
+ required: true,
887
+ shape: {
888
+ kind: "ref",
889
+ name: "JsonRpcResponseId",
890
+ },
891
+ wire_name: "id",
892
+ },
893
+ {
894
+ required: true,
895
+ shape: {
896
+ kind: "literal",
897
+ value: "2.0",
898
+ },
899
+ wire_name: "jsonrpc",
900
+ },
901
+ ],
902
+ },
903
+ JsonRpcId: {
904
+ kind: "union",
905
+ mode: "anyOf",
906
+ variants: [
907
+ {
908
+ kind: "string",
909
+ },
910
+ {
911
+ kind: "integer",
912
+ },
913
+ ],
914
+ },
915
+ JsonRpcMessage: {
916
+ kind: "union",
917
+ mode: "oneOf",
918
+ variants: [
919
+ {
920
+ kind: "ref",
921
+ name: "JsonRpcRequest",
922
+ },
923
+ {
924
+ kind: "ref",
925
+ name: "JsonRpcNotification",
926
+ },
927
+ {
928
+ kind: "ref",
929
+ name: "JsonRpcSuccessResponse",
930
+ },
931
+ {
932
+ kind: "ref",
933
+ name: "JsonRpcErrorResponse",
934
+ },
935
+ ],
936
+ },
937
+ JsonRpcNotification: {
938
+ additional: {
939
+ kind: "allowed",
940
+ },
941
+ forbidden_property_sets: [["id"]],
942
+ kind: "object",
943
+ properties: [
944
+ {
945
+ required: true,
946
+ shape: {
947
+ kind: "literal",
948
+ value: "2.0",
949
+ },
950
+ wire_name: "jsonrpc",
951
+ },
952
+ {
953
+ required: true,
954
+ shape: {
955
+ kind: "string",
956
+ },
957
+ wire_name: "method",
958
+ },
959
+ {
960
+ required: true,
961
+ shape: {
962
+ additional: {
963
+ kind: "allowed",
964
+ },
965
+ forbidden_property_sets: [],
966
+ kind: "object",
967
+ properties: [],
968
+ },
969
+ wire_name: "params",
970
+ },
971
+ ],
972
+ },
973
+ JsonRpcRequest: {
974
+ additional: {
975
+ kind: "allowed",
976
+ },
977
+ forbidden_property_sets: [],
978
+ kind: "object",
979
+ properties: [
980
+ {
981
+ required: true,
982
+ shape: {
983
+ kind: "ref",
984
+ name: "JsonRpcId",
985
+ },
986
+ wire_name: "id",
987
+ },
988
+ {
989
+ required: true,
990
+ shape: {
991
+ kind: "literal",
992
+ value: "2.0",
993
+ },
994
+ wire_name: "jsonrpc",
995
+ },
996
+ {
997
+ required: true,
998
+ shape: {
999
+ kind: "string",
1000
+ },
1001
+ wire_name: "method",
1002
+ },
1003
+ {
1004
+ required: true,
1005
+ shape: {
1006
+ additional: {
1007
+ kind: "allowed",
1008
+ },
1009
+ forbidden_property_sets: [],
1010
+ kind: "object",
1011
+ properties: [],
1012
+ },
1013
+ wire_name: "params",
1014
+ },
1015
+ ],
1016
+ },
1017
+ JsonRpcResponseId: {
1018
+ kind: "union",
1019
+ mode: "anyOf",
1020
+ variants: [
1021
+ {
1022
+ kind: "ref",
1023
+ name: "JsonRpcId",
1024
+ },
1025
+ {
1026
+ kind: "null",
1027
+ },
1028
+ ],
1029
+ },
1030
+ JsonRpcSuccessResponse: {
1031
+ additional: {
1032
+ kind: "allowed",
1033
+ },
1034
+ forbidden_property_sets: [["error"]],
1035
+ kind: "object",
1036
+ properties: [
1037
+ {
1038
+ required: true,
1039
+ shape: {
1040
+ kind: "ref",
1041
+ name: "JsonRpcResponseId",
1042
+ },
1043
+ wire_name: "id",
1044
+ },
1045
+ {
1046
+ required: true,
1047
+ shape: {
1048
+ kind: "literal",
1049
+ value: "2.0",
1050
+ },
1051
+ wire_name: "jsonrpc",
1052
+ },
1053
+ {
1054
+ required: true,
1055
+ shape: {
1056
+ additional: {
1057
+ kind: "allowed",
1058
+ },
1059
+ forbidden_property_sets: [],
1060
+ kind: "object",
1061
+ properties: [],
1062
+ },
1063
+ wire_name: "result",
1064
+ },
1065
+ ],
1066
+ },
1067
+ NativeEvent: {
1068
+ additional: {
1069
+ kind: "allowed",
1070
+ },
1071
+ forbidden_property_sets: [],
1072
+ kind: "object",
1073
+ properties: [
1074
+ {
1075
+ required: true,
1076
+ shape: {
1077
+ kind: "string",
1078
+ },
1079
+ wire_name: "eventName",
1080
+ },
1081
+ {
1082
+ required: true,
1083
+ shape: {
1084
+ additional: {
1085
+ kind: "allowed",
1086
+ },
1087
+ forbidden_property_sets: [],
1088
+ kind: "object",
1089
+ properties: [],
1090
+ },
1091
+ wire_name: "payload",
1092
+ },
1093
+ {
1094
+ required: true,
1095
+ shape: {
1096
+ kind: "string",
1097
+ },
1098
+ wire_name: "provider",
1099
+ },
1100
+ ],
1101
+ },
1102
+ ObserveNotification: {
1103
+ kind: "intersection",
1104
+ variants: [
1105
+ {
1106
+ kind: "ref",
1107
+ name: "JsonRpcNotification",
1108
+ },
1109
+ {
1110
+ additional: {
1111
+ kind: "allowed",
1112
+ },
1113
+ forbidden_property_sets: [],
1114
+ kind: "object",
1115
+ properties: [
1116
+ {
1117
+ required: false,
1118
+ shape: {
1119
+ kind: "literal",
1120
+ value: "hooks/observe",
1121
+ },
1122
+ wire_name: "method",
1123
+ },
1124
+ {
1125
+ required: false,
1126
+ shape: {
1127
+ additional: {
1128
+ kind: "allowed",
1129
+ },
1130
+ forbidden_property_sets: [],
1131
+ kind: "object",
1132
+ properties: [
1133
+ {
1134
+ required: true,
1135
+ shape: {
1136
+ discriminator: "type",
1137
+ kind: "union",
1138
+ mode: "oneOf",
1139
+ variants: [
1140
+ {
1141
+ kind: "ref",
1142
+ name: "ToolBeforeEvent",
1143
+ },
1144
+ {
1145
+ kind: "ref",
1146
+ name: "ToolAfterEvent",
1147
+ },
1148
+ {
1149
+ kind: "ref",
1150
+ name: "ToolErrorEvent",
1151
+ },
1152
+ {
1153
+ kind: "ref",
1154
+ name: "SessionStartEvent",
1155
+ },
1156
+ {
1157
+ kind: "ref",
1158
+ name: "SessionEndEvent",
1159
+ },
1160
+ ],
1161
+ },
1162
+ wire_name: "event",
1163
+ },
1164
+ {
1165
+ required: true,
1166
+ shape: {
1167
+ kind: "ref",
1168
+ name: "ProtocolVersion",
1169
+ },
1170
+ wire_name: "protocolVersion",
1171
+ },
1172
+ ],
1173
+ },
1174
+ wire_name: "params",
1175
+ },
1176
+ ],
1177
+ },
1178
+ ],
1179
+ },
1180
+ ObserveSubscription: {
1181
+ additional: {
1182
+ kind: "allowed",
1183
+ },
1184
+ forbidden_property_sets: [["failurePolicy"], ["timeoutMs"]],
1185
+ kind: "object",
1186
+ properties: [
1187
+ {
1188
+ required: true,
1189
+ shape: {
1190
+ items: {
1191
+ kind: "enum",
1192
+ open_strings: true,
1193
+ values: [
1194
+ "tool.before",
1195
+ "tool.after",
1196
+ "tool.error",
1197
+ "session.start",
1198
+ "session.end",
1199
+ ],
1200
+ },
1201
+ kind: "array",
1202
+ },
1203
+ wire_name: "events",
1204
+ },
1205
+ {
1206
+ required: false,
1207
+ shape: {
1208
+ kind: "boolean",
1209
+ },
1210
+ wire_name: "includeNative",
1211
+ },
1212
+ {
1213
+ required: true,
1214
+ shape: {
1215
+ kind: "literal",
1216
+ value: "observe",
1217
+ },
1218
+ wire_name: "mode",
1219
+ },
1220
+ ],
1221
+ },
1222
+ ProtocolVersion: {
1223
+ kind: "literal",
1224
+ value: "draft",
1225
+ },
1226
+ Registration: {
1227
+ additional: {
1228
+ kind: "allowed",
1229
+ },
1230
+ forbidden_property_sets: [],
1231
+ kind: "object",
1232
+ properties: [
1233
+ {
1234
+ required: true,
1235
+ shape: {
1236
+ items: {
1237
+ kind: "ref",
1238
+ name: "Backend",
1239
+ },
1240
+ kind: "array",
1241
+ },
1242
+ wire_name: "hooks",
1243
+ },
1244
+ {
1245
+ required: true,
1246
+ shape: {
1247
+ kind: "ref",
1248
+ name: "ProtocolVersion",
1249
+ },
1250
+ wire_name: "protocolVersion",
1251
+ },
1252
+ ],
1253
+ },
1254
+ ReverseDnsName: {
1255
+ kind: "string",
1256
+ },
1257
+ Session: {
1258
+ additional: {
1259
+ kind: "allowed",
1260
+ },
1261
+ forbidden_property_sets: [],
1262
+ kind: "object",
1263
+ properties: [
1264
+ {
1265
+ required: false,
1266
+ shape: {
1267
+ additional: {
1268
+ kind: "allowed",
1269
+ },
1270
+ forbidden_property_sets: [],
1271
+ kind: "object",
1272
+ properties: [
1273
+ {
1274
+ required: true,
1275
+ shape: {
1276
+ kind: "string",
1277
+ },
1278
+ wire_name: "id",
1279
+ },
1280
+ {
1281
+ required: false,
1282
+ shape: {
1283
+ kind: "string",
1284
+ },
1285
+ wire_name: "type",
1286
+ },
1287
+ ],
1288
+ },
1289
+ wire_name: "agent",
1290
+ },
1291
+ {
1292
+ required: false,
1293
+ shape: {
1294
+ kind: "string",
1295
+ },
1296
+ wire_name: "cwd",
1297
+ },
1298
+ {
1299
+ required: true,
1300
+ shape: {
1301
+ kind: "string",
1302
+ },
1303
+ wire_name: "id",
1304
+ },
1305
+ {
1306
+ required: false,
1307
+ shape: {
1308
+ kind: "string",
1309
+ },
1310
+ wire_name: "model",
1311
+ },
1312
+ {
1313
+ required: false,
1314
+ shape: {
1315
+ items: {
1316
+ kind: "string",
1317
+ },
1318
+ kind: "array",
1319
+ },
1320
+ wire_name: "workspaceRoots",
1321
+ },
1322
+ ],
1323
+ },
1324
+ SessionEndEvent: {
1325
+ additional: {
1326
+ kind: "allowed",
1327
+ },
1328
+ forbidden_property_sets: [["tool"]],
1329
+ kind: "object",
1330
+ properties: [
1331
+ {
1332
+ required: false,
1333
+ shape: {
1334
+ kind: "ref",
1335
+ name: "Extensions",
1336
+ },
1337
+ wire_name: "extensions",
1338
+ },
1339
+ {
1340
+ required: true,
1341
+ shape: {
1342
+ kind: "string",
1343
+ },
1344
+ wire_name: "id",
1345
+ },
1346
+ {
1347
+ required: false,
1348
+ shape: {
1349
+ kind: "ref",
1350
+ name: "NativeEvent",
1351
+ },
1352
+ wire_name: "native",
1353
+ },
1354
+ {
1355
+ required: false,
1356
+ shape: {
1357
+ kind: "enum",
1358
+ open_strings: true,
1359
+ values: ["completed", "cancelled", "error", "unknown"],
1360
+ },
1361
+ wire_name: "outcome",
1362
+ },
1363
+ {
1364
+ required: true,
1365
+ shape: {
1366
+ kind: "ref",
1367
+ name: "Session",
1368
+ },
1369
+ wire_name: "session",
1370
+ },
1371
+ {
1372
+ required: true,
1373
+ shape: {
1374
+ kind: "string",
1375
+ },
1376
+ wire_name: "source",
1377
+ },
1378
+ {
1379
+ required: true,
1380
+ shape: {
1381
+ kind: "string",
1382
+ },
1383
+ wire_name: "time",
1384
+ },
1385
+ {
1386
+ required: true,
1387
+ shape: {
1388
+ kind: "literal",
1389
+ value: "session.end",
1390
+ },
1391
+ wire_name: "type",
1392
+ },
1393
+ ],
1394
+ },
1395
+ SessionStartEvent: {
1396
+ additional: {
1397
+ kind: "allowed",
1398
+ },
1399
+ forbidden_property_sets: [["outcome"], ["tool"]],
1400
+ kind: "object",
1401
+ properties: [
1402
+ {
1403
+ required: false,
1404
+ shape: {
1405
+ kind: "ref",
1406
+ name: "Extensions",
1407
+ },
1408
+ wire_name: "extensions",
1409
+ },
1410
+ {
1411
+ required: true,
1412
+ shape: {
1413
+ kind: "string",
1414
+ },
1415
+ wire_name: "id",
1416
+ },
1417
+ {
1418
+ required: false,
1419
+ shape: {
1420
+ kind: "ref",
1421
+ name: "NativeEvent",
1422
+ },
1423
+ wire_name: "native",
1424
+ },
1425
+ {
1426
+ required: true,
1427
+ shape: {
1428
+ kind: "ref",
1429
+ name: "Session",
1430
+ },
1431
+ wire_name: "session",
1432
+ },
1433
+ {
1434
+ required: true,
1435
+ shape: {
1436
+ kind: "string",
1437
+ },
1438
+ wire_name: "source",
1439
+ },
1440
+ {
1441
+ required: true,
1442
+ shape: {
1443
+ kind: "string",
1444
+ },
1445
+ wire_name: "time",
1446
+ },
1447
+ {
1448
+ required: true,
1449
+ shape: {
1450
+ kind: "literal",
1451
+ value: "session.start",
1452
+ },
1453
+ wire_name: "type",
1454
+ },
1455
+ ],
1456
+ },
1457
+ StdioTransport: {
1458
+ additional: {
1459
+ kind: "allowed",
1460
+ },
1461
+ forbidden_property_sets: [],
1462
+ kind: "object",
1463
+ properties: [
1464
+ {
1465
+ required: false,
1466
+ shape: {
1467
+ items: {
1468
+ kind: "string",
1469
+ },
1470
+ kind: "array",
1471
+ },
1472
+ wire_name: "args",
1473
+ },
1474
+ {
1475
+ required: true,
1476
+ shape: {
1477
+ kind: "string",
1478
+ },
1479
+ wire_name: "command",
1480
+ },
1481
+ {
1482
+ required: false,
1483
+ shape: {
1484
+ kind: "string",
1485
+ },
1486
+ wire_name: "cwd",
1487
+ },
1488
+ {
1489
+ required: true,
1490
+ shape: {
1491
+ kind: "enum",
1492
+ open_strings: true,
1493
+ values: ["persistent", "per_event"],
1494
+ },
1495
+ wire_name: "lifecycle",
1496
+ },
1497
+ {
1498
+ required: true,
1499
+ shape: {
1500
+ kind: "literal",
1501
+ value: "stdio",
1502
+ },
1503
+ wire_name: "type",
1504
+ },
1505
+ ],
1506
+ },
1507
+ ToolAfterEvent: {
1508
+ additional: {
1509
+ kind: "allowed",
1510
+ },
1511
+ forbidden_property_sets: [],
1512
+ kind: "object",
1513
+ properties: [
1514
+ {
1515
+ required: false,
1516
+ shape: {
1517
+ kind: "ref",
1518
+ name: "Extensions",
1519
+ },
1520
+ wire_name: "extensions",
1521
+ },
1522
+ {
1523
+ required: true,
1524
+ shape: {
1525
+ kind: "string",
1526
+ },
1527
+ wire_name: "id",
1528
+ },
1529
+ {
1530
+ required: false,
1531
+ shape: {
1532
+ kind: "ref",
1533
+ name: "NativeEvent",
1534
+ },
1535
+ wire_name: "native",
1536
+ },
1537
+ {
1538
+ required: true,
1539
+ shape: {
1540
+ kind: "ref",
1541
+ name: "Session",
1542
+ },
1543
+ wire_name: "session",
1544
+ },
1545
+ {
1546
+ required: true,
1547
+ shape: {
1548
+ kind: "string",
1549
+ },
1550
+ wire_name: "source",
1551
+ },
1552
+ {
1553
+ required: true,
1554
+ shape: {
1555
+ kind: "string",
1556
+ },
1557
+ wire_name: "time",
1558
+ },
1559
+ {
1560
+ required: true,
1561
+ shape: {
1562
+ additional: {
1563
+ kind: "allowed",
1564
+ },
1565
+ forbidden_property_sets: [["error"]],
1566
+ kind: "object",
1567
+ properties: [
1568
+ {
1569
+ required: true,
1570
+ shape: {
1571
+ kind: "string",
1572
+ },
1573
+ wire_name: "callId",
1574
+ },
1575
+ {
1576
+ required: true,
1577
+ shape: {
1578
+ additional: {
1579
+ kind: "allowed",
1580
+ },
1581
+ forbidden_property_sets: [],
1582
+ kind: "object",
1583
+ properties: [],
1584
+ },
1585
+ wire_name: "input",
1586
+ },
1587
+ {
1588
+ required: true,
1589
+ shape: {
1590
+ kind: "enum",
1591
+ open_strings: true,
1592
+ values: [
1593
+ "shell",
1594
+ "file_read",
1595
+ "file_write",
1596
+ "file_edit",
1597
+ "search",
1598
+ "fetch",
1599
+ "task",
1600
+ "mcp",
1601
+ "other",
1602
+ ],
1603
+ },
1604
+ wire_name: "kind",
1605
+ },
1606
+ {
1607
+ required: false,
1608
+ shape: {
1609
+ additional: {
1610
+ kind: "allowed",
1611
+ },
1612
+ forbidden_property_sets: [],
1613
+ kind: "object",
1614
+ properties: [],
1615
+ },
1616
+ wire_name: "mcp",
1617
+ },
1618
+ {
1619
+ required: true,
1620
+ shape: {
1621
+ kind: "string",
1622
+ },
1623
+ wire_name: "name",
1624
+ },
1625
+ {
1626
+ required: false,
1627
+ shape: {
1628
+ kind: "any",
1629
+ },
1630
+ wire_name: "output",
1631
+ },
1632
+ ],
1633
+ },
1634
+ wire_name: "tool",
1635
+ },
1636
+ {
1637
+ required: true,
1638
+ shape: {
1639
+ kind: "literal",
1640
+ value: "tool.after",
1641
+ },
1642
+ wire_name: "type",
1643
+ },
1644
+ ],
1645
+ },
1646
+ ToolBeforeEvent: {
1647
+ additional: {
1648
+ kind: "allowed",
1649
+ },
1650
+ forbidden_property_sets: [],
1651
+ kind: "object",
1652
+ properties: [
1653
+ {
1654
+ required: false,
1655
+ shape: {
1656
+ kind: "ref",
1657
+ name: "Extensions",
1658
+ },
1659
+ wire_name: "extensions",
1660
+ },
1661
+ {
1662
+ required: true,
1663
+ shape: {
1664
+ kind: "string",
1665
+ },
1666
+ wire_name: "id",
1667
+ },
1668
+ {
1669
+ required: false,
1670
+ shape: {
1671
+ kind: "ref",
1672
+ name: "NativeEvent",
1673
+ },
1674
+ wire_name: "native",
1675
+ },
1676
+ {
1677
+ required: true,
1678
+ shape: {
1679
+ kind: "ref",
1680
+ name: "Session",
1681
+ },
1682
+ wire_name: "session",
1683
+ },
1684
+ {
1685
+ required: true,
1686
+ shape: {
1687
+ kind: "string",
1688
+ },
1689
+ wire_name: "source",
1690
+ },
1691
+ {
1692
+ required: true,
1693
+ shape: {
1694
+ kind: "string",
1695
+ },
1696
+ wire_name: "time",
1697
+ },
1698
+ {
1699
+ required: true,
1700
+ shape: {
1701
+ additional: {
1702
+ kind: "allowed",
1703
+ },
1704
+ forbidden_property_sets: [["error"], ["output"]],
1705
+ kind: "object",
1706
+ properties: [
1707
+ {
1708
+ required: true,
1709
+ shape: {
1710
+ kind: "string",
1711
+ },
1712
+ wire_name: "callId",
1713
+ },
1714
+ {
1715
+ required: true,
1716
+ shape: {
1717
+ additional: {
1718
+ kind: "allowed",
1719
+ },
1720
+ forbidden_property_sets: [],
1721
+ kind: "object",
1722
+ properties: [],
1723
+ },
1724
+ wire_name: "input",
1725
+ },
1726
+ {
1727
+ required: true,
1728
+ shape: {
1729
+ kind: "enum",
1730
+ open_strings: true,
1731
+ values: [
1732
+ "shell",
1733
+ "file_read",
1734
+ "file_write",
1735
+ "file_edit",
1736
+ "search",
1737
+ "fetch",
1738
+ "task",
1739
+ "mcp",
1740
+ "other",
1741
+ ],
1742
+ },
1743
+ wire_name: "kind",
1744
+ },
1745
+ {
1746
+ required: false,
1747
+ shape: {
1748
+ additional: {
1749
+ kind: "allowed",
1750
+ },
1751
+ forbidden_property_sets: [],
1752
+ kind: "object",
1753
+ properties: [],
1754
+ },
1755
+ wire_name: "mcp",
1756
+ },
1757
+ {
1758
+ required: true,
1759
+ shape: {
1760
+ kind: "string",
1761
+ },
1762
+ wire_name: "name",
1763
+ },
1764
+ ],
1765
+ },
1766
+ wire_name: "tool",
1767
+ },
1768
+ {
1769
+ required: true,
1770
+ shape: {
1771
+ kind: "literal",
1772
+ value: "tool.before",
1773
+ },
1774
+ wire_name: "type",
1775
+ },
1776
+ ],
1777
+ },
1778
+ ToolErrorEvent: {
1779
+ additional: {
1780
+ kind: "allowed",
1781
+ },
1782
+ forbidden_property_sets: [],
1783
+ kind: "object",
1784
+ properties: [
1785
+ {
1786
+ required: false,
1787
+ shape: {
1788
+ kind: "ref",
1789
+ name: "Extensions",
1790
+ },
1791
+ wire_name: "extensions",
1792
+ },
1793
+ {
1794
+ required: true,
1795
+ shape: {
1796
+ kind: "string",
1797
+ },
1798
+ wire_name: "id",
1799
+ },
1800
+ {
1801
+ required: false,
1802
+ shape: {
1803
+ kind: "ref",
1804
+ name: "NativeEvent",
1805
+ },
1806
+ wire_name: "native",
1807
+ },
1808
+ {
1809
+ required: true,
1810
+ shape: {
1811
+ kind: "ref",
1812
+ name: "Session",
1813
+ },
1814
+ wire_name: "session",
1815
+ },
1816
+ {
1817
+ required: true,
1818
+ shape: {
1819
+ kind: "string",
1820
+ },
1821
+ wire_name: "source",
1822
+ },
1823
+ {
1824
+ required: true,
1825
+ shape: {
1826
+ kind: "string",
1827
+ },
1828
+ wire_name: "time",
1829
+ },
1830
+ {
1831
+ required: true,
1832
+ shape: {
1833
+ additional: {
1834
+ kind: "allowed",
1835
+ },
1836
+ forbidden_property_sets: [["output"]],
1837
+ kind: "object",
1838
+ properties: [
1839
+ {
1840
+ required: true,
1841
+ shape: {
1842
+ kind: "string",
1843
+ },
1844
+ wire_name: "callId",
1845
+ },
1846
+ {
1847
+ required: true,
1848
+ shape: {
1849
+ additional: {
1850
+ kind: "allowed",
1851
+ },
1852
+ forbidden_property_sets: [],
1853
+ kind: "object",
1854
+ properties: [
1855
+ {
1856
+ required: false,
1857
+ shape: {
1858
+ kind: "any",
1859
+ },
1860
+ wire_name: "category",
1861
+ },
1862
+ {
1863
+ required: false,
1864
+ shape: {
1865
+ kind: "any",
1866
+ },
1867
+ wire_name: "code",
1868
+ },
1869
+ {
1870
+ required: true,
1871
+ shape: {
1872
+ kind: "any",
1873
+ },
1874
+ wire_name: "message",
1875
+ },
1876
+ ],
1877
+ },
1878
+ wire_name: "error",
1879
+ },
1880
+ {
1881
+ required: true,
1882
+ shape: {
1883
+ additional: {
1884
+ kind: "allowed",
1885
+ },
1886
+ forbidden_property_sets: [],
1887
+ kind: "object",
1888
+ properties: [],
1889
+ },
1890
+ wire_name: "input",
1891
+ },
1892
+ {
1893
+ required: true,
1894
+ shape: {
1895
+ kind: "enum",
1896
+ open_strings: true,
1897
+ values: [
1898
+ "shell",
1899
+ "file_read",
1900
+ "file_write",
1901
+ "file_edit",
1902
+ "search",
1903
+ "fetch",
1904
+ "task",
1905
+ "mcp",
1906
+ "other",
1907
+ ],
1908
+ },
1909
+ wire_name: "kind",
1910
+ },
1911
+ {
1912
+ required: false,
1913
+ shape: {
1914
+ additional: {
1915
+ kind: "allowed",
1916
+ },
1917
+ forbidden_property_sets: [],
1918
+ kind: "object",
1919
+ properties: [],
1920
+ },
1921
+ wire_name: "mcp",
1922
+ },
1923
+ {
1924
+ required: true,
1925
+ shape: {
1926
+ kind: "string",
1927
+ },
1928
+ wire_name: "name",
1929
+ },
1930
+ ],
1931
+ },
1932
+ wire_name: "tool",
1933
+ },
1934
+ {
1935
+ required: true,
1936
+ shape: {
1937
+ kind: "literal",
1938
+ value: "tool.error",
1939
+ },
1940
+ wire_name: "type",
1941
+ },
1942
+ ],
1943
+ },
1944
+ WireMessage: {
1945
+ kind: "union",
1946
+ mode: "oneOf",
1947
+ variants: [
1948
+ {
1949
+ kind: "ref",
1950
+ name: "InterceptRequest",
1951
+ },
1952
+ {
1953
+ kind: "ref",
1954
+ name: "InterceptNoEffectResponse",
1955
+ },
1956
+ {
1957
+ kind: "ref",
1958
+ name: "InterceptDenyResponse",
1959
+ },
1960
+ {
1961
+ kind: "ref",
1962
+ name: "JsonRpcErrorResponse",
1963
+ },
1964
+ {
1965
+ kind: "ref",
1966
+ name: "ObserveNotification",
1967
+ },
1968
+ ],
1969
+ },
1970
+ } as unknown as Record<string, SchemaNode>;
1971
+ function parseRoot(
1972
+ name: string,
1973
+ input: string | unknown,
1974
+ ): ParseResult<unknown> {
1975
+ let raw: JsonValue;
1976
+ try {
1977
+ raw = toSafeJson(typeof input === "string" ? JSON.parse(input) : input);
1978
+ } catch (error) {
1979
+ return {
1980
+ ok: false,
1981
+ diagnostics: [
1982
+ {
1983
+ path: "",
1984
+ code: "invalid_json",
1985
+ severity: "error",
1986
+ message: error instanceof Error ? error.message : "Invalid JSON",
1987
+ },
1988
+ ],
1989
+ };
1990
+ }
1991
+ const diagnostics: ParseDiagnostic[] = [];
1992
+ checkNode(SCHEMAS[name]!, raw, "", diagnostics);
1993
+ if (diagnostics.some((diagnostic) => diagnostic.severity === "error"))
1994
+ return { ok: false, raw, diagnostics };
1995
+ return { ok: true, value: raw, raw, diagnostics };
1996
+ }
1997
+
1998
+ function checkNode(
1999
+ schema: SchemaNode,
2000
+ value: JsonValue,
2001
+ path: string,
2002
+ diagnostics: ParseDiagnostic[],
2003
+ ): void {
2004
+ switch (schema.kind) {
2005
+ case "any":
2006
+ return;
2007
+ case "never":
2008
+ return error(diagnostics, path, "invalid_type", "Value is forbidden");
2009
+ case "null":
2010
+ if (value !== null)
2011
+ error(diagnostics, path, "invalid_type", "Expected null");
2012
+ return;
2013
+ case "boolean":
2014
+ if (typeof value !== "boolean")
2015
+ error(diagnostics, path, "invalid_type", "Expected boolean");
2016
+ return;
2017
+ case "integer":
2018
+ if (typeof value !== "number" || !Number.isSafeInteger(value))
2019
+ error(
2020
+ diagnostics,
2021
+ path,
2022
+ "invalid_type",
2023
+ "Expected safely representable integer",
2024
+ );
2025
+ return;
2026
+ case "number":
2027
+ if (typeof value !== "number" || !Number.isFinite(value))
2028
+ error(diagnostics, path, "invalid_type", "Expected finite number");
2029
+ return;
2030
+ case "string":
2031
+ if (typeof value !== "string")
2032
+ error(diagnostics, path, "invalid_type", "Expected string");
2033
+ return;
2034
+ case "literal":
2035
+ if (!sameJson(value, schema.value))
2036
+ error(
2037
+ diagnostics,
2038
+ path,
2039
+ "literal_mismatch",
2040
+ `Expected ${JSON.stringify(schema.value)}`,
2041
+ );
2042
+ return;
2043
+ case "enum": {
2044
+ if (schema.values.some((candidate) => sameJson(candidate, value))) return;
2045
+ if (schema.open_strings && typeof value === "string") {
2046
+ diagnostics.push({
2047
+ path,
2048
+ code: "unknown_enum",
2049
+ severity: "warning",
2050
+ message: `Unknown enum value ${JSON.stringify(value)} was preserved`,
2051
+ });
2052
+ } else
2053
+ error(
2054
+ diagnostics,
2055
+ path,
2056
+ "invalid_type",
2057
+ "Value does not match the enum's scalar type",
2058
+ );
2059
+ return;
2060
+ }
2061
+ case "array":
2062
+ if (!Array.isArray(value))
2063
+ return error(diagnostics, path, "invalid_type", "Expected array");
2064
+ value.forEach((item, index) =>
2065
+ checkNode(schema.items, item, `${path}/${index}`, diagnostics),
2066
+ );
2067
+ return;
2068
+ case "object":
2069
+ if (!isObject(value))
2070
+ return error(diagnostics, path, "invalid_type", "Expected object");
2071
+ for (const forbiddenSet of schema.forbidden_property_sets) {
2072
+ if (
2073
+ forbiddenSet.every((key) =>
2074
+ Object.prototype.hasOwnProperty.call(value, key),
2075
+ )
2076
+ ) {
2077
+ error(
2078
+ diagnostics,
2079
+ path,
2080
+ "invalid_type",
2081
+ `Forbidden property combination: ${forbiddenSet.join(", ")}`,
2082
+ );
2083
+ }
2084
+ }
2085
+ for (const property of schema.properties) {
2086
+ if (!Object.prototype.hasOwnProperty.call(value, property.wire_name)) {
2087
+ if (property.required)
2088
+ error(
2089
+ diagnostics,
2090
+ joinPath(path, property.wire_name),
2091
+ "missing_required",
2092
+ "Required property is absent",
2093
+ );
2094
+ } else
2095
+ checkNode(
2096
+ property.shape,
2097
+ value[property.wire_name]!,
2098
+ joinPath(path, property.wire_name),
2099
+ diagnostics,
2100
+ );
2101
+ }
2102
+ return;
2103
+ case "intersection":
2104
+ schema.variants.forEach((variant) =>
2105
+ checkNode(variant, value, path, diagnostics),
2106
+ );
2107
+ return;
2108
+ case "ref":
2109
+ checkNode(SCHEMAS[schema.name]!, value, path, diagnostics);
2110
+ return;
2111
+ case "union":
2112
+ checkUnion(schema, value, path, diagnostics);
2113
+ return;
2114
+ }
2115
+ }
2116
+
2117
+ function checkUnion(
2118
+ schema: Extract<SchemaNode, { kind: "union" }>,
2119
+ value: JsonValue,
2120
+ path: string,
2121
+ diagnostics: ParseDiagnostic[],
2122
+ ): void {
2123
+ if (schema.discriminator) {
2124
+ if (!isObject(value) || typeof value[schema.discriminator] !== "string")
2125
+ return error(
2126
+ diagnostics,
2127
+ joinPath(path, schema.discriminator),
2128
+ "invalid_type",
2129
+ "Expected string discriminator",
2130
+ );
2131
+ const actual = value[schema.discriminator] as string;
2132
+ const branch = schema.variants.find(
2133
+ (variant) =>
2134
+ discriminatorValue(variant, schema.discriminator as string) === actual,
2135
+ );
2136
+ if (!branch) {
2137
+ diagnostics.push({
2138
+ path,
2139
+ code: "unknown_variant",
2140
+ severity: "warning",
2141
+ message: `Unknown ${schema.discriminator} variant ${JSON.stringify(actual)} was preserved`,
2142
+ });
2143
+ return;
2144
+ }
2145
+ const branchDiagnostics: ParseDiagnostic[] = [];
2146
+ checkNode(branch, value, path, branchDiagnostics);
2147
+ if (branchDiagnostics.some((item) => item.severity === "error")) {
2148
+ diagnostics.push(...branchDiagnostics, {
2149
+ path,
2150
+ code: "invalid_known_variant",
2151
+ severity: "error",
2152
+ message: `Known ${schema.discriminator} variant is malformed`,
2153
+ });
2154
+ } else diagnostics.push(...branchDiagnostics);
2155
+ return;
2156
+ }
2157
+ const attempts = schema.variants.map((variant) => {
2158
+ const result: ParseDiagnostic[] = [];
2159
+ checkNode(variant, value, path, result);
2160
+ return result;
2161
+ });
2162
+ const matches = attempts.filter(
2163
+ (attempt) => !attempt.some((item) => item.severity === "error"),
2164
+ );
2165
+ if (matches.length === 0)
2166
+ error(diagnostics, path, "no_union_match", "Value matches no union branch");
2167
+ else if (schema.mode === "oneOf" && matches.length > 1)
2168
+ error(
2169
+ diagnostics,
2170
+ path,
2171
+ "ambiguous_union",
2172
+ "Value matches more than one union branch",
2173
+ );
2174
+ else diagnostics.push(...matches[0]!);
2175
+ }
2176
+
2177
+ function discriminatorValue(
2178
+ schema: SchemaNode,
2179
+ property: string,
2180
+ ): string | undefined {
2181
+ if (schema.kind === "ref")
2182
+ return discriminatorValue(SCHEMAS[schema.name]!, property);
2183
+ if (schema.kind === "intersection") {
2184
+ for (const variant of schema.variants) {
2185
+ const value = discriminatorValue(variant, property);
2186
+ if (value !== undefined) return value;
2187
+ }
2188
+ }
2189
+ if (schema.kind === "object") {
2190
+ const field = schema.properties.find(
2191
+ (candidate) => candidate.wire_name === property,
2192
+ );
2193
+ if (
2194
+ field?.shape.kind === "literal" &&
2195
+ typeof field.shape.value === "string"
2196
+ )
2197
+ return field.shape.value;
2198
+ }
2199
+ return undefined;
2200
+ }
2201
+
2202
+ function toSafeJson(value: unknown): JsonValue {
2203
+ if (value === null || typeof value === "string" || typeof value === "boolean")
2204
+ return value;
2205
+ if (typeof value === "number" && Number.isFinite(value)) return value;
2206
+ if (Array.isArray(value)) return value.map(toSafeJson);
2207
+ if (typeof value === "object") {
2208
+ const result = Object.create(null) as Record<string, JsonValue>;
2209
+ for (const [key, child] of Object.entries(
2210
+ value as Record<string, unknown>,
2211
+ )) {
2212
+ Object.defineProperty(result, key, {
2213
+ value: toSafeJson(child),
2214
+ enumerable: true,
2215
+ configurable: true,
2216
+ writable: true,
2217
+ });
2218
+ }
2219
+ return result;
2220
+ }
2221
+ throw new TypeError("Input is not a JSON value");
2222
+ }
2223
+
2224
+ function encodeJson(value: JsonValue): string {
2225
+ return JSON.stringify(value);
2226
+ }
2227
+ function isObject(value: JsonValue): value is Record<string, JsonValue> {
2228
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2229
+ }
2230
+ function sameJson(left: JsonValue, right: JsonValue): boolean {
2231
+ return JSON.stringify(left) === JSON.stringify(right);
2232
+ }
2233
+ function joinPath(path: string, key: string): string {
2234
+ return `${path}/${key.replace(/~/g, "~0").replace(/\//g, "~1")}`;
2235
+ }
2236
+ function error(
2237
+ diagnostics: ParseDiagnostic[],
2238
+ path: string,
2239
+ code: ParseDiagnostic["code"],
2240
+ message: string,
2241
+ ): void {
2242
+ diagnostics.push({ path, code, severity: "error", message });
2243
+ }
2244
+ export function parseCapabilities(
2245
+ input: string | unknown,
2246
+ ): ParseResult<Capabilities> {
2247
+ return parseRoot("Capabilities", input) as ParseResult<Capabilities>;
2248
+ }
2249
+ export function encodeCapabilities(value: Capabilities): string {
2250
+ return encodeJson(value as JsonValue);
2251
+ }
2252
+ export const capabilitiesSchemaRevision = SCHEMA_REVISION;
2253
+
2254
+ export function parseDenyEffect(
2255
+ input: string | unknown,
2256
+ ): ParseResult<DenyEffect> {
2257
+ return parseRoot("DenyEffect", input) as ParseResult<DenyEffect>;
2258
+ }
2259
+ export function encodeDenyEffect(value: DenyEffect): string {
2260
+ return encodeJson(value as JsonValue);
2261
+ }
2262
+ export const denyEffectSchemaRevision = SCHEMA_REVISION;
2263
+
2264
+ export function parseExtensions(
2265
+ input: string | unknown,
2266
+ ): ParseResult<Extensions> {
2267
+ return parseRoot("Extensions", input) as ParseResult<Extensions>;
2268
+ }
2269
+ export function encodeExtensions(value: Extensions): string {
2270
+ return encodeJson(value as JsonValue);
2271
+ }
2272
+ export const extensionsSchemaRevision = SCHEMA_REVISION;
2273
+
2274
+ export function parseInterceptDenyResponse(
2275
+ input: string | unknown,
2276
+ ): ParseResult<InterceptDenyResponse> {
2277
+ return parseRoot(
2278
+ "InterceptDenyResponse",
2279
+ input,
2280
+ ) as ParseResult<InterceptDenyResponse>;
2281
+ }
2282
+ export function encodeInterceptDenyResponse(
2283
+ value: InterceptDenyResponse,
2284
+ ): string {
2285
+ return encodeJson(value as JsonValue);
2286
+ }
2287
+ export const interceptDenyResponseSchemaRevision = SCHEMA_REVISION;
2288
+
2289
+ export function parseInterceptNoEffectResponse(
2290
+ input: string | unknown,
2291
+ ): ParseResult<InterceptNoEffectResponse> {
2292
+ return parseRoot(
2293
+ "InterceptNoEffectResponse",
2294
+ input,
2295
+ ) as ParseResult<InterceptNoEffectResponse>;
2296
+ }
2297
+ export function encodeInterceptNoEffectResponse(
2298
+ value: InterceptNoEffectResponse,
2299
+ ): string {
2300
+ return encodeJson(value as JsonValue);
2301
+ }
2302
+ export const interceptNoEffectResponseSchemaRevision = SCHEMA_REVISION;
2303
+
2304
+ export function parseInterceptRequest(
2305
+ input: string | unknown,
2306
+ ): ParseResult<InterceptRequest> {
2307
+ return parseRoot("InterceptRequest", input) as ParseResult<InterceptRequest>;
2308
+ }
2309
+ export function encodeInterceptRequest(value: InterceptRequest): string {
2310
+ return encodeJson(value as JsonValue);
2311
+ }
2312
+ export const interceptRequestSchemaRevision = SCHEMA_REVISION;
2313
+
2314
+ export function parseJsonRpcMessage(
2315
+ input: string | unknown,
2316
+ ): ParseResult<JsonRpcMessage> {
2317
+ return parseRoot("JsonRpcMessage", input) as ParseResult<JsonRpcMessage>;
2318
+ }
2319
+ export function encodeJsonRpcMessage(value: JsonRpcMessage): string {
2320
+ return encodeJson(value as JsonValue);
2321
+ }
2322
+ export const jsonRpcMessageSchemaRevision = SCHEMA_REVISION;
2323
+
2324
+ export function parseObserveNotification(
2325
+ input: string | unknown,
2326
+ ): ParseResult<ObserveNotification> {
2327
+ return parseRoot(
2328
+ "ObserveNotification",
2329
+ input,
2330
+ ) as ParseResult<ObserveNotification>;
2331
+ }
2332
+ export function encodeObserveNotification(value: ObserveNotification): string {
2333
+ return encodeJson(value as JsonValue);
2334
+ }
2335
+ export const observeNotificationSchemaRevision = SCHEMA_REVISION;
2336
+
2337
+ export function parseRegistration(
2338
+ input: string | unknown,
2339
+ ): ParseResult<Registration> {
2340
+ return parseRoot("Registration", input) as ParseResult<Registration>;
2341
+ }
2342
+ export function encodeRegistration(value: Registration): string {
2343
+ return encodeJson(value as JsonValue);
2344
+ }
2345
+ export const registrationSchemaRevision = SCHEMA_REVISION;
2346
+
2347
+ export function parseSessionEndEvent(
2348
+ input: string | unknown,
2349
+ ): ParseResult<SessionEndEvent> {
2350
+ return parseRoot("SessionEndEvent", input) as ParseResult<SessionEndEvent>;
2351
+ }
2352
+ export function encodeSessionEndEvent(value: SessionEndEvent): string {
2353
+ return encodeJson(value as JsonValue);
2354
+ }
2355
+ export const sessionEndEventSchemaRevision = SCHEMA_REVISION;
2356
+
2357
+ export function parseSessionStartEvent(
2358
+ input: string | unknown,
2359
+ ): ParseResult<SessionStartEvent> {
2360
+ return parseRoot(
2361
+ "SessionStartEvent",
2362
+ input,
2363
+ ) as ParseResult<SessionStartEvent>;
2364
+ }
2365
+ export function encodeSessionStartEvent(value: SessionStartEvent): string {
2366
+ return encodeJson(value as JsonValue);
2367
+ }
2368
+ export const sessionStartEventSchemaRevision = SCHEMA_REVISION;
2369
+
2370
+ export function parseToolAfterEvent(
2371
+ input: string | unknown,
2372
+ ): ParseResult<ToolAfterEvent> {
2373
+ return parseRoot("ToolAfterEvent", input) as ParseResult<ToolAfterEvent>;
2374
+ }
2375
+ export function encodeToolAfterEvent(value: ToolAfterEvent): string {
2376
+ return encodeJson(value as JsonValue);
2377
+ }
2378
+ export const toolAfterEventSchemaRevision = SCHEMA_REVISION;
2379
+
2380
+ export function parseToolBeforeEvent(
2381
+ input: string | unknown,
2382
+ ): ParseResult<ToolBeforeEvent> {
2383
+ return parseRoot("ToolBeforeEvent", input) as ParseResult<ToolBeforeEvent>;
2384
+ }
2385
+ export function encodeToolBeforeEvent(value: ToolBeforeEvent): string {
2386
+ return encodeJson(value as JsonValue);
2387
+ }
2388
+ export const toolBeforeEventSchemaRevision = SCHEMA_REVISION;
2389
+
2390
+ export function parseToolErrorEvent(
2391
+ input: string | unknown,
2392
+ ): ParseResult<ToolErrorEvent> {
2393
+ return parseRoot("ToolErrorEvent", input) as ParseResult<ToolErrorEvent>;
2394
+ }
2395
+ export function encodeToolErrorEvent(value: ToolErrorEvent): string {
2396
+ return encodeJson(value as JsonValue);
2397
+ }
2398
+ export const toolErrorEventSchemaRevision = SCHEMA_REVISION;
2399
+
2400
+ export function parseWireMessage(
2401
+ input: string | unknown,
2402
+ ): ParseResult<WireMessage> {
2403
+ return parseRoot("WireMessage", input) as ParseResult<WireMessage>;
2404
+ }
2405
+ export function encodeWireMessage(value: WireMessage): string {
2406
+ return encodeJson(value as JsonValue);
2407
+ }
2408
+ export const wireMessageSchemaRevision = SCHEMA_REVISION;