@airtop/sdk 1.0.0-alpha2.19 → 1.0.0-alpha2.20
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/dist/index.cjs +137 -137
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +170 -170
- package/dist/index.d.ts +170 -170
- package/dist/index.js +145 -145
- package/dist/index.js.map +1 -1
- package/package.json +13 -12
package/dist/index.js
CHANGED
@@ -9,7 +9,7 @@ var require_package = __commonJS({
|
|
9
9
|
module.exports = {
|
10
10
|
name: "@airtop/sdk",
|
11
11
|
description: "Airtop SDK for TypeScript",
|
12
|
-
version: "1.0.0-alpha2.
|
12
|
+
version: "1.0.0-alpha2.20",
|
13
13
|
type: "module",
|
14
14
|
main: "./dist/index.cjs",
|
15
15
|
module: "./dist/index.js",
|
@@ -38,34 +38,35 @@ var require_package = __commonJS({
|
|
38
38
|
"agentic"
|
39
39
|
],
|
40
40
|
scripts: {
|
41
|
-
"build:second-stage": "tsup src/index.ts",
|
42
41
|
"test:e2e": "vitest --run",
|
43
42
|
"build:dev": "node_modules/.bin/hash-runner",
|
43
|
+
build: "tsup src/index.ts",
|
44
44
|
clean: "rm -rf .turbo node_modules dist",
|
45
|
-
lint: "biome check --write --unsafe src
|
45
|
+
lint: "biome check --no-errors-on-unmatched --write --unsafe src",
|
46
|
+
"lint:staged": "biome check --no-errors-on-unmatched --write --unsafe --staged src",
|
46
47
|
"verify-types": "tsc --noEmit"
|
47
48
|
},
|
48
49
|
dependencies: {
|
49
50
|
"@airtop/json-schema-adapter": "workspace:*",
|
50
|
-
"@airtop/core": "0.1.0-alpha.
|
51
|
+
"@airtop/core": "0.1.0-alpha.36",
|
51
52
|
"date-fns": "4.1.0",
|
52
|
-
loglayer: "6.
|
53
|
+
loglayer: "6.6.0",
|
53
54
|
"serialize-error": "12.0.0",
|
54
55
|
uuid: "11.1.0"
|
55
56
|
},
|
56
57
|
devDependencies: {
|
57
|
-
"@biomejs/biome": "1.
|
58
|
-
"@dotenvx/dotenvx": "1.
|
58
|
+
"@biomejs/biome": "2.1.2",
|
59
|
+
"@dotenvx/dotenvx": "1.48.0",
|
59
60
|
"@internal/tsconfig": "workspace:*",
|
60
61
|
"deep-utility-types": "1.3.1",
|
61
62
|
"env-var": "7.5.0",
|
62
63
|
"hash-runner": "2.0.1",
|
63
64
|
nanoid: "5.1.5",
|
64
|
-
tsup: "8.
|
65
|
-
typescript: "5.8.
|
65
|
+
tsup: "8.5.0",
|
66
|
+
typescript: "5.8.3",
|
66
67
|
"utility-types": "3.11.0",
|
67
68
|
uuid: "11.1.0",
|
68
|
-
vitest: "3.
|
69
|
+
vitest: "3.2.4",
|
69
70
|
zod: "*"
|
70
71
|
},
|
71
72
|
bugs: "https://github.com/airtop-ai/airtop-sdk/issues",
|
@@ -79,7 +80,7 @@ var require_package = __commonJS({
|
|
79
80
|
optionalDependencies: {
|
80
81
|
"@airtop/json-schema-adapter-zod": "workspace:*"
|
81
82
|
},
|
82
|
-
packageManager: "pnpm@10.
|
83
|
+
packageManager: "pnpm@10.12.4"
|
83
84
|
};
|
84
85
|
}
|
85
86
|
});
|
@@ -1532,56 +1533,102 @@ var AirtopClient = class extends AirtopBase {
|
|
1532
1533
|
}
|
1533
1534
|
};
|
1534
1535
|
|
1535
|
-
// src/
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
for (const pluginToAdd of plugin.pluginsToAdd) {
|
1556
|
-
switch (pluginToAdd.augmentationType) {
|
1557
|
-
case "AirtopClient" /* AirtopClient */:
|
1558
|
-
pluginToAdd.augment(AirtopClient.prototype);
|
1559
|
-
break;
|
1560
|
-
case "AirtopSessionClient" /* AirtopSessionClient */:
|
1561
|
-
pluginToAdd.augment(AirtopSessionClient.prototype);
|
1562
|
-
break;
|
1563
|
-
case "AirtopSession" /* AirtopSession */:
|
1564
|
-
pluginToAdd.augment(AirtopSession.prototype);
|
1565
|
-
break;
|
1566
|
-
case "AirtopWindowClient" /* AirtopWindowClient */:
|
1567
|
-
pluginToAdd.augment(AirtopWindowClient.prototype);
|
1568
|
-
break;
|
1569
|
-
case "AirtopWindow" /* AirtopWindow */:
|
1570
|
-
pluginToAdd.augment(AirtopWindow.prototype);
|
1571
|
-
break;
|
1572
|
-
case "AirtopWindowScreenshot" /* AirtopWindowScreenshot */:
|
1573
|
-
pluginToAdd.augment(AirtopWindowScreenshot.prototype);
|
1574
|
-
break;
|
1536
|
+
// src/AirtopMocks.ts
|
1537
|
+
import { Airtop as AirtopCore2 } from "@airtop/core";
|
1538
|
+
import { MockLogLayer } from "loglayer";
|
1539
|
+
import { v4 as uuidv4 } from "uuid";
|
1540
|
+
function createNoOpClient(client) {
|
1541
|
+
return new Proxy(client, {
|
1542
|
+
get(target, prop) {
|
1543
|
+
const value = Reflect.get(target, prop);
|
1544
|
+
if (typeof value === "function") {
|
1545
|
+
return async () => ({
|
1546
|
+
data: {},
|
1547
|
+
meta: {},
|
1548
|
+
warnings: [],
|
1549
|
+
errors: []
|
1550
|
+
});
|
1551
|
+
}
|
1552
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
1553
|
+
return createNoOpClient(value);
|
1554
|
+
}
|
1555
|
+
return value;
|
1575
1556
|
}
|
1576
|
-
}
|
1557
|
+
});
|
1577
1558
|
}
|
1559
|
+
function generateCommonAirtopConfigMock() {
|
1560
|
+
const client = new AirtopCore2({
|
1561
|
+
apiKey: "test-api-key"
|
1562
|
+
});
|
1563
|
+
return {
|
1564
|
+
log: new MockLogLayer(),
|
1565
|
+
client: createNoOpClient(client)
|
1566
|
+
};
|
1567
|
+
}
|
1568
|
+
var AirtopMocks = class {
|
1569
|
+
/**
|
1570
|
+
* Creates an AirtopBase instance (the class used as the base for other Airtop classes) with a mock client and logger.
|
1571
|
+
*/
|
1572
|
+
static getAirtopBaseMock(config = {}) {
|
1573
|
+
return new AirtopBase({
|
1574
|
+
...generateCommonAirtopConfigMock(),
|
1575
|
+
...config
|
1576
|
+
});
|
1577
|
+
}
|
1578
|
+
/**
|
1579
|
+
* Creates an Airtop instance with a mock client and data.
|
1580
|
+
*/
|
1581
|
+
static getAirtopClientMock(config = {}) {
|
1582
|
+
const client = new AirtopClient({
|
1583
|
+
apiKey: "test-api-key",
|
1584
|
+
...config
|
1585
|
+
});
|
1586
|
+
const mocks = generateCommonAirtopConfigMock();
|
1587
|
+
client["log"] = mocks.log;
|
1588
|
+
client["client"] = mocks.client;
|
1589
|
+
return client;
|
1590
|
+
}
|
1591
|
+
/**
|
1592
|
+
* Creates an AirtopSession instance with a mock client and data.
|
1593
|
+
*/
|
1594
|
+
static getAirtopSessionMock(responseData = {}) {
|
1595
|
+
return new AirtopSession(generateCommonAirtopConfigMock(), {
|
1596
|
+
data: {
|
1597
|
+
id: uuidv4(),
|
1598
|
+
configuration: {},
|
1599
|
+
chromedriverUrl: "http://localhost:9515",
|
1600
|
+
status: "active"
|
1601
|
+
},
|
1602
|
+
meta: {},
|
1603
|
+
warnings: [],
|
1604
|
+
...responseData
|
1605
|
+
});
|
1606
|
+
}
|
1607
|
+
/**
|
1608
|
+
* Creates an AirtopWindow instance with a mock client and data.
|
1609
|
+
*/
|
1610
|
+
static getAirtopWindowMock({
|
1611
|
+
sessionId,
|
1612
|
+
windowData
|
1613
|
+
} = {}) {
|
1614
|
+
return new AirtopWindow(generateCommonAirtopConfigMock(), sessionId || uuidv4(), {
|
1615
|
+
data: {
|
1616
|
+
targetId: uuidv4(),
|
1617
|
+
windowId: uuidv4(),
|
1618
|
+
liveViewUrl: "http://localhost:4567"
|
1619
|
+
},
|
1620
|
+
meta: {},
|
1621
|
+
warnings: [],
|
1622
|
+
...windowData || {}
|
1623
|
+
});
|
1624
|
+
}
|
1625
|
+
};
|
1578
1626
|
|
1579
1627
|
// src/agent/AirtopAgentClient.ts
|
1580
|
-
import { version as version2 } from "
|
1581
|
-
import { Airtop as
|
1628
|
+
import { version as version2 } from "process";
|
1629
|
+
import { Airtop as AirtopCore3 } from "@airtop/core";
|
1582
1630
|
import { minutesToMilliseconds } from "date-fns";
|
1583
|
-
import { ConsoleTransport as ConsoleTransport2 } from "loglayer";
|
1584
|
-
import { LogLayer as LogLayer2 } from "loglayer";
|
1631
|
+
import { ConsoleTransport as ConsoleTransport2, LogLayer as LogLayer2 } from "loglayer";
|
1585
1632
|
import { serializeError as serializeError2 } from "serialize-error";
|
1586
1633
|
var AirtopAgentClient = class extends AirtopBase {
|
1587
1634
|
/**
|
@@ -1591,7 +1638,7 @@ var AirtopAgentClient = class extends AirtopBase {
|
|
1591
1638
|
constructor(config) {
|
1592
1639
|
super({
|
1593
1640
|
logLevel: config?.logLevel,
|
1594
|
-
client: new
|
1641
|
+
client: new AirtopCore3({
|
1595
1642
|
maxRetries: 0,
|
1596
1643
|
timeout: minutesToMilliseconds(1),
|
1597
1644
|
apiKey: config.apiKey,
|
@@ -1759,96 +1806,49 @@ var AirtopAgentClient = class extends AirtopBase {
|
|
1759
1806
|
}
|
1760
1807
|
};
|
1761
1808
|
|
1762
|
-
// src/
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1809
|
+
// src/window/AirtopWindowClient.types.ts
|
1810
|
+
var WindowNavigateDirection = /* @__PURE__ */ ((WindowNavigateDirection2) => {
|
1811
|
+
WindowNavigateDirection2["BACK"] = "backward";
|
1812
|
+
WindowNavigateDirection2["FORWARD"] = "forward";
|
1813
|
+
return WindowNavigateDirection2;
|
1814
|
+
})(WindowNavigateDirection || {});
|
1815
|
+
|
1816
|
+
// src/plugin/AirtopPlugin.types.ts
|
1817
|
+
var AirtopPluginAugmentationType = /* @__PURE__ */ ((AirtopPluginAugmentationType2) => {
|
1818
|
+
AirtopPluginAugmentationType2["AirtopClient"] = "AirtopClient";
|
1819
|
+
AirtopPluginAugmentationType2["AirtopWindowClient"] = "AirtopWindowClient";
|
1820
|
+
AirtopPluginAugmentationType2["AirtopWindow"] = "AirtopWindow";
|
1821
|
+
AirtopPluginAugmentationType2["AirtopSessionClient"] = "AirtopSessionClient";
|
1822
|
+
AirtopPluginAugmentationType2["AirtopSession"] = "AirtopSession";
|
1823
|
+
AirtopPluginAugmentationType2["AirtopWindowScreenshot"] = "AirtopWindowScreenshot";
|
1824
|
+
return AirtopPluginAugmentationType2;
|
1825
|
+
})(AirtopPluginAugmentationType || {});
|
1826
|
+
|
1827
|
+
// src/plugin/AirtopPlugin.ts
|
1828
|
+
function registerAirtopPlugin(plugin) {
|
1829
|
+
for (const pluginToAdd of plugin.pluginsToAdd) {
|
1830
|
+
switch (pluginToAdd.augmentationType) {
|
1831
|
+
case "AirtopClient" /* AirtopClient */:
|
1832
|
+
pluginToAdd.augment(AirtopClient.prototype);
|
1833
|
+
break;
|
1834
|
+
case "AirtopSessionClient" /* AirtopSessionClient */:
|
1835
|
+
pluginToAdd.augment(AirtopSessionClient.prototype);
|
1836
|
+
break;
|
1837
|
+
case "AirtopSession" /* AirtopSession */:
|
1838
|
+
pluginToAdd.augment(AirtopSession.prototype);
|
1839
|
+
break;
|
1840
|
+
case "AirtopWindowClient" /* AirtopWindowClient */:
|
1841
|
+
pluginToAdd.augment(AirtopWindowClient.prototype);
|
1842
|
+
break;
|
1843
|
+
case "AirtopWindow" /* AirtopWindow */:
|
1844
|
+
pluginToAdd.augment(AirtopWindow.prototype);
|
1845
|
+
break;
|
1846
|
+
case "AirtopWindowScreenshot" /* AirtopWindowScreenshot */:
|
1847
|
+
pluginToAdd.augment(AirtopWindowScreenshot.prototype);
|
1848
|
+
break;
|
1782
1849
|
}
|
1783
|
-
});
|
1784
|
-
}
|
1785
|
-
function generateCommonAirtopConfigMock() {
|
1786
|
-
const client = new AirtopCore3({
|
1787
|
-
apiKey: "test-api-key"
|
1788
|
-
});
|
1789
|
-
return {
|
1790
|
-
log: new MockLogLayer(),
|
1791
|
-
client: createNoOpClient(client)
|
1792
|
-
};
|
1793
|
-
}
|
1794
|
-
var AirtopMocks = class {
|
1795
|
-
/**
|
1796
|
-
* Creates an AirtopBase instance (the class used as the base for other Airtop classes) with a mock client and logger.
|
1797
|
-
*/
|
1798
|
-
static getAirtopBaseMock(config = {}) {
|
1799
|
-
return new AirtopBase({
|
1800
|
-
...generateCommonAirtopConfigMock(),
|
1801
|
-
...config
|
1802
|
-
});
|
1803
|
-
}
|
1804
|
-
/**
|
1805
|
-
* Creates an Airtop instance with a mock client and data.
|
1806
|
-
*/
|
1807
|
-
static getAirtopClientMock(config = {}) {
|
1808
|
-
const client = new AirtopClient({
|
1809
|
-
apiKey: "test-api-key",
|
1810
|
-
...config
|
1811
|
-
});
|
1812
|
-
const mocks = generateCommonAirtopConfigMock();
|
1813
|
-
client["log"] = mocks.log;
|
1814
|
-
client["client"] = mocks.client;
|
1815
|
-
return client;
|
1816
|
-
}
|
1817
|
-
/**
|
1818
|
-
* Creates an AirtopSession instance with a mock client and data.
|
1819
|
-
*/
|
1820
|
-
static getAirtopSessionMock(responseData = {}) {
|
1821
|
-
return new AirtopSession(generateCommonAirtopConfigMock(), {
|
1822
|
-
data: {
|
1823
|
-
id: uuidv4(),
|
1824
|
-
configuration: {},
|
1825
|
-
chromedriverUrl: "http://localhost:9515",
|
1826
|
-
status: "active"
|
1827
|
-
},
|
1828
|
-
meta: {},
|
1829
|
-
warnings: [],
|
1830
|
-
...responseData
|
1831
|
-
});
|
1832
|
-
}
|
1833
|
-
/**
|
1834
|
-
* Creates an AirtopWindow instance with a mock client and data.
|
1835
|
-
*/
|
1836
|
-
static getAirtopWindowMock({
|
1837
|
-
sessionId,
|
1838
|
-
windowData
|
1839
|
-
} = {}) {
|
1840
|
-
return new AirtopWindow(generateCommonAirtopConfigMock(), sessionId || uuidv4(), {
|
1841
|
-
data: {
|
1842
|
-
targetId: uuidv4(),
|
1843
|
-
windowId: uuidv4(),
|
1844
|
-
liveViewUrl: "http://localhost:4567"
|
1845
|
-
},
|
1846
|
-
meta: {},
|
1847
|
-
warnings: [],
|
1848
|
-
...windowData || {}
|
1849
|
-
});
|
1850
1850
|
}
|
1851
|
-
}
|
1851
|
+
}
|
1852
1852
|
export {
|
1853
1853
|
AirtopAgentClient,
|
1854
1854
|
AirtopBase,
|