Open History to see the last commit
1import { Schema } from "effect";
2import {
3 EventId,
4 IsoDateTime,
5 ProviderItemId,
6 RuntimeItemId,
7 RuntimeRequestId,
8 RuntimeTaskId,
9 ThreadId,
10 TrimmedNonEmptyString,
11 TurnId,
12} from "./baseSchemas";
13import { ProviderKind } from "./orchestration";
14
15const TrimmedNonEmptyStringSchema = TrimmedNonEmptyString;
16const UnknownRecordSchema = Schema.Record(Schema.String, Schema.Unknown);
17
18const RuntimeEventRawSource = Schema.Literals([
19 "codex.app-server.notification",
20 "codex.app-server.request",
21 "codex.eventmsg",
22 "claude.sdk.message",
23 "claude.sdk.permission",
24 "codex.sdk.thread-event",
25 "cursor.acp.notification",
26 "cursor.acp.request",
27 "cursor.acp.response",
28]);
29export type RuntimeEventRawSource = typeof RuntimeEventRawSource.Type;
30
31export const RuntimeEventRaw = Schema.Struct({
32 source: RuntimeEventRawSource,
33 method: Schema.optional(TrimmedNonEmptyStringSchema),
34 messageType: Schema.optional(TrimmedNonEmptyStringSchema),
35 payload: Schema.Unknown,
36});
37export type RuntimeEventRaw = typeof RuntimeEventRaw.Type;
38
39const ProviderRequestId = TrimmedNonEmptyStringSchema;
40export type ProviderRequestId = typeof ProviderRequestId.Type;
41
42const ProviderRefs = Schema.Struct({
43 providerTurnId: Schema.optional(TrimmedNonEmptyStringSchema),
44 providerItemId: Schema.optional(ProviderItemId),
45 providerRequestId: Schema.optional(ProviderRequestId),
46});
47export type ProviderRefs = typeof ProviderRefs.Type;
48
49const RuntimeSessionState = Schema.Literals([
50 "starting",
51 "ready",
52 "running",
53 "waiting",
54 "stopped",
55 "error",
56]);
57export type RuntimeSessionState = typeof RuntimeSessionState.Type;
58
59const RuntimeThreadState = Schema.Literals([
60 "active",
61 "idle",
62 "archived",
63 "closed",
64 "compacted",
65 "error",
66]);
67export type RuntimeThreadState = typeof RuntimeThreadState.Type;
68
69const RuntimeTurnState = Schema.Literals([
70 "completed",
71 "failed",
72 "interrupted",
73 "cancelled",
74]);
75export type RuntimeTurnState = typeof RuntimeTurnState.Type;
76
77const RuntimePlanStepStatus = Schema.Literals(["pending", "inProgress", "completed"]);
78export type RuntimePlanStepStatus = typeof RuntimePlanStepStatus.Type;
79
80const RuntimeItemStatus = Schema.Literals(["inProgress", "completed", "failed", "declined"]);
81export type RuntimeItemStatus = typeof RuntimeItemStatus.Type;
82
83const RuntimeContentStreamKind = Schema.Literals([
84 "assistant_text",
85 "reasoning_text",
86 "reasoning_summary_text",
87 "plan_text",
88 "command_output",
89 "file_change_output",
90 "unknown",
91]);
92export type RuntimeContentStreamKind = typeof RuntimeContentStreamKind.Type;
93
94const RuntimeSessionExitKind = Schema.Literals(["graceful", "error"]);
95export type RuntimeSessionExitKind = typeof RuntimeSessionExitKind.Type;
96
97const RuntimeErrorClass = Schema.Literals([
98 "provider_error",
99 "transport_error",
100 "permission_error",
101 "validation_error",
102 "unknown",
103]);
104export type RuntimeErrorClass = typeof RuntimeErrorClass.Type;
105
106export const CanonicalItemType = Schema.Literals([
107 "user_message",
108 "assistant_message",
109 "reasoning",
110 "plan",
111 "command_execution",
112 "file_change",
113 "mcp_tool_call",
114 "dynamic_tool_call",
115 "collab_agent_tool_call",
116 "web_search",
117 "image_view",
118 "review_entered",
119 "review_exited",
120 "context_compaction",
121 "error",
122 "unknown",
123]);
124export type CanonicalItemType = typeof CanonicalItemType.Type;
125
126export const CanonicalRequestType = Schema.Literals([
127 "command_execution_approval",
128 "file_read_approval",
129 "file_change_approval",
130 "apply_patch_approval",
131 "exec_command_approval",
132 "tool_user_input",
133 "dynamic_tool_call",
134 "auth_tokens_refresh",
135 "unknown",
136]);
137export type CanonicalRequestType = typeof CanonicalRequestType.Type;
138
139const ProviderRuntimeEventType = Schema.Literals([
140 "session.started",
141 "session.configured",
142 "session.state.changed",
143 "session.exited",
144 "thread.started",
145 "thread.state.changed",
146 "thread.metadata.updated",
147 "thread.token-usage.updated",
148 "thread.realtime.started",
149 "thread.realtime.item-added",
150 "thread.realtime.audio.delta",
151 "thread.realtime.error",
152 "thread.realtime.closed",
153 "turn.started",
154 "turn.completed",
155 "turn.aborted",
156 "turn.plan.updated",
157 "turn.proposed.delta",
158 "turn.proposed.completed",
159 "turn.diff.updated",
160 "item.started",
161 "item.updated",
162 "item.completed",
163 "content.delta",
164 "request.opened",
165 "request.resolved",
166 "user-input.requested",
167 "user-input.resolved",
168 "task.started",
169 "task.progress",
170 "task.completed",
171 "hook.started",
172 "hook.progress",
173 "hook.completed",
174 "tool.progress",
175 "tool.summary",
176 "auth.status",
177 "account.updated",
178 "account.rate-limits.updated",
179 "mcp.status.updated",
180 "mcp.oauth.completed",
181 "model.rerouted",
182 "config.warning",
183 "deprecation.notice",
184 "files.persisted",
185 "runtime.warning",
186 "runtime.error",
187]);
188export type ProviderRuntimeEventType = typeof ProviderRuntimeEventType.Type;
189
190const SessionStartedType = Schema.Literal("session.started");
191const SessionConfiguredType = Schema.Literal("session.configured");
192const SessionStateChangedType = Schema.Literal("session.state.changed");
193const SessionExitedType = Schema.Literal("session.exited");
194const ThreadStartedType = Schema.Literal("thread.started");
195const ThreadStateChangedType = Schema.Literal("thread.state.changed");
196const ThreadMetadataUpdatedType = Schema.Literal("thread.metadata.updated");
197const ThreadTokenUsageUpdatedType = Schema.Literal("thread.token-usage.updated");
198const ThreadRealtimeStartedType = Schema.Literal("thread.realtime.started");
199const ThreadRealtimeItemAddedType = Schema.Literal("thread.realtime.item-added");
200const ThreadRealtimeAudioDeltaType = Schema.Literal("thread.realtime.audio.delta");
201const ThreadRealtimeErrorType = Schema.Literal("thread.realtime.error");
202const ThreadRealtimeClosedType = Schema.Literal("thread.realtime.closed");
203const TurnStartedType = Schema.Literal("turn.started");
204const TurnCompletedType = Schema.Literal("turn.completed");
205const TurnAbortedType = Schema.Literal("turn.aborted");
206const TurnPlanUpdatedType = Schema.Literal("turn.plan.updated");
207const TurnProposedDeltaType = Schema.Literal("turn.proposed.delta");
208const TurnProposedCompletedType = Schema.Literal("turn.proposed.completed");
209const TurnDiffUpdatedType = Schema.Literal("turn.diff.updated");
210const ItemStartedType = Schema.Literal("item.started");
211const ItemUpdatedType = Schema.Literal("item.updated");
212const ItemCompletedType = Schema.Literal("item.completed");
213const ContentDeltaType = Schema.Literal("content.delta");
214const RequestOpenedType = Schema.Literal("request.opened");
215const RequestResolvedType = Schema.Literal("request.resolved");
216const UserInputRequestedType = Schema.Literal("user-input.requested");
217const UserInputResolvedType = Schema.Literal("user-input.resolved");
218const TaskStartedType = Schema.Literal("task.started");
219const TaskProgressType = Schema.Literal("task.progress");
220const TaskCompletedType = Schema.Literal("task.completed");
221const HookStartedType = Schema.Literal("hook.started");
222const HookProgressType = Schema.Literal("hook.progress");
223const HookCompletedType = Schema.Literal("hook.completed");
224const ToolProgressType = Schema.Literal("tool.progress");
225const ToolSummaryType = Schema.Literal("tool.summary");
226const AuthStatusType = Schema.Literal("auth.status");
227const AccountUpdatedType = Schema.Literal("account.updated");
228const AccountRateLimitsUpdatedType = Schema.Literal("account.rate-limits.updated");
229const McpStatusUpdatedType = Schema.Literal("mcp.status.updated");
230const McpOauthCompletedType = Schema.Literal("mcp.oauth.completed");
231const ModelReroutedType = Schema.Literal("model.rerouted");
232const ConfigWarningType = Schema.Literal("config.warning");
233const DeprecationNoticeType = Schema.Literal("deprecation.notice");
234const FilesPersistedType = Schema.Literal("files.persisted");
235const RuntimeWarningType = Schema.Literal("runtime.warning");
236const RuntimeErrorType = Schema.Literal("runtime.error");
237
238const ProviderRuntimeEventBase = Schema.Struct({
239 eventId: EventId,
240 provider: ProviderKind,
241 threadId: ThreadId,
242 createdAt: IsoDateTime,
243 turnId: Schema.optional(TurnId),
244 itemId: Schema.optional(RuntimeItemId),
245 requestId: Schema.optional(RuntimeRequestId),
246 providerRefs: Schema.optional(ProviderRefs),
247 raw: Schema.optional(RuntimeEventRaw),
248});
249export type ProviderRuntimeEventBase = typeof ProviderRuntimeEventBase.Type;
250
251const SessionStartedPayload = Schema.Struct({
252 message: Schema.optional(TrimmedNonEmptyStringSchema),
253 resume: Schema.optional(Schema.Unknown),
254});
255export type SessionStartedPayload = typeof SessionStartedPayload.Type;
256
257const SessionConfiguredPayload = Schema.Struct({
258 config: UnknownRecordSchema,
259});
260export type SessionConfiguredPayload = typeof SessionConfiguredPayload.Type;
261
262const SessionStateChangedPayload = Schema.Struct({
263 state: RuntimeSessionState,
264 reason: Schema.optional(TrimmedNonEmptyStringSchema),
265 detail: Schema.optional(Schema.Unknown),
266});
267export type SessionStateChangedPayload = typeof SessionStateChangedPayload.Type;
268
269const SessionExitedPayload = Schema.Struct({
270 reason: Schema.optional(TrimmedNonEmptyStringSchema),
271 recoverable: Schema.optional(Schema.Boolean),
272 exitKind: Schema.optional(RuntimeSessionExitKind),
273});
274export type SessionExitedPayload = typeof SessionExitedPayload.Type;
275
276const ThreadStartedPayload = Schema.Struct({
277 providerThreadId: Schema.optional(TrimmedNonEmptyStringSchema),
278});
279export type ThreadStartedPayload = typeof ThreadStartedPayload.Type;
280
281const ThreadStateChangedPayload = Schema.Struct({
282 state: RuntimeThreadState,
283 detail: Schema.optional(Schema.Unknown),
284});
285export type ThreadStateChangedPayload = typeof ThreadStateChangedPayload.Type;
286
287const ThreadMetadataUpdatedPayload = Schema.Struct({
288 name: Schema.optional(TrimmedNonEmptyStringSchema),
289 metadata: Schema.optional(UnknownRecordSchema),
290});
291export type ThreadMetadataUpdatedPayload = typeof ThreadMetadataUpdatedPayload.Type;
292
293const ThreadTokenUsageUpdatedPayload = Schema.Struct({
294 usage: Schema.Unknown,
295});
296export type ThreadTokenUsageUpdatedPayload = typeof ThreadTokenUsageUpdatedPayload.Type;
297
298const ThreadRealtimeStartedPayload = Schema.Struct({
299 realtimeSessionId: Schema.optional(TrimmedNonEmptyStringSchema),
300});
301export type ThreadRealtimeStartedPayload = typeof ThreadRealtimeStartedPayload.Type;
302
303const ThreadRealtimeItemAddedPayload = Schema.Struct({
304 item: Schema.Unknown,
305});
306export type ThreadRealtimeItemAddedPayload = typeof ThreadRealtimeItemAddedPayload.Type;
307
308const ThreadRealtimeAudioDeltaPayload = Schema.Struct({
309 audio: Schema.Unknown,
310});
311export type ThreadRealtimeAudioDeltaPayload = typeof ThreadRealtimeAudioDeltaPayload.Type;
312
313const ThreadRealtimeErrorPayload = Schema.Struct({
314 message: TrimmedNonEmptyStringSchema,
315});
316export type ThreadRealtimeErrorPayload = typeof ThreadRealtimeErrorPayload.Type;
317
318const ThreadRealtimeClosedPayload = Schema.Struct({
319 reason: Schema.optional(TrimmedNonEmptyStringSchema),
320});
321export type ThreadRealtimeClosedPayload = typeof ThreadRealtimeClosedPayload.Type;
322
323const TurnStartedPayload = Schema.Struct({
324 model: Schema.optional(TrimmedNonEmptyStringSchema),
325 effort: Schema.optional(TrimmedNonEmptyStringSchema),
326});
327export type TurnStartedPayload = typeof TurnStartedPayload.Type;
328
329const TurnCompletedPayload = Schema.Struct({
330 state: RuntimeTurnState,
331 stopReason: Schema.optional(Schema.NullOr(TrimmedNonEmptyStringSchema)),
332 usage: Schema.optional(Schema.Unknown),
333 modelUsage: Schema.optional(UnknownRecordSchema),
334 totalCostUsd: Schema.optional(Schema.Number),
335 errorMessage: Schema.optional(TrimmedNonEmptyStringSchema),
336});
337export type TurnCompletedPayload = typeof TurnCompletedPayload.Type;
338
339const TurnAbortedPayload = Schema.Struct({
340 reason: TrimmedNonEmptyStringSchema,
341});
342export type TurnAbortedPayload = typeof TurnAbortedPayload.Type;
343
344const RuntimePlanStep = Schema.Struct({
345 step: TrimmedNonEmptyStringSchema,
346 status: RuntimePlanStepStatus,
347});
348export type RuntimePlanStep = typeof RuntimePlanStep.Type;
349
350const TurnPlanUpdatedPayload = Schema.Struct({
351 explanation: Schema.optional(Schema.NullOr(TrimmedNonEmptyStringSchema)),
352 plan: Schema.Array(RuntimePlanStep),
353});
354export type TurnPlanUpdatedPayload = typeof TurnPlanUpdatedPayload.Type;
355
356const TurnProposedDeltaPayload = Schema.Struct({
357 delta: Schema.String,
358});
359export type TurnProposedDeltaPayload = typeof TurnProposedDeltaPayload.Type;
360
361const TurnProposedCompletedPayload = Schema.Struct({
362 planMarkdown: TrimmedNonEmptyStringSchema,
363});
364export type TurnProposedCompletedPayload = typeof TurnProposedCompletedPayload.Type;
365
366const TurnDiffUpdatedPayload = Schema.Struct({
367 unifiedDiff: Schema.String,
368});
369export type TurnDiffUpdatedPayload = typeof TurnDiffUpdatedPayload.Type;
370
371export const ItemLifecyclePayload = Schema.Struct({
372 itemType: CanonicalItemType,
373 status: Schema.optional(RuntimeItemStatus),
374 title: Schema.optional(TrimmedNonEmptyStringSchema),
375 detail: Schema.optional(TrimmedNonEmptyStringSchema),
376 data: Schema.optional(Schema.Unknown),
377});
378export type ItemLifecyclePayload = typeof ItemLifecyclePayload.Type;
379
380const ContentDeltaPayload = Schema.Struct({
381 streamKind: RuntimeContentStreamKind,
382 delta: Schema.String,
383 contentIndex: Schema.optional(Schema.Int),
384 summaryIndex: Schema.optional(Schema.Int),
385});
386export type ContentDeltaPayload = typeof ContentDeltaPayload.Type;
387
388const RequestOpenedPayload = Schema.Struct({
389 requestType: CanonicalRequestType,
390 detail: Schema.optional(TrimmedNonEmptyStringSchema),
391 args: Schema.optional(Schema.Unknown),
392});
393export type RequestOpenedPayload = typeof RequestOpenedPayload.Type;
394
395const RequestResolvedPayload = Schema.Struct({
396 requestType: CanonicalRequestType,
397 decision: Schema.optional(TrimmedNonEmptyStringSchema),
398 resolution: Schema.optional(Schema.Unknown),
399});
400export type RequestResolvedPayload = typeof RequestResolvedPayload.Type;
401
402const UserInputQuestionOption = Schema.Struct({
403 label: TrimmedNonEmptyStringSchema,
404 description: TrimmedNonEmptyStringSchema,
405});
406export type UserInputQuestionOption = typeof UserInputQuestionOption.Type;
407
408export const UserInputQuestion = Schema.Struct({
409 id: TrimmedNonEmptyStringSchema,
410 header: TrimmedNonEmptyStringSchema,
411 question: TrimmedNonEmptyStringSchema,
412 options: Schema.Array(UserInputQuestionOption),
413});
414export type UserInputQuestion = typeof UserInputQuestion.Type;
415
416const UserInputRequestedPayload = Schema.Struct({
417 questions: Schema.Array(UserInputQuestion),
418});
419export type UserInputRequestedPayload = typeof UserInputRequestedPayload.Type;
420
421const UserInputResolvedPayload = Schema.Struct({
422 answers: UnknownRecordSchema,
423});
424export type UserInputResolvedPayload = typeof UserInputResolvedPayload.Type;
425
426const TaskStartedPayload = Schema.Struct({
427 taskId: RuntimeTaskId,
428 description: Schema.optional(TrimmedNonEmptyStringSchema),
429 taskType: Schema.optional(TrimmedNonEmptyStringSchema),
430});
431export type TaskStartedPayload = typeof TaskStartedPayload.Type;
432
433const TaskProgressPayload = Schema.Struct({
434 taskId: RuntimeTaskId,
435 description: TrimmedNonEmptyStringSchema,
436 usage: Schema.optional(Schema.Unknown),
437 lastToolName: Schema.optional(TrimmedNonEmptyStringSchema),
438});
439export type TaskProgressPayload = typeof TaskProgressPayload.Type;
440
441const TaskCompletedPayload = Schema.Struct({
442 taskId: RuntimeTaskId,
443 status: Schema.Literals(["completed", "failed", "stopped"]),
444 summary: Schema.optional(TrimmedNonEmptyStringSchema),
445 usage: Schema.optional(Schema.Unknown),
446});
447export type TaskCompletedPayload = typeof TaskCompletedPayload.Type;
448
449const HookStartedPayload = Schema.Struct({
450 hookId: TrimmedNonEmptyStringSchema,
451 hookName: TrimmedNonEmptyStringSchema,
452 hookEvent: TrimmedNonEmptyStringSchema,
453});
454export type HookStartedPayload = typeof HookStartedPayload.Type;
455
456const HookProgressPayload = Schema.Struct({
457 hookId: TrimmedNonEmptyStringSchema,
458 output: Schema.optional(Schema.String),
459 stdout: Schema.optional(Schema.String),
460 stderr: Schema.optional(Schema.String),
461});
462export type HookProgressPayload = typeof HookProgressPayload.Type;
463
464const HookCompletedPayload = Schema.Struct({
465 hookId: TrimmedNonEmptyStringSchema,
466 outcome: Schema.Literals(["success", "error", "cancelled"]),
467 output: Schema.optional(Schema.String),
468 stdout: Schema.optional(Schema.String),
469 stderr: Schema.optional(Schema.String),
470 exitCode: Schema.optional(Schema.Int),
471});
472export type HookCompletedPayload = typeof HookCompletedPayload.Type;
473
474const ToolProgressPayload = Schema.Struct({
475 toolUseId: Schema.optional(TrimmedNonEmptyStringSchema),
476 toolName: Schema.optional(TrimmedNonEmptyStringSchema),
477 summary: Schema.optional(TrimmedNonEmptyStringSchema),
478 elapsedSeconds: Schema.optional(Schema.Number),
479});
480export type ToolProgressPayload = typeof ToolProgressPayload.Type;
481
482const ToolSummaryPayload = Schema.Struct({
483 summary: TrimmedNonEmptyStringSchema,
484 precedingToolUseIds: Schema.optional(Schema.Array(TrimmedNonEmptyStringSchema)),
485});
486export type ToolSummaryPayload = typeof ToolSummaryPayload.Type;
487
488const AuthStatusPayload = Schema.Struct({
489 isAuthenticating: Schema.optional(Schema.Boolean),
490 output: Schema.optional(Schema.Array(Schema.String)),
491 error: Schema.optional(TrimmedNonEmptyStringSchema),
492});
493export type AuthStatusPayload = typeof AuthStatusPayload.Type;
494
495const AccountUpdatedPayload = Schema.Struct({
496 account: Schema.Unknown,
497});
498export type AccountUpdatedPayload = typeof AccountUpdatedPayload.Type;
499
500const AccountRateLimitsUpdatedPayload = Schema.Struct({
501 rateLimits: Schema.Unknown,
502});
503export type AccountRateLimitsUpdatedPayload = typeof AccountRateLimitsUpdatedPayload.Type;
504
505const McpStatusUpdatedPayload = Schema.Struct({
506 status: Schema.Unknown,
507});
508export type McpStatusUpdatedPayload = typeof McpStatusUpdatedPayload.Type;
509
510const McpOauthCompletedPayload = Schema.Struct({
511 success: Schema.Boolean,
512 name: Schema.optional(TrimmedNonEmptyStringSchema),
513 error: Schema.optional(TrimmedNonEmptyStringSchema),
514});
515export type McpOauthCompletedPayload = typeof McpOauthCompletedPayload.Type;
516
517const ModelReroutedPayload = Schema.Struct({
518 fromModel: TrimmedNonEmptyStringSchema,
519 toModel: TrimmedNonEmptyStringSchema,
520 reason: TrimmedNonEmptyStringSchema,
521});
522export type ModelReroutedPayload = typeof ModelReroutedPayload.Type;
523
524const ConfigWarningPayload = Schema.Struct({
525 summary: TrimmedNonEmptyStringSchema,
526 details: Schema.optional(TrimmedNonEmptyStringSchema),
527 path: Schema.optional(TrimmedNonEmptyStringSchema),
528 range: Schema.optional(Schema.Unknown),
529});
530export type ConfigWarningPayload = typeof ConfigWarningPayload.Type;
531
532const DeprecationNoticePayload = Schema.Struct({
533 summary: TrimmedNonEmptyStringSchema,
534 details: Schema.optional(TrimmedNonEmptyStringSchema),
535});
536export type DeprecationNoticePayload = typeof DeprecationNoticePayload.Type;
537
538const FilesPersistedPayload = Schema.Struct({
539 files: Schema.Array(
540 Schema.Struct({
541 filename: TrimmedNonEmptyStringSchema,
542 fileId: TrimmedNonEmptyStringSchema,
543 }),
544 ),
545 failed: Schema.optional(
546 Schema.Array(
547 Schema.Struct({
548 filename: TrimmedNonEmptyStringSchema,
549 error: TrimmedNonEmptyStringSchema,
550 }),
551 ),
552 ),
553});
554export type FilesPersistedPayload = typeof FilesPersistedPayload.Type;
555
556const RuntimeWarningPayload = Schema.Struct({
557 message: TrimmedNonEmptyStringSchema,
558 detail: Schema.optional(Schema.Unknown),
559});
560export type RuntimeWarningPayload = typeof RuntimeWarningPayload.Type;
561
562const RuntimeErrorPayload = Schema.Struct({
563 message: TrimmedNonEmptyStringSchema,
564 class: Schema.optional(RuntimeErrorClass),
565 detail: Schema.optional(Schema.Unknown),
566});
567export type RuntimeErrorPayload = typeof RuntimeErrorPayload.Type;
568
569const ProviderRuntimeSessionStartedEvent = Schema.Struct({
570 ...ProviderRuntimeEventBase.fields,
571 type: SessionStartedType,
572 payload: SessionStartedPayload,
573});
574export type ProviderRuntimeSessionStartedEvent = typeof ProviderRuntimeSessionStartedEvent.Type;
575
576const ProviderRuntimeSessionConfiguredEvent = Schema.Struct({
577 ...ProviderRuntimeEventBase.fields,
578 type: SessionConfiguredType,
579 payload: SessionConfiguredPayload,
580});
581export type ProviderRuntimeSessionConfiguredEvent = typeof ProviderRuntimeSessionConfiguredEvent.Type;
582
583const ProviderRuntimeSessionStateChangedEvent = Schema.Struct({
584 ...ProviderRuntimeEventBase.fields,
585 type: SessionStateChangedType,
586 payload: SessionStateChangedPayload,
587});
588export type ProviderRuntimeSessionStateChangedEvent = typeof ProviderRuntimeSessionStateChangedEvent.Type;
589
590const ProviderRuntimeSessionExitedEvent = Schema.Struct({
591 ...ProviderRuntimeEventBase.fields,
592 type: SessionExitedType,
593 payload: SessionExitedPayload,
594});
595export type ProviderRuntimeSessionExitedEvent = typeof ProviderRuntimeSessionExitedEvent.Type;
596
597const ProviderRuntimeThreadStartedEvent = Schema.Struct({
598 ...ProviderRuntimeEventBase.fields,
599 type: ThreadStartedType,
600 payload: ThreadStartedPayload,
601});
602export type ProviderRuntimeThreadStartedEvent = typeof ProviderRuntimeThreadStartedEvent.Type;
603
604const ProviderRuntimeThreadStateChangedEvent = Schema.Struct({
605 ...ProviderRuntimeEventBase.fields,
606 type: ThreadStateChangedType,
607 payload: ThreadStateChangedPayload,
608});
609export type ProviderRuntimeThreadStateChangedEvent = typeof ProviderRuntimeThreadStateChangedEvent.Type;
610
611const ProviderRuntimeThreadMetadataUpdatedEvent = Schema.Struct({
612 ...ProviderRuntimeEventBase.fields,
613 type: ThreadMetadataUpdatedType,
614 payload: ThreadMetadataUpdatedPayload,
615});
616export type ProviderRuntimeThreadMetadataUpdatedEvent = typeof ProviderRuntimeThreadMetadataUpdatedEvent.Type;
617
618const ProviderRuntimeThreadTokenUsageUpdatedEvent = Schema.Struct({
619 ...ProviderRuntimeEventBase.fields,
620 type: ThreadTokenUsageUpdatedType,
621 payload: ThreadTokenUsageUpdatedPayload,
622});
623export type ProviderRuntimeThreadTokenUsageUpdatedEvent =
624 typeof ProviderRuntimeThreadTokenUsageUpdatedEvent.Type;
625
626const ProviderRuntimeThreadRealtimeStartedEvent = Schema.Struct({
627 ...ProviderRuntimeEventBase.fields,
628 type: ThreadRealtimeStartedType,
629 payload: ThreadRealtimeStartedPayload,
630});
631export type ProviderRuntimeThreadRealtimeStartedEvent =
632 typeof ProviderRuntimeThreadRealtimeStartedEvent.Type;
633
634const ProviderRuntimeThreadRealtimeItemAddedEvent = Schema.Struct({
635 ...ProviderRuntimeEventBase.fields,
636 type: ThreadRealtimeItemAddedType,
637 payload: ThreadRealtimeItemAddedPayload,
638});
639export type ProviderRuntimeThreadRealtimeItemAddedEvent =
640 typeof ProviderRuntimeThreadRealtimeItemAddedEvent.Type;
641
642const ProviderRuntimeThreadRealtimeAudioDeltaEvent = Schema.Struct({
643 ...ProviderRuntimeEventBase.fields,
644 type: ThreadRealtimeAudioDeltaType,
645 payload: ThreadRealtimeAudioDeltaPayload,
646});
647export type ProviderRuntimeThreadRealtimeAudioDeltaEvent =
648 typeof ProviderRuntimeThreadRealtimeAudioDeltaEvent.Type;
649
650const ProviderRuntimeThreadRealtimeErrorEvent = Schema.Struct({
651 ...ProviderRuntimeEventBase.fields,
652 type: ThreadRealtimeErrorType,
653 payload: ThreadRealtimeErrorPayload,
654});
655export type ProviderRuntimeThreadRealtimeErrorEvent =
656 typeof ProviderRuntimeThreadRealtimeErrorEvent.Type;
657
658const ProviderRuntimeThreadRealtimeClosedEvent = Schema.Struct({
659 ...ProviderRuntimeEventBase.fields,
660 type: ThreadRealtimeClosedType,
661 payload: ThreadRealtimeClosedPayload,
662});
663export type ProviderRuntimeThreadRealtimeClosedEvent =
664 typeof ProviderRuntimeThreadRealtimeClosedEvent.Type;
665
666const ProviderRuntimeTurnStartedEvent = Schema.Struct({
667 ...ProviderRuntimeEventBase.fields,
668 type: TurnStartedType,
669 payload: TurnStartedPayload,
670});
671export type ProviderRuntimeTurnStartedEvent = typeof ProviderRuntimeTurnStartedEvent.Type;
672
673const ProviderRuntimeTurnCompletedEvent = Schema.Struct({
674 ...ProviderRuntimeEventBase.fields,
675 type: TurnCompletedType,
676 payload: TurnCompletedPayload,
677});
678export type ProviderRuntimeTurnCompletedEvent = typeof ProviderRuntimeTurnCompletedEvent.Type;
679
680const ProviderRuntimeTurnAbortedEvent = Schema.Struct({
681 ...ProviderRuntimeEventBase.fields,
682 type: TurnAbortedType,
683 payload: TurnAbortedPayload,
684});
685export type ProviderRuntimeTurnAbortedEvent = typeof ProviderRuntimeTurnAbortedEvent.Type;
686
687const ProviderRuntimeTurnPlanUpdatedEvent = Schema.Struct({
688 ...ProviderRuntimeEventBase.fields,
689 type: TurnPlanUpdatedType,
690 payload: TurnPlanUpdatedPayload,
691});
692export type ProviderRuntimeTurnPlanUpdatedEvent = typeof ProviderRuntimeTurnPlanUpdatedEvent.Type;
693
694const ProviderRuntimeTurnProposedDeltaEvent = Schema.Struct({
695 ...ProviderRuntimeEventBase.fields,
696 type: TurnProposedDeltaType,
697 payload: TurnProposedDeltaPayload,
698});
699export type ProviderRuntimeTurnProposedDeltaEvent =
700 typeof ProviderRuntimeTurnProposedDeltaEvent.Type;
701
702const ProviderRuntimeTurnProposedCompletedEvent = Schema.Struct({
703 ...ProviderRuntimeEventBase.fields,
704 type: TurnProposedCompletedType,
705 payload: TurnProposedCompletedPayload,
706});
707export type ProviderRuntimeTurnProposedCompletedEvent =
708 typeof ProviderRuntimeTurnProposedCompletedEvent.Type;
709
710const ProviderRuntimeTurnDiffUpdatedEvent = Schema.Struct({
711 ...ProviderRuntimeEventBase.fields,
712 type: TurnDiffUpdatedType,
713 payload: TurnDiffUpdatedPayload,
714});
715export type ProviderRuntimeTurnDiffUpdatedEvent = typeof ProviderRuntimeTurnDiffUpdatedEvent.Type;
716
717const ProviderRuntimeItemStartedEvent = Schema.Struct({
718 ...ProviderRuntimeEventBase.fields,
719 type: ItemStartedType,
720 payload: ItemLifecyclePayload,
721});
722export type ProviderRuntimeItemStartedEvent = typeof ProviderRuntimeItemStartedEvent.Type;
723
724const ProviderRuntimeItemUpdatedEvent = Schema.Struct({
725 ...ProviderRuntimeEventBase.fields,
726 type: ItemUpdatedType,
727 payload: ItemLifecyclePayload,
728});
729export type ProviderRuntimeItemUpdatedEvent = typeof ProviderRuntimeItemUpdatedEvent.Type;
730
731const ProviderRuntimeItemCompletedEvent = Schema.Struct({
732 ...ProviderRuntimeEventBase.fields,
733 type: ItemCompletedType,
734 payload: ItemLifecyclePayload,
735});
736export type ProviderRuntimeItemCompletedEvent = typeof ProviderRuntimeItemCompletedEvent.Type;
737
738const ProviderRuntimeContentDeltaEvent = Schema.Struct({
739 ...ProviderRuntimeEventBase.fields,
740 type: ContentDeltaType,
741 payload: ContentDeltaPayload,
742});
743export type ProviderRuntimeContentDeltaEvent = typeof ProviderRuntimeContentDeltaEvent.Type;
744
745const ProviderRuntimeRequestOpenedEvent = Schema.Struct({
746 ...ProviderRuntimeEventBase.fields,
747 type: RequestOpenedType,
748 payload: RequestOpenedPayload,
749});
750export type ProviderRuntimeRequestOpenedEvent = typeof ProviderRuntimeRequestOpenedEvent.Type;
751
752const ProviderRuntimeRequestResolvedEvent = Schema.Struct({
753 ...ProviderRuntimeEventBase.fields,
754 type: RequestResolvedType,
755 payload: RequestResolvedPayload,
756});
757export type ProviderRuntimeRequestResolvedEvent = typeof ProviderRuntimeRequestResolvedEvent.Type;
758
759const ProviderRuntimeUserInputRequestedEvent = Schema.Struct({
760 ...ProviderRuntimeEventBase.fields,
761 type: UserInputRequestedType,
762 payload: UserInputRequestedPayload,
763});
764export type ProviderRuntimeUserInputRequestedEvent =
765 typeof ProviderRuntimeUserInputRequestedEvent.Type;
766
767const ProviderRuntimeUserInputResolvedEvent = Schema.Struct({
768 ...ProviderRuntimeEventBase.fields,
769 type: UserInputResolvedType,
770 payload: UserInputResolvedPayload,
771});
772export type ProviderRuntimeUserInputResolvedEvent = typeof ProviderRuntimeUserInputResolvedEvent.Type;
773
774const ProviderRuntimeTaskStartedEvent = Schema.Struct({
775 ...ProviderRuntimeEventBase.fields,
776 type: TaskStartedType,
777 payload: TaskStartedPayload,
778});
779export type ProviderRuntimeTaskStartedEvent = typeof ProviderRuntimeTaskStartedEvent.Type;
780
781const ProviderRuntimeTaskProgressEvent = Schema.Struct({
782 ...ProviderRuntimeEventBase.fields,
783 type: TaskProgressType,
784 payload: TaskProgressPayload,
785});
786export type ProviderRuntimeTaskProgressEvent = typeof ProviderRuntimeTaskProgressEvent.Type;
787
788const ProviderRuntimeTaskCompletedEvent = Schema.Struct({
789 ...ProviderRuntimeEventBase.fields,
790 type: TaskCompletedType,
791 payload: TaskCompletedPayload,
792});
793export type ProviderRuntimeTaskCompletedEvent = typeof ProviderRuntimeTaskCompletedEvent.Type;
794
795const ProviderRuntimeHookStartedEvent = Schema.Struct({
796 ...ProviderRuntimeEventBase.fields,
797 type: HookStartedType,
798 payload: HookStartedPayload,
799});
800export type ProviderRuntimeHookStartedEvent = typeof ProviderRuntimeHookStartedEvent.Type;
801
802const ProviderRuntimeHookProgressEvent = Schema.Struct({
803 ...ProviderRuntimeEventBase.fields,
804 type: HookProgressType,
805 payload: HookProgressPayload,
806});
807export type ProviderRuntimeHookProgressEvent = typeof ProviderRuntimeHookProgressEvent.Type;
808
809const ProviderRuntimeHookCompletedEvent = Schema.Struct({
810 ...ProviderRuntimeEventBase.fields,
811 type: HookCompletedType,
812 payload: HookCompletedPayload,
813});
814export type ProviderRuntimeHookCompletedEvent = typeof ProviderRuntimeHookCompletedEvent.Type;
815
816const ProviderRuntimeToolProgressEvent = Schema.Struct({
817 ...ProviderRuntimeEventBase.fields,
818 type: ToolProgressType,
819 payload: ToolProgressPayload,
820});
821export type ProviderRuntimeToolProgressEvent = typeof ProviderRuntimeToolProgressEvent.Type;
822
823const ProviderRuntimeToolSummaryEvent = Schema.Struct({
824 ...ProviderRuntimeEventBase.fields,
825 type: ToolSummaryType,
826 payload: ToolSummaryPayload,
827});
828export type ProviderRuntimeToolSummaryEvent = typeof ProviderRuntimeToolSummaryEvent.Type;
829
830const ProviderRuntimeAuthStatusEvent = Schema.Struct({
831 ...ProviderRuntimeEventBase.fields,
832 type: AuthStatusType,
833 payload: AuthStatusPayload,
834});
835export type ProviderRuntimeAuthStatusEvent = typeof ProviderRuntimeAuthStatusEvent.Type;
836
837const ProviderRuntimeAccountUpdatedEvent = Schema.Struct({
838 ...ProviderRuntimeEventBase.fields,
839 type: AccountUpdatedType,
840 payload: AccountUpdatedPayload,
841});
842export type ProviderRuntimeAccountUpdatedEvent = typeof ProviderRuntimeAccountUpdatedEvent.Type;
843
844const ProviderRuntimeAccountRateLimitsUpdatedEvent = Schema.Struct({
845 ...ProviderRuntimeEventBase.fields,
846 type: AccountRateLimitsUpdatedType,
847 payload: AccountRateLimitsUpdatedPayload,
848});
849export type ProviderRuntimeAccountRateLimitsUpdatedEvent =
850 typeof ProviderRuntimeAccountRateLimitsUpdatedEvent.Type;
851
852const ProviderRuntimeMcpStatusUpdatedEvent = Schema.Struct({
853 ...ProviderRuntimeEventBase.fields,
854 type: McpStatusUpdatedType,
855 payload: McpStatusUpdatedPayload,
856});
857export type ProviderRuntimeMcpStatusUpdatedEvent = typeof ProviderRuntimeMcpStatusUpdatedEvent.Type;
858
859const ProviderRuntimeMcpOauthCompletedEvent = Schema.Struct({
860 ...ProviderRuntimeEventBase.fields,
861 type: McpOauthCompletedType,
862 payload: McpOauthCompletedPayload,
863});
864export type ProviderRuntimeMcpOauthCompletedEvent = typeof ProviderRuntimeMcpOauthCompletedEvent.Type;
865
866const ProviderRuntimeModelReroutedEvent = Schema.Struct({
867 ...ProviderRuntimeEventBase.fields,
868 type: ModelReroutedType,
869 payload: ModelReroutedPayload,
870});
871export type ProviderRuntimeModelReroutedEvent = typeof ProviderRuntimeModelReroutedEvent.Type;
872
873const ProviderRuntimeConfigWarningEvent = Schema.Struct({
874 ...ProviderRuntimeEventBase.fields,
875 type: ConfigWarningType,
876 payload: ConfigWarningPayload,
877});
878export type ProviderRuntimeConfigWarningEvent = typeof ProviderRuntimeConfigWarningEvent.Type;
879
880const ProviderRuntimeDeprecationNoticeEvent = Schema.Struct({
881 ...ProviderRuntimeEventBase.fields,
882 type: DeprecationNoticeType,
883 payload: DeprecationNoticePayload,
884});
885export type ProviderRuntimeDeprecationNoticeEvent = typeof ProviderRuntimeDeprecationNoticeEvent.Type;
886
887const ProviderRuntimeFilesPersistedEvent = Schema.Struct({
888 ...ProviderRuntimeEventBase.fields,
889 type: FilesPersistedType,
890 payload: FilesPersistedPayload,
891});
892export type ProviderRuntimeFilesPersistedEvent = typeof ProviderRuntimeFilesPersistedEvent.Type;
893
894const ProviderRuntimeWarningEvent = Schema.Struct({
895 ...ProviderRuntimeEventBase.fields,
896 type: RuntimeWarningType,
897 payload: RuntimeWarningPayload,
898});
899export type ProviderRuntimeWarningEvent = typeof ProviderRuntimeWarningEvent.Type;
900
901const ProviderRuntimeErrorEvent = Schema.Struct({
902 ...ProviderRuntimeEventBase.fields,
903 type: RuntimeErrorType,
904 payload: RuntimeErrorPayload,
905});
906export type ProviderRuntimeErrorEvent = typeof ProviderRuntimeErrorEvent.Type;
907
908export const ProviderRuntimeEventV2 = Schema.Union([
909 ProviderRuntimeSessionStartedEvent,
910 ProviderRuntimeSessionConfiguredEvent,
911 ProviderRuntimeSessionStateChangedEvent,
912 ProviderRuntimeSessionExitedEvent,
913 ProviderRuntimeThreadStartedEvent,
914 ProviderRuntimeThreadStateChangedEvent,
915 ProviderRuntimeThreadMetadataUpdatedEvent,
916 ProviderRuntimeThreadTokenUsageUpdatedEvent,
917 ProviderRuntimeThreadRealtimeStartedEvent,
918 ProviderRuntimeThreadRealtimeItemAddedEvent,
919 ProviderRuntimeThreadRealtimeAudioDeltaEvent,
920 ProviderRuntimeThreadRealtimeErrorEvent,
921 ProviderRuntimeThreadRealtimeClosedEvent,
922 ProviderRuntimeTurnStartedEvent,
923 ProviderRuntimeTurnCompletedEvent,
924 ProviderRuntimeTurnAbortedEvent,
925 ProviderRuntimeTurnPlanUpdatedEvent,
926 ProviderRuntimeTurnProposedDeltaEvent,
927 ProviderRuntimeTurnProposedCompletedEvent,
928 ProviderRuntimeTurnDiffUpdatedEvent,
929 ProviderRuntimeItemStartedEvent,
930 ProviderRuntimeItemUpdatedEvent,
931 ProviderRuntimeItemCompletedEvent,
932 ProviderRuntimeContentDeltaEvent,
933 ProviderRuntimeRequestOpenedEvent,
934 ProviderRuntimeRequestResolvedEvent,
935 ProviderRuntimeUserInputRequestedEvent,
936 ProviderRuntimeUserInputResolvedEvent,
937 ProviderRuntimeTaskStartedEvent,
938 ProviderRuntimeTaskProgressEvent,
939 ProviderRuntimeTaskCompletedEvent,
940 ProviderRuntimeHookStartedEvent,
941 ProviderRuntimeHookProgressEvent,
942 ProviderRuntimeHookCompletedEvent,
943 ProviderRuntimeToolProgressEvent,
944 ProviderRuntimeToolSummaryEvent,
945 ProviderRuntimeAuthStatusEvent,
946 ProviderRuntimeAccountUpdatedEvent,
947 ProviderRuntimeAccountRateLimitsUpdatedEvent,
948 ProviderRuntimeMcpStatusUpdatedEvent,
949 ProviderRuntimeMcpOauthCompletedEvent,
950 ProviderRuntimeModelReroutedEvent,
951 ProviderRuntimeConfigWarningEvent,
952 ProviderRuntimeDeprecationNoticeEvent,
953 ProviderRuntimeFilesPersistedEvent,
954 ProviderRuntimeWarningEvent,
955 ProviderRuntimeErrorEvent,
956]);
957export type ProviderRuntimeEventV2 = typeof ProviderRuntimeEventV2.Type;
958
959export const ProviderRuntimeEvent = ProviderRuntimeEventV2;
960export type ProviderRuntimeEvent = ProviderRuntimeEventV2;
961
962// Compatibility aliases for call sites still importing legacy names.
963const ProviderRuntimeMessageDeltaEvent = ProviderRuntimeContentDeltaEvent;
964export type ProviderRuntimeMessageDeltaEvent = ProviderRuntimeContentDeltaEvent;
965const ProviderRuntimeMessageCompletedEvent = ProviderRuntimeItemCompletedEvent;
966export type ProviderRuntimeMessageCompletedEvent = ProviderRuntimeItemCompletedEvent;
967const ProviderRuntimeToolStartedEvent = ProviderRuntimeItemStartedEvent;
968export type ProviderRuntimeToolStartedEvent = ProviderRuntimeItemStartedEvent;
969const ProviderRuntimeToolCompletedEvent = ProviderRuntimeItemCompletedEvent;
970export type ProviderRuntimeToolCompletedEvent = ProviderRuntimeItemCompletedEvent;
971const ProviderRuntimeApprovalRequestedEvent = ProviderRuntimeRequestOpenedEvent;
972export type ProviderRuntimeApprovalRequestedEvent = ProviderRuntimeRequestOpenedEvent;
973const ProviderRuntimeApprovalResolvedEvent = ProviderRuntimeRequestResolvedEvent;
974export type ProviderRuntimeApprovalResolvedEvent = ProviderRuntimeRequestResolvedEvent;
975
976// Legacy helper aliases retained for adapters/tests.
977const ProviderRuntimeToolKind = Schema.Literals([
978 "command",
979 "file-read",
980 "file-change",
981 "other",
982]);
983export type ProviderRuntimeToolKind = typeof ProviderRuntimeToolKind.Type;
984
985export const ProviderRuntimeTurnStatus = RuntimeTurnState;
986export type ProviderRuntimeTurnStatus = RuntimeTurnState;