@pipelex/sdk 0.69.4 → 0.71.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/dist/artifacts.d.ts +98 -27
- package/dist/artifacts.js +400 -91
- package/dist/artifacts.js.map +1 -1
- package/dist/cli/script.d.ts +1 -1
- package/dist/client.d.ts +41 -5
- package/dist/client.js +91 -12
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +49 -20
- package/dist/errors.js +54 -20
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/product-models.d.ts +61 -0
- package/dist/runs.d.ts +14 -1
- package/dist/runs.js +39 -9
- package/dist/runs.js.map +1 -1
- package/dist/stored-texts.d.ts +12 -0
- package/dist/stored-texts.js +27 -5
- package/dist/stored-texts.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/architecture.md +2 -2
- package/docs/artifact-download.md +10 -10
- package/docs/errors.md +2 -2
- package/docs/files.md +41 -1
- package/docs/run-results.md +14 -6
- package/package.json +1 -1
package/dist/artifacts.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* - {@link locateArtifacts} — a pure walk of any JSON value for the strings that
|
|
6
6
|
* ARE `pipelex-storage://` references, each with every path it sits at.
|
|
7
7
|
* {@link collectArtifacts} is the same walk's bare references. No network, no key.
|
|
8
|
-
* - {@link resolveArtifacts} — the
|
|
8
|
+
* - {@link resolveArtifacts} — the server's bulk resolve route over a whole
|
|
9
9
|
* list, chunked at the route's bound, one verdict per reference.
|
|
10
10
|
* - {@link fetchArtifact} — a bounded `Response` for one reference: resolved
|
|
11
11
|
* fresh, timed out, redirects refused, the byte cap enforced mid-stream, no
|
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
* A produced file is never embedded in a run's results: the content carries its
|
|
17
17
|
* durable `pipelex-storage://` reference beside a signed `public_url` that expires
|
|
18
18
|
* on the provider's schedule. Nothing here reads that embedded link — every link
|
|
19
|
-
* is minted fresh by the
|
|
20
|
-
*
|
|
19
|
+
* is minted fresh by the server's bulk resolve route (the hosted platform's presigned
|
|
20
|
+
* link, or a self-hosted runner's own signed link), and re-minted when it has expired
|
|
21
|
+
* by the time a worker reaches it. See `docs/artifact-download.md`.
|
|
21
22
|
*
|
|
22
23
|
* `node:fs/promises`, `node:path` and `undici` come from the Node host
|
|
23
24
|
* (`node-host.ts`), which a bundler building for the browser resolves to a module
|
|
@@ -33,7 +34,8 @@ import type { ConceptSource, StoredTextKind } from "./stored-texts.js";
|
|
|
33
34
|
export declare const PIPELEX_STORAGE_SCHEME = "pipelex-storage://";
|
|
34
35
|
/**
|
|
35
36
|
* How many references one bulk resolve request takes — the route's bound, fixed
|
|
36
|
-
* by the
|
|
37
|
+
* by the route's contract, the same on the platform and a self-hosted runner,
|
|
38
|
+
* rather than configured per deployment. A longer list
|
|
37
39
|
* is a `422`, so {@link resolveArtifacts} chunks at this size.
|
|
38
40
|
*/
|
|
39
41
|
export declare const BULK_RESOLVE_MAX_URIS = 100;
|
|
@@ -51,14 +53,17 @@ export declare const DEFAULT_DOWNLOAD_MAX_TOTAL_BYTES: number;
|
|
|
51
53
|
export declare const DEFAULT_DOWNLOAD_CONCURRENCY = 4;
|
|
52
54
|
/**
|
|
53
55
|
* Why one reference failed — a value, never a thrown error. `code` is the
|
|
54
|
-
* resolve route's own per-reference code (`pipelex.storage.uri_invalid`, `pipelex.org.mismatch
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
56
|
+
* resolve route's own per-reference code (`pipelex.storage.uri_invalid`, `pipelex.org.mismatch`,
|
|
57
|
+
* and a self-hosted runner's `auth.forbidden` whose `requirement` is `read_scope_under_caller` for
|
|
58
|
+
* a reference outside the caller's scope) or one of the fetch boundary's (see `ArtifactFetchError`),
|
|
59
|
+
* plus the download's own `resolve_failed`, `total_limit_exceeded`, `write_failed` and `aborted`.
|
|
60
|
+
* `detail` is the sentence a person reads, and `params` the parameters the route's code declares,
|
|
61
|
+
* when the route sent them.
|
|
58
62
|
*/
|
|
59
63
|
export interface ArtifactItemError {
|
|
60
64
|
code: string;
|
|
61
65
|
detail: string;
|
|
66
|
+
params?: Record<string, unknown> | null;
|
|
62
67
|
}
|
|
63
68
|
/**
|
|
64
69
|
* One reference's resolution — the bulk resolve route's item, verbatim. Either
|
|
@@ -69,11 +74,15 @@ export interface ArtifactItemError {
|
|
|
69
74
|
export type ResolvedArtifact = {
|
|
70
75
|
/** The reference exactly as sent. */
|
|
71
76
|
uri: string;
|
|
72
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* A short-lived signed link, fetchable now and until `expires_at`, whose lifetime the server
|
|
79
|
+
* sets: the hosted platform's presigned link lasts about fifteen minutes, and a self-hosted
|
|
80
|
+
* runner's link to its own download route lasts its `STORAGE_LINK_TTL_SECONDS`.
|
|
81
|
+
*/
|
|
73
82
|
url: string;
|
|
74
83
|
/** UTC expiry of the link, ISO 8601. */
|
|
75
84
|
expires_at: string;
|
|
76
|
-
/** The
|
|
85
|
+
/** The server's content-type guess from the reference's extension; null when it has none. */
|
|
77
86
|
content_type: string | null;
|
|
78
87
|
error: null;
|
|
79
88
|
} | {
|
|
@@ -101,9 +110,12 @@ export interface FetchArtifactOptions {
|
|
|
101
110
|
*/
|
|
102
111
|
timeoutMs?: number;
|
|
103
112
|
/**
|
|
104
|
-
* Accept a plain `http:` link. Off by default: a general-purpose
|
|
105
|
-
* not fetch over plain http silently.
|
|
106
|
-
*
|
|
113
|
+
* Accept a plain `http:` link on any origin. Off by default: a general-purpose
|
|
114
|
+
* library does not fetch over plain http silently. A plain `http:` link on the
|
|
115
|
+
* origin of the client's configured base URL, which a self-hosted runner hands
|
|
116
|
+
* out, is accepted without it, since the client already sends its API key
|
|
117
|
+
* there. The local compose stack's object store hands out plain `http:` links
|
|
118
|
+
* on another origin, which is the case this opts into.
|
|
107
119
|
*/
|
|
108
120
|
allowHttp?: boolean;
|
|
109
121
|
/** Cancels the fetch; a body being read is cancelled too. */
|
|
@@ -190,7 +202,7 @@ export type DownloadedKind = "file" | "text";
|
|
|
190
202
|
* One reference's outcome in a download verdict — one shape with nullable fields,
|
|
191
203
|
* like {@link ResolvedArtifact}: either `path` and `size` are set and `error` is
|
|
192
204
|
* null, or `error` is set and both are null. `found_at` says where the reference
|
|
193
|
-
* sits in the walked scope, and `content_type` is the
|
|
205
|
+
* sits in the walked scope, and `content_type` is the server's guess from the
|
|
194
206
|
* reference's extension, known before the fetch; both are on both arms, so an
|
|
195
207
|
* item that was not saved still says which field it would have filled.
|
|
196
208
|
*/
|
|
@@ -234,11 +246,18 @@ export interface DownloadArtifactsResult {
|
|
|
234
246
|
aborted?: true;
|
|
235
247
|
}
|
|
236
248
|
/**
|
|
237
|
-
* The client surface the artifact operations need: the raw bulk resolve call
|
|
238
|
-
*
|
|
239
|
-
* `PipelexApiClient` satisfies it structurally, and so
|
|
249
|
+
* The client surface the artifact operations need: the raw bulk resolve call, the
|
|
250
|
+
* single-shot result lookup and the origin the client is configured with. Typed as
|
|
251
|
+
* the client's own members so `PipelexApiClient` satisfies it structurally, and so
|
|
252
|
+
* tests inject a fake.
|
|
240
253
|
*/
|
|
241
254
|
export interface ArtifactCapableClient {
|
|
255
|
+
/**
|
|
256
|
+
* The origin (`scheme://host[:port]`) of the client's configured base URL. A
|
|
257
|
+
* resolved link on it is fetched over plain http without `allowHttp`, since the
|
|
258
|
+
* client already sends its API key there.
|
|
259
|
+
*/
|
|
260
|
+
readonly originUrl: string;
|
|
242
261
|
resolveStorageUrls(input: BulkResolveStorageUrlsInput, options?: {
|
|
243
262
|
signal?: AbortSignal;
|
|
244
263
|
}): Promise<BulkResolvedStorageUrls>;
|
|
@@ -293,7 +312,7 @@ export declare function locateStoredReferences(value: unknown, node?: InputFormI
|
|
|
293
312
|
export declare function isStorageReference(value: string): boolean;
|
|
294
313
|
/**
|
|
295
314
|
* A `url` a stored text may be loaded from: a `pipelex-storage://` reference, resolved through the
|
|
296
|
-
*
|
|
315
|
+
* server's bulk route to a link it signs, or a `data:` URL, decoded where it is. A stored text at
|
|
297
316
|
* any other URL is never fetched, so a method cannot have the SDK read a host the caller did not
|
|
298
317
|
* choose: the loader refuses it as `unsupported_url`.
|
|
299
318
|
*
|
|
@@ -350,7 +369,7 @@ export declare function resolveArtifacts(client: Pick<ArtifactCapableClient, "re
|
|
|
350
369
|
}): Promise<ResolvedArtifact[]>;
|
|
351
370
|
/**
|
|
352
371
|
* A bounded `Response` for one reference: the link is minted fresh through the
|
|
353
|
-
* bulk route, then fetched with `redirect: "manual"` (a
|
|
372
|
+
* bulk route, then fetched with `redirect: "manual"` (a signed link has no
|
|
354
373
|
* reason to redirect, and one that does is refused rather than followed), no
|
|
355
374
|
* headers of ours (the link carries its own authorization in the query string,
|
|
356
375
|
* and nothing must ride along to the object store), a budget covering the
|
|
@@ -369,21 +388,46 @@ export declare function resolveArtifacts(client: Pick<ArtifactCapableClient, "re
|
|
|
369
388
|
* caller's abort propagates as-is. Whole-request failures of the resolve step
|
|
370
389
|
* propagate unchanged (`ApiResponseError`, `ApiUnreachableError`).
|
|
371
390
|
*/
|
|
372
|
-
export declare function fetchArtifact(client: Pick<ArtifactCapableClient, "resolveStorageUrls">, uri: string, options?: FetchArtifactOptions): Promise<Response>;
|
|
391
|
+
export declare function fetchArtifact(client: Pick<ArtifactCapableClient, "resolveStorageUrls" | "originUrl">, uri: string, options?: FetchArtifactOptions): Promise<Response>;
|
|
373
392
|
/**
|
|
374
393
|
* The cap on one stored text's bytes: the runtime's own cap on what it reads from storage, so a
|
|
375
394
|
* text the runtime could read is never one the SDK refuses.
|
|
376
395
|
*/
|
|
377
396
|
export declare const DEFAULT_STORED_TEXT_MAX_BYTES: number;
|
|
397
|
+
/**
|
|
398
|
+
* The cap on the bytes of all the stored texts of one load together. Every loaded value is held
|
|
399
|
+
* until the load ends, as bytes and then as a string that can take twice as many, so the load
|
|
400
|
+
* itself must be bounded, not only each text: 256 MiB leaves room for two texts at the per-text
|
|
401
|
+
* cap while keeping what one load holds to a few hundred MiB of the process's memory.
|
|
402
|
+
*/
|
|
403
|
+
export declare const DEFAULT_STORED_TEXT_MAX_TOTAL_BYTES: number;
|
|
378
404
|
/** How many stored texts one load reads at once. */
|
|
379
405
|
export declare const DEFAULT_STORED_TEXT_CONCURRENCY = 8;
|
|
406
|
+
/**
|
|
407
|
+
* The `StoredTextLoadError` reason of a result that cannot say which of its values are stored
|
|
408
|
+
* texts ({@link lacksStoredTextConcepts}); `waitForResult` keeps polling through it for a while.
|
|
409
|
+
*/
|
|
410
|
+
export declare const STORED_TEXT_CONCEPTS_MISSING = "concepts_missing";
|
|
380
411
|
/** The bounds `loadStoredTexts` applies. Every one has a safe default. */
|
|
381
412
|
export interface LoadStoredTextsOptions {
|
|
382
|
-
/**
|
|
413
|
+
/**
|
|
414
|
+
* Refuse a stored text over this many bytes: against the size its reference states before
|
|
415
|
+
* anything is sent, then while reading it. Default 100 MiB.
|
|
416
|
+
*/
|
|
383
417
|
maxBytes?: number;
|
|
418
|
+
/**
|
|
419
|
+
* Refuse the load once its stored texts together cross this many bytes: against the sizes their
|
|
420
|
+
* references state before anything is sent, then counted as the bytes arrive, every read in
|
|
421
|
+
* flight then stopped. Default 256 MiB ({@link DEFAULT_STORED_TEXT_MAX_TOTAL_BYTES}).
|
|
422
|
+
*/
|
|
423
|
+
maxTotalBytes?: number;
|
|
384
424
|
/** Budget for each text's exchange — connect, headers and body. Default 120 s. */
|
|
385
425
|
timeoutMs?: number;
|
|
386
|
-
/**
|
|
426
|
+
/**
|
|
427
|
+
* Accept a plain `http:` link on any origin, as the local stack's object store hands out. Off
|
|
428
|
+
* by default; a plain `http:` link on the origin of the client's configured base URL is
|
|
429
|
+
* accepted without it.
|
|
430
|
+
*/
|
|
387
431
|
allowHttp?: boolean;
|
|
388
432
|
/** How many texts are read at once. Default 8. */
|
|
389
433
|
concurrency?: number;
|
|
@@ -399,21 +443,36 @@ export interface LoadStoredTextsOptions {
|
|
|
399
443
|
*
|
|
400
444
|
* Which values are stored texts is decided by concept, never by URL or MIME type: the concept at
|
|
401
445
|
* each path comes from the run's working memory and output form ({@link mainStuffNode}), so the
|
|
402
|
-
* results must carry them
|
|
403
|
-
*
|
|
446
|
+
* results must carry them. A result that cannot say (no working memory naming the main stuff, or
|
|
447
|
+
* a concept of the method's own that no form describes) is returned as it is when nothing in
|
|
448
|
+
* `main_stuff` is shaped like a stored text's reference; when something is, it throws
|
|
449
|
+
* `StoredTextLoadError` with the reason `concepts_missing` rather than hand a reference on where a
|
|
450
|
+
* text is promised ({@link lacksStoredTextConcepts}). The runtime writes `output_form` after
|
|
451
|
+
* `main_stuff`, so a read can land in between: `waitForResult` keeps polling through that window
|
|
452
|
+
* for a few polls before it throws.
|
|
453
|
+
*
|
|
454
|
+
* A `pipelex-storage://` reference is resolved through the server's bulk route, at most
|
|
404
455
|
* {@link BULK_RESOLVE_MAX_URIS} per request, and its signed link fetched under the same bounds as
|
|
405
|
-
* `fetchArtifact
|
|
456
|
+
* `fetchArtifact`; a link within ten seconds of its `expires_at` when its read is about to start,
|
|
457
|
+
* having waited behind the other reads, is resolved again first. A `data:` URL is decoded, its
|
|
458
|
+
* size bounded from its length before it is. A stored text under any other URL
|
|
406
459
|
* ({@link isLoadableStoredTextUrl}) is refused before anything is sent, since fetching it would
|
|
407
460
|
* read a host the method chose rather than the caller; a result read with
|
|
408
461
|
* `loadStoredTexts: false` keeps it as written. The bytes are UTF-8 by the standard's rule, and a
|
|
409
462
|
* JSON value is the object they serialize.
|
|
410
463
|
*
|
|
464
|
+
* Each text is bounded by `maxBytes` (100 MiB by default) and the load as a whole by
|
|
465
|
+
* `maxTotalBytes` (256 MiB by default), both checked first against the sizes the references state,
|
|
466
|
+
* before anything is sent, then as the bytes arrive; the first text that fails stops every other
|
|
467
|
+
* read in flight.
|
|
468
|
+
*
|
|
411
469
|
* The result passed in is never changed: a new one is returned, or the same one when there is
|
|
412
470
|
* nothing to load. Throws `StoredTextLoadError` naming the text that could not be loaded, where it
|
|
413
471
|
* sits and why, a whole-request failure of the resolve route included (`resolve_failed`, the
|
|
414
|
-
* route's error as its `cause`),
|
|
472
|
+
* route's error as its `cause`), the load's total over `maxTotalBytes` as
|
|
473
|
+
* `total_limit_exceeded`, and lets the caller's abort through.
|
|
415
474
|
*/
|
|
416
|
-
export declare function loadStoredTexts(client: Pick<ArtifactCapableClient, "resolveStorageUrls">, results: RunResults, options?: LoadStoredTextsOptions): Promise<RunResults>;
|
|
475
|
+
export declare function loadStoredTexts(client: Pick<ArtifactCapableClient, "resolveStorageUrls" | "originUrl">, results: RunResults, options?: LoadStoredTextsOptions): Promise<RunResults>;
|
|
417
476
|
/**
|
|
418
477
|
* The concept facts of a run's results: the results themselves when their read carried the
|
|
419
478
|
* working memory and the forms (`selection` undefined reads every artifact), else those three
|
|
@@ -432,6 +491,18 @@ export declare function withConceptArtifacts(client: Pick<ArtifactCapableClient,
|
|
|
432
491
|
* deciding; a `false` says no stored text the runtime made can be there.
|
|
433
492
|
*/
|
|
434
493
|
export declare function mayHoldStoredTexts(value: unknown): boolean;
|
|
494
|
+
/**
|
|
495
|
+
* Whether a completed result cannot say which values of its `main_stuff` are stored texts while
|
|
496
|
+
* something there is shaped like one's reference ({@link mayHoldStoredTexts}): the working memory
|
|
497
|
+
* names no main stuff, or its concept is the method's own and no `output_form` / `input_form` node
|
|
498
|
+
* describes it, so a text in one of its fields could not be told from any other value. A native
|
|
499
|
+
* concept needs no form: the walk knows its shape. The runtime writes `output_form` after
|
|
500
|
+
* `main_stuff`, so a read can land in between; {@link loadStoredTexts} then throws
|
|
501
|
+
* `StoredTextLoadError` (`concepts_missing`) rather than hand a reference on.
|
|
502
|
+
*/
|
|
503
|
+
export declare function lacksStoredTextConcepts(results: ConceptSource & {
|
|
504
|
+
main_stuff?: unknown;
|
|
505
|
+
}): boolean;
|
|
435
506
|
/**
|
|
436
507
|
* Whether a results read narrowed to `selection` carried every artifact the concept at each path
|
|
437
508
|
* is read from: the working memory and both forms. `undefined`, a read of every artifact, does.
|