/** * Browser-safe declarative task-orchestration vocabulary. The input describes * a bounded task DAG in model terms, the normalized graph is the validated * package-owned execution data, and the output is the deterministic canonical * result returned to the calling model and persisted with its tool call. * * @module dsh-tool-orchestrate/types */ import type { JsonValue } from '@deepseek-ai/dsh-session'; import type { ObjectJsonSchema } from '@deepseek-ai/dsh-tools'; import type { WorkflowRunId } from '@deepseek-ai/dsh-workflow'; /** One task declaration as accepted from the model-facing tool. */ export interface OrchestrateTaskInput { /** Lowercase kebab-case task id (`^[a-z][a-z0-9-]{0,63}$`), unique in the graph. */ id: string; /** Short normalized display title. */ title: string; /** The task prompt; normalized text is stored and executed as data. */ prompt: string; /** Direct dependency ids; defaults to an empty array for root tasks. */ dependsOn?: string[]; /** Optional model provider override forwarded only for this task. */ provider?: string; /** Optional model override forwarded only for this task. */ model?: string; /** Optional object-rooted structured-output schema forwarded to this task. */ outputSchema?: ObjectJsonSchema; } /** The orchestration identity block supplied as plain JSON. */ export interface OrchestrateMetaInput { /** Short normalized workflow name used for display and progress. */ name: string; /** One-line normalized description of the orchestration. */ description: string; } /** The complete model-facing orchestration input. */ export interface OrchestrateTasksInput { meta: OrchestrateMetaInput; tasks: OrchestrateTaskInput[]; } /** One task after cross-field validation and normalization. */ export interface NormalizedTask { readonly id: string; readonly title: string; readonly prompt: string; /** Direct dependencies in the order declared by the model. */ readonly dependsOn: readonly string[]; readonly provider?: string; readonly model?: string; readonly outputSchema?: ObjectJsonSchema; } /** * The package-owned execution graph. Tasks keep model input order; `layers` * are deterministic topological layers (each dependency appears in an earlier * layer) and layer members keep model input order. */ export interface NormalizedTaskGraph { readonly meta: OrchestrateMetaInput; readonly tasks: readonly NormalizedTask[]; /** One parallel execution layer; members are task ids in input order. */ readonly layers: readonly (readonly string[])[]; } /** One completed task result. `value` is the child's text or structured JSON value. */ export interface OrchestratedTaskCompleted { readonly id: string; readonly status: 'completed'; readonly value: JsonValue; } /** One failed task result; version 1 does not expose provider error text. */ export interface OrchestratedTaskFailed { readonly id: string; readonly status: 'failed'; readonly error: 'subagent_failed'; } /** One skipped task and the direct dependencies that blocked it, in declaration order. */ export interface OrchestratedTaskSkipped { readonly id: string; readonly status: 'skipped'; readonly blockedBy: string[]; } /** The terminal state of one task. */ export type OrchestratedTaskResult = OrchestratedTaskCompleted | OrchestratedTaskFailed | OrchestratedTaskSkipped; /** Aggregate orchestration status. */ export type OrchestrateTasksStatus = 'completed' | 'partial' | 'failed'; /** Deterministic counts over all tasks. */ export interface OrchestrateTasksCounts { readonly completed: number; readonly failed: number; readonly skipped: number; } /** Canonical tool value before the host injects the workflow run id. */ export interface OrchestrateTasksBody { readonly status: OrchestrateTasksStatus; readonly counts: OrchestrateTasksCounts; /** Results in model task-array order, independent of completion order. */ readonly tasks: OrchestratedTaskResult[]; } /** The canonical model-facing output, including the foreground workflow run id. */ export interface OrchestrateTasksOutput extends OrchestrateTasksBody { readonly runId: WorkflowRunId; }