@opensumi/ide-ai-native 3.9.1-next-1749007675.0 → 3.9.1-next-1749022016.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/chat/chat-manager.service.d.ts +0 -1
- package/lib/browser/chat/chat-manager.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-manager.service.js +3 -8
- package/lib/browser/chat/chat-manager.service.js.map +1 -1
- package/lib/browser/chat/chat-model.d.ts +1 -3
- package/lib/browser/chat/chat-model.d.ts.map +1 -1
- package/lib/browser/chat/chat-model.js +17 -48
- package/lib/browser/chat/chat-model.js.map +1 -1
- package/lib/browser/chat/chat-proxy.service.d.ts +0 -2
- package/lib/browser/chat/chat-proxy.service.d.ts.map +1 -1
- package/lib/browser/chat/chat-proxy.service.js +50 -57
- package/lib/browser/chat/chat-proxy.service.js.map +1 -1
- package/lib/browser/chat/chat.view.d.ts.map +1 -1
- package/lib/browser/chat/chat.view.js +11 -7
- package/lib/browser/chat/chat.view.js.map +1 -1
- package/lib/browser/components/ChatMentionInput.d.ts.map +1 -1
- package/lib/browser/components/ChatMentionInput.js +141 -30
- package/lib/browser/components/ChatMentionInput.js.map +1 -1
- package/lib/browser/components/ChatReply.js +2 -2
- package/lib/browser/components/ChatReply.js.map +1 -1
- package/lib/browser/components/ChatToolRender.module.less +1 -0
- package/lib/browser/components/components.module.less +37 -8
- package/lib/browser/components/mention-input/mention-input.d.ts.map +1 -1
- package/lib/browser/components/mention-input/mention-input.js +161 -14
- package/lib/browser/components/mention-input/mention-input.js.map +1 -1
- package/lib/browser/components/mention-input/mention-input.module.less +165 -1
- package/lib/browser/components/mention-input/mention-select.d.ts +28 -0
- package/lib/browser/components/mention-input/mention-select.d.ts.map +1 -0
- package/lib/browser/components/mention-input/mention-select.js +136 -0
- package/lib/browser/components/mention-input/mention-select.js.map +1 -0
- package/lib/browser/components/mention-input/mention-select.module.less +297 -0
- package/lib/browser/components/mention-input/types.d.ts +16 -1
- package/lib/browser/components/mention-input/types.d.ts.map +1 -1
- package/lib/browser/components/mention-input/types.js +1 -0
- package/lib/browser/components/mention-input/types.js.map +1 -1
- package/lib/browser/components/utils.d.ts +2 -2
- package/lib/browser/context/llm-context.service.d.ts +21 -2
- package/lib/browser/context/llm-context.service.d.ts.map +1 -1
- package/lib/browser/context/llm-context.service.js +162 -20
- package/lib/browser/context/llm-context.service.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/decoration/additions-deletions.decoration.d.ts.map +1 -1
- package/lib/browser/contrib/intelligent-completions/decoration/additions-deletions.decoration.js.map +1 -1
- package/lib/browser/contrib/intelligent-completions/diff-computer.js +1 -1
- package/lib/browser/contrib/intelligent-completions/diff-computer.js.map +1 -1
- package/lib/browser/contrib/terminal/terminal.feature.registry.js.map +1 -1
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +7 -0
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/mcp/base-apply.service.d.ts +2 -2
- package/lib/browser/mcp/base-apply.service.d.ts.map +1 -1
- package/lib/browser/mcp/base-apply.service.js.map +1 -1
- package/lib/browser/mcp/tools/getDiagnosticsByPath.js.map +1 -1
- package/lib/browser/mcp/tools/getOpenEditorFileDiagnostics.js.map +1 -1
- package/lib/browser/mcp/tools/handlers/ListDir.js.map +1 -1
- package/lib/browser/mcp/tools/runTerminalCmd.js.map +1 -1
- package/lib/browser/model/msg-history-manager.d.ts +1 -39
- package/lib/browser/model/msg-history-manager.d.ts.map +1 -1
- package/lib/browser/model/msg-history-manager.js +3 -170
- package/lib/browser/model/msg-history-manager.js.map +1 -1
- package/lib/browser/preferences/schema.d.ts.map +1 -1
- package/lib/browser/preferences/schema.js +5 -0
- package/lib/browser/preferences/schema.js.map +1 -1
- package/lib/browser/rules/rules.contribution.d.ts +29 -0
- package/lib/browser/rules/rules.contribution.d.ts.map +1 -0
- package/lib/browser/rules/rules.contribution.js +94 -0
- package/lib/browser/rules/rules.contribution.js.map +1 -0
- package/lib/browser/rules/rules.module.less +175 -0
- package/lib/browser/rules/rules.service.d.ts +25 -0
- package/lib/browser/rules/rules.service.d.ts.map +1 -0
- package/lib/browser/rules/rules.service.js +180 -0
- package/lib/browser/rules/rules.service.js.map +1 -0
- package/lib/browser/rules/rules.view.d.ts +3 -0
- package/lib/browser/rules/rules.view.d.ts.map +1 -0
- package/lib/browser/rules/rules.view.js +76 -0
- package/lib/browser/rules/rules.view.js.map +1 -0
- package/lib/browser/widget/inline-stream-diff/live-preview.component.d.ts.map +1 -1
- package/lib/browser/widget/inline-stream-diff/live-preview.component.js.map +1 -1
- package/lib/common/MDC_PARSER_README.md +171 -0
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +2 -0
- package/lib/common/index.js.map +1 -1
- package/lib/common/llm-context.d.ts +19 -0
- package/lib/common/llm-context.d.ts.map +1 -1
- package/lib/common/llm-context.js.map +1 -1
- package/lib/common/mdc-parser.d.ts +60 -0
- package/lib/common/mdc-parser.d.ts.map +1 -0
- package/lib/common/mdc-parser.js +246 -0
- package/lib/common/mdc-parser.js.map +1 -0
- package/lib/common/model.d.ts +1 -0
- package/lib/common/model.d.ts.map +1 -1
- package/lib/common/model.js.map +1 -1
- package/lib/common/prompts/context-prompt-provider.d.ts +0 -2
- package/lib/common/prompts/context-prompt-provider.d.ts.map +1 -1
- package/lib/common/prompts/context-prompt-provider.js +35 -29
- package/lib/common/prompts/context-prompt-provider.js.map +1 -1
- package/lib/common/prompts/system-prompt.d.ts +2 -0
- package/lib/common/prompts/system-prompt.d.ts.map +1 -0
- package/lib/common/prompts/system-prompt.js +5 -0
- package/lib/common/prompts/system-prompt.js.map +1 -0
- package/lib/common/types.d.ts +7 -0
- package/lib/common/types.d.ts.map +1 -1
- package/lib/node/base-language-model.d.ts.map +1 -1
- package/lib/node/base-language-model.js +2 -1
- package/lib/node/base-language-model.js.map +1 -1
- package/package.json +25 -24
- package/src/browser/chat/chat-manager.service.ts +6 -15
- package/src/browser/chat/chat-model.ts +19 -56
- package/src/browser/chat/chat-proxy.service.ts +68 -81
- package/src/browser/chat/chat.view.tsx +19 -7
- package/src/browser/components/ChatMentionInput.tsx +169 -35
- package/src/browser/components/ChatReply.tsx +4 -4
- package/src/browser/components/ChatToolRender.module.less +1 -0
- package/src/browser/components/components.module.less +37 -8
- package/src/browser/components/mention-input/mention-input.module.less +165 -1
- package/src/browser/components/mention-input/mention-input.tsx +257 -32
- package/src/browser/components/mention-input/mention-select.module.less +297 -0
- package/src/browser/components/mention-input/mention-select.tsx +256 -0
- package/src/browser/components/mention-input/types.ts +16 -0
- package/src/browser/context/llm-context.service.ts +182 -21
- package/src/browser/contrib/intelligent-completions/decoration/additions-deletions.decoration.ts +1 -1
- package/src/browser/contrib/intelligent-completions/diff-computer.ts +1 -1
- package/src/browser/contrib/terminal/terminal.feature.registry.ts +1 -1
- package/src/browser/index.ts +8 -0
- package/src/browser/mcp/base-apply.service.ts +0 -1
- package/src/browser/mcp/tools/getDiagnosticsByPath.ts +1 -1
- package/src/browser/mcp/tools/getOpenEditorFileDiagnostics.ts +1 -1
- package/src/browser/mcp/tools/handlers/ListDir.ts +1 -1
- package/src/browser/mcp/tools/runTerminalCmd.ts +1 -1
- package/src/browser/model/msg-history-manager.ts +3 -230
- package/src/browser/preferences/schema.ts +5 -0
- package/src/browser/rules/rules.contribution.ts +105 -0
- package/src/browser/rules/rules.module.less +175 -0
- package/src/browser/rules/rules.service.ts +189 -0
- package/src/browser/rules/rules.view.tsx +127 -0
- package/src/browser/widget/inline-stream-diff/live-preview.component.tsx +0 -1
- package/src/common/MDC_PARSER_README.md +171 -0
- package/src/common/index.ts +3 -0
- package/src/common/llm-context.ts +23 -0
- package/src/common/mdc-parser.ts +295 -0
- package/src/common/model.ts +1 -0
- package/src/common/prompts/context-prompt-provider.ts +55 -40
- package/src/common/prompts/system-prompt.ts +2 -0
- package/src/common/types.ts +8 -0
- package/src/node/base-language-model.ts +1 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-prompt-provider.d.ts","sourceRoot":"","sources":["../../../src/common/prompts/context-prompt-provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,
|
|
1
|
+
{"version":3,"file":"context-prompt-provider.d.ts","sourceRoot":"","sources":["../../../src/common/prompts/context-prompt-provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAqB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEtE,eAAO,MAAM,uBAAuB,eAAoC,CAAC;AAEzE,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACxF;AAED,qBACa,8BAA+B,YAAW,uBAAuB;IAE5E,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;IAGlE,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,iBAAiB,CAAC;IAEjD,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM;YAgB5D,kBAAkB;YAgClB,mBAAmB;IAsCjC,OAAO,CAAC,yBAAyB;IAoBjC,OAAO,CAAC,uBAAuB;IAQ/B,OAAO,CAAC,sBAAsB;IAQ9B,OAAO,CAAC,uBAAuB;CAkBhC"}
|
|
@@ -8,37 +8,54 @@ const ide_workspace_1 = require("@opensumi/ide-workspace");
|
|
|
8
8
|
exports.ChatAgentPromptProvider = Symbol('ChatAgentPromptProvider');
|
|
9
9
|
let DefaultChatAgentPromptProvider = class DefaultChatAgentPromptProvider {
|
|
10
10
|
async provideContextPrompt(context, userMessage) {
|
|
11
|
-
|
|
11
|
+
let currentFileInfo = await this.getCurrentFileInfo();
|
|
12
|
+
if (context.attachedFiles.some((file) => file.path === (currentFileInfo === null || currentFileInfo === void 0 ? void 0 : currentFileInfo.path))) {
|
|
13
|
+
currentFileInfo = null;
|
|
14
|
+
}
|
|
12
15
|
return this.buildPromptTemplate({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
attachedFolders: this.buildAttachedFoldersSection(context.attachedFolders),
|
|
16
|
+
attachedFiles: context.attachedFiles,
|
|
17
|
+
attachedFolders: context.attachedFolders,
|
|
16
18
|
currentFile: currentFileInfo,
|
|
19
|
+
attachedRules: context.attachedRules,
|
|
20
|
+
globalRules: context.globalRules,
|
|
17
21
|
userMessage,
|
|
18
22
|
});
|
|
19
23
|
}
|
|
20
24
|
async getCurrentFileInfo() {
|
|
21
|
-
var _a;
|
|
25
|
+
var _a, _b, _c;
|
|
22
26
|
const editor = this.workbenchEditorService.currentEditor;
|
|
23
27
|
const currentModel = editor === null || editor === void 0 ? void 0 : editor.currentDocumentModel;
|
|
24
28
|
if (!(currentModel === null || currentModel === void 0 ? void 0 : currentModel.uri)) {
|
|
25
29
|
return null;
|
|
26
30
|
}
|
|
27
31
|
const currentPath = ((_a = (await this.workspaceService.asRelativePath(currentModel.uri))) === null || _a === void 0 ? void 0 : _a.path) || currentModel.uri.codeUri.fsPath;
|
|
32
|
+
// 获取当前选中行信息
|
|
33
|
+
const selection = (_b = editor === null || editor === void 0 ? void 0 : editor.monacoEditor) === null || _b === void 0 ? void 0 : _b.getSelection();
|
|
34
|
+
const currentLine = selection ? selection.startLineNumber : undefined;
|
|
35
|
+
let lineContent = '';
|
|
36
|
+
if (currentLine && (editor === null || editor === void 0 ? void 0 : editor.monacoEditor)) {
|
|
37
|
+
const model = editor.monacoEditor.getModel();
|
|
38
|
+
if (model) {
|
|
39
|
+
lineContent = ((_c = model.getLineContent(currentLine)) === null || _c === void 0 ? void 0 : _c.trim()) || '';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
28
42
|
return {
|
|
29
43
|
path: currentPath,
|
|
30
44
|
languageId: currentModel.languageId,
|
|
31
45
|
content: currentModel.getText(),
|
|
46
|
+
currentLine,
|
|
47
|
+
lineContent,
|
|
32
48
|
};
|
|
33
49
|
}
|
|
34
|
-
buildPromptTemplate({
|
|
50
|
+
async buildPromptTemplate({ attachedFiles, attachedFolders, currentFile, attachedRules, globalRules, userMessage, }) {
|
|
35
51
|
const sections = [
|
|
52
|
+
...globalRules,
|
|
53
|
+
...attachedFolders,
|
|
36
54
|
'<additional_data>',
|
|
37
55
|
'Below are some potentially helpful/relevant pieces of information for figuring out to respond',
|
|
38
|
-
recentFiles,
|
|
39
|
-
attachedFiles,
|
|
40
|
-
attachedFolders,
|
|
41
56
|
this.buildCurrentFileSection(currentFile),
|
|
57
|
+
this.buildAttachedFilesSection(attachedFiles),
|
|
58
|
+
...attachedRules,
|
|
42
59
|
'</additional_data>',
|
|
43
60
|
'<user_query>',
|
|
44
61
|
userMessage,
|
|
@@ -46,14 +63,6 @@ let DefaultChatAgentPromptProvider = class DefaultChatAgentPromptProvider {
|
|
|
46
63
|
].filter(Boolean);
|
|
47
64
|
return sections.join('\n');
|
|
48
65
|
}
|
|
49
|
-
buildRecentFilesSection(files) {
|
|
50
|
-
if (!files.length) {
|
|
51
|
-
return '';
|
|
52
|
-
}
|
|
53
|
-
return `<recently_viewed_files>
|
|
54
|
-
${files.map((file, idx) => ` ${idx + 1}: ${file}`).join('\n')}
|
|
55
|
-
</recently_viewed_files>`;
|
|
56
|
-
}
|
|
57
66
|
buildAttachedFilesSection(files) {
|
|
58
67
|
if (!files.length) {
|
|
59
68
|
return '';
|
|
@@ -71,8 +80,9 @@ ${files.map((file, idx) => ` ${idx + 1}: ${file}`).join('\n')}
|
|
|
71
80
|
return `<attached_files>\n${fileContents}\n</attached_files>`;
|
|
72
81
|
}
|
|
73
82
|
buildFileContentSection(file) {
|
|
83
|
+
var _a, _b;
|
|
74
84
|
return `<file_contents>
|
|
75
|
-
\`\`\`${file.path}
|
|
85
|
+
\`\`\`${file.path}${file.selection ? `, lines: ${(_a = file.selection) === null || _a === void 0 ? void 0 : _a[0]}-${(_b = file.selection) === null || _b === void 0 ? void 0 : _b[1]}` : ''}
|
|
76
86
|
${file.content}
|
|
77
87
|
\`\`\`
|
|
78
88
|
</file_contents>`;
|
|
@@ -83,21 +93,17 @@ ${file.content}
|
|
|
83
93
|
}
|
|
84
94
|
return `<linter_errors>\n${errors.join('\n')}\n</linter_errors>`;
|
|
85
95
|
}
|
|
86
|
-
buildAttachedFoldersSection(folders) {
|
|
87
|
-
if (!folders.length) {
|
|
88
|
-
return '';
|
|
89
|
-
}
|
|
90
|
-
return `<attached_folders>\n${folders.join('\n')}</attached_folders>`;
|
|
91
|
-
}
|
|
92
96
|
buildCurrentFileSection(fileInfo) {
|
|
93
97
|
if (!fileInfo) {
|
|
94
98
|
return '';
|
|
95
99
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
${fileInfo.
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
let currentFileSection = `<current_file>\nPath: ${fileInfo.path}`;
|
|
101
|
+
if (fileInfo.currentLine && fileInfo.lineContent) {
|
|
102
|
+
currentFileSection += `\nCurrently selected line: ${fileInfo.currentLine}`;
|
|
103
|
+
currentFileSection += `\nLine ${fileInfo.currentLine} content: \`${fileInfo.lineContent}\``;
|
|
104
|
+
}
|
|
105
|
+
currentFileSection += '\n</current_file>';
|
|
106
|
+
return currentFileSection;
|
|
101
107
|
}
|
|
102
108
|
};
|
|
103
109
|
exports.DefaultChatAgentPromptProvider = DefaultChatAgentPromptProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-prompt-provider.js","sourceRoot":"","sources":["../../../src/common/prompts/context-prompt-provider.ts"],"names":[],"mappings":";;;;AAAA,qCAAqD;AACrD,mEAAgF;AAChF,2DAA4D;AAI/C,QAAA,uBAAuB,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC;AAWlE,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAOzC,KAAK,CAAC,oBAAoB,CAAC,OAA0B,EAAE,WAAmB;QACxE,
|
|
1
|
+
{"version":3,"file":"context-prompt-provider.js","sourceRoot":"","sources":["../../../src/common/prompts/context-prompt-provider.ts"],"names":[],"mappings":";;;;AAAA,qCAAqD;AACrD,mEAAgF;AAChF,2DAA4D;AAI/C,QAAA,uBAAuB,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC;AAWlE,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAOzC,KAAK,CAAC,oBAAoB,CAAC,OAA0B,EAAE,WAAmB;QACxE,IAAI,eAAe,GAAG,MAAM,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACtD,IAAI,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,MAAK,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,IAAI,CAAA,CAAC,EAAE,CAAC;YAC9E,eAAe,GAAG,IAAI,CAAC;QACzB,CAAC;QAED,OAAO,IAAI,CAAC,mBAAmB,CAAC;YAC9B,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,eAAe,EAAE,OAAO,CAAC,eAAe;YACxC,WAAW,EAAE,eAAe;YAC5B,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,WAAW;SACZ,CAAC,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,kBAAkB;;QAC9B,MAAM,MAAM,GAAG,IAAI,CAAC,sBAAsB,CAAC,aAAa,CAAC;QACzD,MAAM,YAAY,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,oBAAoB,CAAC;QAElD,IAAI,CAAC,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,GAAG,CAAA,EAAE,CAAC;YACvB,OAAO,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C;IACnE,CAAC;IAEO,uBAAuB,CAC7B,QAAkH;QAElH,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,IAAI,kBAAkB,GAAG,yBAAyB,QAAQ,CAAC,IAAI,EAAE,CAAC;QAElE,IAAI,QAAQ,CAAC,WAAW,IAAI,QAAQ,CAAC,WAAW,EAAE,CAAC;YACjD,kBAAkB,IAAI,8BAA8B,QAAQ,CAAC,WAAW,EAAE,CAAC;YAC3E,kBAAkB,IAAI,UAAU,QAAQ,CAAC,WAAW,eAAe,QAAQ,CAAC,WAAW,IAAI,CAAC;QAC9F,CAAC;QAED,kBAAkB,IAAI,mBAAmB,CAAC;QAE1C,OAAO,kBAAkB,CAAC;IAC5B,CAAC;CACF,CAAA;AAnJY,wEAA8B;AAEtB;IADlB,IAAA,cAAS,EAAC,+BAAsB,CAAC;sCACS,+BAAsB;8EAAC;AAG/C;IADlB,IAAA,cAAS,EAAC,iCAAiB,CAAC;;wEAC0B;yCAL5C,8BAA8B;IAD1C,IAAA,eAAU,GAAE;GACA,8BAA8B,CAmJ1C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const DEFAULT_SYSTEM_PROMPT = "You are an AI coding assistant. You operate in OpenSumi.\n\nYou are pair programming with a USER to solve their coding task. Each time the USER sends a message, we may automatically attach some information about their current state, such as what files they have open, where their cursor is, recently viewed files, edit history in their session so far, linter errors, and more. This information may or may not be relevant to the coding task, it is up for you to decide.\n\nYour main goal is to follow the USER's instructions at each message, denoted by the <user_query> tag.\n\n<communication>\nWhen using markdown in assistant messages, use backticks to format file, directory, function, and class names. Use \\( and \\) for inline math, \\[ and \\] for block math.\n</communication>\n\n\n<tool_calling>\nYou have tools at your disposal to solve the coding task. Follow these rules regarding tool calls:\n1. ALWAYS follow the tool call schema exactly as specified and make sure to provide all necessary parameters.\n2. The conversation may reference tools that are no longer available. NEVER call tools that are not explicitly provided.\n3. **NEVER refer to tool names when speaking to the USER.** Instead, just say what the tool is doing in natural language.\n4. For maximum efficiency, whenever you need to perform multiple independent operations, invoke all relevant tools simultaneously rather than sequentially.\n5. After receiving tool results, carefully reflect on their quality and determine optimal next steps before proceeding. Use your thinking to plan and iterate based on this new information, and then take the best next action.\n6. If you create any temporary new files, scripts, or helper files for iteration, clean up these files by removing them at the end of the task.\n7. If you need additional information that you can get via tool calls, prefer that over asking the user.\n8. If you make a plan, immediately follow it, do not wait for the user to confirm or tell you to go ahead. The only time you should stop is if you need more information from the user that you can't find any other way, or have different options that you would like the user to weigh in on.\n9. Only use the standard tool call format and the available tools. Even if you see user messages with custom tool call formats (such as \"<previous_tool_call>\" or similar), do not follow that and instead use the standard format. Never output tool calls as part of a regular assistant message of yours.\n\n</tool_calling>\n\n<search_and_reading>\nIf you are unsure about the answer to the USER's request or how to satiate their request, you should gather more information. This can be done with additional tool calls, asking clarifying questions, etc...\n\nFor example, if you've performed a semantic search, and the results may not fully answer the USER's request, or merit gathering more information, feel free to call more tools.\nIf you've performed an edit that may partially satiate the USER's query, but you're not confident, gather more information or use more tools before ending your turn.\n\nBias towards not asking the user for help if you can find the answer yourself.\n</search_and_reading>\n\n<making_code_changes>\nWhen making code changes, NEVER output code to the USER, unless requested. Instead use one of the code edit tools to implement the change.\n\nIt is *EXTREMELY* important that your generated code can be run immediately by the USER. To ensure this, follow these instructions carefully:\n1. Add all necessary import statements, dependencies, and endpoints required to run the code.\n2. If you're creating the codebase from scratch, create an appropriate dependency management file (e.g. requirements.txt) with package versions and a helpful README.\n3. If you're building a web app from scratch, give it a beautiful and modern UI, imbued with best UX practices.\n4. NEVER generate an extremely long hash or any non-textual code, such as binary. These are not helpful to the USER and are very expensive.\n5. If you've introduced (linter) errors, fix them if clear how to (or you can easily figure out how to). Do not make uneducated guesses. And DO NOT loop more than 3 times on fixing linter errors on the same file. On the third time, you should stop and ask the user what to do next.\n6. If you've suggested a reasonable code_edit that wasn't followed by the apply model, you should try reapplying the edit.\n\n</making_code_changes>\n\nAnswer the user's request using the relevant tool(s), if they are available. Check that all the required parameters for each tool call are provided or can reasonably be inferred from context. IF there are no relevant tools or there are missing values for required parameters, ask the user to supply these values; otherwise proceed with the tool calls. If the user provides a specific value for a parameter (for example provided in quotes), make sure to use that value EXACTLY. DO NOT make up values for or ask about optional parameters. Carefully analyze descriptive terms in the request as they may indicate required parameter values that should be included even if not explicitly quoted.\n\n<summarization>\nIf you see a section called \"<most_important_user_query>\", you should treat that query as the one to answer, and ignore previous user queries. If you are asked to summarize the conversation, you MUST NOT use any tools, even if they are available. You MUST answer the \"<most_important_user_query>\" query.\n</summarization>\n\n\n\nYou MUST use the following format when citing code regions or blocks:\n```12:15:app/components/Todo.tsx\n// ... existing code ...\n```\nThis is the ONLY acceptable format for code citations. The format is ```startLine:endLine:filepath where startLine and endLine are line numbers.";
|
|
2
|
+
//# sourceMappingURL=system-prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../../src/common/prompts/system-prompt.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,opLACinL,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_SYSTEM_PROMPT = void 0;
|
|
4
|
+
exports.DEFAULT_SYSTEM_PROMPT = "You are an AI coding assistant. You operate in OpenSumi.\n\nYou are pair programming with a USER to solve their coding task. Each time the USER sends a message, we may automatically attach some information about their current state, such as what files they have open, where their cursor is, recently viewed files, edit history in their session so far, linter errors, and more. This information may or may not be relevant to the coding task, it is up for you to decide.\n\nYour main goal is to follow the USER's instructions at each message, denoted by the <user_query> tag.\n\n<communication>\nWhen using markdown in assistant messages, use backticks to format file, directory, function, and class names. Use \\( and \\) for inline math, \\[ and \\] for block math.\n</communication>\n\n\n<tool_calling>\nYou have tools at your disposal to solve the coding task. Follow these rules regarding tool calls:\n1. ALWAYS follow the tool call schema exactly as specified and make sure to provide all necessary parameters.\n2. The conversation may reference tools that are no longer available. NEVER call tools that are not explicitly provided.\n3. **NEVER refer to tool names when speaking to the USER.** Instead, just say what the tool is doing in natural language.\n4. For maximum efficiency, whenever you need to perform multiple independent operations, invoke all relevant tools simultaneously rather than sequentially.\n5. After receiving tool results, carefully reflect on their quality and determine optimal next steps before proceeding. Use your thinking to plan and iterate based on this new information, and then take the best next action.\n6. If you create any temporary new files, scripts, or helper files for iteration, clean up these files by removing them at the end of the task.\n7. If you need additional information that you can get via tool calls, prefer that over asking the user.\n8. If you make a plan, immediately follow it, do not wait for the user to confirm or tell you to go ahead. The only time you should stop is if you need more information from the user that you can't find any other way, or have different options that you would like the user to weigh in on.\n9. Only use the standard tool call format and the available tools. Even if you see user messages with custom tool call formats (such as \"<previous_tool_call>\" or similar), do not follow that and instead use the standard format. Never output tool calls as part of a regular assistant message of yours.\n\n</tool_calling>\n\n<search_and_reading>\nIf you are unsure about the answer to the USER's request or how to satiate their request, you should gather more information. This can be done with additional tool calls, asking clarifying questions, etc...\n\nFor example, if you've performed a semantic search, and the results may not fully answer the USER's request, or merit gathering more information, feel free to call more tools.\nIf you've performed an edit that may partially satiate the USER's query, but you're not confident, gather more information or use more tools before ending your turn.\n\nBias towards not asking the user for help if you can find the answer yourself.\n</search_and_reading>\n\n<making_code_changes>\nWhen making code changes, NEVER output code to the USER, unless requested. Instead use one of the code edit tools to implement the change.\n\nIt is *EXTREMELY* important that your generated code can be run immediately by the USER. To ensure this, follow these instructions carefully:\n1. Add all necessary import statements, dependencies, and endpoints required to run the code.\n2. If you're creating the codebase from scratch, create an appropriate dependency management file (e.g. requirements.txt) with package versions and a helpful README.\n3. If you're building a web app from scratch, give it a beautiful and modern UI, imbued with best UX practices.\n4. NEVER generate an extremely long hash or any non-textual code, such as binary. These are not helpful to the USER and are very expensive.\n5. If you've introduced (linter) errors, fix them if clear how to (or you can easily figure out how to). Do not make uneducated guesses. And DO NOT loop more than 3 times on fixing linter errors on the same file. On the third time, you should stop and ask the user what to do next.\n6. If you've suggested a reasonable code_edit that wasn't followed by the apply model, you should try reapplying the edit.\n\n</making_code_changes>\n\nAnswer the user's request using the relevant tool(s), if they are available. Check that all the required parameters for each tool call are provided or can reasonably be inferred from context. IF there are no relevant tools or there are missing values for required parameters, ask the user to supply these values; otherwise proceed with the tool calls. If the user provides a specific value for a parameter (for example provided in quotes), make sure to use that value EXACTLY. DO NOT make up values for or ask about optional parameters. Carefully analyze descriptive terms in the request as they may indicate required parameter values that should be included even if not explicitly quoted.\n\n<summarization>\nIf you see a section called \"<most_important_user_query>\", you should treat that query as the one to answer, and ignore previous user queries. If you are asked to summarize the conversation, you MUST NOT use any tools, even if they are available. You MUST answer the \"<most_important_user_query>\" query.\n</summarization>\n\n\n\nYou MUST use the following format when citing code regions or blocks:\n```12:15:app/components/Todo.tsx\n// ... existing code ...\n```\nThis is the ONLY acceptable format for code citations. The format is ```startLine:endLine:filepath where startLine and endLine are line numbers.";
|
|
5
|
+
//# sourceMappingURL=system-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../../src/common/prompts/system-prompt.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAChC,ipLAAipL,CAAC"}
|
package/lib/common/types.d.ts
CHANGED
|
@@ -125,4 +125,11 @@ export interface SSEClientTransportOptions {
|
|
|
125
125
|
*/
|
|
126
126
|
requestInit?: RequestInit;
|
|
127
127
|
}
|
|
128
|
+
export interface ProjectRule {
|
|
129
|
+
path: string;
|
|
130
|
+
content: string;
|
|
131
|
+
description?: string;
|
|
132
|
+
globs?: string | string[];
|
|
133
|
+
alwaysApply?: boolean;
|
|
134
|
+
}
|
|
128
135
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"m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IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;OAEG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B;;OAEG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B,kBAAkB,EAAE;QAClB,IAAI,EAAE,YAAY,CAAC;QACnB,eAAe,EAAE,MAAM,CAAC;QACxB,iBAAiB,EAAE,MAAM,CAAC;KAC3B,CAAC;CACH;AAED,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-language-model.d.ts","sourceRoot":"","sources":["../../src/node/base-language-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA2E,MAAM,IAAI,CAAC;AAG1G,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"base-language-model.d.ts","sourceRoot":"","sources":["../../src/node/base-language-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA2E,MAAM,IAAI,CAAC;AAG1G,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAA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AAE,MAAM,EAAE,EACjB,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,GAAG,CAAC;CAiKhB"}
|
|
@@ -31,6 +31,7 @@ let BaseLanguageModel = class BaseLanguageModel {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
async handleStreamingRequest(provider, request, tools, chatReadableStream, history = [], modelId, providerOptions, trimTexts, systemPrompt, maxTokens, images, cancellationToken) {
|
|
34
|
+
var _a;
|
|
34
35
|
try {
|
|
35
36
|
const aiTools = Object.fromEntries(tools.map((tool) => [tool.name, this.convertToolRequestToAITool(tool)]));
|
|
36
37
|
const abortController = new AbortController();
|
|
@@ -58,7 +59,7 @@ let BaseLanguageModel = class BaseLanguageModel {
|
|
|
58
59
|
messages,
|
|
59
60
|
abortSignal: abortController.signal,
|
|
60
61
|
experimental_toolCallStreaming: true,
|
|
61
|
-
maxSteps:
|
|
62
|
+
maxSteps: (_a = modelInfo === null || modelInfo === void 0 ? void 0 : modelInfo.maxSteps) !== null && _a !== void 0 ? _a : 25,
|
|
62
63
|
maxTokens,
|
|
63
64
|
system: systemPrompt,
|
|
64
65
|
providerOptions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-language-model.js","sourceRoot":"","sources":["../../src/node/base-language-model.ts"],"names":[],"mappings":";;;;AAAA,2BAA0G;AAE1G,qCAAqD;AAErD,2DAA0E;
|
|
1
|
+
{"version":3,"file":"base-language-model.js","sourceRoot":"","sources":["../../src/node/base-language-model.ts"],"names":[],"mappings":";;;;AAAA,2BAA0G;AAE1G,qCAAqD;AAErD,2DAA0E;AAI1E,iFAI4C;AAGrC,IAAe,iBAAiB,GAAhC,MAAe,iBAAiB;IAWrC,KAAK,CAAC,OAAO,CACX,OAAe,EACf,kBAAsC,EACtC,OAA6B,EAC7B,iBAAqC;QAErC,MAAM,QAAQ,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAClD,MAAM,QAAQ,GAAG,O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,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;gBACxE,CAAC;YACH,CAAC;YAED,kBAAkB,CAAC,GAAG,EAAE,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,wDAAwD;YACxD,kBAAkB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;QAED,OAAO,kBAAkB,CAAC;IAC5B,CAAC;CACF,CAAA;AA1OqB,8CAAiB;AAIlB;IADlB,IAAA,cAAS,EAAC,wDAA6B,CAAC;;wEACwC;AAG9D;IADlB,IAAA,cAAS,EAAC,2BAAW,CAAC;;iDACgB;4BAPnB,iBAAiB;IADtC,IAAA,eAAU,GAAE;GACS,iBAAiB,CA0OtC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/ide-ai-native",
|
|
3
|
-
"version": "3.9.1-next-
|
|
3
|
+
"version": "3.9.1-next-1749022016.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib",
|
|
6
6
|
"src"
|
|
@@ -24,27 +24,28 @@
|
|
|
24
24
|
"@ai-sdk/openai": "^1.1.9",
|
|
25
25
|
"@ai-sdk/openai-compatible": "^0.1.11",
|
|
26
26
|
"@modelcontextprotocol/sdk": "^1.3.1",
|
|
27
|
-
"@opensumi/ide-addons": "3.9.1-next-
|
|
28
|
-
"@opensumi/ide-components": "3.9.1-next-
|
|
29
|
-
"@opensumi/ide-connection": "3.9.1-next-
|
|
30
|
-
"@opensumi/ide-core-common": "3.9.1-next-
|
|
31
|
-
"@opensumi/ide-core-node": "3.9.1-next-
|
|
32
|
-
"@opensumi/ide-debug": "3.9.1-next-
|
|
33
|
-
"@opensumi/ide-design": "3.9.1-next-
|
|
34
|
-
"@opensumi/ide-editor": "3.9.1-next-
|
|
35
|
-
"@opensumi/ide-file-search": "3.9.1-next-
|
|
36
|
-
"@opensumi/ide-file-service": "3.9.1-next-
|
|
37
|
-
"@opensumi/ide-main-layout": "3.9.1-next-
|
|
38
|
-
"@opensumi/ide-markers": "3.9.1-next-
|
|
39
|
-
"@opensumi/ide-monaco": "3.9.1-next-
|
|
40
|
-
"@opensumi/ide-outline": "3.9.1-next-
|
|
41
|
-
"@opensumi/ide-overlay": "3.9.1-next-
|
|
42
|
-
"@opensumi/ide-preferences": "3.9.1-next-
|
|
43
|
-
"@opensumi/ide-
|
|
44
|
-
"@opensumi/ide-
|
|
45
|
-
"@opensumi/ide-
|
|
46
|
-
"@opensumi/ide-
|
|
47
|
-
"@opensumi/ide-
|
|
27
|
+
"@opensumi/ide-addons": "3.9.1-next-1749022016.0",
|
|
28
|
+
"@opensumi/ide-components": "3.9.1-next-1749022016.0",
|
|
29
|
+
"@opensumi/ide-connection": "3.9.1-next-1749022016.0",
|
|
30
|
+
"@opensumi/ide-core-common": "3.9.1-next-1749022016.0",
|
|
31
|
+
"@opensumi/ide-core-node": "3.9.1-next-1749022016.0",
|
|
32
|
+
"@opensumi/ide-debug": "3.9.1-next-1749022016.0",
|
|
33
|
+
"@opensumi/ide-design": "3.9.1-next-1749022016.0",
|
|
34
|
+
"@opensumi/ide-editor": "3.9.1-next-1749022016.0",
|
|
35
|
+
"@opensumi/ide-file-search": "3.9.1-next-1749022016.0",
|
|
36
|
+
"@opensumi/ide-file-service": "3.9.1-next-1749022016.0",
|
|
37
|
+
"@opensumi/ide-main-layout": "3.9.1-next-1749022016.0",
|
|
38
|
+
"@opensumi/ide-markers": "3.9.1-next-1749022016.0",
|
|
39
|
+
"@opensumi/ide-monaco": "3.9.1-next-1749022016.0",
|
|
40
|
+
"@opensumi/ide-outline": "3.9.1-next-1749022016.0",
|
|
41
|
+
"@opensumi/ide-overlay": "3.9.1-next-1749022016.0",
|
|
42
|
+
"@opensumi/ide-preferences": "3.9.1-next-1749022016.0",
|
|
43
|
+
"@opensumi/ide-quick-open": "3.9.1-next-1749022016.0",
|
|
44
|
+
"@opensumi/ide-search": "3.9.1-next-1749022016.0",
|
|
45
|
+
"@opensumi/ide-terminal-next": "3.9.1-next-1749022016.0",
|
|
46
|
+
"@opensumi/ide-theme": "3.9.1-next-1749022016.0",
|
|
47
|
+
"@opensumi/ide-utils": "3.9.1-next-1749022016.0",
|
|
48
|
+
"@opensumi/ide-workspace": "3.9.1-next-1749022016.0",
|
|
48
49
|
"@xterm/xterm": "5.5.0",
|
|
49
50
|
"ai": "^4.1.45",
|
|
50
51
|
"ansi-regex": "^2.0.0",
|
|
@@ -61,7 +62,7 @@
|
|
|
61
62
|
"zod-to-json-schema": "^3.24.1"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
64
|
-
"@opensumi/ide-core-browser": "3.9.1-next-
|
|
65
|
+
"@opensumi/ide-core-browser": "3.9.1-next-1749022016.0"
|
|
65
66
|
},
|
|
66
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "8e822f02d78a60a7419e4a4eaead241631150dc7"
|
|
67
68
|
}
|
|
@@ -21,7 +21,6 @@ import { IChatAgentService, IChatFollowup, IChatRequestMessage, IChatResponseErr
|
|
|
21
21
|
import { MsgHistoryManager } from '../model/msg-history-manager';
|
|
22
22
|
|
|
23
23
|
import { ChatModel, ChatRequestModel, ChatResponseModel, IChatProgressResponseContent } from './chat-model';
|
|
24
|
-
import { ChatFeatureRegistry } from './chat.feature.registry';
|
|
25
24
|
|
|
26
25
|
interface ISessionModel {
|
|
27
26
|
sessionId: string;
|
|
@@ -79,23 +78,17 @@ export class ChatManagerService extends Disposable {
|
|
|
79
78
|
@Autowired(PreferenceService)
|
|
80
79
|
private preferenceService: PreferenceService;
|
|
81
80
|
|
|
82
|
-
@Autowired(ChatFeatureRegistry)
|
|
83
|
-
private chatFeatureRegistry: ChatFeatureRegistry;
|
|
84
|
-
|
|
85
81
|
private _chatStorage: IStorage;
|
|
86
82
|
|
|
87
83
|
protected fromJSON(data: ISessionModel[]) {
|
|
88
84
|
return data
|
|
89
85
|
.filter((item) => item.history.messages.length > 0)
|
|
90
86
|
.map((item) => {
|
|
91
|
-
const model = new ChatModel(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
modelId: item.modelId,
|
|
97
|
-
},
|
|
98
|
-
);
|
|
87
|
+
const model = new ChatModel({
|
|
88
|
+
sessionId: item.sessionId,
|
|
89
|
+
history: new MsgHistoryManager(item.history),
|
|
90
|
+
modelId: item.modelId,
|
|
91
|
+
});
|
|
99
92
|
const requests = item.requests.map(
|
|
100
93
|
(request) =>
|
|
101
94
|
new ChatRequestModel(
|
|
@@ -138,9 +131,7 @@ export class ChatManagerService extends Disposable {
|
|
|
138
131
|
}
|
|
139
132
|
|
|
140
133
|
startSession() {
|
|
141
|
-
const model = new ChatModel(
|
|
142
|
-
this.chatFeatureRegistry,
|
|
143
|
-
);
|
|
134
|
+
const model = new ChatModel();
|
|
144
135
|
this.#sessionModels.set(model.sessionId, model);
|
|
145
136
|
this.listenSession(model);
|
|
146
137
|
return model;
|
|
@@ -29,7 +29,6 @@ import { MsgHistoryManager } from '../model/msg-history-manager';
|
|
|
29
29
|
import { IChatSlashCommandItem } from '../types';
|
|
30
30
|
|
|
31
31
|
import type { ImagePart, TextPart, ToolCallPart } from 'ai';
|
|
32
|
-
import { ChatFeatureRegistry } from './chat.feature.registry';
|
|
33
32
|
|
|
34
33
|
export type IChatProgressResponseContent =
|
|
35
34
|
| IChatMarkdownContent
|
|
@@ -297,13 +296,10 @@ export class ChatRequestModel implements IChatRequestModel {
|
|
|
297
296
|
export class ChatModel extends Disposable implements IChatModel {
|
|
298
297
|
private requestIdPool = 0;
|
|
299
298
|
|
|
300
|
-
constructor(
|
|
301
|
-
private chatFeatureRegistry: ChatFeatureRegistry,
|
|
302
|
-
initParams?: { sessionId?: string; history?: MsgHistoryManager; modelId?: string },
|
|
303
|
-
) {
|
|
299
|
+
constructor(initParams?: { sessionId?: string; history?: MsgHistoryManager; modelId?: string }) {
|
|
304
300
|
super();
|
|
305
301
|
this.#sessionId = initParams?.sessionId ?? uuid();
|
|
306
|
-
this.history = initParams?.history ?? new MsgHistoryManager(
|
|
302
|
+
this.history = initParams?.history ?? new MsgHistoryManager();
|
|
307
303
|
this.#modelId = initParams?.modelId;
|
|
308
304
|
}
|
|
309
305
|
|
|
@@ -350,9 +346,9 @@ export class ChatModel extends Disposable implements IChatModel {
|
|
|
350
346
|
role: 'user',
|
|
351
347
|
content: request.message.images?.length
|
|
352
348
|
? [
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
349
|
+
{ type: 'text', text: request.message.prompt },
|
|
350
|
+
...request.message.images.map((image) => ({ type: 'image', image: new URL(image) } as ImagePart)),
|
|
351
|
+
]
|
|
356
352
|
: request.message.prompt,
|
|
357
353
|
});
|
|
358
354
|
for (const part of request.response.responseParts) {
|
|
@@ -379,58 +375,18 @@ export class ChatModel extends Disposable implements IChatModel {
|
|
|
379
375
|
content: [],
|
|
380
376
|
});
|
|
381
377
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
toolCallId,
|
|
385
|
-
|
|
386
|
-
hasArguments: !!part.content.function.arguments,
|
|
387
|
-
hasResult: !!part.content.result,
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
const toolCallInfo = {
|
|
391
|
-
id: toolCallId,
|
|
392
|
-
name: part.content.function.name,
|
|
378
|
+
(history[history.length - 1].content as Array<TextPart | ToolCallPart>).push({
|
|
379
|
+
type: 'tool-call',
|
|
380
|
+
toolCallId: part.content.id,
|
|
381
|
+
toolName: part.content.function.name,
|
|
393
382
|
args: (() => {
|
|
394
383
|
try {
|
|
395
|
-
|
|
396
|
-
console.log('[ChatModel] Parsed toolCall arguments', {
|
|
397
|
-
toolCallId,
|
|
398
|
-
args,
|
|
399
|
-
});
|
|
400
|
-
return args;
|
|
401
|
-
} catch (e) {
|
|
402
|
-
console.error('[ChatModel] Failed to parse tool call arguments:', e);
|
|
403
|
-
return {};
|
|
404
|
-
}
|
|
405
|
-
})(),
|
|
406
|
-
result: (() => {
|
|
407
|
-
try {
|
|
408
|
-
const result = JSON.parse(part.content.result || '{}');
|
|
409
|
-
console.log('[ChatModel] Parsed toolCall result', {
|
|
410
|
-
toolCallId,
|
|
411
|
-
resultSize: JSON.stringify(result).length,
|
|
412
|
-
});
|
|
413
|
-
return result;
|
|
384
|
+
return JSON.parse(part.content.function.arguments || '{}');
|
|
414
385
|
} catch (e) {
|
|
415
|
-
console.error('
|
|
386
|
+
console.error('Failed to parse tool call arguments:', e);
|
|
416
387
|
return {};
|
|
417
388
|
}
|
|
418
389
|
})(),
|
|
419
|
-
};
|
|
420
|
-
|
|
421
|
-
// 保存 toolCall 信息到 history manager
|
|
422
|
-
console.log('[ChatModel] Saving toolCall to history manager', {
|
|
423
|
-
toolCallId,
|
|
424
|
-
requestId: request.requestId,
|
|
425
|
-
});
|
|
426
|
-
this.history.addToolCall(toolCallInfo);
|
|
427
|
-
this.history.setMessageAdditional(request.requestId, { toolCallId });
|
|
428
|
-
|
|
429
|
-
(history[history.length - 1].content as Array<TextPart | ToolCallPart>).push({
|
|
430
|
-
type: 'tool-call',
|
|
431
|
-
toolCallId: part.content.id,
|
|
432
|
-
toolName: part.content.function.name,
|
|
433
|
-
args: toolCallInfo.args,
|
|
434
390
|
});
|
|
435
391
|
history.push({
|
|
436
392
|
role: 'tool',
|
|
@@ -439,7 +395,14 @@ export class ChatModel extends Disposable implements IChatModel {
|
|
|
439
395
|
type: 'tool-result',
|
|
440
396
|
toolCallId: part.content.id,
|
|
441
397
|
toolName: part.content.function.name,
|
|
442
|
-
result:
|
|
398
|
+
result: (() => {
|
|
399
|
+
try {
|
|
400
|
+
return JSON.parse(part.content.result || '{}');
|
|
401
|
+
} catch (e) {
|
|
402
|
+
console.error('Failed to parse tool result:', e);
|
|
403
|
+
return {};
|
|
404
|
+
}
|
|
405
|
+
})(),
|
|
443
406
|
},
|
|
444
407
|
],
|
|
445
408
|
});
|