@pipelex/sdk 0.67.0 → 0.69.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 +2 -0
- package/dist/artifacts.d.ts +133 -6
- package/dist/artifacts.js +495 -40
- package/dist/artifacts.js.map +1 -1
- package/dist/cli/present.d.ts +2 -0
- package/dist/cli/present.js +22 -1
- package/dist/cli/present.js.map +1 -1
- package/dist/cli/run.js +13 -4
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/script.d.ts +1 -1
- package/dist/client.d.ts +27 -11
- package/dist/client.js +78 -21
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +46 -5
- package/dist/errors.js +49 -6
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/method-trees.d.ts +0 -10
- package/dist/method-trees.js +0 -28
- package/dist/method-trees.js.map +1 -1
- package/dist/product-models.d.ts +19 -5
- package/dist/runs.d.ts +36 -1
- package/dist/runs.js +101 -42
- package/dist/runs.js.map +1 -1
- package/dist/signals.d.ts +14 -0
- package/dist/signals.js +33 -0
- package/dist/signals.js.map +1 -0
- package/dist/stored-texts.d.ts +85 -0
- package/dist/stored-texts.js +289 -0
- package/dist/stored-texts.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/architecture.md +2 -1
- package/docs/artifact-download.md +7 -3
- package/docs/cli.md +2 -1
- package/docs/errors.md +2 -1
- package/docs/files.md +1 -1
- package/docs/run-results.md +21 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -126,6 +126,8 @@ const me = await client.getMe(); // GET /v1/me
|
|
|
126
126
|
const page = await client.listMethods(); // GET /v1/methods — one page: { items, nextCursor }
|
|
127
127
|
// Only the methods never published. A filtered page can be empty and still carry a nextCursor.
|
|
128
128
|
const drafts = await client.listMethods({ published: false });
|
|
129
|
+
// Only the caller's own methods ("me"), or one member's by user id; each row names its author.
|
|
130
|
+
const mine = await client.listMethods({ createdBy: "me" });
|
|
129
131
|
for await (const method of client.iterateMethods()) {
|
|
130
132
|
// follows the cursor for callers that genuinely want the whole catalog
|
|
131
133
|
}
|
package/dist/artifacts.d.ts
CHANGED
|
@@ -26,7 +26,9 @@
|
|
|
26
26
|
* runs anywhere the global `fetch` does (the dispatcher is a Node refinement), and
|
|
27
27
|
* only `downloadArtifacts` touches a filesystem.
|
|
28
28
|
*/
|
|
29
|
-
import type { GetRunResultOptions, RunResults, RunResultState } from "./runs.js";
|
|
29
|
+
import type { GetRunResultOptions, RunResultArtifact, RunResults, RunResultState } from "./runs.js";
|
|
30
|
+
import type { InputFormItem } from "mthds/protocol";
|
|
31
|
+
import type { ConceptSource, StoredTextKind } from "./stored-texts.js";
|
|
30
32
|
/** The scheme of a durable storage reference. */
|
|
31
33
|
export declare const PIPELEX_STORAGE_SCHEME = "pipelex-storage://";
|
|
32
34
|
/**
|
|
@@ -49,7 +51,7 @@ export declare const DEFAULT_DOWNLOAD_MAX_TOTAL_BYTES: number;
|
|
|
49
51
|
export declare const DEFAULT_DOWNLOAD_CONCURRENCY = 4;
|
|
50
52
|
/**
|
|
51
53
|
* Why one reference failed — a value, never a thrown error. `code` is the
|
|
52
|
-
* resolve route's own per-reference code (`
|
|
54
|
+
* resolve route's own per-reference code (`pipelex.storage.uri_invalid`, `pipelex.org.mismatch`)
|
|
53
55
|
* or one of the fetch boundary's (see `ArtifactFetchError`), plus the download's
|
|
54
56
|
* own `resolve_failed`, `total_limit_exceeded`, `write_failed` and `aborted`.
|
|
55
57
|
* `detail` is the sentence a person reads.
|
|
@@ -158,6 +160,32 @@ export interface ArtifactLocation {
|
|
|
158
160
|
/** Every `$`-rooted path at which the reference occurs, in walk order. */
|
|
159
161
|
found_at: string[];
|
|
160
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Where one stored text sits in a walked value — a value the runtime holds by its
|
|
165
|
+
* `pipelex-storage://` reference, `{ url, size, mime_type, preview }`, in place of its value field.
|
|
166
|
+
* `found_at` is the path of the reference's `url`, in the notation of {@link ArtifactLocation}, and
|
|
167
|
+
* the other fields are what the reference states, `null` when it states none.
|
|
168
|
+
*/
|
|
169
|
+
export interface StoredTextLocation extends ArtifactLocation {
|
|
170
|
+
/** What the text holds once loaded: a text, an HTML fragment or a JSON object. */
|
|
171
|
+
kind: StoredTextKind;
|
|
172
|
+
/** The stored value's length in bytes. */
|
|
173
|
+
size: number | null;
|
|
174
|
+
/** The stored value's MIME type, which names its file when it is saved. */
|
|
175
|
+
mime_type: string | null;
|
|
176
|
+
/** The value's first characters. */
|
|
177
|
+
preview: string | null;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* The storage references of a walked value, told apart by concept: the stored files, which
|
|
181
|
+
* {@link locateArtifacts} answers, and the stored texts.
|
|
182
|
+
*/
|
|
183
|
+
export interface StoredReferences {
|
|
184
|
+
files: ArtifactLocation[];
|
|
185
|
+
texts: StoredTextLocation[];
|
|
186
|
+
}
|
|
187
|
+
/** What a reference of a download names: a stored file, or a stored text saved as a text file. */
|
|
188
|
+
export type DownloadedKind = "file" | "text";
|
|
161
189
|
/**
|
|
162
190
|
* One reference's outcome in a download verdict — one shape with nullable fields,
|
|
163
191
|
* like {@link ResolvedArtifact}: either `path` and `size` are set and `error` is
|
|
@@ -168,6 +196,8 @@ export interface ArtifactLocation {
|
|
|
168
196
|
*/
|
|
169
197
|
export type DownloadedArtifact = {
|
|
170
198
|
uri: string;
|
|
199
|
+
/** A stored file, or a stored text saved as a text file. */
|
|
200
|
+
kind: DownloadedKind;
|
|
171
201
|
/** Every `$`-rooted path in the walked scope where the reference sits; the first one named the file. */
|
|
172
202
|
found_at: string[];
|
|
173
203
|
/** Absolute path of the written file. */
|
|
@@ -178,6 +208,8 @@ export type DownloadedArtifact = {
|
|
|
178
208
|
error: null;
|
|
179
209
|
} | {
|
|
180
210
|
uri: string;
|
|
211
|
+
/** A stored file, or a stored text that would have been saved as a text file. */
|
|
212
|
+
kind: DownloadedKind;
|
|
181
213
|
/** Every `$`-rooted path in the walked scope where the reference sits. */
|
|
182
214
|
found_at: string[];
|
|
183
215
|
path: null;
|
|
@@ -225,8 +257,15 @@ export interface ArtifactCapableClient {
|
|
|
225
257
|
* produced image or document as content carrying its reference in `url`, so a
|
|
226
258
|
* typical path ends there: `$.rooms[3].staged_photo.url`, `$.items[0].url`, or
|
|
227
259
|
* `$.url` for an output that is one image. Pure — no network, no key.
|
|
260
|
+
*
|
|
261
|
+
* `node` is the descriptor node of the walked value, the standard's output-form node for a run's
|
|
262
|
+
* output ({@link mainStuffNode} finds it in the run's results). Given, the walk follows the
|
|
263
|
+
* concept at each path and skips a stored text — a `Text`, `Markdown`, `Html` or `JSON` value, or
|
|
264
|
+
* one refining them, which the runtime may hold by a `pipelex-storage://` reference too — since
|
|
265
|
+
* a stored text is a value of the run, never a file. Without it, nothing says what a value is, so
|
|
266
|
+
* every reference counts. A result read with its stored texts loaded, the default, holds none.
|
|
228
267
|
*/
|
|
229
|
-
export declare function locateArtifacts(value: unknown): ArtifactLocation[];
|
|
268
|
+
export declare function locateArtifacts(value: unknown, node?: InputFormItem | null): ArtifactLocation[];
|
|
230
269
|
/**
|
|
231
270
|
* Every `pipelex-storage://` reference inside a JSON-shaped value, deduplicated,
|
|
232
271
|
* in discovery order — the references of {@link locateArtifacts}, without their
|
|
@@ -236,11 +275,32 @@ export declare function locateArtifacts(value: unknown): ArtifactLocation[];
|
|
|
236
275
|
* heuristic: the runtime serializes a produced image or document as content
|
|
237
276
|
* carrying its reference in `url`, beside an expiring `public_url` this walk
|
|
238
277
|
* ignores. Pure — no network, no key — so a consumer can count or list a run's
|
|
239
|
-
* produced files without resolving any of them.
|
|
278
|
+
* produced files without resolving any of them. `node` skips the stored texts by concept, as on
|
|
279
|
+
* {@link locateArtifacts}.
|
|
240
280
|
*/
|
|
241
|
-
export declare function collectArtifacts(value: unknown): string[];
|
|
281
|
+
export declare function collectArtifacts(value: unknown, node?: InputFormItem | null): string[];
|
|
282
|
+
/**
|
|
283
|
+
* Every `pipelex-storage://` reference inside a JSON-shaped value, told apart by concept: the
|
|
284
|
+
* stored files, exactly as {@link locateArtifacts} answers them, and the stored texts, each with
|
|
285
|
+
* what its reference states. Each list is deduplicated and in discovery order. A stored text is
|
|
286
|
+
* found where `node` describes a stored-text concept ({@link storedTextKindOfNode}) and the value
|
|
287
|
+
* there is its reference, a `pipelex-storage://` `url` with no value field. Without `node` nothing
|
|
288
|
+
* says what a value is, so every reference is a file: a file count one too high, never a file
|
|
289
|
+
* hidden. For a run's output, `node` is {@link mainStuffNode} of its results. Pure — no network.
|
|
290
|
+
*/
|
|
291
|
+
export declare function locateStoredReferences(value: unknown, node?: InputFormItem | null): StoredReferences;
|
|
242
292
|
/** A string that is a storage reference: the scheme, then at least one character. */
|
|
243
293
|
export declare function isStorageReference(value: string): boolean;
|
|
294
|
+
/**
|
|
295
|
+
* A `url` a stored text may be loaded from: a `pipelex-storage://` reference, resolved through the
|
|
296
|
+
* platform's bulk route to a link it signs, or a `data:` URL, decoded where it is. A stored text at
|
|
297
|
+
* any other URL is never fetched, so a method cannot have the SDK read a host the caller did not
|
|
298
|
+
* choose: the loader refuses it as `unsupported_url`.
|
|
299
|
+
*
|
|
300
|
+
* The file walks ({@link locateStoredReferences}, `downloadArtifacts`) report the first kind
|
|
301
|
+
* only, since a `data:` URL holds its value inline and has nothing to resolve or save.
|
|
302
|
+
*/
|
|
303
|
+
export declare function isLoadableStoredTextUrl(url: string): boolean;
|
|
244
304
|
/**
|
|
245
305
|
* The bare filename a reference is saved under, named after the field it fills:
|
|
246
306
|
* the path in `location.found_at[0]`, where the reference was first seen.
|
|
@@ -273,7 +333,7 @@ export declare function isStorageReference(value: string): boolean;
|
|
|
273
333
|
* Throws `ArtifactOperationError` for a location whose `found_at[0]` is not a path
|
|
274
334
|
* in the notation {@link locateArtifacts} writes, or for an unknown scope.
|
|
275
335
|
*/
|
|
276
|
-
export declare function artifactFilename(location: ArtifactLocation, contentType: string | null | undefined, scope: ArtifactScope): string;
|
|
336
|
+
export declare function artifactFilename(location: ArtifactLocation | StoredTextLocation, contentType: string | null | undefined, scope: ArtifactScope): string;
|
|
277
337
|
/**
|
|
278
338
|
* Resolve a list of references through the bulk route, chunked at
|
|
279
339
|
* {@link BULK_RESOLVE_MAX_URIS} per request, and answer one
|
|
@@ -310,6 +370,73 @@ export declare function resolveArtifacts(client: Pick<ArtifactCapableClient, "re
|
|
|
310
370
|
* propagate unchanged (`ApiResponseError`, `ApiUnreachableError`).
|
|
311
371
|
*/
|
|
312
372
|
export declare function fetchArtifact(client: Pick<ArtifactCapableClient, "resolveStorageUrls">, uri: string, options?: FetchArtifactOptions): Promise<Response>;
|
|
373
|
+
/**
|
|
374
|
+
* The cap on one stored text's bytes: the runtime's own cap on what it reads from storage, so a
|
|
375
|
+
* text the runtime could read is never one the SDK refuses.
|
|
376
|
+
*/
|
|
377
|
+
export declare const DEFAULT_STORED_TEXT_MAX_BYTES: number;
|
|
378
|
+
/** How many stored texts one load reads at once. */
|
|
379
|
+
export declare const DEFAULT_STORED_TEXT_CONCURRENCY = 8;
|
|
380
|
+
/** The bounds `loadStoredTexts` applies. Every one has a safe default. */
|
|
381
|
+
export interface LoadStoredTextsOptions {
|
|
382
|
+
/** Refuse a stored text over this many bytes, before and while reading it. Default 100 MiB. */
|
|
383
|
+
maxBytes?: number;
|
|
384
|
+
/** Budget for each text's exchange — connect, headers and body. Default 120 s. */
|
|
385
|
+
timeoutMs?: number;
|
|
386
|
+
/** Accept a plain `http:` link, as the local stack's object store hands out. Off by default. */
|
|
387
|
+
allowHttp?: boolean;
|
|
388
|
+
/** How many texts are read at once. Default 8. */
|
|
389
|
+
concurrency?: number;
|
|
390
|
+
/** Cancels the load; its reason is thrown as is. */
|
|
391
|
+
signal?: AbortSignal;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* A run's result with every stored text in `main_stuff` loaded: each value the runtime holds by
|
|
395
|
+
* reference, `{ url, size, mime_type, preview }`, replaced by its inline form, `{ text }`,
|
|
396
|
+
* `{ inner_html }` (its `css_class` kept) or `{ json_obj }`, which is the shape the generated
|
|
397
|
+
* types parse. The result readers (`getRunResult`, `waitForResult`, `startAndWaitForResult`) call
|
|
398
|
+
* it by default; a caller holding a result read with `loadStoredTexts: false` calls it later.
|
|
399
|
+
*
|
|
400
|
+
* Which values are stored texts is decided by concept, never by URL or MIME type: the concept at
|
|
401
|
+
* each path comes from the run's working memory and output form ({@link mainStuffNode}), so the
|
|
402
|
+
* results must carry them; a result that carries neither is returned as it is. A
|
|
403
|
+
* `pipelex-storage://` reference is resolved through the platform's bulk route, at most
|
|
404
|
+
* {@link BULK_RESOLVE_MAX_URIS} per request, and its signed link fetched under the same bounds as
|
|
405
|
+
* `fetchArtifact`, and a `data:` URL is decoded. A stored text under any other URL
|
|
406
|
+
* ({@link isLoadableStoredTextUrl}) is refused before anything is sent, since fetching it would
|
|
407
|
+
* read a host the method chose rather than the caller; a result read with
|
|
408
|
+
* `loadStoredTexts: false` keeps it as written. The bytes are UTF-8 by the standard's rule, and a
|
|
409
|
+
* JSON value is the object they serialize.
|
|
410
|
+
*
|
|
411
|
+
* The result passed in is never changed: a new one is returned, or the same one when there is
|
|
412
|
+
* nothing to load. Throws `StoredTextLoadError` naming the text that could not be loaded, where it
|
|
413
|
+
* sits and why, a whole-request failure of the resolve route included (`resolve_failed`, the
|
|
414
|
+
* route's error as its `cause`), and lets the caller's abort through.
|
|
415
|
+
*/
|
|
416
|
+
export declare function loadStoredTexts(client: Pick<ArtifactCapableClient, "resolveStorageUrls">, results: RunResults, options?: LoadStoredTextsOptions): Promise<RunResults>;
|
|
417
|
+
/**
|
|
418
|
+
* The concept facts of a run's results: the results themselves when their read carried the
|
|
419
|
+
* working memory and the forms (`selection` undefined reads every artifact), else those three
|
|
420
|
+
* read again by the run's id, beside the results. Nothing is read when nothing is missing, and a
|
|
421
|
+
* second read that finds no completed run leaves the results as they are.
|
|
422
|
+
*/
|
|
423
|
+
export declare function withConceptArtifacts(client: Pick<ArtifactCapableClient, "getRunResult">, results: RunResults, selection: readonly RunResultArtifact[] | undefined, signal?: AbortSignal): Promise<ConceptSource & {
|
|
424
|
+
main_stuff?: unknown;
|
|
425
|
+
}>;
|
|
426
|
+
/**
|
|
427
|
+
* Whether a value holds anything shaped like a stored text's reference, which is what makes a read
|
|
428
|
+
* that left the concepts out read them again: an object carrying a string `url`, no inline value
|
|
429
|
+
* field, and a `size` or a `preview`, which the runtime sets on every reference it stores and an
|
|
430
|
+
* image or a document content never carries. So an output of images and documents alone answers
|
|
431
|
+
* `false`. A `true` says only that the concepts are worth reading, the concept at each path still
|
|
432
|
+
* deciding; a `false` says no stored text the runtime made can be there.
|
|
433
|
+
*/
|
|
434
|
+
export declare function mayHoldStoredTexts(value: unknown): boolean;
|
|
435
|
+
/**
|
|
436
|
+
* Whether a results read narrowed to `selection` carried every artifact the concept at each path
|
|
437
|
+
* is read from: the working memory and both forms. `undefined`, a read of every artifact, does.
|
|
438
|
+
*/
|
|
439
|
+
export declare function carriesConceptArtifacts(selection: readonly RunResultArtifact[] | undefined): boolean;
|
|
313
440
|
/** The write side of a streamed download: what {@link writeFully} needs of a `FileHandle`. */
|
|
314
441
|
export interface ChunkWriter {
|
|
315
442
|
write(buffer: Uint8Array, offset: number, length: number): Promise<{
|