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

推荐订阅源

Y
Y Combinator Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园_首页
量子位
V
Visual Studio Blog
博客园 - Franky
宝玉的分享
宝玉的分享
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 【当耐特】
罗磊的独立博客
小众软件
小众软件
V
V2EX
GbyAI
GbyAI
B
Blog RSS Feed
博客园 - 三生石上(FineUI控件)
大猫的无限游戏
大猫的无限游戏
有赞技术团队
有赞技术团队
月光博客
月光博客
Recent Announcements
Recent Announcements
雷峰网
雷峰网
F
Fortinet All Blogs
M
MIT News - Artificial intelligence

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 resolve param parsing · openclaw...
vincentkoc · 2026-05-30 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -1,4 +1,9 @@

1-

import { ErrorCodes, errorShape } from "../../../packages/gateway-protocol/src/index.js";

1+

import {

2+

ErrorCodes,

3+

errorShape,

4+

formatValidationErrors,

5+

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

6+

import type { ValidationError } from "../../../packages/gateway-protocol/src/index.js";

27

import { hasApprovalTurnSourceRoute } from "../../infra/approval-turn-source.js";

38

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

49

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

@@ -51,6 +56,17 @@ type PendingApprovalListEntry<TPayload> = {

5156

expiresAtMs: number;

5257

};

5358
59+

type ApprovalResolveParams = {

60+

id: string;

61+

decision: string;

62+

};

63+
64+

type ApprovalResolveParamsValidator<TParams extends ApprovalResolveParams> = ((

65+

params: unknown,

66+

) => params is TParams) & {

67+

errors?: ValidationError[] | null;

68+

};

69+
5470

function isPromiseLike<T>(value: T | Promise<T>): value is Promise<T> {

5571

return typeof value === "object" && value !== null && "then" in value;

5672

}

@@ -180,6 +196,34 @@ export function buildRequestedApprovalEvent<TPayload extends ApprovalTurnSourceF

180196

};

181197

}

182198
199+

export function resolveApprovalDecisionParams<TParams extends ApprovalResolveParams>(params: {

200+

rawParams: unknown;

201+

validate: ApprovalResolveParamsValidator<TParams>;

202+

methodName: string;

203+

respond: RespondFn;

204+

}): { inputId: string; decision: ExecApprovalDecision } | null {

205+

const rawParams = params.rawParams;

206+

if (!params.validate(rawParams)) {

207+

params.respond(

208+

false,

209+

undefined,

210+

errorShape(

211+

ErrorCodes.INVALID_REQUEST,

212+

`invalid ${params.methodName} params: ${formatValidationErrors(params.validate.errors)}`,

213+

),

214+

);

215+

return null;

216+

}

217+

if (!isApprovalDecision(rawParams.decision)) {

218+

params.respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, "invalid decision"));

219+

return null;

220+

}

221+

return {

222+

inputId: rawParams.id,

223+

decision: rawParams.decision,

224+

};

225+

}

226+
183227

export function resolveApprovalRequestRecipientConnIds<TPayload>(params: {

184228

context: GatewayRequestContext;

185229

record: ExecApprovalRecord<TPayload>;

Original file line numberDiff line numberDiff line change

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

2020

DEFAULT_EXEC_APPROVAL_TIMEOUT_MS,

2121

resolveExecApprovalAllowedDecisions,

2222

resolveExecApprovalRequestAllowedDecisions,

23-

type ExecApprovalDecision,

2423

type ExecApprovalRequest,

2524

type ExecApprovalResolved,

2625

} from "../../infra/exec-approvals.js";

@@ -37,10 +36,10 @@ import {

3736

bindApprovalRequesterMetadata,

3837

buildRequestedApprovalEvent,

3938

handleApprovalResolve,

40-

isApprovalDecision,

4139

isApprovalRecordVisibleToClient,

4240

listVisiblePendingApprovalRequests,

4341

registerPendingApprovalRecord,

42+

resolveApprovalDecisionParams,

4443

respondPendingApprovalLookupError,

4544

resolvePendingApprovalRecord,

4645

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

@@ -416,28 +415,19 @@ export function createExecApprovalHandlers(

416415

});

417416

},

418417

"exec.approval.resolve": async ({ params, respond, client, context }) => {

419-

if (!validateExecApprovalResolveParams(params)) {

420-

respond(

421-

false,

422-

undefined,

423-

errorShape(

424-

ErrorCodes.INVALID_REQUEST,

425-

`invalid exec.approval.resolve params: ${formatValidationErrors(

426-

validateExecApprovalResolveParams.errors,

427-

)}`,

428-

),

429-

);

430-

return;

431-

}

432-

const p = params as { id: string; decision: string };

433-

if (!isApprovalDecision(p.decision)) {

434-

respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, "invalid decision"));

418+

const resolveParams = resolveApprovalDecisionParams({

419+

rawParams: params,

420+

validate: validateExecApprovalResolveParams,

421+

methodName: "exec.approval.resolve",

422+

respond,

423+

});

424+

if (!resolveParams) {

435425

return;

436426

}

437-

const decision: ExecApprovalDecision = p.decision;

427+

const { inputId, decision } = resolveParams;

438428

await handleApprovalResolve({

439429

manager,

440-

inputId: p.id,

430+

inputId,

441431

decision,

442432

respond,

443433

context,

Original file line numberDiff line numberDiff line change

@@ -21,9 +21,9 @@ import {

2121

handleApprovalResolve,

2222

handleApprovalWaitDecision,

2323

handlePendingApprovalRequest,

24-

isApprovalDecision,

2524

listVisiblePendingApprovalRequests,

2625

registerPendingApprovalRecord,

26+

resolveApprovalDecisionParams,

2727

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

2828

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

2929

@@ -147,28 +147,19 @@ export function createPluginApprovalHandlers(

147147

},

148148
149149

"plugin.approval.resolve": async ({ params, respond, client, context }) => {

150-

if (!validatePluginApprovalResolveParams(params)) {

151-

respond(

152-

false,

153-

undefined,

154-

errorShape(

155-

ErrorCodes.INVALID_REQUEST,

156-

`invalid plugin.approval.resolve params: ${formatValidationErrors(

157-

validatePluginApprovalResolveParams.errors,

158-

)}`,

159-

),

160-

);

161-

return;

162-

}

163-

const p = params as { id: string; decision: string };

164-

if (!isApprovalDecision(p.decision)) {

165-

respond(false, undefined, errorShape(ErrorCodes.INVALID_REQUEST, "invalid decision"));

150+

const resolveParams = resolveApprovalDecisionParams({

151+

rawParams: params,

152+

validate: validatePluginApprovalResolveParams,

153+

methodName: "plugin.approval.resolve",

154+

respond,

155+

});

156+

if (!resolveParams) {

166157

return;

167158

}

168-

const decision = p.decision;

159+

const { inputId, decision } = resolveParams;

169160

await handleApprovalResolve({

170161

manager,

171-

inputId: p.id,

162+

inputId,

172163

decision,

173164

respond,

174165

context,