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。

docs(orca): 补充 Pi Lead 与 Worker 能力说明 (#1920)

Chris Zhang6318a44d0ba3
diff --git a/apps/desktop/help-knowledge/collaboration.md b/apps/desktop/help-knowledge/collaboration.md
index a90b85c5c7..37c9cc5394 100644
--- a/apps/desktop/help-knowledge/collaboration.md
+++ b/apps/desktop/help-knowledge/collaboration.md
@@ -7,8 +7,8 @@ Collaboration ("协同" / Collab) lets one session — the **lead** — bring in
**Turning it on:**
-- In any regular project or dialogue session, open the composer's **+** menu and choose **Collaboration mode**. You can also choose it before sending the first message of a new task. Both Claude Code and Codex sessions can be the lead.
-- Pick the first worker's agent (Claude Code or Codex), and optionally its role / model / effort / an initial task.
+- In any regular project or dialogue session, open the composer's **+** menu and choose **Collaboration mode**. You can also choose it before sending the first message of a new task. Claude Code and Codex can lead locally or over SSH; Pi can lead in local sessions.
+- Pick the first worker's agent (Claude Code, Codex, or Pi), and optionally its role / model / effort / an initial task. SSH remote leads currently use Claude Code or Codex workers.
- Start. This creates the team plus that first worker.
**Adding more workers:**
@@ -28,5 +28,5 @@ Collaboration ("协同" / Collab) lets one session — the **lead** — bring in
**Notes:**
-- The lead can be a Claude Code / Codex **project or dialogue** session. On an SSH remote lead, workers are spawned on the **same remote host**, and the collaboration MCP reaches the remote side over an SSH remote-forward to the local bridge (with a persistent bearer token). A worker can't start its own sub-collab (no nesting).
+- A local lead can be a Claude Code, Codex, or Pi **project or dialogue** session. On an SSH remote lead, the lead and workers currently use Claude Code or Codex; Pi sessions are local-only. Remote workers are spawned on the **same remote host**, and the collaboration MCP reaches the remote side over an SSH remote-forward to the local bridge (with a persistent bearer token). A worker can't start its own sub-collab (no nesting).
- A lead can have only **one active collaboration workflow** at a time. If you have two clients open on the same account (e.g. dev + release) and start collab on the same session in both, the second fails with "开启协同失败" because a workflow is already active — close one client or end the existing collab.
diff --git a/apps/desktop/src/main/__tests__/helpRouting.test.ts b/apps/desktop/src/main/__tests__/helpRouting.test.ts
index 17dabdb0b9..4b28306511 100644
--- a/apps/desktop/src/main/__tests__/helpRouting.test.ts
+++ b/apps/desktop/src/main/__tests__/helpRouting.test.ts
@@ -121,4 +121,12 @@ describe('HELP_KNOWLEDGE invariants', () => {
// 对应意识详情页收单,帮助文档随面板一并退役。
expect(HELP_KNOWLEDGE.find((d) => d.id === 'api-keys')).toBeUndefined();
});
+
+ it('collaboration guidance includes Pi as a local lead and worker without claiming remote Pi support', () => {
+ const collaboration = HELP_KNOWLEDGE.find((d) => d.id === 'collaboration');
+
+ expect(collaboration?.content).toContain('Pi can lead in local sessions');
+ expect(collaboration?.content).toContain('Claude Code, Codex, or Pi');
+ expect(collaboration?.content).toContain('Pi sessions are local-only');
+ });
});
diff --git a/apps/desktop/src/main/maker-ipc/helpKnowledge.generated.ts b/apps/desktop/src/main/maker-ipc/helpKnowledge.generated.ts
index 79c28ca9c1..14040a17b6 100644
--- a/apps/desktop/src/main/maker-ipc/helpKnowledge.generated.ts
+++ b/apps/desktop/src/main/maker-ipc/helpKnowledge.generated.ts
@@ -28,7 +28,7 @@ export const HELP_KNOWLEDGE: HelpKnowledgeDoc[] = [
id: "collaboration",
title: "Collaboration mode (lead + workers)",
summary: "Turn on Collab to bring one or more worker agents in beside your session and delegate tasks to them.",
- content: "Collaboration (\"协同\" / Collab) lets one session — the **lead** — bring in one or more **worker** agents to run alongside it (a \"team\"). The lead delegates tasks to workers through a built-in MCP, and you can watch and steer each worker.\n\n**Turning it on:**\n\n- In any regular project or dialogue session, open the composer's **+** menu and choose **Collaboration mode**. You can also choose it before sending the first message of a new task. Both Claude Code and Codex sessions can be the lead.\n- Pick the first worker's agent (Claude Code or Codex), and optionally its role / model / effort / an initial task.\n- Start. This creates the team plus that first worker.\n\n**Adding more workers:**\n\n- From the collaboration tab's worker list, use **Create new worker** (+) to add more.\n- Default limits are a **soft cap of 5** and a **hard cap of 8** workers per lead — you'll see a warning past the soft cap, and creation is blocked at the hard cap. Both are adjustable (1–20) in the Collaboration section under **Settings > General**.\n\n**While collaborating:**\n\n- Each worker is a full session with its own history, tools, working directory, and model. New workers start in Auto-review mode: safe work can proceed automatically, while higher-risk actions may still be denied or require confirmation. They inherit the lead's working directory by default (or share the worktree when the lead uses one).\n- A worker's model defaults to your last new-session choice for that vendor, falling back to the lead's model.\n- Only one worker is **focused** (shown) at a time — switch between them with the worker tabs / dropdown. You can intervene in any worker directly, and archive workers individually.\n\n**Turning it off:**\n\n- Closing collab **confirms with you first** (in-progress work is lost), then ends the workflow and archives **all** the team's workers. The conversation history stays searchable.\n\n**Notes:**\n\n- The lead can be a Claude Code / Codex **project or dialogue** session. On an SSH remote lead, workers are spawned on the **same remote host**, and the collaboration MCP reaches the remote side over an SSH remote-forward to the local bridge (with a persistent bearer token). A worker can't start its own sub-collab (no nesting).\n- A lead can have only **one active collaboration workflow** at a time. If you have two clients open on the same account (e.g. dev + release) and start collab on the same session in both, the second fails with \"开启协同失败\" because a workflow is already active — close one client or end the existing collab.",
+ content: "Collaboration (\"协同\" / Collab) lets one session — the **lead** — bring in one or more **worker** agents to run alongside it (a \"team\"). The lead delegates tasks to workers through a built-in MCP, and you can watch and steer each worker.\n\n**Turning it on:**\n\n- In any regular project or dialogue session, open the composer's **+** menu and choose **Collaboration mode**. You can also choose it before sending the first message of a new task. Claude Code and Codex can lead locally or over SSH; Pi can lead in local sessions.\n- Pick the first worker's agent (Claude Code, Codex, or Pi), and optionally its role / model / effort / an initial task. SSH remote leads currently use Claude Code or Codex workers.\n- Start. This creates the team plus that first worker.\n\n**Adding more workers:**\n\n- From the collaboration tab's worker list, use **Create new worker** (+) to add more.\n- Default limits are a **soft cap of 5** and a **hard cap of 8** workers per lead — you'll see a warning past the soft cap, and creation is blocked at the hard cap. Both are adjustable (1–20) in the Collaboration section under **Settings > General**.\n\n**While collaborating:**\n\n- Each worker is a full session with its own history, tools, working directory, and model. New workers start in Auto-review mode: safe work can proceed automatically, while higher-risk actions may still be denied or require confirmation. They inherit the lead's working directory by default (or share the worktree when the lead uses one).\n- A worker's model defaults to your last new-session choice for that vendor, falling back to the lead's model.\n- Only one worker is **focused** (shown) at a time — switch between them with the worker tabs / dropdown. You can intervene in any worker directly, and archive workers individually.\n\n**Turning it off:**\n\n- Closing collab **confirms with you first** (in-progress work is lost), then ends the workflow and archives **all** the team's workers. The conversation history stays searchable.\n\n**Notes:**\n\n- A local lead can be a Claude Code, Codex, or Pi **project or dialogue** session. On an SSH remote lead, the lead and workers currently use Claude Code or Codex; Pi sessions are local-only. Remote workers are spawned on the **same remote host**, and the collaboration MCP reaches the remote side over an SSH remote-forward to the local bridge (with a persistent bearer token). A worker can't start its own sub-collab (no nesting).\n- A lead can have only **one active collaboration workflow** at a time. If you have two clients open on the same account (e.g. dev + release) and start collab on the same session in both, the second fails with \"开启协同失败\" because a workflow is already active — close one client or end the existing collab.",
},
{
id: "commands",
diff --git a/docs/dev-rules/orca-team-architecture.md b/docs/dev-rules/orca-team-architecture.md
index 9a33afbc96..8e46e1b618 100644
--- a/docs/dev-rules/orca-team-architecture.md
+++ b/docs/dev-rules/orca-team-architecture.md
@@ -38,7 +38,7 @@ Orca 是 Cindy Desktop 内的多 agent 协同能力:一个 **Lead session**
- 多 worker:同一个 active team 下可创建多个 worker,支持 role、label、focused worker 切换、soft/hard limit 与归档。
- Split view:Lead 与 focused Worker 共用 `OrcaSplitView` pane 外壳,宽屏为左右 split,doc rail 为 Lead/Worker toggle。见 `apps/desktop/src/renderer/features/cc-agent/OrcaSplitView.tsx` 的 `OrcaSplitView`、`OrcaPaneShell`。
-- Claude Code 与 Codex 的普通 Lead 无论是项目还是对话都可开启协同;SSH 远端会话两端均可作 Lead(远端 agent 经 SSH remote-forward 直连本机 HTTP MCP bridge,`cindy_orca` 在两端都可用:codex 走 daemon config 注入,cc 走 per-query http 注入);device-link 被控端的项目与对话同样可作 Lead(Lead / Worker / team 的真身都在被控端,控制端只是镜像)。renderer 的入口判定收敛在 `apps/desktop/src/renderer/features/cc-agent/collabEntryPolicy.ts` 的 `resolveCollabEntryPolicy`,新建草稿(`NewMakerDraftRoute`)与会话视图(`CCAgentSessionView` 的 `allowCollabToggle`)共用同一份:普通 Lead 都显示入口,只排除不能嵌套协同的 Orca Worker 子会话。项目按项目级策略查询;Main 的 `resolveLocalCollabPolicyWorkingDir` 同时服务入口状态查询与最终授权,只有 workspace kind 为 dialogue 且 Main 确认目录位于 app 托管 dialogue root 时才只查用户级/全局级策略(即使 cwd 内出现 `.cindy/plugins.json`),显式绑定真实目录的对话仍按该目录的项目级策略查询,不能靠自报 `workspaceKind` 绕过项目禁用。
+- 本地 Claude Code、Codex 与 Pi 的普通 Lead 无论是项目还是对话都可开启协同,本地 Worker 也支持这三类 agent;Pi 当前仅支持本地 Lead / Worker,不支持 SSH 远程协同。SSH 远端会话的 Claude Code 与 Codex 两端均可作 Lead(远端 agent 经 SSH remote-forward 直连本机 HTTP MCP bridge,`cindy_orca` 在两端都可用:codex 走 daemon config 注入,cc 走 per-query http 注入);device-link 被控端的项目与对话同样可作 Lead(Lead / Worker / team 的真身都在被控端,控制端只是镜像)。renderer 的入口判定收敛在 `apps/desktop/src/renderer/features/cc-agent/collabEntryPolicy.ts` 的 `resolveCollabEntryPolicy`,新建草稿(`NewMakerDraftRoute`)与会话视图(`CCAgentSessionView` 的 `allowCollabToggle`)共用同一份:普通 Lead 都显示入口,只排除不能嵌套协同的 Orca Worker 子会话。项目按项目级策略查询;Main 的 `resolveLocalCollabPolicyWorkingDir` 同时服务入口状态查询与最终授权,只有 workspace kind 为 dialogue 且 Main 确认目录位于 app 托管 dialogue root 时才只查用户级/全局级策略(即使 cwd 内出现 `.cindy/plugins.json`),显式绑定真实目录的对话仍按该目录的项目级策略查询,不能靠自报 `workspaceKind` 绕过项目禁用。
- Codex Lead 使用全局注册的 `cindy_orca`,调用时通过 context 恢复身份并在 handler 内拒绝越权。远端 Codex 同样走 `params._meta.threadId` 路由——remote thread 与本地 thread 一样注册进 `CodexMcpThreadContextStore`(`packages/maker-core/src/agents/codex/index.ts` 的 `registerCodexMcpContext` 不再跳过 remoteHostId)。远端 cc 没有 threadId,身份走持久 bearer token + URL `?session=<id>` 路由(`codexHttpBridge.registerSessionCtx`),审批归属快照在 `remoteCcQueryFactory` 注入后按 `startParams.mcpServers` 最终清单定稿。
- SSH 远端 Codex 的 MCP 桥接:本机 `codexHttpBridge` 在原有 per-run 主 token 之外接受一个 persistent bearer token(safeStorage);`remote-ssh/codex-remote-mcp.ts` 在 session start/resume 前置完成 per-host 固定端口 remote-forward(`RemoteHost.openRemoteForward`,重连自动 rebind)、远端 `$CODEX_HOME/config.toml` 的 `mcp_servers` 管理段漂移检测(行级 marker + 剥离用户同名 table)与 daemon 幂等 bootstrap(token 只经 stdin 的 KEY=value 块注入,不进 argv);config 漂移需要重启 daemon 时若同 host 有 live turn 则本次降级(留待下次 ensure)。worker 创建经 `OrcaLeadSessionSnapshot.remoteHostId` 继承在同一台远端主机 spawn,创建前走 `ensureRemoteReadyForSessionStart`(SSH 重连 / agent 安装 / MCP 注入);lazy resume 与 Orca worker 唤醒路径同样先 ensure 再 bootstrap。
- PR #107 提供 side_chat 的底层 fork 数据动作:user/assistant 消息都能 fork,assistant 按 turn 粒度复制,Claude 用 uuid 锚点,Codex 用 ThreadFork + ThreadRollback。当前作为普通 session 跳转;未来要登记为 side activity 并挂入统一 pane。
@@ -51,7 +51,7 @@ Orca 是 Cindy Desktop 内的多 agent 协同能力:一个 **Lead session**
- workflow_run / CC Workflow 编排还未纳入当前实现。
- side_chat 尚未登记为 side activity 对象,也未挂进 pane;PR #107 只是 fork 数据动作。
- device-link 协同的 Lead / Worker / team 全部在被控端进程内编排,控制端只按 session 来源经隧道路由(`makerTransport` 的 `makerApiFor` / `orcaWorkflowsFor` / `subscribeOrcaWorkerChanged`,channel 见 `packages/device-link/src/allowlist.ts` 的 Orca 段)。collab 开关同样查被控端(`maker:plugins:get-state` 经 `pluginEnableStateFor`):项目读取被控端项目级策略,对话读取被控端用户级/全局级策略。控制端本机状态不能代表被控端真相。老被控端没有该 channel 时回 `CHANNEL_NOT_ALLOWED`,控制端 fail-closed 置灰入口并提示设备版本过旧,而不是放行到 `enableOrca` 才撞错。
-- SSH 远端协同支持 codex 与 claude-code 两类 lead + 远端 worker(继承 remoteHostId)。cc 远端经 `cc-remote-mcp.ts` 把 `cindy_orca` / `orca_worker_bridge` 以 http 形态追加进 `startParams.mcpServers`(persistent token + `?session=` 路由,白名单仅此两个 server)。远端 worker 手动 `send_to_lead` 依赖 daemon 侧 `orca_worker_bridge` 经同一 bridge 可达;auto-bridge 回报不依赖 worker 侧 MCP,天然可用。共享 userData 多实例连同一远端 host 时,只有先建立 SSH 转发的实例能持有该 host 的 MCP bridge 端口,其余实例按“远端无 MCP”降级(与历史行为一致)。远端会话的项目级 collab 开关不查本机 fs;`assertCollabProjectEnabled` 对 remote 只查用户级/全局级开关,远端项目级配置机制是 follow-up。
+- SSH 远端协同仅支持 codex 与 claude-code 两类 lead + 远端 worker(继承 remoteHostId),不支持 Pi Lead 或 Pi Worker。cc 远端经 `cc-remote-mcp.ts` 把 `cindy_orca` / `orca_worker_bridge` 以 http 形态追加进 `startParams.mcpServers`(persistent token + `?session=` 路由,白名单仅此两个 server)。远端 worker 手动 `send_to_lead` 依赖 daemon 侧 `orca_worker_bridge` 经同一 bridge 可达;auto-bridge 回报不依赖 worker 侧 MCP,天然可用。共享 userData 多实例连同一远端 host 时,只有先建立 SSH 转发的实例能持有该 host 的 MCP bridge 端口,其余实例按“远端无 MCP”降级(与历史行为一致)。远端会话的项目级 collab 开关不查本机 fs;`assertCollabProjectEnabled` 对 remote 只查用户级/全局级开关,远端项目级配置机制是 follow-up。
### 核心概念与数据模型
diff --git a/packages/lizi-mcps/src/__tests__/getCapabilitiesTool.test.ts b/packages/lizi-mcps/src/__tests__/getCapabilitiesTool.test.ts
index 8d06957670..c848dc7291 100644
--- a/packages/lizi-mcps/src/__tests__/getCapabilitiesTool.test.ts
+++ b/packages/lizi-mcps/src/__tests__/getCapabilitiesTool.test.ts
@@ -80,6 +80,15 @@ describe('capabilities data source', () => {
expect(entry!.detail).toContain('https://cindy.cn');
expect(entry!.detail).toContain('https://cindy.app');
});
+
+ it('collab-mode 明确 Pi 可作本地 Lead 和 Worker,且不扩大到 SSH 远程 Pi', () => {
+ const entry = findCapability('collab-mode');
+
+ expect(entry).toBeDefined();
+ expect(entry!.detail).toContain('Claude Code / Codex / Pi 本地项目或对话 session');
+ expect(entry!.detail).toContain('也都可以作为 Worker');
+ expect(entry!.detail).toContain('SSH 远程 Lead 与 Worker 当前只支持 Claude Code / Codex');
+ });
});
describe('get_capabilities tool', () => {
diff --git a/packages/lizi-mcps/src/xdt-helper/capabilities.ts b/packages/lizi-mcps/src/xdt-helper/capabilities.ts
index 576e4fc4cb..272adfb3b9 100644
--- a/packages/lizi-mcps/src/xdt-helper/capabilities.ts
+++ b/packages/lizi-mcps/src/xdt-helper/capabilities.ts
@@ -67,7 +67,7 @@ export const CAPABILITIES: readonly CapabilityEntry[] = [
`【是什么】${BRAND_NAME} 业务层在用户的 Lead session 旁边独立创建一个完整的 Worker session(独立 SDK 进程、独立对话历史、独立工具集), Lead 通过 worker_* MCP 工具向 Worker 派任务。UI 上以 split-pane 双栏呈现。`,
'【怎么开】用户表达"用 worker / 协同模式 / 独立 agent / 派一个 agent 帮我 X"等意图时, Lead 调 start_team 工具创建 team, 再调 create_worker 工具添加 worker。worker 创建后可通过 send_to_worker 派活, 通过 list_workers 查看所有 worker, 通过 switch_focus 切换 focused worker。',
'【怎么关】用户表达"够了 / 关掉 worker / 不要协同了"时, Lead 调 end_team 结束整个 team(归档所有 worker), 或调 archive_worker 归档单个 worker。Lead 自身保留可继续单 session 对话。',
- '【硬边界】Worker session 不能再开 team(嵌套禁止, 返 WORKER_CANNOT_NEST);Claude Code / Codex 本地项目 session 都可以作为 Lead 调 start_team;Worker 不能结束自己所在 team(返 WORKER_CANNOT_DISABLE);要求 Lead session 有 workingDir。',
+ '【硬边界】Worker session 不能再开 team(嵌套禁止, 返 WORKER_CANNOT_NEST);Claude Code / Codex / Pi 本地项目或对话 session 都可以作为 Lead 调 start_team,也都可以作为 Worker;SSH 远程 Lead 与 Worker 当前只支持 Claude Code / Codex;Worker 不能结束自己所在 team(返 WORKER_CANNOT_DISABLE);要求 Lead session 有 workingDir。',
'【工具归属】13 个 team 工具(start_team / create_worker / create_workers / send_to_worker / list_worker_queue / update_queued_message / cancel_queued_message / list_workers / switch_focus / idle_worker / end_team / archive_worker / list_available_models)在独立的 cindy_orca server 直接顶层注册, 对应"协同模式"可关插件(Settings → Connections → Built-in Tools)。通用 session handoff 原语 send_to_session 在 essential 的 cindy_helper 的 handoff 类目下(走 call_tool, 常开, 供 skill 路由用)。',
`【与 Claude Code Task tool / Codex subagent 的区别】Task / subagent 是 agent 框架内的子任务派发机制(子 agent 跑在同一 SDK 进程内、有限工具集、生命周期短、对话历史归属父 turn);${BRAND_NAME} 协同模式是业务层的 session 级编排(Lead/Worker 都是完整独立的 ${BRAND_NAME} session, 独立进程、UI 栏位、完整工具、独立对话历史, 长生命周期, 通过 main 进程 IPC + MCP bridge 通信)。两者不互斥, Worker 内部仍可用 Task/subagent 派子任务。`,
'【手动入口】ChatInput「+」菜单里的「协同模式」项,开启态用橙色 UsersRound 图标与文字标识;用户也能在这里手动开/关,与本工具走同一份业务代码。',