UNPKG

@mastra/core

Version:
38 lines 1.8 kB
/** * Storable → Runnable half of the workflow round-trip: rebuild a runnable * `Workflow` from the stored JSON form. References to agents/tools/workflows * are resolved against the live Mastra instance; throws if a reference is * missing — better to surface the failure at load time than at run time. */ import type { Mastra } from '../../mastra/index.js'; import type { SerializedStepFlowEntry } from '../types.js'; import type { JsonSchema, JsonSchemaToZodOptions } from './json-schema-to-zod.js'; /** JSON shape persisted to WorkflowDefinitionsStorage. */ export interface StoredWorkflowGraph { id: string; description?: string; metadata?: Record<string, unknown>; inputSchema: JsonSchema; outputSchema: JsonSchema; stateSchema?: JsonSchema; requestContextSchema?: JsonSchema; graph: SerializedStepFlowEntry[]; } /** * Wrapper so the return value isn't recognized as a thenable by `await`. * `Workflow` carries a `.then(step)` builder method — returning one directly * from an `async` function (or any `await`-ed call) makes the runtime call * that builder method as a Promise resolver and the call hangs forever. * Always destructure: `const { workflow } = await rehydrateWorkflow(...)`. */ export interface RehydratedWorkflow { workflow: any; } /** * Options controlling how `rehydrateWorkflow` handles unsupported JSON Schema * keywords. Forwarded to `jsonSchemaToZod` for every schema on the definition * (top-level + per-step `agent.outputSchema`). See `JsonSchemaToZodOptions`. */ export type RehydrateWorkflowOptions = JsonSchemaToZodOptions; export declare function rehydrateWorkflow(def: StoredWorkflowGraph, mastra: Mastra, opts?: RehydrateWorkflowOptions): Promise<RehydratedWorkflow>; //# sourceMappingURL=rehydrate.d.ts.map