feat: add optional MindSearch skill orchestration

This commit is contained in:
john
2026-07-15 13:46:17 +08:00
parent 87b03f7848
commit 5f1c4dcaca
17 changed files with 373 additions and 2 deletions
+19 -1
View File
@@ -15,6 +15,12 @@ export function resolveSandboxMcpNodeExecPath(overridePath) {
return process.execPath;
}
export function resolveMindSearchMcpServerPath(overridePath) {
const normalized = String(overridePath ?? '').trim();
if (normalized) return normalized;
return path.join(path.dirname(fileURLToPath(import.meta.url)), 'tkmind-search-mcp.mjs');
}
export const CAPABILITY_CATALOG = [
{
key: 'shell',
@@ -130,6 +136,13 @@ export const CAPABILITY_CATALOG = [
risk: 'medium',
category: 'knowledge',
},
{
key: 'search_external',
label: 'MindSearch 外部搜索增强',
description: '可插拔的外部搜索补充能力;不替代现有网页搜索,默认关闭',
risk: 'medium',
category: 'knowledge',
},
{
key: 'computer',
label: '电脑控制',
@@ -190,6 +203,7 @@ export const DEFAULT_USER_CAPABILITIES = Object.fromEntries(
apps: false,
todo: false,
web: true,
search_external: false,
computer: false,
charts: false,
aider: false,
@@ -323,7 +337,7 @@ function sandboxMcpEnvs(sandboxMcp, mcpTools) {
*/
export function buildAgentExtensionPolicy(
capabilities,
{ unrestricted = false, policies = null, sandboxMcp = null, toolMode = 'chat' } = {},
{ unrestricted = false, policies = null, sandboxMcp = null, toolMode = 'chat', mindSearchConfig = null } = {},
) {
if (unrestricted) {
return { extensionOverrides: null, enableContextMemory: true, gooseMode: 'auto' };
@@ -416,6 +430,10 @@ export function buildAgentExtensionPolicy(
if (capabilities.web) {
extensions.push(makeExtension('platform', 'web', ['web_search', 'fetch_url']));
}
const searchEnabled = capabilities.search_external && mindSearchConfig?.enabled && mindSearchConfig.mode !== 'off';
if (searchEnabled && (!policies || policies.network_egress !== 'deny')) {
extensions.push({ type: 'stdio', name: 'tkmind-search', description: 'MindSearch 外部搜索增强(补充能力)', display_name: 'tkmind-search', bundled: false, cmd: resolveSandboxMcpNodeExecPath(process.env.GOOSED_MCP_NODE_PATH), args: [resolveMindSearchMcpServerPath(process.env.TKMIND_SEARCH_MCP_SERVER_PATH)], envs: { TKMIND_SEARCH_ENABLED: '1', TKMIND_SEARCH_MODE: mindSearchConfig.mode, TKMIND_SEARCH_PROVIDER_SEARXNG_ENABLED: mindSearchConfig.providers?.searxng ? '1' : '0', TKMIND_SEARCH_PROVIDER_GITHUB_ENABLED: mindSearchConfig.providers?.github ? '1' : '0', TKMIND_SEARCH_READER_ENABLED: mindSearchConfig.providers?.reader ? '1' : '0', TKMIND_SEARCH_SEARXNG_URL: mindSearchConfig.settings?.searxngEndpoint ?? '', TKMIND_SEARCH_MAX_RESULTS: String(mindSearchConfig.settings?.maxResults ?? 10), TKMIND_SEARCH_TIMEOUT_MS: String(mindSearchConfig.settings?.timeoutMs ?? 8000), TKMIND_SEARCH_READER_MAX_CHARS: String(mindSearchConfig.settings?.readerMaxChars ?? 12000) }, available_tools: ['tkmind_search', 'tkmind_read'] });
}
if (capabilities.computer) {
extensions.push(makeExtension('builtin', 'computercontroller', []));
}