@theia/ai-chat 1.60.2 → 1.61.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/ai-chat-frontend-contribution.d.ts +11 -0
- package/lib/browser/ai-chat-frontend-contribution.d.ts.map +1 -0
- package/lib/browser/ai-chat-frontend-contribution.js +56 -0
- package/lib/browser/ai-chat-frontend-contribution.js.map +1 -0
- package/lib/browser/ai-chat-frontend-module.d.ts.map +1 -1
- package/lib/browser/ai-chat-frontend-module.js +21 -3
- package/lib/browser/ai-chat-frontend-module.js.map +1 -1
- package/lib/browser/change-set-decorator-service.d.ts +24 -0
- package/lib/browser/change-set-decorator-service.d.ts.map +1 -0
- package/lib/browser/change-set-decorator-service.js +66 -0
- package/lib/browser/change-set-decorator-service.js.map +1 -0
- package/lib/browser/change-set-file-element.d.ts +7 -4
- package/lib/browser/change-set-file-element.d.ts.map +1 -1
- package/lib/browser/change-set-file-element.js +20 -12
- package/lib/browser/change-set-file-element.js.map +1 -1
- package/lib/browser/change-set-file-resource.d.ts +1 -42
- package/lib/browser/change-set-file-resource.d.ts.map +1 -1
- package/lib/browser/change-set-file-resource.js +1 -136
- package/lib/browser/change-set-file-resource.js.map +1 -1
- package/lib/browser/change-set-variable.d.ts.map +1 -1
- package/lib/browser/change-set-variable.js +13 -4
- package/lib/browser/change-set-variable.js.map +1 -1
- package/lib/browser/context-file-variable-label-provider.js +1 -1
- package/lib/browser/context-file-variable-label-provider.js.map +1 -1
- package/lib/browser/file-chat-variable-contribution.d.ts.map +1 -1
- package/lib/browser/file-chat-variable-contribution.js +29 -27
- package/lib/browser/file-chat-variable-contribution.js.map +1 -1
- package/lib/browser/task-context-service.d.ts +40 -0
- package/lib/browser/task-context-service.d.ts.map +1 -0
- package/lib/browser/task-context-service.js +148 -0
- package/lib/browser/task-context-service.js.map +1 -0
- package/lib/browser/task-context-storage-service.d.ts +18 -0
- package/lib/browser/task-context-storage-service.d.ts.map +1 -0
- package/lib/browser/task-context-storage-service.js +77 -0
- package/lib/browser/task-context-storage-service.js.map +1 -0
- package/lib/browser/task-context-variable-contribution.d.ts +20 -0
- package/lib/browser/task-context-variable-contribution.d.ts.map +1 -0
- package/lib/browser/task-context-variable-contribution.js +101 -0
- package/lib/browser/task-context-variable-contribution.js.map +1 -0
- package/lib/browser/task-context-variable-label-provider.d.ts +21 -0
- package/lib/browser/task-context-variable-label-provider.d.ts.map +1 -0
- package/lib/browser/task-context-variable-label-provider.js +83 -0
- package/lib/browser/task-context-variable-label-provider.js.map +1 -0
- package/lib/browser/task-context-variable.d.ts +3 -0
- package/lib/browser/task-context-variable.d.ts.map +1 -0
- package/lib/browser/task-context-variable.js +29 -0
- package/lib/browser/task-context-variable.js.map +1 -0
- package/lib/common/chat-agents.d.ts +2 -1
- package/lib/common/chat-agents.d.ts.map +1 -1
- package/lib/common/chat-agents.js +32 -20
- package/lib/common/chat-agents.js.map +1 -1
- package/lib/common/chat-model.d.ts +191 -8
- package/lib/common/chat-model.d.ts.map +1 -1
- package/lib/common/chat-model.js +369 -12
- package/lib/common/chat-model.js.map +1 -1
- package/lib/common/chat-request-parser.d.ts +1 -1
- package/lib/common/chat-request-parser.d.ts.map +1 -1
- package/lib/common/chat-request-parser.js +1 -1
- package/lib/common/chat-request-parser.js.map +1 -1
- package/lib/common/chat-service.d.ts +2 -0
- package/lib/common/chat-service.d.ts.map +1 -1
- package/lib/common/chat-service.js +18 -25
- package/lib/common/chat-service.js.map +1 -1
- package/lib/common/chat-session-naming-service.d.ts.map +1 -1
- package/lib/common/chat-session-naming-service.js +9 -11
- package/lib/common/chat-session-naming-service.js.map +1 -1
- package/lib/common/chat-session-summary-agent-prompt.d.ts +5 -0
- package/lib/common/chat-session-summary-agent-prompt.d.ts.map +1 -0
- package/lib/common/chat-session-summary-agent-prompt.js +30 -0
- package/lib/common/chat-session-summary-agent-prompt.js.map +1 -0
- package/lib/common/chat-session-summary-agent.d.ts +17 -0
- package/lib/common/chat-session-summary-agent.d.ts.map +1 -0
- package/lib/common/chat-session-summary-agent.js +48 -0
- package/lib/common/chat-session-summary-agent.js.map +1 -0
- package/lib/common/context-summary-variable.js +1 -1
- package/lib/common/context-summary-variable.js.map +1 -1
- package/lib/common/parse-contents-with-incomplete-parts.spec.d.ts +2 -0
- package/lib/common/parse-contents-with-incomplete-parts.spec.d.ts.map +1 -0
- package/lib/common/parse-contents-with-incomplete-parts.spec.js +103 -0
- package/lib/common/parse-contents-with-incomplete-parts.spec.js.map +1 -0
- package/lib/common/parse-contents.d.ts +1 -0
- package/lib/common/parse-contents.d.ts.map +1 -1
- package/lib/common/parse-contents.js +45 -5
- package/lib/common/parse-contents.js.map +1 -1
- package/lib/common/parse-contents.spec.d.ts +1 -0
- package/lib/common/parse-contents.spec.d.ts.map +1 -1
- package/lib/common/parse-contents.spec.js +25 -13
- package/lib/common/parse-contents.spec.js.map +1 -1
- package/lib/common/response-content-matcher.d.ts +6 -0
- package/lib/common/response-content-matcher.d.ts.map +1 -1
- package/lib/common/response-content-matcher.js +14 -3
- package/lib/common/response-content-matcher.js.map +1 -1
- package/package.json +11 -11
- package/src/browser/ai-chat-frontend-contribution.ts +49 -0
- package/src/browser/ai-chat-frontend-module.ts +25 -4
- package/src/browser/change-set-decorator-service.ts +72 -0
- package/src/browser/change-set-file-element.ts +18 -13
- package/src/browser/change-set-file-resource.ts +1 -138
- package/src/browser/change-set-variable.ts +14 -6
- package/src/browser/context-file-variable-label-provider.ts +1 -1
- package/src/browser/file-chat-variable-contribution.ts +26 -29
- package/src/browser/task-context-service.ts +144 -0
- package/src/browser/task-context-storage-service.ts +75 -0
- package/src/browser/task-context-variable-contribution.ts +93 -0
- package/src/browser/task-context-variable-label-provider.ts +67 -0
- package/src/browser/task-context-variable.ts +28 -0
- package/src/common/chat-agents.ts +38 -22
- package/src/common/chat-model.ts +566 -17
- package/src/common/chat-request-parser.ts +2 -2
- package/src/common/chat-service.ts +17 -26
- package/src/common/chat-session-naming-service.ts +13 -15
- package/src/common/chat-session-summary-agent-prompt.ts +28 -0
- package/src/common/chat-session-summary-agent.ts +42 -0
- package/src/common/context-summary-variable.ts +1 -1
- package/src/common/parse-contents-with-incomplete-parts.spec.ts +114 -0
- package/src/common/parse-contents.spec.ts +24 -12
- package/src/common/parse-contents.ts +52 -6
- package/src/common/response-content-matcher.ts +21 -3
|
@@ -0,0 +1,28 @@
|
|
|
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 { AIVariable } from '@theia/ai-core';
|
|
18
|
+
import { codiconArray } from '@theia/core/lib/browser';
|
|
19
|
+
|
|
20
|
+
export const TASK_CONTEXT_VARIABLE: AIVariable = {
|
|
21
|
+
id: 'taskContext',
|
|
22
|
+
description: 'Provides context information for a task, e.g. the plan for completing a task or a summary of a previous sessions',
|
|
23
|
+
name: 'taskContext',
|
|
24
|
+
label: 'Task Context',
|
|
25
|
+
iconClasses: codiconArray('clippy'),
|
|
26
|
+
isContextVariable: true,
|
|
27
|
+
args: [{ name: 'context-id', description: 'The ID of the task context to retrieve, or a chat session to summarize.' }]
|
|
28
|
+
};
|
|
@@ -22,11 +22,13 @@
|
|
|
22
22
|
import {
|
|
23
23
|
AgentSpecificVariables,
|
|
24
24
|
AIVariableContext,
|
|
25
|
+
AIVariableResolutionRequest,
|
|
25
26
|
CommunicationRecordingService,
|
|
26
27
|
getTextOfResponse,
|
|
27
28
|
isTextResponsePart,
|
|
28
29
|
isThinkingResponsePart,
|
|
29
30
|
isToolCallResponsePart,
|
|
31
|
+
isUsageResponsePart,
|
|
30
32
|
LanguageModel,
|
|
31
33
|
LanguageModelMessage,
|
|
32
34
|
LanguageModelRequirement,
|
|
@@ -58,9 +60,9 @@ import {
|
|
|
58
60
|
MarkdownChatResponseContentImpl,
|
|
59
61
|
ToolCallChatResponseContentImpl,
|
|
60
62
|
ChatRequestModel,
|
|
61
|
-
ThinkingChatResponseContentImpl
|
|
63
|
+
ThinkingChatResponseContentImpl,
|
|
62
64
|
} from './chat-model';
|
|
63
|
-
import {
|
|
65
|
+
import { parseContents } from './parse-contents';
|
|
64
66
|
import { DefaultResponseContentFactory, ResponseContentMatcher, ResponseContentMatcherProvider } from './response-content-matcher';
|
|
65
67
|
import { ChatToolRequest, ChatToolRequestService } from './chat-tool-request-service';
|
|
66
68
|
|
|
@@ -90,6 +92,10 @@ export namespace ChatSessionContext {
|
|
|
90
92
|
export function is(candidate: unknown): candidate is ChatSessionContext {
|
|
91
93
|
return typeof candidate === 'object' && !!candidate && 'model' in candidate;
|
|
92
94
|
}
|
|
95
|
+
|
|
96
|
+
export function getVariables(context: ChatSessionContext): readonly AIVariableResolutionRequest[] {
|
|
97
|
+
return context.request?.context.variables.map(AIVariableResolutionRequest.fromResolved) ?? context.model.context.getVariables();
|
|
98
|
+
}
|
|
93
99
|
}
|
|
94
100
|
|
|
95
101
|
/**
|
|
@@ -389,28 +395,35 @@ export abstract class AbstractStreamParsingChatAgent extends AbstractChatAgent {
|
|
|
389
395
|
}
|
|
390
396
|
|
|
391
397
|
protected async addStreamResponse(languageModelResponse: LanguageModelStreamResponse, request: MutableChatRequestModel): Promise<void> {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
if (isArray(newContents)) {
|
|
395
|
-
request.response.response.addContents(newContents);
|
|
396
|
-
} else {
|
|
397
|
-
request.response.response.addContent(newContents);
|
|
398
|
-
}
|
|
398
|
+
let completeTextBuffer = '';
|
|
399
|
+
let startIndex = Math.max(0, request.response.response.content.length - 1);
|
|
399
400
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
request.response.response.
|
|
401
|
+
for await (const token of languageModelResponse.stream) {
|
|
402
|
+
const newContent = this.parse(token, request);
|
|
403
|
+
|
|
404
|
+
if (!(isTextResponsePart(token) && token.content)) {
|
|
405
|
+
// For non-text tokens (like tool calls), add them directly
|
|
406
|
+
if (isArray(newContent)) {
|
|
407
|
+
request.response.response.addContents(newContent);
|
|
408
|
+
} else {
|
|
409
|
+
request.response.response.addContent(newContent);
|
|
410
|
+
}
|
|
411
|
+
// And reset the marker index and the text buffer as we skip matching across non-text tokens
|
|
412
|
+
startIndex = request.response.response.content.length - 1;
|
|
413
|
+
completeTextBuffer = '';
|
|
412
414
|
} else {
|
|
413
|
-
|
|
415
|
+
// parse the entire text so far (since beginning of the stream or last non-text token)
|
|
416
|
+
// and replace the entire content with the currently parsed content parts
|
|
417
|
+
completeTextBuffer += token.content;
|
|
418
|
+
|
|
419
|
+
const parsedContents = this.parseContents(completeTextBuffer, request);
|
|
420
|
+
const contentBeforeMarker = startIndex > 0
|
|
421
|
+
? request.response.response.content.slice(0, startIndex)
|
|
422
|
+
: [];
|
|
423
|
+
|
|
424
|
+
request.response.response.clearContent();
|
|
425
|
+
request.response.response.addContents(contentBeforeMarker);
|
|
426
|
+
request.response.response.addContents(parsedContents);
|
|
414
427
|
}
|
|
415
428
|
}
|
|
416
429
|
}
|
|
@@ -435,6 +448,9 @@ export abstract class AbstractStreamParsingChatAgent extends AbstractChatAgent {
|
|
|
435
448
|
if (isThinkingResponsePart(token)) {
|
|
436
449
|
return new ThinkingChatResponseContentImpl(token.thought, token.signature);
|
|
437
450
|
}
|
|
451
|
+
if (isUsageResponsePart(token)) {
|
|
452
|
+
return [];
|
|
453
|
+
}
|
|
438
454
|
return this.defaultContentFactory.create('', request);
|
|
439
455
|
}
|
|
440
456
|
|