@roarpeng/graphflow 1.7.0 → 1.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -0
- package/README.md +11 -7
- package/dist/agents/insight.d.ts +13 -2
- package/dist/agents/insight.d.ts.map +1 -1
- package/dist/agents/insight.js +56 -26
- package/dist/agents/insight.js.map +1 -1
- package/dist/agents/task-profile.d.ts +19 -0
- package/dist/agents/task-profile.d.ts.map +1 -0
- package/dist/agents/task-profile.js +64 -0
- package/dist/agents/task-profile.js.map +1 -0
- package/dist/agents/validator.js +1 -1
- package/dist/agents/validator.js.map +1 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +3 -1
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/discover-workspace.d.ts.map +1 -1
- package/dist/config/discover-workspace.js +9 -2
- package/dist/config/discover-workspace.js.map +1 -1
- package/dist/config/embedding-factory.d.ts.map +1 -1
- package/dist/config/embedding-factory.js +88 -9
- package/dist/config/embedding-factory.js.map +1 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +9 -2
- package/dist/config/loader.js.map +1 -1
- package/dist/config/provider-env.d.ts +32 -0
- package/dist/config/provider-env.d.ts.map +1 -0
- package/dist/config/provider-env.js +51 -0
- package/dist/config/provider-env.js.map +1 -0
- package/dist/config/resolve.d.ts.map +1 -1
- package/dist/config/resolve.js +7 -2
- package/dist/config/resolve.js.map +1 -1
- package/dist/config/schema.d.ts +17 -2
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/workspace-root.d.ts +0 -12
- package/dist/config/workspace-root.d.ts.map +1 -1
- package/dist/config/workspace-root.js +21 -5
- package/dist/config/workspace-root.js.map +1 -1
- package/dist/core/agent-delegation.d.ts +5 -0
- package/dist/core/agent-delegation.d.ts.map +1 -1
- package/dist/core/agent-delegation.js +131 -57
- package/dist/core/agent-delegation.js.map +1 -1
- package/dist/core/cancellation.d.ts +57 -0
- package/dist/core/cancellation.d.ts.map +1 -0
- package/dist/core/cancellation.js +195 -0
- package/dist/core/cancellation.js.map +1 -0
- package/dist/core/dag-engine.d.ts +6 -1
- package/dist/core/dag-engine.d.ts.map +1 -1
- package/dist/core/dag-engine.js +67 -9
- package/dist/core/dag-engine.js.map +1 -1
- package/dist/core/orchestrator-context.d.ts.map +1 -1
- package/dist/core/orchestrator-context.js +3 -0
- package/dist/core/orchestrator-context.js.map +1 -1
- package/dist/core/orchestrator-route.d.ts +1 -1
- package/dist/core/orchestrator-route.d.ts.map +1 -1
- package/dist/core/orchestrator-route.js.map +1 -1
- package/dist/core/orchestrator.js +6 -1
- package/dist/core/orchestrator.js.map +1 -1
- package/dist/core/runtime-controller.d.ts +19 -0
- package/dist/core/runtime-controller.d.ts.map +1 -0
- package/dist/core/runtime-controller.js +89 -0
- package/dist/core/runtime-controller.js.map +1 -0
- package/dist/core/types.d.ts +5 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/graph/context-slicer-types.d.ts +2 -0
- package/dist/graph/context-slicer-types.d.ts.map +1 -1
- package/dist/graph/context-slicer-types.js.map +1 -1
- package/dist/graph/context-slicer.d.ts +1 -0
- package/dist/graph/context-slicer.d.ts.map +1 -1
- package/dist/graph/context-slicer.js +54 -8
- package/dist/graph/context-slicer.js.map +1 -1
- package/dist/graph/file-watcher.d.ts.map +1 -1
- package/dist/graph/file-watcher.js +9 -2
- package/dist/graph/file-watcher.js.map +1 -1
- package/dist/graph/graph-utils.d.ts +6 -1
- package/dist/graph/graph-utils.d.ts.map +1 -1
- package/dist/graph/graph-utils.js +116 -2
- package/dist/graph/graph-utils.js.map +1 -1
- package/dist/graph/graphify-file-client.d.ts.map +1 -1
- package/dist/graph/graphify-file-client.js +2 -1
- package/dist/graph/graphify-file-client.js.map +1 -1
- package/dist/graph/hit-diversify.d.ts +31 -0
- package/dist/graph/hit-diversify.d.ts.map +1 -0
- package/dist/graph/hit-diversify.js +270 -0
- package/dist/graph/hit-diversify.js.map +1 -0
- package/dist/graph/language-indexers/go.d.ts.map +1 -1
- package/dist/graph/language-indexers/go.js +2 -3
- package/dist/graph/language-indexers/go.js.map +1 -1
- package/dist/graph/language-indexers/incremental-parse.d.ts +9 -0
- package/dist/graph/language-indexers/incremental-parse.d.ts.map +1 -0
- package/dist/graph/language-indexers/incremental-parse.js +114 -0
- package/dist/graph/language-indexers/incremental-parse.js.map +1 -0
- package/dist/graph/language-indexers/python.d.ts.map +1 -1
- package/dist/graph/language-indexers/python.js +2 -3
- package/dist/graph/language-indexers/python.js.map +1 -1
- package/dist/graph/language-indexers/rust.d.ts.map +1 -1
- package/dist/graph/language-indexers/rust.js +2 -3
- package/dist/graph/language-indexers/rust.js.map +1 -1
- package/dist/graph/language-indexers/tree-sitter-loader.d.ts +19 -3
- package/dist/graph/language-indexers/tree-sitter-loader.d.ts.map +1 -1
- package/dist/graph/language-indexers/tree-sitter-loader.js +24 -4
- package/dist/graph/language-indexers/tree-sitter-loader.js.map +1 -1
- package/dist/graph/query-expand.d.ts.map +1 -1
- package/dist/graph/query-expand.js +2 -0
- package/dist/graph/query-expand.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/agent-mcp-installer.d.ts +39 -0
- package/dist/integrations/agent-mcp-installer.d.ts.map +1 -1
- package/dist/integrations/agent-mcp-installer.js +220 -14
- package/dist/integrations/agent-mcp-installer.js.map +1 -1
- package/dist/learning/embedding-quality.d.ts +46 -0
- package/dist/learning/embedding-quality.d.ts.map +1 -0
- package/dist/learning/embedding-quality.js +131 -0
- package/dist/learning/embedding-quality.js.map +1 -0
- package/dist/learning/embeddings.d.ts +45 -1
- package/dist/learning/embeddings.d.ts.map +1 -1
- package/dist/learning/embeddings.js +180 -5
- package/dist/learning/embeddings.js.map +1 -1
- package/dist/learning/skill-flywheel.d.ts +1 -1
- package/dist/learning/skill-flywheel.d.ts.map +1 -1
- package/dist/learning/skill-flywheel.js +10 -3
- package/dist/learning/skill-flywheel.js.map +1 -1
- package/dist/routing/deepseek-tools.d.ts +7 -0
- package/dist/routing/deepseek-tools.d.ts.map +1 -0
- package/dist/routing/deepseek-tools.js +154 -0
- package/dist/routing/deepseek-tools.js.map +1 -0
- package/dist/routing/model-router.d.ts +1 -1
- package/dist/routing/model-router.d.ts.map +1 -1
- package/dist/routing/model-router.js +5 -1
- package/dist/routing/model-router.js.map +1 -1
- package/dist/routing/provider-adapters/anthropic.d.ts.map +1 -1
- package/dist/routing/provider-adapters/anthropic.js +7 -4
- package/dist/routing/provider-adapters/anthropic.js.map +1 -1
- package/dist/routing/provider-adapters/bailian.d.ts.map +1 -1
- package/dist/routing/provider-adapters/bailian.js +7 -4
- package/dist/routing/provider-adapters/bailian.js.map +1 -1
- package/dist/routing/provider-adapters/deepseek.d.ts +5 -0
- package/dist/routing/provider-adapters/deepseek.d.ts.map +1 -0
- package/dist/routing/provider-adapters/deepseek.js +109 -0
- package/dist/routing/provider-adapters/deepseek.js.map +1 -0
- package/dist/routing/provider-adapters/doubao.d.ts.map +1 -1
- package/dist/routing/provider-adapters/doubao.js +7 -4
- package/dist/routing/provider-adapters/doubao.js.map +1 -1
- package/dist/routing/provider-adapters/openai.d.ts +2 -4
- package/dist/routing/provider-adapters/openai.d.ts.map +1 -1
- package/dist/routing/provider-adapters/openai.js +23 -32
- package/dist/routing/provider-adapters/openai.js.map +1 -1
- package/dist/routing/provider-adapters/types.d.ts +61 -0
- package/dist/routing/provider-adapters/types.d.ts.map +1 -0
- package/dist/routing/provider-adapters/types.js +56 -0
- package/dist/routing/provider-adapters/types.js.map +1 -0
- package/dist/routing/provider-executor.d.ts +6 -1
- package/dist/routing/provider-executor.d.ts.map +1 -1
- package/dist/routing/provider-executor.js +70 -39
- package/dist/routing/provider-executor.js.map +1 -1
- package/dist/routing/provider-health.d.ts.map +1 -1
- package/dist/routing/provider-health.js +7 -1
- package/dist/routing/provider-health.js.map +1 -1
- package/dist/routing/role-capabilities.d.ts +11 -0
- package/dist/routing/role-capabilities.d.ts.map +1 -0
- package/dist/routing/role-capabilities.js +94 -0
- package/dist/routing/role-capabilities.js.map +1 -0
- package/dist/surfaces/antigravity-rules/graphflow.md +3 -2
- package/dist/surfaces/cli/runtime/env.d.ts.map +1 -1
- package/dist/surfaces/cli/runtime/env.js +3 -0
- package/dist/surfaces/cli/runtime/env.js.map +1 -1
- package/dist/surfaces/cli/runtime/facade.d.ts +2 -1
- package/dist/surfaces/cli/runtime/facade.d.ts.map +1 -1
- package/dist/surfaces/cli/runtime/facade.js +1 -0
- package/dist/surfaces/cli/runtime/facade.js.map +1 -1
- package/dist/surfaces/cli/runtime/graph.d.ts.map +1 -1
- package/dist/surfaces/cli/runtime/graph.js +7 -0
- package/dist/surfaces/cli/runtime/graph.js.map +1 -1
- package/dist/surfaces/cli/runtime/routing.d.ts +3 -0
- package/dist/surfaces/cli/runtime/routing.d.ts.map +1 -1
- package/dist/surfaces/cli/runtime/routing.js +31 -4
- package/dist/surfaces/cli/runtime/routing.js.map +1 -1
- package/dist/surfaces/cli/runtime/types.d.ts +23 -1
- package/dist/surfaces/cli/runtime/types.d.ts.map +1 -1
- package/dist/surfaces/cli/runtime.d.ts +1 -1
- package/dist/surfaces/cli/runtime.d.ts.map +1 -1
- package/dist/surfaces/cli/runtime.js +2 -1
- package/dist/surfaces/cli/runtime.js.map +1 -1
- package/dist/surfaces/copilot-instructions/graphflow.md +3 -2
- package/dist/surfaces/cursor-rules/graphflow.mdc +3 -2
- package/dist/surfaces/mcp/server.js +17 -6
- package/dist/surfaces/mcp/server.js.map +1 -1
- package/dist/surfaces/mcp/tool-definitions.d.ts.map +1 -1
- package/dist/surfaces/mcp/tool-definitions.js +1 -1
- package/dist/surfaces/mcp/tool-definitions.js.map +1 -1
- package/dist/surfaces/mcp/tool-handlers.d.ts.map +1 -1
- package/dist/surfaces/mcp/tool-handlers.js +2 -0
- package/dist/surfaces/mcp/tool-handlers.js.map +1 -1
- package/dist/surfaces/trae-rules/graphflow.md +3 -2
- package/dist/surfaces/trae-skill/graphflow/SKILL.md +2 -0
- package/package.json +1 -1
- package/src/surfaces/antigravity-rules/graphflow.md +3 -2
- package/src/surfaces/copilot-instructions/graphflow.md +3 -2
- package/src/surfaces/cursor-rules/graphflow.mdc +3 -2
- package/src/surfaces/trae-rules/graphflow.md +3 -2
- package/src/surfaces/trae-skill/graphflow/SKILL.md +2 -0
|
@@ -9,6 +9,8 @@ const node_module_1 = require("node:module");
|
|
|
9
9
|
const requireFn = (0, node_module_1.createRequire)(__filename);
|
|
10
10
|
let initPromise = null;
|
|
11
11
|
const WASM_CACHE_DIR = (0, node_path_1.join)(process.cwd(), ".graphflow-cache", "wasm");
|
|
12
|
+
const languageLoadPromises = new Map();
|
|
13
|
+
const parserPool = new Map();
|
|
12
14
|
function wasmFileName(language) {
|
|
13
15
|
return `tree-sitter-${language}.wasm`;
|
|
14
16
|
}
|
|
@@ -65,18 +67,36 @@ function resolveTreeSitterWasmsPath(fileName) {
|
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
async function getTreeSitterParser(language) {
|
|
70
|
+
const pooledParser = parserPool.get(language);
|
|
71
|
+
if (pooledParser) {
|
|
72
|
+
return pooledParser;
|
|
73
|
+
}
|
|
74
|
+
const parserPromise = createTreeSitterParser(language);
|
|
75
|
+
parserPool.set(language, parserPromise);
|
|
76
|
+
return parserPromise;
|
|
77
|
+
}
|
|
78
|
+
async function createTreeSitterParser(language) {
|
|
68
79
|
if (!initPromise) {
|
|
69
80
|
initPromise = Parser.init();
|
|
70
81
|
}
|
|
71
82
|
await initPromise;
|
|
83
|
+
const parser = new Parser();
|
|
84
|
+
const lang = await loadTreeSitterLanguage(language);
|
|
85
|
+
parser.setLanguage(lang);
|
|
86
|
+
return parser;
|
|
87
|
+
}
|
|
88
|
+
async function loadTreeSitterLanguage(language) {
|
|
89
|
+
const cachedLanguage = languageLoadPromises.get(language);
|
|
90
|
+
if (cachedLanguage) {
|
|
91
|
+
return cachedLanguage;
|
|
92
|
+
}
|
|
72
93
|
const wasmPath = resolveBundledWasmPath(language);
|
|
73
94
|
if (!wasmPath) {
|
|
74
95
|
throw new Error(`Bundled tree-sitter grammar not found for "${language}". ` +
|
|
75
96
|
"Reinstall @roarpeng/graphflow or run `npm run wasm:bundle` in the GraphFlow source tree.");
|
|
76
97
|
}
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return parser;
|
|
98
|
+
const languagePromise = Parser.Language.load(wasmPath);
|
|
99
|
+
languageLoadPromises.set(language, languagePromise);
|
|
100
|
+
return languagePromise;
|
|
81
101
|
}
|
|
82
102
|
//# sourceMappingURL=tree-sitter-loader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-sitter-loader.js","sourceRoot":"","sources":["../../../src/graph/language-indexers/tree-sitter-loader.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"tree-sitter-loader.js","sourceRoot":"","sources":["../../../src/graph/language-indexers/tree-sitter-loader.ts"],"names":[],"mappings":";;AAqFA,wDAgBC;AAuBD,kDAWC;AAvID,MAAM,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAC1C,qCAAqC;AACrC,yCAA0C;AAC1C,6CAA4C;AAE5C,MAAM,SAAS,GAAG,IAAA,2BAAa,EAAC,UAAU,CAAC,CAAC;AAE5C,IAAI,WAAW,GAAyB,IAAI,CAAC;AAqD7C,MAAM,cAAc,GAAG,IAAA,gBAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,kBAAkB,EAAE,MAAM,CAAC,CAAC;AACvE,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAwC,CAAC;AAC7E,MAAM,UAAU,GAAG,IAAI,GAAG,EAAiD,CAAC;AAE5E,SAAS,YAAY,CAAC,QAA4B;IAChD,OAAO,eAAe,QAAQ,OAAO,CAAC;AACxC,CAAC;AAED,SAAS,WAAW,CAA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,QAAQ,GAAG,sBAAsB,CAAC,QAAQ,CAAC,CAAC;IAClD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACb,8CAA8C,QAAQ,KAAK;YACzD,0FAA0F,CAC7F,CAAC;IACJ,CAAC;IAED,MAAM,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAqB,CAAC;IAC3E,oBAAoB,CAAC,GAAG,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IACpD,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-expand.d.ts","sourceRoot":"","sources":["../../src/graph/query-expand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAKvD;;;GAGG;AACH,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,MAAM,EACb,aAAa,CAAC,EAAE,MAAM,EACtB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,SAAS,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"query-expand.d.ts","sourceRoot":"","sources":["../../src/graph/query-expand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAKvD;;;GAGG;AACH,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,MAAM,EACb,aAAa,CAAC,EAAE,MAAM,EACtB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,SAAS,EAAE,CAAC,CAwBtB"}
|
|
@@ -12,6 +12,7 @@ async function collectExpandedKeywordHits(client, query, workspaceRoot, englishQ
|
|
|
12
12
|
const queries = (0, graph_utils_js_1.expandSearchQueries)(query, workspaceRoot, englishQuery);
|
|
13
13
|
const baseScoreTokens = (0, graph_utils_js_1.buildSearchScoreTokens)(query, englishQuery);
|
|
14
14
|
const matchQueries = englishQuery?.trim() ? [query, englishQuery.trim()] : [query];
|
|
15
|
+
const pathHints = (0, graph_utils_js_1.extractPathTokens)(workspaceRoot);
|
|
15
16
|
const rankings = [];
|
|
16
17
|
for (const q of queries) {
|
|
17
18
|
const hits = await client.queryByKeyword(q);
|
|
@@ -19,6 +20,7 @@ async function collectExpandedKeywordHits(client, query, workspaceRoot, englishQ
|
|
|
19
20
|
rankings.push((0, graph_utils_js_2.rankNodesForContextQuery)(hits, query, {
|
|
20
21
|
scoreTokens: scoreTokens.length > 0 ? scoreTokens : baseScoreTokens,
|
|
21
22
|
matchQueries,
|
|
23
|
+
pathHints,
|
|
22
24
|
}));
|
|
23
25
|
}
|
|
24
26
|
if (rankings.length <= 1) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-expand.js","sourceRoot":"","sources":["../../src/graph/query-expand.ts"],"names":[],"mappings":";;AAUA,
|
|
1
|
+
{"version":3,"file":"query-expand.js","sourceRoot":"","sources":["../../src/graph/query-expand.ts"],"names":[],"mappings":";;AAUA,gEA6BC;AArCD,6DAAiE;AACjE,qDAAkG;AAClG,qDAA4D;AAE5D;;;GAGG;AACI,KAAK,UAAU,0BAA0B,CAC9C,MAAmB,EACnB,KAAa,EACb,aAAsB,EACtB,YAAqB;IAErB,MAAM,OAAO,GAAG,IAAA,oCAAmB,EAAC,KAAK,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;IACxE,MAAM,eAAe,GAAG,IAAA,uCAAsB,EAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IACpE,MAAM,YAAY,GAAG,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACnF,MAAM,SAAS,GAAG,IAAA,kCAAiB,EAAC,aAAa,CAAC,CAAC;IACnD,MAAM,QAAQ,GAAkB,EAAE,CAAC;IAEnC,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;QAC5C,MAAM,WAAW,GAAG,IAAA,uCAAsB,EAAC,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;QACnE,QAAQ,CAAC,IAAI,CACX,IAAA,yCAAwB,EAAC,IAAI,EAAE,KAAK,EAAE;YACpC,WAAW,EAAE,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,eAAe;YACnE,YAAY;YACZ,SAAS;SACV,CAAC,CACH,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QACzB,OAAO,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED,OAAO,IAAA,oCAAoB,EAAC,QAAQ,CAAC,CAAC;AACxC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { orchestrate, type OrchestrateOptions } from "./core/orchestrator";
|
|
2
|
-
export { runTask, runTaskResult, reportOutcome, submitAgentInsightResult, mergeAgentInsightResult, previewContext, expandAnchor, getGraphFlowSettings, getSettingsPanelStatus, testRoutingAndIndexGraph, indexGraphFromSettings, validateSettingsForGraphIndex, validateSettingsForRouting, saveGraphFlowSettings, indexGraph, inspectGraph, getSkillInsights, resolveConfig, diagnoseRouting, diagnoseRoutingResult, planAndBrainstorm, planAndBrainstormResult, assertGraphFlowRuntime, detectInstalledAgents, formatModelConfigGuide, installMcpToDetectedAgents, runLearningNightly, runLearningNightlyResult, startFileWatcherIfEnabled, } from "./surfaces/cli/runtime";
|
|
2
|
+
export { runTask, runTaskResult, reportOutcome, submitAgentInsightResult, mergeAgentInsightResult, previewContext, expandAnchor, getGraphFlowSettings, getSettingsPanelStatus, testRoutingAndIndexGraph, indexGraphFromSettings, validateSettingsForGraphIndex, validateSettingsForRouting, saveGraphFlowSettings, indexGraph, inspectGraph, getSkillInsights, resolveConfig, diagnoseRouting, diagnoseRoutingResult, planAndBrainstorm, planAndBrainstormResult, assertGraphFlowRuntime, detectInstalledAgents, formatModelConfigGuide, installMcpToDetectedAgents, repairUnsafeWindowsMcpCommands, runLearningNightly, runLearningNightlyResult, startFileWatcherIfEnabled, } from "./surfaces/cli/runtime";
|
|
3
3
|
export type { GraphFlowRuntime, GraphFlowRuntimeModule, LearningNightlyResult } from "./surfaces/cli/runtime";
|
|
4
4
|
export { parseCliOptions, formatCliResult, type CliCommandResult } from "./surfaces/cli/output";
|
|
5
5
|
export { createMcpServer, executeToolCall, getToolDefinitions, startStdioServer, } from "./surfaces/mcp/server";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EACL,OAAO,EACP,aAAa,EACb,aAAa,EACb,wBAAwB,EACxB,uBAAuB,EACvB,cAAc,EACd,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,6BAA6B,EAC7B,0BAA0B,EAC1B,qBAAqB,EACrB,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,EAC1B,kBAAkB,EAClB,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,wBAAwB,CAAC;AAChC,YAAY,E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,cAAc,EAAE,KAAK,gBAAgB,EAAE,sBAAsB,EAAE,KAAK,sBAAsB,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC/K,OAAO,EACL,eAAe,EACf,WAAW,EACX,UAAU,EACV,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,aAAa,GACnB,MAAM,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.listSkills = exports.invokeSkill = exports.graphflowSkills = exports.validateConfigDetailed = exports.loadConfigSafe = exports.loadConfig = exports.validateConfig = exports.createGraphClient = exports.planInsightResult = exports.summarizeInsightForContext = exports.buildAgentInsightWorkItems = exports.buildAgentDelegatedPlanInsight = exports.hasUsableLlmProvider = exports.startStdioServer = exports.getToolDefinitions = exports.executeToolCall = exports.createMcpServer = exports.formatCliResult = exports.parseCliOptions = exports.startFileWatcherIfEnabled = exports.runLearningNightlyResult = exports.runLearningNightly = exports.installMcpToDetectedAgents = exports.formatModelConfigGuide = exports.detectInstalledAgents = exports.assertGraphFlowRuntime = exports.planAndBrainstormResult = exports.planAndBrainstorm = exports.diagnoseRoutingResult = exports.diagnoseRouting = exports.resolveConfig = exports.getSkillInsights = exports.inspectGraph = exports.indexGraph = exports.saveGraphFlowSettings = exports.validateSettingsForRouting = exports.validateSettingsForGraphIndex = exports.indexGraphFromSettings = exports.testRoutingAndIndexGraph = exports.getSettingsPanelStatus = exports.getGraphFlowSettings = exports.expandAnchor = exports.previewContext = exports.mergeAgentInsightResult = exports.submitAgentInsightResult = exports.reportOutcome = exports.runTaskResult = exports.runTask = exports.orchestrate = void 0;
|
|
3
|
+
exports.listSkills = exports.invokeSkill = exports.graphflowSkills = exports.validateConfigDetailed = exports.loadConfigSafe = exports.loadConfig = exports.validateConfig = exports.createGraphClient = exports.planInsightResult = exports.summarizeInsightForContext = exports.buildAgentInsightWorkItems = exports.buildAgentDelegatedPlanInsight = exports.hasUsableLlmProvider = exports.startStdioServer = exports.getToolDefinitions = exports.executeToolCall = exports.createMcpServer = exports.formatCliResult = exports.parseCliOptions = exports.startFileWatcherIfEnabled = exports.runLearningNightlyResult = exports.runLearningNightly = exports.repairUnsafeWindowsMcpCommands = exports.installMcpToDetectedAgents = exports.formatModelConfigGuide = exports.detectInstalledAgents = exports.assertGraphFlowRuntime = exports.planAndBrainstormResult = exports.planAndBrainstorm = exports.diagnoseRoutingResult = exports.diagnoseRouting = exports.resolveConfig = exports.getSkillInsights = exports.inspectGraph = exports.indexGraph = exports.saveGraphFlowSettings = exports.validateSettingsForRouting = exports.validateSettingsForGraphIndex = exports.indexGraphFromSettings = exports.testRoutingAndIndexGraph = exports.getSettingsPanelStatus = exports.getGraphFlowSettings = exports.expandAnchor = exports.previewContext = exports.mergeAgentInsightResult = exports.submitAgentInsightResult = exports.reportOutcome = exports.runTaskResult = exports.runTask = exports.orchestrate = void 0;
|
|
4
4
|
var orchestrator_1 = require("./core/orchestrator");
|
|
5
5
|
Object.defineProperty(exports, "orchestrate", { enumerable: true, get: function () { return orchestrator_1.orchestrate; } });
|
|
6
6
|
var runtime_1 = require("./surfaces/cli/runtime");
|
|
@@ -30,6 +30,7 @@ Object.defineProperty(exports, "assertGraphFlowRuntime", { enumerable: true, get
|
|
|
30
30
|
Object.defineProperty(exports, "detectInstalledAgents", { enumerable: true, get: function () { return runtime_1.detectInstalledAgents; } });
|
|
31
31
|
Object.defineProperty(exports, "formatModelConfigGuide", { enumerable: true, get: function () { return runtime_1.formatModelConfigGuide; } });
|
|
32
32
|
Object.defineProperty(exports, "installMcpToDetectedAgents", { enumerable: true, get: function () { return runtime_1.installMcpToDetectedAgents; } });
|
|
33
|
+
Object.defineProperty(exports, "repairUnsafeWindowsMcpCommands", { enumerable: true, get: function () { return runtime_1.repairUnsafeWindowsMcpCommands; } });
|
|
33
34
|
Object.defineProperty(exports, "runLearningNightly", { enumerable: true, get: function () { return runtime_1.runLearningNightly; } });
|
|
34
35
|
Object.defineProperty(exports, "runLearningNightlyResult", { enumerable: true, get: function () { return runtime_1.runLearningNightlyResult; } });
|
|
35
36
|
Object.defineProperty(exports, "startFileWatcherIfEnabled", { enumerable: true, get: function () { return runtime_1.startFileWatcherIfEnabled; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,oDAA2E;AAAlE,2GAAA,WAAW,OAAA;AACpB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,oDAA2E;AAAlE,2GAAA,WAAW,OAAA;AACpB,kDA+BgC;AA9B9B,kGAAA,OAAO,OAAA;AACP,wGAAA,aAAa,OAAA;AACb,wGAAA,aAAa,OAAA;AACb,mHAAA,wBAAwB,OAAA;AACxB,kHAAA,uBAAuB,OAAA;AACvB,yGAAA,cAAc,OAAA;AACd,uGAAA,YAAY,OAAA;AACZ,+GAAA,oBAAoB,OAAA;AACpB,iHAAA,sBAAsB,OAAA;AACtB,mHAAA,wBAAwB,OAAA;AACxB,iHAAA,sBAAsB,OAAA;AACtB,wHAAA,6BAA6B,OAAA;AAC7B,qHAAA,0BAA0B,OAAA;AAC1B,gHAAA,qBAAqB,OAAA;AACrB,qGAAA,UAAU,OAAA;AACV,uGAAA,YAAY,OAAA;AACZ,2GAAA,gBAAgB,OAAA;AAChB,wGAAA,aAAa,OAAA;AACb,0GAAA,eAAe,OAAA;AACf,gHAAA,qBAAqB,OAAA;AACrB,4GAAA,iBAAiB,OAAA;AACjB,kHAAA,uBAAuB,OAAA;AACvB,iHAAA,sBAAsB,OAAA;AACtB,gHAAA,qBAAqB,OAAA;AACrB,iHAAA,sBAAsB,OAAA;AACtB,qHAAA,0BAA0B,OAAA;AAC1B,yHAAA,8BAA8B,OAAA;AAC9B,6GAAA,kBAAkB,OAAA;AAClB,mHAAA,wBAAwB,OAAA;AACxB,oHAAA,yBAAyB,OAAA;AAG3B,gDAAgG;AAAvF,yGAAA,eAAe,OAAA;AAAE,yGAAA,eAAe,OAAA;AACzC,gDAK+B;AAJ7B,yGAAA,eAAe,OAAA;AACf,yGAAA,eAAe,OAAA;AACf,4GAAA,kBAAkB,OAAA;AAClB,0GAAA,gBAAgB,OAAA;AAGlB,8DAAiE;AAAxD,wHAAA,oBAAoB,OAAA;AAC7B,4DAOiC;AAN/B,kIAAA,8BAA8B,OAAA;AAC9B,8HAAA,0BAA0B,OAAA;AAC1B,8HAAA,0BAA0B,OAAA;AAK5B,0DAA2F;AAAlF,4GAAA,iBAAiB,OAAA;AAC1B,yDAGgC;AAF9B,mHAAA,iBAAiB,OAAA;AAGnB,0CAA+K;AAAtK,wGAAA,cAAc,OAAA;AAAE,oGAAA,UAAU,OAAA;AAAE,wGAAA,cAAc,OAAA;AAAyB,gHAAA,sBAAsB,OAAA;AAClG,mCAqBkB;AApBhB,yGAAA,eAAe,OAAA;AACf,qGAAA,WAAW,OAAA;AACX,oGAAA,UAAU,OAAA"}
|
|
@@ -84,6 +84,45 @@ export declare function resolveMcpNodeLaunch(options: {
|
|
|
84
84
|
command: string;
|
|
85
85
|
env: Record<string, string>;
|
|
86
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* On Windows, convert a long path containing spaces to its 8.3 short form.
|
|
89
|
+
* Many MCP clients (e.g., TRAE) spawn the `command` field via cmd.exe without
|
|
90
|
+
* quoting, so paths like "C:\Program Files\..." break with "'C:\Program' is not
|
|
91
|
+
* recognized". The 8.3 short name (e.g., "C:\PROGRA~1\...") avoids this entirely.
|
|
92
|
+
*/
|
|
93
|
+
export declare function getWindowsShortPath(longPath: string): string | undefined;
|
|
94
|
+
/** Prefer 8.3 short path on Windows when the input contains spaces; otherwise keep as-is. */
|
|
95
|
+
export declare function preferSpaceFreeWindowsPath(pathValue: string): string;
|
|
96
|
+
/**
|
|
97
|
+
* Final guard for MCP clients (notably Trae) that spawn `command` via cmd.exe
|
|
98
|
+
* without quoting. Ensures install-time configs never write spaced absolute paths.
|
|
99
|
+
*/
|
|
100
|
+
export declare function sanitizeMcpServerNodeForWindowsClients(node: McpServerNode): McpServerNode;
|
|
101
|
+
/** True when command/cwd/path-like args still contain spaces (unsafe for unquoted cmd spawn). */
|
|
102
|
+
export declare function mcpNodeNeedsWindowsSpaceRepair(node: McpServerNode): boolean;
|
|
103
|
+
export interface McpWindowsSpaceRepairResult {
|
|
104
|
+
agentId: string;
|
|
105
|
+
agentName: string;
|
|
106
|
+
configPath: string;
|
|
107
|
+
repaired: boolean;
|
|
108
|
+
beforeCommand?: string;
|
|
109
|
+
afterCommand?: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Painless migrate: rewrite existing GraphFlow MCP entries that still use spaced
|
|
113
|
+
* absolute paths (e.g. Program Files). Scans every known agent config path that
|
|
114
|
+
* exists — not only currently "detected" markers — so Trae / Trae CN / TRAE SOLO
|
|
115
|
+
* variants are all fixed on extension activate without a manual Install click.
|
|
116
|
+
*/
|
|
117
|
+
export declare function repairUnsafeWindowsMcpCommands(serverName?: string, options?: {
|
|
118
|
+
/** Test/injection hook — override scanned targets. */
|
|
119
|
+
targets?: Array<{
|
|
120
|
+
agentId: string;
|
|
121
|
+
agentName: string;
|
|
122
|
+
configPath: string;
|
|
123
|
+
serversKey: McpServersKey;
|
|
124
|
+
}>;
|
|
125
|
+
}): McpWindowsSpaceRepairResult[];
|
|
87
126
|
export declare function buildMcpServerNode(options: McpInstallOptions): McpServerNode;
|
|
88
127
|
/** 从 JSON 配置文件中移除指定 MCP 服务器的配置条目 */
|
|
89
128
|
export declare function removeMcpEntry(configPath: string, serversKey: McpServersKey, serverName: string): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-mcp-installer.d.ts","sourceRoot":"","sources":["../../src/integrations/agent-mcp-installer.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,SAAS,GAAG,iBAAiB,CAAC;AAEzE,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,YAAY,GAAG,cAAc,CAAC;AACvE,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,KAAK,CAAC;AAE7C,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,2EAA2E;IAC3E,YAAY,CAAC,EAAE,eAAe,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,6FAA6F;IAC7F,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oFAAoF;IACpF,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,uFAAuF;IACvF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2FAA2F;IAC3F,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gFAAgF;IAChF,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,aAAa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AC,EAAE,gBAAgB,GAAG,eAAe,EAAE,CAmD5F;AAED,wBAAgB,sBAAsB,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CA+BrE"}
|
|
@@ -8,6 +8,11 @@ exports.isEphemeralNodePath = isEphemeralNodePath;
|
|
|
8
8
|
exports.isIdeBundledNode = isIdeBundledNode;
|
|
9
9
|
exports.resolveSystemNodeCommand = resolveSystemNodeCommand;
|
|
10
10
|
exports.resolveMcpNodeLaunch = resolveMcpNodeLaunch;
|
|
11
|
+
exports.getWindowsShortPath = getWindowsShortPath;
|
|
12
|
+
exports.preferSpaceFreeWindowsPath = preferSpaceFreeWindowsPath;
|
|
13
|
+
exports.sanitizeMcpServerNodeForWindowsClients = sanitizeMcpServerNodeForWindowsClients;
|
|
14
|
+
exports.mcpNodeNeedsWindowsSpaceRepair = mcpNodeNeedsWindowsSpaceRepair;
|
|
15
|
+
exports.repairUnsafeWindowsMcpCommands = repairUnsafeWindowsMcpCommands;
|
|
11
16
|
exports.buildMcpServerNode = buildMcpServerNode;
|
|
12
17
|
exports.removeMcpEntry = removeMcpEntry;
|
|
13
18
|
exports.removeCodexMcpEntry = removeCodexMcpEntry;
|
|
@@ -631,7 +636,10 @@ function resolveMcpNodeLaunch(options) {
|
|
|
631
636
|
// 1. Explicit node command (highest priority)
|
|
632
637
|
const explicitNode = options.nodeCommand?.trim();
|
|
633
638
|
if (explicitNode && isUsableNodeCommand(explicitNode) && !isEphemeralNodePath(explicitNode)) {
|
|
634
|
-
return {
|
|
639
|
+
return {
|
|
640
|
+
command: preferSpaceFreeWindowsPath(explicitNode),
|
|
641
|
+
env: { ...MCP_STDIO_ENV },
|
|
642
|
+
};
|
|
635
643
|
}
|
|
636
644
|
// 2. System Node — preferred over Electron because:
|
|
637
645
|
// - Path is stable across IDE updates
|
|
@@ -639,13 +647,23 @@ function resolveMcpNodeLaunch(options) {
|
|
|
639
647
|
// - Better compatibility with MCP client spawn logic
|
|
640
648
|
const systemNode = resolveSystemNodeCommand();
|
|
641
649
|
if (systemNode && systemNode !== "node") {
|
|
642
|
-
|
|
650
|
+
const safeNode = preferSpaceFreeWindowsPath(systemNode);
|
|
651
|
+
// Trae/some clients invoke `command` via cmd.exe without quoting. If we still
|
|
652
|
+
// have spaces (8.3 disabled), fall back to bare "node" so PATH resolution works.
|
|
653
|
+
if (safeNode.includes(" ")) {
|
|
654
|
+
return { command: "node", env: { ...MCP_STDIO_ENV } };
|
|
655
|
+
}
|
|
656
|
+
return { command: safeNode, env: { ...MCP_STDIO_ENV } };
|
|
643
657
|
}
|
|
644
658
|
// 3. Electron fallback — when system Node is unavailable, use the IDE's bundled Electron
|
|
645
659
|
const electronExecPath = options.electronExecPath?.trim();
|
|
646
660
|
if (electronExecPath && (0, node_fs_1.existsSync)(electronExecPath)) {
|
|
661
|
+
const safeElectron = preferSpaceFreeWindowsPath(electronExecPath);
|
|
662
|
+
if (safeElectron.includes(" ")) {
|
|
663
|
+
return { command: "node", env: { ...MCP_STDIO_ENV } };
|
|
664
|
+
}
|
|
647
665
|
return {
|
|
648
|
-
command:
|
|
666
|
+
command: safeElectron,
|
|
649
667
|
env: {
|
|
650
668
|
...MCP_STDIO_ENV,
|
|
651
669
|
ELECTRON_RUN_AS_NODE: "1",
|
|
@@ -655,6 +673,173 @@ function resolveMcpNodeLaunch(options) {
|
|
|
655
673
|
// 4. Last resort: bare "node" (relies on PATH resolution at MCP launch time)
|
|
656
674
|
return { command: "node", env: { ...MCP_STDIO_ENV } };
|
|
657
675
|
}
|
|
676
|
+
/**
|
|
677
|
+
* On Windows, convert a long path containing spaces to its 8.3 short form.
|
|
678
|
+
* Many MCP clients (e.g., TRAE) spawn the `command` field via cmd.exe without
|
|
679
|
+
* quoting, so paths like "C:\Program Files\..." break with "'C:\Program' is not
|
|
680
|
+
* recognized". The 8.3 short name (e.g., "C:\PROGRA~1\...") avoids this entirely.
|
|
681
|
+
*/
|
|
682
|
+
function getWindowsShortPath(longPath) {
|
|
683
|
+
if (!isWindows() || !longPath || !longPath.includes(" ")) {
|
|
684
|
+
return longPath;
|
|
685
|
+
}
|
|
686
|
+
// Try cmd.exe first (faster, available on all Windows)
|
|
687
|
+
try {
|
|
688
|
+
const result = (0, node_child_process_1.execSync)(`for %A in ("${longPath}") do @echo %~sA`, {
|
|
689
|
+
encoding: "utf8",
|
|
690
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
691
|
+
timeout: 3000,
|
|
692
|
+
shell: "cmd.exe",
|
|
693
|
+
}).trim();
|
|
694
|
+
const lines = result.split(/\r?\n/).filter((l) => l.trim());
|
|
695
|
+
const shortPath = lines[lines.length - 1]?.trim();
|
|
696
|
+
if (shortPath && !shortPath.includes(" ") && (0, node_fs_1.existsSync)(shortPath)) {
|
|
697
|
+
return shortPath;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
catch {
|
|
701
|
+
// fall through to PowerShell
|
|
702
|
+
}
|
|
703
|
+
// Fallback: PowerShell with FileSystemObject COM
|
|
704
|
+
try {
|
|
705
|
+
const escaped = longPath.replace(/'/g, "''");
|
|
706
|
+
const result = (0, node_child_process_1.execSync)(`$fso = New-Object -ComObject Scripting.FileSystemObject; if (Test-Path -LiteralPath '${escaped}') { if ((Get-Item -LiteralPath '${escaped}') -is [System.IO.DirectoryInfo]) { $fso.GetFolder('${escaped}').ShortPath } else { $fso.GetFile('${escaped}').ShortPath } }`, {
|
|
707
|
+
encoding: "utf8",
|
|
708
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
709
|
+
timeout: 5000,
|
|
710
|
+
shell: "powershell.exe",
|
|
711
|
+
}).trim();
|
|
712
|
+
if (result && !result.includes(" ") && (0, node_fs_1.existsSync)(result)) {
|
|
713
|
+
return result;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
catch {
|
|
717
|
+
// 8.3 name generation may be disabled on some volumes
|
|
718
|
+
}
|
|
719
|
+
return undefined;
|
|
720
|
+
}
|
|
721
|
+
/** Prefer 8.3 short path on Windows when the input contains spaces; otherwise keep as-is. */
|
|
722
|
+
function preferSpaceFreeWindowsPath(pathValue) {
|
|
723
|
+
if (!isWindows() || !pathValue.includes(" ")) {
|
|
724
|
+
return pathValue;
|
|
725
|
+
}
|
|
726
|
+
return getWindowsShortPath(pathValue) ?? pathValue;
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Final guard for MCP clients (notably Trae) that spawn `command` via cmd.exe
|
|
730
|
+
* without quoting. Ensures install-time configs never write spaced absolute paths.
|
|
731
|
+
*/
|
|
732
|
+
function sanitizeMcpServerNodeForWindowsClients(node) {
|
|
733
|
+
if (!isWindows()) {
|
|
734
|
+
return node;
|
|
735
|
+
}
|
|
736
|
+
let command = preferSpaceFreeWindowsPath(node.command);
|
|
737
|
+
// Absolute node/electron paths that still contain spaces → bare "node" via PATH.
|
|
738
|
+
if (command.includes(" ") &&
|
|
739
|
+
(/[\\/]node(\.exe)?$/i.test(command) || /[\\/]electron(\.exe)?$/i.test(command))) {
|
|
740
|
+
command = "node";
|
|
741
|
+
}
|
|
742
|
+
const args = node.args.map((arg) => {
|
|
743
|
+
if (!arg.includes(" ")) {
|
|
744
|
+
return arg;
|
|
745
|
+
}
|
|
746
|
+
// Only rewrite filesystem-looking args; leave flags like "--foo bar" alone.
|
|
747
|
+
if (/^[A-Za-z]:[\\/]/.test(arg) || arg.startsWith("\\\\") || arg.includes("/") || arg.includes("\\")) {
|
|
748
|
+
return preferSpaceFreeWindowsPath(arg);
|
|
749
|
+
}
|
|
750
|
+
return arg;
|
|
751
|
+
});
|
|
752
|
+
const sanitized = {
|
|
753
|
+
command,
|
|
754
|
+
args,
|
|
755
|
+
};
|
|
756
|
+
if (node.env) {
|
|
757
|
+
sanitized.env = node.env;
|
|
758
|
+
}
|
|
759
|
+
if (node.cwd) {
|
|
760
|
+
sanitized.cwd = preferSpaceFreeWindowsPath(node.cwd);
|
|
761
|
+
}
|
|
762
|
+
return sanitized;
|
|
763
|
+
}
|
|
764
|
+
/** True when command/cwd/path-like args still contain spaces (unsafe for unquoted cmd spawn). */
|
|
765
|
+
function mcpNodeNeedsWindowsSpaceRepair(node) {
|
|
766
|
+
if (node.command.includes(" ")) {
|
|
767
|
+
return true;
|
|
768
|
+
}
|
|
769
|
+
if (node.cwd?.includes(" ")) {
|
|
770
|
+
return true;
|
|
771
|
+
}
|
|
772
|
+
return node.args.some((arg) => {
|
|
773
|
+
if (!arg.includes(" ")) {
|
|
774
|
+
return false;
|
|
775
|
+
}
|
|
776
|
+
return /^[A-Za-z]:[\\/]/.test(arg) || arg.startsWith("\\\\") || arg.includes("/") || arg.includes("\\");
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* Painless migrate: rewrite existing GraphFlow MCP entries that still use spaced
|
|
781
|
+
* absolute paths (e.g. Program Files). Scans every known agent config path that
|
|
782
|
+
* exists — not only currently "detected" markers — so Trae / Trae CN / TRAE SOLO
|
|
783
|
+
* variants are all fixed on extension activate without a manual Install click.
|
|
784
|
+
*/
|
|
785
|
+
function repairUnsafeWindowsMcpCommands(serverName = "graphflow", options) {
|
|
786
|
+
if (!isWindows()) {
|
|
787
|
+
return [];
|
|
788
|
+
}
|
|
789
|
+
const results = [];
|
|
790
|
+
const seen = new Set();
|
|
791
|
+
const targets = options?.targets ??
|
|
792
|
+
buildAgentProfiles().flatMap((profile) => profile.userTargets
|
|
793
|
+
.filter((t) => (t.configFormat ?? "json") !== "codex-toml")
|
|
794
|
+
.map((t) => ({
|
|
795
|
+
agentId: profile.id,
|
|
796
|
+
agentName: profile.name,
|
|
797
|
+
configPath: t.configPath,
|
|
798
|
+
serversKey: t.serversKey,
|
|
799
|
+
})));
|
|
800
|
+
for (const target of targets) {
|
|
801
|
+
const key = `${target.configPath}::${target.serversKey}`;
|
|
802
|
+
if (seen.has(key) || !(0, node_fs_1.existsSync)(target.configPath)) {
|
|
803
|
+
continue;
|
|
804
|
+
}
|
|
805
|
+
seen.add(key);
|
|
806
|
+
try {
|
|
807
|
+
const json = readJsonConfig(target.configPath);
|
|
808
|
+
const servers = json[target.serversKey] ?? {};
|
|
809
|
+
const previous = servers[serverName];
|
|
810
|
+
if (!previous || typeof previous.command !== "string" || !Array.isArray(previous.args)) {
|
|
811
|
+
continue;
|
|
812
|
+
}
|
|
813
|
+
if (!mcpNodeNeedsWindowsSpaceRepair(previous)) {
|
|
814
|
+
results.push({
|
|
815
|
+
agentId: target.agentId,
|
|
816
|
+
agentName: target.agentName,
|
|
817
|
+
configPath: target.configPath,
|
|
818
|
+
repaired: false,
|
|
819
|
+
beforeCommand: previous.command,
|
|
820
|
+
afterCommand: previous.command,
|
|
821
|
+
});
|
|
822
|
+
continue;
|
|
823
|
+
}
|
|
824
|
+
const sanitized = sanitizeMcpServerNodeForWindowsClients(previous);
|
|
825
|
+
servers[serverName] = sanitized;
|
|
826
|
+
json[target.serversKey] = servers;
|
|
827
|
+
writeJsonConfig(target.configPath, json);
|
|
828
|
+
results.push({
|
|
829
|
+
agentId: target.agentId,
|
|
830
|
+
agentName: target.agentName,
|
|
831
|
+
configPath: target.configPath,
|
|
832
|
+
repaired: true,
|
|
833
|
+
beforeCommand: previous.command,
|
|
834
|
+
afterCommand: sanitized.command,
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
catch {
|
|
838
|
+
// Config may be malformed; skip — install path will recreate.
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
return results;
|
|
842
|
+
}
|
|
658
843
|
function resolveWindowsNpxLaunch() {
|
|
659
844
|
const node = resolveSystemNodeCommand();
|
|
660
845
|
if (!node) {
|
|
@@ -667,15 +852,27 @@ function resolveWindowsNpxLaunch() {
|
|
|
667
852
|
];
|
|
668
853
|
for (const npxCli of candidates) {
|
|
669
854
|
if ((0, node_fs_1.existsSync)(npxCli)) {
|
|
855
|
+
// If paths contain spaces, try 8.3 short format to avoid quoting issues
|
|
856
|
+
// with MCP clients that don't properly quote the command (e.g., TRAE).
|
|
857
|
+
const shortNode = getWindowsShortPath(node) ?? node;
|
|
858
|
+
const shortNpxCli = getWindowsShortPath(npxCli) ?? npxCli;
|
|
859
|
+
if (shortNode.includes(" ") || shortNpxCli.includes(" ")) {
|
|
860
|
+
// Can't resolve to a space-free path; fall back to npx.cmd which
|
|
861
|
+
// relies on PATH resolution and handles quoting internally.
|
|
862
|
+
return undefined;
|
|
863
|
+
}
|
|
670
864
|
return {
|
|
671
|
-
command:
|
|
672
|
-
args: [
|
|
865
|
+
command: shortNode,
|
|
866
|
+
args: [shortNpxCli, "-y", "--package=@roarpeng/graphflow", "graphflow-mcp"],
|
|
673
867
|
};
|
|
674
868
|
}
|
|
675
869
|
}
|
|
676
870
|
return undefined;
|
|
677
871
|
}
|
|
678
872
|
function buildMcpServerNode(options) {
|
|
873
|
+
return sanitizeMcpServerNodeForWindowsClients(buildMcpServerNodeRaw(options));
|
|
874
|
+
}
|
|
875
|
+
function buildMcpServerNodeRaw(options) {
|
|
679
876
|
const cwd = options.workspaceRoot ?? options.npmScriptCwd ?? process.cwd();
|
|
680
877
|
// Only inject workspace root when explicitly passed (workspace-scope installs).
|
|
681
878
|
// Never fall back to process.env — that pollutes user-level agent configs.
|
|
@@ -692,12 +889,21 @@ function buildMcpServerNode(options) {
|
|
|
692
889
|
}
|
|
693
890
|
const runtimeRoot = options.bundledRuntimeRoot ?? (0, node_path_1.join)(options.bundledServerPath, "..", "..", "..");
|
|
694
891
|
if (options.launcherPath) {
|
|
892
|
+
// Cursor/Node spawn(.cmd, {shell:false}) fails on Windows with EINVAL /
|
|
893
|
+
// "系统找不到指定的路径". Prefer the sibling .cjs under node; fall back to cmd /c.
|
|
894
|
+
let launcherForSpawn = options.launcherPath;
|
|
695
895
|
if (isWindows() && options.launcherPath.toLowerCase().endsWith(".cmd")) {
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
896
|
+
const cjsSibling = options.launcherPath.replace(/\.cmd$/i, ".cjs");
|
|
897
|
+
if ((0, node_fs_1.existsSync)(cjsSibling)) {
|
|
898
|
+
launcherForSpawn = cjsSibling;
|
|
899
|
+
}
|
|
900
|
+
else {
|
|
901
|
+
return {
|
|
902
|
+
command: "cmd.exe",
|
|
903
|
+
args: ["/c", options.launcherPath],
|
|
904
|
+
env: { ...mcpEnv },
|
|
905
|
+
};
|
|
906
|
+
}
|
|
701
907
|
}
|
|
702
908
|
const launch = resolveMcpNodeLaunch({
|
|
703
909
|
...(options.nodeCommand !== undefined ? { nodeCommand: options.nodeCommand } : {}),
|
|
@@ -705,7 +911,7 @@ function buildMcpServerNode(options) {
|
|
|
705
911
|
});
|
|
706
912
|
return {
|
|
707
913
|
command: launch.command,
|
|
708
|
-
args: [
|
|
914
|
+
args: [launcherForSpawn],
|
|
709
915
|
env: { ...mcpEnv, ...launch.env },
|
|
710
916
|
};
|
|
711
917
|
}
|
|
@@ -909,13 +1115,13 @@ function injectIntoConfig(configPath, serversKey, serverName, node) {
|
|
|
909
1115
|
if (!node.env?.GRAPHFLOW_WORKSPACE_ROOT) {
|
|
910
1116
|
delete mergedEnv.GRAPHFLOW_WORKSPACE_ROOT;
|
|
911
1117
|
}
|
|
912
|
-
servers[serverName] = {
|
|
1118
|
+
servers[serverName] = sanitizeMcpServerNodeForWindowsClients({
|
|
913
1119
|
...previous,
|
|
914
1120
|
...node,
|
|
915
1121
|
...(previous?.args && !node.args?.length ? { args: previous.args } : {}),
|
|
916
1122
|
...(previous?.command && !node.command ? { command: previous.command } : {}),
|
|
917
1123
|
env: mergedEnv,
|
|
918
|
-
};
|
|
1124
|
+
});
|
|
919
1125
|
if (!Object.prototype.hasOwnProperty.call(node, "cwd")) {
|
|
920
1126
|
delete servers[serverName].cwd;
|
|
921
1127
|
}
|
|
@@ -1067,7 +1273,7 @@ function formatModelConfigGuide(workspaceRoot) {
|
|
|
1067
1273
|
"在 VS Code 命令面板运行:`GraphFlow: Settings`",
|
|
1068
1274
|
"",
|
|
1069
1275
|
"## 2. 配置 LLM Provider(规划 / 执行任务)",
|
|
1070
|
-
"- 在设置面板的 Smart / Economy 层分别选择 provider(如 openai / anthropic / bailian / doubao)",
|
|
1276
|
+
"- 在设置面板的 Smart / Economy 层分别选择 provider(如 deepseek / openai / anthropic / bailian / doubao)",
|
|
1071
1277
|
"- API Key:填环境变量名(如 `DEEPSEEK_API_KEY`)、`${DEEPSEEK_API_KEY}`、或直接 `sk-...`",
|
|
1072
1278
|
"- Base URL:每层卡片内直接填写(如 DeepSeek 使用 `https://api.deepseek.com`)",
|
|
1073
1279
|
"- Smart / Economy 模型均可选;留空则使用 provider 默认路由",
|