import { type Static, type TSchema, Type } from "typebox"; import type { WorkflowDefinition } from "../../flow/types.ts"; /** A compact, deterministic schema language used by the creation planner. */ export type SchemaBlueprint = { kind: "string"; description?: string; } | { kind: "number"; description?: string; } | { kind: "integer"; description?: string; } | { kind: "boolean"; description?: string; } | { kind: "unknown"; description?: string; } | { kind: "literal"; value: string | number | boolean; description?: string; } | { kind: "array"; items: SchemaBlueprint; description?: string; } | { kind: "object"; fields: SchemaFieldBlueprint[]; description?: string; } | { kind: "union"; variants: SchemaBlueprint[]; description?: string; }; export interface SchemaFieldBlueprint { readonly name: string; readonly optional?: boolean; readonly title?: string; readonly description?: string; readonly schema: SchemaBlueprint; } export interface NamedSchemaBlueprint { readonly name: string; readonly description?: string; readonly schema: SchemaBlueprint; } export interface RetryBlueprint { readonly maxRetry: number; readonly backoffMs?: number; } export type InputSource = "previous" | "workflow" | "context" | "scope" | "none"; interface StepBlueprintBase { readonly name: string; readonly description?: string; readonly purpose: string; readonly input?: string; readonly output?: string; readonly inputSource?: InputSource; readonly retry?: RetryBlueprint; readonly maxDurationMs?: number; readonly optional?: boolean; } export interface FunctionBlueprint extends StepBlueprintBase { readonly kind: "function"; } export interface AgentBlueprint extends StepBlueprintBase { readonly kind: "agent"; readonly mode: "act" | "report" | "ask"; readonly model?: string; readonly maxOutputRepairs?: number; readonly maxTokens?: number; readonly background?: boolean; readonly resumable?: boolean | string; } export interface QuestionnaireBlueprint extends StepBlueprintBase { readonly kind: "questionnaire"; readonly output: string; } export type LeafStepBlueprint = FunctionBlueprint | AgentBlueprint | QuestionnaireBlueprint; export interface MapBlueprint { readonly kind: "map"; readonly name: string; readonly purpose: string; readonly sources: string[]; } export interface LoopBlueprint { readonly kind: "loop"; readonly name: string; readonly purpose: string; readonly mode: "dowhile" | "dountil"; readonly maxIterations: number; readonly body: WorkflowBodyBlueprint; } export interface ForeachBlueprint { readonly kind: "foreach"; readonly name: string; readonly purpose: string; readonly concurrency?: number; readonly feedback?: boolean; readonly body: WorkflowBodyBlueprint; } export interface ParallelBlueprint { readonly kind: "parallel"; readonly name: string; readonly purpose: string; readonly arms: LeafStepBlueprint[]; } export interface BranchArmBlueprint { readonly purpose: string; readonly body: WorkflowBodyBlueprint; } export interface BranchBlueprint { readonly kind: "branch"; readonly name: string; readonly purpose: string; readonly arms: BranchArmBlueprint[]; } export interface NestedWorkflowBlueprint { readonly kind: "workflow"; readonly name: string; readonly purpose: string; readonly body: WorkflowBodyBlueprint; } export type BlueprintNode = LeafStepBlueprint | MapBlueprint | LoopBlueprint | ForeachBlueprint | ParallelBlueprint | BranchBlueprint | NestedWorkflowBlueprint; export interface WorkflowBodyBlueprint { readonly name: string; readonly description?: string; readonly input?: string; readonly nodes: BlueprintNode[]; } export interface WorkflowBlueprint extends WorkflowBodyBlueprint { readonly description: string; readonly summary: string; readonly schemas: NamedSchemaBlueprint[]; readonly defaultModel?: string; readonly maxConcurrency?: number; } /** Structured contract emitted by the design agent and approved by the user. */ export declare const workflowBlueprintSchema: Type.TObject<{ name: Type.TString; description: Type.TString; summary: Type.TString; input: Type.TOptional; defaultModel: Type.TOptional; maxConcurrency: Type.TOptional; schemas: Type.TArray; schema: Type.TCyclic<{ Schema: Type.TUnion<[Type.TObject<{ kind: Type.TLiteral<"string">; description: Type.TOptional; }>, Type.TObject<{ kind: Type.TLiteral<"number">; description: Type.TOptional; }>, Type.TObject<{ kind: Type.TLiteral<"integer">; description: Type.TOptional; }>, Type.TObject<{ kind: Type.TLiteral<"boolean">; description: Type.TOptional; }>, Type.TObject<{ kind: Type.TLiteral<"unknown">; description: Type.TOptional; }>, Type.TObject<{ kind: Type.TLiteral<"literal">; value: Type.TUnion<[Type.TString, Type.TNumber, Type.TBoolean]>; description: Type.TOptional; }>, Type.TObject<{ kind: Type.TLiteral<"array">; items: Type.TRef<"Schema">; description: Type.TOptional; }>, Type.TObject<{ kind: Type.TLiteral<"object">; fields: Type.TArray; title: Type.TOptional; description: Type.TOptional; schema: Type.TRef<"Schema">; }>>; description: Type.TOptional; }>, Type.TObject<{ kind: Type.TLiteral<"union">; variants: Type.TArray>; description: Type.TOptional; }>]>; }, "Schema">; }>>; nodes: Type.TArray; purpose: Type.TString; input: Type.TOptional; output: Type.TOptional; inputSource: Type.TOptional, Type.TLiteral<"workflow">, Type.TLiteral<"context">, Type.TLiteral<"scope">, Type.TLiteral<"none">]>>; retry: Type.TOptional; }>>; maxDurationMs: Type.TOptional; optional: Type.TOptional; kind: Type.TLiteral<"function">; }>, Type.TObject<{ name: Type.TString; description: Type.TOptional; purpose: Type.TString; input: Type.TOptional; output: Type.TOptional; inputSource: Type.TOptional, Type.TLiteral<"workflow">, Type.TLiteral<"context">, Type.TLiteral<"scope">, Type.TLiteral<"none">]>>; retry: Type.TOptional; }>>; maxDurationMs: Type.TOptional; optional: Type.TOptional; kind: Type.TLiteral<"agent">; mode: Type.TUnion<[Type.TLiteral<"act">, Type.TLiteral<"report">, Type.TLiteral<"ask">]>; model: Type.TOptional; maxOutputRepairs: Type.TOptional; maxTokens: Type.TOptional; background: Type.TOptional; resumable: Type.TOptional>; }>, Type.TObject<{ name: Type.TString; description: Type.TOptional; purpose: Type.TString; input: Type.TOptional; inputSource: Type.TOptional, Type.TLiteral<"workflow">, Type.TLiteral<"context">, Type.TLiteral<"scope">, Type.TLiteral<"none">]>>; retry: Type.TOptional; }>>; maxDurationMs: Type.TOptional; optional: Type.TOptional; kind: Type.TLiteral<"questionnaire">; output: Type.TString; }>]>; Body: Type.TObject<{ name: Type.TString; description: Type.TOptional; input: Type.TOptional; nodes: Type.TArray>; }>; Node: Type.TUnion<[Type.TRef<"Leaf">, Type.TObject<{ kind: Type.TLiteral<"map">; name: Type.TString; purpose: Type.TString; sources: Type.TArray; }>, Type.TObject<{ kind: Type.TLiteral<"loop">; name: Type.TString; purpose: Type.TString; mode: Type.TUnion<[Type.TLiteral<"dowhile">, Type.TLiteral<"dountil">]>; maxIterations: Type.TInteger; body: Type.TRef<"Body">; }>, Type.TObject<{ kind: Type.TLiteral<"foreach">; name: Type.TString; purpose: Type.TString; concurrency: Type.TOptional; feedback: Type.TOptional; body: Type.TRef<"Body">; }>, Type.TObject<{ kind: Type.TLiteral<"parallel">; name: Type.TString; purpose: Type.TString; arms: Type.TArray>; }>, Type.TObject<{ kind: Type.TLiteral<"branch">; name: Type.TString; purpose: Type.TString; arms: Type.TArray; }>>; }>, Type.TObject<{ kind: Type.TLiteral<"workflow">; name: Type.TString; purpose: Type.TString; body: Type.TRef<"Body">; }>]>; }, "Node">>; }>; export type WorkflowBlueprintOutput = Static; /** Select only the generated TSDoc/signature entries needed by this blueprint. */ export declare function renderAuthoringGuide(blueprint: WorkflowBlueprint): string; /** Render a complete, loadable starter module. The model replaces only explicit TODO implementations. */ export declare function renderWorkflowScaffold(blueprint: WorkflowBlueprint): string; /** Reject unfinished or structurally divergent generated source before it is written. */ export declare function describeSourceConformance(blueprint: WorkflowBlueprint, source: string, workflow: WorkflowDefinition): string | undefined; /** The schema type is exported for focused drift tests without coupling them to the creation workflow. */ export declare const authoringSchemas: Readonly<{ workflowBlueprint: TSchema; }>; export {}; //# sourceMappingURL=workflow-authoring.d.ts.map