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

orchestratorMcp.ts

589 lines22.1 KB

1import * as Effect from "effect/Effect";
2import * as Schema from "effect/Schema";
3import * as SchemaTransformation from "effect/SchemaTransformation";
4​
5import {
6 ContextTransferId,
7 IsoDateTime,
8 MessageId,
9 NodeId,
10 NonNegativeInt,
11 PositiveInt,
12 ProjectId,
13 RunId,
14 ScheduledTaskId,
15 ThreadId,
16 TrimmedNonEmptyString,
17 TurnItemId,
18} from "./baseSchemas.ts";
19import {
20 ScheduledTaskRunStatus,
21 ScheduledTaskSchedule,
22 ScheduledTaskUpsertSchedule,
23} from "./scheduledTask.ts";
24import { ProviderInteractionMode, RuntimeMode } from "./providerPolicy.ts";
25import { ThreadLinkedPullRequest } from "./threadPullRequest.ts";
26import { ThreadTitleRegeneration } from "./threadTitle.ts";
27import {
28 OrchestrationV2Actor,
29 OrchestrationV2CreationSource,
30 OrchestrationV2RunStatus,
31 OrchestrationV2TurnItemStatus,
32} from "./orchestrationV2.ts";
33import {
34 ProviderOptionDescriptor,
35 ProviderOptionSelection,
36 ProviderOptionSelectionValue,
37} from "./model.ts";
38import { ProviderDriverKind, ProviderInstanceId } from "./providerInstance.ts";
39​
40const OrchestratorMcpPrompt = TrimmedNonEmptyString.check(Schema.isMaxLength(120_000)).annotate({
41 description: "Complete task or message text for the target agent.",
42});
43const OrchestratorMcpTitle = TrimmedNonEmptyString.check(Schema.isMaxLength(512)).annotate({
44 description: "Optional concise display title.",
45});
46const OrchestratorMcpClientRequestId = TrimmedNonEmptyString.check(
47 Schema.isMaxLength(256),
48).annotate({ description: "Stable idempotency key to reuse when retrying this mutation." });
49​
50/**
51 * OpenCode 1.15 has been observed serializing nested MCP union objects as JSON
52 * strings. Keep the structured object as the documented form while accepting
53 * that compatibility shape at the tool boundary and decoding it immediately.
54 */
55const OrchestratorMcpScheduleFromJsonString = Schema.fromJsonString(
56 ScheduledTaskUpsertSchedule,
57).annotate({
58 description:
59 "Compatibility-only JSON encoding of the schedule object. Prefer a structured object.",
60});
61​
62const OrchestratorMcpSchedule = Schema.Union([
63 ScheduledTaskUpsertSchedule,
64 OrchestratorMcpScheduleFromJsonString,
65]).annotate({
66 description:
67 "Recurring schedule object: {type:'interval', everyMs} or {type:'fixed_time', timeOfDay, weekdays?}. Never stringify it unless the provider requires the compatibility form.",
68});
69​
70/**
71 * Shorthand `{ id: value }` record form for target model options. Unlike the
72 * legacy-tolerant `ProviderOptionSelections` persistence schema, this decodes
73 * strictly: a value that is not a string or boolean fails the request rather
74 * than being silently dropped.
75 */
76const OrchestratorMcpTargetOptionsFromRecord = Schema.Record(
77 Schema.String,
78 ProviderOptionSelectionValue,
79).pipe(
80 Schema.decodeTo(
81 Schema.Array(ProviderOptionSelection),
82 SchemaTransformation.transformEffect({
83 decode: (record) =>
84 Effect.succeed(Object.entries(record).map(([id, value]) => ({ id, value }))),
85 encode: (selections: ReadonlyArray<ProviderOptionSelection>) =>
86 Effect.succeed(
87 Object.fromEntries(selections.map((selection) => [selection.id, selection.value])),
88 ),
89 }),
90 ),
91);
92​
93export const OrchestratorMcpTargetOptions = Schema.Union([
94 Schema.Array(ProviderOptionSelection),
95 OrchestratorMcpTargetOptionsFromRecord,
96]);
97export type OrchestratorMcpTargetOptions = typeof OrchestratorMcpTargetOptions.Type;
98​
99export const OrchestratorMcpTarget = Schema.Struct({
100 providerInstanceId: Schema.optional(
101 ProviderInstanceId.annotate({
102 description: "Configured provider instance id from orchestrator_capabilities.",
103 }),
104 ),
105 driverKind: Schema.optional(
106 ProviderDriverKind.annotate({
107 description: "Provider driver kind; prefer providerInstanceId when available.",
108 }),
109 ),
110 model: Schema.optional(
111 TrimmedNonEmptyString.annotate({
112 description: "Model id advertised for the selected provider instance.",
113 }),
114 ),
115 /**
116 * Model option selections for the child (for example reasoning effort).
117 * Accepts the canonical `[{ id, value }]` array or the shorthand
118 * `{ id: value }` record; valid ids come from the option descriptors
119 * advertised by orchestrator_capabilities. When omitted, options inherit
120 * from the parent only when the child runs the parent's provider and model.
121 */
122 options: Schema.optional(
123 OrchestratorMcpTargetOptions.annotate({
124 description: "Model option selections advertised by orchestrator_capabilities.",
125 }),
126 ),
127});
128export type OrchestratorMcpTarget = typeof OrchestratorMcpTarget.Type;
129​
130export const OrchestratorMcpRuntimeMode = Schema.Union([Schema.Literal("inherit"), RuntimeMode]);
131export type OrchestratorMcpRuntimeMode = typeof OrchestratorMcpRuntimeMode.Type;
132​
133export const OrchestratorMcpInteractionMode = Schema.Union([
134 Schema.Literal("inherit"),
135 ProviderInteractionMode,
136]);
137export type OrchestratorMcpInteractionMode = typeof OrchestratorMcpInteractionMode.Type;
138​
139export const OrchestratorMcpTaskRole = Schema.Literals([
140 "implementation",
141 "research",
142 "review",
143 "design",
144 "test",
145 "general",
146]);
147export type OrchestratorMcpTaskRole = typeof OrchestratorMcpTaskRole.Type;
148​
149export const OrchestratorMcpDelegatedTaskStatus = Schema.Literals([
150 "queued",
151 "running",
152 "waiting",
153 "completed",
154 "failed",
155 "cancelled",
156 "interrupted",
157]);
158export type OrchestratorMcpDelegatedTaskStatus = typeof OrchestratorMcpDelegatedTaskStatus.Type;
159​
160export const OrchestratorMcpTerminalDelegatedTaskStatus = Schema.Literals([
161 "completed",
162 "failed",
163 "cancelled",
164 "interrupted",
165]);
166export type OrchestratorMcpTerminalDelegatedTaskStatus =
167 typeof OrchestratorMcpTerminalDelegatedTaskStatus.Type;
168​
169export const OrchestratorMcpDelegateTaskInput = Schema.Struct({
170 task: OrchestratorMcpPrompt.annotate({
171 description: "Self-contained task for one delegated child agent/subagent.",
172 }),
173 target: Schema.optional(OrchestratorMcpTarget),
174 title: Schema.optional(OrchestratorMcpTitle),
175 role: Schema.optional(OrchestratorMcpTaskRole),
176 mode: Schema.optional(
177 Schema.Literals(["async", "wait"]).annotate({
178 description:
179 "Defaults to async. Use wait only when this turn needs the child's result before you can continue.",
180 }),
181 ),
182 timeoutMs: Schema.optional(Schema.Number).annotate({
183 description:
184 "Wait budget for mode=wait only. Default 10 minutes. Elapsing it returns waitTimedOut=true on that call and does not cancel the child.",
185 }),
186 clientRequestId: Schema.optional(OrchestratorMcpClientRequestId),
187 runtimeMode: Schema.optional(OrchestratorMcpRuntimeMode),
188 interactionMode: Schema.optional(OrchestratorMcpInteractionMode),
189});
190export type OrchestratorMcpDelegateTaskInput = typeof OrchestratorMcpDelegateTaskInput.Type;
191​
192export const OrchestratorMcpDelegateTaskResult = Schema.Struct({
193 taskId: NodeId,
194 childThreadId: ThreadId,
195 childRunId: Schema.NullOr(RunId),
196 childNodeId: NodeId,
197 status: OrchestratorMcpDelegatedTaskStatus,
198 workState: Schema.Literals(["working", "waiting_for_children", "result_available"]),
199 hasPendingChildRuns: Schema.Boolean,
200 latestTerminalRunId: Schema.NullOr(RunId),
201 latestTerminalStatus: Schema.NullOr(OrchestratorMcpTerminalDelegatedTaskStatus),
202 latestTerminalSummary: Schema.NullOr(Schema.String),
203 latestTerminalResultContextTransferId: Schema.NullOr(ContextTransferId),
204 providerInstanceId: ProviderInstanceId,
205 model: Schema.NullOr(Schema.String),
206 summary: Schema.NullOr(Schema.String),
207 resultContextTransferId: Schema.NullOr(ContextTransferId),
208 waitTimedOut: Schema.Boolean.annotate({
209 description:
210 "True only on that mode=wait call when timeoutMs elapsed. The timeout does not cancel the child. Later task_status reads return false and use status for liveness.",
211 }),
212});
213export type OrchestratorMcpDelegateTaskResult = typeof OrchestratorMcpDelegateTaskResult.Type;
214​
215export const OrchestratorMcpTaskStatusInput = Schema.Struct({
216 taskId: NodeId,
217});
218export type OrchestratorMcpTaskStatusInput = typeof OrchestratorMcpTaskStatusInput.Type;
219​
220export const OrchestratorMcpTaskCancelInput = Schema.Struct({
221 taskId: NodeId,
222 reason: Schema.optional(Schema.String.check(Schema.isMaxLength(2_000))),
223 clientRequestId: Schema.optional(OrchestratorMcpClientRequestId),
224});
225export type OrchestratorMcpTaskCancelInput = typeof OrchestratorMcpTaskCancelInput.Type;
226​
227export const OrchestratorMcpTaskCancelResult = Schema.Struct({
228 taskId: NodeId,
229 status: Schema.Literals(["cancel_requested", "completed", "failed", "cancelled", "interrupted"]),
230});
231export type OrchestratorMcpTaskCancelResult = typeof OrchestratorMcpTaskCancelResult.Type;
232​
233export const OrchestratorMcpCreateThreadRequest = Schema.Struct({
234 prompt: Schema.optional(OrchestratorMcpPrompt),
235 title: Schema.optional(OrchestratorMcpTitle),
236 target: Schema.optional(OrchestratorMcpTarget),
237 runtimeMode: Schema.optional(OrchestratorMcpRuntimeMode),
238 interactionMode: Schema.optional(OrchestratorMcpInteractionMode),
239});
240export type OrchestratorMcpCreateThreadRequest = typeof OrchestratorMcpCreateThreadRequest.Type;
241​
242export const OrchestratorMcpCreateThreadsInput = Schema.Struct({
243 threads: Schema.Array(OrchestratorMcpCreateThreadRequest).check(
244 Schema.isMinLength(1),
245 Schema.isMaxLength(20),
246 ),
247 clientRequestId: Schema.optional(OrchestratorMcpClientRequestId),
248});
249export type OrchestratorMcpCreateThreadsInput = typeof OrchestratorMcpCreateThreadsInput.Type;
250​
251export const OrchestratorMcpCreatedThreadStatus = Schema.Union([
252 Schema.Literal("idle"),
253 Schema.Literal("preparing"),
254 Schema.Literal("starting"),
255 OrchestratorMcpDelegatedTaskStatus,
256 Schema.Literal("rolled_back"),
257]);
258export type OrchestratorMcpCreatedThreadStatus = typeof OrchestratorMcpCreatedThreadStatus.Type;
259​
260export const OrchestratorMcpCreatedThread = Schema.Struct({
261 threadId: ThreadId,
262 runId: Schema.NullOr(RunId),
263 status: OrchestratorMcpCreatedThreadStatus,
264 title: Schema.String,
265 createdBy: OrchestrationV2Actor,
266 creationSource: OrchestrationV2CreationSource,
267 providerInstanceId: ProviderInstanceId,
268 model: Schema.String,
269});
270export type OrchestratorMcpCreatedThread = typeof OrchestratorMcpCreatedThread.Type;
271​
272export const OrchestratorMcpCreateThreadsResult = Schema.Struct({
273 threads: Schema.Array(OrchestratorMcpCreatedThread),
274});
275export type OrchestratorMcpCreateThreadsResult = typeof OrchestratorMcpCreateThreadsResult.Type;
276​
277export const OrchestratorMcpThreadStatus = Schema.Union([
278 Schema.Literal("idle"),
279 OrchestrationV2RunStatus,
280]);
281export type OrchestratorMcpThreadStatus = typeof OrchestratorMcpThreadStatus.Type;
282​
283export const OrchestratorMcpThreadListInput = Schema.Struct({
284 statuses: Schema.optional(
285 Schema.Array(OrchestratorMcpThreadStatus).check(Schema.isMaxLength(10)),
286 ),
287 titleContains: Schema.optional(TrimmedNonEmptyString.check(Schema.isMaxLength(256))),
288 settled: Schema.optional(Schema.Boolean),
289 includeSubagents: Schema.optional(Schema.Boolean),
290 cursor: Schema.optional(NonNegativeInt),
291 limit: Schema.optional(PositiveInt.check(Schema.isLessThanOrEqualTo(100))),
292});
293export type OrchestratorMcpThreadListInput = typeof OrchestratorMcpThreadListInput.Type;
294​
295export const OrchestratorMcpThreadListItem = Schema.Struct({
296 threadId: ThreadId,
297 title: Schema.String,
298 createdBy: OrchestrationV2Actor,
299 creationSource: OrchestrationV2CreationSource,
300 status: OrchestratorMcpThreadStatus,
301 latestRunId: Schema.NullOr(RunId),
302 providerInstanceId: ProviderInstanceId,
303 model: Schema.String,
304 runtimeMode: RuntimeMode,
305 interactionMode: ProviderInteractionMode,
306 linkedPullRequest: Schema.NullOr(ThreadLinkedPullRequest),
307 settled: Schema.Boolean,
308 settledAt: Schema.NullOr(IsoDateTime),
309 parentThreadId: Schema.NullOr(ThreadId),
310 relationshipToParent: Schema.NullOr(Schema.Literals(["fork", "subagent"])),
311 itemCount: NonNegativeInt,
312 createdAt: IsoDateTime,
313 updatedAt: IsoDateTime,
314});
315export type OrchestratorMcpThreadListItem = typeof OrchestratorMcpThreadListItem.Type;
316​
317export const OrchestratorMcpThreadListResult = Schema.Struct({
318 projectId: ProjectId,
319 currentThreadId: ThreadId,
320 threads: Schema.Array(OrchestratorMcpThreadListItem),
321 nextCursor: Schema.NullOr(NonNegativeInt),
322 total: NonNegativeInt,
323});
324export type OrchestratorMcpThreadListResult = typeof OrchestratorMcpThreadListResult.Type;
325​
326export const OrchestratorMcpThreadReadInput = Schema.Struct({
327 threadId: ThreadId,
328 itemId: Schema.optional(TurnItemId),
329 textOffset: Schema.optional(NonNegativeInt),
330 view: Schema.optional(Schema.Literals(["messages", "activity"])),
331 afterPosition: Schema.optional(NonNegativeInt),
332 limit: Schema.optional(PositiveInt.check(Schema.isLessThanOrEqualTo(100))),
333 runLimit: Schema.optional(PositiveInt.check(Schema.isLessThanOrEqualTo(50))),
334 maxCharsPerItem: Schema.optional(PositiveInt.check(Schema.isLessThanOrEqualTo(50_000))),
335});
336export type OrchestratorMcpThreadReadInput = typeof OrchestratorMcpThreadReadInput.Type;
337​
338export const OrchestratorMcpThreadDetail = Schema.Struct({
339 threadId: ThreadId,
340 projectId: ProjectId,
341 title: Schema.String,
342 createdBy: OrchestrationV2Actor,
343 creationSource: OrchestrationV2CreationSource,
344 status: OrchestratorMcpThreadStatus,
345 latestRunId: Schema.NullOr(RunId),
346 activeRunId: Schema.NullOr(RunId),
347 providerInstanceId: ProviderInstanceId,
348 model: Schema.String,
349 runtimeMode: RuntimeMode,
350 interactionMode: ProviderInteractionMode,
351 linkedPullRequest: Schema.NullOr(ThreadLinkedPullRequest),
352 titleRegeneration: Schema.NullOr(ThreadTitleRegeneration),
353 branch: Schema.NullOr(Schema.String),
354 worktreePath: Schema.NullOr(Schema.String),
355 parentThreadId: Schema.NullOr(ThreadId),
356 relationshipToParent: Schema.NullOr(Schema.Literals(["fork", "subagent"])),
357 runCount: NonNegativeInt,
358 itemCount: NonNegativeInt,
359 pendingRequestCount: NonNegativeInt,
360 archived: Schema.Boolean,
361 settled: Schema.Boolean,
362 settledAt: Schema.NullOr(IsoDateTime),
363 createdAt: IsoDateTime,
364 updatedAt: IsoDateTime,
365});
366export type OrchestratorMcpThreadDetail = typeof OrchestratorMcpThreadDetail.Type;
367​
368export const OrchestratorMcpThreadRun = Schema.Struct({
369 runId: RunId,
370 ordinal: PositiveInt,
371 status: OrchestrationV2RunStatus,
372 providerInstanceId: ProviderInstanceId,
373 model: Schema.String,
374 requestedAt: IsoDateTime,
375 startedAt: Schema.NullOr(IsoDateTime),
376 completedAt: Schema.NullOr(IsoDateTime),
377});
378export type OrchestratorMcpThreadRun = typeof OrchestratorMcpThreadRun.Type;
379​
380export const OrchestratorMcpThreadTimelineItem = Schema.Struct({
381 position: NonNegativeInt,
382 visibility: Schema.Literals(["local", "inherited", "synthetic"]),
383 sourceThreadId: ThreadId,
384 itemId: TurnItemId,
385 runId: Schema.NullOr(RunId),
386 messageId: Schema.NullOr(MessageId),
387 createdBy: Schema.NullOr(OrchestrationV2Actor),
388 creationSource: Schema.NullOr(OrchestrationV2CreationSource),
389 type: Schema.String,
390 status: OrchestrationV2TurnItemStatus,
391 title: Schema.NullOr(Schema.String),
392 text: Schema.NullOr(Schema.String),
393 textTruncated: Schema.Boolean,
394 nextTextOffset: Schema.optional(Schema.NullOr(NonNegativeInt)),
395 updatedAt: IsoDateTime,
396});
397export type OrchestratorMcpThreadTimelineItem = typeof OrchestratorMcpThreadTimelineItem.Type;
398​
399export const OrchestratorMcpThreadReadResult = Schema.Struct({
400 thread: OrchestratorMcpThreadDetail,
401 recentRuns: Schema.Array(OrchestratorMcpThreadRun),
402 items: Schema.Array(OrchestratorMcpThreadTimelineItem),
403 nextPosition: Schema.NullOr(NonNegativeInt),
404 hasMore: Schema.Boolean,
405});
406export type OrchestratorMcpThreadReadResult = typeof OrchestratorMcpThreadReadResult.Type;
407​
408export const OrchestratorMcpThreadSendInput = Schema.Struct({
409 threadId: ThreadId,
410 message: OrchestratorMcpPrompt,
411 mode: Schema.optional(Schema.Literals(["auto", "queue", "steer", "restart"])),
412 clientRequestId: Schema.optional(OrchestratorMcpClientRequestId),
413});
414export type OrchestratorMcpThreadSendInput = typeof OrchestratorMcpThreadSendInput.Type;
415​
416export const OrchestratorMcpThreadSendResult = Schema.Struct({
417 threadId: ThreadId,
418 messageId: MessageId,
419 runId: RunId,
420 status: OrchestrationV2RunStatus,
421 delivery: Schema.Literals(["started", "queued", "steered", "restarted"]),
422});
423export type OrchestratorMcpThreadSendResult = typeof OrchestratorMcpThreadSendResult.Type;
424​
425export const OrchestratorMcpThreadWaitInput = Schema.Struct({
426 threadId: ThreadId,
427 runId: Schema.optional(RunId),
428 timeoutMs: Schema.optional(Schema.Number),
429});
430export type OrchestratorMcpThreadWaitInput = typeof OrchestratorMcpThreadWaitInput.Type;
431​
432export const OrchestratorMcpThreadWaitResult = Schema.Struct({
433 threadId: ThreadId,
434 runId: Schema.NullOr(RunId),
435 status: OrchestratorMcpThreadStatus,
436 timedOut: Schema.Boolean,
437});
438export type OrchestratorMcpThreadWaitResult = typeof OrchestratorMcpThreadWaitResult.Type;
439​
440export const OrchestratorMcpThreadInterruptInput = Schema.Struct({
441 threadId: ThreadId,
442 runId: Schema.optional(RunId),
443 reason: Schema.optional(Schema.String.check(Schema.isMaxLength(2_000))),
444 clientRequestId: Schema.optional(OrchestratorMcpClientRequestId),
445});
446export type OrchestratorMcpThreadInterruptInput = typeof OrchestratorMcpThreadInterruptInput.Type;
447​
448export const OrchestratorMcpThreadInterruptResult = Schema.Struct({
449 threadId: ThreadId,
450 runId: Schema.NullOr(RunId),
451 status: Schema.Union([
452 Schema.Literal("interrupt_requested"),
453 Schema.Literal("no_active_run"),
454 Schema.Literals(["completed", "failed", "cancelled", "interrupted", "rolled_back"]),
455 ]),
456});
457export type OrchestratorMcpThreadInterruptResult = typeof OrchestratorMcpThreadInterruptResult.Type;
458​
459export const OrchestratorMcpProviderCapability = Schema.Struct({
460 providerInstanceId: ProviderInstanceId,
461 driverKind: ProviderDriverKind,
462 displayName: Schema.NullOr(Schema.String),
463 models: Schema.Array(
464 Schema.Struct({
465 id: Schema.String,
466 label: Schema.NullOr(Schema.String),
467 /** Model options a target may select (for example reasoning effort). */
468 options: Schema.optional(Schema.Array(ProviderOptionDescriptor)),
469 }),
470 ),
471 canRunChildTask: Schema.Boolean,
472 canRunCrossProviderChildTask: Schema.Boolean,
473 constraints: Schema.Array(Schema.String),
474});
475export type OrchestratorMcpProviderCapability = typeof OrchestratorMcpProviderCapability.Type;
476​
477export const OrchestratorMcpCapabilitiesResult = Schema.Struct({
478 parentThreadId: ThreadId,
479 inheritedProviderInstanceId: ProviderInstanceId,
480 inheritedModel: Schema.String,
481 runtimeMode: RuntimeMode,
482 interactionMode: ProviderInteractionMode,
483 providers: Schema.Array(OrchestratorMcpProviderCapability),
484 features: Schema.Struct({
485 appOwnedSubagents: Schema.Boolean,
486 asyncPolling: Schema.Boolean,
487 cancellation: Schema.Boolean,
488 batchThreadCreation: Schema.Boolean,
489 threadManagement: Schema.Boolean,
490 incrementalThreadRead: Schema.Boolean,
491 scheduledTasks: Schema.Boolean,
492 maxBatchThreads: Schema.Number,
493 }),
494});
495export type OrchestratorMcpCapabilitiesResult = typeof OrchestratorMcpCapabilitiesResult.Type;
496​
497export const OrchestratorMcpScheduleTaskInput = Schema.Struct({
498 prompt: OrchestratorMcpPrompt.annotate({
499 description: "Prompt executed on every scheduled run.",
500 }),
501 schedule: OrchestratorMcpSchedule,
502 title: Schema.optional(OrchestratorMcpTitle),
503 enabled: Schema.optional(
504 Schema.Boolean.annotate({ description: "Whether the schedule starts enabled; defaults true." }),
505 ),
506 /**
507 * When true (the default), the scheduled task fires into the calling thread
508 * on each run instead of launching a fresh thread. This is the recurring
509 * "wake up in this thread" behaviour reserved for agent-created tasks.
510 */
511 bindToCurrentThread: Schema.optional(
512 Schema.Boolean.annotate({
513 description:
514 "True (default) posts each run into this thread; false creates a fresh top-level thread per run.",
515 }),
516 ),
517 clientRequestId: Schema.optional(OrchestratorMcpClientRequestId),
518});
519export type OrchestratorMcpScheduleTaskInput = typeof OrchestratorMcpScheduleTaskInput.Type;
520​
521/** Summary of a scheduled task returned by the schedule/list/update tools. */
522export const OrchestratorMcpScheduledTask = Schema.Struct({
523 scheduledTaskId: ScheduledTaskId,
524 title: Schema.String,
525 prompt: Schema.String,
526 enabled: Schema.Boolean,
527 projectId: ProjectId,
528 boundThreadId: Schema.NullOr(ThreadId),
529 schedule: ScheduledTaskSchedule,
530 nextRunAt: Schema.NullOr(IsoDateTime),
531 lastRunStatus: ScheduledTaskRunStatus,
532});
533export type OrchestratorMcpScheduledTask = typeof OrchestratorMcpScheduledTask.Type;
534​
535export const OrchestratorMcpScheduleTaskResult = OrchestratorMcpScheduledTask;
536export type OrchestratorMcpScheduleTaskResult = typeof OrchestratorMcpScheduleTaskResult.Type;
537​
538export const OrchestratorMcpListScheduledTasksResult = Schema.Struct({
539 tasks: Schema.Array(OrchestratorMcpScheduledTask),
540});
541export type OrchestratorMcpListScheduledTasksResult =
542 typeof OrchestratorMcpListScheduledTasksResult.Type;
543​
544export const OrchestratorMcpUpdateScheduledTaskInput = Schema.Struct({
545 scheduledTaskId: ScheduledTaskId,
546 prompt: Schema.optional(OrchestratorMcpPrompt),
547 title: Schema.optional(OrchestratorMcpTitle),
548 schedule: Schema.optional(OrchestratorMcpSchedule),
549 enabled: Schema.optional(Schema.Boolean),
550 bindToCurrentThread: Schema.optional(Schema.Boolean),
551});
552export type OrchestratorMcpUpdateScheduledTaskInput =
553 typeof OrchestratorMcpUpdateScheduledTaskInput.Type;
554​
555export const OrchestratorMcpDeleteScheduledTaskInput = Schema.Struct({
556 scheduledTaskId: ScheduledTaskId,
557});
558export type OrchestratorMcpDeleteScheduledTaskInput =
559 typeof OrchestratorMcpDeleteScheduledTaskInput.Type;
560​
561export const OrchestratorMcpDeleteScheduledTaskResult = Schema.Struct({
562 scheduledTaskId: ScheduledTaskId,
563 deleted: Schema.Boolean,
564});
565export type OrchestratorMcpDeleteScheduledTaskResult =
566 typeof OrchestratorMcpDeleteScheduledTaskResult.Type;
567​
568export class OrchestratorMcpFailure extends Schema.TaggedError<OrchestratorMcpFailure>()(
569 "OrchestratorMcpFailure",
570 {
571 code: Schema.Literals([
572 "capability_denied",
573 "parent_not_active",
574 "provider_unavailable",
575 "model_unavailable",
576 "runtime_mode_escalation_denied",
577 "interaction_mode_escalation_denied",
578 "task_not_found",
579 "task_not_cancellable",
580 "thread_not_found",
581 "run_not_found",
582 "thread_not_sendable",
583 "thread_not_interruptible",
584 "invalid_request",
585 "orchestration_error",
586 ]),
587 message: Schema.String,
588 },
589) {}