notte-sdk 1.9.7 → 1.10.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/dist/index.js CHANGED
@@ -31,11 +31,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
33
  ActionExecutionError: () => ActionExecutionError,
34
- Agent: () => Agent,
35
34
  AuthenticationError: () => AuthenticationError,
36
35
  CAPTCHA_SOLVE_TIMEOUT_MS: () => CAPTCHA_SOLVE_TIMEOUT_MS,
37
36
  CLUSTER_OVERLOAD_RETRY_DELAY_MS: () => CLUSTER_OVERLOAD_RETRY_DELAY_MS,
38
37
  CREDENTIAL_FIELDS: () => CREDENTIAL_FIELDS,
38
+ DEFAULT_MAX_RETRIES: () => DEFAULT_MAX_RETRIES,
39
39
  DEFAULT_NOTTE_API_URL: () => DEFAULT_NOTTE_API_URL,
40
40
  DEFAULT_REQUEST_TIMEOUT_MS: () => DEFAULT_REQUEST_TIMEOUT_MS,
41
41
  Encryption: () => Encryption,
@@ -70,12 +70,17 @@ __export(index_exports, {
70
70
  Session: () => Session,
71
71
  SessionFiles: () => SessionFiles,
72
72
  TIMEOUT_HEADER: () => TIMEOUT_HEADER,
73
+ accountChanges: () => accountChanges,
74
+ accountRuns: () => accountRuns,
73
75
  actions: () => actions,
74
76
  agentStart: () => agentStart,
75
77
  agentStatus: () => agentStatus,
76
78
  agentStop: () => agentStop,
77
79
  anythingStart: () => anythingStart,
80
+ attempts: () => attempts,
81
+ brandRetrieve: () => brandRetrieve,
78
82
  buildFetchScript: () => buildFetchScript,
83
+ changes: () => changes,
79
84
  checkForLatestVersion: () => checkForLatestVersion,
80
85
  client: () => client,
81
86
  connectLinkContext: () => connectLinkContext,
@@ -85,15 +90,23 @@ __export(index_exports, {
85
90
  connectLinkStatus: () => connectLinkStatus,
86
91
  connectLinkSubmit: () => connectLinkSubmit,
87
92
  connectPaymentWallet: () => connectPaymentWallet,
93
+ create: () => create,
88
94
  createClient: () => createClient2,
89
95
  createOrAppendCookiesToFile: () => createOrAppendCookiesToFile,
90
96
  createPayment: () => createPayment,
97
+ creditUsage: () => creditUsage,
91
98
  default: () => NotteClient3,
92
99
  deleteSecret: () => deleteSecret,
93
100
  deleteSessionFile: () => deleteSessionFile,
101
+ delete_: () => delete_,
102
+ deliveries: () => deliveries,
103
+ detail: () => detail,
94
104
  disconnectPaymentWallet: () => disconnectPaymentWallet,
95
105
  downloadRunPayload: () => downloadRunPayload,
96
106
  downloadSessionFile: () => downloadSessionFile,
107
+ executeSessionFile: () => executeSessionFile,
108
+ extractProductEndpoint: () => extractProductEndpoint,
109
+ fetchSpecializedData: () => fetchSpecializedData,
97
110
  functionCreate: () => functionCreate,
98
111
  functionDelete: () => functionDelete,
99
112
  functionDownloadUrl: () => functionDownloadUrl,
@@ -109,6 +122,7 @@ __export(index_exports, {
109
122
  functionScheduleSet: () => functionScheduleSet,
110
123
  functionUpdate: () => functionUpdate,
111
124
  getPayment: () => getPayment,
125
+ getPolicy: () => getPolicy,
112
126
  getRootDomain: () => getRootDomain,
113
127
  getScript: () => getScript,
114
128
  getSecret: () => getSecret,
@@ -116,13 +130,18 @@ __export(index_exports, {
116
130
  getUsage: () => getUsage,
117
131
  getUsageLogs: () => getUsageLogs,
118
132
  healthCheck: () => healthCheck,
133
+ history_: () => history_,
119
134
  installServerOwnedDialogPolicy: () => installServerOwnedDialogPolicy,
135
+ invalidate: () => invalidate,
120
136
  isCaptchaSolveAction: () => isCaptchaSolveAction,
121
137
  isValidMfaSecret: () => isValidMfaSecret,
138
+ limits: () => limits,
122
139
  listAgents: () => listAgents,
123
140
  listAuditEvents: () => listAuditEvents,
141
+ listDataApis: () => listDataApis,
124
142
  listFunctionRunsByFunctionId: () => listFunctionRunsByFunctionId,
125
143
  listFunctions: () => listFunctions,
144
+ listMonitors: () => listMonitors,
126
145
  listPersonas: () => listPersonas,
127
146
  listSecrets: () => listSecrets,
128
147
  listSessionFiles: () => listSessionFiles,
@@ -135,19 +154,20 @@ __export(index_exports, {
135
154
  mailboxSync: () => mailboxSync,
136
155
  mailboxUpdate: () => mailboxUpdate,
137
156
  managedAuthConnectLinkCreate: () => managedAuthConnectLinkCreate,
157
+ mapsSearch: () => mapsSearch,
158
+ newsSearch: () => newsSearch,
138
159
  observeServerOwnedDialog: () => observeServerOwnedDialog,
139
160
  pageExecute: () => pageExecute,
140
161
  pageObserve: () => pageObserve,
141
162
  pageScrape: () => pageScrape,
142
163
  pageScreenshot: () => pageScreenshot,
143
- parseAgentStatusMessage: () => parseAgentStatusMessage,
164
+ peopleEnrich: () => peopleEnrich,
144
165
  personaCreate: () => personaCreate,
145
166
  personaDelete: () => personaDelete,
146
167
  personaEmailsList: () => personaEmailsList,
147
168
  personaGet: () => personaGet,
148
169
  personaSmsList: () => personaSmsList,
149
170
  personaUpdate: () => personaUpdate,
150
- prepareAgentRequest: () => prepareAgentRequest,
151
171
  prepareRunPayloadUpload: () => prepareRunPayloadUpload,
152
172
  processScrapeResponse: () => processScrapeResponse,
153
173
  profileCookiesGet: () => profileCookiesGet,
@@ -157,18 +177,29 @@ __export(index_exports, {
157
177
  profileDuplicate: () => profileDuplicate,
158
178
  profileGet: () => profileGet,
159
179
  profileList: () => profileList,
180
+ profileStateSet: () => profileStateSet,
160
181
  readCookiesFile: () => readCookiesFile,
161
182
  readyCheck: () => readyCheck,
162
183
  responseFromEvaluated: () => responseFromEvaluated,
163
- retry: () => retry,
184
+ retrieve: () => retrieve,
185
+ retrieveChange: () => retrieveChange,
186
+ retrieveDelivery: () => retrieveDelivery,
187
+ retrieveRun: () => retrieveRun,
188
+ retry: () => retry2,
189
+ retryWebhookDelivery: () => retry,
190
+ rotateSecret: () => rotateSecret,
191
+ runNow: () => runNow,
192
+ runs: () => runs,
164
193
  sanitizeFilename: () => sanitizeFilename,
165
194
  scrapeFromHtml: () => scrapeFromHtml,
195
+ scrapeSpecializedData: () => fetchSpecializedData,
166
196
  scrapeWebpage: () => scrapeWebpage,
167
197
  searchWeb: () => searchWeb,
168
198
  sessionAuthReadiness: () => sessionAuthReadiness,
169
199
  sessionCookiesGet: () => sessionCookiesGet,
170
200
  sessionCookiesSet: () => sessionCookiesSet,
171
201
  sessionDebugInfo: () => sessionDebugInfo,
202
+ sessionMouseReplay: () => sessionMouseReplay,
172
203
  sessionNetworkLogs: () => sessionNetworkLogs,
173
204
  sessionOffset: () => sessionOffset,
174
205
  sessionProfilePreview: () => sessionProfilePreview,
@@ -179,6 +210,9 @@ __export(index_exports, {
179
210
  sessionStop: () => sessionStop,
180
211
  startVersionCheck: () => startVersionCheck,
181
212
  storeSecret: () => storeSecret,
213
+ styleguideEndpoint: () => styleguideEndpoint,
214
+ summary: () => summary,
215
+ update: () => update,
182
216
  uploadSessionFile: () => uploadSessionFile,
183
217
  validateCredentials: () => validateCredentials,
184
218
  validateMfaSecret: () => validateMfaSecret,
@@ -192,12 +226,13 @@ __export(index_exports, {
192
226
  vaultCreditCardGet: () => vaultCreditCardGet,
193
227
  vaultCreditCardSet: () => vaultCreditCardSet,
194
228
  vaultDelete: () => vaultDelete,
195
- vaultUpdate: () => vaultUpdate
229
+ vaultUpdate: () => vaultUpdate,
230
+ youtubeEndpoint: () => youtubeEndpoint
196
231
  });
197
232
  module.exports = __toCommonJS(index_exports);
198
233
 
199
234
  // src/version.ts
200
- var SDK_VERSION = true ? "1.9.7" : "dev";
235
+ var SDK_VERSION = true ? "1.10.0" : "dev";
201
236
  var SDK_PACKAGE_NAME = true ? "notte-sdk" : "notte-sdk";
202
237
 
203
238
  // src/version-check.ts
@@ -1081,6 +1116,11 @@ var createClient = (config = {}) => {
1081
1116
  const { opts, url } = await beforeRequest(options);
1082
1117
  return createSseClient({
1083
1118
  ...opts,
1119
+ // Request interceptors can replace fetch when the stream starts.
1120
+ fetch: (input, init) => {
1121
+ const transport = opts.fetch;
1122
+ return transport(input, init);
1123
+ },
1084
1124
  body: opts.body,
1085
1125
  method,
1086
1126
  onRequest: async (url2, init) => {
@@ -1168,11 +1208,6 @@ var sessionProfileSave = (options) => (options.client ?? client).post({
1168
1208
  ...options.headers
1169
1209
  }
1170
1210
  });
1171
- var getSessionScript = (options) => (options.client ?? client).get({
1172
- security: [{ scheme: "bearer", type: "http" }],
1173
- url: "/sessions/{session_id}/workflow/code",
1174
- ...options
1175
- });
1176
1211
  var sessionStop = (options) => (options.client ?? client).delete({
1177
1212
  security: [{ scheme: "bearer", type: "http" }],
1178
1213
  url: "/sessions/{session_id}/stop",
@@ -1239,11 +1274,25 @@ var sessionNetworkLogs = (options) => (options.client ?? client).get({
1239
1274
  url: "/sessions/{session_id}/network/logs",
1240
1275
  ...options
1241
1276
  });
1277
+ var sessionMouseReplay = (options) => (options.client ?? client).get({
1278
+ security: [{ scheme: "bearer", type: "http" }],
1279
+ url: "/sessions/{session_id}/replay/mouse",
1280
+ ...options
1281
+ });
1242
1282
  var sessionReplay = (options) => (options.client ?? client).get({
1243
1283
  security: [{ scheme: "bearer", type: "http" }],
1244
1284
  url: "/sessions/{session_id}/replay",
1245
1285
  ...options
1246
1286
  });
1287
+ var executeSessionFile = (options) => (options.client ?? client).post({
1288
+ security: [{ scheme: "bearer", type: "http" }],
1289
+ url: "/sessions/{session_id}/page/execute/file",
1290
+ ...options,
1291
+ headers: {
1292
+ "Content-Type": "application/json",
1293
+ ...options.headers
1294
+ }
1295
+ });
1247
1296
  var listSessionFiles = (options) => (options.client ?? client).get({
1248
1297
  security: [{ scheme: "bearer", type: "http" }],
1249
1298
  url: "/sessions/{session_id}/files",
@@ -1269,35 +1318,6 @@ var downloadSessionFile = (options) => (options.client ?? client).get({
1269
1318
  url: "/sessions/{session_id}/files/{file_id}",
1270
1319
  ...options
1271
1320
  });
1272
- var agentStart = (options) => (options.client ?? client).post({
1273
- security: [{ scheme: "bearer", type: "http" }],
1274
- url: "/agents/start",
1275
- ...options,
1276
- headers: {
1277
- "Content-Type": "application/json",
1278
- ...options.headers
1279
- }
1280
- });
1281
- var agentStatus = (options) => (options.client ?? client).get({
1282
- security: [{ scheme: "bearer", type: "http" }],
1283
- url: "/agents/{agent_id}",
1284
- ...options
1285
- });
1286
- var getScript = (options) => (options.client ?? client).get({
1287
- security: [{ scheme: "bearer", type: "http" }],
1288
- url: "/agents/{agent_id}/workflow/code",
1289
- ...options
1290
- });
1291
- var agentStop = (options) => (options.client ?? client).delete({
1292
- security: [{ scheme: "bearer", type: "http" }],
1293
- url: "/agents/{agent_id}/stop",
1294
- ...options
1295
- });
1296
- var listAgents = (options) => (options?.client ?? client).get({
1297
- security: [{ scheme: "bearer", type: "http" }],
1298
- url: "/agents",
1299
- ...options
1300
- });
1301
1321
  var functionRuntimeHealth = (options) => (options?.client ?? client).get({
1302
1322
  security: [{ scheme: "bearer", type: "http" }],
1303
1323
  url: "/functions/health",
@@ -1567,6 +1587,15 @@ var profileCookiesSet = (options) => (options.client ?? client).post({
1567
1587
  ...options.headers
1568
1588
  }
1569
1589
  });
1590
+ var profileStateSet = (options) => (options.client ?? client).post({
1591
+ security: [{ scheme: "bearer", type: "http" }],
1592
+ url: "/profiles/{profile_id}/state",
1593
+ ...options,
1594
+ headers: {
1595
+ "Content-Type": "application/json",
1596
+ ...options.headers
1597
+ }
1598
+ });
1570
1599
  var profileList = (options) => (options?.client ?? client).get({
1571
1600
  security: [{ scheme: "bearer", type: "http" }],
1572
1601
  url: "/profiles",
@@ -1761,6 +1790,215 @@ var searchWeb = (options) => (options.client ?? client).post({
1761
1790
  ...options.headers
1762
1791
  }
1763
1792
  });
1793
+ var summary = (options) => (options?.client ?? client).get({
1794
+ security: [{ scheme: "bearer", type: "http" }],
1795
+ url: "/data/analytics",
1796
+ ...options
1797
+ });
1798
+ var history_ = (options) => (options?.client ?? client).get({
1799
+ security: [{ scheme: "bearer", type: "http" }],
1800
+ url: "/data/analytics/requests",
1801
+ ...options
1802
+ });
1803
+ var detail = (options) => (options.client ?? client).get({
1804
+ security: [{ scheme: "bearer", type: "http" }],
1805
+ url: "/data/analytics/requests/{request_id}",
1806
+ ...options
1807
+ });
1808
+ var invalidate = (options) => (options?.client ?? client).delete({
1809
+ security: [{ scheme: "bearer", type: "http" }],
1810
+ url: "/data/cache",
1811
+ ...options
1812
+ });
1813
+ var getPolicy = (options) => (options?.client ?? client).get({
1814
+ security: [{ scheme: "bearer", type: "http" }],
1815
+ url: "/data/cache",
1816
+ ...options
1817
+ });
1818
+ var brandRetrieve = (options) => (options.client ?? client).post({
1819
+ security: [{ scheme: "bearer", type: "http" }],
1820
+ url: "/data/brand/retrieve",
1821
+ ...options,
1822
+ headers: {
1823
+ "Content-Type": "application/json",
1824
+ ...options.headers
1825
+ }
1826
+ });
1827
+ var extractProductEndpoint = (options) => (options.client ?? client).post({
1828
+ security: [{ scheme: "bearer", type: "http" }],
1829
+ url: "/data/products/extract",
1830
+ ...options,
1831
+ headers: {
1832
+ "Content-Type": "application/json",
1833
+ ...options.headers
1834
+ }
1835
+ });
1836
+ var styleguideEndpoint = (options) => (options?.client ?? client).get({
1837
+ security: [{ scheme: "bearer", type: "http" }],
1838
+ url: "/data/web/styleguide",
1839
+ ...options
1840
+ });
1841
+ var mapsSearch = (options) => (options.client ?? client).post({
1842
+ security: [{ scheme: "bearer", type: "http" }],
1843
+ url: "/data/maps/search",
1844
+ ...options,
1845
+ headers: {
1846
+ "Content-Type": "application/json",
1847
+ ...options.headers
1848
+ }
1849
+ });
1850
+ var listMonitors = (options) => (options?.client ?? client).get({
1851
+ security: [{ scheme: "bearer", type: "http" }],
1852
+ url: "/data/monitors",
1853
+ ...options
1854
+ });
1855
+ var create = (options) => (options.client ?? client).post({
1856
+ security: [{ scheme: "bearer", type: "http" }],
1857
+ url: "/data/monitors",
1858
+ ...options,
1859
+ headers: {
1860
+ "Content-Type": "application/json",
1861
+ ...options.headers
1862
+ }
1863
+ });
1864
+ var limits = (options) => (options?.client ?? client).get({
1865
+ security: [{ scheme: "bearer", type: "http" }],
1866
+ url: "/data/monitors/limits",
1867
+ ...options
1868
+ });
1869
+ var creditUsage = (options) => (options?.client ?? client).get({
1870
+ security: [{ scheme: "bearer", type: "http" }],
1871
+ url: "/data/monitors/credit-usage",
1872
+ ...options
1873
+ });
1874
+ var accountRuns = (options) => (options?.client ?? client).get({
1875
+ security: [{ scheme: "bearer", type: "http" }],
1876
+ url: "/data/monitors/runs",
1877
+ ...options
1878
+ });
1879
+ var accountChanges = (options) => (options?.client ?? client).get({
1880
+ security: [{ scheme: "bearer", type: "http" }],
1881
+ url: "/data/monitors/changes",
1882
+ ...options
1883
+ });
1884
+ var delete_ = (options) => (options.client ?? client).delete({
1885
+ security: [{ scheme: "bearer", type: "http" }],
1886
+ url: "/data/monitors/{monitor_id}",
1887
+ ...options
1888
+ });
1889
+ var retrieve = (options) => (options.client ?? client).get({
1890
+ security: [{ scheme: "bearer", type: "http" }],
1891
+ url: "/data/monitors/{monitor_id}",
1892
+ ...options
1893
+ });
1894
+ var update = (options) => (options.client ?? client).patch({
1895
+ security: [{ scheme: "bearer", type: "http" }],
1896
+ url: "/data/monitors/{monitor_id}",
1897
+ ...options,
1898
+ headers: {
1899
+ "Content-Type": "application/json",
1900
+ ...options.headers
1901
+ }
1902
+ });
1903
+ var runNow = (options) => (options.client ?? client).post({
1904
+ security: [{ scheme: "bearer", type: "http" }],
1905
+ url: "/data/monitors/{monitor_id}/run",
1906
+ ...options
1907
+ });
1908
+ var runs = (options) => (options.client ?? client).get({
1909
+ security: [{ scheme: "bearer", type: "http" }],
1910
+ url: "/data/monitors/{monitor_id}/runs",
1911
+ ...options
1912
+ });
1913
+ var changes = (options) => (options.client ?? client).get({
1914
+ security: [{ scheme: "bearer", type: "http" }],
1915
+ url: "/data/monitors/{monitor_id}/changes",
1916
+ ...options
1917
+ });
1918
+ var retrieveRun = (options) => (options.client ?? client).get({
1919
+ security: [{ scheme: "bearer", type: "http" }],
1920
+ url: "/data/monitors/{monitor_id}/runs/{run_id}",
1921
+ ...options
1922
+ });
1923
+ var retrieveChange = (options) => (options.client ?? client).get({
1924
+ security: [{ scheme: "bearer", type: "http" }],
1925
+ url: "/data/monitors/{monitor_id}/changes/{change_id}",
1926
+ ...options
1927
+ });
1928
+ var rotateSecret = (options) => (options.client ?? client).post({
1929
+ security: [{ scheme: "bearer", type: "http" }],
1930
+ url: "/data/monitors/{monitor_id}/webhook/rotate-secret",
1931
+ ...options
1932
+ });
1933
+ var deliveries = (options) => (options.client ?? client).post({
1934
+ security: [{ scheme: "bearer", type: "http" }],
1935
+ url: "/data/webhooks/deliveries",
1936
+ ...options,
1937
+ headers: {
1938
+ "Content-Type": "application/json",
1939
+ ...options.headers
1940
+ }
1941
+ });
1942
+ var retrieveDelivery = (options) => (options.client ?? client).get({
1943
+ security: [{ scheme: "bearer", type: "http" }],
1944
+ url: "/data/webhooks/deliveries/{delivery_id}",
1945
+ ...options
1946
+ });
1947
+ var attempts = (options) => (options.client ?? client).get({
1948
+ security: [{ scheme: "bearer", type: "http" }],
1949
+ url: "/data/webhooks/deliveries/{delivery_id}/attempts",
1950
+ ...options
1951
+ });
1952
+ var retry = (options) => (options.client ?? client).post({
1953
+ security: [{ scheme: "bearer", type: "http" }],
1954
+ url: "/data/webhooks/deliveries/{delivery_id}/retry",
1955
+ ...options,
1956
+ headers: {
1957
+ "Content-Type": "application/json",
1958
+ ...options.headers
1959
+ }
1960
+ });
1961
+ var peopleEnrich = (options) => (options.client ?? client).post({
1962
+ security: [{ scheme: "bearer", type: "http" }],
1963
+ url: "/data/people/enrich",
1964
+ ...options,
1965
+ headers: {
1966
+ "Content-Type": "application/json",
1967
+ ...options.headers
1968
+ }
1969
+ });
1970
+ var newsSearch = (options) => (options.client ?? client).post({
1971
+ security: [{ scheme: "bearer", type: "http" }],
1972
+ url: "/data/news/search",
1973
+ ...options,
1974
+ headers: {
1975
+ "Content-Type": "application/json",
1976
+ ...options.headers
1977
+ }
1978
+ });
1979
+ var fetchSpecializedData = (options) => (options.client ?? client).post({
1980
+ security: [{ scheme: "bearer", type: "http" }],
1981
+ url: "/data/web/fetch",
1982
+ ...options,
1983
+ headers: {
1984
+ "Content-Type": "application/json",
1985
+ ...options.headers
1986
+ }
1987
+ });
1988
+ var youtubeEndpoint = (options) => (options.client ?? client).post({
1989
+ security: [{ scheme: "bearer", type: "http" }],
1990
+ url: "/data/youtube/extract",
1991
+ ...options,
1992
+ headers: {
1993
+ "Content-Type": "application/json",
1994
+ ...options.headers
1995
+ }
1996
+ });
1997
+ var listDataApis = (options) => (options?.client ?? client).get({
1998
+ security: [{ scheme: "bearer", type: "http" }],
1999
+ url: "/data",
2000
+ ...options
2001
+ });
1764
2002
  var scrapeFromHtml = (options) => (options.client ?? client).post({
1765
2003
  security: [{ scheme: "bearer", type: "http" }],
1766
2004
  url: "/scrape_from_html",
@@ -1770,6 +2008,40 @@ var scrapeFromHtml = (options) => (options.client ?? client).post({
1770
2008
  ...options.headers
1771
2009
  }
1772
2010
  });
2011
+ var agentStart = (options) => (options.client ?? client).post({
2012
+ security: [{ scheme: "bearer", type: "http" }],
2013
+ url: "/agents/start",
2014
+ ...options,
2015
+ headers: {
2016
+ "Content-Type": "application/json",
2017
+ ...options.headers
2018
+ }
2019
+ });
2020
+ var agentStop = (options) => (options.client ?? client).delete({
2021
+ security: [{ scheme: "bearer", type: "http" }],
2022
+ url: "/agents/{agent_id}/stop",
2023
+ ...options
2024
+ });
2025
+ var agentStatus = (options) => (options.client ?? client).get({
2026
+ security: [{ scheme: "bearer", type: "http" }],
2027
+ url: "/agents/{agent_id}",
2028
+ ...options
2029
+ });
2030
+ var getScript = (options) => (options.client ?? client).get({
2031
+ security: [{ scheme: "bearer", type: "http" }],
2032
+ url: "/agents/{agent_id}/workflow/code",
2033
+ ...options
2034
+ });
2035
+ var listAgents = (options) => (options?.client ?? client).get({
2036
+ security: [{ scheme: "bearer", type: "http" }],
2037
+ url: "/agents",
2038
+ ...options
2039
+ });
2040
+ var getSessionScript = (options) => (options.client ?? client).get({
2041
+ security: [{ scheme: "bearer", type: "http" }],
2042
+ url: "/sessions/{session_id}/workflow/code",
2043
+ ...options
2044
+ });
1773
2045
 
1774
2046
  // src/managed-auth.ts
1775
2047
  var import_promises = require("timers/promises");
@@ -1854,14 +2126,14 @@ var ActionExecutionError = class _ActionExecutionError extends NotteError {
1854
2126
  agentMessage;
1855
2127
  shouldRetryLater;
1856
2128
  shouldNotifyTeam;
1857
- constructor(detail) {
1858
- super(detail.dev_message || detail.user_message || detail.error_type);
1859
- this.errorType = detail.error_type;
1860
- this.devMessage = detail.dev_message;
1861
- this.userMessage = detail.user_message;
1862
- this.agentMessage = detail.agent_message;
1863
- this.shouldRetryLater = detail.should_retry_later ?? false;
1864
- this.shouldNotifyTeam = detail.should_notify_team ?? false;
2129
+ constructor(detail2) {
2130
+ super(detail2.dev_message || detail2.user_message || detail2.error_type);
2131
+ this.errorType = detail2.error_type;
2132
+ this.devMessage = detail2.dev_message;
2133
+ this.userMessage = detail2.user_message;
2134
+ this.agentMessage = detail2.agent_message;
2135
+ this.shouldRetryLater = detail2.should_retry_later ?? false;
2136
+ this.shouldNotifyTeam = detail2.should_notify_team ?? false;
1865
2137
  }
1866
2138
  static fromMessage(message, errorType = "NotteBaseError") {
1867
2139
  return new _ActionExecutionError({
@@ -1892,7 +2164,7 @@ function normalizeErrorBody(body) {
1892
2164
  return { message: typeof body === "string" ? body : String(body) };
1893
2165
  }
1894
2166
  var DEFAULT_RETRY_MESSAGE = "An error occurred while executing the function. Try again later...";
1895
- function retry(fn, options) {
2167
+ function retry2(fn, options) {
1896
2168
  const {
1897
2169
  maxTries,
1898
2170
  delayMs = 5e3,
@@ -1929,11 +2201,6 @@ function sleep(ms) {
1929
2201
  // src/managed-auth.ts
1930
2202
  var ManagedAuthError = class extends NotteError {
1931
2203
  };
1932
- function validateAuthRetry(value) {
1933
- if (!Number.isInteger(value) || value < 0 || value > 2) {
1934
- throw new InvalidRequestError("auth_retry must be an integer between 0 and 2");
1935
- }
1936
- }
1937
2204
  async function pollAuth(read, options) {
1938
2205
  const timeoutMs = options.timeoutMs ?? 615e3;
1939
2206
  const interval = options.pollIntervalMs ?? 1e3;
@@ -2014,12 +2281,10 @@ var NotteManagedAuth = class {
2014
2281
  return this.run(connectionId, "reauthenticate", options);
2015
2282
  }
2016
2283
  async run(connectionId, action, options) {
2017
- const authRetry = options.auth_retry ?? 0;
2018
- validateAuthRetry(authRetry);
2019
2284
  options.signal?.throwIfAborted();
2020
2285
  const response = await this.client.getClient().post({
2021
2286
  url: `/managed-auth/connections/${encodeURIComponent(connectionId)}/${action}`,
2022
- body: { auth_retry: authRetry },
2287
+ body: { auth_retry: options.auth_retry },
2023
2288
  headers: { "Content-Type": "application/json" },
2024
2289
  signal: options.signal,
2025
2290
  throwOnError: true
@@ -2054,7 +2319,7 @@ function createResources(client2, getApiKey) {
2054
2319
  },
2055
2320
  /** downloadSessionFile: /sessions/{session_id}/files/{file_id}. Returns the API response body. */
2056
2321
  downloadSessionFile: async (sessionId, fileId, requestOptions = {}) => {
2057
- const response = await downloadSessionFile({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId, "file_id": fileId } });
2322
+ const response = await downloadSessionFile({ client: client2, throwOnError: true, signal: requestOptions.signal, parseAs: "blob", headers: { ...requestOptions.headers }, path: { "session_id": sessionId, "file_id": fileId } });
2058
2323
  return response.data;
2059
2324
  },
2060
2325
  /** pageExecute: /sessions/{session_id}/page/execute. Returns the API response body. */
@@ -2062,6 +2327,11 @@ function createResources(client2, getApiKey) {
2062
2327
  const response = await pageExecute({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, body, query });
2063
2328
  return response.data;
2064
2329
  },
2330
+ /** executeSessionFile: /sessions/{session_id}/page/execute/file. Returns the API response body. */
2331
+ executeSessionFile: async (sessionId, body, query = void 0, requestOptions = {}) => {
2332
+ const response = await executeSessionFile({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, body, query });
2333
+ return response.data;
2334
+ },
2065
2335
  /** sessionCookiesGet: /sessions/{session_id}/cookies. Returns the API response body. */
2066
2336
  getCookies: async (sessionId, query = void 0, requestOptions = {}) => {
2067
2337
  const response = await sessionCookiesGet({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, query });
@@ -2082,6 +2352,11 @@ function createResources(client2, getApiKey) {
2082
2352
  const response = await listSessionFiles({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, query });
2083
2353
  return response.data;
2084
2354
  },
2355
+ /** sessionMouseReplay: /sessions/{session_id}/replay/mouse. Returns the API response body. */
2356
+ mouseReplay: async (sessionId, query = void 0, requestOptions = {}) => {
2357
+ const response = await sessionMouseReplay({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, query });
2358
+ return response.data;
2359
+ },
2085
2360
  /** sessionNetworkLogs: /sessions/{session_id}/network/logs. Returns the API response body. */
2086
2361
  networkLogs: async (sessionId, query = void 0, requestOptions = {}) => {
2087
2362
  const response = await sessionNetworkLogs({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, query });
@@ -2107,16 +2382,16 @@ function createResources(client2, getApiKey) {
2107
2382
  const response = await sessionProfilePreview({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, query });
2108
2383
  return response.data;
2109
2384
  },
2110
- /** sessionProfileSave: /sessions/{session_id}/profile/save. Returns the API response body. */
2111
- profileSave: async (sessionId, body, requestOptions = {}) => {
2112
- const response = await sessionProfileSave({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, body });
2113
- return response.data;
2114
- },
2115
2385
  /** sessionReplay: /sessions/{session_id}/replay. Returns the API response body. */
2116
2386
  replay: async (sessionId, requestOptions = {}) => {
2117
2387
  const response = await sessionReplay({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId } });
2118
2388
  return response.data;
2119
2389
  },
2390
+ /** sessionProfileSave: /sessions/{session_id}/profile/save. Returns the API response body. */
2391
+ saveProfile: async (sessionId, body, requestOptions = {}) => {
2392
+ const response = await sessionProfileSave({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, body });
2393
+ return response.data;
2394
+ },
2120
2395
  /** pageScrape: /sessions/{session_id}/page/scrape. Returns the API response body. */
2121
2396
  scrape: async (sessionId, body, query = void 0, requestOptions = {}) => {
2122
2397
  const response = await pageScrape({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, body, query });
@@ -2148,30 +2423,30 @@ function createResources(client2, getApiKey) {
2148
2423
  return response.data;
2149
2424
  }
2150
2425
  },
2151
- agents: {
2152
- /** getScript: /agents/{agent_id}/workflow/code. Returns the API response body. */
2153
- getScript: async (agentId, query, requestOptions = {}) => {
2154
- const response = await getScript({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "agent_id": agentId }, query });
2426
+ files: {
2427
+ /** deleteSessionFile: /sessions/{session_id}/files/{file_id}. Returns the API response body. */
2428
+ delete: async (sessionId, fileId, requestOptions = {}) => {
2429
+ const response = await deleteSessionFile({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId, "file_id": fileId } });
2155
2430
  return response.data;
2156
2431
  },
2157
- /** listAgents: /agents. Returns the API response body. */
2158
- list: async (query = void 0, requestOptions = {}) => {
2159
- const response = await listAgents({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, query });
2432
+ /** downloadSessionFile: /sessions/{session_id}/files/{file_id}. Returns the API response body. */
2433
+ download: async (sessionId, fileId, requestOptions = {}) => {
2434
+ const response = await downloadSessionFile({ client: client2, throwOnError: true, signal: requestOptions.signal, parseAs: "blob", headers: { ...requestOptions.headers }, path: { "session_id": sessionId, "file_id": fileId } });
2160
2435
  return response.data;
2161
2436
  },
2162
- /** agentStart: /agents/start. Returns the API response body. */
2163
- start: async (body, requestOptions = {}) => {
2164
- const response = await agentStart({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, body });
2437
+ /** executeSessionFile: /sessions/{session_id}/page/execute/file. Returns the API response body. */
2438
+ execute: async (sessionId, body, query = void 0, requestOptions = {}) => {
2439
+ const response = await executeSessionFile({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, body, query });
2165
2440
  return response.data;
2166
2441
  },
2167
- /** agentStatus: /agents/{agent_id}. Returns the API response body. */
2168
- status: async (agentId, requestOptions = {}) => {
2169
- const response = await agentStatus({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "agent_id": agentId } });
2442
+ /** listSessionFiles: /sessions/{session_id}/files. Returns the API response body. */
2443
+ list: async (sessionId, query = void 0, requestOptions = {}) => {
2444
+ const response = await listSessionFiles({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, query });
2170
2445
  return response.data;
2171
2446
  },
2172
- /** agentStop: /agents/{agent_id}/stop. Returns the API response body. */
2173
- stop: async (agentId, query, requestOptions = {}) => {
2174
- const response = await agentStop({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "agent_id": agentId }, query });
2447
+ /** uploadSessionFile: /sessions/{session_id}/files. Returns the API response body. */
2448
+ upload: async (sessionId, body, requestOptions = {}) => {
2449
+ const response = await uploadSessionFile({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "session_id": sessionId }, body });
2175
2450
  return response.data;
2176
2451
  }
2177
2452
  },
@@ -2252,8 +2527,8 @@ function createResources(client2, getApiKey) {
2252
2527
  return response.data;
2253
2528
  },
2254
2529
  /** functionRuntimeHealth: /functions/health. Returns the API response body. */
2255
- runtimeHealth: async (requestOptions = {}) => {
2256
- const response = await functionRuntimeHealth({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers } });
2530
+ runtimeHealth: async (requestOptions = {}, query = void 0) => {
2531
+ const response = await functionRuntimeHealth({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, query });
2257
2532
  return response.data;
2258
2533
  },
2259
2534
  /** functionScheduleSet: /functions/{function_id}/schedule. Returns the API response body. */
@@ -2267,6 +2542,43 @@ function createResources(client2, getApiKey) {
2267
2542
  return response.data;
2268
2543
  }
2269
2544
  },
2545
+ personas: {
2546
+ /** personaCreate: /personas/create. Returns the API response body. */
2547
+ create: async (body, requestOptions = {}) => {
2548
+ const response = await personaCreate({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, body });
2549
+ return response.data;
2550
+ },
2551
+ /** personaDelete: /personas/{persona_id}. Returns the API response body. */
2552
+ delete: async (personaId, requestOptions = {}) => {
2553
+ const response = await personaDelete({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "persona_id": personaId } });
2554
+ return response.data;
2555
+ },
2556
+ /** personaEmailsList: /personas/{persona_id}/emails. Returns the API response body. */
2557
+ emailsList: async (personaId, query = void 0, requestOptions = {}) => {
2558
+ const response = await personaEmailsList({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "persona_id": personaId }, query });
2559
+ return response.data;
2560
+ },
2561
+ /** personaGet: /personas/{persona_id}. Returns the API response body. */
2562
+ get: async (personaId, requestOptions = {}) => {
2563
+ const response = await personaGet({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "persona_id": personaId } });
2564
+ return response.data;
2565
+ },
2566
+ /** listPersonas: /personas. Returns the API response body. */
2567
+ list: async (query = void 0, requestOptions = {}) => {
2568
+ const response = await listPersonas({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, query });
2569
+ return response.data;
2570
+ },
2571
+ /** personaSmsList: /personas/{persona_id}/sms. Returns the API response body. */
2572
+ smsList: async (personaId, query = void 0, requestOptions = {}) => {
2573
+ const response = await personaSmsList({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "persona_id": personaId }, query });
2574
+ return response.data;
2575
+ },
2576
+ /** personaUpdate: /personas/{persona_id}. Returns the API response body. */
2577
+ update: async (personaId, body, requestOptions = {}) => {
2578
+ const response = await personaUpdate({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "persona_id": personaId }, body });
2579
+ return response.data;
2580
+ }
2581
+ },
2270
2582
  vaults: {
2271
2583
  /** vaultCreate: /vaults/create. Returns the API response body. */
2272
2584
  create: async (body, requestOptions = {}) => {
@@ -2304,60 +2616,23 @@ function createResources(client2, getApiKey) {
2304
2616
  return response.data;
2305
2617
  },
2306
2618
  /** vaultCreditCardSet: /vaults/{vault_id}/card. Returns the API response body. */
2307
- creditCardSet: async (vaultId, body, requestOptions = {}) => {
2308
- const response = await vaultCreditCardSet({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "vault_id": vaultId }, body });
2309
- return response.data;
2310
- },
2311
- /** vaultDelete: /vaults/{vault_id}. Returns the API response body. */
2312
- delete: async (vaultId, requestOptions = {}) => {
2313
- const response = await vaultDelete({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "vault_id": vaultId } });
2314
- return response.data;
2315
- },
2316
- /** listVaults: /vaults. Returns the API response body. */
2317
- list: async (query = void 0, requestOptions = {}) => {
2318
- const response = await listVaults({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, query });
2319
- return response.data;
2320
- },
2321
- /** vaultUpdate: /vaults/{vault_id}. Returns the API response body. */
2322
- update: async (vaultId, body, requestOptions = {}) => {
2323
- const response = await vaultUpdate({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "vault_id": vaultId }, body });
2324
- return response.data;
2325
- }
2326
- },
2327
- personas: {
2328
- /** personaCreate: /personas/create. Returns the API response body. */
2329
- create: async (body, requestOptions = {}) => {
2330
- const response = await personaCreate({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, body });
2331
- return response.data;
2332
- },
2333
- /** personaDelete: /personas/{persona_id}. Returns the API response body. */
2334
- delete: async (personaId, requestOptions = {}) => {
2335
- const response = await personaDelete({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "persona_id": personaId } });
2336
- return response.data;
2337
- },
2338
- /** personaEmailsList: /personas/{persona_id}/emails. Returns the API response body. */
2339
- emailsList: async (personaId, query = void 0, requestOptions = {}) => {
2340
- const response = await personaEmailsList({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "persona_id": personaId }, query });
2341
- return response.data;
2342
- },
2343
- /** personaGet: /personas/{persona_id}. Returns the API response body. */
2344
- get: async (personaId, requestOptions = {}) => {
2345
- const response = await personaGet({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "persona_id": personaId } });
2619
+ creditCardSet: async (vaultId, body, requestOptions = {}) => {
2620
+ const response = await vaultCreditCardSet({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "vault_id": vaultId }, body });
2346
2621
  return response.data;
2347
2622
  },
2348
- /** listPersonas: /personas. Returns the API response body. */
2349
- list: async (query = void 0, requestOptions = {}) => {
2350
- const response = await listPersonas({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, query });
2623
+ /** vaultDelete: /vaults/{vault_id}. Returns the API response body. */
2624
+ delete: async (vaultId, requestOptions = {}) => {
2625
+ const response = await vaultDelete({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "vault_id": vaultId } });
2351
2626
  return response.data;
2352
2627
  },
2353
- /** personaSmsList: /personas/{persona_id}/sms. Returns the API response body. */
2354
- smsList: async (personaId, query = void 0, requestOptions = {}) => {
2355
- const response = await personaSmsList({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "persona_id": personaId }, query });
2628
+ /** listVaults: /vaults. Returns the API response body. */
2629
+ list: async (query = void 0, requestOptions = {}) => {
2630
+ const response = await listVaults({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, query });
2356
2631
  return response.data;
2357
2632
  },
2358
- /** personaUpdate: /personas/{persona_id}. Returns the API response body. */
2359
- update: async (personaId, body, requestOptions = {}) => {
2360
- const response = await personaUpdate({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "persona_id": personaId }, body });
2633
+ /** vaultUpdate: /vaults/{vault_id}. Returns the API response body. */
2634
+ update: async (vaultId, body, requestOptions = {}) => {
2635
+ const response = await vaultUpdate({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "vault_id": vaultId }, body });
2361
2636
  return response.data;
2362
2637
  }
2363
2638
  },
@@ -2396,6 +2671,11 @@ function createResources(client2, getApiKey) {
2396
2671
  list: async (query = void 0, requestOptions = {}) => {
2397
2672
  const response = await profileList({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, query });
2398
2673
  return response.data;
2674
+ },
2675
+ /** profileStateSet: /profiles/{profile_id}/state. Returns the API response body. */
2676
+ stateSet: async (profileId, body, requestOptions = {}) => {
2677
+ const response = await profileStateSet({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers }, path: { "profile_id": profileId }, body });
2678
+ return response.data;
2399
2679
  }
2400
2680
  }
2401
2681
  };
@@ -2760,10 +3040,16 @@ async function createOrAppendCookiesToFile(cookieFile, cookies) {
2760
3040
  throw error;
2761
3041
  }
2762
3042
  }
2763
- existing.push(...cookies);
2764
- await (0, import_promises2.writeFile)(cookieFile, JSON.stringify(existing), "utf-8");
3043
+ const merged = /* @__PURE__ */ new Map();
3044
+ for (const cookie of [...existing, ...cookies]) {
3045
+ merged.set(cookieIdentity(cookie), cookie);
3046
+ }
3047
+ await (0, import_promises2.writeFile)(cookieFile, JSON.stringify([...merged.values()]), "utf-8");
2765
3048
  });
2766
3049
  }
3050
+ function cookieIdentity(cookie) {
3051
+ return JSON.stringify([cookie.name, cookie.domain ?? null, cookie.path ?? null, cookie.partitionKey ?? null]);
3052
+ }
2767
3053
  var fileLocks = /* @__PURE__ */ new Map();
2768
3054
  async function withFileLock(path, fn) {
2769
3055
  const key = (0, import_node_path.resolve)(path);
@@ -2922,8 +3208,8 @@ async function buildScrapeBody(options) {
2922
3208
  if (json_schema) {
2923
3209
  body.response_format = json_schema;
2924
3210
  } else {
2925
- const { z: z2 } = await import("zod");
2926
- body.response_format = normalizeJsonSchema(z2.toJSONSchema(response_format));
3211
+ const { z } = await import("zod");
3212
+ body.response_format = normalizeJsonSchema(z.toJSONSchema(response_format));
2927
3213
  }
2928
3214
  } else if (response_format) {
2929
3215
  body.response_format = response_format;
@@ -2935,9 +3221,6 @@ function processScrapeResponse(scrapeResponse, options) {
2935
3221
  throw new ScrapeFailedError("empty response");
2936
3222
  }
2937
3223
  const raiseOnFailure = options.raiseOnFailure ?? true;
2938
- if (options.only_images) {
2939
- return scrapeResponse.images ?? [];
2940
- }
2941
3224
  if (requiresSchema(options)) {
2942
3225
  const structured = scrapeResponse.structured;
2943
3226
  if (!structured) {
@@ -2960,10 +3243,126 @@ function processScrapeResponse(scrapeResponse, options) {
2960
3243
  return scrapeResponse.markdown;
2961
3244
  }
2962
3245
 
3246
+ // src/retry.ts
3247
+ var DEFAULT_MAX_RETRIES = 3;
3248
+ var RETRY_BASE_DELAY_MS = 1e3;
3249
+ var RETRY_MAX_DELAY_MS = 1e4;
3250
+ var RETRY_AFTER_MAX_MS = 2e4;
3251
+ var IDEMPOTENT_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS", "PUT", "DELETE"]);
3252
+ var REFUSED_STATUSES = /* @__PURE__ */ new Set([503, 529]);
3253
+ var GATEWAY_STATUSES = /* @__PURE__ */ new Set([502, 504]);
3254
+ var NOT_SENT_ERROR_CODES = /* @__PURE__ */ new Set([
3255
+ "ECONNREFUSED",
3256
+ "EAI_AGAIN",
3257
+ "ENETUNREACH",
3258
+ "EHOSTUNREACH",
3259
+ "UND_ERR_CONNECT_TIMEOUT"
3260
+ ]);
3261
+ var BROKEN_CONNECTION_ERROR_CODES = /* @__PURE__ */ new Set([
3262
+ "ECONNRESET",
3263
+ "EPIPE",
3264
+ "ETIMEDOUT",
3265
+ "UND_ERR_SOCKET",
3266
+ "UND_ERR_CLOSED"
3267
+ ]);
3268
+ function isIdempotentMethod(method) {
3269
+ return IDEMPOTENT_METHODS.has(method.toUpperCase());
3270
+ }
3271
+ function isRetryableStatus(status, method) {
3272
+ return REFUSED_STATUSES.has(status) || GATEWAY_STATUSES.has(status) && isIdempotentMethod(method);
3273
+ }
3274
+ function isRetryableNetworkError(error, method) {
3275
+ const code = networkErrorCode(error);
3276
+ if (code === void 0) return false;
3277
+ return NOT_SENT_ERROR_CODES.has(code) || BROKEN_CONNECTION_ERROR_CODES.has(code) && isIdempotentMethod(method);
3278
+ }
3279
+ function networkErrorCode(error, depth = 0) {
3280
+ if (typeof error !== "object" || error === null || depth > 4) return void 0;
3281
+ const { code, cause, errors } = error;
3282
+ if (typeof code === "string") return code;
3283
+ if (Array.isArray(errors) && errors.length > 0) return networkErrorCode(errors[0], depth + 1);
3284
+ return networkErrorCode(cause, depth + 1);
3285
+ }
3286
+ function parseRetryAfter(header, now = Date.now()) {
3287
+ if (!header) return void 0;
3288
+ const value = header.trim();
3289
+ if (/^\d+(\.\d+)?$/.test(value)) return Number(value) * 1e3;
3290
+ const date = Date.parse(value);
3291
+ return Number.isNaN(date) ? void 0 : Math.max(0, date - now);
3292
+ }
3293
+ function backoffDelayMs(attempt, random = Math.random) {
3294
+ return random() * Math.min(RETRY_MAX_DELAY_MS, RETRY_BASE_DELAY_MS * 2 ** attempt);
3295
+ }
3296
+ function retryDelayMs(attempt, retryAfter, random) {
3297
+ const requested = parseRetryAfter(retryAfter);
3298
+ if (requested === void 0) return backoffDelayMs(attempt, random);
3299
+ return requested <= RETRY_AFTER_MAX_MS ? requested : void 0;
3300
+ }
3301
+ function createRetryingFetch(options) {
3302
+ const wait2 = options.sleep ?? abortableSleep;
3303
+ return async (input, init) => {
3304
+ const baseFetch = options.fetch ?? globalThis.fetch;
3305
+ const request = input instanceof Request ? input : void 0;
3306
+ const method = (request?.method ?? init?.method ?? "GET").toUpperCase();
3307
+ const signal = init?.signal ?? request?.signal;
3308
+ const maxRetries = Math.max(0, Math.floor(options.maxRetries(signal) || 0));
3309
+ const send = (last) => request && request.body !== null && !last ? baseFetch(request.clone(), init) : baseFetch(input, init);
3310
+ for (let attempt = 0; ; attempt++) {
3311
+ const last = attempt >= maxRetries;
3312
+ let response;
3313
+ try {
3314
+ response = await send(last);
3315
+ } catch (error) {
3316
+ if (last || !isRetryableNetworkError(error, method)) throw error;
3317
+ const delay4 = backoffDelayMs(attempt, options.random);
3318
+ if (!fitsDeadline(delay4)) throw error;
3319
+ warn(`${method} request failed (${networkErrorCode(error)})`, delay4, attempt, maxRetries);
3320
+ await wait2(delay4, signal);
3321
+ continue;
3322
+ }
3323
+ if (last || !isRetryableStatus(response.status, method)) return response;
3324
+ const delay3 = retryDelayMs(attempt, response.headers.get("retry-after"), options.random);
3325
+ if (delay3 === void 0 || !fitsDeadline(delay3)) return response;
3326
+ await response.body?.cancel().catch(() => void 0);
3327
+ warn(`${method} request returned ${response.status}`, delay3, attempt, maxRetries);
3328
+ await wait2(delay3, signal);
3329
+ }
3330
+ function fitsDeadline(delay3) {
3331
+ const deadline = options.deadline?.(signal);
3332
+ return deadline === void 0 || Date.now() + delay3 < deadline;
3333
+ }
3334
+ };
3335
+ }
3336
+ function warn(reason, delay3, attempt, maxRetries) {
3337
+ console.warn(`${reason}, retrying in ${(delay3 / 1e3).toFixed(1)}s (${attempt + 1}/${maxRetries})`);
3338
+ }
3339
+ function abortableSleep(ms, signal) {
3340
+ return new Promise((resolve3, reject) => {
3341
+ if (signal?.aborted) {
3342
+ reject(signal.reason);
3343
+ return;
3344
+ }
3345
+ const onAbort = () => {
3346
+ clearTimeout(timer);
3347
+ reject(signal?.reason);
3348
+ };
3349
+ const timer = setTimeout(() => {
3350
+ signal?.removeEventListener("abort", onAbort);
3351
+ resolve3();
3352
+ }, ms);
3353
+ signal?.addEventListener("abort", onAbort, { once: true });
3354
+ });
3355
+ }
3356
+
2963
3357
  // src/session.ts
2964
3358
  var SESSION_START_TRIES = 3;
2965
3359
  var CLUSTER_OVERLOAD_RETRY_DELAY_MS = 3e4;
2966
3360
  var CAPTCHA_SOLVE_TIMEOUT_MS = 1e5;
3361
+ var OBSERVE_MIGRATION_URL = "https://docs.notte.cc/features/sessions/observe-migration";
3362
+ var OBSERVE_DEPRECATIONS = {
3363
+ instructions: `\`observe({ instructions })\` is deprecated and will be removed on December 1, 2026; <<ALTERNATIVE FOR instructions: session.act() \u2014 pending>>. See ${OBSERVE_MIGRATION_URL}`,
3364
+ deep: `\`perception_type: 'deep'\` is deprecated and will be removed on December 1, 2026; use \`perception_type: 'fast'\` (the default). See ${OBSERVE_MIGRATION_URL}`
3365
+ };
2967
3366
  function observeServerOwnedDialog(_dialog) {
2968
3367
  }
2969
3368
  function installServerOwnedDialogPolicy(browser) {
@@ -2978,6 +3377,7 @@ var Session = class {
2978
3377
  legacyHeadless;
2979
3378
  defaultRaiseOnFailure;
2980
3379
  defaultPerceptionType;
3380
+ warnedObserveDeprecations = /* @__PURE__ */ new Set();
2981
3381
  cookieFile;
2982
3382
  cookiesLoaded = false;
2983
3383
  cookieLoadPromise;
@@ -3013,9 +3413,11 @@ var Session = class {
3013
3413
  /**
3014
3414
  * Start the session: creates a new session on the server.
3015
3415
  *
3016
- * Retries up to `SESSION_START_TRIES` times on 5xx errors, waiting
3017
- * `CLUSTER_OVERLOAD_RETRY_DELAY_MS` on HTTP 529 (cluster overload). 4xx
3018
- * errors are never retried.
3416
+ * 503, 529, and refused connections follow the client's retry policy
3417
+ * (`NotteClientConfig.maxRetries`, honoring `Retry-After`). Other 5xx
3418
+ * errors are retried up to `SESSION_START_TRIES` times. With client
3419
+ * retries disabled, 529 waits `CLUSTER_OVERLOAD_RETRY_DELAY_MS` instead.
3420
+ * 4xx errors are never retried.
3019
3421
  *
3020
3422
  * Managed-auth sessions wait for readiness by default. Pass
3021
3423
  * `{ wait_for_authentication: false }` for an explicit nonblocking start,
@@ -3028,11 +3430,6 @@ var Session = class {
3028
3430
  * await session.start();
3029
3431
  */
3030
3432
  async start(options = {}) {
3031
- if (this.legacyHeadless === false) {
3032
- throw new Error(
3033
- "Remote `headless: false` is no longer supported. `headless: true` sessions still include session replays and access to the live viewer."
3034
- );
3035
- }
3036
3433
  if (this.legacyHeadless === true) {
3037
3434
  console.warn("`headless: true` is deprecated and ignored; remote sessions always use the supported browser launch mode.");
3038
3435
  this.legacyHeadless = void 0;
@@ -3041,42 +3438,60 @@ var Session = class {
3041
3438
  throw new Error("Session is already active");
3042
3439
  }
3043
3440
  options.signal?.throwIfAborted();
3044
- validateAuthRetry(this.options.auth_retry ?? 0);
3045
3441
  const { auth_retry, wait_for_authentication, ...request } = this.options;
3046
3442
  const body = {
3047
3443
  ...request,
3048
- ...request.auth_ids?.length ? { auth_retry: auth_retry ?? 0, wait_for_authentication: false } : {}
3444
+ ...this.legacyHeadless !== void 0 ? { headless: this.legacyHeadless } : {},
3445
+ ...auth_retry !== void 0 ? { auth_retry } : {},
3446
+ ...request.auth_ids?.length ? { wait_for_authentication: false } : {}
3049
3447
  };
3050
3448
  const shouldWait = options.wait_for_authentication ?? wait_for_authentication ?? true;
3449
+ const maxRetries = this.client.getConfig().maxRetries ?? 0;
3450
+ const timeoutMs = this.client.getConfig().timeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
3451
+ const deadline = timeoutMs > 0 ? Date.now() + timeoutMs : void 0;
3452
+ const fitsDeadline = (wait2) => deadline === void 0 || Date.now() + wait2 < deadline;
3453
+ let transientRetries = 0;
3051
3454
  let tries = SESSION_START_TRIES;
3052
3455
  const origTries = tries;
3053
3456
  let sessionData;
3054
3457
  while (tries > 0) {
3055
3458
  options.signal?.throwIfAborted();
3056
- tries -= 1;
3459
+ if (!fitsDeadline(0)) throw new NotteTimeoutError(`Session start timed out after ${timeoutMs}ms`);
3057
3460
  try {
3058
- const response = await sessionStart({ client: this.client.getClient(), body, throwOnError: true });
3461
+ const response = await sessionStart({
3462
+ client: this.client.getClient(),
3463
+ body,
3464
+ throwOnError: true,
3465
+ headers: {
3466
+ [MAX_RETRIES_HEADER]: "0",
3467
+ ...deadline === void 0 ? {} : { [TIMEOUT_HEADER]: String(Math.max(1, deadline - Date.now())) }
3468
+ }
3469
+ });
3059
3470
  sessionData = response.data;
3060
3471
  break;
3061
3472
  } catch (error) {
3473
+ const transient = error instanceof NotteAPIError ? isRetryableStatus(error.statusCode, "POST") : isRetryableNetworkError(error, "POST");
3474
+ if (maxRetries > 0 && transient) {
3475
+ const wait2 = transientRetries >= maxRetries ? void 0 : error instanceof NotteAPIError ? retryDelayMs(transientRetries, error.response?.headers.get("retry-after")) : backoffDelayMs(transientRetries);
3476
+ if (wait2 === void 0 || !fitsDeadline(wait2)) throw error;
3477
+ transientRetries += 1;
3478
+ console.warn(
3479
+ `Failed to start session (${error instanceof NotteAPIError ? error.statusCode : "connection error"}), retrying in ${(wait2 / 1e3).toFixed(1)}s (${transientRetries}/${maxRetries})`
3480
+ );
3481
+ await pauseStart(wait2, options.signal);
3482
+ continue;
3483
+ }
3484
+ tries -= 1;
3062
3485
  if (tries === 0 || !(error instanceof NotteAPIError) || error.statusCode < 500) {
3063
3486
  throw error;
3064
3487
  }
3065
3488
  const retryStr = `${origTries - tries}/${origTries - 1}`;
3489
+ if (!fitsDeadline(error.statusCode === 529 ? CLUSTER_OVERLOAD_RETRY_DELAY_MS : 0)) throw error;
3066
3490
  if (error.statusCode === 529) {
3067
3491
  console.warn(
3068
3492
  `Failed to start session due to cluster overload, retrying in ${CLUSTER_OVERLOAD_RETRY_DELAY_MS / 1e3} seconds (${retryStr})...`
3069
3493
  );
3070
- if (options.signal) {
3071
- try {
3072
- await (0, import_promises4.setTimeout)(CLUSTER_OVERLOAD_RETRY_DELAY_MS, void 0, { signal: options.signal });
3073
- } catch (error2) {
3074
- options.signal.throwIfAborted();
3075
- throw error2;
3076
- }
3077
- } else {
3078
- await sleep(CLUSTER_OVERLOAD_RETRY_DELAY_MS);
3079
- }
3494
+ await pauseStart(CLUSTER_OVERLOAD_RETRY_DELAY_MS, options.signal);
3080
3495
  } else {
3081
3496
  console.warn(`Failed to start session: retrying (${retryStr})`);
3082
3497
  }
@@ -3094,6 +3509,7 @@ var Session = class {
3094
3509
  this.fileStorage = this.fileStorage?.forSession(sessionData.session_id);
3095
3510
  try {
3096
3511
  options.signal?.throwIfAborted();
3512
+ if (!fitsDeadline(0)) throw new NotteTimeoutError(`Session start timed out after ${timeoutMs}ms`);
3097
3513
  if (shouldWait) await this.waitForAuth(options);
3098
3514
  if (this.openViewer) {
3099
3515
  this.openViewerInBrowser();
@@ -3418,9 +3834,7 @@ var Session = class {
3418
3834
  * start-time profile settings are not changed, so a session started with `persist: true`
3419
3835
  * still saves again when it stops.
3420
3836
  *
3421
- * @example
3422
- * const profile = await session.saveProfile({ name: 'github' });
3423
- * // later: client.Session({ profile: { id: profile.profile_id } })
3837
+ * See [Browser Profiles](/features/sessions/browser-profiles) for the tested Python and TypeScript example.
3424
3838
  */
3425
3839
  async saveProfile(options = {}) {
3426
3840
  const { profile_id, name } = options;
@@ -3653,19 +4067,30 @@ var Session = class {
3653
4067
  * The `perception_type` defaults to the session option (`fast`). A bare
3654
4068
  * string argument is accepted as the perception type.
3655
4069
  *
4070
+ * Deprecated: `perception_type: 'deep'` and `instructions` are removed on
4071
+ * December 1, 2026, and each warns once per session. Use `perception_type:
4072
+ * 'fast'` (the default) instead of `'deep'`. For `instructions`:
4073
+ * `<<ALTERNATIVE FOR instructions: session.act() — pending>>`. See https://docs.notte.cc/features/sessions/observe-migration
4074
+ *
3656
4075
  * @param options - Observation settings, including an optional URL, or a perception-mode string.
3657
4076
  * @returns Structured page analysis, available actions, and page metadata.
3658
4077
  * @throws NotteAPIError if observation fails.
3659
4078
  * @example
3660
4079
  * const obs = await session.observe();
3661
4080
  * console.log(obs.space.description);
3662
- * const deep = await session.observe({ perception_type: 'deep', max_nb_actions: 50 });
4081
+ * const firstActions = await session.observe({ max_nb_actions: 50 });
3663
4082
  */
3664
4083
  async observe(options = {}) {
3665
4084
  const body = typeof options === "string" ? { perception_type: options } : { ...options };
3666
4085
  if (body.perception_type == null) {
3667
4086
  body.perception_type = this.defaultPerceptionType;
3668
4087
  }
4088
+ if (body.instructions != null) {
4089
+ this.warnObserveDeprecation("instructions");
4090
+ }
4091
+ if (body.perception_type !== "fast") {
4092
+ this.warnObserveDeprecation("deep");
4093
+ }
3669
4094
  const response = await pageObserve({
3670
4095
  client: this.client.getClient(),
3671
4096
  path: { session_id: this.requireSessionId() },
@@ -3674,6 +4099,12 @@ var Session = class {
3674
4099
  });
3675
4100
  return response.data;
3676
4101
  }
4102
+ warnObserveDeprecation(option) {
4103
+ if (!this.warnedObserveDeprecations.has(option)) {
4104
+ this.warnedObserveDeprecations.add(option);
4105
+ console.warn(OBSERVE_DEPRECATIONS[option]);
4106
+ }
4107
+ }
3677
4108
  async scrape(options = {}) {
3678
4109
  const sessionId = this.requireSessionId();
3679
4110
  const body = await buildScrapeBody(options);
@@ -3741,424 +4172,18 @@ var Session = class {
3741
4172
  }
3742
4173
  }
3743
4174
  };
3744
-
3745
- // src/agent.ts
3746
- var import_ws = __toESM(require("ws"));
3747
- var import_zod = require("zod");
3748
- function prepareAgentRequest(data) {
3749
- const apiData = { ...data };
3750
- const rf = data.response_format;
3751
- if (rf && typeof rf.parse === "function" && typeof rf.safeParse === "function") {
3752
- apiData.response_format = normalizeJsonSchema(import_zod.z.toJSONSchema(rf));
3753
- return { apiData, zodSchema: rf };
3754
- }
3755
- return { apiData, zodSchema: null };
3756
- }
3757
- function parseAgentStatusMessage(parsed, agentId) {
3758
- if (parsed?.status === "agent_stop" && parsed.agent && parsed.agent.agent_id === agentId && parsed.agent.task !== void 0 && parsed.agent.status !== void 0) {
3759
- return parsed.agent;
3760
- }
3761
- if (parsed?.agent_id === agentId && parsed.task !== void 0 && parsed.status !== void 0) {
3762
- return parsed;
3763
- }
3764
- return null;
3765
- }
3766
- function validatePersonaOption(persona, persona_id) {
3767
- if (persona) {
3768
- try {
3769
- const personaId = persona.personaId;
3770
- if (!personaId || personaId.length === 0) {
3771
- throw new Error("Persona ID cannot be empty");
3772
- }
3773
- return personaId;
3774
- } catch (error) {
3775
- throw new Error(`Invalid persona object: ${error instanceof Error ? error.message : String(error)}`);
3776
- }
3777
- } else if (persona_id) {
3778
- if (persona_id.length === 0) {
3779
- throw new Error("Persona ID cannot be empty");
3780
- }
3781
- return persona_id;
3782
- }
3783
- return void 0;
3784
- }
3785
- function validateVaultOption(vault, vault_id) {
3786
- if (vault) {
3787
- try {
3788
- const vaultId = vault.vaultId;
3789
- if (!vaultId || vaultId.length === 0) {
3790
- throw new Error("Vault ID cannot be empty");
3791
- }
3792
- return vaultId;
3793
- } catch (error) {
3794
- throw new Error(`Invalid vault object: ${error instanceof Error ? error.message : String(error)}`);
3795
- }
3796
- } else if (vault_id) {
3797
- if (vault_id.length === 0) {
3798
- throw new Error("Vault ID cannot be empty");
3799
- }
3800
- return vault_id;
3801
- }
3802
- return void 0;
3803
- }
3804
- function validateSessionOption(session) {
3805
- const sessionId = session.getId();
3806
- if (!sessionId || sessionId.length === 0) {
3807
- throw new Error("Session ID cannot be empty");
4175
+ async function pauseStart(ms, signal) {
4176
+ if (!signal) {
4177
+ await sleep(ms);
4178
+ return;
3808
4179
  }
3809
- return sessionId;
3810
- }
3811
- function validateAgentIdOption(agent_id) {
3812
- if (agent_id.length === 0) {
3813
- throw new Error("Agent ID cannot be empty");
4180
+ try {
4181
+ await (0, import_promises4.setTimeout)(ms, void 0, { signal });
4182
+ } catch (error) {
4183
+ signal.throwIfAborted();
4184
+ throw error;
3814
4185
  }
3815
4186
  }
3816
- var defaultStepLogger = (stepData, stepCounter, agentId) => {
3817
- console.log(`\u2728 Step ${stepCounter} (agent: ${agentId})`);
3818
- if (stepData && typeof stepData === "object") {
3819
- if (stepData.state) {
3820
- const state = stepData.state;
3821
- if (state.page_summary) {
3822
- console.log(`\u{1F4DD} Current page: ${state.page_summary}`);
3823
- }
3824
- if (state.previous_goal_eval) {
3825
- const statusEmoji = state.previous_goal_status === "success" ? "\u2705" : state.previous_goal_status === "failure" ? "\u274C" : "\u2753";
3826
- console.log(`\u{1F52C} Previous goal: ${statusEmoji} ${state.previous_goal_eval}`);
3827
- }
3828
- if (state.memory) {
3829
- console.log(`\u{1F9E0} Memory: ${state.memory}`);
3830
- }
3831
- if (state.next_goal) {
3832
- console.log(`\u{1F3AF} Next goal: ${state.next_goal}`);
3833
- }
3834
- if (state.relevant_interactions && state.relevant_interactions.length > 0) {
3835
- console.log(`\u{1F194} Relevant ids:`);
3836
- state.relevant_interactions.forEach((interaction) => {
3837
- console.log(` \u25B6 ${interaction.id}: ${interaction.reason}`);
3838
- });
3839
- }
3840
- }
3841
- if (stepData.action) {
3842
- const action = stepData.action;
3843
- let actionStr = `\u26A1 Taking action:
3844
- \u25B6 ${action.name || action.type || "Unknown action"}`;
3845
- if (action.id) {
3846
- actionStr += ` with id ${action.id}`;
3847
- } else if (action.param && action.param.name && action[action.param.name]) {
3848
- actionStr += ` with ${action.param.name}=${action[action.param.name]}`;
3849
- }
3850
- console.log(actionStr);
3851
- }
3852
- } else {
3853
- console.log(stepData);
3854
- }
3855
- console.log("");
3856
- };
3857
- var Agent = class {
3858
- client;
3859
- request;
3860
- response = null;
3861
- websocket = null;
3862
- existingAgent;
3863
- constructor(client2, options) {
3864
- this.client = client2;
3865
- if ("agent_id" in options && options.agent_id) {
3866
- if (options.session) {
3867
- throw new Error("Either session (for running a new agent) or agent_id (for accessing an existing agent) have to be provided, not both");
3868
- }
3869
- validateAgentIdOption(options.agent_id);
3870
- this.existingAgent = true;
3871
- this.response = { agent_id: options.agent_id };
3872
- } else if ("session" in options && options.session) {
3873
- if (options.agent_id) {
3874
- throw new Error("Either session (for running a new agent) or agent_id (for accessing an existing agent) have to be provided, not both");
3875
- }
3876
- this.existingAgent = false;
3877
- const { session, vault, persona, ...requestData } = options;
3878
- const sessionId = validateSessionOption(session);
3879
- const vaultId = validateVaultOption(vault, options.vault_id);
3880
- const personaId = validatePersonaOption(persona, options.persona_id);
3881
- this.request = {
3882
- session_id: sessionId,
3883
- vault_id: vaultId,
3884
- persona_id: personaId,
3885
- ...requestData
3886
- };
3887
- } else {
3888
- throw new Error("Either session (for running a new agent) or agent_id (for accessing an existing agent) have to be provided");
3889
- }
3890
- }
3891
- async start(data) {
3892
- if (this.existingAgent) {
3893
- throw new Error("You cannot call start() on an agent instantiated from agent id");
3894
- }
3895
- if (!this.request) {
3896
- throw new Error("Agent not properly initialized with session");
3897
- }
3898
- try {
3899
- const { apiData } = prepareAgentRequest(data);
3900
- const requestBody = {
3901
- ...this.request,
3902
- ...apiData
3903
- };
3904
- const response = await agentStart({
3905
- client: this.client.getClient(),
3906
- body: requestBody
3907
- });
3908
- if (response?.error) {
3909
- throw new Error(`Failed to start agent: ${formatError(response.error)}`);
3910
- }
3911
- this.response = response.data;
3912
- return this.response;
3913
- } catch (error) {
3914
- throw new Error(`Failed to start agent: ${error instanceof Error ? error.message : String(error)}`);
3915
- }
3916
- }
3917
- async run(data) {
3918
- if (this.existingAgent) {
3919
- throw new Error("You cannot call run() on an agent instantiated from agent id");
3920
- }
3921
- const { apiData, zodSchema } = prepareAgentRequest(data);
3922
- this.response = await this.start(apiData);
3923
- console.log(`[Agent] ${this.agentId} started`);
3924
- const result = await this.watchLogsAndWait(true, data.updateHandler || null);
3925
- if (zodSchema && result && result.answer !== void 0 && result.answer !== null) {
3926
- let candidate;
3927
- try {
3928
- candidate = typeof result.answer === "string" ? JSON.parse(result.answer) : result.answer;
3929
- } catch {
3930
- throw new Error(`Agent answer is not valid JSON and cannot be validated against the schema`);
3931
- }
3932
- try {
3933
- result.answer = zodSchema.parse(candidate);
3934
- } catch (error) {
3935
- throw new Error(`Agent answer schema validation failed: ${error instanceof Error ? error.message : String(error)}`);
3936
- }
3937
- }
3938
- return result;
3939
- }
3940
- /**
3941
- * Watch logs and wait for completion - mirrors Python watch_logs_and_wait
3942
- */
3943
- async watchLogsAndWait(log = true, updateHandler = null) {
3944
- if (this.existingAgent) {
3945
- throw new Error("You cannot call watchLogsAndWait() on an agent instantiated from agent id");
3946
- }
3947
- if (!this.response) {
3948
- throw new Error("Agent not started");
3949
- }
3950
- const deadline = Date.now() + 3e5;
3951
- try {
3952
- const result = await this.watchLogs(log, updateHandler, deadline);
3953
- if (result && result.status !== "active") {
3954
- return result;
3955
- }
3956
- } catch (error) {
3957
- console.warn(`[Agent] ${this.agentId} log stream unavailable; polling for completion.`);
3958
- }
3959
- while (Date.now() < deadline) {
3960
- const result = await this.status(AbortSignal.timeout(Math.max(1, deadline - Date.now())));
3961
- if (result.status !== "active") {
3962
- updateHandler?.({ type: "completion", data: result, timestamp: (/* @__PURE__ */ new Date()).toISOString() });
3963
- return result;
3964
- }
3965
- await new Promise((resolve3) => setTimeout(resolve3, 1e3));
3966
- }
3967
- throw new Error(`Agent ${this.agentId} did not complete before the polling timeout; retrieve status() later.`);
3968
- }
3969
- /**
3970
- * Watch logs via WebSocket - mirrors Python watch_logs method
3971
- */
3972
- async watchLogs(log = true, updateHandler = null, deadline = Date.now() + 3e5) {
3973
- if (this.existingAgent) {
3974
- throw new Error("You cannot call watchLogs() on an agent instantiated from agent id");
3975
- }
3976
- if (!this.response) {
3977
- throw new Error("Agent not started");
3978
- }
3979
- const config = this.client.getConfig();
3980
- if (config.baseUrl?.startsWith("/")) return null;
3981
- const agentId = this.response.agent_id;
3982
- const sessionId = this.response.session_id;
3983
- const debug = await sessionDebugInfo({
3984
- client: this.client.getClient(),
3985
- path: { session_id: sessionId },
3986
- throwOnError: true,
3987
- signal: AbortSignal.timeout(Math.max(1, deadline - Date.now()))
3988
- });
3989
- const wsUrl = new URL(this.client.withDbPreview(debug.data.ws.logs));
3990
- const token = wsUrl.searchParams.get("token");
3991
- if (!token || token === config.apiKey || wsUrl.protocol !== "wss:") return null;
3992
- wsUrl.pathname = `/agents/${encodeURIComponent(agentId)}/debug/logs`;
3993
- wsUrl.searchParams.set("session_id", sessionId);
3994
- return new Promise((resolve3, reject) => {
3995
- this.websocket = new import_ws.default(wsUrl);
3996
- const socket = this.websocket;
3997
- const timeout = setTimeout(() => finish(null), Math.max(0, deadline - Date.now()));
3998
- let settled = false;
3999
- const finish = (result) => {
4000
- if (settled) return;
4001
- settled = true;
4002
- clearTimeout(timeout);
4003
- if (this.websocket === socket) this.websocket = null;
4004
- if (socket.readyState !== import_ws.default.CLOSED) socket.terminate();
4005
- resolve3(result);
4006
- };
4007
- let counter = 0;
4008
- this.websocket.on("open", () => {
4009
- });
4010
- this.websocket.on("error", (error) => {
4011
- console.error(`Connection error: ${agentId} ${error.message}`);
4012
- finish(null);
4013
- });
4014
- this.websocket.on("message", (data) => {
4015
- try {
4016
- const message = data.toString();
4017
- let parsed;
4018
- try {
4019
- parsed = JSON.parse(message);
4020
- } catch {
4021
- return;
4022
- }
4023
- const finalStatus = parseAgentStatusMessage(parsed, agentId);
4024
- if (finalStatus) {
4025
- if (updateHandler) {
4026
- updateHandler({
4027
- type: "completion",
4028
- data: finalStatus,
4029
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
4030
- });
4031
- } else if (!finalStatus.success) {
4032
- console.error(finalStatus.answer);
4033
- }
4034
- finish(finalStatus);
4035
- return;
4036
- }
4037
- if (log) {
4038
- counter++;
4039
- if (updateHandler) {
4040
- updateHandler({
4041
- type: "step",
4042
- data: parsed,
4043
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
4044
- });
4045
- } else {
4046
- defaultStepLogger(parsed, counter, agentId);
4047
- }
4048
- }
4049
- } catch (error) {
4050
- console.error(`Error processing WebSocket message: ${error}`);
4051
- }
4052
- });
4053
- this.websocket.on("close", () => {
4054
- finish(null);
4055
- });
4056
- });
4057
- }
4058
- /**
4059
- * Get agent status - mirrors Python status method
4060
- */
4061
- async status(signal) {
4062
- if (!this.response) {
4063
- throw new Error("Agent not started or not accessible");
4064
- }
4065
- const response = await agentStatus({
4066
- client: this.client.getClient(),
4067
- signal,
4068
- path: {
4069
- agent_id: this.response.agent_id
4070
- }
4071
- });
4072
- if (response?.error) {
4073
- throw new Error(`Failed to get agent status: ${formatError(response.error)}`);
4074
- }
4075
- return response.data;
4076
- }
4077
- /**
4078
- * Stop the agent - mirrors Python stop method
4079
- */
4080
- async stop() {
4081
- if (this.existingAgent) {
4082
- throw new Error("You cannot call stop() on an agent instantiated from agent id");
4083
- }
4084
- if (!this.response) {
4085
- throw new Error("Agent not started");
4086
- }
4087
- try {
4088
- console.log(`[Agent] ${this.response.agent_id} is stopping`);
4089
- const response = await agentStop({
4090
- client: this.client.getClient(),
4091
- path: {
4092
- agent_id: this.response.agent_id
4093
- },
4094
- query: { session_id: this.response.session_id }
4095
- });
4096
- if (response?.error) {
4097
- throw new Error(`Failed to stop agent: ${formatError(response.error)}`);
4098
- }
4099
- console.log(`[Agent] ${this.response.agent_id} stopped`);
4100
- return response.data;
4101
- } catch (error) {
4102
- console.warn(`Failed to stop agent: ${error instanceof Error ? error.message : String(error)}`);
4103
- throw error;
4104
- } finally {
4105
- this.disconnectWebSocket();
4106
- }
4107
- }
4108
- /**
4109
- * Disconnect WebSocket
4110
- */
4111
- disconnectWebSocket() {
4112
- if (this.websocket) {
4113
- this.websocket.close();
4114
- this.websocket = null;
4115
- }
4116
- }
4117
- /**
4118
- * Get agent ID - mirrors Python agent_id property
4119
- */
4120
- get agentId() {
4121
- if (!this.response) {
4122
- throw new Error("You need to run the agent first to get the agent id");
4123
- }
4124
- return this.response.agent_id;
4125
- }
4126
- /**
4127
- * Get session ID - mirrors Python session_id property
4128
- */
4129
- get sessionId() {
4130
- if (!this.response) {
4131
- throw new Error("You need to run the agent first to get the session id");
4132
- }
4133
- return this.response.session_id;
4134
- }
4135
- /**
4136
- * Whether `start()`/`run()` was called on this instance (or it was built from an agent id).
4137
- * This is a local check and does not contact the API.
4138
- */
4139
- hasStarted() {
4140
- return this.response !== null;
4141
- }
4142
- /**
4143
- * Whether the agent is still active on the server. Fetches the current status,
4144
- * like calling `agent.status()` in Python; an agent that was never started is not active.
4145
- */
4146
- async isActive() {
4147
- if (!this.response) {
4148
- return false;
4149
- }
4150
- const status = await this.status();
4151
- return status.status === "active";
4152
- }
4153
- /**
4154
- * @deprecated Only reports whether this instance was started; it does not
4155
- * contact the API. Use `hasStarted()` for that check or `isActive()` for the
4156
- * live server status.
4157
- */
4158
- isRunning() {
4159
- return this.hasStarted();
4160
- }
4161
- };
4162
4187
 
4163
4188
  // src/vaults.ts
4164
4189
  var import_tldts = require("tldts");
@@ -4318,9 +4343,9 @@ var NotteVault = class {
4318
4343
  await this.delete();
4319
4344
  }
4320
4345
  /**
4321
- * Add or update the credentials stored for a website. The URL is reduced to
4322
- * its root domain (`https://github.com/login` → `github.com`) before it is
4323
- * sent, like Python's `AddCredentialsRequest`.
4346
+ * Add or update the credentials stored for a website. Values are sent as
4347
+ * supplied; the API validates credentials and reduces the URL to its root
4348
+ * domain (`https://github.com/login` → `github.com`).
4324
4349
  *
4325
4350
  * ```ts
4326
4351
  * await vault.addCredentials('https://github.com/', {
@@ -4331,13 +4356,11 @@ var NotteVault = class {
4331
4356
  * ```
4332
4357
  */
4333
4358
  async addCredentials(url, credentials) {
4334
- const domain = validateUrl(url);
4335
- validateCredentials(credentials);
4336
4359
  const vaultId = await this.ensureInitialized();
4337
4360
  await vaultCredentialsAdd({
4338
4361
  client: this.client.getClient(),
4339
4362
  path: { vault_id: vaultId },
4340
- body: { url: domain, credentials },
4363
+ body: { url, credentials },
4341
4364
  throwOnError: true
4342
4365
  });
4343
4366
  }
@@ -4351,12 +4374,11 @@ var NotteVault = class {
4351
4374
  * ```
4352
4375
  */
4353
4376
  async getCredentials(url) {
4354
- const domain = validateUrl(url);
4355
4377
  const vaultId = await this.ensureInitialized();
4356
4378
  const response = await vaultCredentialsGet({
4357
4379
  client: this.client.getClient(),
4358
4380
  path: { vault_id: vaultId },
4359
- query: { url: domain },
4381
+ query: { url },
4360
4382
  throwOnError: true
4361
4383
  });
4362
4384
  return response.data.credentials;
@@ -4384,12 +4406,11 @@ var NotteVault = class {
4384
4406
  * ```
4385
4407
  */
4386
4408
  async deleteCredentials(url) {
4387
- const domain = validateUrl(url);
4388
4409
  const vaultId = await this.ensureInitialized();
4389
4410
  await vaultCredentialsDelete({
4390
4411
  client: this.client.getClient(),
4391
4412
  path: { vault_id: vaultId },
4392
- query: { url: domain },
4413
+ query: { url },
4393
4414
  throwOnError: true
4394
4415
  });
4395
4416
  }
@@ -4434,7 +4455,7 @@ var NotteVault = class {
4434
4455
  * ```
4435
4456
  */
4436
4457
  async addCredentialsFromEnv(url) {
4437
- const rootDomain = validateUrl(url);
4458
+ const rootDomain = getRootDomain(url);
4438
4459
  const prefix = rootDomain.replace(/\./g, "_").toUpperCase();
4439
4460
  const credentials = {};
4440
4461
  const variableNames = [];
@@ -4510,6 +4531,10 @@ var NotteVault = class {
4510
4531
  };
4511
4532
 
4512
4533
  // src/personas.ts
4534
+ function withPersonaDefaults(persona) {
4535
+ if (!persona || persona.email_provider) return persona;
4536
+ return { ...persona, email_provider: "notte" };
4537
+ }
4513
4538
  var NottePersona = class {
4514
4539
  client;
4515
4540
  _initRequest;
@@ -4569,7 +4594,7 @@ var NottePersona = class {
4569
4594
  if (response?.error) {
4570
4595
  throw new Error(`Failed to get persona: ${formatError(response.error)}`);
4571
4596
  }
4572
- this.response = response.data;
4597
+ this.response = withPersonaDefaults(response.data);
4573
4598
  return this.response;
4574
4599
  }
4575
4600
  async initNewPersona(createData) {
@@ -4580,7 +4605,7 @@ var NottePersona = class {
4580
4605
  if (response?.error) {
4581
4606
  throw new Error(`Failed to create persona: ${formatError(response.error)}`);
4582
4607
  }
4583
- this.response = response.data;
4608
+ this.response = withPersonaDefaults(response.data);
4584
4609
  console.warn(
4585
4610
  `[Persona] ${this.response.persona_id} created since no persona id was provided. Please store this to retrieve it later.`
4586
4611
  );
@@ -4809,11 +4834,10 @@ async function offloadRunPayloads(client2, path, fields) {
4809
4834
  if (payload.length > MAX_PAYLOAD_BYTES) throw new Error(`Function run ${field} exceeds the payload limit`);
4810
4835
  if (payload.length <= INLINE_FIELD_BYTES) continue;
4811
4836
  const checksum = (0, import_node_crypto2.createHash)("sha256").update(payload).digest("base64");
4812
- const prepared = await client2.post({
4813
- url: "/functions/{function_id}/runs/{run_id}/payloads/{field}/upload",
4837
+ const prepared = await prepareRunPayloadUpload({
4838
+ client: client2,
4814
4839
  path: { ...path, field },
4815
4840
  body: { size_bytes: payload.length, sha256: checksum },
4816
- headers: { "Content-Type": "application/json" },
4817
4841
  throwOnError: true
4818
4842
  });
4819
4843
  const upload = prepared.data;
@@ -4889,7 +4913,6 @@ var FUNCTION_RUN_ENDPOINTS = {
4889
4913
  start: "/functions/{function_id}/runs/{run_id}"
4890
4914
  };
4891
4915
  var RUN_API_KEY_HEADER = "x-notte-api-key";
4892
- var FUNCTION_RUNTIMES = ["standard", "extended"];
4893
4916
  var FUNCTION_RUN_STATUSES = ["closed", "active", "failed"];
4894
4917
  var NotteFunction = class {
4895
4918
  client;
@@ -4992,7 +5015,7 @@ var NotteFunction = class {
4992
5015
  throwOnError: true,
4993
5016
  path: { function_id: functionId },
4994
5017
  query: {
4995
- restricted: options.restricted ?? true,
5018
+ restricted: options.restricted,
4996
5019
  ...options.version !== void 0 ? { version: options.version } : {}
4997
5020
  },
4998
5021
  body: { file }
@@ -5089,7 +5112,7 @@ var NotteFunction = class {
5089
5112
  client: this.client.getClient(),
5090
5113
  throwOnError: true,
5091
5114
  path: { function_id: functionId },
5092
- query: { restricted: options.restricted ?? true },
5115
+ query: { restricted: options.restricted },
5093
5116
  body: { version: options.version }
5094
5117
  });
5095
5118
  return response.data;
@@ -5185,7 +5208,7 @@ var NotteFunction = class {
5185
5208
  client: this.client.getClient(),
5186
5209
  throwOnError: true,
5187
5210
  path: { function_id: functionId },
5188
- query: { ...options, only_active: options.only_active ?? false }
5211
+ query: options
5189
5212
  });
5190
5213
  return response.data;
5191
5214
  }
@@ -5218,9 +5241,6 @@ var NotteFunction = class {
5218
5241
  if (!(timeoutMs > 0)) {
5219
5242
  throw new InvalidRequestError("timeoutMs must be a positive number");
5220
5243
  }
5221
- if (options.runtime !== void 0 && !FUNCTION_RUNTIMES.includes(options.runtime)) {
5222
- throw new InvalidRequestError(`runtime must be one of ${FUNCTION_RUNTIMES.join(", ")}, got '${String(options.runtime)}'`);
5223
- }
5224
5244
  const functionId = await this.ensureInitialized();
5225
5245
  const functionRunId = options.functionRunId ?? (await this.createRun()).function_run_id;
5226
5246
  const body = {
@@ -5563,7 +5583,7 @@ var SessionFiles = class {
5563
5583
  const response = await listSessionFiles({
5564
5584
  client: this.client,
5565
5585
  path: { session_id: this.sessionId },
5566
- query: { limit: options.limit ?? 100, offset: options.offset ?? 0, source: options.source },
5586
+ query: options,
5567
5587
  throwOnError: true
5568
5588
  });
5569
5589
  return response.data;
@@ -5972,6 +5992,7 @@ var DEFAULT_NOTTE_API_URL = "https://api.notte.cc";
5972
5992
  var DEFAULT_REQUEST_TIMEOUT_MS = 6e4;
5973
5993
  var REQUEST_ORIGIN = "sdk-node";
5974
5994
  var TIMEOUT_HEADER = "x-notte-timeout-ms";
5995
+ var MAX_RETRIES_HEADER = "x-notte-max-retries";
5975
5996
  var DB_PREVIEW_ENV = "NOTTE_DB_PREVIEW_BRANCH";
5976
5997
  var DB_PREVIEW_HEADER = "x-db-preview";
5977
5998
  var EXECUTION_ERROR_CLASS = "NotteApiExecutionError";
@@ -5994,6 +6015,10 @@ var NotteClient3 = class {
5994
6015
  if (!(timeoutMs >= 0)) {
5995
6016
  throw new InvalidRequestError("timeoutMs must be a non-negative number");
5996
6017
  }
6018
+ const maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES;
6019
+ if (!Number.isInteger(maxRetries) || maxRetries < 0) {
6020
+ throw new InvalidRequestError("maxRetries must be a non-negative integer");
6021
+ }
5997
6022
  const isProxyMode = isRelativeProxyUrl(baseUrl);
5998
6023
  if (!isProxyMode) {
5999
6024
  const url = new URL(baseUrl);
@@ -6009,7 +6034,15 @@ var NotteClient3 = class {
6009
6034
  "NOTTE_API_KEY needs to be provided. Pass config.apiKey or set the NOTTE_API_KEY environment variable."
6010
6035
  );
6011
6036
  }
6012
- this.config = { baseUrl, apiKey, timeoutMs, captchaTimeoutSeconds, dbPreview, verbose: config.verbose ?? false };
6037
+ this.config = {
6038
+ baseUrl,
6039
+ apiKey,
6040
+ timeoutMs,
6041
+ captchaTimeoutSeconds,
6042
+ dbPreview,
6043
+ maxRetries,
6044
+ verbose: config.verbose ?? false
6045
+ };
6013
6046
  if (baseUrl !== DEFAULT_NOTTE_API_URL && !isProxyMode) {
6014
6047
  console.warn(`NOTTE_API_URL is set to: ${baseUrl}`);
6015
6048
  }
@@ -6018,7 +6051,7 @@ var NotteClient3 = class {
6018
6051
  redirect: "manual",
6019
6052
  throwOnError: true
6020
6053
  });
6021
- this.client.interceptors.request.use((request) => {
6054
+ this.client.interceptors.request.use((request, opts) => {
6022
6055
  const headers = new Headers(request.headers);
6023
6056
  if (this.config.apiKey) headers.set("Authorization", `Bearer ${this.config.apiKey}`);
6024
6057
  headers.set("x-notte-request-origin", REQUEST_ORIGIN);
@@ -6026,16 +6059,25 @@ var NotteClient3 = class {
6026
6059
  if (this.config.dbPreview) headers.set(DB_PREVIEW_HEADER, this.config.dbPreview);
6027
6060
  const override = headers.get(TIMEOUT_HEADER);
6028
6061
  headers.delete(TIMEOUT_HEADER);
6062
+ const retriesOverride = headers.get(MAX_RETRIES_HEADER);
6063
+ headers.delete(MAX_RETRIES_HEADER);
6029
6064
  const timeoutMs2 = override !== null ? Number(override) : this.config.timeoutMs;
6030
6065
  if (this.config.verbose) {
6031
6066
  console.info(`Making \`${request.method}\` request to \`${request.url}\``);
6032
6067
  }
6033
- if (!(timeoutMs2 > 0)) {
6034
- return new Request(request, { headers });
6035
- }
6036
- const deadline = withTimeout(request.signal, timeoutMs2);
6037
- const timed = new Request(request, { headers, signal: deadline.signal });
6038
- pendingDeadlines.set(timed, deadline.release);
6068
+ const callerSignal = opts.signal ?? request.signal;
6069
+ const deadline = timeoutMs2 > 0 ? withTimeout(callerSignal, timeoutMs2) : void 0;
6070
+ const signal = deadline?.signal ?? callerSignal;
6071
+ const timed = new Request(request, { headers, signal });
6072
+ pendingRequests.set(timed, { signal, release: deadline?.release ?? (() => void 0), expiresAt: deadline?.expiresAt ?? Infinity });
6073
+ const transport = originalTransports.get(opts) ?? opts.fetch ?? globalThis.fetch;
6074
+ originalTransports.set(opts, transport);
6075
+ const retrying = createRetryingFetch({
6076
+ fetch: transport,
6077
+ maxRetries: () => retriesOverride !== null ? Number(retriesOverride) : this.config.maxRetries,
6078
+ deadline: () => deadline?.expiresAt
6079
+ });
6080
+ opts.fetch = (input, init) => retrying(input, { ...init, signal });
6039
6081
  return timed;
6040
6082
  });
6041
6083
  this.client.interceptors.response.use(async (response, request, opts) => {
@@ -6073,7 +6115,7 @@ var NotteClient3 = class {
6073
6115
  method: request.method,
6074
6116
  headers: headerRecord,
6075
6117
  body: opts.serializedBody ?? void 0,
6076
- signal: request.signal,
6118
+ signal: requestSignal(request),
6077
6119
  redirect: "manual"
6078
6120
  });
6079
6121
  currentUrl = location;
@@ -6121,14 +6163,15 @@ var NotteClient3 = class {
6121
6163
  if (error instanceof NotteAPIError) {
6122
6164
  return error;
6123
6165
  }
6124
- if (request?.signal.aborted) {
6125
- error = request.signal.reason ?? error;
6166
+ const signal = request && requestSignal(request);
6167
+ if (signal?.aborted) {
6168
+ error = signal.reason ?? error;
6126
6169
  }
6127
6170
  if (isTimeoutAbort(error)) {
6128
6171
  const target = request ? ` to \`${requestPath(request)}\`` : "";
6129
6172
  return new NotteTimeoutError(`Request${target} ${error.message}`, { cause: error });
6130
6173
  }
6131
- if (request?.signal.aborted) return error;
6174
+ if (signal?.aborted) return error;
6132
6175
  if (response) {
6133
6176
  const path = requestPath(request, response);
6134
6177
  const body = normalizeErrorBody(error);
@@ -6178,6 +6221,10 @@ var NotteClient3 = class {
6178
6221
  Session(options = {}) {
6179
6222
  return new Session(this, options);
6180
6223
  }
6224
+ /** Generated file operations; use Files(sessionId) for local file IO helpers. */
6225
+ get files() {
6226
+ return this.resources.files;
6227
+ }
6181
6228
  /** Access files owned by a specific session, including closed sessions. */
6182
6229
  Files(sessionId) {
6183
6230
  return new SessionFiles(this.getClient(), sessionId);
@@ -6196,12 +6243,6 @@ var NotteClient3 = class {
6196
6243
  FileStorage(sessionId) {
6197
6244
  return new RemoteFileStorage(this, sessionId);
6198
6245
  }
6199
- /**
6200
- * Create a new agent
6201
- */
6202
- Agent(options) {
6203
- return new Agent(this, options);
6204
- }
6205
6246
  /**
6206
6247
  * Create or access a vault
6207
6248
  */
@@ -6234,16 +6275,6 @@ var NotteClient3 = class {
6234
6275
  }
6235
6276
  };
6236
6277
  }
6237
- /** Client-bound agent API operations. `list()` retains its array return value. */
6238
- get agents() {
6239
- return {
6240
- ...this.resources.agents,
6241
- list: async (options = {}) => {
6242
- const response = await listAgents({ client: this.getClient(), query: options });
6243
- return response.data?.items ?? [];
6244
- }
6245
- };
6246
- }
6247
6278
  /** Client-bound vault API operations. `list()` retains its array return value. */
6248
6279
  get vaults() {
6249
6280
  return {
@@ -6292,14 +6323,18 @@ var NotteClient3 = class {
6292
6323
  * Personas client for listing and managing personas
6293
6324
  */
6294
6325
  get personas() {
6326
+ const personas = this.resources.personas;
6295
6327
  return {
6296
- ...this.resources.personas,
6328
+ ...personas,
6329
+ create: async (...args) => withPersonaDefaults(await personas.create(...args)),
6330
+ get: async (...args) => withPersonaDefaults(await personas.get(...args)),
6331
+ update: async (...args) => withPersonaDefaults(await personas.update(...args)),
6297
6332
  list: async (options) => {
6298
6333
  const response = await listPersonas({
6299
6334
  client: this.getClient(),
6300
6335
  query: options || {}
6301
6336
  });
6302
- return response.data?.items || [];
6337
+ return (response.data?.items || []).map(withPersonaDefaults);
6303
6338
  }
6304
6339
  };
6305
6340
  }
@@ -6345,18 +6380,18 @@ function isTimeoutAbort(error) {
6345
6380
  function timeoutReason(timeoutMs) {
6346
6381
  return new DOMException(`timed out after ${timeoutMs}ms`, "TimeoutError");
6347
6382
  }
6348
- var pendingDeadlines = /* @__PURE__ */ new WeakMap();
6383
+ var pendingRequests = /* @__PURE__ */ new WeakMap();
6384
+ var originalTransports = /* @__PURE__ */ new WeakMap();
6385
+ function requestSignal(request) {
6386
+ return pendingRequests.get(request)?.signal ?? request.signal;
6387
+ }
6349
6388
  function releaseDeadline(request) {
6350
- if (!request) return;
6351
- const release = pendingDeadlines.get(request);
6352
- if (release) {
6353
- pendingDeadlines.delete(request);
6354
- release();
6355
- }
6389
+ if (request) pendingRequests.get(request)?.release();
6356
6390
  }
6357
6391
  function withTimeout(signal, timeoutMs) {
6358
6392
  const controller = new AbortController();
6359
6393
  const timer = setTimeout(() => controller.abort(timeoutReason(timeoutMs)), timeoutMs);
6394
+ const expiresAt = Date.now() + timeoutMs;
6360
6395
  timer.unref?.();
6361
6396
  let detach = () => void 0;
6362
6397
  let composite;
@@ -6383,7 +6418,7 @@ function withTimeout(signal, timeoutMs) {
6383
6418
  detach();
6384
6419
  };
6385
6420
  composite.addEventListener("abort", release, { once: true });
6386
- return { signal: composite, release };
6421
+ return { signal: composite, release, expiresAt };
6387
6422
  }
6388
6423
 
6389
6424
  // src/actions.ts
@@ -6477,11 +6512,11 @@ var createClient2 = (config) => {
6477
6512
  // Annotate the CommonJS export names for ESM import in node:
6478
6513
  0 && (module.exports = {
6479
6514
  ActionExecutionError,
6480
- Agent,
6481
6515
  AuthenticationError,
6482
6516
  CAPTCHA_SOLVE_TIMEOUT_MS,
6483
6517
  CLUSTER_OVERLOAD_RETRY_DELAY_MS,
6484
6518
  CREDENTIAL_FIELDS,
6519
+ DEFAULT_MAX_RETRIES,
6485
6520
  DEFAULT_NOTTE_API_URL,
6486
6521
  DEFAULT_REQUEST_TIMEOUT_MS,
6487
6522
  Encryption,
@@ -6516,12 +6551,17 @@ var createClient2 = (config) => {
6516
6551
  Session,
6517
6552
  SessionFiles,
6518
6553
  TIMEOUT_HEADER,
6554
+ accountChanges,
6555
+ accountRuns,
6519
6556
  actions,
6520
6557
  agentStart,
6521
6558
  agentStatus,
6522
6559
  agentStop,
6523
6560
  anythingStart,
6561
+ attempts,
6562
+ brandRetrieve,
6524
6563
  buildFetchScript,
6564
+ changes,
6525
6565
  checkForLatestVersion,
6526
6566
  client,
6527
6567
  connectLinkContext,
@@ -6531,14 +6571,22 @@ var createClient2 = (config) => {
6531
6571
  connectLinkStatus,
6532
6572
  connectLinkSubmit,
6533
6573
  connectPaymentWallet,
6574
+ create,
6534
6575
  createClient,
6535
6576
  createOrAppendCookiesToFile,
6536
6577
  createPayment,
6578
+ creditUsage,
6537
6579
  deleteSecret,
6538
6580
  deleteSessionFile,
6581
+ delete_,
6582
+ deliveries,
6583
+ detail,
6539
6584
  disconnectPaymentWallet,
6540
6585
  downloadRunPayload,
6541
6586
  downloadSessionFile,
6587
+ executeSessionFile,
6588
+ extractProductEndpoint,
6589
+ fetchSpecializedData,
6542
6590
  functionCreate,
6543
6591
  functionDelete,
6544
6592
  functionDownloadUrl,
@@ -6554,6 +6602,7 @@ var createClient2 = (config) => {
6554
6602
  functionScheduleSet,
6555
6603
  functionUpdate,
6556
6604
  getPayment,
6605
+ getPolicy,
6557
6606
  getRootDomain,
6558
6607
  getScript,
6559
6608
  getSecret,
@@ -6561,13 +6610,18 @@ var createClient2 = (config) => {
6561
6610
  getUsage,
6562
6611
  getUsageLogs,
6563
6612
  healthCheck,
6613
+ history_,
6564
6614
  installServerOwnedDialogPolicy,
6615
+ invalidate,
6565
6616
  isCaptchaSolveAction,
6566
6617
  isValidMfaSecret,
6618
+ limits,
6567
6619
  listAgents,
6568
6620
  listAuditEvents,
6621
+ listDataApis,
6569
6622
  listFunctionRunsByFunctionId,
6570
6623
  listFunctions,
6624
+ listMonitors,
6571
6625
  listPersonas,
6572
6626
  listSecrets,
6573
6627
  listSessionFiles,
@@ -6580,19 +6634,20 @@ var createClient2 = (config) => {
6580
6634
  mailboxSync,
6581
6635
  mailboxUpdate,
6582
6636
  managedAuthConnectLinkCreate,
6637
+ mapsSearch,
6638
+ newsSearch,
6583
6639
  observeServerOwnedDialog,
6584
6640
  pageExecute,
6585
6641
  pageObserve,
6586
6642
  pageScrape,
6587
6643
  pageScreenshot,
6588
- parseAgentStatusMessage,
6644
+ peopleEnrich,
6589
6645
  personaCreate,
6590
6646
  personaDelete,
6591
6647
  personaEmailsList,
6592
6648
  personaGet,
6593
6649
  personaSmsList,
6594
6650
  personaUpdate,
6595
- prepareAgentRequest,
6596
6651
  prepareRunPayloadUpload,
6597
6652
  processScrapeResponse,
6598
6653
  profileCookiesGet,
@@ -6602,18 +6657,29 @@ var createClient2 = (config) => {
6602
6657
  profileDuplicate,
6603
6658
  profileGet,
6604
6659
  profileList,
6660
+ profileStateSet,
6605
6661
  readCookiesFile,
6606
6662
  readyCheck,
6607
6663
  responseFromEvaluated,
6664
+ retrieve,
6665
+ retrieveChange,
6666
+ retrieveDelivery,
6667
+ retrieveRun,
6608
6668
  retry,
6669
+ retryWebhookDelivery,
6670
+ rotateSecret,
6671
+ runNow,
6672
+ runs,
6609
6673
  sanitizeFilename,
6610
6674
  scrapeFromHtml,
6675
+ scrapeSpecializedData,
6611
6676
  scrapeWebpage,
6612
6677
  searchWeb,
6613
6678
  sessionAuthReadiness,
6614
6679
  sessionCookiesGet,
6615
6680
  sessionCookiesSet,
6616
6681
  sessionDebugInfo,
6682
+ sessionMouseReplay,
6617
6683
  sessionNetworkLogs,
6618
6684
  sessionOffset,
6619
6685
  sessionProfilePreview,
@@ -6624,6 +6690,9 @@ var createClient2 = (config) => {
6624
6690
  sessionStop,
6625
6691
  startVersionCheck,
6626
6692
  storeSecret,
6693
+ styleguideEndpoint,
6694
+ summary,
6695
+ update,
6627
6696
  uploadSessionFile,
6628
6697
  validateCredentials,
6629
6698
  validateMfaSecret,
@@ -6637,6 +6706,7 @@ var createClient2 = (config) => {
6637
6706
  vaultCreditCardGet,
6638
6707
  vaultCreditCardSet,
6639
6708
  vaultDelete,
6640
- vaultUpdate
6709
+ vaultUpdate,
6710
+ youtubeEndpoint
6641
6711
  });
6642
6712
  //# sourceMappingURL=index.js.map