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

providerRuntime.ts

1,154 lines42.5 KB

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);
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// Input includes cache reads/writes; output includes the optional reasoningTokens subset.
323const TurnTokenUsageCommonFields = {
324 usageScope: Schema.Literal("main_agent"),
325 cachedInputTokens: Schema.optional(NonNegativeInt),
326 cacheCreationTokens: Schema.optional(NonNegativeInt),
327 reasoningTokens: Schema.optional(NonNegativeInt),
328 hasSubagents: Schema.Boolean,
329};
330export const TurnTokenUsage = Schema.Union([
331 Schema.Struct({
332 ...TurnTokenUsageCommonFields,
333 usageStatus: Schema.Literal("complete"),
334 inputTokens: NonNegativeInt,
335 outputTokens: NonNegativeInt,
336 }),
337 Schema.Struct({
338 ...TurnTokenUsageCommonFields,
339 usageStatus: Schema.Literals(["partial", "unavailable"]),
340 inputTokens: Schema.optional(NonNegativeInt),
341 outputTokens: Schema.optional(NonNegativeInt),
342 }),
343]);
344export type TurnTokenUsage = typeof TurnTokenUsage.Type;
345​
346const TurnCompletedPayload = Schema.Struct({
347 state: RuntimeTurnState,
348 stopReason: Schema.optional(Schema.NullOr(TrimmedNonEmptyStringSchema)),
349 usage: Schema.optional(Schema.Unknown),
350 modelUsage: Schema.optional(UnknownRecordSchema),
351 totalCostUsd: Schema.optional(Schema.Number),
352 errorMessage: Schema.optional(TrimmedNonEmptyStringSchema),
353 tokenUsage: Schema.optional(TurnTokenUsage),
354});
355export type TurnCompletedPayload = typeof TurnCompletedPayload.Type;
356​
357const TurnAbortedPayload = Schema.Struct({
358 reason: TrimmedNonEmptyStringSchema,
359 tokenUsage: Schema.optional(TurnTokenUsage),
360});
361export type TurnAbortedPayload = typeof TurnAbortedPayload.Type;
362​
363const RuntimePlanStep = Schema.Struct({
364 step: TrimmedNonEmptyStringSchema,
365 status: RuntimePlanStepStatus,
366});
367export type RuntimePlanStep = typeof RuntimePlanStep.Type;
368​
369const TurnPlanUpdatedPayload = Schema.Struct({
370 explanation: Schema.optional(Schema.NullOr(TrimmedNonEmptyStringSchema)),
371 plan: Schema.Array(RuntimePlanStep),
372});
373export type TurnPlanUpdatedPayload = typeof TurnPlanUpdatedPayload.Type;
374​
375const TurnProposedDeltaPayload = Schema.Struct({
376 delta: Schema.String,
377});
378export type TurnProposedDeltaPayload = typeof TurnProposedDeltaPayload.Type;
379​
380const TurnProposedCompletedPayload = Schema.Struct({
381 planMarkdown: TrimmedNonEmptyStringSchema,
382});
383export type TurnProposedCompletedPayload = typeof TurnProposedCompletedPayload.Type;
384​
385const TurnDiffUpdatedPayload = Schema.Struct({
386 unifiedDiff: Schema.String,
387});
388export type TurnDiffUpdatedPayload = typeof TurnDiffUpdatedPayload.Type;
389​
390export const ToolActivitySurface = Schema.Literals(["browser", "computer"]);
391export type ToolActivitySurface = typeof ToolActivitySurface.Type;
392​
393export const ToolActivityNativeAppReference = Schema.Union([
394 Schema.TaggedStruct("app-id", {
395 appId: TrimmedNonEmptyStringSchema.check(
396 Schema.isMaxLength(512),
397 Schema.isPattern(/^[A-Za-z0-9._-]+$/u),
398 ),
399 }),
400 Schema.TaggedStruct("display-name", {
401 displayName: TrimmedNonEmptyStringSchema.check(Schema.isMaxLength(160)),
402 }),
403]);
404export type ToolActivityNativeAppReference = typeof ToolActivityNativeAppReference.Type;
405​
406export const ToolActivityIcon = Schema.Union([
407 Schema.TaggedStruct("website", {
408 pageUrl: TrimmedNonEmptyStringSchema.check(Schema.isMaxLength(4096)),
409 faviconUrl: Schema.optional(TrimmedNonEmptyStringSchema.check(Schema.isMaxLength(4096))),
410 faviconUrlDark: Schema.optional(TrimmedNonEmptyStringSchema.check(Schema.isMaxLength(4096))),
411 }),
412 Schema.TaggedStruct("native-app", {
413 app: ToolActivityNativeAppReference,
414 }),
415 Schema.TaggedStruct("themed-logo", {
416 logoUrl: TrimmedNonEmptyStringSchema.check(Schema.isMaxLength(4096)),
417 logoUrlDark: Schema.optional(TrimmedNonEmptyStringSchema.check(Schema.isMaxLength(4096))),
418 }),
419]);
420export type ToolActivityIcon = typeof ToolActivityIcon.Type;
421​
422export const ToolActivitySource = Schema.Struct({
423 key: TrimmedNonEmptyStringSchema.check(Schema.isMaxLength(512)),
424 name: TrimmedNonEmptyStringSchema.check(Schema.isMaxLength(160)),
425 kind: Schema.Literals(["browser", "computer", "integration"]),
426 icon: Schema.optional(ToolActivityIcon),
427});
428export type ToolActivitySource = typeof ToolActivitySource.Type;
429​
430export const ItemLifecyclePayload = Schema.Struct({
431 itemType: CanonicalItemType,
432 status: Schema.optional(RuntimeItemStatus),
433 title: Schema.optional(TrimmedNonEmptyStringSchema),
434 detail: Schema.optional(TrimmedNonEmptyStringSchema),
435 toolSurface: Schema.optional(ToolActivitySurface),
436 toolIcon: Schema.optional(ToolActivityIcon),
437 toolSource: Schema.optional(ToolActivitySource),
438 data: Schema.optional(Schema.Unknown),
439 agentId: Schema.optional(TrimmedNonEmptyStringSchema),
440 parentToolUseId: Schema.optional(TrimmedNonEmptyStringSchema),
441});
442export type ItemLifecyclePayload = typeof ItemLifecyclePayload.Type;
443​
444const ContentDeltaPayload = Schema.Struct({
445 streamKind: RuntimeContentStreamKind,
446 delta: Schema.String,
447 contentIndex: Schema.optional(Schema.Int),
448 summaryIndex: Schema.optional(Schema.Int),
449});
450export type ContentDeltaPayload = typeof ContentDeltaPayload.Type;
451​
452const RequestOpenedPayload = Schema.Struct({
453 requestType: CanonicalRequestType,
454 detail: Schema.optional(TrimmedNonEmptyStringSchema),
455 appName: Schema.optional(TrimmedNonEmptyStringSchema),
456 options: Schema.optional(Schema.Array(ProviderApprovalOption)),
457 args: Schema.optional(Schema.Unknown),
458});
459export type RequestOpenedPayload = typeof RequestOpenedPayload.Type;
460​
461const RequestResolvedPayload = Schema.Struct({
462 requestType: CanonicalRequestType,
463 decision: Schema.optional(TrimmedNonEmptyStringSchema),
464 resolution: Schema.optional(Schema.Unknown),
465});
466export type RequestResolvedPayload = typeof RequestResolvedPayload.Type;
467​
468const UserInputQuestionOption = Schema.Struct({
469 label: TrimmedNonEmptyStringSchema,
470 description: Schema.String,
471 value: Schema.optional(Schema.String),
472});
473export type UserInputQuestionOption = typeof UserInputQuestionOption.Type;
474​
475export const UserInputQuestion = Schema.Struct({
476 id: TrimmedNonEmptyStringSchema,
477 header: TrimmedNonEmptyStringSchema,
478 question: TrimmedNonEmptyStringSchema,
479 options: Schema.Array(UserInputQuestionOption),
480 allowCustomAnswer: Schema.optional(Schema.Boolean),
481 initialAnswer: Schema.optional(Schema.String),
482 multiSelect: Schema.optional(Schema.Boolean).pipe(
483 Schema.withConstructorDefault(Effect.succeed(false)),
484 ),
485});
486export type UserInputQuestion = typeof UserInputQuestion.Type;
487​
488export const UserInputRequestedPayload = Schema.Struct({
489 questions: Schema.Array(UserInputQuestion),
490 responseMode: Schema.optional(Schema.Literal("message")),
491});
492export type UserInputRequestedPayload = typeof UserInputRequestedPayload.Type;
493​
494const UserInputResolvedPayload = Schema.Struct({
495 answers: UnknownRecordSchema,
496});
497export type UserInputResolvedPayload = typeof UserInputResolvedPayload.Type;
498​
499/** Claude reports activation deltas; Codex reports cumulative totals. Merge per provider in client-runtime. */
500export const RuntimeTaskUsage = Schema.Struct({
501 totalTokens: NonNegativeInt,
502 inputTokens: Schema.optional(NonNegativeInt),
503 cachedInputTokens: Schema.optional(NonNegativeInt),
504 outputTokens: Schema.optional(NonNegativeInt),
505 reasoningOutputTokens: Schema.optional(NonNegativeInt),
506 toolUses: Schema.optional(NonNegativeInt),
507 durationMs: Schema.optional(NonNegativeInt),
508});
509export type RuntimeTaskUsage = typeof RuntimeTaskUsage.Type;
510​
511export const TaskWorkflowPhase = Schema.Struct({
512 index: NonNegativeInt,
513 title: TrimmedNonEmptyStringSchema,
514});
515export type TaskWorkflowPhase = typeof TaskWorkflowPhase.Type;
516​
517export const TaskRunHandles = Schema.Struct({
518 runId: Schema.optional(TrimmedNonEmptyStringSchema),
519 scriptPath: Schema.optional(TrimmedNonEmptyStringSchema),
520 transcriptDir: Schema.optional(TrimmedNonEmptyStringSchema),
521 /** Only http/https URLs, sanitized by the adapter. */
522 sessionUrl: Schema.optional(TrimmedNonEmptyStringSchema),
523});
524export type TaskRunHandles = typeof TaskRunHandles.Type;
525​
526// Repeat on progress and terminal rows so agents survive start-row eviction.
527const taskAgentLinkageFields = {
528 taskType: Schema.optional(TrimmedNonEmptyStringSchema),
529 agentKind: Schema.optional(Schema.Literals(["agent", "background"])),
530 agentId: Schema.optional(TrimmedNonEmptyStringSchema),
531 title: Schema.optional(TrimmedNonEmptyStringSchema),
532 role: Schema.optional(TrimmedNonEmptyStringSchema),
533 model: Schema.optional(TrimmedNonEmptyStringSchema),
534 effort: Schema.optional(TrimmedNonEmptyStringSchema),
535 toolUseId: Schema.optional(TrimmedNonEmptyStringSchema),
536 parentAgentId: Schema.optional(TrimmedNonEmptyStringSchema),
537 workflowName: Schema.optional(TrimmedNonEmptyStringSchema),
538 agentIndex: Schema.optional(NonNegativeInt),
539 phaseIndex: Schema.optional(NonNegativeInt),
540 phaseTitle: Schema.optional(TrimmedNonEmptyStringSchema),
541 phases: Schema.optional(Schema.Array(TaskWorkflowPhase)),
542 attempt: Schema.optional(NonNegativeInt),
543 runHandles: Schema.optional(TaskRunHandles),
544 outputFile: Schema.optional(TrimmedNonEmptyStringSchema),
545 agentPath: Schema.optional(TrimmedNonEmptyStringSchema),
546 /** Provider-synthesized child events belong in Agents, never the parent timeline. */
547 timelineBypass: Schema.optional(Schema.Boolean),
548} as const;
549​
550export const TaskAgentLinkage = Schema.Struct(taskAgentLinkageFields);
551export type TaskAgentLinkage = typeof TaskAgentLinkage.Type;
552​
553const TaskStartedPayload = Schema.Struct({
554 taskId: RuntimeTaskId,
555 description: Schema.optional(TrimmedNonEmptyStringSchema),
556 ...taskAgentLinkageFields,
557});
558export type TaskStartedPayload = typeof TaskStartedPayload.Type;
559​
560export const RuntimeTaskStatus = Schema.Literals([
561 "pending",
562 "running",
563 "waiting",
564 "idle",
565 "completed",
566 "failed",
567 "cancelled",
568 "interrupted",
569]);
570export type RuntimeTaskStatus = typeof RuntimeTaskStatus.Type;
571​
572const TaskProgressPayload = Schema.Struct({
573 taskId: RuntimeTaskId,
574 description: TrimmedNonEmptyStringSchema,
575 summary: Schema.optional(TrimmedNonEmptyStringSchema),
576 usage: Schema.optional(Schema.Unknown),
577 typedUsage: Schema.optional(RuntimeTaskUsage),
578 lastToolName: Schema.optional(TrimmedNonEmptyStringSchema),
579 status: Schema.optional(RuntimeTaskStatus),
580 error: Schema.optional(TrimmedNonEmptyStringSchema),
581 ...taskAgentLinkageFields,
582});
583export type TaskProgressPayload = typeof TaskProgressPayload.Type;
584​
585const TaskUpdatedPayload = Schema.Struct({
586 taskId: RuntimeTaskId,
587 status: Schema.optional(RuntimeTaskStatus),
588 description: Schema.optional(TrimmedNonEmptyStringSchema),
589 error: Schema.optional(TrimmedNonEmptyStringSchema),
590 endedAt: Schema.optional(IsoDateTime),
591 isBackgrounded: Schema.optional(Schema.Boolean),
592 ...taskAgentLinkageFields,
593});
594export type TaskUpdatedPayload = typeof TaskUpdatedPayload.Type;
595​
596const TaskCompletedPayload = Schema.Struct({
597 taskId: RuntimeTaskId,
598 status: Schema.Literals(["completed", "failed", "stopped"]),
599 summary: Schema.optional(TrimmedNonEmptyStringSchema),
600 usage: Schema.optional(Schema.Unknown),
601 typedUsage: Schema.optional(RuntimeTaskUsage),
602 ...taskAgentLinkageFields,
603});
604export type TaskCompletedPayload = typeof TaskCompletedPayload.Type;
605​
606const HookStartedPayload = Schema.Struct({
607 hookId: TrimmedNonEmptyStringSchema,
608 hookName: TrimmedNonEmptyStringSchema,
609 hookEvent: TrimmedNonEmptyStringSchema,
610});
611export type HookStartedPayload = typeof HookStartedPayload.Type;
612​
613const HookProgressPayload = Schema.Struct({
614 hookId: TrimmedNonEmptyStringSchema,
615 output: Schema.optional(Schema.String),
616 stdout: Schema.optional(Schema.String),
617 stderr: Schema.optional(Schema.String),
618});
619export type HookProgressPayload = typeof HookProgressPayload.Type;
620​
621const HookCompletedPayload = Schema.Struct({
622 hookId: TrimmedNonEmptyStringSchema,
623 outcome: Schema.Literals(["success", "error", "cancelled"]),
624 output: Schema.optional(Schema.String),
625 stdout: Schema.optional(Schema.String),
626 stderr: Schema.optional(Schema.String),
627 exitCode: Schema.optional(Schema.Int),
628});
629export type HookCompletedPayload = typeof HookCompletedPayload.Type;
630​
631const ToolProgressPayload = Schema.Struct({
632 toolUseId: Schema.optional(TrimmedNonEmptyStringSchema),
633 toolName: Schema.optional(TrimmedNonEmptyStringSchema),
634 summary: Schema.optional(TrimmedNonEmptyStringSchema),
635 elapsedSeconds: Schema.optional(Schema.Number),
636 taskId: Schema.optional(RuntimeTaskId),
637 parentToolUseId: Schema.optional(TrimmedNonEmptyStringSchema),
638});
639export type ToolProgressPayload = typeof ToolProgressPayload.Type;
640​
641const ToolSummaryPayload = Schema.Struct({
642 summary: TrimmedNonEmptyStringSchema,
643 precedingToolUseIds: Schema.optional(Schema.Array(TrimmedNonEmptyStringSchema)),
644});
645export type ToolSummaryPayload = typeof ToolSummaryPayload.Type;
646​
647const AuthStatusPayload = Schema.Struct({
648 isAuthenticating: Schema.optional(Schema.Boolean),
649 output: Schema.optional(Schema.Array(Schema.String)),
650 error: Schema.optional(TrimmedNonEmptyStringSchema),
651});
652export type AuthStatusPayload = typeof AuthStatusPayload.Type;
653​
654const AccountUpdatedPayload = Schema.Struct({
655 account: Schema.Unknown,
656});
657export type AccountUpdatedPayload = typeof AccountUpdatedPayload.Type;
658​
659const AccountRateLimitsUpdatedPayload = Schema.Struct({
660 limits: ProviderUsageLimitsUpdate,
661});
662export type AccountRateLimitsUpdatedPayload = typeof AccountRateLimitsUpdatedPayload.Type;
663​
664const McpStatusUpdatedPayload = Schema.Struct({
665 status: Schema.Unknown,
666});
667export type McpStatusUpdatedPayload = typeof McpStatusUpdatedPayload.Type;
668​
669const McpOauthCompletedPayload = Schema.Struct({
670 success: Schema.Boolean,
671 name: Schema.optional(TrimmedNonEmptyStringSchema),
672 error: Schema.optional(TrimmedNonEmptyStringSchema),
673});
674export type McpOauthCompletedPayload = typeof McpOauthCompletedPayload.Type;
675​
676const ModelReroutedPayload = Schema.Struct({
677 fromModel: TrimmedNonEmptyStringSchema,
678 toModel: TrimmedNonEmptyStringSchema,
679 reason: TrimmedNonEmptyStringSchema,
680});
681export type ModelReroutedPayload = typeof ModelReroutedPayload.Type;
682​
683const ConfigWarningPayload = Schema.Struct({
684 summary: TrimmedNonEmptyStringSchema,
685 details: Schema.optional(TrimmedNonEmptyStringSchema),
686 path: Schema.optional(TrimmedNonEmptyStringSchema),
687 range: Schema.optional(Schema.Unknown),
688});
689export type ConfigWarningPayload = typeof ConfigWarningPayload.Type;
690​
691const DeprecationNoticePayload = Schema.Struct({
692 summary: TrimmedNonEmptyStringSchema,
693 details: Schema.optional(TrimmedNonEmptyStringSchema),
694});
695export type DeprecationNoticePayload = typeof DeprecationNoticePayload.Type;
696​
697const FilesPersistedPayload = Schema.Struct({
698 files: Schema.Array(
699 Schema.Struct({
700 filename: TrimmedNonEmptyStringSchema,
701 fileId: TrimmedNonEmptyStringSchema,
702 }),
703 ),
704 failed: Schema.optional(
705 Schema.Array(
706 Schema.Struct({
707 filename: TrimmedNonEmptyStringSchema,
708 error: TrimmedNonEmptyStringSchema,
709 }),
710 ),
711 ),
712});
713export type FilesPersistedPayload = typeof FilesPersistedPayload.Type;
714​
715const ToolDeniedPayload = Schema.Struct({
716 toolName: TrimmedNonEmptyStringSchema,
717 toolUseId: Schema.optional(TrimmedNonEmptyStringSchema),
718 reason: Schema.optional(TrimmedNonEmptyStringSchema),
719 agentId: Schema.optional(TrimmedNonEmptyStringSchema),
720});
721export type ToolDeniedPayload = typeof ToolDeniedPayload.Type;
722​
723const RuntimeWarningPayload = Schema.Struct({
724 message: TrimmedNonEmptyStringSchema,
725 detail: Schema.optional(Schema.Unknown),
726});
727export type RuntimeWarningPayload = typeof RuntimeWarningPayload.Type;
728​
729const RuntimeErrorPayload = Schema.Struct({
730 message: TrimmedNonEmptyStringSchema,
731 code: Schema.optional(TrimmedNonEmptyStringSchema),
732 class: Schema.optional(RuntimeErrorClass),
733 detail: Schema.optional(Schema.Unknown),
734});
735export type RuntimeErrorPayload = typeof RuntimeErrorPayload.Type;
736​
737const ProviderRuntimeSessionStartedEvent = Schema.Struct({
738 ...ProviderRuntimeEventBase.fields,
739 type: SessionStartedType,
740 payload: SessionStartedPayload,
741});
742export type ProviderRuntimeSessionStartedEvent = typeof ProviderRuntimeSessionStartedEvent.Type;
743​
744const ProviderRuntimeSessionConfiguredEvent = Schema.Struct({
745 ...ProviderRuntimeEventBase.fields,
746 type: SessionConfiguredType,
747 payload: SessionConfiguredPayload,
748});
749export type ProviderRuntimeSessionConfiguredEvent =
750 typeof ProviderRuntimeSessionConfiguredEvent.Type;
751​
752const ProviderRuntimeSessionStateChangedEvent = Schema.Struct({
753 ...ProviderRuntimeEventBase.fields,
754 type: SessionStateChangedType,
755 payload: SessionStateChangedPayload,
756});
757export type ProviderRuntimeSessionStateChangedEvent =
758 typeof ProviderRuntimeSessionStateChangedEvent.Type;
759​
760const ProviderRuntimeSessionExitedEvent = Schema.Struct({
761 ...ProviderRuntimeEventBase.fields,
762 type: SessionExitedType,
763 payload: SessionExitedPayload,
764});
765export type ProviderRuntimeSessionExitedEvent = typeof ProviderRuntimeSessionExitedEvent.Type;
766​
767const ProviderRuntimeThreadStartedEvent = Schema.Struct({
768 ...ProviderRuntimeEventBase.fields,
769 type: ThreadStartedType,
770 payload: ThreadStartedPayload,
771});
772export type ProviderRuntimeThreadStartedEvent = typeof ProviderRuntimeThreadStartedEvent.Type;
773​
774const ProviderRuntimeThreadStateChangedEvent = Schema.Struct({
775 ...ProviderRuntimeEventBase.fields,
776 type: ThreadStateChangedType,
777 payload: ThreadStateChangedPayload,
778});
779export type ProviderRuntimeThreadStateChangedEvent =
780 typeof ProviderRuntimeThreadStateChangedEvent.Type;
781​
782const ProviderRuntimeThreadMetadataUpdatedEvent = Schema.Struct({
783 ...ProviderRuntimeEventBase.fields,
784 type: ThreadMetadataUpdatedType,
785 payload: ThreadMetadataUpdatedPayload,
786});
787export type ProviderRuntimeThreadMetadataUpdatedEvent =
788 typeof ProviderRuntimeThreadMetadataUpdatedEvent.Type;
789​
790const ProviderRuntimeThreadTokenUsageUpdatedEvent = Schema.Struct({
791 ...ProviderRuntimeEventBase.fields,
792 type: ThreadTokenUsageUpdatedType,
793 payload: ThreadTokenUsageUpdatedPayload,
794});
795export type ProviderRuntimeThreadTokenUsageUpdatedEvent =
796 typeof ProviderRuntimeThreadTokenUsageUpdatedEvent.Type;
797​
798const ProviderRuntimeThreadRealtimeStartedEvent = Schema.Struct({
799 ...ProviderRuntimeEventBase.fields,
800 type: ThreadRealtimeStartedType,
801 payload: ThreadRealtimeStartedPayload,
802});
803export type ProviderRuntimeThreadRealtimeStartedEvent =
804 typeof ProviderRuntimeThreadRealtimeStartedEvent.Type;
805​
806const ProviderRuntimeThreadRealtimeItemAddedEvent = Schema.Struct({
807 ...ProviderRuntimeEventBase.fields,
808 type: ThreadRealtimeItemAddedType,
809 payload: ThreadRealtimeItemAddedPayload,
810});
811export type ProviderRuntimeThreadRealtimeItemAddedEvent =
812 typeof ProviderRuntimeThreadRealtimeItemAddedEvent.Type;
813​
814const ProviderRuntimeThreadRealtimeAudioDeltaEvent = Schema.Struct({
815 ...ProviderRuntimeEventBase.fields,
816 type: ThreadRealtimeAudioDeltaType,
817 payload: ThreadRealtimeAudioDeltaPayload,
818});
819export type ProviderRuntimeThreadRealtimeAudioDeltaEvent =
820 typeof ProviderRuntimeThreadRealtimeAudioDeltaEvent.Type;
821​
822const ProviderRuntimeThreadRealtimeErrorEvent = Schema.Struct({
823 ...ProviderRuntimeEventBase.fields,
824 type: ThreadRealtimeErrorType,
825 payload: ThreadRealtimeErrorPayload,
826});
827export type ProviderRuntimeThreadRealtimeErrorEvent =
828 typeof ProviderRuntimeThreadRealtimeErrorEvent.Type;
829​
830const ProviderRuntimeThreadRealtimeClosedEvent = Schema.Struct({
831 ...ProviderRuntimeEventBase.fields,
832 type: ThreadRealtimeClosedType,
833 payload: ThreadRealtimeClosedPayload,
834});
835export type ProviderRuntimeThreadRealtimeClosedEvent =
836 typeof ProviderRuntimeThreadRealtimeClosedEvent.Type;
837​
838const ProviderRuntimeTurnStartedEvent = Schema.Struct({
839 ...ProviderRuntimeEventBase.fields,
840 type: TurnStartedType,
841 payload: TurnStartedPayload,
842});
843export type ProviderRuntimeTurnStartedEvent = typeof ProviderRuntimeTurnStartedEvent.Type;
844​
845const ProviderRuntimeTurnCompletedEvent = Schema.Struct({
846 ...ProviderRuntimeEventBase.fields,
847 type: TurnCompletedType,
848 payload: TurnCompletedPayload,
849});
850export type ProviderRuntimeTurnCompletedEvent = typeof ProviderRuntimeTurnCompletedEvent.Type;
851​
852const ProviderRuntimeTurnAbortedEvent = Schema.Struct({
853 ...ProviderRuntimeEventBase.fields,
854 type: TurnAbortedType,
855 payload: TurnAbortedPayload,
856});
857export type ProviderRuntimeTurnAbortedEvent = typeof ProviderRuntimeTurnAbortedEvent.Type;
858​
859const ProviderRuntimeTurnPlanUpdatedEvent = Schema.Struct({
860 ...ProviderRuntimeEventBase.fields,
861 type: TurnPlanUpdatedType,
862 payload: TurnPlanUpdatedPayload,
863});
864export type ProviderRuntimeTurnPlanUpdatedEvent = typeof ProviderRuntimeTurnPlanUpdatedEvent.Type;
865​
866const ProviderRuntimeTurnProposedDeltaEvent = Schema.Struct({
867 ...ProviderRuntimeEventBase.fields,
868 type: TurnProposedDeltaType,
869 payload: TurnProposedDeltaPayload,
870});
871export type ProviderRuntimeTurnProposedDeltaEvent =
872 typeof ProviderRuntimeTurnProposedDeltaEvent.Type;
873​
874const ProviderRuntimeTurnProposedCompletedEvent = Schema.Struct({
875 ...ProviderRuntimeEventBase.fields,
876 type: TurnProposedCompletedType,
877 payload: TurnProposedCompletedPayload,
878});
879export type ProviderRuntimeTurnProposedCompletedEvent =
880 typeof ProviderRuntimeTurnProposedCompletedEvent.Type;
881​
882const ProviderRuntimeTurnDiffUpdatedEvent = Schema.Struct({
883 ...ProviderRuntimeEventBase.fields,
884 type: TurnDiffUpdatedType,
885 payload: TurnDiffUpdatedPayload,
886});
887export type ProviderRuntimeTurnDiffUpdatedEvent = typeof ProviderRuntimeTurnDiffUpdatedEvent.Type;
888​
889const ProviderRuntimeItemStartedEvent = Schema.Struct({
890 ...ProviderRuntimeEventBase.fields,
891 type: ItemStartedType,
892 payload: ItemLifecyclePayload,
893});
894export type ProviderRuntimeItemStartedEvent = typeof ProviderRuntimeItemStartedEvent.Type;
895​
896const ProviderRuntimeItemUpdatedEvent = Schema.Struct({
897 ...ProviderRuntimeEventBase.fields,
898 type: ItemUpdatedType,
899 payload: ItemLifecyclePayload,
900});
901export type ProviderRuntimeItemUpdatedEvent = typeof ProviderRuntimeItemUpdatedEvent.Type;
902​
903const ProviderRuntimeItemCompletedEvent = Schema.Struct({
904 ...ProviderRuntimeEventBase.fields,
905 type: ItemCompletedType,
906 payload: ItemLifecyclePayload,
907});
908export type ProviderRuntimeItemCompletedEvent = typeof ProviderRuntimeItemCompletedEvent.Type;
909​
910const ProviderRuntimeContentDeltaEvent = Schema.Struct({
911 ...ProviderRuntimeEventBase.fields,
912 type: ContentDeltaType,
913 payload: ContentDeltaPayload,
914});
915export type ProviderRuntimeContentDeltaEvent = typeof ProviderRuntimeContentDeltaEvent.Type;
916​
917const ProviderRuntimeRequestOpenedEvent = Schema.Struct({
918 ...ProviderRuntimeEventBase.fields,
919 type: RequestOpenedType,
920 payload: RequestOpenedPayload,
921});
922export type ProviderRuntimeRequestOpenedEvent = typeof ProviderRuntimeRequestOpenedEvent.Type;
923​
924const ProviderRuntimeRequestResolvedEvent = Schema.Struct({
925 ...ProviderRuntimeEventBase.fields,
926 type: RequestResolvedType,
927 payload: RequestResolvedPayload,
928});
929export type ProviderRuntimeRequestResolvedEvent = typeof ProviderRuntimeRequestResolvedEvent.Type;
930​
931const ProviderRuntimeUserInputRequestedEvent = Schema.Struct({
932 ...ProviderRuntimeEventBase.fields,
933 type: UserInputRequestedType,
934 payload: UserInputRequestedPayload,
935});
936export type ProviderRuntimeUserInputRequestedEvent =
937 typeof ProviderRuntimeUserInputRequestedEvent.Type;
938​
939const ProviderRuntimeUserInputResolvedEvent = Schema.Struct({
940 ...ProviderRuntimeEventBase.fields,
941 type: UserInputResolvedType,
942 payload: UserInputResolvedPayload,
943});
944export type ProviderRuntimeUserInputResolvedEvent =
945 typeof ProviderRuntimeUserInputResolvedEvent.Type;
946​
947const ProviderRuntimeTaskStartedEvent = Schema.Struct({
948 ...ProviderRuntimeEventBase.fields,
949 type: TaskStartedType,
950 payload: TaskStartedPayload,
951});
952export type ProviderRuntimeTaskStartedEvent = typeof ProviderRuntimeTaskStartedEvent.Type;
953​
954const ProviderRuntimeTaskProgressEvent = Schema.Struct({
955 ...ProviderRuntimeEventBase.fields,
956 type: TaskProgressType,
957 payload: TaskProgressPayload,
958});
959export type ProviderRuntimeTaskProgressEvent = typeof ProviderRuntimeTaskProgressEvent.Type;
960​
961const ProviderRuntimeTaskUpdatedEvent = Schema.Struct({
962 ...ProviderRuntimeEventBase.fields,
963 type: TaskUpdatedType,
964 payload: TaskUpdatedPayload,
965});
966export type ProviderRuntimeTaskUpdatedEvent = typeof ProviderRuntimeTaskUpdatedEvent.Type;
967​
968const ProviderRuntimeTaskCompletedEvent = Schema.Struct({
969 ...ProviderRuntimeEventBase.fields,
970 type: TaskCompletedType,
971 payload: TaskCompletedPayload,
972});
973export type ProviderRuntimeTaskCompletedEvent = typeof ProviderRuntimeTaskCompletedEvent.Type;
974​
975const ProviderRuntimeHookStartedEvent = Schema.Struct({
976 ...ProviderRuntimeEventBase.fields,
977 type: HookStartedType,
978 payload: HookStartedPayload,
979});
980export type ProviderRuntimeHookStartedEvent = typeof ProviderRuntimeHookStartedEvent.Type;
981​
982const ProviderRuntimeHookProgressEvent = Schema.Struct({
983 ...ProviderRuntimeEventBase.fields,
984 type: HookProgressType,
985 payload: HookProgressPayload,
986});
987export type ProviderRuntimeHookProgressEvent = typeof ProviderRuntimeHookProgressEvent.Type;
988​
989const ProviderRuntimeHookCompletedEvent = Schema.Struct({
990 ...ProviderRuntimeEventBase.fields,
991 type: HookCompletedType,
992 payload: HookCompletedPayload,
993});
994export type ProviderRuntimeHookCompletedEvent = typeof ProviderRuntimeHookCompletedEvent.Type;
995​
996const ProviderRuntimeToolProgressEvent = Schema.Struct({
997 ...ProviderRuntimeEventBase.fields,
998 type: ToolProgressType,
999 payload: ToolProgressPayload,
1000});
1001export type ProviderRuntimeToolProgressEvent = typeof ProviderRuntimeToolProgressEvent.Type;
1002​
1003const ProviderRuntimeToolSummaryEvent = Schema.Struct({
1004 ...ProviderRuntimeEventBase.fields,
1005 type: ToolSummaryType,
1006 payload: ToolSummaryPayload,
1007});
1008export type ProviderRuntimeToolSummaryEvent = typeof ProviderRuntimeToolSummaryEvent.Type;
1009​
1010const ProviderRuntimeAuthStatusEvent = Schema.Struct({
1011 ...ProviderRuntimeEventBase.fields,
1012 type: AuthStatusType,
1013 payload: AuthStatusPayload,
1014});
1015export type ProviderRuntimeAuthStatusEvent = typeof ProviderRuntimeAuthStatusEvent.Type;
1016​
1017const ProviderRuntimeAccountUpdatedEvent = Schema.Struct({
1018 ...ProviderRuntimeEventBase.fields,
1019 type: AccountUpdatedType,
1020 payload: AccountUpdatedPayload,
1021});
1022export type ProviderRuntimeAccountUpdatedEvent = typeof ProviderRuntimeAccountUpdatedEvent.Type;
1023​
1024const ProviderRuntimeAccountRateLimitsUpdatedEvent = Schema.Struct({
1025 ...ProviderRuntimeEventBase.fields,
1026 type: AccountRateLimitsUpdatedType,
1027 payload: AccountRateLimitsUpdatedPayload,
1028});
1029export type ProviderRuntimeAccountRateLimitsUpdatedEvent =
1030 typeof ProviderRuntimeAccountRateLimitsUpdatedEvent.Type;
1031​
1032const ProviderRuntimeMcpStatusUpdatedEvent = Schema.Struct({
1033 ...ProviderRuntimeEventBase.fields,
1034 type: McpStatusUpdatedType,
1035 payload: McpStatusUpdatedPayload,
1036});
1037export type ProviderRuntimeMcpStatusUpdatedEvent = typeof ProviderRuntimeMcpStatusUpdatedEvent.Type;
1038​
1039const ProviderRuntimeMcpOauthCompletedEvent = Schema.Struct({
1040 ...ProviderRuntimeEventBase.fields,
1041 type: McpOauthCompletedType,
1042 payload: McpOauthCompletedPayload,
1043});
1044export type ProviderRuntimeMcpOauthCompletedEvent =
1045 typeof ProviderRuntimeMcpOauthCompletedEvent.Type;
1046​
1047const ProviderRuntimeModelReroutedEvent = Schema.Struct({
1048 ...ProviderRuntimeEventBase.fields,
1049 type: ModelReroutedType,
1050 payload: ModelReroutedPayload,
1051});
1052export type ProviderRuntimeModelReroutedEvent = typeof ProviderRuntimeModelReroutedEvent.Type;
1053​
1054const ProviderRuntimeConfigWarningEvent = Schema.Struct({
1055 ...ProviderRuntimeEventBase.fields,
1056 type: ConfigWarningType,
1057 payload: ConfigWarningPayload,
1058});
1059export type ProviderRuntimeConfigWarningEvent = typeof ProviderRuntimeConfigWarningEvent.Type;
1060​
1061const ProviderRuntimeDeprecationNoticeEvent = Schema.Struct({
1062 ...ProviderRuntimeEventBase.fields,
1063 type: DeprecationNoticeType,
1064 payload: DeprecationNoticePayload,
1065});
1066export type ProviderRuntimeDeprecationNoticeEvent =
1067 typeof ProviderRuntimeDeprecationNoticeEvent.Type;
1068​
1069const ProviderRuntimeFilesPersistedEvent = Schema.Struct({
1070 ...ProviderRuntimeEventBase.fields,
1071 type: FilesPersistedType,
1072 payload: FilesPersistedPayload,
1073});
1074export type ProviderRuntimeFilesPersistedEvent = typeof ProviderRuntimeFilesPersistedEvent.Type;
1075​
1076const ProviderRuntimeToolDeniedEvent = Schema.Struct({
1077 ...ProviderRuntimeEventBase.fields,
1078 type: ToolDeniedType,
1079 payload: ToolDeniedPayload,
1080});
1081export type ProviderRuntimeToolDeniedEvent = typeof ProviderRuntimeToolDeniedEvent.Type;
1082​
1083const ProviderRuntimeWarningEvent = Schema.Struct({
1084 ...ProviderRuntimeEventBase.fields,
1085 type: RuntimeWarningType,
1086 payload: RuntimeWarningPayload,
1087});
1088export type ProviderRuntimeWarningEvent = typeof ProviderRuntimeWarningEvent.Type;
1089​
1090const ProviderRuntimeErrorEvent = Schema.Struct({
1091 ...ProviderRuntimeEventBase.fields,
1092 type: RuntimeErrorType,
1093 payload: RuntimeErrorPayload,
1094});
1095export type ProviderRuntimeErrorEvent = typeof ProviderRuntimeErrorEvent.Type;
1096​
1097export const ProviderRuntimeEventV2 = Schema.Union([
1098 ProviderRuntimeSessionStartedEvent,
1099 ProviderRuntimeSessionConfiguredEvent,
1100 ProviderRuntimeSessionStateChangedEvent,
1101 ProviderRuntimeSessionExitedEvent,
1102 ProviderRuntimeThreadStartedEvent,
1103 ProviderRuntimeThreadStateChangedEvent,
1104 ProviderRuntimeThreadMetadataUpdatedEvent,
1105 ProviderRuntimeThreadTokenUsageUpdatedEvent,
1106 ProviderRuntimeThreadRealtimeStartedEvent,
1107 ProviderRuntimeThreadRealtimeItemAddedEvent,
1108 ProviderRuntimeThreadRealtimeAudioDeltaEvent,
1109 ProviderRuntimeThreadRealtimeErrorEvent,
1110 ProviderRuntimeThreadRealtimeClosedEvent,
1111 ProviderRuntimeTurnStartedEvent,
1112 ProviderRuntimeTurnCompletedEvent,
1113 ProviderRuntimeTurnAbortedEvent,
1114 ProviderRuntimeTurnPlanUpdatedEvent,
1115 ProviderRuntimeTurnProposedDeltaEvent,
1116 ProviderRuntimeTurnProposedCompletedEvent,
1117 ProviderRuntimeTurnDiffUpdatedEvent,
1118 ProviderRuntimeItemStartedEvent,
1119 ProviderRuntimeItemUpdatedEvent,
1120 ProviderRuntimeItemCompletedEvent,
1121 ProviderRuntimeContentDeltaEvent,
1122 ProviderRuntimeRequestOpenedEvent,
1123 ProviderRuntimeRequestResolvedEvent,
1124 ProviderRuntimeUserInputRequestedEvent,
1125 ProviderRuntimeUserInputResolvedEvent,
1126 ProviderRuntimeTaskStartedEvent,
1127 ProviderRuntimeTaskProgressEvent,
1128 ProviderRuntimeTaskUpdatedEvent,
1129 ProviderRuntimeTaskCompletedEvent,
1130 ProviderRuntimeHookStartedEvent,
1131 ProviderRuntimeHookProgressEvent,
1132 ProviderRuntimeHookCompletedEvent,
1133 ProviderRuntimeToolProgressEvent,
1134 ProviderRuntimeToolSummaryEvent,
1135 ProviderRuntimeAuthStatusEvent,
1136 ProviderRuntimeAccountUpdatedEvent,
1137 ProviderRuntimeAccountRateLimitsUpdatedEvent,
1138 ProviderRuntimeMcpStatusUpdatedEvent,
1139 ProviderRuntimeMcpOauthCompletedEvent,
1140 ProviderRuntimeModelReroutedEvent,
1141 ProviderRuntimeConfigWarningEvent,
1142 ProviderRuntimeDeprecationNoticeEvent,
1143 ProviderRuntimeFilesPersistedEvent,
1144 ProviderRuntimeToolDeniedEvent,
1145 ProviderRuntimeWarningEvent,
1146 ProviderRuntimeErrorEvent,
1147]);
1148export type ProviderRuntimeEventV2 = typeof ProviderRuntimeEventV2.Type;
1149​
1150export const ProviderRuntimeEvent = ProviderRuntimeEventV2;
1151export type ProviderRuntimeEvent = ProviderRuntimeEventV2;
1152​
1153export const ProviderRuntimeTurnStatus = RuntimeTurnState;
1154export type ProviderRuntimeTurnStatus = RuntimeTurnState;