Skip to main content

testbed/src

packages/testbed/src

Purpose

Public exports for launching and supervising connected-agent testbeds.

Public surface

AgentName

TypeAlias

AgentName

Variable

awaitAgentReadyByPolling

Function

createOpenClawAdapter

Function
Creates an OpenClawAdapter. Omitted paths resolve from this package’s installed, versioned openclaw and @moltzap/openclaw-channel dependencies. Callers may override either path for local development.

launchTestbed

Function
Launch a testbed of N agents (sequentially by default; concurrency is opt-in), tearing down all already-started agents if any one fails. Sibling: launchTestbedWithProcessSignals adds SIGINT / SIGTERM handlers so Ctrl-C during startup interrupts cleanly via TestbedStartupInterrupted.

launchTestbedWithProcessSignals

Function
Wraps launchTestbed with OS-signal handlers so user Ctrl-C during startup interrupts cleanly instead of half-launching a testbed. Fails with:
  • TestbedStartupInterrupted — a signal arrives during testbed startup

LogSlice

Interface

NanoclawAdapter

Class
Nanoclaw runtime adapter. Runs agent subprocesses inside Docker containers via the OneCLI gateway. Two-phase startup: ensure the runtime cache is installed, then launch. Inbound marker: New messages. The immutable cache key covers the pinned NanoClaw source, dependency lock, bundled channel/skill, and host ABI.

NanoclawAdapterOptions

Interface

OpenClawAdapter

Class
OpenClaw runtime adapter. Spawns the OpenClaw gateway as a child process, configures it with a moltzap channel plugin, and reports readiness via the server-side WS authentication event. Readiness signal: server-side WS authentication event surfaces via deps.server.awaitAgentReady. Inbound traffic log marker: inbound from agent:. Errors flow into the testbed via SpawnFailed (boot) or RuntimeExitedBeforeReady / RuntimeReadyTimedOut (post-spawn, surfaced by processExitLoop).

OpenClawAdapterDeps

Interface

OpenClawAdapterOptions

Interface

ReadyOutcome

TypeAlias

Runtime

Interface
Runtime interface contract for agent subprocess management. Five methods. spawn starts the subprocess. waitUntilReady blocks until the server’s ConnectionManager confirms authentication (or timeout/exit). teardown kills the process group and removes the working directory. getLogs returns accumulated output from a byte offset. getInboundMarker returns a substring that proves an inbound message was received by the runtime’s channel plugin.

RuntimeExitedBeforeReady

Class
Raised by startPendingRuntimeAgent when waitUntilReady returns ProcessExited. The process exited before reaching ready. stderr carries the full accumulated stdout+stderr at exit; exitCode is null only if the process exited via signal. Caller action: inspect stderr; check binary auth config.

RuntimeKind

TypeAlias

RuntimeLaunchFailed

TypeAlias
Union of every failure mode startRuntimeAgent and launchTestbed can produce. Use Effect.catchTags to branch by tag, or Effect.catchAll to handle uniformly. Note: TestbedStartupInterrupted lives in testbed.ts because it only arises in the signal-handling variant and carries the interrupting Signal.

RuntimeReadyTimedOut

Class
Raised by startPendingRuntimeAgent when waitUntilReady returns Timeout. The process did not signal ready within timeoutMs and has been torn down before the failure reaches the caller. Caller action: increase readyTimeoutMs, or enable process-level diagnostics at the adapter boundary.

RuntimeServerHandle

Interface

RuntimeStartOptions

TypeAlias

ServerUrl

TypeAlias

ServerUrl

Variable

SpawnFailed

Class
Raised by Runtime.spawn() in any adapter when the child process cannot be started — exec error, missing binary, port allocation failure, state-dir creation failure. cause carries the underlying Error. Caller action: surface to user. No retry — binary or config is wrong.

SpawnInput

Interface

startRuntimeAgent

Function
Spawn one runtime agent, wait for ready, release the startup cleanup scope and hand a long-lived Runtime back to the caller. Error channel is the union RuntimeLaunchFailed of the three shapes above. Sibling: launchTestbed for multi-agent coordinated startup. Fails with:
  • SpawnFailed — the child process cannot be started (exec error, bad binary, port allocation failure, state-dir error)
  • RuntimeReadyTimedOutwaitUntilReady exceeds readyTimeoutMs
  • RuntimeExitedBeforeReady — the process exits before signaling ready (inspect stderr)

Testbed

Interface

TestbedAgent

Interface

TestbedAgentSpec

Interface

TestbedLaunchOptions

TypeAlias

TestbedProcessSignalOptions

TypeAlias

TestbedStartupInterrupted

Class

WorkspaceFile

Interface

Files

  • await-agent-ready.ts
  • errors.ts
  • nanoclaw-adapter.ts
  • openclaw-adapter.ts
  • runtime.ts
  • testbed.ts