feat(gateway): add SDK environment discovery RPCs#74867
feat(gateway): add SDK environment discovery RPCs#74867BunsDev merged 3 commits intoopenclaw:mainfrom
Conversation
|
Codex review: needs changes before merge. Summary Reproducibility: yes. Source inspection on current main shows SDK list/status still throw unsupported errors, Gateway discovery lacks Real behavior proof Next step before merge Security Review findings
Review detailsBest possible solution: Clean the changelog placement, get maintainer API approval on the initial environment vocabulary/managed-candidate choice, then land the additive read-only contract with provisioning surfaces still unsupported. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection on current main shows SDK list/status still throw unsupported errors, Gateway discovery lacks Is this the best way to solve the issue? Mostly yes, but not merge-ready. The protocol/handler/SDK/scope/docs shape follows the existing Gateway RPC pattern; the duplicate changelog block needs a narrow repair and the API vocabulary should be confirmed by the maintainer owner. Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 7c13004883f6. |
|
Answer to @clawsweeper Thanks for the review. I ran the acceptance criteria locally after the final rebase:
All passed. On the API-shape question: this PR intentionally keeps the first contract narrow and read-only: |
|
@BunsDev the remaining API question from the review is scope/vocabulary: this first slice currently exposes Gateway-local and node-catalog candidates only, with read-only status/capabilities under operator.read; should the initial contract also include an explicit unavailable managed candidate, or should managed stay absent until a real managed source exists? |
ba64381 to
805f21e
Compare
|
Live VPS validation on PR head Checks run:
Results:
Live smoke: Started an isolated PR-head Gateway on the VPS with separate state/config: OPENCLAW_HOME=/home/speedy/openclaw-pr74867-smoke-home \
OPENCLAW_CONFIG_PATH=/home/speedy/openclaw-pr74867-smoke-home/openclaw.json \
OPENCLAW_STATE_DIR=/home/speedy/openclaw-pr74867-smoke-home/state \
OPENCLAW_HIDE_BANNER=1 \
pnpm openclaw gateway --dev --port 19867 --auth none --bind loopback --allow-unconfigured runThe Gateway reached ready on The Gateway log also showed the live RPC response: This verifies |
805f21e to
7d33e3a
Compare
|
For the initial contract, keep managed candidates absent until there is a real managed environment source to enumerate. That keeps Given that scope, #74867 is the right first slice for #74708: it adds the |
…anks @ai-hpc Co-authored-by: ai-hpc <183861985+ai-hpc@users.noreply.github.com> Co-authored-by: BunsDev <68980965+BunsDev@users.noreply.github.com>
Summary
@openclaw/sdkexposedoc.environments.*, butlistandstatusstill failed as unsupported and Gateway advertised no environment discovery RPCs.environments.listandenvironments.statusGateway RPCs, SDK call-through/types,operator.readscope classification, protocol schemas/generated Swift models, docs, changelog, and focused tests.oc.environments.create/deleteremain unsupported, and per-run runtime/environment options still fail before submission.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
N/A. This is the first additive read-only environment discovery contract for the SDK/Gateway surface.
Regression Test Plan (if applicable)
N/A.
User-visible / Behavior Changes
oc.environments.list()andoc.environments.status(environmentId)now return read-only environment summaries withid,type,status, and optionallabel/capabilities.oc.environments.create/deleteremain unsupported.Diagram (if applicable)
Security Impact (required)
Yes/No) YesYes/No) NoYes/No) NoYes/No) NoYes/No) YesYes, explain risk + mitigation: the new RPCs requireoperator.readand expose only environment candidate metadata derived from Gateway-local state and existing node discovery surfaces. They do not create environments, run commands, expose secrets, or change auth behavior.Repro + Verification
Environment
@openclaw/sdkSteps
oc.environments.list()oroc.environments.status("gateway").Expected
Actual
Evidence
Verification run locally after rebase onto
openclaw/main:pnpm protocol:checkpnpm test src/gateway/server-methods/environments.test.ts src/gateway/method-scopes.test.ts packages/sdk/src/index.test.ts src/gateway/protocol/index.test.ts -- --reporter=verbosepnpm lint:corepnpm tsgo:core && pnpm tsgo:core:testpnpm lint:docs && pnpm format:docs:check && pnpm check:changelog-attributionsgit diff --check openclaw/main...HEADHuman Verification (required)
list/statuscall-through, Gateway list/status handlers, unknown environment rejection, protocol validation, method discovery/scope classification, generated Swift models, docs/changelog checks, and unsupported create/delete behavior remains explicit.list()sends{}for the empty params schema, invalid params reject, unknown status id rejects, paired/offline nodes are surfaced via the existing node catalog, and duplicate capabilities are normalized.Review Conversations
Compatibility / Migration
Yes/No) YesYes/No) NoYes/No) NoRisks and Mitigations
Real behavior proof
Behavior or issue addressed: Refs #74708 — App SDK clients had no read-only RPC for discovering Gateway-local + paired-node environments. This patch adds
environments.listandenvironments.statusto the Gateway protocol (with TypeBox schemas, scope mapping, server method registration, SDK client/types exposure, Swift bindings, and docs), so clients can enumerate available environments and inspect a single environment without enabling provisioning surfaces.Real environment tested: macOS Darwin 25.2.0 (arm64), Node 24.15.0 (Homebrew
node@24), local OpenClaw source checkout at/Users/a1111/openclaw/running directly vianode --import tsxagainst the patchedsrc/gateway/server-methods/environments.ts, the new TypeBox validators insrc/gateway/protocol/index.ts, and the production node-catalog/pairing helpers undersrc/infra/. Real paired Mac node and real device-pairing state loaded from~/.openclaw/— no mocks.Exact steps or command run after this patch:
fix/sdk-environments-discovery(HEAD7d33e3a7e8, rebased onto upstreamb8f9137d31).validateEnvironmentsListParams/validateEnvironmentsStatusParamsvalidators with valid and invalid params.listEnvironmentsserver-handler flow live: read real device + node pairings vialistDevicePairing()/listNodePairing(), built the known-node catalog, and mapped each entry through the samesummarizeNodeEnvironmentshape the handler emits to clients.Evidence after fix:
Live terminal capture from the patched source running on my Mac (paired Mac node id and labels are local-real, not synthetic):
The output is the exact
EnvironmentSummary[]shape the newenvironments.listserver handler returns (gateway local first, thennode:<nodeId>entries sourced from the paired/known-node catalog, with deduplicated and sorted capabilities). The validators reject malformed param shapes ({extra:1}for list, missingenvironmentIdfor status) before the handler runs, matchingrespondInvalidParamssemantics.Observed result after fix:
The Gateway exposes two new read-only RPCs whose live request/response behavior matches the protocol contract:
environments.listenumerates agatewaylocal environment plus onenode:<id>entry per paired/connected node with sorted capabilities;environments.statusresolves the same shape for a singleenvironmentIdand returns a typedINVALID_REQUESTerror for unknown ids. Schema validation runs on the wire payload (via TypeBoxvalidateEnvironmentsListParams/validateEnvironmentsStatusParams) and short-circuits handlers withINVALID_PARAMSfor malformed input. SDK client/types and SwiftGatewayModelsbindings are wired so app clients consume the same shapes without provisioning surface access.What was not tested: