@e4779/pi-fabric 0.117.2-fork.31 → 0.131.4-fork.33

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 (811) hide show
  1. package/README.md +13 -6
  2. package/THIRD_PARTY_NOTICES.md +6 -14
  3. package/dist/activity/store.d.ts +2 -1
  4. package/dist/activity/store.d.ts.map +1 -1
  5. package/dist/actors/binding-store.d.ts +13 -0
  6. package/dist/actors/binding-store.d.ts.map +1 -1
  7. package/dist/actors/directory.d.ts.map +1 -1
  8. package/dist/actors/feedback.d.ts +5 -0
  9. package/dist/actors/feedback.d.ts.map +1 -0
  10. package/dist/actors/global-registry.d.ts +8 -0
  11. package/dist/actors/global-registry.d.ts.map +1 -1
  12. package/dist/actors/host-event-payload.d.ts +14 -0
  13. package/dist/actors/host-event-payload.d.ts.map +1 -1
  14. package/dist/actors/manager.d.ts +4 -3
  15. package/dist/actors/manager.d.ts.map +1 -1
  16. package/dist/actors/mesh-monitor.d.ts +2 -0
  17. package/dist/actors/mesh-monitor.d.ts.map +1 -1
  18. package/dist/actors/name-policy.d.ts +3 -0
  19. package/dist/actors/name-policy.d.ts.map +1 -0
  20. package/dist/actors/registry-store.d.ts +14 -5
  21. package/dist/actors/registry-store.d.ts.map +1 -1
  22. package/dist/actors/store-read.d.ts +16 -0
  23. package/dist/actors/store-read.d.ts.map +1 -0
  24. package/dist/agents/agent-files.d.ts +80 -0
  25. package/dist/agents/agent-files.d.ts.map +1 -0
  26. package/dist/agents/agent-files.js +327 -0
  27. package/dist/agents/agent-files.js.map +7 -0
  28. package/dist/agents/child-skills.d.ts +60 -0
  29. package/dist/agents/child-skills.d.ts.map +1 -0
  30. package/dist/agents/child-skills.js +94 -0
  31. package/dist/agents/child-skills.js.map +7 -0
  32. package/dist/agents/clone-first-worktree.d.ts +6 -0
  33. package/dist/agents/clone-first-worktree.d.ts.map +1 -1
  34. package/dist/agents/completion-inbox.d.ts.map +1 -1
  35. package/dist/agents/cow-clone.d.ts.map +1 -1
  36. package/dist/agents/handoff.d.ts +12 -2
  37. package/dist/agents/handoff.d.ts.map +1 -1
  38. package/dist/agents/herdr-status.d.ts +26 -0
  39. package/dist/agents/herdr-status.d.ts.map +1 -0
  40. package/dist/agents/herdr-status.js +161 -0
  41. package/dist/agents/herdr-status.js.map +7 -0
  42. package/dist/agents/hosted-run.d.ts +20 -4
  43. package/dist/agents/hosted-run.d.ts.map +1 -1
  44. package/dist/agents/manager.d.ts +18 -2
  45. package/dist/agents/manager.d.ts.map +1 -1
  46. package/dist/agents/model-pin-guard.d.ts +27 -0
  47. package/dist/agents/model-pin-guard.d.ts.map +1 -0
  48. package/dist/agents/model-pin-guard.js +86 -0
  49. package/dist/agents/model-pin-guard.js.map +7 -0
  50. package/dist/agents/model-pin.d.ts +25 -0
  51. package/dist/agents/model-pin.d.ts.map +1 -0
  52. package/dist/agents/provider-bridge.d.ts +7 -6
  53. package/dist/agents/provider-bridge.d.ts.map +1 -1
  54. package/dist/agents/provider-bridge.js +33 -5
  55. package/dist/agents/provider-bridge.js.map +3 -3
  56. package/dist/agents/request.d.ts.map +1 -1
  57. package/dist/agents/result.d.ts.map +1 -1
  58. package/dist/agents/result.js +1 -1
  59. package/dist/agents/runner-notice.d.ts.map +1 -1
  60. package/dist/agents/runner-protocol.d.ts +8 -0
  61. package/dist/agents/runner-protocol.d.ts.map +1 -1
  62. package/dist/agents/service-schema.d.ts.map +1 -1
  63. package/dist/agents/transports/herdr-core-socket.d.ts +13 -0
  64. package/dist/agents/transports/herdr-core-socket.d.ts.map +1 -0
  65. package/dist/agents/transports/herdr-core-transport.d.ts +10 -0
  66. package/dist/agents/transports/herdr-core-transport.d.ts.map +1 -0
  67. package/dist/agents/transports/herdr-socket.d.ts +12 -0
  68. package/dist/agents/transports/herdr-socket.d.ts.map +1 -0
  69. package/dist/agents/transports/herdr-transport.d.ts.map +1 -1
  70. package/dist/agents/types.d.ts +51 -0
  71. package/dist/agents/types.d.ts.map +1 -1
  72. package/dist/agents/worker-recovery.d.ts +75 -0
  73. package/dist/agents/worker-recovery.d.ts.map +1 -0
  74. package/dist/agents/worktree-manager.d.ts.map +1 -1
  75. package/dist/agents.js +12 -11
  76. package/dist/agents.js.map +2 -2
  77. package/dist/audit/details.d.ts +38 -1
  78. package/dist/audit/details.d.ts.map +1 -1
  79. package/dist/audit/projection.d.ts.map +1 -1
  80. package/dist/audit/trace-schema.d.ts +50 -0
  81. package/dist/audit/trace-schema.d.ts.map +1 -0
  82. package/dist/audit/trace.d.ts +2 -48
  83. package/dist/audit/trace.d.ts.map +1 -1
  84. package/dist/chunks/chunk-2RWNVCFD.js +483 -0
  85. package/dist/chunks/chunk-2RWNVCFD.js.map +7 -0
  86. package/dist/chunks/chunk-2SCMGO2Z.js +16 -0
  87. package/dist/chunks/chunk-2SCMGO2Z.js.map +7 -0
  88. package/dist/chunks/chunk-35EEGOH3.js +324 -0
  89. package/dist/chunks/chunk-35EEGOH3.js.map +7 -0
  90. package/dist/chunks/{chunk-UTOBAZ5T.js → chunk-37NIOSVU.js} +1 -1
  91. package/dist/chunks/chunk-37NIOSVU.js.map +7 -0
  92. package/dist/chunks/chunk-3IJEQBFS.js +25 -0
  93. package/dist/chunks/chunk-3IJEQBFS.js.map +7 -0
  94. package/dist/chunks/{chunk-EHQQ4KCX.js → chunk-3MOY6WIB.js} +84 -19
  95. package/dist/chunks/chunk-3MOY6WIB.js.map +7 -0
  96. package/dist/chunks/chunk-3VK6UGAN.js +64 -0
  97. package/dist/chunks/chunk-3VK6UGAN.js.map +7 -0
  98. package/dist/chunks/{chunk-ROTCDDOV.js → chunk-3XT5WHSG.js} +59 -119
  99. package/dist/chunks/chunk-3XT5WHSG.js.map +7 -0
  100. package/dist/chunks/{chunk-FIDUHKMM.js → chunk-4BYS4ZLY.js} +16 -16
  101. package/dist/chunks/chunk-4BYS4ZLY.js.map +7 -0
  102. package/dist/chunks/{chunk-UOM37PE4.js → chunk-4PBW54I2.js} +162 -92
  103. package/dist/chunks/chunk-4PBW54I2.js.map +7 -0
  104. package/dist/chunks/{chunk-ZEXCKK4K.js → chunk-4WKD3YM3.js} +3 -3
  105. package/dist/chunks/{chunk-PK4NIJEV.js → chunk-4XMXFHAR.js} +62 -3
  106. package/dist/chunks/chunk-4XMXFHAR.js.map +7 -0
  107. package/dist/chunks/{chunk-4EW7GVUR.js → chunk-56NMRVTV.js} +589 -377
  108. package/dist/chunks/chunk-56NMRVTV.js.map +7 -0
  109. package/dist/chunks/chunk-5QJFDKPN.js +179 -0
  110. package/dist/chunks/chunk-5QJFDKPN.js.map +7 -0
  111. package/dist/chunks/{chunk-P7CBPPHY.js → chunk-6GWDGTHC.js} +5 -5
  112. package/dist/chunks/{chunk-P7CBPPHY.js.map → chunk-6GWDGTHC.js.map} +1 -1
  113. package/dist/chunks/chunk-6HO2IUQ5.js +104 -0
  114. package/dist/chunks/chunk-6HO2IUQ5.js.map +7 -0
  115. package/dist/chunks/chunk-6OGYPHNQ.js +62 -0
  116. package/dist/chunks/chunk-6OGYPHNQ.js.map +7 -0
  117. package/dist/chunks/{chunk-G4TLWHRS.js → chunk-7N7IC3Z2.js} +4 -3
  118. package/dist/chunks/{chunk-G4TLWHRS.js.map → chunk-7N7IC3Z2.js.map} +2 -2
  119. package/dist/chunks/{chunk-5XBYFSI5.js → chunk-7YNE4NB2.js} +2 -2
  120. package/dist/chunks/chunk-ASOJYFKU.js +1316 -0
  121. package/dist/chunks/chunk-ASOJYFKU.js.map +7 -0
  122. package/dist/chunks/{chunk-NTC2MCB6.js → chunk-B5L3X3ID.js} +1 -1
  123. package/dist/chunks/{chunk-NTC2MCB6.js.map → chunk-B5L3X3ID.js.map} +1 -1
  124. package/dist/chunks/chunk-BIBRWZWQ.js +325 -0
  125. package/dist/chunks/chunk-BIBRWZWQ.js.map +7 -0
  126. package/dist/chunks/{chunk-K6QXUGS5.js → chunk-BMAEZNZ5.js} +2 -1
  127. package/dist/chunks/{chunk-FSB2VIRZ.js → chunk-CBIV747V.js} +14 -3
  128. package/dist/chunks/chunk-CBIV747V.js.map +7 -0
  129. package/dist/chunks/{chunk-CCHZXF6K.js → chunk-CXYJJ3HZ.js} +3 -3
  130. package/dist/chunks/{chunk-R2XQ6AHT.js → chunk-DGERP4VL.js} +22 -10
  131. package/dist/chunks/chunk-DGERP4VL.js.map +7 -0
  132. package/dist/chunks/{chunk-C7Z6F3SO.js → chunk-DGUXJSYA.js} +64 -33
  133. package/dist/chunks/chunk-DGUXJSYA.js.map +7 -0
  134. package/dist/chunks/chunk-F2LGSRIN.js +38 -0
  135. package/dist/chunks/chunk-F2LGSRIN.js.map +7 -0
  136. package/dist/chunks/chunk-F6A6MQ6G.js +609 -0
  137. package/dist/chunks/chunk-F6A6MQ6G.js.map +7 -0
  138. package/dist/chunks/{chunk-IR3PIHJM.js → chunk-FK73YJKV.js} +67 -2
  139. package/dist/chunks/chunk-FK73YJKV.js.map +7 -0
  140. package/dist/chunks/{chunk-XCEEQ5AB.js → chunk-G2DZJ5LK.js} +1607 -1567
  141. package/dist/chunks/chunk-G2DZJ5LK.js.map +7 -0
  142. package/dist/chunks/{chunk-VYQV5JRT.js → chunk-GJVKEHDL.js} +2 -2
  143. package/dist/chunks/chunk-GJVKEHDL.js.map +7 -0
  144. package/dist/chunks/{chunk-TIIIHPHF.js → chunk-GS67KDMV.js} +2 -2
  145. package/dist/chunks/{chunk-D5NYNIST.js → chunk-H57KPL3V.js} +5 -5
  146. package/dist/chunks/{chunk-KVYNGDGC.js → chunk-HFDJWLMS.js} +6 -6
  147. package/dist/chunks/{chunk-KVYNGDGC.js.map → chunk-HFDJWLMS.js.map} +1 -1
  148. package/dist/chunks/{chunk-INRXG4J5.js → chunk-HGD75NZY.js} +2 -2
  149. package/dist/chunks/{chunk-CRRUW26I.js → chunk-HRDMBGMY.js} +12 -12
  150. package/dist/chunks/{chunk-CRRUW26I.js.map → chunk-HRDMBGMY.js.map} +2 -2
  151. package/dist/chunks/{chunk-GO32KSEZ.js → chunk-HRVYXRWZ.js} +85 -10
  152. package/dist/chunks/chunk-HRVYXRWZ.js.map +7 -0
  153. package/dist/chunks/{chunk-MLLYR3Y6.js → chunk-HSEZPCL5.js} +19 -78
  154. package/dist/chunks/chunk-HSEZPCL5.js.map +7 -0
  155. package/dist/chunks/chunk-JMUUNW2H.js +65 -0
  156. package/dist/chunks/chunk-JMUUNW2H.js.map +7 -0
  157. package/dist/chunks/{chunk-UXIBKMUM.js → chunk-KIFOEBYJ.js} +4 -4
  158. package/dist/chunks/{chunk-3FJUP3GV.js → chunk-L6H46CPY.js} +2 -2
  159. package/dist/chunks/{chunk-SPCJXN4K.js → chunk-LKYLD5SN.js} +298 -65
  160. package/dist/chunks/chunk-LKYLD5SN.js.map +7 -0
  161. package/dist/chunks/{chunk-K7J2ABAZ.js → chunk-LRSZFYUC.js} +92 -32
  162. package/dist/chunks/chunk-LRSZFYUC.js.map +7 -0
  163. package/dist/chunks/{chunk-GIK2WNAK.js → chunk-LZ2ZXOCU.js} +112 -23
  164. package/dist/chunks/chunk-LZ2ZXOCU.js.map +7 -0
  165. package/dist/chunks/{chunk-FUY6XVRX.js → chunk-MPMEK3IQ.js} +2 -2
  166. package/dist/chunks/{chunk-HP5P7NBO.js → chunk-MSDL7U6Q.js} +4 -4
  167. package/dist/chunks/{chunk-ASSLHWZS.js → chunk-MX53BRAC.js} +2 -2
  168. package/dist/chunks/chunk-N7ZAK2PB.js +132 -0
  169. package/dist/chunks/chunk-N7ZAK2PB.js.map +7 -0
  170. package/dist/chunks/{chunk-VSDUSNIA.js → chunk-NBIYYMKS.js} +8 -2
  171. package/dist/chunks/chunk-NBIYYMKS.js.map +7 -0
  172. package/dist/chunks/chunk-NENQZCGW.js +45 -0
  173. package/dist/chunks/chunk-NENQZCGW.js.map +7 -0
  174. package/dist/chunks/chunk-NJHJKINP.js +47 -0
  175. package/dist/chunks/chunk-NJHJKINP.js.map +7 -0
  176. package/dist/chunks/{chunk-U366I5K2.js → chunk-NQ7IWEIF.js} +18 -6
  177. package/dist/chunks/chunk-NQ7IWEIF.js.map +7 -0
  178. package/dist/chunks/{chunk-ZQMBS5SH.js → chunk-OJ4HAALD.js} +15 -12
  179. package/dist/chunks/chunk-OJ4HAALD.js.map +7 -0
  180. package/dist/chunks/chunk-OZCJU3PZ.js +33 -0
  181. package/dist/chunks/chunk-OZCJU3PZ.js.map +7 -0
  182. package/dist/chunks/chunk-P3DCXKL3.js +40 -0
  183. package/dist/chunks/chunk-P3DCXKL3.js.map +7 -0
  184. package/dist/chunks/chunk-P7YSPKTM.js +294 -0
  185. package/dist/chunks/chunk-P7YSPKTM.js.map +7 -0
  186. package/dist/chunks/chunk-PQVUMJ5J.js +223 -0
  187. package/dist/chunks/chunk-PQVUMJ5J.js.map +7 -0
  188. package/dist/chunks/chunk-PUBHBEYO.js +84 -0
  189. package/dist/chunks/chunk-PUBHBEYO.js.map +7 -0
  190. package/dist/chunks/{chunk-P4KH4S4S.js → chunk-QGTD3LAZ.js} +5 -20
  191. package/dist/chunks/chunk-QGTD3LAZ.js.map +7 -0
  192. package/dist/chunks/{chunk-TIJ3YQXX.js → chunk-QOEOKW2X.js} +2 -2
  193. package/dist/chunks/{chunk-TIJ3YQXX.js.map → chunk-QOEOKW2X.js.map} +1 -1
  194. package/dist/chunks/{chunk-QT4W5YVB.js → chunk-RAA3FAYZ.js} +2 -2
  195. package/dist/chunks/{chunk-3UGN25XS.js → chunk-RKJPBTBB.js} +98 -1664
  196. package/dist/chunks/chunk-RKJPBTBB.js.map +7 -0
  197. package/dist/chunks/{chunk-WJJXODAB.js → chunk-RLKRZXSX.js} +8 -1
  198. package/dist/chunks/{chunk-WJJXODAB.js.map → chunk-RLKRZXSX.js.map} +2 -2
  199. package/dist/chunks/chunk-RWKQ5SRW.js +129 -0
  200. package/dist/chunks/chunk-RWKQ5SRW.js.map +7 -0
  201. package/dist/chunks/chunk-SW25R47N.js +71 -0
  202. package/dist/chunks/chunk-SW25R47N.js.map +7 -0
  203. package/dist/chunks/{chunk-EKODKR6Y.js → chunk-TEMKDJJY.js} +148 -72
  204. package/dist/chunks/chunk-TEMKDJJY.js.map +7 -0
  205. package/dist/chunks/{chunk-EFETPXU2.js → chunk-TJZYM2SP.js} +118 -237
  206. package/dist/chunks/chunk-TJZYM2SP.js.map +7 -0
  207. package/dist/chunks/{chunk-53N2I4QA.js → chunk-TXCNZCZP.js} +2 -2
  208. package/dist/chunks/{chunk-LNASO4VT.js → chunk-U6Y6TKJL.js} +45 -20
  209. package/dist/chunks/chunk-U6Y6TKJL.js.map +7 -0
  210. package/dist/chunks/chunk-UD7LFV43.js +28 -0
  211. package/dist/chunks/chunk-UD7LFV43.js.map +7 -0
  212. package/dist/chunks/{chunk-7QKKLBHJ.js → chunk-UPMWLOKL.js} +10 -1
  213. package/dist/chunks/{chunk-7QKKLBHJ.js.map → chunk-UPMWLOKL.js.map} +2 -2
  214. package/dist/chunks/chunk-V4OW2ULC.js +422 -0
  215. package/dist/chunks/chunk-V4OW2ULC.js.map +7 -0
  216. package/dist/chunks/{chunk-FE6NOAO7.js → chunk-VGRUWTMG.js} +1993 -659
  217. package/dist/chunks/chunk-VGRUWTMG.js.map +7 -0
  218. package/dist/chunks/{chunk-PYFJW3HC.js → chunk-W5FEHVZA.js} +2 -16
  219. package/dist/chunks/{chunk-PYFJW3HC.js.map → chunk-W5FEHVZA.js.map} +3 -3
  220. package/dist/chunks/chunk-WKFRGICG.js +101 -0
  221. package/dist/chunks/chunk-WKFRGICG.js.map +7 -0
  222. package/dist/chunks/{chunk-LEU5CDSL.js → chunk-XFOSUGLU.js} +5 -5
  223. package/dist/chunks/{chunk-MZUC6LLH.js → chunk-XMYG2TKR.js} +4 -4
  224. package/dist/chunks/{chunk-MZUC6LLH.js.map → chunk-XMYG2TKR.js.map} +1 -1
  225. package/dist/chunks/chunk-YC65P7ZO.js +57 -0
  226. package/dist/chunks/chunk-YC65P7ZO.js.map +7 -0
  227. package/dist/chunks/{chunk-5UBRGTVN.js → chunk-ZHROHNEE.js} +31 -15
  228. package/dist/chunks/chunk-ZHROHNEE.js.map +7 -0
  229. package/dist/cli/decisions.d.ts.map +1 -1
  230. package/dist/cli/decisions.js +15 -3
  231. package/dist/cli/decisions.js.map +2 -2
  232. package/dist/cli/mesh.js +4 -3
  233. package/dist/cli/mesh.js.map +1 -1
  234. package/dist/commands/fabric-handler.d.ts +7 -0
  235. package/dist/commands/fabric-handler.d.ts.map +1 -0
  236. package/dist/commands/fabric-handler.js +916 -0
  237. package/dist/commands/fabric-handler.js.map +7 -0
  238. package/dist/commands/fabric.d.ts +11 -1
  239. package/dist/commands/fabric.d.ts.map +1 -1
  240. package/dist/compaction/claim-events.d.ts +61 -0
  241. package/dist/compaction/claim-events.d.ts.map +1 -0
  242. package/dist/compaction/claim-events.js +210 -0
  243. package/dist/compaction/claim-events.js.map +7 -0
  244. package/dist/compaction/claim.d.ts +51 -0
  245. package/dist/compaction/claim.d.ts.map +1 -0
  246. package/dist/compaction/hook.d.ts +28 -2
  247. package/dist/compaction/hook.d.ts.map +1 -1
  248. package/dist/compaction/hook.js +12 -7
  249. package/dist/compaction/owner.js +9 -8
  250. package/dist/compaction/trace-events.d.ts +1 -1
  251. package/dist/compaction/trace-events.d.ts.map +1 -1
  252. package/dist/components/configuration.js +6 -6
  253. package/dist/components/effect-scope.d.ts.map +1 -1
  254. package/dist/config.d.ts +40 -3
  255. package/dist/config.d.ts.map +1 -1
  256. package/dist/core/action-arguments.d.ts.map +1 -1
  257. package/dist/core/action-policy-hooks.d.ts +69 -0
  258. package/dist/core/action-policy-hooks.d.ts.map +1 -0
  259. package/dist/core/action-registry.d.ts +31 -10
  260. package/dist/core/action-registry.d.ts.map +1 -1
  261. package/dist/core/action-registry.js +12 -9
  262. package/dist/core/approval-controller.d.ts +23 -3
  263. package/dist/core/approval-controller.d.ts.map +1 -1
  264. package/dist/core/atomic-write.d.ts +164 -0
  265. package/dist/core/atomic-write.d.ts.map +1 -1
  266. package/dist/core/call-presentation.d.ts +14 -0
  267. package/dist/core/call-presentation.d.ts.map +1 -0
  268. package/dist/core/child-tool-allowlist.d.ts +17 -1
  269. package/dist/core/child-tool-allowlist.d.ts.map +1 -1
  270. package/dist/core/compact-controller.d.ts +34 -0
  271. package/dist/core/compact-controller.d.ts.map +1 -1
  272. package/dist/core/core-override-guidance.d.ts +3 -1
  273. package/dist/core/core-override-guidance.d.ts.map +1 -1
  274. package/dist/core/file-lock.d.ts.map +1 -1
  275. package/dist/core/foreground-tools.d.ts +4 -1
  276. package/dist/core/foreground-tools.d.ts.map +1 -1
  277. package/dist/core/host-policy.d.ts +43 -0
  278. package/dist/core/host-policy.d.ts.map +1 -0
  279. package/dist/core/host-sdk-runtime.d.ts.map +1 -1
  280. package/dist/core/host-sdk.d.ts.map +1 -1
  281. package/dist/core/host-sdk.js +1 -1
  282. package/dist/core/managed-host-guidance.d.ts +5 -0
  283. package/dist/core/managed-host-guidance.d.ts.map +1 -0
  284. package/dist/core/model-aliases.d.ts +22 -0
  285. package/dist/core/model-aliases.d.ts.map +1 -0
  286. package/dist/core/model-resolution.d.ts +41 -20
  287. package/dist/core/model-resolution.d.ts.map +1 -1
  288. package/dist/core/native-tool-result.d.ts +1 -0
  289. package/dist/core/native-tool-result.d.ts.map +1 -1
  290. package/dist/core/program-tasks.d.ts +52 -0
  291. package/dist/core/program-tasks.d.ts.map +1 -0
  292. package/dist/core/prompt-guidance.d.ts +5 -0
  293. package/dist/core/prompt-guidance.d.ts.map +1 -0
  294. package/dist/core/prompt-guidance.js +159 -0
  295. package/dist/core/prompt-guidance.js.map +7 -0
  296. package/dist/core/provider-operations.d.ts.map +1 -1
  297. package/dist/core/provider-operations.js +60 -108
  298. package/dist/core/provider-operations.js.map +3 -3
  299. package/dist/core/shell-inbox.d.ts.map +1 -1
  300. package/dist/core/shell-jobs.d.ts +7 -5
  301. package/dist/core/shell-jobs.d.ts.map +1 -1
  302. package/dist/core/shell-timing.d.ts.map +1 -1
  303. package/dist/core/skill-prompt.d.ts +1 -1
  304. package/dist/core/skill-prompt.d.ts.map +1 -1
  305. package/dist/core/skill-references.d.ts +1 -1
  306. package/dist/core/skill-references.d.ts.map +1 -1
  307. package/dist/core/system-guidance.d.ts.map +1 -1
  308. package/dist/core/tool-result-proxy.d.ts.map +1 -1
  309. package/dist/decisions/command.d.ts +2 -1
  310. package/dist/decisions/command.d.ts.map +1 -1
  311. package/dist/decisions/command.js +40 -12
  312. package/dist/decisions/command.js.map +2 -2
  313. package/dist/decisions/events.d.ts +12 -0
  314. package/dist/decisions/events.d.ts.map +1 -0
  315. package/dist/decisions/events.js +130 -0
  316. package/dist/decisions/events.js.map +7 -0
  317. package/dist/decisions/host.d.ts +31 -3
  318. package/dist/decisions/host.d.ts.map +1 -1
  319. package/dist/decisions/render.d.ts +44 -0
  320. package/dist/decisions/render.d.ts.map +1 -0
  321. package/dist/decisions/store.d.ts +8 -0
  322. package/dist/decisions/store.d.ts.map +1 -1
  323. package/dist/durable/agent.d.ts +8 -0
  324. package/dist/durable/agent.d.ts.map +1 -1
  325. package/dist/durable/extension-load-error.d.ts +8 -0
  326. package/dist/durable/extension-load-error.d.ts.map +1 -0
  327. package/dist/durable/session.d.ts +1 -0
  328. package/dist/durable/session.d.ts.map +1 -1
  329. package/dist/durable/worker-host.d.ts +10 -1
  330. package/dist/durable/worker-host.d.ts.map +1 -1
  331. package/dist/durable/worker-host.js +10 -1181
  332. package/dist/durable/worker-host.js.map +4 -4
  333. package/dist/durable/worker-options.d.ts +3 -0
  334. package/dist/durable/worker-options.d.ts.map +1 -1
  335. package/dist/durable/worker-role-seed.d.ts +82 -0
  336. package/dist/durable/worker-role-seed.d.ts.map +1 -0
  337. package/dist/durable/worker.js +43 -4
  338. package/dist/durable/worker.js.map +2 -2
  339. package/dist/durable-controls.d.ts.map +1 -1
  340. package/dist/durable-extension-wasm.d.ts +8 -0
  341. package/dist/durable-extension-wasm.d.ts.map +1 -0
  342. package/dist/durable-extension-wasm.js +32 -0
  343. package/dist/durable-extension-wasm.js.map +7 -0
  344. package/dist/durable-extension.d.ts +94 -0
  345. package/dist/durable-extension.d.ts.map +1 -0
  346. package/dist/durable-extension.js +649 -0
  347. package/dist/durable-extension.js.map +7 -0
  348. package/dist/durable-host.d.ts +8 -0
  349. package/dist/durable-host.d.ts.map +1 -0
  350. package/dist/durable-host.js +20 -0
  351. package/dist/durable-host.js.map +7 -0
  352. package/dist/durable-journal.d.ts +94 -0
  353. package/dist/durable-journal.d.ts.map +1 -0
  354. package/dist/durable.d.ts.map +1 -1
  355. package/dist/durable.js +13 -10
  356. package/dist/durable.js.map +2 -2
  357. package/dist/entropy/index.js +12 -10
  358. package/dist/entropy/pool-store.d.ts.map +1 -1
  359. package/dist/execution-service.d.ts +14 -0
  360. package/dist/execution-service.d.ts.map +1 -1
  361. package/dist/extension-bootstrap.d.ts.map +1 -1
  362. package/dist/extension-bootstrap.js +28 -27
  363. package/dist/extension-bootstrap.js.map +2 -2
  364. package/dist/extension-copy.d.ts +21 -0
  365. package/dist/extension-copy.d.ts.map +1 -0
  366. package/dist/extension-copy.js +90 -0
  367. package/dist/extension-copy.js.map +7 -0
  368. package/dist/extension.d.ts +1 -1
  369. package/dist/extension.d.ts.map +1 -1
  370. package/dist/fabric-exec-arguments.d.ts.map +1 -1
  371. package/dist/fabric-exec-tool.d.ts +2 -1
  372. package/dist/fabric-exec-tool.d.ts.map +1 -1
  373. package/dist/fabric-runtime-state.d.ts +19 -0
  374. package/dist/fabric-runtime-state.d.ts.map +1 -1
  375. package/dist/fabric-runtime-state.js +2205 -839
  376. package/dist/fabric-runtime-state.js.map +4 -4
  377. package/dist/fabric-state.d.ts +44 -1
  378. package/dist/fabric-state.d.ts.map +1 -1
  379. package/dist/feedback.d.ts +5 -0
  380. package/dist/feedback.d.ts.map +1 -0
  381. package/dist/index.d.ts +5 -3
  382. package/dist/index.d.ts.map +1 -1
  383. package/dist/index.js +88 -53
  384. package/dist/index.js.map +2 -2
  385. package/dist/jev/client.js +2 -2
  386. package/dist/jev/manager.d.ts +3 -0
  387. package/dist/jev/manager.d.ts.map +1 -1
  388. package/dist/jev/observation.d.ts +1 -1
  389. package/dist/jev/observation.js +6 -6
  390. package/dist/jev-fabric/bridge.d.ts.map +1 -1
  391. package/dist/jev.js +11 -12
  392. package/dist/main-agent.d.ts +2 -1
  393. package/dist/main-agent.d.ts.map +1 -1
  394. package/dist/managed-host.d.ts +13 -0
  395. package/dist/managed-host.d.ts.map +1 -1
  396. package/dist/memory/digest.js +2 -2
  397. package/dist/memory/discovery.js +6 -7
  398. package/dist/memory/file-worker.js +10 -11
  399. package/dist/memory/file-worker.js.map +1 -1
  400. package/dist/memory/normalize.js +5 -6
  401. package/dist/memory/search.js +7 -8
  402. package/dist/memory/worker-provider.js +11 -12
  403. package/dist/memory.js +11 -12
  404. package/dist/memory.js.map +1 -1
  405. package/dist/mesh/grants.d.ts +3 -3
  406. package/dist/mesh/grants.d.ts.map +1 -1
  407. package/dist/mesh/store.d.ts +8 -0
  408. package/dist/mesh/store.d.ts.map +1 -1
  409. package/dist/native-codemode.d.ts.map +1 -1
  410. package/dist/native-tool-catalog.d.ts.map +1 -1
  411. package/dist/native-tool-catalog.js +12 -3
  412. package/dist/native-tool-catalog.js.map +2 -2
  413. package/dist/programs/host.d.ts +18 -6
  414. package/dist/programs/host.d.ts.map +1 -1
  415. package/dist/programs/host.js +71 -47
  416. package/dist/programs/host.js.map +2 -2
  417. package/dist/programs/source.d.ts +11 -0
  418. package/dist/programs/source.d.ts.map +1 -1
  419. package/dist/programs/store.d.ts.map +1 -1
  420. package/dist/protocol.d.ts +504 -8
  421. package/dist/protocol.d.ts.map +1 -1
  422. package/dist/protocol.js +41 -11
  423. package/dist/provider-globals.d.ts +13 -0
  424. package/dist/provider-globals.d.ts.map +1 -0
  425. package/dist/providers/agents-actions.d.ts.map +1 -1
  426. package/dist/providers/agents-provider.d.ts +3 -0
  427. package/dist/providers/agents-provider.d.ts.map +1 -1
  428. package/dist/providers/captured-tools-provider.d.ts +5 -0
  429. package/dist/providers/captured-tools-provider.d.ts.map +1 -1
  430. package/dist/providers/compact-provider.d.ts +4 -1
  431. package/dist/providers/compact-provider.d.ts.map +1 -1
  432. package/dist/providers/components-provider.d.ts.map +1 -1
  433. package/dist/providers/decisions-provider.d.ts +9 -1
  434. package/dist/providers/decisions-provider.d.ts.map +1 -1
  435. package/dist/providers/jev-provider.d.ts +1 -1
  436. package/dist/providers/jev-provider.js +11 -12
  437. package/dist/providers/memory-provider.js +10 -11
  438. package/dist/providers/pi-tools-provider.d.ts +14 -0
  439. package/dist/providers/pi-tools-provider.d.ts.map +1 -1
  440. package/dist/providers/programs-provider.d.ts.map +1 -1
  441. package/dist/providers/sessions-provider.d.ts +7 -0
  442. package/dist/providers/sessions-provider.d.ts.map +1 -1
  443. package/dist/repeat-guard.d.ts +7 -6
  444. package/dist/repeat-guard.d.ts.map +1 -1
  445. package/dist/residency/actor-client.js +3 -3
  446. package/dist/residency/client.d.ts +15 -0
  447. package/dist/residency/client.d.ts.map +1 -1
  448. package/dist/residency/host.d.ts.map +1 -1
  449. package/dist/residency/host.js +34 -23
  450. package/dist/residency/launcher.js +1 -1
  451. package/dist/residency/pi-entry.js +34 -23
  452. package/dist/residency/pi-entry.js.map +1 -1
  453. package/dist/residency/protocol.d.ts +2 -0
  454. package/dist/residency/protocol.d.ts.map +1 -1
  455. package/dist/runners.js +11 -1
  456. package/dist/runners.js.map +2 -2
  457. package/dist/runtime/core-override-guest-types.js +2 -2
  458. package/dist/runtime/cpython-child-source.d.ts.map +1 -1
  459. package/dist/runtime/cpython-runtime.d.ts.map +1 -1
  460. package/dist/runtime/cpython-runtime.js +51 -21
  461. package/dist/runtime/cpython-runtime.js.map +2 -2
  462. package/dist/runtime/deadline-pause.d.ts +2 -0
  463. package/dist/runtime/deadline-pause.d.ts.map +1 -1
  464. package/dist/runtime/dynamic-guest-types.d.ts.map +1 -1
  465. package/dist/runtime/dynamic-guest-types.js +2 -1
  466. package/dist/runtime/exec-journal.d.ts +73 -0
  467. package/dist/runtime/exec-journal.d.ts.map +1 -0
  468. package/dist/runtime/exec-journal.js +335 -0
  469. package/dist/runtime/exec-journal.js.map +7 -0
  470. package/dist/runtime/guest-types.d.ts +3 -2
  471. package/dist/runtime/guest-types.d.ts.map +1 -1
  472. package/dist/runtime/guest-types.js +1 -1
  473. package/dist/runtime/journal-shim.d.ts +3 -0
  474. package/dist/runtime/journal-shim.d.ts.map +1 -0
  475. package/dist/runtime/kernel.d.ts +95 -1
  476. package/dist/runtime/kernel.d.ts.map +1 -1
  477. package/dist/runtime/monty-bridge.d.ts +6 -2
  478. package/dist/runtime/monty-bridge.d.ts.map +1 -1
  479. package/dist/runtime/monty-runtime.d.ts.map +1 -1
  480. package/dist/runtime/monty-runtime.js +27 -15
  481. package/dist/runtime/monty-runtime.js.map +2 -2
  482. package/dist/runtime/native-codemode-guest.d.ts.map +1 -1
  483. package/dist/runtime/node-process-runtime.d.ts.map +1 -1
  484. package/dist/runtime/node-process-runtime.js +7 -5
  485. package/dist/runtime/quickjs-runtime.d.ts +7 -1
  486. package/dist/runtime/quickjs-runtime.d.ts.map +1 -1
  487. package/dist/runtime/quickjs-runtime.js +5 -4
  488. package/dist/runtime/sha256.d.ts +4 -0
  489. package/dist/runtime/sha256.d.ts.map +1 -0
  490. package/dist/runtime/transpile.d.ts +8 -0
  491. package/dist/runtime/transpile.d.ts.map +1 -0
  492. package/dist/runtime/type-checker.d.ts +1 -7
  493. package/dist/runtime/type-checker.d.ts.map +1 -1
  494. package/dist/runtime/type-checker.js +4 -2
  495. package/dist/runtime/typescript-kernel.js +13 -10
  496. package/dist/runtime/typescript-kernel.js.map +1 -1
  497. package/dist/runtime-state-builtins.d.ts.map +1 -1
  498. package/dist/speculation/scanner.js +1 -1
  499. package/dist/speculation/store.d.ts +7 -16
  500. package/dist/speculation/store.d.ts.map +1 -1
  501. package/dist/speculation/types.d.ts +1 -0
  502. package/dist/speculation/types.d.ts.map +1 -1
  503. package/dist/storage/retention.d.ts.map +1 -1
  504. package/dist/topology/participant-directory.d.ts +26 -1
  505. package/dist/topology/participant-directory.d.ts.map +1 -1
  506. package/dist/topology/peer-presence.d.ts.map +1 -1
  507. package/dist/topology/peer-settle.js +11 -0
  508. package/dist/topology/peer-settle.js.map +7 -0
  509. package/dist/topology/session-label-settings.d.ts +13 -0
  510. package/dist/topology/session-label-settings.d.ts.map +1 -0
  511. package/dist/topology/session-label.d.ts +60 -0
  512. package/dist/topology/session-label.d.ts.map +1 -0
  513. package/dist/topology/types.d.ts +27 -0
  514. package/dist/topology/types.d.ts.map +1 -1
  515. package/dist/type-error-guidance.js +1 -1
  516. package/dist/ui/controller.d.ts +1 -0
  517. package/dist/ui/controller.d.ts.map +1 -1
  518. package/dist/ui/conversation-chrome.d.ts.map +1 -1
  519. package/dist/ui/conversation-chrome.js +3 -2
  520. package/dist/ui/conversation-commands.d.ts +1 -1
  521. package/dist/ui/conversation-commands.d.ts.map +1 -1
  522. package/dist/ui/conversation-native-reader.js +2 -2
  523. package/dist/ui/conversation-selection.d.ts +4 -1
  524. package/dist/ui/conversation-selection.d.ts.map +1 -1
  525. package/dist/ui/conversation-targets.d.ts.map +1 -1
  526. package/dist/ui/conversation-targets.js +2 -2
  527. package/dist/ui/conversation.d.ts +25 -24
  528. package/dist/ui/conversation.d.ts.map +1 -1
  529. package/dist/ui/conversation.js +170 -339
  530. package/dist/ui/conversation.js.map +2 -2
  531. package/dist/ui/core-tool-render.d.ts +1 -0
  532. package/dist/ui/core-tool-render.d.ts.map +1 -1
  533. package/dist/ui/dashboard-model.d.ts.map +1 -1
  534. package/dist/ui/dashboard.d.ts.map +1 -1
  535. package/dist/ui/dashboard.js +23 -16
  536. package/dist/ui/dashboard.js.map +2 -2
  537. package/dist/ui/fabric-render.d.ts +7 -0
  538. package/dist/ui/fabric-render.d.ts.map +1 -1
  539. package/dist/ui/footer-dock.d.ts +48 -0
  540. package/dist/ui/footer-dock.d.ts.map +1 -0
  541. package/dist/ui/format.d.ts +7 -0
  542. package/dist/ui/format.d.ts.map +1 -1
  543. package/dist/ui/settings-sections-lifecycle.d.ts.map +1 -1
  544. package/dist/ui/settings-sections-presentation.d.ts.map +1 -1
  545. package/dist/ui/settings-values.d.ts +2 -1
  546. package/dist/ui/settings-values.d.ts.map +1 -1
  547. package/dist/ui/settings.js +60 -19
  548. package/dist/ui/settings.js.map +2 -2
  549. package/dist/ui/shell-hang-keys.d.ts +8 -1
  550. package/dist/ui/shell-hang-keys.d.ts.map +1 -1
  551. package/dist/ui/shell-tasks.d.ts +2 -2
  552. package/dist/ui/shell-tasks.d.ts.map +1 -1
  553. package/dist/ui/shell-tasks.js +27 -94
  554. package/dist/ui/shell-tasks.js.map +2 -2
  555. package/dist/ui/snapshot.d.ts.map +1 -1
  556. package/dist/ui/terminal-title.d.ts +41 -0
  557. package/dist/ui/terminal-title.d.ts.map +1 -0
  558. package/dist/ui/types.d.ts +4 -0
  559. package/dist/ui/types.d.ts.map +1 -1
  560. package/dist/ui/widget-keys.d.ts +5 -0
  561. package/dist/ui/widget-keys.d.ts.map +1 -0
  562. package/dist/ui/widget.d.ts +40 -18
  563. package/dist/ui/widget.d.ts.map +1 -1
  564. package/dist/ui/word-diff/line-emphasis.js +1603 -0
  565. package/dist/ui/word-diff/line-emphasis.js.map +7 -0
  566. package/dist/util.d.ts +2 -0
  567. package/dist/util.d.ts.map +1 -1
  568. package/dist/verified/authority.d.ts +2 -2
  569. package/dist/verified/authority.d.ts.map +1 -1
  570. package/dist/verified/budget.d.ts +4 -0
  571. package/dist/verified/budget.d.ts.map +1 -0
  572. package/dist/verified/generated/actor-name.d.ts +4 -0
  573. package/dist/verified/generated/actor-name.js +17 -0
  574. package/dist/verified/generated/authority.d.ts +4 -0
  575. package/dist/verified/generated/authority.js +28 -0
  576. package/dist/verified/generated/budget.d.ts +4 -0
  577. package/dist/verified/generated/budget.js +17 -0
  578. package/dist/verified/generated/compaction.d.ts +4 -0
  579. package/dist/verified/generated/compaction.js +19 -0
  580. package/dist/verified/generated/grants.d.ts +4 -0
  581. package/dist/verified/generated/grants.js +17 -0
  582. package/dist/verified/generated/lifecycle.d.ts +4 -0
  583. package/dist/verified/generated/lifecycle.js +50 -0
  584. package/dist/verified/generated/manifest.json +137 -48
  585. package/dist/verified/generated/policy.d.ts +17 -0
  586. package/dist/verified/generated/policy.js +211 -0
  587. package/dist/verified/generated/provider.d.ts +4 -0
  588. package/dist/verified/generated/provider.js +18 -0
  589. package/dist/verified/generated/resources.d.ts +6 -0
  590. package/dist/verified/generated/resources.js +73 -0
  591. package/dist/verified/generated/speculation.d.ts +6 -0
  592. package/dist/verified/generated/speculation.js +48 -0
  593. package/dist/verified/generated/storage.d.ts +4 -0
  594. package/dist/verified/generated/storage.js +18 -0
  595. package/dist/verified/grants.d.ts +22 -0
  596. package/dist/verified/grants.d.ts.map +1 -0
  597. package/dist/verified/lifecycle.d.ts +31 -0
  598. package/dist/verified/lifecycle.d.ts.map +1 -0
  599. package/dist/verified/machine.d.ts +18 -0
  600. package/dist/verified/machine.d.ts.map +1 -0
  601. package/dist/verified/memory.d.ts +1 -1
  602. package/dist/verified/memory.d.ts.map +1 -1
  603. package/dist/verified/nat.d.ts +1 -1
  604. package/dist/verified/nat.d.ts.map +1 -1
  605. package/dist/verified/policy.d.ts +17 -5
  606. package/dist/verified/policy.d.ts.map +1 -1
  607. package/dist/verified/provider.d.ts +22 -0
  608. package/dist/verified/provider.d.ts.map +1 -0
  609. package/dist/verified/resources.d.ts +21 -7
  610. package/dist/verified/resources.d.ts.map +1 -1
  611. package/dist/verified/speculation.d.ts +36 -0
  612. package/dist/verified/speculation.d.ts.map +1 -0
  613. package/dist/verified/storage.d.ts.map +1 -1
  614. package/dist/worker/missing-install.d.ts +8 -0
  615. package/dist/worker/missing-install.d.ts.map +1 -0
  616. package/dist/worker/options.d.ts.map +1 -1
  617. package/dist/worker/options.js +25 -0
  618. package/dist/worker/options.js.map +2 -2
  619. package/dist/worker/prompt-lifecycle.d.ts +16 -0
  620. package/dist/worker/prompt-lifecycle.d.ts.map +1 -0
  621. package/dist/worker/prompt-lifecycle.js +90 -0
  622. package/dist/worker/prompt-lifecycle.js.map +7 -0
  623. package/dist/worker/questions.d.ts +15 -3
  624. package/dist/worker/questions.d.ts.map +1 -1
  625. package/dist/worker/questions.js +53 -8
  626. package/dist/worker/questions.js.map +2 -2
  627. package/dist/worker/recovery-watchdog.d.ts +22 -0
  628. package/dist/worker/recovery-watchdog.d.ts.map +1 -1
  629. package/dist/worker/recovery-watchdog.js +116 -1
  630. package/dist/worker/recovery-watchdog.js.map +2 -2
  631. package/dist/worker/result.js +1 -1
  632. package/dist/worker/result.js.map +2 -2
  633. package/dist/worker.js +131 -21
  634. package/dist/worker.js.map +2 -2
  635. package/docs/actor-name-policy-handoff.md +5 -0
  636. package/docs/agents.md +172 -22
  637. package/docs/architecture.md +5 -1
  638. package/docs/audit-trace.md +2 -1
  639. package/docs/background-tasks.md +126 -28
  640. package/docs/codemode-parity.md +2 -2
  641. package/docs/compaction.md +21 -5
  642. package/docs/components.md +1 -1
  643. package/docs/configuration.md +113 -66
  644. package/docs/decisions.md +92 -10
  645. package/docs/durable-extension.md +121 -0
  646. package/docs/durable-pi.md +306 -6
  647. package/docs/extractive-history.md +3 -1
  648. package/docs/interface.md +22 -17
  649. package/docs/jev.md +2 -2
  650. package/docs/kernels.md +1 -1
  651. package/{node_modules/pi-coralbricks-provider/LICENSE → docs/licenses/gdp-wired-mit.txt} +1 -1
  652. package/docs/managed-host-migration.md +50 -0
  653. package/docs/programmatic-compaction.md +216 -6
  654. package/docs/programs.md +23 -1
  655. package/docs/prompt-cache.md +4 -2
  656. package/docs/provider-capabilities.md +15 -14
  657. package/docs/providers.md +99 -3
  658. package/docs/shell-composition.md +15 -0
  659. package/docs/short-lock-protocol.md +90 -0
  660. package/docs/skills.md +5 -1
  661. package/docs/speculation.md +6 -0
  662. package/docs/verified-kernels.md +309 -220
  663. package/package.json +45 -24
  664. package/proofs/actor-name.ts +27 -0
  665. package/proofs/authority.ts +62 -0
  666. package/proofs/budget.ts +24 -0
  667. package/proofs/compaction.ts +51 -0
  668. package/proofs/grants.ts +39 -0
  669. package/proofs/index.ts +40 -0
  670. package/proofs/kernel.ts +44 -0
  671. package/proofs/lifecycle.ts +128 -0
  672. package/proofs/policy.ts +195 -0
  673. package/proofs/provider.ts +52 -0
  674. package/proofs/resources.ts +160 -0
  675. package/proofs/speculation.ts +69 -0
  676. package/proofs/storage.ts +66 -0
  677. package/scripts/verified-kernels.ts +141 -0
  678. package/skillsets/python/fabric-council/SKILL.md +94 -20
  679. package/skillsets/python/fabric-exec/SKILL.md +2 -2
  680. package/skillsets/python/fabric-exec/references/agents.md +10 -4
  681. package/skillsets/python/fabric-fusion/SKILL.md +1 -1
  682. package/skillsets/python/fabric-guide/SKILL.md +1 -1
  683. package/skillsets/typescript/fabric-council/SKILL.md +110 -22
  684. package/skillsets/typescript/fabric-exec/SKILL.md +7 -7
  685. package/skillsets/typescript/fabric-exec/references/agents.md +17 -8
  686. package/skillsets/typescript/fabric-fusion/SKILL.md +1 -1
  687. package/skillsets/typescript/fabric-guide/SKILL.md +1 -1
  688. package/LAWS.bend +0 -502
  689. package/PROOF.bend +0 -452
  690. package/dist/chunks/chunk-3UGN25XS.js.map +0 -7
  691. package/dist/chunks/chunk-4EW7GVUR.js.map +0 -7
  692. package/dist/chunks/chunk-5UBRGTVN.js.map +0 -7
  693. package/dist/chunks/chunk-BN7F52EG.js +0 -525
  694. package/dist/chunks/chunk-BN7F52EG.js.map +0 -7
  695. package/dist/chunks/chunk-C7Z6F3SO.js.map +0 -7
  696. package/dist/chunks/chunk-DK35W6U7.js +0 -259
  697. package/dist/chunks/chunk-DK35W6U7.js.map +0 -7
  698. package/dist/chunks/chunk-EFETPXU2.js.map +0 -7
  699. package/dist/chunks/chunk-EHQQ4KCX.js.map +0 -7
  700. package/dist/chunks/chunk-EKODKR6Y.js.map +0 -7
  701. package/dist/chunks/chunk-FE6NOAO7.js.map +0 -7
  702. package/dist/chunks/chunk-FIDUHKMM.js.map +0 -7
  703. package/dist/chunks/chunk-FSB2VIRZ.js.map +0 -7
  704. package/dist/chunks/chunk-GIK2WNAK.js.map +0 -7
  705. package/dist/chunks/chunk-GO32KSEZ.js.map +0 -7
  706. package/dist/chunks/chunk-IR3PIHJM.js.map +0 -7
  707. package/dist/chunks/chunk-ITVLKXCI.js +0 -266
  708. package/dist/chunks/chunk-ITVLKXCI.js.map +0 -7
  709. package/dist/chunks/chunk-K7J2ABAZ.js.map +0 -7
  710. package/dist/chunks/chunk-KJZAOENY.js +0 -212
  711. package/dist/chunks/chunk-KJZAOENY.js.map +0 -7
  712. package/dist/chunks/chunk-LNASO4VT.js.map +0 -7
  713. package/dist/chunks/chunk-MLLYR3Y6.js.map +0 -7
  714. package/dist/chunks/chunk-P4KH4S4S.js.map +0 -7
  715. package/dist/chunks/chunk-PK4NIJEV.js.map +0 -7
  716. package/dist/chunks/chunk-Q2JQ3RYZ.js +0 -99
  717. package/dist/chunks/chunk-Q2JQ3RYZ.js.map +0 -7
  718. package/dist/chunks/chunk-R2XQ6AHT.js.map +0 -7
  719. package/dist/chunks/chunk-ROTCDDOV.js.map +0 -7
  720. package/dist/chunks/chunk-SPCJXN4K.js.map +0 -7
  721. package/dist/chunks/chunk-U366I5K2.js.map +0 -7
  722. package/dist/chunks/chunk-UKMQK5VP.js +0 -231
  723. package/dist/chunks/chunk-UKMQK5VP.js.map +0 -7
  724. package/dist/chunks/chunk-UOM37PE4.js.map +0 -7
  725. package/dist/chunks/chunk-UTOBAZ5T.js.map +0 -7
  726. package/dist/chunks/chunk-VSDUSNIA.js.map +0 -7
  727. package/dist/chunks/chunk-VTK2FEH7.js +0 -229
  728. package/dist/chunks/chunk-VTK2FEH7.js.map +0 -7
  729. package/dist/chunks/chunk-VYQV5JRT.js.map +0 -7
  730. package/dist/chunks/chunk-XCEEQ5AB.js.map +0 -7
  731. package/dist/chunks/chunk-ZLNJDTCN.js +0 -226
  732. package/dist/chunks/chunk-ZLNJDTCN.js.map +0 -7
  733. package/dist/chunks/chunk-ZQMBS5SH.js.map +0 -7
  734. package/dist/ui/conversation-shortcut.d.ts +0 -3
  735. package/dist/ui/conversation-shortcut.d.ts.map +0 -1
  736. package/dist/ui/widget-activity.d.ts +0 -21
  737. package/dist/ui/widget-activity.d.ts.map +0 -1
  738. package/dist/verified/generated/authority-kernel.d.ts +0 -10
  739. package/dist/verified/generated/authority-kernel.js +0 -127
  740. package/dist/verified/generated/kernel.d.ts +0 -31
  741. package/dist/verified/generated/kernel.js +0 -389
  742. package/dist/verified/generated/lifecycle-kernel.d.ts +0 -7
  743. package/dist/verified/generated/lifecycle-kernel.js +0 -164
  744. package/dist/verified/generated/provider-kernel.d.ts +0 -9
  745. package/dist/verified/generated/provider-kernel.js +0 -87
  746. package/dist/verified/generated/storage-kernel.d.ts +0 -11
  747. package/dist/verified/generated/storage-kernel.js +0 -107
  748. package/docs/licenses/bend-apache-2.0.txt +0 -202
  749. package/node_modules/pi-coralbricks-provider/README.md +0 -306
  750. package/node_modules/pi-coralbricks-provider/auth.ts +0 -30
  751. package/node_modules/pi-coralbricks-provider/custom-models.json +0 -1
  752. package/node_modules/pi-coralbricks-provider/deprecated-models.json +0 -1
  753. package/node_modules/pi-coralbricks-provider/guard.ts +0 -155
  754. package/node_modules/pi-coralbricks-provider/index.ts +0 -662
  755. package/node_modules/pi-coralbricks-provider/models.json +0 -88
  756. package/node_modules/pi-coralbricks-provider/package.json +0 -74
  757. package/node_modules/pi-coralbricks-provider/park.ts +0 -122
  758. package/node_modules/pi-coralbricks-provider/patch.json +0 -34
  759. package/node_modules/pi-coralbricks-provider/scripts/update-models.js +0 -658
  760. package/node_modules/pi-coralbricks-provider/settings.ts +0 -143
  761. package/node_modules/pi-coralbricks-provider/sync-policy.ts +0 -309
  762. package/proofs/abi.json +0 -308
  763. package/proofs/authority-abi.json +0 -7
  764. package/proofs/authority-kernel.bend +0 -23
  765. package/proofs/authority-proof.bend +0 -74
  766. package/proofs/authority-spec.bend +0 -30
  767. package/proofs/authority-state.bend +0 -43
  768. package/proofs/authority-types.d.ts +0 -3
  769. package/proofs/kernel.bend +0 -139
  770. package/proofs/lifecycle-abi.json +0 -3
  771. package/proofs/lifecycle-kernel.bend +0 -11
  772. package/proofs/lifecycle-proof.bend +0 -249
  773. package/proofs/lifecycle-spec.bend +0 -261
  774. package/proofs/lifecycle-types.d.ts +0 -4
  775. package/proofs/lifecycle.bend +0 -119
  776. package/proofs/provider-abi.json +0 -4
  777. package/proofs/provider-kernel.bend +0 -14
  778. package/proofs/provider-plans.bend +0 -28
  779. package/proofs/provider-spec.bend +0 -14
  780. package/proofs/provider-types.d.ts +0 -5
  781. package/proofs/resource-proof.bend +0 -633
  782. package/proofs/resource-spec.bend +0 -133
  783. package/proofs/resources.bend +0 -160
  784. package/proofs/state-kernel.bend +0 -17
  785. package/proofs/state-plans.bend +0 -40
  786. package/proofs/state-proof.bend +0 -42
  787. package/proofs/state-spec.bend +0 -26
  788. package/proofs/storage-abi.json +0 -3
  789. package/proofs/storage-kernel.bend +0 -11
  790. package/proofs/storage-plans.bend +0 -100
  791. package/proofs/storage-proof.bend +0 -176
  792. package/proofs/storage-spec.bend +0 -70
  793. package/proofs/storage-types.d.ts +0 -8
  794. package/proofs/types.d.ts +0 -7
  795. package/scripts/test-verified-kernels.mjs +0 -107
  796. package/scripts/verified-kernels.mjs +0 -176
  797. /package/dist/chunks/{chunk-ZEXCKK4K.js.map → chunk-4WKD3YM3.js.map} +0 -0
  798. /package/dist/chunks/{chunk-5XBYFSI5.js.map → chunk-7YNE4NB2.js.map} +0 -0
  799. /package/dist/chunks/{chunk-K6QXUGS5.js.map → chunk-BMAEZNZ5.js.map} +0 -0
  800. /package/dist/chunks/{chunk-CCHZXF6K.js.map → chunk-CXYJJ3HZ.js.map} +0 -0
  801. /package/dist/chunks/{chunk-TIIIHPHF.js.map → chunk-GS67KDMV.js.map} +0 -0
  802. /package/dist/chunks/{chunk-D5NYNIST.js.map → chunk-H57KPL3V.js.map} +0 -0
  803. /package/dist/chunks/{chunk-INRXG4J5.js.map → chunk-HGD75NZY.js.map} +0 -0
  804. /package/dist/chunks/{chunk-UXIBKMUM.js.map → chunk-KIFOEBYJ.js.map} +0 -0
  805. /package/dist/chunks/{chunk-3FJUP3GV.js.map → chunk-L6H46CPY.js.map} +0 -0
  806. /package/dist/chunks/{chunk-FUY6XVRX.js.map → chunk-MPMEK3IQ.js.map} +0 -0
  807. /package/dist/chunks/{chunk-HP5P7NBO.js.map → chunk-MSDL7U6Q.js.map} +0 -0
  808. /package/dist/chunks/{chunk-ASSLHWZS.js.map → chunk-MX53BRAC.js.map} +0 -0
  809. /package/dist/chunks/{chunk-QT4W5YVB.js.map → chunk-RAA3FAYZ.js.map} +0 -0
  810. /package/dist/chunks/{chunk-53N2I4QA.js.map → chunk-TXCNZCZP.js.map} +0 -0
  811. /package/dist/chunks/{chunk-LEU5CDSL.js.map → chunk-XFOSUGLU.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/memory/context.ts", "../../src/memory/request-limits.ts", "../../src/memory/request-context.ts", "../../src/memory/request-cache.ts", "../../src/memory/source-observation.ts", "../../src/memory/host-source.ts", "../../src/memory/portable.ts", "../../src/memory/recall-service.ts", "../../src/verified/memory.ts", "../../src/memory/expand-service.ts", "../../src/memory/sessions-service.ts", "../../src/providers/memory-provider.ts"],
4
- "sourcesContent": ["import type { FabricExecutionOutcomeV1 } from \"../audit/trace.js\";\nimport type { EntryRange, MemoryCoverage } from \"./index.js\";\nimport type { MemoryBranches } from \"./lineage.js\";\nimport type {\n DigestHit,\n SearchResult,\n SearchSegment,\n SearchSegmentEntry,\n} from \"./search.js\";\nimport {\n compareLexical,\n normalizeMemoryPhrase,\n tokenizeLexical,\n type MemoryQueryMatch,\n type MemoryQueryMode,\n} from \"./tokenize.js\";\n\nexport const RECALL_DEFAULT_PAGE_SIZE = 10;\nexport const RECALL_MAX_PAGE_SIZE = 50;\nexport const RECALL_DEFAULT_SNIPPET_CHARS = 480;\nexport const RECALL_MAX_SNIPPET_CHARS = 2_000;\nexport const RECALL_MAX_RESPONSE_CHARS = 30_000;\n\nexport interface MemoryRecallCallArgs {\n query?: string;\n queryMode?: MemoryQueryMode;\n queryMatch?: MemoryQueryMatch;\n expectedSourceHash?: string;\n expectedLineageFingerprint?: string;\n branches?: MemoryBranches;\n scope?: string;\n offset?: number;\n pageSize?: number;\n snippetChars?: number;\n role?: string;\n tool?: string;\n ref?: string;\n provider?: string;\n action?: string;\n outcome?: FabricExecutionOutcomeV1;\n since?: number;\n until?: number;\n entryRange?: EntryRange;\n source?: string;\n}\n\ninterface MemoryExpandCallArgs {\n session: string;\n source?: string;\n expectedSourceHash?: string;\n expectedLineageFingerprint?: string;\n branches?: MemoryBranches;\n indices?: number[];\n entryIds?: string[];\n operationAddresses?: string[];\n entryRange?: EntryRange;\n before?: number;\n after?: number;\n entryOffset?: number;\n textOffset?: number;\n maxChars?: number;\n maxEntries?: number;\n}\n\ninterface MemorySourceBinding {\n sessionId: string;\n sessionFile: string;\n source?: string;\n sourceHash: string;\n branches: MemoryBranches;\n lineageFingerprint: string;\n tier: \"hot\" | \"cold\";\n}\n\ninterface MemoryExpandFollow {\n ref: \"memory.expand\";\n args: MemoryExpandCallArgs;\n}\n\ninterface MemoryRecallFollow {\n ref: \"memory.recall\";\n args: MemoryRecallCallArgs;\n}\n\ninterface MemoryRecallEntryHit {\n kind: \"entry\";\n sessionId: string;\n tier: \"hot\" | \"cold\";\n index: number;\n entryId: string | null;\n parentId: string | null;\n operationAddress: string | null;\n type: string;\n role: string | null;\n tool: string | null;\n ref: string | null;\n provider: string | null;\n action: string | null;\n timestamp: number | null;\n isError: boolean;\n outcome?: FabricExecutionOutcomeV1;\n score: number;\n snippet: string;\n truncated: boolean;\n follow: MemoryExpandFollow;\n}\n\ninterface MemoryRecallSessionHit {\n kind: \"session\";\n sessionId: string;\n tier: \"cold\";\n cwd: string;\n lastTimestamp: number | null;\n score: number;\n matchedTerms: number;\n matchedStructuralEntries: number;\n follow: MemoryRecallFollow;\n}\n\ntype MemoryRecallHit = MemoryRecallEntryHit | MemoryRecallSessionHit;\n\ninterface MemoryRecallContinuation {\n ref: \"memory.recall\";\n args: MemoryRecallCallArgs;\n}\n\nexport interface MemoryRecallResponse {\n total: number;\n hits: MemoryRecallHit[];\n next: MemoryRecallContinuation | null;\n coverage: MemoryCoverage;\n}\n\ninterface RecallPresentationInput {\n result: SearchResult;\n query?: string;\n queryMode: MemoryQueryMode;\n coverage: MemoryCoverage;\n offset?: number;\n pageSize: number;\n snippetChars: number;\n requestArgs: MemoryRecallCallArgs;\n}\n\ninterface Snippet {\n text: string;\n truncated: boolean;\n}\n\nconst boundedMetadata = (value: string | null | undefined, max = 512): string | null => {\n if (value === undefined || value === null) return null;\n return value.length <= max ? value : `${value.slice(0, Math.max(1, max - 1))}\u2026`;\n};\n\nconst safeSlice = (text: string, start: number, end: number): string => {\n let safeStart = Math.max(0, start);\n let safeEnd = Math.min(text.length, end);\n const startCode = text.charCodeAt(safeStart);\n if (safeStart > 0 && startCode >= 0xdc00 && startCode <= 0xdfff) safeStart += 1;\n const endCode = text.charCodeAt(safeEnd - 1);\n if (safeEnd < text.length && endCode >= 0xd800 && endCode <= 0xdbff) safeEnd -= 1;\n return text.slice(safeStart, safeEnd);\n};\n\nconst snippetAnchor = (\n text: string,\n query: string | undefined,\n queryMode: MemoryQueryMode,\n): number => {\n if (!query) return 0;\n const normalized = normalizeMemoryPhrase(text);\n if (queryMode === \"phrase\") {\n const phrase = normalizeMemoryPhrase(query.trim());\n return Math.max(0, normalized.indexOf(phrase));\n }\n if (queryMode === \"literal\") {\n const terms = [...new Set(tokenizeLexical(query))].sort((left, right) =>\n right.length - left.length || left.localeCompare(right)\n );\n for (const term of terms) {\n const index = normalized.indexOf(term);\n if (index >= 0) return index;\n }\n }\n return 0;\n};\n\nconst makeSnippet = (\n text: string,\n query: string | undefined,\n queryMode: MemoryQueryMode,\n maxChars: number,\n): Snippet => {\n if (text.length <= maxChars) return { text, truncated: false };\n const anchor = snippetAnchor(text, query, queryMode);\n const leadingContext = Math.floor(maxChars / 3);\n let start = Math.max(0, anchor - leadingContext);\n let end = Math.min(text.length, start + maxChars);\n if (end - start < maxChars) start = Math.max(0, end - maxChars);\n const body = safeSlice(text, start, end);\n return {\n text: `${start > 0 ? \"\u2026\" : \"\"}${body}${end < text.length ? \"\u2026\" : \"\"}`,\n truncated: true,\n };\n};\n\nconst sourceFromSegment = (segment: SearchSegment, sourceId?: string): MemorySourceBinding => ({\n sessionId: boundedMetadata(segment.sessionId) ?? \"\",\n sessionFile: segment.sessionFile,\n ...(sourceId ? { source: sourceId } : {}),\n sourceHash: segment.sourceHash,\n branches: segment.branches,\n lineageFingerprint: segment.lineageFingerprint,\n tier: segment.tier,\n});\n\nconst sourceFromDigest = (digest: DigestHit, sourceId?: string): MemorySourceBinding => ({\n sessionId: boundedMetadata(digest.sessionId) ?? \"\",\n sessionFile: digest.sessionFile,\n ...(sourceId ? { source: sourceId } : {}),\n sourceHash: digest.sourceHash,\n branches: digest.branches,\n lineageFingerprint: digest.lineageFingerprint,\n tier: \"cold\",\n});\n\nconst expandArgs = (\n source: MemorySourceBinding,\n entry: SearchSegmentEntry[\"entry\"],\n): MemoryExpandCallArgs => ({\n session: source.sessionFile,\n ...(source.source ? { source: source.source } : {}),\n expectedSourceHash: source.sourceHash,\n expectedLineageFingerprint: source.lineageFingerprint,\n branches: source.branches,\n indices: [entry.index],\n});\n\nconst entryHit = (\n segment: SearchSegment,\n item: SearchSegmentEntry,\n query: string | undefined,\n queryMode: MemoryQueryMode,\n snippetChars: number,\n sourceId?: string,\n): MemoryRecallEntryHit => {\n const entry = item.entry;\n const source = sourceFromSegment(segment, sourceId);\n const snippet = makeSnippet(entry.text, query, queryMode, snippetChars);\n return {\n kind: \"entry\",\n sessionId: source.sessionId,\n tier: source.tier,\n index: entry.index,\n entryId: boundedMetadata(entry.entryId),\n parentId: boundedMetadata(entry.parentId),\n operationAddress: boundedMetadata(entry.operationAddress),\n type: boundedMetadata(entry.type) ?? \"entry\",\n role: boundedMetadata(entry.role),\n tool: boundedMetadata(entry.toolName),\n ref: boundedMetadata(entry.ref),\n provider: boundedMetadata(entry.provider),\n action: boundedMetadata(entry.action),\n timestamp: entry.timestamp,\n isError: entry.isError,\n ...(entry.outcome ? { outcome: entry.outcome } : {}),\n score: item.score,\n snippet: snippet.text,\n truncated: snippet.truncated || entry.truncated,\n follow: { ref: \"memory.expand\", args: expandArgs(source, entry) },\n };\n};\n\nconst hydrationArgs = (\n digest: DigestHit,\n request: MemoryRecallCallArgs,\n): MemoryRecallCallArgs => {\n const { offset: _offset, entryRange: _entryRange, ...base } = request;\n return {\n ...base,\n scope: `session:${digest.sessionFile}`,\n branches: digest.branches,\n expectedSourceHash: digest.sourceHash,\n expectedLineageFingerprint: digest.lineageFingerprint,\n };\n};\n\nconst sessionHit = (\n digest: DigestHit,\n request: MemoryRecallCallArgs,\n sourceId?: string,\n): MemoryRecallSessionHit => {\n const source = sourceFromDigest(digest, sourceId);\n return {\n kind: \"session\",\n sessionId: source.sessionId,\n tier: \"cold\",\n cwd: boundedMetadata(digest.cwd, 2_048) ?? \"\",\n lastTimestamp: digest.lastTs,\n score: digest.score,\n matchedTerms: digest.matchedTerms,\n matchedStructuralEntries: digest.matchedStructuralEntries,\n follow: { ref: \"memory.recall\", args: hydrationArgs(digest, request) },\n };\n};\n\ntype RecallCandidate =\n | { kind: \"entry\"; segment: SearchSegment; item: SearchSegmentEntry }\n | { kind: \"session\"; digest: DigestHit };\n\nconst recallCandidateCache = new WeakMap<SearchResult, RecallCandidate[]>();\n\nconst flattenCandidates = (result: SearchResult): RecallCandidate[] => {\n const cached = recallCandidateCache.get(result);\n if (cached) return cached;\n const candidates: RecallCandidate[] = [];\n for (const item of result.items) {\n if (item.kind === \"digest\") {\n candidates.push({ kind: \"session\", digest: item.digest });\n continue;\n }\n for (const entry of item.segment.entries) {\n if (entry.matched) candidates.push({ kind: \"entry\", segment: item.segment, item: entry });\n }\n }\n candidates.sort((left, right) => {\n const leftScore = left.kind === \"entry\" ? left.item.score : left.digest.score;\n const rightScore = right.kind === \"entry\" ? right.item.score : right.digest.score;\n if (rightScore !== leftScore) return rightScore - leftScore;\n const leftMtime = left.kind === \"entry\" ? left.segment.sessionMtime : left.digest.sessionMtime;\n const rightMtime = right.kind === \"entry\" ? right.segment.sessionMtime : right.digest.sessionMtime;\n if (rightMtime !== leftMtime) return rightMtime - leftMtime;\n if (left.kind !== right.kind) return left.kind === \"entry\" ? -1 : 1;\n if (left.kind === \"entry\" && right.kind === \"entry\") {\n if (left.item.entry.index !== right.item.entry.index) {\n return left.item.entry.index - right.item.entry.index;\n }\n return compareLexical(left.segment.sessionFile, right.segment.sessionFile);\n }\n if (left.kind === \"session\" && right.kind === \"session\") {\n return compareLexical(left.digest.sessionFile, right.digest.sessionFile);\n }\n return 0;\n });\n recallCandidateCache.set(result, candidates);\n return candidates;\n};\n\nconst materializeCandidate = (\n candidate: RecallCandidate,\n query: string | undefined,\n queryMode: MemoryQueryMode,\n snippetChars: number,\n request: MemoryRecallCallArgs,\n sourceId?: string,\n): MemoryRecallHit => candidate.kind === \"session\"\n ? sessionHit(candidate.digest, request, sourceId)\n : entryHit(candidate.segment, candidate.item, query, queryMode, snippetChars, sourceId);\n\nconst canonicalNextArgs = (\n request: MemoryRecallCallArgs,\n offset: number,\n): MemoryRecallCallArgs => {\n const { offset: _offset, ...base } = request;\n return { ...base, offset };\n};\n\nexport const presentRecall = (input: RecallPresentationInput): MemoryRecallResponse => {\n const candidates = flattenCandidates(input.result);\n const start = input.offset ?? 0;\n let selected = candidates.slice(start, start + input.pageSize);\n\n const build = (pageCandidates: RecallCandidate[]): MemoryRecallResponse => {\n const hits = pageCandidates.map((candidate) =>\n materializeCandidate(\n candidate,\n input.query,\n input.queryMode,\n input.snippetChars,\n input.requestArgs,\n input.requestArgs.source,\n )\n );\n return {\n total: candidates.length,\n hits,\n next: start + hits.length < candidates.length\n ? { ref: \"memory.recall\", args: canonicalNextArgs(input.requestArgs, start + hits.length) }\n : null,\n coverage: input.coverage,\n };\n };\n\n let response = build(selected);\n while (selected.length > 1 && JSON.stringify(response).length > RECALL_MAX_RESPONSE_CHARS) {\n selected = selected.slice(0, -1);\n response = build(selected);\n }\n return response;\n};\n", "export const EXPAND_DEFAULT_MAX_CHARS = 20_000;\nexport const EXPAND_MAX_CHARS = 24_000;\nexport const EXPAND_DEFAULT_MAX_ENTRIES = 10;\nexport const EXPAND_MAX_ENTRIES = 20;\nexport const EXPAND_MAX_CONTEXT = 100;\nexport const EXPAND_MAX_EXACT_SELECTORS = 100;\nexport const SESSIONS_MAX = 500;\n", "import path from \"node:path\";\nimport type { FabricMemoryConfig } from \"../config.js\";\nimport type { MemorySourceRegistry } from \"./portable.js\";\nimport type { FabricScope } from \"../protocol.js\";\nimport {\n enumerateAllSessions,\n resolveScope,\n type ResolveScopeInput,\n type SessionRef,\n} from \"./discovery.js\";\nimport type { LiveSessionBranch, MemoryBranches } from \"./lineage.js\";\nimport { DEFAULT_HOT_SESSIONS, type MemoryIndexOptions } from \"./index.js\";\n\nexport interface MemoryProviderContext {\n agentDir: string;\n cwd: string;\n config: FabricMemoryConfig;\n sessionId?: string;\n sessionFile?: string;\n getLiveBranch?: () => LiveSessionBranch;\n /** Registered portable memory sources; present enables host-backed calls. */\n sources?: MemorySourceRegistry;\n /** Per-call host-issued scope: forwarded to source authorization and keyed into request caches. */\n fabricScope?: Readonly<FabricScope>;\n}\n\nexport const parseBranches = (value: unknown, action: string): MemoryBranches => {\n if (value === undefined) return \"active\";\n if (value === \"active\" || value === \"all\") return value;\n throw new Error(`${action} branches must be \"active\" or \"all\"`);\n};\n\nexport const resolveIndexOptions = (\n config: FabricMemoryConfig,\n agentDir: string,\n branches: MemoryBranches,\n liveBranchForFile?: MemoryIndexOptions[\"liveBranchForFile\"],\n): MemoryIndexOptions => ({\n indexDir: config.indexDir ?? `${agentDir}/fabric/memory-index`,\n maxEntryChars: config.maxEntryChars,\n branches,\n indexThinking: config.indexThinking ?? false,\n indexToolOutput: config.indexToolOutput ?? true,\n ...(liveBranchForFile ? { liveBranchForFile } : {}),\n hotSessions: config.hotSessions ?? DEFAULT_HOT_SESSIONS,\n digestTerms: config.digestTerms ?? 200,\n ...(config.maxColdVocabularyBytes === undefined\n ? {} : { maxColdVocabularyBytes: config.maxColdVocabularyBytes }),\n ...(config.maxColdCacheBytes === undefined ? {} : { maxColdCacheBytes: config.maxColdCacheBytes }),\n ...(config.maxSyncSessions === undefined ? {} : { maxSyncSessions: config.maxSyncSessions }),\n ...(config.maxSyncSourceBytes === undefined ? {} : { maxSyncSourceBytes: config.maxSyncSourceBytes }),\n ...(config.maxCacheCleanupFiles === undefined\n ? {} : { maxCacheCleanupFiles: config.maxCacheCleanupFiles }),\n});\n\nexport const resolveTierRefs = (refs: SessionRef[], context: MemoryProviderContext): SessionRef[] => {\n const all = enumerateAllSessions(context.agentDir, Number.MAX_SAFE_INTEGER);\n const known = new Set(all.map((ref) => ref.file));\n for (const ref of refs) {\n if (!known.has(ref.file)) all.push(ref);\n }\n return all;\n};\n\nexport const resolveRefs = (\n scope: string | undefined,\n context: MemoryProviderContext,\n boundedBrowse: boolean,\n): SessionRef[] => {\n const effectiveScope = scope ?? \"session\";\n const input: ResolveScopeInput = {\n agentDir: context.agentDir,\n cwd: context.cwd,\n scope: effectiveScope,\n maxSessions: boundedBrowse ? context.config.maxSessions : Number.MAX_SAFE_INTEGER,\n };\n if (context.sessionId) input.sessionId = context.sessionId;\n if (context.sessionFile) input.sessionFile = context.sessionFile;\n return resolveScope(input);\n};\n\nexport const liveBranchResolver = (\n context: MemoryProviderContext,\n): MemoryIndexOptions[\"liveBranchForFile\"] | undefined => {\n if (!context.sessionFile || !context.getLiveBranch) return undefined;\n const current = path.resolve(context.sessionFile);\n return (sessionFile) => path.resolve(sessionFile) === current\n ? context.getLiveBranch?.()\n : undefined;\n};\n\nexport const stalePointerError = (\n sessionFile: string,\n expectedSourceHash: string | undefined,\n actualSourceHash: string,\n expectedLineageFingerprint?: string,\n actualLineageFingerprint?: string,\n) => ({\n code: \"stale_pointer\",\n message: expectedLineageFingerprint !== undefined &&\n expectedLineageFingerprint !== actualLineageFingerprint\n ? \"Session active lineage changed after the pointer was issued.\"\n : \"Session source changed after the pointer was issued.\",\n sessionFile,\n ...(expectedSourceHash === undefined ? {} : { expectedSourceHash }),\n actualSourceHash,\n ...(expectedLineageFingerprint === undefined ? {} : { expectedLineageFingerprint }),\n ...(actualLineageFingerprint === undefined ? {} : { actualLineageFingerprint }),\n});\n\nexport const addressError = (message: string, entryCount?: number) => ({\n code: \"index_out_of_bounds\",\n message,\n ...(entryCount === undefined ? {} : { entryCount }),\n});\n\nexport const recallFailure = (error: { code: string; message: string; [key: string]: unknown }) => ({\n total: 0,\n hits: [],\n next: null,\n coverage: {\n complete: false,\n indexedSessions: 0,\n eligibleSessions: 0,\n staleSessions: 0,\n incompleteSessions: 0,\n reasons: [error.code],\n },\n error,\n});\n", "import path from \"node:path\";\nimport {\n RECALL_DEFAULT_PAGE_SIZE,\n RECALL_DEFAULT_SNIPPET_CHARS,\n type MemoryRecallCallArgs,\n} from \"./context.js\";\nimport type { MemoryBranches } from \"./lineage.js\";\nimport type { ExpandSessionSelection, ExpandedSessionEntry, NormalizedEntry } from \"./normalize.js\";\nimport type { MemoryCoverage } from \"./index.js\";\nimport type { SearchResult } from \"./search.js\";\nimport {\n sameSourceObservation,\n sameSourceObservations,\n type SourceObservation,\n} from \"./source-observation.js\";\n\nconst CONTINUATION_CACHE_TTL_MS = 5 * 60_000;\nconst EXPANSION_SNAPSHOT_LIMIT = 2;\nconst EXPANSION_SELECTION_LIMIT = 16;\n\nexport type CanonicalExpansionSelection = ExpandSessionSelection & {\n before?: number;\n after?: number;\n};\n\nexport interface ResolvedExpansionSelection {\n entries: ExpandedSessionEntry[];\n canonical: CanonicalExpansionSelection;\n anchorIndex: number | null;\n}\n\nexport interface ExpansionSnapshot {\n file: string;\n branches: MemoryBranches;\n /** Host scope digest; a snapshot is never served under another scope. */\n scopeDigest?: string;\n sourceHash: string;\n lineageFingerprint: string;\n observation: SourceObservation;\n entries: readonly NormalizedEntry[];\n selections: Map<string, ResolvedExpansionSelection>;\n touchedAt: number;\n}\n\nexport interface RecallContinuationCache {\n key: string;\n result: SearchResult;\n coverage: MemoryCoverage;\n requestArgs: MemoryRecallCallArgs;\n observations: readonly SourceObservation[];\n touchedAt: number;\n}\n\nexport const recallContinuationKey = (args: MemoryRecallCallArgs, scopeDigest?: string): string => JSON.stringify([\n scopeDigest ?? null,\n args.query ?? null,\n args.queryMode ?? \"literal\",\n args.queryMatch ?? null,\n args.expectedSourceHash ?? null,\n args.expectedLineageFingerprint ?? null,\n args.branches ?? \"active\",\n args.scope ?? \"session\",\n args.pageSize ?? RECALL_DEFAULT_PAGE_SIZE,\n args.snippetChars ?? RECALL_DEFAULT_SNIPPET_CHARS,\n args.role ?? null,\n args.tool ?? null,\n args.ref ?? null,\n args.provider ?? null,\n args.action ?? null,\n args.outcome ?? null,\n args.since ?? null,\n args.until ?? null,\n args.entryRange ? [args.entryRange.first, args.entryRange.last] : null,\n]);\n\nconst expansionSnapshotKey = (file: string, branches: MemoryBranches, scopeDigest?: string): string =>\n `${path.resolve(file)}\\0${branches}\\0${scopeDigest ?? \"\"}`;\n\nexport const expansionSelectionKey = (selection: CanonicalExpansionSelection): string => JSON.stringify([\n selection.indices ?? null,\n selection.entryIds ?? null,\n selection.operationAddresses ?? null,\n selection.entryRange ? [selection.entryRange.first, selection.entryRange.last] : null,\n selection.before ?? 0,\n selection.after ?? 0,\n]);\n\nexport class MemoryRequestCache {\n private recallContinuation: RecallContinuationCache | undefined;\n private readonly expansionSnapshots = new Map<string, ExpansionSnapshot>();\n\n cachedRecallContinuation(\n key: string,\n observations: readonly SourceObservation[] | null,\n ): RecallContinuationCache | undefined {\n const cached = this.recallContinuation;\n if (!cached || cached.key !== key) return undefined;\n if (\n !observations ||\n Date.now() - cached.touchedAt > CONTINUATION_CACHE_TTL_MS ||\n !sameSourceObservations(cached.observations, observations)\n ) {\n this.recallContinuation = undefined;\n return undefined;\n }\n cached.touchedAt = Date.now();\n return cached;\n }\n\n rememberRecallContinuation(cached: RecallContinuationCache): void {\n this.recallContinuation = cached;\n }\n\n forgetRecallContinuation(cached: RecallContinuationCache): void {\n if (this.recallContinuation === cached) this.recallContinuation = undefined;\n }\n\n cachedExpansionSnapshot(\n file: string,\n branches: MemoryBranches,\n observation: SourceObservation | null,\n scopeDigest?: string,\n ): ExpansionSnapshot | undefined {\n const key = expansionSnapshotKey(file, branches, scopeDigest);\n const cached = this.expansionSnapshots.get(key);\n if (!cached) return undefined;\n if (\n !observation ||\n Date.now() - cached.touchedAt > CONTINUATION_CACHE_TTL_MS ||\n !sameSourceObservation(cached.observation, observation)\n ) {\n this.expansionSnapshots.delete(key);\n return undefined;\n }\n cached.touchedAt = Date.now();\n this.expansionSnapshots.delete(key);\n this.expansionSnapshots.set(key, cached);\n return cached;\n }\n\n rememberExpansionSnapshot(snapshot: ExpansionSnapshot): void {\n const key = expansionSnapshotKey(snapshot.file, snapshot.branches, snapshot.scopeDigest);\n this.expansionSnapshots.delete(key);\n this.expansionSnapshots.set(key, snapshot);\n while (this.expansionSnapshots.size > EXPANSION_SNAPSHOT_LIMIT) {\n const oldest = this.expansionSnapshots.keys().next().value;\n if (oldest === undefined) break;\n this.expansionSnapshots.delete(oldest);\n }\n }\n\n rememberExpansionSelection(\n snapshot: ExpansionSnapshot,\n keys: readonly string[],\n selection: ResolvedExpansionSelection,\n ): void {\n for (const key of new Set(keys)) {\n snapshot.selections.delete(key);\n snapshot.selections.set(key, selection);\n }\n while (snapshot.selections.size > EXPANSION_SELECTION_LIMIT) {\n const oldest = snapshot.selections.keys().next().value;\n if (oldest === undefined) break;\n snapshot.selections.delete(oldest);\n }\n }\n\n forgetExpansionSnapshot(snapshot: ExpansionSnapshot): void {\n const key = expansionSnapshotKey(snapshot.file, snapshot.branches, snapshot.scopeDigest);\n if (this.expansionSnapshots.get(key) === snapshot) this.expansionSnapshots.delete(key);\n }\n}\n\n// Services can only access their own cache lifecycle operations.\nexport type RecallRequestCache = Pick<MemoryRequestCache,\n \"cachedRecallContinuation\" | \"rememberRecallContinuation\" | \"forgetRecallContinuation\"\n>;\n\nexport type ExpansionRequestCache = Pick<MemoryRequestCache,\n \"cachedExpansionSnapshot\" | \"rememberExpansionSnapshot\" | \"rememberExpansionSelection\" | \"forgetExpansionSnapshot\"\n>;\n", "import crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { SessionRef } from \"./discovery.js\";\nimport type { LiveSessionBranch, MemoryBranches } from \"./lineage.js\";\nimport type { MemoryIndexOptions } from \"./index.js\";\n\ninterface SourceIdentity {\n device: bigint;\n inode: bigint;\n size: bigint;\n modifiedAt: bigint;\n changedAt: bigint;\n}\n\nexport interface SourceObservation {\n file: string;\n identity: SourceIdentity;\n liveBranchSignature: string | null;\n}\n\ntype LiveBranchResolver = MemoryIndexOptions[\"liveBranchForFile\"];\n\nconst sourceIdentity = (file: string): SourceIdentity | null => {\n try {\n const stat = fs.statSync(file, { bigint: true });\n if (!stat.isFile()) return null;\n return {\n device: stat.dev,\n inode: stat.ino,\n size: stat.size,\n modifiedAt: stat.mtimeNs,\n changedAt: stat.ctimeNs,\n };\n } catch {\n return null;\n }\n};\n\nconst sameSourceIdentity = (left: SourceIdentity, right: SourceIdentity): boolean =>\n left.device === right.device &&\n left.inode === right.inode &&\n left.size === right.size &&\n left.modifiedAt === right.modifiedAt &&\n left.changedAt === right.changedAt;\n\nconst liveBranchSignature = (branch: LiveSessionBranch | undefined): string | null =>\n branch ? `${branch.leafId ?? \"\"}\\0${branch.entries.length}` : null;\n\nexport const observeSource = (\n file: string,\n branches: MemoryBranches,\n liveBranch: LiveSessionBranch | undefined,\n): SourceObservation | null => {\n const identity = sourceIdentity(file);\n if (!identity) return null;\n return {\n file: path.resolve(file),\n identity,\n liveBranchSignature: branches === \"active\" ? liveBranchSignature(liveBranch) : null,\n };\n};\n\nconst hostIdentity = (revision: string, sourceHash: string): SourceIdentity => {\n const digest = crypto.createHash(\"sha256\").update(`${revision}\\u0000${sourceHash}`).digest(\"hex\");\n return {\n device: BigInt(parseInt(digest.slice(0, 8), 16)),\n inode: BigInt(parseInt(digest.slice(8, 16), 16)),\n size: BigInt(parseInt(digest.slice(16, 24), 16)),\n modifiedAt: BigInt(parseInt(digest.slice(24, 32), 16)),\n changedAt: BigInt(parseInt(digest.slice(32, 40), 16)),\n };\n};\n\n/**\n * Observation identity for a portable host source snapshot: derived from the\n * adapter revision plus the engine's source hash, so a changed or reloaded\n * snapshot invalidates request caches without any filesystem access.\n */\nexport const observeHostSource = (\n displayKey: string,\n revision: string,\n sourceHash: string,\n): SourceObservation => ({\n file: displayKey,\n identity: hostIdentity(revision, sourceHash),\n liveBranchSignature: null,\n});\n\nexport const observeSources = (\n refs: readonly SessionRef[],\n branches: MemoryBranches,\n liveResolver: LiveBranchResolver,\n): SourceObservation[] | null => {\n const observations: SourceObservation[] = [];\n for (const ref of refs) {\n const liveBranch = branches === \"active\" ? liveResolver?.(ref.file) : undefined;\n const observation = observeSource(ref.file, branches, liveBranch);\n if (!observation) return null;\n observations.push(observation);\n }\n return observations;\n};\n\nexport const sameSourceObservation = (left: SourceObservation, right: SourceObservation): boolean =>\n left.file === right.file &&\n sameSourceIdentity(left.identity, right.identity) &&\n left.liveBranchSignature === right.liveBranchSignature;\n\nexport const sameSourceObservations = (\n left: readonly SourceObservation[],\n right: readonly SourceObservation[],\n): boolean => left.length === right.length && left.every((item, index) =>\n sameSourceObservation(item, right[index]!)\n);\n", "import crypto from \"node:crypto\";\nimport { foldSessionDigest } from \"./digest.js\";\nimport { resolveSessionTarget, type SessionRef } from \"./discovery.js\";\nimport {\n classifySessionTiers,\n digestPolicy,\n fitDigestCache,\n fingerprintSource,\n loadTieredIndex,\n MEMORY_CACHE_VERSION,\n missingDigest,\n missingShard,\n shardPolicy,\n type DigestShard,\n type EntryRange,\n type MemoryCoverage,\n type MemoryIndexOptions,\n type Shard,\n type SourceState,\n type TieredIndexBundle,\n} from \"./index.js\";\nimport {\n reconstructRecordsLineage,\n reconstructSessionLineage,\n type MemoryBranches,\n type SessionLineage,\n} from \"./lineage.js\";\nimport {\n normalizeRecords,\n normalizeSession,\n type NormalizationCoverage,\n type NormalizedEntry,\n} from \"./normalize.js\";\nimport type {\n MemorySourceAction,\n MemorySourceCoverage,\n MemorySourceListPage,\n MemorySourceRecord,\n MemorySourceSessionDescriptor,\n MemorySourceSessionMetadata,\n MemorySourceSnapshot,\n PortableMemorySource,\n} from \"./portable.js\";\nimport { MemorySourceError } from \"./portable.js\";\nimport type { FabricScope } from \"../protocol.js\";\nimport { observeHostSource, observeSource, observeSources, type SourceObservation } from \"./source-observation.js\";\nimport {\n liveBranchResolver,\n resolveTierRefs,\n type MemoryProviderContext,\n} from \"./request-context.js\";\n\nconst HOST_KEY_PREFIX = \"memory-source:\";\nconst REASON_PATTERN = /^[a-z0-9_.:-]{1,64}$/;\n\nexport interface HostSnapshot {\n sourceId: string;\n sessionKey: string;\n displayKey: string;\n sessionId: string;\n revision: string;\n metadata: MemorySourceSessionMetadata;\n records: readonly MemorySourceRecord[];\n coverageReasons: string[];\n selectedLeafId?: string | null;\n}\n\n/** Opaque, stable, non-filesystem session key shown in public outputs. */\nconst hostDisplayKey = (sourceId: string, sessionKey: string): string =>\n `${HOST_KEY_PREFIX}${sourceId}/${sessionKey}`;\n\n/** Accept both the engine's display key and the adapter's raw session key. */\nconst hostSessionKey = (sourceId: string, session: string): string => {\n const prefix = `${HOST_KEY_PREFIX}${sourceId}/`;\n return session.startsWith(prefix) ? session.slice(prefix.length) : session;\n};\n\nexport const resolveRegisteredSource = (\n registry: { get(id: string): PortableMemorySource | undefined } | undefined,\n sourceId: string,\n): PortableMemorySource => {\n const source = registry?.get(sourceId);\n if (!source) throw new MemorySourceError(\"source_not_found\", `Memory source not registered: ${sourceId}`);\n return source;\n};\n\nexport const memorySourceFailure = (error: unknown): { code: string; message: string } | null =>\n error instanceof MemorySourceError ? { code: error.code, message: error.message } : null;\n\nexport const checkAbort = (signal: AbortSignal | undefined): void => {\n if (signal?.aborted) throw new MemorySourceError(\"aborted\", \"Memory source call was aborted.\");\n};\n\nconst assertAuthorized = async (\n source: PortableMemorySource,\n action: MemorySourceAction,\n sessionKey: string | null,\n scope: Readonly<FabricScope> | undefined,\n): Promise<void> => {\n if (!source.authorize) return;\n let allowed: boolean;\n try {\n allowed = await (scope ? source.authorize(action, sessionKey, scope) : source.authorize(action, sessionKey));\n } catch {\n // Adapter failures stay sanitized: no backend error text, paths, or\n // credentials may reach public memory results.\n throw new MemorySourceError(\"source_unauthorized\", \"Memory source authorization failed.\");\n }\n if (allowed !== true) {\n throw new MemorySourceError(\"source_unauthorized\", \"Memory source denied access.\");\n }\n};\n\nconst coverageReasons = (coverage: MemorySourceCoverage | undefined): string[] => {\n if (!coverage || coverage.complete !== false) return [];\n const reason = typeof coverage.reason === \"string\" && REASON_PATTERN.test(coverage.reason)\n ? `source_coverage:${coverage.reason}`\n : \"source_coverage_incomplete\";\n return [reason];\n};\n\nconst asSessionKey = (value: unknown): string =>\n typeof value === \"string\" && value.length > 0 ? value : \"\";\n\nconst normalizeListResponse = (\n response: readonly MemorySourceSessionDescriptor[] | MemorySourceListPage,\n): { sessions: readonly MemorySourceSessionDescriptor[]; coverageReasons: string[] } =>\n Array.isArray(response)\n ? { sessions: response as readonly MemorySourceSessionDescriptor[], coverageReasons: [] }\n : { sessions: (response as MemorySourceListPage).sessions, coverageReasons: coverageReasons((response as MemorySourceListPage).coverage) };\n\n/**\n * Validate one adapter snapshot. Authorization is re-checked after the async\n * load so a revocation during the load fails closed before any content\n * reaches the engine. The returned snapshot deep-clones records and metadata,\n * so later adapter mutation (including nested objects) cannot change what the\n * engine already indexed; non-JSON-serializable records fail closed as\n * invalid_source_response because the engine's own hashing is JSON-canonical.\n */\nconst loadHostSnapshot = async (\n source: PortableMemorySource,\n sessionKey: string,\n action: MemorySourceAction,\n signal?: AbortSignal,\n scope?: Readonly<FabricScope>,\n): Promise<HostSnapshot | null> => {\n checkAbort(signal);\n await assertAuthorized(source, action, sessionKey, scope);\n const response = await source.loadSession(sessionKey, signal === undefined ? {} : { signal });\n checkAbort(signal);\n await assertAuthorized(source, action, sessionKey, scope);\n if (response === null || response === undefined) return null;\n const key = asSessionKey(response.sessionKey);\n const revision = asSessionKey(response.revision);\n if (!revision || !Array.isArray(response.records) || key !== sessionKey) {\n throw new MemorySourceError(\"invalid_source_response\", \"Memory source returned an invalid snapshot.\");\n }\n if (!response.records.every((record) =>\n record !== null && typeof record === \"object\" && !Array.isArray(record))) {\n throw new MemorySourceError(\"invalid_source_response\", \"Memory source snapshot has non-object records.\");\n }\n let records: readonly MemorySourceRecord[];\n try {\n records = JSON.parse(JSON.stringify(response.records)) as MemorySourceRecord[];\n } catch {\n throw new MemorySourceError(\n \"invalid_source_response\",\n \"Memory source snapshot records are not JSON-serializable.\",\n );\n }\n if (response.selectedLeafId !== undefined && response.selectedLeafId !== null &&\n (typeof response.selectedLeafId !== \"string\" || !records.some(record =>\n record.type !== \"session\" && record.id === response.selectedLeafId))) {\n throw new MemorySourceError(\"invalid_source_response\", \"Memory source selected leaf is invalid.\");\n }\n return {\n sourceId: source.id,\n sessionKey,\n displayKey: hostDisplayKey(source.id, sessionKey),\n sessionId: response.sessionId ?? sessionKey,\n revision,\n metadata: { ...(response.metadata ?? {}) },\n records,\n ...(response.selectedLeafId !== undefined ? { selectedLeafId: response.selectedLeafId } : {}),\n coverageReasons: coverageReasons(response.coverage),\n };\n};\n\nexport const listHostSnapshots = async (\n source: PortableMemorySource,\n limit: number,\n action: MemorySourceAction,\n signal?: AbortSignal,\n scope?: Readonly<FabricScope>,\n): Promise<{ snapshots: HostSnapshot[]; coverageReasons: string[] }> => {\n checkAbort(signal);\n await assertAuthorized(source, action, null, scope);\n const boundedLimit = Math.max(0, Math.floor(limit));\n const listed = normalizeListResponse(\n await source.listSessions(signal === undefined ? { limit: boundedLimit } : { limit: boundedLimit, signal }),\n );\n checkAbort(signal);\n const snapshots: HostSnapshot[] = [];\n const coverageReasons = new Set(listed.coverageReasons);\n if (listed.sessions.length > boundedLimit) {\n coverageReasons.add(\"source_limit_exceeded\");\n }\n for (const descriptor of listed.sessions.slice(0, boundedLimit)) {\n checkAbort(signal);\n const key = asSessionKey(descriptor.sessionKey);\n if (!key) {\n coverageReasons.add(\"invalid_source_response\");\n continue;\n }\n const snapshot = await loadHostSnapshot(source, key, action, signal, scope);\n if (!snapshot) {\n coverageReasons.add(\"source_unavailable\");\n continue;\n }\n for (const reason of snapshot.coverageReasons) coverageReasons.add(reason);\n snapshots.push(snapshot);\n }\n if (snapshots.length === 0) {\n await assertAuthorized(source, action, null, scope);\n }\n return { snapshots, coverageReasons: [...coverageReasons] };\n};\n\nconst hostSourceState = (snapshot: HostSnapshot): SourceState => {\n const canonical = JSON.stringify(snapshot.records);\n const sourceHash = crypto\n .createHash(\"sha256\")\n .update(`${snapshot.revision}\\u0000${canonical}`)\n .digest(\"hex\");\n return {\n mtime: snapshot.metadata.updatedAt ?? 0,\n size: Buffer.byteLength(canonical, \"utf8\"),\n sourceHash,\n };\n};\n\nconst hostRef = (snapshot: HostSnapshot): SessionRef => ({\n id: snapshot.sessionId,\n file: snapshot.displayKey,\n cwd: snapshot.metadata.cwd ?? \"\",\n mtime: snapshot.metadata.updatedAt ?? 0,\n});\n\nconst hostLineage = (snapshot: HostSnapshot, branches: MemoryBranches): SessionLineage =>\n reconstructRecordsLineage(snapshot.records, branches, undefined, snapshot.selectedLeafId);\n\nconst hostIdentity = (sessionFile: string, sessionId: string | undefined, cwd: string | undefined) => ({\n sessionFile,\n ...(sessionId !== undefined ? { sessionId } : {}),\n ...(cwd !== undefined ? { cwd } : {}),\n});\n\nconst mergedCoverage = (\n base: NormalizationCoverage,\n extra: readonly string[],\n): NormalizationCoverage => {\n if (extra.length === 0) return base;\n const reasons = [...new Set([...base.reasons, ...extra])].sort();\n return { complete: false, reasons };\n};\n\nconst buildHostShard = (\n snapshot: HostSnapshot,\n options: MemoryIndexOptions,\n tier: \"hot\" | \"cold\",\n entryRange?: EntryRange,\n): Shard => {\n const state = hostSourceState(snapshot);\n const lineage = hostLineage(snapshot, options.branches ?? \"active\");\n const { entries, header, indexCoverage } = normalizeRecords(\n snapshot.records,\n hostIdentity(snapshot.displayKey, snapshot.sessionId, snapshot.metadata.cwd),\n options.maxEntryChars,\n {\n lineage,\n indexThinking: options.indexThinking ?? false,\n indexToolOutput: options.indexToolOutput ?? true,\n },\n );\n const selected = entryRange\n ? entries.filter((entry) => entry.index >= entryRange.first && entry.index <= entryRange.last)\n : entries;\n return {\n cacheVersion: MEMORY_CACHE_VERSION,\n kind: \"shard\",\n sessionFile: snapshot.displayKey,\n sessionId: header?.sessionId ?? snapshot.sessionId,\n mtime: state.mtime,\n size: state.size,\n sourceHash: state.sourceHash,\n branches: lineage.branches,\n lineageFingerprint: lineage.fingerprint,\n policy: shardPolicy(options, lineage),\n cacheBytes: 0,\n cacheSourceRatio: 0,\n entries: selected,\n totalEntryCount: entries.length,\n indexCoverage: mergedCoverage(indexCoverage, snapshot.coverageReasons),\n tier,\n };\n};\n\nconst buildHostDigest = (snapshot: HostSnapshot, options: MemoryIndexOptions): DigestShard => {\n const state = hostSourceState(snapshot);\n const lineage = hostLineage(snapshot, options.branches ?? \"active\");\n const { entries, header, indexCoverage } = normalizeRecords(\n snapshot.records,\n hostIdentity(snapshot.displayKey, snapshot.sessionId, snapshot.metadata.cwd),\n Number.MAX_SAFE_INTEGER,\n {\n lineage,\n indexThinking: options.indexThinking ?? false,\n indexToolOutput: options.indexToolOutput ?? true,\n },\n );\n const digest = foldSessionDigest({\n sessionId: header?.sessionId ?? snapshot.sessionId,\n file: snapshot.displayKey,\n cwd: header?.cwd ?? snapshot.metadata.cwd ?? \"\",\n entries,\n maxVocabularyBytes: options.maxColdVocabularyBytes ?? 512 * 1024,\n normalizationCoverage: mergedCoverage(indexCoverage, snapshot.coverageReasons),\n });\n return fitDigestCache({\n cacheVersion: MEMORY_CACHE_VERSION,\n kind: \"digest\",\n ...digest,\n mtime: state.mtime,\n size: state.size,\n sourceHash: state.sourceHash,\n branches: lineage.branches,\n lineageFingerprint: lineage.fingerprint,\n policy: digestPolicy(options, lineage),\n cacheBytes: 0,\n cacheSourceRatio: 0,\n }, options.maxColdCacheBytes ?? 1024 * 1024);\n};\n\n/** In-memory tiered index for host sources: identical tiers, budgets, and\n * coverage semantics as the filesystem index, with no disk cache writes. */\nexport const loadHostTieredIndex = (\n snapshots: readonly HostSnapshot[],\n options: MemoryIndexOptions,\n hydrate = false,\n entryRange?: EntryRange,\n extraReasons: readonly string[] = [],\n): TieredIndexBundle => {\n const refs = snapshots.map(hostRef);\n const tiers = classifySessionTiers(refs, options.hotSessions ?? 50);\n const maxSessions = options.maxSyncSessions ?? 10_000;\n const maxSourceBytes = options.maxSyncSourceBytes ?? 512 * 1024 * 1024;\n const shards: Shard[] = [];\n const digests: DigestShard[] = [];\n const reasons = new Set(extraReasons);\n let indexedSessions = 0;\n let incompleteSessions = 0;\n let processedSessions = 0;\n let processedSourceBytes = 0;\n const byKey = new Map(snapshots.map((snapshot) => [snapshot.displayKey, snapshot]));\n for (const ref of refs) {\n const snapshot = byKey.get(ref.file);\n if (!snapshot) {\n reasons.add(\"source_unavailable\");\n continue;\n }\n const size = hostSourceState(snapshot).size;\n if (processedSessions >= maxSessions) {\n reasons.add(\"max_sync_sessions\");\n continue;\n }\n const tier = tiers.get(ref.file) ?? \"cold\";\n const sourceWorkBytes = size * (hydrate && tier === \"cold\" ? 6 : 3);\n if (processedSourceBytes + sourceWorkBytes > maxSourceBytes) {\n reasons.add(\"max_sync_source_bytes\");\n continue;\n }\n processedSessions += 1;\n processedSourceBytes += sourceWorkBytes;\n if (hydrate) {\n if (tier === \"cold\") digests.push(buildHostDigest(snapshot, options));\n const shard = buildHostShard(snapshot, options, \"cold\", entryRange);\n shards.push(shard);\n if (shard.sourceHash) indexedSessions += 1;\n if (shard.sourceHash && !shard.indexCoverage.complete) {\n incompleteSessions += 1;\n for (const reason of shard.indexCoverage.reasons) reasons.add(reason);\n }\n } else if (tier === \"hot\") {\n const shard = buildHostShard(snapshot, options, \"hot\");\n shards.push(shard);\n if (shard.sourceHash) indexedSessions += 1;\n if (shard.sourceHash && !shard.indexCoverage.complete) {\n incompleteSessions += 1;\n for (const reason of shard.indexCoverage.reasons) reasons.add(reason);\n }\n } else {\n const digest = buildHostDigest(snapshot, options);\n digests.push(digest);\n if (digest.sourceHash) indexedSessions += 1;\n if (!digest.indexCoverage.complete) {\n incompleteSessions += 1;\n for (const reason of digest.indexCoverage.reasons) reasons.add(reason);\n }\n }\n }\n const eligibleSessions = refs.length;\n const staleSessions = eligibleSessions - indexedSessions;\n // Extra reasons (adapter coverage caps, list truncation) also demote the\n // result to incomplete: a truncated source is never presented as complete.\n const coverage: MemoryCoverage = {\n complete: reasons.size === 0 && staleSessions === 0 && incompleteSessions === 0,\n indexedSessions,\n eligibleSessions,\n staleSessions,\n incompleteSessions,\n reasons: [...reasons].sort(),\n };\n return { shards, digests, refs, tiers, coverage };\n};\n\n/** Source-resolution strategy shared by filesystem and host-backed calls. */\nexport interface RecallSourcePlan {\n refs: SessionRef[];\n sessionKey: string | null;\n observeAll(branches: MemoryBranches): readonly SourceObservation[] | null;\n stateFor(ref: SessionRef): SourceState | null;\n lineageFor(ref: SessionRef, branches: MemoryBranches): SessionLineage;\n loadIndex(\n options: MemoryIndexOptions,\n hydrate: boolean,\n entryRange?: EntryRange,\n ): TieredIndexBundle;\n}\n\nexport const fileRecallPlan = (refs: SessionRef[], context: MemoryProviderContext): RecallSourcePlan => {\n const liveResolver = liveBranchResolver(context);\n return {\n refs,\n sessionKey: null,\n observeAll: (branches) => observeSources(refs, branches, liveResolver),\n stateFor: (ref) => fingerprintSource(ref.file),\n lineageFor: (ref, branches) =>\n reconstructSessionLineage(ref.file, branches, liveResolver?.(ref.file)),\n loadIndex: (options, hydrate, entryRange) =>\n loadTieredIndex(refs, resolveTierRefs(refs, context), options, hydrate, entryRange),\n };\n};\n\nexport const hostRecallPlan = async (\n source: PortableMemorySource,\n sourceId: string,\n sessionKey: string | null,\n context: MemoryProviderContext,\n signal?: AbortSignal,\n): Promise<RecallSourcePlan> => {\n const loaded = sessionKey !== null\n ? await (async () => {\n const snapshot = await loadHostSnapshot(source, sessionKey, \"recall\", signal, context.fabricScope);\n return snapshot\n ? { snapshots: [snapshot], coverageReasons: [] as string[] }\n : null;\n })()\n : await listHostSnapshots(source, context.config.maxSessions, \"recall\", signal, context.fabricScope);\n if (!loaded) throw new MemorySourceError(\"session_not_found\", `Session not found in source ${sourceId}: ${sessionKey}`);\n const snapshots = loaded.snapshots;\n const refs = snapshots.map(hostRef);\n const byKey = new Map(snapshots.map((snapshot) => [snapshot.displayKey, snapshot]));\n const stateByKey = new Map<string, SourceState>();\n const stateOf = (snapshot: HostSnapshot): SourceState => {\n let state = stateByKey.get(snapshot.displayKey);\n if (!state) {\n state = hostSourceState(snapshot);\n stateByKey.set(snapshot.displayKey, state);\n }\n return state;\n };\n return {\n refs,\n sessionKey,\n observeAll: (branches) =>\n snapshots.map((snapshot) =>\n ({ ...observeHostSource(snapshot.displayKey, snapshot.revision, stateOf(snapshot).sourceHash), liveBranchSignature: hostLineage(snapshot, branches).fingerprint })),\n stateFor: (ref) => {\n const snapshot = byKey.get(ref.file);\n return snapshot ? stateOf(snapshot) : null;\n },\n lineageFor: (ref, branches) => {\n const snapshot = byKey.get(ref.file);\n return snapshot\n ? hostLineage(snapshot, branches)\n : reconstructSessionLineage(ref.file, branches);\n },\n loadIndex: (options, hydrate, entryRange) =>\n loadHostTieredIndex(snapshots, options, hydrate, entryRange, loaded.coverageReasons),\n };\n};\n\nexport interface ExpansionAccess {\n ref: SessionRef;\n state(): SourceState | null;\n lineage(branches: MemoryBranches): SessionLineage;\n observe(branches: MemoryBranches): SourceObservation | null;\n normalizeFull(\n branches: MemoryBranches,\n policy: { indexThinking: boolean; indexToolOutput: boolean },\n lineage?: SessionLineage,\n ): { entries: NormalizedEntry[]; indexCoverage: NormalizationCoverage } | null;\n}\n\nexport const fileExpansionAccess = (\n session: string,\n context: MemoryProviderContext,\n): ExpansionAccess | null => {\n const ref = resolveSessionTarget(context.agentDir, session);\n if (!ref) return null;\n const liveResolver = liveBranchResolver(context);\n return {\n ref,\n state: () => fingerprintSource(ref.file),\n lineage: (branches) => reconstructSessionLineage(ref.file, branches, liveResolver?.(ref.file)),\n observe: (branches) =>\n observeSource(ref.file, branches, branches === \"active\" ? liveResolver?.(ref.file) : undefined),\n normalizeFull: (branches, policy, lineage) => {\n const resolvedLineage = lineage ??\n reconstructSessionLineage(ref.file, branches, liveResolver?.(ref.file));\n const normalized = normalizeSession(ref.file, Number.MAX_SAFE_INTEGER, {\n lineage: resolvedLineage,\n ...policy,\n });\n return normalized.header === null && normalized.entries.length === 0 &&\n normalized.indexCoverage.reasons.includes(\"source_unavailable\")\n ? null\n : { entries: normalized.entries, indexCoverage: normalized.indexCoverage };\n },\n };\n};\n\nexport const hostExpansionAccess = async (\n sourceId: string,\n session: string,\n context: MemoryProviderContext,\n signal?: AbortSignal,\n): Promise<ExpansionAccess> => {\n const source = resolveRegisteredSource(context.sources, sourceId);\n const sessionKey = hostSessionKey(sourceId, session);\n const snapshot = await loadHostSnapshot(source, sessionKey, \"expand\", signal, context.fabricScope);\n if (!snapshot) {\n throw new MemorySourceError(\"session_not_found\", `Session not found in source ${sourceId}: ${sessionKey}`);\n }\n const state = hostSourceState(snapshot);\n const ref = hostRef(snapshot);\n return {\n ref,\n state: () => state,\n lineage: (branches) => hostLineage(snapshot, branches),\n observe: (branches) => ({ ...observeHostSource(snapshot.displayKey, snapshot.revision, state.sourceHash), liveBranchSignature: hostLineage(snapshot, branches).fingerprint }),\n normalizeFull: (branches, policy) => {\n const normalized = normalizeRecords(\n snapshot.records,\n hostIdentity(snapshot.displayKey, snapshot.sessionId, snapshot.metadata.cwd),\n Number.MAX_SAFE_INTEGER,\n { lineage: hostLineage(snapshot, branches), ...policy },\n );\n return {\n entries: normalized.entries,\n indexCoverage: mergedCoverage(normalized.indexCoverage, snapshot.coverageReasons),\n };\n },\n };\n};\n", "// Portable memory sources: a versioned, host-embeddable interface that feeds\n// explicit authorized session snapshots into the existing memory engine. This\n// module stays lightweight: no extension, UI, command, or provider runtime.\nimport type { FabricScope } from \"../protocol.js\";\n\nexport const MEMORY_SOURCE_INTERFACE_VERSION = 1;\n\nexport type MemorySourceRecord = { [key: string]: unknown };\n\nexport interface MemorySourceSessionMetadata {\n sessionId?: string;\n title?: string;\n cwd?: string;\n updatedAt?: number;\n}\n\n/**\n * Adapter-reported coverage of its own retained data. Omit (or omit\n * `complete`) only when the adapter returned everything it currently holds;\n * an adapter that caps enumeration or record loading must report\n * `complete: false` with a stable machine-readable reason so the engine never\n * presents a silently truncated archive as authoritative.\n */\nexport interface MemorySourceCoverage {\n complete: boolean;\n reason?: string;\n}\n\nexport interface MemorySourceSessionDescriptor {\n sessionKey: string;\n sessionId?: string;\n revision: string;\n metadata?: MemorySourceSessionMetadata;\n}\n\nexport interface MemorySourceSnapshot extends MemorySourceSessionDescriptor {\n records: readonly MemorySourceRecord[];\n /** Authoritative live leaf; null means an empty active path, omitted uses persisted semantics. */\n selectedLeafId?: string | null;\n /** Record-loading coverage; omitted means complete. */\n coverage?: MemorySourceCoverage;\n}\n\nexport interface MemorySourceListPage {\n sessions: readonly MemorySourceSessionDescriptor[];\n /** Enumeration coverage; omitted means complete. */\n coverage?: MemorySourceCoverage;\n}\n\nexport type MemorySourceAction = \"list\" | \"recall\" | \"expand\";\n\nexport interface MemorySourceRequestContext {\n signal?: AbortSignal;\n}\n\nexport interface PortableMemorySource {\n readonly interfaceVersion: typeof MEMORY_SOURCE_INTERFACE_VERSION;\n readonly id: string;\n listSessions(\n request: { limit: number } & MemorySourceRequestContext,\n ): Promise<readonly MemorySourceSessionDescriptor[] | MemorySourceListPage>;\n loadSession(\n sessionKey: string,\n request: MemorySourceRequestContext,\n ): Promise<MemorySourceSnapshot | null>;\n /** `scope` is the caller's host-issued scope, so a source can filter before content enters context. */\n authorize?(\n action: MemorySourceAction,\n sessionKey: string | null,\n scope?: Readonly<FabricScope>,\n ): boolean | Promise<boolean>;\n}\n\nexport type MemorySourceErrorCode =\n | \"source_not_found\"\n | \"source_unauthorized\"\n | \"invalid_source_response\"\n | \"session_not_found\"\n | \"aborted\";\n\nexport class MemorySourceError extends Error {\n constructor(\n readonly code: MemorySourceErrorCode,\n message: string,\n ) {\n super(message);\n this.name = \"MemorySourceError\";\n }\n}\n\nconst SOURCE_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;\n\nconst isRecord = (value: unknown): value is MemorySourceRecord =>\n value !== null && typeof value === \"object\" && !Array.isArray(value);\n\nconst assertValidSource = (source: PortableMemorySource): void => {\n if (!isRecord(source) || typeof source !== \"object\") {\n throw new TypeError(\"A portable memory source must be an object\");\n }\n if (source.interfaceVersion !== MEMORY_SOURCE_INTERFACE_VERSION) {\n throw new TypeError(\n `Portable memory source interface version must be ${MEMORY_SOURCE_INTERFACE_VERSION}`,\n );\n }\n if (typeof source.id !== \"string\" || !SOURCE_ID_PATTERN.test(source.id)) {\n throw new TypeError(\n \"Portable memory source id must be 1-128 chars of letters, digits, dot, underscore, or dash\",\n );\n }\n if (typeof source.listSessions !== \"function\" || typeof source.loadSession !== \"function\") {\n throw new TypeError(\"A portable memory source requires listSessions and loadSession\");\n }\n};\n\n/** Validate a portable memory source at registration time; returns it unchanged. */\nexport const defineMemorySource = (source: PortableMemorySource): PortableMemorySource => {\n assertValidSource(source);\n return source;\n};\n\nexport interface MemorySourceRegistry {\n register(source: PortableMemorySource): void;\n get(id: string): PortableMemorySource | undefined;\n ids(): readonly string[];\n}\n\nexport const createMemorySourceRegistry = (): MemorySourceRegistry => {\n const sources = new Map<string, PortableMemorySource>();\n return {\n register(source: PortableMemorySource) {\n assertValidSource(source);\n sources.set(source.id, source);\n },\n get(id: string) {\n return sources.get(id);\n },\n ids() {\n return [...sources.keys()].sort();\n },\n };\n};\n", "import type { FabricInvocationContext } from \"../protocol.js\";\nimport {\n presentRecall,\n RECALL_DEFAULT_PAGE_SIZE,\n RECALL_DEFAULT_SNIPPET_CHARS,\n RECALL_MAX_PAGE_SIZE,\n RECALL_MAX_SNIPPET_CHARS,\n type MemoryRecallCallArgs,\n} from \"./context.js\";\nimport { reconstructSessionLineage } from \"./lineage.js\";\nimport {\n fingerprintSource,\n loadTieredIndex,\n type EntryRange,\n type SearchFilters,\n} from \"./index.js\";\nimport {\n DEFAULT_REGEX_MAX_HAYSTACK_BYTES,\n DEFAULT_REGEX_MAX_HAYSTACK_TERMS,\n DEFAULT_REGEX_MAX_PATTERN_BYTES,\n DEFAULT_REGEX_TIMEOUT_MS,\n searchMemoryIndex,\n type SearchResult,\n} from \"./search.js\";\nimport type { MemoryQueryMatch, MemoryQueryMode } from \"./tokenize.js\";\nimport {\n parseBranches,\n resolveRefs,\n liveBranchResolver,\n resolveIndexOptions,\n addressError,\n recallFailure,\n stalePointerError,\n type MemoryProviderContext,\n} from \"./request-context.js\";\nimport {\n checkAbort,\n fileRecallPlan,\n hostRecallPlan,\n memorySourceFailure,\n resolveRegisteredSource,\n type RecallSourcePlan,\n} from \"./host-source.js\";\nimport { sameSourceObservations, type SourceObservation } from \"./source-observation.js\";\nimport { recallContinuationKey, type RecallRequestCache } from \"./request-cache.js\";\n\nexport async function processMemoryRecall(\n args: Record<string, unknown>,\n invocationContext: Pick<FabricInvocationContext, \"update\" | \"signal\">,\n context: MemoryProviderContext,\n cache: RecallRequestCache,\n): Promise<unknown> {\n const query = typeof args.query === \"string\" ? args.query : undefined;\n const rawQueryMode = args.queryMode;\n if (\n rawQueryMode !== undefined &&\n rawQueryMode !== \"literal\" &&\n rawQueryMode !== \"phrase\" &&\n rawQueryMode !== \"regex\"\n ) {\n throw new Error('memory.recall queryMode must be \"literal\", \"phrase\", or \"regex\"');\n }\n const queryMode: MemoryQueryMode = rawQueryMode === \"phrase\"\n ? \"phrase\"\n : rawQueryMode === \"regex\"\n ? \"regex\"\n : \"literal\";\n const rawQueryMatch = args.queryMatch;\n if (rawQueryMatch !== undefined && rawQueryMatch !== \"all\" && rawQueryMatch !== \"any\") {\n throw new Error('memory.recall queryMatch must be \"all\" or \"any\"');\n }\n if (queryMode !== \"literal\" && rawQueryMatch !== undefined) {\n throw new Error(\"memory.recall queryMatch is only valid with literal queryMode\");\n }\n const queryMatch: MemoryQueryMatch = rawQueryMatch === \"all\" ? \"all\" : \"any\";\n const expectedSourceHash = typeof args.expectedSourceHash === \"string\"\n ? args.expectedSourceHash\n : undefined;\n const expectedLineageFingerprint = typeof args.expectedLineageFingerprint === \"string\"\n ? args.expectedLineageFingerprint\n : undefined;\n const branches = parseBranches(args.branches, \"memory.recall\");\n const scope = typeof args.scope === \"string\" ? args.scope : undefined;\n const role = typeof args.role === \"string\" ? args.role : undefined;\n const tool = typeof args.tool === \"string\" ? args.tool : undefined;\n const ref = typeof args.ref === \"string\" ? args.ref : undefined;\n const provider = typeof args.provider === \"string\" ? args.provider : undefined;\n const action = typeof args.action === \"string\" ? args.action : undefined;\n const rawOutcome = args.outcome;\n if (\n rawOutcome !== undefined &&\n rawOutcome !== \"succeeded\" &&\n rawOutcome !== \"failed\" &&\n rawOutcome !== \"aborted\" &&\n rawOutcome !== \"timed_out\"\n ) {\n throw new Error(\"memory.recall outcome must be succeeded, failed, aborted, or timed_out\");\n }\n const outcome = rawOutcome as SearchFilters[\"outcome\"];\n const since = typeof args.since === \"number\" ? args.since : undefined;\n const until = typeof args.until === \"number\" ? args.until : undefined;\n const offset = typeof args.offset === \"number\" && args.offset >= 0\n ? Math.floor(args.offset)\n : undefined;\n const pageSize =\n typeof args.pageSize === \"number\" && args.pageSize >= 1\n ? Math.min(Math.floor(args.pageSize), RECALL_MAX_PAGE_SIZE)\n : RECALL_DEFAULT_PAGE_SIZE;\n const snippetChars =\n typeof args.snippetChars === \"number\" && args.snippetChars >= 80\n ? Math.min(Math.floor(args.snippetChars), RECALL_MAX_SNIPPET_CHARS)\n : RECALL_DEFAULT_SNIPPET_CHARS;\n\n const sourceId = typeof args.source === \"string\" && args.source.length > 0\n ? args.source\n : undefined;\n let plan: RecallSourcePlan;\n if (sourceId !== undefined) {\n if (scope !== undefined && scope !== `source:${sourceId}` && !scope.startsWith(\"session:\")) {\n throw new Error(\n 'memory.recall scope must name the selected source, one of its sessions, or be omitted',\n );\n }\n try {\n plan = await hostRecallPlan(\n resolveRegisteredSource(context.sources, sourceId),\n sourceId,\n scope?.startsWith(\"session:\") ? scope.slice(\"session:\".length).trim() : null,\n context,\n invocationContext.signal,\n );\n } catch (error) {\n const failure = memorySourceFailure(error);\n if (!failure) throw error;\n return recallFailure(failure);\n }\n } else {\n plan = fileRecallPlan(resolveRefs(scope, context, false), context);\n }\n const refs = plan.refs;\n const options = resolveIndexOptions(\n context.config,\n context.agentDir,\n branches,\n sourceId === undefined ? liveBranchResolver(context) : undefined,\n );\n const hydrate = sourceId !== undefined\n ? plan.sessionKey !== null\n : scope?.trim().startsWith(\"session:\") ?? false;\n if ((expectedSourceHash !== undefined || expectedLineageFingerprint !== undefined) && !hydrate) {\n throw new Error(\"memory.recall integrity expectations require scope session:<id-or-path>\");\n }\n\n const rawRange = args.entryRange;\n const entryRange = rawRange && typeof rawRange === \"object\" && !Array.isArray(rawRange)\n ? rawRange as Record<string, unknown>\n : undefined;\n const first = entryRange?.first;\n const last = entryRange?.last;\n if ((first === undefined) !== (last === undefined)) {\n throw new Error(\"memory.recall entryRange requires both first and last\");\n }\n if ((first !== undefined || last !== undefined) && !hydrate) {\n throw new Error(\"memory.recall entryRange requires scope session:<id-or-path>\");\n }\n if (first !== undefined && (\n typeof first !== \"number\" ||\n typeof last !== \"number\" ||\n !Number.isSafeInteger(first) ||\n !Number.isSafeInteger(last) ||\n first < 0 ||\n last < first\n )) {\n return recallFailure(addressError(\"Entry range requires safe integers with 0 <= first <= last.\"));\n }\n const selectedRange: EntryRange | undefined =\n typeof first === \"number\" && typeof last === \"number\" ? { first, last } : undefined;\n const filters: SearchFilters = {};\n if (role) filters.role = role;\n if (tool) filters.tool = tool;\n if (ref) filters.ref = ref;\n if (provider) filters.provider = provider;\n if (action) filters.action = action;\n if (outcome) filters.outcome = outcome;\n if (since !== undefined) filters.since = since;\n if (until !== undefined) filters.until = until;\n const baseRequestArgs: MemoryRecallCallArgs = {\n ...(sourceId ? { source: sourceId } : {}),\n ...(query === undefined ? {} : { query }),\n queryMode,\n ...(queryMode === \"literal\" ? { queryMatch } : {}),\n ...(expectedSourceHash ? { expectedSourceHash } : {}),\n ...(expectedLineageFingerprint ? { expectedLineageFingerprint } : {}),\n branches,\n scope: sourceId\n ? plan.sessionKey !== null\n ? `session:${plan.refs[0]?.file ?? plan.sessionKey}`\n : `source:${sourceId}`\n : scope ?? \"session\",\n ...(offset === undefined ? {} : { offset }),\n pageSize,\n snippetChars,\n ...(role ? { role } : {}),\n ...(tool ? { tool } : {}),\n ...(ref ? { ref } : {}),\n ...(provider ? { provider } : {}),\n ...(action ? { action } : {}),\n ...(outcome ? { outcome } : {}),\n ...(since !== undefined ? { since } : {}),\n ...(until !== undefined ? { until } : {}),\n ...(selectedRange ? { entryRange: selectedRange } : {}),\n };\n const updateProgress = (searchResult: SearchResult): void => {\n invocationContext.update(\n searchResult.matchMode === \"structural\"\n ? `memory.recall: ${searchResult.matchedCount} structural matches`\n : searchResult.matchMode === \"combined\"\n ? `memory.recall: ${searchResult.matchedCount} filtered matches`\n : query\n ? `memory.recall: ${searchResult.matchedCount} matches`\n : `memory.recall: ${searchResult.matchedCount} recent entries`,\n );\n };\n const observationsBefore: readonly SourceObservation[] | null = await plan.observeAll(branches);\n const cached = offset === undefined\n ? undefined\n : cache.cachedRecallContinuation(\n recallContinuationKey(baseRequestArgs, context.fabricScope?.digest),\n observationsBefore,\n );\n if (cached) {\n const response = presentRecall({\n result: cached.result,\n ...(query === undefined ? {} : { query }),\n queryMode,\n coverage: cached.coverage,\n ...(offset === undefined ? {} : { offset }),\n pageSize,\n snippetChars,\n requestArgs: cached.requestArgs,\n });\n const observationsAfterCachedPage = await plan.observeAll(branches);\n if (\n observationsBefore &&\n observationsAfterCachedPage &&\n sameSourceObservations(observationsBefore, observationsAfterCachedPage)\n ) {\n if (response.next === null) cache.forgetRecallContinuation(cached);\n updateProgress(cached.result);\n return response;\n }\n cache.forgetRecallContinuation(cached);\n }\n\n if (hydrate && refs[0]) {\n const state = plan.stateFor(refs[0]);\n const lineage = plan.lineageFor(refs[0], branches);\n const sourceChanged = expectedSourceHash !== undefined &&\n state?.sourceHash !== expectedSourceHash;\n const lineageChanged = expectedLineageFingerprint !== undefined &&\n lineage.fingerprint !== expectedLineageFingerprint;\n if (state && (sourceChanged || lineageChanged)) {\n return recallFailure(stalePointerError(\n refs[0].file,\n expectedSourceHash,\n state.sourceHash,\n expectedLineageFingerprint,\n lineage.fingerprint,\n ));\n }\n }\n\n const index = plan.loadIndex(options, hydrate, selectedRange);\n const hydratedShard = index.shards[0];\n const hydratedSourceChanged = expectedSourceHash !== undefined &&\n hydratedShard?.sourceHash !== expectedSourceHash;\n const hydratedLineageChanged = expectedLineageFingerprint !== undefined &&\n hydratedShard?.lineageFingerprint !== expectedLineageFingerprint;\n if (hydrate && hydratedShard && (hydratedSourceChanged || hydratedLineageChanged)) {\n return recallFailure(stalePointerError(\n hydratedShard.sessionFile,\n expectedSourceHash,\n hydratedShard.sourceHash,\n expectedLineageFingerprint,\n hydratedShard.lineageFingerprint,\n ));\n }\n if (\n hydrate &&\n selectedRange &&\n index.shards[0] &&\n selectedRange.last >= index.shards[0].totalEntryCount\n ) {\n return recallFailure(addressError(\n `Entry range ends at ${selectedRange.last}, but the session has ${index.shards[0].totalEntryCount} entries.`,\n index.shards[0].totalEntryCount,\n ));\n }\n\n const searchQuery = {\n ...(query === undefined ? {} : { query }),\n queryMode,\n queryMatch,\n filters,\n regexLimits: {\n maxPatternBytes: context.config.regexMaxPatternBytes\n ?? DEFAULT_REGEX_MAX_PATTERN_BYTES,\n maxHaystackTerms: context.config.regexMaxHaystackTerms\n ?? DEFAULT_REGEX_MAX_HAYSTACK_TERMS,\n maxHaystackBytes: context.config.regexMaxHaystackBytes\n ?? DEFAULT_REGEX_MAX_HAYSTACK_BYTES,\n timeoutMs: context.config.regexTimeoutMs ?? DEFAULT_REGEX_TIMEOUT_MS,\n },\n };\n const result = await searchMemoryIndex(index.shards, index.digests, searchQuery);\n const coverage = {\n ...index.coverage,\n complete: index.coverage.complete && result.queryCoverage.complete,\n reasons: [...new Set([...index.coverage.reasons, ...result.queryCoverage.reasons])].sort(),\n ...(result.queryCoverage.error ? { error: result.queryCoverage.error } : {}),\n };\n const soleRef = refs.length === 1 ? refs[0] : undefined;\n const soleShard = soleRef\n ? index.shards.find((candidate) => candidate.sessionFile === soleRef.file)\n : undefined;\n const soleDigest = soleRef\n ? index.digests.find((candidate) => candidate.file === soleRef.file)\n : undefined;\n const continuationBinding = soleRef && (soleShard?.sourceHash || soleDigest?.sourceHash)\n ? {\n file: soleRef.file,\n sourceHash: soleShard?.sourceHash ?? soleDigest!.sourceHash,\n lineageFingerprint: soleShard?.lineageFingerprint ?? soleDigest!.lineageFingerprint,\n }\n : undefined;\n const requestArgs: MemoryRecallCallArgs = {\n ...baseRequestArgs,\n ...((expectedSourceHash ?? continuationBinding?.sourceHash)\n ? { expectedSourceHash: expectedSourceHash ?? continuationBinding!.sourceHash }\n : {}),\n ...((expectedLineageFingerprint ?? continuationBinding?.lineageFingerprint)\n ? {\n expectedLineageFingerprint:\n expectedLineageFingerprint ?? continuationBinding!.lineageFingerprint,\n }\n : {}),\n scope: continuationBinding\n ? `session:${continuationBinding.file}`\n : baseRequestArgs.scope ?? \"session\",\n };\n const response = presentRecall({\n result,\n ...(query === undefined ? {} : { query }),\n queryMode,\n coverage,\n ...(offset === undefined ? {} : { offset }),\n pageSize,\n snippetChars,\n requestArgs,\n });\n const observationsAfter = await plan.observeAll(branches);\n if (\n response.next !== null &&\n observationsBefore &&\n observationsAfter &&\n sameSourceObservations(observationsBefore, observationsAfter)\n ) {\n cache.rememberRecallContinuation({\n key: recallContinuationKey(requestArgs, context.fabricScope?.digest),\n result,\n coverage,\n requestArgs,\n observations: observationsAfter,\n touchedAt: Date.now(),\n });\n }\n updateProgress(result);\n return response;\n}\n", "import { acceptMemoryChunk, type TextRange } from \"./policy.js\";\n\n/** Check the actual outgoing page against the selected normalized source, after\n * all envelope trimming. Source observation/hashing and lineage selection remain\n * host responsibilities; ranges are checked by the compiled Bend kernel. */\nexport const acceptsExpansionPage = (\n records: readonly Record<string, unknown>[],\n source: readonly { index: number; text: string }[],\n entryOffset: number,\n textOffset: number,\n cursor: { position: number; textOffset: number },\n): boolean => {\n if (![entryOffset, textOffset, cursor.position, cursor.textOffset].every((n) => Number.isSafeInteger(n) && n >= 0)) return false;\n let position = entryOffset;\n let offset = textOffset;\n for (const record of records) {\n const entry = source[position];\n const range = record.textRange as TextRange | undefined;\n if (!entry || record.index !== entry.index || typeof record.text !== \"string\" || !range ||\n !acceptMemoryChunk(range, record.text.length, offset, entry.text.length) ||\n record.text !== entry.text.slice(range.start, range.end)) return false;\n if (range.complete) {\n position++;\n offset = 0;\n } else {\n offset = range.end;\n }\n }\n return position === cursor.position && offset === cursor.textOffset &&\n (records.length > 0 || position === source.length);\n};\n", "import { pointerCurrent } from \"../verified/policy.js\";\nimport { acceptsExpansionPage } from \"../verified/memory.js\";\nimport { RECALL_MAX_RESPONSE_CHARS } from \"./context.js\";\nimport {\n expandSessionEntriesChecked,\n type ExpandSessionSelection,\n} from \"./normalize.js\";\nimport {\n fileExpansionAccess,\n hostExpansionAccess,\n memorySourceFailure,\n type ExpansionAccess,\n} from \"./host-source.js\";\nimport {\n EXPAND_DEFAULT_MAX_CHARS,\n EXPAND_MAX_CHARS,\n EXPAND_DEFAULT_MAX_ENTRIES,\n EXPAND_MAX_ENTRIES,\n EXPAND_MAX_CONTEXT,\n EXPAND_MAX_EXACT_SELECTORS,\n} from \"./request-limits.js\";\nimport {\n parseBranches,\n addressError,\n stalePointerError,\n type MemoryProviderContext,\n} from \"./request-context.js\";\nimport { sameSourceObservation } from \"./source-observation.js\";\nimport {\n expansionSelectionKey,\n type CanonicalExpansionSelection,\n type ExpansionRequestCache,\n} from \"./request-cache.js\";\n\nexport async function processMemoryExpand(\n args: Record<string, unknown>,\n context: MemoryProviderContext,\n cache: ExpansionRequestCache,\n signal?: AbortSignal,\n): Promise<unknown> {\n const session = typeof args.session === \"string\" ? args.session : \"\";\n const sourceId = typeof args.source === \"string\" && args.source.length > 0\n ? args.source\n : undefined;\n const expectedSourceHash = typeof args.expectedSourceHash === \"string\"\n ? args.expectedSourceHash\n : undefined;\n const expectedLineageFingerprint = typeof args.expectedLineageFingerprint === \"string\"\n ? args.expectedLineageFingerprint\n : undefined;\n const branches = parseBranches(args.branches, \"memory.expand\");\n const rawIndices = args.indices;\n if (rawIndices !== undefined && !Array.isArray(rawIndices)) {\n throw new Error(\"memory.expand indices must be an array\");\n }\n if (Array.isArray(rawIndices) && !rawIndices.every((index) =>\n typeof index === \"number\" && Number.isSafeInteger(index) && index >= 0)) {\n return { session, error: addressError(\"Every entry index must be a non-negative safe integer.\"), entries: [] };\n }\n const indices = (rawIndices as number[] | undefined) ?? [];\n const entryIds = Array.isArray(args.entryIds)\n ? args.entryIds.filter(\n (entryId): entryId is string => typeof entryId === \"string\" && entryId.length > 0,\n )\n : [];\n const operationAddresses = Array.isArray(args.operationAddresses)\n ? args.operationAddresses.filter(\n (address): address is string => typeof address === \"string\" && address.length > 0,\n )\n : [];\n if (indices.length + entryIds.length + operationAddresses.length > EXPAND_MAX_EXACT_SELECTORS) {\n throw new Error(`memory.expand accepts at most ${EXPAND_MAX_EXACT_SELECTORS} exact selectors per call`);\n }\n const rawRange = args.entryRange;\n const rangeRecord = rawRange && typeof rawRange === \"object\" && !Array.isArray(rawRange)\n ? rawRange as Record<string, unknown>\n : undefined;\n const first = rangeRecord?.first;\n const last = rangeRecord?.last;\n if (!session) throw new Error(\"memory.expand requires a session\");\n if ((first === undefined) !== (last === undefined)) {\n throw new Error(\"memory.expand entryRange requires both first and last\");\n }\n if (first !== undefined && (\n typeof first !== \"number\" ||\n typeof last !== \"number\" ||\n !Number.isSafeInteger(first) ||\n !Number.isSafeInteger(last) ||\n first < 0 ||\n last < first\n )) {\n return { session, error: addressError(\"Entry range requires safe integers with 0 <= first <= last.\"), entries: [] };\n }\n const numeric = (value: unknown, fallback: number, maximum: number): number =>\n typeof value === \"number\" && Number.isSafeInteger(value) && value >= 0\n ? Math.min(value, maximum)\n : fallback;\n const before = numeric(args.before, 0, EXPAND_MAX_CONTEXT);\n const after = numeric(args.after, 0, EXPAND_MAX_CONTEXT);\n const entryOffset = numeric(args.entryOffset, 0, Number.MAX_SAFE_INTEGER);\n const textOffset = numeric(args.textOffset, 0, Number.MAX_SAFE_INTEGER);\n const maxChars = Math.max(256, numeric(args.maxChars, EXPAND_DEFAULT_MAX_CHARS, EXPAND_MAX_CHARS));\n const maxEntries = Math.max(1, numeric(args.maxEntries, EXPAND_DEFAULT_MAX_ENTRIES, EXPAND_MAX_ENTRIES));\n\n let access: ExpansionAccess | null;\n if (sourceId !== undefined) {\n try {\n access = await hostExpansionAccess(sourceId, session, context, signal);\n } catch (error) {\n const failure = memorySourceFailure(error);\n if (!failure) throw error;\n return { session, error: failure, entries: [] };\n }\n } else {\n access = fileExpansionAccess(session, context);\n }\n if (!access) {\n return {\n session,\n error: { code: \"session_not_found\", message: `Session not found: ${session}` },\n entries: [],\n };\n }\n const ref = access.ref;\n const observedSource = access.observe(branches);\n let snapshot = cache.cachedExpansionSnapshot(ref.file, branches, observedSource, context.fabricScope?.digest);\n if (snapshot) {\n const sourceChanged = expectedSourceHash !== undefined &&\n snapshot.sourceHash !== expectedSourceHash;\n const lineageChanged = expectedLineageFingerprint !== undefined &&\n snapshot.lineageFingerprint !== expectedLineageFingerprint;\n if (!pointerCurrent(!sourceChanged, !lineageChanged)) {\n return {\n session: ref.file,\n branches,\n error: stalePointerError(\n ref.file,\n expectedSourceHash,\n snapshot.sourceHash,\n expectedLineageFingerprint,\n snapshot.lineageFingerprint,\n ),\n entries: [],\n };\n }\n }\n\n if (!snapshot) {\n const initialState = access.state();\n if (!initialState) {\n return {\n session: ref.file,\n error: { code: \"source_unavailable\", message: `Session source is unavailable: ${ref.file}` },\n entries: [],\n };\n }\n const initialLineage = access.lineage(branches);\n const sourceChanged = expectedSourceHash !== undefined &&\n initialState.sourceHash !== expectedSourceHash;\n const lineageChanged = expectedLineageFingerprint !== undefined &&\n initialLineage.fingerprint !== expectedLineageFingerprint;\n if (!pointerCurrent(!sourceChanged, !lineageChanged)) {\n return {\n session: ref.file,\n branches,\n error: stalePointerError(\n ref.file,\n expectedSourceHash,\n initialState.sourceHash,\n expectedLineageFingerprint,\n initialLineage.fingerprint,\n ),\n entries: [],\n };\n }\n\n const normalizedFull = access.normalizeFull(\n branches,\n { indexThinking: true, indexToolOutput: true },\n initialLineage,\n );\n if (!normalizedFull) {\n return {\n session: ref.file,\n error: stalePointerError(\n ref.file,\n expectedSourceHash ?? initialState.sourceHash,\n initialState.sourceHash,\n expectedLineageFingerprint ?? initialLineage.fingerprint,\n initialLineage.fingerprint,\n ),\n entries: [],\n };\n }\n const normalized = normalizedFull.entries;\n const finalState = access.state();\n const finalLineage = access.lineage(branches);\n const finalObservation = access.observe(branches);\n if (\n !finalState ||\n !finalObservation ||\n !pointerCurrent(finalState.sourceHash === initialState.sourceHash, finalLineage.fingerprint === initialLineage.fingerprint)\n ) {\n return {\n session: ref.file,\n error: stalePointerError(\n ref.file,\n expectedSourceHash ?? initialState.sourceHash,\n finalState?.sourceHash ?? \"\",\n expectedLineageFingerprint ?? initialLineage.fingerprint,\n finalLineage.fingerprint,\n ),\n entries: [],\n };\n }\n snapshot = {\n file: ref.file,\n branches,\n ...(context.fabricScope ? { scopeDigest: context.fabricScope.digest } : {}),\n sourceHash: finalState.sourceHash,\n lineageFingerprint: finalLineage.fingerprint,\n observation: finalObservation,\n entries: normalized,\n selections: new Map(),\n touchedAt: Date.now(),\n };\n }\n\n const entryCount = snapshot.entries.length;\n const outOfBounds = indices.find((index) => index >= entryCount);\n if (outOfBounds !== undefined) {\n return {\n session: ref.file,\n error: addressError(`Entry index ${outOfBounds} is outside 0..${Math.max(0, entryCount - 1)}.`, entryCount),\n entries: [],\n };\n }\n if (typeof last === \"number\" && last >= entryCount) {\n return {\n session: ref.file,\n error: addressError(`Entry range ends at ${last}, but the session has ${entryCount} entries.`, entryCount),\n entries: [],\n };\n }\n if (\n indices.length === 0 &&\n entryIds.length === 0 &&\n operationAddresses.length === 0 &&\n (first === undefined || last === undefined)\n ) {\n if (before > 0 || after > 0) {\n throw new Error(\"memory.expand before/after requires one selected anchor\");\n }\n cache.forgetExpansionSnapshot(snapshot);\n return {\n session: ref.file,\n sourceHash: snapshot.sourceHash,\n branches,\n lineageFingerprint: snapshot.lineageFingerprint,\n entryCount,\n entries: [],\n next: null,\n };\n }\n\n const requestedSelection: ExpandSessionSelection = {};\n if (indices.length > 0) requestedSelection.indices = indices;\n if (entryIds.length > 0) requestedSelection.entryIds = entryIds;\n if (operationAddresses.length > 0) requestedSelection.operationAddresses = operationAddresses;\n if (typeof first === \"number\" && typeof last === \"number\") {\n requestedSelection.entryRange = { first, last };\n }\n const requestedWithContext: CanonicalExpansionSelection = {\n ...requestedSelection,\n ...(before > 0 ? { before } : {}),\n ...(after > 0 ? { after } : {}),\n };\n const requestedKey = expansionSelectionKey(requestedWithContext);\n let resolved = snapshot.selections.get(requestedKey);\n if (!resolved) {\n let expansion = expandSessionEntriesChecked(snapshot.entries, requestedSelection);\n if (\"error\" in expansion) {\n return {\n session: ref.file,\n sourceHash: snapshot.sourceHash,\n branches,\n lineageFingerprint: snapshot.lineageFingerprint,\n error: expansion.error,\n entries: [],\n };\n }\n\n let anchorIndex: number | null = null;\n let canonical: CanonicalExpansionSelection;\n if (before > 0 || after > 0) {\n if (expansion.expanded.length !== 1) {\n throw new Error(\"memory.expand before/after requires exactly one resolved anchor\");\n }\n anchorIndex = expansion.expanded[0]!.index;\n const contextRange = {\n first: Math.max(0, anchorIndex - before),\n last: Math.min(Math.max(0, entryCount - 1), anchorIndex + after),\n };\n canonical = requestedWithContext;\n expansion = expandSessionEntriesChecked(snapshot.entries, { entryRange: contextRange });\n if (\"error\" in expansion) {\n return {\n session: ref.file,\n sourceHash: snapshot.sourceHash,\n branches,\n lineageFingerprint: snapshot.lineageFingerprint,\n error: expansion.error,\n entries: [],\n };\n }\n } else if (requestedSelection.entryRange) {\n canonical = { entryRange: requestedSelection.entryRange };\n } else {\n canonical = { indices: expansion.expanded.map((entry) => entry.index) };\n }\n resolved = { entries: expansion.expanded, canonical, anchorIndex };\n cache.rememberExpansionSelection(\n snapshot,\n [requestedKey, expansionSelectionKey(canonical)],\n resolved,\n );\n }\n\n const selected = resolved.entries;\n const canonicalSelection = resolved.canonical;\n const anchorIndex = resolved.anchorIndex;\n const finalState = snapshot;\n const finalLineage = { fingerprint: snapshot.lineageFingerprint };\n if (entryOffset > selected.length) {\n return {\n session: ref.file,\n error: addressError(`Entry offset ${entryOffset} is outside 0..${selected.length}.`, selected.length),\n entries: [],\n };\n }\n if (entryOffset < selected.length && textOffset > selected[entryOffset]!.text.length) {\n return {\n session: ref.file,\n error: {\n code: \"text_offset_out_of_bounds\",\n message: `Text offset ${textOffset} exceeds entry #${selected[entryOffset]!.index} length ${selected[entryOffset]!.text.length}.`,\n textLength: selected[entryOffset]!.text.length,\n },\n entries: [],\n };\n }\n\n const bounded = (value: string | null, maximum = 512): string | null =>\n value === null || value.length <= maximum\n ? value\n : `${value.slice(0, Math.max(1, maximum - 1))}\u2026`;\n const compactStructure = (value: unknown): unknown => {\n if (value === undefined) return undefined;\n const serialized = JSON.stringify(value);\n return serialized.length <= 2_000 ? value : undefined;\n };\n const output: Array<Record<string, unknown>> = [];\n const cursors: Array<{ position: number; textOffset: number }> = [];\n let position = entryOffset;\n let currentTextOffset = textOffset;\n let remainingChars = maxChars;\n while (position < selected.length && output.length < maxEntries && remainingChars > 0) {\n const entry = selected[position]!;\n let end = Math.min(entry.text.length, currentTextOffset + remainingChars);\n if (\n end < entry.text.length &&\n end > currentTextOffset &&\n entry.text.charCodeAt(end) >= 0xdc00 &&\n entry.text.charCodeAt(end) <= 0xdfff\n ) {\n end -= 1;\n }\n if (end === currentTextOffset && currentTextOffset < entry.text.length) {\n end = Math.min(entry.text.length, currentTextOffset + 2);\n }\n const chunk = entry.text.slice(currentTextOffset, end);\n const textComplete = end >= entry.text.length;\n const operation = compactStructure(entry.operation);\n const branchFact = compactStructure(entry.branchFact);\n output.push({\n index: entry.index,\n entryId: bounded(entry.entryId),\n parentId: bounded(entry.parentId),\n type: bounded(entry.type),\n role: bounded(entry.role),\n timestamp: entry.timestamp,\n isError: entry.isError,\n ...(anchorIndex !== null ? { anchor: entry.index === anchorIndex } : {}),\n text: chunk,\n textRange: {\n start: currentTextOffset,\n end,\n total: entry.text.length,\n complete: textComplete,\n },\n ...(entry.parentEntryId !== undefined ? { parentEntryId: bounded(entry.parentEntryId) } : {}),\n ...(entry.operationAddress ? { operationAddress: bounded(entry.operationAddress) } : {}),\n ...(entry.toolName ? { tool: bounded(entry.toolName) } : {}),\n ...(entry.ref ? { ref: bounded(entry.ref) } : {}),\n ...(entry.provider ? { provider: bounded(entry.provider) } : {}),\n ...(entry.action ? { action: bounded(entry.action) } : {}),\n ...(entry.outcome ? { outcome: entry.outcome } : {}),\n ...(entry.filesTouched\n ? { filesTouched: entry.filesTouched.slice(0, 20).map((file) => bounded(file, 1_024)) }\n : {}),\n ...(operation !== undefined ? { operation } : {}),\n ...(branchFact !== undefined ? { branchFact } : {}),\n ...((entry.operation !== undefined && operation === undefined) ||\n (entry.branchFact !== undefined && branchFact === undefined)\n ? { structuredTruncated: true }\n : {}),\n ...(entry.factAddress ? { factAddress: bounded(entry.factAddress) } : {}),\n ...(entry.carrierEntryId ? { carrierEntryId: bounded(entry.carrierEntryId) } : {}),\n ...(entry.carrierParentId !== undefined ? { carrierParentId: bounded(entry.carrierParentId) } : {}),\n ...(entry.carrierFromId !== undefined ? { carrierFromId: bounded(entry.carrierFromId) } : {}),\n });\n remainingChars -= chunk.length;\n if (!textComplete) {\n currentTextOffset = end;\n cursors.push({ position, textOffset: currentTextOffset });\n break;\n }\n position += 1;\n currentTextOffset = 0;\n cursors.push({ position, textOffset: 0 });\n }\n\n const responseAt = (\n records: Array<Record<string, unknown>>,\n cursor: { position: number; textOffset: number },\n ): Record<string, unknown> => {\n const hasNext = cursor.position < selected.length;\n const nextArgs = hasNext\n ? {\n ...(sourceId ? { source: sourceId } : {}),\n session: ref.file,\n expectedSourceHash: finalState.sourceHash,\n expectedLineageFingerprint: finalLineage.fingerprint,\n branches,\n ...canonicalSelection,\n entryOffset: cursor.position,\n ...(cursor.textOffset > 0 ? { textOffset: cursor.textOffset } : {}),\n maxChars,\n maxEntries,\n }\n : null;\n return {\n session: ref.file,\n sourceHash: finalState.sourceHash,\n branches,\n lineageFingerprint: finalLineage.fingerprint,\n entryCount,\n entries: records,\n next: nextArgs ? { ref: \"memory.expand\", args: nextArgs } : null,\n };\n };\n\n let cursor = { position, textOffset: currentTextOffset };\n let response = responseAt(output, cursor);\n while (output.length > 1 && JSON.stringify(response).length > RECALL_MAX_RESPONSE_CHARS) {\n output.pop();\n cursors.pop();\n cursor = cursors.at(-1) ?? { position: entryOffset, textOffset };\n response = responseAt(output, cursor);\n }\n if (output.length === 1 && JSON.stringify(response).length > RECALL_MAX_RESPONSE_CHARS) {\n const record = output[0]!;\n const range = record.textRange as { start: number; end: number; total: number; complete: boolean };\n const chunk = record.text as string;\n const excess = JSON.stringify(response).length - RECALL_MAX_RESPONSE_CHARS;\n let keep = Math.max(1, chunk.length - excess - 256);\n if (\n keep < chunk.length &&\n keep > 0 &&\n chunk.charCodeAt(keep) >= 0xdc00 &&\n chunk.charCodeAt(keep) <= 0xdfff\n ) {\n keep -= 1;\n }\n if (keep > 0 && keep < chunk.length) {\n record.text = chunk.slice(0, keep);\n range.end = range.start + keep;\n range.complete = false;\n cursor = { position: entryOffset, textOffset: range.end };\n response = responseAt(output, cursor);\n }\n if (JSON.stringify(response).length > RECALL_MAX_RESPONSE_CHARS) {\n delete record.operation;\n delete record.branchFact;\n if (Array.isArray(record.filesTouched)) {\n record.filesTouched = record.filesTouched.slice(0, 4).map((file) => bounded(String(file), 256));\n }\n record.structuredTruncated = true;\n response = responseAt(output, cursor);\n }\n if (JSON.stringify(response).length > RECALL_MAX_RESPONSE_CHARS) {\n const current = String(record.text);\n const firstCodePointChars = (current.codePointAt(0) ?? 0) > 0xffff ? 2 : 1;\n const minimalText = current.slice(0, Math.min(current.length, firstCodePointChars));\n const minimalRange = record.textRange as { start: number; end: number; total: number; complete: boolean };\n minimalRange.end = minimalRange.start + minimalText.length;\n minimalRange.complete = minimalRange.end >= minimalRange.total;\n output[0] = {\n index: record.index,\n entryId: record.entryId,\n parentId: record.parentId,\n type: record.type,\n role: record.role,\n timestamp: record.timestamp,\n isError: record.isError,\n ...(record.anchor !== undefined ? { anchor: record.anchor } : {}),\n text: minimalText,\n textRange: minimalRange,\n structuredTruncated: true,\n };\n cursor = minimalRange.complete\n ? { position: entryOffset + 1, textOffset: 0 }\n : { position: entryOffset, textOffset: minimalRange.end };\n response = responseAt(output, cursor);\n }\n }\n\n if (!acceptsExpansionPage(output, selected, entryOffset, textOffset, cursor)) {\n cache.forgetExpansionSnapshot(snapshot);\n return { session: ref.file, entries: [], error: { code: \"invalid_expansion\", message: \"Expansion failed source-bound chunk verification\" } };\n }\n\n const endingObservation = access.observe(branches);\n if (!endingObservation || !sameSourceObservation(snapshot.observation, endingObservation)) {\n cache.forgetExpansionSnapshot(snapshot);\n const actualState = access.state();\n const actualLineage = access.lineage(branches);\n if (\n !actualState ||\n !endingObservation ||\n !pointerCurrent(actualState.sourceHash === snapshot.sourceHash, actualLineage.fingerprint === snapshot.lineageFingerprint)\n ) {\n return {\n session: ref.file,\n error: stalePointerError(\n ref.file,\n expectedSourceHash ?? snapshot.sourceHash,\n actualState?.sourceHash ?? \"\",\n expectedLineageFingerprint ?? snapshot.lineageFingerprint,\n actualLineage.fingerprint,\n ),\n entries: [],\n };\n }\n snapshot.observation = endingObservation;\n }\n if (response.next === null) {\n cache.forgetExpansionSnapshot(snapshot);\n } else {\n snapshot.touchedAt = Date.now();\n cache.rememberExpansionSnapshot(snapshot);\n }\n return response;\n}\n", "import { loadTieredIndex } from \"./index.js\";\nimport { SESSIONS_MAX } from \"./request-limits.js\";\nimport {\n parseBranches,\n resolveRefs,\n resolveIndexOptions,\n liveBranchResolver,\n resolveTierRefs,\n type MemoryProviderContext,\n} from \"./request-context.js\";\nimport {\n listHostSnapshots,\n loadHostTieredIndex,\n memorySourceFailure,\n resolveRegisteredSource,\n} from \"./host-source.js\";\n\nexport async function processMemorySessions(\n args: Record<string, unknown>,\n context: MemoryProviderContext,\n signal?: AbortSignal,\n): Promise<unknown> {\n const sourceId = typeof args.source === \"string\" && args.source.length > 0\n ? args.source\n : undefined;\n const scope = typeof args.scope === \"string\" ? args.scope : undefined;\n const branches = parseBranches(args.branches, \"memory.sessions\");\n const limit =\n typeof args.limit === \"number\" && Number.isSafeInteger(args.limit) && args.limit >= 1\n ? Math.min(args.limit, SESSIONS_MAX)\n : SESSIONS_MAX;\n\n if (sourceId !== undefined) {\n try {\n const source = resolveRegisteredSource(context.sources, sourceId);\n const { snapshots, coverageReasons } = await listHostSnapshots(source, limit, \"list\", signal, context.fabricScope);\n const options = resolveIndexOptions(context.config, context.agentDir, branches);\n const index = loadHostTieredIndex(snapshots, options, false, undefined, coverageReasons);\n const shards = new Map(index.shards.map((shard) => [shard.sessionFile, shard]));\n const digests = new Map(index.digests.map((digest) => [digest.file, digest]));\n const sessions = snapshots.map((snapshot) => {\n const tier = index.tiers.get(snapshot.displayKey) ?? \"cold\";\n const shard = shards.get(snapshot.displayKey);\n const digest = digests.get(snapshot.displayKey);\n return {\n id: shard?.sessionId ?? digest?.sessionId ?? snapshot.sessionId,\n file: snapshot.displayKey,\n cwd: digest?.cwd ?? snapshot.metadata.cwd ?? \"\",\n mtime: snapshot.metadata.updatedAt ?? 0,\n entryCount: shard?.entries.length ?? digest?.entryCount ?? 0,\n tier,\n branches,\n lineageFingerprint: shard?.lineageFingerprint ?? digest?.lineageFingerprint ?? null,\n };\n });\n return {\n scope: `source:${sourceId}`,\n branches,\n sessions,\n ...(index.coverage.complete ? {} : { coverage: index.coverage }),\n };\n } catch (error) {\n const failure = memorySourceFailure(error);\n if (!failure) throw error;\n return {\n scope: `source:${sourceId}`,\n branches,\n sessions: [],\n error: failure,\n };\n }\n }\n\n const refs = resolveRefs(scope, context, true).slice(0, limit);\n const options = resolveIndexOptions(\n context.config,\n context.agentDir,\n branches,\n liveBranchResolver(context),\n );\n const index = loadTieredIndex(refs, resolveTierRefs(refs, context), options);\n const shards = new Map(index.shards.map((shard) => [shard.sessionFile, shard]));\n const digests = new Map(index.digests.map((digest) => [digest.file, digest]));\n const sessions = refs.map((ref) => {\n const tier = index.tiers.get(ref.file) ?? \"cold\";\n const shard = shards.get(ref.file);\n const digest = digests.get(ref.file);\n return {\n id: shard?.sessionId ?? digest?.sessionId ?? ref.id,\n file: ref.file,\n cwd: digest?.cwd ?? ref.cwd,\n mtime: ref.mtime,\n entryCount: shard?.entries.length ?? digest?.entryCount ?? 0,\n tier,\n branches,\n lineageFingerprint: shard?.lineageFingerprint ?? digest?.lineageFingerprint ?? null,\n };\n });\n return { scope: scope ?? \"session\", branches, sessions };\n}\n", "import type {\n FabricActionDescriptor,\n FabricInvocationContext,\n FabricProvider,\n FabricProviderListRequest,\n} from \"../protocol.js\";\nimport { AmbiguousSessionError } from \"../memory/discovery.js\";\nimport {\n RECALL_DEFAULT_PAGE_SIZE,\n RECALL_DEFAULT_SNIPPET_CHARS,\n RECALL_MAX_PAGE_SIZE,\n RECALL_MAX_SNIPPET_CHARS,\n} from \"../memory/context.js\";\nimport {\n EXPAND_DEFAULT_MAX_CHARS,\n EXPAND_MAX_CHARS,\n EXPAND_DEFAULT_MAX_ENTRIES,\n EXPAND_MAX_ENTRIES,\n EXPAND_MAX_CONTEXT,\n EXPAND_MAX_EXACT_SELECTORS,\n} from \"../memory/request-limits.js\";\nimport { recallFailure, type MemoryProviderContext } from \"../memory/request-context.js\";\nimport { MemoryRequestCache } from \"../memory/request-cache.js\";\nimport { processMemoryRecall } from \"../memory/recall-service.js\";\nimport { processMemoryExpand } from \"../memory/expand-service.js\";\nimport { processMemorySessions } from \"../memory/sessions-service.js\";\nimport { actionArgNormalizer, type ArgNormalizationSpec } from \"./arg-normalization.js\";\n\nconst errorOutputSchema = {\n type: \"object\",\n properties: {\n code: { type: \"string\" },\n message: { type: \"string\" },\n },\n required: [\"code\", \"message\"],\n};\n\nconst coverageOutputSchema = {\n type: \"object\",\n properties: {\n complete: { type: \"boolean\" },\n indexedSessions: { type: \"number\" },\n eligibleSessions: { type: \"number\" },\n staleSessions: { type: \"number\" },\n incompleteSessions: { type: \"number\" },\n reasons: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"Stable machine-readable incompleteness codes; empty when complete is true.\",\n },\n error: errorOutputSchema,\n },\n required: [\n \"complete\",\n \"indexedSessions\",\n \"eligibleSessions\",\n \"staleSessions\",\n \"incompleteSessions\",\n \"reasons\",\n ],\n};\n\nconst callOutputSchema = (ref: \"memory.recall\" | \"memory.expand\") => ({\n type: \"object\",\n properties: {\n ref: { const: ref },\n args: { type: \"object\" },\n },\n required: [\"ref\", \"args\"],\n});\n\nconst recallEntryOutputSchema = {\n type: \"object\",\n properties: {\n kind: { const: \"entry\" },\n sessionId: { type: \"string\" },\n tier: { type: \"string\", enum: [\"hot\", \"cold\"] },\n index: { type: \"number\" },\n entryId: { type: [\"string\", \"null\"] },\n parentId: { type: [\"string\", \"null\"] },\n operationAddress: { type: [\"string\", \"null\"] },\n type: { type: \"string\" },\n role: { type: [\"string\", \"null\"] },\n tool: { type: [\"string\", \"null\"] },\n ref: { type: [\"string\", \"null\"] },\n provider: { type: [\"string\", \"null\"] },\n action: { type: [\"string\", \"null\"] },\n timestamp: { type: [\"number\", \"null\"] },\n isError: { type: \"boolean\" },\n outcome: { type: \"string\", enum: [\"succeeded\", \"failed\", \"aborted\", \"timed_out\"] },\n score: { type: \"number\" },\n snippet: { type: \"string\" },\n truncated: { type: \"boolean\" },\n follow: callOutputSchema(\"memory.expand\"),\n },\n required: [\n \"kind\",\n \"sessionId\",\n \"tier\",\n \"index\",\n \"entryId\",\n \"parentId\",\n \"operationAddress\",\n \"type\",\n \"role\",\n \"tool\",\n \"ref\",\n \"provider\",\n \"action\",\n \"timestamp\",\n \"isError\",\n \"score\",\n \"snippet\",\n \"truncated\",\n \"follow\",\n ],\n};\n\nconst recallSessionOutputSchema = {\n type: \"object\",\n properties: {\n kind: { const: \"session\" },\n sessionId: { type: \"string\" },\n tier: { const: \"cold\" },\n cwd: { type: \"string\" },\n lastTimestamp: { type: [\"number\", \"null\"] },\n score: { type: \"number\" },\n matchedTerms: { type: \"number\" },\n matchedStructuralEntries: { type: \"number\" },\n follow: callOutputSchema(\"memory.recall\"),\n },\n required: [\n \"kind\",\n \"sessionId\",\n \"tier\",\n \"cwd\",\n \"lastTimestamp\",\n \"score\",\n \"matchedTerms\",\n \"matchedStructuralEntries\",\n \"follow\",\n ],\n};\n\nconst recallOutputSchema: Record<string, unknown> = {\n type: \"object\",\n description: \"Bounded ranked memory hits with uniform follow and pagination calls.\",\n properties: {\n total: { type: \"number\" },\n hits: {\n type: \"array\",\n description: \"Call tools.call(hit.follow) to expand an entry or resolve a cold session.\",\n items: { oneOf: [recallEntryOutputSchema, recallSessionOutputSchema] },\n },\n next: {\n oneOf: [callOutputSchema(\"memory.recall\"), { type: \"null\" }],\n description: \"When non-null, call tools.call(next).\",\n },\n coverage: coverageOutputSchema,\n error: errorOutputSchema,\n },\n required: [\"total\", \"hits\", \"next\", \"coverage\"],\n};\n\nconst expandOutputSchema: Record<string, unknown> = {\n type: \"object\",\n description: \"Integrity-bound session entries returned as lossless bounded text chunks.\",\n properties: {\n session: { type: \"string\" },\n sourceHash: { type: \"string\" },\n branches: { type: \"string\", enum: [\"active\", \"all\"] },\n lineageFingerprint: { type: \"string\" },\n entryCount: { type: \"number\" },\n entries: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n index: { type: \"number\" },\n entryId: { type: [\"string\", \"null\"] },\n parentId: { type: [\"string\", \"null\"] },\n type: { type: [\"string\", \"null\"] },\n role: { type: [\"string\", \"null\"] },\n timestamp: { type: [\"number\", \"null\"] },\n isError: { type: \"boolean\" },\n text: { type: \"string\" },\n textRange: {\n type: \"object\",\n properties: {\n start: { type: \"number\" },\n end: { type: \"number\" },\n total: { type: \"number\" },\n complete: { type: \"boolean\" },\n },\n required: [\"start\", \"end\", \"total\", \"complete\"],\n },\n anchor: { type: \"boolean\" },\n parentEntryId: { type: [\"string\", \"null\"] },\n operationAddress: { type: [\"string\", \"null\"] },\n tool: { type: [\"string\", \"null\"] },\n ref: { type: [\"string\", \"null\"] },\n provider: { type: [\"string\", \"null\"] },\n action: { type: [\"string\", \"null\"] },\n outcome: { type: \"string\", enum: [\"succeeded\", \"failed\", \"aborted\", \"timed_out\"] },\n filesTouched: { type: \"array\", items: { type: [\"string\", \"null\"] } },\n operation: { type: \"object\" },\n branchFact: { type: \"object\" },\n structuredTruncated: { type: \"boolean\" },\n factAddress: { type: [\"string\", \"null\"] },\n carrierEntryId: { type: [\"string\", \"null\"] },\n carrierParentId: { type: [\"string\", \"null\"] },\n carrierFromId: { type: [\"string\", \"null\"] },\n },\n required: [\"index\", \"entryId\", \"parentId\", \"type\", \"role\", \"timestamp\", \"isError\", \"text\", \"textRange\"],\n },\n },\n next: {\n oneOf: [callOutputSchema(\"memory.expand\"), { type: \"null\" }],\n description: \"When non-null, call tools.call(next).\",\n },\n error: errorOutputSchema,\n },\n required: [\"entries\"],\n};\n\nconst sessionsOutputSchema: Record<string, unknown> = {\n type: \"object\",\n properties: {\n scope: { type: \"string\" },\n branches: { type: \"string\", enum: [\"active\", \"all\"] },\n sessions: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n id: { type: \"string\" },\n file: { type: \"string\" },\n cwd: { type: \"string\" },\n mtime: { type: \"number\" },\n entryCount: { type: \"number\" },\n tier: { type: \"string\", enum: [\"hot\", \"cold\"] },\n branches: { type: \"string\", enum: [\"active\", \"all\"] },\n lineageFingerprint: { type: [\"string\", \"null\"] },\n },\n required: [\n \"id\",\n \"file\",\n \"cwd\",\n \"mtime\",\n \"entryCount\",\n \"tier\",\n \"branches\",\n \"lineageFingerprint\",\n ],\n },\n },\n error: errorOutputSchema,\n },\n};\n\nconst SOURCE_ARG_SCHEMA = {\n type: \"string\",\n minLength: 1,\n description:\n \"Registered portable memory source id. When set, the call resolves against that source only \u2014 filesystem scopes are never consulted and there is no filesystem fallback.\",\n} as const;\n\nexport const memoryActionDescriptors: FabricActionDescriptor[] = [\n {\n name: \"recall\",\n description:\n \"Search session memory as bounded ranked snippets. Literal queries rank any matching term by default; queryMatch all narrows to co-located terms. Call tools.call(hit.follow) for either an exact entry or a cold-session candidate, and tools.call(next) to continue.\",\n inputSchema: {\n type: \"object\",\n properties: {\n source: SOURCE_ARG_SCHEMA,\n query: { type: \"string\", maxLength: 4096 },\n queryMode: {\n type: \"string\",\n enum: [\"literal\", \"phrase\", \"regex\"],\n default: \"literal\",\n description: \"Canonical tokens (default), one case-insensitive exact phrase, or explicitly bounded regex.\",\n },\n queryMatch: {\n type: \"string\",\n enum: [\"all\", \"any\"],\n default: \"any\",\n description: \"For literal mode, accept any term (default) or require all terms in one hot entry.\",\n },\n expectedSourceHash: {\n type: \"string\",\n description: \"SHA-256 from a prior pointer; stale sources are refused.\",\n },\n expectedLineageFingerprint: {\n type: \"string\",\n description: \"Active-lineage fingerprint from a prior pointer; changed leaves are refused.\",\n },\n branches: {\n type: \"string\",\n enum: [\"active\", \"all\"],\n description: \"Search the active parent-linked path (default) or every branch.\",\n },\n scope: {\n type: \"string\",\n description:\n \"session | project | global | session:<id-or-path>. Defaults to session.\",\n },\n offset: {\n type: \"number\",\n minimum: 0,\n description: \"Exact ranked-hit offset, normally copied from next.args.\",\n },\n pageSize: { type: \"number\", minimum: 1, maximum: RECALL_MAX_PAGE_SIZE, default: RECALL_DEFAULT_PAGE_SIZE },\n snippetChars: {\n type: \"number\",\n minimum: 80,\n maximum: RECALL_MAX_SNIPPET_CHARS,\n default: RECALL_DEFAULT_SNIPPET_CHARS,\n description: \"Maximum indexed-text characters shown per hit; full text remains in memory.expand.\",\n },\n role: {\n type: \"string\",\n enum: [\n \"assistant\",\n \"bashExecution\",\n \"branchCustomMessage\",\n \"branchSummary\",\n \"branchUser\",\n \"compaction\",\n \"compactionSummary\",\n \"custom\",\n \"fabricOperation\",\n \"fabricPhase\",\n \"fabricRun\",\n \"toolResult\",\n \"user\",\n ],\n description:\n \"Exact normalized entry role to filter by: the closed set the session normalizer can produce.\",\n },\n tool: { type: \"string\" },\n ref: {\n type: \"string\",\n minLength: 1,\n description: \"Exact persisted Fabric action ref, such as pi.grep. This is structural selection, not lexical expansion.\",\n },\n provider: {\n type: \"string\",\n minLength: 1,\n description: \"Exact persisted Fabric provider identity.\",\n },\n action: {\n type: \"string\",\n minLength: 1,\n description: \"Exact persisted Fabric action name.\",\n },\n outcome: {\n type: \"string\",\n enum: [\"succeeded\", \"failed\", \"aborted\", \"timed_out\"],\n description: \"Exact persisted Fabric execution outcome.\",\n },\n since: { type: \"number\" },\n until: { type: \"number\" },\n entryRange: {\n type: \"object\",\n description:\n \"Inclusive normalized-entry range for an explicit session:<id> resolution.\",\n properties: {\n first: { type: \"number\", minimum: 0 },\n last: { type: \"number\", minimum: 0 },\n },\n required: [\"first\", \"last\"],\n additionalProperties: false,\n },\n },\n additionalProperties: false,\n },\n outputSchema: recallOutputSchema,\n risk: \"read\",\n namespace: \"memory\",\n },\n {\n name: \"expand\",\n description:\n \"Read exact normalized session entries and nearby context as bounded lossless chunks. Call tools.call(next) to continue, or use guest-side memory.walk(args, visitor) to traverse complete reassembled entries.\",\n inputSchema: {\n type: \"object\",\n properties: {\n source: SOURCE_ARG_SCHEMA,\n session: { type: \"string\", description: \"Exact session file path, unambiguous id, or source session key.\" },\n expectedSourceHash: {\n type: \"string\",\n description: \"SHA-256 from a prior pointer; stale sources are refused.\",\n },\n expectedLineageFingerprint: {\n type: \"string\",\n description: \"Active-lineage fingerprint from a prior pointer; changed leaves are refused.\",\n },\n branches: {\n type: \"string\",\n enum: [\"active\", \"all\"],\n description: \"Expand on the active parent-linked path (default) or across every branch.\",\n },\n indices: { type: \"array\", maxItems: EXPAND_MAX_EXACT_SELECTORS, items: { type: \"number\", minimum: 0 } },\n entryIds: { type: \"array\", maxItems: EXPAND_MAX_EXACT_SELECTORS, items: { type: \"string\", maxLength: 512 } },\n operationAddresses: { type: \"array\", maxItems: EXPAND_MAX_EXACT_SELECTORS, items: { type: \"string\", maxLength: 512 } },\n entryRange: {\n type: \"object\",\n properties: {\n first: { type: \"number\", minimum: 0 },\n last: { type: \"number\", minimum: 0 },\n },\n required: [\"first\", \"last\"],\n additionalProperties: false,\n },\n before: {\n type: \"number\",\n minimum: 0,\n maximum: EXPAND_MAX_CONTEXT,\n default: 0,\n description: \"Entries before one exact selected anchor.\",\n },\n after: {\n type: \"number\",\n minimum: 0,\n maximum: EXPAND_MAX_CONTEXT,\n default: 0,\n description: \"Entries after one exact selected anchor.\",\n },\n entryOffset: {\n type: \"number\",\n minimum: 0,\n description: \"Continuation offset within the resolved selection; copy from next.args.\",\n },\n textOffset: {\n type: \"number\",\n minimum: 0,\n description: \"Continuation offset within the first returned entry; copy from next.args.\",\n },\n maxChars: {\n type: \"number\",\n minimum: 256,\n maximum: EXPAND_MAX_CHARS,\n default: EXPAND_DEFAULT_MAX_CHARS,\n description: \"Total entry-text characters returned in this chunk.\",\n },\n maxEntries: {\n type: \"number\",\n minimum: 1,\n maximum: EXPAND_MAX_ENTRIES,\n default: EXPAND_DEFAULT_MAX_ENTRIES,\n description: \"Maximum complete or partial entries returned in this chunk.\",\n },\n },\n required: [\"session\"],\n additionalProperties: false,\n },\n outputSchema: expandOutputSchema,\n risk: \"read\",\n namespace: \"memory\",\n },\n {\n name: \"sessions\",\n description: \"List known sessions in scope with id, file, cwd, mtime, entry count, and hot/cold tier.\",\n inputSchema: {\n type: \"object\",\n properties: {\n source: SOURCE_ARG_SCHEMA,\n scope: { type: \"string\" },\n branches: {\n type: \"string\",\n enum: [\"active\", \"all\"],\n description: \"Count the active parent-linked path (default) or every branch.\",\n },\n limit: {\n type: \"number\",\n minimum: 1,\n description: \"Maximum sessions returned; capped at the internal session ceiling.\",\n },\n },\n additionalProperties: false,\n },\n outputSchema: sessionsOutputSchema,\n risk: \"read\",\n namespace: \"memory\",\n },\n];\n\nconst descriptors = memoryActionDescriptors;\n\n// Value spellings models reliably substitute for the documented memory scopes,\n// e.g. scope \"cwd\" for \"project\". Same discipline as the key aliases below:\n// identical intent only. Unknown scopes still fall through to resolveScope's\n// default \"session\" handling.\nconst MEMORY_SCOPE_VALUE_ALIASES: Record<string, string> = {\n cwd: \"project\",\n repo: \"project\",\n directory: \"project\",\n folder: \"project\",\n all: \"global\",\n current: \"session\",\n};\n\nconst MEMORY_ARG_NORMALIZATION: Record<string, ArgNormalizationSpec> = {\n recall: { values: { scope: MEMORY_SCOPE_VALUE_ALIASES } },\n sessions: { values: { scope: MEMORY_SCOPE_VALUE_ALIASES } },\n};\n\n// Argument repair derives from the action schemas plus the shared synonym\n// lexicon; only scope value spellings stay table-bound because the schema\n// spells scope as a free string rather than an enum.\nexport const normalizeMemoryArgs = actionArgNormalizer(\n () => descriptors,\n MEMORY_ARG_NORMALIZATION,\n);\n\nexport type { MemoryProviderContext } from \"../memory/request-context.js\";\n\n/** Lightweight recall/expand/sessions action schemas for managed proxies. */\nexport const memoryActionSchemas: {\n recall: { inputSchema: object; outputSchema: object };\n expand: { inputSchema: object; outputSchema: object };\n sessions: { inputSchema: object; outputSchema: object };\n} = Object.fromEntries(\n descriptors.map((descriptor) => [\n descriptor.name,\n { inputSchema: descriptor.inputSchema, outputSchema: descriptor.outputSchema },\n ]),\n) as {\n recall: { inputSchema: object; outputSchema: object };\n expand: { inputSchema: object; outputSchema: object };\n sessions: { inputSchema: object; outputSchema: object };\n};\n\nexport class MemoryProvider implements FabricProvider {\n readonly name = \"memory\";\n readonly description =\n \"Cross-session memory: a search engine over every Pi session timeline on this machine\";\n\n private readonly cache = new MemoryRequestCache();\n\n constructor(private readonly context: MemoryProviderContext) {}\n\n async list(\n request: FabricProviderListRequest,\n _context: FabricInvocationContext,\n ): Promise<FabricActionDescriptor[]> {\n const query = request.query?.toLowerCase();\n return query\n ? descriptors.filter((descriptor) =>\n `${descriptor.name} ${descriptor.description}`.toLowerCase().includes(query),\n )\n : descriptors;\n }\n\n async describe(\n actionName: string,\n _context: FabricInvocationContext,\n ): Promise<FabricActionDescriptor | undefined> {\n return descriptors.find((descriptor) => descriptor.name === actionName);\n }\n\n prepareArguments(\n actionName: string,\n args: Record<string, unknown>,\n ): Record<string, unknown> {\n return normalizeMemoryArgs(actionName, args);\n }\n\n async invoke(\n actionName: string,\n args: Record<string, unknown>,\n invocationContext: FabricInvocationContext,\n ): Promise<unknown> {\n const context = invocationContext.scope\n ? { ...this.context, fabricScope: invocationContext.scope }\n : this.context;\n try {\n switch (actionName) {\n case \"recall\":\n return await processMemoryRecall(args, invocationContext, context, this.cache);\n case \"expand\":\n return await processMemoryExpand(args, context, this.cache, invocationContext.signal);\n case \"sessions\":\n return await processMemorySessions(args, context, invocationContext.signal);\n default:\n throw new Error(`Unknown memory action: ${actionName}`);\n }\n } catch (error) {\n if (error instanceof AmbiguousSessionError) {\n const detail = {\n code: error.code,\n message: error.message,\n session: error.session,\n candidates: error.candidates,\n };\n if (actionName === \"recall\") return recallFailure(detail);\n if (actionName === \"expand\") return { entries: [], next: null, error: detail };\n return { error: detail };\n }\n throw error;\n }\n }\n\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBO,IAAM,2BAA2B;AACjC,IAAM,uBAAuB;AAC7B,IAAM,+BAA+B;AACrC,IAAM,2BAA2B;AACjC,IAAM,4BAA4B;AAgIzC,IAAM,kBAAkB,CAAC,OAAkC,MAAM,QAAuB;AACtF,MAAI,UAAU,UAAa,UAAU,KAAM,QAAO;AAClD,SAAO,MAAM,UAAU,MAAM,QAAQ,GAAG,MAAM,MAAM,GAAG,KAAK,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC;AAC9E;AAEA,IAAM,YAAY,CAAC,MAAc,OAAe,QAAwB;AACtE,MAAI,YAAY,KAAK,IAAI,GAAG,KAAK;AACjC,MAAI,UAAU,KAAK,IAAI,KAAK,QAAQ,GAAG;AACvC,QAAM,YAAY,KAAK,WAAW,SAAS;AAC3C,MAAI,YAAY,KAAK,aAAa,SAAU,aAAa,MAAQ,cAAa;AAC9E,QAAM,UAAU,KAAK,WAAW,UAAU,CAAC;AAC3C,MAAI,UAAU,KAAK,UAAU,WAAW,SAAU,WAAW,MAAQ,YAAW;AAChF,SAAO,KAAK,MAAM,WAAW,OAAO;AACtC;AAEA,IAAM,gBAAgB,CACpB,MACA,OACA,cACW;AACX,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,aAAa,sBAAsB,IAAI;AAC7C,MAAI,cAAc,UAAU;AAC1B,UAAM,SAAS,sBAAsB,MAAM,KAAK,CAAC;AACjD,WAAO,KAAK,IAAI,GAAG,WAAW,QAAQ,MAAM,CAAC;AAAA,EAC/C;AACA,MAAI,cAAc,WAAW;AAC3B,UAAM,QAAQ,CAAC,GAAG,IAAI,IAAI,gBAAgB,KAAK,CAAC,CAAC,EAAE;AAAA,MAAK,CA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AAY,KAAK,CAAC,eAAe,WAAW,SAAS,UAAU;AAAA,EACxE;AAAA,EAEA,iBACE,YACA,MACyB;AACzB,WAAO,oBAAoB,YAAY,IAAI;AAAA,EAC7C;AAAA,EAEA,MAAM,OACJ,YACA,MACA,mBACkB;AAClB,UAAM,UAAU,kBAAkB,QAC9B,EAAE,GAAG,KAAK,SAAS,aAAa,kBAAkB,MAAM,IACxD,KAAK;AACT,QAAI;AACF,cAAQ,YAAY;AAAA,QAClB,KAAK;AACH,iBAAO,MAAM,oBAAoB,MAAM,mBAAmB,SAAS,KAAK,KAAK;AAAA,QAC/E,KAAK;AACH,iBAAO,MAAM,oBAAoB,MAAM,SAAS,KAAK,OAAO,kBAAkB,MAAM;AAAA,QACtF,KAAK;AACH,iBAAO,MAAM,sBAAsB,MAAM,SAAS,kBAAkB,MAAM;AAAA,QAC5E;AACE,gBAAM,IAAI,MAAM,0BAA0B,UAAU,EAAE;AAAA,MAC1D;AAAA,IACF,SAAS,OAAO;AACd,UAAI,iBAAiB,uBAAuB;AAC1C,cAAM,SAAS;AAAA,UACb,MAAM,MAAM;AAAA,UACZ,SAAS,MAAM;AAAA,UACf,SAAS,MAAM;AAAA,UACf,YAAY,MAAM;AAAA,QACpB;AACA,YAAI,eAAe,SAAU,QAAO,cAAc,MAAM;AACxD,YAAI,eAAe,SAAU,QAAO,EAAE,SAAS,CAAC,GAAG,MAAM,MAAM,OAAO,OAAO;AAC7E,eAAO,EAAE,OAAO,OAAO;AAAA,MACzB;AACA,YAAM;AAAA,IACR;AAAA,EACF;AAEF;",
4
+ "sourcesContent": ["import type { FabricExecutionOutcomeV1 } from \"../audit/trace.js\";\nimport type { EntryRange, MemoryCoverage } from \"./index.js\";\nimport type { MemoryBranches } from \"./lineage.js\";\nimport type {\n DigestHit,\n SearchResult,\n SearchSegment,\n SearchSegmentEntry,\n} from \"./search.js\";\nimport {\n compareLexical,\n normalizeMemoryPhrase,\n tokenizeLexical,\n type MemoryQueryMatch,\n type MemoryQueryMode,\n} from \"./tokenize.js\";\n\nexport const RECALL_DEFAULT_PAGE_SIZE = 10;\nexport const RECALL_MAX_PAGE_SIZE = 50;\nexport const RECALL_DEFAULT_SNIPPET_CHARS = 480;\nexport const RECALL_MAX_SNIPPET_CHARS = 2_000;\nexport const RECALL_MAX_RESPONSE_CHARS = 30_000;\n\nexport interface MemoryRecallCallArgs {\n query?: string;\n queryMode?: MemoryQueryMode;\n queryMatch?: MemoryQueryMatch;\n expectedSourceHash?: string;\n expectedLineageFingerprint?: string;\n branches?: MemoryBranches;\n scope?: string;\n offset?: number;\n pageSize?: number;\n snippetChars?: number;\n role?: string;\n tool?: string;\n ref?: string;\n provider?: string;\n action?: string;\n outcome?: FabricExecutionOutcomeV1;\n since?: number;\n until?: number;\n entryRange?: EntryRange;\n source?: string;\n}\n\ninterface MemoryExpandCallArgs {\n session: string;\n source?: string;\n expectedSourceHash?: string;\n expectedLineageFingerprint?: string;\n branches?: MemoryBranches;\n indices?: number[];\n entryIds?: string[];\n operationAddresses?: string[];\n entryRange?: EntryRange;\n before?: number;\n after?: number;\n entryOffset?: number;\n textOffset?: number;\n maxChars?: number;\n maxEntries?: number;\n}\n\ninterface MemorySourceBinding {\n sessionId: string;\n sessionFile: string;\n source?: string;\n sourceHash: string;\n branches: MemoryBranches;\n lineageFingerprint: string;\n tier: \"hot\" | \"cold\";\n}\n\ninterface MemoryExpandFollow {\n ref: \"memory.expand\";\n args: MemoryExpandCallArgs;\n}\n\ninterface MemoryRecallFollow {\n ref: \"memory.recall\";\n args: MemoryRecallCallArgs;\n}\n\ninterface MemoryRecallEntryHit {\n kind: \"entry\";\n sessionId: string;\n tier: \"hot\" | \"cold\";\n index: number;\n entryId: string | null;\n parentId: string | null;\n operationAddress: string | null;\n type: string;\n role: string | null;\n tool: string | null;\n ref: string | null;\n provider: string | null;\n action: string | null;\n timestamp: number | null;\n isError: boolean;\n outcome?: FabricExecutionOutcomeV1;\n score: number;\n snippet: string;\n truncated: boolean;\n follow: MemoryExpandFollow;\n}\n\ninterface MemoryRecallSessionHit {\n kind: \"session\";\n sessionId: string;\n tier: \"cold\";\n cwd: string;\n lastTimestamp: number | null;\n score: number;\n matchedTerms: number;\n matchedStructuralEntries: number;\n follow: MemoryRecallFollow;\n}\n\ntype MemoryRecallHit = MemoryRecallEntryHit | MemoryRecallSessionHit;\n\ninterface MemoryRecallContinuation {\n ref: \"memory.recall\";\n args: MemoryRecallCallArgs;\n}\n\nexport interface MemoryRecallResponse {\n total: number;\n hits: MemoryRecallHit[];\n next: MemoryRecallContinuation | null;\n coverage: MemoryCoverage;\n}\n\ninterface RecallPresentationInput {\n result: SearchResult;\n query?: string;\n queryMode: MemoryQueryMode;\n coverage: MemoryCoverage;\n offset?: number;\n pageSize: number;\n snippetChars: number;\n requestArgs: MemoryRecallCallArgs;\n}\n\ninterface Snippet {\n text: string;\n truncated: boolean;\n}\n\nconst boundedMetadata = (value: string | null | undefined, max = 512): string | null => {\n if (value === undefined || value === null) return null;\n return value.length <= max ? value : `${value.slice(0, Math.max(1, max - 1))}\u2026`;\n};\n\nconst safeSlice = (text: string, start: number, end: number): string => {\n let safeStart = Math.max(0, start);\n let safeEnd = Math.min(text.length, end);\n const startCode = text.charCodeAt(safeStart);\n if (safeStart > 0 && startCode >= 0xdc00 && startCode <= 0xdfff) safeStart += 1;\n const endCode = text.charCodeAt(safeEnd - 1);\n if (safeEnd < text.length && endCode >= 0xd800 && endCode <= 0xdbff) safeEnd -= 1;\n return text.slice(safeStart, safeEnd);\n};\n\nconst snippetAnchor = (\n text: string,\n query: string | undefined,\n queryMode: MemoryQueryMode,\n): number => {\n if (!query) return 0;\n const normalized = normalizeMemoryPhrase(text);\n if (queryMode === \"phrase\") {\n const phrase = normalizeMemoryPhrase(query.trim());\n return Math.max(0, normalized.indexOf(phrase));\n }\n if (queryMode === \"literal\") {\n const terms = [...new Set(tokenizeLexical(query))].sort((left, right) =>\n right.length - left.length || left.localeCompare(right)\n );\n for (const term of terms) {\n const index = normalized.indexOf(term);\n if (index >= 0) return index;\n }\n }\n return 0;\n};\n\nconst makeSnippet = (\n text: string,\n query: string | undefined,\n queryMode: MemoryQueryMode,\n maxChars: number,\n): Snippet => {\n if (text.length <= maxChars) return { text, truncated: false };\n const anchor = snippetAnchor(text, query, queryMode);\n const leadingContext = Math.floor(maxChars / 3);\n let start = Math.max(0, anchor - leadingContext);\n let end = Math.min(text.length, start + maxChars);\n if (end - start < maxChars) start = Math.max(0, end - maxChars);\n const body = safeSlice(text, start, end);\n return {\n text: `${start > 0 ? \"\u2026\" : \"\"}${body}${end < text.length ? \"\u2026\" : \"\"}`,\n truncated: true,\n };\n};\n\nconst sourceFromSegment = (segment: SearchSegment, sourceId?: string): MemorySourceBinding => ({\n sessionId: boundedMetadata(segment.sessionId) ?? \"\",\n sessionFile: segment.sessionFile,\n ...(sourceId ? { source: sourceId } : {}),\n sourceHash: segment.sourceHash,\n branches: segment.branches,\n lineageFingerprint: segment.lineageFingerprint,\n tier: segment.tier,\n});\n\nconst sourceFromDigest = (digest: DigestHit, sourceId?: string): MemorySourceBinding => ({\n sessionId: boundedMetadata(digest.sessionId) ?? \"\",\n sessionFile: digest.sessionFile,\n ...(sourceId ? { source: sourceId } : {}),\n sourceHash: digest.sourceHash,\n branches: digest.branches,\n lineageFingerprint: digest.lineageFingerprint,\n tier: \"cold\",\n});\n\nconst expandArgs = (\n source: MemorySourceBinding,\n entry: SearchSegmentEntry[\"entry\"],\n): MemoryExpandCallArgs => ({\n session: source.sessionFile,\n ...(source.source ? { source: source.source } : {}),\n expectedSourceHash: source.sourceHash,\n expectedLineageFingerprint: source.lineageFingerprint,\n branches: source.branches,\n indices: [entry.index],\n});\n\nconst entryHit = (\n segment: SearchSegment,\n item: SearchSegmentEntry,\n query: string | undefined,\n queryMode: MemoryQueryMode,\n snippetChars: number,\n sourceId?: string,\n): MemoryRecallEntryHit => {\n const entry = item.entry;\n const source = sourceFromSegment(segment, sourceId);\n const snippet = makeSnippet(entry.text, query, queryMode, snippetChars);\n return {\n kind: \"entry\",\n sessionId: source.sessionId,\n tier: source.tier,\n index: entry.index,\n entryId: boundedMetadata(entry.entryId),\n parentId: boundedMetadata(entry.parentId),\n operationAddress: boundedMetadata(entry.operationAddress),\n type: boundedMetadata(entry.type) ?? \"entry\",\n role: boundedMetadata(entry.role),\n tool: boundedMetadata(entry.toolName),\n ref: boundedMetadata(entry.ref),\n provider: boundedMetadata(entry.provider),\n action: boundedMetadata(entry.action),\n timestamp: entry.timestamp,\n isError: entry.isError,\n ...(entry.outcome ? { outcome: entry.outcome } : {}),\n score: item.score,\n snippet: snippet.text,\n truncated: snippet.truncated || entry.truncated,\n follow: { ref: \"memory.expand\", args: expandArgs(source, entry) },\n };\n};\n\nconst hydrationArgs = (\n digest: DigestHit,\n request: MemoryRecallCallArgs,\n): MemoryRecallCallArgs => {\n const { offset: _offset, entryRange: _entryRange, ...base } = request;\n return {\n ...base,\n scope: `session:${digest.sessionFile}`,\n branches: digest.branches,\n expectedSourceHash: digest.sourceHash,\n expectedLineageFingerprint: digest.lineageFingerprint,\n };\n};\n\nconst sessionHit = (\n digest: DigestHit,\n request: MemoryRecallCallArgs,\n sourceId?: string,\n): MemoryRecallSessionHit => {\n const source = sourceFromDigest(digest, sourceId);\n return {\n kind: \"session\",\n sessionId: source.sessionId,\n tier: \"cold\",\n cwd: boundedMetadata(digest.cwd, 2_048) ?? \"\",\n lastTimestamp: digest.lastTs,\n score: digest.score,\n matchedTerms: digest.matchedTerms,\n matchedStructuralEntries: digest.matchedStructuralEntries,\n follow: { ref: \"memory.recall\", args: hydrationArgs(digest, request) },\n };\n};\n\ntype RecallCandidate =\n | { kind: \"entry\"; segment: SearchSegment; item: SearchSegmentEntry }\n | { kind: \"session\"; digest: DigestHit };\n\nconst recallCandidateCache = new WeakMap<SearchResult, RecallCandidate[]>();\n\nconst flattenCandidates = (result: SearchResult): RecallCandidate[] => {\n const cached = recallCandidateCache.get(result);\n if (cached) return cached;\n const candidates: RecallCandidate[] = [];\n for (const item of result.items) {\n if (item.kind === \"digest\") {\n candidates.push({ kind: \"session\", digest: item.digest });\n continue;\n }\n for (const entry of item.segment.entries) {\n if (entry.matched) candidates.push({ kind: \"entry\", segment: item.segment, item: entry });\n }\n }\n candidates.sort((left, right) => {\n const leftScore = left.kind === \"entry\" ? left.item.score : left.digest.score;\n const rightScore = right.kind === \"entry\" ? right.item.score : right.digest.score;\n if (rightScore !== leftScore) return rightScore - leftScore;\n const leftMtime = left.kind === \"entry\" ? left.segment.sessionMtime : left.digest.sessionMtime;\n const rightMtime = right.kind === \"entry\" ? right.segment.sessionMtime : right.digest.sessionMtime;\n if (rightMtime !== leftMtime) return rightMtime - leftMtime;\n if (left.kind !== right.kind) return left.kind === \"entry\" ? -1 : 1;\n if (left.kind === \"entry\" && right.kind === \"entry\") {\n if (left.item.entry.index !== right.item.entry.index) {\n return left.item.entry.index - right.item.entry.index;\n }\n return compareLexical(left.segment.sessionFile, right.segment.sessionFile);\n }\n if (left.kind === \"session\" && right.kind === \"session\") {\n return compareLexical(left.digest.sessionFile, right.digest.sessionFile);\n }\n return 0;\n });\n recallCandidateCache.set(result, candidates);\n return candidates;\n};\n\nconst materializeCandidate = (\n candidate: RecallCandidate,\n query: string | undefined,\n queryMode: MemoryQueryMode,\n snippetChars: number,\n request: MemoryRecallCallArgs,\n sourceId?: string,\n): MemoryRecallHit => candidate.kind === \"session\"\n ? sessionHit(candidate.digest, request, sourceId)\n : entryHit(candidate.segment, candidate.item, query, queryMode, snippetChars, sourceId);\n\nconst canonicalNextArgs = (\n request: MemoryRecallCallArgs,\n offset: number,\n): MemoryRecallCallArgs => {\n const { offset: _offset, ...base } = request;\n return { ...base, offset };\n};\n\nexport const presentRecall = (input: RecallPresentationInput): MemoryRecallResponse => {\n const candidates = flattenCandidates(input.result);\n const start = input.offset ?? 0;\n let selected = candidates.slice(start, start + input.pageSize);\n\n const build = (pageCandidates: RecallCandidate[]): MemoryRecallResponse => {\n const hits = pageCandidates.map((candidate) =>\n materializeCandidate(\n candidate,\n input.query,\n input.queryMode,\n input.snippetChars,\n input.requestArgs,\n input.requestArgs.source,\n )\n );\n return {\n total: candidates.length,\n hits,\n next: start + hits.length < candidates.length\n ? { ref: \"memory.recall\", args: canonicalNextArgs(input.requestArgs, start + hits.length) }\n : null,\n coverage: input.coverage,\n };\n };\n\n let response = build(selected);\n while (selected.length > 1 && JSON.stringify(response).length > RECALL_MAX_RESPONSE_CHARS) {\n selected = selected.slice(0, -1);\n response = build(selected);\n }\n return response;\n};\n", "export const EXPAND_DEFAULT_MAX_CHARS = 20_000;\nexport const EXPAND_MAX_CHARS = 24_000;\nexport const EXPAND_DEFAULT_MAX_ENTRIES = 10;\nexport const EXPAND_MAX_ENTRIES = 20;\nexport const EXPAND_MAX_CONTEXT = 100;\nexport const EXPAND_MAX_EXACT_SELECTORS = 100;\nexport const SESSIONS_MAX = 500;\n", "import path from \"node:path\";\nimport type { FabricMemoryConfig } from \"../config.js\";\nimport type { MemorySourceRegistry } from \"./portable.js\";\nimport type { FabricScope } from \"../protocol.js\";\nimport {\n enumerateAllSessions,\n resolveScope,\n type ResolveScopeInput,\n type SessionRef,\n} from \"./discovery.js\";\nimport type { LiveSessionBranch, MemoryBranches } from \"./lineage.js\";\nimport { DEFAULT_HOT_SESSIONS, type MemoryIndexOptions } from \"./index.js\";\n\nexport interface MemoryProviderContext {\n agentDir: string;\n cwd: string;\n config: FabricMemoryConfig;\n sessionId?: string;\n sessionFile?: string;\n getLiveBranch?: () => LiveSessionBranch;\n /** Registered portable memory sources; present enables host-backed calls. */\n sources?: MemorySourceRegistry;\n /** Per-call host-issued scope: forwarded to source authorization and keyed into request caches. */\n fabricScope?: Readonly<FabricScope>;\n}\n\nexport const parseBranches = (value: unknown, action: string): MemoryBranches => {\n if (value === undefined) return \"active\";\n if (value === \"active\" || value === \"all\") return value;\n throw new Error(`${action} branches must be \"active\" or \"all\"`);\n};\n\nexport const resolveIndexOptions = (\n config: FabricMemoryConfig,\n agentDir: string,\n branches: MemoryBranches,\n liveBranchForFile?: MemoryIndexOptions[\"liveBranchForFile\"],\n): MemoryIndexOptions => ({\n indexDir: config.indexDir ?? `${agentDir}/fabric/memory-index`,\n maxEntryChars: config.maxEntryChars,\n branches,\n indexThinking: config.indexThinking ?? false,\n indexToolOutput: config.indexToolOutput ?? true,\n ...(liveBranchForFile ? { liveBranchForFile } : {}),\n hotSessions: config.hotSessions ?? DEFAULT_HOT_SESSIONS,\n digestTerms: config.digestTerms ?? 200,\n ...(config.maxColdVocabularyBytes === undefined\n ? {} : { maxColdVocabularyBytes: config.maxColdVocabularyBytes }),\n ...(config.maxColdCacheBytes === undefined ? {} : { maxColdCacheBytes: config.maxColdCacheBytes }),\n ...(config.maxSyncSessions === undefined ? {} : { maxSyncSessions: config.maxSyncSessions }),\n ...(config.maxSyncSourceBytes === undefined ? {} : { maxSyncSourceBytes: config.maxSyncSourceBytes }),\n ...(config.maxCacheCleanupFiles === undefined\n ? {} : { maxCacheCleanupFiles: config.maxCacheCleanupFiles }),\n});\n\nexport const resolveTierRefs = (refs: SessionRef[], context: MemoryProviderContext): SessionRef[] => {\n const all = enumerateAllSessions(context.agentDir, Number.MAX_SAFE_INTEGER);\n const known = new Set(all.map((ref) => ref.file));\n for (const ref of refs) {\n if (!known.has(ref.file)) all.push(ref);\n }\n return all;\n};\n\nexport const resolveRefs = (\n scope: string | undefined,\n context: MemoryProviderContext,\n boundedBrowse: boolean,\n): SessionRef[] => {\n const effectiveScope = scope ?? \"session\";\n const input: ResolveScopeInput = {\n agentDir: context.agentDir,\n cwd: context.cwd,\n scope: effectiveScope,\n maxSessions: boundedBrowse ? context.config.maxSessions : Number.MAX_SAFE_INTEGER,\n };\n if (context.sessionId) input.sessionId = context.sessionId;\n if (context.sessionFile) input.sessionFile = context.sessionFile;\n return resolveScope(input);\n};\n\nexport const liveBranchResolver = (\n context: MemoryProviderContext,\n): MemoryIndexOptions[\"liveBranchForFile\"] | undefined => {\n if (!context.sessionFile || !context.getLiveBranch) return undefined;\n const current = path.resolve(context.sessionFile);\n return (sessionFile) => path.resolve(sessionFile) === current\n ? context.getLiveBranch?.()\n : undefined;\n};\n\nexport const stalePointerError = (\n sessionFile: string,\n expectedSourceHash: string | undefined,\n actualSourceHash: string,\n expectedLineageFingerprint?: string,\n actualLineageFingerprint?: string,\n) => ({\n code: \"stale_pointer\",\n message: expectedLineageFingerprint !== undefined &&\n expectedLineageFingerprint !== actualLineageFingerprint\n ? \"Session active lineage changed after the pointer was issued.\"\n : \"Session source changed after the pointer was issued.\",\n sessionFile,\n ...(expectedSourceHash === undefined ? {} : { expectedSourceHash }),\n actualSourceHash,\n ...(expectedLineageFingerprint === undefined ? {} : { expectedLineageFingerprint }),\n ...(actualLineageFingerprint === undefined ? {} : { actualLineageFingerprint }),\n});\n\nexport const addressError = (message: string, entryCount?: number) => ({\n code: \"index_out_of_bounds\",\n message,\n ...(entryCount === undefined ? {} : { entryCount }),\n});\n\nexport const recallFailure = (error: { code: string; message: string; [key: string]: unknown }) => ({\n total: 0,\n hits: [],\n next: null,\n coverage: {\n complete: false,\n indexedSessions: 0,\n eligibleSessions: 0,\n staleSessions: 0,\n incompleteSessions: 0,\n reasons: [error.code],\n },\n error,\n});\n", "import path from \"node:path\";\nimport {\n RECALL_DEFAULT_PAGE_SIZE,\n RECALL_DEFAULT_SNIPPET_CHARS,\n type MemoryRecallCallArgs,\n} from \"./context.js\";\nimport type { MemoryBranches } from \"./lineage.js\";\nimport type { ExpandSessionSelection, ExpandedSessionEntry, NormalizedEntry } from \"./normalize.js\";\nimport type { MemoryCoverage } from \"./index.js\";\nimport type { SearchResult } from \"./search.js\";\nimport {\n sameSourceObservation,\n sameSourceObservations,\n type SourceObservation,\n} from \"./source-observation.js\";\n\nconst CONTINUATION_CACHE_TTL_MS = 5 * 60_000;\nconst EXPANSION_SNAPSHOT_LIMIT = 2;\nconst EXPANSION_SELECTION_LIMIT = 16;\n\nexport type CanonicalExpansionSelection = ExpandSessionSelection & {\n before?: number;\n after?: number;\n};\n\nexport interface ResolvedExpansionSelection {\n entries: ExpandedSessionEntry[];\n canonical: CanonicalExpansionSelection;\n anchorIndex: number | null;\n}\n\nexport interface ExpansionSnapshot {\n file: string;\n branches: MemoryBranches;\n /** Host scope digest; a snapshot is never served under another scope. */\n scopeDigest?: string;\n sourceHash: string;\n lineageFingerprint: string;\n observation: SourceObservation;\n entries: readonly NormalizedEntry[];\n selections: Map<string, ResolvedExpansionSelection>;\n touchedAt: number;\n}\n\nexport interface RecallContinuationCache {\n key: string;\n result: SearchResult;\n coverage: MemoryCoverage;\n requestArgs: MemoryRecallCallArgs;\n observations: readonly SourceObservation[];\n touchedAt: number;\n}\n\nexport const recallContinuationKey = (args: MemoryRecallCallArgs, scopeDigest?: string): string => JSON.stringify([\n scopeDigest ?? null,\n args.query ?? null,\n args.queryMode ?? \"literal\",\n args.queryMatch ?? null,\n args.expectedSourceHash ?? null,\n args.expectedLineageFingerprint ?? null,\n args.branches ?? \"active\",\n args.scope ?? \"session\",\n args.pageSize ?? RECALL_DEFAULT_PAGE_SIZE,\n args.snippetChars ?? RECALL_DEFAULT_SNIPPET_CHARS,\n args.role ?? null,\n args.tool ?? null,\n args.ref ?? null,\n args.provider ?? null,\n args.action ?? null,\n args.outcome ?? null,\n args.since ?? null,\n args.until ?? null,\n args.entryRange ? [args.entryRange.first, args.entryRange.last] : null,\n]);\n\nconst expansionSnapshotKey = (file: string, branches: MemoryBranches, scopeDigest?: string): string =>\n `${path.resolve(file)}\\0${branches}\\0${scopeDigest ?? \"\"}`;\n\nexport const expansionSelectionKey = (selection: CanonicalExpansionSelection): string => JSON.stringify([\n selection.indices ?? null,\n selection.entryIds ?? null,\n selection.operationAddresses ?? null,\n selection.entryRange ? [selection.entryRange.first, selection.entryRange.last] : null,\n selection.before ?? 0,\n selection.after ?? 0,\n]);\n\nexport class MemoryRequestCache {\n private recallContinuation: RecallContinuationCache | undefined;\n private readonly expansionSnapshots = new Map<string, ExpansionSnapshot>();\n\n cachedRecallContinuation(\n key: string,\n observations: readonly SourceObservation[] | null,\n ): RecallContinuationCache | undefined {\n const cached = this.recallContinuation;\n if (!cached || cached.key !== key) return undefined;\n if (\n !observations ||\n Date.now() - cached.touchedAt > CONTINUATION_CACHE_TTL_MS ||\n !sameSourceObservations(cached.observations, observations)\n ) {\n this.recallContinuation = undefined;\n return undefined;\n }\n cached.touchedAt = Date.now();\n return cached;\n }\n\n rememberRecallContinuation(cached: RecallContinuationCache): void {\n this.recallContinuation = cached;\n }\n\n forgetRecallContinuation(cached: RecallContinuationCache): void {\n if (this.recallContinuation === cached) this.recallContinuation = undefined;\n }\n\n cachedExpansionSnapshot(\n file: string,\n branches: MemoryBranches,\n observation: SourceObservation | null,\n scopeDigest?: string,\n ): ExpansionSnapshot | undefined {\n const key = expansionSnapshotKey(file, branches, scopeDigest);\n const cached = this.expansionSnapshots.get(key);\n if (!cached) return undefined;\n if (\n !observation ||\n Date.now() - cached.touchedAt > CONTINUATION_CACHE_TTL_MS ||\n !sameSourceObservation(cached.observation, observation)\n ) {\n this.expansionSnapshots.delete(key);\n return undefined;\n }\n cached.touchedAt = Date.now();\n this.expansionSnapshots.delete(key);\n this.expansionSnapshots.set(key, cached);\n return cached;\n }\n\n rememberExpansionSnapshot(snapshot: ExpansionSnapshot): void {\n const key = expansionSnapshotKey(snapshot.file, snapshot.branches, snapshot.scopeDigest);\n this.expansionSnapshots.delete(key);\n this.expansionSnapshots.set(key, snapshot);\n while (this.expansionSnapshots.size > EXPANSION_SNAPSHOT_LIMIT) {\n const oldest = this.expansionSnapshots.keys().next().value;\n if (oldest === undefined) break;\n this.expansionSnapshots.delete(oldest);\n }\n }\n\n rememberExpansionSelection(\n snapshot: ExpansionSnapshot,\n keys: readonly string[],\n selection: ResolvedExpansionSelection,\n ): void {\n for (const key of new Set(keys)) {\n snapshot.selections.delete(key);\n snapshot.selections.set(key, selection);\n }\n while (snapshot.selections.size > EXPANSION_SELECTION_LIMIT) {\n const oldest = snapshot.selections.keys().next().value;\n if (oldest === undefined) break;\n snapshot.selections.delete(oldest);\n }\n }\n\n forgetExpansionSnapshot(snapshot: ExpansionSnapshot): void {\n const key = expansionSnapshotKey(snapshot.file, snapshot.branches, snapshot.scopeDigest);\n if (this.expansionSnapshots.get(key) === snapshot) this.expansionSnapshots.delete(key);\n }\n}\n\n// Services can only access their own cache lifecycle operations.\nexport type RecallRequestCache = Pick<MemoryRequestCache,\n \"cachedRecallContinuation\" | \"rememberRecallContinuation\" | \"forgetRecallContinuation\"\n>;\n\nexport type ExpansionRequestCache = Pick<MemoryRequestCache,\n \"cachedExpansionSnapshot\" | \"rememberExpansionSnapshot\" | \"rememberExpansionSelection\" | \"forgetExpansionSnapshot\"\n>;\n", "import crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { SessionRef } from \"./discovery.js\";\nimport type { LiveSessionBranch, MemoryBranches } from \"./lineage.js\";\nimport type { MemoryIndexOptions } from \"./index.js\";\n\ninterface SourceIdentity {\n device: bigint;\n inode: bigint;\n size: bigint;\n modifiedAt: bigint;\n changedAt: bigint;\n}\n\nexport interface SourceObservation {\n file: string;\n identity: SourceIdentity;\n liveBranchSignature: string | null;\n}\n\ntype LiveBranchResolver = MemoryIndexOptions[\"liveBranchForFile\"];\n\nconst sourceIdentity = (file: string): SourceIdentity | null => {\n try {\n const stat = fs.statSync(file, { bigint: true });\n if (!stat.isFile()) return null;\n return {\n device: stat.dev,\n inode: stat.ino,\n size: stat.size,\n modifiedAt: stat.mtimeNs,\n changedAt: stat.ctimeNs,\n };\n } catch {\n return null;\n }\n};\n\nconst sameSourceIdentity = (left: SourceIdentity, right: SourceIdentity): boolean =>\n left.device === right.device &&\n left.inode === right.inode &&\n left.size === right.size &&\n left.modifiedAt === right.modifiedAt &&\n left.changedAt === right.changedAt;\n\nconst liveBranchSignature = (branch: LiveSessionBranch | undefined): string | null =>\n branch ? `${branch.leafId ?? \"\"}\\0${branch.entries.length}` : null;\n\nexport const observeSource = (\n file: string,\n branches: MemoryBranches,\n liveBranch: LiveSessionBranch | undefined,\n): SourceObservation | null => {\n const identity = sourceIdentity(file);\n if (!identity) return null;\n return {\n file: path.resolve(file),\n identity,\n liveBranchSignature: branches === \"active\" ? liveBranchSignature(liveBranch) : null,\n };\n};\n\nconst hostIdentity = (revision: string, sourceHash: string): SourceIdentity => {\n const digest = crypto.createHash(\"sha256\").update(`${revision}\\u0000${sourceHash}`).digest(\"hex\");\n return {\n device: BigInt(parseInt(digest.slice(0, 8), 16)),\n inode: BigInt(parseInt(digest.slice(8, 16), 16)),\n size: BigInt(parseInt(digest.slice(16, 24), 16)),\n modifiedAt: BigInt(parseInt(digest.slice(24, 32), 16)),\n changedAt: BigInt(parseInt(digest.slice(32, 40), 16)),\n };\n};\n\n/**\n * Observation identity for a portable host source snapshot: derived from the\n * adapter revision plus the engine's source hash, so a changed or reloaded\n * snapshot invalidates request caches without any filesystem access.\n */\nexport const observeHostSource = (\n displayKey: string,\n revision: string,\n sourceHash: string,\n): SourceObservation => ({\n file: displayKey,\n identity: hostIdentity(revision, sourceHash),\n liveBranchSignature: null,\n});\n\nexport const observeSources = (\n refs: readonly SessionRef[],\n branches: MemoryBranches,\n liveResolver: LiveBranchResolver,\n): SourceObservation[] | null => {\n const observations: SourceObservation[] = [];\n for (const ref of refs) {\n const liveBranch = branches === \"active\" ? liveResolver?.(ref.file) : undefined;\n const observation = observeSource(ref.file, branches, liveBranch);\n if (!observation) return null;\n observations.push(observation);\n }\n return observations;\n};\n\nexport const sameSourceObservation = (left: SourceObservation, right: SourceObservation): boolean =>\n left.file === right.file &&\n sameSourceIdentity(left.identity, right.identity) &&\n left.liveBranchSignature === right.liveBranchSignature;\n\nexport const sameSourceObservations = (\n left: readonly SourceObservation[],\n right: readonly SourceObservation[],\n): boolean => left.length === right.length && left.every((item, index) =>\n sameSourceObservation(item, right[index]!)\n);\n", "import crypto from \"node:crypto\";\nimport { foldSessionDigest } from \"./digest.js\";\nimport { resolveSessionTarget, type SessionRef } from \"./discovery.js\";\nimport {\n classifySessionTiers,\n digestPolicy,\n fitDigestCache,\n fingerprintSource,\n loadTieredIndex,\n MEMORY_CACHE_VERSION,\n missingDigest,\n missingShard,\n shardPolicy,\n type DigestShard,\n type EntryRange,\n type MemoryCoverage,\n type MemoryIndexOptions,\n type Shard,\n type SourceState,\n type TieredIndexBundle,\n} from \"./index.js\";\nimport {\n reconstructRecordsLineage,\n reconstructSessionLineage,\n type MemoryBranches,\n type SessionLineage,\n} from \"./lineage.js\";\nimport {\n normalizeRecords,\n normalizeSession,\n type NormalizationCoverage,\n type NormalizedEntry,\n} from \"./normalize.js\";\nimport type {\n MemorySourceAction,\n MemorySourceCoverage,\n MemorySourceListPage,\n MemorySourceRecord,\n MemorySourceSessionDescriptor,\n MemorySourceSessionMetadata,\n MemorySourceSnapshot,\n PortableMemorySource,\n} from \"./portable.js\";\nimport { MemorySourceError } from \"./portable.js\";\nimport type { FabricScope } from \"../protocol.js\";\nimport { observeHostSource, observeSource, observeSources, type SourceObservation } from \"./source-observation.js\";\nimport {\n liveBranchResolver,\n resolveTierRefs,\n type MemoryProviderContext,\n} from \"./request-context.js\";\n\nconst HOST_KEY_PREFIX = \"memory-source:\";\nconst REASON_PATTERN = /^[a-z0-9_.:-]{1,64}$/;\n\nexport interface HostSnapshot {\n sourceId: string;\n sessionKey: string;\n displayKey: string;\n sessionId: string;\n revision: string;\n metadata: MemorySourceSessionMetadata;\n records: readonly MemorySourceRecord[];\n coverageReasons: string[];\n selectedLeafId?: string | null;\n}\n\n/** Opaque, stable, non-filesystem session key shown in public outputs. */\nconst hostDisplayKey = (sourceId: string, sessionKey: string): string =>\n `${HOST_KEY_PREFIX}${sourceId}/${sessionKey}`;\n\n/** Accept both the engine's display key and the adapter's raw session key. */\nconst hostSessionKey = (sourceId: string, session: string): string => {\n const prefix = `${HOST_KEY_PREFIX}${sourceId}/`;\n return session.startsWith(prefix) ? session.slice(prefix.length) : session;\n};\n\nexport const resolveRegisteredSource = (\n registry: { get(id: string): PortableMemorySource | undefined } | undefined,\n sourceId: string,\n): PortableMemorySource => {\n const source = registry?.get(sourceId);\n if (!source) throw new MemorySourceError(\"source_not_found\", `Memory source not registered: ${sourceId}`);\n return source;\n};\n\nexport const memorySourceFailure = (error: unknown): { code: string; message: string } | null =>\n error instanceof MemorySourceError ? { code: error.code, message: error.message } : null;\n\nexport const checkAbort = (signal: AbortSignal | undefined): void => {\n if (signal?.aborted) throw new MemorySourceError(\"aborted\", \"Memory source call was aborted.\");\n};\n\nconst assertAuthorized = async (\n source: PortableMemorySource,\n action: MemorySourceAction,\n sessionKey: string | null,\n scope: Readonly<FabricScope> | undefined,\n): Promise<void> => {\n if (!source.authorize) return;\n let allowed: boolean;\n try {\n allowed = await (scope ? source.authorize(action, sessionKey, scope) : source.authorize(action, sessionKey));\n } catch {\n // Adapter failures stay sanitized: no backend error text, paths, or\n // credentials may reach public memory results.\n throw new MemorySourceError(\"source_unauthorized\", \"Memory source authorization failed.\");\n }\n if (allowed !== true) {\n throw new MemorySourceError(\"source_unauthorized\", \"Memory source denied access.\");\n }\n};\n\nconst coverageReasons = (coverage: MemorySourceCoverage | undefined): string[] => {\n if (!coverage || coverage.complete !== false) return [];\n const reason = typeof coverage.reason === \"string\" && REASON_PATTERN.test(coverage.reason)\n ? `source_coverage:${coverage.reason}`\n : \"source_coverage_incomplete\";\n return [reason];\n};\n\nconst asSessionKey = (value: unknown): string =>\n typeof value === \"string\" && value.length > 0 ? value : \"\";\n\nconst normalizeListResponse = (\n response: readonly MemorySourceSessionDescriptor[] | MemorySourceListPage,\n): { sessions: readonly MemorySourceSessionDescriptor[]; coverageReasons: string[] } =>\n Array.isArray(response)\n ? { sessions: response as readonly MemorySourceSessionDescriptor[], coverageReasons: [] }\n : { sessions: (response as MemorySourceListPage).sessions, coverageReasons: coverageReasons((response as MemorySourceListPage).coverage) };\n\n/**\n * Validate one adapter snapshot. Authorization is re-checked after the async\n * load so a revocation during the load fails closed before any content\n * reaches the engine. The returned snapshot deep-clones records and metadata,\n * so later adapter mutation (including nested objects) cannot change what the\n * engine already indexed; non-JSON-serializable records fail closed as\n * invalid_source_response because the engine's own hashing is JSON-canonical.\n */\nconst loadHostSnapshot = async (\n source: PortableMemorySource,\n sessionKey: string,\n action: MemorySourceAction,\n signal?: AbortSignal,\n scope?: Readonly<FabricScope>,\n): Promise<HostSnapshot | null> => {\n checkAbort(signal);\n await assertAuthorized(source, action, sessionKey, scope);\n const response = await source.loadSession(sessionKey, signal === undefined ? {} : { signal });\n checkAbort(signal);\n await assertAuthorized(source, action, sessionKey, scope);\n if (response === null || response === undefined) return null;\n const key = asSessionKey(response.sessionKey);\n const revision = asSessionKey(response.revision);\n if (!revision || !Array.isArray(response.records) || key !== sessionKey) {\n throw new MemorySourceError(\"invalid_source_response\", \"Memory source returned an invalid snapshot.\");\n }\n if (!response.records.every((record) =>\n record !== null && typeof record === \"object\" && !Array.isArray(record))) {\n throw new MemorySourceError(\"invalid_source_response\", \"Memory source snapshot has non-object records.\");\n }\n let records: readonly MemorySourceRecord[];\n try {\n records = JSON.parse(JSON.stringify(response.records)) as MemorySourceRecord[];\n } catch {\n throw new MemorySourceError(\n \"invalid_source_response\",\n \"Memory source snapshot records are not JSON-serializable.\",\n );\n }\n if (response.selectedLeafId !== undefined && response.selectedLeafId !== null &&\n (typeof response.selectedLeafId !== \"string\" || !records.some(record =>\n record.type !== \"session\" && record.id === response.selectedLeafId))) {\n throw new MemorySourceError(\"invalid_source_response\", \"Memory source selected leaf is invalid.\");\n }\n return {\n sourceId: source.id,\n sessionKey,\n displayKey: hostDisplayKey(source.id, sessionKey),\n sessionId: response.sessionId ?? sessionKey,\n revision,\n metadata: { ...(response.metadata ?? {}) },\n records,\n ...(response.selectedLeafId !== undefined ? { selectedLeafId: response.selectedLeafId } : {}),\n coverageReasons: coverageReasons(response.coverage),\n };\n};\n\nexport const listHostSnapshots = async (\n source: PortableMemorySource,\n limit: number,\n action: MemorySourceAction,\n signal?: AbortSignal,\n scope?: Readonly<FabricScope>,\n): Promise<{ snapshots: HostSnapshot[]; coverageReasons: string[] }> => {\n checkAbort(signal);\n await assertAuthorized(source, action, null, scope);\n const boundedLimit = Math.max(0, Math.floor(limit));\n const listed = normalizeListResponse(\n await source.listSessions(signal === undefined ? { limit: boundedLimit } : { limit: boundedLimit, signal }),\n );\n checkAbort(signal);\n const snapshots: HostSnapshot[] = [];\n const coverageReasons = new Set(listed.coverageReasons);\n if (listed.sessions.length > boundedLimit) {\n coverageReasons.add(\"source_limit_exceeded\");\n }\n for (const descriptor of listed.sessions.slice(0, boundedLimit)) {\n checkAbort(signal);\n const key = asSessionKey(descriptor.sessionKey);\n if (!key) {\n coverageReasons.add(\"invalid_source_response\");\n continue;\n }\n const snapshot = await loadHostSnapshot(source, key, action, signal, scope);\n if (!snapshot) {\n coverageReasons.add(\"source_unavailable\");\n continue;\n }\n for (const reason of snapshot.coverageReasons) coverageReasons.add(reason);\n snapshots.push(snapshot);\n }\n if (snapshots.length === 0) {\n await assertAuthorized(source, action, null, scope);\n }\n return { snapshots, coverageReasons: [...coverageReasons] };\n};\n\nconst hostSourceState = (snapshot: HostSnapshot): SourceState => {\n const canonical = JSON.stringify(snapshot.records);\n const sourceHash = crypto\n .createHash(\"sha256\")\n .update(`${snapshot.revision}\\u0000${canonical}`)\n .digest(\"hex\");\n return {\n mtime: snapshot.metadata.updatedAt ?? 0,\n size: Buffer.byteLength(canonical, \"utf8\"),\n sourceHash,\n };\n};\n\nconst hostRef = (snapshot: HostSnapshot): SessionRef => ({\n id: snapshot.sessionId,\n file: snapshot.displayKey,\n cwd: snapshot.metadata.cwd ?? \"\",\n mtime: snapshot.metadata.updatedAt ?? 0,\n});\n\nconst hostLineage = (snapshot: HostSnapshot, branches: MemoryBranches): SessionLineage =>\n reconstructRecordsLineage(snapshot.records, branches, undefined, snapshot.selectedLeafId);\n\nconst hostIdentity = (sessionFile: string, sessionId: string | undefined, cwd: string | undefined) => ({\n sessionFile,\n ...(sessionId !== undefined ? { sessionId } : {}),\n ...(cwd !== undefined ? { cwd } : {}),\n});\n\nconst mergedCoverage = (\n base: NormalizationCoverage,\n extra: readonly string[],\n): NormalizationCoverage => {\n if (extra.length === 0) return base;\n const reasons = [...new Set([...base.reasons, ...extra])].sort();\n return { complete: false, reasons };\n};\n\nconst buildHostShard = (\n snapshot: HostSnapshot,\n options: MemoryIndexOptions,\n tier: \"hot\" | \"cold\",\n entryRange?: EntryRange,\n): Shard => {\n const state = hostSourceState(snapshot);\n const lineage = hostLineage(snapshot, options.branches ?? \"active\");\n const { entries, header, indexCoverage } = normalizeRecords(\n snapshot.records,\n hostIdentity(snapshot.displayKey, snapshot.sessionId, snapshot.metadata.cwd),\n options.maxEntryChars,\n {\n lineage,\n indexThinking: options.indexThinking ?? false,\n indexToolOutput: options.indexToolOutput ?? true,\n },\n );\n const selected = entryRange\n ? entries.filter((entry) => entry.index >= entryRange.first && entry.index <= entryRange.last)\n : entries;\n return {\n cacheVersion: MEMORY_CACHE_VERSION,\n kind: \"shard\",\n sessionFile: snapshot.displayKey,\n sessionId: header?.sessionId ?? snapshot.sessionId,\n mtime: state.mtime,\n size: state.size,\n sourceHash: state.sourceHash,\n branches: lineage.branches,\n lineageFingerprint: lineage.fingerprint,\n policy: shardPolicy(options, lineage),\n cacheBytes: 0,\n cacheSourceRatio: 0,\n entries: selected,\n totalEntryCount: entries.length,\n indexCoverage: mergedCoverage(indexCoverage, snapshot.coverageReasons),\n tier,\n };\n};\n\nconst buildHostDigest = (snapshot: HostSnapshot, options: MemoryIndexOptions): DigestShard => {\n const state = hostSourceState(snapshot);\n const lineage = hostLineage(snapshot, options.branches ?? \"active\");\n const { entries, header, indexCoverage } = normalizeRecords(\n snapshot.records,\n hostIdentity(snapshot.displayKey, snapshot.sessionId, snapshot.metadata.cwd),\n Number.MAX_SAFE_INTEGER,\n {\n lineage,\n indexThinking: options.indexThinking ?? false,\n indexToolOutput: options.indexToolOutput ?? true,\n },\n );\n const digest = foldSessionDigest({\n sessionId: header?.sessionId ?? snapshot.sessionId,\n file: snapshot.displayKey,\n cwd: header?.cwd ?? snapshot.metadata.cwd ?? \"\",\n entries,\n maxVocabularyBytes: options.maxColdVocabularyBytes ?? 512 * 1024,\n normalizationCoverage: mergedCoverage(indexCoverage, snapshot.coverageReasons),\n });\n return fitDigestCache({\n cacheVersion: MEMORY_CACHE_VERSION,\n kind: \"digest\",\n ...digest,\n mtime: state.mtime,\n size: state.size,\n sourceHash: state.sourceHash,\n branches: lineage.branches,\n lineageFingerprint: lineage.fingerprint,\n policy: digestPolicy(options, lineage),\n cacheBytes: 0,\n cacheSourceRatio: 0,\n }, options.maxColdCacheBytes ?? 1024 * 1024);\n};\n\n/** In-memory tiered index for host sources: identical tiers, budgets, and\n * coverage semantics as the filesystem index, with no disk cache writes. */\nexport const loadHostTieredIndex = (\n snapshots: readonly HostSnapshot[],\n options: MemoryIndexOptions,\n hydrate = false,\n entryRange?: EntryRange,\n extraReasons: readonly string[] = [],\n): TieredIndexBundle => {\n const refs = snapshots.map(hostRef);\n const tiers = classifySessionTiers(refs, options.hotSessions ?? 50);\n const maxSessions = options.maxSyncSessions ?? 10_000;\n const maxSourceBytes = options.maxSyncSourceBytes ?? 512 * 1024 * 1024;\n const shards: Shard[] = [];\n const digests: DigestShard[] = [];\n const reasons = new Set(extraReasons);\n let indexedSessions = 0;\n let incompleteSessions = 0;\n let processedSessions = 0;\n let processedSourceBytes = 0;\n const byKey = new Map(snapshots.map((snapshot) => [snapshot.displayKey, snapshot]));\n for (const ref of refs) {\n const snapshot = byKey.get(ref.file);\n if (!snapshot) {\n reasons.add(\"source_unavailable\");\n continue;\n }\n const size = hostSourceState(snapshot).size;\n if (processedSessions >= maxSessions) {\n reasons.add(\"max_sync_sessions\");\n continue;\n }\n const tier = tiers.get(ref.file) ?? \"cold\";\n const sourceWorkBytes = size * (hydrate && tier === \"cold\" ? 6 : 3);\n if (processedSourceBytes + sourceWorkBytes > maxSourceBytes) {\n reasons.add(\"max_sync_source_bytes\");\n continue;\n }\n processedSessions += 1;\n processedSourceBytes += sourceWorkBytes;\n if (hydrate) {\n if (tier === \"cold\") digests.push(buildHostDigest(snapshot, options));\n const shard = buildHostShard(snapshot, options, \"cold\", entryRange);\n shards.push(shard);\n if (shard.sourceHash) indexedSessions += 1;\n if (shard.sourceHash && !shard.indexCoverage.complete) {\n incompleteSessions += 1;\n for (const reason of shard.indexCoverage.reasons) reasons.add(reason);\n }\n } else if (tier === \"hot\") {\n const shard = buildHostShard(snapshot, options, \"hot\");\n shards.push(shard);\n if (shard.sourceHash) indexedSessions += 1;\n if (shard.sourceHash && !shard.indexCoverage.complete) {\n incompleteSessions += 1;\n for (const reason of shard.indexCoverage.reasons) reasons.add(reason);\n }\n } else {\n const digest = buildHostDigest(snapshot, options);\n digests.push(digest);\n if (digest.sourceHash) indexedSessions += 1;\n if (!digest.indexCoverage.complete) {\n incompleteSessions += 1;\n for (const reason of digest.indexCoverage.reasons) reasons.add(reason);\n }\n }\n }\n const eligibleSessions = refs.length;\n const staleSessions = eligibleSessions - indexedSessions;\n // Extra reasons (adapter coverage caps, list truncation) also demote the\n // result to incomplete: a truncated source is never presented as complete.\n const coverage: MemoryCoverage = {\n complete: reasons.size === 0 && staleSessions === 0 && incompleteSessions === 0,\n indexedSessions,\n eligibleSessions,\n staleSessions,\n incompleteSessions,\n reasons: [...reasons].sort(),\n };\n return { shards, digests, refs, tiers, coverage };\n};\n\n/** Source-resolution strategy shared by filesystem and host-backed calls. */\nexport interface RecallSourcePlan {\n refs: SessionRef[];\n sessionKey: string | null;\n observeAll(branches: MemoryBranches): readonly SourceObservation[] | null;\n stateFor(ref: SessionRef): SourceState | null;\n lineageFor(ref: SessionRef, branches: MemoryBranches): SessionLineage;\n loadIndex(\n options: MemoryIndexOptions,\n hydrate: boolean,\n entryRange?: EntryRange,\n ): TieredIndexBundle;\n}\n\nexport const fileRecallPlan = (refs: SessionRef[], context: MemoryProviderContext): RecallSourcePlan => {\n const liveResolver = liveBranchResolver(context);\n return {\n refs,\n sessionKey: null,\n observeAll: (branches) => observeSources(refs, branches, liveResolver),\n stateFor: (ref) => fingerprintSource(ref.file),\n lineageFor: (ref, branches) =>\n reconstructSessionLineage(ref.file, branches, liveResolver?.(ref.file)),\n loadIndex: (options, hydrate, entryRange) =>\n loadTieredIndex(refs, resolveTierRefs(refs, context), options, hydrate, entryRange),\n };\n};\n\nexport const hostRecallPlan = async (\n source: PortableMemorySource,\n sourceId: string,\n sessionKey: string | null,\n context: MemoryProviderContext,\n signal?: AbortSignal,\n): Promise<RecallSourcePlan> => {\n const loaded = sessionKey !== null\n ? await (async () => {\n const snapshot = await loadHostSnapshot(source, sessionKey, \"recall\", signal, context.fabricScope);\n return snapshot\n ? { snapshots: [snapshot], coverageReasons: [] as string[] }\n : null;\n })()\n : await listHostSnapshots(source, context.config.maxSessions, \"recall\", signal, context.fabricScope);\n if (!loaded) throw new MemorySourceError(\"session_not_found\", `Session not found in source ${sourceId}: ${sessionKey}`);\n const snapshots = loaded.snapshots;\n const refs = snapshots.map(hostRef);\n const byKey = new Map(snapshots.map((snapshot) => [snapshot.displayKey, snapshot]));\n const stateByKey = new Map<string, SourceState>();\n const stateOf = (snapshot: HostSnapshot): SourceState => {\n let state = stateByKey.get(snapshot.displayKey);\n if (!state) {\n state = hostSourceState(snapshot);\n stateByKey.set(snapshot.displayKey, state);\n }\n return state;\n };\n return {\n refs,\n sessionKey,\n observeAll: (branches) =>\n snapshots.map((snapshot) =>\n ({ ...observeHostSource(snapshot.displayKey, snapshot.revision, stateOf(snapshot).sourceHash), liveBranchSignature: hostLineage(snapshot, branches).fingerprint })),\n stateFor: (ref) => {\n const snapshot = byKey.get(ref.file);\n return snapshot ? stateOf(snapshot) : null;\n },\n lineageFor: (ref, branches) => {\n const snapshot = byKey.get(ref.file);\n return snapshot\n ? hostLineage(snapshot, branches)\n : reconstructSessionLineage(ref.file, branches);\n },\n loadIndex: (options, hydrate, entryRange) =>\n loadHostTieredIndex(snapshots, options, hydrate, entryRange, loaded.coverageReasons),\n };\n};\n\nexport interface ExpansionAccess {\n ref: SessionRef;\n state(): SourceState | null;\n lineage(branches: MemoryBranches): SessionLineage;\n observe(branches: MemoryBranches): SourceObservation | null;\n normalizeFull(\n branches: MemoryBranches,\n policy: { indexThinking: boolean; indexToolOutput: boolean },\n lineage?: SessionLineage,\n ): { entries: NormalizedEntry[]; indexCoverage: NormalizationCoverage } | null;\n}\n\nexport const fileExpansionAccess = (\n session: string,\n context: MemoryProviderContext,\n): ExpansionAccess | null => {\n const ref = resolveSessionTarget(context.agentDir, session);\n if (!ref) return null;\n const liveResolver = liveBranchResolver(context);\n return {\n ref,\n state: () => fingerprintSource(ref.file),\n lineage: (branches) => reconstructSessionLineage(ref.file, branches, liveResolver?.(ref.file)),\n observe: (branches) =>\n observeSource(ref.file, branches, branches === \"active\" ? liveResolver?.(ref.file) : undefined),\n normalizeFull: (branches, policy, lineage) => {\n const resolvedLineage = lineage ??\n reconstructSessionLineage(ref.file, branches, liveResolver?.(ref.file));\n const normalized = normalizeSession(ref.file, Number.MAX_SAFE_INTEGER, {\n lineage: resolvedLineage,\n ...policy,\n });\n return normalized.header === null && normalized.entries.length === 0 &&\n normalized.indexCoverage.reasons.includes(\"source_unavailable\")\n ? null\n : { entries: normalized.entries, indexCoverage: normalized.indexCoverage };\n },\n };\n};\n\nexport const hostExpansionAccess = async (\n sourceId: string,\n session: string,\n context: MemoryProviderContext,\n signal?: AbortSignal,\n): Promise<ExpansionAccess> => {\n const source = resolveRegisteredSource(context.sources, sourceId);\n const sessionKey = hostSessionKey(sourceId, session);\n const snapshot = await loadHostSnapshot(source, sessionKey, \"expand\", signal, context.fabricScope);\n if (!snapshot) {\n throw new MemorySourceError(\"session_not_found\", `Session not found in source ${sourceId}: ${sessionKey}`);\n }\n const state = hostSourceState(snapshot);\n const ref = hostRef(snapshot);\n return {\n ref,\n state: () => state,\n lineage: (branches) => hostLineage(snapshot, branches),\n observe: (branches) => ({ ...observeHostSource(snapshot.displayKey, snapshot.revision, state.sourceHash), liveBranchSignature: hostLineage(snapshot, branches).fingerprint }),\n normalizeFull: (branches, policy) => {\n const normalized = normalizeRecords(\n snapshot.records,\n hostIdentity(snapshot.displayKey, snapshot.sessionId, snapshot.metadata.cwd),\n Number.MAX_SAFE_INTEGER,\n { lineage: hostLineage(snapshot, branches), ...policy },\n );\n return {\n entries: normalized.entries,\n indexCoverage: mergedCoverage(normalized.indexCoverage, snapshot.coverageReasons),\n };\n },\n };\n};\n", "// Portable memory sources: a versioned, host-embeddable interface that feeds\n// explicit authorized session snapshots into the existing memory engine. This\n// module stays lightweight: no extension, UI, command, or provider runtime.\nimport type { FabricScope } from \"../protocol.js\";\n\nexport const MEMORY_SOURCE_INTERFACE_VERSION = 1;\n\nexport type MemorySourceRecord = { [key: string]: unknown };\n\nexport interface MemorySourceSessionMetadata {\n sessionId?: string;\n title?: string;\n cwd?: string;\n updatedAt?: number;\n}\n\n/**\n * Adapter-reported coverage of its own retained data. Omit (or omit\n * `complete`) only when the adapter returned everything it currently holds;\n * an adapter that caps enumeration or record loading must report\n * `complete: false` with a stable machine-readable reason so the engine never\n * presents a silently truncated archive as authoritative.\n */\nexport interface MemorySourceCoverage {\n complete: boolean;\n reason?: string;\n}\n\nexport interface MemorySourceSessionDescriptor {\n sessionKey: string;\n sessionId?: string;\n revision: string;\n metadata?: MemorySourceSessionMetadata;\n}\n\nexport interface MemorySourceSnapshot extends MemorySourceSessionDescriptor {\n records: readonly MemorySourceRecord[];\n /** Authoritative live leaf; null means an empty active path, omitted uses persisted semantics. */\n selectedLeafId?: string | null;\n /** Record-loading coverage; omitted means complete. */\n coverage?: MemorySourceCoverage;\n}\n\nexport interface MemorySourceListPage {\n sessions: readonly MemorySourceSessionDescriptor[];\n /** Enumeration coverage; omitted means complete. */\n coverage?: MemorySourceCoverage;\n}\n\nexport type MemorySourceAction = \"list\" | \"recall\" | \"expand\";\n\nexport interface MemorySourceRequestContext {\n signal?: AbortSignal;\n}\n\nexport interface PortableMemorySource {\n readonly interfaceVersion: typeof MEMORY_SOURCE_INTERFACE_VERSION;\n readonly id: string;\n listSessions(\n request: { limit: number } & MemorySourceRequestContext,\n ): Promise<readonly MemorySourceSessionDescriptor[] | MemorySourceListPage>;\n loadSession(\n sessionKey: string,\n request: MemorySourceRequestContext,\n ): Promise<MemorySourceSnapshot | null>;\n /** `scope` is the caller's host-issued scope, so a source can filter before content enters context. */\n authorize?(\n action: MemorySourceAction,\n sessionKey: string | null,\n scope?: Readonly<FabricScope>,\n ): boolean | Promise<boolean>;\n}\n\nexport type MemorySourceErrorCode =\n | \"source_not_found\"\n | \"source_unauthorized\"\n | \"invalid_source_response\"\n | \"session_not_found\"\n | \"aborted\";\n\nexport class MemorySourceError extends Error {\n constructor(\n readonly code: MemorySourceErrorCode,\n message: string,\n ) {\n super(message);\n this.name = \"MemorySourceError\";\n }\n}\n\nconst SOURCE_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;\n\nconst isRecord = (value: unknown): value is MemorySourceRecord =>\n value !== null && typeof value === \"object\" && !Array.isArray(value);\n\nconst assertValidSource = (source: PortableMemorySource): void => {\n if (!isRecord(source) || typeof source !== \"object\") {\n throw new TypeError(\"A portable memory source must be an object\");\n }\n if (source.interfaceVersion !== MEMORY_SOURCE_INTERFACE_VERSION) {\n throw new TypeError(\n `Portable memory source interface version must be ${MEMORY_SOURCE_INTERFACE_VERSION}`,\n );\n }\n if (typeof source.id !== \"string\" || !SOURCE_ID_PATTERN.test(source.id)) {\n throw new TypeError(\n \"Portable memory source id must be 1-128 chars of letters, digits, dot, underscore, or dash\",\n );\n }\n if (typeof source.listSessions !== \"function\" || typeof source.loadSession !== \"function\") {\n throw new TypeError(\"A portable memory source requires listSessions and loadSession\");\n }\n};\n\n/** Validate a portable memory source at registration time; returns it unchanged. */\nexport const defineMemorySource = (source: PortableMemorySource): PortableMemorySource => {\n assertValidSource(source);\n return source;\n};\n\nexport interface MemorySourceRegistry {\n register(source: PortableMemorySource): void;\n get(id: string): PortableMemorySource | undefined;\n ids(): readonly string[];\n}\n\nexport const createMemorySourceRegistry = (): MemorySourceRegistry => {\n const sources = new Map<string, PortableMemorySource>();\n return {\n register(source: PortableMemorySource) {\n assertValidSource(source);\n sources.set(source.id, source);\n },\n get(id: string) {\n return sources.get(id);\n },\n ids() {\n return [...sources.keys()].sort();\n },\n };\n};\n", "import type { FabricInvocationContext } from \"../protocol.js\";\nimport {\n presentRecall,\n RECALL_DEFAULT_PAGE_SIZE,\n RECALL_DEFAULT_SNIPPET_CHARS,\n RECALL_MAX_PAGE_SIZE,\n RECALL_MAX_SNIPPET_CHARS,\n type MemoryRecallCallArgs,\n} from \"./context.js\";\nimport { reconstructSessionLineage } from \"./lineage.js\";\nimport {\n fingerprintSource,\n loadTieredIndex,\n type EntryRange,\n type SearchFilters,\n} from \"./index.js\";\nimport {\n DEFAULT_REGEX_MAX_HAYSTACK_BYTES,\n DEFAULT_REGEX_MAX_HAYSTACK_TERMS,\n DEFAULT_REGEX_MAX_PATTERN_BYTES,\n DEFAULT_REGEX_TIMEOUT_MS,\n searchMemoryIndex,\n type SearchResult,\n} from \"./search.js\";\nimport type { MemoryQueryMatch, MemoryQueryMode } from \"./tokenize.js\";\nimport {\n parseBranches,\n resolveRefs,\n liveBranchResolver,\n resolveIndexOptions,\n addressError,\n recallFailure,\n stalePointerError,\n type MemoryProviderContext,\n} from \"./request-context.js\";\nimport {\n checkAbort,\n fileRecallPlan,\n hostRecallPlan,\n memorySourceFailure,\n resolveRegisteredSource,\n type RecallSourcePlan,\n} from \"./host-source.js\";\nimport { sameSourceObservations, type SourceObservation } from \"./source-observation.js\";\nimport { recallContinuationKey, type RecallRequestCache } from \"./request-cache.js\";\n\nexport async function processMemoryRecall(\n args: Record<string, unknown>,\n invocationContext: Pick<FabricInvocationContext, \"update\" | \"signal\">,\n context: MemoryProviderContext,\n cache: RecallRequestCache,\n): Promise<unknown> {\n const query = typeof args.query === \"string\" ? args.query : undefined;\n const rawQueryMode = args.queryMode;\n if (\n rawQueryMode !== undefined &&\n rawQueryMode !== \"literal\" &&\n rawQueryMode !== \"phrase\" &&\n rawQueryMode !== \"regex\"\n ) {\n throw new Error('memory.recall queryMode must be \"literal\", \"phrase\", or \"regex\"');\n }\n const queryMode: MemoryQueryMode = rawQueryMode === \"phrase\"\n ? \"phrase\"\n : rawQueryMode === \"regex\"\n ? \"regex\"\n : \"literal\";\n const rawQueryMatch = args.queryMatch;\n if (rawQueryMatch !== undefined && rawQueryMatch !== \"all\" && rawQueryMatch !== \"any\") {\n throw new Error('memory.recall queryMatch must be \"all\" or \"any\"');\n }\n if (queryMode !== \"literal\" && rawQueryMatch !== undefined) {\n throw new Error(\"memory.recall queryMatch is only valid with literal queryMode\");\n }\n const queryMatch: MemoryQueryMatch = rawQueryMatch === \"all\" ? \"all\" : \"any\";\n const expectedSourceHash = typeof args.expectedSourceHash === \"string\"\n ? args.expectedSourceHash\n : undefined;\n const expectedLineageFingerprint = typeof args.expectedLineageFingerprint === \"string\"\n ? args.expectedLineageFingerprint\n : undefined;\n const branches = parseBranches(args.branches, \"memory.recall\");\n const scope = typeof args.scope === \"string\" ? args.scope : undefined;\n const role = typeof args.role === \"string\" ? args.role : undefined;\n const tool = typeof args.tool === \"string\" ? args.tool : undefined;\n const ref = typeof args.ref === \"string\" ? args.ref : undefined;\n const provider = typeof args.provider === \"string\" ? args.provider : undefined;\n const action = typeof args.action === \"string\" ? args.action : undefined;\n const rawOutcome = args.outcome;\n if (\n rawOutcome !== undefined &&\n rawOutcome !== \"succeeded\" &&\n rawOutcome !== \"failed\" &&\n rawOutcome !== \"aborted\" &&\n rawOutcome !== \"timed_out\"\n ) {\n throw new Error(\"memory.recall outcome must be succeeded, failed, aborted, or timed_out\");\n }\n const outcome = rawOutcome as SearchFilters[\"outcome\"];\n const since = typeof args.since === \"number\" ? args.since : undefined;\n const until = typeof args.until === \"number\" ? args.until : undefined;\n const offset = typeof args.offset === \"number\" && args.offset >= 0\n ? Math.floor(args.offset)\n : undefined;\n const pageSize =\n typeof args.pageSize === \"number\" && args.pageSize >= 1\n ? Math.min(Math.floor(args.pageSize), RECALL_MAX_PAGE_SIZE)\n : RECALL_DEFAULT_PAGE_SIZE;\n const snippetChars =\n typeof args.snippetChars === \"number\" && args.snippetChars >= 80\n ? Math.min(Math.floor(args.snippetChars), RECALL_MAX_SNIPPET_CHARS)\n : RECALL_DEFAULT_SNIPPET_CHARS;\n\n const sourceId = typeof args.source === \"string\" && args.source.length > 0\n ? args.source\n : undefined;\n let plan: RecallSourcePlan;\n if (sourceId !== undefined) {\n if (scope !== undefined && scope !== `source:${sourceId}` && !scope.startsWith(\"session:\")) {\n throw new Error(\n 'memory.recall scope must name the selected source, one of its sessions, or be omitted',\n );\n }\n try {\n plan = await hostRecallPlan(\n resolveRegisteredSource(context.sources, sourceId),\n sourceId,\n scope?.startsWith(\"session:\") ? scope.slice(\"session:\".length).trim() : null,\n context,\n invocationContext.signal,\n );\n } catch (error) {\n const failure = memorySourceFailure(error);\n if (!failure) throw error;\n return recallFailure(failure);\n }\n } else {\n plan = fileRecallPlan(resolveRefs(scope, context, false), context);\n }\n const refs = plan.refs;\n const options = resolveIndexOptions(\n context.config,\n context.agentDir,\n branches,\n sourceId === undefined ? liveBranchResolver(context) : undefined,\n );\n const hydrate = sourceId !== undefined\n ? plan.sessionKey !== null\n : scope?.trim().startsWith(\"session:\") ?? false;\n if ((expectedSourceHash !== undefined || expectedLineageFingerprint !== undefined) && !hydrate) {\n throw new Error(\"memory.recall integrity expectations require scope session:<id-or-path>\");\n }\n\n const rawRange = args.entryRange;\n const entryRange = rawRange && typeof rawRange === \"object\" && !Array.isArray(rawRange)\n ? rawRange as Record<string, unknown>\n : undefined;\n const first = entryRange?.first;\n const last = entryRange?.last;\n if ((first === undefined) !== (last === undefined)) {\n throw new Error(\"memory.recall entryRange requires both first and last\");\n }\n if ((first !== undefined || last !== undefined) && !hydrate) {\n throw new Error(\"memory.recall entryRange requires scope session:<id-or-path>\");\n }\n if (first !== undefined && (\n typeof first !== \"number\" ||\n typeof last !== \"number\" ||\n !Number.isSafeInteger(first) ||\n !Number.isSafeInteger(last) ||\n first < 0 ||\n last < first\n )) {\n return recallFailure(addressError(\"Entry range requires safe integers with 0 <= first <= last.\"));\n }\n const selectedRange: EntryRange | undefined =\n typeof first === \"number\" && typeof last === \"number\" ? { first, last } : undefined;\n const filters: SearchFilters = {};\n if (role) filters.role = role;\n if (tool) filters.tool = tool;\n if (ref) filters.ref = ref;\n if (provider) filters.provider = provider;\n if (action) filters.action = action;\n if (outcome) filters.outcome = outcome;\n if (since !== undefined) filters.since = since;\n if (until !== undefined) filters.until = until;\n const baseRequestArgs: MemoryRecallCallArgs = {\n ...(sourceId ? { source: sourceId } : {}),\n ...(query === undefined ? {} : { query }),\n queryMode,\n ...(queryMode === \"literal\" ? { queryMatch } : {}),\n ...(expectedSourceHash ? { expectedSourceHash } : {}),\n ...(expectedLineageFingerprint ? { expectedLineageFingerprint } : {}),\n branches,\n scope: sourceId\n ? plan.sessionKey !== null\n ? `session:${plan.refs[0]?.file ?? plan.sessionKey}`\n : `source:${sourceId}`\n : scope ?? \"session\",\n ...(offset === undefined ? {} : { offset }),\n pageSize,\n snippetChars,\n ...(role ? { role } : {}),\n ...(tool ? { tool } : {}),\n ...(ref ? { ref } : {}),\n ...(provider ? { provider } : {}),\n ...(action ? { action } : {}),\n ...(outcome ? { outcome } : {}),\n ...(since !== undefined ? { since } : {}),\n ...(until !== undefined ? { until } : {}),\n ...(selectedRange ? { entryRange: selectedRange } : {}),\n };\n const updateProgress = (searchResult: SearchResult): void => {\n invocationContext.update(\n searchResult.matchMode === \"structural\"\n ? `memory.recall: ${searchResult.matchedCount} structural matches`\n : searchResult.matchMode === \"combined\"\n ? `memory.recall: ${searchResult.matchedCount} filtered matches`\n : query\n ? `memory.recall: ${searchResult.matchedCount} matches`\n : `memory.recall: ${searchResult.matchedCount} recent entries`,\n );\n };\n const observationsBefore: readonly SourceObservation[] | null = await plan.observeAll(branches);\n const cached = offset === undefined\n ? undefined\n : cache.cachedRecallContinuation(\n recallContinuationKey(baseRequestArgs, context.fabricScope?.digest),\n observationsBefore,\n );\n if (cached) {\n const response = presentRecall({\n result: cached.result,\n ...(query === undefined ? {} : { query }),\n queryMode,\n coverage: cached.coverage,\n ...(offset === undefined ? {} : { offset }),\n pageSize,\n snippetChars,\n requestArgs: cached.requestArgs,\n });\n const observationsAfterCachedPage = await plan.observeAll(branches);\n if (\n observationsBefore &&\n observationsAfterCachedPage &&\n sameSourceObservations(observationsBefore, observationsAfterCachedPage)\n ) {\n if (response.next === null) cache.forgetRecallContinuation(cached);\n updateProgress(cached.result);\n return response;\n }\n cache.forgetRecallContinuation(cached);\n }\n\n if (hydrate && refs[0]) {\n const state = plan.stateFor(refs[0]);\n const lineage = plan.lineageFor(refs[0], branches);\n const sourceChanged = expectedSourceHash !== undefined &&\n state?.sourceHash !== expectedSourceHash;\n const lineageChanged = expectedLineageFingerprint !== undefined &&\n lineage.fingerprint !== expectedLineageFingerprint;\n if (state && (sourceChanged || lineageChanged)) {\n return recallFailure(stalePointerError(\n refs[0].file,\n expectedSourceHash,\n state.sourceHash,\n expectedLineageFingerprint,\n lineage.fingerprint,\n ));\n }\n }\n\n const index = plan.loadIndex(options, hydrate, selectedRange);\n const hydratedShard = index.shards[0];\n const hydratedSourceChanged = expectedSourceHash !== undefined &&\n hydratedShard?.sourceHash !== expectedSourceHash;\n const hydratedLineageChanged = expectedLineageFingerprint !== undefined &&\n hydratedShard?.lineageFingerprint !== expectedLineageFingerprint;\n if (hydrate && hydratedShard && (hydratedSourceChanged || hydratedLineageChanged)) {\n return recallFailure(stalePointerError(\n hydratedShard.sessionFile,\n expectedSourceHash,\n hydratedShard.sourceHash,\n expectedLineageFingerprint,\n hydratedShard.lineageFingerprint,\n ));\n }\n if (\n hydrate &&\n selectedRange &&\n index.shards[0] &&\n selectedRange.last >= index.shards[0].totalEntryCount\n ) {\n return recallFailure(addressError(\n `Entry range ends at ${selectedRange.last}, but the session has ${index.shards[0].totalEntryCount} entries.`,\n index.shards[0].totalEntryCount,\n ));\n }\n\n const searchQuery = {\n ...(query === undefined ? {} : { query }),\n queryMode,\n queryMatch,\n filters,\n regexLimits: {\n maxPatternBytes: context.config.regexMaxPatternBytes\n ?? DEFAULT_REGEX_MAX_PATTERN_BYTES,\n maxHaystackTerms: context.config.regexMaxHaystackTerms\n ?? DEFAULT_REGEX_MAX_HAYSTACK_TERMS,\n maxHaystackBytes: context.config.regexMaxHaystackBytes\n ?? DEFAULT_REGEX_MAX_HAYSTACK_BYTES,\n timeoutMs: context.config.regexTimeoutMs ?? DEFAULT_REGEX_TIMEOUT_MS,\n },\n };\n const result = await searchMemoryIndex(index.shards, index.digests, searchQuery);\n const coverage = {\n ...index.coverage,\n complete: index.coverage.complete && result.queryCoverage.complete,\n reasons: [...new Set([...index.coverage.reasons, ...result.queryCoverage.reasons])].sort(),\n ...(result.queryCoverage.error ? { error: result.queryCoverage.error } : {}),\n };\n const soleRef = refs.length === 1 ? refs[0] : undefined;\n const soleShard = soleRef\n ? index.shards.find((candidate) => candidate.sessionFile === soleRef.file)\n : undefined;\n const soleDigest = soleRef\n ? index.digests.find((candidate) => candidate.file === soleRef.file)\n : undefined;\n const continuationBinding = soleRef && (soleShard?.sourceHash || soleDigest?.sourceHash)\n ? {\n file: soleRef.file,\n sourceHash: soleShard?.sourceHash ?? soleDigest!.sourceHash,\n lineageFingerprint: soleShard?.lineageFingerprint ?? soleDigest!.lineageFingerprint,\n }\n : undefined;\n const requestArgs: MemoryRecallCallArgs = {\n ...baseRequestArgs,\n ...((expectedSourceHash ?? continuationBinding?.sourceHash)\n ? { expectedSourceHash: expectedSourceHash ?? continuationBinding!.sourceHash }\n : {}),\n ...((expectedLineageFingerprint ?? continuationBinding?.lineageFingerprint)\n ? {\n expectedLineageFingerprint:\n expectedLineageFingerprint ?? continuationBinding!.lineageFingerprint,\n }\n : {}),\n scope: continuationBinding\n ? `session:${continuationBinding.file}`\n : baseRequestArgs.scope ?? \"session\",\n };\n const response = presentRecall({\n result,\n ...(query === undefined ? {} : { query }),\n queryMode,\n coverage,\n ...(offset === undefined ? {} : { offset }),\n pageSize,\n snippetChars,\n requestArgs,\n });\n const observationsAfter = await plan.observeAll(branches);\n if (\n response.next !== null &&\n observationsBefore &&\n observationsAfter &&\n sameSourceObservations(observationsBefore, observationsAfter)\n ) {\n cache.rememberRecallContinuation({\n key: recallContinuationKey(requestArgs, context.fabricScope?.digest),\n result,\n coverage,\n requestArgs,\n observations: observationsAfter,\n touchedAt: Date.now(),\n });\n }\n updateProgress(result);\n return response;\n}\n", "import { acceptMemoryChunk, type TextRange } from \"./policy.js\";\n\n/** Check the actual outgoing page against the selected normalized source, after\n * all envelope trimming. Source observation/hashing and lineage selection remain\n * host responsibilities; ranges are checked by the compiled gdp-wired kernel. */\nexport const acceptsExpansionPage = (\n records: readonly Record<string, unknown>[],\n source: readonly { index: number; text: string }[],\n entryOffset: number,\n textOffset: number,\n cursor: { position: number; textOffset: number },\n): boolean => {\n if (![entryOffset, textOffset, cursor.position, cursor.textOffset].every((n) => Number.isSafeInteger(n) && n >= 0)) return false;\n let position = entryOffset;\n let offset = textOffset;\n for (const record of records) {\n const entry = source[position];\n const range = record.textRange as TextRange | undefined;\n if (!entry || record.index !== entry.index || typeof record.text !== \"string\" || !range ||\n !acceptMemoryChunk(range, record.text.length, offset, entry.text.length) ||\n record.text !== entry.text.slice(range.start, range.end)) return false;\n if (range.complete) {\n position++;\n offset = 0;\n } else {\n offset = range.end;\n }\n }\n return position === cursor.position && offset === cursor.textOffset &&\n (records.length > 0 || position === source.length);\n};\n", "import { pointerCurrent } from \"../verified/policy.js\";\nimport { acceptsExpansionPage } from \"../verified/memory.js\";\nimport { RECALL_MAX_RESPONSE_CHARS } from \"./context.js\";\nimport {\n expandSessionEntriesChecked,\n type ExpandSessionSelection,\n} from \"./normalize.js\";\nimport {\n fileExpansionAccess,\n hostExpansionAccess,\n memorySourceFailure,\n type ExpansionAccess,\n} from \"./host-source.js\";\nimport {\n EXPAND_DEFAULT_MAX_CHARS,\n EXPAND_MAX_CHARS,\n EXPAND_DEFAULT_MAX_ENTRIES,\n EXPAND_MAX_ENTRIES,\n EXPAND_MAX_CONTEXT,\n EXPAND_MAX_EXACT_SELECTORS,\n} from \"./request-limits.js\";\nimport {\n parseBranches,\n addressError,\n stalePointerError,\n type MemoryProviderContext,\n} from \"./request-context.js\";\nimport { sameSourceObservation } from \"./source-observation.js\";\nimport {\n expansionSelectionKey,\n type CanonicalExpansionSelection,\n type ExpansionRequestCache,\n} from \"./request-cache.js\";\n\nexport async function processMemoryExpand(\n args: Record<string, unknown>,\n context: MemoryProviderContext,\n cache: ExpansionRequestCache,\n signal?: AbortSignal,\n): Promise<unknown> {\n const session = typeof args.session === \"string\" ? args.session : \"\";\n const sourceId = typeof args.source === \"string\" && args.source.length > 0\n ? args.source\n : undefined;\n const expectedSourceHash = typeof args.expectedSourceHash === \"string\"\n ? args.expectedSourceHash\n : undefined;\n const expectedLineageFingerprint = typeof args.expectedLineageFingerprint === \"string\"\n ? args.expectedLineageFingerprint\n : undefined;\n const branches = parseBranches(args.branches, \"memory.expand\");\n const rawIndices = args.indices;\n if (rawIndices !== undefined && !Array.isArray(rawIndices)) {\n throw new Error(\"memory.expand indices must be an array\");\n }\n if (Array.isArray(rawIndices) && !rawIndices.every((index) =>\n typeof index === \"number\" && Number.isSafeInteger(index) && index >= 0)) {\n return { session, error: addressError(\"Every entry index must be a non-negative safe integer.\"), entries: [] };\n }\n const indices = (rawIndices as number[] | undefined) ?? [];\n const entryIds = Array.isArray(args.entryIds)\n ? args.entryIds.filter(\n (entryId): entryId is string => typeof entryId === \"string\" && entryId.length > 0,\n )\n : [];\n const operationAddresses = Array.isArray(args.operationAddresses)\n ? args.operationAddresses.filter(\n (address): address is string => typeof address === \"string\" && address.length > 0,\n )\n : [];\n if (indices.length + entryIds.length + operationAddresses.length > EXPAND_MAX_EXACT_SELECTORS) {\n throw new Error(`memory.expand accepts at most ${EXPAND_MAX_EXACT_SELECTORS} exact selectors per call`);\n }\n const rawRange = args.entryRange;\n const rangeRecord = rawRange && typeof rawRange === \"object\" && !Array.isArray(rawRange)\n ? rawRange as Record<string, unknown>\n : undefined;\n const first = rangeRecord?.first;\n const last = rangeRecord?.last;\n if (!session) throw new Error(\"memory.expand requires a session\");\n if ((first === undefined) !== (last === undefined)) {\n throw new Error(\"memory.expand entryRange requires both first and last\");\n }\n if (first !== undefined && (\n typeof first !== \"number\" ||\n typeof last !== \"number\" ||\n !Number.isSafeInteger(first) ||\n !Number.isSafeInteger(last) ||\n first < 0 ||\n last < first\n )) {\n return { session, error: addressError(\"Entry range requires safe integers with 0 <= first <= last.\"), entries: [] };\n }\n const numeric = (value: unknown, fallback: number, maximum: number): number =>\n typeof value === \"number\" && Number.isSafeInteger(value) && value >= 0\n ? Math.min(value, maximum)\n : fallback;\n const before = numeric(args.before, 0, EXPAND_MAX_CONTEXT);\n const after = numeric(args.after, 0, EXPAND_MAX_CONTEXT);\n const entryOffset = numeric(args.entryOffset, 0, Number.MAX_SAFE_INTEGER);\n const textOffset = numeric(args.textOffset, 0, Number.MAX_SAFE_INTEGER);\n const maxChars = Math.max(256, numeric(args.maxChars, EXPAND_DEFAULT_MAX_CHARS, EXPAND_MAX_CHARS));\n const maxEntries = Math.max(1, numeric(args.maxEntries, EXPAND_DEFAULT_MAX_ENTRIES, EXPAND_MAX_ENTRIES));\n\n let access: ExpansionAccess | null;\n if (sourceId !== undefined) {\n try {\n access = await hostExpansionAccess(sourceId, session, context, signal);\n } catch (error) {\n const failure = memorySourceFailure(error);\n if (!failure) throw error;\n return { session, error: failure, entries: [] };\n }\n } else {\n access = fileExpansionAccess(session, context);\n }\n if (!access) {\n return {\n session,\n error: { code: \"session_not_found\", message: `Session not found: ${session}` },\n entries: [],\n };\n }\n const ref = access.ref;\n const observedSource = access.observe(branches);\n let snapshot = cache.cachedExpansionSnapshot(ref.file, branches, observedSource, context.fabricScope?.digest);\n if (snapshot) {\n const sourceChanged = expectedSourceHash !== undefined &&\n snapshot.sourceHash !== expectedSourceHash;\n const lineageChanged = expectedLineageFingerprint !== undefined &&\n snapshot.lineageFingerprint !== expectedLineageFingerprint;\n if (!pointerCurrent(!sourceChanged, !lineageChanged)) {\n return {\n session: ref.file,\n branches,\n error: stalePointerError(\n ref.file,\n expectedSourceHash,\n snapshot.sourceHash,\n expectedLineageFingerprint,\n snapshot.lineageFingerprint,\n ),\n entries: [],\n };\n }\n }\n\n if (!snapshot) {\n const initialState = access.state();\n if (!initialState) {\n return {\n session: ref.file,\n error: { code: \"source_unavailable\", message: `Session source is unavailable: ${ref.file}` },\n entries: [],\n };\n }\n const initialLineage = access.lineage(branches);\n const sourceChanged = expectedSourceHash !== undefined &&\n initialState.sourceHash !== expectedSourceHash;\n const lineageChanged = expectedLineageFingerprint !== undefined &&\n initialLineage.fingerprint !== expectedLineageFingerprint;\n if (!pointerCurrent(!sourceChanged, !lineageChanged)) {\n return {\n session: ref.file,\n branches,\n error: stalePointerError(\n ref.file,\n expectedSourceHash,\n initialState.sourceHash,\n expectedLineageFingerprint,\n initialLineage.fingerprint,\n ),\n entries: [],\n };\n }\n\n const normalizedFull = access.normalizeFull(\n branches,\n { indexThinking: true, indexToolOutput: true },\n initialLineage,\n );\n if (!normalizedFull) {\n return {\n session: ref.file,\n error: stalePointerError(\n ref.file,\n expectedSourceHash ?? initialState.sourceHash,\n initialState.sourceHash,\n expectedLineageFingerprint ?? initialLineage.fingerprint,\n initialLineage.fingerprint,\n ),\n entries: [],\n };\n }\n const normalized = normalizedFull.entries;\n const finalState = access.state();\n const finalLineage = access.lineage(branches);\n const finalObservation = access.observe(branches);\n if (\n !finalState ||\n !finalObservation ||\n !pointerCurrent(finalState.sourceHash === initialState.sourceHash, finalLineage.fingerprint === initialLineage.fingerprint)\n ) {\n return {\n session: ref.file,\n error: stalePointerError(\n ref.file,\n expectedSourceHash ?? initialState.sourceHash,\n finalState?.sourceHash ?? \"\",\n expectedLineageFingerprint ?? initialLineage.fingerprint,\n finalLineage.fingerprint,\n ),\n entries: [],\n };\n }\n snapshot = {\n file: ref.file,\n branches,\n ...(context.fabricScope ? { scopeDigest: context.fabricScope.digest } : {}),\n sourceHash: finalState.sourceHash,\n lineageFingerprint: finalLineage.fingerprint,\n observation: finalObservation,\n entries: normalized,\n selections: new Map(),\n touchedAt: Date.now(),\n };\n }\n\n const entryCount = snapshot.entries.length;\n const outOfBounds = indices.find((index) => index >= entryCount);\n if (outOfBounds !== undefined) {\n return {\n session: ref.file,\n error: addressError(`Entry index ${outOfBounds} is outside 0..${Math.max(0, entryCount - 1)}.`, entryCount),\n entries: [],\n };\n }\n if (typeof last === \"number\" && last >= entryCount) {\n return {\n session: ref.file,\n error: addressError(`Entry range ends at ${last}, but the session has ${entryCount} entries.`, entryCount),\n entries: [],\n };\n }\n if (\n indices.length === 0 &&\n entryIds.length === 0 &&\n operationAddresses.length === 0 &&\n (first === undefined || last === undefined)\n ) {\n if (before > 0 || after > 0) {\n throw new Error(\"memory.expand before/after requires one selected anchor\");\n }\n cache.forgetExpansionSnapshot(snapshot);\n return {\n session: ref.file,\n sourceHash: snapshot.sourceHash,\n branches,\n lineageFingerprint: snapshot.lineageFingerprint,\n entryCount,\n entries: [],\n next: null,\n };\n }\n\n const requestedSelection: ExpandSessionSelection = {};\n if (indices.length > 0) requestedSelection.indices = indices;\n if (entryIds.length > 0) requestedSelection.entryIds = entryIds;\n if (operationAddresses.length > 0) requestedSelection.operationAddresses = operationAddresses;\n if (typeof first === \"number\" && typeof last === \"number\") {\n requestedSelection.entryRange = { first, last };\n }\n const requestedWithContext: CanonicalExpansionSelection = {\n ...requestedSelection,\n ...(before > 0 ? { before } : {}),\n ...(after > 0 ? { after } : {}),\n };\n const requestedKey = expansionSelectionKey(requestedWithContext);\n let resolved = snapshot.selections.get(requestedKey);\n if (!resolved) {\n let expansion = expandSessionEntriesChecked(snapshot.entries, requestedSelection);\n if (\"error\" in expansion) {\n return {\n session: ref.file,\n sourceHash: snapshot.sourceHash,\n branches,\n lineageFingerprint: snapshot.lineageFingerprint,\n error: expansion.error,\n entries: [],\n };\n }\n\n let anchorIndex: number | null = null;\n let canonical: CanonicalExpansionSelection;\n if (before > 0 || after > 0) {\n if (expansion.expanded.length !== 1) {\n throw new Error(\"memory.expand before/after requires exactly one resolved anchor\");\n }\n anchorIndex = expansion.expanded[0]!.index;\n const contextRange = {\n first: Math.max(0, anchorIndex - before),\n last: Math.min(Math.max(0, entryCount - 1), anchorIndex + after),\n };\n canonical = requestedWithContext;\n expansion = expandSessionEntriesChecked(snapshot.entries, { entryRange: contextRange });\n if (\"error\" in expansion) {\n return {\n session: ref.file,\n sourceHash: snapshot.sourceHash,\n branches,\n lineageFingerprint: snapshot.lineageFingerprint,\n error: expansion.error,\n entries: [],\n };\n }\n } else if (requestedSelection.entryRange) {\n canonical = { entryRange: requestedSelection.entryRange };\n } else {\n canonical = { indices: expansion.expanded.map((entry) => entry.index) };\n }\n resolved = { entries: expansion.expanded, canonical, anchorIndex };\n cache.rememberExpansionSelection(\n snapshot,\n [requestedKey, expansionSelectionKey(canonical)],\n resolved,\n );\n }\n\n const selected = resolved.entries;\n const canonicalSelection = resolved.canonical;\n const anchorIndex = resolved.anchorIndex;\n const finalState = snapshot;\n const finalLineage = { fingerprint: snapshot.lineageFingerprint };\n if (entryOffset > selected.length) {\n return {\n session: ref.file,\n error: addressError(`Entry offset ${entryOffset} is outside 0..${selected.length}.`, selected.length),\n entries: [],\n };\n }\n if (entryOffset < selected.length && textOffset > selected[entryOffset]!.text.length) {\n return {\n session: ref.file,\n error: {\n code: \"text_offset_out_of_bounds\",\n message: `Text offset ${textOffset} exceeds entry #${selected[entryOffset]!.index} length ${selected[entryOffset]!.text.length}.`,\n textLength: selected[entryOffset]!.text.length,\n },\n entries: [],\n };\n }\n\n const bounded = (value: string | null, maximum = 512): string | null =>\n value === null || value.length <= maximum\n ? value\n : `${value.slice(0, Math.max(1, maximum - 1))}\u2026`;\n const compactStructure = (value: unknown): unknown => {\n if (value === undefined) return undefined;\n const serialized = JSON.stringify(value);\n return serialized.length <= 2_000 ? value : undefined;\n };\n const output: Array<Record<string, unknown>> = [];\n const cursors: Array<{ position: number; textOffset: number }> = [];\n let position = entryOffset;\n let currentTextOffset = textOffset;\n let remainingChars = maxChars;\n while (position < selected.length && output.length < maxEntries && remainingChars > 0) {\n const entry = selected[position]!;\n let end = Math.min(entry.text.length, currentTextOffset + remainingChars);\n if (\n end < entry.text.length &&\n end > currentTextOffset &&\n entry.text.charCodeAt(end) >= 0xdc00 &&\n entry.text.charCodeAt(end) <= 0xdfff\n ) {\n end -= 1;\n }\n if (end === currentTextOffset && currentTextOffset < entry.text.length) {\n end = Math.min(entry.text.length, currentTextOffset + 2);\n }\n const chunk = entry.text.slice(currentTextOffset, end);\n const textComplete = end >= entry.text.length;\n const operation = compactStructure(entry.operation);\n const branchFact = compactStructure(entry.branchFact);\n output.push({\n index: entry.index,\n entryId: bounded(entry.entryId),\n parentId: bounded(entry.parentId),\n type: bounded(entry.type),\n role: bounded(entry.role),\n timestamp: entry.timestamp,\n isError: entry.isError,\n ...(anchorIndex !== null ? { anchor: entry.index === anchorIndex } : {}),\n text: chunk,\n textRange: {\n start: currentTextOffset,\n end,\n total: entry.text.length,\n complete: textComplete,\n },\n ...(entry.parentEntryId !== undefined ? { parentEntryId: bounded(entry.parentEntryId) } : {}),\n ...(entry.operationAddress ? { operationAddress: bounded(entry.operationAddress) } : {}),\n ...(entry.toolName ? { tool: bounded(entry.toolName) } : {}),\n ...(entry.ref ? { ref: bounded(entry.ref) } : {}),\n ...(entry.provider ? { provider: bounded(entry.provider) } : {}),\n ...(entry.action ? { action: bounded(entry.action) } : {}),\n ...(entry.outcome ? { outcome: entry.outcome } : {}),\n ...(entry.filesTouched\n ? { filesTouched: entry.filesTouched.slice(0, 20).map((file) => bounded(file, 1_024)) }\n : {}),\n ...(operation !== undefined ? { operation } : {}),\n ...(branchFact !== undefined ? { branchFact } : {}),\n ...((entry.operation !== undefined && operation === undefined) ||\n (entry.branchFact !== undefined && branchFact === undefined)\n ? { structuredTruncated: true }\n : {}),\n ...(entry.factAddress ? { factAddress: bounded(entry.factAddress) } : {}),\n ...(entry.carrierEntryId ? { carrierEntryId: bounded(entry.carrierEntryId) } : {}),\n ...(entry.carrierParentId !== undefined ? { carrierParentId: bounded(entry.carrierParentId) } : {}),\n ...(entry.carrierFromId !== undefined ? { carrierFromId: bounded(entry.carrierFromId) } : {}),\n });\n remainingChars -= chunk.length;\n if (!textComplete) {\n currentTextOffset = end;\n cursors.push({ position, textOffset: currentTextOffset });\n break;\n }\n position += 1;\n currentTextOffset = 0;\n cursors.push({ position, textOffset: 0 });\n }\n\n const responseAt = (\n records: Array<Record<string, unknown>>,\n cursor: { position: number; textOffset: number },\n ): Record<string, unknown> => {\n const hasNext = cursor.position < selected.length;\n const nextArgs = hasNext\n ? {\n ...(sourceId ? { source: sourceId } : {}),\n session: ref.file,\n expectedSourceHash: finalState.sourceHash,\n expectedLineageFingerprint: finalLineage.fingerprint,\n branches,\n ...canonicalSelection,\n entryOffset: cursor.position,\n ...(cursor.textOffset > 0 ? { textOffset: cursor.textOffset } : {}),\n maxChars,\n maxEntries,\n }\n : null;\n return {\n session: ref.file,\n sourceHash: finalState.sourceHash,\n branches,\n lineageFingerprint: finalLineage.fingerprint,\n entryCount,\n entries: records,\n next: nextArgs ? { ref: \"memory.expand\", args: nextArgs } : null,\n };\n };\n\n let cursor = { position, textOffset: currentTextOffset };\n let response = responseAt(output, cursor);\n while (output.length > 1 && JSON.stringify(response).length > RECALL_MAX_RESPONSE_CHARS) {\n output.pop();\n cursors.pop();\n cursor = cursors.at(-1) ?? { position: entryOffset, textOffset };\n response = responseAt(output, cursor);\n }\n if (output.length === 1 && JSON.stringify(response).length > RECALL_MAX_RESPONSE_CHARS) {\n const record = output[0]!;\n const range = record.textRange as { start: number; end: number; total: number; complete: boolean };\n const chunk = record.text as string;\n const excess = JSON.stringify(response).length - RECALL_MAX_RESPONSE_CHARS;\n let keep = Math.max(1, chunk.length - excess - 256);\n if (\n keep < chunk.length &&\n keep > 0 &&\n chunk.charCodeAt(keep) >= 0xdc00 &&\n chunk.charCodeAt(keep) <= 0xdfff\n ) {\n keep -= 1;\n }\n if (keep > 0 && keep < chunk.length) {\n record.text = chunk.slice(0, keep);\n range.end = range.start + keep;\n range.complete = false;\n cursor = { position: entryOffset, textOffset: range.end };\n response = responseAt(output, cursor);\n }\n if (JSON.stringify(response).length > RECALL_MAX_RESPONSE_CHARS) {\n delete record.operation;\n delete record.branchFact;\n if (Array.isArray(record.filesTouched)) {\n record.filesTouched = record.filesTouched.slice(0, 4).map((file) => bounded(String(file), 256));\n }\n record.structuredTruncated = true;\n response = responseAt(output, cursor);\n }\n if (JSON.stringify(response).length > RECALL_MAX_RESPONSE_CHARS) {\n const current = String(record.text);\n const firstCodePointChars = (current.codePointAt(0) ?? 0) > 0xffff ? 2 : 1;\n const minimalText = current.slice(0, Math.min(current.length, firstCodePointChars));\n const minimalRange = record.textRange as { start: number; end: number; total: number; complete: boolean };\n minimalRange.end = minimalRange.start + minimalText.length;\n minimalRange.complete = minimalRange.end >= minimalRange.total;\n output[0] = {\n index: record.index,\n entryId: record.entryId,\n parentId: record.parentId,\n type: record.type,\n role: record.role,\n timestamp: record.timestamp,\n isError: record.isError,\n ...(record.anchor !== undefined ? { anchor: record.anchor } : {}),\n text: minimalText,\n textRange: minimalRange,\n structuredTruncated: true,\n };\n cursor = minimalRange.complete\n ? { position: entryOffset + 1, textOffset: 0 }\n : { position: entryOffset, textOffset: minimalRange.end };\n response = responseAt(output, cursor);\n }\n }\n\n if (!acceptsExpansionPage(output, selected, entryOffset, textOffset, cursor)) {\n cache.forgetExpansionSnapshot(snapshot);\n return { session: ref.file, entries: [], error: { code: \"invalid_expansion\", message: \"Expansion failed source-bound chunk verification\" } };\n }\n\n const endingObservation = access.observe(branches);\n if (!endingObservation || !sameSourceObservation(snapshot.observation, endingObservation)) {\n cache.forgetExpansionSnapshot(snapshot);\n const actualState = access.state();\n const actualLineage = access.lineage(branches);\n if (\n !actualState ||\n !endingObservation ||\n !pointerCurrent(actualState.sourceHash === snapshot.sourceHash, actualLineage.fingerprint === snapshot.lineageFingerprint)\n ) {\n return {\n session: ref.file,\n error: stalePointerError(\n ref.file,\n expectedSourceHash ?? snapshot.sourceHash,\n actualState?.sourceHash ?? \"\",\n expectedLineageFingerprint ?? snapshot.lineageFingerprint,\n actualLineage.fingerprint,\n ),\n entries: [],\n };\n }\n snapshot.observation = endingObservation;\n }\n if (response.next === null) {\n cache.forgetExpansionSnapshot(snapshot);\n } else {\n snapshot.touchedAt = Date.now();\n cache.rememberExpansionSnapshot(snapshot);\n }\n return response;\n}\n", "import { loadTieredIndex } from \"./index.js\";\nimport { SESSIONS_MAX } from \"./request-limits.js\";\nimport {\n parseBranches,\n resolveRefs,\n resolveIndexOptions,\n liveBranchResolver,\n resolveTierRefs,\n type MemoryProviderContext,\n} from \"./request-context.js\";\nimport {\n listHostSnapshots,\n loadHostTieredIndex,\n memorySourceFailure,\n resolveRegisteredSource,\n} from \"./host-source.js\";\n\nexport async function processMemorySessions(\n args: Record<string, unknown>,\n context: MemoryProviderContext,\n signal?: AbortSignal,\n): Promise<unknown> {\n const sourceId = typeof args.source === \"string\" && args.source.length > 0\n ? args.source\n : undefined;\n const scope = typeof args.scope === \"string\" ? args.scope : undefined;\n const branches = parseBranches(args.branches, \"memory.sessions\");\n const limit =\n typeof args.limit === \"number\" && Number.isSafeInteger(args.limit) && args.limit >= 1\n ? Math.min(args.limit, SESSIONS_MAX)\n : SESSIONS_MAX;\n\n if (sourceId !== undefined) {\n try {\n const source = resolveRegisteredSource(context.sources, sourceId);\n const { snapshots, coverageReasons } = await listHostSnapshots(source, limit, \"list\", signal, context.fabricScope);\n const options = resolveIndexOptions(context.config, context.agentDir, branches);\n const index = loadHostTieredIndex(snapshots, options, false, undefined, coverageReasons);\n const shards = new Map(index.shards.map((shard) => [shard.sessionFile, shard]));\n const digests = new Map(index.digests.map((digest) => [digest.file, digest]));\n const sessions = snapshots.map((snapshot) => {\n const tier = index.tiers.get(snapshot.displayKey) ?? \"cold\";\n const shard = shards.get(snapshot.displayKey);\n const digest = digests.get(snapshot.displayKey);\n return {\n id: shard?.sessionId ?? digest?.sessionId ?? snapshot.sessionId,\n file: snapshot.displayKey,\n cwd: digest?.cwd ?? snapshot.metadata.cwd ?? \"\",\n mtime: snapshot.metadata.updatedAt ?? 0,\n entryCount: shard?.entries.length ?? digest?.entryCount ?? 0,\n tier,\n branches,\n lineageFingerprint: shard?.lineageFingerprint ?? digest?.lineageFingerprint ?? null,\n };\n });\n return {\n scope: `source:${sourceId}`,\n branches,\n sessions,\n ...(index.coverage.complete ? {} : { coverage: index.coverage }),\n };\n } catch (error) {\n const failure = memorySourceFailure(error);\n if (!failure) throw error;\n return {\n scope: `source:${sourceId}`,\n branches,\n sessions: [],\n error: failure,\n };\n }\n }\n\n const refs = resolveRefs(scope, context, true).slice(0, limit);\n const options = resolveIndexOptions(\n context.config,\n context.agentDir,\n branches,\n liveBranchResolver(context),\n );\n const index = loadTieredIndex(refs, resolveTierRefs(refs, context), options);\n const shards = new Map(index.shards.map((shard) => [shard.sessionFile, shard]));\n const digests = new Map(index.digests.map((digest) => [digest.file, digest]));\n const sessions = refs.map((ref) => {\n const tier = index.tiers.get(ref.file) ?? \"cold\";\n const shard = shards.get(ref.file);\n const digest = digests.get(ref.file);\n return {\n id: shard?.sessionId ?? digest?.sessionId ?? ref.id,\n file: ref.file,\n cwd: digest?.cwd ?? ref.cwd,\n mtime: ref.mtime,\n entryCount: shard?.entries.length ?? digest?.entryCount ?? 0,\n tier,\n branches,\n lineageFingerprint: shard?.lineageFingerprint ?? digest?.lineageFingerprint ?? null,\n };\n });\n return { scope: scope ?? \"session\", branches, sessions };\n}\n", "import type {\n FabricActionDescriptor,\n FabricInvocationContext,\n FabricProvider,\n FabricProviderListRequest,\n} from \"../protocol.js\";\nimport { AmbiguousSessionError } from \"../memory/discovery.js\";\nimport {\n RECALL_DEFAULT_PAGE_SIZE,\n RECALL_DEFAULT_SNIPPET_CHARS,\n RECALL_MAX_PAGE_SIZE,\n RECALL_MAX_SNIPPET_CHARS,\n} from \"../memory/context.js\";\nimport {\n EXPAND_DEFAULT_MAX_CHARS,\n EXPAND_MAX_CHARS,\n EXPAND_DEFAULT_MAX_ENTRIES,\n EXPAND_MAX_ENTRIES,\n EXPAND_MAX_CONTEXT,\n EXPAND_MAX_EXACT_SELECTORS,\n} from \"../memory/request-limits.js\";\nimport { recallFailure, type MemoryProviderContext } from \"../memory/request-context.js\";\nimport { MemoryRequestCache } from \"../memory/request-cache.js\";\nimport { processMemoryRecall } from \"../memory/recall-service.js\";\nimport { processMemoryExpand } from \"../memory/expand-service.js\";\nimport { processMemorySessions } from \"../memory/sessions-service.js\";\nimport { actionArgNormalizer, type ArgNormalizationSpec } from \"./arg-normalization.js\";\n\nconst errorOutputSchema = {\n type: \"object\",\n properties: {\n code: { type: \"string\" },\n message: { type: \"string\" },\n },\n required: [\"code\", \"message\"],\n};\n\nconst coverageOutputSchema = {\n type: \"object\",\n properties: {\n complete: { type: \"boolean\" },\n indexedSessions: { type: \"number\" },\n eligibleSessions: { type: \"number\" },\n staleSessions: { type: \"number\" },\n incompleteSessions: { type: \"number\" },\n reasons: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"Stable machine-readable incompleteness codes; empty when complete is true.\",\n },\n error: errorOutputSchema,\n },\n required: [\n \"complete\",\n \"indexedSessions\",\n \"eligibleSessions\",\n \"staleSessions\",\n \"incompleteSessions\",\n \"reasons\",\n ],\n};\n\nconst callOutputSchema = (ref: \"memory.recall\" | \"memory.expand\") => ({\n type: \"object\",\n properties: {\n ref: { const: ref },\n args: { type: \"object\" },\n },\n required: [\"ref\", \"args\"],\n});\n\nconst recallEntryOutputSchema = {\n type: \"object\",\n properties: {\n kind: { const: \"entry\" },\n sessionId: { type: \"string\" },\n tier: { type: \"string\", enum: [\"hot\", \"cold\"] },\n index: { type: \"number\" },\n entryId: { type: [\"string\", \"null\"] },\n parentId: { type: [\"string\", \"null\"] },\n operationAddress: { type: [\"string\", \"null\"] },\n type: { type: \"string\" },\n role: { type: [\"string\", \"null\"] },\n tool: { type: [\"string\", \"null\"] },\n ref: { type: [\"string\", \"null\"] },\n provider: { type: [\"string\", \"null\"] },\n action: { type: [\"string\", \"null\"] },\n timestamp: { type: [\"number\", \"null\"] },\n isError: { type: \"boolean\" },\n outcome: { type: \"string\", enum: [\"succeeded\", \"failed\", \"aborted\", \"timed_out\"] },\n score: { type: \"number\" },\n snippet: { type: \"string\" },\n truncated: { type: \"boolean\" },\n follow: callOutputSchema(\"memory.expand\"),\n },\n required: [\n \"kind\",\n \"sessionId\",\n \"tier\",\n \"index\",\n \"entryId\",\n \"parentId\",\n \"operationAddress\",\n \"type\",\n \"role\",\n \"tool\",\n \"ref\",\n \"provider\",\n \"action\",\n \"timestamp\",\n \"isError\",\n \"score\",\n \"snippet\",\n \"truncated\",\n \"follow\",\n ],\n};\n\nconst recallSessionOutputSchema = {\n type: \"object\",\n properties: {\n kind: { const: \"session\" },\n sessionId: { type: \"string\" },\n tier: { const: \"cold\" },\n cwd: { type: \"string\" },\n lastTimestamp: { type: [\"number\", \"null\"] },\n score: { type: \"number\" },\n matchedTerms: { type: \"number\" },\n matchedStructuralEntries: { type: \"number\" },\n follow: callOutputSchema(\"memory.recall\"),\n },\n required: [\n \"kind\",\n \"sessionId\",\n \"tier\",\n \"cwd\",\n \"lastTimestamp\",\n \"score\",\n \"matchedTerms\",\n \"matchedStructuralEntries\",\n \"follow\",\n ],\n};\n\nconst recallOutputSchema: Record<string, unknown> = {\n type: \"object\",\n description: \"Bounded ranked memory hits with uniform follow and pagination calls.\",\n properties: {\n total: { type: \"number\" },\n hits: {\n type: \"array\",\n description: \"Call tools.call(hit.follow) to expand an entry or resolve a cold session.\",\n items: { oneOf: [recallEntryOutputSchema, recallSessionOutputSchema] },\n },\n next: {\n oneOf: [callOutputSchema(\"memory.recall\"), { type: \"null\" }],\n description: \"When non-null, call tools.call(next).\",\n },\n coverage: coverageOutputSchema,\n error: errorOutputSchema,\n },\n required: [\"total\", \"hits\", \"next\", \"coverage\"],\n};\n\nconst expandOutputSchema: Record<string, unknown> = {\n type: \"object\",\n description: \"Integrity-bound session entries returned as lossless bounded text chunks.\",\n properties: {\n session: { type: \"string\" },\n sourceHash: { type: \"string\" },\n branches: { type: \"string\", enum: [\"active\", \"all\"] },\n lineageFingerprint: { type: \"string\" },\n entryCount: { type: \"number\" },\n entries: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n index: { type: \"number\" },\n entryId: { type: [\"string\", \"null\"] },\n parentId: { type: [\"string\", \"null\"] },\n type: { type: [\"string\", \"null\"] },\n role: { type: [\"string\", \"null\"] },\n timestamp: { type: [\"number\", \"null\"] },\n isError: { type: \"boolean\" },\n text: { type: \"string\" },\n textRange: {\n type: \"object\",\n properties: {\n start: { type: \"number\" },\n end: { type: \"number\" },\n total: { type: \"number\" },\n complete: { type: \"boolean\" },\n },\n required: [\"start\", \"end\", \"total\", \"complete\"],\n },\n anchor: { type: \"boolean\" },\n parentEntryId: { type: [\"string\", \"null\"] },\n operationAddress: { type: [\"string\", \"null\"] },\n tool: { type: [\"string\", \"null\"] },\n ref: { type: [\"string\", \"null\"] },\n provider: { type: [\"string\", \"null\"] },\n action: { type: [\"string\", \"null\"] },\n outcome: { type: \"string\", enum: [\"succeeded\", \"failed\", \"aborted\", \"timed_out\"] },\n filesTouched: { type: \"array\", items: { type: [\"string\", \"null\"] } },\n operation: { type: \"object\" },\n branchFact: { type: \"object\" },\n structuredTruncated: { type: \"boolean\" },\n factAddress: { type: [\"string\", \"null\"] },\n carrierEntryId: { type: [\"string\", \"null\"] },\n carrierParentId: { type: [\"string\", \"null\"] },\n carrierFromId: { type: [\"string\", \"null\"] },\n },\n required: [\"index\", \"entryId\", \"parentId\", \"type\", \"role\", \"timestamp\", \"isError\", \"text\", \"textRange\"],\n },\n },\n next: {\n oneOf: [callOutputSchema(\"memory.expand\"), { type: \"null\" }],\n description: \"When non-null, call tools.call(next).\",\n },\n error: errorOutputSchema,\n },\n required: [\"entries\"],\n};\n\nconst sessionsOutputSchema: Record<string, unknown> = {\n type: \"object\",\n properties: {\n scope: { type: \"string\" },\n branches: { type: \"string\", enum: [\"active\", \"all\"] },\n sessions: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n id: { type: \"string\" },\n file: { type: \"string\" },\n cwd: { type: \"string\" },\n mtime: { type: \"number\" },\n entryCount: { type: \"number\" },\n tier: { type: \"string\", enum: [\"hot\", \"cold\"] },\n branches: { type: \"string\", enum: [\"active\", \"all\"] },\n lineageFingerprint: { type: [\"string\", \"null\"] },\n },\n required: [\n \"id\",\n \"file\",\n \"cwd\",\n \"mtime\",\n \"entryCount\",\n \"tier\",\n \"branches\",\n \"lineageFingerprint\",\n ],\n },\n },\n error: errorOutputSchema,\n },\n};\n\nconst SOURCE_ARG_SCHEMA = {\n type: \"string\",\n minLength: 1,\n description:\n \"Registered portable memory source id. When set, the call resolves against that source only \u2014 filesystem scopes are never consulted and there is no filesystem fallback.\",\n} as const;\n\nexport const memoryActionDescriptors: FabricActionDescriptor[] = [\n {\n name: \"recall\",\n description:\n \"Search session memory as bounded ranked snippets. Literal queries rank any matching term by default; queryMatch all narrows to co-located terms. Call tools.call(hit.follow) for either an exact entry or a cold-session candidate, and tools.call(next) to continue.\",\n inputSchema: {\n type: \"object\",\n properties: {\n source: SOURCE_ARG_SCHEMA,\n query: { type: \"string\", maxLength: 4096 },\n queryMode: {\n type: \"string\",\n enum: [\"literal\", \"phrase\", \"regex\"],\n default: \"literal\",\n description: \"Canonical tokens (default), one case-insensitive exact phrase, or explicitly bounded regex.\",\n },\n queryMatch: {\n type: \"string\",\n enum: [\"all\", \"any\"],\n default: \"any\",\n description: \"For literal mode, accept any term (default) or require all terms in one hot entry.\",\n },\n expectedSourceHash: {\n type: \"string\",\n description: \"SHA-256 from a prior pointer; stale sources are refused.\",\n },\n expectedLineageFingerprint: {\n type: \"string\",\n description: \"Active-lineage fingerprint from a prior pointer; changed leaves are refused.\",\n },\n branches: {\n type: \"string\",\n enum: [\"active\", \"all\"],\n description: \"Search the active parent-linked path (default) or every branch.\",\n },\n scope: {\n type: \"string\",\n description:\n \"session | project | global | session:<id-or-path>. Defaults to session.\",\n },\n offset: {\n type: \"number\",\n minimum: 0,\n description: \"Exact ranked-hit offset, normally copied from next.args.\",\n },\n pageSize: { type: \"number\", minimum: 1, maximum: RECALL_MAX_PAGE_SIZE, default: RECALL_DEFAULT_PAGE_SIZE },\n snippetChars: {\n type: \"number\",\n minimum: 80,\n maximum: RECALL_MAX_SNIPPET_CHARS,\n default: RECALL_DEFAULT_SNIPPET_CHARS,\n description: \"Maximum indexed-text characters shown per hit; full text remains in memory.expand.\",\n },\n role: {\n type: \"string\",\n enum: [\n \"assistant\",\n \"bashExecution\",\n \"branchCustomMessage\",\n \"branchSummary\",\n \"branchUser\",\n \"compaction\",\n \"compactionSummary\",\n \"custom\",\n \"fabricOperation\",\n \"fabricPhase\",\n \"fabricRun\",\n \"toolResult\",\n \"user\",\n ],\n description:\n \"Exact normalized entry role to filter by: the closed set the session normalizer can produce.\",\n },\n tool: { type: \"string\" },\n ref: {\n type: \"string\",\n minLength: 1,\n description: \"Exact persisted Fabric action ref, such as pi.grep. This is structural selection, not lexical expansion.\",\n },\n provider: {\n type: \"string\",\n minLength: 1,\n description: \"Exact persisted Fabric provider identity.\",\n },\n action: {\n type: \"string\",\n minLength: 1,\n description: \"Exact persisted Fabric action name.\",\n },\n outcome: {\n type: \"string\",\n enum: [\"succeeded\", \"failed\", \"aborted\", \"timed_out\"],\n description: \"Exact persisted Fabric execution outcome.\",\n },\n since: { type: \"number\" },\n until: { type: \"number\" },\n entryRange: {\n type: \"object\",\n description:\n \"Inclusive normalized-entry range for an explicit session:<id> resolution.\",\n properties: {\n first: { type: \"number\", minimum: 0 },\n last: { type: \"number\", minimum: 0 },\n },\n required: [\"first\", \"last\"],\n additionalProperties: false,\n },\n },\n additionalProperties: false,\n },\n outputSchema: recallOutputSchema,\n risk: \"read\",\n namespace: \"memory\",\n },\n {\n name: \"expand\",\n description:\n \"Read exact normalized session entries and nearby context as bounded lossless chunks. Call tools.call(next) to continue, or use guest-side memory.walk(args, visitor) to traverse complete reassembled entries.\",\n inputSchema: {\n type: \"object\",\n properties: {\n source: SOURCE_ARG_SCHEMA,\n session: { type: \"string\", description: \"Exact session file path, unambiguous id, or source session key.\" },\n expectedSourceHash: {\n type: \"string\",\n description: \"SHA-256 from a prior pointer; stale sources are refused.\",\n },\n expectedLineageFingerprint: {\n type: \"string\",\n description: \"Active-lineage fingerprint from a prior pointer; changed leaves are refused.\",\n },\n branches: {\n type: \"string\",\n enum: [\"active\", \"all\"],\n description: \"Expand on the active parent-linked path (default) or across every branch.\",\n },\n indices: { type: \"array\", maxItems: EXPAND_MAX_EXACT_SELECTORS, items: { type: \"number\", minimum: 0 } },\n entryIds: { type: \"array\", maxItems: EXPAND_MAX_EXACT_SELECTORS, items: { type: \"string\", maxLength: 512 } },\n operationAddresses: { type: \"array\", maxItems: EXPAND_MAX_EXACT_SELECTORS, items: { type: \"string\", maxLength: 512 } },\n entryRange: {\n type: \"object\",\n properties: {\n first: { type: \"number\", minimum: 0 },\n last: { type: \"number\", minimum: 0 },\n },\n required: [\"first\", \"last\"],\n additionalProperties: false,\n },\n before: {\n type: \"number\",\n minimum: 0,\n maximum: EXPAND_MAX_CONTEXT,\n default: 0,\n description: \"Entries before one exact selected anchor.\",\n },\n after: {\n type: \"number\",\n minimum: 0,\n maximum: EXPAND_MAX_CONTEXT,\n default: 0,\n description: \"Entries after one exact selected anchor.\",\n },\n entryOffset: {\n type: \"number\",\n minimum: 0,\n description: \"Continuation offset within the resolved selection; copy from next.args.\",\n },\n textOffset: {\n type: \"number\",\n minimum: 0,\n description: \"Continuation offset within the first returned entry; copy from next.args.\",\n },\n maxChars: {\n type: \"number\",\n minimum: 256,\n maximum: EXPAND_MAX_CHARS,\n default: EXPAND_DEFAULT_MAX_CHARS,\n description: \"Total entry-text characters returned in this chunk.\",\n },\n maxEntries: {\n type: \"number\",\n minimum: 1,\n maximum: EXPAND_MAX_ENTRIES,\n default: EXPAND_DEFAULT_MAX_ENTRIES,\n description: \"Maximum complete or partial entries returned in this chunk.\",\n },\n },\n required: [\"session\"],\n additionalProperties: false,\n },\n outputSchema: expandOutputSchema,\n risk: \"read\",\n namespace: \"memory\",\n },\n {\n name: \"sessions\",\n description: \"List known sessions in scope with id, file, cwd, mtime, entry count, and hot/cold tier.\",\n inputSchema: {\n type: \"object\",\n properties: {\n source: SOURCE_ARG_SCHEMA,\n scope: { type: \"string\" },\n branches: {\n type: \"string\",\n enum: [\"active\", \"all\"],\n description: \"Count the active parent-linked path (default) or every branch.\",\n },\n limit: {\n type: \"number\",\n minimum: 1,\n description: \"Maximum sessions returned; capped at the internal session ceiling.\",\n },\n },\n additionalProperties: false,\n },\n outputSchema: sessionsOutputSchema,\n risk: \"read\",\n namespace: \"memory\",\n },\n];\n\nconst descriptors = memoryActionDescriptors;\n\n// Value spellings models reliably substitute for the documented memory scopes,\n// e.g. scope \"cwd\" for \"project\". Same discipline as the key aliases below:\n// identical intent only. Unknown scopes still fall through to resolveScope's\n// default \"session\" handling.\nconst MEMORY_SCOPE_VALUE_ALIASES: Record<string, string> = {\n cwd: \"project\",\n repo: \"project\",\n directory: \"project\",\n folder: \"project\",\n all: \"global\",\n current: \"session\",\n};\n\nconst MEMORY_ARG_NORMALIZATION: Record<string, ArgNormalizationSpec> = {\n recall: { values: { scope: MEMORY_SCOPE_VALUE_ALIASES } },\n sessions: { values: { scope: MEMORY_SCOPE_VALUE_ALIASES } },\n};\n\n// Argument repair derives from the action schemas plus the shared synonym\n// lexicon; only scope value spellings stay table-bound because the schema\n// spells scope as a free string rather than an enum.\nexport const normalizeMemoryArgs = actionArgNormalizer(\n () => descriptors,\n MEMORY_ARG_NORMALIZATION,\n);\n\nexport type { MemoryProviderContext } from \"../memory/request-context.js\";\n\n/** Lightweight recall/expand/sessions action schemas for managed proxies. */\nexport const memoryActionSchemas: {\n recall: { inputSchema: object; outputSchema: object };\n expand: { inputSchema: object; outputSchema: object };\n sessions: { inputSchema: object; outputSchema: object };\n} = Object.fromEntries(\n descriptors.map((descriptor) => [\n descriptor.name,\n { inputSchema: descriptor.inputSchema, outputSchema: descriptor.outputSchema },\n ]),\n) as {\n recall: { inputSchema: object; outputSchema: object };\n expand: { inputSchema: object; outputSchema: object };\n sessions: { inputSchema: object; outputSchema: object };\n};\n\nexport class MemoryProvider implements FabricProvider {\n readonly name = \"memory\";\n readonly description =\n \"Cross-session memory: a search engine over every Pi session timeline on this machine\";\n\n private readonly cache = new MemoryRequestCache();\n\n constructor(private readonly context: MemoryProviderContext) {}\n\n async list(\n request: FabricProviderListRequest,\n _context: FabricInvocationContext,\n ): Promise<FabricActionDescriptor[]> {\n const query = request.query?.toLowerCase();\n return query\n ? descriptors.filter((descriptor) =>\n `${descriptor.name} ${descriptor.description}`.toLowerCase().includes(query),\n )\n : descriptors;\n }\n\n async describe(\n actionName: string,\n _context: FabricInvocationContext,\n ): Promise<FabricActionDescriptor | undefined> {\n return descriptors.find((descriptor) => descriptor.name === actionName);\n }\n\n prepareArguments(\n actionName: string,\n args: Record<string, unknown>,\n ): Record<string, unknown> {\n return normalizeMemoryArgs(actionName, args);\n }\n\n async invoke(\n actionName: string,\n args: Record<string, unknown>,\n invocationContext: FabricInvocationContext,\n ): Promise<unknown> {\n const context = invocationContext.scope\n ? { ...this.context, fabricScope: invocationContext.scope }\n : this.context;\n try {\n switch (actionName) {\n case \"recall\":\n return await processMemoryRecall(args, invocationContext, context, this.cache);\n case \"expand\":\n return await processMemoryExpand(args, context, this.cache, invocationContext.signal);\n case \"sessions\":\n return await processMemorySessions(args, context, invocationContext.signal);\n default:\n throw new Error(`Unknown memory action: ${actionName}`);\n }\n } catch (error) {\n if (error instanceof AmbiguousSessionError) {\n const detail = {\n code: error.code,\n message: error.message,\n session: error.session,\n candidates: error.candidates,\n };\n if (actionName === \"recall\") return recallFailure(detail);\n if (actionName === \"expand\") return { entries: [], next: null, error: detail };\n return { error: detail };\n }\n throw error;\n }\n }\n\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBO,IAAM,2BAA2B;AACjC,IAAM,uBAAuB;AAC7B,IAAM,+BAA+B;AACrC,IAAM,2BAA2B;AACjC,IAAM,4BAA4B;AAgIzC,IAAM,kBAAkB,CAAC,OAAkC,MAAM,QAAuB;AACtF,MAAI,UAAU,UAAa,UAAU,KAAM,QAAO;AAClD,SAAO,MAAM,UAAU,MAAM,QAAQ,GAAG,MAAM,MAAM,GAAG,KAAK,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC;AAC9E;AAEA,IAAM,YAAY,CAAC,MAAc,OAAe,QAAwB;AACtE,MAAI,YAAY,KAAK,IAAI,GAAG,KAAK;AACjC,MAAI,UAAU,KAAK,IAAI,KAAK,QAAQ,GAAG;AACvC,QAAM,YAAY,KAAK,WAAW,SAAS;AAC3C,MAAI,YAAY,KAAK,aAAa,SAAU,aAAa,MAAQ,cAAa;AAC9E,QAAM,UAAU,KAAK,WAAW,UAAU,CAAC;AAC3C,MAAI,UAAU,KAAK,UAAU,WAAW,SAAU,WAAW,MAAQ,YAAW;AAChF,SAAO,KAAK,MAAM,WAAW,OAAO;AACtC;AAEA,IAAM,gBAAgB,CACpB,MACA,OACA,cACW;AACX,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,aAAa,sBAAsB,IAAI;AAC7C,MAAI,cAAc,UAAU;AAC1B,UAAM,SAAS,sBAAsB,MAAM,KAAK,CAAC;AACjD,WAAO,KAAK,IAAI,GAAG,WAAW,QAAQ,MAAM,CAAC;AAAA,EAC/C;AACA,MAAI,cAAc,WAAW;AA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AS,KAAK;AAAA,IAC7E,IACA;AAAA,EACN;AAAA,EAEA,MAAM,SACJ,YACA,UAC6C;AAC7C,WAAO,YAAY,KAAK,CAAC,eAAe,WAAW,SAAS,UAAU;AAAA,EACxE;AAAA,EAEA,iBACE,YACA,MACyB;AACzB,WAAO,oBAAoB,YAAY,IAAI;AAAA,EAC7C;AAAA,EAEA,MAAM,OACJ,YACA,MACA,mBACkB;AAClB,UAAM,UAAU,kBAAkB,QAC9B,EAAE,GAAG,KAAK,SAAS,aAAa,kBAAkB,MAAM,IACxD,KAAK;AACT,QAAI;AACF,cAAQ,YAAY;AAAA,QAClB,KAAK;AACH,iBAAO,MAAM,oBAAoB,MAAM,mBAAmB,SAAS,KAAK,KAAK;AAAA,QAC/E,KAAK;AACH,iBAAO,MAAM,oBAAoB,MAAM,SAAS,KAAK,OAAO,kBAAkB,MAAM;AAAA,QACtF,KAAK;AACH,iBAAO,MAAM,sBAAsB,MAAM,SAAS,kBAAkB,MAAM;AAAA,QAC5E;AACE,gBAAM,IAAI,MAAM,0BAA0B,UAAU,EAAE;AAAA,MAC1D;AAAA,IACF,SAAS,OAAO;AACd,UAAI,iBAAiB,uBAAuB;AAC1C,cAAM,SAAS;AAAA,UACb,MAAM,MAAM;AAAA,UACZ,SAAS,MAAM;AAAA,UACf,SAAS,MAAM;AAAA,UACf,YAAY,MAAM;AAAA,QACpB;AACA,YAAI,eAAe,SAAU,QAAO,cAAc,MAAM;AACxD,YAAI,eAAe,SAAU,QAAO,EAAE,SAAS,CAAC,GAAG,MAAM,MAAM,OAAO,OAAO;AAC7E,eAAO,EAAE,OAAO,OAAO;AAAA,MACzB;AACA,YAAM;AAAA,IACR;AAAA,EACF;AAEF;",
6
6
  "names": ["path", "path", "path", "crypto", "coverageReasons", "crypto", "hostIdentity", "response", "finalState", "finalLineage", "anchorIndex", "cursor", "coverageReasons", "options", "index", "shards", "digests", "sessions"]
7
7
  }