@colbymchenry/codegraph-win32-arm64 1.6.1 → 1.6.2
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/lib/dist/.test-build-engine.json +1 -1
- package/lib/dist/.test-build-viewer.json +1 -1
- package/lib/dist/bin/codegraph.js +9 -3
- package/lib/dist/bin/codegraph.js.map +1 -1
- package/lib/dist/bin/command-supervision.d.ts +7 -0
- package/lib/dist/bin/command-supervision.d.ts.map +1 -1
- package/lib/dist/bin/command-supervision.js +39 -27
- package/lib/dist/bin/command-supervision.js.map +1 -1
- package/lib/dist/db/queries.d.ts +31 -7
- package/lib/dist/db/queries.d.ts.map +1 -1
- package/lib/dist/db/queries.js +56 -10
- package/lib/dist/db/queries.js.map +1 -1
- package/lib/dist/directory.d.ts +30 -0
- package/lib/dist/directory.d.ts.map +1 -1
- package/lib/dist/directory.js +45 -0
- package/lib/dist/directory.js.map +1 -1
- package/lib/dist/extraction/astro-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/astro-extractor.js +7 -35
- package/lib/dist/extraction/astro-extractor.js.map +1 -1
- package/lib/dist/extraction/cfml-extractor.d.ts +76 -10
- package/lib/dist/extraction/cfml-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/cfml-extractor.js +287 -68
- package/lib/dist/extraction/cfml-extractor.js.map +1 -1
- package/lib/dist/extraction/commonjs-requires.d.ts +23 -0
- package/lib/dist/extraction/commonjs-requires.d.ts.map +1 -0
- package/lib/dist/extraction/commonjs-requires.js +68 -0
- package/lib/dist/extraction/commonjs-requires.js.map +1 -0
- package/lib/dist/extraction/generated-detection.d.ts +9 -0
- package/lib/dist/extraction/generated-detection.d.ts.map +1 -1
- package/lib/dist/extraction/generated-detection.js +42 -2
- package/lib/dist/extraction/generated-detection.js.map +1 -1
- package/lib/dist/extraction/grammars.d.ts +2 -0
- package/lib/dist/extraction/grammars.d.ts.map +1 -1
- package/lib/dist/extraction/grammars.js +94 -0
- package/lib/dist/extraction/grammars.js.map +1 -1
- package/lib/dist/extraction/index.d.ts +19 -4
- package/lib/dist/extraction/index.d.ts.map +1 -1
- package/lib/dist/extraction/index.js +227 -64
- package/lib/dist/extraction/index.js.map +1 -1
- package/lib/dist/extraction/kernel/index.d.ts.map +1 -1
- package/lib/dist/extraction/kernel/index.js +6 -0
- package/lib/dist/extraction/kernel/index.js.map +1 -1
- package/lib/dist/extraction/languages/c-cpp.d.ts +15 -0
- package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -1
- package/lib/dist/extraction/languages/c-cpp.js +122 -2
- package/lib/dist/extraction/languages/c-cpp.js.map +1 -1
- package/lib/dist/extraction/languages/csharp.d.ts.map +1 -1
- package/lib/dist/extraction/languages/csharp.js +14 -5
- package/lib/dist/extraction/languages/csharp.js.map +1 -1
- package/lib/dist/extraction/languages/dart.d.ts.map +1 -1
- package/lib/dist/extraction/languages/dart.js +8 -0
- package/lib/dist/extraction/languages/dart.js.map +1 -1
- package/lib/dist/extraction/languages/kotlin.d.ts +4 -0
- package/lib/dist/extraction/languages/kotlin.d.ts.map +1 -1
- package/lib/dist/extraction/languages/kotlin.js +68 -0
- package/lib/dist/extraction/languages/kotlin.js.map +1 -1
- package/lib/dist/extraction/languages/swift.d.ts +15 -0
- package/lib/dist/extraction/languages/swift.d.ts.map +1 -1
- package/lib/dist/extraction/languages/swift.js +50 -0
- package/lib/dist/extraction/languages/swift.js.map +1 -1
- package/lib/dist/extraction/languages/typescript.d.ts +7 -0
- package/lib/dist/extraction/languages/typescript.d.ts.map +1 -1
- package/lib/dist/extraction/languages/typescript.js +21 -0
- package/lib/dist/extraction/languages/typescript.js.map +1 -1
- package/lib/dist/extraction/parse-budget.d.ts +16 -0
- package/lib/dist/extraction/parse-budget.d.ts.map +1 -0
- package/lib/dist/extraction/parse-budget.js +24 -0
- package/lib/dist/extraction/parse-budget.js.map +1 -0
- package/lib/dist/extraction/parse-pool.d.ts +12 -0
- package/lib/dist/extraction/parse-pool.d.ts.map +1 -1
- package/lib/dist/extraction/parse-pool.js +51 -3
- package/lib/dist/extraction/parse-pool.js.map +1 -1
- package/lib/dist/extraction/parse-worker.js +3 -1
- package/lib/dist/extraction/parse-worker.js.map +1 -1
- package/lib/dist/extraction/sfc-script.d.ts +43 -0
- package/lib/dist/extraction/sfc-script.d.ts.map +1 -0
- package/lib/dist/extraction/sfc-script.js +135 -0
- package/lib/dist/extraction/sfc-script.js.map +1 -0
- package/lib/dist/extraction/store-worker.js +5 -0
- package/lib/dist/extraction/store-worker.js.map +1 -1
- package/lib/dist/extraction/store-writer.d.ts +10 -2
- package/lib/dist/extraction/store-writer.d.ts.map +1 -1
- package/lib/dist/extraction/store-writer.js +12 -4
- package/lib/dist/extraction/store-writer.js.map +1 -1
- package/lib/dist/extraction/svelte-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/svelte-extractor.js +7 -37
- package/lib/dist/extraction/svelte-extractor.js.map +1 -1
- package/lib/dist/extraction/syntax-tokens.d.ts.map +1 -1
- package/lib/dist/extraction/syntax-tokens.js +2 -1
- package/lib/dist/extraction/syntax-tokens.js.map +1 -1
- package/lib/dist/extraction/tree-sitter.d.ts +8 -0
- package/lib/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter.js +123 -6
- package/lib/dist/extraction/tree-sitter.js.map +1 -1
- package/lib/dist/extraction/vue-extractor.d.ts +7 -0
- package/lib/dist/extraction/vue-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/vue-extractor.js +73 -35
- package/lib/dist/extraction/vue-extractor.js.map +1 -1
- package/lib/dist/extraction/vue-options-api.d.ts +28 -0
- package/lib/dist/extraction/vue-options-api.d.ts.map +1 -0
- package/lib/dist/extraction/vue-options-api.js +196 -0
- package/lib/dist/extraction/vue-options-api.js.map +1 -0
- package/lib/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-kotlin.wasm +0 -0
- package/lib/dist/graph/branch-guards.d.ts +17 -0
- package/lib/dist/graph/branch-guards.d.ts.map +1 -1
- package/lib/dist/graph/branch-guards.js +97 -2
- package/lib/dist/graph/branch-guards.js.map +1 -1
- package/lib/dist/graph/named-symbol-flow.d.ts.map +1 -1
- package/lib/dist/graph/named-symbol-flow.js +8 -1
- package/lib/dist/graph/named-symbol-flow.js.map +1 -1
- package/lib/dist/index.d.ts +5 -0
- package/lib/dist/index.d.ts.map +1 -1
- package/lib/dist/index.js +7 -0
- package/lib/dist/index.js.map +1 -1
- package/lib/dist/mcp/daemon-paths.d.ts.map +1 -1
- package/lib/dist/mcp/daemon-paths.js +8 -2
- package/lib/dist/mcp/daemon-paths.js.map +1 -1
- package/lib/dist/mcp/daemon-registry.d.ts +4 -0
- package/lib/dist/mcp/daemon-registry.d.ts.map +1 -1
- package/lib/dist/mcp/daemon-registry.js +46 -12
- package/lib/dist/mcp/daemon-registry.js.map +1 -1
- package/lib/dist/mcp/engine.d.ts +2 -0
- package/lib/dist/mcp/engine.d.ts.map +1 -1
- package/lib/dist/mcp/engine.js +13 -5
- package/lib/dist/mcp/engine.js.map +1 -1
- package/lib/dist/mcp/index-freshness-worker.js +7 -1
- package/lib/dist/mcp/index-freshness-worker.js.map +1 -1
- package/lib/dist/mcp/index-freshness.d.ts +7 -1
- package/lib/dist/mcp/index-freshness.d.ts.map +1 -1
- package/lib/dist/mcp/index-freshness.js +31 -8
- package/lib/dist/mcp/index-freshness.js.map +1 -1
- package/lib/dist/mcp/project-lifecycle.d.ts.map +1 -1
- package/lib/dist/mcp/project-lifecycle.js +5 -4
- package/lib/dist/mcp/project-lifecycle.js.map +1 -1
- package/lib/dist/mcp/proxy.d.ts +9 -2
- package/lib/dist/mcp/proxy.d.ts.map +1 -1
- package/lib/dist/mcp/proxy.js +194 -34
- package/lib/dist/mcp/proxy.js.map +1 -1
- package/lib/dist/mcp/query-pool.d.ts +16 -1
- package/lib/dist/mcp/query-pool.d.ts.map +1 -1
- package/lib/dist/mcp/query-pool.js +58 -4
- package/lib/dist/mcp/query-pool.js.map +1 -1
- package/lib/dist/mcp/tools.d.ts +32 -2
- package/lib/dist/mcp/tools.d.ts.map +1 -1
- package/lib/dist/mcp/tools.js +120 -6
- package/lib/dist/mcp/tools.js.map +1 -1
- package/lib/dist/resolution/alias-binding.d.ts.map +1 -1
- package/lib/dist/resolution/alias-binding.js +16 -0
- package/lib/dist/resolution/alias-binding.js.map +1 -1
- package/lib/dist/resolution/angular-template-synthesizer.d.ts +49 -0
- package/lib/dist/resolution/angular-template-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/angular-template-synthesizer.js +359 -0
- package/lib/dist/resolution/angular-template-synthesizer.js.map +1 -0
- package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -1
- package/lib/dist/resolution/callback-synthesizer.js +171 -3
- package/lib/dist/resolution/callback-synthesizer.js.map +1 -1
- package/lib/dist/resolution/cpp-macro-visibility.d.ts.map +1 -1
- package/lib/dist/resolution/cpp-macro-visibility.js +57 -7
- package/lib/dist/resolution/cpp-macro-visibility.js.map +1 -1
- package/lib/dist/resolution/frameworks/angular-router.d.ts +142 -0
- package/lib/dist/resolution/frameworks/angular-router.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/angular-router.js +1126 -0
- package/lib/dist/resolution/frameworks/angular-router.js.map +1 -0
- package/lib/dist/resolution/frameworks/astro.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/astro.js +32 -6
- package/lib/dist/resolution/frameworks/astro.js.map +1 -1
- package/lib/dist/resolution/frameworks/csharp.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/csharp.js +127 -59
- package/lib/dist/resolution/frameworks/csharp.js.map +1 -1
- package/lib/dist/resolution/frameworks/expo-modules.d.ts +10 -0
- package/lib/dist/resolution/frameworks/expo-modules.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/expo-modules.js +95 -1
- package/lib/dist/resolution/frameworks/expo-modules.js.map +1 -1
- package/lib/dist/resolution/frameworks/expo-router.d.ts +6 -0
- package/lib/dist/resolution/frameworks/expo-router.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/expo-router.js +62 -0
- package/lib/dist/resolution/frameworks/expo-router.js.map +1 -1
- package/lib/dist/resolution/frameworks/express.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/express.js +103 -44
- package/lib/dist/resolution/frameworks/express.js.map +1 -1
- package/lib/dist/resolution/frameworks/fabric.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/fabric.js +13 -11
- package/lib/dist/resolution/frameworks/fabric.js.map +1 -1
- package/lib/dist/resolution/frameworks/go.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/go.js +11 -28
- package/lib/dist/resolution/frameworks/go.js.map +1 -1
- package/lib/dist/resolution/frameworks/index.d.ts +3 -2
- package/lib/dist/resolution/frameworks/index.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/index.js +11 -1
- package/lib/dist/resolution/frameworks/index.js.map +1 -1
- package/lib/dist/resolution/frameworks/java.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/java.js +9 -21
- package/lib/dist/resolution/frameworks/java.js.map +1 -1
- package/lib/dist/resolution/frameworks/laravel.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/laravel.js +369 -26
- package/lib/dist/resolution/frameworks/laravel.js.map +1 -1
- package/lib/dist/resolution/frameworks/name-heuristic.d.ts +35 -0
- package/lib/dist/resolution/frameworks/name-heuristic.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/name-heuristic.js +45 -0
- package/lib/dist/resolution/frameworks/name-heuristic.js.map +1 -0
- package/lib/dist/resolution/frameworks/nestjs.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/nestjs.js +282 -41
- package/lib/dist/resolution/frameworks/nestjs.js.map +1 -1
- package/lib/dist/resolution/frameworks/nextjs.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/nextjs.js +1 -0
- package/lib/dist/resolution/frameworks/nextjs.js.map +1 -1
- package/lib/dist/resolution/frameworks/page-component.d.ts +20 -0
- package/lib/dist/resolution/frameworks/page-component.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/page-component.js +45 -0
- package/lib/dist/resolution/frameworks/page-component.js.map +1 -0
- package/lib/dist/resolution/frameworks/play.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/play.js +3 -1
- package/lib/dist/resolution/frameworks/play.js.map +1 -1
- package/lib/dist/resolution/frameworks/python.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/python.js +113 -26
- package/lib/dist/resolution/frameworks/python.js.map +1 -1
- package/lib/dist/resolution/frameworks/react-router.d.ts +6 -5
- package/lib/dist/resolution/frameworks/react-router.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/react-router.js +22 -8
- package/lib/dist/resolution/frameworks/react-router.js.map +1 -1
- package/lib/dist/resolution/frameworks/react.d.ts +11 -1
- package/lib/dist/resolution/frameworks/react.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/react.js +367 -18
- package/lib/dist/resolution/frameworks/react.js.map +1 -1
- package/lib/dist/resolution/frameworks/ruby.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/ruby.js +177 -17
- package/lib/dist/resolution/frameworks/ruby.js.map +1 -1
- package/lib/dist/resolution/frameworks/rust.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/rust.js +24 -22
- package/lib/dist/resolution/frameworks/rust.js.map +1 -1
- package/lib/dist/resolution/frameworks/svelte.js +8 -5
- package/lib/dist/resolution/frameworks/svelte.js.map +1 -1
- package/lib/dist/resolution/frameworks/swift.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/swift.js +253 -124
- package/lib/dist/resolution/frameworks/swift.js.map +1 -1
- package/lib/dist/resolution/frameworks/vue-router.d.ts +26 -10
- package/lib/dist/resolution/frameworks/vue-router.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/vue-router.js +176 -53
- package/lib/dist/resolution/frameworks/vue-router.js.map +1 -1
- package/lib/dist/resolution/frameworks/vue.d.ts +9 -2
- package/lib/dist/resolution/frameworks/vue.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/vue.js +45 -11
- package/lib/dist/resolution/frameworks/vue.js.map +1 -1
- package/lib/dist/resolution/import-resolver.d.ts +28 -0
- package/lib/dist/resolution/import-resolver.d.ts.map +1 -1
- package/lib/dist/resolution/import-resolver.js +269 -37
- package/lib/dist/resolution/import-resolver.js.map +1 -1
- package/lib/dist/resolution/index.d.ts +35 -0
- package/lib/dist/resolution/index.d.ts.map +1 -1
- package/lib/dist/resolution/index.js +224 -14
- package/lib/dist/resolution/index.js.map +1 -1
- package/lib/dist/resolution/js-builtins.d.ts.map +1 -1
- package/lib/dist/resolution/js-builtins.js +2 -0
- package/lib/dist/resolution/js-builtins.js.map +1 -1
- package/lib/dist/resolution/name-matcher.d.ts +33 -1
- package/lib/dist/resolution/name-matcher.d.ts.map +1 -1
- package/lib/dist/resolution/name-matcher.js +6392 -227
- package/lib/dist/resolution/name-matcher.js.map +1 -1
- package/lib/dist/resolution/react-router-synthesizer.d.ts +2 -0
- package/lib/dist/resolution/react-router-synthesizer.d.ts.map +1 -1
- package/lib/dist/resolution/react-router-synthesizer.js +80 -9
- package/lib/dist/resolution/react-router-synthesizer.js.map +1 -1
- package/lib/dist/resolution/resolver-pool.d.ts +20 -1
- package/lib/dist/resolution/resolver-pool.d.ts.map +1 -1
- package/lib/dist/resolution/resolver-pool.js +31 -5
- package/lib/dist/resolution/resolver-pool.js.map +1 -1
- package/lib/dist/resolution/resolver-worker.js +3 -0
- package/lib/dist/resolution/resolver-worker.js.map +1 -1
- package/lib/dist/resolution/swift-type-visibility.d.ts +68 -0
- package/lib/dist/resolution/swift-type-visibility.d.ts.map +1 -0
- package/lib/dist/resolution/swift-type-visibility.js +454 -0
- package/lib/dist/resolution/swift-type-visibility.js.map +1 -0
- package/lib/dist/resolution/tier-synthesizer.d.ts +7 -2
- package/lib/dist/resolution/tier-synthesizer.d.ts.map +1 -1
- package/lib/dist/resolution/tier-synthesizer.js +365 -2
- package/lib/dist/resolution/tier-synthesizer.js.map +1 -1
- package/lib/dist/resolution/type-parameters.d.ts +11 -0
- package/lib/dist/resolution/type-parameters.d.ts.map +1 -0
- package/lib/dist/resolution/type-parameters.js +287 -0
- package/lib/dist/resolution/type-parameters.js.map +1 -0
- package/lib/dist/resolution/types.d.ts +27 -0
- package/lib/dist/resolution/types.d.ts.map +1 -1
- package/lib/dist/resolution/types.js.map +1 -1
- package/lib/dist/sync/worktree.d.ts +22 -0
- package/lib/dist/sync/worktree.d.ts.map +1 -1
- package/lib/dist/sync/worktree.js +54 -0
- package/lib/dist/sync/worktree.js.map +1 -1
- package/lib/dist/telemetry/index.d.ts.map +1 -1
- package/lib/dist/telemetry/index.js +69 -27
- package/lib/dist/telemetry/index.js.map +1 -1
- package/lib/dist/ui-server/api/effects.d.ts +7 -0
- package/lib/dist/ui-server/api/effects.d.ts.map +1 -1
- package/lib/dist/ui-server/api/effects.js +35 -7
- package/lib/dist/ui-server/api/effects.js.map +1 -1
- package/lib/dist/ui-server/api/entrypoints.d.ts +6 -0
- package/lib/dist/ui-server/api/entrypoints.d.ts.map +1 -1
- package/lib/dist/ui-server/api/entrypoints.js +91 -6
- package/lib/dist/ui-server/api/entrypoints.js.map +1 -1
- package/lib/dist/ui-server/api/map.d.ts +41 -6
- package/lib/dist/ui-server/api/map.d.ts.map +1 -1
- package/lib/dist/ui-server/api/map.js +122 -22
- package/lib/dist/ui-server/api/map.js.map +1 -1
- package/lib/dist/ui-server/api/node.d.ts.map +1 -1
- package/lib/dist/ui-server/api/node.js +8 -2
- package/lib/dist/ui-server/api/node.js.map +1 -1
- package/lib/dist/ui-server/api/route-roots.d.ts +6 -0
- package/lib/dist/ui-server/api/route-roots.d.ts.map +1 -1
- package/lib/dist/ui-server/api/route-roots.js +23 -2
- package/lib/dist/ui-server/api/route-roots.js.map +1 -1
- package/lib/dist/ui-server/api/routes.d.ts +2 -0
- package/lib/dist/ui-server/api/routes.d.ts.map +1 -1
- package/lib/dist/ui-server/api/routes.js +61 -5
- package/lib/dist/ui-server/api/routes.js.map +1 -1
- package/lib/dist/ui-server/api/screens.d.ts.map +1 -1
- package/lib/dist/ui-server/api/screens.js +16 -1
- package/lib/dist/ui-server/api/screens.js.map +1 -1
- package/lib/dist/ui-server/api/steps.d.ts.map +1 -1
- package/lib/dist/ui-server/api/steps.js +124 -16
- package/lib/dist/ui-server/api/steps.js.map +1 -1
- package/lib/dist/ui-server/api/trails.js +1 -0
- package/lib/dist/ui-server/api/trails.js.map +1 -1
- package/lib/dist/ui-server/api/when.d.ts +10 -2
- package/lib/dist/ui-server/api/when.d.ts.map +1 -1
- package/lib/dist/ui-server/api/when.js +34 -10
- package/lib/dist/ui-server/api/when.js.map +1 -1
- package/lib/dist/ui-server/highlight/bounded-tokenize.d.ts +28 -0
- package/lib/dist/ui-server/highlight/bounded-tokenize.d.ts.map +1 -0
- package/lib/dist/ui-server/highlight/bounded-tokenize.js +139 -0
- package/lib/dist/ui-server/highlight/bounded-tokenize.js.map +1 -0
- package/lib/dist/ui-server/highlight/index.d.ts.map +1 -1
- package/lib/dist/ui-server/highlight/index.js +6 -1
- package/lib/dist/ui-server/highlight/index.js.map +1 -1
- package/lib/dist/ui-server/highlight/tokenize-worker.d.ts +7 -0
- package/lib/dist/ui-server/highlight/tokenize-worker.d.ts.map +1 -0
- package/lib/dist/ui-server/highlight/tokenize-worker.js +20 -0
- package/lib/dist/ui-server/highlight/tokenize-worker.js.map +1 -0
- package/lib/dist/upgrade/index.d.ts +43 -5
- package/lib/dist/upgrade/index.d.ts.map +1 -1
- package/lib/dist/upgrade/index.js +157 -35
- package/lib/dist/upgrade/index.js.map +1 -1
- package/lib/dist/viewer/assets/{index-D4S7YUPf.js → index-BSGpxBr9.js} +60 -58
- package/lib/dist/viewer/index.html +1 -1
- package/lib/dist/worker-teardown.d.ts +48 -0
- package/lib/dist/worker-teardown.d.ts.map +1 -0
- package/lib/dist/worker-teardown.js +100 -0
- package/lib/dist/worker-teardown.js.map +1 -0
- package/lib/kernel/codegraph-kernel.node +2 -2
- package/lib/node_modules/.package-lock.json +1 -1
- package/lib/package.json +1 -1
- package/package.json +1 -1
|
@@ -3,5 +3,11 @@ export interface PendingChangeCounts {
|
|
|
3
3
|
modified: number;
|
|
4
4
|
removed: number;
|
|
5
5
|
}
|
|
6
|
-
export declare function measurePendingChanges(root: string): Promise<PendingChangeCounts | null>;
|
|
6
|
+
export declare function measurePendingChanges(root: string, timeoutMs?: number): Promise<PendingChangeCounts | null>;
|
|
7
|
+
/**
|
|
8
|
+
* Terminate every measurement still running, each once it has loaded its
|
|
9
|
+
* modules (worker-teardown.ts) — for a server that is about to exit, since
|
|
10
|
+
* exiting tears the workers down the same way terminating them does.
|
|
11
|
+
*/
|
|
12
|
+
export declare function endFreshnessMeasurements(): Promise<void>;
|
|
7
13
|
//# sourceMappingURL=index-freshness.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-freshness.d.ts","sourceRoot":"","sources":["../../src/mcp/index-freshness.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index-freshness.d.ts","sourceRoot":"","sources":["../../src/mcp/index-freshness.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AASD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,SAAqB,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAUvH;AAED;;;;GAIG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC,CAE9D"}
|
|
@@ -34,14 +34,18 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.measurePendingChanges = measurePendingChanges;
|
|
37
|
+
exports.endFreshnessMeasurements = endFreshnessMeasurements;
|
|
37
38
|
const fs_1 = require("fs");
|
|
38
39
|
const path = __importStar(require("path"));
|
|
39
40
|
const worker_threads_1 = require("worker_threads");
|
|
41
|
+
const worker_teardown_1 = require("../worker-teardown");
|
|
40
42
|
/** `getChangedFiles()` may fall back to a huge filesystem scan (#1959). */
|
|
41
43
|
const MEASURE_TIMEOUT_MS = 8_000;
|
|
42
44
|
let liveMeasurements = 0;
|
|
43
45
|
const active = new Map();
|
|
44
|
-
|
|
46
|
+
/** Every measurement worker not yet terminated, with its load — for {@link endFreshnessMeasurements}. */
|
|
47
|
+
const live = new Map();
|
|
48
|
+
function measurePendingChanges(root, timeoutMs = MEASURE_TIMEOUT_MS) {
|
|
45
49
|
const key = path.resolve(root);
|
|
46
50
|
const existing = active.get(key);
|
|
47
51
|
if (existing)
|
|
@@ -49,11 +53,19 @@ function measurePendingChanges(root) {
|
|
|
49
53
|
// Status probes for many projects must not exhaust the shared daemon.
|
|
50
54
|
if (liveMeasurements >= 2)
|
|
51
55
|
return Promise.resolve(null);
|
|
52
|
-
const pending = runMeasurement(key).finally(() => active.delete(key));
|
|
56
|
+
const pending = runMeasurement(key, timeoutMs).finally(() => active.delete(key));
|
|
53
57
|
active.set(key, pending);
|
|
54
58
|
return pending;
|
|
55
59
|
}
|
|
56
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Terminate every measurement still running, each once it has loaded its
|
|
62
|
+
* modules (worker-teardown.ts) — for a server that is about to exit, since
|
|
63
|
+
* exiting tears the workers down the same way terminating them does.
|
|
64
|
+
*/
|
|
65
|
+
async function endFreshnessMeasurements() {
|
|
66
|
+
await Promise.all([...live].map(([worker, loaded]) => (0, worker_teardown_1.terminateOnceStarted)(worker, loaded)));
|
|
67
|
+
}
|
|
68
|
+
function runMeasurement(root, timeoutMs) {
|
|
57
69
|
// The compiled sibling is beside us in production; Vitest loads src/ but
|
|
58
70
|
// builds dist/ before the tests, so use that copy for the worker there.
|
|
59
71
|
const sibling = path.join(__dirname, 'index-freshness-worker.js');
|
|
@@ -69,6 +81,10 @@ function runMeasurement(root) {
|
|
|
69
81
|
catch {
|
|
70
82
|
return Promise.resolve(null);
|
|
71
83
|
}
|
|
84
|
+
// Its first message is 'loaded', posted once its modules are in. Terminating
|
|
85
|
+
// it before then can crash the whole process on Windows (worker-teardown.ts).
|
|
86
|
+
const loaded = (0, worker_teardown_1.workerStarted)(worker);
|
|
87
|
+
live.set(worker, loaded);
|
|
72
88
|
liveMeasurements++;
|
|
73
89
|
return new Promise(resolve => {
|
|
74
90
|
let settled = false;
|
|
@@ -77,13 +93,20 @@ function runMeasurement(root) {
|
|
|
77
93
|
return;
|
|
78
94
|
settled = true;
|
|
79
95
|
clearTimeout(timer);
|
|
80
|
-
// A worker inside a synchronous Git call may take time to terminate
|
|
81
|
-
//
|
|
82
|
-
|
|
96
|
+
// A worker inside a synchronous Git call may take time to terminate, and
|
|
97
|
+
// one still loading its modules must not be terminated yet. Return
|
|
98
|
+
// unknown on deadline, but keep its concurrency slot until it is gone.
|
|
99
|
+
void (0, worker_teardown_1.terminateOnceStarted)(worker, loaded).finally(() => {
|
|
100
|
+
live.delete(worker);
|
|
101
|
+
liveMeasurements--;
|
|
102
|
+
});
|
|
83
103
|
resolve(counts);
|
|
84
104
|
};
|
|
85
|
-
const timer = setTimeout(() => finish(null),
|
|
86
|
-
worker.
|
|
105
|
+
const timer = setTimeout(() => finish(null), timeoutMs);
|
|
106
|
+
worker.on('message', (msg) => {
|
|
107
|
+
if (msg?.type !== 'counts')
|
|
108
|
+
return;
|
|
109
|
+
const value = msg.counts;
|
|
87
110
|
const valid = value && typeof value === 'object' && ['added', 'modified', 'removed'].every(key => Number.isSafeInteger(value[key]) && value[key] >= 0);
|
|
88
111
|
finish(valid ? value : null);
|
|
89
112
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-freshness.js","sourceRoot":"","sources":["../../src/mcp/index-freshness.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;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ACrD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBACpB,gBAAgB,EAAE,CAAC;YACrB,CAAC,CAAC,CAAC;YACH,OAAO,CAAC,MAAM,CAAC,CAAC;QAClB,CAAC,CAAC;QACF,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC;QACxD,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,GAA2D,EAAE,EAAE;YACnF,IAAI,GAAG,EAAE,IAAI,KAAK,QAAQ;gBAAE,OAAO;YACnC,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC;YACzB,MAAM,KAAK,GAAG,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC,KAAK,CACxF,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,GAAgC,CAAC,CAAC,IAAI,KAAK,CAAC,GAAgC,CAAC,IAAI,CAAC,CACrH,CAAC;YACF,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACzC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-lifecycle.d.ts","sourceRoot":"","sources":["../../src/mcp/project-lifecycle.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,SAAS,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"project-lifecycle.d.ts","sourceRoot":"","sources":["../../src/mcp/project-lifecycle.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,SAAS,MAAM,UAAU,CAAC;AAqBtC,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,SAAS,CAAC;IACd,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAID,mFAAmF;AACnF,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,SAAS,EACrB,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,GACzC,YAAY,CAwBd"}
|
|
@@ -12,13 +12,14 @@ const projects = new Map();
|
|
|
12
12
|
/** Engines in one process share a graph; other processes share the writer slot. */
|
|
13
13
|
function acquireProject(root, open, options) {
|
|
14
14
|
root = (0, fs_1.realpathSync)(root);
|
|
15
|
-
|
|
15
|
+
const key = (0, directory_1.canonicalProjectRoot)(root);
|
|
16
|
+
let project = projects.get(key);
|
|
16
17
|
if (!project) {
|
|
17
18
|
const cg = open();
|
|
18
|
-
project = { cg, refs: 0, owner: false, caughtUp: false, retirement: null, gate: null, socket: null, options,
|
|
19
|
+
project = { key, cg, refs: 0, owner: false, caughtUp: false, retirement: null, gate: null, socket: null, options,
|
|
19
20
|
timer: setInterval(() => { void ready(root, project); }, 1000) };
|
|
20
21
|
project.timer.unref();
|
|
21
|
-
projects.set(
|
|
22
|
+
projects.set(key, project);
|
|
22
23
|
}
|
|
23
24
|
const entry = project;
|
|
24
25
|
entry.refs++;
|
|
@@ -59,7 +60,7 @@ function retire(root, project) {
|
|
|
59
60
|
setTimeout(finish, 25);
|
|
60
61
|
return;
|
|
61
62
|
}
|
|
62
|
-
projects.delete(
|
|
63
|
+
projects.delete(project.key);
|
|
63
64
|
project.cg.close();
|
|
64
65
|
if (project.owner)
|
|
65
66
|
(0, writer_lock_1.releaseWriterLock)(root);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-lifecycle.js","sourceRoot":"","sources":["../../src/mcp/project-lifecycle.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"project-lifecycle.js","sourceRoot":"","sources":["../../src/mcp/project-lifecycle.ts"],"names":[],"mappings":";;AAiCA,wCA4BC;AA7DD,qFAAqF;AACrF,2BAAkC;AAGlC,4CAAmE;AACnE,kCAAoE;AACpE,iDAA2D;AAC3D,mCAA2C;AAC3C,+CAAyG;AAsBzG,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAmB,CAAC;AAE5C,mFAAmF;AACnF,SAAgB,cAAc,CAC5B,IAAY,EACZ,IAAqB,EACrB,OAA0C;IAE1C,IAAI,GAAG,IAAA,iBAAY,EAAC,IAAI,CAAC,CAAC;IAC1B,MAAM,GAAG,GAAG,IAAA,gCAAoB,EAAC,IAAI,CAAC,CAAC;IACvC,IAAI,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC;QAClB,OAAO,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;YAC9G,KAAK,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,KAAK,CAAC,IAAI,EAAE,OAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC;QACpE,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACtB,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC7B,CAAC;IACD,MAAM,KAAK,GAAG,OAAO,CAAC;IACtB,KAAK,CAAC,IAA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AG,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACxE,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC1B,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC7B,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,EAAE,YAAY;YACvF,MAAM,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/lib/dist/mcp/proxy.d.ts
CHANGED
|
@@ -64,8 +64,9 @@ export interface LocalHandshakeDeps {
|
|
|
64
64
|
/** Probe → spawn → retry → hello-verify; resolves a connected daemon socket,
|
|
65
65
|
* or null when the daemon path is genuinely unavailable (→ in-process fallback). */
|
|
66
66
|
getDaemonSocket(): Promise<net.Socket | null>;
|
|
67
|
-
/** Lazily create an in-process engine — used
|
|
68
|
-
* preserving the "a broken daemon never wedges a session"
|
|
67
|
+
/** Lazily create an in-process engine — used only while the daemon is
|
|
68
|
+
* unreachable, preserving the "a broken daemon never wedges a session"
|
|
69
|
+
* guarantee. Called again whenever the previous engine was retired (#2277). */
|
|
69
70
|
makeEngine(): MCPEngine;
|
|
70
71
|
/** Project root for the fallback engine's lazy init. */
|
|
71
72
|
root: string;
|
|
@@ -82,6 +83,12 @@ export interface LocalHandshakeDeps {
|
|
|
82
83
|
* the local one). If the daemon never comes up (version mismatch / spawn fail),
|
|
83
84
|
* a lazily-created in-process engine serves the calls — so the handshake speedup
|
|
84
85
|
* never costs the old fall-back-to-direct robustness.
|
|
86
|
+
*
|
|
87
|
+
* Serving in-process is not for the rest of the session (#2277): that engine
|
|
88
|
+
* may own the project's writer lock, and no daemon can start while it does, so
|
|
89
|
+
* every other session on the project would be stuck without auto-sync. The
|
|
90
|
+
* proxy retries the daemon with backoff, handing the writer lock back first,
|
|
91
|
+
* and proxies again once one answers.
|
|
85
92
|
*/
|
|
86
93
|
export declare function runLocalHandshakeProxy(deps: LocalHandshakeDeps): Promise<void>;
|
|
87
94
|
//# sourceMappingURL=proxy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/mcp/proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAE3B,OAAO,EAAqB,WAAW,EAAwB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/mcp/proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAE3B,OAAO,EAAqB,WAAW,EAAwB,MAAM,UAAU,CAAC;AAahF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAiC1C;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CAK9E;AAED,MAAM,WAAW,WAAW;IAC1B;;;;;OAKG;IACH,OAAO,EAAE,SAAS,GAAG,iBAAiB,CAAC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,QAAQ,CAC5B,UAAU,EAAE,MAAM,EAClB,eAAe,GAAE,MAAgC,GAChD,OAAO,CAAC,WAAW,CAAC,CAqCtB;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,UAAU,EAAE,MAAM,EAClB,eAAe,GAAE,MAAgC,GAChD,OAAO,CAAC,GAAG,CAAC,MAAM,GAAG,kBAAkB,GAAG,IAAI,CAAC,CAgCjD;AAsBD;+DAC+D;AAC/D,MAAM,WAAW,kBAAkB;IACjC;yFACqF;IACrF,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC9C;;oFAEgF;IAChF,UAAU,IAAI,SAAS,CAAC;IACxB,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkUpF"}
|
package/lib/dist/mcp/proxy.js
CHANGED
|
@@ -68,11 +68,29 @@ const version_1 = require("./version");
|
|
|
68
68
|
const session_1 = require("./session");
|
|
69
69
|
const server_instructions_1 = require("./server-instructions");
|
|
70
70
|
const tools_1 = require("./tools");
|
|
71
|
+
const transport_1 = require("./transport");
|
|
71
72
|
const explore_session_state_1 = require("./explore-session-state");
|
|
72
73
|
const telemetry_1 = require("../telemetry");
|
|
73
74
|
const liveness_watchdog_1 = require("./liveness-watchdog");
|
|
75
|
+
const worker_teardown_1 = require("../worker-teardown");
|
|
74
76
|
/** Default poll cadence for the PPID watchdog (same as the direct server). */
|
|
75
77
|
const DEFAULT_PPID_POLL_MS = 5000;
|
|
78
|
+
/**
|
|
79
|
+
* How long a proxy serving in-process waits before trying the shared daemon
|
|
80
|
+
* again, doubling after each miss up to the cap (#2277). Tunable through
|
|
81
|
+
* `CODEGRAPH_DAEMON_RETRY_MS` (`0` turns retrying off) and
|
|
82
|
+
* `CODEGRAPH_DAEMON_RETRY_MAX_MS`.
|
|
83
|
+
*/
|
|
84
|
+
const DEFAULT_DAEMON_RETRY_MS = 5_000;
|
|
85
|
+
const DEFAULT_DAEMON_RETRY_MAX_MS = 300_000;
|
|
86
|
+
/**
|
|
87
|
+
* Longest the proxy waits, once it is shutting down, for its in-process engines
|
|
88
|
+
* to stop before exiting anyway. An engine's stop waits up to
|
|
89
|
+
* {@link WORKER_START_SETTLE_MS} for a query worker still starting up (exiting
|
|
90
|
+
* mid-start can crash the process on Windows); this bounds a stop that never
|
|
91
|
+
* settles (#2311).
|
|
92
|
+
*/
|
|
93
|
+
const SHUTDOWN_BACKSTOP_MS = worker_teardown_1.WORKER_START_SETTLE_MS + 5_000;
|
|
76
94
|
/**
|
|
77
95
|
* Env var that opts INTO the "attached to shared daemon" log line. Off by
|
|
78
96
|
* default: the line is benign INFO, but MCP hosts render any server stderr at
|
|
@@ -206,6 +224,12 @@ function sendClientHello(socket) {
|
|
|
206
224
|
* the local one). If the daemon never comes up (version mismatch / spawn fail),
|
|
207
225
|
* a lazily-created in-process engine serves the calls — so the handshake speedup
|
|
208
226
|
* never costs the old fall-back-to-direct robustness.
|
|
227
|
+
*
|
|
228
|
+
* Serving in-process is not for the rest of the session (#2277): that engine
|
|
229
|
+
* may own the project's writer lock, and no daemon can start while it does, so
|
|
230
|
+
* every other session on the project would be stuck without auto-sync. The
|
|
231
|
+
* proxy retries the daemon with backoff, handing the writer lock back first,
|
|
232
|
+
* and proxies again once one answers.
|
|
209
233
|
*/
|
|
210
234
|
async function runLocalHandshakeProxy(deps) {
|
|
211
235
|
// The proxy is long-lived and can serve fallback tool calls in-process. Match
|
|
@@ -215,6 +239,7 @@ async function runLocalHandshakeProxy(deps) {
|
|
|
215
239
|
let daemonStatus = 'connecting';
|
|
216
240
|
let daemonSocket = null;
|
|
217
241
|
let clientInitId = undefined; // suppress the daemon's reply to the forwarded initialize
|
|
242
|
+
let clientInitLine; // replayed to a daemon that comes up mid-session (#2277)
|
|
218
243
|
// Telemetry attribution for the in-process fallback only — calls routed to
|
|
219
244
|
// the daemon are counted by the daemon's own session (which receives the
|
|
220
245
|
// forwarded initialize, clientInfo included), never double-counted here.
|
|
@@ -222,7 +247,16 @@ async function runLocalHandshakeProxy(deps) {
|
|
|
222
247
|
const pending = []; // client lines buffered until the daemon resolves
|
|
223
248
|
let engine = null;
|
|
224
249
|
let engineReady = null;
|
|
250
|
+
// Calls being served in-process; the engine is only ever stopped after they finish.
|
|
251
|
+
const localCalls = new Set();
|
|
252
|
+
// Engines retired but not yet stopped; shutdown() waits for them too.
|
|
253
|
+
const retiring = new Set();
|
|
225
254
|
let shuttingDown = false;
|
|
255
|
+
const retryBaseMs = parseDelayMs(process.env.CODEGRAPH_DAEMON_RETRY_MS, DEFAULT_DAEMON_RETRY_MS);
|
|
256
|
+
const retryMaxMs = Math.max(retryBaseMs, parseDelayMs(process.env.CODEGRAPH_DAEMON_RETRY_MAX_MS, DEFAULT_DAEMON_RETRY_MAX_MS));
|
|
257
|
+
let retryDelayMs = retryBaseMs;
|
|
258
|
+
let retryTimer = null;
|
|
259
|
+
let attachedAt = 0;
|
|
226
260
|
// Requests forwarded to the daemon and not yet answered, keyed by JSON-RPC id.
|
|
227
261
|
// If the daemon dies mid-session (#662 — e.g. an MCP host SIGTERM's it when a
|
|
228
262
|
// new session starts), these would otherwise hang forever; we re-serve them
|
|
@@ -255,25 +289,67 @@ async function runLocalHandshakeProxy(deps) {
|
|
|
255
289
|
livenessWatchdog?.stop();
|
|
256
290
|
}
|
|
257
291
|
catch { /* ignore */ }
|
|
292
|
+
if (retryTimer)
|
|
293
|
+
clearTimeout(retryTimer);
|
|
258
294
|
try {
|
|
259
295
|
daemonSocket?.destroy();
|
|
260
296
|
}
|
|
261
297
|
catch { /* ignore */ }
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
298
|
+
// Exit once every engine has stopped, a retiring one included: exiting while
|
|
299
|
+
// a query worker is still starting up can crash the process on Windows (see
|
|
300
|
+
// QueryPool.destroy), and stopping releases the writer lock. The backstop
|
|
301
|
+
// bounds a stop that never settles; it stays ref'd so the process lives
|
|
302
|
+
// until one of the two exits it.
|
|
303
|
+
setTimeout(() => {
|
|
304
|
+
process.stderr.write(`[CodeGraph MCP] In-process engine did not stop within ${SHUTDOWN_BACKSTOP_MS}ms; exiting anyway.\n`);
|
|
305
|
+
process.exit(0);
|
|
306
|
+
}, SHUTDOWN_BACKSTOP_MS);
|
|
307
|
+
const stopping = [engine, ...retiring].map((e) => Promise.resolve().then(() => e?.stop()));
|
|
308
|
+
void Promise.allSettled(stopping).then(() => process.exit(0));
|
|
267
309
|
};
|
|
268
|
-
|
|
269
|
-
|
|
310
|
+
// Resolves the engine a call was started on, so a call in flight while the
|
|
311
|
+
// engine is being retired still finishes on it.
|
|
312
|
+
const ensureEngine = async () => {
|
|
313
|
+
// shutdown() stops only the engines it can see; never start one after it.
|
|
314
|
+
if (!engine && shuttingDown)
|
|
315
|
+
throw new Error('codegraph is shutting down');
|
|
316
|
+
if (!engine) {
|
|
270
317
|
engine = deps.makeEngine();
|
|
271
|
-
if (!engineReady)
|
|
272
318
|
engineReady = engine.ensureInitialized(deps.root).catch(() => { });
|
|
273
|
-
|
|
319
|
+
}
|
|
320
|
+
const current = engine;
|
|
321
|
+
await engineReady;
|
|
322
|
+
return current;
|
|
323
|
+
};
|
|
324
|
+
// Stop the in-process engine once the calls it is serving have answered.
|
|
325
|
+
// Stopping it releases the writer lock if it held one.
|
|
326
|
+
const retireEngine = async () => {
|
|
327
|
+
const retired = engine;
|
|
328
|
+
engine = null;
|
|
329
|
+
engineReady = null;
|
|
330
|
+
if (retired)
|
|
331
|
+
retiring.add(retired);
|
|
332
|
+
try {
|
|
333
|
+
await Promise.allSettled([...localCalls]);
|
|
334
|
+
try {
|
|
335
|
+
await retired?.stop();
|
|
336
|
+
}
|
|
337
|
+
catch { /* best-effort */ }
|
|
338
|
+
}
|
|
339
|
+
finally {
|
|
340
|
+
if (retired)
|
|
341
|
+
retiring.delete(retired);
|
|
342
|
+
}
|
|
274
343
|
};
|
|
275
344
|
// Daemon-unavailable fallback: serve a client message in-process.
|
|
276
|
-
const handleLocally =
|
|
345
|
+
const handleLocally = (line) => {
|
|
346
|
+
const call = serveLocally(line);
|
|
347
|
+
localCalls.add(call);
|
|
348
|
+
const done = () => { localCalls.delete(call); };
|
|
349
|
+
call.then(done, done);
|
|
350
|
+
return call;
|
|
351
|
+
};
|
|
352
|
+
const serveLocally = async (line) => {
|
|
277
353
|
let msg;
|
|
278
354
|
try {
|
|
279
355
|
msg = JSON.parse(line);
|
|
@@ -284,9 +360,9 @@ async function runLocalHandshakeProxy(deps) {
|
|
|
284
360
|
const id = msg.id;
|
|
285
361
|
if (msg.method === 'tools/call' && id !== undefined) {
|
|
286
362
|
try {
|
|
287
|
-
await ensureEngine();
|
|
363
|
+
const local = await ensureEngine();
|
|
288
364
|
const params = (msg.params || {});
|
|
289
|
-
const result = await
|
|
365
|
+
const result = await local.getToolHandler().execute(params.name, params.arguments || {}, exploreSession);
|
|
290
366
|
writeClient({ jsonrpc: '2.0', id, result });
|
|
291
367
|
(0, telemetry_1.getTelemetry)().recordUsage('mcp_tool', params.name, !result.isError, telemetryClient);
|
|
292
368
|
}
|
|
@@ -327,6 +403,10 @@ async function runLocalHandshakeProxy(deps) {
|
|
|
327
403
|
let stdinBuf = '';
|
|
328
404
|
process.stdin.setEncoding('utf8');
|
|
329
405
|
process.stdin.on('data', (chunk) => {
|
|
406
|
+
// Nothing is served once shutdown starts: a call now could start an engine
|
|
407
|
+
// shutdown() never sees, and the process exits as soon as the others stop.
|
|
408
|
+
if (shuttingDown)
|
|
409
|
+
return;
|
|
330
410
|
stdinBuf += chunk;
|
|
331
411
|
let idx;
|
|
332
412
|
while ((idx = stdinBuf.indexOf('\n')) !== -1) {
|
|
@@ -344,6 +424,7 @@ async function runLocalHandshakeProxy(deps) {
|
|
|
344
424
|
}
|
|
345
425
|
if (msg.method === 'initialize') {
|
|
346
426
|
clientInitId = msg.id;
|
|
427
|
+
clientInitLine = line;
|
|
347
428
|
const initParams = (msg.params ?? {});
|
|
348
429
|
if (initParams.clientInfo) {
|
|
349
430
|
telemetryClient = {
|
|
@@ -368,6 +449,13 @@ async function runLocalHandshakeProxy(deps) {
|
|
|
368
449
|
else if (msg.method === 'prompts/list') {
|
|
369
450
|
writeClient({ jsonrpc: '2.0', id: msg.id, result: { prompts: [] } });
|
|
370
451
|
}
|
|
452
|
+
else if (msg.method === 'server/discover' && msg.id !== undefined) {
|
|
453
|
+
// Newer clients (Antigravity 2.5) probe this before `initialize` and wait
|
|
454
|
+
// for the answer. We don't implement it; Method-not-found is what sends
|
|
455
|
+
// them on to `initialize`. Answer locally — forwarded, it waited on the
|
|
456
|
+
// daemon connection and was lost if the client closed stdin first. (#2084)
|
|
457
|
+
writeClient({ jsonrpc: '2.0', id: msg.id, error: { code: transport_1.ErrorCodes.MethodNotFound, message: 'Method not found: server/discover' } });
|
|
458
|
+
}
|
|
371
459
|
else {
|
|
372
460
|
routeToDaemon(line);
|
|
373
461
|
}
|
|
@@ -390,19 +478,70 @@ async function runLocalHandshakeProxy(deps) {
|
|
|
390
478
|
shutdown();
|
|
391
479
|
});
|
|
392
480
|
// ---- daemon connection (background) ----
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
481
|
+
const connectDaemon = async () => {
|
|
482
|
+
let socket = null;
|
|
483
|
+
try {
|
|
484
|
+
socket = await deps.getDaemonSocket();
|
|
485
|
+
}
|
|
486
|
+
catch {
|
|
487
|
+
socket = null;
|
|
488
|
+
}
|
|
489
|
+
// `socket.destroyed`: the connect-window error guard above can absorb an
|
|
490
|
+
// 'error' that already destroyed the socket before we got here (#974) — treat
|
|
491
|
+
// a dead socket as "no daemon" so we cleanly fall back to the in-process engine.
|
|
492
|
+
if (socket && (socket.destroyed || shuttingDown)) {
|
|
493
|
+
try {
|
|
494
|
+
socket.destroy();
|
|
495
|
+
}
|
|
496
|
+
catch { /* ignore */ }
|
|
497
|
+
socket = null;
|
|
498
|
+
}
|
|
499
|
+
return socket;
|
|
500
|
+
};
|
|
501
|
+
// Every buffered call binds to the engine now, so a later retirement waits for all of them.
|
|
502
|
+
const serveBufferedLocally = () => {
|
|
503
|
+
for (const line of pending.splice(0))
|
|
504
|
+
void handleLocally(line);
|
|
505
|
+
};
|
|
506
|
+
const scheduleDaemonRetry = () => {
|
|
507
|
+
if (shuttingDown || retryTimer || retryBaseMs <= 0)
|
|
508
|
+
return;
|
|
509
|
+
const delay = retryDelayMs;
|
|
510
|
+
retryDelayMs = Math.min(retryDelayMs * 2, retryMaxMs);
|
|
511
|
+
retryTimer = setTimeout(() => { retryTimer = null; void retryDaemon(); }, delay);
|
|
512
|
+
retryTimer.unref?.();
|
|
513
|
+
};
|
|
514
|
+
const retryDaemon = async () => {
|
|
515
|
+
if (shuttingDown || daemonStatus !== 'failed')
|
|
516
|
+
return;
|
|
517
|
+
// While a writing engine owns writer.pid no daemon can start (#2277). Hand
|
|
518
|
+
// the lock back first, once the calls it is serving have answered, and
|
|
519
|
+
// buffer new calls until a daemon answers or we resume in-process. One
|
|
520
|
+
// writer at a time: the engine is fully stopped before a daemon is spawned.
|
|
521
|
+
const handover = engine !== null && !engine.isReadOnly();
|
|
522
|
+
if (handover) {
|
|
523
|
+
daemonStatus = 'connecting';
|
|
524
|
+
await retireEngine();
|
|
525
|
+
}
|
|
526
|
+
const socket = await connectDaemon();
|
|
527
|
+
if (shuttingDown)
|
|
528
|
+
return;
|
|
529
|
+
if (socket) {
|
|
530
|
+
process.stderr.write('[CodeGraph MCP] Shared daemon reachable; proxying this session to it instead of serving in-process.\n');
|
|
531
|
+
attachDaemon(socket, true);
|
|
532
|
+
// A read-only engine holds no lock: let its calls finish, then close it.
|
|
533
|
+
if (!handover)
|
|
534
|
+
void retireEngine();
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
daemonStatus = 'failed';
|
|
538
|
+
serveBufferedLocally();
|
|
539
|
+
scheduleDaemonRetry();
|
|
540
|
+
};
|
|
541
|
+
const attachDaemon = (socket, replayInitialize) => {
|
|
404
542
|
daemonSocket = socket;
|
|
405
543
|
daemonStatus = 'ready';
|
|
544
|
+
attachedAt = Date.now();
|
|
406
545
|
let sockBuf = '';
|
|
407
546
|
socket.setEncoding('utf8');
|
|
408
547
|
socket.on('data', (chunk) => {
|
|
@@ -433,25 +572,39 @@ async function runLocalHandshakeProxy(deps) {
|
|
|
433
572
|
// The daemon going away does NOT end the session (#662). An MCP host can
|
|
434
573
|
// SIGTERM the shared daemon when another session starts; if we exited here,
|
|
435
574
|
// this host would silently lose CodeGraph and any in-flight request would
|
|
436
|
-
// hang. Instead, fall back to the in-process engine
|
|
437
|
-
//
|
|
575
|
+
// hang. Instead, fall back to the in-process engine until a daemon answers
|
|
576
|
+
// again, and re-serve whatever the dead daemon never answered.
|
|
438
577
|
const onDaemonLost = () => {
|
|
439
|
-
if (shuttingDown ||
|
|
578
|
+
if (shuttingDown || daemonSocket !== socket)
|
|
440
579
|
return; // host teardown, or already handled
|
|
441
580
|
daemonStatus = 'failed';
|
|
581
|
+
daemonSocket = null;
|
|
442
582
|
try {
|
|
443
|
-
|
|
583
|
+
socket.destroy();
|
|
444
584
|
}
|
|
445
585
|
catch { /* ignore */ }
|
|
446
|
-
daemonSocket = null;
|
|
447
586
|
process.stderr.write(`[CodeGraph MCP] Shared daemon connection lost; serving this session in-process (degraded), re-serving ${inflight.size} in-flight request(s).\n`);
|
|
448
587
|
const orphaned = [...inflight.values()];
|
|
449
588
|
inflight.clear();
|
|
450
589
|
for (const line of orphaned)
|
|
451
590
|
void handleLocally(line);
|
|
591
|
+
// A link that stayed up past the longest wait starts the backoff over; one
|
|
592
|
+
// that keeps dropping right after it attaches keeps backing off.
|
|
593
|
+
if (Date.now() - attachedAt >= retryMaxMs)
|
|
594
|
+
retryDelayMs = retryBaseMs;
|
|
595
|
+
scheduleDaemonRetry();
|
|
452
596
|
};
|
|
453
597
|
socket.on('close', onDaemonLost);
|
|
454
598
|
socket.on('error', onDaemonLost);
|
|
599
|
+
// A daemon that came up mid-session has never seen this client: prime its
|
|
600
|
+
// session with the client's own initialize, whose reply is suppressed
|
|
601
|
+
// above like the first one.
|
|
602
|
+
if (replayInitialize && clientInitLine !== undefined) {
|
|
603
|
+
try {
|
|
604
|
+
socket.write(clientInitLine + '\n');
|
|
605
|
+
}
|
|
606
|
+
catch { /* close path */ }
|
|
607
|
+
}
|
|
455
608
|
for (const line of pending) {
|
|
456
609
|
trackInflight(line);
|
|
457
610
|
if (process.env.CODEGRAPH_MCP_DEBUG)
|
|
@@ -462,13 +615,16 @@ async function runLocalHandshakeProxy(deps) {
|
|
|
462
615
|
catch { /* ignore */ }
|
|
463
616
|
}
|
|
464
617
|
pending.length = 0;
|
|
618
|
+
};
|
|
619
|
+
const socket = await connectDaemon();
|
|
620
|
+
if (socket) {
|
|
621
|
+
attachDaemon(socket, false);
|
|
465
622
|
}
|
|
466
623
|
else if (!shuttingDown) {
|
|
467
624
|
daemonStatus = 'failed';
|
|
468
625
|
process.stderr.write('[CodeGraph MCP] Shared daemon unavailable; serving this session in-process (degraded).\n');
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
await handleLocally(line);
|
|
626
|
+
serveBufferedLocally();
|
|
627
|
+
scheduleDaemonRetry();
|
|
472
628
|
}
|
|
473
629
|
await new Promise(() => { });
|
|
474
630
|
}
|
|
@@ -649,13 +805,17 @@ function startPpidWatchdog(socket) {
|
|
|
649
805
|
timer.unref?.();
|
|
650
806
|
}
|
|
651
807
|
function parsePollMs(raw) {
|
|
808
|
+
return parseDelayMs(raw, DEFAULT_PPID_POLL_MS);
|
|
809
|
+
}
|
|
810
|
+
/** A non-negative millisecond env value; unset or malformed gives `fallback`. */
|
|
811
|
+
function parseDelayMs(raw, fallback) {
|
|
652
812
|
if (raw === undefined || raw === '')
|
|
653
|
-
return
|
|
813
|
+
return fallback;
|
|
654
814
|
const parsed = Number(raw);
|
|
655
815
|
if (!Number.isFinite(parsed))
|
|
656
|
-
return
|
|
816
|
+
return fallback;
|
|
657
817
|
if (parsed < 0)
|
|
658
|
-
return
|
|
818
|
+
return fallback;
|
|
659
819
|
return Math.floor(parsed);
|
|
660
820
|
}
|
|
661
821
|
function parseHostPpid(raw) {
|