Skip to content

Commit 6f7e5f9

Browse files
YuzuruSobviyus
andauthored
fix: add operator.read and operator.write to default CLI scopes (#22582)
Merged via /review-pr -> /prepare-pr -> /merge-pr. Prepared head SHA: 8569fc8 Co-authored-by: YuzuruS <[email protected]> Co-authored-by: obviyus <[email protected]> Reviewed-by: @obviyus
1 parent b77e53d commit 6f7e5f9

9 files changed

Lines changed: 43 additions & 6 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Docs: https://docs.openclaw.ai
5959
- Gateway/Pairing: treat operator.admin pairing tokens as satisfying operator.write requests so legacy devices stop looping through scope-upgrade prompts introduced in 2026.2.19. (#23125, #23006) Thanks @vignesh07.
6060
- Gateway/Pairing: treat `operator.admin` as satisfying other `operator.*` scope checks during device-auth verification so local CLI/TUI sessions stop entering pairing-required loops for pairing/approval-scoped commands. (#22062, #22193, #21191) Thanks @Botaccess, @jhartshorn, and @ctbritt.
6161
- Gateway/Pairing: preserve existing approved token scopes when processing repair pairings that omit `scopes`, preventing empty-scope token regressions on reconnecting clients. (#21906) Thanks @paki81.
62+
- Gateway/Scopes: include `operator.read` and `operator.write` in default operator connect scope bundles across CLI, Control UI, and macOS clients so write-scoped announce/sub-agent follow-up calls no longer hit `pairing required` disconnects on loopback gateways. (#22582) thanks @YuzuruS.
6263
- Plugins/CLI: make `openclaw plugins enable` and plugin install/link flows update allowlists via shared plugin-enable policy so enabled plugins are not left disabled by allowlist mismatch. (#23190) Thanks @downwind7clawd-ctrl.
6364
- Memory/QMD: add optional `memory.qmd.mcporter` search routing so QMD `query/search/vsearch` can run through mcporter keep-alive flows (including multi-collection paths) to reduce cold starts, while keeping searches on agent-scoped QMD state for consistent recall. (#19617) Thanks @nicole-luxe and @vignesh07.
6465
- Chat/UI: strip inline reply/audio directive tags (`[[reply_to_current]]`, `[[reply_to:<id>]]`, `[[audio_as_voice]]`) from displayed chat history, live chat event output, and session preview snippets so control tags no longer leak into user-visible surfaces.

‎apps/macos/Sources/OpenClawMacCLI/ConnectCommand.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct ConnectOptions {
1515
var clientMode: String = "ui"
1616
var displayName: String?
1717
var role: String = "operator"
18-
var scopes: [String] = ["operator.admin", "operator.approvals", "operator.pairing"]
18+
var scopes: [String] = defaultOperatorConnectScopes
1919
var help: Bool = false
2020

2121
static func parse(_ args: [String]) -> ConnectOptions {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
let defaultOperatorConnectScopes: [String] = [
2+
"operator.admin",
3+
"operator.read",
4+
"operator.write",
5+
"operator.approvals",
6+
"operator.pairing",
7+
]

‎apps/macos/Sources/OpenClawMacCLI/WizardCommand.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ actor GatewayWizardClient {
251251
let clientMode = "ui"
252252
let role = "operator"
253253
// Explicit scopes; gateway no longer defaults empty scopes to admin.
254-
let scopes: [String] = ["operator.admin", "operator.approvals", "operator.pairing"]
254+
let scopes = defaultOperatorConnectScopes
255255
let client: [String: ProtoAnyCodable] = [
256256
"id": ProtoAnyCodable(clientId),
257257
"displayName": ProtoAnyCodable(Host.current().localizedName ?? "OpenClaw macOS Wizard CLI"),

‎apps/shared/OpenClawKit/Sources/OpenClawKit/GatewayChannel.swift‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ private enum ConnectChallengeError: Error {
127127
case timeout
128128
}
129129

130+
private let defaultOperatorConnectScopes: [String] = [
131+
"operator.admin",
132+
"operator.read",
133+
"operator.write",
134+
"operator.approvals",
135+
"operator.pairing",
136+
]
137+
130138
public actor GatewayChannelActor {
131139
private let logger = Logger(subsystem: "ai.openclaw", category: "gateway")
132140
private var task: WebSocketTaskBox?
@@ -318,7 +326,7 @@ public actor GatewayChannelActor {
318326
let primaryLocale = Locale.preferredLanguages.first ?? Locale.current.identifier
319327
let options = self.connectOptions ?? GatewayConnectOptions(
320328
role: "operator",
321-
scopes: ["operator.admin", "operator.approvals", "operator.pairing"],
329+
scopes: defaultOperatorConnectScopes,
322330
caps: [],
323331
commands: [],
324332
permissions: [:],

‎src/gateway/call.test.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,13 @@ describe("callGateway url resolution", () => {
206206
{
207207
label: "keeps legacy admin scopes for explicit CLI callers",
208208
call: () => callGatewayCli({ method: "health" }),
209-
expectedScopes: ["operator.admin", "operator.approvals", "operator.pairing"],
209+
expectedScopes: [
210+
"operator.admin",
211+
"operator.read",
212+
"operator.write",
213+
"operator.approvals",
214+
"operator.pairing",
215+
],
210216
},
211217
])("scope selection: $label", async ({ call, expectedScopes }) => {
212218
setLocalLoopbackGatewayConfig();

‎src/gateway/method-scopes.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export type OperatorScope =
1313

1414
export const CLI_DEFAULT_OPERATOR_SCOPES: OperatorScope[] = [
1515
ADMIN_SCOPE,
16+
READ_SCOPE,
17+
WRITE_SCOPE,
1618
APPROVALS_SCOPE,
1719
PAIRING_SCOPE,
1820
];

‎src/gateway/server.auth.e2e.test.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,13 @@ describe("gateway server auth/connect", () => {
873873
const { randomUUID } = await import("node:crypto");
874874
const os = await import("node:os");
875875
const path = await import("node:path");
876-
const scopes = ["operator.admin", "operator.approvals", "operator.pairing"];
876+
const scopes = [
877+
"operator.admin",
878+
"operator.read",
879+
"operator.write",
880+
"operator.approvals",
881+
"operator.pairing",
882+
];
877883
const { device } = await createSignedDevice({
878884
token: "secret",
879885
scopes,

‎ui/src/ui/gateway.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ export type GatewayBrowserClientOptions = {
6161

6262
// 4008 = application-defined code (browser rejects 1008 "Policy Violation")
6363
const CONNECT_FAILED_CLOSE_CODE = 4008;
64+
const DEFAULT_OPERATOR_CONNECT_SCOPES = [
65+
"operator.admin",
66+
"operator.read",
67+
"operator.write",
68+
"operator.approvals",
69+
"operator.pairing",
70+
];
6471

6572
export class GatewayBrowserClient {
6673
private ws: WebSocket | null = null;
@@ -145,7 +152,7 @@ export class GatewayBrowserClient {
145152
// Gateways may reject this unless gateway.controlUi.allowInsecureAuth is enabled.
146153
const isSecureContext = typeof crypto !== "undefined" && !!crypto.subtle;
147154

148-
const scopes = ["operator.admin", "operator.approvals", "operator.pairing"];
155+
const scopes = DEFAULT_OPERATOR_CONNECT_SCOPES;
149156
const role = "operator";
150157
let deviceIdentity: Awaited<ReturnType<typeof loadOrCreateDeviceIdentity>> | null = null;
151158
let canFallbackToShared = false;

0 commit comments

Comments
 (0)