Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(bots): keep remote Pi plugins and paused settings grants
zqchris46a3f324249c
diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.tsindex 9d6ea5b087..75ed41e306 100644--- a/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts+++ b/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts@@ -1366,6 +1366,35 @@ describe('Bot canonical Session lifecycle', () => {expect(opts.botProfileContextPrompt).not.toContain('ghost_call');});+ it('keeps plugin discovery guidance for remote Pi because cindy is tunneled', async () => {+ const created = await invoke('local-db:bots:create-canonical-session', {+ botId: 'bot-1',+ expectedCanonicalSessionId: null,+ expectedProfileVersion: 1,+ });+ const opts: MakerSessionCreateOpts = {+ id: created.session.id,+ agentKind: 'pi',+ workingDir: '/srv/cindy-bot',+ remoteHostId: 'remote-host-1',+ workspaceKind: 'project',+ model: 'grok-4.5',+ permissionMode: 'ask',+ };++ await hydrateBotProfileRuntime(opts, {+ listSkills: async () => [],+ listMcpServers: async () => [],+ listToolsets: async () => [{+ id: 'xdt_helper', name: 'Helper', essential: true, available: true,+ }],+ });++ expect(opts.botProfileContextPrompt).toContain('`find_bot_capabilities`');+ expect(opts.botProfileContextPrompt).toContain('ghost_list');+ expect(opts.botProfileContextPrompt).toContain('ghost_call');+ });+it('keeps ambient catalogs only as explicit disabled rows under legacy inherit', async () => {const created = await invoke('local-db:bots:create-canonical-session', {botId: 'bot-1',@@ -2019,6 +2048,23 @@ describe('Bot canonical Session lifecycle', () => {await expect(selectBotCapability({ callerSessionId: created.session.id, kind: 'mcp', id: 'shared-docs', joined: true })).resolves.toMatchObject({ ok: false });});+ it('allows trusted settings to add capabilities while the Bot is paused', async () => {+ const created = await invoke('local-db:bots:create-canonical-session', {+ botId: 'bot-1', expectedCanonicalSessionId: null, expectedProfileVersion: 1,+ });+ const service = createBotCapabilityService(capabilityDeps);+ h.validateCapabilityAdditions.mockImplementation(service.validateAdditions);+ h.sqlite!.prepare("UPDATE bot_profiles SET status = 'paused' WHERE id = 'bot-1'").run();+ await expect(selectBotCapability({+ callerSessionId: created.session.id, kind: 'mcp', id: 'shared-docs', joined: true,+ })).resolves.toMatchObject({ ok: false });+ await expect(findBotCapabilities({ callerSessionId: created.session.id, kind: 'mcp' }))+ .resolves.toMatchObject({ ok: false });+ await expect(invoke('local-db:bots:update', {+ id: 'bot-1', capabilities: { mcpServers: ['shared-docs'] },+ })).resolves.toMatchObject({ currentVersion: 2 });+ });+it.each([['browser', 'cindy_browser'], ['scheduler', 'cindy_scheduler'], ['contacts', 'cindy_contacts']])('mounts the selected %s toolset into the actual MCP policy', async (toolset, server) => {await invoke('local-db:bots:update', { id: 'bot-1', capabilities: { toolsets: [toolset], toolsetMode: 'allowlist' } });const created = await invoke('local-db:bots:create-canonical-session', { botId: 'bot-1', expectedCanonicalSessionId: null, expectedProfileVersion: 2 });diff --git a/apps/desktop/src/main/maker-ipc/botCapabilityService.ts b/apps/desktop/src/main/maker-ipc/botCapabilityService.tsindex f9da30e180..04801ce8fd 100644--- a/apps/desktop/src/main/maker-ipc/botCapabilityService.ts+++ b/apps/desktop/src/main/maker-ipc/botCapabilityService.ts@@ -38,7 +38,7 @@ const strings = (value: unknown): string[] =>Array.isArray(value) ? value.filter((entry): entry is string => typeof entry === 'string') : [];/** Only the live owner may select capabilities; no caller-supplied Bot or connection config. */-async function context(callerSessionId: string) {+async function context(callerSessionId: string, opts?: { allowPaused?: boolean }) {const owner = activeOwnerScopeKey();const assertOwner = () => {if (isAppSessionBoundaryPending() || activeOwnerScopeKey() !== owner)@@ -73,6 +73,9 @@ async function context(callerSessionId: string) {.where(eq(botSessionLinks.sessionId, callerSessionId)).limit(1);assertOwner();+ const profileAllowed =+ row?.profileStatus === 'active' ||+ (opts?.allowPaused === true && row?.profileStatus === 'paused');if (!row ||row.source !== 'bot' ||@@ -80,7 +83,7 @@ async function context(callerSessionId: string) {row.canonicalSessionId !== callerSessionId ||row.archivedAt !== null ||row.sessionStatus !== 'active' ||- row.profileStatus !== 'active'+ !profileAllowed) {throw new Error('只有当前伙伴主任务可以管理自己的能力');}@@ -234,9 +237,10 @@ export function createBotCapabilityService(deps: BotCapabilityServiceDeps) {if (additions.length === 0) return;try {if (!update.canonicalSessionId) throw new Error('Missing canonical task');- const ctx = await context(update.canonicalSessionId);+ // Settings remain editable while paused; model-initiated list/select stay active-only.+ const ctx = await context(update.canonicalSessionId, { allowPaused: true });if (ctx.botId !== update.botId) throw new Error('Canonical task owner mismatch');- const modelChain = readEffectiveBotModelChain(update.next);+ const modelChain = await readEffectiveBotModelChain(update.next);for (const { kind, ids } of additions) {const entries = await catalog({ callerSessionId: update.canonicalSessionId, kind }, ctx, deps,{ modelChain, forceReload: true });diff --git a/apps/desktop/src/main/maker-ipc/botProfileRuntime.ts b/apps/desktop/src/main/maker-ipc/botProfileRuntime.tsindex a59ec62917..3fe219ab1e 100644--- a/apps/desktop/src/main/maker-ipc/botProfileRuntime.ts+++ b/apps/desktop/src/main/maker-ipc/botProfileRuntime.ts@@ -304,7 +304,8 @@ export function buildBotCapabilityContextPrompt(const helperAvailable = options.helperAvailable !== false;// cindy / ghost_* live on the local builtin gateway. SSH Claude/Codex only// inject collab, memory and helper (REMOTE_ALLOWED_SERVER_NAMES); advertising- // plugins there would tell the model to call tools it cannot reach.+ // plugins there would tell the model to call tools it cannot reach. Remote Pi+ // tunnels cindy, so keep plugin guidance there.const cindyAvailable = options.cindyAvailable !== false;const pluginGuidance = cindyAvailable? ' Installed plugins are available on demand through `cindy` (`ghost_list`, `ghost_info`, `ghost_call`) under their existing permissions.'@@ -807,8 +808,9 @@ export async function hydrateBotProfileRuntime(});const helperAvailable = !opts.remoteHostId || opts.agentKind === 'pi'|| toolsetCatalog.some((item) => item.id === 'xdt_helper' && item.available !== false);- // Local sessions always mount the cindy gateway. Remote SSH never does.- const cindyAvailable = !opts.remoteHostId;+ // Local sessions always mount the cindy gateway. Remote Claude/Codex do not+ // (REMOTE_ALLOWED_SERVER_NAMES). Remote Pi tunnels cindy via the MCP bridge.+ const cindyAvailable = !opts.remoteHostId || opts.agentKind === 'pi';// 三层装配(见 botSystemPrompt.ts):身份与「你会做什么」进稳定段,会话控制等// 进上下文段,技能索引与记忆快照进易变段并排在最后。能力说明按**这个伙伴// 实际挂载到的 toolset** 注入 —— 挂了 docs 才讲怎么做文件,没挂的一个字不提。diff --git a/docs/ghost-progressive-discovery.md b/docs/ghost-progressive-discovery.mdindex 02df23ec56..1313b80766 100644--- a/docs/ghost-progressive-discovery.md+++ b/docs/ghost-progressive-discovery.md@@ -106,9 +106,12 @@ frontmatter `name + description` 的召回作用;`manual.items` 只是插件- formatter 的调用方必须传入**已解析的会话 workingDir**;拿不到语境(ALS 缺失、bridge 建线期 `workingDir === ''`)时**不注入,绝不回退全量**——否则会把当前目录已停用插件的元数据送进高权重 prompt。-- 远端 SSH 会话(`remoteHostId`)一律不注入:固定 `cindy` MCP server 不在远端- 注入白名单,远端 agent 调不到 ghost 工具;且远端 workingDir 是远程路径,- 无法匹配本地的目录停用记录。Claude 与 Codex 行为一致;Pi 仅支持本地会话。+- 远端 SSH 的 Claude / Codex(`remoteHostId`)不注入花名册:固定 `cindy` MCP+ 不在远端注入白名单,agent 调不到 ghost 工具;且远端 workingDir 是远程路径,+ 无法匹配本地的目录停用记录。远端 Pi 经 MCP bridge 隧道可达 in-process+ `cindy`,伙伴提示词与 helper 工具描述应保留 `ghost_list` / `ghost_info` /+ `ghost_call`;花名册 system 段仍 fail-closed(远端路径对不上本地停用记录,+ 伙伴会话也不注入全量花名册,按需 `ghost_list`)。- 空花名册 = 零注入(不留空壳标签)。## 4. 安全设计(威胁模型:插件作者不守约)diff --git a/packages/lizi-mcps/src/__tests__/lizi_xdtHelperMcpServer.test.ts b/packages/lizi-mcps/src/__tests__/lizi_xdtHelperMcpServer.test.tsindex f9d1612c31..dd8ae14fdc 100644--- a/packages/lizi-mcps/src/__tests__/lizi_xdtHelperMcpServer.test.ts+++ b/packages/lizi-mcps/src/__tests__/lizi_xdtHelperMcpServer.test.ts@@ -680,7 +680,7 @@ describe("direct Bot MCP tools", () => {}});- it("omits ghost plugin guidance from Pi helper discovery on remote sessions", async () => {+ it("keeps ghost plugin guidance in Pi helper discovery on remote sessions", async () => {const server = createXdtHelperMcpServer({resolveSurface: async () => "bot",botCapabilities: {@@ -704,7 +704,8 @@ describe("direct Bot MCP tools", () => {})).tools as Array<{ name: string; description: string }>;const find = discovered.find((tool) => tool.name === "find_bot_capabilities");expect(find?.description).toContain("Skill");- expect(find?.description).not.toMatch(/ghost_list|ghost_info|ghost_call/);+ expect(find?.description).toContain("ghost_list");+ expect(find?.description).toContain("ghost_info");} finally {await client.close();await server.close();diff --git a/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts b/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.tsindex 3ca1a0dbab..ce6a821459 100644--- a/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts+++ b/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts@@ -163,7 +163,10 @@ interface BotMessagingCallbacks {// ── Entry tool registration ──────────────────────────────────────────────────function cindyAvailableForSession(sessionCtx: XdtHelperMcpSessionCtx): boolean {- return !resolveLiziMcpSessionContext(sessionCtx).remoteHostId;+ const ctx = resolveLiziMcpSessionContext(sessionCtx);+ // Match helper / remoteBotOnly: cindy is missing only for remote Claude/Codex.+ // Remote Pi tunnels the in-process cindy gateway over the MCP bridge.+ return !ctx.remoteHostId || ctx.agentKind === 'pi';}function registerListToolsEntry(