@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.
- package/lib/browser/agent-delegation-tool.d.ts +25 -0
- package/lib/browser/agent-delegation-tool.d.ts.map +1 -0
- package/lib/browser/agent-delegation-tool.js +171 -0
- package/lib/browser/agent-delegation-tool.js.map +1 -0
- package/lib/browser/ai-chat-frontend-module.d.ts.map +1 -1
- package/lib/browser/ai-chat-frontend-module.js +8 -0
- package/lib/browser/ai-chat-frontend-module.js.map +1 -1
- package/lib/browser/change-set-file-element.d.ts +47 -8
- package/lib/browser/change-set-file-element.d.ts.map +1 -1
- package/lib/browser/change-set-file-element.js +207 -31
- package/lib/browser/change-set-file-element.js.map +1 -1
- package/lib/browser/chat-tool-preferences.d.ts +1 -1
- package/lib/browser/chat-tool-preferences.d.ts.map +1 -1
- package/lib/browser/chat-tool-preferences.js +4 -4
- package/lib/browser/chat-tool-preferences.js.map +1 -1
- package/lib/browser/chat-tool-request-service.js +1 -1
- package/lib/browser/chat-tool-request-service.js.map +1 -1
- package/lib/browser/delegation-response-content.d.ts +20 -0
- package/lib/browser/delegation-response-content.d.ts.map +1 -0
- package/lib/browser/delegation-response-content.js +51 -0
- package/lib/browser/delegation-response-content.js.map +1 -0
- package/lib/browser/file-chat-variable-contribution.d.ts +15 -1
- package/lib/browser/file-chat-variable-contribution.d.ts.map +1 -1
- package/lib/browser/file-chat-variable-contribution.js +111 -5
- package/lib/browser/file-chat-variable-contribution.js.map +1 -1
- package/lib/browser/frontend-chat-service.d.ts +1 -1
- package/lib/browser/frontend-chat-service.d.ts.map +1 -1
- package/lib/browser/frontend-chat-service.js +2 -13
- package/lib/browser/frontend-chat-service.js.map +1 -1
- package/lib/browser/image-context-variable-contribution.d.ts +27 -0
- package/lib/browser/image-context-variable-contribution.d.ts.map +1 -0
- package/lib/browser/image-context-variable-contribution.js +149 -0
- package/lib/browser/image-context-variable-contribution.js.map +1 -0
- package/lib/browser/task-context-service.d.ts +9 -3
- package/lib/browser/task-context-service.d.ts.map +1 -1
- package/lib/browser/task-context-service.js +111 -9
- package/lib/browser/task-context-service.js.map +1 -1
- package/lib/browser/task-context-storage-service.d.ts +1 -0
- package/lib/browser/task-context-storage-service.d.ts.map +1 -1
- package/lib/browser/task-context-storage-service.js +4 -1
- package/lib/browser/task-context-storage-service.js.map +1 -1
- package/lib/common/change-set.js +1 -1
- package/lib/common/change-set.js.map +1 -1
- package/lib/common/chat-agent-service.d.ts +1 -0
- package/lib/common/chat-agent-service.d.ts.map +1 -1
- package/lib/common/chat-agent-service.js +2 -1
- package/lib/common/chat-agent-service.js.map +1 -1
- package/lib/common/chat-agents.d.ts +2 -2
- package/lib/common/chat-agents.d.ts.map +1 -1
- package/lib/common/chat-agents.js +21 -5
- package/lib/common/chat-agents.js.map +1 -1
- package/lib/common/chat-model.d.ts +7 -7
- package/lib/common/chat-model.d.ts.map +1 -1
- package/lib/common/chat-model.js +1 -1
- package/lib/common/chat-model.js.map +1 -1
- package/lib/common/chat-request-parser.d.ts.map +1 -1
- package/lib/common/chat-request-parser.js +3 -6
- package/lib/common/chat-request-parser.js.map +1 -1
- package/lib/common/chat-service.d.ts +14 -2
- package/lib/common/chat-service.d.ts.map +1 -1
- package/lib/common/chat-service.js +36 -10
- package/lib/common/chat-service.js.map +1 -1
- package/lib/common/chat-session-naming-service.js +2 -2
- package/lib/common/chat-session-naming-service.js.map +1 -1
- package/lib/common/chat-session-summary-agent-prompt.js +3 -3
- package/lib/common/chat-session-summary-agent-prompt.js.map +1 -1
- package/lib/common/chat-tool-request-service.d.ts +2 -2
- package/lib/common/chat-tool-request-service.d.ts.map +1 -1
- package/lib/common/image-context-variable.d.ts +29 -0
- package/lib/common/image-context-variable.d.ts.map +1 -0
- package/lib/common/image-context-variable.js +99 -0
- package/lib/common/image-context-variable.js.map +1 -0
- package/package.json +11 -10
- package/src/browser/agent-delegation-tool.ts +207 -0
- package/src/browser/ai-chat-frontend-module.ts +20 -2
- package/src/browser/change-set-file-element.ts +236 -32
- package/src/browser/chat-tool-preferences.ts +4 -4
- package/src/browser/chat-tool-request-service.ts +1 -1
- package/src/browser/delegation-response-content.ts +55 -0
- package/src/browser/file-chat-variable-contribution.ts +120 -6
- package/src/browser/frontend-chat-service.ts +2 -11
- package/src/browser/image-context-variable-contribution.ts +153 -0
- package/src/browser/task-context-service.ts +115 -9
- package/src/browser/task-context-storage-service.ts +5 -1
- package/src/common/change-set.ts +1 -1
- package/src/common/chat-agent-service.ts +1 -0
- package/src/common/chat-agents.ts +26 -9
- package/src/common/chat-model.ts +16 -7
- package/src/common/chat-request-parser.ts +3 -12
- package/src/common/chat-service.ts +40 -10
- package/src/common/chat-session-naming-service.ts +2 -2
- package/src/common/chat-session-summary-agent-prompt.ts +3 -3
- package/src/common/chat-tool-request-service.ts +2 -2
- package/src/common/image-context-variable.ts +116 -0
|
@@ -19,8 +19,8 @@ import { injectable } from '@theia/core/shared/inversify';
|
|
|
19
19
|
import { MutableChatRequestModel } from './chat-model';
|
|
20
20
|
|
|
21
21
|
export interface ChatToolRequest extends ToolRequest {
|
|
22
|
-
handler(arg_string: string, context: MutableChatRequestModel):
|
|
23
|
-
handler(arg_string: string, ctx?: unknown):
|
|
22
|
+
handler(arg_string: string, context: MutableChatRequestModel): ReturnType<ToolRequest['handler']>;
|
|
23
|
+
handler(arg_string: string, ctx?: unknown): ReturnType<ToolRequest['handler']>;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2025 EclipseSource GmbH and others.
|
|
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 {
|
|
18
|
+
AIVariable,
|
|
19
|
+
AIVariableResolutionRequest,
|
|
20
|
+
ResolvedAIContextVariable
|
|
21
|
+
} from '@theia/ai-core';
|
|
22
|
+
|
|
23
|
+
export const IMAGE_CONTEXT_VARIABLE: AIVariable = {
|
|
24
|
+
id: 'imageContext',
|
|
25
|
+
description: 'Provides context information for an image',
|
|
26
|
+
name: 'imageContext',
|
|
27
|
+
label: 'Image File',
|
|
28
|
+
iconClasses: ['codicon', 'codicon-file-media'],
|
|
29
|
+
isContextVariable: true,
|
|
30
|
+
args: [
|
|
31
|
+
{ name: 'name', description: 'The name of the image file if available.', isOptional: true },
|
|
32
|
+
{ name: 'wsRelativePath', description: 'The workspace-relative path of the image file if available.', isOptional: true },
|
|
33
|
+
{ name: 'data', description: 'The image data in base64.' },
|
|
34
|
+
{ name: 'mimeType', description: 'The mimetype of the image.' }
|
|
35
|
+
]
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export interface ImageContextVariable {
|
|
39
|
+
name?: string;
|
|
40
|
+
wsRelativePath?: string;
|
|
41
|
+
data: string;
|
|
42
|
+
mimeType: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface ImageContextVariableRequest extends AIVariableResolutionRequest {
|
|
46
|
+
variable: typeof IMAGE_CONTEXT_VARIABLE;
|
|
47
|
+
arg: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export namespace ImageContextVariable {
|
|
51
|
+
export const name = 'name';
|
|
52
|
+
export const wsRelativePath = 'wsRelativePath';
|
|
53
|
+
export const data = 'data';
|
|
54
|
+
export const mimeType = 'mimeType';
|
|
55
|
+
|
|
56
|
+
export function isImageContextRequest(request: object): request is ImageContextVariableRequest {
|
|
57
|
+
return AIVariableResolutionRequest.is(request) && request.variable.id === IMAGE_CONTEXT_VARIABLE.id && !!request.arg;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function isResolvedImageContext(resolved: object): resolved is ResolvedAIContextVariable & { arg: string } {
|
|
61
|
+
return ResolvedAIContextVariable.is(resolved) && resolved.variable.id === IMAGE_CONTEXT_VARIABLE.id && !!resolved.arg;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function parseRequest(request: AIVariableResolutionRequest): undefined | ImageContextVariable {
|
|
65
|
+
return isImageContextRequest(request) ? parseArg(request.arg) : undefined;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function resolve(request: ImageContextVariableRequest): ResolvedAIContextVariable {
|
|
69
|
+
const args = parseArg(request.arg);
|
|
70
|
+
return {
|
|
71
|
+
...request,
|
|
72
|
+
value: args.wsRelativePath ?? args.name ?? 'Image',
|
|
73
|
+
contextValue: args.wsRelativePath ?? args.name ?? 'Image'
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function parseResolved(resolved: ResolvedAIContextVariable): undefined | ImageContextVariable {
|
|
78
|
+
return isResolvedImageContext(resolved) ? parseArg(resolved.arg) : undefined;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function createRequest(content: ImageContextVariable): ImageContextVariableRequest {
|
|
82
|
+
return {
|
|
83
|
+
variable: IMAGE_CONTEXT_VARIABLE,
|
|
84
|
+
arg: createArgString(content)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function createArgString(args: ImageContextVariable): string {
|
|
89
|
+
return JSON.stringify(args);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function parseArg(argString: string): ImageContextVariable {
|
|
93
|
+
const result: Partial<ImageContextVariable> = {};
|
|
94
|
+
|
|
95
|
+
if (!argString) {
|
|
96
|
+
throw new Error('Invalid argument string: empty string');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
try {
|
|
100
|
+
const parsed = JSON.parse(argString) as Partial<ImageContextVariable>;
|
|
101
|
+
Object.assign(result, parsed);
|
|
102
|
+
} catch (error) {
|
|
103
|
+
throw new Error(`Failed to parse JSON argument string: ${error.message}`);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (!result.data) {
|
|
107
|
+
throw new Error(`Missing required argument: ${data}`);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (!result.mimeType) {
|
|
111
|
+
throw new Error(`Missing required argument: ${mimeType}`);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return result as ImageContextVariable;
|
|
115
|
+
}
|
|
116
|
+
}
|