Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(provider-share): 澄清沙箱测试投影与跨平台权限边界

yan3456540f6b04
diff --git a/apps/desktop/src/main/remote-agent/__tests__/providerAccess.test.ts b/apps/desktop/src/main/remote-agent/__tests__/providerAccess.test.ts
index 46004c9bca..aacc1aac75 100644
--- a/apps/desktop/src/main/remote-agent/__tests__/providerAccess.test.ts
+++ b/apps/desktop/src/main/remote-agent/__tests__/providerAccess.test.ts
@@ -121,7 +121,7 @@ describe('guest proxy binding for direct shares and same-account group relays',
});
for (const kind of ['codex', 'pi', 'claude-code'] as const) {
const id = kind === 'codex' ? rootId : bridgeId;
- const binding = await binder({ kind, hostSessionId: `gpt-${kind}`, providerId: 'openai',
+ const binding = await binder({ kind, hostSessionId: `gpt-${kind}`, sessionId: `gpt-task-${kind}`, providerId: 'openai',
controller: providerShareGuestPeer('share', 'alice', 'phone'), isCurrent: () => true });
expect(binding?.modelIds).toEqual([id]);
expect(await binding?.allowsModel?.(id)).toBe(true);
diff --git a/apps/desktop/src/main/remote-agent/executor/__tests__/virtualWorkspace.test.ts b/apps/desktop/src/main/remote-agent/executor/__tests__/virtualWorkspace.test.ts
index 0f1dd606a4..e7519c7313 100644
--- a/apps/desktop/src/main/remote-agent/executor/__tests__/virtualWorkspace.test.ts
+++ b/apps/desktop/src/main/remote-agent/executor/__tests__/virtualWorkspace.test.ts
@@ -24,10 +24,17 @@ afterEach(() => { fs.rmSync(root, { recursive: true, force: true }); });
/** Agent 写进文件的路径还原到本机时沿用它的分隔符,源码字符串里不会冒出 `\f`、`\b` 这类转义。 */
function written(local: string, virtual: string): string { return virtual.startsWith('C:') ? local : local.replace(/\\/g, '/'); }
-/** 转发给 exec-server 的 Codex 请求里与沙箱有关的字段。 */
+/** managed fixture 的结果投影;原始 wire 字段由下方断言核实,不是外部输入校验。 */
interface MappedSandboxRequest {
cwd?: string;
- sandbox: { cwd?: string; userHomeDir?: string; windowsSandboxLevel?: unknown; permissions: { file_system: { entries: unknown[] } } };
+ sandbox: {
+ cwd?: string;
+ userHomeDir?: string;
+ windowsSandboxLevel?: unknown;
+ permissions: {
+ file_system: { entries: unknown[] };
+ };
+ };
}
function setup(virtual: string) {
@@ -610,7 +617,8 @@ describe('virtual workspace', () => {
expect(params.sandbox.windowsSandboxLevel).toBe(process.platform === 'win32' ? 'restricted-token' : 'disabled');
const explicit = mapExecServerParams({ sandbox: { ...sandbox, windowsSandboxLevel: 'mxc' } }, workspace) as MappedSandboxRequest;
expect(explicit.sandbox.windowsSandboxLevel).toBe('mxc');
- const unrestricted = mapExecServerParams({ sandbox: { ...sandbox, permissions: { type: 'unrestricted' } } }, workspace) as MappedSandboxRequest;
+ const unrestricted = mapExecServerParams({ sandbox: { ...sandbox, permissions: { type: 'unrestricted' } } }, workspace) as { sandbox: { windowsSandboxLevel?: unknown } };
+ expect(unrestricted).toMatchObject({ sandbox: { permissions: { type: 'unrestricted' } } });
expect(unrestricted.sandbox.windowsSandboxLevel).toBe('disabled');
// 没有虚拟工作区(旧版对端)时沙箱原样转发,与之前一致。
const plain = new ExecutorWorkspace({ workingDir: project });
diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.md
index b9f9f475ed..f74bf32dff 100644
--- a/docs/dev-rules/protocol-compatibility.md
+++ b/docs/dev-rules/protocol-compatibility.md
@@ -1752,8 +1752,11 @@ Codex 原生图片恢复(#6412)在既有 `maker:remote-agent:v1` 上追加
映射为本机路径(绝对 glob 里本机目录名按字面转义);不在其中的是 B 自己的目录(如它的 Codex 记忆目录),读写
授权丢弃,只收不放;禁止规则不因转换失效:路径条目在 A 上也是合法绝对路径时原样保留,没映射上的禁止 glob
一律原样保留;用户目录对不上时换成 A 本机的(Codex 缺了它会把 `~/…` 规则当解析失败、一律拒绝读取);
- `file:///C:/…` 是否为盘符按 B 的路径约定(虚拟工作区路径)判断;网络与 Windows 沙箱档位不动。原样转发时
- 两端系统不同会被 A 的 exec-server 拒绝(`invalid sandbox permission path URI`)。
+ `file:///C:/…` 是否为盘符按 B 的路径约定(虚拟工作区路径)判断;网络配置按原值透传。Windows 沙箱档位通常
+ 保持原值;唯一例外是在已有虚拟映射、Agent 路径为 POSIX、本机执行端为 Windows、`permissions.type=managed`
+ 且 `windowsSandboxLevel=disabled` 时,选择本机 `restricted-token`,见[远程适配规则](remote-and-mobile-adaptation.md)。
+ 显式 Windows 选择、非受限请求与无虚拟映射的 legacy 分支不改;原生实现无法落实限制时仍拒绝,不删规则或转无沙箱。
+ 原样转发时两端系统不同可能被 A 的 exec-server 拒绝(`invalid sandbox permission path URI`)。
- **影子目录与配置同步**:`open` 载荷除项目说明文件(含 `.claude/CLAUDE.md`、`.claude/rules`、
`.codex/skills`)外还带 `ancestorFiles`(项目上级目录里的
`CLAUDE.md` / `CLAUDE.local.md` / `AGENTS.md` / `AGENTS.override.md`,按层级 `up`,最多 24 级)与