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

推荐订阅源

B
Blog RSS Feed
有赞技术团队
有赞技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
Y
Y Combinator Blog
Jina AI
Jina AI
G
Google Developers Blog
Last Week in AI
Last Week in AI
博客园 - 叶小钗
H
Hackread – Cybersecurity News, Data Breaches, AI and More
L
LangChain Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
Visual Studio Blog
aimingoo的专栏
aimingoo的专栏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
J
Java Code Geeks
Stack Overflow Blog
Stack Overflow Blog
IT之家
IT之家
The GitHub Blog
The GitHub Blog
D
Docker
量子位
罗磊的独立博客
腾讯CDC

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
refactor: share approval request registration · openclaw/...
vincentkoc · 2026-05-30 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -141,6 +141,45 @@ export function listVisiblePendingApprovalRequests<TPayload>(params: {

141141

}));

142142

}

143143
144+

export function bindApprovalRequesterMetadata<TPayload>(params: {

145+

record: ExecApprovalRecord<TPayload>;

146+

client?: GatewayClient | null;

147+

}): void {

148+

params.record.requestedByConnId = params.client?.connId ?? null;

149+

params.record.requestedByDeviceId = params.client?.connect?.device?.id ?? null;

150+

params.record.requestedByClientId = params.client?.connect?.client?.id ?? null;

151+

params.record.requestedByDeviceTokenAuth = params.client?.isDeviceTokenAuth === true;

152+

}

153+
154+

export function registerPendingApprovalRecord<TPayload>(params: {

155+

manager: ExecApprovalManager<TPayload>;

156+

record: ExecApprovalRecord<TPayload>;

157+

timeoutMs: number;

158+

respond: RespondFn;

159+

}): Promise<ExecApprovalDecision | null> | undefined {

160+

try {

161+

return params.manager.register(params.record, params.timeoutMs);

162+

} catch (err) {

163+

params.respond(

164+

false,

165+

undefined,

166+

errorShape(ErrorCodes.INVALID_REQUEST, `registration failed: ${String(err)}`),

167+

);

168+

return undefined;

169+

}

170+

}

171+
172+

export function buildRequestedApprovalEvent<TPayload extends ApprovalTurnSourceFields>(

173+

record: ExecApprovalRecord<TPayload>,

174+

): RequestedApprovalEvent<TPayload> {

175+

return {

176+

id: record.id,

177+

request: record.request,

178+

createdAtMs: record.createdAtMs,

179+

expiresAtMs: record.expiresAtMs,

180+

};

181+

}

182+
144183

export function resolveApprovalRequestRecipientConnIds<TPayload>(params: {

145184

context: GatewayRequestContext;

146185

record: ExecApprovalRecord<TPayload>;

Original file line numberDiff line numberDiff line change

@@ -34,10 +34,13 @@ import type { ExecApprovalManager } from "../exec-approval-manager.js";

3434

import {

3535

handleApprovalWaitDecision,

3636

handlePendingApprovalRequest,

37+

bindApprovalRequesterMetadata,

38+

buildRequestedApprovalEvent,

3739

handleApprovalResolve,

3840

isApprovalDecision,

3941

isApprovalRecordVisibleToClient,

4042

listVisiblePendingApprovalRequests,

43+

registerPendingApprovalRecord,

4144

respondPendingApprovalLookupError,

4245

resolvePendingApprovalRecord,

4346

} from "./approval-shared.js";

@@ -323,31 +326,19 @@ export function createExecApprovalHandlers(

323326

turnSourceThreadId: p.turnSourceThreadId ?? null,

324327

};

325328

const record = manager.create(request, timeoutMs, explicitId);

326-

record.requestedByConnId = client?.connId ?? null;

327-

record.requestedByDeviceId = client?.connect?.device?.id ?? null;

328-

record.requestedByClientId = client?.connect?.client?.id ?? null;

329-

record.requestedByDeviceTokenAuth = client?.isDeviceTokenAuth === true;

329+

bindApprovalRequesterMetadata({ record, client });

330330

// Use register() to synchronously add to pending map before sending any response.

331331

// This ensures the approval ID is valid immediately after the "accepted" response.

332-

let decisionPromise: Promise<

333-

import("../../infra/exec-approvals.js").ExecApprovalDecision | null

334-

>;

335-

try {

336-

decisionPromise = manager.register(record, timeoutMs);

337-

} catch (err) {

338-

respond(

339-

false,

340-

undefined,

341-

errorShape(ErrorCodes.INVALID_REQUEST, `registration failed: ${String(err)}`),

342-

);

332+

const decisionPromise = registerPendingApprovalRecord({

333+

manager,

334+

record,

335+

timeoutMs,

336+

respond,

337+

});

338+

if (!decisionPromise) {

343339

return;

344340

}

345-

const requestEvent: ExecApprovalRequest = {

346-

id: record.id,

347-

request: record.request,

348-

createdAtMs: record.createdAtMs,

349-

expiresAtMs: record.expiresAtMs,

350-

};

341+

const requestEvent: ExecApprovalRequest = buildRequestedApprovalEvent(record);

351342

await handlePendingApprovalRequest({

352343

manager,

353344

record,

Original file line numberDiff line numberDiff line change

@@ -7,7 +7,6 @@ import {

77

validatePluginApprovalResolveParams,

88

} from "../../../packages/gateway-protocol/src/index.js";

99

import type { ExecApprovalForwarder } from "../../infra/exec-approval-forwarder.js";

10-

import type { ExecApprovalDecision } from "../../infra/exec-approvals.js";

1110

import type { PluginApprovalRequestPayload } from "../../infra/plugin-approvals.js";

1211

import {

1312

DEFAULT_PLUGIN_APPROVAL_TIMEOUT_MS,

@@ -17,11 +16,14 @@ import {

1716

import { normalizeOptionalString } from "../../shared/string-coerce.js";

1817

import type { ExecApprovalManager } from "../exec-approval-manager.js";

1918

import {

19+

bindApprovalRequesterMetadata,

20+

buildRequestedApprovalEvent,

2021

handleApprovalResolve,

2122

handleApprovalWaitDecision,

2223

handlePendingApprovalRequest,

2324

isApprovalDecision,

2425

listVisiblePendingApprovalRequests,

26+

registerPendingApprovalRecord,

2527

} from "./approval-shared.js";

2628

import type { GatewayRequestHandlers } from "./types.js";

2729

@@ -98,29 +100,19 @@ export function createPluginApprovalHandlers(

98100

// Always server-generate the ID — never accept plugin-provided IDs.

99101

// Kind-prefix so /approve routing can distinguish plugin vs exec IDs deterministically.

100102

const record = manager.create(request, timeoutMs, `plugin:${randomUUID()}`);

101-

record.requestedByConnId = client?.connId ?? null;

102-

record.requestedByDeviceId = client?.connect?.device?.id ?? null;

103-

record.requestedByClientId = client?.connect?.client?.id ?? null;

104-

record.requestedByDeviceTokenAuth = client?.isDeviceTokenAuth === true;

103+

bindApprovalRequesterMetadata({ record, client });

105104
106-

let decisionPromise: Promise<ExecApprovalDecision | null>;

107-

try {

108-

decisionPromise = manager.register(record, timeoutMs);

109-

} catch (err) {

110-

respond(

111-

false,

112-

undefined,

113-

errorShape(ErrorCodes.INVALID_REQUEST, `registration failed: ${String(err)}`),

114-

);

105+

const decisionPromise = registerPendingApprovalRecord({

106+

manager,

107+

record,

108+

timeoutMs,

109+

respond,

110+

});

111+

if (!decisionPromise) {

115112

return;

116113

}

117114
118-

const requestEvent = {

119-

id: record.id,

120-

request: record.request,

121-

createdAtMs: record.createdAtMs,

122-

expiresAtMs: record.expiresAtMs,

123-

};

115+

const requestEvent = buildRequestedApprovalEvent(record);

124116
125117

await handlePendingApprovalRequest({

126118

manager,