@zvec/zvec-grep 0.1.5 → 0.1.7

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 (358) hide show
  1. package/README.md +154 -236
  2. package/README_CN.md +142 -233
  3. package/dist/authorization/index.d.ts +7 -0
  4. package/dist/authorization/index.js +7 -0
  5. package/dist/authorization/index.js.map +1 -0
  6. package/dist/authorization/manager.d.ts +8 -0
  7. package/dist/authorization/manager.js +19 -0
  8. package/dist/authorization/manager.js.map +1 -0
  9. package/dist/authorization/operation.d.ts +7 -0
  10. package/dist/authorization/operation.js +50 -0
  11. package/dist/authorization/operation.js.map +1 -0
  12. package/dist/authorization/planner.d.ts +21 -0
  13. package/dist/authorization/planner.js +97 -0
  14. package/dist/authorization/planner.js.map +1 -0
  15. package/dist/authorization/prompt.d.ts +11 -0
  16. package/dist/authorization/prompt.js +62 -0
  17. package/dist/authorization/prompt.js.map +1 -0
  18. package/dist/authorization/store.d.ts +20 -0
  19. package/dist/authorization/store.js +251 -0
  20. package/dist/authorization/store.js.map +1 -0
  21. package/dist/authorization/target.d.ts +15 -0
  22. package/dist/authorization/target.js +49 -0
  23. package/dist/authorization/target.js.map +1 -0
  24. package/dist/authorization/types.d.ts +61 -0
  25. package/dist/authorization/types.js +2 -0
  26. package/dist/authorization/types.js.map +1 -0
  27. package/dist/cli/args.d.ts +1 -1
  28. package/dist/cli/args.js +338 -55
  29. package/dist/cli/args.js.map +1 -1
  30. package/dist/cli/auth.d.ts +21 -0
  31. package/dist/cli/auth.js +209 -0
  32. package/dist/cli/auth.js.map +1 -0
  33. package/dist/cli/commands.js +469 -625
  34. package/dist/cli/commands.js.map +1 -1
  35. package/dist/cli/errors.js +2 -2
  36. package/dist/cli/errors.js.map +1 -1
  37. package/dist/cli/format/context.d.ts +4 -0
  38. package/dist/cli/format/context.js +311 -44
  39. package/dist/cli/format/context.js.map +1 -1
  40. package/dist/cli/format/debug.js +12 -6
  41. package/dist/cli/format/debug.js.map +1 -1
  42. package/dist/cli/format/progress.d.ts +4 -0
  43. package/dist/cli/format/progress.js +219 -46
  44. package/dist/cli/format/progress.js.map +1 -1
  45. package/dist/cli/format/status.d.ts +79 -6
  46. package/dist/cli/format/status.js +341 -111
  47. package/dist/cli/format/status.js.map +1 -1
  48. package/dist/cli/help.js +395 -63
  49. package/dist/cli/help.js.map +1 -1
  50. package/dist/cli/index.d.ts +1 -1
  51. package/dist/cli/index.js +1 -1
  52. package/dist/cli/install.d.ts +4 -0
  53. package/dist/cli/install.js +963 -0
  54. package/dist/cli/install.js.map +1 -0
  55. package/dist/cli/managed-rg.d.ts +10 -0
  56. package/dist/cli/managed-rg.js +329 -0
  57. package/dist/cli/managed-rg.js.map +1 -0
  58. package/dist/cli/server-search.d.ts +3 -0
  59. package/dist/cli/server-search.js +12 -0
  60. package/dist/cli/server-search.js.map +1 -0
  61. package/dist/cli/types.d.ts +23 -6
  62. package/dist/cli/types.js.map +1 -1
  63. package/dist/client/daemon-client.d.ts +31 -0
  64. package/dist/client/daemon-client.js +203 -0
  65. package/dist/client/daemon-client.js.map +1 -0
  66. package/dist/client/mode-router.d.ts +9 -0
  67. package/dist/client/mode-router.js +28 -0
  68. package/dist/client/mode-router.js.map +1 -0
  69. package/dist/client/search-policy.d.ts +11 -0
  70. package/dist/client/search-policy.js +15 -0
  71. package/dist/client/search-policy.js.map +1 -0
  72. package/dist/daemon/backend.d.ts +77 -0
  73. package/dist/daemon/backend.js +1087 -0
  74. package/dist/daemon/backend.js.map +1 -0
  75. package/dist/daemon/change-set.d.ts +25 -0
  76. package/dist/daemon/change-set.js +101 -0
  77. package/dist/daemon/change-set.js.map +1 -0
  78. package/dist/daemon/config.d.ts +24 -0
  79. package/dist/daemon/config.js +88 -0
  80. package/dist/daemon/config.js.map +1 -0
  81. package/dist/daemon/errors.d.ts +5 -0
  82. package/dist/daemon/errors.js +11 -0
  83. package/dist/daemon/errors.js.map +1 -0
  84. package/dist/daemon/http-server.d.ts +30 -0
  85. package/dist/daemon/http-server.js +288 -0
  86. package/dist/daemon/http-server.js.map +1 -0
  87. package/dist/daemon/index-coordinator.d.ts +24 -0
  88. package/dist/daemon/index-coordinator.js +68 -0
  89. package/dist/daemon/index-coordinator.js.map +1 -0
  90. package/dist/daemon/job-scheduler.d.ts +70 -0
  91. package/dist/daemon/job-scheduler.js +366 -0
  92. package/dist/daemon/job-scheduler.js.map +1 -0
  93. package/dist/daemon/logger.d.ts +9 -0
  94. package/dist/daemon/logger.js +53 -0
  95. package/dist/daemon/logger.js.map +1 -0
  96. package/dist/daemon/model-pool.d.ts +45 -0
  97. package/dist/daemon/model-pool.js +187 -0
  98. package/dist/daemon/model-pool.js.map +1 -0
  99. package/dist/daemon/root-lease.d.ts +14 -0
  100. package/dist/daemon/root-lease.js +188 -0
  101. package/dist/daemon/root-lease.js.map +1 -0
  102. package/dist/daemon/root-runtime.d.ts +78 -0
  103. package/dist/daemon/root-runtime.js +333 -0
  104. package/dist/daemon/root-runtime.js.map +1 -0
  105. package/dist/daemon/runtime-manager.d.ts +46 -0
  106. package/dist/daemon/runtime-manager.js +246 -0
  107. package/dist/daemon/runtime-manager.js.map +1 -0
  108. package/dist/daemon/runtime.d.ts +12 -0
  109. package/dist/daemon/runtime.js +102 -0
  110. package/dist/daemon/runtime.js.map +1 -0
  111. package/dist/daemon/server-controller.d.ts +39 -0
  112. package/dist/daemon/server-controller.js +254 -0
  113. package/dist/daemon/server-controller.js.map +1 -0
  114. package/dist/daemon/watch-manager.d.ts +50 -0
  115. package/dist/daemon/watch-manager.js +293 -0
  116. package/dist/daemon/watch-manager.js.map +1 -0
  117. package/dist/daemon/workspace-read-session-cache.d.ts +31 -0
  118. package/dist/daemon/workspace-read-session-cache.js +115 -0
  119. package/dist/daemon/workspace-read-session-cache.js.map +1 -0
  120. package/dist/engine/code-formats.d.ts +3 -0
  121. package/dist/engine/code-formats.js +14 -0
  122. package/dist/engine/code-formats.js.map +1 -0
  123. package/dist/engine/config.d.ts +30 -8
  124. package/dist/engine/config.js +171 -45
  125. package/dist/engine/config.js.map +1 -1
  126. package/dist/engine/{errors/index.d.ts → errors.d.ts} +6 -1
  127. package/dist/engine/{errors/details.js → errors.js} +17 -4
  128. package/dist/engine/errors.js.map +1 -0
  129. package/dist/engine/extraction/code/adapter.d.ts +1 -1
  130. package/dist/engine/extraction/code/adapter.js +1 -1
  131. package/dist/engine/extraction/code/adapter.js.map +1 -1
  132. package/dist/engine/extraction/code/extractor.d.ts +5 -11
  133. package/dist/engine/extraction/code/extractor.js +116 -48
  134. package/dist/engine/extraction/code/extractor.js.map +1 -1
  135. package/dist/engine/extraction/code/families/c-family.js +1 -1
  136. package/dist/engine/extraction/code/families/c-family.js.map +1 -1
  137. package/dist/engine/extraction/code/families/js-ts.d.ts +1 -1
  138. package/dist/engine/extraction/code/families/metadata.d.ts +1 -1
  139. package/dist/engine/extraction/code/tree-sitter/grammar.js.map +1 -0
  140. package/dist/engine/extraction/code/tree-sitter/nodes.js.map +1 -0
  141. package/dist/engine/extraction/code/tree-sitter/parser.js.map +1 -0
  142. package/dist/engine/extraction/image/extractor.d.ts +5 -0
  143. package/dist/engine/extraction/image/extractor.js +35 -0
  144. package/dist/engine/extraction/image/extractor.js.map +1 -0
  145. package/dist/engine/extraction/index.d.ts +4 -44
  146. package/dist/engine/extraction/index.js +2 -280
  147. package/dist/engine/extraction/index.js.map +1 -1
  148. package/dist/engine/extraction/markdown/extractor.d.ts +5 -11
  149. package/dist/engine/extraction/markdown/extractor.js +38 -17
  150. package/dist/engine/extraction/markdown/extractor.js.map +1 -1
  151. package/dist/engine/extraction/runtime.d.ts +4 -0
  152. package/dist/engine/extraction/runtime.js +26 -0
  153. package/dist/engine/extraction/runtime.js.map +1 -0
  154. package/dist/engine/extraction/source.d.ts +18 -0
  155. package/dist/engine/extraction/source.js +22 -0
  156. package/dist/engine/extraction/source.js.map +1 -0
  157. package/dist/engine/extraction/text/extractor.d.ts +7 -0
  158. package/dist/engine/extraction/text/extractor.js +168 -0
  159. package/dist/engine/extraction/text/extractor.js.map +1 -0
  160. package/dist/engine/extraction/types.d.ts +4 -0
  161. package/dist/engine/{models → extraction}/types.js.map +1 -1
  162. package/dist/engine/extraction/vector-content.d.ts +5 -0
  163. package/dist/engine/extraction/vector-content.js +95 -0
  164. package/dist/engine/extraction/vector-content.js.map +1 -0
  165. package/dist/engine/file-size-policy.d.ts +6 -0
  166. package/dist/engine/file-size-policy.js +20 -0
  167. package/dist/engine/file-size-policy.js.map +1 -0
  168. package/dist/engine/file-type.d.ts +15 -0
  169. package/dist/engine/file-type.js +152 -0
  170. package/dist/engine/file-type.js.map +1 -0
  171. package/dist/engine/index-status.d.ts +9 -0
  172. package/dist/engine/index-status.js +38 -0
  173. package/dist/engine/index-status.js.map +1 -0
  174. package/dist/engine/manifest.d.ts +13 -0
  175. package/dist/engine/manifest.js +124 -0
  176. package/dist/engine/manifest.js.map +1 -0
  177. package/dist/engine/models/{providers/llama-cpp/embedding.d.ts → backends/llama-cpp.d.ts} +25 -20
  178. package/dist/engine/models/{providers/llama-cpp/embedding.js → backends/llama-cpp.js} +127 -106
  179. package/dist/engine/models/backends/llama-cpp.js.map +1 -0
  180. package/dist/engine/models/backends/model2vec-runtime.d.ts +63 -0
  181. package/dist/engine/models/backends/model2vec-runtime.js +112 -0
  182. package/dist/engine/models/backends/model2vec-runtime.js.map +1 -0
  183. package/dist/engine/models/backends/model2vec-tokenizer.d.ts +2 -0
  184. package/dist/engine/models/backends/model2vec-tokenizer.js +42 -0
  185. package/dist/engine/models/backends/model2vec-tokenizer.js.map +1 -0
  186. package/dist/engine/models/backends/model2vec-worker-pool.d.ts +25 -0
  187. package/dist/engine/models/backends/model2vec-worker-pool.js +264 -0
  188. package/dist/engine/models/backends/model2vec-worker-pool.js.map +1 -0
  189. package/dist/engine/models/backends/model2vec-worker.d.ts +1 -0
  190. package/dist/engine/models/backends/model2vec-worker.js +41 -0
  191. package/dist/engine/models/backends/model2vec-worker.js.map +1 -0
  192. package/dist/engine/models/backends/model2vec.d.ts +40 -0
  193. package/dist/engine/models/backends/model2vec.js +311 -0
  194. package/dist/engine/models/backends/model2vec.js.map +1 -0
  195. package/dist/engine/models/backends/qwen.d.ts +44 -0
  196. package/dist/engine/models/{providers/qwen/embedding.js → backends/qwen.js} +155 -94
  197. package/dist/engine/models/backends/qwen.js.map +1 -0
  198. package/dist/engine/models/backends/transformers-js.d.ts +87 -0
  199. package/dist/engine/models/backends/transformers-js.js +316 -0
  200. package/dist/engine/models/backends/transformers-js.js.map +1 -0
  201. package/dist/engine/models/catalog.d.ts +207 -23
  202. package/dist/engine/models/catalog.js +191 -25
  203. package/dist/engine/models/catalog.js.map +1 -1
  204. package/dist/engine/models/download-progress.d.ts +15 -0
  205. package/dist/engine/models/download-progress.js +48 -0
  206. package/dist/engine/models/download-progress.js.map +1 -0
  207. package/dist/engine/models/embeddings.d.ts +59 -18
  208. package/dist/engine/models/embeddings.js +52 -28
  209. package/dist/engine/models/embeddings.js.map +1 -1
  210. package/dist/engine/models/factory.d.ts +2 -5
  211. package/dist/engine/models/factory.js +41 -56
  212. package/dist/engine/models/factory.js.map +1 -1
  213. package/dist/engine/models/index.d.ts +4 -6
  214. package/dist/engine/models/index.js +4 -4
  215. package/dist/engine/models/index.js.map +1 -1
  216. package/dist/engine/models/ranking.d.ts +7 -3
  217. package/dist/engine/models/resolution.d.ts +8 -0
  218. package/dist/engine/models/resolution.js +22 -0
  219. package/dist/engine/models/resolution.js.map +1 -0
  220. package/dist/engine/pipeline/indexing/index.d.ts +9 -7
  221. package/dist/engine/pipeline/indexing/index.js +409 -165
  222. package/dist/engine/pipeline/indexing/index.js.map +1 -1
  223. package/dist/engine/pipeline/indexing/input-budget.d.ts +2 -0
  224. package/dist/engine/pipeline/indexing/input-budget.js +51 -0
  225. package/dist/engine/pipeline/indexing/input-budget.js.map +1 -0
  226. package/dist/engine/pipeline/indexing/root-paths.js +6 -6
  227. package/dist/engine/pipeline/indexing/root-paths.js.map +1 -1
  228. package/dist/engine/pipeline/indexing/scanner/index.d.ts +9 -2
  229. package/dist/engine/pipeline/indexing/scanner/index.js +291 -35
  230. package/dist/engine/pipeline/indexing/scanner/index.js.map +1 -1
  231. package/dist/engine/pipeline/search/index.d.ts +6 -6
  232. package/dist/engine/pipeline/search/index.js +8 -10
  233. package/dist/engine/pipeline/search/index.js.map +1 -1
  234. package/dist/engine/service/index.d.ts +3 -2
  235. package/dist/engine/service/index.js +1 -1
  236. package/dist/engine/service/index.js.map +1 -1
  237. package/dist/engine/service/root.d.ts +10 -12
  238. package/dist/engine/service/root.js +29 -25
  239. package/dist/engine/service/root.js.map +1 -1
  240. package/dist/engine/service/structure-enrichment.d.ts +1 -1
  241. package/dist/engine/service/structure-enrichment.js +20 -22
  242. package/dist/engine/service/structure-enrichment.js.map +1 -1
  243. package/dist/engine/service/types.d.ts +40 -38
  244. package/dist/engine/service/workspace-index.d.ts +26 -0
  245. package/dist/engine/service/workspace-index.js +157 -0
  246. package/dist/engine/service/workspace-index.js.map +1 -0
  247. package/dist/engine/service/zvec-grep.d.ts +12 -1
  248. package/dist/engine/service/zvec-grep.js +698 -489
  249. package/dist/engine/service/zvec-grep.js.map +1 -1
  250. package/dist/engine/storage/index.d.ts +30 -20
  251. package/dist/engine/storage/index.js +2 -1
  252. package/dist/engine/storage/index.js.map +1 -1
  253. package/dist/engine/storage/layout.d.ts +10 -0
  254. package/dist/engine/storage/layout.js +29 -0
  255. package/dist/engine/storage/layout.js.map +1 -0
  256. package/dist/engine/storage/zvec.d.ts +4 -67
  257. package/dist/engine/storage/zvec.js +115 -85
  258. package/dist/engine/storage/zvec.js.map +1 -1
  259. package/dist/engine/types.d.ts +29 -23
  260. package/dist/engine/types.js +1 -1
  261. package/dist/engine/types.js.map +1 -1
  262. package/dist/engine/utils/daemon-lease.d.ts +17 -0
  263. package/dist/engine/utils/daemon-lease.js +175 -0
  264. package/dist/engine/utils/daemon-lease.js.map +1 -0
  265. package/dist/engine/utils/file-selection.js +38 -1
  266. package/dist/engine/utils/file-selection.js.map +1 -1
  267. package/dist/engine/utils/lock.js +1 -1
  268. package/dist/engine/utils/lock.js.map +1 -1
  269. package/dist/index-progress.d.ts +10 -0
  270. package/dist/index-progress.js +159 -0
  271. package/dist/index-progress.js.map +1 -0
  272. package/dist/index.d.ts +4 -4
  273. package/dist/index.js +1 -1
  274. package/dist/index.js.map +1 -1
  275. package/dist/mcp/http-transport.d.ts +27 -0
  276. package/dist/mcp/http-transport.js +182 -0
  277. package/dist/mcp/http-transport.js.map +1 -0
  278. package/dist/mcp/input-normalization.d.ts +38 -0
  279. package/dist/mcp/input-normalization.js +104 -0
  280. package/dist/mcp/input-normalization.js.map +1 -0
  281. package/dist/mcp/progress-heartbeat.d.ts +17 -0
  282. package/dist/mcp/progress-heartbeat.js +46 -0
  283. package/dist/mcp/progress-heartbeat.js.map +1 -0
  284. package/dist/mcp/request-metadata.d.ts +2 -0
  285. package/dist/mcp/request-metadata.js +11 -0
  286. package/dist/mcp/request-metadata.js.map +1 -0
  287. package/dist/mcp/request-state.d.ts +40 -0
  288. package/dist/mcp/request-state.js +210 -0
  289. package/dist/mcp/request-state.js.map +1 -0
  290. package/dist/mcp/result-format.d.ts +13 -0
  291. package/dist/mcp/result-format.js +75 -0
  292. package/dist/mcp/result-format.js.map +1 -0
  293. package/dist/mcp/schemas.d.ts +672 -0
  294. package/dist/mcp/schemas.js +506 -0
  295. package/dist/mcp/schemas.js.map +1 -0
  296. package/dist/mcp/stdio-bridge.d.ts +9 -0
  297. package/dist/mcp/stdio-bridge.js +131 -0
  298. package/dist/mcp/stdio-bridge.js.map +1 -0
  299. package/dist/mcp/tools.d.ts +153 -0
  300. package/dist/mcp/tools.js +482 -0
  301. package/dist/mcp/tools.js.map +1 -0
  302. package/dist/mcp/toolset.d.ts +5 -0
  303. package/dist/mcp/toolset.js +12 -0
  304. package/dist/mcp/toolset.js.map +1 -0
  305. package/dist/observability/trace-context.d.ts +11 -0
  306. package/dist/observability/trace-context.js +138 -0
  307. package/dist/observability/trace-context.js.map +1 -0
  308. package/dist/prompts/zvec-grep-guidance.d.ts +2 -0
  309. package/dist/prompts/zvec-grep-guidance.js +9 -0
  310. package/dist/prompts/zvec-grep-guidance.js.map +1 -0
  311. package/docs/01-agents.md +132 -0
  312. package/docs/02-cli.md +239 -0
  313. package/docs/03-mcp.md +185 -0
  314. package/docs/04-pipeline.md +226 -0
  315. package/docs/05-architecture.md +86 -0
  316. package/docs/06-server.md +215 -0
  317. package/docs/07-embedding.md +182 -0
  318. package/docs/08-roadmap.md +85 -0
  319. package/docs/README.md +53 -0
  320. package/package.json +20 -11
  321. package/dist/cli/mcp.d.ts +0 -2
  322. package/dist/cli/mcp.js +0 -354
  323. package/dist/cli/mcp.js.map +0 -1
  324. package/dist/engine/collection/index.d.ts +0 -55
  325. package/dist/engine/collection/index.js +0 -710
  326. package/dist/engine/collection/index.js.map +0 -1
  327. package/dist/engine/errors/details.d.ts +0 -6
  328. package/dist/engine/errors/details.js.map +0 -1
  329. package/dist/engine/errors/index.js +0 -16
  330. package/dist/engine/errors/index.js.map +0 -1
  331. package/dist/engine/extraction/tree-sitter/grammar.js.map +0 -1
  332. package/dist/engine/extraction/tree-sitter/nodes.js.map +0 -1
  333. package/dist/engine/extraction/tree-sitter/parser.js.map +0 -1
  334. package/dist/engine/files/file-type.d.ts +0 -5
  335. package/dist/engine/files/file-type.js +0 -119
  336. package/dist/engine/files/file-type.js.map +0 -1
  337. package/dist/engine/models/providers/index.d.ts +0 -2
  338. package/dist/engine/models/providers/index.js +0 -3
  339. package/dist/engine/models/providers/index.js.map +0 -1
  340. package/dist/engine/models/providers/llama-cpp/embedding.js.map +0 -1
  341. package/dist/engine/models/providers/llama-cpp/index.d.ts +0 -1
  342. package/dist/engine/models/providers/llama-cpp/index.js +0 -2
  343. package/dist/engine/models/providers/llama-cpp/index.js.map +0 -1
  344. package/dist/engine/models/providers/qwen/embedding.d.ts +0 -42
  345. package/dist/engine/models/providers/qwen/embedding.js.map +0 -1
  346. package/dist/engine/models/providers/qwen/index.d.ts +0 -1
  347. package/dist/engine/models/providers/qwen/index.js +0 -2
  348. package/dist/engine/models/providers/qwen/index.js.map +0 -1
  349. package/dist/engine/models/types.d.ts +0 -30
  350. package/skills/zvec-grep/SKILL.md +0 -151
  351. package/skills/zvec-grep/agents/openai.yaml +0 -4
  352. /package/dist/engine/extraction/{tree-sitter → code/tree-sitter}/grammar.d.ts +0 -0
  353. /package/dist/engine/extraction/{tree-sitter → code/tree-sitter}/grammar.js +0 -0
  354. /package/dist/engine/extraction/{tree-sitter → code/tree-sitter}/nodes.d.ts +0 -0
  355. /package/dist/engine/extraction/{tree-sitter → code/tree-sitter}/nodes.js +0 -0
  356. /package/dist/engine/extraction/{tree-sitter → code/tree-sitter}/parser.d.ts +0 -0
  357. /package/dist/engine/extraction/{tree-sitter → code/tree-sitter}/parser.js +0 -0
  358. /package/dist/engine/{models → extraction}/types.js +0 -0
@@ -1,710 +0,0 @@
1
- import { ZVecCollectionSchema, ZVecCreateAndOpen, ZVecDataType, ZVecIndexType, ZVecOpen, } from "@zvec/zvec";
2
- import { randomUUID } from "node:crypto";
3
- import { existsSync, mkdirSync, rmSync } from "node:fs";
4
- import { basename, dirname, join } from "node:path";
5
- import { collectionDetail, detail, EngineError, errorDetails, } from "../errors/index.js";
6
- import { getCollectionIndexStatus, indexCollection, } from "../pipeline/indexing/index.js";
7
- import { fileBelongsToRootPath, validateRootPaths, } from "../pipeline/indexing/root-paths.js";
8
- import { diagnoseEntitySearch, diagnoseFileSearch, searchPlanCollection, } from "../pipeline/search/index.js";
9
- import { assertZvecStatus, initializeZvec, openZvecCollection, quoteFilterString, readNullableNumberFieldFromFields, readNullableStringFieldFromFields, readNumberFieldFromFields, readStringFieldFromFields, ZvecCollectionStorage, ZvecFileMetaStore, } from "../storage/zvec.js";
10
- import { CURRENT_INDEX_VERSION } from "../types.js";
11
- import { defaultHome, normalizePath } from "../utils/path.js";
12
- const COLLECTIONS_ZVEC = "collections.zvec";
13
- const FILES_ZVEC = "files.zvec";
14
- export class Collection {
15
- info;
16
- embeddingModel;
17
- readOnly;
18
- fileStorePath;
19
- storage;
20
- embedding;
21
- constructor(info, embeddingModel, readOnly = false, fileStorePath = join(info.path, FILES_ZVEC)) {
22
- this.info = info;
23
- this.embeddingModel = embeddingModel;
24
- this.readOnly = readOnly;
25
- this.fileStorePath = fileStorePath;
26
- this.embedding = requireIndexedEmbedding(info, "open");
27
- this.validateIndexVersion();
28
- if (this.embeddingModel) {
29
- this.validateEmbeddingSchema(this.embeddingModel);
30
- }
31
- this.storage = new ZvecCollectionStorage(info.path, this.embedding, this.fileStorePath, info.id, readOnly);
32
- }
33
- get id() {
34
- return this.info.id;
35
- }
36
- get name() {
37
- return this.info.name;
38
- }
39
- index(options = {}) {
40
- if (this.readOnly) {
41
- throw new EngineError("Cannot index a read-only collection", {
42
- code: "ZVEC_GREP.ENGINE.COLLECTION.READ_ONLY",
43
- context: collectionOperationDetails(this.name, "index"),
44
- });
45
- }
46
- const embeddingModel = this.requireEmbeddingModel("index");
47
- return indexCollection({
48
- collection: this.info,
49
- embeddingModel,
50
- storage: this.storage,
51
- embeddingConcurrency: options.embeddingConcurrency,
52
- onProgress: options.onProgress,
53
- });
54
- }
55
- status() {
56
- return getCollectionIndexStatus(this.info, this.storage.listFiles());
57
- }
58
- searchPlan(plan) {
59
- return searchPlanCollection(plan, {
60
- collection: this.info,
61
- embeddingModel: this.embeddingModel,
62
- storage: this.storage,
63
- });
64
- }
65
- diagnoseFile(absolutePath) {
66
- const path = normalizePath(absolutePath);
67
- const file = this.storage.getFileByPath(path);
68
- const matchedRootPath = this.info.rootPaths.find((rootPath) => fileBelongsToRootPath(path, rootPath));
69
- return {
70
- collectionId: this.id,
71
- collectionName: this.name,
72
- absolutePath: path,
73
- belongsToCollection: matchedRootPath !== undefined,
74
- matchedRootPath: matchedRootPath?.absolutePath,
75
- file: file ?? undefined,
76
- entityCount: file?.indexStatus?.entityCount ?? 0,
77
- reason: file
78
- ? undefined
79
- : matchedRootPath
80
- ? "File is under a collection root but has not been indexed; file-selection, ignore, discovery, size, or file-type rules may exclude it"
81
- : "File is outside the collection roots or excluded by root include/exclude patterns",
82
- };
83
- }
84
- diagnoseEntitySearch(query, entityId) {
85
- const embeddingModel = this.requireEmbeddingModel("diagnose");
86
- return diagnoseEntitySearch(query, entityId, {
87
- collection: this.info,
88
- embeddingModel,
89
- storage: this.storage,
90
- });
91
- }
92
- diagnoseFileSearch(query, absolutePath) {
93
- const embeddingModel = this.requireEmbeddingModel("diagnose");
94
- return diagnoseFileSearch(query, absolutePath, {
95
- collection: this.info,
96
- embeddingModel,
97
- storage: this.storage,
98
- });
99
- }
100
- getFile(absolutePath) {
101
- return this.storage.getFileByPath(absolutePath);
102
- }
103
- listEntitiesByFile(fileId, options = {}) {
104
- return this.storage.listEntitiesByFile(fileId, options);
105
- }
106
- getEntity(entityId) {
107
- return this.storage.getEntity(entityId);
108
- }
109
- close() {
110
- this.storage.close();
111
- }
112
- validateIndexVersion() {
113
- if (this.info.indexVersion !== CURRENT_INDEX_VERSION) {
114
- throw new EngineError("Collection index version is not supported", {
115
- code: "ZVEC_GREP.ENGINE.COLLECTION.INDEX_VERSION_MISMATCH",
116
- context: errorDetails([
117
- collectionDetail(this.name),
118
- detail("expected", CURRENT_INDEX_VERSION),
119
- detail("actual", this.info.indexVersion),
120
- ]),
121
- });
122
- }
123
- }
124
- validateEmbeddingSchema(current) {
125
- this.validateIndexVersion();
126
- const expected = this.embedding;
127
- if (expected.provider !== current.ref.provider) {
128
- throw new EngineError("Collection embedding provider does not match current model", {
129
- code: "ZVEC_GREP.ENGINE.COLLECTION.EMBEDDING_PROVIDER_MISMATCH",
130
- context: collectionMismatchDetails(this.name, expected.provider, current.ref.provider),
131
- });
132
- }
133
- if (expected.model !== current.ref.model) {
134
- throw new EngineError("Collection embedding model does not match current model", {
135
- code: "ZVEC_GREP.ENGINE.COLLECTION.EMBEDDING_MODEL_MISMATCH",
136
- context: collectionMismatchDetails(this.name, expected.model, current.ref.model),
137
- });
138
- }
139
- if (expected.dimension !== current.dimension) {
140
- throw new EngineError("Collection embedding dimension does not match current model", {
141
- code: "ZVEC_GREP.ENGINE.COLLECTION.EMBEDDING_DIMENSION_MISMATCH",
142
- context: collectionMismatchDetails(this.name, expected.dimension, current.dimension),
143
- });
144
- }
145
- if (expected.metric !== current.metric) {
146
- throw new EngineError("Collection embedding metric does not match current model", {
147
- code: "ZVEC_GREP.ENGINE.COLLECTION.EMBEDDING_METRIC_MISMATCH",
148
- context: collectionMismatchDetails(this.name, expected.metric, current.metric),
149
- });
150
- }
151
- }
152
- requireEmbeddingModel(operation) {
153
- if (!this.embeddingModel) {
154
- throw new EngineError("Collection operation requires an embedding model", {
155
- code: "ZVEC_GREP.ENGINE.COLLECTION.EMBEDDING_MODEL_REQUIRED",
156
- context: collectionOperationDetails(this.name, operation),
157
- });
158
- }
159
- return this.embeddingModel;
160
- }
161
- }
162
- function collectionOperationDetails(name, operation) {
163
- return errorDetails([collectionDetail(name), detail("operation", operation)]);
164
- }
165
- function collectionMismatchDetails(name, expected, actual) {
166
- return errorDetails([
167
- collectionDetail(name),
168
- detail("expected", expected),
169
- detail("actual", actual),
170
- ]);
171
- }
172
- export function isCollectionIndexed(info) {
173
- return (info?.embedding !== null &&
174
- info?.embedding !== undefined &&
175
- info.indexVersion !== null &&
176
- info.indexVersion !== undefined);
177
- }
178
- function requireIndexedEmbedding(info, operation) {
179
- if (isCollectionIndexed(info)) {
180
- return info.embedding;
181
- }
182
- throw new EngineError("Collection index has not been built", {
183
- code: "ZVEC_GREP.ENGINE.COLLECTION.INDEX_MISSING",
184
- context: errorDetails([
185
- collectionDetail(info.name),
186
- detail("operation", operation),
187
- detail("hint", "Run zg index to build this index."),
188
- ]),
189
- });
190
- }
191
- export class CollectionRegistry {
192
- home;
193
- embeddingModel;
194
- readOnly;
195
- meta;
196
- collections = new Map();
197
- constructor(home = defaultHome(), embeddingModel, readOnly = false) {
198
- this.home = home;
199
- this.embeddingModel = embeddingModel;
200
- this.readOnly = readOnly;
201
- if (!readOnly) {
202
- mkdirSync(home, { recursive: true });
203
- }
204
- this.meta = new ZvecCollectionsMetaStore(collectionsMetaPath(home), readOnly);
205
- }
206
- list() {
207
- return this.meta.list();
208
- }
209
- get(name) {
210
- return this.meta.getByName(name);
211
- }
212
- has(name) {
213
- return this.get(name) !== null;
214
- }
215
- remove(name) {
216
- if (this.readOnly) {
217
- throw new EngineError("Cannot remove a collection from a read-only registry", {
218
- code: "ZVEC_GREP.ENGINE.COLLECTION.READ_ONLY",
219
- context: collectionOperationDetails(name, "remove"),
220
- });
221
- }
222
- const info = this.get(name);
223
- if (!info) {
224
- return false;
225
- }
226
- const cached = this.collections.get(name);
227
- if (cached) {
228
- cached.close();
229
- this.collections.delete(name);
230
- }
231
- this.meta.remove(info.id);
232
- const files = new ZvecFileMetaStore(filesMetaPath(this.home), false);
233
- try {
234
- files.deleteCollection(info.id);
235
- }
236
- finally {
237
- files.close();
238
- }
239
- rmSync(info.path, { recursive: true, force: true });
240
- return true;
241
- }
242
- rename(name, nextName) {
243
- if (this.readOnly) {
244
- throw new EngineError("Cannot rename a collection from a read-only registry", {
245
- code: "ZVEC_GREP.ENGINE.COLLECTION.READ_ONLY",
246
- context: collectionOperationDetails(name, "rename"),
247
- });
248
- }
249
- const normalizedNextName = nextName.trim();
250
- if (normalizedNextName.length === 0) {
251
- throw new EngineError("Collection rename requires a non-empty name", {
252
- code: "ZVEC_GREP.ENGINE.COLLECTION.EMPTY_NAME",
253
- context: collectionOperationDetails(name, "rename"),
254
- });
255
- }
256
- const info = this.get(name);
257
- if (!info) {
258
- return null;
259
- }
260
- if (this.has(normalizedNextName)) {
261
- throw new EngineError("Collection already exists", {
262
- code: "ZVEC_GREP.ENGINE.COLLECTION.ALREADY_EXISTS",
263
- context: errorDetails([collectionDetail(normalizedNextName)]),
264
- });
265
- }
266
- const cached = this.collections.get(name);
267
- if (cached) {
268
- cached.close();
269
- this.collections.delete(name);
270
- }
271
- const updated = {
272
- ...info,
273
- name: normalizedNextName,
274
- updatedTime: Date.now(),
275
- };
276
- this.meta.upsert(updated);
277
- return updated;
278
- }
279
- async status(name) {
280
- const info = this.get(name);
281
- if (!info ||
282
- !isCollectionIndexed(info) ||
283
- info.indexPolicy === "disabled") {
284
- return null;
285
- }
286
- return this.open(name).status();
287
- }
288
- create(name, rootPaths, path) {
289
- if (this.readOnly) {
290
- throw new EngineError("Cannot create a collection in a read-only registry", {
291
- code: "ZVEC_GREP.ENGINE.COLLECTION.READ_ONLY",
292
- context: collectionOperationDetails(name, "create"),
293
- });
294
- }
295
- if (!this.embeddingModel) {
296
- throw new EngineError("Creating a collection requires an embedding model", {
297
- code: "ZVEC_GREP.ENGINE.COLLECTION.EMBEDDING_MODEL_REQUIRED",
298
- context: collectionOperationDetails(name, "create"),
299
- });
300
- }
301
- if (this.has(name)) {
302
- throw new EngineError("Collection already exists", {
303
- code: "ZVEC_GREP.ENGINE.COLLECTION.ALREADY_EXISTS",
304
- context: errorDetails([collectionDetail(name)]),
305
- });
306
- }
307
- const id = randomUUID();
308
- const collectionPath = normalizePath(path ?? join(this.home, "collections", id));
309
- const now = Date.now();
310
- const normalizedRootPaths = validateRootPaths(rootPaths);
311
- const info = {
312
- id,
313
- name,
314
- path: collectionPath,
315
- rootPaths: normalizedRootPaths,
316
- indexPolicy: "enabled",
317
- embedding: currentEmbeddingSchema(this.embeddingModel),
318
- indexVersion: CURRENT_INDEX_VERSION,
319
- createdTime: now,
320
- updatedTime: now,
321
- };
322
- mkdirSync(collectionPath, { recursive: true });
323
- this.meta.upsert(info);
324
- return info;
325
- }
326
- prepareIndex(name, rootPaths, path) {
327
- if (this.readOnly) {
328
- throw new EngineError("Cannot prepare a collection in a read-only registry", {
329
- code: "ZVEC_GREP.ENGINE.COLLECTION.READ_ONLY",
330
- context: collectionOperationDetails(name, "prepareIndex"),
331
- });
332
- }
333
- if (!this.embeddingModel) {
334
- throw new EngineError("Preparing a collection requires an embedding model", {
335
- code: "ZVEC_GREP.ENGINE.COLLECTION.EMBEDDING_MODEL_REQUIRED",
336
- context: collectionOperationDetails(name, "prepareIndex"),
337
- });
338
- }
339
- const existing = this.get(name);
340
- if (!existing) {
341
- return this.create(name, rootPaths, path);
342
- }
343
- const normalizedRootPaths = validateRootPaths(rootPaths);
344
- const collectionPath = normalizePath(path ?? existing.path);
345
- const cached = this.collections.get(name);
346
- if (cached) {
347
- cached.close();
348
- this.collections.delete(name);
349
- }
350
- const updated = {
351
- ...existing,
352
- path: collectionPath,
353
- rootPaths: normalizedRootPaths,
354
- indexPolicy: "enabled",
355
- embedding: currentEmbeddingSchema(this.embeddingModel),
356
- indexVersion: CURRENT_INDEX_VERSION,
357
- updatedTime: Date.now(),
358
- };
359
- mkdirSync(collectionPath, { recursive: true });
360
- this.meta.upsert(updated);
361
- return updated;
362
- }
363
- disableIndex(name, rootPaths, path) {
364
- if (this.readOnly) {
365
- throw new EngineError("Cannot disable a collection index in a read-only registry", {
366
- code: "ZVEC_GREP.ENGINE.COLLECTION.READ_ONLY",
367
- context: collectionOperationDetails(name, "disableIndex"),
368
- });
369
- }
370
- const existing = this.get(name);
371
- const normalizedRootPaths = validateRootPaths(rootPaths);
372
- const now = Date.now();
373
- if (existing) {
374
- const cached = this.collections.get(name);
375
- if (cached) {
376
- cached.close();
377
- this.collections.delete(name);
378
- }
379
- const updated = {
380
- ...existing,
381
- rootPaths: normalizedRootPaths,
382
- path: normalizePath(path ?? existing.path),
383
- indexPolicy: "disabled",
384
- embedding: null,
385
- indexVersion: null,
386
- updatedTime: now,
387
- };
388
- this.meta.upsert(updated);
389
- return updated;
390
- }
391
- const collectionPath = normalizePath(path ?? join(this.home, "collections", randomUUID()));
392
- const info = {
393
- id: randomUUID(),
394
- name,
395
- path: collectionPath,
396
- rootPaths: normalizedRootPaths,
397
- indexPolicy: "disabled",
398
- embedding: null,
399
- indexVersion: null,
400
- createdTime: now,
401
- updatedTime: now,
402
- };
403
- this.meta.upsert(info);
404
- return info;
405
- }
406
- updateRootPaths(name, rootPaths) {
407
- if (this.readOnly) {
408
- throw new EngineError("Cannot update a collection from a read-only registry", {
409
- code: "ZVEC_GREP.ENGINE.COLLECTION.READ_ONLY",
410
- context: collectionOperationDetails(name, "updateRootPaths"),
411
- });
412
- }
413
- const info = this.get(name);
414
- if (!info) {
415
- return null;
416
- }
417
- const normalizedRootPaths = validateRootPaths(rootPaths);
418
- if (rootPathsEqual(info.rootPaths, normalizedRootPaths)) {
419
- return info;
420
- }
421
- const cached = this.collections.get(name);
422
- if (cached) {
423
- cached.close();
424
- this.collections.delete(name);
425
- }
426
- const updated = {
427
- ...info,
428
- rootPaths: normalizedRootPaths,
429
- updatedTime: Date.now(),
430
- };
431
- this.meta.upsert(updated);
432
- return updated;
433
- }
434
- open(name) {
435
- const cached = this.collections.get(name);
436
- if (cached) {
437
- return cached;
438
- }
439
- const info = this.get(name);
440
- if (!info) {
441
- throw new EngineError("Collection not found", {
442
- code: "ZVEC_GREP.ENGINE.COLLECTION.NOT_FOUND",
443
- context: errorDetails([collectionDetail(name)]),
444
- });
445
- }
446
- if (info.indexPolicy === "disabled") {
447
- throw new EngineError("Collection index is disabled", {
448
- code: "ZVEC_GREP.ENGINE.COLLECTION.INDEX_DISABLED",
449
- context: errorDetails([
450
- collectionDetail(name),
451
- detail("hint", "Run zg index to enable and build this index, or use zg query --rg for no-index search."),
452
- ]),
453
- });
454
- }
455
- if (!isCollectionIndexed(info)) {
456
- throw new EngineError("Collection index has not been built", {
457
- code: "ZVEC_GREP.ENGINE.COLLECTION.INDEX_MISSING",
458
- context: errorDetails([
459
- collectionDetail(name),
460
- detail("hint", "Run zg index to build this index."),
461
- ]),
462
- });
463
- }
464
- const collection = new Collection(info, this.embeddingModel, this.readOnly, filesMetaPath(this.home));
465
- this.collections.set(name, collection);
466
- return collection;
467
- }
468
- close() {
469
- for (const collection of this.collections.values()) {
470
- collection.close();
471
- }
472
- this.collections.clear();
473
- this.meta.close();
474
- }
475
- }
476
- class ZvecCollectionsMetaStore {
477
- path;
478
- readOnly;
479
- collection;
480
- needsOptimize = false;
481
- constructor(path, readOnly = false) {
482
- this.path = path;
483
- this.readOnly = readOnly;
484
- initializeZvec();
485
- if (!readOnly) {
486
- mkdirSync(homeDirectoryForMetaPath(path), { recursive: true });
487
- }
488
- if (existsSync(path)) {
489
- this.collection = openZvecCollection(path, readOnly, "open", () => ZVecOpen(path, { readOnly }));
490
- }
491
- else if (readOnly) {
492
- this.collection = null;
493
- }
494
- else {
495
- this.collection = openZvecCollection(path, readOnly, "create", () => ZVecCreateAndOpen(path, createCollectionsSchema()));
496
- }
497
- }
498
- list() {
499
- if (!this.collection) {
500
- return [];
501
- }
502
- const topk = Math.max(this.collection.stats.docCount, 1);
503
- return this.collection
504
- .querySync({ topk, includeVector: false })
505
- .map((doc) => docToCollectionInfo(doc))
506
- .sort((left, right) => left.name.localeCompare(right.name));
507
- }
508
- getByName(name) {
509
- if (!this.collection) {
510
- return null;
511
- }
512
- const [doc] = this.collection.querySync({
513
- filter: `name = ${quoteFilterString(name)}`,
514
- topk: 1,
515
- includeVector: false,
516
- });
517
- return doc ? docToCollectionInfo(doc) : null;
518
- }
519
- upsert(info) {
520
- this.assertWritable("upsert");
521
- const collection = this.requireCollection();
522
- const deleteStatus = collection.deleteSync(info.id);
523
- assertZvecStatusOrNotFound(deleteStatus, "collection metadata replace", info.name);
524
- const status = collection.upsertSync(collectionInfoToDoc(info));
525
- assertZvecStatus(status, "collection metadata upsert", info.name);
526
- this.needsOptimize = true;
527
- }
528
- remove(collectionId) {
529
- this.assertWritable("remove");
530
- const status = this.requireCollection().deleteByFilterSync(`collection_id = ${quoteFilterString(collectionId)}`);
531
- assertZvecStatus(status, "collection metadata delete", collectionId);
532
- this.needsOptimize = true;
533
- }
534
- close() {
535
- if (!this.collection) {
536
- return;
537
- }
538
- if (this.needsOptimize) {
539
- this.collection.optimizeSync();
540
- this.needsOptimize = false;
541
- }
542
- this.collection.closeSync();
543
- }
544
- requireCollection() {
545
- if (!this.collection) {
546
- throw new EngineError("zvec collection metadata storage is unavailable", {
547
- code: "ZVEC_GREP.ENGINE.COLLECTION.META_UNAVAILABLE",
548
- context: `path=${this.path}`,
549
- });
550
- }
551
- return this.collection;
552
- }
553
- assertWritable(operation) {
554
- if (this.readOnly) {
555
- throw new EngineError("Cannot update read-only collection metadata storage", {
556
- code: "ZVEC_GREP.ENGINE.COLLECTION.READ_ONLY",
557
- context: `path=${this.path} operation=${operation}`,
558
- });
559
- }
560
- }
561
- }
562
- function assertZvecStatusOrNotFound(status, operation, context) {
563
- if (status.ok || status.code === "ZVEC_NOT_FOUND") {
564
- return;
565
- }
566
- assertZvecStatus(status, operation, context);
567
- }
568
- function createCollectionsSchema() {
569
- return new ZVecCollectionSchema({
570
- name: "zvec_grep_collections",
571
- fields: [
572
- indexedStringField("collection_id"),
573
- indexedStringField("name"),
574
- indexedStringField("path"),
575
- stringField("root_paths_json"),
576
- indexedStringField("index_policy", true),
577
- indexedStringField("embedding_provider", true),
578
- indexedStringField("embedding_model", true),
579
- {
580
- name: "embedding_dimension",
581
- dataType: ZVecDataType.INT32,
582
- nullable: true,
583
- },
584
- indexedStringField("embedding_metric", true),
585
- {
586
- name: "index_version",
587
- dataType: ZVecDataType.INT32,
588
- nullable: true,
589
- },
590
- {
591
- name: "created_time",
592
- dataType: ZVecDataType.INT64,
593
- nullable: false,
594
- },
595
- {
596
- name: "updated_time",
597
- dataType: ZVecDataType.INT64,
598
- nullable: false,
599
- },
600
- ],
601
- });
602
- }
603
- function collectionInfoToDoc(info) {
604
- const fields = {
605
- collection_id: info.id,
606
- name: info.name,
607
- path: info.path,
608
- root_paths_json: JSON.stringify(info.rootPaths),
609
- created_time: info.createdTime,
610
- updated_time: info.updatedTime,
611
- };
612
- if (info.indexPolicy !== undefined) {
613
- fields.index_policy = info.indexPolicy;
614
- }
615
- if (info.embedding) {
616
- fields.embedding_provider = info.embedding.provider;
617
- fields.embedding_model = info.embedding.model;
618
- fields.embedding_dimension = info.embedding.dimension;
619
- fields.embedding_metric = info.embedding.metric;
620
- }
621
- if (info.indexVersion !== null && info.indexVersion !== undefined) {
622
- fields.index_version = info.indexVersion;
623
- }
624
- return {
625
- id: info.id,
626
- fields,
627
- };
628
- }
629
- function docToCollectionInfo(doc) {
630
- const fields = doc.fields;
631
- const embedding = collectionEmbeddingFromFields(fields);
632
- return {
633
- id: readStringFieldFromFields(fields, "collection_id"),
634
- name: readStringFieldFromFields(fields, "name"),
635
- path: normalizePath(readStringFieldFromFields(fields, "path")),
636
- rootPaths: parseRootPaths(readStringFieldFromFields(fields, "root_paths_json")),
637
- indexPolicy: collectionIndexPolicyFromFields(fields),
638
- embedding,
639
- indexVersion: readNullableNumberFieldFromFields(fields, "index_version"),
640
- createdTime: readNumberFieldFromFields(fields, "created_time"),
641
- updatedTime: readNumberFieldFromFields(fields, "updated_time"),
642
- };
643
- }
644
- function collectionEmbeddingFromFields(fields) {
645
- const provider = readNullableStringFieldFromFields(fields, "embedding_provider");
646
- const model = readNullableStringFieldFromFields(fields, "embedding_model");
647
- const dimension = readNullableNumberFieldFromFields(fields, "embedding_dimension");
648
- const metric = readNullableStringFieldFromFields(fields, "embedding_metric");
649
- if (!provider || !model || !dimension || !metric) {
650
- return null;
651
- }
652
- return {
653
- provider,
654
- model,
655
- dimension,
656
- metric,
657
- };
658
- }
659
- function collectionIndexPolicyFromFields(fields) {
660
- const policy = readNullableStringFieldFromFields(fields, "index_policy");
661
- return policy === "enabled" || policy === "disabled" ? policy : undefined;
662
- }
663
- function parseRootPaths(value) {
664
- try {
665
- const parsed = JSON.parse(value);
666
- return Array.isArray(parsed) ? validateRootPaths(parsed) : [];
667
- }
668
- catch {
669
- return [];
670
- }
671
- }
672
- function collectionsMetaPath(home) {
673
- return join(home, COLLECTIONS_ZVEC);
674
- }
675
- function filesMetaPath(home) {
676
- return join(home, FILES_ZVEC);
677
- }
678
- function homeDirectoryForMetaPath(path) {
679
- return dirname(path);
680
- }
681
- function indexedStringField(name, nullable = false) {
682
- return {
683
- name,
684
- dataType: ZVecDataType.STRING,
685
- nullable,
686
- indexParams: { indexType: ZVecIndexType.INVERT },
687
- };
688
- }
689
- function stringField(name, nullable = false) {
690
- return {
691
- name,
692
- dataType: ZVecDataType.STRING,
693
- nullable,
694
- };
695
- }
696
- export function defaultCollectionName(path) {
697
- return basename(normalizePath(path));
698
- }
699
- function currentEmbeddingSchema(model) {
700
- return {
701
- provider: model.ref.provider,
702
- model: model.ref.model,
703
- dimension: model.dimension,
704
- metric: model.metric,
705
- };
706
- }
707
- function rootPathsEqual(left, right) {
708
- return JSON.stringify(left) === JSON.stringify(right);
709
- }
710
- //# sourceMappingURL=index.js.map