Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

providerRuntime.ts

981 lines34.8 KB

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