Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions integration-tests/fixtures/mock-acp-child/agent.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ import {
PROTOCOL_VERSION,
RequestError,
} from '@agentclientprotocol/sdk';
import {
EXTERNAL_TOOL_GUARD_READY_META_KEY,
EXTERNAL_TOOL_GUARD_REQUIRED_VALUE,
PRIVATE_EXTERNAL_TOOL_GUARD_ENV,
PRIVATE_EXTERNAL_TOOL_GUARD_PROVIDER_ENV,
} from '@qwen-code/acp-bridge/externalToolGuard';
Comment on lines +27 to +32

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code part adopted; PR-management part needs a maintainer.

This round adopted PR 9161's extra line: the mock child now also does delete process.env[PRIVATE_EXTERNAL_TOOL_GUARD_PROVIDER_ENV] (commit ac2fa92abc). Verified against the real children first — acpAgent.ts and gemini.tsx both consume and delete both guard markers, and qwen serve passes exactly these two envs via childEnvOverrides (the token/capability envs are scrubbed daemon-side and never reach the child, so the fixture does not delete them). This PR's fixture change is now a strict superset of PR 9161's.

Not actionable from this flow (no GitHub credentials): adding Fixes #9159 to the PR description and closing PR 9161, or the inverse. Recommendation: keep this PR, add Fixes #9159 to its description, and close PR 9161, since it now carries the complete fixture change. Leaving this thread open for the maintainer's call.

Verification this round: npm run build, npm run bundle, npm run typecheck, npm run lint all pass; both journal-recovery integration suites (the fixture's consumers) pass 3/3 against the bundled CLI with QWEN_SANDBOX=false.

中文说明

代码部分已采纳;PR 管理部分需要维护者处理。

本轮已采纳 PR 9161 多出的那一行:mock 子进程现在同样执行 delete process.env[PRIVATE_EXTERNAL_TOOL_GUARD_PROVIDER_ENV](提交 ac2fa92abc)。实现前已对照真实子进程核实——acpAgent.ts 与 gemini.tsx 都会消费并删除这两个守卫标记,而 qwen serve 通过 childEnvOverrides 传递给子进程的恰好就是这两个环境变量(token/capability 环境变量在守护进程一侧即被清除、不会到达子进程,因此夹具不删除它们)。本 PR 的夹具改动现在是 PR 9161 的严格超集。

本流程无法执行(没有 GitHub 凭据):在 PR 描述中添加 Fixes #9159 并关闭 PR 9161,或反向操作。建议:保留本 PR、在其描述中添加 Fixes #9159、关闭 PR 9161,因为本 PR 已包含完整的夹具改动。此线程保持打开,等待维护者决定。

本轮验证:npm run build、npm run bundle、npm run typecheck、npm run lint 全部通过;两个 journal-recovery 集成测试套件(该夹具的消费方)在 QWEN_SANDBOX=false 下针对打包后的 CLI 运行,3/3 全部通过。

import { Writable, Readable } from 'node:stream';

// Protect the stdout NDJSON pipe — any console method that writes to
Expand All @@ -40,6 +46,15 @@ const delayMs = parseInt(process.env.MOCK_ACP_PROMPT_DELAY_MS || '100', 10);
const emitChunks = parseInt(process.env.MOCK_ACP_EMIT_CHUNKS || '3', 10);
let sessionCounter = 0;

// Mirror the real child (acpAgent.ts): `qwen serve` requires the guard ack
// in the initialize response, and the markers are consumed + deleted before
// anything else can inherit them.
const externalToolGuardMarker = process.env[PRIVATE_EXTERNAL_TOOL_GUARD_ENV];
delete process.env[PRIVATE_EXTERNAL_TOOL_GUARD_ENV];
delete process.env[PRIVATE_EXTERNAL_TOOL_GUARD_PROVIDER_ENV];
const externalToolGuardRequired =
externalToolGuardMarker === EXTERNAL_TOOL_GUARD_REQUIRED_VALUE;

new AgentSideConnection(
(connection) => ({
async initialize() {
Expand All @@ -48,6 +63,14 @@ new AgentSideConnection(
agentInfo: { name: 'mock-acp', version: '0.0.1' },
authMethods: [],
agentCapabilities: {},
...(externalToolGuardRequired
? {
_meta: {
[EXTERNAL_TOOL_GUARD_READY_META_KEY]:
EXTERNAL_TOOL_GUARD_REQUIRED_VALUE,
},
}
: {}),
};
},

Expand Down
Loading