@theia/ai-external-api 1.76.0-next.33
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 +83 -0
- package/lib/browser/ai-external-api-frontend-contribution.d.ts +28 -0
- package/lib/browser/ai-external-api-frontend-contribution.d.ts.map +1 -0
- package/lib/browser/ai-external-api-frontend-contribution.js +88 -0
- package/lib/browser/ai-external-api-frontend-contribution.js.map +1 -0
- package/lib/browser/ai-external-api-frontend-contribution.spec.d.ts +2 -0
- package/lib/browser/ai-external-api-frontend-contribution.spec.d.ts.map +1 -0
- package/lib/browser/ai-external-api-frontend-contribution.spec.js +102 -0
- package/lib/browser/ai-external-api-frontend-contribution.spec.js.map +1 -0
- package/lib/browser/ai-external-api-frontend-module.d.ts +4 -0
- package/lib/browser/ai-external-api-frontend-module.d.ts.map +1 -0
- package/lib/browser/ai-external-api-frontend-module.js +47 -0
- package/lib/browser/ai-external-api-frontend-module.js.map +1 -0
- package/lib/browser/frontend-external-chat-session-provider.d.ts +63 -0
- package/lib/browser/frontend-external-chat-session-provider.d.ts.map +1 -0
- package/lib/browser/frontend-external-chat-session-provider.js +271 -0
- package/lib/browser/frontend-external-chat-session-provider.js.map +1 -0
- package/lib/browser/frontend-external-chat-session-provider.spec.d.ts +2 -0
- package/lib/browser/frontend-external-chat-session-provider.spec.d.ts.map +1 -0
- package/lib/browser/frontend-external-chat-session-provider.spec.js +421 -0
- package/lib/browser/frontend-external-chat-session-provider.spec.js.map +1 -0
- package/lib/browser/index.d.ts +3 -0
- package/lib/browser/index.d.ts.map +1 -0
- package/lib/browser/index.js +21 -0
- package/lib/browser/index.js.map +1 -0
- package/lib/common/external-chat-session-provider.d.ts +213 -0
- package/lib/common/external-chat-session-provider.d.ts.map +1 -0
- package/lib/common/external-chat-session-provider.js +147 -0
- package/lib/common/external-chat-session-provider.js.map +1 -0
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.d.ts.map +1 -0
- package/lib/common/index.js +20 -0
- package/lib/common/index.js.map +1 -0
- package/lib/node/ai-external-api-backend-module.d.ts +4 -0
- package/lib/node/ai-external-api-backend-module.d.ts.map +1 -0
- package/lib/node/ai-external-api-backend-module.js +38 -0
- package/lib/node/ai-external-api-backend-module.js.map +1 -0
- package/lib/node/ai-external-api-endpoint.d.ts +31 -0
- package/lib/node/ai-external-api-endpoint.d.ts.map +1 -0
- package/lib/node/ai-external-api-endpoint.js +189 -0
- package/lib/node/ai-external-api-endpoint.js.map +1 -0
- package/lib/node/ai-external-api-endpoint.spec.d.ts +2 -0
- package/lib/node/ai-external-api-endpoint.spec.d.ts.map +1 -0
- package/lib/node/ai-external-api-endpoint.spec.js +233 -0
- package/lib/node/ai-external-api-endpoint.spec.js.map +1 -0
- package/lib/node/external-chat-session-registry.d.ts +83 -0
- package/lib/node/external-chat-session-registry.d.ts.map +1 -0
- package/lib/node/external-chat-session-registry.js +266 -0
- package/lib/node/external-chat-session-registry.js.map +1 -0
- package/lib/node/external-chat-session-registry.spec.d.ts +2 -0
- package/lib/node/external-chat-session-registry.spec.d.ts.map +1 -0
- package/lib/node/external-chat-session-registry.spec.js +366 -0
- package/lib/node/external-chat-session-registry.spec.js.map +1 -0
- package/lib/node/index.d.ts +3 -0
- package/lib/node/index.d.ts.map +1 -0
- package/lib/node/index.js +21 -0
- package/lib/node/index.js.map +1 -0
- package/package.json +52 -0
- package/src/browser/ai-external-api-frontend-contribution.spec.ts +128 -0
- package/src/browser/ai-external-api-frontend-contribution.ts +90 -0
- package/src/browser/ai-external-api-frontend-module.ts +48 -0
- package/src/browser/frontend-external-chat-session-provider.spec.ts +491 -0
- package/src/browser/frontend-external-chat-session-provider.ts +277 -0
- package/src/browser/index.ts +18 -0
- package/src/common/external-chat-session-provider.ts +330 -0
- package/src/common/index.ts +17 -0
- package/src/node/ai-external-api-backend-module.ts +41 -0
- package/src/node/ai-external-api-endpoint.spec.ts +272 -0
- package/src/node/ai-external-api-endpoint.ts +195 -0
- package/src/node/external-chat-session-registry.spec.ts +413 -0
- package/src/node/external-chat-session-registry.ts +270 -0
- package/src/node/index.ts +18 -0
package/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<div align='center'>
|
|
2
|
+
|
|
3
|
+
<br />
|
|
4
|
+
|
|
5
|
+
<img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
|
|
6
|
+
|
|
7
|
+
<h2>ECLIPSE THEIA - AI EXTERNAL API EXTENSION</h2>
|
|
8
|
+
|
|
9
|
+
<hr />
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
## Description
|
|
14
|
+
|
|
15
|
+
This package exposes an HTTP API on the Theia backend that allows external tools
|
|
16
|
+
(control planes, dashboards, CLIs) to inspect the AI chat sessions of a running Theia
|
|
17
|
+
instance, to follow session changes as a push stream, to open or restore sessions in
|
|
18
|
+
the IDE, to send prompts to sessions, and to create new sessions.
|
|
19
|
+
|
|
20
|
+
Session data is provided live by the connected frontends: each frontend registers itself with
|
|
21
|
+
the backend and is queried on demand. Sessions that are restored (in memory) in a connected
|
|
22
|
+
frontend are reported with their full state; persisted sessions that have not been restored
|
|
23
|
+
are reported with their persisted metadata and `"restored": false`. If no frontend is
|
|
24
|
+
connected, the session list is empty. Sessions that an agent delegated to another agent are
|
|
25
|
+
listed alongside top-level ones and carry `parentSessionId` and `rootSessionId`, so consumers
|
|
26
|
+
can group them as the IDE's session list does.
|
|
27
|
+
|
|
28
|
+
Session *status* uses the aggregated per-session status of `ChatModel.status`
|
|
29
|
+
(`@theia/ai-chat`): `idle`, `running`, `awaitingApproval`, `awaitingToolCall`,
|
|
30
|
+
`awaitingInput`, or `failed`. Persisted sessions that are not restored report `failed` if
|
|
31
|
+
their last request ended in an error and `idle` otherwise.
|
|
32
|
+
|
|
33
|
+
### Enabling the API
|
|
34
|
+
|
|
35
|
+
The endpoints are contributed to the external API server of `@theia/external-api`, which is
|
|
36
|
+
disabled by default and configured through the `externalApi.*` user preferences (delivery
|
|
37
|
+
mode, port, hostname, and bearer token). See the `@theia/external-api` README for the
|
|
38
|
+
configuration and its security considerations.
|
|
39
|
+
|
|
40
|
+
### API Endpoints
|
|
41
|
+
|
|
42
|
+
| Endpoint | Purpose |
|
|
43
|
+
|---|---|
|
|
44
|
+
| `GET /api/ai/sessions` | List the sessions, most recently used first. |
|
|
45
|
+
| `POST /api/ai/sessions` | Create a session, optionally sending an initial prompt. |
|
|
46
|
+
| `GET /api/ai/sessions/events` | Follow the session list as server-sent events. |
|
|
47
|
+
| `GET /api/ai/sessions/:id` | Read one session including its conversation. |
|
|
48
|
+
| `POST /api/ai/sessions/:id/prompt` | Send a prompt to the session. |
|
|
49
|
+
| `POST /api/ai/sessions/:id/open` | Show the session in the chat view of a connected frontend. |
|
|
50
|
+
| `POST /api/ai/sessions/:id/restore` | Restore the session without focusing it. |
|
|
51
|
+
|
|
52
|
+
The endpoints, their request and response bodies, and their error responses are documented in
|
|
53
|
+
the [API reference](https://github.com/eclipse-theia/theia/blob/master/packages/ai-external-api/doc/api-reference.md).
|
|
54
|
+
The API also describes itself: all endpoints are published, with descriptions and schemas,
|
|
55
|
+
in the OpenAPI document served at `GET /api/openapi.json` (see `@theia/external-api`), e.g.
|
|
56
|
+
to generate clients or MCP tool definitions.
|
|
57
|
+
|
|
58
|
+
### Security Considerations
|
|
59
|
+
|
|
60
|
+
- Chat histories can contain sensitive workspace content. Configure an `externalApi.token`
|
|
61
|
+
and mind the security considerations of `@theia/external-api`.
|
|
62
|
+
- The creation and prompt endpoints trigger agent execution: they start language model
|
|
63
|
+
requests and, depending on the configured tool confirmation settings, tool calls in the
|
|
64
|
+
user's IDE. Do not expose them without a token.
|
|
65
|
+
- The open and restore endpoints affect the IDE: opening raises the chat view in the user's
|
|
66
|
+
frontend, creating switches the active session, and restoring loads persisted session data
|
|
67
|
+
into memory.
|
|
68
|
+
|
|
69
|
+
## Additional Information
|
|
70
|
+
|
|
71
|
+
- [API documentation for `@theia/ai-external-api`](https://eclipse-theia.github.io/theia/docs/next/modules/_theia_ai-external-api.html)
|
|
72
|
+
- [Theia - GitHub](https://github.com/eclipse-theia/theia)
|
|
73
|
+
- [Theia - Website](https://theia-ide.org/)
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
|
|
78
|
+
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
|
|
79
|
+
|
|
80
|
+
## Trademark
|
|
81
|
+
|
|
82
|
+
"Theia" is a trademark of the Eclipse Foundation
|
|
83
|
+
<https://www.eclipse.org/theia>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ChatService, ChatSession } from '@theia/ai-chat/lib/common/chat-service';
|
|
2
|
+
import { Disposable } from '@theia/core';
|
|
3
|
+
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
|
|
4
|
+
import { ExternalChatSessionBackendService } from '../common/external-chat-session-provider';
|
|
5
|
+
/**
|
|
6
|
+
* Connects this frontend to the external session API of the backend.
|
|
7
|
+
*
|
|
8
|
+
* Injecting the {@link ExternalChatSessionBackendService} proxy on application start eagerly
|
|
9
|
+
* establishes the RPC connection through which the backend queries this frontend for session
|
|
10
|
+
* information. In the other direction, this contribution observes the frontend's chat sessions
|
|
11
|
+
* and notifies the backend about changes that are visible to external API clients (session
|
|
12
|
+
* lifecycle, titles, and status), debounced to coalesce bursts of changes.
|
|
13
|
+
*/
|
|
14
|
+
export declare class AIExternalApiFrontendContribution implements FrontendApplicationContribution {
|
|
15
|
+
/** Debounce delay in milliseconds for change notifications to the backend. */
|
|
16
|
+
protected readonly notifyDelay = 200;
|
|
17
|
+
/** Maximum time in milliseconds a continuously changing session may defer a notification. */
|
|
18
|
+
protected readonly notifyMaxDelay = 1000;
|
|
19
|
+
protected readonly backendService: ExternalChatSessionBackendService;
|
|
20
|
+
protected readonly chatService: ChatService;
|
|
21
|
+
/** Status listeners per tracked session, disposed when the session is deleted. */
|
|
22
|
+
protected readonly sessionListeners: Map<string, Disposable>;
|
|
23
|
+
protected readonly notifyBackend: import("lodash").DebouncedFunc<() => void>;
|
|
24
|
+
onStart(): void;
|
|
25
|
+
/** Notifies the backend about status changes of the given session until the session is deleted. */
|
|
26
|
+
protected trackSession(session: ChatSession): void;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=ai-external-api-frontend-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-external-api-frontend-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/ai-external-api-frontend-contribution.ts"],"names":[],"mappings":"AAiBA,OAAO,EACH,WAAW,EAAE,WAAW,EAC3B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAG1E,OAAO,EAAE,iCAAiC,EAAE,MAAM,0CAA0C,CAAC;AAE7F;;;;;;;;GAQG;AACH,qBACa,iCAAkC,YAAW,+BAA+B;IAErF,8EAA8E;IAC9E,SAAS,CAAC,QAAQ,CAAC,WAAW,OAAO;IACrC,6FAA6F;IAC7F,SAAS,CAAC,QAAQ,CAAC,cAAc,QAAQ;IAGzC,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,iCAAiC,CAAC;IAGrE,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAE5C,kFAAkF;IAClF,SAAS,CAAC,QAAQ,CAAC,gBAAgB,0BAAiC;IAEpE,SAAS,CAAC,QAAQ,CAAC,aAAa,6CAI9B;IAEF,OAAO,IAAI,IAAI;IAoBf,mGAAmG;IACnG,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;CAUrD"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2026 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.AIExternalApiFrontendContribution = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const chat_model_1 = require("@theia/ai-chat/lib/common/chat-model");
|
|
21
|
+
const chat_service_1 = require("@theia/ai-chat/lib/common/chat-service");
|
|
22
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
23
|
+
const debounce = require("@theia/core/shared/lodash.debounce");
|
|
24
|
+
const external_chat_session_provider_1 = require("../common/external-chat-session-provider");
|
|
25
|
+
/**
|
|
26
|
+
* Connects this frontend to the external session API of the backend.
|
|
27
|
+
*
|
|
28
|
+
* Injecting the {@link ExternalChatSessionBackendService} proxy on application start eagerly
|
|
29
|
+
* establishes the RPC connection through which the backend queries this frontend for session
|
|
30
|
+
* information. In the other direction, this contribution observes the frontend's chat sessions
|
|
31
|
+
* and notifies the backend about changes that are visible to external API clients (session
|
|
32
|
+
* lifecycle, titles, and status), debounced to coalesce bursts of changes.
|
|
33
|
+
*/
|
|
34
|
+
let AIExternalApiFrontendContribution = class AIExternalApiFrontendContribution {
|
|
35
|
+
constructor() {
|
|
36
|
+
/** Debounce delay in milliseconds for change notifications to the backend. */
|
|
37
|
+
this.notifyDelay = 200;
|
|
38
|
+
/** Maximum time in milliseconds a continuously changing session may defer a notification. */
|
|
39
|
+
this.notifyMaxDelay = 1000;
|
|
40
|
+
/** Status listeners per tracked session, disposed when the session is deleted. */
|
|
41
|
+
this.sessionListeners = new Map();
|
|
42
|
+
this.notifyBackend = debounce(() => this.backendService.notifySessionsChanged(), this.notifyDelay, { maxWait: this.notifyMaxDelay });
|
|
43
|
+
}
|
|
44
|
+
onStart() {
|
|
45
|
+
this.chatService.onSessionEvent(event => {
|
|
46
|
+
if ((0, chat_service_1.isActiveSessionChangedEvent)(event)) {
|
|
47
|
+
// which session is active is not visible to external API clients
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if ((0, chat_service_1.isSessionCreatedEvent)(event)) {
|
|
51
|
+
const session = this.chatService.getSession(event.sessionId);
|
|
52
|
+
if (session) {
|
|
53
|
+
this.trackSession(session);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else if ((0, chat_service_1.isSessionDeletedEvent)(event)) {
|
|
57
|
+
this.sessionListeners.get(event.sessionId)?.dispose();
|
|
58
|
+
this.sessionListeners.delete(event.sessionId);
|
|
59
|
+
}
|
|
60
|
+
this.notifyBackend();
|
|
61
|
+
});
|
|
62
|
+
this.chatService.getSessions().forEach(session => this.trackSession(session));
|
|
63
|
+
}
|
|
64
|
+
/** Notifies the backend about status changes of the given session until the session is deleted. */
|
|
65
|
+
trackSession(session) {
|
|
66
|
+
if (this.sessionListeners.has(session.id)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
this.sessionListeners.set(session.id, session.model.onDidChange(event => {
|
|
70
|
+
if (chat_model_1.ChatChangeEvent.isStatusChangedEvent(event)) {
|
|
71
|
+
this.notifyBackend();
|
|
72
|
+
}
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
exports.AIExternalApiFrontendContribution = AIExternalApiFrontendContribution;
|
|
77
|
+
tslib_1.__decorate([
|
|
78
|
+
(0, inversify_1.inject)(external_chat_session_provider_1.ExternalChatSessionBackendService),
|
|
79
|
+
tslib_1.__metadata("design:type", Object)
|
|
80
|
+
], AIExternalApiFrontendContribution.prototype, "backendService", void 0);
|
|
81
|
+
tslib_1.__decorate([
|
|
82
|
+
(0, inversify_1.inject)(chat_service_1.ChatService),
|
|
83
|
+
tslib_1.__metadata("design:type", Object)
|
|
84
|
+
], AIExternalApiFrontendContribution.prototype, "chatService", void 0);
|
|
85
|
+
exports.AIExternalApiFrontendContribution = AIExternalApiFrontendContribution = tslib_1.__decorate([
|
|
86
|
+
(0, inversify_1.injectable)()
|
|
87
|
+
], AIExternalApiFrontendContribution);
|
|
88
|
+
//# sourceMappingURL=ai-external-api-frontend-contribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-external-api-frontend-contribution.js","sourceRoot":"","sources":["../../src/browser/ai-external-api-frontend-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;;;;AAEhF,qEAAuE;AACvE,yEAEgD;AAGhD,4DAAkE;AAClE,+DAAgE;AAChE,6FAA6F;AAE7F;;;;;;;;GAQG;AAEI,IAAM,iCAAiC,GAAvC,MAAM,iCAAiC;IAAvC;QAEH,8EAA8E;QAC3D,gBAAW,GAAG,GAAG,CAAC;QACrC,6FAA6F;QAC1E,mBAAc,GAAG,IAAI,CAAC;QAQzC,kFAAkF;QAC/D,qBAAgB,GAAG,IAAI,GAAG,EAAsB,CAAC;QAEjD,kBAAa,GAAG,QAAQ,CACvC,GAAG,EAAE,CAAC,IAAI,CAAC,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,CAAC,KAAK,CAAC,EAAE;YACpE,IAAI,4BAAe,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC9C,IAAI,CAAC,aAAa,EAAE,CAAC;YACzB,CAAC;QACL,CAAC,CAAC,CAAC,CAAC;IACR,CAAC;CACJ,CAAA;AArDY,8EAAiC;AAQvB;IADlB,IAAA,kBAAM,EAAC,kEAAiC,CAAC;;yEAC2B;AAGlD;IADlB,IAAA,kBAAM,EAAC,0BAAW,CAAC;;sEACwB;4CAXnC,iCAAiC;IAD7C,IAAA,sBAAU,GAAE;GACA,iCAAiC,CAqD7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-external-api-frontend-contribution.spec.d.ts","sourceRoot":"","sources":["../../src/browser/ai-external-api-frontend-contribution.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2026 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
|
+
const jsdom_1 = require("@theia/core/lib/browser/test/jsdom");
|
|
19
|
+
const disableJSDOM = (0, jsdom_1.enableJSDOM)();
|
|
20
|
+
const frontend_application_config_provider_1 = require("@theia/core/lib/browser/frontend-application-config-provider");
|
|
21
|
+
frontend_application_config_provider_1.FrontendApplicationConfigProvider.set({});
|
|
22
|
+
const core_1 = require("@theia/core");
|
|
23
|
+
const chai_1 = require("chai");
|
|
24
|
+
const ai_external_api_frontend_contribution_1 = require("./ai-external-api-frontend-contribution");
|
|
25
|
+
disableJSDOM();
|
|
26
|
+
describe('AIExternalApiFrontendContribution', () => {
|
|
27
|
+
function trackedSession(id) {
|
|
28
|
+
const modelChanges = new core_1.Emitter();
|
|
29
|
+
return {
|
|
30
|
+
session: { id, model: { onDidChange: modelChanges.event } },
|
|
31
|
+
fireStatusChanged: () => modelChanges.fire({ kind: 'statusChanged' }),
|
|
32
|
+
fireOtherModelChange: () => modelChanges.fire({ kind: 'responseChanged' })
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function startContribution(initialSessions = []) {
|
|
36
|
+
const sessionEvents = new core_1.Emitter();
|
|
37
|
+
const sessions = [...initialSessions];
|
|
38
|
+
const chatService = {
|
|
39
|
+
onSessionEvent: sessionEvents.event,
|
|
40
|
+
getSessions: () => sessions.map(tracked => tracked.session),
|
|
41
|
+
getSession: (id) => sessions.find(tracked => tracked.session.id === id)?.session
|
|
42
|
+
};
|
|
43
|
+
let count = 0;
|
|
44
|
+
const contribution = new ai_external_api_frontend_contribution_1.AIExternalApiFrontendContribution();
|
|
45
|
+
contribution['chatService'] = chatService;
|
|
46
|
+
contribution['backendService'] = { notifySessionsChanged: () => count++ };
|
|
47
|
+
contribution.onStart();
|
|
48
|
+
return {
|
|
49
|
+
sessionEvents,
|
|
50
|
+
addSession: tracked => sessions.push(tracked),
|
|
51
|
+
removeSession: id => sessions.splice(sessions.findIndex(tracked => tracked.session.id === id), 1),
|
|
52
|
+
notifications: () => count
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** Waits long enough for a debounced notification to be delivered. */
|
|
56
|
+
function settle() {
|
|
57
|
+
return new Promise(resolve => setTimeout(resolve, 300));
|
|
58
|
+
}
|
|
59
|
+
it('notifies the backend when a session is created', async () => {
|
|
60
|
+
const context = startContribution();
|
|
61
|
+
context.addSession(trackedSession('1'));
|
|
62
|
+
context.sessionEvents.fire({ type: 'created', sessionId: '1' });
|
|
63
|
+
await settle();
|
|
64
|
+
(0, chai_1.expect)(context.notifications()).to.equal(1);
|
|
65
|
+
});
|
|
66
|
+
it('notifies the backend on session status changes', async () => {
|
|
67
|
+
const tracked = trackedSession('1');
|
|
68
|
+
const context = startContribution([tracked]);
|
|
69
|
+
tracked.fireStatusChanged();
|
|
70
|
+
await settle();
|
|
71
|
+
(0, chai_1.expect)(context.notifications()).to.equal(1);
|
|
72
|
+
});
|
|
73
|
+
it('coalesces bursts of changes into a single notification', async () => {
|
|
74
|
+
const tracked = trackedSession('1');
|
|
75
|
+
const context = startContribution([tracked]);
|
|
76
|
+
context.sessionEvents.fire({ type: 'renamed', sessionId: '1' });
|
|
77
|
+
tracked.fireStatusChanged();
|
|
78
|
+
tracked.fireStatusChanged();
|
|
79
|
+
await settle();
|
|
80
|
+
(0, chai_1.expect)(context.notifications()).to.equal(1);
|
|
81
|
+
});
|
|
82
|
+
it('ignores changes that are not visible to external clients', async () => {
|
|
83
|
+
const tracked = trackedSession('1');
|
|
84
|
+
const context = startContribution([tracked]);
|
|
85
|
+
context.sessionEvents.fire({ type: 'activeChange', sessionId: '1' });
|
|
86
|
+
tracked.fireOtherModelChange();
|
|
87
|
+
await settle();
|
|
88
|
+
(0, chai_1.expect)(context.notifications()).to.equal(0);
|
|
89
|
+
});
|
|
90
|
+
it('stops observing deleted sessions', async () => {
|
|
91
|
+
const tracked = trackedSession('1');
|
|
92
|
+
const context = startContribution([tracked]);
|
|
93
|
+
context.removeSession('1');
|
|
94
|
+
context.sessionEvents.fire({ type: 'deleted', sessionId: '1' });
|
|
95
|
+
await settle();
|
|
96
|
+
(0, chai_1.expect)(context.notifications()).to.equal(1);
|
|
97
|
+
tracked.fireStatusChanged();
|
|
98
|
+
await settle();
|
|
99
|
+
(0, chai_1.expect)(context.notifications()).to.equal(1);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
//# sourceMappingURL=ai-external-api-frontend-contribution.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-external-api-frontend-contribution.spec.js","sourceRoot":"","sources":["../../src/browser/ai-external-api-frontend-contribution.spec.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,8DAAiE;AACjE,MAAM,YAAY,GAAG,IAAA,mBAAW,GAAE,CAAC;AACnC,uHAAiH;AACjH,wEAAiC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAI1C,sCAAsC;AACtC,+BAA8B;AAC9B,mGAA4F;AAE5F,YAAY,EAAE,CAAC;AAIf,QAAQ,CAAC,mCAAmC,EAAE,GAAG,EAAE;IAQ/C,SAAS,cAAc,CAAC,EAAU;QAC9B,MAAM,YAAY,GAAG,IAAI,cAAO,EAAmB,CAAC;QACpD,OAAO;YACH,OAAO,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,YAAY,CAAC,KAAK,EAAE,EAA4B;YACrF,iBAAiB,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,eAAe,EAAqB,CAAC;YACxF,oBAAoB,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAqB,CAAC;SAChG,CAAC;IACN,CAAC;IASD,SAAS,iBAAiB,CAAC,kBAAoC,EAAE;QAC7D,MAAM,aAAa,GAAG,IAAI,cAAO,E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":3,"file":"ai-external-api-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/ai-external-api-frontend-module.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;AAK/D,wBAwBG"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2026 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
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
19
|
+
const service_connection_provider_1 = require("@theia/core/lib/browser/messaging/service-connection-provider");
|
|
20
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
21
|
+
const external_chat_session_provider_1 = require("../common/external-chat-session-provider");
|
|
22
|
+
const ai_external_api_frontend_contribution_1 = require("./ai-external-api-frontend-contribution");
|
|
23
|
+
const frontend_external_chat_session_provider_1 = require("./frontend-external-chat-session-provider");
|
|
24
|
+
exports.default = new inversify_1.ContainerModule(bind => {
|
|
25
|
+
bind(frontend_external_chat_session_provider_1.FrontendExternalChatSessionProvider).toSelf().inSingletonScope();
|
|
26
|
+
bind(external_chat_session_provider_1.ExternalChatSessionProvider).toService(frontend_external_chat_session_provider_1.FrontendExternalChatSessionProvider);
|
|
27
|
+
bind(external_chat_session_provider_1.ExternalChatSessionBackendService).toDynamicValue(ctx => {
|
|
28
|
+
const connection = ctx.container.get(service_connection_provider_1.RemoteConnectionProvider);
|
|
29
|
+
const provider = ctx.container.get(external_chat_session_provider_1.ExternalChatSessionProvider);
|
|
30
|
+
// expose only the provider interface over RPC: handing out the implementation itself
|
|
31
|
+
// would make all of its methods, including the internal ones, remotely callable
|
|
32
|
+
const exposed = {
|
|
33
|
+
getWorkspace: () => provider.getWorkspace(),
|
|
34
|
+
getSessions: () => provider.getSessions(),
|
|
35
|
+
getSessionSummary: sessionId => provider.getSessionSummary(sessionId),
|
|
36
|
+
getSession: sessionId => provider.getSession(sessionId),
|
|
37
|
+
openSession: sessionId => provider.openSession(sessionId),
|
|
38
|
+
restoreSession: sessionId => provider.restoreSession(sessionId),
|
|
39
|
+
sendPrompt: (sessionId, prompt) => provider.sendPrompt(sessionId, prompt),
|
|
40
|
+
createSession: request => provider.createSession(request)
|
|
41
|
+
};
|
|
42
|
+
return connection.createProxy(external_chat_session_provider_1.EXTERNAL_CHAT_SESSION_PROVIDER_PATH, exposed);
|
|
43
|
+
}).inSingletonScope();
|
|
44
|
+
bind(ai_external_api_frontend_contribution_1.AIExternalApiFrontendContribution).toSelf().inSingletonScope();
|
|
45
|
+
bind(browser_1.FrontendApplicationContribution).toService(ai_external_api_frontend_contribution_1.AIExternalApiFrontendContribution);
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=ai-external-api-frontend-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-external-api-frontend-module.js","sourceRoot":"","sources":["../../src/browser/ai-external-api-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,yDA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AAE,CAAC,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC;SAC5D,CAAC;QACF,OAAO,UAAU,CAAC,WAAW,CAAoC,oEAAmC,EAAE,OAAO,CAAC,CAAC;IACnH,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAEtB,IAAI,CAAC,yEAAiC,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACpE,IAAI,CAAC,yCAA+B,CAAC,CAAC,SAAS,CAAC,yEAAiC,CAAC,CAAC;AACvF,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ChatAgentService } from '@theia/ai-chat/lib/common/chat-agent-service';
|
|
2
|
+
import { ChatService, ChatSession } from '@theia/ai-chat/lib/common/chat-service';
|
|
3
|
+
import { ChatSessionMetadata } from '@theia/ai-chat/lib/common/chat-session-store';
|
|
4
|
+
import { PreferenceService } from '@theia/core';
|
|
5
|
+
import { ILogger } from '@theia/core/lib/common/logger';
|
|
6
|
+
import { WorkspaceService } from '@theia/workspace/lib/browser';
|
|
7
|
+
import { ExternalChatMessage, ExternalChatPrompt, ExternalChatPromptResult, ExternalChatSessionCreateRequest, ExternalChatSessionCreateResult, ExternalChatSessionDetail, ExternalChatSessionProvider, ExternalChatSessionSummary } from '../common/external-chat-session-provider';
|
|
8
|
+
/**
|
|
9
|
+
* Answers the backend's external session queries from this frontend's {@link ChatService}.
|
|
10
|
+
*
|
|
11
|
+
* Reports sessions that are restored (live) in this frontend with their full state, and
|
|
12
|
+
* persisted sessions that have not been restored with their persisted metadata. Live sessions
|
|
13
|
+
* are attributed to the workspace this frontend has opened; persisted sessions only when
|
|
14
|
+
* sessions are persisted per workspace, as the global session store holds sessions saved
|
|
15
|
+
* from any workspace.
|
|
16
|
+
*/
|
|
17
|
+
export declare class FrontendExternalChatSessionProvider implements ExternalChatSessionProvider {
|
|
18
|
+
/** Number of trailing conversation lines included in a summary's preview. */
|
|
19
|
+
protected readonly previewLineCount = 5;
|
|
20
|
+
/** Maximum length of a single preview line; longer lines are truncated. */
|
|
21
|
+
protected readonly previewLineLength = 200;
|
|
22
|
+
protected readonly logger: ILogger;
|
|
23
|
+
protected readonly chatService: ChatService;
|
|
24
|
+
protected readonly agentService: ChatAgentService;
|
|
25
|
+
protected readonly workspaceService: WorkspaceService;
|
|
26
|
+
protected readonly preferenceService: PreferenceService;
|
|
27
|
+
getSessions(): Promise<ExternalChatSessionSummary[]>;
|
|
28
|
+
getSessionSummary(sessionId: string): Promise<ExternalChatSessionSummary | undefined>;
|
|
29
|
+
getSession(sessionId: string): Promise<ExternalChatSessionDetail | undefined>;
|
|
30
|
+
openSession(sessionId: string): Promise<boolean>;
|
|
31
|
+
restoreSession(sessionId: string): Promise<ExternalChatSessionDetail | undefined>;
|
|
32
|
+
sendPrompt(sessionId: string, prompt: ExternalChatPrompt): Promise<ExternalChatPromptResult | undefined>;
|
|
33
|
+
createSession(request: ExternalChatSessionCreateRequest): Promise<ExternalChatSessionCreateResult>;
|
|
34
|
+
getWorkspace(): Promise<string | undefined>;
|
|
35
|
+
protected getWorkspaceUri(): Promise<string | undefined>;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the workspace to attribute persisted sessions to: this frontend's workspace when
|
|
38
|
+
* sessions are persisted per workspace, and `undefined` when they are persisted globally,
|
|
39
|
+
* as the global session store holds sessions saved from any workspace.
|
|
40
|
+
*/
|
|
41
|
+
protected getPersistedSessionsWorkspace(workspace: string | undefined): Promise<string | undefined>;
|
|
42
|
+
/** Returns the metadata of all persisted sessions, or an empty list if reading the persisted index fails. */
|
|
43
|
+
protected getPersistedMetadata(): Promise<ChatSessionMetadata[]>;
|
|
44
|
+
protected toDetail(session: ChatSession, workspace: string | undefined): ExternalChatSessionDetail;
|
|
45
|
+
protected toSummary(session: ChatSession, workspace: string | undefined): ExternalChatSessionSummary;
|
|
46
|
+
/** Reduces the metadata of a persisted session that is not restored to a summary. */
|
|
47
|
+
protected toPersistedSummary(metadata: ChatSessionMetadata, workspace: string | undefined): ExternalChatSessionSummary;
|
|
48
|
+
/**
|
|
49
|
+
* Reduces the session's conversation to plain-text messages, similar to the message history
|
|
50
|
+
* sent to the language model for the next request. In-progress responses are included with
|
|
51
|
+
* their content so far.
|
|
52
|
+
*/
|
|
53
|
+
protected toMessages(session: ChatSession): ExternalChatMessage[];
|
|
54
|
+
/**
|
|
55
|
+
* Returns the last few non-empty lines of the conversation, or `undefined` for an empty
|
|
56
|
+
* conversation. Walks the conversation from the end so that only as many entries as the
|
|
57
|
+
* preview needs are rendered, however long the conversation is.
|
|
58
|
+
*/
|
|
59
|
+
protected toPreview(session: ChatSession): string | undefined;
|
|
60
|
+
/** Splits an entry into its non-empty, truncated preview lines. */
|
|
61
|
+
protected toPreviewLines(text: string | undefined): string[];
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=frontend-external-chat-session-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontend-external-chat-session-provider.d.ts","sourceRoot":"","sources":["../../src/browser/frontend-external-chat-session-provider.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAGhF,OAAO,EAAE,WAAW,EAAE,WAAW,EAAoB,MAAM,wCAAwC,CAAC;AACpG,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EACH,mBAAmB,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,gCAAgC,EAAE,+BAA+B,EACpI,yBAAyB,EAAE,2BAA2B,EAAE,0BAA0B,EACrF,MAAM,0CAA0C,CAAC;AAElD;;;;;;;;GAQG;AACH,qBACa,mCAAoC,YAAW,2BAA2B;IAEnF,6EAA6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