/** * assemble-outcome — the host-owned assembler that STAMPS a {@link CommandOutcome} * onto a handler's pure-domain return (launch, north-star §5.5). * * The single load-bearing rule of the Output plane: **the host assembles, the * handler stays pure domain.** A tool handler returns (or hands the host) its * `SignalEnvelope` / `CommandResult` / a bare JSON document / an error message; * THIS module turns that into the one outer currency by deriving `kind`, * `status`, `exitCode`, the structured `errors`, AND stamping the scope-owned * `diagnostics` snapshot. The handler never constructs a `CommandOutcome` (it * cannot — the diagnostics bus is scope-collected). This keeps every tool, * first-party or external, off the privilege of choosing its own error JSON or * success carrier. * * No stdout here — the builders only read the current scope's diagnostics plane. * {@link renderOutcome} (the sibling) is the one place an outcome reaches a stream. */ import { type CliDiagnostic, type CommandOutcome, type SignalEnvelope, type WarningDetail } from '@opensip-cli/contracts'; /** Derive a run outcome's `kind` from the envelope's tool id: `'.run'`. */ export declare function kindFromEnvelope(envelope: SignalEnvelope): string; /** * Derive a result outcome's `kind` from a `CommandResult`'s discriminant * (`result.type`, e.g. `'history'` → `'history'`), falling back to a neutral * `'command.result'` for bare JSON documents that carry no `type`. */ export declare function kindFromResult(value: unknown): string; /** * Wrap a completed run's {@link SignalEnvelope} as a `status:'ok'` outcome — the * envelope rides UNCHANGED under `.envelope` (the byte-identical inner currency; * the break is purely this new outer wrapper). `status` is `'ok'` for any run * that completed: a failing gate is a successful run with a non-zero `exitCode`, * and the gate verdict is read from `.envelope.verdict`, not the outer status. * * `warnings` are non-fatal run notices (e.g. graph's partial-coverage * parse-failure count) stamped onto `CommandOutcome.warnings`; they never * change `status` or `exitCode`. */ export declare function outcomeFromEnvelope(envelope: SignalEnvelope, exitCode: number, warnings?: readonly WarningDetail[]): CommandOutcome; /** * Wrap a `CommandResult` (or a bare JSON document) as `.data`. An `ErrorResult` * (`type:'error'`) becomes a `status:'error'` outcome carrying its own * `exitCode` + a structured `errors` entry; everything else is `status:'ok'` with * the supplied `exitCode`. */ export declare function outcomeFromResult(value: unknown, exitCode: number): CommandOutcome; /** * Build a `status:'error'` outcome from a thrown error — the host's error * stamper. A typed {@link ToolError} maps to its canonical exit code * (`mapToolErrorToExitCode`) and contributes its `code`; an untyped error is a * `RUNTIME_ERROR` (exit 1). The actionable `suggestion` comes from the shared * `getErrorSuggestion` rule table — the same diagnosis the legacy * `handleParseError` surfaced. * * @param kind The outcome kind (e.g. `'bootstrap.error'` for a pre-handler * failure, Phase 3); defaults to `'command.error'`. */ export declare function outcomeFromError(error: unknown, opts?: { readonly kind?: string; }): CommandOutcome; /** * Build a `status:'error'` outcome from an already-resolved message + exit code — * the seam tool handlers use when they have a diagnosed failure (the former * `emitJson({ error })` shape) rather than a thrown error to map. */ export declare function outcomeFromErrorMessage(opts: { readonly message: string; readonly exitCode: number; readonly suggestion?: string; /** Optional machine-readable error category, surfaced as `ErrorDetail.code`. */ readonly code?: string; readonly diagnostic?: CliDiagnostic; readonly kind?: string; }): CommandOutcome; //# sourceMappingURL=assemble-outcome.d.ts.map