notte-sdk 1.10.14 → 1.10.16
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.d.mts +2515 -2250
- package/dist/index.d.ts +2515 -2250
- package/dist/index.js +175 -85
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +173 -85
- package/dist/index.mjs.map +1 -1
- package/dist/proxy/core.js +3 -0
- package/dist/proxy/core.js.map +1 -1
- package/dist/proxy/core.mjs +3 -0
- package/dist/proxy/core.mjs.map +1 -1
- package/dist/proxy/next.js +3 -0
- package/dist/proxy/next.js.map +1 -1
- package/dist/proxy/next.mjs +3 -0
- package/dist/proxy/next.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var SDK_VERSION = true ? "1.10.
|
|
2
|
+
var SDK_VERSION = true ? "1.10.16" : "dev";
|
|
3
3
|
var SDK_PACKAGE_NAME = true ? "notte-sdk" : "notte-sdk";
|
|
4
4
|
|
|
5
5
|
// src/version-check.ts
|
|
@@ -937,15 +937,14 @@ var createClient = (config = {}) => {
|
|
|
937
937
|
var client = createClient(createConfig({ baseUrl: "https://api.notte.cc" }));
|
|
938
938
|
|
|
939
939
|
// src/lib/client/sdk.gen.ts
|
|
940
|
-
var
|
|
941
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
942
|
-
url: "/sessions/{session_id}/auth",
|
|
943
|
-
...options
|
|
944
|
-
});
|
|
945
|
-
var listSessions = (options) => (options?.client ?? client).get({
|
|
940
|
+
var recommendLaunchPreset = (options) => (options.client ?? client).post({
|
|
946
941
|
security: [{ scheme: "bearer", type: "http" }],
|
|
947
|
-
url: "/
|
|
948
|
-
...options
|
|
942
|
+
url: "/launch-presets/recommend",
|
|
943
|
+
...options,
|
|
944
|
+
headers: {
|
|
945
|
+
"Content-Type": "application/json",
|
|
946
|
+
...options.headers
|
|
947
|
+
}
|
|
949
948
|
});
|
|
950
949
|
var sessionStart = (options) => (options.client ?? client).post({
|
|
951
950
|
security: [{ scheme: "bearer", type: "http" }],
|
|
@@ -956,11 +955,6 @@ var sessionStart = (options) => (options.client ?? client).post({
|
|
|
956
955
|
...options.headers
|
|
957
956
|
}
|
|
958
957
|
});
|
|
959
|
-
var sessionStatus = (options) => (options.client ?? client).get({
|
|
960
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
961
|
-
url: "/sessions/{session_id}",
|
|
962
|
-
...options
|
|
963
|
-
});
|
|
964
958
|
var sessionSteps = (options) => (options.client ?? client).get({
|
|
965
959
|
security: [{ scheme: "bearer", type: "http" }],
|
|
966
960
|
url: "/sessions/{session_id}/steps",
|
|
@@ -1087,21 +1081,6 @@ var pageDocumentRead = (options) => (options.client ?? client).post({
|
|
|
1087
1081
|
...options.headers
|
|
1088
1082
|
}
|
|
1089
1083
|
});
|
|
1090
|
-
var sessionNetworkLogs = (options) => (options.client ?? client).get({
|
|
1091
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1092
|
-
url: "/sessions/{session_id}/network/logs",
|
|
1093
|
-
...options
|
|
1094
|
-
});
|
|
1095
|
-
var sessionMouseReplay = (options) => (options.client ?? client).get({
|
|
1096
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1097
|
-
url: "/sessions/{session_id}/replay/mouse",
|
|
1098
|
-
...options
|
|
1099
|
-
});
|
|
1100
|
-
var sessionReplay = (options) => (options.client ?? client).get({
|
|
1101
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1102
|
-
url: "/sessions/{session_id}/replay",
|
|
1103
|
-
...options
|
|
1104
|
-
});
|
|
1105
1084
|
var executeSessionFile = (options) => (options.client ?? client).post({
|
|
1106
1085
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1107
1086
|
url: "/sessions/{session_id}/page/execute/file",
|
|
@@ -1471,48 +1450,6 @@ var profileList = (options) => (options?.client ?? client).get({
|
|
|
1471
1450
|
url: "/profiles",
|
|
1472
1451
|
...options
|
|
1473
1452
|
});
|
|
1474
|
-
var mailboxConnectToken = (options) => (options.client ?? client).post({
|
|
1475
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1476
|
-
url: "/mailboxes/connect-token",
|
|
1477
|
-
...options,
|
|
1478
|
-
headers: {
|
|
1479
|
-
"Content-Type": "application/json",
|
|
1480
|
-
...options.headers
|
|
1481
|
-
}
|
|
1482
|
-
});
|
|
1483
|
-
var mailboxSync = (options) => (options?.client ?? client).post({
|
|
1484
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1485
|
-
url: "/mailboxes/sync",
|
|
1486
|
-
...options,
|
|
1487
|
-
headers: {
|
|
1488
|
-
"Content-Type": "application/json",
|
|
1489
|
-
...options?.headers
|
|
1490
|
-
}
|
|
1491
|
-
});
|
|
1492
|
-
var mailboxList = (options) => (options?.client ?? client).get({
|
|
1493
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1494
|
-
url: "/mailboxes",
|
|
1495
|
-
...options
|
|
1496
|
-
});
|
|
1497
|
-
var mailboxDelete = (options) => (options.client ?? client).delete({
|
|
1498
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1499
|
-
url: "/mailboxes/{mailbox_id}",
|
|
1500
|
-
...options
|
|
1501
|
-
});
|
|
1502
|
-
var mailboxGet = (options) => (options.client ?? client).get({
|
|
1503
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1504
|
-
url: "/mailboxes/{mailbox_id}",
|
|
1505
|
-
...options
|
|
1506
|
-
});
|
|
1507
|
-
var mailboxUpdate = (options) => (options.client ?? client).patch({
|
|
1508
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1509
|
-
url: "/mailboxes/{mailbox_id}",
|
|
1510
|
-
...options,
|
|
1511
|
-
headers: {
|
|
1512
|
-
"Content-Type": "application/json",
|
|
1513
|
-
...options.headers
|
|
1514
|
-
}
|
|
1515
|
-
});
|
|
1516
1453
|
var managedAuthConnectLinkCreate = (options) => (options.client ?? client).post({
|
|
1517
1454
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1518
1455
|
url: "/managed-auth/connect-links",
|
|
@@ -1549,15 +1486,6 @@ var connectLinkSubmit = (options) => (options.client ?? client).post({
|
|
|
1549
1486
|
}
|
|
1550
1487
|
});
|
|
1551
1488
|
var connectLinkStatus = (options) => (options.client ?? client).get({ url: "/managed-auth/connect-links/status", ...options });
|
|
1552
|
-
var anythingStart = (options) => (options.client ?? client).post({
|
|
1553
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1554
|
-
url: "/anything/start",
|
|
1555
|
-
...options,
|
|
1556
|
-
headers: {
|
|
1557
|
-
"Content-Type": "application/json",
|
|
1558
|
-
...options.headers
|
|
1559
|
-
}
|
|
1560
|
-
});
|
|
1561
1489
|
var listSecrets = (options) => (options?.client ?? client).get({
|
|
1562
1490
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1563
1491
|
url: "/secrets",
|
|
@@ -1820,11 +1748,62 @@ var scrapeFromHtml = (options) => (options.client ?? client).post({
|
|
|
1820
1748
|
...options.headers
|
|
1821
1749
|
}
|
|
1822
1750
|
});
|
|
1751
|
+
var anythingStart = (options) => (options.client ?? client).sse.post({
|
|
1752
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1753
|
+
url: "/anything/start",
|
|
1754
|
+
...options,
|
|
1755
|
+
headers: {
|
|
1756
|
+
"Content-Type": "application/json",
|
|
1757
|
+
...options.headers
|
|
1758
|
+
}
|
|
1759
|
+
});
|
|
1823
1760
|
var listAuditEvents = (options) => (options?.client ?? client).get({
|
|
1824
1761
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1825
1762
|
url: "/audit-events",
|
|
1826
1763
|
...options
|
|
1827
1764
|
});
|
|
1765
|
+
var mailboxList = (options) => (options?.client ?? client).get({
|
|
1766
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1767
|
+
url: "/mailboxes",
|
|
1768
|
+
...options
|
|
1769
|
+
});
|
|
1770
|
+
var mailboxConnectToken = (options) => (options.client ?? client).post({
|
|
1771
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1772
|
+
url: "/mailboxes/connect-token",
|
|
1773
|
+
...options,
|
|
1774
|
+
headers: {
|
|
1775
|
+
"Content-Type": "application/json",
|
|
1776
|
+
...options.headers
|
|
1777
|
+
}
|
|
1778
|
+
});
|
|
1779
|
+
var mailboxSync = (options) => (options?.client ?? client).post({
|
|
1780
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1781
|
+
url: "/mailboxes/sync",
|
|
1782
|
+
...options,
|
|
1783
|
+
headers: {
|
|
1784
|
+
"Content-Type": "application/json",
|
|
1785
|
+
...options?.headers
|
|
1786
|
+
}
|
|
1787
|
+
});
|
|
1788
|
+
var mailboxDelete = (options) => (options.client ?? client).delete({
|
|
1789
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1790
|
+
url: "/mailboxes/{mailbox_id}",
|
|
1791
|
+
...options
|
|
1792
|
+
});
|
|
1793
|
+
var mailboxGet = (options) => (options.client ?? client).get({
|
|
1794
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1795
|
+
url: "/mailboxes/{mailbox_id}",
|
|
1796
|
+
...options
|
|
1797
|
+
});
|
|
1798
|
+
var mailboxUpdate = (options) => (options.client ?? client).patch({
|
|
1799
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1800
|
+
url: "/mailboxes/{mailbox_id}",
|
|
1801
|
+
...options,
|
|
1802
|
+
headers: {
|
|
1803
|
+
"Content-Type": "application/json",
|
|
1804
|
+
...options.headers
|
|
1805
|
+
}
|
|
1806
|
+
});
|
|
1828
1807
|
var listPersonas = (options) => (options?.client ?? client).get({
|
|
1829
1808
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1830
1809
|
url: "/personas",
|
|
@@ -1873,6 +1852,36 @@ var listSecretProxyHostPresets = (options) => (options?.client ?? client).get({
|
|
|
1873
1852
|
url: "/secret-proxy/host-presets",
|
|
1874
1853
|
...options
|
|
1875
1854
|
});
|
|
1855
|
+
var listSessions = (options) => (options?.client ?? client).get({
|
|
1856
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1857
|
+
url: "/sessions",
|
|
1858
|
+
...options
|
|
1859
|
+
});
|
|
1860
|
+
var sessionStatus = (options) => (options.client ?? client).get({
|
|
1861
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1862
|
+
url: "/sessions/{session_id}",
|
|
1863
|
+
...options
|
|
1864
|
+
});
|
|
1865
|
+
var sessionAuthReadiness = (options) => (options.client ?? client).get({
|
|
1866
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1867
|
+
url: "/sessions/{session_id}/auth",
|
|
1868
|
+
...options
|
|
1869
|
+
});
|
|
1870
|
+
var sessionNetworkLogs = (options) => (options.client ?? client).get({
|
|
1871
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1872
|
+
url: "/sessions/{session_id}/network/logs",
|
|
1873
|
+
...options
|
|
1874
|
+
});
|
|
1875
|
+
var sessionReplay = (options) => (options.client ?? client).get({
|
|
1876
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1877
|
+
url: "/sessions/{session_id}/replay",
|
|
1878
|
+
...options
|
|
1879
|
+
});
|
|
1880
|
+
var sessionMouseReplay = (options) => (options.client ?? client).get({
|
|
1881
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1882
|
+
url: "/sessions/{session_id}/replay/mouse",
|
|
1883
|
+
...options
|
|
1884
|
+
});
|
|
1876
1885
|
var getUsage = (options) => (options?.client ?? client).get({
|
|
1877
1886
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1878
1887
|
url: "/usage",
|
|
@@ -2044,6 +2053,31 @@ var CaptchaRejectedError = class extends ActionExecutionError {
|
|
|
2044
2053
|
super({ error_type: "CaptchaRejectedError", dev_message: message, user_message: message, agent_message: message });
|
|
2045
2054
|
}
|
|
2046
2055
|
};
|
|
2056
|
+
var SessionClosedError = class extends NotteError {
|
|
2057
|
+
sessionId;
|
|
2058
|
+
status;
|
|
2059
|
+
closeReason;
|
|
2060
|
+
constructor(sessionId, status, closeReason, timeouts = {}, options) {
|
|
2061
|
+
super(`Session ${sessionId} is closed: ${closeDescription(status, closeReason, timeouts)}. Start a new session.`, options);
|
|
2062
|
+
this.sessionId = sessionId;
|
|
2063
|
+
this.status = status;
|
|
2064
|
+
this.closeReason = closeReason;
|
|
2065
|
+
}
|
|
2066
|
+
};
|
|
2067
|
+
function closeDescription(status, closeReason, { idleTimeoutMinutes, maxDurationMinutes }) {
|
|
2068
|
+
switch (closeReason) {
|
|
2069
|
+
case "idle_timeout":
|
|
2070
|
+
return idleTimeoutMinutes === void 0 ? "it timed out without activity" : `it timed out after ${idleTimeoutMinutes} minutes without activity`;
|
|
2071
|
+
case "max_duration":
|
|
2072
|
+
return maxDurationMinutes === void 0 ? "it reached its maximum duration" : `it reached its maximum duration of ${maxDurationMinutes} minutes`;
|
|
2073
|
+
case "manual":
|
|
2074
|
+
return "it was stopped";
|
|
2075
|
+
case "error":
|
|
2076
|
+
return "it ended with an error";
|
|
2077
|
+
default:
|
|
2078
|
+
return `its status is ${status}`;
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2047
2081
|
var EvaluateJsNoDataError = class extends NotteError {
|
|
2048
2082
|
constructor() {
|
|
2049
2083
|
super("evaluate_js returned no data. Upgrade the Notte API to a build that returns the evaluated value.");
|
|
@@ -3325,6 +3359,46 @@ async function* iterSessionSteps(client2, sessionId, options = {}) {
|
|
|
3325
3359
|
var SESSION_START_TRIES = 3;
|
|
3326
3360
|
var CLUSTER_OVERLOAD_RETRY_DELAY_MS = 3e4;
|
|
3327
3361
|
var CAPTCHA_SOLVE_TIMEOUT_MS = 1e5;
|
|
3362
|
+
var CDP_CONNECT_RETRY_DELAY_MS = 300;
|
|
3363
|
+
var CDP_TRANSPORT_FAILURES = [
|
|
3364
|
+
"socket hang up",
|
|
3365
|
+
"ECONNRESET",
|
|
3366
|
+
"ECONNREFUSED",
|
|
3367
|
+
"ETIMEDOUT",
|
|
3368
|
+
"Client network socket disconnected before secure TLS connection was established"
|
|
3369
|
+
];
|
|
3370
|
+
function cdpTransportFailure(error) {
|
|
3371
|
+
const firstLine = (error instanceof Error ? error.message : String(error)).split("\n", 1)[0] ?? "";
|
|
3372
|
+
const marker = "WebSocket error: ";
|
|
3373
|
+
const at = firstLine.indexOf(marker);
|
|
3374
|
+
if (at < 0) return void 0;
|
|
3375
|
+
const reason = firstLine.slice(at + marker.length);
|
|
3376
|
+
if (reason.startsWith("ws://") || reason.startsWith("wss://")) return void 0;
|
|
3377
|
+
return CDP_TRANSPORT_FAILURES.some((failure) => reason.includes(failure)) ? reason : void 0;
|
|
3378
|
+
}
|
|
3379
|
+
async function connectOverCdpWithRetry(connect) {
|
|
3380
|
+
try {
|
|
3381
|
+
return await connect();
|
|
3382
|
+
} catch (error) {
|
|
3383
|
+
const reason = cdpTransportFailure(error);
|
|
3384
|
+
if (reason === void 0) throw error;
|
|
3385
|
+
console.warn(`[Session] CDP connection failed (${reason}), retrying once in ${CDP_CONNECT_RETRY_DELAY_MS / 1e3}s`);
|
|
3386
|
+
}
|
|
3387
|
+
await delay2(CDP_CONNECT_RETRY_DELAY_MS);
|
|
3388
|
+
return connect();
|
|
3389
|
+
}
|
|
3390
|
+
function closedSessionError(response, cause) {
|
|
3391
|
+
if (response.status !== "closed" && response.status !== "error" && response.status !== "timed_out") {
|
|
3392
|
+
return null;
|
|
3393
|
+
}
|
|
3394
|
+
return new SessionClosedError(
|
|
3395
|
+
response.session_id,
|
|
3396
|
+
response.status,
|
|
3397
|
+
response.close_reason ?? null,
|
|
3398
|
+
{ idleTimeoutMinutes: response.idle_timeout_minutes, maxDurationMinutes: response.max_duration_minutes },
|
|
3399
|
+
{ cause }
|
|
3400
|
+
);
|
|
3401
|
+
}
|
|
3328
3402
|
var OBSERVE_MIGRATION_URL = "https://docs.notte.cc/features/sessions/observe-migration";
|
|
3329
3403
|
var OBSERVE_DEPRECATIONS = {
|
|
3330
3404
|
instructions: `\`observe({ instructions })\` is deprecated and will be removed on December 1, 2026; the Python SDK's local sessions replace it with session.act(); here, call observe() without it and pick from the returned actions. See ${OBSERVE_MIGRATION_URL}`,
|
|
@@ -3940,9 +4014,11 @@ var Session = class {
|
|
|
3940
4014
|
try {
|
|
3941
4015
|
if (!this.playwrightBrowser) {
|
|
3942
4016
|
const cdpUrl = await this.cdpUrl();
|
|
3943
|
-
this.playwrightBrowser =
|
|
3944
|
-
|
|
3945
|
-
|
|
4017
|
+
this.playwrightBrowser = await connectOverCdpWithRetry(
|
|
4018
|
+
() => this.options.cdp_url ? playwright.chromium.connectOverCDP(cdpUrl) : playwright.chromium.connectOverCDP(cdpUrl, {
|
|
4019
|
+
headers: { "x-notte-request-origin": REQUEST_ORIGIN, "x-notte-sdk-version": SDK_VERSION }
|
|
4020
|
+
})
|
|
4021
|
+
);
|
|
3946
4022
|
installServerOwnedDialogPolicy(this.playwrightBrowser);
|
|
3947
4023
|
}
|
|
3948
4024
|
const page = this.playwrightBrowser.contexts()[0]?.pages()[0];
|
|
@@ -3952,6 +4028,14 @@ var Session = class {
|
|
|
3952
4028
|
this.playwrightPage = page;
|
|
3953
4029
|
return page;
|
|
3954
4030
|
} catch (error) {
|
|
4031
|
+
let closed = null;
|
|
4032
|
+
try {
|
|
4033
|
+
closed = closedSessionError(await this.status(), error);
|
|
4034
|
+
} catch {
|
|
4035
|
+
}
|
|
4036
|
+
if (closed) {
|
|
4037
|
+
throw closed;
|
|
4038
|
+
}
|
|
3955
4039
|
throw new Error(`Failed to access the playwright page from CDP: ${error instanceof Error ? error.message : String(error)}`, {
|
|
3956
4040
|
cause: error
|
|
3957
4041
|
});
|
|
@@ -5925,9 +6009,11 @@ var NotteAnything = class {
|
|
|
5925
6009
|
* Rejects with a `NotteAPIError` when the API answers with a non-2xx status.
|
|
5926
6010
|
*/
|
|
5927
6011
|
async start(body) {
|
|
5928
|
-
const { data, response } = await
|
|
5929
|
-
|
|
6012
|
+
const { data, response } = await this.client.getClient().post({
|
|
6013
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
6014
|
+
url: "/anything/start",
|
|
5930
6015
|
body,
|
|
6016
|
+
headers: { "Content-Type": "application/json" },
|
|
5931
6017
|
parseAs: "stream",
|
|
5932
6018
|
throwOnError: true
|
|
5933
6019
|
});
|
|
@@ -6626,6 +6712,7 @@ export {
|
|
|
6626
6712
|
SESSION_START_TRIES,
|
|
6627
6713
|
ScrapeFailedError,
|
|
6628
6714
|
Session,
|
|
6715
|
+
SessionClosedError,
|
|
6629
6716
|
SessionFiles,
|
|
6630
6717
|
TIMEOUT_HEADER,
|
|
6631
6718
|
accountChanges,
|
|
@@ -6751,6 +6838,7 @@ export {
|
|
|
6751
6838
|
profileStateSet,
|
|
6752
6839
|
readCookiesFile,
|
|
6753
6840
|
readyCheck,
|
|
6841
|
+
recommendLaunchPreset,
|
|
6754
6842
|
responseFromEvaluated,
|
|
6755
6843
|
retrieve,
|
|
6756
6844
|
retrieveChange,
|