@pipelex/sdk 0.38.0 → 0.40.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 (52) hide show
  1. package/README.md +3 -2
  2. package/dist/bundle-resources.d.ts +62 -0
  3. package/dist/bundle-resources.js +165 -0
  4. package/dist/bundle-resources.js.map +1 -0
  5. package/dist/cli/run.js +8 -111
  6. package/dist/cli/run.js.map +1 -1
  7. package/dist/cli/script.d.ts +1 -1
  8. package/dist/cli/source.d.ts +2 -1
  9. package/dist/cli/source.js +61 -3
  10. package/dist/cli/source.js.map +1 -1
  11. package/dist/client.d.ts +116 -30
  12. package/dist/client.js +235 -75
  13. package/dist/client.js.map +1 -1
  14. package/dist/error-models.d.ts +64 -18
  15. package/dist/error-models.js +20 -9
  16. package/dist/error-models.js.map +1 -1
  17. package/dist/errors.d.ts +125 -23
  18. package/dist/errors.js +124 -22
  19. package/dist/errors.js.map +1 -1
  20. package/dist/execute-result.js +4 -4
  21. package/dist/execute-result.js.map +1 -1
  22. package/dist/hooks/bundle-gather.d.ts +28 -1
  23. package/dist/hooks/bundle-gather.js +163 -3
  24. package/dist/hooks/bundle-gather.js.map +1 -1
  25. package/dist/hooks/claude-mthds-check.d.ts +4 -2
  26. package/dist/hooks/claude-mthds-check.js +5 -2
  27. package/dist/hooks/claude-mthds-check.js.map +1 -1
  28. package/dist/index.d.ts +7 -5
  29. package/dist/index.js +6 -2
  30. package/dist/index.js.map +1 -1
  31. package/dist/models.d.ts +42 -4
  32. package/dist/prepare-inputs.d.ts +58 -4
  33. package/dist/prepare-inputs.js +307 -61
  34. package/dist/prepare-inputs.js.map +1 -1
  35. package/dist/product-models.d.ts +13 -5
  36. package/dist/run-may-have-started.d.ts +31 -0
  37. package/dist/run-may-have-started.js +138 -0
  38. package/dist/run-may-have-started.js.map +1 -0
  39. package/dist/runs.d.ts +95 -7
  40. package/dist/runs.js +18 -0
  41. package/dist/runs.js.map +1 -1
  42. package/dist/version.d.ts +1 -1
  43. package/dist/version.js +1 -1
  44. package/docs/architecture.md +6 -3
  45. package/docs/bundle-resources.md +107 -0
  46. package/docs/cli.md +2 -1
  47. package/docs/crate-routes.md +5 -1
  48. package/docs/errors.md +87 -17
  49. package/docs/hook-bundle.md +2 -0
  50. package/docs/input-preparation.md +26 -4
  51. package/docs/run-results.md +39 -0
  52. package/package.json +2 -2
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. "Retryable" means a retry can succeed, not that it is safe: a start answered with a `500` may already have created a run.
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 inference details. 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 report is the runner's VERBOSE one, provider text included, so what a person sees is your presentation:
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";
@@ -209,6 +209,7 @@ These pages ship inside the published package, so a reader who has only installe
209
209
  | [`docs/run-usage.md`](./docs/run-usage.md) | What a run consumed, record by record, and `summarizeUsage` which folds them into one reading |
210
210
  | [`docs/artifact-download.md`](./docs/artifact-download.md) | Turning the `pipelex-storage://` references a run produced back into bytes: `locateArtifacts`, `collectArtifacts`, `resolveArtifacts`, `fetchArtifact`, `downloadArtifacts`, and how a saved file is named after the field it fills |
211
211
  | [`docs/input-preparation.md`](./docs/input-preparation.md) | The other direction — `uploadFile` and `prepareInputs`, which turn local files into references a run can take, and the upload grant a browser page sends a file with |
212
+ | [`docs/bundle-resources.md`](./docs/bundle-resources.md) | Sending the files a bundle's steps read, such as a `PipeDocGen` step's template, as `resources` beside its `.mthds` contents: where they go, what is refused and by whom, and the template check's warnings |
212
213
  | [`docs/crate-routes.md`](./docs/crate-routes.md) | `resolve`, `codegen` and `pipeIo` — the normalized crate, the stamped types, and a method's I/O artifacts without a validation — and the offline `runCodegenCheck` that guards a committed tree |
213
214
  | [`docs/client-identification.md`](./docs/client-identification.md) | The `User-Agent` every API request carries, and `appInfo`, the option that puts your program's name in front of it |
214
215
  | [`docs/errors.md`](./docs/errors.md) | The verdict every error carries (`retryable`, `errorDomain`, `errorVerdictOf`), a failed run's stored error report on `RunFailedError` and `RunRead`, and every member of a refused request's `ApiResponseError`, with the fields to branch on |
@@ -0,0 +1,62 @@
1
+ /**
2
+ * The files a bundle's steps read, sent with the bundle as the request's `resources`.
3
+ *
4
+ * A bundle sent as content has no directory, so a file one of its steps reads from beside the
5
+ * bundle, such as a `PipeDocGen` step's `template_file`, has to travel with it. The runner takes
6
+ * such files as `resources`: a JSON object mapping each file's path, exactly as the step names it,
7
+ * relative to the bundle and written with forward slashes, to the file's bytes in standard padded
8
+ * base64. It takes them beside `mthds_contents` (or a method bundle) on `/v1/validate`,
9
+ * `/v1/execute` and `/v1/start`, and beside inline `files[]` on `/v1/pipe-io`, `/v1/resolve` and
10
+ * `/v1/codegen`. A caller hands this SDK the bytes, keyed by that path, and the SDK encodes them.
11
+ *
12
+ * The SDK refuses before any request what the runner refuses for certain about the keys, with the
13
+ * runner's own rule (`resource_path_refusal` in pipelex's `bundle_resource.py`): an empty path, a
14
+ * backslash, a colon, a NUL character, an absolute path, a `..` segment, a path naming no file,
15
+ * and two keys naming one file once `.` segments and repeated slashes collapse. Each is a
16
+ * `RequestArgumentError` naming the key, where the runner answers a `422` `InvalidResourcePath`.
17
+ * The sizes are left to the server, since a deployment configures them: 32 files, 5 MiB each and
18
+ * 10 MiB in all by default, a `413` `PayloadTooLarge` beyond, and 512 KiB in all for the `.html`
19
+ * template files, a `413` `BundleResourcesTooLargeError`. So is every rule that needs the parsed
20
+ * bundle: a file no step names is a `422` `BundleResourceNotNamedError`.
21
+ */
22
+ /** The bytes of one file a bundle's steps read: the byte forms `uploadFile` takes. */
23
+ export type BundleResourceBytes = Uint8Array | ArrayBuffer | Blob;
24
+ /**
25
+ * The files a bundle's steps read, such as a `PipeDocGen` step's template file, keyed by the path
26
+ * the step names (`templates/invoice.docx`), each as its bytes. `./templates/invoice.docx` names
27
+ * the same file, so only one of the two spellings may be given.
28
+ */
29
+ export type BundleResources = Readonly<Record<string, BundleResourceBytes>>;
30
+ /**
31
+ * Whether `resources` is a plain object, the one shape a map of paths to bytes takes: its
32
+ * prototype is `Object.prototype` or `null`. A `Map`, an array or a class instance is not one,
33
+ * and the encoder refuses it rather than reading it as a map with no file in it.
34
+ */
35
+ export declare function isResourceMap(resources: unknown): resources is Record<string, unknown>;
36
+ /**
37
+ * Whether `resources` carries at least one file. An absent, `null` or empty map carries none, so
38
+ * it is not sent, as an empty bundle encoding is not. A value that is not a plain object carries
39
+ * none either; the encoder refuses it.
40
+ */
41
+ export declare function hasBundleResources(resources: unknown): boolean;
42
+ /**
43
+ * Why `path` cannot name a file inside a bundle, or `undefined` when it can — the runner's rule,
44
+ * held by the key of a file sent with a bundle and by the path a step names.
45
+ */
46
+ export declare function bundleResourcePathRefusal(path: string): string | undefined;
47
+ /**
48
+ * The one spelling of a bundle-relative path the runner keys a file by: `.` segments and repeated
49
+ * slashes collapse, so `./templates//invoice.docx` is `templates/invoice.docx`. Only meaningful
50
+ * for a path {@link bundleResourcePathRefusal} accepts.
51
+ */
52
+ export declare function canonicalBundleResourcePath(path: string): string;
53
+ /**
54
+ * Encode `resources` for the wire: each key as given, each value as its bytes in standard padded
55
+ * base64. Returns `undefined` when there is nothing to send, so the key stays off the wire.
56
+ *
57
+ * Every key is checked before any value is read, so a refused path costs no read of a `Blob`.
58
+ *
59
+ * @throws {RequestArgumentError} `resources` is not a map of paths to bytes, a key cannot name a
60
+ * file inside the bundle, two keys name one file, or a value is not bytes.
61
+ */
62
+ export declare function encodeBundleResources(resources: BundleResources | null | undefined): Promise<Record<string, string> | undefined>;
@@ -0,0 +1,165 @@
1
+ /**
2
+ * The files a bundle's steps read, sent with the bundle as the request's `resources`.
3
+ *
4
+ * A bundle sent as content has no directory, so a file one of its steps reads from beside the
5
+ * bundle, such as a `PipeDocGen` step's `template_file`, has to travel with it. The runner takes
6
+ * such files as `resources`: a JSON object mapping each file's path, exactly as the step names it,
7
+ * relative to the bundle and written with forward slashes, to the file's bytes in standard padded
8
+ * base64. It takes them beside `mthds_contents` (or a method bundle) on `/v1/validate`,
9
+ * `/v1/execute` and `/v1/start`, and beside inline `files[]` on `/v1/pipe-io`, `/v1/resolve` and
10
+ * `/v1/codegen`. A caller hands this SDK the bytes, keyed by that path, and the SDK encodes them.
11
+ *
12
+ * The SDK refuses before any request what the runner refuses for certain about the keys, with the
13
+ * runner's own rule (`resource_path_refusal` in pipelex's `bundle_resource.py`): an empty path, a
14
+ * backslash, a colon, a NUL character, an absolute path, a `..` segment, a path naming no file,
15
+ * and two keys naming one file once `.` segments and repeated slashes collapse. Each is a
16
+ * `RequestArgumentError` naming the key, where the runner answers a `422` `InvalidResourcePath`.
17
+ * The sizes are left to the server, since a deployment configures them: 32 files, 5 MiB each and
18
+ * 10 MiB in all by default, a `413` `PayloadTooLarge` beyond, and 512 KiB in all for the `.html`
19
+ * template files, a `413` `BundleResourcesTooLargeError`. So is every rule that needs the parsed
20
+ * bundle: a file no step names is a `422` `BundleResourceNotNamedError`.
21
+ */
22
+ import { RequestArgumentError } from "./errors.js";
23
+ import { bytesToBase64 } from "./upload.js";
24
+ /**
25
+ * Whether `resources` is a plain object, the one shape a map of paths to bytes takes: its
26
+ * prototype is `Object.prototype` or `null`. A `Map`, an array or a class instance is not one,
27
+ * and the encoder refuses it rather than reading it as a map with no file in it.
28
+ */
29
+ export function isResourceMap(resources) {
30
+ if (typeof resources !== "object" || resources === null)
31
+ return false;
32
+ const prototype = Object.getPrototypeOf(resources);
33
+ return prototype === Object.prototype || prototype === null;
34
+ }
35
+ /**
36
+ * Whether `resources` carries at least one file. An absent, `null` or empty map carries none, so
37
+ * it is not sent, as an empty bundle encoding is not. A value that is not a plain object carries
38
+ * none either; the encoder refuses it.
39
+ */
40
+ export function hasBundleResources(resources) {
41
+ return isResourceMap(resources) && Object.keys(resources).length > 0;
42
+ }
43
+ /**
44
+ * Python's whitespace, the set `str.strip()` removes and `str.isspace()` accepts, which the
45
+ * runner's rule tests a path against. It differs from JavaScript's `trim()`: it holds the
46
+ * separators U+001C to U+001F and U+0085, and not the byte-order mark U+FEFF.
47
+ */
48
+ const PYTHON_WHITESPACE = new Set([
49
+ 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x85, 0xa0, 0x1680, 0x2000, 0x2001,
50
+ 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200a, 0x2028, 0x2029, 0x202f,
51
+ 0x205f, 0x3000,
52
+ ]);
53
+ /** Whether `path` holds nothing but Python's whitespace: `not path.strip()`, the runner's test. */
54
+ function isBlankForPython(path) {
55
+ for (const character of path) {
56
+ if (!PYTHON_WHITESPACE.has(character.codePointAt(0)))
57
+ return false;
58
+ }
59
+ return true;
60
+ }
61
+ /**
62
+ * Why `path` cannot name a file inside a bundle, or `undefined` when it can — the runner's rule,
63
+ * held by the key of a file sent with a bundle and by the path a step names.
64
+ */
65
+ export function bundleResourcePathRefusal(path) {
66
+ if (isBlankForPython(path))
67
+ return "it is empty";
68
+ if (path.includes("\\"))
69
+ return "it holds a backslash; write the path with forward slashes";
70
+ if (path.includes(":"))
71
+ return "it holds a colon";
72
+ if (path.includes("\0"))
73
+ return "it holds a NUL character";
74
+ if (path.startsWith("/"))
75
+ return "it is absolute; write it relative to the bundle";
76
+ const segments = pathSegments(path);
77
+ if (segments.includes(".."))
78
+ return "it leaves the bundle through a '..' segment";
79
+ if (segments.length === 0)
80
+ return "it names no file";
81
+ return undefined;
82
+ }
83
+ /**
84
+ * The one spelling of a bundle-relative path the runner keys a file by: `.` segments and repeated
85
+ * slashes collapse, so `./templates//invoice.docx` is `templates/invoice.docx`. Only meaningful
86
+ * for a path {@link bundleResourcePathRefusal} accepts.
87
+ */
88
+ export function canonicalBundleResourcePath(path) {
89
+ return pathSegments(path).join("/");
90
+ }
91
+ function pathSegments(path) {
92
+ return path.split("/").filter((segment) => segment !== "" && segment !== ".");
93
+ }
94
+ /**
95
+ * Encode `resources` for the wire: each key as given, each value as its bytes in standard padded
96
+ * base64. Returns `undefined` when there is nothing to send, so the key stays off the wire.
97
+ *
98
+ * Every key is checked before any value is read, so a refused path costs no read of a `Blob`.
99
+ *
100
+ * @throws {RequestArgumentError} `resources` is not a map of paths to bytes, a key cannot name a
101
+ * file inside the bundle, two keys name one file, or a value is not bytes.
102
+ */
103
+ export async function encodeBundleResources(resources) {
104
+ if (resources === undefined || resources === null)
105
+ return undefined;
106
+ if (!isResourceMap(resources)) {
107
+ throw new RequestArgumentError("resources must be a plain object mapping each file's path, as the step names it, to the " +
108
+ `file's bytes; got ${describeValue(resources)}.`);
109
+ }
110
+ // Read once: a second read of a proxy or a getter could differ from the one checked.
111
+ const entries = Object.entries(resources);
112
+ if (entries.length === 0)
113
+ return undefined;
114
+ const pathByCanonical = new Map();
115
+ for (const [path] of entries) {
116
+ const refusal = bundleResourcePathRefusal(path);
117
+ if (refusal !== undefined) {
118
+ throw new RequestArgumentError(`resources key ${JSON.stringify(path)} cannot name a file inside the bundle: ${refusal}.`);
119
+ }
120
+ const canonical = canonicalBundleResourcePath(path);
121
+ const first = pathByCanonical.get(canonical);
122
+ if (first !== undefined) {
123
+ throw new RequestArgumentError(`resources keys ${JSON.stringify(first)} and ${JSON.stringify(path)} name the same file ` +
124
+ `"${canonical}": send it once.`);
125
+ }
126
+ pathByCanonical.set(canonical, path);
127
+ }
128
+ // A null prototype, so a key such as `__proto__` is an own property that reaches the wire.
129
+ const wire = Object.create(null);
130
+ for (const [path, value] of entries) {
131
+ wire[path] = bytesToBase64(await resourceBytes(path, value));
132
+ }
133
+ return wire;
134
+ }
135
+ async function resourceBytes(path, value) {
136
+ if (value instanceof Uint8Array)
137
+ return value;
138
+ if (value instanceof ArrayBuffer)
139
+ return new Uint8Array(value);
140
+ if (typeof Blob !== "undefined" && value instanceof Blob) {
141
+ return new Uint8Array(await value.arrayBuffer());
142
+ }
143
+ throw new RequestArgumentError(`resources[${JSON.stringify(path)}] must be the file's bytes (a Uint8Array, an ArrayBuffer ` +
144
+ `or a Blob); got ${describeValue(value)}.` +
145
+ (typeof value === "string"
146
+ ? " A string is read neither as a path nor as base64: read the file and pass its bytes."
147
+ : ""));
148
+ }
149
+ function describeValue(value) {
150
+ if (value === null)
151
+ return "null";
152
+ if (Array.isArray(value))
153
+ return "an array";
154
+ if (value instanceof Map)
155
+ return "a Map; pass Object.fromEntries(map)";
156
+ if (typeof value === "string")
157
+ return "a string";
158
+ if (typeof value === "object") {
159
+ const name = Object.getPrototypeOf(value)
160
+ ?.constructor?.name;
161
+ return typeof name === "string" && name !== "" ? `an instance of ${name}` : "an object";
162
+ }
163
+ return `a value of type ${typeof value}`;
164
+ }
165
+ //# sourceMappingURL=bundle-resources.js.map
@@ -0,0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AAE,CAAC,CAAC,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC;IAC1F,CAAC;IACD,OAAO,mBAAmB,OAAO,KAAK,EAAE,CAAC;AAC3C,CAAC"}
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 { ApiResponseError, ApiUnreachableError, MissingMainStuffError, PipelineExecuteTimeoutError, RunFailedError, isGatewayCutOff, renderInputsTemplate, } from "../index.js";
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", since: performance.now() };
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: its answer was lost to a time limit, a
216
- * connection that closed once the request had left or a gateway that cut the request off, or it
217
- * came back unreadable, or a gateway answered that it lost or never got the server's answer
218
- * (`502`, `504`, RFC 9110). A gateway cuts a request off at ~30 seconds, whether a blocking
219
- * execute or a start the server is still handling, such as one fetching a `method_ref`'s package:
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
- if (stage.kind !== "starting")
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. */
@@ -1 +1 @@
1
- {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,2BAA2B,EAC3B,cAAc,EACd,eAAe,EACf,oBAAoB,GACrB,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,EAA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CAAC;IACtE,CAAC;AACH,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"}
@@ -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.38.0";
18
+ export declare const SCRIPT_RUNNER = "npx --yes --no-update-notifier --loglevel=warn @pipelex/sdk@0.40.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. */
@@ -43,7 +43,8 @@ export interface DescribedPipe {
43
43
  * the same selection the run's input preparation makes.
44
44
  *
45
45
  * @throws {CommandError} When the method does not load, or the answer does not describe the pipe
46
- * it selected. A refusal of the request itself propagates as the SDK's `ApiResponseError`.
46
+ * it selected or describes it with an input form the walk or the template cannot read. A refusal
47
+ * of the request itself propagates as the SDK's `ApiResponseError`.
47
48
  * @throws {Interrupted} When the person interrupts the wait.
48
49
  */
49
50
  export declare function describePipe(client: PipelexApiClient, source: MethodSource, pipe: string | undefined, interrupt: AbortSignal): Promise<DescribedPipe>;
@@ -5,6 +5,7 @@
5
5
  * bundle, and to the run as `mthds_contents`, in the same order. An address travels as
6
6
  * `method_ref` and a catalog id as `method_id`, both resolved by the server.
7
7
  */
8
+ import { inputFormFault } from "../index.js";
8
9
  import { CommandError, EXIT_FAILED, untilInterrupted } from "./io.js";
9
10
  import { loadFailureLines, METHOD_DOES_NOT_LOAD_SENTENCE } from "./present.js";
10
11
  export function crateSelector(source) {
@@ -33,7 +34,8 @@ export function runSelector(source) {
33
34
  * the same selection the run's input preparation makes.
34
35
  *
35
36
  * @throws {CommandError} When the method does not load, or the answer does not describe the pipe
36
- * it selected. A refusal of the request itself propagates as the SDK's `ApiResponseError`.
37
+ * it selected or describes it with an input form the walk or the template cannot read. A refusal
38
+ * of the request itself propagates as the SDK's `ApiResponseError`.
37
39
  * @throws {Interrupted} When the person interrupts the wait.
38
40
  */
39
41
  export async function describePipe(client, source, pipe, interrupt) {
@@ -58,12 +60,68 @@ export async function describePipe(client, source, pipe, interrupt) {
58
60
  const inputForm = report.input_form;
59
61
  if (typeof pipeRef !== "string" ||
60
62
  !isPlainObject(inputForm) ||
61
- !isPlainObject(inputForm[pipeRef])) {
63
+ !Object.hasOwn(inputForm, pipeRef)) {
62
64
  throw new CommandError("the API's pipe I/O answer does not describe the pipe it selected.", {
63
65
  exitCode: EXIT_FAILED,
64
66
  });
65
67
  }
66
- return { report, pipeRef, descriptor: inputForm[pipeRef] };
68
+ // The template is rendered from this entry, so it is checked as input preparation checks it,
69
+ // and then for what the template reads beyond the walk: a malformed entry would otherwise crash
70
+ // the rendering or print a template under made-up keys. The sentence is the Python command's,
71
+ // printed when its client cannot parse an entry, which cannot say where, so neither command
72
+ // names the fault. Python's closed models refuse more than this, such as a member the standard
73
+ // does not define, which the template never reads.
74
+ const entry = inputForm[pipeRef];
75
+ if (inputFormFault(entry) !== undefined || !templateReadable(entry)) {
76
+ throw new CommandError("the API's pipe I/O answer describes the pipe it selected with a malformed input form.", { exitCode: EXIT_FAILED });
77
+ }
78
+ return { report, pipeRef, descriptor: entry };
79
+ }
80
+ /**
81
+ * Whether an entry `inputFormFault` passed also holds what the inputs template reads beyond the
82
+ * walk, in a shape it can render: every node's `concept_ref` a string, its `refines` a list of
83
+ * strings, an enum's `choices` a list and a list's `item_count` a whole number of at least two,
84
+ * the last three when present. Members the template only tests for truth are not checked.
85
+ */
86
+ function templateReadable(entry) {
87
+ return entry.fields.every(templateReadableNode);
88
+ }
89
+ function templateReadableNode(node) {
90
+ if (node.concept_ref !== undefined && typeof node.concept_ref !== "string")
91
+ return false;
92
+ if (node.refines !== undefined &&
93
+ node.refines !== null &&
94
+ !(Array.isArray(node.refines) && node.refines.every((ref) => typeof ref === "string"))) {
95
+ return false;
96
+ }
97
+ // Every kind is listed, so a kind a newer `mthds` pin adds stops the build here until the
98
+ // template's reads of it are checked, as it does in the walk's own table.
99
+ const kind = node.kind;
100
+ switch (kind) {
101
+ case "text":
102
+ case "prose":
103
+ case "date":
104
+ case "number":
105
+ case "boolean":
106
+ case "document":
107
+ case "image":
108
+ case "unknown":
109
+ return true;
110
+ case "object":
111
+ return templateReadable(node);
112
+ case "enum":
113
+ return Array.isArray(node.choices);
114
+ case "list":
115
+ return ((node.item_count === undefined ||
116
+ node.item_count === null ||
117
+ (Number.isInteger(node.item_count) && node.item_count >= 2)) &&
118
+ templateReadableNode(node.item));
119
+ default: {
120
+ // Unreachable: `inputFormFault` refused a kind outside the walk's table.
121
+ const unreachable = kind;
122
+ return unreachable;
123
+ }
124
+ }
67
125
  }
68
126
  function isPlainObject(value) {
69
127
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -1 +1 @@
1
- {"version":3,"file":"source.js","sourceRoot":"","sources":["../../src/cli/source.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,6BAA6B,EAAE,MAAM,cAAc,CAAC;AAc/E,MAAM,UAAU,aAAa,CAAC,MAAoB;IAChD,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,QAAQ;YACX,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;QAC/F,KAAK,SAAS;YACZ,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC;QAC1C,KAAK,SAAS;YACZ,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC;IAC1C,CAAC;AACH,CAAC;AAED,4CAA4C;AAC5C,MAAM,UAAU,WAAW,CAAC,MAAoB;IAC9C,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB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