@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.
@@ -0,0 +1,289 @@
1
+ /**
2
+ * Which values of a run are stored texts, told by concept — the pure half of loading them.
3
+ *
4
+ * Since the runtime's large-text storage, a `native.Text`, `native.Markdown`, `native.Html` or `native.JSON` value past
5
+ * the runtime's inline threshold is stored under the run's scope and travels as its reference,
6
+ * `{ url, size, mime_type, preview }`, in place of its value field (`text`, `inner_html` or
7
+ * `json_obj`). Its `url` is a `pipelex-storage://` address, exactly as an image's or a document's
8
+ * is, so a reader must tell a stored text from a file, and the MTHDS standard rules how: by the
9
+ * concept at the value's path, never by its URL or its MIME type (a `Document` may well be
10
+ * `text/plain`).
11
+ *
12
+ * The concept at each path comes from the run's own artifacts:
13
+ *
14
+ * ```
15
+ * main stuff's concept ── working_memory.aliases.main_stuff → working_memory.root[name].concept
16
+ * └── its structure ─── the first output_form / input_form node naming that concept,
17
+ * which states each nested field's concept and refinement chain
18
+ * └── no node ─── the native's own shape: Page → TextAndImages → Text, Image
19
+ * plural ─────────────── a `{ items: [...] }` content, unless the concept has a field `items`
20
+ * ```
21
+ *
22
+ * A concept is a stored text when it, or a concept its `refines` chain names, is one of
23
+ * {@link STORED_TEXT_CONCEPT_REFS}. Nothing here performs I/O: the walk is shared by the loader
24
+ * (`loadStoredTexts`) and by the file walkers (`locateArtifacts`, `collectArtifacts`), which skip
25
+ * a stored text rather than count it as a file. See `docs/run-results.md`, "Stored texts".
26
+ */
27
+ // ── Constants ────────────────────────────────────────────────────────
28
+ /** The concepts whose value the runtime stores past its inline threshold and carries as a reference. */
29
+ export const STORED_TEXT_CONCEPT_REFS = [
30
+ "native.Text",
31
+ "native.Markdown",
32
+ "native.Html",
33
+ "native.JSON",
34
+ ];
35
+ const KIND_BY_CONCEPT = {
36
+ "native.Text": "text",
37
+ "native.Markdown": "text",
38
+ "native.Html": "html",
39
+ "native.JSON": "json",
40
+ };
41
+ /** The field a loaded value of each kind is carried in: the inline form's value field. */
42
+ export const STORED_TEXT_VALUE_FIELD = {
43
+ text: "text",
44
+ html: "inner_html",
45
+ json: "json_obj",
46
+ };
47
+ /** The fields of the referenced form, which the loaded form drops. */
48
+ export const STORED_TEXT_REFERENCE_FIELDS = ["url", "size", "mime_type", "preview"];
49
+ const MAIN_STUFF_ALIAS = "main_stuff";
50
+ const LIST_ITEMS_FIELD = "items";
51
+ /**
52
+ * The members of the native composites whose shape the walk knows without a descriptor, so a
53
+ * page's text is found even when the run's forms are missing.
54
+ */
55
+ const NATIVE_MEMBERS = {
56
+ "native.Page": { text_and_images: "native.TextAndImages", page_view: "native.Image" },
57
+ "native.TextAndImages": { text: "native.Text", images: ["native.Image"] },
58
+ };
59
+ const NATIVE_FILE_KINDS = {
60
+ "native.Image": "image",
61
+ "native.Document": "document",
62
+ };
63
+ // ── Concept tests ────────────────────────────────────────────────────
64
+ /**
65
+ * The kind of stored text a concept holds, read off the concept itself and then its refinement
66
+ * chain (immediate parent first), or `null` for any other concept. `my.Memo refines native.Text`
67
+ * is a `text`; a `native.Document`, whatever its MIME type, is `null`.
68
+ */
69
+ export function storedTextKindOf(conceptRef, refines) {
70
+ for (const candidate of [conceptRef, ...(refines ?? [])]) {
71
+ if (typeof candidate !== "string")
72
+ continue;
73
+ const kind = KIND_BY_CONCEPT[candidate];
74
+ if (kind !== undefined)
75
+ return kind;
76
+ }
77
+ return null;
78
+ }
79
+ /** Whether a concept, or one its refinement chain names, is a stored text — see {@link storedTextKindOf}. */
80
+ export function isStoredTextConcept(conceptRef, refines) {
81
+ return storedTextKindOf(conceptRef, refines) !== null;
82
+ }
83
+ /** The domain of the natives: a concept whose chain reaches one is never text by the language's rule alone. */
84
+ const NATIVE_PREFIX = "native.";
85
+ /**
86
+ * The stored-text kind a descriptor node describes, or `null`: a list is never one, its items may
87
+ * be. A node is a stored text when its concept, or one its refinement chain names, is one of
88
+ * {@link STORED_TEXT_CONCEPT_REFS}, and also when its concept reaches no native at all and the
89
+ * node is text (`prose`, or `text` under a `label` intent): a description-only concept, or one
90
+ * refining such a concept, is text by the language's rule, and the runtime stores it as it stores
91
+ * a `native.Text`. A field typed by a bare field type carries no concept and is always inline.
92
+ */
93
+ export function storedTextKindOfNode(node) {
94
+ if (node === undefined || node.kind === "list")
95
+ return null;
96
+ const kind = storedTextKindOf(node.concept_ref, node.refines);
97
+ if (kind !== null)
98
+ return kind;
99
+ if (node.concept_ref === undefined)
100
+ return null;
101
+ const chain = [node.concept_ref, ...(node.refines ?? [])];
102
+ if (chain.some((concept) => concept.startsWith(NATIVE_PREFIX)))
103
+ return null;
104
+ return node.kind === "prose" || node.kind === "text" ? "text" : null;
105
+ }
106
+ /**
107
+ * The descriptor node of a run's main output, the output-form node the standard states for it,
108
+ * found from the run's own artifacts: the main stuff's concept, which the working memory names,
109
+ * and that concept's structure, which the first `output_form` or `input_form` node naming it
110
+ * states (a concept's node is the same wherever it stands). A concept no form describes keeps the
111
+ * shape the walk knows of a native, and is otherwise opaque. A `{ items: [...] }` content is the
112
+ * plural envelope, unless the concept has a field called `items`.
113
+ *
114
+ * `null` when the results carry no working memory, or one naming no main stuff: nothing then
115
+ * says what the output is, so a walk guided by it treats every value alike.
116
+ */
117
+ export function mainStuffNode(results) {
118
+ const memory = results.working_memory;
119
+ if (memory == null || typeof memory !== "object")
120
+ return null;
121
+ const aliases = memory.aliases;
122
+ const aliased = typeof aliases === "object" && aliases !== null
123
+ ? aliases[MAIN_STUFF_ALIAS]
124
+ : undefined;
125
+ const name = typeof aliased === "string" ? aliased : MAIN_STUFF_ALIAS;
126
+ const stuff = memory.root?.[name];
127
+ const conceptRef = conceptRefOf(stuff?.concept);
128
+ if (conceptRef === null)
129
+ return null;
130
+ return contentNode(conceptRef, results.main_stuff, results);
131
+ }
132
+ /**
133
+ * A descriptor node for a whole working memory (`{ root, aliases }`): each stuff's `content`
134
+ * described by the concept that stuff names, as {@link mainStuffNode} describes the main one.
135
+ * Nothing else in the memory is concept-typed.
136
+ */
137
+ export function workingMemoryNode(results) {
138
+ const memory = results.working_memory;
139
+ if (memory == null || typeof memory !== "object")
140
+ return null;
141
+ const root = memory.root;
142
+ if (typeof root !== "object" || root === null)
143
+ return null;
144
+ const stuffFields = [];
145
+ for (const [name, stuff] of Object.entries(root)) {
146
+ if (typeof stuff !== "object" || stuff === null)
147
+ continue;
148
+ const conceptRef = conceptRefOf(stuff.concept);
149
+ if (conceptRef === null)
150
+ continue;
151
+ const content = contentNode(conceptRef, stuff.content, results);
152
+ stuffFields.push(named(name, objectNode(null, [named("content", content)])));
153
+ }
154
+ return objectNode(null, [named("root", objectNode(null, stuffFields))]);
155
+ }
156
+ /**
157
+ * The node describing the child at `key` of a value described by `node`, or `undefined` when
158
+ * nothing describes it: a field of an object node, an item of a list node, and the `items` of the
159
+ * plural envelope a list content is serialized to, which the list node itself goes on describing.
160
+ */
161
+ export function childNode(node, parent, key) {
162
+ if (node === undefined)
163
+ return undefined;
164
+ if (node.kind === "list") {
165
+ if (Array.isArray(parent))
166
+ return node.item;
167
+ return key === LIST_ITEMS_FIELD ? node : undefined;
168
+ }
169
+ if (node.kind === "object" && typeof key === "string" && !Array.isArray(parent)) {
170
+ return node.fields.find((field) => field.name === key);
171
+ }
172
+ return undefined;
173
+ }
174
+ /** A stuff's concept as its reference: the string the standard carries, or a pre-0.60 `{ code, domain_code }`. */
175
+ function conceptRefOf(concept) {
176
+ if (typeof concept === "string")
177
+ return concept;
178
+ if (typeof concept === "object" && concept !== null) {
179
+ const fields = concept;
180
+ const domain = fields["domain_code"] ?? fields["domain"];
181
+ const code = fields["code"];
182
+ if (typeof domain === "string" && typeof code === "string")
183
+ return `${domain}.${code}`;
184
+ }
185
+ return null;
186
+ }
187
+ /** The node a content of `conceptRef` is walked with: the concept's node, wrapped when the content is plural. */
188
+ function contentNode(conceptRef, content, source) {
189
+ const element = nodeForConcept(conceptRef, source);
190
+ if (!isPluralEnvelope(content, element))
191
+ return element;
192
+ return {
193
+ kind: "list",
194
+ concept_ref: conceptRef,
195
+ ...(element.refines === undefined ? {} : { refines: element.refines }),
196
+ required: true,
197
+ item: element,
198
+ };
199
+ }
200
+ function isPluralEnvelope(content, element) {
201
+ if (typeof content !== "object" || content === null || Array.isArray(content))
202
+ return false;
203
+ const keys = Object.keys(content);
204
+ if (keys.length !== 1 || keys[0] !== LIST_ITEMS_FIELD)
205
+ return false;
206
+ if (!Array.isArray(content[LIST_ITEMS_FIELD]))
207
+ return false;
208
+ return !(element.kind === "object" && element.fields.some((field) => field.name === LIST_ITEMS_FIELD));
209
+ }
210
+ /** The node the forms state for a concept, else the native's own shape, else an opaque node. */
211
+ function nodeForConcept(conceptRef, source) {
212
+ for (const form of [source.output_form, source.input_form]) {
213
+ if (form == null || typeof form !== "object")
214
+ continue;
215
+ for (const descriptor of Object.values(form)) {
216
+ const roots = descriptorRoots(descriptor);
217
+ for (const root of roots) {
218
+ const found = findConceptNode(root, conceptRef);
219
+ if (found !== undefined)
220
+ return found;
221
+ }
222
+ }
223
+ }
224
+ return nativeNode(conceptRef);
225
+ }
226
+ /** The top nodes of one form entry: an output's `field`, an input's `fields`. */
227
+ function descriptorRoots(descriptor) {
228
+ if (typeof descriptor !== "object" || descriptor === null)
229
+ return [];
230
+ const entry = descriptor;
231
+ const roots = [];
232
+ if (isNode(entry.field))
233
+ roots.push(entry.field);
234
+ if (Array.isArray(entry.fields))
235
+ roots.push(...entry.fields.filter(isNode));
236
+ return roots;
237
+ }
238
+ function isNode(value) {
239
+ return (typeof value === "object" &&
240
+ value !== null &&
241
+ typeof value.kind === "string");
242
+ }
243
+ /** Depth first, the first node that is not a list and names `conceptRef`. */
244
+ function findConceptNode(node, conceptRef) {
245
+ if (node.kind !== "list" && node.concept_ref === conceptRef)
246
+ return node;
247
+ if (node.kind === "list" && isNode(node.item))
248
+ return findConceptNode(node.item, conceptRef);
249
+ if (node.kind === "object" && Array.isArray(node.fields)) {
250
+ for (const field of node.fields) {
251
+ if (!isNode(field))
252
+ continue;
253
+ const found = findConceptNode(field, conceptRef);
254
+ if (found !== undefined)
255
+ return found;
256
+ }
257
+ }
258
+ return undefined;
259
+ }
260
+ /** A concept no form describes: the shape of a native the walk knows, else an opaque node naming it. */
261
+ function nativeNode(conceptRef) {
262
+ const members = NATIVE_MEMBERS[conceptRef];
263
+ if (members !== undefined) {
264
+ return objectNode(conceptRef, Object.entries(members).map(([name, member]) => named(name, typeof member === "string"
265
+ ? nativeNode(member)
266
+ : {
267
+ kind: "list",
268
+ concept_ref: member[0],
269
+ required: true,
270
+ item: nativeNode(member[0]),
271
+ })));
272
+ }
273
+ const fileKind = NATIVE_FILE_KINDS[conceptRef];
274
+ if (fileKind !== undefined)
275
+ return { kind: fileKind, concept_ref: conceptRef, required: true };
276
+ return { kind: "unknown", concept_ref: conceptRef, required: true };
277
+ }
278
+ function objectNode(conceptRef, fields) {
279
+ return {
280
+ kind: "object",
281
+ ...(conceptRef === null ? {} : { concept_ref: conceptRef }),
282
+ required: true,
283
+ fields: fields,
284
+ };
285
+ }
286
+ function named(name, node) {
287
+ return { ...node, name };
288
+ }
289
+ //# sourceMappingURL=stored-texts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stored-texts.js","sourceRoot":"","sources":["../src/stored-texts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAKH,wEAAwE;AAExE,wGAAwG;AACxG,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,aAAa;IACb,iBAAiB;IACjB,aAAa;IACb,aAAa;CACL,CAAC;AAKX,MAAM,eAAe,GAA6C;IAChE,aAAa,EAAE,MAAM;IACrB,iBAAiB,EAAE,MAAM;IACzB,aAAa,EAAE,MAAM;IACrB,aAAa,EAAE,MAAM;CACtB,CAAC;AAEF,0FAA0F;AAC1F,MAAM,CAAC,MAAM,uBAAuB,GAA6C;IAC/E,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,YAAY;IACl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,CAAC;IACD,MAAM,QAAQ,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAC/C,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC/F,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AACtE,CAAC;AAED,SAAS,UAAU,CAAC,UAAyB,EAAE,MAAuB;IACpE,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,GAAG,CAAC,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;QAC3D,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,MAA8D;KACvE,CAAC;AACJ,CAAC;AAED,SAAS,KAAK,CAAC,IAAY,EAAE,IAAmB;IAC9C,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAA8B,CAAC;AACvD,CAAC"}
package/dist/version.d.ts CHANGED
@@ -3,4 +3,4 @@
3
3
  * `User-Agent` without importing the public barrel. Kept in sync with
4
4
  * `package.json` — enforced by `tests/index.test.ts`.
5
5
  */
6
- export declare const SDK_VERSION = "0.67.0";
6
+ export declare const SDK_VERSION = "0.69.0";
package/dist/version.js CHANGED
@@ -3,5 +3,5 @@
3
3
  * `User-Agent` without importing the public barrel. Kept in sync with
4
4
  * `package.json` — enforced by `tests/index.test.ts`.
5
5
  */
6
- export const SDK_VERSION = "0.67.0";
6
+ export const SDK_VERSION = "0.69.0";
7
7
  //# sourceMappingURL=version.js.map
@@ -132,6 +132,7 @@ Flat `src/` (mirrors `mthds-js`'s `runners/api` flatness — the SDK has one cli
132
132
  - `errors.ts` — the typed errors, each carrying its failure as a problem document. The abstract `PipelexRequestError` refines the standard's `ProblemError` (from `mthds/protocol`), so every getter that reads the problem (`code`, `domain`, `retry`, `nextStep`, `retryAfter`, `requestId`) is on every SDK error, and it takes the problem as a constructor argument, so every subclass states its problem where it is raised and one that forgets it does not compile. The message stays the SDK's own sentence. Under that base sit `RequestArgumentError` (the client refusing a call's arguments before sending any request, `client.argument_invalid` unless the site gives another, as the invalid base URL gives `client.not_configured`), the transport and run-lifecycle errors, `PagingNotTerminatingError`, the input-preparation family under `InputPreparationError`, and the artifact family under `ArtifactOperationError` (`ScopeUnavailableError`, `ArtifactFetchError`, `ArtifactAuthenticationError`, the last carrying the download verdict so far). `ApiResponseError` carries the answer read as its problem (`readHostedAnswer`), with its `status`, `statusText` and raw `responseBody`, and also stands for a 2xx answer the SDK could not read. `RunFailedError` carries `run.failed` and reads the run's own problem, which it nests as `run_error`, as `runError`. The module also holds the builders of the problems the SDK states itself (`argumentInvalidProblem`, `responseUnreadableProblem`, `storageStatusProblem`, `uploadTransportProblem`, `artifactFetchProblem`, `methodFileTransferProblem`, `runFailedProblem`) and the codes a caller branches on (`MethodErrorCode`, `IdempotencyErrorCode`, `LogoRefusalCode`). It is not the whole error surface: `codegen-check.ts` exports `CodegenLockError` and `exact-json.ts` `ExactJsonUnsupportedError`, both `ProblemError`s outside the request family because nothing was requested over the wire. The shared case file `tests/fixtures/sdk-problems.json` pins each problem's code for both SDKs. See [errors.md](./errors.md#the-problem-every-error-carries).
133
133
  - `user-agent.ts` — client identification per the spec `conformance/specs/client-identification.md`, in the `conformance` repository beside the specs' tests: the exported `AppInfo` option, its RFC 9110 token validation (a `TypeError` on a bad field, a `RangeError` past the 512-character ceiling), its rendering, the runtime detection (Node, Bun, Deno, or a browser, where no header is set) and `buildUserAgent`, which the client calls once at construction. The barrel re-exports `buildUserAgent`, `validateAppInfo`, `MAX_USER_AGENT_LENGTH` and the `RuntimeInfo` type, so a consumer's raw fetches send the same value. The client's private `requestHeaders` is the one place API request headers are built, so every route carries the value; the artifact fetch of a presigned link never goes through it. See [client-identification.md](./client-identification.md).
134
134
  - `exact-json.ts` — `parseExactJson` and `stringifyExactJson`, JSON whose integers stay exact, and `ExactJsonUnsupportedError`. The reader, which the client applies to every answer carrying a person's data (a method example, a run's record, a run's results, the blocking execute's answer), is one `JSON.parse` call whose reviver turns a number past `Number.MAX_SAFE_INTEGER` spelled as an integer into a `bigint` of its source text (`context.source`), so it reads everything else exactly as `JSON.parse` does, with no second parser to keep in step; a text holding no run of 16 digits is parsed with no reviver at all. On a runtime whose reviver gets no source text, it refuses a whole number past the safe range with `ExactJsonUnsupportedError`, which the client reports as an answer it cannot read, rather than rounding it. The writer, which `requestRaw` applies to every request body before the request is made, is one `JSON.stringify` call whose replacer turns each `bigint` into `JSON.rawJSON` text, so every getter and `toJSON` in the body runs once, and a `bigint` an inherited `toJSON` such as the `BigInt.prototype.toJSON` polyfill already turned into a string is looked up in its holder and written as its digits; a runtime without `JSON.rawJSON` refuses the `bigint`, as a `RequestArgumentError` from the client, rather than rounding it. The barrel exports all three, for a caller showing such data as JSON text; the error is a `ProblemError` whose problem is `client.tool_outdated`, naming the JavaScript runtime. It imports nothing but the standard's problem helpers. See [exact-integers.md](./exact-integers.md).
135
+ - `signals.ts` — `eitherSignal`, a signal that aborts when either of two does, built by hand because older browsers lack `AbortSignal.any`. It imports nothing, so the poll loop in `runs.ts`, which joins the wait's deadline to the caller's signal, and the tree uploads in `client.ts` both use it.
135
136
  - `timers.ts` — `MAX_TIMER_DELAY_MS`, the longest delay `setTimeout` honours, and `isTimerDelay`, which every caller-supplied `timeoutMs` is checked against before it reaches a timer: a longer delay overflows and fires at once. It imports nothing, so the browser-safe upload entry uses it too.
136
137
  - `node-host.ts` and `node-host/` — the Node host ([above](#the-node-host)): `loadNodeHost()` and `isNodeRuntime()` in `node-host.ts`, the Node variant `node-host/node.ts`, the only module of the barrel's graph that imports a Node built-in, `undici` or the `mthds` root entry, and `node-host/unavailable.ts`, the variant every other runtime resolves.
137
138
  - `version.ts` — `SDK_VERSION`, in its own module so the client stamps it on the `User-Agent` without importing the barrel, which re-exports it.
@@ -159,7 +160,7 @@ Flat `src/` (mirrors `mthds-js`'s `runners/api` flatness — the SDK has one cli
159
160
  The hosted catalog/account routes the webapp drives. All ride the same `{base}/v1/*` + `Authorization: Bearer` + org-from-JWT contract as the protocol routes, go through the shared `requestProduct<T>` helper (30s management timeout, empty-body tolerant), and map a non-2xx RFC 9457 `problem+json` to a typed `ApiResponseError`. Every route parses a 2xx body through one private helper, so an answer that is not JSON (a gateway's HTML page, an empty body where one was due) is an `ApiResponseError` carrying its status and raw text, `client.response_unreadable`, rather than a bare `SyntaxError`. A product route whose answer the SDK or its caller reads before anything else (`listMethods`, `listRuns`, `getRunDetail`, `upload`, `requestUploadGrant`, `resolveStorageUrls`, and the methods routes answering one stored method) goes through `requestProductObject` or a helper built on the same read instead, which also refuses an empty body and JSON that is not an object; the two paged routes then refuse, the same way, through one page reader, a page whose `items` is not an array or whose `next_cursor` is neither a string nor `null`, `upload` an answer with no non-empty string `uri`, and `getMethod` and `getMethodVersion` a `files` member that is not a listing of files, each with its string `path`, `sha256`, `url` and `expires_at` and a non-negative integer `size`. Every refusal the platform renders is a problem document under a registered code, a core one (`request.invalid`, `auth.forbidden`, …) or a Pipelex one (`pipelex.catalog.not_found`, `pipelex.billing.plan_limit`, …), and consumers branch on its `code`, as the hosted-envelope spec (`conformance/specs/pipelex-hosted-envelope.md`, in the `conformance` repository) says, never on the HTTP status. An answer whose body is no problem document comes from the hosted edge and reads by its status. See [errors.md](./errors.md).
160
161
 
161
162
  - **User profile:** `getMe` (`GET /v1/me`).
162
- - **Methods catalog:** `listMethods`, `getMethod`, `createMethod`, `writeDraft`, `renameMethod`, `publishMethod`, `listMethodVersions`, `getMethodVersion`, `deleteMethod`. **A saved method has a draft and immutable published versions.** Its draft is a method tree with its `input_data`, which `writeDraft` (`PUT /v1/methods/{id}/draft`) replaces whole, without validating it; `updated_at` is the draft's token, which moves on every draft write and nothing else, and `draft_digest` the draft's tree digest (`sha256:` and 64 hex digits), `null` for an empty draft. A save takes the tree as `files`, sent as given, or as `directory`, `tree` or `contents`, sent inline or by hash after uploading the blobs the organization lacks, and a read lists the tree's files, each with a short-lived link to its bytes, which `writeMethodTree` writes to disk ([method-trees.md](./method-trees.md)). A draft write may carry `expected_updated_at`, the token the caller last saw, and is then a compare-and-swap: a draft that moved since is a `409` `pipelex.catalog.update_conflict` and nothing is written. `renameMethod` (`PATCH /v1/methods/{id}`) changes the name alone and moves no token; with `expected_name` it lands only while the method still holds that name, and is otherwise the same `409` `pipelex.catalog.update_conflict`, naming `expected_name`, with nothing written. `publishMethod` (`POST /v1/methods/{id}/publish`) takes the required `expected_draft_updated_at` and answers a `MethodPublishResult` discriminated on `outcome` — `published` with the new version, `unchanged` with the existing latest version when the draft's digest equals it, `refused` with a `reason` (`invalid` or `not_runnable`, and for a public method `storage_reference`, `thumbnail_missing` or `thumbnail_invalid`, read open so a later reason arrives as its raw string), a `message` and the runner's `validation` verdict, its problem items read member by member as `validate` reads them — every arm carrying the `method`; the SDK reads the nested method as `getMethod` does, and an answer whose `outcome` is none of these, or a refusal whose `validation` is not a verdict object, is an answer it cannot read. A publish that produced no verdict is thrown rather than answered: only a draft that differs from the latest version reaches the runner, and a runner that cannot be reached, answers unusably or does not finish within the platform's deadline is a `502` or `503` with nothing written, so a retry is safe, and a retry of a publish that landed while its answer was lost answers `unchanged` with the version it wrote. A method is stored as one item that keeps room for the summary a publish adds, so a draft that saves can always be published: a creation or a draft write is a `413` `request.too_large` when it would grow the method past that room, below the store's item limit, and a rename is the same `413` for a name so long it would leave the method too large to publish. A version is numbered from 1, never reused, and holds the draft's tree as it stood, its `tree_digest` (`null` for a version stored before methods were trees), its `crate_fingerprint` (`null` when the runner could not resolve the bundle in memory), the runner's version, and when and by whom it was published; `listMethodVersions` pages the summaries newest first (`MethodVersionPage`, `{items, nextCursor}`, a `limit` from 1 to 100, 20 by default, and a `422` outside that range), and `getMethodVersion` reads one with its `files` listed as a method's are, or answers a `500` `runtime.unexpected` for a version stored before methods were trees and never rewritten as one. A method read carries `latest_version` and `latest_published`, both `null` until the first publish, so the publish state is derived: never published, draft unchanged (`draft_digest` not `null` and equal to `latest_published.tree_digest`), or draft ahead. The method routes take a bare id and address the method itself, never one of its versions; the platform does not parse a suffix there, so `mt_x@3` would answer a `404` that reads as a method that does not exist, and each route refuses a suffixed id with `RequestArgumentError` before anything is sent, naming `parseMethodSelector` and `getMethodVersion`. The whole-method `updateMethod` is gone, replaced by the draft write and the rename. **`deleteMethod` is asynchronous and its return type says so:** `DELETE /v1/methods/{id}` answers `202` with a `MethodDeletionAccepted` (`method_id`, `deletion_state`, `deletion_job_id`) the moment the platform has claimed the method and terminated its in-flight workflows — the rest of the cascade (runs, events, S3 objects) is enqueued. A resolved promise means "accepted", never "gone"; completion is the row disappearing from `listMethods`, not any field of that body. The claim is a conditional write, so a double-clicked delete is a `409` `pipelex.catalog.being_deleted` rather than a second cascade over the same runs, and an unknown or foreign-org id is a `404`. The erasure deletes the method's versions with the rest. (This doc previously stated the SDK had no `delete` because the platform had no such route — the route has always existed; the claim was simply false.) `listMethods` returns **one page**, not the whole catalog — a `MethodPage` (`{items, nextCursor}`) served from a narrow index projection, so its cost is the page size rather than the size of the catalog. It used to return every method with its full `.mthds` bundle attached, which hit DynamoDB's 1 MB page cap at a couple hundred methods and came back truncated with no error and no flag, so methods silently vanished from the UI. Rows are therefore `MethodSummary`, **not** `MethodDetail`: no `files`, no `updated_at`, because neither is in the projection and putting the source back is what restored the truncation. Reach for `getMethod(id)` when you need a method's files. `query.q` is applied server-side across the whole catalog, not over the page — filtering one page client-side would be searching 50 rows of 10,000 and calling it a search. `query.published` filters the same way, sent as `published=true` (the methods with a published version) or `published=false` (those never published), and combines with `q`. Each row carries the method's publish state, so a list tells its methods apart without reading each one: `latest_version` and `latest_published` (a `MethodVersionSummary`), both `null` when the method was never published, and `draft_digest`, `null` for an empty draft; all three are optional, absent from a platform that does not serve them. Never published is `latest_version === null`, the draft unchanged is a `draft_digest` that is not `null` and equals `latest_published.tree_digest`, and the draft ahead is two digests that differ. Both filters run after the index read, so **a filtered page can come back empty and still carry a `nextCursor`**: an empty page is not the end of the list, and only a `null` cursor is. `iterateMethods` is the async iterator that follows the cursor for callers who genuinely want everything (`for await (const m of client.iterateMethods())`); it keeps going **past empty pages**, since `{items: [], nextCursor: "…"}` means "nothing matched in the slice I just read, keep going". A server that keeps minting fresh cursors forever stops it at a page ceiling far past any real catalog with a `PagingNotTerminatingError` carrying `pageLimit`, never a silently truncated stream; `iterateRuns` shares the same loop. It gives up only when the server stops advancing its cursor, and **throws** rather than returning a partial answer; like `iterateRuns` it is deliberately not a `listAllMethods(): Promise<MethodSummary[]>`, because an all-at-once helper needs a page cap and a cap means silently returning a truncated list. `MethodSummary.deletion_state` rides the list rows: a method mid-erasure stays listed so the UI can render it as "Deleting…", while `getMethod` refuses it with a 409. Full read responses (`MethodDetail`, from `getMethod`) carry `org_id`, `created_by_user_id`, a server-derived `description` (recomputed on every draft write from the manifest's `description`, else the primary bundle's top-level `description`, else its main pipe's), `categories` and `visibility`, the draft token and digest, the latest version's summary and the draft's `files` on top of the write contract's `name` / `input_data`; the writes and the rename answer `MethodData`, the same method without `files`. Another organization's public method reads as a `PublicMethodDetail`, its latest published version and nothing of its draft, so `getMethod` is typed `MethodDetail | PublicMethodDetail`, told apart by `updated_at`; an answer without it that carries a member only the owner's read has is an answer the SDK cannot read, and so is a public read without its `latest_version` and `latest_published` ([public-methods.md](./public-methods.md)).
163
+ - **Methods catalog:** `listMethods`, `getMethod`, `createMethod`, `writeDraft`, `renameMethod`, `publishMethod`, `listMethodVersions`, `getMethodVersion`, `deleteMethod`. **A saved method has a draft and immutable published versions.** Its draft is a method tree with its `input_data`, which `writeDraft` (`PUT /v1/methods/{id}/draft`) replaces whole, without validating it; `updated_at` is the draft's token, which moves on every draft write and nothing else, and `draft_digest` the draft's tree digest (`sha256:` and 64 hex digits), `null` for an empty draft. A save takes the tree as `files`, sent as given, or as `directory`, `tree` or `contents`, sent inline or by hash after uploading the blobs the organization lacks, and a read lists the tree's files, each with a short-lived link to its bytes, which `writeMethodTree` writes to disk ([method-trees.md](./method-trees.md)). A draft write may carry `expected_updated_at`, the token the caller last saw, and is then a compare-and-swap: a draft that moved since is a `409` `pipelex.catalog.update_conflict` and nothing is written. `renameMethod` (`PATCH /v1/methods/{id}`) changes the name alone and moves no token; with `expected_name` it lands only while the method still holds that name, and is otherwise the same `409` `pipelex.catalog.update_conflict`, naming `expected_name`, with nothing written. `publishMethod` (`POST /v1/methods/{id}/publish`) takes the required `expected_draft_updated_at` and answers a `MethodPublishResult` discriminated on `outcome` — `published` with the new version, `unchanged` with the existing latest version when the draft's digest equals it, `refused` with a `reason` (`invalid` or `not_runnable`, and for a public method `storage_reference`, `thumbnail_missing` or `thumbnail_invalid`, read open so a later reason arrives as its raw string), a `message` and the runner's `validation` verdict, its problem items read member by member as `validate` reads them — every arm carrying the `method`; the SDK reads the nested method as `getMethod` does, and an answer whose `outcome` is none of these, or a refusal whose `validation` is not a verdict object, is an answer it cannot read. A publish that produced no verdict is thrown rather than answered: only a draft that differs from the latest version reaches the runner, and a runner that cannot be reached, answers unusably or does not finish within the platform's deadline is a `502` or `503` with nothing written, so a retry is safe, and a retry of a publish that landed while its answer was lost answers `unchanged` with the version it wrote. A method is stored as one item that keeps room for the summary a publish adds, so a draft that saves can always be published: a creation or a draft write is a `413` `request.too_large` when it would grow the method past that room, below the store's item limit, and a rename is the same `413` for a name so long it would leave the method too large to publish. A version is numbered from 1, never reused, and holds the draft's tree as it stood, its `tree_digest` (`null` for a version stored before methods were trees), its `crate_fingerprint` (`null` when the runner could not resolve the bundle in memory), the runner's version, and when and by whom it was published; `listMethodVersions` pages the summaries newest first (`MethodVersionPage`, `{items, nextCursor}`, a `limit` from 1 to 100, 20 by default, and a `422` outside that range), and `getMethodVersion` reads one with its `files` listed as a method's are, or answers a `500` `runtime.unexpected` for a version stored before methods were trees and never rewritten as one. A method read carries `latest_version` and `latest_published`, both `null` until the first publish, so the publish state is derived: never published, draft unchanged (`draft_digest` not `null` and equal to `latest_published.tree_digest`), or draft ahead. The method routes take a bare id and address the method itself, never one of its versions; the platform does not parse a suffix there, so `mt_x@3` would answer a `404` that reads as a method that does not exist, and each route refuses a suffixed id with `RequestArgumentError` before anything is sent, naming `parseMethodSelector` and `getMethodVersion`. The whole-method `updateMethod` is gone, replaced by the draft write and the rename. **`deleteMethod` is asynchronous and its return type says so:** `DELETE /v1/methods/{id}` answers `202` with a `MethodDeletionAccepted` (`method_id`, `deletion_state`, `deletion_job_id`) the moment the platform has claimed the method and terminated its in-flight workflows — the rest of the cascade (runs, events, S3 objects) is enqueued. A resolved promise means "accepted", never "gone"; completion is the row disappearing from `listMethods`, not any field of that body. The claim is a conditional write, so a double-clicked delete is a `409` `pipelex.catalog.being_deleted` rather than a second cascade over the same runs, and an unknown or foreign-org id is a `404`. The erasure deletes the method's versions with the rest. (This doc previously stated the SDK had no `delete` because the platform had no such route — the route has always existed; the claim was simply false.) `listMethods` returns **one page**, not the whole catalog — a `MethodPage` (`{items, nextCursor}`) served from a narrow index projection, so its cost is the page size rather than the size of the catalog. It used to return every method with its full `.mthds` bundle attached, which hit DynamoDB's 1 MB page cap at a couple hundred methods and came back truncated with no error and no flag, so methods silently vanished from the UI. Rows are therefore `MethodSummary`, **not** `MethodDetail`: no `files`, no `updated_at`, because neither is in the projection and putting the source back is what restored the truncation. Reach for `getMethod(id)` when you need a method's files. `query.q` is applied server-side across the whole catalog, not over the page — filtering one page client-side would be searching 50 rows of 10,000 and calling it a search. `query.published` filters the same way, sent as `published=true` (the methods with a published version) or `published=false` (those never published), and combines with `q`. `query.createdBy` filters the same way again, sent as `created_by`: `"me"` keeps the caller's own methods, resolved by the platform from the authenticated identity, a member's user id keeps that member's, and an id naming nobody lists nothing; it combines with `q` and `published`. Each row names who created the method in `created_by_user_id`, the canonical user id of that member, so a list can show each row's author from the organization's members; it is optional, absent from a platform that does not serve it. Each row carries the method's publish state, so a list tells its methods apart without reading each one: `latest_version` and `latest_published` (a `MethodVersionSummary`), both `null` when the method was never published, and `draft_digest`, `null` for an empty draft; all three are optional, absent from a platform that does not serve them. Never published is `latest_version === null`, the draft unchanged is a `draft_digest` that is not `null` and equals `latest_published.tree_digest`, and the draft ahead is two digests that differ. The filters run after the index read, so **a filtered page can come back empty and still carry a `nextCursor`**: an empty page is not the end of the list, and only a `null` cursor is. `iterateMethods` is the async iterator that follows the cursor for callers who genuinely want everything (`for await (const m of client.iterateMethods())`), sending its query with every page; it keeps going **past empty pages**, since `{items: [], nextCursor: "…"}` means "nothing matched in the slice I just read, keep going". A server that keeps minting fresh cursors forever stops it at a page ceiling far past any real catalog with a `PagingNotTerminatingError` carrying `pageLimit`, never a silently truncated stream; `iterateRuns` shares the same loop. It gives up only when the server stops advancing its cursor, and **throws** rather than returning a partial answer; like `iterateRuns` it is deliberately not a `listAllMethods(): Promise<MethodSummary[]>`, because an all-at-once helper needs a page cap and a cap means silently returning a truncated list. `MethodSummary.deletion_state` rides the list rows: a method mid-erasure stays listed so the UI can render it as "Deleting…", while `getMethod` refuses it with a 409. Full read responses (`MethodDetail`, from `getMethod`) carry `org_id`, `created_by_user_id`, a server-derived `description` (recomputed on every draft write from the manifest's `description`, else the primary bundle's top-level `description`, else its main pipe's), `categories` and `visibility`, the draft token and digest, the latest version's summary and the draft's `files` on top of the write contract's `name` / `input_data`; the writes and the rename answer `MethodData`, the same method without `files`. Another organization's public method reads as a `PublicMethodDetail`, its latest published version and nothing of its draft, so `getMethod` is typed `MethodDetail | PublicMethodDetail`, told apart by `updated_at`; an answer without it that carries a member only the owner's read has is an answer the SDK cannot read, and so is a public read without its `latest_version` and `latest_published` ([public-methods.md](./public-methods.md)).
163
164
  - **Method examples:** `createMethodExample`, `listMethodExamples`, `iterateMethodExamples`, `getMethodExample`, `updateMethodExample`, `recordMethodExampleLatestRun`, `saveAssistantMethodExample`, `deleteMethodExample`, on `/v1/methods/{id}/examples`. An example is a named set of inputs saved on a method, shared across the organization, with an `input_revision` that rises each time its inputs change and the `latest_run_id` of those inputs, which an inputs edit clears. `recordMethodExampleLatestRun` records a run against the revision whose inputs it used and answers a `MethodExampleLatestRunResult` discriminated on `outcome`, `recorded` or `stale`, each arm carrying the `example`: a run that outlasted an edit is a verdict, never thrown, and an answer off the union is one the SDK cannot read; `saveAssistantMethodExample` is the build assistant's save, which writes into the example it names only while that example is still the assistant's (`kept_by_assistant`) at the revision it read, and otherwise creates one, answering a `MethodExampleAssistantSaveResult` discriminated on `outcome`, `kept` or `created`; one helper, `readVerdict`, reads these verdicts and `publishMethod`'s, the example checked once, by the reader every example goes through. Every answer carrying an example is read with `parseExactJson` and every request body written with `stringifyExactJson`, so an integer past `Number.MAX_SAFE_INTEGER` in the inputs reads as a `bigint` and goes back digit for digit, to an edit or as a run's inputs; `3.0` still reads as `3`, and inputs holding one sent back unchanged are an edit for the platform, which compares inputs as canonical JSON. Every example the client hands back, the page rows and the verdict's `example` included, is checked by `readMethodExample` against the fields the Python SDK's model requires, with the strict types it holds them to, an example breaking one being an answer the SDK cannot read. The list is paged oldest first by an opaque cursor, and a page may be short while `nextCursor` is set; `iterateMethodExamples` follows it through the loop `iterateMethods` and `iterateRuns` share, and refuses a method id at the call rather than at the first pull. Every method takes a bare catalog id, and the client refuses an example id that is empty, `.` or `..` or holds a lone surrogate, a create without its name or inputs or whose `run_id` is given but empty, an edit naming neither `name` nor `inputs`, and a latest-run write without a run id or a positive integer revision before sending. See [method-examples.md](./method-examples.md).
164
165
  - **Template catalog:** `listMethodTemplates`, `iterateMethodTemplates`, on `GET /v1/method-templates`, and `listMethodCategories`, on `GET /v1/method-categories`. The public methods of the deployment's templates organization, in the order the platform serves for the `ordering` asked for, filtered by `category`, with the page's `categories` and each card's thumbnails behind short-lived links. `listMethodTemplates` reads the page with its own reader rather than `requestPage`, since its `ordering` and `categories` sit beside `items` and `nextCursor`, and redacts the links of an answer it cannot read; `iterateMethodTemplates` follows the cursor with the same ordering and category. `listMethodCategories` reads the catalog's whole list of categories, which an admin of the platform keeps, in its order. Both check each category with one reader, `methodCategoriesFault`: a string `slug` and `label`, and `labels`, an object of strings by language tag ([public-methods.md](./public-methods.md)).
165
166
  - **Method copies:** `copyMethod`, on `/v1/methods/{id}/copy`. `copyMethod` makes a new, unpublished method in an organization the caller may change methods in, the method's own for a duplicate, holding the original's draft tree, its form inputs and its examples, the stored files they name copied into the destination, and answers a `MethodCopyResult` discriminated on `outcome`: `copied` with the copy as `method` and what was copied, or `refused` with the `references` of a bundle naming storage the destination cannot read or, in a duplicate, a file under the original's run files, which erasing the original would remove. The two arms carry different members, so the verdict is read by the copy itself rather than by `readVerdict`, which reads verdicts whose arms share one: an `outcome` off the union, a `copied` answer whose `method` is not an object and a `refused` one whose `references` is not an array are each an answer the SDK cannot read. Its body is closed, `destination_org_id` with `name` and `expected_draft_updated_at` when given, and its last argument takes an `idempotencyKey`, sent as the `Idempotency-Key` header through the same `requestRaw` option and the same `idempotencyKeyOf` check a start uses. Every method read carries `copied_from`, the original a copy names, `null` on a method created afresh. `MethodErrorCode` names the copy's own codes, `pipelex.org.not_found` and `pipelex.catalog.copy_too_large`, whose `limit` member is typed `MethodCopyLimit`. It takes a bare catalog id. See [method-copy.md](./method-copy.md).
@@ -35,6 +35,8 @@ Walks any JSON-shaped value and returns every string that **is** a `pipelex-stor
35
35
 
36
36
  Both are pure — no network, no key — and exported standalone, so a consumer can count, list or place a result's files without resolving any of them.
37
37
 
38
+ **Stored texts are not files.** A large `Text`, `Markdown`, `Html` or `JSON` value the runtime stored travels as a `pipelex-storage://` reference too ([`run-results.md`](./run-results.md#stored-texts--loaded-by-default)), and only its concept tells it from a file. Both walks take the walked value's descriptor node as a second argument, `locateArtifacts(results.main_stuff, mainStuffNode(results))`, and then skip every stored text; without it nothing says what a value is, so every reference counts as a file. A result read with its texts loaded, the default, holds none. `locateStoredReferences(value, node)` answers both kinds, `{ files, texts }`: the files as `locateArtifacts` gives them, and each text as a `StoredTextLocation` carrying its `kind` (`text`, `html` or `json`), `size`, `mime_type` and `preview`, its `found_at` being the path of its `url`.
39
+
38
40
  ### `resolveArtifacts(uris)` — fresh links for a whole list
39
41
 
40
42
  ```ts
@@ -48,7 +50,7 @@ for (const item of resolved) {
48
50
  }
49
51
  ```
50
52
 
51
- One call to the platform's bulk route for the whole list, chunked at the route's bound of 100 references per request (`BULK_RESOLVE_MAX_URIS`), answering one `ResolvedArtifact` per reference **in request order, duplicates included**. A resolved item carries `url`, `expires_at` (UTC, ISO 8601) and `content_type` (`string | null` — the platform's guess from the reference's extension, null when it has none) with `error: null`; a refused item carries `error` as `{ code, detail }` with the three link fields null. The codes are the route's: `invalid_storage_uri` for a malformed reference and `forbidden` for one belonging to another organization. A consumer branches on `error`, never on an HTTP status, because the request is a `200` whenever every reference got a verdict.
53
+ One call to the platform's bulk route for the whole list, chunked at the route's bound of 100 references per request (`BULK_RESOLVE_MAX_URIS`), answering one `ResolvedArtifact` per reference **in request order, duplicates included**. A resolved item carries `url`, `expires_at` (UTC, ISO 8601) and `content_type` (`string | null` — the platform's guess from the reference's extension, null when it has none) with `error: null`; a refused item carries `error` as `{ code, detail }` with the three link fields null. The codes are the route's, from the platform's registry: `pipelex.storage.uri_invalid` for a malformed reference and `pipelex.org.mismatch` for one belonging to another organization. A consumer branches on `error`, never on an HTTP status, because the request is a `200` whenever every reference got a verdict.
52
54
 
53
55
  Only what is not about a reference throws: the route's whole-request refusals (a caller with no organization, a request over the bound or with an unknown field, a signing failure, a deployment without the route) as `ApiResponseError`, and an unreachable host as `ApiUnreachableError`. An empty list resolves to an empty list with no request made. A link lives about fifteen minutes; resolve close to the moment of use.
54
56
 
@@ -82,7 +84,7 @@ Resolves the reference fresh and returns the object store's response as a bounde
82
84
 
83
85
  It is **header-neutral**: the status, status text and headers are the store's own. The one change is that a `Content-Encoding` the fetch already decoded is dropped with the encoded `Content-Length`, since the body handed on is the decoded bytes. A proxy relaying it therefore owns the response hygiene — `X-Content-Type-Options: nosniff`, a sandboxing CSP on the asset response, a controlled `Content-Disposition`, private caching — and must set them itself, as the example does.
84
86
 
85
- Only a `2xx` is returned. Anything else throws an `ArtifactFetchError` whose `reason` says why, beside its problem ([errors.md](./errors.md#each-classs-problem)), in the same closed vocabulary the download verdict uses per item: the route's `invalid_storage_uri` / `forbidden`, then `unsupported_url` (not a URL, not http(s), or carrying credentials), `plain_http_refused`, `redirect_refused`, `store_refused` (a 401/403 from the store — the link is freshly minted, so this is the store refusing a fresh signature, not an expired link), `not_found` (404/410), `store_error` (any other non-2xx, with `status`), `too_large`, `timeout` and `network`. Its problem follows its `reason` and `status`: a `store_error` or a `store_refused` is `runtime.unavailable`, `retry` `yes`, when its `status` is a `408`, a `429` or a `5xx` other than `501`, `runtime.unsupported` for a `501`, and `client.response_unreadable` naming the status, `retry` `no`, for any other status, so a `400`, a `405`, a `401` or a `403` is not worth asking again; `timeout` and `network` are `runtime.unavailable`, `retry` `yes`. The caller's abort propagates as-is, and the body reader is cancelled with it. `downloadArtifacts` and a proxy share this boundary: the download is the same fetch followed by a write.
87
+ Only a `2xx` is returned. Anything else throws an `ArtifactFetchError` whose `reason` says why, beside its problem ([errors.md](./errors.md#each-classs-problem)), in the same closed vocabulary the download verdict uses per item: the route's `pipelex.storage.uri_invalid` / `pipelex.org.mismatch`, both read as `input.reference_not_found`, then `unsupported_url` (not a URL, not http(s), or carrying credentials), `plain_http_refused`, `redirect_refused`, `store_refused` (a 401/403 from the store — the link is freshly minted, so this is the store refusing a fresh signature, not an expired link), `not_found` (404/410), `store_error` (any other non-2xx, with `status`), `too_large`, `timeout` and `network`. Its problem follows its `reason` and `status`: a `store_error` or a `store_refused` is `runtime.unavailable`, `retry` `yes`, when its `status` is a `408`, a `429` or a `5xx` other than `501`, `runtime.unsupported` for a `501`, and `client.response_unreadable` naming the status, `retry` `no`, for any other status, so a `400`, a `405`, a `401` or a `403` is not worth asking again; `timeout` and `network` are `runtime.unavailable`, `retry` `yes`. The caller's abort propagates as-is, and the body reader is cancelled with it. `downloadArtifacts` and a proxy share this boundary: the download is the same fetch followed by a write.
86
88
 
87
89
  ### `downloadArtifacts({ run_id | results, dir, … })` — the files on disk
88
90
 
@@ -106,6 +108,8 @@ if (!verdict.all_saved) {
106
108
 
107
109
  **Where it reads from.** Exactly one of `run_id` and `results`. A `run_id` re-reads the results through `getRunResult`, asking only for the scope's artifact, so a completed run is downloadable days later from its id alone; a `RunResults` already in hand is read as it is, with no request. `scope` picks the artifact walked for references: `main_stuff` (the default) is the run's output, and `working_memory` is the opt-in that also brings down the echoed inputs and every intermediate stuff — it is read off the parsed results body, whether or not `RunResults` declares the field.
108
110
 
111
+ **Stored texts are saved as text files.** The walk follows the concepts of the run (`mainStuffNode`, or each stuff's concept for `working_memory`), so a stored text is saved beside the files rather than counted as one: its verdict entry has `kind: "text"` where a file's has `kind: "file"`, its `content_type` is the MIME type its reference states, and its file is named by that type. A download by `run_id` reads the run's `working_memory`, `output_form` and `input_form` beside its scope when the scope may hold a stored text, and reads the scope with `loadStoredTexts: false`.
112
+
109
113
  **How it downloads.** The whole set is resolved through the bulk route ahead of the workers, then a bounded number of workers (`concurrency`, default 4) each take the next reference and fetch it → open its file with `wx` → stream the body in. Resolution is just-in-time where it matters: a link that has expired by the time its worker reaches it — a large set downloaded a few at a time can outlive the fifteen-minute link — is resolved again for that reference alone, so no fetch ever runs on a stale signature.
110
114
 
111
115
  **Filenames: each file is named after the field it fills.** The name comes from the first path in the reference's `found_at`, by the rule `artifactFilename(location, contentType, scope)` (exported) applies:
@@ -115,7 +119,7 @@ if (!verdict.all_saved) {
115
119
  3. The segments are joined with `-`. A reference that is the walked value itself, or its `url`, has no segment left and takes the scope's name, so an output that is one image is saved as `main_stuff.png`.
116
120
  4. A name over the length cap (128 characters, extension included) keeps its tail: whole leading segments are dropped first, since the last ones are the specific ones, and a single segment still too long is cut to fit.
117
121
  5. A stem Windows reserves for a device — `con`, `prn`, `aux`, `nul`, `com0` to `com9` or `lpt0` to `lpt9`, in any case — gets a trailing `_`, so a field named `aux` is saved as `aux_.png`. Windows reserves those names whatever the extension, and a field name is the method author's to choose.
118
- 6. The extension is the one the storage key's last segment carries, reduced to `[A-Za-z0-9]`, when it has a short one; otherwise the content type's, for the types a run produces (`image/png` gives `.png`, `application/pdf` gives `.pdf`); otherwise there is none.
122
+ 6. The extension is the one the storage key's last segment carries, reduced to `[A-Za-z0-9]`, when it has a short one; otherwise the content type's, for the types a run produces (`image/png` gives `.png`, `application/pdf` gives `.pdf`); otherwise there is none. A stored text is named by the MIME type its reference states instead, never by its storage key: `text/plain` gives `.txt`, `text/markdown` `.md`, `text/html` `.html` and `application/json` `.json`, and a type outside those gives its kind's (`.txt`, `.html`, `.json`).
119
123
 
120
124
  For example, a home-staging method whose output is
121
125
 
package/docs/cli.md CHANGED
@@ -79,7 +79,8 @@ Every error goes to stderr, its first line `Error: <sentence>` and the lines und
79
79
  - **A value at a file input that is no file**: `Error: the inputs hold a value at a file input that cannot be read as a file.`, then `Reason: <the SDK's message>` and the forms a file input takes. An unreadable local path reads `Error: Local file cannot be read: "<path>" (<reason>).`
80
80
  - **An unreachable API**: `Error: could not reach the Pipelex API at <base URL> (<code>).`
81
81
  - **A failed upload** of a file the inputs name: `Error: the upload of "<file>" failed (status <n>).`, the status left out when no answer came back, then `Reason: <the SDK's message>`, which says what the status means for an upload (a file past the size limit, a deployment without file upload, a credential refused), and `Next step:` and `Request id:` when the API's answer carries them. It covers the SDK's `RejectedAssetError`, `UploadAuthenticationError`, `UnsupportedUploadCapabilityError` and `UploadTransportError`, each of which names the file it was sending. It exits `1`, and no run starts.
82
- - **A wait that fails once the run exists**, on an unreachable API, a refused poll or an answer the command cannot read: the failure's own lines, then `Run <id> may still be going on the server, so do not start it again.`, since the run was started and nothing says it ended. A run that ended in failure (`RunFailedError`) and a run that ended without its main output (`MissingMainStuffError`) get no such line. It exits `1`.
82
+ - **A wait that fails once the run exists**, on an unreachable API, a refused poll or an answer the command cannot read: the failure's own lines, then `Run <id> may still be going on the server, so do not start it again.`, since the run was started and nothing says it ended. A run that ended in failure (`RunFailedError`), a run that ended without its main output (`MissingMainStuffError`) and a run that completed with a stored text the command could not load (`StoredTextLoadError`) get no such line. It exits `1`.
83
+ - **A completed run whose stored text could not be loaded** (`StoredTextLoadError`): `Error: the run completed, but the stored text at <path> in its output could not be loaded (<reason>).`, the path being where the text sits in the main output (`$`, `$.items[2]`) and the reason the error's, then `Reason: <the problem's sentence>` and `Next step:` when the problem advises one. The run is over, so nothing says it may still be going. When the error carries the run's answer as `wireResults`, which only a bare runner's blocking run does since nothing else keeps a copy of it, the command first prints that output on stdout as it prints a result, each stored text still its reference `{url, size, mime_type, preview}`, and adds `The output above is the run's answer, each stored text still its reference.` It exits `1`.
83
84
  - **A start whose outcome is unknown**: once the command has reached a request that may create a run, the start or a bare runner's blocking execute, and before the API names the run, a failure the SDK reads as one that may have started a run, its error's problem having the `retry` `outcome_unknown` ([`errors.md`](errors.md#a-run-that-may-have-started--outcome_unknown)), adds `A run may have started on the server without the command learning of it, so check before starting it again.` under its own lines. That is a problem document from the platform whose own `retry` says so, an answer the command cannot read, and, from the hosted edge, a `408`, which a proxy in front of the platform may answer for a request it forwarded, any `5xx` but a `501`, a request the gateway cut off, and a transport failure that does not prove the request never left, such as an answer lost to a time limit or to a connection that closed once the request had left. Timing plays no part: a `503` or `504` that came back at once reads the same as one at the gateway's limit, since the gateway can answer one after the runner has started the run. Any other answer from the API, and a transport failure that proves the request never left, add nothing, since no run was created. Such a failure names a step of the connection's set-up, which no request follows: an unknown host (`ENOTFOUND`, `EAI_AGAIN`), a refused connection (`ECONNREFUSED`, from every address the host has included), no route to the host or to the network (`EHOSTUNREACH`, `ENETUNREACH`, from the `connect` call), the connection given up by the system's or undici's own connect time limit (`ETIMEDOUT` from `connect`, `UND_ERR_CONNECT_TIMEOUT`), a server certificate the TLS handshake refused (`CERT_HAS_EXPIRED`, `DEPTH_ZERO_SELF_SIGNED_CERT`, `ERR_TLS_CERT_ALTNAME_INVALID` and the other verdicts of the certificate's check Node names, then `UNSPECIFIED`, its code for every verdict it does not name, such as an unhandled critical extension). Both commands read the same failures the same way, each through its SDK's member, so where one command cannot tell whether the request had left, both take the reading that a run may exist: a connection dropped during the TLS handshake, which Node reports as the reset (`ECONNRESET`) of a connection dropped once the request had left, and another TLS failure. A host that drops packets is a connection that never comes, and each command meets its transport's connect time limit first, which proves nothing was sent: here undici's own, ten seconds for the TCP connect and the TLS handshake together (`UND_ERR_CONNECT_TIMEOUT`), which runs out before the SDK's own time limit (`ABORT_TIMEOUT`), at least 30 seconds on every request the command sends; in the Python command, httpx's connect timeout, which the one time limit the Python client passes bounds. Fetch cannot say whether the SDK's own time limit ran out before the connection was made or once the request had left, so the command reads it as an answer lost to a time limit; with Node's own dispatcher it is one, since undici gives up a connection that does not come sooner. It exits `1`.
84
85
 
85
86
  The checks that need no request come first, so a mistake costs nothing. `run` checks, in this order, its flags, `--pipe`'s form, the method (reading a path from disk), the inputs, the poll interval, the key and the base URL. `script` checks its flags, `--pipe`'s form, a control character in any value, the method's form, `--name`, `--dir`, the target file when its name is already known, the key and the base URL. The flags are read in command-line order and the first problem is the one reported: `--help` or `-h` anywhere before the `--` that ends the options asks for the help whatever else is there, and an argument that is exactly one of the two is never taken as a flag's value, so `run --method --help` prints the help, and so does `run --pipe -- --help`, where the `--` is `--pipe`'s value and ends nothing; an unknown option or a positional argument is refused; a flag given twice is refused rather than the last one winning; a string flag needs a non-empty value, given as the next argument or after `=`, and a next argument starting with `-` is not taken as one, except `-` alone, which `--inputs` reads as stdin. Before a subcommand, `--help` prints the command's help whatever follows it, as a subcommand's does, while `--version` must stand alone: `pipelex-sdk --version run …` is a usage error, since printing the version would leave the rest of the command line unanswered.
package/docs/errors.md CHANGED
@@ -126,7 +126,8 @@ 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 `invalid_storage_uri`, `forbidden` and `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. |
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` 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. |
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; `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. |
130
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. |
131
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`. |
132
133
 
package/docs/files.md CHANGED
@@ -134,7 +134,7 @@ console.log(renamed.name); // "March invoice.pdf"
134
134
  `linkFiles` asks for fresh links to read files, each named by exactly one of its record's id, `{ file_id }`, and its address, `{ uri }`, at most 100 in one request. The answer holds exactly one `FileLink` per requested file, in the request's order. **Branch on each item's `error`, never on the status**: the request is a `200` whenever every file got a verdict.
135
135
 
136
136
  - A linked file carries `url`, a presigned `GET` valid for fifteen minutes, its `expires_at`, the `name` a download saves under and its `media_type`, with `error` `null`.
137
- - A file that got no link carries `error`, a `FileLinkError` `{ code, detail }`, and `null` `url`, `expires_at`, `name` and `media_type`: `not_found` for an unknown file id, `conflict` for a file whose upload has not finished, `invalid_storage_uri` for a malformed address and `forbidden` for another organization's. `code` is typed as a string, so a code a later platform adds still reads.
137
+ - A file that got no link carries `error`, a `FileLinkError` `{ code, detail }`, and `null` `url`, `expires_at`, `name` and `media_type`: the platform's registry codes, `request.invalid` naming `file_id` or `uri` for an unknown file or one whose upload has not finished, `pipelex.storage.uri_invalid` for a malformed address and `pipelex.org.mismatch` for another organization's. `code` is typed as a string, so a code a later platform adds still reads.
138
138
 
139
139
  ```ts
140
140
  const { items } = await client.linkFiles([{ file_id: "fl_0199" }, { uri: input.uri }]);
@@ -228,7 +228,27 @@ switch (state.state) {
228
228
  }
229
229
  ```
230
230
 
231
- `getRunResult` is the single-shot lookup and returns that discriminated state. `waitForResult(runId)` drives the same lookup in a loop, honouring the server's `Retry-After`, and returns the `RunResults` directly — throwing `RunFailedError` on a terminal non-completed status and `RunTimeoutError` when the budget runs out. The `failed` arm and `RunFailedError` carry the same facts: the run's `status`, the `message` naming the reason, `problem`, the platform's `run.failed` document, and the run's own problem, which `run.failed` nests as `run_error`: the arm's `error`, `null` when the run ended without one, and the error's `runError`. [`errors.md`](./errors.md#a-failed-run--runfailederror) describes both.
231
+ `getRunResult` is the single-shot lookup and returns that discriminated state. `waitForResult(runId)` drives the same lookup in a loop, honouring the server's `Retry-After`, and returns the `RunResults` directly — throwing `RunFailedError` on a terminal non-completed status and `RunTimeoutError` when the budget runs out. `timeoutMs` is one deadline for the whole wait: it bounds each status read, each progress read and each sleep, and the load of the completed result's stored texts ([below](#stored-texts--loaded-by-default)). The `failed` arm and `RunFailedError` carry the same facts: the run's `status`, the `message` naming the reason, `problem`, the platform's `run.failed` document, and the run's own problem, which `run.failed` nests as `run_error`: the arm's `error`, `null` when the run ended without one, and the error's `runError`. [`errors.md`](./errors.md#a-failed-run--runfailederror) describes both.
232
+
233
+ ## Stored texts — loaded by default
234
+
235
+ The runtime keeps a large text out of a run's results. A `native.Text`, `native.Markdown`, `native.Html` or `native.JSON` value past its inline threshold, or a value of a concept that refines one of them or is description-only, is stored under the run's scope and travels as its reference, in place of its value field:
236
+
237
+ ```json
238
+ { "url": "pipelex-storage://org/…/generated/3f9c…/value.md", "size": 182344, "mime_type": "text/markdown", "preview": "# Quarterly review…" }
239
+ ```
240
+
241
+ An inline value arrives as `{ "text": "…" }`, `{ "inner_html": "…" }` (its `css_class` beside it) or `{ "json_obj": { … } }`. **The result readers load every stored text of `main_stuff` before they return**, so it reaches the generated parser in the shape the method's concepts describe, the value field required: `getRunResult`, `waitForResult` and `startAndWaitForResult` resolve the references through the platform's bulk route, at most `BULK_RESOLVE_MAX_URIS` per request, fetch each signed link under the bounds `fetchArtifact` applies (100 MiB per text by default), and decode the bytes as UTF-8, a JSON value being the object they serialize. A text that cannot be loaded throws `StoredTextLoadError`, naming its `uri`, its `path` in `main_stuff` and a `reason` (`not_found`, `pipelex.org.mismatch`, `resolve_failed`, `unsupported_url`, `too_large`, `not_utf8`, `not_json_object`, …).
242
+
243
+ **Only the platform's references and `data:` URLs are loaded.** A `pipelex-storage://` reference is fetched through the link the platform signs for it, and a `data:` URL is decoded where it is. A stored text under any other URL, which a method's own code can put there, is refused as `unsupported_url` before anything is sent, so a method never has the SDK read a host the caller did not choose; `loadStoredTexts: false` hands it back as written.
244
+
245
+ **`waitForResult`'s `timeoutMs` bounds the load.** The wait reads the run's status without loading, then loads the completed result under the time it has left. A deadline that passes during the load throws `RunTimeoutError` saying the run completed and its stored texts did not load in time; `getRunResult` reads it again, and with `loadStoredTexts: false` it answers at once.
246
+
247
+ **The blocking fallback never loses a completed result.** `startAndWaitForResult` on a bare runner, or falling back to one, holds the run's only copy in the `POST /v1/execute` answer, and a bare runner serves no bulk resolve route. A load that fails there throws `StoredTextLoadError` with that result, every stored text still its reference, on its `wireResults`; on every other path `wireResults` is `undefined`, since the run can be read again.
248
+
249
+ **`loadStoredTexts: false` hands the wire shape back**, the references untouched, on all three readers. The generated `<Name>Wire` types describe that shape, the value field optional beside the reference's fields. `loadStoredTexts(client, results, options)`, exported, loads such a result later, and returns a new one, never changing the one it is given.
250
+
251
+ **Which values are stored texts is decided by concept, never by URL or MIME type**, as the standard rules: a `Document` may be `text/plain` too. The concept at each path comes from the run's own artifacts: the main stuff's concept from `working_memory`, and its structure from the `output_form` node naming that concept (`mainStuffNode(results)` gives that node). A read whose `artifacts` selection left out `working_memory`, `output_form` or `input_form` reads those three again by the run's id only when `main_stuff` holds a value shaped like a stored text's reference, a `url` with no value field beside a `size` or a `preview`, which the runtime sets on every reference it stores; the result returned holds only what was asked for. An image or a document carries neither, so a narrowed read of an output made of them stays one request. A result that carries no working memory is returned as it is.
232
252
 
233
253
  ## `working_memory` — every named stuff of the run
234
254
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipelex/sdk",
3
- "version": "0.67.0",
3
+ "version": "0.69.0",
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": {