Open History to see the last commit
1import { Effect, Option, Schema, SchemaIssue, Struct } from "effect";
2import { ProviderOptionSelections } from "./model.ts";
3import { RepositoryIdentity } from "./environment.ts";
4import {
5 ApprovalRequestId,
6 CheckpointRef,
7 CommandId,
8 EventId,
9 IsoDateTime,
10 MessageId,
11 NonNegativeInt,
12 ProjectId,
13 ProviderItemId,
14 ThreadId,
15 TrimmedNonEmptyString,
16 TurnId,
17} from "./baseSchemas.ts";
18
19export const ORCHESTRATION_WS_METHODS = {
20 dispatchCommand: "orchestration.dispatchCommand",
21 getTurnDiff: "orchestration.getTurnDiff",
22 getFullThreadDiff: "orchestration.getFullThreadDiff",
23 replayEvents: "orchestration.replayEvents",
24 subscribeShell: "orchestration.subscribeShell",
25 subscribeThread: "orchestration.subscribeThread",
26} as const;
27
28export const ProviderKind = Schema.Literals(["codex", "claudeAgent", "cursor", "opencode"]);
29export type ProviderKind = typeof ProviderKind.Type;
30export const ProviderApprovalPolicy = Schema.Literals([
31 "untrusted",
32 "on-failure",
33 "on-request",
34 "never",
35]);
36export type ProviderApprovalPolicy = typeof ProviderApprovalPolicy.Type;
37export const ProviderSandboxMode = Schema.Literals([
38 "read-only",
39 "workspace-write",
40 "danger-full-access",
41]);
42export type ProviderSandboxMode = typeof ProviderSandboxMode.Type;
43
44export const DEFAULT_PROVIDER_KIND: ProviderKind = "codex";
45
46export const CodexModelSelection = Schema.Struct({
47 provider: Schema.Literal("codex"),
48 model: TrimmedNonEmptyString,
49 options: Schema.optionalKey(ProviderOptionSelections),
50});
51export type CodexModelSelection = typeof CodexModelSelection.Type;
52
53export const ClaudeModelSelection = Schema.Struct({
54 provider: Schema.Literal("claudeAgent"),
55 model: TrimmedNonEmptyString,
56 options: Schema.optionalKey(ProviderOptionSelections),
57});
58export type ClaudeModelSelection = typeof ClaudeModelSelection.Type;
59
60export const CursorModelSelection = Schema.Struct({
61 provider: Schema.Literal("cursor"),
62 model: TrimmedNonEmptyString,
63 options: Schema.optionalKey(ProviderOptionSelections),
64});
65export type CursorModelSelection = typeof CursorModelSelection.Type;
66export const OpenCodeModelSelection = Schema.Struct({
67 provider: Schema.Literal("opencode"),
68 model: TrimmedNonEmptyString,
69 options: Schema.optionalKey(ProviderOptionSelections),
70});
71export type OpenCodeModelSelection = typeof OpenCodeModelSelection.Type;
72
73export const ModelSelection = Schema.Union([
74 CodexModelSelection,
75 ClaudeModelSelection,
76 CursorModelSelection,
77 OpenCodeModelSelection,
78]);
79export type ModelSelection = typeof ModelSelection.Type;
80
81export const RuntimeMode = Schema.Literals([
82 "approval-required",
83 "auto-accept-edits",
84 "full-access",
85]);
86export type RuntimeMode = typeof RuntimeMode.Type;
87export const DEFAULT_RUNTIME_MODE: RuntimeMode = "full-access";
88export const ProviderInteractionMode = Schema.Literals(["default", "plan"]);
89export type ProviderInteractionMode = typeof ProviderInteractionMode.Type;
90export const DEFAULT_PROVIDER_INTERACTION_MODE: ProviderInteractionMode = "default";
91export const ProviderRequestKind = Schema.Literals(["command", "file-read", "file-change"]);
92export type ProviderRequestKind = typeof ProviderRequestKind.Type;
93export const AssistantDeliveryMode = Schema.Literals(["buffered", "streaming"]);
94export type AssistantDeliveryMode = typeof AssistantDeliveryMode.Type;
95export const ProviderApprovalDecision = Schema.Literals([
96 "accept",
97 "acceptForSession",
98 "decline",
99 "cancel",
100]);
101export type ProviderApprovalDecision = typeof ProviderApprovalDecision.Type;
102export const ProviderUserInputAnswers = Schema.Record(Schema.String, Schema.Unknown);
103export type ProviderUserInputAnswers = typeof ProviderUserInputAnswers.Type;
104
105export const PROVIDER_SEND_TURN_MAX_INPUT_CHARS = 120_000;
106export const PROVIDER_SEND_TURN_MAX_ATTACHMENTS = 8;
107export const PROVIDER_SEND_TURN_MAX_IMAGE_BYTES = 10 * 1024 * 1024;
108const PROVIDER_SEND_TURN_MAX_IMAGE_DATA_URL_CHARS = 14_000_000;
109const CHAT_ATTACHMENT_ID_MAX_CHARS = 128;
110// Correlation id is command id by design in this model.
111export const CorrelationId = CommandId;
112export type CorrelationId = typeof CorrelationId.Type;
113
114const ChatAttachmentId = TrimmedNonEmptyString.check(
115 Schema.isMaxLength(CHAT_ATTACHMENT_ID_MAX_CHARS),
116 Schema.isPattern(/^[a-z0-9_-]+$/i),
117);
118export type ChatAttachmentId = typeof ChatAttachmentId.Type;
119
120export const ChatImageAttachment = Schema.Struct({
121 type: Schema.Literal("image"),
122 id: ChatAttachmentId,
123 name: TrimmedNonEmptyString.check(Schema.isMaxLength(255)),
124 mimeType: TrimmedNonEmptyString.check(Schema.isMaxLength(100), Schema.isPattern(/^image\//i)),
125 sizeBytes: NonNegativeInt.check(Schema.isLessThanOrEqualTo(PROVIDER_SEND_TURN_MAX_IMAGE_BYTES)),
126});
127export type ChatImageAttachment = typeof ChatImageAttachment.Type;
128
129const UploadChatImageAttachment = Schema.Struct({
130 type: Schema.Literal("image"),
131 name: TrimmedNonEmptyString.check(Schema.isMaxLength(255)),
132 mimeType: TrimmedNonEmptyString.check(Schema.isMaxLength(100), Schema.isPattern(/^image\//i)),
133 sizeBytes: NonNegativeInt.check(Schema.isLessThanOrEqualTo(PROVIDER_SEND_TURN_MAX_IMAGE_BYTES)),
134 dataUrl: TrimmedNonEmptyString.check(
135 Schema.isMaxLength(PROVIDER_SEND_TURN_MAX_IMAGE_DATA_URL_CHARS),
136 ),
137});
138export type UploadChatImageAttachment = typeof UploadChatImageAttachment.Type;
139
140export const ChatAttachment = Schema.Union([ChatImageAttachment]);
141export type ChatAttachment = typeof ChatAttachment.Type;
142const UploadChatAttachment = Schema.Union([UploadChatImageAttachment]);
143export type UploadChatAttachment = typeof UploadChatAttachment.Type;
144
145export const ProjectScriptIcon = Schema.Literals([
146 "play",
147 "test",
148 "lint",
149 "configure",
150 "build",
151 "debug",
152]);
153export type ProjectScriptIcon = typeof ProjectScriptIcon.Type;
154
155export const ProjectScript = Schema.Struct({
156 id: TrimmedNonEmptyString,
157 name: TrimmedNonEmptyString,
158 command: TrimmedNonEmptyString,
159 icon: ProjectScriptIcon,
160 runOnWorktreeCreate: Schema.Boolean,
161});
162export type ProjectScript = typeof ProjectScript.Type;
163
164export const OrchestrationProject = Schema.Struct({
165 id: ProjectId,
166 title: TrimmedNonEmptyString,
167 workspaceRoot: TrimmedNonEmptyString,
168 repositoryIdentity: Schema.optional(Schema.NullOr(RepositoryIdentity)),
169 defaultModelSelection: Schema.NullOr(ModelSelection),
170 scripts: Schema.Array(ProjectScript),
171 createdAt: IsoDateTime,
172 updatedAt: IsoDateTime,
173 deletedAt: Schema.NullOr(IsoDateTime),
174});
175export type OrchestrationProject = typeof OrchestrationProject.Type;
176
177export const OrchestrationMessageRole = Schema.Literals(["user", "assistant", "system"]);
178export type OrchestrationMessageRole = typeof OrchestrationMessageRole.Type;
179
180export const OrchestrationMessage = Schema.Struct({
181 id: MessageId,
182 role: OrchestrationMessageRole,
183 text: Schema.String,
184 attachments: Schema.optional(Schema.Array(ChatAttachment)),
185 turnId: Schema.NullOr(TurnId),
186 streaming: Schema.Boolean,
187 createdAt: IsoDateTime,
188 updatedAt: IsoDateTime,
189});
190export type OrchestrationMessage = typeof OrchestrationMessage.Type;
191
192export const OrchestrationProposedPlanId = TrimmedNonEmptyString;
193export type OrchestrationProposedPlanId = typeof OrchestrationProposedPlanId.Type;
194
195export const OrchestrationProposedPlan = Schema.Struct({
196 id: OrchestrationProposedPlanId,
197 turnId: Schema.NullOr(TurnId),
198 planMarkdown: TrimmedNonEmptyString,
199 implementedAt: Schema.NullOr(IsoDateTime).pipe(Schema.withDecodingDefault(Effect.succeed(null))),
200 implementationThreadId: Schema.NullOr(ThreadId).pipe(
201 Schema.withDecodingDefault(Effect.succeed(null)),
202 ),
203 createdAt: IsoDateTime,
204 updatedAt: IsoDateTime,
205});
206export type OrchestrationProposedPlan = typeof OrchestrationProposedPlan.Type;
207
208const SourceProposedPlanReference = Schema.Struct({
209 threadId: ThreadId,
210 planId: OrchestrationProposedPlanId,
211});
212
213export const OrchestrationSessionStatus = Schema.Literals([
214 "idle",
215 "starting",
216 "running",
217 "ready",
218 "interrupted",
219 "stopped",
220 "error",
221]);
222export type OrchestrationSessionStatus = typeof OrchestrationSessionStatus.Type;
223
224export const OrchestrationSession = Schema.Struct({
225 threadId: ThreadId,
226 status: OrchestrationSessionStatus,
227 providerName: Schema.NullOr(TrimmedNonEmptyString),
228 runtimeMode: RuntimeMode.pipe(Schema.withDecodingDefault(Effect.succeed(DEFAULT_RUNTIME_MODE))),
229 activeTurnId: Schema.NullOr(TurnId),
230 lastError: Schema.NullOr(TrimmedNonEmptyString),
231 updatedAt: IsoDateTime,
232});
233export type OrchestrationSession = typeof OrchestrationSession.Type;
234
235export const OrchestrationCheckpointFile = Schema.Struct({
236 path: TrimmedNonEmptyString,
237 kind: TrimmedNonEmptyString,
238 additions: NonNegativeInt,
239 deletions: NonNegativeInt,
240});
241export type OrchestrationCheckpointFile = typeof OrchestrationCheckpointFile.Type;
242
243export const OrchestrationCheckpointStatus = Schema.Literals(["ready", "missing", "error"]);
244export type OrchestrationCheckpointStatus = typeof OrchestrationCheckpointStatus.Type;
245
246export const OrchestrationCheckpointSummary = Schema.Struct({
247 turnId: TurnId,
248 checkpointTurnCount: NonNegativeInt,
249 checkpointRef: CheckpointRef,
250 status: OrchestrationCheckpointStatus,
251 files: Schema.Array(OrchestrationCheckpointFile),
252 assistantMessageId: Schema.NullOr(MessageId),
253 completedAt: IsoDateTime,
254});
255export type OrchestrationCheckpointSummary = typeof OrchestrationCheckpointSummary.Type;
256
257export const OrchestrationThreadActivityTone = Schema.Literals([
258 "info",
259 "tool",
260 "approval",
261 "error",
262]);
263export type OrchestrationThreadActivityTone = typeof OrchestrationThreadActivityTone.Type;
264
265export const OrchestrationThreadActivity = Schema.Struct({
266 id: EventId,
267 tone: OrchestrationThreadActivityTone,
268 kind: TrimmedNonEmptyString,
269 summary: TrimmedNonEmptyString,
270 payload: Schema.Unknown,
271 turnId: Schema.NullOr(TurnId),
272 sequence: Schema.optional(NonNegativeInt),
273 createdAt: IsoDateTime,
274});
275export type OrchestrationThreadActivity = typeof OrchestrationThreadActivity.Type;
276
277const OrchestrationLatestTurnState = Schema.Literals([
278 "running",
279 "interrupted",
280 "completed",
281 "error",
282]);
283export type OrchestrationLatestTurnState = typeof OrchestrationLatestTurnState.Type;
284
285export const OrchestrationLatestTurn = Schema.Struct({
286 turnId: TurnId,
287 state: OrchestrationLatestTurnState,
288 requestedAt: IsoDateTime,
289 startedAt: Schema.NullOr(IsoDateTime),
290 completedAt: Schema.NullOr(IsoDateTime),
291 assistantMessageId: Schema.NullOr(MessageId),
292 sourceProposedPlan: Schema.optional(SourceProposedPlanReference),
293});
294export type OrchestrationLatestTurn = typeof OrchestrationLatestTurn.Type;
295
296export const OrchestrationThread = Schema.Struct({
297 id: ThreadId,
298 projectId: ProjectId,
299 title: TrimmedNonEmptyString,
300 modelSelection: ModelSelection,
301 runtimeMode: RuntimeMode,
302 interactionMode: ProviderInteractionMode.pipe(
303 Schema.withDecodingDefault(Effect.succeed(DEFAULT_PROVIDER_INTERACTION_MODE)),
304 ),
305 branch: Schema.NullOr(TrimmedNonEmptyString),
306 worktreePath: Schema.NullOr(TrimmedNonEmptyString),
307 latestTurn: Schema.NullOr(OrchestrationLatestTurn),
308 createdAt: IsoDateTime,
309 updatedAt: IsoDateTime,
310 archivedAt: Schema.NullOr(IsoDateTime).pipe(Schema.withDecodingDefault(Effect.succeed(null))),
311 deletedAt: Schema.NullOr(IsoDateTime),
312 messages: Schema.Array(OrchestrationMessage),
313 proposedPlans: Schema.Array(OrchestrationProposedPlan).pipe(
314 Schema.withDecodingDefault(Effect.succeed([])),
315 ),
316 activities: Schema.Array(OrchestrationThreadActivity),
317 checkpoints: Schema.Array(OrchestrationCheckpointSummary),
318 session: Schema.NullOr(OrchestrationSession),
319});
320export type OrchestrationThread = typeof OrchestrationThread.Type;
321
322export const OrchestrationReadModel = Schema.Struct({
323 snapshotSequence: NonNegativeInt,
324 projects: Schema.Array(OrchestrationProject),
325 threads: Schema.Array(OrchestrationThread),
326 updatedAt: IsoDateTime,
327});
328export type OrchestrationReadModel = typeof OrchestrationReadModel.Type;
329
330export const OrchestrationProjectShell = Schema.Struct({
331 id: ProjectId,
332 title: TrimmedNonEmptyString,
333 workspaceRoot: TrimmedNonEmptyString,
334 repositoryIdentity: Schema.optional(Schema.NullOr(RepositoryIdentity)),
335 defaultModelSelection: Schema.NullOr(ModelSelection),
336 scripts: Schema.Array(ProjectScript),
337 createdAt: IsoDateTime,
338 updatedAt: IsoDateTime,
339});
340export type OrchestrationProjectShell = typeof OrchestrationProjectShell.Type;
341
342export const OrchestrationThreadShell = Schema.Struct({
343 id: ThreadId,
344 projectId: ProjectId,
345 title: TrimmedNonEmptyString,
346 modelSelection: ModelSelection,
347 runtimeMode: RuntimeMode,
348 interactionMode: ProviderInteractionMode.pipe(
349 Schema.withDecodingDefault(Effect.succeed(DEFAULT_PROVIDER_INTERACTION_MODE)),
350 ),
351 branch: Schema.NullOr(TrimmedNonEmptyString),
352 worktreePath: Schema.NullOr(TrimmedNonEmptyString),
353 latestTurn: Schema.NullOr(OrchestrationLatestTurn),
354 createdAt: IsoDateTime,
355 updatedAt: IsoDateTime,
356 archivedAt: Schema.NullOr(IsoDateTime).pipe(Schema.withDecodingDefault(Effect.succeed(null))),
357 session: Schema.NullOr(OrchestrationSession),
358 latestUserMessageAt: Schema.NullOr(IsoDateTime),
359 hasPendingApprovals: Schema.Boolean,
360 hasPendingUserInput: Schema.Boolean,
361 hasActionableProposedPlan: Schema.Boolean,
362});
363export type OrchestrationThreadShell = typeof OrchestrationThreadShell.Type;
364
365export const OrchestrationShellSnapshot = Schema.Struct({
366 snapshotSequence: NonNegativeInt,
367 projects: Schema.Array(OrchestrationProjectShell),
368 threads: Schema.Array(OrchestrationThreadShell),
369 updatedAt: IsoDateTime,
370});
371export type OrchestrationShellSnapshot = typeof OrchestrationShellSnapshot.Type;
372
373export const OrchestrationShellStreamEvent = Schema.Union([
374 Schema.Struct({
375 kind: Schema.Literal("project-upserted"),
376 sequence: NonNegativeInt,
377 project: OrchestrationProjectShell,
378 }),
379 Schema.Struct({
380 kind: Schema.Literal("project-removed"),
381 sequence: NonNegativeInt,
382 projectId: ProjectId,
383 }),
384 Schema.Struct({
385 kind: Schema.Literal("thread-upserted"),
386 sequence: NonNegativeInt,
387 thread: OrchestrationThreadShell,
388 }),
389 Schema.Struct({
390 kind: Schema.Literal("thread-removed"),
391 sequence: NonNegativeInt,
392 threadId: ThreadId,
393 }),
394]);
395export type OrchestrationShellStreamEvent = typeof OrchestrationShellStreamEvent.Type;
396
397export const OrchestrationShellStreamItem = Schema.Union([
398 Schema.Struct({
399 kind: Schema.Literal("snapshot"),
400 snapshot: OrchestrationShellSnapshot,
401 }),
402 OrchestrationShellStreamEvent,
403]);
404export type OrchestrationShellStreamItem = typeof OrchestrationShellStreamItem.Type;
405
406export const OrchestrationSubscribeThreadInput = Schema.Struct({
407 threadId: ThreadId,
408});
409export type OrchestrationSubscribeThreadInput = typeof OrchestrationSubscribeThreadInput.Type;
410
411export const OrchestrationThreadDetailSnapshot = Schema.Struct({
412 snapshotSequence: NonNegativeInt,
413 thread: OrchestrationThread,
414});
415export type OrchestrationThreadDetailSnapshot = typeof OrchestrationThreadDetailSnapshot.Type;
416
417export const ProjectCreateCommand = Schema.Struct({
418 type: Schema.Literal("project.create"),
419 commandId: CommandId,
420 projectId: ProjectId,
421 title: TrimmedNonEmptyString,
422 workspaceRoot: TrimmedNonEmptyString,
423 createWorkspaceRootIfMissing: Schema.optional(Schema.Boolean),
424 defaultModelSelection: Schema.optional(Schema.NullOr(ModelSelection)),
425 createdAt: IsoDateTime,
426});
427
428const ProjectMetaUpdateCommand = Schema.Struct({
429 type: Schema.Literal("project.meta.update"),
430 commandId: CommandId,
431 projectId: ProjectId,
432 title: Schema.optional(TrimmedNonEmptyString),
433 workspaceRoot: Schema.optional(TrimmedNonEmptyString),
434 defaultModelSelection: Schema.optional(Schema.NullOr(ModelSelection)),
435 scripts: Schema.optional(Schema.Array(ProjectScript)),
436});
437
438const ProjectDeleteCommand = Schema.Struct({
439 type: Schema.Literal("project.delete"),
440 commandId: CommandId,
441 projectId: ProjectId,
442 force: Schema.optional(Schema.Boolean),
443});
444
445const ThreadCreateCommand = Schema.Struct({
446 type: Schema.Literal("thread.create"),
447 commandId: CommandId,
448 threadId: ThreadId,
449 projectId: ProjectId,
450 title: TrimmedNonEmptyString,
451 modelSelection: ModelSelection,
452 runtimeMode: RuntimeMode,
453 interactionMode: ProviderInteractionMode.pipe(
454 Schema.withDecodingDefault(Effect.succeed(DEFAULT_PROVIDER_INTERACTION_MODE)),
455 ),
456 branch: Schema.NullOr(TrimmedNonEmptyString),
457 worktreePath: Schema.NullOr(TrimmedNonEmptyString),
458 createdAt: IsoDateTime,
459});
460
461const ThreadDeleteCommand = Schema.Struct({
462 type: Schema.Literal("thread.delete"),
463 commandId: CommandId,
464 threadId: ThreadId,
465});
466
467const ThreadArchiveCommand = Schema.Struct({
468 type: Schema.Literal("thread.archive"),
469 commandId: CommandId,
470 threadId: ThreadId,
471});
472
473const ThreadUnarchiveCommand = Schema.Struct({
474 type: Schema.Literal("thread.unarchive"),
475 commandId: CommandId,
476 threadId: ThreadId,
477});
478
479const ThreadMetaUpdateCommand = Schema.Struct({
480 type: Schema.Literal("thread.meta.update"),
481 commandId: CommandId,
482 threadId: ThreadId,
483 title: Schema.optional(TrimmedNonEmptyString),
484 modelSelection: Schema.optional(ModelSelection),
485 branch: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
486 worktreePath: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
487});
488
489const ThreadRuntimeModeSetCommand = Schema.Struct({
490 type: Schema.Literal("thread.runtime-mode.set"),
491 commandId: CommandId,
492 threadId: ThreadId,
493 runtimeMode: RuntimeMode,
494 createdAt: IsoDateTime,
495});
496
497const ThreadInteractionModeSetCommand = Schema.Struct({
498 type: Schema.Literal("thread.interaction-mode.set"),
499 commandId: CommandId,
500 threadId: ThreadId,
501 interactionMode: ProviderInteractionMode,
502 createdAt: IsoDateTime,
503});
504
505const ThreadTurnStartBootstrapCreateThread = Schema.Struct({
506 projectId: ProjectId,
507 title: TrimmedNonEmptyString,
508 modelSelection: ModelSelection,
509 runtimeMode: RuntimeMode,
510 interactionMode: ProviderInteractionMode,
511 branch: Schema.NullOr(TrimmedNonEmptyString),
512 worktreePath: Schema.NullOr(TrimmedNonEmptyString),
513 createdAt: IsoDateTime,
514});
515
516const ThreadTurnStartBootstrapPrepareWorktree = Schema.Struct({
517 projectCwd: TrimmedNonEmptyString,
518 baseBranch: TrimmedNonEmptyString,
519 branch: Schema.optional(TrimmedNonEmptyString),
520});
521
522const ThreadTurnStartBootstrap = Schema.Struct({
523 createThread: Schema.optional(ThreadTurnStartBootstrapCreateThread),
524 prepareWorktree: Schema.optional(ThreadTurnStartBootstrapPrepareWorktree),
525 runSetupScript: Schema.optional(Schema.Boolean),
526});
527
528export type ThreadTurnStartBootstrap = typeof ThreadTurnStartBootstrap.Type;
529
530export const ThreadTurnStartCommand = Schema.Struct({
531 type: Schema.Literal("thread.turn.start"),
532 commandId: CommandId,
533 threadId: ThreadId,
534 message: Schema.Struct({
535 messageId: MessageId,
536 role: Schema.Literal("user"),
537 text: Schema.String,
538 attachments: Schema.Array(ChatAttachment),
539 }),
540 modelSelection: Schema.optional(ModelSelection),
541 titleSeed: Schema.optional(TrimmedNonEmptyString),
542 runtimeMode: RuntimeMode.pipe(Schema.withDecodingDefault(Effect.succeed(DEFAULT_RUNTIME_MODE))),
543 interactionMode: ProviderInteractionMode.pipe(
544 Schema.withDecodingDefault(Effect.succeed(DEFAULT_PROVIDER_INTERACTION_MODE)),
545 ),
546 bootstrap: Schema.optional(ThreadTurnStartBootstrap),
547 sourceProposedPlan: Schema.optional(SourceProposedPlanReference),
548 createdAt: IsoDateTime,
549});
550
551const ClientThreadTurnStartCommand = Schema.Struct({
552 type: Schema.Literal("thread.turn.start"),
553 commandId: CommandId,
554 threadId: ThreadId,
555 message: Schema.Struct({
556 messageId: MessageId,
557 role: Schema.Literal("user"),
558 text: Schema.String,
559 attachments: Schema.Array(UploadChatAttachment),
560 }),
561 modelSelection: Schema.optional(ModelSelection),
562 titleSeed: Schema.optional(TrimmedNonEmptyString),
563 runtimeMode: RuntimeMode,
564 interactionMode: ProviderInteractionMode,
565 bootstrap: Schema.optional(ThreadTurnStartBootstrap),
566 sourceProposedPlan: Schema.optional(SourceProposedPlanReference),
567 createdAt: IsoDateTime,
568});
569
570const ThreadTurnInterruptCommand = Schema.Struct({
571 type: Schema.Literal("thread.turn.interrupt"),
572 commandId: CommandId,
573 threadId: ThreadId,
574 turnId: Schema.optional(TurnId),
575 createdAt: IsoDateTime,
576});
577
578const ThreadApprovalRespondCommand = Schema.Struct({
579 type: Schema.Literal("thread.approval.respond"),
580 commandId: CommandId,
581 threadId: ThreadId,
582 requestId: ApprovalRequestId,
583 decision: ProviderApprovalDecision,
584 createdAt: IsoDateTime,
585});
586
587const ThreadUserInputRespondCommand = Schema.Struct({
588 type: Schema.Literal("thread.user-input.respond"),
589 commandId: CommandId,
590 threadId: ThreadId,
591 requestId: ApprovalRequestId,
592 answers: ProviderUserInputAnswers,
593 createdAt: IsoDateTime,
594});
595
596const ThreadCheckpointRevertCommand = Schema.Struct({
597 type: Schema.Literal("thread.checkpoint.revert"),
598 commandId: CommandId,
599 threadId: ThreadId,
600 turnCount: NonNegativeInt,
601 createdAt: IsoDateTime,
602});
603
604const ThreadSessionStopCommand = Schema.Struct({
605 type: Schema.Literal("thread.session.stop"),
606 commandId: CommandId,
607 threadId: ThreadId,
608 createdAt: IsoDateTime,
609});
610
611const DispatchableClientOrchestrationCommand = Schema.Union([
612 ProjectCreateCommand,
613 ProjectMetaUpdateCommand,
614 ProjectDeleteCommand,
615 ThreadCreateCommand,
616 ThreadDeleteCommand,
617 ThreadArchiveCommand,
618 ThreadUnarchiveCommand,
619 ThreadMetaUpdateCommand,
620 ThreadRuntimeModeSetCommand,
621 ThreadInteractionModeSetCommand,
622 ThreadTurnStartCommand,
623 ThreadTurnInterruptCommand,
624 ThreadApprovalRespondCommand,
625 ThreadUserInputRespondCommand,
626 ThreadCheckpointRevertCommand,
627 ThreadSessionStopCommand,
628]);
629export type DispatchableClientOrchestrationCommand =
630 typeof DispatchableClientOrchestrationCommand.Type;
631
632export const ClientOrchestrationCommand = Schema.Union([
633 ProjectCreateCommand,
634 ProjectMetaUpdateCommand,
635 ProjectDeleteCommand,
636 ThreadCreateCommand,
637 ThreadDeleteCommand,
638 ThreadArchiveCommand,
639 ThreadUnarchiveCommand,
640 ThreadMetaUpdateCommand,
641 ThreadRuntimeModeSetCommand,
642 ThreadInteractionModeSetCommand,
643 ClientThreadTurnStartCommand,
644 ThreadTurnInterruptCommand,
645 ThreadApprovalRespondCommand,
646 ThreadUserInputRespondCommand,
647 ThreadCheckpointRevertCommand,
648 ThreadSessionStopCommand,
649]);
650export type ClientOrchestrationCommand = typeof ClientOrchestrationCommand.Type;
651
652const ThreadSessionSetCommand = Schema.Struct({
653 type: Schema.Literal("thread.session.set"),
654 commandId: CommandId,
655 threadId: ThreadId,
656 session: OrchestrationSession,
657 createdAt: IsoDateTime,
658});
659
660const ThreadMessageAssistantDeltaCommand = Schema.Struct({
661 type: Schema.Literal("thread.message.assistant.delta"),
662 commandId: CommandId,
663 threadId: ThreadId,
664 messageId: MessageId,
665 delta: Schema.String,
666 turnId: Schema.optional(TurnId),
667 createdAt: IsoDateTime,
668});
669
670const ThreadMessageAssistantCompleteCommand = Schema.Struct({
671 type: Schema.Literal("thread.message.assistant.complete"),
672 commandId: CommandId,
673 threadId: ThreadId,
674 messageId: MessageId,
675 turnId: Schema.optional(TurnId),
676 createdAt: IsoDateTime,
677});
678
679const ThreadProposedPlanUpsertCommand = Schema.Struct({
680 type: Schema.Literal("thread.proposed-plan.upsert"),
681 commandId: CommandId,
682 threadId: ThreadId,
683 proposedPlan: OrchestrationProposedPlan,
684 createdAt: IsoDateTime,
685});
686
687const ThreadTurnDiffCompleteCommand = Schema.Struct({
688 type: Schema.Literal("thread.turn.diff.complete"),
689 commandId: CommandId,
690 threadId: ThreadId,
691 turnId: TurnId,
692 completedAt: IsoDateTime,
693 checkpointRef: CheckpointRef,
694 status: OrchestrationCheckpointStatus,
695 files: Schema.Array(OrchestrationCheckpointFile),
696 assistantMessageId: Schema.optional(MessageId),
697 checkpointTurnCount: NonNegativeInt,
698 createdAt: IsoDateTime,
699});
700
701const ThreadActivityAppendCommand = Schema.Struct({
702 type: Schema.Literal("thread.activity.append"),
703 commandId: CommandId,
704 threadId: ThreadId,
705 activity: OrchestrationThreadActivity,
706 createdAt: IsoDateTime,
707});
708
709const ThreadRevertCompleteCommand = Schema.Struct({
710 type: Schema.Literal("thread.revert.complete"),
711 commandId: CommandId,
712 threadId: ThreadId,
713 turnCount: NonNegativeInt,
714 createdAt: IsoDateTime,
715});
716
717const InternalOrchestrationCommand = Schema.Union([
718 ThreadSessionSetCommand,
719 ThreadMessageAssistantDeltaCommand,
720 ThreadMessageAssistantCompleteCommand,
721 ThreadProposedPlanUpsertCommand,
722 ThreadTurnDiffCompleteCommand,
723 ThreadActivityAppendCommand,
724 ThreadRevertCompleteCommand,
725]);
726export type InternalOrchestrationCommand = typeof InternalOrchestrationCommand.Type;
727
728export const OrchestrationCommand = Schema.Union([
729 DispatchableClientOrchestrationCommand,
730 InternalOrchestrationCommand,
731]);
732export type OrchestrationCommand = typeof OrchestrationCommand.Type;
733
734export const OrchestrationEventType = Schema.Literals([
735 "project.created",
736 "project.meta-updated",
737 "project.deleted",
738 "thread.created",
739 "thread.deleted",
740 "thread.archived",
741 "thread.unarchived",
742 "thread.meta-updated",
743 "thread.runtime-mode-set",
744 "thread.interaction-mode-set",
745 "thread.message-sent",
746 "thread.turn-start-requested",
747 "thread.turn-interrupt-requested",
748 "thread.approval-response-requested",
749 "thread.user-input-response-requested",
750 "thread.checkpoint-revert-requested",
751 "thread.reverted",
752 "thread.session-stop-requested",
753 "thread.session-set",
754 "thread.proposed-plan-upserted",
755 "thread.turn-diff-completed",
756 "thread.activity-appended",
757]);
758export type OrchestrationEventType = typeof OrchestrationEventType.Type;
759
760export const OrchestrationAggregateKind = Schema.Literals(["project", "thread"]);
761export type OrchestrationAggregateKind = typeof OrchestrationAggregateKind.Type;
762export const OrchestrationActorKind = Schema.Literals(["client", "server", "provider"]);
763
764export const ProjectCreatedPayload = Schema.Struct({
765 projectId: ProjectId,
766 title: TrimmedNonEmptyString,
767 workspaceRoot: TrimmedNonEmptyString,
768 repositoryIdentity: Schema.optional(Schema.NullOr(RepositoryIdentity)),
769 defaultModelSelection: Schema.NullOr(ModelSelection),
770 scripts: Schema.Array(ProjectScript),
771 createdAt: IsoDateTime,
772 updatedAt: IsoDateTime,
773});
774
775export const ProjectMetaUpdatedPayload = Schema.Struct({
776 projectId: ProjectId,
777 title: Schema.optional(TrimmedNonEmptyString),
778 workspaceRoot: Schema.optional(TrimmedNonEmptyString),
779 repositoryIdentity: Schema.optional(Schema.NullOr(RepositoryIdentity)),
780 defaultModelSelection: Schema.optional(Schema.NullOr(ModelSelection)),
781 scripts: Schema.optional(Schema.Array(ProjectScript)),
782 updatedAt: IsoDateTime,
783});
784
785export const ProjectDeletedPayload = Schema.Struct({
786 projectId: ProjectId,
787 deletedAt: IsoDateTime,
788});
789
790export const ThreadCreatedPayload = Schema.Struct({
791 threadId: ThreadId,
792 projectId: ProjectId,
793 title: TrimmedNonEmptyString,
794 modelSelection: ModelSelection,
795 runtimeMode: RuntimeMode.pipe(Schema.withDecodingDefault(Effect.succeed(DEFAULT_RUNTIME_MODE))),
796 interactionMode: ProviderInteractionMode.pipe(
797 Schema.withDecodingDefault(Effect.succeed(DEFAULT_PROVIDER_INTERACTION_MODE)),
798 ),
799 branch: Schema.NullOr(TrimmedNonEmptyString),
800 worktreePath: Schema.NullOr(TrimmedNonEmptyString),
801 createdAt: IsoDateTime,
802 updatedAt: IsoDateTime,
803});
804
805export const ThreadDeletedPayload = Schema.Struct({
806 threadId: ThreadId,
807 deletedAt: IsoDateTime,
808});
809
810export const ThreadArchivedPayload = Schema.Struct({
811 threadId: ThreadId,
812 archivedAt: IsoDateTime,
813 updatedAt: IsoDateTime,
814});
815
816export const ThreadUnarchivedPayload = Schema.Struct({
817 threadId: ThreadId,
818 updatedAt: IsoDateTime,
819});
820
821export const ThreadMetaUpdatedPayload = Schema.Struct({
822 threadId: ThreadId,
823 title: Schema.optional(TrimmedNonEmptyString),
824 modelSelection: Schema.optional(ModelSelection),
825 branch: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
826 worktreePath: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
827 updatedAt: IsoDateTime,
828});
829
830export const ThreadRuntimeModeSetPayload = Schema.Struct({
831 threadId: ThreadId,
832 runtimeMode: RuntimeMode,
833 updatedAt: IsoDateTime,
834});
835
836export const ThreadInteractionModeSetPayload = Schema.Struct({
837 threadId: ThreadId,
838 interactionMode: ProviderInteractionMode.pipe(
839 Schema.withDecodingDefault(Effect.succeed(DEFAULT_PROVIDER_INTERACTION_MODE)),
840 ),
841 updatedAt: IsoDateTime,
842});
843
844export const ThreadMessageSentPayload = Schema.Struct({
845 threadId: ThreadId,
846 messageId: MessageId,
847 role: OrchestrationMessageRole,
848 text: Schema.String,
849 attachments: Schema.optional(Schema.Array(ChatAttachment)),
850 turnId: Schema.NullOr(TurnId),
851 streaming: Schema.Boolean,
852 createdAt: IsoDateTime,
853 updatedAt: IsoDateTime,
854});
855
856export const ThreadTurnStartRequestedPayload = Schema.Struct({
857 threadId: ThreadId,
858 messageId: MessageId,
859 modelSelection: Schema.optional(ModelSelection),
860 titleSeed: Schema.optional(TrimmedNonEmptyString),
861 runtimeMode: RuntimeMode.pipe(Schema.withDecodingDefault(Effect.succeed(DEFAULT_RUNTIME_MODE))),
862 interactionMode: ProviderInteractionMode.pipe(
863 Schema.withDecodingDefault(Effect.succeed(DEFAULT_PROVIDER_INTERACTION_MODE)),
864 ),
865 sourceProposedPlan: Schema.optional(SourceProposedPlanReference),
866 createdAt: IsoDateTime,
867});
868
869export const ThreadTurnInterruptRequestedPayload = Schema.Struct({
870 threadId: ThreadId,
871 turnId: Schema.optional(TurnId),
872 createdAt: IsoDateTime,
873});
874
875export const ThreadApprovalResponseRequestedPayload = Schema.Struct({
876 threadId: ThreadId,
877 requestId: ApprovalRequestId,
878 decision: ProviderApprovalDecision,
879 createdAt: IsoDateTime,
880});
881
882const ThreadUserInputResponseRequestedPayload = Schema.Struct({
883 threadId: ThreadId,
884 requestId: ApprovalRequestId,
885 answers: ProviderUserInputAnswers,
886 createdAt: IsoDateTime,
887});
888
889export const ThreadCheckpointRevertRequestedPayload = Schema.Struct({
890 threadId: ThreadId,
891 turnCount: NonNegativeInt,
892 createdAt: IsoDateTime,
893});
894
895export const ThreadRevertedPayload = Schema.Struct({
896 threadId: ThreadId,
897 turnCount: NonNegativeInt,
898});
899
900export const ThreadSessionStopRequestedPayload = Schema.Struct({
901 threadId: ThreadId,
902 createdAt: IsoDateTime,
903});
904
905export const ThreadSessionSetPayload = Schema.Struct({
906 threadId: ThreadId,
907 session: OrchestrationSession,
908});
909
910export const ThreadProposedPlanUpsertedPayload = Schema.Struct({
911 threadId: ThreadId,
912 proposedPlan: OrchestrationProposedPlan,
913});
914
915export const ThreadTurnDiffCompletedPayload = Schema.Struct({
916 threadId: ThreadId,
917 turnId: TurnId,
918 checkpointTurnCount: NonNegativeInt,
919 checkpointRef: CheckpointRef,
920 status: OrchestrationCheckpointStatus,
921 files: Schema.Array(OrchestrationCheckpointFile),
922 assistantMessageId: Schema.NullOr(MessageId),
923 completedAt: IsoDateTime,
924});
925
926export const ThreadActivityAppendedPayload = Schema.Struct({
927 threadId: ThreadId,
928 activity: OrchestrationThreadActivity,
929});
930
931export const OrchestrationEventMetadata = Schema.Struct({
932 providerTurnId: Schema.optional(TrimmedNonEmptyString),
933 providerItemId: Schema.optional(ProviderItemId),
934 adapterKey: Schema.optional(TrimmedNonEmptyString),
935 requestId: Schema.optional(ApprovalRequestId),
936 ingestedAt: Schema.optional(IsoDateTime),
937});
938export type OrchestrationEventMetadata = typeof OrchestrationEventMetadata.Type;
939
940const EventBaseFields = {
941 sequence: NonNegativeInt,
942 eventId: EventId,
943 aggregateKind: OrchestrationAggregateKind,
944 aggregateId: Schema.Union([ProjectId, ThreadId]),
945 occurredAt: IsoDateTime,
946 commandId: Schema.NullOr(CommandId),
947 causationEventId: Schema.NullOr(EventId),
948 correlationId: Schema.NullOr(CommandId),
949 metadata: OrchestrationEventMetadata,
950} as const;
951
952export const OrchestrationEvent = Schema.Union([
953 Schema.Struct({
954 ...EventBaseFields,
955 type: Schema.Literal("project.created"),
956 payload: ProjectCreatedPayload,
957 }),
958 Schema.Struct({
959 ...EventBaseFields,
960 type: Schema.Literal("project.meta-updated"),
961 payload: ProjectMetaUpdatedPayload,
962 }),
963 Schema.Struct({
964 ...EventBaseFields,
965 type: Schema.Literal("project.deleted"),
966 payload: ProjectDeletedPayload,
967 }),
968 Schema.Struct({
969 ...EventBaseFields,
970 type: Schema.Literal("thread.created"),
971 payload: ThreadCreatedPayload,
972 }),
973 Schema.Struct({
974 ...EventBaseFields,
975 type: Schema.Literal("thread.deleted"),
976 payload: ThreadDeletedPayload,
977 }),
978 Schema.Struct({
979 ...EventBaseFields,
980 type: Schema.Literal("thread.archived"),
981 payload: ThreadArchivedPayload,
982 }),
983 Schema.Struct({
984 ...EventBaseFields,
985 type: Schema.Literal("thread.unarchived"),
986 payload: ThreadUnarchivedPayload,
987 }),
988 Schema.Struct({
989 ...EventBaseFields,
990 type: Schema.Literal("thread.meta-updated"),
991 payload: ThreadMetaUpdatedPayload,
992 }),
993 Schema.Struct({
994 ...EventBaseFields,
995 type: Schema.Literal("thread.runtime-mode-set"),
996 payload: ThreadRuntimeModeSetPayload,
997 }),
998 Schema.Struct({
999 ...EventBaseFields,
1000 type: Schema.Literal("thread.interaction-mode-set"),
1001 payload: ThreadInteractionModeSetPayload,
1002 }),
1003 Schema.Struct({
1004 ...EventBaseFields,
1005 type: Schema.Literal("thread.message-sent"),
1006 payload: ThreadMessageSentPayload,
1007 }),
1008 Schema.Struct({
1009 ...EventBaseFields,
1010 type: Schema.Literal("thread.turn-start-requested"),
1011 payload: ThreadTurnStartRequestedPayload,
1012 }),
1013 Schema.Struct({
1014 ...EventBaseFields,
1015 type: Schema.Literal("thread.turn-interrupt-requested"),
1016 payload: ThreadTurnInterruptRequestedPayload,
1017 }),
1018 Schema.Struct({
1019 ...EventBaseFields,
1020 type: Schema.Literal("thread.approval-response-requested"),
1021 payload: ThreadApprovalResponseRequestedPayload,
1022 }),
1023 Schema.Struct({
1024 ...EventBaseFields,
1025 type: Schema.Literal("thread.user-input-response-requested"),
1026 payload: ThreadUserInputResponseRequestedPayload,
1027 }),
1028 Schema.Struct({
1029 ...EventBaseFields,
1030 type: Schema.Literal("thread.checkpoint-revert-requested"),
1031 payload: ThreadCheckpointRevertRequestedPayload,
1032 }),
1033 Schema.Struct({
1034 ...EventBaseFields,
1035 type: Schema.Literal("thread.reverted"),
1036 payload: ThreadRevertedPayload,
1037 }),
1038 Schema.Struct({
1039 ...EventBaseFields,
1040 type: Schema.Literal("thread.session-stop-requested"),
1041 payload: ThreadSessionStopRequestedPayload,
1042 }),
1043 Schema.Struct({
1044 ...EventBaseFields,
1045 type: Schema.Literal("thread.session-set"),
1046 payload: ThreadSessionSetPayload,
1047 }),
1048 Schema.Struct({
1049 ...EventBaseFields,
1050 type: Schema.Literal("thread.proposed-plan-upserted"),
1051 payload: ThreadProposedPlanUpsertedPayload,
1052 }),
1053 Schema.Struct({
1054 ...EventBaseFields,
1055 type: Schema.Literal("thread.turn-diff-completed"),
1056 payload: ThreadTurnDiffCompletedPayload,
1057 }),
1058 Schema.Struct({
1059 ...EventBaseFields,
1060 type: Schema.Literal("thread.activity-appended"),
1061 payload: ThreadActivityAppendedPayload,
1062 }),
1063]);
1064export type OrchestrationEvent = typeof OrchestrationEvent.Type;
1065
1066export const OrchestrationThreadStreamItem = Schema.Union([
1067 Schema.Struct({
1068 kind: Schema.Literal("snapshot"),
1069 snapshot: OrchestrationThreadDetailSnapshot,
1070 }),
1071 Schema.Struct({
1072 kind: Schema.Literal("event"),
1073 event: OrchestrationEvent,
1074 }),
1075]);
1076export type OrchestrationThreadStreamItem = typeof OrchestrationThreadStreamItem.Type;
1077
1078export const OrchestrationCommandReceiptStatus = Schema.Literals(["accepted", "rejected"]);
1079export type OrchestrationCommandReceiptStatus = typeof OrchestrationCommandReceiptStatus.Type;
1080
1081export const TurnCountRange = Schema.Struct({
1082 fromTurnCount: NonNegativeInt,
1083 toTurnCount: NonNegativeInt,
1084}).check(
1085 Schema.makeFilter(
1086 (input) =>
1087 input.fromTurnCount <= input.toTurnCount ||
1088 new SchemaIssue.InvalidValue(Option.some(input.fromTurnCount), {
1089 message: "fromTurnCount must be less than or equal to toTurnCount",
1090 }),
1091 { identifier: "OrchestrationTurnDiffRange" },
1092 ),
1093);
1094
1095export const ThreadTurnDiff = TurnCountRange.mapFields(
1096 Struct.assign({
1097 threadId: ThreadId,
1098 diff: Schema.String,
1099 }),
1100 { unsafePreserveChecks: true },
1101);
1102
1103export const ProviderSessionRuntimeStatus = Schema.Literals([
1104 "starting",
1105 "running",
1106 "stopped",
1107 "error",
1108]);
1109export type ProviderSessionRuntimeStatus = typeof ProviderSessionRuntimeStatus.Type;
1110
1111const ProjectionThreadTurnStatus = Schema.Literals([
1112 "running",
1113 "completed",
1114 "interrupted",
1115 "error",
1116]);
1117export type ProjectionThreadTurnStatus = typeof ProjectionThreadTurnStatus.Type;
1118
1119const ProjectionCheckpointRow = Schema.Struct({
1120 threadId: ThreadId,
1121 turnId: TurnId,
1122 checkpointTurnCount: NonNegativeInt,
1123 checkpointRef: CheckpointRef,
1124 status: OrchestrationCheckpointStatus,
1125 files: Schema.Array(OrchestrationCheckpointFile),
1126 assistantMessageId: Schema.NullOr(MessageId),
1127 completedAt: IsoDateTime,
1128});
1129export type ProjectionCheckpointRow = typeof ProjectionCheckpointRow.Type;
1130
1131export const ProjectionPendingApprovalStatus = Schema.Literals(["pending", "resolved"]);
1132export type ProjectionPendingApprovalStatus = typeof ProjectionPendingApprovalStatus.Type;
1133
1134export const ProjectionPendingApprovalDecision = Schema.NullOr(ProviderApprovalDecision);
1135export type ProjectionPendingApprovalDecision = typeof ProjectionPendingApprovalDecision.Type;
1136
1137export const DispatchResult = Schema.Struct({
1138 sequence: NonNegativeInt,
1139});
1140export type DispatchResult = typeof DispatchResult.Type;
1141
1142export const OrchestrationGetTurnDiffInput = TurnCountRange.mapFields(
1143 Struct.assign({ threadId: ThreadId }),
1144 { unsafePreserveChecks: true },
1145);
1146export type OrchestrationGetTurnDiffInput = typeof OrchestrationGetTurnDiffInput.Type;
1147
1148export const OrchestrationGetTurnDiffResult = ThreadTurnDiff;
1149export type OrchestrationGetTurnDiffResult = typeof OrchestrationGetTurnDiffResult.Type;
1150
1151export const OrchestrationGetFullThreadDiffInput = Schema.Struct({
1152 threadId: ThreadId,
1153 toTurnCount: NonNegativeInt,
1154});
1155export type OrchestrationGetFullThreadDiffInput = typeof OrchestrationGetFullThreadDiffInput.Type;
1156
1157export const OrchestrationGetFullThreadDiffResult = ThreadTurnDiff;
1158export type OrchestrationGetFullThreadDiffResult = typeof OrchestrationGetFullThreadDiffResult.Type;
1159
1160export const OrchestrationReplayEventsInput = Schema.Struct({
1161 fromSequenceExclusive: NonNegativeInt,
1162});
1163export type OrchestrationReplayEventsInput = typeof OrchestrationReplayEventsInput.Type;
1164
1165const OrchestrationReplayEventsResult = Schema.Array(OrchestrationEvent);
1166export type OrchestrationReplayEventsResult = typeof OrchestrationReplayEventsResult.Type;
1167
1168export const OrchestrationRpcSchemas = {
1169 dispatchCommand: {
1170 input: ClientOrchestrationCommand,
1171 output: DispatchResult,
1172 },
1173 getTurnDiff: {
1174 input: OrchestrationGetTurnDiffInput,
1175 output: OrchestrationGetTurnDiffResult,
1176 },
1177 getFullThreadDiff: {
1178 input: OrchestrationGetFullThreadDiffInput,
1179 output: OrchestrationGetFullThreadDiffResult,
1180 },
1181 replayEvents: {
1182 input: OrchestrationReplayEventsInput,
1183 output: OrchestrationReplayEventsResult,
1184 },
1185 subscribeThread: {
1186 input: OrchestrationSubscribeThreadInput,
1187 output: OrchestrationThreadStreamItem,
1188 },
1189 subscribeShell: {
1190 input: Schema.Struct({}),
1191 output: OrchestrationShellStreamItem,
1192 },
1193} as const;
1194
1195export class OrchestrationGetSnapshotError extends Schema.TaggedErrorClass<OrchestrationGetSnapshotError>()(
1196 "OrchestrationGetSnapshotError",
1197 {
1198 message: TrimmedNonEmptyString,
1199 cause: Schema.optional(Schema.Defect),
1200 },
1201) {}
1202
1203export class OrchestrationDispatchCommandError extends Schema.TaggedErrorClass<OrchestrationDispatchCommandError>()(
1204 "OrchestrationDispatchCommandError",
1205 {
1206 message: TrimmedNonEmptyString,
1207 cause: Schema.optional(Schema.Defect),
1208 },
1209) {}
1210
1211export class OrchestrationGetTurnDiffError extends Schema.TaggedErrorClass<OrchestrationGetTurnDiffError>()(
1212 "OrchestrationGetTurnDiffError",
1213 {
1214 message: TrimmedNonEmptyString,
1215 cause: Schema.optional(Schema.Defect),
1216 },
1217) {}
1218
1219export class OrchestrationGetFullThreadDiffError extends Schema.TaggedErrorClass<OrchestrationGetFullThreadDiffError>()(
1220 "OrchestrationGetFullThreadDiffError",
1221 {
1222 message: TrimmedNonEmptyString,
1223 cause: Schema.optional(Schema.Defect),
1224 },
1225) {}
1226
1227export class OrchestrationReplayEventsError extends Schema.TaggedErrorClass<OrchestrationReplayEventsError>()(
1228 "OrchestrationReplayEventsError",
1229 {
1230 message: TrimmedNonEmptyString,
1231 cause: Schema.optional(Schema.Defect),
1232 },
1233) {}