@pipelex/sdk 0.46.0 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -42,6 +42,7 @@ See [`docs/cli.md`](./docs/cli.md) for every flag, the output, the exit codes an
42
42
  import { PipelexApiClient } from "@pipelex/sdk";
43
43
 
44
44
  // Base URL + key from PIPELEX_BASE_URL / PIPELEX_API_KEY, or pass them explicitly.
45
+ // `requestTimeoutMs` sets the client's request ceiling, twenty minutes by default.
45
46
  const client = new PipelexApiClient({
46
47
  baseUrl: "https://api.pipelex.com",
47
48
  apiKey: process.env.PIPELEX_API_KEY,
@@ -113,6 +114,7 @@ A reference the runner cannot read at all (blank, a sigil alone, too long) or an
113
114
  The hosted management surface (catalog, account, billing) hangs off the same client. Every route maps a non-2xx `problem+json` to a typed `ApiResponseError` (see [Errors](#errors) for how to branch on it):
114
115
 
115
116
  ```ts
117
+ import { listMethodTree } from "mthds";
116
118
  import { PipelexApiClient, ApiResponseError, parseMethodSelector } from "@pipelex/sdk";
117
119
 
118
120
  const client = new PipelexApiClient({ apiKey: process.env.PIPELEX_API_KEY });
@@ -124,13 +126,16 @@ const drafts = await client.listMethods({ published: false });
124
126
  for await (const method of client.iterateMethods()) {
125
127
  // follows the cursor for callers that genuinely want the whole catalog
126
128
  }
127
- const created = await client.createMethod({ name: "Greeter", mthds: "domain = 'demo'" });
129
+ // A saved method is a method tree: list one from a directory, under the deployment's limits,
130
+ // and the save sends it inline when small, or by hash after uploading the files it lacks.
131
+ const tree = await listMethodTree("methods/greeter", { limits: await client.methodTreeLimits() });
132
+ const created = await client.createMethod({ name: "Greeter", tree });
128
133
 
129
134
  // A saved method has a draft, written freely and never validated, and immutable published
130
- // versions. `updated_at` is the draft's token: echo it so no write or publish takes a draft
131
- // you have not seen.
135
+ // versions. A draft write replaces the whole tree. `updated_at` is the draft's token: echo it so
136
+ // no write or publish takes a draft you have not seen.
132
137
  const draft = await client.writeDraft(created.method_id, {
133
- mthds: "domain = 'demo'\n",
138
+ contents: { "main.mthds": "domain = 'demo'\n" },
134
139
  expected_updated_at: created.updated_at,
135
140
  });
136
141
  const published = await client.publishMethod(created.method_id, {
@@ -140,6 +145,9 @@ if (published.outcome === "refused") console.error(published.message, published.
140
145
  else console.log(`version ${published.version.version}`); // "published" or "unchanged"
141
146
  const versions = await client.listMethodVersions(created.method_id); // newest first
142
147
  const { method_id, version } = parseMethodSelector("mt_abc123@3"); // the method routes take a bare id
148
+ // A read lists the tree's files with short-lived links; write them to disk, checked (Node only).
149
+ const detail = await client.getMethod(created.method_id);
150
+ await client.writeMethodTree(detail.files, { destination: "greeter-draft" });
143
151
 
144
152
  // A saved example is a named set of inputs with the latest run of exactly those inputs. Record a
145
153
  // run against the revision whose inputs it used: an edit since answers `stale`, never an error.
@@ -244,6 +252,7 @@ These pages ship inside the published package, so a reader who has only installe
244
252
  | [`docs/artifact-download.md`](./docs/artifact-download.md) | Turning the `pipelex-storage://` references a run produced back into bytes: `locateArtifacts`, `collectArtifacts`, `resolveArtifacts`, `fetchArtifact`, `downloadArtifacts`, and how a saved file is named after the field it fills |
245
253
  | [`docs/input-preparation.md`](./docs/input-preparation.md) | The other direction — `uploadFile` and `prepareInputs`, which turn local files into references a run can take, and the upload grant a browser page sends a file with |
246
254
  | [`docs/bundle-resources.md`](./docs/bundle-resources.md) | Sending the files a bundle's steps read, such as a `PipeDocGen` step's template, as `resources` beside its `.mthds` contents: where they go, what is refused and by whom, and the template check's warnings |
255
+ | [`docs/method-trees.md`](./docs/method-trees.md) | A saved method's tree: the three forms a save takes it in, how it travels inline or by hash and what is uploaded, the deployment's limits, the read's listing with its links, `writeMethodTree`, and `MethodFileTransferError` |
247
256
  | [`docs/method-examples.md`](./docs/method-examples.md) | A method's saved examples: the create, the paged list and its iterator, the edit that raises the input revision, the latest-run write and its `recorded` or `stale` verdict, how an integer past `Number.MAX_SAFE_INTEGER` in the inputs stays exact, and what is refused before sending |
248
257
  | [`docs/exact-integers.md`](./docs/exact-integers.md) | Which reads keep an integer past `Number.MAX_SAFE_INTEGER` exact, as a `bigint` (a run's inputs and outputs, an example's inputs), how a request body writes it back with its digits, and `parseExactJson` and `stringifyExactJson` for code showing such data as JSON text |
249
258
  | [`docs/crate-routes.md`](./docs/crate-routes.md) | `resolve`, `codegen` and `pipeIo` — the normalized crate, the stamped types, and a method's I/O artifacts without a validation — and the offline `runCodegenCheck` that guards a committed tree |
@@ -15,7 +15,7 @@ import type { CommandIO } from "./io.js";
15
15
  * update notice and npm 12's run notices off the script's stderr, which carries the command's
16
16
  * own lines, while npm's warnings and errors still print.
17
17
  */
18
- export declare const SCRIPT_RUNNER = "npx --yes --no-update-notifier --loglevel=warn @pipelex/sdk@0.46.0";
18
+ export declare const SCRIPT_RUNNER = "npx --yes --no-update-notifier --loglevel=warn @pipelex/sdk@0.47.0";
19
19
  export declare const SCRIPT_WRITER = "@pipelex/sdk";
20
20
  export declare const SCRIPT_NEEDS = "Node 22.12 or later";
21
21
  /** Run `pipelex-sdk script` and return its exit code. */
package/dist/client.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import type { MTHDSProtocol, ModelCategory, ModelDeck, RunOptions, StartOptions, VersionInfo } from "mthds/protocol";
2
- import type { CodegenRequest, CodegenResponse, DictPipeOutput, FormatResponse, LintResponse, ModelCheckCategory, ModelReferenceVerdict, MthdsFileItem, PipeIORequest, PipeIOResponse, PipelexRunResultStart, PipelexValidationResult, ResolveRequest, ResolveResponse, ValidateMethodSelector } from "./models.js";
2
+ import type { CodegenRequest, CodegenResponse, DictPipeOutput, FormatResponse, LintResponse, ModelCheckCategory, ModelReferenceVerdict, PipeIORequest, PipeIOResponse, PipelexRunResultStart, PipelexValidationResult, ResolveRequest, ResolveResponse, ValidateMethodSelector } from "./models.js";
3
3
  import { type GetRunResultOptions, type RunProgress, type RunRead, type RunResults, type RunResultState, type StartAndWaitForResultOptions, type WaitForResultOptions } from "./runs.js";
4
- import type { BillingPortalResponse, ChangePlanResponse, CheckoutResponse, InvoiceView, Membership, MembershipsResponse, ListMethodExamplesQuery, ListMethodsQuery, ListMethodVersionsQuery, MethodData, MethodDeletionAccepted, MethodDraftInput, MethodExample, MethodExampleCreateInput, MethodExampleLatestRunInput, MethodExampleLatestRunResult, MethodExamplePage, MethodExampleUpdateInput, MethodPage, MethodPublishInput, MethodPublishResult, MethodRenameInput, MethodSummary, MethodVersion, MethodVersionPage, MethodWriteInput, OnboardingSubmission, PipelexApiKeyCreated, PipelexApiKeyList, ListRunsQuery, RunHistoryItem, RunDetail, RunPage, PlanView, ResolvedStorageUrl, SubscriptionResponse, UpdateRunInput, UploadGrant, UploadGrantInput, UploadInput, UploadedFile, UserProfile } from "./product-models.js";
4
+ import type { BillingPortalResponse, ChangePlanResponse, CheckoutResponse, InvoiceView, Membership, MembershipsResponse, ListMethodExamplesQuery, ListMethodsQuery, ListMethodVersionsQuery, MethodData, MethodDeletionAccepted, MethodDetail, MethodDraftInput, MethodExample, MethodExampleCreateInput, MethodExampleLatestRunInput, MethodExampleLatestRunResult, MethodExamplePage, MethodExampleUpdateInput, MethodPage, MethodPublishInput, MethodPublishResult, MethodRenameInput, MethodSummary, MethodVersion, MethodVersionPage, MethodWriteInput, OnboardingSubmission, PipelexApiKeyCreated, PipelexApiKeyList, ListRunsQuery, RunHistoryItem, RunDetail, RunPage, PlanView, ResolvedStorageUrl, SavedMethodFile, SubscriptionResponse, UpdateRunInput, UploadGrant, UploadGrantInput, UploadInput, UploadedFile, UserProfile } from "./product-models.js";
5
+ import type { MethodTreeLimits } from "./method-trees.js";
5
6
  import type { AppInfo } from "./user-agent.js";
6
7
  import type { UploadableAsset, UploadFileOptions, UploadRecord } from "./upload.js";
7
8
  import type { BundleResources } from "./bundle-resources.js";
@@ -203,6 +204,15 @@ export interface PipelexApiClientOptions {
203
204
  * beside the specs' tests.
204
205
  */
205
206
  appInfo?: AppInfo;
207
+ /**
208
+ * The client's request ceiling, in milliseconds: the time limit of a request given no
209
+ * `timeoutMs` of its own, the blocking `execute`, a `start` carrying its method and a save
210
+ * carrying a method's tree (`createMethod`, `writeDraft`) among them, and of each transfer of a method's file to or from storage, an upload before a save or a
211
+ * download by `writeMethodTree`. Defaults to 20 minutes, the runner's blocking execute ceiling.
212
+ * A positive number no larger than 2147483647, the longest delay a timer honours, else a
213
+ * `RangeError` at construction.
214
+ */
215
+ requestTimeoutMs?: number;
206
216
  }
207
217
  /** Hosted default — the client composes every endpoint as `{base}/v1/{endpoint}`. */
208
218
  export declare const DEFAULT_API_BASE_URL = "https://api.pipelex.com";
@@ -219,6 +229,14 @@ export declare class PipelexApiClient implements HostedProtocolSurface {
219
229
  private readonly originUrl;
220
230
  /** Cached `/v1/version` handshake outcome — whether the durable lifecycle is served. */
221
231
  private lifecycleAvailable;
232
+ /**
233
+ * The first `/v1/version` handshake that answered, kept for the client's lifetime: what a save
234
+ * reads from it (`blob_store`) and the tree limits it announces do not change while a client
235
+ * lives. A handshake that failed is not kept, so the next call asks again.
236
+ */
237
+ private versionInfo;
238
+ /** The client's request ceiling (`PipelexApiClientOptions.requestTimeoutMs`). */
239
+ private readonly requestTimeoutMs;
222
240
  /**
223
241
  * The `User-Agent` sent on every API request, computed once at construction;
224
242
  * `undefined` in a browser, where no header may be set.
@@ -262,19 +280,18 @@ export declare class PipelexApiClient implements HostedProtocolSurface {
262
280
  */
263
281
  private requestProductObject;
264
282
  /**
265
- * A methods-catalog route answering one stored method (`getMethod`, `createMethod`,
266
- * `writeDraft`, `renameMethod`), parsed into the public shape by `readStoredSources`.
283
+ * A methods-catalog route answering one stored method (`createMethod`, `writeDraft`,
284
+ * `renameMethod`), read as `readObjectAnswer` reads it.
267
285
  */
268
286
  private requestMethodData;
269
287
  /**
270
- * The stored sources of a method or of a published version, read from the answer `res`
271
- * carried, into the public shape. A stored `mthds` that is neither a string nor absent (`null`
272
- * stays "no source", which `getMethodClosure` reports), and a stored `python` the SDK cannot
273
- * parse, are an answer it cannot read, so each throws an `ApiResponseError` built from that
274
- * answer, the latter with `mthds`'s refusal as `cause`: `runtime`, not retryable, since no
275
- * change to the call fixes it. `subject` names what carried them in the message.
288
+ * A route answering a saved tree's listing beside what names it (`getMethod`,
289
+ * `getMethodVersion`), read as `readObjectAnswer` reads it, then its `files` checked: a listing
290
+ * that is not an array of `{ path, sha256, size, url, expires_at }`, each a string but `size`, a
291
+ * non-negative integer, is an answer the SDK cannot read, since `writeMethodTree` would write
292
+ * from it. Throws the `ApiResponseError` `unreadableAnswer` builds, `subject` naming the answer.
276
293
  */
277
- private readStoredSources;
294
+ private readSavedTree;
278
295
  /**
279
296
  * A verdict, the `200` a route answers discriminated on `outcome` with the object the verdict
280
297
  * is about as one `member`: `publishMethod`'s `method`, `recordMethodExampleLatestRun`'s
@@ -315,7 +332,10 @@ export declare class PipelexApiClient implements HostedProtocolSurface {
315
332
  * member included.
316
333
  */
317
334
  private readMethodExample;
318
- /** Issue a product request and return its 2xx answer, a non-2xx thrown as `ApiResponseError`. */
335
+ /**
336
+ * Issue a product request and return its 2xx answer, a non-2xx thrown as `ApiResponseError`.
337
+ * The request takes the poll timeout unless `options.timeoutMs` gives another.
338
+ */
319
339
  private requestProductAnswer;
320
340
  private throwApiResponseError;
321
341
  /** The JSON body of a `/v1` route's 2xx answer; see `readAnswerAt`. */
@@ -349,7 +369,8 @@ export declare class PipelexApiClient implements HostedProtocolSurface {
349
369
  * `API <method> <path> answered <status> with <what>`: the answer's status, its raw text as
350
370
  * `responseBody`, no hosted problem member but the `X-Request-ID` header, the failure that made it
351
371
  * unreadable as `cause`, and the verdict the fallback gives a 2xx, `runtime` and not retryable.
352
- * On a request that may create a run, the run may have started: the server accepted it.
372
+ * An answer that carries signed links (`RawResponse.carriesLinks`) is held with every link
373
+ * hidden, and with no `cause`, which could quote one. On a request that may create a run, the run may have started: the server accepted it.
353
374
  */
354
375
  private unreadableAnswer;
355
376
  /**
@@ -864,10 +885,13 @@ export declare class PipelexApiClient implements HostedProtocolSurface {
864
885
  */
865
886
  iterateMethods(query?: Omit<ListMethodsQuery, "cursor">): AsyncGenerator<MethodSummary, void, undefined>;
866
887
  /**
867
- * Read one method — `GET /v1/methods/{id}`: its identity, its draft (`mthds`, `python`,
868
- * `input_data`) with the draft's token (`updated_at`) and digest (`draft_digest`), and its
869
- * latest published version's summary (`latest_version`, `latest_published`), whatever the
870
- * publish state. A method never published reads with both `null`, never as an error.
888
+ * Read one method with its draft's files — `GET /v1/methods/{id}`: its identity, its draft
889
+ * (`files`, `input_data`) with the draft's token (`updated_at`) and digest (`draft_digest`),
890
+ * and its latest published version's summary (`latest_version`, `latest_published`), whatever
891
+ * the publish state. A method never published reads with both `null`, never as an error.
892
+ * `files` lists the draft's tree in tree path order, each file with its SHA-256, its size and a
893
+ * link to its bytes valid for about fifteen minutes, and is empty for an empty draft;
894
+ * `writeMethodTree` brings the tree to disk.
871
895
  *
872
896
  * Takes a bare catalog id: the method routes address the method itself, never a version of
873
897
  * it. A caller holding `mt_…@3` strips the suffix with `parseMethodSelector` and reads that
@@ -875,64 +899,145 @@ export declare class PipelexApiClient implements HostedProtocolSurface {
875
899
  * suffixed id, before any request, rather than read back the `404` the platform would answer,
876
900
  * and for an id that is empty, `.` or `..`, which the URL would resolve into another route's
877
901
  * path.
902
+ *
903
+ * Throws `ApiResponseError`: `404` `not_found` for an unknown or foreign-org method, `409`
904
+ * `method_being_deleted` while its erasure runs, and a `409` whose verdict is `runtime` for a
905
+ * method whose draft names a tree the platform holds no record of. An answer whose `files` is
906
+ * not a listing is an answer the SDK cannot read, thrown as an `ApiResponseError` too.
878
907
  */
879
- getMethod(methodId: string): Promise<MethodData>;
908
+ getMethod(methodId: string): Promise<MethodDetail>;
880
909
  /**
881
- * Resolve a stored method's id into the runnable MTHDS closure of its DRAFT — a
882
- * client-side semantic layer over `getMethod` (the platform has no route that
883
- * returns a parsed closure). Fetches the method, parses its draft's polymorphic
884
- * `mthds` source with `methodSourceToContents`, and labels each resulting file
885
- * with the `method_id` as its `source` provenance.
910
+ * Create a method — `POST /v1/methods`. The new method holds its tree as its draft and has no
911
+ * published version, so its bare id answers `409 method_not_published` on the run and tooling
912
+ * routes until its first `publishMethod`; its draft runs as `mt_…@draft` at once.
886
913
  *
887
- * **This is the draft, not what a bare id runs.** A run, a validation or a pipe I/O
888
- * read by a bare `method_id` resolves to the latest PUBLISHED version, which the
889
- * draft may be ahead of. For the closure of a version, read it with
890
- * `getMethodVersion` and parse its `mthds` with `methodSourceToContents`.
914
+ * The tree is `files`, sent as given, or `tree` or `contents`, which the client sends inline
915
+ * when its inline map weighs 256 KiB or less, or when the platform keeps no blob store, and
916
+ * otherwise every file by hash, after asking `POST /v1/blobs/missing` which files the
917
+ * organization lacks and uploading those: a file uploaded once is never uploaded again. With
918
+ * none of the three, the draft is empty (see `docs/method-trees.md`).
891
919
  *
892
- * This is the LOCAL expansion utility — for callers that want the files in
893
- * hand (to edit, to diff, or to send to a bare runner, which has no catalog to
894
- * resolve an id against). The operations that accept `method_id`
895
- * natively (`execute`/`start`, `validate`/`resolve`/`codegen`/`pipeIo`, and
896
- * `prepareInputs`, which composes a `pipeIo` of its own) take the id as a
897
- * pass-through instead; nothing in this client expands an id behind your back.
898
- *
899
- * Takes a bare catalog id, as `getMethod` does. Requires an API key: the methods
900
- * catalog is org-scoped to the key's org, so an unknown OR foreign-org id is a
901
- * `getMethod` `404` (`ApiResponseError` `not_found`), which propagates unchanged. A
902
- * real, in-org method whose draft parses to nothing throws `EmptyMethodSourceError`
903
- * (distinct from the 404) — the row exists but has no runnable source yet.
920
+ * Throws `RequestArgumentError` for two forms of the tree, or `contents` holding no file, before
921
+ * any request; `MethodFileTransferError` when a file the organization lacks could not be
922
+ * uploaded, and nothing is saved. Throws `ApiResponseError`: `422` `invalid_method_files` for a
923
+ * map the standard refuses, with its `tree_refusal`; `422` `method_tree_too_large` for a tree
924
+ * past one of the deployment's limits, named in its `limit`; `422` `blob_mismatch` for a hash
925
+ * stated at another size than the one held; `422` `missing_blobs` for a hash entry whose bytes
926
+ * the organization does not hold; `413` `payload_too_large` for a method that would leave no
927
+ * room for a publish.
904
928
  */
905
- getMethodClosure(methodId: string): Promise<MthdsFileItem[]>;
929
+ createMethod(input: MethodWriteInput): Promise<MethodData>;
906
930
  /**
907
- * Create a method — `POST /v1/methods`. The new method holds the input as its draft and has
908
- * no published version, so its bare id answers `409 method_not_published` on the run and
909
- * tooling routes until its first `publishMethod`; its draft runs as `mt_…@draft` at once.
910
- *
911
- * Throws `ApiResponseError`: `413` `payload_too_large` for a method that would leave no room
912
- * for a publish, measured as a draft write is, and `422` `validation_failed` for Python files
913
- * no run could import or for text holding a lone surrogate.
931
+ * The time limit of a save carrying `files`: the client's request ceiling, as for a `start`
932
+ * carrying its method, since a tree sent inline to a deployment with no blob store has no size
933
+ * bound and its whole upload is charged against the limit; the poll timeout for a save sending
934
+ * no tree.
914
935
  */
915
- createMethod(input: MethodWriteInput): Promise<MethodData>;
936
+ private saveTimeout;
916
937
  /**
917
938
  * Replace a method's draft — `PUT /v1/methods/{id}/draft` — and return the method with the
918
939
  * draft's new token (`updated_at`) and digest (`draft_digest`).
919
940
  *
920
941
  * The draft is never validated on write, and writing it changes nothing for the callers of
921
942
  * the method's bare id, who run the latest published version until the next `publishMethod`.
922
- * `python` and `input_data` are three-way (see `MethodDraftInput`). With
943
+ * The write replaces the draft's whole tree, given in exactly one form: `files`, sent as given,
944
+ * `files: null` emptying the draft, or `tree` or `contents`, sent inline or by hash as
945
+ * `createMethod` sends them. `input_data` is three-way (see `MethodDraftInput`). With
923
946
  * `expected_updated_at`, the write is a compare-and-swap on the draft token: a draft that
924
947
  * moved since is refused with a `409` whose `code` is `method_update_conflict`, and nothing is
925
948
  * written. Without it, last writer wins.
926
949
  *
927
- * Takes a bare catalog id, as `getMethod` does. Throws `ApiResponseError`: `404` `not_found`
928
- * for an unknown or foreign-org method, `409` `method_being_deleted` while its erasure runs,
929
- * `413` `payload_too_large` for a draft that would grow the method past the room a publish
930
- * needs, which keeps a draft that saves publishable, `422` `validation_failed` for Python
931
- * files no run could import or for text holding a lone surrogate, `403` for a read-only key,
932
- * and a `503` that wrote nothing, safe to retry, when the method kept changing under the
933
- * write.
950
+ * Takes a bare catalog id, as `getMethod` does. Throws `RequestArgumentError` for a draft that
951
+ * gives its tree in no form or in two, or `contents` holding no file, before any request;
952
+ * `MethodFileTransferError` when a file the organization lacks could not be uploaded. Throws
953
+ * `ApiResponseError`: `404` `not_found` for an unknown or foreign-org method, `409`
954
+ * `method_being_deleted` while its erasure runs, the `422` refusals of a tree `createMethod`
955
+ * lists, `413` `payload_too_large` for a draft that would grow the method past the room a
956
+ * publish needs, `403` for a read-only key, and a `503` that wrote nothing, safe to retry,
957
+ * when the method kept changing under the write.
934
958
  */
935
959
  writeDraft(methodId: string, input: MethodDraftInput): Promise<MethodData>;
960
+ /**
961
+ * The limits the deployment holds a method's tree to — `GET /v1/version`, read from
962
+ * `limits.method_tree` of the public handshake — in the shape the `mthds` package's
963
+ * `listMethodTree` takes as its `limits` option, so a tree the platform would refuse is refused
964
+ * while it is listed, before any file is hashed:
965
+ *
966
+ * ```ts
967
+ * import { listMethodTree } from "mthds";
968
+ * const tree = await listMethodTree("methods/receipts", { limits: await client.methodTreeLimits() });
969
+ * await client.createMethod({ name: "Receipts", tree });
970
+ * ```
971
+ *
972
+ * A limit the server does not announce is absent, so a bare runner, which announces none,
973
+ * yields no limit, and none is ever assumed. A value that is not a positive integer is left out
974
+ * rather than trusted.
975
+ */
976
+ methodTreeLimits(): Promise<MethodTreeLimits>;
977
+ /**
978
+ * The version handshake, asked once per client: the first answer is kept (see `versionInfo`),
979
+ * and a failure is thrown and not kept, so the next call asks again.
980
+ */
981
+ private cachedVersion;
982
+ /**
983
+ * Write a saved method's tree to disk: each file of a listing `getMethod` or `getMethodVersion`
984
+ * served, at its tree path under `options.destination`. **Node only.**
985
+ *
986
+ * Each file is downloaded through its link, at most eight at a time, with no credential of this
987
+ * client, and checked against the listing: its size and its SHA-256 must be the ones listed, so
988
+ * what lands on disk is the tree the method's digest names. The files are written into a fresh
989
+ * hidden directory beside the destination, which takes its name only once every file is
990
+ * written: an interrupted or failed write never leaves a partial tree under that name. The
991
+ * destination must not exist, or be an empty directory; one holding anything is refused rather
992
+ * than written into or replaced. An empty listing writes an empty directory.
993
+ *
994
+ * The links expire about fifteen minutes after the read that served them: write the tree soon
995
+ * after reading the method, and read it again for fresh links when a download is refused.
996
+ *
997
+ * Throws `RequestArgumentError` before any download when the destination exists and is not an
998
+ * empty directory, or the listing holds a path that is not a tree path, the same path twice, or
999
+ * paths that collide once case-folded or where one names a directory of another;
1000
+ * `MethodFileTransferError` when a file could not be downloaded, or its bytes are not the file
1001
+ * listed, and nothing is left under the destination.
1002
+ */
1003
+ writeMethodTree(files: readonly SavedMethodFile[], options: {
1004
+ destination: string;
1005
+ }): Promise<void>;
1006
+ /**
1007
+ * The `files` a save sends: `files` as given, or `tree` or `contents` prepared, uploading what
1008
+ * the organization lacks; `undefined` when the input gives none. Two forms are refused with
1009
+ * `RequestArgumentError` before any request, naming `call`.
1010
+ */
1011
+ private methodTreeFiles;
1012
+ /**
1013
+ * The `files` map that sends `tree`: inline, or by hash once the organization holds every file.
1014
+ *
1015
+ * A tree whose inline map weighs `INLINE_TREE_MAX_BYTES` or less travels inline, with no round
1016
+ * trip, measured as the request spends it, its JSON with no whitespace in UTF-8. A larger tree
1017
+ * travels inline too when the version handshake declares no blob store; otherwise
1018
+ * `POST /v1/blobs/missing` is asked which files the organization lacks, naming the tree's
1019
+ * digest, each one it lacks is uploaded once, and every file travels by hash. A file read to be
1020
+ * measured is uploaded from memory rather than read a second time. A tree holding no file is
1021
+ * refused with `RequestArgumentError` before any request, `call` naming the caller's method.
1022
+ */
1023
+ private prepareTreeFiles;
1024
+ /**
1025
+ * Which of these blobs the organization lacks, and where to upload each —
1026
+ * `POST /v1/blobs/missing` — with the answer it was read from, which carries signed links. A
1027
+ * blob held is left out, and an empty `missing` means nothing to upload. An answer whose
1028
+ * `missing` is not a list of blobs, each with its upload target, is an answer the SDK cannot
1029
+ * read, thrown as an `ApiResponseError` holding the answer with its links hidden.
1030
+ */
1031
+ private findMissingBlobs;
1032
+ /**
1033
+ * Upload each missing blob from the tree's bytes, a few at a time, stopping at the first
1034
+ * failure. A blob the platform asks for that the tree does not hold, or holds at another size,
1035
+ * is the platform's fault, thrown before anything is sent as the `ApiResponseError` of an answer
1036
+ * the SDK cannot read. The bytes the tree reads for a blob are checked against it before they
1037
+ * are sent, since storage keeps a blob under the hash it is named by: bytes of another hash or
1038
+ * size are refused with `RequestArgumentError`, and nothing more is uploaded.
1039
+ */
1040
+ private uploadMissing;
936
1041
  /**
937
1042
  * Rename a method — `PATCH /v1/methods/{id}` — and return it. The name belongs to the method,
938
1043
  * not to a version: a rename changes nothing else, moves no token, and never commits the
@@ -979,7 +1084,7 @@ export declare class PipelexApiClient implements HostedProtocolSurface {
979
1084
  */
980
1085
  publishMethod(methodId: string, input: MethodPublishInput): Promise<MethodPublishResult>;
981
1086
  /**
982
- * One page of a method's published versions, newest first, without their sources —
1087
+ * One page of a method's published versions, newest first, without their files —
983
1088
  * `GET /v1/methods/{id}/versions`.
984
1089
  *
985
1090
  * Pass the page's `nextCursor` back as `cursor` to continue; `null` is the last page. A page
@@ -993,14 +1098,16 @@ export declare class PipelexApiClient implements HostedProtocolSurface {
993
1098
  */
994
1099
  listMethodVersions(methodId: string, query?: ListMethodVersionsQuery): Promise<MethodVersionPage>;
995
1100
  /**
996
- * One published version of a method, with its sources —
997
- * `GET /v1/methods/{id}/versions/{n}`. Its `python` is parsed into `MethodFile[]` as a
998
- * method's is.
1101
+ * One published version of a method, with its files — `GET /v1/methods/{id}/versions/{n}`.
1102
+ * `files` lists the version's tree as `getMethod` lists the draft's, each file with a link to
1103
+ * its bytes valid for about fifteen minutes, which `writeMethodTree` writes to disk.
999
1104
  *
1000
1105
  * Takes a bare catalog id, as `getMethod` does, and the version number. Throws
1001
1106
  * `RequestArgumentError` for a `version` that is not a positive integer, before any request.
1002
1107
  * Throws `ApiResponseError`: `404` `method_version_not_found` for a version the method never
1003
- * published, `404` `not_found` for an unknown method, `409` `method_being_deleted`.
1108
+ * published, `404` `not_found` for an unknown method, `409` `method_being_deleted`, and `409`
1109
+ * `conflict`, whose verdict is `runtime`, for a version stored before methods were trees and
1110
+ * never rewritten as one, which names no tree to serve.
1004
1111
  */
1005
1112
  getMethodVersion(methodId: string, version: number): Promise<MethodVersion>;
1006
1113
  /**