notte-sdk 1.10.13 → 1.10.15
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 +3264 -2897
- package/dist/index.d.ts +3264 -2897
- package/dist/index.js +256 -130
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +254 -130
- package/dist/index.mjs.map +1 -1
- package/dist/proxy/core.js +2 -0
- package/dist/proxy/core.js.map +1 -1
- package/dist/proxy/core.mjs +2 -0
- package/dist/proxy/core.mjs.map +1 -1
- package/dist/proxy/next.js +2 -0
- package/dist/proxy/next.js.map +1 -1
- package/dist/proxy/next.mjs +2 -0
- package/dist/proxy/next.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -70,6 +70,7 @@ __export(index_exports, {
|
|
|
70
70
|
SESSION_START_TRIES: () => SESSION_START_TRIES,
|
|
71
71
|
ScrapeFailedError: () => ScrapeFailedError,
|
|
72
72
|
Session: () => Session,
|
|
73
|
+
SessionClosedError: () => SessionClosedError,
|
|
73
74
|
SessionFiles: () => SessionFiles,
|
|
74
75
|
TIMEOUT_HEADER: () => TIMEOUT_HEADER,
|
|
75
76
|
accountChanges: () => accountChanges,
|
|
@@ -224,6 +225,7 @@ __export(index_exports, {
|
|
|
224
225
|
sessionResume: () => sessionResume,
|
|
225
226
|
sessionStart: () => sessionStart,
|
|
226
227
|
sessionStatus: () => sessionStatus,
|
|
228
|
+
sessionSteps: () => sessionSteps,
|
|
227
229
|
sessionStop: () => sessionStop,
|
|
228
230
|
startVersionCheck: () => startVersionCheck,
|
|
229
231
|
storeSecret: () => storeSecret,
|
|
@@ -249,7 +251,7 @@ __export(index_exports, {
|
|
|
249
251
|
module.exports = __toCommonJS(index_exports);
|
|
250
252
|
|
|
251
253
|
// src/version.ts
|
|
252
|
-
var SDK_VERSION = true ? "1.10.
|
|
254
|
+
var SDK_VERSION = true ? "1.10.15" : "dev";
|
|
253
255
|
var SDK_PACKAGE_NAME = true ? "notte-sdk" : "notte-sdk";
|
|
254
256
|
|
|
255
257
|
// src/version-check.ts
|
|
@@ -1187,16 +1189,6 @@ var createClient = (config = {}) => {
|
|
|
1187
1189
|
var client = createClient(createConfig({ baseUrl: "https://api.notte.cc" }));
|
|
1188
1190
|
|
|
1189
1191
|
// src/lib/client/sdk.gen.ts
|
|
1190
|
-
var sessionAuthReadiness = (options) => (options.client ?? client).get({
|
|
1191
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1192
|
-
url: "/sessions/{session_id}/auth",
|
|
1193
|
-
...options
|
|
1194
|
-
});
|
|
1195
|
-
var listSessions = (options) => (options?.client ?? client).get({
|
|
1196
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1197
|
-
url: "/sessions",
|
|
1198
|
-
...options
|
|
1199
|
-
});
|
|
1200
1192
|
var sessionStart = (options) => (options.client ?? client).post({
|
|
1201
1193
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1202
1194
|
url: "/sessions/start",
|
|
@@ -1206,9 +1198,9 @@ var sessionStart = (options) => (options.client ?? client).post({
|
|
|
1206
1198
|
...options.headers
|
|
1207
1199
|
}
|
|
1208
1200
|
});
|
|
1209
|
-
var
|
|
1201
|
+
var sessionSteps = (options) => (options.client ?? client).get({
|
|
1210
1202
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1211
|
-
url: "/sessions/{session_id}",
|
|
1203
|
+
url: "/sessions/{session_id}/steps",
|
|
1212
1204
|
...options
|
|
1213
1205
|
});
|
|
1214
1206
|
var sessionProfilePreview = (options) => (options.client ?? client).get({
|
|
@@ -1332,21 +1324,6 @@ var pageDocumentRead = (options) => (options.client ?? client).post({
|
|
|
1332
1324
|
...options.headers
|
|
1333
1325
|
}
|
|
1334
1326
|
});
|
|
1335
|
-
var sessionNetworkLogs = (options) => (options.client ?? client).get({
|
|
1336
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1337
|
-
url: "/sessions/{session_id}/network/logs",
|
|
1338
|
-
...options
|
|
1339
|
-
});
|
|
1340
|
-
var sessionMouseReplay = (options) => (options.client ?? client).get({
|
|
1341
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1342
|
-
url: "/sessions/{session_id}/replay/mouse",
|
|
1343
|
-
...options
|
|
1344
|
-
});
|
|
1345
|
-
var sessionReplay = (options) => (options.client ?? client).get({
|
|
1346
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1347
|
-
url: "/sessions/{session_id}/replay",
|
|
1348
|
-
...options
|
|
1349
|
-
});
|
|
1350
1327
|
var executeSessionFile = (options) => (options.client ?? client).post({
|
|
1351
1328
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1352
1329
|
url: "/sessions/{session_id}/page/execute/file",
|
|
@@ -1716,91 +1693,6 @@ var profileList = (options) => (options?.client ?? client).get({
|
|
|
1716
1693
|
url: "/profiles",
|
|
1717
1694
|
...options
|
|
1718
1695
|
});
|
|
1719
|
-
var personaCreate = (options) => (options.client ?? client).post({
|
|
1720
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1721
|
-
url: "/personas/create",
|
|
1722
|
-
...options,
|
|
1723
|
-
headers: {
|
|
1724
|
-
"Content-Type": "application/json",
|
|
1725
|
-
...options.headers
|
|
1726
|
-
}
|
|
1727
|
-
});
|
|
1728
|
-
var personaDelete = (options) => (options.client ?? client).delete({
|
|
1729
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1730
|
-
url: "/personas/{persona_id}",
|
|
1731
|
-
...options
|
|
1732
|
-
});
|
|
1733
|
-
var personaGet = (options) => (options.client ?? client).get({
|
|
1734
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1735
|
-
url: "/personas/{persona_id}",
|
|
1736
|
-
...options
|
|
1737
|
-
});
|
|
1738
|
-
var personaUpdate = (options) => (options.client ?? client).patch({
|
|
1739
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1740
|
-
url: "/personas/{persona_id}",
|
|
1741
|
-
...options,
|
|
1742
|
-
headers: {
|
|
1743
|
-
"Content-Type": "application/json",
|
|
1744
|
-
...options.headers
|
|
1745
|
-
}
|
|
1746
|
-
});
|
|
1747
|
-
var personaEmailsList = (options) => (options.client ?? client).get({
|
|
1748
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1749
|
-
url: "/personas/{persona_id}/emails",
|
|
1750
|
-
...options
|
|
1751
|
-
});
|
|
1752
|
-
var listPersonas = (options) => (options?.client ?? client).get({
|
|
1753
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1754
|
-
url: "/personas",
|
|
1755
|
-
...options
|
|
1756
|
-
});
|
|
1757
|
-
var personaSmsList = (options) => (options.client ?? client).get({
|
|
1758
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1759
|
-
url: "/personas/{persona_id}/sms",
|
|
1760
|
-
...options
|
|
1761
|
-
});
|
|
1762
|
-
var mailboxConnectToken = (options) => (options.client ?? client).post({
|
|
1763
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1764
|
-
url: "/mailboxes/connect-token",
|
|
1765
|
-
...options,
|
|
1766
|
-
headers: {
|
|
1767
|
-
"Content-Type": "application/json",
|
|
1768
|
-
...options.headers
|
|
1769
|
-
}
|
|
1770
|
-
});
|
|
1771
|
-
var mailboxSync = (options) => (options?.client ?? client).post({
|
|
1772
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1773
|
-
url: "/mailboxes/sync",
|
|
1774
|
-
...options,
|
|
1775
|
-
headers: {
|
|
1776
|
-
"Content-Type": "application/json",
|
|
1777
|
-
...options?.headers
|
|
1778
|
-
}
|
|
1779
|
-
});
|
|
1780
|
-
var mailboxList = (options) => (options?.client ?? client).get({
|
|
1781
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1782
|
-
url: "/mailboxes",
|
|
1783
|
-
...options
|
|
1784
|
-
});
|
|
1785
|
-
var mailboxDelete = (options) => (options.client ?? client).delete({
|
|
1786
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1787
|
-
url: "/mailboxes/{mailbox_id}",
|
|
1788
|
-
...options
|
|
1789
|
-
});
|
|
1790
|
-
var mailboxGet = (options) => (options.client ?? client).get({
|
|
1791
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1792
|
-
url: "/mailboxes/{mailbox_id}",
|
|
1793
|
-
...options
|
|
1794
|
-
});
|
|
1795
|
-
var mailboxUpdate = (options) => (options.client ?? client).patch({
|
|
1796
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1797
|
-
url: "/mailboxes/{mailbox_id}",
|
|
1798
|
-
...options,
|
|
1799
|
-
headers: {
|
|
1800
|
-
"Content-Type": "application/json",
|
|
1801
|
-
...options.headers
|
|
1802
|
-
}
|
|
1803
|
-
});
|
|
1804
1696
|
var managedAuthConnectLinkCreate = (options) => (options.client ?? client).post({
|
|
1805
1697
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1806
1698
|
url: "/managed-auth/connect-links",
|
|
@@ -1837,15 +1729,6 @@ var connectLinkSubmit = (options) => (options.client ?? client).post({
|
|
|
1837
1729
|
}
|
|
1838
1730
|
});
|
|
1839
1731
|
var connectLinkStatus = (options) => (options.client ?? client).get({ url: "/managed-auth/connect-links/status", ...options });
|
|
1840
|
-
var anythingStart = (options) => (options.client ?? client).post({
|
|
1841
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1842
|
-
url: "/anything/start",
|
|
1843
|
-
...options,
|
|
1844
|
-
headers: {
|
|
1845
|
-
"Content-Type": "application/json",
|
|
1846
|
-
...options.headers
|
|
1847
|
-
}
|
|
1848
|
-
});
|
|
1849
1732
|
var listSecrets = (options) => (options?.client ?? client).get({
|
|
1850
1733
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1851
1734
|
url: "/secrets",
|
|
@@ -1870,11 +1753,6 @@ var deleteSecret = (options) => (options.client ?? client).delete({
|
|
|
1870
1753
|
url: "/secrets/{secret_id}",
|
|
1871
1754
|
...options
|
|
1872
1755
|
});
|
|
1873
|
-
var listSecretProxyHostPresets = (options) => (options?.client ?? client).get({
|
|
1874
|
-
security: [{ scheme: "bearer", type: "http" }],
|
|
1875
|
-
url: "/secret-proxy/host-presets",
|
|
1876
|
-
...options
|
|
1877
|
-
});
|
|
1878
1756
|
var healthCheck = (options) => (options?.client ?? client).get({ url: "/health", ...options });
|
|
1879
1757
|
var readyCheck = (options) => (options?.client ?? client).get({ url: "/ready", ...options });
|
|
1880
1758
|
var scrapeWebpage = (options) => (options.client ?? client).post({
|
|
@@ -2113,11 +1991,140 @@ var scrapeFromHtml = (options) => (options.client ?? client).post({
|
|
|
2113
1991
|
...options.headers
|
|
2114
1992
|
}
|
|
2115
1993
|
});
|
|
1994
|
+
var anythingStart = (options) => (options.client ?? client).sse.post({
|
|
1995
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1996
|
+
url: "/anything/start",
|
|
1997
|
+
...options,
|
|
1998
|
+
headers: {
|
|
1999
|
+
"Content-Type": "application/json",
|
|
2000
|
+
...options.headers
|
|
2001
|
+
}
|
|
2002
|
+
});
|
|
2116
2003
|
var listAuditEvents = (options) => (options?.client ?? client).get({
|
|
2117
2004
|
security: [{ scheme: "bearer", type: "http" }],
|
|
2118
2005
|
url: "/audit-events",
|
|
2119
2006
|
...options
|
|
2120
2007
|
});
|
|
2008
|
+
var mailboxList = (options) => (options?.client ?? client).get({
|
|
2009
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2010
|
+
url: "/mailboxes",
|
|
2011
|
+
...options
|
|
2012
|
+
});
|
|
2013
|
+
var mailboxConnectToken = (options) => (options.client ?? client).post({
|
|
2014
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2015
|
+
url: "/mailboxes/connect-token",
|
|
2016
|
+
...options,
|
|
2017
|
+
headers: {
|
|
2018
|
+
"Content-Type": "application/json",
|
|
2019
|
+
...options.headers
|
|
2020
|
+
}
|
|
2021
|
+
});
|
|
2022
|
+
var mailboxSync = (options) => (options?.client ?? client).post({
|
|
2023
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2024
|
+
url: "/mailboxes/sync",
|
|
2025
|
+
...options,
|
|
2026
|
+
headers: {
|
|
2027
|
+
"Content-Type": "application/json",
|
|
2028
|
+
...options?.headers
|
|
2029
|
+
}
|
|
2030
|
+
});
|
|
2031
|
+
var mailboxDelete = (options) => (options.client ?? client).delete({
|
|
2032
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2033
|
+
url: "/mailboxes/{mailbox_id}",
|
|
2034
|
+
...options
|
|
2035
|
+
});
|
|
2036
|
+
var mailboxGet = (options) => (options.client ?? client).get({
|
|
2037
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2038
|
+
url: "/mailboxes/{mailbox_id}",
|
|
2039
|
+
...options
|
|
2040
|
+
});
|
|
2041
|
+
var mailboxUpdate = (options) => (options.client ?? client).patch({
|
|
2042
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2043
|
+
url: "/mailboxes/{mailbox_id}",
|
|
2044
|
+
...options,
|
|
2045
|
+
headers: {
|
|
2046
|
+
"Content-Type": "application/json",
|
|
2047
|
+
...options.headers
|
|
2048
|
+
}
|
|
2049
|
+
});
|
|
2050
|
+
var listPersonas = (options) => (options?.client ?? client).get({
|
|
2051
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2052
|
+
url: "/personas",
|
|
2053
|
+
...options
|
|
2054
|
+
});
|
|
2055
|
+
var personaCreate = (options) => (options.client ?? client).post({
|
|
2056
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2057
|
+
url: "/personas/create",
|
|
2058
|
+
...options,
|
|
2059
|
+
headers: {
|
|
2060
|
+
"Content-Type": "application/json",
|
|
2061
|
+
...options.headers
|
|
2062
|
+
}
|
|
2063
|
+
});
|
|
2064
|
+
var personaDelete = (options) => (options.client ?? client).delete({
|
|
2065
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2066
|
+
url: "/personas/{persona_id}",
|
|
2067
|
+
...options
|
|
2068
|
+
});
|
|
2069
|
+
var personaGet = (options) => (options.client ?? client).get({
|
|
2070
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2071
|
+
url: "/personas/{persona_id}",
|
|
2072
|
+
...options
|
|
2073
|
+
});
|
|
2074
|
+
var personaUpdate = (options) => (options.client ?? client).patch({
|
|
2075
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2076
|
+
url: "/personas/{persona_id}",
|
|
2077
|
+
...options,
|
|
2078
|
+
headers: {
|
|
2079
|
+
"Content-Type": "application/json",
|
|
2080
|
+
...options.headers
|
|
2081
|
+
}
|
|
2082
|
+
});
|
|
2083
|
+
var personaEmailsList = (options) => (options.client ?? client).get({
|
|
2084
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2085
|
+
url: "/personas/{persona_id}/emails",
|
|
2086
|
+
...options
|
|
2087
|
+
});
|
|
2088
|
+
var personaSmsList = (options) => (options.client ?? client).get({
|
|
2089
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2090
|
+
url: "/personas/{persona_id}/sms",
|
|
2091
|
+
...options
|
|
2092
|
+
});
|
|
2093
|
+
var listSecretProxyHostPresets = (options) => (options?.client ?? client).get({
|
|
2094
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2095
|
+
url: "/secret-proxy/host-presets",
|
|
2096
|
+
...options
|
|
2097
|
+
});
|
|
2098
|
+
var listSessions = (options) => (options?.client ?? client).get({
|
|
2099
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2100
|
+
url: "/sessions",
|
|
2101
|
+
...options
|
|
2102
|
+
});
|
|
2103
|
+
var sessionStatus = (options) => (options.client ?? client).get({
|
|
2104
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2105
|
+
url: "/sessions/{session_id}",
|
|
2106
|
+
...options
|
|
2107
|
+
});
|
|
2108
|
+
var sessionAuthReadiness = (options) => (options.client ?? client).get({
|
|
2109
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2110
|
+
url: "/sessions/{session_id}/auth",
|
|
2111
|
+
...options
|
|
2112
|
+
});
|
|
2113
|
+
var sessionNetworkLogs = (options) => (options.client ?? client).get({
|
|
2114
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2115
|
+
url: "/sessions/{session_id}/network/logs",
|
|
2116
|
+
...options
|
|
2117
|
+
});
|
|
2118
|
+
var sessionReplay = (options) => (options.client ?? client).get({
|
|
2119
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2120
|
+
url: "/sessions/{session_id}/replay",
|
|
2121
|
+
...options
|
|
2122
|
+
});
|
|
2123
|
+
var sessionMouseReplay = (options) => (options.client ?? client).get({
|
|
2124
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
2125
|
+
url: "/sessions/{session_id}/replay/mouse",
|
|
2126
|
+
...options
|
|
2127
|
+
});
|
|
2121
2128
|
var getUsage = (options) => (options?.client ?? client).get({
|
|
2122
2129
|
security: [{ scheme: "bearer", type: "http" }],
|
|
2123
2130
|
url: "/usage",
|
|
@@ -2289,6 +2296,31 @@ var CaptchaRejectedError = class extends ActionExecutionError {
|
|
|
2289
2296
|
super({ error_type: "CaptchaRejectedError", dev_message: message, user_message: message, agent_message: message });
|
|
2290
2297
|
}
|
|
2291
2298
|
};
|
|
2299
|
+
var SessionClosedError = class extends NotteError {
|
|
2300
|
+
sessionId;
|
|
2301
|
+
status;
|
|
2302
|
+
closeReason;
|
|
2303
|
+
constructor(sessionId, status, closeReason, timeouts = {}, options) {
|
|
2304
|
+
super(`Session ${sessionId} is closed: ${closeDescription(status, closeReason, timeouts)}. Start a new session.`, options);
|
|
2305
|
+
this.sessionId = sessionId;
|
|
2306
|
+
this.status = status;
|
|
2307
|
+
this.closeReason = closeReason;
|
|
2308
|
+
}
|
|
2309
|
+
};
|
|
2310
|
+
function closeDescription(status, closeReason, { idleTimeoutMinutes, maxDurationMinutes }) {
|
|
2311
|
+
switch (closeReason) {
|
|
2312
|
+
case "idle_timeout":
|
|
2313
|
+
return idleTimeoutMinutes === void 0 ? "it timed out without activity" : `it timed out after ${idleTimeoutMinutes} minutes without activity`;
|
|
2314
|
+
case "max_duration":
|
|
2315
|
+
return maxDurationMinutes === void 0 ? "it reached its maximum duration" : `it reached its maximum duration of ${maxDurationMinutes} minutes`;
|
|
2316
|
+
case "manual":
|
|
2317
|
+
return "it was stopped";
|
|
2318
|
+
case "error":
|
|
2319
|
+
return "it ended with an error";
|
|
2320
|
+
default:
|
|
2321
|
+
return `its status is ${status}`;
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2292
2324
|
var EvaluateJsNoDataError = class extends NotteError {
|
|
2293
2325
|
constructor() {
|
|
2294
2326
|
super("evaluate_js returned no data. Upgrade the Notte API to a build that returns the evaluated value.");
|
|
@@ -2697,6 +2729,7 @@ function createResources(client2, getApiKey) {
|
|
|
2697
2729
|
},
|
|
2698
2730
|
/** functionRunStart: /functions/{function_id}/runs/start. Returns the API response body. */
|
|
2699
2731
|
runStart: async (functionId, body, requestOptions = {}) => {
|
|
2732
|
+
if (typeof functionId !== "string" || !functionId.trim()) throw new TypeError("runStart requires a non-empty functionId.");
|
|
2700
2733
|
const response = await functionRunStart({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers, "x-notte-api-key": getApiKey() }, path: { "function_id": functionId }, body });
|
|
2701
2734
|
return response.data;
|
|
2702
2735
|
},
|
|
@@ -3546,10 +3579,41 @@ function abortableSleep(ms, signal) {
|
|
|
3546
3579
|
});
|
|
3547
3580
|
}
|
|
3548
3581
|
|
|
3582
|
+
// src/session-steps.ts
|
|
3583
|
+
async function getSessionSteps(client2, sessionId, options = {}) {
|
|
3584
|
+
const response = await client2.getClient().get({
|
|
3585
|
+
url: `/sessions/${encodeURIComponent(sessionId)}/steps`,
|
|
3586
|
+
query: { cursor: options.cursor, limit: options.limit },
|
|
3587
|
+
throwOnError: true
|
|
3588
|
+
});
|
|
3589
|
+
return { steps: response.data.steps ?? [], next_cursor: response.data.next_cursor ?? null };
|
|
3590
|
+
}
|
|
3591
|
+
async function* iterSessionSteps(client2, sessionId, options = {}) {
|
|
3592
|
+
let cursor;
|
|
3593
|
+
while (true) {
|
|
3594
|
+
const page = await getSessionSteps(client2, sessionId, { cursor, limit: options.limit });
|
|
3595
|
+
yield* page.steps;
|
|
3596
|
+
if (page.next_cursor === null) return;
|
|
3597
|
+
cursor = page.next_cursor;
|
|
3598
|
+
}
|
|
3599
|
+
}
|
|
3600
|
+
|
|
3549
3601
|
// src/session.ts
|
|
3550
3602
|
var SESSION_START_TRIES = 3;
|
|
3551
3603
|
var CLUSTER_OVERLOAD_RETRY_DELAY_MS = 3e4;
|
|
3552
3604
|
var CAPTCHA_SOLVE_TIMEOUT_MS = 1e5;
|
|
3605
|
+
function closedSessionError(response, cause) {
|
|
3606
|
+
if (response.status !== "closed" && response.status !== "error" && response.status !== "timed_out") {
|
|
3607
|
+
return null;
|
|
3608
|
+
}
|
|
3609
|
+
return new SessionClosedError(
|
|
3610
|
+
response.session_id,
|
|
3611
|
+
response.status,
|
|
3612
|
+
response.close_reason ?? null,
|
|
3613
|
+
{ idleTimeoutMinutes: response.idle_timeout_minutes, maxDurationMinutes: response.max_duration_minutes },
|
|
3614
|
+
{ cause }
|
|
3615
|
+
);
|
|
3616
|
+
}
|
|
3553
3617
|
var OBSERVE_MIGRATION_URL = "https://docs.notte.cc/features/sessions/observe-migration";
|
|
3554
3618
|
var OBSERVE_DEPRECATIONS = {
|
|
3555
3619
|
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}`,
|
|
@@ -4056,6 +4120,36 @@ var Session = class {
|
|
|
4056
4120
|
});
|
|
4057
4121
|
return response.data;
|
|
4058
4122
|
}
|
|
4123
|
+
/**
|
|
4124
|
+
* Get one page of the session's steps. Each step has the shape of an item of
|
|
4125
|
+
* `status().steps`. Pass the page's `next_cursor` back as `cursor`, as is, to
|
|
4126
|
+
* get the next page; it is `null` on the last page. Works after `stop()`.
|
|
4127
|
+
*
|
|
4128
|
+
* @throws NotteAPIError with status 400 when `cursor` is no longer valid: restart from the first page (no `cursor`).
|
|
4129
|
+
* @example
|
|
4130
|
+
* let page = await session.steps({ limit: 50 });
|
|
4131
|
+
* while (page.next_cursor !== null) {
|
|
4132
|
+
* page = await session.steps({ cursor: page.next_cursor, limit: 50 });
|
|
4133
|
+
* }
|
|
4134
|
+
*/
|
|
4135
|
+
async steps(options = {}) {
|
|
4136
|
+
return getSessionSteps(this.client, this.lastSessionId(), options);
|
|
4137
|
+
}
|
|
4138
|
+
/**
|
|
4139
|
+
* Iterate over all of the session's steps, following `next_cursor` page by page.
|
|
4140
|
+
* A cursor that is no longer valid stops the iteration with a `NotteAPIError`
|
|
4141
|
+
* with status 400, after the steps already yielded; it is not restarted here,
|
|
4142
|
+
* since that would yield those steps again. To read the steps again, start a
|
|
4143
|
+
* new iteration. Works after `stop()`.
|
|
4144
|
+
*
|
|
4145
|
+
* @example
|
|
4146
|
+
* for await (const step of session.iterSteps({ limit: 50 })) {
|
|
4147
|
+
* console.log(step);
|
|
4148
|
+
* }
|
|
4149
|
+
*/
|
|
4150
|
+
async *iterSteps(options = {}) {
|
|
4151
|
+
yield* iterSessionSteps(this.client, this.lastSessionId(), options);
|
|
4152
|
+
}
|
|
4059
4153
|
// #######################################################################
|
|
4060
4154
|
// ############################# Debug / CDP #############################
|
|
4061
4155
|
// #######################################################################
|
|
@@ -4147,6 +4241,14 @@ var Session = class {
|
|
|
4147
4241
|
this.playwrightPage = page;
|
|
4148
4242
|
return page;
|
|
4149
4243
|
} catch (error) {
|
|
4244
|
+
let closed = null;
|
|
4245
|
+
try {
|
|
4246
|
+
closed = closedSessionError(await this.status(), error);
|
|
4247
|
+
} catch {
|
|
4248
|
+
}
|
|
4249
|
+
if (closed) {
|
|
4250
|
+
throw closed;
|
|
4251
|
+
}
|
|
4150
4252
|
throw new Error(`Failed to access the playwright page from CDP: ${error instanceof Error ? error.message : String(error)}`, {
|
|
4151
4253
|
cause: error
|
|
4152
4254
|
});
|
|
@@ -6120,9 +6222,11 @@ var NotteAnything = class {
|
|
|
6120
6222
|
* Rejects with a `NotteAPIError` when the API answers with a non-2xx status.
|
|
6121
6223
|
*/
|
|
6122
6224
|
async start(body) {
|
|
6123
|
-
const { data, response } = await
|
|
6124
|
-
|
|
6225
|
+
const { data, response } = await this.client.getClient().post({
|
|
6226
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
6227
|
+
url: "/anything/start",
|
|
6125
6228
|
body,
|
|
6229
|
+
headers: { "Content-Type": "application/json" },
|
|
6126
6230
|
parseAs: "stream",
|
|
6127
6231
|
throwOnError: true
|
|
6128
6232
|
});
|
|
@@ -6523,7 +6627,27 @@ var NotteClient3 = class {
|
|
|
6523
6627
|
list: async (options = {}) => {
|
|
6524
6628
|
const response = await listSessions({ client: this.getClient(), query: options });
|
|
6525
6629
|
return response.data?.items ?? [];
|
|
6526
|
-
}
|
|
6630
|
+
},
|
|
6631
|
+
/**
|
|
6632
|
+
* One page of the session's steps (`{ steps, next_cursor }`), from
|
|
6633
|
+
* `GET /sessions/{session_id}/steps`. Each step has the shape of an item of
|
|
6634
|
+
* `status().steps`. Pass `next_cursor` back as `cursor`, as is, for the next
|
|
6635
|
+
* page; it is `null` on the last page. A `NotteAPIError` with status 400 means
|
|
6636
|
+
* the cursor is no longer valid: restart from the first page (no `cursor`).
|
|
6637
|
+
*/
|
|
6638
|
+
steps: (sessionId, options = {}) => getSessionSteps(this, sessionId, options),
|
|
6639
|
+
/**
|
|
6640
|
+
* Every step of the session, following `next_cursor` page by page. A cursor
|
|
6641
|
+
* that is no longer valid stops the iteration with the 400 `NotteAPIError`,
|
|
6642
|
+
* after the steps already yielded; start a new iteration to read them again.
|
|
6643
|
+
*
|
|
6644
|
+
* ```ts
|
|
6645
|
+
* for await (const step of client.sessions.iterSteps(sessionId, { limit: 50 })) {
|
|
6646
|
+
* console.log(step);
|
|
6647
|
+
* }
|
|
6648
|
+
* ```
|
|
6649
|
+
*/
|
|
6650
|
+
iterSteps: (sessionId, options = {}) => iterSessionSteps(this, sessionId, options)
|
|
6527
6651
|
};
|
|
6528
6652
|
}
|
|
6529
6653
|
/** Client-bound vault API operations. `list()` retains its array return value. */
|
|
@@ -6802,6 +6926,7 @@ var createClient2 = (config) => {
|
|
|
6802
6926
|
SESSION_START_TRIES,
|
|
6803
6927
|
ScrapeFailedError,
|
|
6804
6928
|
Session,
|
|
6929
|
+
SessionClosedError,
|
|
6805
6930
|
SessionFiles,
|
|
6806
6931
|
TIMEOUT_HEADER,
|
|
6807
6932
|
accountChanges,
|
|
@@ -6955,6 +7080,7 @@ var createClient2 = (config) => {
|
|
|
6955
7080
|
sessionResume,
|
|
6956
7081
|
sessionStart,
|
|
6957
7082
|
sessionStatus,
|
|
7083
|
+
sessionSteps,
|
|
6958
7084
|
sessionStop,
|
|
6959
7085
|
startVersionCheck,
|
|
6960
7086
|
storeSecret,
|