genaicode 0.11.1 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/README.md +3 -9
  2. package/dist/ai-service/ai-studio.d.ts +18 -1
  3. package/dist/ai-service/ai-studio.js +92 -21
  4. package/dist/ai-service/ai-studio.js.map +1 -1
  5. package/dist/ai-service/anthropic.js +59 -25
  6. package/dist/ai-service/anthropic.js.map +1 -1
  7. package/dist/ai-service/common-types.d.ts +8 -3
  8. package/dist/ai-service/common.d.ts +5 -1
  9. package/dist/ai-service/common.js +9 -0
  10. package/dist/ai-service/common.js.map +1 -1
  11. package/dist/ai-service/dall-e.js +1 -0
  12. package/dist/ai-service/dall-e.js.map +1 -1
  13. package/dist/ai-service/github-models.d.ts +13 -0
  14. package/dist/ai-service/github-models.js +51 -0
  15. package/dist/ai-service/github-models.js.map +1 -0
  16. package/dist/ai-service/local-llm.js +2 -1
  17. package/dist/ai-service/local-llm.js.map +1 -1
  18. package/dist/ai-service/openai-responses.d.ts +9 -0
  19. package/dist/ai-service/openai-responses.js +286 -0
  20. package/dist/ai-service/openai-responses.js.map +1 -0
  21. package/dist/ai-service/openai.js +22 -10
  22. package/dist/ai-service/openai.js.map +1 -1
  23. package/dist/ai-service/service-configurations-types.d.ts +7 -7
  24. package/dist/ai-service/service-configurations.d.ts +1 -0
  25. package/dist/ai-service/service-configurations.js +41 -36
  26. package/dist/ai-service/service-configurations.js.map +1 -1
  27. package/dist/ai-service/vertex-ai-claude.js +2 -2
  28. package/dist/ai-service/vertex-ai-claude.js.map +1 -1
  29. package/dist/ai-service/vertex-ai.d.ts +1 -0
  30. package/dist/ai-service/vertex-ai.js +4 -332
  31. package/dist/ai-service/vertex-ai.js.map +1 -1
  32. package/dist/cli/cli-options.js +1 -1
  33. package/dist/cli/cli-options.js.map +1 -1
  34. package/dist/cli/validate-cli-params.js +1 -1
  35. package/dist/cli/validate-cli-params.js.map +1 -1
  36. package/dist/files/cache-file.d.ts +4 -0
  37. package/dist/files/cache-file.js +21 -0
  38. package/dist/files/cache-file.js.map +1 -1
  39. package/dist/files/find-files.d.ts +1 -0
  40. package/dist/files/find-files.js +4 -1
  41. package/dist/files/find-files.js.map +1 -1
  42. package/dist/files/source-code-utils.js +1 -1
  43. package/dist/files/summary-cache.d.ts +1 -1
  44. package/dist/files/summary-cache.js +1 -1
  45. package/dist/files/summary-cache.js.map +1 -1
  46. package/dist/main/codegen-utils.d.ts +6 -1
  47. package/dist/main/codegen-utils.js +21 -2
  48. package/dist/main/codegen-utils.js.map +1 -1
  49. package/dist/main/codegen.js +2 -2
  50. package/dist/main/codegen.js.map +1 -1
  51. package/dist/main/common/content-bus-types.d.ts +17 -1
  52. package/dist/main/common/content-bus.d.ts +3 -1
  53. package/dist/main/common/content-bus.js +23 -1
  54. package/dist/main/common/content-bus.js.map +1 -1
  55. package/dist/main/common/user-actions.d.ts +3 -0
  56. package/dist/main/common/user-actions.js +10 -0
  57. package/dist/main/common/user-actions.js.map +1 -1
  58. package/dist/main/config-lib.js +3 -2
  59. package/dist/main/config-lib.js.map +1 -1
  60. package/dist/main/config-types.d.ts +4 -0
  61. package/dist/main/config.js +4 -0
  62. package/dist/main/config.js.map +1 -1
  63. package/dist/main/interactive/select-ai-service.js +0 -1
  64. package/dist/main/interactive/select-ai-service.js.map +1 -1
  65. package/dist/main/interactive/user-action-handlers.js +7 -2
  66. package/dist/main/interactive/user-action-handlers.js.map +1 -1
  67. package/dist/main/knowledge/knowledge-store.d.ts +6 -0
  68. package/dist/main/knowledge/knowledge-store.js +128 -0
  69. package/dist/main/knowledge/knowledge-store.js.map +1 -0
  70. package/dist/main/knowledge/types.d.ts +20 -0
  71. package/dist/main/knowledge/types.js +2 -0
  72. package/dist/main/knowledge/types.js.map +1 -0
  73. package/dist/main/ui/backend/endpoints/interrupt-execution-endpoint.js +17 -3
  74. package/dist/main/ui/backend/endpoints/interrupt-execution-endpoint.js.map +1 -1
  75. package/dist/main/ui/common/api-types.d.ts +67 -4
  76. package/dist/main/ui/common/api-types.js +12 -1
  77. package/dist/main/ui/common/api-types.js.map +1 -1
  78. package/dist/main/ui/frontend/assets/index-j9Oi9iiP.js +2635 -0
  79. package/dist/main/ui/frontend/index.html +1 -1
  80. package/dist/main/ui/user-action-handlers.js +7 -1
  81. package/dist/main/ui/user-action-handlers.js.map +1 -1
  82. package/dist/project-profiles/types.d.ts +4 -4
  83. package/dist/project-profiles/types.js +4 -4
  84. package/dist/project-profiles/types.js.map +1 -1
  85. package/dist/prompt/function-calling-validate.js +2 -1
  86. package/dist/prompt/function-calling-validate.js.map +1 -1
  87. package/dist/prompt/function-calling.js +4 -0
  88. package/dist/prompt/function-calling.js.map +1 -1
  89. package/dist/prompt/function-defs/ask-question.js +4 -0
  90. package/dist/prompt/function-defs/ask-question.js.map +1 -1
  91. package/dist/prompt/function-defs/container-task-commands.d.ts +10 -0
  92. package/dist/prompt/function-defs/container-task-commands.js +185 -0
  93. package/dist/prompt/function-defs/container-task-commands.js.map +1 -0
  94. package/dist/prompt/function-defs/run-container-task.d.ts +11 -0
  95. package/dist/prompt/function-defs/run-container-task.js +41 -0
  96. package/dist/prompt/function-defs/run-container-task.js.map +1 -0
  97. package/dist/prompt/function-defs/web-search.d.ts +9 -0
  98. package/dist/prompt/function-defs/web-search.js +16 -0
  99. package/dist/prompt/function-defs/web-search.js.map +1 -0
  100. package/dist/prompt/limits.js +1 -1
  101. package/dist/prompt/steps/step-ask-question/handlers/container-task/command-execution-loop.d.ts +7 -0
  102. package/dist/prompt/steps/step-ask-question/handlers/container-task/command-execution-loop.js +301 -0
  103. package/dist/prompt/steps/step-ask-question/handlers/container-task/command-execution-loop.js.map +1 -0
  104. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/check-context.d.ts +12 -0
  105. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/check-context.js +41 -0
  106. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/check-context.js.map +1 -0
  107. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/complete-task.d.ts +4 -0
  108. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/complete-task.js +49 -0
  109. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/complete-task.js.map +1 -0
  110. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/copy-from-container.d.ts +4 -0
  111. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/copy-from-container.js +190 -0
  112. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/copy-from-container.js.map +1 -0
  113. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/copy-to-container.d.ts +4 -0
  114. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/copy-to-container.js +139 -0
  115. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/copy-to-container.js.map +1 -0
  116. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/edit-file.d.ts +10 -0
  117. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/edit-file.js +93 -0
  118. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/edit-file.js.map +1 -0
  119. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/fail-task.d.ts +4 -0
  120. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/fail-task.js +72 -0
  121. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/fail-task.js.map +1 -0
  122. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/gain-knowledge.d.ts +10 -0
  123. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/gain-knowledge.js +125 -0
  124. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/gain-knowledge.js.map +1 -0
  125. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/interrupt-controller.d.ts +19 -0
  126. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/interrupt-controller.js +33 -0
  127. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/interrupt-controller.js.map +1 -0
  128. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/query-knowledge.d.ts +8 -0
  129. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/query-knowledge.js +85 -0
  130. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/query-knowledge.js.map +1 -0
  131. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/request-secret.d.ts +6 -0
  132. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/request-secret.js +122 -0
  133. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/request-secret.js.map +1 -0
  134. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/run-command.d.ts +7 -0
  135. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/run-command.js +146 -0
  136. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/run-command.js.map +1 -0
  137. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/send-message.d.ts +4 -0
  138. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/send-message.js +56 -0
  139. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/send-message.js.map +1 -0
  140. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/set-execution-plan.d.ts +4 -0
  141. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/set-execution-plan.js +56 -0
  142. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/set-execution-plan.js.map +1 -0
  143. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/update-execution-plan.d.ts +4 -0
  144. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/update-execution-plan.js +39 -0
  145. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/update-execution-plan.js.map +1 -0
  146. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/view-file.d.ts +10 -0
  147. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/view-file.js +95 -0
  148. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/view-file.js.map +1 -0
  149. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/web-search.d.ts +2 -0
  150. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/web-search.js +96 -0
  151. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/web-search.js.map +1 -0
  152. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/wrap-context.d.ts +4 -0
  153. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/wrap-context.js +123 -0
  154. package/dist/prompt/steps/step-ask-question/handlers/container-task/commands/wrap-context.js.map +1 -0
  155. package/dist/prompt/steps/step-ask-question/handlers/container-task/container-command-handlers.d.ts +34 -0
  156. package/dist/prompt/steps/step-ask-question/handlers/container-task/container-command-handlers.js +332 -0
  157. package/dist/prompt/steps/step-ask-question/handlers/container-task/container-command-handlers.js.map +1 -0
  158. package/dist/prompt/steps/step-ask-question/handlers/container-task/container-commands-registry.d.ts +11 -0
  159. package/dist/prompt/steps/step-ask-question/handlers/container-task/container-commands-registry.js +50 -0
  160. package/dist/prompt/steps/step-ask-question/handlers/container-task/container-commands-registry.js.map +1 -0
  161. package/dist/prompt/steps/step-ask-question/handlers/container-task/container-commands-types.d.ts +28 -0
  162. package/dist/prompt/steps/step-ask-question/handlers/container-task/container-commands-types.js +2 -0
  163. package/dist/prompt/steps/step-ask-question/handlers/container-task/container-commands-types.js.map +1 -0
  164. package/dist/prompt/steps/step-ask-question/handlers/container-task/container-task-orchestrator.d.ts +2 -0
  165. package/dist/prompt/steps/step-ask-question/handlers/container-task/container-task-orchestrator.js +202 -0
  166. package/dist/prompt/steps/step-ask-question/handlers/container-task/container-task-orchestrator.js.map +1 -0
  167. package/dist/prompt/steps/step-ask-question/handlers/container-task/container-task-types.d.ts +52 -0
  168. package/dist/prompt/steps/step-ask-question/handlers/container-task/container-task-types.js +2 -0
  169. package/dist/prompt/steps/step-ask-question/handlers/container-task/container-task-types.js.map +1 -0
  170. package/dist/prompt/steps/step-ask-question/handlers/container-task/utils/docker-check.d.ts +4 -0
  171. package/dist/prompt/steps/step-ask-question/handlers/container-task/utils/docker-check.js +15 -0
  172. package/dist/prompt/steps/step-ask-question/handlers/container-task/utils/docker-check.js.map +1 -0
  173. package/dist/prompt/steps/step-ask-question/handlers/container-task/utils/docker-utils.d.ts +50 -0
  174. package/dist/prompt/steps/step-ask-question/handlers/container-task/utils/docker-utils.js +358 -0
  175. package/dist/prompt/steps/step-ask-question/handlers/container-task/utils/docker-utils.js.map +1 -0
  176. package/dist/prompt/steps/step-ask-question/handlers/handle-compound-action.js +2 -2
  177. package/dist/prompt/steps/step-ask-question/handlers/handle-compound-action.js.map +1 -1
  178. package/dist/prompt/steps/step-ask-question/handlers/handle-explore-external-directories.js +1 -1
  179. package/dist/prompt/steps/step-ask-question/handlers/handle-explore-external-directories.js.map +1 -1
  180. package/dist/prompt/steps/step-ask-question/handlers/handle-genaicode-help.js +1 -1
  181. package/dist/prompt/steps/step-ask-question/handlers/handle-genaicode-help.js.map +1 -1
  182. package/dist/prompt/steps/step-ask-question/handlers/handle-generate-image.js +2 -2
  183. package/dist/prompt/steps/step-ask-question/handlers/handle-generate-image.js.map +1 -1
  184. package/dist/prompt/steps/step-ask-question/handlers/handle-perform-analysis.js +1 -1
  185. package/dist/prompt/steps/step-ask-question/handlers/handle-perform-analysis.js.map +1 -1
  186. package/dist/prompt/steps/step-ask-question/handlers/handle-run-container-task.d.ts +2 -0
  187. package/dist/prompt/steps/step-ask-question/handlers/handle-run-container-task.js +7 -0
  188. package/dist/prompt/steps/step-ask-question/handlers/handle-run-container-task.js.map +1 -0
  189. package/dist/prompt/steps/step-ask-question/handlers/handle-send-message.js +1 -1
  190. package/dist/prompt/steps/step-ask-question/handlers/handle-send-message.js.map +1 -1
  191. package/dist/prompt/steps/step-ask-question/handlers/handle-web-search.d.ts +1 -0
  192. package/dist/prompt/steps/step-ask-question/handlers/handle-web-search.js +85 -0
  193. package/dist/prompt/steps/step-ask-question/handlers/handle-web-search.js.map +1 -0
  194. package/dist/prompt/steps/step-ask-question/step-ask-question-types.d.ts +1 -1
  195. package/dist/prompt/steps/step-ask-question/step-ask-question.d.ts +2 -0
  196. package/dist/prompt/steps/step-ask-question/step-ask-question.js +11 -1
  197. package/dist/prompt/steps/step-ask-question/step-ask-question.js.map +1 -1
  198. package/dist/prompt/steps/step-codegen-planning.js +1 -1
  199. package/dist/prompt/steps/step-codegen-planning.js.map +1 -1
  200. package/dist/prompt/steps/step-summarization.js +17 -10
  201. package/dist/prompt/steps/step-summarization.js.map +1 -1
  202. package/dist/prompt/systemprompt.js +3 -0
  203. package/dist/prompt/systemprompt.js.map +1 -1
  204. package/dist/utils/docker-utils.d.ts +37 -0
  205. package/dist/utils/docker-utils.js +258 -0
  206. package/dist/utils/docker-utils.js.map +1 -0
  207. package/dist/vite-genaicode/vite-genaicode-plugin.js +8 -1
  208. package/dist/vite-genaicode/vite-genaicode-plugin.js.map +1 -1
  209. package/package.json +13 -5
  210. package/dist/main/ui/frontend/assets/index-DylPpHEw.js +0 -2256
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy-from-container.js","sourceRoot":"","sources":["../../../../../../../src/prompt/steps/step-ask-question/handlers/container-task/commands/copy-from-container.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAC;AACpF,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AACjH,OAAO,EAAE,gCAAgC,EAAE,MAAM,+CAA+C,CAAC;AACjG,OAAO,EACL,0BAA0B,EAC1B,iBAAiB,EACjB,2BAA2B,EAC3B,2BAA2B,GAC5B,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAEtE,MAAM,CAAC,MAAM,uBA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, CommandHandlerResult } from '../container-commands-types.js';
3
+ export declare const getCopyToContainerDef: () => FunctionDef;
4
+ export declare function handleCopyToContainer(props: Pick<CommandHandlerBaseProps, 'actionResult' | 'taskExecutionPrompt' | 'container' | 'options'>): Promise<CommandHandlerResult>;
@@ -0,0 +1,139 @@
1
+ import { abortController } from '../../../../../../main/common/abort-controller.js';
2
+ import { putAssistantMessage, putContainerLog, putSystemMessage, putUserMessage, } from '../../../../../../main/common/content-bus.js';
3
+ import { askUserForConfirmationWithAnswer } from '../../../../../../main/common/user-actions.js';
4
+ import { checkPathExistsInContainer, copyToContainer as utilCopyToContainer } from '../utils/docker-utils.js';
5
+ import { rcConfig } from '../../../../../../main/config.js';
6
+ import { isAncestorDirectory } from '../../../../../../files/file-utils.js';
7
+ export const getCopyToContainerDef = () => ({
8
+ name: 'copyToContainer',
9
+ description: 'Copy a file or directory from the host to the container.',
10
+ parameters: {
11
+ type: 'object',
12
+ properties: {
13
+ hostPath: {
14
+ type: 'string',
15
+ description: `The absolute path of the file or directory on the host machine, which must be within the project root directory.\nThe file path must start from: ${rcConfig.rootDir}`,
16
+ },
17
+ containerPath: {
18
+ type: 'string',
19
+ description: 'The absolute destination path inside the container.',
20
+ },
21
+ },
22
+ required: ['hostPath', 'containerPath'],
23
+ },
24
+ });
25
+ export async function handleCopyToContainer(props) {
26
+ const { actionResult, taskExecutionPrompt, container, options } = props;
27
+ const args = actionResult.args;
28
+ if (abortController?.signal.aborted) {
29
+ putContainerLog('warn', 'Copy to container cancelled by user.', undefined, 'copy');
30
+ taskExecutionPrompt.push({ type: 'assistant', functionCalls: [actionResult] }, {
31
+ type: 'user',
32
+ functionResponses: [
33
+ { name: actionResult.name, call_id: actionResult.id || undefined, content: 'Operation cancelled by user.' },
34
+ ],
35
+ });
36
+ return { shouldBreakOuter: false, commandsExecutedIncrement: 0 };
37
+ }
38
+ // check if hostPath belongs to the project directory
39
+ if (!isAncestorDirectory(rcConfig.rootDir, args.hostPath)) {
40
+ const errorMsg = `Invalid host path: ${args.hostPath}. It must be within the project root directory: ${rcConfig.rootDir}`;
41
+ putContainerLog('error', errorMsg, args, 'copy');
42
+ putSystemMessage(`❌ ${errorMsg}`);
43
+ taskExecutionPrompt.push({
44
+ type: 'assistant',
45
+ functionCalls: [actionResult],
46
+ }, {
47
+ type: 'user',
48
+ functionResponses: [
49
+ {
50
+ name: actionResult.name,
51
+ call_id: actionResult.id || undefined,
52
+ content: `Error: Invalid host path. It must be within the project root directory: ${rcConfig.rootDir}.`,
53
+ },
54
+ ],
55
+ });
56
+ return { shouldBreakOuter: false, commandsExecutedIncrement: 0 };
57
+ }
58
+ // check if container path exists in container
59
+ if (!(await checkPathExistsInContainer(container, args.containerPath))) {
60
+ const errorMsg = `Invalid container path: ${args.containerPath}. It must be a valid path inside the container.`;
61
+ putContainerLog('error', errorMsg, args, 'copy');
62
+ putSystemMessage(`❌ ${errorMsg}`);
63
+ taskExecutionPrompt.push({
64
+ type: 'assistant',
65
+ functionCalls: [actionResult],
66
+ }, {
67
+ type: 'user',
68
+ functionResponses: [
69
+ {
70
+ name: actionResult.name,
71
+ call_id: actionResult.id || undefined,
72
+ content: `Error: Invalid container path. It must be a valid path inside the container. The path must exist, perhaps you need to create the directory first.`,
73
+ },
74
+ ],
75
+ });
76
+ return { shouldBreakOuter: false, commandsExecutedIncrement: 0 };
77
+ }
78
+ putAssistantMessage(`Preparing to copy from host path "${args.hostPath}" to container path "${args.containerPath}".`);
79
+ const confirmation = await askUserForConfirmationWithAnswer(`Do you want to proceed with the copy operation?`, 'Copy files to container', 'Reject', true, options);
80
+ if (confirmation.answer) {
81
+ putUserMessage(confirmation.answer);
82
+ }
83
+ if (!confirmation.confirmed) {
84
+ putContainerLog('warn', 'Copy to container cancelled by user.', undefined, 'copy');
85
+ putSystemMessage('Copy to container cancelled by user.');
86
+ taskExecutionPrompt.push({
87
+ type: 'assistant',
88
+ text: `Do you want to proceed with the copy operation?`,
89
+ functionCalls: [actionResult],
90
+ }, {
91
+ type: 'user',
92
+ functionResponses: [
93
+ {
94
+ name: actionResult.name,
95
+ call_id: actionResult.id || undefined,
96
+ content: 'I reject the copy operation.' + confirmation.answer,
97
+ },
98
+ ],
99
+ });
100
+ return { shouldBreakOuter: false, commandsExecutedIncrement: 0 };
101
+ }
102
+ try {
103
+ await utilCopyToContainer(container, args.hostPath, args.containerPath);
104
+ taskExecutionPrompt.push({
105
+ type: 'assistant',
106
+ text: `Do you want to proceed with the copy operation?`,
107
+ functionCalls: [actionResult],
108
+ }, {
109
+ type: 'user',
110
+ text: 'I approve the copy operation.' + (confirmation.answer ? ` ${confirmation.answer}` : ''),
111
+ functionResponses: [
112
+ {
113
+ name: actionResult.name,
114
+ call_id: actionResult.id || undefined,
115
+ content: `Successfully copied ${args.hostPath} to container path ${args.containerPath}.`,
116
+ },
117
+ ],
118
+ });
119
+ }
120
+ catch (error) {
121
+ const errorMessage = error instanceof Error ? error.message : String(error);
122
+ putSystemMessage('❌ Error copying to container', { error: errorMessage });
123
+ taskExecutionPrompt.push({
124
+ type: 'assistant',
125
+ functionCalls: [actionResult],
126
+ }, {
127
+ type: 'user',
128
+ functionResponses: [
129
+ {
130
+ name: actionResult.name,
131
+ call_id: actionResult.id || undefined,
132
+ content: `Error: ${errorMessage}`,
133
+ },
134
+ ],
135
+ });
136
+ }
137
+ return { shouldBreakOuter: false, commandsExecutedIncrement: 0 };
138
+ }
139
+ //# sourceMappingURL=copy-to-container.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy-to-container.js","sourceRoot":"","sources":["../../../../../../../src/prompt/steps/step-ask-question/handlers/container-task/commands/copy-to-container.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAC;AACpF,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,cAAc,GACf,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,gCAAgC,EAAE,MAAM,+CAA+C,CAAC;AACjG,OAAO,EAAE,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{ FunctionDef } from '../../../../../../ai-service/common-types.js';
2
+ import { CommandHandlerBaseProps, CommandHandlerResult } from '../container-commands-types.js';
3
+ export declare const editFileDef: FunctionDef;
4
+ export type EditFileArgs = {
5
+ reasoning: string;
6
+ filePath: string;
7
+ newContent?: string;
8
+ patch?: string;
9
+ };
10
+ export declare function handleEditFile(props: CommandHandlerBaseProps): Promise<CommandHandlerResult>;
@@ -0,0 +1,93 @@
1
+ import { putContainerLog } from '../../../../../../main/common/content-bus.js';
2
+ import { executeCommand, getFileContentFromContainer } from '../utils/docker-utils.js';
3
+ import * as diff from 'diff';
4
+ export const editFileDef = {
5
+ name: 'editFile',
6
+ description: 'Edit a text file inside the container. You can either provide the full new content or a patch in diff format.',
7
+ parameters: {
8
+ type: 'object',
9
+ properties: {
10
+ reasoning: {
11
+ type: 'string',
12
+ description: 'Explanation of why this file needs to be edited.',
13
+ },
14
+ filePath: {
15
+ type: 'string',
16
+ description: 'The absolute path to the file inside the container.',
17
+ },
18
+ newContent: {
19
+ type: 'string',
20
+ description: 'The full new content of the file. Use this for overwriting the file. Cannot be used with patch.',
21
+ },
22
+ patch: {
23
+ type: 'string',
24
+ description: 'A patch in diff format to apply to the file. Use this for partial updates. Cannot be used with newContent.',
25
+ },
26
+ },
27
+ required: ['reasoning', 'filePath'],
28
+ },
29
+ };
30
+ export async function handleEditFile(props) {
31
+ const { actionResult, taskExecutionPrompt, container } = props;
32
+ const args = actionResult.args;
33
+ const { reasoning, filePath, newContent, patch } = args;
34
+ try {
35
+ if (!newContent && !patch) {
36
+ throw new Error('Either newContent or patch must be provided for editFile.');
37
+ }
38
+ if (newContent && patch) {
39
+ throw new Error('Cannot provide both newContent and patch for editFile.');
40
+ }
41
+ putContainerLog('info', `Editing file: ${reasoning}`, args, 'command');
42
+ let finalContent;
43
+ if (patch) {
44
+ const originalContent = await getFileContentFromContainer(container, filePath);
45
+ const patchedContent = diff.applyPatch(originalContent, patch);
46
+ if (patchedContent === false) {
47
+ throw new Error('Failed to apply patch. The patch may be invalid or not apply cleanly. Try providing the full file content instead.');
48
+ }
49
+ finalContent = patchedContent;
50
+ }
51
+ else {
52
+ finalContent = newContent;
53
+ }
54
+ const { output, exitCode } = await executeCommand(container, '/bin/sh', `tee "${filePath}"`, finalContent, '/');
55
+ if (exitCode !== 0) {
56
+ throw new Error(`Failed to write to file: ${output}`);
57
+ }
58
+ const resultMessage = `File ${filePath} edited successfully.`;
59
+ putContainerLog('info', resultMessage, { filePath, exitCode, output }, 'command');
60
+ taskExecutionPrompt.push({
61
+ type: 'assistant',
62
+ functionCalls: [actionResult],
63
+ }, {
64
+ type: 'user',
65
+ functionResponses: [
66
+ {
67
+ name: actionResult.name,
68
+ call_id: actionResult.id,
69
+ content: resultMessage,
70
+ },
71
+ ],
72
+ });
73
+ }
74
+ catch (e) {
75
+ const errMessage = e instanceof Error ? e.message : String(e);
76
+ putContainerLog('error', 'An error occurred while editing the file', { error: errMessage });
77
+ taskExecutionPrompt.push({
78
+ type: 'assistant',
79
+ functionCalls: [actionResult],
80
+ }, {
81
+ type: 'user',
82
+ functionResponses: [
83
+ {
84
+ name: actionResult.name,
85
+ call_id: actionResult.id,
86
+ content: `File edit failed: ${errMessage}`,
87
+ },
88
+ ],
89
+ });
90
+ }
91
+ return { commandsExecutedIncrement: 1 };
92
+ }
93
+ //# sourceMappingURL=edit-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit-file.js","sourceRoot":"","sources":["../../../../../../../src/prompt/steps/step-ask-question/handlers/container-task/commands/edit-file.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAE/E,OAAO,EAAE,cAAc,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AACvF,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,MAAM,CAAC,MAAM,WAAW,GAAgB;IACtC,IAAI,EAAE,UAAU;IAChB,WAAW,EACT,+GAA+G;IACjH,UAAU,EAAE;QACV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SAC9B,EACD;YACE,IAAI,EAAE,MAAM;YACZ,iBAAiB,EAAE;gBACjB;oBACE,IAAI,EAAE,YAAY,CAAC,IAAI;oBACvB,OAAO,EAAE,YAAY,CAAC,EAAE;oBACxB,OAAO,EAAE,qBAAqB,UAAU,EAAE;iBAC3C;aACF;SACF,CACF,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,yBAAyB,EAAE,CAAC,EAAE,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { FunctionDef } from '../../../../../../ai-service/common-types.js';
2
+ import { CommandHandlerBaseProps, CommandHandlerResult } from '../container-commands-types.js';
3
+ export declare const failTaskDef: FunctionDef;
4
+ export declare function handleFailTask(props: Pick<CommandHandlerBaseProps, 'actionResult' | 'taskExecutionPrompt' | 'options'>): Promise<CommandHandlerResult>;
@@ -0,0 +1,72 @@
1
+ import { putAssistantMessage, putSystemMessage, putUserMessage } from '../../../../../../main/common/content-bus.js';
2
+ import { askUserForConfirmationWithAnswer } from '../../../../../../main/common/user-actions.js';
3
+ export const failTaskDef = {
4
+ name: 'failTask',
5
+ description: 'Mark the container task as failed.',
6
+ parameters: {
7
+ type: 'object',
8
+ properties: {
9
+ reason: {
10
+ type: 'string',
11
+ description: 'Explanation of why the task failed.',
12
+ },
13
+ },
14
+ required: ['reason'],
15
+ },
16
+ };
17
+ export async function handleFailTask(props) {
18
+ const { actionResult, taskExecutionPrompt, options } = props;
19
+ const args = actionResult.args;
20
+ putSystemMessage('❌ Task marked as failed by internal operator.');
21
+ putAssistantMessage(args.reason);
22
+ const confirmation = await askUserForConfirmationWithAnswer('Do you want to finish the failed task?', 'Finish', 'Continue', true, options);
23
+ if (!confirmation.confirmed) {
24
+ putSystemMessage('The user decided not to finish the failed task.');
25
+ if (confirmation.answer) {
26
+ putUserMessage(confirmation.answer);
27
+ }
28
+ taskExecutionPrompt.push({
29
+ type: 'assistant',
30
+ text: 'Failing the task.',
31
+ functionCalls: [actionResult],
32
+ }, {
33
+ type: 'user',
34
+ text: 'Lets not fail the task, and continue working on it. ' + (confirmation.answer ? confirmation.answer : ''),
35
+ functionResponses: [
36
+ {
37
+ name: actionResult.name,
38
+ call_id: actionResult.id || undefined,
39
+ },
40
+ ],
41
+ });
42
+ return {
43
+ shouldBreakOuter: false,
44
+ commandsExecutedIncrement: 0,
45
+ };
46
+ }
47
+ putSystemMessage('The user decided to finish the failed task.');
48
+ if (confirmation.answer) {
49
+ putUserMessage(confirmation.answer);
50
+ }
51
+ taskExecutionPrompt.push({
52
+ type: 'assistant',
53
+ text: 'Failing the task.',
54
+ functionCalls: [actionResult],
55
+ }, {
56
+ type: 'user',
57
+ functionResponses: [
58
+ {
59
+ name: actionResult.name,
60
+ call_id: actionResult.id || undefined,
61
+ content: 'Task marked as failed.',
62
+ },
63
+ ],
64
+ });
65
+ return {
66
+ shouldBreakOuter: true,
67
+ success: false,
68
+ summary: args.reason,
69
+ commandsExecutedIncrement: 0,
70
+ };
71
+ }
72
+ //# sourceMappingURL=fail-task.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fail-task.js","sourceRoot":"","sources":["../../../../../../../src/prompt/steps/step-ask-question/handlers/container-task/commands/fail-task.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,8CAA8C,CAAC;AACrH,OAAO,EAAE,gCAAgC,EAAE,MAAM,+CAA+C,CAAC;AAGjG,MAAM,CAAC,MAAM,WAAW,GAAgB;IACtC,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,oCAAoC;IACjD,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,qCAAqC;aACnD;SACF;QACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;KACrB;CACF,CAAC;AAMF,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,KAAwF;IAExF,MAAM,EAAE,Y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ACzB,aAAa,EAAE,CAAC,YAAY,CAAC;KAC9B,EACD;QACE,IAAI,EAAE,MAAM;QACZ,iBAAiB,EAAE;YACjB;gBACE,IAAI,EAAE,YAAY,CAAC,IAAI;gBACvB,OAAO,EAAE,YAAY,CAAC,EAAE,IAAI,SAAS;gBACrC,OAAO,EAAE,wBAAwB;aAClC;SACF;KACF,CACF,CAAC;IACF,OAAO;QACL,gBAAgB,EAAE,IAAI;QACtB,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,IAAI,CAAC,MAAM;QACpB,yBAAyB,EAAE,CAAC;KAC7B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { FunctionDef, PromptItem } from '../../../../../../ai-service/common-types.js';
2
+ import { CommandHandlerResult, CommandHandlerBaseProps } from '../container-commands-types.js';
3
+ export declare const gainKnowledgeDef: FunctionDef;
4
+ export declare function handleGainKnowledge(props: CommandHandlerBaseProps): Promise<CommandHandlerResult>;
5
+ export declare function maybeGainKnowledge(props: CommandHandlerBaseProps & {
6
+ taskDescription: string;
7
+ summary: string;
8
+ systemPrompt: PromptItem;
9
+ taskPrompt: PromptItem;
10
+ }): Promise<void>;
@@ -0,0 +1,125 @@
1
+ import { ModelType } from '../../../../../../ai-service/common-types.js';
2
+ import { appendKnowledge, getKnowledgeBase, knowledgeContextDef, } from '../../../../../../main/knowledge/knowledge-store.js';
3
+ import { putContainerLog } from '../../../../../../main/common/content-bus.js';
4
+ export const gainKnowledgeDef = {
5
+ name: 'gainKnowledge',
6
+ description: `Persist a new knowledge entry capturing a prompt, its answer/insight, and optional tags/metadata. Use this to record successful operations, solutions to problems, or any other valuable information that could help in future tasks. Avoid storing secrets.
7
+ Before calling this function make sure to check if the information you want to store not exists already in the knowledge base using queryKnowledge tool.`,
8
+ parameters: {
9
+ type: 'object',
10
+ properties: {
11
+ prompt: {
12
+ type: 'string',
13
+ description: 'The problem, question, or description of the situation.',
14
+ },
15
+ answer: {
16
+ type: 'string',
17
+ description: 'The validated solution, insight, or outcome.',
18
+ },
19
+ metadata: {
20
+ type: 'object',
21
+ description: 'Optional structured data, e.g., { "exitCode": 0, "relevantFile": "package.json" }.',
22
+ },
23
+ explanation: {
24
+ type: 'string',
25
+ description: 'A brief explanation of why this knowledge is valuable to store.',
26
+ },
27
+ knowledgeType: {
28
+ type: 'string',
29
+ description: 'The type of knowledge being captured',
30
+ enum: ['project specific', 'general', 'docker quirks', 'other'],
31
+ },
32
+ },
33
+ required: ['prompt', 'answer', 'explanation', 'knowledgeType'],
34
+ },
35
+ };
36
+ export async function handleGainKnowledge(props) {
37
+ const { actionResult, taskExecutionPrompt } = props;
38
+ const args = actionResult.args;
39
+ taskExecutionPrompt.push({
40
+ type: 'assistant',
41
+ functionCalls: [actionResult],
42
+ });
43
+ try {
44
+ const newEntry = await appendKnowledge(args);
45
+ const message = `Successfully added knowledge entry ${newEntry.id}.`;
46
+ putContainerLog('info', message, newEntry);
47
+ taskExecutionPrompt.push({
48
+ type: 'user',
49
+ functionResponses: [
50
+ {
51
+ name: actionResult.name,
52
+ call_id: actionResult.id,
53
+ content: JSON.stringify({ id: newEntry.id, success: true }),
54
+ },
55
+ ],
56
+ });
57
+ }
58
+ catch (error) {
59
+ const errorMessage = error instanceof Error ? error.message : String(error);
60
+ putContainerLog('error', `Failed to add knowledge entry: ${errorMessage}`, {
61
+ error,
62
+ });
63
+ taskExecutionPrompt.push({
64
+ type: 'user',
65
+ functionResponses: [
66
+ {
67
+ name: actionResult.name,
68
+ call_id: actionResult.id,
69
+ content: `Failed to add knowledge entry: ${errorMessage}`,
70
+ },
71
+ ],
72
+ });
73
+ }
74
+ }
75
+ export async function maybeGainKnowledge(props) {
76
+ const { generateContentFn, taskExecutionPrompt } = props;
77
+ try {
78
+ const knowledgeBase = await getKnowledgeBase();
79
+ const corpus = knowledgeBase.map(({ id, prompt, answer }) => ({ id, prompt, answer }));
80
+ const response = await generateContentFn([
81
+ props.systemPrompt,
82
+ props.taskPrompt,
83
+ ...taskExecutionPrompt,
84
+ {
85
+ type: 'assistant',
86
+ functionCalls: [
87
+ {
88
+ name: knowledgeContextDef.name,
89
+ args: {},
90
+ },
91
+ ],
92
+ },
93
+ {
94
+ type: 'user',
95
+ functionResponses: [
96
+ {
97
+ name: knowledgeContextDef.name,
98
+ content: JSON.stringify({ corpus }),
99
+ },
100
+ ],
101
+ },
102
+ ], {
103
+ modelType: ModelType.DEFAULT,
104
+ temperature: 0.2,
105
+ functionDefs: [knowledgeContextDef, gainKnowledgeDef],
106
+ requiredFunctionName: gainKnowledgeDef.name,
107
+ expectedResponseType: {
108
+ text: false,
109
+ functionCall: true,
110
+ },
111
+ }, { disableCache: true });
112
+ const gainKnowledgeCall = response.find((part) => part.type === 'functionCall')?.functionCall;
113
+ if (gainKnowledgeCall?.name !== 'gainKnowledge') {
114
+ putContainerLog('info', 'No knowledge gain needed based on current context.');
115
+ return;
116
+ }
117
+ // Intentionally not awaiting this
118
+ handleGainKnowledge({ ...props, actionResult: gainKnowledgeCall });
119
+ }
120
+ catch (error) {
121
+ const errorMessage = error instanceof Error ? error.message : String(error);
122
+ putContainerLog('error', 'Error during maybeGainKnowledge execution', { error: errorMessage });
123
+ }
124
+ }
125
+ //# sourceMappingURL=gain-knowledge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gain-knowledge.js","sourceRoot":"","sources":["../../../../../../../src/prompt/steps/step-ask-question/handlers/container-task/commands/gain-knowledge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,SAAS,EAAc,MAAM,8CAA8C,CAAC;AAElG,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,qDAAqD,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAE/E,MAAM,CAAC,MAAM,gBAAgB,GAAgB;IAC3C,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE;yJAC0I;IACvJ,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;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AI,EAAE,MAAM;gBACZ,iBAAiB,EAAE;oBACjB;wBACE,IAAI,EAAE,mBAAmB,CAAC,IAAI;wBAC9B,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;qBACpC;iBACF;aACF;SACF,EACD;YACE,SAAS,EAAE,SAAS,CAAC,OAAO;YAC5B,WAAW,EAAE,GAAG;YAChB,YAAY,EAAE,CAAC,mBAAmB,EAAE,gBAAgB,CAAC;YACrD,oBAAoB,EAAE,gBAAgB,CAAC,IAAI;YAC3C,oBAAoB,EAAE;gBACpB,IAAI,EAAE,KAAK;gBACX,YAAY,EAAE,IAAI;aACnB;SACF,EACD,EAAE,YAAY,EAAE,IAAI,EAAE,CACvB,CAAC;QAEF,MAAM,iBAAiB,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,EAAE,YAAY,CAAC;QAE9F,IAAI,iBAAiB,EAAE,IAAI,KAAK,eAAe,EAAE,CAAC;YAChD,eAAe,CAAC,MAAM,EAAE,oDAAoD,CAAC,CAAC;YAC9E,OAAO;QACT,CAAC;QACD,kCAAkC;QAClC,mBAAmB,CAAC,EAAE,GAAG,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC,CAAC;IACrE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,eAAe,CAAC,OAAO,EAAE,2CAA2C,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;IACjG,CAAC;AACH,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Requests an interrupt for the current container command.
3
+ * @returns An object indicating whether the interrupt request was accepted.
4
+ */
5
+ export declare function requestInterrupt(): {
6
+ accepted: boolean;
7
+ };
8
+ /**
9
+ * Sets a listener for when an interrupt is requested.
10
+ * @param fn The function to call when an interrupt is requested.
11
+ * @returns A function to remove the listener.
12
+ */
13
+ export declare function onInterruptRequested(fn: () => void): () => void;
14
+ /**
15
+ * Checks if an interrupt has been requested.
16
+ * @returns True if an interrupt has been requested, false otherwise.
17
+ */
18
+ export declare function isInterrupted(): boolean;
19
+ export declare function clearInterruption(): void;
@@ -0,0 +1,33 @@
1
+ import { putContainerLog } from '../../../../../../main/common/content-bus.js';
2
+ let interruptionController = new AbortController();
3
+ /**
4
+ * Requests an interrupt for the current container command.
5
+ * @returns An object indicating whether the interrupt request was accepted.
6
+ */
7
+ export function requestInterrupt() {
8
+ putContainerLog('warn', `User requested to interrupt current command.`);
9
+ interruptionController.abort();
10
+ return { accepted: true };
11
+ }
12
+ /**
13
+ * Sets a listener for when an interrupt is requested.
14
+ * @param fn The function to call when an interrupt is requested.
15
+ * @returns A function to remove the listener.
16
+ */
17
+ export function onInterruptRequested(fn) {
18
+ interruptionController.signal.addEventListener('abort', fn);
19
+ return () => {
20
+ interruptionController.signal.removeEventListener('abort', fn);
21
+ };
22
+ }
23
+ /**
24
+ * Checks if an interrupt has been requested.
25
+ * @returns True if an interrupt has been requested, false otherwise.
26
+ */
27
+ export function isInterrupted() {
28
+ return interruptionController.signal.aborted;
29
+ }
30
+ export function clearInterruption() {
31
+ interruptionController = new AbortController();
32
+ }
33
+ //# sourceMappingURL=interrupt-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interrupt-controller.js","sourceRoot":"","sources":["../../../../../../../src/prompt/steps/step-ask-question/handlers/container-task/commands/interrupt-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAC;AAE/E,IAAI,sBAAsB,GAAG,IAAI,eAAe,EAAE,CAAC;AAEnD;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC9B,eAAe,CAAC,MAAM,EAAE,8CAA8C,CAAC,CAAC;IAExE,sBAAsB,CAAC,KAAK,EAAE,CAAC;IAE/B,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAC5B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,EAAc;IACjD,sBAAsB,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC5D,OAAO,GAAG,EAAE;QACV,sBAAsB,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACjE,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,sBAAsB,CAAC,MAAM,CAAC,OAAO,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,sBAAsB,GAAG,IAAI,eAAe,EAAE,CAAC;AACjD,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { FunctionDef, PromptItem } from '../../../../../../ai-service/common-types.js';
2
+ import { CommandHandlerResult, CommandHandlerBaseProps } from '../container-commands-types.js';
3
+ export declare const queryKnowledgeDef: FunctionDef;
4
+ export declare function handleQueryKnowledge(props: CommandHandlerBaseProps): Promise<CommandHandlerResult>;
5
+ export declare function maybeQueryKnowledge(props: CommandHandlerBaseProps & {
6
+ systemPrompt: PromptItem;
7
+ taskPrompt: PromptItem;
8
+ }): Promise<CommandHandlerResult>;