notte-sdk 1.10.14 → 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.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,
@@ -250,7 +251,7 @@ __export(index_exports, {
250
251
  module.exports = __toCommonJS(index_exports);
251
252
 
252
253
  // src/version.ts
253
- var SDK_VERSION = true ? "1.10.14" : "dev";
254
+ var SDK_VERSION = true ? "1.10.15" : "dev";
254
255
  var SDK_PACKAGE_NAME = true ? "notte-sdk" : "notte-sdk";
255
256
 
256
257
  // src/version-check.ts
@@ -1188,16 +1189,6 @@ var createClient = (config = {}) => {
1188
1189
  var client = createClient(createConfig({ baseUrl: "https://api.notte.cc" }));
1189
1190
 
1190
1191
  // src/lib/client/sdk.gen.ts
1191
- var sessionAuthReadiness = (options) => (options.client ?? client).get({
1192
- security: [{ scheme: "bearer", type: "http" }],
1193
- url: "/sessions/{session_id}/auth",
1194
- ...options
1195
- });
1196
- var listSessions = (options) => (options?.client ?? client).get({
1197
- security: [{ scheme: "bearer", type: "http" }],
1198
- url: "/sessions",
1199
- ...options
1200
- });
1201
1192
  var sessionStart = (options) => (options.client ?? client).post({
1202
1193
  security: [{ scheme: "bearer", type: "http" }],
1203
1194
  url: "/sessions/start",
@@ -1207,11 +1198,6 @@ var sessionStart = (options) => (options.client ?? client).post({
1207
1198
  ...options.headers
1208
1199
  }
1209
1200
  });
1210
- var sessionStatus = (options) => (options.client ?? client).get({
1211
- security: [{ scheme: "bearer", type: "http" }],
1212
- url: "/sessions/{session_id}",
1213
- ...options
1214
- });
1215
1201
  var sessionSteps = (options) => (options.client ?? client).get({
1216
1202
  security: [{ scheme: "bearer", type: "http" }],
1217
1203
  url: "/sessions/{session_id}/steps",
@@ -1338,21 +1324,6 @@ var pageDocumentRead = (options) => (options.client ?? client).post({
1338
1324
  ...options.headers
1339
1325
  }
1340
1326
  });
1341
- var sessionNetworkLogs = (options) => (options.client ?? client).get({
1342
- security: [{ scheme: "bearer", type: "http" }],
1343
- url: "/sessions/{session_id}/network/logs",
1344
- ...options
1345
- });
1346
- var sessionMouseReplay = (options) => (options.client ?? client).get({
1347
- security: [{ scheme: "bearer", type: "http" }],
1348
- url: "/sessions/{session_id}/replay/mouse",
1349
- ...options
1350
- });
1351
- var sessionReplay = (options) => (options.client ?? client).get({
1352
- security: [{ scheme: "bearer", type: "http" }],
1353
- url: "/sessions/{session_id}/replay",
1354
- ...options
1355
- });
1356
1327
  var executeSessionFile = (options) => (options.client ?? client).post({
1357
1328
  security: [{ scheme: "bearer", type: "http" }],
1358
1329
  url: "/sessions/{session_id}/page/execute/file",
@@ -1722,48 +1693,6 @@ var profileList = (options) => (options?.client ?? client).get({
1722
1693
  url: "/profiles",
1723
1694
  ...options
1724
1695
  });
1725
- var mailboxConnectToken = (options) => (options.client ?? client).post({
1726
- security: [{ scheme: "bearer", type: "http" }],
1727
- url: "/mailboxes/connect-token",
1728
- ...options,
1729
- headers: {
1730
- "Content-Type": "application/json",
1731
- ...options.headers
1732
- }
1733
- });
1734
- var mailboxSync = (options) => (options?.client ?? client).post({
1735
- security: [{ scheme: "bearer", type: "http" }],
1736
- url: "/mailboxes/sync",
1737
- ...options,
1738
- headers: {
1739
- "Content-Type": "application/json",
1740
- ...options?.headers
1741
- }
1742
- });
1743
- var mailboxList = (options) => (options?.client ?? client).get({
1744
- security: [{ scheme: "bearer", type: "http" }],
1745
- url: "/mailboxes",
1746
- ...options
1747
- });
1748
- var mailboxDelete = (options) => (options.client ?? client).delete({
1749
- security: [{ scheme: "bearer", type: "http" }],
1750
- url: "/mailboxes/{mailbox_id}",
1751
- ...options
1752
- });
1753
- var mailboxGet = (options) => (options.client ?? client).get({
1754
- security: [{ scheme: "bearer", type: "http" }],
1755
- url: "/mailboxes/{mailbox_id}",
1756
- ...options
1757
- });
1758
- var mailboxUpdate = (options) => (options.client ?? client).patch({
1759
- security: [{ scheme: "bearer", type: "http" }],
1760
- url: "/mailboxes/{mailbox_id}",
1761
- ...options,
1762
- headers: {
1763
- "Content-Type": "application/json",
1764
- ...options.headers
1765
- }
1766
- });
1767
1696
  var managedAuthConnectLinkCreate = (options) => (options.client ?? client).post({
1768
1697
  security: [{ scheme: "bearer", type: "http" }],
1769
1698
  url: "/managed-auth/connect-links",
@@ -1800,15 +1729,6 @@ var connectLinkSubmit = (options) => (options.client ?? client).post({
1800
1729
  }
1801
1730
  });
1802
1731
  var connectLinkStatus = (options) => (options.client ?? client).get({ url: "/managed-auth/connect-links/status", ...options });
1803
- var anythingStart = (options) => (options.client ?? client).post({
1804
- security: [{ scheme: "bearer", type: "http" }],
1805
- url: "/anything/start",
1806
- ...options,
1807
- headers: {
1808
- "Content-Type": "application/json",
1809
- ...options.headers
1810
- }
1811
- });
1812
1732
  var listSecrets = (options) => (options?.client ?? client).get({
1813
1733
  security: [{ scheme: "bearer", type: "http" }],
1814
1734
  url: "/secrets",
@@ -2071,11 +1991,62 @@ var scrapeFromHtml = (options) => (options.client ?? client).post({
2071
1991
  ...options.headers
2072
1992
  }
2073
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
+ });
2074
2003
  var listAuditEvents = (options) => (options?.client ?? client).get({
2075
2004
  security: [{ scheme: "bearer", type: "http" }],
2076
2005
  url: "/audit-events",
2077
2006
  ...options
2078
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
+ });
2079
2050
  var listPersonas = (options) => (options?.client ?? client).get({
2080
2051
  security: [{ scheme: "bearer", type: "http" }],
2081
2052
  url: "/personas",
@@ -2124,6 +2095,36 @@ var listSecretProxyHostPresets = (options) => (options?.client ?? client).get({
2124
2095
  url: "/secret-proxy/host-presets",
2125
2096
  ...options
2126
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
+ });
2127
2128
  var getUsage = (options) => (options?.client ?? client).get({
2128
2129
  security: [{ scheme: "bearer", type: "http" }],
2129
2130
  url: "/usage",
@@ -2295,6 +2296,31 @@ var CaptchaRejectedError = class extends ActionExecutionError {
2295
2296
  super({ error_type: "CaptchaRejectedError", dev_message: message, user_message: message, agent_message: message });
2296
2297
  }
2297
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
+ }
2298
2324
  var EvaluateJsNoDataError = class extends NotteError {
2299
2325
  constructor() {
2300
2326
  super("evaluate_js returned no data. Upgrade the Notte API to a build that returns the evaluated value.");
@@ -3576,6 +3602,18 @@ async function* iterSessionSteps(client2, sessionId, options = {}) {
3576
3602
  var SESSION_START_TRIES = 3;
3577
3603
  var CLUSTER_OVERLOAD_RETRY_DELAY_MS = 3e4;
3578
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
+ }
3579
3617
  var OBSERVE_MIGRATION_URL = "https://docs.notte.cc/features/sessions/observe-migration";
3580
3618
  var OBSERVE_DEPRECATIONS = {
3581
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}`,
@@ -4203,6 +4241,14 @@ var Session = class {
4203
4241
  this.playwrightPage = page;
4204
4242
  return page;
4205
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
+ }
4206
4252
  throw new Error(`Failed to access the playwright page from CDP: ${error instanceof Error ? error.message : String(error)}`, {
4207
4253
  cause: error
4208
4254
  });
@@ -6176,9 +6222,11 @@ var NotteAnything = class {
6176
6222
  * Rejects with a `NotteAPIError` when the API answers with a non-2xx status.
6177
6223
  */
6178
6224
  async start(body) {
6179
- const { data, response } = await anythingStart({
6180
- client: this.client.getClient(),
6225
+ const { data, response } = await this.client.getClient().post({
6226
+ security: [{ scheme: "bearer", type: "http" }],
6227
+ url: "/anything/start",
6181
6228
  body,
6229
+ headers: { "Content-Type": "application/json" },
6182
6230
  parseAs: "stream",
6183
6231
  throwOnError: true
6184
6232
  });
@@ -6878,6 +6926,7 @@ var createClient2 = (config) => {
6878
6926
  SESSION_START_TRIES,
6879
6927
  ScrapeFailedError,
6880
6928
  Session,
6929
+ SessionClosedError,
6881
6930
  SessionFiles,
6882
6931
  TIMEOUT_HEADER,
6883
6932
  accountChanges,