| ... | ... | @@ -1,226 +1,438 @@ |
| 1 | 1 | import { Schema } from "effect"; |
| 2 | | import { TrimmedNonEmptyString } from "./baseSchemas"; |
| 3 | | |
| 4 | 2 | import { |
| 5 | | ApprovalRequestId, |
| 6 | 3 | EventId, |
| 7 | | NonNegativeInt, |
| 4 | IsoDateTime, |
| 8 | 5 | ProviderItemId, |
| 9 | 6 | ProviderSessionId, |
| 10 | 7 | ProviderThreadId, |
| 11 | 8 | ProviderTurnId, |
| 12 | | IsoDateTime, |
| 9 | RuntimeItemId, |
| 10 | RuntimeRequestId, |
| 11 | RuntimeSessionId, |
| 12 | ThreadId, |
| 13 | TrimmedNonEmptyString, |
| 14 | TurnId, |
| 13 | 15 | } from "./baseSchemas"; |
| 14 | | import { ProviderApprovalDecision, ProviderKind, ProviderRequestKind } from "./orchestration"; |
| 16 | import { ProviderKind } from "./orchestration"; |
| 15 | 17 | |
| 16 | 18 | const TrimmedNonEmptyStringSchema = TrimmedNonEmptyString; |
| 19 | const UnknownRecordSchema = Schema.Record(Schema.String, Schema.Unknown); |
| 17 | 20 | |
| 18 | | export const ProviderRuntimeToolKind = Schema.Union([ProviderRequestKind, Schema.Literal("other")]); |
| 19 | | export type ProviderRuntimeToolKind = typeof ProviderRuntimeToolKind.Type; |
| 21 | export const RuntimeEventRawSource = Schema.Literals([ |
| 22 | "codex.app-server.notification", |
| 23 | "codex.app-server.request", |
| 24 | "codex.eventmsg", |
| 25 | "claude.sdk.message", |
| 26 | "claude.sdk.permission", |
| 27 | "codex.sdk.thread-event", |
| 28 | ]); |
| 29 | export type RuntimeEventRawSource = typeof RuntimeEventRawSource.Type; |
| 30 | |
| 31 | export const RuntimeEventRaw = Schema.Struct({ |
| 32 | source: RuntimeEventRawSource, |
| 33 | method: Schema.optional(TrimmedNonEmptyStringSchema), |
| 34 | messageType: Schema.optional(TrimmedNonEmptyStringSchema), |
| 35 | payload: Schema.Unknown, |
| 36 | }); |
| 37 | export type RuntimeEventRaw = typeof RuntimeEventRaw.Type; |
| 38 | |
| 39 | export const ProviderRequestId = TrimmedNonEmptyStringSchema; |
| 40 | export type ProviderRequestId = typeof ProviderRequestId.Type; |
| 20 | 41 | |
| 21 | | export const ProviderRuntimeTurnStatus = Schema.Literals([ |
| 42 | export const ProviderRefs = Schema.Struct({ |
| 43 | providerSessionId: Schema.optional(ProviderSessionId), |
| 44 | providerThreadId: Schema.optional(ProviderThreadId), |
| 45 | providerTurnId: Schema.optional(ProviderTurnId), |
| 46 | providerItemId: Schema.optional(ProviderItemId), |
| 47 | providerRequestId: Schema.optional(ProviderRequestId), |
| 48 | }); |
| 49 | export type ProviderRefs = typeof ProviderRefs.Type; |
| 50 | |
| 51 | export const RuntimeTurnState = Schema.Literals([ |
| 22 | 52 | "completed", |
| 23 | 53 | "failed", |
| 24 | | "cancelled", |
| 25 | 54 | "interrupted", |
| 55 | "cancelled", |
| 26 | 56 | ]); |
| 27 | | export type ProviderRuntimeTurnStatus = typeof ProviderRuntimeTurnStatus.Type; |
| 57 | export type RuntimeTurnState = typeof RuntimeTurnState.Type; |
| 28 | 58 | |
| 29 | | export const ProviderRuntimeSessionStartedEvent = Schema.Struct({ |
| 30 | | type: Schema.Literal("session.started"), |
| 59 | export const RuntimePlanStepStatus = Schema.Literals(["pending", "inProgress", "completed"]); |
| 60 | export type RuntimePlanStepStatus = typeof RuntimePlanStepStatus.Type; |
| 61 | |
| 62 | export const RuntimeItemStatus = Schema.Literals(["inProgress", "completed", "failed", "declined"]); |
| 63 | export type RuntimeItemStatus = typeof RuntimeItemStatus.Type; |
| 64 | |
| 65 | export const RuntimeContentStreamKind = Schema.Literals([ |
| 66 | "assistant_text", |
| 67 | "reasoning_text", |
| 68 | "reasoning_summary_text", |
| 69 | "plan_text", |
| 70 | "command_output", |
| 71 | "file_change_output", |
| 72 | "unknown", |
| 73 | ]); |
| 74 | export type RuntimeContentStreamKind = typeof RuntimeContentStreamKind.Type; |
| 75 | |
| 76 | export const RuntimeSessionExitKind = Schema.Literals(["graceful", "error"]); |
| 77 | export type RuntimeSessionExitKind = typeof RuntimeSessionExitKind.Type; |
| 78 | |
| 79 | export const RuntimeErrorClass = Schema.Literals([ |
| 80 | "provider_error", |
| 81 | "transport_error", |
| 82 | "permission_error", |
| 83 | "validation_error", |
| 84 | "unknown", |
| 85 | ]); |
| 86 | export type RuntimeErrorClass = typeof RuntimeErrorClass.Type; |
| 87 | |
| 88 | export const CanonicalItemType = Schema.Literals([ |
| 89 | "user_message", |
| 90 | "assistant_message", |
| 91 | "reasoning", |
| 92 | "plan", |
| 93 | "command_execution", |
| 94 | "file_change", |
| 95 | "mcp_tool_call", |
| 96 | "dynamic_tool_call", |
| 97 | "error", |
| 98 | "unknown", |
| 99 | ]); |
| 100 | export type CanonicalItemType = typeof CanonicalItemType.Type; |
| 101 | |
| 102 | export const CanonicalRequestType = Schema.Literals([ |
| 103 | "command_execution_approval", |
| 104 | "file_change_approval", |
| 105 | "apply_patch_approval", |
| 106 | "exec_command_approval", |
| 107 | "tool_user_input", |
| 108 | "dynamic_tool_call", |
| 109 | "unknown", |
| 110 | ]); |
| 111 | export type CanonicalRequestType = typeof CanonicalRequestType.Type; |
| 112 | |
| 113 | export const ProviderRuntimeEventType = Schema.Literals([ |
| 114 | "session.started", |
| 115 | "session.exited", |
| 116 | "thread.started", |
| 117 | "turn.started", |
| 118 | "turn.completed", |
| 119 | "turn.plan.updated", |
| 120 | "item.started", |
| 121 | "item.updated", |
| 122 | "item.completed", |
| 123 | "content.delta", |
| 124 | "request.opened", |
| 125 | "request.resolved", |
| 126 | "user-input.requested", |
| 127 | "user-input.resolved", |
| 128 | "runtime.warning", |
| 129 | "runtime.error", |
| 130 | ]); |
| 131 | export type ProviderRuntimeEventType = typeof ProviderRuntimeEventType.Type; |
| 132 | |
| 133 | export const SessionStartedType = Schema.Literal("session.started"); |
| 134 | export const SessionExitedType = Schema.Literal("session.exited"); |
| 135 | export const ThreadStartedType = Schema.Literal("thread.started"); |
| 136 | export const TurnStartedType = Schema.Literal("turn.started"); |
| 137 | export const TurnCompletedType = Schema.Literal("turn.completed"); |
| 138 | export const TurnPlanUpdatedType = Schema.Literal("turn.plan.updated"); |
| 139 | export const ItemStartedType = Schema.Literal("item.started"); |
| 140 | export const ItemUpdatedType = Schema.Literal("item.updated"); |
| 141 | export const ItemCompletedType = Schema.Literal("item.completed"); |
| 142 | export const ContentDeltaType = Schema.Literal("content.delta"); |
| 143 | export const RequestOpenedType = Schema.Literal("request.opened"); |
| 144 | export const RequestResolvedType = Schema.Literal("request.resolved"); |
| 145 | export const UserInputRequestedType = Schema.Literal("user-input.requested"); |
| 146 | export const UserInputResolvedType = Schema.Literal("user-input.resolved"); |
| 147 | export const RuntimeWarningType = Schema.Literal("runtime.warning"); |
| 148 | export const RuntimeErrorType = Schema.Literal("runtime.error"); |
| 149 | |
| 150 | export const ProviderRuntimeEventBase = Schema.Struct({ |
| 31 | 151 | eventId: EventId, |
| 32 | 152 | provider: ProviderKind, |
| 33 | | sessionId: ProviderSessionId, |
| 34 | | sessionSequence: Schema.optional(NonNegativeInt), |
| 153 | sessionId: RuntimeSessionId, |
| 35 | 154 | createdAt: IsoDateTime, |
| 36 | | threadId: Schema.optional(ProviderThreadId), |
| 155 | threadId: Schema.optional(ThreadId), |
| 156 | turnId: Schema.optional(TurnId), |
| 157 | itemId: Schema.optional(RuntimeItemId), |
| 158 | requestId: Schema.optional(RuntimeRequestId), |
| 159 | providerRefs: Schema.optional(ProviderRefs), |
| 160 | raw: Schema.optional(RuntimeEventRaw), |
| 161 | }); |
| 162 | export type ProviderRuntimeEventBase = typeof ProviderRuntimeEventBase.Type; |
| 163 | |
| 164 | export const SessionStartedPayload = Schema.Struct({ |
| 37 | 165 | message: Schema.optional(TrimmedNonEmptyStringSchema), |
| 166 | resume: Schema.optional(Schema.Unknown), |
| 167 | }); |
| 168 | export type SessionStartedPayload = typeof SessionStartedPayload.Type; |
| 169 | |
| 170 | export const SessionExitedPayload = Schema.Struct({ |
| 171 | reason: Schema.optional(TrimmedNonEmptyStringSchema), |
| 172 | recoverable: Schema.optional(Schema.Boolean), |
| 173 | exitKind: Schema.optional(RuntimeSessionExitKind), |
| 174 | }); |
| 175 | export type SessionExitedPayload = typeof SessionExitedPayload.Type; |
| 176 | |
| 177 | export const ThreadStartedPayload = Schema.Struct({ |
| 178 | providerThreadId: Schema.optional(ProviderThreadId), |
| 179 | }); |
| 180 | export type ThreadStartedPayload = typeof ThreadStartedPayload.Type; |
| 181 | |
| 182 | export const TurnStartedPayload = Schema.Struct({ |
| 183 | model: Schema.optional(TrimmedNonEmptyStringSchema), |
| 184 | effort: Schema.optional(TrimmedNonEmptyStringSchema), |
| 185 | }); |
| 186 | export type TurnStartedPayload = typeof TurnStartedPayload.Type; |
| 187 | |
| 188 | export const TurnCompletedPayload = Schema.Struct({ |
| 189 | state: RuntimeTurnState, |
| 190 | stopReason: Schema.optional(Schema.NullOr(TrimmedNonEmptyStringSchema)), |
| 191 | usage: Schema.optional(Schema.Unknown), |
| 192 | modelUsage: Schema.optional(UnknownRecordSchema), |
| 193 | totalCostUsd: Schema.optional(Schema.Number), |
| 194 | errorMessage: Schema.optional(TrimmedNonEmptyStringSchema), |
| 195 | }); |
| 196 | export type TurnCompletedPayload = typeof TurnCompletedPayload.Type; |
| 197 | |
| 198 | export const RuntimePlanStep = Schema.Struct({ |
| 199 | step: TrimmedNonEmptyStringSchema, |
| 200 | status: RuntimePlanStepStatus, |
| 201 | }); |
| 202 | export type RuntimePlanStep = typeof RuntimePlanStep.Type; |
| 203 | |
| 204 | export const TurnPlanUpdatedPayload = Schema.Struct({ |
| 205 | explanation: Schema.optional(Schema.NullOr(TrimmedNonEmptyStringSchema)), |
| 206 | plan: Schema.Array(RuntimePlanStep), |
| 207 | }); |
| 208 | export type TurnPlanUpdatedPayload = typeof TurnPlanUpdatedPayload.Type; |
| 209 | |
| 210 | export const ItemLifecyclePayload = Schema.Struct({ |
| 211 | itemType: CanonicalItemType, |
| 212 | status: Schema.optional(RuntimeItemStatus), |
| 213 | title: Schema.optional(TrimmedNonEmptyStringSchema), |
| 214 | detail: Schema.optional(TrimmedNonEmptyStringSchema), |
| 215 | data: Schema.optional(Schema.Unknown), |
| 216 | }); |
| 217 | export type ItemLifecyclePayload = typeof ItemLifecyclePayload.Type; |
| 218 | |
| 219 | export const ContentDeltaPayload = Schema.Struct({ |
| 220 | streamKind: RuntimeContentStreamKind, |
| 221 | delta: Schema.String, |
| 222 | contentIndex: Schema.optional(Schema.Int), |
| 223 | summaryIndex: Schema.optional(Schema.Int), |
| 224 | }); |
| 225 | export type ContentDeltaPayload = typeof ContentDeltaPayload.Type; |
| 226 | |
| 227 | export const RequestOpenedPayload = Schema.Struct({ |
| 228 | requestType: CanonicalRequestType, |
| 229 | detail: Schema.optional(TrimmedNonEmptyStringSchema), |
| 230 | args: Schema.optional(Schema.Unknown), |
| 231 | }); |
| 232 | export type RequestOpenedPayload = typeof RequestOpenedPayload.Type; |
| 233 | |
| 234 | export const RequestResolvedPayload = Schema.Struct({ |
| 235 | requestType: CanonicalRequestType, |
| 236 | decision: Schema.optional(TrimmedNonEmptyStringSchema), |
| 237 | resolution: Schema.optional(Schema.Unknown), |
| 238 | }); |
| 239 | export type RequestResolvedPayload = typeof RequestResolvedPayload.Type; |
| 240 | |
| 241 | export const UserInputQuestionOption = Schema.Struct({ |
| 242 | label: TrimmedNonEmptyStringSchema, |
| 243 | description: TrimmedNonEmptyStringSchema, |
| 244 | }); |
| 245 | export type UserInputQuestionOption = typeof UserInputQuestionOption.Type; |
| 246 | |
| 247 | export const UserInputQuestion = Schema.Struct({ |
| 248 | id: TrimmedNonEmptyStringSchema, |
| 249 | header: TrimmedNonEmptyStringSchema, |
| 250 | question: TrimmedNonEmptyStringSchema, |
| 251 | options: Schema.Array(UserInputQuestionOption), |
| 252 | }); |
| 253 | export type UserInputQuestion = typeof UserInputQuestion.Type; |
| 254 | |
| 255 | export const UserInputRequestedPayload = Schema.Struct({ |
| 256 | questions: Schema.Array(UserInputQuestion), |
| 257 | }); |
| 258 | export type UserInputRequestedPayload = typeof UserInputRequestedPayload.Type; |
| 259 | |
| 260 | export const UserInputResolvedPayload = Schema.Struct({ |
| 261 | answers: UnknownRecordSchema, |
| 262 | }); |
| 263 | export type UserInputResolvedPayload = typeof UserInputResolvedPayload.Type; |
| 264 | |
| 265 | export const RuntimeWarningPayload = Schema.Struct({ |
| 266 | message: TrimmedNonEmptyStringSchema, |
| 267 | detail: Schema.optional(Schema.Unknown), |
| 268 | }); |
| 269 | export type RuntimeWarningPayload = typeof RuntimeWarningPayload.Type; |
| 270 | |
| 271 | export const RuntimeErrorPayload = Schema.Struct({ |
| 272 | message: TrimmedNonEmptyStringSchema, |
| 273 | class: Schema.optional(RuntimeErrorClass), |
| 274 | detail: Schema.optional(Schema.Unknown), |
| 275 | }); |
| 276 | export type RuntimeErrorPayload = typeof RuntimeErrorPayload.Type; |
| 277 | |
| 278 | export const ProviderRuntimeSessionStartedEvent = Schema.Struct({ |
| 279 | ...ProviderRuntimeEventBase.fields, |
| 280 | type: SessionStartedType, |
| 281 | payload: SessionStartedPayload, |
| 38 | 282 | }); |
| 39 | 283 | export type ProviderRuntimeSessionStartedEvent = typeof ProviderRuntimeSessionStartedEvent.Type; |
| 40 | 284 | |
| 41 | 285 | export const ProviderRuntimeSessionExitedEvent = Schema.Struct({ |
| 42 | | type: Schema.Literal("session.exited"), |
| 43 | | eventId: EventId, |
| 44 | | provider: ProviderKind, |
| 45 | | sessionId: ProviderSessionId, |
| 46 | | sessionSequence: Schema.optional(NonNegativeInt), |
| 47 | | createdAt: IsoDateTime, |
| 48 | | threadId: Schema.optional(ProviderThreadId), |
| 49 | | message: Schema.optional(TrimmedNonEmptyStringSchema), |
| 286 | ...ProviderRuntimeEventBase.fields, |
| 287 | type: SessionExitedType, |
| 288 | payload: SessionExitedPayload, |
| 50 | 289 | }); |
| 51 | 290 | export type ProviderRuntimeSessionExitedEvent = typeof ProviderRuntimeSessionExitedEvent.Type; |
| 52 | 291 | |
| 53 | 292 | export const ProviderRuntimeThreadStartedEvent = Schema.Struct({ |
| 54 | | type: Schema.Literal("thread.started"), |
| 55 | | eventId: EventId, |
| 56 | | provider: ProviderKind, |
| 57 | | sessionId: ProviderSessionId, |
| 58 | | sessionSequence: Schema.optional(NonNegativeInt), |
| 59 | | createdAt: IsoDateTime, |
| 60 | | threadId: ProviderThreadId, |
| 293 | ...ProviderRuntimeEventBase.fields, |
| 294 | type: ThreadStartedType, |
| 295 | payload: ThreadStartedPayload, |
| 61 | 296 | }); |
| 62 | 297 | export type ProviderRuntimeThreadStartedEvent = typeof ProviderRuntimeThreadStartedEvent.Type; |
| 63 | 298 | |
| 64 | 299 | export const ProviderRuntimeTurnStartedEvent = Schema.Struct({ |
| 65 | | type: Schema.Literal("turn.started"), |
| 66 | | eventId: EventId, |
| 67 | | provider: ProviderKind, |
| 68 | | sessionId: ProviderSessionId, |
| 69 | | sessionSequence: Schema.optional(NonNegativeInt), |
| 70 | | createdAt: IsoDateTime, |
| 71 | | threadId: Schema.optional(ProviderThreadId), |
| 72 | | turnId: ProviderTurnId, |
| 300 | ...ProviderRuntimeEventBase.fields, |
| 301 | type: TurnStartedType, |
| 302 | payload: TurnStartedPayload, |
| 73 | 303 | }); |
| 74 | 304 | export type ProviderRuntimeTurnStartedEvent = typeof ProviderRuntimeTurnStartedEvent.Type; |
| 75 | 305 | |
| 76 | 306 | export const ProviderRuntimeTurnCompletedEvent = Schema.Struct({ |
| 77 | | type: Schema.Literal("turn.completed"), |
| 78 | | eventId: EventId, |
| 79 | | provider: ProviderKind, |
| 80 | | sessionId: ProviderSessionId, |
| 81 | | sessionSequence: Schema.optional(NonNegativeInt), |
| 82 | | createdAt: IsoDateTime, |
| 83 | | threadId: Schema.optional(ProviderThreadId), |
| 84 | | turnId: Schema.optional(ProviderTurnId), |
| 85 | | status: Schema.optional(ProviderRuntimeTurnStatus), |
| 86 | | errorMessage: Schema.optional(TrimmedNonEmptyStringSchema), |
| 307 | ...ProviderRuntimeEventBase.fields, |
| 308 | type: TurnCompletedType, |
| 309 | payload: TurnCompletedPayload, |
| 87 | 310 | }); |
| 88 | 311 | export type ProviderRuntimeTurnCompletedEvent = typeof ProviderRuntimeTurnCompletedEvent.Type; |
| 89 | 312 | |
| 90 | | export const ProviderRuntimeMessageDeltaEvent = Schema.Struct({ |
| 91 | | type: Schema.Literal("message.delta"), |
| 92 | | eventId: EventId, |
| 93 | | provider: ProviderKind, |
| 94 | | sessionId: ProviderSessionId, |
| 95 | | sessionSequence: Schema.optional(NonNegativeInt), |
| 96 | | createdAt: IsoDateTime, |
| 97 | | threadId: Schema.optional(ProviderThreadId), |
| 98 | | turnId: Schema.optional(ProviderTurnId), |
| 99 | | itemId: Schema.optional(ProviderItemId), |
| 100 | | delta: Schema.String, |
| 313 | export const ProviderRuntimeTurnPlanUpdatedEvent = Schema.Struct({ |
| 314 | ...ProviderRuntimeEventBase.fields, |
| 315 | type: TurnPlanUpdatedType, |
| 316 | payload: TurnPlanUpdatedPayload, |
| 101 | 317 | }); |
| 102 | | export type ProviderRuntimeMessageDeltaEvent = typeof ProviderRuntimeMessageDeltaEvent.Type; |
| 318 | export type ProviderRuntimeTurnPlanUpdatedEvent = typeof ProviderRuntimeTurnPlanUpdatedEvent.Type; |
| 103 | 319 | |
| 104 | | export const ProviderRuntimeMessageCompletedEvent = Schema.Struct({ |
| 105 | | type: Schema.Literal("message.completed"), |
| 106 | | eventId: EventId, |
| 107 | | provider: ProviderKind, |
| 108 | | sessionId: ProviderSessionId, |
| 109 | | sessionSequence: Schema.optional(NonNegativeInt), |
| 110 | | createdAt: IsoDateTime, |
| 111 | | itemId: ProviderItemId, |
| 112 | | threadId: Schema.optional(ProviderThreadId), |
| 113 | | turnId: Schema.optional(ProviderTurnId), |
| 320 | export const ProviderRuntimeItemStartedEvent = Schema.Struct({ |
| 321 | ...ProviderRuntimeEventBase.fields, |
| 322 | type: ItemStartedType, |
| 323 | payload: ItemLifecyclePayload, |
| 114 | 324 | }); |
| 115 | | export type ProviderRuntimeMessageCompletedEvent = typeof ProviderRuntimeMessageCompletedEvent.Type; |
| 325 | export type ProviderRuntimeItemStartedEvent = typeof ProviderRuntimeItemStartedEvent.Type; |
| 116 | 326 | |
| 117 | | export const ProviderRuntimeToolStartedEvent = Schema.Struct({ |
| 118 | | type: Schema.Literal("tool.started"), |
| 119 | | eventId: EventId, |
| 120 | | provider: ProviderKind, |
| 121 | | sessionId: ProviderSessionId, |
| 122 | | sessionSequence: Schema.optional(NonNegativeInt), |
| 123 | | createdAt: IsoDateTime, |
| 124 | | threadId: Schema.optional(ProviderThreadId), |
| 125 | | turnId: Schema.optional(ProviderTurnId), |
| 126 | | itemId: Schema.optional(ProviderItemId), |
| 127 | | toolKind: ProviderRuntimeToolKind, |
| 128 | | title: TrimmedNonEmptyStringSchema, |
| 129 | | detail: Schema.optional(TrimmedNonEmptyStringSchema), |
| 327 | export const ProviderRuntimeItemUpdatedEvent = Schema.Struct({ |
| 328 | ...ProviderRuntimeEventBase.fields, |
| 329 | type: ItemUpdatedType, |
| 330 | payload: ItemLifecyclePayload, |
| 130 | 331 | }); |
| 131 | | export type ProviderRuntimeToolStartedEvent = typeof ProviderRuntimeToolStartedEvent.Type; |
| 332 | export type ProviderRuntimeItemUpdatedEvent = typeof ProviderRuntimeItemUpdatedEvent.Type; |
| 132 | 333 | |
| 133 | | export const ProviderRuntimeToolCompletedEvent = Schema.Struct({ |
| 134 | | type: Schema.Literal("tool.completed"), |
| 135 | | eventId: EventId, |
| 136 | | provider: ProviderKind, |
| 137 | | sessionId: ProviderSessionId, |
| 138 | | sessionSequence: Schema.optional(NonNegativeInt), |
| 139 | | createdAt: IsoDateTime, |
| 140 | | threadId: Schema.optional(ProviderThreadId), |
| 141 | | turnId: Schema.optional(ProviderTurnId), |
| 142 | | itemId: Schema.optional(ProviderItemId), |
| 143 | | toolKind: ProviderRuntimeToolKind, |
| 144 | | title: TrimmedNonEmptyStringSchema, |
| 145 | | detail: Schema.optional(TrimmedNonEmptyStringSchema), |
| 334 | export const ProviderRuntimeItemCompletedEvent = Schema.Struct({ |
| 335 | ...ProviderRuntimeEventBase.fields, |
| 336 | type: ItemCompletedType, |
| 337 | payload: ItemLifecyclePayload, |
| 146 | 338 | }); |
| 147 | | export type ProviderRuntimeToolCompletedEvent = typeof ProviderRuntimeToolCompletedEvent.Type; |
| 339 | export type ProviderRuntimeItemCompletedEvent = typeof ProviderRuntimeItemCompletedEvent.Type; |
| 148 | 340 | |
| 149 | | export const ProviderRuntimeApprovalRequestedEvent = Schema.Struct({ |
| 150 | | type: Schema.Literal("approval.requested"), |
| 151 | | eventId: EventId, |
| 152 | | provider: ProviderKind, |
| 153 | | sessionId: ProviderSessionId, |
| 154 | | sessionSequence: Schema.optional(NonNegativeInt), |
| 155 | | createdAt: IsoDateTime, |
| 156 | | threadId: Schema.optional(ProviderThreadId), |
| 157 | | turnId: Schema.optional(ProviderTurnId), |
| 158 | | itemId: Schema.optional(ProviderItemId), |
| 159 | | requestId: ApprovalRequestId, |
| 160 | | requestKind: ProviderRequestKind, |
| 161 | | detail: Schema.optional(TrimmedNonEmptyStringSchema), |
| 341 | export const ProviderRuntimeContentDeltaEvent = Schema.Struct({ |
| 342 | ...ProviderRuntimeEventBase.fields, |
| 343 | type: ContentDeltaType, |
| 344 | payload: ContentDeltaPayload, |
| 162 | 345 | }); |
| 163 | | export type ProviderRuntimeApprovalRequestedEvent = |
| 164 | | typeof ProviderRuntimeApprovalRequestedEvent.Type; |
| 346 | export type ProviderRuntimeContentDeltaEvent = typeof ProviderRuntimeContentDeltaEvent.Type; |
| 165 | 347 | |
| 166 | | export const ProviderRuntimeApprovalResolvedEvent = Schema.Struct({ |
| 167 | | type: Schema.Literal("approval.resolved"), |
| 168 | | eventId: EventId, |
| 169 | | provider: ProviderKind, |
| 170 | | sessionId: ProviderSessionId, |
| 171 | | sessionSequence: Schema.optional(NonNegativeInt), |
| 172 | | createdAt: IsoDateTime, |
| 173 | | threadId: Schema.optional(ProviderThreadId), |
| 174 | | turnId: Schema.optional(ProviderTurnId), |
| 175 | | itemId: Schema.optional(ProviderItemId), |
| 176 | | requestId: ApprovalRequestId, |
| 177 | | requestKind: Schema.optional(ProviderRequestKind), |
| 178 | | decision: Schema.optional(ProviderApprovalDecision), |
| 348 | export const ProviderRuntimeRequestOpenedEvent = Schema.Struct({ |
| 349 | ...ProviderRuntimeEventBase.fields, |
| 350 | type: RequestOpenedType, |
| 351 | payload: RequestOpenedPayload, |
| 179 | 352 | }); |
| 180 | | export type ProviderRuntimeApprovalResolvedEvent = typeof ProviderRuntimeApprovalResolvedEvent.Type; |
| 353 | export type ProviderRuntimeRequestOpenedEvent = typeof ProviderRuntimeRequestOpenedEvent.Type; |
| 181 | 354 | |
| 182 | | export const ProviderRuntimeCheckpointCapturedEvent = Schema.Struct({ |
| 183 | | type: Schema.Literal("checkpoint.captured"), |
| 184 | | eventId: EventId, |
| 185 | | provider: ProviderKind, |
| 186 | | sessionId: ProviderSessionId, |
| 187 | | sessionSequence: Schema.optional(NonNegativeInt), |
| 188 | | createdAt: IsoDateTime, |
| 189 | | threadId: ProviderThreadId, |
| 190 | | turnId: Schema.optional(ProviderTurnId), |
| 191 | | turnCount: NonNegativeInt, |
| 192 | | status: Schema.optional(ProviderRuntimeTurnStatus), |
| 355 | export const ProviderRuntimeRequestResolvedEvent = Schema.Struct({ |
| 356 | ...ProviderRuntimeEventBase.fields, |
| 357 | type: RequestResolvedType, |
| 358 | payload: RequestResolvedPayload, |
| 193 | 359 | }); |
| 194 | | export type ProviderRuntimeCheckpointCapturedEvent = |
| 195 | | typeof ProviderRuntimeCheckpointCapturedEvent.Type; |
| 360 | export type ProviderRuntimeRequestResolvedEvent = typeof ProviderRuntimeRequestResolvedEvent.Type; |
| 361 | |
| 362 | export const ProviderRuntimeUserInputRequestedEvent = Schema.Struct({ |
| 363 | ...ProviderRuntimeEventBase.fields, |
| 364 | type: UserInputRequestedType, |
| 365 | payload: UserInputRequestedPayload, |
| 366 | }); |
| 367 | export type ProviderRuntimeUserInputRequestedEvent = |
| 368 | typeof ProviderRuntimeUserInputRequestedEvent.Type; |
| 369 | |
| 370 | export const ProviderRuntimeUserInputResolvedEvent = Schema.Struct({ |
| 371 | ...ProviderRuntimeEventBase.fields, |
| 372 | type: UserInputResolvedType, |
| 373 | payload: UserInputResolvedPayload, |
| 374 | }); |
| 375 | export type ProviderRuntimeUserInputResolvedEvent = |
| 376 | typeof ProviderRuntimeUserInputResolvedEvent.Type; |
| 377 | |
| 378 | export const ProviderRuntimeWarningEvent = Schema.Struct({ |
| 379 | ...ProviderRuntimeEventBase.fields, |
| 380 | type: RuntimeWarningType, |
| 381 | payload: RuntimeWarningPayload, |
| 382 | }); |
| 383 | export type ProviderRuntimeWarningEvent = typeof ProviderRuntimeWarningEvent.Type; |
| 196 | 384 | |
| 197 | 385 | export const ProviderRuntimeErrorEvent = Schema.Struct({ |
| 198 | | type: Schema.Literal("runtime.error"), |
| 199 | | eventId: EventId, |
| 200 | | provider: ProviderKind, |
| 201 | | sessionId: ProviderSessionId, |
| 202 | | sessionSequence: Schema.optional(NonNegativeInt), |
| 203 | | createdAt: IsoDateTime, |
| 204 | | threadId: Schema.optional(ProviderThreadId), |
| 205 | | turnId: Schema.optional(ProviderTurnId), |
| 206 | | itemId: Schema.optional(ProviderItemId), |
| 207 | | message: TrimmedNonEmptyStringSchema, |
| 386 | ...ProviderRuntimeEventBase.fields, |
| 387 | type: RuntimeErrorType, |
| 388 | payload: RuntimeErrorPayload, |
| 208 | 389 | }); |
| 209 | 390 | export type ProviderRuntimeErrorEvent = typeof ProviderRuntimeErrorEvent.Type; |
| 210 | 391 | |
| 211 | | export const ProviderRuntimeEvent = Schema.Union([ |
| 392 | export const ProviderRuntimeEventV2 = Schema.Union([ |
| 212 | 393 | ProviderRuntimeSessionStartedEvent, |
| 213 | 394 | ProviderRuntimeSessionExitedEvent, |
| 214 | 395 | ProviderRuntimeThreadStartedEvent, |
| 215 | 396 | ProviderRuntimeTurnStartedEvent, |
| 216 | 397 | ProviderRuntimeTurnCompletedEvent, |
| 217 | | ProviderRuntimeMessageDeltaEvent, |
| 218 | | ProviderRuntimeMessageCompletedEvent, |
| 219 | | ProviderRuntimeToolStartedEvent, |
| 220 | | ProviderRuntimeToolCompletedEvent, |
| 221 | | ProviderRuntimeApprovalRequestedEvent, |
| 222 | | ProviderRuntimeApprovalResolvedEvent, |
| 223 | | ProviderRuntimeCheckpointCapturedEvent, |
| 398 | ProviderRuntimeTurnPlanUpdatedEvent, |
| 399 | ProviderRuntimeItemStartedEvent, |
| 400 | ProviderRuntimeItemUpdatedEvent, |
| 401 | ProviderRuntimeItemCompletedEvent, |
| 402 | ProviderRuntimeContentDeltaEvent, |
| 403 | ProviderRuntimeRequestOpenedEvent, |
| 404 | ProviderRuntimeRequestResolvedEvent, |
| 405 | ProviderRuntimeUserInputRequestedEvent, |
| 406 | ProviderRuntimeUserInputResolvedEvent, |
| 407 | ProviderRuntimeWarningEvent, |
| 224 | 408 | ProviderRuntimeErrorEvent, |
| 225 | 409 | ]); |
| 226 | | export type ProviderRuntimeEvent = typeof ProviderRuntimeEvent.Type; |
| 410 | export type ProviderRuntimeEventV2 = typeof ProviderRuntimeEventV2.Type; |
| 411 | |
| 412 | export const ProviderRuntimeEvent = ProviderRuntimeEventV2; |
| 413 | export type ProviderRuntimeEvent = ProviderRuntimeEventV2; |
| 414 | |
| 415 | export const ProviderRuntimeMessageDeltaEvent = ProviderRuntimeContentDeltaEvent; |
| 416 | export type ProviderRuntimeMessageDeltaEvent = ProviderRuntimeContentDeltaEvent; |
| 417 | export const ProviderRuntimeMessageCompletedEvent = ProviderRuntimeItemCompletedEvent; |
| 418 | export type ProviderRuntimeMessageCompletedEvent = ProviderRuntimeItemCompletedEvent; |
| 419 | export const ProviderRuntimeToolStartedEvent = ProviderRuntimeItemStartedEvent; |
| 420 | export type ProviderRuntimeToolStartedEvent = ProviderRuntimeItemStartedEvent; |
| 421 | export const ProviderRuntimeToolCompletedEvent = ProviderRuntimeItemCompletedEvent; |
| 422 | export type ProviderRuntimeToolCompletedEvent = ProviderRuntimeItemCompletedEvent; |
| 423 | export const ProviderRuntimeApprovalRequestedEvent = ProviderRuntimeRequestOpenedEvent; |
| 424 | export type ProviderRuntimeApprovalRequestedEvent = ProviderRuntimeRequestOpenedEvent; |
| 425 | export const ProviderRuntimeApprovalResolvedEvent = ProviderRuntimeRequestResolvedEvent; |
| 426 | export type ProviderRuntimeApprovalResolvedEvent = ProviderRuntimeRequestResolvedEvent; |
| 427 | |
| 428 | export const ProviderRuntimeToolKind = Schema.Literals([ |
| 429 | "command_execution", |
| 430 | "file_change", |
| 431 | "mcp_tool_call", |
| 432 | "dynamic_tool_call", |
| 433 | "other", |
| 434 | ]); |
| 435 | export type ProviderRuntimeToolKind = typeof ProviderRuntimeToolKind.Type; |
| 436 | |
| 437 | export const ProviderRuntimeTurnStatus = RuntimeTurnState; |
| 438 | export type ProviderRuntimeTurnStatus = RuntimeTurnState; |