/** * pre-action-hook — Commander `preAction` adapter (ADR-0052). * * Business rules live in {@link planPreActionBootstrap} (phases 1–4) and * {@link executePostBailoutBootstrap} (phases 5–9). This module wires those * to Commander's preAction/postAction hooks. */ import { type RunScope } from '@opensip-cli/core'; import { acquireHostRuntimeLease, type RuntimeLeaseLifecycle, type SafeRuntimeLeaseEventBuffer } from '../commands/host-runtime-access.js'; import { planPreActionBootstrap } from './plan-pre-action-bootstrap.js'; import type { CommandActionScopeRunner } from './command-action-scope-runner.js'; import type { PreActionRuntime } from './pre-action-runtime.js'; import type { StartupRuntimeLeaseHandoff } from './startup-runtime-lease.js'; import type { CommandScopeIndex } from '../commands/command-scope-index.js'; import type { Command } from 'commander'; export { resolveOwningTool } from './owning-tool-init.js'; export type { PreActionRuntime } from './pre-action-runtime.js'; /** * Per-program bridge from async pre-action bootstrap into Commander's already * registered action continuation. It owns no readable run state surface: its * only operation binds the staged RunScope for the dynamic extent of one * mounted action and disposes it before that extent ends. */ interface CommandActionScopeController extends CommandActionScopeRunner { readonly stage: (scope: RunScope) => void; } /** * Create one invocation-local scope handoff. This is deliberately a closure * returned to the composition root, never module-global mutable state. */ export declare function createCommandActionScopeRunner(): CommandActionScopeController; export interface PrepareLeasedBootstrapPlanInput { readonly opts: Record; readonly cwd: string; readonly cwdExplicit: boolean; readonly runId: string; readonly commandName: string; readonly commandPath: string; readonly commandScopes: CommandScopeIndex; readonly explicitConfigPath?: string; /** Composite reader held continuously across dynamic startup discovery. */ readonly startupRuntimeLease?: StartupRuntimeLeaseHandoff; readonly startupLeaseEvents?: SafeRuntimeLeaseEventBuffer; } export interface PrepareLeasedBootstrapPlanDeps { readonly plan?: typeof planPreActionBootstrap; readonly acquire?: typeof acquireHostRuntimeLease; } export interface PreparedLeasedBootstrapPlan { readonly plan: ReturnType; readonly runtimeLeaseLifecycle: RuntimeLeaseLifecycle; readonly leaseEvents: SafeRuntimeLeaseEventBuffer; } /** * Discover tentatively, acquire the declared runtime footprint, then replan * authoritatively while the lease is held. Repeated canonical-root churn is * bounded and visible. * * @throws {ConfigurationError} When no declared runtime scope exists for the * mounted command (`CONFIGURATION.COMMAND_SCOPE_UNDECLARED`, via {@link * declaredScopeForCommand}); when the canonical project root changes * repeatedly across all stabilization attempts * (`CONFIGURATION.RUNTIME_CONTEXT_UNSTABLE`); or when planning/lease * acquisition fails and {@link recoveryGuidance} rethrows a * `CONFIGURATION.RECOVERY_REQUIRED` error with resume/reconcile guidance * appended. * @throws {unknown} Rethrows, via {@link recoveryGuidance}, any other error * raised by `deps.plan` or `deps.acquire` unchanged. */ export declare function prepareLeasedBootstrapPlan(input: PrepareLeasedBootstrapPlanInput, deps?: PrepareLeasedBootstrapPlanDeps): Promise; export declare function installPreActionHook(program: Command, version: string, runtime: PreActionRuntime, commandScopes: CommandScopeIndex, startupRuntimeLease?: StartupRuntimeLeaseHandoff, startupLeaseEvents?: SafeRuntimeLeaseEventBuffer): CommandActionScopeRunner; export declare function disposeCurrentScope(): void; //# sourceMappingURL=pre-action-hook.d.ts.map