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(bots): include remote helper in frozen capabilities

Chrisc37ba2cb0e43
diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts
index 5dca3db23f..dcd2ed7bea 100644
--- a/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts
+++ b/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts
@@ -6,6 +6,8 @@ import { rmSync } from 'node:fs';
import { drizzle } from 'drizzle-orm/better-sqlite3';
import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest';
import { BOT_TEMPLATE_PRESET_IDENTITIES } from '../../../../shared/botTemplatePreset';
+import { isBotToolsetAvailableOnTarget } from '../../../../shared/botRemoteCapabilities';
+import { resolveBotAllowedBuiltinPluginIds } from '../../../maker-host/plugins/types';
import {
botDelegations,
@@ -1212,7 +1214,12 @@ describe('Bot canonical Session lifecycle', () => {
expect(snapshots).toEqual([]);
});
- it('resolves every remote capability catalog against the target host', async () => {
+ it.each([
+ { agentKind: 'codex' as const, helperEnabled: true },
+ { agentKind: 'claude-code' as const, helperEnabled: true },
+ { agentKind: 'codex' as const, helperEnabled: false },
+ { agentKind: 'claude-code' as const, helperEnabled: false },
+ ])('resolves remote capabilities and helper guidance from the same catalog ($agentKind, helper=$helperEnabled)', async ({ agentKind, helperEnabled }) => {
const created = await invoke('local-db:bots:create-canonical-session', {
botId: 'bot-1',
expectedCanonicalSessionId: null,
@@ -1221,7 +1228,7 @@ describe('Bot canonical Session lifecycle', () => {
const inputs: Array<{ kind: string; remoteHostId?: string }> = [];
const opts: MakerSessionCreateOpts = {
id: created.session.id,
- agentKind: 'codex',
+ agentKind,
workingDir: '/srv/cindy-bot',
remoteHostId: 'remote-host-1',
workspaceKind: 'project',
@@ -1240,7 +1247,10 @@ describe('Bot canonical Session lifecycle', () => {
},
listToolsets: async (input) => {
inputs.push({ kind: 'toolsets', remoteHostId: input.remoteHostId });
- return [];
+ return [{
+ id: 'xdt_helper', name: 'Helper', essential: true,
+ available: helperEnabled && isBotToolsetAvailableOnTarget({ ...input, toolsetId: 'xdt_helper' }),
+ }];
},
});
@@ -1249,6 +1259,10 @@ describe('Bot canonical Session lifecycle', () => {
{ kind: 'mcp', remoteHostId: 'remote-host-1' },
{ kind: 'toolsets', remoteHostId: 'remote-host-1' },
]);
+ const policy = opts.botRuntimeProfile!.toolsetPolicy;
+ const allowed = resolveBotAllowedBuiltinPluginIds(policy.catalog, policy.configured);
+ expect(allowed.includes('xdt_helper')).toBe(helperEnabled);
+ expect(opts.botProfileContextPrompt?.includes('`start_session_task`')).toBe(helperEnabled);
});
it('keeps ambient catalogs only as explicit disabled rows under legacy inherit', async () => {
diff --git a/apps/desktop/src/main/maker-host/__tests__/cc-remote-mcp.test.ts b/apps/desktop/src/main/maker-host/__tests__/cc-remote-mcp.test.ts
index cbebdd1f88..eae58051b0 100644
--- a/apps/desktop/src/main/maker-host/__tests__/cc-remote-mcp.test.ts
+++ b/apps/desktop/src/main/maker-host/__tests__/cc-remote-mcp.test.ts
@@ -16,6 +16,8 @@ import {
isFrozenBuiltinPluginAllowed,
} from '../../mcp-integrations/codexBuiltinToolPolicy.js';
import { buildCcRemoteHttpMcpServers } from '../cc-remote-mcp.js';
+import { isBotToolsetAvailableOnTarget } from '../../../shared/botRemoteCapabilities.js';
+import { resolveBotAllowedBuiltinPluginIds } from '../plugins/types.js';
function fakeBridge() {
const registered = new Map<
@@ -62,9 +64,15 @@ describe('buildCcRemoteHttpMcpServers', () => {
it.each([true, false])('injects the helper only for an identified Bot (bot=%s)', async (botSession) => {
const { bridge, registered } = fakeBridge();
+ const allowed = resolveBotAllowedBuiltinPluginIds([{
+ id: 'xdt_helper',
+ available: isBotToolsetAvailableOnTarget({
+ agentKind: 'claude-code', remoteHostId: HOST.id, toolsetId: 'xdt_helper',
+ }),
+ }], []);
const { servers, cleanup } = await buildCcRemoteHttpMcpServers({
host: HOST, sessionId: 'bot-session', sessionInstanceId: 'bot-instance', workingDir: '/remote/bot', botSession,
- vendorOptions: { [CODEX_ALLOWED_BUILTIN_PLUGIN_IDS_KEY]: ['xdt_helper'] },
+ vendorOptions: { [CODEX_ALLOWED_BUILTIN_PLUGIN_IDS_KEY]: allowed },
}, {
ensureBridgeStarted: async () => ({ port: 38080, serverNames: ['cindy_helper', 'cindy_orca'], bridge }),
ensureForward: async () => 47921, getBridgeToken: () => 'remote-test-token', isCollabEnabled: () => false,
diff --git a/apps/desktop/src/main/maker-ipc/botProfileRuntime.ts b/apps/desktop/src/main/maker-ipc/botProfileRuntime.ts
index db8dea9858..f75706166b 100644
--- a/apps/desktop/src/main/maker-ipc/botProfileRuntime.ts
+++ b/apps/desktop/src/main/maker-ipc/botProfileRuntime.ts
@@ -792,7 +792,8 @@ export async function hydrateBotProfileRuntime(
displayName: profile.displayName,
identitySource: identity,
});
- const helperAvailable = !opts.remoteHostId || opts.agentKind === 'pi';
+ const helperAvailable = !opts.remoteHostId || opts.agentKind === 'pi'
+ || toolsetCatalog.some((item) => item.id === 'xdt_helper' && item.available !== false);
// 三层装配(见 botSystemPrompt.ts):身份与「你会做什么」进稳定段,会话控制等
// 进上下文段,技能索引与记忆快照进易变段并排在最后。能力说明按**这个伙伴
// 实际挂载到的 toolset** 注入 —— 挂了 docs 才讲怎么做文件,没挂的一个字不提。
diff --git a/apps/desktop/src/main/mcp-integrations/__tests__/codexHttpBridge.test.ts b/apps/desktop/src/main/mcp-integrations/__tests__/codexHttpBridge.test.ts
index 83ef6bbc92..228ac8b2a3 100644
--- a/apps/desktop/src/main/mcp-integrations/__tests__/codexHttpBridge.test.ts
+++ b/apps/desktop/src/main/mcp-integrations/__tests__/codexHttpBridge.test.ts
@@ -11,7 +11,9 @@ import {
type CodexHttpBridge,
withMcpRouteIdentity,
} from '../codexHttpBridge.js';
-import { CODEX_DISABLED_BUILTIN_PLUGIN_IDS_KEY } from '../codexBuiltinToolPolicy.js';
+import { CODEX_ALLOWED_BUILTIN_PLUGIN_IDS_KEY, CODEX_DISABLED_BUILTIN_PLUGIN_IDS_KEY } from '../codexBuiltinToolPolicy.js';
+import { isBotToolsetAvailableOnTarget } from '../../../shared/botRemoteCapabilities.js';
+import { resolveBotAllowedBuiltinPluginIds } from '../../maker-host/plugins/types.js';
function noopLogger(): Logger {
const logger: Logger = {
@@ -220,7 +222,14 @@ describe('codexHttpBridge', () => {
logger: noopLogger(),
});
const current = bridge;
- const ctx = { agentKind, sessionId: 'remote-bot', sessionInstanceId: 'remote-instance', remoteHostId: 'ssh-host', workingDir: '/bot' };
+ const allowed = resolveBotAllowedBuiltinPluginIds([{
+ id: 'xdt_helper',
+ available: isBotToolsetAvailableOnTarget({ agentKind, remoteHostId: 'ssh-host', toolsetId: 'xdt_helper' }),
+ }], []);
+ const ctx = {
+ agentKind, sessionId: 'remote-bot', sessionInstanceId: 'remote-instance', remoteHostId: 'ssh-host', workingDir: '/bot',
+ vendorOptions: { [CODEX_ALLOWED_BUILTIN_PLUGIN_IDS_KEY]: allowed },
+ };
if (agentKind === 'claude-code') current.registerSessionCtx(ctx.sessionId, ctx);
const url = withMcpRouteIdentity(current.url('cindy_helper'), {
sessionInstanceId: ctx.sessionInstanceId,
diff --git a/apps/desktop/src/shared/__tests__/botRemoteCapabilities.test.ts b/apps/desktop/src/shared/__tests__/botRemoteCapabilities.test.ts
index cc704b2277..4847002f1b 100644
--- a/apps/desktop/src/shared/__tests__/botRemoteCapabilities.test.ts
+++ b/apps/desktop/src/shared/__tests__/botRemoteCapabilities.test.ts
@@ -28,6 +28,11 @@ describe('isBotToolsetAvailableOnTarget', () => {
remoteHostId: 'host-1',
toolsetId: 'memory',
})).toBe(true);
+ expect(isBotToolsetAvailableOnTarget({
+ agentKind,
+ remoteHostId: 'host-1',
+ toolsetId: 'xdt_helper',
+ })).toBe(true);
expect(isBotToolsetAvailableOnTarget({
agentKind,
remoteHostId: 'host-1',
diff --git a/apps/desktop/src/shared/botRemoteCapabilities.ts b/apps/desktop/src/shared/botRemoteCapabilities.ts
index 3d8506d8e3..cbd2e5219c 100644
--- a/apps/desktop/src/shared/botRemoteCapabilities.ts
+++ b/apps/desktop/src/shared/botRemoteCapabilities.ts
@@ -8,7 +8,7 @@ import type { AgentKind } from '@cindy/maker-core';
* Keep this list in user-facing Plugin IDs: Bot profiles freeze Toolsets by
* Plugin ID, while the transport layer maps those IDs to MCP provider names.
*/
-const REMOTE_CC_CODEX_TOOLSET_IDS = new Set(['collab', 'memory']);
+const REMOTE_CC_CODEX_TOOLSET_IDS = new Set(['collab', 'memory', 'xdt_helper']);
export function isBotToolsetAvailableOnTarget(input: {
agentKind: AgentKind;