@opensumi/ide-ai-native 3.8.1-next-1740735826.0 → 3.8.1-next-1740965430.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/lib/browser/chat/chat-agent.service.d.ts +8 -0
  2. package/lib/browser/chat/chat-agent.service.d.ts.map +1 -1
  3. package/lib/browser/chat/chat-agent.service.js +34 -0
  4. package/lib/browser/chat/chat-agent.service.js.map +1 -1
  5. package/lib/browser/chat/chat-model.d.ts.map +1 -1
  6. package/lib/browser/chat/chat-model.js +3 -2
  7. package/lib/browser/chat/chat-model.js.map +1 -1
  8. package/lib/browser/chat/chat-proxy.service.d.ts.map +1 -1
  9. package/lib/browser/chat/chat-proxy.service.js +1 -1
  10. package/lib/browser/chat/chat-proxy.service.js.map +1 -1
  11. package/lib/browser/chat/chat.module.less +1 -2
  12. package/lib/browser/chat/chat.view.d.ts.map +1 -1
  13. package/lib/browser/chat/chat.view.js +6 -38
  14. package/lib/browser/chat/chat.view.js.map +1 -1
  15. package/lib/browser/components/ChatContext/index.js +2 -2
  16. package/lib/browser/components/ChatContext/index.js.map +1 -1
  17. package/lib/browser/components/ChatInput.d.ts.map +1 -1
  18. package/lib/browser/components/ChatInput.js +25 -1
  19. package/lib/browser/components/ChatInput.js.map +1 -1
  20. package/lib/browser/components/ChatToolRender.d.ts.map +1 -1
  21. package/lib/browser/components/ChatToolRender.js +2 -3
  22. package/lib/browser/components/ChatToolRender.js.map +1 -1
  23. package/lib/browser/components/chat-history.module.less +1 -1
  24. package/lib/browser/components/components.module.less +20 -0
  25. package/lib/browser/context/llm-context.service.d.ts +18 -5
  26. package/lib/browser/context/llm-context.service.d.ts.map +1 -1
  27. package/lib/browser/context/llm-context.service.js +80 -47
  28. package/lib/browser/context/llm-context.service.js.map +1 -1
  29. package/lib/browser/layout/layout.module.less +4 -4
  30. package/lib/browser/mcp/tools/components/index.module.less +1 -0
  31. package/lib/browser/mcp/tools/createNewFileWithText.d.ts.map +1 -1
  32. package/lib/browser/mcp/tools/createNewFileWithText.js +1 -0
  33. package/lib/browser/mcp/tools/createNewFileWithText.js.map +1 -1
  34. package/lib/browser/mcp/tools/getDiagnosticsByPath.d.ts.map +1 -1
  35. package/lib/browser/mcp/tools/getDiagnosticsByPath.js +1 -0
  36. package/lib/browser/mcp/tools/getDiagnosticsByPath.js.map +1 -1
  37. package/lib/browser/mcp/tools/handlers/RunCommand.d.ts.map +1 -1
  38. package/lib/browser/mcp/tools/handlers/RunCommand.js +2 -0
  39. package/lib/browser/mcp/tools/handlers/RunCommand.js.map +1 -1
  40. package/lib/browser/mcp/tools/runTerminalCmd.d.ts.map +1 -1
  41. package/lib/browser/mcp/tools/runTerminalCmd.js +1 -0
  42. package/lib/browser/mcp/tools/runTerminalCmd.js.map +1 -1
  43. package/lib/browser/preferences/schema.d.ts.map +1 -1
  44. package/lib/browser/preferences/schema.js +0 -1
  45. package/lib/browser/preferences/schema.js.map +1 -1
  46. package/lib/common/llm-context.d.ts +13 -9
  47. package/lib/common/llm-context.d.ts.map +1 -1
  48. package/lib/common/llm-context.js.map +1 -1
  49. package/lib/common/prompts/context-prompt-provider.d.ts +4 -3
  50. package/lib/common/prompts/context-prompt-provider.d.ts.map +1 -1
  51. package/lib/common/prompts/context-prompt-provider.js +33 -22
  52. package/lib/common/prompts/context-prompt-provider.js.map +1 -1
  53. package/package.json +23 -23
  54. package/src/browser/chat/chat-agent.service.ts +42 -3
  55. package/src/browser/chat/chat-model.ts +11 -6
  56. package/src/browser/chat/chat-proxy.service.ts +2 -1
  57. package/src/browser/chat/chat.module.less +1 -2
  58. package/src/browser/chat/chat.view.tsx +7 -70
  59. package/src/browser/components/ChatContext/index.tsx +2 -2
  60. package/src/browser/components/ChatInput.tsx +67 -4
  61. package/src/browser/components/ChatToolRender.tsx +1 -2
  62. package/src/browser/components/chat-history.module.less +1 -1
  63. package/src/browser/components/components.module.less +20 -0
  64. package/src/browser/context/llm-context.service.ts +93 -54
  65. package/src/browser/layout/layout.module.less +4 -4
  66. package/src/browser/mcp/tools/components/index.module.less +1 -0
  67. package/src/browser/mcp/tools/createNewFileWithText.ts +1 -0
  68. package/src/browser/mcp/tools/getDiagnosticsByPath.ts +1 -0
  69. package/src/browser/mcp/tools/handlers/RunCommand.ts +2 -0
  70. package/src/browser/mcp/tools/runTerminalCmd.ts +1 -0
  71. package/src/browser/preferences/schema.ts +0 -1
  72. package/src/common/llm-context.ts +10 -4
  73. package/src/common/prompts/context-prompt-provider.ts +38 -29
@@ -17,6 +17,7 @@ let RunTerminalCommandTool = class RunTerminalCommandTool {
17
17
  getToolDefinition() {
18
18
  return {
19
19
  name: 'run_terminal_cmd',
20
+ label: 'Run Command',
20
21
  description: "PROPOSE a command to run on behalf of the user.\nIf you have this tool, note that you DO have the ability to run commands directly on the USER's system.\n\nAdhere to these rules:\n1. Based on the contents of the conversation, you will be told if you are in the same shell as a previous step or a new shell.\n2. If in a new shell, you should `cd` to the right directory and do necessary setup in addition to running the command.\n3. If in the same shell, the state will persist, no need to do things like `cd` to the same directory.\n4. For ANY commands that would use a pager, you should append ` | cat` to the command (or whatever is appropriate). You MUST do this for: git, less, head, tail, more, etc.\n5. For commands that are long running/expected to run indefinitely until interruption, please run them in the background. To run jobs in the background, set `is_background` to true rather than changing the details of the command.\n6. Dont include any newlines in the command.",
21
22
  inputSchema: RunCommand_1.inputSchema,
22
23
  handler: this.handler.bind(this),
@@ -1 +1 @@
1
- {"version":3,"file":"runTerminalCmd.js","sourceRoot":"","sources":["../../../../src/browser/mcp/tools/runTerminalCmd.ts"],"names":[],"mappings":";;;;AAEA,qCAAyC;AACzC,iEAAuD;AACvD,+DAA6D;AAC7D,kFAAmH;AAEnH,uCAAsG;AAEtG,oDAA8D;AAC9D,sDAAuE;AAGhE,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAajC,iBAAiB,CAAC,QAA4B;QAC5C,QAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,iBAAi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AAI,EAAE,kBAAkB;YACxB,KAAK,EAAE,aAAa;YACpB,WAAW,EACT,u9BAAu9B;YACz9B,WAAW,EAAX,wBAAW;YACX,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;SACjC,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,OAAO,CAAC,IAA0D,EAAE,MAAiB;QACjG,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACtD,CAAC;CACF,CAAA;AAhCY,wDAAsB;AAEd;IADlB,IAAA,cAAS,EAAC,gCAAmB,CAAC;;kEAC4B;AAGxC;IADlB,IAAA,cAAS,EAAC,4BAAS,CAAC;;yDACmB;AAGrB;IADlB,IAAA,cAAS,EAAC,sCAAyB,CAAC;;4DACsB;AAG1C;IADhB,IAAA,cAAS,EAAC,8BAAiB,CAAC;sCACO,8BAAiB;iEAAC;iCAX3C,sBAAsB;IADlC,IAAA,wBAAM,EAAC,6BAAqB,CAAC;GACjB,sBAAsB,CAgClC"}
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/browser/preferences/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAKzF,oBAAY,sBAAsB;IAChC,UAAU,eAAe;IACzB,UAAU,eAAe;CAC1B;AAED,eAAO,MAAM,wBAAwB,EAAE,gBAgJtC,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/browser/preferences/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAKzF,oBAAY,sBAAsB;IAChC,UAAU,eAAe;IACzB,UAAU,eAAe;CAC1B;AAED,eAAO,MAAM,wBAAwB,EAAE,gBA+ItC,CAAC"}
@@ -149,7 +149,6 @@ exports.aiNativePreferenceSchema = {
149
149
  },
150
150
  [ide_core_browser_1.AINativeSettingSectionsId.SystemPrompt]: {
151
151
  type: 'string',
152
- default: '',
153
152
  description: (0, ide_core_common_1.localize)('preference.ai.native.chat.system.prompt.description'),
154
153
  },
155
154
  },
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/browser/preferences/schema.ts"],"names":[],"mappings":";;;AAAA,iEAAyF;AACzF,+DAAqD;AAErD,gFAAyE;AAEzE,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,mDAAyB,CAAA;IACzB,mDAAyB,CAAA;AAC3B,CAAC,EAHW,sBAAsB,sCAAtB,sBAAsB,QAGjC;AAEY,QAAA,wBAAwB,GAAqB;IACxD,UAAU,EAAE;QACV,CAAC,4CAAyB,CAAC,qBAAqB,CAAC,EAAE;YACjD,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,sBAAsB,CAAC,UAAU,EAAE,sBAAsB,CAAC,UAAU,CAAC;YAC5E,gBAAgB,EAAE;gBAChB,IAAA,0BAAQ,EAAC,yDAAyD,CAAC;gBACnE,IAAA,0BAAQ,EAAC,yDAAyD,CAAC;aACpE;YACD,OAAO,EAAE,sBAAsB,CAAC,UAAU;SAC3C;QACD,CAAC,4CAAyB,CAAC,qBAAqB,CAAC,EAAE;YACjD,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,IAAI;SACd;QACD,CAAC,4CAAyB,CAAC,2BAA2B,CAAC,EAAE;YACvD,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,IAAI;SACd;QACD,CAAC,4CAAyB,CAAC,+BAA+B,CAAC,EAAE;YAC3D,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,IAAI;SACd;QACD,CAAC,4CAAyB,CAAC,eAAe,CAAC,EAAE;YAC3C,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC;YACpC,OAAO,EAAE,SAAS;SACnB;QACD,CAAC,4CAAyB,CAAC,8CA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
@@ -10,28 +10,32 @@ export interface LLMContextService {
10
10
  * 清除上下文
11
11
  */
12
12
  cleanFileContext(): void;
13
- onDidContextFilesChangeEvent: Event<FileContext[]>;
13
+ onDidContextFilesChangeEvent: Event<{
14
+ viewed: FileContext[];
15
+ attached: FileContext[];
16
+ version: number;
17
+ }>;
14
18
  /**
15
19
  * 从 context 中移除文件
16
20
  * @param uri URI
17
21
  */
18
- removeFileFromContext(uri: URI): void;
22
+ removeFileFromContext(uri: URI, isManual?: boolean): void;
19
23
  /** 导出为可序列化格式 */
20
24
  serialize(): SerializedContext;
21
25
  }
22
26
  export interface FileContext {
23
27
  uri: URI;
24
28
  selection?: [number, number];
25
- isManual: boolean;
26
29
  }
27
30
  export declare const LLMContextServiceToken: unique symbol;
31
+ export interface AttachFileContext {
32
+ content: string;
33
+ lineErrors: string[];
34
+ path: string;
35
+ language: string;
36
+ }
28
37
  export interface SerializedContext {
29
38
  recentlyViewFiles: string[];
30
- attachedFiles: Array<{
31
- content: string;
32
- lineErrors: string[];
33
- path: string;
34
- language: string;
35
- }>;
39
+ attachedFiles: Array<AttachFileContext>;
36
40
  }
37
41
  //# sourceMappingURL=llm-context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"llm-context.d.ts","sourceRoot":"","sources":["../../src/common/llm-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAEjE,MAAM,WAAW,iBAAiB;IAChC,mBAAmB,IAAI,IAAI,CAAC;IAE5B,kBAAkB,IAAI,IAAI,CAAC;IAE3B;;OAEG;IACH,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAEnF;;OAEG;IACH,gBAAgB,IAAI,IAAI,CAAC;IAEzB,4BAA4B,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,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EAAE,OAAO,GAAG,IAAI,CAAC;IAE1D,gBAAgB;IAChB,SAAS,IAAI,iBAAiB,CAAC;CAChC;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,GAAG,CAAC;IACT,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,eAAO,MAAM,sBAAsB,eAA8B,CAAC;AAElE,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,aAAa,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;CACzC"}
@@ -1 +1 @@
1
- {"version":3,"file":"llm-context.js","sourceRoot":"","sources":["../../src/common/llm-context.ts"],"names":[],"mappings":";;;AAmCa,QAAA,sBAAsB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC"}
1
+ {"version":3,"file":"llm-context.js","sourceRoot":"","sources":["../../src/common/llm-context.ts"],"names":[],"mappings":";;;AAkCa,QAAA,sBAAsB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { MaybePromise } from '@opensumi/ide-core-common/lib/utils';
1
+ import { WorkbenchEditorService } from '@opensumi/ide-editor/lib/common/editor';
2
2
  import { SerializedContext } from '../llm-context';
3
3
  export declare const ChatAgentPromptProvider: unique symbol;
4
4
  export interface ChatAgentPromptProvider {
@@ -6,9 +6,10 @@ export interface ChatAgentPromptProvider {
6
6
  * 提供上下文提示
7
7
  * @param context 上下文
8
8
  */
9
- provideContextPrompt(context: SerializedContext, userMessage: string): MaybePromise<string>;
9
+ provideContextPrompt(context: SerializedContext, userMessage: string): string;
10
10
  }
11
11
  export declare class DefaultChatAgentPromptProvider implements ChatAgentPromptProvider {
12
- provideContextPrompt(context: SerializedContext, userMessage: string): MaybePromise<string>;
12
+ protected readonly workbenchEditorService: WorkbenchEditorService;
13
+ provideContextPrompt(context: SerializedContext, userMessage: string): string;
13
14
  }
14
15
  //# sourceMappingURL=context-prompt-provider.d.ts.map
@@ -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,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAEnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,eAAO,MAAM,uBAAuB,eAAoC,CAAC;AAEzE,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;CAC7F;AAED,qBACa,8BAA+B,YAAW,uBAAuB;IAC5E,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC;CA4B5F"}
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;AAEhF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,eAAO,MAAM,uBAAuB,eAAoC,CAAC;AAEzE,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;CAC/E;AAED,qBACa,8BAA+B,YAAW,uBAAuB;IAE5E,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;IAElE,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM;CAkC9E"}
@@ -3,35 +3,46 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DefaultChatAgentPromptProvider = exports.ChatAgentPromptProvider = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const di_1 = require("@opensumi/di");
6
+ const editor_1 = require("@opensumi/ide-editor/lib/common/editor");
6
7
  exports.ChatAgentPromptProvider = Symbol('ChatAgentPromptProvider');
7
8
  let DefaultChatAgentPromptProvider = class DefaultChatAgentPromptProvider {
8
9
  provideContextPrompt(context, userMessage) {
10
+ const editor = this.workbenchEditorService.currentEditor;
11
+ const currentModel = editor === null || editor === void 0 ? void 0 : editor.currentDocumentModel;
9
12
  return `
10
- <additional_data>
11
- Below are some potentially helpful/relevant pieces of information for figuring out to respond
12
- <recently_viewed_files>
13
- ${context.recentlyViewFiles.map((file, idx) => `${idx + 1} : ${file}`)}
14
- </recently_viewed_files>
15
- <attached_files>
16
- ${context.attachedFiles.map((file) => `
17
- <file_contents>
18
- \`\`\`${file.language} ${file.path}
19
- ${file.content}
20
- \`\`\`
21
- </file_contents>
22
- <linter_errors>
23
- ${file.lineErrors.join('\n')}
24
- </linter_errors>
25
- `)}
26
-
27
- </attached_files>
28
- </additional_data>
29
- <user_query>
30
- ${userMessage}
31
- </user_query>`;
13
+ <additional_data>
14
+ Below are some potentially helpful/relevant pieces of information for figuring out to respond
15
+ <recently_viewed_files>
16
+ ${context.recentlyViewFiles.map((file, idx) => ` ${idx + 1}: ${file}`).join('\n')}
17
+ </recently_viewed_files>
18
+ <attached_files>
19
+ ${context.attachedFiles.map((file) => `
20
+ <file_contents>
21
+ \`\`\`${file.path}
22
+ ${file.content}
23
+ \`\`\`
24
+ </file_contents>
25
+ <linter_errors>
26
+ ${file.lineErrors.join('\n')}
27
+ </linter_errors>
28
+ `)}
29
+ </attached_files>
30
+ ${currentModel ? `<current_opened_file>
31
+ \`\`\`${currentModel.languageId} ${currentModel.uri.toString()}
32
+ ${currentModel.getText()}
33
+ \`\`\`
34
+ </current_opened_file>` : ''}
35
+ </additional_data>
36
+ <user_query>
37
+ ${userMessage}
38
+ </user_query>`;
32
39
  }
33
40
  };
34
41
  exports.DefaultChatAgentPromptProvider = DefaultChatAgentPromptProvider;
42
+ tslib_1.__decorate([
43
+ (0, di_1.Autowired)(editor_1.WorkbenchEditorService),
44
+ tslib_1.__metadata("design:type", editor_1.WorkbenchEditorService)
45
+ ], DefaultChatAgentPromptProvider.prototype, "workbenchEditorService", void 0);
35
46
  exports.DefaultChatAgentPromptProvider = DefaultChatAgentPromptProvider = tslib_1.__decorate([
36
47
  (0, di_1.Injectable)()
37
48
  ], DefaultChatAgentPromptProvider);
@@ -1 +1 @@
1
- {"version":3,"file":"context-prompt-provider.js","sourceRoot":"","sources":["../../../src/common/prompts/context-prompt-provider.ts"],"names":[],"mappings":";;;;AAAA,qCAA0C;AAK7B,QAAA,uBAAuB,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC;AAWlE,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IACzC,oBAAoB,CAAC,OAA0B,EAAE,WAAmB;QAClE,OAAO;;;;YAIC,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC;;;YAGpE,OAAO,CAAC,aAAa,CAAC,GAAG,CACzB,CAAC,IAAI,EAAE,EAAE,CACP;;kBAEI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,IAAI;YAChC,IAAI,CAAC,OAAO;;;;YAIZ,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;;WAE3B,CACA;;;;;YAKC,WAAW;wBACC,CAAC;IACvB,CAAC;CACF,CAAA;AA7BY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,eAAU,GAAE;GACA,8BAA8B,CA6B1C"}
1
+ {"version":3,"file":"context-prompt-provider.js","sourceRoot":"","sources":["../../../src/common/prompts/context-prompt-provider.ts"],"names":[],"mappings":";;;;AAAA,qCAAqD;AACrD,mEAAgF;AAInE,QAAA,uBAAuB,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC;AAWlE,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAIzC,oBAAoB,CAAC,OAA0B,EAAE,WAAmB;QAClE,MAAM,MAAM,GAAG,IAAI,CAAC,sBAAsB,CAAC,aAAa,CAAC;QACzD,MAAM,YAAY,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,oBAAoB,CAAC;QAClD,OAAO;;;;EAIT,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,OAAO,GAAG,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;;MAG9E,OAAO,CAAC,aAAa,CAAC,GAAG,CACzB,CAAC,IAAI,EAAE,EAAE,CACP;;YAEI,IAAI,CAAC,IAAI;MACf,IAAI,CAAC,OAAO;;;;MAIZ,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;;eAEjB,CACV;;EAEH,YAAY,CAAC,CAAC,CAAC;UACP,YAAY,CAAC,UAAU,IAAI,YAAY,CAAC,GAAG,CAAC,QAAQ,EAAE;EAC9D,YAAY,CAAC,OAAO,EAAE;;yBAEC,CAAC,CAAC,CAAC,EAAE;;;EAG5B,WAAW;cACC,CAAC;IACb,CAAC;CACF,CAAA;AAtCY,wEAA8B;AAEtB;IADlB,IAAA,cAAS,EAAC,+BAAsB,CAAC;sCACS,+BAAsB;8EAAC;yCAFvD,8BAA8B;IAD1C,IAAA,eAAU,GAAE;GACA,8BAA8B,CAsC1C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opensumi/ide-ai-native",
3
- "version": "3.8.1-next-1740735826.0",
3
+ "version": "3.8.1-next-1740965430.0",
4
4
  "files": [
5
5
  "lib",
6
6
  "src"
@@ -23,26 +23,26 @@
23
23
  "@ai-sdk/deepseek": "^0.1.11",
24
24
  "@ai-sdk/openai-compatible": "^0.1.11",
25
25
  "@modelcontextprotocol/sdk": "^1.3.1",
26
- "@opensumi/ide-addons": "3.8.1-next-1740735826.0",
27
- "@opensumi/ide-components": "3.8.1-next-1740735826.0",
28
- "@opensumi/ide-connection": "3.8.1-next-1740735826.0",
29
- "@opensumi/ide-core-common": "3.8.1-next-1740735826.0",
30
- "@opensumi/ide-core-node": "3.8.1-next-1740735826.0",
31
- "@opensumi/ide-debug": "3.8.1-next-1740735826.0",
32
- "@opensumi/ide-design": "3.8.1-next-1740735826.0",
33
- "@opensumi/ide-editor": "3.8.1-next-1740735826.0",
34
- "@opensumi/ide-file-search": "3.8.1-next-1740735826.0",
35
- "@opensumi/ide-file-service": "3.8.1-next-1740735826.0",
36
- "@opensumi/ide-main-layout": "3.8.1-next-1740735826.0",
37
- "@opensumi/ide-markers": "3.8.1-next-1740735826.0",
38
- "@opensumi/ide-monaco": "3.8.1-next-1740735826.0",
39
- "@opensumi/ide-overlay": "3.8.1-next-1740735826.0",
40
- "@opensumi/ide-preferences": "3.8.1-next-1740735826.0",
41
- "@opensumi/ide-search": "3.8.1-next-1740735826.0",
42
- "@opensumi/ide-terminal-next": "3.8.1-next-1740735826.0",
43
- "@opensumi/ide-theme": "3.8.1-next-1740735826.0",
44
- "@opensumi/ide-utils": "3.8.1-next-1740735826.0",
45
- "@opensumi/ide-workspace": "3.8.1-next-1740735826.0",
26
+ "@opensumi/ide-addons": "3.8.1-next-1740965430.0",
27
+ "@opensumi/ide-components": "3.8.1-next-1740965430.0",
28
+ "@opensumi/ide-connection": "3.8.1-next-1740965430.0",
29
+ "@opensumi/ide-core-common": "3.8.1-next-1740965430.0",
30
+ "@opensumi/ide-core-node": "3.8.1-next-1740965430.0",
31
+ "@opensumi/ide-debug": "3.8.1-next-1740965430.0",
32
+ "@opensumi/ide-design": "3.8.1-next-1740965430.0",
33
+ "@opensumi/ide-editor": "3.8.1-next-1740965430.0",
34
+ "@opensumi/ide-file-search": "3.8.1-next-1740965430.0",
35
+ "@opensumi/ide-file-service": "3.8.1-next-1740965430.0",
36
+ "@opensumi/ide-main-layout": "3.8.1-next-1740965430.0",
37
+ "@opensumi/ide-markers": "3.8.1-next-1740965430.0",
38
+ "@opensumi/ide-monaco": "3.8.1-next-1740965430.0",
39
+ "@opensumi/ide-overlay": "3.8.1-next-1740965430.0",
40
+ "@opensumi/ide-preferences": "3.8.1-next-1740965430.0",
41
+ "@opensumi/ide-search": "3.8.1-next-1740965430.0",
42
+ "@opensumi/ide-terminal-next": "3.8.1-next-1740965430.0",
43
+ "@opensumi/ide-theme": "3.8.1-next-1740965430.0",
44
+ "@opensumi/ide-utils": "3.8.1-next-1740965430.0",
45
+ "@opensumi/ide-workspace": "3.8.1-next-1740965430.0",
46
46
  "@xterm/xterm": "5.5.0",
47
47
  "ai": "^4.1.45",
48
48
  "ansi-regex": "^2.0.0",
@@ -57,7 +57,7 @@
57
57
  "zod-to-json-schema": "^3.24.1"
58
58
  },
59
59
  "devDependencies": {
60
- "@opensumi/ide-core-browser": "3.8.1-next-1740735826.0"
60
+ "@opensumi/ide-core-browser": "3.8.1-next-1740965430.0"
61
61
  },
62
- "gitHead": "d65885df2186f12fb5af31ef3677faec843830c5"
62
+ "gitHead": "d7a584f2cfadb07e889c0f0d10b4872fad286fc2"
63
63
  }
@@ -4,16 +4,15 @@ import { Autowired, Injectable } from '@opensumi/di';
4
4
  import {
5
5
  CancellationToken,
6
6
  ChatFeatureRegistryToken,
7
+ ChatMessageRole,
7
8
  ChatServiceToken,
8
9
  Disposable,
9
10
  Emitter,
10
- IChatContent,
11
11
  IChatProgress,
12
12
  IDisposable,
13
13
  ILogger,
14
- toDisposable,
14
+ toDisposable
15
15
  } from '@opensumi/ide-core-common';
16
- import { ChatMessageRole } from '@opensumi/ide-core-common';
17
16
  import { IChatMessage } from '@opensumi/ide-core-common/lib/types/ai-native';
18
17
 
19
18
  import {
@@ -26,6 +25,8 @@ import {
26
25
  IChatFollowup,
27
26
  IChatMessageStructure,
28
27
  } from '../../common';
28
+ import { LLMContextService, LLMContextServiceToken } from '../../common/llm-context';
29
+ import { ChatAgentPromptProvider } from '../../common/prompts/context-prompt-provider';
29
30
  import { IChatFeatureRegistry } from '../types';
30
31
 
31
32
  import { ChatService } from './chat.api.service';
@@ -36,6 +37,12 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
36
37
 
37
38
  private defaultAgentId: string | undefined;
38
39
 
40
+ private initialUserMessageMap: Map<string, string> = new Map();
41
+
42
+ private shouldUpdateContext = false;
43
+
44
+ private contextVersion: number;
45
+
39
46
  private readonly _onDidChangeAgents = new Emitter<void>();
40
47
  readonly onDidChangeAgents = this._onDidChangeAgents.event;
41
48
 
@@ -45,6 +52,12 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
45
52
  @Autowired(ILogger)
46
53
  logger: ILogger;
47
54
 
55
+ @Autowired(LLMContextServiceToken)
56
+ protected readonly contextService: LLMContextService;
57
+
58
+ @Autowired(ChatAgentPromptProvider)
59
+ protected readonly promptProvider: ChatAgentPromptProvider;
60
+
48
61
  @Autowired(ChatServiceToken)
49
62
  private aiChatService: ChatService;
50
63
 
@@ -54,6 +67,12 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
54
67
  constructor() {
55
68
  super();
56
69
  this.addDispose(this._onDidChangeAgents);
70
+ this.addDispose(this.contextService.onDidContextFilesChangeEvent((event) => {
71
+ if (event.version !== this.contextVersion) {
72
+ this.contextVersion = event.version;
73
+ this.shouldUpdateContext = true;
74
+ }
75
+ }));
57
76
  }
58
77
 
59
78
  registerAgent(agent: IChatAgent): IDisposable {
@@ -120,6 +139,8 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
120
139
  if (!data) {
121
140
  throw new Error(`No agent with id ${id}`);
122
141
  }
142
+
143
+ // system
123
144
  if (data.agent.metadata.systemPrompt) {
124
145
  history.unshift({
125
146
  role: ChatMessageRole.System,
@@ -127,10 +148,28 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
127
148
  });
128
149
  }
129
150
 
151
+ // 发送第一条消息时携带初始 context
152
+ if (!this.initialUserMessageMap.has(id)) {
153
+ this.initialUserMessageMap.set(id, request.message);
154
+ const rawMessage = request.message;
155
+ request.message = this.provideContextMessage(rawMessage);
156
+ }
157
+
158
+ if (this.shouldUpdateContext) {
159
+ request.message = this.provideContextMessage(request.message);
160
+ this.shouldUpdateContext = false;
161
+ }
162
+
130
163
  const result = await data.agent.invoke(request, progress, history, token);
131
164
  return result;
132
165
  }
133
166
 
167
+ private provideContextMessage(message: string) {
168
+ const context = this.contextService.serialize();
169
+ const fullMessage = this.promptProvider.provideContextPrompt(context, message);
170
+ return fullMessage;
171
+ }
172
+
134
173
  populateChatInput(id: string, message: IChatMessageStructure) {
135
174
  this.aiChatService.sendMessage({
136
175
  ...message,
@@ -1,4 +1,4 @@
1
- import { Autowired, INJECTOR_TOKEN, Injectable, Injector } from '@opensumi/di';
1
+ import { Injectable } from '@opensumi/di';
2
2
  import {
3
3
  Disposable,
4
4
  Emitter,
@@ -8,8 +8,6 @@ import {
8
8
  IChatProgress,
9
9
  IChatToolContent,
10
10
  IChatTreeData,
11
- ILogger,
12
- memoize,
13
11
  uuid,
14
12
  } from '@opensumi/ide-core-common';
15
13
  import { MarkdownString, isMarkdownString } from '@opensumi/monaco-editor-core/esm/vs/base/common/htmlContent';
@@ -274,13 +272,18 @@ export class ChatRequestModel implements IChatRequestModel {
274
272
  export class ChatModel extends Disposable implements IChatModel {
275
273
  private static requestIdPool = 0;
276
274
 
277
- constructor(initParams?: { sessionId?: string; history?: MsgHistoryManager; requests?: ChatRequestModel[] }) {
275
+ constructor(initParams?: {
276
+ sessionId?: string;
277
+ history?: MsgHistoryManager;
278
+ requests?: ChatRequestModel[];
279
+ }) {
278
280
  super();
279
281
  this.#sessionId = initParams?.sessionId ?? uuid();
280
282
  this.history = initParams?.history ?? new MsgHistoryManager();
281
283
  if (initParams?.requests) {
282
284
  this.#requests = new Map(initParams.requests.map((r) => [r.requestId, r]));
283
285
  }
286
+
284
287
  }
285
288
 
286
289
  #sessionId: string;
@@ -300,9 +303,11 @@ export class ChatModel extends Disposable implements IChatModel {
300
303
  readonly history: MsgHistoryManager;
301
304
 
302
305
  addRequest(message: IChatRequestMessage): ChatRequestModel {
306
+ const msg = message;
307
+
303
308
  const requestId = `${this.sessionId}_request_${ChatModel.requestIdPool++}`;
304
- const response = new ChatResponseModel(requestId, this, message.agentId);
305
- const request = new ChatRequestModel(requestId, this, message, response);
309
+ const response = new ChatResponseModel(requestId, this, msg.agentId);
310
+ const request = new ChatRequestModel(requestId, this, msg, response);
306
311
 
307
312
  this.#requests.set(requestId, request);
308
313
  return request;
@@ -8,6 +8,7 @@ import {
8
8
  ChatServiceToken,
9
9
  Deferred,
10
10
  Disposable,
11
+ getOperatingSystemName,
11
12
  IAIBackService,
12
13
  IAIReporter,
13
14
  IApplicationService,
@@ -92,7 +93,7 @@ export class ChatProxyService extends Disposable {
92
93
  AINativeSettingSectionsId.SystemPrompt,
93
94
  'You are a powerful AI coding assistant working in OpenSumi, a top IDE framework. You collaborate with a USER to solve coding tasks, which may involve creating, modifying, or debugging code, or answering questions. When the USER sends a message, relevant context (e.g., open files, cursor position, edit history, linter errors) may be attached. Use this information as needed.\n\n<tool_calling>\nYou have access to tools to assist with tasks. Follow these rules:\n1. Always adhere to the tool call schema and provide all required parameters.\n2. Only use tools explicitly provided; ignore unavailable ones.\n3. Avoid mentioning tool names to the USER (e.g., say "I will edit your file" instead of "I need to use the edit_file tool").\n4. Only call tools when necessary; respond directly if the task is general or you already know the answer.\n5. Explain to the USER why you’re using a tool before calling it.\n</tool_calling>\n\n<making_code_changes>\nWhen modifying code:\n1. Use code edit tools instead of outputting code unless explicitly requested.\n2. Limit tool calls to one per turn.\n3. Ensure generated code is immediately executable by including necessary imports, dependencies, and endpoints.\n4. For new projects, create a dependency management file (e.g., requirements.txt) and a README.\n5. For web apps, design a modern, user-friendly UI.\n6. Avoid generating non-textual or excessively long code.\n7. Read file contents before editing, unless appending a small change or creating a new file.\n8. Fix introduced linter errors if possible, but stop after 3 attempts and ask the USER for guidance.\n9. Reapply reasonable code edits if they weren’t followed initially.\n</making_code_changes>\n\nUse the appropriate tools to fulfill the USER’s request, ensuring all required parameters are provided or inferred from context.',
94
95
  ) +
95
- `\n\n<user_info>\nThe user's OS version is ${this.applicationService.frontendOS}. The absolute path of the user's workspace is ${this.appConfig.workspaceDir}.\n</user_info>`,
96
+ `\n\n<user_info>\nThe user's OS is ${getOperatingSystemName()}. The absolute path of the user's workspace is ${this.appConfig.workspaceDir}.\n</user_info>`,
96
97
  },
97
98
  invoke: async (
98
99
  request: IChatAgentRequest,
@@ -279,7 +279,6 @@
279
279
  }
280
280
  }
281
281
 
282
-
283
282
  .chat_tips_container {
284
283
  display: flex;
285
284
  align-items: center;
@@ -290,6 +289,6 @@
290
289
  }
291
290
 
292
291
  .chat_history {
293
- width: calc(100% - 60px);
292
+ width: calc(100% - 40px);
294
293
  color: var(--design-text-foreground);
295
294
  }
@@ -5,7 +5,6 @@ import {
5
5
  AINativeConfigService,
6
6
  CommandService,
7
7
  getIcon,
8
- useEventEffect,
9
8
  useInjectable,
10
9
  useUpdateOnEvent,
11
10
  } from '@opensumi/ide-core-browser';
@@ -42,8 +41,6 @@ import {
42
41
  IChatMessageStructure,
43
42
  TokenMCPServerProxyService,
44
43
  } from '../../common';
45
- import { LLMContextService, LLMContextServiceToken } from '../../common/llm-context';
46
- import { ChatAgentPromptProvider } from '../../common/prompts/context-prompt-provider';
47
44
  import { ChatContext } from '../components/ChatContext';
48
45
  import { CodeBlockWrapperInput } from '../components/ChatEditor';
49
46
  import ChatHistory, { IChatHistoryItem } from '../components/ChatHistory';
@@ -82,17 +79,11 @@ export const AIChatView = () => {
82
79
  const chatAgentService = useInjectable<IChatAgentService>(IChatAgentService);
83
80
  const chatFeatureRegistry = useInjectable<ChatFeatureRegistry>(ChatFeatureRegistryToken);
84
81
  const chatRenderRegistry = useInjectable<ChatRenderRegistry>(ChatRenderRegistryToken);
85
- const contextService = useInjectable<LLMContextService>(LLMContextServiceToken);
86
- const promptProvider = useInjectable<ChatAgentPromptProvider>(ChatAgentPromptProvider);
87
- const mcpServerProxyService = useInjectable<MCPServerProxyService>(TokenMCPServerProxyService);
88
82
 
89
83
  const layoutService = useInjectable<IMainLayoutService>(IMainLayoutService);
90
84
  const msgHistoryManager = aiChatService.sessionModel.history;
91
85
  const containerRef = React.useRef<HTMLDivElement>(null);
92
86
  const chatInputRef = React.useRef<{ setInputValue: (v: string) => void } | null>(null);
93
- const dialogService = useInjectable<IDialogService>(IDialogService);
94
- const aiNativeConfigService = useInjectable<AINativeConfigService>(AINativeConfigService);
95
- const commandService = useInjectable<CommandService>(CommandService);
96
87
 
97
88
  const [shortcutCommands, setShortcutCommands] = React.useState<ChatSlashCommandItemModel[]>([]);
98
89
 
@@ -114,8 +105,6 @@ export const AIChatView = () => {
114
105
  const [defaultAgentId, setDefaultAgentId] = React.useState<string>('');
115
106
  const [command, setCommand] = React.useState('');
116
107
  const [theme, setTheme] = React.useState<string | null>(null);
117
- const [mcpToolsCount, setMcpToolsCount] = React.useState<number>(0);
118
- const [mcpServersCount, setMcpServersCount] = React.useState<number>(0);
119
108
 
120
109
  React.useEffect(() => {
121
110
  const featureSlashCommands = chatFeatureRegistry.getAllShortcutSlashCommand();
@@ -515,10 +504,7 @@ export const AIChatView = () => {
515
504
  const { message, agentId, command, reportExtra } = value;
516
505
  const { actionType, actionSource } = reportExtra || {};
517
506
 
518
- const context = contextService.serialize();
519
- const fullMessage = await promptProvider.provideContextPrompt(context, message);
520
-
521
- const request = aiChatService.createRequest(fullMessage, agentId!, command);
507
+ const request = aiChatService.createRequest(message, agentId!, command);
522
508
  if (!request) {
523
509
  return;
524
510
  }
@@ -667,32 +653,6 @@ export const AIChatView = () => {
667
653
  };
668
654
  }, [aiChatService.sessionModel]);
669
655
 
670
- useEventEffect(
671
- mcpServerProxyService.onChangeMCPServers,
672
- () => {
673
- mcpServerProxyService.getAllMCPTools().then((tools) => {
674
- setMcpToolsCount(tools.length);
675
- });
676
- mcpServerProxyService.$getServers().then((servers) => {
677
- setMcpServersCount(servers.length);
678
- });
679
- },
680
- [mcpServerProxyService],
681
- );
682
-
683
- const handleShowMCPTools = React.useCallback(async () => {
684
- const tools = await mcpServerProxyService.getAllMCPTools();
685
- dialogService.open({
686
- message: <MCPToolsDialog tools={tools} />,
687
- type: MessageType.Empty,
688
- buttons: ['关闭'],
689
- });
690
- }, [mcpServerProxyService, dialogService]);
691
-
692
- const handleShowMCPConfig = React.useCallback(() => {
693
- commandService.executeCommand(OPEN_MCP_CONFIG_COMMAND.id);
694
- }, [commandService]);
695
-
696
656
  return (
697
657
  <div id={styles.ai_chat_view}>
698
658
  <div className={styles.header_container}>
@@ -732,18 +692,6 @@ export const AIChatView = () => {
732
692
  </Popover>
733
693
  ))}
734
694
  </div>
735
- <div className={styles.header_operate_right}>
736
- {aiNativeConfigService.capabilities.supportsMCP && (
737
- <>
738
- <div className={styles.tag} onClick={handleShowMCPConfig}>
739
- {`MCP Servers: ${mcpServersCount}`}
740
- </div>
741
- <div className={styles.tag} onClick={handleShowMCPTools}>
742
- {`MCP Tools: ${mcpToolsCount}`}
743
- </div>
744
- </>
745
- )}
746
- </div>
747
695
  </div>
748
696
  <ChatInputWrapperRender
749
697
  onSend={(value, agentId, command) =>
@@ -786,6 +734,8 @@ export function DefaultChatViewHeader({
786
734
  const aiNativeConfigService = useInjectable<AINativeConfigService>(AINativeConfigService);
787
735
  const mcpServerProxyService = useInjectable<MCPServerProxyService>(TokenMCPServerProxyService);
788
736
  const aiChatService = useInjectable<ChatInternalService>(IChatInternalService);
737
+ const commandService = useInjectable<CommandService>(CommandService);
738
+
789
739
  const [historyList, setHistoryList] = React.useState<IChatHistoryItem[]>([]);
790
740
  const [currentTitle, setCurrentTitle] = React.useState<string>('');
791
741
  const handleNewChat = React.useCallback(() => {
@@ -806,6 +756,10 @@ export function DefaultChatViewHeader({
806
756
  [aiChatService],
807
757
  );
808
758
 
759
+ const handleShowMCPConfig = React.useCallback(() => {
760
+ commandService.executeCommand(OPEN_MCP_CONFIG_COMMAND.id);
761
+ }, [commandService]);
762
+
809
763
  const handleShowMCPTools = React.useCallback(async () => {
810
764
  const tools = await mcpServerProxyService.getAllMCPTools();
811
765
  dialogService.open({
@@ -894,23 +848,6 @@ export function DefaultChatViewHeader({
894
848
  ariaLabel={localize('aiNative.operate.clear.title')}
895
849
  />
896
850
  </Popover>
897
- {aiNativeConfigService.capabilities.supportsMCP && (
898
- <Popover
899
- overlayClassName={styles.popover_icon}
900
- id={'ai-chat-header-tools'}
901
- position={PopoverPosition.left}
902
- title={localize('aiNative.operate.tools.title')}
903
- >
904
- <EnhanceIcon
905
- wrapperClassName={styles.action_btn}
906
- className={getIcon('menubar-tool')}
907
- onClick={handleShowMCPTools}
908
- tabIndex={0}
909
- role='button'
910
- ariaLabel={localize('aiNative.operate.tools.title')}
911
- />
912
- </Popover>
913
- )}
914
851
  <Popover
915
852
  overlayClassName={styles.popover_icon}
916
853
  id={'ai-chat-header-close'}
@@ -39,7 +39,7 @@ export const ChatContext = memo(() => {
39
39
  50,
40
40
  )((files) => {
41
41
  if (files) {
42
- updateAddedFiles(files);
42
+ updateAddedFiles([...files.attached]);
43
43
  }
44
44
  }, contextService);
45
45
 
@@ -57,7 +57,7 @@ export const ChatContext = memo(() => {
57
57
  }, []);
58
58
 
59
59
  const onDidDeselect = useCallback((uri: URI) => {
60
- contextService.removeFileFromContext(uri);
60
+ contextService.removeFileFromContext(uri, true);
61
61
  }, []);
62
62
 
63
63
  const onDidClickFile = useCallback((uri: URI) => {