genaicode 0.9.3 → 0.9.5

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 (136) hide show
  1. package/dist/ai-service/anthropic.js +4 -1
  2. package/dist/ai-service/anthropic.js.map +1 -1
  3. package/dist/ai-service/common.js +1 -1
  4. package/dist/ai-service/common.js.map +1 -1
  5. package/dist/ai-service/openai.js +1 -1
  6. package/dist/ai-service/openai.js.map +1 -1
  7. package/dist/ai-service/service-configurations.js +1 -1
  8. package/dist/ai-service/service-configurations.js.map +1 -1
  9. package/dist/files/cache-file.d.ts +4 -1
  10. package/dist/files/cache-file.js.map +1 -1
  11. package/dist/files/file-id-utils.d.ts +7 -0
  12. package/dist/files/file-id-utils.js +25 -0
  13. package/dist/files/file-id-utils.js.map +1 -0
  14. package/dist/files/read-files.js +8 -8
  15. package/dist/files/read-files.js.map +1 -1
  16. package/dist/files/source-code-tree.js +3 -3
  17. package/dist/files/source-code-tree.js.map +1 -1
  18. package/dist/files/source-code-types.d.ts +21 -3
  19. package/dist/files/summary-cache.d.ts +3 -2
  20. package/dist/files/summary-cache.js +1 -1
  21. package/dist/files/summary-cache.js.map +1 -1
  22. package/dist/main/common/content-bus-types.d.ts +1 -1
  23. package/dist/main/common/content-bus.js +1 -1
  24. package/dist/main/common/content-bus.js.map +1 -1
  25. package/dist/main/config-schema.js +1 -1
  26. package/dist/main/config-schema.js.map +1 -1
  27. package/dist/main/ui/frontend/assets/{index-CSR1NiB_.js → index-Dizqxzws.js} +226 -187
  28. package/dist/main/ui/frontend/index.html +1 -1
  29. package/dist/prompt/ai-service-fallback.js +5 -1
  30. package/dist/prompt/ai-service-fallback.js.map +1 -1
  31. package/dist/prompt/function-calling.js +8 -1
  32. package/dist/prompt/function-calling.js.map +1 -1
  33. package/dist/prompt/function-defs/ask-question.d.ts +3 -0
  34. package/dist/prompt/function-defs/ask-question.js +43 -1
  35. package/dist/prompt/function-defs/ask-question.js.map +1 -1
  36. package/dist/prompt/function-defs/context-compression.d.ts +25 -5
  37. package/dist/prompt/function-defs/context-compression.js +23 -8
  38. package/dist/prompt/function-defs/context-compression.js.map +1 -1
  39. package/dist/prompt/function-defs/conversation-graph.d.ts +33 -0
  40. package/dist/prompt/function-defs/conversation-graph.js +110 -0
  41. package/dist/prompt/function-defs/conversation-graph.js.map +1 -0
  42. package/dist/prompt/function-defs/extract-file-fragments.d.ts +27 -0
  43. package/dist/prompt/function-defs/extract-file-fragments.js +36 -0
  44. package/dist/prompt/function-defs/extract-file-fragments.js.map +1 -0
  45. package/dist/prompt/steps/step-ask-question/ask-question-handler.d.ts +2 -0
  46. package/dist/prompt/steps/step-ask-question/ask-question-handler.js +12 -0
  47. package/dist/prompt/steps/step-ask-question/ask-question-handler.js.map +1 -0
  48. package/dist/prompt/steps/step-ask-question/handlers/code-generation.js +1 -0
  49. package/dist/prompt/steps/step-ask-question/handlers/code-generation.js.map +1 -1
  50. package/dist/prompt/steps/step-ask-question/handlers/file-request-utils.d.ts +47 -0
  51. package/dist/prompt/steps/step-ask-question/handlers/file-request-utils.js +114 -0
  52. package/dist/prompt/steps/step-ask-question/handlers/file-request-utils.js.map +1 -0
  53. package/dist/prompt/steps/step-ask-question/handlers/handle-code-generation.d.ts +4 -0
  54. package/dist/prompt/steps/step-ask-question/handlers/handle-code-generation.js +169 -0
  55. package/dist/prompt/steps/step-ask-question/handlers/handle-code-generation.js.map +1 -0
  56. package/dist/prompt/steps/step-ask-question/handlers/handle-confirm-code-generation.d.ts +2 -0
  57. package/dist/prompt/steps/step-ask-question/handlers/handle-confirm-code-generation.js +40 -0
  58. package/dist/prompt/steps/step-ask-question/handlers/handle-confirm-code-generation.js.map +1 -0
  59. package/dist/prompt/steps/step-ask-question/handlers/handle-context-compression.js +2 -0
  60. package/dist/prompt/steps/step-ask-question/handlers/handle-context-compression.js.map +1 -1
  61. package/dist/prompt/steps/step-ask-question/handlers/handle-context-optimization.d.ts +2 -0
  62. package/dist/prompt/steps/step-ask-question/handlers/handle-context-optimization.js +34 -0
  63. package/dist/prompt/steps/step-ask-question/handlers/handle-context-optimization.js.map +1 -0
  64. package/dist/prompt/steps/step-ask-question/handlers/handle-conversation-graph.d.ts +12 -0
  65. package/dist/prompt/steps/step-ask-question/handlers/handle-conversation-graph.js +243 -0
  66. package/dist/prompt/steps/step-ask-question/handlers/handle-conversation-graph.js.map +1 -0
  67. package/dist/prompt/steps/step-ask-question/handlers/handle-create-file.d.ts +2 -2
  68. package/dist/prompt/steps/step-ask-question/handlers/handle-create-file.js +5 -3
  69. package/dist/prompt/steps/step-ask-question/handlers/handle-create-file.js.map +1 -1
  70. package/dist/prompt/steps/step-ask-question/handlers/handle-end-conversation.js +2 -0
  71. package/dist/prompt/steps/step-ask-question/handlers/handle-end-conversation.js.map +1 -1
  72. package/dist/prompt/steps/step-ask-question/handlers/handle-genaicode-help.js +2 -0
  73. package/dist/prompt/steps/step-ask-question/handlers/handle-genaicode-help.js.map +1 -1
  74. package/dist/prompt/steps/step-ask-question/handlers/handle-generate-image.js +2 -0
  75. package/dist/prompt/steps/step-ask-question/handlers/handle-generate-image.js.map +1 -1
  76. package/dist/prompt/steps/step-ask-question/handlers/handle-lint.d.ts +6 -0
  77. package/dist/prompt/steps/step-ask-question/handlers/handle-lint.js +105 -0
  78. package/dist/prompt/steps/step-ask-question/handlers/handle-lint.js.map +1 -0
  79. package/dist/prompt/steps/step-ask-question/handlers/handle-perform-analysis.js +4 -5
  80. package/dist/prompt/steps/step-ask-question/handlers/handle-perform-analysis.js.map +1 -1
  81. package/dist/prompt/steps/step-ask-question/handlers/handle-pull-app-context.js +2 -0
  82. package/dist/prompt/steps/step-ask-question/handlers/handle-pull-app-context.js.map +1 -1
  83. package/dist/prompt/steps/step-ask-question/handlers/handle-push-app-context.js +2 -0
  84. package/dist/prompt/steps/step-ask-question/handlers/handle-push-app-context.js.map +1 -1
  85. package/dist/prompt/steps/step-ask-question/handlers/handle-reasoning-inference.js +3 -3
  86. package/dist/prompt/steps/step-ask-question/handlers/handle-reasoning-inference.js.map +1 -1
  87. package/dist/prompt/steps/step-ask-question/handlers/handle-remove-files-from-context.d.ts +2 -0
  88. package/dist/prompt/steps/step-ask-question/handlers/handle-remove-files-from-context.js +88 -0
  89. package/dist/prompt/steps/step-ask-question/handlers/handle-remove-files-from-context.js.map +1 -0
  90. package/dist/prompt/steps/step-ask-question/handlers/handle-request-files-content.d.ts +8 -0
  91. package/dist/prompt/steps/step-ask-question/handlers/handle-request-files-content.js +136 -0
  92. package/dist/prompt/steps/step-ask-question/handlers/handle-request-files-content.js.map +1 -0
  93. package/dist/prompt/steps/step-ask-question/handlers/handle-request-files-fragments.d.ts +8 -0
  94. package/dist/prompt/steps/step-ask-question/handlers/handle-request-files-fragments.js +173 -0
  95. package/dist/prompt/steps/step-ask-question/handlers/handle-request-files-fragments.js.map +1 -0
  96. package/dist/prompt/steps/step-ask-question/handlers/handle-request-permissions.d.ts +2 -0
  97. package/dist/prompt/steps/step-ask-question/handlers/handle-request-permissions.js +71 -0
  98. package/dist/prompt/steps/step-ask-question/handlers/handle-request-permissions.js.map +1 -0
  99. package/dist/prompt/steps/step-ask-question/handlers/handle-search-code.d.ts +0 -3
  100. package/dist/prompt/steps/step-ask-question/handlers/handle-search-code.js +2 -3
  101. package/dist/prompt/steps/step-ask-question/handlers/handle-search-code.js.map +1 -1
  102. package/dist/prompt/steps/step-ask-question/handlers/handle-send-message.js +2 -0
  103. package/dist/prompt/steps/step-ask-question/handlers/handle-send-message.js.map +1 -1
  104. package/dist/prompt/steps/step-ask-question/handlers/handle-update-file.d.ts +2 -2
  105. package/dist/prompt/steps/step-ask-question/handlers/handle-update-file.js +6 -4
  106. package/dist/prompt/steps/step-ask-question/handlers/handle-update-file.js.map +1 -1
  107. package/dist/prompt/steps/step-ask-question/handlers/request-files-content.js +7 -3
  108. package/dist/prompt/steps/step-ask-question/handlers/request-files-content.js.map +1 -1
  109. package/dist/prompt/steps/step-ask-question/step-ask-question-handlers.d.ts +3 -0
  110. package/dist/prompt/steps/step-ask-question/step-ask-question-handlers.js +5 -0
  111. package/dist/prompt/steps/step-ask-question/step-ask-question-handlers.js.map +1 -0
  112. package/dist/prompt/steps/step-ask-question/step-ask-question-types.d.ts +13 -2
  113. package/dist/prompt/steps/step-ask-question/step-ask-question.d.ts +21 -0
  114. package/dist/prompt/steps/step-ask-question/step-ask-question.js +30 -71
  115. package/dist/prompt/steps/step-ask-question/step-ask-question.js.map +1 -1
  116. package/dist/prompt/steps/step-codegen-planning.js +1 -3
  117. package/dist/prompt/steps/step-codegen-planning.js.map +1 -1
  118. package/dist/prompt/steps/step-context-compression.d.ts +1 -1
  119. package/dist/prompt/steps/step-context-compression.js +130 -34
  120. package/dist/prompt/steps/step-context-compression.js.map +1 -1
  121. package/dist/prompt/steps/step-context-optimization.js +7 -68
  122. package/dist/prompt/steps/step-context-optimization.js.map +1 -1
  123. package/dist/prompt/steps/step-generate-codegen-summary.js +1 -3
  124. package/dist/prompt/steps/step-generate-codegen-summary.js.map +1 -1
  125. package/dist/prompt/steps/step-history-update.js +1 -3
  126. package/dist/prompt/steps/step-history-update.js.map +1 -1
  127. package/dist/prompt/steps/step-process-file-updates.js +0 -3
  128. package/dist/prompt/steps/step-process-file-updates.js.map +1 -1
  129. package/dist/prompt/steps/step-summarization.d.ts +2 -1
  130. package/dist/prompt/steps/step-summarization.js +6 -5
  131. package/dist/prompt/steps/step-summarization.js.map +1 -1
  132. package/dist/prompt/steps/step-verify-patch.js +1 -3
  133. package/dist/prompt/steps/step-verify-patch.js.map +1 -1
  134. package/dist/prompt/systemprompt.js +5 -3
  135. package/dist/prompt/systemprompt.js.map +1 -1
  136. package/package.json +4 -4
@@ -0,0 +1,47 @@
1
+ import { PromptItem } from '../../../../ai-service/common-types.js';
2
+ import { CodegenOptions } from '../../../../main/codegen-types.js';
3
+ /**
4
+ * Checks if a file's content is already provided in the conversation history
5
+ * @param filePath The path of the file to check
6
+ * @param prompt The conversation history
7
+ * @returns true if the file content is already available in the history
8
+ */
9
+ export declare function isFileContentAlreadyProvided(filePath: string, prompt: PromptItem[]): boolean;
10
+ /**
11
+ * Categorizes requested files into legitimate and illegitimate files
12
+ * @param requestedFiles Array of file paths to categorize
13
+ * @returns Object containing arrays of legitimate and illegitimate file paths
14
+ */
15
+ export declare function categorizeLegitimateFiles(requestedFiles: string[]): {
16
+ legitimateFiles: string[];
17
+ illegitimateFiles: string[];
18
+ };
19
+ /**
20
+ * Checks if a file path is legitimate (exists in the source files)
21
+ * @param filePath The path of the file to check
22
+ * @returns true if the file path is legitimate
23
+ */
24
+ export declare function isFilePathLegitimate(filePath: string): boolean;
25
+ /**
26
+ * Process file requests by checking if they are already provided and categorizing them
27
+ * @param requestedFiles Array of file paths to process
28
+ * @param prompt The conversation history
29
+ * @param options Codegen options
30
+ * @returns Processed file request information
31
+ */
32
+ export declare function processFileRequests(requestedFiles: string[], prompt: PromptItem[], options: CodegenOptions): {
33
+ requestedFiles: string[];
34
+ alreadyProvidedFiles: string[];
35
+ legitimateFiles: string[];
36
+ illegitimateFiles: string[];
37
+ };
38
+ /**
39
+ * Generate a user-friendly message about file processing status
40
+ * @param alreadyProvidedFiles Files already provided in conversation
41
+ * @param requestedFiles Files that were requested
42
+ * @param legitimateFiles Files that are legitimate and will be processed
43
+ * @param illegitimateFiles Files that are not legitimate
44
+ * @param type Type of content being provided ('content' or 'fragments')
45
+ * @returns A formatted message string
46
+ */
47
+ export declare function generateFilesContentPrompt(alreadyProvidedFiles: string[], requestedFiles: string[], legitimateFiles: string[], illegitimateFiles: string[], type: 'content' | 'fragments'): string;
@@ -0,0 +1,114 @@
1
+ import { getSourceFiles } from '../../../../files/find-files.js';
2
+ import { refreshFiles } from '../../../../files/find-files.js';
3
+ import { getExpandedContextPaths } from '../../../../files/source-code-utils.js';
4
+ import { putSystemMessage } from '../../../../main/common/content-bus.js';
5
+ /**
6
+ * Checks if a file's content is already provided in the conversation history
7
+ * @param filePath The path of the file to check
8
+ * @param prompt The conversation history
9
+ * @returns true if the file content is already available in the history
10
+ */
11
+ export function isFileContentAlreadyProvided(filePath, prompt) {
12
+ return prompt.some((item) => {
13
+ if (item.type !== 'user' || !item.functionResponses) {
14
+ return false;
15
+ }
16
+ return item.functionResponses.some((response) => {
17
+ if (response.name !== 'getSourceCode' || !response.content) {
18
+ return false;
19
+ }
20
+ try {
21
+ const sourceCodeMap = JSON.parse(response.content);
22
+ return (sourceCodeMap[filePath] &&
23
+ sourceCodeMap[filePath] &&
24
+ 'content' in sourceCodeMap[filePath] &&
25
+ sourceCodeMap[filePath].content !== null);
26
+ }
27
+ catch (error) {
28
+ console.warn('Error parsing getSourceCode response:', error);
29
+ return false;
30
+ }
31
+ });
32
+ });
33
+ }
34
+ /**
35
+ * Categorizes requested files into legitimate and illegitimate files
36
+ * @param requestedFiles Array of file paths to categorize
37
+ * @returns Object containing arrays of legitimate and illegitimate file paths
38
+ */
39
+ export function categorizeLegitimateFiles(requestedFiles) {
40
+ const legitimateFiles = [];
41
+ const illegitimateFiles = [];
42
+ requestedFiles.forEach((filePath) => {
43
+ if (isFilePathLegitimate(filePath)) {
44
+ legitimateFiles.push(filePath);
45
+ }
46
+ else {
47
+ illegitimateFiles.push(filePath);
48
+ }
49
+ });
50
+ return { legitimateFiles, illegitimateFiles };
51
+ }
52
+ /**
53
+ * Checks if a file path is legitimate (exists in the source files)
54
+ * @param filePath The path of the file to check
55
+ * @returns true if the file path is legitimate
56
+ */
57
+ export function isFilePathLegitimate(filePath) {
58
+ return getSourceFiles().includes(filePath);
59
+ }
60
+ /**
61
+ * Process file requests by checking if they are already provided and categorizing them
62
+ * @param requestedFiles Array of file paths to process
63
+ * @param prompt The conversation history
64
+ * @param options Codegen options
65
+ * @returns Processed file request information
66
+ */
67
+ export function processFileRequests(requestedFiles, prompt, options) {
68
+ // Expand context paths
69
+ requestedFiles = getExpandedContextPaths(requestedFiles, options);
70
+ // Check which files are already provided in the conversation history
71
+ const alreadyProvidedFiles = requestedFiles.filter((file) => isFileContentAlreadyProvided(file, prompt));
72
+ // Filter out already provided files
73
+ requestedFiles = requestedFiles.filter((file) => !isFileContentAlreadyProvided(file, prompt));
74
+ // Refresh files in case new files appeared
75
+ refreshFiles();
76
+ // Categorize files into legitimate and illegitimate
77
+ const { legitimateFiles, illegitimateFiles } = categorizeLegitimateFiles(requestedFiles);
78
+ putSystemMessage('Processing file requests', {
79
+ requestedFiles,
80
+ alreadyProvidedFiles,
81
+ legitimateFiles,
82
+ illegitimateFiles,
83
+ });
84
+ return {
85
+ requestedFiles,
86
+ alreadyProvidedFiles,
87
+ legitimateFiles,
88
+ illegitimateFiles,
89
+ };
90
+ }
91
+ /**
92
+ * Generate a user-friendly message about file processing status
93
+ * @param alreadyProvidedFiles Files already provided in conversation
94
+ * @param requestedFiles Files that were requested
95
+ * @param legitimateFiles Files that are legitimate and will be processed
96
+ * @param illegitimateFiles Files that are not legitimate
97
+ * @param type Type of content being provided ('content' or 'fragments')
98
+ * @returns A formatted message string
99
+ */
100
+ export function generateFilesContentPrompt(alreadyProvidedFiles, requestedFiles, legitimateFiles, illegitimateFiles, type) {
101
+ return ((alreadyProvidedFiles.length > 0
102
+ ? `Some files were already provided in the conversation history:
103
+ ${alreadyProvidedFiles.map((path) => `- ${path}`).join('\n')}
104
+
105
+ Providing ${type} for the remaining files:
106
+ ${requestedFiles.map((path) => `- ${path}`).join('\n')}`
107
+ : `All requested file ${type} have been provided:
108
+ ${legitimateFiles.map((path) => `- ${path}`).join('\n')}`) +
109
+ (illegitimateFiles.length > 0
110
+ ? `\n\nSome files are not legitimate and their ${type} cannot be provided:
111
+ ${illegitimateFiles.map((path) => `- ${path}`).join('\n')}`
112
+ : ''));
113
+ }
114
+ //# sourceMappingURL=file-request-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-request-utils.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/file-request-utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,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;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,0BAA0B,CACxC,oBAA8B,EAC9B,cAAwB,EACxB,eAAyB,EACzB,iBAA2B,EAC3B,IAA6B;IAE7B,OAAO,CACL,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC;QAC9B,CAAC,CAAC;EACN,oBAAoB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;YAEhD,IAAI;EACd,cAAc,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QAClD,CAAC,CAAC,sBAAsB,IAAI;EAChC,eAAe,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACtD,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC;YAC3B,CAAC,CAAC,+CAA+C,IAAI;EACzD,iBAAiB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACrD,CAAC,CAAC,EAAE,CAAC,CACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';
2
+ export declare const CODEGEN_SUMMARY_GENERATED_MESSAGE = "Codegen summary is generated. Would you like to proceed with the code changes?";
3
+ export declare const CODEGEN_SUMMARY_APPROVED = "Accept codegen summary and continue";
4
+ export declare function handleCodeGeneration({ generateContentFn, generateImageFn, waitIfPaused, prompt, options, }: ActionHandlerProps): Promise<ActionResult>;
@@ -0,0 +1,169 @@
1
+ import { putAssistantMessage, putSystemMessage, putUserMessage } from '../../../../main/common/content-bus.js';
2
+ import { askUserForConfirmation, askUserForConfirmationWithAnswer } from '../../../../main/common/user-actions.js';
3
+ import { getFunctionDefs } from '../../../function-calling.js';
4
+ import { CODEGEN_SUMMARY_PROMPT } from '../../../static-prompts.js';
5
+ import { executeStepCodegenPlanning } from '../../step-codegen-planning.js';
6
+ import { generateCodegenSummary } from '../../step-generate-codegen-summary.js';
7
+ import { processFileUpdates } from '../../step-process-file-updates.js';
8
+ import { StepResult } from '../../steps-types.js';
9
+ import { updateFiles } from '../../../../files/update-files.js';
10
+ import { executeStepContextCompression } from '../../step-context-compression.js';
11
+ import { registerActionHandler } from '../step-ask-question-handlers.js';
12
+ export const CODEGEN_SUMMARY_GENERATED_MESSAGE = 'Codegen summary is generated. Would you like to proceed with the code changes?';
13
+ export const CODEGEN_SUMMARY_APPROVED = 'Accept codegen summary and continue';
14
+ registerActionHandler('codeGeneration', handleCodeGeneration);
15
+ export async function handleCodeGeneration({ generateContentFn, generateImageFn, waitIfPaused, prompt, options, }) {
16
+ const planningResult = await executeStepCodegenPlanning(generateContentFn, prompt, options);
17
+ if (planningResult === StepResult.BREAK) {
18
+ return {
19
+ breakLoop: true,
20
+ items: [],
21
+ };
22
+ }
23
+ // Ask user to confirm the planning result
24
+ const planningConfirmation = await askUserForConfirmationWithAnswer(CODEGEN_SUMMARY_PROMPT, 'Accept plan', 'Reject plan', true, options);
25
+ if (!planningConfirmation.confirmed) {
26
+ // User rejected the planning, return to conversation
27
+ return {
28
+ breakLoop: false,
29
+ items: [
30
+ {
31
+ assistant: {
32
+ type: 'assistant',
33
+ text: CODEGEN_SUMMARY_PROMPT,
34
+ functionCalls: [],
35
+ },
36
+ user: {
37
+ type: 'user',
38
+ text: planningConfirmation.answer || 'Planning rejected. Returning to conversation.',
39
+ },
40
+ },
41
+ ],
42
+ };
43
+ }
44
+ // Add user's planning confirmation answer to prompt history
45
+ const assistantItem = {
46
+ type: 'assistant',
47
+ text: CODEGEN_SUMMARY_PROMPT,
48
+ };
49
+ putAssistantMessage(assistantItem.text, undefined, undefined, undefined, assistantItem);
50
+ prompt.push(assistantItem);
51
+ const userItem = {
52
+ type: 'user',
53
+ text: 'Accept planning and continue.' + (planningConfirmation.answer ? `\n\n${planningConfirmation.answer}` : ''),
54
+ };
55
+ putUserMessage(userItem.text, undefined, undefined, undefined, userItem);
56
+ prompt.push(userItem);
57
+ try {
58
+ // First step: Generate and validate codegen summary
59
+ const { codegenSummaryRequest, baseResult } = await generateCodegenSummary(generateContentFn, prompt, getFunctionDefs(), options);
60
+ // Ask user to confirm the codegen summary
61
+ const codegenSummaryConfirmation = await askUserForConfirmationWithAnswer(CODEGEN_SUMMARY_GENERATED_MESSAGE, 'Accept codegen summary', 'Reject codegen summary', true, options);
62
+ if (!codegenSummaryConfirmation.confirmed) {
63
+ // User rejected the codegen summary, return to conversation
64
+ return {
65
+ breakLoop: false,
66
+ items: [
67
+ {
68
+ assistant: {
69
+ type: 'assistant',
70
+ text: CODEGEN_SUMMARY_GENERATED_MESSAGE,
71
+ },
72
+ user: {
73
+ type: 'user',
74
+ text: codegenSummaryConfirmation.answer || 'Codegen summary rejected. Returning to conversation.',
75
+ },
76
+ },
77
+ ],
78
+ };
79
+ }
80
+ putAssistantMessage(CODEGEN_SUMMARY_GENERATED_MESSAGE);
81
+ putUserMessage(codegenSummaryConfirmation.answer || CODEGEN_SUMMARY_APPROVED);
82
+ prompt.push({
83
+ type: 'assistant',
84
+ text: CODEGEN_SUMMARY_GENERATED_MESSAGE,
85
+ }, {
86
+ type: 'user',
87
+ text: codegenSummaryConfirmation.answer || CODEGEN_SUMMARY_APPROVED,
88
+ });
89
+ // Second step: Process file updates
90
+ const updateResults = await processFileUpdates(generateContentFn, prompt, getFunctionDefs(), options, codegenSummaryRequest, waitIfPaused, generateImageFn);
91
+ const functionCalls = [...baseResult, ...updateResults];
92
+ const confirmApply = await askUserForConfirmationWithAnswer('Code changes are generated, now what?', 'Apply code changes', 'Reject code changes', true, options);
93
+ putAssistantMessage('Code changes are generated, now what?');
94
+ if (confirmApply.confirmed) {
95
+ putUserMessage(confirmApply.answer || 'Apply code changes.');
96
+ prompt.push({
97
+ type: 'assistant',
98
+ text: 'Code changes are generated, now what?',
99
+ }, {
100
+ type: 'user',
101
+ text: 'Apply code changes. ' + confirmApply.answer,
102
+ });
103
+ putSystemMessage('Applying code changes...');
104
+ if (options.dryRun) {
105
+ putSystemMessage('Dry run mode, not updating files');
106
+ }
107
+ else {
108
+ // Apply the code changes
109
+ await updateFiles(functionCalls.filter((call) => call.name !== 'explanation' && call.name !== 'getSourceCode' && call.name !== 'codegenSummary'), options);
110
+ putSystemMessage('Code changes applied successfully');
111
+ }
112
+ }
113
+ else {
114
+ putUserMessage(confirmApply.answer || 'Reject code changes.');
115
+ putSystemMessage('Rejecting code changes...');
116
+ prompt.push({
117
+ type: 'assistant',
118
+ text: 'Code changes are generated, now what?',
119
+ }, {
120
+ type: 'user',
121
+ text: 'Reject code changes. ' + confirmApply.answer,
122
+ });
123
+ }
124
+ if (!(await askUserForConfirmation('Code generation completed, do you want to continue conversation?', false, options, 'Continue conversation', 'End conversation')).confirmed) {
125
+ return {
126
+ breakLoop: true,
127
+ stepResult: functionCalls,
128
+ items: [],
129
+ };
130
+ }
131
+ putSystemMessage('Continuing conversation...');
132
+ const compressionResult = await executeStepContextCompression(generateContentFn, prompt, options);
133
+ prompt.push({
134
+ type: 'assistant',
135
+ text: `Code generation completed, changes ${confirmApply.confirmed ? 'were accepted and applied' : 'changes were rejected and not applied'}. Should we continue the conversation?`,
136
+ }, {
137
+ type: 'user',
138
+ text: 'Thank you for doing the code generation, now lets continue the conversation.',
139
+ });
140
+ return {
141
+ breakLoop: compressionResult !== StepResult.CONTINUE,
142
+ stepResult: functionCalls,
143
+ items: [],
144
+ };
145
+ }
146
+ catch (error) {
147
+ putSystemMessage(`Error during code generation: ${error instanceof Error ? error.message : 'Unknown error'}`);
148
+ const tryAgainConfirm = await askUserForConfirmation('An error occurred during code generation. Would you like to try again or continue the conversation?', false, options, 'Try again', 'Continue conversation');
149
+ return {
150
+ breakLoop: !tryAgainConfirm.confirmed,
151
+ items: [
152
+ {
153
+ assistant: {
154
+ type: 'assistant',
155
+ text: 'An error occurred during code generation. Would you like to try again or continue the conversation?',
156
+ functionCalls: [],
157
+ },
158
+ user: {
159
+ type: 'user',
160
+ text: tryAgainConfirm.confirmed
161
+ ? 'Lets continue the conversation'
162
+ : 'Error occurred during code generation.',
163
+ },
164
+ },
165
+ ],
166
+ };
167
+ }
168
+ }
169
+ //# sourceMappingURL=handle-code-generation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-code-generation.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-code-generation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAC/G,OAAO,EAAE,sBAAsB,EAAE,gCAAgC,EAAE,MAAM,yCAAyC,CAAC;AACnH,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAEzE,MAAM,CAAC,MAAM,iCAAiC,GAC5C,gFAAgF,CAAC;AAEnF,MAAM,CAAC,MAAM,wBAAwB,GAAG,qCAAqC,CAAC;AAE9E,qBAAqB,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,CAAC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AAI,EAAE,qGAAqG;wBAC3G,aAAa,EAAE,EAAE;qBAClB;oBACD,IAAI,EAAE;wBACJ,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,eAAe,CAAC,SAAS;4BAC7B,CAAC,CAAC,gCAAgC;4BAClC,CAAC,CAAC,wCAAwC;qBAC7C;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 handleConfirmCodeGeneration({ askQuestionCall, options, prompt, ...props }: ActionHandlerProps): Promise<ActionResult>;
@@ -0,0 +1,40 @@
1
+ import { putSystemMessage } from '../../../../main/common/content-bus.js';
2
+ import { askUserForConfirmationWithAnswer } from '../../../../main/common/user-actions.js';
3
+ import { getActionHandler } from '../ask-question-handler.js';
4
+ import { registerActionHandler } from '../step-ask-question-handlers.js';
5
+ registerActionHandler('confirmCodeGeneration', handleConfirmCodeGeneration);
6
+ export async function handleConfirmCodeGeneration({ askQuestionCall, options, prompt, ...props }) {
7
+ const userConfirmation = await askUserForConfirmationWithAnswer('The assistant is ready to start code generation. Do you want to proceed?', 'Start code generation', 'Continue conversation', true, options);
8
+ if (userConfirmation.confirmed) {
9
+ putSystemMessage('Proceeding with code generation.');
10
+ prompt.push({
11
+ type: 'assistant',
12
+ text: askQuestionCall.args?.message ?? '',
13
+ }, {
14
+ type: 'user',
15
+ text: userConfirmation.answer ?? 'Confirmed. Proceed with code generation.',
16
+ });
17
+ return await getActionHandler('codeGeneration')({
18
+ askQuestionCall,
19
+ options,
20
+ prompt,
21
+ ...props,
22
+ });
23
+ }
24
+ else {
25
+ putSystemMessage('Declined. Continuing the conversation.');
26
+ return {
27
+ breakLoop: false,
28
+ items: [
29
+ {
30
+ assistant: { type: 'assistant', text: askQuestionCall.args?.message ?? '' },
31
+ user: {
32
+ type: 'user',
33
+ text: userConfirmation.answer || 'Declined. Please continue the conversation.',
34
+ },
35
+ },
36
+ ],
37
+ };
38
+ }
39
+ }
40
+ //# sourceMappingURL=handle-confirm-code-generation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-confirm-code-generation.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-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,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAGzE,qBAAqB,CAAC,uBAAuB,EAAE,2BAA2B,CAAC,CAAC;AAE5E,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,EAChD,eAAe,EACf,OAAO,EACP,MAAM,EACN,GAAG,KAAK,EACW;IACnB,MAAM,gBAAgB,GAAG,MAAM,gCAAgC,CAC7D,0EAA0E,EAC1E,uBAAuB,EACvB,uBAAuB,EACvB,IAAI,EACJ,OAAO,CACR,CAAC;IACF,IAAI,gBAAgB,CAAC,SAAS,EAAE,CAAC;QAC/B,gBAAgB,CAAC,kCAAkC,CAAC,CAAC;QAErD,MAAM,CAAC,IAAI,CACT;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE;SAC1C,EACD;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,gBAAgB,CAAC,MAAM,IAAI,0CAA0C;SAC5E,CACF,CAAC;QAEF,OAAO,MAAM,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;YAC9C,eAAe;YACf,OAAO;YACP,MAAM;YACN,GAAG,KAAK;SACT,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,gBAAgB,CAAC,wCAAwC,CAAC,CAAC;QAC3D,OAAO;YACL,SAAS,EAAE,KAAK;YAChB,KAAK,EAAE;gBACL;oBACE,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE;oBAC3E,IAAI,EAAE;wBACJ,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,gBAAgB,CAAC,MAAM,IAAI,6CAA6C;qBAC/E;iBACF;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -2,6 +2,8 @@ import { executeStepContextCompression } from '../../step-context-compression.js
2
2
  import { putSystemMessage } from '../../../../main/common/content-bus.js';
3
3
  import { StepResult } from '../../steps-types.js';
4
4
  import { askUserForConfirmation } from '../../../../main/common/user-actions.js';
5
+ import { registerActionHandler } from '../step-ask-question-handlers.js';
6
+ registerActionHandler('contextCompression', handleContextCompression);
5
7
  export async function handleContextCompression({ askQuestionCall, prompt, options, generateContentFn, }) {
6
8
  putSystemMessage('Context compression requested.');
7
9
  // First confirmation: Ask user if they want to proceed with content generation
@@ -1 +1 @@
1
- {"version":3,"file":"handle-context-compression.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-context-compression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AAElF,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AAEjF,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,EAC7C,eAAe,EACf,MAAM,EACN,OAAO,EACP,iBAAiB,GACE;IACnB,gBAAgB,CAAC,gCAAgC,CAAC,CAAC;IAEnD,+EAA+E;IAC/E,MAAM,kBAAkB,GAAG,MAAM,sBAAsB,CACrD,kGAAkG,EAClG,KAAK,EACL,OAAO,EACP,kBAAkB,EAClB,uBAAuB,CACxB,CAAC;IAEF,IAAI,CAAC,kBAAkB,CAAC,SAAS,EAAE,CAAC;QAClC,gBAAgB,CAAC,+BAA+B,CAAC,CAAC;QAElD,MAAM,CAAC,IAAI,CACT;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE;SAC1C,EACD;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,gCAAgC;SACvC,CACF,CAAC;QAEF,OAAO;YACL,SAAS,EAAE,KAAK;YAChB,KAAK,EAAE,EAAE;SACV,CAAC;IACJ,CAAC;IAED,IAAI,CAAC;QACH,2BAA2B;QAC3B,MAAM,MAAM,GAAG,MAAM,6BAA6B,CAAC,iBAAiB,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAEvF,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAC/D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,gBAAgB,CAAC,kCAAkC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAChE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IACxC,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"handle-context-compression.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-context-compression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AAElF,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAEzE,qBAAqB,CAAC,oBAAoB,EAAE,wBAAwB,CAAC,CAAC;AAEtE,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,EAC7C,eAAe,EACf,MAAM,EACN,OAAO,EACP,iBAAiB,GACE;IACnB,gBAAgB,CAAC,gCAAgC,CAAC,CAAC;IAEnD,+EAA+E;IAC/E,MAAM,kBAAkB,GAAG,MAAM,sBAAsB,CACrD,kGAAkG,EAClG,KAAK,EACL,OAAO,EACP,kBAAkB,EAClB,uBAAuB,CACxB,CAAC;IAEF,IAAI,CAAC,kBAAkB,CAAC,SAAS,EAAE,CAAC;QAClC,gBAAgB,CAAC,+BAA+B,CAAC,CAAC;QAElD,MAAM,CAAC,IAAI,CACT;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE;SAC1C,EACD;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,gCAAgC;SACvC,CACF,CAAC;QAEF,OAAO;YACL,SAAS,EAAE,KAAK;YAChB,KAAK,EAAE,EAAE;SACV,CAAC;IACJ,CAAC;IAED,IAAI,CAAC;QACH,2BAA2B;QAC3B,MAAM,MAAM,GAAG,MAAM,6BAA6B,CAAC,iBAAiB,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAEvF,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAC/D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,gBAAgB,CAAC,kCAAkC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAChE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IACxC,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,34 @@
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 { registerActionHandler } from '../step-ask-question-handlers.js';
6
+ registerActionHandler('contextOptimization', handleContextOptimization);
7
+ export async function handleContextOptimization({ askQuestionCall, prompt, options, generateContentFn, }) {
8
+ const userConfirmation = await askUserForConfirmation('The assistant suggests optimizing the context to reduce token usage, cost, and latency. Do you want to proceed?', false, options);
9
+ const user = {
10
+ type: 'user',
11
+ text: userConfirmation.confirmed ? 'Context optimization applied.' : 'Context optimization not applied.',
12
+ };
13
+ const assistant = {
14
+ type: 'assistant',
15
+ text: askQuestionCall.args?.message ?? '',
16
+ };
17
+ if (userConfirmation.confirmed) {
18
+ // the request may be caused be an appearance of a new file, so lets refresh
19
+ refreshFiles();
20
+ // Execute context optimization step
21
+ putSystemMessage('Executing context optimization step.');
22
+ await executeStepContextOptimization(generateContentFn, [...prompt, assistant, user], options);
23
+ }
24
+ return {
25
+ breakLoop: false,
26
+ items: [
27
+ {
28
+ assistant,
29
+ user,
30
+ },
31
+ ],
32
+ };
33
+ }
34
+ //# sourceMappingURL=handle-context-optimization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-context-optimization.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-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,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAGzE,qBAAqB,CAAC,qBAAqB,EAAE,yBAAyB,CAAC,CAAC;AAExE,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,EACL,OAAO,CACR,CAAC;IAEF,MAAM,IAAI,GAAa;QACrB,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC,CAAC,mCAAmC;KACzG,CAAC;IAEF,MAAM,SAAS,GAAkB;QAC/B,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE;KAC1C,CAAC;IAEF,IAAI,gBAAgB,CAAC,SAAS,EAAE,CAAC;QAC/B,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,KAAK,EAAE;YACL;gBACE,SAAS;gBACT,IAAI;aACL;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';
2
+ import { ConversationEdge, ConversationNode } from '../../../function-defs/conversation-graph.js';
3
+ export declare const CONVERSATION_GRAPH_PROMPT = "# Conversation Graph Guide\n\nA conversation graph is a flexible structure for managing complex interactions. It consists of nodes (conversation states) connected by edges (transitions).\n\n## Core Components\n\n1. **Nodes (States)**\n - Each node represents a distinct state in the conversation\n - Contains:\n - id: Unique identifier\n - actionType: The action to perform\n - instruction: Internal guidance for execution\n\n2. **Edges (Transitions)**\n - Connect nodes to define possible conversation flows\n - Contains:\n - sourceNode: Starting point\n - targetNode: Destination\n - instruction: Condition for transition\n\n## Key Concepts\n\n- **State Management**: Nodes capture the current state and required action\n- **Flow Control**: Edges determine how the conversation can progress\n- **Flexibility**: Support for various conversation patterns and flows\n- **Context Awareness**: Each node operates with awareness of the conversation state\n\n## Implementation Notes\n\n- Nodes should be self-contained and focused\n- Edges should have clear, evaluatable conditions\n- Any node can connect to any other node if logically appropriate\n- Nodes and edges must formulate a direct acyclic graph (DAG)\n\n## Technical Details\n\nNodes require:\n- Unique ID for reference\n- Valid action type\n- Clear execution instructions\n\nEdges require:\n- Valid source and target node IDs\n- Clear transition conditions\n\n# Let's get started!\n\n0. Read and understand the conersation we had so far (context).\n1. Think about the big picture of the upcoming conversation flow and the desired outcome.\n2. Define the entry node to start the upcoming conversation.\n3. Create nodes with reasoning, action type, and instructions.\n4. Connect nodes with edges to define the conversation flow.\n";
4
+ export declare const getEdgeEvaluationPrompt: (currentNode: ConversationNode, outgoingEdges: ConversationEdge[]) => string;
5
+ /**
6
+ * Handles the conversationGraph action by:
7
+ * 1. Generating a conversationGraph function call
8
+ * 2. Extracting nodes and edges from the response
9
+ * 3. Traversing the graph and executing actions
10
+ * 4. Returning appropriate ActionResult
11
+ */
12
+ export declare function handleConversationGraph({ askQuestionCall, prompt, options, generateContentFn, generateImageFn, waitIfPaused, }: ActionHandlerProps): Promise<ActionResult>;