@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,172 @@
1
+ /**
2
+ * Nectar's in-repo router seam over `node:http` (PRD-008a).
3
+ *
4
+ * This is nectar's OWN minimal, zero-runtime-dependency analogue of the
5
+ * `basePath` router honeycomb gets from Hono. It MIRRORS honeycomb's
6
+ * `ROUTE_GROUPS` + `group()` accessor + permission-middleware-inheritance
7
+ * pattern (`honeycomb/src/daemon/runtime/server.ts:68-106`, `:205-328`) across
8
+ * the process boundary (`ADR-0002`, mirror-not-import) rather than importing
9
+ * Hono, honoring nectar's zero-runtime-dependency invariant (`AGENTS.md`).
10
+ *
11
+ * Reconciliation with PRD-002a: PRD-002a originally sketched a Hono daemon
12
+ * bound via `@hono/node-server`; the shipped PRD-002 diverged to a zero-runtime
13
+ * `node:http` server (`src/server.ts`, only `/health`). PRD-008 follows the
14
+ * shipped reality, so the `ROUTE_GROUPS`-equivalent list, the `RouteGroup`
15
+ * handle, and the permission-middleware mount are nectar's own abstraction
16
+ * layered over `node:http`, not a Hono app.
17
+ *
18
+ * The load-bearing property (honeycomb's a-AC-6): a route group's middleware is
19
+ * mounted at bootstrap for the group prefix, and handlers attach LATER against a
20
+ * live route table, so an endpoint filled after boot still runs the
21
+ * already-mounted permission gate without re-wiring auth. An unfilled path under
22
+ * a mounted group falls through to the root 501 scaffold, never a
23
+ * 404-with-no-auth.
24
+ */
25
+ import type { IncomingMessage } from "node:http";
26
+ /** The `/api/hive-graph` group base path (decision #34, mirrors honeycomb's `/api/graph`). */
27
+ export declare const HIVE_GRAPH_GROUP = "/api/hive-graph";
28
+ /**
29
+ * Max POST/PUT/PATCH request body accepted before the dispatcher rejects with
30
+ * `413 payload_too_large`. A sane 1 MiB cap: the search/build/projection bodies
31
+ * are small JSON control payloads; no endpoint here streams bulk data. Bounds
32
+ * memory so a hostile client cannot exhaust the loopback daemon.
33
+ */
34
+ export declare const MAX_REQUEST_BODY_BYTES = 1048576;
35
+ /**
36
+ * A route-group spec, mirroring honeycomb's `RouteGroupSpec`
37
+ * (`honeycomb/src/daemon/runtime/server.ts:57-61`). `protect` mounts the
38
+ * permission gate on the group prefix; `session` would additionally mount the
39
+ * runtime-path middleware ahead of permission (nectar has no session-capture
40
+ * surface today, so every current group is `session: false`).
41
+ */
42
+ export interface RouteGroupSpec {
43
+ readonly path: string;
44
+ readonly protect: boolean;
45
+ readonly session: boolean;
46
+ }
47
+ /**
48
+ * The frozen `ROUTE_GROUPS`-equivalent list (decision #34). `/api/hive-graph`
49
+ * is `protect: true` (session-protected daemon routes) and `session: false`
50
+ * (permission only, like honeycomb's `/api/graph` at
51
+ * `honeycomb/src/daemon/runtime/server.ts:84`; the DEFAULT-flagged session bit
52
+ * is resolved to `false` since these are operator graph endpoints, not
53
+ * memory-capture surfaces). The daemon's own diagnostics endpoints (`/health`,
54
+ * and `/api/status` if PRD-002 ever ships it) are NOT in this list: they are
55
+ * unprotected and owned by the daemon bootstrap, not PRD-008.
56
+ */
57
+ export declare const ROUTE_GROUPS: readonly RouteGroupSpec[];
58
+ /** A fully-serialized HTTP response the dispatcher writes to the socket. */
59
+ export interface RouteResponse {
60
+ readonly status: number;
61
+ readonly body: string;
62
+ readonly contentType: string;
63
+ }
64
+ /**
65
+ * The per-request context handed to a route handler. Carries the request shape
66
+ * (method/path/query/headers/body) AND the response helpers (`json`), mirroring
67
+ * the `c` context honeycomb's handlers receive.
68
+ */
69
+ export interface RouteContext {
70
+ readonly method: string;
71
+ /** The pathname with the query string stripped. */
72
+ readonly path: string;
73
+ readonly rawUrl: string;
74
+ readonly query: URLSearchParams;
75
+ readonly headers: NodeJS.Dict<string | string[]>;
76
+ /**
77
+ * The parsed JSON request body, or `undefined` when the body is empty. Throws
78
+ * a plain `Error` when the body is present but not valid JSON (the handler
79
+ * catches it and surfaces a structured error, never an unhandled throw).
80
+ */
81
+ body(): unknown;
82
+ /** Build a JSON response (default status 200). */
83
+ json(body: unknown, status?: number): RouteResponse;
84
+ }
85
+ /** A route handler attached to a group; may be async. Never expected to throw (the dispatcher guards anyway). */
86
+ export type RouteHandler = (ctx: RouteContext) => RouteResponse | Promise<RouteResponse>;
87
+ /** A permission-gate rejection: the fail-closed 401/403 honeycomb's gate produces. */
88
+ export interface PermissionRejection {
89
+ readonly status: 401 | 403;
90
+ readonly body: unknown;
91
+ }
92
+ /**
93
+ * The permission-gate seam mounted on every `protect: true` group. Returns
94
+ * `null` to allow the request through, or a {@link PermissionRejection} to
95
+ * fail it closed BEFORE the handler runs. This is the seam 008a scaffolds;
96
+ * the RBAC/authenticator policy internals are the mirrored honeycomb pattern
97
+ * and are not designed here. Nectar's loopback daemon defaults to
98
+ * {@link allowAllPermission} (open on `127.0.0.1`); a future RBAC policy
99
+ * attaches here.
100
+ */
101
+ export type PermissionGate = (ctx: RouteContext, spec: RouteGroupSpec) => PermissionRejection | null | Promise<PermissionRejection | null>;
102
+ /** The default gate for nectar's loopback daemon: allow every request through. */
103
+ export declare const allowAllPermission: PermissionGate;
104
+ /**
105
+ * A route-group handle: nectar's zero-dependency analogue of honeycomb's Hono
106
+ * `basePath` router. `.get`/`.post` register a handler at a subpath RELATIVE to
107
+ * the group base (`/search`, not `/api/hive-graph/search`); the group base is
108
+ * prepended when the handler is stored on the shared live route table.
109
+ */
110
+ export interface RouteGroup {
111
+ readonly base: string;
112
+ get(subpath: string, handler: RouteHandler): RouteGroup;
113
+ post(subpath: string, handler: RouteHandler): RouteGroup;
114
+ }
115
+ /** The root 501 scaffold for an unfilled path under a mounted group (mirrors honeycomb's `notFound`). */
116
+ export declare function notImplementedScaffold(path: string): RouteResponse;
117
+ /**
118
+ * The nectar router: holds the frozen group specs, the shared live route table,
119
+ * and the permission gate. Constructed side-effect free at daemon assembly
120
+ * (importing/constructing binds no socket); handlers attach to it via `group()`
121
+ * either before or after the socket binds (the table is consulted per request,
122
+ * so late attachment is picked up — the "keeps the binding live" property).
123
+ */
124
+ export declare class NectarRouter {
125
+ private readonly specs;
126
+ private readonly permission;
127
+ /** `${METHOD} ${fullPath}` -> handler. */
128
+ private readonly routes;
129
+ constructor(specs?: readonly RouteGroupSpec[], permission?: PermissionGate);
130
+ /**
131
+ * Return the {@link RouteGroup} handle for a known group base, or `undefined`
132
+ * for an unknown group path (mirrors honeycomb's accessor contract,
133
+ * `honeycomb/src/daemon/runtime/server.ts:205-214`). Handlers register at
134
+ * paths relative to the group and inherit its already-mounted middleware.
135
+ */
136
+ group(path: string): RouteGroup | undefined;
137
+ /** The group spec whose base the request path sits under (exact base or `${base}/...`), or undefined. */
138
+ matchGroup(path: string): RouteGroupSpec | undefined;
139
+ /**
140
+ * Dispatch a request whose path is under a mounted group. Returns `undefined`
141
+ * when the path is under NO group (the caller then serves its own 404,
142
+ * preserving the shipped daemon's `not_found` for non-group paths). For a
143
+ * matched group: runs the permission gate first (protect groups), then the
144
+ * handler behind it; an unfilled path falls to the 501 scaffold; a handler
145
+ * that throws unexpectedly is caught and surfaced as a 500 data body, never
146
+ * crashing the request pipeline.
147
+ */
148
+ dispatch(ctx: RouteContext): Promise<RouteResponse | undefined>;
149
+ }
150
+ /** Raised by {@link buildRouteContext} when the request body exceeds {@link MAX_REQUEST_BODY_BYTES}. */
151
+ export declare class BodyTooLargeError extends Error {
152
+ constructor();
153
+ }
154
+ /**
155
+ * Raised by {@link RouteContext.body} when the request body is present but not
156
+ * valid JSON (NEC-042 item 1 / AC-018l.8). A distinct type so a handler (or the
157
+ * dispatcher backstop) maps it to a 400 client error rather than the generic 500
158
+ * `handler_error`. Thrown CONSISTENTLY: once the parse fails, every later
159
+ * `body()` call rethrows this same error rather than silently returning
160
+ * `undefined` from a poisoned cache.
161
+ */
162
+ export declare class MalformedJsonError extends Error {
163
+ constructor();
164
+ }
165
+ /**
166
+ * Read a request body up to the cap and build a {@link RouteContext}. Reading
167
+ * the (bounded) body up front keeps the context synchronous for handlers and
168
+ * enforces the size cap before any handler runs. Rejects with
169
+ * {@link BodyTooLargeError} when the body exceeds {@link MAX_REQUEST_BODY_BYTES}.
170
+ */
171
+ export declare function buildRouteContext(req: IncomingMessage, path: string, rawUrl: string): Promise<RouteContext>;
172
+ //# sourceMappingURL=router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/api/router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,8FAA8F;AAC9F,eAAO,MAAM,gBAAgB,oBAAoB,CAAC;AAElD;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,UAAY,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;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
@@ -0,0 +1,212 @@
1
+ /** The `/api/hive-graph` group base path (decision #34, mirrors honeycomb's `/api/graph`). */
2
+ export const HIVE_GRAPH_GROUP = "/api/hive-graph";
3
+ /**
4
+ * Max POST/PUT/PATCH request body accepted before the dispatcher rejects with
5
+ * `413 payload_too_large`. A sane 1 MiB cap: the search/build/projection bodies
6
+ * are small JSON control payloads; no endpoint here streams bulk data. Bounds
7
+ * memory so a hostile client cannot exhaust the loopback daemon.
8
+ */
9
+ export const MAX_REQUEST_BODY_BYTES = 1_048_576;
10
+ /**
11
+ * The frozen `ROUTE_GROUPS`-equivalent list (decision #34). `/api/hive-graph`
12
+ * is `protect: true` (session-protected daemon routes) and `session: false`
13
+ * (permission only, like honeycomb's `/api/graph` at
14
+ * `honeycomb/src/daemon/runtime/server.ts:84`; the DEFAULT-flagged session bit
15
+ * is resolved to `false` since these are operator graph endpoints, not
16
+ * memory-capture surfaces). The daemon's own diagnostics endpoints (`/health`,
17
+ * and `/api/status` if PRD-002 ever ships it) are NOT in this list: they are
18
+ * unprotected and owned by the daemon bootstrap, not PRD-008.
19
+ */
20
+ export const ROUTE_GROUPS = Object.freeze([
21
+ Object.freeze({ path: HIVE_GRAPH_GROUP, protect: true, session: false }),
22
+ ]);
23
+ /** The default gate for nectar's loopback daemon: allow every request through. */
24
+ export const allowAllPermission = () => null;
25
+ function jsonResponse(body, status = 200) {
26
+ return {
27
+ status,
28
+ body: JSON.stringify(body ?? null),
29
+ contentType: "application/json; charset=utf-8",
30
+ };
31
+ }
32
+ /** The root 501 scaffold for an unfilled path under a mounted group (mirrors honeycomb's `notFound`). */
33
+ export function notImplementedScaffold(path) {
34
+ return jsonResponse({ error: "not_implemented", path }, 501);
35
+ }
36
+ function joinBase(base, subpath) {
37
+ const sub = subpath.startsWith("/") ? subpath : `/${subpath}`;
38
+ if (sub === "/")
39
+ return base;
40
+ return `${base}${sub}`;
41
+ }
42
+ /**
43
+ * The nectar router: holds the frozen group specs, the shared live route table,
44
+ * and the permission gate. Constructed side-effect free at daemon assembly
45
+ * (importing/constructing binds no socket); handlers attach to it via `group()`
46
+ * either before or after the socket binds (the table is consulted per request,
47
+ * so late attachment is picked up — the "keeps the binding live" property).
48
+ */
49
+ export class NectarRouter {
50
+ specs;
51
+ permission;
52
+ /** `${METHOD} ${fullPath}` -> handler. */
53
+ routes = new Map();
54
+ constructor(specs = ROUTE_GROUPS, permission = allowAllPermission) {
55
+ this.specs = specs;
56
+ this.permission = permission;
57
+ }
58
+ /**
59
+ * Return the {@link RouteGroup} handle for a known group base, or `undefined`
60
+ * for an unknown group path (mirrors honeycomb's accessor contract,
61
+ * `honeycomb/src/daemon/runtime/server.ts:205-214`). Handlers register at
62
+ * paths relative to the group and inherit its already-mounted middleware.
63
+ */
64
+ group(path) {
65
+ const spec = this.specs.find((s) => s.path === path);
66
+ if (spec === undefined)
67
+ return undefined;
68
+ const register = (method, subpath, handler) => {
69
+ this.routes.set(`${method} ${joinBase(spec.path, subpath)}`, handler);
70
+ };
71
+ const handle = {
72
+ base: spec.path,
73
+ get(subpath, handler) {
74
+ register("GET", subpath, handler);
75
+ return handle;
76
+ },
77
+ post(subpath, handler) {
78
+ register("POST", subpath, handler);
79
+ return handle;
80
+ },
81
+ };
82
+ return handle;
83
+ }
84
+ /** The group spec whose base the request path sits under (exact base or `${base}/...`), or undefined. */
85
+ matchGroup(path) {
86
+ return this.specs.find((s) => path === s.path || path.startsWith(`${s.path}/`));
87
+ }
88
+ /**
89
+ * Dispatch a request whose path is under a mounted group. Returns `undefined`
90
+ * when the path is under NO group (the caller then serves its own 404,
91
+ * preserving the shipped daemon's `not_found` for non-group paths). For a
92
+ * matched group: runs the permission gate first (protect groups), then the
93
+ * handler behind it; an unfilled path falls to the 501 scaffold; a handler
94
+ * that throws unexpectedly is caught and surfaced as a 500 data body, never
95
+ * crashing the request pipeline.
96
+ */
97
+ async dispatch(ctx) {
98
+ const spec = this.matchGroup(ctx.path);
99
+ if (spec === undefined)
100
+ return undefined;
101
+ if (spec.protect) {
102
+ const rejection = await this.permission(ctx, spec);
103
+ if (rejection !== null)
104
+ return jsonResponse(rejection.body, rejection.status);
105
+ }
106
+ const handler = this.routes.get(`${ctx.method} ${ctx.path}`);
107
+ if (handler === undefined)
108
+ return notImplementedScaffold(ctx.path);
109
+ try {
110
+ return await handler(ctx);
111
+ }
112
+ catch (err) {
113
+ // A malformed JSON body is a client error (400), not a server fault (500).
114
+ if (err instanceof MalformedJsonError) {
115
+ return jsonResponse({ error: "invalid_json", reason: err.message }, 400);
116
+ }
117
+ const reason = err instanceof Error ? err.message : String(err);
118
+ return jsonResponse({ error: "handler_error", reason }, 500);
119
+ }
120
+ }
121
+ }
122
+ /** Raised by {@link buildRouteContext} when the request body exceeds {@link MAX_REQUEST_BODY_BYTES}. */
123
+ export class BodyTooLargeError extends Error {
124
+ constructor() {
125
+ super("request body exceeds the maximum allowed size");
126
+ this.name = "BodyTooLargeError";
127
+ }
128
+ }
129
+ /**
130
+ * Raised by {@link RouteContext.body} when the request body is present but not
131
+ * valid JSON (NEC-042 item 1 / AC-018l.8). A distinct type so a handler (or the
132
+ * dispatcher backstop) maps it to a 400 client error rather than the generic 500
133
+ * `handler_error`. Thrown CONSISTENTLY: once the parse fails, every later
134
+ * `body()` call rethrows this same error rather than silently returning
135
+ * `undefined` from a poisoned cache.
136
+ */
137
+ export class MalformedJsonError extends Error {
138
+ constructor() {
139
+ super("request body is not valid JSON");
140
+ this.name = "MalformedJsonError";
141
+ }
142
+ }
143
+ /**
144
+ * Read a request body up to the cap and build a {@link RouteContext}. Reading
145
+ * the (bounded) body up front keeps the context synchronous for handlers and
146
+ * enforces the size cap before any handler runs. Rejects with
147
+ * {@link BodyTooLargeError} when the body exceeds {@link MAX_REQUEST_BODY_BYTES}.
148
+ */
149
+ export function buildRouteContext(req, path, rawUrl) {
150
+ return new Promise((resolve, reject) => {
151
+ const chunks = [];
152
+ let size = 0;
153
+ let aborted = false;
154
+ req.on("data", (chunk) => {
155
+ if (aborted)
156
+ return; // over-cap: drain remaining data, never buffer it
157
+ size += chunk.length;
158
+ if (size > MAX_REQUEST_BODY_BYTES) {
159
+ // Stop buffering and reject, but do NOT destroy the socket: the server
160
+ // still needs to write the 413 response back to the client. Remaining
161
+ // request data is drained (discarded) by the `aborted` guard above.
162
+ aborted = true;
163
+ chunks.length = 0;
164
+ reject(new BodyTooLargeError());
165
+ return;
166
+ }
167
+ chunks.push(chunk);
168
+ });
169
+ req.on("error", (err) => {
170
+ if (!aborted)
171
+ reject(err);
172
+ });
173
+ req.on("end", () => {
174
+ if (aborted)
175
+ return;
176
+ const raw = Buffer.concat(chunks).toString("utf8");
177
+ let parsed;
178
+ let parsedOnce = false;
179
+ // Cache the thrown state too, so a malformed body rethrows CONSISTENTLY
180
+ // instead of poisoning the cache: the pre-fix code set `parsedOnce` BEFORE
181
+ // parsing, so after one throw every later `body()` returned `undefined`
182
+ // silently (NEC-042 item 1 / AC-018l.8).
183
+ let parseError;
184
+ const queryString = rawUrl.includes("?") ? rawUrl.slice(rawUrl.indexOf("?") + 1) : "";
185
+ resolve({
186
+ method: (req.method ?? "GET").toUpperCase(),
187
+ path,
188
+ rawUrl,
189
+ query: new URLSearchParams(queryString),
190
+ headers: req.headers,
191
+ body() {
192
+ if (parseError !== undefined)
193
+ throw parseError;
194
+ if (parsedOnce)
195
+ return parsed;
196
+ const trimmed = raw.trim();
197
+ try {
198
+ parsed = trimmed === "" ? undefined : JSON.parse(trimmed);
199
+ }
200
+ catch {
201
+ parseError = new MalformedJsonError();
202
+ throw parseError;
203
+ }
204
+ parsedOnce = true; // set only AFTER a successful parse
205
+ return parsed;
206
+ },
207
+ json: jsonResponse,
208
+ });
209
+ });
210
+ });
211
+ }
212
+ //# sourceMappingURL=router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/api/router.ts"],"names":[],"mappings":"AA0BA,8FAA8F;AAC9F,MAAM,CAAC,MAAM,gBAAgB,GAAG,iBAAiB,CA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 * Produces the coarse, cheap pipeline status an operator and the dashboard
5
+ * read: queue depth (latest-pending-per-nectar count), the `describe_status`
6
+ * breakdown (one counter per REAL enum value, W-1 closed — all six values kept
7
+ * distinct, never collapsed into a single `skipped` bucket), and the cumulative
8
+ * cost counter. Aggregate counts only, no full scan (mirrors honeycomb's coarse
9
+ * `/health` posture). Fail-soft: a missing table on a fresh workspace degrades
10
+ * to empty counts + `degraded: true`, never a 500 (mirrors the per-arm
11
+ * fail-soft at `honeycomb/src/daemon/runtime/memories/recall.ts:24-35`).
12
+ */
13
+ import { type DescribeStatus } from "../hive-graph/model.js";
14
+ import type { QueryScope, StorageQuery, StorageRow } from "../hive-graph/search-types.js";
15
+ /** The `describe_status` breakdown: one counter per real enum value (all six kept distinct). */
16
+ export type DescribeStatusCounts = Record<DescribeStatus, number>;
17
+ /** The `/api/hive-graph/status` response shape (PRD-008c). */
18
+ export interface HiveGraphStatus {
19
+ readonly queueDepth: number;
20
+ readonly describeStatus: DescribeStatusCounts;
21
+ readonly costSpentUsd: number;
22
+ readonly degraded: boolean;
23
+ }
24
+ /** A zeroed counter for every real `describe_status` value (the honest empty breakdown). */
25
+ export declare function emptyDescribeStatusCounts(): DescribeStatusCounts;
26
+ /** Aggregate count of version rows grouped by `describe_status`, scoped by tenancy. */
27
+ export declare function buildDescribeStatusCountSql(scope: QueryScope): string;
28
+ /**
29
+ * Latest-pending-per-nectar rows, scoped by tenancy. The queue depth is the row
30
+ * count of this result (one row per nectar whose latest version is pending),
31
+ * mirroring the enricher's pending-work query shape
32
+ * (`src/enricher/pending-query.ts` `buildPendingWorkSql`).
33
+ */
34
+ export declare function buildQueueDepthSql(scope: QueryScope): string;
35
+ /** Fold GROUP BY rows into the six-value breakdown; unknown values are ignored (schema is the source of truth). */
36
+ export declare function parseDescribeStatusCounts(rows: readonly StorageRow[]): DescribeStatusCounts;
37
+ export interface ReadHiveGraphStatusOptions {
38
+ /** The cumulative brooding/enricher cost counter (from the daemon's health cost slice). */
39
+ readonly costSpentUsd?: number;
40
+ }
41
+ /**
42
+ * Read the pipeline status over the injected {@link StorageQuery}. Fail-soft:
43
+ * a missing table (fresh workspace) returns the degraded empty status, never
44
+ * throwing (AC-008c.2.2). A non-missing-table storage failure also degrades
45
+ * rather than crashing the status read. `costSpentUsd` is supplied by the
46
+ * daemon's in-memory cost counter (there is no durable cost table to query).
47
+ */
48
+ export declare function readHiveGraphStatusOverStorage(storage: StorageQuery, scope: QueryScope, options?: ReadHiveGraphStatusOptions): Promise<HiveGraphStatus>;
49
+ //# sourceMappingURL=status-query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status-query.d.ts","sourceRoot":"","sources":["../../src/api/status-query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAqB,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAKhF,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAI1F,gGAAgG;AAChG,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAElE,8DAA8D;AAC9D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,cAAc,EAAE,oBAAoB,CAAC;IAC9C,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED,4FAA4F;AAC5F,wBAAgB,yBAAyB,IAAI,oBAAoB,CAIhE;AAUD,uFAAuF;AACvF,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAQrE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAU5D;AAED,mHAAmH;AACnH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,SAAS,UAAU,EAAE,GAAG,oBAAoB,CAW3F;AAOD,MAAM,WAAW,0BAA0B;IACzC,2FAA2F;IAC3F,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;;;;GAMG;AACH,wBAAsB,8BAA8B,CAClD,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,UAAU,EACjB,OAAO,GAAE,0BAA+B,GACvC,OAAO,CAAC,eAAe,CAAC,CAoB1B"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * The `/api/hive-graph/status` read model (PRD-008c).
3
+ *
4
+ * Produces the coarse, cheap pipeline status an operator and the dashboard
5
+ * read: queue depth (latest-pending-per-nectar count), the `describe_status`
6
+ * breakdown (one counter per REAL enum value, W-1 closed — all six values kept
7
+ * distinct, never collapsed into a single `skipped` bucket), and the cumulative
8
+ * cost counter. Aggregate counts only, no full scan (mirrors honeycomb's coarse
9
+ * `/health` posture). Fail-soft: a missing table on a fresh workspace degrades
10
+ * to empty counts + `degraded: true`, never a 500 (mirrors the per-arm
11
+ * fail-soft at `honeycomb/src/daemon/runtime/memories/recall.ts:24-35`).
12
+ */
13
+ import { DESCRIBE_STATUSES } from "../hive-graph/model.js";
14
+ import { HIVE_GRAPH_VERSIONS_TABLE } from "../hive-graph/schema.js";
15
+ import { isMissingTableError } from "../hive-graph/deeplake-heal.js";
16
+ import { TransportError } from "../hive-graph/deeplake-transport.js";
17
+ import { sLiteral, sqlIdent } from "../hive-graph/sql-guards.js";
18
+ const HIVE_GRAPH_VERSIONS = sqlIdent(HIVE_GRAPH_VERSIONS_TABLE.name);
19
+ /** A zeroed counter for every real `describe_status` value (the honest empty breakdown). */
20
+ export function emptyDescribeStatusCounts() {
21
+ const counts = {};
22
+ for (const status of DESCRIBE_STATUSES)
23
+ counts[status] = 0;
24
+ return counts;
25
+ }
26
+ function tenancyPredicate(scope) {
27
+ return (`${sqlIdent("org_id")} = ${sLiteral(scope.orgId)} AND ` +
28
+ `${sqlIdent("workspace_id")} = ${sLiteral(scope.workspaceId)} AND ` +
29
+ `${sqlIdent("project_id")} = ${sLiteral(scope.projectId)}`);
30
+ }
31
+ /** Aggregate count of version rows grouped by `describe_status`, scoped by tenancy. */
32
+ export function buildDescribeStatusCountSql(scope) {
33
+ const statusCol = sqlIdent("describe_status");
34
+ return (`SELECT ${statusCol}, COUNT(*) AS n ` +
35
+ `FROM "${HIVE_GRAPH_VERSIONS}" ` +
36
+ `WHERE ${tenancyPredicate(scope)} ` +
37
+ `GROUP BY ${statusCol}`);
38
+ }
39
+ /**
40
+ * Latest-pending-per-nectar rows, scoped by tenancy. The queue depth is the row
41
+ * count of this result (one row per nectar whose latest version is pending),
42
+ * mirroring the enricher's pending-work query shape
43
+ * (`src/enricher/pending-query.ts` `buildPendingWorkSql`).
44
+ */
45
+ export function buildQueueDepthSql(scope) {
46
+ const nectarCol = sqlIdent("nectar");
47
+ const seqCol = sqlIdent("seq");
48
+ const statusCol = sqlIdent("describe_status");
49
+ return (`SELECT ${nectarCol}, MAX(${seqCol}) AS seq ` +
50
+ `FROM "${HIVE_GRAPH_VERSIONS}" ` +
51
+ `WHERE ${statusCol} = ${sLiteral("pending")} AND ${tenancyPredicate(scope)} ` +
52
+ `GROUP BY ${nectarCol}`);
53
+ }
54
+ /** Fold GROUP BY rows into the six-value breakdown; unknown values are ignored (schema is the source of truth). */
55
+ export function parseDescribeStatusCounts(rows) {
56
+ const counts = emptyDescribeStatusCounts();
57
+ const known = new Set(DESCRIBE_STATUSES);
58
+ for (const row of rows) {
59
+ const status = typeof row["describe_status"] === "string" ? row["describe_status"] : "";
60
+ if (!known.has(status))
61
+ continue;
62
+ const raw = row["n"];
63
+ const n = typeof raw === "number" ? raw : Number(raw);
64
+ if (Number.isFinite(n))
65
+ counts[status] = n;
66
+ }
67
+ return counts;
68
+ }
69
+ function isMissingTable(err) {
70
+ if (err instanceof TransportError && isMissingTableError(err))
71
+ return true;
72
+ return err instanceof Error && /table does not exist|no such table|relation .* does not exist/i.test(err.message);
73
+ }
74
+ /**
75
+ * Read the pipeline status over the injected {@link StorageQuery}. Fail-soft:
76
+ * a missing table (fresh workspace) returns the degraded empty status, never
77
+ * throwing (AC-008c.2.2). A non-missing-table storage failure also degrades
78
+ * rather than crashing the status read. `costSpentUsd` is supplied by the
79
+ * daemon's in-memory cost counter (there is no durable cost table to query).
80
+ */
81
+ export async function readHiveGraphStatusOverStorage(storage, scope, options = {}) {
82
+ const costSpentUsd = options.costSpentUsd ?? 0;
83
+ try {
84
+ const [statusRows, queueRows] = await Promise.all([
85
+ storage.query(buildDescribeStatusCountSql(scope), scope),
86
+ storage.query(buildQueueDepthSql(scope), scope),
87
+ ]);
88
+ return {
89
+ queueDepth: queueRows.length,
90
+ describeStatus: parseDescribeStatusCounts(statusRows),
91
+ costSpentUsd,
92
+ degraded: false,
93
+ };
94
+ }
95
+ catch (err) {
96
+ if (isMissingTable(err)) {
97
+ return { queueDepth: 0, describeStatus: emptyDescribeStatusCounts(), costSpentUsd, degraded: true };
98
+ }
99
+ // Any other storage failure also degrades (coarse status never 500s the daemon).
100
+ return { queueDepth: 0, describeStatus: emptyDescribeStatusCounts(), costSpentUsd, degraded: true };
101
+ }
102
+ }
103
+ //# sourceMappingURL=status-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status-query.js","sourceRoot":"","sources":["../../src/api/status-query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,iBAAiB,EAAuB,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAGjE,MAAM,mBAAmB,GAAG,QAAQ,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC;AAarE,4FAA4F;AAC5F,MAAM,U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2BAA2B,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;YACxD,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;SAChD,CAAC,CAAC;QACH,OAAO;YACL,UAAU,EAAE,SAAS,CAAC,MAAM;YAC5B,cAAc,EAAE,yBAAyB,CAAC,UAAU,CAAC;YACrD,YAAY;YACZ,QAAQ,EAAE,KAAK;SAChB,CAAC;IACJ,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACtB,IAAI,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,cAAc,EAAE,yBAAyB,EAAE,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QACtG,CAAC;QACD,iFAAiF;QACjF,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,cAAc,EAAE,yBAAyB,EAAE,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACtG,CAAC;AACH,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The shared in-process brood guard (PRD-018g / NEC-011 AC-018g.1/.2).
3
+ *
4
+ * ONE guard instance, owned by the daemon composition root, is shared by every
5
+ * path that can start a brood - the boot auto-brood and the API's
6
+ * `POST /api/hive-graph/build` handler - so at most one brood runs per daemon at
7
+ * a time (no concurrent double-brood, no double-mint). The same instance also
8
+ * lets the enricher cycle observe that a brood is active (`active()`) and pause,
9
+ * so it never describes rows the brood is mid-describe on.
10
+ *
11
+ * This lives in its own module (not `daemon.ts`) so both `daemon.ts` and
12
+ * `api/hive-graph-api.ts` can import it without a circular dependency.
13
+ */
14
+ export interface BroodGuard {
15
+ /** Begin a brood if none is in flight. Returns true on acquisition, false if one is already active. */
16
+ tryAcquire(): boolean;
17
+ /** End the in-flight brood, allowing the next acquisition. Idempotent. */
18
+ release(): void;
19
+ /** True while a brood is in flight. */
20
+ active(): boolean;
21
+ }
22
+ /** Build a fresh, unheld {@link BroodGuard}. */
23
+ export declare function createBroodGuard(): BroodGuard;
24
+ //# sourceMappingURL=brood-guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brood-guard.d.ts","sourceRoot":"","sources":["../src/brood-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,UAAU;IACzB,uGAAuG;IACvG,UAAU,IAAI,OAAO,CAAC;IACtB,0EAA0E;IAC1E,OAAO,IAAI,IAAI,CAAC;IAChB,uCAAuC;IACvC,MAAM,IAAI,OAAO,CAAC;CACnB;AAED,gDAAgD;AAChD,wBAAgB,gBAAgB,IAAI,UAAU,CAe7C"}
@@ -0,0 +1,19 @@
1
+ /** Build a fresh, unheld {@link BroodGuard}. */
2
+ export function createBroodGuard() {
3
+ let inFlight = false;
4
+ return {
5
+ tryAcquire() {
6
+ if (inFlight)
7
+ return false;
8
+ inFlight = true;
9
+ return true;
10
+ },
11
+ release() {
12
+ inFlight = false;
13
+ },
14
+ active() {
15
+ return inFlight;
16
+ },
17
+ };
18
+ }
19
+ //# sourceMappingURL=brood-guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brood-guard.js","sourceRoot":"","sources":["../src/brood-guard.ts"],"names":[],"mappings":"AAsBA,gDAAgD;AAChD,MAAM,UAAU,gBAAgB;IAC9B,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,OAAO;QACL,UAAU;YACR,IAAI,QAAQ;gBAAE,OAAO,KAAK,CAAC;YAC3B,QAAQ,GAAG,IAAI,CAAC;YAChB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO;YACL,QAAQ,GAAG,KAAK,CAAC;QACnB,CAAC;QACD,MAAM;YACJ,OAAO,QAAQ,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC"}