@pipelex/sdk 0.32.0 → 0.34.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.
Files changed (87) hide show
  1. package/README.md +40 -5
  2. package/dist/artifacts.js +23 -9
  3. package/dist/artifacts.js.map +1 -1
  4. package/dist/cli/args.d.ts +41 -0
  5. package/dist/cli/args.js +96 -0
  6. package/dist/cli/args.js.map +1 -0
  7. package/dist/cli/bundle.d.ts +45 -0
  8. package/dist/cli/bundle.js +148 -0
  9. package/dist/cli/bundle.js.map +1 -0
  10. package/dist/cli/environment.d.ts +36 -0
  11. package/dist/cli/environment.js +72 -0
  12. package/dist/cli/environment.js.map +1 -0
  13. package/dist/cli/help.d.ts +4 -0
  14. package/dist/cli/help.js +56 -0
  15. package/dist/cli/help.js.map +1 -0
  16. package/dist/cli/inputs.d.ts +13 -0
  17. package/dist/cli/inputs.js +70 -0
  18. package/dist/cli/inputs.js.map +1 -0
  19. package/dist/cli/io.d.ts +79 -0
  20. package/dist/cli/io.js +96 -0
  21. package/dist/cli/io.js.map +1 -0
  22. package/dist/cli/main.d.ts +18 -0
  23. package/dist/cli/main.js +58 -0
  24. package/dist/cli/main.js.map +1 -0
  25. package/dist/cli/method.d.ts +56 -0
  26. package/dist/cli/method.js +108 -0
  27. package/dist/cli/method.js.map +1 -0
  28. package/dist/cli/present.d.ts +43 -0
  29. package/dist/cli/present.js +191 -0
  30. package/dist/cli/present.js.map +1 -0
  31. package/dist/cli/run.d.ts +17 -0
  32. package/dist/cli/run.js +290 -0
  33. package/dist/cli/run.js.map +1 -0
  34. package/dist/cli/script.d.ts +23 -0
  35. package/dist/cli/script.js +212 -0
  36. package/dist/cli/script.js.map +1 -0
  37. package/dist/cli/source.d.ts +49 -0
  38. package/dist/cli/source.js +71 -0
  39. package/dist/cli/source.js.map +1 -0
  40. package/dist/cli.d.ts +10 -0
  41. package/dist/cli.js +65 -0
  42. package/dist/cli.js.map +1 -0
  43. package/dist/client.d.ts +125 -17
  44. package/dist/client.js +383 -109
  45. package/dist/client.js.map +1 -1
  46. package/dist/codegen-check.d.ts +9 -0
  47. package/dist/codegen-check.js +12 -6
  48. package/dist/codegen-check.js.map +1 -1
  49. package/dist/error-models.d.ts +60 -2
  50. package/dist/error-models.js +169 -3
  51. package/dist/error-models.js.map +1 -1
  52. package/dist/error-verdicts.d.ts +34 -0
  53. package/dist/error-verdicts.js +69 -0
  54. package/dist/error-verdicts.js.map +1 -0
  55. package/dist/errors.d.ts +250 -48
  56. package/dist/errors.js +330 -64
  57. package/dist/errors.js.map +1 -1
  58. package/dist/hooks/validate-client.d.ts +3 -3
  59. package/dist/hooks/validate-client.js +3 -3
  60. package/dist/index.d.ts +4 -4
  61. package/dist/index.js +3 -2
  62. package/dist/index.js.map +1 -1
  63. package/dist/prepare-inputs.d.ts +6 -0
  64. package/dist/prepare-inputs.js +46 -14
  65. package/dist/prepare-inputs.js.map +1 -1
  66. package/dist/runs.d.ts +28 -1
  67. package/dist/runs.js +2 -1
  68. package/dist/runs.js.map +1 -1
  69. package/dist/upload-grant.d.ts +15 -10
  70. package/dist/upload-grant.js +36 -17
  71. package/dist/upload-grant.js.map +1 -1
  72. package/dist/upload.d.ts +6 -0
  73. package/dist/upload.js +25 -7
  74. package/dist/upload.js.map +1 -1
  75. package/dist/user-agent.d.ts +3 -2
  76. package/dist/user-agent.js +3 -2
  77. package/dist/user-agent.js.map +1 -1
  78. package/dist/version.d.ts +1 -1
  79. package/dist/version.js +1 -1
  80. package/docs/architecture.md +15 -9
  81. package/docs/artifact-download.md +3 -3
  82. package/docs/cli.md +123 -0
  83. package/docs/client-identification.md +1 -1
  84. package/docs/errors.md +96 -11
  85. package/docs/input-preparation.md +16 -8
  86. package/docs/run-results.md +20 -0
  87. package/package.json +5 -1
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The verdict an `ApiResponseError` falls back to when the server sent no usable member.
3
+ *
4
+ * A problem document may carry `retryable` and `error_domain`, and when it does the error takes
5
+ * them (see `ApiResponseError`). When it does not — the platform does not classify its own
6
+ * refusals yet, a gateway answers an HTML page, a bare runner answers Starlette's
7
+ * `{"detail": "Not Found"}` — each missing member is read off this table instead, so a consumer
8
+ * never has to choose its own default. The one exception is a `retryable` missing beside a sent
9
+ * `input` or `config` domain, which is not retryable whatever the status. The table reads only the
10
+ * HTTP status, the platform's native `code`, and whether the body names what it refused.
11
+ *
12
+ * It is also the platform's reference: the verdicts the platform will send on its own refusals
13
+ * are decided against this table, so a refusal keeps its verdict when the platform starts
14
+ * sending one. The Python twin, `pipelex-sdk`, must apply the same table. The case file
15
+ * `tests/fixtures/error-verdicts.json` holds every row, and this package's suite drives the table
16
+ * through it; the Python suite is to drive its own code through an identical copy, once that copy
17
+ * is added.
18
+ */
19
+ import type { ErrorVerdict } from "./errors.js";
20
+ /**
21
+ * The verdict of a refused request whose problem document carried no usable member.
22
+ *
23
+ * - `status` is the HTTP status of the answer.
24
+ * - `code` is the platform's native code, when the body carried one.
25
+ * - `named` says whether the body names what it refused: a platform `code` or a runner
26
+ * `error_type`. It decides a `404`: a named one is a resource the caller asked for that does not
27
+ * exist (`input`), a bare one is a route the deployment does not serve (`config`).
28
+ *
29
+ * Every `4xx` the table does not list is the caller's request refused (`input`, not retryable),
30
+ * every `5xx` it does not list is a fault in the service that may pass (`runtime`, retryable),
31
+ * and any other status is one no refusal carries, such as the `2xx` of an answer the client could
32
+ * not read, so nothing says a retry helps (`runtime`, not retryable).
33
+ */
34
+ export declare function fallbackVerdict(status: number, code: string | undefined, named: boolean): ErrorVerdict;
@@ -0,0 +1,69 @@
1
+ /**
2
+ * The verdict an `ApiResponseError` falls back to when the server sent no usable member.
3
+ *
4
+ * A problem document may carry `retryable` and `error_domain`, and when it does the error takes
5
+ * them (see `ApiResponseError`). When it does not — the platform does not classify its own
6
+ * refusals yet, a gateway answers an HTML page, a bare runner answers Starlette's
7
+ * `{"detail": "Not Found"}` — each missing member is read off this table instead, so a consumer
8
+ * never has to choose its own default. The one exception is a `retryable` missing beside a sent
9
+ * `input` or `config` domain, which is not retryable whatever the status. The table reads only the
10
+ * HTTP status, the platform's native `code`, and whether the body names what it refused.
11
+ *
12
+ * It is also the platform's reference: the verdicts the platform will send on its own refusals
13
+ * are decided against this table, so a refusal keeps its verdict when the platform starts
14
+ * sending one. The Python twin, `pipelex-sdk`, must apply the same table. The case file
15
+ * `tests/fixtures/error-verdicts.json` holds every row, and this package's suite drives the table
16
+ * through it; the Python suite is to drive its own code through an identical copy, once that copy
17
+ * is added.
18
+ */
19
+ const INPUT = Object.freeze({ errorDomain: "input", retryable: false });
20
+ const CONFIG = Object.freeze({ errorDomain: "config", retryable: false });
21
+ const TRANSIENT = Object.freeze({ errorDomain: "runtime", retryable: true });
22
+ const FAULT = Object.freeze({ errorDomain: "runtime", retryable: false });
23
+ /** The platform code a `409` carries when the organization holds as many API keys as it may. */
24
+ const API_KEY_LIMIT_CODE = "pipelex_api_key_limit_reached";
25
+ /**
26
+ * The verdict of a refused request whose problem document carried no usable member.
27
+ *
28
+ * - `status` is the HTTP status of the answer.
29
+ * - `code` is the platform's native code, when the body carried one.
30
+ * - `named` says whether the body names what it refused: a platform `code` or a runner
31
+ * `error_type`. It decides a `404`: a named one is a resource the caller asked for that does not
32
+ * exist (`input`), a bare one is a route the deployment does not serve (`config`).
33
+ *
34
+ * Every `4xx` the table does not list is the caller's request refused (`input`, not retryable),
35
+ * every `5xx` it does not list is a fault in the service that may pass (`runtime`, retryable),
36
+ * and any other status is one no refusal carries, such as the `2xx` of an answer the client could
37
+ * not read, so nothing says a retry helps (`runtime`, not retryable).
38
+ */
39
+ export function fallbackVerdict(status, code, named) {
40
+ switch (status) {
41
+ case 401:
42
+ case 402:
43
+ case 403:
44
+ // The credential, the plan or the access must change.
45
+ return CONFIG;
46
+ case 404:
47
+ return named ? INPUT : CONFIG;
48
+ case 405:
49
+ // The deployment does not serve this method on the route.
50
+ return CONFIG;
51
+ case 408:
52
+ case 429:
53
+ // Refused for its timing, not its content.
54
+ return TRANSIENT;
55
+ case 409:
56
+ // A conflict with the stored state is the caller's, except the key limit, which someone
57
+ // lifts by removing a key.
58
+ return code === API_KEY_LIMIT_CODE ? CONFIG : INPUT;
59
+ case 501:
60
+ // The deployment does not implement it, and asking again will not change that.
61
+ return CONFIG;
62
+ }
63
+ if (status >= 400 && status < 500)
64
+ return INPUT;
65
+ if (status >= 500 && status < 600)
66
+ return TRANSIENT;
67
+ return FAULT;
68
+ }
69
+ //# sourceMappingURL=error-verdicts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-verdicts.js","sourceRoot":"","sources":["../src/error-verdicts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,MAAM,KAAK,GAAiB,MAAM,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;AACtF,MAAM,MAAM,GAAiB,MAAM,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;AACxF,MAAM,SAAS,GAAiB,MAAM,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAC3F,MAAM,KAAK,GAAiB,MAAM,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;AAExF,gGAAgG;AAChG,MAAM,kBAAkB,GAAG,+BAA+B,CAAC;AAE3D;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAc,EACd,IAAwB,EACxB,KAAc;IAEd,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,GAAG,CAAC;QACT,KAAK,GAAG,CAAC;QACT,KAAK,GAAG;YACN,sDAAsD;YACtD,OAAO,MAAM,CAAC;QAChB,KAAK,GAAG;YACN,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;QAChC,KAAK,GAAG;YACN,0DAA0D;YAC1D,OAAO,MAAM,CAAC;QAChB,KAAK,GAAG,CAAC;QACT,KAAK,GAAG;YACN,2CAA2C;YAC3C,OAAO,SAAS,CAAC;QACnB,KAAK,GAAG;YACN,wFAAwF;YACxF,2BAA2B;YAC3B,OAAO,IAAI,KAAK,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;QACtD,KAAK,GAAG;YACN,+EAA+E;YAC/E,OAAO,MAAM,CAAC;IAClB,CAAC;IACD,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,GAAG,GAAG;QAAE,OAAO,KAAK,CAAC;IAChD,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,GAAG,GAAG;QAAE,OAAO,SAAS,CAAC;IACpD,OAAO,KAAK,CAAC;AACf,CAAC"}
package/dist/errors.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  /**
2
- * Pipelex SDK errors — transport and run-lifecycle errors raised by
3
- * `PipelexApiClient`. All derive from the protocol-base `PipelineRequestError`
4
- * (re-exported from `mthds/protocol`), except `ClientAuthenticationError`.
2
+ * Pipelex SDK errors — the argument, transport, run-lifecycle, input-preparation and artifact
3
+ * errors `PipelexApiClient` raises. Every one derives from `PipelexRequestError`, itself a
4
+ * `PipelineRequestError` (the protocol base, re-exported from `mthds/protocol`), and so carries
5
+ * a verdict: `retryable` and `errorDomain`, always decided. The one exported error outside the
6
+ * family, `CodegenLockError`, declares the same two members itself.
5
7
  */
6
8
  import { PipelineRequestError } from "mthds/protocol";
7
9
  import type { ValidationErrorItem } from "./models.js";
@@ -9,18 +11,97 @@ import type { ArtifactScope, DownloadArtifactsResult } from "./artifacts.js";
9
11
  import type { FieldError, MigrationErrorBlock, ProblemDetails, ProviderErrorMetadata, RunErrorReport, UserAction } from "./error-models.js";
10
12
  import type { RunStatus } from "./runs.js";
11
13
  export { PipelineRequestError };
12
- export declare class ClientAuthenticationError extends Error {
13
- constructor(message: string);
14
+ /**
15
+ * Who can fix a failure:
16
+ *
17
+ * - `input` — the caller, by changing the request: the inputs, the method, a reference, an
18
+ * argument.
19
+ * - `config` — someone changing the environment: the base URL, the credential, the plan, the
20
+ * deployment.
21
+ * - `runtime` — nobody beforehand: a fault during execution or in the service.
22
+ *
23
+ * The set is closed: the hosted envelope spec names these three, so a fourth would be a contract
24
+ * change and would reach the SDK as one.
25
+ */
26
+ export type ErrorDomain = "input" | "config" | "runtime";
27
+ /** Whether a value is one of the three error domains. */
28
+ export declare function isErrorDomain(value: unknown): value is ErrorDomain;
29
+ /**
30
+ * The verdict an error carries: whether asking again can plausibly succeed (`retryable`), and who
31
+ * can fix the failure (`errorDomain`). Both are always decided.
32
+ *
33
+ * "Retryable" says a retry can succeed, never that it is safe: it says nothing about whether the
34
+ * first attempt had an effect. A start answered with a `500` may already have created a run, so a
35
+ * caller that must not start a run twice decides that for itself.
36
+ */
37
+ export interface ErrorVerdict {
38
+ readonly retryable: boolean;
39
+ readonly errorDomain: ErrorDomain;
40
+ }
41
+ /**
42
+ * The base of every error this SDK raises over a request, carrying the verdict as two readonly
43
+ * own properties: `retryable` and `errorDomain`. Each subclass passes its verdict to this
44
+ * constructor, so a class that forgets one does not compile, and every class says its verdict
45
+ * where it is defined.
46
+ *
47
+ * It refines the standard's `PipelineRequestError`, so `instanceof PipelineRequestError` still
48
+ * matches every SDK error. To read a verdict from anything a `catch` holds, use
49
+ * `errorVerdictOf`, which also reads it off an error raised by another copy of this SDK.
50
+ */
51
+ export declare abstract class PipelexRequestError extends PipelineRequestError implements ErrorVerdict {
52
+ /** Whether asking again can plausibly succeed. Always decided. */
53
+ readonly retryable: boolean;
54
+ /** Who can fix the failure: `input`, `config` or `runtime`. Always decided. */
55
+ readonly errorDomain: ErrorDomain;
56
+ constructor(message: string, verdict: ErrorVerdict, options?: {
57
+ cause?: unknown;
58
+ });
59
+ }
60
+ /**
61
+ * The verdict of anything a `catch` holds: the pair from an `Error` carrying a boolean
62
+ * `retryable` and a known `errorDomain`, and `undefined` otherwise.
63
+ *
64
+ * The check is structural rather than `instanceof`, so it reads every error of this SDK, of
65
+ * another copy of it installed beside this one, of a consumer's own subclass, and an `mthds`
66
+ * `ApiResponseError` whose runner sent both members. `undefined` means the error carries no
67
+ * verdict: the `RangeError` or `TypeError` the SDK raises for an argument of the wrong type or
68
+ * range before any request is sent (a bug in the calling code), the caller's own abort, which the
69
+ * client rethrows untouched, or anything else a `try` block threw. An argument the client refuses
70
+ * for what it asks is a `RequestArgumentError`, which carries one.
71
+ */
72
+ export declare function errorVerdictOf(err: unknown): ErrorVerdict | undefined;
73
+ /**
74
+ * The SDK refused a call's arguments before sending any request: no run source given to
75
+ * `execute()` or `start()`, run sources or method selectors that exclude each other, a selector
76
+ * rule of `validate()`, an empty `validateFiles()`, a reserved key in `extra`, or a base URL that
77
+ * is not host-only. Nothing reached the API, so the message says what to change.
78
+ *
79
+ * Its verdict is `input`, not retryable — the caller must change the arguments — unless
80
+ * `options.verdict` declares another: the client declares `config` for a base URL that is not
81
+ * host-only, since it typically comes from `PIPELEX_BASE_URL`. A refusal the standard's own
82
+ * check raises (`assertExclusiveRunSources`) is rethrown as this class with the same message, the
83
+ * standard's error as `cause`.
84
+ */
85
+ export declare class RequestArgumentError extends PipelexRequestError {
86
+ constructor(message: string, options?: {
87
+ cause?: unknown;
88
+ verdict?: ErrorVerdict;
89
+ });
14
90
  }
15
91
  /**
16
92
  * Base class for every failure raised by input preparation (`uploadFile` /
17
93
  * `prepareInputs`). Catch this to handle any preparation failure; catch a
18
94
  * subclass to branch on the semantic category. All preparation failures are
19
95
  * raised BEFORE any run is created — a run never triggers a hidden upload.
96
+ *
97
+ * Its verdict is `input`, not retryable — the asset, the inputs or the method selector must
98
+ * change — unless `options.verdict` declares another: the SDK's own subclasses do, and so can a
99
+ * consumer's, such as a form reporting a missing input in its own words.
20
100
  */
21
- export declare class InputPreparationError extends PipelineRequestError {
101
+ export declare class InputPreparationError extends PipelexRequestError {
22
102
  constructor(message: string, options?: {
23
103
  cause?: unknown;
104
+ verdict?: ErrorVerdict;
24
105
  });
25
106
  }
26
107
  /**
@@ -52,6 +133,36 @@ export declare class InvalidLocalSourceError extends InputPreparationError {
52
133
  cause?: unknown;
53
134
  });
54
135
  }
136
+ /**
137
+ * A value the caller gave at a file input cannot be turned into a file to upload: a `data:` URL
138
+ * that does not decode (no comma, bad base64, bad percent-encoding), or a value of a type no file
139
+ * input takes, neither a path or URL string, nor bytes, nor `{url}` content. `prepareInputs`
140
+ * raises it while it reads the inputs, before anything is uploaded. As with
141
+ * `InvalidLocalSourceError`, the inputs are what must change, which is how a consumer tells it
142
+ * apart from `MethodLoadError`, a method that does not load, raised by the same preparation.
143
+ */
144
+ export declare class InvalidInputValueError extends InputPreparationError {
145
+ constructor(message: string, options?: {
146
+ cause?: unknown;
147
+ });
148
+ }
149
+ /**
150
+ * The pipe I/O answer said the method does not load (`is_valid: false`), so its signature cannot
151
+ * be read and no input can be prepared: the method, not the inputs, must change.
152
+ * `validationErrors` holds the answer's items, each kept when it carries a string `category` and
153
+ * `message`, possibly none; `serverMessage` is the answer's own `message` when it is a string. The
154
+ * error's message names the first item's message, else the answer's own.
155
+ */
156
+ export declare class MethodLoadError extends InputPreparationError {
157
+ readonly validationErrors: ValidationErrorItem[];
158
+ readonly serverMessage: string | undefined;
159
+ constructor(message: string, details: {
160
+ validationErrors: ValidationErrorItem[];
161
+ serverMessage?: string | undefined;
162
+ }, options?: {
163
+ cause?: unknown;
164
+ });
165
+ }
55
166
  /**
56
167
  * Why an asset was refused, in a closed vocabulary a caller branches on rather than
57
168
  * on the message: `too_large` — past the service-defined size cap (`uploadFile`'s
@@ -59,12 +170,17 @@ export declare class InvalidLocalSourceError extends InputPreparationError {
59
170
  * `grant_expired` — the grant's validity window has passed; `signature_mismatch` —
60
171
  * the file's size, content type or metadata differ from what the grant signed;
61
172
  * `unsigned_header` — the request carried a storage header the grant did not sign;
62
- * `store_refused` — any other refusal from storage.
173
+ * `store_refused` — any other refusal from storage. Storage's `408` and `429` are no
174
+ * refusal of the asset: they refuse the request for its timing, and are an
175
+ * `UploadTransportError`.
63
176
  */
64
177
  export type RejectedAssetCode = "too_large" | "grant_used" | "grant_expired" | "signature_mismatch" | "unsigned_header" | "store_refused";
65
178
  /**
66
179
  * The server or storage refused the asset — most commonly a `413` past the
67
- * service-defined size cap, or storage refusing an upload with a grant. The SDK
180
+ * service-defined size cap, or storage refusing an upload with a grant. A storage
181
+ * `4xx` that says nothing about the file is not among them: a `408` or a `429`, which
182
+ * time out or throttle the request, a `400 RequestTimeout` and a `409
183
+ * ConditionalRequestConflict` are an `UploadTransportError`. The SDK
68
184
  * does not impose a client-side cap; it surfaces the refusal. `filename` and
69
185
  * `status` locate it, and `code` says why: the SDK sets it on every one it raises,
70
186
  * so it is undefined only on one a caller constructs without it.
@@ -81,18 +197,28 @@ export declare class RejectedAssetError extends InputPreparationError {
81
197
  /**
82
198
  * The configured deployment does not support upload (no `/v1/upload` route, seen
83
199
  * as a `404`). Upload is a hosted Pipelex-product capability even though the SDK
84
- * can be pointed at other base URLs.
200
+ * can be pointed at other base URLs. Its verdict is `config`, not retryable: the base URL
201
+ * must point at a deployment that serves upload. `filename` is the file whose upload met it, as
202
+ * `uploadFile` sent it.
85
203
  */
86
204
  export declare class UnsupportedUploadCapabilityError extends InputPreparationError {
205
+ readonly filename: string | undefined;
87
206
  constructor(message: string, options?: {
88
207
  cause?: unknown;
208
+ filename?: string;
89
209
  });
90
210
  }
91
- /** Upload was not authorized — a `401`/`403` from the upload route. */
211
+ /**
212
+ * Upload was not authorized — a `401`/`403` from the upload route. Its verdict is `config`, not
213
+ * retryable: the credential must change. `filename` is the file whose upload was refused, as
214
+ * `uploadFile` sent it.
215
+ */
92
216
  export declare class UploadAuthenticationError extends InputPreparationError {
93
217
  readonly status: number;
218
+ readonly filename: string | undefined;
94
219
  constructor(message: string, status: number, options?: {
95
220
  cause?: unknown;
221
+ filename?: string;
96
222
  });
97
223
  }
98
224
  /**
@@ -105,7 +231,8 @@ export declare class UploadAuthenticationError extends InputPreparationError {
105
231
  * `uploadFile`. Whether the file was stored is unknown.
106
232
  * - `unreachable` — no response reached the SDK. In a browser, a refused cross-origin
107
233
  * request looks like this.
108
- * - `server_error` — a `5xx`. Whether the file was stored is unknown.
234
+ * - `server_error` — a `5xx`. Whether the file was stored is unknown, except after a `501`:
235
+ * storage does not implement the request it was sent, and stored nothing.
109
236
  * - `storage_timeout` — storage's `400 RequestTimeout`: it stopped waiting for the
110
237
  * file's bytes and stored nothing.
111
238
  * - `conflict` — storage's `409 ConditionalRequestConflict`: another `PUT` with the
@@ -113,26 +240,46 @@ export declare class UploadAuthenticationError extends InputPreparationError {
113
240
  * - `redirected` — storage redirected the `PUT`, and the redirect was refused.
114
241
  * - `invalid_grant_url` — the grant's `url` is not an absolute `http(s)` URL free of
115
242
  * user info, so nothing was sent.
116
- * - `unexpected` — a status or a failure the SDK has no specific mapping for.
243
+ * - `unexpected` — a status or a failure the SDK has no specific mapping for. From
244
+ * `uploadWithGrant`, storage's `408` or `429`: it timed out or throttled the request,
245
+ * which a later attempt can pass.
117
246
  */
118
247
  export type UploadTransportCode = "timeout" | "unreachable" | "server_error" | "storage_timeout" | "conflict" | "redirected" | "invalid_grant_url" | "unexpected";
119
248
  /**
120
249
  * A network or server fault reaching the upload route or storage — an unreachable
121
- * host, a timeout, a `5xx`, a refused redirect, storage timing out on the body, or
122
- * any other unexpected `upload()` failure. `code` says which: the SDK sets it on
250
+ * host, a timeout, a `5xx`, a refused redirect, storage timing out on the body,
251
+ * storage timing out or throttling the request (a `408` or a `429`), or any other
252
+ * unexpected `upload()` failure. `code` says which: the SDK sets it on
123
253
  * every one it raises, so it is undefined only on one a caller constructs without
124
254
  * it. `status` is the HTTP status when a response produced it, and undefined when
125
255
  * none did. From `uploadFile` the wrapped `ApiResponseError` is also reachable via
126
- * `cause`; `uploadWithGrant` wraps no response, because storage's error body can
127
- * echo the grant's credential.
256
+ * `cause`, and `filename` is the file it was sending; `uploadWithGrant` wraps no response,
257
+ * because storage's error body can echo the grant's credential, and leaves `filename` undefined.
258
+ *
259
+ * Its verdict is the wrapped error's when `cause` carries one: `uploadFile` wraps the
260
+ * `ApiResponseError` or `ApiUnreachableError` the client's `upload()` threw, and `code` is too
261
+ * coarse to judge it by (a `402` plan limit is `unexpected`, like a malformed answer). Otherwise
262
+ * — always the case from `uploadWithGrant`, which wraps no response — `code` decides: `timeout`,
263
+ * `storage_timeout` and `conflict` are `runtime` and retryable, `conflict` because storage
264
+ * documents its `409 ConditionalRequestConflict` as retryable and the grant is not spent by it (a
265
+ * spent grant is the `412` of a `RejectedAssetError` with code `grant_used`); `server_error` is
266
+ * `runtime`, and retryable when the fallback table a refused API request reads would call its
267
+ * `status` retryable — any `5xx` but a `501`, which storage answers for a request it does not
268
+ * implement — or when it carries no status; `unexpected` is `runtime`, and retryable when that
269
+ * table would call its `status` retryable — storage's `408` or `429`, refused for its timing —
270
+ * and not retryable for any other status or none; `unreachable` is `config` and retryable, like
271
+ * `ApiUnreachableError`; `redirected` is `config` and not retryable; `invalid_grant_url` and no
272
+ * code at all are `runtime` and not retryable.
128
273
  */
129
274
  export declare class UploadTransportError extends InputPreparationError {
130
275
  readonly status: number | undefined;
131
276
  readonly code: UploadTransportCode | undefined;
277
+ readonly filename: string | undefined;
132
278
  constructor(message: string, options?: {
133
279
  cause?: unknown;
134
280
  status?: number;
135
281
  code?: UploadTransportCode;
282
+ filename?: string;
136
283
  });
137
284
  }
138
285
  /**
@@ -144,10 +291,16 @@ export declare class UploadTransportError extends InputPreparationError {
144
291
  * operation throws only when it can produce no verdict at all. Transport
145
292
  * failures on the resolve route (`ApiResponseError`, `ApiUnreachableError`)
146
293
  * and the run-lifecycle errors propagate unchanged, so they are not subclasses.
294
+ *
295
+ * Its verdict is `runtime`, not retryable, unless `options.verdict` declares another: the SDK
296
+ * declares `input` where it refuses an argument (a `scope`, a bound, a location) and `config`
297
+ * where the environment refuses the download (a runtime with no filesystem, a directory that
298
+ * cannot be created).
147
299
  */
148
- export declare class ArtifactOperationError extends PipelineRequestError {
300
+ export declare class ArtifactOperationError extends PipelexRequestError {
149
301
  constructor(message: string, options?: {
150
302
  cause?: unknown;
303
+ verdict?: ErrorVerdict;
151
304
  });
152
305
  }
153
306
  /**
@@ -174,6 +327,14 @@ export declare class ScopeUnavailableError extends ArtifactOperationError {
174
327
  * (any other non-2xx), `too_large`, `timeout`, `network`. `status` is the
175
328
  * store's HTTP status when one was received. `downloadArtifacts` never lets
176
329
  * this escape: it becomes the item's `error`.
330
+ *
331
+ * Its verdict follows `code`: `invalid_storage_uri`, `forbidden`, `unsupported_url`, `not_found`
332
+ * and `too_large` are `input` and not retryable, since the reference or the bound must change;
333
+ * `plain_http_refused` is `config` and not retryable; `redirect_refused` and `store_refused` are
334
+ * `runtime` and not retryable; `timeout` and `network` are `runtime` and retryable; `store_error`
335
+ * is `runtime`, and retryable when the fallback table a refused API request reads would call its
336
+ * `status` retryable — a `408`, a `429` or a `5xx` other than `501` — and not retryable for any
337
+ * other status or none. A code this version does not know is `runtime` and not retryable.
177
338
  */
178
339
  export declare class ArtifactFetchError extends ArtifactOperationError {
179
340
  readonly uri: string;
@@ -189,7 +350,9 @@ export declare class ArtifactFetchError extends ArtifactOperationError {
189
350
  * the download stops — but the files already saved are real, and `verdict`
190
351
  * carries the result as it stood: every item saved before the refusal, and
191
352
  * the rest marked `aborted`. `status` is the route's status; the wrapped
192
- * `ApiResponseError` is reachable via `cause`.
353
+ * `ApiResponseError` is reachable via `cause`. (`verdict` is the download's result, not the
354
+ * error's own: that is `retryable` and `errorDomain`, `config` and not retryable, since the
355
+ * credential must change.)
193
356
  */
194
357
  export declare class ArtifactAuthenticationError extends ArtifactOperationError {
195
358
  readonly status: number;
@@ -206,8 +369,13 @@ export declare class ArtifactAuthenticationError extends ArtifactOperationError
206
369
  *
207
370
  * `code` is the underlying network error code when available
208
371
  * (`ECONNREFUSED`, `ENOTFOUND`, `ETIMEDOUT`, `EAI_AGAIN`, `ABORT_TIMEOUT`).
372
+ *
373
+ * Its verdict is `config` and retryable: the address or the network must be checked, and a later
374
+ * attempt can get through. With the code `ABORT_TIMEOUT`, the SDK's own request timeout, it is
375
+ * `runtime` and retryable instead: the API took the request and did not answer in time, which is
376
+ * no fault of the base URL.
209
377
  */
210
- export declare class ApiUnreachableError extends PipelineRequestError {
378
+ export declare class ApiUnreachableError extends PipelexRequestError {
211
379
  readonly apiUrl: string;
212
380
  readonly code: string | undefined;
213
381
  constructor(message: string, apiUrl: string, code: string | undefined, options?: {
@@ -219,8 +387,11 @@ export declare class ApiUnreachableError extends PipelineRequestError {
219
387
  * hosted gateway's ~30s synchronous-request limit. The blocking path cannot
220
388
  * run methods longer than 30s behind the hosted gateway — use the durable run
221
389
  * lifecycle (start + poll) instead.
390
+ *
391
+ * Its verdict is `input`, not retryable: asking again meets the same limit, and the caller fixes
392
+ * it by starting the run and polling.
222
393
  */
223
- export declare class PipelineExecuteTimeoutError extends PipelineRequestError {
394
+ export declare class PipelineExecuteTimeoutError extends PipelexRequestError {
224
395
  readonly elapsedMs: number;
225
396
  constructor(elapsedMs: number, options?: {
226
397
  cause?: unknown;
@@ -247,8 +418,15 @@ export declare class PipelineExecuteTimeoutError extends PipelineRequestError {
247
418
  * report's message (`Run finished with status FAILED: <message>`), so printing the error
248
419
  * already tells the reason.
249
420
  * - `runId` locates the run, for a status read or a support request.
421
+ *
422
+ * Its verdict comes from the report. `errorDomain` is the report's `error_domain` when it is one
423
+ * of the three domains, and `runtime` otherwise, including a run with no report. `retryable` is
424
+ * true only when the report's `retryable` is `true`: a report that says nothing, and a run with
425
+ * none, read as not retryable, since starting the run again spends credit and nothing says it
426
+ * would succeed. The report keeps its own `retryable` as written, so a consumer that words the
427
+ * unknown differently still can.
250
428
  */
251
- export declare class RunFailedError extends PipelineRequestError {
429
+ export declare class RunFailedError extends PipelexRequestError {
252
430
  readonly runId: string;
253
431
  readonly status: RunStatus;
254
432
  readonly error: RunErrorReport | null;
@@ -266,8 +444,10 @@ export declare class RunFailedError extends PipelineRequestError {
266
444
  * `execute` response named a `main_stuff_name` whose stuff is absent from the returned working
267
445
  * memory. `runId` locates the run. (An empty-but-present main stuff — `{ items: [] }`, `{ text:
268
446
  * "" }` — is a valid output and does NOT throw; only a genuinely absent one does.)
447
+ *
448
+ * Its verdict is `runtime`, not retryable: the API broke its own contract on a completed run.
269
449
  */
270
- export declare class MissingMainStuffError extends PipelineRequestError {
450
+ export declare class MissingMainStuffError extends PipelexRequestError {
271
451
  readonly runId: string;
272
452
  constructor(message: string, runId: string);
273
453
  }
@@ -275,8 +455,10 @@ export declare class MissingMainStuffError extends PipelineRequestError {
275
455
  * Thrown when `waitForResult` exceeds its `timeoutMs` before the run reaches a
276
456
  * terminal state. The run is NOT cancelled — it keeps executing server-side and
277
457
  * can be resumed later by `runId` (the poll loop just stopped waiting).
458
+ *
459
+ * Its verdict is `runtime` and retryable: the run is still going, and waiting again can succeed.
278
460
  */
279
- export declare class RunTimeoutError extends PipelineRequestError {
461
+ export declare class RunTimeoutError extends PipelexRequestError {
280
462
  readonly runId: string;
281
463
  readonly timeoutMs: number;
282
464
  constructor(message: string, runId: string, timeoutMs: number);
@@ -289,8 +471,10 @@ export declare class RunTimeoutError extends PipelineRequestError {
289
471
  * when it cannot hold the connection open. The run keeps executing
290
472
  * server-side — resume by `runId` (`getRunResult` / `waitForResult` on a
291
473
  * hosted deployment, or the `location` status resource when provided).
474
+ *
475
+ * Its verdict is `runtime` and retryable: the run is still going, and is resumed by its id.
292
476
  */
293
- export declare class RunStillRunningError extends PipelineRequestError {
477
+ export declare class RunStillRunningError extends PipelexRequestError {
294
478
  readonly runId: string;
295
479
  readonly retryAfterSeconds: number | null;
296
480
  readonly location: string | null;
@@ -307,13 +491,28 @@ export declare class RunStillRunningError extends PipelineRequestError {
307
491
  * it 404s those routes; only a deployment that includes the platform block
308
492
  * (the Pipelex Hosted API) serves status/results. Distinguished from a genuine
309
493
  * run-not-found 404, which carries the server's structured error envelope.
494
+ *
495
+ * Its verdict is `config`, not retryable: the base URL points at a bare runner without the run
496
+ * lifecycle.
310
497
  */
311
- export declare class RunLifecycleUnavailableError extends PipelineRequestError {
498
+ export declare class RunLifecycleUnavailableError extends PipelexRequestError {
312
499
  readonly apiUrl: string;
313
500
  constructor(message: string, apiUrl: string, options?: {
314
501
  cause?: unknown;
315
502
  });
316
503
  }
504
+ /**
505
+ * Thrown when a paged-list iterator (`iterateMethods`) refuses to keep following cursors.
506
+ *
507
+ * The ceiling, `pageLimit` pages, sits far beyond any real catalog, so reaching it is a
508
+ * server-side fault — an endpoint minting a fresh cursor forever — not a coverage limit the caller
509
+ * can raise. Throwing beats returning, because a silently truncated list is exactly the bug
510
+ * paging was introduced to remove. Its verdict is `runtime`, not retryable.
511
+ */
512
+ export declare class PagingNotTerminatingError extends PipelexRequestError {
513
+ readonly pageLimit: number;
514
+ constructor(message: string, pageLimit: number);
515
+ }
317
516
  /**
318
517
  * The last constructor argument of `ApiResponseError`: the error's `cause`, the problem
319
518
  * document's typed members, and the decoded document whole. The same shape as `mthds`'s
@@ -325,16 +524,32 @@ export interface ApiResponseErrorOptions {
325
524
  problemDocument?: Record<string, unknown>;
326
525
  }
327
526
  /**
328
- * A non-2xx response that DID come back from the API, with its problem document parsed.
527
+ * A response that DID come back from the API and that the SDK cannot hand back as a result: a
528
+ * non-2xx refusal, with its problem document parsed, or a 2xx answer the SDK could not read —
529
+ * a body that is not JSON, JSON that is not the object the route answers, or a stored method
530
+ * whose `python` field is not the serialized file list. The second carries the answer's status
531
+ * and raw text, no problem member, what made it unreadable as `cause` (the parse failure, or
532
+ * `mthds`'s refusal of the `python` field), and the verdict the fallback gives a 2xx: `runtime`,
533
+ * not retryable.
329
534
  *
330
535
  * Every error the hosted API answers is an RFC 9457 `application/problem+json` document, and
331
536
  * this error carries its members as typed fields, each `undefined` when the document did not
332
- * carry it (a member of the wrong type reads as absent rather than as a wrong value):
537
+ * carry it (a member of the wrong type reads as absent rather than as a wrong value, and the
538
+ * nested members `providerMetadata`, `migration`, `validationErrors` and `errors` are checked
539
+ * field by field as a failed run's stored report is) — except the verdict, which is always
540
+ * decided:
333
541
  *
334
- * - **The branch fields.** `errorDomain` says who can fix the failure — `input` (the caller),
335
- * `config` (a configuration change), `runtime` (nobody beforehand) — and `type` is the stable
336
- * URI naming the error class. `retryable` says whether a retry can succeed, `undefined`
337
- * meaning unknown. Branch on these, never on the HTTP status or on the wording of a message.
542
+ * - **The verdict.** `errorDomain` says who can fix the failure — `input` (the caller),
543
+ * `config` (a configuration change), `runtime` (nobody beforehand) — and `retryable` whether
544
+ * asking again can succeed. Each is the document's member when the server sent a valid one,
545
+ * and otherwise the SDK's fallback, read from the status, the platform `code` and whether the
546
+ * body names what it refused. A runner often sends `error_domain` without `retryable`, and
547
+ * then the domain it sent decides `retryable`: `input` and `config` are not retryable, as a
548
+ * stored report that says nothing is not, since the caller or the environment must change,
549
+ * while `runtime` takes the fallback's. Nothing on the error says which a value came from:
550
+ * `problemDocument` keeps what the server sent.
551
+ * - **The branch fields.** `errorDomain`, and `type`, the stable URI naming the error class.
552
+ * Branch on these, never on the HTTP status or on the wording of a message.
338
553
  * - **The native codes.** `code` is the platform's own closed code (`conflict`, `not_found`,
339
554
  * `pipelex_api_key_limit_reached`, …) and `errorType` the runner's open exception class
340
555
  * name. Each is finer than `errorDomain` and specific to the surface that emits it; the
@@ -352,11 +567,11 @@ export interface ApiResponseErrorOptions {
352
567
  * `problemDocument` is the decoded document whole, so a member this SDK does not name stays
353
568
  * reachable without re-parsing `responseBody`, which is the raw text; it is `undefined` when
354
569
  * the body was not a JSON object. The members `mthds`'s own `ApiResponseError` carries have the
355
- * same names and types here, and the rest (`code`, `errorCategory`, `model`, `provider`,
356
- * `providerMetadata`, `migration`, `errors`) are the Pipelex members the standard's client
357
- * leaves to this SDK.
570
+ * same names here, and the same types except the verdict, which this SDK narrows from optional
571
+ * to decided; the rest (`code`, `errorCategory`, `model`, `provider`, `providerMetadata`,
572
+ * `migration`, `errors`) are the Pipelex members the standard's client leaves to this SDK.
358
573
  */
359
- export declare class ApiResponseError extends PipelineRequestError {
574
+ export declare class ApiResponseError extends PipelexRequestError {
360
575
  readonly apiUrl: string;
361
576
  readonly status: number;
362
577
  readonly statusText: string;
@@ -385,24 +600,11 @@ export declare class ApiResponseError extends PipelineRequestError {
385
600
  * lines for this request.
386
601
  */
387
602
  readonly requestId: string | undefined;
388
- /**
389
- * The body's `error_domain`: who can fix the failure. `input` — the caller (a malformed
390
- * bundle, a bad argument, a missing input); `config` — a configuration change (a missing
391
- * secret, a model the backend does not serve); `runtime` — nobody beforehand (a provider
392
- * outage during execution). Typed open, as the server owns the vocabulary; `undefined` when
393
- * the server did not classify it.
394
- */
395
- readonly errorDomain: string | undefined;
396
603
  /**
397
604
  * The body's `error_category`: the finer classification of an inference failure — known
398
605
  * values `transient`, `configuration`, `content`, `capacity`, `ambiguous`, `unknown`.
399
606
  */
400
607
  readonly errorCategory: string | undefined;
401
- /**
402
- * The body's `retryable`: whether retrying the same request can plausibly succeed.
403
- * `undefined` means unknown, which is not the same as `false`.
404
- */
405
- readonly retryable: boolean | undefined;
406
608
  /** The body's `user_action`: what the caller should do next, when the server can say. */
407
609
  readonly userAction: UserAction | undefined;
408
610
  /** The body's `model`: the model an inference failure used. */