@askexenow/exe-os 0.9.127 → 0.9.129

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 (373) hide show
  1. package/dist/active-agent-3FDJYREJ.js +22 -0
  2. package/dist/active-agent-WC7YK3L5.js +23 -0
  3. package/dist/agent-context-CDWUZEXY.js +11 -0
  4. package/dist/agent-loop-G4VUR5ME.js +10 -0
  5. package/dist/agentic-ontology-2VYNTMNO.js +25 -0
  6. package/dist/backfill-metadata-OJWOCLSZ.js +601 -0
  7. package/dist/background-jobs-LGRDXGXC.js +25 -0
  8. package/dist/bash-Y5PEW5UQ.js +8 -0
  9. package/dist/behaviors-CSB2YLDT.js +22 -0
  10. package/dist/bin/age-ontology-load.js +10 -258
  11. package/dist/bin/agentic-ontology-backfill.js +23 -5296
  12. package/dist/bin/agentic-reflection-backfill.js +19 -4739
  13. package/dist/bin/agentic-semantic-label.js +28 -4723
  14. package/dist/bin/backfill-conversations.js +42 -5543
  15. package/dist/bin/backfill-responses.js +41 -5542
  16. package/dist/bin/backfill-vectors.js +43 -4795
  17. package/dist/bin/bulk-sync-postgres.js +22 -5313
  18. package/dist/bin/cc-doctor.js +10 -602
  19. package/dist/bin/cleanup-stale-review-tasks.js +32 -6803
  20. package/dist/bin/cli.js +169 -38993
  21. package/dist/bin/exe-agent-config.js +21 -253
  22. package/dist/bin/exe-agent.js +63 -2429
  23. package/dist/bin/exe-assign.js +34 -5810
  24. package/dist/bin/exe-boot.js +180 -12726
  25. package/dist/bin/exe-call.js +48 -1409
  26. package/dist/bin/exe-cloud.js +64 -8516
  27. package/dist/bin/exe-dispatch.js +35 -10818
  28. package/dist/bin/exe-doctor.js +24 -7537
  29. package/dist/bin/exe-export-behaviors.js +18 -6122
  30. package/dist/bin/exe-forget.js +22 -6274
  31. package/dist/bin/exe-gateway.js +62 -15286
  32. package/dist/bin/exe-healthcheck.js +9 -602
  33. package/dist/bin/exe-heartbeat.js +51 -6898
  34. package/dist/bin/exe-kill.js +30 -5961
  35. package/dist/bin/exe-launch-agent.js +101 -6788
  36. package/dist/bin/exe-new-employee.js +42 -3774
  37. package/dist/bin/exe-pending-messages.js +28 -6833
  38. package/dist/bin/exe-pending-notifications.js +31 -6869
  39. package/dist/bin/exe-pending-reviews.js +38 -6910
  40. package/dist/bin/exe-rename.js +57 -5766
  41. package/dist/bin/exe-review.js +29 -5948
  42. package/dist/bin/exe-search.js +22 -7692
  43. package/dist/bin/exe-session-cleanup.js +52 -11147
  44. package/dist/bin/exe-settings.js +35 -524
  45. package/dist/bin/exe-start-codex.js +70 -6641
  46. package/dist/bin/exe-start-opencode.js +54 -6584
  47. package/dist/bin/exe-status.js +26 -7081
  48. package/dist/bin/exe-support.js +10 -546
  49. package/dist/bin/exe-team.js +18 -5942
  50. package/dist/bin/git-sweep.js +26 -10909
  51. package/dist/bin/graph-backfill.js +24 -5979
  52. package/dist/bin/graph-export.js +31 -6128
  53. package/dist/bin/graph-layer-benchmark.js +4 -8
  54. package/dist/bin/install.js +47 -2322
  55. package/dist/bin/intercom-check.js +25 -11501
  56. package/dist/bin/list-providers.js +4 -18
  57. package/dist/bin/postgres-agentic-reflection-backfill.js +14 -357
  58. package/dist/bin/postgres-agentic-semantic-backfill.js +14 -404
  59. package/dist/bin/pre-publish.js +4 -298
  60. package/dist/bin/registry-proxy.js +8 -172
  61. package/dist/bin/scan-tasks.js +47 -10881
  62. package/dist/bin/setup.js +6 -9492
  63. package/dist/bin/shard-migrate.js +30 -5149
  64. package/dist/bin/stack-update.js +75 -203
  65. package/dist/bin/update.js +20 -654
  66. package/dist/capacity-monitor-3GZIHLB4.js +46 -0
  67. package/dist/catchup-brief-67QDCINS.js +148 -0
  68. package/dist/chunk-2QD7KBJN.js +664 -0
  69. package/dist/chunk-2WGSIVI4.js +149 -0
  70. package/dist/chunk-35TVNLJI.js +57 -0
  71. package/dist/chunk-3SYV36U5.js +47 -0
  72. package/dist/chunk-46SQTBQW.js +207 -0
  73. package/dist/chunk-4CMVLKEI.js +171 -0
  74. package/dist/chunk-4FLUOZTR.js +116 -0
  75. package/dist/chunk-4NYQAS33.js +17 -0
  76. package/dist/chunk-4QNPADWL.js +902 -0
  77. package/dist/chunk-4Y6QZBEO.js +58 -0
  78. package/dist/chunk-557C2IGL.js +0 -0
  79. package/dist/chunk-55S56YDO.js +305 -0
  80. package/dist/chunk-5BS5ELMC.js +85 -0
  81. package/dist/chunk-5DHM77JE.js +256 -0
  82. package/dist/chunk-5QTWQKNF.js +137 -0
  83. package/dist/chunk-6A7P74QV.js +53 -0
  84. package/dist/chunk-6BFIFI5F.js +45 -0
  85. package/dist/chunk-6KFICEAT.js +20 -0
  86. package/dist/chunk-6LKDJ5WX.js +317 -0
  87. package/dist/chunk-6M5II4EV.js +148 -0
  88. package/dist/chunk-6QEFN3DV.js +302 -0
  89. package/dist/chunk-6WTMJAG3.js +171 -0
  90. package/dist/chunk-6Y4B3QF6.js +19 -0
  91. package/dist/chunk-7RK3AYJE.js +163 -0
  92. package/dist/chunk-7TCP2XTP.js +390 -0
  93. package/dist/chunk-A2NZP64U.js +2307 -0
  94. package/dist/chunk-AFYIYM2K.js +322 -0
  95. package/dist/chunk-AJWFPKQS.js +573 -0
  96. package/dist/chunk-AVE2B4DQ.js +140 -0
  97. package/dist/chunk-B4TT2QQA.js +87 -0
  98. package/dist/chunk-BCMOO4OQ.js +1066 -0
  99. package/dist/chunk-BU3ID2WT.js +432 -0
  100. package/dist/chunk-CFIM43JH.js +862 -0
  101. package/dist/chunk-CURJUF3W.js +66 -0
  102. package/dist/chunk-DC4ZD76Y.js +288 -0
  103. package/dist/chunk-DL52JPGF.js +706 -0
  104. package/dist/chunk-DRSC6ZRA.js +36 -0
  105. package/dist/chunk-E2Q4Y22A.js +86 -0
  106. package/dist/chunk-ECGTESAP.js +236 -0
  107. package/dist/chunk-EHOJUXYG.js +365 -0
  108. package/dist/chunk-EIT6J37V.js +119 -0
  109. package/dist/chunk-ELE2C7L4.js +31 -0
  110. package/dist/chunk-EQSQ4HBW.js +9 -0
  111. package/dist/chunk-FWFFZGSC.js +94 -0
  112. package/dist/chunk-GCNWCYJI.js +249 -0
  113. package/dist/chunk-GGTUUI7J.js +6 -0
  114. package/dist/chunk-GU56L7OY.js +223 -0
  115. package/dist/chunk-HF25XPZE.js +83 -0
  116. package/dist/chunk-HOKOOBDL.js +52 -0
  117. package/dist/chunk-HP43GLZ6.js +89 -0
  118. package/dist/chunk-HSRM6PNM.js +682 -0
  119. package/dist/chunk-HVRTW3OP.js +164 -0
  120. package/dist/chunk-IHDHL5ML.js +125 -0
  121. package/dist/chunk-IHF5RXJM.js +168 -0
  122. package/dist/chunk-IJ73YE73.js +409 -0
  123. package/dist/chunk-INO4ZD5Y.js +162 -0
  124. package/dist/chunk-IRQTM7DY.js +475 -0
  125. package/dist/chunk-JD4FAPYG.js +1208 -0
  126. package/dist/chunk-JN44LQ53.js +316 -0
  127. package/dist/chunk-JQ6TLNIV.js +133 -0
  128. package/dist/chunk-JT76KRZQ.js +35 -0
  129. package/dist/chunk-K6OEWZTB.js +262 -0
  130. package/dist/chunk-KCUYRZSX.js +72 -0
  131. package/dist/chunk-KFQGP6VL.js +33 -0
  132. package/dist/chunk-KRLOFIPI.js +83 -0
  133. package/dist/chunk-KVPG5UT6.js +305 -0
  134. package/dist/chunk-L3TB7CC3.js +170 -0
  135. package/dist/chunk-L4X5EUHR.js +283 -0
  136. package/dist/chunk-LAN26C3W.js +655 -0
  137. package/dist/chunk-LPGBKR4H.js +54 -0
  138. package/dist/chunk-LVNMOVGD.js +132 -0
  139. package/dist/chunk-LX5WEEZ7.js +157 -0
  140. package/dist/chunk-MBH42QNH.js +295 -0
  141. package/dist/chunk-MFO7MNSD.js +102 -0
  142. package/dist/chunk-MILTNDZH.js +736 -0
  143. package/dist/chunk-MJAE4NB7.js +1090 -0
  144. package/dist/chunk-MLCUPTP7.js +132 -0
  145. package/dist/chunk-MPURH6JI.js +445 -0
  146. package/dist/chunk-MVBWW2EO.js +89 -0
  147. package/dist/chunk-MZIGUUDQ.js +42 -0
  148. package/dist/chunk-N3DTSVKE.js +157 -0
  149. package/dist/chunk-N5RRQOAC.js +134 -0
  150. package/dist/chunk-N7L33TED.js +1664 -0
  151. package/dist/chunk-NDYSNVI5.js +122 -0
  152. package/dist/chunk-NEAHEC5G.js +155 -0
  153. package/dist/chunk-NGVOA6ZQ.js +84 -0
  154. package/dist/chunk-NHK5KW6Y.js +193 -0
  155. package/dist/chunk-NMQKGFEP.js +458 -0
  156. package/dist/chunk-NPT4EHZK.js +352 -0
  157. package/dist/chunk-NXFJHTED.js +55 -0
  158. package/dist/chunk-NZLCDI6Y.js +216 -0
  159. package/dist/chunk-O377P7GM.js +100 -0
  160. package/dist/chunk-O4VFZRA5.js +33 -0
  161. package/dist/chunk-O7YD7JYE.js +237 -0
  162. package/dist/chunk-OFK72LTZ.js +81 -0
  163. package/dist/chunk-ORCCI2VV.js +140 -0
  164. package/dist/chunk-OVQR4KMC.js +579 -0
  165. package/dist/chunk-P3CVUMEH.js +54 -0
  166. package/dist/chunk-P4HIF72O.js +30 -0
  167. package/dist/chunk-PEDLSJBL.js +1039 -0
  168. package/dist/chunk-PFICKZZ5.js +219 -0
  169. package/dist/chunk-PGW7TIV6.js +142 -0
  170. package/dist/chunk-PJHHFJAN.js +63 -0
  171. package/dist/chunk-PP4SNOJ5.js +471 -0
  172. package/dist/chunk-PRKVT4KN.js +90 -0
  173. package/dist/chunk-Q2O4VJHH.js +305 -0
  174. package/dist/chunk-Q36CMZIX.js +38 -0
  175. package/dist/chunk-Q3V7K4ME.js +149 -0
  176. package/dist/chunk-QGYPJGHB.js +81 -0
  177. package/dist/chunk-R23EMFJV.js +198 -0
  178. package/dist/chunk-R4M6XCMU.js +39 -0
  179. package/dist/chunk-R4WMF32C.js +81 -0
  180. package/dist/chunk-RJT7H2KR.js +349 -0
  181. package/dist/chunk-RJZMRZNV.js +280 -0
  182. package/dist/chunk-RMFDPCA2.js +72 -0
  183. package/dist/chunk-RUG3N6P4.js +292 -0
  184. package/dist/chunk-RWO327FJ.js +84 -0
  185. package/dist/chunk-SG7EFHQ7.js +108 -0
  186. package/dist/chunk-SH45SJQW.js +0 -0
  187. package/dist/chunk-SPKE5ANC.js +42 -0
  188. package/dist/chunk-SVMFVPBF.js +104 -0
  189. package/dist/chunk-SVXDCELZ.js +163 -0
  190. package/dist/chunk-TMEE7AT7.js +72 -0
  191. package/dist/chunk-TWYEE4FB.js +125 -0
  192. package/dist/chunk-TYLF4LSW.js +110 -0
  193. package/dist/chunk-V4TZI6EO.js +60 -0
  194. package/dist/chunk-VFZTXKQI.js +372 -0
  195. package/dist/chunk-VQ4K2MLM.js +199 -0
  196. package/dist/chunk-VU447UAO.js +173 -0
  197. package/dist/chunk-WMC3TXJF.js +50 -0
  198. package/dist/chunk-WPOA7XAE.js +84 -0
  199. package/dist/chunk-WZQ4CPRG.js +64 -0
  200. package/dist/chunk-X2IMCCM5.js +49 -0
  201. package/dist/chunk-X2Z5GT3V.js +118 -0
  202. package/dist/chunk-XEKO37NM.js +43 -0
  203. package/dist/chunk-XUHFQHGZ.js +505 -0
  204. package/dist/chunk-YGAAZN3E.js +47 -0
  205. package/dist/chunk-YKOW7KMK.js +558 -0
  206. package/dist/chunk-YOQKMB6N.js +145 -0
  207. package/dist/chunk-YZFZDJWZ.js +107 -0
  208. package/dist/chunk-ZBY4AUD4.js +10342 -0
  209. package/dist/chunk-ZOJYPNCM.js +127 -0
  210. package/dist/chunk-ZS7MGQSD.js +1494 -0
  211. package/dist/chunk-ZTZQ5A6B.js +191 -0
  212. package/dist/code-context-index-HXGC4IJL.js +28 -0
  213. package/dist/content-extractor-UVZXRIPC.js +8 -0
  214. package/dist/conversation-entity-extractor-HKSNDF4L.js +113 -0
  215. package/dist/conversation-wiki-populator-NKDAQEZ5.js +105 -0
  216. package/dist/crdt-sync-T7MHVQCS.js +33 -0
  217. package/dist/crm-bridge-Q5JBVJ6P.js +19 -0
  218. package/dist/crm-webhook-OAFTLJYA.js +10 -0
  219. package/dist/cto-delegation-gate-XWHZCUJH.js +208 -0
  220. package/dist/daemon-auth-GWUXTUYO.js +15 -0
  221. package/dist/daemon-orchestration-2C3TVOHO.js +91 -0
  222. package/dist/daemon-protocol-RLH2XM2K.js +19 -0
  223. package/dist/db-backup-CH2KG3JY.js +23 -0
  224. package/dist/devtools-PLJCAU53.js +8 -0
  225. package/dist/discord-G4BQJ2VX.js +7 -0
  226. package/dist/email-XMRNMFXR.js +137 -0
  227. package/dist/entity-boost-IOER4VRR.js +249 -0
  228. package/dist/exe-drift-2IJFQV43.js +68 -0
  229. package/dist/exe-export-Y2RFXGNB.js +71 -0
  230. package/dist/exe-import-LN6PE2YT.js +74 -0
  231. package/dist/exe-key-DHKBWLIT.js +571 -0
  232. package/dist/exe-org-F7LZRHFB.js +73 -0
  233. package/dist/factory-YTD23AW7.js +67 -0
  234. package/dist/fast-db-init-IIP6EGWT.js +7 -0
  235. package/dist/file-edit-FJVEO7XZ.js +8 -0
  236. package/dist/file-read-Q2NH3J35.js +8 -0
  237. package/dist/file-write-UNSFXNH4.js +8 -0
  238. package/dist/gateway/index.js +87 -16563
  239. package/dist/gateway-client-APTYJNCL.js +11 -0
  240. package/dist/git-staleness-I2BUEDE2.js +111 -0
  241. package/dist/git-task-sweep-UEOTXRW4.js +35 -0
  242. package/dist/glob-GRMXLDMB.js +7 -0
  243. package/dist/global-procedures-MFE5LGRF.js +19 -0
  244. package/dist/graph-query-657O5JYJ.js +25 -0
  245. package/dist/graph-rag-ZE5N7C65.js +28 -0
  246. package/dist/grep-NBV6SKYZ.js +7 -0
  247. package/dist/hooks/bug-report-worker.js +41 -10823
  248. package/dist/hooks/codex-stop-task-finalizer.js +38 -9055
  249. package/dist/hooks/commit-complete.js +32 -10914
  250. package/dist/hooks/error-recall.js +35 -7955
  251. package/dist/hooks/exe-heartbeat-hook.js +17 -327
  252. package/dist/hooks/ingest-worker.js +16 -565
  253. package/dist/hooks/ingest.js +98 -11436
  254. package/dist/hooks/instructions-loaded.js +25 -6209
  255. package/dist/hooks/notification.js +16 -6098
  256. package/dist/hooks/post-compact.js +34 -7041
  257. package/dist/hooks/post-tool-combined.js +27 -9751
  258. package/dist/hooks/pre-compact.js +38 -11130
  259. package/dist/hooks/pre-tool-use.js +61 -7233
  260. package/dist/hooks/prompt-submit.js +113 -13358
  261. package/dist/hooks/session-end.js +57 -11503
  262. package/dist/hooks/session-start.js +46 -9423
  263. package/dist/hooks/stop.js +70 -7210
  264. package/dist/hooks/subagent-stop.js +33 -6897
  265. package/dist/hooks/summary-worker.js +86 -8629
  266. package/dist/hooks-KD3N2D7P.js +9 -0
  267. package/dist/imessage-L7WKA2WD.js +7 -0
  268. package/dist/index.js +49 -19391
  269. package/dist/installer-5N24GXFB.js +32 -0
  270. package/dist/installer-QSD76YRY.js +291 -0
  271. package/dist/installer-ZPQUKHU5.js +331 -0
  272. package/dist/intercom-queue-PEEGAJ33.js +19 -0
  273. package/dist/key-backup-status-57UB74DU.js +41 -0
  274. package/dist/lib/agent-config.js +19 -224
  275. package/dist/lib/cloud-sync.js +44 -5398
  276. package/dist/lib/cloudflare-dns.js +7 -111
  277. package/dist/lib/config.js +18 -278
  278. package/dist/lib/consolidation.js +21 -1047
  279. package/dist/lib/crypto.js +7 -45
  280. package/dist/lib/database.js +20 -2932
  281. package/dist/lib/db-daemon-client.js +24 -460
  282. package/dist/lib/db.js +22 -2932
  283. package/dist/lib/device-registry.js +20 -2992
  284. package/dist/lib/embedder.js +14 -822
  285. package/dist/lib/employee-templates.js +21 -1102
  286. package/dist/lib/employees.js +30 -497
  287. package/dist/lib/error-detector.js +9 -149
  288. package/dist/lib/exe-daemon-client.js +16 -570
  289. package/dist/lib/exe-daemon.js +509 -18398
  290. package/dist/lib/file-grep.js +2 -0
  291. package/dist/lib/hybrid-search.js +18 -7674
  292. package/dist/lib/identity-templates.js +2 -0
  293. package/dist/lib/identity.js +13 -309
  294. package/dist/lib/keychain.js +9 -499
  295. package/dist/lib/license.js +21 -549
  296. package/dist/lib/messaging.js +35 -1631
  297. package/dist/lib/post-tool-memory.js +8 -370
  298. package/dist/lib/registry-proxy.js +8 -155
  299. package/dist/lib/reminders.js +11 -231
  300. package/dist/lib/runtime-table.js +7 -20
  301. package/dist/lib/schedules.js +16 -4614
  302. package/dist/lib/session-registry.js +9 -57
  303. package/dist/lib/session-wrappers.js +3 -127
  304. package/dist/lib/skill-learning.js +20 -2101
  305. package/dist/lib/status-brief.js +4 -368
  306. package/dist/lib/store.js +25 -5593
  307. package/dist/lib/task-router.js +12 -254
  308. package/dist/lib/tasks.js +44 -5801
  309. package/dist/lib/tmux-routing.js +45 -5804
  310. package/dist/lib/tmux-status.js +16 -248
  311. package/dist/lib/tmux-transport.js +6 -90
  312. package/dist/lib/token-spend.js +9 -337
  313. package/dist/lib/transport.js +8 -134
  314. package/dist/lib/ws-auth.js +6 -14
  315. package/dist/lib/ws-client.js +4 -22
  316. package/dist/license-gate-NXXDOOAQ.js +14 -0
  317. package/dist/mcp/register-tools.js +90 -32454
  318. package/dist/mcp/server.js +139 -32625
  319. package/dist/mcp/tools/complete-reminder.js +10 -237
  320. package/dist/mcp/tools/create-reminder.js +10 -222
  321. package/dist/mcp/tools/create-task.js +28 -6730
  322. package/dist/mcp/tools/deactivate-behavior.js +13 -476
  323. package/dist/mcp/tools/list-reminders.js +10 -232
  324. package/dist/mcp/tools/list-tasks.js +28 -1571
  325. package/dist/mcp/tools/send-message.js +25 -1672
  326. package/dist/mcp/tools/update-task.js +27 -6123
  327. package/dist/mcp-diagnostics-OOZ3TDPY.js +200 -0
  328. package/dist/memory-cards-RIL5BZHK.js +175 -0
  329. package/dist/memory-queue-JYIJ7TMQ.js +13 -0
  330. package/dist/memory-queue-client-PE7757HU.js +14 -0
  331. package/dist/notifications-CJFULBMN.js +42 -0
  332. package/dist/orchestration-phase-Y2TYNW5H.js +23 -0
  333. package/dist/orchestrator-RXIPT6PZ.js +29 -0
  334. package/dist/permission-presets-WI524OSE.js +25 -0
  335. package/dist/permissions-TYT6YMNZ.js +14 -0
  336. package/dist/pg-ssl-KFHNJPGO.js +7 -0
  337. package/dist/plan-limits-5WY5YK6X.js +27 -0
  338. package/dist/preferences-MW3BYTQ5.js +10 -0
  339. package/dist/project-name-PL2ZDWNU.js +11 -0
  340. package/dist/projection-worker-OY4WYZW6.js +661 -0
  341. package/dist/reranker-LFJ73RRS.js +19 -0
  342. package/dist/review-gate-E6K7QQE5.js +120 -0
  343. package/dist/runtime/index.js +82 -13408
  344. package/dist/self-query-router-IZANO632.js +83 -0
  345. package/dist/session-events-TQ6S5KQN.js +32 -0
  346. package/dist/session-kill-telemetry-46YIJWE2.js +30 -0
  347. package/dist/session-scope-3MYK3YRV.js +34 -0
  348. package/dist/setup-wizard-ZJ7UCRBP.js +12 -0
  349. package/dist/shard-manager-RCFZ6RXY.js +29 -0
  350. package/dist/signal-XN2C7PIG.js +7 -0
  351. package/dist/slack-Z77TFJCK.js +7 -0
  352. package/dist/task-enforcement-337DZI3I.js +252 -0
  353. package/dist/task-scanner-IMIR3T7T.js +11 -0
  354. package/dist/task-scope-MUU4KXE6.js +32 -0
  355. package/dist/tasks-crud-PMLK3MM4.js +53 -0
  356. package/dist/tasks-review-56LVKKNL.js +44 -0
  357. package/dist/telegram-CRPZO7JT.js +7 -0
  358. package/dist/telemetry-SPVGPKU7.js +9 -0
  359. package/dist/tool-capability-index-XNBSDCH3.js +10 -0
  360. package/dist/tool-gates-LGH6CSY4.js +14 -0
  361. package/dist/tool-gates-W7SZCYTX.js +13 -0
  362. package/dist/tool-registry-436LVVLY.js +11 -0
  363. package/dist/tool-telemetry-L77WNAYT.js +15 -0
  364. package/dist/tui/App.js +253 -14668
  365. package/dist/tui-data-SB45REYU.js +161 -0
  366. package/dist/update-check-LZGZISRJ.js +11 -0
  367. package/dist/webhook-VVP7KQVC.js +96 -0
  368. package/dist/whatsapp-J6QNDBGY.js +9 -0
  369. package/dist/whatsapp-accounts-RTJF3LM6.js +15 -0
  370. package/dist/wiki-client-EKCIKCVC.js +136 -0
  371. package/dist/worker-gate-UYNN62GJ.js +19 -0
  372. package/dist/worktree-4T4BPWPN.js +205 -0
  373. package/package.json +1 -1
@@ -0,0 +1,601 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ disposeStore,
4
+ initStore
5
+ } from "./chunk-HSRM6PNM.js";
6
+ import "./chunk-NHK5KW6Y.js";
7
+ import "./chunk-WZQ4CPRG.js";
8
+ import {
9
+ getClient,
10
+ init_database
11
+ } from "./chunk-A2NZP64U.js";
12
+ import "./chunk-4NYQAS33.js";
13
+ import {
14
+ getEmployeeNamesByRole,
15
+ init_employees,
16
+ loadEmployeesSync
17
+ } from "./chunk-RUG3N6P4.js";
18
+ import "./chunk-XUHFQHGZ.js";
19
+ import "./chunk-KVPG5UT6.js";
20
+ import "./chunk-X2IMCCM5.js";
21
+ import {
22
+ isMainModule
23
+ } from "./chunk-6Y4B3QF6.js";
24
+ import "./chunk-KFQGP6VL.js";
25
+
26
+ // src/bin/backfill-metadata.ts
27
+ init_database();
28
+ init_employees();
29
+ var VALID_INTENTS = /* @__PURE__ */ new Set(["decision", "question", "correction", "report", "discovery", "implementation"]);
30
+ var VALID_OUTCOMES = /* @__PURE__ */ new Set(["success", "failure", "partial", "superseded"]);
31
+ var VALID_DOMAINS = /* @__PURE__ */ new Set(["code", "architecture", "marketing", "operations", "customer", "research"]);
32
+ var VALID_AUDIENCES = /* @__PURE__ */ new Set(["founder", "team", "self"]);
33
+ var VALID_LANGUAGE_TYPES = /* @__PURE__ */ new Set(["code", "prose", "mixed", "json", "sql"]);
34
+ var MAX_TEXT_LENGTH = 2e3;
35
+ var BATCH_SLEEP_MS = 1e3;
36
+ function roleAgentMarkers(role) {
37
+ try {
38
+ const employees = loadEmployeesSync();
39
+ const names = getEmployeeNamesByRole(employees, role).map((n) => n.toLowerCase().trim()).filter(Boolean);
40
+ if (names.length > 0) return names;
41
+ } catch {
42
+ }
43
+ return [];
44
+ }
45
+ var MARKETING_AGENT_MARKERS = roleAgentMarkers("CMO");
46
+ var RESEARCH_AGENT_MARKERS = roleAgentMarkers("AI Product Lead");
47
+ function mentionsAgentMarker(text, markers) {
48
+ return markers.some(
49
+ (marker) => text.includes(`/${marker}/`) || text.includes(`agent_id: ${marker}`)
50
+ );
51
+ }
52
+ function classifyMemoryHeuristic(rawText, toolName) {
53
+ const t = rawText.toLowerCase();
54
+ let intent;
55
+ if (toolName === "store_decision" || t.includes("decided") || t.includes("decision:")) {
56
+ intent = "decision";
57
+ } else if (toolName === "store_memory" || toolName === "commit_to_long_term_memory" || toolName === "update_task" || toolName === "store_behavior" || t.startsWith("stored memory") || t.startsWith("task updated") || t.startsWith("auto-summary")) {
58
+ intent = "report";
59
+ } else if (t.includes("fix ") || t.includes("fixed") || t.includes("correction") || t.includes("bug") || t.includes("revert") || t.includes("hotfix")) {
60
+ intent = "correction";
61
+ } else if (toolName === "Edit" || toolName === "Write" || toolName === "NotebookEdit" || toolName === "Bash" && (t.includes("npm run build") || t.includes("git commit") || t.includes("npm install") || t.includes("npx "))) {
62
+ intent = "implementation";
63
+ } else if (toolName === "Read" || toolName === "Grep" || toolName === "Glob" || toolName === "Agent" || t.includes("?") || t.includes("search")) {
64
+ intent = "question";
65
+ } else if (t.includes("found") || t.includes("discovered") || t.includes("noticed") || t.includes("interesting") || t.includes("realized")) {
66
+ intent = "discovery";
67
+ } else if (toolName === "Bash") {
68
+ intent = "implementation";
69
+ } else {
70
+ intent = "report";
71
+ }
72
+ let outcome;
73
+ if (t.includes("error") || t.includes("failed") || t.includes("failure") || t.includes("exit code 1") || t.includes("exception") || t.includes("crash") || t.includes("rejected") || t.includes("\u274C")) {
74
+ outcome = "failure";
75
+ } else if (t.includes("success") || t.includes("passed") || t.includes("\u2713") || t.includes("complete") || t.includes("done") || t.includes("shipped") || t.includes("merged") || t.includes("build success")) {
76
+ outcome = "success";
77
+ } else if (t.includes("superseded") || t.includes("deprecated") || t.includes("replaced by") || t.includes("archived")) {
78
+ outcome = "superseded";
79
+ } else {
80
+ outcome = "partial";
81
+ }
82
+ let domain;
83
+ if (t.includes("marketing") || t.includes("campaign") || t.includes("brand") || t.includes("carousel") || t.includes("seo") || t.includes("content strategy") || mentionsAgentMarker(t, MARKETING_AGENT_MARKERS)) {
84
+ domain = "marketing";
85
+ } else if (t.includes("architecture") || t.includes("adr") || t.includes("design doc") || t.includes("system design") || t.includes("ARCHITECTURE.md") || t.includes("schema") && t.includes("migration")) {
86
+ domain = "architecture";
87
+ } else if (t.includes("customer") || t.includes("onboarding") || t.includes("install") || t.includes("setup wizard") || t.includes("license") || t.includes("stripe") || t.includes("user feedback")) {
88
+ domain = "customer";
89
+ } else if (t.includes("deploy") || t.includes("ci/cd") || t.includes("docker") || t.includes("nginx") || t.includes("cron") || t.includes("schedule") || t.includes("task management") || t.includes("roster") || toolName === "update_task" || toolName === "create_task") {
90
+ domain = "operations";
91
+ } else if (t.includes("research") || t.includes("competitor") || t.includes("benchmark") || t.includes("comparison") || t.includes("analysis") || t.includes("evaluate") || mentionsAgentMarker(t, RESEARCH_AGENT_MARKERS)) {
92
+ domain = "research";
93
+ } else {
94
+ domain = "code";
95
+ }
96
+ let audience;
97
+ if (toolName === "send_message" || toolName === "ask_team_memory" || toolName === "create_task" || toolName === "update_task" || t.includes("dispatched") || t.includes("assigned to")) {
98
+ audience = "team";
99
+ } else if (toolName === "store_memory" || toolName === "commit_to_long_term_memory" || toolName === "store_decision" || toolName === "store_behavior" || t.includes("summary") || t.includes("report") || t.includes("audit") || t.startsWith("stored memory")) {
100
+ audience = "founder";
101
+ } else {
102
+ audience = "self";
103
+ }
104
+ let languageType;
105
+ const jsonIndicators = (t.match(/[{}[\]]/g) || []).length;
106
+ const codeIndicators = (t.match(/\b(function|const|let|var|import|export|return|if|else|class|async|await)\b/g) || []).length;
107
+ const sqlIndicators = (t.match(/\b(SELECT|INSERT|UPDATE|DELETE|CREATE|ALTER|FROM|WHERE|JOIN)\b/gi) || []).length;
108
+ if (sqlIndicators >= 2) {
109
+ languageType = "sql";
110
+ } else if (jsonIndicators > 6 && jsonIndicators > codeIndicators) {
111
+ languageType = "json";
112
+ } else if (codeIndicators >= 3) {
113
+ languageType = codeIndicators > 5 ? "code" : "mixed";
114
+ } else if (jsonIndicators > 3) {
115
+ languageType = "mixed";
116
+ } else {
117
+ languageType = "prose";
118
+ }
119
+ return { intent, outcome, domain, audience, language_type: languageType };
120
+ }
121
+ async function classifyMemory(_anthropic, rawText) {
122
+ const truncated = rawText.length > MAX_TEXT_LENGTH ? rawText.slice(0, MAX_TEXT_LENGTH) : rawText;
123
+ const baseUrl = process.env.ANTHROPIC_BASE_URL ?? "https://api.anthropic.com";
124
+ const apiKey = process.env.ANTHROPIC_API_KEY ?? "";
125
+ const model = process.env.BACKFILL_MODEL ?? "claude-haiku-4-5-20251001";
126
+ try {
127
+ const res = await fetch(`${baseUrl}/v1/messages`, {
128
+ method: "POST",
129
+ headers: {
130
+ "x-api-key": apiKey,
131
+ "anthropic-version": "2023-06-01",
132
+ "content-type": "application/json"
133
+ },
134
+ body: JSON.stringify({
135
+ model,
136
+ max_tokens: 100,
137
+ system: "You are a JSON classifier. Output ONLY valid JSON. No explanation, no markdown, no text before or after the JSON object.",
138
+ messages: [
139
+ {
140
+ role: "user",
141
+ content: `{"task":"classify","categories":{"intent":["decision","question","correction","report","discovery","implementation"],"outcome":["success","failure","partial","superseded"],"domain":["code","architecture","marketing","operations","customer","research"],"audience":["founder","team","self"],"language_type":["code","prose","mixed","json","sql"]},"text":"${truncated.replace(/"/g, '\\"').replace(/\n/g, " ").slice(0, 500)}"}`
142
+ },
143
+ {
144
+ role: "assistant",
145
+ content: "{"
146
+ }
147
+ ]
148
+ })
149
+ });
150
+ if (!res.ok) {
151
+ const errText = await res.text();
152
+ throw new Error(`${res.status} ${errText.slice(0, 200)}`);
153
+ }
154
+ const data = await res.json();
155
+ const textBlock = data.content.find((b) => b.type === "text");
156
+ if (!textBlock?.text) return null;
157
+ const jsonText = "{" + textBlock.text.trim();
158
+ const parsed = JSON.parse(jsonText);
159
+ if (!VALID_INTENTS.has(parsed.intent)) return null;
160
+ if (!VALID_OUTCOMES.has(parsed.outcome)) return null;
161
+ if (!VALID_DOMAINS.has(parsed.domain)) return null;
162
+ if (!VALID_AUDIENCES.has(parsed.audience)) return null;
163
+ if (!VALID_LANGUAGE_TYPES.has(parsed.language_type)) return null;
164
+ return parsed;
165
+ } catch (err) {
166
+ process.stderr.write(
167
+ `[backfill-metadata] LLM error: ${err instanceof Error ? err.message : String(err)}
168
+ `
169
+ );
170
+ return null;
171
+ }
172
+ }
173
+ async function backfillHeuristic(options) {
174
+ const client = getClient();
175
+ const countResult = await client.execute({
176
+ sql: "SELECT COUNT(*) as cnt FROM memories WHERE intent IS NULL AND outcome IS NULL AND domain IS NULL",
177
+ args: []
178
+ });
179
+ const totalUnclassified = Number(countResult.rows[0]?.cnt ?? 0);
180
+ if (totalUnclassified === 0) {
181
+ process.stderr.write("[backfill-metadata] All memories already classified.\n");
182
+ return { classified: 0, skipped: 0, remaining: 0 };
183
+ }
184
+ const toProcess = options.limit > 0 ? Math.min(options.limit, totalUnclassified) : totalUnclassified;
185
+ process.stderr.write(`[backfill-metadata] ${totalUnclassified} unclassified. Heuristic-classifying ${toProcess}.
186
+ `);
187
+ if (options.dryRun) {
188
+ process.stderr.write("[backfill-metadata] Dry run \u2014 would classify " + toProcess + " memories.\n");
189
+ return { classified: 0, skipped: 0, remaining: totalUnclassified };
190
+ }
191
+ let classified = 0;
192
+ let skipped = 0;
193
+ while (classified + skipped < toProcess) {
194
+ const batch = await client.execute({
195
+ sql: `SELECT id, raw_text, tool_name FROM memories
196
+ WHERE intent IS NULL AND outcome IS NULL AND domain IS NULL
197
+ ORDER BY rowid LIMIT ?`,
198
+ args: [options.batchSize]
199
+ });
200
+ if (batch.rows.length === 0) break;
201
+ for (const row of batch.rows) {
202
+ const rawText = row.raw_text;
203
+ const toolName = row.tool_name;
204
+ if (!rawText || rawText.length < 10) {
205
+ await client.execute({
206
+ sql: "UPDATE memories SET intent = 'report', outcome = 'partial', domain = 'code', audience = 'self', language_type = 'prose' WHERE id = ?",
207
+ args: [row.id]
208
+ });
209
+ skipped++;
210
+ continue;
211
+ }
212
+ const result = classifyMemoryHeuristic(rawText, toolName);
213
+ await client.execute({
214
+ sql: "UPDATE memories SET intent = ?, outcome = ?, domain = ?, audience = ?, language_type = ? WHERE id = ?",
215
+ args: [result.intent, result.outcome, result.domain, result.audience, result.language_type, row.id]
216
+ });
217
+ classified++;
218
+ }
219
+ if (classified % 5e3 < options.batchSize) {
220
+ process.stderr.write(`[backfill-metadata] Heuristic progress: ${classified} classified, ${skipped} skipped
221
+ `);
222
+ }
223
+ }
224
+ const remainResult = await client.execute({
225
+ sql: "SELECT COUNT(*) as cnt FROM memories WHERE intent IS NULL AND outcome IS NULL AND domain IS NULL",
226
+ args: []
227
+ });
228
+ const remaining = Number(remainResult.rows[0]?.cnt ?? 0);
229
+ process.stderr.write(
230
+ `[backfill-metadata] Heuristic complete. Classified: ${classified}, Skipped: ${skipped}, Remaining: ${remaining}
231
+ `
232
+ );
233
+ return { classified, skipped, remaining };
234
+ }
235
+ async function backfillClassifications(options) {
236
+ const Anthropic = (await import("@anthropic-ai/sdk")).default;
237
+ const client = getClient();
238
+ const anthropic = new Anthropic();
239
+ let classified = 0;
240
+ let skipped = 0;
241
+ let failed = 0;
242
+ let offset = 0;
243
+ const countResult = await client.execute({
244
+ sql: "SELECT COUNT(*) as cnt FROM memories WHERE intent IS NULL AND outcome IS NULL AND domain IS NULL",
245
+ args: []
246
+ });
247
+ const totalUnclassified = Number(countResult.rows[0]?.cnt ?? 0);
248
+ if (totalUnclassified === 0) {
249
+ process.stderr.write("[backfill-metadata] All memories already classified.\n");
250
+ return { classified: 0, skipped: 0, failed: 0, remaining: 0 };
251
+ }
252
+ const toProcess = options.limit > 0 ? Math.min(options.limit, totalUnclassified) : totalUnclassified;
253
+ process.stderr.write(`[backfill-metadata] ${totalUnclassified} unclassified memories. Processing ${toProcess}.
254
+ `);
255
+ if (options.dryRun) {
256
+ const sample = await client.execute({
257
+ sql: "SELECT id, SUBSTR(raw_text, 1, 80) as preview FROM memories WHERE intent IS NULL AND outcome IS NULL AND domain IS NULL ORDER BY timestamp DESC LIMIT 10",
258
+ args: []
259
+ });
260
+ process.stderr.write("[backfill-metadata] Dry run \u2014 sample of unclassified memories:\n");
261
+ for (const row of sample.rows) {
262
+ process.stderr.write(` ${row.id} \u2014 ${row.preview}...
263
+ `);
264
+ }
265
+ return { classified: 0, skipped: 0, failed: 0, remaining: totalUnclassified };
266
+ }
267
+ while (classified + skipped + failed < toProcess) {
268
+ const batch = await client.execute({
269
+ sql: "SELECT id, raw_text FROM memories WHERE intent IS NULL AND outcome IS NULL AND domain IS NULL ORDER BY timestamp DESC LIMIT ?",
270
+ args: [options.batchSize]
271
+ });
272
+ if (batch.rows.length === 0) break;
273
+ for (const row of batch.rows) {
274
+ const id = row.id;
275
+ const rawText = row.raw_text;
276
+ if (!rawText || rawText.length < 10) {
277
+ skipped++;
278
+ continue;
279
+ }
280
+ const result = await classifyMemory(anthropic, rawText);
281
+ if (!result) {
282
+ failed++;
283
+ process.stderr.write(`[backfill-metadata] Failed to classify ${id}
284
+ `);
285
+ await client.execute({
286
+ sql: "UPDATE memories SET intent = 'unknown' WHERE id = ?",
287
+ args: [id]
288
+ });
289
+ continue;
290
+ }
291
+ await client.execute({
292
+ sql: "UPDATE memories SET intent = ?, outcome = ?, domain = ?, audience = ?, language_type = ? WHERE id = ?",
293
+ args: [result.intent, result.outcome, result.domain, result.audience, result.language_type, id]
294
+ });
295
+ classified++;
296
+ }
297
+ const total = classified + skipped + failed;
298
+ if (total % 100 < options.batchSize) {
299
+ process.stderr.write(`[backfill-metadata] Progress: ${classified} classified, ${failed} failed, ${skipped} skipped (${total}/${toProcess})
300
+ `);
301
+ }
302
+ offset += batch.rows.length;
303
+ if (classified + skipped + failed < toProcess) {
304
+ await new Promise((resolve) => setTimeout(resolve, BATCH_SLEEP_MS));
305
+ }
306
+ }
307
+ const remainResult = await client.execute({
308
+ sql: "SELECT COUNT(*) as cnt FROM memories WHERE intent IS NULL AND outcome IS NULL AND domain IS NULL",
309
+ args: []
310
+ });
311
+ const remaining = Number(remainResult.rows[0]?.cnt ?? 0);
312
+ process.stderr.write(
313
+ `[backfill-metadata] Classification complete. Classified: ${classified}, Failed: ${failed}, Skipped: ${skipped}, Remaining: ${remaining}
314
+ `
315
+ );
316
+ return { classified, skipped, failed, remaining };
317
+ }
318
+ async function backfillEntities(options) {
319
+ const client = getClient();
320
+ let populated = 0;
321
+ const countResult = await client.execute({
322
+ sql: "SELECT COUNT(*) as cnt FROM memories WHERE referenced_entities IS NULL",
323
+ args: []
324
+ });
325
+ const totalNull = Number(countResult.rows[0]?.cnt ?? 0);
326
+ if (totalNull === 0) {
327
+ process.stderr.write("[backfill-metadata] All memories already have referenced_entities.\n");
328
+ return 0;
329
+ }
330
+ const toProcess = options.limit > 0 ? Math.min(options.limit, totalNull) : totalNull;
331
+ process.stderr.write(`[backfill-metadata] ${totalNull} memories without referenced_entities. Processing ${toProcess}.
332
+ `);
333
+ if (options.dryRun) {
334
+ process.stderr.write("[backfill-metadata] Dry run \u2014 would populate referenced_entities for up to " + toProcess + " memories.\n");
335
+ return 0;
336
+ }
337
+ const entityRows = await client.execute({
338
+ sql: "SELECT DISTINCT name FROM entities",
339
+ args: []
340
+ });
341
+ const knownEntities = new Set(entityRows.rows.map((r) => r.name));
342
+ let processed = 0;
343
+ while (processed < toProcess) {
344
+ const batch = await client.execute({
345
+ sql: `SELECT m.id, m.raw_text, GROUP_CONCAT(e.name) as entities
346
+ FROM memories m
347
+ LEFT JOIN entity_memories em ON em.memory_id = m.id
348
+ LEFT JOIN entities e ON e.id = em.entity_id
349
+ WHERE m.referenced_entities IS NULL
350
+ GROUP BY m.id
351
+ LIMIT ?`,
352
+ args: [options.batchSize]
353
+ });
354
+ if (batch.rows.length === 0) break;
355
+ for (const row of batch.rows) {
356
+ const id = row.id;
357
+ const rawText = row.raw_text;
358
+ const graphEntities = row.entities;
359
+ let entityList;
360
+ if (graphEntities) {
361
+ entityList = graphEntities.split(",").filter(Boolean);
362
+ } else {
363
+ entityList = extractEntitiesHeuristic(rawText, knownEntities);
364
+ }
365
+ const jsonArray = JSON.stringify(entityList);
366
+ await client.execute({
367
+ sql: "UPDATE memories SET referenced_entities = ? WHERE id = ?",
368
+ args: [jsonArray, id]
369
+ });
370
+ populated++;
371
+ }
372
+ processed += batch.rows.length;
373
+ if (processed % 100 < options.batchSize) {
374
+ process.stderr.write(`[backfill-metadata] Entity progress: ${populated} populated (${processed}/${toProcess})
375
+ `);
376
+ }
377
+ }
378
+ process.stderr.write(`[backfill-metadata] Entity extraction complete. Populated: ${populated}
379
+ `);
380
+ return populated;
381
+ }
382
+ function extractEntitiesHeuristic(rawText, knownEntities) {
383
+ const entities = /* @__PURE__ */ new Set();
384
+ for (const name of knownEntities) {
385
+ if (name.length >= 3 && rawText.toLowerCase().includes(name.toLowerCase())) {
386
+ entities.add(name);
387
+ }
388
+ }
389
+ const filePathPattern = /(?:\/[\w.-]+){2,}/g;
390
+ const paths = rawText.match(filePathPattern);
391
+ if (paths) {
392
+ for (const p of paths.slice(0, 5)) {
393
+ entities.add(p);
394
+ }
395
+ }
396
+ const toolPattern = /\b(Read|Write|Edit|Bash|Grep|Glob|Agent|mcp__\w+)\b/g;
397
+ const tools = rawText.match(toolPattern);
398
+ if (tools) {
399
+ for (const t of new Set(tools)) {
400
+ entities.add(t);
401
+ }
402
+ }
403
+ return [...entities];
404
+ }
405
+ async function showStats() {
406
+ const client = getClient();
407
+ const fields = ["intent", "outcome", "domain", "audience", "language_type"];
408
+ const totalResult = await client.execute({ sql: "SELECT COUNT(*) as cnt FROM memories", args: [] });
409
+ const total = Number(totalResult.rows[0]?.cnt ?? 0);
410
+ const unclassResult = await client.execute({
411
+ sql: "SELECT COUNT(*) as cnt FROM memories WHERE intent IS NULL",
412
+ args: []
413
+ });
414
+ const unclassified = Number(unclassResult.rows[0]?.cnt ?? 0);
415
+ process.stdout.write(`Total memories: ${total}
416
+ Classified: ${total - unclassified}
417
+ Unclassified: ${unclassified}
418
+
419
+ `);
420
+ for (const field of fields) {
421
+ const dist = await client.execute({
422
+ sql: `SELECT ${field} as val, COUNT(*) as cnt FROM memories WHERE ${field} IS NOT NULL GROUP BY ${field} ORDER BY cnt DESC`,
423
+ args: []
424
+ });
425
+ process.stdout.write(`${field}:
426
+ `);
427
+ for (const row of dist.rows) {
428
+ const pct = (Number(row.cnt) / (total - unclassified) * 100).toFixed(1);
429
+ process.stdout.write(` ${String(row.val).padEnd(20)} ${String(row.cnt).padStart(7)} (${pct}%)
430
+ `);
431
+ }
432
+ process.stdout.write("\n");
433
+ }
434
+ }
435
+ async function exportBatches(options) {
436
+ const fs = await import("fs");
437
+ const path = await import("path");
438
+ const client = getClient();
439
+ const outDir = path.join(process.cwd(), "exe/output/classifications/input");
440
+ fs.mkdirSync(outDir, { recursive: true });
441
+ const countResult = await client.execute({
442
+ sql: "SELECT COUNT(*) as cnt FROM memories WHERE intent IS NULL AND outcome IS NULL AND domain IS NULL",
443
+ args: []
444
+ });
445
+ const total = Number(countResult.rows[0]?.cnt ?? 0);
446
+ process.stderr.write(`[backfill-metadata] ${total} unclassified memories to export.
447
+ `);
448
+ if (total === 0) return 0;
449
+ const toProcess = options.limit > 0 ? Math.min(options.limit, total) : total;
450
+ let offset = 0;
451
+ let batchNum = 1;
452
+ let exported = 0;
453
+ while (offset < toProcess) {
454
+ const batch = await client.execute({
455
+ sql: "SELECT id, SUBSTR(raw_text, 1, 500) as text FROM memories WHERE intent IS NULL AND outcome IS NULL AND domain IS NULL ORDER BY rowid LIMIT ? OFFSET ?",
456
+ args: [options.batchSize, offset]
457
+ });
458
+ if (batch.rows.length === 0) break;
459
+ const lines = batch.rows.map((row) => {
460
+ const text = String(row.text || "").replace(/\n/g, " ");
461
+ return JSON.stringify({ id: row.id, text });
462
+ });
463
+ const batchFile = path.join(outDir, `batch-${String(batchNum).padStart(4, "0")}.jsonl`);
464
+ fs.writeFileSync(batchFile, lines.join("\n") + "\n");
465
+ exported += batch.rows.length;
466
+ offset += options.batchSize;
467
+ batchNum++;
468
+ if ((batchNum - 1) % 50 === 0) {
469
+ process.stderr.write(`[backfill-metadata] Exported ${exported}/${toProcess}
470
+ `);
471
+ }
472
+ }
473
+ process.stderr.write(`[backfill-metadata] Export complete: ${batchNum - 1} batch files, ${exported} memories.
474
+ `);
475
+ return exported;
476
+ }
477
+ async function importClassifications(importDir) {
478
+ const fs = await import("fs");
479
+ const path = await import("path");
480
+ const client = getClient();
481
+ const files = fs.readdirSync(importDir).filter((f) => f.endsWith(".jsonl")).sort();
482
+ process.stderr.write(`[backfill-metadata] Found ${files.length} JSONL files to import from ${importDir}
483
+ `);
484
+ let imported = 0;
485
+ let invalid = 0;
486
+ for (const file of files) {
487
+ const lines = fs.readFileSync(path.join(importDir, file), "utf-8").split("\n").filter(Boolean);
488
+ for (const line of lines) {
489
+ try {
490
+ const rec = JSON.parse(line);
491
+ if (!rec.id || !VALID_INTENTS.has(rec.intent) || !VALID_OUTCOMES.has(rec.outcome) || !VALID_DOMAINS.has(rec.domain) || !VALID_AUDIENCES.has(rec.audience) || !VALID_LANGUAGE_TYPES.has(rec.language_type)) {
492
+ invalid++;
493
+ continue;
494
+ }
495
+ await client.execute({
496
+ sql: "UPDATE memories SET intent = ?, outcome = ?, domain = ?, audience = ?, language_type = ? WHERE id = ?",
497
+ args: [rec.intent, rec.outcome, rec.domain, rec.audience, rec.language_type, rec.id]
498
+ });
499
+ imported++;
500
+ } catch {
501
+ invalid++;
502
+ }
503
+ }
504
+ if (imported % 1e3 < 200) {
505
+ process.stderr.write(`[backfill-metadata] Imported ${imported} (${invalid} invalid)
506
+ `);
507
+ }
508
+ }
509
+ process.stderr.write(`[backfill-metadata] Import complete: ${imported} updated, ${invalid} invalid.
510
+ `);
511
+ return { imported, invalid };
512
+ }
513
+ function parseArgs(argv) {
514
+ let batchSize = 50;
515
+ let limit = 0;
516
+ let dryRun = false;
517
+ let entities = false;
518
+ let exportBatchesFlag = false;
519
+ let importDir = "";
520
+ let heuristic = false;
521
+ let stats = false;
522
+ for (let i = 0; i < argv.length; i++) {
523
+ const arg = argv[i];
524
+ if (arg.startsWith("--batch-size=")) {
525
+ batchSize = parseInt(arg.split("=")[1], 10) || 50;
526
+ } else if (arg === "--batch-size" && argv[i + 1]) {
527
+ batchSize = parseInt(argv[++i], 10) || 50;
528
+ } else if (arg.startsWith("--limit=")) {
529
+ limit = parseInt(arg.split("=")[1], 10) || 0;
530
+ } else if (arg === "--limit" && argv[i + 1]) {
531
+ limit = parseInt(argv[++i], 10) || 0;
532
+ } else if (arg === "--dry-run") {
533
+ dryRun = true;
534
+ } else if (arg === "--entities") {
535
+ entities = true;
536
+ } else if (arg === "--heuristic") {
537
+ heuristic = true;
538
+ } else if (arg === "--stats") {
539
+ stats = true;
540
+ } else if (arg === "--export") {
541
+ exportBatchesFlag = true;
542
+ } else if (arg.startsWith("--import=")) {
543
+ importDir = arg.split("=")[1];
544
+ } else if (arg === "--import" && argv[i + 1]) {
545
+ importDir = argv[++i];
546
+ }
547
+ }
548
+ return { batchSize, limit, dryRun, entities, exportBatches: exportBatchesFlag, importDir, heuristic, stats };
549
+ }
550
+ async function backfillMetadata(options) {
551
+ await initStore();
552
+ let classified = 0;
553
+ let skipped = 0;
554
+ let failed = 0;
555
+ let remaining = 0;
556
+ let entitiesPopulated = 0;
557
+ if (options.stats) {
558
+ await showStats();
559
+ await disposeStore();
560
+ return { classified: 0, skipped: 0, failed: 0, entitiesPopulated: 0, remaining: 0 };
561
+ }
562
+ if (options.exportBatches) {
563
+ const exported = await exportBatches(options);
564
+ await disposeStore();
565
+ return { classified: 0, skipped: 0, failed: 0, entitiesPopulated: 0, remaining: exported };
566
+ }
567
+ if (options.importDir) {
568
+ const { imported, invalid } = await importClassifications(options.importDir);
569
+ await disposeStore();
570
+ return { classified: imported, skipped: 0, failed: invalid, entitiesPopulated: 0, remaining: 0 };
571
+ }
572
+ if (options.heuristic) {
573
+ const result = await backfillHeuristic(options);
574
+ await disposeStore();
575
+ return { classified: result.classified, skipped: result.skipped, failed: 0, entitiesPopulated: 0, remaining: result.remaining };
576
+ }
577
+ if (options.entities) {
578
+ entitiesPopulated = await backfillEntities(options);
579
+ } else {
580
+ const result = await backfillClassifications(options);
581
+ classified = result.classified;
582
+ skipped = result.skipped;
583
+ failed = result.failed;
584
+ remaining = result.remaining;
585
+ }
586
+ await disposeStore();
587
+ return { classified, skipped, failed, entitiesPopulated, remaining };
588
+ }
589
+ if (isMainModule(import.meta.url)) {
590
+ const options = parseArgs(process.argv.slice(2));
591
+ backfillMetadata(options).then((result) => {
592
+ console.log(JSON.stringify(result, null, 2));
593
+ process.exit(result.failed > 0 ? 1 : 0);
594
+ }).catch((err) => {
595
+ console.error("[backfill-metadata] Fatal:", err instanceof Error ? err.message : String(err));
596
+ process.exit(1);
597
+ });
598
+ }
599
+ export {
600
+ backfillMetadata
601
+ };
@@ -0,0 +1,25 @@
1
+ import {
2
+ acquireJobLock,
3
+ cancelBackgroundJob,
4
+ enforceBackgroundJobGuardrails,
5
+ formatJobs,
6
+ listBackgroundJobs,
7
+ politeBatchPause,
8
+ releaseJobLock,
9
+ reniceCurrentProcess,
10
+ startManagedJob
11
+ } from "./chunk-MBH42QNH.js";
12
+ import "./chunk-KVPG5UT6.js";
13
+ import "./chunk-X2IMCCM5.js";
14
+ import "./chunk-KFQGP6VL.js";
15
+ export {
16
+ acquireJobLock,
17
+ cancelBackgroundJob,
18
+ enforceBackgroundJobGuardrails,
19
+ formatJobs,
20
+ listBackgroundJobs,
21
+ politeBatchPause,
22
+ releaseJobLock,
23
+ reniceCurrentProcess,
24
+ startManagedJob
25
+ };
@@ -0,0 +1,8 @@
1
+ import {
2
+ BashTool
3
+ } from "./chunk-5BS5ELMC.js";
4
+ import "./chunk-AVE2B4DQ.js";
5
+ import "./chunk-KFQGP6VL.js";
6
+ export {
7
+ BashTool
8
+ };
@@ -0,0 +1,22 @@
1
+ import {
2
+ deactivateBehavior,
3
+ init_behaviors,
4
+ listBehaviors,
5
+ listBehaviorsByDomain,
6
+ listBehaviorsSince,
7
+ storeBehavior
8
+ } from "./chunk-IHF5RXJM.js";
9
+ import "./chunk-A2NZP64U.js";
10
+ import "./chunk-4NYQAS33.js";
11
+ import "./chunk-RUG3N6P4.js";
12
+ import "./chunk-KVPG5UT6.js";
13
+ import "./chunk-X2IMCCM5.js";
14
+ import "./chunk-KFQGP6VL.js";
15
+ init_behaviors();
16
+ export {
17
+ deactivateBehavior,
18
+ listBehaviors,
19
+ listBehaviorsByDomain,
20
+ listBehaviorsSince,
21
+ storeBehavior
22
+ };