notte-sdk 1.10.13 → 1.10.14

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
@@ -224,6 +224,7 @@ __export(index_exports, {
224
224
  sessionResume: () => sessionResume,
225
225
  sessionStart: () => sessionStart,
226
226
  sessionStatus: () => sessionStatus,
227
+ sessionSteps: () => sessionSteps,
227
228
  sessionStop: () => sessionStop,
228
229
  startVersionCheck: () => startVersionCheck,
229
230
  storeSecret: () => storeSecret,
@@ -249,7 +250,7 @@ __export(index_exports, {
249
250
  module.exports = __toCommonJS(index_exports);
250
251
 
251
252
  // src/version.ts
252
- var SDK_VERSION = true ? "1.10.13" : "dev";
253
+ var SDK_VERSION = true ? "1.10.14" : "dev";
253
254
  var SDK_PACKAGE_NAME = true ? "notte-sdk" : "notte-sdk";
254
255
 
255
256
  // src/version-check.ts
@@ -1211,6 +1212,11 @@ var sessionStatus = (options) => (options.client ?? client).get({
1211
1212
  url: "/sessions/{session_id}",
1212
1213
  ...options
1213
1214
  });
1215
+ var sessionSteps = (options) => (options.client ?? client).get({
1216
+ security: [{ scheme: "bearer", type: "http" }],
1217
+ url: "/sessions/{session_id}/steps",
1218
+ ...options
1219
+ });
1214
1220
  var sessionProfilePreview = (options) => (options.client ?? client).get({
1215
1221
  security: [{ scheme: "bearer", type: "http" }],
1216
1222
  url: "/sessions/{session_id}/profile-preview",
@@ -1716,49 +1722,6 @@ var profileList = (options) => (options?.client ?? client).get({
1716
1722
  url: "/profiles",
1717
1723
  ...options
1718
1724
  });
1719
- var personaCreate = (options) => (options.client ?? client).post({
1720
- security: [{ scheme: "bearer", type: "http" }],
1721
- url: "/personas/create",
1722
- ...options,
1723
- headers: {
1724
- "Content-Type": "application/json",
1725
- ...options.headers
1726
- }
1727
- });
1728
- var personaDelete = (options) => (options.client ?? client).delete({
1729
- security: [{ scheme: "bearer", type: "http" }],
1730
- url: "/personas/{persona_id}",
1731
- ...options
1732
- });
1733
- var personaGet = (options) => (options.client ?? client).get({
1734
- security: [{ scheme: "bearer", type: "http" }],
1735
- url: "/personas/{persona_id}",
1736
- ...options
1737
- });
1738
- var personaUpdate = (options) => (options.client ?? client).patch({
1739
- security: [{ scheme: "bearer", type: "http" }],
1740
- url: "/personas/{persona_id}",
1741
- ...options,
1742
- headers: {
1743
- "Content-Type": "application/json",
1744
- ...options.headers
1745
- }
1746
- });
1747
- var personaEmailsList = (options) => (options.client ?? client).get({
1748
- security: [{ scheme: "bearer", type: "http" }],
1749
- url: "/personas/{persona_id}/emails",
1750
- ...options
1751
- });
1752
- var listPersonas = (options) => (options?.client ?? client).get({
1753
- security: [{ scheme: "bearer", type: "http" }],
1754
- url: "/personas",
1755
- ...options
1756
- });
1757
- var personaSmsList = (options) => (options.client ?? client).get({
1758
- security: [{ scheme: "bearer", type: "http" }],
1759
- url: "/personas/{persona_id}/sms",
1760
- ...options
1761
- });
1762
1725
  var mailboxConnectToken = (options) => (options.client ?? client).post({
1763
1726
  security: [{ scheme: "bearer", type: "http" }],
1764
1727
  url: "/mailboxes/connect-token",
@@ -1870,11 +1833,6 @@ var deleteSecret = (options) => (options.client ?? client).delete({
1870
1833
  url: "/secrets/{secret_id}",
1871
1834
  ...options
1872
1835
  });
1873
- var listSecretProxyHostPresets = (options) => (options?.client ?? client).get({
1874
- security: [{ scheme: "bearer", type: "http" }],
1875
- url: "/secret-proxy/host-presets",
1876
- ...options
1877
- });
1878
1836
  var healthCheck = (options) => (options?.client ?? client).get({ url: "/health", ...options });
1879
1837
  var readyCheck = (options) => (options?.client ?? client).get({ url: "/ready", ...options });
1880
1838
  var scrapeWebpage = (options) => (options.client ?? client).post({
@@ -2118,6 +2076,54 @@ var listAuditEvents = (options) => (options?.client ?? client).get({
2118
2076
  url: "/audit-events",
2119
2077
  ...options
2120
2078
  });
2079
+ var listPersonas = (options) => (options?.client ?? client).get({
2080
+ security: [{ scheme: "bearer", type: "http" }],
2081
+ url: "/personas",
2082
+ ...options
2083
+ });
2084
+ var personaCreate = (options) => (options.client ?? client).post({
2085
+ security: [{ scheme: "bearer", type: "http" }],
2086
+ url: "/personas/create",
2087
+ ...options,
2088
+ headers: {
2089
+ "Content-Type": "application/json",
2090
+ ...options.headers
2091
+ }
2092
+ });
2093
+ var personaDelete = (options) => (options.client ?? client).delete({
2094
+ security: [{ scheme: "bearer", type: "http" }],
2095
+ url: "/personas/{persona_id}",
2096
+ ...options
2097
+ });
2098
+ var personaGet = (options) => (options.client ?? client).get({
2099
+ security: [{ scheme: "bearer", type: "http" }],
2100
+ url: "/personas/{persona_id}",
2101
+ ...options
2102
+ });
2103
+ var personaUpdate = (options) => (options.client ?? client).patch({
2104
+ security: [{ scheme: "bearer", type: "http" }],
2105
+ url: "/personas/{persona_id}",
2106
+ ...options,
2107
+ headers: {
2108
+ "Content-Type": "application/json",
2109
+ ...options.headers
2110
+ }
2111
+ });
2112
+ var personaEmailsList = (options) => (options.client ?? client).get({
2113
+ security: [{ scheme: "bearer", type: "http" }],
2114
+ url: "/personas/{persona_id}/emails",
2115
+ ...options
2116
+ });
2117
+ var personaSmsList = (options) => (options.client ?? client).get({
2118
+ security: [{ scheme: "bearer", type: "http" }],
2119
+ url: "/personas/{persona_id}/sms",
2120
+ ...options
2121
+ });
2122
+ var listSecretProxyHostPresets = (options) => (options?.client ?? client).get({
2123
+ security: [{ scheme: "bearer", type: "http" }],
2124
+ url: "/secret-proxy/host-presets",
2125
+ ...options
2126
+ });
2121
2127
  var getUsage = (options) => (options?.client ?? client).get({
2122
2128
  security: [{ scheme: "bearer", type: "http" }],
2123
2129
  url: "/usage",
@@ -2697,6 +2703,7 @@ function createResources(client2, getApiKey) {
2697
2703
  },
2698
2704
  /** functionRunStart: /functions/{function_id}/runs/start. Returns the API response body. */
2699
2705
  runStart: async (functionId, body, requestOptions = {}) => {
2706
+ if (typeof functionId !== "string" || !functionId.trim()) throw new TypeError("runStart requires a non-empty functionId.");
2700
2707
  const response = await functionRunStart({ client: client2, throwOnError: true, signal: requestOptions.signal, headers: { ...requestOptions.headers, "x-notte-api-key": getApiKey() }, path: { "function_id": functionId }, body });
2701
2708
  return response.data;
2702
2709
  },
@@ -3546,6 +3553,25 @@ function abortableSleep(ms, signal) {
3546
3553
  });
3547
3554
  }
3548
3555
 
3556
+ // src/session-steps.ts
3557
+ async function getSessionSteps(client2, sessionId, options = {}) {
3558
+ const response = await client2.getClient().get({
3559
+ url: `/sessions/${encodeURIComponent(sessionId)}/steps`,
3560
+ query: { cursor: options.cursor, limit: options.limit },
3561
+ throwOnError: true
3562
+ });
3563
+ return { steps: response.data.steps ?? [], next_cursor: response.data.next_cursor ?? null };
3564
+ }
3565
+ async function* iterSessionSteps(client2, sessionId, options = {}) {
3566
+ let cursor;
3567
+ while (true) {
3568
+ const page = await getSessionSteps(client2, sessionId, { cursor, limit: options.limit });
3569
+ yield* page.steps;
3570
+ if (page.next_cursor === null) return;
3571
+ cursor = page.next_cursor;
3572
+ }
3573
+ }
3574
+
3549
3575
  // src/session.ts
3550
3576
  var SESSION_START_TRIES = 3;
3551
3577
  var CLUSTER_OVERLOAD_RETRY_DELAY_MS = 3e4;
@@ -4056,6 +4082,36 @@ var Session = class {
4056
4082
  });
4057
4083
  return response.data;
4058
4084
  }
4085
+ /**
4086
+ * Get one page of the session's steps. Each step has the shape of an item of
4087
+ * `status().steps`. Pass the page's `next_cursor` back as `cursor`, as is, to
4088
+ * get the next page; it is `null` on the last page. Works after `stop()`.
4089
+ *
4090
+ * @throws NotteAPIError with status 400 when `cursor` is no longer valid: restart from the first page (no `cursor`).
4091
+ * @example
4092
+ * let page = await session.steps({ limit: 50 });
4093
+ * while (page.next_cursor !== null) {
4094
+ * page = await session.steps({ cursor: page.next_cursor, limit: 50 });
4095
+ * }
4096
+ */
4097
+ async steps(options = {}) {
4098
+ return getSessionSteps(this.client, this.lastSessionId(), options);
4099
+ }
4100
+ /**
4101
+ * Iterate over all of the session's steps, following `next_cursor` page by page.
4102
+ * A cursor that is no longer valid stops the iteration with a `NotteAPIError`
4103
+ * with status 400, after the steps already yielded; it is not restarted here,
4104
+ * since that would yield those steps again. To read the steps again, start a
4105
+ * new iteration. Works after `stop()`.
4106
+ *
4107
+ * @example
4108
+ * for await (const step of session.iterSteps({ limit: 50 })) {
4109
+ * console.log(step);
4110
+ * }
4111
+ */
4112
+ async *iterSteps(options = {}) {
4113
+ yield* iterSessionSteps(this.client, this.lastSessionId(), options);
4114
+ }
4059
4115
  // #######################################################################
4060
4116
  // ############################# Debug / CDP #############################
4061
4117
  // #######################################################################
@@ -6523,7 +6579,27 @@ var NotteClient3 = class {
6523
6579
  list: async (options = {}) => {
6524
6580
  const response = await listSessions({ client: this.getClient(), query: options });
6525
6581
  return response.data?.items ?? [];
6526
- }
6582
+ },
6583
+ /**
6584
+ * One page of the session's steps (`{ steps, next_cursor }`), from
6585
+ * `GET /sessions/{session_id}/steps`. Each step has the shape of an item of
6586
+ * `status().steps`. Pass `next_cursor` back as `cursor`, as is, for the next
6587
+ * page; it is `null` on the last page. A `NotteAPIError` with status 400 means
6588
+ * the cursor is no longer valid: restart from the first page (no `cursor`).
6589
+ */
6590
+ steps: (sessionId, options = {}) => getSessionSteps(this, sessionId, options),
6591
+ /**
6592
+ * Every step of the session, following `next_cursor` page by page. A cursor
6593
+ * that is no longer valid stops the iteration with the 400 `NotteAPIError`,
6594
+ * after the steps already yielded; start a new iteration to read them again.
6595
+ *
6596
+ * ```ts
6597
+ * for await (const step of client.sessions.iterSteps(sessionId, { limit: 50 })) {
6598
+ * console.log(step);
6599
+ * }
6600
+ * ```
6601
+ */
6602
+ iterSteps: (sessionId, options = {}) => iterSessionSteps(this, sessionId, options)
6527
6603
  };
6528
6604
  }
6529
6605
  /** Client-bound vault API operations. `list()` retains its array return value. */
@@ -6955,6 +7031,7 @@ var createClient2 = (config) => {
6955
7031
  sessionResume,
6956
7032
  sessionStart,
6957
7033
  sessionStatus,
7034
+ sessionSteps,
6958
7035
  sessionStop,
6959
7036
  startVersionCheck,
6960
7037
  storeSecret,