import { z } from 'zod'; import type { FullToolInfo } from '../tool.js'; import { type ValidationResult, type WorkflowFile, type WorkflowStepDefinition } from './dynamic-types.js'; import type { BaseWorkflowContext, Logger, StepFn, ToolRegistry, WorkflowFn, WorkflowTools } from './workflow.js'; /** * JSON Schema type to Zod type mapping */ type JsonSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null'; /** * JSON Schema enum values - can be string, number, or boolean */ type JsonSchemaEnum = (string | number | boolean)[]; interface JsonSchema { type?: JsonSchemaType | JsonSchemaType[]; enum?: JsonSchemaEnum; properties?: Record; required?: string[]; items?: JsonSchema; additionalProperties?: boolean | JsonSchema; description?: string; [key: string]: unknown; } /** * Convert a JSON Schema to a Zod schema * Supports a subset of JSON SchemaDraft 7 * * This is exported to allow reuse in other parts of the codebase that need to * convert JSON schemas to Zod schemas (e.g., MCP server tool schema conversion). */ export declare function convertJsonSchemaToZod(schema: JsonSchema): z.ZodTypeAny; /** * Tool groups that can be used in step.tools arrays. * - "readonly": File reading operations only * - "readwrite": Full file system access * - "internet": Network operations (fetch, search) * - "all": All available tools (special keyword, not in this map) */ export declare const TOOL_GROUPS: Record; /** * Type for the runWorkflow tool that allows workflows to call other workflows */ export type RunWorkflowTool = { input: { workflowId: string; input?: Record; }; output: unknown; }; export type DynamicWorkflowRegistry = ToolRegistry & { runWorkflow: RunWorkflowTool; }; export type DynamicWorkflowParseResult = { success: true; definition: WorkflowFile; } | { success: false; error: string; }; /** * Validate a workflow file for common issues */ export declare function validateWorkflowFile(definition: WorkflowFile): ValidationResult; export declare function parseDynamicWorkflowDefinition(source: string): DynamicWorkflowParseResult; export type DynamicStepRuntimeContext = { workflowId: string; stepId: string; input: Record; state: Record; tools: WorkflowTools; logger: Logger; step: StepFn; runWorkflow: (workflowId: string, input?: Record) => Promise; toolInfo: Readonly | undefined; agentTools: Record Promise>; }; export type DynamicWorkflowRunnerOptions = { /** * Tool definitions used when a step does not have persisted `code` * and needs to be executed via `agentWorkflow`. */ toolInfo?: Readonly; /** * Model id forwarded to `agentWorkflow` for agent-executed steps. */ model?: string; /** * Maximum round trips for agent-executed steps. */ maxToolRoundTrips?: number; /** * Customize per-step system prompt for agent-executed steps. */ stepSystemPrompt?: (args: { workflowId: string; step: WorkflowStepDefinition; input: Record; state: Record; }) => string; /** * Whether to wrap plain text agent responses in an object { result: ... }. * Defaults to false. */ wrapAgentResultInObject?: boolean; /** * Built-in workflows that can be called by name if not found in the definition. */ builtInWorkflows?: Record>; /** * Allow unsafe code execution in condition expressions. * When false (default), only simple comparisons and property access are allowed. * When true, arbitrary JavaScript code can be executed in conditions. * WARNING: Setting to true with untrusted workflow definitions is a security risk. * @default false */ allowUnsafeCodeExecution?: boolean; }; export declare function createDynamicWorkflow = BaseWorkflowContext>(definition: WorkflowFile | string, options?: DynamicWorkflowRunnerOptions): (workflowId: string, input: Record, context: TContext) => Promise; export {};