import type { AgencyConfig } from "../../config/config.js"; import type { Policy } from "../../runtime/policy.js"; import { type Problem, type Workflow } from "../../stdlib/workflow/types.js"; import { type WorkflowFile } from "./locate.js"; import type { DriverCall, DriverOutcome } from "./runDriver.js"; import { type ImportPlan } from "./toolImports.js"; import { type TrustedModules } from "../../compiler/trustedModules.js"; export type WorkflowIo = { cwd: string; out: (text: string) => void; err: (text: string) => void; config: AgencyConfig; runDriver: (call: DriverCall) => Promise; /** Asks a yes-or-no question, or null when there is no terminal to ask in. */ confirm: ((question: string) => Promise) | null; }; export type PreparedWorkflow = { found: WorkflowFile; /** The file's `workflow`, after `parseWorkflow`. */ workflow: Workflow; plan: ImportPlan; /** The project's resolved list, for the driver's imports. */ trustedModules: TrustedModules[]; /** How the file is named in messages: its path from the working directory. */ label: string; }; /** Find, read, parse, and plan the imports for a workflow. Prints what is * wrong and returns the exit code instead when a step fails: * 2 for locateWorkflow, 1 for a file that does not parse as JSON, for * parseWorkflow's problems, and for the import plan's problems. */ export declare function prepareWorkflow(target: string, io: WorkflowIo): PreparedWorkflow | { exitCode: number; }; export type DriverResult = { kind: "value"; value: unknown; } | { kind: "problems"; problems: Problem[]; } | { kind: "failed"; message: string; step: string | null; } /** The value was a list of interrupts nothing answered. */ | { kind: "unanswered"; effects: string[]; }; /** What a driver node's outcome means. `{ ok: false }` from runDriver is * `failed`, with its message. */ export declare function readDriverResult(outcome: DriverOutcome): DriverResult; /** The `--json` form every command prints: `{ success: true, value }`, or * `{ success: false, error, step }` with the problems when there are some. * One shape, so a script reads every command the same way. */ export declare function resultJson(result: DriverResult, label: string): string; export declare function workflowCheck(target: string, options: { json?: boolean; }, io: WorkflowIo): Promise; export declare function workflowCompile(target: string, io: WorkflowIo): Promise; export declare function workflowTools(sources: string[], options: { dir?: string; json?: boolean; }, io: WorkflowIo): Promise; export declare function workflowList(dirArg: string | undefined, options: { json?: boolean; }, io: WorkflowIo): Promise; export type RunCommandOptions = { inputs?: string; json?: boolean; }; export type RunCommandSettings = { config: AgencyConfig; /** The person's policy, from --policy, --approve, and --reject. */ person: Policy; budget?: { maxCost?: string; maxTime?: string; }; }; /** Run a saved workflow. Before anything runs, the person sees every effect * their policy does not cover and approves or declines them all at once. * The table, the question, and every message go to `err`, so `out` holds * only the result. */ export declare function workflowRun(target: string, options: RunCommandOptions, settings: RunCommandSettings, io: WorkflowIo): Promise;