@cchistory/lite 0.4.5 → 0.6.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 (556) hide show
  1. package/INSTALL.md +1 -1
  2. package/apps/lite-cli/dist/agent-contract.d.ts +7 -5
  3. package/apps/lite-cli/dist/agent-contract.d.ts.map +1 -1
  4. package/apps/lite-cli/dist/agent-contract.js +36 -25
  5. package/apps/lite-cli/dist/agent-contract.js.map +1 -1
  6. package/apps/lite-cli/dist/bin.js +2 -2
  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 +151 -66
  10. package/apps/lite-cli/dist/index.js.map +1 -1
  11. package/apps/lite-cli/dist/index.test.js +59 -89
  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 +2 -2
  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 +6 -2
  35. package/apps/lite-tui/dist/index.js.map +1 -1
  36. package/apps/lite-tui/dist/index.test.js +10 -8
  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 +2 -2
  42. package/bin/cchistory-lite.mjs +2 -2
  43. package/docs/guide/for-agents.md +66 -46
  44. package/docs/guide/lite.md +53 -11
  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 +1 -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 +1 -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 +314 -143
  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/launcher-memory.d.ts +12 -0
  116. package/node_modules/@cchistory/live-runtime/dist/launcher-memory.d.ts.map +1 -0
  117. package/node_modules/@cchistory/live-runtime/dist/launcher-memory.js +44 -0
  118. package/node_modules/@cchistory/live-runtime/dist/launcher-memory.js.map +1 -0
  119. package/node_modules/@cchistory/live-runtime/dist/launcher-memory.test.d.ts +2 -0
  120. package/node_modules/@cchistory/live-runtime/dist/launcher-memory.test.d.ts.map +1 -0
  121. package/node_modules/@cchistory/live-runtime/dist/launcher-memory.test.js +20 -0
  122. package/node_modules/@cchistory/live-runtime/dist/launcher-memory.test.js.map +1 -0
  123. package/node_modules/@cchistory/live-runtime/dist/live-read-recovery.test.d.ts +2 -0
  124. package/node_modules/@cchistory/live-runtime/dist/live-read-recovery.test.d.ts.map +1 -0
  125. package/node_modules/@cchistory/live-runtime/dist/live-read-recovery.test.js +92 -0
  126. package/node_modules/@cchistory/live-runtime/dist/live-read-recovery.test.js.map +1 -0
  127. package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.d.ts +16 -0
  128. package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.d.ts.map +1 -0
  129. package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.js +55 -0
  130. package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.js.map +1 -0
  131. package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.d.ts +2 -0
  132. package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.d.ts.map +1 -0
  133. package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.js +192 -0
  134. package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.js.map +1 -0
  135. package/node_modules/@cchistory/live-runtime/dist/scan-guard.d.ts +22 -22
  136. package/node_modules/@cchistory/live-runtime/dist/scan-guard.d.ts.map +1 -1
  137. package/node_modules/@cchistory/live-runtime/dist/scan-guard.js +53 -47
  138. package/node_modules/@cchistory/live-runtime/dist/scan-guard.js.map +1 -1
  139. package/node_modules/@cchistory/live-runtime/dist/scan-guard.test.js +287 -83
  140. package/node_modules/@cchistory/live-runtime/dist/scan-guard.test.js.map +1 -1
  141. package/node_modules/@cchistory/live-runtime/dist/selective-query.d.ts +47 -0
  142. package/node_modules/@cchistory/live-runtime/dist/selective-query.d.ts.map +1 -0
  143. package/node_modules/@cchistory/live-runtime/dist/selective-query.js +15 -0
  144. package/node_modules/@cchistory/live-runtime/dist/selective-query.js.map +1 -0
  145. package/node_modules/@cchistory/live-runtime/dist/selective-query.test.d.ts +2 -0
  146. package/node_modules/@cchistory/live-runtime/dist/selective-query.test.d.ts.map +1 -0
  147. package/node_modules/@cchistory/live-runtime/dist/selective-query.test.js +171 -0
  148. package/node_modules/@cchistory/live-runtime/dist/selective-query.test.js.map +1 -0
  149. package/node_modules/@cchistory/live-runtime/dist/sql-query.d.ts +37 -0
  150. package/node_modules/@cchistory/live-runtime/dist/sql-query.d.ts.map +1 -0
  151. package/node_modules/@cchistory/live-runtime/dist/sql-query.js +301 -0
  152. package/node_modules/@cchistory/live-runtime/dist/sql-query.js.map +1 -0
  153. package/node_modules/@cchistory/live-runtime/dist/sql-query.test.d.ts +2 -0
  154. package/node_modules/@cchistory/live-runtime/dist/sql-query.test.d.ts.map +1 -0
  155. package/node_modules/@cchistory/live-runtime/dist/sql-query.test.js +67 -0
  156. package/node_modules/@cchistory/live-runtime/dist/sql-query.test.js.map +1 -0
  157. package/node_modules/@cchistory/live-runtime/dist/sql-worker.d.ts +2 -0
  158. package/node_modules/@cchistory/live-runtime/dist/sql-worker.d.ts.map +1 -0
  159. package/node_modules/@cchistory/live-runtime/dist/sql-worker.js +14 -0
  160. package/node_modules/@cchistory/live-runtime/dist/sql-worker.js.map +1 -0
  161. package/node_modules/@cchistory/live-runtime/dist/system-memory.d.ts +13 -10
  162. package/node_modules/@cchistory/live-runtime/dist/system-memory.d.ts.map +1 -1
  163. package/node_modules/@cchistory/live-runtime/dist/system-memory.js +61 -34
  164. package/node_modules/@cchistory/live-runtime/dist/system-memory.js.map +1 -1
  165. package/node_modules/@cchistory/live-runtime/dist/system-memory.test.d.ts +2 -0
  166. package/node_modules/@cchistory/live-runtime/dist/system-memory.test.d.ts.map +1 -0
  167. package/node_modules/@cchistory/live-runtime/dist/system-memory.test.js +76 -0
  168. package/node_modules/@cchistory/live-runtime/dist/system-memory.test.js.map +1 -0
  169. package/node_modules/@cchistory/live-runtime/package.json +1 -1
  170. package/node_modules/@cchistory/source-adapters/dist/core/discovery.test.js +2 -1
  171. package/node_modules/@cchistory/source-adapters/dist/core/discovery.test.js.map +1 -1
  172. package/node_modules/@cchistory/source-adapters/dist/core/factories.d.ts +2 -4
  173. package/node_modules/@cchistory/source-adapters/dist/core/factories.d.ts.map +1 -1
  174. package/node_modules/@cchistory/source-adapters/dist/core/factories.js +1 -23
  175. package/node_modules/@cchistory/source-adapters/dist/core/factories.js.map +1 -1
  176. package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.d.ts +25 -0
  177. package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.d.ts.map +1 -0
  178. package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.js +81 -0
  179. package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.js.map +1 -0
  180. package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.d.ts +2 -0
  181. package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.d.ts.map +1 -0
  182. package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.js +122 -0
  183. package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.js.map +1 -0
  184. package/node_modules/@cchistory/source-adapters/dist/core/git-project.d.ts +1 -1
  185. package/node_modules/@cchistory/source-adapters/dist/core/git-project.d.ts.map +1 -1
  186. package/node_modules/@cchistory/source-adapters/dist/core/git-project.js +2 -11
  187. package/node_modules/@cchistory/source-adapters/dist/core/git-project.js.map +1 -1
  188. package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.test.js +31 -1
  189. package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.test.js.map +1 -1
  190. package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts +4 -3
  191. package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts.map +1 -1
  192. package/node_modules/@cchistory/source-adapters/dist/core/parser.js +32 -13
  193. package/node_modules/@cchistory/source-adapters/dist/core/parser.js.map +1 -1
  194. package/node_modules/@cchistory/source-adapters/dist/core/probe.d.ts +8 -6
  195. package/node_modules/@cchistory/source-adapters/dist/core/probe.d.ts.map +1 -1
  196. package/node_modules/@cchistory/source-adapters/dist/core/probe.js +46 -45
  197. package/node_modules/@cchistory/source-adapters/dist/core/probe.js.map +1 -1
  198. package/node_modules/@cchistory/source-adapters/dist/core/projections.d.ts +2 -28
  199. package/node_modules/@cchistory/source-adapters/dist/core/projections.d.ts.map +1 -1
  200. package/node_modules/@cchistory/source-adapters/dist/core/projections.js +2 -695
  201. package/node_modules/@cchistory/source-adapters/dist/core/projections.js.map +1 -1
  202. package/node_modules/@cchistory/source-adapters/dist/core/projections.test.js +2 -1
  203. package/node_modules/@cchistory/source-adapters/dist/core/projections.test.js.map +1 -1
  204. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.d.ts +18 -0
  205. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.d.ts.map +1 -0
  206. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.js +27 -0
  207. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.js.map +1 -0
  208. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.d.ts +2 -0
  209. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.d.ts.map +1 -0
  210. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.js +76 -0
  211. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.js.map +1 -0
  212. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.d.ts +6 -0
  213. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.d.ts.map +1 -1
  214. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.js +1 -1
  215. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.js.map +1 -1
  216. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.test.js +1 -1
  217. package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.test.js.map +1 -1
  218. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts +1 -1
  219. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts.map +1 -1
  220. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js +1 -1
  221. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js.map +1 -1
  222. package/node_modules/@cchistory/source-adapters/dist/core/token-usage.d.ts +1 -13
  223. package/node_modules/@cchistory/source-adapters/dist/core/token-usage.d.ts.map +1 -1
  224. package/node_modules/@cchistory/source-adapters/dist/core/token-usage.js +1 -246
  225. package/node_modules/@cchistory/source-adapters/dist/core/token-usage.js.map +1 -1
  226. package/node_modules/@cchistory/source-adapters/dist/core/tokens.test.js +1 -1
  227. package/node_modules/@cchistory/source-adapters/dist/core/tokens.test.js.map +1 -1
  228. package/node_modules/@cchistory/source-adapters/dist/core/type-guards.d.ts +1 -25
  229. package/node_modules/@cchistory/source-adapters/dist/core/type-guards.d.ts.map +1 -1
  230. package/node_modules/@cchistory/source-adapters/dist/core/type-guards.js +1 -79
  231. package/node_modules/@cchistory/source-adapters/dist/core/type-guards.js.map +1 -1
  232. package/node_modules/@cchistory/source-adapters/dist/core/types.d.ts +6 -35
  233. package/node_modules/@cchistory/source-adapters/dist/core/types.d.ts.map +1 -1
  234. package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.d.ts +2 -1
  235. package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.d.ts.map +1 -1
  236. package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.js +14 -10
  237. package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.js.map +1 -1
  238. package/node_modules/@cchistory/source-adapters/dist/index.d.ts +6 -0
  239. package/node_modules/@cchistory/source-adapters/dist/index.d.ts.map +1 -1
  240. package/node_modules/@cchistory/source-adapters/dist/index.js +4 -0
  241. package/node_modules/@cchistory/source-adapters/dist/index.js.map +1 -1
  242. package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts +2 -0
  243. package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts.map +1 -1
  244. package/node_modules/@cchistory/source-adapters/dist/index.test.js +2 -0
  245. package/node_modules/@cchistory/source-adapters/dist/index.test.js.map +1 -1
  246. package/node_modules/@cchistory/source-adapters/dist/masks.d.ts +1 -30
  247. package/node_modules/@cchistory/source-adapters/dist/masks.d.ts.map +1 -1
  248. package/node_modules/@cchistory/source-adapters/dist/masks.js +1 -341
  249. package/node_modules/@cchistory/source-adapters/dist/masks.js.map +1 -1
  250. package/node_modules/@cchistory/source-adapters/dist/platforms/accio.test.js +1 -1
  251. package/node_modules/@cchistory/source-adapters/dist/platforms/accio.test.js.map +1 -1
  252. package/node_modules/@cchistory/source-adapters/dist/platforms/amp.test.js +1 -1
  253. package/node_modules/@cchistory/source-adapters/dist/platforms/amp.test.js.map +1 -1
  254. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.test.js +2 -1
  255. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.test.js.map +1 -1
  256. package/node_modules/@cchistory/source-adapters/dist/platforms/claude.test.js +1 -1
  257. package/node_modules/@cchistory/source-adapters/dist/platforms/claude.test.js.map +1 -1
  258. package/node_modules/@cchistory/source-adapters/dist/platforms/codebuddy.test.js +1 -1
  259. package/node_modules/@cchistory/source-adapters/dist/platforms/codebuddy.test.js.map +1 -1
  260. package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.d.ts +14 -0
  261. package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.d.ts.map +1 -0
  262. package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.js +103 -0
  263. package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.js.map +1 -0
  264. package/node_modules/@cchistory/source-adapters/dist/platforms/codex.test.js +1 -1
  265. package/node_modules/@cchistory/source-adapters/dist/platforms/codex.test.js.map +1 -1
  266. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.d.ts +2 -1
  267. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.d.ts.map +1 -1
  268. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.js +5 -3
  269. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.js.map +1 -1
  270. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.test.js +2 -1
  271. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.test.js.map +1 -1
  272. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor.test.js +2 -1
  273. package/node_modules/@cchistory/source-adapters/dist/platforms/cursor.test.js.map +1 -1
  274. package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid.test.js +1 -1
  275. package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid.test.js.map +1 -1
  276. package/node_modules/@cchistory/source-adapters/dist/platforms/gemini.test.js +2 -1
  277. package/node_modules/@cchistory/source-adapters/dist/platforms/gemini.test.js.map +1 -1
  278. package/node_modules/@cchistory/source-adapters/dist/platforms/grok.d.ts.map +1 -1
  279. package/node_modules/@cchistory/source-adapters/dist/platforms/grok.js +24 -1
  280. package/node_modules/@cchistory/source-adapters/dist/platforms/grok.js.map +1 -1
  281. package/node_modules/@cchistory/source-adapters/dist/platforms/grok.test.js +2 -1
  282. package/node_modules/@cchistory/source-adapters/dist/platforms/grok.test.js.map +1 -1
  283. package/node_modules/@cchistory/source-adapters/dist/platforms/kimi.test.js +2 -1
  284. package/node_modules/@cchistory/source-adapters/dist/platforms/kimi.test.js.map +1 -1
  285. package/node_modules/@cchistory/source-adapters/dist/platforms/lobechat.test.js +1 -1
  286. package/node_modules/@cchistory/source-adapters/dist/platforms/lobechat.test.js.map +1 -1
  287. package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw.test.js +1 -1
  288. package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw.test.js.map +1 -1
  289. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.test.js +2 -1
  290. package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.test.js.map +1 -1
  291. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.d.ts +2 -1
  292. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.d.ts.map +1 -1
  293. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.js +11 -9
  294. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.js.map +1 -1
  295. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode.test.js +2 -1
  296. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode.test.js.map +1 -1
  297. package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.d.ts +8 -0
  298. package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.d.ts.map +1 -0
  299. package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.js +7 -0
  300. package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.js.map +1 -0
  301. package/node_modules/@cchistory/source-adapters/dist/test-helpers.js.map +1 -1
  302. package/node_modules/@cchistory/source-adapters/package.json +1 -1
  303. package/node_modules/commander/LICENSE +22 -0
  304. package/node_modules/commander/Readme.md +428 -0
  305. package/node_modules/commander/index.js +1224 -0
  306. package/node_modules/commander/package.json +38 -0
  307. package/node_modules/commander/typings/index.d.ts +310 -0
  308. package/node_modules/discontinuous-range/.npmignore +28 -0
  309. package/node_modules/discontinuous-range/.travis.yml +4 -0
  310. package/node_modules/discontinuous-range/LICENSE +21 -0
  311. package/node_modules/discontinuous-range/README.md +23 -0
  312. package/node_modules/discontinuous-range/index.js +144 -0
  313. package/node_modules/discontinuous-range/package.json +27 -0
  314. package/node_modules/discontinuous-range/test/main-test.js +96 -0
  315. package/node_modules/moo/LICENSE +29 -0
  316. package/node_modules/moo/README.md +385 -0
  317. package/node_modules/moo/moo.js +645 -0
  318. package/node_modules/moo/package.json +29 -0
  319. package/node_modules/nearley/LICENSE.txt +21 -0
  320. package/node_modules/nearley/README.md +80 -0
  321. package/node_modules/nearley/bin/nearley-railroad.js +121 -0
  322. package/node_modules/nearley/bin/nearley-test.js +64 -0
  323. package/node_modules/nearley/bin/nearley-unparse.js +29 -0
  324. package/node_modules/nearley/bin/nearleyc.js +38 -0
  325. package/node_modules/nearley/builtin/cow.ne +2 -0
  326. package/node_modules/nearley/builtin/number.ne +51 -0
  327. package/node_modules/nearley/builtin/postprocessors.ne +36 -0
  328. package/node_modules/nearley/builtin/string.ne +26 -0
  329. package/node_modules/nearley/builtin/whitespace.ne +5 -0
  330. package/node_modules/nearley/lib/compile.js +307 -0
  331. package/node_modules/nearley/lib/generate.js +244 -0
  332. package/node_modules/nearley/lib/lint.js +28 -0
  333. package/node_modules/nearley/lib/nearley-language-bootstrapped.js +132 -0
  334. package/node_modules/nearley/lib/nearley-language-bootstrapped.ne +126 -0
  335. package/node_modules/nearley/lib/nearley.js +564 -0
  336. package/node_modules/nearley/lib/stream.js +18 -0
  337. package/node_modules/nearley/lib/unparse.js +139 -0
  338. package/node_modules/nearley/package.json +63 -0
  339. package/node_modules/pgsql-ast-parser/ast-mapper.d.ts +237 -0
  340. package/node_modules/pgsql-ast-parser/ast-mapper.d.ts.map +1 -0
  341. package/node_modules/pgsql-ast-parser/ast-mapper.spec.d.ts +3 -0
  342. package/node_modules/pgsql-ast-parser/ast-mapper.spec.d.ts.map +1 -0
  343. package/node_modules/pgsql-ast-parser/ast-visitor.d.ts +33 -0
  344. package/node_modules/pgsql-ast-parser/ast-visitor.d.ts.map +1 -0
  345. package/node_modules/pgsql-ast-parser/ast-visitor.spec.d.ts +3 -0
  346. package/node_modules/pgsql-ast-parser/ast-visitor.spec.d.ts.map +1 -0
  347. package/node_modules/pgsql-ast-parser/index.d.ts +11 -0
  348. package/node_modules/pgsql-ast-parser/index.d.ts.map +1 -0
  349. package/node_modules/pgsql-ast-parser/index.js +6484 -0
  350. package/node_modules/pgsql-ast-parser/index.js.map +1 -0
  351. package/node_modules/pgsql-ast-parser/interfaces.d.ts +1 -0
  352. package/node_modules/pgsql-ast-parser/interfaces.d.ts.map +1 -0
  353. package/node_modules/pgsql-ast-parser/keywords.d.ts +2 -0
  354. package/node_modules/pgsql-ast-parser/keywords.d.ts.map +1 -0
  355. package/node_modules/pgsql-ast-parser/lexer.d.ts +15 -0
  356. package/node_modules/pgsql-ast-parser/lexer.d.ts.map +1 -0
  357. package/node_modules/pgsql-ast-parser/lexer.spec.d.ts +3 -0
  358. package/node_modules/pgsql-ast-parser/lexer.spec.d.ts.map +1 -0
  359. package/node_modules/pgsql-ast-parser/literal-syntaxes/array-lexer.d.ts +3 -0
  360. package/node_modules/pgsql-ast-parser/literal-syntaxes/array-lexer.d.ts.map +1 -0
  361. package/node_modules/pgsql-ast-parser/literal-syntaxes/array.ne.d.ts +29 -0
  362. package/node_modules/pgsql-ast-parser/literal-syntaxes/array.ne.d.ts.map +1 -0
  363. package/node_modules/pgsql-ast-parser/literal-syntaxes/array.spec.d.ts +3 -0
  364. package/node_modules/pgsql-ast-parser/literal-syntaxes/array.spec.d.ts.map +1 -0
  365. package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric-lexer.d.ts +3 -0
  366. package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric-lexer.d.ts.map +1 -0
  367. package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.ne.d.ts +29 -0
  368. package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.ne.d.ts.map +1 -0
  369. package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.spec.d.ts +3 -0
  370. package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.spec.d.ts.map +1 -0
  371. package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-builder.d.ts +10 -0
  372. package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-builder.d.ts.map +1 -0
  373. package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso-lexer.d.ts +3 -0
  374. package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso-lexer.d.ts.map +1 -0
  375. package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso.ne.d.ts +29 -0
  376. package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso.ne.d.ts.map +1 -0
  377. package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-lexer.d.ts +3 -0
  378. package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-lexer.d.ts.map +1 -0
  379. package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.ne.d.ts +29 -0
  380. package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.ne.d.ts.map +1 -0
  381. package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.spec.d.ts +3 -0
  382. package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.spec.d.ts.map +1 -0
  383. package/node_modules/pgsql-ast-parser/package.json +69 -0
  384. package/node_modules/pgsql-ast-parser/parser.d.ts +33 -0
  385. package/node_modules/pgsql-ast-parser/parser.d.ts.map +1 -0
  386. package/node_modules/pgsql-ast-parser/pg-escape.d.ts +2 -0
  387. package/node_modules/pgsql-ast-parser/pg-escape.d.ts.map +1 -0
  388. package/node_modules/pgsql-ast-parser/readme.md +255 -0
  389. package/node_modules/pgsql-ast-parser/src/ast-mapper.spec.ts +296 -0
  390. package/node_modules/pgsql-ast-parser/src/ast-mapper.ts +1378 -0
  391. package/node_modules/pgsql-ast-parser/src/ast-visitor.spec.ts +57 -0
  392. package/node_modules/pgsql-ast-parser/src/ast-visitor.ts +101 -0
  393. package/node_modules/pgsql-ast-parser/src/index.ts +10 -0
  394. package/node_modules/pgsql-ast-parser/src/interfaces.ts +0 -0
  395. package/node_modules/pgsql-ast-parser/src/keywords.ts +8 -0
  396. package/node_modules/pgsql-ast-parser/src/lexer.spec.ts +245 -0
  397. package/node_modules/pgsql-ast-parser/src/lexer.ts +267 -0
  398. package/node_modules/pgsql-ast-parser/src/literal-syntaxes/array-lexer.ts +27 -0
  399. package/node_modules/pgsql-ast-parser/src/literal-syntaxes/array.ne +18 -0
  400. package/node_modules/pgsql-ast-parser/src/literal-syntaxes/array.spec.ts +55 -0
  401. package/node_modules/pgsql-ast-parser/src/literal-syntaxes/geometric-lexer.ts +26 -0
  402. package/node_modules/pgsql-ast-parser/src/literal-syntaxes/geometric.ne +88 -0
  403. package/node_modules/pgsql-ast-parser/src/literal-syntaxes/geometric.spec.ts +131 -0
  404. package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-builder.ts +148 -0
  405. package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-iso-lexer.ts +17 -0
  406. package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-iso.ne +53 -0
  407. package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-lexer.ts +26 -0
  408. package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval.ne +54 -0
  409. package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval.spec.ts +106 -0
  410. package/node_modules/pgsql-ast-parser/src/parser.ts +142 -0
  411. package/node_modules/pgsql-ast-parser/src/pg-escape.ts +14 -0
  412. package/node_modules/pgsql-ast-parser/src/syntax/alter-index.ne +29 -0
  413. package/node_modules/pgsql-ast-parser/src/syntax/alter-index.spec.ts +35 -0
  414. package/node_modules/pgsql-ast-parser/src/syntax/alter-table.ne +123 -0
  415. package/node_modules/pgsql-ast-parser/src/syntax/alter-table.spec.ts +476 -0
  416. package/node_modules/pgsql-ast-parser/src/syntax/alter-type.ne +33 -0
  417. package/node_modules/pgsql-ast-parser/src/syntax/alter-type.spec.ts +29 -0
  418. package/node_modules/pgsql-ast-parser/src/syntax/ast.ts +1150 -0
  419. package/node_modules/pgsql-ast-parser/src/syntax/base.ne +369 -0
  420. package/node_modules/pgsql-ast-parser/src/syntax/create-extension.ne +17 -0
  421. package/node_modules/pgsql-ast-parser/src/syntax/create-extension.spec.ts +37 -0
  422. package/node_modules/pgsql-ast-parser/src/syntax/create-index.ne +62 -0
  423. package/node_modules/pgsql-ast-parser/src/syntax/create-index.spec.ts +245 -0
  424. package/node_modules/pgsql-ast-parser/src/syntax/create-table.ne +174 -0
  425. package/node_modules/pgsql-ast-parser/src/syntax/create-table.spec.ts +761 -0
  426. package/node_modules/pgsql-ast-parser/src/syntax/create-type.ne +40 -0
  427. package/node_modules/pgsql-ast-parser/src/syntax/create-type.spec.ts +32 -0
  428. package/node_modules/pgsql-ast-parser/src/syntax/create-view.ne +68 -0
  429. package/node_modules/pgsql-ast-parser/src/syntax/create-view.spec.ts +187 -0
  430. package/node_modules/pgsql-ast-parser/src/syntax/deallocate.ne +13 -0
  431. package/node_modules/pgsql-ast-parser/src/syntax/deallocate.spec.ts +19 -0
  432. package/node_modules/pgsql-ast-parser/src/syntax/delete.ne +36 -0
  433. package/node_modules/pgsql-ast-parser/src/syntax/delete.spec.ts +71 -0
  434. package/node_modules/pgsql-ast-parser/src/syntax/drop.ne +28 -0
  435. package/node_modules/pgsql-ast-parser/src/syntax/drop.spec.ts +77 -0
  436. package/node_modules/pgsql-ast-parser/src/syntax/edge-cases.spec.ts +41 -0
  437. package/node_modules/pgsql-ast-parser/src/syntax/expr.ne +350 -0
  438. package/node_modules/pgsql-ast-parser/src/syntax/expr.spec.ts +1638 -0
  439. package/node_modules/pgsql-ast-parser/src/syntax/functions.ne +114 -0
  440. package/node_modules/pgsql-ast-parser/src/syntax/functions.spec.ts +235 -0
  441. package/node_modules/pgsql-ast-parser/src/syntax/insert.ne +63 -0
  442. package/node_modules/pgsql-ast-parser/src/syntax/insert.spec.ts +292 -0
  443. package/node_modules/pgsql-ast-parser/src/syntax/main.ne +77 -0
  444. package/node_modules/pgsql-ast-parser/src/syntax/nearley.d.ts +3 -0
  445. package/node_modules/pgsql-ast-parser/src/syntax/prepare.ne +8 -0
  446. package/node_modules/pgsql-ast-parser/src/syntax/prepare.spec.ts +44 -0
  447. package/node_modules/pgsql-ast-parser/src/syntax/refresh-materialized-view.ne +19 -0
  448. package/node_modules/pgsql-ast-parser/src/syntax/refresh-materialized-view.spec.ts +42 -0
  449. package/node_modules/pgsql-ast-parser/src/syntax/select.ne +223 -0
  450. package/node_modules/pgsql-ast-parser/src/syntax/select.spec.ts +1063 -0
  451. package/node_modules/pgsql-ast-parser/src/syntax/sequence.ne +101 -0
  452. package/node_modules/pgsql-ast-parser/src/syntax/sequence.spec.ts +103 -0
  453. package/node_modules/pgsql-ast-parser/src/syntax/simple-statements.ne +168 -0
  454. package/node_modules/pgsql-ast-parser/src/syntax/simple-statements.spec.ts +327 -0
  455. package/node_modules/pgsql-ast-parser/src/syntax/spec-utils.ts +333 -0
  456. package/node_modules/pgsql-ast-parser/src/syntax/union.ne +18 -0
  457. package/node_modules/pgsql-ast-parser/src/syntax/union.spec.ts +125 -0
  458. package/node_modules/pgsql-ast-parser/src/syntax/update.ne +56 -0
  459. package/node_modules/pgsql-ast-parser/src/syntax/update.spec.ts +87 -0
  460. package/node_modules/pgsql-ast-parser/src/syntax/with.ne +41 -0
  461. package/node_modules/pgsql-ast-parser/src/syntax/with.spec.ts +155 -0
  462. package/node_modules/pgsql-ast-parser/src/to-sql.spec.ts +85 -0
  463. package/node_modules/pgsql-ast-parser/src/to-sql.ts +1555 -0
  464. package/node_modules/pgsql-ast-parser/src/utils.ts +47 -0
  465. package/node_modules/pgsql-ast-parser/syntax/alter-index.spec.d.ts +3 -0
  466. package/node_modules/pgsql-ast-parser/syntax/alter-index.spec.d.ts.map +1 -0
  467. package/node_modules/pgsql-ast-parser/syntax/alter-table.spec.d.ts +3 -0
  468. package/node_modules/pgsql-ast-parser/syntax/alter-table.spec.d.ts.map +1 -0
  469. package/node_modules/pgsql-ast-parser/syntax/alter-type.spec.d.ts +3 -0
  470. package/node_modules/pgsql-ast-parser/syntax/alter-type.spec.d.ts.map +1 -0
  471. package/node_modules/pgsql-ast-parser/syntax/ast.d.ts +826 -0
  472. package/node_modules/pgsql-ast-parser/syntax/ast.d.ts.map +1 -0
  473. package/node_modules/pgsql-ast-parser/syntax/create-extension.spec.d.ts +3 -0
  474. package/node_modules/pgsql-ast-parser/syntax/create-extension.spec.d.ts.map +1 -0
  475. package/node_modules/pgsql-ast-parser/syntax/create-index.spec.d.ts +3 -0
  476. package/node_modules/pgsql-ast-parser/syntax/create-index.spec.d.ts.map +1 -0
  477. package/node_modules/pgsql-ast-parser/syntax/create-table.spec.d.ts +3 -0
  478. package/node_modules/pgsql-ast-parser/syntax/create-table.spec.d.ts.map +1 -0
  479. package/node_modules/pgsql-ast-parser/syntax/create-type.spec.d.ts +3 -0
  480. package/node_modules/pgsql-ast-parser/syntax/create-type.spec.d.ts.map +1 -0
  481. package/node_modules/pgsql-ast-parser/syntax/create-view.spec.d.ts +3 -0
  482. package/node_modules/pgsql-ast-parser/syntax/create-view.spec.d.ts.map +1 -0
  483. package/node_modules/pgsql-ast-parser/syntax/deallocate.spec.d.ts +3 -0
  484. package/node_modules/pgsql-ast-parser/syntax/deallocate.spec.d.ts.map +1 -0
  485. package/node_modules/pgsql-ast-parser/syntax/delete.spec.d.ts +3 -0
  486. package/node_modules/pgsql-ast-parser/syntax/delete.spec.d.ts.map +1 -0
  487. package/node_modules/pgsql-ast-parser/syntax/drop.spec.d.ts +3 -0
  488. package/node_modules/pgsql-ast-parser/syntax/drop.spec.d.ts.map +1 -0
  489. package/node_modules/pgsql-ast-parser/syntax/edge-cases.spec.d.ts +3 -0
  490. package/node_modules/pgsql-ast-parser/syntax/edge-cases.spec.d.ts.map +1 -0
  491. package/node_modules/pgsql-ast-parser/syntax/expr.spec.d.ts +3 -0
  492. package/node_modules/pgsql-ast-parser/syntax/expr.spec.d.ts.map +1 -0
  493. package/node_modules/pgsql-ast-parser/syntax/functions.spec.d.ts +3 -0
  494. package/node_modules/pgsql-ast-parser/syntax/functions.spec.d.ts.map +1 -0
  495. package/node_modules/pgsql-ast-parser/syntax/insert.spec.d.ts +3 -0
  496. package/node_modules/pgsql-ast-parser/syntax/insert.spec.d.ts.map +1 -0
  497. package/node_modules/pgsql-ast-parser/syntax/main.ne.d.ts +29 -0
  498. package/node_modules/pgsql-ast-parser/syntax/main.ne.d.ts.map +1 -0
  499. package/node_modules/pgsql-ast-parser/syntax/prepare.spec.d.ts +3 -0
  500. package/node_modules/pgsql-ast-parser/syntax/prepare.spec.d.ts.map +1 -0
  501. package/node_modules/pgsql-ast-parser/syntax/refresh-materialized-view.spec.d.ts +3 -0
  502. package/node_modules/pgsql-ast-parser/syntax/refresh-materialized-view.spec.d.ts.map +1 -0
  503. package/node_modules/pgsql-ast-parser/syntax/select.spec.d.ts +3 -0
  504. package/node_modules/pgsql-ast-parser/syntax/select.spec.d.ts.map +1 -0
  505. package/node_modules/pgsql-ast-parser/syntax/sequence.spec.d.ts +3 -0
  506. package/node_modules/pgsql-ast-parser/syntax/sequence.spec.d.ts.map +1 -0
  507. package/node_modules/pgsql-ast-parser/syntax/simple-statements.spec.d.ts +3 -0
  508. package/node_modules/pgsql-ast-parser/syntax/simple-statements.spec.d.ts.map +1 -0
  509. package/node_modules/pgsql-ast-parser/syntax/spec-utils.d.ts +35 -0
  510. package/node_modules/pgsql-ast-parser/syntax/spec-utils.d.ts.map +1 -0
  511. package/node_modules/pgsql-ast-parser/syntax/union.spec.d.ts +3 -0
  512. package/node_modules/pgsql-ast-parser/syntax/union.spec.d.ts.map +1 -0
  513. package/node_modules/pgsql-ast-parser/syntax/update.spec.d.ts +3 -0
  514. package/node_modules/pgsql-ast-parser/syntax/update.spec.d.ts.map +1 -0
  515. package/node_modules/pgsql-ast-parser/syntax/with.spec.d.ts +3 -0
  516. package/node_modules/pgsql-ast-parser/syntax/with.spec.d.ts.map +1 -0
  517. package/node_modules/pgsql-ast-parser/to-sql.d.ts +7 -0
  518. package/node_modules/pgsql-ast-parser/to-sql.d.ts.map +1 -0
  519. package/node_modules/pgsql-ast-parser/to-sql.spec.d.ts +3 -0
  520. package/node_modules/pgsql-ast-parser/to-sql.spec.d.ts.map +1 -0
  521. package/node_modules/pgsql-ast-parser/utils.d.ts +16 -0
  522. package/node_modules/pgsql-ast-parser/utils.d.ts.map +1 -0
  523. package/node_modules/railroad-diagrams/.gitattributes +22 -0
  524. package/node_modules/railroad-diagrams/.npmignore +163 -0
  525. package/node_modules/railroad-diagrams/README.md +86 -0
  526. package/node_modules/railroad-diagrams/css-example.py-js +183 -0
  527. package/node_modules/railroad-diagrams/example.html +141 -0
  528. package/node_modules/railroad-diagrams/generator.html +59 -0
  529. package/node_modules/railroad-diagrams/package.json +23 -0
  530. package/node_modules/railroad-diagrams/railroad-diagrams.css +23 -0
  531. package/node_modules/railroad-diagrams/railroad-diagrams.js +524 -0
  532. package/node_modules/railroad-diagrams/railroad_diagrams.py +427 -0
  533. package/node_modules/randexp/LICENSE +19 -0
  534. package/node_modules/randexp/README.md +134 -0
  535. package/node_modules/randexp/lib/randexp.js +245 -0
  536. package/node_modules/randexp/package.json +48 -0
  537. package/node_modules/ret/LICENSE +19 -0
  538. package/node_modules/ret/README.md +183 -0
  539. package/node_modules/ret/lib/index.js +282 -0
  540. package/node_modules/ret/lib/positions.js +17 -0
  541. package/node_modules/ret/lib/sets.js +82 -0
  542. package/node_modules/ret/lib/types.js +10 -0
  543. package/node_modules/ret/lib/util.js +111 -0
  544. package/node_modules/ret/package.json +35 -0
  545. package/package.json +22 -6
  546. package/schemas/cchistory-lite-agent-v1.schema.json +6 -7
  547. package/schemas/cchistory-lite-error-v1.schema.json +58 -8
  548. package/schemas/cchistory-lite-query-result-v2.schema.json +66 -11
  549. package/schemas/cchistory-lite-query-result-v3.schema.json +219 -0
  550. package/schemas/cchistory-lite-query-v3.schema.json +57 -0
  551. package/schemas/cchistory-lite-source-inventory-v1.schema.json +72 -0
  552. package/skills/using-cchistory-lite/SKILL.md +126 -55
  553. package/node_modules/@cchistory/live-runtime/dist/node-memory.d.ts +0 -8
  554. package/node_modules/@cchistory/live-runtime/dist/node-memory.d.ts.map +0 -1
  555. package/node_modules/@cchistory/live-runtime/dist/node-memory.js +0 -110
  556. package/node_modules/@cchistory/live-runtime/dist/node-memory.js.map +0 -1
@@ -0,0 +1,301 @@
1
+ import { Worker } from "node:worker_threads";
2
+ import { QUERY_COLUMNS } from "@cchistory/canonical";
3
+ export const SQL_REQUEST_SCHEMA = "cchistory-lite-query/v3";
4
+ export const SQL_RESULT_SCHEMA = "cchistory-lite-query-result/v3";
5
+ export const MAX_SQL_BYTES = 16_384;
6
+ export const MAX_QUERY_REQUEST_BYTES = 1_048_576;
7
+ export class QueryValidationError extends Error {
8
+ reason;
9
+ operationId;
10
+ code = "invalid_query_request";
11
+ constructor(message, reason, operationId) {
12
+ super(message);
13
+ this.reason = reason;
14
+ this.operationId = operationId;
15
+ }
16
+ }
17
+ const fail = (reason, message) => { throw new QueryValidationError(message, reason); };
18
+ function node(value) {
19
+ if (!value || typeof value !== "object" || Array.isArray(value))
20
+ return fail("unsupported", "Expected a supported SQL node.");
21
+ return value;
22
+ }
23
+ function only(value, keys) {
24
+ if (Object.keys(value).some(k => !keys.includes(k)))
25
+ fail("unsupported", "Unsupported query construct or option.");
26
+ }
27
+ export function parseSqlRequest(raw) {
28
+ if (Buffer.byteLength(raw) > MAX_QUERY_REQUEST_BYTES)
29
+ fail("budget", "Query request exceeds 1 MiB.");
30
+ let value;
31
+ try {
32
+ value = JSON.parse(raw);
33
+ }
34
+ catch {
35
+ return fail("syntax", "Query request must be JSON.");
36
+ }
37
+ const root = node(value);
38
+ only(root, ["schema", "operations"]);
39
+ if (root.schema !== SQL_REQUEST_SCHEMA)
40
+ fail("unsupported", `Expected ${SQL_REQUEST_SCHEMA}.`);
41
+ if (!Array.isArray(root.operations) || root.operations.length < 1 || root.operations.length > 16)
42
+ fail("budget", "Expected 1–16 SQL operations.");
43
+ const seen = new Set();
44
+ const operations = root.operations.map(value => {
45
+ const op = node(value);
46
+ only(op, ["id", "kind", "sql", "params", "complete"]);
47
+ if (typeof op.id !== "string" || !op.id.trim() || seen.has(op.id))
48
+ fail("parameter", "Operation IDs must be nonempty and unique.");
49
+ if (op.kind !== "sql")
50
+ fail("unsupported", "v3 accepts SQL operations only.");
51
+ if (op.complete !== undefined && typeof op.complete !== "boolean")
52
+ fail("type", "complete must be a boolean.");
53
+ seen.add(op.id);
54
+ try {
55
+ validateSqlInput(op.sql, op.params === undefined ? [] : op.params);
56
+ }
57
+ catch (e) {
58
+ if (e instanceof QueryValidationError)
59
+ throw new QueryValidationError(e.message, e.reason, op.id);
60
+ throw e;
61
+ }
62
+ return { id: op.id, kind: "sql", sql: op.sql, params: (op.params === undefined ? [] : op.params), complete: op.complete === true };
63
+ });
64
+ return { schema: SQL_REQUEST_SCHEMA, operations };
65
+ }
66
+ function validateSqlInput(sql, params) {
67
+ if (typeof sql !== "string" || !sql.trim())
68
+ fail("syntax", "SQL must be a nonempty string.");
69
+ if (Buffer.byteLength(sql) > MAX_SQL_BYTES)
70
+ fail("budget", "SQL exceeds 16 KiB.");
71
+ if (!Array.isArray(params) || params.length > 32)
72
+ fail("parameter", "Bind at most 32 scalar parameters.");
73
+ if (Buffer.byteLength(JSON.stringify(params)) > MAX_SQL_BYTES)
74
+ fail("budget", "Parameters exceed 16 KiB.");
75
+ if (params.some(v => v !== null && !["string", "number", "boolean"].includes(typeof v) || typeof v === "number" && !Number.isFinite(v))) {
76
+ fail("parameter", "Parameters must be finite JSON scalars or null.");
77
+ }
78
+ }
79
+ export async function compileSqlRequest(request) {
80
+ // Revalidate library callers too, before starting a worker or touching history.
81
+ const checked = parseSqlRequest(JSON.stringify(request));
82
+ const worker = new Worker(new URL("./sql-worker.js", import.meta.url));
83
+ const message = (timeout) => new Promise((resolve, reject) => {
84
+ const cleanup = () => { clearTimeout(timer); worker.off("message", onMessage); worker.off("error", onError); worker.off("exit", onExit); };
85
+ const onMessage = (value) => { cleanup(); resolve(value); };
86
+ const onError = (error) => { cleanup(); reject(error); };
87
+ const onExit = () => onError(new QueryValidationError("SQL parser exited before completing the request.", "budget"));
88
+ const timer = setTimeout(() => onError(new QueryValidationError("SQL parser exceeded its execution deadline.", "budget")), timeout);
89
+ worker.once("message", onMessage);
90
+ worker.once("error", onError);
91
+ worker.once("exit", onExit);
92
+ });
93
+ try {
94
+ await message(5000);
95
+ const operations = [];
96
+ for (const op of checked.operations) {
97
+ try {
98
+ const pending = message(1000);
99
+ worker.postMessage(op.sql);
100
+ const parsed = await pending;
101
+ if (parsed.error)
102
+ fail("syntax", String(parsed.error));
103
+ operations.push({ id: op.id, kind: "sql", query: lowerSqlAst(parsed.ast, op.params, op.complete) });
104
+ }
105
+ catch (e) {
106
+ if (e instanceof QueryValidationError)
107
+ throw new QueryValidationError(e.message, e.reason, op.id);
108
+ throw e;
109
+ }
110
+ }
111
+ return { schema: SQL_REQUEST_SCHEMA, operations };
112
+ }
113
+ finally {
114
+ await worker.terminate();
115
+ }
116
+ }
117
+ export async function compileSql(sql, params = [], complete = false) {
118
+ return (await compileSqlRequest({ schema: SQL_REQUEST_SCHEMA, operations: [{ id: "query", kind: "sql", sql, params, complete }] })).operations[0].query;
119
+ }
120
+ function timestamp(value, parameter) {
121
+ const reject = () => fail(parameter ? "parameter" : "type", "Expected a valid RFC3339 timestamp with a timezone and millisecond precision.");
122
+ const m = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,3}))?(Z|[+-]\d{2}:\d{2})$/u.exec(value);
123
+ if (!m)
124
+ return reject();
125
+ const [year, month, day, hour, minute, second] = m.slice(1, 7).map(Number);
126
+ const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
127
+ const days = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
128
+ if (month < 1 || month > 12 || day < 1 || day > days[month - 1] || hour > 23 || minute > 59 || second > 59)
129
+ return reject();
130
+ if (m[8] !== "Z" && (Number(m[8].slice(1, 3)) > 23 || Number(m[8].slice(4)) > 59))
131
+ return reject();
132
+ const date = new Date(value);
133
+ if (!Number.isFinite(date.getTime()))
134
+ return reject();
135
+ return date.toISOString();
136
+ }
137
+ /** Positive AST allowlist. Parser support does not grant a feature to the product. */
138
+ export function lowerSqlAst(ast, params, complete) {
139
+ if (!Array.isArray(ast) || ast.length !== 1)
140
+ return fail("unsupported", "Exactly one SELECT statement is required.");
141
+ const select = node(ast[0]);
142
+ only(select, ["type", "columns", "from", "where", "orderBy", "limit"]);
143
+ if (select.type !== "select")
144
+ fail("unsupported", "Only SELECT is supported.");
145
+ if (!Array.isArray(select.from) || select.from.length !== 1)
146
+ fail("unsupported", "Select one collection.");
147
+ const from = node(select.from[0]);
148
+ only(from, ["type", "name"]);
149
+ if (from.type !== "table")
150
+ fail("unsupported", "Select one collection.");
151
+ const table = node(from.name);
152
+ only(table, ["name"]);
153
+ if (table.name !== "sessions" && table.name !== "turns")
154
+ fail("field", "Collection must be sessions or turns.");
155
+ const collection = table.name;
156
+ const fields = new Map(QUERY_COLUMNS[collection].map(c => [c.name, c]));
157
+ const ref = (raw) => {
158
+ const n = node(raw);
159
+ only(n, ["type", "name"]);
160
+ if (n.type !== "ref")
161
+ return fail("unsupported", "Expected a bare public field.");
162
+ if (typeof n.name !== "string" || !fields.has(n.name))
163
+ return fail("field", `Unknown ${collection} field: ${String(n.name)}.`);
164
+ return n.name;
165
+ };
166
+ const used = new Set(), expectedTypes = new Map();
167
+ const value = (raw, type) => {
168
+ const n = node(raw);
169
+ let v;
170
+ const parameter = n.type === "parameter";
171
+ if (parameter) {
172
+ only(n, ["type", "name"]);
173
+ const index = Number(String(n.name).slice(1));
174
+ if (!/^\$[1-9]\d*$/u.test(String(n.name)) || index > params.length)
175
+ return fail("parameter", "Missing parameter binding.");
176
+ used.add(index);
177
+ if (expectedTypes.has(index) && expectedTypes.get(index) !== type)
178
+ return fail("type", "Repeated parameter requires incompatible types.");
179
+ expectedTypes.set(index, type);
180
+ v = params[index - 1];
181
+ }
182
+ else if (n.type === "null") {
183
+ only(n, ["type"]);
184
+ v = null;
185
+ }
186
+ else if (["string", "integer", "numeric", "boolean"].includes(String(n.type))) {
187
+ only(n, ["type", "value"]);
188
+ v = n.value;
189
+ }
190
+ else if (n.type === "unary" && ["-", "+"].includes(String(n.op))) {
191
+ only(n, ["type", "op", "operand"]);
192
+ const operand = node(n.operand);
193
+ if (!["integer", "numeric"].includes(String(operand.type)))
194
+ return fail("unsupported", "Only numeric literal signs are supported.");
195
+ const literal = value(operand, "number");
196
+ v = n.op === "-" ? -literal : literal;
197
+ }
198
+ else
199
+ return fail("unsupported", "Expected a scalar literal or bound parameter.");
200
+ if (v === null)
201
+ return null;
202
+ if (typeof v !== (type === "timestamp" ? "string" : type) || typeof v === "number" && !Number.isFinite(v))
203
+ return fail("type", `Expected ${type} operand.`);
204
+ return type === "timestamp" ? timestamp(v, parameter) : v;
205
+ };
206
+ let leaves = 0;
207
+ const predicate = (raw, depth = 0) => {
208
+ if (depth > 8 || ++leaves > 128)
209
+ return fail("budget", "Predicate complexity exceeds v1 bounds.");
210
+ const n = node(raw);
211
+ if (n.type === "binary" && (n.op === "AND" || n.op === "OR")) {
212
+ leaves--;
213
+ only(n, ["type", "op", "left", "right"]);
214
+ return { kind: n.op === "AND" ? "and" : "or", left: predicate(n.left, depth + 1), right: predicate(n.right, depth + 1) };
215
+ }
216
+ if (n.type === "unary" && n.op === "NOT") {
217
+ leaves--;
218
+ only(n, ["type", "op", "operand"]);
219
+ return { kind: "not", operand: predicate(n.operand, depth + 1) };
220
+ }
221
+ if (leaves > 64)
222
+ return fail("budget", "At most 64 predicate leaves are supported.");
223
+ if (n.type === "unary" && (n.op === "IS NULL" || n.op === "IS NOT NULL")) {
224
+ only(n, ["type", "op", "operand"]);
225
+ return { kind: "null", field: ref(n.operand), negate: n.op === "IS NOT NULL" };
226
+ }
227
+ if (n.type === "ternary" && (n.op === "BETWEEN" || n.op === "NOT BETWEEN")) {
228
+ only(n, ["type", "op", "value", "lo", "hi"]);
229
+ const field = ref(n.value), type = fields.get(field).type;
230
+ if (type !== "number" && type !== "timestamp")
231
+ return fail("type", "BETWEEN requires a number or timestamp field.");
232
+ const range = { kind: "and", left: { kind: "compare", field, op: ">=", value: value(n.lo, type) }, right: { kind: "compare", field, op: "<=", value: value(n.hi, type) } };
233
+ return n.op === "BETWEEN" ? range : { kind: "not", operand: range };
234
+ }
235
+ if (n.type !== "binary")
236
+ return fail("unsupported", "Unsupported predicate.");
237
+ only(n, ["type", "op", "left", "right"]);
238
+ const field = ref(n.left), type = fields.get(field).type, op = String(n.op);
239
+ if (op === "IN" || op === "NOT IN") {
240
+ const list = node(n.right);
241
+ only(list, ["type", "expressions"]);
242
+ if (list.type !== "list" || !Array.isArray(list.expressions))
243
+ return fail("unsupported", "IN requires a value list.");
244
+ if (list.expressions.length < 1 || list.expressions.length > 32)
245
+ return fail("budget", "IN accepts 1–32 values.");
246
+ return { kind: "in", field, values: list.expressions.map(v => value(v, type)), negate: op === "NOT IN" };
247
+ }
248
+ if (op === "LIKE" || op === "NOT LIKE") {
249
+ if (type !== "string")
250
+ return fail("type", "LIKE requires a string field.");
251
+ const pattern = value(n.right, "string");
252
+ if (pattern !== null && (pattern.match(/\\+$/u)?.[0].length ?? 0) % 2 === 1)
253
+ return fail(node(n.right).type === "parameter" ? "parameter" : "type", "LIKE pattern has a dangling escape.");
254
+ return { kind: "like", field, pattern, negate: op === "NOT LIKE" };
255
+ }
256
+ if (!["=", "!=", "<", "<=", ">", ">="].includes(op))
257
+ return fail("unsupported", `Unsupported operator: ${op}.`);
258
+ if (op !== "=" && op !== "!=" && type !== "number" && type !== "timestamp")
259
+ return fail("type", "Ordering comparisons require numbers or timestamps.");
260
+ return { kind: "compare", field, op: op, value: value(n.right, type) };
261
+ };
262
+ if (!Array.isArray(select.columns) || !select.columns.length)
263
+ fail("field", "Select public columns.");
264
+ const projections = select.columns.map(raw => { const c = node(raw); only(c, ["expr"]); return c.expr; });
265
+ let columns;
266
+ if (projections.length === 1 && node(projections[0]).type === "ref" && node(projections[0]).name === "*") {
267
+ only(node(projections[0]), ["type", "name"]);
268
+ columns = [...fields.keys()];
269
+ }
270
+ else
271
+ columns = projections.map(ref);
272
+ if (new Set(columns).size !== columns.length)
273
+ fail("field", "Duplicate columns are not supported.");
274
+ const where = select.where === undefined ? undefined : predicate(select.where);
275
+ if (select.orderBy !== undefined && !Array.isArray(select.orderBy))
276
+ fail("unsupported", "Unsupported ordering.");
277
+ const order = (select.orderBy ?? []).map(raw => {
278
+ const o = node(raw);
279
+ only(o, ["by", "order", "nulls"]);
280
+ const field = ref(o.by);
281
+ const direction = o.order ?? "ASC", nulls = o.nulls ?? (direction === "ASC" ? "LAST" : "FIRST");
282
+ if (direction !== "ASC" && direction !== "DESC" || nulls !== "FIRST" && nulls !== "LAST")
283
+ fail("unsupported", "Unsupported ordering.");
284
+ return { field, direction: direction, nulls: nulls };
285
+ });
286
+ if (order.length > 3 || new Set(order.map(x => x.field)).size !== order.length)
287
+ fail("budget", "Order by up to three distinct fields.");
288
+ if (select.limit === undefined)
289
+ return fail("budget", "An explicit LIMIT is required.");
290
+ const page = node(select.limit);
291
+ only(page, ["limit", "offset"]);
292
+ if (page.limit === undefined)
293
+ return fail("budget", "An explicit LIMIT is required.");
294
+ const limit = value(page.limit, "number"), offset = page.offset === undefined ? 0 : value(page.offset, "number");
295
+ if (typeof limit !== "number" || !Number.isSafeInteger(limit) || limit < 1 || limit > 1000 || typeof offset !== "number" || !Number.isSafeInteger(offset) || offset < 0 || offset > 100000)
296
+ return fail("budget", "LIMIT must be 1–1000 and OFFSET 0–100000.");
297
+ if (used.size !== params.length || [...used].some(i => i < 1 || i > used.size))
298
+ fail("parameter", "Bindings must exactly match contiguous $1…$N references.");
299
+ return { collection, columns, predicate: where, order, limit, offset, complete };
300
+ }
301
+ //# sourceMappingURL=sql-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql-query.js","sourceRoot":"","sources":["../src/sql-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,MAAM,CAAC,MAAM,kBAAkB,GAAG,yBAAyB,CAAC;AAC5D,MAAM,CAAC,MAAM,iBAAiB,GAAG,gCAAgC,CAAC;AACl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AC,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACjH,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,GAAG,MAAM;QAAE,OAAO,IAAI,CAAC,QAAQ,EAAE,2CAA2C,CAAC,CAAC;IAC/P,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;QAAE,IAAI,CAAC,WAAW,EAAE,0DAA0D,CAAC,CAAC;IAC9J,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACnF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=sql-query.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql-query.test.d.ts","sourceRoot":"","sources":["../src/sql-query.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,67 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFile } from "node:fs/promises";
3
+ import test from "node:test";
4
+ import { executeQueryRows, collectionQueryTemplate } from "@cchistory/canonical";
5
+ import { compileSql, compileSqlRequest, parseSqlRequest, SQL_REQUEST_SCHEMA, QueryValidationError } from "./sql-query.js";
6
+ const fixture = JSON.parse(await readFile(new URL("../../../mock_data/fixtures/query-contract/review.json", import.meta.url), "utf8"));
7
+ const rows = (collection) => (collection === "sessions" ? fixture.canonical_session_order : fixture.canonical_turn_order)
8
+ .map(id => fixture[collection].find(row => row.id === id));
9
+ test("Q1–Q5: the reviewed SQL corpus executes with fixed IDs, values, and canonical ties", async () => {
10
+ const request = await compileSqlRequest({ schema: SQL_REQUEST_SCHEMA, operations: fixture.queries.map(({ id, sql, params }) => ({ id, kind: "sql", sql, params, complete: false })) });
11
+ for (const [index, op] of request.operations.entries()) {
12
+ const expected = fixture.queries[index];
13
+ const result = executeQueryRows(rows(op.query.collection), op.query);
14
+ assert.deepEqual(result.ids, expected.expected_ids, expected.id);
15
+ assert.equal(result.total, null);
16
+ if (expected.expected_rows)
17
+ assert.deepEqual(result.rows, expected.expected_rows);
18
+ }
19
+ for (const [id, template] of [["latest_sessions", "latest-sessions"], ["latest_turns", "latest-turns"], ["list_sessions", "list-sessions"]]) {
20
+ const sql = request.operations.find(op => op.id === id).query;
21
+ const command = collectionQueryTemplate(template, sql.limit, sql.offset);
22
+ const fromSql = executeQueryRows(rows(sql.collection), { ...sql, complete: true });
23
+ const fromCommand = executeQueryRows(rows(command.collection), command);
24
+ assert.deepEqual(fromCommand.ids, fromSql.ids);
25
+ assert.equal(fromCommand.total, fromSql.total);
26
+ }
27
+ });
28
+ test("Q6: concrete and generated rejected queries never lower into executable plans", async () => {
29
+ for (const q of fixture.rejections) {
30
+ await assert.rejects(compileSql(q.sql, q.params), e => e instanceof QueryValidationError && e.reason === q.expected_rejection, q.id);
31
+ }
32
+ const rejected = [
33
+ 'SELECT id FROM sessions LIMIT 1; /*' + 'x'.repeat(16385) + '*/',
34
+ 'SELECT id FROM sessions WHERE ' + 'NOT '.repeat(9) + '(turn_count = 1) LIMIT 1',
35
+ 'SELECT id FROM sessions WHERE ' + Array(65).fill('turn_count = 1').join(' OR ') + ' LIMIT 1',
36
+ 'SELECT id FROM sessions WHERE id IN (' + Array(33).fill("'s1'").join(',') + ') LIMIT 1',
37
+ ];
38
+ for (const sql of rejected)
39
+ await assert.rejects(compileSql(sql), e => e instanceof QueryValidationError && e.reason === "budget");
40
+ for (const sql of [
41
+ 'SELECT id AS x FROM sessions LIMIT 1', 'SELECT id FROM sessions AS x LIMIT 1',
42
+ 'SELECT DISTINCT id FROM sessions LIMIT 1', 'SELECT sessions.id FROM sessions LIMIT 1',
43
+ 'SELECT * FROM sessions LIMIT 1 OFFSET -1', 'SELECT id, id FROM sessions LIMIT 1',
44
+ 'SELECT id FROM sessions WHERE turn_count = turn_count LIMIT 1',
45
+ ])
46
+ await assert.rejects(compileSql(sql), QueryValidationError);
47
+ await assert.rejects(compileSql('SELECT id FROM sessions LIMIT $2', [1, 2]), QueryValidationError);
48
+ await assert.rejects(compileSql('SELECT id FROM sessions LIMIT 1', [1]), QueryValidationError);
49
+ await assert.rejects(compileSql('SELECT id FROM sessions WHERE title = $1 AND turn_count = $1 LIMIT 1', [1]), QueryValidationError);
50
+ assert.throws(() => parseSqlRequest(JSON.stringify({ schema: SQL_REQUEST_SCHEMA, operations: Array(17).fill({}) })), QueryValidationError);
51
+ assert.throws(() => parseSqlRequest(JSON.stringify({ schema: SQL_REQUEST_SCHEMA, operations: [{ id: "q", kind: "sql", sql: "SELECT id FROM sessions LIMIT 1", params: null }] })), QueryValidationError);
52
+ });
53
+ test("Scalar semantics: timezone normalization, null order, Unicode patterns, and typed values", async () => {
54
+ const run = async (sql, params = []) => {
55
+ const query = await compileSql(sql, params, true);
56
+ return executeQueryRows(rows(query.collection), query);
57
+ };
58
+ assert.deepEqual((await run('SELECT id FROM sessions WHERE last_message_at = $1 LIMIT 10', ['2026-04-15T20:00:00+08:00'])).ids, ['s2', 's1']);
59
+ assert.deepEqual((await run('SELECT id FROM sessions ORDER BY last_message_at DESC LIMIT 1')).ids, ['s5']);
60
+ assert.deepEqual((await run('SELECT id FROM sessions WHERE total_tokens IS NULL OR total_tokens NOT BETWEEN 0 AND 20 LIMIT 10')).ids, ['s1', 's6', 's5']);
61
+ const query = await compileSql('SELECT id FROM sessions WHERE title LIKE $1 LIMIT 10', ['_\\_%']);
62
+ assert.deepEqual(executeQueryRows([{ id: 'unicode', title: '😀_text' }, { id: 'wrong', title: '😀text' }], query).ids, ['unicode']);
63
+ await assert.rejects(compileSql('SELECT id FROM sessions WHERE title LIKE $1 LIMIT 10', ['x\\']), QueryValidationError);
64
+ await assert.rejects(compileSql('SELECT id FROM sessions WHERE created_at = $1 LIMIT 10', ['2026-04-15']), QueryValidationError);
65
+ await assert.rejects(compileSql('SELECT id FROM sessions WHERE turn_count > $1 LIMIT 10', ['1']), QueryValidationError);
66
+ });
67
+ //# sourceMappingURL=sql-query.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql-query.test.js","sourceRoot":"","sources":["../src/sql-query.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,eAAe,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE1H,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,IAAI,GAAG,CAAC,wDAAwD,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAKpI,CAAC;AACF,MAAM,IAAI,GAAG,CAAC,UAA2B,EAAE,EAAE,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAC,OAAO,CAAC,oBAAoB,CAAC;KACvI,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAE,CAAC,CAA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,QAAQ,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IACpI,MAAM,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,sDAAsD,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC;IACxH,MAAM,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,wDAAwD,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC;IACjI,MAAM,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,wDAAwD,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC;AAC1H,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=sql-worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql-worker.d.ts","sourceRoot":"","sources":["../src/sql-worker.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import { parentPort } from "node:worker_threads";
2
+ import { parse } from "pgsql-ast-parser";
3
+ if (!parentPort)
4
+ throw new Error("SQL parser requires a worker port.");
5
+ parentPort.on("message", (sql) => {
6
+ try {
7
+ parentPort.postMessage({ ast: parse(sql) });
8
+ }
9
+ catch {
10
+ parentPort.postMessage({ error: "SQL syntax is not supported by the selected PostgreSQL parser." });
11
+ }
12
+ });
13
+ parentPort.postMessage({ ready: true });
14
+ //# sourceMappingURL=sql-worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql-worker.js","sourceRoot":"","sources":["../src/sql-worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,IAAI,CAAC,UAAU;IAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;AACvE,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,GAAW,EAAE,EAAE;IACvC,IAAI,CAAC;QAAC,UAAW,CAAC,WAAW,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAAC,CAAC;IACrD,MAAM,CAAC;QAAC,UAAW,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,gEAAgE,EAAE,CAAC,CAAC;IAAC,CAAC;AACjH,CAAC,CAAC,CAAC;AACH,UAAU,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC"}
@@ -1,19 +1,22 @@
1
1
  export interface SystemMemoryDeps {
2
2
  platform?: NodeJS.Platform;
3
- /** Reads /proc/meminfo contents; only consulted on Linux. */
3
+ availableMemory?: () => number;
4
4
  readMeminfo?: () => string;
5
+ readVmStat?: () => string;
5
6
  freemem?: () => number;
6
- /** process.constrainedMemory(): the enforced cgroup memory limit, 0 when unconstrained. */
7
+ totalmem?: () => number;
8
+ /** Zero means unavailable/unknown, not proof that no external limit exists. */
7
9
  constrainedMemory?: () => number;
8
10
  }
9
- /**
10
- * Bytes the host can hand out right now. Linux MemAvailable counts reclaimable
11
- * page cache (os.freemem does not), so it is the honest signal on Linux;
12
- * os.freemem() is the fallback elsewhere and when meminfo is unreadable or
13
- * predates MemAvailable. /proc/meminfo and freemem are both host-wide, so an
14
- * enforced cgroup limit caps the result to keep containers honest. Returns
15
- * undefined when no signal is available.
16
- */
11
+ export interface AvailableMemoryReading {
12
+ bytes?: number;
13
+ source: "darwin_vm_stat" | "linux_memavailable" | "node_available" | "os_freemem" | "unknown";
14
+ constrainedBytes?: number;
15
+ }
16
+ /** Darwin's Node availableMemory reports unused pages, not reclaimable memory. */
17
+ export declare function readAvailableMemory(deps?: SystemMemoryDeps): AvailableMemoryReading;
17
18
  export declare function readAvailableMemoryBytes(deps?: SystemMemoryDeps): number | undefined;
19
+ /** Same available-memory accounting as psutil/Zabbix on macOS: free + inactive. */
20
+ export declare function parseDarwinAvailableBytes(raw: string): number | undefined;
18
21
  export declare function parseMemAvailableBytes(meminfo: string): number | undefined;
19
22
  //# sourceMappingURL=system-memory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"system-memory.d.ts","sourceRoot":"","sources":["../src/system-memory.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC3B,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,MAAM,CAAC;IACvB,2FAA2F;IAC3F,iBAAiB,CAAC,EAAE,MAAM,MAAM,CAAC;CAClC;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,GAAE,gBAAqB,GAAG,MAAM,GAAG,SAAS,CAexF;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAK1E"}
1
+ {"version":3,"file":"system-memory.d.ts","sourceRoot":"","sources":["../src/system-memory.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,MAAM,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,MAAM,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,MAAM,CAAC;IACxB,+EAA+E;IAC/E,iBAAiB,CAAC,EAAE,MAAM,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,gBAAgB,GAAG,oBAAoB,GAAG,gBAAgB,GAAG,YAAY,GAAG,SAAS,CAAC;IAC9F,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,kFAAkF;AAClF,wBAAgB,mBAAmB,CAAC,IAAI,GAAE,gBAAqB,GAAG,sBAAsB,CA4BvF;AAED,wBAAgB,wBAAwB,CAAC,IAAI,GAAE,gBAAqB,GAAG,MAAM,GAAG,SAAS,CAExF;AAED,mFAAmF;AACnF,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CASzE;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAK1E"}
@@ -1,46 +1,73 @@
1
+ import { execFileSync } from "node:child_process";
1
2
  import { readFileSync } from "node:fs";
2
3
  import os from "node:os";
3
4
  import process from "node:process";
4
- /**
5
- * Shared system-memory reading for the scan guard and the adaptive heap
6
- * ceiling. Everything here is synchronous (the scan watchdog calls it from
7
- * inside sync progress callbacks) and best-effort: a reading failure returns
8
- * `undefined` ("unknown") and never throws, so a guard can never break a scan
9
- * with its own errors.
10
- */
11
- const MEMINFO_PATH = "/proc/meminfo";
12
- /**
13
- * Bytes the host can hand out right now. Linux MemAvailable counts reclaimable
14
- * page cache (os.freemem does not), so it is the honest signal on Linux;
15
- * os.freemem() is the fallback elsewhere and when meminfo is unreadable or
16
- * predates MemAvailable. /proc/meminfo and freemem are both host-wide, so an
17
- * enforced cgroup limit caps the result to keep containers honest. Returns
18
- * undefined when no signal is available.
19
- */
20
- export function readAvailableMemoryBytes(deps = {}) {
5
+ /** Darwin's Node availableMemory reports unused pages, not reclaimable memory. */
6
+ export function readAvailableMemory(deps = {}) {
21
7
  const platform = deps.platform ?? process.platform;
22
- let available;
23
- if (platform === "linux") {
24
- const meminfo = safeCall(deps.readMeminfo ?? (() => readFileSync(MEMINFO_PATH, "utf8")));
25
- if (meminfo !== undefined)
26
- available = parseMemAvailableBytes(meminfo);
27
- available ??= positiveFiniteBytes(safeCall(deps.freemem ?? (() => os.freemem())));
28
- }
29
- else {
30
- available = positiveFiniteBytes(safeCall(deps.freemem ?? (() => os.freemem())));
8
+ const constraint = finiteBytes(safeCall(deps.constrainedMemory ?? (() => process.constrainedMemory())));
9
+ const constrainedBytes = constraint && constraint > 0 ? constraint : undefined;
10
+ const total = finiteBytes(safeCall(deps.totalmem ?? (() => os.totalmem())));
11
+ const finish = (bytes, source) => ({
12
+ bytes: bytes === undefined ? undefined : Math.min(bytes, total ?? Infinity, constrainedBytes ?? Infinity),
13
+ source: bytes === undefined ? "unknown" : source,
14
+ ...(constrainedBytes === undefined ? {} : { constrainedBytes }),
15
+ });
16
+ if (platform === "darwin") {
17
+ const raw = safeCall(deps.readVmStat ?? readDarwinVmStat);
18
+ // An unreadable/unknown format is unknown capacity. Falling back to free pages
19
+ // would restore the false tiny budget this path exists to avoid.
20
+ return finish(raw === undefined ? undefined : parseDarwinAvailableBytes(raw), "darwin_vm_stat");
31
21
  }
32
- const constrained = positiveFiniteBytes(safeCall(deps.constrainedMemory ?? (() => process.constrainedMemory())));
33
- if (constrained !== undefined && available !== undefined) {
34
- available = Math.min(available, constrained);
22
+ const nodeAvailable = finiteBytes(safeCall(deps.availableMemory ?? (() => process.availableMemory())));
23
+ if (platform === "linux") {
24
+ const raw = safeCall(deps.readMeminfo ?? (() => readFileSync("/proc/meminfo", "utf8")));
25
+ const hostAvailable = raw === undefined ? undefined : parseMemAvailableBytes(raw);
26
+ // Under a known cgroup constraint, Node includes current group usage. Keep a
27
+ // real zero; never replace remaining quota with total quota or host RAM.
28
+ if (constrainedBytes !== undefined && nodeAvailable !== undefined)
29
+ return finish(Math.min(nodeAvailable, hostAvailable ?? Infinity), "node_available");
30
+ if (hostAvailable !== undefined)
31
+ return finish(hostAvailable, "linux_memavailable");
35
32
  }
36
- return available;
33
+ if (nodeAvailable !== undefined)
34
+ return finish(nodeAvailable, "node_available");
35
+ return finish(finiteBytes(safeCall(deps.freemem ?? (() => os.freemem()))), "os_freemem");
36
+ }
37
+ export function readAvailableMemoryBytes(deps = {}) {
38
+ return readAvailableMemory(deps).bytes;
39
+ }
40
+ /** Same available-memory accounting as psutil/Zabbix on macOS: free + inactive. */
41
+ export function parseDarwinAvailableBytes(raw) {
42
+ const pageSize = Number(/page size of (\d+) bytes/u.exec(raw)?.[1]);
43
+ const free = /^Pages free:\s*(\d+)\.\s*$/mu.exec(raw)?.[1];
44
+ const inactive = /^Pages inactive:\s*(\d+)\.\s*$/mu.exec(raw)?.[1];
45
+ if (!Number.isSafeInteger(pageSize) || pageSize <= 0 || free === undefined || inactive === undefined)
46
+ return undefined;
47
+ // vm_stat free_count already includes speculative pages. Purgeable, file-backed
48
+ // and compressor counts overlap other categories; don't add them again.
49
+ const bytes = (Number(free) + Number(inactive)) * pageSize;
50
+ return Number.isSafeInteger(bytes) && bytes >= 0 ? bytes : undefined;
37
51
  }
38
52
  export function parseMemAvailableBytes(meminfo) {
39
53
  const match = /^MemAvailable:\s*(\d+)\s*kB\s*$/mu.exec(meminfo);
40
54
  if (!match?.[1])
41
55
  return undefined;
42
- const kib = Number(match[1]);
43
- return Number.isSafeInteger(kib) ? kib * 1024 : undefined;
56
+ const bytes = Number(match[1]) * 1024;
57
+ return Number.isSafeInteger(bytes) ? bytes : undefined;
58
+ }
59
+ // Process-local sampling only, shared by estimate/admission/watchdog. Never a store.
60
+ let darwinSample;
61
+ function readDarwinVmStat() {
62
+ const now = performance.now();
63
+ if (!darwinSample || now - darwinSample.at >= 1000) {
64
+ const raw = safeCall(() => execFileSync("/usr/bin/vm_stat", [], {
65
+ encoding: "utf8", timeout: 1000, maxBuffer: 64 * 1024, env: { ...process.env, LC_ALL: "C" },
66
+ stdio: ["ignore", "pipe", "ignore"],
67
+ }));
68
+ darwinSample = { at: now, raw };
69
+ }
70
+ return darwinSample.raw;
44
71
  }
45
72
  function safeCall(read) {
46
73
  try {
@@ -50,7 +77,7 @@ function safeCall(read) {
50
77
  return undefined;
51
78
  }
52
79
  }
53
- function positiveFiniteBytes(value) {
54
- return value !== undefined && Number.isFinite(value) && value > 0 ? value : undefined;
80
+ function finiteBytes(value) {
81
+ return value !== undefined && Number.isFinite(value) && value >= 0 ? value : undefined;
55
82
  }
56
83
  //# sourceMappingURL=system-memory.js.map