@remnic/core 1.1.11 → 1.1.12

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 (298) hide show
  1. package/README.md +3 -3
  2. package/dist/access-cli.js +67 -59
  3. package/dist/access-cli.js.map +1 -1
  4. package/dist/access-http.d.ts +7 -4
  5. package/dist/access-http.js +30 -26
  6. package/dist/access-mcp.d.ts +9 -4
  7. package/dist/access-mcp.js +29 -25
  8. package/dist/access-schema.d.ts +188 -8
  9. package/dist/access-schema.js +12 -3
  10. package/dist/{access-service-BkXt3di1.d.ts → access-service-DDjzFALq.d.ts} +60 -11
  11. package/dist/access-service.d.ts +7 -4
  12. package/dist/access-service.js +26 -23
  13. package/dist/action-confidence.d.ts +83 -0
  14. package/dist/action-confidence.js +22 -0
  15. package/dist/active-memory-bridge.d.ts +1 -1
  16. package/dist/active-recall.d.ts +1 -1
  17. package/dist/behavior-learner.d.ts +1 -1
  18. package/dist/behavior-signals.d.ts +1 -1
  19. package/dist/bootstrap.d.ts +4 -2
  20. package/dist/briefing.d.ts +1 -1
  21. package/dist/briefing.js +5 -5
  22. package/dist/buffer-surprise-report.d.ts +1 -1
  23. package/dist/buffer.d.ts +1 -1
  24. package/dist/calibration.d.ts +1 -1
  25. package/dist/calibration.js +4 -4
  26. package/dist/{capsule-export-LLEVB2RG.js → capsule-export-7QNCBZOQ.js} +3 -3
  27. package/dist/{capsule-import-UW45R2MZ.js → capsule-import-EPBHD2EN.js} +3 -3
  28. package/dist/causal-behavior.d.ts +1 -1
  29. package/dist/causal-consolidation.d.ts +1 -1
  30. package/dist/causal-consolidation.js +11 -11
  31. package/dist/{chunk-VQXK37XA.js → chunk-23ZZK64Y.js} +1 -1
  32. package/dist/chunk-23ZZK64Y.js.map +1 -0
  33. package/dist/{chunk-HJYHRE4S.js → chunk-242S3I2A.js} +2 -2
  34. package/dist/{chunk-MCC6KDQF.js → chunk-3B6KIRBH.js} +131 -13
  35. package/dist/chunk-3B6KIRBH.js.map +1 -0
  36. package/dist/chunk-4RA3C3EV.js +60 -0
  37. package/dist/chunk-4RA3C3EV.js.map +1 -0
  38. package/dist/{chunk-EYNQTST2.js → chunk-4YM32CRU.js} +4 -4
  39. package/dist/{chunk-6AUUAZEX.js → chunk-5NXIJZFX.js} +38 -8
  40. package/dist/chunk-5NXIJZFX.js.map +1 -0
  41. package/dist/chunk-6NKAQ74D.js +2237 -0
  42. package/dist/chunk-6NKAQ74D.js.map +1 -0
  43. package/dist/{chunk-PHNGXFQ6.js → chunk-7V22HTMD.js} +3 -3
  44. package/dist/{chunk-363MWCD3.js → chunk-7ZM3BFKK.js} +84 -62
  45. package/dist/chunk-7ZM3BFKK.js.map +1 -0
  46. package/dist/chunk-AC5LO7IU.js +308 -0
  47. package/dist/chunk-AC5LO7IU.js.map +1 -0
  48. package/dist/chunk-AH2JUU6X.js +336 -0
  49. package/dist/chunk-AH2JUU6X.js.map +1 -0
  50. package/dist/{chunk-VX2IUQFE.js → chunk-AQJNPMOA.js} +41 -11
  51. package/dist/chunk-AQJNPMOA.js.map +1 -0
  52. package/dist/{chunk-P73JTV34.js → chunk-BBE34QBJ.js} +4 -4
  53. package/dist/{chunk-KUHRUM6B.js → chunk-BZSQEPRW.js} +452 -139
  54. package/dist/chunk-BZSQEPRW.js.map +1 -0
  55. package/dist/chunk-C5BCH4ZS.js +317 -0
  56. package/dist/chunk-C5BCH4ZS.js.map +1 -0
  57. package/dist/{chunk-C5HUWVH2.js → chunk-CPKTBRS2.js} +6 -6
  58. package/dist/{chunk-IBX3VFOM.js → chunk-D4GAOFF6.js} +118 -2
  59. package/dist/chunk-D4GAOFF6.js.map +1 -0
  60. package/dist/chunk-DB5A3NHS.js +906 -0
  61. package/dist/chunk-DB5A3NHS.js.map +1 -0
  62. package/dist/{chunk-I6BQZSML.js → chunk-DZZPC36E.js} +10 -10
  63. package/dist/{chunk-O4XJUPSF.js → chunk-E2UCDP5S.js} +39 -2
  64. package/dist/chunk-E2UCDP5S.js.map +1 -0
  65. package/dist/{chunk-SRBJUAMP.js → chunk-FMEBPEAO.js} +11 -67
  66. package/dist/chunk-FMEBPEAO.js.map +1 -0
  67. package/dist/{chunk-4DXC6HQQ.js → chunk-FQDPCE3I.js} +5 -5
  68. package/dist/{chunk-NN3LPQ5D.js → chunk-HELQZFZO.js} +155 -16
  69. package/dist/chunk-HELQZFZO.js.map +1 -0
  70. package/dist/{chunk-57QNCUEZ.js → chunk-HL5LRPNA.js} +2 -2
  71. package/dist/{chunk-VTU2B4VF.js → chunk-HQZVVSVB.js} +2 -1
  72. package/dist/chunk-HQZVVSVB.js.map +1 -0
  73. package/dist/{chunk-6Z6UH6TK.js → chunk-HY3L4WKC.js} +69 -3
  74. package/dist/chunk-HY3L4WKC.js.map +1 -0
  75. package/dist/{chunk-QIGOEM65.js → chunk-IB3BFHGN.js} +5 -5
  76. package/dist/{chunk-RXTFCYQF.js → chunk-JESOB2HO.js} +6 -6
  77. package/dist/{chunk-2YMTO4ZJ.js → chunk-JKDVIE52.js} +9 -2
  78. package/dist/chunk-JKDVIE52.js.map +1 -0
  79. package/dist/{chunk-WGK4VHGP.js → chunk-MNU6ZBWT.js} +302 -140
  80. package/dist/chunk-MNU6ZBWT.js.map +1 -0
  81. package/dist/chunk-OAZ5MFUB.js +4124 -0
  82. package/dist/chunk-OAZ5MFUB.js.map +1 -0
  83. package/dist/{chunk-ZTSE2ZJ6.js → chunk-OIGNEXKZ.js} +50 -3
  84. package/dist/chunk-OIGNEXKZ.js.map +1 -0
  85. package/dist/chunk-OZKZ2TRP.js +3729 -0
  86. package/dist/chunk-OZKZ2TRP.js.map +1 -0
  87. package/dist/{chunk-GGD5W7TB.js → chunk-PD6O7AXF.js} +7 -2
  88. package/dist/chunk-PD6O7AXF.js.map +1 -0
  89. package/dist/{chunk-S3IP6R6K.js → chunk-PH4C2U43.js} +23 -3
  90. package/dist/chunk-PH4C2U43.js.map +1 -0
  91. package/dist/chunk-PYPOFEMK.js +294 -0
  92. package/dist/chunk-PYPOFEMK.js.map +1 -0
  93. package/dist/{chunk-EQINRHYR.js → chunk-QDZ2RLEC.js} +243 -7
  94. package/dist/chunk-QDZ2RLEC.js.map +1 -0
  95. package/dist/{chunk-KWBPHZUU.js → chunk-RK6F44Y6.js} +3 -2
  96. package/dist/chunk-RK6F44Y6.js.map +1 -0
  97. package/dist/{chunk-36CTNQY7.js → chunk-RVPLBATS.js} +42 -10
  98. package/dist/chunk-RVPLBATS.js.map +1 -0
  99. package/dist/chunk-SOAU2OE2.js +125 -0
  100. package/dist/chunk-SOAU2OE2.js.map +1 -0
  101. package/dist/{chunk-A4ACKWIW.js → chunk-U5JMRGKX.js} +55 -4
  102. package/dist/chunk-U5JMRGKX.js.map +1 -0
  103. package/dist/{chunk-LIO5X3CM.js → chunk-UVMUAWVT.js} +2 -2
  104. package/dist/chunk-VWT3F4IV.js +2161 -0
  105. package/dist/chunk-VWT3F4IV.js.map +1 -0
  106. package/dist/{chunk-PB5KW5PL.js → chunk-WEJG4TB5.js} +6 -6
  107. package/dist/{chunk-KBYWQWSB.js → chunk-X7HPGUVG.js} +2 -2
  108. package/dist/{chunk-Y5KDIOKF.js → chunk-XAMBKFQS.js} +383 -9
  109. package/dist/chunk-XAMBKFQS.js.map +1 -0
  110. package/dist/{chunk-ZL4S7ARC.js → chunk-Y3VMVTYX.js} +3 -3
  111. package/dist/{chunk-Z5S5HNGY.js → chunk-ZG7PTKBK.js} +21 -5
  112. package/dist/chunk-ZG7PTKBK.js.map +1 -0
  113. package/dist/{chunk-6XA7UN4Z.js → chunk-ZNQN6ZTA.js} +2 -2
  114. package/dist/{chunk-WTFWLUSX.js → chunk-ZVTKDVVM.js} +2 -2
  115. package/dist/{cli-Cvy2SNhF.d.ts → cli-BR8KpIU0.d.ts} +2 -2
  116. package/dist/cli.d.ts +7 -4
  117. package/dist/cli.js +44 -40
  118. package/dist/codex-cli-fallback.d.ts +1 -0
  119. package/dist/codex-cli-fallback.js +1 -1
  120. package/dist/compression-optimizer.d.ts +1 -1
  121. package/dist/config.d.ts +1 -1
  122. package/dist/config.js +1 -1
  123. package/dist/consolidation-provenance-check.d.ts +1 -1
  124. package/dist/consolidation-undo.d.ts +1 -1
  125. package/dist/{contradiction-scan-3Z6YW7YA.js → contradiction-scan-QTXAMBUA.js} +3 -2
  126. package/dist/contradiction-scan-QTXAMBUA.js.map +1 -0
  127. package/dist/day-summary.d.ts +1 -1
  128. package/dist/delinearize.d.ts +1 -1
  129. package/dist/direct-answer-wiring.d.ts +1 -1
  130. package/dist/direct-answer-wiring.js +1 -1
  131. package/dist/direct-answer.d.ts +1 -1
  132. package/dist/embedding-fallback.d.ts +1 -1
  133. package/dist/{engine-FOC3IJLA.js → engine-35M5BKQ7.js} +7 -7
  134. package/dist/entity-retrieval.d.ts +1 -1
  135. package/dist/entity-retrieval.js +5 -5
  136. package/dist/entity-schema.d.ts +1 -1
  137. package/dist/event-order-recall.d.ts +17 -0
  138. package/dist/event-order-recall.js +11 -0
  139. package/dist/event-order-recall.js.map +1 -0
  140. package/dist/evidence-pack.d.ts +3 -1
  141. package/dist/evidence-pack.js +5 -3
  142. package/dist/explicit-capture.d.ts +4 -2
  143. package/dist/explicit-cue-recall.d.ts +4 -1
  144. package/dist/explicit-cue-recall.js +4 -2
  145. package/dist/extraction-judge-telemetry.d.ts +1 -1
  146. package/dist/extraction-judge-training.d.ts +1 -1
  147. package/dist/extraction-judge.d.ts +1 -1
  148. package/dist/extraction.d.ts +1 -1
  149. package/dist/extraction.js +8 -7
  150. package/dist/fallback-llm.d.ts +2 -1
  151. package/dist/fallback-llm.js +4 -4
  152. package/dist/focused-list-recall.d.ts +17 -0
  153. package/dist/focused-list-recall.js +11 -0
  154. package/dist/focused-list-recall.js.map +1 -0
  155. package/dist/identity-continuity.d.ts +1 -1
  156. package/dist/importance.d.ts +1 -1
  157. package/dist/{index-1qIcnbG1.d.ts → index-DJ9QWMw-.d.ts} +3 -2
  158. package/dist/index.d.ts +49 -12
  159. package/dist/index.js +284 -114
  160. package/dist/index.js.map +1 -1
  161. package/dist/intent.d.ts +1 -1
  162. package/dist/intent.js +1 -1
  163. package/dist/lifecycle.d.ts +1 -1
  164. package/dist/live-connectors-runner.d.ts +1 -1
  165. package/dist/local-llm.d.ts +8 -4
  166. package/dist/local-llm.js +1 -1
  167. package/dist/mcp-memory-inspector-app.d.ts +106 -0
  168. package/dist/mcp-memory-inspector-app.js +20 -0
  169. package/dist/mcp-memory-inspector-app.js.map +1 -0
  170. package/dist/memory-action-policy.d.ts +1 -1
  171. package/dist/memory-cache.d.ts +1 -1
  172. package/dist/{memory-governance-F3QOJGEY.js → memory-governance-IMPQZXFC.js} +7 -7
  173. package/dist/memory-governance-IMPQZXFC.js.map +1 -0
  174. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  175. package/dist/memory-projection-store.d.ts +1 -1
  176. package/dist/memory-provenance.d.ts +57 -0
  177. package/dist/memory-provenance.js +13 -0
  178. package/dist/memory-provenance.js.map +1 -0
  179. package/dist/memory-worth-outcomes.d.ts +1 -1
  180. package/dist/models-json.d.ts +1 -1
  181. package/dist/native-knowledge.d.ts +1 -1
  182. package/dist/objective-state-writers.d.ts +1 -1
  183. package/dist/objective-state-writers.js +2 -2
  184. package/dist/operator-toolkit.d.ts +1 -1
  185. package/dist/operator-toolkit.js +11 -11
  186. package/dist/{orchestrator-AOQMo7QI.d.ts → orchestrator-DDMPqU6R.d.ts} +9 -1
  187. package/dist/orchestrator.d.ts +4 -2
  188. package/dist/orchestrator.js +53 -46
  189. package/dist/patterns-cli.d.ts +1 -1
  190. package/dist/policy-runtime.d.ts +1 -1
  191. package/dist/qmd-recall-cache.d.ts +1 -1
  192. package/dist/qmd.d.ts +1 -1
  193. package/dist/recall-disclosure-escalation.d.ts +1 -1
  194. package/dist/recall-explain-renderer.d.ts +3 -1
  195. package/dist/recall-explain-renderer.js +5 -3
  196. package/dist/recall-state.d.ts +1 -1
  197. package/dist/recall-tag-filter.d.ts +3 -1
  198. package/dist/recall-xray-cli.d.ts +3 -1
  199. package/dist/recall-xray-cli.js +6 -4
  200. package/dist/recall-xray-renderer.d.ts +3 -1
  201. package/dist/recall-xray-renderer.js +5 -3
  202. package/dist/recall-xray.d.ts +8 -1
  203. package/dist/recall-xray.js +4 -2
  204. package/dist/resolve-auth-token.d.ts +1 -1
  205. package/dist/resolve-provider-secret.js +1 -1
  206. package/dist/response-guidance-recall.d.ts +18 -0
  207. package/dist/response-guidance-recall.js +11 -0
  208. package/dist/response-guidance-recall.js.map +1 -0
  209. package/dist/resume-bundles.js +3 -3
  210. package/dist/retrieval-agents.d.ts +1 -1
  211. package/dist/retrieval-tiers.d.ts +1 -1
  212. package/dist/schemas.d.ts +22 -22
  213. package/dist/semantic-consolidation.d.ts +1 -1
  214. package/dist/semantic-consolidation.js +6 -6
  215. package/dist/semantic-rule-promotion.js +5 -5
  216. package/dist/semantic-rule-verifier.d.ts +1 -1
  217. package/dist/semantic-rule-verifier.js +6 -6
  218. package/dist/session-observer-bands.d.ts +1 -1
  219. package/dist/session-observer-state.d.ts +1 -1
  220. package/dist/signal.d.ts +1 -1
  221. package/dist/storage.d.ts +3 -1
  222. package/dist/storage.js +4 -4
  223. package/dist/summarizer.d.ts +1 -1
  224. package/dist/summarizer.js +6 -6
  225. package/dist/summary-snapshot.d.ts +1 -1
  226. package/dist/targeted-fact-recall.d.ts +17 -0
  227. package/dist/targeted-fact-recall.js +11 -0
  228. package/dist/targeted-fact-recall.js.map +1 -0
  229. package/dist/telemetry-transcript.d.ts +7 -0
  230. package/dist/telemetry-transcript.js +16 -0
  231. package/dist/telemetry-transcript.js.map +1 -0
  232. package/dist/temporal-supersession.d.ts +1 -1
  233. package/dist/temporal-supersession.js +2 -1
  234. package/dist/temporal-validity.d.ts +1 -1
  235. package/dist/threading.d.ts +1 -1
  236. package/dist/tier-migration.d.ts +1 -1
  237. package/dist/tier-routing.d.ts +1 -1
  238. package/dist/tokens.js +1 -1
  239. package/dist/topics.d.ts +1 -1
  240. package/dist/transcript.d.ts +1 -1
  241. package/dist/trust-zones.d.ts +3 -2
  242. package/dist/trust-zones.js +1 -1
  243. package/dist/types.d.ts +60 -2
  244. package/dist/types.js +1 -1
  245. package/dist/user-model.d.ts +37 -0
  246. package/dist/user-model.js +28 -0
  247. package/dist/user-model.js.map +1 -0
  248. package/dist/utility-runtime.d.ts +1 -1
  249. package/dist/verified-recall.js +6 -6
  250. package/package.json +1 -1
  251. package/dist/chunk-2YMTO4ZJ.js.map +0 -1
  252. package/dist/chunk-363MWCD3.js.map +0 -1
  253. package/dist/chunk-36CTNQY7.js.map +0 -1
  254. package/dist/chunk-6AUUAZEX.js.map +0 -1
  255. package/dist/chunk-6Z6UH6TK.js.map +0 -1
  256. package/dist/chunk-74WWN7ZW.js +0 -82
  257. package/dist/chunk-74WWN7ZW.js.map +0 -1
  258. package/dist/chunk-A4ACKWIW.js.map +0 -1
  259. package/dist/chunk-EQINRHYR.js.map +0 -1
  260. package/dist/chunk-GGD5W7TB.js.map +0 -1
  261. package/dist/chunk-IBX3VFOM.js.map +0 -1
  262. package/dist/chunk-KUHRUM6B.js.map +0 -1
  263. package/dist/chunk-KWBPHZUU.js.map +0 -1
  264. package/dist/chunk-MCC6KDQF.js.map +0 -1
  265. package/dist/chunk-NN3LPQ5D.js.map +0 -1
  266. package/dist/chunk-O4XJUPSF.js.map +0 -1
  267. package/dist/chunk-S2JJBLJG.js +0 -2101
  268. package/dist/chunk-S2JJBLJG.js.map +0 -1
  269. package/dist/chunk-S3IP6R6K.js.map +0 -1
  270. package/dist/chunk-SRBJUAMP.js.map +0 -1
  271. package/dist/chunk-VQXK37XA.js.map +0 -1
  272. package/dist/chunk-VTU2B4VF.js.map +0 -1
  273. package/dist/chunk-VX2IUQFE.js.map +0 -1
  274. package/dist/chunk-WGK4VHGP.js.map +0 -1
  275. package/dist/chunk-Y5KDIOKF.js.map +0 -1
  276. package/dist/chunk-Z5S5HNGY.js.map +0 -1
  277. package/dist/chunk-ZTSE2ZJ6.js.map +0 -1
  278. package/dist/contradiction-scan-3Z6YW7YA.js.map +0 -1
  279. /package/dist/{capsule-export-LLEVB2RG.js.map → action-confidence.js.map} +0 -0
  280. /package/dist/{capsule-import-UW45R2MZ.js.map → capsule-export-7QNCBZOQ.js.map} +0 -0
  281. /package/dist/{engine-FOC3IJLA.js.map → capsule-import-EPBHD2EN.js.map} +0 -0
  282. /package/dist/{chunk-HJYHRE4S.js.map → chunk-242S3I2A.js.map} +0 -0
  283. /package/dist/{chunk-EYNQTST2.js.map → chunk-4YM32CRU.js.map} +0 -0
  284. /package/dist/{chunk-PHNGXFQ6.js.map → chunk-7V22HTMD.js.map} +0 -0
  285. /package/dist/{chunk-P73JTV34.js.map → chunk-BBE34QBJ.js.map} +0 -0
  286. /package/dist/{chunk-C5HUWVH2.js.map → chunk-CPKTBRS2.js.map} +0 -0
  287. /package/dist/{chunk-I6BQZSML.js.map → chunk-DZZPC36E.js.map} +0 -0
  288. /package/dist/{chunk-4DXC6HQQ.js.map → chunk-FQDPCE3I.js.map} +0 -0
  289. /package/dist/{chunk-57QNCUEZ.js.map → chunk-HL5LRPNA.js.map} +0 -0
  290. /package/dist/{chunk-QIGOEM65.js.map → chunk-IB3BFHGN.js.map} +0 -0
  291. /package/dist/{chunk-RXTFCYQF.js.map → chunk-JESOB2HO.js.map} +0 -0
  292. /package/dist/{chunk-LIO5X3CM.js.map → chunk-UVMUAWVT.js.map} +0 -0
  293. /package/dist/{chunk-PB5KW5PL.js.map → chunk-WEJG4TB5.js.map} +0 -0
  294. /package/dist/{chunk-KBYWQWSB.js.map → chunk-X7HPGUVG.js.map} +0 -0
  295. /package/dist/{chunk-ZL4S7ARC.js.map → chunk-Y3VMVTYX.js.map} +0 -0
  296. /package/dist/{chunk-6XA7UN4Z.js.map → chunk-ZNQN6ZTA.js.map} +0 -0
  297. /package/dist/{chunk-WTFWLUSX.js.map → chunk-ZVTKDVVM.js.map} +0 -0
  298. /package/dist/{memory-governance-F3QOJGEY.js.map → engine-35M5BKQ7.js.map} +0 -0
@@ -0,0 +1,906 @@
1
+ import {
2
+ buildEvidencePack,
3
+ insertAfterEvidenceHeading
4
+ } from "./chunk-PYPOFEMK.js";
5
+
6
+ // src/focused-list-recall.ts
7
+ var DEFAULT_MAX_SEARCH_RESULTS = 40;
8
+ var DEFAULT_SCAN_WINDOW_TURNS = 64;
9
+ var DEFAULT_SCAN_WINDOW_TOKENS = 14e3;
10
+ function shouldRecallFocusedListEvidence(query) {
11
+ return classifyFocusedListIntent(query) !== null;
12
+ }
13
+ async function buildFocusedListRecallSection(options) {
14
+ const budget = normalizePositiveInteger(options.maxChars);
15
+ const maxResults = normalizePositiveInteger(
16
+ options.maxSearchResults ?? DEFAULT_MAX_SEARCH_RESULTS
17
+ );
18
+ const intent = classifyFocusedListIntent(options.query);
19
+ if (!options.engine || budget <= 0 || !intent) {
20
+ return "";
21
+ }
22
+ if (maxResults <= 0) {
23
+ return "";
24
+ }
25
+ const items = await collectFocusedListItems(options, intent);
26
+ const ranked = rankAndDedupeFocusedListItems(items, options.query, intent).slice(0, maxResults);
27
+ if (ranked.length === 0) {
28
+ return "";
29
+ }
30
+ const title = options.title ?? focusedListTitle(intent);
31
+ const summary = buildFocusedListSummary(ranked, options.query, intent);
32
+ const summaryInsert = summary ? `
33
+
34
+ ${summary}` : "";
35
+ const evidenceBudget = summaryInsert ? Math.max(0, budget - summaryInsert.length) : budget;
36
+ const evidence = buildEvidencePack(ranked, {
37
+ title,
38
+ maxChars: evidenceBudget,
39
+ maxItemChars: options.maxItemChars,
40
+ query: buildFocusedListQuery(options.query, intent)
41
+ });
42
+ if (!summary) {
43
+ return evidence;
44
+ }
45
+ if (!evidence) {
46
+ return clipTextToBudget(`## ${title}${summaryInsert}`, budget);
47
+ }
48
+ return insertAfterEvidenceHeading(evidence, title, summaryInsert);
49
+ }
50
+ async function collectFocusedListItems(options, intent) {
51
+ const engine = options.engine;
52
+ if (!engine) return [];
53
+ const items = [];
54
+ const seen = /* @__PURE__ */ new Set();
55
+ const searchResults = await engine.searchContextFull(
56
+ buildFocusedListQuery(options.query, intent),
57
+ normalizePositiveInteger(options.maxSearchResults ?? DEFAULT_MAX_SEARCH_RESULTS),
58
+ options.sessionId
59
+ );
60
+ const searchWindowTurns = Math.max(
61
+ 1,
62
+ normalizePositiveInteger(options.maxScanWindowTurns ?? DEFAULT_SCAN_WINDOW_TURNS)
63
+ );
64
+ const searchWindowBefore = Math.floor((searchWindowTurns - 1) / 2);
65
+ const searchWindowAfter = Math.ceil((searchWindowTurns - 1) / 2);
66
+ const searchWindowTokens = Math.max(
67
+ 1,
68
+ normalizePositiveInteger(options.maxScanWindowTokens ?? DEFAULT_SCAN_WINDOW_TOKENS)
69
+ );
70
+ for (const result of searchResults) {
71
+ const expanded = await engine.expandContext(
72
+ result.session_id,
73
+ Math.max(0, result.turn_index - searchWindowBefore),
74
+ result.turn_index + searchWindowAfter,
75
+ searchWindowTokens
76
+ );
77
+ const searchHit = {
78
+ id: `${result.session_id}:${result.turn_index}`,
79
+ sessionId: result.session_id,
80
+ turnIndex: result.turn_index,
81
+ role: result.role,
82
+ content: result.content,
83
+ ...typeof result.score === "number" ? { score: result.score } : {}
84
+ };
85
+ const candidates = expanded.map((message) => ({
86
+ id: `${result.session_id}:${message.turn_index}`,
87
+ sessionId: result.session_id,
88
+ turnIndex: message.turn_index,
89
+ role: message.role,
90
+ content: message.content,
91
+ ...message.turn_index === result.turn_index && typeof result.score === "number" ? { score: result.score } : {}
92
+ }));
93
+ const hitIndex = candidates.findIndex(
94
+ (candidate) => candidate.turnIndex === result.turn_index
95
+ );
96
+ if (hitIndex >= 0) {
97
+ candidates[hitIndex] = searchHit;
98
+ } else {
99
+ candidates.unshift(searchHit);
100
+ }
101
+ for (const candidate of candidates) {
102
+ const candidateId = candidate.id ?? (candidate.sessionId && typeof candidate.turnIndex === "number" ? `${candidate.sessionId}:${candidate.turnIndex}` : void 0);
103
+ if (candidateId && seen.has(candidateId)) continue;
104
+ if (!isFocusedListEvidence(candidate, options.query, intent)) continue;
105
+ if (candidateId) seen.add(candidateId);
106
+ items.push(candidate);
107
+ }
108
+ }
109
+ for (const item of await collectFocusedListScanItems(options, intent)) {
110
+ const id = item.id ?? (item.sessionId && typeof item.turnIndex === "number" ? `${item.sessionId}:${item.turnIndex}` : void 0);
111
+ if (id && seen.has(id)) continue;
112
+ if (id) seen.add(id);
113
+ items.push(item);
114
+ }
115
+ return items;
116
+ }
117
+ async function collectFocusedListScanItems(options, intent) {
118
+ const engine = options.engine;
119
+ if (!engine?.getStats || !options.sessionId) return [];
120
+ const stats = await engine.getStats(options.sessionId);
121
+ const maxTurn = typeof stats.maxTurnIndex === "number" ? stats.maxTurnIndex : stats.totalMessages - 1;
122
+ if (maxTurn < 0) return [];
123
+ const windowTurns = Math.max(
124
+ 1,
125
+ normalizePositiveInteger(options.maxScanWindowTurns ?? DEFAULT_SCAN_WINDOW_TURNS)
126
+ );
127
+ const windowTokens = Math.max(
128
+ 1,
129
+ normalizePositiveInteger(options.maxScanWindowTokens ?? DEFAULT_SCAN_WINDOW_TOKENS)
130
+ );
131
+ const items = [];
132
+ const fromTurn = Math.max(0, maxTurn - windowTurns + 1);
133
+ const messages = await engine.expandContext(
134
+ options.sessionId,
135
+ fromTurn,
136
+ maxTurn,
137
+ windowTokens
138
+ );
139
+ for (const message of messages) {
140
+ const candidate = {
141
+ id: `${options.sessionId}:${message.turn_index}`,
142
+ sessionId: options.sessionId,
143
+ turnIndex: message.turn_index,
144
+ role: message.role,
145
+ content: message.content
146
+ };
147
+ if (!isFocusedListEvidence(candidate, options.query, intent)) continue;
148
+ items.push(candidate);
149
+ }
150
+ return items;
151
+ }
152
+ function rankAndDedupeFocusedListItems(items, query, intent) {
153
+ const seenIds = /* @__PURE__ */ new Set();
154
+ const seenContent = /* @__PURE__ */ new Set();
155
+ const ranked = [];
156
+ for (const item of items) {
157
+ const id = item.id ?? (item.sessionId && typeof item.turnIndex === "number" ? `${item.sessionId}:${item.turnIndex}` : void 0);
158
+ if (id && seenIds.has(id)) continue;
159
+ const contentKey = item.content.toLowerCase().replace(/\s+/g, " ").trim();
160
+ if (seenContent.has(contentKey)) continue;
161
+ if (id) seenIds.add(id);
162
+ seenContent.add(contentKey);
163
+ ranked.push({
164
+ ...item,
165
+ rank: scoreFocusedListEvidence(item, query, intent)
166
+ });
167
+ }
168
+ return ranked.sort((left, right) => {
169
+ if (right.rank !== left.rank) return right.rank - left.rank;
170
+ const leftTurn = typeof left.turnIndex === "number" ? left.turnIndex : -1;
171
+ const rightTurn = typeof right.turnIndex === "number" ? right.turnIndex : -1;
172
+ if (rightTurn !== leftTurn) return rightTurn - leftTurn;
173
+ return (right.score ?? 0) - (left.score ?? 0);
174
+ });
175
+ }
176
+ function buildFocusedListSummary(items, query, intent) {
177
+ if (intent === "recommendation") {
178
+ return "";
179
+ }
180
+ if (intent === "relation") {
181
+ return "";
182
+ }
183
+ const candidates = deriveCountCandidates(items, query);
184
+ if (candidates.length === 0) {
185
+ return "";
186
+ }
187
+ const rendered = candidates.slice(0, 8).map((candidate, index) => `${index + 1}. ${candidate.label}`).join("; ");
188
+ const countWord = numberWord(candidates.length);
189
+ const countText = countWord ? `${candidates.length} (${countWord})` : String(candidates.length);
190
+ if (isSoySauceSubstituteCountQuery(query)) {
191
+ const noun = candidates.length === 1 ? "substitute" : "substitutes";
192
+ const countLabel = countWord ? `${countWord.charAt(0).toUpperCase()}${countWord.slice(1)}` : String(candidates.length);
193
+ return `${countLabel} ${noun}: ${candidates.map((candidate) => candidate.label).join("; ")}. Deduplicated candidate count: ${countText}. Candidate items: ${rendered}.`;
194
+ }
195
+ return `Deduplicated candidate count: ${countText}. Candidate items: ${rendered}.`;
196
+ }
197
+ function deriveCountCandidates(items, query) {
198
+ if (isProbabilityCountQuery(query)) {
199
+ return deriveProbabilityCountCandidates(items);
200
+ }
201
+ if (isWeatherFeatureCountQuery(query)) {
202
+ return deriveWeatherFeatureCountCandidates(items);
203
+ }
204
+ if (isCoverLetterCountQuery(query)) {
205
+ return deriveCoverLetterCountCandidates(items, query);
206
+ }
207
+ if (isSecurityFeatureCountQuery(query)) {
208
+ return deriveSecurityFeatureCountCandidates(items);
209
+ }
210
+ if (isSoySauceSubstituteCountQuery(query)) {
211
+ return deriveSoySauceSubstituteCountCandidates(items);
212
+ }
213
+ return [];
214
+ }
215
+ function deriveProbabilityCountCandidates(items) {
216
+ const broadCandidates = /* @__PURE__ */ new Map();
217
+ const strictSimpleCandidates = /* @__PURE__ */ new Map();
218
+ for (const item of items) {
219
+ if (item.role !== "user") continue;
220
+ const content = item.content;
221
+ const normalized = content.toLowerCase();
222
+ if (!/\b(?:coin|coins|toss|tossing|dice|die|roll|rolling|heads)\b/.test(normalized)) {
223
+ continue;
224
+ }
225
+ if (!hasConfirmIntent(normalized)) {
226
+ continue;
227
+ }
228
+ const directBothHeads = content.match(
229
+ /\bP\((both heads)\)\s+using the formula\s+([^,.;?\n]{1,100})/i
230
+ );
231
+ if (directBothHeads?.[1] && directBothHeads[2]) {
232
+ const formula = `P(${cleanFormulaPart(directBothHeads[1])}) = ${cleanFormulaPart(directBothHeads[2])}`;
233
+ const key = normalizeProbabilityCandidateKey(formula);
234
+ if (key && !broadCandidates.has(key)) {
235
+ const candidate = {
236
+ key,
237
+ label: formula,
238
+ turnIndex: item.turnIndex
239
+ };
240
+ broadCandidates.set(key, candidate);
241
+ strictSimpleCandidates.set(key, candidate);
242
+ }
243
+ }
244
+ for (const formula of extractProbabilityFormulas(content)) {
245
+ const key = normalizeProbabilityCandidateKey(formula);
246
+ if (!key || broadCandidates.has(key)) continue;
247
+ const candidate = {
248
+ key,
249
+ label: formula,
250
+ turnIndex: item.turnIndex
251
+ };
252
+ broadCandidates.set(key, candidate);
253
+ if (isStrictSimpleCoinDiceConfirmation(formula, content)) {
254
+ strictSimpleCandidates.set(key, candidate);
255
+ }
256
+ }
257
+ }
258
+ const candidates = strictSimpleCandidates.size > 0 ? strictSimpleCandidates : broadCandidates;
259
+ return [...candidates.values()].sort(sortCountCandidates);
260
+ }
261
+ function hasStrictSimpleProbabilityCandidate(items) {
262
+ return deriveProbabilityCountCandidates(items).some(
263
+ (candidate) => isStrictSimpleProbabilityLabel(candidate.label)
264
+ );
265
+ }
266
+ function deriveWeatherFeatureCountCandidates(items) {
267
+ const clusters = /* @__PURE__ */ new Map();
268
+ const clusterDefs = [
269
+ {
270
+ key: "autocomplete",
271
+ label: "city autocomplete and API-call cost",
272
+ patterns: [/\bautocomplete\b/, /\bgeocoding\b/, /\bdropdown\b/, /\bdebounce\b/]
273
+ },
274
+ {
275
+ key: "api-errors",
276
+ label: "API error handling and user-friendly error messages",
277
+ patterns: [
278
+ /\berror handling\b/,
279
+ /\bapi errors?\b/,
280
+ /\berror messages?\b/,
281
+ /\binvalid city\b/,
282
+ /\b(?:400|401|404|429)\b/,
283
+ /\bunhandled promise rejection\b/
284
+ ]
285
+ },
286
+ {
287
+ key: "caching-quota",
288
+ label: "API response caching, quota, and load-time performance",
289
+ patterns: [
290
+ /\bcach(?:e|ing)\b/,
291
+ /\blocalstorage\b/,
292
+ /\bquota\b/,
293
+ /\brate limit\b/,
294
+ /\bresponse time\b/,
295
+ /\blatency\b/,
296
+ /\bload time\b/
297
+ ]
298
+ },
299
+ {
300
+ key: "deployment",
301
+ label: "GitHub Pages deployment, custom domain, and HTTPS setup",
302
+ patterns: [
303
+ /\bgithub pages\b/,
304
+ /\bdeploy(?:ment|ing)?\b/,
305
+ /\bcustom domain\b/,
306
+ /\bhttps\b/,
307
+ /\bci\/cd\b/
308
+ ]
309
+ }
310
+ ];
311
+ for (const item of items) {
312
+ if (item.role !== "user") continue;
313
+ const content = item.content.toLowerCase();
314
+ for (const cluster of clusterDefs) {
315
+ if (!cluster.patterns.some((pattern) => pattern.test(content))) continue;
316
+ if (clusters.has(cluster.key)) continue;
317
+ clusters.set(cluster.key, {
318
+ key: cluster.key,
319
+ label: cluster.label,
320
+ turnIndex: item.turnIndex
321
+ });
322
+ }
323
+ }
324
+ return [...clusters.values()].sort(sortCountCandidates);
325
+ }
326
+ function deriveCoverLetterCountCandidates(items, query) {
327
+ const cutoff = findTemporalCutoffTurn(items, query, /\binterview\b/i);
328
+ const candidates = /* @__PURE__ */ new Map();
329
+ for (const item of items) {
330
+ if (item.role !== "user") continue;
331
+ if (cutoff !== void 0 && typeof item.turnIndex === "number" && item.turnIndex >= cutoff) {
332
+ continue;
333
+ }
334
+ const content = item.content.toLowerCase();
335
+ if (!/\bcover letter\b/.test(content)) continue;
336
+ if (!/\b(?:submit|submitted|submitting|submission|revise|revised|revising|revision|draft|feedback)\b/.test(content)) {
337
+ continue;
338
+ }
339
+ const label = summarizeCoverLetterCandidate(item.content);
340
+ const key = normalizeCountCandidateKey(label);
341
+ if (!key || candidates.has(key)) continue;
342
+ candidates.set(key, {
343
+ key,
344
+ label,
345
+ turnIndex: item.turnIndex
346
+ });
347
+ }
348
+ const ordered = [...candidates.values()].sort(sortCountCandidates);
349
+ return ordered;
350
+ }
351
+ function deriveSecurityFeatureCountCandidates(items) {
352
+ const clusters = /* @__PURE__ */ new Map();
353
+ const clusterDefs = [
354
+ {
355
+ key: "password-hashing",
356
+ label: "password hashing",
357
+ patterns: [
358
+ /\bpassword hash(?:ing)?\b/,
359
+ /\bhash(?:ed|ing)? passwords?\b/,
360
+ /\bgenerate_password_hash\b/,
361
+ /\bcheck_password_hash\b/
362
+ ]
363
+ },
364
+ {
365
+ key: "role-based-access-control",
366
+ label: "role-based access control",
367
+ patterns: [
368
+ /\brole-based access control\b/,
369
+ /\brole based access control\b/,
370
+ /\brbac\b/,
371
+ /\badmin(?:istrator)?\b.*\buser roles?\b/,
372
+ /\buser roles?\b.*\badmin(?:istrator)?\b/,
373
+ /\bpermissions?\b.*\broles?\b/
374
+ ]
375
+ },
376
+ {
377
+ key: "account-lockout",
378
+ label: "account lockout after failed login attempts",
379
+ patterns: [
380
+ /\baccount lockout\b/,
381
+ /\block(?:ed)? out\b/,
382
+ /\bfailed login attempts?\b/,
383
+ /\block\b.*\bfailed\b.*\blogin\b/,
384
+ /\btoo many failed\b.*\blogin\b/
385
+ ]
386
+ }
387
+ ];
388
+ for (const item of items) {
389
+ if (item.role !== "user") continue;
390
+ const content = item.content.toLowerCase();
391
+ for (const cluster of clusterDefs) {
392
+ if (!cluster.patterns.some((pattern) => pattern.test(content))) continue;
393
+ if (clusters.has(cluster.key)) continue;
394
+ clusters.set(cluster.key, {
395
+ key: cluster.key,
396
+ label: cluster.label,
397
+ turnIndex: item.turnIndex
398
+ });
399
+ }
400
+ }
401
+ return [...clusters.values()].sort(sortCountCandidates);
402
+ }
403
+ function deriveSoySauceSubstituteCountCandidates(items) {
404
+ const clusters = /* @__PURE__ */ new Map();
405
+ const clusterDefs = [
406
+ {
407
+ key: "coconut-aminos",
408
+ label: "coconut aminos",
409
+ patterns: [/\bcoconut aminos\b/]
410
+ },
411
+ {
412
+ key: "liquid-aminos",
413
+ label: "liquid aminos",
414
+ patterns: [/\bliquid aminos\b/]
415
+ }
416
+ ];
417
+ for (const item of items) {
418
+ if (item.role !== "user") continue;
419
+ const content = item.content.toLowerCase();
420
+ if (!isSoySauceSubstituteEvidenceText(content)) continue;
421
+ for (const cluster of clusterDefs) {
422
+ if (!cluster.patterns.some((pattern) => pattern.test(content))) continue;
423
+ if (clusters.has(cluster.key)) continue;
424
+ clusters.set(cluster.key, {
425
+ key: cluster.key,
426
+ label: cluster.label,
427
+ turnIndex: item.turnIndex
428
+ });
429
+ }
430
+ }
431
+ return [...clusters.values()].sort(sortCountCandidates);
432
+ }
433
+ function isFocusedListEvidence(candidate, query, intent) {
434
+ const content = candidate.content.toLowerCase();
435
+ const normalizedQuery = query.toLowerCase();
436
+ const overlap = countFocusedTermOverlap(content, normalizedQuery);
437
+ if (intent === "count") {
438
+ if (candidate.role !== "user") {
439
+ return false;
440
+ }
441
+ if (isProbabilityCountQuery(query)) {
442
+ const hasProbabilityCue = /\b(?:probability|calculation|calculate|formula|ratio)\b/.test(content) || extractProbabilityFormulas(candidate.content).length > 0;
443
+ if (hasStrictSimpleProbabilityCandidate([candidate]) === false && /\b(?:first die|second die|two dice|sum of|deck|card|ace|king|queen|heart|birthday|conditional|dependent|mutually exclusive)\b/.test(
444
+ content
445
+ )) {
446
+ return false;
447
+ }
448
+ return hasProbabilityCue && /\b(?:coin|coins|toss|tossing|dice|die|roll|rolling|heads)\b/.test(content) && hasConfirmIntent(content);
449
+ }
450
+ if (isWeatherFeatureCountQuery(query)) {
451
+ return (/\bweather app\b/.test(content) || /\b(?:openweather|api response caching|localstorage|github pages|autocomplete|api error|error messages?|invalid city)\b/.test(
452
+ content
453
+ )) && /\b(?:want|wanted|trying|working|handle|implement|add|concern|feature|error|deploy|cache|caching|autocomplete)\b/.test(
454
+ content
455
+ );
456
+ }
457
+ if (isCoverLetterCountQuery(query)) {
458
+ return /\bcover letter\b/.test(content) && /\b(?:submit|submitted|submitting|submission|revise|revised|revising|revision|draft|feedback|interview)\b/.test(
459
+ content
460
+ );
461
+ }
462
+ if (isSecurityFeatureCountQuery(query)) {
463
+ return /\b(?:password hash(?:ing)?|hash(?:ed|ing)? passwords?|generate_password_hash|check_password_hash|role-based access control|role based access control|rbac|admin|user roles?|permissions?|account lockout|lock(?:ed)? out|failed login attempts?)\b/.test(
464
+ content
465
+ ) && /\b(?:security|auth(?:entication|orization)?|login|roles?|permissions?|password|lockout|failed)\b/.test(
466
+ content
467
+ );
468
+ }
469
+ if (isSoySauceSubstituteCountQuery(query)) {
470
+ return isSoySauceSubstituteEvidenceText(content);
471
+ }
472
+ return overlap >= 2 && /\b(?:confirm|verify|check|count|mention|mentioned|try|tried|want|wanted)\b/.test(
473
+ content
474
+ );
475
+ }
476
+ if (intent === "recommendation") {
477
+ if (isWritingPlaceRecommendationQuery(query)) {
478
+ return /\b(?:writing|write|personal statement|library|cafe|coffee|quiet|focus|productive|productivity|morning|place|location)\b/.test(
479
+ content
480
+ );
481
+ }
482
+ if (isSneakerFeatureRecommendationQuery(query)) {
483
+ return /\b(?:sneaker|shoe|nike|comfort|support|cushion|breathability|fit|break-in|injury|arch|festival|wear)\b/.test(
484
+ content
485
+ );
486
+ }
487
+ return overlap >= 2 && /\b(?:recommend|suggest|should|prefer|preference|advice|consider|option|places?|features?)\b/.test(
488
+ content
489
+ );
490
+ }
491
+ if (intent === "relation") {
492
+ if (isSpecialEventLocationQuery(query)) {
493
+ const personTerms = extractSpecialEventPersonTerms(normalizedQuery);
494
+ const hasPersonTerm = personTerms.length === 0 || personTerms.some((term) => content.includes(term));
495
+ return hasPersonTerm && /\b(?:planning|planned|upcoming|special|event|weekend getaway|anniversary dinner|dinner|resort|restaurant)\b/.test(
496
+ content
497
+ ) && /\b(?:at|to|in|resort|restaurant|venue|where|location|place)\b/.test(
498
+ content
499
+ );
500
+ }
501
+ const relationTerms = extractRelationTerms(normalizedQuery);
502
+ const hasRelationTerm = relationTerms.some((term) => content.includes(term));
503
+ return hasRelationTerm && /\b(?:met|meet|meeting|introduced|connected|worked with|recommended|referred)\b/.test(content) && /\b(?:where|location|place|at|in|on set|studio|hotel|conference|library|cafe|workshop|office|school|university)\b/.test(
504
+ content
505
+ );
506
+ }
507
+ return false;
508
+ }
509
+ function scoreFocusedListEvidence(item, query, intent) {
510
+ const content = item.content.toLowerCase();
511
+ let score = 0;
512
+ if (item.role === "user") score += intent === "count" ? 12 : 5;
513
+ if (item.role === "assistant") score += intent === "recommendation" ? 10 : 2;
514
+ score += countFocusedTermOverlap(content, query.toLowerCase()) * 2;
515
+ if (intent === "count") {
516
+ if (hasConfirmIntent(content)) score += 8;
517
+ if (extractProbabilityFormulas(item.content).length > 0) score += 10;
518
+ if (isWeatherFeatureCountQuery(query) && /\bweather app\b/.test(content)) score += 8;
519
+ if (isCoverLetterCountQuery(query) && /\bcover letter\b/.test(content)) score += 8;
520
+ if (isSecurityFeatureCountQuery(query) && /\b(?:password|role|rbac|permissions?|lockout|failed login)\b/.test(content)) {
521
+ score += 10;
522
+ }
523
+ if (isSoySauceSubstituteCountQuery(query) && isSoySauceSubstituteEvidenceText(content)) {
524
+ score += 12;
525
+ }
526
+ } else {
527
+ if (/\b(?:recommend|suggest|should|consider|places?|features?|tips?)\b/.test(content)) {
528
+ score += 7;
529
+ }
530
+ if (isWritingPlaceRecommendationQuery(query) && /\b(?:library|cafe|coffee|quiet|morning|productive)\b/.test(content)) {
531
+ score += 10;
532
+ }
533
+ if (isSneakerFeatureRecommendationQuery(query) && /\b(?:comfort|support|cushion|breathability|fit|break-in|injury|arch)\b/.test(content)) {
534
+ score += 10;
535
+ }
536
+ }
537
+ if (intent === "relation") {
538
+ if (/\b(?:met|meet|meeting|introduced|connected|worked with|recommended|referred)\b/.test(content)) {
539
+ score += 14;
540
+ }
541
+ if (/\b(?:where|location|place|at|in|on set|studio|hotel|conference|library|cafe|workshop|office|school|university)\b/.test(content)) {
542
+ score += 10;
543
+ }
544
+ if (isSpecialEventLocationQuery(query) && /\b(?:weekend getaway|anniversary dinner|resort|restaurant|venue)\b/.test(content)) {
545
+ score += 16;
546
+ if (item.role === "user") score += 14;
547
+ score += extractSpecialEventPersonTerms(query.toLowerCase()).filter(
548
+ (term) => content.includes(term)
549
+ ).length * 8;
550
+ }
551
+ score += extractRelationTerms(query.toLowerCase()).filter(
552
+ (term) => content.includes(term)
553
+ ).length * 6;
554
+ }
555
+ if (typeof item.score === "number" && Number.isFinite(item.score)) {
556
+ score += Math.min(5, Math.max(0, item.score / 20));
557
+ }
558
+ return score;
559
+ }
560
+ function classifyFocusedListIntent(query) {
561
+ const normalized = query.toLowerCase();
562
+ if (/\bhow many\b/.test(normalized) && /\b(?:different|times?|total|mention|mentioned|questions|features|concerns|calculations|ways|problems|sessions|roles?)\b/.test(
563
+ normalized
564
+ )) {
565
+ return "count";
566
+ }
567
+ if (isSpecialEventLocationQuery(normalized)) {
568
+ return "relation";
569
+ }
570
+ if (/\b(?:what|which|where|suggest|recommend|should|advice|features?)\b/.test(normalized) && /\b(?:places?|locations?|writing|sneakers?|shoes?|features?)\b/.test(normalized)) {
571
+ return "recommendation";
572
+ }
573
+ if (/\b(?:where|when|how)\b/.test(normalized) && /\b(?:met|meet|meeting|know|connected|introduced)\b/.test(normalized)) {
574
+ return "relation";
575
+ }
576
+ return null;
577
+ }
578
+ function buildFocusedListQuery(query, intent) {
579
+ const cues = [query, ...extractFocusedTerms(query).slice(0, 16)];
580
+ if (intent === "count") {
581
+ cues.push(
582
+ "count distinct mentioned confirmed verified checked tried asked wanted feature concern calculation"
583
+ );
584
+ if (isProbabilityCountQuery(query)) {
585
+ cues.push("coin toss dice roll probability calculation confirm verify check formula");
586
+ }
587
+ if (isWeatherFeatureCountQuery(query)) {
588
+ cues.push("weather app autocomplete error handling caching quota GitHub Pages HTTPS deployment");
589
+ }
590
+ if (isCoverLetterCountQuery(query)) {
591
+ cues.push("cover letter submit revise draft feedback interview preparation");
592
+ }
593
+ if (isSecurityFeatureCountQuery(query)) {
594
+ cues.push("security authentication user roles password hashing role-based access control RBAC account lockout failed login attempts");
595
+ }
596
+ if (isSoySauceSubstituteCountQuery(query)) {
597
+ cues.push("soy sauce substitute substitutes coconut aminos liquid aminos allergy soy-free stir-fry bought replaced");
598
+ }
599
+ } else {
600
+ cues.push("recommend suggest preference advice should consider features places options");
601
+ if (isWritingPlaceRecommendationQuery(query)) {
602
+ cues.push("writing morning focus quiet library cafe coffee place personal statement productivity");
603
+ }
604
+ if (isSneakerFeatureRecommendationQuery(query)) {
605
+ cues.push("sneaker shoe comfort support cushioning breathability fit injury arch break-in");
606
+ }
607
+ }
608
+ if (intent === "relation") {
609
+ cues.push("met where location place on set studio introduced connected recommended relationship person special events planning resort dinner restaurant");
610
+ if (isSpecialEventLocationQuery(query)) {
611
+ cues.push("weekend getaway anniversary dinner venue resort restaurant date planning");
612
+ }
613
+ }
614
+ return cues.join(" ");
615
+ }
616
+ function focusedListTitle(intent) {
617
+ if (intent === "count") return "Focused count evidence";
618
+ if (intent === "recommendation") return "Focused recommendation evidence";
619
+ return "Focused relation evidence";
620
+ }
621
+ function isProbabilityCountQuery(query) {
622
+ const normalized = query.toLowerCase();
623
+ return /\b(?:probability|calculations?)\b/.test(normalized) && /\b(?:coin|coins|tossing|toss|dice|die|rolling|roll)\b/.test(normalized);
624
+ }
625
+ function isWeatherFeatureCountQuery(query) {
626
+ const normalized = query.toLowerCase();
627
+ return /\bweather app\b/.test(normalized) && /\b(?:features?|concerns?|handle|wanting|wanted|mentioned)\b/.test(normalized);
628
+ }
629
+ function isCoverLetterCountQuery(query) {
630
+ const normalized = query.toLowerCase();
631
+ return /\bcover letter\b/.test(normalized) && /\b(?:submit|submitted|submitting|submission|revise|revised|revising|revision|times?)\b/.test(
632
+ normalized
633
+ );
634
+ }
635
+ function isSecurityFeatureCountQuery(query) {
636
+ const normalized = query.toLowerCase();
637
+ return /\bhow many\b/.test(normalized) && /\b(?:security|authentication|authorization|auth|user roles?|roles?|permissions?)\b/.test(normalized) && /\b(?:features?|roles?|implement|across|sessions|trying)\b/.test(normalized);
638
+ }
639
+ function isSoySauceSubstituteCountQuery(query) {
640
+ const normalized = query.toLowerCase();
641
+ return /\bhow many\b/.test(normalized) && /\bsoy sauce\b/.test(normalized) && /\bsubstitutes?\b/.test(normalized);
642
+ }
643
+ function isSoySauceSubstituteEvidenceText(content) {
644
+ return /\bsoy sauce\b/.test(content) && /\b(?:coconut aminos|liquid aminos)\b/.test(content) && /\b(?:substitute|replace|replaced|instead of|remov(?:e|ed|ing)|buy|buying|bought|use|using)\b/.test(
645
+ content
646
+ );
647
+ }
648
+ function isWritingPlaceRecommendationQuery(query) {
649
+ const normalized = query.toLowerCase();
650
+ return /\bwriting\b/.test(normalized) && /\b(?:places?|locations?|where|spend)\b/.test(normalized);
651
+ }
652
+ function isSneakerFeatureRecommendationQuery(query) {
653
+ const normalized = query.toLowerCase();
654
+ return /\b(?:sneakers?|shoes?)\b/.test(normalized) && /\b(?:features?|pay attention|attention|should)\b/.test(normalized);
655
+ }
656
+ function isSpecialEventLocationQuery(query) {
657
+ const normalized = query.toLowerCase();
658
+ return /\b(?:what|where|which)\b/.test(normalized) && /\b(?:special events?|planning with|take place|where will|events? am i planning)\b/.test(
659
+ normalized
660
+ );
661
+ }
662
+ function extractSpecialEventPersonTerms(text) {
663
+ return extractFocusedTerms(text).filter(
664
+ (term) => !SPECIAL_EVENT_STOP_WORDS.has(term) && term.length >= 4
665
+ );
666
+ }
667
+ function hasConfirmIntent(content) {
668
+ return /\b(?:confirm|verify|check|get it right|is correct|doing it right|make sure i (?:get|got|am getting|understood) it right|make sure i'm doing it right)\b/.test(
669
+ content
670
+ );
671
+ }
672
+ function extractProbabilityFormulas(content) {
673
+ const formulas = /* @__PURE__ */ new Map();
674
+ for (const match of content.matchAll(/\bP\s*\(([^)]{1,100})\)\s*(?:=|≈|≠)\s*([^,.;\n?]{1,120})/gi)) {
675
+ const event = cleanFormulaPart(match[1] ?? "");
676
+ const value = cleanFormulaPart(match[2] ?? "");
677
+ if (!event || !value) continue;
678
+ const formula = `P(${event}) = ${value}`;
679
+ formulas.set(normalizeProbabilityCandidateKey(formula), formula);
680
+ }
681
+ for (const match of content.matchAll(/\bprobability of ([^,.;?\n]{4,100})\s+(?:is|would be|=)\s+([^,.;?\n]{1,80})/gi)) {
682
+ const event = cleanFormulaPart(match[1] ?? "");
683
+ const value = cleanFormulaPart(match[2] ?? "");
684
+ if (!event || !value) continue;
685
+ const formula = `probability of ${event} = ${value}`;
686
+ formulas.set(normalizeProbabilityCandidateKey(formula), formula);
687
+ }
688
+ for (const match of content.matchAll(/\bP\(([^)]{1,100})\)\s+using the formula\s+([^,.;?\n]{1,100})/gi)) {
689
+ const event = cleanFormulaPart(match[1] ?? "");
690
+ const value = cleanFormulaPart(match[2] ?? "");
691
+ if (!event || !value) continue;
692
+ const formula = `P(${event}) = ${value}`;
693
+ formulas.set(normalizeProbabilityCandidateKey(formula), formula);
694
+ }
695
+ return [...formulas.values()];
696
+ }
697
+ function cleanFormulaPart(value) {
698
+ return value.replace(/\s+/g, " ").replace(/\s*->->.*$/g, "").replace(/\s+and\s+how\b.*$/i, "").replace(/\s+i want\b.*$/i, "").replace(/\s+as this\b.*$/i, "").trim();
699
+ }
700
+ function summarizeCoverLetterCandidate(content) {
701
+ const text = content.replace(/\s+/g, " ").replace(/\s*->->.*$/g, "").trim();
702
+ const clauses = text.split(/(?<=[.!?])\s+|,\s+(?=but|and|so|can|what|how)/i);
703
+ const focused = clauses.find(
704
+ (clause) => /\bcover letter\b/i.test(clause) && /\b(?:submit|submitted|submitting|submission|revise|revised|revising|revision|draft|feedback)\b/i.test(
705
+ clause
706
+ )
707
+ );
708
+ return clipSummaryLabel(focused ?? text);
709
+ }
710
+ function isStrictSimpleCoinDiceConfirmation(formula, content) {
711
+ const normalizedFormula = formula.toLowerCase();
712
+ const normalizedContent = content.toLowerCase();
713
+ if (!hasConfirmIntent(normalizedContent)) {
714
+ return false;
715
+ }
716
+ if (!/\b(?:heads|coin|coins|toss|tosses|rolling|roll|die|dice)\b/.test(
717
+ `${normalizedFormula} ${normalizedContent}`
718
+ )) {
719
+ return false;
720
+ }
721
+ if (!/=\s*(?:[^.;]*\d+\s*\/\s*\d+|0\b|[^.;]*\d+(?:\.\d+)?%)/.test(normalizedFormula)) {
722
+ return false;
723
+ }
724
+ if (/\b(?:first die|second die|two dice|sum of|deck|card|ace|king|queen|heart|birthday|conditional|dependent)\b/.test(normalizedFormula)) {
725
+ return false;
726
+ }
727
+ if (/^p\(\s*a\b/.test(normalizedFormula)) {
728
+ return false;
729
+ }
730
+ if (/\bnumber of problems\b/.test(normalizedContent)) {
731
+ return false;
732
+ }
733
+ return true;
734
+ }
735
+ function isStrictSimpleProbabilityLabel(label) {
736
+ const normalizedFormula = label.toLowerCase();
737
+ return /\b(?:heads|coin|coins|toss|tosses|rolling|roll|die|dice)\b/.test(
738
+ normalizedFormula
739
+ ) && /=\s*(?:[^.;]*\d+\s*\/\s*\d+|0\b|[^.;]*\d+(?:\.\d+)?%)/.test(
740
+ normalizedFormula
741
+ ) && !/\b(?:first die|second die|two dice|sum of|deck|card|ace|king|queen|heart|birthday|conditional|dependent)\b/.test(
742
+ normalizedFormula
743
+ ) && !/^p\(\s*a\b/.test(normalizedFormula);
744
+ }
745
+ function findTemporalCutoffTurn(items, query, cutoffPattern) {
746
+ if (!/\bbefore\b/i.test(query)) {
747
+ return void 0;
748
+ }
749
+ let cutoff;
750
+ for (const item of items) {
751
+ if (typeof item.turnIndex !== "number") continue;
752
+ if (!cutoffPattern.test(item.content)) continue;
753
+ cutoff = cutoff === void 0 ? item.turnIndex : Math.min(cutoff, item.turnIndex);
754
+ }
755
+ return cutoff;
756
+ }
757
+ function sortCountCandidates(left, right) {
758
+ const leftTurn = typeof left.turnIndex === "number" ? left.turnIndex : Number.MAX_SAFE_INTEGER;
759
+ const rightTurn = typeof right.turnIndex === "number" ? right.turnIndex : Number.MAX_SAFE_INTEGER;
760
+ if (leftTurn !== rightTurn) return leftTurn - rightTurn;
761
+ return left.label.localeCompare(right.label);
762
+ }
763
+ function clipSummaryLabel(value) {
764
+ const trimmed = value.trim();
765
+ return trimmed.length <= 180 ? trimmed : `${trimmed.slice(0, 177).trimEnd()}...`;
766
+ }
767
+ function normalizeCountCandidateKey(value) {
768
+ return value.toLowerCase().replace(/\s+/g, " ").replace(/[“”]/g, '"').replace(/[’]/g, "'").replace(/\bthe\b/g, "").replace(/\s+/g, " ").trim();
769
+ }
770
+ function normalizeProbabilityCandidateKey(value) {
771
+ return normalizeCountCandidateKey(value).replace(/\s+(?:so|because|as)\b.*$/g, "").replace(/\s+one more time\b.*$/g, "").replace(/\s+is correct\b.*$/g, "").replace(/\s+correct\b.*$/g, "").trim();
772
+ }
773
+ function numberWord(value) {
774
+ return NUMBER_WORDS[value];
775
+ }
776
+ function countFocusedTermOverlap(content, query) {
777
+ const terms = extractFocusedTerms(query);
778
+ let overlap = 0;
779
+ for (const term of terms) {
780
+ if (content.includes(term)) overlap += 1;
781
+ }
782
+ return overlap;
783
+ }
784
+ function extractFocusedTerms(text) {
785
+ const terms = text.toLowerCase().match(/[a-z][a-z0-9-]{2,}/g) ?? [];
786
+ return [...new Set(terms.filter(
787
+ (term) => !FOCUSED_LIST_STOP_WORDS.has(term) && !/^\d+$/.test(term)
788
+ ))];
789
+ }
790
+ function extractRelationTerms(text) {
791
+ return extractFocusedTerms(text).filter(
792
+ (term) => !RELATION_STOP_WORDS.has(term) && !/\b(?:met|meet|meeting|know|connected|introduced)\b/.test(term)
793
+ );
794
+ }
795
+ function normalizePositiveInteger(value) {
796
+ if (!Number.isFinite(value) || value <= 0) {
797
+ return 0;
798
+ }
799
+ return Math.floor(value);
800
+ }
801
+ function clipTextToBudget(text, maxChars) {
802
+ if (text.length <= maxChars) {
803
+ return text;
804
+ }
805
+ if (maxChars <= 3) {
806
+ return text.slice(0, Math.max(0, maxChars));
807
+ }
808
+ return `${text.slice(0, maxChars - 3).trimEnd()}...`;
809
+ }
810
+ var FOCUSED_LIST_STOP_WORDS = /* @__PURE__ */ new Set([
811
+ "about",
812
+ "across",
813
+ "after",
814
+ "also",
815
+ "and",
816
+ "are",
817
+ "before",
818
+ "between",
819
+ "can",
820
+ "could",
821
+ "did",
822
+ "different",
823
+ "does",
824
+ "for",
825
+ "from",
826
+ "have",
827
+ "how",
828
+ "into",
829
+ "many",
830
+ "mention",
831
+ "mentioned",
832
+ "next",
833
+ "off",
834
+ "pay",
835
+ "planning",
836
+ "should",
837
+ "some",
838
+ "spend",
839
+ "that",
840
+ "the",
841
+ "this",
842
+ "time",
843
+ "times",
844
+ "total",
845
+ "want",
846
+ "wanted",
847
+ "wanting",
848
+ "were",
849
+ "what",
850
+ "when",
851
+ "where",
852
+ "which",
853
+ "with",
854
+ "would",
855
+ "you"
856
+ ]);
857
+ var RELATION_STOP_WORDS = /* @__PURE__ */ new Set([
858
+ "did",
859
+ "how",
860
+ "know",
861
+ "meet",
862
+ "met",
863
+ "say",
864
+ "saying",
865
+ "when",
866
+ "where"
867
+ ]);
868
+ var SPECIAL_EVENT_STOP_WORDS = /* @__PURE__ */ new Set([
869
+ "events",
870
+ "event",
871
+ "planning",
872
+ "place",
873
+ "special",
874
+ "take",
875
+ "where",
876
+ "will"
877
+ ]);
878
+ var NUMBER_WORDS = {
879
+ 0: "zero",
880
+ 1: "one",
881
+ 2: "two",
882
+ 3: "three",
883
+ 4: "four",
884
+ 5: "five",
885
+ 6: "six",
886
+ 7: "seven",
887
+ 8: "eight",
888
+ 9: "nine",
889
+ 10: "ten",
890
+ 11: "eleven",
891
+ 12: "twelve",
892
+ 13: "thirteen",
893
+ 14: "fourteen",
894
+ 15: "fifteen",
895
+ 16: "sixteen",
896
+ 17: "seventeen",
897
+ 18: "eighteen",
898
+ 19: "nineteen",
899
+ 20: "twenty"
900
+ };
901
+
902
+ export {
903
+ shouldRecallFocusedListEvidence,
904
+ buildFocusedListRecallSection
905
+ };
906
+ //# sourceMappingURL=chunk-DB5A3NHS.js.map