惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
雷峰网
雷峰网
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
B
Blog
Y
Y Combinator Blog
WordPress大学
WordPress大学
Microsoft Azure Blog
Microsoft Azure Blog
小众软件
小众软件
G
Google Developers Blog
云风的 BLOG
云风的 BLOG
罗磊的独立博客
博客园 - 三生石上(FineUI控件)
博客园 - 叶小钗
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
量子位
The Cloudflare Blog
T
The Blog of Author Tim Ferriss
博客园_首页
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
IT之家
IT之家
阮一峰的网络日志
阮一峰的网络日志
L
LangChain Blog
宝玉的分享
宝玉的分享

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix: route mobile exec approvals to reviewer device (#951...
joshavant · 2026-06-21 · via Recent Commits to openclaw:main

File tree

  • extensions/codex/src/app-server

  • packages/gateway-protocol/src/schema

Original file line numberDiff line numberDiff line change

@@ -23,6 +23,10 @@ private struct WatchChatPreview {

2323

var statusText: String?

2424

}

2525
26+

private struct ExecApprovalGatewayEventPayload: Decodable {

27+

var id: String

28+

}

29+
2630

/// Ensures notification requests return promptly even if the system prompt blocks.

2731

private final class NotificationInvokeLatch<T: Sendable>: @unchecked Sendable {

2832

private let lock = NSLock()

@@ -895,26 +899,49 @@ final class NodeAppModel {

895899

for await evt in stream {

896900

if Task.isCancelled { return }

897901

guard let payload = evt.payload else { continue }

898-

switch evt.event {

899-

case "voicewake.changed":

900-

struct Payload: Decodable { var triggers: [String] }

901-

guard let decoded = try? GatewayPayloadDecoding.decode(payload, as: Payload.self) else { continue }

902-

let triggers = VoiceWakePreferences.sanitizeTriggerWords(decoded.triggers)

903-

VoiceWakePreferences.saveTriggerWords(triggers)

904-

case "talk.mode":

905-

struct Payload: Decodable {

906-

var enabled: Bool

907-

var phase: String?

908-

}

909-

guard let decoded = try? GatewayPayloadDecoding.decode(payload, as: Payload.self) else { continue }

910-

self.applyTalkModeSync(enabled: decoded.enabled, phase: decoded.phase)

911-

default:

912-

continue

913-

}

902+

await self.handleOperatorGatewayServerEvent(evt)

914903

}

915904

}

916905

}

917906
907+

private func handleOperatorGatewayServerEvent(_ evt: EventFrame) async {

908+

guard let payload = evt.payload else { return }

909+

switch evt.event {

910+

case "voicewake.changed":

911+

struct Payload: Decodable { var triggers: [String] }

912+

guard let decoded = try? GatewayPayloadDecoding.decode(payload, as: Payload.self) else { return }

913+

let triggers = VoiceWakePreferences.sanitizeTriggerWords(decoded.triggers)

914+

VoiceWakePreferences.saveTriggerWords(triggers)

915+

case "talk.mode":

916+

struct Payload: Decodable {

917+

var enabled: Bool

918+

var phase: String?

919+

}

920+

guard let decoded = try? GatewayPayloadDecoding.decode(payload, as: Payload.self) else { return }

921+

self.applyTalkModeSync(enabled: decoded.enabled, phase: decoded.phase)

922+

case ExecApprovalNotificationBridge.requestedKind:

923+

guard let approvalId = Self.execApprovalEventID(from: payload) else { return }

924+

await self.presentExecApprovalNotificationPrompt(

925+

ExecApprovalNotificationPrompt(approvalId: approvalId))

926+

case ExecApprovalNotificationBridge.resolvedKind:

927+

guard let approvalId = Self.execApprovalEventID(from: payload) else { return }

928+

await self.handleExecApprovalResolvedRemotePush(approvalId: approvalId)

929+

default:

930+

return

931+

}

932+

}

933+
934+

private nonisolated static func execApprovalEventID(from payload: AnyCodable) -> String? {

935+

guard let decoded = try? GatewayPayloadDecoding.decode(

936+

payload,

937+

as: ExecApprovalGatewayEventPayload.self)

938+

else {

939+

return nil

940+

}

941+

let approvalId = decoded.id.trimmingCharacters(in: .whitespacesAndNewlines)

942+

return approvalId.isEmpty ? nil : approvalId

943+

}

944+
918945

private func applyTalkModeSync(enabled: Bool, phase: String?) {

919946

_ = phase

920947

guard self.talkMode.isEnabled != enabled else { return }

@@ -5139,6 +5166,14 @@ extension NodeAppModel {

51395166

isBackgrounded: isBackgrounded)

51405167

}

51415168
5169+

nonisolated static func _test_execApprovalEventID(from payload: AnyCodable) -> String? {

5170+

self.execApprovalEventID(from: payload)

5171+

}

5172+
5173+

func _test_handleOperatorGatewayServerEvent(_ event: EventFrame) async {

5174+

await self.handleOperatorGatewayServerEvent(event)

5175+

}

5176+
51425177

nonisolated static func _test_watchExecApprovalIDsNeedingFetch(

51435178

candidateIDs: [String],

51445179

cachedApprovalIDs: [String]) -> [String]

Original file line numberDiff line numberDiff line change

@@ -1160,6 +1160,35 @@ private final class MockBootstrapNotificationCenter: NotificationCentering, @unc

11601160

isBackgrounded: false))

11611161

}

11621162
1163+

@Test func execApprovalEventIDDecodesGatewayPayload() {

1164+

#expect(NodeAppModel._test_execApprovalEventID(from: AnyCodable(["id": " approval-1 "])) == "approval-1")

1165+

#expect(NodeAppModel._test_execApprovalEventID(from: AnyCodable(["id": " "])) == nil)

1166+

#expect(NodeAppModel._test_execApprovalEventID(from: AnyCodable(["other": "approval-1"])) == nil)

1167+

}

1168+
1169+

@Test @MainActor func operatorGatewayResolvedEventClearsPendingApprovalPrompt() async throws {

1170+

let appModel = NodeAppModel()

1171+

try appModel._test_presentExecApprovalPrompt(

1172+

#require(

1173+

NodeAppModel._test_makeExecApprovalPrompt(

1174+

id: "approval-event-resolved",

1175+

commandText: "echo clear",

1176+

allowedDecisions: ["allow-once", "deny"],

1177+

host: "gateway",

1178+

nodeId: nil,

1179+

agentId: nil,

1180+

expiresAtMs: Int(Date().timeIntervalSince1970 * 1000) + 60000)))

1181+
1182+

await appModel._test_handleOperatorGatewayServerEvent(EventFrame(

1183+

type: "event",

1184+

event: ExecApprovalNotificationBridge.resolvedKind,

1185+

payload: AnyCodable(["id": "approval-event-resolved"]),

1186+

seq: nil,

1187+

stateversion: nil))

1188+
1189+

#expect(appModel._test_pendingExecApprovalPrompt() == nil)

1190+

}

1191+
11631192

@Test func watchExecApprovalHydrateFetchesOnlyMissingIDs() {

11641193

let idsToFetch = NodeAppModel._test_watchExecApprovalIDsNeedingFetch(

11651194

candidateIDs: ["cached", "pending", "cached", "other", "", " pending "],

Original file line numberDiff line numberDiff line change

@@ -961,6 +961,26 @@ describe("Codex app-server dynamic tool build", () => {

961961

});

962962

});

963963
964+

it("passes the approval reviewer device into Codex dynamic tools", async () => {

965+

const sessionFile = path.join(tempDir, "session.jsonl");

966+

const workspaceDir = path.join(tempDir, "workspace");

967+

const params = createParams(sessionFile, workspaceDir);

968+

params.disableTools = false;

969+

params.approvalReviewerDeviceId = "device-ios-reviewer";

970+

params.runtimePlan = createCodexRuntimePlanFixture();

971+

const factoryOptions: unknown[] = [];

972+

setOpenClawCodingToolsFactoryForTests((options) => {

973+

factoryOptions.push(options);

974+

return [];

975+

});

976+
977+

await buildDynamicToolsForTest(params, workspaceDir, { sandbox: null as never });

978+
979+

expect(factoryOptions[0]).toMatchObject({

980+

approvalReviewerDeviceId: "device-ios-reviewer",

981+

});

982+

});

983+
964984

it("forwards tool outcome ordering into Codex dynamic tools", async () => {

965985

const sessionFile = path.join(tempDir, "session.jsonl");

966986

const workspaceDir = path.join(tempDir, "workspace");

Original file line numberDiff line numberDiff line change

@@ -19,10 +19,7 @@ import {

1919

} from "openclaw/plugin-sdk/agent-harness-runtime";

2020

import { resolveAgentDir } from "openclaw/plugin-sdk/agent-runtime";

2121

import { isToolAllowed } from "openclaw/plugin-sdk/sandbox";

22-

import {

23-

readCodexPluginConfig,

24-

type CodexPluginConfig,

25-

} from "./config.js";

22+

import { readCodexPluginConfig, type CodexPluginConfig } from "./config.js";

2623

import {

2724

filterCodexDynamicTools,

2825

isForcedPrivateQaCodexRuntime,

@@ -260,6 +257,7 @@ export async function buildDynamicTools(input: DynamicToolBuildParams) {

260257

...sessionKeys,

261258

sessionId: params.sessionId,

262259

runId: params.runId,

260+

approvalReviewerDeviceId: params.approvalReviewerDeviceId,

263261

agentDir,

264262

cwd: input.effectiveCwd ?? input.effectiveWorkspace,

265263

workspaceDir: input.effectiveWorkspace,

@@ -593,9 +591,10 @@ export function resolveCodexAppServerExecutionCwd(params: {

593591

nativeToolSurfaceEnabled: boolean;

594592

remoteWorkspaceRoot?: string;

595593

}): string {

596-

const cwd = params.environment && params.nativeToolSurfaceEnabled

597-

? params.environment.cwd

598-

: params.effectiveCwd;

594+

const cwd =

595+

params.environment && params.nativeToolSurfaceEnabled

596+

? params.environment.cwd

597+

: params.effectiveCwd;

599598

return mapCodexAppServerRemoteWorkspacePath({

600599

value: cwd,

601600

localWorkspaceRoot: params.localWorkspaceRoot,

Original file line numberDiff line numberDiff line change

@@ -182,6 +182,12 @@ export const ExecApprovalRequestParamsSchema = Type.Object(

182182

turnSourceTo: Type.Optional(Type.Union([Type.String(), Type.Null()])),

183183

turnSourceAccountId: Type.Optional(Type.Union([Type.String(), Type.Null()])),

184184

turnSourceThreadId: Type.Optional(Type.Union([Type.String(), Type.Number(), Type.Null()])),

185+

approvalReviewerDeviceIds: Type.Optional(

186+

Type.Array(NonEmptyString, {

187+

description:

188+

"Trusted approval-runtime metadata naming operator devices that may review this approval; ordinary Gateway clients may send the field, but the Gateway only binds it for internal approval-runtime requests.",

189+

}),

190+

),

185191

requireDeliveryRoute: Type.Optional(Type.Boolean()),

186192

suppressDelivery: Type.Optional(Type.Boolean()),

187193

timeoutMs: Type.Optional(Type.Integer({ minimum: 1 })),

Original file line numberDiff line numberDiff line change

@@ -452,6 +452,8 @@ export function createOpenClawCodingTools(options?: {

452452

oneShotCliRun?: boolean;

453453

/** Stable run identifier for this agent invocation. */

454454

runId?: string;

455+

/** Device-scoped operator session allowed to review approvals initiated by this run. */

456+

approvalReviewerDeviceId?: string;

455457

/** Diagnostic trace context for hook/log correlation during this run. */

456458

trace?: DiagnosticTraceContext;

457459

/** What initiated this run (for trigger-specific tool restrictions). */

@@ -869,6 +871,7 @@ export function createOpenClawCodingTools(options?: {

869871

currentChannelId: options?.currentChannelId,

870872

currentThreadTs: options?.currentThreadTs,

871873

accountId: options?.agentAccountId,

874+

approvalReviewerDeviceId: options?.approvalReviewerDeviceId,

872875

backgroundMs: options?.exec?.backgroundMs ?? execConfig.backgroundMs,

873876

timeoutSec: options?.exec?.timeoutSec ?? execConfig.timeoutSec,

874877

approvalRunningNoticeMs:

Original file line numberDiff line numberDiff line change

@@ -58,6 +58,7 @@ function restoreProcessPlatformForTest(): void {

5858

}

5959
6060

type ApprovalRequestPayload = {

61+

approvalReviewerDeviceIds?: string[];

6162

commandSpans?: Array<{ startIndex: number; endIndex: number }>;

6263

};

6364

@@ -159,6 +160,23 @@ describe("exec approval requests", () => {

159160

]);

160161

});

161162
163+

it("passes approval reviewer devices into host approval registration payloads", async () => {

164+

vi.mocked(callGatewayTool).mockResolvedValue({ id: "approval-id", expiresAtMs: 1234 });

165+
166+

await registerExecApprovalRequestForHost({

167+

approvalId: "approval-id",

168+

command: "echo hi",

169+

approvalReviewerDeviceIds: ["device-ios-reviewer"],

170+

workdir: "/tmp/project",

171+

host: "node",

172+

security: "allowlist",

173+

ask: "always",

174+

});

175+
176+

const payload = requireApprovalRequestPayload(0);

177+

expect(payload?.approvalReviewerDeviceIds).toEqual(["device-ios-reviewer"]);

178+

});

179+
162180

it("does not generate command spans by default", async () => {

163181

vi.mocked(callGatewayTool).mockResolvedValue({ id: "approval-id", expiresAtMs: 1234 });

164182
Original file line numberDiff line numberDiff line change

@@ -64,6 +64,7 @@ type RequestExecApprovalDecisionParams = {

6464

turnSourceTo?: string;

6565

turnSourceAccountId?: string;

6666

turnSourceThreadId?: string | number;

67+

approvalReviewerDeviceIds?: string[];

6768

requireDeliveryRoute?: boolean;

6869

suppressDelivery?: boolean;

6970

};

@@ -99,6 +100,7 @@ function buildExecApprovalRequestToolParams(

99100

turnSourceTo: params.turnSourceTo,

100101

turnSourceAccountId: params.turnSourceAccountId,

101102

turnSourceThreadId: params.turnSourceThreadId,

103+

approvalReviewerDeviceIds: params.approvalReviewerDeviceIds,

102104

requireDeliveryRoute: params.requireDeliveryRoute,

103105

suppressDelivery: params.suppressDelivery,

104106

timeoutMs: DEFAULT_APPROVAL_TIMEOUT_MS,

@@ -205,6 +207,7 @@ type HostExecApprovalParams = {

205207

turnSourceTo?: string;

206208

turnSourceAccountId?: string;

207209

turnSourceThreadId?: string | number;

210+

approvalReviewerDeviceIds?: string[];

208211

requireDeliveryRoute?: boolean;

209212

suppressDelivery?: boolean;

210213

};

@@ -313,6 +316,7 @@ async function buildHostApprovalDecisionParams(

313316

resolvedPath: params.resolvedPath,

314317

requireDeliveryRoute: params.requireDeliveryRoute,

315318

suppressDelivery: params.suppressDelivery,

319+

approvalReviewerDeviceIds: params.approvalReviewerDeviceIds,

316320

...buildExecApprovalTurnSourceContext(params),

317321

};

318322

}

Original file line numberDiff line numberDiff line change

@@ -95,6 +95,7 @@ type ProcessGatewayAllowlistParams = {

9595

/** Session-store template, so the direct/denied followup can detect a rebind. */

9696

sessionStore?: string;

9797

bashElevated?: ExecElevatedDefaults;

98+

approvalReviewerDeviceId?: string;

9899

turnSourceChannel?: string;

99100

turnSourceTo?: string;

100101

turnSourceAccountId?: string;

@@ -695,6 +696,9 @@ export async function processGatewayAllowlist(

695696

agentId: params.agentId,

696697

sessionKey: params.sessionKey,

697698

}),

699+

approvalReviewerDeviceIds: params.approvalReviewerDeviceId

700+

? [params.approvalReviewerDeviceId]

701+

: undefined,

698702

resolvedPath: resolveApprovalAuditTrustPath(

699703

allowlistEval.segments[0]?.resolution ?? null,

700704

params.workdir,

Original file line numberDiff line numberDiff line change

@@ -178,6 +178,9 @@ export async function executeNodeHostCommand(

178178

agentId: prepared.agentId,

179179

sessionKey: prepared.sessionKey,

180180

}),

181+

approvalReviewerDeviceIds: params.approvalReviewerDeviceId

182+

? [params.approvalReviewerDeviceId]

183+

: undefined,

181184

...(options.requireDeliveryRoute !== undefined

182185

? { requireDeliveryRoute: options.requireDeliveryRoute }

183186

: {}),