import type { SharedArtifactContract } from "../../../scanners/artifacts.js"; import type { ExternalScannerIngestRequest } from "../../../scanners/external-scanner-receiver.js"; import type { McpTransport } from "../../../senpi/types.js"; /** * Minimal OpenClaw request shape asserted by runtime integration tests. * * The real gateway payload includes more fields, but these are the stable * pieces the tests care about when proving prompt/context propagation. */ export interface GatewayInvokeRequest { tool: string; args: { prompt?: string; input?: Record; model?: string; }; /** Request headers as sent by the action-layer client (lowercased keys). */ headers: Record; } /** * Stable options for constructing the shared runtime/gateway harness. * * `stateDir` is explicit so each test controls its own temp lifecycle and can * keep isolation boundaries obvious. The gateway reasoning/action type options * are mostly cosmetic, but keeping them configurable preserves readable logs. */ export interface RuntimeGatewayHarnessOptions { stateDir: string; mcpTransport?: McpTransport; gatewayReasoning?: string; gatewayActionType?: string; } /** * Input for seeding retained scanner context directly into the shared-artifact * store when a test needs pre-existing dependency state. */ export interface SeedRetainedContextOptions { address: string; scannerId: string; contract: SharedArtifactContract; value: Value; updatedAt: number; } /** * Default MCP transport used by runtime integration tests that do not care * about real tool behavior. * * The runtime expects `list_open_positions` to resolve cleanly even when no * positions exist, so the helper returns an empty list there and a generic * success envelope elsewhere. * * `strategy_get_clearinghouse_state` gets a real (empty) clearing-house shape rather than the * generic envelope: the open action reads the book BEFORE it asks for a decision, and an * unreadable response is a fail-closed skip — so a generic envelope here stops a runtime * integration test at the gate with no LLM call and no order, for reasons that have nothing * to do with what it is testing. */ export declare function noopTransport(method: string, _params?: unknown): Promise; /** * Creates a dedicated temporary runtime state directory for one test. * * The caller supplies the prefix so failures remain easy to attribute from temp * paths and filesystem inspection. */ export declare function createRuntimeStateDir(prefix: string): string; /** * Captures OpenClaw gateway requests while returning a deterministic no-op * decision response. * * This helper keeps the real action layer, prompt interpolation, and context * building in play without making network calls or depending on gateway * availability. */ export declare class GatewayCapture { readonly calls: GatewayInvokeRequest[]; private readonly originalGatewayToken; private readonly reasoning; private readonly actionType; private readonly fetchMock; constructor(options?: { reasoning?: string; actionType?: string; }); /** * Installs the fetch stub and a deterministic gateway token expected by the * real action-layer client. */ install(): void; /** * Restores the original fetch global and gateway token after a test. * * Restoring the env var matters because some runtime tests explicitly verify * behavior when the token is absent. */ restore(): void; /** * Waits until the expected number of gateway calls has been captured. * * The runtime routes actions through an async serial consumer, so tests must * poll briefly instead of assuming the request exists immediately after a * scanner run or ingest call resolves. */ waitForCallCount(expectedCount: number): Promise; /** * Asserts that no gateway requests were emitted after a short stabilization * window. * * This guards tests that expect dependency failures or skips to prevent any * downstream LLM routing. */ expectNoCalls(): Promise; } /** * Shared integration harness for runtime tests that need real scanner-module * behavior plus captured action-layer gateway requests. * * The harness centralizes the repetitive bootstrap/teardown logic so scenario * tests can stay focused on their domain-specific setup and assertions. */ export declare class RuntimeGatewayHarness { private readonly options; private runtime; private address; private readonly gateway; private readonly mcpTransport; constructor(options: RuntimeGatewayHarnessOptions); /** Installs the gateway capture so the real action path can run offline. */ installGatewayCapture(): void; /** * Starts the runtime from an inline YAML recipe string and resolves the * strategy address once boot completes. */ start(recipeYaml: string): Promise; /** * Stops the runtime, restores gateway globals, and removes the temporary * state directory. */ dispose(): Promise; /** Runs one configured scanner through the real scanner module. */ runScanner(scannerId: string): Promise; /** Runs one scanner plus its dependency chain through the real scanner module. */ runScannerChain(scannerId: string): Promise; /** Reads retained scanner context for the active runtime strategy. */ readScannerContext(scannerId: string): Promise; /** Queries persisted latest signals for the active runtime strategy. */ querySignals(scannerId: string): Promise; /** Forwards one external ingest request through the real runtime surface. */ ingestExternalScannerData(request: ExternalScannerIngestRequest): Promise; /** * Returns the most recent captured gateway request after waiting for the * action queue to emit it. */ waitForGatewayRequest(): Promise; /** Asserts that the runtime did not emit any gateway requests. */ expectNoGatewayRequests(): Promise; /** * Seeds one retained-context envelope directly into the shared-artifact store. * * This is intentionally test-only: it lets dependency-focused scenarios start * from an already-published context snapshot without forcing an upstream * scanner run first. */ seedRetainedContext(options: SeedRetainedContextOptions): Promise; /** Returns the active strategy address once the runtime has started. */ getAddress(): string; private get scannerModule(); private requireRuntime; private requireAddress; } //# sourceMappingURL=runtime-gateway-harness.d.ts.map