@remnic/core 9.69.39 → 9.69.40

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 (639) hide show
  1. package/dist/access-admin-ops-surface.d.ts +16 -14
  2. package/dist/access-admin-ops-surface.js +37 -37
  3. package/dist/access-authorization-probe.d.ts +16 -14
  4. package/dist/access-authorization-probe.js +38 -38
  5. package/dist/access-boundary.d.ts +16 -14
  6. package/dist/access-boundary.js +37 -37
  7. package/dist/access-cli.js +98 -97
  8. package/dist/access-cli.js.map +1 -1
  9. package/dist/access-coding-context-resolution.d.ts +1 -1
  10. package/dist/access-extraction-force-flush.d.ts +16 -14
  11. package/dist/access-extraction-force-flush.js +37 -37
  12. package/dist/access-health-types.d.ts +1 -1
  13. package/dist/access-http-briefing.d.ts +16 -14
  14. package/dist/access-http-briefing.js +38 -38
  15. package/dist/access-http-lcm-compaction.d.ts +16 -14
  16. package/dist/access-http-lifecycle-flush.d.ts +16 -14
  17. package/dist/access-http-offline-stream.d.ts +16 -14
  18. package/dist/access-http-query.d.ts +2 -2
  19. package/dist/access-http-query.js +39 -39
  20. package/dist/access-http.d.ts +17 -15
  21. package/dist/access-http.js +53 -53
  22. package/dist/access-identity-continuity-surface.d.ts +13 -12
  23. package/dist/access-identity-continuity-surface.js +37 -37
  24. package/dist/access-lcm-surface.d.ts +16 -14
  25. package/dist/access-lcm-surface.js +37 -37
  26. package/dist/access-mcp.d.ts +16 -14
  27. package/dist/access-mcp.js +45 -45
  28. package/dist/access-memory-search-fanout.d.ts +2 -2
  29. package/dist/{access-namespace-preflight-DY4z6L5X.d.ts → access-namespace-preflight-CKBumJ8W.d.ts} +1 -1
  30. package/dist/access-namespace-preflight.d.ts +3 -3
  31. package/dist/access-namespace-preflight.js +37 -37
  32. package/dist/access-observe-transcript.d.ts +13 -12
  33. package/dist/access-observe-write-category.d.ts +1 -1
  34. package/dist/access-observe-write-category.js +2 -2
  35. package/dist/access-observe-write-surface.d.ts +16 -14
  36. package/dist/access-observe-write-surface.js +37 -37
  37. package/dist/access-offline-manifest.d.ts +37 -13
  38. package/dist/access-offline-manifest.js +7 -3
  39. package/dist/access-operations-batch.js +39 -39
  40. package/dist/access-operations.d.ts +16 -14
  41. package/dist/access-operations.js +44 -44
  42. package/dist/access-recall-concurrency.d.ts +16 -14
  43. package/dist/access-recall-concurrency.js +37 -37
  44. package/dist/access-recall-response.d.ts +16 -14
  45. package/dist/access-recall-response.js +37 -37
  46. package/dist/access-recall-surface.d.ts +16 -14
  47. package/dist/access-recall-surface.js +37 -37
  48. package/dist/access-schema.d.ts +5 -3
  49. package/dist/access-schema.js +1 -1
  50. package/dist/{access-service-MY4bsr_Q.d.ts → access-service-DJ3qogNt.d.ts} +8 -8
  51. package/dist/access-service-helpers.d.ts +16 -14
  52. package/dist/access-service.d.ts +16 -14
  53. package/dist/access-service.js +37 -37
  54. package/dist/access-surface-catalog.d.ts +16 -14
  55. package/dist/access-surface-catalog.js +39 -39
  56. package/dist/access-wearables-meetings-surface.d.ts +6 -5
  57. package/dist/action-confidence.d.ts +1 -1
  58. package/dist/active-memory-bridge.d.ts +1 -1
  59. package/dist/active-recall.d.ts +1 -1
  60. package/dist/active-recall.js +6 -5
  61. package/dist/active-recall.js.map +1 -1
  62. package/dist/activity/digest.d.ts +1 -1
  63. package/dist/ambient-provenance.d.ts +1 -1
  64. package/dist/artifact-search.d.ts +1 -1
  65. package/dist/{auto-sync-RP4C6ZPF.js → auto-sync-D6BAPIJV.js} +5 -5
  66. package/dist/background-generation-config.d.ts +1 -1
  67. package/dist/background-generation-config.js +3 -1
  68. package/dist/background-generation.d.ts +1 -1
  69. package/dist/behavior-learner.d.ts +1 -1
  70. package/dist/behavior-signals.d.ts +1 -1
  71. package/dist/bootstrap.d.ts +13 -12
  72. package/dist/briefing-window.d.ts +2 -2
  73. package/dist/briefing.d.ts +2 -2
  74. package/dist/briefing.js +15 -15
  75. package/dist/buffer-surprise-report.d.ts +1 -1
  76. package/dist/buffer-turn-helpers.d.ts +1 -1
  77. package/dist/buffer.d.ts +2 -2
  78. package/dist/buffer.js +5 -5
  79. package/dist/bulk-import/index.d.ts +3 -3
  80. package/dist/calibration.d.ts +3 -2
  81. package/dist/calibration.js +2 -2
  82. package/dist/capabilities.d.ts +1 -1
  83. package/dist/{catalog-CW87xGx8.d.ts → catalog-BHXkBVhg.d.ts} +1 -1
  84. package/dist/causal-behavior.d.ts +1 -1
  85. package/dist/causal-consolidation.d.ts +1 -1
  86. package/dist/causal-consolidation.js +19 -18
  87. package/dist/causal-consolidation.js.map +1 -1
  88. package/dist/causal-trajectory-graph.d.ts +1 -1
  89. package/dist/{chunk-B36GUU6T.js → chunk-23HFXQ5J.js} +36 -3
  90. package/dist/chunk-23HFXQ5J.js.map +1 -0
  91. package/dist/{chunk-YFTNZMGR.js → chunk-27NO2KVB.js} +31 -8
  92. package/dist/chunk-27NO2KVB.js.map +1 -0
  93. package/dist/{chunk-JTQR6L2N.js → chunk-2SKMZUOW.js} +2 -2
  94. package/dist/{chunk-GG5FHZJJ.js → chunk-2SNCQHJZ.js} +2 -2
  95. package/dist/{chunk-O76F5QPP.js → chunk-3QEVOQF5.js} +2 -2
  96. package/dist/{chunk-3N3PBBEH.js → chunk-3XPN7AVY.js} +2 -2
  97. package/dist/{chunk-X4TD4O2F.js → chunk-46Z3VGWF.js} +2 -2
  98. package/dist/{chunk-2ZTDRNCS.js → chunk-4CMXI55L.js} +2 -2
  99. package/dist/{chunk-FWWWUPOE.js → chunk-5LYSEZOF.js} +18 -9
  100. package/dist/chunk-5LYSEZOF.js.map +1 -0
  101. package/dist/{chunk-IQEJIOEU.js → chunk-62HFZNCJ.js} +17 -10
  102. package/dist/chunk-62HFZNCJ.js.map +1 -0
  103. package/dist/{chunk-YKREX63Z.js → chunk-6L2II3KS.js} +5 -3
  104. package/dist/chunk-6L2II3KS.js.map +1 -0
  105. package/dist/{chunk-MUTVRKKY.js → chunk-7D6SER6A.js} +8 -8
  106. package/dist/{chunk-WBM2MVBK.js → chunk-7Z54NXVS.js} +2 -2
  107. package/dist/{chunk-ACY4ZPF7.js → chunk-AEOOGXMQ.js} +10 -5
  108. package/dist/chunk-AEOOGXMQ.js.map +1 -0
  109. package/dist/{chunk-UHRZ324M.js → chunk-BGRTZOJB.js} +3 -3
  110. package/dist/{chunk-ZEGL7YCC.js → chunk-BXIJSPCL.js} +2 -2
  111. package/dist/{chunk-JKKII6GX.js → chunk-BYQX4IOG.js} +2 -2
  112. package/dist/{chunk-WIWLX65T.js → chunk-C5R73BON.js} +2 -2
  113. package/dist/{chunk-BD7JTBYP.js → chunk-D7MAYFQP.js} +2 -2
  114. package/dist/{chunk-TNZNSMVJ.js → chunk-DAZANIYU.js} +249 -295
  115. package/dist/chunk-DAZANIYU.js.map +1 -0
  116. package/dist/{chunk-LMLGBG6H.js → chunk-DFVSJFHK.js} +2 -2
  117. package/dist/{chunk-3NPNBVFR.js → chunk-ES5BUPYB.js} +2 -2
  118. package/dist/{chunk-MVAQ2WM3.js → chunk-G2XZFGYN.js} +6 -2
  119. package/dist/chunk-G2XZFGYN.js.map +1 -0
  120. package/dist/{chunk-TNSCIPBQ.js → chunk-G6NQ3L4T.js} +2 -2
  121. package/dist/{chunk-5N4MZLEH.js → chunk-GO5LOHCD.js} +2 -2
  122. package/dist/{chunk-AECJY3GJ.js → chunk-GSSDHAYH.js} +2 -2
  123. package/dist/{chunk-TSP5WH72.js → chunk-HJUP3K6L.js} +2 -2
  124. package/dist/{chunk-AAZEKXUP.js → chunk-ICNJ6J46.js} +2 -2
  125. package/dist/{chunk-6EHM2AV7.js → chunk-IMBQFHRV.js} +2 -2
  126. package/dist/{chunk-4RZLTZVM.js → chunk-IOPIGX7Y.js} +1 -1
  127. package/dist/{chunk-EYKIDK33.js → chunk-IS2IDFJP.js} +13 -13
  128. package/dist/{chunk-VJIE4D2I.js → chunk-J4WGTN2N.js} +2 -2
  129. package/dist/{chunk-NXGSONWM.js → chunk-J7FVMLBR.js} +2 -2
  130. package/dist/{chunk-VSL63CFJ.js → chunk-JAJIMTFB.js} +6 -6
  131. package/dist/{chunk-4JVQRFZD.js → chunk-JOP7W24J.js} +9 -9
  132. package/dist/{chunk-YUW66UAH.js → chunk-JUDT33RX.js} +2 -2
  133. package/dist/{chunk-QHT7MOUF.js → chunk-K4A6UVPB.js} +22 -11
  134. package/dist/chunk-K4A6UVPB.js.map +1 -0
  135. package/dist/{chunk-D545Z7UH.js → chunk-K4JKAXMO.js} +2 -2
  136. package/dist/{chunk-BV4ZKIZH.js → chunk-K75A5XWU.js} +3 -2
  137. package/dist/{chunk-3CBI2ZSA.js → chunk-KG2OOAFF.js} +20 -12
  138. package/dist/chunk-KG2OOAFF.js.map +1 -0
  139. package/dist/{chunk-M6HBPLBA.js → chunk-KOTG3RXE.js} +2 -2
  140. package/dist/{chunk-CWTCMZGE.js → chunk-KTOXQMW3.js} +119 -3
  141. package/dist/chunk-KTOXQMW3.js.map +1 -0
  142. package/dist/{chunk-OB3XMWX5.js → chunk-KVO2BTA4.js} +2 -2
  143. package/dist/{chunk-GI4ZBWPQ.js → chunk-KY236SP5.js} +3 -3
  144. package/dist/{chunk-4BCHFSC7.js → chunk-LFVZD5EC.js} +3 -3
  145. package/dist/{chunk-O4M4BDIJ.js → chunk-LKFVVN7R.js} +2 -2
  146. package/dist/{chunk-IYKZJVL5.js → chunk-MDIEES23.js} +1 -1
  147. package/dist/chunk-MDIEES23.js.map +1 -0
  148. package/dist/{chunk-4RX5O34R.js → chunk-MJC7UKH7.js} +2 -2
  149. package/dist/{chunk-CZTPU65V.js → chunk-MVG3KXON.js} +63 -16
  150. package/dist/chunk-MVG3KXON.js.map +1 -0
  151. package/dist/{chunk-YDVAM7S4.js → chunk-NETQXOPY.js} +2 -2
  152. package/dist/chunk-NETQXOPY.js.map +1 -0
  153. package/dist/{chunk-UZZ7SQT3.js → chunk-NVVZPBKI.js} +2 -2
  154. package/dist/{chunk-BLDBT6HZ.js → chunk-PJRKLB4Z.js} +18 -2
  155. package/dist/chunk-PJRKLB4Z.js.map +1 -0
  156. package/dist/{chunk-VBSNUH4J.js → chunk-PKUJNICO.js} +2 -2
  157. package/dist/{chunk-OPBFP4TF.js → chunk-QE6YVNP5.js} +7 -7
  158. package/dist/{chunk-WKDFJXW5.js → chunk-QM2SPLKQ.js} +1 -1
  159. package/dist/chunk-QM2SPLKQ.js.map +1 -0
  160. package/dist/{chunk-ENBPQEVU.js → chunk-QPVNK2VE.js} +2 -2
  161. package/dist/{chunk-RLJHJQUY.js → chunk-QS5Q5RBV.js} +2 -2
  162. package/dist/{chunk-3EKVN2OP.js → chunk-RDLPFM7I.js} +2 -2
  163. package/dist/{chunk-F4EHXVP7.js → chunk-RJQAP333.js} +2 -2
  164. package/dist/{chunk-QTQ6XKGT.js → chunk-RLU2Y5GV.js} +4 -4
  165. package/dist/chunk-RLU2Y5GV.js.map +1 -0
  166. package/dist/{chunk-5SPCMAUC.js → chunk-ROEFLU37.js} +4 -4
  167. package/dist/{chunk-UZEHHXYC.js → chunk-SFHLQPBF.js} +22 -22
  168. package/dist/chunk-SK7D34OL.js +68 -0
  169. package/dist/chunk-SK7D34OL.js.map +1 -0
  170. package/dist/{chunk-ZBW7A667.js → chunk-SUEOG2S4.js} +2 -2
  171. package/dist/{chunk-Q7CLGFA7.js → chunk-TEMKBSV6.js} +2 -2
  172. package/dist/{chunk-LQNRVPTV.js → chunk-THTF2W7M.js} +151 -118
  173. package/dist/chunk-THTF2W7M.js.map +1 -0
  174. package/dist/{chunk-GMIQV6DD.js → chunk-TO36VPZI.js} +2 -2
  175. package/dist/{chunk-6YAIN5XJ.js → chunk-TZ44E732.js} +44 -6
  176. package/dist/chunk-TZ44E732.js.map +1 -0
  177. package/dist/{chunk-JXN77SGO.js → chunk-U2VDCFXW.js} +1 -1
  178. package/dist/chunk-U2VDCFXW.js.map +1 -0
  179. package/dist/{chunk-LPYYY4AP.js → chunk-UZ6JYPJ6.js} +500 -218
  180. package/dist/chunk-UZ6JYPJ6.js.map +1 -0
  181. package/dist/{chunk-FXHOZGSE.js → chunk-V2ZA4YWE.js} +2 -2
  182. package/dist/{chunk-XH3HGI2N.js → chunk-VHKXRYQN.js} +2 -2
  183. package/dist/{chunk-GAS7KYC7.js → chunk-VKWFNPBH.js} +2 -2
  184. package/dist/{chunk-6H2G7RFT.js → chunk-VNQRRUNS.js} +11 -10
  185. package/dist/chunk-VNQRRUNS.js.map +1 -0
  186. package/dist/{chunk-IL6ODG6M.js → chunk-VQWBUPSJ.js} +2 -2
  187. package/dist/{chunk-5YCNDC3C.js → chunk-VQYWKCDR.js} +2 -2
  188. package/dist/{chunk-54NX5EG4.js → chunk-W23JARAQ.js} +2 -2
  189. package/dist/{chunk-YQNNHLCG.js → chunk-WPGR3RW4.js} +2 -2
  190. package/dist/{chunk-FNHLI2RE.js → chunk-WZYHPAG5.js} +3 -3
  191. package/dist/{chunk-5HYUUFMQ.js → chunk-XCPNH2MG.js} +259 -10
  192. package/dist/chunk-XCPNH2MG.js.map +1 -0
  193. package/dist/{chunk-TA4C3XB7.js → chunk-XM46Y66S.js} +2 -2
  194. package/dist/{chunk-PCOVEDPK.js → chunk-YRIFXXMI.js} +3 -3
  195. package/dist/{chunk-TRLOFIQC.js → chunk-YTK5MVNF.js} +2 -2
  196. package/dist/{chunk-Q432REND.js → chunk-YTZN2UZO.js} +2 -2
  197. package/dist/{chunk-6AGWBKQU.js → chunk-Z4GUX2M6.js} +2 -2
  198. package/dist/{chunk-AENM6GKU.js → chunk-ZAEPD4C2.js} +2 -2
  199. package/dist/{chunk-KQW3YGEN.js → chunk-ZRMMXWYI.js} +2 -2
  200. package/dist/{chunk-P4ZAEYKG.js → chunk-ZX3AYNNV.js} +6 -3
  201. package/dist/chunk-ZX3AYNNV.js.map +1 -0
  202. package/dist/{chunk-MCRVQ5YQ.js → chunk-ZZCR2QYL.js} +2 -2
  203. package/dist/{cli-DGq0MNpO.d.ts → cli-BWri5-am.d.ts} +5 -5
  204. package/dist/cli.d.ts +18 -16
  205. package/dist/cli.js +75 -74
  206. package/dist/coding/export-okf-codegraph.d.ts +1 -1
  207. package/dist/coding/export-okf-codegraph.js +14 -14
  208. package/dist/coding/pre-action-gate.d.ts +1 -1
  209. package/dist/compounding/engine.d.ts +2 -2
  210. package/dist/compounding/engine.js +15 -15
  211. package/dist/compounding/preference-consolidator.d.ts +1 -1
  212. package/dist/compression-optimizer.d.ts +1 -1
  213. package/dist/config.d.ts +1 -1
  214. package/dist/config.js +6 -5
  215. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  216. package/dist/connectors/codex-materialize-runner.js +15 -15
  217. package/dist/connectors/codex-materialize.d.ts +1 -1
  218. package/dist/connectors/index.d.ts +1 -1
  219. package/dist/connectors/index.js +15 -15
  220. package/dist/consolidation-provenance-check.d.ts +2 -2
  221. package/dist/consolidation-undo.d.ts +2 -2
  222. package/dist/contradiction/index.d.ts +6 -5
  223. package/dist/converge-config.d.ts +1 -1
  224. package/dist/convergence-refresh.d.ts +2 -2
  225. package/dist/convergence-refresh.js +17 -17
  226. package/dist/conversation-index/backend.d.ts +1 -1
  227. package/dist/conversation-index/chunker.d.ts +1 -1
  228. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  229. package/dist/conversation-index/indexer.d.ts +1 -1
  230. package/dist/conversation-index/search.d.ts +1 -1
  231. package/dist/corpus-watermark.d.ts +1 -1
  232. package/dist/corpus-watermark.js +17 -17
  233. package/dist/cross-lingual-recall.d.ts +1 -1
  234. package/dist/day-summary.d.ts +1 -1
  235. package/dist/deep-recall-http-glue.d.ts +16 -14
  236. package/dist/deep-recall-http-glue.js +2 -2
  237. package/dist/deep-recall-mcp-tools.d.ts +16 -14
  238. package/dist/deep-recall-policy-llm.d.ts +4 -3
  239. package/dist/deep-recall-policy-llm.js +3 -3
  240. package/dist/deep-recall-seeds.d.ts +1 -1
  241. package/dist/delinearize.d.ts +1 -1
  242. package/dist/dependency-propagation-config.d.ts +1 -1
  243. package/dist/{dependency-propagation-delivery-Cq1ekOwV.d.ts → dependency-propagation-delivery-ueZlKTQB.d.ts} +1 -1
  244. package/dist/direct-answer-wiring.d.ts +1 -1
  245. package/dist/direct-answer.d.ts +1 -1
  246. package/dist/embedding-fallback.d.ts +1 -1
  247. package/dist/enrichment/index.d.ts +1 -1
  248. package/dist/entity-origin-fields.d.ts +1 -1
  249. package/dist/entity-retrieval.d.ts +2 -2
  250. package/dist/entity-retrieval.js +15 -15
  251. package/dist/entity-schema.d.ts +1 -1
  252. package/dist/episodic-context.d.ts +1 -1
  253. package/dist/eval-trajectory-contracts.d.ts +1 -1
  254. package/dist/eval-trajectory-store.d.ts +1 -1
  255. package/dist/eval-trajectory.d.ts +1 -1
  256. package/dist/explicit-capture.d.ts +13 -12
  257. package/dist/external-wiki-access.d.ts +16 -14
  258. package/dist/external-wiki-access.js +38 -38
  259. package/dist/external-wiki-collection-registration.d.ts +1 -1
  260. package/dist/external-wiki-collection.d.ts +1 -1
  261. package/dist/external-wiki-mcp-tools.d.ts +16 -14
  262. package/dist/extraction-error-classification.d.ts +14 -3
  263. package/dist/extraction-error-classification.js +5 -3
  264. package/dist/extraction-faithfulness.d.ts +4 -3
  265. package/dist/extraction-faithfulness.js +3 -3
  266. package/dist/extraction-judge-telemetry.d.ts +4 -3
  267. package/dist/extraction-judge-training.d.ts +4 -3
  268. package/dist/extraction-judge.d.ts +4 -3
  269. package/dist/extraction-judge.js +3 -3
  270. package/dist/extraction-liveness.d.ts +1 -1
  271. package/dist/extraction-normalization.d.ts +1 -1
  272. package/dist/extraction-prompt.d.ts +1 -1
  273. package/dist/extraction-source-grounding-rules.d.ts +1 -1
  274. package/dist/extraction-source-grounding.d.ts +1 -1
  275. package/dist/extraction-span-config.d.ts +1 -1
  276. package/dist/extraction-span-materialize.d.ts +1 -1
  277. package/dist/extraction.d.ts +4 -4
  278. package/dist/extraction.js +25 -23
  279. package/dist/fallback-llm-codex-subscription.d.ts +52 -7
  280. package/dist/fallback-llm-codex-subscription.js +17 -1
  281. package/dist/fallback-llm.d.ts +25 -28
  282. package/dist/fallback-llm.js +4 -3
  283. package/dist/{generic-recall-paths-BcySh_f9.d.ts → generic-recall-paths-CpyVmA88.d.ts} +1 -1
  284. package/dist/graph-append-error.d.ts +1 -1
  285. package/dist/graph-dashboard-diff.d.ts +1 -1
  286. package/dist/graph-dashboard-key.d.ts +1 -1
  287. package/dist/graph-dashboard-parser.d.ts +1 -1
  288. package/dist/graph-edge-reinforcement.d.ts +1 -1
  289. package/dist/graph-jsonl.d.ts +1 -1
  290. package/dist/graph-path-reconstruction.d.ts +1 -1
  291. package/dist/graph-path-scoring.d.ts +1 -1
  292. package/dist/graph-snapshot.d.ts +1 -1
  293. package/dist/graph.d.ts +1 -1
  294. package/dist/harmonic-retrieval.js +1 -1
  295. package/dist/importance.d.ts +1 -1
  296. package/dist/importers/index.d.ts +1 -1
  297. package/dist/importers/test-utils.d.ts +1 -1
  298. package/dist/in-flight-reads.d.ts +1 -1
  299. package/dist/{index-DWOb4wz9.d.ts → index-BvUA4S7M.d.ts} +3 -3
  300. package/dist/index.d.ts +79 -39
  301. package/dist/index.js +119 -103
  302. package/dist/intent.d.ts +1 -1
  303. package/dist/lcm/engine.d.ts +1 -1
  304. package/dist/lcm/index.d.ts +1 -1
  305. package/dist/lcm/index.js +3 -3
  306. package/dist/lcm/tools.d.ts +1 -1
  307. package/dist/lifecycle.d.ts +1 -1
  308. package/dist/live-connectors-runner.d.ts +1 -1
  309. package/dist/local-llm-BsJGulur.d.ts +247 -0
  310. package/dist/local-llm-config.d.ts +4 -1
  311. package/dist/local-llm-config.js +4 -2
  312. package/dist/local-llm-helpers.d.ts +18 -69
  313. package/dist/local-llm-helpers.js +1 -1
  314. package/dist/local-llm.d.ts +3 -170
  315. package/dist/local-llm.js +2 -2
  316. package/dist/local-model-endpoint.d.ts +1 -1
  317. package/dist/location/index.d.ts +3 -3
  318. package/dist/location/index.js +17 -17
  319. package/dist/maintenance/memory-governance.d.ts +1 -1
  320. package/dist/maintenance/memory-governance.js +15 -15
  321. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
  322. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +15 -15
  323. package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
  324. package/dist/maintenance/rebuild-memory-projection.js +16 -16
  325. package/dist/{maintenance-CW9wCzMP.d.ts → maintenance-CYubtIRr.d.ts} +9 -3
  326. package/dist/mcp-memory-inspector-app.d.ts +16 -14
  327. package/dist/memory-action-policy.d.ts +1 -1
  328. package/dist/memory-cache.d.ts +1 -1
  329. package/dist/memory-controller.d.ts +1 -1
  330. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  331. package/dist/memory-projection-store.d.ts +1 -1
  332. package/dist/memory-provenance.d.ts +1 -1
  333. package/dist/memory-snapshot.d.ts +1 -1
  334. package/dist/memory-subject-cli.d.ts +16 -14
  335. package/dist/memory-subject.d.ts +16 -14
  336. package/dist/memory-worth-outcomes.d.ts +2 -2
  337. package/dist/models-json.d.ts +1 -1
  338. package/dist/namespaces/migrate.d.ts +3 -3
  339. package/dist/namespaces/migrate.js +16 -16
  340. package/dist/namespaces/principal.d.ts +1 -1
  341. package/dist/namespaces/search.d.ts +12 -1
  342. package/dist/namespaces/search.js +9 -9
  343. package/dist/namespaces/storage.d.ts +3 -3
  344. package/dist/namespaces/storage.js +15 -15
  345. package/dist/native-knowledge.d.ts +1 -1
  346. package/dist/offline-sync-impression-drain.d.ts +1 -1
  347. package/dist/operator-doctor-corpus.d.ts +1 -1
  348. package/dist/operator-doctor-corpus.js +18 -18
  349. package/dist/operator-doctor-replica.d.ts +1 -1
  350. package/dist/operator-toolkit.d.ts +3 -3
  351. package/dist/operator-toolkit.js +29 -28
  352. package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
  353. package/dist/orchestration/maintenance.d.ts +4 -4
  354. package/dist/orchestration/maintenance.js +26 -26
  355. package/dist/{orchestrator-ComHLm49.d.ts → orchestrator-BWDRJ_0d.d.ts} +24 -11
  356. package/dist/orchestrator.d.ts +13 -12
  357. package/dist/orchestrator.js +101 -98
  358. package/dist/patterns-cli.d.ts +1 -1
  359. package/dist/{pipeline-CiYcqqhl.d.ts → pipeline-7JMn2yMH.d.ts} +1 -1
  360. package/dist/policy-runtime.d.ts +1 -1
  361. package/dist/proactive-contention.d.ts +2 -2
  362. package/dist/provenance.d.ts +1 -1
  363. package/dist/{public-http-CuK4_Cb1.d.ts → public-http-CJWs3mo9.d.ts} +1 -1
  364. package/dist/{qmd-qXD4vatU.d.ts → qmd-CxCH9G9m.d.ts} +2 -2
  365. package/dist/qmd-preflight.d.ts +2 -2
  366. package/dist/qmd-recall-cache.d.ts +1 -1
  367. package/dist/qmd.d.ts +2 -2
  368. package/dist/qmd.js +2 -2
  369. package/dist/recall-concurrency-config.d.ts +1 -1
  370. package/dist/recall-disclosure-escalation.d.ts +1 -1
  371. package/dist/recall-explain-renderer.d.ts +1 -1
  372. package/dist/recall-explain-renderer.js +3 -3
  373. package/dist/recall-memory-map.d.ts +1 -1
  374. package/dist/recall-navigate-access.d.ts +1 -1
  375. package/dist/recall-navigate-access.js +2 -2
  376. package/dist/recall-navigate-disclosure.d.ts +1 -1
  377. package/dist/recall-navigate-disclosure.js +1 -1
  378. package/dist/recall-navigate.d.ts +1 -1
  379. package/dist/recall-navigate.js +2 -2
  380. package/dist/recall-planner-llm.d.ts +3 -2
  381. package/dist/recall-planner-llm.js +4 -3
  382. package/dist/recall-planner-llm.js.map +1 -1
  383. package/dist/recall-state-view-admission.d.ts +13 -3
  384. package/dist/recall-state-view-admission.js +8 -8
  385. package/dist/recall-state-view-anchors.d.ts +1 -1
  386. package/dist/recall-state-view-anchors.js +2 -2
  387. package/dist/recall-state-view-inject.js +2 -2
  388. package/dist/recall-state-view-render.js +2 -2
  389. package/dist/recall-state-view-widen.js +2 -2
  390. package/dist/recall-state-view-wire.js +3 -3
  391. package/dist/recall-state-view.d.ts +1 -0
  392. package/dist/recall-state-view.js +1 -1
  393. package/dist/recall-state.d.ts +1 -1
  394. package/dist/recall-tag-filter.d.ts +1 -1
  395. package/dist/recall-timings.d.ts +1 -1
  396. package/dist/recall-xray-cli.d.ts +1 -1
  397. package/dist/recall-xray-cli.js +4 -4
  398. package/dist/recall-xray-renderer.d.ts +1 -1
  399. package/dist/recall-xray-renderer.js +3 -3
  400. package/dist/recall-xray.d.ts +1 -1
  401. package/dist/recall-xray.js +2 -2
  402. package/dist/reconcile/cursor.d.ts +1 -1
  403. package/dist/reconcile/manifest.d.ts +1 -1
  404. package/dist/reconcile/plan.d.ts +1 -1
  405. package/dist/replay/normalizers/chatgpt.d.ts +1 -1
  406. package/dist/replay/normalizers/claude.d.ts +1 -1
  407. package/dist/replay/normalizers/openclaw.d.ts +1 -1
  408. package/dist/replay/normalizers/shared.d.ts +1 -1
  409. package/dist/replay/runner.d.ts +1 -1
  410. package/dist/replay/types.d.ts +1 -1
  411. package/dist/replica-divergence.d.ts +1 -1
  412. package/dist/replica-peers-config.d.ts +1 -1
  413. package/dist/resolve-auth-token.d.ts +1 -1
  414. package/dist/resume-bundles.js +7 -6
  415. package/dist/retrieval-agents.d.ts +2 -2
  416. package/dist/retrieval-tiers.d.ts +1 -1
  417. package/dist/routing/engine.d.ts +1 -1
  418. package/dist/routing/store.d.ts +1 -1
  419. package/dist/salvage-envelope.d.ts +1 -1
  420. package/dist/{scope-profiles-BT9rqC3w.d.ts → scope-profiles-BGAUqhBR.d.ts} +1 -1
  421. package/dist/search/embed-helper.d.ts +1 -1
  422. package/dist/search/factory.d.ts +1 -1
  423. package/dist/search/factory.js +8 -8
  424. package/dist/search/index.d.ts +1 -1
  425. package/dist/search/index.js +10 -10
  426. package/dist/search/lancedb-backend.d.ts +1 -1
  427. package/dist/search/lancedb-backend.js +2 -2
  428. package/dist/search/meilisearch-backend.d.ts +1 -1
  429. package/dist/search/meilisearch-backend.js +2 -2
  430. package/dist/search/noop-backend.d.ts +1 -1
  431. package/dist/search/orama-backend.d.ts +1 -1
  432. package/dist/search/orama-backend.js +2 -2
  433. package/dist/search/port.d.ts +2 -2
  434. package/dist/search/port.js +1 -1
  435. package/dist/search/remote-backend.d.ts +1 -1
  436. package/dist/search/remote-backend.js +2 -2
  437. package/dist/{semantic-consolidation-CmZi7thY.d.ts → semantic-consolidation-CCeRD9pV.d.ts} +1 -1
  438. package/dist/semantic-consolidation.d.ts +2 -2
  439. package/dist/semantic-consolidation.js +16 -16
  440. package/dist/semantic-rule-promotion.js +15 -15
  441. package/dist/semantic-rule-verifier.d.ts +1 -1
  442. package/dist/semantic-rule-verifier.js +15 -15
  443. package/dist/{service-CLkA7AQB.d.ts → service-BwpzRduk.d.ts} +2 -2
  444. package/dist/session-observer-bands.d.ts +1 -1
  445. package/dist/session-observer-state.d.ts +1 -1
  446. package/dist/shared-context/manager.d.ts +1 -1
  447. package/dist/signal.d.ts +1 -1
  448. package/dist/source-agent-qualifier.d.ts +1 -1
  449. package/dist/source-agent-qualifier.js +18 -18
  450. package/dist/standup/build.js +15 -15
  451. package/dist/{storage-wvX01lht.d.ts → storage-BprAGBG0.d.ts} +2 -1
  452. package/dist/storage.d.ts +2 -2
  453. package/dist/storage.js +14 -14
  454. package/dist/subject-config.d.ts +1 -1
  455. package/dist/summarizer.d.ts +1 -1
  456. package/dist/summarizer.js +5 -5
  457. package/dist/summary-snapshot.d.ts +1 -1
  458. package/dist/support-passport/index.d.ts +18 -17
  459. package/dist/support-passport/index.js +40 -40
  460. package/dist/task-llm-config.d.ts +16 -0
  461. package/dist/task-llm-config.js +12 -0
  462. package/dist/task-llm-config.js.map +1 -0
  463. package/dist/temporal-supersession.d.ts +2 -2
  464. package/dist/temporal-timeline-recall.d.ts +1 -1
  465. package/dist/temporal-validity.d.ts +1 -1
  466. package/dist/threading.d.ts +1 -1
  467. package/dist/tier-migration.d.ts +2 -2
  468. package/dist/tier-routing.d.ts +1 -1
  469. package/dist/topics.d.ts +1 -1
  470. package/dist/transcript.d.ts +1 -1
  471. package/dist/transfer/export-okf.d.ts +1 -1
  472. package/dist/transfer/export-okf.js +15 -15
  473. package/dist/trust-score-stage.d.ts +1 -1
  474. package/dist/trust-score.d.ts +1 -1
  475. package/dist/{types-Cyr32ABj.d.ts → types-nJV23pa3.d.ts} +1 -1
  476. package/dist/types.d.ts +1 -1
  477. package/dist/types.js +1 -1
  478. package/dist/utility-runtime.d.ts +1 -1
  479. package/dist/verified-recall.js +15 -15
  480. package/dist/who-knows-cli.d.ts +16 -14
  481. package/dist/who-knows-cli.js +16 -16
  482. package/dist/who-knows.d.ts +16 -14
  483. package/dist/who-knows.js +15 -15
  484. package/dist/write-envelope.d.ts +1 -1
  485. package/package.json +2 -2
  486. package/src/access-category-alias.test.ts +93 -0
  487. package/src/access-offline-manifest.ts +52 -2
  488. package/src/access-schema.ts +9 -4
  489. package/src/activity/config.test.ts +61 -0
  490. package/src/activity/config.ts +40 -1
  491. package/src/activity/timeline/analysis-provider.ts +8 -2
  492. package/src/activity/timeline/analysis-run.test.ts +82 -0
  493. package/src/activity/timeline/publish-cli.test.ts +30 -0
  494. package/src/activity/timeline/publish-cli.ts +7 -0
  495. package/src/activity/timeline/query.ts +8 -1
  496. package/src/activity/timeline/regenerate.test.ts +82 -2
  497. package/src/activity/timeline/regenerate.ts +7 -1
  498. package/src/activity/vault-frontmatter.test.ts +99 -1
  499. package/src/activity/vault-frontmatter.ts +131 -0
  500. package/src/activity/vault-publish.ts +6 -0
  501. package/src/activity/vault-publisher.test.ts +172 -0
  502. package/src/activity/vault-publisher.ts +69 -15
  503. package/src/activity/vault-region.test.ts +7 -2
  504. package/src/activity/vault-region.ts +7 -3
  505. package/src/background-generation-config.ts +32 -6
  506. package/src/background-generation.test.ts +10 -1
  507. package/src/cli/timeline-publish-commands.ts +9 -0
  508. package/src/config.test.ts +170 -43
  509. package/src/config.ts +17 -5
  510. package/src/extraction-error-classification.ts +36 -1
  511. package/src/extraction-timeout.test.ts +110 -1
  512. package/src/extraction.test.ts +19 -1
  513. package/src/extraction.ts +23 -21
  514. package/src/fallback-llm-codex-subscription.ts +193 -7
  515. package/src/fallback-llm-parse-failure.test.ts +156 -0
  516. package/src/fallback-llm.test.ts +58 -0
  517. package/src/fallback-llm.ts +187 -186
  518. package/src/index.ts +1 -0
  519. package/src/local-llm-config.ts +11 -10
  520. package/src/local-llm-headers-timeout.test.ts +30 -0
  521. package/src/local-llm-helpers.ts +28 -0
  522. package/src/local-llm.ts +8 -19
  523. package/src/namespaces/search.test.ts +51 -1
  524. package/src/namespaces/search.ts +48 -3
  525. package/src/orchestration/extraction-persist-promotion.test.ts +228 -2
  526. package/src/orchestration/extraction-persist-promotion.ts +17 -14
  527. package/src/orchestration/orchestrator-helpers.test.ts +104 -0
  528. package/src/orchestration/orchestrator-init.ts +366 -106
  529. package/src/orchestration/recall-internal.ts +5 -11
  530. package/src/orchestration/semantic-merge-promotion-payload.ts +62 -6
  531. package/src/orchestration/startup-collection-checks.ts +85 -0
  532. package/src/orchestrator-flush.test.ts +7 -0
  533. package/src/orchestrator-init.test.ts +1539 -0
  534. package/src/orchestrator.ts +7 -0
  535. package/src/qmd.ts +21 -10
  536. package/src/recall-state-view-admission.ts +11 -1
  537. package/src/recall-state-view-cron-intent.test.ts +268 -0
  538. package/src/recall-state-view-widen.test.ts +14 -5
  539. package/src/recall-state-view-widen.ts +8 -1
  540. package/src/recall-state-view.ts +5 -2
  541. package/src/reconcile-identity-cache.test.ts +82 -1
  542. package/src/search/port.ts +1 -1
  543. package/src/storage/cas-revision-store.test.ts +4 -0
  544. package/src/storage/cas-revision-store.ts +104 -12
  545. package/src/storage-frontmatter-cas.test.ts +19 -17
  546. package/src/summarizer.ts +5 -1
  547. package/src/task-llm-config.test.ts +124 -0
  548. package/src/task-llm-config.ts +88 -0
  549. package/src/testing/subjects/startup-discovery-lifecycle.test.ts +273 -0
  550. package/src/types.ts +1 -0
  551. package/dist/chunk-3CBI2ZSA.js.map +0 -1
  552. package/dist/chunk-5HYUUFMQ.js.map +0 -1
  553. package/dist/chunk-6H2G7RFT.js.map +0 -1
  554. package/dist/chunk-6YAIN5XJ.js.map +0 -1
  555. package/dist/chunk-ACY4ZPF7.js.map +0 -1
  556. package/dist/chunk-B36GUU6T.js.map +0 -1
  557. package/dist/chunk-BLDBT6HZ.js.map +0 -1
  558. package/dist/chunk-CWTCMZGE.js.map +0 -1
  559. package/dist/chunk-CZTPU65V.js.map +0 -1
  560. package/dist/chunk-FWWWUPOE.js.map +0 -1
  561. package/dist/chunk-IQEJIOEU.js.map +0 -1
  562. package/dist/chunk-IYKZJVL5.js.map +0 -1
  563. package/dist/chunk-JXN77SGO.js.map +0 -1
  564. package/dist/chunk-LPYYY4AP.js.map +0 -1
  565. package/dist/chunk-LQNRVPTV.js.map +0 -1
  566. package/dist/chunk-MVAQ2WM3.js.map +0 -1
  567. package/dist/chunk-P4ZAEYKG.js.map +0 -1
  568. package/dist/chunk-QHT7MOUF.js.map +0 -1
  569. package/dist/chunk-QTQ6XKGT.js.map +0 -1
  570. package/dist/chunk-TNZNSMVJ.js.map +0 -1
  571. package/dist/chunk-WKDFJXW5.js.map +0 -1
  572. package/dist/chunk-YDVAM7S4.js.map +0 -1
  573. package/dist/chunk-YFTNZMGR.js.map +0 -1
  574. package/dist/chunk-YKREX63Z.js.map +0 -1
  575. /package/dist/{auto-sync-RP4C6ZPF.js.map → auto-sync-D6BAPIJV.js.map} +0 -0
  576. /package/dist/{chunk-JTQR6L2N.js.map → chunk-2SKMZUOW.js.map} +0 -0
  577. /package/dist/{chunk-GG5FHZJJ.js.map → chunk-2SNCQHJZ.js.map} +0 -0
  578. /package/dist/{chunk-O76F5QPP.js.map → chunk-3QEVOQF5.js.map} +0 -0
  579. /package/dist/{chunk-3N3PBBEH.js.map → chunk-3XPN7AVY.js.map} +0 -0
  580. /package/dist/{chunk-X4TD4O2F.js.map → chunk-46Z3VGWF.js.map} +0 -0
  581. /package/dist/{chunk-2ZTDRNCS.js.map → chunk-4CMXI55L.js.map} +0 -0
  582. /package/dist/{chunk-MUTVRKKY.js.map → chunk-7D6SER6A.js.map} +0 -0
  583. /package/dist/{chunk-WBM2MVBK.js.map → chunk-7Z54NXVS.js.map} +0 -0
  584. /package/dist/{chunk-UHRZ324M.js.map → chunk-BGRTZOJB.js.map} +0 -0
  585. /package/dist/{chunk-ZEGL7YCC.js.map → chunk-BXIJSPCL.js.map} +0 -0
  586. /package/dist/{chunk-JKKII6GX.js.map → chunk-BYQX4IOG.js.map} +0 -0
  587. /package/dist/{chunk-WIWLX65T.js.map → chunk-C5R73BON.js.map} +0 -0
  588. /package/dist/{chunk-BD7JTBYP.js.map → chunk-D7MAYFQP.js.map} +0 -0
  589. /package/dist/{chunk-LMLGBG6H.js.map → chunk-DFVSJFHK.js.map} +0 -0
  590. /package/dist/{chunk-3NPNBVFR.js.map → chunk-ES5BUPYB.js.map} +0 -0
  591. /package/dist/{chunk-TNSCIPBQ.js.map → chunk-G6NQ3L4T.js.map} +0 -0
  592. /package/dist/{chunk-5N4MZLEH.js.map → chunk-GO5LOHCD.js.map} +0 -0
  593. /package/dist/{chunk-AECJY3GJ.js.map → chunk-GSSDHAYH.js.map} +0 -0
  594. /package/dist/{chunk-TSP5WH72.js.map → chunk-HJUP3K6L.js.map} +0 -0
  595. /package/dist/{chunk-AAZEKXUP.js.map → chunk-ICNJ6J46.js.map} +0 -0
  596. /package/dist/{chunk-6EHM2AV7.js.map → chunk-IMBQFHRV.js.map} +0 -0
  597. /package/dist/{chunk-4RZLTZVM.js.map → chunk-IOPIGX7Y.js.map} +0 -0
  598. /package/dist/{chunk-EYKIDK33.js.map → chunk-IS2IDFJP.js.map} +0 -0
  599. /package/dist/{chunk-VJIE4D2I.js.map → chunk-J4WGTN2N.js.map} +0 -0
  600. /package/dist/{chunk-NXGSONWM.js.map → chunk-J7FVMLBR.js.map} +0 -0
  601. /package/dist/{chunk-VSL63CFJ.js.map → chunk-JAJIMTFB.js.map} +0 -0
  602. /package/dist/{chunk-4JVQRFZD.js.map → chunk-JOP7W24J.js.map} +0 -0
  603. /package/dist/{chunk-YUW66UAH.js.map → chunk-JUDT33RX.js.map} +0 -0
  604. /package/dist/{chunk-D545Z7UH.js.map → chunk-K4JKAXMO.js.map} +0 -0
  605. /package/dist/{chunk-BV4ZKIZH.js.map → chunk-K75A5XWU.js.map} +0 -0
  606. /package/dist/{chunk-M6HBPLBA.js.map → chunk-KOTG3RXE.js.map} +0 -0
  607. /package/dist/{chunk-OB3XMWX5.js.map → chunk-KVO2BTA4.js.map} +0 -0
  608. /package/dist/{chunk-GI4ZBWPQ.js.map → chunk-KY236SP5.js.map} +0 -0
  609. /package/dist/{chunk-4BCHFSC7.js.map → chunk-LFVZD5EC.js.map} +0 -0
  610. /package/dist/{chunk-O4M4BDIJ.js.map → chunk-LKFVVN7R.js.map} +0 -0
  611. /package/dist/{chunk-4RX5O34R.js.map → chunk-MJC7UKH7.js.map} +0 -0
  612. /package/dist/{chunk-UZZ7SQT3.js.map → chunk-NVVZPBKI.js.map} +0 -0
  613. /package/dist/{chunk-VBSNUH4J.js.map → chunk-PKUJNICO.js.map} +0 -0
  614. /package/dist/{chunk-OPBFP4TF.js.map → chunk-QE6YVNP5.js.map} +0 -0
  615. /package/dist/{chunk-ENBPQEVU.js.map → chunk-QPVNK2VE.js.map} +0 -0
  616. /package/dist/{chunk-RLJHJQUY.js.map → chunk-QS5Q5RBV.js.map} +0 -0
  617. /package/dist/{chunk-3EKVN2OP.js.map → chunk-RDLPFM7I.js.map} +0 -0
  618. /package/dist/{chunk-F4EHXVP7.js.map → chunk-RJQAP333.js.map} +0 -0
  619. /package/dist/{chunk-5SPCMAUC.js.map → chunk-ROEFLU37.js.map} +0 -0
  620. /package/dist/{chunk-UZEHHXYC.js.map → chunk-SFHLQPBF.js.map} +0 -0
  621. /package/dist/{chunk-ZBW7A667.js.map → chunk-SUEOG2S4.js.map} +0 -0
  622. /package/dist/{chunk-Q7CLGFA7.js.map → chunk-TEMKBSV6.js.map} +0 -0
  623. /package/dist/{chunk-GMIQV6DD.js.map → chunk-TO36VPZI.js.map} +0 -0
  624. /package/dist/{chunk-FXHOZGSE.js.map → chunk-V2ZA4YWE.js.map} +0 -0
  625. /package/dist/{chunk-XH3HGI2N.js.map → chunk-VHKXRYQN.js.map} +0 -0
  626. /package/dist/{chunk-GAS7KYC7.js.map → chunk-VKWFNPBH.js.map} +0 -0
  627. /package/dist/{chunk-IL6ODG6M.js.map → chunk-VQWBUPSJ.js.map} +0 -0
  628. /package/dist/{chunk-5YCNDC3C.js.map → chunk-VQYWKCDR.js.map} +0 -0
  629. /package/dist/{chunk-54NX5EG4.js.map → chunk-W23JARAQ.js.map} +0 -0
  630. /package/dist/{chunk-YQNNHLCG.js.map → chunk-WPGR3RW4.js.map} +0 -0
  631. /package/dist/{chunk-FNHLI2RE.js.map → chunk-WZYHPAG5.js.map} +0 -0
  632. /package/dist/{chunk-TA4C3XB7.js.map → chunk-XM46Y66S.js.map} +0 -0
  633. /package/dist/{chunk-PCOVEDPK.js.map → chunk-YRIFXXMI.js.map} +0 -0
  634. /package/dist/{chunk-TRLOFIQC.js.map → chunk-YTK5MVNF.js.map} +0 -0
  635. /package/dist/{chunk-Q432REND.js.map → chunk-YTZN2UZO.js.map} +0 -0
  636. /package/dist/{chunk-6AGWBKQU.js.map → chunk-Z4GUX2M6.js.map} +0 -0
  637. /package/dist/{chunk-AENM6GKU.js.map → chunk-ZAEPD4C2.js.map} +0 -0
  638. /package/dist/{chunk-KQW3YGEN.js.map → chunk-ZRMMXWYI.js.map} +0 -0
  639. /package/dist/{chunk-MCRVQ5YQ.js.map → chunk-ZZCR2QYL.js.map} +0 -0
@@ -39,14 +39,49 @@ export function classifyExtractionThrownError(err: unknown): ExtractionFailureCl
39
39
  * genuine empty-parse.
40
40
  */
41
41
  export function classifyFallbackParseFailure(
42
- reason: "no_models" | "empty" | "http_error",
42
+ reason: "no_models" | "empty" | "http_error" | "schema_rejection" | "timeout",
43
43
  ): ExtractionFailureClass {
44
44
  switch (reason) {
45
45
  case "no_models":
46
46
  return "auth_config";
47
47
  case "http_error":
48
+ case "timeout":
48
49
  return "provider_retryable";
49
50
  case "empty":
51
+ case "schema_rejection":
50
52
  return "parse_empty";
51
53
  }
52
54
  }
55
+
56
+ /**
57
+ * Operator-visible extraction parse-failure line. Keeps the historical
58
+ * greppable prefix and appends the fields that used to live only at debug.
59
+ */
60
+ export function formatExtractionParseFailureLog(input: {
61
+ failureReason: string;
62
+ attemptedModel?: string;
63
+ httpStatus?: number;
64
+ errorClass?: string;
65
+ traceId: string;
66
+ }): string {
67
+ const modelUsed =
68
+ typeof input.attemptedModel === "string" && input.attemptedModel.length > 0
69
+ ? input.attemptedModel
70
+ : "unknown";
71
+ const errorClass =
72
+ typeof input.errorClass === "string" && input.errorClass.length > 0
73
+ ? input.errorClass
74
+ : "none";
75
+ const httpStatus =
76
+ typeof input.httpStatus === "number" && Number.isFinite(input.httpStatus)
77
+ ? String(input.httpStatus)
78
+ : "none";
79
+ return [
80
+ "extraction fallback returned no parsed output",
81
+ `failureReason=${input.failureReason}`,
82
+ `modelUsed=${modelUsed}`,
83
+ `errorClass=${errorClass}`,
84
+ `httpStatus=${httpStatus}`,
85
+ `traceId=${input.traceId}`,
86
+ ].join(" ");
87
+ }
@@ -3,7 +3,9 @@ import test from "node:test";
3
3
 
4
4
  import { parseConfig } from "./config.js";
5
5
  import { ExtractionEngine } from "./extraction.js";
6
- import type { BufferTurn } from "./types.js";
6
+ import { initLogger, resetLogger } from "./logger.js";
7
+ import type { BufferTurn, ExtractionFailureClass, LlmTraceEvent } from "./types.js";
8
+ import type { StructuredParseFailure } from "./fallback-llm.js";
7
9
 
8
10
  test("gateway extraction fallback honors configured timeout and output budget", async () => {
9
11
  const config = parseConfig({
@@ -320,3 +322,110 @@ test("gateway extraction forwards caller cancellation to the provider", async ()
320
322
  controller.abort(new Error("deadline"));
321
323
  await assert.rejects(extraction, /deadline/);
322
324
  });
325
+
326
+ function gatewayConfig() {
327
+ return {
328
+ modelSource: "gateway" as const,
329
+ gatewayConfig: {
330
+ agents: {
331
+ defaults: { model: { primary: "bench-internal/gpt-5.5" } },
332
+ list: [],
333
+ },
334
+ models: {
335
+ providers: {
336
+ "bench-internal": {
337
+ api: "codex-cli" as const,
338
+ baseUrl: "codex-cli://local",
339
+ models: [{ id: "gpt-5.5", name: "gpt-5.5" }],
340
+ },
341
+ },
342
+ },
343
+ },
344
+ };
345
+ }
346
+
347
+ const RETRYABLE: ReadonlySet<ExtractionFailureClass> = new Set([
348
+ "provider_retryable",
349
+ "parse_empty",
350
+ "auth_config",
351
+ ]);
352
+
353
+ test("extraction warn and llm_error keep failure classes distinct and fingerprints retryable", async () => {
354
+ const cases: Array<{
355
+ failure: StructuredParseFailure;
356
+ expectedClass: ExtractionFailureClass;
357
+ }> = [
358
+ {
359
+ failure: { result: null, failureReason: "empty", attemptedModel: "bench-internal/gpt-5.5", errorClass: "empty" },
360
+ expectedClass: "parse_empty",
361
+ },
362
+ {
363
+ failure: {
364
+ result: null,
365
+ failureReason: "schema_rejection",
366
+ attemptedModel: "bench-internal/gpt-5.5",
367
+ errorClass: "schema_rejection",
368
+ },
369
+ expectedClass: "parse_empty",
370
+ },
371
+ {
372
+ failure: {
373
+ result: null,
374
+ failureReason: "http_error",
375
+ attemptedModel: "bench-internal/gpt-5.5",
376
+ httpStatus: 502,
377
+ errorClass: "http_5xx",
378
+ },
379
+ expectedClass: "provider_retryable",
380
+ },
381
+ {
382
+ failure: { result: null, failureReason: "timeout", errorClass: "timeout" },
383
+ expectedClass: "provider_retryable",
384
+ },
385
+ ];
386
+
387
+ for (const { failure, expectedClass } of cases) {
388
+ const warns: string[] = [];
389
+ const events: LlmTraceEvent[] = [];
390
+ initLogger({ info() {}, warn(msg) { warns.push(msg); }, error() {} }, false, { timestamps: false });
391
+ (globalThis as { __openclawEngramTrace?: (event: LlmTraceEvent) => void }).__openclawEngramTrace = (event) => {
392
+ events.push(event);
393
+ };
394
+ try {
395
+ const engine = new ExtractionEngine(parseConfig(gatewayConfig()));
396
+ (engine as unknown as {
397
+ fallbackLlm: {
398
+ parseWithSchemaDetailed(): Promise<StructuredParseFailure>;
399
+ };
400
+ }).fallbackLlm = {
401
+ async parseWithSchemaDetailed() {
402
+ return failure;
403
+ },
404
+ };
405
+ const result = await engine.extract([
406
+ { role: "user", content: "Remember that the depot is cedar hall.", timestamp: "2026-05-08T00:00:00.000Z" },
407
+ ]);
408
+ assert.equal(result.extractionFailure, "fallback_no_parsed_output");
409
+ assert.equal(result.extractionFailureClass, expectedClass);
410
+ assert.equal(RETRYABLE.has(result.extractionFailureClass ?? "provider_retryable"), true);
411
+ const warn = warns.find((line) => line.includes("extraction fallback returned no parsed output"));
412
+ assert.ok(warn, `missing warn for ${failure.failureReason}`);
413
+ assert.match(warn, new RegExp(`failureReason=${failure.failureReason}`));
414
+ assert.match(warn, /modelUsed=/);
415
+ assert.match(warn, /errorClass=/);
416
+ assert.match(warn, /httpStatus=/);
417
+ assert.match(warn, /traceId=/);
418
+ if (failure.httpStatus !== undefined) {
419
+ assert.match(warn, new RegExp(`httpStatus=${failure.httpStatus}`));
420
+ }
421
+ const errorEvent = events.find((event) => event.kind === "llm_error");
422
+ assert.ok(errorEvent, `missing llm_error for ${failure.failureReason}`);
423
+ assert.match(errorEvent.error ?? "", new RegExp(`failureReason=${failure.failureReason}`));
424
+ assert.match(errorEvent.error ?? "", /traceId=/);
425
+ assert.equal(errorEvent.traceId.length > 0, true);
426
+ } finally {
427
+ resetLogger();
428
+ delete (globalThis as { __openclawEngramTrace?: unknown }).__openclawEngramTrace;
429
+ }
430
+ }
431
+ });
@@ -10,7 +10,7 @@
10
10
  import assert from "node:assert/strict";
11
11
  import test from "node:test";
12
12
 
13
- import { classifyExtractionThrownError, classifyFallbackParseFailure } from "./extraction.js";
13
+ import { classifyExtractionThrownError, classifyFallbackParseFailure, formatExtractionParseFailureLog } from "./extraction.js";
14
14
 
15
15
  test("classifyExtractionThrownError: 401/403 → auth_config", () => {
16
16
  assert.equal(classifyExtractionThrownError({ status: 401 }), "auth_config");
@@ -36,4 +36,22 @@ test("classifyFallbackParseFailure: maps the gateway parse-failure reasons", ()
36
36
  assert.equal(classifyFallbackParseFailure("no_models"), "auth_config");
37
37
  assert.equal(classifyFallbackParseFailure("http_error"), "provider_retryable");
38
38
  assert.equal(classifyFallbackParseFailure("empty"), "parse_empty");
39
+ assert.equal(classifyFallbackParseFailure("schema_rejection"), "parse_empty");
40
+ assert.equal(classifyFallbackParseFailure("timeout"), "provider_retryable");
41
+ });
42
+
43
+ test("formatExtractionParseFailureLog keeps the greppable prefix and distinct fields", () => {
44
+ const line = formatExtractionParseFailureLog({
45
+ failureReason: "http_error",
46
+ attemptedModel: "openai/test-model",
47
+ httpStatus: 502,
48
+ errorClass: "http_5xx",
49
+ traceId: "trace-1",
50
+ });
51
+ assert.match(line, /^extraction fallback returned no parsed output /);
52
+ assert.match(line, /failureReason=http_error/);
53
+ assert.match(line, /modelUsed=openai\/test-model/);
54
+ assert.match(line, /errorClass=http_5xx/);
55
+ assert.match(line, /httpStatus=502/);
56
+ assert.match(line, /traceId=trace-1/);
39
57
  });
package/src/extraction.ts CHANGED
@@ -38,7 +38,8 @@ import {
38
38
  } from "./extraction-source-grounding.js";
39
39
  import { applyGroundingWithConnector, headerConnector, renderExtractionConversation, resolveSourceConnector, type ExtractionGroundingContext } from "./source-agent-qualifier.js";
40
40
  import { isMemoryCategory } from "./write-envelope.js";
41
- import { classifyExtractionThrownError, classifyFallbackParseFailure } from "./extraction-error-classification.js";
41
+ export { classifyExtractionThrownError, classifyFallbackParseFailure, formatExtractionParseFailureLog } from "./extraction-error-classification.js";
42
+ import { classifyExtractionThrownError, classifyFallbackParseFailure, formatExtractionParseFailureLog } from "./extraction-error-classification.js";
42
43
  import { AMBIENT_CAPTURE_PROMPT_SECTION_COMPACT, clampAmbientCaptureConfidence } from "./ambient-provenance.js";
43
44
  import {
44
45
  CONSOLIDATION_RESPONSE_SCHEMA,
@@ -53,22 +54,8 @@ import {
53
54
  spanModePromptSection,
54
55
  } from "./extraction-prompt.js";
55
56
  import { zodToJsonSchema } from "zod-to-json-schema";
56
- import {
57
- containsExtractionPlaceholder,
58
- extractionAttributes,
59
- extractionCueAnchors,
60
- extractionText,
61
- isPlainRecord,
62
- } from "./extraction-normalization.js";
63
- export { classifyExtractionThrownError, classifyFallbackParseFailure } from "./extraction-error-classification.js";
64
- import {
65
- applyExtractionSpanMaterialization,
66
- bindLocalExtractionPrompt,
67
- buildSpanMaterializeTurns,
68
- stripUntrustedFactSpans,
69
- truncateLocalExtractionConversation,
70
- type SpanMaterializeTurn,
71
- } from "./extraction-span-materialize.js";
57
+ import { containsExtractionPlaceholder, extractionAttributes, extractionCueAnchors, extractionText, isPlainRecord } from "./extraction-normalization.js";
58
+ import { applyExtractionSpanMaterialization, bindLocalExtractionPrompt, buildSpanMaterializeTurns, stripUntrustedFactSpans, truncateLocalExtractionConversation, type SpanMaterializeTurn } from "./extraction-span-materialize.js";
72
59
  import { resolveLocalLlmCapabilities, resolveMemoryLifecycleCapabilities, resolvePipelineProcessingCapabilities, resolveRecallAuxiliaryCapabilities } from "./capabilities.js";
73
60
  type ExtractionQuestion = ExtractionResult["questions"][number];
74
61
  type ExtractedFactResult = ExtractionResult["facts"][number];
@@ -1363,7 +1350,7 @@ export class ExtractionEngine {
1363
1350
  this.withGatewayAgent({
1364
1351
  temperature: 0.3,
1365
1352
  maxTokens: this.config.extractionMaxOutputTokens,
1366
- timeoutMs: this.config.localLlmTimeoutMs,
1353
+ timeoutMs: this.config.taskLlmTimeoutMs ?? this.config.localLlmTimeoutMs,
1367
1354
  jsonSchema: {
1368
1355
  name: "extraction_result",
1369
1356
  schema: EXTRACTION_PROVIDER_JSON_SCHEMA,
@@ -1391,11 +1378,26 @@ export class ExtractionEngine {
1391
1378
  return this.finalizeExtractionResult(finalResult, boundedTurns, resolvedConnector, ambientCapture);
1392
1379
  }
1393
1380
 
1381
+ const parseFailure =
1382
+ detailed.result === null
1383
+ ? detailed
1384
+ : { failureReason: "empty" as const, attemptedModel: undefined, httpStatus: undefined, errorClass: "empty" };
1385
+ const failureLog = formatExtractionParseFailureLog({
1386
+ failureReason: parseFailure.failureReason,
1387
+ attemptedModel: parseFailure.attemptedModel,
1388
+ httpStatus: parseFailure.httpStatus,
1389
+ errorClass: parseFailure.errorClass,
1390
+ traceId: fallbackTraceId,
1391
+ });
1394
1392
  this.emit({
1395
- kind: "llm_error", traceId: fallbackTraceId, model: "fallback", operation: "extraction",
1396
- durationMs: fallbackDurationMs, error: "fallback returned no parsed output",
1393
+ kind: "llm_error",
1394
+ traceId: fallbackTraceId,
1395
+ model: parseFailure.attemptedModel ?? "fallback",
1396
+ operation: "extraction",
1397
+ durationMs: fallbackDurationMs,
1398
+ error: failureLog,
1397
1399
  });
1398
- log.warn("extraction fallback returned no parsed output");
1400
+ log.warn(failureLog);
1399
1401
  const fallbackParseFailureClass: ExtractionFailureClass =
1400
1402
  detailed.result === null
1401
1403
  ? detailed.failureReason === "no_models" && primaryExtractorAttempted
@@ -1,11 +1,10 @@
1
1
  /**
2
- * Codex-subscription helpers for FallbackLlmClient (issue #2833).
3
- *
4
- * Terminal error classification, the `api: "codex-cli"` provider attempt,
5
- * and Codex runner/lifecycle helpers live here so fallback-llm.ts stays
6
- * generic chain orchestration.
2
+ * Helpers extracted from FallbackLlmClient so fallback-llm.ts stays under
3
+ * the 1200-line cap: Codex-subscription lifecycle (issue #2833) plus
4
+ * generic chain helpers used by the same client.
7
5
  */
8
6
 
7
+ import path from "node:path";
9
8
  import { raceAbort } from "./abort-error.js";
10
9
  import { callCodexCliFallback, isCodexCliFallbackRunnerRegistered } from "./cli-fallback.js";
11
10
  import type { CodexCliFallbackRunner } from "./cli-fallback.js";
@@ -16,10 +15,14 @@ import {
16
15
  CodexSubscriptionTimeoutError,
17
16
  assertNoApiKeyConfig,
18
17
  ensureCodexSubscriptionRunnerRegistered,
18
+ getCodexSubscriptionRunnerForOwner,
19
19
  getCodexSubscriptionShutdownSignal,
20
20
  isDefaultRegisteredCodexSubscriptionRunner,
21
21
  } from "./providers/codex-subscription.js";
22
- import type { ModelProviderConfig } from "./types.js";
22
+ import type { GetRuntimeAuthForModelFn, ResolveApiKeyFn } from "./resolve-provider-secret.js";
23
+ import { resolveHomeDir } from "./runtime/env.js";
24
+ import type { GatewayConfig, ModelProviderConfig } from "./types.js";
25
+ import { expandTildePath } from "./utils/path.js";
23
26
 
24
27
  type CodexSubscriptionAttemptResult = {
25
28
  content: string;
@@ -151,7 +154,7 @@ export async function tryCodexSubscriptionProvider(
151
154
 
152
155
  export function abortReason(signal: AbortSignal | undefined): Error {
153
156
  const reason = signal?.reason;
154
- return reason instanceof Error ? reason : new Error("fallback LLM request aborted");
157
+ return reason instanceof Error ? reason : new Error("task LLM request aborted");
155
158
  }
156
159
 
157
160
  export function withCodexRuntimeShutdown<T extends { signal?: AbortSignal }>(
@@ -166,3 +169,186 @@ export function withCodexRuntimeShutdown<T extends { signal?: AbortSignal }>(
166
169
  signal: options.signal ? AbortSignal.any([options.signal, shutdown]) : shutdown,
167
170
  };
168
171
  }
172
+
173
+ export function isUnsupportedJsonSchemaError(error: unknown): boolean {
174
+ const message = error instanceof Error ? error.message : String(error);
175
+ // Require an HTTP status plus explicit schema/format context. A bare
176
+ // "unsupported" (e.g. "'temperature' is unsupported with this model") must
177
+ // NOT trigger the schema-stripping retry, or we pay a duplicate request
178
+ // for unrelated provider errors.
179
+ if (!/\b(?:400|404|422)\b/.test(message)) {
180
+ return false;
181
+ }
182
+ if (/(?:response[_ ]?format|json[_ ]?schema|structured[_ ]?output)/i.test(message)) {
183
+ return true;
184
+ }
185
+ // "unsupported" only counts when adjacent to schema/format terminology.
186
+ return /\bunsupported\b[\s\S]{0,40}\b(?:schema|format)\b/i.test(message);
187
+ }
188
+
189
+ export function extractResponsesOutputText(data: {
190
+ output_text?: string;
191
+ output?: Array<{
192
+ type?: string;
193
+ text?: string;
194
+ content?: Array<{
195
+ type?: string;
196
+ text?: string;
197
+ }>;
198
+ }>;
199
+ }): string | null {
200
+ if (typeof data.output_text === "string" && data.output_text.trim().length > 0) {
201
+ return data.output_text;
202
+ }
203
+
204
+ const chunks: string[] = [];
205
+ for (const item of data.output ?? []) {
206
+ if (typeof item.text === "string" && item.text.trim().length > 0) {
207
+ chunks.push(item.text);
208
+ }
209
+ for (const part of item.content ?? []) {
210
+ if (
211
+ (part.type === "output_text" || part.type === "text") &&
212
+ typeof part.text === "string" &&
213
+ part.text.trim().length > 0
214
+ ) {
215
+ chunks.push(part.text);
216
+ }
217
+ }
218
+ }
219
+
220
+ const joined = chunks.join("\n").trim();
221
+ return joined.length > 0 ? joined : null;
222
+ }
223
+
224
+ export type StructuredParseFailureReason =
225
+ | "no_models"
226
+ | "empty"
227
+ | "http_error"
228
+ | "schema_rejection"
229
+ | "timeout";
230
+
231
+ export interface StructuredParseFailure {
232
+ result: null;
233
+ failureReason: StructuredParseFailureReason;
234
+ /** Model string of the last attempt, when one was selected. Not `modelUsed`. */
235
+ attemptedModel?: string;
236
+ /** HTTP status when known. Never a response body. */
237
+ httpStatus?: number;
238
+ /** Coarse class: http_4xx / http_5xx / timeout / network / empty / schema_rejection / no_models. */
239
+ errorClass?: string;
240
+ }
241
+
242
+ export type StructuredParseResult<T> =
243
+ | { result: T; modelUsed: string }
244
+ | StructuredParseFailure;
245
+
246
+ export interface FallbackLlmRuntimeContext {
247
+ agentDir?: string;
248
+ getRuntimeAuthForModel?: GetRuntimeAuthForModelFn | null;
249
+ resolveApiKeyForProvider?: ResolveApiKeyFn | null;
250
+ workspaceDir?: string;
251
+ /** Per-runtime Codex child owner. Shutdown must terminate only this runner. */
252
+ codexSubscriptionRunner?: CodexCliFallbackRunner;
253
+ }
254
+
255
+ type GatewayBackedRuntimeConfig = {
256
+ providerApiKeyResolver?: ResolveApiKeyFn | null;
257
+ runtimeAuthForModelResolver?: GetRuntimeAuthForModelFn | null;
258
+ workspaceDir?: string;
259
+ };
260
+
261
+ export function fallbackLlmRuntimeContextFromConfig(
262
+ config: Pick<
263
+ GatewayBackedRuntimeConfig,
264
+ "providerApiKeyResolver" | "runtimeAuthForModelResolver" | "workspaceDir"
265
+ >,
266
+ overrides: FallbackLlmRuntimeContext = {},
267
+ ): FallbackLlmRuntimeContext {
268
+ return {
269
+ workspaceDir: config.workspaceDir,
270
+ resolveApiKeyForProvider: config.providerApiKeyResolver,
271
+ getRuntimeAuthForModel: config.runtimeAuthForModelResolver,
272
+ codexSubscriptionRunner: getCodexSubscriptionRunnerForOwner(config),
273
+ ...overrides,
274
+ };
275
+ }
276
+
277
+ const HTTP_STATUS_IN_MESSAGE = /\b([1-5]\d{2})\b/;
278
+
279
+ export function isTimeoutError(err: unknown): boolean {
280
+ const msg = err instanceof Error ? err.message : String(err);
281
+ return /timed out after \d+ms/i.test(msg) || /timed out before request started/i.test(msg);
282
+ }
283
+
284
+ function isEmptyProviderResponse(err: unknown): boolean {
285
+ const msg = err instanceof Error ? err.message : String(err);
286
+ return /^Empty response from /i.test(msg);
287
+ }
288
+
289
+ function finiteHttpStatus(value: unknown): number | undefined {
290
+ if (typeof value !== "number" || !Number.isFinite(value) || !Number.isInteger(value)) return undefined;
291
+ if (value < 100 || value > 599) return undefined;
292
+ return value;
293
+ }
294
+
295
+ function httpStatusFromProviderError(err: unknown): number | undefined {
296
+ if (err && typeof err === "object") {
297
+ if ("status" in err) {
298
+ const status = finiteHttpStatus(err.status);
299
+ if (status !== undefined) return status;
300
+ }
301
+ if ("statusCode" in err) {
302
+ const status = finiteHttpStatus(err.statusCode);
303
+ if (status !== undefined) return status;
304
+ }
305
+ }
306
+ const msg = err instanceof Error ? err.message : String(err);
307
+ const match = HTTP_STATUS_IN_MESSAGE.exec(msg);
308
+ if (!match) return undefined;
309
+ return finiteHttpStatus(Number(match[1]));
310
+ }
311
+
312
+ function errorClassForHttpStatus(status: number): string {
313
+ if (status >= 500) return "http_5xx";
314
+ if (status >= 400) return "http_4xx";
315
+ return `http_${status}`;
316
+ }
317
+
318
+ export function classifyThrownProviderError(err: unknown): Omit<StructuredParseFailure, "result"> {
319
+ if (isTimeoutError(err)) {
320
+ return { failureReason: "timeout", errorClass: "timeout" };
321
+ }
322
+ if (isEmptyProviderResponse(err)) {
323
+ return { failureReason: "empty", errorClass: "empty" };
324
+ }
325
+ const httpStatus = httpStatusFromProviderError(err);
326
+ if (httpStatus !== undefined) {
327
+ return {
328
+ failureReason: "http_error",
329
+ httpStatus,
330
+ errorClass: errorClassForHttpStatus(httpStatus),
331
+ };
332
+ }
333
+ return { failureReason: "http_error", errorClass: "network" };
334
+ }
335
+
336
+ export function normalizeRuntimePath(value: unknown): string | undefined {
337
+ if (typeof value !== "string") return undefined;
338
+ const trimmed = value.trim();
339
+ return trimmed.length > 0 ? expandTildePath(trimmed) : undefined;
340
+ }
341
+
342
+ export function readGatewayWorkspaceDir(gatewayConfig: GatewayConfig | undefined): string | undefined {
343
+ if (!gatewayConfig || typeof gatewayConfig !== "object") return undefined;
344
+ const raw = gatewayConfig as Record<string, unknown>;
345
+ return (
346
+ normalizeRuntimePath(raw.workspaceDir) ??
347
+ normalizeRuntimePath(raw.workspacePath) ??
348
+ normalizeRuntimePath(raw.workspace)
349
+ );
350
+ }
351
+
352
+ export function defaultOpenClawWorkspaceDir(): string {
353
+ return path.join(resolveHomeDir(), ".openclaw", "workspace");
354
+ }
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Distinct structured-parse failure classes (issue #2968).
3
+ *
4
+ * HTTP 200 empty, invalid JSON, schema-invalid JSON, HTTP errors, and the
5
+ * abort/timeout race must not collapse into one reason. Fingerprints stay
6
+ * retryable because these map to provider_retryable / parse_empty, which the
7
+ * extraction-run coordinator never marks processed.
8
+ */
9
+ import assert from "node:assert/strict";
10
+ import test from "node:test";
11
+ import { z } from "zod";
12
+
13
+ import { classifyFallbackParseFailure } from "./extraction-error-classification.js";
14
+ import { FallbackLlmClient } from "./fallback-llm.js";
15
+ import { clearModelsJsonCache } from "./models-json.js";
16
+ import { clearSecretCache } from "./resolve-provider-secret.js";
17
+
18
+ const Schema = z.object({ ok: z.literal(true) });
19
+
20
+ function makeClient(): FallbackLlmClient {
21
+ return new FallbackLlmClient({
22
+ agents: { defaults: { model: { primary: "openai/test-model" } } },
23
+ models: {
24
+ providers: {
25
+ openai: {
26
+ baseUrl: "https://openai.example/v1",
27
+ api: "openai-completions",
28
+ apiKey: "key",
29
+ models: [],
30
+ },
31
+ },
32
+ },
33
+ });
34
+ }
35
+
36
+ async function parse(
37
+ fetchImpl: typeof fetch,
38
+ options: { timeoutMs?: number; signal?: AbortSignal } = {},
39
+ ) {
40
+ const originalFetch = globalThis.fetch;
41
+ globalThis.fetch = fetchImpl;
42
+ const client = makeClient();
43
+ try {
44
+ return await client.parseWithSchemaDetailed(
45
+ [
46
+ { role: "system", content: "Return JSON." },
47
+ { role: "user", content: "Do the thing." },
48
+ ],
49
+ { parse: (data: unknown) => Schema.parse(data) },
50
+ { temperature: 0, maxTokens: 16, ...options },
51
+ );
52
+ } finally {
53
+ globalThis.fetch = originalFetch;
54
+ clearModelsJsonCache();
55
+ clearSecretCache();
56
+ }
57
+ }
58
+
59
+ function jsonResponse(body: unknown, status = 200): Response {
60
+ return new Response(JSON.stringify(body), {
61
+ status,
62
+ headers: { "Content-Type": "application/json" },
63
+ });
64
+ }
65
+
66
+ test("parseWithSchemaDetailed: HTTP 200 empty content is empty, not http_error", { concurrency: false }, async () => {
67
+ const detailed = await parse(async () =>
68
+ jsonResponse({ choices: [{ message: { content: "" } }] }),
69
+ );
70
+ assert.equal(detailed.result, null);
71
+ if (detailed.result !== null) throw new Error("expected failure");
72
+ assert.equal(detailed.failureReason, "empty");
73
+ assert.equal(detailed.errorClass, "empty");
74
+ assert.equal(classifyFallbackParseFailure(detailed.failureReason), "parse_empty");
75
+ });
76
+
77
+ test("parseWithSchemaDetailed: invalid JSON is empty, not schema_rejection", { concurrency: false }, async () => {
78
+ const detailed = await parse(async () =>
79
+ jsonResponse({ choices: [{ message: { content: "not-json {{{" } }] }),
80
+ );
81
+ assert.equal(detailed.result, null);
82
+ if (detailed.result !== null) throw new Error("expected failure");
83
+ assert.equal(detailed.failureReason, "empty");
84
+ assert.equal(detailed.errorClass, "empty");
85
+ assert.notEqual(detailed.failureReason, "schema_rejection");
86
+ assert.notEqual(detailed.failureReason, "http_error");
87
+ assert.equal(classifyFallbackParseFailure(detailed.failureReason), "parse_empty");
88
+ });
89
+
90
+ test("parseWithSchemaDetailed: schema-invalid JSON is schema_rejection", { concurrency: false }, async () => {
91
+ const detailed = await parse(async () =>
92
+ jsonResponse({ choices: [{ message: { content: '{"ok":false}' } }] }),
93
+ );
94
+ assert.equal(detailed.result, null);
95
+ if (detailed.result !== null) throw new Error("expected failure");
96
+ assert.equal(detailed.failureReason, "schema_rejection");
97
+ assert.equal(detailed.errorClass, "schema_rejection");
98
+ assert.equal(detailed.attemptedModel, "openai/test-model");
99
+ assert.equal(classifyFallbackParseFailure(detailed.failureReason), "parse_empty");
100
+ });
101
+
102
+ test("parseWithSchemaDetailed: HTTP error is http_error with redacted status class", { concurrency: false }, async () => {
103
+ const detailed = await parse(
104
+ async () =>
105
+ new Response("upstream error: auth rejected by upstream (401 Unauthorized)", {
106
+ status: 502,
107
+ headers: { "Content-Type": "text/plain" },
108
+ }),
109
+ );
110
+ assert.equal(detailed.result, null);
111
+ if (detailed.result !== null) throw new Error("expected failure");
112
+ assert.equal(detailed.failureReason, "http_error");
113
+ assert.equal(detailed.httpStatus, 502);
114
+ assert.equal(detailed.errorClass, "http_5xx");
115
+ assert.equal(detailed.attemptedModel, "openai/test-model");
116
+ assert.equal(classifyFallbackParseFailure(detailed.failureReason), "provider_retryable");
117
+ const serialized = JSON.stringify(detailed);
118
+ assert.equal(serialized.includes("auth rejected"), false);
119
+ assert.equal(serialized.includes("Unauthorized"), false);
120
+ });
121
+
122
+ test("parseWithSchemaDetailed: abort/timeout race is timeout, not http_error", { concurrency: false }, async () => {
123
+ const detailed = await parse(
124
+ async (_url, init) => {
125
+ const signal = init?.signal;
126
+ return await new Promise<Response>((_resolve, reject) => {
127
+ const onAbort = (): void => {
128
+ reject(signal?.reason ?? new Error("aborted"));
129
+ };
130
+ if (signal?.aborted) {
131
+ onAbort();
132
+ return;
133
+ }
134
+ signal?.addEventListener("abort", onAbort, { once: true });
135
+ });
136
+ },
137
+ { timeoutMs: 25 },
138
+ );
139
+ assert.equal(detailed.result, null);
140
+ if (detailed.result !== null) throw new Error("expected failure");
141
+ assert.equal(detailed.failureReason, "timeout");
142
+ assert.equal(detailed.errorClass, "timeout");
143
+ assert.notEqual(detailed.failureReason, "http_error");
144
+ assert.equal(classifyFallbackParseFailure(detailed.failureReason), "provider_retryable");
145
+ });
146
+
147
+ test("parseWithSchemaDetailed: success shape still uses modelUsed as discriminant", { concurrency: false }, async () => {
148
+ const detailed = await parse(async () =>
149
+ jsonResponse({ choices: [{ message: { content: '{"ok":true}' } }] }),
150
+ );
151
+ assert.equal("modelUsed" in detailed, true);
152
+ assert.notEqual(detailed.result, null);
153
+ if (detailed.result === null) throw new Error("expected success");
154
+ assert.deepEqual(detailed.result, { ok: true });
155
+ assert.equal(detailed.modelUsed, "openai/test-model");
156
+ });