@legioncodeinc/nectar 0.0.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 (467) hide show
  1. package/LICENSE.md +662 -0
  2. package/README.md +307 -0
  3. package/dist/api/daemon-api-wiring.d.ts +72 -0
  4. package/dist/api/daemon-api-wiring.d.ts.map +1 -0
  5. package/dist/api/daemon-api-wiring.js +150 -0
  6. package/dist/api/daemon-api-wiring.js.map +1 -0
  7. package/dist/api/hive-graph-api.d.ts +136 -0
  8. package/dist/api/hive-graph-api.d.ts.map +1 -0
  9. package/dist/api/hive-graph-api.js +234 -0
  10. package/dist/api/hive-graph-api.js.map +1 -0
  11. package/dist/api/loopback-client.d.ts +27 -0
  12. package/dist/api/loopback-client.d.ts.map +1 -0
  13. package/dist/api/loopback-client.js +87 -0
  14. package/dist/api/loopback-client.js.map +1 -0
  15. package/dist/api/router.d.ts +172 -0
  16. package/dist/api/router.d.ts.map +1 -0
  17. package/dist/api/router.js +212 -0
  18. package/dist/api/router.js.map +1 -0
  19. package/dist/api/status-query.d.ts +49 -0
  20. package/dist/api/status-query.d.ts.map +1 -0
  21. package/dist/api/status-query.js +103 -0
  22. package/dist/api/status-query.js.map +1 -0
  23. package/dist/brood-guard.d.ts +24 -0
  24. package/dist/brood-guard.d.ts.map +1 -0
  25. package/dist/brood-guard.js +19 -0
  26. package/dist/brood-guard.js.map +1 -0
  27. package/dist/brood-prereqs.d.ts +62 -0
  28. package/dist/brood-prereqs.d.ts.map +1 -0
  29. package/dist/brood-prereqs.js +87 -0
  30. package/dist/brood-prereqs.js.map +1 -0
  31. package/dist/brooding/bucketing.d.ts +68 -0
  32. package/dist/brooding/bucketing.d.ts.map +1 -0
  33. package/dist/brooding/bucketing.js +122 -0
  34. package/dist/brooding/bucketing.js.map +1 -0
  35. package/dist/brooding/cli.d.ts +78 -0
  36. package/dist/brooding/cli.d.ts.map +1 -0
  37. package/dist/brooding/cli.js +140 -0
  38. package/dist/brooding/cli.js.map +1 -0
  39. package/dist/brooding/constants.d.ts +75 -0
  40. package/dist/brooding/constants.d.ts.map +1 -0
  41. package/dist/brooding/constants.js +91 -0
  42. package/dist/brooding/constants.js.map +1 -0
  43. package/dist/brooding/cost.d.ts +110 -0
  44. package/dist/brooding/cost.d.ts.map +1 -0
  45. package/dist/brooding/cost.js +96 -0
  46. package/dist/brooding/cost.js.map +1 -0
  47. package/dist/brooding/describe.d.ts +152 -0
  48. package/dist/brooding/describe.d.ts.map +1 -0
  49. package/dist/brooding/describe.js +281 -0
  50. package/dist/brooding/describe.js.map +1 -0
  51. package/dist/brooding/discovery.d.ts +116 -0
  52. package/dist/brooding/discovery.d.ts.map +1 -0
  53. package/dist/brooding/discovery.js +179 -0
  54. package/dist/brooding/discovery.js.map +1 -0
  55. package/dist/brooding/index.d.ts +23 -0
  56. package/dist/brooding/index.d.ts.map +1 -0
  57. package/dist/brooding/index.js +33 -0
  58. package/dist/brooding/index.js.map +1 -0
  59. package/dist/brooding/pipeline-async.d.ts +97 -0
  60. package/dist/brooding/pipeline-async.d.ts.map +1 -0
  61. package/dist/brooding/pipeline-async.js +364 -0
  62. package/dist/brooding/pipeline-async.js.map +1 -0
  63. package/dist/brooding/pipeline.d.ts +198 -0
  64. package/dist/brooding/pipeline.d.ts.map +1 -0
  65. package/dist/brooding/pipeline.js +454 -0
  66. package/dist/brooding/pipeline.js.map +1 -0
  67. package/dist/brooding/precheck.d.ts +52 -0
  68. package/dist/brooding/precheck.d.ts.map +1 -0
  69. package/dist/brooding/precheck.js +143 -0
  70. package/dist/brooding/precheck.js.map +1 -0
  71. package/dist/brooding/resumability.d.ts +57 -0
  72. package/dist/brooding/resumability.d.ts.map +1 -0
  73. package/dist/brooding/resumability.js +46 -0
  74. package/dist/brooding/resumability.js.map +1 -0
  75. package/dist/cli.d.ts +139 -0
  76. package/dist/cli.d.ts.map +1 -0
  77. package/dist/cli.js +912 -0
  78. package/dist/cli.js.map +1 -0
  79. package/dist/config-file.d.ts +52 -0
  80. package/dist/config-file.d.ts.map +1 -0
  81. package/dist/config-file.js +130 -0
  82. package/dist/config-file.js.map +1 -0
  83. package/dist/config.d.ts +49 -0
  84. package/dist/config.d.ts.map +1 -0
  85. package/dist/config.js +98 -0
  86. package/dist/config.js.map +1 -0
  87. package/dist/daemon.d.ts +265 -0
  88. package/dist/daemon.d.ts.map +1 -0
  89. package/dist/daemon.js +664 -0
  90. package/dist/daemon.js.map +1 -0
  91. package/dist/doctor-registry.d.ts +134 -0
  92. package/dist/doctor-registry.d.ts.map +1 -0
  93. package/dist/doctor-registry.js +173 -0
  94. package/dist/doctor-registry.js.map +1 -0
  95. package/dist/embeddings/cohere-portkey.d.ts +67 -0
  96. package/dist/embeddings/cohere-portkey.d.ts.map +1 -0
  97. package/dist/embeddings/cohere-portkey.js +171 -0
  98. package/dist/embeddings/cohere-portkey.js.map +1 -0
  99. package/dist/embeddings/config.d.ts +74 -0
  100. package/dist/embeddings/config.d.ts.map +1 -0
  101. package/dist/embeddings/config.js +131 -0
  102. package/dist/embeddings/config.js.map +1 -0
  103. package/dist/embeddings/guard.d.ts +34 -0
  104. package/dist/embeddings/guard.d.ts.map +1 -0
  105. package/dist/embeddings/guard.js +67 -0
  106. package/dist/embeddings/guard.js.map +1 -0
  107. package/dist/embeddings/hosted-portkey.d.ts +73 -0
  108. package/dist/embeddings/hosted-portkey.d.ts.map +1 -0
  109. package/dist/embeddings/hosted-portkey.js +179 -0
  110. package/dist/embeddings/hosted-portkey.js.map +1 -0
  111. package/dist/embeddings/http.d.ts +33 -0
  112. package/dist/embeddings/http.d.ts.map +1 -0
  113. package/dist/embeddings/http.js +19 -0
  114. package/dist/embeddings/http.js.map +1 -0
  115. package/dist/embeddings/index.d.ts +17 -0
  116. package/dist/embeddings/index.d.ts.map +1 -0
  117. package/dist/embeddings/index.js +17 -0
  118. package/dist/embeddings/index.js.map +1 -0
  119. package/dist/embeddings/local-nomic.d.ts +78 -0
  120. package/dist/embeddings/local-nomic.d.ts.map +1 -0
  121. package/dist/embeddings/local-nomic.js +126 -0
  122. package/dist/embeddings/local-nomic.js.map +1 -0
  123. package/dist/embeddings/provider.d.ts +79 -0
  124. package/dist/embeddings/provider.d.ts.map +1 -0
  125. package/dist/embeddings/provider.js +50 -0
  126. package/dist/embeddings/provider.js.map +1 -0
  127. package/dist/enricher/config.d.ts +43 -0
  128. package/dist/enricher/config.d.ts.map +1 -0
  129. package/dist/enricher/config.js +34 -0
  130. package/dist/enricher/config.js.map +1 -0
  131. package/dist/enricher/content-cache.d.ts +29 -0
  132. package/dist/enricher/content-cache.d.ts.map +1 -0
  133. package/dist/enricher/content-cache.js +24 -0
  134. package/dist/enricher/content-cache.js.map +1 -0
  135. package/dist/enricher/cycle.d.ts +71 -0
  136. package/dist/enricher/cycle.d.ts.map +1 -0
  137. package/dist/enricher/cycle.js +319 -0
  138. package/dist/enricher/cycle.js.map +1 -0
  139. package/dist/enricher/describe.d.ts +61 -0
  140. package/dist/enricher/describe.d.ts.map +1 -0
  141. package/dist/enricher/describe.js +175 -0
  142. package/dist/enricher/describe.js.map +1 -0
  143. package/dist/enricher/failure.d.ts +25 -0
  144. package/dist/enricher/failure.d.ts.map +1 -0
  145. package/dist/enricher/failure.js +46 -0
  146. package/dist/enricher/failure.js.map +1 -0
  147. package/dist/enricher/index.d.ts +22 -0
  148. package/dist/enricher/index.d.ts.map +1 -0
  149. package/dist/enricher/index.js +22 -0
  150. package/dist/enricher/index.js.map +1 -0
  151. package/dist/enricher/jaccard.d.ts +11 -0
  152. package/dist/enricher/jaccard.d.ts.map +1 -0
  153. package/dist/enricher/jaccard.js +29 -0
  154. package/dist/enricher/jaccard.js.map +1 -0
  155. package/dist/enricher/loop.d.ts +22 -0
  156. package/dist/enricher/loop.d.ts.map +1 -0
  157. package/dist/enricher/loop.js +34 -0
  158. package/dist/enricher/loop.js.map +1 -0
  159. package/dist/enricher/meaningful-change.d.ts +28 -0
  160. package/dist/enricher/meaningful-change.d.ts.map +1 -0
  161. package/dist/enricher/meaningful-change.js +41 -0
  162. package/dist/enricher/meaningful-change.js.map +1 -0
  163. package/dist/enricher/observability.d.ts +22 -0
  164. package/dist/enricher/observability.d.ts.map +1 -0
  165. package/dist/enricher/observability.js +55 -0
  166. package/dist/enricher/observability.js.map +1 -0
  167. package/dist/enricher/pending-query.d.ts +35 -0
  168. package/dist/enricher/pending-query.d.ts.map +1 -0
  169. package/dist/enricher/pending-query.js +54 -0
  170. package/dist/enricher/pending-query.js.map +1 -0
  171. package/dist/enricher/sql-update.d.ts +7 -0
  172. package/dist/enricher/sql-update.d.ts.map +1 -0
  173. package/dist/enricher/sql-update.js +22 -0
  174. package/dist/enricher/sql-update.js.map +1 -0
  175. package/dist/enricher/store-adapter.d.ts +98 -0
  176. package/dist/enricher/store-adapter.d.ts.map +1 -0
  177. package/dist/enricher/store-adapter.js +129 -0
  178. package/dist/enricher/store-adapter.js.map +1 -0
  179. package/dist/enricher/store.d.ts +58 -0
  180. package/dist/enricher/store.d.ts.map +1 -0
  181. package/dist/enricher/store.js +126 -0
  182. package/dist/enricher/store.js.map +1 -0
  183. package/dist/enricher/tokenize.d.ts +10 -0
  184. package/dist/enricher/tokenize.d.ts.map +1 -0
  185. package/dist/enricher/tokenize.js +28 -0
  186. package/dist/enricher/tokenize.js.map +1 -0
  187. package/dist/errors.d.ts +41 -0
  188. package/dist/errors.d.ts.map +1 -0
  189. package/dist/errors.js +56 -0
  190. package/dist/errors.js.map +1 -0
  191. package/dist/health.d.ts +147 -0
  192. package/dist/health.d.ts.map +1 -0
  193. package/dist/health.js +168 -0
  194. package/dist/health.js.map +1 -0
  195. package/dist/hive-graph/deeplake-credentials.d.ts +68 -0
  196. package/dist/hive-graph/deeplake-credentials.d.ts.map +1 -0
  197. package/dist/hive-graph/deeplake-credentials.js +135 -0
  198. package/dist/hive-graph/deeplake-credentials.js.map +1 -0
  199. package/dist/hive-graph/deeplake-heal.d.ts +63 -0
  200. package/dist/hive-graph/deeplake-heal.d.ts.map +1 -0
  201. package/dist/hive-graph/deeplake-heal.js +118 -0
  202. package/dist/hive-graph/deeplake-heal.js.map +1 -0
  203. package/dist/hive-graph/deeplake-store.d.ts +199 -0
  204. package/dist/hive-graph/deeplake-store.d.ts.map +1 -0
  205. package/dist/hive-graph/deeplake-store.js +541 -0
  206. package/dist/hive-graph/deeplake-store.js.map +1 -0
  207. package/dist/hive-graph/deeplake-transport.d.ts +89 -0
  208. package/dist/hive-graph/deeplake-transport.d.ts.map +1 -0
  209. package/dist/hive-graph/deeplake-transport.js +145 -0
  210. package/dist/hive-graph/deeplake-transport.js.map +1 -0
  211. package/dist/hive-graph/hash.d.ts +3 -0
  212. package/dist/hive-graph/hash.d.ts.map +1 -0
  213. package/dist/hive-graph/hash.js +12 -0
  214. package/dist/hive-graph/hash.js.map +1 -0
  215. package/dist/hive-graph/memory-store.d.ts +39 -0
  216. package/dist/hive-graph/memory-store.d.ts.map +1 -0
  217. package/dist/hive-graph/memory-store.js +125 -0
  218. package/dist/hive-graph/memory-store.js.map +1 -0
  219. package/dist/hive-graph/model.d.ts +109 -0
  220. package/dist/hive-graph/model.d.ts.map +1 -0
  221. package/dist/hive-graph/model.js +36 -0
  222. package/dist/hive-graph/model.js.map +1 -0
  223. package/dist/hive-graph/paths.d.ts +7 -0
  224. package/dist/hive-graph/paths.d.ts.map +1 -0
  225. package/dist/hive-graph/paths.js +26 -0
  226. package/dist/hive-graph/paths.js.map +1 -0
  227. package/dist/hive-graph/project-scope.d.ts +99 -0
  228. package/dist/hive-graph/project-scope.d.ts.map +1 -0
  229. package/dist/hive-graph/project-scope.js +286 -0
  230. package/dist/hive-graph/project-scope.js.map +1 -0
  231. package/dist/hive-graph/schema.d.ts +53 -0
  232. package/dist/hive-graph/schema.d.ts.map +1 -0
  233. package/dist/hive-graph/schema.js +139 -0
  234. package/dist/hive-graph/schema.js.map +1 -0
  235. package/dist/hive-graph/search-types.d.ts +82 -0
  236. package/dist/hive-graph/search-types.d.ts.map +1 -0
  237. package/dist/hive-graph/search-types.js +2 -0
  238. package/dist/hive-graph/search-types.js.map +1 -0
  239. package/dist/hive-graph/search.d.ts +51 -0
  240. package/dist/hive-graph/search.d.ts.map +1 -0
  241. package/dist/hive-graph/search.js +417 -0
  242. package/dist/hive-graph/search.js.map +1 -0
  243. package/dist/hive-graph/sql-guards.d.ts +99 -0
  244. package/dist/hive-graph/sql-guards.d.ts.map +1 -0
  245. package/dist/hive-graph/sql-guards.js +129 -0
  246. package/dist/hive-graph/sql-guards.js.map +1 -0
  247. package/dist/hive-graph/store.d.ts +151 -0
  248. package/dist/hive-graph/store.d.ts.map +1 -0
  249. package/dist/hive-graph/store.js +2 -0
  250. package/dist/hive-graph/store.js.map +1 -0
  251. package/dist/hive-graph/ulid.d.ts +14 -0
  252. package/dist/hive-graph/ulid.d.ts.map +1 -0
  253. package/dist/hive-graph/ulid.js +109 -0
  254. package/dist/hive-graph/ulid.js.map +1 -0
  255. package/dist/hivedoctor-registry.d.ts +111 -0
  256. package/dist/hivedoctor-registry.d.ts.map +1 -0
  257. package/dist/hivedoctor-registry.js +143 -0
  258. package/dist/hivedoctor-registry.js.map +1 -0
  259. package/dist/index.d.ts +106 -0
  260. package/dist/index.d.ts.map +1 -0
  261. package/dist/index.js +78 -0
  262. package/dist/index.js.map +1 -0
  263. package/dist/lock.d.ts +66 -0
  264. package/dist/lock.d.ts.map +1 -0
  265. package/dist/lock.js +282 -0
  266. package/dist/lock.js.map +1 -0
  267. package/dist/poll-loop.d.ts +71 -0
  268. package/dist/poll-loop.d.ts.map +1 -0
  269. package/dist/poll-loop.js +130 -0
  270. package/dist/poll-loop.js.map +1 -0
  271. package/dist/portkey/config.d.ts +46 -0
  272. package/dist/portkey/config.d.ts.map +1 -0
  273. package/dist/portkey/config.js +68 -0
  274. package/dist/portkey/config.js.map +1 -0
  275. package/dist/portkey/describe-model.d.ts +53 -0
  276. package/dist/portkey/describe-model.d.ts.map +1 -0
  277. package/dist/portkey/describe-model.js +56 -0
  278. package/dist/portkey/describe-model.js.map +1 -0
  279. package/dist/portkey/headers.d.ts +31 -0
  280. package/dist/portkey/headers.d.ts.map +1 -0
  281. package/dist/portkey/headers.js +37 -0
  282. package/dist/portkey/headers.js.map +1 -0
  283. package/dist/portkey/transport.d.ts +89 -0
  284. package/dist/portkey/transport.d.ts.map +1 -0
  285. package/dist/portkey/transport.js +167 -0
  286. package/dist/portkey/transport.js.map +1 -0
  287. package/dist/projection/format.d.ts +51 -0
  288. package/dist/projection/format.d.ts.map +1 -0
  289. package/dist/projection/format.js +81 -0
  290. package/dist/projection/format.js.map +1 -0
  291. package/dist/projection/generate.d.ts +31 -0
  292. package/dist/projection/generate.d.ts.map +1 -0
  293. package/dist/projection/generate.js +83 -0
  294. package/dist/projection/generate.js.map +1 -0
  295. package/dist/projection/inherit.d.ts +27 -0
  296. package/dist/projection/inherit.d.ts.map +1 -0
  297. package/dist/projection/inherit.js +128 -0
  298. package/dist/projection/inherit.js.map +1 -0
  299. package/dist/projection/load.d.ts +47 -0
  300. package/dist/projection/load.d.ts.map +1 -0
  301. package/dist/projection/load.js +258 -0
  302. package/dist/projection/load.js.map +1 -0
  303. package/dist/projection/store-adapter.d.ts +42 -0
  304. package/dist/projection/store-adapter.d.ts.map +1 -0
  305. package/dist/projection/store-adapter.js +42 -0
  306. package/dist/projection/store-adapter.js.map +1 -0
  307. package/dist/projection/write.d.ts +79 -0
  308. package/dist/projection/write.d.ts.map +1 -0
  309. package/dist/projection/write.js +122 -0
  310. package/dist/projection/write.js.map +1 -0
  311. package/dist/registration/classify.d.ts +33 -0
  312. package/dist/registration/classify.d.ts.map +1 -0
  313. package/dist/registration/classify.js +32 -0
  314. package/dist/registration/classify.js.map +1 -0
  315. package/dist/registration/copy-detect.d.ts +22 -0
  316. package/dist/registration/copy-detect.d.ts.map +1 -0
  317. package/dist/registration/copy-detect.js +12 -0
  318. package/dist/registration/copy-detect.js.map +1 -0
  319. package/dist/registration/disk-fs.d.ts +41 -0
  320. package/dist/registration/disk-fs.d.ts.map +1 -0
  321. package/dist/registration/disk-fs.js +175 -0
  322. package/dist/registration/disk-fs.js.map +1 -0
  323. package/dist/registration/fs-watch.d.ts +114 -0
  324. package/dist/registration/fs-watch.d.ts.map +1 -0
  325. package/dist/registration/fs-watch.js +266 -0
  326. package/dist/registration/fs-watch.js.map +1 -0
  327. package/dist/registration/ignore.d.ts +77 -0
  328. package/dist/registration/ignore.d.ts.map +1 -0
  329. package/dist/registration/ignore.js +249 -0
  330. package/dist/registration/ignore.js.map +1 -0
  331. package/dist/registration/ladder.d.ts +211 -0
  332. package/dist/registration/ladder.d.ts.map +1 -0
  333. package/dist/registration/ladder.js +378 -0
  334. package/dist/registration/ladder.js.map +1 -0
  335. package/dist/registration/paths-safe.d.ts +21 -0
  336. package/dist/registration/paths-safe.d.ts.map +1 -0
  337. package/dist/registration/paths-safe.js +88 -0
  338. package/dist/registration/paths-safe.js.map +1 -0
  339. package/dist/registration/prune-cli.d.ts +48 -0
  340. package/dist/registration/prune-cli.d.ts.map +1 -0
  341. package/dist/registration/prune-cli.js +57 -0
  342. package/dist/registration/prune-cli.js.map +1 -0
  343. package/dist/registration/review-cli.d.ts +42 -0
  344. package/dist/registration/review-cli.d.ts.map +1 -0
  345. package/dist/registration/review-cli.js +110 -0
  346. package/dist/registration/review-cli.js.map +1 -0
  347. package/dist/registration/review-store.d.ts +73 -0
  348. package/dist/registration/review-store.d.ts.map +1 -0
  349. package/dist/registration/review-store.js +243 -0
  350. package/dist/registration/review-store.js.map +1 -0
  351. package/dist/registration/service.d.ts +196 -0
  352. package/dist/registration/service.d.ts.map +1 -0
  353. package/dist/registration/service.js +384 -0
  354. package/dist/registration/service.js.map +1 -0
  355. package/dist/registration/store-bridge.d.ts +133 -0
  356. package/dist/registration/store-bridge.d.ts.map +1 -0
  357. package/dist/registration/store-bridge.js +159 -0
  358. package/dist/registration/store-bridge.js.map +1 -0
  359. package/dist/registration/tlsh.d.ts +125 -0
  360. package/dist/registration/tlsh.d.ts.map +1 -0
  361. package/dist/registration/tlsh.js +274 -0
  362. package/dist/registration/tlsh.js.map +1 -0
  363. package/dist/server.d.ts +26 -0
  364. package/dist/server.d.ts.map +1 -0
  365. package/dist/server.js +156 -0
  366. package/dist/server.js.map +1 -0
  367. package/dist/service/argv.d.ts +52 -0
  368. package/dist/service/argv.d.ts.map +1 -0
  369. package/dist/service/argv.js +127 -0
  370. package/dist/service/argv.js.map +1 -0
  371. package/dist/service/command-runner.d.ts +54 -0
  372. package/dist/service/command-runner.d.ts.map +1 -0
  373. package/dist/service/command-runner.js +55 -0
  374. package/dist/service/command-runner.js.map +1 -0
  375. package/dist/service/index.d.ts +83 -0
  376. package/dist/service/index.d.ts.map +1 -0
  377. package/dist/service/index.js +270 -0
  378. package/dist/service/index.js.map +1 -0
  379. package/dist/service/platform.d.ts +110 -0
  380. package/dist/service/platform.d.ts.map +1 -0
  381. package/dist/service/platform.js +157 -0
  382. package/dist/service/platform.js.map +1 -0
  383. package/dist/service/templates.d.ts +88 -0
  384. package/dist/service/templates.d.ts.map +1 -0
  385. package/dist/service/templates.js +212 -0
  386. package/dist/service/templates.js.map +1 -0
  387. package/dist/source-graph/deeplake-credentials.d.ts +57 -0
  388. package/dist/source-graph/deeplake-credentials.d.ts.map +1 -0
  389. package/dist/source-graph/deeplake-credentials.js +109 -0
  390. package/dist/source-graph/deeplake-credentials.js.map +1 -0
  391. package/dist/source-graph/deeplake-heal.d.ts +53 -0
  392. package/dist/source-graph/deeplake-heal.d.ts.map +1 -0
  393. package/dist/source-graph/deeplake-heal.js +41 -0
  394. package/dist/source-graph/deeplake-heal.js.map +1 -0
  395. package/dist/source-graph/deeplake-store.d.ts +151 -0
  396. package/dist/source-graph/deeplake-store.d.ts.map +1 -0
  397. package/dist/source-graph/deeplake-store.js +389 -0
  398. package/dist/source-graph/deeplake-store.js.map +1 -0
  399. package/dist/source-graph/deeplake-transport.d.ts +74 -0
  400. package/dist/source-graph/deeplake-transport.d.ts.map +1 -0
  401. package/dist/source-graph/deeplake-transport.js +107 -0
  402. package/dist/source-graph/deeplake-transport.js.map +1 -0
  403. package/dist/source-graph/hash.d.ts +3 -0
  404. package/dist/source-graph/hash.d.ts.map +1 -0
  405. package/dist/source-graph/hash.js +12 -0
  406. package/dist/source-graph/hash.js.map +1 -0
  407. package/dist/source-graph/memory-store.d.ts +32 -0
  408. package/dist/source-graph/memory-store.d.ts.map +1 -0
  409. package/dist/source-graph/memory-store.js +81 -0
  410. package/dist/source-graph/memory-store.js.map +1 -0
  411. package/dist/source-graph/model.d.ts +102 -0
  412. package/dist/source-graph/model.d.ts.map +1 -0
  413. package/dist/source-graph/model.js +36 -0
  414. package/dist/source-graph/model.js.map +1 -0
  415. package/dist/source-graph/paths.d.ts +7 -0
  416. package/dist/source-graph/paths.d.ts.map +1 -0
  417. package/dist/source-graph/paths.js +26 -0
  418. package/dist/source-graph/paths.js.map +1 -0
  419. package/dist/source-graph/schema.d.ts +44 -0
  420. package/dist/source-graph/schema.d.ts.map +1 -0
  421. package/dist/source-graph/schema.js +123 -0
  422. package/dist/source-graph/schema.js.map +1 -0
  423. package/dist/source-graph/sql-guards.d.ts +99 -0
  424. package/dist/source-graph/sql-guards.d.ts.map +1 -0
  425. package/dist/source-graph/sql-guards.js +129 -0
  426. package/dist/source-graph/sql-guards.js.map +1 -0
  427. package/dist/source-graph/store.d.ts +101 -0
  428. package/dist/source-graph/store.d.ts.map +1 -0
  429. package/dist/source-graph/store.js +2 -0
  430. package/dist/source-graph/store.js.map +1 -0
  431. package/dist/source-graph/ulid.d.ts +9 -0
  432. package/dist/source-graph/ulid.d.ts.map +1 -0
  433. package/dist/source-graph/ulid.js +61 -0
  434. package/dist/source-graph/ulid.js.map +1 -0
  435. package/dist/telemetry/checkin.d.ts +66 -0
  436. package/dist/telemetry/checkin.d.ts.map +1 -0
  437. package/dist/telemetry/checkin.js +142 -0
  438. package/dist/telemetry/checkin.js.map +1 -0
  439. package/dist/telemetry/db.d.ts +34 -0
  440. package/dist/telemetry/db.d.ts.map +1 -0
  441. package/dist/telemetry/db.js +122 -0
  442. package/dist/telemetry/db.js.map +1 -0
  443. package/dist/telemetry/index.d.ts +76 -0
  444. package/dist/telemetry/index.d.ts.map +1 -0
  445. package/dist/telemetry/index.js +98 -0
  446. package/dist/telemetry/index.js.map +1 -0
  447. package/dist/telemetry/logs.d.ts +83 -0
  448. package/dist/telemetry/logs.d.ts.map +1 -0
  449. package/dist/telemetry/logs.js +110 -0
  450. package/dist/telemetry/logs.js.map +1 -0
  451. package/dist/telemetry/metrics.d.ts +82 -0
  452. package/dist/telemetry/metrics.d.ts.map +1 -0
  453. package/dist/telemetry/metrics.js +148 -0
  454. package/dist/telemetry/metrics.js.map +1 -0
  455. package/dist/telemetry-usage/emit.d.ts +105 -0
  456. package/dist/telemetry-usage/emit.d.ts.map +1 -0
  457. package/dist/telemetry-usage/emit.js +267 -0
  458. package/dist/telemetry-usage/emit.js.map +1 -0
  459. package/dist/telemetry-usage/posthog-key.d.ts +22 -0
  460. package/dist/telemetry-usage/posthog-key.d.ts.map +1 -0
  461. package/dist/telemetry-usage/posthog-key.js +22 -0
  462. package/dist/telemetry-usage/posthog-key.js.map +1 -0
  463. package/dist/worker.d.ts +69 -0
  464. package/dist/worker.d.ts.map +1 -0
  465. package/dist/worker.js +91 -0
  466. package/dist/worker.js.map +1 -0
  467. package/package.json +44 -0
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Brood prerequisite evaluation and first-run guidance (PRD-018k / NEC-023).
3
+ *
4
+ * Brooding is dormant out of the box: auto-brood on boot runs only when Deep
5
+ * Lake credentials resolve AND Portkey is explicitly enabled (via
6
+ * `NECTAR_PORTKEY_ENABLED` + `NECTAR_PORTKEY_API_KEY` + `NECTAR_PORTKEY_CONFIG`).
7
+ * Without those the daemon boots, serves `/health`, and describes nothing, with
8
+ * no signal that it is waiting on configuration. This module makes the dormancy
9
+ * loud: the daemon logs exactly which prerequisites are missing at startup, the
10
+ * `/health` brooding slice carries a machine-readable reason, and (on an
11
+ * interactive terminal) the CLI prints the exact steps to configure them.
12
+ *
13
+ * Pure and dependency-free (Node built-ins only, AGENTS.md): a caller supplies
14
+ * whether the credentials file resolved and the Portkey env flags; this module
15
+ * decides ready/dormant, the machine-readable reason, and the human message.
16
+ */
17
+ /** The machine-readable dormancy reason surfaced on `/health` and in the startup log. */
18
+ export type BroodDormancyReason = "credentials_missing" | "portkey_disabled";
19
+ /** The outcome of evaluating the brood prerequisites. */
20
+ export interface BroodPrereqStatus {
21
+ /** True when every prerequisite is satisfied (auto-brood can run). */
22
+ readonly ready: boolean;
23
+ /** The machine-readable reason when dormant; null when ready. */
24
+ readonly reason: BroodDormancyReason | null;
25
+ /** Human-readable list of exactly what is missing (empty when ready). */
26
+ readonly missing: readonly string[];
27
+ }
28
+ /** The resolved prerequisite inputs (each already reduced to a boolean by the caller). */
29
+ export interface BroodPrereqInputs {
30
+ /** `~/.deeplake/credentials.json` resolved and validated. */
31
+ readonly credentialsPresent: boolean;
32
+ /** The credentials file path, named in the missing list when absent. */
33
+ readonly credentialsPath: string;
34
+ /** `NECTAR_PORTKEY_ENABLED` is set to a truthy value. */
35
+ readonly portkeyEnabled: boolean;
36
+ /** `NECTAR_PORTKEY_API_KEY` is set (non-blank). */
37
+ readonly portkeyApiKeySet: boolean;
38
+ /** `NECTAR_PORTKEY_CONFIG` is set (non-blank). */
39
+ readonly portkeyConfigSet: boolean;
40
+ }
41
+ /**
42
+ * Evaluate the brood prerequisites. `ready` is true only when the credentials
43
+ * file resolved and all three Portkey variables are set; otherwise `reason` is
44
+ * `credentials_missing` (credentials take priority as the first blocker) or
45
+ * `portkey_disabled`, and `missing` names each unsatisfied prerequisite so the
46
+ * startup log can enumerate them (AC-018k.1 / AC-018k.2).
47
+ */
48
+ export declare function evaluateBroodPrereqs(inputs: BroodPrereqInputs): BroodPrereqStatus;
49
+ /** Build the prerequisite status from the process env + a resolved credentials state. */
50
+ export declare function broodPrereqsFromEnv(opts: {
51
+ readonly credentialsPresent: boolean;
52
+ readonly credentialsPath: string;
53
+ readonly env?: NodeJS.ProcessEnv;
54
+ }): BroodPrereqStatus;
55
+ /**
56
+ * Build the guided first-run message a caller prints on an interactive terminal
57
+ * (AC-018k.5 option B): the exact steps to satisfy the missing prerequisites.
58
+ * Returns the empty string when nothing is missing, so a caller can print it
59
+ * unconditionally without a "you are configured" line.
60
+ */
61
+ export declare function formatFirstRunGuidance(status: BroodPrereqStatus): string;
62
+ //# sourceMappingURL=brood-prereqs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brood-prereqs.d.ts","sourceRoot":"","sources":["../src/brood-prereqs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,yFAAyF;AACzF,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,GAAG,kBAAkB,CAAC;AAE7E,yDAAyD;AACzD,MAAM,WAAW,iBAAiB;IAChC,sEAAsE;IACtE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,iEAAiE;IACjE,QAAQ,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAC5C,yEAAyE;IACzE,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED,0FAA0F;AAC1F,MAAM,WAAW,iBAAiB;IAChC,6DAA6D;IAC7D,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;IACrC,wEAAwE;IACxE,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,yDAAyD;IACzD,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,mDAAmD;IACnD,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,kDAAkD;IAClD,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;CACpC;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,CAUjF;AAcD,yFAAyF;AACzF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACxC,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;IACrC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CAClC,GAAG,iBAAiB,CASpB;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAiBxE"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Brood prerequisite evaluation and first-run guidance (PRD-018k / NEC-023).
3
+ *
4
+ * Brooding is dormant out of the box: auto-brood on boot runs only when Deep
5
+ * Lake credentials resolve AND Portkey is explicitly enabled (via
6
+ * `NECTAR_PORTKEY_ENABLED` + `NECTAR_PORTKEY_API_KEY` + `NECTAR_PORTKEY_CONFIG`).
7
+ * Without those the daemon boots, serves `/health`, and describes nothing, with
8
+ * no signal that it is waiting on configuration. This module makes the dormancy
9
+ * loud: the daemon logs exactly which prerequisites are missing at startup, the
10
+ * `/health` brooding slice carries a machine-readable reason, and (on an
11
+ * interactive terminal) the CLI prints the exact steps to configure them.
12
+ *
13
+ * Pure and dependency-free (Node built-ins only, AGENTS.md): a caller supplies
14
+ * whether the credentials file resolved and the Portkey env flags; this module
15
+ * decides ready/dormant, the machine-readable reason, and the human message.
16
+ */
17
+ /**
18
+ * Evaluate the brood prerequisites. `ready` is true only when the credentials
19
+ * file resolved and all three Portkey variables are set; otherwise `reason` is
20
+ * `credentials_missing` (credentials take priority as the first blocker) or
21
+ * `portkey_disabled`, and `missing` names each unsatisfied prerequisite so the
22
+ * startup log can enumerate them (AC-018k.1 / AC-018k.2).
23
+ */
24
+ export function evaluateBroodPrereqs(inputs) {
25
+ const missing = [];
26
+ if (!inputs.credentialsPresent)
27
+ missing.push(`${inputs.credentialsPath} (Deep Lake credentials)`);
28
+ if (!inputs.portkeyEnabled)
29
+ missing.push("NECTAR_PORTKEY_ENABLED");
30
+ if (!inputs.portkeyApiKeySet)
31
+ missing.push("NECTAR_PORTKEY_API_KEY");
32
+ if (!inputs.portkeyConfigSet)
33
+ missing.push("NECTAR_PORTKEY_CONFIG");
34
+ if (missing.length === 0)
35
+ return { ready: true, reason: null, missing: [] };
36
+ const reason = inputs.credentialsPresent ? "portkey_disabled" : "credentials_missing";
37
+ return { ready: false, reason, missing };
38
+ }
39
+ /** True when an env value is a recognized truthy flag (mirrors portkey/config's `envBool`). */
40
+ function envTruthy(raw) {
41
+ if (raw === undefined)
42
+ return false;
43
+ const v = raw.trim().toLowerCase();
44
+ return v === "1" || v === "true" || v === "yes" || v === "on";
45
+ }
46
+ /** True when an env value is present and non-blank. */
47
+ function envSet(raw) {
48
+ return raw !== undefined && raw.trim() !== "";
49
+ }
50
+ /** Build the prerequisite status from the process env + a resolved credentials state. */
51
+ export function broodPrereqsFromEnv(opts) {
52
+ const env = opts.env ?? process.env;
53
+ return evaluateBroodPrereqs({
54
+ credentialsPresent: opts.credentialsPresent,
55
+ credentialsPath: opts.credentialsPath,
56
+ portkeyEnabled: envTruthy(env["NECTAR_PORTKEY_ENABLED"]),
57
+ portkeyApiKeySet: envSet(env["NECTAR_PORTKEY_API_KEY"]),
58
+ portkeyConfigSet: envSet(env["NECTAR_PORTKEY_CONFIG"]),
59
+ });
60
+ }
61
+ /**
62
+ * Build the guided first-run message a caller prints on an interactive terminal
63
+ * (AC-018k.5 option B): the exact steps to satisfy the missing prerequisites.
64
+ * Returns the empty string when nothing is missing, so a caller can print it
65
+ * unconditionally without a "you are configured" line.
66
+ */
67
+ export function formatFirstRunGuidance(status) {
68
+ if (status.ready)
69
+ return "";
70
+ const lines = [
71
+ "nectar: brooding is dormant, so no file will be described yet.",
72
+ "To enable it, configure these prerequisites, then restart the daemon:",
73
+ ];
74
+ if (status.reason === "credentials_missing") {
75
+ lines.push(" 1. Sign in so ~/.deeplake/credentials.json exists (the shared Deep Lake credentials).");
76
+ lines.push(" 2. Enable Portkey so descriptions can be generated:");
77
+ }
78
+ else {
79
+ lines.push(" 1. Enable Portkey so descriptions can be generated:");
80
+ }
81
+ lines.push(" export NECTAR_PORTKEY_ENABLED=1");
82
+ lines.push(" export NECTAR_PORTKEY_API_KEY=<your Portkey API key>");
83
+ lines.push(" export NECTAR_PORTKEY_CONFIG=<your Portkey config id>");
84
+ lines.push(`Missing now: ${status.missing.join(", ")}.`);
85
+ return `${lines.join("\n")}\n`;
86
+ }
87
+ //# sourceMappingURL=brood-prereqs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brood-prereqs.js","sourceRoot":"","sources":["../src/brood-prereqs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AA6BH;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAyB;IAC5D,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,CAAC,MAAM,CAAC,kBAAkB;QAAE,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,eAAe,0BAA0B,CAAC,CAAC;IAClG,IAAI,CAAC,MAAM,CAAC,cAAc;QAAE,OAAO,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACnE,IAAI,CAAC,MAAM,CAAC,gBAAgB;QAAE,OAAO,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACrE,IAAI,CAAC,MAAM,CAAC,gBAAgB;QAAE,OAAO,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IAEpE,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC5E,MAAM,MAAM,GAAwB,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,qBAAqB,CAAC;IAC3G,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC3C,CAAC;AAED,+FAA+F;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CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC;IACtE,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;IACrD,KAAK,CAAC,IAAI,CAAC,6DAA6D,CAAC,CAAC;IAC1E,KAAK,CAAC,IAAI,CAAC,8DAA8D,CAAC,CAAC;IAC3E,KAAK,CAAC,IAAI,CAAC,gBAAgB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzD,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACjC,CAAC"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Bucketing + dynamic batch packing (PRD-007b) - stage 3 of the pipeline.
3
+ *
4
+ * Files that survive the pre-check are bucketed by size and parsability into the
5
+ * four buckets, carried verbatim from `brooding-pipeline.md`:
6
+ *
7
+ * - skip-binary NUL in first 8 KB, or a known-binary extension. No LLM call.
8
+ * - skip-too-large size_bytes > MAX_DESCRIBE_SIZE (256 KB). No LLM call.
9
+ * - batch text, size_bytes <= BATCH_FILE_SIZE (4 KB), cumulative <= 100 KB.
10
+ * - solo text, size_bytes > BATCH_FILE_SIZE but <= MAX_DESCRIBE_SIZE.
11
+ *
12
+ * The buckets are mutually exclusive and exhaustive. Batch packing is DYNAMIC
13
+ * (locked decision #22): files are packed until the estimated input-token budget
14
+ * is approached, capped by the 100 KB cumulative `BATCH_TOTAL_SIZE` and the
15
+ * max-files safety ceiling in the corpus's 30-50 band - it adapts to actual file
16
+ * sizes rather than counting a fixed number of files, and preserves the cost
17
+ * math (~40 files/call remains the representative average at ~2 KB/file).
18
+ */
19
+ import { type BroodBucket } from "./constants.js";
20
+ import type { PreparedFile } from "./precheck.js";
21
+ /** Estimated input tokens for a byte count ("4 KB of source ~= 1K tokens"). */
22
+ export declare function estimateTokens(sizeBytes: number): number;
23
+ /**
24
+ * True when an extension is in the known-binary list, with NO dependence on
25
+ * file content or size. Exposed so {@link "./precheck.js" | precheck.ts} can
26
+ * short-circuit a known-binary file before reading any bytes (NEC-012 /
27
+ * AC-018e.5), the same predicate {@link classifyBucket} applies after prepare.
28
+ */
29
+ export declare function isKnownBinaryExtension(ext: string): boolean;
30
+ /**
31
+ * Classify one prepared file into exactly one bucket. Order: known-binary
32
+ * extension first (no size dependence), then too-large, then NUL-sniffed binary,
33
+ * then the batch/solo size split.
34
+ */
35
+ export declare function classifyBucket(prepared: PreparedFile): BroodBucket;
36
+ /** A packed batch call: the files it carries plus its cumulative byte + token estimate. */
37
+ export interface BatchGroup {
38
+ readonly files: readonly PreparedFile[];
39
+ readonly totalBytes: number;
40
+ readonly estimatedTokens: number;
41
+ }
42
+ export interface PackBatchesOptions {
43
+ readonly maxFiles?: number;
44
+ readonly maxTotalBytes?: number;
45
+ readonly tokenBudget?: number;
46
+ }
47
+ /**
48
+ * Pack batch-eligible files into {@link BatchGroup}s with dynamic token-budget
49
+ * packing (decision #22). A file starts a new group when adding it to the
50
+ * current group would exceed the max-files ceiling, the cumulative byte cap, or
51
+ * the input-token budget. A single file always fits (a batch file is <= 4 KB).
52
+ */
53
+ export declare function packBatches(batchFiles: readonly PreparedFile[], opts?: PackBatchesOptions): BatchGroup[];
54
+ /** The full bucketing outcome for a set of survivors. */
55
+ export interface BucketedFiles {
56
+ readonly skipBinary: readonly PreparedFile[];
57
+ readonly skipTooLarge: readonly PreparedFile[];
58
+ /** Batch-eligible files packed into dynamic groups. */
59
+ readonly batches: readonly BatchGroup[];
60
+ readonly soloFiles: readonly PreparedFile[];
61
+ /** Flat count of files in the batch bucket (across all groups). */
62
+ readonly batchFileCount: number;
63
+ /** Count of solo files. */
64
+ readonly soloFileCount: number;
65
+ }
66
+ /** Bucket survivors into the four buckets, packing the batch bucket dynamically. */
67
+ export declare function bucketFiles(survivors: readonly PreparedFile[], opts?: PackBatchesOptions): BucketedFiles;
68
+ //# sourceMappingURL=bucketing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,2BAA2B;IAC3B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAED,oFAAoF;AACpF,wBAAgB,WAAW,CACzB,SAAS,EAAE,SAAS,YAAY,EAAE,EAClC,IAAI,GAAE,kBAAuB,GAC5B,aAAa,CAqCf"}
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Bucketing + dynamic batch packing (PRD-007b) - stage 3 of the pipeline.
3
+ *
4
+ * Files that survive the pre-check are bucketed by size and parsability into the
5
+ * four buckets, carried verbatim from `brooding-pipeline.md`:
6
+ *
7
+ * - skip-binary NUL in first 8 KB, or a known-binary extension. No LLM call.
8
+ * - skip-too-large size_bytes > MAX_DESCRIBE_SIZE (256 KB). No LLM call.
9
+ * - batch text, size_bytes <= BATCH_FILE_SIZE (4 KB), cumulative <= 100 KB.
10
+ * - solo text, size_bytes > BATCH_FILE_SIZE but <= MAX_DESCRIBE_SIZE.
11
+ *
12
+ * The buckets are mutually exclusive and exhaustive. Batch packing is DYNAMIC
13
+ * (locked decision #22): files are packed until the estimated input-token budget
14
+ * is approached, capped by the 100 KB cumulative `BATCH_TOTAL_SIZE` and the
15
+ * max-files safety ceiling in the corpus's 30-50 band - it adapts to actual file
16
+ * sizes rather than counting a fixed number of files, and preserves the cost
17
+ * math (~40 files/call remains the representative average at ~2 KB/file).
18
+ */
19
+ import { BATCH_FILE_SIZE, BATCH_INPUT_TOKEN_BUDGET, BATCH_TOTAL_SIZE, BYTES_PER_TOKEN, KNOWN_BINARY_EXTENSIONS, MAX_BATCH_FILES, MAX_DESCRIBE_SIZE, } from "./constants.js";
20
+ /** Estimated input tokens for a byte count ("4 KB of source ~= 1K tokens"). */
21
+ export function estimateTokens(sizeBytes) {
22
+ return Math.ceil(sizeBytes / BYTES_PER_TOKEN);
23
+ }
24
+ /**
25
+ * True when an extension is in the known-binary list, with NO dependence on
26
+ * file content or size. Exposed so {@link "./precheck.js" | precheck.ts} can
27
+ * short-circuit a known-binary file before reading any bytes (NEC-012 /
28
+ * AC-018e.5), the same predicate {@link classifyBucket} applies after prepare.
29
+ */
30
+ export function isKnownBinaryExtension(ext) {
31
+ return KNOWN_BINARY_EXTENSIONS.has(ext);
32
+ }
33
+ /**
34
+ * Classify one prepared file into exactly one bucket. Order: known-binary
35
+ * extension first (no size dependence), then too-large, then NUL-sniffed binary,
36
+ * then the batch/solo size split.
37
+ */
38
+ export function classifyBucket(prepared) {
39
+ if (isKnownBinaryExtension(prepared.file.ext))
40
+ return "skip-binary";
41
+ if (prepared.file.sizeBytes > MAX_DESCRIBE_SIZE)
42
+ return "skip-too-large";
43
+ if (prepared.hasNulInSniff)
44
+ return "skip-binary";
45
+ if (prepared.file.sizeBytes <= BATCH_FILE_SIZE)
46
+ return "batch";
47
+ return "solo";
48
+ }
49
+ /**
50
+ * Pack batch-eligible files into {@link BatchGroup}s with dynamic token-budget
51
+ * packing (decision #22). A file starts a new group when adding it to the
52
+ * current group would exceed the max-files ceiling, the cumulative byte cap, or
53
+ * the input-token budget. A single file always fits (a batch file is <= 4 KB).
54
+ */
55
+ export function packBatches(batchFiles, opts = {}) {
56
+ const maxFiles = opts.maxFiles ?? MAX_BATCH_FILES;
57
+ const maxTotalBytes = opts.maxTotalBytes ?? BATCH_TOTAL_SIZE;
58
+ const tokenBudget = opts.tokenBudget ?? BATCH_INPUT_TOKEN_BUDGET;
59
+ const groups = [];
60
+ let current = [];
61
+ let bytes = 0;
62
+ let tokens = 0;
63
+ const flush = () => {
64
+ if (current.length > 0) {
65
+ groups.push({ files: current, totalBytes: bytes, estimatedTokens: tokens });
66
+ current = [];
67
+ bytes = 0;
68
+ tokens = 0;
69
+ }
70
+ };
71
+ for (const f of batchFiles) {
72
+ const fileTokens = estimateTokens(f.file.sizeBytes);
73
+ const wouldExceed = current.length + 1 > maxFiles ||
74
+ bytes + f.file.sizeBytes > maxTotalBytes ||
75
+ tokens + fileTokens > tokenBudget;
76
+ if (current.length > 0 && wouldExceed)
77
+ flush();
78
+ current.push(f);
79
+ bytes += f.file.sizeBytes;
80
+ tokens += fileTokens;
81
+ }
82
+ flush();
83
+ return groups;
84
+ }
85
+ /** Bucket survivors into the four buckets, packing the batch bucket dynamically. */
86
+ export function bucketFiles(survivors, opts = {}) {
87
+ const skipBinary = [];
88
+ const skipTooLarge = [];
89
+ const batchEligible = [];
90
+ const soloFiles = [];
91
+ for (const p of survivors) {
92
+ const bucket = classifyBucket(p);
93
+ switch (bucket) {
94
+ case "skip-binary":
95
+ skipBinary.push(p);
96
+ break;
97
+ case "skip-too-large":
98
+ skipTooLarge.push(p);
99
+ break;
100
+ case "batch":
101
+ batchEligible.push(p);
102
+ break;
103
+ case "solo":
104
+ soloFiles.push(p);
105
+ break;
106
+ default: {
107
+ const _exhaustive = bucket;
108
+ return _exhaustive;
109
+ }
110
+ }
111
+ }
112
+ const batches = packBatches(batchEligible, opts);
113
+ return {
114
+ skipBinary,
115
+ skipTooLarge,
116
+ batches,
117
+ soloFiles,
118
+ batchFileCount: batchEligible.length,
119
+ soloFileCount: soloFiles.length,
120
+ };
121
+ }
122
+ //# sourceMappingURL=bucketing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bucketing.js","sourceRoot":"","sources":["../../src/brooding/bucketing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,gBAAgB,EAChB,eAAe,EACf,uBAAuB,EACvB,eAAe,EACf,iBAAiB,GAElB,MAAM,gBAAgB,CAAC;AAGxB,+EAA+E;AAC/E,MAAM,UAAU,cAAc,CAAC,SAAiB;IAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,eAAe,CAAC,CAAC;AAChD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,GAAW;IAChD,OAAO,uBAAuB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC1C,CAAC;AAED;;;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AC;YACrB,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAAG,WAAW,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IACjD,OAAO;QACL,UAAU;QACV,YAAY;QACZ,OAAO;QACP,SAAS;QACT,cAAc,EAAE,aAAa,CAAC,MAAM;QACpC,aAAa,EAAE,SAAS,CAAC,MAAM;KAChC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,78 @@
1
+ import type { Tenancy } from "../hive-graph/model.js";
2
+ import type { AsyncHiveGraphStore, HiveGraphStore } from "../hive-graph/store.js";
3
+ import type { BroodRunOptions } from "./pipeline.js";
4
+ import type { BroodCostEstimate } from "./cost.js";
5
+ import type { DiscoverySource } from "./discovery.js";
6
+ /** The parsed `brood` flags plus any parse errors. */
7
+ export interface ParsedBroodArgs {
8
+ readonly options: BroodRunOptions;
9
+ /** Non-empty when a flag was malformed (e.g. `--limit abc`); the caller should reject. */
10
+ readonly errors: readonly string[];
11
+ }
12
+ /**
13
+ * Parse the `brood` verb's flags. Recognizes `--force`, `--dry-run`,
14
+ * `--limit N` (and `--limit=N`), and `--model <new>` (and `--model=<new>`).
15
+ * Unknown flags and malformed values are reported in `errors`.
16
+ */
17
+ export declare function parseBroodArgs(argv: readonly string[]): ParsedBroodArgs;
18
+ /** Inputs the automatic-trigger decision needs (checked at startup / registration). */
19
+ export interface AutoBroodCheck {
20
+ /** Whether the project already has any `hive_graph` rows. */
21
+ readonly hasHiveGraphRows: boolean;
22
+ /** Whether `.honeycomb/nectars.json` exists for the project. */
23
+ readonly hasProjection: boolean;
24
+ }
25
+ /**
26
+ * The automatic trigger (PRD-007d): brooding runs the first time hiveantennae
27
+ * runs against a project with NO `hive_graph` rows OR NO `.honeycomb/nectars.json`.
28
+ * The daemon must run this in the background (it does not block readiness).
29
+ */
30
+ export declare function shouldAutoBrood(check: AutoBroodCheck): boolean;
31
+ /** Build the {@link AutoBroodCheck} from the store + project root (a startup helper). */
32
+ export declare function evaluateAutoBrood(store: HiveGraphStore, tenancy: Tenancy, root: string): AutoBroodCheck;
33
+ /**
34
+ * The async twin of {@link evaluateAutoBrood} for the durable
35
+ * {@link AsyncHiveGraphStore} (Deep Lake). Reads whether the project has any
36
+ * hive_graph rows over the async store and whether the projection exists on
37
+ * disk. The daemon's durable auto-brood path uses this so a real daemon with
38
+ * Deep Lake credentials evaluates the trigger against the durable substrate.
39
+ */
40
+ export declare function evaluateAutoBroodAsync(store: AsyncHiveGraphStore, tenancy: Tenancy, root: string): Promise<AutoBroodCheck>;
41
+ /** The fields a dry-run preview prints (a subset shared by plan + result). */
42
+ export interface DryRunPreviewInput {
43
+ readonly discoveredCount: number;
44
+ readonly inheritedCount: number;
45
+ readonly skipBinaryCount: number;
46
+ readonly skipTooLargeCount: number;
47
+ readonly batchFileCount: number;
48
+ readonly soloFileCount: number;
49
+ readonly batchCalls: number;
50
+ readonly soloCalls: number;
51
+ readonly estimate: BroodCostEstimate;
52
+ /**
53
+ * PRD-018c AC-018c.11: how discovery produced the candidate set ("git" or
54
+ * "walk"). Optional so existing callers that predate this field keep
55
+ * compiling; `formatDryRunReport` simply omits the line when absent.
56
+ */
57
+ readonly source?: DiscoverySource;
58
+ /**
59
+ * PRD-018c NEC-039 / AC-018c.10/11: set when `source` is "walk" because git
60
+ * was PRESENT but ERRORED - the loud counterpart to the silent walk that
61
+ * runs when git is simply absent (which leaves this undefined).
62
+ */
63
+ readonly degraded?: {
64
+ readonly reason: string;
65
+ };
66
+ }
67
+ /**
68
+ * Format the `--dry-run` cost preview (PRD-007d). Prints the bucket counts, the
69
+ * estimated call count, and the estimated cost for THIS project, derived from
70
+ * the 007b per-bucket economics applied to the actual discovery.
71
+ *
72
+ * PRD-018c AC-018c.11: also prints the discovery source (git or walk) and,
73
+ * when discovery degraded to the walk because git errored (never when git is
74
+ * simply absent), the reason - so a user can tell the degradation happened
75
+ * instead of only noticing an inflated brood cost.
76
+ */
77
+ export declare function formatDryRunReport(input: DryRunPreviewInput): string;
78
+ //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Q,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;IAClC;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CACjD;AAMD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,kBAAkB,GAAG,MAAM,CAoBpE"}
@@ -0,0 +1,140 @@
1
+ /**
2
+ * The `brood` CLI surface (PRD-007d).
3
+ *
4
+ * Owns the BROOD-verb behavior: flag parsing (`--force`, `--limit N`,
5
+ * `--dry-run`, `--model <new>`), the two triggering paths (automatic on a fresh
6
+ * project vs explicit invocation), and the `--dry-run` cost-preview formatting.
7
+ * The CLI INVOCATION dispatch (the `nectar` binary, loopback thin-client) is
8
+ * owned by PRD-002c; this module is the pure verb logic the orchestrator wires.
9
+ */
10
+ import { existsSync } from "node:fs";
11
+ import { DEFAULT_PROJECTION_REL_PATH } from "../projection/format.js";
12
+ import { projectionFinalPath } from "../projection/write.js";
13
+ function takeValue(argv, i, inlineValue) {
14
+ if (inlineValue !== undefined)
15
+ return { value: inlineValue, next: i };
16
+ const nextArg = argv[i + 1];
17
+ if (nextArg === undefined || nextArg.startsWith("-"))
18
+ return { value: undefined, next: i };
19
+ return { value: nextArg, next: i + 1 };
20
+ }
21
+ /**
22
+ * Parse the `brood` verb's flags. Recognizes `--force`, `--dry-run`,
23
+ * `--limit N` (and `--limit=N`), and `--model <new>` (and `--model=<new>`).
24
+ * Unknown flags and malformed values are reported in `errors`.
25
+ */
26
+ export function parseBroodArgs(argv) {
27
+ let force = false;
28
+ let dryRun = false;
29
+ let limit;
30
+ let model;
31
+ const errors = [];
32
+ for (let i = 0; i < argv.length; i++) {
33
+ const arg = argv[i];
34
+ const eq = arg.indexOf("=");
35
+ const flag = eq === -1 ? arg : arg.slice(0, eq);
36
+ const inline = eq === -1 ? undefined : arg.slice(eq + 1);
37
+ switch (flag) {
38
+ case "--force":
39
+ force = true;
40
+ break;
41
+ case "--dry-run":
42
+ dryRun = true;
43
+ break;
44
+ case "--limit": {
45
+ const { value, next } = takeValue(argv, i, inline);
46
+ i = next;
47
+ if (value === undefined) {
48
+ errors.push("--limit requires a non-negative integer");
49
+ break;
50
+ }
51
+ const n = Number.parseInt(value, 10);
52
+ if (!Number.isInteger(n) || n < 0 || String(n) !== value.trim()) {
53
+ errors.push(`--limit expects a non-negative integer, got ${JSON.stringify(value)}`);
54
+ break;
55
+ }
56
+ limit = n;
57
+ break;
58
+ }
59
+ case "--model": {
60
+ const { value, next } = takeValue(argv, i, inline);
61
+ i = next;
62
+ if (value === undefined || value.trim() === "") {
63
+ errors.push("--model requires a model id");
64
+ break;
65
+ }
66
+ model = value;
67
+ break;
68
+ }
69
+ default:
70
+ errors.push(`unknown brood flag: ${flag}`);
71
+ break;
72
+ }
73
+ }
74
+ const options = { force, dryRun };
75
+ return {
76
+ options: { ...options, ...(limit !== undefined ? { limit } : {}), ...(model !== undefined ? { model } : {}) },
77
+ errors,
78
+ };
79
+ }
80
+ /**
81
+ * The automatic trigger (PRD-007d): brooding runs the first time hiveantennae
82
+ * runs against a project with NO `hive_graph` rows OR NO `.honeycomb/nectars.json`.
83
+ * The daemon must run this in the background (it does not block readiness).
84
+ */
85
+ export function shouldAutoBrood(check) {
86
+ return !check.hasHiveGraphRows || !check.hasProjection;
87
+ }
88
+ /** Build the {@link AutoBroodCheck} from the store + project root (a startup helper). */
89
+ export function evaluateAutoBrood(store, tenancy, root) {
90
+ const hasHiveGraphRows = store.listLatestVersions(tenancy).length > 0;
91
+ const hasProjection = existsSync(projectionFinalPath(root, DEFAULT_PROJECTION_REL_PATH));
92
+ return { hasHiveGraphRows, hasProjection };
93
+ }
94
+ /**
95
+ * The async twin of {@link evaluateAutoBrood} for the durable
96
+ * {@link AsyncHiveGraphStore} (Deep Lake). Reads whether the project has any
97
+ * hive_graph rows over the async store and whether the projection exists on
98
+ * disk. The daemon's durable auto-brood path uses this so a real daemon with
99
+ * Deep Lake credentials evaluates the trigger against the durable substrate.
100
+ */
101
+ export async function evaluateAutoBroodAsync(store, tenancy, root) {
102
+ const hasHiveGraphRows = (await store.listLatestVersions(tenancy)).length > 0;
103
+ const hasProjection = existsSync(projectionFinalPath(root, DEFAULT_PROJECTION_REL_PATH));
104
+ return { hasHiveGraphRows, hasProjection };
105
+ }
106
+ function usd(n) {
107
+ return `$${n.toFixed(2)}`;
108
+ }
109
+ /**
110
+ * Format the `--dry-run` cost preview (PRD-007d). Prints the bucket counts, the
111
+ * estimated call count, and the estimated cost for THIS project, derived from
112
+ * the 007b per-bucket economics applied to the actual discovery.
113
+ *
114
+ * PRD-018c AC-018c.11: also prints the discovery source (git or walk) and,
115
+ * when discovery degraded to the walk because git errored (never when git is
116
+ * simply absent), the reason - so a user can tell the degradation happened
117
+ * instead of only noticing an inflated brood cost.
118
+ */
119
+ export function formatDryRunReport(input) {
120
+ const e = input.estimate;
121
+ const lines = [
122
+ "brood --dry-run (no LLM calls made)",
123
+ ...(input.source !== undefined ? [` discovery source: ${input.source}`] : []),
124
+ ...(input.degraded !== undefined
125
+ ? [` discovery DEGRADED: git ls-files failed, fell back to a manual walk (${input.degraded.reason})`]
126
+ : []),
127
+ ` discovered: ${input.discoveredCount}`,
128
+ ` inherited ($0): ${input.inheritedCount}`,
129
+ " buckets:",
130
+ ` skip-binary: ${input.skipBinaryCount}`,
131
+ ` skip-too-large: ${input.skipTooLargeCount}`,
132
+ ` batch files: ${input.batchFileCount} (${input.batchCalls} calls)`,
133
+ ` solo files: ${input.soloFileCount} (${input.soloCalls} calls)`,
134
+ ` estimated calls: ${e.totalCalls}`,
135
+ ` estimated input: ${e.inputTokens} tokens`,
136
+ ` estimated cost: ${usd(e.totalUsd)} (input ${usd(e.inputUsd)} + output ${usd(e.outputUsd)}, embedding ${usd(e.embeddingUsd)})`,
137
+ ];
138
+ return lines.join("\n");
139
+ }
140
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/brooding/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGrC,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAY7D,SAAS,SAAS,CAAC,IAAuB,EAAE,CAAS,EAAE,WAA+B;IACpF,IAAI,WAAW,KAAK,SAAS;QAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IACtE,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAC3F,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;AACzC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,IAAuB;IACpD,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,IAAI,MAAM,GAAG,KAAK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