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

推荐订阅源

Hugging Face - Blog
Hugging Face - Blog
云风的 BLOG
云风的 BLOG
大猫的无限游戏
大猫的无限游戏
M
MIT News - Artificial intelligence
L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Recent Announcements
Recent Announcements
IT之家
IT之家
Google DeepMind News
Google DeepMind News
罗磊的独立博客
爱范儿
爱范儿
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
U
Unit 42
MongoDB | Blog
MongoDB | Blog
S
SegmentFault 最新的问题
B
Blog
博客园 - 叶小钗
月光博客
月光博客
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
C
Check Point 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(exec): return approved WebChat gateway exec output in...
clawsweeper · 2026-05-22 · via Recent Commits to openclaw:main

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

1616

requiresExecApproval,

1717

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

1818

import type { SafeBinProfile } from "../infra/exec-safe-bin-policy.js";

19+

import { INTERNAL_MESSAGE_CHANNEL, normalizeMessageChannel } from "../utils/message-channel.js";

1920

import { markBackgrounded, tail } from "./bash-process-registry.js";

2021

import {

2122

buildExecApprovalRequesterContext,

@@ -87,6 +88,7 @@ export type ProcessGatewayAllowlistResult = {

8788

execCommandOverride?: string;

8889

allowWithoutEnforcedCommand?: boolean;

8990

pendingResult?: AgentToolResult<ExecToolDetails>;

91+

deniedResult?: AgentToolResult<ExecToolDetails>;

9092

};

91939294

function hasGatewayAllowlistMiss(params: {

@@ -347,6 +349,36 @@ function buildGatewayExecApprovalFollowupSummary(params: {

347349

: `Exec finished (gateway id=${params.approvalId}, session=${params.sessionId}, ${exitLabel})`;

348350

}

349351352+

function shouldAwaitGatewayApprovalInline(params: {

353+

turnSourceChannel?: string;

354+

approvalFollowupMode?: "agent" | "direct";

355+

}): boolean {

356+

if (params.approvalFollowupMode === "direct") {

357+

return false;

358+

}

359+

return normalizeMessageChannel(params.turnSourceChannel) === INTERNAL_MESSAGE_CHANNEL;

360+

}

361+362+

function buildGatewayExecApprovalDeniedToolResult(params: {

363+

approvalId: string;

364+

deniedReason: string;

365+

command: string;

366+

cwd: string;

367+

}): AgentToolResult<ExecToolDetails> {

368+

const text = `Exec denied (gateway id=${params.approvalId}, ${params.deniedReason}): ${params.command}`;

369+

return {

370+

content: [{ type: "text", text }],

371+

details: {

372+

status: "failed",

373+

exitCode: null,

374+

durationMs: 0,

375+

aggregated: text,

376+

timedOut: params.deniedReason.includes("timeout"),

377+

cwd: params.cwd,

378+

},

379+

};

380+

}

381+350382

async function resolveGatewayExecApprovalFollowupText(params: {

351383

approvalFollowup?: ExecApprovalFollowupFactory;

352384

approvalId: string;

@@ -564,31 +596,14 @@ export async function processGatewayAllowlist(

564596

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

565597

params.workdir,

566598

);

567-

const effectiveTimeout =

568-

typeof params.timeoutSec === "number" ? params.timeoutSec : params.defaultTimeoutSec;

569-

const followupTarget = buildExecApprovalFollowupTarget({

570-

approvalId,

571-

sessionKey: params.notifySessionKey ?? params.sessionKey,

572-

bashElevated: params.bashElevated,

573-

turnSourceChannel: params.turnSourceChannel,

574-

turnSourceTo: params.turnSourceTo,

575-

turnSourceAccountId: params.turnSourceAccountId,

576-

turnSourceThreadId: params.turnSourceThreadId,

577-

direct: params.approvalFollowupMode === "direct",

578-

});

579-580-

void (async () => {

599+

const resolveApprovalForExecution = async (onFailure: () => void) => {

581600

const decision = await resolveApprovalDecisionOrUndefined({

582601

approvalId,

583602

preResolvedDecision,

584-

onFailure: () =>

585-

void sendExecApprovalFollowupResult(

586-

followupTarget,

587-

`Exec denied (gateway id=${approvalId}, approval-request-failed): ${params.command}`,

588-

),

603+

onFailure,

589604

});

590605

if (decision === undefined) {

591-

return;

606+

return { deniedReason: "approval-request-failed", requestFailed: true };

592607

}

593608594609

const {

@@ -647,10 +662,58 @@ export async function processGatewayAllowlist(

647662

deniedReason = deniedReason ?? "allowlist-miss";

648663

}

649664650-

if (deniedReason) {

665+

return { deniedReason, requestFailed: false };

666+

};

667+668+

if (unavailableReason === null && shouldAwaitGatewayApprovalInline(params)) {

669+

const approvalDecision = await resolveApprovalForExecution(() => undefined);

670+

if (approvalDecision.deniedReason) {

671+

return {

672+

deniedResult: buildGatewayExecApprovalDeniedToolResult({

673+

approvalId,

674+

deniedReason: approvalDecision.deniedReason,

675+

command: params.command,

676+

cwd: params.workdir,

677+

}),

678+

};

679+

}

680+681+

recordMatchedAllowlistUse(resolvedPath ?? undefined);

682+

return {

683+

execCommandOverride: enforcedCommand,

684+

allowWithoutEnforcedCommand: enforcedCommand === undefined,

685+

};

686+

}

687+688+

const effectiveTimeout =

689+

typeof params.timeoutSec === "number" ? params.timeoutSec : params.defaultTimeoutSec;

690+

const followupTarget = buildExecApprovalFollowupTarget({

691+

approvalId,

692+

sessionKey: params.notifySessionKey ?? params.sessionKey,

693+

bashElevated: params.bashElevated,

694+

turnSourceChannel: params.turnSourceChannel,

695+

turnSourceTo: params.turnSourceTo,

696+

turnSourceAccountId: params.turnSourceAccountId,

697+

turnSourceThreadId: params.turnSourceThreadId,

698+

direct: params.approvalFollowupMode === "direct",

699+

});

700+701+

void (async () => {

702+

const approvalDecision = await resolveApprovalForExecution(

703+

() =>

704+

void sendExecApprovalFollowupResult(

705+

followupTarget,

706+

`Exec denied (gateway id=${approvalId}, approval-request-failed): ${params.command}`,

707+

),

708+

);

709+

if (approvalDecision.requestFailed) {

710+

return;

711+

}

712+713+

if (approvalDecision.deniedReason) {

651714

await sendExecApprovalFollowupResult(

652715

followupTarget,

653-

`Exec denied (gateway id=${approvalId}, ${deniedReason}): ${params.command}`,

716+

`Exec denied (gateway id=${approvalId}, ${approvalDecision.deniedReason}): ${params.command}`,

654717

);

655718

return;

656719

}