/**
 * Shared workflow trigger — used by the dashboard catalog `POST .../run`
 * route on the daemon side.  Wraps the load/coerce/createRun/drive sequence
 * with injectable deps so the orchestration can be unit-tested without the
 * full daemon process.
 *
 * IM `/workflow run` still goes through `executeWorkflowCommand`; this helper
 * is the dashboard-trigger path that consumes pre-decoded JSON params and
 * fires the workflow loop in the background.
 */
import { type RawParamInput } from './params.js';
import { EventLog } from './events/append.js';
import { type BotResolver } from './run-init.js';
import type { WorkflowDefinition } from './definition.js';
import type { WorkflowRuntimeContext, WorkerSpawnFn } from './runtime.js';
export type TriggerInput = {
    workflowId: string;
    rawParams: Record<string, RawParamInput>;
    chatBinding: {
        chatId: string;
        larkAppId: string;
    };
    initiator: string;
};
export type TriggerDeps = {
    spawnSubagent: WorkerSpawnFn;
    botResolver: BotResolver;
    /** Build the ctx scaffolding (hostExecutors, reconcilers, loadEffectInput). */
    makeRuntimeContext: (log: EventLog, def: WorkflowDefinition, spawnSubagent: WorkerSpawnFn) => WorkflowRuntimeContext;
    /** Daemon side registers the ctx so future cancel/approve can find it. */
    attachRuntime: (runId: string, ctx: WorkflowRuntimeContext) => {
        ready?: Promise<unknown>;
    };
    /** Fire-and-forget loop drive — daemon owns the actual scheduling. */
    driveRun: (runId: string) => void;
    /** Test seam: override the file lookup. */
    loadWorkflowDefinition?: (workflowId: string) => Promise<WorkflowDefinition>;
    /** Test seam: deterministic run id. */
    makeRunId?: (def: WorkflowDefinition) => string;
    /** Test seam: explicit runs dir override. */
    makeEventLog?: (runId: string) => EventLog;
};
export type TriggerSuccess = {
    ok: true;
    runId: string;
    workflowId: string;
    status: string;
    lastSeq: number;
};
export type TriggerFailure = {
    ok: false;
    error: 'unknown_workflow';
    message: string;
} | {
    ok: false;
    error: 'invalid_params';
    message: string;
    issues: Array<{
        path: string[];
        code: string;
        message: string;
    }>;
} | {
    ok: false;
    error: 'load_definition_failed' | 'internal_error';
    message: string;
};
export type TriggerResult = TriggerSuccess | TriggerFailure;
export declare function triggerWorkflowRun(input: TriggerInput, deps: TriggerDeps): Promise<TriggerResult>;
//# sourceMappingURL=trigger-run.d.ts.map