Open History to see the last commit
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 SecretRef,
16 ThreadId,
17 TrimmedNonEmptyString,
18 TurnItemId,
19} from "./baseSchemas.ts";
20import {
21 ScheduledTaskRunStatus,
22 ScheduledTaskSchedule,
23 ScheduledTaskUpsertSchedule,
24} from "./scheduledTask.ts";
25import { ProviderInteractionMode, RuntimeMode } from "./providerPolicy.ts";
26import { PullRequestState } from "./pullRequest.ts";
27import {
28 ThreadLinkedPullRequest,
29 ThreadPullRequestKey,
30 ThreadPullRequestLinkSource,
31} from "./threadPullRequest.ts";
32import { ThreadTitleRegeneration } from "./threadTitle.ts";
33import {
34 OrchestrationV2Actor,
35 OrchestrationV2CreationSource,
36 OrchestrationV2RunStatus,
37 OrchestrationV2TurnItemStatus,
38} from "./orchestrationV2.ts";
39import {
40 ProviderOptionDescriptor,
41 ProviderOptionSelection,
42 ProviderOptionSelectionValue,
43} from "./model.ts";
44import { ProviderDriverKind, ProviderInstanceId } from "./providerInstance.ts";
45
46const OrchestratorMcpPrompt = TrimmedNonEmptyString.check(Schema.isMaxLength(120_000)).annotate({
47 description: "Complete task or message text for the target agent.",
48});
49const OrchestratorMcpTitle = TrimmedNonEmptyString.check(Schema.isMaxLength(512)).annotate({
50 description: "Optional concise display title.",
51});
52const OrchestratorMcpClientRequestId = TrimmedNonEmptyString.check(
53 Schema.isMaxLength(256),
54).annotate({ description: "Stable idempotency key to reuse when retrying this mutation." });
55
56/**
57 * OpenCode 1.15 has been observed serializing nested MCP union objects as JSON
58 * strings. Keep the structured object as the documented form while accepting
59 * that compatibility shape at the tool boundary and decoding it immediately.
60 */
61const OrchestratorMcpScheduleFromJsonString = Schema.fromJsonString(
62 ScheduledTaskUpsertSchedule,
63).annotate({
64 description:
65 "Compatibility-only JSON encoding of the schedule object. Prefer a structured object.",
66});
67
68const OrchestratorMcpSchedule = Schema.Union([
69 ScheduledTaskUpsertSchedule,
70 OrchestratorMcpScheduleFromJsonString,
71]).annotate({
72 description:
73 "Trigger object: {type:'interval', everyMs}, {type:'fixed_time', timeOfDay, weekdays?}, or {type:'webhook'} to run on each request to a generated URL. Never stringify it unless the provider requires the compatibility form.",
74});
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 options: Schema.optional(
116 OrchestratorMcpTargetOptions.annotate({
117 description: "Model option selections advertised by orchestrator_capabilities.",
118 }),
119 ),
120});
121export type OrchestratorMcpTarget = typeof OrchestratorMcpTarget.Type;
122
123export const OrchestratorMcpRuntimeMode = Schema.Union([Schema.Literal("inherit"), RuntimeMode]);
124export type OrchestratorMcpRuntimeMode = typeof OrchestratorMcpRuntimeMode.Type;
125
126export const OrchestratorMcpInteractionMode = Schema.Union([
127 Schema.Literal("inherit"),
128 ProviderInteractionMode,
129]);
130export type OrchestratorMcpInteractionMode = typeof OrchestratorMcpInteractionMode.Type;
131
132export const OrchestratorMcpTaskRole = Schema.Literals([
133 "implementation",
134 "research",
135 "review",
136 "design",
137 "test",
138 "general",
139]);
140export type OrchestratorMcpTaskRole = typeof OrchestratorMcpTaskRole.Type;
141
142export const OrchestratorMcpDelegatedTaskStatus = Schema.Literals([
143 "queued",
144 "running",
145 "waiting",
146 "completed",
147 "failed",
148 "cancelled",
149 "interrupted",
150]);
151export type OrchestratorMcpDelegatedTaskStatus = typeof OrchestratorMcpDelegatedTaskStatus.Type;
152
153export const OrchestratorMcpTerminalDelegatedTaskStatus = Schema.Literals([
154 "completed",
155 "failed",
156 "cancelled",
157 "interrupted",
158]);
159export type OrchestratorMcpTerminalDelegatedTaskStatus =
160 typeof OrchestratorMcpTerminalDelegatedTaskStatus.Type;
161
162export const OrchestratorMcpDelegateTaskInput = Schema.Struct({
163 task: OrchestratorMcpPrompt.annotate({
164 description: "Self-contained task for one delegated child agent/subagent.",
165 }),
166 target: Schema.optional(OrchestratorMcpTarget),
167 title: Schema.optional(OrchestratorMcpTitle),
168 role: Schema.optional(OrchestratorMcpTaskRole),
169 isolation: Schema.optional(
170 Schema.Literals(["shared", "worktree"]).annotate({
171 description:
172 "Defaults to shared: use the parent's checkout. Worktree creates a separate checkout from the parent's current local commit before starting the child. Uncommitted edits are not copied.",
173 }),
174 ),
175 mode: Schema.optional(
176 Schema.Literals(["async", "wait"]).annotate({
177 description:
178 "Defaults to async. Use wait only when this turn needs the child's result before you can continue.",
179 }),
180 ),
181 timeoutMs: Schema.optional(Schema.Finite).annotate({
182 description:
183 "Wait budget for mode=wait only. Default 10 minutes. Elapsing it returns waitTimedOut=true on that call and does not cancel the child.",
184 }),
185 clientRequestId: Schema.optional(OrchestratorMcpClientRequestId),
186 runtimeMode: Schema.optional(
187 OrchestratorMcpRuntimeMode.annotate({
188 description:
189 "Defaults to inherit; omit it unless the user asks for a supervised child. A narrower mode is not a read-only switch: on most providers, approval-required and auto-accept-edits pause the child at each action that needs approval until a person approves it in the child's thread, which this thread cannot do. To limit what the child does, say so in the task. A mode ranked above this thread's is rejected; that ranking does not promise the child's provider permissions are narrower than this thread's.",
190 }),
191 ),
192 interactionMode: Schema.optional(OrchestratorMcpInteractionMode),
193});
194export type OrchestratorMcpDelegateTaskInput = typeof OrchestratorMcpDelegateTaskInput.Type;
195
196export const OrchestratorMcpDelegateTaskResult = Schema.Struct({
197 taskId: NodeId,
198 childThreadId: ThreadId,
199 childRunId: Schema.NullOr(RunId),
200 childNodeId: NodeId,
201 status: OrchestratorMcpDelegatedTaskStatus,
202 workState: Schema.Literals(["working", "waiting_for_children", "result_available"]),
203 hasPendingChildRuns: Schema.Boolean,
204 latestTerminalRunId: Schema.NullOr(RunId),
205 latestTerminalStatus: Schema.NullOr(OrchestratorMcpTerminalDelegatedTaskStatus),
206 latestTerminalSummary: Schema.NullOr(Schema.String),
207 latestTerminalResultContextTransferId: Schema.NullOr(ContextTransferId),
208 providerInstanceId: ProviderInstanceId,
209 model: Schema.NullOr(Schema.String),
210 summary: Schema.NullOr(Schema.String),
211 resultContextTransferId: Schema.NullOr(ContextTransferId),
212 hasPendingQuestion: Schema.Boolean.annotate({
213 description:
214 "Blocking question ends mode=wait. Pass threadId=childThreadId to t3_pending_request_list, t3_pending_request_read (with requestId) and t3_pending_request_respond, or ask the user; the task's completion still wakes this thread.",
215 }),
216 waitTimedOut: Schema.Boolean.annotate({
217 description:
218 "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.",
219 }),
220});
221export type OrchestratorMcpDelegateTaskResult = typeof OrchestratorMcpDelegateTaskResult.Type;
222
223export const OrchestratorMcpTaskStatusInput = Schema.Struct({
224 taskId: NodeId,
225});
226export type OrchestratorMcpTaskStatusInput = typeof OrchestratorMcpTaskStatusInput.Type;
227
228export const OrchestratorMcpTaskCancelInput = Schema.Struct({
229 taskId: NodeId,
230 reason: Schema.optional(Schema.String.check(Schema.isMaxLength(2_000))),
231 clientRequestId: Schema.optional(OrchestratorMcpClientRequestId),
232});
233export type OrchestratorMcpTaskCancelInput = typeof OrchestratorMcpTaskCancelInput.Type;
234
235export const OrchestratorMcpTaskCancelResult = Schema.Struct({
236 taskId: NodeId,
237 status: Schema.Literals(["cancel_requested", "completed", "failed", "cancelled", "interrupted"]),
238});
239export type OrchestratorMcpTaskCancelResult = typeof OrchestratorMcpTaskCancelResult.Type;
240
241export const OrchestratorMcpCreateThreadRequest = Schema.Struct({
242 prompt: Schema.optional(OrchestratorMcpPrompt),
243 title: Schema.optional(OrchestratorMcpTitle),
244 target: Schema.optional(OrchestratorMcpTarget),
245 runtimeMode: Schema.optional(OrchestratorMcpRuntimeMode),
246 interactionMode: Schema.optional(OrchestratorMcpInteractionMode),
247});
248export type OrchestratorMcpCreateThreadRequest = typeof OrchestratorMcpCreateThreadRequest.Type;
249
250export const OrchestratorMcpCreateThreadsInput = Schema.Struct({
251 threads: Schema.Array(OrchestratorMcpCreateThreadRequest).check(
252 Schema.isMinLength(1),
253 Schema.isMaxLength(20),
254 ),
255 clientRequestId: Schema.optional(OrchestratorMcpClientRequestId),
256});
257export type OrchestratorMcpCreateThreadsInput = typeof OrchestratorMcpCreateThreadsInput.Type;
258
259export const OrchestratorMcpCreatedThreadStatus = Schema.Union([
260 Schema.Literal("idle"),
261 Schema.Literal("preparing"),
262 Schema.Literal("starting"),
263 OrchestratorMcpDelegatedTaskStatus,
264 Schema.Literal("rolled_back"),
265]);
266export type OrchestratorMcpCreatedThreadStatus = typeof OrchestratorMcpCreatedThreadStatus.Type;
267
268export const OrchestratorMcpCreatedThread = Schema.Struct({
269 threadId: ThreadId,
270 runId: Schema.NullOr(RunId),
271 status: OrchestratorMcpCreatedThreadStatus,
272 title: Schema.String,
273 createdBy: OrchestrationV2Actor,
274 creationSource: OrchestrationV2CreationSource,
275 providerInstanceId: ProviderInstanceId,
276 model: Schema.String,
277});
278export type OrchestratorMcpCreatedThread = typeof OrchestratorMcpCreatedThread.Type;
279
280export const OrchestratorMcpCreateThreadsResult = Schema.Struct({
281 threads: Schema.Array(OrchestratorMcpCreatedThread),
282});
283export type OrchestratorMcpCreateThreadsResult = typeof OrchestratorMcpCreateThreadsResult.Type;
284
285export const OrchestratorMcpThreadStatus = Schema.Union([
286 Schema.Literal("idle"),
287 OrchestrationV2RunStatus,
288]);
289export type OrchestratorMcpThreadStatus = typeof OrchestratorMcpThreadStatus.Type;
290
291const OrchestratorMcpProjectTarget = Schema.optional(
292 ProjectId.annotate({
293 description:
294 "Project to act on. Omit for the calling thread's project; required when the caller is not a T3 thread.",
295 }),
296);
297
298export const OrchestratorMcpThreadListInput = Schema.Struct({
299 projectId: OrchestratorMcpProjectTarget,
300 statuses: Schema.optional(
301 Schema.Array(OrchestratorMcpThreadStatus).check(Schema.isMaxLength(10)),
302 ),
303 titleContains: Schema.optional(TrimmedNonEmptyString.check(Schema.isMaxLength(256))),
304 settled: Schema.optional(Schema.Boolean),
305 snoozed: Schema.optional(Schema.Boolean),
306 includeSubagents: Schema.optional(Schema.Boolean),
307 cursor: Schema.optional(NonNegativeInt),
308 limit: Schema.optional(PositiveInt.check(Schema.isLessThanOrEqualTo(100))),
309});
310export type OrchestratorMcpThreadListInput = typeof OrchestratorMcpThreadListInput.Type;
311
312/** A pull request linked to a thread; `state` is null until the host has been read. */
313export const OrchestratorMcpThreadPullRequest = Schema.Struct({
314 ...ThreadPullRequestKey.fields,
315 url: TrimmedNonEmptyString,
316 source: ThreadPullRequestLinkSource,
317 state: Schema.NullOr(PullRequestState),
318});
319export type OrchestratorMcpThreadPullRequest = typeof OrchestratorMcpThreadPullRequest.Type;
320
321export const OrchestratorMcpThreadListItem = Schema.Struct({
322 threadId: ThreadId,
323 title: Schema.String,
324 createdBy: OrchestrationV2Actor,
325 creationSource: OrchestrationV2CreationSource,
326 status: OrchestratorMcpThreadStatus,
327 latestRunId: Schema.NullOr(RunId),
328 providerInstanceId: ProviderInstanceId,
329 model: Schema.String,
330 runtimeMode: RuntimeMode,
331 interactionMode: ProviderInteractionMode,
332 linkedPullRequest: Schema.NullOr(ThreadLinkedPullRequest),
333 /** Missing on older servers. */
334 pullRequests: Schema.optional(Schema.Array(OrchestratorMcpThreadPullRequest)),
335 settled: Schema.Boolean,
336 settledAt: Schema.NullOr(IsoDateTime),
337 snoozed: Schema.Boolean,
338 snoozedUntil: Schema.NullOr(IsoDateTime),
339 parentThreadId: Schema.NullOr(ThreadId),
340 relationshipToParent: Schema.NullOr(Schema.Literals(["fork", "subagent"])),
341 itemCount: NonNegativeInt,
342 createdAt: IsoDateTime,
343 updatedAt: IsoDateTime,
344});
345export type OrchestratorMcpThreadListItem = typeof OrchestratorMcpThreadListItem.Type;
346
347export const OrchestratorMcpThreadListResult = Schema.Struct({
348 projectId: ProjectId,
349 currentThreadId: Schema.NullOr(ThreadId),
350 threads: Schema.Array(OrchestratorMcpThreadListItem),
351 nextCursor: Schema.NullOr(NonNegativeInt),
352 total: NonNegativeInt,
353});
354export type OrchestratorMcpThreadListResult = typeof OrchestratorMcpThreadListResult.Type;
355
356export const OrchestratorMcpThreadReadInput = Schema.Struct({
357 threadId: ThreadId,
358 itemId: Schema.optional(TurnItemId),
359 textOffset: Schema.optional(NonNegativeInt),
360 view: Schema.optional(Schema.Literals(["messages", "activity"])),
361 afterPosition: Schema.optional(NonNegativeInt),
362 limit: Schema.optional(PositiveInt.check(Schema.isLessThanOrEqualTo(100))),
363 runLimit: Schema.optional(PositiveInt.check(Schema.isLessThanOrEqualTo(50))),
364 maxCharsPerItem: Schema.optional(PositiveInt.check(Schema.isLessThanOrEqualTo(50_000))),
365});
366export type OrchestratorMcpThreadReadInput = typeof OrchestratorMcpThreadReadInput.Type;
367
368export const OrchestratorMcpThreadDetail = Schema.Struct({
369 threadId: ThreadId,
370 projectId: ProjectId,
371 title: Schema.String,
372 createdBy: OrchestrationV2Actor,
373 creationSource: OrchestrationV2CreationSource,
374 status: OrchestratorMcpThreadStatus,
375 latestRunId: Schema.NullOr(RunId),
376 activeRunId: Schema.NullOr(RunId),
377 providerInstanceId: ProviderInstanceId,
378 model: Schema.String,
379 runtimeMode: RuntimeMode,
380 interactionMode: ProviderInteractionMode,
381 linkedPullRequest: Schema.NullOr(ThreadLinkedPullRequest),
382 /** Missing on older servers. */
383 pullRequests: Schema.optional(Schema.Array(OrchestratorMcpThreadPullRequest)),
384 titleRegeneration: Schema.NullOr(ThreadTitleRegeneration),
385 branch: Schema.NullOr(Schema.String),
386 worktreePath: Schema.NullOr(Schema.String),
387 parentThreadId: Schema.NullOr(ThreadId),
388 relationshipToParent: Schema.NullOr(Schema.Literals(["fork", "subagent"])),
389 runCount: NonNegativeInt,
390 itemCount: NonNegativeInt,
391 pendingRequestCount: NonNegativeInt,
392 archived: Schema.Boolean,
393 settled: Schema.Boolean,
394 settledAt: Schema.NullOr(IsoDateTime),
395 snoozed: Schema.Boolean,
396 snoozedUntil: Schema.NullOr(IsoDateTime),
397 createdAt: IsoDateTime,
398 updatedAt: IsoDateTime,
399});
400export type OrchestratorMcpThreadDetail = typeof OrchestratorMcpThreadDetail.Type;
401
402export const OrchestratorMcpThreadRun = Schema.Struct({
403 runId: RunId,
404 ordinal: PositiveInt,
405 status: OrchestrationV2RunStatus,
406 providerInstanceId: ProviderInstanceId,
407 model: Schema.String,
408 requestedAt: IsoDateTime,
409 startedAt: Schema.NullOr(IsoDateTime),
410 completedAt: Schema.NullOr(IsoDateTime),
411});
412export type OrchestratorMcpThreadRun = typeof OrchestratorMcpThreadRun.Type;
413
414export const OrchestratorMcpThreadTimelineItem = Schema.Struct({
415 position: NonNegativeInt,
416 visibility: Schema.Literals(["local", "inherited", "synthetic"]),
417 sourceThreadId: ThreadId,
418 itemId: TurnItemId,
419 subagentId: Schema.optional(NodeId),
420 runId: Schema.NullOr(RunId),
421 messageId: Schema.NullOr(MessageId),
422 createdBy: Schema.NullOr(OrchestrationV2Actor),
423 creationSource: Schema.NullOr(OrchestrationV2CreationSource),
424 type: Schema.String,
425 status: OrchestrationV2TurnItemStatus,
426 title: Schema.NullOr(Schema.String),
427 text: Schema.NullOr(Schema.String),
428 textTruncated: Schema.Boolean,
429 nextTextOffset: Schema.optional(Schema.NullOr(NonNegativeInt)),
430 updatedAt: IsoDateTime,
431});
432export type OrchestratorMcpThreadTimelineItem = typeof OrchestratorMcpThreadTimelineItem.Type;
433
434export const OrchestratorMcpThreadReadResult = Schema.Struct({
435 thread: OrchestratorMcpThreadDetail,
436 recentRuns: Schema.Array(OrchestratorMcpThreadRun),
437 items: Schema.Array(OrchestratorMcpThreadTimelineItem),
438 nextPosition: Schema.NullOr(NonNegativeInt),
439 hasMore: Schema.Boolean,
440});
441export type OrchestratorMcpThreadReadResult = typeof OrchestratorMcpThreadReadResult.Type;
442
443export const OrchestratorMcpThreadSendInput = Schema.Struct({
444 threadId: ThreadId,
445 message: OrchestratorMcpPrompt,
446 mode: Schema.optional(Schema.Literals(["auto", "queue", "steer", "restart"])),
447 clientRequestId: Schema.optional(OrchestratorMcpClientRequestId),
448});
449export type OrchestratorMcpThreadSendInput = typeof OrchestratorMcpThreadSendInput.Type;
450
451export const OrchestratorMcpThreadSendResult = Schema.Struct({
452 threadId: ThreadId,
453 messageId: MessageId,
454 runId: RunId,
455 taskId: Schema.optional(NodeId),
456 status: OrchestrationV2RunStatus,
457 delivery: Schema.Literals(["started", "queued", "steered", "restarted"]),
458});
459export type OrchestratorMcpThreadSendResult = typeof OrchestratorMcpThreadSendResult.Type;
460
461export const OrchestratorMcpThreadWaitInput = Schema.Struct({
462 threadId: ThreadId,
463 runId: Schema.optional(RunId),
464 timeoutMs: Schema.optional(Schema.Finite),
465});
466export type OrchestratorMcpThreadWaitInput = typeof OrchestratorMcpThreadWaitInput.Type;
467
468export const OrchestratorMcpThreadWaitResult = Schema.Struct({
469 threadId: ThreadId,
470 runId: Schema.NullOr(RunId),
471 status: OrchestratorMcpThreadStatus,
472 timedOut: Schema.Boolean,
473});
474export type OrchestratorMcpThreadWaitResult = typeof OrchestratorMcpThreadWaitResult.Type;
475
476export const OrchestratorMcpThreadInterruptInput = Schema.Struct({
477 threadId: ThreadId,
478 runId: Schema.optional(RunId),
479 reason: Schema.optional(Schema.String.check(Schema.isMaxLength(2_000))),
480 clientRequestId: Schema.optional(OrchestratorMcpClientRequestId),
481});
482export type OrchestratorMcpThreadInterruptInput = typeof OrchestratorMcpThreadInterruptInput.Type;
483
484export const OrchestratorMcpThreadInterruptResult = Schema.Struct({
485 threadId: ThreadId,
486 runId: Schema.NullOr(RunId),
487 status: Schema.Union([
488 Schema.Literal("interrupt_requested"),
489 Schema.Literal("no_active_run"),
490 Schema.Literals(["completed", "failed", "cancelled", "interrupted", "rolled_back"]),
491 ]),
492});
493export type OrchestratorMcpThreadInterruptResult = typeof OrchestratorMcpThreadInterruptResult.Type;
494
495export const OrchestratorMcpProviderCapability = Schema.Struct({
496 providerInstanceId: ProviderInstanceId,
497 driverKind: ProviderDriverKind,
498 displayName: Schema.NullOr(Schema.String),
499 models: Schema.Array(
500 Schema.Struct({
501 id: Schema.String,
502 label: Schema.NullOr(Schema.String),
503 options: Schema.optional(Schema.Array(ProviderOptionDescriptor)),
504 }),
505 ),
506 runtimeModes: Schema.optional(Schema.Array(RuntimeMode)),
507 canRunChildTask: Schema.Boolean,
508 canRunCrossProviderChildTask: Schema.Boolean,
509 constraints: Schema.Array(Schema.String),
510});
511export type OrchestratorMcpProviderCapability = typeof OrchestratorMcpProviderCapability.Type;
512
513export const OrchestratorMcpCapabilitiesResult = Schema.Struct({
514 parentThreadId: Schema.NullOr(ThreadId),
515 inheritedProviderInstanceId: Schema.NullOr(ProviderInstanceId),
516 inheritedModel: Schema.NullOr(Schema.String),
517 runtimeMode: RuntimeMode,
518 interactionMode: ProviderInteractionMode,
519 providers: Schema.Array(OrchestratorMcpProviderCapability),
520 features: Schema.Struct({
521 appOwnedSubagents: Schema.Boolean,
522 asyncPolling: Schema.Boolean,
523 cancellation: Schema.Boolean,
524 batchThreadCreation: Schema.Boolean,
525 threadManagement: Schema.Boolean,
526 incrementalThreadRead: Schema.Boolean,
527 scheduledTasks: Schema.Boolean,
528 maxBatchThreads: Schema.Number,
529 }),
530});
531export type OrchestratorMcpCapabilitiesResult = typeof OrchestratorMcpCapabilitiesResult.Type;
532
533export const OrchestratorMcpScheduleTaskInput = Schema.Struct({
534 projectId: OrchestratorMcpProjectTarget,
535 prompt: OrchestratorMcpPrompt.annotate({
536 description: "Prompt executed on every scheduled run.",
537 }),
538 schedule: OrchestratorMcpSchedule,
539 title: Schema.optional(OrchestratorMcpTitle),
540 enabled: Schema.optional(
541 Schema.Boolean.annotate({ description: "Whether the schedule starts enabled; defaults true." }),
542 ),
543 bindToCurrentThread: Schema.optional(
544 Schema.Boolean.annotate({
545 description:
546 "True (default) posts each run into this thread; false creates a fresh top-level thread per run.",
547 }),
548 ),
549 clientRequestId: Schema.optional(OrchestratorMcpClientRequestId),
550});
551export type OrchestratorMcpScheduleTaskInput = typeof OrchestratorMcpScheduleTaskInput.Type;
552
553export const OrchestratorMcpScheduledTask = Schema.Struct({
554 scheduledTaskId: ScheduledTaskId,
555 title: Schema.String,
556 prompt: Schema.String,
557 enabled: Schema.Boolean,
558 projectId: ProjectId,
559 boundThreadId: Schema.NullOr(ThreadId),
560 schedule: ScheduledTaskSchedule,
561 nextRunAt: Schema.NullOr(IsoDateTime),
562 lastRunStatus: ScheduledTaskRunStatus,
563 webhookUrl: Schema.optional(Schema.String).annotate({
564 description:
565 "Public URL to give the sender. Absent when this environment has no T3 Connect managed tunnel; the user must enable T3 Connect remote access first.",
566 }),
567 webhookSignature: Schema.optional(Schema.Literals(["none", "set"])).annotate({
568 description: "Whether requests must carry a valid signature.",
569 }),
570});
571export type OrchestratorMcpScheduledTask = typeof OrchestratorMcpScheduledTask.Type;
572
573export const OrchestratorMcpScheduleTaskResult = OrchestratorMcpScheduledTask;
574export type OrchestratorMcpScheduleTaskResult = typeof OrchestratorMcpScheduleTaskResult.Type;
575
576export const OrchestratorMcpListScheduledTasksInput = Schema.Struct({
577 projectId: Schema.optional(
578 ProjectId.annotate({
579 description:
580 "Only list this project's tasks. Omit for the calling thread's project, or for every project when the caller is not a T3 thread.",
581 }),
582 ),
583});
584export type OrchestratorMcpListScheduledTasksInput =
585 typeof OrchestratorMcpListScheduledTasksInput.Type;
586
587export const OrchestratorMcpListScheduledTasksResult = Schema.Struct({
588 tasks: Schema.Array(OrchestratorMcpScheduledTask),
589});
590export type OrchestratorMcpListScheduledTasksResult =
591 typeof OrchestratorMcpListScheduledTasksResult.Type;
592
593export const OrchestratorMcpUpdateScheduledTaskInput = Schema.Struct({
594 scheduledTaskId: ScheduledTaskId,
595 prompt: Schema.optional(OrchestratorMcpPrompt),
596 title: Schema.optional(OrchestratorMcpTitle),
597 schedule: Schema.optional(OrchestratorMcpSchedule),
598 enabled: Schema.optional(Schema.Boolean),
599 bindToCurrentThread: Schema.optional(Schema.Boolean),
600});
601export type OrchestratorMcpUpdateScheduledTaskInput =
602 typeof OrchestratorMcpUpdateScheduledTaskInput.Type;
603
604export const OrchestratorMcpRequestSecretInput = Schema.Struct({
605 label: TrimmedNonEmptyString.annotate({
606 description: "What you need, shown as the card's title, e.g. 'GitHub webhook secret'.",
607 }),
608 reason: TrimmedNonEmptyString.annotate({
609 description:
610 "One or two sentences on what it is for and where the user gets or also enters it.",
611 }),
612 placeholder: Schema.optional(TrimmedNonEmptyString).annotate({
613 description: "Hint inside the input, e.g. 'Paste your GitHub token'.",
614 }),
615 timeoutMs: Schema.optional(
616 Schema.Int.check(Schema.isBetween({ minimum: 1_000, maximum: 60 * 60 * 1_000 })),
617 ).annotate({ description: "How long to wait for the user. Default 10 minutes." }),
618 clientRequestId: Schema.optional(OrchestratorMcpClientRequestId).annotate({
619 description:
620 "Reuse when retrying a call that lost its result, so the user sees one card and its answer is returned again. Use a new id to ask again after timed_out or cancelled.",
621 }),
622});
623export type OrchestratorMcpRequestSecretInput = typeof OrchestratorMcpRequestSecretInput.Type;
624
625export const OrchestratorMcpRequestSecretResult = Schema.Union([
626 Schema.Struct({
627 status: Schema.Literal("saved").annotate({ description: "secretRef holds the value." }),
628 secretRef: SecretRef.annotate({
629 description:
630 "Pass it to a tool that accepts a secretRef; it works once, and you never see the value.",
631 }),
632 }),
633 Schema.Struct({
634 status: Schema.Literals(["declined", "cancelled", "timed_out"]).annotate({
635 description:
636 "declined: the user chose not to. cancelled: the request ended with the run. timed_out: the user did not answer in time; the card is closed, so ask again with a new clientRequestId if still needed.",
637 }),
638 }),
639]);
640export type OrchestratorMcpRequestSecretResult = typeof OrchestratorMcpRequestSecretResult.Type;
641
642export const OrchestratorMcpDeleteScheduledTaskInput = Schema.Struct({
643 scheduledTaskId: ScheduledTaskId,
644});
645export type OrchestratorMcpDeleteScheduledTaskInput =
646 typeof OrchestratorMcpDeleteScheduledTaskInput.Type;
647
648export const OrchestratorMcpDeleteScheduledTaskResult = Schema.Struct({
649 scheduledTaskId: ScheduledTaskId,
650 deleted: Schema.Boolean,
651});
652export type OrchestratorMcpDeleteScheduledTaskResult =
653 typeof OrchestratorMcpDeleteScheduledTaskResult.Type;
654
655export class OrchestratorMcpFailure extends Schema.TaggedError<OrchestratorMcpFailure>()(
656 "OrchestratorMcpFailure",
657 {
658 code: Schema.Literals([
659 "capability_denied",
660 "parent_not_active",
661 "provider_unavailable",
662 "model_unavailable",
663 "runtime_mode_escalation_denied",
664 "interaction_mode_escalation_denied",
665 "task_not_found",
666 "task_not_cancellable",
667 "thread_not_found",
668 "run_not_found",
669 "thread_not_sendable",
670 "thread_not_interruptible",
671 "invalid_request",
672 "orchestration_error",
673 "thread_credential_required",
674 "target_required",
675 ]),
676 message: Schema.String,
677 },
678) {}