fix(browser): request admin scope for CLI control (#81716) · openclaw/openclaw@10d2f41
joshavant
·
2026-05-14
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -27,6 +27,7 @@ Docs: https://docs.openclaw.ai
|
27 | 27 | - CLI/plugins: keep bare plugin and parent-command help on the lightweight path, avoiding plugin registry discovery before rendering help. |
28 | 28 | - CLI tables: preserve muted/color styling on wrapped continuation lines after multiline cells, keeping `openclaw plugins list` descriptions readable. |
29 | 29 | - Process execution: collapse case-insensitive duplicate child environment keys on Windows so caller-provided overrides such as `PATH` cannot be shadowed by host `Path`. |
| 30 | +- Browser CLI: request the existing `operator.admin` gateway scope explicitly for browser control commands, avoiding unnecessary scope-upgrade approval loops. Fixes #81555. (#81716) Thanks @joshavant. |
30 | 31 | - iOS: restore first-use Contacts, Calendar, and Reminders permission prompts and add Privacy & Access status/actions in Settings. Thanks @BunsDev. |
31 | 32 | - Canvas: return not found for malformed percent-encoded Canvas/A2UI/document asset paths and keep decoded parent traversal blocked before path normalization. |
32 | 33 | - Telegram: allow trusted local Bot API media files whose filenames start with dots instead of falling back to remote download. |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -7,6 +7,10 @@ import type {
|
7 | 7 | OpenClawPluginToolContext, |
8 | 8 | OpenClawPluginToolFactory, |
9 | 9 | } from "openclaw/plugin-sdk/plugin-entry"; |
| 10 | +import { |
| 11 | +BROWSER_REQUEST_GATEWAY_METHOD, |
| 12 | +BROWSER_REQUEST_GATEWAY_SCOPE, |
| 13 | +} from "./src/browser-gateway-contract.js"; |
10 | 14 | import { BrowserToolSchema } from "./src/browser-tool.schema.js"; |
11 | 15 | |
12 | 16 | const BROWSER_CLI_DESCRIPTOR = { |
@@ -107,13 +111,13 @@ export function registerBrowserPlugin(api: OpenClawPluginApi) {
|
107 | 111 | { commands: ["browser"], descriptors: [BROWSER_CLI_DESCRIPTOR] }, |
108 | 112 | ); |
109 | 113 | api.registerGatewayMethod( |
110 | | -"browser.request", |
| 114 | +BROWSER_REQUEST_GATEWAY_METHOD, |
111 | 115 | async (opts) => { |
112 | 116 | const { handleBrowserGatewayRequest } = await import("./register.runtime.js"); |
113 | 117 | return await handleBrowserGatewayRequest(opts); |
114 | 118 | }, |
115 | 119 | { |
116 | | -scope: "operator.admin", |
| 120 | +scope: BROWSER_REQUEST_GATEWAY_SCOPE, |
117 | 121 | }, |
118 | 122 | ); |
119 | 123 | api.registerService(createLazyBrowserPluginService()); |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +export const BROWSER_REQUEST_GATEWAY_METHOD = "browser.request" as const; |
| 2 | +export const BROWSER_REQUEST_GATEWAY_SCOPE = "operator.admin" as const; |
| 3 | +export const BROWSER_REQUEST_GATEWAY_SCOPES = [BROWSER_REQUEST_GATEWAY_SCOPE] as const; |
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import { beforeEach, describe, expect, it, vi } from "vitest"; |
| 2 | +import type { callGatewayFromCli } from "./core-api.js"; |
| 3 | + |
| 4 | +type CallGatewayFromCliArgs = Parameters<typeof callGatewayFromCli>; |
| 5 | + |
| 6 | +const gatewayMocks = vi.hoisted(() => ({ |
| 7 | +callGatewayFromCli: vi.fn(async () => ({ ok: true })), |
| 8 | +})); |
| 9 | + |
| 10 | +vi.mock("./core-api.js", () => ({ |
| 11 | +callGatewayFromCli: gatewayMocks.callGatewayFromCli, |
| 12 | +})); |
| 13 | + |
| 14 | +const { callBrowserRequest } = await import("./browser-cli-shared.js"); |
| 15 | + |
| 16 | +describe("callBrowserRequest", () => { |
| 17 | +beforeEach(() => { |
| 18 | +gatewayMocks.callGatewayFromCli.mockClear(); |
| 19 | +}); |
| 20 | + |
| 21 | +it("requests the browser.request admin scope explicitly", async () => { |
| 22 | +await callBrowserRequest( |
| 23 | +{ json: true }, |
| 24 | +{ method: "GET", path: "/status", query: { profile: "openclaw" } }, |
| 25 | +{ progress: true }, |
| 26 | +); |
| 27 | + |
| 28 | +const call = gatewayMocks.callGatewayFromCli.mock.calls[0] as unknown as |
| 29 | +| CallGatewayFromCliArgs |
| 30 | +| undefined; |
| 31 | +const extra = call?.[3]; |
| 32 | +expect(extra).toEqual({ progress: true, scopes: ["operator.admin"] }); |
| 33 | +}); |
| 34 | +}); |
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime"; |
| 2 | +import { |
| 3 | +BROWSER_REQUEST_GATEWAY_METHOD, |
| 4 | +BROWSER_REQUEST_GATEWAY_SCOPES, |
| 5 | +} from "../browser-gateway-contract.js"; |
2 | 6 | import { callGatewayFromCli, type GatewayRpcOpts } from "./core-api.js"; |
3 | 7 | |
4 | 8 | export type BrowserParentOpts = GatewayRpcOpts & { |
@@ -44,7 +48,7 @@ export async function callBrowserRequest<T>(
|
44 | 48 | : undefined; |
45 | 49 | const timeout = typeof resolvedTimeout === "number" ? String(resolvedTimeout) : opts.timeout; |
46 | 50 | const payload = await callGatewayFromCli( |
47 | | -"browser.request", |
| 51 | +BROWSER_REQUEST_GATEWAY_METHOD, |
48 | 52 | { ...opts, timeout }, |
49 | 53 | { |
50 | 54 | method: params.method, |
@@ -53,7 +57,7 @@ export async function callBrowserRequest<T>(
|
53 | 57 | body: params.body, |
54 | 58 | timeoutMs: resolvedTimeout, |
55 | 59 | }, |
56 | | -{ progress: extra?.progress }, |
| 60 | +{ progress: extra?.progress, scopes: [...BROWSER_REQUEST_GATEWAY_SCOPES] }, |
57 | 61 | ); |
58 | 62 | if (payload === undefined) { |
59 | 63 | throw new Error("Unexpected browser.request response"); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。