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

推荐订阅源

S
SegmentFault 最新的问题
爱范儿
爱范儿
博客园 - Franky
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
IT之家
IT之家
有赞技术团队
有赞技术团队
美团技术团队
Last Week in AI
Last Week in AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
The Cloudflare Blog
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Engineering at Meta
Engineering at Meta
T
Tailwind CSS Blog
J
Java Code Geeks
Martin Fowler
Martin Fowler
I
InfoQ
小众软件
小众软件
MongoDB | Blog
MongoDB | 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(gateway): make repeated approval resolves idempotent ...
steipete · 2026-04-28 · via Recent Commits to openclaw:main

@@ -11,8 +11,19 @@ import type { GatewayClient, GatewayRequestContext, RespondFn } from "./types.js

11111212

export const APPROVAL_NOT_FOUND_DETAILS = {

1313

reason: ErrorCodes.APPROVAL_NOT_FOUND,

14+

remediation: "Re-request the action; pending approvals are cleared after expiry or restart.",

1415

} as const;

151617+

const APPROVAL_ALREADY_RESOLVED_DETAILS = {

18+

reason: "APPROVAL_ALREADY_RESOLVED",

19+

} as const;

20+21+

function resolveRecordedApprovalDecision<TPayload>(

22+

record: ExecApprovalRecord<TPayload>,

23+

): ExecApprovalDecision | undefined {

24+

return record.decision ?? record.consumedDecision;

25+

}

26+1627

type PendingApprovalLookupError =

1728

| "missing"

1829

| {

@@ -97,6 +108,37 @@ export function resolvePendingApprovalRecord<TPayload>(params: {

97108

return { ok: true, approvalId: resolvedId.id, snapshot };

98109

}

99110111+

function resolveResolvedApprovalRecord<TPayload>(params: {

112+

manager: ExecApprovalManager<TPayload>;

113+

inputId: string;

114+

exposeAmbiguousPrefixError?: boolean;

115+

}):

116+

| {

117+

ok: true;

118+

approvalId: string;

119+

snapshot: ExecApprovalRecord<TPayload>;

120+

}

121+

| {

122+

ok: false;

123+

response: PendingApprovalLookupError;

124+

} {

125+

const resolvedId = params.manager.lookupApprovalId(params.inputId, { includeResolved: true });

126+

if (resolvedId.kind !== "exact" && resolvedId.kind !== "prefix") {

127+

return {

128+

ok: false,

129+

response: resolvePendingApprovalLookupError({

130+

resolvedId,

131+

exposeAmbiguousPrefixError: params.exposeAmbiguousPrefixError,

132+

}),

133+

};

134+

}

135+

const snapshot = params.manager.getSnapshot(resolvedId.id);

136+

if (!snapshot || snapshot.resolvedAtMs === undefined) {

137+

return { ok: false, response: "missing" };

138+

}

139+

return { ok: true, approvalId: resolvedId.id, snapshot };

140+

}

141+100142

export function respondPendingApprovalLookupError(params: {

101143

respond: RespondFn;

102144

response: PendingApprovalLookupError;

@@ -259,6 +301,25 @@ export async function handleApprovalResolve<TPayload, TResolvedEvent extends obj

259301

exposeAmbiguousPrefixError: params.exposeAmbiguousPrefixError,

260302

});

261303

if (!resolved.ok) {

304+

const resolvedRepeat = resolveResolvedApprovalRecord({

305+

manager: params.manager,

306+

inputId: params.inputId,

307+

exposeAmbiguousPrefixError: params.exposeAmbiguousPrefixError,

308+

});

309+

if (resolvedRepeat.ok) {

310+

if (resolveRecordedApprovalDecision(resolvedRepeat.snapshot) === params.decision) {

311+

params.respond(true, { ok: true }, undefined);

312+

return;

313+

}

314+

params.respond(

315+

false,

316+

undefined,

317+

errorShape(ErrorCodes.INVALID_REQUEST, "approval already resolved", {

318+

details: APPROVAL_ALREADY_RESOLVED_DETAILS,

319+

}),

320+

);

321+

return;

322+

}

262323

respondPendingApprovalLookupError({ respond: params.respond, response: resolved.response });

263324

return;

264325

}