Open History to see the last commit
1import * as Effect from "effect/Effect";
2import * as Schema from "effect/Schema";
3import {
4 EventId,
5 IsoDateTime,
6 NonNegativeInt,
7 ProviderItemId,
8 PositiveInt,
9 RuntimeItemId,
10 RuntimeRequestId,
11 RuntimeTaskId,
12 ThreadId,
13 TrimmedNonEmptyString,
14 TurnId,
15} from "./baseSchemas.ts";
16import { ProviderInstanceId, ProviderDriverKind } from "./providerInstance.ts";
17import { ProviderUsageLimitsUpdate } from "./providerUsageLimits.ts";
18import { ProviderApprovalOption } from "./providerPolicy.ts";
19
20const TrimmedNonEmptyStringSchema = TrimmedNonEmptyString;
21const UnknownRecordSchema = Schema.Record(Schema.String, Schema.Unknown);
22
23const RuntimeEventRawSource = Schema.Union([
24 Schema.Literal("codex.app-server.notification"),
25 Schema.Literal("codex.app-server.request"),
26 Schema.Literal("codex.eventmsg"),
27 Schema.Literal("claude.sdk.message"),
28 Schema.Literal("claude.sdk.permission"),
29 Schema.Literal("codex.sdk.thread-event"),
30 Schema.Literal("opencode.sdk.event"),
31 Schema.Literal("acp.jsonrpc"),
32 Schema.TemplateLiteral(["acp.", Schema.String, ".extension"]),
33]);
34export type RuntimeEventRawSource = typeof RuntimeEventRawSource.Type;
35
36export const RuntimeEventRaw = Schema.Struct({
37 source: RuntimeEventRawSource,
38 method: Schema.optional(TrimmedNonEmptyStringSchema),
39 messageType: Schema.optional(TrimmedNonEmptyStringSchema),
40 payload: Schema.Unknown,
41});
42export type RuntimeEventRaw = typeof RuntimeEventRaw.Type;
43
44const ProviderRequestId = TrimmedNonEmptyStringSchema;
45export type ProviderRequestId = typeof ProviderRequestId.Type;
46
47const ProviderRefs = Schema.Struct({
48 providerTurnId: Schema.optional(TrimmedNonEmptyStringSchema),
49 providerItemId: Schema.optional(ProviderItemId),
50 providerRequestId: Schema.optional(ProviderRequestId),
51});
52export type ProviderRefs = typeof ProviderRefs.Type;
53
54const RuntimeSessionState = Schema.Literals([
55 "starting",
56 "ready",
57 "running",
58 "waiting",
59 "stopped",
60 "error",
61]);
62export type RuntimeSessionState = typeof RuntimeSessionState.Type;
63
64const RuntimeThreadState = Schema.Literals([
65 "active",
66 "idle",
67 "archived",
68 "closed",
69 "compacted",
70 "error",
71]);
72export type RuntimeThreadState = typeof RuntimeThreadState.Type;
73
74const RuntimeTurnState = Schema.Literals(["completed", "failed", "interrupted", "cancelled"]);
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
106const TOOL_LIFECYCLE_ITEM_TYPES = [
107 "command_execution",
108 "file_change",
109 "mcp_tool_call",
110 "dynamic_tool_call",
111 "collab_agent_tool_call",
112 "web_search",
113 "image_view",
114] as const;
115
116export const ToolLifecycleItemType = Schema.Literals(TOOL_LIFECYCLE_ITEM_TYPES);
117export type ToolLifecycleItemType = typeof ToolLifecycleItemType.Type;
118
119export function isToolLifecycleItemType(value: string): value is ToolLifecycleItemType {
120 return TOOL_LIFECYCLE_ITEM_TYPES.includes(value as ToolLifecycleItemType);
121}
122
123export const CanonicalItemType = Schema.Literals([
124 "user_message",
125 "assistant_message",
126 "reasoning",
127 "plan",
128 ...TOOL_LIFECYCLE_ITEM_TYPES,
129 "review_entered",
130 "review_exited",
131 "context_compaction",
132 "error",
133 "unknown",
134]);
135export type CanonicalItemType = typeof CanonicalItemType.Type;
136
137export const CanonicalRequestType = Schema.Literals([
138 "command_execution_approval",
139 "file_read_approval",
140 "file_change_approval",
141 "apply_patch_approval",
142 "exec_command_approval",
143 "mcp_elicitation_approval",
144 "permission_approval",
145 "tool_user_input",
146 "dynamic_tool_call",
147 "auth_tokens_refresh",
148 "unknown",
149]);
150export type CanonicalRequestType = typeof CanonicalRequestType.Type;
151
152const SessionStartedType = Schema.Literal("session.started");
153const SessionConfiguredType = Schema.Literal("session.configured");
154const SessionStateChangedType = Schema.Literal("session.state.changed");
155const SessionExitedType = Schema.Literal("session.exited");
156const ThreadStartedType = Schema.Literal("thread.started");
157const ThreadStateChangedType = Schema.Literal("thread.state.changed");
158const ThreadMetadataUpdatedType = Schema.Literal("thread.metadata.updated");
159const ThreadTokenUsageUpdatedType = Schema.Literal("thread.token-usage.updated");
160const ThreadRealtimeStartedType = Schema.Literal("thread.realtime.started");
161const ThreadRealtimeItemAddedType = Schema.Literal("thread.realtime.item-added");
162const ThreadRealtimeAudioDeltaType = Schema.Literal("thread.realtime.audio.delta");
163const ThreadRealtimeErrorType = Schema.Literal("thread.realtime.error");
164const ThreadRealtimeClosedType = Schema.Literal("thread.realtime.closed");
165const TurnStartedType = Schema.Literal("turn.started");
166const TurnCompletedType = Schema.Literal("turn.completed");
167const TurnAbortedType = Schema.Literal("turn.aborted");
168const TurnPlanUpdatedType = Schema.Literal("turn.plan.updated");
169const TurnProposedDeltaType = Schema.Literal("turn.proposed.delta");
170const TurnProposedCompletedType = Schema.Literal("turn.proposed.completed");
171const TurnDiffUpdatedType = Schema.Literal("turn.diff.updated");
172const ItemStartedType = Schema.Literal("item.started");
173const ItemUpdatedType = Schema.Literal("item.updated");
174const ItemCompletedType = Schema.Literal("item.completed");
175const ContentDeltaType = Schema.Literal("content.delta");
176const RequestOpenedType = Schema.Literal("request.opened");
177const RequestResolvedType = Schema.Literal("request.resolved");
178const UserInputRequestedType = Schema.Literal("user-input.requested");
179const UserInputResolvedType = Schema.Literal("user-input.resolved");
180const TaskStartedType = Schema.Literal("task.started");
181const TaskProgressType = Schema.Literal("task.progress");
182const TaskUpdatedType = Schema.Literal("task.updated");
183const TaskCompletedType = Schema.Literal("task.completed");
184const HookStartedType = Schema.Literal("hook.started");
185const HookProgressType = Schema.Literal("hook.progress");
186const HookCompletedType = Schema.Literal("hook.completed");
187const ToolProgressType = Schema.Literal("tool.progress");
188const ToolSummaryType = Schema.Literal("tool.summary");
189const AuthStatusType = Schema.Literal("auth.status");
190const AccountUpdatedType = Schema.Literal("account.updated");
191const AccountRateLimitsUpdatedType = Schema.Literal("account.rate-limits.updated");
192const McpStatusUpdatedType = Schema.Literal("mcp.status.updated");
193const McpOauthCompletedType = Schema.Literal("mcp.oauth.completed");
194const ModelReroutedType = Schema.Literal("model.rerouted");
195const ConfigWarningType = Schema.Literal("config.warning");
196const DeprecationNoticeType = Schema.Literal("deprecation.notice");
197const FilesPersistedType = Schema.Literal("files.persisted");
198const ToolDeniedType = Schema.Literal("tool.denied");
199const RuntimeWarningType = Schema.Literal("runtime.warning");
200const RuntimeErrorType = Schema.Literal("runtime.error");
201
202const ProviderRuntimeEventBase = Schema.Struct({
203 eventId: EventId,
204 provider: ProviderDriverKind,
205 providerInstanceId: Schema.optional(ProviderInstanceId),
206 threadId: ThreadId,
207 createdAt: IsoDateTime,
208 turnId: Schema.optional(TurnId),
209 itemId: Schema.optional(RuntimeItemId),
210 requestId: Schema.optional(RuntimeRequestId),
211 providerRefs: Schema.optional(ProviderRefs),
212 raw: Schema.optional(RuntimeEventRaw),
213});
214export type ProviderRuntimeEventBase = typeof ProviderRuntimeEventBase.Type;
215
216const SessionStartedPayload = Schema.Struct({
217 message: Schema.optional(TrimmedNonEmptyStringSchema),
218 resume: Schema.optional(Schema.Unknown),
219});
220export type SessionStartedPayload = typeof SessionStartedPayload.Type;
221
222const SessionConfiguredPayload = Schema.Struct({
223 config: UnknownRecordSchema,
224});
225export type SessionConfiguredPayload = typeof SessionConfiguredPayload.Type;
226
227const SessionStateChangedPayload = Schema.Struct({
228 state: RuntimeSessionState,
229 reason: Schema.optional(TrimmedNonEmptyStringSchema),
230 detail: Schema.optional(Schema.Unknown),
231});
232export type SessionStateChangedPayload = typeof SessionStateChangedPayload.Type;
233
234const SessionExitedPayload = Schema.Struct({
235 reason: Schema.optional(TrimmedNonEmptyStringSchema),
236 recoverable: Schema.optional(Schema.Boolean),
237 exitKind: Schema.optional(RuntimeSessionExitKind),
238});
239export type SessionExitedPayload = typeof SessionExitedPayload.Type;
240
241const ThreadStartedPayload = Schema.Struct({
242 providerThreadId: Schema.optional(TrimmedNonEmptyStringSchema),
243});
244export type ThreadStartedPayload = typeof ThreadStartedPayload.Type;
245
246const ThreadStateChangedPayload = Schema.Struct({
247 state: RuntimeThreadState,
248 beforeTokens: Schema.optional(NonNegativeInt),
249 afterTokens: Schema.optional(NonNegativeInt),
250 detail: Schema.optional(Schema.Unknown),
251});
252export type ThreadStateChangedPayload = typeof ThreadStateChangedPayload.Type;
253
254const ThreadMetadataUpdatedPayload = Schema.Struct({
255 name: Schema.optional(TrimmedNonEmptyStringSchema),
256 metadata: Schema.optional(UnknownRecordSchema),
257});
258export type ThreadMetadataUpdatedPayload = typeof ThreadMetadataUpdatedPayload.Type;
259
260export const ThreadTokenUsageSnapshot = Schema.Struct({
261 usedTokens: NonNegativeInt,
262 totalProcessedTokens: Schema.optional(NonNegativeInt),
263 maxTokens: Schema.optional(PositiveInt),
264 inputTokens: Schema.optional(NonNegativeInt),
265 cachedInputTokens: Schema.optional(NonNegativeInt),
266 outputTokens: Schema.optional(NonNegativeInt),
267 reasoningOutputTokens: Schema.optional(NonNegativeInt),
268 lastUsedTokens: Schema.optional(NonNegativeInt),
269 lastInputTokens: Schema.optional(NonNegativeInt),
270 lastCachedInputTokens: Schema.optional(NonNegativeInt),
271 lastOutputTokens: Schema.optional(NonNegativeInt),
272 lastReasoningOutputTokens: Schema.optional(NonNegativeInt),
273 toolUses: Schema.optional(NonNegativeInt),
274 durationMs: Schema.optional(NonNegativeInt),
275 compactsAutomatically: Schema.optional(Schema.Boolean),
276 autoCompactThreshold: Schema.optional(PositiveInt),
277 cost: Schema.optional(
278 Schema.Struct({
279 amount: Schema.Number.check(Schema.isFinite()),
280 currency: TrimmedNonEmptyStringSchema.check(Schema.isMaxLength(32)),
281 }),
282 ),
283});
284export type ThreadTokenUsageSnapshot = typeof ThreadTokenUsageSnapshot.Type;
285
286const ThreadTokenUsageUpdatedPayload = Schema.Struct({
287 usage: ThreadTokenUsageSnapshot,
288});
289export type ThreadTokenUsageUpdatedPayload = typeof ThreadTokenUsageUpdatedPayload.Type;
290
291const ThreadRealtimeStartedPayload = Schema.Struct({
292 realtimeSessionId: Schema.optional(TrimmedNonEmptyStringSchema),
293});
294export type ThreadRealtimeStartedPayload = typeof ThreadRealtimeStartedPayload.Type;
295
296const ThreadRealtimeItemAddedPayload = Schema.Struct({
297 item: Schema.Unknown,
298});
299export type ThreadRealtimeItemAddedPayload = typeof ThreadRealtimeItemAddedPayload.Type;
300
301const ThreadRealtimeAudioDeltaPayload = Schema.Struct({
302 audio: Schema.Unknown,
303});
304export type ThreadRealtimeAudioDeltaPayload = typeof ThreadRealtimeAudioDeltaPayload.Type;
305
306const ThreadRealtimeErrorPayload = Schema.Struct({
307 message: TrimmedNonEmptyStringSchema,
308});
309export type ThreadRealtimeErrorPayload = typeof ThreadRealtimeErrorPayload.Type;
310
311const ThreadRealtimeClosedPayload = Schema.Struct({
312 reason: Schema.optional(TrimmedNonEmptyStringSchema),
313});
314export type ThreadRealtimeClosedPayload = typeof ThreadRealtimeClosedPayload.Type;
315
316const TurnStartedPayload = Schema.Struct({
317 model: Schema.optional(TrimmedNonEmptyStringSchema),
318 effort: Schema.optional(TrimmedNonEmptyStringSchema),
319});
320export type TurnStartedPayload = typeof TurnStartedPayload.Type;
321
322/**
323 * Input includes cache reads and writes. Output includes reasoning, and
324 * reasoningTokens is an optional subset.
325 */
326const TurnTokenUsageCommonFields = {
327 usageScope: Schema.Literal("main_agent"),
328 cachedInputTokens: Schema.optional(NonNegativeInt),
329 cacheCreationTokens: Schema.optional(NonNegativeInt),
330 reasoningTokens: Schema.optional(NonNegativeInt),
331 hasSubagents: Schema.Boolean,
332};
333export const TurnTokenUsage = Schema.Union([
334 Schema.Struct({
335 ...TurnTokenUsageCommonFields,
336 usageStatus: Schema.Literal("complete"),
337 inputTokens: NonNegativeInt,
338 outputTokens: NonNegativeInt,
339 }),
340 Schema.Struct({
341 ...TurnTokenUsageCommonFields,
342 usageStatus: Schema.Literals(["partial", "unavailable"]),
343 inputTokens: Schema.optional(NonNegativeInt),
344 outputTokens: Schema.optional(NonNegativeInt),
345 }),
346]);
347export type TurnTokenUsage = typeof TurnTokenUsage.Type;
348
349const TurnCompletedPayload = Schema.Struct({
350 state: RuntimeTurnState,
351 stopReason: Schema.optional(Schema.NullOr(TrimmedNonEmptyStringSchema)),
352 usage: Schema.optional(Schema.Unknown),
353 modelUsage: Schema.optional(UnknownRecordSchema),
354 totalCostUsd: Schema.optional(Schema.Number),
355 errorMessage: Schema.optional(TrimmedNonEmptyStringSchema),
356 tokenUsage: Schema.optional(TurnTokenUsage),
357});
358export type TurnCompletedPayload = typeof TurnCompletedPayload.Type;
359
360const TurnAbortedPayload = Schema.Struct({
361 reason: TrimmedNonEmptyStringSchema,
362 tokenUsage: Schema.optional(TurnTokenUsage),
363});
364export type TurnAbortedPayload = typeof TurnAbortedPayload.Type;
365
366const RuntimePlanStep = Schema.Struct({
367 step: TrimmedNonEmptyStringSchema,
368 status: RuntimePlanStepStatus,
369});
370export type RuntimePlanStep = typeof RuntimePlanStep.Type;
371
372const TurnPlanUpdatedPayload = Schema.Struct({
373 explanation: Schema.optional(Schema.NullOr(TrimmedNonEmptyStringSchema)),
374 plan: Schema.Array(RuntimePlanStep),
375});
376export type TurnPlanUpdatedPayload = typeof TurnPlanUpdatedPayload.Type;
377
378const TurnProposedDeltaPayload = Schema.Struct({
379 delta: Schema.String,
380});
381export type TurnProposedDeltaPayload = typeof TurnProposedDeltaPayload.Type;
382
383const TurnProposedCompletedPayload = Schema.Struct({
384 planMarkdown: TrimmedNonEmptyStringSchema,
385});
386export type TurnProposedCompletedPayload = typeof TurnProposedCompletedPayload.Type;
387
388const TurnDiffUpdatedPayload = Schema.Struct({
389 unifiedDiff: Schema.String,
390});
391export type TurnDiffUpdatedPayload = typeof TurnDiffUpdatedPayload.Type;
392
393export const ToolActivitySurface = Schema.Literals(["browser", "computer"]);
394export type ToolActivitySurface = typeof ToolActivitySurface.Type;
395
396export const ToolActivityNativeAppReference = Schema.Union([
397 Schema.TaggedStruct("app-id", {
398 appId: TrimmedNonEmptyStringSchema.check(
399 Schema.isMaxLength(512),
400 Schema.isPattern(/^[A-Za-z0-9._-]+$/u),
401 ),
402 }),
403 Schema.TaggedStruct("display-name", {
404 displayName: TrimmedNonEmptyStringSchema.check(Schema.isMaxLength(160)),
405 }),
406]);
407export type ToolActivityNativeAppReference = typeof ToolActivityNativeAppReference.Type;
408
409export const ToolActivityIcon = Schema.Union([
410 Schema.TaggedStruct("website", {
411 pageUrl: TrimmedNonEmptyStringSchema.check(Schema.isMaxLength(4096)),
412 faviconUrl: Schema.optional(TrimmedNonEmptyStringSchema.check(Schema.isMaxLength(4096))),
413 faviconUrlDark: Schema.optional(TrimmedNonEmptyStringSchema.check(Schema.isMaxLength(4096))),
414 }),
415 Schema.TaggedStruct("native-app", {
416 app: ToolActivityNativeAppReference,
417 }),
418 Schema.TaggedStruct("themed-logo", {
419 logoUrl: TrimmedNonEmptyStringSchema.check(Schema.isMaxLength(4096)),
420 logoUrlDark: Schema.optional(TrimmedNonEmptyStringSchema.check(Schema.isMaxLength(4096))),
421 }),
422]);
423export type ToolActivityIcon = typeof ToolActivityIcon.Type;
424
425export const ToolActivitySource = Schema.Struct({
426 key: TrimmedNonEmptyStringSchema.check(Schema.isMaxLength(512)),
427 name: TrimmedNonEmptyStringSchema.check(Schema.isMaxLength(160)),
428 kind: Schema.Literals(["browser", "computer", "integration"]),
429 icon: Schema.optional(ToolActivityIcon),
430});
431export type ToolActivitySource = typeof ToolActivitySource.Type;
432
433export const ItemLifecyclePayload = Schema.Struct({
434 itemType: CanonicalItemType,
435 status: Schema.optional(RuntimeItemStatus),
436 title: Schema.optional(TrimmedNonEmptyStringSchema),
437 detail: Schema.optional(TrimmedNonEmptyStringSchema),
438 toolSurface: Schema.optional(ToolActivitySurface),
439 toolIcon: Schema.optional(ToolActivityIcon),
440 toolSource: Schema.optional(ToolActivitySource),
441 data: Schema.optional(Schema.Unknown),
442 agentId: Schema.optional(TrimmedNonEmptyStringSchema),
443 parentToolUseId: Schema.optional(TrimmedNonEmptyStringSchema),
444});
445export type ItemLifecyclePayload = typeof ItemLifecyclePayload.Type;
446
447const ContentDeltaPayload = Schema.Struct({
448 streamKind: RuntimeContentStreamKind,
449 delta: Schema.String,
450 contentIndex: Schema.optional(Schema.Int),
451 summaryIndex: Schema.optional(Schema.Int),
452});
453export type ContentDeltaPayload = typeof ContentDeltaPayload.Type;
454
455const RequestOpenedPayload = Schema.Struct({
456 requestType: CanonicalRequestType,
457 detail: Schema.optional(TrimmedNonEmptyStringSchema),
458 appName: Schema.optional(TrimmedNonEmptyStringSchema),
459 options: Schema.optional(Schema.Array(ProviderApprovalOption)),
460 args: Schema.optional(Schema.Unknown),
461});
462export type RequestOpenedPayload = typeof RequestOpenedPayload.Type;
463
464const RequestResolvedPayload = Schema.Struct({
465 requestType: CanonicalRequestType,
466 decision: Schema.optional(TrimmedNonEmptyStringSchema),
467 resolution: Schema.optional(Schema.Unknown),
468});
469export type RequestResolvedPayload = typeof RequestResolvedPayload.Type;
470
471const UserInputQuestionOption = Schema.Struct({
472 label: TrimmedNonEmptyStringSchema,
473 description: Schema.String,
474 value: Schema.optional(Schema.String),
475});
476export type UserInputQuestionOption = typeof UserInputQuestionOption.Type;
477
478export const UserInputQuestion = Schema.Struct({
479 id: TrimmedNonEmptyStringSchema,
480 header: TrimmedNonEmptyStringSchema,
481 question: TrimmedNonEmptyStringSchema,
482 options: Schema.Array(UserInputQuestionOption),
483 allowCustomAnswer: Schema.optional(Schema.Boolean),
484 initialAnswer: Schema.optional(Schema.String),
485 multiSelect: Schema.optional(Schema.Boolean).pipe(
486 Schema.withConstructorDefault(Effect.succeed(false)),
487 ),
488});
489export type UserInputQuestion = typeof UserInputQuestion.Type;
490
491export const UserInputRequestedPayload = Schema.Struct({
492 questions: Schema.Array(UserInputQuestion),
493 responseMode: Schema.optional(Schema.Literal("message")),
494});
495export type UserInputRequestedPayload = typeof UserInputRequestedPayload.Type;
496
497const UserInputResolvedPayload = Schema.Struct({
498 answers: UnknownRecordSchema,
499});
500export type UserInputResolvedPayload = typeof UserInputResolvedPayload.Type;
501
502/**
503 * Claude reports per-activation deltas; Codex reports cumulative totals — the
504 * merge strategy is provider-specific and lives in client-runtime.
505 */
506export const RuntimeTaskUsage = Schema.Struct({
507 totalTokens: NonNegativeInt,
508 inputTokens: Schema.optional(NonNegativeInt),
509 cachedInputTokens: Schema.optional(NonNegativeInt),
510 outputTokens: Schema.optional(NonNegativeInt),
511 reasoningOutputTokens: Schema.optional(NonNegativeInt),
512 toolUses: Schema.optional(NonNegativeInt),
513 durationMs: Schema.optional(NonNegativeInt),
514});
515export type RuntimeTaskUsage = typeof RuntimeTaskUsage.Type;
516
517export const TaskWorkflowPhase = Schema.Struct({
518 index: NonNegativeInt,
519 title: TrimmedNonEmptyStringSchema,
520});
521export type TaskWorkflowPhase = typeof TaskWorkflowPhase.Type;
522
523export const TaskRunHandles = Schema.Struct({
524 runId: Schema.optional(TrimmedNonEmptyStringSchema),
525 scriptPath: Schema.optional(TrimmedNonEmptyStringSchema),
526 transcriptDir: Schema.optional(TrimmedNonEmptyStringSchema),
527 /** Only http/https URLs may be stored here — sanitized at the adapter. */
528 sessionUrl: Schema.optional(TrimmedNonEmptyStringSchema),
529});
530export type TaskRunHandles = typeof TaskRunHandles.Type;
531
532/**
533 * Repeated on progress and terminal rows (not just start) so client folds can
534 * reconstruct an agent even when its start row aged out of activity retention.
535 */
536const taskAgentLinkageFields = {
537 taskType: Schema.optional(TrimmedNonEmptyStringSchema),
538 agentKind: Schema.optional(Schema.Literals(["agent", "background"])),
539 agentId: Schema.optional(TrimmedNonEmptyStringSchema),
540 title: Schema.optional(TrimmedNonEmptyStringSchema),
541 role: Schema.optional(TrimmedNonEmptyStringSchema),
542 model: Schema.optional(TrimmedNonEmptyStringSchema),
543 effort: Schema.optional(TrimmedNonEmptyStringSchema),
544 toolUseId: Schema.optional(TrimmedNonEmptyStringSchema),
545 parentAgentId: Schema.optional(TrimmedNonEmptyStringSchema),
546 workflowName: Schema.optional(TrimmedNonEmptyStringSchema),
547 agentIndex: Schema.optional(NonNegativeInt),
548 phaseIndex: Schema.optional(NonNegativeInt),
549 phaseTitle: Schema.optional(TrimmedNonEmptyStringSchema),
550 phases: Schema.optional(Schema.Array(TaskWorkflowPhase)),
551 attempt: Schema.optional(NonNegativeInt),
552 runHandles: Schema.optional(TaskRunHandles),
553 outputFile: Schema.optional(TrimmedNonEmptyStringSchema),
554 agentPath: Schema.optional(TrimmedNonEmptyStringSchema),
555 /**
556 * Set on provider-synthesized child-agent events (Codex) whose activity
557 * belongs in the Agents surface, never the parent timeline.
558 */
559 timelineBypass: Schema.optional(Schema.Boolean),
560} as const;
561
562export const TaskAgentLinkage = Schema.Struct(taskAgentLinkageFields);
563export type TaskAgentLinkage = typeof TaskAgentLinkage.Type;
564
565const TaskStartedPayload = Schema.Struct({
566 taskId: RuntimeTaskId,
567 description: Schema.optional(TrimmedNonEmptyStringSchema),
568 ...taskAgentLinkageFields,
569});
570export type TaskStartedPayload = typeof TaskStartedPayload.Type;
571
572export const RuntimeTaskStatus = Schema.Literals([
573 "pending",
574 "running",
575 "waiting",
576 "idle",
577 "completed",
578 "failed",
579 "cancelled",
580 "interrupted",
581]);
582export type RuntimeTaskStatus = typeof RuntimeTaskStatus.Type;
583
584const TaskProgressPayload = Schema.Struct({
585 taskId: RuntimeTaskId,
586 description: TrimmedNonEmptyStringSchema,
587 summary: Schema.optional(TrimmedNonEmptyStringSchema),
588 usage: Schema.optional(Schema.Unknown),
589 typedUsage: Schema.optional(RuntimeTaskUsage),
590 lastToolName: Schema.optional(TrimmedNonEmptyStringSchema),
591 status: Schema.optional(RuntimeTaskStatus),
592 error: Schema.optional(TrimmedNonEmptyStringSchema),
593 ...taskAgentLinkageFields,
594});
595export type TaskProgressPayload = typeof TaskProgressPayload.Type;
596
597const TaskUpdatedPayload = Schema.Struct({
598 taskId: RuntimeTaskId,
599 status: Schema.optional(RuntimeTaskStatus),
600 description: Schema.optional(TrimmedNonEmptyStringSchema),
601 error: Schema.optional(TrimmedNonEmptyStringSchema),
602 endedAt: Schema.optional(IsoDateTime),
603 isBackgrounded: Schema.optional(Schema.Boolean),
604 ...taskAgentLinkageFields,
605});
606export type TaskUpdatedPayload = typeof TaskUpdatedPayload.Type;
607
608const TaskCompletedPayload = Schema.Struct({
609 taskId: RuntimeTaskId,
610 status: Schema.Literals(["completed", "failed", "stopped"]),
611 summary: Schema.optional(TrimmedNonEmptyStringSchema),
612 usage: Schema.optional(Schema.Unknown),
613 typedUsage: Schema.optional(RuntimeTaskUsage),
614 ...taskAgentLinkageFields,
615});
616export type TaskCompletedPayload = typeof TaskCompletedPayload.Type;
617
618const HookStartedPayload = Schema.Struct({
619 hookId: TrimmedNonEmptyStringSchema,
620 hookName: TrimmedNonEmptyStringSchema,
621 hookEvent: TrimmedNonEmptyStringSchema,
622});
623export type HookStartedPayload = typeof HookStartedPayload.Type;
624
625const HookProgressPayload = Schema.Struct({
626 hookId: TrimmedNonEmptyStringSchema,
627 output: Schema.optional(Schema.String),
628 stdout: Schema.optional(Schema.String),
629 stderr: Schema.optional(Schema.String),
630});
631export type HookProgressPayload = typeof HookProgressPayload.Type;
632
633const HookCompletedPayload = Schema.Struct({
634 hookId: TrimmedNonEmptyStringSchema,
635 outcome: Schema.Literals(["success", "error", "cancelled"]),
636 output: Schema.optional(Schema.String),
637 stdout: Schema.optional(Schema.String),
638 stderr: Schema.optional(Schema.String),
639 exitCode: Schema.optional(Schema.Int),
640});
641export type HookCompletedPayload = typeof HookCompletedPayload.Type;
642
643const ToolProgressPayload = Schema.Struct({
644 toolUseId: Schema.optional(TrimmedNonEmptyStringSchema),
645 toolName: Schema.optional(TrimmedNonEmptyStringSchema),
646 summary: Schema.optional(TrimmedNonEmptyStringSchema),
647 elapsedSeconds: Schema.optional(Schema.Number),
648 taskId: Schema.optional(RuntimeTaskId),
649 parentToolUseId: Schema.optional(TrimmedNonEmptyStringSchema),
650});
651export type ToolProgressPayload = typeof ToolProgressPayload.Type;
652
653const ToolSummaryPayload = Schema.Struct({
654 summary: TrimmedNonEmptyStringSchema,
655 precedingToolUseIds: Schema.optional(Schema.Array(TrimmedNonEmptyStringSchema)),
656});
657export type ToolSummaryPayload = typeof ToolSummaryPayload.Type;
658
659const AuthStatusPayload = Schema.Struct({
660 isAuthenticating: Schema.optional(Schema.Boolean),
661 output: Schema.optional(Schema.Array(Schema.String)),
662 error: Schema.optional(TrimmedNonEmptyStringSchema),
663});
664export type AuthStatusPayload = typeof AuthStatusPayload.Type;
665
666const AccountUpdatedPayload = Schema.Struct({
667 account: Schema.Unknown,
668});
669export type AccountUpdatedPayload = typeof AccountUpdatedPayload.Type;
670
671const AccountRateLimitsUpdatedPayload = Schema.Struct({
672 limits: ProviderUsageLimitsUpdate,
673});
674export type AccountRateLimitsUpdatedPayload = typeof AccountRateLimitsUpdatedPayload.Type;
675
676const McpStatusUpdatedPayload = Schema.Struct({
677 status: Schema.Unknown,
678});
679export type McpStatusUpdatedPayload = typeof McpStatusUpdatedPayload.Type;
680
681const McpOauthCompletedPayload = Schema.Struct({
682 success: Schema.Boolean,
683 name: Schema.optional(TrimmedNonEmptyStringSchema),
684 error: Schema.optional(TrimmedNonEmptyStringSchema),
685});
686export type McpOauthCompletedPayload = typeof McpOauthCompletedPayload.Type;
687
688const ModelReroutedPayload = Schema.Struct({
689 fromModel: TrimmedNonEmptyStringSchema,
690 toModel: TrimmedNonEmptyStringSchema,
691 reason: TrimmedNonEmptyStringSchema,
692});
693export type ModelReroutedPayload = typeof ModelReroutedPayload.Type;
694
695const ConfigWarningPayload = Schema.Struct({
696 summary: TrimmedNonEmptyStringSchema,
697 details: Schema.optional(TrimmedNonEmptyStringSchema),
698 path: Schema.optional(TrimmedNonEmptyStringSchema),
699 range: Schema.optional(Schema.Unknown),
700});
701export type ConfigWarningPayload = typeof ConfigWarningPayload.Type;
702
703const DeprecationNoticePayload = Schema.Struct({
704 summary: TrimmedNonEmptyStringSchema,
705 details: Schema.optional(TrimmedNonEmptyStringSchema),
706});
707export type DeprecationNoticePayload = typeof DeprecationNoticePayload.Type;
708
709const FilesPersistedPayload = Schema.Struct({
710 files: Schema.Array(
711 Schema.Struct({
712 filename: TrimmedNonEmptyStringSchema,
713 fileId: TrimmedNonEmptyStringSchema,
714 }),
715 ),
716 failed: Schema.optional(
717 Schema.Array(
718 Schema.Struct({
719 filename: TrimmedNonEmptyStringSchema,
720 error: TrimmedNonEmptyStringSchema,
721 }),
722 ),
723 ),
724});
725export type FilesPersistedPayload = typeof FilesPersistedPayload.Type;
726
727const ToolDeniedPayload = Schema.Struct({
728 toolName: TrimmedNonEmptyStringSchema,
729 toolUseId: Schema.optional(TrimmedNonEmptyStringSchema),
730 reason: Schema.optional(TrimmedNonEmptyStringSchema),
731 agentId: Schema.optional(TrimmedNonEmptyStringSchema),
732});
733export type ToolDeniedPayload = typeof ToolDeniedPayload.Type;
734
735const RuntimeWarningPayload = Schema.Struct({
736 message: TrimmedNonEmptyStringSchema,
737 detail: Schema.optional(Schema.Unknown),
738});
739export type RuntimeWarningPayload = typeof RuntimeWarningPayload.Type;
740
741const RuntimeErrorPayload = Schema.Struct({
742 message: TrimmedNonEmptyStringSchema,
743 code: Schema.optional(TrimmedNonEmptyStringSchema),
744 class: Schema.optional(RuntimeErrorClass),
745 detail: Schema.optional(Schema.Unknown),
746});
747export type RuntimeErrorPayload = typeof RuntimeErrorPayload.Type;
748
749const ProviderRuntimeSessionStartedEvent = Schema.Struct({
750 ...ProviderRuntimeEventBase.fields,
751 type: SessionStartedType,
752 payload: SessionStartedPayload,
753});
754export type ProviderRuntimeSessionStartedEvent = typeof ProviderRuntimeSessionStartedEvent.Type;
755
756const ProviderRuntimeSessionConfiguredEvent = Schema.Struct({
757 ...ProviderRuntimeEventBase.fields,
758 type: SessionConfiguredType,
759 payload: SessionConfiguredPayload,
760});
761export type ProviderRuntimeSessionConfiguredEvent =
762 typeof ProviderRuntimeSessionConfiguredEvent.Type;
763
764const ProviderRuntimeSessionStateChangedEvent = Schema.Struct({
765 ...ProviderRuntimeEventBase.fields,
766 type: SessionStateChangedType,
767 payload: SessionStateChangedPayload,
768});
769export type ProviderRuntimeSessionStateChangedEvent =
770 typeof ProviderRuntimeSessionStateChangedEvent.Type;
771
772const ProviderRuntimeSessionExitedEvent = Schema.Struct({
773 ...ProviderRuntimeEventBase.fields,
774 type: SessionExitedType,
775 payload: SessionExitedPayload,
776});
777export type ProviderRuntimeSessionExitedEvent = typeof ProviderRuntimeSessionExitedEvent.Type;
778
779const ProviderRuntimeThreadStartedEvent = Schema.Struct({
780 ...ProviderRuntimeEventBase.fields,
781 type: ThreadStartedType,
782 payload: ThreadStartedPayload,
783});
784export type ProviderRuntimeThreadStartedEvent = typeof ProviderRuntimeThreadStartedEvent.Type;
785
786const ProviderRuntimeThreadStateChangedEvent = Schema.Struct({
787 ...ProviderRuntimeEventBase.fields,
788 type: ThreadStateChangedType,
789 payload: ThreadStateChangedPayload,
790});
791export type ProviderRuntimeThreadStateChangedEvent =
792 typeof ProviderRuntimeThreadStateChangedEvent.Type;
793
794const ProviderRuntimeThreadMetadataUpdatedEvent = Schema.Struct({
795 ...ProviderRuntimeEventBase.fields,
796 type: ThreadMetadataUpdatedType,
797 payload: ThreadMetadataUpdatedPayload,
798});
799export type ProviderRuntimeThreadMetadataUpdatedEvent =
800 typeof ProviderRuntimeThreadMetadataUpdatedEvent.Type;
801
802const ProviderRuntimeThreadTokenUsageUpdatedEvent = Schema.Struct({
803 ...ProviderRuntimeEventBase.fields,
804 type: ThreadTokenUsageUpdatedType,
805 payload: ThreadTokenUsageUpdatedPayload,
806});
807export type ProviderRuntimeThreadTokenUsageUpdatedEvent =
808 typeof ProviderRuntimeThreadTokenUsageUpdatedEvent.Type;
809
810const ProviderRuntimeThreadRealtimeStartedEvent = Schema.Struct({
811 ...ProviderRuntimeEventBase.fields,
812 type: ThreadRealtimeStartedType,
813 payload: ThreadRealtimeStartedPayload,
814});
815export type ProviderRuntimeThreadRealtimeStartedEvent =
816 typeof ProviderRuntimeThreadRealtimeStartedEvent.Type;
817
818const ProviderRuntimeThreadRealtimeItemAddedEvent = Schema.Struct({
819 ...ProviderRuntimeEventBase.fields,
820 type: ThreadRealtimeItemAddedType,
821 payload: ThreadRealtimeItemAddedPayload,
822});
823export type ProviderRuntimeThreadRealtimeItemAddedEvent =
824 typeof ProviderRuntimeThreadRealtimeItemAddedEvent.Type;
825
826const ProviderRuntimeThreadRealtimeAudioDeltaEvent = Schema.Struct({
827 ...ProviderRuntimeEventBase.fields,
828 type: ThreadRealtimeAudioDeltaType,
829 payload: ThreadRealtimeAudioDeltaPayload,
830});
831export type ProviderRuntimeThreadRealtimeAudioDeltaEvent =
832 typeof ProviderRuntimeThreadRealtimeAudioDeltaEvent.Type;
833
834const ProviderRuntimeThreadRealtimeErrorEvent = Schema.Struct({
835 ...ProviderRuntimeEventBase.fields,
836 type: ThreadRealtimeErrorType,
837 payload: ThreadRealtimeErrorPayload,
838});
839export type ProviderRuntimeThreadRealtimeErrorEvent =
840 typeof ProviderRuntimeThreadRealtimeErrorEvent.Type;
841
842const ProviderRuntimeThreadRealtimeClosedEvent = Schema.Struct({
843 ...ProviderRuntimeEventBase.fields,
844 type: ThreadRealtimeClosedType,
845 payload: ThreadRealtimeClosedPayload,
846});
847export type ProviderRuntimeThreadRealtimeClosedEvent =
848 typeof ProviderRuntimeThreadRealtimeClosedEvent.Type;
849
850const ProviderRuntimeTurnStartedEvent = Schema.Struct({
851 ...ProviderRuntimeEventBase.fields,
852 type: TurnStartedType,
853 payload: TurnStartedPayload,
854});
855export type ProviderRuntimeTurnStartedEvent = typeof ProviderRuntimeTurnStartedEvent.Type;
856
857const ProviderRuntimeTurnCompletedEvent = Schema.Struct({
858 ...ProviderRuntimeEventBase.fields,
859 type: TurnCompletedType,
860 payload: TurnCompletedPayload,
861});
862export type ProviderRuntimeTurnCompletedEvent = typeof ProviderRuntimeTurnCompletedEvent.Type;
863
864const ProviderRuntimeTurnAbortedEvent = Schema.Struct({
865 ...ProviderRuntimeEventBase.fields,
866 type: TurnAbortedType,
867 payload: TurnAbortedPayload,
868});
869export type ProviderRuntimeTurnAbortedEvent = typeof ProviderRuntimeTurnAbortedEvent.Type;
870
871const ProviderRuntimeTurnPlanUpdatedEvent = Schema.Struct({
872 ...ProviderRuntimeEventBase.fields,
873 type: TurnPlanUpdatedType,
874 payload: TurnPlanUpdatedPayload,
875});
876export type ProviderRuntimeTurnPlanUpdatedEvent = typeof ProviderRuntimeTurnPlanUpdatedEvent.Type;
877
878const ProviderRuntimeTurnProposedDeltaEvent = Schema.Struct({
879 ...ProviderRuntimeEventBase.fields,
880 type: TurnProposedDeltaType,
881 payload: TurnProposedDeltaPayload,
882});
883export type ProviderRuntimeTurnProposedDeltaEvent =
884 typeof ProviderRuntimeTurnProposedDeltaEvent.Type;
885
886const ProviderRuntimeTurnProposedCompletedEvent = Schema.Struct({
887 ...ProviderRuntimeEventBase.fields,
888 type: TurnProposedCompletedType,
889 payload: TurnProposedCompletedPayload,
890});
891export type ProviderRuntimeTurnProposedCompletedEvent =
892 typeof ProviderRuntimeTurnProposedCompletedEvent.Type;
893
894const ProviderRuntimeTurnDiffUpdatedEvent = Schema.Struct({
895 ...ProviderRuntimeEventBase.fields,
896 type: TurnDiffUpdatedType,
897 payload: TurnDiffUpdatedPayload,
898});
899export type ProviderRuntimeTurnDiffUpdatedEvent = typeof ProviderRuntimeTurnDiffUpdatedEvent.Type;
900
901const ProviderRuntimeItemStartedEvent = Schema.Struct({
902 ...ProviderRuntimeEventBase.fields,
903 type: ItemStartedType,
904 payload: ItemLifecyclePayload,
905});
906export type ProviderRuntimeItemStartedEvent = typeof ProviderRuntimeItemStartedEvent.Type;
907
908const ProviderRuntimeItemUpdatedEvent = Schema.Struct({
909 ...ProviderRuntimeEventBase.fields,
910 type: ItemUpdatedType,
911 payload: ItemLifecyclePayload,
912});
913export type ProviderRuntimeItemUpdatedEvent = typeof ProviderRuntimeItemUpdatedEvent.Type;
914
915const ProviderRuntimeItemCompletedEvent = Schema.Struct({
916 ...ProviderRuntimeEventBase.fields,
917 type: ItemCompletedType,
918 payload: ItemLifecyclePayload,
919});
920export type ProviderRuntimeItemCompletedEvent = typeof ProviderRuntimeItemCompletedEvent.Type;
921
922const ProviderRuntimeContentDeltaEvent = Schema.Struct({
923 ...ProviderRuntimeEventBase.fields,
924 type: ContentDeltaType,
925 payload: ContentDeltaPayload,
926});
927export type ProviderRuntimeContentDeltaEvent = typeof ProviderRuntimeContentDeltaEvent.Type;
928
929const ProviderRuntimeRequestOpenedEvent = Schema.Struct({
930 ...ProviderRuntimeEventBase.fields,
931 type: RequestOpenedType,
932 payload: RequestOpenedPayload,
933});
934export type ProviderRuntimeRequestOpenedEvent = typeof ProviderRuntimeRequestOpenedEvent.Type;
935
936const ProviderRuntimeRequestResolvedEvent = Schema.Struct({
937 ...ProviderRuntimeEventBase.fields,
938 type: RequestResolvedType,
939 payload: RequestResolvedPayload,
940});
941export type ProviderRuntimeRequestResolvedEvent = typeof ProviderRuntimeRequestResolvedEvent.Type;
942
943const ProviderRuntimeUserInputRequestedEvent = Schema.Struct({
944 ...ProviderRuntimeEventBase.fields,
945 type: UserInputRequestedType,
946 payload: UserInputRequestedPayload,
947});
948export type ProviderRuntimeUserInputRequestedEvent =
949 typeof ProviderRuntimeUserInputRequestedEvent.Type;
950
951const ProviderRuntimeUserInputResolvedEvent = Schema.Struct({
952 ...ProviderRuntimeEventBase.fields,
953 type: UserInputResolvedType,
954 payload: UserInputResolvedPayload,
955});
956export type ProviderRuntimeUserInputResolvedEvent =
957 typeof ProviderRuntimeUserInputResolvedEvent.Type;
958
959const ProviderRuntimeTaskStartedEvent = Schema.Struct({
960 ...ProviderRuntimeEventBase.fields,
961 type: TaskStartedType,
962 payload: TaskStartedPayload,
963});
964export type ProviderRuntimeTaskStartedEvent = typeof ProviderRuntimeTaskStartedEvent.Type;
965
966const ProviderRuntimeTaskProgressEvent = Schema.Struct({
967 ...ProviderRuntimeEventBase.fields,
968 type: TaskProgressType,
969 payload: TaskProgressPayload,
970});
971export type ProviderRuntimeTaskProgressEvent = typeof ProviderRuntimeTaskProgressEvent.Type;
972
973const ProviderRuntimeTaskUpdatedEvent = Schema.Struct({
974 ...ProviderRuntimeEventBase.fields,
975 type: TaskUpdatedType,
976 payload: TaskUpdatedPayload,
977});
978export type ProviderRuntimeTaskUpdatedEvent = typeof ProviderRuntimeTaskUpdatedEvent.Type;
979
980const ProviderRuntimeTaskCompletedEvent = Schema.Struct({
981 ...ProviderRuntimeEventBase.fields,
982 type: TaskCompletedType,
983 payload: TaskCompletedPayload,
984});
985export type ProviderRuntimeTaskCompletedEvent = typeof ProviderRuntimeTaskCompletedEvent.Type;
986
987const ProviderRuntimeHookStartedEvent = Schema.Struct({
988 ...ProviderRuntimeEventBase.fields,
989 type: HookStartedType,
990 payload: HookStartedPayload,
991});
992export type ProviderRuntimeHookStartedEvent = typeof ProviderRuntimeHookStartedEvent.Type;
993
994const ProviderRuntimeHookProgressEvent = Schema.Struct({
995 ...ProviderRuntimeEventBase.fields,
996 type: HookProgressType,
997 payload: HookProgressPayload,
998});
999export type ProviderRuntimeHookProgressEvent = typeof ProviderRuntimeHookProgressEvent.Type;
1000
1001const ProviderRuntimeHookCompletedEvent = Schema.Struct({
1002 ...ProviderRuntimeEventBase.fields,
1003 type: HookCompletedType,
1004 payload: HookCompletedPayload,
1005});
1006export type ProviderRuntimeHookCompletedEvent = typeof ProviderRuntimeHookCompletedEvent.Type;
1007
1008const ProviderRuntimeToolProgressEvent = Schema.Struct({
1009 ...ProviderRuntimeEventBase.fields,
1010 type: ToolProgressType,
1011 payload: ToolProgressPayload,
1012});
1013export type ProviderRuntimeToolProgressEvent = typeof ProviderRuntimeToolProgressEvent.Type;
1014
1015const ProviderRuntimeToolSummaryEvent = Schema.Struct({
1016 ...ProviderRuntimeEventBase.fields,
1017 type: ToolSummaryType,
1018 payload: ToolSummaryPayload,
1019});
1020export type ProviderRuntimeToolSummaryEvent = typeof ProviderRuntimeToolSummaryEvent.Type;
1021
1022const ProviderRuntimeAuthStatusEvent = Schema.Struct({
1023 ...ProviderRuntimeEventBase.fields,
1024 type: AuthStatusType,
1025 payload: AuthStatusPayload,
1026});
1027export type ProviderRuntimeAuthStatusEvent = typeof ProviderRuntimeAuthStatusEvent.Type;
1028
1029const ProviderRuntimeAccountUpdatedEvent = Schema.Struct({
1030 ...ProviderRuntimeEventBase.fields,
1031 type: AccountUpdatedType,
1032 payload: AccountUpdatedPayload,
1033});
1034export type ProviderRuntimeAccountUpdatedEvent = typeof ProviderRuntimeAccountUpdatedEvent.Type;
1035
1036const ProviderRuntimeAccountRateLimitsUpdatedEvent = Schema.Struct({
1037 ...ProviderRuntimeEventBase.fields,
1038 type: AccountRateLimitsUpdatedType,
1039 payload: AccountRateLimitsUpdatedPayload,
1040});
1041export type ProviderRuntimeAccountRateLimitsUpdatedEvent =
1042 typeof ProviderRuntimeAccountRateLimitsUpdatedEvent.Type;
1043
1044const ProviderRuntimeMcpStatusUpdatedEvent = Schema.Struct({
1045 ...ProviderRuntimeEventBase.fields,
1046 type: McpStatusUpdatedType,
1047 payload: McpStatusUpdatedPayload,
1048});
1049export type ProviderRuntimeMcpStatusUpdatedEvent = typeof ProviderRuntimeMcpStatusUpdatedEvent.Type;
1050
1051const ProviderRuntimeMcpOauthCompletedEvent = Schema.Struct({
1052 ...ProviderRuntimeEventBase.fields,
1053 type: McpOauthCompletedType,
1054 payload: McpOauthCompletedPayload,
1055});
1056export type ProviderRuntimeMcpOauthCompletedEvent =
1057 typeof ProviderRuntimeMcpOauthCompletedEvent.Type;
1058
1059const ProviderRuntimeModelReroutedEvent = Schema.Struct({
1060 ...ProviderRuntimeEventBase.fields,
1061 type: ModelReroutedType,
1062 payload: ModelReroutedPayload,
1063});
1064export type ProviderRuntimeModelReroutedEvent = typeof ProviderRuntimeModelReroutedEvent.Type;
1065
1066const ProviderRuntimeConfigWarningEvent = Schema.Struct({
1067 ...ProviderRuntimeEventBase.fields,
1068 type: ConfigWarningType,
1069 payload: ConfigWarningPayload,
1070});
1071export type ProviderRuntimeConfigWarningEvent = typeof ProviderRuntimeConfigWarningEvent.Type;
1072
1073const ProviderRuntimeDeprecationNoticeEvent = Schema.Struct({
1074 ...ProviderRuntimeEventBase.fields,
1075 type: DeprecationNoticeType,
1076 payload: DeprecationNoticePayload,
1077});
1078export type ProviderRuntimeDeprecationNoticeEvent =
1079 typeof ProviderRuntimeDeprecationNoticeEvent.Type;
1080
1081const ProviderRuntimeFilesPersistedEvent = Schema.Struct({
1082 ...ProviderRuntimeEventBase.fields,
1083 type: FilesPersistedType,
1084 payload: FilesPersistedPayload,
1085});
1086export type ProviderRuntimeFilesPersistedEvent = typeof ProviderRuntimeFilesPersistedEvent.Type;
1087
1088const ProviderRuntimeToolDeniedEvent = Schema.Struct({
1089 ...ProviderRuntimeEventBase.fields,
1090 type: ToolDeniedType,
1091 payload: ToolDeniedPayload,
1092});
1093export type ProviderRuntimeToolDeniedEvent = typeof ProviderRuntimeToolDeniedEvent.Type;
1094
1095const ProviderRuntimeWarningEvent = Schema.Struct({
1096 ...ProviderRuntimeEventBase.fields,
1097 type: RuntimeWarningType,
1098 payload: RuntimeWarningPayload,
1099});
1100export type ProviderRuntimeWarningEvent = typeof ProviderRuntimeWarningEvent.Type;
1101
1102const ProviderRuntimeErrorEvent = Schema.Struct({
1103 ...ProviderRuntimeEventBase.fields,
1104 type: RuntimeErrorType,
1105 payload: RuntimeErrorPayload,
1106});
1107export type ProviderRuntimeErrorEvent = typeof ProviderRuntimeErrorEvent.Type;
1108
1109export const ProviderRuntimeEventV2 = Schema.Union([
1110 ProviderRuntimeSessionStartedEvent,
1111 ProviderRuntimeSessionConfiguredEvent,
1112 ProviderRuntimeSessionStateChangedEvent,
1113 ProviderRuntimeSessionExitedEvent,
1114 ProviderRuntimeThreadStartedEvent,
1115 ProviderRuntimeThreadStateChangedEvent,
1116 ProviderRuntimeThreadMetadataUpdatedEvent,
1117 ProviderRuntimeThreadTokenUsageUpdatedEvent,
1118 ProviderRuntimeThreadRealtimeStartedEvent,
1119 ProviderRuntimeThreadRealtimeItemAddedEvent,
1120 ProviderRuntimeThreadRealtimeAudioDeltaEvent,
1121 ProviderRuntimeThreadRealtimeErrorEvent,
1122 ProviderRuntimeThreadRealtimeClosedEvent,
1123 ProviderRuntimeTurnStartedEvent,
1124 ProviderRuntimeTurnCompletedEvent,
1125 ProviderRuntimeTurnAbortedEvent,
1126 ProviderRuntimeTurnPlanUpdatedEvent,
1127 ProviderRuntimeTurnProposedDeltaEvent,
1128 ProviderRuntimeTurnProposedCompletedEvent,
1129 ProviderRuntimeTurnDiffUpdatedEvent,
1130 ProviderRuntimeItemStartedEvent,
1131 ProviderRuntimeItemUpdatedEvent,
1132 ProviderRuntimeItemCompletedEvent,
1133 ProviderRuntimeContentDeltaEvent,
1134 ProviderRuntimeRequestOpenedEvent,
1135 ProviderRuntimeRequestResolvedEvent,
1136 ProviderRuntimeUserInputRequestedEvent,
1137 ProviderRuntimeUserInputResolvedEvent,
1138 ProviderRuntimeTaskStartedEvent,
1139 ProviderRuntimeTaskProgressEvent,
1140 ProviderRuntimeTaskUpdatedEvent,
1141 ProviderRuntimeTaskCompletedEvent,
1142 ProviderRuntimeHookStartedEvent,
1143 ProviderRuntimeHookProgressEvent,
1144 ProviderRuntimeHookCompletedEvent,
1145 ProviderRuntimeToolProgressEvent,
1146 ProviderRuntimeToolSummaryEvent,
1147 ProviderRuntimeAuthStatusEvent,
1148 ProviderRuntimeAccountUpdatedEvent,
1149 ProviderRuntimeAccountRateLimitsUpdatedEvent,
1150 ProviderRuntimeMcpStatusUpdatedEvent,
1151 ProviderRuntimeMcpOauthCompletedEvent,
1152 ProviderRuntimeModelReroutedEvent,
1153 ProviderRuntimeConfigWarningEvent,
1154 ProviderRuntimeDeprecationNoticeEvent,
1155 ProviderRuntimeFilesPersistedEvent,
1156 ProviderRuntimeToolDeniedEvent,
1157 ProviderRuntimeWarningEvent,
1158 ProviderRuntimeErrorEvent,
1159]);
1160export type ProviderRuntimeEventV2 = typeof ProviderRuntimeEventV2.Type;
1161
1162export const ProviderRuntimeEvent = ProviderRuntimeEventV2;
1163export type ProviderRuntimeEvent = ProviderRuntimeEventV2;
1164
1165export const ProviderRuntimeTurnStatus = RuntimeTurnState;
1166export type ProviderRuntimeTurnStatus = RuntimeTurnState;