@pipelex/sdk 0.73.0 → 0.74.2
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 +24 -1
- package/dist/artifacts.js +95 -15
- package/dist/artifacts.js.map +1 -1
- package/dist/cli/run.d.ts +2 -0
- package/dist/cli/run.js +13 -5
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/script.d.ts +1 -1
- package/dist/client.d.ts +25 -2
- package/dist/client.js +65 -7
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +6 -4
- package/dist/errors.js +6 -4
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/run-artifact-links.d.ts +73 -0
- package/dist/run-artifact-links.js +167 -0
- package/dist/run-artifact-links.js.map +1 -0
- package/dist/runs.d.ts +53 -3
- package/dist/runs.js +7 -4
- package/dist/runs.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/cli.md +1 -1
- package/docs/errors.md +1 -1
- package/docs/organization-branding.md +1 -1
- package/docs/run-results.md +32 -1
- package/package.json +2 -2
package/docs/errors.md
CHANGED
|
@@ -126,7 +126,7 @@ The classes remain, so a `catch` can still tell an argument refusal from a refus
|
|
|
126
126
|
| `MethodFileTransferError` | By `reason`: `unreachable` and `storage_error` are `runtime.unavailable`; `refused` reads storage's status, as above, `runtime.unexpected` with none; `mismatch`, downloaded bytes that are not the file listed, is `client.response_unreadable`. It carries `operation`, `reason`, `sha256`, `path` and `status`, and neither the link, nor storage's error body, nor a cause ([method-trees.md](./method-trees.md#when-a-transfer-fails)). |
|
|
127
127
|
| `ArtifactOperationError` | `runtime.unexpected` when built without a problem; the SDK gives `client.argument_invalid` where it refuses an argument (a `scope`, a bound, a location), `runtime.unsupported` for a runtime with no filesystem, `client.write_failed` for a directory that cannot be created, and `client.response_unreadable` for a resolution that answered the wrong count of items. |
|
|
128
128
|
| `ScopeUnavailableError` | `client.response_unreadable`: the run's results carry no artifact in the scope asked for. |
|
|
129
|
-
| `ArtifactFetchError` | The SDK gives `client.download_limit_exceeded` naming the cap for a file over it (`too_large`), `client.timeout` naming the budget for a download that ran out of time, and `client.unreachable` naming the store's origin for one that failed on the network. Otherwise by `reason` and `status`: `input.reference_not_found` naming the reference for the bulk resolve route's `pipelex.storage.uri_invalid` and `pipelex.org.mismatch`, for a self-hosted runner's `auth.forbidden` whose `params.requirement` is `read_scope_under_caller`, and for `not_found`; `client.link_refused` for `unsupported_url`, `plain_http_refused` and `redirect_refused`; for `store_error` and `store_refused`, the reading of the store's status as for any storage answer (`runtime.unavailable` for a `408`, a `429` or a `5xx` other than `501`, `runtime.unsupported` for a `501`, `client.response_unreadable` naming any other status, a `401` or a `403` included), and `runtime.unavailable` when no status is known; `runtime.unavailable` for `timeout` and `network`; and `runtime.unexpected` otherwise. `uri` and `reason` name the reference and the failure, `status` the store's HTTP status when one was received, and `requirement` the `requirement` the resolve route's refusal names in its `params`, when it names one, which tells a self-hosted runner's scope refusal from any other `auth.forbidden`. |
|
|
129
|
+
| `ArtifactFetchError` | The SDK gives `client.download_limit_exceeded` naming the cap for a file over it (`too_large`), `client.timeout` naming the budget for a download that ran out of time, and `client.unreachable` naming the store's origin for one that failed on the network. Otherwise by `reason` and `status`: `input.reference_not_found` naming the reference for the bulk resolve route's `pipelex.storage.uri_invalid` and `pipelex.org.mismatch`, for a self-hosted runner's `auth.forbidden` whose `params.requirement` is `read_scope_under_caller`, and for `not_found`; `client.link_refused` for `unsupported_url`, `plain_http_refused` and `redirect_refused`; for `store_error` and `store_refused`, the reading of the store's status as for any storage answer (`runtime.unavailable` for a `408`, a `429` or a `5xx` other than `501`, `runtime.unsupported` for a `501`, `client.response_unreadable` naming any other status, a `401` or a `403` included), and `runtime.unavailable` when no status is known; `runtime.unavailable` for `timeout` and `network`; `client.response_unreadable` naming the store's status for `unreadable`, a result artifact handed back by reference (`artifact_links`) whose file is not the artifact's JSON, its `uri` then `artifact_links.<name>` and never the signed link; and `runtime.unexpected` otherwise. `uri` and `reason` name the reference and the failure, `status` the store's HTTP status when one was received, and `requirement` the `requirement` the resolve route's refusal names in its `params`, when it names one, which tells a self-hosted runner's scope refusal from any other `auth.forbidden`. |
|
|
130
130
|
| `StoredTextLoadError` | The fetch failure's own problem, as `ArtifactFetchError` gives it, when a stored text's bytes could not be read, a refusal of the resolve route included; the resolve route's own problem for `resolve_failed`, the route failing as a whole; `client.link_refused` for `unsupported_url`, a stored text whose `url` is neither a `pipelex-storage://` reference nor a `data:` URL, which is never fetched; and `client.response_unreadable` naming the run for `not_utf8` and `not_json_object`, bytes read that are not the value. `uri`, `path` and `reason` name the text, `status` the HTTP status received when one was, and `requirement` the `requirement` the resolve route's refusal of the reference names in its `params`, when it names one, which tells a self-hosted runner's scope refusal from any other `auth.forbidden`; `wireResults` carries the completed result as it was answered on the blocking fallback alone, where there is no run to read again, and is `undefined` elsewhere, where reading it again with `loadStoredTexts: false` gives it. |
|
|
131
131
|
| `CodegenLockError` | `client.file_unreadable` naming `codegen.lock` for a lock that is malformed or tracks an unsafe path, `client.tool_outdated` naming this SDK for a lock newer than it reads, and `client.argument_invalid` naming `files` for a supplied tree holding an unsafe or duplicate path. It extends `ProblemError` rather than `PipelexRequestError`, since nothing was requested. |
|
|
132
132
|
| `ExactJsonUnsupportedError` | `client.tool_outdated`, naming the JavaScript runtime: `parseExactJson` met a number past `Number.MAX_SAFE_INTEGER` on a runtime whose `JSON.parse` hands a reviver no source text ([exact-integers.md](./exact-integers.md)). It extends `ProblemError`; the client reports it as the `ApiResponseError` of an answer it cannot read, with this error as `cause`. |
|
|
@@ -29,7 +29,7 @@ Both answer the same shape, so a client holds one type whichever it called. `get
|
|
|
29
29
|
| `design_system` | `BrandingDesignSystem \| null` | The team's design system, a DTCG token document, `null` when there is none. |
|
|
30
30
|
| `white_label` | `boolean` | Whether the organization holds the white-label entitlement. |
|
|
31
31
|
|
|
32
|
-
A `BrandingColors` always carries its three keys, each `#rrggbb` in lower case or `null` when not set: `action` is the button colour, `accent` the accent colour and `header` the header band's colour. A dark colour that is `null` falls back to the light colour of the same role, and a light one that is `null` to Pipelex's own palette for that theme.
|
|
32
|
+
A `BrandingColors` always carries its three keys, each `#rrggbb` in lower case or `null` when not set: `action` is the button colour, `accent` the accent colour and `header` the header band's colour. A dark colour that is `null` falls back to the light colour of the same role, and a light one that is `null` to Pipelex's own palette for that theme. Turning a colour set into the roles a page paints with is the host's: the method-app web template does it in `src/lib/brandRoles.ts` (`resolveDarkSeeds`, then `deriveBrandRoles` once per theme), since `@pipelex/mthds-form` no longer exports a brand entry.
|
|
33
33
|
|
|
34
34
|
**The preset, the shell and the typeface.** `preset` is the id of the preset the team started its design system from, such as `corporate`; `shell` is the id of the page shell its method apps wear, such as `masthead`; `typeface` is the id of the typeface their text is set in, such as `manrope`. Both themes share them. The platform holds each to a shape, one to 32 lower-case letters, digits and hyphens (`^[a-z0-9-]{1,32}$`), and never to a list: the lists of presets, shells and typefaces live with the application that offers them, so a client reads an id it does not know as unset, and a preset or a shell added to that list needs no new SDK. None counts towards whether an app is branded, which stays a logo or a colour in either theme, since a branded app trades Pipelex's strip for the team's band and a preset alone would leave that band carrying nothing of the team's. The preset replaced the app style the branding carried before: the platform no longer answers `style`, and refuses a write naming it.
|
|
35
35
|
|
package/docs/run-results.md
CHANGED
|
@@ -31,6 +31,7 @@ console.log(results.main_stuff, summarizeUsage(results).total_cost_usd);
|
|
|
31
31
|
| `tokens_usages` | `TokensUsageRecord[] \| null` | the `tokens_usages.json` artifact | lifted off `pipe_output` |
|
|
32
32
|
| `usage_assembly_error` | `string \| null` | relayed | lifted off `pipe_output` |
|
|
33
33
|
| `pipe_output` | `DictPipeOutput \| null \| undefined` | absent | the runner's whole native output |
|
|
34
|
+
| `artifact_links` | `RunArtifactLinks \| undefined` | the artifacts handed back by reference, when some were and the read did not follow them | absent |
|
|
34
35
|
|
|
35
36
|
## Reading only some artifacts — `artifacts`
|
|
36
37
|
|
|
@@ -45,6 +46,36 @@ const results = await client.waitForResult(runId, { artifacts: ["working_memory"
|
|
|
45
46
|
|
|
46
47
|
An empty selection or a name outside the list is a `RequestArgumentError` thrown before any request, `client.argument_invalid`, the same refusal the platform would answer with a `400`. `waitForResult` and `startAndWaitForResult` take the same `artifacts` in their poll options and send it on every poll; `startAndWaitForResult` refuses a bad selection before it starts the run. Against a bare runner the selection has nothing to narrow: the blocking fallback returns every artifact the runner sent. `downloadArtifacts` given a `run_id` asks for its scope's artifact alone.
|
|
47
48
|
|
|
49
|
+
## Artifacts handed back by reference — `artifact_links`
|
|
50
|
+
|
|
51
|
+
The API Gateway in front of the hosted platform refuses to deliver a body past its 10 MB limit, which a wide batch's graph spec reaches on its own. So the platform measures the artifacts a completed run wrote before it answers, and when inline they would take the body past its budget it hands the largest back by reference until the rest fits: each such artifact's field reads `null`, both `tokens_usages` and `usage_assembly_error` for the usage envelope, and `artifact_links` maps its name, as `artifacts` names it, to a `RunArtifactLink`, `{ url, expires_at }`, a GET of its stored file signed for about fifteen minutes. `main_stuff` is the last to leave, so a read of the output alone gets it inline whenever it fits. `artifact_links` is absent from every answer that fits, and a `null` field with no entry in it still means the artifact was not written.
|
|
52
|
+
|
|
53
|
+
**The result readers follow the links by default.** `getRunResult`, `waitForResult` and `startAndWaitForResult` fetch each linked file into its field before the main-stuff check and the stored-text load, so a referenced artifact reads as its content and the result looks like one answered inline: the followed entries are dropped and `artifact_links` is absent. A referenced `working_memory` is therefore there to tell the stored-text load which values are texts, and a referenced `main_stuff` is no `MissingMainStuffError`. `waitForResult` follows the links after the status read, under its `timeoutMs` like the stored-text load, so a deadline that passes while they download says the run completed. Each file is fetched under `fetchArtifact`'s bounds (`maxBytes` 1 GiB, `timeoutMs` 120 s, redirects refused, no credential sent) and read exactly with `parseExactJson`, as an inline answer is. The file is the one the runner wrote, so the links inside it are as stored and never re-signed: a produced file's `public_url` in a followed artifact may have expired, and its `pipelex-storage://` reference is what to resolve ([Produced files](#produced-files)). A link the store refuses, an expired one included, throws `ArtifactFetchError` naming it as `artifact_links.<name>`, never the signed link itself; reading the results again hands back a fresh one.
|
|
54
|
+
|
|
55
|
+
**Pass the link instead of the content when the file must not cross your server.** A server whose responses are capped, such as a Vercel function at about 4.5 MB, cannot relay an artifact that was referenced precisely because it passes 10 MB. It reads with `followArtifactLinks: false`, which fetches nothing and hands the links back on `artifact_links`, each referenced field `null`; the main-stuff check then throws `MissingMainStuffError` only for a `null` `main_stuff` with no link, so "handed back by reference" (`results.artifact_links?.main_stuff` is set) is told apart from "not written". The server hands the link to its client, which fetches the file from storage directly within its fifteen minutes and reads it with `parseRunArtifact(name, text)`, the pure parse the SDK applies, which needs no client or key and unpacks the usage envelope. A stored-text load on such a read still needs the run's concepts: when `main_stuff` holds a value shaped like a stored text's reference and the working memory or a form came back by reference, the load fetches that artifact for its own use and the result keeps the link; pass `loadStoredTexts: false` as well to fetch nothing at all. `loadStoredTexts(results)` called later on such a result does the same, and follows a `main_stuff` handed back by reference into the result first, since its texts are what it loads.
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
// On the capped server: no file crosses it, a stored text included.
|
|
59
|
+
const state = await client.getRunResult(runId, {
|
|
60
|
+
followArtifactLinks: false,
|
|
61
|
+
loadStoredTexts: false,
|
|
62
|
+
});
|
|
63
|
+
if (state.state === "completed") {
|
|
64
|
+
const { main_stuff, artifact_links } = state.result;
|
|
65
|
+
// `stringifyExactJson`, never `Response.json`: an exact read may hold a `bigint`.
|
|
66
|
+
const body = stringifyExactJson({ main_stuff, links: artifact_links ?? {} });
|
|
67
|
+
return new Response(body, { headers: { "content-type": "application/json" } });
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// In the browser, given the link.
|
|
71
|
+
const response = await fetch(link.url);
|
|
72
|
+
const { graph_spec } = parseRunArtifact("graph_spec", await response.text());
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`followArtifactLinks(results, { artifacts })`, a client method and an export taking the client, follows the links of a result read without following, every one or only the named ones, and returns a new result; `fetchRunArtifact(name, link)` fetches one link and returns the fields it fills, `{ tokens_usages, usage_assembly_error }` for the usage envelope. A link under a name this version does not know is left in place. `downloadArtifacts` follows its scope's link itself, and the link of a concept artifact its walk needs, whether it was given a `run_id` or a result read without following, under its own `maxBytes`, `timeoutMs` and `allowHttp`; such a fetch that fails throws its `ArtifactFetchError` rather than becoming an item's error, since no file can be walked without it. An empty `artifacts` names nothing to follow and throws `RequestArgumentError`, as the result readers refuse an empty selection.
|
|
76
|
+
|
|
77
|
+
**What following costs in memory.** Each linked file is buffered whole before it is parsed, and the links of one result are fetched at once, so a default read of a large run holds every referenced artifact in memory, as raw text and then parsed, before it returns: the parsed result is what the caller asked for, but a small serverless worker reading a wide batch may not have the room. Such a caller reads with `followArtifactLinks: false` and follows only what it needs, `followArtifactLinks(results, { artifacts: ["main_stuff"] })`, or passes the links on.
|
|
78
|
+
|
|
48
79
|
## `pipeline_run_id` — the durable handle
|
|
49
80
|
|
|
50
81
|
The run id is what makes a run readable after the process that started it has gone. `start` returns it in its acknowledgement before the run finishes, and every lifecycle read takes it: `getRunStatus(runId)` for the status row, `getRunResult(runId)` for a single result lookup, `waitForResult(runId)` to resume polling a run an earlier session started. It is also what a `RunTimeoutError` leaves you with — the run keeps executing server-side, so the timeout is a reason to re-poll by id, not a reason to run the method again.
|
|
@@ -199,7 +230,7 @@ async function refresh(runId: string): Promise<void> {
|
|
|
199
230
|
|
|
200
231
|
## `main_stuff` — the output
|
|
201
232
|
|
|
202
|
-
`main_stuff` is the resolved content of the run's main output and is always present for a completed run, unless the read's `artifacts` selection left it out. On the hosted path it is the `main_stuff.json` artifact; on the blocking path the SDK resolves it out of the returned working memory through the response's `main_stuff_name`. Both deliver the same content shape, so there is no shape-guessing and no path-dependent branch to write. A completed run that cannot deliver one throws `MissingMainStuffError` rather than handing back a half-filled result.
|
|
233
|
+
`main_stuff` is the resolved content of the run's main output and is always present for a completed run, unless the read's `artifacts` selection left it out or a read with `followArtifactLinks: false` found it handed back by reference ([above](#artifacts-handed-back-by-reference--artifact_links)). On the hosted path it is the `main_stuff.json` artifact; on the blocking path the SDK resolves it out of the returned working memory through the response's `main_stuff_name`. Both deliver the same content shape, so there is no shape-guessing and no path-dependent branch to write. A completed run that cannot deliver one, neither inline nor by reference, throws `MissingMainStuffError` rather than handing back a half-filled result.
|
|
203
234
|
|
|
204
235
|
It is typed `unknown` because the content is polymorphic: a structured output arrives as an object of the concept's fields, and a multiple output as the envelope `{ items: [...] }` that the runtime's `ListContent` serialises to. Every content type serialises to an object, natives included — a text output is `{ "text": "…" }` and a number `{ "number": 0 }` — so a guard written for a bare `""` or `0` never fires, and an empty multiple output is `{ "items": [] }` rather than `[]`. Narrow it where you read it, ideally through the types generated for the method rather than a hand-written cast.
|
|
205
236
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipelex/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.74.2",
|
|
4
4
|
"description": "TypeScript SDK for the Pipelex hosted API — execute methods, manage runs, and call the product surface.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@eslint/js": "^9.39.4",
|
|
70
|
-
"@pipelex/tools-wasm": "0.
|
|
70
|
+
"@pipelex/tools-wasm": "0.7.0",
|
|
71
71
|
"@types/node": "^22.12.0",
|
|
72
72
|
"@vitest/coverage-v8": "^4.1.9",
|
|
73
73
|
"dependency-cruiser": "^17.4.3",
|