@superblocksteam/vite-plugin-file-sync 2.0.159-next.0 → 2.0.160

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 (337) hide show
  1. package/dist/ai-service/agent/middleware.d.ts +2 -1
  2. package/dist/ai-service/agent/middleware.d.ts.map +1 -1
  3. package/dist/ai-service/agent/middleware.js +3 -2
  4. package/dist/ai-service/agent/middleware.js.map +1 -1
  5. package/dist/ai-service/agent/prompts/build-base-system-prompt.d.ts.map +1 -1
  6. package/dist/ai-service/agent/prompts/build-base-system-prompt.js +4 -5
  7. package/dist/ai-service/agent/prompts/build-base-system-prompt.js.map +1 -1
  8. package/dist/ai-service/agent/tool-message-utils.d.ts.map +1 -1
  9. package/dist/ai-service/agent/tool-message-utils.js +1 -16
  10. package/dist/ai-service/agent/tool-message-utils.js.map +1 -1
  11. package/dist/ai-service/agent/tools/apis/test-api.d.ts +1 -50
  12. package/dist/ai-service/agent/tools/apis/test-api.d.ts.map +1 -1
  13. package/dist/ai-service/agent/tools/apis/test-api.js +10 -132
  14. package/dist/ai-service/agent/tools/apis/test-api.js.map +1 -1
  15. package/dist/ai-service/agent/tools/build-delete-file.d.ts +2 -1
  16. package/dist/ai-service/agent/tools/build-delete-file.d.ts.map +1 -1
  17. package/dist/ai-service/agent/tools/build-delete-file.js +0 -2
  18. package/dist/ai-service/agent/tools/build-delete-file.js.map +1 -1
  19. package/dist/ai-service/agent/tools/build-edit-file.d.ts +2 -1
  20. package/dist/ai-service/agent/tools/build-edit-file.d.ts.map +1 -1
  21. package/dist/ai-service/agent/tools/build-edit-file.js +0 -2
  22. package/dist/ai-service/agent/tools/build-edit-file.js.map +1 -1
  23. package/dist/ai-service/agent/tools/build-install-packages.d.ts +0 -1
  24. package/dist/ai-service/agent/tools/build-install-packages.d.ts.map +1 -1
  25. package/dist/ai-service/agent/tools/build-install-packages.js +16 -123
  26. package/dist/ai-service/agent/tools/build-install-packages.js.map +1 -1
  27. package/dist/ai-service/agent/tools/build-lookup-npm-package.d.ts.map +1 -1
  28. package/dist/ai-service/agent/tools/build-lookup-npm-package.js +16 -4
  29. package/dist/ai-service/agent/tools/build-lookup-npm-package.js.map +1 -1
  30. package/dist/ai-service/agent/tools/build-manage-checklist.d.ts +7 -11
  31. package/dist/ai-service/agent/tools/build-manage-checklist.d.ts.map +1 -1
  32. package/dist/ai-service/agent/tools/build-manage-checklist.js +9 -18
  33. package/dist/ai-service/agent/tools/build-manage-checklist.js.map +1 -1
  34. package/dist/ai-service/agent/tools/build-multi-edit-file.d.ts +2 -1
  35. package/dist/ai-service/agent/tools/build-multi-edit-file.d.ts.map +1 -1
  36. package/dist/ai-service/agent/tools/build-multi-edit-file.js +0 -2
  37. package/dist/ai-service/agent/tools/build-multi-edit-file.js.map +1 -1
  38. package/dist/ai-service/agent/tools/build-read-file.d.ts.map +1 -1
  39. package/dist/ai-service/agent/tools/build-read-file.js +18 -31
  40. package/dist/ai-service/agent/tools/build-read-file.js.map +1 -1
  41. package/dist/ai-service/agent/tools/build-rename-file.d.ts +2 -1
  42. package/dist/ai-service/agent/tools/build-rename-file.d.ts.map +1 -1
  43. package/dist/ai-service/agent/tools/build-rename-file.js +0 -2
  44. package/dist/ai-service/agent/tools/build-rename-file.js.map +1 -1
  45. package/dist/ai-service/agent/tools/build-write-file.d.ts +2 -1
  46. package/dist/ai-service/agent/tools/build-write-file.d.ts.map +1 -1
  47. package/dist/ai-service/agent/tools/build-write-file.js +0 -2
  48. package/dist/ai-service/agent/tools/build-write-file.js.map +1 -1
  49. package/dist/ai-service/agent/tools/databases/dev-database-tasks.d.ts +3 -3
  50. package/dist/ai-service/agent/tools/databases/dev-database-tasks.d.ts.map +1 -1
  51. package/dist/ai-service/agent/tools/databases/dev-database-tasks.js +7 -5
  52. package/dist/ai-service/agent/tools/databases/dev-database-tasks.js.map +1 -1
  53. package/dist/ai-service/agent/tools/debug-cache.d.ts +14 -16
  54. package/dist/ai-service/agent/tools/debug-cache.d.ts.map +1 -1
  55. package/dist/ai-service/agent/tools/debug-cache.js +42 -200
  56. package/dist/ai-service/agent/tools/debug-cache.js.map +1 -1
  57. package/dist/ai-service/agent/tools/integrations/execute-request.d.ts +13 -13
  58. package/dist/ai-service/agent/tools/integrations/execute-request.d.ts.map +1 -1
  59. package/dist/ai-service/agent/tools/integrations/execute-request.js +20 -52
  60. package/dist/ai-service/agent/tools/integrations/execute-request.js.map +1 -1
  61. package/dist/ai-service/agent/tools/integrations/sql-classification.d.ts +1 -7
  62. package/dist/ai-service/agent/tools/integrations/sql-classification.d.ts.map +1 -1
  63. package/dist/ai-service/agent/tools/integrations/sql-classification.js +11 -229
  64. package/dist/ai-service/agent/tools/integrations/sql-classification.js.map +1 -1
  65. package/dist/ai-service/agent/tools/report-security-findings.d.ts +5 -5
  66. package/dist/ai-service/agent/tools.d.ts +0 -32
  67. package/dist/ai-service/agent/tools.d.ts.map +1 -1
  68. package/dist/ai-service/agent/tools.js +33 -54
  69. package/dist/ai-service/agent/tools.js.map +1 -1
  70. package/dist/ai-service/agent/tools2/registry.d.ts +1 -1
  71. package/dist/ai-service/agent/tools2/registry.d.ts.map +1 -1
  72. package/dist/ai-service/agent/tools2/registry.js +4 -21
  73. package/dist/ai-service/agent/tools2/registry.js.map +1 -1
  74. package/dist/ai-service/agent/tools2/tools/end-test-run.d.ts +2 -2
  75. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.d.ts.map +1 -1
  76. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js +11 -20
  77. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js.map +1 -1
  78. package/dist/ai-service/agent/tools2/tools/grep-metadata-ripgrep.d.ts +0 -4
  79. package/dist/ai-service/agent/tools2/tools/grep-metadata-ripgrep.d.ts.map +1 -1
  80. package/dist/ai-service/agent/tools2/tools/grep-metadata-ripgrep.js +8 -28
  81. package/dist/ai-service/agent/tools2/tools/grep-metadata-ripgrep.js.map +1 -1
  82. package/dist/ai-service/agent/tools2/tools/update-test-case-status.d.ts +2 -2
  83. package/dist/ai-service/app-interface/shell.d.ts +3 -20
  84. package/dist/ai-service/app-interface/shell.d.ts.map +1 -1
  85. package/dist/ai-service/app-interface/shell.js +65 -139
  86. package/dist/ai-service/app-interface/shell.js.map +1 -1
  87. package/dist/ai-service/attachment-upload.d.ts.map +1 -1
  88. package/dist/ai-service/attachment-upload.js +1 -4
  89. package/dist/ai-service/attachment-upload.js.map +1 -1
  90. package/dist/ai-service/chat/chat-session-store.d.ts +8 -0
  91. package/dist/ai-service/chat/chat-session-store.d.ts.map +1 -1
  92. package/dist/ai-service/chat/chat-session-store.js +611 -34
  93. package/dist/ai-service/chat/chat-session-store.js.map +1 -1
  94. package/dist/ai-service/chat/utils.d.ts +6 -2
  95. package/dist/ai-service/chat/utils.d.ts.map +1 -1
  96. package/dist/ai-service/chat/utils.js +95 -2
  97. package/dist/ai-service/chat/utils.js.map +1 -1
  98. package/dist/ai-service/index.d.ts +2 -3
  99. package/dist/ai-service/index.d.ts.map +1 -1
  100. package/dist/ai-service/index.js +48 -138
  101. package/dist/ai-service/index.js.map +1 -1
  102. package/dist/ai-service/integrations/store.d.ts +0 -9
  103. package/dist/ai-service/integrations/store.d.ts.map +1 -1
  104. package/dist/ai-service/integrations/store.js +1 -11
  105. package/dist/ai-service/integrations/store.js.map +1 -1
  106. package/dist/ai-service/llm/client.d.ts.map +1 -1
  107. package/dist/ai-service/llm/client.js +4 -67
  108. package/dist/ai-service/llm/client.js.map +1 -1
  109. package/dist/ai-service/llm/context-v2/adapter.d.ts +0 -1
  110. package/dist/ai-service/llm/context-v2/adapter.d.ts.map +1 -1
  111. package/dist/ai-service/llm/context-v2/adapter.js +0 -3
  112. package/dist/ai-service/llm/context-v2/adapter.js.map +1 -1
  113. package/dist/ai-service/llm/context-v2/compaction/client-side.d.ts +0 -7
  114. package/dist/ai-service/llm/context-v2/compaction/client-side.d.ts.map +1 -1
  115. package/dist/ai-service/llm/context-v2/compaction/client-side.js +6 -28
  116. package/dist/ai-service/llm/context-v2/compaction/client-side.js.map +1 -1
  117. package/dist/ai-service/llm/context-v2/compaction/compaction-strategy.d.ts +0 -12
  118. package/dist/ai-service/llm/context-v2/compaction/compaction-strategy.d.ts.map +1 -1
  119. package/dist/ai-service/llm/context-v2/compactor.d.ts +0 -8
  120. package/dist/ai-service/llm/context-v2/compactor.d.ts.map +1 -1
  121. package/dist/ai-service/llm/context-v2/compactor.js +3 -15
  122. package/dist/ai-service/llm/context-v2/compactor.js.map +1 -1
  123. package/dist/ai-service/llm/context-v2/config.d.ts.map +1 -1
  124. package/dist/ai-service/llm/context-v2/config.js +0 -1
  125. package/dist/ai-service/llm/context-v2/config.js.map +1 -1
  126. package/dist/ai-service/llm/context-v2/context-metrics.d.ts +1 -44
  127. package/dist/ai-service/llm/context-v2/context-metrics.d.ts.map +1 -1
  128. package/dist/ai-service/llm/context-v2/context-metrics.js +12 -97
  129. package/dist/ai-service/llm/context-v2/context-metrics.js.map +1 -1
  130. package/dist/ai-service/llm/context-v2/context.d.ts +0 -125
  131. package/dist/ai-service/llm/context-v2/context.d.ts.map +1 -1
  132. package/dist/ai-service/llm/context-v2/context.js +14 -478
  133. package/dist/ai-service/llm/context-v2/context.js.map +1 -1
  134. package/dist/ai-service/llm/context-v2/conversation-context.d.ts +0 -12
  135. package/dist/ai-service/llm/context-v2/conversation-context.d.ts.map +1 -1
  136. package/dist/ai-service/llm/context-v2/phase1-tool-summarizer.d.ts.map +1 -1
  137. package/dist/ai-service/llm/context-v2/phase1-tool-summarizer.js +1 -2
  138. package/dist/ai-service/llm/context-v2/phase1-tool-summarizer.js.map +1 -1
  139. package/dist/ai-service/llm/context-v2/phase2-session-summarizer.js +3 -3
  140. package/dist/ai-service/llm/context-v2/phase2-session-summarizer.js.map +1 -1
  141. package/dist/ai-service/llm/context-v2/token-tracker.d.ts +1 -49
  142. package/dist/ai-service/llm/context-v2/token-tracker.d.ts.map +1 -1
  143. package/dist/ai-service/llm/context-v2/token-tracker.js +0 -119
  144. package/dist/ai-service/llm/context-v2/token-tracker.js.map +1 -1
  145. package/dist/ai-service/llm/context-v2/truncation-fallback.d.ts.map +1 -1
  146. package/dist/ai-service/llm/context-v2/truncation-fallback.js +1 -2
  147. package/dist/ai-service/llm/context-v2/truncation-fallback.js.map +1 -1
  148. package/dist/ai-service/llm/context-v2/types.d.ts +0 -9
  149. package/dist/ai-service/llm/context-v2/types.d.ts.map +1 -1
  150. package/dist/ai-service/llm/context-v2/types.js.map +1 -1
  151. package/dist/ai-service/llm/error.d.ts +1 -22
  152. package/dist/ai-service/llm/error.d.ts.map +1 -1
  153. package/dist/ai-service/llm/error.js +22 -159
  154. package/dist/ai-service/llm/error.js.map +1 -1
  155. package/dist/ai-service/llm/stream/empty-tool-call-tracker.d.ts +3 -4
  156. package/dist/ai-service/llm/stream/empty-tool-call-tracker.d.ts.map +1 -1
  157. package/dist/ai-service/llm/stream/empty-tool-call-tracker.js +4 -5
  158. package/dist/ai-service/llm/stream/empty-tool-call-tracker.js.map +1 -1
  159. package/dist/ai-service/llm/stream/idle-monitor.d.ts.map +1 -1
  160. package/dist/ai-service/llm/stream/idle-monitor.js +0 -5
  161. package/dist/ai-service/llm/stream/idle-monitor.js.map +1 -1
  162. package/dist/ai-service/llm/stream/observers/logging.d.ts +0 -6
  163. package/dist/ai-service/llm/stream/observers/logging.d.ts.map +1 -1
  164. package/dist/ai-service/llm/stream/observers/logging.js +3 -44
  165. package/dist/ai-service/llm/stream/observers/logging.js.map +1 -1
  166. package/dist/ai-service/llm/stream/orchestrator.d.ts.map +1 -1
  167. package/dist/ai-service/llm/stream/orchestrator.js +4 -28
  168. package/dist/ai-service/llm/stream/orchestrator.js.map +1 -1
  169. package/dist/ai-service/llm/stream/retry-engine.d.ts +1 -1
  170. package/dist/ai-service/llm/stream/retry-engine.d.ts.map +1 -1
  171. package/dist/ai-service/llm/stream/retry-engine.js +1 -9
  172. package/dist/ai-service/llm/stream/retry-engine.js.map +1 -1
  173. package/dist/ai-service/llm/stream/session.d.ts +0 -6
  174. package/dist/ai-service/llm/stream/session.d.ts.map +1 -1
  175. package/dist/ai-service/llm/stream/session.js +0 -6
  176. package/dist/ai-service/llm/stream/session.js.map +1 -1
  177. package/dist/ai-service/llm/stream/terminal-reason.d.ts.map +1 -1
  178. package/dist/ai-service/llm/stream/terminal-reason.js +1 -11
  179. package/dist/ai-service/llm/stream/terminal-reason.js.map +1 -1
  180. package/dist/ai-service/llm/stream/wait-state-tracker.d.ts +3 -4
  181. package/dist/ai-service/llm/stream/wait-state-tracker.d.ts.map +1 -1
  182. package/dist/ai-service/llm/stream/wait-state-tracker.js +8 -12
  183. package/dist/ai-service/llm/stream/wait-state-tracker.js.map +1 -1
  184. package/dist/ai-service/policy-agent-metrics.d.ts +1 -2
  185. package/dist/ai-service/policy-agent-metrics.d.ts.map +1 -1
  186. package/dist/ai-service/policy-agent-metrics.js +2 -11
  187. package/dist/ai-service/policy-agent-metrics.js.map +1 -1
  188. package/dist/ai-service/resolve-generation-state-for-ui.js +1 -1
  189. package/dist/ai-service/resolve-generation-state-for-ui.js.map +1 -1
  190. package/dist/ai-service/security/secret-scanner-service.d.ts +6 -3
  191. package/dist/ai-service/security/secret-scanner-service.d.ts.map +1 -1
  192. package/dist/ai-service/security/secret-scanner-service.js +97 -229
  193. package/dist/ai-service/security/secret-scanner-service.js.map +1 -1
  194. package/dist/ai-service/security/secret-scanner.d.ts +5 -28
  195. package/dist/ai-service/security/secret-scanner.d.ts.map +1 -1
  196. package/dist/ai-service/security/secret-scanner.js +42 -197
  197. package/dist/ai-service/security/secret-scanner.js.map +1 -1
  198. package/dist/ai-service/skills/system/superblocks-frontend/skill.generated.d.ts +1 -1
  199. package/dist/ai-service/skills/system/superblocks-frontend/skill.generated.d.ts.map +1 -1
  200. package/dist/ai-service/skills/system/superblocks-frontend/skill.generated.js +0 -49
  201. package/dist/ai-service/skills/system/superblocks-frontend/skill.generated.js.map +1 -1
  202. package/dist/ai-service/skills/system/third-party-migration/skill.generated.d.ts +1 -1
  203. package/dist/ai-service/skills/system/third-party-migration/skill.generated.d.ts.map +1 -1
  204. package/dist/ai-service/skills/system/third-party-migration/skill.generated.js +0 -1
  205. package/dist/ai-service/skills/system/third-party-migration/skill.generated.js.map +1 -1
  206. package/dist/ai-service/state-machine/clark-fsm.d.ts +0 -2
  207. package/dist/ai-service/state-machine/clark-fsm.d.ts.map +1 -1
  208. package/dist/ai-service/state-machine/clark-fsm.js +1 -1
  209. package/dist/ai-service/state-machine/clark-fsm.js.map +1 -1
  210. package/dist/ai-service/state-machine/handlers/agent-planning.d.ts +1 -1
  211. package/dist/ai-service/state-machine/handlers/agent-planning.d.ts.map +1 -1
  212. package/dist/ai-service/state-machine/handlers/agent-planning.js +3 -74
  213. package/dist/ai-service/state-machine/handlers/agent-planning.js.map +1 -1
  214. package/dist/ai-service/state-machine/handlers/llm-generating.d.ts.map +1 -1
  215. package/dist/ai-service/state-machine/handlers/llm-generating.js +11 -1
  216. package/dist/ai-service/state-machine/handlers/llm-generating.js.map +1 -1
  217. package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.d.ts +2 -3
  218. package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.d.ts.map +1 -1
  219. package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.js +5 -25
  220. package/dist/ai-service/state-machine/helpers/policy-gate-usage-metrics.js.map +1 -1
  221. package/dist/ai-service/state-machine/helpers/prompt-billing-metrics.d.ts.map +1 -1
  222. package/dist/ai-service/state-machine/helpers/prompt-billing-metrics.js +0 -1
  223. package/dist/ai-service/state-machine/helpers/prompt-billing-metrics.js.map +1 -1
  224. package/dist/ai-service/state-machine/helpers/stable-peer.d.ts +0 -4
  225. package/dist/ai-service/state-machine/helpers/stable-peer.d.ts.map +1 -1
  226. package/dist/ai-service/state-machine/helpers/stable-peer.js +1 -6
  227. package/dist/ai-service/state-machine/helpers/stable-peer.js.map +1 -1
  228. package/dist/ai-service/test-utils/metrics-harness.d.ts +0 -6
  229. package/dist/ai-service/test-utils/metrics-harness.d.ts.map +1 -1
  230. package/dist/ai-service/test-utils/metrics-harness.js.map +1 -1
  231. package/dist/ai-service/transform/api-builder/shared.d.ts.map +1 -1
  232. package/dist/ai-service/transform/api-builder/shared.js +1 -2
  233. package/dist/ai-service/transform/api-builder/shared.js.map +1 -1
  234. package/dist/dev-server-ws-smoke-client.d.ts.map +1 -1
  235. package/dist/dev-server-ws-smoke-client.js +0 -1
  236. package/dist/dev-server-ws-smoke-client.js.map +1 -1
  237. package/dist/file-sync-vite-plugin.d.ts +0 -21
  238. package/dist/file-sync-vite-plugin.d.ts.map +1 -1
  239. package/dist/file-sync-vite-plugin.js +11 -131
  240. package/dist/file-sync-vite-plugin.js.map +1 -1
  241. package/dist/file-system-helpers.d.ts +2 -2
  242. package/dist/file-system-helpers.d.ts.map +1 -1
  243. package/dist/file-system-helpers.js +12 -2
  244. package/dist/file-system-helpers.js.map +1 -1
  245. package/dist/parsing/jsx.d.ts +0 -12
  246. package/dist/parsing/jsx.d.ts.map +1 -1
  247. package/dist/parsing/jsx.js +12 -30
  248. package/dist/parsing/jsx.js.map +1 -1
  249. package/dist/parsing/page.d.ts.map +1 -1
  250. package/dist/parsing/page.js +8 -16
  251. package/dist/parsing/page.js.map +1 -1
  252. package/dist/plugin-options.d.ts +0 -4
  253. package/dist/plugin-options.d.ts.map +1 -1
  254. package/dist/plugin-options.js.map +1 -1
  255. package/dist/policy-gate-callback-mapper.d.ts +1 -2
  256. package/dist/policy-gate-callback-mapper.d.ts.map +1 -1
  257. package/dist/policy-gate-callback-mapper.js +5 -3
  258. package/dist/policy-gate-callback-mapper.js.map +1 -1
  259. package/dist/policy-gate-run-registry.d.ts +2 -4
  260. package/dist/policy-gate-run-registry.d.ts.map +1 -1
  261. package/dist/policy-gate-run-registry.js +2 -17
  262. package/dist/policy-gate-run-registry.js.map +1 -1
  263. package/dist/policy-gate-runner.d.ts +1 -1
  264. package/dist/policy-gate-runner.d.ts.map +1 -1
  265. package/dist/policy-gate-runner.js +7 -41
  266. package/dist/policy-gate-runner.js.map +1 -1
  267. package/dist/router-parser.d.ts +1 -6
  268. package/dist/router-parser.d.ts.map +1 -1
  269. package/dist/router-parser.js +17 -72
  270. package/dist/router-parser.js.map +1 -1
  271. package/dist/scan-scope-merge.d.ts +1 -1
  272. package/dist/scan-scope-merge.js +1 -1
  273. package/dist/source-tracker.d.ts.map +1 -1
  274. package/dist/source-tracker.js +6 -2
  275. package/dist/source-tracker.js.map +1 -1
  276. package/dist/sync-service/download.d.ts.map +1 -1
  277. package/dist/sync-service/download.js +2 -10
  278. package/dist/sync-service/download.js.map +1 -1
  279. package/dist/sync-service/index.d.ts +0 -5
  280. package/dist/sync-service/index.d.ts.map +1 -1
  281. package/dist/sync-service/index.js +14 -66
  282. package/dist/sync-service/index.js.map +1 -1
  283. package/dist/sync-service/list-dir.d.ts.map +1 -1
  284. package/dist/sync-service/list-dir.js +4 -8
  285. package/dist/sync-service/list-dir.js.map +1 -1
  286. package/dist/sync-service/snapshot/upload-snapshot.d.ts.map +1 -1
  287. package/dist/sync-service/snapshot/upload-snapshot.js +0 -20
  288. package/dist/sync-service/snapshot/upload-snapshot.js.map +1 -1
  289. package/dist/util/log-sanitizer.d.ts.map +1 -1
  290. package/dist/util/log-sanitizer.js +8 -10
  291. package/dist/util/log-sanitizer.js.map +1 -1
  292. package/dist/util/logger.d.ts +0 -2
  293. package/dist/util/logger.d.ts.map +1 -1
  294. package/dist/util/logger.js +38 -357
  295. package/dist/util/logger.js.map +1 -1
  296. package/dist/util.d.ts +1 -3
  297. package/dist/util.d.ts.map +1 -1
  298. package/dist/util.js +2 -2
  299. package/dist/util.js.map +1 -1
  300. package/package.json +9 -9
  301. package/dist/ai-service/agent/tool-result-metrics.d.ts +0 -29
  302. package/dist/ai-service/agent/tool-result-metrics.d.ts.map +0 -1
  303. package/dist/ai-service/agent/tool-result-metrics.js +0 -162
  304. package/dist/ai-service/agent/tool-result-metrics.js.map +0 -1
  305. package/dist/ai-service/agent/tools/page-edit-guidance.d.ts +0 -2
  306. package/dist/ai-service/agent/tools/page-edit-guidance.d.ts.map +0 -1
  307. package/dist/ai-service/agent/tools/page-edit-guidance.js +0 -11
  308. package/dist/ai-service/agent/tools/page-edit-guidance.js.map +0 -1
  309. package/dist/ai-service/app-interface/cancellable-exec.d.ts +0 -34
  310. package/dist/ai-service/app-interface/cancellable-exec.d.ts.map +0 -1
  311. package/dist/ai-service/app-interface/cancellable-exec.js +0 -98
  312. package/dist/ai-service/app-interface/cancellable-exec.js.map +0 -1
  313. package/dist/ai-service/attachments/parse-data-url.d.ts +0 -5
  314. package/dist/ai-service/attachments/parse-data-url.d.ts.map +0 -1
  315. package/dist/ai-service/attachments/parse-data-url.js +0 -14
  316. package/dist/ai-service/attachments/parse-data-url.js.map +0 -1
  317. package/dist/ai-service/integrations/mention-safe-tag-name.d.ts +0 -12
  318. package/dist/ai-service/integrations/mention-safe-tag-name.d.ts.map +0 -1
  319. package/dist/ai-service/integrations/mention-safe-tag-name.js +0 -18
  320. package/dist/ai-service/integrations/mention-safe-tag-name.js.map +0 -1
  321. package/dist/ai-service/llm/context-v2/well-formed-text.d.ts +0 -24
  322. package/dist/ai-service/llm/context-v2/well-formed-text.d.ts.map +0 -1
  323. package/dist/ai-service/llm/context-v2/well-formed-text.js +0 -73
  324. package/dist/ai-service/llm/context-v2/well-formed-text.js.map +0 -1
  325. package/dist/ai-service/policy-gate-error.d.ts +0 -3
  326. package/dist/ai-service/policy-gate-error.d.ts.map +0 -1
  327. package/dist/ai-service/policy-gate-error.js +0 -33
  328. package/dist/ai-service/policy-gate-error.js.map +0 -1
  329. package/dist/migration-templates/app-fullstack/.gitignore +0 -50
  330. package/dist/parsing/parse-tsx-module.d.ts +0 -4
  331. package/dist/parsing/parse-tsx-module.d.ts.map +0 -1
  332. package/dist/parsing/parse-tsx-module.js +0 -13
  333. package/dist/parsing/parse-tsx-module.js.map +0 -1
  334. package/dist/router-parser-metrics.d.ts +0 -2
  335. package/dist/router-parser-metrics.d.ts.map +0 -1
  336. package/dist/router-parser-metrics.js +0 -13
  337. package/dist/router-parser-metrics.js.map +0 -1
@@ -32,7 +32,7 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
32
32
  if (target) Object.defineProperty(target, contextIn.name, descriptor);
33
33
  done = true;
34
34
  };
35
- import { EVICTION_PROTECTED_MESSAGE_TYPES, EXCLUDED_MESSAGE_TYPES, parsePersistedChatMessage, } from "@superblocksteam/library-shared/types";
35
+ import { EXCLUDED_MESSAGE_TYPES, TEXT_ATTACHMENT_MIME_TYPES, } from "@superblocksteam/library-shared/types";
36
36
  import { CHAT_PAYLOAD_PROMPT_ID_KEY, } from "@superblocksteam/shared";
37
37
  import { getErrorMeta } from "../../util/logger.js";
38
38
  import llmobs from "../llmobs/index.js";
@@ -41,7 +41,7 @@ import { recordChatGetMessages } from "./chat-session-store-metrics.js";
41
41
  import { getLastUserMessage } from "./extract-history.js";
42
42
  import { TranscriptBudget, } from "./transcript-budget.js";
43
43
  import { ensureTranscriptInstruments, recordTranscriptEviction, recordTranscriptServerLoad, registerTranscriptResidentBytesSource, } from "./transcript-metrics.js";
44
- import { sanitizeAiProviderResponse, sanitizeToolOutput } from "./utils.js";
44
+ import { inferTextAttachmentType, sanitizeAiProviderResponse, sanitizeToolOutput, } from "./utils.js";
45
45
  export function isAiChatMessage(item) {
46
46
  return "role" in item && "content" in item;
47
47
  }
@@ -68,15 +68,24 @@ const DEFAULT_MESSAGE_LIMIT = 3000;
68
68
  */
69
69
  const EVICTION_WARN_THROTTLE_MS = 30_000;
70
70
  /**
71
- * Chat item types that are never evicted from the resident transcript. The list
72
- * itself is EVICTION_PROTECTED_MESSAGE_TYPES in library-shared, which carries
73
- * the rationale; it lives there because the editor's pod-reconcile merge has to
74
- * exclude these types when it infers this pod's eviction frontier from a
75
- * payload. Derived into a Set here because isEvictableChatItem is on the
76
- * per-item path of every enforce() pass. Summaries are protected separately via
77
- * isAiChatSummary.
71
+ * Chat item types that are never evicted from the resident transcript.
72
+ * They are byte-tiny but semantically load-bearing as presence sentinels:
73
+ * commit markers feed getLatestCommitId (checkpoint restore), draft
74
+ * accept/reject feed determineSummaryOutcome, and aws_infra_demo gates the
75
+ * one-time demo card off "has this type ever appeared in history". Eviction
76
+ * is oldest-first and the demo sentinel is emitted on the first prompt, so
77
+ * without protection it is the first item dropped in exactly the long
78
+ * sessions this budget targets, which re-fires the demo card mid-session.
79
+ * Summaries are protected separately via isAiChatSummary.
78
80
  */
79
- const EVICTION_PROTECTED_TYPES = new Set(EVICTION_PROTECTED_MESSAGE_TYPES.filter((type) => type !== undefined));
81
+ const EVICTION_PROTECTED_TYPES = new Set([
82
+ "aws_infra_demo",
83
+ "commitRestored",
84
+ "commitRestoring",
85
+ "draftAccepted",
86
+ "draftCommitted",
87
+ "draftRejected",
88
+ ]);
80
89
  function isEvictableChatItem(item) {
81
90
  if (isAiChatSummary(item)) {
82
91
  return false;
@@ -147,16 +156,594 @@ let ChatSessionStore = (() => {
147
156
  // TODO(ai): consider replacing this with a queue-based approach
148
157
  this.inFlightLoadFromServer = Promise.resolve();
149
158
  }
150
- validateChatMessageV1(payload, fallbackTimestamp) {
151
- // Validation lives in library-shared so the editor's durable reader of the
152
- // same rows accepts and normalizes exactly what this transcript does.
153
- return parsePersistedChatMessage(payload, {
154
- fallbackTimestamp,
155
- onInvalid: (detail) => this.logger.warn(`[ai-service] ${detail}`),
156
- onError: (error) => this.logger.error("[ai-service] Failed to validate message payload", getErrorMeta(error)),
157
- });
159
+ /***
160
+ * Validates and sanitizes the attachments array
161
+ * @param attachments - The attachments array to validate
162
+ * @returns A tuple containing:
163
+ * - a boolean indicating if the attachments are valid
164
+ * - the sanitized attachments array
165
+ */
166
+ validateAttachments(attachments) {
167
+ if (!attachments) {
168
+ return [true, undefined];
169
+ }
170
+ if (typeof attachments !== "object" || !Array.isArray(attachments)) {
171
+ return [false, undefined];
172
+ }
173
+ const validAttachments = attachments
174
+ .map((attachment) => {
175
+ if (typeof attachment !== "object" || !("type" in attachment)) {
176
+ return undefined;
177
+ }
178
+ // Validate image attachment
179
+ if (attachment.type === "image") {
180
+ if (typeof attachment.image !== "string") {
181
+ return undefined;
182
+ }
183
+ return {
184
+ type: attachment.type,
185
+ image: attachment.image,
186
+ fileName: typeof attachment.fileName === "string"
187
+ ? attachment.fileName
188
+ : undefined,
189
+ };
190
+ }
191
+ // Validate PDF attachment
192
+ if (attachment.type === "pdf") {
193
+ if (typeof attachment.data !== "string") {
194
+ return undefined;
195
+ }
196
+ return {
197
+ type: attachment.type,
198
+ data: attachment.data,
199
+ fileName: typeof attachment.fileName === "string"
200
+ ? attachment.fileName
201
+ : undefined,
202
+ size: attachment.size,
203
+ };
204
+ }
205
+ // Validate archive attachment (zip, tgz, gz)
206
+ if (attachment.type === "archive") {
207
+ if (typeof attachment.data !== "string") {
208
+ return undefined;
209
+ }
210
+ return {
211
+ type: attachment.type,
212
+ data: attachment.data,
213
+ fileName: typeof attachment.fileName === "string"
214
+ ? attachment.fileName
215
+ : undefined,
216
+ size: attachment.size,
217
+ };
218
+ }
219
+ const normalizedTextAttachmentType = typeof attachment.content === "string"
220
+ ? inferTextAttachmentType({
221
+ attachmentType: attachment.type,
222
+ mimeType: attachment.mimeType,
223
+ fileName: typeof attachment.fileName === "string"
224
+ ? attachment.fileName
225
+ : "",
226
+ })
227
+ : null;
228
+ // Validate text attachments and normalize any text-like subtype to the
229
+ // stable server-side text attachment shape.
230
+ if (normalizedTextAttachmentType) {
231
+ if (typeof attachment.content !== "string") {
232
+ return undefined;
233
+ }
234
+ return {
235
+ type: normalizedTextAttachmentType,
236
+ content: attachment.content,
237
+ fileName: typeof attachment.fileName === "string"
238
+ ? attachment.fileName
239
+ : undefined,
240
+ mimeType: typeof attachment.mimeType === "string"
241
+ ? attachment.mimeType
242
+ : TEXT_ATTACHMENT_MIME_TYPES[normalizedTextAttachmentType],
243
+ size: attachment.size,
244
+ };
245
+ }
246
+ if (attachment.type === "uploaded") {
247
+ if (typeof attachment.url !== "string" ||
248
+ typeof attachment.mediaType !== "string") {
249
+ return undefined;
250
+ }
251
+ return {
252
+ type: "uploaded",
253
+ url: attachment.url,
254
+ signedUrl: typeof attachment.signedUrl === "string"
255
+ ? attachment.signedUrl
256
+ : undefined,
257
+ mediaType: attachment.mediaType,
258
+ fileName: typeof attachment.fileName === "string"
259
+ ? attachment.fileName
260
+ : undefined,
261
+ label: typeof attachment.label === "string"
262
+ ? attachment.label
263
+ : undefined,
264
+ insight: typeof attachment.insight === "string"
265
+ ? attachment.insight
266
+ : undefined,
267
+ storageKey: typeof attachment.storageKey === "string"
268
+ ? attachment.storageKey
269
+ : undefined,
270
+ signedUrlExpiresAt: typeof attachment.signedUrlExpiresAt === "string"
271
+ ? attachment.signedUrlExpiresAt
272
+ : undefined,
273
+ scopeType: attachment.scopeType === "app" || attachment.scopeType === "org"
274
+ ? attachment.scopeType
275
+ : undefined,
276
+ applicationId: typeof attachment.applicationId === "string"
277
+ ? attachment.applicationId
278
+ : undefined,
279
+ };
280
+ }
281
+ return undefined;
282
+ })
283
+ .filter(Boolean);
284
+ return [validAttachments.length === attachments.length, validAttachments];
285
+ }
286
+ validateChatMessageV1(payload) {
287
+ try {
288
+ if (!payload || typeof payload !== "object") {
289
+ return null;
290
+ }
291
+ const msg = payload;
292
+ // Validate required fields. Legacy roles "server" and "ai" (written by
293
+ // older server paths such as setApplicationHash for `draftCommitted`
294
+ // messages, and recognized as assistant-like in commitMessage.ts) are
295
+ // coerced to "assistant" so existing chat history keeps rendering.
296
+ if (typeof msg.role !== "string") {
297
+ this.logger.warn(`[ai-service] Invalid message role: ${msg.role}`);
298
+ return null;
299
+ }
300
+ const normalizedRole = msg.role === "server" || msg.role === "ai" ? "assistant" : msg.role;
301
+ if (!["user", "assistant", "system"].includes(normalizedRole)) {
302
+ this.logger.warn(`[ai-service] Invalid message role after normalize: ${msg.role}`);
303
+ return null;
304
+ }
305
+ msg.role = normalizedRole;
306
+ if (typeof msg.content !== "string") {
307
+ this.logger.warn(`[ai-service] Invalid message content (type=${typeof msg.content})`);
308
+ return null;
309
+ }
310
+ if (typeof msg.type !== "string") {
311
+ this.logger.warn(`[ai-service] Invalid message type: ${msg.type}`);
312
+ return null;
313
+ }
314
+ // Validate optional fields with defaults
315
+ const timestamp = typeof msg.timestamp === "number" ? msg.timestamp : Date.now();
316
+ const group = typeof msg.group === "string" ? msg.group : undefined;
317
+ const status = typeof msg.status === "string" ? msg.status : undefined;
318
+ const action = typeof msg.action === "string" ? msg.action : undefined;
319
+ const title = typeof msg.title === "string" ? msg.title : undefined;
320
+ const streaming = typeof msg.streaming === "boolean" ? msg.streaming : undefined;
321
+ const integrations = Array.isArray(msg.integrations)
322
+ ? msg.integrations
323
+ : undefined;
324
+ const entities = Array.isArray(msg.entities)
325
+ ? msg.entities
326
+ : undefined;
327
+ const [isAttachmentsValid, attachments] = this.validateAttachments(msg.attachments);
328
+ if (!isAttachmentsValid) {
329
+ this.logger.warn(`[ai-service] Invalid attachments`);
330
+ return null;
331
+ }
332
+ if (msg.type === "tool") {
333
+ return {
334
+ role: msg.role,
335
+ content: msg.content,
336
+ type: "tool",
337
+ id: typeof msg.id === "string" ? msg.id : undefined,
338
+ timestamp,
339
+ status: status,
340
+ action: action,
341
+ args: msg.args,
342
+ tool: msg.tool,
343
+ toolCallId: typeof msg.toolCallId === "string" ? msg.toolCallId : undefined,
344
+ title,
345
+ };
346
+ }
347
+ else if (msg.type === "tool-result") {
348
+ if (typeof msg.toolCallId !== "string" ||
349
+ typeof msg.toolName !== "string") {
350
+ this.logger.warn(`[ai-service] Invalid tool-result message: missing required fields`);
351
+ return null;
352
+ }
353
+ return {
354
+ role: msg.role,
355
+ content: msg.content || "",
356
+ type: "tool-result",
357
+ id: typeof msg.id === "string" ? msg.id : undefined,
358
+ timestamp,
359
+ status: status,
360
+ toolCallId: msg.toolCallId,
361
+ toolName: msg.toolName,
362
+ output: msg.output,
363
+ title,
364
+ };
365
+ }
366
+ else if (msg.type === "tool-error") {
367
+ if (typeof msg.toolCallId !== "string" ||
368
+ typeof msg.toolName !== "string") {
369
+ this.logger.warn(`[ai-service] Invalid tool-error message: missing required fields`);
370
+ return null;
371
+ }
372
+ return {
373
+ role: msg.role,
374
+ content: msg.content || "",
375
+ type: "tool-error",
376
+ id: typeof msg.id === "string" ? msg.id : undefined,
377
+ timestamp,
378
+ status: status,
379
+ toolCallId: msg.toolCallId,
380
+ toolName: msg.toolName,
381
+ error: msg.error instanceof Error
382
+ ? msg.error.message
383
+ : typeof msg.error === "string"
384
+ ? msg.error
385
+ : (JSON.stringify(msg.error, null, 2) ?? "Unknown error"),
386
+ title,
387
+ errorCode: msg.errorCode,
388
+ errorSummary: typeof msg.errorSummary === "string"
389
+ ? msg.errorSummary
390
+ : undefined,
391
+ };
392
+ }
393
+ else if (msg.group === "checklist") {
394
+ if (typeof msg.checklistData !== "object") {
395
+ this.logger.warn(`[ai-service] Invalid checklist data`);
396
+ return null;
397
+ }
398
+ return {
399
+ role: msg.role,
400
+ content: msg.content,
401
+ type: "tool",
402
+ id: typeof msg.id === "string" ? msg.id : undefined,
403
+ timestamp,
404
+ group,
405
+ status,
406
+ action,
407
+ checklistData: msg.checklistData,
408
+ title,
409
+ };
410
+ }
411
+ else if (msg.type === "multi_choice") {
412
+ if (!Array.isArray(msg.choices) || msg.choices.length === 0) {
413
+ this.logger.warn(`[ai-service] Invalid choices for multi_choice message`);
414
+ return null;
415
+ }
416
+ return {
417
+ role: msg.role,
418
+ content: msg.content,
419
+ type: "multi_choice",
420
+ id: typeof msg.id === "string" ? msg.id : undefined,
421
+ timestamp,
422
+ choices: msg.choices,
423
+ selectionType: typeof msg.selectionType === "string"
424
+ ? msg.selectionType
425
+ : "single",
426
+ title,
427
+ questionType: typeof msg.questionType === "string"
428
+ ? msg.questionType
429
+ : undefined,
430
+ subtitle: typeof msg.subtitle === "string" ? msg.subtitle : undefined,
431
+ details: typeof msg.details === "string" ? msg.details : undefined,
432
+ knowledgeCandidates: Array.isArray(msg.knowledgeCandidates)
433
+ ? msg.knowledgeCandidates
434
+ : undefined,
435
+ };
436
+ }
437
+ else if (msg.type === "remember_knowledge_draft") {
438
+ if (!Array.isArray(msg.candidates) || msg.candidates.length === 0) {
439
+ this.logger.warn(`[ai-service] Invalid candidates for remember_knowledge_draft message`);
440
+ return null;
441
+ }
442
+ return {
443
+ role: msg.role,
444
+ content: msg.content,
445
+ type: "remember_knowledge_draft",
446
+ id: typeof msg.id === "string" ? msg.id : undefined,
447
+ timestamp,
448
+ candidates: msg.candidates,
449
+ title,
450
+ };
451
+ }
452
+ else if (msg.type === "multi_choice_response") {
453
+ if (typeof msg.responseToMessageId !== "string") {
454
+ this.logger.warn(`[ai-service] Invalid responseToMessageId for multi_choice_response`);
455
+ return null;
456
+ }
457
+ if (!Array.isArray(msg.selectedChoiceIndices)) {
458
+ this.logger.warn(`[ai-service] Invalid selectedChoiceIndices for multi_choice_response`);
459
+ return null;
460
+ }
461
+ const response = {
462
+ role: msg.role,
463
+ content: msg.content,
464
+ type: "multi_choice_response",
465
+ id: typeof msg.id === "string" ? msg.id : undefined,
466
+ timestamp,
467
+ responseToMessageId: msg.responseToMessageId,
468
+ selectedChoiceIndices: msg.selectedChoiceIndices,
469
+ selectedScopes: Array.isArray(msg.selectedScopes)
470
+ ? msg.selectedScopes
471
+ : undefined,
472
+ savedFacts: Array.isArray(msg.savedFacts)
473
+ ? msg.savedFacts
474
+ : undefined,
475
+ title,
476
+ };
477
+ return response;
478
+ }
479
+ else if (msg.type === "remember_knowledge_draft_response") {
480
+ if (typeof msg.responseToMessageId !== "string") {
481
+ this.logger.warn(`[ai-service] Invalid responseToMessageId for remember_knowledge_draft_response`);
482
+ return null;
483
+ }
484
+ if (!Array.isArray(msg.selectedCandidateIndices)) {
485
+ this.logger.warn(`[ai-service] Invalid selectedCandidateIndices for remember_knowledge_draft_response`);
486
+ return null;
487
+ }
488
+ return {
489
+ role: msg.role,
490
+ content: msg.content,
491
+ type: "remember_knowledge_draft_response",
492
+ id: typeof msg.id === "string" ? msg.id : undefined,
493
+ timestamp,
494
+ responseToMessageId: msg.responseToMessageId,
495
+ selectedCandidateIndices: msg.selectedCandidateIndices,
496
+ selectedScopes: Array.isArray(msg.selectedScopes)
497
+ ? msg.selectedScopes
498
+ : undefined,
499
+ savedFacts: Array.isArray(msg.savedFacts)
500
+ ? msg.savedFacts
501
+ : undefined,
502
+ title,
503
+ };
504
+ }
505
+ else if (msg.type === "confirm") {
506
+ return {
507
+ role: msg.role,
508
+ content: msg.content,
509
+ type: "confirm",
510
+ id: typeof msg.id === "string" ? msg.id : undefined,
511
+ timestamp,
512
+ knowledgeEntry: typeof msg.knowledgeEntry === "object" &&
513
+ msg.knowledgeEntry !== null
514
+ ? msg.knowledgeEntry
515
+ : undefined,
516
+ title,
517
+ };
518
+ }
519
+ else if (msg.type === "searchable_dropdown") {
520
+ if (!Array.isArray(msg.options) || msg.options.length === 0) {
521
+ this.logger.warn(`[ai-service] Invalid options for searchable_dropdown message`);
522
+ return null;
523
+ }
524
+ return {
525
+ role: msg.role,
526
+ content: msg.content,
527
+ type: "searchable_dropdown",
528
+ id: typeof msg.id === "string" ? msg.id : undefined,
529
+ timestamp,
530
+ options: msg.options,
531
+ placeholder: typeof msg.placeholder === "string" ? msg.placeholder : undefined,
532
+ title,
533
+ };
534
+ }
535
+ else if (msg.type === "searchable_dropdown_response") {
536
+ if (typeof msg.responseToMessageId !== "string") {
537
+ this.logger.warn(`[ai-service] Invalid responseToMessageId for searchable_dropdown_response`);
538
+ return null;
539
+ }
540
+ if (typeof msg.selectedValue !== "string") {
541
+ this.logger.warn(`[ai-service] Invalid selectedValue for searchable_dropdown_response`);
542
+ return null;
543
+ }
544
+ return {
545
+ role: msg.role,
546
+ content: msg.content,
547
+ type: "searchable_dropdown_response",
548
+ id: typeof msg.id === "string" ? msg.id : undefined,
549
+ timestamp,
550
+ responseToMessageId: msg.responseToMessageId,
551
+ selectedValue: msg.selectedValue,
552
+ selectedLabel: typeof msg.selectedLabel === "string"
553
+ ? msg.selectedLabel
554
+ : msg.selectedValue,
555
+ title,
556
+ };
557
+ }
558
+ else if (msg.type === "confirm_response") {
559
+ if (typeof msg.responseToMessageId !== "string") {
560
+ this.logger.warn(`[ai-service] Invalid responseToMessageId for confirm_response`);
561
+ return null;
562
+ }
563
+ return {
564
+ role: msg.role,
565
+ content: msg.content,
566
+ type: "confirm_response",
567
+ id: typeof msg.id === "string" ? msg.id : undefined,
568
+ timestamp,
569
+ responseToMessageId: msg.responseToMessageId,
570
+ approved: Boolean(msg.approved),
571
+ selectedScopes: Array.isArray(msg.selectedScopes)
572
+ ? msg.selectedScopes
573
+ : undefined,
574
+ savedFacts: Array.isArray(msg.savedFacts)
575
+ ? msg.savedFacts
576
+ : undefined,
577
+ title,
578
+ };
579
+ }
580
+ else if (msg.type === "plan_response") {
581
+ if (typeof msg.responseToMessageId !== "string") {
582
+ this.logger.warn(`[ai-service] Invalid responseToMessageId for plan_response`);
583
+ return null;
584
+ }
585
+ return {
586
+ role: msg.role,
587
+ content: msg.content,
588
+ type: "plan_response",
589
+ id: typeof msg.id === "string" ? msg.id : undefined,
590
+ timestamp,
591
+ responseToMessageId: msg.responseToMessageId,
592
+ title,
593
+ approved: typeof msg.approved === "boolean" ? msg.approved : undefined,
594
+ enableTesting: typeof msg.enableTesting === "boolean"
595
+ ? msg.enableTesting
596
+ : undefined,
597
+ };
598
+ }
599
+ else if (msg.type === "test_run_start") {
600
+ if (typeof msg.testRunId !== "string") {
601
+ this.logger.warn(`[ai-service] Invalid test_run_start message: missing testRunId`);
602
+ return null;
603
+ }
604
+ return {
605
+ role: msg.role,
606
+ content: msg.content,
607
+ type: "test_run_start",
608
+ id: typeof msg.id === "string" ? msg.id : undefined,
609
+ timestamp,
610
+ testRunId: msg.testRunId,
611
+ header: typeof msg.header === "string" ? msg.header : "End-to-end Testing",
612
+ testCases: Array.isArray(msg.testCases) ? msg.testCases : undefined,
613
+ };
614
+ }
615
+ else if (msg.type === "test_case_update") {
616
+ if (typeof msg.testRunId !== "string") {
617
+ this.logger.warn(`[ai-service] Invalid test_case_update message: missing testRunId`);
618
+ return null;
619
+ }
620
+ if (typeof msg.testCaseId !== "string") {
621
+ this.logger.warn(`[ai-service] Invalid test_case_update message: missing testCaseId`);
622
+ return null;
623
+ }
624
+ return {
625
+ role: msg.role,
626
+ content: msg.content,
627
+ type: "test_case_update",
628
+ id: typeof msg.id === "string" ? msg.id : undefined,
629
+ timestamp,
630
+ testRunId: msg.testRunId,
631
+ testCaseId: msg.testCaseId,
632
+ testCaseStatus: msg.testCaseStatus,
633
+ };
634
+ }
635
+ else if (msg.type === "test_run_end") {
636
+ if (typeof msg.testRunId !== "string") {
637
+ this.logger.warn(`[ai-service] Invalid test_run_end message: missing testRunId`);
638
+ return null;
639
+ }
640
+ return {
641
+ role: msg.role,
642
+ content: msg.content,
643
+ type: "test_run_end",
644
+ id: typeof msg.id === "string" ? msg.id : undefined,
645
+ timestamp,
646
+ testRunId: msg.testRunId,
647
+ testStatus: typeof msg.testStatus === "string"
648
+ ? msg.testStatus
649
+ : "completed",
650
+ summary: typeof msg.summary === "string" ? msg.summary : undefined,
651
+ };
652
+ }
653
+ else if (msg.type === "retry_notification") {
654
+ return {
655
+ role: msg.role,
656
+ content: msg.content,
657
+ type: "retry_notification",
658
+ id: typeof msg.id === "string" ? msg.id : undefined,
659
+ timestamp,
660
+ retryType: msg.retryType,
661
+ attempt: typeof msg.attempt === "number" ? msg.attempt : undefined,
662
+ delaySeconds: typeof msg.delaySeconds === "number" ? msg.delaySeconds : undefined,
663
+ fromProvider: typeof msg.fromProvider === "string" ? msg.fromProvider : undefined,
664
+ toProvider: typeof msg.toProvider === "string" ? msg.toProvider : undefined,
665
+ reason: typeof msg.reason === "string" ? msg.reason : undefined,
666
+ };
667
+ }
668
+ else if (msg.type === "knowledge") {
669
+ return {
670
+ role: msg.role,
671
+ content: msg.content,
672
+ type: "knowledge",
673
+ id: typeof msg.id === "string" ? msg.id : undefined,
674
+ timestamp,
675
+ status,
676
+ facts: msg.facts,
677
+ };
678
+ }
679
+ else if (msg.type === "app_knowledge_saved") {
680
+ return {
681
+ role: msg.role,
682
+ content: msg.content,
683
+ type: "app_knowledge_saved",
684
+ id: typeof msg.id === "string" ? msg.id : undefined,
685
+ timestamp,
686
+ knowledgeCount: typeof msg.knowledgeCount === "number" ? msg.knowledgeCount : 0,
687
+ responseToMessageId: typeof msg.responseToMessageId === "string"
688
+ ? msg.responseToMessageId
689
+ : undefined,
690
+ savedFacts: Array.isArray(msg.savedFacts)
691
+ ? msg.savedFacts
692
+ : undefined,
693
+ };
694
+ }
695
+ else if (msg.type === "next_steps") {
696
+ return {
697
+ role: msg.role,
698
+ content: msg.content,
699
+ type: "next_steps",
700
+ id: typeof msg.id === "string" ? msg.id : undefined,
701
+ timestamp,
702
+ nextSteps: Array.isArray(msg.nextSteps) ? msg.nextSteps : [],
703
+ };
704
+ }
705
+ const baseMessage = {
706
+ role: msg.role,
707
+ content: msg.content,
708
+ type: msg.type,
709
+ id: typeof msg.id === "string" ? msg.id : undefined,
710
+ timestamp,
711
+ group,
712
+ status: status,
713
+ action: action,
714
+ attachments,
715
+ title,
716
+ };
717
+ if (msg.type === "plan") {
718
+ if (streaming !== undefined) {
719
+ baseMessage.streaming = streaming;
720
+ }
721
+ if (integrations) {
722
+ baseMessage.integrations = integrations;
723
+ }
724
+ if (entities) {
725
+ baseMessage.entities = entities;
726
+ }
727
+ if (msg.includesFreshDatabase === true) {
728
+ baseMessage.includesFreshDatabase = true;
729
+ }
730
+ }
731
+ // Preserve commitId for commitRestored, commitRestoring, and draftCommitted messages
732
+ if ((msg.type === "commitRestored" ||
733
+ msg.type === "commitRestoring" ||
734
+ msg.type === "draftCommitted") &&
735
+ typeof msg.commitId === "string") {
736
+ baseMessage.commitId =
737
+ msg.commitId;
738
+ }
739
+ return baseMessage;
740
+ }
741
+ catch (error) {
742
+ this.logger.error("[ai-service] Failed to validate message payload", getErrorMeta(error));
743
+ return null;
744
+ }
158
745
  }
159
- validateChatSummaryV1(payload, fallbackTimestamp) {
746
+ validateChatSummaryV1(payload) {
160
747
  try {
161
748
  if (!payload || typeof payload !== "object") {
162
749
  return null;
@@ -192,9 +779,7 @@ let ChatSessionStore = (() => {
192
779
  return null;
193
780
  }
194
781
  // Validate optional fields with defaults
195
- const timestamp = Number.isFinite(summary.timestamp)
196
- ? summary.timestamp
197
- : fallbackTimestamp;
782
+ const timestamp = typeof summary.timestamp === "number" ? summary.timestamp : Date.now();
198
783
  return {
199
784
  summary: summary.summary,
200
785
  relevantFilePaths: summary.relevantFilePaths,
@@ -209,14 +794,14 @@ let ChatSessionStore = (() => {
209
794
  return null;
210
795
  }
211
796
  }
212
- validateChatItemV1(payload, fallbackTimestamp) {
797
+ validateChatItemV1(payload) {
213
798
  // First try to validate as a message
214
- const messageResult = this.validateChatMessageV1(payload, fallbackTimestamp);
799
+ const messageResult = this.validateChatMessageV1(payload);
215
800
  if (messageResult) {
216
801
  return messageResult;
217
802
  }
218
803
  // If not a valid message, try to validate as a summary
219
- const summaryResult = this.validateChatSummaryV1(payload, fallbackTimestamp);
804
+ const summaryResult = this.validateChatSummaryV1(payload);
220
805
  if (summaryResult) {
221
806
  return summaryResult;
222
807
  }
@@ -270,15 +855,7 @@ let ChatSessionStore = (() => {
270
855
  });
271
856
  const rawMessages = data?.messages ?? [];
272
857
  const mapped = rawMessages.map((msg) => {
273
- // The row's own created column, not Date.now(). This value is what
274
- // the sort below orders on when a payload carries no timestamp, so
275
- // inventing one here filed old rows at the end of history on every
276
- // load. It is also half of the composite key the editor dedupes
277
- // id-less rows on, which the durable reader derives the same way.
278
- const persistedAt = msg.created
279
- ? Date.parse(msg.created)
280
- : Date.now();
281
- const chatItem = this.validateChatItemV1(msg.chatPayload, Number.isFinite(persistedAt) ? persistedAt : Date.now());
858
+ const chatItem = this.validateChatItemV1(msg.chatPayload);
282
859
  if (chatItem && isAiChatMessage(chatItem)) {
283
860
  chatItem.authorEmail = msg.authorEmail;
284
861
  chatItem.authorName = msg.authorName;