@superblocksteam/vite-plugin-file-sync 2.0.42 → 2.0.43-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (456) hide show
  1. package/dist/ai-service/agent/prompts/build-base-system-prompt.d.ts +2 -1
  2. package/dist/ai-service/agent/prompts/build-base-system-prompt.d.ts.map +1 -1
  3. package/dist/ai-service/agent/prompts/build-base-system-prompt.js +31 -2
  4. package/dist/ai-service/agent/prompts/build-base-system-prompt.js.map +1 -1
  5. package/dist/ai-service/agent/subagents/apis/example-selector.d.ts +24 -0
  6. package/dist/ai-service/agent/subagents/apis/example-selector.d.ts.map +1 -0
  7. package/dist/ai-service/agent/subagents/apis/example-selector.js +104 -0
  8. package/dist/ai-service/agent/subagents/apis/example-selector.js.map +1 -0
  9. package/dist/ai-service/agent/subagents/apis/examples.d.ts +55 -0
  10. package/dist/ai-service/agent/subagents/apis/examples.d.ts.map +1 -0
  11. package/dist/ai-service/agent/subagents/apis/examples.js +1229 -0
  12. package/dist/ai-service/agent/subagents/apis/examples.js.map +1 -0
  13. package/dist/ai-service/agent/subagents/apis/generate-api-source.d.ts +83 -0
  14. package/dist/ai-service/agent/subagents/apis/generate-api-source.d.ts.map +1 -0
  15. package/dist/ai-service/agent/{apis.js → subagents/apis/generate-api-source.js} +141 -98
  16. package/dist/ai-service/agent/subagents/apis/generate-api-source.js.map +1 -0
  17. package/dist/ai-service/agent/subagents/apis/prompt-builder.d.ts +39 -0
  18. package/dist/ai-service/agent/subagents/apis/prompt-builder.d.ts.map +1 -0
  19. package/dist/ai-service/agent/subagents/apis/prompt-builder.js +115 -0
  20. package/dist/ai-service/agent/subagents/apis/prompt-builder.js.map +1 -0
  21. package/dist/ai-service/agent/subagents/apis/static-analysis.d.ts +2 -0
  22. package/dist/ai-service/agent/subagents/apis/static-analysis.d.ts.map +1 -0
  23. package/dist/ai-service/agent/subagents/apis/static-analysis.js +766 -0
  24. package/dist/ai-service/agent/subagents/apis/static-analysis.js.map +1 -0
  25. package/dist/ai-service/agent/subagents/apis/system-prompt.d.ts +3 -0
  26. package/dist/ai-service/agent/subagents/apis/system-prompt.d.ts.map +1 -0
  27. package/dist/ai-service/agent/{apis-system-prompt.js → subagents/apis/system-prompt.js} +127 -34
  28. package/dist/ai-service/agent/{apis-system-prompt.js.map → subagents/apis/system-prompt.js.map} +1 -1
  29. package/dist/ai-service/agent/tool-message-utils.d.ts +6 -16
  30. package/dist/ai-service/agent/tool-message-utils.d.ts.map +1 -1
  31. package/dist/ai-service/agent/tool-message-utils.js +75 -204
  32. package/dist/ai-service/agent/tool-message-utils.js.map +1 -1
  33. package/dist/ai-service/agent/tools/build-add-event.d.ts +2 -4
  34. package/dist/ai-service/agent/tools/build-add-event.d.ts.map +1 -1
  35. package/dist/ai-service/agent/tools/build-add-event.js +9 -8
  36. package/dist/ai-service/agent/tools/build-add-event.js.map +1 -1
  37. package/dist/ai-service/agent/tools/build-add-state-var.d.ts +2 -4
  38. package/dist/ai-service/agent/tools/build-add-state-var.d.ts.map +1 -1
  39. package/dist/ai-service/agent/tools/build-add-state-var.js +6 -5
  40. package/dist/ai-service/agent/tools/build-add-state-var.js.map +1 -1
  41. package/dist/ai-service/agent/tools/build-add-timer.d.ts +2 -4
  42. package/dist/ai-service/agent/tools/build-add-timer.d.ts.map +1 -1
  43. package/dist/ai-service/agent/tools/build-add-timer.js +7 -6
  44. package/dist/ai-service/agent/tools/build-add-timer.js.map +1 -1
  45. package/dist/ai-service/agent/tools/build-create-page.d.ts +2 -3
  46. package/dist/ai-service/agent/tools/build-create-page.d.ts.map +1 -1
  47. package/dist/ai-service/agent/tools/build-create-page.js +11 -10
  48. package/dist/ai-service/agent/tools/build-create-page.js.map +1 -1
  49. package/dist/ai-service/agent/tools/build-debug.d.ts +1 -3
  50. package/dist/ai-service/agent/tools/build-debug.d.ts.map +1 -1
  51. package/dist/ai-service/agent/tools/build-debug.js +7 -5
  52. package/dist/ai-service/agent/tools/build-debug.js.map +1 -1
  53. package/dist/ai-service/agent/tools/build-edit-file.d.ts +2 -4
  54. package/dist/ai-service/agent/tools/build-edit-file.d.ts.map +1 -1
  55. package/dist/ai-service/agent/tools/build-edit-file.js +10 -7
  56. package/dist/ai-service/agent/tools/build-edit-file.js.map +1 -1
  57. package/dist/ai-service/agent/tools/build-finalize.d.ts +2 -4
  58. package/dist/ai-service/agent/tools/build-finalize.d.ts.map +1 -1
  59. package/dist/ai-service/agent/tools/build-finalize.js +7 -6
  60. package/dist/ai-service/agent/tools/build-finalize.js.map +1 -1
  61. package/dist/ai-service/agent/tools/build-install-packages.d.ts +2 -4
  62. package/dist/ai-service/agent/tools/build-install-packages.d.ts.map +1 -1
  63. package/dist/ai-service/agent/tools/build-install-packages.js +7 -6
  64. package/dist/ai-service/agent/tools/build-install-packages.js.map +1 -1
  65. package/dist/ai-service/agent/tools/build-list-available-components.d.ts +3 -8
  66. package/dist/ai-service/agent/tools/build-list-available-components.d.ts.map +1 -1
  67. package/dist/ai-service/agent/tools/build-list-available-components.js +30 -9
  68. package/dist/ai-service/agent/tools/build-list-available-components.js.map +1 -1
  69. package/dist/ai-service/agent/tools/build-list-files.d.ts +2 -3
  70. package/dist/ai-service/agent/tools/build-list-files.d.ts.map +1 -1
  71. package/dist/ai-service/agent/tools/build-list-files.js +10 -8
  72. package/dist/ai-service/agent/tools/build-list-files.js.map +1 -1
  73. package/dist/ai-service/agent/tools/build-manage-checklist.d.ts +3 -3
  74. package/dist/ai-service/agent/tools/build-manage-checklist.d.ts.map +1 -1
  75. package/dist/ai-service/agent/tools/build-manage-checklist.js +9 -8
  76. package/dist/ai-service/agent/tools/build-manage-checklist.js.map +1 -1
  77. package/dist/ai-service/agent/tools/build-multi-edit-file.d.ts +2 -4
  78. package/dist/ai-service/agent/tools/build-multi-edit-file.d.ts.map +1 -1
  79. package/dist/ai-service/agent/tools/build-multi-edit-file.js +9 -6
  80. package/dist/ai-service/agent/tools/build-multi-edit-file.js.map +1 -1
  81. package/dist/ai-service/agent/tools/build-read-files.d.ts +2 -4
  82. package/dist/ai-service/agent/tools/build-read-files.d.ts.map +1 -1
  83. package/dist/ai-service/agent/tools/build-read-files.js +10 -8
  84. package/dist/ai-service/agent/tools/build-read-files.js.map +1 -1
  85. package/dist/ai-service/agent/tools/build-register-component-name.d.ts +2 -4
  86. package/dist/ai-service/agent/tools/build-register-component-name.d.ts.map +1 -1
  87. package/dist/ai-service/agent/tools/build-register-component-name.js +9 -8
  88. package/dist/ai-service/agent/tools/build-register-component-name.js.map +1 -1
  89. package/dist/ai-service/agent/tools/build-rename-page.d.ts +2 -3
  90. package/dist/ai-service/agent/tools/build-rename-page.d.ts.map +1 -1
  91. package/dist/ai-service/agent/tools/build-rename-page.js +6 -5
  92. package/dist/ai-service/agent/tools/build-rename-page.js.map +1 -1
  93. package/dist/ai-service/agent/tools/build-set-api-triggers.d.ts +2 -4
  94. package/dist/ai-service/agent/tools/build-set-api-triggers.d.ts.map +1 -1
  95. package/dist/ai-service/agent/tools/build-set-api-triggers.js +6 -5
  96. package/dist/ai-service/agent/tools/build-set-api-triggers.js.map +1 -1
  97. package/dist/ai-service/agent/tools/build-update-state-var.d.ts +2 -3
  98. package/dist/ai-service/agent/tools/build-update-state-var.d.ts.map +1 -1
  99. package/dist/ai-service/agent/tools/build-update-state-var.js +6 -5
  100. package/dist/ai-service/agent/tools/build-update-state-var.js.map +1 -1
  101. package/dist/ai-service/agent/tools/build-validate-icons.d.ts +2 -3
  102. package/dist/ai-service/agent/tools/build-validate-icons.d.ts.map +1 -1
  103. package/dist/ai-service/agent/tools/build-validate-icons.js +8 -6
  104. package/dist/ai-service/agent/tools/build-validate-icons.js.map +1 -1
  105. package/dist/ai-service/agent/tools/build-write-file.d.ts +2 -4
  106. package/dist/ai-service/agent/tools/build-write-file.d.ts.map +1 -1
  107. package/dist/ai-service/agent/tools/build-write-file.js +6 -5
  108. package/dist/ai-service/agent/tools/build-write-file.js.map +1 -1
  109. package/dist/ai-service/agent/tools/debug-cache.d.ts.map +1 -1
  110. package/dist/ai-service/agent/tools/debug-cache.js +4 -1
  111. package/dist/ai-service/agent/tools/debug-cache.js.map +1 -1
  112. package/dist/ai-service/agent/tools/index.d.ts +23 -20
  113. package/dist/ai-service/agent/tools/index.d.ts.map +1 -1
  114. package/dist/ai-service/agent/tools/index.js +23 -20
  115. package/dist/ai-service/agent/tools/index.js.map +1 -1
  116. package/dist/ai-service/agent/tools/integrations/execute-request.d.ts +25 -0
  117. package/dist/ai-service/agent/tools/integrations/execute-request.d.ts.map +1 -0
  118. package/dist/ai-service/agent/tools/integrations/execute-request.js +213 -0
  119. package/dist/ai-service/agent/tools/integrations/execute-request.js.map +1 -0
  120. package/dist/ai-service/agent/tools/integrations/index.d.ts +4 -0
  121. package/dist/ai-service/agent/tools/integrations/index.d.ts.map +1 -0
  122. package/dist/ai-service/agent/tools/integrations/index.js +4 -0
  123. package/dist/ai-service/agent/tools/integrations/index.js.map +1 -0
  124. package/dist/ai-service/agent/tools/integrations/internal.d.ts +3 -0
  125. package/dist/ai-service/agent/tools/integrations/internal.d.ts.map +1 -0
  126. package/dist/ai-service/agent/tools/integrations/internal.js +11 -0
  127. package/dist/ai-service/agent/tools/integrations/internal.js.map +1 -0
  128. package/dist/ai-service/agent/tools/integrations/metadata.d.ts +10 -0
  129. package/dist/ai-service/agent/tools/integrations/metadata.d.ts.map +1 -0
  130. package/dist/ai-service/agent/tools/integrations/metadata.js +80 -0
  131. package/dist/ai-service/agent/tools/integrations/metadata.js.map +1 -0
  132. package/dist/ai-service/agent/tools/integrations/run-code.d.ts +5 -0
  133. package/dist/ai-service/agent/tools/integrations/run-code.d.ts.map +1 -0
  134. package/dist/ai-service/agent/tools/integrations/run-code.js +32 -0
  135. package/dist/ai-service/agent/tools/integrations/run-code.js.map +1 -0
  136. package/dist/ai-service/agent/tools/study-current-app-state.d.ts +2 -4
  137. package/dist/ai-service/agent/tools/study-current-app-state.d.ts.map +1 -1
  138. package/dist/ai-service/agent/tools/study-current-app-state.js +10 -8
  139. package/dist/ai-service/agent/tools/study-current-app-state.js.map +1 -1
  140. package/dist/ai-service/agent/tools.d.ts +3 -280
  141. package/dist/ai-service/agent/tools.d.ts.map +1 -1
  142. package/dist/ai-service/agent/tools.js +68 -55
  143. package/dist/ai-service/agent/tools.js.map +1 -1
  144. package/dist/ai-service/agent/tools2/access-control.d.ts +119 -0
  145. package/dist/ai-service/agent/tools2/access-control.d.ts.map +1 -0
  146. package/dist/ai-service/agent/tools2/access-control.js +216 -0
  147. package/dist/ai-service/agent/tools2/access-control.js.map +1 -0
  148. package/dist/ai-service/agent/tools2/example.d.ts +13 -0
  149. package/dist/ai-service/agent/tools2/example.d.ts.map +1 -0
  150. package/dist/ai-service/agent/tools2/example.js +143 -0
  151. package/dist/ai-service/agent/tools2/example.js.map +1 -0
  152. package/dist/ai-service/agent/tools2/index.d.ts +16 -0
  153. package/dist/ai-service/agent/tools2/index.d.ts.map +1 -0
  154. package/dist/ai-service/agent/tools2/index.js +18 -0
  155. package/dist/ai-service/agent/tools2/index.js.map +1 -0
  156. package/dist/ai-service/agent/tools2/registry.d.ts +167 -0
  157. package/dist/ai-service/agent/tools2/registry.d.ts.map +1 -0
  158. package/dist/ai-service/agent/tools2/registry.js +305 -0
  159. package/dist/ai-service/agent/tools2/registry.js.map +1 -0
  160. package/dist/ai-service/agent/tools2/tools/ask-multi-choice.d.ts +12 -0
  161. package/dist/ai-service/agent/tools2/tools/ask-multi-choice.d.ts.map +1 -0
  162. package/dist/ai-service/agent/tools2/tools/ask-multi-choice.js +73 -0
  163. package/dist/ai-service/agent/tools2/tools/ask-multi-choice.js.map +1 -0
  164. package/dist/ai-service/agent/tools2/tools/bash.d.ts +34 -0
  165. package/dist/ai-service/agent/tools2/tools/bash.d.ts.map +1 -0
  166. package/dist/ai-service/agent/tools2/tools/bash.js +76 -0
  167. package/dist/ai-service/agent/tools2/tools/bash.js.map +1 -0
  168. package/dist/ai-service/agent/tools2/tools/edit.d.ts +14 -0
  169. package/dist/ai-service/agent/tools2/tools/edit.d.ts.map +1 -0
  170. package/dist/ai-service/agent/tools2/tools/edit.js +60 -0
  171. package/dist/ai-service/agent/tools2/tools/edit.js.map +1 -0
  172. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.d.ts +10 -0
  173. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.d.ts.map +1 -0
  174. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js +66 -0
  175. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js.map +1 -0
  176. package/dist/ai-service/agent/tools2/tools/glob.d.ts +11 -0
  177. package/dist/ai-service/agent/tools2/tools/glob.d.ts.map +1 -0
  178. package/dist/ai-service/agent/tools2/tools/glob.js +44 -0
  179. package/dist/ai-service/agent/tools2/tools/glob.js.map +1 -0
  180. package/dist/ai-service/agent/tools2/tools/grep.d.ts +21 -0
  181. package/dist/ai-service/agent/tools2/tools/grep.d.ts.map +1 -0
  182. package/dist/ai-service/agent/tools2/tools/grep.js +100 -0
  183. package/dist/ai-service/agent/tools2/tools/grep.js.map +1 -0
  184. package/dist/ai-service/agent/tools2/tools/index.d.ts +13 -0
  185. package/dist/ai-service/agent/tools2/tools/index.d.ts.map +1 -0
  186. package/dist/ai-service/agent/tools2/tools/index.js +13 -0
  187. package/dist/ai-service/agent/tools2/tools/index.js.map +1 -0
  188. package/dist/ai-service/agent/tools2/tools/read.d.ts +9 -0
  189. package/dist/ai-service/agent/tools2/tools/read.d.ts.map +1 -0
  190. package/dist/ai-service/agent/tools2/tools/read.js +43 -0
  191. package/dist/ai-service/agent/tools2/tools/read.js.map +1 -0
  192. package/dist/ai-service/agent/tools2/tools/write.d.ts +11 -0
  193. package/dist/ai-service/agent/tools2/tools/write.d.ts.map +1 -0
  194. package/dist/ai-service/agent/tools2/tools/write.js +28 -0
  195. package/dist/ai-service/agent/tools2/tools/write.js.map +1 -0
  196. package/dist/ai-service/agent/tools2/types.d.ts +148 -0
  197. package/dist/ai-service/agent/tools2/types.d.ts.map +1 -0
  198. package/dist/ai-service/agent/tools2/types.js +55 -0
  199. package/dist/ai-service/agent/tools2/types.js.map +1 -0
  200. package/dist/ai-service/agent/utils.d.ts +2 -3
  201. package/dist/ai-service/agent/utils.d.ts.map +1 -1
  202. package/dist/ai-service/agent/utils.js +14 -13
  203. package/dist/ai-service/agent/utils.js.map +1 -1
  204. package/dist/ai-service/chat/chat-session-store.d.ts +5 -0
  205. package/dist/ai-service/chat/chat-session-store.d.ts.map +1 -1
  206. package/dist/ai-service/chat/chat-session-store.js +484 -345
  207. package/dist/ai-service/chat/chat-session-store.js.map +1 -1
  208. package/dist/ai-service/chat/extract-history.d.ts +1 -0
  209. package/dist/ai-service/chat/extract-history.d.ts.map +1 -1
  210. package/dist/ai-service/chat/extract-history.js +12 -1
  211. package/dist/ai-service/chat/extract-history.js.map +1 -1
  212. package/dist/ai-service/const.d.ts +2 -1
  213. package/dist/ai-service/const.d.ts.map +1 -1
  214. package/dist/ai-service/const.js +7 -1
  215. package/dist/ai-service/const.js.map +1 -1
  216. package/dist/ai-service/index.d.ts +9 -8
  217. package/dist/ai-service/index.d.ts.map +1 -1
  218. package/dist/ai-service/index.js +7 -0
  219. package/dist/ai-service/index.js.map +1 -1
  220. package/dist/ai-service/integrations/metadata/database.d.ts.map +1 -1
  221. package/dist/ai-service/integrations/metadata/database.js +3 -29
  222. package/dist/ai-service/integrations/metadata/database.js.map +1 -1
  223. package/dist/ai-service/integrations/metadata/databricks.d.ts +25 -0
  224. package/dist/ai-service/integrations/metadata/databricks.d.ts.map +1 -0
  225. package/dist/ai-service/integrations/metadata/databricks.js +174 -0
  226. package/dist/ai-service/integrations/metadata/databricks.js.map +1 -0
  227. package/dist/ai-service/integrations/store.d.ts +34 -4
  228. package/dist/ai-service/integrations/store.d.ts.map +1 -1
  229. package/dist/ai-service/integrations/store.js +125 -5
  230. package/dist/ai-service/integrations/store.js.map +1 -1
  231. package/dist/ai-service/llm/context/caching/constants.d.ts +27 -0
  232. package/dist/ai-service/llm/context/caching/constants.d.ts.map +1 -0
  233. package/dist/ai-service/llm/context/caching/constants.js +20 -0
  234. package/dist/ai-service/llm/context/caching/constants.js.map +1 -0
  235. package/dist/ai-service/llm/context/caching/factory.d.ts +12 -0
  236. package/dist/ai-service/llm/context/caching/factory.d.ts.map +1 -0
  237. package/dist/ai-service/llm/context/caching/factory.js +28 -0
  238. package/dist/ai-service/llm/context/caching/factory.js.map +1 -0
  239. package/dist/ai-service/llm/context/caching/index.d.ts +10 -0
  240. package/dist/ai-service/llm/context/caching/index.d.ts.map +1 -0
  241. package/dist/ai-service/llm/context/caching/index.js +9 -0
  242. package/dist/ai-service/llm/context/caching/index.js.map +1 -0
  243. package/dist/ai-service/llm/context/caching/quantized-strategy.d.ts +22 -0
  244. package/dist/ai-service/llm/context/caching/quantized-strategy.d.ts.map +1 -0
  245. package/dist/ai-service/llm/context/caching/quantized-strategy.js +48 -0
  246. package/dist/ai-service/llm/context/caching/quantized-strategy.js.map +1 -0
  247. package/dist/ai-service/llm/context/caching/strategy.d.ts +20 -0
  248. package/dist/ai-service/llm/context/caching/strategy.d.ts.map +1 -0
  249. package/dist/ai-service/llm/context/caching/strategy.js +5 -0
  250. package/dist/ai-service/llm/context/caching/strategy.js.map +1 -0
  251. package/dist/ai-service/llm/context/caching/types.d.ts +34 -0
  252. package/dist/ai-service/llm/context/caching/types.d.ts.map +1 -0
  253. package/dist/ai-service/llm/context/caching/types.js +8 -0
  254. package/dist/ai-service/llm/context/caching/types.js.map +1 -0
  255. package/dist/ai-service/llm/context/config.d.ts +51 -0
  256. package/dist/ai-service/llm/context/config.d.ts.map +1 -0
  257. package/dist/ai-service/llm/context/config.js +58 -0
  258. package/dist/ai-service/llm/context/config.js.map +1 -0
  259. package/dist/ai-service/llm/context/constants.d.ts +106 -0
  260. package/dist/ai-service/llm/context/constants.d.ts.map +1 -0
  261. package/dist/ai-service/llm/context/constants.js +106 -0
  262. package/dist/ai-service/llm/context/constants.js.map +1 -0
  263. package/dist/ai-service/llm/context/context.d.ts +207 -0
  264. package/dist/ai-service/llm/context/context.d.ts.map +1 -0
  265. package/dist/ai-service/llm/context/context.js +742 -0
  266. package/dist/ai-service/llm/context/context.js.map +1 -0
  267. package/dist/ai-service/llm/context/errors.d.ts +45 -0
  268. package/dist/ai-service/llm/context/errors.d.ts.map +1 -0
  269. package/dist/ai-service/llm/context/errors.js +56 -0
  270. package/dist/ai-service/llm/context/errors.js.map +1 -0
  271. package/dist/ai-service/llm/context/index.d.ts +13 -0
  272. package/dist/ai-service/llm/context/index.d.ts.map +1 -0
  273. package/dist/ai-service/llm/context/index.js +17 -0
  274. package/dist/ai-service/llm/context/index.js.map +1 -0
  275. package/dist/ai-service/llm/context/internal-types.d.ts +52 -0
  276. package/dist/ai-service/llm/context/internal-types.d.ts.map +1 -0
  277. package/dist/ai-service/llm/context/internal-types.js +28 -0
  278. package/dist/ai-service/llm/context/internal-types.js.map +1 -0
  279. package/dist/ai-service/llm/context/levels/index.d.ts +12 -0
  280. package/dist/ai-service/llm/context/levels/index.d.ts.map +1 -0
  281. package/dist/ai-service/llm/context/levels/index.js +12 -0
  282. package/dist/ai-service/llm/context/levels/index.js.map +1 -0
  283. package/dist/ai-service/llm/context/levels/l1.d.ts +83 -0
  284. package/dist/ai-service/llm/context/levels/l1.d.ts.map +1 -0
  285. package/dist/ai-service/llm/context/levels/l1.js +143 -0
  286. package/dist/ai-service/llm/context/levels/l1.js.map +1 -0
  287. package/dist/ai-service/llm/context/levels/l2.d.ts +60 -0
  288. package/dist/ai-service/llm/context/levels/l2.d.ts.map +1 -0
  289. package/dist/ai-service/llm/context/levels/l2.js +96 -0
  290. package/dist/ai-service/llm/context/levels/l2.js.map +1 -0
  291. package/dist/ai-service/llm/context/levels/l3.d.ts +46 -0
  292. package/dist/ai-service/llm/context/levels/l3.d.ts.map +1 -0
  293. package/dist/ai-service/llm/context/levels/l3.js +70 -0
  294. package/dist/ai-service/llm/context/levels/l3.js.map +1 -0
  295. package/dist/ai-service/llm/context/logger.d.ts +17 -0
  296. package/dist/ai-service/llm/context/logger.d.ts.map +1 -0
  297. package/dist/ai-service/llm/context/logger.js +26 -0
  298. package/dist/ai-service/llm/context/logger.js.map +1 -0
  299. package/dist/ai-service/llm/context/manager.d.ts +79 -0
  300. package/dist/ai-service/llm/context/manager.d.ts.map +1 -0
  301. package/dist/ai-service/llm/context/manager.js +136 -0
  302. package/dist/ai-service/llm/context/manager.js.map +1 -0
  303. package/dist/ai-service/llm/context/options.d.ts +43 -0
  304. package/dist/ai-service/llm/context/options.d.ts.map +1 -0
  305. package/dist/ai-service/llm/context/options.js +81 -0
  306. package/dist/ai-service/llm/context/options.js.map +1 -0
  307. package/dist/ai-service/llm/context/serialization.d.ts +56 -0
  308. package/dist/ai-service/llm/context/serialization.d.ts.map +1 -0
  309. package/dist/ai-service/llm/context/serialization.js +9 -0
  310. package/dist/ai-service/llm/context/serialization.js.map +1 -0
  311. package/dist/ai-service/llm/context/storage/index.d.ts +10 -0
  312. package/dist/ai-service/llm/context/storage/index.d.ts.map +1 -0
  313. package/dist/ai-service/llm/context/storage/index.js +2 -0
  314. package/dist/ai-service/llm/context/storage/index.js.map +1 -0
  315. package/dist/ai-service/llm/context/storage/local.d.ts +22 -0
  316. package/dist/ai-service/llm/context/storage/local.d.ts.map +1 -0
  317. package/dist/ai-service/llm/context/storage/local.js +42 -0
  318. package/dist/ai-service/llm/context/storage/local.js.map +1 -0
  319. package/dist/ai-service/llm/context/types.d.ts +125 -0
  320. package/dist/ai-service/llm/context/types.d.ts.map +1 -0
  321. package/dist/ai-service/llm/context/types.js +5 -0
  322. package/dist/ai-service/llm/context/types.js.map +1 -0
  323. package/dist/ai-service/llm/context/utils/content-compaction.d.ts +26 -0
  324. package/dist/ai-service/llm/context/utils/content-compaction.d.ts.map +1 -0
  325. package/dist/ai-service/llm/context/utils/content-compaction.js +52 -0
  326. package/dist/ai-service/llm/context/utils/content-compaction.js.map +1 -0
  327. package/dist/ai-service/llm/context/utils/index.d.ts +10 -0
  328. package/dist/ai-service/llm/context/utils/index.d.ts.map +1 -0
  329. package/dist/ai-service/llm/context/utils/index.js +10 -0
  330. package/dist/ai-service/llm/context/utils/index.js.map +1 -0
  331. package/dist/ai-service/llm/context/utils/message-utils.d.ts +34 -0
  332. package/dist/ai-service/llm/context/utils/message-utils.d.ts.map +1 -0
  333. package/dist/ai-service/llm/context/utils/message-utils.js +73 -0
  334. package/dist/ai-service/llm/context/utils/message-utils.js.map +1 -0
  335. package/dist/ai-service/llm/context/utils/token-estimation.d.ts +31 -0
  336. package/dist/ai-service/llm/context/utils/token-estimation.d.ts.map +1 -0
  337. package/dist/ai-service/llm/context/utils/token-estimation.js +52 -0
  338. package/dist/ai-service/llm/context/utils/token-estimation.js.map +1 -0
  339. package/dist/ai-service/llm/context/utils/visualization.d.ts +40 -0
  340. package/dist/ai-service/llm/context/utils/visualization.d.ts.map +1 -0
  341. package/dist/ai-service/llm/context/utils/visualization.js +516 -0
  342. package/dist/ai-service/llm/context/utils/visualization.js.map +1 -0
  343. package/dist/ai-service/llm/impl/anthropic.js +2 -2
  344. package/dist/ai-service/llm/impl/anthropic.js.map +1 -1
  345. package/dist/ai-service/llmobs/helpers.d.ts.map +1 -1
  346. package/dist/ai-service/llmobs/helpers.js +10 -19
  347. package/dist/ai-service/llmobs/helpers.js.map +1 -1
  348. package/dist/ai-service/llmobs/middleware/stream-text.d.ts.map +1 -1
  349. package/dist/ai-service/llmobs/middleware/stream-text.js +16 -11
  350. package/dist/ai-service/llmobs/middleware/stream-text.js.map +1 -1
  351. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ButtonPropsDocs.js +1 -1
  352. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/CheckboxPropsDocs.js +1 -1
  353. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ColumnPropsDocs.js +1 -1
  354. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ContainerPropsDocs.js +1 -1
  355. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/DatePickerPropsDocs.js +1 -1
  356. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/DropdownPropsDocs.js +1 -1
  357. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/IconPropsDocs.js +1 -1
  358. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ImagePropsDocs.js +1 -1
  359. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/InputPropsDocs.js +1 -1
  360. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ModalPropsDocs.js +1 -1
  361. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/PagePropsDocs.js +1 -1
  362. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/SectionPropsDocs.js +1 -1
  363. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/SlideoutPropsDocs.js +1 -1
  364. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/SwitchPropsDocs.js +1 -1
  365. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/TablePropsDocs.js +1 -1
  366. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/TextPropsDocs.js +1 -1
  367. package/dist/ai-service/prompt-builder-service/static-fragments/library-typedefs/Dim.js +1 -1
  368. package/dist/ai-service/prompt-builder-service/static-fragments/library-typedefs/EventFlow.js +1 -1
  369. package/dist/ai-service/prompt-builder-service/static-fragments/library-typedefs/TextStyleWithVariant.js +1 -1
  370. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/full-examples.js +1 -1
  371. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-api.js +1 -1
  372. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-components-rules.js +1 -1
  373. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-custom-components.js +1 -1
  374. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-data-filtering.js +1 -1
  375. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-event-flow.js +1 -1
  376. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-forms.js +1 -1
  377. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-layouts.js +1 -1
  378. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-page.js +1 -1
  379. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-rbac.js +1 -1
  380. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-routes.js +1 -1
  381. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-state.js +1 -1
  382. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-theming-chakra-new.js +1 -1
  383. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/system-base.js +1 -1
  384. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/system-incremental.js +1 -1
  385. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/system-specific-edit.js +1 -1
  386. package/dist/ai-service/state-machine/clark-fsm.d.ts +9 -5
  387. package/dist/ai-service/state-machine/clark-fsm.d.ts.map +1 -1
  388. package/dist/ai-service/state-machine/clark-fsm.js.map +1 -1
  389. package/dist/ai-service/state-machine/handlers/agent-planning.d.ts.map +1 -1
  390. package/dist/ai-service/state-machine/handlers/agent-planning.js +36 -9
  391. package/dist/ai-service/state-machine/handlers/agent-planning.js.map +1 -1
  392. package/dist/ai-service/state-machine/handlers/llm-generating.d.ts.map +1 -1
  393. package/dist/ai-service/state-machine/handlers/llm-generating.js +161 -104
  394. package/dist/ai-service/state-machine/handlers/llm-generating.js.map +1 -1
  395. package/dist/ai-service/state-machine/helpers/context-id.d.ts +4 -0
  396. package/dist/ai-service/state-machine/helpers/context-id.d.ts.map +1 -0
  397. package/dist/ai-service/state-machine/helpers/context-id.js +16 -0
  398. package/dist/ai-service/state-machine/helpers/context-id.js.map +1 -0
  399. package/dist/ai-service/state-machine/helpers/peer.d.ts.map +1 -1
  400. package/dist/ai-service/state-machine/helpers/peer.js +7 -4
  401. package/dist/ai-service/state-machine/helpers/peer.js.map +1 -1
  402. package/dist/ai-service/state-machine/mocks.d.ts +2 -3
  403. package/dist/ai-service/state-machine/mocks.d.ts.map +1 -1
  404. package/dist/ai-service/state-machine/mocks.js.map +1 -1
  405. package/dist/ai-service/transform/api-builder/to-sdk-transformer.d.ts.map +1 -1
  406. package/dist/ai-service/transform/api-builder/to-sdk-transformer.js +0 -2
  407. package/dist/ai-service/transform/api-builder/to-sdk-transformer.js.map +1 -1
  408. package/dist/ai-service/types.d.ts +3 -0
  409. package/dist/ai-service/types.d.ts.map +1 -1
  410. package/dist/ai-service/types.js.map +1 -1
  411. package/dist/ai-service/util/parse-jwt.d.ts +12 -0
  412. package/dist/ai-service/util/parse-jwt.d.ts.map +1 -0
  413. package/dist/ai-service/util/parse-jwt.js +30 -0
  414. package/dist/ai-service/util/parse-jwt.js.map +1 -0
  415. package/dist/ai-service/util/safe-stringify.d.ts +1 -1
  416. package/dist/ai-service/util/safe-stringify.d.ts.map +1 -1
  417. package/dist/ai-service/util/safe-stringify.js +3 -3
  418. package/dist/ai-service/util/safe-stringify.js.map +1 -1
  419. package/dist/binding-extraction/extract-js-identifiers.d.ts.map +1 -1
  420. package/dist/binding-extraction/extract-js-identifiers.js +1 -1
  421. package/dist/binding-extraction/extract-js-identifiers.js.map +1 -1
  422. package/dist/build-errors.d.ts +10 -0
  423. package/dist/build-errors.d.ts.map +1 -0
  424. package/dist/build-errors.js +14 -0
  425. package/dist/build-errors.js.map +1 -0
  426. package/dist/client-error-overlay.d.ts +7 -0
  427. package/dist/client-error-overlay.d.ts.map +1 -0
  428. package/dist/client-error-overlay.js +124 -0
  429. package/dist/client-error-overlay.js.map +1 -0
  430. package/dist/component-docs-service/index.d.ts.map +1 -1
  431. package/dist/component-docs-service/index.js +0 -2
  432. package/dist/component-docs-service/index.js.map +1 -1
  433. package/dist/file-sync-vite-plugin.d.ts.map +1 -1
  434. package/dist/file-sync-vite-plugin.js +37 -26
  435. package/dist/file-sync-vite-plugin.js.map +1 -1
  436. package/dist/file-system-manager.d.ts.map +1 -1
  437. package/dist/file-system-manager.js +4 -7
  438. package/dist/file-system-manager.js.map +1 -1
  439. package/dist/injected-index.d.ts.map +1 -1
  440. package/dist/injected-index.js +6 -1
  441. package/dist/injected-index.js.map +1 -1
  442. package/dist/parsing/page.d.ts.map +1 -1
  443. package/dist/parsing/page.js +5 -5
  444. package/dist/parsing/page.js.map +1 -1
  445. package/dist/parsing/scope.d.ts.map +1 -1
  446. package/dist/parsing/scope.js +2 -7
  447. package/dist/parsing/scope.js.map +1 -1
  448. package/dist/routing.d.ts.map +1 -1
  449. package/dist/routing.js +0 -18
  450. package/dist/routing.js.map +1 -1
  451. package/package.json +8 -8
  452. package/dist/ai-service/agent/apis-system-prompt.d.ts +0 -3
  453. package/dist/ai-service/agent/apis-system-prompt.d.ts.map +0 -1
  454. package/dist/ai-service/agent/apis.d.ts +0 -55
  455. package/dist/ai-service/agent/apis.d.ts.map +0 -1
  456. package/dist/ai-service/agent/apis.js.map +0 -1
@@ -1,4 +1,39 @@
1
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
2
+ var useValue = arguments.length > 2;
3
+ for (var i = 0; i < initializers.length; i++) {
4
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
5
+ }
6
+ return useValue ? value : void 0;
7
+ };
8
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
9
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
10
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
11
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
12
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
13
+ var _, done = false;
14
+ for (var i = decorators.length - 1; i >= 0; i--) {
15
+ var context = {};
16
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
17
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
18
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
19
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
20
+ if (kind === "accessor") {
21
+ if (result === void 0) continue;
22
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
23
+ if (_ = accept(result.get)) descriptor.get = _;
24
+ if (_ = accept(result.set)) descriptor.set = _;
25
+ if (_ = accept(result.init)) initializers.unshift(_);
26
+ }
27
+ else if (_ = accept(result)) {
28
+ if (kind === "field") initializers.unshift(_);
29
+ else descriptor[key] = _;
30
+ }
31
+ }
32
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
33
+ done = true;
34
+ };
1
35
  import { getErrorMeta } from "../../util/logger.js";
36
+ import llmobs from "../llmobs/index.js";
2
37
  import { extractProductiveHistoryForContext, getLastUserMessage, } from "./extract-history.js";
3
38
  export function isAiChatMessage(item) {
4
39
  return "role" in item && "content" in item;
@@ -6,401 +41,505 @@ export function isAiChatMessage(item) {
6
41
  export function isAiChatSummary(item) {
7
42
  return "summary" in item && "relevantFilePaths" in item;
8
43
  }
9
- export class ChatSessionStore {
10
- applicationId;
11
- rpcClient;
12
- logger;
13
- messages;
14
- inFlightLoadFromServer;
15
- loadedFromServer = "no";
16
- constructor(config) {
17
- this.rpcClient = config.rpcClient;
18
- this.applicationId = config.applicationId;
19
- this.messages = [];
20
- this.logger = config.logger;
21
- // NOTE: This is used to serialize messages to be after any load.
22
- // We initialize it as resolved to handle the prompt-from-empty-state case.
23
- // TODO(ai): consider replacing this with a queue-based approach
24
- this.inFlightLoadFromServer = Promise.resolve();
25
- }
26
- /***
27
- * Validates and sanitizes the attachments array
28
- * @param attachments - The attachments array to validate
29
- * @returns A tuple containing:
30
- * - a boolean indicating if the attachments are valid
31
- * - the sanitized attachments array
32
- */
33
- validateAttachments(attachments) {
34
- if (!attachments) {
35
- return [true, undefined];
44
+ let ChatSessionStore = (() => {
45
+ let _instanceExtraInitializers = [];
46
+ let _getMessages_decorators;
47
+ let _getLatestSummary_decorators;
48
+ return class ChatSessionStore {
49
+ static {
50
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
51
+ _getMessages_decorators = [llmobs.decorate({
52
+ kind: "task",
53
+ name: "ChatSessionStore.getMessages",
54
+ })];
55
+ _getLatestSummary_decorators = [llmobs.decorate({
56
+ kind: "task",
57
+ name: "ChatSessionStore.getLatestSummary",
58
+ })];
59
+ __esDecorate(this, null, _getMessages_decorators, { kind: "method", name: "getMessages", static: false, private: false, access: { has: obj => "getMessages" in obj, get: obj => obj.getMessages }, metadata: _metadata }, null, _instanceExtraInitializers);
60
+ __esDecorate(this, null, _getLatestSummary_decorators, { kind: "method", name: "getLatestSummary", static: false, private: false, access: { has: obj => "getLatestSummary" in obj, get: obj => obj.getLatestSummary }, metadata: _metadata }, null, _instanceExtraInitializers);
61
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
36
62
  }
37
- if (typeof attachments !== "object" || !Array.isArray(attachments)) {
38
- return [false, undefined];
63
+ // Approximate number of characters per token for estimating token usage
64
+ static CHARS_PER_TOKEN = 3.5;
65
+ applicationId = __runInitializers(this, _instanceExtraInitializers);
66
+ rpcClient;
67
+ logger;
68
+ messages;
69
+ inFlightLoadFromServer;
70
+ loadedFromServer = "no";
71
+ constructor(config) {
72
+ this.rpcClient = config.rpcClient;
73
+ this.applicationId = config.applicationId;
74
+ this.messages = [];
75
+ this.logger = config.logger;
76
+ // NOTE: This is used to serialize messages to be after any load.
77
+ // We initialize it as resolved to handle the prompt-from-empty-state case.
78
+ // TODO(ai): consider replacing this with a queue-based approach
79
+ this.inFlightLoadFromServer = Promise.resolve();
39
80
  }
40
- const validAttachments = attachments
41
- .map((attachment) => {
42
- if (typeof attachment !== "object" || !("type" in attachment)) {
43
- return undefined;
81
+ /***
82
+ * Validates and sanitizes the attachments array
83
+ * @param attachments - The attachments array to validate
84
+ * @returns A tuple containing:
85
+ * - a boolean indicating if the attachments are valid
86
+ * - the sanitized attachments array
87
+ */
88
+ validateAttachments(attachments) {
89
+ if (!attachments) {
90
+ return [true, undefined];
44
91
  }
45
- // Validate image attachment
46
- if (attachment.type === "image") {
47
- if (typeof attachment.image !== "string") {
92
+ if (typeof attachments !== "object" || !Array.isArray(attachments)) {
93
+ return [false, undefined];
94
+ }
95
+ const validAttachments = attachments
96
+ .map((attachment) => {
97
+ if (typeof attachment !== "object" || !("type" in attachment)) {
48
98
  return undefined;
49
99
  }
50
- return {
51
- type: attachment.type,
52
- image: attachment.image,
53
- fileName: attachment.fileName,
54
- };
55
- }
56
- return undefined;
57
- })
58
- .filter(Boolean);
59
- return [validAttachments.length === attachments.length, validAttachments];
60
- }
61
- validateChatMessageV1(payload) {
62
- try {
63
- if (!payload || typeof payload !== "object") {
64
- return null;
65
- }
66
- const msg = payload;
67
- // Validate required fields
68
- if (typeof msg.role !== "string" ||
69
- !["user", "assistant", "server"].includes(msg.role)) {
70
- this.logger.warn(`[ai-service] Invalid message role: ${msg.role}`);
71
- return null;
72
- }
73
- if (typeof msg.content !== "string") {
74
- this.logger.warn(`[ai-service] Invalid message content`);
75
- return null;
76
- }
77
- if (typeof msg.type !== "string") {
78
- this.logger.warn(`[ai-service] Invalid message type: ${msg.type}`);
79
- return null;
80
- }
81
- // Validate optional fields with defaults
82
- const timestamp = typeof msg.timestamp === "number" ? msg.timestamp : Date.now();
83
- const group = typeof msg.group === "string" ? msg.group : undefined;
84
- const status = typeof msg.status === "string" ? msg.status : undefined;
85
- const action = typeof msg.action === "string" ? msg.action : undefined;
86
- const [isAttachmentsValid, attachments] = this.validateAttachments(msg.attachments);
87
- if (!isAttachmentsValid) {
88
- this.logger.warn(`[ai-service] Invalid attachments`);
89
- return null;
90
- }
91
- if (msg.type === "tool") {
92
- if (typeof msg.data !== "object") {
93
- this.logger.warn(`[ai-service] Invalid message data`);
100
+ // Validate image attachment
101
+ if (attachment.type === "image") {
102
+ if (typeof attachment.image !== "string") {
103
+ return undefined;
104
+ }
105
+ return {
106
+ type: attachment.type,
107
+ image: attachment.image,
108
+ fileName: attachment.fileName,
109
+ };
110
+ }
111
+ return undefined;
112
+ })
113
+ .filter(Boolean);
114
+ return [validAttachments.length === attachments.length, validAttachments];
115
+ }
116
+ validateChatMessageV1(payload) {
117
+ try {
118
+ if (!payload || typeof payload !== "object") {
119
+ return null;
120
+ }
121
+ const msg = payload;
122
+ // Validate required fields
123
+ if (typeof msg.role !== "string" ||
124
+ !["user", "assistant", "server"].includes(msg.role)) {
125
+ this.logger.warn(`[ai-service] Invalid message role: ${msg.role}`);
94
126
  return null;
95
127
  }
128
+ if (typeof msg.content !== "string") {
129
+ this.logger.warn(`[ai-service] Invalid message content`);
130
+ return null;
131
+ }
132
+ if (typeof msg.type !== "string") {
133
+ this.logger.warn(`[ai-service] Invalid message type: ${msg.type}`);
134
+ return null;
135
+ }
136
+ // Validate optional fields with defaults
137
+ const timestamp = typeof msg.timestamp === "number" ? msg.timestamp : Date.now();
138
+ const group = typeof msg.group === "string" ? msg.group : undefined;
139
+ const status = typeof msg.status === "string" ? msg.status : undefined;
140
+ const action = typeof msg.action === "string" ? msg.action : undefined;
141
+ const [isAttachmentsValid, attachments] = this.validateAttachments(msg.attachments);
142
+ if (!isAttachmentsValid) {
143
+ this.logger.warn(`[ai-service] Invalid attachments`);
144
+ return null;
145
+ }
146
+ if (msg.type === "tool") {
147
+ return {
148
+ role: msg.role,
149
+ content: msg.content,
150
+ type: "tool",
151
+ id: typeof msg.id === "string" ? msg.id : undefined,
152
+ timestamp,
153
+ status: status,
154
+ action: action,
155
+ args: msg.args,
156
+ tool: msg.tool,
157
+ };
158
+ }
159
+ else if (msg.group === "checklist") {
160
+ if (typeof msg.checklistData !== "object") {
161
+ this.logger.warn(`[ai-service] Invalid checklist data`);
162
+ return null;
163
+ }
164
+ return {
165
+ role: msg.role,
166
+ content: msg.content,
167
+ type: "tool",
168
+ id: typeof msg.id === "string" ? msg.id : undefined,
169
+ timestamp,
170
+ group,
171
+ status,
172
+ action,
173
+ checklistData: msg.checklistData,
174
+ };
175
+ }
176
+ else if (msg.type === "multi_choice") {
177
+ if (!Array.isArray(msg.choices) || msg.choices.length === 0) {
178
+ this.logger.warn(`[ai-service] Invalid choices for multi_choice message`);
179
+ return null;
180
+ }
181
+ return {
182
+ role: msg.role,
183
+ content: msg.content,
184
+ type: "multi_choice",
185
+ id: typeof msg.id === "string" ? msg.id : undefined,
186
+ timestamp,
187
+ choices: msg.choices,
188
+ selectionType: typeof msg.selectionType === "string"
189
+ ? msg.selectionType
190
+ : "single",
191
+ };
192
+ }
193
+ else if (msg.type === "multi_choice_response") {
194
+ if (typeof msg.responseToMessageId !== "string") {
195
+ this.logger.warn(`[ai-service] Invalid responseToMessageId for multi_choice_response`);
196
+ return null;
197
+ }
198
+ if (!Array.isArray(msg.selectedChoiceIndices)) {
199
+ this.logger.warn(`[ai-service] Invalid selectedChoiceIndices for multi_choice_response`);
200
+ return null;
201
+ }
202
+ return {
203
+ role: msg.role,
204
+ content: msg.content,
205
+ type: "multi_choice_response",
206
+ id: typeof msg.id === "string" ? msg.id : undefined,
207
+ timestamp,
208
+ responseToMessageId: msg.responseToMessageId,
209
+ selectedChoiceIndices: msg.selectedChoiceIndices,
210
+ };
211
+ }
212
+ else if (msg.type === "plan_response") {
213
+ if (typeof msg.responseToMessageId !== "string") {
214
+ this.logger.warn(`[ai-service] Invalid responseToMessageId for plan_response`);
215
+ return null;
216
+ }
217
+ return {
218
+ role: msg.role,
219
+ content: msg.content,
220
+ type: "plan_response",
221
+ id: typeof msg.id === "string" ? msg.id : undefined,
222
+ timestamp,
223
+ responseToMessageId: msg.responseToMessageId,
224
+ };
225
+ }
96
226
  return {
97
227
  role: msg.role,
98
228
  content: msg.content,
99
- type: "tool",
229
+ type: msg.type,
230
+ id: typeof msg.id === "string" ? msg.id : undefined,
100
231
  timestamp,
232
+ group,
101
233
  status: status,
102
234
  action: action,
103
- data: msg.data,
235
+ attachments,
104
236
  };
105
237
  }
106
- else if (msg.group === "checklist") {
107
- if (typeof msg.checklistData !== "object") {
108
- this.logger.warn(`[ai-service] Invalid checklist data`);
238
+ catch (error) {
239
+ this.logger.error("[ai-service] Failed to validate message payload", getErrorMeta(error));
240
+ return null;
241
+ }
242
+ }
243
+ validateChatSummaryV1(payload) {
244
+ try {
245
+ if (!payload || typeof payload !== "object") {
246
+ return null;
247
+ }
248
+ const summary = payload;
249
+ // Validate required fields
250
+ if (typeof summary.summary !== "string") {
251
+ this.logger.warn(`[ai-service] Invalid summary content`);
252
+ return null;
253
+ }
254
+ if (!Array.isArray(summary.relevantFilePaths)) {
255
+ this.logger.warn(`[ai-service] Invalid relevantFilePaths - must be array`);
256
+ return null;
257
+ }
258
+ if (!summary.relevantFilePaths.every((path) => typeof path === "string")) {
259
+ this.logger.warn(`[ai-service] Invalid relevantFilePaths - all items must be strings`);
260
+ return null;
261
+ }
262
+ if (!Array.isArray(summary.goals)) {
263
+ this.logger.warn(`[ai-service] Invalid goals - must be array`);
264
+ return null;
265
+ }
266
+ if (!summary.goals.every((goal) => typeof goal === "string")) {
267
+ this.logger.warn(`[ai-service] Invalid goals - all items must be strings`);
268
+ return null;
269
+ }
270
+ if (!Array.isArray(summary.decisions)) {
271
+ this.logger.warn(`[ai-service] Invalid decisions - must be array`);
272
+ return null;
273
+ }
274
+ if (!summary.decisions.every((decision) => typeof decision === "string")) {
275
+ this.logger.warn(`[ai-service] Invalid decisions - all items must be strings`);
109
276
  return null;
110
277
  }
278
+ // Validate optional fields with defaults
279
+ const timestamp = typeof summary.timestamp === "number" ? summary.timestamp : Date.now();
111
280
  return {
112
- role: msg.role,
113
- content: msg.content,
114
- type: "tool",
281
+ summary: summary.summary,
282
+ relevantFilePaths: summary.relevantFilePaths,
283
+ goals: summary.goals,
284
+ decisions: summary.decisions,
285
+ adviceToAgents: summary.adviceToAgents,
115
286
  timestamp,
116
- group,
117
- status,
118
- action,
119
- checklistData: msg.checklistData,
120
287
  };
121
288
  }
122
- return {
123
- role: msg.role,
124
- content: msg.content,
125
- type: msg.type,
126
- timestamp,
127
- group,
128
- status: status,
129
- action: action,
130
- attachments,
131
- };
132
- }
133
- catch (error) {
134
- this.logger.error("[ai-service] Failed to validate message payload", getErrorMeta(error));
135
- return null;
136
- }
137
- }
138
- validateChatSummaryV1(payload) {
139
- try {
140
- if (!payload || typeof payload !== "object") {
141
- return null;
142
- }
143
- const summary = payload;
144
- // Validate required fields
145
- if (typeof summary.summary !== "string") {
146
- this.logger.warn(`[ai-service] Invalid summary content`);
289
+ catch (error) {
290
+ this.logger.error("[ai-service] Failed to validate summary payload", getErrorMeta(error));
147
291
  return null;
148
292
  }
149
- if (!Array.isArray(summary.relevantFilePaths)) {
150
- this.logger.warn(`[ai-service] Invalid relevantFilePaths - must be array`);
151
- return null;
152
- }
153
- if (!summary.relevantFilePaths.every((path) => typeof path === "string")) {
154
- this.logger.warn(`[ai-service] Invalid relevantFilePaths - all items must be strings`);
155
- return null;
293
+ }
294
+ validateChatItemV1(payload) {
295
+ // First try to validate as a message
296
+ const messageResult = this.validateChatMessageV1(payload);
297
+ if (messageResult) {
298
+ return messageResult;
156
299
  }
157
- if (!Array.isArray(summary.goals)) {
158
- this.logger.warn(`[ai-service] Invalid goals - must be array`);
159
- return null;
300
+ // If not a valid message, try to validate as a summary
301
+ const summaryResult = this.validateChatSummaryV1(payload);
302
+ if (summaryResult) {
303
+ return summaryResult;
160
304
  }
161
- if (!summary.goals.every((goal) => typeof goal === "string")) {
162
- this.logger.warn(`[ai-service] Invalid goals - all items must be strings`);
163
- return null;
305
+ return null;
306
+ }
307
+ async ensureLoadedFromServer() {
308
+ // NOTE: we will want to re-evaluate this if/when the auth token associated with this sandbox is changed
309
+ // the existing solution is that each time the page loaded by the client, we re-fetch from the server,
310
+ // so this may be a non-issue.
311
+ if (this.loadedFromServer === "loaded" ||
312
+ this.loadedFromServer === "loading") {
313
+ await this.inFlightLoadFromServer;
314
+ return;
164
315
  }
165
- if (!Array.isArray(summary.decisions)) {
166
- this.logger.warn(`[ai-service] Invalid decisions - must be array`);
167
- return null;
316
+ try {
317
+ this.loadedFromServer = "loading";
318
+ this.inFlightLoadFromServer = this.rpcClient.call(async (client) => {
319
+ const applicationId = this.applicationId;
320
+ const { data } = await client.call.v1.ai.chat.getMessages({
321
+ applicationId,
322
+ });
323
+ this.messages =
324
+ data?.messages
325
+ .map((msg) => this.validateChatItemV1(msg.chatPayload))
326
+ .filter((item) => item !== null)
327
+ .sort((a, b) => {
328
+ return (a.timestamp || 0) - (b.timestamp || 0);
329
+ }) ?? [];
330
+ });
331
+ await this.inFlightLoadFromServer;
332
+ this.loadedFromServer = "loaded";
168
333
  }
169
- if (!summary.decisions.every((decision) => typeof decision === "string")) {
170
- this.logger.warn(`[ai-service] Invalid decisions - all items must be strings`);
171
- return null;
334
+ catch (error) {
335
+ this.logger.error("[ai-service] Failed to load chat messages from server", getErrorMeta(error));
172
336
  }
173
- // Validate optional fields with defaults
174
- const timestamp = typeof summary.timestamp === "number" ? summary.timestamp : Date.now();
175
- return {
176
- summary: summary.summary,
177
- relevantFilePaths: summary.relevantFilePaths,
178
- goals: summary.goals,
179
- decisions: summary.decisions,
180
- adviceToAgents: summary.adviceToAgents,
181
- timestamp,
182
- };
183
- }
184
- catch (error) {
185
- this.logger.error("[ai-service] Failed to validate summary payload", getErrorMeta(error));
186
- return null;
187
- }
188
- }
189
- validateChatItemV1(payload) {
190
- // First try to validate as a message
191
- const messageResult = this.validateChatMessageV1(payload);
192
- if (messageResult) {
193
- return messageResult;
194
337
  }
195
- // If not a valid message, try to validate as a summary
196
- const summaryResult = this.validateChatSummaryV1(payload);
197
- if (summaryResult) {
198
- return summaryResult;
199
- }
200
- return null;
201
- }
202
- async ensureLoadedFromServer() {
203
- // NOTE: we will want to re-evaluate this if/when the auth token associated with this sandbox is changed
204
- // the existing solution is that each time the page loaded by the client, we re-fetch from the server,
205
- // so this may be a non-issue.
206
- if (this.loadedFromServer === "loaded" ||
207
- this.loadedFromServer === "loading") {
208
- await this.inFlightLoadFromServer;
209
- return;
338
+ getLastUserMessage() {
339
+ const messages = this.messages.filter(isAiChatMessage);
340
+ return getLastUserMessage(messages);
210
341
  }
211
- try {
212
- this.loadedFromServer = "loading";
213
- this.inFlightLoadFromServer = this.rpcClient.call(async (client) => {
214
- const applicationId = this.applicationId;
215
- const { data } = await client.call.v1.ai.chat.getMessages({
216
- applicationId,
217
- });
218
- this.messages =
219
- data?.messages
220
- .map((msg) => this.validateChatItemV1(msg.chatPayload))
221
- .filter((item) => item !== null)
222
- .sort((a, b) => {
223
- return (a.timestamp || 0) - (b.timestamp || 0);
224
- }) ?? [];
342
+ getRecentExchanges() {
343
+ // Filter out summaries but keep regular messages for the existing logic
344
+ const messages = this.messages.filter(isAiChatMessage);
345
+ return extractProductiveHistoryForContext(messages, {
346
+ maxAcceptedExchanges: 2,
347
+ includeRecentUnknown: true,
225
348
  });
226
- await this.inFlightLoadFromServer;
227
- this.loadedFromServer = "loaded";
228
349
  }
229
- catch (error) {
230
- this.logger.error("[ai-service] Failed to load chat messages from server", getErrorMeta(error));
350
+ async getMessages() {
351
+ await this.ensureLoadedFromServer();
352
+ return this.messages.filter(isAiChatMessage);
231
353
  }
232
- }
233
- getLastUserMessage() {
234
- const messages = this.messages.filter(isAiChatMessage);
235
- return getLastUserMessage(messages);
236
- }
237
- getRecentExchanges() {
238
- // Filter out summaries but keep regular messages for the existing logic
239
- const messages = this.messages.filter(isAiChatMessage);
240
- return extractProductiveHistoryForContext(messages, {
241
- maxAcceptedExchanges: 2,
242
- includeRecentUnknown: true,
243
- });
244
- }
245
- async getMessages() {
246
- await this.ensureLoadedFromServer();
247
- return this.messages.filter(isAiChatMessage);
248
- }
249
- async newChat() {
250
- try {
251
- await this.rpcClient.call(async (client) => {
252
- const applicationId = this.applicationId;
253
- return await client.call.v1.ai.chat.new({ applicationId });
254
- });
255
- this.messages = [];
354
+ async newChat() {
355
+ try {
356
+ await this.rpcClient.call(async (client) => {
357
+ const applicationId = this.applicationId;
358
+ return await client.call.v1.ai.chat.new({ applicationId });
359
+ });
360
+ this.messages = [];
361
+ }
362
+ catch (error) {
363
+ this.logger.error("[ai-service] Failed to create new chat", getErrorMeta(error));
364
+ }
256
365
  }
257
- catch (error) {
258
- this.logger.error("[ai-service] Failed to create new chat", getErrorMeta(error));
366
+ async recordUser(text, options = {}) {
367
+ const message = {
368
+ role: "user",
369
+ content: text,
370
+ id: crypto.randomUUID(),
371
+ timestamp: Date.now(),
372
+ type: "text",
373
+ };
374
+ if (options.attachments) {
375
+ message.attachments = options.attachments;
376
+ }
377
+ await this.appendMessage(message);
259
378
  }
260
- }
261
- async recordUser(text, options = {}) {
262
- const message = {
263
- role: "user",
264
- content: text,
265
- timestamp: Date.now(),
266
- type: "text",
267
- };
268
- if (options.attachments) {
269
- message.attachments = options.attachments;
379
+ async recordUserAcceptance() {
380
+ const message = {
381
+ role: "user",
382
+ content: "",
383
+ id: crypto.randomUUID(),
384
+ timestamp: Date.now(),
385
+ type: "draftAccepted",
386
+ };
387
+ await this.appendMessage(message);
270
388
  }
271
- await this.appendMessage(message);
272
- }
273
- async recordUserAcceptance() {
274
- const message = {
275
- role: "user",
276
- content: "",
277
- timestamp: Date.now(),
278
- type: "draftAccepted",
279
- };
280
- await this.appendMessage(message);
281
- }
282
- async recordUserRejection() {
283
- const message = {
284
- role: "user",
285
- content: "",
286
- timestamp: Date.now(),
287
- type: "draftRejected",
288
- };
289
- await this.appendMessage(message);
290
- }
291
- async recordAssistant(payload) {
292
- let message;
293
- if ("checklistData" in payload) {
294
- message = {
295
- role: "assistant",
296
- content: payload.text,
297
- type: "tool",
298
- group: "checklist",
299
- status: payload.status,
389
+ async recordUserRejection() {
390
+ const message = {
391
+ role: "user",
392
+ content: "",
393
+ id: crypto.randomUUID(),
300
394
  timestamp: Date.now(),
301
- checklistData: payload.checklistData,
395
+ type: "draftRejected",
302
396
  };
397
+ await this.appendMessage(message);
303
398
  }
304
- else if (payload.type === "tool") {
305
- message = {
306
- role: "assistant",
307
- content: payload.text,
308
- type: "tool",
309
- status: payload.status,
399
+ async recordUserResponse(text, responseType, metadata) {
400
+ const baseMessage = {
401
+ role: "user",
402
+ content: text,
403
+ id: crypto.randomUUID(),
310
404
  timestamp: Date.now(),
311
- data: {
312
- label: payload.label,
313
- name: payload.name,
314
- displayType: payload.displayType,
315
- },
405
+ type: responseType,
406
+ responseToMessageId: metadata.responseToMessageId,
316
407
  };
408
+ if (responseType === "multi_choice_response" &&
409
+ metadata.selectedChoiceIndices) {
410
+ baseMessage.selectedChoiceIndices =
411
+ metadata.selectedChoiceIndices;
412
+ }
413
+ await this.appendMessage(baseMessage);
414
+ }
415
+ async recordAssistant(payload) {
416
+ let message;
417
+ // Use ID from payload if present, otherwise generate new one
418
+ const messageId = payload.id ?? crypto.randomUUID();
419
+ if ("checklistData" in payload) {
420
+ message = {
421
+ role: "assistant",
422
+ content: payload.text,
423
+ type: "tool",
424
+ group: "checklist",
425
+ status: payload.status,
426
+ id: messageId,
427
+ timestamp: Date.now(),
428
+ checklistData: payload.checklistData,
429
+ };
430
+ }
431
+ else if (payload.type === "tool") {
432
+ message = {
433
+ role: "assistant",
434
+ content: "",
435
+ type: "tool",
436
+ status: payload.status,
437
+ id: messageId,
438
+ timestamp: Date.now(),
439
+ args: payload.args,
440
+ tool: payload.tool,
441
+ group: "group" in payload ? payload.group : "",
442
+ };
443
+ }
444
+ else {
445
+ message = {
446
+ role: "assistant",
447
+ content: payload.text,
448
+ type: payload.type || "text",
449
+ group: "group" in payload ? payload.group : "",
450
+ status: payload.status,
451
+ id: messageId,
452
+ timestamp: Date.now(),
453
+ ...("choices" in payload && payload.choices
454
+ ? { choices: payload.choices }
455
+ : {}),
456
+ ...("selectionType" in payload && payload.selectionType
457
+ ? { selectionType: payload.selectionType }
458
+ : {}),
459
+ };
460
+ }
461
+ await this.appendMessage(message);
317
462
  }
318
- else {
319
- message = {
463
+ async recordAssistantChangeInfo(payload) {
464
+ const message = {
320
465
  role: "assistant",
321
- content: payload.text,
322
- type: payload.type || "text",
323
- group: "group" in payload ? payload.group : "",
466
+ group: payload.type,
467
+ content: payload.name,
468
+ action: payload.action,
324
469
  status: payload.status,
470
+ type: "changeInfo",
471
+ id: crypto.randomUUID(),
325
472
  timestamp: Date.now(),
326
473
  };
474
+ await this.appendMessage(message);
327
475
  }
328
- await this.appendMessage(message);
329
- }
330
- async recordAssistantChangeInfo(payload) {
331
- const message = {
332
- role: "assistant",
333
- group: payload.type,
334
- content: payload.name,
335
- action: payload.action,
336
- status: payload.status,
337
- type: "changeInfo",
338
- timestamp: Date.now(),
339
- };
340
- await this.appendMessage(message);
341
- }
342
- async appendMessage(payload) {
343
- await this.ensureLoadedFromServer();
344
- this.messages.push(payload);
345
- try {
346
- await this.rpcClient.call(async (client) => {
347
- const applicationId = this.applicationId;
348
- return await client.call.v1.ai.chat.pushMessage({
349
- applicationId,
350
- payload: payload,
476
+ async appendMessage(message) {
477
+ await this.ensureLoadedFromServer();
478
+ this.messages.push(message);
479
+ const payload = {
480
+ ...message,
481
+ };
482
+ try {
483
+ await this.rpcClient.call(async (client) => {
484
+ const applicationId = this.applicationId;
485
+ return await client.call.v1.ai.chat.pushMessage({
486
+ applicationId,
487
+ payload,
488
+ });
351
489
  });
352
- });
353
- }
354
- catch (error) {
355
- this.logger.error("[ai-service] Failed to write chat message to server", getErrorMeta(error));
356
- }
357
- }
358
- determineSummaryOutcome(summary, allMessages) {
359
- // Find the index of this summary in all messages
360
- const summaryIndex = allMessages.findIndex((item) => isAiChatSummary(item) &&
361
- item.timestamp === summary.timestamp &&
362
- item.summary === summary.summary);
363
- if (summaryIndex === -1) {
364
- return "unknown";
490
+ }
491
+ catch (error) {
492
+ this.logger.error("[ai-service] Failed to write chat message to server", getErrorMeta(error));
493
+ }
365
494
  }
366
- // Look for acceptance/rejection messages after this summary
367
- const messagesAfterSummary = allMessages.slice(summaryIndex + 1);
368
- for (const item of messagesAfterSummary) {
369
- if (isAiChatMessage(item) && item.role === "user") {
370
- if (item.type === "draftAccepted") {
371
- return "accepted";
372
- }
373
- if (item.type === "draftRejected") {
374
- return "rejected";
495
+ determineSummaryOutcome(summary, allMessages) {
496
+ // Find the index of this summary in all messages
497
+ const summaryIndex = allMessages.findIndex((item) => isAiChatSummary(item) &&
498
+ item.timestamp === summary.timestamp &&
499
+ item.summary === summary.summary);
500
+ if (summaryIndex === -1) {
501
+ return "unknown";
502
+ }
503
+ // Look for acceptance/rejection messages after this summary
504
+ const messagesAfterSummary = allMessages.slice(summaryIndex + 1);
505
+ for (const item of messagesAfterSummary) {
506
+ if (isAiChatMessage(item) && item.role === "user") {
507
+ if (item.type === "draftAccepted") {
508
+ return "accepted";
509
+ }
510
+ if (item.type === "draftRejected") {
511
+ return "rejected";
512
+ }
375
513
  }
376
514
  }
515
+ return "unknown";
377
516
  }
378
- return "unknown";
379
- }
380
- async recordSummary(summaryData) {
381
- const summaryPayload = {
382
- ...summaryData,
383
- timestamp: Date.now(),
384
- };
385
- await this.appendMessage(summaryPayload);
386
- }
387
- async getSummaries() {
388
- await this.ensureLoadedFromServer();
389
- return this.messages.filter(isAiChatSummary);
390
- }
391
- async getLatestSummary() {
392
- return (await this.getLatestSummaries(1))[0];
393
- }
394
- async getLatestSummaries(count) {
395
- const summaries = await this.getSummaries();
396
- const sortedSummaries = summaries
397
- .sort((a, b) => (b.timestamp || 0) - (a.timestamp || 0))
398
- .slice(0, count);
399
- // Add outcome information to each summary
400
- return sortedSummaries.map((summary) => ({
401
- ...summary,
402
- outcome: this.determineSummaryOutcome(summary, this.messages),
403
- }));
404
- }
405
- }
517
+ async recordSummary(summaryData) {
518
+ const summaryPayload = {
519
+ ...summaryData,
520
+ timestamp: Date.now(),
521
+ };
522
+ await this.appendMessage(summaryPayload);
523
+ }
524
+ async getSummaries() {
525
+ await this.ensureLoadedFromServer();
526
+ return this.messages.filter(isAiChatSummary);
527
+ }
528
+ async getLatestSummary() {
529
+ return (await this.getLatestSummaries(1))[0];
530
+ }
531
+ async getLatestSummaries(count) {
532
+ const summaries = await this.getSummaries();
533
+ const sortedSummaries = summaries
534
+ .sort((a, b) => (b.timestamp || 0) - (a.timestamp || 0))
535
+ .slice(0, count);
536
+ // Add outcome information to each summary
537
+ return sortedSummaries.map((summary) => ({
538
+ ...summary,
539
+ outcome: this.determineSummaryOutcome(summary, this.messages),
540
+ }));
541
+ }
542
+ };
543
+ })();
544
+ export { ChatSessionStore };
406
545
  //# sourceMappingURL=chat-session-store.js.map