@theia/ai-chat 1.63.0-next.24 → 1.63.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 (94) hide show
  1. package/lib/browser/agent-delegation-tool.d.ts +25 -0
  2. package/lib/browser/agent-delegation-tool.d.ts.map +1 -0
  3. package/lib/browser/agent-delegation-tool.js +171 -0
  4. package/lib/browser/agent-delegation-tool.js.map +1 -0
  5. package/lib/browser/ai-chat-frontend-module.d.ts.map +1 -1
  6. package/lib/browser/ai-chat-frontend-module.js +8 -0
  7. package/lib/browser/ai-chat-frontend-module.js.map +1 -1
  8. package/lib/browser/change-set-file-element.d.ts +47 -8
  9. package/lib/browser/change-set-file-element.d.ts.map +1 -1
  10. package/lib/browser/change-set-file-element.js +207 -31
  11. package/lib/browser/change-set-file-element.js.map +1 -1
  12. package/lib/browser/chat-tool-preferences.d.ts +1 -1
  13. package/lib/browser/chat-tool-preferences.d.ts.map +1 -1
  14. package/lib/browser/chat-tool-preferences.js +4 -4
  15. package/lib/browser/chat-tool-preferences.js.map +1 -1
  16. package/lib/browser/chat-tool-request-service.js +1 -1
  17. package/lib/browser/chat-tool-request-service.js.map +1 -1
  18. package/lib/browser/delegation-response-content.d.ts +20 -0
  19. package/lib/browser/delegation-response-content.d.ts.map +1 -0
  20. package/lib/browser/delegation-response-content.js +51 -0
  21. package/lib/browser/delegation-response-content.js.map +1 -0
  22. package/lib/browser/file-chat-variable-contribution.d.ts +15 -1
  23. package/lib/browser/file-chat-variable-contribution.d.ts.map +1 -1
  24. package/lib/browser/file-chat-variable-contribution.js +111 -5
  25. package/lib/browser/file-chat-variable-contribution.js.map +1 -1
  26. package/lib/browser/frontend-chat-service.d.ts +1 -1
  27. package/lib/browser/frontend-chat-service.d.ts.map +1 -1
  28. package/lib/browser/frontend-chat-service.js +2 -13
  29. package/lib/browser/frontend-chat-service.js.map +1 -1
  30. package/lib/browser/image-context-variable-contribution.d.ts +27 -0
  31. package/lib/browser/image-context-variable-contribution.d.ts.map +1 -0
  32. package/lib/browser/image-context-variable-contribution.js +149 -0
  33. package/lib/browser/image-context-variable-contribution.js.map +1 -0
  34. package/lib/browser/task-context-service.d.ts +9 -3
  35. package/lib/browser/task-context-service.d.ts.map +1 -1
  36. package/lib/browser/task-context-service.js +111 -9
  37. package/lib/browser/task-context-service.js.map +1 -1
  38. package/lib/browser/task-context-storage-service.d.ts +1 -0
  39. package/lib/browser/task-context-storage-service.d.ts.map +1 -1
  40. package/lib/browser/task-context-storage-service.js +4 -1
  41. package/lib/browser/task-context-storage-service.js.map +1 -1
  42. package/lib/common/change-set.js +1 -1
  43. package/lib/common/change-set.js.map +1 -1
  44. package/lib/common/chat-agent-service.d.ts +1 -0
  45. package/lib/common/chat-agent-service.d.ts.map +1 -1
  46. package/lib/common/chat-agent-service.js +2 -1
  47. package/lib/common/chat-agent-service.js.map +1 -1
  48. package/lib/common/chat-agents.d.ts +2 -2
  49. package/lib/common/chat-agents.d.ts.map +1 -1
  50. package/lib/common/chat-agents.js +21 -5
  51. package/lib/common/chat-agents.js.map +1 -1
  52. package/lib/common/chat-model.d.ts +7 -7
  53. package/lib/common/chat-model.d.ts.map +1 -1
  54. package/lib/common/chat-model.js +1 -1
  55. package/lib/common/chat-model.js.map +1 -1
  56. package/lib/common/chat-request-parser.d.ts.map +1 -1
  57. package/lib/common/chat-request-parser.js +3 -6
  58. package/lib/common/chat-request-parser.js.map +1 -1
  59. package/lib/common/chat-service.d.ts +14 -2
  60. package/lib/common/chat-service.d.ts.map +1 -1
  61. package/lib/common/chat-service.js +36 -10
  62. package/lib/common/chat-service.js.map +1 -1
  63. package/lib/common/chat-session-naming-service.js +2 -2
  64. package/lib/common/chat-session-naming-service.js.map +1 -1
  65. package/lib/common/chat-session-summary-agent-prompt.js +3 -3
  66. package/lib/common/chat-session-summary-agent-prompt.js.map +1 -1
  67. package/lib/common/chat-tool-request-service.d.ts +2 -2
  68. package/lib/common/chat-tool-request-service.d.ts.map +1 -1
  69. package/lib/common/image-context-variable.d.ts +29 -0
  70. package/lib/common/image-context-variable.d.ts.map +1 -0
  71. package/lib/common/image-context-variable.js +99 -0
  72. package/lib/common/image-context-variable.js.map +1 -0
  73. package/package.json +11 -10
  74. package/src/browser/agent-delegation-tool.ts +207 -0
  75. package/src/browser/ai-chat-frontend-module.ts +20 -2
  76. package/src/browser/change-set-file-element.ts +236 -32
  77. package/src/browser/chat-tool-preferences.ts +4 -4
  78. package/src/browser/chat-tool-request-service.ts +1 -1
  79. package/src/browser/delegation-response-content.ts +55 -0
  80. package/src/browser/file-chat-variable-contribution.ts +120 -6
  81. package/src/browser/frontend-chat-service.ts +2 -11
  82. package/src/browser/image-context-variable-contribution.ts +153 -0
  83. package/src/browser/task-context-service.ts +115 -9
  84. package/src/browser/task-context-storage-service.ts +5 -1
  85. package/src/common/change-set.ts +1 -1
  86. package/src/common/chat-agent-service.ts +1 -0
  87. package/src/common/chat-agents.ts +26 -9
  88. package/src/common/chat-model.ts +16 -7
  89. package/src/common/chat-request-parser.ts +3 -12
  90. package/src/common/chat-service.ts +40 -10
  91. package/src/common/chat-session-naming-service.ts +2 -2
  92. package/src/common/chat-session-summary-agent-prompt.ts +3 -3
  93. package/src/common/chat-tool-request-service.ts +2 -2
  94. package/src/common/image-context-variable.ts +116 -0
@@ -1 +1 @@
1
- {"version":3,"file":"chat-session-naming-service.js","sourceRoot":"","sources":["../../src/common/chat-session-naming-service.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;;AAEhF,4CAUwB;AACxB,4DAAkE;AAElE,sCAA2C;AAE3C,MAAM,0BAA0B,GAAqB;IACjD,EAAE,EAAE,4BAA4B;IAChC,cA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,wDAAsB;AACxB,yBAAE,GAAG,qBAAqB,AAAxB,CAAyB;AAiBf;IADlB,IAAA,kBAAM,EAAC,+BAAqB,CAAC;;0DACuB;AAGlC;IADlB,IAAA,kBAAM,EAAC,8BAAoB,CAAC;;oEACiC;AAGpD;IADT,IAAA,kBAAM,EAAC,uBAAa,CAAC;;6DACiB;iCAxB9B,sBAAsB;IADlC,IAAA,sBAAU,GAAE;GACA,sBAAsB,CAgElC"}
@@ -12,9 +12,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.CHAT_SESSION_SUMMARY_PROMPT = void 0;
13
13
  const context_variables_1 = require("./context-variables");
14
14
  exports.CHAT_SESSION_SUMMARY_PROMPT = {
15
- id: 'chat-session-summary-system-prompt',
15
+ id: 'chat-session-summary-system',
16
16
  defaultVariant: {
17
- id: 'chat-session-summary-prompt',
17
+ id: 'chat-session-summary-system-default',
18
18
  template: '{{!-- !-- This prompt is licensed under the MIT License (https://opensource.org/license/mit).\n' +
19
19
  'Made improvements or adaptations to this prompt template? We\'d love for you to share it with the community! Contribute back here: ' +
20
20
  'https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}\n\n' +
@@ -24,7 +24,7 @@ exports.CHAT_SESSION_SUMMARY_PROMPT = {
24
24
  'Ensure that the summary is sufficiently comprehensive to allow seamless continuation of the workflow. ' +
25
25
  'The summary will primarily be used by other AI agents, so tailor your response for use by AI agents. ' +
26
26
  'Also consider the system message. ' +
27
- 'Make sure you include all necessary context information and use unique references(such as URIs, file paths, etc.). ' +
27
+ 'Make sure you include all necessary context information and use unique references (such as URIs, file paths, etc.). ' +
28
28
  'If the conversation was about a task, describe the state of the task, i.e.what has been completed and what is open. ' +
29
29
  'If a changeset is open in the session, describe the state of the suggested changes. ' +
30
30
  `\n\n{{${context_variables_1.CHANGE_SET_SUMMARY_VARIABLE_ID}}}`,
@@ -1 +1 @@
1
- {"version":3,"file":"chat-session-summary-agent-prompt.js","sourceRoot":"","sources":["../../src/common/chat-session-summary-agent-prompt.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,+CAA+C;AAC/C,mEAAmE;AACnE,sCAAsC;AACtC,EAAE;AACF,+BAA+B;;;AAE/B,2DAAqE;AAExD,QAAA,2BAA2B,GAAG;IACvC,EAAE,EAAE,oCAAoC;IACxC,cAAc,EAAE;QACZ,EAAE,EAAE,6BAA6B;QACjC,QAAQ,EAAE,iGAAiG;YACvG,sIAAsI;YACtI,uGAAuG;YACvG,6EAA6E;YAC7E,mGAAmG;YACnG,4DAA4D;YAC5D,wGAAwG;YACxG,uGAAuG;YACvG,oCAAoC;YACpC,qHAAqH;YACrH,sHAAsH;YACtH,sFAAsF;YACtF,SAAS,kDAA8B,IAAI;KAClD;CACJ,CAAC"}
1
+ {"version":3,"file":"chat-session-summary-agent-prompt.js","sourceRoot":"","sources":["../../src/common/chat-session-summary-agent-prompt.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,+CAA+C;AAC/C,mEAAmE;AACnE,sCAAsC;AACtC,EAAE;AACF,+BAA+B;;;AAE/B,2DAAqE;AAExD,QAAA,2BAA2B,GAAG;IACvC,EAAE,EAAE,6BAA6B;IACjC,cAAc,EAAE;QACZ,EAAE,EAAE,qCAAqC;QACzC,QAAQ,EAAE,iGAAiG;YACvG,sIAAsI;YACtI,uGAAuG;YACvG,6EAA6E;YAC7E,mGAAmG;YACnG,4DAA4D;YAC5D,wGAAwG;YACxG,uGAAuG;YACvG,oCAAoC;YACpC,sHAAsH;YACtH,sHAAsH;YACtH,sFAAsF;YACtF,SAAS,kDAA8B,IAAI;KAClD;CACJ,CAAC"}
@@ -1,8 +1,8 @@
1
1
  import { ToolRequest } from '@theia/ai-core';
2
2
  import { MutableChatRequestModel } from './chat-model';
3
3
  export interface ChatToolRequest extends ToolRequest {
4
- handler(arg_string: string, context: MutableChatRequestModel): Promise<unknown>;
5
- handler(arg_string: string, ctx?: unknown): Promise<unknown>;
4
+ handler(arg_string: string, context: MutableChatRequestModel): ReturnType<ToolRequest['handler']>;
5
+ handler(arg_string: string, ctx?: unknown): ReturnType<ToolRequest['handler']>;
6
6
  }
7
7
  /**
8
8
  * Wraps tool requests in a chat context.
@@ -1 +1 @@
1
- {"version":3,"file":"chat-tool-request-service.d.ts","sourceRoot":"","sources":["../../src/common/chat-tool-request-service.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD,MAAM,WAAW,eAAgB,SAAQ,WAAW;IAChD,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAChF,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAChE;AAED;;;;;GAKG;AACH,qBACa,sBAAsB;IAE/B,mBAAmB,CAAC,OAAO,EAAE,uBAAuB,GAAG,eAAe,EAAE;IAQxE,kBAAkB,CAAC,YAAY,EAAE,WAAW,EAAE,GAAG,SAAS,EAAE,OAAO,EAAE,uBAAuB,GAAG,eAAe,EAAE;IAOhH,SAAS,CAAC,iBAAiB,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,uBAAuB,GAAG,eAAe;CAO3G"}
1
+ {"version":3,"file":"chat-tool-request-service.d.ts","sourceRoot":"","sources":["../../src/common/chat-tool-request-service.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD,MAAM,WAAW,eAAgB,SAAQ,WAAW;IAChD,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,GAAG,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;IAClG,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;CAClF;AAED;;;;;GAKG;AACH,qBACa,sBAAsB;IAE/B,mBAAmB,CAAC,OAAO,EAAE,uBAAuB,GAAG,eAAe,EAAE;IAQxE,kBAAkB,CAAC,YAAY,EAAE,WAAW,EAAE,GAAG,SAAS,EAAE,OAAO,EAAE,uBAAuB,GAAG,eAAe,EAAE;IAOhH,SAAS,CAAC,iBAAiB,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,uBAAuB,GAAG,eAAe;CAO3G"}
@@ -0,0 +1,29 @@
1
+ import { AIVariable, AIVariableResolutionRequest, ResolvedAIContextVariable } from '@theia/ai-core';
2
+ export declare const IMAGE_CONTEXT_VARIABLE: AIVariable;
3
+ export interface ImageContextVariable {
4
+ name?: string;
5
+ wsRelativePath?: string;
6
+ data: string;
7
+ mimeType: string;
8
+ }
9
+ export interface ImageContextVariableRequest extends AIVariableResolutionRequest {
10
+ variable: typeof IMAGE_CONTEXT_VARIABLE;
11
+ arg: string;
12
+ }
13
+ export declare namespace ImageContextVariable {
14
+ const name = "name";
15
+ const wsRelativePath = "wsRelativePath";
16
+ const data = "data";
17
+ const mimeType = "mimeType";
18
+ function isImageContextRequest(request: object): request is ImageContextVariableRequest;
19
+ function isResolvedImageContext(resolved: object): resolved is ResolvedAIContextVariable & {
20
+ arg: string;
21
+ };
22
+ function parseRequest(request: AIVariableResolutionRequest): undefined | ImageContextVariable;
23
+ function resolve(request: ImageContextVariableRequest): ResolvedAIContextVariable;
24
+ function parseResolved(resolved: ResolvedAIContextVariable): undefined | ImageContextVariable;
25
+ function createRequest(content: ImageContextVariable): ImageContextVariableRequest;
26
+ function createArgString(args: ImageContextVariable): string;
27
+ function parseArg(argString: string): ImageContextVariable;
28
+ }
29
+ //# sourceMappingURL=image-context-variable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-context-variable.d.ts","sourceRoot":"","sources":["../../src/common/image-context-variable.ts"],"names":[],"mappings":"AAgBA,OAAO,EACH,UAAU,EACV,2BAA2B,EAC3B,yBAAyB,EAC5B,MAAM,gBAAgB,CAAC;AAExB,eAAO,MAAM,sBAAsB,EAAE,UAapC,CAAC;AAEF,MAAM,WAAW,oBAAoB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,2BAA4B,SAAQ,2BAA2B;IAC5E,QAAQ,EAAE,OAAO,sBAAsB,CAAC;IACxC,GAAG,EAAE,MAAM,CAAC;CACf;AAED,yBAAiB,oBAAoB,CAAC;IAC3B,MAAM,IAAI,SAAS,CAAC;IACpB,MAAM,cAAc,mBAAmB,CAAC;IACxC,MAAM,IAAI,SAAS,CAAC;IACpB,MAAM,QAAQ,aAAa,CAAC;IAEnC,SAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,IAAI,2BAA2B,CAE7F;IAED,SAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,IAAI,yBAAyB,GAAG;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAEhH;IAED,SAAgB,YAAY,CAAC,OAAO,EAAE,2BAA2B,GAAG,SAAS,GAAG,oBAAoB,CAEnG;IAED,SAAgB,OAAO,CAAC,OAAO,EAAE,2BAA2B,GAAG,yBAAyB,CAOvF;IAED,SAAgB,aAAa,CAAC,QAAQ,EAAE,yBAAyB,GAAG,SAAS,GAAG,oBAAoB,CAEnG;IAED,SAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,2BAA2B,CAKxF;IAED,SAAgB,eAAe,CAAC,IAAI,EAAE,oBAAoB,GAAG,MAAM,CAElE;IAED,SAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,oBAAoB,CAuBhE;CACJ"}
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2025 EclipseSource GmbH and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.ImageContextVariable = exports.IMAGE_CONTEXT_VARIABLE = void 0;
19
+ const ai_core_1 = require("@theia/ai-core");
20
+ exports.IMAGE_CONTEXT_VARIABLE = {
21
+ id: 'imageContext',
22
+ description: 'Provides context information for an image',
23
+ name: 'imageContext',
24
+ label: 'Image File',
25
+ iconClasses: ['codicon', 'codicon-file-media'],
26
+ isContextVariable: true,
27
+ args: [
28
+ { name: 'name', description: 'The name of the image file if available.', isOptional: true },
29
+ { name: 'wsRelativePath', description: 'The workspace-relative path of the image file if available.', isOptional: true },
30
+ { name: 'data', description: 'The image data in base64.' },
31
+ { name: 'mimeType', description: 'The mimetype of the image.' }
32
+ ]
33
+ };
34
+ var ImageContextVariable;
35
+ (function (ImageContextVariable) {
36
+ ImageContextVariable.name = 'name';
37
+ ImageContextVariable.wsRelativePath = 'wsRelativePath';
38
+ ImageContextVariable.data = 'data';
39
+ ImageContextVariable.mimeType = 'mimeType';
40
+ function isImageContextRequest(request) {
41
+ return ai_core_1.AIVariableResolutionRequest.is(request) && request.variable.id === exports.IMAGE_CONTEXT_VARIABLE.id && !!request.arg;
42
+ }
43
+ ImageContextVariable.isImageContextRequest = isImageContextRequest;
44
+ function isResolvedImageContext(resolved) {
45
+ return ai_core_1.ResolvedAIContextVariable.is(resolved) && resolved.variable.id === exports.IMAGE_CONTEXT_VARIABLE.id && !!resolved.arg;
46
+ }
47
+ ImageContextVariable.isResolvedImageContext = isResolvedImageContext;
48
+ function parseRequest(request) {
49
+ return isImageContextRequest(request) ? parseArg(request.arg) : undefined;
50
+ }
51
+ ImageContextVariable.parseRequest = parseRequest;
52
+ function resolve(request) {
53
+ var _a, _b, _c, _d;
54
+ const args = parseArg(request.arg);
55
+ return {
56
+ ...request,
57
+ value: (_b = (_a = args.wsRelativePath) !== null && _a !== void 0 ? _a : args.name) !== null && _b !== void 0 ? _b : 'Image',
58
+ contextValue: (_d = (_c = args.wsRelativePath) !== null && _c !== void 0 ? _c : args.name) !== null && _d !== void 0 ? _d : 'Image'
59
+ };
60
+ }
61
+ ImageContextVariable.resolve = resolve;
62
+ function parseResolved(resolved) {
63
+ return isResolvedImageContext(resolved) ? parseArg(resolved.arg) : undefined;
64
+ }
65
+ ImageContextVariable.parseResolved = parseResolved;
66
+ function createRequest(content) {
67
+ return {
68
+ variable: exports.IMAGE_CONTEXT_VARIABLE,
69
+ arg: createArgString(content)
70
+ };
71
+ }
72
+ ImageContextVariable.createRequest = createRequest;
73
+ function createArgString(args) {
74
+ return JSON.stringify(args);
75
+ }
76
+ ImageContextVariable.createArgString = createArgString;
77
+ function parseArg(argString) {
78
+ const result = {};
79
+ if (!argString) {
80
+ throw new Error('Invalid argument string: empty string');
81
+ }
82
+ try {
83
+ const parsed = JSON.parse(argString);
84
+ Object.assign(result, parsed);
85
+ }
86
+ catch (error) {
87
+ throw new Error(`Failed to parse JSON argument string: ${error.message}`);
88
+ }
89
+ if (!result.data) {
90
+ throw new Error(`Missing required argument: ${ImageContextVariable.data}`);
91
+ }
92
+ if (!result.mimeType) {
93
+ throw new Error(`Missing required argument: ${ImageContextVariable.mimeType}`);
94
+ }
95
+ return result;
96
+ }
97
+ ImageContextVariable.parseArg = parseArg;
98
+ })(ImageContextVariable || (exports.ImageContextVariable = ImageContextVariable = {}));
99
+ //# sourceMappingURL=image-context-variable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-context-variable.js","sourceRoot":"","sources":["../../src/common/image-context-variable.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAEhF,4CAIwB;AAEX,QAAA,sBAAsB,GAAe;IAC9C,EAAE,EAAE,cAAc;IAClB,WAAW,EAAE,2CAA2C;IACxD,IAAI,EAAE,cAAc;IACpB,KAAK,EAAE,YAAY;IACnB,WAAW,EAAE,CAAC,SAAS,EAAE,oBAAoB,CAAC;IAC9C,iBAAiB,EAAE,IAAI;IACvB,IAAI,EAAE;QACF,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,0CAA0C,EAAE,UAAU,EAAE,IAAI,EAAE;QAC3F,EAAE,IAAI,EAAE,gBAAgB,EAAE,WAAW,EAAE,6DAA6D,EAAE,UAAU,EAAE,IAAI,EAAE;QACxH,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,2BAA2B,EAAE;QAC1D,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,4BAA4B,EAAE;KAClE;CACJ,CAAC;AAcF,IAAiB,oBAAoB,CAkEpC;AAlED,WAAiB,oBAAoB;IACpB,yBAAI,GAAG,MAAM,CAAC;IACd,mCAAc,GAAG,gBAAgB,CAAC;IAClC,yBAAI,GAAG,MAAM,CAAC;IACd,6BAAQ,GAAG,UAAU,CAAC;IAEnC,SAAgB,qBAAqB,CAAC,OAAe;Q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EAAE,8BAAsB;YAChC,GAAG,EAAE,eAAe,CAAC,OAAO,CAAC;SAChC,CAAC;IACN,CAAC;IALe,kCAAa,gBAK5B,CAAA;IAED,SAAgB,eAAe,CAAC,IAA0B;QACtD,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAFe,oCAAe,kBAE9B,CAAA;IAED,SAAgB,QAAQ,CAAC,SAAiB;QACtC,MAAM,MAAM,GAAkC,EAAE,CAAC;QAEjD,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC7D,CAAC;QAED,IAAI,CAAC;YACD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAkC,CAAC;YACtE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,yCAAyC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC9E,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,8BAA8B,qBAAA,IAAI,EAAE,CAAC,CAAC;QAC1D,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,8BAA8B,qBAAA,QAAQ,EAAE,CAAC,CAAC;QAC9D,CAAC;QAED,OAAO,MAA8B,CAAC;IAC1C,CAAC;IAvBe,6BAAQ,WAuBvB,CAAA;AACL,CAAC,EAlEgB,oBAAoB,oCAApB,oBAAoB,QAkEpC"}
package/package.json CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "@theia/ai-chat",
3
- "version": "1.63.0-next.24+83b50cc66",
3
+ "version": "1.63.0",
4
4
  "description": "Theia - AI Chat Extension",
5
5
  "dependencies": {
6
- "@theia/ai-core": "1.63.0-next.24+83b50cc66",
7
- "@theia/core": "1.63.0-next.24+83b50cc66",
8
- "@theia/editor": "1.63.0-next.24+83b50cc66",
9
- "@theia/file-search": "1.63.0-next.24+83b50cc66",
10
- "@theia/filesystem": "1.63.0-next.24+83b50cc66",
11
- "@theia/monaco": "1.63.0-next.24+83b50cc66",
6
+ "@theia/ai-core": "1.63.0",
7
+ "@theia/core": "1.63.0",
8
+ "@theia/editor": "1.63.0",
9
+ "@theia/file-search": "1.63.0",
10
+ "@theia/filesystem": "1.63.0",
11
+ "@theia/monaco": "1.63.0",
12
12
  "@theia/monaco-editor-core": "1.96.302",
13
- "@theia/workspace": "1.63.0-next.24+83b50cc66",
13
+ "@theia/workspace": "1.63.0",
14
+ "js-yaml": "^4.1.0",
14
15
  "minimatch": "^5.1.0",
15
16
  "tslib": "^2.6.2"
16
17
  },
@@ -48,10 +49,10 @@
48
49
  "watch": "theiaext watch"
49
50
  },
50
51
  "devDependencies": {
51
- "@theia/ext-scripts": "1.62.0"
52
+ "@theia/ext-scripts": "1.63.0"
52
53
  },
53
54
  "nyc": {
54
55
  "extends": "../../configs/nyc.json"
55
56
  },
56
- "gitHead": "83b50cc66b001a5b9100ccd944dcace04cd4ae2e"
57
+ "gitHead": "facf442522991134333495a0b90cf56a56990280"
57
58
  }
@@ -0,0 +1,207 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2025 EclipseSource GmbH.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { ToolProvider, ToolRequest } from '@theia/ai-core';
18
+ import { inject, injectable } from '@theia/core/shared/inversify';
19
+ import {
20
+ ChatAgentService,
21
+ ChatAgentServiceFactory,
22
+ ChatRequest,
23
+ ChatService,
24
+ ChatServiceFactory,
25
+ MutableChatRequestModel,
26
+ MutableChatModel,
27
+ ChatSession,
28
+ } from '../common';
29
+ import { DelegationResponseContent } from './delegation-response-content';
30
+
31
+ export const AGENT_DELEGATION_FUNCTION_ID = 'delegateToAgent';
32
+
33
+ @injectable()
34
+ export class AgentDelegationTool implements ToolProvider {
35
+ static ID = AGENT_DELEGATION_FUNCTION_ID;
36
+
37
+ @inject(ChatAgentServiceFactory)
38
+ protected readonly getChatAgentService: () => ChatAgentService;
39
+
40
+ @inject(ChatServiceFactory)
41
+ protected readonly getChatService: () => ChatService;
42
+
43
+ getTool(): ToolRequest {
44
+ return {
45
+ id: AgentDelegationTool.ID,
46
+ name: AgentDelegationTool.ID,
47
+ description:
48
+ 'Delegate a task or question to a specific AI agent. This tool allows you to submit requests to specialized agents based on their capabilities.',
49
+ parameters: {
50
+ type: 'object',
51
+ properties: {
52
+ agentId: {
53
+ type: 'string',
54
+ description:
55
+ 'The ID of the AI agent to delegate the task to.',
56
+ },
57
+ prompt: {
58
+ type: 'string',
59
+ description:
60
+ 'The task, question, or prompt to pass to the specified agent.',
61
+ },
62
+ },
63
+ required: ['agentId', 'prompt'],
64
+ },
65
+ handler: (arg_string: string, ctx: MutableChatRequestModel) =>
66
+ this.delegateToAgent(arg_string, ctx),
67
+ };
68
+ }
69
+
70
+ private async delegateToAgent(
71
+ arg_string: string,
72
+ ctx: MutableChatRequestModel
73
+ ): Promise<string> {
74
+ try {
75
+ const args = JSON.parse(arg_string);
76
+ const { agentId, prompt } = args;
77
+
78
+ if (!agentId || !prompt) {
79
+ const errorMsg = 'Both agentId and prompt parameters are required.';
80
+ console.error(errorMsg, { agentId, prompt });
81
+ return errorMsg;
82
+ }
83
+
84
+ // Check if the specified agent exists
85
+ const agent = this.getChatAgentService().getAgent(agentId);
86
+ if (!agent) {
87
+ const availableAgents = this.getChatAgentService()
88
+ .getAgents()
89
+ .map(a => a.id);
90
+ const errorMsg = `Agent '${agentId}' not found or not enabled. Available agents: ${availableAgents.join(', ')}`;
91
+ console.error(errorMsg);
92
+ return errorMsg;
93
+ }
94
+
95
+ let newSession;
96
+ try {
97
+ // FIXME: this creates a new conversation visible in the UI (Panel), which we don't want
98
+ // It is not possible to start a session without specifying a location (default=Panel)
99
+ const chatService = this.getChatService();
100
+
101
+ // Store the current active session to restore it after delegation
102
+ const currentActiveSession = chatService.getActiveSession();
103
+
104
+ newSession = chatService.createSession(
105
+ undefined,
106
+ { focus: false },
107
+ agent
108
+ );
109
+
110
+ // Immediately restore the original active session to avoid confusing the user
111
+ if (currentActiveSession) {
112
+ chatService.setActiveSession(currentActiveSession.id, { focus: false });
113
+ }
114
+
115
+ // Setup ChangeSet bubbling from delegated session to parent session
116
+ this.setupChangeSetBubbling(newSession, ctx.session, agent.name);
117
+ } catch (sessionError) {
118
+ const errorMsg = `Failed to create chat session for agent '${agentId}': ${sessionError instanceof Error ? sessionError.message : sessionError}`;
119
+ console.error(errorMsg, sessionError);
120
+ return errorMsg;
121
+ }
122
+
123
+ // Send the request
124
+ const chatRequest: ChatRequest = {
125
+ text: prompt,
126
+ };
127
+
128
+ let response;
129
+ try {
130
+ const chatService = this.getChatService();
131
+ response = await chatService.sendRequest(
132
+ newSession.id,
133
+ chatRequest
134
+ );
135
+ } catch (sendError) {
136
+ const errorMsg = `Failed to send request to agent '${agentId}': ${sendError instanceof Error ? sendError.message : sendError}`;
137
+ console.error(errorMsg, sendError);
138
+ return errorMsg;
139
+ }
140
+
141
+ if (response) {
142
+ // Add the response content immediately to enable streaming
143
+ // The renderer will handle the streaming updates
144
+ ctx.response.response.addContent(
145
+ new DelegationResponseContent(agent.name, prompt, response)
146
+ );
147
+
148
+ try {
149
+ // Wait for completion to return the final result as tool output
150
+ const result = await response.responseCompleted;
151
+ const stringResult = result.response.asString();
152
+ // Return the raw text to the top-level Agent, as a tool result
153
+ return stringResult;
154
+ } catch (completionError) {
155
+ const errorMsg = `Failed to complete response from agent '${agentId}': ${completionError instanceof Error ? completionError.message : completionError}`;
156
+ console.error(errorMsg, completionError);
157
+ return errorMsg;
158
+ }
159
+ } else {
160
+ const errorMsg = `Delegation to agent '${agentId}' has failed: no response returned.`;
161
+ console.error(errorMsg);
162
+ return errorMsg;
163
+ }
164
+ } catch (error) {
165
+ console.error('Failed to delegate to agent', error);
166
+ return JSON.stringify({
167
+ error: `Failed to parse arguments or delegate to agent: ${error instanceof Error ? error.message : 'Unknown error'}`,
168
+ });
169
+ }
170
+ }
171
+
172
+ /**
173
+ * Sets up monitoring of the ChangeSet in the delegated session and bubbles changes to the parent session.
174
+ * @param delegatedSession The session created for the delegated agent
175
+ * @param parentModel The parent session model that should receive the bubbled changes
176
+ * @param agentName The name of the agent for attribution purposes
177
+ */
178
+ private setupChangeSetBubbling(
179
+ delegatedSession: ChatSession,
180
+ parentModel: MutableChatModel,
181
+ agentName: string
182
+ ): void {
183
+ // Monitor ChangeSet for bubbling
184
+ delegatedSession.model.changeSet.onDidChange(_event => {
185
+ this.bubbleChangeSet(delegatedSession, parentModel, agentName);
186
+ });
187
+ }
188
+
189
+ /**
190
+ * Bubbles the ChangeSet from the delegated session to the parent session.
191
+ * @param delegatedSession The session from which to bubble changes
192
+ * @param parentModel The parent session model to receive the bubbled changes
193
+ * @param agentName The name of the agent for attribution purposes
194
+ */
195
+ private bubbleChangeSet(
196
+ delegatedSession: ChatSession,
197
+ parentModel: MutableChatModel,
198
+ agentName: string
199
+ ): void {
200
+ const delegatedElements = delegatedSession.model.changeSet.getElements();
201
+ if (delegatedElements.length > 0) {
202
+ const bubbledTitle = `Changes from ${agentName}`;
203
+ parentModel.changeSet.setTitle(bubbledTitle);
204
+ parentModel.changeSet.addElements(...delegatedElements);
205
+ }
206
+ }
207
+ }
@@ -14,7 +14,7 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
- import { Agent, AgentService, AIVariableContribution } from '@theia/ai-core/lib/common';
17
+ import { Agent, AgentService, AIVariableContribution, bindToolProvider } from '@theia/ai-core/lib/common';
18
18
  import { bindContributionProvider, CommandContribution } from '@theia/core';
19
19
  import { FrontendApplicationContribution, LabelProviderContribution, PreferenceContribution } from '@theia/core/lib/browser';
20
20
  import { ContainerModule } from '@theia/core/shared/inversify';
@@ -26,7 +26,9 @@ import {
26
26
  ChatRequestParserImpl,
27
27
  ChatService,
28
28
  ToolCallChatResponseContentFactory,
29
- PinChatAgent
29
+ PinChatAgent,
30
+ ChatServiceFactory,
31
+ ChatAgentServiceFactory
30
32
  } from '../common';
31
33
  import { ChatAgentsVariableContribution } from '../common/chat-agents-variable-contribution';
32
34
  import { CustomChatAgent } from '../common/custom-chat-agent';
@@ -54,6 +56,8 @@ import { TaskContextVariableLabelProvider } from './task-context-variable-label-
54
56
  import { TaskContextService, TaskContextStorageService } from './task-context-service';
55
57
  import { InMemoryTaskContextStorage } from './task-context-storage-service';
56
58
  import { AIChatFrontendContribution } from './ai-chat-frontend-contribution';
59
+ import { ImageContextVariableContribution } from './image-context-variable-contribution';
60
+ import { AgentDelegationTool } from './agent-delegation-tool';
57
61
 
58
62
  export default new ContainerModule(bind => {
59
63
  bindContributionProvider(bind, Agent);
@@ -83,6 +87,13 @@ export default new ContainerModule(bind => {
83
87
  bind(FrontendChatServiceImpl).toSelf().inSingletonScope();
84
88
  bind(ChatService).toService(FrontendChatServiceImpl);
85
89
 
90
+ bind(ChatServiceFactory).toDynamicValue(ctx => () =>
91
+ ctx.container.get<ChatService>(ChatService)
92
+ );
93
+ bind(ChatAgentServiceFactory).toDynamicValue(ctx => () =>
94
+ ctx.container.get<ChatAgentService>(ChatAgentService)
95
+ );
96
+
86
97
  bind(PreferenceContribution).toConstantValue({ schema: aiChatPreferences });
87
98
 
88
99
  // Tool confirmation preferences
@@ -131,14 +142,21 @@ export default new ContainerModule(bind => {
131
142
 
132
143
  bind(ChatSessionSummaryAgent).toSelf().inSingletonScope();
133
144
  bind(Agent).toService(ChatSessionSummaryAgent);
145
+
134
146
  bind(TaskContextVariableContribution).toSelf().inSingletonScope();
135
147
  bind(AIVariableContribution).toService(TaskContextVariableContribution);
136
148
  bind(TaskContextVariableLabelProvider).toSelf().inSingletonScope();
137
149
  bind(LabelProviderContribution).toService(TaskContextVariableLabelProvider);
138
150
 
151
+ bind(ImageContextVariableContribution).toSelf().inSingletonScope();
152
+ bind(AIVariableContribution).toService(ImageContextVariableContribution);
153
+ bind(LabelProviderContribution).toService(ImageContextVariableContribution);
154
+
139
155
  bind(TaskContextService).toSelf().inSingletonScope();
140
156
  bind(InMemoryTaskContextStorage).toSelf().inSingletonScope();
141
157
  bind(TaskContextStorageService).toService(InMemoryTaskContextStorage);
142
158
  bind(AIChatFrontendContribution).toSelf().inSingletonScope();
143
159
  bind(CommandContribution).toService(AIChatFrontendContribution);
160
+
161
+ bindToolProvider(AgentDelegationTool, bind);
144
162
  });