@cchistory/lite 0.4.4 → 0.5.0

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 (542) hide show
  1. package/INSTALL.md +1 -1
  2. package/apps/lite-cli/dist/agent-contract.d.ts +4 -5
  3. package/apps/lite-cli/dist/agent-contract.d.ts.map +1 -1
  4. package/apps/lite-cli/dist/agent-contract.js +35 -28
  5. package/apps/lite-cli/dist/agent-contract.js.map +1 -1
  6. package/apps/lite-cli/dist/bin.js +3 -3
  7. package/apps/lite-cli/dist/bin.js.map +1 -1
  8. package/apps/lite-cli/dist/index.d.ts.map +1 -1
  9. package/apps/lite-cli/dist/index.js +155 -81
  10. package/apps/lite-cli/dist/index.js.map +1 -1
  11. package/apps/lite-cli/dist/index.test.js +87 -63
  12. package/apps/lite-cli/dist/index.test.js.map +1 -1
  13. package/apps/lite-cli/dist/query.d.ts +4 -1
  14. package/apps/lite-cli/dist/query.d.ts.map +1 -1
  15. package/apps/lite-cli/dist/query.js +45 -29
  16. package/apps/lite-cli/dist/query.js.map +1 -1
  17. package/apps/lite-cli/dist/resource-errors.d.ts +3 -0
  18. package/apps/lite-cli/dist/resource-errors.d.ts.map +1 -0
  19. package/apps/lite-cli/dist/resource-errors.js +17 -0
  20. package/apps/lite-cli/dist/resource-errors.js.map +1 -0
  21. package/apps/lite-cli/dist/shell.d.ts +12 -2
  22. package/apps/lite-cli/dist/shell.d.ts.map +1 -1
  23. package/apps/lite-cli/dist/shell.js +129 -57
  24. package/apps/lite-cli/dist/shell.js.map +1 -1
  25. package/apps/lite-cli/dist/sql-query.test.d.ts +2 -0
  26. package/apps/lite-cli/dist/sql-query.test.d.ts.map +1 -0
  27. package/apps/lite-cli/dist/sql-query.test.js +290 -0
  28. package/apps/lite-cli/dist/sql-query.test.js.map +1 -0
  29. package/apps/lite-cli/dist/version.d.ts +1 -1
  30. package/apps/lite-cli/dist/version.js +1 -1
  31. package/apps/lite-tui/dist/bin.js +3 -3
  32. package/apps/lite-tui/dist/bin.js.map +1 -1
  33. package/apps/lite-tui/dist/index.d.ts.map +1 -1
  34. package/apps/lite-tui/dist/index.js +2 -2
  35. package/apps/lite-tui/dist/index.js.map +1 -1
  36. package/apps/lite-tui/dist/index.test.js +5 -3
  37. package/apps/lite-tui/dist/index.test.js.map +1 -1
  38. package/apps/lite-tui/dist/render.d.ts +1 -1
  39. package/apps/lite-tui/dist/version.d.ts +1 -1
  40. package/apps/lite-tui/dist/version.js +1 -1
  41. package/bin/cchistory-lite-tui.mjs +3 -3
  42. package/bin/cchistory-lite.mjs +3 -3
  43. package/docs/guide/for-agents.md +65 -42
  44. package/docs/guide/lite.md +64 -24
  45. package/docs/guide/queries/latest-sessions.sql +4 -0
  46. package/docs/guide/queries/latest-turns.sql +1 -0
  47. package/docs/guide/queries/list-sessions.sql +2 -0
  48. package/docs/guide/query.md +153 -0
  49. package/node_modules/@cchistory/canonical/dist/directory-scope.d.ts +7 -0
  50. package/node_modules/@cchistory/canonical/dist/directory-scope.d.ts.map +1 -1
  51. package/node_modules/@cchistory/canonical/dist/directory-scope.js +11 -0
  52. package/node_modules/@cchistory/canonical/dist/directory-scope.js.map +1 -1
  53. package/node_modules/@cchistory/canonical/dist/index.d.ts +5 -1
  54. package/node_modules/@cchistory/canonical/dist/index.d.ts.map +1 -1
  55. package/node_modules/@cchistory/canonical/dist/index.js +5 -1
  56. package/node_modules/@cchistory/canonical/dist/index.js.map +1 -1
  57. package/node_modules/@cchistory/canonical/dist/query.d.ts +15 -0
  58. package/node_modules/@cchistory/canonical/dist/query.d.ts.map +1 -0
  59. package/node_modules/@cchistory/canonical/dist/query.js +208 -0
  60. package/node_modules/@cchistory/canonical/dist/query.js.map +1 -0
  61. package/node_modules/@cchistory/canonical/dist/session-family.d.ts +1 -0
  62. package/node_modules/@cchistory/canonical/dist/session-family.d.ts.map +1 -1
  63. package/node_modules/@cchistory/canonical/dist/session-family.js +3 -0
  64. package/node_modules/@cchistory/canonical/dist/session-family.js.map +1 -1
  65. package/node_modules/@cchistory/canonical/dist/session-family.test.js +61 -0
  66. package/node_modules/@cchistory/canonical/dist/session-family.test.js.map +1 -1
  67. package/node_modules/@cchistory/canonical/dist/session-interpreter.d.ts +30 -0
  68. package/node_modules/@cchistory/canonical/dist/session-interpreter.d.ts.map +1 -0
  69. package/node_modules/@cchistory/canonical/dist/session-interpreter.js +713 -0
  70. package/node_modules/@cchistory/canonical/dist/session-interpreter.js.map +1 -0
  71. package/node_modules/@cchistory/canonical/dist/session-interpreter.test.d.ts +2 -0
  72. package/node_modules/@cchistory/canonical/dist/session-interpreter.test.d.ts.map +1 -0
  73. package/node_modules/@cchistory/canonical/dist/session-interpreter.test.js +56 -0
  74. package/node_modules/@cchistory/canonical/dist/session-interpreter.test.js.map +1 -0
  75. package/node_modules/@cchistory/canonical/package.json +1 -1
  76. package/node_modules/@cchistory/domain/dist/evidence-atoms.d.ts +7 -0
  77. package/node_modules/@cchistory/domain/dist/evidence-atoms.d.ts.map +1 -0
  78. package/node_modules/@cchistory/domain/dist/evidence-atoms.js +36 -0
  79. package/node_modules/@cchistory/domain/dist/evidence-atoms.js.map +1 -0
  80. package/node_modules/@cchistory/domain/dist/evidence-values.d.ts +26 -0
  81. package/node_modules/@cchistory/domain/dist/evidence-values.d.ts.map +1 -0
  82. package/node_modules/@cchistory/domain/dist/evidence-values.js +80 -0
  83. package/node_modules/@cchistory/domain/dist/evidence-values.js.map +1 -0
  84. package/node_modules/@cchistory/domain/dist/index.d.ts +6 -0
  85. package/node_modules/@cchistory/domain/dist/index.d.ts.map +1 -1
  86. package/node_modules/@cchistory/domain/dist/index.js +5 -0
  87. package/node_modules/@cchistory/domain/dist/index.js.map +1 -1
  88. package/node_modules/@cchistory/domain/dist/masks.d.ts +31 -0
  89. package/node_modules/@cchistory/domain/dist/masks.d.ts.map +1 -0
  90. package/node_modules/@cchistory/domain/dist/masks.js +342 -0
  91. package/node_modules/@cchistory/domain/dist/masks.js.map +1 -0
  92. package/node_modules/@cchistory/domain/dist/parsed-session.d.ts +58 -0
  93. package/node_modules/@cchistory/domain/dist/parsed-session.d.ts.map +1 -0
  94. package/node_modules/@cchistory/domain/dist/parsed-session.js +2 -0
  95. package/node_modules/@cchistory/domain/dist/parsed-session.js.map +1 -0
  96. package/node_modules/@cchistory/domain/dist/query.d.ts +67 -0
  97. package/node_modules/@cchistory/domain/dist/query.d.ts.map +1 -0
  98. package/node_modules/@cchistory/domain/dist/query.js +2 -0
  99. package/node_modules/@cchistory/domain/dist/query.js.map +1 -0
  100. package/node_modules/@cchistory/domain/dist/token-evidence.d.ts +14 -0
  101. package/node_modules/@cchistory/domain/dist/token-evidence.d.ts.map +1 -0
  102. package/node_modules/@cchistory/domain/dist/token-evidence.js +247 -0
  103. package/node_modules/@cchistory/domain/dist/token-evidence.js.map +1 -0
  104. package/node_modules/@cchistory/domain/package.json +1 -1
  105. package/node_modules/@cchistory/live-runtime/dist/bootstrap.d.ts +0 -1
  106. package/node_modules/@cchistory/live-runtime/dist/bootstrap.d.ts.map +1 -1
  107. package/node_modules/@cchistory/live-runtime/dist/bootstrap.js +0 -1
  108. package/node_modules/@cchistory/live-runtime/dist/bootstrap.js.map +1 -1
  109. package/node_modules/@cchistory/live-runtime/dist/index.d.ts +30 -9
  110. package/node_modules/@cchistory/live-runtime/dist/index.d.ts.map +1 -1
  111. package/node_modules/@cchistory/live-runtime/dist/index.js +263 -58
  112. package/node_modules/@cchistory/live-runtime/dist/index.js.map +1 -1
  113. package/node_modules/@cchistory/live-runtime/dist/index.test.js +177 -20
  114. package/node_modules/@cchistory/live-runtime/dist/index.test.js.map +1 -1
  115. package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.d.ts +16 -0
  116. package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.d.ts.map +1 -0
  117. package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.js +55 -0
  118. package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.js.map +1 -0
  119. package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.d.ts +2 -0
  120. package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.d.ts.map +1 -0
  121. package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.js +192 -0
  122. package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.js.map +1 -0
  123. package/node_modules/@cchistory/live-runtime/dist/scan-guard.d.ts +32 -23
  124. package/node_modules/@cchistory/live-runtime/dist/scan-guard.d.ts.map +1 -1
  125. package/node_modules/@cchistory/live-runtime/dist/scan-guard.js +65 -45
  126. package/node_modules/@cchistory/live-runtime/dist/scan-guard.js.map +1 -1
  127. package/node_modules/@cchistory/live-runtime/dist/scan-guard.test.js +363 -59
  128. package/node_modules/@cchistory/live-runtime/dist/scan-guard.test.js.map +1 -1
  129. package/node_modules/@cchistory/live-runtime/dist/selective-query.d.ts +47 -0
  130. package/node_modules/@cchistory/live-runtime/dist/selective-query.d.ts.map +1 -0
  131. package/node_modules/@cchistory/live-runtime/dist/selective-query.js +15 -0
  132. package/node_modules/@cchistory/live-runtime/dist/selective-query.js.map +1 -0
  133. package/node_modules/@cchistory/live-runtime/dist/selective-query.test.d.ts +2 -0
  134. package/node_modules/@cchistory/live-runtime/dist/selective-query.test.d.ts.map +1 -0
  135. package/node_modules/@cchistory/live-runtime/dist/selective-query.test.js +166 -0
  136. package/node_modules/@cchistory/live-runtime/dist/selective-query.test.js.map +1 -0
  137. package/node_modules/@cchistory/live-runtime/dist/sql-query.d.ts +37 -0
  138. package/node_modules/@cchistory/live-runtime/dist/sql-query.d.ts.map +1 -0
  139. package/node_modules/@cchistory/live-runtime/dist/sql-query.js +301 -0
  140. package/node_modules/@cchistory/live-runtime/dist/sql-query.js.map +1 -0
  141. package/node_modules/@cchistory/live-runtime/dist/sql-query.test.d.ts +2 -0
  142. package/node_modules/@cchistory/live-runtime/dist/sql-query.test.d.ts.map +1 -0
  143. package/node_modules/@cchistory/live-runtime/dist/sql-query.test.js +67 -0
  144. package/node_modules/@cchistory/live-runtime/dist/sql-query.test.js.map +1 -0
  145. package/node_modules/@cchistory/live-runtime/dist/sql-worker.d.ts +2 -0
  146. package/node_modules/@cchistory/live-runtime/dist/sql-worker.d.ts.map +1 -0
  147. package/node_modules/@cchistory/live-runtime/dist/sql-worker.js +14 -0
  148. package/node_modules/@cchistory/live-runtime/dist/sql-worker.js.map +1 -0
  149. package/node_modules/@cchistory/live-runtime/dist/system-memory.d.ts +13 -10
  150. package/node_modules/@cchistory/live-runtime/dist/system-memory.d.ts.map +1 -1
  151. package/node_modules/@cchistory/live-runtime/dist/system-memory.js +61 -34
  152. package/node_modules/@cchistory/live-runtime/dist/system-memory.js.map +1 -1
  153. package/node_modules/@cchistory/live-runtime/dist/system-memory.test.d.ts +2 -0
  154. package/node_modules/@cchistory/live-runtime/dist/system-memory.test.d.ts.map +1 -0
  155. package/node_modules/@cchistory/live-runtime/dist/system-memory.test.js +76 -0
  156. package/node_modules/@cchistory/live-runtime/dist/system-memory.test.js.map +1 -0
  157. package/node_modules/@cchistory/live-runtime/package.json +1 -1
  158. package/node_modules/@cchistory/source-adapters/dist/core/discovery.test.js +2 -1
  159. package/node_modules/@cchistory/source-adapters/dist/core/discovery.test.js.map +1 -1
  160. package/node_modules/@cchistory/source-adapters/dist/core/factories.d.ts +2 -4
  161. package/node_modules/@cchistory/source-adapters/dist/core/factories.d.ts.map +1 -1
  162. package/node_modules/@cchistory/source-adapters/dist/core/factories.js +1 -23
  163. package/node_modules/@cchistory/source-adapters/dist/core/factories.js.map +1 -1
  164. package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.d.ts +25 -0
  165. package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.d.ts.map +1 -0
  166. package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.js +80 -0
  167. package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.js.map +1 -0
  168. package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.d.ts +2 -0
  169. package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.d.ts.map +1 -0
  170. package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.js +122 -0
  171. package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.js.map +1 -0
  172. package/node_modules/@cchistory/source-adapters/dist/core/git-project.d.ts +1 -1
  173. package/node_modules/@cchistory/source-adapters/dist/core/git-project.d.ts.map +1 -1
  174. package/node_modules/@cchistory/source-adapters/dist/core/git-project.js +2 -11
  175. package/node_modules/@cchistory/source-adapters/dist/core/git-project.js.map +1 -1
  176. package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts +2 -1
  177. package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts.map +1 -1
  178. package/node_modules/@cchistory/source-adapters/dist/core/parser.js +4 -4
  179. package/node_modules/@cchistory/source-adapters/dist/core/parser.js.map +1 -1
  180. package/node_modules/@cchistory/source-adapters/dist/core/probe.d.ts +8 -6
  181. package/node_modules/@cchistory/source-adapters/dist/core/probe.d.ts.map +1 -1
  182. package/node_modules/@cchistory/source-adapters/dist/core/probe.js +54 -36
  183. package/node_modules/@cchistory/source-adapters/dist/core/probe.js.map +1 -1
  184. package/node_modules/@cchistory/source-adapters/dist/core/projections.d.ts +2 -28
  185. package/node_modules/@cchistory/source-adapters/dist/core/projections.d.ts.map +1 -1
  186. package/node_modules/@cchistory/source-adapters/dist/core/projections.js +2 -695
  187. package/node_modules/@cchistory/source-adapters/dist/core/projections.js.map +1 -1
  188. package/node_modules/@cchistory/source-adapters/dist/core/projections.test.js +2 -1
  189. package/node_modules/@cchistory/source-adapters/dist/core/projections.test.js.map +1 -1
  190. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.d.ts +18 -0
  191. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.d.ts.map +1 -0
  192. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.js +27 -0
  193. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.js.map +1 -0
  194. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.d.ts +2 -0
  195. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.d.ts.map +1 -0
  196. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.js +75 -0
  197. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.js.map +1 -0
  198. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.d.ts +6 -0
  199. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.d.ts.map +1 -1
  200. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.js +1 -1
  201. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.js.map +1 -1
  202. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.test.js +1 -1
  203. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.test.js.map +1 -1
  204. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts +1 -1
  205. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts.map +1 -1
  206. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js +1 -1
  207. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js.map +1 -1
  208. package/node_modules/@cchistory/source-adapters/dist/core/token-usage.d.ts +1 -13
  209. package/node_modules/@cchistory/source-adapters/dist/core/token-usage.d.ts.map +1 -1
  210. package/node_modules/@cchistory/source-adapters/dist/core/token-usage.js +1 -246
  211. package/node_modules/@cchistory/source-adapters/dist/core/token-usage.js.map +1 -1
  212. package/node_modules/@cchistory/source-adapters/dist/core/tokens.test.js +1 -1
  213. package/node_modules/@cchistory/source-adapters/dist/core/tokens.test.js.map +1 -1
  214. package/node_modules/@cchistory/source-adapters/dist/core/type-guards.d.ts +1 -25
  215. package/node_modules/@cchistory/source-adapters/dist/core/type-guards.d.ts.map +1 -1
  216. package/node_modules/@cchistory/source-adapters/dist/core/type-guards.js +1 -79
  217. package/node_modules/@cchistory/source-adapters/dist/core/type-guards.js.map +1 -1
  218. package/node_modules/@cchistory/source-adapters/dist/core/types.d.ts +6 -35
  219. package/node_modules/@cchistory/source-adapters/dist/core/types.d.ts.map +1 -1
  220. package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.d.ts +2 -1
  221. package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.d.ts.map +1 -1
  222. package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.js +14 -10
  223. package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.js.map +1 -1
  224. package/node_modules/@cchistory/source-adapters/dist/index.d.ts +6 -0
  225. package/node_modules/@cchistory/source-adapters/dist/index.d.ts.map +1 -1
  226. package/node_modules/@cchistory/source-adapters/dist/index.js +4 -0
  227. package/node_modules/@cchistory/source-adapters/dist/index.js.map +1 -1
  228. package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts +2 -0
  229. package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts.map +1 -1
  230. package/node_modules/@cchistory/source-adapters/dist/index.test.js +2 -0
  231. package/node_modules/@cchistory/source-adapters/dist/index.test.js.map +1 -1
  232. package/node_modules/@cchistory/source-adapters/dist/masks.d.ts +1 -30
  233. package/node_modules/@cchistory/source-adapters/dist/masks.d.ts.map +1 -1
  234. package/node_modules/@cchistory/source-adapters/dist/masks.js +1 -341
  235. package/node_modules/@cchistory/source-adapters/dist/masks.js.map +1 -1
  236. package/node_modules/@cchistory/source-adapters/dist/platforms/accio.test.js +1 -1
  237. package/node_modules/@cchistory/source-adapters/dist/platforms/accio.test.js.map +1 -1
  238. package/node_modules/@cchistory/source-adapters/dist/platforms/amp.test.js +1 -1
  239. package/node_modules/@cchistory/source-adapters/dist/platforms/amp.test.js.map +1 -1
  240. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.test.js +2 -1
  241. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.test.js.map +1 -1
  242. package/node_modules/@cchistory/source-adapters/dist/platforms/claude.test.js +1 -1
  243. package/node_modules/@cchistory/source-adapters/dist/platforms/claude.test.js.map +1 -1
  244. package/node_modules/@cchistory/source-adapters/dist/platforms/codebuddy.test.js +1 -1
  245. package/node_modules/@cchistory/source-adapters/dist/platforms/codebuddy.test.js.map +1 -1
  246. package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.d.ts +14 -0
  247. package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.d.ts.map +1 -0
  248. package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.js +103 -0
  249. package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.js.map +1 -0
  250. package/node_modules/@cchistory/source-adapters/dist/platforms/codex.test.js +1 -1
  251. package/node_modules/@cchistory/source-adapters/dist/platforms/codex.test.js.map +1 -1
  252. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.d.ts +2 -1
  253. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.d.ts.map +1 -1
  254. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.js +5 -3
  255. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.js.map +1 -1
  256. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.test.js +2 -1
  257. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.test.js.map +1 -1
  258. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor.test.js +2 -1
  259. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor.test.js.map +1 -1
  260. package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid.test.js +1 -1
  261. package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid.test.js.map +1 -1
  262. package/node_modules/@cchistory/source-adapters/dist/platforms/gemini.test.js +2 -1
  263. package/node_modules/@cchistory/source-adapters/dist/platforms/gemini.test.js.map +1 -1
  264. package/node_modules/@cchistory/source-adapters/dist/platforms/grok.d.ts.map +1 -1
  265. package/node_modules/@cchistory/source-adapters/dist/platforms/grok.js +24 -1
  266. package/node_modules/@cchistory/source-adapters/dist/platforms/grok.js.map +1 -1
  267. package/node_modules/@cchistory/source-adapters/dist/platforms/grok.test.js +2 -1
  268. package/node_modules/@cchistory/source-adapters/dist/platforms/grok.test.js.map +1 -1
  269. package/node_modules/@cchistory/source-adapters/dist/platforms/kimi.test.js +2 -1
  270. package/node_modules/@cchistory/source-adapters/dist/platforms/kimi.test.js.map +1 -1
  271. package/node_modules/@cchistory/source-adapters/dist/platforms/lobechat.test.js +1 -1
  272. package/node_modules/@cchistory/source-adapters/dist/platforms/lobechat.test.js.map +1 -1
  273. package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw.test.js +1 -1
  274. package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw.test.js.map +1 -1
  275. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.test.js +2 -1
  276. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.test.js.map +1 -1
  277. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.d.ts +2 -1
  278. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.d.ts.map +1 -1
  279. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.js +11 -9
  280. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.js.map +1 -1
  281. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode.test.js +2 -1
  282. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode.test.js.map +1 -1
  283. package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.d.ts +8 -0
  284. package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.d.ts.map +1 -0
  285. package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.js +7 -0
  286. package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.js.map +1 -0
  287. package/node_modules/@cchistory/source-adapters/dist/test-helpers.js.map +1 -1
  288. package/node_modules/@cchistory/source-adapters/package.json +1 -1
  289. package/node_modules/commander/LICENSE +22 -0
  290. package/node_modules/commander/Readme.md +428 -0
  291. package/node_modules/commander/index.js +1224 -0
  292. package/node_modules/commander/package.json +38 -0
  293. package/node_modules/commander/typings/index.d.ts +310 -0
  294. package/node_modules/discontinuous-range/.npmignore +28 -0
  295. package/node_modules/discontinuous-range/.travis.yml +4 -0
  296. package/node_modules/discontinuous-range/LICENSE +21 -0
  297. package/node_modules/discontinuous-range/README.md +23 -0
  298. package/node_modules/discontinuous-range/index.js +144 -0
  299. package/node_modules/discontinuous-range/package.json +27 -0
  300. package/node_modules/discontinuous-range/test/main-test.js +96 -0
  301. package/node_modules/moo/LICENSE +29 -0
  302. package/node_modules/moo/README.md +385 -0
  303. package/node_modules/moo/moo.js +645 -0
  304. package/node_modules/moo/package.json +29 -0
  305. package/node_modules/nearley/LICENSE.txt +21 -0
  306. package/node_modules/nearley/README.md +80 -0
  307. package/node_modules/nearley/bin/nearley-railroad.js +121 -0
  308. package/node_modules/nearley/bin/nearley-test.js +64 -0
  309. package/node_modules/nearley/bin/nearley-unparse.js +29 -0
  310. package/node_modules/nearley/bin/nearleyc.js +38 -0
  311. package/node_modules/nearley/builtin/cow.ne +2 -0
  312. package/node_modules/nearley/builtin/number.ne +51 -0
  313. package/node_modules/nearley/builtin/postprocessors.ne +36 -0
  314. package/node_modules/nearley/builtin/string.ne +26 -0
  315. package/node_modules/nearley/builtin/whitespace.ne +5 -0
  316. package/node_modules/nearley/lib/compile.js +307 -0
  317. package/node_modules/nearley/lib/generate.js +244 -0
  318. package/node_modules/nearley/lib/lint.js +28 -0
  319. package/node_modules/nearley/lib/nearley-language-bootstrapped.js +132 -0
  320. package/node_modules/nearley/lib/nearley-language-bootstrapped.ne +126 -0
  321. package/node_modules/nearley/lib/nearley.js +564 -0
  322. package/node_modules/nearley/lib/stream.js +18 -0
  323. package/node_modules/nearley/lib/unparse.js +139 -0
  324. package/node_modules/nearley/package.json +63 -0
  325. package/node_modules/pgsql-ast-parser/ast-mapper.d.ts +237 -0
  326. package/node_modules/pgsql-ast-parser/ast-mapper.d.ts.map +1 -0
  327. package/node_modules/pgsql-ast-parser/ast-mapper.spec.d.ts +3 -0
  328. package/node_modules/pgsql-ast-parser/ast-mapper.spec.d.ts.map +1 -0
  329. package/node_modules/pgsql-ast-parser/ast-visitor.d.ts +33 -0
  330. package/node_modules/pgsql-ast-parser/ast-visitor.d.ts.map +1 -0
  331. package/node_modules/pgsql-ast-parser/ast-visitor.spec.d.ts +3 -0
  332. package/node_modules/pgsql-ast-parser/ast-visitor.spec.d.ts.map +1 -0
  333. package/node_modules/pgsql-ast-parser/index.d.ts +11 -0
  334. package/node_modules/pgsql-ast-parser/index.d.ts.map +1 -0
  335. package/node_modules/pgsql-ast-parser/index.js +6484 -0
  336. package/node_modules/pgsql-ast-parser/index.js.map +1 -0
  337. package/node_modules/pgsql-ast-parser/interfaces.d.ts +1 -0
  338. package/node_modules/pgsql-ast-parser/interfaces.d.ts.map +1 -0
  339. package/node_modules/pgsql-ast-parser/keywords.d.ts +2 -0
  340. package/node_modules/pgsql-ast-parser/keywords.d.ts.map +1 -0
  341. package/node_modules/pgsql-ast-parser/lexer.d.ts +15 -0
  342. package/node_modules/pgsql-ast-parser/lexer.d.ts.map +1 -0
  343. package/node_modules/pgsql-ast-parser/lexer.spec.d.ts +3 -0
  344. package/node_modules/pgsql-ast-parser/lexer.spec.d.ts.map +1 -0
  345. package/node_modules/pgsql-ast-parser/literal-syntaxes/array-lexer.d.ts +3 -0
  346. package/node_modules/pgsql-ast-parser/literal-syntaxes/array-lexer.d.ts.map +1 -0
  347. package/node_modules/pgsql-ast-parser/literal-syntaxes/array.ne.d.ts +29 -0
  348. package/node_modules/pgsql-ast-parser/literal-syntaxes/array.ne.d.ts.map +1 -0
  349. package/node_modules/pgsql-ast-parser/literal-syntaxes/array.spec.d.ts +3 -0
  350. package/node_modules/pgsql-ast-parser/literal-syntaxes/array.spec.d.ts.map +1 -0
  351. package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric-lexer.d.ts +3 -0
  352. package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric-lexer.d.ts.map +1 -0
  353. package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.ne.d.ts +29 -0
  354. package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.ne.d.ts.map +1 -0
  355. package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.spec.d.ts +3 -0
  356. package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.spec.d.ts.map +1 -0
  357. package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-builder.d.ts +10 -0
  358. package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-builder.d.ts.map +1 -0
  359. package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso-lexer.d.ts +3 -0
  360. package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso-lexer.d.ts.map +1 -0
  361. package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso.ne.d.ts +29 -0
  362. package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso.ne.d.ts.map +1 -0
  363. package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-lexer.d.ts +3 -0
  364. package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-lexer.d.ts.map +1 -0
  365. package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.ne.d.ts +29 -0
  366. package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.ne.d.ts.map +1 -0
  367. package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.spec.d.ts +3 -0
  368. package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.spec.d.ts.map +1 -0
  369. package/node_modules/pgsql-ast-parser/package.json +69 -0
  370. package/node_modules/pgsql-ast-parser/parser.d.ts +33 -0
  371. package/node_modules/pgsql-ast-parser/parser.d.ts.map +1 -0
  372. package/node_modules/pgsql-ast-parser/pg-escape.d.ts +2 -0
  373. package/node_modules/pgsql-ast-parser/pg-escape.d.ts.map +1 -0
  374. package/node_modules/pgsql-ast-parser/readme.md +255 -0
  375. package/node_modules/pgsql-ast-parser/src/ast-mapper.spec.ts +296 -0
  376. package/node_modules/pgsql-ast-parser/src/ast-mapper.ts +1378 -0
  377. package/node_modules/pgsql-ast-parser/src/ast-visitor.spec.ts +57 -0
  378. package/node_modules/pgsql-ast-parser/src/ast-visitor.ts +101 -0
  379. package/node_modules/pgsql-ast-parser/src/index.ts +10 -0
  380. package/node_modules/pgsql-ast-parser/src/interfaces.ts +0 -0
  381. package/node_modules/pgsql-ast-parser/src/keywords.ts +8 -0
  382. package/node_modules/pgsql-ast-parser/src/lexer.spec.ts +245 -0
  383. package/node_modules/pgsql-ast-parser/src/lexer.ts +267 -0
  384. package/node_modules/pgsql-ast-parser/src/literal-syntaxes/array-lexer.ts +27 -0
  385. package/node_modules/pgsql-ast-parser/src/literal-syntaxes/array.ne +18 -0
  386. package/node_modules/pgsql-ast-parser/src/literal-syntaxes/array.spec.ts +55 -0
  387. package/node_modules/pgsql-ast-parser/src/literal-syntaxes/geometric-lexer.ts +26 -0
  388. package/node_modules/pgsql-ast-parser/src/literal-syntaxes/geometric.ne +88 -0
  389. package/node_modules/pgsql-ast-parser/src/literal-syntaxes/geometric.spec.ts +131 -0
  390. package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-builder.ts +148 -0
  391. package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-iso-lexer.ts +17 -0
  392. package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-iso.ne +53 -0
  393. package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-lexer.ts +26 -0
  394. package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval.ne +54 -0
  395. package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval.spec.ts +106 -0
  396. package/node_modules/pgsql-ast-parser/src/parser.ts +142 -0
  397. package/node_modules/pgsql-ast-parser/src/pg-escape.ts +14 -0
  398. package/node_modules/pgsql-ast-parser/src/syntax/alter-index.ne +29 -0
  399. package/node_modules/pgsql-ast-parser/src/syntax/alter-index.spec.ts +35 -0
  400. package/node_modules/pgsql-ast-parser/src/syntax/alter-table.ne +123 -0
  401. package/node_modules/pgsql-ast-parser/src/syntax/alter-table.spec.ts +476 -0
  402. package/node_modules/pgsql-ast-parser/src/syntax/alter-type.ne +33 -0
  403. package/node_modules/pgsql-ast-parser/src/syntax/alter-type.spec.ts +29 -0
  404. package/node_modules/pgsql-ast-parser/src/syntax/ast.ts +1150 -0
  405. package/node_modules/pgsql-ast-parser/src/syntax/base.ne +369 -0
  406. package/node_modules/pgsql-ast-parser/src/syntax/create-extension.ne +17 -0
  407. package/node_modules/pgsql-ast-parser/src/syntax/create-extension.spec.ts +37 -0
  408. package/node_modules/pgsql-ast-parser/src/syntax/create-index.ne +62 -0
  409. package/node_modules/pgsql-ast-parser/src/syntax/create-index.spec.ts +245 -0
  410. package/node_modules/pgsql-ast-parser/src/syntax/create-table.ne +174 -0
  411. package/node_modules/pgsql-ast-parser/src/syntax/create-table.spec.ts +761 -0
  412. package/node_modules/pgsql-ast-parser/src/syntax/create-type.ne +40 -0
  413. package/node_modules/pgsql-ast-parser/src/syntax/create-type.spec.ts +32 -0
  414. package/node_modules/pgsql-ast-parser/src/syntax/create-view.ne +68 -0
  415. package/node_modules/pgsql-ast-parser/src/syntax/create-view.spec.ts +187 -0
  416. package/node_modules/pgsql-ast-parser/src/syntax/deallocate.ne +13 -0
  417. package/node_modules/pgsql-ast-parser/src/syntax/deallocate.spec.ts +19 -0
  418. package/node_modules/pgsql-ast-parser/src/syntax/delete.ne +36 -0
  419. package/node_modules/pgsql-ast-parser/src/syntax/delete.spec.ts +71 -0
  420. package/node_modules/pgsql-ast-parser/src/syntax/drop.ne +28 -0
  421. package/node_modules/pgsql-ast-parser/src/syntax/drop.spec.ts +77 -0
  422. package/node_modules/pgsql-ast-parser/src/syntax/edge-cases.spec.ts +41 -0
  423. package/node_modules/pgsql-ast-parser/src/syntax/expr.ne +350 -0
  424. package/node_modules/pgsql-ast-parser/src/syntax/expr.spec.ts +1638 -0
  425. package/node_modules/pgsql-ast-parser/src/syntax/functions.ne +114 -0
  426. package/node_modules/pgsql-ast-parser/src/syntax/functions.spec.ts +235 -0
  427. package/node_modules/pgsql-ast-parser/src/syntax/insert.ne +63 -0
  428. package/node_modules/pgsql-ast-parser/src/syntax/insert.spec.ts +292 -0
  429. package/node_modules/pgsql-ast-parser/src/syntax/main.ne +77 -0
  430. package/node_modules/pgsql-ast-parser/src/syntax/nearley.d.ts +3 -0
  431. package/node_modules/pgsql-ast-parser/src/syntax/prepare.ne +8 -0
  432. package/node_modules/pgsql-ast-parser/src/syntax/prepare.spec.ts +44 -0
  433. package/node_modules/pgsql-ast-parser/src/syntax/refresh-materialized-view.ne +19 -0
  434. package/node_modules/pgsql-ast-parser/src/syntax/refresh-materialized-view.spec.ts +42 -0
  435. package/node_modules/pgsql-ast-parser/src/syntax/select.ne +223 -0
  436. package/node_modules/pgsql-ast-parser/src/syntax/select.spec.ts +1063 -0
  437. package/node_modules/pgsql-ast-parser/src/syntax/sequence.ne +101 -0
  438. package/node_modules/pgsql-ast-parser/src/syntax/sequence.spec.ts +103 -0
  439. package/node_modules/pgsql-ast-parser/src/syntax/simple-statements.ne +168 -0
  440. package/node_modules/pgsql-ast-parser/src/syntax/simple-statements.spec.ts +327 -0
  441. package/node_modules/pgsql-ast-parser/src/syntax/spec-utils.ts +333 -0
  442. package/node_modules/pgsql-ast-parser/src/syntax/union.ne +18 -0
  443. package/node_modules/pgsql-ast-parser/src/syntax/union.spec.ts +125 -0
  444. package/node_modules/pgsql-ast-parser/src/syntax/update.ne +56 -0
  445. package/node_modules/pgsql-ast-parser/src/syntax/update.spec.ts +87 -0
  446. package/node_modules/pgsql-ast-parser/src/syntax/with.ne +41 -0
  447. package/node_modules/pgsql-ast-parser/src/syntax/with.spec.ts +155 -0
  448. package/node_modules/pgsql-ast-parser/src/to-sql.spec.ts +85 -0
  449. package/node_modules/pgsql-ast-parser/src/to-sql.ts +1555 -0
  450. package/node_modules/pgsql-ast-parser/src/utils.ts +47 -0
  451. package/node_modules/pgsql-ast-parser/syntax/alter-index.spec.d.ts +3 -0
  452. package/node_modules/pgsql-ast-parser/syntax/alter-index.spec.d.ts.map +1 -0
  453. package/node_modules/pgsql-ast-parser/syntax/alter-table.spec.d.ts +3 -0
  454. package/node_modules/pgsql-ast-parser/syntax/alter-table.spec.d.ts.map +1 -0
  455. package/node_modules/pgsql-ast-parser/syntax/alter-type.spec.d.ts +3 -0
  456. package/node_modules/pgsql-ast-parser/syntax/alter-type.spec.d.ts.map +1 -0
  457. package/node_modules/pgsql-ast-parser/syntax/ast.d.ts +826 -0
  458. package/node_modules/pgsql-ast-parser/syntax/ast.d.ts.map +1 -0
  459. package/node_modules/pgsql-ast-parser/syntax/create-extension.spec.d.ts +3 -0
  460. package/node_modules/pgsql-ast-parser/syntax/create-extension.spec.d.ts.map +1 -0
  461. package/node_modules/pgsql-ast-parser/syntax/create-index.spec.d.ts +3 -0
  462. package/node_modules/pgsql-ast-parser/syntax/create-index.spec.d.ts.map +1 -0
  463. package/node_modules/pgsql-ast-parser/syntax/create-table.spec.d.ts +3 -0
  464. package/node_modules/pgsql-ast-parser/syntax/create-table.spec.d.ts.map +1 -0
  465. package/node_modules/pgsql-ast-parser/syntax/create-type.spec.d.ts +3 -0
  466. package/node_modules/pgsql-ast-parser/syntax/create-type.spec.d.ts.map +1 -0
  467. package/node_modules/pgsql-ast-parser/syntax/create-view.spec.d.ts +3 -0
  468. package/node_modules/pgsql-ast-parser/syntax/create-view.spec.d.ts.map +1 -0
  469. package/node_modules/pgsql-ast-parser/syntax/deallocate.spec.d.ts +3 -0
  470. package/node_modules/pgsql-ast-parser/syntax/deallocate.spec.d.ts.map +1 -0
  471. package/node_modules/pgsql-ast-parser/syntax/delete.spec.d.ts +3 -0
  472. package/node_modules/pgsql-ast-parser/syntax/delete.spec.d.ts.map +1 -0
  473. package/node_modules/pgsql-ast-parser/syntax/drop.spec.d.ts +3 -0
  474. package/node_modules/pgsql-ast-parser/syntax/drop.spec.d.ts.map +1 -0
  475. package/node_modules/pgsql-ast-parser/syntax/edge-cases.spec.d.ts +3 -0
  476. package/node_modules/pgsql-ast-parser/syntax/edge-cases.spec.d.ts.map +1 -0
  477. package/node_modules/pgsql-ast-parser/syntax/expr.spec.d.ts +3 -0
  478. package/node_modules/pgsql-ast-parser/syntax/expr.spec.d.ts.map +1 -0
  479. package/node_modules/pgsql-ast-parser/syntax/functions.spec.d.ts +3 -0
  480. package/node_modules/pgsql-ast-parser/syntax/functions.spec.d.ts.map +1 -0
  481. package/node_modules/pgsql-ast-parser/syntax/insert.spec.d.ts +3 -0
  482. package/node_modules/pgsql-ast-parser/syntax/insert.spec.d.ts.map +1 -0
  483. package/node_modules/pgsql-ast-parser/syntax/main.ne.d.ts +29 -0
  484. package/node_modules/pgsql-ast-parser/syntax/main.ne.d.ts.map +1 -0
  485. package/node_modules/pgsql-ast-parser/syntax/prepare.spec.d.ts +3 -0
  486. package/node_modules/pgsql-ast-parser/syntax/prepare.spec.d.ts.map +1 -0
  487. package/node_modules/pgsql-ast-parser/syntax/refresh-materialized-view.spec.d.ts +3 -0
  488. package/node_modules/pgsql-ast-parser/syntax/refresh-materialized-view.spec.d.ts.map +1 -0
  489. package/node_modules/pgsql-ast-parser/syntax/select.spec.d.ts +3 -0
  490. package/node_modules/pgsql-ast-parser/syntax/select.spec.d.ts.map +1 -0
  491. package/node_modules/pgsql-ast-parser/syntax/sequence.spec.d.ts +3 -0
  492. package/node_modules/pgsql-ast-parser/syntax/sequence.spec.d.ts.map +1 -0
  493. package/node_modules/pgsql-ast-parser/syntax/simple-statements.spec.d.ts +3 -0
  494. package/node_modules/pgsql-ast-parser/syntax/simple-statements.spec.d.ts.map +1 -0
  495. package/node_modules/pgsql-ast-parser/syntax/spec-utils.d.ts +35 -0
  496. package/node_modules/pgsql-ast-parser/syntax/spec-utils.d.ts.map +1 -0
  497. package/node_modules/pgsql-ast-parser/syntax/union.spec.d.ts +3 -0
  498. package/node_modules/pgsql-ast-parser/syntax/union.spec.d.ts.map +1 -0
  499. package/node_modules/pgsql-ast-parser/syntax/update.spec.d.ts +3 -0
  500. package/node_modules/pgsql-ast-parser/syntax/update.spec.d.ts.map +1 -0
  501. package/node_modules/pgsql-ast-parser/syntax/with.spec.d.ts +3 -0
  502. package/node_modules/pgsql-ast-parser/syntax/with.spec.d.ts.map +1 -0
  503. package/node_modules/pgsql-ast-parser/to-sql.d.ts +7 -0
  504. package/node_modules/pgsql-ast-parser/to-sql.d.ts.map +1 -0
  505. package/node_modules/pgsql-ast-parser/to-sql.spec.d.ts +3 -0
  506. package/node_modules/pgsql-ast-parser/to-sql.spec.d.ts.map +1 -0
  507. package/node_modules/pgsql-ast-parser/utils.d.ts +16 -0
  508. package/node_modules/pgsql-ast-parser/utils.d.ts.map +1 -0
  509. package/node_modules/railroad-diagrams/.gitattributes +22 -0
  510. package/node_modules/railroad-diagrams/.npmignore +163 -0
  511. package/node_modules/railroad-diagrams/README.md +86 -0
  512. package/node_modules/railroad-diagrams/css-example.py-js +183 -0
  513. package/node_modules/railroad-diagrams/example.html +141 -0
  514. package/node_modules/railroad-diagrams/generator.html +59 -0
  515. package/node_modules/railroad-diagrams/package.json +23 -0
  516. package/node_modules/railroad-diagrams/railroad-diagrams.css +23 -0
  517. package/node_modules/railroad-diagrams/railroad-diagrams.js +524 -0
  518. package/node_modules/railroad-diagrams/railroad_diagrams.py +427 -0
  519. package/node_modules/randexp/LICENSE +19 -0
  520. package/node_modules/randexp/README.md +134 -0
  521. package/node_modules/randexp/lib/randexp.js +245 -0
  522. package/node_modules/randexp/package.json +48 -0
  523. package/node_modules/ret/LICENSE +19 -0
  524. package/node_modules/ret/README.md +183 -0
  525. package/node_modules/ret/lib/index.js +282 -0
  526. package/node_modules/ret/lib/positions.js +17 -0
  527. package/node_modules/ret/lib/sets.js +82 -0
  528. package/node_modules/ret/lib/types.js +10 -0
  529. package/node_modules/ret/lib/util.js +111 -0
  530. package/node_modules/ret/package.json +35 -0
  531. package/package.json +22 -6
  532. package/schemas/cchistory-lite-agent-v1.schema.json +6 -7
  533. package/schemas/cchistory-lite-error-v1.schema.json +58 -8
  534. package/schemas/cchistory-lite-query-result-v2.schema.json +66 -11
  535. package/schemas/cchistory-lite-query-result-v3.schema.json +219 -0
  536. package/schemas/cchistory-lite-query-v3.schema.json +57 -0
  537. package/schemas/cchistory-lite-source-inventory-v1.schema.json +72 -0
  538. package/skills/using-cchistory-lite/SKILL.md +125 -53
  539. package/node_modules/@cchistory/live-runtime/dist/node-memory.d.ts +0 -8
  540. package/node_modules/@cchistory/live-runtime/dist/node-memory.d.ts.map +0 -1
  541. package/node_modules/@cchistory/live-runtime/dist/node-memory.js +0 -110
  542. package/node_modules/@cchistory/live-runtime/dist/node-memory.js.map +0 -1
@@ -1,15 +1,19 @@
1
+ import { randomUUID } from "node:crypto";
1
2
  import { access, realpath, stat } from "node:fs/promises";
2
3
  import os from "node:os";
3
4
  import path from "node:path";
4
5
  import process from "node:process";
5
6
  import { deriveHostId, deriveSourceInstanceId, normalizeLocalPathIdentity, } from "@cchistory/domain";
6
- import { auditProjectionConsistency, buildSessionLastMessageIndex, buildDirectoryScopedProjectTreeProjection, buildFallbackProjectObservationCandidates, buildProjectDisplayList, buildSessionRelatedWorkIndex, compareTurnsByChronology, compareTurnsByRecency, computeUsageOverview, computeUsageRollup, deriveProjectLinkSnapshot, filterProjectsByDirectoryScope, filterSessionsByDirectoryScope, filterTopLevelSessions, filterTurnsByDirectoryScope, buildSessionFamilyInventory, FAMILY_IO_PREVIEW_CHARS, listDelegatedRelationsForFamilyChildren, listSessionFamilies, mergeSessionFamilyInventories, installRuntimeWarningFilter, orderSessionsByLastMessage, pathMatchesDirectoryScope, searchSessionsInMemory, searchTurnsInMemory, resolveTurnUsage, summarizeSessionUsage, } from "@cchistory/canonical";
7
- import { applyMaskTemplates } from "@cchistory/source-adapters";
7
+ import { executeCanonicalQuery, collectionQueryTemplate, hasSessionFamilyLinkTool, auditProjectionConsistency, interpretSessionEvidence, buildSessionLastMessageIndex, buildDirectoryScopedProjectTreeProjection, buildFallbackProjectObservationCandidates, buildProjectDisplayList, buildSessionRelatedWorkIndex, compareTurnsByChronology, compareTurnsByRecency, computeUsageOverview, computeUsageRollup, deriveProjectLinkSnapshot, filterProjectsByDirectoryScope, selectSampleSessions, summarizeDirectoryScope, filterSessionsByDirectoryScope, filterTopLevelSessions, filterTurnsByDirectoryScope, buildSessionFamilyInventory, FAMILY_IO_PREVIEW_CHARS, listDelegatedRelationsForFamilyChildren, listSessionFamilies, mergeSessionFamilyInventories, installRuntimeWarningFilter, orderSessionsByLastMessage, pathMatchesDirectoryScope, searchSessionsInMemory, searchTurnsInMemory, resolveTurnUsage, summarizeSessionUsage, } from "@cchistory/canonical";
8
+ import { SourceReadBudgetExceededError, applyMaskTemplates } from "@cchistory/source-adapters";
8
9
  import { SAMPLE_RANK_CONCURRENCY, mapPool } from "./async-pool.js";
9
- import { acquireScanLock, assessScanRisk, createScanWatchdog, isScanGuardEnabled, ScanGuardRefusedError, } from "./scan-guard.js";
10
- export { buildAdaptiveNodeExecArgv, calculateAdaptiveOldSpaceMiB, isAdaptiveNodeMemoryApplied, MAX_OLD_SPACE_MIB, MIN_OLD_SPACE_MIB, runWithAdaptiveNodeMemory, } from "./node-memory.js";
11
- export { acquireScanLock, assessScanRisk, createScanWatchdog, defaultScanLockPath, formatScanGuardBytes, formatScanGuardWarning, FULL_SCAN_MEMORY_MULTIPLIER, isScanGuardEnabled, LIGHT_SCAN_MEMORY_MULTIPLIER, SCAN_GUARD_REFUSE_AVAILABLE_FRACTION, SCAN_GUARD_WARN_AVAILABLE_FRACTION, SCAN_LOCK_WAIT_MS, SCAN_WATCHDOG_MIN_FLOOR_BYTES, SCAN_WATCHDOG_TOTAL_FLOOR_FRACTION, ScanGuardAbortedError, ScanGuardRefusedError, } from "./scan-guard.js";
12
- export { readAvailableMemoryBytes } from "./system-memory.js";
10
+ import { isSelectiveLatestQuery, newQueryReadWork } from "./selective-query.js";
11
+ import { PreparationMetadata } from "./preparation-metadata.js";
12
+ import { readRemainingHeapBytes, LIGHT_SCAN_MEMORY_MULTIPLIER, FULL_SCAN_MEMORY_MULTIPLIER, SCAN_GUARD_REFUSE_AVAILABLE_FRACTION, acquireScanLock, assessScanRisk, createScanWatchdog, isScanGuardEnabled, ScanGuardRefusedError, } from "./scan-guard.js";
13
+ export { acquireScanLock, assessScanRisk, createScanWatchdog, defaultScanLockPath, formatScanGuardBytes, formatScanGuardWarning, FULL_SCAN_MEMORY_MULTIPLIER, isScanGuardEnabled, LIGHT_SCAN_MEMORY_MULTIPLIER, SCAN_GUARD_REFUSE_AVAILABLE_FRACTION, SCAN_GUARD_WARN_AVAILABLE_FRACTION, SCAN_LOCK_WAIT_MS, SCAN_WATCHDOG_AVAILABLE_RESERVE_FRACTION, ScanGuardAbortedError, ScanGuardRefusedError, } from "./scan-guard.js";
14
+ import { readAvailableMemoryBytes } from "./system-memory.js";
15
+ export { SourceReadBudgetExceededError } from "@cchistory/source-adapters";
16
+ export { readAvailableMemory, readAvailableMemoryBytes } from "./system-memory.js";
13
17
  installRuntimeWarningFilter();
14
18
  export function maskCompactPreview(value, kind) {
15
19
  if (!value?.trim())
@@ -32,7 +36,14 @@ export class AmbiguousReferenceError extends Error {
32
36
  }
33
37
  }
34
38
  export class LiveHistorySnapshot {
39
+ selectSampleSessions(perSource, directoryScope) {
40
+ return selectSampleSessions(this.data, perSource, directoryScope);
41
+ }
42
+ getDirectoryScopeDiagnostics(directoryScope) {
43
+ return summarizeDirectoryScope(this.data.sessions, directoryScope);
44
+ }
35
45
  data;
46
+ readIdentity = { id: randomUUID(), prepared_at: new Date().toISOString() };
36
47
  /** Non-fatal projection diagnostics kept visible to read-only surfaces. */
37
48
  projectionIssues;
38
49
  sourcesById;
@@ -101,6 +112,12 @@ export class LiveHistorySnapshot {
101
112
  directoryScope: options.directoryScope,
102
113
  }));
103
114
  }
115
+ executeCollectionQuery(query, options = {}) {
116
+ return executeCanonicalQuery(this.data, query, options.directoryScope);
117
+ }
118
+ selectCollectionTemplate(kind, limit = 20, offset = 0, options = {}) {
119
+ return this.executeCollectionQuery(collectionQueryTemplate(kind, limit, offset), options);
120
+ }
104
121
  listResolvedSessions(options = {}) {
105
122
  return filterSessionsByDirectoryScope(this.data.sessions, options.directoryScope);
106
123
  }
@@ -366,6 +383,38 @@ export class LiveHistorySnapshot {
366
383
  }
367
384
  }
368
385
  export async function scanLiteHistory(options = {}) {
386
+ return withPreparedScan(options, (sources, scanGuard, getPlan) => scanResolvedSources(scanGuard.guardedOptions(options), sources, scanGuard, getPlan));
387
+ }
388
+ /** Query-only selective reads never escape as a reusable full snapshot. */
389
+ export async function scanLiteQuery(query, options = {}) {
390
+ const work = newQueryReadWork();
391
+ options = { ...options, contextMode: "none" };
392
+ return withPreparedScan(options, async (sources, scanGuard, getPlan) => {
393
+ const guardedOptions = scanGuard.guardedOptions(options);
394
+ let selection;
395
+ for (const source of sources) {
396
+ const plan = await getPlan(source, options);
397
+ work.discoveredPrimaryFiles += plan.discoveredPrimaryFiles;
398
+ work.plannedPrimaryFiles += plan.readPlan.files.length;
399
+ work.metadataEvidenceFiles += new Set(plan.selectionEvidence.flatMap(e => [...e.files])).size;
400
+ }
401
+ if (isSelectiveLatestQuery(query) && sources.length === 1 && sources[0].platform === "codex" && !options.sample && !options.sessionRefs?.length) {
402
+ const source = sources[0], plan = await getPlan(source, options);
403
+ selection = await prepareSelectiveGroups(plan, query, work, scanGuard);
404
+ }
405
+ else
406
+ work.fallbackReason = query.complete ? "complete_requested" : "query_or_source_shape";
407
+ const snapshot = await scanResolvedSources(guardedOptions, sources, scanGuard, getPlan, work, selection);
408
+ const result = snapshot.executeCollectionQuery(query, { directoryScope: options.directoryScope });
409
+ if (selection?.stopped)
410
+ result.coverage = { execution: "selective", rows: "exact", diagnostics: "observed" };
411
+ work.retainedSessions = snapshot.data.sessions.length;
412
+ work.retainedTurns = snapshot.data.turns.length;
413
+ return { identity: snapshot.readIdentity, sourceIds: snapshot.data.sources.map(s => s.id), directoryScope: options.directoryScope,
414
+ result, projectionIssues: snapshot.projectionIssues, sources: snapshot.data.sources, lossAudits: snapshot.data.loss_audits, directoryScopeDiagnostics: snapshot.getDirectoryScopeDiagnostics(options.directoryScope), work };
415
+ });
416
+ }
417
+ async function withPreparedScan(options, run) {
369
418
  if (options.contextMode === "matching" && resolveContextTargets(options).length === 0) {
370
419
  throw new Error("matching context mode requires at least one context target.");
371
420
  }
@@ -377,9 +426,21 @@ export async function scanLiteHistory(options = {}) {
377
426
  throw new Error(`No selected Lite source can resolve requested session ${options.sessionRefs?.join(", ")}.`);
378
427
  }
379
428
  }
380
- const scanGuard = await beginScanGuard(options, sources);
429
+ const sourceAdapters = await import("@cchistory/source-adapters");
430
+ const metadata = new PreparationMetadata();
431
+ const plans = new Map();
432
+ const getPlan = (source, scanOptions) => {
433
+ const key = JSON.stringify([source.id, scanOptions.sessionRefs ?? []]);
434
+ let pending = plans.get(key);
435
+ if (!pending) {
436
+ pending = prepareSourceScan(source, scanOptions, sourceAdapters, metadata);
437
+ plans.set(key, pending);
438
+ }
439
+ return pending;
440
+ };
441
+ const scanGuard = await beginScanGuard(options, sources, getPlan);
381
442
  try {
382
- return await scanResolvedSources(scanGuard.guardedOptions(options), sources, scanGuard);
443
+ return await run(sources, scanGuard, getPlan);
383
444
  }
384
445
  finally {
385
446
  await scanGuard.release();
@@ -392,12 +453,13 @@ export async function scanLiteHistory(options = {}) {
392
453
  * kill-switch env is read here — the live-runtime entry — so the guard module
393
454
  * and its tests stay explicit about behavior.
394
455
  */
395
- async function beginScanGuard(options, sources) {
456
+ async function beginScanGuard(options, sources, getPlan) {
396
457
  const request = options.scanGuard;
397
458
  if (!request || !isScanGuardEnabled(process.env.CCHISTORY_SCAN_GUARD)) {
398
459
  return {
399
460
  guardedOptions: (scanOptions) => scanOptions,
400
461
  assertHealthy: () => { },
462
+ assess: async () => { },
401
463
  release: async () => { },
402
464
  };
403
465
  }
@@ -414,26 +476,60 @@ async function beginScanGuard(options, sources) {
414
476
  }
415
477
  lockHandle = lock.handle;
416
478
  }
417
- try {
418
- if (!request.bypass) {
419
- const assessment = await assessScanRisk({
420
- roots: sources.map((source) => ({ path: source.base_dir, slot_id: source.slot_id })),
421
- limitFiles: options.limitFiles,
422
- profile: request.profile,
423
- }, { walkRootBytes: deps.walkRootBytes, readAvailableBytes: deps.readAvailableBytes });
424
- if (assessment.status === "refuse") {
425
- throw new ScanGuardRefusedError({ reason: "estimated_memory", assessment });
426
- }
427
- if (assessment.status === "warn") {
428
- options.onScanGuardEvent?.({ type: "warn", assessment });
429
- }
479
+ const assess = async (scanOptions) => {
480
+ const directoryScoped = Boolean(scanOptions.directoryScope);
481
+ // Planning failures must propagate before the generic estimator's best-effort walk.
482
+ const prepared = new Map();
483
+ if (!deps.walkRootBytes) {
484
+ for (const source of sources)
485
+ prepared.set(source.slot_id, await getPlan(source, scanOptions));
486
+ }
487
+ const walkRootBytes = deps.walkRootBytes ?? (async (_root, _limit, slotId) => {
488
+ const plan = slotId && prepared.get(slotId);
489
+ if (!plan)
490
+ throw new Error(`Scan estimate has no source for ${slotId}.`);
491
+ return plan.readPlan.bytes;
492
+ });
493
+ const assessment = await assessScanRisk({
494
+ roots: sources.map((source) => ({ path: source.base_dir, slot_id: source.slot_id })),
495
+ limitFiles: scanOptions.limitFiles,
496
+ profile: request.profile,
497
+ ...(directoryScoped ? { directoryScoped: true } : {}),
498
+ }, { walkRootBytes, readAvailableBytes: deps.readAvailableBytes, readHeapBytes: deps.readHeapBytes });
499
+ if (assessment.status === "refuse") {
500
+ throw new ScanGuardRefusedError({ reason: "estimated_memory", assessment });
501
+ }
502
+ if (assessment.status === "warn") {
503
+ options.onScanGuardEvent?.({ type: "warn", assessment });
430
504
  }
505
+ };
506
+ try {
507
+ await assess(options);
431
508
  }
432
509
  catch (error) {
433
510
  // A refused scan must not keep siblings queued behind a lock it no longer needs.
434
511
  await lockHandle?.release();
435
512
  throw error;
436
513
  }
514
+ const multiplier = request.profile === "full" ? FULL_SCAN_MEMORY_MULTIPLIER : LIGHT_SCAN_MEMORY_MULTIPLIER;
515
+ const readHeadroom = () => {
516
+ let available;
517
+ try {
518
+ available = (deps.readAvailableBytes ?? readAvailableMemoryBytes)();
519
+ }
520
+ catch { /* use heap */ }
521
+ const heap = (deps.readHeapBytes ?? readRemainingHeapBytes)();
522
+ return Math.max(0, Math.min(heap, available ?? heap)) * SCAN_GUARD_REFUSE_AVAILABLE_FRACTION / multiplier;
523
+ };
524
+ let remaining = readHeadroom();
525
+ const readBudget = {
526
+ admit(bytes, unit) {
527
+ const allowed = Math.floor(Math.min(remaining, readHeadroom()));
528
+ if (!Number.isSafeInteger(bytes) || bytes < 0 || bytes > allowed)
529
+ throw new SourceReadBudgetExceededError(unit, bytes, allowed);
530
+ remaining -= bytes;
531
+ },
532
+ };
437
533
  const watchdog = createScanWatchdog({
438
534
  ...deps.watchdog,
439
535
  readAvailableBytes: deps.watchdog?.readAvailableBytes ?? deps.readAvailableBytes,
@@ -441,35 +537,41 @@ async function beginScanGuard(options, sources) {
441
537
  return {
442
538
  guardedOptions: (scanOptions) => ({
443
539
  ...scanOptions,
540
+ readBudget,
444
541
  onProgress: (event) => {
445
542
  watchdog.observeProgress(event);
446
543
  scanOptions.onProgress?.(event);
447
544
  },
448
545
  }),
449
546
  assertHealthy: () => watchdog.assertHealthy(),
547
+ assess,
450
548
  release: async () => {
451
549
  await lockHandle?.release();
452
550
  },
453
551
  };
454
552
  }
455
- async function scanResolvedSources(options, sources, scanGuard) {
553
+ async function scanResolvedSources(options, sources, scanGuard, getPlan, work, selection) {
456
554
  const sourceAdapters = await import("@cchistory/source-adapters");
457
555
  const contextMode = options.contextMode ?? "full";
458
556
  const scanSources = async (scanOptions) => {
459
557
  const nextPayloads = [];
460
558
  let nextHost;
461
- // Rebuild the native file inventory on every invocation, then scan one
462
- // source at a time so raw adapter payloads can be released promptly. Each
559
+ // Reuse this attempt's inventory, then scan one source at a time so raw
560
+ // adapter payloads can be released promptly. Each
463
561
  // adapter explicitly declares its minimum safe projection boundary; the
464
562
  // runtime never infers independence from a file-oriented source shape.
465
563
  for (const source of sources) {
466
- const adapter = sourceAdapters.listPlatformAdapters().find((entry) => entry.platform === source.platform);
467
- const result = adapter?.projectionBoundary === "logical_session"
468
- ? await scanLogicalSessionGroups(source, scanOptions, contextMode, sourceAdapters, (filePaths, includeWorkspaceMetadata) => sourceAdapters.inspectSourceFilesLogicalSessionMetadata(source.platform, filePaths, {
469
- includeWorkspaceMetadata,
470
- workspaceScan: source.platform === "codex" && scanOptions.directoryScope ? "first" : "full",
471
- }))
472
- : await scanSourceWithCollector(source, scanOptions, contextMode, sourceAdapters);
564
+ const plan = await getPlan(source, scanOptions);
565
+ for (const evidence of plan.selectionEvidence)
566
+ await sourceAdapters.assertSourceFileReadPlanCurrent(evidence);
567
+ await sourceAdapters.assertSourceFileReadPlanCurrent(plan.readPlan);
568
+ const result = plan.groups
569
+ ? await scanLogicalSessionGroups(source, scanOptions, contextMode, sourceAdapters, plan, () => scanGuard.assess(scanOptions), work, selection)
570
+ : await scanSourceWithCollector(source, scanOptions, contextMode, sourceAdapters, plan.readPlan.files, plan.readPlan, plan.selectSessionFiles, work);
571
+ for (const evidence of plan.selectionEvidence)
572
+ await sourceAdapters.assertSourceFileReadPlanCurrent(evidence);
573
+ if (selection)
574
+ await sourceAdapters.assertSourceFileReadPlanCurrent(plan.readPlan);
473
575
  nextHost ??= result.host;
474
576
  nextPayloads.push(result.payload);
475
577
  // Watchdog backstop: breaches recorded inside adapter progress callbacks
@@ -478,7 +580,7 @@ async function scanResolvedSources(options, sources, scanGuard) {
478
580
  scanGuard.assertHealthy();
479
581
  }
480
582
  if (!nextHost) {
481
- const emptyProbe = await sourceAdapters.runSourceProbe({}, []);
583
+ const emptyProbe = await sourceAdapters.runSourceProbe(interpretSessionEvidence, {}, []);
482
584
  nextHost = emptyProbe.host;
483
585
  }
484
586
  return { host: nextHost, payloads: nextPayloads };
@@ -489,10 +591,9 @@ async function scanResolvedSources(options, sources, scanGuard) {
489
591
  return buildLiveSnapshot({ host, sources: payloads });
490
592
  const missingChildRefs = missingDelegatedChildSessionRefs(payloads, requestedSessionRefs);
491
593
  if (missingChildRefs.length > 0) {
492
- ({ host, payloads } = await scanSources({
493
- ...options,
494
- sessionRefs: [...requestedSessionRefs, ...missingChildRefs],
495
- }));
594
+ const expandedOptions = { ...options, sessionRefs: [...requestedSessionRefs, ...missingChildRefs] };
595
+ await scanGuard.assess(expandedOptions);
596
+ ({ host, payloads } = await scanSources(expandedOptions));
496
597
  }
497
598
  const combined = buildLiveSnapshot({ host, sources: payloads });
498
599
  const resolvedSessionRefs = requestedSessionRefs.map((ref) => {
@@ -550,26 +651,91 @@ export function buildLiveSnapshot(probe) {
550
651
  loss_audits: probe.sources.flatMap((payload) => payload.loss_audits),
551
652
  }), candidates);
552
653
  }
553
- async function scanSourceWithCollector(source, options, contextMode, sourceAdapters, sourceFiles) {
554
- let scopedFiles = sourceFiles;
555
- const directoryScope = options.directoryScope;
556
- if (scopedFiles === undefined && (directoryScope || options.sample)) {
557
- const listed = await sourceAdapters.listSourceFiles(source.platform, source.base_dir, options.limitFiles);
558
- scopedFiles = directoryScope
559
- ? listed.filter((filePath) => sourceFileMayBeInDirectoryScope(sourceAdapters, source, filePath, directoryScope))
560
- : listed;
561
- }
562
- if (options.sample && scopedFiles) {
563
- scopedFiles = await selectSampleSourceFiles(source, scopedFiles, options.sample.perSource, sourceAdapters);
564
- }
565
- const probe = await sourceAdapters.runSourceProbe({
654
+ async function prepareSourceScan(source, options, adapters, metadata) {
655
+ const adapter = adapters.listPlatformAdapters().find((entry) => entry.platform === source.platform);
656
+ let files;
657
+ let discoveredPrimaryFiles;
658
+ let groups;
659
+ const selectionEvidence = new Set();
660
+ if (adapter?.projectionBoundary === "logical_session") {
661
+ ({ files, groups, discoveredPrimaryFiles } = await prepareLogicalSessionGroups(source, options, adapters, async (filePaths, includeWorkspaceMetadata) => {
662
+ const inspected = await metadata.inspect(source, filePaths, {
663
+ includeWorkspaceMetadata,
664
+ workspaceScan: source.platform === "codex" && options.directoryScope ? "first" : "full",
665
+ });
666
+ for (const evidence of inspected.evidence)
667
+ selectionEvidence.add(evidence);
668
+ return inspected.metadata;
669
+ }));
670
+ }
671
+ else {
672
+ files = await adapters.listSourceFiles(source.platform, source.base_dir, options.limitFiles);
673
+ discoveredPrimaryFiles = files.length;
674
+ if (options.directoryScope) {
675
+ files = files.filter((file) => sourceFileMayBeInDirectoryScope(adapters, source, file, options.directoryScope));
676
+ }
677
+ if (options.sample)
678
+ files = await selectSampleSourceFiles(source, files, options.sample.perSource, adapters);
679
+ }
680
+ const selectedFiles = groups ? groups.flatMap((group) => group.files) : files;
681
+ const readPlan = await adapters.createSourceFileReadPlan(source, selectedFiles, options.safeMode ?? false);
682
+ // Some source-level identity lookups read whole JSON files. Budget all their
683
+ // candidates before doing that work; retain the probe's existing targeting rule.
684
+ const selectSessionFiles = adapter?.projectionBoundary !== "logical_session"
685
+ && !options.directoryScope && !options.sample && Boolean(options.sessionRefs?.length);
686
+ return { discoveredPrimaryFiles, readPlan, selectionEvidence: [...selectionEvidence], selectSessionFiles, groups, fallbackFiles: groups ? files : undefined };
687
+ }
688
+ async function prepareSelectiveGroups(plan, query, work, guard) {
689
+ if (!plan.groups?.length) {
690
+ work.fallbackReason = "uncertain_grouping";
691
+ return undefined;
692
+ }
693
+ const adapters = await import("@cchistory/source-adapters");
694
+ for (const evidence of plan.selectionEvidence)
695
+ await adapters.assertSourceFileReadPlanCurrent(evidence);
696
+ await adapters.assertSourceFileReadPlanCurrent(plan.readPlan);
697
+ const byFile = new Map();
698
+ for (const file of plan.readPlan.files) {
699
+ const evidence = await adapters.inspectCodexActivityEvidence(plan.readPlan, file);
700
+ work.inventoryFiles++;
701
+ work.inventoryBytesRead += evidence.bytesRead;
702
+ work.inventoryRecordsDecoded += evidence.recordsDecoded;
703
+ byFile.set(file, evidence);
704
+ guard.assertHealthy();
705
+ if (!evidence.supported || hasSessionFamilyLinkTool(evidence.toolNames)) {
706
+ work.fallbackReason = evidence.reason ?? "family_link_tool";
707
+ return undefined;
708
+ }
709
+ }
710
+ const groups = plan.groups.map(group => ({ group, evidence: group.files.map(file => byFile.get(file)) }));
711
+ if (groups.some(g => new Set(g.evidence.map(e => e.sessionId)).size !== 1)
712
+ || new Set(groups.map(g => g.evidence[0]?.sessionId)).size !== groups.length) {
713
+ work.fallbackReason = "group_identity_mismatch";
714
+ return undefined;
715
+ }
716
+ const ranked = groups.map(g => ({ group: g.group, bound: g.evidence.reduce((max, e) => e.upperBound > max ? e.upperBound : max, "") }))
717
+ .sort((a, b) => b.bound.localeCompare(a.bound));
718
+ await adapters.assertSourceFileReadPlanCurrent(plan.readPlan);
719
+ return { groups: ranked.map(x => x.group), upperBounds: ranked.map(x => x.bound), query, stopped: false };
720
+ }
721
+ async function scanSourceWithCollector(source, options, contextMode, sourceAdapters, sourceFiles, readPlan, selectSessionFiles = false, work) {
722
+ if (selectSessionFiles) {
723
+ sourceFiles = await sourceAdapters.selectSourceSessionFiles(source, sourceFiles, options.sessionRefs);
724
+ await sourceAdapters.assertSourceFileReadPlanCurrent(readPlan);
725
+ }
726
+ const probe = await sourceAdapters.runSourceProbe(work ? evidence => { work.canonicalInterpretations++; return interpretSessionEvidence(evidence); } : interpretSessionEvidence, {
566
727
  ...buildProbeOptions(source, options),
567
- ...(scopedFiles ? { source_file_paths: { [source.id]: scopedFiles } } : {}),
728
+ source_file_paths: { [source.id]: sourceFiles },
729
+ source_file_plans: { [source.id]: readPlan },
568
730
  }, [source]);
569
731
  const payload = probe.sources[0];
570
732
  if (!payload) {
571
733
  throw new Error(`Lite source probe produced no payload for ${source.display_name}.`);
572
734
  }
735
+ if (work) {
736
+ work.payloadFilesProcessed += sourceFiles.length;
737
+ work.payloadRecordsProcessed += payload.source.total_records;
738
+ }
573
739
  const compacted = compactSourcePayload(payload, contextMode, resolveContextTargets(options));
574
740
  return {
575
741
  host: probe.host,
@@ -578,7 +744,7 @@ async function scanSourceWithCollector(source, options, contextMode, sourceAdapt
578
744
  : compacted,
579
745
  };
580
746
  }
581
- async function scanLogicalSessionGroups(source, options, contextMode, sourceAdapters, inspectGroupFiles) {
747
+ async function prepareLogicalSessionGroups(source, options, sourceAdapters, inspectGroupFiles) {
582
748
  const listedFiles = await sourceAdapters.listSourceFiles(source.platform, source.base_dir, options.limitFiles);
583
749
  let files = options.directoryScope
584
750
  ? listedFiles.filter((filePath) => sourceFileMayBeInDirectoryScope(sourceAdapters, source, filePath, options.directoryScope))
@@ -596,13 +762,13 @@ async function scanLogicalSessionGroups(source, options, contextMode, sourceAdap
596
762
  files = await selectSampleSourceFiles(source, files, options.sample.perSource, sourceAdapters);
597
763
  }
598
764
  if (files.length === 0) {
599
- return scanSourceWithCollector(source, options, contextMode, sourceAdapters, []);
765
+ return { files: [], discoveredPrimaryFiles: listedFiles.length };
600
766
  }
601
767
  const filesByGroup = new Map();
602
768
  const requestedSessionRefs = options.sessionRefs?.filter((ref) => ref.trim().length > 0) ?? [];
603
769
  const inspectedFiles = await inspectGroupFiles(files, Boolean(options.directoryScope || requestedSessionRefs.length > 0));
604
770
  if (inspectedFiles.some((metadata) => metadata.sessionKeyState === "uncertain")) {
605
- return scanSourceWithCollector(source, options, contextMode, sourceAdapters, files);
771
+ return { files, discoveredPrimaryFiles: listedFiles.length };
606
772
  }
607
773
  for (const [fileIndex, filePath] of files.entries()) {
608
774
  const metadata = inspectedFiles[fileIndex];
@@ -660,8 +826,12 @@ async function scanLogicalSessionGroups(source, options, contextMode, sourceAdap
660
826
  : undefined,
661
827
  }));
662
828
  if (selectedGroupFiles.length === 0) {
663
- return scanSourceWithCollector(source, options, contextMode, sourceAdapters, []);
829
+ return { files: [], discoveredPrimaryFiles: listedFiles.length };
664
830
  }
831
+ return { files, groups: selectedGroupFiles, discoveredPrimaryFiles: listedFiles.length };
832
+ }
833
+ async function scanLogicalSessionGroups(source, options, contextMode, sourceAdapters, plan, assessExpandedPlan, work, selection) {
834
+ const selectedGroupFiles = selection?.groups ?? plan.groups;
665
835
  const blobsById = new Map();
666
836
  const candidatesById = new Map();
667
837
  const sessionsById = new Map();
@@ -678,10 +848,11 @@ async function scanLogicalSessionGroups(source, options, contextMode, sourceAdap
678
848
  let requiresSourceCollector = false;
679
849
  let forwardedSourceStart = false;
680
850
  let host;
681
- for (const group of selectedGroupFiles) {
682
- const probe = await sourceAdapters.runSourceProbe({
851
+ for (const [groupIndex, group] of selectedGroupFiles.entries()) {
852
+ const probe = await sourceAdapters.runSourceProbe(work ? evidence => { work.canonicalInterpretations++; return interpretSessionEvidence(evidence); } : interpretSessionEvidence, {
683
853
  ...buildProbeOptions(source, options, group.targetSessionRefs),
684
854
  source_file_paths: { [source.id]: group.files },
855
+ source_file_plans: { [source.id]: plan.readPlan },
685
856
  on_progress: (event) => {
686
857
  if (event.stage === "source_start") {
687
858
  if (forwardedSourceStart)
@@ -701,6 +872,10 @@ async function scanLogicalSessionGroups(source, options, contextMode, sourceAdap
701
872
  if (!groupPayload) {
702
873
  throw new Error(`Lite source probe produced no payload for ${source.display_name}.`);
703
874
  }
875
+ if (work) {
876
+ work.payloadFilesProcessed += group.files.length;
877
+ work.payloadRecordsProcessed += groupPayload.source.total_records;
878
+ }
704
879
  totalRecords += groupPayload.source.total_records;
705
880
  totalFragments += groupPayload.source.total_fragments;
706
881
  totalAtoms += groupPayload.source.total_atoms;
@@ -726,9 +901,37 @@ async function scanLogicalSessionGroups(source, options, contextMode, sourceAdap
726
901
  sessionRelationFragments.push(...groupPayload.fragments.filter((fragment) => fragment.fragment_kind === "session_relation"));
727
902
  familyInventories.push(familyInventoryFromPayload(groupPayload, flattenRelatedWorkIndex(buildSessionRelatedWorkIndex(groupPayload.sessions, groupPayload.fragments))));
728
903
  lossAudits.push(...groupPayload.loss_audits);
904
+ if (selection && !requiresSourceCollector) {
905
+ // Unexpected cross-session relationships invalidate the narrow independence proof.
906
+ if (sessionRelationFragments.length || familyInventories.some(f => f.children.length > 0)) {
907
+ if (work)
908
+ work.fallbackReason = "derived_relationship";
909
+ selection = undefined;
910
+ }
911
+ else {
912
+ const turns = [...turnsById.values()].sort(compareTurnsByRecency);
913
+ const sessions = orderSessionsByLastMessage([...sessionsById.values()], turns);
914
+ const current = executeCanonicalQuery({ sessions, turns, related_work: [] }, selection.query, options.directoryScope);
915
+ const cutoff = current.rows.at(-1)?.last_message_at;
916
+ const nextBound = selection.upperBounds[groupIndex + 1];
917
+ if (current.shown === selection.query.limit && typeof cutoff === "string" && nextBound !== undefined && nextBound < cutoff) {
918
+ selection.stopped = true;
919
+ if (work)
920
+ work.skippedPrimaryFiles = selectedGroupFiles.slice(groupIndex + 1).reduce((n, g) => n + g.files.length, 0);
921
+ break;
922
+ }
923
+ }
924
+ }
729
925
  }
730
926
  if (requiresSourceCollector) {
731
- return scanSourceWithCollector(source, options, contextMode, sourceAdapters, files);
927
+ plan.readPlan = await sourceAdapters.createSourceFileReadPlan(source, plan.fallbackFiles, options.safeMode ?? false);
928
+ await assessExpandedPlan();
929
+ await sourceAdapters.assertSourceFileReadPlanCurrent(plan.readPlan);
930
+ if (selection)
931
+ selection.stopped = false;
932
+ if (work)
933
+ work.fallbackReason = "duplicate_identity";
934
+ return scanSourceWithCollector(source, options, contextMode, sourceAdapters, plan.readPlan.files, plan.readPlan, false, work);
732
935
  }
733
936
  if (!host) {
734
937
  throw new Error(`Lite logical-session scan produced no host for ${source.display_name}.`);
@@ -861,6 +1064,7 @@ function sourceFileMayBeInDirectoryScope(sourceAdapters, source, filePath, direc
861
1064
  function buildProbeOptions(source, options, targetSessionRefs = options.sessionRefs) {
862
1065
  return {
863
1066
  source_ids: [source.id],
1067
+ read_budget: options.readBudget,
864
1068
  target_session_refs: targetSessionRefs,
865
1069
  limit_files_per_source: options.limitFiles,
866
1070
  safe_mode: options.safeMode,
@@ -1266,4 +1470,5 @@ function normalizeJsonShapeForJsonOutputMutating(value) {
1266
1470
  }
1267
1471
  return value;
1268
1472
  }
1473
+ export { compileSql, compileSqlRequest, parseSqlRequest, QueryValidationError, SQL_REQUEST_SCHEMA, SQL_RESULT_SCHEMA, MAX_SQL_BYTES, MAX_QUERY_REQUEST_BYTES } from "./sql-query.js";
1269
1474
  //# sourceMappingURL=index.js.map