@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.
- package/README.md +4 -4
- package/dist/cli/run.js +8 -111
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/script.d.ts +1 -1
- package/dist/client.d.ts +33 -10
- package/dist/client.js +111 -44
- package/dist/client.js.map +1 -1
- package/dist/error-models.d.ts +64 -18
- package/dist/error-models.js +20 -9
- package/dist/error-models.js.map +1 -1
- package/dist/errors.d.ts +114 -22
- package/dist/errors.js +114 -21
- package/dist/errors.js.map +1 -1
- package/dist/execute-result.js +4 -4
- package/dist/execute-result.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/prepare-inputs.d.ts +13 -0
- package/dist/prepare-inputs.js +86 -41
- package/dist/prepare-inputs.js.map +1 -1
- package/dist/product-models.d.ts +13 -5
- package/dist/run-may-have-started.d.ts +31 -0
- package/dist/run-may-have-started.js +138 -0
- package/dist/run-may-have-started.js.map +1 -0
- package/dist/runs.d.ts +95 -7
- package/dist/runs.js +18 -0
- package/dist/runs.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/architecture.md +3 -2
- package/docs/cli.md +1 -1
- package/docs/errors.md +85 -16
- package/docs/input-preparation.md +18 -0
- package/docs/run-results.md +39 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -134,7 +134,7 @@ try {
|
|
|
134
134
|
|
|
135
135
|
### Errors
|
|
136
136
|
|
|
137
|
-
Every error the SDK throws carries a verdict: `retryable`, whether asking again can succeed, and `errorDomain`, who can fix the failure (`input` for the caller, `config` for a change to the environment such as the credential, the plan or the base URL, `runtime` for nobody beforehand). Both are always decided, and `errorVerdictOf` reads them from anything a `catch` holds, returning `undefined` for what is not an SDK error, such as a bug in the calling code or your own abort.
|
|
137
|
+
Every error the SDK throws carries a verdict: `retryable`, whether asking again can succeed, and `errorDomain`, who can fix the failure (`input` for the caller, `config` for a change to the environment such as the credential, the plan or the base URL, `runtime` for nobody beforehand). Both are always decided, and `errorVerdictOf` reads them from anything a `catch` holds, returning `undefined` for what is not an SDK error, such as a bug in the calling code or your own abort. A failed `start` or blocking `execute` also says whether it may have created a run anyway, as `runMayHaveStarted`, read with `runMayHaveStartedOf`: when it is `true`, `retryable` is `false`, since asking again could start a second paid run, and the person should look the run up in the run history first ([`docs/errors.md`](./docs/errors.md#a-failed-run-start--runmayhavestarted)).
|
|
138
138
|
|
|
139
139
|
```ts
|
|
140
140
|
import { errorVerdictOf } from "@pipelex/sdk";
|
|
@@ -152,7 +152,7 @@ try {
|
|
|
152
152
|
|
|
153
153
|
A refused request throws an `ApiResponseError` carrying every member of the server's RFC 9457 problem document. **Branch on `errorDomain` and `type`**, as the hosted-envelope spec says, never on the HTTP status or the message: `errorDomain` is the verdict's domain and `type` is the stable URI of the error class, the same on every occurrence. The verdict is the server's when it sent a valid one, and otherwise the SDK's fallback, read from the status, except that an `input` or `config` domain the server sent without `retryable` is not retryable; `problemDocument` keeps what the server sent. `userAction` gives the next step, and `requestId` — from the body, or the `X-Request-ID` header — is the id to hand to support. `code` (the platform's native code, one-to-one with `type`) and `errorType` (the runner's exception class name) are each surface's finer code, and a client of that surface may branch on it too: on the platform's own refusals `code` and `type` read the same answer, `MethodErrorCode` naming the codes a method caller branches on, while a refusal the platform relays from the runner carries the runner's `type` and `errorType` and no `code`. `errors` carries the platform's field-level failures.
|
|
154
154
|
|
|
155
|
-
On the hosted API, a run that ends without completing throws a `RunFailedError` from `waitForResult`, `startAndWaitForResult` and `downloadArtifacts`, and comes back as the `failed` arm of `getRunResult`. (Against a bare `pipelex-api` runner, `startAndWaitForResult` runs the method with the blocking `execute`, so a failed run there throws the runner's `ApiResponseError`, whose problem members carry the same classification.) Its `status` is the run's terminal status and its `error` is the run's stored error report, checked field by field and typed as `RunErrorReport`: the reason in `message`, `error_domain`, `type_uri` and `retryable` to branch on, `user_action` as the next step, and the
|
|
155
|
+
On the hosted API, a run that ends without completing throws a `RunFailedError` from `waitForResult`, `startAndWaitForResult` and `downloadArtifacts`, and comes back as the `failed` arm of `getRunResult`. (Against a bare `pipelex-api` runner, `startAndWaitForResult` runs the method with the blocking `execute`, so a failed run there throws the runner's `ApiResponseError`, whose problem members carry the same classification.) Its `status` is the run's terminal status and its `error` is the run's stored error report, checked field by field and typed as `RunErrorReport`: the reason in `message`, `error_domain`, `type_uri` and `retryable` to branch on, `user_action` as the next step, and the provider's answer in `provider_metadata`'s `status_code` and `retry_after_seconds`. It is `null` when the run ended without a report, and the error's own verdict comes from it: the report's domain, and retryable only when the report says so. The platform serves the runner's STRICT projection of the report: `message` is the author's copy when `caller_facing_message` is `true` and `An internal error occurred.` otherwise, `user_action` comes only with caller-facing copy, and the model, the provider and the provider's own text are left out, so `message` can be shown as it comes and what a person sees is still your presentation:
|
|
156
156
|
|
|
157
157
|
```ts
|
|
158
158
|
import { RunFailedError } from "@pipelex/sdk";
|
|
@@ -216,8 +216,8 @@ These pages ship inside the published package, so a reader who has only installe
|
|
|
216
216
|
## Develop
|
|
217
217
|
|
|
218
218
|
```bash
|
|
219
|
-
make install # Install dependencies
|
|
220
|
-
make check #
|
|
219
|
+
make install # Install the dependencies from the lockfile (npm ci, which never rewrites it)
|
|
220
|
+
make check # Lockfile check + lint + format check + typecheck + build + depcruise (alias: make c)
|
|
221
221
|
make test # Run the test suite (alias: make t)
|
|
222
222
|
make all # Clean, check, and test
|
|
223
223
|
```
|
package/dist/cli/run.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* as soon as the run exists; and the main output reaches stdout once the run completes, however
|
|
9
9
|
* long that takes.
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
11
|
+
import { MissingMainStuffError, RunFailedError, renderInputsTemplate, runMayHaveStartedOf, } from "../index.js";
|
|
12
12
|
import { parseFlags } from "./args.js";
|
|
13
13
|
import { readBundle } from "./bundle.js";
|
|
14
14
|
import { makeClient, readPollInterval } from "./environment.js";
|
|
@@ -75,7 +75,7 @@ export async function runCommandRun(args, io) {
|
|
|
75
75
|
onStarting: () => {
|
|
76
76
|
// Only once a request that may create a run is about to leave: an interrupt before
|
|
77
77
|
// it, during the version handshake included, starts nothing, and the command says so.
|
|
78
|
-
stage = { kind: "starting"
|
|
78
|
+
stage = { kind: "starting" };
|
|
79
79
|
},
|
|
80
80
|
onStarted: (ack) => {
|
|
81
81
|
if (io.interrupt.aborted)
|
|
@@ -122,120 +122,17 @@ function waitedOnRun(stage, error) {
|
|
|
122
122
|
return undefined;
|
|
123
123
|
return stage.runId;
|
|
124
124
|
}
|
|
125
|
-
/**
|
|
126
|
-
* Whether a transport failure proves the request never left, so that no run was created by it: it
|
|
127
|
-
* names a step of the connection's set-up, which no request follows. That is the name lookup or
|
|
128
|
-
* the connection itself failing (the system calls `getaddrinfo` and `connect`: an unknown host, a
|
|
129
|
-
* refused connection, no route to the host or the network, the system's connect time limit),
|
|
130
|
-
* undici's own connect time limit, which covers the TLS handshake, and a server certificate the
|
|
131
|
-
* TLS handshake refused. Several addresses each failing so, which Node reports together as an
|
|
132
|
-
* `AggregateError`, prove it too. A host that drops packets is a connection that never comes:
|
|
133
|
-
* undici gives it up after ten seconds (`UND_ERR_CONNECT_TIMEOUT`), before the time limit of any
|
|
134
|
-
* request the command sends, as the Python command meets httpx's connect timeout first and reads
|
|
135
|
-
* it the same way.
|
|
136
|
-
*
|
|
137
|
-
* Anything else may have come once the request had left, the Python command reading the same
|
|
138
|
-
* failures the same way. A reset (`ECONNRESET`) comes from a `read` whether the connection dropped
|
|
139
|
-
* during the TLS handshake or after the request, and so does an `EHOSTUNREACH` met once connected,
|
|
140
|
-
* so neither proves anything; nor does another TLS failure, which may come after the handshake;
|
|
141
|
-
* nor does the SDK's own time limit (`ABORT_TIMEOUT`), which fetch cannot place before or after
|
|
142
|
-
* the connection was made. Every request the command sends has a limit longer than undici's
|
|
143
|
-
* connect limit, so with Node's own dispatcher it runs out only once the request has left.
|
|
144
|
-
*/
|
|
145
|
-
function provesNothingSent(error) {
|
|
146
|
-
// The SDK keeps fetch's own failure as `cause`, and undici gives the transport's under it.
|
|
147
|
-
const fetchFailure = error.cause;
|
|
148
|
-
return fetchFailure instanceof Error && isConnectionSetupFailure(fetchFailure.cause);
|
|
149
|
-
}
|
|
150
|
-
function isConnectionSetupFailure(failure) {
|
|
151
|
-
if (failure instanceof AggregateError) {
|
|
152
|
-
return failure.errors.length > 0 && failure.errors.every(isConnectionSetupFailure);
|
|
153
|
-
}
|
|
154
|
-
if (typeof failure !== "object" || failure === null)
|
|
155
|
-
return false;
|
|
156
|
-
const { code, syscall } = failure;
|
|
157
|
-
if (typeof code === "string" && CONNECTION_SETUP_CODES.has(code))
|
|
158
|
-
return true;
|
|
159
|
-
return typeof syscall === "string" && CONNECTION_SETUP_CALLS.has(syscall);
|
|
160
|
-
}
|
|
161
|
-
/** The system calls that resolve the host's name and open the connection. */
|
|
162
|
-
const CONNECTION_SETUP_CALLS = new Set(["getaddrinfo", "connect"]);
|
|
163
|
-
/**
|
|
164
|
-
* The codes only a step of the connection's set-up gives: the name lookup's and the connect call's
|
|
165
|
-
* own (set even where Node reports several addresses together, without a system call), undici's
|
|
166
|
-
* connect time limit, Node's limit on one attempt among several addresses, Node's own check of the
|
|
167
|
-
* host's name, and every code Node gives a server certificate the TLS handshake refused.
|
|
168
|
-
*/
|
|
169
|
-
const CONNECTION_SETUP_CODES = new Set([
|
|
170
|
-
"ECONNREFUSED",
|
|
171
|
-
"ENOTFOUND",
|
|
172
|
-
"EAI_AGAIN",
|
|
173
|
-
"UND_ERR_CONNECT_TIMEOUT",
|
|
174
|
-
"ERR_SOCKET_CONNECTION_TIMEOUT",
|
|
175
|
-
"ERR_TLS_CERT_ALTNAME_INVALID",
|
|
176
|
-
"ERR_TLS_CERT_ALTNAME_FORMAT",
|
|
177
|
-
// Node names the verdicts of OpenSSL's certificate check from a fixed table, the "X509 certificate
|
|
178
|
-
// error codes" of its `tls` docs, and gives every other verdict, such as an unhandled critical
|
|
179
|
-
// extension or a CA certificate that may not sign certificates, the code `UNSPECIFIED`. The
|
|
180
|
-
// error carries nothing else that marks it, so these codes are the mark: the table as Node 24
|
|
181
|
-
// compiles it, in its order, then its default. The Python command reads every
|
|
182
|
-
// `ssl.SSLCertVerificationError` the same way.
|
|
183
|
-
"UNABLE_TO_GET_ISSUER_CERT",
|
|
184
|
-
"UNABLE_TO_GET_CRL",
|
|
185
|
-
"UNABLE_TO_DECRYPT_CERT_SIGNATURE",
|
|
186
|
-
"UNABLE_TO_DECRYPT_CRL_SIGNATURE",
|
|
187
|
-
"UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY",
|
|
188
|
-
"CERT_SIGNATURE_FAILURE",
|
|
189
|
-
"CRL_SIGNATURE_FAILURE",
|
|
190
|
-
"CERT_NOT_YET_VALID",
|
|
191
|
-
"CERT_HAS_EXPIRED",
|
|
192
|
-
"CRL_NOT_YET_VALID",
|
|
193
|
-
"CRL_HAS_EXPIRED",
|
|
194
|
-
"ERROR_IN_CERT_NOT_BEFORE_FIELD",
|
|
195
|
-
"ERROR_IN_CERT_NOT_AFTER_FIELD",
|
|
196
|
-
"ERROR_IN_CRL_LAST_UPDATE_FIELD",
|
|
197
|
-
"ERROR_IN_CRL_NEXT_UPDATE_FIELD",
|
|
198
|
-
"OUT_OF_MEM",
|
|
199
|
-
"DEPTH_ZERO_SELF_SIGNED_CERT",
|
|
200
|
-
"SELF_SIGNED_CERT_IN_CHAIN",
|
|
201
|
-
"UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
|
|
202
|
-
"UNABLE_TO_VERIFY_LEAF_SIGNATURE",
|
|
203
|
-
"CERT_CHAIN_TOO_LONG",
|
|
204
|
-
"CERT_REVOKED",
|
|
205
|
-
"INVALID_CA",
|
|
206
|
-
"PATH_LENGTH_EXCEEDED",
|
|
207
|
-
"INVALID_PURPOSE",
|
|
208
|
-
"CERT_UNTRUSTED",
|
|
209
|
-
"CERT_REJECTED",
|
|
210
|
-
"HOSTNAME_MISMATCH",
|
|
211
|
-
"UNSPECIFIED",
|
|
212
|
-
]);
|
|
213
125
|
/**
|
|
214
126
|
* Whether a failure met once a request that may create a run was sent, and before the API named
|
|
215
|
-
* the run, leaves it unknown whether one was created
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
* the SDK's `isGatewayCutOff` tells it, past its threshold, from the time since `onStarting`. Any
|
|
221
|
-
* other answer from the API, a `503` that came back before that saying the request was not handled
|
|
222
|
-
* included, and a failure that proves nothing was sent, say no run was created.
|
|
127
|
+
* the run, leaves it unknown whether one was created. The SDK decides it on the error it raises
|
|
128
|
+
* (`runMayHaveStarted`): its answer was lost to a time limit, a connection that closed once the
|
|
129
|
+
* request had left or a gateway that cut the request off, it came back unreadable, or the server
|
|
130
|
+
* or a gateway failed while handling it. A failure that proves nothing was sent, and an answer
|
|
131
|
+
* refusing the request before anything ran, say no run was created.
|
|
223
132
|
*/
|
|
224
133
|
function mayHaveStarted(stage, error) {
|
|
225
|
-
|
|
226
|
-
return false;
|
|
227
|
-
if (error instanceof PipelineExecuteTimeoutError)
|
|
228
|
-
return true;
|
|
229
|
-
if (error instanceof ApiUnreachableError)
|
|
230
|
-
return !provesNothingSent(error);
|
|
231
|
-
if (!(error instanceof ApiResponseError))
|
|
232
|
-
return false;
|
|
233
|
-
if (error.status >= 200 && error.status < 300)
|
|
234
|
-
return true;
|
|
235
|
-
return (GATEWAY_LOST_ANSWER.has(error.status) || isGatewayCutOff(error, performance.now() - stage.since));
|
|
134
|
+
return stage.kind === "starting" && runMayHaveStartedOf(error);
|
|
236
135
|
}
|
|
237
|
-
/** The gateway statuses that say the server's answer was lost or never came (RFC 9110). */
|
|
238
|
-
const GATEWAY_LOST_ANSWER = new Set([502, 504]);
|
|
239
136
|
/** The line under a failure that leaves it unknown whether a run was created. */
|
|
240
137
|
export const RUN_MAY_HAVE_STARTED_LINE = "A run may have started on the server without the command learning of it, so check before starting it again.";
|
|
241
138
|
/** The line under a failure met while waiting on a run that exists. */
|
package/dist/cli/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,UAAU,GACX,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAGvE,MAAM,SAAS,GAAG;IAChB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC1B,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IACxB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC1B,iBAAiB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;CAC9B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CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,OAAO,CACpB,MAAwB,EACxB,MAAoB,EACpB,IAAwB,EACxB,MAA2C,EAC3C,EAAa;IAEb,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC;IAC5E,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CACrC,GAAG,EAAE,CACH,MAAM,CAAC,aAAa,CAAC;QACnB,GAAG,aAAa,CAAC,MAAM,CAAC;QACxB,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QACjD,MAAM;QACN,wEAAwE;QACxE,MAAM,EAAE,EAAE,CAAC,SAAS;KACrB,CAAC,EACJ,EAAE,CAAC,SAAS,CACb,CAAC;IACF,KAAK,MAAM,MAAM,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACtC,EAAE,CAAC,WAAW,CAAC,YAAY,MAAM,CAAC,QAAQ,OAAO,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,QAAQ,CAAC,MAAM,CAAC;AACzB,CAAC;AAED,sDAAsD;AACtD,SAAS,gBAAgB,CAAC,KAAY,EAAE,YAAqB;IAC3D,IAAI,YAAY;QAAE,OAAO,cAAc,CAAC;IACxC,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,OAAO;YACV,OAAO,kCAAkC,CAAC;QAC5C,KAAK,UAAU;YACb,OAAO,qGAAqG,CAAC;QAC/G,KAAK,SAAS;YACZ,OAAO,oBAAoB,KAAK,CAAC,KAAK,6BAA6B,CAAC;IACxE,CAAC;AACH,CAAC"}
|
package/dist/cli/script.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ import type { CommandIO } from "./io.js";
|
|
|
15
15
|
* update notice and npm 12's run notices off the script's stderr, which carries the command's
|
|
16
16
|
* own lines, while npm's warnings and errors still print.
|
|
17
17
|
*/
|
|
18
|
-
export declare const SCRIPT_RUNNER = "npx --yes --no-update-notifier --loglevel=warn @pipelex/sdk@0.
|
|
18
|
+
export declare const SCRIPT_RUNNER = "npx --yes --no-update-notifier --loglevel=warn @pipelex/sdk@0.39.0";
|
|
19
19
|
export declare const SCRIPT_WRITER = "@pipelex/sdk";
|
|
20
20
|
export declare const SCRIPT_NEEDS = "Node 22.12 or later";
|
|
21
21
|
/** Run `pipelex-sdk script` and return its exit code. */
|
package/dist/client.d.ts
CHANGED
|
@@ -161,7 +161,8 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
|
|
|
161
161
|
* DNS/connect/TLS/timeout failures as `ApiUnreachableError`; a caller-driven
|
|
162
162
|
* abort (Ctrl-C / agent walk-away) propagates as-is so the poll loop can stop
|
|
163
163
|
* cleanly. Non-2xx interpretation is left to the caller. `url` is a fully
|
|
164
|
-
* resolved absolute URL.
|
|
164
|
+
* resolved absolute URL. `mayStartRun` marks a request that may create a run,
|
|
165
|
+
* whose `ApiUnreachableError` then says whether it may have (see `RunCreation`).
|
|
165
166
|
*/
|
|
166
167
|
private requestRaw;
|
|
167
168
|
/**
|
|
@@ -230,6 +231,7 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
|
|
|
230
231
|
* `API <method> <path> answered <status> with <what>`: the answer's status, its raw text as
|
|
231
232
|
* `responseBody`, no problem member but the `X-Request-ID` header, the failure that made it
|
|
232
233
|
* unreadable as `cause`, and the verdict the fallback gives a 2xx, `runtime` and not retryable.
|
|
234
|
+
* On a request that may create a run, the run may have started: the server accepted it.
|
|
233
235
|
*/
|
|
234
236
|
private unreadableAnswer;
|
|
235
237
|
/**
|
|
@@ -249,6 +251,11 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
|
|
|
249
251
|
* error. Hosted does not emit 202 today, but the protocol permits it;
|
|
250
252
|
* raising a typed error (with the `pipeline_run_id` + `Location` + `Retry-After`
|
|
251
253
|
* hints) beats a generic parse failure on an unexpected body shape.
|
|
254
|
+
*
|
|
255
|
+
* The 202 must name the run it accepted, as `start`'s acknowledgement must: one whose body is
|
|
256
|
+
* not JSON, or names no run (an empty id included), leaves the caller a run it cannot follow, so it is an answer the
|
|
257
|
+
* SDK cannot read, which may have started a run, never a `RunStillRunningError` without an id.
|
|
258
|
+
* The Python SDK reads the same answers the same way.
|
|
252
259
|
*/
|
|
253
260
|
private throwIfExecuteDegraded;
|
|
254
261
|
/**
|
|
@@ -538,12 +545,17 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
|
|
|
538
545
|
* Fetch a run's status by bare id — `GET /v1/runs/{pipeline_run_id}/status`.
|
|
539
546
|
*
|
|
540
547
|
* Self-healing: a finished-but-unrecorded run resolves to its true terminal
|
|
541
|
-
* status on read. `degraded: true` means
|
|
542
|
-
* `
|
|
543
|
-
*
|
|
544
|
-
* is
|
|
545
|
-
*
|
|
546
|
-
*
|
|
548
|
+
* status on read. `degraded: true` means the read is not a plain fresh reading,
|
|
549
|
+
* and `degradation.reason` says why (see `DegradationReason`):
|
|
550
|
+
* `status_unavailable` when the platform could not reach the workflow engine
|
|
551
|
+
* and `status` is the last one recorded, `workflow_task_failing` when `status`
|
|
552
|
+
* is live and the run is stuck, its workflow task failing until the platform
|
|
553
|
+
* ends it at `degradation.ends_at`. `retry_after_seconds` carries the server's
|
|
554
|
+
* `Retry-After` hint when present, and `request_id` the id to quote to support.
|
|
555
|
+
* A failed run's stored report, `error`, and the `degradation` are each
|
|
556
|
+
* checked field by field (see `RunErrorReport` and `RunDegradation`), so
|
|
557
|
+
* neither ever fails the read. Throws `RunLifecycleUnavailableError` when the
|
|
558
|
+
* lifecycle routes are absent (a bare runner).
|
|
547
559
|
*/
|
|
548
560
|
getRunStatus(runId: string, options?: {
|
|
549
561
|
signal?: AbortSignal;
|
|
@@ -609,6 +621,13 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
|
|
|
609
621
|
* `pollOptions.signal` is also read before the run is created: a caller that aborts while the
|
|
610
622
|
* version handshake is in flight gets its abort, and neither the start nor the blocking execute
|
|
611
623
|
* is sent. Once one of them is sent, the abort stops only the wait.
|
|
624
|
+
*
|
|
625
|
+
* An error from the start, or from the blocking execute, says whether that request may still
|
|
626
|
+
* have started a run whose id never reached the caller (`runMayHaveStarted`); when it may have,
|
|
627
|
+
* it is not retryable, since calling this method again could pay for the run twice: look the run
|
|
628
|
+
* up in the run history first. An error from the wait, once `onStarted` has named the run,
|
|
629
|
+
* started nothing, so its `runMayHaveStarted` is false, and its `retryable` is about waiting
|
|
630
|
+
* again on that id with `waitForResult`, never about calling this method again.
|
|
612
631
|
*/
|
|
613
632
|
startAndWaitForResult(options: PipelexStartOptions, pollOptions?: StartAndWaitForResultOptions): Promise<RunResults>;
|
|
614
633
|
/** The authenticated user's profile — `GET /v1/me`. */
|
|
@@ -956,6 +975,9 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
|
|
|
956
975
|
* answers with, which states the kind of every input at every depth, so a file
|
|
957
976
|
* position is a fact of the method, never a guess from the value's shape. It
|
|
958
977
|
* needs an API serving `POST /v1/pipe-io`. See `docs/input-preparation.md`.
|
|
978
|
+
*
|
|
979
|
+
* With `allowUploads: false` it uploads nothing and reads no file: a value that
|
|
980
|
+
* would need an upload throws `UploadNotAllowedError`, naming the input.
|
|
959
981
|
*/
|
|
960
982
|
prepareInputs(request: PrepareInputsRequest): Promise<PreparedInputs>;
|
|
961
983
|
/**
|
|
@@ -1050,8 +1072,9 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
|
|
|
1050
1072
|
* `is_gateway_cut_off` reads the same failures, its `ABORT_TIMEOUT` being httpx's read or write
|
|
1051
1073
|
* timeout.
|
|
1052
1074
|
*
|
|
1053
|
-
* The blocking `execute` turns such a failure into a `PipelineExecuteTimeoutError`.
|
|
1054
|
-
*
|
|
1055
|
-
* reads
|
|
1075
|
+
* The blocking `execute` turns such a failure into a `PipelineExecuteTimeoutError`. Whether a
|
|
1076
|
+
* failed `start` or `execute` may have started a run needs no timing: the error says it as
|
|
1077
|
+
* `runMayHaveStarted`, which reads every `503` but the platform's coded one as a run that may
|
|
1078
|
+
* have started, however quickly it came back.
|
|
1056
1079
|
*/
|
|
1057
1080
|
export declare function isGatewayCutOff(error: unknown, elapsedMs: number): boolean;
|