notte-sdk 1.10.20 → 1.10.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -3525,6 +3525,12 @@ type FunctionListItemResponse = {
3525
3525
  * The site this function drives, used to group endpoints in the console. Null when the function never named a site.
3526
3526
  */
3527
3527
  domain?: string | null;
3528
+ /**
3529
+ * Slug
3530
+ *
3531
+ * The function's short name, unique across all functions: it runs at https://functions.notte.cc/<slug>. Assigned at creation and renamable. Null for a function that has none.
3532
+ */
3533
+ slug?: string | null;
3528
3534
  /**
3529
3535
  * Workflow Id
3530
3536
  *
@@ -3580,6 +3586,12 @@ type FunctionMetadataUpdateRequest = {
3580
3586
  * Turn deletion protection on or off. While it is on, the function cannot be deleted. Any workspace member's key can turn it on; turning it off takes the key of a workspace admin or owner. Omit or send null to leave it unchanged.
3581
3587
  */
3582
3588
  deletion_protected?: boolean | null;
3589
+ /**
3590
+ * Slug
3591
+ *
3592
+ * Rename the function's short name in https://functions.notte.cc/<slug>: 3 to 48 lowercase letters, digits and inner hyphens, unique across all functions (409 when another function has it). Omit or send null to leave it unchanged.
3593
+ */
3594
+ slug?: string | null;
3583
3595
  /**
3584
3596
  * Response Format
3585
3597
  *
@@ -3717,6 +3729,12 @@ type FunctionResponse = {
3717
3729
  * The site this function drives, used to group endpoints in the console. Null when the function never named a site.
3718
3730
  */
3719
3731
  domain?: string | null;
3732
+ /**
3733
+ * Slug
3734
+ *
3735
+ * The function's short name, unique across all functions: it runs at https://functions.notte.cc/<slug>. Assigned at creation and renamable. Null for a function that has none.
3736
+ */
3737
+ slug?: string | null;
3720
3738
  /**
3721
3739
  * Instructions
3722
3740
  *
@@ -4247,6 +4265,12 @@ type FunctionWithLinkResponse = {
4247
4265
  * The site this function drives, used to group endpoints in the console. Null when the function never named a site.
4248
4266
  */
4249
4267
  domain?: string | null;
4268
+ /**
4269
+ * Slug
4270
+ *
4271
+ * The function's short name, unique across all functions: it runs at https://functions.notte.cc/<slug>. Assigned at creation and renamable. Null for a function that has none.
4272
+ */
4273
+ slug?: string | null;
4250
4274
  /**
4251
4275
  * Instructions
4252
4276
  *
@@ -10900,6 +10924,12 @@ type FunctionListItemResponseWritable = {
10900
10924
  * The site this function drives, used to group endpoints in the console. Null when the function never named a site.
10901
10925
  */
10902
10926
  domain?: string | null;
10927
+ /**
10928
+ * Slug
10929
+ *
10930
+ * The function's short name, unique across all functions: it runs at https://functions.notte.cc/<slug>. Assigned at creation and renamable. Null for a function that has none.
10931
+ */
10932
+ slug?: string | null;
10903
10933
  };
10904
10934
  /**
10905
10935
  * FunctionResponse
@@ -11023,6 +11053,12 @@ type FunctionResponseWritable = {
11023
11053
  * The site this function drives, used to group endpoints in the console. Null when the function never named a site.
11024
11054
  */
11025
11055
  domain?: string | null;
11056
+ /**
11057
+ * Slug
11058
+ *
11059
+ * The function's short name, unique across all functions: it runs at https://functions.notte.cc/<slug>. Assigned at creation and renamable. Null for a function that has none.
11060
+ */
11061
+ slug?: string | null;
11026
11062
  /**
11027
11063
  * Instructions
11028
11064
  *
@@ -11223,6 +11259,12 @@ type FunctionWithLinkResponseWritable = {
11223
11259
  * The site this function drives, used to group endpoints in the console. Null when the function never named a site.
11224
11260
  */
11225
11261
  domain?: string | null;
11262
+ /**
11263
+ * Slug
11264
+ *
11265
+ * The function's short name, unique across all functions: it runs at https://functions.notte.cc/<slug>. Assigned at creation and renamable. Null for a function that has none.
11266
+ */
11267
+ slug?: string | null;
11226
11268
  /**
11227
11269
  * Instructions
11228
11270
  *
@@ -20354,7 +20396,9 @@ declare class Session {
20354
20396
  * (`NotteClientConfig.maxRetries`, honoring `Retry-After`). Other 5xx
20355
20397
  * errors are retried up to `SESSION_START_TRIES` times. With client
20356
20398
  * retries disabled, 529 waits `CLUSTER_OVERLOAD_RETRY_DELAY_MS` instead.
20357
- * 4xx errors are never retried.
20399
+ * 4xx errors are never retried, nor is a 529 marked
20400
+ * `X-Error-Class: WorkerRequestTimeout`: an API worker did not answer in
20401
+ * time and may already have created the session.
20358
20402
  *
20359
20403
  * Managed-auth sessions wait for readiness by default. Pass
20360
20404
  * `{ wait_for_authentication: false }` for an explicit nonblocking start,
@@ -21554,7 +21598,9 @@ interface NotteClientConfig {
21554
21598
  * errors), with exponential backoff and full jitter. `Retry-After` is
21555
21599
  * honored. POST and PATCH requests are only retried when the API cannot
21556
21600
  * have processed them (503, 529, connection refused), so they are never
21557
- * applied twice. All attempts share the request timeout. Defaults to 3;
21601
+ * applied twice. A 529 marked `X-Error-Class: WorkerRequestTimeout` (an API
21602
+ * worker did not answer in time) is treated like a 504. All attempts share
21603
+ * the request timeout. Defaults to 3;
21558
21604
  * `0` disables retries.
21559
21605
  */
21560
21606
  maxRetries?: number;
@@ -21987,7 +22033,10 @@ declare class Encryption {
21987
22033
  *
21988
22034
  * What is retried:
21989
22035
  * - 503 and 529: the API declined the request before doing any work, so every
21990
- * method is retried.
22036
+ * method is retried. The exception is the gateway's 529 marked
22037
+ * `X-Error-Class: WorkerRequestTimeout`: an API worker did not answer in
22038
+ * time and may already have processed the request, so it is treated like a
22039
+ * 504.
21991
22040
  * - 502 and 504: a gateway lost or timed out on the upstream response, which
21992
22041
  * may already have been processed. Only idempotent methods (GET, HEAD,
21993
22042
  * OPTIONS, PUT, DELETE) are retried, so a POST such as starting a session
package/dist/index.d.ts CHANGED
@@ -3525,6 +3525,12 @@ type FunctionListItemResponse = {
3525
3525
  * The site this function drives, used to group endpoints in the console. Null when the function never named a site.
3526
3526
  */
3527
3527
  domain?: string | null;
3528
+ /**
3529
+ * Slug
3530
+ *
3531
+ * The function's short name, unique across all functions: it runs at https://functions.notte.cc/<slug>. Assigned at creation and renamable. Null for a function that has none.
3532
+ */
3533
+ slug?: string | null;
3528
3534
  /**
3529
3535
  * Workflow Id
3530
3536
  *
@@ -3580,6 +3586,12 @@ type FunctionMetadataUpdateRequest = {
3580
3586
  * Turn deletion protection on or off. While it is on, the function cannot be deleted. Any workspace member's key can turn it on; turning it off takes the key of a workspace admin or owner. Omit or send null to leave it unchanged.
3581
3587
  */
3582
3588
  deletion_protected?: boolean | null;
3589
+ /**
3590
+ * Slug
3591
+ *
3592
+ * Rename the function's short name in https://functions.notte.cc/<slug>: 3 to 48 lowercase letters, digits and inner hyphens, unique across all functions (409 when another function has it). Omit or send null to leave it unchanged.
3593
+ */
3594
+ slug?: string | null;
3583
3595
  /**
3584
3596
  * Response Format
3585
3597
  *
@@ -3717,6 +3729,12 @@ type FunctionResponse = {
3717
3729
  * The site this function drives, used to group endpoints in the console. Null when the function never named a site.
3718
3730
  */
3719
3731
  domain?: string | null;
3732
+ /**
3733
+ * Slug
3734
+ *
3735
+ * The function's short name, unique across all functions: it runs at https://functions.notte.cc/<slug>. Assigned at creation and renamable. Null for a function that has none.
3736
+ */
3737
+ slug?: string | null;
3720
3738
  /**
3721
3739
  * Instructions
3722
3740
  *
@@ -4247,6 +4265,12 @@ type FunctionWithLinkResponse = {
4247
4265
  * The site this function drives, used to group endpoints in the console. Null when the function never named a site.
4248
4266
  */
4249
4267
  domain?: string | null;
4268
+ /**
4269
+ * Slug
4270
+ *
4271
+ * The function's short name, unique across all functions: it runs at https://functions.notte.cc/<slug>. Assigned at creation and renamable. Null for a function that has none.
4272
+ */
4273
+ slug?: string | null;
4250
4274
  /**
4251
4275
  * Instructions
4252
4276
  *
@@ -10900,6 +10924,12 @@ type FunctionListItemResponseWritable = {
10900
10924
  * The site this function drives, used to group endpoints in the console. Null when the function never named a site.
10901
10925
  */
10902
10926
  domain?: string | null;
10927
+ /**
10928
+ * Slug
10929
+ *
10930
+ * The function's short name, unique across all functions: it runs at https://functions.notte.cc/<slug>. Assigned at creation and renamable. Null for a function that has none.
10931
+ */
10932
+ slug?: string | null;
10903
10933
  };
10904
10934
  /**
10905
10935
  * FunctionResponse
@@ -11023,6 +11053,12 @@ type FunctionResponseWritable = {
11023
11053
  * The site this function drives, used to group endpoints in the console. Null when the function never named a site.
11024
11054
  */
11025
11055
  domain?: string | null;
11056
+ /**
11057
+ * Slug
11058
+ *
11059
+ * The function's short name, unique across all functions: it runs at https://functions.notte.cc/<slug>. Assigned at creation and renamable. Null for a function that has none.
11060
+ */
11061
+ slug?: string | null;
11026
11062
  /**
11027
11063
  * Instructions
11028
11064
  *
@@ -11223,6 +11259,12 @@ type FunctionWithLinkResponseWritable = {
11223
11259
  * The site this function drives, used to group endpoints in the console. Null when the function never named a site.
11224
11260
  */
11225
11261
  domain?: string | null;
11262
+ /**
11263
+ * Slug
11264
+ *
11265
+ * The function's short name, unique across all functions: it runs at https://functions.notte.cc/<slug>. Assigned at creation and renamable. Null for a function that has none.
11266
+ */
11267
+ slug?: string | null;
11226
11268
  /**
11227
11269
  * Instructions
11228
11270
  *
@@ -20354,7 +20396,9 @@ declare class Session {
20354
20396
  * (`NotteClientConfig.maxRetries`, honoring `Retry-After`). Other 5xx
20355
20397
  * errors are retried up to `SESSION_START_TRIES` times. With client
20356
20398
  * retries disabled, 529 waits `CLUSTER_OVERLOAD_RETRY_DELAY_MS` instead.
20357
- * 4xx errors are never retried.
20399
+ * 4xx errors are never retried, nor is a 529 marked
20400
+ * `X-Error-Class: WorkerRequestTimeout`: an API worker did not answer in
20401
+ * time and may already have created the session.
20358
20402
  *
20359
20403
  * Managed-auth sessions wait for readiness by default. Pass
20360
20404
  * `{ wait_for_authentication: false }` for an explicit nonblocking start,
@@ -21554,7 +21598,9 @@ interface NotteClientConfig {
21554
21598
  * errors), with exponential backoff and full jitter. `Retry-After` is
21555
21599
  * honored. POST and PATCH requests are only retried when the API cannot
21556
21600
  * have processed them (503, 529, connection refused), so they are never
21557
- * applied twice. All attempts share the request timeout. Defaults to 3;
21601
+ * applied twice. A 529 marked `X-Error-Class: WorkerRequestTimeout` (an API
21602
+ * worker did not answer in time) is treated like a 504. All attempts share
21603
+ * the request timeout. Defaults to 3;
21558
21604
  * `0` disables retries.
21559
21605
  */
21560
21606
  maxRetries?: number;
@@ -21987,7 +22033,10 @@ declare class Encryption {
21987
22033
  *
21988
22034
  * What is retried:
21989
22035
  * - 503 and 529: the API declined the request before doing any work, so every
21990
- * method is retried.
22036
+ * method is retried. The exception is the gateway's 529 marked
22037
+ * `X-Error-Class: WorkerRequestTimeout`: an API worker did not answer in
22038
+ * time and may already have processed the request, so it is treated like a
22039
+ * 504.
21991
22040
  * - 502 and 504: a gateway lost or timed out on the upstream response, which
21992
22041
  * may already have been processed. Only idempotent methods (GET, HEAD,
21993
22042
  * OPTIONS, PUT, DELETE) are retried, so a POST such as starting a session
package/dist/index.js CHANGED
@@ -252,7 +252,7 @@ __export(index_exports, {
252
252
  module.exports = __toCommonJS(index_exports);
253
253
 
254
254
  // src/version.ts
255
- var SDK_VERSION = true ? "1.10.20" : "dev";
255
+ var SDK_VERSION = true ? "1.10.21" : "dev";
256
256
  var SDK_PACKAGE_NAME = true ? "notte-sdk" : "notte-sdk";
257
257
 
258
258
  // src/version-check.ts
@@ -3512,6 +3512,7 @@ var RETRY_AFTER_MAX_MS = 2e4;
3512
3512
  var IDEMPOTENT_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS", "PUT", "DELETE"]);
3513
3513
  var REFUSED_STATUSES = /* @__PURE__ */ new Set([503, 529]);
3514
3514
  var GATEWAY_STATUSES = /* @__PURE__ */ new Set([502, 504]);
3515
+ var WORKER_TIMEOUT_ERROR_CLASS = "WorkerRequestTimeout";
3515
3516
  var NOT_SENT_ERROR_CODES = /* @__PURE__ */ new Set([
3516
3517
  "ECONNREFUSED",
3517
3518
  "EAI_AGAIN",
@@ -3529,7 +3530,8 @@ var BROKEN_CONNECTION_ERROR_CODES = /* @__PURE__ */ new Set([
3529
3530
  function isIdempotentMethod(method) {
3530
3531
  return IDEMPOTENT_METHODS.has(method.toUpperCase());
3531
3532
  }
3532
- function isRetryableStatus(status, method) {
3533
+ function isRetryableStatus(status, method, errorClass) {
3534
+ if (status === 529 && errorClass === WORKER_TIMEOUT_ERROR_CLASS) return isIdempotentMethod(method);
3533
3535
  return REFUSED_STATUSES.has(status) || GATEWAY_STATUSES.has(status) && isIdempotentMethod(method);
3534
3536
  }
3535
3537
  function isRetryableNetworkError(error, method) {
@@ -3581,7 +3583,7 @@ function createRetryingFetch(options) {
3581
3583
  await wait2(delay4, signal);
3582
3584
  continue;
3583
3585
  }
3584
- if (last || !isRetryableStatus(response.status, method)) return response;
3586
+ if (last || !isRetryableStatus(response.status, method, response.headers.get("x-error-class"))) return response;
3585
3587
  const delay3 = retryDelayMs(attempt, response.headers.get("retry-after"), options.random);
3586
3588
  if (delay3 === void 0 || !fitsDeadline(delay3)) return response;
3587
3589
  await response.body?.cancel().catch(() => void 0);
@@ -3761,7 +3763,9 @@ var Session = class {
3761
3763
  * (`NotteClientConfig.maxRetries`, honoring `Retry-After`). Other 5xx
3762
3764
  * errors are retried up to `SESSION_START_TRIES` times. With client
3763
3765
  * retries disabled, 529 waits `CLUSTER_OVERLOAD_RETRY_DELAY_MS` instead.
3764
- * 4xx errors are never retried.
3766
+ * 4xx errors are never retried, nor is a 529 marked
3767
+ * `X-Error-Class: WorkerRequestTimeout`: an API worker did not answer in
3768
+ * time and may already have created the session.
3765
3769
  *
3766
3770
  * Managed-auth sessions wait for readiness by default. Pass
3767
3771
  * `{ wait_for_authentication: false }` for an explicit nonblocking start,
@@ -3816,7 +3820,11 @@ var Session = class {
3816
3820
  sessionData = response.data;
3817
3821
  break;
3818
3822
  } catch (error) {
3819
- const transient = error instanceof NotteAPIError ? isRetryableStatus(error.statusCode, "POST") : isRetryableNetworkError(error, "POST");
3823
+ const errorClass = error instanceof NotteAPIError ? error.response?.headers.get("x-error-class") : void 0;
3824
+ if (error instanceof NotteAPIError && error.statusCode === 529 && errorClass === WORKER_TIMEOUT_ERROR_CLASS) {
3825
+ throw error;
3826
+ }
3827
+ const transient = error instanceof NotteAPIError ? isRetryableStatus(error.statusCode, "POST", errorClass) : isRetryableNetworkError(error, "POST");
3820
3828
  if (maxRetries > 0 && transient) {
3821
3829
  const wait2 = transientRetries >= maxRetries ? void 0 : error instanceof NotteAPIError ? retryDelayMs(transientRetries, error.response?.headers.get("retry-after")) : backoffDelayMs(transientRetries);
3822
3830
  if (wait2 === void 0 || !fitsDeadline(wait2)) throw error;