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(ci): stabilize approval tests and remove local-only doc link

DavidShen741ed3d4d21c
diff --git a/docs/product-rules/shared-task-mode.md b/docs/product-rules/shared-task-mode.md
index f7726f1367..1980bf5108 100644
--- a/docs/product-rules/shared-task-mode.md
+++ b/docs/product-rules/shared-task-mode.md
@@ -73,7 +73,7 @@
## UI review 与全部关闭(2026-09-18)
-[单文件交互原型](../../artifacts/shared-task-design/index.html) 展示三种入口:A 任务顶部小面板与账号菜单;B 一个共享窗口,分当前任务与我发起的共享;C 侧栏入口与右侧管理面板。原型是设计展示,不是实际客户端或验收截图。Light/Dark、小屏及开启、加入、邀请、移除、全部关闭、离线结束一起评审。
+单文件交互原型仅保存在本地 `artifacts/shared-task-design/index.html`,不随仓库提交;仓库内的实现依据为本文记录的已确认方案。原型展示三种入口:A 任务顶部小面板与账号菜单;B 一个共享窗口,分当前任务与我发起的共享;C 侧栏入口与右侧管理面板。原型是设计展示,不是实际客户端或验收截图。Light/Dark、小屏及开启、加入、邀请、移除、全部关闭、离线结束一起评审。
已选定方案 B:“共享任务 → 我发起的 → 关闭全部共享”。范围为当前账号、当前区域内由我发起的共享(含其他主机),不退出加入别人的任务、不停止 Agent、不删除任务、不影响同账号远控。确认面板列出任务与主机,默认取消;失败保留未关闭项供重试。
diff --git a/packages/maker-core/src/agents/codex/index.test.ts b/packages/maker-core/src/agents/codex/index.test.ts
index b455f81ef4..aaf6f295a8 100644
--- a/packages/maker-core/src/agents/codex/index.test.ts
+++ b/packages/maker-core/src/agents/codex/index.test.ts
@@ -23600,7 +23600,7 @@ describe('CodexAgent resume preparation', () => {
}));
const host = installFakeHost(agent);
try {
- await expect(agent.forkSdkSession({ sourceSdkSessionId: resumeSessionId, workingDir: root })).rejects.toThrow();
+ await expect(agent.forkSdkSession({ sourceSdkSessionId: resumeSessionId, workingDir: root, upToMessageId: undefined })).rejects.toThrow();
expect(host.getHost).not.toHaveBeenCalled();
expect(host.request).not.toHaveBeenCalled();
} finally {
diff --git a/packages/maker-core/src/agents/pi/__tests__/pi-startsession-cleanup.test.ts b/packages/maker-core/src/agents/pi/__tests__/pi-startsession-cleanup.test.ts
index 6d52666cf4..3d03fc8e48 100644
--- a/packages/maker-core/src/agents/pi/__tests__/pi-startsession-cleanup.test.ts
+++ b/packages/maker-core/src/agents/pi/__tests__/pi-startsession-cleanup.test.ts
@@ -342,6 +342,25 @@ describe('PiAgent.startSession failure cleanup (mocked pi process)', () => {
};
}
+ /** Offer the first status only after the test attaches its approval surface. */
+ function deferSubagentDiscovery(run: PiSubagentRunStatus) {
+ const ownRunRoot = path.join(agentHome, 'runtime', 'pi-subagent-runs', 's1');
+ let publish!: () => void;
+ const ready = new Promise<void>((resolve) => { publish = resolve; });
+ const list = mockRunDiscovery().mockImplementation(async (root) => {
+ if (root !== ownRunRoot) return [];
+ await ready;
+ return [run];
+ });
+ return {
+ publish,
+ clear() {
+ list.mockResolvedValue([]);
+ publish();
+ },
+ };
+ }
+
it('disposes ctx (and does not close a nonexistent proc) when the process constructor throws synchronously', async () => {
knobs.ctorThrows = true;
const agent = new PiAgent(buildDeps());
@@ -1570,33 +1589,40 @@ describe('PiAgent.startSession failure cleanup (mocked pi process)', () => {
toolName: 'bash',
input: { command: 'printf fixture' },
});
- mockRunDiscovery().mockResolvedValue([run]);
+ // Startup can discover this before the surface attaches. Depending on the
+ // real 500ms poll to re-offer it races vi.waitFor's 1s deadline under CI load.
+ const discovery = deferSubagentDiscovery(run);
const control = vi.spyOn(piSubagentRuns, 'controlPiSubagentRuns').mockResolvedValue(1);
const resolver = vi.fn(async () => ({ kind: 'permission', behavior }) as const);
const handle = await new PiAgent(buildDeps()).startSession(opts());
handle.setInteractionResolver(resolver);
+ discovery.publish();
- await vi.waitFor(() => expect(control).toHaveBeenCalledWith(
- expect.any(String),
- run.taskId,
- 'approval',
- expect.objectContaining({
- childId: run.tasks[0]!.childId,
- approvalId: 'approval-1',
- confirmed,
- runtimeOwnerId: ownerId(),
- }),
- ), { timeout: 3_000 });
- expect(resolver).toHaveBeenCalledOnce();
- expect(resolver).toHaveBeenCalledWith(expect.objectContaining({
- kind: 'permission',
- toolName: 'bash',
- input: { command: 'printf fixture' },
- title: 'Subagent: bash',
- description: 'Requested by approval-fixture',
- metadata: expect.objectContaining({ provider: 'pi', subagent: true }),
- }));
- await handle.close();
+ try {
+ await vi.waitFor(() => expect(control).toHaveBeenCalledWith(
+ expect.any(String),
+ run.taskId,
+ 'approval',
+ expect.objectContaining({
+ childId: run.tasks[0]!.childId,
+ approvalId: 'approval-1',
+ confirmed,
+ runtimeOwnerId: ownerId(),
+ }),
+ ), { timeout: 3_000 });
+ expect(resolver).toHaveBeenCalledOnce();
+ expect(resolver).toHaveBeenCalledWith(expect.objectContaining({
+ kind: 'permission',
+ toolName: 'bash',
+ input: { command: 'printf fixture' },
+ title: 'Subagent: bash',
+ description: 'Requested by approval-fixture',
+ metadata: expect.objectContaining({ provider: 'pi', subagent: true }),
+ }));
+ } finally {
+ discovery.clear();
+ await handle.close();
+ }
});
it.each([
@@ -1609,18 +1635,23 @@ describe('PiAgent.startSession failure cleanup (mocked pi process)', () => {
toolName: 'bash',
input: { command: 'printf fixture' },
}, {}, 'input');
- mockRunDiscovery().mockResolvedValue([run]);
+ const discovery = deferSubagentDiscovery(run);
const control = vi.spyOn(piSubagentRuns, 'controlPiSubagentRuns').mockResolvedValue(1);
const handle = await new PiAgent(buildDeps()).startSession(opts());
handle.setInteractionResolver(vi.fn(async () => ({ kind: 'permission', behavior }) as const));
+ discovery.publish();
- await vi.waitFor(() => expect(control).toHaveBeenCalledWith(
- expect.any(String),
- run.taskId,
- 'approval',
- expect.objectContaining({ value }),
- ), { timeout: 3_000 });
- await handle.close();
+ try {
+ await vi.waitFor(() => expect(control).toHaveBeenCalledWith(
+ expect.any(String),
+ run.taskId,
+ 'approval',
+ expect.objectContaining({ value }),
+ ), { timeout: 3_000 });
+ } finally {
+ discovery.clear();
+ await handle.close();
+ }
},
);
@@ -1997,18 +2028,23 @@ describe('PiAgent.startSession failure cleanup (mocked pi process)', () => {
it('fails closed when the durable Subagent approval resolver throws', async () => {
const run = pendingSubagentRun({ toolName: 'write', input: { path: 'a.txt' } });
- mockRunDiscovery().mockResolvedValue([run]);
+ const discovery = deferSubagentDiscovery(run);
const control = vi.spyOn(piSubagentRuns, 'controlPiSubagentRuns').mockResolvedValue(1);
const handle = await new PiAgent(buildDeps()).startSession(opts());
handle.setInteractionResolver(vi.fn(async () => { throw new Error('resolver failed'); }));
+ discovery.publish();
- await vi.waitFor(() => expect(control).toHaveBeenCalledWith(
- expect.any(String),
- run.taskId,
- 'approval',
- expect.objectContaining({ confirmed: false }),
- ), { timeout: 3_000 });
- await handle.close();
+ try {
+ await vi.waitFor(() => expect(control).toHaveBeenCalledWith(
+ expect.any(String),
+ run.taskId,
+ 'approval',
+ expect.objectContaining({ confirmed: false }),
+ ), { timeout: 3_000 });
+ } finally {
+ discovery.clear();
+ await handle.close();
+ }
});
it('retries durable Subagent approval delivery without asking the user twice', async () => {