/** * Template interpolation for taskflow tasks. * * Supported placeholders: * {args.X} invocation argument * {steps.ID.output} prior phase final output (string) * {steps.ID.json} prior phase output parsed as JSON (stringified back if object) * {previous.output} alias for the immediately-preceding completed phase output * {item} / {item.f} map loop variable (or custom name via phase.as) * * Unknown placeholders are left intact rather than throwing, so a * partially-specified task still runs. The unresolved refs are returned in * `missing[]`; the runtime surfaces them as a phase warning (see * `warnUnresolvedRefs` in runtime.ts) — logged and persisted to * `PhaseState.warnings`. */ export interface InterpolationContext { args: Record; steps: Record; previousOutput?: string; /** loop variable bindings, e.g. { item: {...} } */ locals?: Record; /** Reflexion summary for loop iterations (loop phases with reflexion: true). * Resolved by the bare `{reflexion}` placeholder — a single string, no * sub-path traversal (mirrors {previous.output}). Undefined → the * placeholder stays intact (a missing warning), like any unknown ref. */ reflexion?: string; /** Observed-read hook (M3): invoked once per successfully-resolved * placeholder path, so the runtime can capture which upstream phases a * phase actually consumed (its observed readSet). Unresolved refs do NOT * fire it (they become `missing` warnings instead). Default undefined → * zero overhead, fully backward-compatible. */ onRead?: (ref: string) => void; } export interface InterpolationResult { text: string; missing: string[]; } export declare function interpolate(template: string | null | undefined, ctx: InterpolationContext): InterpolationResult; /** Resolve a structured field without stringifying an exact placeholder. * This lets flow.with preserve typed args and steps.*.json values, while mixed * templates keep the historical string interpolation behavior. */ export declare function interpolateValue(value: unknown, ctx: InterpolationContext): unknown; export declare function safeParse(text: string): unknown; /** * Strict JSON parse for files the USER authored or pointed at (as opposed to * `safeParse`, which is deliberately lenient for LLM/subagent output). * * Unlike `safeParse`, this THROWS on malformed input and preserves the original * `SyntaxError` — V8's message carries the offending byte position and, since * Node 17, a `lineNumber`/`columnNumber` pair. File loaders surface that to * the user so they can fix a stray bare newline (or similar) in seconds * instead of chasing a phantom "file not found". * * When `allowFence` is set (used by `defineFile`, which may point at a markdown * draft wrapping the JSON in a ```json block), a fenced block is tried if the * whole-document parse fails — but the *underlying* parse error is still * thrown if no block parses, so the position is never lost. */ export declare function parseStrict(text: string, opts?: { allowFence?: boolean; }): unknown; /** Coerce a parsed value into an array for map fan-out. */ export declare function coerceArray(value: unknown): unknown[] | null; /** * Evaluate a `when` expression to a boolean. Returns `{ value, error }`. * Parse errors set `error` and fail OPEN (`value: true`) so a broken guard * never silently drops a phase. */ export declare function tryEvaluateCondition(expr: string, ctx: InterpolationContext): { value: boolean; error?: string; }; /** Boolean convenience wrapper over {@link tryEvaluateCondition}. */ export declare function evaluateCondition(expr: string, ctx: InterpolationContext): boolean; //# sourceMappingURL=interpolate.d.ts.map