/** * ForgeResponse envelope builder — Sprint 2 . * * Wraps any tool/command result in the standard JSON envelope consumed by: * - MCP tool handlers (every tool in src/mcp/tools.ts — the pinned canonical * set is asserted by tool-drift.test.ts) * - CLI commands running with --output json * * Idempotency token algorithm: * SHA-256(command + JSON.stringify(sorted_params) + floor(Date.now() / 300_000)) * → same token for identical calls within a 5-minute window. * * Design constraints: * - No external dependencies (only Node built-in `crypto`) * - Import-safe from both ESM MCP server and CLI binary * - next_actions are generated by context-aware heuristics when not * provided explicitly; callers may always override with their own list. */ import type { ForgeResponse, NextAction } from "./types.js"; /** * Compute a 16-character hex idempotency token for the given call signature. * Identical calls within the same 5-minute window produce the same token. * * Truncated to 16 chars (64 bits) for readability; collision risk is negligible * for the deduplication use-case. */ export declare function computeIdempotencyToken(command: string, params: Record): string; export interface BuildEnvelopeOptions { /** Tool or CLI command name (e.g. "forge_check_gates", "forge gate status"). */ command: string; /** Input parameters used for idempotency token computation. */ params: Record; /** The raw response data from the engine or local logic. */ data: T; /** Explicit next_actions. If omitted, inferred from data heuristics. */ next_actions?: NextAction[]; /** Wall-clock time the operation started (to compute duration_ms). */ startedAt: number; /** Override status. Defaults to "ok". */ status?: "ok" | "error" | "blocked"; } /** * Build a ForgeResponse envelope. * * Callers should capture `Date.now()` before the async operation and pass it * as `startedAt` so `duration_ms` accurately reflects end-to-end latency. */ export declare function buildEnvelope(opts: BuildEnvelopeOptions): ForgeResponse; /** * Build an error envelope. The data field carries the structured error object. */ export declare function buildErrorEnvelope(command: string, params: Record, errorData: object, next_actions: NextAction[], startedAt: number, status?: "error" | "blocked"): ForgeResponse; //# sourceMappingURL=envelope.d.ts.map