@remnic/core 10.0.194 → 10.0.196

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 (323) hide show
  1. package/dist/access-admin-ops-surface.js +65 -66
  2. package/dist/access-cli.js +65 -66
  3. package/dist/access-cli.js.map +1 -1
  4. package/dist/access-coding-context-resolution.js +2 -2
  5. package/dist/access-extraction-force-flush-preempt.js +65 -66
  6. package/dist/access-extraction-force-flush.js +65 -66
  7. package/dist/access-http-briefing.js +65 -66
  8. package/dist/access-http-query.js +65 -66
  9. package/dist/access-http.js +65 -66
  10. package/dist/access-identity-continuity-surface.js +65 -66
  11. package/dist/access-lcm-surface.js +65 -66
  12. package/dist/access-mcp.d.ts.map +1 -1
  13. package/dist/access-mcp.js +65 -66
  14. package/dist/access-observe-write-category.js +2 -2
  15. package/dist/access-observe-write-surface.js +65 -66
  16. package/dist/access-operations-batch.js +65 -66
  17. package/dist/access-operations.js +65 -66
  18. package/dist/access-recall-concurrency.d.ts +4 -0
  19. package/dist/access-recall-concurrency.d.ts.map +1 -1
  20. package/dist/access-recall-concurrency.js +65 -66
  21. package/dist/access-recall-diagnostics.js +2 -2
  22. package/dist/access-recall-response.d.ts.map +1 -1
  23. package/dist/access-recall-response.js +65 -66
  24. package/dist/access-recall-surface.d.ts.map +1 -1
  25. package/dist/access-recall-surface.js +65 -66
  26. package/dist/access-schema.d.ts +1 -0
  27. package/dist/access-schema.d.ts.map +1 -1
  28. package/dist/access-schema.js +1 -1
  29. package/dist/access-service.d.ts.map +1 -1
  30. package/dist/access-service.js +65 -66
  31. package/dist/active-recall.js +7 -6
  32. package/dist/active-recall.js.map +1 -1
  33. package/dist/{auto-sync-BJUAGKI5.js → auto-sync-BEW65FDT.js} +6 -5
  34. package/dist/{auto-sync-BJUAGKI5.js.map → auto-sync-BEW65FDT.js.map} +1 -1
  35. package/dist/briefing.js +7 -6
  36. package/dist/buffer.d.ts +1 -0
  37. package/dist/buffer.d.ts.map +1 -1
  38. package/dist/buffer.js +3 -3
  39. package/dist/calibration.js +5 -4
  40. package/dist/calibration.js.map +1 -1
  41. package/dist/causal-consolidation.js +8 -7
  42. package/dist/causal-consolidation.js.map +1 -1
  43. package/dist/{chunk-FZU62GIV.js → chunk-2X5I5C3M.js} +27 -10
  44. package/dist/chunk-2X5I5C3M.js.map +1 -0
  45. package/dist/{chunk-F2MVWUNF.js → chunk-374E2HYZ.js} +10 -2
  46. package/dist/chunk-374E2HYZ.js.map +1 -0
  47. package/dist/{chunk-3ZS3NUEI.js → chunk-3DSLTUK6.js} +2 -2
  48. package/dist/{chunk-DYUPSTCV.js → chunk-3EXG2KPK.js} +3 -3
  49. package/dist/{chunk-FGFU6J26.js → chunk-4FTYKZ77.js} +3 -3
  50. package/dist/{chunk-QIPRDRGM.js → chunk-4HEJDVPU.js} +1 -1
  51. package/dist/chunk-4HEJDVPU.js.map +1 -0
  52. package/dist/{chunk-EEA2RM4B.js → chunk-4I6A3SDL.js} +2 -2
  53. package/dist/{chunk-SKJM4PKE.js → chunk-4JI5PPFW.js} +2 -2
  54. package/dist/{chunk-TDG5NZAZ.js → chunk-65JA7LWV.js} +2 -2
  55. package/dist/{chunk-3YID7KZ6.js → chunk-6QMKUWXH.js} +2 -2
  56. package/dist/{chunk-7SOKOEAZ.js → chunk-6RRHTHKQ.js} +2 -2
  57. package/dist/{chunk-VHQNJW4Q.js → chunk-6W62D4MC.js} +2 -2
  58. package/dist/{chunk-CRS2NY44.js → chunk-7O6H7BPW.js} +2 -2
  59. package/dist/{chunk-VSLV3EEP.js → chunk-7TK5Q6LQ.js} +112 -81
  60. package/dist/chunk-7TK5Q6LQ.js.map +1 -0
  61. package/dist/{chunk-NN3LMWKA.js → chunk-7TQ3EDQ3.js} +1 -1
  62. package/dist/chunk-7TQ3EDQ3.js.map +1 -0
  63. package/dist/{chunk-KJ65WZHB.js → chunk-A7DIZOTF.js} +2 -2
  64. package/dist/{chunk-TZ7ZA2LM.js → chunk-AD3JOG2Q.js} +2 -2
  65. package/dist/{chunk-2QW5HPKU.js → chunk-AUDLHIHI.js} +35 -28
  66. package/dist/chunk-AUDLHIHI.js.map +1 -0
  67. package/dist/{chunk-BDFSVUUZ.js → chunk-C3H2QZOZ.js} +2 -1
  68. package/dist/chunk-C3H2QZOZ.js.map +1 -0
  69. package/dist/{chunk-7EP4FURO.js → chunk-C72YQM7E.js} +2 -2
  70. package/dist/{chunk-4EAVEDLG.js → chunk-CRKT2JXN.js} +9 -9
  71. package/dist/{chunk-CJSTQNE5.js → chunk-CTOMDCCA.js} +2 -2
  72. package/dist/{chunk-PSQ347YP.js → chunk-DSKII2W4.js} +3 -3
  73. package/dist/{chunk-KOVQZJ27.js → chunk-E7LDTUWK.js} +2 -2
  74. package/dist/{chunk-SPAKBUJY.js → chunk-EWLMEYLF.js} +2 -2
  75. package/dist/{chunk-JJ42IDJU.js → chunk-FEGQI5KR.js} +2 -2
  76. package/dist/{chunk-3BICT225.js → chunk-FGNBUUPX.js} +2 -2
  77. package/dist/{chunk-QZMGZBTF.js → chunk-HBG6CQEX.js} +2 -2
  78. package/dist/{chunk-7V6GNQC2.js → chunk-HINQENZG.js} +2 -2
  79. package/dist/{chunk-WRVKI6ZO.js → chunk-HLQXSX4F.js} +2 -2
  80. package/dist/{chunk-KQIOW3TG.js → chunk-HUDE2SQA.js} +2 -2
  81. package/dist/{chunk-T765HQ5U.js → chunk-IIDAN7XJ.js} +2 -2
  82. package/dist/{chunk-M7Q7Z6V5.js → chunk-JDZ5JPYG.js} +38 -8
  83. package/dist/chunk-JDZ5JPYG.js.map +1 -0
  84. package/dist/{chunk-VMNX2UV7.js → chunk-JRUOIEFL.js} +5 -5
  85. package/dist/{chunk-JKMIGCK6.js → chunk-KDGEEZOI.js} +3 -2
  86. package/dist/chunk-KDGEEZOI.js.map +1 -0
  87. package/dist/{chunk-MMRTPH3J.js → chunk-KQYGUFMQ.js} +5 -3
  88. package/dist/chunk-KQYGUFMQ.js.map +1 -0
  89. package/dist/{chunk-TWYYUMYO.js → chunk-KXAGZRJV.js} +2 -2
  90. package/dist/{chunk-JITK24KX.js → chunk-LJNCJK7B.js} +10 -10
  91. package/dist/{chunk-Z6EFSXU3.js → chunk-LMM2LRVQ.js} +2 -2
  92. package/dist/{chunk-V65H7MI6.js → chunk-M42UFQZY.js} +51 -4
  93. package/dist/chunk-M42UFQZY.js.map +1 -0
  94. package/dist/{chunk-KZ4BJRGQ.js → chunk-ODGVLSCQ.js} +2 -2
  95. package/dist/{chunk-AALJHIKH.js → chunk-OHJ5PNYB.js} +3 -3
  96. package/dist/{chunk-XZMQLON4.js → chunk-OK726OF4.js} +7 -5
  97. package/dist/chunk-OK726OF4.js.map +1 -0
  98. package/dist/{chunk-Q6S67LHR.js → chunk-OOMFFMX3.js} +2 -2
  99. package/dist/{chunk-YCJJODER.js → chunk-PNDTRIOI.js} +10 -3
  100. package/dist/chunk-PNDTRIOI.js.map +1 -0
  101. package/dist/{chunk-3RZ4GDOH.js → chunk-PX4AMRAN.js} +93 -23
  102. package/dist/chunk-PX4AMRAN.js.map +1 -0
  103. package/dist/{chunk-JNDMIAJ4.js → chunk-QEVZKJM6.js} +2 -2
  104. package/dist/{chunk-ZNCCX7P6.js → chunk-QO5QZR2U.js} +2 -2
  105. package/dist/{chunk-NFQKIZK3.js → chunk-QXEF66SC.js} +2 -2
  106. package/dist/{chunk-NKHRIDYP.js → chunk-RTXW6E6X.js} +3 -3
  107. package/dist/{chunk-5WDUY2ZZ.js → chunk-S4QWAWR6.js} +4 -4
  108. package/dist/{chunk-HEJFE3BC.js → chunk-SJCN7ESG.js} +2 -2
  109. package/dist/{chunk-AJ7JHHRY.js → chunk-SPPWVMP4.js} +2 -2
  110. package/dist/{chunk-QSF5SJAM.js → chunk-STQNKDKZ.js} +9 -3
  111. package/dist/chunk-STQNKDKZ.js.map +1 -0
  112. package/dist/{chunk-QFKNIKUF.js → chunk-SXR7L57Z.js} +2 -2
  113. package/dist/{chunk-GYCUX3N4.js → chunk-TGMIJABS.js} +2 -2
  114. package/dist/{chunk-GH7IKABD.js → chunk-UFJJMQDV.js} +2 -2
  115. package/dist/{chunk-FKHXXL42.js → chunk-VAE6QCZQ.js} +2 -2
  116. package/dist/{chunk-UH2VY2QQ.js → chunk-WCW7I7ZM.js} +2 -2
  117. package/dist/{chunk-5GIYIYJI.js → chunk-WLP3XJCO.js} +2 -2
  118. package/dist/{chunk-STSORBX5.js → chunk-XII23FXP.js} +1 -1
  119. package/dist/chunk-XII23FXP.js.map +1 -0
  120. package/dist/{chunk-LR6LWX33.js → chunk-XXDIPAUE.js} +2 -2
  121. package/dist/{chunk-G2MS56KM.js → chunk-YQUGYQRY.js} +2 -2
  122. package/dist/{chunk-WEI6HEUX.js → chunk-YXAH5TSN.js} +2 -2
  123. package/dist/{chunk-75K6DRPN.js → chunk-ZAVFAGBE.js} +2 -2
  124. package/dist/{chunk-7KTORRIK.js → chunk-ZNJU3NBJ.js} +2 -2
  125. package/dist/cli.js +65 -66
  126. package/dist/coding/export-okf-codegraph.js +9 -8
  127. package/dist/coding/export-okf-codegraph.js.map +1 -1
  128. package/dist/compounding/engine.js +8 -7
  129. package/dist/config.d.ts.map +1 -1
  130. package/dist/config.js +7 -6
  131. package/dist/connectors/codex-materialize-runner.js +7 -6
  132. package/dist/connectors/index.js +7 -6
  133. package/dist/convergence-refresh.js +9 -8
  134. package/dist/corpus-watermark.js +9 -8
  135. package/dist/deep-recall-http-glue.js +2 -2
  136. package/dist/deep-recall-policy-llm.js +4 -3
  137. package/dist/entity-retrieval.js +7 -6
  138. package/dist/eval-trajectory-store.js +2 -2
  139. package/dist/eval-trajectory.js +2 -2
  140. package/dist/evals.d.ts.map +1 -1
  141. package/dist/evals.js +1 -1
  142. package/dist/explicit-capture.js +65 -66
  143. package/dist/extraction-error-classification.d.ts +40 -5
  144. package/dist/extraction-error-classification.d.ts.map +1 -1
  145. package/dist/extraction-error-classification.js +5 -2
  146. package/dist/extraction-faithfulness.js +4 -3
  147. package/dist/extraction-judge.js +4 -3
  148. package/dist/extraction.d.ts.map +1 -1
  149. package/dist/extraction.js +17 -18
  150. package/dist/fallback-llm-codex-subscription.d.ts +3 -1
  151. package/dist/fallback-llm-codex-subscription.d.ts.map +1 -1
  152. package/dist/fallback-llm-codex-subscription.js +2 -1
  153. package/dist/fallback-llm.d.ts.map +1 -1
  154. package/dist/fallback-llm.js +3 -2
  155. package/dist/harmonic-retrieval.js +7 -6
  156. package/dist/index.js +65 -66
  157. package/dist/live-connectors-runner.js +1 -2
  158. package/dist/local-llm-helpers.d.ts +1 -0
  159. package/dist/local-llm-helpers.d.ts.map +1 -1
  160. package/dist/local-llm-helpers.js +1 -1
  161. package/dist/local-llm.d.ts.map +1 -1
  162. package/dist/local-llm.js +4 -3
  163. package/dist/location/index.js +8 -7
  164. package/dist/maintenance/memory-governance.js +7 -6
  165. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +7 -6
  166. package/dist/maintenance/rebuild-memory-projection-runner.js +9 -8
  167. package/dist/maintenance/rebuild-memory-projection.js +8 -7
  168. package/dist/memory-browse.js +3 -3
  169. package/dist/namespaces/migrate.js +8 -7
  170. package/dist/namespaces/storage.js +7 -6
  171. package/dist/operator-doctor-corpus.js +10 -9
  172. package/dist/operator-toolkit.js +15 -14
  173. package/dist/orchestration/backlog-scheduler.js +66 -67
  174. package/dist/orchestration/backlog-scheduler.js.map +1 -1
  175. package/dist/orchestration/buffer-drain-runner.js +66 -67
  176. package/dist/orchestration/extraction-drain.d.ts +1 -0
  177. package/dist/orchestration/extraction-drain.d.ts.map +1 -1
  178. package/dist/orchestration/extraction-run-helpers.d.ts +41 -4
  179. package/dist/orchestration/extraction-run-helpers.d.ts.map +1 -1
  180. package/dist/orchestration/extraction-run.d.ts +4 -0
  181. package/dist/orchestration/extraction-run.d.ts.map +1 -1
  182. package/dist/orchestration/maintenance.js +17 -16
  183. package/dist/orchestration/orchestrator-helpers.d.ts +2 -0
  184. package/dist/orchestration/orchestrator-helpers.d.ts.map +1 -1
  185. package/dist/orchestration/recall-entry.d.ts +2 -2
  186. package/dist/orchestration/recall-entry.d.ts.map +1 -1
  187. package/dist/orchestration/recall-internal.d.ts.map +1 -1
  188. package/dist/orchestrator.d.ts.map +1 -1
  189. package/dist/orchestrator.js +65 -66
  190. package/dist/recall-explain-renderer.js +3 -3
  191. package/dist/recall-navigate-access.js +2 -2
  192. package/dist/recall-navigate-disclosure.js +2 -2
  193. package/dist/recall-navigate.js +2 -2
  194. package/dist/recall-navigation.js +65 -66
  195. package/dist/recall-planner-llm.js +3 -2
  196. package/dist/recall-planner-llm.js.map +1 -1
  197. package/dist/recall-state-view-admission.js +3 -3
  198. package/dist/recall-why-service.js +3 -3
  199. package/dist/recall-xray-cli.js +4 -4
  200. package/dist/recall-xray-renderer.js +3 -3
  201. package/dist/recall-xray.js +2 -2
  202. package/dist/resume-bundles.js +8 -7
  203. package/dist/semantic-consolidation.js +8 -7
  204. package/dist/semantic-rule-promotion.js +7 -6
  205. package/dist/semantic-rule-verifier.js +7 -6
  206. package/dist/source-agent-qualifier.js +10 -9
  207. package/dist/standup/build.js +7 -6
  208. package/dist/storage.d.ts.map +1 -1
  209. package/dist/storage.js +6 -5
  210. package/dist/summarizer.js +6 -5
  211. package/dist/support-passport/index.js +6 -5
  212. package/dist/transfer/export-okf.js +7 -6
  213. package/dist/types-extraction-failure.d.ts +7 -1
  214. package/dist/types-extraction-failure.d.ts.map +1 -1
  215. package/dist/types.d.ts +6 -6
  216. package/dist/types.d.ts.map +1 -1
  217. package/dist/types.js +1 -1
  218. package/dist/verified-recall.js +7 -6
  219. package/dist/who-knows-cli.js +8 -7
  220. package/dist/who-knows.js +7 -6
  221. package/package.json +2 -2
  222. package/src/access-mcp.ts +8 -0
  223. package/src/access-recall-concurrency.ts +35 -2
  224. package/src/access-recall-response.ts +3 -1
  225. package/src/access-recall-surface.ts +1 -0
  226. package/src/access-schema.ts +8 -0
  227. package/src/access-service-recall-concurrency.test.ts +65 -0
  228. package/src/access-service.ts +4 -3
  229. package/src/buffer-incremental-persistence.test.ts +23 -0
  230. package/src/buffer.ts +30 -28
  231. package/src/config.ts +2 -0
  232. package/src/evals.ts +6 -6
  233. package/src/extraction-error-classification.ts +88 -8
  234. package/src/extraction-local-failure-class.test.ts +117 -3
  235. package/src/extraction-reply-diagnostic-wiring.test.ts +3 -1
  236. package/src/extraction.test.ts +73 -3
  237. package/src/extraction.ts +26 -25
  238. package/src/fallback-llm-codex-subscription.ts +17 -3
  239. package/src/fallback-llm.test.ts +70 -0
  240. package/src/fallback-llm.ts +17 -18
  241. package/src/local-llm-headers-timeout.test.ts +151 -0
  242. package/src/local-llm-helpers.ts +1 -1
  243. package/src/local-llm.ts +44 -43
  244. package/src/orchestration/extraction-drain.ts +11 -5
  245. package/src/orchestration/extraction-run-helpers.ts +110 -4
  246. package/src/orchestration/extraction-run.test.ts +408 -3
  247. package/src/orchestration/extraction-run.ts +75 -75
  248. package/src/orchestration/orchestrator-helpers.ts +2 -0
  249. package/src/orchestration/recall-entry.ts +7 -7
  250. package/src/orchestration/recall-internal.ts +14 -4
  251. package/src/orchestrator.ts +3 -2
  252. package/src/recall-client-deadline-trace.test.ts +209 -0
  253. package/src/storage.ts +5 -4
  254. package/src/types-extraction-failure.ts +12 -1
  255. package/src/types.ts +6 -6
  256. package/dist/chunk-2QW5HPKU.js.map +0 -1
  257. package/dist/chunk-3RZ4GDOH.js.map +0 -1
  258. package/dist/chunk-BDFSVUUZ.js.map +0 -1
  259. package/dist/chunk-C7SRUWBW.js +0 -54
  260. package/dist/chunk-C7SRUWBW.js.map +0 -1
  261. package/dist/chunk-F2MVWUNF.js.map +0 -1
  262. package/dist/chunk-FZU62GIV.js.map +0 -1
  263. package/dist/chunk-JKMIGCK6.js.map +0 -1
  264. package/dist/chunk-M7Q7Z6V5.js.map +0 -1
  265. package/dist/chunk-MMRTPH3J.js.map +0 -1
  266. package/dist/chunk-NN3LMWKA.js.map +0 -1
  267. package/dist/chunk-QIPRDRGM.js.map +0 -1
  268. package/dist/chunk-QSF5SJAM.js.map +0 -1
  269. package/dist/chunk-STSORBX5.js.map +0 -1
  270. package/dist/chunk-V65H7MI6.js.map +0 -1
  271. package/dist/chunk-VSLV3EEP.js.map +0 -1
  272. package/dist/chunk-XZMQLON4.js.map +0 -1
  273. package/dist/chunk-YCJJODER.js.map +0 -1
  274. /package/dist/{chunk-3ZS3NUEI.js.map → chunk-3DSLTUK6.js.map} +0 -0
  275. /package/dist/{chunk-DYUPSTCV.js.map → chunk-3EXG2KPK.js.map} +0 -0
  276. /package/dist/{chunk-FGFU6J26.js.map → chunk-4FTYKZ77.js.map} +0 -0
  277. /package/dist/{chunk-EEA2RM4B.js.map → chunk-4I6A3SDL.js.map} +0 -0
  278. /package/dist/{chunk-SKJM4PKE.js.map → chunk-4JI5PPFW.js.map} +0 -0
  279. /package/dist/{chunk-TDG5NZAZ.js.map → chunk-65JA7LWV.js.map} +0 -0
  280. /package/dist/{chunk-3YID7KZ6.js.map → chunk-6QMKUWXH.js.map} +0 -0
  281. /package/dist/{chunk-7SOKOEAZ.js.map → chunk-6RRHTHKQ.js.map} +0 -0
  282. /package/dist/{chunk-VHQNJW4Q.js.map → chunk-6W62D4MC.js.map} +0 -0
  283. /package/dist/{chunk-CRS2NY44.js.map → chunk-7O6H7BPW.js.map} +0 -0
  284. /package/dist/{chunk-KJ65WZHB.js.map → chunk-A7DIZOTF.js.map} +0 -0
  285. /package/dist/{chunk-TZ7ZA2LM.js.map → chunk-AD3JOG2Q.js.map} +0 -0
  286. /package/dist/{chunk-7EP4FURO.js.map → chunk-C72YQM7E.js.map} +0 -0
  287. /package/dist/{chunk-4EAVEDLG.js.map → chunk-CRKT2JXN.js.map} +0 -0
  288. /package/dist/{chunk-CJSTQNE5.js.map → chunk-CTOMDCCA.js.map} +0 -0
  289. /package/dist/{chunk-PSQ347YP.js.map → chunk-DSKII2W4.js.map} +0 -0
  290. /package/dist/{chunk-KOVQZJ27.js.map → chunk-E7LDTUWK.js.map} +0 -0
  291. /package/dist/{chunk-SPAKBUJY.js.map → chunk-EWLMEYLF.js.map} +0 -0
  292. /package/dist/{chunk-JJ42IDJU.js.map → chunk-FEGQI5KR.js.map} +0 -0
  293. /package/dist/{chunk-3BICT225.js.map → chunk-FGNBUUPX.js.map} +0 -0
  294. /package/dist/{chunk-QZMGZBTF.js.map → chunk-HBG6CQEX.js.map} +0 -0
  295. /package/dist/{chunk-7V6GNQC2.js.map → chunk-HINQENZG.js.map} +0 -0
  296. /package/dist/{chunk-WRVKI6ZO.js.map → chunk-HLQXSX4F.js.map} +0 -0
  297. /package/dist/{chunk-KQIOW3TG.js.map → chunk-HUDE2SQA.js.map} +0 -0
  298. /package/dist/{chunk-T765HQ5U.js.map → chunk-IIDAN7XJ.js.map} +0 -0
  299. /package/dist/{chunk-VMNX2UV7.js.map → chunk-JRUOIEFL.js.map} +0 -0
  300. /package/dist/{chunk-TWYYUMYO.js.map → chunk-KXAGZRJV.js.map} +0 -0
  301. /package/dist/{chunk-JITK24KX.js.map → chunk-LJNCJK7B.js.map} +0 -0
  302. /package/dist/{chunk-Z6EFSXU3.js.map → chunk-LMM2LRVQ.js.map} +0 -0
  303. /package/dist/{chunk-KZ4BJRGQ.js.map → chunk-ODGVLSCQ.js.map} +0 -0
  304. /package/dist/{chunk-AALJHIKH.js.map → chunk-OHJ5PNYB.js.map} +0 -0
  305. /package/dist/{chunk-Q6S67LHR.js.map → chunk-OOMFFMX3.js.map} +0 -0
  306. /package/dist/{chunk-JNDMIAJ4.js.map → chunk-QEVZKJM6.js.map} +0 -0
  307. /package/dist/{chunk-ZNCCX7P6.js.map → chunk-QO5QZR2U.js.map} +0 -0
  308. /package/dist/{chunk-NFQKIZK3.js.map → chunk-QXEF66SC.js.map} +0 -0
  309. /package/dist/{chunk-NKHRIDYP.js.map → chunk-RTXW6E6X.js.map} +0 -0
  310. /package/dist/{chunk-5WDUY2ZZ.js.map → chunk-S4QWAWR6.js.map} +0 -0
  311. /package/dist/{chunk-HEJFE3BC.js.map → chunk-SJCN7ESG.js.map} +0 -0
  312. /package/dist/{chunk-AJ7JHHRY.js.map → chunk-SPPWVMP4.js.map} +0 -0
  313. /package/dist/{chunk-QFKNIKUF.js.map → chunk-SXR7L57Z.js.map} +0 -0
  314. /package/dist/{chunk-GYCUX3N4.js.map → chunk-TGMIJABS.js.map} +0 -0
  315. /package/dist/{chunk-GH7IKABD.js.map → chunk-UFJJMQDV.js.map} +0 -0
  316. /package/dist/{chunk-FKHXXL42.js.map → chunk-VAE6QCZQ.js.map} +0 -0
  317. /package/dist/{chunk-UH2VY2QQ.js.map → chunk-WCW7I7ZM.js.map} +0 -0
  318. /package/dist/{chunk-5GIYIYJI.js.map → chunk-WLP3XJCO.js.map} +0 -0
  319. /package/dist/{chunk-LR6LWX33.js.map → chunk-XXDIPAUE.js.map} +0 -0
  320. /package/dist/{chunk-G2MS56KM.js.map → chunk-YQUGYQRY.js.map} +0 -0
  321. /package/dist/{chunk-WEI6HEUX.js.map → chunk-YXAH5TSN.js.map} +0 -0
  322. /package/dist/{chunk-75K6DRPN.js.map → chunk-ZAVFAGBE.js.map} +0 -0
  323. /package/dist/{chunk-7KTORRIK.js.map → chunk-ZNJU3NBJ.js.map} +0 -0
@@ -255,4 +255,4 @@ export {
255
255
  localLlmBackendPoolExpiredAtMs,
256
256
  markLocalLlmBackendPoolUnavailable
257
257
  };
258
- //# sourceMappingURL=chunk-NN3LMWKA.js.map
258
+ //# sourceMappingURL=chunk-7TQ3EDQ3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/local-llm-helpers.ts"],"sourcesContent":["import type { ResponseFormatJSONSchema } from \"openai/resources/shared\";\nimport { fetch as undiciFetch, type Response as UndiciResponse } from \"undici\";\nimport { log } from \"./logger.js\";\nimport { directProbeDispatcher, isInvalidDispatcherArg, type TransportRequestInit } from \"./local-llm-transport.js\";\nimport type { LocalLlmRequestPriority } from \"./local-llm.js\";\n\nexport interface LocalLlmChatCompletionOptions {\n temperature?: number;\n maxTokens?: number;\n responseFormat?: { type: string } | ResponseFormatJSONSchema;\n timeoutMs?: number;\n operation?: string;\n forceDisableThinking?: boolean;\n disableThinking?: boolean;\n priority?: LocalLlmRequestPriority;\n signal?: AbortSignal;\n redactProviderErrors?: boolean;\n /** Per-request model; defaults to config.localLlmModel. */\n model?: string;\n /**\n * Optional out-box for the terminal failure cause (issue #2891): on a\n * failed request the client records the last provider error here so\n * callers can classify it (e.g. HTTP 429 → rate-limited) in memory\n * instead of seeing only null. Never logged.\n */\n failureDiag?: { lastError?: unknown; finishReason?: string; sawTransientAttempt?: boolean };\n}\n\nexport interface LocalLlmChatCompletionResult {\n content: string;\n usage?: { promptTokens: number; completionTokens: number; totalTokens: number };\n}\nexport function isAbortError(err: unknown): boolean {\n if (!err || typeof err !== \"object\") return false;\n const maybe = err as { name?: string; message?: string };\n return (\n maybe.name === \"AbortError\" ||\n maybe.message === \"This operation was aborted\" ||\n maybe.message === \"The operation was aborted\"\n );\n}\n\n/** Caller signal combined with a client-wide shutdown signal, so a daemon\n * stop aborts in-flight requests and retry loops at once — even for\n * callers that pass no signal of their own. */\nexport function combineClientAbortSignals(\n caller: AbortSignal | undefined,\n shutdown: AbortSignal | undefined,\n): AbortSignal | undefined {\n if (shutdown === undefined) return caller;\n if (caller === undefined) return shutdown;\n return AbortSignal.any([caller, shutdown]);\n}\n\nexport function waitForRetryBackoff(backoffMs: number, signal?: AbortSignal): Promise<boolean> {\n return new Promise((resolve) => {\n let settled = false;\n let timer: NodeJS.Timeout | undefined;\n const onAbort = (): void => {\n if (settled) return;\n settled = true;\n if (timer) clearTimeout(timer);\n signal?.removeEventListener(\"abort\", onAbort);\n resolve(false);\n };\n const onTimer = (): void => {\n if (settled) return;\n settled = true;\n signal?.removeEventListener(\"abort\", onAbort);\n resolve(true);\n };\n timer = setTimeout(onTimer, backoffMs);\n if (signal) {\n if (signal.aborted) onAbort();\n else signal.addEventListener(\"abort\", onAbort, { once: true });\n }\n });\n}\n\nexport function normalizeBackendTripReason(reason: string): string {\n const cleaned = reason.replace(/\\s+/g, \" \").replace(/^[-:–—\\s]+/, \"\").trim();\n if (!cleaned) return \"unknown local backend failure\";\n return cleaned.length > 160 ? `${cleaned.slice(0, 157)}...` : cleaned;\n}\n\nexport function extractNonRecoverableBackendReason(reason: string): string | null {\n const match = reason.match(\n /Failed to load model|Library not loaded|different Team IDs|code signature|llm_engine_mlx_amphibian/i,\n );\n return match?.[0] ?? null;\n}\n\nexport function extractNonRecoverableBackendReasonFromErrorText(errorText: string): string | null {\n const directReason = extractNonRecoverableBackendReason(errorText);\n if (directReason) return directReason;\n try {\n const parsed = JSON.parse(errorText) as { error?: { message?: string } };\n return extractNonRecoverableBackendReason(parsed?.error?.message ?? \"\");\n } catch {\n return null;\n }\n}\n\n/**\n * Flatten a fetch rejection into one line, including the `cause` undici hides\n * the real reason behind (`fetch failed` alone says nothing).\n */\nexport function describeFetchFailure(err: unknown): string {\n const name = err instanceof Error ? err.name : \"\";\n const message = err instanceof Error ? err.message : String(err);\n const cause: unknown = err instanceof Error ? (err as Error & { cause?: unknown }).cause : undefined;\n const causeText = cause instanceof Error\n ? ` (cause: ${cause.name}: ${cause.message}${\n typeof (cause as Error & { code?: unknown }).code === \"string\"\n ? ` [${String((cause as Error & { code?: unknown }).code)}]`\n : \"\"\n })`\n : cause === undefined\n ? \"\"\n : ` (cause: ${String(cause)})`;\n return `${name ? `${name}: ` : \"\"}${message}${causeText}`;\n}\n\n/**\n * What to record when every availability probe failed.\n *\n * A probe that TIMED OUT is not evidence the backend is down: the budget is a\n * fixed 2s and a busy event loop can burn it before the socket is scheduled,\n * so the backend looks dead while it answers other callers in single-digit ms.\n * Caching that verdict took extraction offline for a whole health-check\n * interval at a time (issue #2210), so a timeout leaves availability UNKNOWN —\n * this call fails, the next one re-probes instead of reading a stale false.\n *\n * A backend that ANSWERED and said no is a real verdict and stays cached, or\n * the daemon re-probes a known-bad endpoint on every request.\n */\nexport function resolveUnavailableVerdict(args: {\n baseUrl: string;\n sawAbortedProbe: boolean;\n wasAvailable: boolean | null;\n}): { cacheVerdict: boolean; warning: string | null } {\n if (args.sawAbortedProbe) {\n return {\n cacheVerdict: false,\n warning:\n `local LLM availability probe timed out at ${args.baseUrl} (event loop busy?); treating availability as ` +\n \"unknown and re-probing on the next request rather than marking the backend down\",\n };\n }\n return {\n cacheVerdict: true,\n // Surfaced at warn, not debug: extraction stops silently when this flips,\n // and the daemon emits no debug at all unless configured for it.\n warning: args.wasAvailable !== false ? `local LLM became unavailable at ${args.baseUrl}` : null,\n };\n}\n\nexport interface ProbeFetchResult {\n ok: boolean;\n data: unknown;\n status: number | null;\n /** The probe hit its own budget rather than getting an answer. */\n aborted?: boolean;\n}\n\n/**\n * One health-probe request.\n *\n * Every failure is logged with its cause: a transport error and a 404 both\n * returned `ok: false` with nothing recorded, so an unreachable backend was\n * indistinguishable from a wrong path and an availability failure had no\n * diagnosable reason at all (§22, issue #2210).\n */\nexport async function probeFetch(\n url: string,\n options: { timeoutMs: number; headers: Record<string, string>; signal?: AbortSignal },\n): Promise<ProbeFetchResult> {\n const controller = new AbortController();\n const requestSignal = options.signal\n ? AbortSignal.any([options.signal, controller.signal])\n : controller.signal;\n const timeout = setTimeout(() => controller.abort(), options.timeoutMs);\n try {\n const init: TransportRequestInit = { signal: requestSignal, headers: options.headers };\n const dispatcher = directProbeDispatcher();\n if (dispatcher) init.dispatcher = dispatcher;\n let response: Response | UndiciResponse;\n try {\n response = await fetch(url, init);\n } catch (err) {\n // node >= 26 wraps dispatch failures in TypeError(\"fetch failed\"),\n // so UND_ERR_INVALID_ARG can ride `err` or its cause chain; the\n // bundled undici's fetch accepts the same init on every supported\n // Node, so direct-mode probes still run there.\n if (!(err instanceof Error) || !isInvalidDispatcherArg(err)) throw err;\n response = await undiciFetch(url, init);\n }\n clearTimeout(timeout);\n if (!response.ok) {\n log.debug(`local LLM probe: ${url} returned HTTP ${response.status}`);\n return { ok: false, data: null, status: response.status };\n }\n const contentType = response.headers.get(\"content-type\");\n const data = contentType?.includes(\"application/json\") ? await response.json() : await response.text();\n return { ok: true, data, status: response.status };\n } catch (err) {\n clearTimeout(timeout);\n const aborted = isAbortError(err);\n log.debug(\n `local LLM probe: ${url} ${aborted ? `timed out after ${options.timeoutMs}ms` : \"failed\"}: ${describeFetchFailure(err)}`,\n );\n return { ok: false, data: null, status: null, aborted };\n }\n}\n\ninterface PendingProbe {\n promise: Promise<boolean>;\n controller: AbortController;\n /** Callers still awaiting this sequence; at zero the sequence is aborted. */\n waiters: number;\n}\n\n/**\n * Collapses concurrent probe sequences onto one in-flight run.\n *\n * A timed-out availability probe deliberately caches nothing (issue #2210),\n * which removed the false verdict that used to absorb concurrent callers:\n * every queued request would then run its own full probe sequence, on a host\n * already slow enough to blow the probe budget.\n *\n * Cancellation is refcounted rather than shared: one caller walking away must\n * not abort a sequence the others are still waiting on, so the underlying task\n * is aborted only once every waiter has gone.\n */\nexport class SingleFlightProbe {\n private pending: PendingProbe | null = null;\n\n run(task: (signal: AbortSignal) => Promise<boolean>, signal?: AbortSignal): Promise<boolean> {\n let active = this.pending;\n if (!active) {\n const controller = new AbortController();\n const created: PendingProbe = { promise: Promise.resolve(false), controller, waiters: 0 };\n created.promise = task(controller.signal).finally(() => {\n if (this.pending === created) this.pending = null;\n });\n this.pending = created;\n active = created;\n }\n const entry = active;\n entry.waiters += 1;\n let released = false;\n const release = () => {\n if (released) return;\n released = true;\n entry.waiters -= 1;\n if (entry.waiters > 0) return;\n // Detach BEFORE aborting. `pending` would otherwise still point at this\n // doomed entry until the task's own `finally` runs a microtask later, and\n // a caller arriving in that window would join an aborted sequence and\n // read its `false` as a verdict.\n if (this.pending === entry) this.pending = null;\n entry.controller.abort();\n };\n if (!signal) return entry.promise.finally(release);\n return new Promise<boolean>((resolve, reject) => {\n const onAbort = () => {\n release();\n resolve(false);\n };\n signal.addEventListener(\"abort\", onAbort, { once: true });\n entry.promise.then(\n (value) => {\n signal.removeEventListener(\"abort\", onAbort);\n release();\n resolve(value);\n },\n (err: unknown) => {\n signal.removeEventListener(\"abort\", onAbort);\n release();\n reject(err instanceof Error ? err : new Error(String(err)));\n },\n );\n });\n }\n}\n\n/** True when `value` is safe for `fetch` request headers. Node's `Headers`\n * accepts a ByteString: controls and DEL are out, and so is anything above\n * U+00FF — `é` is sendable, `Ā` is not (Kilo review on #3474). */\nexport function isHttpHeaderFieldValue(value: string): boolean {\n if (!value) return false;\n for (let i = 0; i < value.length; i += 1) {\n const code = value.charCodeAt(i);\n if (code < 0x20 || code === 0x7f || code > 0xff) return false;\n }\n return true;\n}\n\nfunction trimTrailingSlashes(url: string): string {\n let end = url.length;\n while (end > 0 && url.charCodeAt(end - 1) === 47) end -= 1;\n return end === url.length ? url : url.slice(0, end);\n}\n\n/** Circuit-breaker and rate-limit scope when recall/extraction share one proxy URL. */\nexport function formatLocalLlmPoolKey(chatUrl: string, operation: string): string {\n let normalized = chatUrl.replace(\"localhost\", \"127.0.0.1\");\n normalized = trimTrailingSlashes(normalized);\n if (normalized.endsWith(\"/v1\")) {\n normalized = normalized.slice(0, -3);\n }\n const completions = normalized.endsWith(\"/chat/completions\")\n ? normalized\n : `${normalized}/v1/chat/completions`;\n return `${completions}|op=${operation}`;\n}\n\n/** HTTP headers the jarvis-ml recall proxy reads for pool routing. */\nexport function buildLocalLlmRoutingHeaders(\n operation: string,\n priority: \"recall-critical\" | \"background\" | undefined,\n): Record<string, string> {\n const routingEntries: Array<readonly [string, string]> = [\n [\"Content-Type\", \"application/json\"],\n ];\n if (operation !== \"unspecified\" && isHttpHeaderFieldValue(operation)) {\n routingEntries.push([\"X-Remnic-Operation\", operation]);\n }\n if (priority) {\n routingEntries.push([\"X-Remnic-Priority\", priority]);\n }\n return Object.fromEntries(routingEntries) satisfies Record<string, string>;\n}\n\nconst LOCAL_LLM_GLOBAL_BACKEND_STATE = \"__openclawEngramLocalLlmBackendState\";\n\nexport type LocalLlmBackendPoolState = {\n untilMs: number;\n reason: string;\n /** Once the trip lapses this is set instead of deleting the entry: every\n * client must observe the transition once, so a tombstone stays visible for\n * BACKEND_POOL_TOMBSTONE_MS. */\n expiredAtMs?: number;\n};\n\n/** How long a lapsed circuit stays readable so each client can invalidate its\n * cached health verdict once (the health cache is 60s; this leaves margin). */\nconst BACKEND_POOL_TOMBSTONE_MS = 15 * 60_000;\n\nfunction localLlmBackendPoolMap(): Map<string, LocalLlmBackendPoolState> {\n // SAFETY: globalThis carries one optional Map slot keyed for backend pool state.\n const globalAny = globalThis as typeof globalThis & {\n [LOCAL_LLM_GLOBAL_BACKEND_STATE]?: Map<string, LocalLlmBackendPoolState>;\n };\n const existing = globalAny[LOCAL_LLM_GLOBAL_BACKEND_STATE];\n if (existing) return existing;\n const created = new Map<string, LocalLlmBackendPoolState>();\n globalAny[LOCAL_LLM_GLOBAL_BACKEND_STATE] = created;\n return created;\n}\n\nexport function getLocalLlmTrippedBackendPoolState(\n now: number,\n chatUrl: string,\n operation: string,\n): LocalLlmBackendPoolState | null {\n const key = formatLocalLlmPoolKey(chatUrl, operation);\n const map = localLlmBackendPoolMap();\n const state = map.get(key) ?? null;\n if (!state) return null;\n if (state.untilMs <= now) {\n state.expiredAtMs ??= state.untilMs;\n if (state.expiredAtMs + BACKEND_POOL_TOMBSTONE_MS <= now) map.delete(key);\n return null;\n }\n return state;\n}\n\n/** The instant this pool's circuit lapsed, or null while it is active or\n * absent. The tombstone stays in the map so every client holding a cached\n * health verdict can observe the transition once — deleting on first read left\n * later clients stale (wAN review on #3474). */\nexport function localLlmBackendPoolExpiredAtMs(now: number, chatUrl: string, operation: string): number | null {\n const key = formatLocalLlmPoolKey(chatUrl, operation);\n const state = localLlmBackendPoolMap().get(key) ?? null;\n if (state && state.untilMs <= now) {\n state.expiredAtMs ??= state.untilMs;\n return state.expiredAtMs;\n }\n return null;\n}\n\nexport function markLocalLlmBackendPoolUnavailable(\n reason: string,\n durationMs: number,\n chatUrl: string,\n operation: string,\n): void {\n const normalizedReason = normalizeBackendTripReason(reason);\n const key = formatLocalLlmPoolKey(chatUrl, operation);\n if (durationMs > 0) {\n localLlmBackendPoolMap().set(key, { untilMs: Date.now() + durationMs, reason: normalizedReason });\n } else {\n localLlmBackendPoolMap().delete(key);\n }\n}\n"],"mappings":";;;;;;;;;AACA,SAAS,SAAS,mBAAoD;AA+B/D,SAAS,aAAa,KAAuB;AAClD,MAAI,CAAC,OAAO,OAAO,QAAQ,SAAU,QAAO;AAC5C,QAAM,QAAQ;AACd,SACE,MAAM,SAAS,gBACf,MAAM,YAAY,gCAClB,MAAM,YAAY;AAEtB;AAKO,SAAS,0BACd,QACA,UACyB;AACzB,MAAI,aAAa,OAAW,QAAO;AACnC,MAAI,WAAW,OAAW,QAAO;AACjC,SAAO,YAAY,IAAI,CAAC,QAAQ,QAAQ,CAAC;AAC3C;AAEO,SAAS,oBAAoB,WAAmB,QAAwC;AAC7F,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,QAAI,UAAU;AACd,QAAI;AACJ,UAAM,UAAU,MAAY;AAC1B,UAAI,QAAS;AACb,gBAAU;AACV,UAAI,MAAO,cAAa,KAAK;AAC7B,cAAQ,oBAAoB,SAAS,OAAO;AAC5C,cAAQ,KAAK;AAAA,IACf;AACA,UAAM,UAAU,MAAY;AAC1B,UAAI,QAAS;AACb,gBAAU;AACV,cAAQ,oBAAoB,SAAS,OAAO;AAC5C,cAAQ,IAAI;AAAA,IACd;AACA,YAAQ,WAAW,SAAS,SAAS;AACrC,QAAI,QAAQ;AACV,UAAI,OAAO,QAAS,SAAQ;AAAA,UACvB,QAAO,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;AAAA,IAC/D;AAAA,EACF,CAAC;AACH;AAEO,SAAS,2BAA2B,QAAwB;AACjE,QAAM,UAAU,OAAO,QAAQ,QAAQ,GAAG,EAAE,QAAQ,cAAc,EAAE,EAAE,KAAK;AAC3E,MAAI,CAAC,QAAS,QAAO;AACrB,SAAO,QAAQ,SAAS,MAAM,GAAG,QAAQ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AC5B,QAAI,MAAM,cAAc,6BAA6B,IAAK,KAAI,OAAO,GAAG;AACxE,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAMO,SAAS,+BAA+B,KAAa,SAAiB,WAAkC;AAC7G,QAAM,MAAM,sBAAsB,SAAS,SAAS;AACpD,QAAM,QAAQ,uBAAuB,EAAE,IAAI,GAAG,KAAK;AACnD,MAAI,SAAS,MAAM,WAAW,KAAK;AACjC,UAAM,gBAAgB,MAAM;AAC5B,WAAO,MAAM;AAAA,EACf;AACA,SAAO;AACT;AAEO,SAAS,mCACd,QACA,YACA,SACA,WACM;AACN,QAAM,mBAAmB,2BAA2B,MAAM;AAC1D,QAAM,MAAM,sBAAsB,SAAS,SAAS;AACpD,MAAI,aAAa,GAAG;AAClB,2BAAuB,EAAE,IAAI,KAAK,EAAE,SAAS,KAAK,IAAI,IAAI,YAAY,QAAQ,iBAAiB,CAAC;AAAA,EAClG,OAAO;AACL,2BAAuB,EAAE,OAAO,GAAG;AAAA,EACrC;AACF;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  rebuildMemoryProjection,
3
3
  watchProjectionRebuildParent
4
- } from "./chunk-DYUPSTCV.js";
4
+ } from "./chunk-3EXG2KPK.js";
5
5
  import {
6
6
  initLogger,
7
7
  log
@@ -77,4 +77,4 @@ if (invokedAsRunner) {
77
77
  export {
78
78
  PROJECTION_REBUILD_RUNNER_FLAG
79
79
  };
80
- //# sourceMappingURL=chunk-KJ65WZHB.js.map
80
+ //# sourceMappingURL=chunk-A7DIZOTF.js.map
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  computeCorpusWatermarks,
6
6
  resolveCorpusNamespaceRoots
7
- } from "./chunk-CJSTQNE5.js";
7
+ } from "./chunk-CTOMDCCA.js";
8
8
 
9
9
  // src/operator-doctor-corpus.ts
10
10
  var DIGEST_PREFIX_LENGTH = 12;
@@ -78,4 +78,4 @@ export {
78
78
  corpusWatermarksFromCheck,
79
79
  summarizeCorpusAndReplica
80
80
  };
81
- //# sourceMappingURL=chunk-TZ7ZA2LM.js.map
81
+ //# sourceMappingURL=chunk-AD3JOG2Q.js.map
@@ -6,7 +6,7 @@ import {
6
6
  headerConnector,
7
7
  renderExtractionConversation,
8
8
  resolveSourceConnector
9
- } from "./chunk-FKHXXL42.js";
9
+ } from "./chunk-VAE6QCZQ.js";
10
10
  import {
11
11
  normalizeReasoningTrace
12
12
  } from "./chunk-54V4BZWP.js";
@@ -54,17 +54,6 @@ import {
54
54
  extractionText,
55
55
  isPlainRecord
56
56
  } from "./chunk-DR4TYD56.js";
57
- import {
58
- LocalLlmRejectedError,
59
- classifyExtractionThrownError,
60
- classifyFallbackParseFailure,
61
- classifyLocalLlmRejected,
62
- directInputTooLargeResult,
63
- formatDirectInputTooLargeLog,
64
- formatExtractionParseFailureLog,
65
- isRequestTooLargeError,
66
- localRejectionStatus
67
- } from "./chunk-M7Q7Z6V5.js";
68
57
  import {
69
58
  delinearize
70
59
  } from "./chunk-VEWZZM3H.js";
@@ -78,7 +67,7 @@ import {
78
67
  } from "./chunk-TK6EBBKG.js";
79
68
  import {
80
69
  LocalLlmClient
81
- } from "./chunk-FZU62GIV.js";
70
+ } from "./chunk-2X5I5C3M.js";
82
71
  import {
83
72
  CONSOLIDATION_RESPONSE_SCHEMA,
84
73
  CUE_ANCHOR_PROMPT_INSTRUCTION,
@@ -104,14 +93,27 @@ import {
104
93
  import {
105
94
  FallbackLlmClient,
106
95
  gatewayTaskChainOptions
107
- } from "./chunk-MMRTPH3J.js";
96
+ } from "./chunk-KQYGUFMQ.js";
108
97
  import {
109
98
  buildChatCompletionTokenLimit,
110
99
  shouldAssumeOpenAiChatCompletions
111
100
  } from "./chunk-L2EXJQJP.js";
112
101
  import {
113
102
  fallbackLlmRuntimeContextFromConfig
114
- } from "./chunk-QSF5SJAM.js";
103
+ } from "./chunk-STQNKDKZ.js";
104
+ import {
105
+ LocalLlmRejectedError,
106
+ classifyExtractionThrownError,
107
+ classifyFallbackParseFailure,
108
+ classifyLocalLlmRejected,
109
+ directInputTooLargeResult,
110
+ downgradePermanentOnTransientAttempt,
111
+ formatDirectInputTooLargeLog,
112
+ formatExtractionParseFailureLog,
113
+ isParameterConfigRejection,
114
+ isRequestTooLargeError,
115
+ localRejectionStatus
116
+ } from "./chunk-JDZ5JPYG.js";
115
117
  import {
116
118
  extractJsonCandidates
117
119
  } from "./chunk-YBA52OKG.js";
@@ -700,9 +702,8 @@ var ExtractionEngine = class {
700
702
  '{"facts":[{"category":"fact","content":"...","confidence":0.0,"tags":["..."],"entityRef":"optional","promptedByQuestion":"optional","quote":"optional verbatim span from a single turn"}],"profileUpdates":["..."],"entities":[{"name":"...","type":"person","facts":["..."],"structuredSections":[{"key":"beliefs","title":"Beliefs","facts":["..."]}],"promptedByQuestion":"optional"}],"relationships":[{"source":"...","target":"...","label":"...","promptedByQuestion":"optional"}]}',
701
703
  this.config.provenance?.enabled ? '- Source quotes: For each fact, include a "quote" field with the EXACT verbatim words from the conversation that support the fact (a contiguous span from a single turn, not a paraphrase). Cap at ~300 chars.' : "",
702
704
  // #1578: emit the same event-time guidance as the primary extraction
703
- // paths so proactive-recovered facts also carry an optional eventTime
704
- // (chatgpt-codex thread on extraction.ts:1607). Returns "" when the
705
- // bi-temporal gate is off, keeping the prompt unchanged by default.
705
+ // paths so proactive-recovered facts also carry an optional eventTime.
706
+ // Returns "" when the bi-temporal gate is off.
706
707
  eventTimePromptInstruction(this.config),
707
708
  headerConnector(sourceConnector) !== void 0 && resolveMemoryLifecycleCapabilities(this.config).extractionScopeClassification ? `Tool, command, or CLI-flag instructions tied to the ${sourceConnector} agent are "project" scope; when you recover one, begin the fact with a leading "In ${sourceConnector}, " clause naming that agent (e.g. "In ${sourceConnector}, use the search tool with a repository path.").` : "",
708
709
  "",
@@ -988,14 +989,15 @@ var ExtractionEngine = class {
988
989
  localLlm: resolveLocalLlmCapabilities(this.config).localLlm
989
990
  });
990
991
  this.profiler.startSpan("total", extractionTraceId);
991
- let primaryExtractorAttempted = false;
992
+ let primaryExtractorAttempted = false, primaryTransientAttemptSeen = false;
992
993
  let directInputTooLarge = false;
993
994
  try {
994
995
  if (this.shouldUseLocalLlm) {
995
996
  this.profiler.startSpan("local-llm", extractionTraceId);
996
997
  primaryExtractorAttempted = true;
998
+ const localDiag = {};
997
999
  try {
998
- const localResult = await this.extractWithLocalLlm(conversation, signal, ambientCapture);
1000
+ const localResult = await this.extractWithLocalLlm(conversation, signal, ambientCapture, localDiag);
999
1001
  throwIfExtractionAborted(signal);
1000
1002
  if (localResult) {
1001
1003
  const durationMs = Date.now() - startTime;
@@ -1027,6 +1029,7 @@ var ExtractionEngine = class {
1027
1029
  extractionFailureClass: "provider_retryable"
1028
1030
  };
1029
1031
  }
1032
+ primaryTransientAttemptSeen ||= localDiag.sawTransientAttempt === true;
1030
1033
  log.info("extraction: local LLM unavailable, falling back to gateway default AI");
1031
1034
  } catch (err) {
1032
1035
  if (signal?.aborted) throw err;
@@ -1041,6 +1044,7 @@ var ExtractionEngine = class {
1041
1044
  extractionFailureClass: err instanceof LocalLlmRejectedError ? classifyLocalLlmRejected(err) : classifyExtractionThrownError(err)
1042
1045
  };
1043
1046
  }
1047
+ primaryTransientAttemptSeen ||= localDiag.sawTransientAttempt === true || (err instanceof LocalLlmRejectedError ? classifyLocalLlmRejected(err) : classifyExtractionThrownError(err)) === "provider_retryable";
1044
1048
  log.info("extraction: local LLM error, falling back to gateway default AI:", err);
1045
1049
  } finally {
1046
1050
  try {
@@ -1093,6 +1097,7 @@ var ExtractionEngine = class {
1093
1097
  closedDirectTrace = true;
1094
1098
  directInputTooLarge = err instanceof Object && isRequestTooLargeError(err);
1095
1099
  if (directInputTooLarge) log.warn(formatDirectInputTooLargeLog(conversation.length));
1100
+ primaryTransientAttemptSeen ||= classifyExtractionThrownError(err) === "provider_retryable";
1096
1101
  log.info("extraction: direct client failed, falling back to gateway AI:", err);
1097
1102
  } finally {
1098
1103
  try {
@@ -1189,10 +1194,12 @@ ${extractionResponseShape(this.config.extraction?.spanMode ?? "off")}`
1189
1194
  });
1190
1195
  log.warn(failureLog);
1191
1196
  const fallbackParseFailureClass = detailed.result === null ? detailed.failureReason === "no_models" && primaryExtractorAttempted ? (
1192
- // Gateway had no models, but a local/direct extractor already failed —
1193
- // the root cause is the primary (transient), not gateway auth/config.
1197
+ // The root cause is the primary's failure, not gateway auth/config.
1194
1198
  "provider_retryable"
1195
- ) : classifyFallbackParseFailure(detailed.failureReason) : "parse_empty";
1199
+ ) : (
1200
+ // Status-bearing refusals classify via the thrown-error classifier — no unbounded retry (#3757).
1201
+ detailed.failureReason === "http_error" && detailed.httpStatus !== void 0 ? classifyExtractionThrownError({ status: detailed.httpStatus, code: detailed.errorClass, transientAttemptSeen: detailed.sawTransientAttempt === true || primaryTransientAttemptSeen }) : classifyFallbackParseFailure(detailed.failureReason)
1202
+ ) : "parse_empty";
1196
1203
  if (directInputTooLarge) return directInputTooLargeResult();
1197
1204
  return {
1198
1205
  facts: [],
@@ -1220,7 +1227,7 @@ ${extractionResponseShape(this.config.extraction?.spanMode ?? "off")}`
1220
1227
  entities: [],
1221
1228
  questions: [],
1222
1229
  extractionFailure: "fallback_failed",
1223
- extractionFailureClass: classifyExtractionThrownError(err)
1230
+ extractionFailureClass: downgradePermanentOnTransientAttempt(classifyExtractionThrownError(err), primaryTransientAttemptSeen)
1224
1231
  };
1225
1232
  } finally {
1226
1233
  try {
@@ -1237,7 +1244,7 @@ ${extractionResponseShape(this.config.extraction?.spanMode ?? "off")}`
1237
1244
  * Extract memories using local LLM with JSON mode.
1238
1245
  * Uses a minimal prompt to fit within local model context limits (typically 4k-8k).
1239
1246
  */
1240
- async extractWithLocalLlm(conversation, signal, ambientCapture = false) {
1247
+ async extractWithLocalLlm(conversation, signal, ambientCapture = false, diag) {
1241
1248
  const lifecycleCaps = resolveMemoryLifecycleCapabilities(this.config);
1242
1249
  log.debug(
1243
1250
  `extractWithLocalLlm: starting extraction, localLlmEnabled=${this.shouldUseLocalLlm}, model=${this.config.localLlmModel}`
@@ -1288,7 +1295,7 @@ ${extractionResponseShape(this.config.extraction?.spanMode ?? "off")}
1288
1295
  Conversation:
1289
1296
  ${truncatedConversation}`;
1290
1297
  log.debug(`extractWithLocalLlm: calling localLlm.chatCompletion with prompt length ${localPrompt.length}...`);
1291
- const failureDiag = {};
1298
+ const failureDiag = diag ?? {};
1292
1299
  const response = await this.localLlm.chatCompletion(
1293
1300
  [
1294
1301
  { role: "system", content: "You are a memory extraction system. Output valid JSON only." },
@@ -1309,7 +1316,7 @@ ${truncatedConversation}`;
1309
1316
  const rejected = localRejectionStatus(failureDiag);
1310
1317
  if (rejected !== void 0) {
1311
1318
  log.warn(formatUnusableReplyDiagnostic(buildUnusableReplyDiagnostic("", failureDiag.finishReason, 0, contextSizes.maxOutputTokens)));
1312
- throw new LocalLlmRejectedError(rejected, failureDiag.finishReason);
1319
+ throw new LocalLlmRejectedError(rejected, failureDiag.finishReason, rejected === 400 && isParameterConfigRejection(failureDiag.lastError), failureDiag.sawTransientAttempt);
1313
1320
  }
1314
1321
  log.debug("extractWithLocalLlm: chatCompletion returned null or empty content");
1315
1322
  return null;
@@ -2462,4 +2469,4 @@ export {
2462
2469
  shouldEnableLocalExtractionThinking,
2463
2470
  ExtractionEngine
2464
2471
  };
2465
- //# sourceMappingURL=chunk-2QW5HPKU.js.map
2472
+ //# sourceMappingURL=chunk-AUDLHIHI.js.map