@cchistory/lite 0.7.0 → 0.8.1

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 (248) hide show
  1. package/INSTALL.md +1 -1
  2. package/apps/lite-cli/dist/agent-contract.d.ts.map +1 -1
  3. package/apps/lite-cli/dist/agent-contract.js +29 -4
  4. package/apps/lite-cli/dist/agent-contract.js.map +1 -1
  5. package/apps/lite-cli/dist/index.d.ts.map +1 -1
  6. package/apps/lite-cli/dist/index.js +87 -48
  7. package/apps/lite-cli/dist/index.js.map +1 -1
  8. package/apps/lite-cli/dist/index.test.js +33 -1
  9. package/apps/lite-cli/dist/index.test.js.map +1 -1
  10. package/apps/lite-cli/dist/json-v2.d.ts.map +1 -1
  11. package/apps/lite-cli/dist/json-v2.js +8 -1
  12. package/apps/lite-cli/dist/json-v2.js.map +1 -1
  13. package/apps/lite-cli/dist/stats-command.d.ts +52 -0
  14. package/apps/lite-cli/dist/stats-command.d.ts.map +1 -0
  15. package/apps/lite-cli/dist/stats-command.js +322 -0
  16. package/apps/lite-cli/dist/stats-command.js.map +1 -0
  17. package/apps/lite-cli/dist/stats-command.test.d.ts +2 -0
  18. package/apps/lite-cli/dist/stats-command.test.d.ts.map +1 -0
  19. package/apps/lite-cli/dist/stats-command.test.js +154 -0
  20. package/apps/lite-cli/dist/stats-command.test.js.map +1 -0
  21. package/apps/lite-cli/dist/stats-render.d.ts +21 -0
  22. package/apps/lite-cli/dist/stats-render.d.ts.map +1 -0
  23. package/apps/lite-cli/dist/stats-render.js +207 -0
  24. package/apps/lite-cli/dist/stats-render.js.map +1 -0
  25. package/apps/lite-cli/dist/version.d.ts +1 -1
  26. package/apps/lite-cli/dist/version.js +1 -1
  27. package/apps/lite-tui/dist/index.d.ts.map +1 -1
  28. package/apps/lite-tui/dist/index.js +75 -4
  29. package/apps/lite-tui/dist/index.js.map +1 -1
  30. package/apps/lite-tui/dist/input.d.ts.map +1 -1
  31. package/apps/lite-tui/dist/input.js +124 -3
  32. package/apps/lite-tui/dist/input.js.map +1 -1
  33. package/apps/lite-tui/dist/model.d.ts +29 -4
  34. package/apps/lite-tui/dist/model.d.ts.map +1 -1
  35. package/apps/lite-tui/dist/model.js +90 -8
  36. package/apps/lite-tui/dist/model.js.map +1 -1
  37. package/apps/lite-tui/dist/render.d.ts +1 -1
  38. package/apps/lite-tui/dist/render.d.ts.map +1 -1
  39. package/apps/lite-tui/dist/render.js +21 -51
  40. package/apps/lite-tui/dist/render.js.map +1 -1
  41. package/apps/lite-tui/dist/state.d.ts +3 -1
  42. package/apps/lite-tui/dist/state.d.ts.map +1 -1
  43. package/apps/lite-tui/dist/state.js +31 -13
  44. package/apps/lite-tui/dist/state.js.map +1 -1
  45. package/apps/lite-tui/dist/state.test.js +118 -0
  46. package/apps/lite-tui/dist/state.test.js.map +1 -1
  47. package/apps/lite-tui/dist/stats-dashboard.test.d.ts +2 -0
  48. package/apps/lite-tui/dist/stats-dashboard.test.d.ts.map +1 -0
  49. package/apps/lite-tui/dist/stats-dashboard.test.js +191 -0
  50. package/apps/lite-tui/dist/stats-dashboard.test.js.map +1 -0
  51. package/apps/lite-tui/dist/stats-query.d.ts +11 -0
  52. package/apps/lite-tui/dist/stats-query.d.ts.map +1 -0
  53. package/apps/lite-tui/dist/stats-query.js +104 -0
  54. package/apps/lite-tui/dist/stats-query.js.map +1 -0
  55. package/apps/lite-tui/dist/stats-render.d.ts +9 -0
  56. package/apps/lite-tui/dist/stats-render.d.ts.map +1 -0
  57. package/apps/lite-tui/dist/stats-render.js +311 -0
  58. package/apps/lite-tui/dist/stats-render.js.map +1 -0
  59. package/apps/lite-tui/dist/stats-state.d.ts +121 -0
  60. package/apps/lite-tui/dist/stats-state.d.ts.map +1 -0
  61. package/apps/lite-tui/dist/stats-state.js +335 -0
  62. package/apps/lite-tui/dist/stats-state.js.map +1 -0
  63. package/apps/lite-tui/dist/version.d.ts +1 -1
  64. package/apps/lite-tui/dist/version.js +1 -1
  65. package/docs/guide/lite.md +34 -4
  66. package/docs/guide/pricing.example.json +38 -0
  67. package/node_modules/@cchistory/canonical/dist/codex-usage.d.ts +7 -0
  68. package/node_modules/@cchistory/canonical/dist/codex-usage.d.ts.map +1 -0
  69. package/node_modules/@cchistory/canonical/dist/codex-usage.js +169 -0
  70. package/node_modules/@cchistory/canonical/dist/codex-usage.js.map +1 -0
  71. package/node_modules/@cchistory/canonical/dist/index.d.ts +7 -2
  72. package/node_modules/@cchistory/canonical/dist/index.d.ts.map +1 -1
  73. package/node_modules/@cchistory/canonical/dist/index.js +7 -2
  74. package/node_modules/@cchistory/canonical/dist/index.js.map +1 -1
  75. package/node_modules/@cchistory/canonical/dist/index.test.js +65 -1
  76. package/node_modules/@cchistory/canonical/dist/index.test.js.map +1 -1
  77. package/node_modules/@cchistory/canonical/dist/model-name-matching.d.ts +12 -0
  78. package/node_modules/@cchistory/canonical/dist/model-name-matching.d.ts.map +1 -0
  79. package/node_modules/@cchistory/canonical/dist/model-name-matching.js +225 -0
  80. package/node_modules/@cchistory/canonical/dist/model-name-matching.js.map +1 -0
  81. package/node_modules/@cchistory/canonical/dist/model-name-matching.test.d.ts +2 -0
  82. package/node_modules/@cchistory/canonical/dist/model-name-matching.test.d.ts.map +1 -0
  83. package/node_modules/@cchistory/canonical/dist/model-name-matching.test.js +72 -0
  84. package/node_modules/@cchistory/canonical/dist/model-name-matching.test.js.map +1 -0
  85. package/node_modules/@cchistory/canonical/dist/model-pricing-catalog.d.ts +14 -0
  86. package/node_modules/@cchistory/canonical/dist/model-pricing-catalog.d.ts.map +1 -0
  87. package/node_modules/@cchistory/canonical/dist/model-pricing-catalog.js +345 -0
  88. package/node_modules/@cchistory/canonical/dist/model-pricing-catalog.js.map +1 -0
  89. package/node_modules/@cchistory/canonical/dist/projection-audit.d.ts +1 -1
  90. package/node_modules/@cchistory/canonical/dist/projection-audit.d.ts.map +1 -1
  91. package/node_modules/@cchistory/canonical/dist/projection-audit.js +22 -0
  92. package/node_modules/@cchistory/canonical/dist/projection-audit.js.map +1 -1
  93. package/node_modules/@cchistory/canonical/dist/query.js +1 -1
  94. package/node_modules/@cchistory/canonical/dist/query.js.map +1 -1
  95. package/node_modules/@cchistory/canonical/dist/read-order.d.ts +2 -0
  96. package/node_modules/@cchistory/canonical/dist/read-order.d.ts.map +1 -1
  97. package/node_modules/@cchistory/canonical/dist/read-order.js +10 -0
  98. package/node_modules/@cchistory/canonical/dist/read-order.js.map +1 -1
  99. package/node_modules/@cchistory/canonical/dist/session-family.js +2 -2
  100. package/node_modules/@cchistory/canonical/dist/session-family.js.map +1 -1
  101. package/node_modules/@cchistory/canonical/dist/session-interpreter.d.ts.map +1 -1
  102. package/node_modules/@cchistory/canonical/dist/session-interpreter.js +29 -2
  103. package/node_modules/@cchistory/canonical/dist/session-interpreter.js.map +1 -1
  104. package/node_modules/@cchistory/canonical/dist/usage-breakdown.d.ts +37 -0
  105. package/node_modules/@cchistory/canonical/dist/usage-breakdown.d.ts.map +1 -0
  106. package/node_modules/@cchistory/canonical/dist/usage-breakdown.js +279 -0
  107. package/node_modules/@cchistory/canonical/dist/usage-breakdown.js.map +1 -0
  108. package/node_modules/@cchistory/canonical/dist/usage-pricing-config.d.ts +11 -0
  109. package/node_modules/@cchistory/canonical/dist/usage-pricing-config.d.ts.map +1 -0
  110. package/node_modules/@cchistory/canonical/dist/usage-pricing-config.js +320 -0
  111. package/node_modules/@cchistory/canonical/dist/usage-pricing-config.js.map +1 -0
  112. package/node_modules/@cchistory/canonical/dist/usage-pricing.d.ts +34 -0
  113. package/node_modules/@cchistory/canonical/dist/usage-pricing.d.ts.map +1 -0
  114. package/node_modules/@cchistory/canonical/dist/usage-pricing.js +176 -0
  115. package/node_modules/@cchistory/canonical/dist/usage-pricing.js.map +1 -0
  116. package/node_modules/@cchistory/canonical/dist/usage-pricing.test.d.ts +2 -0
  117. package/node_modules/@cchistory/canonical/dist/usage-pricing.test.d.ts.map +1 -0
  118. package/node_modules/@cchistory/canonical/dist/usage-pricing.test.js +466 -0
  119. package/node_modules/@cchistory/canonical/dist/usage-pricing.test.js.map +1 -0
  120. package/node_modules/@cchistory/canonical/dist/usage-time.d.ts +53 -0
  121. package/node_modules/@cchistory/canonical/dist/usage-time.d.ts.map +1 -0
  122. package/node_modules/@cchistory/canonical/dist/usage-time.js +323 -0
  123. package/node_modules/@cchistory/canonical/dist/usage-time.js.map +1 -0
  124. package/node_modules/@cchistory/canonical/dist/usage.d.ts +47 -31
  125. package/node_modules/@cchistory/canonical/dist/usage.d.ts.map +1 -1
  126. package/node_modules/@cchistory/canonical/dist/usage.js +184 -96
  127. package/node_modules/@cchistory/canonical/dist/usage.js.map +1 -1
  128. package/node_modules/@cchistory/canonical/package.json +1 -1
  129. package/node_modules/@cchistory/domain/dist/index.d.ts +22 -2
  130. package/node_modules/@cchistory/domain/dist/index.d.ts.map +1 -1
  131. package/node_modules/@cchistory/domain/dist/index.js +1 -0
  132. package/node_modules/@cchistory/domain/dist/index.js.map +1 -1
  133. package/node_modules/@cchistory/domain/dist/usage-pricing.d.ts +155 -0
  134. package/node_modules/@cchistory/domain/dist/usage-pricing.d.ts.map +1 -0
  135. package/node_modules/@cchistory/domain/dist/usage-pricing.js +7 -0
  136. package/node_modules/@cchistory/domain/dist/usage-pricing.js.map +1 -0
  137. package/node_modules/@cchistory/domain/package.json +1 -1
  138. package/node_modules/@cchistory/live-runtime/dist/antigravity.test.d.ts +2 -0
  139. package/node_modules/@cchistory/live-runtime/dist/antigravity.test.d.ts.map +1 -0
  140. package/node_modules/@cchistory/live-runtime/dist/antigravity.test.js +104 -0
  141. package/node_modules/@cchistory/live-runtime/dist/antigravity.test.js.map +1 -0
  142. package/node_modules/@cchistory/live-runtime/dist/grok-bot.test.d.ts +2 -0
  143. package/node_modules/@cchistory/live-runtime/dist/grok-bot.test.d.ts.map +1 -0
  144. package/node_modules/@cchistory/live-runtime/dist/grok-bot.test.js +211 -0
  145. package/node_modules/@cchistory/live-runtime/dist/grok-bot.test.js.map +1 -0
  146. package/node_modules/@cchistory/live-runtime/dist/index.d.ts +13 -2
  147. package/node_modules/@cchistory/live-runtime/dist/index.d.ts.map +1 -1
  148. package/node_modules/@cchistory/live-runtime/dist/index.js +61 -3
  149. package/node_modules/@cchistory/live-runtime/dist/index.js.map +1 -1
  150. package/node_modules/@cchistory/live-runtime/dist/index.test.js +114 -1
  151. package/node_modules/@cchistory/live-runtime/dist/index.test.js.map +1 -1
  152. package/node_modules/@cchistory/live-runtime/package.json +1 -1
  153. package/node_modules/@cchistory/source-adapters/dist/core/atomizer.d.ts.map +1 -1
  154. package/node_modules/@cchistory/source-adapters/dist/core/atomizer.js +10 -0
  155. package/node_modules/@cchistory/source-adapters/dist/core/atomizer.js.map +1 -1
  156. package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.d.ts +4 -0
  157. package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.d.ts.map +1 -1
  158. package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.js.map +1 -1
  159. package/node_modules/@cchistory/source-adapters/dist/core/discovery.d.ts.map +1 -1
  160. package/node_modules/@cchistory/source-adapters/dist/core/discovery.js +17 -3
  161. package/node_modules/@cchistory/source-adapters/dist/core/discovery.js.map +1 -1
  162. package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts.map +1 -1
  163. package/node_modules/@cchistory/source-adapters/dist/core/parser.js +79 -9
  164. package/node_modules/@cchistory/source-adapters/dist/core/parser.js.map +1 -1
  165. package/node_modules/@cchistory/source-adapters/dist/core/path-utils.d.ts.map +1 -1
  166. package/node_modules/@cchistory/source-adapters/dist/core/path-utils.js +2 -1
  167. package/node_modules/@cchistory/source-adapters/dist/core/path-utils.js.map +1 -1
  168. package/node_modules/@cchistory/source-adapters/dist/core/probe.d.ts.map +1 -1
  169. package/node_modules/@cchistory/source-adapters/dist/core/probe.js +160 -66
  170. package/node_modules/@cchistory/source-adapters/dist/core/probe.js.map +1 -1
  171. package/node_modules/@cchistory/source-adapters/dist/core/registry.test.js +2 -1
  172. package/node_modules/@cchistory/source-adapters/dist/core/registry.test.js.map +1 -1
  173. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts.map +1 -1
  174. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js +11 -0
  175. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js.map +1 -1
  176. package/node_modules/@cchistory/source-adapters/dist/core/tokens.test.js +15 -15
  177. package/node_modules/@cchistory/source-adapters/dist/core/tokens.test.js.map +1 -1
  178. package/node_modules/@cchistory/source-adapters/dist/core/types.d.ts +2 -4
  179. package/node_modules/@cchistory/source-adapters/dist/core/types.d.ts.map +1 -1
  180. package/node_modules/@cchistory/source-adapters/dist/core/user-text.d.ts +9 -7
  181. package/node_modules/@cchistory/source-adapters/dist/core/user-text.d.ts.map +1 -1
  182. package/node_modules/@cchistory/source-adapters/dist/core/user-text.js +34 -8
  183. package/node_modules/@cchistory/source-adapters/dist/core/user-text.js.map +1 -1
  184. package/node_modules/@cchistory/source-adapters/dist/core/utils.test.js +11 -0
  185. package/node_modules/@cchistory/source-adapters/dist/core/utils.test.js.map +1 -1
  186. package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts +2 -0
  187. package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts.map +1 -1
  188. package/node_modules/@cchistory/source-adapters/dist/index.test.js +2 -0
  189. package/node_modules/@cchistory/source-adapters/dist/index.test.js.map +1 -1
  190. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/live.d.ts +1 -0
  191. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/live.d.ts.map +1 -1
  192. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/live.js +2 -0
  193. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/live.js.map +1 -1
  194. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/protobuf.d.ts +18 -0
  195. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/protobuf.d.ts.map +1 -0
  196. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/protobuf.js +105 -0
  197. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/protobuf.js.map +1 -0
  198. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/sqlite.d.ts +8 -0
  199. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/sqlite.d.ts.map +1 -0
  200. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/sqlite.js +227 -0
  201. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/sqlite.js.map +1 -0
  202. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/usage.d.ts +6 -0
  203. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/usage.d.ts.map +1 -0
  204. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/usage.js +22 -0
  205. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity/usage.js.map +1 -0
  206. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity-sqlite.test.d.ts +2 -0
  207. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity-sqlite.test.d.ts.map +1 -0
  208. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity-sqlite.test.js +145 -0
  209. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity-sqlite.test.js.map +1 -0
  210. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.d.ts +1 -0
  211. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.d.ts.map +1 -1
  212. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.js +14 -5
  213. package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.js.map +1 -1
  214. package/node_modules/@cchistory/source-adapters/dist/platforms/codex/runtime.d.ts.map +1 -1
  215. package/node_modules/@cchistory/source-adapters/dist/platforms/codex/runtime.js +25 -18
  216. package/node_modules/@cchistory/source-adapters/dist/platforms/codex/runtime.js.map +1 -1
  217. package/node_modules/@cchistory/source-adapters/dist/platforms/codex.d.ts.map +1 -1
  218. package/node_modules/@cchistory/source-adapters/dist/platforms/codex.js +18 -1
  219. package/node_modules/@cchistory/source-adapters/dist/platforms/codex.js.map +1 -1
  220. package/node_modules/@cchistory/source-adapters/dist/platforms/codex.test.js +67 -0
  221. package/node_modules/@cchistory/source-adapters/dist/platforms/codex.test.js.map +1 -1
  222. package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot/runtime.d.ts +27 -0
  223. package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot/runtime.d.ts.map +1 -0
  224. package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot/runtime.js +262 -0
  225. package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot/runtime.js.map +1 -0
  226. package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot/title.d.ts +18 -0
  227. package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot/title.d.ts.map +1 -0
  228. package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot/title.js +101 -0
  229. package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot/title.js.map +1 -0
  230. package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot.d.ts +17 -0
  231. package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot.d.ts.map +1 -0
  232. package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot.js +145 -0
  233. package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot.js.map +1 -0
  234. package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot.test.d.ts +2 -0
  235. package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot.test.d.ts.map +1 -0
  236. package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot.test.js +423 -0
  237. package/node_modules/@cchistory/source-adapters/dist/platforms/grok-bot.test.js.map +1 -0
  238. package/node_modules/@cchistory/source-adapters/dist/platforms/registry.d.ts.map +1 -1
  239. package/node_modules/@cchistory/source-adapters/dist/platforms/registry.js +2 -0
  240. package/node_modules/@cchistory/source-adapters/dist/platforms/registry.js.map +1 -1
  241. package/node_modules/@cchistory/source-adapters/dist/platforms/runtime-types.d.ts +0 -5
  242. package/node_modules/@cchistory/source-adapters/dist/platforms/runtime-types.d.ts.map +1 -1
  243. package/node_modules/@cchistory/source-adapters/dist/platforms/types.d.ts +3 -1
  244. package/node_modules/@cchistory/source-adapters/dist/platforms/types.d.ts.map +1 -1
  245. package/node_modules/@cchistory/source-adapters/dist/platforms/types.js +2 -1
  246. package/node_modules/@cchistory/source-adapters/dist/platforms/types.js.map +1 -1
  247. package/node_modules/@cchistory/source-adapters/package.json +1 -1
  248. package/package.json +5 -5
@@ -0,0 +1 @@
1
+ {"version":3,"file":"title.js","sourceRoot":"","sources":["../../../src/platforms/grok-bot/title.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,kBAAkB,GAAG,sBAAsB,CAAC;AAClD,MAAM,iBAAiB,GAAG,gDAAgD,CAAC;AAC3E,MAAM,WAAW,GAAG,yBAAyB,CAAC;AAC9C,MAAM,YAAY,GAAG,qCAAqC,CAAC;AAC3D,MAAM,aAAa,GAAG,2CAA2C,CAAC;AAElE,MAAM,UAAU,yBAAyB,CAAC,IAAwB;IAChE,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;IACnD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,OAAO,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;IACxD,OAAO,OAAO,CAAC,KAAK,EAAE,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC;A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S,sBAAsB,CAAC,KAAa;IAC3C,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACrD,MAAM,MAAM,GAAG,GAAG,KAAK,GAAG,GAAG,EAAE,CAAC;IAChC,KAAK,MAAM,QAAQ,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAU,EAAE,CAAC;QACxD,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAC3D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAY,CAAC;YAC1C,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;gBACnE,OAAO,MAAiC,CAAC;YAC3C,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,oBAAoB;QACtB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { PlatformAdapter } from "./types.js";
2
+ export declare function isGrokBotStorePath(filePath: string): boolean;
3
+ export declare function isGrokBotTranscriptPath(filePath: string): boolean;
4
+ export declare function isGrokBotConversationBlobsPath(filePath: string): boolean;
5
+ export declare function parseGrokBotAgentIdFromPath(filePath: string): string | undefined;
6
+ export declare function resolveGrokBotDataRoot(baseDir: string): string;
7
+ export declare function listGrokBotSourceRoots(baseDir: string): string[];
8
+ export declare function uniqueExistingPaths(candidates: readonly string[]): string[];
9
+ /**
10
+ * Companion evidence for identity + SQLite WAL. conversation-blobs.db is an
11
+ * opaque LLM payload cache (often tens of MB) not referenced by store message
12
+ * rows; listing it for full-byte capture caused memory pressure and empty
13
+ * parse diagnostics without improving projection. Keep store.db as truth.
14
+ */
15
+ export declare function listGrokBotCompanionEvidencePaths(_baseDir: string, filePath: string): string[];
16
+ export declare const grokBotAdapter: PlatformAdapter;
17
+ //# sourceMappingURL=grok-bot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grok-bot.d.ts","sourceRoot":"","sources":["../../src/platforms/grok-bot.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAOlD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAM5D;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAGjE;AAED,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAMxE;AAED,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAehF;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAS9D;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAUhE;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAY3E;AAYD;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAmB9F;AAED,eAAO,MAAM,cAAc,EAAE,eA0C5B,CAAC"}
@@ -0,0 +1,145 @@
1
+ import path from "node:path";
2
+ import { normalizePathSeparators } from "../core/path-utils.js";
3
+ const STORE_BASENAME = "store.db";
4
+ const BLOBS_BASENAME = "conversation-blobs.db";
5
+ const AGENTS_DIR = "agents";
6
+ const TRANSCRIPTS_DIR = "agent-transcripts";
7
+ export function isGrokBotStorePath(filePath) {
8
+ const normalized = normalizePathSeparators(filePath);
9
+ return (path.basename(normalized) === STORE_BASENAME &&
10
+ /\/agents\/[^/]+\/store\.db$/u.test(normalized));
11
+ }
12
+ export function isGrokBotTranscriptPath(filePath) {
13
+ const normalized = normalizePathSeparators(filePath);
14
+ return normalized.includes(`/${TRANSCRIPTS_DIR}/`) && normalized.endsWith(".jsonl");
15
+ }
16
+ export function isGrokBotConversationBlobsPath(filePath) {
17
+ const normalized = normalizePathSeparators(filePath);
18
+ return (path.basename(normalized) === BLOBS_BASENAME &&
19
+ /\/agents\/[^/]+\/conversation-blobs\.db$/u.test(normalized));
20
+ }
21
+ export function parseGrokBotAgentIdFromPath(filePath) {
22
+ const normalized = normalizePathSeparators(filePath);
23
+ const storeMatch = normalized.match(/\/agents\/([^/]+)\/store\.db$/u);
24
+ if (storeMatch?.[1]) {
25
+ return storeMatch[1];
26
+ }
27
+ const blobsMatch = normalized.match(/\/agents\/([^/]+)\/conversation-blobs\.db$/u);
28
+ if (blobsMatch?.[1]) {
29
+ return blobsMatch[1];
30
+ }
31
+ const transcriptMatch = normalized.match(/\/agent-transcripts\/([^/]+)\/[^/]+\.jsonl$/u);
32
+ if (transcriptMatch?.[1]) {
33
+ return transcriptMatch[1];
34
+ }
35
+ return undefined;
36
+ }
37
+ export function resolveGrokBotDataRoot(baseDir) {
38
+ const normalized = normalizePathSeparators(baseDir);
39
+ if (normalized.endsWith(`/${AGENTS_DIR}`) || path.basename(normalized) === AGENTS_DIR) {
40
+ return path.dirname(path.normalize(baseDir));
41
+ }
42
+ if (normalized.endsWith(`/${TRANSCRIPTS_DIR}`) || path.basename(normalized) === TRANSCRIPTS_DIR) {
43
+ return path.dirname(path.normalize(baseDir));
44
+ }
45
+ return path.normalize(baseDir);
46
+ }
47
+ export function listGrokBotSourceRoots(baseDir) {
48
+ const normalized = normalizePathSeparators(baseDir);
49
+ if (normalized.endsWith(`/${AGENTS_DIR}`) || path.basename(normalized) === AGENTS_DIR) {
50
+ return [path.normalize(baseDir)];
51
+ }
52
+ if (normalized.endsWith(`/${TRANSCRIPTS_DIR}`) || path.basename(normalized) === TRANSCRIPTS_DIR) {
53
+ return [path.normalize(baseDir)];
54
+ }
55
+ const root = path.normalize(baseDir);
56
+ return [path.join(root, AGENTS_DIR), path.join(root, TRANSCRIPTS_DIR)];
57
+ }
58
+ export function uniqueExistingPaths(candidates) {
59
+ const seen = new Set();
60
+ const unique = [];
61
+ for (const candidate of candidates) {
62
+ const normalized = path.normalize(candidate);
63
+ if (seen.has(normalized)) {
64
+ continue;
65
+ }
66
+ seen.add(normalized);
67
+ unique.push(normalized);
68
+ }
69
+ return unique;
70
+ }
71
+ function resolveGrokBotDataRootFromTranscript(filePath) {
72
+ const normalized = normalizePathSeparators(filePath);
73
+ const marker = `/${TRANSCRIPTS_DIR}/`;
74
+ const index = normalized.lastIndexOf(marker);
75
+ if (index < 0) {
76
+ return undefined;
77
+ }
78
+ return normalized.slice(0, index);
79
+ }
80
+ /**
81
+ * Companion evidence for identity + SQLite WAL. conversation-blobs.db is an
82
+ * opaque LLM payload cache (often tens of MB) not referenced by store message
83
+ * rows; listing it for full-byte capture caused memory pressure and empty
84
+ * parse diagnostics without improving projection. Keep store.db as truth.
85
+ */
86
+ export function listGrokBotCompanionEvidencePaths(_baseDir, filePath) {
87
+ const companions = [];
88
+ if (isGrokBotStorePath(filePath)) {
89
+ const agentDir = path.dirname(filePath);
90
+ companions.push(path.join(agentDir, "profile.json"), `${filePath}-wal`, `${filePath}-shm`);
91
+ }
92
+ if (isGrokBotTranscriptPath(filePath)) {
93
+ const agentId = parseGrokBotAgentIdFromPath(filePath);
94
+ const dataRoot = resolveGrokBotDataRootFromTranscript(filePath);
95
+ if (agentId && dataRoot) {
96
+ const agentDir = path.join(dataRoot, AGENTS_DIR, agentId);
97
+ companions.push(path.join(agentDir, "profile.json"));
98
+ }
99
+ }
100
+ return companions;
101
+ }
102
+ export const grokBotAdapter = {
103
+ platform: "grok_bot",
104
+ supportTier: "experimental",
105
+ sessionTargeting: "hybrid",
106
+ projectionBoundary: "source",
107
+ getDefaultBaseDirCandidates: (options) => {
108
+ const homeDir = options.homeDir ?? "";
109
+ const envRoots = [
110
+ process.env.GROK_BOT_HOME,
111
+ process.env.AGENT_DATA,
112
+ process.env.SAND_DATA,
113
+ ]
114
+ .map((value) => value?.trim())
115
+ .filter((value) => Boolean(value))
116
+ .map((value) => path.normalize(value));
117
+ return uniqueExistingPaths([
118
+ ...envRoots,
119
+ path.join(homeDir, "agent-data"),
120
+ path.join(homeDir, "sand-data"),
121
+ path.join(homeDir, ".agent-data"),
122
+ path.join(homeDir, ".sand-data"),
123
+ ]);
124
+ },
125
+ getSourceRoots: (baseDir) => listGrokBotSourceRoots(baseDir),
126
+ matchesSourceFile: (filePath) => {
127
+ if (isGrokBotStorePath(filePath)) {
128
+ return true;
129
+ }
130
+ // Inventory stays path-only. The probe selects a preferred store only after
131
+ // its budgeted parse succeeds, using attempt-local evidence rather than mtime.
132
+ return isGrokBotTranscriptPath(filePath);
133
+ },
134
+ getSourceFilePriority: (filePath) => {
135
+ if (isGrokBotStorePath(filePath)) {
136
+ return 0;
137
+ }
138
+ if (isGrokBotTranscriptPath(filePath)) {
139
+ return 1;
140
+ }
141
+ return 2;
142
+ },
143
+ getCompanionEvidencePaths: (baseDir, filePath) => listGrokBotCompanionEvidencePaths(baseDir, filePath),
144
+ };
145
+ //# sourceMappingURL=grok-bot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grok-bot.js","sourceRoot":"","sources":["../../src/platforms/grok-bot.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAGhE,MAAM,cAAc,GAAG,UAAU,CAAC;AAClC,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAC/C,MAAM,UAAU,GAAG,QAAQ,CAAC;AAC5B,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAE5C,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,MAAM,UAAU,GAAG,uBAAuB,CAAC,QAAQ,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G,QAAQ;YACX,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC;YAChC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC;YAC/B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC;YACjC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC;SACjC,CAAC,CAAC;IACL,CAAC;IACD,cAAc,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,sBAAsB,CAAC,OAAO,CAAC;IAC5D,iBAAiB,EAAE,CAAC,QAAQ,EAAE,EAAE;QAC9B,IAAI,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC;QACd,CAAC;QACD,4EAA4E;QAC5E,+EAA+E;QAC/E,OAAO,uBAAuB,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC;IACD,qBAAqB,EAAE,CAAC,QAAQ,EAAE,EAAE;QAClC,IAAI,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACjC,OAAO,CAAC,CAAC;QACX,CAAC;QACD,IAAI,uBAAuB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACtC,OAAO,CAAC,CAAC;QACX,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;IACD,yBAAyB,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,CAAC,iCAAiC,CAAC,OAAO,EAAE,QAAQ,CAAC;CACvG,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=grok-bot.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grok-bot.test.d.ts","sourceRoot":"","sources":["../../src/platforms/grok-bot.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,423 @@
1
+ import { runSourceProbe } from "../probe-reference.test.js";
2
+ import assert from "node:assert/strict";
3
+ import { cp, mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
4
+ import { DatabaseSync } from "node:sqlite";
5
+ import os from "node:os";
6
+ import path from "node:path";
7
+ import { test } from "node:test";
8
+ import { getDefaultSourcesForHost, listSourceFiles, } from "../index.js";
9
+ import { splitUserText } from "../core/user-text.js";
10
+ import { normalizeSessionTitleCandidate } from "../core/atomizer.js";
11
+ import { createSourceDefinition, getRepoMockDataRoot } from "../test-helpers.js";
12
+ import { grokBotAdapter, isGrokBotStorePath, isGrokBotTranscriptPath, listGrokBotCompanionEvidencePaths, parseGrokBotAgentIdFromPath, } from "./grok-bot.js";
13
+ import { cleanGrokBotUserTitleText, extractGrokBotProfileUpdateName, isGrokBotHiddenPromptText, resolveGrokBotSessionTitle, shortGrokBotAgentLabel, } from "./grok-bot/title.js";
14
+ const STORE_AGENT = "aaaaaaaa-bbbb-4ccc-8ddd-eeeeeeeeee01";
15
+ const EMPTY_AGENT = "bbbbbbbb-cccc-4ddd-8eee-ffffffffffff";
16
+ const JSONL_ONLY = "cccccccc-dddd-4eee-8fff-111111111111";
17
+ const EMPTY_STORE_JSONL = "dddddddd-eeee-4fff-8111-222222222222";
18
+ const DELETED_AGENT = "eeeeeeee-ffff-4111-8222-333333333333";
19
+ const MISSING_PROFILE = "ffffffff-1111-4222-8333-444444444444";
20
+ const fixtureRoot = path.join(getRepoMockDataRoot(), "fixtures/grok-bot");
21
+ const reviewCases = JSON.parse(await readFile(path.join(fixtureRoot, "review-cases.json"), "utf8"));
22
+ async function copyAgentFixture(root, agentId = reviewCases.agent_id) {
23
+ for (const directory of ["agents", "agent-transcripts"]) {
24
+ await mkdir(path.join(root, directory), { recursive: true });
25
+ await cp(path.join(fixtureRoot, directory, agentId), path.join(root, directory, agentId), { recursive: true });
26
+ }
27
+ return path.join(root, "agents", agentId, "store.db");
28
+ }
29
+ function seedStore(dbPath, messages) {
30
+ const db = new DatabaseSync(dbPath);
31
+ db.exec(`
32
+ CREATE TABLE transcript_entries (
33
+ seq INTEGER PRIMARY KEY,
34
+ id TEXT NOT NULL,
35
+ entry TEXT NOT NULL
36
+ );
37
+ `);
38
+ const insert = db.prepare("INSERT INTO transcript_entries (seq, id, entry) VALUES (?, ?, ?)");
39
+ let seq = 1;
40
+ for (const message of messages) {
41
+ insert.run(seq++, String(message.id ?? seq), JSON.stringify(message));
42
+ }
43
+ db.close();
44
+ }
45
+ test("[grok_bot] default candidates include agent-data and sand-data", () => {
46
+ const candidates = grokBotAdapter.getDefaultBaseDirCandidates({ homeDir: "/home/fixture" });
47
+ assert.deepEqual(candidates, [
48
+ "/home/fixture/agent-data",
49
+ "/home/fixture/sand-data",
50
+ "/home/fixture/.agent-data",
51
+ "/home/fixture/.sand-data",
52
+ ]);
53
+ assert.equal(grokBotAdapter.platform, "grok_bot");
54
+ assert.equal(grokBotAdapter.supportTier, "experimental");
55
+ });
56
+ test("[grok_bot] path helpers recognize store and transcript layouts", () => {
57
+ const storePath = `/data/agents/${STORE_AGENT}/store.db`;
58
+ const transcriptPath = `/data/agent-transcripts/${STORE_AGENT}/${STORE_AGENT}.jsonl`;
59
+ assert.equal(isGrokBotStorePath(storePath), true);
60
+ assert.equal(isGrokBotTranscriptPath(transcriptPath), true);
61
+ assert.equal(parseGrokBotAgentIdFromPath(storePath), STORE_AGENT);
62
+ assert.equal(parseGrokBotAgentIdFromPath(transcriptPath), STORE_AGENT);
63
+ });
64
+ test("[grok_bot] companions omit opaque conversation-blobs.db", () => {
65
+ const storePath = `/data/agents/${STORE_AGENT}/store.db`;
66
+ const companions = listGrokBotCompanionEvidencePaths("/data", storePath);
67
+ assert.ok(companions.some((entry) => entry.endsWith("profile.json")));
68
+ assert.equal(companions.some((entry) => entry.endsWith("conversation-blobs.db")), false);
69
+ });
70
+ test("[grok_bot] title helpers strip hidden prompts and prefer profile update names", () => {
71
+ assert.equal(isGrokBotHiddenPromptText("[SAND_HIDDEN_PROMPT][first run] hi"), true);
72
+ assert.equal(isGrokBotHiddenPromptText("normal user text"), false);
73
+ assert.equal(cleanGrokBotUserTitleText("[t0u]\nMap the workspace"), "Map the workspace");
74
+ assert.equal(cleanGrokBotUserTitleText("[SAND_HIDDEN_PROMPT]nope"), undefined);
75
+ const token = Buffer.from(JSON.stringify({ name: "Recovered Name" }), "utf8").toString("base64url");
76
+ assert.equal(extractGrokBotProfileUpdateName(`[SAND_HIDDEN_PROMPT]<<SAND_AGENT_PROFILE_UPDATE:v1:${token}>>`), "Recovered Name");
77
+ const title = resolveGrokBotSessionTitle({
78
+ agentId: DELETED_AGENT,
79
+ profileUpdateName: "Recovered Name",
80
+ firstUserText: "[t0u]\nShould not win",
81
+ truncate: (value, length) => value.slice(0, length),
82
+ });
83
+ assert.equal(title, "Recovered Name");
84
+ assert.equal(shortGrokBotAgentLabel(DELETED_AGENT), "eeeeeeee");
85
+ });
86
+ test("[grok_bot] SAND_HIDDEN_PROMPT user_query chunks are injected, not authored", () => {
87
+ const text = [
88
+ "<timestamp>Wednesday, Oct 7, 2026, 1:00 PM (UTC+8)</timestamp>",
89
+ "<user_query>",
90
+ "[SAND_HIDDEN_PROMPT][first run] This is your very first turn.",
91
+ "</user_query>",
92
+ ].join("\n");
93
+ const chunks = splitUserText(text, { platform: "grok_bot" });
94
+ assert.equal(chunks.some((chunk) => chunk.originKind === "user_authored"), false);
95
+ assert.equal(chunks.some((chunk) => chunk.originKind === "injected_user_shaped" && chunk.text.includes("SAND_HIDDEN_PROMPT")), true);
96
+ });
97
+ test("[grok_bot] hidden prompt classification is scoped to Grok Bot across text envelopes", () => {
98
+ for (const text of reviewCases.source_isolation.hidden_prompt_shapes) {
99
+ for (const platform of [undefined, "codex", "claude_code", "cursor", "cursor_agent", "grok", "grok_bot"]) {
100
+ const authored = splitUserText(text, { platform }).filter(chunk => chunk.originKind === "user_authored");
101
+ assert.equal(authored.some(chunk => chunk.text.includes("[SAND_HIDDEN_PROMPT]")), platform !== "grok_bot", `${platform}: ${text}`);
102
+ }
103
+ }
104
+ for (const text of reviewCases.source_isolation.mixed_prompts) {
105
+ const authored = splitUserText(text, { platform: "grok_bot" }).filter(chunk => chunk.originKind === "user_authored");
106
+ assert.deepEqual(authored.map(chunk => chunk.text), [reviewCases.masking.prompt]);
107
+ }
108
+ const ordinary = splitUserText(reviewCases.source_isolation.ordinary_multi_query, { platform: "grok_bot" })
109
+ .filter(chunk => chunk.originKind === "user_authored");
110
+ assert.deepEqual(ordinary.map(chunk => chunk.text), [Array(2).fill(reviewCases.masking.prompt).join("\n\n")]);
111
+ });
112
+ test("[grok_bot] shared title normalization preserves literal Grok markers", () => {
113
+ for (const text of reviewCases.source_isolation.literal_prompts) {
114
+ assert.equal(normalizeSessionTitleCandidate(text), text);
115
+ }
116
+ });
117
+ test("[grok_bot] fixture corpus: store preferred, titles cleaned, empty store skipped", async () => {
118
+ const source = createSourceDefinition("src-grok-bot-fixture", "grok_bot", fixtureRoot);
119
+ const files = await listSourceFiles("grok_bot", fixtureRoot);
120
+ assert.ok(files.some((file) => file.endsWith(`${STORE_AGENT}/store.db`)));
121
+ assert.ok(files.some((file) => file.endsWith(`${JSONL_ONLY}.jsonl`)));
122
+ assert.ok(files.some((file) => file.endsWith(`${EMPTY_STORE_JSONL}.jsonl`)));
123
+ assert.ok(files.some((file) => file.endsWith(`${DELETED_AGENT}.jsonl`)));
124
+ assert.ok(files.some((file) => file.endsWith(`${MISSING_PROFILE}.jsonl`)));
125
+ // Inventory is path-only; preference follows the actual budgeted store parse.
126
+ assert.equal(files.some((file) => file.includes(STORE_AGENT) && file.endsWith(".jsonl")), true);
127
+ const [payload] = (await runSourceProbe({ source_ids: [source.id] }, [source])).sources;
128
+ assert.ok(payload);
129
+ assert.equal(payload.source.sync_status, "healthy");
130
+ const sessionIds = payload.sessions.map((session) => session.source_session_id).sort();
131
+ assert.deepEqual(sessionIds, [DELETED_AGENT, EMPTY_STORE_JSONL, JSONL_ONLY, MISSING_PROFILE, STORE_AGENT].sort());
132
+ assert.equal(payload.sessions.some((session) => session.source_session_id === EMPTY_AGENT), false);
133
+ const storeSession = payload.sessions.find((session) => session.source_session_id === STORE_AGENT);
134
+ assert.ok(storeSession);
135
+ assert.equal(storeSession.title, "Fixture Bot");
136
+ const storeTurn = payload.turns.find((turn) => turn.session_id === storeSession.id);
137
+ assert.ok(storeTurn);
138
+ assert.match(storeTurn.canonical_text, /workspace map/u);
139
+ assert.equal(payload.turns.some((turn) => turn.canonical_text.includes("should not win over store")), false);
140
+ const jsonlSession = payload.sessions.find((session) => session.source_session_id === JSONL_ONLY);
141
+ assert.ok(jsonlSession);
142
+ const jsonlTurn = payload.turns.find((turn) => turn.session_id === jsonlSession.id);
143
+ assert.ok(jsonlTurn);
144
+ assert.match(jsonlTurn.canonical_text, /Jsonl-only session/u);
145
+ const emptyStoreSession = payload.sessions.find((session) => session.source_session_id === EMPTY_STORE_JSONL);
146
+ assert.ok(emptyStoreSession);
147
+ assert.equal(emptyStoreSession.title, "Empty Store With Jsonl");
148
+ assert.ok(payload.turns.some((turn) => turn.canonical_text.includes("Fallback jsonl after empty store")));
149
+ const deletedSession = payload.sessions.find((session) => session.source_session_id === DELETED_AGENT);
150
+ assert.ok(deletedSession);
151
+ assert.equal(deletedSession.title, "Deleted Bot From Update");
152
+ assert.doesNotMatch(deletedSession.title ?? "", /SAND_HIDDEN_PROMPT|first run/u);
153
+ assert.ok(payload.turns.some((turn) => turn.session_id === deletedSession.id && /workspace roots/u.test(turn.canonical_text)));
154
+ assert.equal(payload.turns.some((turn) => turn.session_id === deletedSession.id && turn.canonical_text.includes("SAND_HIDDEN_PROMPT")), false);
155
+ const missingSession = payload.sessions.find((session) => session.source_session_id === MISSING_PROFILE);
156
+ assert.ok(missingSession);
157
+ assert.match(missingSession.title ?? "", /Summarize the feeds layout/u);
158
+ assert.doesNotMatch(missingSession.title ?? "", /SAND_HIDDEN_PROMPT|\[t0u\]/u);
159
+ });
160
+ test("[grok_bot] missing root degrades safely", async () => {
161
+ const missing = path.join(os.tmpdir(), `cchistory-grok-bot-missing-${process.pid}`);
162
+ const source = createSourceDefinition("src-grok-bot-missing", "grok_bot", missing);
163
+ const [payload] = (await runSourceProbe({ source_ids: [source.id] }, [source])).sources;
164
+ assert.ok(payload);
165
+ assert.equal(payload.sessions.length, 0);
166
+ assert.equal(payload.turns.length, 0);
167
+ });
168
+ test("[grok_bot] empty root degrades safely", async () => {
169
+ const tempRoot = await mkdtemp(path.join(os.tmpdir(), "cchistory-grok-bot-empty-"));
170
+ try {
171
+ await mkdir(path.join(tempRoot, "agents"), { recursive: true });
172
+ await mkdir(path.join(tempRoot, "agent-transcripts"), { recursive: true });
173
+ const source = createSourceDefinition("src-grok-bot-empty", "grok_bot", tempRoot);
174
+ const [payload] = (await runSourceProbe({ source_ids: [source.id] }, [source])).sources;
175
+ assert.ok(payload);
176
+ assert.equal(payload.sessions.length, 0);
177
+ }
178
+ finally {
179
+ await rm(tempRoot, { recursive: true, force: true });
180
+ }
181
+ });
182
+ test("[grok_bot] malformed store.db degrades without inventing sessions", async () => {
183
+ const tempRoot = await mkdtemp(path.join(os.tmpdir(), "cchistory-grok-bot-malformed-"));
184
+ try {
185
+ const agentId = "12121212-eeee-4fff-8111-222222222222";
186
+ const agentDir = path.join(tempRoot, "agents", agentId);
187
+ await mkdir(agentDir, { recursive: true });
188
+ await writeFile(path.join(agentDir, "store.db"), "not-a-sqlite-database", "utf8");
189
+ const source = createSourceDefinition("src-grok-bot-malformed", "grok_bot", tempRoot);
190
+ const [payload] = (await runSourceProbe({ source_ids: [source.id] }, [source])).sources;
191
+ assert.ok(payload);
192
+ assert.equal(payload.sessions.length, 0);
193
+ }
194
+ finally {
195
+ await rm(tempRoot, { recursive: true, force: true });
196
+ }
197
+ });
198
+ test("[grok_bot] store-only and jsonl-only temp trees both project", async () => {
199
+ const tempRoot = await mkdtemp(path.join(os.tmpdir(), "cchistory-grok-bot-shapes-"));
200
+ try {
201
+ const storeId = "11111111-2222-4333-8444-555555555555";
202
+ const jsonlId = "66666666-7777-4888-8999-aaaaaaaaaaaa";
203
+ const storeDir = path.join(tempRoot, "agents", storeId);
204
+ await mkdir(storeDir, { recursive: true });
205
+ seedStore(path.join(storeDir, "store.db"), [
206
+ {
207
+ kind: "message",
208
+ id: "t0u",
209
+ role: "user",
210
+ content: "Store-only prompt",
211
+ timestampMs: Date.parse("2026-10-07T11:00:00.000Z"),
212
+ },
213
+ {
214
+ kind: "message",
215
+ id: "t0a0",
216
+ role: "assistant",
217
+ content: "Store-only reply",
218
+ timestampMs: Date.parse("2026-10-07T11:00:01.000Z"),
219
+ },
220
+ ]);
221
+ await writeFile(path.join(storeDir, "profile.json"), JSON.stringify({ name: "Store Only" }), "utf8");
222
+ const transcriptDir = path.join(tempRoot, "agent-transcripts", jsonlId);
223
+ await mkdir(transcriptDir, { recursive: true });
224
+ await writeFile(path.join(transcriptDir, `${jsonlId}.jsonl`), `${JSON.stringify({
225
+ role: "user",
226
+ message: { content: [{ type: "text", text: "Jsonl-only prompt" }] },
227
+ })}\n${JSON.stringify({
228
+ role: "assistant",
229
+ message: { content: [{ type: "text", text: "Jsonl-only reply" }] },
230
+ })}\n`, "utf8");
231
+ const source = createSourceDefinition("src-grok-bot-shapes", "grok_bot", tempRoot);
232
+ const [payload] = (await runSourceProbe({ source_ids: [source.id] }, [source])).sources;
233
+ assert.ok(payload);
234
+ assert.equal(payload.sessions.length, 2);
235
+ assert.ok(payload.turns.some((turn) => turn.canonical_text === "Store-only prompt"));
236
+ assert.ok(payload.turns.some((turn) => turn.canonical_text === "Jsonl-only prompt"));
237
+ const storeSession = payload.sessions.find((session) => session.source_session_id === storeId);
238
+ assert.equal(storeSession?.title, "Store Only");
239
+ }
240
+ finally {
241
+ await rm(tempRoot, { recursive: true, force: true });
242
+ }
243
+ });
244
+ test("[grok_bot] when both shapes exist for one agent, store wins", async () => {
245
+ const tempRoot = await mkdtemp(path.join(os.tmpdir(), "cchistory-grok-bot-both-"));
246
+ try {
247
+ const agentId = "99999999-aaaa-4bbb-8ccc-dddddddddddd";
248
+ const storeDir = path.join(tempRoot, "agents", agentId);
249
+ await mkdir(storeDir, { recursive: true });
250
+ seedStore(path.join(storeDir, "store.db"), [
251
+ {
252
+ kind: "message",
253
+ id: "t0u",
254
+ role: "user",
255
+ content: "Preferred store text",
256
+ timestampMs: Date.parse("2026-10-07T12:00:00.000Z"),
257
+ },
258
+ {
259
+ kind: "message",
260
+ id: "t0a0",
261
+ role: "assistant",
262
+ content: "Preferred store reply",
263
+ timestampMs: Date.parse("2026-10-07T12:00:01.000Z"),
264
+ },
265
+ ]);
266
+ const transcriptDir = path.join(tempRoot, "agent-transcripts", agentId);
267
+ await mkdir(transcriptDir, { recursive: true });
268
+ await writeFile(path.join(transcriptDir, `${agentId}.jsonl`), `${JSON.stringify({
269
+ role: "user",
270
+ message: { content: [{ type: "text", text: "Duplicate jsonl text" }] },
271
+ })}\n`, "utf8");
272
+ const files = await listSourceFiles("grok_bot", tempRoot);
273
+ assert.ok(files.some((file) => file.endsWith("store.db")));
274
+ assert.equal(files.some((file) => file.endsWith(".jsonl")), true);
275
+ const source = createSourceDefinition("src-grok-bot-both", "grok_bot", tempRoot);
276
+ const events = [];
277
+ const [payload] = (await runSourceProbe({ source_ids: [source.id], on_progress: event => events.push(event) }, [source])).sources;
278
+ assert.ok(payload);
279
+ assert.equal(payload.sessions.length, 1);
280
+ assert.equal(payload.turns[0]?.canonical_text, "Preferred store text");
281
+ assert.equal(payload.turns.some((turn) => turn.canonical_text.includes("Duplicate jsonl")), false);
282
+ assert.ok(events.some(event => event.stage === "file_skip" && event.file_path?.endsWith(".jsonl")));
283
+ assert.equal(events.some(event => event.stage === "file_capture_done" && event.file_path?.endsWith(".jsonl")), false);
284
+ // Explicit inventories may put JSONL before SQLite. Reconciliation must use
285
+ // parsed evidence even when raw bodies are not retained.
286
+ for (const retainRaw of [true, false]) {
287
+ const [reversed] = (await runSourceProbe({ source_ids: [source.id],
288
+ source_file_paths: { [source.id]: [...files].reverse() }, retain_raw_records: retainRaw }, [source])).sources;
289
+ assert.ok(reversed);
290
+ assert.deepEqual(reversed.turns.map(turn => turn.canonical_text), ["Preferred store text"]);
291
+ }
292
+ }
293
+ finally {
294
+ await rm(tempRoot, { recursive: true, force: true });
295
+ }
296
+ });
297
+ test("[grok_bot] unusable stores retain evidence and allow the JSONL conversation", async () => {
298
+ for (const fixture of reviewCases.fallback_cases) {
299
+ const root = await mkdtemp(path.join(os.tmpdir(), `cchistory-grok-bot-${fixture.name}-`));
300
+ try {
301
+ const storePath = await copyAgentFixture(root);
302
+ if (fixture.database_text) {
303
+ await writeFile(storePath, fixture.database_text, "utf8");
304
+ }
305
+ else {
306
+ const db = new DatabaseSync(storePath);
307
+ try {
308
+ if (fixture.missing_table) {
309
+ db.exec("DROP TABLE transcript_entries");
310
+ }
311
+ else {
312
+ const entries = fixture.raw_entry ? [fixture.raw_entry] : fixture.entries.map(entry => JSON.stringify(entry));
313
+ const insert = db.prepare("INSERT INTO transcript_entries (seq, id, entry) VALUES (?, ?, ?)");
314
+ entries.forEach((entry, index) => insert.run(index + 1, `fixture-${index}`, entry));
315
+ }
316
+ }
317
+ finally {
318
+ db.close();
319
+ }
320
+ }
321
+ const source = createSourceDefinition("src-grok-bot-fallback", "grok_bot", root);
322
+ const [payload] = (await runSourceProbe({ safe_mode: true, retain_raw_records: false }, [source])).sources;
323
+ assert.ok(payload);
324
+ assert.equal(payload.sessions.length, 1, fixture.name);
325
+ assert.deepEqual(payload.turns.map(turn => turn.canonical_text), ["Fallback jsonl after empty store."], fixture.name);
326
+ assert.equal(payload.sessions[0]?.title, "Empty Store With Jsonl", fixture.name);
327
+ if (fixture.diagnostic) {
328
+ assert.ok(payload.loss_audits.some(audit => audit.diagnostic_code === fixture.diagnostic), fixture.name);
329
+ }
330
+ if (fixture.retained_text) {
331
+ assert.ok(payload.atoms.some(atom => atom.payload.text === fixture.retained_text), fixture.name);
332
+ }
333
+ if (fixture.retained_item_type) {
334
+ const unknown = payload.fragments.find(fragment => fragment.fragment_kind === "unknown" &&
335
+ fragment.payload.type === fixture.retained_item_type);
336
+ assert.ok(unknown, fixture.name);
337
+ assert.deepEqual(unknown.payload.raw, fixture.entries?.[0], fixture.name);
338
+ }
339
+ if (!fixture.database_text && !fixture.missing_table) {
340
+ assert.ok(payload.records.some(record => record.record_path_or_offset !== "meta" &&
341
+ payload.blobs.some(blob => blob.id === record.blob_id && blob.origin_path.endsWith("store.db"))), fixture.name);
342
+ }
343
+ }
344
+ finally {
345
+ await rm(root, { recursive: true, force: true });
346
+ }
347
+ }
348
+ });
349
+ test("[grok_bot] canonical masks user, profile and recovered titles in both native shapes", async () => {
350
+ const fixture = reviewCases.masking;
351
+ const token = fixture.token_prefix + fixture.token_character.repeat(fixture.token_length);
352
+ for (const shape of ["store", "jsonl"]) {
353
+ for (const titleSource of ["user", "profile", "profile-update"]) {
354
+ for (const padding of ["", fixture.cut_padding_character.repeat(fixture.cut_padding_length) + " "]) {
355
+ const root = await mkdtemp(path.join(os.tmpdir(), "cchistory-grok-bot-mask-"));
356
+ try {
357
+ const storePath = await copyAgentFixture(root);
358
+ const agentDir = path.dirname(storePath);
359
+ await rm(path.join(agentDir, "profile.json"));
360
+ const entries = [
361
+ { kind: "message", id: "t0u", role: "user", content: titleSource === "user" ? `${padding}${token} ${fixture.prompt}` : fixture.prompt, timestampMs: fixture.timestamp_ms },
362
+ { kind: "message", id: "t0a0", role: "assistant", content: fixture.reply, timestampMs: fixture.timestamp_ms + 1000 },
363
+ ];
364
+ if (titleSource === "profile") {
365
+ await writeFile(path.join(agentDir, "profile.json"), JSON.stringify({ name: `${padding}${token} ${fixture.name}` }));
366
+ }
367
+ else if (titleSource === "profile-update") {
368
+ const update = Buffer.from(JSON.stringify({ name: `${padding}${token} ${fixture.name}` })).toString("base64url");
369
+ entries.unshift({ kind: "message", id: "profile-update", role: "user",
370
+ content: `[SAND_HIDDEN_PROMPT]<<SAND_AGENT_PROFILE_UPDATE:v1:${update}>>`, timestampMs: fixture.timestamp_ms - 1000 });
371
+ }
372
+ if (shape === "store") {
373
+ const db = new DatabaseSync(storePath);
374
+ try {
375
+ const insert = db.prepare("INSERT INTO transcript_entries (seq, id, entry) VALUES (?, ?, ?)");
376
+ entries.forEach((entry, index) => insert.run(index + 1, entry.id, JSON.stringify(entry)));
377
+ }
378
+ finally {
379
+ db.close();
380
+ }
381
+ }
382
+ else {
383
+ await writeFile(path.join(root, "agent-transcripts", reviewCases.agent_id, `${reviewCases.agent_id}.jsonl`), entries.map(entry => JSON.stringify({ role: entry.role, content: entry.content })).join("\n"));
384
+ }
385
+ const source = createSourceDefinition("src-grok-bot-mask", "grok_bot", root);
386
+ const [payload] = (await runSourceProbe({ safe_mode: true }, [source])).sources;
387
+ assert.ok(payload);
388
+ assert.ok(payload.sessions[0]?.title?.includes(fixture.token_prefix), `${shape}/${titleSource} raw evidence`);
389
+ const canonical = payload.sessions[0]?.canonical_title;
390
+ assert.ok(canonical);
391
+ assert.equal(canonical.includes(fixture.token_prefix), false, `${shape}/${titleSource} token fragment`);
392
+ if (padding) {
393
+ assert.ok(canonical.startsWith(padding.trim()), `${shape}/${titleSource} prefix`);
394
+ assert.ok(canonical.includes(titleSource === "user" ? "Rotate" : "Fixture"), `${shape}/${titleSource} visible title`);
395
+ }
396
+ else {
397
+ assert.equal(canonical, titleSource === "user" ? fixture.prompt : fixture.name, `${shape}/${titleSource}`);
398
+ }
399
+ assert.equal(payload.turns[0]?.canonical_text, titleSource === "user" && padding ? `${padding} ${fixture.prompt}` : fixture.prompt, `${shape}/${titleSource}`);
400
+ if (titleSource === "profile" && padding) {
401
+ await writeFile(path.join(agentDir, "profile.json"), JSON.stringify({ name: token }));
402
+ const [masked] = (await runSourceProbe({ safe_mode: true }, [source])).sources;
403
+ assert.equal(masked?.sessions[0]?.canonical_title, "", `${shape} fully masked profile`);
404
+ }
405
+ }
406
+ finally {
407
+ await rm(root, { recursive: true, force: true });
408
+ }
409
+ }
410
+ }
411
+ }
412
+ });
413
+ test("[grok_bot] default discovery registers grok_bot slot", () => {
414
+ const sources = getDefaultSourcesForHost({
415
+ homeDir: "/tmp/cchistory-no-such-home",
416
+ includeMissing: true,
417
+ });
418
+ const grokBot = sources.find((source) => source.platform === "grok_bot");
419
+ assert.ok(grokBot);
420
+ assert.equal(grokBot.slot_id, "grok_bot");
421
+ assert.equal(grokBot.display_name, "Grok Bot");
422
+ });
423
+ //# sourceMappingURL=grok-bot.test.js.map