@vibgrate/cli 2026.817.2 → 2026.818.1

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.
Files changed (143) hide show
  1. package/dist/activity-MF2GNYAI.js +5 -0
  2. package/dist/activity-MF2GNYAI.js.map +1 -0
  3. package/dist/agent-CUK24AWF.js +30 -0
  4. package/dist/{agent-UQC7QN77.js.map → agent-CUK24AWF.js.map} +1 -1
  5. package/dist/{approvals-ASPJQUZK.js → approvals-YFOU6GVB.js} +5 -5
  6. package/dist/{approvals-ASPJQUZK.js.map → approvals-YFOU6GVB.js.map} +1 -1
  7. package/dist/attach-6S3XS7VO.js +9 -0
  8. package/dist/attach-6S3XS7VO.js.map +1 -0
  9. package/dist/baseline-OBZJRCCP.js +9 -0
  10. package/dist/{baseline-FIV6PR2M.js.map → baseline-OBZJRCCP.js.map} +1 -1
  11. package/dist/{chunk-E2FAQREZ.js → chunk-43ESHUM5.js} +174 -401
  12. package/dist/chunk-43ESHUM5.js.map +1 -0
  13. package/dist/{chunk-K6DXETMC.js → chunk-4QAMUBAC.js} +13 -12
  14. package/dist/chunk-4QAMUBAC.js.map +1 -0
  15. package/dist/{chunk-6K3XK7C5.js → chunk-6ABMV74F.js} +6 -3
  16. package/dist/chunk-6ABMV74F.js.map +1 -0
  17. package/dist/chunk-6BEBJCK4.js +467 -0
  18. package/dist/chunk-6BEBJCK4.js.map +1 -0
  19. package/dist/{chunk-KJT2R6WW.js → chunk-6LY3JH6S.js} +3 -3
  20. package/dist/{chunk-KJT2R6WW.js.map → chunk-6LY3JH6S.js.map} +1 -1
  21. package/dist/chunk-6WRG7VDO.js +118 -0
  22. package/dist/chunk-6WRG7VDO.js.map +1 -0
  23. package/dist/chunk-DBX3DL27.js +26 -0
  24. package/dist/chunk-DBX3DL27.js.map +1 -0
  25. package/dist/{chunk-Q3M6K3HY.js → chunk-DH6EDSQP.js} +3 -3
  26. package/dist/{chunk-Q3M6K3HY.js.map → chunk-DH6EDSQP.js.map} +1 -1
  27. package/dist/{chunk-5OL2TSHK.js → chunk-DM6MJ7IF.js} +4 -4
  28. package/dist/{chunk-5OL2TSHK.js.map → chunk-DM6MJ7IF.js.map} +1 -1
  29. package/dist/{chunk-Q4G2BWE3.js → chunk-DUCEKH7Q.js} +12 -6
  30. package/dist/chunk-DUCEKH7Q.js.map +1 -0
  31. package/dist/{chunk-EXV4QSAD.js → chunk-E7RVA2ZI.js} +3 -3
  32. package/dist/{chunk-EXV4QSAD.js.map → chunk-E7RVA2ZI.js.map} +1 -1
  33. package/dist/{chunk-C3LMWZKF.js → chunk-FFYO7G3T.js} +4 -4
  34. package/dist/{chunk-C3LMWZKF.js.map → chunk-FFYO7G3T.js.map} +1 -1
  35. package/dist/chunk-G7ZFSH5J.js +132 -0
  36. package/dist/chunk-G7ZFSH5J.js.map +1 -0
  37. package/dist/{chunk-M7IO3DXH.js → chunk-GKZU6MII.js} +165 -31
  38. package/dist/chunk-GKZU6MII.js.map +1 -0
  39. package/dist/chunk-H5Q4JUY4.js +47 -0
  40. package/dist/chunk-H5Q4JUY4.js.map +1 -0
  41. package/dist/{chunk-LHKQGVRF.js → chunk-H6RV2OAX.js} +31 -10
  42. package/dist/chunk-H6RV2OAX.js.map +1 -0
  43. package/dist/{chunk-2FEB5KJS.js → chunk-I3PKYYRP.js} +5 -4
  44. package/dist/chunk-I3PKYYRP.js.map +1 -0
  45. package/dist/{chunk-XLXJC7H3.js → chunk-J3A3O4IA.js} +5 -118
  46. package/dist/chunk-J3A3O4IA.js.map +1 -0
  47. package/dist/{chunk-O2DL2Q55.js → chunk-J7CVFTLG.js} +5 -5
  48. package/dist/{chunk-O2DL2Q55.js.map → chunk-J7CVFTLG.js.map} +1 -1
  49. package/dist/{chunk-3NJUOIZQ.js → chunk-LHQYYBCH.js} +5 -5
  50. package/dist/{chunk-3NJUOIZQ.js.map → chunk-LHQYYBCH.js.map} +1 -1
  51. package/dist/{chunk-GOGMS3ST.js → chunk-MHJBIGWV.js} +752 -51
  52. package/dist/chunk-MHJBIGWV.js.map +1 -0
  53. package/dist/chunk-NDNNOAS6.js +16 -0
  54. package/dist/chunk-NDNNOAS6.js.map +1 -0
  55. package/dist/{chunk-RBIRXQR6.js → chunk-NO4BMW7M.js} +4 -14
  56. package/dist/chunk-NO4BMW7M.js.map +1 -0
  57. package/dist/{chunk-DVW3SVCW.js → chunk-OS4YFOFJ.js} +29 -9
  58. package/dist/chunk-OS4YFOFJ.js.map +1 -0
  59. package/dist/{chunk-3H3SVJUY.js → chunk-OVUZWR67.js} +107 -542
  60. package/dist/chunk-OVUZWR67.js.map +1 -0
  61. package/dist/chunk-POOL355F.js +237 -0
  62. package/dist/chunk-POOL355F.js.map +1 -0
  63. package/dist/{chunk-WVMOGIPC.js → chunk-Q7TWHJJ6.js} +3 -3
  64. package/dist/{chunk-WVMOGIPC.js.map → chunk-Q7TWHJJ6.js.map} +1 -1
  65. package/dist/{chunk-3FMRFECC.js → chunk-SBHK4ECM.js} +3 -3
  66. package/dist/{chunk-3FMRFECC.js.map → chunk-SBHK4ECM.js.map} +1 -1
  67. package/dist/chunk-SUD54UGN.js +6 -0
  68. package/dist/{chunk-PRG2ULPK.js.map → chunk-SUD54UGN.js.map} +1 -1
  69. package/dist/{chunk-WAKP7SK7.js → chunk-V2UGRUTL.js} +225 -48
  70. package/dist/chunk-V2UGRUTL.js.map +1 -0
  71. package/dist/{chunk-AXZZ5CCG.js → chunk-WVTGF2MP.js} +38 -19
  72. package/dist/chunk-WVTGF2MP.js.map +1 -0
  73. package/dist/{chunk-TVDMNIUT.js → chunk-X4DECFUG.js} +4 -4
  74. package/dist/{chunk-TVDMNIUT.js.map → chunk-X4DECFUG.js.map} +1 -1
  75. package/dist/{chunk-OZ3IFXRD.js → chunk-YENM3HT7.js} +5 -4
  76. package/dist/chunk-YENM3HT7.js.map +1 -0
  77. package/dist/{chunk-KNGAZDGF.js → chunk-ZWFMJUXC.js} +151 -42
  78. package/dist/chunk-ZWFMJUXC.js.map +1 -0
  79. package/dist/cli.d.ts +6 -0
  80. package/dist/cli.js +576 -454
  81. package/dist/cli.js.map +1 -1
  82. package/dist/daemon-4Q5QBBAF.js +31 -0
  83. package/dist/{daemon-FPTRHO5N.js.map → daemon-4Q5QBBAF.js.map} +1 -1
  84. package/dist/embed-worker-main.js +3 -3
  85. package/dist/ensure-map-B2PS5ALS.js +40 -0
  86. package/dist/{ensure-map-342G2IV3.js.map → ensure-map-B2PS5ALS.js.map} +1 -1
  87. package/dist/graph-backend-EEXMD6XY.js +16 -0
  88. package/dist/{graph-backend-RNWQBT3P.js.map → graph-backend-EEXMD6XY.js.map} +1 -1
  89. package/dist/index.d.ts +606 -4
  90. package/dist/index.js +24 -17
  91. package/dist/index.js.map +1 -1
  92. package/dist/{interactive-SR7TMF6M.js → interactive-KEPGE5HD.js} +40 -33
  93. package/dist/interactive-KEPGE5HD.js.map +1 -0
  94. package/dist/load-H5HAME25.js +11 -0
  95. package/dist/{load-AYFECIQB.js.map → load-H5HAME25.js.map} +1 -1
  96. package/dist/parse-worker.js +3 -2
  97. package/dist/parse-worker.js.map +1 -1
  98. package/dist/{run-outcome-YQQJG3LW.js → run-outcome-V3L4GAN4.js} +5 -5
  99. package/dist/{run-outcome-YQQJG3LW.js.map → run-outcome-V3L4GAN4.js.map} +1 -1
  100. package/dist/runtime-session-M2FRGTDS.js +27 -0
  101. package/dist/{runtime-session-CNJ4DAV5.js.map → runtime-session-M2FRGTDS.js.map} +1 -1
  102. package/dist/{session-H34HUV2Y.js → session-77YXFUC7.js} +8 -8
  103. package/dist/{session-H34HUV2Y.js.map → session-77YXFUC7.js.map} +1 -1
  104. package/dist/slot-subscription-25GOARW5.js +95 -0
  105. package/dist/slot-subscription-25GOARW5.js.map +1 -0
  106. package/dist/{stream-json-55YDNAFX.js → stream-json-S6E3W2US.js} +18 -15
  107. package/dist/stream-json-S6E3W2US.js.map +1 -0
  108. package/dist/version-VRZT5G4T.js +4 -0
  109. package/dist/{version-WSE3QOPK.js.map → version-VRZT5G4T.js.map} +1 -1
  110. package/dist/{vg-mcp-bridge-2CNLHNEL.js → vg-mcp-bridge-HCPJWJKJ.js} +12 -11
  111. package/dist/vg-mcp-bridge-HCPJWJKJ.js.map +1 -0
  112. package/dist/{vgd-URUZQORN.js → vgd-R2PNIDEP.js} +15 -10
  113. package/dist/vgd-R2PNIDEP.js.map +1 -0
  114. package/package.json +1 -1
  115. package/dist/agent-UQC7QN77.js +0 -27
  116. package/dist/baseline-FIV6PR2M.js +0 -9
  117. package/dist/chunk-2FEB5KJS.js.map +0 -1
  118. package/dist/chunk-3H3SVJUY.js.map +0 -1
  119. package/dist/chunk-6K3XK7C5.js.map +0 -1
  120. package/dist/chunk-AXZZ5CCG.js.map +0 -1
  121. package/dist/chunk-DVW3SVCW.js.map +0 -1
  122. package/dist/chunk-E2FAQREZ.js.map +0 -1
  123. package/dist/chunk-GOGMS3ST.js.map +0 -1
  124. package/dist/chunk-K6DXETMC.js.map +0 -1
  125. package/dist/chunk-KNGAZDGF.js.map +0 -1
  126. package/dist/chunk-LHKQGVRF.js.map +0 -1
  127. package/dist/chunk-M7IO3DXH.js.map +0 -1
  128. package/dist/chunk-OZ3IFXRD.js.map +0 -1
  129. package/dist/chunk-PRG2ULPK.js +0 -6
  130. package/dist/chunk-Q4G2BWE3.js.map +0 -1
  131. package/dist/chunk-RBIRXQR6.js.map +0 -1
  132. package/dist/chunk-WAKP7SK7.js.map +0 -1
  133. package/dist/chunk-XLXJC7H3.js.map +0 -1
  134. package/dist/daemon-FPTRHO5N.js +0 -26
  135. package/dist/ensure-map-342G2IV3.js +0 -33
  136. package/dist/graph-backend-RNWQBT3P.js +0 -15
  137. package/dist/interactive-SR7TMF6M.js.map +0 -1
  138. package/dist/load-AYFECIQB.js +0 -11
  139. package/dist/runtime-session-CNJ4DAV5.js +0 -22
  140. package/dist/stream-json-55YDNAFX.js.map +0 -1
  141. package/dist/version-WSE3QOPK.js +0 -4
  142. package/dist/vg-mcp-bridge-2CNLHNEL.js.map +0 -1
  143. package/dist/vgd-URUZQORN.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { G as GraphNode, a as GraphEdge, A as Area, R as ResolverKind, V as VgGr
2
2
  export { e as AnalysisTier, C as Centrality, D as DerivedBy, f as EpistemicTier, g as FactConfidence, h as FactKind, i as GraphMeta, j as GraphSummaries, H as HubBlastSummary, N as NodeKind, P as Provenance, k as SUPPORTED_SCHEMA_VERSIONS, l as Span, m as SupportedSchemaVersion, T as Toolchain, U as Unknown } from './types-DHqH0XIE.js';
3
3
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
4
4
 
5
- declare const VERSION = "2026.817.2";
5
+ declare const VERSION = "2026.818.1";
6
6
 
7
7
  /**
8
8
  * Analysis stage: importance, centrality, hubs, communities, and surprise.
@@ -699,9 +699,24 @@ interface QueryResult {
699
699
  }
700
700
  declare function queryGraph(graph: VgGraph, question: string, options?: QueryOptions): QueryResult;
701
701
  interface SemanticQueryOptions extends QueryOptions {
702
- embedder: Embedder;
702
+ /** Local embedder. Optional only when {@link semanticRanked} supplies the pass. */
703
+ embedder?: Embedder;
703
704
  /** Precomputed node vectors (from getNodeEmbeddings); falls back to lexical for nodes without one. */
704
- nodeVectors: Map<string, number[]>;
705
+ nodeVectors?: Map<string, number[]>;
706
+ /**
707
+ * A semantic pass someone else already ran — vgd ranking the question
708
+ * against its resident slot index. Supplied instead of `embedder` +
709
+ * `nodeVectors` so the caller pays neither a model load nor a vector scan,
710
+ * and no vectors cross the socket.
711
+ *
712
+ * Only the ORDER of this list is consumed (RRF fuses rankings, not scores),
713
+ * so a truncated top-K is not an approximation: a candidate ranked past a
714
+ * few hundred cannot reach a 12-row answer.
715
+ */
716
+ semanticRanked?: Array<{
717
+ id: string;
718
+ score: number;
719
+ }>;
705
720
  }
706
721
  /**
707
722
  * Hybrid lexical + local-embedding retrieval, combined with Reciprocal Rank
@@ -802,6 +817,570 @@ declare class GraphIndex {
802
817
  private resolveTargets;
803
818
  }
804
819
 
820
+ /**
821
+ * Wire protocol for the lightweight Vibgrate daemon (`vgd`) — Fusion Runtime Phase 2 prototype.
822
+ *
823
+ * Line-delimited JSON over a local Unix domain socket (named pipe on Windows).
824
+ * No credentials leave this process; the socket is local-only.
825
+ */
826
+ declare const VGD_PROTOCOL_VERSION: "vgd/0";
827
+ interface WorkspaceRecord {
828
+ /** Stable repository id (same as global store key). */
829
+ id: string;
830
+ /** Absolute repository root. */
831
+ root: string;
832
+ /** Absolute path to the current graph snapshot (may not exist yet). */
833
+ graphPath: string;
834
+ /** ISO timestamp when this workspace was last registered / refreshed. */
835
+ registeredAt: string;
836
+ /** Optional federation label. */
837
+ label?: string;
838
+ /** Optional federation role. */
839
+ role?: 'primary' | 'member';
840
+ /** Git branch or detached SHA at registration (multi-branch ActiveGraph). */
841
+ gitRef?: string;
842
+ }
843
+ /** Lightweight ActiveGraph slot summary (no full graph payload). */
844
+ interface GraphSlotSummary {
845
+ repositoryId: string;
846
+ gitRef: string;
847
+ loadedAt: number;
848
+ lastAccessAt: number;
849
+ nodeCount: number;
850
+ current: boolean;
851
+ idleMs: number;
852
+ evictable: boolean;
853
+ }
854
+ type VgdRequest = {
855
+ op: 'ping';
856
+ } | {
857
+ op: 'status';
858
+ }
859
+ /** Ask the daemon to exit cleanly (honoured only by a standalone `vg daemon start`). */
860
+ | {
861
+ op: 'shutdown';
862
+ } | {
863
+ op: 'list';
864
+ } | {
865
+ op: 'register';
866
+ root: string;
867
+ label?: string;
868
+ role?: 'primary' | 'member';
869
+ } | {
870
+ op: 'unregister';
871
+ root: string;
872
+ } | {
873
+ op: 'register-federation';
874
+ primaryRoot: string;
875
+ members: Array<{
876
+ root: string;
877
+ label?: string;
878
+ role?: 'primary' | 'member';
879
+ }>;
880
+ } | {
881
+ op: 'list-graph-slots';
882
+ repositoryId?: string;
883
+ } | {
884
+ op: 'select-git-ref';
885
+ repositoryId: string;
886
+ gitRef: string;
887
+ } | {
888
+ op: 'put-graph';
889
+ repositoryId: string;
890
+ gitRef: string;
891
+ graph: unknown;
892
+ }
893
+ /**
894
+ * Load the workspace's on-disk code map into ActiveGraph inside the daemon
895
+ * (binary snapshot first, JSON fallback). The fast-path alternative to
896
+ * shipping the whole graph over the socket with put-graph — use it whenever
897
+ * the map already exists on disk.
898
+ */
899
+ | {
900
+ op: 'load-graph';
901
+ root: string;
902
+ gitRef?: string;
903
+ graphPath?: string;
904
+ }
905
+ /** Lexical/structural query against the ActiveGraph for a repository. */
906
+ | {
907
+ op: 'query-graph';
908
+ repositoryId: string;
909
+ query: string;
910
+ limit?: number;
911
+ gitRef?: string;
912
+ semantic?: boolean;
913
+ }
914
+ /** Blast-radius impact for a symbol id or qualified name. */
915
+ | {
916
+ op: 'impact-of';
917
+ repositoryId: string;
918
+ symbol: string;
919
+ depth?: number;
920
+ gitRef?: string;
921
+ }
922
+ /** Compact graph meta for the current (or named) slot — not the full graph. */
923
+ | {
924
+ op: 'graph-summary';
925
+ repositoryId: string;
926
+ gitRef?: string;
927
+ }
928
+ /** Semantic warm (docs/VGD-SEMANTIC-WARM-SPEC.md): worker + per-slot index state. */
929
+ | {
930
+ op: 'embed-status';
931
+ repositoryId?: string;
932
+ }
933
+ /** Embed one string in the daemon's warm worker; the caller ranks locally. */
934
+ | {
935
+ op: 'embed-query';
936
+ text: string;
937
+ }
938
+ /** Ensure the slot's vector index exists, building it if needed. */
939
+ | {
940
+ op: 'embed-index';
941
+ repositoryId: string;
942
+ gitRef?: string;
943
+ } | {
944
+ op: 'embed-rank';
945
+ repositoryId: string;
946
+ gitRef?: string;
947
+ text: string;
948
+ limit?: number;
949
+ } | {
950
+ op: 'dep-context';
951
+ repositoryId: string;
952
+ }
953
+ /**
954
+ * Hold this connection open and stream slot changes on it. The only op that
955
+ * does not answer once and stop — everything else is request/response.
956
+ */
957
+ | {
958
+ op: 'watch-slots';
959
+ repositoryId?: string;
960
+ }
961
+ /** Approach B host broker: warm model status inside vgd. */
962
+ | {
963
+ op: 'host-status';
964
+ } | {
965
+ op: 'host-load';
966
+ modelPath: string;
967
+ } | {
968
+ op: 'host-unload';
969
+ modelPath?: string;
970
+ } | {
971
+ op: 'host-generate';
972
+ modelPath: string;
973
+ messages: Array<{
974
+ role: string;
975
+ content: string;
976
+ }>;
977
+ grammar?: string;
978
+ requireGrammar?: boolean;
979
+ maxTokens?: number;
980
+ temperature?: number;
981
+ };
982
+ /** Semantic warm state: the worker, and one row per resident slot index. */
983
+ interface EmbedStatusPayload {
984
+ worker: 'stopped' | 'starting' | 'ready' | 'unavailable';
985
+ pid?: number;
986
+ model?: string;
987
+ crashes: number;
988
+ reason?: string;
989
+ slots: Array<{
990
+ repositoryId: string;
991
+ gitRef: string;
992
+ state: string;
993
+ vectors: number;
994
+ nodeCount: number;
995
+ /** Targets still missing a vector on a slot that is not ready. */
996
+ pending?: number;
997
+ builtAt?: number;
998
+ buildMs?: number;
999
+ error?: string;
1000
+ }>;
1001
+ }
1002
+ /** Compact match row for query-graph (no full node payloads). */
1003
+ interface VgdQueryMatch {
1004
+ id: string;
1005
+ qualifiedName: string;
1006
+ kind: string;
1007
+ file: string;
1008
+ line: number;
1009
+ score: number;
1010
+ why: string;
1011
+ }
1012
+ interface VgdImpactItem {
1013
+ id: string;
1014
+ name: string;
1015
+ kind: string;
1016
+ file: string;
1017
+ line: number;
1018
+ depth: number;
1019
+ confidence: number;
1020
+ }
1021
+ type VgdResponse = {
1022
+ ok: true;
1023
+ pong: true;
1024
+ version: typeof VGD_PROTOCOL_VERSION;
1025
+ } | {
1026
+ ok: true;
1027
+ pid: number;
1028
+ uptimeMs: number;
1029
+ workspaces: number;
1030
+ /** Resident multi-branch ActiveGraph slots (Fusion §4.1.1). */
1031
+ graphSlots?: number;
1032
+ version: typeof VGD_PROTOCOL_VERSION;
1033
+ socketPath: string;
1034
+ /** Calendar version of the CLI process serving this socket. */
1035
+ cliVersion?: string;
1036
+ /** What the daemon is watching, and what it is mid-rebuild on. */
1037
+ freshness?: Array<{
1038
+ repositoryId: string;
1039
+ root: string;
1040
+ gitRef: string;
1041
+ watching: boolean;
1042
+ pending: number;
1043
+ building: boolean;
1044
+ lastRebuildAt?: number;
1045
+ }>;
1046
+ } | {
1047
+ ok: true;
1048
+ workspaces: WorkspaceRecord[];
1049
+ } | {
1050
+ ok: true;
1051
+ workspace: WorkspaceRecord;
1052
+ } | {
1053
+ ok: true;
1054
+ workspaces: WorkspaceRecord[];
1055
+ federation: true;
1056
+ } | {
1057
+ ok: true;
1058
+ removed: boolean;
1059
+ } | {
1060
+ ok: true;
1061
+ stopping: true;
1062
+ } | {
1063
+ ok: true;
1064
+ slots: GraphSlotSummary[];
1065
+ } | {
1066
+ ok: true;
1067
+ watching: true;
1068
+ repositoryId?: string;
1069
+ }
1070
+ /**
1071
+ * An unsolicited frame on a `watch-slots` connection: this repo's map
1072
+ * changed and the subscriber should reload it. Carries the corpus hash so a
1073
+ * subscriber that already has that map can ignore the event.
1074
+ */
1075
+ | {
1076
+ ok: true;
1077
+ event: 'slot-changed';
1078
+ repositoryId: string;
1079
+ gitRef: string;
1080
+ nodeCount: number;
1081
+ corpusHash: string | null;
1082
+ } | {
1083
+ ok: true;
1084
+ semantic: EmbedStatusPayload;
1085
+ } | {
1086
+ ok: true;
1087
+ repositoryId: string;
1088
+ /** Digest of every manifest and lockfile in the tree. */
1089
+ manifestHash: string;
1090
+ /** Declared/installed dependency records, as `engine/drift.ts` builds them. */
1091
+ dependencies: Array<{
1092
+ name: string;
1093
+ ecosystem: string;
1094
+ declared: string;
1095
+ installed?: string;
1096
+ }>;
1097
+ builtAt: number;
1098
+ } | {
1099
+ ok: true;
1100
+ vector: number[];
1101
+ model?: string;
1102
+ } | {
1103
+ ok: true;
1104
+ ranked: Array<{
1105
+ id: string;
1106
+ score: number;
1107
+ }>;
1108
+ repositoryId: string;
1109
+ gitRef: string;
1110
+ state: string;
1111
+ vectors: number;
1112
+ model?: string;
1113
+ rankMs: number;
1114
+ } | {
1115
+ ok: true;
1116
+ indexed: true;
1117
+ repositoryId: string;
1118
+ gitRef: string;
1119
+ state: string;
1120
+ vectors: number;
1121
+ buildMs?: number;
1122
+ } | {
1123
+ ok: true;
1124
+ selected: true;
1125
+ repositoryId: string;
1126
+ gitRef: string;
1127
+ } | {
1128
+ ok: true;
1129
+ stored: true;
1130
+ repositoryId: string;
1131
+ gitRef: string;
1132
+ nodeCount: number;
1133
+ } | {
1134
+ ok: true;
1135
+ query: string;
1136
+ repositoryId: string;
1137
+ gitRef: string;
1138
+ /** How the ranking was produced — `lexical` when semantic was not available. */
1139
+ mode?: string;
1140
+ matches: VgdQueryMatch[];
1141
+ tokensEstimate: number;
1142
+ } | {
1143
+ ok: true;
1144
+ repositoryId: string;
1145
+ gitRef: string;
1146
+ symbol: string;
1147
+ root: {
1148
+ id: string;
1149
+ name: string;
1150
+ };
1151
+ depth: number;
1152
+ affected: VgdImpactItem[];
1153
+ direct: number;
1154
+ transitive: number;
1155
+ } | {
1156
+ ok: true;
1157
+ repositoryId: string;
1158
+ gitRef: string;
1159
+ summary: {
1160
+ nodeCount: number;
1161
+ edgeCount: number;
1162
+ languages: string[];
1163
+ corpusHash: string | null;
1164
+ root: string | null;
1165
+ };
1166
+ } | {
1167
+ ok: true;
1168
+ host: {
1169
+ poolSize: number;
1170
+ loadedModels: string[];
1171
+ bindingReady: boolean;
1172
+ };
1173
+ } | {
1174
+ ok: true;
1175
+ hostLoaded: true;
1176
+ modelPath: string;
1177
+ } | {
1178
+ ok: true;
1179
+ hostUnloaded: true;
1180
+ cleared: number;
1181
+ } | {
1182
+ ok: true;
1183
+ hostGenerated: true;
1184
+ text: string;
1185
+ model: string;
1186
+ constrained: boolean;
1187
+ grammarApplied?: boolean;
1188
+ draftAcceptedChars?: number;
1189
+ latencyMs?: number;
1190
+ unknownIdentifiers?: string[];
1191
+ } | {
1192
+ ok: false;
1193
+ error: string;
1194
+ code?: string;
1195
+ };
1196
+
1197
+ interface VgdClientOptions {
1198
+ socketPath?: string;
1199
+ /** End-to-end response timeout in ms (default: per-op, see {@link defaultVgdTimeoutMs}). */
1200
+ timeoutMs?: number;
1201
+ }
1202
+ /**
1203
+ * Send one request to a running vgd and return the parsed response.
1204
+ * Rejects if the daemon is not reachable.
1205
+ */
1206
+ declare function vgdRequest(request: VgdRequest, options?: VgdClientOptions): Promise<VgdResponse>;
1207
+ /** True when a local vgd answers ping. */
1208
+ declare function vgdIsRunning(options?: VgdClientOptions): Promise<boolean>;
1209
+
1210
+ type VgdPublishOutcome = {
1211
+ status: 'not-running';
1212
+ } | {
1213
+ status: 'failed';
1214
+ error: string;
1215
+ }
1216
+ /** The daemon already holds this exact map — nothing was sent. */
1217
+ | {
1218
+ status: 'current';
1219
+ repositoryId: string;
1220
+ gitRef: string;
1221
+ } | {
1222
+ status: 'published';
1223
+ repositoryId: string;
1224
+ gitRef: string;
1225
+ nodeCount: number;
1226
+ semantic?: string;
1227
+ };
1228
+
1229
+ /**
1230
+ * The one way an ordinary command joins the local runtime.
1231
+ *
1232
+ * Until now vgd only ever existed because `vg code` or the VS Code extension
1233
+ * started it, so a developer running `vg`, `vg build` and `vg ask` all day
1234
+ * never had a runtime at all — every invocation re-read the map and re-loaded
1235
+ * the embedder from cold. Auto-start makes the daemon the normal case, and
1236
+ * publishing on attach makes it hold the thing it is supposed to accelerate.
1237
+ *
1238
+ * Three rules keep this safe to put in front of every command:
1239
+ *
1240
+ * - **Never blocking.** `ensureVgdSoft` spawns and waits ~1.5s, not the 30s
1241
+ * `vg daemon ensure` waits. A daemon that is still coming up simply is not
1242
+ * used this time; the command runs its in-process path and finds a warm
1243
+ * runtime on the next call.
1244
+ * - **Never fatal.** Every outcome is a value, never a throw. "No daemon" is a
1245
+ * supported configuration, and it must stay one — the fallbacks are the
1246
+ * code paths that exist today.
1247
+ * - **Always escapable.** `--no-daemon`, `VG_NO_DAEMON=1`, and `CI` all turn
1248
+ * auto-start off. A one-shot CI job should not leave a background process
1249
+ * behind, and a user who does not want one must be able to say so once.
1250
+ */
1251
+ type AttachStatus = 'attached' | 'disabled' | 'unavailable';
1252
+ interface AttachResult {
1253
+ status: AttachStatus;
1254
+ /** Why, when not attached — safe to show verbatim. */
1255
+ reason?: string;
1256
+ /** True when this call is what started the daemon. */
1257
+ started?: boolean;
1258
+ socketPath?: string;
1259
+ repositoryId?: string;
1260
+ gitRef?: string;
1261
+ /** Outcome of the map publish, when one was requested. */
1262
+ published?: VgdPublishOutcome;
1263
+ }
1264
+ interface AttachOptions {
1265
+ socketPath?: string;
1266
+ /** Spawn a daemon when none is listening (default true). */
1267
+ autoStart?: boolean;
1268
+ /** How long to wait for a just-spawned daemon before giving up (default 1500ms). */
1269
+ readyBudgetMs?: number;
1270
+ /** Publish this repo's map after attaching (default true). */
1271
+ publish?: boolean;
1272
+ /**
1273
+ * The corpus hash of the map the caller already holds. When the daemon's
1274
+ * slot reports the same hash the publish is skipped entirely.
1275
+ *
1276
+ * This matters more than it looks: `load-graph` runs the registry's slot
1277
+ * funnel, and `onGraphPut` deliberately drops the slot's vectors — so
1278
+ * re-publishing an unchanged map on every `vg ask` invalidated and re-seeded
1279
+ * the semantic index once per command, for nothing.
1280
+ */
1281
+ corpusHash?: string;
1282
+ /** Also wait for the slot's semantic index (default false — warming is background work). */
1283
+ warmSemantic?: boolean;
1284
+ gitRef?: string;
1285
+ /** Custom `--graph` artifact path. */
1286
+ graphPath?: string;
1287
+ /** Explicit opt-out from the caller's parsed flags (`--no-daemon`). */
1288
+ disabled?: boolean;
1289
+ /** Injected (tests). */
1290
+ isRunning?: typeof vgdIsRunning;
1291
+ request?: typeof vgdRequest;
1292
+ ensure?: (socketPath: string, readyBudgetMs: number) => Promise<{
1293
+ running: boolean;
1294
+ started: boolean;
1295
+ }>;
1296
+ env?: NodeJS.ProcessEnv;
1297
+ }
1298
+ /**
1299
+ * Ensure a local vgd is running and knows about this repository's map.
1300
+ * Resolves to a description of what happened; never throws.
1301
+ */
1302
+ declare function attachVgd(root: string, options?: AttachOptions): Promise<AttachResult>;
1303
+
1304
+ /**
1305
+ * One way to ask the daemon for a semantic ranking, shared by every surface.
1306
+ *
1307
+ * `vg ask`, `vg serve` and `vg lsp` each grew their own copy of "load the
1308
+ * embedder, embed the corpus, rank" — and `engine/refresh-scheduler.ts` records
1309
+ * what that costs: the per-server copies diverged, and one of them blocked an
1310
+ * editor Ask for ninety seconds. This is the single implementation of the
1311
+ * daemon path so that cannot happen again.
1312
+ *
1313
+ * Long-lived callers (the MCP server, the language server) hold one of these
1314
+ * for the process: it attaches once, remembers the slot, and per request sends
1315
+ * only the question. Short-lived callers get the same behaviour with the attach
1316
+ * folded into the first call.
1317
+ *
1318
+ * Every failure resolves to `null`, never a throw. `null` means "rank it
1319
+ * yourself" — the in-process path each caller already has, which is also what
1320
+ * happens when no daemon is running at all.
1321
+ */
1322
+ interface DaemonRanking {
1323
+ ranked: Array<{
1324
+ id: string;
1325
+ score: number;
1326
+ }>;
1327
+ /** How many vectors the slot holds — for logging, not correctness. */
1328
+ vectors: number;
1329
+ model?: string;
1330
+ }
1331
+ interface SemanticSessionOptions extends Omit<AttachOptions, 'corpusHash'> {
1332
+ /** How long to wait before retrying after a failed attach (default 30s). */
1333
+ retryAfterMs?: number;
1334
+ now?: () => number;
1335
+ /** Injected (tests). */
1336
+ attach?: typeof attachVgd;
1337
+ request?: typeof vgdRequest;
1338
+ }
1339
+ declare class DaemonSemanticSession {
1340
+ private repositoryId;
1341
+ private gitRef;
1342
+ private socketPath;
1343
+ /** The map the daemon was last told about, so an unchanged one is not resent. */
1344
+ private publishedHash;
1345
+ /** Do not re-attach before this time — a down daemon must not cost every request. */
1346
+ private retryAfter;
1347
+ private attaching;
1348
+ private readonly root;
1349
+ private readonly options;
1350
+ private readonly retryAfterMs;
1351
+ private readonly now;
1352
+ private readonly attachImpl;
1353
+ private readonly requestImpl;
1354
+ constructor(root: string, options?: SemanticSessionOptions);
1355
+ /** True once a slot is known — useful for a one-line status log. */
1356
+ get attached(): boolean;
1357
+ /**
1358
+ * Rank `question` against the daemon's index for this repo.
1359
+ * `corpusHash` is the caller's current map: when it differs from what the
1360
+ * daemon holds, the map is republished before ranking, so a locally
1361
+ * refreshed map never ranks against yesterday's vectors.
1362
+ */
1363
+ rank(question: string, corpusHash?: string): Promise<DaemonRanking | null>;
1364
+ /**
1365
+ * The daemon's shared dependency context for this repo — the manifest digest
1366
+ * and the dependency records — computed once per daemon instead of once per
1367
+ * process. Null whenever the daemon cannot answer, so the caller falls back
1368
+ * to computing it locally.
1369
+ */
1370
+ depContext(): Promise<{
1371
+ manifestHash: string;
1372
+ dependencies: Array<{
1373
+ name: string;
1374
+ ecosystem: string;
1375
+ declared: string;
1376
+ installed?: string;
1377
+ }>;
1378
+ } | null>;
1379
+ private reset;
1380
+ /** Attach once; concurrent callers share the one attempt. */
1381
+ private ensureAttached;
1382
+ }
1383
+
805
1384
  /**
806
1385
  * The read-only tool set for the LOCAL `vg serve` MCP. Every tool is
807
1386
  * side-effect-free and `readOnlyHint: true` (auto-approvable), and independent of
@@ -824,6 +1403,12 @@ interface ToolContext {
824
1403
  seen?: Set<string>;
825
1404
  /** Path the served graph was loaded from (locates its tags sidecar). */
826
1405
  graphPath?: string;
1406
+ /**
1407
+ * The local runtime's semantic index, when one is reachable. Held for the
1408
+ * life of the server: attaching once and sending only the question per call
1409
+ * is what removes this process's own model load and vector scan.
1410
+ */
1411
+ semanticSession?: DaemonSemanticSession;
827
1412
  }
828
1413
  interface VgTool {
829
1414
  name: string;
@@ -1121,6 +1706,8 @@ interface ServeOptions {
1121
1706
  dedup?: boolean;
1122
1707
  /** Auto-refresh the map when the working tree drifts (default true). */
1123
1708
  refresh?: boolean;
1709
+ /** `--no-daemon`: never auto-start or use the local runtime. */
1710
+ daemon?: boolean;
1124
1711
  /**
1125
1712
  * Event-driven refresh: recursive fs.watch on the workspace so a save
1126
1713
  * rebuilds in ~400 ms instead of waiting out the freshness poll (default
@@ -1152,6 +1739,12 @@ declare class GraphSource {
1152
1739
  /** Timing / root overrides (production passes `root`; tests may pass more). */
1153
1740
  private readonly tuning;
1154
1741
  private cachedMtimeMs;
1742
+ /**
1743
+ * True while the daemon owns freshness for this workspace. Set only after
1744
+ * the daemon confirms a subscription, cleared the instant it drops — so the
1745
+ * failure mode is "this process watches again", never "nobody watches".
1746
+ */
1747
+ private daemonOwnsFreshness;
1155
1748
  private cached;
1156
1749
  /** Project root used for freshness probes and rebuilds. */
1157
1750
  readonly root: string;
@@ -1170,6 +1763,15 @@ declare class GraphSource {
1170
1763
  constructor(graphPath: string, refresh?: boolean,
1171
1764
  /** Timing / root overrides (production passes `root`; tests may pass more). */
1172
1765
  tuning?: GraphSourceTuning);
1766
+ /**
1767
+ * Hand freshness to the daemon: stop probing on every call and stop watching.
1768
+ * The daemon pushes `slot-changed` and we reload from disk then.
1769
+ */
1770
+ deferFreshnessToDaemon(): void;
1771
+ /** The daemon went away — resume owning freshness locally. */
1772
+ resumeLocalFreshness(): void;
1773
+ /** The daemon says the map moved; drop the cache so the next get() re-reads. */
1774
+ reloadFromDisk(): void;
1173
1775
  /** Current graph: auto-refreshed if the tree drifted, reloaded if the file changed. */
1174
1776
  get(): Promise<VgGraph>;
1175
1777
  /**
@@ -1411,7 +2013,7 @@ interface DriftNote {
1411
2013
  installed?: string;
1412
2014
  drift: 'current' | 'behind' | 'ahead' | 'unknown';
1413
2015
  }
1414
- declare function driftFor(root: string, entry: LibEntry): DriftNote;
2016
+ declare function driftFor(root: string, entry: LibEntry, inv?: DriftInventory): DriftNote;
1415
2017
  interface AddOptions {
1416
2018
  root: string;
1417
2019
  name?: string;