@pipelex/sdk 0.37.0 → 0.39.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.
@@ -4,9 +4,10 @@
4
4
  *
5
5
  * **The runner owns these shapes; this SDK follows them.** A run that fails reports why as
6
6
  * the runner's `ErrorReport` (`pipelex.base_exceptions`), which the hosted platform stores
7
- * whole on the run row as `error` and serves as it was stored: on the status read
8
- * (`RunRead.error`), on the run records (`PipelineRun.error`), and inside the problem
9
- * document of the results read's `409`, where the client lifts it onto the failed arm of
7
+ * whole on the run row as `error` and serves through the runner's STRICT disclosure: on the
8
+ * status read (`RunRead.error`), on the run records (`PipelineRun.error`,
9
+ * `RunHistoryItem.error`), and inside the problem document of the results read's `409`, where
10
+ * the client lifts it onto the failed arm of
10
11
  * `RunResultState` and onto `RunFailedError.error`. The same classification fields
11
12
  * (`error_domain`, `user_action`, …) ride a runner-rendered problem document as extension
12
13
  * members, which is why `ApiResponseError` types its members with the models declared here.
@@ -26,10 +27,19 @@
26
27
  * `providerMetadata`, `migration`, `validationErrors` and `errors` hold to their types as a stored
27
28
  * report's do.
28
29
  *
29
- * **Nothing else is stripped.** The platform serves the runner's VERBOSE report, so `message` and
30
- * `provider_metadata` can hold a provider's raw text. Deciding what of it a person should see
31
- * is each consumer's presentation, not this SDK's; the report arrives here whole, members this
32
- * SDK does not name included.
30
+ * **The platform serves the STRICT projection; this SDK strips nothing further.** The run row
31
+ * keeps the runner's VERBOSE report as the operators' record, and every read that hands it to a
32
+ * caller serves the rule the hosted runner applies to an error on `execute`: `error_type`,
33
+ * `title`, `type_uri`, `error_domain`, `error_category`, `retryable` and `validation_errors`
34
+ * pass through; `message` and `user_action` pass through only when `caller_facing_message` is
35
+ * `true`, which the served report then keeps, and otherwise `message` is the placeholder
36
+ * `An internal error occurred.` while `user_action` and the flag are absent; `provider_metadata`
37
+ * keeps only `status_code` and `retry_after_seconds`; `model`, `provider` and `migration` are
38
+ * absent. The reports the platform writes itself are caller-facing copy, so they keep their
39
+ * message and their next step. A platform run locally with `ERROR_DISCLOSURE=verbose` serves the
40
+ * report whole, which is why the types still name every member the runner writes. Deciding what
41
+ * a person should see is each consumer's presentation; the report arrives here as served,
42
+ * members this SDK does not name included.
33
43
  */
34
44
  import type { ValidationErrorItem } from "./models.js";
35
45
  /**
@@ -51,7 +61,10 @@ export interface UserAction {
51
61
  * What the inference provider's SDK said about a failed call — the runner's
52
62
  * `ProviderErrorMetadata`. Present on a report whose failure came back from a model provider.
53
63
  * `message` is the provider SDK's own text, relayed raw; the provider's response body never
54
- * crosses the wire, because the runner excludes it from every serialization.
64
+ * crosses the wire, because the runner excludes it from every serialization. A hosted run read
65
+ * keeps only `status_code` and `retry_after_seconds`, the client hints; the other members reach a
66
+ * caller only from a server that discloses errors VERBOSE, such as a platform run locally with
67
+ * `ERROR_DISCLOSURE=verbose`.
55
68
  *
56
69
  * **The hosted store turns its numbers into strings.** A report read back from the platform's
57
70
  * run store carries `status_code` and `retry_after_seconds` as JSON strings (`"404"`,
@@ -103,8 +116,19 @@ export interface MigrationErrorBlock {
103
116
  * failure's report carries, and how its `message` names the failing pipe, is the runner's to
104
117
  * decide; read them as given.
105
118
  *
106
- * A report is `null` where the run has none — a cancelled, terminated or timed-out run, or one
107
- * the platform finalized itself — so the absence of a report says nothing about why.
119
+ * The runner writes the report of a run that fails while it runs. A run the platform ends or
120
+ * settles itself carries one the platform wrote in the same shape, as caller-facing copy:
121
+ * `WorkflowTaskKeptFailingError` for a workflow task that kept failing (the run ends `FAILED`,
122
+ * not `TERMINATED`), `RunTimedOutError` for a timeout and `RunWorkflowNotFoundError` for a
123
+ * workflow that vanished. A `CANCELLED`, `TERMINATED` or `TIMED_OUT` run holds a report when a
124
+ * completion callback carried one, and a `TIMED_OUT` run otherwise holds the platform's timeout
125
+ * report. A report is `null` on a completed run and where a run has none — one whose start
126
+ * failed, a blocking `execute` run, whose answer carried its reason, one cancelled, terminated or
127
+ * given its status by hand with no completion callback carrying a report, one that ended before
128
+ * the platform wrote reports of its own — so the absence of a report says nothing about why.
129
+ *
130
+ * What the platform serves of a report is the runner's STRICT projection (see the module
131
+ * comment), so the members the projection drops are absent on a hosted read.
108
132
  */
109
133
  export interface RunErrorReport {
110
134
  /**
@@ -113,8 +137,8 @@ export interface RunErrorReport {
113
137
  */
114
138
  error_type?: string | null;
115
139
  /**
116
- * What went wrong, as the runner wrote it. On the VERBOSE report the platform serves, it can
117
- * carry a provider's raw text.
140
+ * What went wrong. The platform serves the author's copy only when `caller_facing_message` is
141
+ * `true`, and the placeholder `An internal error occurred.` otherwise.
118
142
  */
119
143
  message?: string | null;
120
144
  /** A stable human label for the error class (`LLM completion`). */
@@ -134,22 +158,38 @@ export interface RunErrorReport {
134
158
  error_category?: string | null;
135
159
  /** Whether retrying the same run can succeed. Absent or `null` means unknown, never "no". */
136
160
  retryable?: boolean | null;
137
- /** The next step the runner advises. */
161
+ /** The next step the runner advises. The platform serves it only beside caller-facing copy. */
138
162
  user_action?: UserAction | null;
139
- /** The model the failing call used, when the failure is an inference failure. */
163
+ /**
164
+ * The model the failing call used, when the failure is an inference failure. Absent on a
165
+ * hosted read, whose STRICT projection drops it.
166
+ */
140
167
  model?: string | null;
141
- /** The provider the failing call reached, when the failure is an inference failure. */
168
+ /**
169
+ * The provider the failing call reached, when the failure is an inference failure. Absent on
170
+ * a hosted read, whose STRICT projection drops it.
171
+ */
142
172
  provider?: string | null;
143
- /** What the provider's SDK said, when the failure came back from a provider. */
173
+ /**
174
+ * What the provider's SDK said, when the failure came back from a provider. A hosted read
175
+ * keeps only its `status_code` and `retry_after_seconds`.
176
+ */
144
177
  provider_metadata?: ProviderErrorMetadata | null;
145
- /** True when `message` was written as caller-facing copy. The runner emits it only when true. */
178
+ /**
179
+ * True when `message` was written as caller-facing copy. The runner emits it only when true,
180
+ * and the platform keeps it on a caller-facing report and leaves it out otherwise, so it is how
181
+ * a consumer tells the author's copy from the placeholder.
182
+ */
146
183
  caller_facing_message?: boolean | null;
147
184
  /**
148
185
  * The structured diagnostics of a bundle that failed validation — the same items the
149
186
  * validate report and a `422`'s `ApiResponseError.validationErrors` carry.
150
187
  */
151
188
  validation_errors?: ValidationErrorItem[] | null;
152
- /** A pending configuration migration that explains the failure. */
189
+ /**
190
+ * A pending configuration migration that explains the failure. Absent on a hosted read, whose
191
+ * STRICT projection drops it.
192
+ */
153
193
  migration?: MigrationErrorBlock | null;
154
194
  /** Fields a newer runner adds, reachable before this SDK names them. */
155
195
  [extension: string]: unknown;
@@ -207,6 +247,12 @@ export interface ProblemDetails {
207
247
  }
208
248
  /** Whether a value is a plain object: an object that is neither `null` nor an array. */
209
249
  export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
250
+ /**
251
+ * Drop each of `fields` from `record` when it is present and fails `fits`. `null` always fits,
252
+ * since every field of these shapes allows it. Internal: the run status read's degradation
253
+ * (`readRunDegradation` in `runs.ts`) is checked with it too.
254
+ */
255
+ export declare function dropUnfit(record: Record<string, unknown>, fields: readonly string[], fits: (value: unknown) => boolean): void;
210
256
  /**
211
257
  * `provider_metadata`, its named string fields kept as strings and `status_code` and
212
258
  * `retry_after_seconds` as a number or a string; its other members are relayed as sent.
@@ -4,9 +4,10 @@
4
4
  *
5
5
  * **The runner owns these shapes; this SDK follows them.** A run that fails reports why as
6
6
  * the runner's `ErrorReport` (`pipelex.base_exceptions`), which the hosted platform stores
7
- * whole on the run row as `error` and serves as it was stored: on the status read
8
- * (`RunRead.error`), on the run records (`PipelineRun.error`), and inside the problem
9
- * document of the results read's `409`, where the client lifts it onto the failed arm of
7
+ * whole on the run row as `error` and serves through the runner's STRICT disclosure: on the
8
+ * status read (`RunRead.error`), on the run records (`PipelineRun.error`,
9
+ * `RunHistoryItem.error`), and inside the problem document of the results read's `409`, where
10
+ * the client lifts it onto the failed arm of
10
11
  * `RunResultState` and onto `RunFailedError.error`. The same classification fields
11
12
  * (`error_domain`, `user_action`, …) ride a runner-rendered problem document as extension
12
13
  * members, which is why `ApiResponseError` types its members with the models declared here.
@@ -26,10 +27,19 @@
26
27
  * `providerMetadata`, `migration`, `validationErrors` and `errors` hold to their types as a stored
27
28
  * report's do.
28
29
  *
29
- * **Nothing else is stripped.** The platform serves the runner's VERBOSE report, so `message` and
30
- * `provider_metadata` can hold a provider's raw text. Deciding what of it a person should see
31
- * is each consumer's presentation, not this SDK's; the report arrives here whole, members this
32
- * SDK does not name included.
30
+ * **The platform serves the STRICT projection; this SDK strips nothing further.** The run row
31
+ * keeps the runner's VERBOSE report as the operators' record, and every read that hands it to a
32
+ * caller serves the rule the hosted runner applies to an error on `execute`: `error_type`,
33
+ * `title`, `type_uri`, `error_domain`, `error_category`, `retryable` and `validation_errors`
34
+ * pass through; `message` and `user_action` pass through only when `caller_facing_message` is
35
+ * `true`, which the served report then keeps, and otherwise `message` is the placeholder
36
+ * `An internal error occurred.` while `user_action` and the flag are absent; `provider_metadata`
37
+ * keeps only `status_code` and `retry_after_seconds`; `model`, `provider` and `migration` are
38
+ * absent. The reports the platform writes itself are caller-facing copy, so they keep their
39
+ * message and their next step. A platform run locally with `ERROR_DISCLOSURE=verbose` serves the
40
+ * report whole, which is why the types still name every member the runner writes. Deciding what
41
+ * a person should see is each consumer's presentation; the report arrives here as served,
42
+ * members this SDK does not name included.
33
43
  */
34
44
  // ── Checking a stored report, and a problem document's nested members ─
35
45
  //
@@ -66,9 +76,10 @@ export function isPlainObject(value) {
66
76
  }
67
77
  /**
68
78
  * Drop each of `fields` from `record` when it is present and fails `fits`. `null` always fits,
69
- * since every field of these shapes allows it.
79
+ * since every field of these shapes allows it. Internal: the run status read's degradation
80
+ * (`readRunDegradation` in `runs.ts`) is checked with it too.
70
81
  */
71
- function dropUnfit(record, fields, fits) {
82
+ export function dropUnfit(record, fields, fits) {
72
83
  for (const field of fields) {
73
84
  if (!Object.hasOwn(record, field))
74
85
  continue;
@@ -1 +1 @@
1
- {"version":3,"file":"error-models.js","sourceRoot":"","sources":["../src/error-models.ts"],"names":[],"mapp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AAC;IAC5B,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO;IAC3B,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5D,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;;QACxC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;AAC5B,CAAC"}
package/dist/errors.d.ts CHANGED
@@ -2,8 +2,9 @@
2
2
  * Pipelex SDK errors — the argument, transport, run-lifecycle, input-preparation and artifact
3
3
  * errors `PipelexApiClient` raises. Every one derives from `PipelexRequestError`, itself a
4
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
+ * a verdict: `retryable` and `errorDomain`, always decided, and `runMayHaveStarted`, which says
6
+ * whether a failed start or execute may still have started a run. The one exported error outside
7
+ * the family, `CodegenLockError`, declares the verdict's two members itself.
7
8
  */
8
9
  import { PipelineRequestError } from "mthds/protocol";
9
10
  import type { ValidationErrorItem } from "./models.js";
@@ -30,9 +31,11 @@ export declare function isErrorDomain(value: unknown): value is ErrorDomain;
30
31
  * The verdict an error carries: whether asking again can plausibly succeed (`retryable`), and who
31
32
  * can fix the failure (`errorDomain`). Both are always decided.
32
33
  *
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.
34
+ * "Retryable" says a retry can succeed, and on a request that may create a run, that it cannot
35
+ * start a second one: a failed `start` or `execute` that may still have started a run (an error
36
+ * whose `runMayHaveStarted` is true) is never retryable, whatever the server or the fallback table
37
+ * says, since asking again could pay for the run twice. Everywhere else it says nothing about
38
+ * whether the first attempt had an effect.
36
39
  */
37
40
  export interface ErrorVerdict {
38
41
  readonly retryable: boolean;
@@ -40,21 +43,35 @@ export interface ErrorVerdict {
40
43
  }
41
44
  /**
42
45
  * 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
+ * own properties, `retryable` and `errorDomain`, and a third, `runMayHaveStarted`. Each subclass
47
+ * passes its verdict to this constructor, so a class that forgets one does not compile, and every
48
+ * class says its verdict where it is defined.
49
+ *
50
+ * `runMayHaveStarted` is false unless the subclass passes it: only `ApiUnreachableError` and
51
+ * `ApiResponseError` built for a request that may create a run, and `PipelineExecuteTimeoutError`,
52
+ * ever carry it as true, and when they do, `retryable` is false whatever the verdict passed.
46
53
  *
47
54
  * It refines the standard's `PipelineRequestError`, so `instanceof PipelineRequestError` still
48
55
  * 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.
56
+ * `errorVerdictOf`, which also reads it off an error raised by another copy of this SDK, and
57
+ * `runMayHaveStartedOf` for the third member.
50
58
  */
51
59
  export declare abstract class PipelexRequestError extends PipelineRequestError implements ErrorVerdict {
52
60
  /** Whether asking again can plausibly succeed. Always decided. */
53
61
  readonly retryable: boolean;
54
62
  /** Who can fix the failure: `input`, `config` or `runtime`. Always decided. */
55
63
  readonly errorDomain: ErrorDomain;
64
+ /**
65
+ * Whether the failed request may still have started a run whose id never reached the caller:
66
+ * a `start` or an `execute` (and so `startAndWaitForResult`'s start, or the blocking execute it
67
+ * falls back to) that failed in a way that does not prove the server started nothing. When it
68
+ * is true, `retryable` is false: look the run up in the run history before starting it again.
69
+ * False for every other request, a wait on a run already named included. Always decided.
70
+ */
71
+ readonly runMayHaveStarted: boolean;
56
72
  constructor(message: string, verdict: ErrorVerdict, options?: {
57
73
  cause?: unknown;
74
+ runMayHaveStarted?: boolean;
58
75
  });
59
76
  }
60
77
  /**
@@ -70,6 +87,16 @@ export declare abstract class PipelexRequestError extends PipelineRequestError i
70
87
  * for what it asks is a `RequestArgumentError`, which carries one.
71
88
  */
72
89
  export declare function errorVerdictOf(err: unknown): ErrorVerdict | undefined;
90
+ /**
91
+ * Whether anything a `catch` holds is a failed run start that may still have started a run: true
92
+ * only for an `Error` carrying `runMayHaveStarted` as `true`.
93
+ *
94
+ * The check is structural, as `errorVerdictOf`'s is, so it reads an error raised by another copy
95
+ * of this SDK installed beside this one. Anything else is false: an error of a request that
96
+ * cannot start a run, an `mthds` error, which the standard's client never raises over a start of
97
+ * this SDK, and a value that is not an `Error`.
98
+ */
99
+ export declare function runMayHaveStartedOf(err: unknown): boolean;
73
100
  /**
74
101
  * The SDK refused a call's arguments before sending any request: no run source given to
75
102
  * `execute()` or `start()`, run sources or method selectors that exclude each other, a selector
@@ -148,6 +175,35 @@ export declare class InvalidInputValueError extends InputPreparationError {
148
175
  cause?: unknown;
149
176
  });
150
177
  }
178
+ /**
179
+ * What a value refused under `allowUploads: false` is, in a closed vocabulary a caller branches on
180
+ * rather than on the message: `local_path` — a string that is neither an `http(s)` URL nor a
181
+ * `pipelex-storage://` reference, which preparation would read from disk; `data_url` — a `data:`
182
+ * URL, which it would decode and upload; `bytes` — a `Blob`, `File`, `ArrayBuffer` or `Uint8Array`.
183
+ */
184
+ export type UploadNotAllowedKind = "local_path" | "data_url" | "bytes";
185
+ /**
186
+ * `prepareInputs` was called with `allowUploads: false`, and a value at a file input would need an
187
+ * upload: a local path, a `data:` URL or bytes. It is raised before anything is read from disk,
188
+ * decoded or sent to the upload route, so a server preparing inputs on a caller's behalf never
189
+ * reads a file of its own because the caller named it. `inputName` is the input the value belongs
190
+ * to, `inputPath` where it sits inside that input (`report.attachments[1]`, or the name alone for a
191
+ * top-level file), and `valueKind` what it is. The value itself is neither in the message nor on
192
+ * the error, since it is the caller's data. Its verdict is `input`, not retryable: the caller must
193
+ * pass an `http(s)` URL or a `pipelex-storage://` reference instead.
194
+ */
195
+ export declare class UploadNotAllowedError extends InputPreparationError {
196
+ readonly inputName: string;
197
+ readonly inputPath: string;
198
+ readonly valueKind: UploadNotAllowedKind;
199
+ constructor(details: {
200
+ inputName: string;
201
+ inputPath: string;
202
+ valueKind: UploadNotAllowedKind;
203
+ }, options?: {
204
+ cause?: unknown;
205
+ });
206
+ }
151
207
  /**
152
208
  * The pipe I/O answer said the method does not load (`is_valid: false`), so its signature cannot
153
209
  * be read and no input can be prepared: the method, not the inputs, must change.
@@ -376,12 +432,19 @@ export declare class ArtifactAuthenticationError extends ArtifactOperationError
376
432
  * attempt can get through. With the code `ABORT_TIMEOUT`, the SDK's own request timeout, it is
377
433
  * `runtime` and retryable instead: the API took the request and did not answer in time, which is
378
434
  * no fault of the base URL.
435
+ *
436
+ * On a request that may create a run (`options.mayStartRun`, which the client sets on `start` and
437
+ * `execute`), `runMayHaveStarted` is true unless `cause`, the failure fetch threw, proves the
438
+ * request never left: the name lookup, the connection or the TLS handshake failed. A reset, a time
439
+ * limit or a body that could not be decoded proves nothing, so the run may have started and the
440
+ * error is not retryable.
379
441
  */
380
442
  export declare class ApiUnreachableError extends PipelexRequestError {
381
443
  readonly apiUrl: string;
382
444
  readonly code: string | undefined;
383
445
  constructor(message: string, apiUrl: string, code: string | undefined, options?: {
384
446
  cause?: unknown;
447
+ mayStartRun?: boolean;
385
448
  });
386
449
  }
387
450
  /**
@@ -391,7 +454,8 @@ export declare class ApiUnreachableError extends PipelexRequestError {
391
454
  * lifecycle (start + poll) instead.
392
455
  *
393
456
  * Its verdict is `input`, not retryable: asking again meets the same limit, and the caller fixes
394
- * it by starting the run and polling.
457
+ * it by starting the run and polling. `runMayHaveStarted` is always true: the gateway gave up on
458
+ * the request, and the run it carried goes on without its id reaching the caller.
395
459
  */
396
460
  export declare class PipelineExecuteTimeoutError extends PipelexRequestError {
397
461
  readonly elapsedMs: number;
@@ -407,15 +471,21 @@ export declare class PipelineExecuteTimeoutError extends PipelexRequestError {
407
471
  *
408
472
  * - `status` is the run's terminal status, read from the problem's `run_status` member, or from
409
473
  * its `detail` sentence on a platform that predates the member.
410
- * - `error` is the run's stored error report, typed whole as `RunErrorReport`: the runner's
411
- * `error_type`, `message`, `title`, `type_uri`, `error_domain`, `error_category`,
412
- * `retryable`, `user_action`, `model`, `provider`, `provider_metadata`, `validation_errors`
413
- * and anything newer through its index signature. Branch on `error.error_domain`,
414
- * `error.type_uri` and `error.retryable`; show `error.user_action` as the next step. It is
415
- * the runner's VERBOSE report, so `message` and `provider_metadata` can hold a provider's raw
416
- * text — deciding what a person sees is the consumer's. `null` when the run ended with no
417
- * stored report (a cancelled, terminated or timed-out run, or one the platform finalized
418
- * itself).
474
+ * - `error` is the run's stored error report as the platform serves it, typed whole as
475
+ * `RunErrorReport`: the runner's `error_type`, `message`, `title`, `type_uri`, `error_domain`,
476
+ * `error_category`, `retryable`, `user_action`, `provider_metadata`, `caller_facing_message`,
477
+ * `validation_errors` and anything newer through its index signature. Branch on
478
+ * `error.error_domain`, `error.type_uri` and `error.retryable`; show `error.user_action` as the
479
+ * next step. The platform serves the runner's STRICT projection, so `message` is the author's
480
+ * copy only when `caller_facing_message` is `true` and the placeholder
481
+ * `An internal error occurred.` otherwise, `user_action` comes only with caller-facing copy,
482
+ * `provider_metadata` keeps only `status_code` and `retry_after_seconds`, and `model`,
483
+ * `provider` and `migration` are absent; deciding what a person sees is still the consumer's.
484
+ * A run the platform ended or settled itself carries the caller-facing report the platform
485
+ * wrote, in the same shape. A cancelled, terminated or timed-out run carries a report when a
486
+ * completion callback carried one, and a timed-out run otherwise the platform's timeout report.
487
+ * `null` when the run ended with no stored report (one whose start failed, or one cancelled,
488
+ * terminated or given its status by hand with no completion callback carrying a report).
419
489
  * - The error's own `message` is the problem's `detail`, which names the status and then the
420
490
  * report's message (`Run finished with status FAILED: <message>`), so printing the error
421
491
  * already tells the reason.
@@ -535,13 +605,21 @@ export declare class PagingNotTerminatingError extends PipelexRequestError {
535
605
  export type MethodErrorCode = "method_update_conflict" | "method_being_deleted" | "method_not_published" | "method_version_not_found";
536
606
  /**
537
607
  * The last constructor argument of `ApiResponseError`: the error's `cause`, the problem
538
- * document's typed members, and the decoded document whole. The same shape as `mthds`'s
539
- * `ApiResponseErrorOptions`, plus `problemDocument`.
608
+ * document's typed members, the decoded document whole, and whether the request that met the
609
+ * answer may create a run. The same shape as `mthds`'s `ApiResponseErrorOptions`, plus
610
+ * `problemDocument` and `mayStartRun`.
540
611
  */
541
612
  export interface ApiResponseErrorOptions {
542
613
  cause?: unknown;
543
614
  problem?: ProblemDetails;
544
615
  problemDocument?: Record<string, unknown>;
616
+ /**
617
+ * The request was a `start` or an `execute`, so the answer is read for whether it may have
618
+ * started a run (see `ApiResponseError.runMayHaveStarted`). The client sets it on those two
619
+ * routes alone; a consumer building the error by hand sets it to get the verdict the client
620
+ * would give.
621
+ */
622
+ mayStartRun?: boolean;
545
623
  }
546
624
  /**
547
625
  * A response that DID come back from the API and that the SDK cannot hand back as a result: a
@@ -568,6 +646,14 @@ export interface ApiResponseErrorOptions {
568
646
  * stored report that says nothing is not, since the caller or the environment must change,
569
647
  * while `runtime` takes the fallback's. Nothing on the error says which a value came from:
570
648
  * `problemDocument` keeps what the server sent.
649
+ * - **A run that may have started.** On a `start` or an `execute`, `runMayHaveStarted` says
650
+ * whether the answer leaves a run possibly started without its id reaching the caller: any
651
+ * `2xx` the SDK could not read, a `408`, and every `5xx` but a `501` and the platform's `503`
652
+ * coded `pipeline_start_unavailable`, which says the runner was never reached. Then
653
+ * `retryable` is false, whatever the server sent: asking again could start a second run. A
654
+ * runner's own failure of a blocking execute reads the same, since the SDK cannot tell a run
655
+ * that ended from one that goes on, and its `retryable` stays readable on `problemDocument`.
656
+ * On every other route it is false.
571
657
  * - **The branch fields.** `errorDomain`, and `type`, the stable URI naming the error class.
572
658
  * Branch on these, never on the HTTP status or on the wording of a message; they are the
573
659
  * fields that mean the same on both surfaces.
@@ -636,7 +722,13 @@ export declare class ApiResponseError extends PipelexRequestError {
636
722
  readonly model: string | undefined;
637
723
  /** The body's `provider`: the provider an inference failure reached. */
638
724
  readonly provider: string | undefined;
639
- /** The body's `provider_metadata`: what the provider's SDK said, raw text included. */
725
+ /**
726
+ * The body's `provider_metadata`: what the provider's SDK said. On the hosted API it comes
727
+ * from the runner's problem document, which the hosted runner renders under its STRICT
728
+ * disclosure, so it keeps only `status_code` and `retry_after_seconds`; a runner that
729
+ * discloses errors VERBOSE, as a self-hosted one does when `ERROR_DISCLOSURE` is unset, sends
730
+ * it whole, the provider's raw text included.
731
+ */
640
732
  readonly providerMetadata: ProviderErrorMetadata | undefined;
641
733
  /** The body's `migration`: a pending configuration migration that explains the failure. */
642
734
  readonly migration: MigrationErrorBlock | undefined;