/**
 * Daemon-backed `WorkerSpawnFn` implementation.
 *
 * Forks `worker.js` for a single workflow step, sends the prompt via
 * the `init` IPC, and resolves with the agent's final transcript when
 * the worker emits `final_output` and quiesces.
 *
 * Why not reuse `forkWorker` from `core/worker-pool.ts`: that path is
 * tightly coupled to chat / card / streaming state (DaemonSession,
 * dashboardEventBus, sessionStore writes).  Workflow steps don't have
 * a real chat to bind to — we mint a synthetic chatId / rootMessageId
 * and ignore the worker's chat-side side effects (streaming card POST,
 * screenshot uploads).  The bot's real `larkAppId / larkAppSecret`
 * still flow through so the CLI adapter's environment matches a real
 * spawn.
 *
 * The `WorkerProcessFactory` indirection keeps the module unit-testable:
 * tests inject a scripted process that emits canned IPC frames, real
 * code injects `forkWorkerJs` (defined below).
 */
import type { DaemonSpawnDeps } from './spawn-bot.js';
type WorkerEvent = {
    type: 'ready';
    port: number;
    token: string;
} | {
    type: 'cli_session_id';
    cliSessionId: string;
} | {
    type: 'final_output';
    content: string;
    lastUuid: string;
    turnId: string;
    kind?: 'bridge' | 'local-turn' | 'local-turn-headless';
    userText?: string;
} | {
    type: 'screen_update';
    content: string;
    status: 'working' | 'idle' | 'analyzing';
} | {
    type: 'prompt_ready';
} | {
    type: 'claude_exit';
    code: number | null;
    signal: string | null;
} | {
    type: 'error';
    message: string;
};
export interface WorkerHandle {
    send(msg: unknown): void;
    on(event: 'message', cb: (msg: WorkerEvent) => void): void;
    on(event: 'exit', cb: (code: number | null) => void): void;
    on(event: 'error', cb: (err: Error) => void): void;
    kill(signal?: NodeJS.Signals): void;
    readonly pid?: number;
    readonly stdout?: NodeJS.ReadableStream | null;
    readonly stderr?: NodeJS.ReadableStream | null;
}
export interface WorkerProcessFactory {
    spawn(opts: WorkerSpawnOptions): WorkerHandle;
}
export type WorkerSpawnOptions = {
    workerPath: string;
    cwd: string;
    env: NodeJS.ProcessEnv;
};
/** Default factory: real `node:child_process.fork` against `worker.js`. */
export declare const forkWorkerJsFactory: WorkerProcessFactory;
export type WorkflowDaemonSpawnDeps = {
    /** Real workers need access to bot credentials per step. */
    resolveLarkCredentials(botName: string): {
        larkAppId: string;
        larkAppSecret: string;
    };
    /** Override worker.js path (tests).  Default: `<dist>/worker.js`. */
    workerPath?: string;
    /** Override process factory (tests). */
    factory?: WorkerProcessFactory;
    /**
     * Override how long we wait for the worker's first final_output after
     * init.  Defaults to 5 minutes — long enough for typical agent steps
     * with tool use.  Workflow `node.timeoutMs` overrides on a per-step
     * basis.
     */
    defaultTimeoutMs?: number;
    /**
     * After we receive `final_output` we wait `quiesceMs` before resolving,
     * in case the worker emits additional turns (multi-step agent loops).
     * Tests can shrink this.  Default 800 ms.
     */
    quiesceMs?: number;
    /**
     * Grace period after cancel SIGINT before escalating to SIGKILL.
     * Default 5000 ms — long enough for a CLI to flush its current chunk
     * and exit cleanly, short enough that a stuck worker doesn't keep
     * `cancelWorkflowRunOnDaemon` blocked.  Per-CLI tuning lives in
     * v0.1.4-b's `cancelPolicy` schema; we keep a single constant here.
     */
    cancelGraceMs?: number;
};
export declare function createWorkflowDaemonSpawn(deps: WorkflowDaemonSpawnDeps): DaemonSpawnDeps;
export declare function expandWorkflowWorkingDir(workingDir: string | undefined): string | undefined;
/**
 * Deterministically map any string id to a UUID-v4-shaped hex token.
 *
 * Why: Claude Code CLI ≥ 2.1.146 rejects `--session-id` values that
 * aren't valid UUIDs ("Invalid session ID. Must be a valid UUID."). The
 * workflow runtime mints synthetic ids by concatenating runId /
 * activityId / attemptId (which embed `::` separators), so the raw form
 * fails validation. We keep determinism (same input → same uuid, so the
 * jsonl bridge path & resume both work) by hashing through SHA-256 and
 * rewriting the version + variant nibbles to satisfy the v4 shape.
 */
export declare function syntheticSessionUuid(rawId: string): string;
export {};
//# sourceMappingURL=daemon-spawn.d.ts.map