Skip to content

Commit da40134

Browse files
committed
fix: preserve fallback approval runtime auth
1 parent f366922 commit da40134

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

src/agents/tools/gateway.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,21 @@ describe("gateway tool defaults", () => {
364364
expect(call.deviceIdentity).toEqual(mocks.deviceIdentity);
365365
});
366366

367+
it("keeps the local approval runtime token for remote mode without a remote URL", async () => {
368+
mocks.configState.value = {
369+
gateway: {
370+
mode: "remote",
371+
},
372+
};
373+
mocks.callGateway.mockResolvedValueOnce({ decision: "allow-once" });
374+
375+
await callGatewayTool("exec.approval.waitDecision", {}, { id: "approval-id" });
376+
377+
const call = capturedGatewayCall();
378+
expect(call).not.toHaveProperty("deviceIdentity");
379+
expect(call.approvalRuntimeToken).toEqual(expect.any(String));
380+
});
381+
367382
it("does not send the local approval runtime token to env-selected gateways", async () => {
368383
process.env.OPENCLAW_GATEWAY_URL = "wss://gateway.example";
369384
mocks.callGateway.mockResolvedValueOnce({ decision: "allow-once" });

src/agents/tools/gateway.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,13 @@ function resolveDefaultGatewayTarget(params: {
117117
// so loopback alone must not grant local approval-runtime authority.
118118
return "remote";
119119
}
120-
return params.cfg.gateway?.mode === "remote" ? "remote" : "local";
120+
if (
121+
params.cfg.gateway?.mode === "remote" &&
122+
normalizeOptionalString(params.cfg.gateway.remote?.url)
123+
) {
124+
return "remote";
125+
}
126+
return "local";
121127
}
122128

123129
function validateGatewayUrlOverrideForAgentTools(params: {

0 commit comments

Comments
 (0)