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(mcps): hide update checks from remote Pi tasks

Cindy2f0a551222a1
diff --git a/packages/lizi-mcps/src/__tests__/lizi_xdtHelperMcpServer.test.ts b/packages/lizi-mcps/src/__tests__/lizi_xdtHelperMcpServer.test.ts
index 556e4eb670..b8f7860800 100644
--- a/packages/lizi-mcps/src/__tests__/lizi_xdtHelperMcpServer.test.ts
+++ b/packages/lizi-mcps/src/__tests__/lizi_xdtHelperMcpServer.test.ts
@@ -58,6 +58,42 @@ describe("cindy_helper MCP server", () => {
await server.close();
}
});
+ it('hides app updates from a remote Pi task while retaining its other helper categories', async () => {
+ let remoteHostId: string | undefined;
+ const check = vi.fn(async () => ({ status: 'ready', currentVersion: '0.1.86', targetVersion: '0.1.90' }));
+ const server = createXdtHelperMcpServer({
+ resolveSurface: async () => 'default',
+ appUpdate: { isCurrentSession: () => true, check },
+ }, {
+ agentKind: 'pi', workingDir: '/repo', sessionId: 'pi-task',
+ getSessionContext: () => ({
+ agentKind: 'pi', workingDir: '/repo', sessionId: 'pi-task',
+ sessionInstanceId: 'instance-1', remoteHostId,
+ }),
+ });
+ const [ct, st] = InMemoryTransport.createLinkedPair();
+ const client = new Client({ name: 'remote-pi-update-test', version: '0.0.0' });
+ await Promise.all([server.connect(st), client.connect(ct)]);
+ try {
+ const list = async () => parsePayload(await client.callTool({ name: 'list_tools', arguments: {} }));
+ const local = (await list()).categories as Array<{ name: string }>;
+ expect(local.map((category) => category.name)).toContain('app_update');
+ remoteHostId = 'ssh-host';
+ const remote = (await list()).categories as Array<{ name: string }>;
+ expect(remote.map((category) => category.name)).not.toContain('app_update');
+ expect(remote.map((category) => category.name)).toContain('cindy');
+ expect(parsePayload(await client.callTool({
+ name: 'list_tools', arguments: { category: 'app_update' },
+ }))).toMatchObject({ ok: false, errorCode: 'CAPABILITY_NOT_AVAILABLE' });
+ expect(parsePayload(await client.callTool({
+ name: 'call_tool', arguments: { name: 'check_app_update', args: {} },
+ }))).toMatchObject({ ok: false, errorCode: 'CAPABILITY_NOT_AVAILABLE' });
+ expect(check).not.toHaveBeenCalled();
+ } finally {
+ await client.close();
+ await server.close();
+ }
+ });
it('lets a remote agent start only the scoped Grok device login and returns no credential', async () => {
let current = true;
const start = vi.fn(async () => ({
diff --git a/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts b/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts
index fb77f24459..4bf066d10b 100644
--- a/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts
+++ b/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts
@@ -810,6 +810,9 @@ export function createXdtHelperMcpServer(
const sessionId = context.sessionId;
const remoteBotOnly = !!context.remoteHostId && context.agentKind !== 'pi';
const defaultCategories = new Set(CATEGORY_ENUM.filter((category) => category !== 'bots'));
+ // Remote Pi retains the regular helper surface, but a remote task cannot
+ // check the local desktop updater; keep that unavailable tool undiscoverable.
+ if (context.remoteHostId) defaultCategories.delete('app_update');
const allow = (categories: ReadonlySet<string>): HelperSurfaceAllow => ({
categories,
extraTools: new Set(),