alumnium 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.mocharc.json +10 -0
- package/.vscode/extensions.json +6 -0
- package/.vscode/settings.json +16 -0
- package/README.md +75 -0
- package/dist/Alumni.d.ts +33 -0
- package/dist/Alumni.js +116 -0
- package/dist/Area.d.ts +19 -0
- package/dist/Area.js +43 -0
- package/dist/Cache.d.ts +7 -0
- package/dist/Cache.js +11 -0
- package/dist/Model.d.ts +21 -0
- package/dist/Model.js +47 -0
- package/dist/accessibility/AccessibilityElement.d.ts +14 -0
- package/dist/accessibility/AccessibilityElement.js +15 -0
- package/dist/accessibility/BaseAccessibilityTree.d.ts +6 -0
- package/dist/accessibility/BaseAccessibilityTree.js +2 -0
- package/dist/accessibility/ChromiumAccessibilityTree.d.ts +20 -0
- package/dist/accessibility/ChromiumAccessibilityTree.js +216 -0
- package/dist/accessibility/UIAutomator2AccessibilityTree.d.ts +15 -0
- package/dist/accessibility/UIAutomator2AccessibilityTree.js +149 -0
- package/dist/accessibility/XCUITestAccessibilityTree.d.ts +15 -0
- package/dist/accessibility/XCUITestAccessibilityTree.js +144 -0
- package/dist/accessibility/index.d.ts +5 -0
- package/dist/accessibility/index.js +5 -0
- package/dist/clients/HttpClient.d.ts +27 -0
- package/dist/clients/HttpClient.js +204 -0
- package/dist/clients/typecasting.d.ts +5 -0
- package/dist/clients/typecasting.js +28 -0
- package/dist/drivers/AppiumDriver.d.ts +29 -0
- package/dist/drivers/AppiumDriver.js +187 -0
- package/dist/drivers/BaseDriver.d.ts +19 -0
- package/dist/drivers/BaseDriver.js +2 -0
- package/dist/drivers/PlaywrightDriver.d.ts +29 -0
- package/dist/drivers/PlaywrightDriver.js +146 -0
- package/dist/drivers/SeleniumDriver.d.ts +27 -0
- package/dist/drivers/SeleniumDriver.js +149 -0
- package/dist/drivers/index.d.ts +4 -0
- package/dist/drivers/index.js +1 -0
- package/dist/drivers/keys.d.ts +6 -0
- package/dist/drivers/keys.js +7 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +9 -0
- package/dist/tools/BaseTool.d.ts +10 -0
- package/dist/tools/BaseTool.js +14 -0
- package/dist/tools/ClickTool.d.ts +10 -0
- package/dist/tools/ClickTool.js +11 -0
- package/dist/tools/DragAndDropTool.d.ts +12 -0
- package/dist/tools/DragAndDropTool.js +12 -0
- package/dist/tools/HoverTool.d.ts +10 -0
- package/dist/tools/HoverTool.js +11 -0
- package/dist/tools/NavigateBackTool.d.ts +6 -0
- package/dist/tools/NavigateBackTool.js +16 -0
- package/dist/tools/PressKeyTool.d.ts +11 -0
- package/dist/tools/PressKeyTool.js +11 -0
- package/dist/tools/SelectTool.d.ts +12 -0
- package/dist/tools/SelectTool.js +12 -0
- package/dist/tools/TypeTool.d.ts +12 -0
- package/dist/tools/TypeTool.js +12 -0
- package/dist/tools/toolToSchemaConverter.d.ts +18 -0
- package/dist/tools/toolToSchemaConverter.js +62 -0
- package/dist/utils/logger.d.ts +1 -0
- package/dist/utils/logger.js +33 -0
- package/log/alumnium.log +731 -0
- package/package.json +58 -0
- package/playwright-report/data/9bb9e740488ba36abef0f2c1176f965fea9c0318.zip +0 -0
- package/playwright-report/index.html +85 -0
- package/playwright-report/trace/assets/codeMirrorModule-eyVcHN77.js +24 -0
- package/playwright-report/trace/assets/defaultSettingsView-w0zYjHsW.js +265 -0
- package/playwright-report/trace/codeMirrorModule.C3UTv-Ge.css +1 -0
- package/playwright-report/trace/codicon.DCmgc-ay.ttf +0 -0
- package/playwright-report/trace/defaultSettingsView.TQ8_7ybu.css +1 -0
- package/playwright-report/trace/index.Bx16ehp1.js +2 -0
- package/playwright-report/trace/index.I8N9v4jT.css +1 -0
- package/playwright-report/trace/index.html +43 -0
- package/playwright-report/trace/playwright-logo.svg +9 -0
- package/playwright-report/trace/snapshot.html +21 -0
- package/playwright-report/trace/sw.bundle.js +3 -0
- package/playwright-report/trace/uiMode.Btcz36p_.css +1 -0
- package/playwright-report/trace/uiMode.DRQ310U5.js +5 -0
- package/playwright-report/trace/uiMode.html +17 -0
- package/playwright-report/trace/xtermModule.DYP7pi_n.css +32 -0
- package/reports/test-report.html +1408 -0
- package/src/Alumni.ts +195 -0
- package/src/Area.ts +99 -0
- package/src/Cache.ts +17 -0
- package/src/Model.ts +56 -0
- package/src/accessibility/AccessibilityElement.ts +39 -0
- package/src/accessibility/BaseAccessibilityTree.ts +7 -0
- package/src/accessibility/ChromiumAccessibilityTree.ts +290 -0
- package/src/accessibility/UIAutomator2AccessibilityTree.ts +199 -0
- package/src/accessibility/XCUITestAccessibilityTree.ts +186 -0
- package/src/accessibility/index.ts +5 -0
- package/src/clients/HttpClient.ts +288 -0
- package/src/clients/typecasting.ts +34 -0
- package/src/drivers/AppiumDriver.ts +208 -0
- package/src/drivers/BaseDriver.ts +20 -0
- package/src/drivers/PlaywrightDriver.ts +186 -0
- package/src/drivers/SeleniumDriver.ts +208 -0
- package/src/drivers/index.ts +5 -0
- package/src/drivers/keys.ts +6 -0
- package/src/drivers/scripts/waitFor.js +8 -0
- package/src/drivers/scripts/waiter.js +194 -0
- package/src/index.ts +11 -0
- package/src/tools/BaseTool.ts +29 -0
- package/src/tools/ClickTool.ts +17 -0
- package/src/tools/DragAndDropTool.ts +20 -0
- package/src/tools/HoverTool.ts +17 -0
- package/src/tools/NavigateBackTool.ts +19 -0
- package/src/tools/PressKeyTool.ts +18 -0
- package/src/tools/SelectTool.ts +20 -0
- package/src/tools/TypeTool.ts +19 -0
- package/src/tools/toolToSchemaConverter.ts +83 -0
- package/src/utils/logger.ts +46 -0
- package/test-results/.last-run.json +6 -0
- package/test-results/calculator-Calculator-Tests-addition-default/trace.zip +0 -0
- package/tsconfig.json +27 -0
- package/wdio.conf.ts +45 -0
package/.mocharc.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"[javascript]": {
|
|
3
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
4
|
+
"editor.codeActionsOnSave": {
|
|
5
|
+
"source.organizeImports": "explicit",
|
|
6
|
+
"source.fixAll": "explicit",
|
|
7
|
+
},
|
|
8
|
+
},
|
|
9
|
+
"[typescript]": {
|
|
10
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
11
|
+
"editor.codeActionsOnSave": {
|
|
12
|
+
"source.organizeImports": "explicit",
|
|
13
|
+
"source.fixAll": "explicit",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<h1>
|
|
2
|
+
<p align="center">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/alumnium-hq/alumnium.github.io/efb2afaf0ced7ec07c241445e7b381914281edaf/src/assets/logo.svg" height="128" alt="Logo" />
|
|
4
|
+
<br />
|
|
5
|
+
Alumnium
|
|
6
|
+
</p>
|
|
7
|
+
</h1>
|
|
8
|
+
<p align="center">
|
|
9
|
+
Pave the way towards AI-powered test automation.
|
|
10
|
+
<br />
|
|
11
|
+
<a href="#installation">Installation</a>
|
|
12
|
+
·
|
|
13
|
+
<a href="#quick-start">Quick Start</a>
|
|
14
|
+
·
|
|
15
|
+
<a href="https://alumnium.ai/docs/">Documentation</a>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
Alumnium is an experimental project that builds upon the existing test automation ecosystem, offering a higher-level abstraction for testing. It simplifies interactions with applications and provide more robust mechanisms for verifying assertions. It works with Appium, Playwright, or Selenium.
|
|
19
|
+
|
|
20
|
+
https://github.com/user-attachments/assets/b1a548c0-f1e1-4ffe-bec9-d814770ba2ae
|
|
21
|
+
|
|
22
|
+
Currently in the very early stages of development and not recommended for production use.
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install alumnium
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
1. Run Alumnium server:
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
docker run --rm -p 8013:8013 -e OPENAI_API_KEY=... alumnium/alumnium
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
2. Run your tests:
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
import { Alumni } from "alumnium";
|
|
42
|
+
import { Builder } from "selenium-webdriver";
|
|
43
|
+
|
|
44
|
+
const driver = await new Builder().forBrowser("chrome").build();
|
|
45
|
+
const al = new Alumni(driver);
|
|
46
|
+
|
|
47
|
+
await driver.get("https://search.brave.com");
|
|
48
|
+
await al.do("type 'selenium' into the search field, then press 'Enter'");
|
|
49
|
+
await al.check("page title contains selenium");
|
|
50
|
+
await al.check("search results contain selenium.dev");
|
|
51
|
+
console.log("Atomic number:", await al.get("atomic number")); // 34
|
|
52
|
+
|
|
53
|
+
await al.quit();
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Check out [documentation][1] and more [examples][2]!
|
|
57
|
+
|
|
58
|
+
## Contributing
|
|
59
|
+
|
|
60
|
+
See the [contributing guidelines][4] for information on how to get involved in the project and develop locally.
|
|
61
|
+
|
|
62
|
+
## Acknowledgments
|
|
63
|
+
|
|
64
|
+
[][5]
|
|
65
|
+
|
|
66
|
+
Alumnium is a member of [LambdaTest][5] Open Source Program, which supports the project community and development with
|
|
67
|
+
the necessary tools. Thank you! 💚
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
[1]: https://alumnium.ai/docs/
|
|
72
|
+
[2]: https://github.com/alumnium-hq/alumnium/tree/main/packages/typescript/examples/
|
|
73
|
+
[3]: https://alumnium.ai/docs/getting-started/configuration/
|
|
74
|
+
[4]: https://github.com/alumnium-hq/alumnium/tree/main/CONTRIBUTING.md
|
|
75
|
+
[5]: https://www.lambdatest.com/
|
package/dist/Alumni.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Page } from "playwright";
|
|
2
|
+
import { WebDriver } from "selenium-webdriver";
|
|
3
|
+
import type { Browser } from "webdriverio";
|
|
4
|
+
import { Area } from "./Area.js";
|
|
5
|
+
import { Cache } from "./Cache.js";
|
|
6
|
+
import { Data } from "./clients/typecasting.js";
|
|
7
|
+
import { BaseDriver } from "./drivers/BaseDriver.js";
|
|
8
|
+
import { Element } from "./drivers/index.js";
|
|
9
|
+
import { Model } from "./Model.js";
|
|
10
|
+
import { BaseTool } from "./tools/BaseTool.js";
|
|
11
|
+
export interface AlumniOptions {
|
|
12
|
+
url?: string;
|
|
13
|
+
model?: Model;
|
|
14
|
+
extraTools?: (new (...args: any[]) => BaseTool)[];
|
|
15
|
+
}
|
|
16
|
+
export declare class Alumni {
|
|
17
|
+
driver: BaseDriver;
|
|
18
|
+
private client;
|
|
19
|
+
private tools;
|
|
20
|
+
cache: Cache;
|
|
21
|
+
private url;
|
|
22
|
+
private model;
|
|
23
|
+
constructor(driver: WebDriver | Page | Browser, options?: AlumniOptions);
|
|
24
|
+
quit(): Promise<void>;
|
|
25
|
+
do(goal: string): Promise<void>;
|
|
26
|
+
check(statement: string, vision?: boolean): Promise<string>;
|
|
27
|
+
get(data: string, vision?: boolean): Promise<Data>;
|
|
28
|
+
find(description: string): Promise<Element>;
|
|
29
|
+
area(description: string): Promise<Area>;
|
|
30
|
+
learn(goal: string, actions: string[]): Promise<void>;
|
|
31
|
+
clearLearnExamples(): Promise<void>;
|
|
32
|
+
getStats(): Promise<Record<string, Record<string, number>>>;
|
|
33
|
+
}
|
package/dist/Alumni.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { WebDriver } from "selenium-webdriver";
|
|
2
|
+
import { Area } from "./Area.js";
|
|
3
|
+
import { Cache } from "./Cache.js";
|
|
4
|
+
import { HttpClient } from "./clients/HttpClient.js";
|
|
5
|
+
import { AppiumDriver } from "./drivers/AppiumDriver.js";
|
|
6
|
+
import { PlaywrightDriver } from "./drivers/PlaywrightDriver.js";
|
|
7
|
+
import { SeleniumDriver } from "./drivers/SeleniumDriver.js";
|
|
8
|
+
import { Model } from "./Model.js";
|
|
9
|
+
import { BaseTool } from "./tools/BaseTool.js";
|
|
10
|
+
import { ClickTool } from "./tools/ClickTool.js";
|
|
11
|
+
import { DragAndDropTool } from "./tools/DragAndDropTool.js";
|
|
12
|
+
import { HoverTool } from "./tools/HoverTool.js";
|
|
13
|
+
import { PressKeyTool } from "./tools/PressKeyTool.js";
|
|
14
|
+
import { SelectTool } from "./tools/SelectTool.js";
|
|
15
|
+
import { TypeTool } from "./tools/TypeTool.js";
|
|
16
|
+
import { getLogger } from "./utils/logger.js";
|
|
17
|
+
const logger = getLogger(["Alumni"]);
|
|
18
|
+
export class Alumni {
|
|
19
|
+
constructor(driver, options = {}) {
|
|
20
|
+
this.url = options.url || "http://localhost:8013";
|
|
21
|
+
this.model = options.model || Model.current;
|
|
22
|
+
// Wrap driver or use directly if already wrapped
|
|
23
|
+
if (driver instanceof WebDriver) {
|
|
24
|
+
this.driver = new SeleniumDriver(driver);
|
|
25
|
+
}
|
|
26
|
+
else if (driver.context) {
|
|
27
|
+
this.driver = new PlaywrightDriver(driver);
|
|
28
|
+
}
|
|
29
|
+
else if (driver.capabilities &&
|
|
30
|
+
driver.getPageSource) {
|
|
31
|
+
// WebdriverIO Browser (Appium)
|
|
32
|
+
this.driver = new AppiumDriver(driver);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
throw new Error(`Unsupported driver type '${typeof driver}'`);
|
|
36
|
+
}
|
|
37
|
+
// Initialize tools
|
|
38
|
+
this.tools = {
|
|
39
|
+
ClickTool,
|
|
40
|
+
TypeTool,
|
|
41
|
+
HoverTool,
|
|
42
|
+
SelectTool,
|
|
43
|
+
PressKeyTool,
|
|
44
|
+
DragAndDropTool,
|
|
45
|
+
};
|
|
46
|
+
// Add extra tools if provided
|
|
47
|
+
if (options.extraTools) {
|
|
48
|
+
for (const tool of options.extraTools) {
|
|
49
|
+
this.tools[tool.name] = tool;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// Initialize HTTP client
|
|
53
|
+
this.client = new HttpClient(this.url, this.driver.platform, this.tools);
|
|
54
|
+
this.cache = new Cache(this.client);
|
|
55
|
+
logger.info(`Using model: ${this.model.provider}/${this.model.name}`);
|
|
56
|
+
logger.info(`Using HTTP client with server: ${this.url}`);
|
|
57
|
+
}
|
|
58
|
+
async quit() {
|
|
59
|
+
await this.client.quit();
|
|
60
|
+
await this.driver.quit();
|
|
61
|
+
}
|
|
62
|
+
async do(goal) {
|
|
63
|
+
const initialAccessibilityTree = await this.driver.getAccessibilityTree();
|
|
64
|
+
const steps = await this.client.planActions(goal, initialAccessibilityTree.toStr());
|
|
65
|
+
for (let idx = 0; idx < steps.length; idx++) {
|
|
66
|
+
const step = steps[idx];
|
|
67
|
+
// Use initial tree for first step, fresh tree for subsequent steps
|
|
68
|
+
const accessibilityTree = idx === 0
|
|
69
|
+
? initialAccessibilityTree
|
|
70
|
+
: await this.driver.getAccessibilityTree();
|
|
71
|
+
const actorResponse = await this.client.executeAction(goal, step, accessibilityTree.toStr());
|
|
72
|
+
// Execute tool calls
|
|
73
|
+
for (const toolCall of actorResponse) {
|
|
74
|
+
await BaseTool.executeToolCall(toolCall, this.tools, this.client, this.driver);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async check(statement, vision = false) {
|
|
79
|
+
const screenshot = vision ? await this.driver.screenshot() : undefined;
|
|
80
|
+
const accessibilityTree = await this.driver.getAccessibilityTree();
|
|
81
|
+
const [explanation, value] = await this.client.retrieve(`Is the following true or false - ${statement}`, accessibilityTree.toStr(), await this.driver.title(), await this.driver.url(), screenshot);
|
|
82
|
+
if (!value) {
|
|
83
|
+
throw new Error(explanation);
|
|
84
|
+
}
|
|
85
|
+
return explanation;
|
|
86
|
+
}
|
|
87
|
+
async get(data, vision = false) {
|
|
88
|
+
const screenshot = vision ? await this.driver.screenshot() : undefined;
|
|
89
|
+
const accessibilityTree = await this.driver.getAccessibilityTree();
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
91
|
+
const [_explanation, value] = await this.client.retrieve(data, accessibilityTree.toStr(), await this.driver.title(), await this.driver.url(), screenshot);
|
|
92
|
+
return value;
|
|
93
|
+
}
|
|
94
|
+
async find(description) {
|
|
95
|
+
const accessibilityTree = await this.driver.getAccessibilityTree();
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
97
|
+
const response = await this.client.findElement(description, accessibilityTree.toStr());
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
99
|
+
return this.driver.findElement(response.id);
|
|
100
|
+
}
|
|
101
|
+
async area(description) {
|
|
102
|
+
const accessibilityTree = await this.driver.getAccessibilityTree();
|
|
103
|
+
const response = await this.client.findArea(description, accessibilityTree.toStr());
|
|
104
|
+
const scopedTree = accessibilityTree.scopeToArea(response.id);
|
|
105
|
+
return new Area(response.id, response.explanation, scopedTree, this.driver, this.tools, this.client);
|
|
106
|
+
}
|
|
107
|
+
async learn(goal, actions) {
|
|
108
|
+
await this.client.addExample(goal, actions);
|
|
109
|
+
}
|
|
110
|
+
async clearLearnExamples() {
|
|
111
|
+
await this.client.clearExamples();
|
|
112
|
+
}
|
|
113
|
+
async getStats() {
|
|
114
|
+
return await this.client.getStats();
|
|
115
|
+
}
|
|
116
|
+
}
|
package/dist/Area.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseAccessibilityTree } from "./accessibility/BaseAccessibilityTree.js";
|
|
2
|
+
import { HttpClient } from "./clients/HttpClient.js";
|
|
3
|
+
import { Data } from "./clients/typecasting.js";
|
|
4
|
+
import { BaseDriver } from "./drivers/BaseDriver.js";
|
|
5
|
+
import { Element } from "./drivers/index.js";
|
|
6
|
+
import { BaseTool } from "./tools/BaseTool.js";
|
|
7
|
+
export declare class Area {
|
|
8
|
+
id: number;
|
|
9
|
+
description: string;
|
|
10
|
+
private accessibilityTree;
|
|
11
|
+
private driver;
|
|
12
|
+
private tools;
|
|
13
|
+
private client;
|
|
14
|
+
constructor(id: number, description: string, accessibilityTree: BaseAccessibilityTree, driver: BaseDriver, tools: Record<string, new (...args: any[]) => BaseTool>, client: HttpClient);
|
|
15
|
+
do(goal: string): Promise<void>;
|
|
16
|
+
check(statement: string, vision?: boolean): Promise<string>;
|
|
17
|
+
get(data: string, vision?: boolean): Promise<Data>;
|
|
18
|
+
find(description: string): Promise<Element>;
|
|
19
|
+
}
|
package/dist/Area.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { BaseTool } from "./tools/BaseTool.js";
|
|
2
|
+
export class Area {
|
|
3
|
+
constructor(id, description, accessibilityTree, driver,
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
tools, client) {
|
|
6
|
+
this.id = id;
|
|
7
|
+
this.description = description;
|
|
8
|
+
this.accessibilityTree = accessibilityTree;
|
|
9
|
+
this.driver = driver;
|
|
10
|
+
this.tools = tools;
|
|
11
|
+
this.client = client;
|
|
12
|
+
}
|
|
13
|
+
async do(goal) {
|
|
14
|
+
const steps = await this.client.planActions(goal, this.accessibilityTree.toStr());
|
|
15
|
+
for (const step of steps) {
|
|
16
|
+
const actorResponse = await this.client.executeAction(goal, step, this.accessibilityTree.toStr());
|
|
17
|
+
// Execute tool calls
|
|
18
|
+
for (const toolCall of actorResponse) {
|
|
19
|
+
await BaseTool.executeToolCall(toolCall, this.tools, this.client, this.driver);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
async check(statement, vision = false) {
|
|
24
|
+
const screenshot = vision ? await this.driver.screenshot() : undefined;
|
|
25
|
+
const [explanation, value] = await this.client.retrieve(`Is the following true or false - ${statement}`, this.accessibilityTree.toStr(), await this.driver.title(), await this.driver.url(), screenshot);
|
|
26
|
+
if (!value) {
|
|
27
|
+
throw new Error(explanation);
|
|
28
|
+
}
|
|
29
|
+
return explanation;
|
|
30
|
+
}
|
|
31
|
+
async get(data, vision = false) {
|
|
32
|
+
const screenshot = vision ? await this.driver.screenshot() : undefined;
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
34
|
+
const [_explanation, value] = await this.client.retrieve(data, this.accessibilityTree.toStr(), await this.driver.title(), await this.driver.url(), screenshot);
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
async find(description) {
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
39
|
+
const response = await this.client.findElement(description, this.accessibilityTree.toStr());
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
41
|
+
return this.driver.findElement(response.id);
|
|
42
|
+
}
|
|
43
|
+
}
|
package/dist/Cache.d.ts
ADDED
package/dist/Cache.js
ADDED
package/dist/Model.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare enum Provider {
|
|
2
|
+
AZURE_OPENAI = "azure_openai",
|
|
3
|
+
ANTHROPIC = "anthropic",
|
|
4
|
+
AWS_ANTHROPIC = "aws_anthropic",
|
|
5
|
+
AWS_META = "aws_meta",
|
|
6
|
+
DEEPSEEK = "deepseek",
|
|
7
|
+
GOOGLE = "google",
|
|
8
|
+
MISTRALAI = "mistralai",
|
|
9
|
+
OLLAMA = "ollama",
|
|
10
|
+
OPENAI = "openai"
|
|
11
|
+
}
|
|
12
|
+
export declare class ModelName {
|
|
13
|
+
static readonly DEFAULT: Record<Provider, string>;
|
|
14
|
+
}
|
|
15
|
+
export declare class Model {
|
|
16
|
+
provider: Provider;
|
|
17
|
+
name: string;
|
|
18
|
+
static current: Model;
|
|
19
|
+
constructor(provider?: Provider | string, name?: string);
|
|
20
|
+
static initialize(): void;
|
|
21
|
+
}
|
package/dist/Model.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export var Provider;
|
|
2
|
+
(function (Provider) {
|
|
3
|
+
Provider["AZURE_OPENAI"] = "azure_openai";
|
|
4
|
+
Provider["ANTHROPIC"] = "anthropic";
|
|
5
|
+
Provider["AWS_ANTHROPIC"] = "aws_anthropic";
|
|
6
|
+
Provider["AWS_META"] = "aws_meta";
|
|
7
|
+
Provider["DEEPSEEK"] = "deepseek";
|
|
8
|
+
Provider["GOOGLE"] = "google";
|
|
9
|
+
Provider["MISTRALAI"] = "mistralai";
|
|
10
|
+
Provider["OLLAMA"] = "ollama";
|
|
11
|
+
Provider["OPENAI"] = "openai";
|
|
12
|
+
})(Provider || (Provider = {}));
|
|
13
|
+
export class ModelName {
|
|
14
|
+
}
|
|
15
|
+
ModelName.DEFAULT = {
|
|
16
|
+
[Provider.AZURE_OPENAI]: "gpt-4o-mini",
|
|
17
|
+
[Provider.ANTHROPIC]: "claude-3-haiku-20240307",
|
|
18
|
+
[Provider.AWS_ANTHROPIC]: "anthropic.claude-3-haiku-20240307-v1:0",
|
|
19
|
+
[Provider.AWS_META]: "us.meta.llama4-maverick-17b-instruct-v1:0",
|
|
20
|
+
[Provider.DEEPSEEK]: "deepseek-chat",
|
|
21
|
+
[Provider.GOOGLE]: "gemini-2.0-flash-001",
|
|
22
|
+
[Provider.MISTRALAI]: "mistral-medium-2505",
|
|
23
|
+
[Provider.OLLAMA]: "mistral-small3.1",
|
|
24
|
+
[Provider.OPENAI]: "gpt-4o-mini-2024-07-18",
|
|
25
|
+
};
|
|
26
|
+
export class Model {
|
|
27
|
+
constructor(provider, name) {
|
|
28
|
+
// Convert string to Provider enum if needed
|
|
29
|
+
if (typeof provider === "string") {
|
|
30
|
+
this.provider =
|
|
31
|
+
Provider[provider.toUpperCase()] ||
|
|
32
|
+
Provider.OPENAI;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
this.provider = provider || Provider.OPENAI;
|
|
36
|
+
}
|
|
37
|
+
this.name = name || ModelName.DEFAULT[this.provider];
|
|
38
|
+
}
|
|
39
|
+
static initialize() {
|
|
40
|
+
const alumniumModel = process.env.ALUMNIUM_MODEL || "openai";
|
|
41
|
+
const [provider, ...nameParts] = alumniumModel.toLowerCase().split("/");
|
|
42
|
+
const name = nameParts.length > 0 ? nameParts[0] : undefined;
|
|
43
|
+
Model.current = new Model(provider, name);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Initialize on module load
|
|
47
|
+
Model.initialize();
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class AccessibilityElement {
|
|
2
|
+
id?: number;
|
|
3
|
+
backendNodeId?: number;
|
|
4
|
+
name?: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
type?: string;
|
|
7
|
+
value?: string;
|
|
8
|
+
androidResourceId?: string;
|
|
9
|
+
androidClass?: string;
|
|
10
|
+
androidText?: string;
|
|
11
|
+
androidContentDesc?: string;
|
|
12
|
+
androidBounds?: string;
|
|
13
|
+
constructor(id?: number, name?: string, label?: string, type?: string, value?: string, backendNodeId?: number, androidResourceId?: string, androidClass?: string, androidText?: string, androidContentDesc?: string, androidBounds?: string);
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class AccessibilityElement {
|
|
2
|
+
constructor(id, name, label, type, value, backendNodeId, androidResourceId, androidClass, androidText, androidContentDesc, androidBounds) {
|
|
3
|
+
this.id = id;
|
|
4
|
+
this.backendNodeId = backendNodeId;
|
|
5
|
+
this.name = name;
|
|
6
|
+
this.label = label;
|
|
7
|
+
this.type = type;
|
|
8
|
+
this.value = value;
|
|
9
|
+
this.androidResourceId = androidResourceId;
|
|
10
|
+
this.androidClass = androidClass;
|
|
11
|
+
this.androidText = androidText;
|
|
12
|
+
this.androidContentDesc = androidContentDesc;
|
|
13
|
+
this.androidBounds = androidBounds;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AccessibilityElement } from "./AccessibilityElement.js";
|
|
2
|
+
export declare abstract class BaseAccessibilityTree {
|
|
3
|
+
abstract toStr(): string;
|
|
4
|
+
abstract elementById(id: number): AccessibilityElement;
|
|
5
|
+
abstract scopeToArea(rawId: number): BaseAccessibilityTree;
|
|
6
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AccessibilityElement } from "./AccessibilityElement.js";
|
|
2
|
+
import { BaseAccessibilityTree } from "./BaseAccessibilityTree.js";
|
|
3
|
+
interface CDPResponse {
|
|
4
|
+
nodes: any[];
|
|
5
|
+
}
|
|
6
|
+
export declare class ChromiumAccessibilityTree extends BaseAccessibilityTree {
|
|
7
|
+
private cdpResponse;
|
|
8
|
+
private nextRawId;
|
|
9
|
+
private raw;
|
|
10
|
+
constructor(cdpResponse: CDPResponse);
|
|
11
|
+
private static fromXml;
|
|
12
|
+
toStr(): string;
|
|
13
|
+
private nodeToXml;
|
|
14
|
+
private elementToString;
|
|
15
|
+
elementById(rawId: number): AccessibilityElement;
|
|
16
|
+
scopeToArea(rawId: number): ChromiumAccessibilityTree;
|
|
17
|
+
private findElementByRawId;
|
|
18
|
+
private parseSimpleXml;
|
|
19
|
+
}
|
|
20
|
+
export {};
|