/** * dispatch-external-tool-hook — the HOST supervisor for running an EXTERNAL * tool's LIFECYCLE HOOK out-of-process (ADR-0054 M4-F). * * After M4-F the host never executes an external-provenance tool's lifecycle * hooks in-process. Two host-command hooks still need the tool's runtime to * produce data: `collectReportData` (the `report` command + report auto-open) and * `sessionReplay` (`sessions show`). For an external tool the host forks the SAME * `__tool-command-worker` subcommand the command dispatch uses — but in HOOK mode * (the spec sets `hook` instead of `commandName`). The worker imports the * untrusted runtime, runs the named hook against its own re-bootstrapped scope, * and returns the hook's plain-data result in {@link ToolCommandResult.hookResult}. * * The host gets the data WITHOUT executing the external runtime in the kernel * process. A fork failure / throw / timeout is a structured {@link ToolError} — * the host never crashes and never falls back to in-host execution. */ import { type ToolProvenance } from '@opensip-cli/core'; import { type DispatchHostCtx } from './dispatch-replay-result.js'; import type { ToolCommandWorkerSpec } from './tool-command-dispatch-types.js'; export interface DispatchExternalToolHookArgs { /** The external tool's provenance (source must NOT be `'bundled'`). */ readonly provenance: ToolProvenance; /** Which lifecycle hook to run in the worker. */ readonly hook: NonNullable; /** The serializable argument the hook needs (e.g. the stored session row). */ readonly hookArg?: unknown; /** The project cwd the worker bootstraps against (steers discovery + project). */ readonly cwd: string; /** The real host context the supervisor serves host-RPC upcalls through. */ readonly ctx: DispatchHostCtx; /** Override the wall-clock timeout (tests use a short one). */ readonly timeoutMs?: number; /** Override the CLI entry script the supervisor forks (defaults to argv[1]). */ readonly cliScript?: string; } /** * Run one external tool lifecycle hook in a forked worker and return its * plain-data result. A worker fault becomes a structured {@link ToolError} — the * host never crashes; external runtime never falls back to in-host execution. * * @returns The hook's result (`hookResult`) — a `Record` for * `collectReportData`, a `ToolSessionReplay` for `sessionReplay`, or `undefined` * when the worker tool declared no such hook. */ export declare function dispatchExternalToolHook(args: DispatchExternalToolHookArgs): Promise; //# sourceMappingURL=dispatch-external-tool-hook.d.ts.map