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.
- package/dist/ai-service/anthropic.js +4 -1
- package/dist/ai-service/anthropic.js.map +1 -1
- package/dist/ai-service/common.js +1 -1
- package/dist/ai-service/common.js.map +1 -1
- package/dist/ai-service/openai.js +1 -1
- package/dist/ai-service/openai.js.map +1 -1
- package/dist/ai-service/service-configurations.js +1 -1
- package/dist/ai-service/service-configurations.js.map +1 -1
- package/dist/files/cache-file.d.ts +4 -1
- package/dist/files/cache-file.js.map +1 -1
- package/dist/files/file-id-utils.d.ts +7 -0
- package/dist/files/file-id-utils.js +25 -0
- package/dist/files/file-id-utils.js.map +1 -0
- package/dist/files/read-files.js +8 -8
- package/dist/files/read-files.js.map +1 -1
- package/dist/files/source-code-tree.js +3 -3
- package/dist/files/source-code-tree.js.map +1 -1
- package/dist/files/source-code-types.d.ts +21 -3
- package/dist/files/summary-cache.d.ts +3 -2
- package/dist/files/summary-cache.js +1 -1
- package/dist/files/summary-cache.js.map +1 -1
- package/dist/main/common/content-bus-types.d.ts +1 -1
- package/dist/main/common/content-bus.js +1 -1
- package/dist/main/common/content-bus.js.map +1 -1
- package/dist/main/config-schema.js +1 -1
- package/dist/main/config-schema.js.map +1 -1
- package/dist/main/ui/frontend/assets/{index-CSR1NiB_.js → index-Dizqxzws.js} +226 -187
- package/dist/main/ui/frontend/index.html +1 -1
- package/dist/prompt/ai-service-fallback.js +5 -1
- package/dist/prompt/ai-service-fallback.js.map +1 -1
- package/dist/prompt/function-calling.js +8 -1
- package/dist/prompt/function-calling.js.map +1 -1
- package/dist/prompt/function-defs/ask-question.d.ts +3 -0
- package/dist/prompt/function-defs/ask-question.js +43 -1
- package/dist/prompt/function-defs/ask-question.js.map +1 -1
- package/dist/prompt/function-defs/context-compression.d.ts +25 -5
- package/dist/prompt/function-defs/context-compression.js +23 -8
- package/dist/prompt/function-defs/context-compression.js.map +1 -1
- package/dist/prompt/function-defs/conversation-graph.d.ts +33 -0
- package/dist/prompt/function-defs/conversation-graph.js +110 -0
- package/dist/prompt/function-defs/conversation-graph.js.map +1 -0
- package/dist/prompt/function-defs/extract-file-fragments.d.ts +27 -0
- package/dist/prompt/function-defs/extract-file-fragments.js +36 -0
- package/dist/prompt/function-defs/extract-file-fragments.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/ask-question-handler.d.ts +2 -0
- package/dist/prompt/steps/step-ask-question/ask-question-handler.js +12 -0
- package/dist/prompt/steps/step-ask-question/ask-question-handler.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/code-generation.js +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/code-generation.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/file-request-utils.d.ts +47 -0
- package/dist/prompt/steps/step-ask-question/handlers/file-request-utils.js +114 -0
- package/dist/prompt/steps/step-ask-question/handlers/file-request-utils.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-code-generation.d.ts +4 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-code-generation.js +169 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-code-generation.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-confirm-code-generation.d.ts +2 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-confirm-code-generation.js +40 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-confirm-code-generation.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-context-compression.js +2 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-context-compression.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-context-optimization.d.ts +2 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-context-optimization.js +34 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-context-optimization.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-conversation-graph.d.ts +12 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-conversation-graph.js +243 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-conversation-graph.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-create-file.d.ts +2 -2
- package/dist/prompt/steps/step-ask-question/handlers/handle-create-file.js +5 -3
- package/dist/prompt/steps/step-ask-question/handlers/handle-create-file.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-end-conversation.js +2 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-end-conversation.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-genaicode-help.js +2 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-genaicode-help.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-generate-image.js +2 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-generate-image.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-lint.d.ts +6 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-lint.js +105 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-lint.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-perform-analysis.js +4 -5
- package/dist/prompt/steps/step-ask-question/handlers/handle-perform-analysis.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-pull-app-context.js +2 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-pull-app-context.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-push-app-context.js +2 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-push-app-context.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-reasoning-inference.js +3 -3
- package/dist/prompt/steps/step-ask-question/handlers/handle-reasoning-inference.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-remove-files-from-context.d.ts +2 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-remove-files-from-context.js +88 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-remove-files-from-context.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-request-files-content.d.ts +8 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-request-files-content.js +136 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-request-files-content.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-request-files-fragments.d.ts +8 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-request-files-fragments.js +173 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-request-files-fragments.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-request-permissions.d.ts +2 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-request-permissions.js +71 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-request-permissions.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-search-code.d.ts +0 -3
- package/dist/prompt/steps/step-ask-question/handlers/handle-search-code.js +2 -3
- package/dist/prompt/steps/step-ask-question/handlers/handle-search-code.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-send-message.js +2 -0
- package/dist/prompt/steps/step-ask-question/handlers/handle-send-message.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/handle-update-file.d.ts +2 -2
- package/dist/prompt/steps/step-ask-question/handlers/handle-update-file.js +6 -4
- package/dist/prompt/steps/step-ask-question/handlers/handle-update-file.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/handlers/request-files-content.js +7 -3
- package/dist/prompt/steps/step-ask-question/handlers/request-files-content.js.map +1 -1
- package/dist/prompt/steps/step-ask-question/step-ask-question-handlers.d.ts +3 -0
- package/dist/prompt/steps/step-ask-question/step-ask-question-handlers.js +5 -0
- package/dist/prompt/steps/step-ask-question/step-ask-question-handlers.js.map +1 -0
- package/dist/prompt/steps/step-ask-question/step-ask-question-types.d.ts +13 -2
- package/dist/prompt/steps/step-ask-question/step-ask-question.d.ts +21 -0
- package/dist/prompt/steps/step-ask-question/step-ask-question.js +30 -71
- package/dist/prompt/steps/step-ask-question/step-ask-question.js.map +1 -1
- package/dist/prompt/steps/step-codegen-planning.js +1 -3
- package/dist/prompt/steps/step-codegen-planning.js.map +1 -1
- package/dist/prompt/steps/step-context-compression.d.ts +1 -1
- package/dist/prompt/steps/step-context-compression.js +130 -34
- package/dist/prompt/steps/step-context-compression.js.map +1 -1
- package/dist/prompt/steps/step-context-optimization.js +7 -68
- package/dist/prompt/steps/step-context-optimization.js.map +1 -1
- package/dist/prompt/steps/step-generate-codegen-summary.js +1 -3
- package/dist/prompt/steps/step-generate-codegen-summary.js.map +1 -1
- package/dist/prompt/steps/step-history-update.js +1 -3
- package/dist/prompt/steps/step-history-update.js.map +1 -1
- package/dist/prompt/steps/step-process-file-updates.js +0 -3
- package/dist/prompt/steps/step-process-file-updates.js.map +1 -1
- package/dist/prompt/steps/step-summarization.d.ts +2 -1
- package/dist/prompt/steps/step-summarization.js +6 -5
- package/dist/prompt/steps/step-summarization.js.map +1 -1
- package/dist/prompt/steps/step-verify-patch.js +1 -3
- package/dist/prompt/steps/step-verify-patch.js.map +1 -1
- package/dist/prompt/systemprompt.js +5 -3
- package/dist/prompt/systemprompt.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle-reasoning-inference.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-reasoning-inference.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"handle-reasoning-inference.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-reasoning-inference.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EA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AAK,EAAE,EAAE;SACV,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,2BAA2B;QAC3B,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,gBAAgB,CAAC,qCAAqC,YAAY,EAAE,CAAC,CAAC;QAEtE,MAAM,CAAC,IAAI,CACT;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,eAAe,CAAC,IAAK,CAAC,OAAO;SACpC,EACD;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,mCAAmC;SAC1C,CACF,CAAC;QAEF,OAAO;YACL,gCAAgC;YAChC,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,EAAE;SACV,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ModelType } from '../../../../ai-service/common-types.js';
|
|
2
|
+
import { putSystemMessage } from '../../../../main/common/content-bus.js';
|
|
3
|
+
import { getFunctionDefs } from '../../../function-calling.js';
|
|
4
|
+
import { registerActionHandler } from '../step-ask-question-handlers.js';
|
|
5
|
+
registerActionHandler('removeFilesFromContext', handleRemoveFilesFromContext);
|
|
6
|
+
export async function handleRemoveFilesFromContext({ askQuestionCall, generateContentFn, prompt, options, }) {
|
|
7
|
+
const [removeFilesFromContextCall] = (await generateContentFn([
|
|
8
|
+
...prompt,
|
|
9
|
+
{
|
|
10
|
+
type: 'assistant',
|
|
11
|
+
text: askQuestionCall.args?.message ?? '',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
type: 'user',
|
|
15
|
+
text: 'Yes, you can request the removal of files from context.',
|
|
16
|
+
},
|
|
17
|
+
], getFunctionDefs(), 'removeFilesFromContext', 0.7, ModelType.CHEAP, options));
|
|
18
|
+
if (!removeFilesFromContextCall) {
|
|
19
|
+
return {
|
|
20
|
+
breakLoop: true,
|
|
21
|
+
items: [],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const filesToRemove = removeFilesFromContextCall.args?.filePaths ?? [];
|
|
25
|
+
let userText = '';
|
|
26
|
+
if (filesToRemove.length > 0) {
|
|
27
|
+
removeFileContentsFromPrompt(prompt, filesToRemove);
|
|
28
|
+
putSystemMessage('Context reduction applied', filesToRemove);
|
|
29
|
+
userText = 'Context reduction applied';
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
putSystemMessage('No specific files were provided for context reduction. The context remains unchanged.');
|
|
33
|
+
userText = 'No specific files were provided for context reduction. The context remains unchanged.';
|
|
34
|
+
}
|
|
35
|
+
prompt.push({
|
|
36
|
+
type: 'assistant',
|
|
37
|
+
text: askQuestionCall.args?.message ?? '',
|
|
38
|
+
functionCalls: [removeFilesFromContextCall],
|
|
39
|
+
}, {
|
|
40
|
+
type: 'user',
|
|
41
|
+
text: userText,
|
|
42
|
+
functionResponses: [
|
|
43
|
+
{ name: 'removeFilesFromContext', call_id: removeFilesFromContextCall.id, content: undefined },
|
|
44
|
+
],
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
breakLoop: false,
|
|
48
|
+
items: [],
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function removeFileContentsFromPrompt(prompt, filesToRemove) {
|
|
52
|
+
// Find all source code responses in the prompt history
|
|
53
|
+
const sourceCodeResponses = prompt.filter((item) => item.type === 'user' && item.functionResponses?.some((fr) => fr.name === 'getSourceCode'));
|
|
54
|
+
if (sourceCodeResponses.length === 0) {
|
|
55
|
+
console.warn('No source code responses found in prompt history');
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
sourceCodeResponses.forEach((response) => {
|
|
59
|
+
const sourceCodeResponse = response.functionResponses?.find((fr) => fr.name === 'getSourceCode');
|
|
60
|
+
if (!sourceCodeResponse || !sourceCodeResponse.content) {
|
|
61
|
+
console.warn('Skipping invalid source code response');
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
const contentObj = JSON.parse(sourceCodeResponse.content);
|
|
66
|
+
let modifiedFiles = 0;
|
|
67
|
+
filesToRemove.forEach((file) => {
|
|
68
|
+
if (contentObj[file] && 'content' in contentObj[file]) {
|
|
69
|
+
contentObj[file].content = null;
|
|
70
|
+
modifiedFiles++;
|
|
71
|
+
}
|
|
72
|
+
else if (contentObj[file] && 'fragments' in contentObj[file]) {
|
|
73
|
+
delete contentObj[file].fragments;
|
|
74
|
+
modifiedFiles++;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
// Only update if files were actually modified
|
|
78
|
+
if (modifiedFiles > 0) {
|
|
79
|
+
sourceCodeResponse.content = JSON.stringify(contentObj);
|
|
80
|
+
console.log(`Removed content from ${modifiedFiles} files in source code response`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
console.error('Error processing source code response:', error);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=handle-remove-files-from-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle-remove-files-from-context.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-remove-files-from-context.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAGzE,qBAAqB,CAAC,wBAAwB,EAAE,4BAA4B,CAAC,CAAC;AAE9E,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,EACjD,eAAe,EACf,iBAAiB,EACjB,MAAM,EACN,OAAO,GACY;IACnB,MAAM,CAAC,0BAA0B,CAAC,GAAG,CAAC,M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AU,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC/D,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC;oBAClC,aAAa,EAAE,CAAC;gBAClB,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,8CAA8C;YAC9C,IAAI,aAAa,GAAG,CAAC,EAAE,CAAC;gBACtB,kBAAkB,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;gBACxD,OAAO,CAAC,GAAG,CAAC,wBAAwB,aAAa,gCAAgC,CAAC,CAAC;YACrF,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAC;QACjE,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GenerateContentFunction } from '../../../../ai-service/common-types.js';
|
|
2
|
+
import { PromptItem } from '../../../../ai-service/common-types.js';
|
|
3
|
+
import { FunctionCall } from '../../../../ai-service/common-types.js';
|
|
4
|
+
import { ModelType } from '../../../../ai-service/common-types.js';
|
|
5
|
+
import { CodegenOptions } from '../../../../main/codegen-types.js';
|
|
6
|
+
import { ActionHandlerProps, ActionResult, AskQuestionCall, RequestFilesContentArgs } from '../step-ask-question-types.js';
|
|
7
|
+
export declare function handleRequestFilesContent({ askQuestionCall, options, prompt, generateContentFn, }: ActionHandlerProps): Promise<ActionResult>;
|
|
8
|
+
export declare function generateRequestFilesContentCall(generateContentFn: GenerateContentFunction, prompt: PromptItem[], askQuestionCall: AskQuestionCall, options: CodegenOptions, modelType: ModelType): Promise<FunctionCall<RequestFilesContentArgs> | undefined>;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { ModelType } from '../../../../ai-service/common-types.js';
|
|
2
|
+
import { refreshFiles } from '../../../../files/find-files.js';
|
|
3
|
+
import { getSourceCode } from '../../../../files/read-files.js';
|
|
4
|
+
import { getExpandedContextPaths } from '../../../../files/source-code-utils.js';
|
|
5
|
+
import { putSystemMessage } from '../../../../main/common/content-bus.js';
|
|
6
|
+
import { getFunctionDefs } from '../../../function-calling.js';
|
|
7
|
+
import { registerActionHandler } from '../step-ask-question-handlers.js';
|
|
8
|
+
import { isFileContentAlreadyProvided, categorizeLegitimateFiles } from './file-request-utils.js';
|
|
9
|
+
registerActionHandler('requestFilesContent', handleRequestFilesContent);
|
|
10
|
+
export async function handleRequestFilesContent({ askQuestionCall, options, prompt, generateContentFn, }) {
|
|
11
|
+
let requestFilesContentCall = await generateRequestFilesContentCall(generateContentFn, prompt, askQuestionCall, options, ModelType.CHEAP);
|
|
12
|
+
if (!requestFilesContentCall) {
|
|
13
|
+
return {
|
|
14
|
+
breakLoop: true,
|
|
15
|
+
items: [],
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
let requestedFiles = getExpandedContextPaths(requestFilesContentCall.args?.filePaths ?? [], options);
|
|
19
|
+
putSystemMessage('Requesting files content', {
|
|
20
|
+
requestedFiles,
|
|
21
|
+
expandedRequestedFiles: requestedFiles.filter((file) => !requestFilesContentCall?.args?.filePaths?.includes(file)),
|
|
22
|
+
});
|
|
23
|
+
// Check which files are already provided in the conversation history
|
|
24
|
+
const alreadyProvidedFiles = requestedFiles.filter((file) => isFileContentAlreadyProvided(file, prompt));
|
|
25
|
+
if (alreadyProvidedFiles.length === requestedFiles.length) {
|
|
26
|
+
putSystemMessage('All requested files are already provided');
|
|
27
|
+
// All requested files are already provided
|
|
28
|
+
prompt.push({
|
|
29
|
+
type: 'assistant',
|
|
30
|
+
text: askQuestionCall.args?.message ?? '',
|
|
31
|
+
functionCalls: [requestFilesContentCall],
|
|
32
|
+
}, {
|
|
33
|
+
type: 'user',
|
|
34
|
+
text: 'The requested file contents are already provided in the conversation history.',
|
|
35
|
+
functionResponses: [
|
|
36
|
+
{
|
|
37
|
+
name: 'requestFilesContent',
|
|
38
|
+
call_id: requestFilesContentCall.id,
|
|
39
|
+
content: JSON.stringify({ filePaths: requestedFiles }),
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
cache: true,
|
|
43
|
+
});
|
|
44
|
+
return { breakLoop: false, items: [] };
|
|
45
|
+
}
|
|
46
|
+
// Filter out already provided files
|
|
47
|
+
requestedFiles = requestedFiles.filter((file) => !isFileContentAlreadyProvided(file, prompt));
|
|
48
|
+
// the request may be caused be an appearance of a new file, so lets refresh
|
|
49
|
+
refreshFiles();
|
|
50
|
+
let { legitimateFiles, illegitimateFiles } = categorizeLegitimateFiles(requestedFiles);
|
|
51
|
+
if (illegitimateFiles.length > 0) {
|
|
52
|
+
requestFilesContentCall = await generateRequestFilesContentCall(generateContentFn, prompt, askQuestionCall, options,
|
|
53
|
+
// use non cheap mode, as maybe the cheap mode didn't provide correct files
|
|
54
|
+
ModelType.DEFAULT);
|
|
55
|
+
if (!requestFilesContentCall) {
|
|
56
|
+
return {
|
|
57
|
+
breakLoop: true,
|
|
58
|
+
items: [],
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
requestedFiles = requestFilesContentCall.args?.filePaths ?? [];
|
|
62
|
+
const categorized = categorizeLegitimateFiles(requestedFiles);
|
|
63
|
+
legitimateFiles = categorized.legitimateFiles;
|
|
64
|
+
illegitimateFiles = categorized.illegitimateFiles;
|
|
65
|
+
}
|
|
66
|
+
const sourceCallId = (askQuestionCall.id ?? askQuestionCall.name) + '_source';
|
|
67
|
+
const assistant = {
|
|
68
|
+
type: 'assistant',
|
|
69
|
+
text: askQuestionCall.args?.message ?? '',
|
|
70
|
+
functionCalls: [
|
|
71
|
+
requestFilesContentCall,
|
|
72
|
+
{ name: 'getSourceCode', id: sourceCallId, args: { filePaths: legitimateFiles } },
|
|
73
|
+
],
|
|
74
|
+
};
|
|
75
|
+
const sourceCode = getSourceCode({ filterPaths: legitimateFiles, forceAll: true, ignoreImportantFiles: true }, options);
|
|
76
|
+
const user = {
|
|
77
|
+
type: 'user',
|
|
78
|
+
text: (alreadyProvidedFiles.length > 0
|
|
79
|
+
? // TODO: Maybe reference to some specific getSourceCode call id
|
|
80
|
+
`Some files were already provided in the conversation history:
|
|
81
|
+
${alreadyProvidedFiles.map((path) => `- ${path}`).join('\n')}
|
|
82
|
+
|
|
83
|
+
Providing content for the remaining files:
|
|
84
|
+
${requestedFiles.map((path) => `- ${path}`).join('\n')}`
|
|
85
|
+
: `All requested file contents have been provided:
|
|
86
|
+
${legitimateFiles.map((path) => `- ${path}`).join('\n')}`) +
|
|
87
|
+
(illegitimateFiles.length > 0
|
|
88
|
+
? `\n\nSome files are not legitimate and their content cannot be provided:
|
|
89
|
+
${illegitimateFiles.map((path) => `- ${path}`).join('\n')}`
|
|
90
|
+
: ''),
|
|
91
|
+
data: { legitimateFiles, illegitimateFiles },
|
|
92
|
+
functionResponses: [
|
|
93
|
+
{
|
|
94
|
+
name: 'requestFilesContent',
|
|
95
|
+
call_id: requestFilesContentCall.id,
|
|
96
|
+
content: JSON.stringify({ filePaths: legitimateFiles }),
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: 'getSourceCode',
|
|
100
|
+
call_id: sourceCallId,
|
|
101
|
+
content: JSON.stringify(sourceCode),
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
cache: true,
|
|
105
|
+
};
|
|
106
|
+
putSystemMessage('Providing files content', {
|
|
107
|
+
requestedFiles,
|
|
108
|
+
legitimateFiles,
|
|
109
|
+
illegitimateFiles,
|
|
110
|
+
});
|
|
111
|
+
prompt.push(assistant, user);
|
|
112
|
+
return { breakLoop: false, items: [] };
|
|
113
|
+
}
|
|
114
|
+
export async function generateRequestFilesContentCall(generateContentFn, prompt, askQuestionCall, options, modelType) {
|
|
115
|
+
const req = [
|
|
116
|
+
[
|
|
117
|
+
...prompt,
|
|
118
|
+
{
|
|
119
|
+
type: 'assistant',
|
|
120
|
+
text: askQuestionCall.args?.message ?? '',
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
type: 'user',
|
|
124
|
+
text: 'Yes, you can request the files contents.',
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
getFunctionDefs(),
|
|
128
|
+
'requestFilesContent',
|
|
129
|
+
0.7,
|
|
130
|
+
modelType,
|
|
131
|
+
options,
|
|
132
|
+
];
|
|
133
|
+
const [requestFilesContentCall] = (await generateContentFn(...req));
|
|
134
|
+
return requestFilesContentCall;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=handle-request-files-content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle-request-files-content.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-request-files-content.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AASzE,OAAO,EAAE,4BAA4B,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAElG,qBAAqB,CAAC,qBAAqB,EAAE,yBAAyB,CAAC,CAAC;AAExE,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,EAC9C,eAAe,EACf,OAAO,EACP,MAAM,EACN,iBAAiB,GACE;IACnB,IAAI,uBAAuB,GAAG,MAAM,+BAA+B,CACjE,iBAAiB,EACjB,MAAM,EACN,eAAe,EACf,OAAO,EACP,SAAS,CAAC,KAAK,CAChB,CAAC;IAEF,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAC7B,OAAO;YACL,SAAS,EAAE,IAAI;YACf,KA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,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAE7B,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;AACzC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,iBAA0C,EAC1C,MAAoB,EACpB,eAAgC,EAChC,OAAuB,EACvB,SAAoB;IAEpB,MAAM,GAAG,GAAG;QACV;YACE,GAAG,MAAM;YACT;gBACE,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE;aAC1C;YACD;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,0CAA0C;aACjD;SACF;QACD,eAAe,EAAE;QACjB,qBAAqB;QACrB,GAAG;QACH,SAAS;QACT,OAAO;KACe,CAAC;IACzB,MAAM,CAAC,uBAAuB,CAAC,GAAG,CAAC,MAAM,iBAAiB,CAAC,GAAG,GAAG,CAAC,CAEjE,CAAC;IAEF,OAAO,uBAAuB,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GenerateContentFunction } from '../../../../ai-service/common-types.js';
|
|
2
|
+
import { PromptItem } from '../../../../ai-service/common-types.js';
|
|
3
|
+
import { FunctionCall } from '../../../../ai-service/common-types.js';
|
|
4
|
+
import { ModelType } from '../../../../ai-service/common-types.js';
|
|
5
|
+
import { CodegenOptions } from '../../../../main/codegen-types.js';
|
|
6
|
+
import { ActionHandlerProps, ActionResult, AskQuestionCall, RequestFilesFragmentsArgs } from '../step-ask-question-types.js';
|
|
7
|
+
export declare function handleRequestFilesFragments({ askQuestionCall, options, prompt, generateContentFn, }: ActionHandlerProps): Promise<ActionResult>;
|
|
8
|
+
export declare function generateRequestFilesFragmentsCall(generateContentFn: GenerateContentFunction, prompt: PromptItem[], askQuestionCall: AskQuestionCall, options: CodegenOptions, modelType: ModelType): Promise<FunctionCall<RequestFilesFragmentsArgs> | undefined>;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { ModelType } from '../../../../ai-service/common-types.js';
|
|
2
|
+
import { generateFileId } from '../../../../files/file-id-utils.js';
|
|
3
|
+
import { getSourceCode } from '../../../../files/read-files.js';
|
|
4
|
+
import { putSystemMessage } from '../../../../main/common/content-bus.js';
|
|
5
|
+
import { getFunctionDefs } from '../../../function-calling.js';
|
|
6
|
+
import { registerActionHandler } from '../step-ask-question-handlers.js';
|
|
7
|
+
import { processFileRequests, generateFilesContentPrompt } from './file-request-utils.js';
|
|
8
|
+
registerActionHandler('requestFilesFragments', handleRequestFilesFragments);
|
|
9
|
+
export async function handleRequestFilesFragments({ askQuestionCall, options, prompt, generateContentFn, }) {
|
|
10
|
+
let requestFilesFragmentsCall = await generateRequestFilesFragmentsCall(generateContentFn, prompt, askQuestionCall, options, ModelType.CHEAP);
|
|
11
|
+
if (!requestFilesFragmentsCall) {
|
|
12
|
+
return {
|
|
13
|
+
breakLoop: true,
|
|
14
|
+
items: [],
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const fragmentPrompt = requestFilesFragmentsCall.args?.fragmentPrompt;
|
|
18
|
+
if (!fragmentPrompt) {
|
|
19
|
+
putSystemMessage('No fragment prompt provided');
|
|
20
|
+
return {
|
|
21
|
+
breakLoop: true,
|
|
22
|
+
items: [],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
// Process file requests using the utility function
|
|
26
|
+
let { requestedFiles, alreadyProvidedFiles, legitimateFiles, illegitimateFiles } = processFileRequests(requestFilesFragmentsCall.args?.filePaths ?? [], prompt, options);
|
|
27
|
+
if (alreadyProvidedFiles.length === requestedFiles.length) {
|
|
28
|
+
putSystemMessage('All requested files are already provided');
|
|
29
|
+
prompt.push({
|
|
30
|
+
type: 'assistant',
|
|
31
|
+
text: askQuestionCall.args?.message ?? '',
|
|
32
|
+
functionCalls: [requestFilesFragmentsCall],
|
|
33
|
+
}, {
|
|
34
|
+
type: 'user',
|
|
35
|
+
text: 'The requested file fragments are already provided in the conversation history.',
|
|
36
|
+
functionResponses: [
|
|
37
|
+
{
|
|
38
|
+
name: 'requestFilesFragments',
|
|
39
|
+
call_id: requestFilesFragmentsCall.id,
|
|
40
|
+
content: JSON.stringify({ filePaths: requestedFiles }),
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
cache: true,
|
|
44
|
+
});
|
|
45
|
+
return { breakLoop: false, items: [] };
|
|
46
|
+
}
|
|
47
|
+
// If there are illegitimate files, try again with non-cheap mode
|
|
48
|
+
if (illegitimateFiles.length > 0) {
|
|
49
|
+
requestFilesFragmentsCall = await generateRequestFilesFragmentsCall(generateContentFn, prompt, askQuestionCall, options, ModelType.DEFAULT);
|
|
50
|
+
if (!requestFilesFragmentsCall) {
|
|
51
|
+
return {
|
|
52
|
+
breakLoop: true,
|
|
53
|
+
items: [],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const processed = processFileRequests(requestFilesFragmentsCall.args?.filePaths ?? [], prompt, options);
|
|
57
|
+
requestedFiles = processed.requestedFiles;
|
|
58
|
+
alreadyProvidedFiles = processed.alreadyProvidedFiles;
|
|
59
|
+
legitimateFiles = processed.legitimateFiles;
|
|
60
|
+
illegitimateFiles = processed.illegitimateFiles;
|
|
61
|
+
}
|
|
62
|
+
// Get the content of legitimate files
|
|
63
|
+
const sourceCodeMap = await getSourceCode({ filterPaths: legitimateFiles, forceAll: true, ignoreImportantFiles: true }, options);
|
|
64
|
+
// Extract fragments from files using LLM
|
|
65
|
+
const extractedFragments = await extractFragments(sourceCodeMap, fragmentPrompt, generateContentFn, options);
|
|
66
|
+
const sourceCallId = (askQuestionCall.id ?? askQuestionCall.name) + '_source';
|
|
67
|
+
const assistant = {
|
|
68
|
+
type: 'assistant',
|
|
69
|
+
text: askQuestionCall.args?.message ?? '',
|
|
70
|
+
functionCalls: [
|
|
71
|
+
requestFilesFragmentsCall,
|
|
72
|
+
{ name: 'getSourceCode', id: sourceCallId, args: { filePaths: legitimateFiles } },
|
|
73
|
+
],
|
|
74
|
+
};
|
|
75
|
+
const fragmentsSourceCode = {};
|
|
76
|
+
for (const fragment of extractedFragments.fragments) {
|
|
77
|
+
fragmentsSourceCode[fragment.filePath] = {
|
|
78
|
+
fileId: generateFileId(fragment.filePath),
|
|
79
|
+
fragments: [fragment.content],
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const user = {
|
|
83
|
+
type: 'user',
|
|
84
|
+
text: generateFilesContentPrompt(alreadyProvidedFiles, requestedFiles, legitimateFiles, illegitimateFiles, 'fragments'),
|
|
85
|
+
data: { legitimateFiles, illegitimateFiles },
|
|
86
|
+
functionResponses: [
|
|
87
|
+
{
|
|
88
|
+
name: 'requestFilesFragments',
|
|
89
|
+
call_id: requestFilesFragmentsCall.id,
|
|
90
|
+
content: JSON.stringify({ filePaths: legitimateFiles }),
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'getSourceCode',
|
|
94
|
+
call_id: sourceCallId,
|
|
95
|
+
content: JSON.stringify(fragmentsSourceCode),
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
cache: true,
|
|
99
|
+
};
|
|
100
|
+
putSystemMessage('Providing files fragments', {
|
|
101
|
+
requestedFiles,
|
|
102
|
+
legitimateFiles,
|
|
103
|
+
illegitimateFiles,
|
|
104
|
+
fragmentCount: extractedFragments.fragments.length,
|
|
105
|
+
});
|
|
106
|
+
prompt.push(assistant, user);
|
|
107
|
+
return { breakLoop: false, items: [] };
|
|
108
|
+
}
|
|
109
|
+
export async function generateRequestFilesFragmentsCall(generateContentFn, prompt, askQuestionCall, options, modelType) {
|
|
110
|
+
const [requestFilesFragmentsCall] = (await generateContentFn([
|
|
111
|
+
...prompt,
|
|
112
|
+
{
|
|
113
|
+
type: 'assistant',
|
|
114
|
+
text: askQuestionCall.args?.message ?? '',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
type: 'user',
|
|
118
|
+
text: 'Yes, you can request the file fragments.',
|
|
119
|
+
},
|
|
120
|
+
], getFunctionDefs(), 'requestFilesFragments', 0.7, modelType, options));
|
|
121
|
+
return requestFilesFragmentsCall;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Extract fragments from files using LLM with multi-file support
|
|
125
|
+
*/
|
|
126
|
+
async function extractFragments(sourceCodeMap, fragmentPrompt, generateContentFn, options) {
|
|
127
|
+
const filePaths = Object.keys(sourceCodeMap);
|
|
128
|
+
try {
|
|
129
|
+
// Process all files in a single LLM call
|
|
130
|
+
const [extractFragmentsCall] = (await generateContentFn([
|
|
131
|
+
{
|
|
132
|
+
type: 'systemPrompt',
|
|
133
|
+
systemPrompt: 'You are tasked with extracting relevant fragments from multiple source code files based on a given prompt. ' +
|
|
134
|
+
'Analyze each file thoroughly, identify meaningful sections that match the prompt criteria, and provide clear ' +
|
|
135
|
+
'explanations for your selections. Each fragment must be attributed to its source file for proper tracking.',
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
type: 'assistant',
|
|
139
|
+
text: 'I will analyze the provided files and extract relevant fragments based on your prompt.',
|
|
140
|
+
functionCalls: [{ name: 'getSourceCode', args: { filePaths } }],
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
type: 'user',
|
|
144
|
+
text: `Please extract relevant fragments from the provided files.\nExtraction prompt: ${fragmentPrompt}`,
|
|
145
|
+
functionResponses: [
|
|
146
|
+
{
|
|
147
|
+
name: 'getSourceCode',
|
|
148
|
+
content: JSON.stringify(sourceCodeMap),
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
},
|
|
152
|
+
], getFunctionDefs(), 'extractFileFragments', 0.2, ModelType.CHEAP, options));
|
|
153
|
+
if (!extractFragmentsCall?.args) {
|
|
154
|
+
putSystemMessage('Failed to extract fragments');
|
|
155
|
+
return {
|
|
156
|
+
filePaths,
|
|
157
|
+
fragments: [],
|
|
158
|
+
reasoning: 'Fragment extraction failed',
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
putSystemMessage(`Successfully extracted ${extractFragmentsCall.args.fragments.length} fragments from ${filePaths.length} files`);
|
|
162
|
+
return extractFragmentsCall.args;
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
putSystemMessage('Error during fragment extraction', { error });
|
|
166
|
+
return {
|
|
167
|
+
filePaths,
|
|
168
|
+
fragments: [],
|
|
169
|
+
reasoning: `Error during fragment extraction: ${error}`,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=handle-request-files-fragments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle-request-files-fragments.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-request-files-fragments.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAGhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AASzE,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAE1F,qBAAqB,CAAC,uBAAuB,EAAE,2BAA2B,CAAC,CAAC;AAE5E,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,EAChD,eAAe,EACf,OAAO,EACP,MAAM,EACN,iBAAiB,GACE;IACnB,IAAI,yBAAyB,GAAG,MAAM,iCAAiC,CACrE,iBAAiB,EACjB,MAAM,EACN,eAAe,EACf,OAAO,EACP,SAAS,CAAC,KAAK,CAChB,CAAC;IAEF,IAAI,CAAC,yBAAyB,EAAE,CAAC;QAC/B,OAAO;YACL,SAAS,EAAE,IAAI;YACf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QAED,gBAAgB,CACd,0BAA0B,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,mBAAmB,SAAS,CAAC,MAAM,QAAQ,CAChH,CAAC;QACF,OAAO,oBAAoB,CAAC,IAAI,CAAC;IACnC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,gBAAgB,CAAC,kCAAkC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAChE,OAAO;YACL,SAAS;YACT,SAAS,EAAE,EAAE;YACb,SAAS,EAAE,qCAAqC,KAAK,EAAE;SACxD,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ModelType } from '../../../../ai-service/common-types.js';
|
|
2
|
+
import { askUserForConfirmation } from '../../../../main/common/user-actions.js';
|
|
3
|
+
import { getFunctionDefs } from '../../../function-calling.js';
|
|
4
|
+
import { registerActionHandler } from '../step-ask-question-handlers.js';
|
|
5
|
+
registerActionHandler('requestPermissions', handleRequestPermissions);
|
|
6
|
+
export async function handleRequestPermissions({ askQuestionCall, options, prompt, generateContentFn, }) {
|
|
7
|
+
const [requestPermissionsCall] = (await generateContentFn([
|
|
8
|
+
...prompt,
|
|
9
|
+
{
|
|
10
|
+
type: 'assistant',
|
|
11
|
+
text: askQuestionCall.args?.message ?? '',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
type: 'user',
|
|
15
|
+
text: 'Yes, you can request the permissions.',
|
|
16
|
+
},
|
|
17
|
+
], getFunctionDefs(), 'requestPermissions', 0.7, ModelType.CHEAP, options));
|
|
18
|
+
if (!requestPermissionsCall) {
|
|
19
|
+
return {
|
|
20
|
+
breakLoop: true,
|
|
21
|
+
items: [],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const userConfirmation = await askUserForConfirmation('The assistant is requesting additional permissions. Do you want to grant them?', false, options);
|
|
25
|
+
const user = {
|
|
26
|
+
type: 'user',
|
|
27
|
+
text: userConfirmation ? 'Permissions granted.' : 'Permission request denied.',
|
|
28
|
+
functionResponses: [
|
|
29
|
+
{
|
|
30
|
+
name: 'requestPermissions',
|
|
31
|
+
call_id: requestPermissionsCall.id,
|
|
32
|
+
content: JSON.stringify({ confirmed: userConfirmation.confirmed }),
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
if (userConfirmation.confirmed) {
|
|
37
|
+
updatePermissions(requestPermissionsCall, options);
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
breakLoop: false,
|
|
41
|
+
items: [
|
|
42
|
+
{
|
|
43
|
+
assistant: {
|
|
44
|
+
type: 'assistant',
|
|
45
|
+
text: askQuestionCall.args?.message ?? '',
|
|
46
|
+
functionCalls: [requestPermissionsCall],
|
|
47
|
+
},
|
|
48
|
+
user,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function updatePermissions(requestPermissionsCall, options) {
|
|
54
|
+
const permissions = requestPermissionsCall.args;
|
|
55
|
+
if (permissions) {
|
|
56
|
+
if ('enableImagen' in permissions && permissions.enableImagen) {
|
|
57
|
+
options.imagen = options.aiService === 'openai' ? 'dall-e' : 'vertex-ai';
|
|
58
|
+
}
|
|
59
|
+
if ('enableVision' in permissions && permissions.enableVision)
|
|
60
|
+
options.vision = true;
|
|
61
|
+
if ('allowDirectoryCreate' in permissions && permissions.allowDirectoryCreate)
|
|
62
|
+
options.allowDirectoryCreate = true;
|
|
63
|
+
if ('allowFileCreate' in permissions && permissions.allowFileCreate)
|
|
64
|
+
options.allowFileCreate = true;
|
|
65
|
+
if ('allowFileDelete' in permissions && permissions.allowFileDelete)
|
|
66
|
+
options.allowFileDelete = true;
|
|
67
|
+
if ('allowFileMove' in permissions && permissions.allowFileMove)
|
|
68
|
+
options.allowFileMove = true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=handle-request-permissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handle-request-permissions.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-request-permissions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAEnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAGzE,qBAAqB,CAAC,oBAAoB,EAAE,wBAAwB,CAAC,CAAC;AAEtE,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,EAC7C,eAAe,EACf,OAAO,EACP,MAAM,EACN,iBAAiB,GACE;IACnB,MAAM,CAAC,sBAAsB,CAAC,GAAG,CAAC,MAAM,iBAAiB,CACvD;QACE,GAAG,MAAM;QACT;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE;SAC1C;QACD;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,uCAAuC;SAC9C;KACF,EACD,eAAe,EAAE,EACjB,oBAAoB,EACpB,GAAG,EACH,SAAS,CAAC,KAAK,EACf,OAAO,CACR,CAAuD,CAAC;IAEzD,IAAI,CAAC,sBAAsB,EAAE,CAAC;QAC5B,OAAO;YACL,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,EAAE;SACV,CAAC;IACJ,CAAC;IAED,MAAM,gBAAgB,GAAG,MAAM,sBAAsB,CACnD,gFAAgF,EAChF,KAAK,EACL,OAAO,CACR,CAAC;IAEF,MAAM,IAAI,GAAa;QACrB,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,4BAA4B;QAC9E,iBAAiB,EAAE;YACjB;gBACE,IAAI,EAAE,oBAAoB;gBAC1B,OAAO,EAAE,sBAAsB,CAAC,EA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,IAAI,WAAW,CAAC,aAAa;YAAE,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAChG,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
import { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Handler for the searchCode action
|
|
4
|
-
*/
|
|
5
2
|
export declare function handleSearchCode({ askQuestionCall, generateContentFn, prompt, options, }: ActionHandlerProps): Promise<ActionResult>;
|
|
@@ -2,9 +2,8 @@ import { searchSourceCode } from '../../../../files/search-files.js';
|
|
|
2
2
|
import { ModelType } from '../../../../ai-service/common-types.js';
|
|
3
3
|
import { getFunctionDefs } from '../../../function-calling.js';
|
|
4
4
|
import { putSystemMessage } from '../../../../main/common/content-bus.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*/
|
|
5
|
+
import { registerActionHandler } from '../step-ask-question-handlers.js';
|
|
6
|
+
registerActionHandler('searchCode', handleSearchCode);
|
|
8
7
|
export async function handleSearchCode({ askQuestionCall, generateContentFn, prompt, options, }) {
|
|
9
8
|
try {
|
|
10
9
|
const searchCodeCall = await generateSearchCodeCall(generateContentFn, prompt, askQuestionCall, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle-search-code.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-search-code.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAIrE,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"handle-search-code.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-search-code.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,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actions.js';
|
|
2
|
+
import { registerActionHandler } from '../step-ask-question-handlers.js';
|
|
3
|
+
registerActionHandler('sendMessage', handleSendMessage);
|
|
2
4
|
export async function handleSendMessage({ askQuestionCall, options }) {
|
|
3
5
|
const response = await askUserForInput('Your answer', askQuestionCall.args?.message ?? '', options);
|
|
4
6
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle-send-message.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-send-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"handle-send-message.js","sourceRoot":"","sources":["../../../../../src/prompt/steps/step-ask-question/handlers/handle-send-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAGzE,qBAAqB,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC;AAExD,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,EAAE,eAAe,EAAE,OAAO,EAAsB;IACtF,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,aAAa,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;IACpG,OAAO;QACL,SAAS,EAAE,KAAK;QAChB,KAAK,EAAE;YACL;gBACE,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAAE;gBAC3E,IAAI,EAAE;oBACJ,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,QAAQ,CAAC,MAAM;iBACtB;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare
|
|
1
|
+
import { ActionHandlerProps, ActionResult } from '../step-ask-question-types.js';
|
|
2
|
+
export declare function handleUpdateFile({ askQuestionCall, options, prompt, generateContentFn, }: ActionHandlerProps): Promise<ActionResult>;
|