genaicode 0.14.1 → 0.15.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 (294) hide show
  1. package/dist/ai-service/ai-studio.d.ts +2 -18
  2. package/dist/ai-service/ai-studio.js +88 -32
  3. package/dist/ai-service/ai-studio.js.map +1 -1
  4. package/dist/ai-service/anthropic.js +87 -45
  5. package/dist/ai-service/anthropic.js.map +1 -1
  6. package/dist/ai-service/common-types.d.ts +36 -3
  7. package/dist/ai-service/common-types.js +0 -2
  8. package/dist/ai-service/common-types.js.map +1 -1
  9. package/dist/ai-service/common.js +0 -2
  10. package/dist/ai-service/common.js.map +1 -1
  11. package/dist/ai-service/files-api.d.ts +33 -0
  12. package/dist/ai-service/files-api.js +239 -0
  13. package/dist/ai-service/files-api.js.map +1 -0
  14. package/dist/ai-service/github-models.js +0 -2
  15. package/dist/ai-service/github-models.js.map +1 -1
  16. package/dist/ai-service/local-llm.js +0 -4
  17. package/dist/ai-service/local-llm.js.map +1 -1
  18. package/dist/ai-service/openai-responses.js +62 -16
  19. package/dist/ai-service/openai-responses.js.map +1 -1
  20. package/dist/ai-service/openai.js +157 -54
  21. package/dist/ai-service/openai.js.map +1 -1
  22. package/dist/ai-service/service-configurations-types.d.ts +0 -1
  23. package/dist/ai-service/service-configurations.js +19 -20
  24. package/dist/ai-service/service-configurations.js.map +1 -1
  25. package/dist/ai-service/vertex-ai.js +2 -1
  26. package/dist/ai-service/vertex-ai.js.map +1 -1
  27. package/dist/cli/cli-params.js +2 -2
  28. package/dist/cli/cli-params.js.map +1 -1
  29. package/dist/files/file-id-utils.js +1 -1
  30. package/dist/files/file-id-utils.js.map +1 -1
  31. package/dist/files/read-files.js +10 -6
  32. package/dist/files/read-files.js.map +1 -1
  33. package/dist/files/source-code-types.d.ts +9 -5
  34. package/dist/files/source-code-utils.d.ts +2 -1
  35. package/dist/files/source-code-utils.js +30 -12
  36. package/dist/files/source-code-utils.js.map +1 -1
  37. package/dist/files/summary-cache.d.ts +6 -4
  38. package/dist/files/summary-cache.js +3 -2
  39. package/dist/files/summary-cache.js.map +1 -1
  40. package/dist/index.d.ts +1 -1
  41. package/dist/index.js +1 -1
  42. package/dist/index.js.map +1 -1
  43. package/dist/main/codegen-types.d.ts +2 -2
  44. package/dist/main/common/content-bus-types.d.ts +14 -0
  45. package/dist/main/common/content-bus.d.ts +3 -1
  46. package/dist/main/common/content-bus.js +28 -3
  47. package/dist/main/common/content-bus.js.map +1 -1
  48. package/dist/main/common/user-actions.d.ts +1 -1
  49. package/dist/main/config-types.d.ts +0 -3
  50. package/dist/main/config-types.js.map +1 -1
  51. package/dist/main/config.js +1 -1
  52. package/dist/main/config.js.map +1 -1
  53. package/dist/main/plugin-loader.d.ts +1 -1
  54. package/dist/main/ui/backend/endpoints/compress-context-endpoint.d.ts +1 -0
  55. package/dist/main/ui/backend/endpoints/compress-context-endpoint.js +18 -0
  56. package/dist/main/ui/backend/endpoints/compress-context-endpoint.js.map +1 -0
  57. package/dist/main/ui/backend/endpoints/config-endpoint.js +1 -1
  58. package/dist/main/ui/backend/endpoints/config-endpoint.js.map +1 -1
  59. package/dist/main/ui/backend/endpoints/context-endpoint.js +102 -0
  60. package/dist/main/ui/backend/endpoints/context-endpoint.js.map +1 -1
  61. package/dist/main/ui/backend/endpoints/edit-message-endpoint.js +9 -6
  62. package/dist/main/ui/backend/endpoints/edit-message-endpoint.js.map +1 -1
  63. package/dist/main/ui/backend/endpoints/index.d.ts +1 -0
  64. package/dist/main/ui/backend/endpoints/index.js +1 -0
  65. package/dist/main/ui/backend/endpoints/index.js.map +1 -1
  66. package/dist/main/ui/backend/endpoints/interrupt-execution-endpoint.js +1 -1
  67. package/dist/main/ui/backend/endpoints/interrupt-execution-endpoint.js.map +1 -1
  68. package/dist/main/ui/backend/service.d.ts +68 -7
  69. package/dist/main/ui/backend/service.js +301 -28
  70. package/dist/main/ui/backend/service.js.map +1 -1
  71. package/dist/main/ui/codegen-ui.js +2 -2
  72. package/dist/main/ui/codegen-ui.js.map +1 -1
  73. package/dist/main/ui/common/api-types.d.ts +6 -2
  74. package/dist/main/ui/common/api-types.js.map +1 -1
  75. package/dist/main/ui/frontend/assets/index-DAM_kJhM.js +3445 -0
  76. package/dist/main/ui/frontend/index.html +1 -1
  77. package/dist/prompt/context-utils.d.ts +7 -0
  78. package/dist/prompt/context-utils.js +33 -0
  79. package/dist/prompt/context-utils.js.map +1 -0
  80. package/dist/prompt/function-calling.js +4 -5
  81. package/dist/prompt/function-calling.js.map +1 -1
  82. package/dist/prompt/function-defs/code-execution.d.ts +7 -0
  83. package/dist/prompt/function-defs/code-execution.js +27 -0
  84. package/dist/prompt/function-defs/code-execution.js.map +1 -0
  85. package/dist/prompt/function-defs/conversation-graph.d.ts +1 -1
  86. package/dist/prompt/function-defs/conversation-graph.js +1 -1
  87. package/dist/prompt/function-defs/conversation-graph.js.map +1 -1
  88. package/dist/prompt/function-defs/get-source-code.js +3 -3
  89. package/dist/prompt/function-defs/iterate.d.ts +20 -0
  90. package/dist/prompt/function-defs/iterate.js +373 -0
  91. package/dist/prompt/function-defs/iterate.js.map +1 -0
  92. package/dist/prompt/function-defs/set-summaries.js +6 -2
  93. package/dist/prompt/function-defs/set-summaries.js.map +1 -1
  94. package/dist/prompt/limits.js +1 -1
  95. package/dist/prompt/prompt-service.js +13 -10
  96. package/dist/prompt/prompt-service.js.map +1 -1
  97. package/dist/prompt/source-code-optimize.d.ts +2 -0
  98. package/dist/prompt/source-code-optimize.js +27 -0
  99. package/dist/prompt/source-code-optimize.js.map +1 -0
  100. package/dist/prompt/steps/step-ask-question/step-ask-question.js +7 -1
  101. package/dist/prompt/steps/step-ask-question/step-ask-question.js.map +1 -1
  102. package/dist/prompt/steps/step-codegen-planning.js +6 -2
  103. package/dist/prompt/steps/step-codegen-planning.js.map +1 -1
  104. package/dist/prompt/steps/step-context-compression.js +5 -0
  105. package/dist/prompt/steps/step-context-compression.js.map +1 -1
  106. package/dist/prompt/steps/step-context-optimization.js +6 -3
  107. package/dist/prompt/steps/step-context-optimization.js.map +1 -1
  108. package/dist/prompt/steps/step-iterate/handlers/container-task/command-execution-loop.d.ts +7 -0
  109. package/dist/prompt/steps/step-iterate/handlers/container-task/command-execution-loop.js +301 -0
  110. package/dist/prompt/steps/step-iterate/handlers/container-task/command-execution-loop.js.map +1 -0
  111. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/complete-task.d.ts +4 -0
  112. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/complete-task.js +49 -0
  113. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/complete-task.js.map +1 -0
  114. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/copy-from-container.d.ts +4 -0
  115. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/copy-from-container.js +190 -0
  116. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/copy-from-container.js.map +1 -0
  117. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/copy-to-container.d.ts +4 -0
  118. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/copy-to-container.js +139 -0
  119. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/copy-to-container.js.map +1 -0
  120. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/edit-file.d.ts +10 -0
  121. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/edit-file.js +93 -0
  122. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/edit-file.js.map +1 -0
  123. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/fail-task.d.ts +4 -0
  124. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/fail-task.js +72 -0
  125. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/fail-task.js.map +1 -0
  126. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/gain-knowledge.d.ts +10 -0
  127. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/gain-knowledge.js +125 -0
  128. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/gain-knowledge.js.map +1 -0
  129. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/interrupt-controller.d.ts +19 -0
  130. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/interrupt-controller.js +33 -0
  131. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/interrupt-controller.js.map +1 -0
  132. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/query-knowledge.d.ts +8 -0
  133. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/query-knowledge.js +85 -0
  134. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/query-knowledge.js.map +1 -0
  135. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/request-secret.d.ts +6 -0
  136. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/request-secret.js +122 -0
  137. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/request-secret.js.map +1 -0
  138. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/run-command.d.ts +7 -0
  139. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/run-command.js +146 -0
  140. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/run-command.js.map +1 -0
  141. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/send-message.d.ts +4 -0
  142. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/send-message.js +56 -0
  143. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/send-message.js.map +1 -0
  144. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/set-execution-plan.d.ts +4 -0
  145. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/set-execution-plan.js +56 -0
  146. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/set-execution-plan.js.map +1 -0
  147. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/update-execution-plan.d.ts +4 -0
  148. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/update-execution-plan.js +39 -0
  149. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/update-execution-plan.js.map +1 -0
  150. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/view-file.d.ts +10 -0
  151. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/view-file.js +95 -0
  152. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/view-file.js.map +1 -0
  153. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/web-search.d.ts +2 -0
  154. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/web-search.js +96 -0
  155. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/web-search.js.map +1 -0
  156. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/wrap-context.d.ts +4 -0
  157. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/wrap-context.js +123 -0
  158. package/dist/prompt/steps/step-iterate/handlers/container-task/commands/wrap-context.js.map +1 -0
  159. package/dist/prompt/steps/step-iterate/handlers/container-task/container-commands-registry.d.ts +11 -0
  160. package/dist/prompt/steps/step-iterate/handlers/container-task/container-commands-registry.js +50 -0
  161. package/dist/prompt/steps/step-iterate/handlers/container-task/container-commands-registry.js.map +1 -0
  162. package/dist/prompt/steps/step-iterate/handlers/container-task/container-commands-types.d.ts +28 -0
  163. package/dist/prompt/steps/step-iterate/handlers/container-task/container-commands-types.js +2 -0
  164. package/dist/prompt/steps/step-iterate/handlers/container-task/container-commands-types.js.map +1 -0
  165. package/dist/prompt/steps/step-iterate/handlers/container-task/container-task-orchestrator.d.ts +2 -0
  166. package/dist/prompt/steps/step-iterate/handlers/container-task/container-task-orchestrator.js +202 -0
  167. package/dist/prompt/steps/step-iterate/handlers/container-task/container-task-orchestrator.js.map +1 -0
  168. package/dist/prompt/steps/step-iterate/handlers/container-task/utils/docker-check.d.ts +4 -0
  169. package/dist/prompt/steps/step-iterate/handlers/container-task/utils/docker-check.js +15 -0
  170. package/dist/prompt/steps/step-iterate/handlers/container-task/utils/docker-check.js.map +1 -0
  171. package/dist/prompt/steps/step-iterate/handlers/container-task/utils/docker-utils.d.ts +50 -0
  172. package/dist/prompt/steps/step-iterate/handlers/container-task/utils/docker-utils.js +358 -0
  173. package/dist/prompt/steps/step-iterate/handlers/container-task/utils/docker-utils.js.map +1 -0
  174. package/dist/prompt/steps/step-iterate/handlers/file-request-utils.d.ts +47 -0
  175. package/dist/prompt/steps/step-iterate/handlers/file-request-utils.js +114 -0
  176. package/dist/prompt/steps/step-iterate/handlers/file-request-utils.js.map +1 -0
  177. package/dist/prompt/steps/step-iterate/handlers/handle-code-execution.d.ts +1 -0
  178. package/dist/prompt/steps/step-iterate/handlers/handle-code-execution.js +133 -0
  179. package/dist/prompt/steps/step-iterate/handlers/handle-code-execution.js.map +1 -0
  180. package/dist/prompt/steps/step-iterate/handlers/handle-code-generation.d.ts +4 -0
  181. package/dist/prompt/steps/step-iterate/handlers/handle-code-generation.js +177 -0
  182. package/dist/prompt/steps/step-iterate/handlers/handle-code-generation.js.map +1 -0
  183. package/dist/prompt/steps/step-iterate/handlers/handle-compound-action.d.ts +20 -0
  184. package/dist/prompt/steps/step-iterate/handlers/handle-compound-action.js +305 -0
  185. package/dist/prompt/steps/step-iterate/handlers/handle-compound-action.js.map +1 -0
  186. package/dist/prompt/steps/step-iterate/handlers/handle-confirm-code-generation.d.ts +2 -0
  187. package/dist/prompt/steps/step-iterate/handlers/handle-confirm-code-generation.js +40 -0
  188. package/dist/prompt/steps/step-iterate/handlers/handle-confirm-code-generation.js.map +1 -0
  189. package/dist/prompt/steps/step-iterate/handlers/handle-context-compression.d.ts +2 -0
  190. package/dist/prompt/steps/step-iterate/handlers/handle-context-compression.js +35 -0
  191. package/dist/prompt/steps/step-iterate/handlers/handle-context-compression.js.map +1 -0
  192. package/dist/prompt/steps/step-iterate/handlers/handle-context-optimization.d.ts +2 -0
  193. package/dist/prompt/steps/step-iterate/handlers/handle-context-optimization.js +34 -0
  194. package/dist/prompt/steps/step-iterate/handlers/handle-context-optimization.js.map +1 -0
  195. package/dist/prompt/steps/step-iterate/handlers/handle-conversation-graph.d.ts +11 -0
  196. package/dist/prompt/steps/step-iterate/handlers/handle-conversation-graph.js +503 -0
  197. package/dist/prompt/steps/step-iterate/handlers/handle-conversation-graph.js.map +1 -0
  198. package/dist/prompt/steps/step-iterate/handlers/handle-create-file.d.ts +2 -0
  199. package/dist/prompt/steps/step-iterate/handlers/handle-create-file.js +159 -0
  200. package/dist/prompt/steps/step-iterate/handlers/handle-create-file.js.map +1 -0
  201. package/dist/prompt/steps/step-iterate/handlers/handle-end-conversation.d.ts +2 -0
  202. package/dist/prompt/steps/step-iterate/handlers/handle-end-conversation.js +30 -0
  203. package/dist/prompt/steps/step-iterate/handlers/handle-end-conversation.js.map +1 -0
  204. package/dist/prompt/steps/step-iterate/handlers/handle-explore-external-directories.d.ts +2 -0
  205. package/dist/prompt/steps/step-iterate/handlers/handle-explore-external-directories.js +280 -0
  206. package/dist/prompt/steps/step-iterate/handlers/handle-explore-external-directories.js.map +1 -0
  207. package/dist/prompt/steps/step-iterate/handlers/handle-genaicode-help.d.ts +8 -0
  208. package/dist/prompt/steps/step-iterate/handlers/handle-genaicode-help.js +105 -0
  209. package/dist/prompt/steps/step-iterate/handlers/handle-genaicode-help.js.map +1 -0
  210. package/dist/prompt/steps/step-iterate/handlers/handle-generate-image.d.ts +2 -0
  211. package/dist/prompt/steps/step-iterate/handlers/handle-generate-image.js +110 -0
  212. package/dist/prompt/steps/step-iterate/handlers/handle-generate-image.js.map +1 -0
  213. package/dist/prompt/steps/step-iterate/handlers/handle-perform-analysis.d.ts +6 -0
  214. package/dist/prompt/steps/step-iterate/handlers/handle-perform-analysis.js +110 -0
  215. package/dist/prompt/steps/step-iterate/handlers/handle-perform-analysis.js.map +1 -0
  216. package/dist/prompt/steps/step-iterate/handlers/handle-project-command.d.ts +2 -0
  217. package/dist/prompt/steps/step-iterate/handlers/handle-project-command.js +280 -0
  218. package/dist/prompt/steps/step-iterate/handlers/handle-project-command.js.map +1 -0
  219. package/dist/prompt/steps/step-iterate/handlers/handle-pull-app-context.d.ts +9 -0
  220. package/dist/prompt/steps/step-iterate/handlers/handle-pull-app-context.js +94 -0
  221. package/dist/prompt/steps/step-iterate/handlers/handle-pull-app-context.js.map +1 -0
  222. package/dist/prompt/steps/step-iterate/handlers/handle-pull-console-logs.d.ts +2 -0
  223. package/dist/prompt/steps/step-iterate/handlers/handle-pull-console-logs.js +174 -0
  224. package/dist/prompt/steps/step-iterate/handlers/handle-pull-console-logs.js.map +1 -0
  225. package/dist/prompt/steps/step-iterate/handlers/handle-push-app-context.d.ts +9 -0
  226. package/dist/prompt/steps/step-iterate/handlers/handle-push-app-context.js +104 -0
  227. package/dist/prompt/steps/step-iterate/handlers/handle-push-app-context.js.map +1 -0
  228. package/dist/prompt/steps/step-iterate/handlers/handle-read-external-files.d.ts +2 -0
  229. package/dist/prompt/steps/step-iterate/handlers/handle-read-external-files.js +149 -0
  230. package/dist/prompt/steps/step-iterate/handlers/handle-read-external-files.js.map +1 -0
  231. package/dist/prompt/steps/step-iterate/handlers/handle-reasoning-inference.d.ts +7 -0
  232. package/dist/prompt/steps/step-iterate/handlers/handle-reasoning-inference.js +119 -0
  233. package/dist/prompt/steps/step-iterate/handlers/handle-reasoning-inference.js.map +1 -0
  234. package/dist/prompt/steps/step-iterate/handlers/handle-remove-files-from-context.d.ts +2 -0
  235. package/dist/prompt/steps/step-iterate/handlers/handle-remove-files-from-context.js +100 -0
  236. package/dist/prompt/steps/step-iterate/handlers/handle-remove-files-from-context.js.map +1 -0
  237. package/dist/prompt/steps/step-iterate/handlers/handle-request-files-content.d.ts +8 -0
  238. package/dist/prompt/steps/step-iterate/handlers/handle-request-files-content.js +146 -0
  239. package/dist/prompt/steps/step-iterate/handlers/handle-request-files-content.js.map +1 -0
  240. package/dist/prompt/steps/step-iterate/handlers/handle-request-files-fragments.d.ts +8 -0
  241. package/dist/prompt/steps/step-iterate/handlers/handle-request-files-fragments.js +197 -0
  242. package/dist/prompt/steps/step-iterate/handlers/handle-request-files-fragments.js.map +1 -0
  243. package/dist/prompt/steps/step-iterate/handlers/handle-request-git-context.d.ts +3 -0
  244. package/dist/prompt/steps/step-iterate/handlers/handle-request-git-context.js +251 -0
  245. package/dist/prompt/steps/step-iterate/handlers/handle-request-git-context.js.map +1 -0
  246. package/dist/prompt/steps/step-iterate/handlers/handle-request-permissions.d.ts +2 -0
  247. package/dist/prompt/steps/step-iterate/handlers/handle-request-permissions.js +83 -0
  248. package/dist/prompt/steps/step-iterate/handlers/handle-request-permissions.js.map +1 -0
  249. package/dist/prompt/steps/step-iterate/handlers/handle-run-bash-command.d.ts +2 -0
  250. package/dist/prompt/steps/step-iterate/handlers/handle-run-bash-command.js +185 -0
  251. package/dist/prompt/steps/step-iterate/handlers/handle-run-bash-command.js.map +1 -0
  252. package/dist/prompt/steps/step-iterate/handlers/handle-run-container-task.d.ts +2 -0
  253. package/dist/prompt/steps/step-iterate/handlers/handle-run-container-task.js +7 -0
  254. package/dist/prompt/steps/step-iterate/handlers/handle-run-container-task.js.map +1 -0
  255. package/dist/prompt/steps/step-iterate/handlers/handle-search-code.d.ts +2 -0
  256. package/dist/prompt/steps/step-iterate/handlers/handle-search-code.js +96 -0
  257. package/dist/prompt/steps/step-iterate/handlers/handle-search-code.js.map +1 -0
  258. package/dist/prompt/steps/step-iterate/handlers/handle-send-message.d.ts +2 -0
  259. package/dist/prompt/steps/step-iterate/handlers/handle-send-message.js +21 -0
  260. package/dist/prompt/steps/step-iterate/handlers/handle-send-message.js.map +1 -0
  261. package/dist/prompt/steps/step-iterate/handlers/handle-structured-question.d.ts +1 -0
  262. package/dist/prompt/steps/step-iterate/handlers/handle-structured-question.js +72 -0
  263. package/dist/prompt/steps/step-iterate/handlers/handle-structured-question.js.map +1 -0
  264. package/dist/prompt/steps/step-iterate/handlers/handle-update-file.d.ts +2 -0
  265. package/dist/prompt/steps/step-iterate/handlers/handle-update-file.js +161 -0
  266. package/dist/prompt/steps/step-iterate/handlers/handle-update-file.js.map +1 -0
  267. package/dist/prompt/steps/step-iterate/handlers/handle-web-search.d.ts +1 -0
  268. package/dist/prompt/steps/step-iterate/handlers/handle-web-search.js +85 -0
  269. package/dist/prompt/steps/step-iterate/handlers/handle-web-search.js.map +1 -0
  270. package/dist/prompt/steps/step-iterate/iterate-handler.d.ts +4 -0
  271. package/dist/prompt/steps/step-iterate/iterate-handler.js +14 -0
  272. package/dist/prompt/steps/step-iterate/iterate-handler.js.map +1 -0
  273. package/dist/prompt/steps/step-iterate/step-iterate-handlers.d.ts +3 -0
  274. package/dist/prompt/steps/step-iterate/step-iterate-handlers.js +5 -0
  275. package/dist/prompt/steps/step-iterate/step-iterate-handlers.js.map +1 -0
  276. package/dist/prompt/steps/step-iterate/step-iterate-types.d.ts +255 -0
  277. package/dist/prompt/steps/step-iterate/step-iterate-types.js +2 -0
  278. package/dist/prompt/steps/step-iterate/step-iterate-types.js.map +1 -0
  279. package/dist/prompt/steps/step-iterate/step-iterate.d.ts +37 -0
  280. package/dist/prompt/steps/step-iterate/step-iterate.js +132 -0
  281. package/dist/prompt/steps/step-iterate/step-iterate.js.map +1 -0
  282. package/dist/prompt/steps/step-summarization.js +9 -19
  283. package/dist/prompt/steps/step-summarization.js.map +1 -1
  284. package/dist/prompt/systemprompt.js +93 -168
  285. package/dist/prompt/systemprompt.js.map +1 -1
  286. package/dist/prompt/token-estimator.js +1 -1
  287. package/dist/prompt/token-estimator.js.map +1 -1
  288. package/dist/vite-genaicode/console-interceptor.d.ts +19 -6
  289. package/dist/vite-genaicode/console-interceptor.js +45 -13
  290. package/dist/vite-genaicode/console-interceptor.js.map +1 -1
  291. package/dist/vite-genaicode/vite-genaicode-frontend.js +1 -1
  292. package/dist/vite-genaicode/vite-genaicode-frontend.js.map +1 -1
  293. package/package.json +7 -6
  294. package/dist/main/ui/frontend/assets/index-5-emJmrg.js +0 -2881
@@ -2,17 +2,20 @@ import { registerEndpoint } from '../api-handlers.js';
2
2
  registerEndpoint((router, service) => {
3
3
  router.post('/edit-message', async (req, res) => {
4
4
  try {
5
- const { messageId, newContent } = req.body;
5
+ const { messageId, newContent, newData } = req.body;
6
6
  if (!messageId || typeof messageId !== 'string') {
7
7
  return res.status(400).json({ error: 'Invalid message ID' });
8
8
  }
9
- if (!newContent || typeof newContent !== 'string') {
10
- return res.status(400).json({ error: 'Invalid message content' });
9
+ if (newContent === undefined && newData === undefined) {
10
+ return res.status(400).json({ error: 'Invalid message content or data' });
11
11
  }
12
- if (newContent.trim().length === 0) {
13
- return res.status(400).json({ error: 'Message content cannot be empty' });
12
+ // Allow empty content if newData is present (e.g. updating planning data)
13
+ if (newContent !== undefined && (typeof newContent !== 'string' || newContent.trim().length === 0)) {
14
+ if (!newData) {
15
+ return res.status(400).json({ error: 'Message content cannot be empty' });
16
+ }
14
17
  }
15
- const success = await service.editMessage(messageId, newContent);
18
+ const success = await service.editMessage(messageId, newContent, newData);
16
19
  if (success) {
17
20
  res.json({ message: 'Message edited successfully' });
18
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"edit-message-endpoint.js","sourceRoot":"","sources":["../../../../../src/main/ui/backend/endpoints/edit-message-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,gBAAgB,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;IACnC,MAAM,CAAC,IAAI,CAAC,eAAe,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QAC9C,IAAI,CAAC;YACH,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC,IAGrC,CAAC;YAEF,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;gBAChD,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,oBAAoB,EAAE,CAAC,CAAC;YAC/D,CAAC;YAED,IAAI,CAAC,UAAU,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;gBAClD,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,yBAAyB,EAAE,CAAC,CAAC;YACpE,CAAC;YAED,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACnC,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,iCAAiC,EAAE,CAAC,CAAC;YAC5E,CAAC;YAED,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;YAEjE,IAAI,OAAO,EAAE,CAAC;gBACZ,GAAG,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,6BAA6B,EAAE,CAAC,CAAC;YACvD,CAAC;iBAAM,CAAC;gBACN,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC,CAAC;YACvD,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;YAC/C,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;gBAC3B,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACjD,CAAC;iBAAM,CAAC;gBACN,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,6CAA6C,EAAE,CAAC,CAAC;YACjF,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"edit-message-endpoint.js","sourceRoot":"","sources":["../../../../../src/main/ui/backend/endpoints/edit-message-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,gBAAgB,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;IACnC,MAAM,CAAC,IAAI,CAAC,eAAe,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QAC9C,IAAI,CAAC;YACH,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC,IAI9C,CAAC;YAEF,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;gBAChD,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,oBAAoB,EAAE,CAAC,CAAC;YAC/D,CAAC;YAED,IAAI,UAAU,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;gBACtD,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,iCAAiC,EAAE,CAAC,CAAC;YAC5E,CAAC;YAED,0EAA0E;YAC1E,IAAI,UAAU,KAAK,SAAS,IAAI,CAAC,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC;gBACnG,IAAI,CAAC,OAAO,EAAE,CAAC;oBACb,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,iCAAiC,EAAE,CAAC,CAAC;gBAC5E,CAAC;YACH,CAAC;YAED,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;YAE1E,IAAI,OAAO,EAAE,CAAC;gBACZ,GAAG,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,6BAA6B,EAAE,CAAC,CAAC;YACvD,CAAC;iBAAM,CAAC;gBACN,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC,CAAC;YACvD,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;YAC/C,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;gBAC3B,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACjD,CAAC;iBAAM,CAAC;gBACN,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,6CAA6C,EAAE,CAAC,CAAC;YACjF,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -10,3 +10,4 @@ import './usage-endpoint.js';
10
10
  import './config-endpoint.js';
11
11
  import './iteration-endpoint.js';
12
12
  import './context-endpoint.js';
13
+ import './compress-context-endpoint.js';
@@ -10,4 +10,5 @@ import './usage-endpoint.js';
10
10
  import './config-endpoint.js';
11
11
  import './iteration-endpoint.js';
12
12
  import './context-endpoint.js';
13
+ import './compress-context-endpoint.js';
13
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/main/ui/backend/endpoints/index.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAC/B,OAAO,4BAA4B,CAAC;AACpC,OAAO,+BAA+B,CAAC;AACvC,OAAO,gCAAgC,CAAC;AACxC,OAAO,gCAAgC,CAAC;AACxC,OAAO,mCAAmC,CAAC;AAC3C,OAAO,qCAAqC,CAAC;AAC7C,OAAO,wBAAwB,CAAC;AAChC,OAAO,qBAAqB,CAAC;AAC7B,OAAO,sBAAsB,CAAC;AAC9B,OAAO,yBAAyB,CAAC;AACjC,OAAO,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/main/ui/backend/endpoints/index.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAC/B,OAAO,4BAA4B,CAAC;AACpC,OAAO,+BAA+B,CAAC;AACvC,OAAO,gCAAgC,CAAC;AACxC,OAAO,gCAAgC,CAAC;AACxC,OAAO,mCAAmC,CAAC;AAC3C,OAAO,qCAAqC,CAAC;AAC7C,OAAO,wBAAwB,CAAC;AAChC,OAAO,qBAAqB,CAAC;AAC7B,OAAO,sBAAsB,CAAC;AAC9B,OAAO,yBAAyB,CAAC;AACjC,OAAO,uBAAuB,CAAC;AAC/B,OAAO,gCAAgC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { registerEndpoint } from '../api-handlers.js';
2
- import { requestInterrupt } from '../../../../prompt/steps/step-ask-question/handlers/container-task/commands/interrupt-controller.js';
2
+ import { requestInterrupt } from '../../../../prompt/steps/step-iterate/handlers/container-task/commands/interrupt-controller.js';
3
3
  registerEndpoint((router, service) => {
4
4
  router.post('/interrupt-execution', async (req, res) => {
5
5
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"interrupt-execution-endpoint.js","sourceRoot":"","sources":["../../../../../src/main/ui/backend/endpoints/interrupt-execution-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qGAAqG,CAAC;AAEvI,gBAAgB,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;IACnC,MAAM,CAAC,IAAI,CAAC,sBAAsB,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QACrD,IAAI,CAAC;YACH,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC;YAE3B,IAAI,KAAK,KAAK,mBAAmB,EAAE,CAAC;gBAClC,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAC;gBAClC,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;oBACpB,GAAG,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,wDAAwD,EAAE,CAAC,CAAC;gBAClF,CAAC;qBAAM,CAAC;oBACN,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,qDAAqD,EAAE,CAAC,CAAC;gBACzF,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,+CAA+C;gBAC/C,MAAM,OAAO,CAAC,kBAAkB,EAAE,CAAC;gBACnC,GAAG,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,oCAAoC,EAAE,CAAC,CAAC;YAC9D,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;YACtD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,gDAAgD,EAAE,CAAC,CAAC;QACpF,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"interrupt-execution-endpoint.js","sourceRoot":"","sources":["../../../../../src/main/ui/backend/endpoints/interrupt-execution-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gGAAgG,CAAC;AAElI,gBAAgB,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;IACnC,MAAM,CAAC,IAAI,CAAC,sBAAsB,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QACrD,IAAI,CAAC;YACH,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC;YAE3B,IAAI,KAAK,KAAK,mBAAmB,EAAE,CAAC;gBAClC,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAC;gBAClC,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;oBACpB,GAAG,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,wDAAwD,EAAE,CAAC,CAAC;gBAClF,CAAC;qBAAM,CAAC;oBACN,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,qDAAqD,EAAE,CAAC,CAAC;gBACzF,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,+CAA+C;gBAC/C,MAAM,OAAO,CAAC,kBAAkB,EAAE,CAAC;gBACnC,GAAG,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,oCAAoC,EAAE,CAAC,CAAC;YAC9D,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;YACtD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,gDAAgD,EAAE,CAAC,CAAC;QACpF,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,14 +1,14 @@
1
1
  import { CodegenOptions } from '../../codegen-types.js';
2
2
  import { AiServiceType } from '../../../ai-service/service-configurations-types.js';
3
3
  import { RcConfig } from '../../config-types.js';
4
- import { ServiceConfigUpdate, SanitizedServiceConfigurations } from '../common/api-types.js';
4
+ import { ServiceConfigUpdate, SanitizedServiceConfigurations, ContextFile } from '../common/api-types.js';
5
5
  import { ContentProps } from '../../common/content-bus-types.js';
6
6
  import { UsageMetrics } from '../../common/cost-collector.js';
7
7
  import { CodegenResult, ConfirmationProps, Question } from '../common/api-types.js';
8
- import { FunctionCall, PromptImageMediaType, PromptItemImage } from '../../../ai-service/common-types.js';
8
+ import { FunctionCall, PromptImageMediaType, PromptItem, PromptItemImage } from '../../../ai-service/common-types.js';
9
9
  import { ModelType } from '../../../ai-service/common-types.js';
10
10
  import { AppContextProvider } from '../../common/app-context-bus.js';
11
- import { ActionType, StructuredQuestionForm, StructuredQuestionResponse } from '../../../prompt/steps/step-ask-question/step-ask-question-types.js';
11
+ import { ActionType, StructuredQuestionForm, StructuredQuestionResponse } from '../../../prompt/steps/step-iterate/step-iterate-types.js';
12
12
  export interface ImageData {
13
13
  buffer: Buffer;
14
14
  mimetype: PromptImageMediaType;
@@ -17,23 +17,28 @@ export interface ImageData {
17
17
  export declare class Service implements AppContextProvider {
18
18
  private executionStatus;
19
19
  private currentQuestion;
20
- private askQuestionConversation;
20
+ private iterateConversation;
21
21
  private codegenOptions;
22
22
  private content;
23
23
  private pausePromiseResolve;
24
24
  private securityToken;
25
+ private getContext;
25
26
  private contextStorage;
26
- constructor(codegenOptions: CodegenOptions);
27
+ constructor(codegenOptions: CodegenOptions, getContext: () => PromptItem[]);
28
+ /**
29
+ * Expose the current prompt context items (PromptItem[])
30
+ */
31
+ getPromptContext(): PromptItem[];
27
32
  /**
28
33
  * Edit a message in the conversation
29
34
  * @param messageId ID of the message to edit
30
35
  * @param newContent New content for the message
36
+ * @param newData New data for the message (optional)
31
37
  * @returns true if the message was successfully edited, false otherwise
32
38
  * @throws Error if the message ID is invalid or if editing is not allowed
33
39
  */
34
- editMessage(messageId: string, newContent: string): Promise<boolean>;
40
+ editMessage(messageId: string, newContent: string, newData?: Record<string, unknown>): Promise<boolean>;
35
41
  /**
36
- * Get service configurations in a safe format that excludes sensitive data.
37
42
  * This method is used by external API endpoints.
38
43
  */
39
44
  getServiceConfigurations(): SanitizedServiceConfigurations;
@@ -52,6 +57,40 @@ export declare class Service implements AppContextProvider {
52
57
  interruptExecution(): Promise<void>;
53
58
  pauseExecution(): Promise<void>;
54
59
  resumeExecution(): Promise<void>;
60
+ /**
61
+ * Optimize the current context
62
+ */
63
+ optimizeContext(): Promise<{
64
+ success: boolean;
65
+ message?: string;
66
+ stats?: {
67
+ tokensBefore: number;
68
+ tokensAfter: number;
69
+ savings: number;
70
+ percentage: number;
71
+ };
72
+ }>;
73
+ /**
74
+ * Compress the current context
75
+ */
76
+ compressContext(): Promise<{
77
+ success: boolean;
78
+ message?: string;
79
+ stats?: {
80
+ tokensBefore: number;
81
+ tokensAfter: number;
82
+ savings: number;
83
+ percentage: number;
84
+ };
85
+ }>;
86
+ getContextPreview(): Promise<{
87
+ preview: {
88
+ type: string;
89
+ summary: string;
90
+ tokenCount: number;
91
+ }[];
92
+ totalTokens: number;
93
+ }>;
55
94
  getExecutionStatus(): Promise<string>;
56
95
  getCurrentQuestion(): Promise<Question | null>;
57
96
  askQuestion(question: string, confirmation: ConfirmationProps): Promise<{
@@ -94,4 +133,26 @@ export declare class Service implements AppContextProvider {
94
133
  * Clear all context values
95
134
  */
96
135
  clearAllContext(): Promise<void>;
136
+ /**
137
+ * Get list of files currently in the conversation context
138
+ * @returns Array of unique file paths
139
+ */
140
+ getContextFiles(): Promise<ContextFile[]>;
141
+ /**
142
+ * Remove files from the conversation context by setting their content to null
143
+ * @param filePaths Array of file paths to remove
144
+ * @returns Number of files removed
145
+ */
146
+ removeFilesFromContext(filePaths: string[]): Promise<number>;
147
+ /**
148
+ * Get all project files (not just those in context)
149
+ * @returns Array of file paths
150
+ */
151
+ getAllProjectFiles(): Promise<string[]>;
152
+ /**
153
+ * Add files to the conversation context by fetching their content
154
+ * @param filePaths Array of file paths to add
155
+ * @returns Number of files added
156
+ */
157
+ addFilesToContext(filePaths: string[]): Promise<number>;
97
158
  }
@@ -5,54 +5,90 @@ import { abortController } from '../../common/abort-controller.js';
5
5
  import { getUsageMetrics } from '../../common/cost-collector.js';
6
6
  import { editMessage, putSystemMessage } from '../../common/content-bus.js';
7
7
  import { getGenerateContentFunctions } from '../../codegen.js';
8
- import { ModelType } from '../../../ai-service/common-types.js';
9
8
  import { getSanitizedServiceConfigurations, updateServiceConfig } from '../../../ai-service/service-configurations.js';
9
+ import { estimateTokenCount } from '../../../prompt/token-estimator.js';
10
+ import { executeStepContextOptimization } from '../../../prompt/steps/step-context-optimization.js';
11
+ import { executeStepContextCompression } from '../../../prompt/steps/step-context-compression.js';
12
+ import { getFilesContextSizeFromPrompt } from '../../../prompt/context-utils.js';
10
13
  export class Service {
11
14
  executionStatus = 'idle';
12
15
  currentQuestion = null;
13
- askQuestionConversation = [];
16
+ iterateConversation = [];
14
17
  codegenOptions;
15
18
  content = [];
16
19
  pausePromiseResolve = null;
17
20
  securityToken;
21
+ getContext = () => [];
18
22
  // Context storage for managing application context
19
23
  contextStorage = new Map();
20
- constructor(codegenOptions) {
24
+ constructor(codegenOptions, getContext) {
21
25
  this.codegenOptions = codegenOptions;
22
26
  this.securityToken = this.generateToken();
27
+ this.getContext = getContext;
28
+ }
29
+ /**
30
+ * Expose the current prompt context items (PromptItem[])
31
+ */
32
+ getPromptContext() {
33
+ return this.getContext();
23
34
  }
24
35
  /**
25
36
  * Edit a message in the conversation
26
37
  * @param messageId ID of the message to edit
27
38
  * @param newContent New content for the message
39
+ * @param newData New data for the message (optional)
28
40
  * @returns true if the message was successfully edited, false otherwise
29
41
  * @throws Error if the message ID is invalid or if editing is not allowed
30
42
  */
31
- async editMessage(messageId, newContent) {
43
+ async editMessage(messageId, newContent, newData) {
32
44
  // Basic input validation
33
- if (!messageId || !newContent.trim()) {
34
- throw new Error('Invalid message ID or content');
45
+ if (!messageId || (newContent === undefined && newData === undefined)) {
46
+ throw new Error('Invalid message ID, content or data');
35
47
  }
36
48
  // Find the message in the content array
37
49
  const contentItem = this.content.find((item) => item.message?.id === messageId);
38
50
  if (!contentItem || !contentItem.message) {
39
51
  throw new Error('Message not found');
40
52
  }
41
- // Check if editing is allowed for this message type
42
- if (contentItem.message.type === 'system') {
43
- throw new Error('System messages cannot be edited');
44
- }
45
53
  // Check if the message is from an ongoing iteration
46
54
  const currentIterationId = this.getCurrentIterationId();
47
55
  if (contentItem.message.iterationId !== currentIterationId || this.executionStatus === 'idle') {
48
56
  throw new Error('Can only edit messages from the currently ongoing iteration');
49
57
  }
58
+ // Prevent editing after submit (when no question is active)
59
+ if (!this.currentQuestion) {
60
+ throw new Error('Cannot edit message after it has been submitted or when no question is active');
61
+ }
62
+ // Apply newData if provided
63
+ if (newData !== undefined && contentItem.message) {
64
+ // Validate codegenPlanning data structure
65
+ if (newData.name === 'codegenPlanning') {
66
+ const args = newData.args;
67
+ if (!args ||
68
+ typeof args.problemAnalysis !== 'string' ||
69
+ typeof args.codeChanges !== 'string' ||
70
+ !Array.isArray(args.affectedFiles)) {
71
+ throw new Error('Invalid codegenPlanning data structure');
72
+ }
73
+ }
74
+ // Validate codegenSummary data structure
75
+ else if (newData.name === 'codegenSummary') {
76
+ const args = newData.args;
77
+ if (!args ||
78
+ typeof args.explanation !== 'string' ||
79
+ !Array.isArray(args.fileUpdates) ||
80
+ !Array.isArray(args.contextPaths)) {
81
+ throw new Error('Invalid codegenSummary data structure');
82
+ }
83
+ }
84
+ contentItem.message.data = newData;
85
+ contentItem.data = newData;
86
+ }
50
87
  // Try to edit the message using content bus
51
- const success = editMessage(contentItem, newContent);
88
+ const success = editMessage(contentItem, newContent !== undefined ? newContent : contentItem.message.content, newData);
52
89
  return success;
53
90
  }
54
91
  /**
55
- * Get service configurations in a safe format that excludes sensitive data.
56
92
  * This method is used by external API endpoints.
57
93
  */
58
94
  getServiceConfigurations() {
@@ -134,20 +170,18 @@ export class Service {
134
170
  text: prompt,
135
171
  },
136
172
  ], {
137
- functionDefs: modelType === ModelType.REASONING
138
- ? []
139
- : [
140
- {
141
- name: 'printMessage',
142
- description: 'Print a message',
143
- parameters: {
144
- type: 'object',
145
- properties: { message: { type: 'string' } },
146
- required: ['message'],
147
- },
173
+ functionDefs: [
174
+ {
175
+ name: 'printMessage',
176
+ description: 'Print a message',
177
+ parameters: {
178
+ type: 'object',
179
+ properties: { message: { type: 'string' } },
180
+ required: ['message'],
148
181
  },
149
- ],
150
- requiredFunctionName: modelType === ModelType.REASONING ? 'reasoningInferenceResponse' : 'printMessage',
182
+ },
183
+ ],
184
+ requiredFunctionName: 'printMessage',
151
185
  temperature,
152
186
  modelType,
153
187
  expectedResponseType: {
@@ -187,6 +221,127 @@ export class Service {
187
221
  }
188
222
  }
189
223
  }
224
+ /**
225
+ * Optimize the current context
226
+ */
227
+ async optimizeContext() {
228
+ try {
229
+ const prompt = this.getContext();
230
+ const generateContentFns = getGenerateContentFunctions();
231
+ const generateContentFn = generateContentFns[this.codegenOptions.aiService];
232
+ if (!generateContentFn) {
233
+ throw new Error(`AI service ${this.codegenOptions.aiService} is not available`);
234
+ }
235
+ // Estimate tokens before
236
+ const tokensBefore = estimateTokenCount(JSON.stringify(prompt));
237
+ // Execute optimization
238
+ await executeStepContextOptimization(generateContentFn, prompt, this.codegenOptions);
239
+ // Estimate tokens after
240
+ const tokensAfter = estimateTokenCount(JSON.stringify(prompt));
241
+ const filesContextSize = getFilesContextSizeFromPrompt(prompt);
242
+ putSystemMessage('Context optimization applied', { filesContextSize, contextSize: tokensAfter });
243
+ return {
244
+ success: true,
245
+ stats: {
246
+ tokensBefore,
247
+ tokensAfter,
248
+ savings: tokensBefore - tokensAfter,
249
+ percentage: tokensBefore > 0 ? Math.round(((tokensBefore - tokensAfter) / tokensBefore) * 100) : 0,
250
+ },
251
+ };
252
+ }
253
+ catch (error) {
254
+ console.error('Error optimizing context:', error);
255
+ return {
256
+ success: false,
257
+ message: error instanceof Error ? error.message : 'Unknown error during context optimization',
258
+ };
259
+ }
260
+ }
261
+ /**
262
+ * Compress the current context
263
+ */
264
+ async compressContext() {
265
+ try {
266
+ const prompt = this.getContext();
267
+ const generateContentFns = getGenerateContentFunctions();
268
+ const generateContentFn = generateContentFns[this.codegenOptions.aiService];
269
+ if (!generateContentFn) {
270
+ throw new Error(`AI service ${this.codegenOptions.aiService} is not available`);
271
+ }
272
+ // Estimate tokens before
273
+ const tokensBefore = estimateTokenCount(JSON.stringify(prompt));
274
+ // Execute compression
275
+ await executeStepContextCompression(generateContentFn, prompt, this.codegenOptions);
276
+ // Estimate tokens after
277
+ const tokensAfter = estimateTokenCount(JSON.stringify(prompt));
278
+ const filesContextSize = getFilesContextSizeFromPrompt(prompt);
279
+ putSystemMessage('Context compression applied', {
280
+ tokensBefore,
281
+ tokensAfter,
282
+ filesContextSize,
283
+ contextSize: tokensAfter,
284
+ });
285
+ return {
286
+ success: true,
287
+ stats: {
288
+ tokensBefore,
289
+ tokensAfter,
290
+ savings: tokensBefore - tokensAfter,
291
+ percentage: tokensBefore > 0 ? Math.round(((tokensBefore - tokensAfter) / tokensBefore) * 100) : 0,
292
+ },
293
+ };
294
+ }
295
+ catch (error) {
296
+ console.error('Error compressing context:', error);
297
+ return {
298
+ success: false,
299
+ message: error instanceof Error ? error.message : 'Unknown error during context compression',
300
+ };
301
+ }
302
+ }
303
+ async getContextPreview() {
304
+ const prompt = this.getContext();
305
+ const preview = prompt.map((item) => {
306
+ let summary = '';
307
+ if (item.type === 'user') {
308
+ const text = item.text ?? '';
309
+ summary = text ? text.substring(0, 100) + (text.length > 100 ? '...' : '') : 'User Input';
310
+ if (Array.isArray(item.images) && item.images.length > 0) {
311
+ summary += ` [${item.images.length} images]`;
312
+ }
313
+ if (item.functionResponses?.length) {
314
+ const name = item.functionResponses.map((fr) => fr.name).join(', ');
315
+ summary += ` Function Response${name ? `: ${name}` : ''}`;
316
+ }
317
+ }
318
+ else if (item.type === 'assistant') {
319
+ // assistant may contain text and/or functionCalls
320
+ const text = item.text;
321
+ if (text) {
322
+ summary = text.substring(0, 100) + (text.length > 100 ? '...' : '');
323
+ }
324
+ else if (Array.isArray(item.functionCalls)) {
325
+ const names = item.functionCalls.map((fc) => fc?.name).filter(Boolean);
326
+ summary = names.length ? `Assistant: ${names.join(', ')}` : 'Assistant';
327
+ }
328
+ else {
329
+ summary = 'Assistant';
330
+ }
331
+ }
332
+ else if (item.type === 'systemPrompt') {
333
+ const text = item.text;
334
+ summary = text ? text.substring(0, 100) + (text.length > 100 ? '...' : '') : 'System Prompt';
335
+ }
336
+ return {
337
+ type: item.type,
338
+ summary,
339
+ tokenCount: estimateTokenCount(JSON.stringify(item)),
340
+ };
341
+ });
342
+ const totalTokens = estimateTokenCount(JSON.stringify(prompt));
343
+ return { preview, totalTokens };
344
+ }
190
345
  async getExecutionStatus() {
191
346
  return this.executionStatus;
192
347
  }
@@ -202,7 +357,7 @@ export class Service {
202
357
  };
203
358
  await this.waitForQuestionAnswer();
204
359
  console.log('Question answer wait finished.');
205
- const conversationItem = this.askQuestionConversation.find((q) => q.id === questionId);
360
+ const conversationItem = this.iterateConversation.find((q) => q.id === questionId);
206
361
  if (!conversationItem) {
207
362
  // Should ideally not happen if waitForQuestionAnswer resolved correctly
208
363
  throw new Error(`Conversation item not found for question ID: ${questionId}`);
@@ -220,7 +375,7 @@ export class Service {
220
375
  };
221
376
  await this.waitForQuestionAnswer();
222
377
  console.log('Structured question answer wait finished.');
223
- const conversationItem = this.askQuestionConversation.find((q) => q.id === questionId);
378
+ const conversationItem = this.iterateConversation.find((q) => q.id === questionId);
224
379
  if (!conversationItem || !conversationItem.structuredResponse) {
225
380
  // Should ideally not happen if waitForQuestionAnswer resolved correctly
226
381
  throw new Error(`Conversation item or structured response not found for question ID: ${questionId}`);
@@ -240,7 +395,7 @@ export class Service {
240
395
  mediaType: image.mimetype,
241
396
  }));
242
397
  // Store the answer and processed images in the conversation history
243
- this.askQuestionConversation.push({
398
+ this.iterateConversation.push({
244
399
  id: this.currentQuestion.id,
245
400
  question: this.currentQuestion.text,
246
401
  answer: answer,
@@ -345,5 +500,123 @@ export class Service {
345
500
  async clearAllContext() {
346
501
  this.contextStorage.clear();
347
502
  }
503
+ /**
504
+ * Get list of files currently in the conversation context
505
+ * @returns Array of unique file paths
506
+ */
507
+ async getContextFiles() {
508
+ const contextFilesMap = new Map();
509
+ for (const item of this.getContext()) {
510
+ for (const response of item.functionResponses ?? []) {
511
+ if (response.name === 'getSourceCode' && response.content) {
512
+ try {
513
+ const sourceCode = JSON.parse(response.content);
514
+ for (const [filePath, fileData] of Object.entries(sourceCode)) {
515
+ if (fileData && typeof fileData === 'object' && 'content' in fileData && fileData.content !== null) {
516
+ const content = String(fileData.content);
517
+ const tokenCount = estimateTokenCount(content);
518
+ contextFilesMap.set(filePath, tokenCount);
519
+ }
520
+ }
521
+ }
522
+ catch (error) {
523
+ console.warn('Failed to parse getSourceCode response while fetching context files:', error);
524
+ }
525
+ }
526
+ }
527
+ }
528
+ return Array.from(contextFilesMap.entries())
529
+ .map(([path, tokenCount]) => ({ path, tokenCount }))
530
+ .sort((a, b) => a.path.localeCompare(b.path));
531
+ }
532
+ /**
533
+ * Remove files from the conversation context by setting their content to null
534
+ * @param filePaths Array of file paths to remove
535
+ * @returns Number of files removed
536
+ */
537
+ async removeFilesFromContext(filePaths) {
538
+ if (!Array.isArray(filePaths) || filePaths.length === 0) {
539
+ return 0;
540
+ }
541
+ const filesToRemove = new Set(filePaths);
542
+ const removedFiles = new Set();
543
+ for (const item of this.getContext()) {
544
+ for (const response of item.functionResponses ?? []) {
545
+ if (response.name === 'getSourceCode' && response.content) {
546
+ try {
547
+ const sourceCode = JSON.parse(response.content);
548
+ let modified = false;
549
+ for (const filePath of filesToRemove) {
550
+ if (sourceCode[filePath] &&
551
+ typeof sourceCode[filePath] === 'object' &&
552
+ 'content' in sourceCode[filePath] &&
553
+ sourceCode[filePath].content !== null) {
554
+ sourceCode[filePath].content = null;
555
+ removedFiles.add(filePath);
556
+ modified = true;
557
+ }
558
+ }
559
+ if (modified) {
560
+ response.content = JSON.stringify(sourceCode);
561
+ }
562
+ }
563
+ catch (error) {
564
+ console.warn('Failed to parse getSourceCode response while removing context files:', error);
565
+ }
566
+ }
567
+ }
568
+ }
569
+ if (removedFiles.size > 0) {
570
+ const filesContextSize = getFilesContextSizeFromPrompt(this.getContext());
571
+ putSystemMessage('Context reduction applied', { removed: Array.from(removedFiles), filesContextSize });
572
+ }
573
+ return removedFiles.size;
574
+ }
575
+ /**
576
+ * Get all project files (not just those in context)
577
+ * @returns Array of file paths
578
+ */
579
+ async getAllProjectFiles() {
580
+ const { getSourceFiles } = await import('../../../files/find-files.js');
581
+ return getSourceFiles();
582
+ }
583
+ /**
584
+ * Add files to the conversation context by fetching their content
585
+ * @param filePaths Array of file paths to add
586
+ * @returns Number of files added
587
+ */
588
+ async addFilesToContext(filePaths) {
589
+ if (!Array.isArray(filePaths) || filePaths.length === 0) {
590
+ return 0;
591
+ }
592
+ const { getSourceCode } = await import('../../../files/read-files.js');
593
+ const { putSystemMessage } = await import('../../common/content-bus.js');
594
+ try {
595
+ // Fetch the content of the requested files
596
+ const sourceCode = getSourceCode({ filterPaths: filePaths, forceAll: true }, this.codegenOptions);
597
+ // Create a getSourceCode function response and inject it into the context
598
+ const functionResponse = {
599
+ name: 'getSourceCode',
600
+ content: JSON.stringify(sourceCode),
601
+ };
602
+ // Find the most recent prompt item in the context to attach the response
603
+ const contextItems = this.getContext();
604
+ if (contextItems.length > 0) {
605
+ const lastItem = contextItems[contextItems.length - 1];
606
+ if (!lastItem.functionResponses) {
607
+ lastItem.functionResponses = [];
608
+ }
609
+ lastItem.functionResponses.push(functionResponse);
610
+ }
611
+ const addedCount = filePaths.length;
612
+ const filesContextSize = getFilesContextSizeFromPrompt(this.getContext());
613
+ putSystemMessage('Files added to context', { added: filePaths, filesContextSize });
614
+ return addedCount;
615
+ }
616
+ catch (error) {
617
+ console.error('Failed to add files to context:', error);
618
+ throw error;
619
+ }
620
+ }
348
621
  }
349
622
  //# sourceMappingURL=service.js.map