@theia/ai-history 1.55.0-next.4 → 1.55.0-next.67
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/README.md +0 -1
- package/lib/browser/ai-history-communication-card.d.ts.map +1 -1
- package/lib/browser/ai-history-communication-card.js +14 -5
- package/lib/browser/ai-history-communication-card.js.map +1 -1
- package/lib/browser/ai-history-contribution.d.ts +14 -3
- package/lib/browser/ai-history-contribution.d.ts.map +1 -1
- package/lib/browser/ai-history-contribution.js +108 -6
- package/lib/browser/ai-history-contribution.js.map +1 -1
- package/lib/browser/ai-history-frontend-module.d.ts.map +1 -1
- package/lib/browser/ai-history-frontend-module.js +3 -1
- package/lib/browser/ai-history-frontend-module.js.map +1 -1
- package/lib/browser/ai-history-widget.d.ts +18 -2
- package/lib/browser/ai-history-widget.d.ts.map +1 -1
- package/lib/browser/ai-history-widget.js +38 -2
- package/lib/browser/ai-history-widget.js.map +1 -1
- package/lib/common/communication-recording-service.d.ts +7 -3
- package/lib/common/communication-recording-service.d.ts.map +1 -1
- package/lib/common/communication-recording-service.js +20 -9
- package/lib/common/communication-recording-service.js.map +1 -1
- package/lib/common/communication-recording-service.spec.js +22 -0
- package/lib/common/communication-recording-service.spec.js.map +1 -1
- package/package.json +8 -8
- package/src/browser/ai-history-communication-card.tsx +25 -2
- package/src/browser/ai-history-contribution.ts +97 -7
- package/src/browser/ai-history-frontend-module.ts +4 -1
- package/src/browser/ai-history-widget.tsx +54 -5
- package/src/browser/style/ai-history.css +18 -1
- package/src/common/communication-recording-service.spec.ts +25 -0
- package/src/common/communication-recording-service.ts +37 -12
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-history-communication-card.d.ts","sourceRoot":"","sources":["../../src/browser/ai-history-communication-card.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,KAAK,MAAM,0BAA0B,CAAC;AAElD,MAAM,WAAW,sBAAsB;IACnC,KAAK,EAAE,yBAAyB,CAAC;CACpC;AAED,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,
|
|
1
|
+
{"version":3,"file":"ai-history-communication-card.d.ts","sourceRoot":"","sources":["../../src/browser/ai-history-communication-card.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,KAAK,MAAM,0BAA0B,CAAC;AAElD,MAAM,WAAW,sBAAsB;IACnC,KAAK,EAAE,yBAAyB,CAAC;CACpC;AAED,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAgD9D,CAAC"}
|
|
@@ -12,13 +12,22 @@ const CommunicationCard = ({ entry }) => (React.createElement("div", { className
|
|
|
12
12
|
entry.sessionId)),
|
|
13
13
|
React.createElement("div", { className: 'theia-card-content' },
|
|
14
14
|
entry.request && (React.createElement("div", { className: 'theia-card-request' },
|
|
15
|
-
React.createElement("
|
|
16
|
-
React.createElement("strong", null, "Request")),
|
|
15
|
+
React.createElement("h2", null, "Request"),
|
|
17
16
|
React.createElement("pre", null, entry.request))),
|
|
18
17
|
entry.response && (React.createElement("div", { className: 'theia-card-response' },
|
|
19
|
-
React.createElement("
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
React.createElement("h2", null, "Response"),
|
|
19
|
+
React.createElement("pre", null, entry.response))),
|
|
20
|
+
(entry.systemMessage || (entry.messages && entry.messages.length > 0)) && (React.createElement("div", { className: 'theia-card-context' },
|
|
21
|
+
React.createElement("details", null,
|
|
22
|
+
React.createElement("summary", null,
|
|
23
|
+
React.createElement("h2", null, "Context")),
|
|
24
|
+
(entry.systemMessage && (React.createElement("div", { className: 'theia-context-system-message' },
|
|
25
|
+
React.createElement("h3", null, "System Message"),
|
|
26
|
+
React.createElement("pre", null, entry.systemMessage)))),
|
|
27
|
+
(entry.messages && entry.messages.length > 0) && (React.createElement("div", { className: 'theia-context-messages' },
|
|
28
|
+
React.createElement("h3", null, "Messages"),
|
|
29
|
+
React.createElement("ul", null, entry.messages.map((message, index) => (React.createElement("li", { key: index },
|
|
30
|
+
React.createElement("pre", null, JSON.stringify(message, undefined, 2)))))))))))),
|
|
22
31
|
React.createElement("div", { className: 'theia-card-meta' },
|
|
23
32
|
React.createElement("span", { className: 'theia-card-timestamp' },
|
|
24
33
|
"Timestamp: ",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-history-communication-card.js","sourceRoot":"","sources":["../../src/browser/ai-history-communication-card.tsx"],"names":[],"mappings":";;;AAgBA,kDAAkD;AAM3C,MAAM,iBAAiB,GAAqC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAC9E,6BAAK,SAAS,EAAC,YAAY;IACvB,6BAAK,SAAS,EAAC,iBAAiB;QAC5B,8BAAM,SAAS,EAAC,uBAAuB;;YAAc,KAAK,CAAC,SAAS,CAAQ;QAC5E,8BAAM,SAAS,EAAC,uBAAuB;;YAAc,KAAK,CAAC,SAAS,CAAQ,CAC1E;IACN,6BAAK,SAAS,EAAC,oBAAoB;QAC9B,KAAK,CAAC,OAAO,IAAI,CACd,6BAAK,SAAS,EAAC,oBAAoB;YAC/B
|
|
1
|
+
{"version":3,"file":"ai-history-communication-card.js","sourceRoot":"","sources":["../../src/browser/ai-history-communication-card.tsx"],"names":[],"mappings":";;;AAgBA,kDAAkD;AAM3C,MAAM,iBAAiB,GAAqC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAC9E,6BAAK,SAAS,EAAC,YAAY;IACvB,6BAAK,SAAS,EAAC,iBAAiB;QAC5B,8BAAM,SAAS,EAAC,uBAAuB;;YAAc,KAAK,CAAC,SAAS,CAAQ;QAC5E,8BAAM,SAAS,EAAC,uBAAuB;;YAAc,KAAK,CAAC,SAAS,CAAQ,CAC1E;IACN,6BAAK,SAAS,EAAC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AAU,CAC5G,CACJ,CACT,CAAC;AAhDW,QAAA,iBAAiB,qBAgD5B"}
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import { FrontendApplication } from '@theia/core/lib/browser';
|
|
2
2
|
import { AIViewContribution } from '@theia/ai-core/lib/browser';
|
|
3
3
|
import { AIHistoryView } from './ai-history-widget';
|
|
4
|
-
import { Command, CommandRegistry } from '@theia/core';
|
|
4
|
+
import { Command, CommandRegistry, Emitter } from '@theia/core';
|
|
5
|
+
import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
|
5
6
|
export declare const AI_HISTORY_TOGGLE_COMMAND_ID = "aiHistory:toggle";
|
|
6
7
|
export declare const OPEN_AI_HISTORY_VIEW: Command;
|
|
7
|
-
export declare
|
|
8
|
+
export declare const AI_HISTORY_VIEW_SORT_CHRONOLOGICALLY: Command;
|
|
9
|
+
export declare const AI_HISTORY_VIEW_SORT_REVERSE_CHRONOLOGICALLY: Command;
|
|
10
|
+
export declare const AI_HISTORY_VIEW_CLEAR: Command;
|
|
11
|
+
export declare class AIHistoryViewContribution extends AIViewContribution<AIHistoryView> implements TabBarToolbarContribution {
|
|
12
|
+
private recordingService;
|
|
8
13
|
constructor();
|
|
9
14
|
initializeLayout(_app: FrontendApplication): Promise<void>;
|
|
10
|
-
registerCommands(
|
|
15
|
+
registerCommands(registry: CommandRegistry): void;
|
|
16
|
+
clearHistory(): void;
|
|
17
|
+
protected withHistoryWidget(widget?: unknown, predicate?: (output: AIHistoryView) => boolean): boolean | false;
|
|
18
|
+
protected readonly onAIHistoryWidgetStateChangedEmitter: Emitter<void>;
|
|
19
|
+
protected readonly onAIHistoryWidgettStateChanged: import("@theia/core").Event<void>;
|
|
20
|
+
protected init(): void;
|
|
21
|
+
registerToolbarItems(registry: TabBarToolbarRegistry): void;
|
|
11
22
|
}
|
|
12
23
|
//# sourceMappingURL=ai-history-contribution.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-history-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/ai-history-contribution.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"ai-history-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/ai-history-contribution.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,mBAAmB,EAAW,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAC;AAGjH,eAAO,MAAM,4BAA4B,qBAAqB,CAAC;AAC/D,eAAO,MAAM,oBAAoB,SAG/B,CAAC;AAEH,eAAO,MAAM,oCAAoC,SAI/C,CAAC;AAEH,eAAO,MAAM,4CAA4C,SAIvD,CAAC;AAEH,eAAO,MAAM,qBAAqB,SAIhC,CAAC;AAEH,qBACa,yBAA0B,SAAQ,kBAAkB,CAAC,aAAa,CAAE,YAAW,yBAAyB;IAC1E,OAAO,CAAC,gBAAgB,CAAgC;;IAczF,gBAAgB,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvD,gBAAgB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IA8BnD,YAAY,IAAI,IAAI;IAI3B,SAAS,CAAC,iBAAiB,CACvB,MAAM,GAAE,OAA6B,EACrC,SAAS,GAAE,CAAC,MAAM,EAAE,aAAa,KAAK,OAAoB,GAC3D,OAAO,GAAG,KAAK;IAIlB,SAAS,CAAC,QAAQ,CAAC,oCAAoC,gBAAuB;IAC9E,SAAS,CAAC,QAAQ,CAAC,8BAA8B,oCAAmD;cAGjF,IAAI,IAAI,IAAI;IAO/B,oBAAoB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,IAAI;CAsB9D"}
|
|
@@ -1,17 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AIHistoryViewContribution = exports.OPEN_AI_HISTORY_VIEW = exports.AI_HISTORY_TOGGLE_COMMAND_ID = void 0;
|
|
3
|
+
exports.AIHistoryViewContribution = exports.AI_HISTORY_VIEW_CLEAR = exports.AI_HISTORY_VIEW_SORT_REVERSE_CHRONOLOGICALLY = exports.AI_HISTORY_VIEW_SORT_CHRONOLOGICALLY = exports.OPEN_AI_HISTORY_VIEW = exports.AI_HISTORY_TOGGLE_COMMAND_ID = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
|
|
5
|
+
// *****************************************************************************
|
|
6
|
+
// Copyright (C) 2024 EclipseSource GmbH.
|
|
7
|
+
//
|
|
8
|
+
// This program and the accompanying materials are made available under the
|
|
9
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
10
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
11
|
+
//
|
|
12
|
+
// This Source Code may also be made available under the following Secondary
|
|
13
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
14
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
15
|
+
// with the GNU Classpath Exception which is available at
|
|
16
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
17
|
+
//
|
|
18
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
19
|
+
// *****************************************************************************
|
|
20
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
21
|
+
const browser_2 = require("@theia/ai-core/lib/browser");
|
|
6
22
|
const inversify_1 = require("@theia/core/shared/inversify");
|
|
7
23
|
const ai_history_widget_1 = require("./ai-history-widget");
|
|
8
24
|
const core_1 = require("@theia/core");
|
|
25
|
+
const ai_core_1 = require("@theia/ai-core");
|
|
9
26
|
exports.AI_HISTORY_TOGGLE_COMMAND_ID = 'aiHistory:toggle';
|
|
10
27
|
exports.OPEN_AI_HISTORY_VIEW = core_1.Command.toLocalizedCommand({
|
|
11
28
|
id: 'aiHistory:open',
|
|
12
29
|
label: 'Open AI History view',
|
|
13
30
|
});
|
|
14
|
-
|
|
31
|
+
exports.AI_HISTORY_VIEW_SORT_CHRONOLOGICALLY = core_1.Command.toLocalizedCommand({
|
|
32
|
+
id: 'aiHistory:sortChronologically',
|
|
33
|
+
label: 'AI History: Sort chronologically',
|
|
34
|
+
iconClass: (0, browser_1.codicon)('arrow-down')
|
|
35
|
+
});
|
|
36
|
+
exports.AI_HISTORY_VIEW_SORT_REVERSE_CHRONOLOGICALLY = core_1.Command.toLocalizedCommand({
|
|
37
|
+
id: 'aiHistory:sortReverseChronologically',
|
|
38
|
+
label: 'AI History: Sort reverse chronologically',
|
|
39
|
+
iconClass: (0, browser_1.codicon)('arrow-up')
|
|
40
|
+
});
|
|
41
|
+
exports.AI_HISTORY_VIEW_CLEAR = core_1.Command.toLocalizedCommand({
|
|
42
|
+
id: 'aiHistory:clear',
|
|
43
|
+
label: 'AI History: Clear History',
|
|
44
|
+
iconClass: (0, browser_1.codicon)('clear-all')
|
|
45
|
+
});
|
|
46
|
+
let AIHistoryViewContribution = class AIHistoryViewContribution extends browser_2.AIViewContribution {
|
|
15
47
|
constructor() {
|
|
16
48
|
super({
|
|
17
49
|
widgetId: ai_history_widget_1.AIHistoryView.ID,
|
|
@@ -22,18 +54,88 @@ let AIHistoryViewContribution = class AIHistoryViewContribution extends browser_
|
|
|
22
54
|
},
|
|
23
55
|
toggleCommandId: exports.AI_HISTORY_TOGGLE_COMMAND_ID,
|
|
24
56
|
});
|
|
57
|
+
this.onAIHistoryWidgetStateChangedEmitter = new core_1.Emitter();
|
|
58
|
+
this.onAIHistoryWidgettStateChanged = this.onAIHistoryWidgetStateChangedEmitter.event;
|
|
25
59
|
}
|
|
26
60
|
async initializeLayout(_app) {
|
|
27
61
|
await this.openView();
|
|
28
62
|
}
|
|
29
|
-
registerCommands(
|
|
30
|
-
super.registerCommands(
|
|
31
|
-
|
|
63
|
+
registerCommands(registry) {
|
|
64
|
+
super.registerCommands(registry);
|
|
65
|
+
registry.registerCommand(exports.OPEN_AI_HISTORY_VIEW, {
|
|
32
66
|
execute: () => this.openView({ activate: true }),
|
|
33
67
|
});
|
|
68
|
+
registry.registerCommand(exports.AI_HISTORY_VIEW_SORT_CHRONOLOGICALLY, {
|
|
69
|
+
isEnabled: widget => this.withHistoryWidget(widget, historyView => !historyView.isChronological),
|
|
70
|
+
isVisible: widget => this.withHistoryWidget(widget, historyView => !historyView.isChronological),
|
|
71
|
+
execute: widget => this.withHistoryWidget(widget, historyView => {
|
|
72
|
+
historyView.sortHistory(true);
|
|
73
|
+
return true;
|
|
74
|
+
})
|
|
75
|
+
});
|
|
76
|
+
registry.registerCommand(exports.AI_HISTORY_VIEW_SORT_REVERSE_CHRONOLOGICALLY, {
|
|
77
|
+
isEnabled: widget => this.withHistoryWidget(widget, historyView => historyView.isChronological),
|
|
78
|
+
isVisible: widget => this.withHistoryWidget(widget, historyView => historyView.isChronological),
|
|
79
|
+
execute: widget => this.withHistoryWidget(widget, historyView => {
|
|
80
|
+
historyView.sortHistory(false);
|
|
81
|
+
return true;
|
|
82
|
+
})
|
|
83
|
+
});
|
|
84
|
+
registry.registerCommand(exports.AI_HISTORY_VIEW_CLEAR, {
|
|
85
|
+
isEnabled: widget => this.withHistoryWidget(widget),
|
|
86
|
+
isVisible: widget => this.withHistoryWidget(widget),
|
|
87
|
+
execute: widget => this.withHistoryWidget(widget, () => {
|
|
88
|
+
this.clearHistory();
|
|
89
|
+
return true;
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
clearHistory() {
|
|
94
|
+
this.recordingService.clearHistory();
|
|
95
|
+
}
|
|
96
|
+
withHistoryWidget(widget = this.tryGetWidget(), predicate = () => true) {
|
|
97
|
+
return widget instanceof ai_history_widget_1.AIHistoryView ? predicate(widget) : false;
|
|
98
|
+
}
|
|
99
|
+
init() {
|
|
100
|
+
super.init();
|
|
101
|
+
this.widget.then(widget => {
|
|
102
|
+
widget.onStateChanged(() => this.onAIHistoryWidgetStateChangedEmitter.fire());
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
registerToolbarItems(registry) {
|
|
106
|
+
registry.registerItem({
|
|
107
|
+
id: exports.AI_HISTORY_VIEW_SORT_CHRONOLOGICALLY.id,
|
|
108
|
+
command: exports.AI_HISTORY_VIEW_SORT_CHRONOLOGICALLY.id,
|
|
109
|
+
tooltip: 'Sort chronologically',
|
|
110
|
+
isVisible: widget => this.withHistoryWidget(widget),
|
|
111
|
+
onDidChange: this.onAIHistoryWidgettStateChanged
|
|
112
|
+
});
|
|
113
|
+
registry.registerItem({
|
|
114
|
+
id: exports.AI_HISTORY_VIEW_SORT_REVERSE_CHRONOLOGICALLY.id,
|
|
115
|
+
command: exports.AI_HISTORY_VIEW_SORT_REVERSE_CHRONOLOGICALLY.id,
|
|
116
|
+
tooltip: 'Sort reverse chronologically',
|
|
117
|
+
isVisible: widget => this.withHistoryWidget(widget),
|
|
118
|
+
onDidChange: this.onAIHistoryWidgettStateChanged
|
|
119
|
+
});
|
|
120
|
+
registry.registerItem({
|
|
121
|
+
id: exports.AI_HISTORY_VIEW_CLEAR.id,
|
|
122
|
+
command: exports.AI_HISTORY_VIEW_CLEAR.id,
|
|
123
|
+
tooltip: 'Clear History of all agents',
|
|
124
|
+
isVisible: widget => this.withHistoryWidget(widget)
|
|
125
|
+
});
|
|
34
126
|
}
|
|
35
127
|
};
|
|
36
128
|
exports.AIHistoryViewContribution = AIHistoryViewContribution;
|
|
129
|
+
tslib_1.__decorate([
|
|
130
|
+
(0, inversify_1.inject)(ai_core_1.CommunicationRecordingService),
|
|
131
|
+
tslib_1.__metadata("design:type", Object)
|
|
132
|
+
], AIHistoryViewContribution.prototype, "recordingService", void 0);
|
|
133
|
+
tslib_1.__decorate([
|
|
134
|
+
(0, inversify_1.postConstruct)(),
|
|
135
|
+
tslib_1.__metadata("design:type", Function),
|
|
136
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
137
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
138
|
+
], AIHistoryViewContribution.prototype, "init", null);
|
|
37
139
|
exports.AIHistoryViewContribution = AIHistoryViewContribution = tslib_1.__decorate([
|
|
38
140
|
(0, inversify_1.injectable)(),
|
|
39
141
|
tslib_1.__metadata("design:paramtypes", [])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-history-contribution.js","sourceRoot":"","sources":["../../src/browser/ai-history-contribution.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"ai-history-contribution.js","sourceRoot":"","sources":["../../src/browser/ai-history-contribution.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;AAChF,qDAAuE;AACvE,wDAAgE;AAChE,4DAAiF;AACjF,2DAAoD;AACpD,sCAAgE;AAEhE,4CAA+D;AAElD,QAAA,4BAA4B,GAAG,kBAAkB,CAAC;AAClD,QAAA,oBAAoB,GAAG,cAAO,CAAC,kBAAkB,CAAC;IAC3D,EAAE,EAAE,gBAAgB;IACpB,KAAK,EAAE,sBAAsB;CAChC,CAAC,CAAC;AAEU,QAAA,oCAAoC,GAAG,cAAO,CAAC,kBAAkB,CAAC;IAC3E,EAAE,EAAE,+BAA+B;IACnC,KAAK,EAAE,kCAAkC;IACzC,SAAS,EAAE,IAAA,iBAAO,EAAC,YAAY,CAAC;CACnC,CAAC,CAAC;AAEU,QAAA,4CAA4C,GAAG,cAAO,CAAC,kBAA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ACjC,OAAO,EAAE,6BAA6B;YACtC,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC;SACtD,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AA7FY,8DAAyB;AACa;IAA9C,IAAA,kBAAM,EAAC,uCAA6B,CAAC;;mEAAyD;AA+D5E;IADlB,IAAA,yBAAa,GAAE;;;;qDAMf;oCArEQ,yBAAyB;IADrC,IAAA,sBAAU,GAAE;;GACA,yBAAyB,CA6FrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-history-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/ai-history-frontend-module.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAM/D,OAAO,wCAAwC,CAAC;;
|
|
1
|
+
{"version":3,"file":"ai-history-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/ai-history-frontend-module.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAM/D,OAAO,wCAAwC,CAAC;;AAGhD,wBAkBG"}
|
|
@@ -23,6 +23,7 @@ const core_1 = require("@theia/core");
|
|
|
23
23
|
const ai_history_contribution_1 = require("./ai-history-contribution");
|
|
24
24
|
const ai_history_widget_1 = require("./ai-history-widget");
|
|
25
25
|
require("../../src/browser/style/ai-history.css");
|
|
26
|
+
const tab_bar_toolbar_1 = require("@theia/core/lib/browser/shell/tab-bar-toolbar");
|
|
26
27
|
exports.default = new inversify_1.ContainerModule(bind => {
|
|
27
28
|
bind(communication_recording_service_1.DefaultCommunicationRecordingService).toSelf().inSingletonScope();
|
|
28
29
|
bind(ai_core_1.CommunicationRecordingService).toService(communication_recording_service_1.DefaultCommunicationRecordingService);
|
|
@@ -31,10 +32,11 @@ exports.default = new inversify_1.ContainerModule(bind => {
|
|
|
31
32
|
return parentLogger.child('llm-communication-recorder');
|
|
32
33
|
}).inSingletonScope().whenTargetNamed('llm-communication-recorder');
|
|
33
34
|
(0, browser_1.bindViewContribution)(bind, ai_history_contribution_1.AIHistoryViewContribution);
|
|
34
|
-
bind(ai_history_widget_1.AIHistoryView).toSelf()
|
|
35
|
+
bind(ai_history_widget_1.AIHistoryView).toSelf();
|
|
35
36
|
bind(browser_1.WidgetFactory).toDynamicValue(context => ({
|
|
36
37
|
id: ai_history_widget_1.AIHistoryView.ID,
|
|
37
38
|
createWidget: () => context.container.get(ai_history_widget_1.AIHistoryView)
|
|
38
39
|
})).inSingletonScope();
|
|
40
|
+
bind(tab_bar_toolbar_1.TabBarToolbarContribution).toService(ai_history_contribution_1.AIHistoryViewContribution);
|
|
39
41
|
});
|
|
40
42
|
//# sourceMappingURL=ai-history-frontend-module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-history-frontend-module.js","sourceRoot":"","sources":["../../src/browser/ai-history-frontend-module.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;AAChF,4CAA+D;AAC/D,4DAA+D;AAC/D,+FAAiG;AACjG,qDAA8E;AAC9E,sCAAsC;AACtC,uEAAsE;AACtE,2DAAoD;AACpD,kDAAgD;
|
|
1
|
+
{"version":3,"file":"ai-history-frontend-module.js","sourceRoot":"","sources":["../../src/browser/ai-history-frontend-module.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;AAChF,4CAA+D;AAC/D,4DAA+D;AAC/D,+FAAiG;AACjG,qDAA8E;AAC9E,sCAAsC;AACtC,uEAAsE;AACtE,2DAAoD;AACpD,kDAAgD;AAChD,mFAA0F;AAE1F,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACtC,IAAI,CAAC,sEAAoC,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACvE,IAAI,CAAC,uCAA6B,CAAC,CAAC,SAAS,CAAC,sEAAoC,CAAC,CAAC;IAEpF,IAAI,CAAC,cAAO,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;QAC/B,MAAM,YAAY,GAAG,GAAG,CAAC,SAAS,CAAC,GAAG,CAAU,cAAO,CAAC,CAAC;QACzD,OAAO,YAAY,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC,eAAe,CAAC,4BAA4B,CAAC,CAAC;IAEpE,IAAA,8BAAoB,EAAC,IAAI,EAAE,mDAAyB,CAAC,CAAC;IAEtD,IAAI,CAAC,iCAAa,CAAC,CAAC,MAAM,EAAE,CAAC;IAC7B,IAAI,CAAC,uBAAa,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAC3C,EAAE,EAAE,iCAAa,CAAC,EAAE;QACpB,YAAY,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAgB,iCAAa,CAAC;KAC1E,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACvB,IAAI,CAAC,2CAAyB,CAAC,CAAC,SAAS,CAAC,mDAAyB,CAAC,CAAC;AAEzE,CAAC,CAAC,CAAC"}
|
|
@@ -1,19 +1,35 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Agent, AgentService, CommunicationRecordingService, CommunicationRequestEntry, CommunicationResponseEntry } from '@theia/ai-core';
|
|
3
|
-
import { ReactWidget } from '@theia/core/lib/browser';
|
|
3
|
+
import { ReactWidget, StatefulWidget } from '@theia/core/lib/browser';
|
|
4
4
|
import * as React from '@theia/core/shared/react';
|
|
5
|
-
|
|
5
|
+
import { Emitter } from '@theia/core';
|
|
6
|
+
declare namespace AIHistoryView {
|
|
7
|
+
interface State {
|
|
8
|
+
chronological: boolean;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export declare class AIHistoryView extends ReactWidget implements StatefulWidget {
|
|
6
12
|
protected recordingService: CommunicationRecordingService;
|
|
7
13
|
protected readonly agentService: AgentService;
|
|
8
14
|
static ID: string;
|
|
9
15
|
static LABEL: string;
|
|
10
16
|
protected selectedAgent?: Agent;
|
|
17
|
+
protected _state: AIHistoryView.State;
|
|
18
|
+
protected readonly onStateChangedEmitter: Emitter<AIHistoryView.State>;
|
|
19
|
+
readonly onStateChanged: import("@theia/core").Event<AIHistoryView.State>;
|
|
11
20
|
constructor();
|
|
21
|
+
protected get state(): AIHistoryView.State;
|
|
22
|
+
protected set state(state: AIHistoryView.State);
|
|
23
|
+
storeState(): object;
|
|
24
|
+
restoreState(oldState: object & Partial<AIHistoryView.State>): void;
|
|
12
25
|
protected init(): void;
|
|
13
26
|
protected selectAgent(agent: Agent | undefined): void;
|
|
14
27
|
protected historyContentUpdated(entry: CommunicationRequestEntry | CommunicationResponseEntry): void;
|
|
15
28
|
render(): React.ReactNode;
|
|
16
29
|
protected renderHistory(): React.ReactNode;
|
|
17
30
|
protected onClick(e: React.MouseEvent<HTMLDivElement>, agent: Agent): void;
|
|
31
|
+
sortHistory(chronological: boolean): void;
|
|
32
|
+
get isChronological(): boolean;
|
|
18
33
|
}
|
|
34
|
+
export {};
|
|
19
35
|
//# sourceMappingURL=ai-history-widget.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-history-widget.d.ts","sourceRoot":"","sources":["../../src/browser/ai-history-widget.tsx"],"names":[],"mappings":";AAe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,IAAI;IASnE,SAAS,CAAC,IAAI,IAAI,IAAI;IAStB,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,GAAG,IAAI;IAKrD,SAAS,CAAC,qBAAqB,CAAC,KAAK,EAAE,yBAAyB,GAAG,0BAA0B,GAAG,IAAI;IAMpG,MAAM,IAAI,KAAK,CAAC,SAAS;IAsBzB,SAAS,CAAC,aAAa,IAAI,KAAK,CAAC,SAAS;IAc1C,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;IAKnE,WAAW,CAAC,aAAa,EAAE,OAAO,GAAG,IAAI;IAIhD,IAAI,eAAe,IAAI,OAAO,CAE7B;CACJ"}
|
|
@@ -24,19 +24,42 @@ const inversify_1 = require("@theia/core/shared/inversify");
|
|
|
24
24
|
const React = require("@theia/core/shared/react");
|
|
25
25
|
const ai_history_communication_card_1 = require("./ai-history-communication-card");
|
|
26
26
|
const select_component_1 = require("@theia/core/lib/browser/widgets/select-component");
|
|
27
|
+
const core_1 = require("@theia/core");
|
|
27
28
|
let AIHistoryView = AIHistoryView_1 = class AIHistoryView extends browser_1.ReactWidget {
|
|
28
29
|
constructor() {
|
|
29
30
|
super();
|
|
31
|
+
this._state = { chronological: false };
|
|
32
|
+
this.onStateChangedEmitter = new core_1.Emitter();
|
|
33
|
+
this.onStateChanged = this.onStateChangedEmitter.event;
|
|
30
34
|
this.id = AIHistoryView_1.ID;
|
|
31
35
|
this.title.label = AIHistoryView_1.LABEL;
|
|
32
36
|
this.title.caption = AIHistoryView_1.LABEL;
|
|
33
37
|
this.title.closable = true;
|
|
34
38
|
this.title.iconClass = (0, browser_1.codicon)('history');
|
|
35
39
|
}
|
|
40
|
+
get state() {
|
|
41
|
+
return this._state;
|
|
42
|
+
}
|
|
43
|
+
set state(state) {
|
|
44
|
+
this._state = state;
|
|
45
|
+
this.onStateChangedEmitter.fire(this._state);
|
|
46
|
+
}
|
|
47
|
+
storeState() {
|
|
48
|
+
return this.state;
|
|
49
|
+
}
|
|
50
|
+
restoreState(oldState) {
|
|
51
|
+
const copy = (0, core_1.deepClone)(this.state);
|
|
52
|
+
if (oldState.chronological) {
|
|
53
|
+
copy.chronological = oldState.chronological;
|
|
54
|
+
}
|
|
55
|
+
this.state = copy;
|
|
56
|
+
}
|
|
36
57
|
init() {
|
|
37
58
|
this.update();
|
|
38
59
|
this.toDispose.push(this.recordingService.onDidRecordRequest(entry => this.historyContentUpdated(entry)));
|
|
39
60
|
this.toDispose.push(this.recordingService.onDidRecordResponse(entry => this.historyContentUpdated(entry)));
|
|
61
|
+
this.toDispose.push(this.recordingService.onStructuralChange(() => this.update()));
|
|
62
|
+
this.toDispose.push(this.onStateChanged(newState => this.update()));
|
|
40
63
|
this.selectAgent(this.agentService.getAllAgents()[0]);
|
|
41
64
|
}
|
|
42
65
|
selectAgent(agent) {
|
|
@@ -56,26 +79,39 @@ let AIHistoryView = AIHistoryView_1 = class AIHistoryView extends browser_1.Reac
|
|
|
56
79
|
this.update();
|
|
57
80
|
};
|
|
58
81
|
return (React.createElement("div", { className: 'agent-history-widget' },
|
|
59
|
-
React.createElement(select_component_1.SelectComponent, { options: this.agentService.getAllAgents().map(agent => ({
|
|
82
|
+
React.createElement(select_component_1.SelectComponent, { options: this.agentService.getAllAgents().map(agent => ({
|
|
83
|
+
value: agent.id,
|
|
84
|
+
label: agent.name,
|
|
85
|
+
description: agent.description || ''
|
|
86
|
+
})), onChange: selectionChange, defaultValue: (_a = this.selectedAgent) === null || _a === void 0 ? void 0 : _a.id }),
|
|
60
87
|
React.createElement("div", { className: 'agent-history' }, this.renderHistory())));
|
|
61
88
|
}
|
|
62
89
|
renderHistory() {
|
|
63
90
|
if (!this.selectedAgent) {
|
|
64
91
|
return React.createElement("div", { className: 'theia-card no-content' }, "No agent selected.");
|
|
65
92
|
}
|
|
66
|
-
const history = this.recordingService.getHistory(this.selectedAgent.id);
|
|
93
|
+
const history = [...this.recordingService.getHistory(this.selectedAgent.id)];
|
|
67
94
|
if (history.length === 0) {
|
|
68
95
|
return React.createElement("div", { className: 'theia-card no-content' },
|
|
69
96
|
"No history available for the selected agent '",
|
|
70
97
|
this.selectedAgent.name,
|
|
71
98
|
"'.");
|
|
72
99
|
}
|
|
100
|
+
if (!this.state.chronological) {
|
|
101
|
+
history.reverse();
|
|
102
|
+
}
|
|
73
103
|
return history.map(entry => React.createElement(ai_history_communication_card_1.CommunicationCard, { key: entry.requestId, entry: entry }));
|
|
74
104
|
}
|
|
75
105
|
onClick(e, agent) {
|
|
76
106
|
e.stopPropagation();
|
|
77
107
|
this.selectAgent(agent);
|
|
78
108
|
}
|
|
109
|
+
sortHistory(chronological) {
|
|
110
|
+
this.state = { ...(0, core_1.deepClone)(this.state), chronological: chronological };
|
|
111
|
+
}
|
|
112
|
+
get isChronological() {
|
|
113
|
+
return this.state.chronological === true;
|
|
114
|
+
}
|
|
79
115
|
};
|
|
80
116
|
exports.AIHistoryView = AIHistoryView;
|
|
81
117
|
AIHistoryView.ID = 'ai-history-widget';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-history-widget.js","sourceRoot":"","sources":["../../src/browser/ai-history-widget.tsx"],"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;AAChF,4CAA2I;AAC3I,qDAA+
|
|
1
|
+
{"version":3,"file":"ai-history-widget.js","sourceRoot":"","sources":["../../src/browser/ai-history-widget.tsx"],"names":[],"mappings":";;;;;AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,E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AO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,oBAAC,iDAAiB,IAAC,GAAG,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,KAAK,GAAI,CAAC,CAAC;IAC3F,CAAC;IAES,OAAO,CAAC,CAAmC,EAAE,KAAY;QAC/D,CAAC,CAAC,eAAe,EAAE,CAAC;QACpB,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAEM,WAAW,CAAC,aAAsB;QACrC,IAAI,CAAC,KAAK,GAAG,EAAE,GAAG,IAAA,gBAAS,EAAC,IAAI,CAAC,KAAK,CAAC,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;IAC5E,CAAC;IAED,IAAI,eAAe;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC;IAC7C,CAAC;;AAjHQ,sCAAa;AAMR,gBAAE,GAAG,mBAAmB,AAAtB,CAAuB;AAChC,mBAAK,GAAG,mCAAmC,AAAtC,CAAuC;AALzC;IADT,IAAA,kBAAM,EAAC,uCAA6B,CAAC;;uDACoB;AAEvC;IADlB,IAAA,kBAAM,EAAC,sBAAY,CAAC;;mDACyB;AA0CpC;IADT,IAAA,yBAAa,GAAE;;;;yCAQf;wBArDQ,aAAa;IADzB,IAAA,sBAAU,GAAE;;GACA,aAAa,CAkHzB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommunicationHistory,
|
|
1
|
+
import { CommunicationHistory, CommunicationRecordingService, CommunicationRequestEntry, CommunicationRequestEntryParam, CommunicationResponseEntry, CommunicationResponseEntryParam } from '@theia/ai-core';
|
|
2
2
|
import { Emitter, Event, ILogger } from '@theia/core';
|
|
3
3
|
export declare class DefaultCommunicationRecordingService implements CommunicationRecordingService {
|
|
4
4
|
protected logger: ILogger;
|
|
@@ -6,9 +6,13 @@ export declare class DefaultCommunicationRecordingService implements Communicati
|
|
|
6
6
|
readonly onDidRecordRequest: Event<CommunicationRequestEntry>;
|
|
7
7
|
protected onDidRecordResponseEmitter: Emitter<CommunicationResponseEntry>;
|
|
8
8
|
readonly onDidRecordResponse: Event<CommunicationResponseEntry>;
|
|
9
|
+
protected onStructuralChangeEmitter: Emitter<void>;
|
|
10
|
+
readonly onStructuralChange: Event<void>;
|
|
9
11
|
protected history: Map<string, CommunicationHistory>;
|
|
10
12
|
getHistory(agentId: string): CommunicationHistory;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
getSessionHistory(sessionId: string): CommunicationHistory;
|
|
14
|
+
recordRequest(requestEntry: CommunicationRequestEntryParam): void;
|
|
15
|
+
recordResponse(responseEntry: CommunicationResponseEntryParam): void;
|
|
16
|
+
clearHistory(): void;
|
|
13
17
|
}
|
|
14
18
|
//# sourceMappingURL=communication-recording-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"communication-recording-service.d.ts","sourceRoot":"","sources":["../../src/common/communication-recording-service.ts"],"names":[],"mappings":"AAeA,OAAO,
|
|
1
|
+
{"version":3,"file":"communication-recording-service.d.ts","sourceRoot":"","sources":["../../src/common/communication-recording-service.ts"],"names":[],"mappings":"AAeA,OAAO,EACH,oBAAoB,EACpB,6BAA6B,EAC7B,yBAAyB,EACzB,8BAA8B,EAC9B,0BAA0B,EAC1B,+BAA+B,EAClC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGtD,qBACa,oCAAqC,YAAW,6BAA6B;IAGtF,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC;IAE1B,SAAS,CAAC,yBAAyB,qCAA4C;IAC/E,QAAQ,CAAC,kBAAkB,EAAE,KAAK,CAAC,yBAAyB,CAAC,CAAwC;IAErG,SAAS,CAAC,0BAA0B,sCAA6C;IACjF,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC,0BAA0B,CAAC,CAAyC;IAExG,SAAS,CAAC,yBAAyB,gBAAuB;IAC1D,QAAQ,CAAC,kBAAkB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAwC;IAEhF,SAAS,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAa;IAEjE,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB;IAIjD,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,oBAAoB;IAQ1D,aAAa,CAAC,YAAY,EAAE,8BAA8B,GAAG,IAAI;IAWjE,cAAc,CAAC,aAAa,EAAE,+BAA+B,GAAG,IAAI;IAiBpE,YAAY,IAAI,IAAI;CAIvB"}
|
|
@@ -10,37 +10,48 @@ let DefaultCommunicationRecordingService = class DefaultCommunicationRecordingSe
|
|
|
10
10
|
this.onDidRecordRequest = this.onDidRecordRequestEmitter.event;
|
|
11
11
|
this.onDidRecordResponseEmitter = new core_1.Emitter();
|
|
12
12
|
this.onDidRecordResponse = this.onDidRecordResponseEmitter.event;
|
|
13
|
+
this.onStructuralChangeEmitter = new core_1.Emitter();
|
|
14
|
+
this.onStructuralChange = this.onStructuralChangeEmitter.event;
|
|
13
15
|
this.history = new Map();
|
|
14
16
|
}
|
|
15
17
|
getHistory(agentId) {
|
|
16
18
|
return this.history.get(agentId) || [];
|
|
17
19
|
}
|
|
20
|
+
getSessionHistory(sessionId) {
|
|
21
|
+
return Array.from(this.history.values()).reduce((acc, current) => acc.concat(current.filter(entry => entry.sessionId === sessionId)), []);
|
|
22
|
+
}
|
|
18
23
|
recordRequest(requestEntry) {
|
|
19
24
|
var _a;
|
|
20
25
|
this.logger.debug('Recording request:', requestEntry.request);
|
|
26
|
+
const completedEntry = { timestamp: Date.now(), ...requestEntry };
|
|
21
27
|
if (this.history.has(requestEntry.agentId)) {
|
|
22
|
-
(_a = this.history.get(requestEntry.agentId)) === null || _a === void 0 ? void 0 : _a.push(
|
|
28
|
+
(_a = this.history.get(requestEntry.agentId)) === null || _a === void 0 ? void 0 : _a.push(completedEntry);
|
|
23
29
|
}
|
|
24
30
|
else {
|
|
25
|
-
this.history.set(requestEntry.agentId, [
|
|
31
|
+
this.history.set(requestEntry.agentId, [completedEntry]);
|
|
26
32
|
}
|
|
27
|
-
this.onDidRecordRequestEmitter.fire(
|
|
33
|
+
this.onDidRecordRequestEmitter.fire(completedEntry);
|
|
28
34
|
}
|
|
29
35
|
recordResponse(responseEntry) {
|
|
30
36
|
this.logger.debug('Recording response:', responseEntry.response);
|
|
31
|
-
|
|
32
|
-
|
|
37
|
+
const completedEntry = { timestamp: Date.now(), ...responseEntry };
|
|
38
|
+
if (this.history.has(completedEntry.agentId)) {
|
|
39
|
+
const entry = this.history.get(completedEntry.agentId);
|
|
33
40
|
if (entry) {
|
|
34
|
-
const matchingRequest = entry.find(e => e.requestId ===
|
|
41
|
+
const matchingRequest = entry.find(e => e.requestId === completedEntry.requestId);
|
|
35
42
|
if (!matchingRequest) {
|
|
36
43
|
throw Error('No matching request found for response');
|
|
37
44
|
}
|
|
38
|
-
matchingRequest.response =
|
|
39
|
-
matchingRequest.responseTime =
|
|
40
|
-
this.onDidRecordResponseEmitter.fire(
|
|
45
|
+
matchingRequest.response = completedEntry.response;
|
|
46
|
+
matchingRequest.responseTime = completedEntry.timestamp - matchingRequest.timestamp;
|
|
47
|
+
this.onDidRecordResponseEmitter.fire(completedEntry);
|
|
41
48
|
}
|
|
42
49
|
}
|
|
43
50
|
}
|
|
51
|
+
clearHistory() {
|
|
52
|
+
this.history.clear();
|
|
53
|
+
this.onStructuralChangeEmitter.fire(undefined);
|
|
54
|
+
}
|
|
44
55
|
};
|
|
45
56
|
exports.DefaultCommunicationRecordingService = DefaultCommunicationRecordingService;
|
|
46
57
|
tslib_1.__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"communication-recording-service.js","sourceRoot":"","sources":["../../src/common/communication-recording-service.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"communication-recording-service.js","sourceRoot":"","sources":["../../src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QACrB,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACnD,CAAC;CACJ,CAAA;AA5DY,oFAAoC;AAGnC;IADT,IAAA,kBAAM,EAAC,cAAO,CAAC;IAAE,IAAA,iBAAK,EAAC,4BAA4B,CAAC;;oEAC3B;+CAHjB,oCAAoC;IADhD,IAAA,sBAAU,GAAE;GACA,oCAAoC,CA4DhD"}
|
|
@@ -15,5 +15,27 @@ describe('DefaultCommunicationRecordingService', () => {
|
|
|
15
15
|
(0, chai_1.expect)(history2[0].request).to.eq('dummy request');
|
|
16
16
|
(0, chai_1.expect)(history2[0].response).to.eq('dummy response');
|
|
17
17
|
});
|
|
18
|
+
it('returns session history', () => {
|
|
19
|
+
const service = new communication_recording_service_1.DefaultCommunicationRecordingService();
|
|
20
|
+
service.logger = new mock_logger_1.MockLogger();
|
|
21
|
+
// some requests and responses for session 1
|
|
22
|
+
service.recordRequest({ agentId: 'agent', requestId: '1', sessionId: '1', timestamp: 100, request: 'session 1 request 1' });
|
|
23
|
+
service.recordResponse({ agentId: 'agent', requestId: '1', sessionId: '1', timestamp: 200, response: 'session 1 response 1' });
|
|
24
|
+
service.recordRequest({ agentId: 'agent2', requestId: '2', sessionId: '1', timestamp: 100, request: 'session 1 request 2' });
|
|
25
|
+
service.recordResponse({ agentId: 'agent2', requestId: '2', sessionId: '1', timestamp: 200, response: 'session 1 response 2' });
|
|
26
|
+
// some requests and responses for session 2
|
|
27
|
+
service.recordRequest({ agentId: 'agent', requestId: '3', sessionId: '2', timestamp: 100, request: 'different session request' });
|
|
28
|
+
service.recordResponse({ agentId: 'agent', requestId: '3', sessionId: '2', timestamp: 200, response: 'different session request' });
|
|
29
|
+
const history1 = service.getSessionHistory('1');
|
|
30
|
+
(0, chai_1.expect)(history1.length).to.eq(2);
|
|
31
|
+
(0, chai_1.expect)(history1[0].request).to.eq('session 1 request 1');
|
|
32
|
+
(0, chai_1.expect)(history1[0].response).to.eq('session 1 response 1');
|
|
33
|
+
(0, chai_1.expect)(history1[1].request).to.eq('session 1 request 2');
|
|
34
|
+
(0, chai_1.expect)(history1[1].response).to.eq('session 1 response 2');
|
|
35
|
+
const history2 = service.getSessionHistory('2');
|
|
36
|
+
(0, chai_1.expect)(history2.length).to.eq(1);
|
|
37
|
+
(0, chai_1.expect)(history2[0].request).to.eq('different session request');
|
|
38
|
+
(0, chai_1.expect)(history2[0].response).to.eq('different session request');
|
|
39
|
+
});
|
|
18
40
|
});
|
|
19
41
|
//# sourceMappingURL=communication-recording-service.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"communication-recording-service.spec.js","sourceRoot":"","sources":["../../src/common/communication-recording-service.spec.ts"],"names":[],"mappings":";;AAgBA,yEAAqE;AACrE,uFAAyF;AACzF,+BAA8B;AAE9B,QAAQ,CAAC,sCAAsC,EAAE,GAAG,EAAE;IAElD,EAAE,CAAC,iBAAiB,EAAE,GAAG,EAAE;QACvB,MAAM,OAAO,GAAG,IAAI,sEAAoC,EAAE,CAAC;QAC1D,OAA0C,CAAC,MAAM,GAAG,IAAI,wBAAU,EAAE,CAAC;QACtE,OAAO,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC;QAEtH,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC7C,IAAA,aAAM,EAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC;QAEnD,OAAO,CAAC,cAAc,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC,CAAC;QACzH,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC7C,IAAA,aAAM,EAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC;QACnD,IAAA,aAAM,EAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AAEP,CAAC,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"communication-recording-service.spec.js","sourceRoot":"","sources":["../../src/common/communication-recording-service.spec.ts"],"names":[],"mappings":";;AAgBA,yEAAqE;AACrE,uFAAyF;AACzF,+BAA8B;AAE9B,QAAQ,CAAC,sCAAsC,EAAE,GAAG,EAAE;IAElD,EAAE,CAAC,iBAAiB,EAAE,GAAG,EAAE;QACvB,MAAM,OAAO,GAAG,IAAI,sEAAoC,EAAE,CAAC;QAC1D,OAA0C,CAAC,MAAM,GAAG,IAAI,wBAAU,EAAE,CAAC;QACtE,OAAO,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC;QAEtH,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC7C,IAAA,aAAM,EAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC;QAEnD,OAAO,CAAC,cAAc,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC,CAAC;QACzH,MAAM,Q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QAC/D,IAAA,aAAM,EAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,2BAA2B,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;AAEP,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/ai-history",
|
|
3
|
-
"version": "1.55.0-next.
|
|
3
|
+
"version": "1.55.0-next.67+8664face6",
|
|
4
4
|
"description": "Theia - AI communication history",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/ai-core": "1.55.0-next.
|
|
7
|
-
"@theia/core": "1.55.0-next.
|
|
8
|
-
"@theia/filesystem": "1.55.0-next.
|
|
9
|
-
"@theia/output": "1.55.0-next.
|
|
10
|
-
"@theia/workspace": "1.55.0-next.
|
|
6
|
+
"@theia/ai-core": "1.55.0-next.67+8664face6",
|
|
7
|
+
"@theia/core": "1.55.0-next.67+8664face6",
|
|
8
|
+
"@theia/filesystem": "1.55.0-next.67+8664face6",
|
|
9
|
+
"@theia/output": "1.55.0-next.67+8664face6",
|
|
10
|
+
"@theia/workspace": "1.55.0-next.67+8664face6",
|
|
11
11
|
"minimatch": "^5.1.0",
|
|
12
12
|
"tslib": "^2.6.2"
|
|
13
13
|
},
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"watch": "theiaext watch"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@theia/ext-scripts": "1.
|
|
48
|
+
"@theia/ext-scripts": "1.55.0"
|
|
49
49
|
},
|
|
50
50
|
"nyc": {
|
|
51
51
|
"extends": "../../configs/nyc.json"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "8664face680c050b8d544a381645259b6821a634"
|
|
54
54
|
}
|
|
@@ -29,16 +29,39 @@ export const CommunicationCard: React.FC<CommunicationCardProps> = ({ entry }) =
|
|
|
29
29
|
<div className='theia-card-content'>
|
|
30
30
|
{entry.request && (
|
|
31
31
|
<div className='theia-card-request'>
|
|
32
|
-
<
|
|
32
|
+
<h2>Request</h2>
|
|
33
33
|
<pre>{entry.request}</pre>
|
|
34
34
|
</div>
|
|
35
35
|
)}
|
|
36
36
|
{entry.response && (
|
|
37
37
|
<div className='theia-card-response'>
|
|
38
|
-
<
|
|
38
|
+
<h2>Response</h2>
|
|
39
39
|
<pre>{entry.response}</pre>
|
|
40
40
|
</div>
|
|
41
41
|
)}
|
|
42
|
+
{(entry.systemMessage || (entry.messages && entry.messages.length > 0)) && (
|
|
43
|
+
<div className='theia-card-context'>
|
|
44
|
+
<details>
|
|
45
|
+
<summary><h2>Context</h2></summary>
|
|
46
|
+
{(entry.systemMessage && (
|
|
47
|
+
<div className='theia-context-system-message'>
|
|
48
|
+
<h3>System Message</h3>
|
|
49
|
+
<pre>{entry.systemMessage}</pre>
|
|
50
|
+
</div>
|
|
51
|
+
))}
|
|
52
|
+
{(entry.messages && entry.messages.length > 0) && (
|
|
53
|
+
<div className='theia-context-messages'>
|
|
54
|
+
<h3>Messages</h3>
|
|
55
|
+
<ul>
|
|
56
|
+
{entry.messages.map((message, index) => (
|
|
57
|
+
<li key={index}><pre>{JSON.stringify(message, undefined, 2)}</pre></li>
|
|
58
|
+
))}
|
|
59
|
+
</ul>
|
|
60
|
+
</div>
|
|
61
|
+
)}
|
|
62
|
+
</details>
|
|
63
|
+
</div>
|
|
64
|
+
)}
|
|
42
65
|
</div>
|
|
43
66
|
<div className='theia-card-meta'>
|
|
44
67
|
<span className='theia-card-timestamp'>Timestamp: {new Date(entry.timestamp).toLocaleString()}</span>
|
|
@@ -13,11 +13,13 @@
|
|
|
13
13
|
//
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
|
-
import { FrontendApplication } from '@theia/core/lib/browser';
|
|
16
|
+
import { FrontendApplication, codicon } from '@theia/core/lib/browser';
|
|
17
17
|
import { AIViewContribution } from '@theia/ai-core/lib/browser';
|
|
18
|
-
import { injectable } from '@theia/core/shared/inversify';
|
|
18
|
+
import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
19
19
|
import { AIHistoryView } from './ai-history-widget';
|
|
20
|
-
import { Command, CommandRegistry } from '@theia/core';
|
|
20
|
+
import { Command, CommandRegistry, Emitter } from '@theia/core';
|
|
21
|
+
import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
|
22
|
+
import { CommunicationRecordingService } from '@theia/ai-core';
|
|
21
23
|
|
|
22
24
|
export const AI_HISTORY_TOGGLE_COMMAND_ID = 'aiHistory:toggle';
|
|
23
25
|
export const OPEN_AI_HISTORY_VIEW = Command.toLocalizedCommand({
|
|
@@ -25,8 +27,28 @@ export const OPEN_AI_HISTORY_VIEW = Command.toLocalizedCommand({
|
|
|
25
27
|
label: 'Open AI History view',
|
|
26
28
|
});
|
|
27
29
|
|
|
30
|
+
export const AI_HISTORY_VIEW_SORT_CHRONOLOGICALLY = Command.toLocalizedCommand({
|
|
31
|
+
id: 'aiHistory:sortChronologically',
|
|
32
|
+
label: 'AI History: Sort chronologically',
|
|
33
|
+
iconClass: codicon('arrow-down')
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const AI_HISTORY_VIEW_SORT_REVERSE_CHRONOLOGICALLY = Command.toLocalizedCommand({
|
|
37
|
+
id: 'aiHistory:sortReverseChronologically',
|
|
38
|
+
label: 'AI History: Sort reverse chronologically',
|
|
39
|
+
iconClass: codicon('arrow-up')
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export const AI_HISTORY_VIEW_CLEAR = Command.toLocalizedCommand({
|
|
43
|
+
id: 'aiHistory:clear',
|
|
44
|
+
label: 'AI History: Clear History',
|
|
45
|
+
iconClass: codicon('clear-all')
|
|
46
|
+
});
|
|
47
|
+
|
|
28
48
|
@injectable()
|
|
29
|
-
export class AIHistoryViewContribution extends AIViewContribution<AIHistoryView> {
|
|
49
|
+
export class AIHistoryViewContribution extends AIViewContribution<AIHistoryView> implements TabBarToolbarContribution {
|
|
50
|
+
@inject(CommunicationRecordingService) private recordingService: CommunicationRecordingService;
|
|
51
|
+
|
|
30
52
|
constructor() {
|
|
31
53
|
super({
|
|
32
54
|
widgetId: AIHistoryView.ID,
|
|
@@ -43,10 +65,78 @@ export class AIHistoryViewContribution extends AIViewContribution<AIHistoryView>
|
|
|
43
65
|
await this.openView();
|
|
44
66
|
}
|
|
45
67
|
|
|
46
|
-
override registerCommands(
|
|
47
|
-
super.registerCommands(
|
|
48
|
-
|
|
68
|
+
override registerCommands(registry: CommandRegistry): void {
|
|
69
|
+
super.registerCommands(registry);
|
|
70
|
+
registry.registerCommand(OPEN_AI_HISTORY_VIEW, {
|
|
49
71
|
execute: () => this.openView({ activate: true }),
|
|
50
72
|
});
|
|
73
|
+
registry.registerCommand(AI_HISTORY_VIEW_SORT_CHRONOLOGICALLY, {
|
|
74
|
+
isEnabled: widget => this.withHistoryWidget(widget, historyView => !historyView.isChronological),
|
|
75
|
+
isVisible: widget => this.withHistoryWidget(widget, historyView => !historyView.isChronological),
|
|
76
|
+
execute: widget => this.withHistoryWidget(widget, historyView => {
|
|
77
|
+
historyView.sortHistory(true);
|
|
78
|
+
return true;
|
|
79
|
+
})
|
|
80
|
+
});
|
|
81
|
+
registry.registerCommand(AI_HISTORY_VIEW_SORT_REVERSE_CHRONOLOGICALLY, {
|
|
82
|
+
isEnabled: widget => this.withHistoryWidget(widget, historyView => historyView.isChronological),
|
|
83
|
+
isVisible: widget => this.withHistoryWidget(widget, historyView => historyView.isChronological),
|
|
84
|
+
execute: widget => this.withHistoryWidget(widget, historyView => {
|
|
85
|
+
historyView.sortHistory(false);
|
|
86
|
+
return true;
|
|
87
|
+
})
|
|
88
|
+
});
|
|
89
|
+
registry.registerCommand(AI_HISTORY_VIEW_CLEAR, {
|
|
90
|
+
isEnabled: widget => this.withHistoryWidget(widget),
|
|
91
|
+
isVisible: widget => this.withHistoryWidget(widget),
|
|
92
|
+
execute: widget => this.withHistoryWidget(widget, () => {
|
|
93
|
+
this.clearHistory();
|
|
94
|
+
return true;
|
|
95
|
+
})
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
public clearHistory(): void {
|
|
99
|
+
this.recordingService.clearHistory();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
protected withHistoryWidget(
|
|
103
|
+
widget: unknown = this.tryGetWidget(),
|
|
104
|
+
predicate: (output: AIHistoryView) => boolean = () => true
|
|
105
|
+
): boolean | false {
|
|
106
|
+
return widget instanceof AIHistoryView ? predicate(widget) : false;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
protected readonly onAIHistoryWidgetStateChangedEmitter = new Emitter<void>();
|
|
110
|
+
protected readonly onAIHistoryWidgettStateChanged = this.onAIHistoryWidgetStateChangedEmitter.event;
|
|
111
|
+
|
|
112
|
+
@postConstruct()
|
|
113
|
+
protected override init(): void {
|
|
114
|
+
super.init();
|
|
115
|
+
this.widget.then(widget => {
|
|
116
|
+
widget.onStateChanged(() => this.onAIHistoryWidgetStateChangedEmitter.fire());
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
registerToolbarItems(registry: TabBarToolbarRegistry): void {
|
|
121
|
+
registry.registerItem({
|
|
122
|
+
id: AI_HISTORY_VIEW_SORT_CHRONOLOGICALLY.id,
|
|
123
|
+
command: AI_HISTORY_VIEW_SORT_CHRONOLOGICALLY.id,
|
|
124
|
+
tooltip: 'Sort chronologically',
|
|
125
|
+
isVisible: widget => this.withHistoryWidget(widget),
|
|
126
|
+
onDidChange: this.onAIHistoryWidgettStateChanged
|
|
127
|
+
});
|
|
128
|
+
registry.registerItem({
|
|
129
|
+
id: AI_HISTORY_VIEW_SORT_REVERSE_CHRONOLOGICALLY.id,
|
|
130
|
+
command: AI_HISTORY_VIEW_SORT_REVERSE_CHRONOLOGICALLY.id,
|
|
131
|
+
tooltip: 'Sort reverse chronologically',
|
|
132
|
+
isVisible: widget => this.withHistoryWidget(widget),
|
|
133
|
+
onDidChange: this.onAIHistoryWidgettStateChanged
|
|
134
|
+
});
|
|
135
|
+
registry.registerItem({
|
|
136
|
+
id: AI_HISTORY_VIEW_CLEAR.id,
|
|
137
|
+
command: AI_HISTORY_VIEW_CLEAR.id,
|
|
138
|
+
tooltip: 'Clear History of all agents',
|
|
139
|
+
isVisible: widget => this.withHistoryWidget(widget)
|
|
140
|
+
});
|
|
51
141
|
}
|
|
52
142
|
}
|
|
@@ -21,6 +21,7 @@ import { ILogger } from '@theia/core';
|
|
|
21
21
|
import { AIHistoryViewContribution } from './ai-history-contribution';
|
|
22
22
|
import { AIHistoryView } from './ai-history-widget';
|
|
23
23
|
import '../../src/browser/style/ai-history.css';
|
|
24
|
+
import { TabBarToolbarContribution } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
|
24
25
|
|
|
25
26
|
export default new ContainerModule(bind => {
|
|
26
27
|
bind(DefaultCommunicationRecordingService).toSelf().inSingletonScope();
|
|
@@ -33,9 +34,11 @@ export default new ContainerModule(bind => {
|
|
|
33
34
|
|
|
34
35
|
bindViewContribution(bind, AIHistoryViewContribution);
|
|
35
36
|
|
|
36
|
-
bind(AIHistoryView).toSelf()
|
|
37
|
+
bind(AIHistoryView).toSelf();
|
|
37
38
|
bind(WidgetFactory).toDynamicValue(context => ({
|
|
38
39
|
id: AIHistoryView.ID,
|
|
39
40
|
createWidget: () => context.container.get<AIHistoryView>(AIHistoryView)
|
|
40
41
|
})).inSingletonScope();
|
|
42
|
+
bind(TabBarToolbarContribution).toService(AIHistoryViewContribution);
|
|
43
|
+
|
|
41
44
|
});
|
|
@@ -14,14 +14,21 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
import { Agent, AgentService, CommunicationRecordingService, CommunicationRequestEntry, CommunicationResponseEntry } from '@theia/ai-core';
|
|
17
|
-
import { codicon, ReactWidget } from '@theia/core/lib/browser';
|
|
17
|
+
import { codicon, ReactWidget, StatefulWidget } from '@theia/core/lib/browser';
|
|
18
18
|
import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
19
19
|
import * as React from '@theia/core/shared/react';
|
|
20
20
|
import { CommunicationCard } from './ai-history-communication-card';
|
|
21
21
|
import { SelectComponent, SelectOption } from '@theia/core/lib/browser/widgets/select-component';
|
|
22
|
+
import { deepClone, Emitter } from '@theia/core';
|
|
23
|
+
|
|
24
|
+
namespace AIHistoryView {
|
|
25
|
+
export interface State {
|
|
26
|
+
chronological: boolean;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
22
29
|
|
|
23
30
|
@injectable()
|
|
24
|
-
export class AIHistoryView extends ReactWidget {
|
|
31
|
+
export class AIHistoryView extends ReactWidget implements StatefulWidget {
|
|
25
32
|
@inject(CommunicationRecordingService)
|
|
26
33
|
protected recordingService: CommunicationRecordingService;
|
|
27
34
|
@inject(AgentService)
|
|
@@ -32,6 +39,10 @@ export class AIHistoryView extends ReactWidget {
|
|
|
32
39
|
|
|
33
40
|
protected selectedAgent?: Agent;
|
|
34
41
|
|
|
42
|
+
protected _state: AIHistoryView.State = { chronological: false };
|
|
43
|
+
protected readonly onStateChangedEmitter = new Emitter<AIHistoryView.State>();
|
|
44
|
+
readonly onStateChanged = this.onStateChangedEmitter.event;
|
|
45
|
+
|
|
35
46
|
constructor() {
|
|
36
47
|
super();
|
|
37
48
|
this.id = AIHistoryView.ID;
|
|
@@ -41,11 +52,34 @@ export class AIHistoryView extends ReactWidget {
|
|
|
41
52
|
this.title.iconClass = codicon('history');
|
|
42
53
|
}
|
|
43
54
|
|
|
55
|
+
protected get state(): AIHistoryView.State {
|
|
56
|
+
return this._state;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
protected set state(state: AIHistoryView.State) {
|
|
60
|
+
this._state = state;
|
|
61
|
+
this.onStateChangedEmitter.fire(this._state);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
storeState(): object {
|
|
65
|
+
return this.state;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
restoreState(oldState: object & Partial<AIHistoryView.State>): void {
|
|
69
|
+
const copy = deepClone(this.state);
|
|
70
|
+
if (oldState.chronological) {
|
|
71
|
+
copy.chronological = oldState.chronological;
|
|
72
|
+
}
|
|
73
|
+
this.state = copy;
|
|
74
|
+
}
|
|
75
|
+
|
|
44
76
|
@postConstruct()
|
|
45
77
|
protected init(): void {
|
|
46
78
|
this.update();
|
|
47
79
|
this.toDispose.push(this.recordingService.onDidRecordRequest(entry => this.historyContentUpdated(entry)));
|
|
48
80
|
this.toDispose.push(this.recordingService.onDidRecordResponse(entry => this.historyContentUpdated(entry)));
|
|
81
|
+
this.toDispose.push(this.recordingService.onStructuralChange(() => this.update()));
|
|
82
|
+
this.toDispose.push(this.onStateChanged(newState => this.update()));
|
|
49
83
|
this.selectAgent(this.agentService.getAllAgents()[0]);
|
|
50
84
|
}
|
|
51
85
|
|
|
@@ -68,13 +102,17 @@ export class AIHistoryView extends ReactWidget {
|
|
|
68
102
|
return (
|
|
69
103
|
<div className='agent-history-widget'>
|
|
70
104
|
<SelectComponent
|
|
71
|
-
options={this.agentService.getAllAgents().map(agent => ({
|
|
105
|
+
options={this.agentService.getAllAgents().map(agent => ({
|
|
106
|
+
value: agent.id,
|
|
107
|
+
label: agent.name,
|
|
108
|
+
description: agent.description || ''
|
|
109
|
+
}))}
|
|
72
110
|
onChange={selectionChange}
|
|
73
111
|
defaultValue={this.selectedAgent?.id} />
|
|
74
112
|
<div className='agent-history'>
|
|
75
113
|
{this.renderHistory()}
|
|
76
114
|
</div>
|
|
77
|
-
</div
|
|
115
|
+
</div>
|
|
78
116
|
);
|
|
79
117
|
}
|
|
80
118
|
|
|
@@ -82,10 +120,13 @@ export class AIHistoryView extends ReactWidget {
|
|
|
82
120
|
if (!this.selectedAgent) {
|
|
83
121
|
return <div className='theia-card no-content'>No agent selected.</div>;
|
|
84
122
|
}
|
|
85
|
-
const history = this.recordingService.getHistory(this.selectedAgent.id);
|
|
123
|
+
const history = [...this.recordingService.getHistory(this.selectedAgent.id)];
|
|
86
124
|
if (history.length === 0) {
|
|
87
125
|
return <div className='theia-card no-content'>No history available for the selected agent '{this.selectedAgent.name}'.</div>;
|
|
88
126
|
}
|
|
127
|
+
if (!this.state.chronological) {
|
|
128
|
+
history.reverse();
|
|
129
|
+
}
|
|
89
130
|
return history.map(entry => <CommunicationCard key={entry.requestId} entry={entry} />);
|
|
90
131
|
}
|
|
91
132
|
|
|
@@ -93,4 +134,12 @@ export class AIHistoryView extends ReactWidget {
|
|
|
93
134
|
e.stopPropagation();
|
|
94
135
|
this.selectAgent(agent);
|
|
95
136
|
}
|
|
137
|
+
|
|
138
|
+
public sortHistory(chronological: boolean): void {
|
|
139
|
+
this.state = { ...deepClone(this.state), chronological: chronological };
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
get isChronological(): boolean {
|
|
143
|
+
return this.state.chronological === true;
|
|
144
|
+
}
|
|
96
145
|
}
|
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
display: flex;
|
|
32
32
|
justify-content: space-between;
|
|
33
33
|
font-size: 0.9em;
|
|
34
|
-
margin-bottom: var(--theia-ui-padding);
|
|
35
34
|
padding: var(--theia-ui-padding) 0;
|
|
36
35
|
}
|
|
37
36
|
|
|
@@ -40,6 +39,24 @@
|
|
|
40
39
|
margin-bottom: 10px;
|
|
41
40
|
}
|
|
42
41
|
|
|
42
|
+
.theia-card-content h2 {
|
|
43
|
+
font-size: var(--theia-ui-font-size2);
|
|
44
|
+
}
|
|
45
|
+
.theia-card-content h3 {
|
|
46
|
+
font-size: var(--theia-ui-font-size1);
|
|
47
|
+
font-weight: bold;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.theia-card-content .theia-card-context h2 {
|
|
51
|
+
display: inline;
|
|
52
|
+
}
|
|
53
|
+
.theia-card-content .theia-card-context ul {
|
|
54
|
+
padding-inline-start: 20px;
|
|
55
|
+
}
|
|
56
|
+
.theia-card-content .theia-card-context pre {
|
|
57
|
+
overflow: scroll;
|
|
58
|
+
}
|
|
59
|
+
|
|
43
60
|
.theia-card-content p {
|
|
44
61
|
margin: var(--theia-ui-padding) 0;
|
|
45
62
|
}
|
|
@@ -34,4 +34,29 @@ describe('DefaultCommunicationRecordingService', () => {
|
|
|
34
34
|
expect(history2[0].response).to.eq('dummy response');
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
+
it('returns session history', () => {
|
|
38
|
+
const service = new DefaultCommunicationRecordingService();
|
|
39
|
+
(service as unknown as { logger: ILogger }).logger = new MockLogger();
|
|
40
|
+
// some requests and responses for session 1
|
|
41
|
+
service.recordRequest({ agentId: 'agent', requestId: '1', sessionId: '1', timestamp: 100, request: 'session 1 request 1' });
|
|
42
|
+
service.recordResponse({ agentId: 'agent', requestId: '1', sessionId: '1', timestamp: 200, response: 'session 1 response 1' });
|
|
43
|
+
service.recordRequest({ agentId: 'agent2', requestId: '2', sessionId: '1', timestamp: 100, request: 'session 1 request 2' });
|
|
44
|
+
service.recordResponse({ agentId: 'agent2', requestId: '2', sessionId: '1', timestamp: 200, response: 'session 1 response 2' });
|
|
45
|
+
// some requests and responses for session 2
|
|
46
|
+
service.recordRequest({ agentId: 'agent', requestId: '3', sessionId: '2', timestamp: 100, request: 'different session request' });
|
|
47
|
+
service.recordResponse({ agentId: 'agent', requestId: '3', sessionId: '2', timestamp: 200, response: 'different session request' });
|
|
48
|
+
|
|
49
|
+
const history1 = service.getSessionHistory('1');
|
|
50
|
+
expect(history1.length).to.eq(2);
|
|
51
|
+
expect(history1[0].request).to.eq('session 1 request 1');
|
|
52
|
+
expect(history1[0].response).to.eq('session 1 response 1');
|
|
53
|
+
expect(history1[1].request).to.eq('session 1 request 2');
|
|
54
|
+
expect(history1[1].response).to.eq('session 1 response 2');
|
|
55
|
+
|
|
56
|
+
const history2 = service.getSessionHistory('2');
|
|
57
|
+
expect(history2.length).to.eq(1);
|
|
58
|
+
expect(history2[0].request).to.eq('different session request');
|
|
59
|
+
expect(history2[0].response).to.eq('different session request');
|
|
60
|
+
});
|
|
61
|
+
|
|
37
62
|
});
|
|
@@ -13,7 +13,14 @@
|
|
|
13
13
|
//
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
CommunicationHistory,
|
|
18
|
+
CommunicationRecordingService,
|
|
19
|
+
CommunicationRequestEntry,
|
|
20
|
+
CommunicationRequestEntryParam,
|
|
21
|
+
CommunicationResponseEntry,
|
|
22
|
+
CommunicationResponseEntryParam
|
|
23
|
+
} from '@theia/ai-core';
|
|
17
24
|
import { Emitter, Event, ILogger } from '@theia/core';
|
|
18
25
|
import { inject, injectable, named } from '@theia/core/shared/inversify';
|
|
19
26
|
|
|
@@ -29,35 +36,53 @@ export class DefaultCommunicationRecordingService implements CommunicationRecord
|
|
|
29
36
|
protected onDidRecordResponseEmitter = new Emitter<CommunicationResponseEntry>();
|
|
30
37
|
readonly onDidRecordResponse: Event<CommunicationResponseEntry> = this.onDidRecordResponseEmitter.event;
|
|
31
38
|
|
|
39
|
+
protected onStructuralChangeEmitter = new Emitter<void>();
|
|
40
|
+
readonly onStructuralChange: Event<void> = this.onStructuralChangeEmitter.event;
|
|
41
|
+
|
|
32
42
|
protected history: Map<string, CommunicationHistory> = new Map();
|
|
33
43
|
|
|
34
44
|
getHistory(agentId: string): CommunicationHistory {
|
|
35
45
|
return this.history.get(agentId) || [];
|
|
36
46
|
}
|
|
37
47
|
|
|
38
|
-
|
|
48
|
+
getSessionHistory(sessionId: string): CommunicationHistory {
|
|
49
|
+
return Array.from(
|
|
50
|
+
this.history.values()
|
|
51
|
+
).reduce((acc, current) =>
|
|
52
|
+
acc.concat(current.filter(entry => entry.sessionId === sessionId)), []
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
recordRequest(requestEntry: CommunicationRequestEntryParam): void {
|
|
39
57
|
this.logger.debug('Recording request:', requestEntry.request);
|
|
58
|
+
const completedEntry = { timestamp: Date.now(), ...requestEntry };
|
|
40
59
|
if (this.history.has(requestEntry.agentId)) {
|
|
41
|
-
this.history.get(requestEntry.agentId)?.push(
|
|
60
|
+
this.history.get(requestEntry.agentId)?.push(completedEntry);
|
|
42
61
|
} else {
|
|
43
|
-
this.history.set(requestEntry.agentId, [
|
|
62
|
+
this.history.set(requestEntry.agentId, [completedEntry]);
|
|
44
63
|
}
|
|
45
|
-
this.onDidRecordRequestEmitter.fire(
|
|
64
|
+
this.onDidRecordRequestEmitter.fire(completedEntry);
|
|
46
65
|
}
|
|
47
66
|
|
|
48
|
-
recordResponse(responseEntry:
|
|
67
|
+
recordResponse(responseEntry: CommunicationResponseEntryParam): void {
|
|
49
68
|
this.logger.debug('Recording response:', responseEntry.response);
|
|
50
|
-
|
|
51
|
-
|
|
69
|
+
const completedEntry = { timestamp: Date.now(), ...responseEntry };
|
|
70
|
+
if (this.history.has(completedEntry.agentId)) {
|
|
71
|
+
const entry = this.history.get(completedEntry.agentId);
|
|
52
72
|
if (entry) {
|
|
53
|
-
const matchingRequest = entry.find(e => e.requestId ===
|
|
73
|
+
const matchingRequest = entry.find(e => e.requestId === completedEntry.requestId);
|
|
54
74
|
if (!matchingRequest) {
|
|
55
75
|
throw Error('No matching request found for response');
|
|
56
76
|
}
|
|
57
|
-
matchingRequest.response =
|
|
58
|
-
matchingRequest.responseTime =
|
|
59
|
-
this.onDidRecordResponseEmitter.fire(
|
|
77
|
+
matchingRequest.response = completedEntry.response;
|
|
78
|
+
matchingRequest.responseTime = completedEntry.timestamp - matchingRequest.timestamp;
|
|
79
|
+
this.onDidRecordResponseEmitter.fire(completedEntry);
|
|
60
80
|
}
|
|
61
81
|
}
|
|
62
82
|
}
|
|
83
|
+
|
|
84
|
+
clearHistory(): void {
|
|
85
|
+
this.history.clear();
|
|
86
|
+
this.onStructuralChangeEmitter.fire(undefined);
|
|
87
|
+
}
|
|
63
88
|
}
|