@theia/ai-chat 1.65.0-next.19 → 1.65.0-next.39
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-module.d.ts.map +1 -1
- package/lib/browser/ai-chat-frontend-module.js +5 -4
- package/lib/browser/ai-chat-frontend-module.js.map +1 -1
- package/lib/browser/change-set-file-element.d.ts +2 -2
- package/lib/browser/change-set-file-element.d.ts.map +1 -1
- package/lib/browser/change-set-file-element.js +6 -6
- package/lib/browser/change-set-file-element.js.map +1 -1
- package/lib/browser/{chat-tool-preferences.d.ts → chat-tool-preference-bindings.d.ts} +3 -23
- package/lib/browser/chat-tool-preference-bindings.d.ts.map +1 -0
- package/lib/browser/chat-tool-preference-bindings.js +122 -0
- package/lib/browser/chat-tool-preference-bindings.js.map +1 -0
- package/lib/browser/chat-tool-request-service.d.ts +2 -1
- package/lib/browser/chat-tool-request-service.d.ts.map +1 -1
- package/lib/browser/chat-tool-request-service.js +4 -3
- package/lib/browser/chat-tool-request-service.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 +3 -3
- package/lib/browser/frontend-chat-service.js.map +1 -1
- package/lib/browser/task-context-service.d.ts +1 -1
- package/lib/browser/task-context-service.d.ts.map +1 -1
- package/lib/browser/task-context-service.js +2 -2
- package/lib/browser/task-context-service.js.map +1 -1
- package/lib/{browser → common}/ai-chat-preferences.d.ts +1 -1
- package/lib/common/ai-chat-preferences.d.ts.map +1 -0
- package/lib/{browser → common}/ai-chat-preferences.js +1 -2
- package/lib/common/ai-chat-preferences.js.map +1 -0
- package/lib/common/chat-agents.d.ts +4 -0
- package/lib/common/chat-agents.d.ts.map +1 -1
- package/lib/common/chat-agents.js +18 -1
- package/lib/common/chat-agents.js.map +1 -1
- package/lib/common/chat-service.d.ts +1 -0
- package/lib/common/chat-service.d.ts.map +1 -1
- package/lib/common/chat-service.js +8 -0
- package/lib/common/chat-service.js.map +1 -1
- package/lib/common/chat-tool-preferences.d.ts +23 -0
- package/lib/common/chat-tool-preferences.d.ts.map +1 -0
- package/lib/common/chat-tool-preferences.js +68 -0
- package/lib/common/chat-tool-preferences.js.map +1 -0
- package/lib/node/ai-chat-backend-module.d.ts +4 -0
- package/lib/node/ai-chat-backend-module.d.ts.map +1 -0
- package/lib/node/ai-chat-backend-module.js +26 -0
- package/lib/node/ai-chat-backend-module.js.map +1 -0
- package/package.json +11 -10
- package/src/browser/ai-chat-frontend-module.ts +5 -4
- package/src/browser/change-set-file-element.ts +2 -2
- package/src/browser/{chat-tool-preferences.ts → chat-tool-preference-bindings.ts} +3 -64
- package/src/browser/chat-tool-request-service.ts +2 -1
- package/src/browser/frontend-chat-service.ts +2 -2
- package/src/browser/task-context-service.ts +1 -1
- package/src/{browser → common}/ai-chat-preferences.ts +2 -4
- package/src/common/chat-agents.ts +18 -1
- package/src/common/chat-service.ts +10 -0
- package/src/common/chat-tool-preferences.ts +83 -0
- package/src/node/ai-chat-backend-module.ts +25 -0
- package/lib/browser/ai-chat-preferences.d.ts.map +0 -1
- package/lib/browser/ai-chat-preferences.js.map +0 -1
- package/lib/browser/chat-tool-preferences.d.ts.map +0 -1
- package/lib/browser/chat-tool-preferences.js +0 -170
- package/lib/browser/chat-tool-preferences.js.map +0 -1
|
@@ -233,6 +233,8 @@ export class ChatServiceImpl implements ChatService {
|
|
|
233
233
|
return undefined;
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
+
this.cancelIncompleteRequests(session);
|
|
237
|
+
|
|
236
238
|
const resolutionContext: ChatSessionContext = { model: session.model };
|
|
237
239
|
const resolvedContext = await this.resolveChatContext(request.variables ?? session.model.context.getVariables(), resolutionContext);
|
|
238
240
|
const parsedRequest = await this.chatRequestParser.parseChatRequest(request, session.model.location, resolvedContext);
|
|
@@ -274,6 +276,14 @@ export class ChatServiceImpl implements ChatService {
|
|
|
274
276
|
return invocation;
|
|
275
277
|
}
|
|
276
278
|
|
|
279
|
+
protected cancelIncompleteRequests(session: ChatSessionInternal): void {
|
|
280
|
+
for (const pastRequest of session.model.getRequests()) {
|
|
281
|
+
if (!pastRequest.response.isComplete) {
|
|
282
|
+
pastRequest.cancel();
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
277
287
|
protected updateSessionMetadata(session: ChatSessionInternal, request: MutableChatRequestModel): void {
|
|
278
288
|
session.lastInteraction = new Date();
|
|
279
289
|
if (session.title) {
|
|
@@ -0,0 +1,83 @@
|
|
|
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 { AI_CORE_PREFERENCES_TITLE } from '@theia/ai-core/lib/common/ai-core-preferences';
|
|
18
|
+
import { nls } from '@theia/core';
|
|
19
|
+
import {
|
|
20
|
+
createPreferenceProxy,
|
|
21
|
+
PreferenceContribution,
|
|
22
|
+
PreferenceProxy,
|
|
23
|
+
PreferenceSchema,
|
|
24
|
+
PreferenceService,
|
|
25
|
+
} from '@theia/core/lib/common/preferences';
|
|
26
|
+
import { interfaces } from '@theia/core/shared/inversify';
|
|
27
|
+
|
|
28
|
+
export type ChatToolPreferences = PreferenceProxy<ChatToolConfiguration>;
|
|
29
|
+
|
|
30
|
+
export const ChatToolPreferenceContribution = Symbol('ChatToolPreferenceContribution');
|
|
31
|
+
export const ChatToolPreferences = Symbol('ChatToolPreferences');
|
|
32
|
+
|
|
33
|
+
export function createChatToolPreferences(preferences: PreferenceService, schema: PreferenceSchema = chatToolPreferences): ChatToolPreferences {
|
|
34
|
+
return createPreferenceProxy(preferences, schema);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function bindChatToolPreferences(bind: interfaces.Bind): void {
|
|
38
|
+
bind(ChatToolPreferences).toDynamicValue((ctx: interfaces.Context) => {
|
|
39
|
+
const preferences = ctx.container.get<PreferenceService>(PreferenceService);
|
|
40
|
+
const contribution = ctx.container.get<PreferenceContribution>(ChatToolPreferenceContribution);
|
|
41
|
+
return createChatToolPreferences(preferences, contribution.schema);
|
|
42
|
+
}).inSingletonScope();
|
|
43
|
+
bind(ChatToolPreferenceContribution).toConstantValue({ schema: chatToolPreferences });
|
|
44
|
+
bind(PreferenceContribution).toService(ChatToolPreferenceContribution);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Enum for tool confirmation modes
|
|
49
|
+
*/
|
|
50
|
+
export enum ToolConfirmationMode {
|
|
51
|
+
ALWAYS_ALLOW = 'always_allow',
|
|
52
|
+
CONFIRM = 'confirm',
|
|
53
|
+
DISABLED = 'disabled'
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const TOOL_CONFIRMATION_PREFERENCE = 'ai-features.chat.toolConfirmation';
|
|
57
|
+
|
|
58
|
+
export const chatToolPreferences: PreferenceSchema = {
|
|
59
|
+
properties: {
|
|
60
|
+
[TOOL_CONFIRMATION_PREFERENCE]: {
|
|
61
|
+
type: 'object',
|
|
62
|
+
additionalProperties: {
|
|
63
|
+
type: 'string',
|
|
64
|
+
enum: [ToolConfirmationMode.ALWAYS_ALLOW, ToolConfirmationMode.CONFIRM, ToolConfirmationMode.DISABLED],
|
|
65
|
+
enumDescriptions: [
|
|
66
|
+
nls.localize('theia/ai/chat/toolConfirmation/yolo/description', 'Execute tools automatically without confirmation'),
|
|
67
|
+
nls.localize('theia/ai/chat/toolConfirmation/confirm/description', 'Ask for confirmation before executing tools'),
|
|
68
|
+
nls.localize('theia/ai/chat/toolConfirmation/disabled/description', 'Disable tool execution')
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
default: {},
|
|
72
|
+
description: nls.localize('theia/ai/chat/toolConfirmation/description',
|
|
73
|
+
'Configure confirmation behavior for different tools. Key is the tool ID, value is the confirmation mode.' +
|
|
74
|
+
'Use "*" as the key to set a global default for all tools.'),
|
|
75
|
+
title: AI_CORE_PREFERENCES_TITLE,
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export interface ChatToolConfiguration {
|
|
81
|
+
[TOOL_CONFIRMATION_PREFERENCE]: { [toolId: string]: ToolConfirmationMode };
|
|
82
|
+
}
|
|
83
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2025 STMicroelectronics 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 { PreferenceContribution } from '@theia/core';
|
|
18
|
+
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
19
|
+
import { aiChatPreferences } from '../common/ai-chat-preferences';
|
|
20
|
+
import { chatToolPreferences } from '../common/chat-tool-preferences';
|
|
21
|
+
|
|
22
|
+
export default new ContainerModule(bind => {
|
|
23
|
+
bind(PreferenceContribution).toConstantValue({ schema: aiChatPreferences });
|
|
24
|
+
bind(PreferenceContribution).toConstantValue({ schema: chatToolPreferences });
|
|
25
|
+
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ai-chat-preferences.d.ts","sourceRoot":"","sources":["../../src/browser/ai-chat-preferences.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6DAA6D,CAAC;AAE/F,eAAO,MAAM,uBAAuB,sCAAsC,CAAC;AAC3E,eAAO,MAAM,mBAAmB,kCAAkC,CAAC;AAEnE,eAAO,MAAM,iBAAiB,EAAE,gBAmB/B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ai-chat-preferences.js","sourceRoot":"","sources":["../../src/browser/ai-chat-preferences.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,wFAA2F;AAC3F,sCAAkC;AAGrB,QAAA,uBAAuB,GAAG,mCAAmC,CAAC;AAC9D,QAAA,mBAAmB,GAAG,+BAA+B,CAAC;AAEtD,QAAA,iBAAiB,GAAqB;IAC/C,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACR,CAAC,+BAAuB,CAAC,EAAE;YACvB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,UAAG,CAAC,QAAQ,CAAC,wCAAwC,EAC9D;qEACqD,CAA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,CAAC,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAGxD,SAAS,CAAC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAa;IAEvF;;OAEG;IACH,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,oBAAoB;IAezE;;OAEG;IACH,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,oBAAoB,GAAG,IAAI;IAqBrE;;OAEG;IACH,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAS5F;;OAEG;IACH,qBAAqB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAQ5C;;OAEG;IACH,0BAA0B,IAAI;QAAE,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,CAAA;KAAE;IAIxE,gCAAgC,IAAI,IAAI;CAQ3C"}
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2025 EclipseSource GmbH.
|
|
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.ToolConfirmationManager = exports.bindChatToolPreferences = exports.createChatToolPreferences = exports.ChatToolPreferences = exports.ChatToolPreferenceContribution = exports.chatToolPreferences = exports.TOOL_CONFIRMATION_PREFERENCE = exports.ToolConfirmationMode = void 0;
|
|
19
|
-
const tslib_1 = require("tslib");
|
|
20
|
-
const ai_core_preferences_1 = require("@theia/ai-core/lib/browser/ai-core-preferences");
|
|
21
|
-
const core_1 = require("@theia/core");
|
|
22
|
-
const inversify_1 = require("@theia/core/shared/inversify");
|
|
23
|
-
const preferences_1 = require("@theia/core/lib/browser/preferences");
|
|
24
|
-
/**
|
|
25
|
-
* Enum for tool confirmation modes
|
|
26
|
-
*/
|
|
27
|
-
var ToolConfirmationMode;
|
|
28
|
-
(function (ToolConfirmationMode) {
|
|
29
|
-
ToolConfirmationMode["ALWAYS_ALLOW"] = "always_allow";
|
|
30
|
-
ToolConfirmationMode["CONFIRM"] = "confirm";
|
|
31
|
-
ToolConfirmationMode["DISABLED"] = "disabled";
|
|
32
|
-
})(ToolConfirmationMode || (exports.ToolConfirmationMode = ToolConfirmationMode = {}));
|
|
33
|
-
exports.TOOL_CONFIRMATION_PREFERENCE = 'ai-features.chat.toolConfirmation';
|
|
34
|
-
exports.chatToolPreferences = {
|
|
35
|
-
type: 'object',
|
|
36
|
-
properties: {
|
|
37
|
-
[exports.TOOL_CONFIRMATION_PREFERENCE]: {
|
|
38
|
-
type: 'object',
|
|
39
|
-
additionalProperties: {
|
|
40
|
-
type: 'string',
|
|
41
|
-
enum: [ToolConfirmationMode.ALWAYS_ALLOW, ToolConfirmationMode.CONFIRM, ToolConfirmationMode.DISABLED],
|
|
42
|
-
enumDescriptions: [
|
|
43
|
-
core_1.nls.localize('theia/ai/chat/toolConfirmation/yolo/description', 'Execute tools automatically without confirmation'),
|
|
44
|
-
core_1.nls.localize('theia/ai/chat/toolConfirmation/confirm/description', 'Ask for confirmation before executing tools'),
|
|
45
|
-
core_1.nls.localize('theia/ai/chat/toolConfirmation/disabled/description', 'Disable tool execution')
|
|
46
|
-
]
|
|
47
|
-
},
|
|
48
|
-
default: {},
|
|
49
|
-
description: core_1.nls.localize('theia/ai/chat/toolConfirmation/description', 'Configure confirmation behavior for different tools. Key is the tool ID, value is the confirmation mode.' +
|
|
50
|
-
'Use "*" as the key to set a global default for all tools.'),
|
|
51
|
-
title: ai_core_preferences_1.AI_CORE_PREFERENCES_TITLE,
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
exports.ChatToolPreferenceContribution = Symbol('ChatToolPreferenceContribution');
|
|
56
|
-
exports.ChatToolPreferences = Symbol('ChatToolPreferences');
|
|
57
|
-
function createChatToolPreferences(preferences, schema = exports.chatToolPreferences) {
|
|
58
|
-
return (0, preferences_1.createPreferenceProxy)(preferences, schema);
|
|
59
|
-
}
|
|
60
|
-
exports.createChatToolPreferences = createChatToolPreferences;
|
|
61
|
-
function bindChatToolPreferences(bind) {
|
|
62
|
-
bind(exports.ChatToolPreferences).toDynamicValue((ctx) => {
|
|
63
|
-
const preferences = ctx.container.get(preferences_1.PreferenceService);
|
|
64
|
-
const contribution = ctx.container.get(exports.ChatToolPreferenceContribution);
|
|
65
|
-
return createChatToolPreferences(preferences, contribution.schema);
|
|
66
|
-
}).inSingletonScope();
|
|
67
|
-
bind(exports.ChatToolPreferenceContribution).toConstantValue({ schema: exports.chatToolPreferences });
|
|
68
|
-
bind(preferences_1.PreferenceContribution).toService(exports.ChatToolPreferenceContribution);
|
|
69
|
-
}
|
|
70
|
-
exports.bindChatToolPreferences = bindChatToolPreferences;
|
|
71
|
-
/**
|
|
72
|
-
* Utility class to manage tool confirmation settings
|
|
73
|
-
*/
|
|
74
|
-
let ToolConfirmationManager = class ToolConfirmationManager {
|
|
75
|
-
constructor() {
|
|
76
|
-
// In-memory session overrides (not persisted), per chat
|
|
77
|
-
this.sessionOverrides = new Map();
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Get the confirmation mode for a specific tool, considering session overrides first (per chat)
|
|
81
|
-
*/
|
|
82
|
-
getConfirmationMode(toolId, chatId) {
|
|
83
|
-
const chatMap = this.sessionOverrides.get(chatId);
|
|
84
|
-
if (chatMap && chatMap.has(toolId)) {
|
|
85
|
-
return chatMap.get(toolId);
|
|
86
|
-
}
|
|
87
|
-
const toolConfirmation = this.preferences[exports.TOOL_CONFIRMATION_PREFERENCE];
|
|
88
|
-
if (toolConfirmation[toolId]) {
|
|
89
|
-
return toolConfirmation[toolId];
|
|
90
|
-
}
|
|
91
|
-
if (toolConfirmation['*']) {
|
|
92
|
-
return toolConfirmation['*'];
|
|
93
|
-
}
|
|
94
|
-
return ToolConfirmationMode.ALWAYS_ALLOW; // Default to Always Allow
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Set the confirmation mode for a specific tool (persisted)
|
|
98
|
-
*/
|
|
99
|
-
setConfirmationMode(toolId, mode) {
|
|
100
|
-
const current = this.preferences[exports.TOOL_CONFIRMATION_PREFERENCE] || {};
|
|
101
|
-
// Determine the global default (star entry), or fallback to schema default
|
|
102
|
-
let starMode = current['*'];
|
|
103
|
-
if (starMode === undefined) {
|
|
104
|
-
starMode = ToolConfirmationMode.ALWAYS_ALLOW;
|
|
105
|
-
}
|
|
106
|
-
if (mode === starMode) {
|
|
107
|
-
// Remove the toolId entry if it exists
|
|
108
|
-
if (toolId in current) {
|
|
109
|
-
const { [toolId]: _, ...rest } = current;
|
|
110
|
-
this.preferenceService.updateValue(exports.TOOL_CONFIRMATION_PREFERENCE, rest);
|
|
111
|
-
}
|
|
112
|
-
// else, nothing to update
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
// Set or update the toolId entry
|
|
116
|
-
const updated = { ...current, [toolId]: mode };
|
|
117
|
-
this.preferenceService.updateValue(exports.TOOL_CONFIRMATION_PREFERENCE, updated);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Set the confirmation mode for a specific tool for this session only (not persisted, per chat)
|
|
122
|
-
*/
|
|
123
|
-
setSessionConfirmationMode(toolId, mode, chatId) {
|
|
124
|
-
let chatMap = this.sessionOverrides.get(chatId);
|
|
125
|
-
if (!chatMap) {
|
|
126
|
-
chatMap = new Map();
|
|
127
|
-
this.sessionOverrides.set(chatId, chatMap);
|
|
128
|
-
}
|
|
129
|
-
chatMap.set(toolId, mode);
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Clear all session overrides for a specific chat, or all if no chatId is given
|
|
133
|
-
*/
|
|
134
|
-
clearSessionOverrides(chatId) {
|
|
135
|
-
if (chatId) {
|
|
136
|
-
this.sessionOverrides.delete(chatId);
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
this.sessionOverrides.clear();
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Get all tool confirmation settings
|
|
144
|
-
*/
|
|
145
|
-
getAllConfirmationSettings() {
|
|
146
|
-
return this.preferences[exports.TOOL_CONFIRMATION_PREFERENCE] || {};
|
|
147
|
-
}
|
|
148
|
-
resetAllConfirmationModeSettings() {
|
|
149
|
-
const current = this.preferences[exports.TOOL_CONFIRMATION_PREFERENCE] || {};
|
|
150
|
-
if ('*' in current) {
|
|
151
|
-
this.preferenceService.updateValue(exports.TOOL_CONFIRMATION_PREFERENCE, { '*': current['*'] });
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
this.preferenceService.updateValue(exports.TOOL_CONFIRMATION_PREFERENCE, {});
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
exports.ToolConfirmationManager = ToolConfirmationManager;
|
|
159
|
-
tslib_1.__decorate([
|
|
160
|
-
(0, inversify_1.inject)(exports.ChatToolPreferences),
|
|
161
|
-
tslib_1.__metadata("design:type", Object)
|
|
162
|
-
], ToolConfirmationManager.prototype, "preferences", void 0);
|
|
163
|
-
tslib_1.__decorate([
|
|
164
|
-
(0, inversify_1.inject)(preferences_1.PreferenceService),
|
|
165
|
-
tslib_1.__metadata("design:type", Object)
|
|
166
|
-
], ToolConfirmationManager.prototype, "preferenceService", void 0);
|
|
167
|
-
exports.ToolConfirmationManager = ToolConfirmationManager = tslib_1.__decorate([
|
|
168
|
-
(0, inversify_1.injectable)()
|
|
169
|
-
], ToolConfirmationManager);
|
|
170
|
-
//# sourceMappingURL=chat-tool-preferences.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chat-tool-preferences.js","sourceRoot":"","sources":["../../src/browser/chat-tool-preferences.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,wFAA2F;AAC3F,sCAAkC;AAClC,4DAA8E;AAC9E,qEAM6C;AAE7C;;GAEG;AACH,IAAY,oBAIX;AAJD,WAAY,oBAAoB;IAC5B,qDAA6B,CAAA;IAC7B,2CAAmB,CAAA;IACnB,6CAAqB,CAAA;AACzB,CAAC,EAJW,oBAAoB,oCAApB,oBAAoB,QAI/B;AAEY,QAAA,4BAA4B,GAAG,mCAAmC,CAAC;AAEnE,QAAA,mBAAmB,GAAqB;IACjD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACR,CAAC,oCAA4B,CAAC,EAAE;YAC5B,IAAI,EAAE,QAAQ;YACd,oBAAoB,EAAE;gBAClB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,oBAAoB,CAAC,YAAY,EAAE,oBAAoB,CAAC,OAAO,EAAE,oBAAoB,CAAC,QAAQ,CAAC;gBACtG,gBAAgB,EAAE;oBACd,UAAG,CAAC,QAAQ,CAAC,iDAAiD,EAAE,kDAAkD,CAAC;oBACnH,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