import type { SessionConfigOption } from "@automatalabs/acp-agents"; import type { WorkflowDir } from "@automatalabs/workflow-engine"; import type { WorkflowMeta } from "@automatalabs/shared-types"; export type MockAnswerJson = null | boolean | number | string | MockAnswerJson[] | { [key: string]: MockAnswerJson; }; export interface MockAnswerSequence { readonly $sequence: readonly MockAnswerJson[]; } export type MockAnswerRule = MockAnswerJson | MockAnswerSequence; /** Label glob -> one reusable answer or one finite answer sequence. */ export type MockAnswers = Readonly>; export interface ValidateWorkflowOptions { /** The `args` global handed to the script during the dry run. */ args?: unknown; /** A workflow directory view (or dir path(s)) serving saved workflows by name, so * nested `workflow("")` calls resolve during the dry run instead of failing. */ workflows?: string | string[] | WorkflowDir; /** Base cwd for the dry run. Default: a throwaway temp dir (so `isolation: "worktree"` * degrades to a no-op instead of creating real worktrees in a repo). */ cwd?: string; /** false => static parse only, no dry run. Default true. */ dryRun?: boolean; /** Cap on dry-run agent calls (defaults to the engine's own cap). */ maxAgents?: number; /** Dry-run wall-clock limit. Default 30_000 ms. */ timeoutMs?: number; /** Dry-run answers selected by the resolved agent label. */ mockAnswers?: MockAnswers; } export interface ValidatedMockAnswerUse { glob: string; /** Zero-based in the machine report; absent for a reusable single answer. */ sequenceIndex?: number; sequenceLength?: number; } export interface ValidatedMockAnswerRule { glob: string; kind: "single" | "sequence"; /** Reached calls whose labels matched this glob, including calls won by a later glob. */ matchingCalls: number; /** Calls for which this rule won and reserved an answer, including fixture-validation failures. */ consumedCalls: number; sequenceLength?: number; } export interface UnusedMockAnswer { glob: string; /** Zero-based sequence item; absent for a reusable single answer. */ sequenceIndex?: number; reason: "no-match" | "shadowed" | "not-reached"; } export interface ValidatedMockAnswers { /** Captured normalized rule order, which also documents last-match precedence. */ rules: ValidatedMockAnswerRule[]; unused: UnusedMockAnswer[]; } /** One agent() call observed during the dry run, with its backend attribution. */ export interface ValidatedAgentCall { label: string; phase?: string; /** The verbatim model spec the call requested (undefined = the run/session default). */ model?: string; tier?: string; mode?: string; /** The verbatim session config options authored for this call. */ configOptions?: Record; /** Which concrete registry built-in or custom backend the spec routes to (suffixed * " (script-declared)" when it comes from meta.backends). */ backend: string; /** True when the call requested structured output. */ schema: boolean; mockAnswer?: ValidatedMockAnswerUse; } export interface ValidateHarnessOptions { backendId: string; /** The call's verbatim selected model; absent means the harness/session default. */ model?: string; probed: boolean; /** Present when probed=false: the harness's spawn/auth/session error. */ error?: string; options?: SessionConfigOption[]; } export interface ValidatedCheckpoint { prompt: string; kind: string; /** The reply the dry-run mock confirm took (the checkpoint's declared default, else true). */ reply: unknown; } export interface ValidateWorkflowReport { /** True when parse, dry run, and all checks against successfully probed catalogs pass. */ ok: boolean; /** 0 = valid; 1 = parse/static failure; 2 = dry-run or config-option failure. */ exitCode: 0 | 1 | 2; parse: { ok: boolean; error?: string; meta?: WorkflowMeta; }; dryRun?: { ok: boolean; status: string; reason?: string; /** True when the run was cut off by ValidateWorkflowOptions.timeoutMs. */ timedOut: boolean; agentCalls: ValidatedAgentCall[]; checkpoints: ValidatedCheckpoint[]; phasesVisited: string[]; logs: string[]; durationMs: number; /** Fresh, per-run advertised config-option catalogs for every routed backend/model pair. */ harnessOptions?: ValidateHarnessOptions[]; /** The script's return value, composed from fabricated agent results. */ result?: unknown; mockAnswers?: ValidatedMockAnswers; }; warnings: string[]; } /** * Fabricate a value that structurally satisfies a JSON Schema — the dry run's stand-in * for a real agent's structured output. Deterministic and intentionally simple: first * enum/anyOf variant, `true` booleans (so ok-gates terminate), `mock-` strings. */ export declare function fabricateFromSchema(schema: unknown, hint?: string, depth?: number): unknown; /** Tokens the mock runner reports per agent call (the dry-run token accounting). */ export declare const MOCK_TOKENS_PER_AGENT = 1000; /** Maximum advertised model count for client-side ordered thought-domain enumeration. * Larger catalogs stay on exact advertised-value validation so zero-token validation remains bounded. */ export declare const ORDERED_THOUGHT_LEVEL_ENUMERATION_MODEL_LIMIT = 32; type SelectConfigOption = Extract; /** Every leaf {value,label} the select advertises, flattening any advertised optgroups. */ export declare function selectChoicePairs(option: SelectConfigOption): { value: string; label?: string; }[]; /** * Above this many advertised choices, a select's inline enumeration is replaced by a * grouped summary in every RENDERED surface — the human table AND `--json` — so a harness * with a huge model catalog (pi, opencode) cannot flood an agent's context on either flag. * The complete list stays in the in-memory report (validation reads it, SDK embedders get * it) and is reachable only through the explicit `config --models[=]` * path. Small catalogs — claude, codex, and every effort/mode/boolean option — stay under * this bound and render verbatim, unchanged. */ export declare const MAX_INLINE_SELECT_CHOICES = 24; export interface SelectChoiceGroup { group: string; count: number; } export interface SelectChoiceSummary { total: number; groups: SelectChoiceGroup[]; } /** * Group a select's choices for summary display. Prefers the harness-advertised optgroup * labels; absent those, groups by the first "/"-segment of each value. Groups come back * largest-first, ties broken by first appearance. */ export declare function summarizeSelectChoices(option: SelectConfigOption): SelectChoiceSummary; /** A select whose leaf-choice count exceeds the inline bound — rendered as a summary. */ export declare function isOversizedSelect(option: SessionConfigOption): option is SelectConfigOption; /** A select option reshaped for SERIALIZED output (--json): the huge `options` leaf array * is dropped in favor of a compact grouped summary. Every scalar field is preserved. */ export type CollapsedSelectOption = Omit & { truncated: true; choiceSummary: SelectChoiceSummary & { expand: string; }; }; export type RenderedConfigOption = SessionConfigOption | CollapsedSelectOption; export interface RenderedHarnessOptions extends Omit { options?: RenderedConfigOption[]; } /** * Collapse each harness's oversized select options for serialized (`--json`) output — the * only place the full catalog would otherwise reach an agent's context through a machine * flag. Small options and every non-select option pass through untouched. Applied ONLY at * the CLI print boundary; the in-memory report keeps the complete catalog so validation * and programmatic `probeHarnessConfig()` callers are unaffected. */ export declare function collapseHarnessOptionsForOutput(harnesses: readonly ValidateHarnessOptions[] | undefined): RenderedHarnessOptions[] | undefined; /** * Validate a workflow script: parse it, dry-run against a mock AgentRunner, then probe * each routed backend/model pair's advertised config options. Never throws for an invalid script — * read `report.ok` / `report.exitCode`. */ export declare function validateWorkflowScript(script: string, options?: ValidateWorkflowOptions): Promise; /** Render the per-harness advertised config-option tables, one indent level below the * given prefix. Shared verbatim between the validate report and `agentprism-workflows * config` (./config.ts) so the two commands' tables never drift. */ export declare function renderHarnessOptionLines(harnesses: readonly ValidateHarnessOptions[], indent: string): string[]; /** Render a ValidateWorkflowReport as the human-readable CLI output. */ export declare function formatValidateReport(report: ValidateWorkflowReport): string; export {}; //# sourceMappingURL=validate.d.ts.map