This is the first adapter behind the
RuntimeAdapter seam, and the template the other four runtimes follow. It changes nothing about how OpenClaw runs; it only re-expresses a live Gateway session as the normalized lifecycle stream. The adapter depends on the structural OpenClawGatewayClient shape (not the concrete GatewayClient class), so a test double or the server’s operator-client slice can be passed in.
Public API
All exports come fromsrc/index.ts. The package declares a single . export in package.json (no subpath barrels).
Classes
OpenClawAdapter members:
capabilities(): Capabilities: returns{ streaming: true, mcp: false, worktrees: false, resume: true, toolApproval: true, models: [], runtimeClass: 'connected-substrate', nativeSkills: 'preserve', nativeMemory: 'preserve', nativeChannels: 'gateway', nativeScheduler: true }.nativeHomeis deliberately omitted; the Gateway owns its own state dir. Theconnected-substrateclass is what makes the one-shot executor runner refuse OpenClaw by construction: its runs ride the LIVE Gateway session over this adapter’s long-lived client.health(): Promise<HealthResult>: racesclient.agents.list()against a 2 s timeout; any throw →{ ok: false, message }, else{ ok: true }.start(_task: TaskHandle, opts: StartOpts): Promise<RunHandle>: concatenatesopts.context(if any) aboveopts.message, then calls the raw RPCchat.sendwith{ sessionKey, message, deliver: false, idempotencyKey: crypto.randomUUID() }. TherunIdis not returned here; it late-binds on the first streaming frame insideevents(), so the handle is{ adapterId: 'openclaw', sessionKey, runId: null }. A{ok:true}ack that carriesaccepted: falseor a no-run status (no-active-run/no_active_run/dropped/rejected/no_session) throws “acknowledged but did not start a run” so the caller can release/retry instead of blocking on frames that never come.events(run: RunHandle): AsyncIterable<RuntimeEvent>: subscribes eagerly (on call, not on first pull) toclient.onEvent, filters frames torun.sessionKey, late/re-bindsrun.runIdfrom each frame, accumulates non-reasoningtext-deltatext, and yields the mapped stream via a boundedcreateAsyncQueue(max: 1000). It is a continuous session observer; it yields across multiple runs on the same long-lived session. Consumer termination (return()) unsubscribes.abort(run: RunHandle): Promise<void>: two-tier teardown viaPromise.allSettled: the surgical per-runchat.abort(sessionKey, runId)only when arunIdis bound, PLUS the heaviersessions.abort(sessionKey, runId?)backstop ALWAYS (covers the runId-not-yet-bound race and queued/pending work).setModel(run: RunHandle, model: string): Promise<void>:sessions.patch(sessionKey, { model }).writeContext(run: RunHandle, key: string, value: string): Promise<void>:agents.files.set(agentId, key, value), recoveringagentIdfrom theagent:<agentId>:<session>sessionKey shape.
Functions
Types & interfaces
The
Capabilities, HealthResult, RunHandle, RuntimeAdapter, RuntimeEvent, RuntimeEventBase, StartOpts, and TaskHandle types referenced above are owned by @clawboo/executor; EventFrame, AgentsListResult, and SessionPatchResult come from @clawboo/gateway-client. None are re-exported here.Used by
apps/web/server/lib/runtimes/serverAdapter.ts, whosebuildOpenClawServerAdapterinstantiatesnew OpenClawAdapter(client)over the operator connection; the server-side team orchestrator (serverDeliver) uses it to run an OpenClaw team member’s turn.apps/web/server/lib/teamChat/runTeamExchange.ts, wraps the operator client inOpenClawAdapterto drive a peer-chat turn.apps/web/server/lib/routines/openclawDispatch.ts, importsOpenClawAdapter+OpenClawGatewayClientfor the connected-substrate routine dispatcher (uses the adapter’sstart/events/abortslice;makeAdapteris a test seam).apps/web/server/lib/routines/wakeBridge.ts, probes a scheduled OpenClaw fire vianew OpenClawAdapter(operatorClient).apps/web/server/lib/agentSource/openClawAgentSource.ts, exposes its operator client typed asOpenClawGatewayClient.
Source
packages/adapters/openclaw/src/index.ts (barrel; re-exports ./adapter, ./types, ./mapFrame).
See also
- @clawboo/executor, the
RuntimeAdaptertrait +RuntimeEventunion this adapter implements. - @clawboo/gateway-client, the
GatewayClientwhose structural slice this adapter wraps. - RuntimeAdapter trait, the cross-runtime contract.
- OpenClaw runtime, using the runtime end-to-end.
- Sibling adapters: @clawboo/adapter-claude-code, @clawboo/adapter-codex, @clawboo/adapter-hermes, @clawboo/adapter-native.