import { A as RunLog, D as RecordingOptions, E as RecordedRequest, I as Failure, M as Settings, n as Plugin, u as Payload } from "./plugin-DYhXH7JX.mjs"; import { r as TracingPort, t as OwnPortsArgument } from "./ports-5rVV3z3m.mjs"; import "@grpc/grpc-js"; /** How a payload is run. */ interface RunOptions { /** Laid over the payload, field by field however deep: the route's sample, or the payload given. */ with?: Record; /** What answers each platform call; `200 {}` unless given. */ respond?: RecordingOptions["respond"]; /** The run's settings (contract/settings.json), each the one given or its default: the handler gets their platform credentials, `context.credentials`. */ settings?: Partial; /** The project's own ports: `context.ports`. */ ports?: Own; /** Aborted to cancel the run; never unless given. */ signal?: AbortSignal; /** Where the run is traced: `noopTracing` unless given, whatever the settings say. */ tracing?: TracingPort; } /** How a step ended, and how long it took. */ interface RunStep { /** The step's name, its key on the trace. */ key: string; status: "completed" | "failed"; durationMs: number; } /** What came of a run. */ interface RunResult { /** Whether it succeeded: the worker's exit, 0 when it did. */ success: boolean; /** What the handler returned, when it succeeded and returned anything. */ data?: unknown; /** How it failed, when it did. */ failure?: Failure; /** What the worker prints for the answer, as exec prints it. */ stdout: string; /** What reached the platform, in order. */ requests: RecordedRequest[]; /** What was logged, every level, in order. */ logs: RunLog[]; /** How each step ended, in the order they ended. */ steps: RunStep[]; } /** * Answers `request`, a route's name or a payload, with `with` laid over it, as * exec answers the document the agent delivers it in, and says what came of * it; the plugin's own ports required when it needs them. A name of no route * with a sample is refused. */ declare function run(plugin: Plugin, request: string | Payload, ...[given]: OwnPortsArgument, RunOptions & { ports: Own; }>): Promise; /** An event of an Execute, as the agent reads it; an output event the test client forwards from the plugin's own output carries no data. */ interface PluginTestEvent { started?: {}; output?: { stdout: string; stderr: string; /** What the plugin streamed beside its text, as bytes (JSON when it is a document); none for its own output. */ data: Buffer | null; }; result?: { success: boolean; data: Buffer; error: string; error_code: string; exit_code: number; }; } /** Every event of an Execute, and its result, its data parsed as JSON; no result when none came. */ interface ExecuteResponse { events: PluginTestEvent[]; result: { success: boolean; data: unknown; error: string; errorCode: string; exitCode: number; } | null; } /** Told each event of an Execute as it comes. */ type EventCallback = (event: PluginTestEvent) => void; /** How an Execute is sent: the command type (the plugin's first declared unless given) and the action type, the agent's labels. */ interface ExecuteOptions { commandType?: string; actionType?: string; } /** A client of a plugin process, as the agent drives one. */ interface PluginTestClient { /** The command types the plugin declares to the agent. */ readonly commandTypes: string[]; /** Sends `payload` as the agent's Execute, and answers its events and its result once the call ends. */ execute(payload: unknown, options?: ExecuteOptions): Promise; /** As `execute`, each event told to `onEvent` as it comes, the plugin's own output among them. */ executeStreaming(payload: unknown, onEvent: EventCallback, options?: ExecuteOptions): Promise; /** Closes the connection and stops the plugin. */ stop(): void; } /** A plugin process, as a client drives it: its output and how it stops. */ interface SpawnedPlugin { stdout: ReadableStream; stderr: ReadableStream; kill(): void; } /** How a plugin process is started: Bun's spawn, unless a test gives another. */ type Spawn = (command: string[], options: { cwd: string; env: Record; }) => SpawnedPlugin; /** How a plugin process is started. */ interface StartOptions { /** Where it runs; its entry point's folder unless given. */ cwd?: string; /** Laid over this process's environment. */ env?: Record; /** How long it has to print its handshake; HANDSHAKE_TIMEOUT_MS unless given. */ handshakeTimeoutMs?: number; } /** * Starts a plugin's entry point as the agent starts a worker (`environmentOf`) * and answers a client of it once it is ready. The plugin runs with the ports * its entry point passes: a test that wants it local starts the entry point * that passes in-memory ones (`local.ts`). A plugin that prints no handshake * within the agent's bound, or another line first, is killed and refused. */ declare function startPluginProcess(entrypoint: string, options?: StartOptions, spawn?: Spawn): Promise; export { type EventCallback, type ExecuteOptions, type ExecuteResponse, type PluginTestClient, type PluginTestEvent, type RunOptions, type RunResult, type RunStep, type Spawn, type SpawnedPlugin, type StartOptions, run, startPluginProcess }; //# sourceMappingURL=testing.d.mts.map