import { type Group, type HandlerFs } from "../index.js"; import { type DiagnosticLogEvent, type LogLevel } from "../runtime-logging.js"; import { type FetchRoute } from "./fakes.js"; import { type FsChange, type MemoryFs } from "./memory-fs.js"; import { type ParityResult } from "./parity.js"; import { type StreamStatusEvent } from "../stream.js"; import { type CLIOutputFormats } from "../cli.js"; export type PipelineStage = "resolve" | "secrets" | "requirements" | "params" | "confirm" | "handler" | "render"; export type EffectEvent = { seq: number; kind: "fetch"; method: string; url: string; } | { seq: number; kind: "fs"; op: "writeFile" | "rename" | "unlink"; path: string; } | { seq: number; kind: "service"; service: string; method: string; args: unknown[]; } | { seq: number; kind: "env"; key: string; } | { seq: number; kind: "progress"; message: string; } | { seq: number; kind: "confirm"; message: string; approved: boolean; }; export interface ConfirmationRequest { message: string; declineInputPrompt?: string; } export interface HarnessOptions { services?: TServices; env?: Record; secrets?: Record; fs?: Record | HandlerFs; fetch?: typeof globalThis.fetch | FetchRoute[]; confirmations?: "approve" | "decline" | ((request: ConfirmationRequest) => boolean | Promise); apiVersion?: string; logLevel?: LogLevel; } export interface RunResult { ok: boolean; value?: T; error?: unknown; failedAt?: PipelineStage; pending: boolean; logs: DiagnosticLogEvent[]; progress: string[]; confirmations: ConfirmationRequest[]; timeline: EffectEvent[]; fsChanges: FsChange[]; rendered: { rich?: string; markdown?: string; json?: unknown; }; } export interface CommandTestHarness { cli(args: string[], options?: HarnessCLIOptions): Promise; run(path: string[], params?: Record): Promise>; stream(path: string[], params?: Record, options?: { limit?: number; signal?: AbortSignal; }): Promise>; parity(path: string[], params?: Record): Promise; fs: MemoryFs; timeline: EffectEvent[]; } export interface HarnessCLIOptions { formats?: CLIOutputFormats; } export interface HarnessCLIResult { exitCode: number; stdout: string; stderr: string; } export interface StreamRunResult { ok: boolean; events: T[]; statuses: StreamStatusEvent[]; error?: unknown; } type EmptyHarnessServices = Record; export declare function createCommandTestHarness(root: Group, options?: HarnessOptions): CommandTestHarness; export {};