@theia/ai-ide 1.63.2 → 1.64.0-next.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/app-tester-chat-agent.d.ts +1 -1
- package/lib/browser/app-tester-chat-agent.d.ts.map +1 -1
- package/lib/browser/app-tester-chat-agent.js +32 -10
- package/lib/browser/app-tester-chat-agent.js.map +1 -1
- package/lib/browser/app-tester-chat-functions.d.ts +25 -0
- package/lib/browser/app-tester-chat-functions.d.ts.map +1 -0
- package/lib/browser/app-tester-chat-functions.js +170 -0
- package/lib/browser/app-tester-chat-functions.js.map +1 -0
- package/lib/browser/frontend-module.d.ts.map +1 -1
- package/lib/browser/frontend-module.js +10 -0
- package/lib/browser/frontend-module.js.map +1 -1
- package/lib/common/app-tester-chat-functions.d.ts +5 -0
- package/lib/common/app-tester-chat-functions.d.ts.map +1 -0
- package/lib/common/app-tester-chat-functions.js +23 -0
- package/lib/common/app-tester-chat-functions.js.map +1 -0
- package/lib/common/browser-automation-protocol.d.ts +15 -0
- package/lib/common/browser-automation-protocol.d.ts.map +1 -0
- package/lib/common/browser-automation-protocol.js +22 -0
- package/lib/common/browser-automation-protocol.js.map +1 -0
- package/lib/node/app-tester-agent/browser-automation-impl.d.ts +18 -0
- package/lib/node/app-tester-agent/browser-automation-impl.d.ts.map +1 -0
- package/lib/node/app-tester-agent/browser-automation-impl.js +96 -0
- package/lib/node/app-tester-agent/browser-automation-impl.js.map +1 -0
- package/lib/node/backend-module.d.ts +4 -0
- package/lib/node/backend-module.d.ts.map +1 -0
- package/lib/node/backend-module.js +35 -0
- package/lib/node/backend-module.js.map +1 -0
- package/package.json +21 -19
- package/src/browser/app-tester-chat-agent.ts +135 -111
- package/src/browser/app-tester-chat-functions.ts +170 -0
- package/src/browser/frontend-module.ts +19 -1
- package/src/common/app-tester-chat-functions.ts +20 -0
- package/src/common/browser-automation-protocol.ts +32 -0
- package/src/node/app-tester-agent/browser-automation-impl.ts +107 -0
- package/src/node/backend-module.ts +38 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2025 EclipseSource GmbH.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
export const browserAutomationPath = '/services/automation/browser';
|
|
18
|
+
export const BrowserAutomation = Symbol('BrowserAutomation');
|
|
19
|
+
export interface BrowserAutomation {
|
|
20
|
+
launch(remoteDebuggingPort: number): Promise<LaunchResult | undefined>;
|
|
21
|
+
isRunning(): Promise<boolean>;
|
|
22
|
+
queryDom(selector?: string): Promise<string>;
|
|
23
|
+
close(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface LaunchResult {
|
|
27
|
+
remoteDebuggingPort: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const BrowserAutomationClient = Symbol('BrowserAutomationClient');
|
|
31
|
+
export interface BrowserAutomationClient {
|
|
32
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2025 EclipseSource GmbH.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { type RpcServer } from '@theia/core';
|
|
18
|
+
import { injectable } from '@theia/core/shared/inversify';
|
|
19
|
+
import { Browser, launch, Page } from 'puppeteer-core';
|
|
20
|
+
import type { BrowserAutomation, BrowserAutomationClient, LaunchResult } from '../../common/browser-automation-protocol';
|
|
21
|
+
|
|
22
|
+
const MAX_DOM_LENGTH = 50000;
|
|
23
|
+
|
|
24
|
+
@injectable()
|
|
25
|
+
export class BrowserAutomationImpl implements RpcServer<BrowserAutomationClient>, BrowserAutomation {
|
|
26
|
+
protected _browser?: Browser;
|
|
27
|
+
protected _page?: Page;
|
|
28
|
+
protected client?: BrowserAutomationClient;
|
|
29
|
+
|
|
30
|
+
protected get browser(): Browser {
|
|
31
|
+
if (!this._browser) {
|
|
32
|
+
throw new Error('Browser is not launched');
|
|
33
|
+
}
|
|
34
|
+
return this._browser;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
protected get page(): Page {
|
|
38
|
+
if (!this._page) {
|
|
39
|
+
throw new Error('Page is not created');
|
|
40
|
+
}
|
|
41
|
+
return this._page;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async isRunning(): Promise<boolean> {
|
|
45
|
+
return this._browser !== undefined && this._browser.connected;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async launch(remoteDebuggingPort: number): Promise<LaunchResult | undefined> {
|
|
49
|
+
if (this._browser) {
|
|
50
|
+
await this.close();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const browser = await launch({
|
|
54
|
+
headless: false,
|
|
55
|
+
channel: 'chrome',
|
|
56
|
+
args: [
|
|
57
|
+
`--remote-debugging-port=${remoteDebuggingPort}`
|
|
58
|
+
],
|
|
59
|
+
});
|
|
60
|
+
this._browser = browser;
|
|
61
|
+
// The initial page will be used per default
|
|
62
|
+
this._page = (await browser.pages())[0];
|
|
63
|
+
return {
|
|
64
|
+
remoteDebuggingPort
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async close(): Promise<void> {
|
|
69
|
+
await this._browser?.close();
|
|
70
|
+
this._browser = undefined;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async queryDom(selector?: string): Promise<string> {
|
|
74
|
+
const page = this.page;
|
|
75
|
+
let content = '';
|
|
76
|
+
|
|
77
|
+
if (selector) {
|
|
78
|
+
const element = await page.$(selector);
|
|
79
|
+
if (!element) {
|
|
80
|
+
throw new Error(`Element with selector "${selector}" not found`);
|
|
81
|
+
}
|
|
82
|
+
content = await page.evaluate(el => el.outerHTML, element);
|
|
83
|
+
} else {
|
|
84
|
+
content = await page.content();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (content.length > MAX_DOM_LENGTH) {
|
|
88
|
+
return 'The queried DOM is too large. Please provide a more specific query.';
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return content;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
dispose(): void {
|
|
95
|
+
this._browser?.close();
|
|
96
|
+
this._browser = undefined;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
setClient(client: BrowserAutomationClient | undefined): void {
|
|
100
|
+
this.client = client;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
getClient?(): BrowserAutomationClient | undefined {
|
|
104
|
+
return this.client;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2025 EclipseSource GmbH.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { ConnectionHandler, RpcConnectionHandler } from '@theia/core';
|
|
18
|
+
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
19
|
+
import { BrowserAutomation, browserAutomationPath, type BrowserAutomationClient } from '../common/browser-automation-protocol';
|
|
20
|
+
import { BrowserAutomationImpl } from './app-tester-agent/browser-automation-impl';
|
|
21
|
+
import { ConnectionContainerModule } from '@theia/core/lib/node/messaging/connection-container-module';
|
|
22
|
+
|
|
23
|
+
const browserAutomationModule = ConnectionContainerModule.create(({ bind, bindBackendService, bindFrontendService }) => {
|
|
24
|
+
bind(BrowserAutomation).to(BrowserAutomationImpl).inSingletonScope();
|
|
25
|
+
bind(ConnectionHandler).toDynamicValue(ctx =>
|
|
26
|
+
new RpcConnectionHandler<BrowserAutomationClient>(browserAutomationPath, client => {
|
|
27
|
+
const server = ctx.container.get<BrowserAutomationImpl>(BrowserAutomation);
|
|
28
|
+
server.setClient(client);
|
|
29
|
+
client.onDidCloseConnection(() => server.close());
|
|
30
|
+
return server;
|
|
31
|
+
})
|
|
32
|
+
).inSingletonScope();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export default new ContainerModule(bind => {
|
|
36
|
+
bind(ConnectionContainerModule).toConstantValue(browserAutomationModule);
|
|
37
|
+
|
|
38
|
+
});
|