返回 CodeWhale
protocol.generated.ts
根目录 / crates / tui / extension-host / src / protocol.generated.ts
1 // @generated from the Rust protocol types in crates/tui/src/extension_host/protocol.rs
2 // by `extension_host::protocol::tests`. Do not edit: change the Rust side, re-record with
3 // CODEWHALE_CONFORMANCE_UPDATE=1 cargo test -p codewhale-tui --lib extension_host::protocol
4 // and rebuild dist/ with `npm run build`.
5
6 export const PROTOCOL_VERSION = 1
7 export const MAGIC_ASCII = 'CWX1'
8 export const HEADER_LEN = 8
9 export const MAX_FRAME = 33554432
10 export const MAX_INFLIGHT = 256
11
12 /** JSON-RPC error codes used on this channel. */
13 export const ErrorCode = {
14 ParseError: -32700,
15 InvalidRequest: -32600,
16 MethodNotFound: -32601,
17 InvalidParams: -32602,
18 Internal: -32603,
19 ExecutionFailed: -32000,
20 NotAvailable: -32001,
21 Refused: -32002,
22 Denied: -32003,
23 Cancelled: -32800,
24 } as const
25
26 export type Direction = 'core_to_host' | 'host_to_core'
27
28 /** Every method either side may send, and the trust tiers it is allowed on; nothing else is admitted. */
29 export const METHODS = [
30 { name: 'host/initialize', direction: 'core_to_host', request: true, params: 'InitializeParams', tiers: ['plugin', 'builtin'] },
31 { name: 'host/ping', direction: 'core_to_host', request: true, params: 'EmptyParams', tiers: ['plugin', 'builtin'] },
32 { name: 'host/shutdown', direction: 'core_to_host', request: true, params: 'EmptyParams', tiers: ['plugin', 'builtin'] },
33 { name: 'ext/activate', direction: 'core_to_host', request: true, params: 'ActivateParams', tiers: ['plugin', 'builtin'] },
34 { name: 'ext/deactivate', direction: 'core_to_host', request: true, params: 'DeactivateParams', tiers: ['plugin', 'builtin'] },
35 { name: 'tool/call', direction: 'core_to_host', request: true, params: 'ToolCallParams', tiers: ['plugin', 'builtin'] },
36 { name: 'command/run', direction: 'core_to_host', request: true, params: 'CommandRunParams', tiers: ['plugin', 'builtin'] },
37 { name: 'hook/evaluate', direction: 'core_to_host', request: true, params: 'HookEvaluateParams', tiers: ['plugin', 'builtin'] },
38 { name: 'mcp/open', direction: 'core_to_host', request: true, params: 'McpOpenParams', tiers: ['builtin'] },
39 { name: 'mcp/request', direction: 'core_to_host', request: true, params: 'McpRequestParams', tiers: ['builtin'] },
40 { name: 'mcp/close', direction: 'core_to_host', request: true, params: 'McpCloseParams', tiers: ['builtin'] },
41 { name: 'harness/run', direction: 'core_to_host', request: true, params: 'HarnessRunParams', tiers: ['builtin'] },
42 { name: '$/cancel', direction: 'core_to_host', request: false, params: 'CancelParams', tiers: ['plugin', 'builtin'] },
43 { name: 'host/hello', direction: 'host_to_core', request: false, params: 'HelloParams', tiers: ['plugin', 'builtin'] },
44 { name: 'host/ready', direction: 'host_to_core', request: false, params: 'EmptyParams', tiers: ['plugin', 'builtin'] },
45 { name: 'registry/register', direction: 'host_to_core', request: true, params: 'RegisterParams', tiers: ['plugin', 'builtin'] },
46 { name: 'registry/unregister', direction: 'host_to_core', request: true, params: 'UnregisterParams', tiers: ['plugin', 'builtin'] },
47 { name: 'core/call', direction: 'host_to_core', request: true, params: 'CoreCallParams', tiers: ['plugin', 'builtin'] },
48 { name: 'proc/launch', direction: 'host_to_core', request: true, params: 'ProcLaunchParams', tiers: ['builtin'] },
49 { name: 'proc/read', direction: 'host_to_core', request: true, params: 'ProcSessionParams', tiers: ['builtin'] },
50 { name: 'proc/write', direction: 'host_to_core', request: true, params: 'ProcWriteParams', tiers: ['builtin'] },
51 { name: 'proc/close', direction: 'host_to_core', request: true, params: 'ProcSessionParams', tiers: ['builtin'] },
52 { name: 'net/start', direction: 'host_to_core', request: true, params: 'ProcLaunchParams', tiers: ['builtin'] },
53 { name: 'net/fetch', direction: 'host_to_core', request: true, params: 'NetFetchParams', tiers: ['builtin'] },
54 { name: 'net/read', direction: 'host_to_core', request: true, params: 'NetReadParams', tiers: ['builtin'] },
55 { name: 'net/release', direction: 'host_to_core', request: true, params: 'NetReadParams', tiers: ['builtin'] },
56 { name: 'net/close', direction: 'host_to_core', request: true, params: 'ProcSessionParams', tiers: ['builtin'] },
57 { name: 'exec/redeem', direction: 'host_to_core', request: true, params: 'ExecutionRedeemParams', tiers: ['builtin'] },
58 { name: 'ext/faulted', direction: 'host_to_core', request: false, params: 'FaultedParams', tiers: ['plugin', 'builtin'] },
59 { name: 'log', direction: 'host_to_core', request: false, params: 'LogParams', tiers: ['plugin', 'builtin'] },
60 { name: '$/cancel', direction: 'host_to_core', request: false, params: 'CancelParams', tiers: ['plugin', 'builtin'] },
61 ] as const
62
63 /** A field's wire kind: the Rust field's serde type, normalized for validation. */
64 export type Kind =
65 | 'string'
66 | 'boolean'
67 | 'uint'
68 | 'integer'
69 | 'object'
70 | 'json'
71 | { readonly ref: string }
72 | { readonly enum: readonly string[] }
73 | { readonly items: Kind }
74
75 /** An object's fields; `strict` is Rust's `deny_unknown_fields`. */
76 export interface Shape {
77 readonly strict: boolean
78 readonly required: { readonly [field: string]: Kind }
79 readonly optional: { readonly [field: string]: Kind }
80 }
81
82 /** Every method's params, and an error response's `error`. */
83 export const SHAPES: { readonly [name: string]: Shape } = {
84 ActivateParams: {
85 strict: false,
86 required: { owner: { ref: 'OwnerRef' }, plugin_name: 'string', entry: { ref: 'EntryRef' } },
87 optional: { scope: { ref: 'EntryRef' }, config: 'json', data_dir: 'string' },
88 },
89 CancelParams: {
90 strict: true,
91 required: { id: 'uint' },
92 optional: {},
93 },
94 CommandRunParams: {
95 strict: false,
96 required: { handle: 'uint', command_id: 'string', raw_input: 'string', deadline_ms: 'uint' },
97 optional: { workspace: 'string', session_id: 'string', agent_id: 'string', origin_turn_id: 'string' },
98 },
99 CoreCallParams: {
100 strict: true,
101 required: { owner: { ref: 'OwnerRef' }, ticket: 'string', name: 'string', input: 'json' },
102 optional: {},
103 },
104 DeactivateParams: {
105 strict: false,
106 required: { owner: { ref: 'OwnerRef' } },
107 optional: { entry: { ref: 'EntryRef' } },
108 },
109 EmptyParams: {
110 strict: true,
111 required: {},
112 optional: {},
113 },
114 EntryRef: {
115 strict: false,
116 required: { path: 'string', sha256: 'string' },
117 optional: {},
118 },
119 ExecutionRedeemParams: {
120 strict: true,
121 required: { owner: { ref: 'OwnerRef' }, execution_id: 'string', ticket: 'string' },
122 optional: {},
123 },
124 FaultedParams: {
125 strict: true,
126 required: { owner: { ref: 'OwnerRef' }, error: 'string' },
127 optional: {},
128 },
129 HarnessRunParams: {
130 strict: true,
131 required: { owner: { ref: 'OwnerRef' }, execution_id: 'string', ticket: 'string', deadline_ms: 'uint' },
132 optional: { hook: { ref: 'HookDispatchWire' } },
133 },
134 HelloParams: {
135 strict: true,
136 required: { protocol: { ref: 'ProtocolRange' }, host_version: 'string', bundle_sha256: 'string', runtime: { ref: 'HelloRuntime' }, tier: { enum: ['builtin', 'plugin'] }, builtin_modules: { items: { ref: 'ModuleDigestWire' } } },
137 optional: { memory_limit_mib: 'uint' },
138 },
139 HelloRuntime: {
140 strict: true,
141 required: { name: 'string', version: 'string' },
142 optional: {},
143 },
144 HookCallPayload: {
145 strict: true,
146 required: { name: 'string', call_id: 'string', input: 'json', mode: 'string', workspace: 'string', model: 'string' },
147 optional: {},
148 },
149 HookDispatchWire: {
150 strict: true,
151 required: { event: 'string', dialect: 'string', point: 'string', query: 'string' },
152 optional: { matcher: 'string' },
153 },
154 HookEvaluateParams: {
155 strict: true,
156 required: { handle: 'uint', event: 'string', payload: { ref: 'HookCallPayload' }, deadline_ms: 'uint' },
157 optional: {},
158 },
159 HostLimits: {
160 strict: false,
161 required: { max_frame: 'uint', max_inflight: 'uint', dispose_deadline_ms: 'uint', activate_deadline_ms: 'uint' },
162 optional: {},
163 },
164 InitializeParams: {
165 strict: false,
166 required: { protocol: 'uint', limits: { ref: 'HostLimits' } },
167 optional: {},
168 },
169 LogParams: {
170 strict: true,
171 required: { level: 'string', msg: 'string' },
172 optional: { plugin_id: 'string' },
173 },
174 McpCloseParams: {
175 strict: true,
176 required: { owner: { ref: 'OwnerRef' }, session_id: 'string', deadline_ms: 'uint' },
177 optional: {},
178 },
179 McpHttpHeaders: {
180 strict: true,
181 required: {},
182 optional: { accept: 'string', content_type: 'string', mcp_session_id: 'string', mcp_protocol_version: 'string' },
183 },
184 McpOpenParams: {
185 strict: true,
186 required: { owner: { ref: 'OwnerRef' }, session_id: 'string', launch_ticket: 'string', transport: 'string', initialize_grant: { ref: 'McpOperationGrant' }, initialized_grant: { ref: 'McpOperationGrant' }, client_version: 'string', deadline_ms: 'uint' },
187 optional: {},
188 },
189 McpOperationGrant: {
190 strict: true,
191 required: { ticket: 'string', operation_id: 'string', method: 'string', params: 'json' },
192 optional: { wire_id: 'string' },
193 },
194 McpRequestParams: {
195 strict: true,
196 required: { owner: { ref: 'OwnerRef' }, session_id: 'string', grant: { ref: 'McpOperationGrant' }, deadline_ms: 'uint' },
197 optional: {},
198 },
199 ModuleDigestWire: {
200 strict: true,
201 required: { id: 'string', sha256: 'string' },
202 optional: {},
203 },
204 NetFetchParams: {
205 strict: true,
206 required: { owner: { ref: 'OwnerRef' }, session_id: 'string', url: 'string', method: 'string', headers: { ref: 'McpHttpHeaders' } },
207 optional: { frame: 'json', ticket: 'string', operation_id: 'string' },
208 },
209 NetReadParams: {
210 strict: true,
211 required: { owner: { ref: 'OwnerRef' }, session_id: 'string', response_id: 'string' },
212 optional: {},
213 },
214 OwnerRef: {
215 strict: true,
216 required: { plugin_id: 'string', generation: 'uint', owner_token: 'string' },
217 optional: {},
218 },
219 ProcLaunchParams: {
220 strict: true,
221 required: { owner: { ref: 'OwnerRef' }, session_id: 'string', ticket: 'string' },
222 optional: {},
223 },
224 ProcSessionParams: {
225 strict: true,
226 required: { owner: { ref: 'OwnerRef' }, session_id: 'string' },
227 optional: {},
228 },
229 ProcWriteParams: {
230 strict: true,
231 required: { owner: { ref: 'OwnerRef' }, session_id: 'string', frame: 'json' },
232 optional: { ticket: 'string', operation_id: 'string' },
233 },
234 ProtocolRange: {
235 strict: true,
236 required: { min: 'uint', max: 'uint' },
237 optional: {},
238 },
239 RegisterParams: {
240 strict: true,
241 required: { owner: { ref: 'OwnerRef' }, kind: { enum: ['tool', 'command', 'hook', 'prompt_section', 'prompt_template', 'skill_root', 'shell_hook', 'mcp_server'] }, spec: { ref: 'RegisterSpecWire' } },
242 optional: { scope: { ref: 'EntryRef' } },
243 },
244 RegisterSpecWire: {
245 strict: true,
246 required: { name: 'string', description: 'string' },
247 optional: { input_schema: 'object', argument_hint: 'string' },
248 },
249 RpcErrorWire: {
250 strict: true,
251 required: { code: 'integer', message: 'string' },
252 optional: { data: 'json' },
253 },
254 ToolCallParams: {
255 strict: false,
256 required: { handle: 'uint', call_id: 'string', input: 'json', deadline_ms: 'uint' },
257 optional: { workspace: 'string', ticket: 'string', session_id: 'string', agent_id: 'string', origin_turn_id: 'string' },
258 },
259 UnregisterParams: {
260 strict: true,
261 required: { owner: { ref: 'OwnerRef' }, handle: 'uint' },
262 optional: {},
263 },
264 }
265
266 export type Json = null | boolean | number | string | Json[] | { [key: string]: Json }
267
268 export interface ActivateParams {
269 owner: OwnerRef
270 scope?: EntryRef
271 plugin_name: string
272 entry: EntryRef
273 config?: Json
274 data_dir?: string
275 }
276
277 export type ActivateResult = { status: 'ok'; tools: string[]; commands?: string[] } | { status: 'failed'; diagnostic: string }
278
279 export interface CancelParams {
280 id: number
281 }
282
283 export type CommandResultWire = { kind: 'success'; text?: string } | { kind: 'error'; text: string } | { kind: 'submit'; prompt: string; text?: string }
284
285 export interface CommandRunParams {
286 handle: number
287 command_id: string
288 raw_input: string
289 deadline_ms: number
290 workspace?: string
291 session_id?: string
292 agent_id?: string
293 origin_turn_id?: string
294 }
295
296 export type ContentBlockWire = { type: 'text'; text: string }
297
298 export interface CoreCallParams {
299 owner: OwnerRef
300 ticket: string
301 name: string
302 input: Json
303 }
304
305 export interface DeactivateParams {
306 owner: OwnerRef
307 entry?: EntryRef
308 }
309
310 export interface DeactivateResult {
311 disposed: boolean
312 leaked: string[]
313 }
314
315 export interface EmptyParams {}
316
317 export interface EntryRef {
318 path: string
319 sha256: string
320 }
321
322 export interface ExecutionRedeemParams {
323 owner: OwnerRef
324 execution_id: string
325 ticket: string
326 }
327
328 export interface FaultedParams {
329 owner: OwnerRef
330 error: string
331 }
332
333 export interface HarnessRunParams {
334 owner: OwnerRef
335 execution_id: string
336 ticket: string
337 deadline_ms: number
338 hook?: HookDispatchWire
339 }
340
341 export interface HelloParams {
342 protocol: ProtocolRange
343 host_version: string
344 bundle_sha256: string
345 runtime: HelloRuntime
346 tier: HostTier
347 builtin_modules: ModuleDigestWire[]
348 memory_limit_mib?: number
349 }
350
351 export interface HelloRuntime {
352 name: string
353 version: string
354 }
355
356 export interface HookCallPayload {
357 name: string
358 call_id: string
359 input: Json
360 mode: string
361 workspace: string
362 model: string
363 }
364
365 export interface HookDispatchWire {
366 event: string
367 dialect: string
368 point: string
369 matcher?: string
370 query: string
371 }
372
373 export interface HookEvaluateParams {
374 handle: number
375 event: string
376 payload: HookCallPayload
377 deadline_ms: number
378 }
379
380 export type HookVerdictWire = { kind: 'abstain' } | { kind: 'deny'; reason: string } | { kind: 'ask'; reason: string } | { kind: 'annotate'; text: string } | { kind: 'revise'; input: { [key: string]: Json } }
381
382 export interface HostLimits {
383 max_frame: number
384 max_inflight: number
385 dispose_deadline_ms: number
386 activate_deadline_ms: number
387 }
388
389 export type HostTier = 'builtin' | 'plugin'
390
391 export interface InitializeParams {
392 protocol: number
393 limits: HostLimits
394 }
395
396 export interface LogParams {
397 level: string
398 msg: string
399 plugin_id?: string
400 }
401
402 export interface McpCloseParams {
403 owner: OwnerRef
404 session_id: string
405 deadline_ms: number
406 }
407
408 export interface McpHttpHeaders {
409 accept?: string
410 content_type?: string
411 mcp_session_id?: string
412 mcp_protocol_version?: string
413 }
414
415 export interface McpOpenParams {
416 owner: OwnerRef
417 session_id: string
418 launch_ticket: string
419 transport: string
420 initialize_grant: McpOperationGrant
421 initialized_grant: McpOperationGrant
422 client_version: string
423 deadline_ms: number
424 }
425
426 export interface McpOperationGrant {
427 ticket: string
428 operation_id: string
429 method: string
430 wire_id?: string
431 params: Json
432 }
433
434 export interface McpRequestParams {
435 owner: OwnerRef
436 session_id: string
437 grant: McpOperationGrant
438 deadline_ms: number
439 }
440
441 export interface ModuleDigestWire {
442 id: string
443 sha256: string
444 }
445
446 export interface NetFetchParams {
447 owner: OwnerRef
448 session_id: string
449 url: string
450 method: string
451 headers: McpHttpHeaders
452 frame?: Json
453 ticket?: string
454 operation_id?: string
455 }
456
457 export interface NetReadParams {
458 owner: OwnerRef
459 session_id: string
460 response_id: string
461 }
462
463 export interface OwnerRef {
464 plugin_id: string
465 generation: number
466 owner_token: string
467 }
468
469 export interface ProcLaunchParams {
470 owner: OwnerRef
471 session_id: string
472 ticket: string
473 }
474
475 export interface ProcSessionParams {
476 owner: OwnerRef
477 session_id: string
478 }
479
480 export interface ProcWriteParams {
481 owner: OwnerRef
482 session_id: string
483 frame: Json
484 ticket?: string
485 operation_id?: string
486 }
487
488 export interface ProtocolRange {
489 min: number
490 max: number
491 }
492
493 export type RegisterKind = 'tool' | 'command' | 'hook' | 'prompt_section' | 'prompt_template' | 'skill_root' | 'shell_hook' | 'mcp_server'
494
495 export interface RegisterParams {
496 owner: OwnerRef
497 scope?: EntryRef
498 kind: RegisterKind
499 spec: RegisterSpecWire
500 }
501
502 export type RegisterResult = { handle: number } | { refused: string }
503
504 export interface RegisterSpecWire {
505 name: string
506 description: string
507 input_schema?: { [key: string]: Json }
508 argument_hint?: string
509 }
510
511 export interface RpcErrorWire {
512 code: number
513 message: string
514 data?: Json
515 }
516
517 export interface ToolCallParams {
518 handle: number
519 call_id: string
520 input: Json
521 deadline_ms: number
522 workspace?: string
523 ticket?: string
524 session_id?: string
525 agent_id?: string
526 origin_turn_id?: string
527 }
528
529 export interface ToolResultWire {
530 content: ContentBlockWire[]
531 is_error: boolean
532 structured?: Json
533 }
534
535 export interface UnregisterParams {
536 owner: OwnerRef
537 handle: number
538 }
539
539 lines TYPESCRIPT