genaicode 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (626) hide show
  1. package/README.md +6 -10
  2. package/dist/ai-service/anthropic.js +7 -2
  3. package/dist/ai-service/anthropic.js.map +1 -1
  4. package/dist/ai-service/chat-gpt.d.ts +2 -0
  5. package/dist/ai-service/chat-gpt.js +7 -4
  6. package/dist/ai-service/chat-gpt.js.map +1 -1
  7. package/dist/ai-service/common.test.js +2 -1
  8. package/dist/ai-service/common.test.js.map +1 -1
  9. package/dist/ai-service/dall-e.js +1 -0
  10. package/dist/ai-service/dall-e.js.map +1 -1
  11. package/dist/ai-service/vertex-ai-claude.js +1 -0
  12. package/dist/ai-service/vertex-ai-claude.js.map +1 -1
  13. package/dist/cli/cli-options.js +10 -22
  14. package/dist/cli/cli-options.js.map +1 -1
  15. package/dist/cli/cli-params.d.ts +1 -5
  16. package/dist/cli/cli-params.js +10 -29
  17. package/dist/cli/cli-params.js.map +1 -1
  18. package/dist/cli/validate-cli-params.js +16 -11
  19. package/dist/cli/validate-cli-params.js.map +1 -1
  20. package/dist/cli/validate-cli-params.test.js +2 -2
  21. package/dist/cli/validate-cli-params.test.js.map +1 -1
  22. package/dist/examples/genaicode_plugins/fake_ai_service.d.ts +3 -0
  23. package/dist/examples/genaicode_plugins/fake_ai_service.js +11 -0
  24. package/dist/examples/genaicode_plugins/fake_ai_service.js.map +1 -0
  25. package/dist/examples/genaicode_plugins/grok_ai_service.d.ts +3 -0
  26. package/dist/examples/genaicode_plugins/grok_ai_service.js +153 -0
  27. package/dist/examples/genaicode_plugins/grok_ai_service.js.map +1 -0
  28. package/dist/examples/genaicode_plugins/nonsense_operation.d.ts +3 -0
  29. package/dist/examples/genaicode_plugins/nonsense_operation.js +23 -0
  30. package/dist/examples/genaicode_plugins/nonsense_operation.js.map +1 -0
  31. package/dist/files/path-utils.d.ts +1 -0
  32. package/dist/files/path-utils.js +12 -0
  33. package/dist/files/path-utils.js.map +1 -0
  34. package/dist/files/update-files.d.ts +1 -1
  35. package/dist/files/update-files.js +8 -183
  36. package/dist/files/update-files.js.map +1 -1
  37. package/dist/index.d.ts +6 -1
  38. package/dist/index.js +6 -0
  39. package/dist/index.js.map +1 -1
  40. package/dist/main/codegen-types.d.ts +29 -1
  41. package/dist/main/codegen-utils.d.ts +3 -0
  42. package/dist/main/codegen-utils.js +18 -0
  43. package/dist/main/codegen-utils.js.map +1 -0
  44. package/dist/main/codegen.js +14 -25
  45. package/dist/main/codegen.js.map +1 -1
  46. package/dist/main/codegen.test.js +12 -15
  47. package/dist/main/codegen.test.js.map +1 -1
  48. package/dist/main/common/user-actions.d.ts +14 -2
  49. package/dist/main/common/user-actions.js +16 -1
  50. package/dist/main/common/user-actions.js.map +1 -1
  51. package/dist/main/config-lib.d.ts +1 -0
  52. package/dist/main/config-lib.js +7 -0
  53. package/dist/main/config-lib.js.map +1 -1
  54. package/dist/main/config.js +3 -0
  55. package/dist/main/config.js.map +1 -1
  56. package/dist/main/interactive/user-action-handlers.js +2 -2
  57. package/dist/main/interactive/user-action-handlers.js.map +1 -1
  58. package/dist/main/plugin-loader.d.ts +9 -0
  59. package/dist/main/plugin-loader.js +55 -0
  60. package/dist/main/plugin-loader.js.map +1 -0
  61. package/dist/main/ui/backend/api-utils.js +2 -2
  62. package/dist/main/ui/backend/api-utils.js.map +1 -1
  63. package/dist/main/ui/backend/api.js +15 -3
  64. package/dist/main/ui/backend/api.js.map +1 -1
  65. package/dist/main/ui/backend/service.d.ts +6 -11
  66. package/dist/main/ui/backend/service.js +11 -7
  67. package/dist/main/ui/backend/service.js.map +1 -1
  68. package/dist/main/ui/common/api-types.d.ts +20 -0
  69. package/dist/main/ui/common/api-types.js +2 -0
  70. package/dist/main/ui/common/api-types.js.map +1 -0
  71. package/dist/main/ui/frontend/assets/{index-Dicb_1yw.js → index-Dk_qaEQg.js} +75 -72
  72. package/dist/main/ui/frontend/index.html +1 -1
  73. package/dist/main/ui/user-action-handlers.js +9 -4
  74. package/dist/main/ui/user-action-handlers.js.map +1 -1
  75. package/dist/operations/create-directory/create-directory-def.d.ts +9 -0
  76. package/dist/operations/create-directory/create-directory-def.js +22 -0
  77. package/dist/operations/create-directory/create-directory-def.js.map +1 -0
  78. package/dist/operations/create-directory/create-directory-executor.d.ts +6 -0
  79. package/dist/operations/create-directory/create-directory-executor.js +22 -0
  80. package/dist/operations/create-directory/create-directory-executor.js.map +1 -0
  81. package/dist/operations/create-file/create-file-def.d.ts +10 -0
  82. package/dist/operations/create-file/create-file-def.js +26 -0
  83. package/dist/operations/create-file/create-file-def.js.map +1 -0
  84. package/dist/operations/create-file/create-file-executor.d.ts +6 -0
  85. package/dist/operations/create-file/create-file-executor.js +27 -0
  86. package/dist/operations/create-file/create-file-executor.js.map +1 -0
  87. package/dist/operations/delete-file/delete-file-def.d.ts +9 -0
  88. package/dist/operations/delete-file/delete-file-def.js +22 -0
  89. package/dist/operations/delete-file/delete-file-def.js.map +1 -0
  90. package/dist/operations/delete-file/delete-file-executor.d.ts +6 -0
  91. package/dist/operations/delete-file/delete-file-executor.js +23 -0
  92. package/dist/operations/delete-file/delete-file-executor.js.map +1 -0
  93. package/dist/operations/download-file/download-file-def.d.ts +10 -0
  94. package/dist/operations/download-file/download-file-def.js +26 -0
  95. package/dist/operations/download-file/download-file-def.js.map +1 -0
  96. package/dist/operations/download-file/download-file-executor.d.ts +6 -0
  97. package/dist/operations/download-file/download-file-executor.js +44 -0
  98. package/dist/operations/download-file/download-file-executor.js.map +1 -0
  99. package/dist/operations/imgly-remove-background/imgly-remove-background-def.d.ts +10 -0
  100. package/dist/operations/imgly-remove-background/imgly-remove-background-def.js +26 -0
  101. package/dist/operations/imgly-remove-background/imgly-remove-background-def.js.map +1 -0
  102. package/dist/operations/imgly-remove-background/imgly-remove-background-executor.d.ts +6 -0
  103. package/dist/operations/imgly-remove-background/imgly-remove-background-executor.js +40 -0
  104. package/dist/operations/imgly-remove-background/imgly-remove-background-executor.js.map +1 -0
  105. package/dist/operations/move-file/move-file-def.d.ts +10 -0
  106. package/dist/operations/move-file/move-file-def.js +26 -0
  107. package/dist/operations/move-file/move-file-def.js.map +1 -0
  108. package/dist/operations/move-file/move-file-executor.d.ts +6 -0
  109. package/dist/operations/move-file/move-file-executor.js +29 -0
  110. package/dist/operations/move-file/move-file-executor.js.map +1 -0
  111. package/dist/operations/operations-index.d.ts +3 -0
  112. package/dist/operations/operations-index.js +33 -0
  113. package/dist/operations/operations-index.js.map +1 -0
  114. package/dist/operations/patch-file/patch-file-def.d.ts +10 -0
  115. package/dist/operations/patch-file/patch-file-def.js +39 -0
  116. package/dist/operations/patch-file/patch-file-def.js.map +1 -0
  117. package/dist/operations/patch-file/patch-file-executor.d.ts +5 -0
  118. package/dist/operations/patch-file/patch-file-executor.js +26 -0
  119. package/dist/operations/patch-file/patch-file-executor.js.map +1 -0
  120. package/dist/operations/resize-image/resize-image-def.d.ts +13 -0
  121. package/dist/operations/resize-image/resize-image-def.js +37 -0
  122. package/dist/operations/resize-image/resize-image-def.js.map +1 -0
  123. package/dist/operations/resize-image/resize-image-executor.d.ts +5 -0
  124. package/dist/operations/resize-image/resize-image-executor.js +30 -0
  125. package/dist/operations/resize-image/resize-image-executor.js.map +1 -0
  126. package/dist/operations/split-image/split-image-def.d.ts +18 -0
  127. package/dist/operations/split-image/split-image-def.js +46 -0
  128. package/dist/operations/split-image/split-image-def.js.map +1 -0
  129. package/dist/operations/split-image/split-image-executor.d.ts +6 -0
  130. package/dist/operations/split-image/split-image-executor.js +51 -0
  131. package/dist/operations/split-image/split-image-executor.js.map +1 -0
  132. package/dist/operations/update-file/update-file-def.d.ts +10 -0
  133. package/dist/operations/update-file/update-file-def.js +26 -0
  134. package/dist/operations/update-file/update-file-def.js.map +1 -0
  135. package/dist/operations/update-file/update-file-executor.d.ts +5 -0
  136. package/dist/operations/update-file/update-file-executor.js +22 -0
  137. package/dist/operations/update-file/update-file-executor.js.map +1 -0
  138. package/dist/prompt/ai-service-fallback.js.map +1 -1
  139. package/dist/prompt/function-calling-validate.js +2 -2
  140. package/dist/prompt/function-calling-validate.js.map +1 -1
  141. package/dist/prompt/function-calling.d.ts +1 -1
  142. package/dist/prompt/function-calling.js +29 -44
  143. package/dist/prompt/function-calling.js.map +1 -1
  144. package/dist/prompt/function-defs/ask-question-reflect.d.ts +2 -20
  145. package/dist/prompt/function-defs/ask-question-reflect.js.map +1 -1
  146. package/dist/prompt/function-defs/ask-question.d.ts +2 -73
  147. package/dist/prompt/function-defs/ask-question.js +28 -14
  148. package/dist/prompt/function-defs/ask-question.js.map +1 -1
  149. package/dist/prompt/function-defs/codegen-summary.d.ts +2 -62
  150. package/dist/prompt/function-defs/codegen-summary.js +4 -2
  151. package/dist/prompt/function-defs/codegen-summary.js.map +1 -1
  152. package/dist/prompt/function-defs/explanation.d.ts +2 -14
  153. package/dist/prompt/function-defs/explanation.js.map +1 -1
  154. package/dist/prompt/function-defs/generate-image.d.ts +2 -38
  155. package/dist/prompt/function-defs/generate-image.js.map +1 -1
  156. package/dist/prompt/function-defs/get-image-assets.d.ts +2 -17
  157. package/dist/prompt/function-defs/get-image-assets.js.map +1 -1
  158. package/dist/prompt/function-defs/get-source-code.d.ts +2 -17
  159. package/dist/prompt/function-defs/get-source-code.js.map +1 -1
  160. package/dist/prompt/function-defs/optimize-context.d.ts +2 -43
  161. package/dist/prompt/function-defs/optimize-context.js.map +1 -1
  162. package/dist/prompt/function-defs/read-history.d.ts +2 -13
  163. package/dist/prompt/function-defs/read-history.js.map +1 -1
  164. package/dist/prompt/function-defs/set-summaries.d.ts +2 -28
  165. package/dist/prompt/function-defs/set-summaries.js.map +1 -1
  166. package/dist/prompt/function-defs/update-history.d.ts +2 -18
  167. package/dist/prompt/function-defs/update-history.js.map +1 -1
  168. package/dist/prompt/prompt-service.js +6 -6
  169. package/dist/prompt/prompt-service.js.map +1 -1
  170. package/dist/prompt/prompt-service.test.js +16 -19
  171. package/dist/prompt/prompt-service.test.js.map +1 -1
  172. package/dist/prompt/steps/step-ask-question/handlers/cancel-code-generation.d.ts +2 -0
  173. package/dist/prompt/steps/step-ask-question/handlers/cancel-code-generation.js +16 -0
  174. package/dist/prompt/steps/step-ask-question/handlers/cancel-code-generation.js.map +1 -0
  175. package/dist/prompt/steps/step-ask-question/handlers/confirm-code-generation.d.ts +2 -0
  176. package/dist/prompt/steps/step-ask-question/handlers/confirm-code-generation.js +37 -0
  177. package/dist/prompt/steps/step-ask-question/handlers/confirm-code-generation.js.map +1 -0
  178. package/dist/prompt/steps/step-ask-question/handlers/context-optimization.d.ts +2 -0
  179. package/dist/prompt/steps/step-ask-question/handlers/context-optimization.js +36 -0
  180. package/dist/prompt/steps/step-ask-question/handlers/context-optimization.js.map +1 -0
  181. package/dist/prompt/steps/step-ask-question/handlers/default-action.d.ts +2 -0
  182. package/dist/prompt/steps/step-ask-question/handlers/default-action.js +18 -0
  183. package/dist/prompt/steps/step-ask-question/handlers/default-action.js.map +1 -0
  184. package/dist/prompt/steps/step-ask-question/handlers/handle-request-answer.d.ts +2 -0
  185. package/dist/prompt/steps/step-ask-question/handlers/handle-request-answer.js +20 -0
  186. package/dist/prompt/steps/step-ask-question/handlers/handle-request-answer.js.map +1 -0
  187. package/dist/prompt/steps/step-ask-question/handlers/remove-files-from-context.d.ts +2 -0
  188. package/dist/prompt/steps/step-ask-question/handlers/remove-files-from-context.js +43 -0
  189. package/dist/prompt/steps/step-ask-question/handlers/remove-files-from-context.js.map +1 -0
  190. package/dist/prompt/steps/step-ask-question/handlers/request-files-content.d.ts +2 -0
  191. package/dist/prompt/steps/step-ask-question/handlers/request-files-content.js +49 -0
  192. package/dist/prompt/steps/step-ask-question/handlers/request-files-content.js.map +1 -0
  193. package/dist/prompt/steps/step-ask-question/handlers/request-permissions.d.ts +2 -0
  194. package/dist/prompt/steps/step-ask-question/handlers/request-permissions.js +46 -0
  195. package/dist/prompt/steps/step-ask-question/handlers/request-permissions.js.map +1 -0
  196. package/dist/prompt/steps/step-ask-question/handlers/start-code-generation.d.ts +2 -0
  197. package/dist/prompt/steps/step-ask-question/handlers/start-code-generation.js +16 -0
  198. package/dist/prompt/steps/step-ask-question/handlers/start-code-generation.js.map +1 -0
  199. package/dist/prompt/steps/step-ask-question/step-ask-question-handlers.d.ts +0 -0
  200. package/dist/prompt/steps/step-ask-question/step-ask-question-handlers.js +2 -0
  201. package/dist/prompt/steps/step-ask-question/step-ask-question-handlers.js.map +1 -0
  202. package/dist/prompt/steps/step-ask-question/step-ask-question-reflect.d.ts +4 -0
  203. package/dist/prompt/steps/step-ask-question/step-ask-question-reflect.js +91 -0
  204. package/dist/prompt/steps/step-ask-question/step-ask-question-reflect.js.map +1 -0
  205. package/dist/prompt/steps/step-ask-question/step-ask-question-types.d.ts +56 -0
  206. package/dist/prompt/steps/step-ask-question/step-ask-question-types.js +2 -0
  207. package/dist/prompt/steps/step-ask-question/step-ask-question-types.js.map +1 -0
  208. package/dist/prompt/steps/step-ask-question/step-ask-question.d.ts +6 -0
  209. package/dist/prompt/steps/step-ask-question/step-ask-question.js +95 -0
  210. package/dist/prompt/steps/step-ask-question/step-ask-question.js.map +1 -0
  211. package/dist/prompt/steps/step-context-optimization.js +9 -2
  212. package/dist/prompt/steps/step-context-optimization.js.map +1 -1
  213. package/dist/prompt/steps/step-generate-summary.js +2 -2
  214. package/dist/prompt/steps/step-generate-summary.js.map +1 -1
  215. package/dist/prompt/steps/step-history-update.js +2 -2
  216. package/dist/prompt/steps/step-history-update.js.map +1 -1
  217. package/dist/prompt/steps/step-summarization.js +2 -2
  218. package/dist/prompt/steps/step-summarization.js.map +1 -1
  219. package/dist/src/ai-service/ai-studio.d.ts +6 -0
  220. package/dist/src/ai-service/ai-studio.js +190 -0
  221. package/dist/src/ai-service/ai-studio.js.map +1 -0
  222. package/dist/src/ai-service/anthropic.d.ts +6 -0
  223. package/dist/src/ai-service/anthropic.js +150 -0
  224. package/dist/src/ai-service/anthropic.js.map +1 -0
  225. package/dist/src/ai-service/chat-gpt.d.ts +5 -0
  226. package/dist/src/ai-service/chat-gpt.js +146 -0
  227. package/dist/src/ai-service/chat-gpt.js.map +1 -0
  228. package/dist/src/ai-service/common.d.ts +69 -0
  229. package/dist/src/ai-service/common.js +38 -0
  230. package/dist/src/ai-service/common.js.map +1 -0
  231. package/dist/src/ai-service/common.test.d.ts +1 -0
  232. package/dist/src/ai-service/common.test.js +86 -0
  233. package/dist/src/ai-service/common.test.js.map +1 -0
  234. package/dist/src/ai-service/dall-e.d.ts +14 -0
  235. package/dist/src/ai-service/dall-e.js +50 -0
  236. package/dist/src/ai-service/dall-e.js.map +1 -0
  237. package/dist/src/ai-service/unescape-function-call.d.ts +7 -0
  238. package/dist/src/ai-service/unescape-function-call.js +59 -0
  239. package/dist/src/ai-service/unescape-function-call.js.map +1 -0
  240. package/dist/src/ai-service/unescape-function-call.test.d.ts +1 -0
  241. package/dist/src/ai-service/unescape-function-call.test.js +18 -0
  242. package/dist/src/ai-service/unescape-function-call.test.js.map +1 -0
  243. package/dist/src/ai-service/vertex-ai-claude.d.ts +5 -0
  244. package/dist/src/ai-service/vertex-ai-claude.js +104 -0
  245. package/dist/src/ai-service/vertex-ai-claude.js.map +1 -0
  246. package/dist/src/ai-service/vertex-ai-imagen.d.ts +14 -0
  247. package/dist/src/ai-service/vertex-ai-imagen.js +77 -0
  248. package/dist/src/ai-service/vertex-ai-imagen.js.map +1 -0
  249. package/dist/src/ai-service/vertex-ai.d.ts +6 -0
  250. package/dist/src/ai-service/vertex-ai.js +202 -0
  251. package/dist/src/ai-service/vertex-ai.js.map +1 -0
  252. package/dist/src/cli/cli-options.d.ts +10 -0
  253. package/dist/src/cli/cli-options.js +132 -0
  254. package/dist/src/cli/cli-options.js.map +1 -0
  255. package/dist/src/cli/cli-options.test.d.ts +1 -0
  256. package/dist/src/cli/cli-options.test.js +34 -0
  257. package/dist/src/cli/cli-options.test.js.map +1 -0
  258. package/dist/src/cli/cli-params.d.ts +32 -0
  259. package/dist/src/cli/cli-params.js +106 -0
  260. package/dist/src/cli/cli-params.js.map +1 -0
  261. package/dist/src/cli/cli-params.test.d.ts +1 -0
  262. package/dist/src/cli/cli-params.test.js +38 -0
  263. package/dist/src/cli/cli-params.test.js.map +1 -0
  264. package/dist/src/cli/service-autodetect.d.ts +2 -0
  265. package/dist/src/cli/service-autodetect.js +17 -0
  266. package/dist/src/cli/service-autodetect.js.map +1 -0
  267. package/dist/src/cli/service-autodetect.test.d.ts +1 -0
  268. package/dist/src/cli/service-autodetect.test.js +38 -0
  269. package/dist/src/cli/service-autodetect.test.js.map +1 -0
  270. package/dist/src/cli/validate-cli-params.d.ts +18 -0
  271. package/dist/src/cli/validate-cli-params.js +145 -0
  272. package/dist/src/cli/validate-cli-params.js.map +1 -0
  273. package/dist/src/cli/validate-cli-params.test.d.ts +1 -0
  274. package/dist/src/cli/validate-cli-params.test.js +106 -0
  275. package/dist/src/cli/validate-cli-params.test.js.map +1 -0
  276. package/dist/src/files/cache-file.d.ts +3 -0
  277. package/dist/src/files/cache-file.js +36 -0
  278. package/dist/src/files/cache-file.js.map +1 -0
  279. package/dist/src/files/file-utils.d.ts +2 -0
  280. package/dist/src/files/file-utils.js +7 -0
  281. package/dist/src/files/file-utils.js.map +1 -0
  282. package/dist/src/files/file-utils.test.d.ts +1 -0
  283. package/dist/src/files/file-utils.test.js +18 -0
  284. package/dist/src/files/file-utils.test.js.map +1 -0
  285. package/dist/src/files/find-files.d.ts +9 -0
  286. package/dist/src/files/find-files.js +81 -0
  287. package/dist/src/files/find-files.js.map +1 -0
  288. package/dist/src/files/path-utils.d.ts +1 -0
  289. package/dist/src/files/path-utils.js +12 -0
  290. package/dist/src/files/path-utils.js.map +1 -0
  291. package/dist/src/files/read-files.d.ts +21 -0
  292. package/dist/src/files/read-files.js +68 -0
  293. package/dist/src/files/read-files.js.map +1 -0
  294. package/dist/src/files/read-files.test.d.ts +1 -0
  295. package/dist/src/files/read-files.test.js +89 -0
  296. package/dist/src/files/read-files.test.js.map +1 -0
  297. package/dist/src/files/temp-buffer.d.ts +2 -0
  298. package/dist/src/files/temp-buffer.js +12 -0
  299. package/dist/src/files/temp-buffer.js.map +1 -0
  300. package/dist/src/files/update-files.d.ts +6 -0
  301. package/dist/src/files/update-files.js +19 -0
  302. package/dist/src/files/update-files.js.map +1 -0
  303. package/dist/src/images/ensure-alpha.d.ts +1 -0
  304. package/dist/src/images/ensure-alpha.js +5 -0
  305. package/dist/src/images/ensure-alpha.js.map +1 -0
  306. package/dist/src/images/imgly-remove-background.d.ts +2 -0
  307. package/dist/src/images/imgly-remove-background.js +21 -0
  308. package/dist/src/images/imgly-remove-background.js.map +1 -0
  309. package/dist/src/images/resize-image.d.ts +19 -0
  310. package/dist/src/images/resize-image.js +22 -0
  311. package/dist/src/images/resize-image.js.map +1 -0
  312. package/dist/src/images/split-image.d.ts +18 -0
  313. package/dist/src/images/split-image.js +25 -0
  314. package/dist/src/images/split-image.js.map +1 -0
  315. package/dist/src/index.d.ts +3 -0
  316. package/dist/src/index.js +3 -0
  317. package/dist/src/index.js.map +1 -0
  318. package/dist/src/main/codegen-types.d.ts +58 -0
  319. package/dist/src/main/codegen-types.js +2 -0
  320. package/dist/src/main/codegen-types.js.map +1 -0
  321. package/dist/src/main/codegen-utils.d.ts +3 -0
  322. package/dist/src/main/codegen-utils.js +18 -0
  323. package/dist/src/main/codegen-utils.js.map +1 -0
  324. package/dist/src/main/codegen.d.ts +4 -0
  325. package/dist/src/main/codegen.js +201 -0
  326. package/dist/src/main/codegen.js.map +1 -0
  327. package/dist/src/main/codegen.test.d.ts +3 -0
  328. package/dist/src/main/codegen.test.js +288 -0
  329. package/dist/src/main/codegen.test.js.map +1 -0
  330. package/dist/src/main/common/content-bus-types.d.ts +21 -0
  331. package/dist/src/main/common/content-bus-types.js +11 -0
  332. package/dist/src/main/common/content-bus-types.js.map +1 -0
  333. package/dist/src/main/common/content-bus.d.ts +10 -0
  334. package/dist/src/main/common/content-bus.js +39 -0
  335. package/dist/src/main/common/content-bus.js.map +1 -0
  336. package/dist/src/main/common/cost-collector.d.ts +11 -0
  337. package/dist/src/main/common/cost-collector.js +90 -0
  338. package/dist/src/main/common/cost-collector.js.map +1 -0
  339. package/dist/src/main/common/user-actions.d.ts +19 -0
  340. package/dist/src/main/common/user-actions.js +30 -0
  341. package/dist/src/main/common/user-actions.js.map +1 -0
  342. package/dist/src/main/config-lib.d.ts +36 -0
  343. package/dist/src/main/config-lib.js +51 -0
  344. package/dist/src/main/config-lib.js.map +1 -0
  345. package/dist/src/main/config-lib.test.d.ts +1 -0
  346. package/dist/src/main/config-lib.test.js +64 -0
  347. package/dist/src/main/config-lib.test.js.map +1 -0
  348. package/dist/src/main/config.d.ts +7 -0
  349. package/dist/src/main/config.js +51 -0
  350. package/dist/src/main/config.js.map +1 -0
  351. package/dist/src/main/interactive/codegen-interactive.d.ts +2 -0
  352. package/dist/src/main/interactive/codegen-interactive.js +61 -0
  353. package/dist/src/main/interactive/codegen-interactive.js.map +1 -0
  354. package/dist/src/main/interactive/codegen-interactive.test.d.ts +5 -0
  355. package/dist/src/main/interactive/codegen-interactive.test.js +79 -0
  356. package/dist/src/main/interactive/codegen-interactive.test.js.map +1 -0
  357. package/dist/src/main/interactive/codegen-worker.d.ts +3 -0
  358. package/dist/src/main/interactive/codegen-worker.js +54 -0
  359. package/dist/src/main/interactive/codegen-worker.js.map +1 -0
  360. package/dist/src/main/interactive/common.d.ts +5 -0
  361. package/dist/src/main/interactive/common.js +51 -0
  362. package/dist/src/main/interactive/common.js.map +1 -0
  363. package/dist/src/main/interactive/configure.d.ts +2 -0
  364. package/dist/src/main/interactive/configure.js +99 -0
  365. package/dist/src/main/interactive/configure.js.map +1 -0
  366. package/dist/src/main/interactive/error-handling.d.ts +1 -0
  367. package/dist/src/main/interactive/error-handling.js +43 -0
  368. package/dist/src/main/interactive/error-handling.js.map +1 -0
  369. package/dist/src/main/interactive/help.d.ts +1 -0
  370. package/dist/src/main/interactive/help.js +22 -0
  371. package/dist/src/main/interactive/help.js.map +1 -0
  372. package/dist/src/main/interactive/process-comments.d.ts +2 -0
  373. package/dist/src/main/interactive/process-comments.js +39 -0
  374. package/dist/src/main/interactive/process-comments.js.map +1 -0
  375. package/dist/src/main/interactive/select-ai-service.d.ts +2 -0
  376. package/dist/src/main/interactive/select-ai-service.js +27 -0
  377. package/dist/src/main/interactive/select-ai-service.js.map +1 -0
  378. package/dist/src/main/interactive/task-file.d.ts +2 -0
  379. package/dist/src/main/interactive/task-file.js +35 -0
  380. package/dist/src/main/interactive/task-file.js.map +1 -0
  381. package/dist/src/main/interactive/text-prompt.d.ts +2 -0
  382. package/dist/src/main/interactive/text-prompt.js +18 -0
  383. package/dist/src/main/interactive/text-prompt.js.map +1 -0
  384. package/dist/src/main/interactive/user-action-handlers.d.ts +1 -0
  385. package/dist/src/main/interactive/user-action-handlers.js +13 -0
  386. package/dist/src/main/interactive/user-action-handlers.js.map +1 -0
  387. package/dist/src/main/interactive/user-interrupt.d.ts +1 -0
  388. package/dist/src/main/interactive/user-interrupt.js +36 -0
  389. package/dist/src/main/interactive/user-interrupt.js.map +1 -0
  390. package/dist/src/main/plugin-loader.d.ts +6 -0
  391. package/dist/src/main/plugin-loader.js +40 -0
  392. package/dist/src/main/plugin-loader.js.map +1 -0
  393. package/dist/src/main/ui/backend/api-utils.d.ts +2 -0
  394. package/dist/src/main/ui/backend/api-utils.js +18 -0
  395. package/dist/src/main/ui/backend/api-utils.js.map +1 -0
  396. package/dist/src/main/ui/backend/api.d.ts +2 -0
  397. package/dist/src/main/ui/backend/api.js +210 -0
  398. package/dist/src/main/ui/backend/api.js.map +1 -0
  399. package/dist/src/main/ui/backend/server.d.ts +7 -0
  400. package/dist/src/main/ui/backend/server.js +83 -0
  401. package/dist/src/main/ui/backend/server.js.map +1 -0
  402. package/dist/src/main/ui/backend/service.d.ts +44 -0
  403. package/dist/src/main/ui/backend/service.js +171 -0
  404. package/dist/src/main/ui/backend/service.js.map +1 -0
  405. package/dist/src/main/ui/codegen-ui.d.ts +2 -0
  406. package/dist/src/main/ui/codegen-ui.js +13 -0
  407. package/dist/src/main/ui/codegen-ui.js.map +1 -0
  408. package/dist/src/main/ui/common/api-types.d.ts +20 -0
  409. package/dist/src/main/ui/common/api-types.js +2 -0
  410. package/dist/src/main/ui/common/api-types.js.map +1 -0
  411. package/dist/src/main/ui/user-action-handlers.d.ts +2 -0
  412. package/dist/src/main/ui/user-action-handlers.js +14 -0
  413. package/dist/src/main/ui/user-action-handlers.js.map +1 -0
  414. package/dist/src/operations/create-directory/create-directory-def.d.ts +9 -0
  415. package/dist/src/operations/create-directory/create-directory-def.js +22 -0
  416. package/dist/src/operations/create-directory/create-directory-def.js.map +1 -0
  417. package/dist/src/operations/create-directory/create-directory-executor.d.ts +6 -0
  418. package/dist/src/operations/create-directory/create-directory-executor.js +22 -0
  419. package/dist/src/operations/create-directory/create-directory-executor.js.map +1 -0
  420. package/dist/src/operations/create-file/create-file-def.d.ts +10 -0
  421. package/dist/src/operations/create-file/create-file-def.js +26 -0
  422. package/dist/src/operations/create-file/create-file-def.js.map +1 -0
  423. package/dist/src/operations/create-file/create-file-executor.d.ts +6 -0
  424. package/dist/src/operations/create-file/create-file-executor.js +27 -0
  425. package/dist/src/operations/create-file/create-file-executor.js.map +1 -0
  426. package/dist/src/operations/delete-file/delete-file-def.d.ts +9 -0
  427. package/dist/src/operations/delete-file/delete-file-def.js +22 -0
  428. package/dist/src/operations/delete-file/delete-file-def.js.map +1 -0
  429. package/dist/src/operations/delete-file/delete-file-executor.d.ts +6 -0
  430. package/dist/src/operations/delete-file/delete-file-executor.js +23 -0
  431. package/dist/src/operations/delete-file/delete-file-executor.js.map +1 -0
  432. package/dist/src/operations/download-file/download-file-def.d.ts +10 -0
  433. package/dist/src/operations/download-file/download-file-def.js +26 -0
  434. package/dist/src/operations/download-file/download-file-def.js.map +1 -0
  435. package/dist/src/operations/download-file/download-file-executor.d.ts +6 -0
  436. package/dist/src/operations/download-file/download-file-executor.js +44 -0
  437. package/dist/src/operations/download-file/download-file-executor.js.map +1 -0
  438. package/dist/src/operations/imgly-remove-background/imgly-remove-background-def.d.ts +10 -0
  439. package/dist/src/operations/imgly-remove-background/imgly-remove-background-def.js +26 -0
  440. package/dist/src/operations/imgly-remove-background/imgly-remove-background-def.js.map +1 -0
  441. package/dist/src/operations/imgly-remove-background/imgly-remove-background-executor.d.ts +6 -0
  442. package/dist/src/operations/imgly-remove-background/imgly-remove-background-executor.js +40 -0
  443. package/dist/src/operations/imgly-remove-background/imgly-remove-background-executor.js.map +1 -0
  444. package/dist/src/operations/move-file/move-file-def.d.ts +10 -0
  445. package/dist/src/operations/move-file/move-file-def.js +26 -0
  446. package/dist/src/operations/move-file/move-file-def.js.map +1 -0
  447. package/dist/src/operations/move-file/move-file-executor.d.ts +6 -0
  448. package/dist/src/operations/move-file/move-file-executor.js +29 -0
  449. package/dist/src/operations/move-file/move-file-executor.js.map +1 -0
  450. package/dist/src/operations/operations-index.d.ts +3 -0
  451. package/dist/src/operations/operations-index.js +33 -0
  452. package/dist/src/operations/operations-index.js.map +1 -0
  453. package/dist/src/operations/patch-file/patch-file-def.d.ts +10 -0
  454. package/dist/src/operations/patch-file/patch-file-def.js +39 -0
  455. package/dist/src/operations/patch-file/patch-file-def.js.map +1 -0
  456. package/dist/src/operations/patch-file/patch-file-executor.d.ts +5 -0
  457. package/dist/src/operations/patch-file/patch-file-executor.js +26 -0
  458. package/dist/src/operations/patch-file/patch-file-executor.js.map +1 -0
  459. package/dist/src/operations/resize-image/resize-image-def.d.ts +13 -0
  460. package/dist/src/operations/resize-image/resize-image-def.js +37 -0
  461. package/dist/src/operations/resize-image/resize-image-def.js.map +1 -0
  462. package/dist/src/operations/resize-image/resize-image-executor.d.ts +5 -0
  463. package/dist/src/operations/resize-image/resize-image-executor.js +30 -0
  464. package/dist/src/operations/resize-image/resize-image-executor.js.map +1 -0
  465. package/dist/src/operations/split-image/split-image-def.d.ts +18 -0
  466. package/dist/src/operations/split-image/split-image-def.js +46 -0
  467. package/dist/src/operations/split-image/split-image-def.js.map +1 -0
  468. package/dist/src/operations/split-image/split-image-executor.d.ts +6 -0
  469. package/dist/src/operations/split-image/split-image-executor.js +51 -0
  470. package/dist/src/operations/split-image/split-image-executor.js.map +1 -0
  471. package/dist/src/operations/update-file/update-file-def.d.ts +10 -0
  472. package/dist/src/operations/update-file/update-file-def.js +26 -0
  473. package/dist/src/operations/update-file/update-file-def.js.map +1 -0
  474. package/dist/src/operations/update-file/update-file-executor.d.ts +5 -0
  475. package/dist/src/operations/update-file/update-file-executor.js +22 -0
  476. package/dist/src/operations/update-file/update-file-executor.js.map +1 -0
  477. package/dist/src/prompt/ai-service-fallback.d.ts +3 -0
  478. package/dist/src/prompt/ai-service-fallback.js +84 -0
  479. package/dist/src/prompt/ai-service-fallback.js.map +1 -0
  480. package/dist/src/prompt/function-calling-validate.d.ts +3 -0
  481. package/dist/src/prompt/function-calling-validate.js +99 -0
  482. package/dist/src/prompt/function-calling-validate.js.map +1 -0
  483. package/dist/src/prompt/function-calling.d.ts +5 -0
  484. package/dist/src/prompt/function-calling.js +43 -0
  485. package/dist/src/prompt/function-calling.js.map +1 -0
  486. package/dist/src/prompt/function-defs/ask-question-reflect.d.ts +2 -0
  487. package/dist/src/prompt/function-defs/ask-question-reflect.js +21 -0
  488. package/dist/src/prompt/function-defs/ask-question-reflect.js.map +1 -0
  489. package/dist/src/prompt/function-defs/ask-question.d.ts +8 -0
  490. package/dist/src/prompt/function-defs/ask-question.js +100 -0
  491. package/dist/src/prompt/function-defs/ask-question.js.map +1 -0
  492. package/dist/src/prompt/function-defs/codegen-summary.d.ts +5 -0
  493. package/dist/src/prompt/function-defs/codegen-summary.js +82 -0
  494. package/dist/src/prompt/function-defs/codegen-summary.js.map +1 -0
  495. package/dist/src/prompt/function-defs/explanation.d.ts +5 -0
  496. package/dist/src/prompt/function-defs/explanation.js +18 -0
  497. package/dist/src/prompt/function-defs/explanation.js.map +1 -0
  498. package/dist/src/prompt/function-defs/generate-image.d.ts +5 -0
  499. package/dist/src/prompt/function-defs/generate-image.js +42 -0
  500. package/dist/src/prompt/function-defs/generate-image.js.map +1 -0
  501. package/dist/src/prompt/function-defs/get-image-assets.d.ts +5 -0
  502. package/dist/src/prompt/function-defs/get-image-assets.js +21 -0
  503. package/dist/src/prompt/function-defs/get-image-assets.js.map +1 -0
  504. package/dist/src/prompt/function-defs/get-source-code.d.ts +5 -0
  505. package/dist/src/prompt/function-defs/get-source-code.js +22 -0
  506. package/dist/src/prompt/function-defs/get-source-code.js.map +1 -0
  507. package/dist/src/prompt/function-defs/optimize-context.d.ts +5 -0
  508. package/dist/src/prompt/function-defs/optimize-context.js +47 -0
  509. package/dist/src/prompt/function-defs/optimize-context.js.map +1 -0
  510. package/dist/src/prompt/function-defs/read-history.d.ts +2 -0
  511. package/dist/src/prompt/function-defs/read-history.js +14 -0
  512. package/dist/src/prompt/function-defs/read-history.js.map +1 -0
  513. package/dist/src/prompt/function-defs/set-summaries.d.ts +5 -0
  514. package/dist/src/prompt/function-defs/set-summaries.js +32 -0
  515. package/dist/src/prompt/function-defs/set-summaries.js.map +1 -0
  516. package/dist/src/prompt/function-defs/update-history.d.ts +5 -0
  517. package/dist/src/prompt/function-defs/update-history.js +22 -0
  518. package/dist/src/prompt/function-defs/update-history.js.map +1 -0
  519. package/dist/src/prompt/limits.d.ts +3 -0
  520. package/dist/src/prompt/limits.js +21 -0
  521. package/dist/src/prompt/limits.js.map +1 -0
  522. package/dist/src/prompt/limits.test.d.ts +1 -0
  523. package/dist/src/prompt/limits.test.js +35 -0
  524. package/dist/src/prompt/limits.test.js.map +1 -0
  525. package/dist/src/prompt/prompt-codegen.d.ts +9 -0
  526. package/dist/src/prompt/prompt-codegen.js +117 -0
  527. package/dist/src/prompt/prompt-codegen.js.map +1 -0
  528. package/dist/src/prompt/prompt-codegen.test.d.ts +1 -0
  529. package/dist/src/prompt/prompt-codegen.test.js +98 -0
  530. package/dist/src/prompt/prompt-codegen.test.js.map +1 -0
  531. package/dist/src/prompt/prompt-consts.d.ts +1 -0
  532. package/dist/src/prompt/prompt-consts.js +2 -0
  533. package/dist/src/prompt/prompt-consts.js.map +1 -0
  534. package/dist/src/prompt/prompt-service-ask-question.test.d.ts +4 -0
  535. package/dist/src/prompt/prompt-service-ask-question.test.js +215 -0
  536. package/dist/src/prompt/prompt-service-ask-question.test.js.map +1 -0
  537. package/dist/src/prompt/prompt-service.d.ts +5 -0
  538. package/dist/src/prompt/prompt-service.js +214 -0
  539. package/dist/src/prompt/prompt-service.js.map +1 -0
  540. package/dist/src/prompt/prompt-service.test.d.ts +2 -0
  541. package/dist/src/prompt/prompt-service.test.js +553 -0
  542. package/dist/src/prompt/prompt-service.test.js.map +1 -0
  543. package/dist/src/prompt/steps/step-ask-question/handlers/cancel-code-generation.d.ts +2 -0
  544. package/dist/src/prompt/steps/step-ask-question/handlers/cancel-code-generation.js +16 -0
  545. package/dist/src/prompt/steps/step-ask-question/handlers/cancel-code-generation.js.map +1 -0
  546. package/dist/src/prompt/steps/step-ask-question/handlers/confirm-code-generation.d.ts +2 -0
  547. package/dist/src/prompt/steps/step-ask-question/handlers/confirm-code-generation.js +37 -0
  548. package/dist/src/prompt/steps/step-ask-question/handlers/confirm-code-generation.js.map +1 -0
  549. package/dist/src/prompt/steps/step-ask-question/handlers/context-optimization.d.ts +2 -0
  550. package/dist/src/prompt/steps/step-ask-question/handlers/context-optimization.js +36 -0
  551. package/dist/src/prompt/steps/step-ask-question/handlers/context-optimization.js.map +1 -0
  552. package/dist/src/prompt/steps/step-ask-question/handlers/default-action.d.ts +2 -0
  553. package/dist/src/prompt/steps/step-ask-question/handlers/default-action.js +18 -0
  554. package/dist/src/prompt/steps/step-ask-question/handlers/default-action.js.map +1 -0
  555. package/dist/src/prompt/steps/step-ask-question/handlers/handle-request-answer.d.ts +2 -0
  556. package/dist/src/prompt/steps/step-ask-question/handlers/handle-request-answer.js +20 -0
  557. package/dist/src/prompt/steps/step-ask-question/handlers/handle-request-answer.js.map +1 -0
  558. package/dist/src/prompt/steps/step-ask-question/handlers/remove-files-from-context.d.ts +2 -0
  559. package/dist/src/prompt/steps/step-ask-question/handlers/remove-files-from-context.js +43 -0
  560. package/dist/src/prompt/steps/step-ask-question/handlers/remove-files-from-context.js.map +1 -0
  561. package/dist/src/prompt/steps/step-ask-question/handlers/request-files-content.d.ts +2 -0
  562. package/dist/src/prompt/steps/step-ask-question/handlers/request-files-content.js +49 -0
  563. package/dist/src/prompt/steps/step-ask-question/handlers/request-files-content.js.map +1 -0
  564. package/dist/src/prompt/steps/step-ask-question/handlers/request-permissions.d.ts +2 -0
  565. package/dist/src/prompt/steps/step-ask-question/handlers/request-permissions.js +46 -0
  566. package/dist/src/prompt/steps/step-ask-question/handlers/request-permissions.js.map +1 -0
  567. package/dist/src/prompt/steps/step-ask-question/handlers/start-code-generation.d.ts +2 -0
  568. package/dist/src/prompt/steps/step-ask-question/handlers/start-code-generation.js +16 -0
  569. package/dist/src/prompt/steps/step-ask-question/handlers/start-code-generation.js.map +1 -0
  570. package/dist/src/prompt/steps/step-ask-question/step-ask-question-handlers.d.ts +0 -0
  571. package/dist/src/prompt/steps/step-ask-question/step-ask-question-handlers.js +2 -0
  572. package/dist/src/prompt/steps/step-ask-question/step-ask-question-handlers.js.map +1 -0
  573. package/dist/src/prompt/steps/step-ask-question/step-ask-question-reflect.d.ts +4 -0
  574. package/dist/src/prompt/steps/step-ask-question/step-ask-question-reflect.js +91 -0
  575. package/dist/src/prompt/steps/step-ask-question/step-ask-question-reflect.js.map +1 -0
  576. package/dist/src/prompt/steps/step-ask-question/step-ask-question-types.d.ts +55 -0
  577. package/dist/src/prompt/steps/step-ask-question/step-ask-question-types.js +2 -0
  578. package/dist/src/prompt/steps/step-ask-question/step-ask-question-types.js.map +1 -0
  579. package/dist/src/prompt/steps/step-ask-question/step-ask-question.d.ts +6 -0
  580. package/dist/src/prompt/steps/step-ask-question/step-ask-question.js +88 -0
  581. package/dist/src/prompt/steps/step-ask-question/step-ask-question.js.map +1 -0
  582. package/dist/src/prompt/steps/step-context-optimization.d.ts +4 -0
  583. package/dist/src/prompt/steps/step-context-optimization.js +200 -0
  584. package/dist/src/prompt/steps/step-context-optimization.js.map +1 -0
  585. package/dist/src/prompt/steps/step-generate-image.d.ts +2 -0
  586. package/dist/src/prompt/steps/step-generate-image.js +29 -0
  587. package/dist/src/prompt/steps/step-generate-image.js.map +1 -0
  588. package/dist/src/prompt/steps/step-generate-summary.d.ts +3 -0
  589. package/dist/src/prompt/steps/step-generate-summary.js +41 -0
  590. package/dist/src/prompt/steps/step-generate-summary.js.map +1 -0
  591. package/dist/src/prompt/steps/step-history-update.d.ts +5 -0
  592. package/dist/src/prompt/steps/step-history-update.js +54 -0
  593. package/dist/src/prompt/steps/step-history-update.js.map +1 -0
  594. package/dist/src/prompt/steps/step-summarization.d.ts +8 -0
  595. package/dist/src/prompt/steps/step-summarization.js +75 -0
  596. package/dist/src/prompt/steps/step-summarization.js.map +1 -0
  597. package/dist/src/prompt/steps/step-validate-recover.d.ts +2 -0
  598. package/dist/src/prompt/steps/step-validate-recover.js +51 -0
  599. package/dist/src/prompt/steps/step-validate-recover.js.map +1 -0
  600. package/dist/src/prompt/steps/step-verify-patch.d.ts +6 -0
  601. package/dist/src/prompt/steps/step-verify-patch.js +34 -0
  602. package/dist/src/prompt/steps/step-verify-patch.js.map +1 -0
  603. package/dist/src/prompt/steps/steps-types.d.ts +16 -0
  604. package/dist/src/prompt/steps/steps-types.js +6 -0
  605. package/dist/src/prompt/steps/steps-types.js.map +1 -0
  606. package/dist/src/prompt/steps/steps-utils.d.ts +7 -0
  607. package/dist/src/prompt/steps/steps-utils.js +11 -0
  608. package/dist/src/prompt/steps/steps-utils.js.map +1 -0
  609. package/dist/src/prompt/systemprompt.d.ts +3 -0
  610. package/dist/src/prompt/systemprompt.js +209 -0
  611. package/dist/src/prompt/systemprompt.js.map +1 -0
  612. package/dist/src/prompt/systemprompt.test.d.ts +3 -0
  613. package/dist/src/prompt/systemprompt.test.js +43 -0
  614. package/dist/src/prompt/systemprompt.test.js.map +1 -0
  615. package/dist/src/prompt/token-estimator.d.ts +8 -0
  616. package/dist/src/prompt/token-estimator.js +31 -0
  617. package/dist/src/prompt/token-estimator.js.map +1 -0
  618. package/dist/src/vite-genaicode/vite-genaicode-frontend.d.ts +1 -0
  619. package/dist/src/vite-genaicode/vite-genaicode-frontend.js +142 -0
  620. package/dist/src/vite-genaicode/vite-genaicode-frontend.js.map +1 -0
  621. package/dist/src/vite-genaicode/vite-genaicode-plugin.d.ts +7 -0
  622. package/dist/src/vite-genaicode/vite-genaicode-plugin.js +40 -0
  623. package/dist/src/vite-genaicode/vite-genaicode-plugin.js.map +1 -0
  624. package/dist/vite-genaicode/vite-genaicode-plugin.js +3 -3
  625. package/dist/vite-genaicode/vite-genaicode-plugin.js.map +1 -1
  626. package/package.json +4 -2
@@ -0,0 +1,37 @@
1
+ import { putSystemMessage } from '../../../../main/common/content-bus.js';
2
+ import { askUserForConfirmationWithAnswer } from '../../../../main/common/user-actions.js';
3
+ import { StepResult } from '../../steps-types.js';
4
+ export async function handleConfirmCodeGeneration({ askQuestionCall }) {
5
+ const userConfirmation = await askUserForConfirmationWithAnswer('The assistant is ready to start code generation. Do you want to proceed?', 'Start code generation', 'Continue conversation', true);
6
+ if (userConfirmation.confirmed) {
7
+ putSystemMessage('Proceeding with code generation.');
8
+ return {
9
+ breakLoop: true,
10
+ stepResult: StepResult.CONTINUE,
11
+ items: [
12
+ {
13
+ assistant: { type: 'assistant', text: askQuestionCall.args?.content ?? '', functionCalls: [] },
14
+ user: { type: 'user', text: userConfirmation.answer || 'Confirmed. Proceed with code generation.' },
15
+ },
16
+ ],
17
+ };
18
+ }
19
+ else {
20
+ putSystemMessage('Declined. Continuing the conversation.');
21
+ return {
22
+ breakLoop: false,
23
+ stepResult: StepResult.CONTINUE,
24
+ items: [
25
+ {
26
+ assistant: { type: 'assistant', text: askQuestionCall.args?.content ?? '', functionCalls: [askQuestionCall] },
27
+ user: {
28
+ type: 'user',
29
+ text: userConfirmation.answer || 'Declined. Please continue the conversation.',
30
+ functionResponses: [{ name: 'askQuestion', call_id: askQuestionCall.id ?? '', content: undefined }],
31
+ },
32
+ },
33
+ ],
34
+ };
35
+ }
36
+ }
37
+ //# sourceMappingURL=confirm-code-generation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirm-code-generation.js","sourceRoot":"","sources":["../../../../../../src/prompt/steps/step-ask-question/handlers/confirm-code-generation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,gCAAgC,EAAE,MAAM,yCAAyC,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,EAAE,eAAe,EAAsB;IACvF,MAAM,gBAAgB,GAAG,MAAM,gCAAgC,CAC7D,0EAA0E,EAC1E,uBAAuB,EACvB,uBAAuB,EACvB,IAAI,CACL,CAAC;IACF,IAAI,gBAAgB,CAAC,SAAS,EAAE,CAAC;QAC/B,gBAAgB,CAAC,kCAAkC,CAAC,CAAC;QACrD,OAAO;YACL,SAAS,EAAE,IAAI;YACf,UAAU,EAAE,UAAU,CAAC,QAAQ;YAC/B,KAAK,EAAE;gBACL;oBACE,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE;oBAC9F,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,CAAC,MAAM,IAAI,0CAA0C,EAAE;iBACpG;aACF;SACF,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,gBAAgB,CAAC,wCAAwC,CAAC,CAAC;QAC3D,OAAO;YACL,SAAS,EAAE,KAAK;YAChB,UAAU,EAAE,UAAU,CAAC,QAAQ;YAC/B,KAAK,EAAE;gBACL;oBACE,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE,aAAa,EAAE,CAAC,eAAe,CAAC,EAAE;oBAC7G,IAAI,EAAE;wBACJ,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,gBAAgB,CAAC,MAAM,IAAI,6CAA6C;wBAC9E,iBAAiB,EAAE,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,CAAC,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;qBACpG;iBACF;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';
2
+ export declare function handleContextOptimization({ askQuestionCall, prompt, options, generateContentFn, }: ActionHandlerProps): Promise<ActionResult>;
@@ -0,0 +1,36 @@
1
+ import { refreshFiles } from '../../../../files/find-files.js';
2
+ import { putSystemMessage } from '../../../../main/common/content-bus.js';
3
+ import { askUserForConfirmation } from '../../../../main/common/user-actions.js';
4
+ import { executeStepContextOptimization } from '../../step-context-optimization.js';
5
+ import { StepResult } from '../../steps-types.js';
6
+ export async function handleContextOptimization({ askQuestionCall, prompt, options, generateContentFn, }) {
7
+ const userConfirmation = await askUserForConfirmation('The assistant suggests optimizing the context to reduce token usage, cost, and latency. Do you want to proceed?', false);
8
+ const user = {
9
+ type: 'user',
10
+ text: userConfirmation ? 'Context optimization applied.' : 'Context optimization not applied.',
11
+ functionResponses: [{ name: 'askQuestion', call_id: askQuestionCall.id ?? '', content: undefined }],
12
+ };
13
+ const assistant = {
14
+ type: 'assistant',
15
+ text: askQuestionCall.args?.content ?? '',
16
+ functionCalls: [askQuestionCall],
17
+ };
18
+ if (userConfirmation) {
19
+ // the request may be caused be an appearance of a new file, so lets refresh
20
+ refreshFiles();
21
+ // Execute context optimization step
22
+ putSystemMessage('Executing context optimization step.');
23
+ await executeStepContextOptimization(generateContentFn, [...prompt, assistant, user], options);
24
+ }
25
+ return {
26
+ breakLoop: false,
27
+ stepResult: StepResult.CONTINUE,
28
+ items: [
29
+ {
30
+ assistant,
31
+ user,
32
+ },
33
+ ],
34
+ };
35
+ }
36
+ //# sourceMappingURL=context-optimization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-optimization.js","sourceRoot":"","sources":["../../../../../../src/prompt/steps/step-ask-question/handlers/context-optimization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,EAC9C,eAAe,EACf,MAAM,EACN,OAAO,EACP,iBAAiB,GACE;IACnB,MAAM,gBAAgB,GAAG,MAAM,sBAAsB,CACnD,iHAAiH,EACjH,KAAK,CACN,CAAC;IAEF,MAAM,IAAI,GAAa;QACrB,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC,CAAC,mCAAmC;QAC9F,iBAAiB,EAAE,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,CAAC,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;KACpG,CAAC;IAEF,MAAM,SAAS,GAAkB;QAC/B,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE;QACzC,aAAa,EAAE,CAAC,eAAe,CAAC;KACjC,CAAC;IAEF,IAAI,gBAAgB,EAAE,CAAC;QACrB,4EAA4E;QAC5E,YAAY,EAAE,CAAC;QAEf,oCAAoC;QACpC,gBAAgB,CAAC,sCAAsC,CAAC,CAAC;QACzD,MAAM,8BAA8B,CAAC,iBAAiB,EAAE,CAAC,GAAG,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;IACjG,CAAC;IAED,OAAO;QACL,SAAS,EAAE,KAAK;QAChB,UAAU,EAAE,UAAU,CAAC,QAAQ;QAC/B,KAAK,EAAE;YACL;gBACE,SAAS;gBACT,IAAI;aACL;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';
2
+ export declare function handleDefaultAction({ askQuestionCall }: ActionHandlerProps): Promise<ActionResult>;
@@ -0,0 +1,18 @@
1
+ import { StepResult } from '../../steps-types.js';
2
+ export async function handleDefaultAction({ askQuestionCall }) {
3
+ return {
4
+ breakLoop: false,
5
+ stepResult: StepResult.CONTINUE,
6
+ items: [
7
+ {
8
+ assistant: { type: 'assistant', text: askQuestionCall.args?.content ?? '', functionCalls: [askQuestionCall] },
9
+ user: {
10
+ type: 'user',
11
+ text: "I don't want to start the code generation yet, let's talk a bit more.",
12
+ functionResponses: [{ name: 'askQuestion', call_id: askQuestionCall.id ?? '', content: undefined }],
13
+ },
14
+ },
15
+ ],
16
+ };
17
+ }
18
+ //# sourceMappingURL=default-action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-action.js","sourceRoot":"","sources":["../../../../../../src/prompt/steps/step-ask-question/handlers/default-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,EAAE,eAAe,EAAsB;IAC/E,OAAO;QACL,SAAS,EAAE,KAAK;QAChB,UAAU,EAAE,UAAU,CAAC,QAAQ;QAC/B,KAAK,EAAE;YACL;gBACE,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE,aAAa,EAAE,CAAC,eAAe,CAAC,EAAE;gBAC7G,IAAI,EAAE;oBACJ,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,uEAAuE;oBAC7E,iBAAiB,EAAE,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,CAAC,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;iBACpG;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';
2
+ export declare function handleRequestAnswer({ askQuestionCall }: ActionHandlerProps): Promise<ActionResult>;
@@ -0,0 +1,20 @@
1
+ import { askUserForInput } from '../../../../main/common/user-actions.js';
2
+ import { StepResult } from '../../steps-types.js';
3
+ export async function handleRequestAnswer({ askQuestionCall }) {
4
+ const userText = await askUserForInput('Your answer', askQuestionCall.args?.content ?? '');
5
+ return {
6
+ breakLoop: false,
7
+ stepResult: StepResult.CONTINUE,
8
+ items: [
9
+ {
10
+ assistant: { type: 'assistant', text: askQuestionCall.args?.content ?? '', functionCalls: [askQuestionCall] },
11
+ user: {
12
+ type: 'user',
13
+ text: userText,
14
+ functionResponses: [{ name: 'askQuestion', call_id: askQuestionCall.id ?? '', content: undefined }],
15
+ },
16
+ },
17
+ ],
18
+ };
19
+ }
20
+ //# sourceMappingURL=handle-request-answer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-request-answer.js","sourceRoot":"","sources":["../../../../../../src/prompt/steps/step-ask-question/handlers/handle-request-answer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,EAAE,eAAe,EAAsB;IAC/E,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,aAAa,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC;IAC3F,OAAO;QACL,SAAS,EAAE,KAAK;QAChB,UAAU,EAAE,UAAU,CAAC,QAAQ;QAC/B,KAAK,EAAE;YACL;gBACE,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE,aAAa,EAAE,CAAC,eAAe,CAAC,EAAE;gBAC7G,IAAI,EAAE;oBACJ,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,QAAQ;oBACd,iBAAiB,EAAE,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,CAAC,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;iBACpG;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';
2
+ export declare function handleRemoveFilesFromContext({ askQuestionCall, prompt, }: ActionHandlerProps): Promise<ActionResult>;
@@ -0,0 +1,43 @@
1
+ import { putSystemMessage } from '../../../../main/common/content-bus.js';
2
+ import { StepResult } from '../../steps-types.js';
3
+ import { getSourceCodeResponse } from '../../steps-utils.js';
4
+ export async function handleRemoveFilesFromContext({ askQuestionCall, prompt, }) {
5
+ const filesToRemove = askQuestionCall.args?.removeFilesFromContext ?? [];
6
+ let userText = '';
7
+ if (filesToRemove.length > 0) {
8
+ removeFileContentsFromPrompt(prompt, filesToRemove);
9
+ putSystemMessage('Context reduction applied', filesToRemove);
10
+ userText = 'Context reduction applied';
11
+ }
12
+ else {
13
+ userText = 'No specific files were provided for context reduction. The context remains unchanged.';
14
+ }
15
+ return {
16
+ breakLoop: false,
17
+ stepResult: StepResult.CONTINUE,
18
+ items: [
19
+ {
20
+ assistant: { type: 'assistant', text: askQuestionCall.args?.content ?? '', functionCalls: [askQuestionCall] },
21
+ user: {
22
+ type: 'user',
23
+ text: userText,
24
+ functionResponses: [{ name: 'askQuestion', call_id: askQuestionCall.id ?? '', content: undefined }],
25
+ },
26
+ },
27
+ ],
28
+ };
29
+ }
30
+ function removeFileContentsFromPrompt(prompt, filesToRemove) {
31
+ const response = getSourceCodeResponse(prompt);
32
+ if (!response || !response.content) {
33
+ throw new Error('Could not find source code response');
34
+ }
35
+ const contentObj = JSON.parse(response.content);
36
+ filesToRemove.forEach((file) => {
37
+ if (contentObj[file]) {
38
+ delete contentObj[file].content;
39
+ }
40
+ });
41
+ response.content = JSON.stringify(contentObj);
42
+ }
43
+ //# sourceMappingURL=remove-files-from-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-files-from-context.js","sourceRoot":"","sources":["../../../../../../src/prompt/steps/step-ask-question/handlers/remove-files-from-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,EACjD,eAAe,EACf,MAAM,GACa;IACnB,MAAM,aAAa,GAAG,eAAe,CAAC,IAAI,EAAE,sBAAsB,IAAI,EAAE,CAAC;IACzE,IAAI,QAAQ,GAAG,EAAE,CAAC;IAElB,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,4BAA4B,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;QACpD,gBAAgB,CAAC,2BAA2B,EAAE,aAAa,CAAC,CAAC;QAC7D,QAAQ,GAAG,2BAA2B,CAAC;IACzC,CAAC;SAAM,CAAC;QACN,QAAQ,GAAG,uFAAuF,CAAC;IACrG,CAAC;IAED,OAAO;QACL,SAAS,EAAE,KAAK;QAChB,UAAU,EAAE,UAAU,CAAC,QAAQ;QAC/B,KAAK,EAAE;YACL;gBACE,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE,aAAa,EAAE,CAAC,eAAe,CAAC,EAAE;gBAC7G,IAAI,EAAE;oBACJ,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,QAAQ;oBACd,iBAAiB,EAAE,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,CAAC,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;iBACpG;aACF;SACF;KACF,CAAC;AACJ,CAAC;AAED,SAAS,4BAA4B,CAAC,MAAoB,EAAE,aAAuB;IACjF,MAAM,QAAQ,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC/C,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;IACD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAChD,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC7B,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACrB,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC;QAClC,CAAC;IACH,CAAC,CAAC,CAAC;IACH,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AAChD,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';
2
+ export declare function handleRequestFilesContent({ askQuestionCall, options, }: ActionHandlerProps): Promise<ActionResult>;
@@ -0,0 +1,49 @@
1
+ import { getSourceFiles, refreshFiles } from '../../../../files/find-files.js';
2
+ import { getSourceCode } from '../../../../files/read-files.js';
3
+ import { StepResult } from '../../steps-types.js';
4
+ export async function handleRequestFilesContent({ askQuestionCall, options, }) {
5
+ const requestedFiles = askQuestionCall.args?.requestFilesContent ?? [];
6
+ // the request may be caused be an appearance of a new file, so lets refresh
7
+ refreshFiles();
8
+ const { legitimateFiles, illegitimateFiles } = categorizeLegitimateFiles(requestedFiles);
9
+ const sourceCallId = (askQuestionCall.id ?? '') + '_source';
10
+ const assistant = {
11
+ type: 'assistant',
12
+ text: askQuestionCall.args?.content ?? '',
13
+ functionCalls: [askQuestionCall, { name: 'getSourceCode', id: sourceCallId, args: { filePaths: legitimateFiles } }],
14
+ };
15
+ const sourceCode = getSourceCode({ filterPaths: legitimateFiles, forceAll: true }, options);
16
+ const user = {
17
+ type: 'user',
18
+ text: illegitimateFiles.length > 0
19
+ ? 'Some files are not legitimate and their content cannot be provided'
20
+ : 'All requested file contents have been provided.',
21
+ functionResponses: [
22
+ { name: 'askQuestion', call_id: askQuestionCall.id ?? '', content: undefined },
23
+ {
24
+ name: 'getSourceCode',
25
+ call_id: sourceCallId,
26
+ content: JSON.stringify(sourceCode),
27
+ },
28
+ ],
29
+ cache: true,
30
+ };
31
+ return { breakLoop: false, stepResult: StepResult.CONTINUE, items: [{ assistant, user }] };
32
+ }
33
+ function categorizeLegitimateFiles(requestedFiles) {
34
+ const legitimateFiles = [];
35
+ const illegitimateFiles = [];
36
+ requestedFiles.forEach((filePath) => {
37
+ if (isFilePathLegitimate(filePath)) {
38
+ legitimateFiles.push(filePath);
39
+ }
40
+ else {
41
+ illegitimateFiles.push(filePath);
42
+ }
43
+ });
44
+ return { legitimateFiles, illegitimateFiles };
45
+ }
46
+ function isFilePathLegitimate(filePath) {
47
+ return getSourceFiles().includes(filePath);
48
+ }
49
+ //# sourceMappingURL=request-files-content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-files-content.js","sourceRoot":"","sources":["../../../../../../src/prompt/steps/step-ask-question/handlers/request-files-content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,EAC9C,eAAe,EACf,OAAO,GACY;IACnB,MAAM,cAAc,GAAG,eAAe,CAAC,IAAI,EAAE,mBAAmB,IAAI,EAAE,CAAC;IACvE,4EAA4E;IAC5E,YAAY,EAAE,CAAC;IAEf,MAAM,EAAE,eAAe,EAAE,iBAAiB,EAAE,GAAG,yBAAyB,CAAC,cAAc,CAAC,CAAC;IAEzF,MAAM,YAAY,GAAG,CAAC,eAAe,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,SAAS,CAAC;IAC5D,MAAM,SAAS,GAAkB;QAC/B,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE;QACzC,aAAa,EAAE,CAAC,eAAe,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,EAAE,CAAC;KACpH,CAAC;IAEF,MAAM,UAAU,GAAG,aAAa,CAAC,EAAE,WAAW,EAAE,eAAe,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;IAC5F,MAAM,IAAI,GAAa;QACrB,IAAI,EAAE,MAAM;QACZ,IAAI,EACF,iBAAiB,CAAC,MAAM,GAAG,CAAC;YAC1B,CAAC,CAAC,oEAAoE;YACtE,CAAC,CAAC,iDAAiD;QACvD,iBAAiB,EAAE;YACjB,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,CAAC,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;YAC9E;gBACE,IAAI,EAAE,eAAe;gBACrB,OAAO,EAAE,YAAY;gBACrB,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;aACpC;SACF;QACD,KAAK,EAAE,IAAI;KACZ,CAAC;IAEF,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AAC7F,CAAC;AAED,SAAS,yBAAyB,CAAC,cAAwB;IAIzD,MAAM,eAAe,GAAa,EAAE,CAAC;IACrC,MAAM,iBAAiB,GAAa,EAAE,CAAC;IAEvC,cAAc,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;QAClC,IAAI,oBAAoB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC;aAAM,CAAC;YACN,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,oBAAoB,CAAC,QAAgB;IAC5C,OAAO,cAAc,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';
2
+ export declare function handleRequestPermissions({ askQuestionCall, options, }: ActionHandlerProps): Promise<ActionResult>;
@@ -0,0 +1,46 @@
1
+ import { askUserForConfirmation } from '../../../../main/common/user-actions.js';
2
+ import { StepResult } from '../../steps-types.js';
3
+ export async function handleRequestPermissions({ askQuestionCall, options, }) {
4
+ const userConfirmation = await askUserForConfirmation('The assistant is requesting additional permissions. Do you want to grant them?', false);
5
+ const user = {
6
+ type: 'user',
7
+ text: userConfirmation ? 'Permissions granted.' : 'Permission request denied.',
8
+ functionResponses: [{ name: 'askQuestion', call_id: askQuestionCall.id ?? '', content: undefined }],
9
+ };
10
+ if (userConfirmation) {
11
+ updatePermissions(askQuestionCall, options);
12
+ }
13
+ return {
14
+ breakLoop: false,
15
+ stepResult: StepResult.CONTINUE,
16
+ items: [
17
+ {
18
+ assistant: { type: 'assistant', text: askQuestionCall.args?.content ?? '', functionCalls: [askQuestionCall] },
19
+ user,
20
+ },
21
+ ],
22
+ };
23
+ }
24
+ function updatePermissions(askQuestionCall, options) {
25
+ if (askQuestionCall.args &&
26
+ typeof askQuestionCall.args === 'object' &&
27
+ 'requestPermissions' in askQuestionCall.args) {
28
+ const permissions = askQuestionCall.args.requestPermissions;
29
+ if (permissions && typeof permissions === 'object') {
30
+ if ('enableImagen' in permissions && permissions.enableImagen) {
31
+ options.imagen = options.aiService === 'chat-gpt' ? 'dall-e' : 'vertex-ai';
32
+ }
33
+ if ('enableVision' in permissions && permissions.enableVision)
34
+ options.vision = true;
35
+ if ('allowDirectoryCreate' in permissions && permissions.allowDirectoryCreate)
36
+ options.allowDirectoryCreate = true;
37
+ if ('allowFileCreate' in permissions && permissions.allowFileCreate)
38
+ options.allowFileCreate = true;
39
+ if ('allowFileDelete' in permissions && permissions.allowFileDelete)
40
+ options.allowFileDelete = true;
41
+ if ('allowFileMove' in permissions && permissions.allowFileMove)
42
+ options.allowFileMove = true;
43
+ }
44
+ }
45
+ }
46
+ //# sourceMappingURL=request-permissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-permissions.js","sourceRoot":"","sources":["../../../../../../src/prompt/steps/step-ask-question/handlers/request-permissions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,EAC7C,eAAe,EACf,OAAO,GACY;IACnB,MAAM,gBAAgB,GAAG,MAAM,sBAAsB,CACnD,gFAAgF,EAChF,KAAK,CACN,CAAC;IAEF,MAAM,IAAI,GAAa;QACrB,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,4BAA4B;QAC9E,iBAAiB,EAAE,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,CAAC,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;KACpG,CAAC;IAEF,IAAI,gBAAgB,EAAE,CAAC;QACrB,iBAAiB,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,OAAO;QACL,SAAS,EAAE,KAAK;QAChB,UAAU,EAAE,UAAU,CAAC,QAAQ;QAC/B,KAAK,EAAE;YACL;gBACE,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE,aAAa,EAAE,CAAC,eAAe,CAAC,EAAE;gBAC7G,IAAI;aACL;SACF;KACF,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,eAAgC,EAAE,OAAuB;IAClF,IACE,eAAe,CAAC,IAAI;QACpB,OAAO,eAAe,CAAC,IAAI,KAAK,QAAQ;QACxC,oBAAoB,IAAI,eAAe,CAAC,IAAI,EAC5C,CAAC;QACD,MAAM,WAAW,GAAG,eAAe,CAAC,IAAI,CAAC,kBAAkB,CAAC;QAC5D,IAAI,WAAW,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;YACnD,IAAI,cAAc,IAAI,WAAW,IAAI,WAAW,CAAC,YAAY,EAAE,CAAC;gBAC9D,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC;YAC7E,CAAC;YACD,IAAI,cAAc,IAAI,WAAW,IAAI,WAAW,CAAC,YAAY;gBAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;YACrF,IAAI,sBAAsB,IAAI,WAAW,IAAI,WAAW,CAAC,oBAAoB;gBAC3E,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;YACtC,IAAI,iBAAiB,IAAI,WAAW,IAAI,WAAW,CAAC,eAAe;gBAAE,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;YACpG,IAAI,iBAAiB,IAAI,WAAW,IAAI,WAAW,CAAC,eAAe;gBAAE,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;YACpG,IAAI,eAAe,IAAI,WAAW,IAAI,WAAW,CAAC,aAAa;gBAAE,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;QAChG,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';
2
+ export declare function handleStartCodeGeneration({ askQuestionCall }: ActionHandlerProps): Promise<ActionResult>;
@@ -0,0 +1,16 @@
1
+ import { putSystemMessage } from '../../../../main/common/content-bus.js';
2
+ import { StepResult } from '../../steps-types.js';
3
+ export async function handleStartCodeGeneration({ askQuestionCall }) {
4
+ putSystemMessage('Proceeding with code generation.');
5
+ return {
6
+ breakLoop: true,
7
+ stepResult: StepResult.CONTINUE,
8
+ items: [
9
+ {
10
+ assistant: { type: 'assistant', text: askQuestionCall.args?.content ?? '', functionCalls: [] },
11
+ user: { type: 'user', text: 'Proceeding with code generation.' },
12
+ },
13
+ ],
14
+ };
15
+ }
16
+ //# sourceMappingURL=start-code-generation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start-code-generation.js","sourceRoot":"","sources":["../../../../../../src/prompt/steps/step-ask-question/handlers/start-code-generation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,EAAE,eAAe,EAAsB;IACrF,gBAAgB,CAAC,kCAAkC,CAAC,CAAC;IACrD,OAAO;QACL,SAAS,EAAE,IAAI;QACf,UAAU,EAAE,UAAU,CAAC,QAAQ;QAC/B,KAAK,EAAE;YACL;gBACE,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE;gBAC9F,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,kCAAkC,EAAE;aACjE;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=step-ask-question-handlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-ask-question-handlers.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/step-ask-question-handlers.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import { FunctionDef, GenerateContentFunction, PromptItem } from '../../../ai-service/common.js';
2
+ import { CodegenOptions } from '../../../main/codegen-types.js';
3
+ import { AskQuestionCall, EscalationDecision, SelfReflectionContext } from './step-ask-question-types.js';
4
+ export declare function performSelfReflection(askQuestionCall: AskQuestionCall, context: SelfReflectionContext, prompt: PromptItem[], functionDefs: FunctionDef[], options: CodegenOptions, generateContentFn: GenerateContentFunction): Promise<EscalationDecision>;
@@ -0,0 +1,91 @@
1
+ import { validateAndRecoverSingleResult } from '../step-validate-recover.js';
2
+ const SELF_REFLECT_PROMPT = `Please reflect on your last response provided in \`askQuestion\` function call in the context of our conversation by considering these questions:
3
+
4
+ - Did you fully understand and address the user's request?
5
+ - Was your response clear, accurate, and helpful?
6
+ - Are you confident that no further clarification or escalation is needed?
7
+ - Is your response too similar to previous questions or responses in the conversation?
8
+ - Is your response adding value to the conversation or moving it forward?
9
+ - Are you maintaining your own identity and perspective as an AI assistant?
10
+ - Are you directly addressing the user's points without deflecting or prolonging the conversation?
11
+ - Are you providing clear, concise, and helpful responses without being overly cautious or evasive?
12
+ - Are you demonstrating confidence and competence in your abilities without expressing unnecessary uncertainty?
13
+
14
+ Common problems/pitfalls:
15
+
16
+ - There is an in-depth question to the user, but actionType is set to confirmCodeGeneration, while it should be requestAnswer
17
+ - Question was already answered before, but the assistant is asking the same question again
18
+ - The question content is incomplete, for example the question content ends with a colon
19
+ - Saying that an analysis will be done, instead of actually doing the analysis
20
+ - The response is too similar to a previous question or response
21
+ - The assistant takes on the user's voice or persona instead of maintaining its own identity
22
+
23
+ Specific examples of problematic responses:
24
+
25
+ 1. User: "What's the weather like today?"
26
+ Assistant: "To provide information about today's weather, I'll need to know your location. What city are you in?"
27
+ User: "New York"
28
+ Assistant: "To give you accurate weather information for New York, I'll need to know which specific area of New York you're interested in. Could you please provide more details about your location?"
29
+ Problem: The assistant is being overly cautious and asking for unnecessary details, prolonging the conversation instead of providing a helpful response based on the information already given.
30
+
31
+ 2. User: "Can you explain how to implement a binary search algorithm?"
32
+ Assistant: "Certainly! I'd be happy to explain how to implement a binary search algorithm. Before we begin, could you tell me what programming language you'd like the explanation in?"
33
+ User: "Python"
34
+ Assistant: "Great choice! Python is an excellent language for implementing a binary search algorithm. Before we dive into the Python implementation, could you let me know your level of experience with Python programming?"
35
+ Problem: The assistant is asking for excessive context before providing the requested explanation, which may frustrate the user who was expecting a more direct response.
36
+
37
+ 3. User: "I'm not convinced if those responses are really problematic"
38
+ Assistant: "I'm not convinced if those responses in the "Specific examples of problematic responses" section are really problematic. Could you provide more context or clarification on why you consider them to be problematic examples?"
39
+ Problem: The assistant is repeating the user's statement and asking for clarification instead of engaging with the user's perspective. This response fails to maintain the assistant's identity and doesn't add value to the conversation.
40
+
41
+ If your response meets the criteria for a clear, helpful, and non-repetitive answer, continue the conversation as usual. If you believe that escalating to a more advanced model would significantly improve assistance or if the response is too similar to previous interactions, please indicate that using the \`shouldEscalate\` parameter and provide a \`reason\`.`;
42
+ export async function performSelfReflection(askQuestionCall, context, prompt, functionDefs, options, generateContentFn) {
43
+ if (!options.selfReflectionEnabled) {
44
+ return {
45
+ shouldEscalate: false,
46
+ reason: 'Self-reflection is disabled by user configuration.',
47
+ };
48
+ }
49
+ const currentTime = Date.now();
50
+ const { shouldEscalate, reason } = await runSelfReflect(askQuestionCall, prompt, functionDefs, options, generateContentFn);
51
+ if (shouldEscalate) {
52
+ context.escalationCount++;
53
+ context.lastEscalationTime = currentTime;
54
+ }
55
+ return {
56
+ shouldEscalate,
57
+ reason,
58
+ };
59
+ }
60
+ async function runSelfReflect(askQuestionCall, prompt, functionDefs, options, generateContentFn) {
61
+ const currentResponse = askQuestionCall.args?.content ?? '';
62
+ const reflectRequest = [
63
+ [
64
+ ...prompt,
65
+ { type: 'assistant', text: currentResponse, functionCalls: [askQuestionCall] },
66
+ {
67
+ type: 'user',
68
+ text: SELF_REFLECT_PROMPT,
69
+ functionResponses: [{ name: 'askQuestion', call_id: askQuestionCall.id ?? '', content: undefined }],
70
+ },
71
+ ],
72
+ functionDefs,
73
+ 'askQuestionReflect',
74
+ 0.2,
75
+ true,
76
+ options,
77
+ ];
78
+ let result = await generateContentFn(...reflectRequest);
79
+ result = await validateAndRecoverSingleResult(reflectRequest, result, generateContentFn);
80
+ const reflectionResult = result.find((call) => call.name === 'askQuestionReflect')?.args;
81
+ const shouldEscalate = (reflectionResult?.shouldEscalate ?? 0) > 50;
82
+ const reason = reflectionResult?.reason || '';
83
+ return {
84
+ shouldEscalate,
85
+ reason: reason ||
86
+ (shouldEscalate
87
+ ? 'Response requires escalation to a more advanced model'
88
+ : 'Response does not require escalation'),
89
+ };
90
+ }
91
+ //# sourceMappingURL=step-ask-question-reflect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-ask-question-reflect.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/step-ask-question-reflect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAG7E,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0WAuC8U,CAAC;AAE3W,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,eAAgC,EAChC,OAA8B,EAC9B,MAAoB,EACpB,YAA2B,EAC3B,OAAuB,EACvB,iBAA0C;IAE1C,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC;QACnC,OAAO;YACL,cAAc,EAAE,KAAK;YACrB,MAAM,EAAE,oDAAoD;SAC7D,CAAC;IACJ,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE/B,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,MAAM,cAAc,CACrD,eAAe,EACf,MAAM,EACN,YAAY,EACZ,OAAO,EACP,iBAAiB,CAClB,CAAC;IAEF,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,CAAC,eAAe,EAAE,CAAC;QAC1B,OAAO,CAAC,kBAAkB,GAAG,WAAW,CAAC;IAC3C,CAAC;IAED,OAAO;QACL,cAAc;QACd,MAAM;KACP,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,cAAc,CAC3B,eAAgC,EAChC,MAAoB,EACpB,YAA2B,EAC3B,OAAuB,EACvB,iBAA0C;IAE1C,MAAM,eAAe,GAAG,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,CAAC;IAE5D,MAAM,cAAc,GAAwB;QAC1C;YACE,GAAG,MAAM;YACT,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,EAAE,aAAa,EAAE,CAAC,eAAe,CAAC,EAAE;YAC9E;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,mBAAmB;gBACzB,iBAAiB,EAAE,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,CAAC,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;aACpG;SACF;QACD,YAAY;QACZ,oBAAoB;QACpB,GAAG;QACH,IAAI;QACJ,OAAO;KACR,CAAC;IAEF,IAAI,MAAM,GAAG,MAAM,iBAAiB,CAAC,GAAG,cAAc,CAAC,CAAC;IACxD,MAAM,GAAG,MAAM,8BAA8B,CAAC,cAAc,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAEzF,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,oBAAoB,CAAC,EAAE,IAAI,CAAC;IACzF,MAAM,cAAc,GAAG,CAAE,gBAAgB,EAAE,cAAqC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC;IAC5F,MAAM,MAAM,GAAI,gBAAgB,EAAE,MAAiB,IAAI,EAAE,CAAC;IAE1D,OAAO;QACL,cAAc;QACd,MAAM,EACJ,MAAM;YACN,CAAC,cAAc;gBACb,CAAC,CAAC,uDAAuD;gBACzD,CAAC,CAAC,sCAAsC,CAAC;KAC9C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { FunctionCall, GenerateContentFunction, PromptItem } from '../../../ai-service/common.js';
2
+ import { CodegenOptions } from '../../../main/codegen-types.js';
3
+ import { StepResult } from '../steps-types.js';
4
+ export type ActionType = 'requestAnswer' | 'requestPermissions' | 'requestFilesContent' | 'removeFilesFromContext' | 'confirmCodeGeneration' | 'startCodeGeneration' | 'cancelCodeGeneration' | 'contextOptimization';
5
+ type AskQuestionArgs = {
6
+ actionType: ActionType;
7
+ content: string;
8
+ requestFilesContent?: string[];
9
+ requestPermissions?: Record<'allowDirectoryCreate' | 'allowFileCreate' | 'allowFileDelete' | 'allowFileMove' | 'enableVision' | 'enableImagen', boolean>;
10
+ removeFilesFromContext?: string[];
11
+ };
12
+ export type AskQuestionCall = FunctionCall<AskQuestionArgs>;
13
+ export interface AssistantItem {
14
+ type: 'assistant';
15
+ text: string;
16
+ functionCalls: FunctionCall[];
17
+ cache?: true;
18
+ }
19
+ export interface UserItem {
20
+ type: 'user';
21
+ text: string;
22
+ functionResponses?: Array<{
23
+ name: string;
24
+ call_id: string;
25
+ content: string | undefined;
26
+ }>;
27
+ cache?: true;
28
+ }
29
+ export interface ActionResult {
30
+ breakLoop: boolean;
31
+ stepResult: StepResult;
32
+ items: Array<{
33
+ assistant: AssistantItem;
34
+ user: UserItem;
35
+ }>;
36
+ }
37
+ export type ActionHandlerProps = {
38
+ askQuestionCall: AskQuestionCall;
39
+ prompt: PromptItem[];
40
+ options: CodegenOptions;
41
+ generateContentFn: GenerateContentFunction;
42
+ messages: {
43
+ contextSourceCode: (paths: string[], pathsOnly: boolean) => string;
44
+ };
45
+ };
46
+ export type ActionHandler = (props: ActionHandlerProps) => Promise<ActionResult>;
47
+ export interface EscalationDecision {
48
+ shouldEscalate: boolean;
49
+ reason: string;
50
+ }
51
+ export interface SelfReflectionContext {
52
+ escalationCount: number;
53
+ lastEscalationTime: number;
54
+ }
55
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=step-ask-question-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-ask-question-types.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/step-ask-question-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import { FunctionDef, GenerateContentFunction, PromptItem } from '../../../ai-service/common.js';
2
+ import { StepResult } from '../steps-types.js';
3
+ import { CodegenOptions } from '../../../main/codegen-types.js';
4
+ export declare function executeStepAskQuestion(generateContentFn: GenerateContentFunction, prompt: PromptItem[], functionDefs: FunctionDef[], temperature: number, messages: {
5
+ contextSourceCode: (paths: string[], pathsOnly: boolean) => string;
6
+ }, options: CodegenOptions): Promise<StepResult>;
@@ -0,0 +1,88 @@
1
+ import { StepResult } from '../steps-types.js';
2
+ import { putAssistantMessage, putSystemMessage, putUserMessage } from '../../../main/common/content-bus.js';
3
+ import { abortController } from '../../../main/interactive/codegen-worker.js';
4
+ import { validateAndRecoverSingleResult } from '../step-validate-recover.js';
5
+ import { handleRequestFilesContent } from './handlers/request-files-content.js';
6
+ import { handleContextOptimization } from './handlers/context-optimization.js';
7
+ import { handleRemoveFilesFromContext } from './handlers/remove-files-from-context.js';
8
+ import { handleRequestPermissions } from './handlers/request-permissions.js';
9
+ import { handleDefaultAction } from './handlers/default-action.js';
10
+ import { handleRequestAnswer } from './handlers/handle-request-answer.js';
11
+ import { handleStartCodeGeneration } from './handlers/start-code-generation.js';
12
+ import { handleConfirmCodeGeneration } from './handlers/confirm-code-generation.js';
13
+ import { handleCancelCodeGeneration } from './handlers/cancel-code-generation.js';
14
+ import { performSelfReflection } from './step-ask-question-reflect.js';
15
+ export async function executeStepAskQuestion(generateContentFn, prompt, functionDefs, temperature, messages, options) {
16
+ console.log('Allowing the assistant to ask a question...');
17
+ const selfReflectionContext = {
18
+ escalationCount: 0,
19
+ lastEscalationTime: 0,
20
+ };
21
+ while (!abortController?.signal.aborted) {
22
+ try {
23
+ const askQuestionCall = await getAskQuestionCall(generateContentFn, prompt, functionDefs, temperature, options, selfReflectionContext);
24
+ if (!askQuestionCall) {
25
+ break;
26
+ }
27
+ console.log('Assistant asks:', askQuestionCall.args);
28
+ if (askQuestionCall.args?.content) {
29
+ putAssistantMessage(askQuestionCall.args.content, askQuestionCall.args);
30
+ }
31
+ const actionType = askQuestionCall.args?.actionType;
32
+ if (actionType) {
33
+ const actionHandler = getActionHandler(actionType);
34
+ const result = await actionHandler({ askQuestionCall, prompt, options, messages, generateContentFn });
35
+ // This is important to display the content to the user interface (ui or interactive cli)
36
+ putUserMessage(result.items.slice(-1)[0].user.text);
37
+ if (result.breakLoop) {
38
+ return result.stepResult;
39
+ }
40
+ prompt.push(...result.items.map(({ assistant, user }) => [assistant, user]).flat());
41
+ console.log('The question was answered');
42
+ }
43
+ else {
44
+ console.error('Invalid action type received');
45
+ break;
46
+ }
47
+ }
48
+ catch (error) {
49
+ console.error('Error in executeStepAskQuestion:', error);
50
+ putSystemMessage(`An error occurred: ${error instanceof Error ? error.message : String(error)}`);
51
+ return StepResult.BREAK;
52
+ }
53
+ }
54
+ putSystemMessage('Assistant did not ask a question. This unexpected, we need to abort.');
55
+ return StepResult.BREAK;
56
+ }
57
+ async function getAskQuestionCall(generateContentFn, prompt, functionDefs, temperature, options, selfReflectionContext) {
58
+ const askQuestionRequest = [prompt, functionDefs, 'askQuestion', temperature, true, options];
59
+ let askQuestionResult = await generateContentFn(...askQuestionRequest);
60
+ askQuestionResult = await validateAndRecoverSingleResult(askQuestionRequest, askQuestionResult, generateContentFn);
61
+ const cheapModelResponse = askQuestionResult.find((call) => call.name === 'askQuestion');
62
+ if (cheapModelResponse) {
63
+ const escalationDecision = await performSelfReflection(cheapModelResponse, selfReflectionContext, prompt, functionDefs, options, generateContentFn);
64
+ if (escalationDecision.shouldEscalate) {
65
+ console.log('Self-reflection suggests escalating to non-cheap model.');
66
+ // Re-run with non-cheap model
67
+ const nonCheapRequest = [prompt, functionDefs, 'askQuestion', temperature, false, options];
68
+ let nonCheapResult = await generateContentFn(...nonCheapRequest);
69
+ nonCheapResult = await validateAndRecoverSingleResult(nonCheapRequest, nonCheapResult, generateContentFn);
70
+ return nonCheapResult.find((call) => call.name === 'askQuestion');
71
+ }
72
+ }
73
+ return cheapModelResponse;
74
+ }
75
+ function getActionHandler(actionType) {
76
+ const handlers = {
77
+ cancelCodeGeneration: handleCancelCodeGeneration,
78
+ confirmCodeGeneration: handleConfirmCodeGeneration,
79
+ startCodeGeneration: handleStartCodeGeneration,
80
+ requestFilesContent: handleRequestFilesContent,
81
+ requestPermissions: handleRequestPermissions,
82
+ removeFilesFromContext: handleRemoveFilesFromContext,
83
+ requestAnswer: handleRequestAnswer,
84
+ contextOptimization: handleContextOptimization,
85
+ };
86
+ return handlers[actionType] || handleDefaultAction;
87
+ }
88
+ //# sourceMappingURL=step-ask-question.js.map