/**
 * Step resolver — dependency ordering and template variable resolution.
 *
 * Pure functions: steps + context in → ordered execution plan out.
 * No I/O, no side effects, no Neo4j.
 *
 *   STEPS (unordered)
 *     │
 *     v
 *   resolveOrder()  ──→  Kahn's algorithm (topological sort)
 *     │                    ├─ cycle detected → CyclicDependencyError
 *     │                    └─ position tiebreak for independent steps
 *     v
 *   ORDERED STEPS
 *     │
 *     v
 *   resolveTemplates()  ──→  {{key.path}} substitution
 *     │                        ├─ JSON parse: object → pass-through, array → {_items}, else {_raw}
 *     │                        └─ unresolved → UnresolvedTemplateError
 *     v
 *   RESOLVED PARAMS
 */
interface StepBase {
    stepId: string;
    dependsOn?: string[];
    onFailure?: "abort" | "skip" | "retry";
    retryLimit?: number;
    outputKey?: string;
    timeout?: number;
    position: number;
    label: string;
}
export interface ToolStepDefinition extends StepBase {
    type: "tool";
    plugin: string;
    tool: string;
    params?: Record<string, unknown>;
}
export interface LlmStepDefinition extends StepBase {
    type: "llm";
    prompt: string;
    model?: string;
    maxTokens?: number;
    /**
     * Behaviour when the LLM call cannot produce a response
     * (pre-flight probe failed OR spawn failed during execution).
     *
     * - `"fail"` (default): apply the step's onFailure policy
     *   (abort / skip / retry). Retries are short-circuited when
     *   pre-flight probe already confirmed the LLM is unavailable.
     * - `"raw"`: emit a degraded output via renderFallbackTemplate()
     *   and mark the StepResult with status `"degraded"`. Requires
     *   outputKey so downstream steps can consume the fallback.
     */
    fallbackMode?: "fail" | "raw";
    /**
     * Optional custom fallback template. Used only when
     * `fallbackMode === "raw"`. Resolved via renderFallbackTemplate()
     * with extra variables `{{_error}}` and `{{_priorOutputs}}`.
     * Defaults to a standard banner + prior-output dump.
     * Max 4 KB.
     */
    fallbackTemplate?: string;
}
export type StepDefinition = ToolStepDefinition | LlmStepDefinition;
/**
 * Topological sort with position-based tiebreaking.
 * Returns steps in execution order. Throws on cycles.
 */
export declare function resolveOrder(steps: StepDefinition[]): StepDefinition[];
/**
 * Parse a step's MCP tool response text into a structured output.
 * If the text is valid JSON: objects are returned directly, arrays are
 * wrapped as { _items: array }. Non-object/array JSON and unparseable
 * text are wrapped as { _raw: text }.
 */
export declare function parseStepOutput(text: string): Record<string, unknown>;
/**
 * Resolve all {{template.variables}} in a params object.
 * Context is a map of outputKey → parsed step output.
 *
 * Throws UnresolvedTemplateError if any variable cannot be resolved.
 */
export declare function resolveTemplates(params: Record<string, unknown>, context: Record<string, Record<string, unknown>>): Record<string, unknown>;
/**
 * Resolve template variables in a single string value.
 * Supports full replacement: "{{a.b}}" → value of a.b
 * Supports interpolation: "Hello {{name}}" → "Hello John"
 */
export declare function resolveStringTemplate(template: string, context: Record<string, Record<string, unknown>>): unknown;
export interface RenderFallbackParams {
    /** Optional custom template. Undefined → use the default template. */
    template: string | undefined;
    /** All prior step outputs available in the execution context. */
    outputContext: Record<string, Record<string, unknown>>;
    /** One-line summary of the probe or spawn error that triggered fallback. */
    error: string;
    /**
     * Keys to exclude from the `{{_priorOutputs}}` dump (typically the
     * seeded inputContext keys from the workflow invocation). These keys
     * may contain credentials or trigger metadata that must not leak into
     * delivered degraded output. Individual references like
     * `{{stepKey.field}}` in a custom template still resolve normally —
     * only the catch-all dump respects this exclusion.
     */
    excludeFromPriorOutputs?: ReadonlySet<string>;
}
/**
 * Render a fallback output string when an LLM step's call cannot succeed.
 *
 * Lenient by design — unresolved `{{ref}}` variables become
 * `<unresolved: ref>` rather than throwing. A fallback that itself throws
 * would defeat the degradation mechanism.
 *
 *   DEFAULT TEMPLATE → banner + {{_error}} + {{_priorOutputs}}
 *   CUSTOM TEMPLATE  → author-supplied string with the same special
 *                      variables plus any {{stepKey.field}} from outputContext
 *
 * This is a dedicated helper, not a `lenient: true` flag on
 * resolveStringTemplate(), because only fallback rendering needs the
 * lenient semantics — normal step execution must still fail loudly on
 * unresolved refs.
 */
export declare function renderFallbackTemplate(params: RenderFallbackParams): string;
export {};
//# sourceMappingURL=step-resolver.d.ts.map