@pipelex/sdk 0.47.0 → 0.48.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 +8 -6
- package/dist/cli/script.d.ts +1 -1
- package/dist/cli/source.d.ts +8 -7
- package/dist/cli/source.js +11 -5
- package/dist/cli/source.js.map +1 -1
- package/dist/client.d.ts +321 -210
- package/dist/client.js +819 -514
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +5 -2
- package/dist/errors.js +5 -2
- package/dist/errors.js.map +1 -1
- package/dist/hooks/bundle-gather.d.ts +28 -40
- package/dist/hooks/bundle-gather.js +55 -230
- package/dist/hooks/bundle-gather.js.map +1 -1
- package/dist/hooks/claude-mthds-check.d.ts +7 -5
- package/dist/hooks/claude-mthds-check.js +8 -53
- package/dist/hooks/claude-mthds-check.js.map +1 -1
- package/dist/hooks/validate-stage.d.ts +27 -0
- package/dist/hooks/validate-stage.js +57 -0
- package/dist/hooks/validate-stage.js.map +1 -0
- package/dist/index.d.ts +3 -4
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/method-trees.d.ts +208 -73
- package/dist/method-trees.js +221 -34
- package/dist/method-trees.js.map +1 -1
- package/dist/models.d.ts +162 -59
- package/dist/prepare-inputs.d.ts +46 -27
- package/dist/prepare-inputs.js +123 -42
- package/dist/prepare-inputs.js.map +1 -1
- package/dist/product-models.d.ts +14 -16
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/architecture.md +17 -18
- package/docs/cli.md +1 -1
- package/docs/crate-routes.md +42 -20
- package/docs/errors.md +5 -5
- package/docs/hook-bundle.md +1 -1
- package/docs/input-preparation.md +11 -11
- package/docs/method-trees.md +119 -21
- package/docs/run-results.md +5 -2
- package/package.json +2 -2
- package/dist/bundle-resources.d.ts +0 -62
- package/dist/bundle-resources.js +0 -165
- package/dist/bundle-resources.js.map +0 -1
- package/docs/bundle-resources.md +0 -107
package/dist/models.d.ts
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* the model reference check. Built on the protocol wire types imported from the
|
|
9
9
|
* `mthds/protocol` subpath.
|
|
10
10
|
*/
|
|
11
|
-
import type { InputForm, OutputForm, PipeIOContracts, RunResultExecute, RunResultStart } from "mthds/protocol";
|
|
12
|
-
import type {
|
|
11
|
+
import type { InputForm, MethodFiles, MethodTreeSource, OutputForm, PipeIOContracts, RunResultExecute, RunResultStart } from "mthds/protocol";
|
|
12
|
+
import type { MethodTreeForm, NoMethodTree } from "./method-trees.js";
|
|
13
13
|
export interface DictStuff {
|
|
14
14
|
concept: string;
|
|
15
15
|
content: unknown;
|
|
@@ -75,7 +75,7 @@ export interface PipelexRunResultStart extends RunResultStart {
|
|
|
75
75
|
* The hosted tooling routes' own selector — the layer-3 extension the platform
|
|
76
76
|
* adds on `POST /v1/validate`, `/v1/resolve`, `/v1/codegen`, and `/v1/pipe-io`: a stored
|
|
77
77
|
* method's catalog id (`mt_…`), optionally naming a version, resolved server-side against
|
|
78
|
-
* the org's catalog, the
|
|
78
|
+
* the org's catalog, the tree of the version it names injected as the method's `files`
|
|
79
79
|
* before the runner sees the request. A bare `mt_…` names the latest published version,
|
|
80
80
|
* `mt_…@<n>` version `n` and `mt_…@draft` the draft. A **pass-through to the hosted API**:
|
|
81
81
|
* nothing is expanded client-side, and it is meaningless off-platform (a bare runner
|
|
@@ -97,11 +97,11 @@ export interface PipelexHostedToolingExtensions {
|
|
|
97
97
|
method_id?: string;
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
100
|
-
* The method selector the tooling routes take in place of
|
|
100
|
+
* The method selector the tooling routes take in place of the method's tree: a
|
|
101
101
|
* `method_ref` address (server-resolved by the runner through the same fetch
|
|
102
102
|
* path as a `method_ref` run) OR a hosted `method_id` (platform-resolved) —
|
|
103
103
|
* never both. The tooling routes are stateless, so the strict XOR applies:
|
|
104
|
-
* exactly one of
|
|
104
|
+
* exactly one of the tree / `method_ref` / `method_id` per request.
|
|
105
105
|
*
|
|
106
106
|
* Lives here, beside the other wire shapes, rather than on the client: it is
|
|
107
107
|
* the request's shape, and a module that composes a `validate` call of its own
|
|
@@ -115,6 +115,23 @@ export type ValidateMethodSelector = {
|
|
|
115
115
|
method_id: string;
|
|
116
116
|
method_ref?: never;
|
|
117
117
|
};
|
|
118
|
+
/**
|
|
119
|
+
* What `validate()` judges: the method's tree, in exactly one of the four forms of
|
|
120
|
+
* `MethodTreeForm` (a `directory`, `contents`, a `tree` or the `files` map), or one of the two
|
|
121
|
+
* selectors of `ValidateMethodSelector`. Each arm pins the others to `never`, so naming two is a
|
|
122
|
+
* compile error; an untyped caller naming none, or more than one, is refused with a
|
|
123
|
+
* `RequestArgumentError` before any request, as the route itself would refuse a second selector
|
|
124
|
+
* with a `422`. At run time a `null` member, an empty `directory` and an empty selector string
|
|
125
|
+
* are absent, and a `files` map or `contents` holding no file is refused, as the MTHDS standard
|
|
126
|
+
* refuses a tree holding no file.
|
|
127
|
+
*
|
|
128
|
+
* It widens the protocol's own `ValidateSource` (`{ files }` or `{ tree }`) with the two forms
|
|
129
|
+
* this client lists or encodes itself and the two selectors the Pipelex API resolves.
|
|
130
|
+
*/
|
|
131
|
+
export type PipelexValidateSource = (MethodTreeForm & {
|
|
132
|
+
method_ref?: never;
|
|
133
|
+
method_id?: never;
|
|
134
|
+
}) | (ValidateMethodSelector & NoMethodTree);
|
|
118
135
|
/** Per-pipe dry-run verdict in `validated_pipes[]` — mirror of pipelex's `DryRunStatus`. */
|
|
119
136
|
export type DryRunStatus = "SUCCESS" | "FAILURE" | "SKIPPED";
|
|
120
137
|
/** One entry of `PipelexValidationReport.validated_pipes` — `{pipe_ref, status}`. */
|
|
@@ -139,6 +156,35 @@ export interface LiftablePipeEntry {
|
|
|
139
156
|
/** Where the possible absence originates (human-readable). */
|
|
140
157
|
absence_source: string;
|
|
141
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* What a step reads a file of its method tree as — mirror of pipelex's `TreeFileUse`:
|
|
161
|
+
* `template`, the template a `PipeDocGen` step fills, named by its `template_file`;
|
|
162
|
+
* `template_asset`, an image, a stylesheet or a font that step's HTML template names by a
|
|
163
|
+
* literal relative URL, or that one of its stylesheets names; `python_module`, the module
|
|
164
|
+
* defining the function a `PipeFunc` step calls, named by the import path of its
|
|
165
|
+
* `function_name`.
|
|
166
|
+
*
|
|
167
|
+
* A report reads it open (see {@link TreeFileRead.use}): a runner of a later version may add
|
|
168
|
+
* a use as another kind of step comes to read files of its tree.
|
|
169
|
+
*/
|
|
170
|
+
export type TreeFileUse = "template" | "template_asset" | "python_module";
|
|
171
|
+
/**
|
|
172
|
+
* One file of its method tree a step reads — mirror of pipelex's `TreeFileRead`, an entry of
|
|
173
|
+
* {@link PipelexValidationReport.tree_files_read}.
|
|
174
|
+
*/
|
|
175
|
+
export interface TreeFileRead {
|
|
176
|
+
/**
|
|
177
|
+
* The file's path from the root of the method's tree, with forward slashes, such as
|
|
178
|
+
* `templates/invoice.html`, never a path on the server.
|
|
179
|
+
*/
|
|
180
|
+
tree_path: string;
|
|
181
|
+
/**
|
|
182
|
+
* What the step reads the file as. Read open: `string & {}` keeps the editor's completion
|
|
183
|
+
* on the uses this SDK knows, and a consumer that switches on this field has to say what a
|
|
184
|
+
* use it does not know does.
|
|
185
|
+
*/
|
|
186
|
+
use: TreeFileUse | (string & {});
|
|
187
|
+
}
|
|
142
188
|
/**
|
|
143
189
|
* Pipelex's `POST /v1/validate` 200 body for a VALID bundle — the canonical
|
|
144
190
|
* `PipelexValidationReport`, carrying the `is_valid: true` discriminant of the
|
|
@@ -209,6 +255,27 @@ export interface PipelexValidationReport {
|
|
|
209
255
|
output_form?: OutputForm;
|
|
210
256
|
/** Pipes the runtime may skip when an optional slot resolves absent. */
|
|
211
257
|
liftable_pipes: LiftablePipeEntry[];
|
|
258
|
+
/**
|
|
259
|
+
* Per step, the files of the method's tree it reads, keyed by namespaced `pipe_ref` over
|
|
260
|
+
* the same set as `pipe_io_contracts`, each file by its tree path with what the step reads
|
|
261
|
+
* it as. A `PipeDocGen` step reads its template and the images, stylesheets and fonts its
|
|
262
|
+
* HTML template names by literal relative URLs; a `PipeFunc` step reads the module of its
|
|
263
|
+
* function when that module is a file of the tree. A step that reads no file of the tree,
|
|
264
|
+
* a controller included, has an empty list. The paths come from what each step already
|
|
265
|
+
* names, so a client can show which step uses a file without parsing the method.
|
|
266
|
+
*
|
|
267
|
+
* OPTIONAL because a runner predating the field sends nothing: an absent field says the
|
|
268
|
+
* server did not report the reads, where an empty list says that step reads no file.
|
|
269
|
+
*/
|
|
270
|
+
tree_files_read?: Record<string, TreeFileRead[]>;
|
|
271
|
+
/**
|
|
272
|
+
* The per-file view of `tree_files_read`: each tree path a step reads, in sorted order, to
|
|
273
|
+
* the namespaced refs of the steps that read it, each listed once. A file of the tree with
|
|
274
|
+
* no entry is read by no step: the bundles themselves, a README, a package's `__init__.py`
|
|
275
|
+
* beside its modules. Optional for the same reason as `tree_files_read`, and present
|
|
276
|
+
* whenever it is.
|
|
277
|
+
*/
|
|
278
|
+
tree_file_readers?: Record<string, string[]>;
|
|
212
279
|
/**
|
|
213
280
|
* The qualified ref of the pipe a selector-less run of THIS request would execute —
|
|
214
281
|
* the primary blueprint's declared `main_pipe` qualified by its domain and, for a
|
|
@@ -326,9 +393,8 @@ export type ValidationErrorCategory = "blueprint_validation" | "pipe_factory" |
|
|
|
326
393
|
* not, so the same item arrives with explicit `null`s there. A truthiness check reads
|
|
327
394
|
* both; an `=== undefined` check would be wrong on one of them.
|
|
328
395
|
*
|
|
329
|
-
* `source` is the declaring file path (CLI) or the
|
|
330
|
-
*
|
|
331
|
-
* diagnostics.
|
|
396
|
+
* `source` is the declaring file: its path (CLI), or its tree path in the tree the
|
|
397
|
+
* request sent — the owning file for cross-file diagnostics.
|
|
332
398
|
*
|
|
333
399
|
* An `unknown_model` item (a model reference the runner's model deck does not know)
|
|
334
400
|
* carries the reference as written, the kind of model the field takes and the close
|
|
@@ -514,50 +580,84 @@ export interface FormatResponse {
|
|
|
514
580
|
diagnostics: Diagnostic[];
|
|
515
581
|
}
|
|
516
582
|
/**
|
|
517
|
-
*
|
|
518
|
-
*
|
|
519
|
-
* this file, so an invalid verdict can point at the file that caused it.
|
|
583
|
+
* The method every crate route takes — `/v1/resolve`, `/v1/codegen` and `/v1/pipe-io`
|
|
584
|
+
* (mirror of the runner's `MethodTreeRequest`).
|
|
520
585
|
*
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
*
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
*/
|
|
527
|
-
export interface MthdsFileItem {
|
|
528
|
-
content: string;
|
|
529
|
-
source?: string;
|
|
530
|
-
}
|
|
531
|
-
/**
|
|
532
|
-
* The closure selector every crate route shares — `/v1/resolve`, `/v1/codegen` and
|
|
533
|
-
* `/v1/pipe-io` (mirror of the server's `MthdsFilesRequest`).
|
|
586
|
+
* Supply the method EITHER as its tree OR as a `method_ref` — never both, and never neither
|
|
587
|
+
* (both arms are a request-shape `422`); the hosted `method_id` joins them as a third form on
|
|
588
|
+
* each route's own request (see {@link PipelexHostedToolingExtensions}). The tree is the MTHDS
|
|
589
|
+
* protocol's map of file entries, keyed by tree path, given in exactly one of the four forms
|
|
590
|
+
* every route takes (`MethodTreeForms`):
|
|
534
591
|
*
|
|
535
|
-
*
|
|
536
|
-
*
|
|
537
|
-
*
|
|
538
|
-
*
|
|
539
|
-
*
|
|
540
|
-
*
|
|
541
|
-
*
|
|
542
|
-
* real relative paths as per-file sources. The **registry form** (any non-address
|
|
543
|
-
* reference) stays reserved and answers `501` until a method registry exists.
|
|
592
|
+
* - `directory`, the method's directory on disk, listed by the `mthds` package's lister under
|
|
593
|
+
* the standard's membership rule and the deployment's limits (Node only);
|
|
594
|
+
* - `contents`, each file's bytes or text by tree path;
|
|
595
|
+
* - `tree`, a `MethodTreeSource`, such as the `MethodTree` the `mthds` package's
|
|
596
|
+
* `listMethodTree` returns;
|
|
597
|
+
* - `files`, the map itself, each value the file's text, `{ base64 }` or `{ sha256, size }` for
|
|
598
|
+
* bytes the runner already holds, sent as given.
|
|
544
599
|
*
|
|
545
|
-
* The
|
|
546
|
-
*
|
|
547
|
-
*
|
|
600
|
+
* The client sends a `directory`, `contents` or `tree` inline when its inline map weighs 256 KiB
|
|
601
|
+
* or less and no more than the inline limit the API announces, or whatever its weight when the
|
|
602
|
+
* API keeps no blob store, and otherwise every file by hash, after uploading the files the API
|
|
603
|
+
* lacks, exactly as `createMethod` sends one (see `docs/method-trees.md`). Every `.mthds` file of
|
|
604
|
+
* the tree is one of the method's bundles, named by its tree path in diagnostics and in the
|
|
605
|
+
* crate's `source_map`, and every other file is one a step may read, such as a `PipeDocGen`
|
|
606
|
+
* template.
|
|
548
607
|
*
|
|
549
|
-
* `
|
|
550
|
-
*
|
|
551
|
-
*
|
|
552
|
-
*
|
|
553
|
-
*
|
|
554
|
-
*
|
|
608
|
+
* An **address-form** `method_ref` (`github.com/<owner>/<repo>[/<selector>][@<tag>]`) is
|
|
609
|
+
* resolved by the server (pipelex-api >= 0.21.0): the package's whole tree is fetched at the tag
|
|
610
|
+
* and read as a tree sent in `files` is. The **registry form** (any non-address reference) stays
|
|
611
|
+
* reserved and answers `501` until a method registry exists.
|
|
612
|
+
*
|
|
613
|
+
* The XOR is a server-side invariant, not a type-level one: expressing it as a union here would
|
|
614
|
+
* make the common `{ files }` call site pick a branch for no gain, and the server rejects the
|
|
615
|
+
* illegal shapes with a typed `ApiResponseError` either way. Two forms of the tree at once are
|
|
616
|
+
* the one shape the client refuses itself, with a `RequestArgumentError`, since it prepares the
|
|
617
|
+
* tree before posting. An empty map or string is absent, as in the Python SDK: `files: {}`,
|
|
618
|
+
* `files: null`, `contents: {}`, `directory: ""` and `dependencies: {}` select and send nothing,
|
|
619
|
+
* so an empty one beside another selector never reaches the wire as a second selector.
|
|
620
|
+
*
|
|
621
|
+
* `dependencies` accompanies the tree: the method packages it calls by address that the runner
|
|
622
|
+
* cannot fetch, each a map of file entries keyed by its address, sent as given. These routes load
|
|
623
|
+
* a package the method calls only from what was shipped with it, so a call into one nothing
|
|
624
|
+
* shipped is the invalid verdict.
|
|
625
|
+
*
|
|
626
|
+
* The files the closure's steps read, such as a `PipeDocGen` step's `template_file`, are files of
|
|
627
|
+
* the tree like any other, so a directory sends them with its bundles.
|
|
628
|
+
*
|
|
629
|
+
* `read_scope` is the Pipelex API's scope the request reads the method under: a hash entry of
|
|
630
|
+
* `files` resolves in that scope's blob store, else in the caller's own. A tree sent by hash asks
|
|
631
|
+
* `POST /v1/blobs/missing` under the same scope, so its blobs are uploaded into the store the
|
|
632
|
+
* request reads. **The hosted platform ignores it**: it stamps the caller's organization as the
|
|
633
|
+
* read scope of every crate request and drops the one the caller sent, so it only reaches a
|
|
634
|
+
* runner called directly.
|
|
555
635
|
*/
|
|
556
636
|
export interface CrateRequestBase {
|
|
557
|
-
|
|
637
|
+
/** The method's directory, listed by the standard's lister and sent as `tree` is. Node only. */
|
|
638
|
+
directory?: string | null;
|
|
639
|
+
/** The method's files, each one's bytes or text by tree path, sent as `tree` is. */
|
|
640
|
+
contents?: Readonly<Record<string, Uint8Array | string>> | null;
|
|
641
|
+
/** The method's tree as a listed source, sent inline when small and by hash otherwise. */
|
|
642
|
+
tree?: MethodTreeSource | null;
|
|
643
|
+
/** The method's tree as the protocol's map of file entries, sent as given. */
|
|
644
|
+
files?: MethodFiles | null;
|
|
645
|
+
/** The method packages the tree calls by address, each a map of file entries keyed by its address. */
|
|
646
|
+
dependencies?: Record<string, MethodFiles>;
|
|
558
647
|
method_ref?: string;
|
|
559
|
-
/** The
|
|
560
|
-
|
|
648
|
+
/** The scope the runner reads the tree under; the hosted platform replaces it with the caller's organization. */
|
|
649
|
+
read_scope?: string;
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* What a crate route call — `resolve`, `codegen`, `pipeIo` — takes beside its request.
|
|
653
|
+
*
|
|
654
|
+
* `signal` is read between the steps a `tree` or `contents` costs before the request, and before
|
|
655
|
+
* the request itself: once it has aborted, no further file of the tree is read, neither the blob
|
|
656
|
+
* route nor an upload starts, and the route is not asked, and the call throws the abort. A request
|
|
657
|
+
* already sent runs to its end, as in `prepareInputs`, which passes its own `signal` here.
|
|
658
|
+
*/
|
|
659
|
+
export interface CrateRouteOptions {
|
|
660
|
+
signal?: AbortSignal;
|
|
561
661
|
}
|
|
562
662
|
/**
|
|
563
663
|
* The `is_valid: false` arm shared by every crate route — `/v1/resolve`,
|
|
@@ -578,7 +678,7 @@ export interface CrateInvalidReport {
|
|
|
578
678
|
}
|
|
579
679
|
/**
|
|
580
680
|
* `POST /v1/resolve` request — the crate envelope (no projection axes) plus the
|
|
581
|
-
* hosted `method_id` selector. Exactly one of
|
|
681
|
+
* hosted `method_id` selector. Exactly one of the tree / `method_ref` /
|
|
582
682
|
* `method_id` — the strict tooling XOR; see {@link PipelexHostedToolingExtensions}.
|
|
583
683
|
*/
|
|
584
684
|
export type ResolveRequest = CrateRequestBase & PipelexHostedToolingExtensions;
|
|
@@ -626,7 +726,7 @@ export type CodegenKind = "types";
|
|
|
626
726
|
export type CodegenTarget = "ts-zod" | "python-pydantic" | "python-structures";
|
|
627
727
|
/**
|
|
628
728
|
* `POST /v1/codegen` request — the crate envelope plus the two explicit projection
|
|
629
|
-
* axes and the hosted `method_id` selector (exactly one of
|
|
729
|
+
* axes and the hosted `method_id` selector (exactly one of the tree / `method_ref` /
|
|
630
730
|
* `method_id`; see {@link PipelexHostedToolingExtensions}).
|
|
631
731
|
*/
|
|
632
732
|
export interface CodegenRequest extends CrateRequestBase, PipelexHostedToolingExtensions {
|
|
@@ -677,7 +777,7 @@ export interface CodegenValidReport {
|
|
|
677
777
|
export type CodegenResponse = CodegenValidReport | CrateInvalidReport;
|
|
678
778
|
/**
|
|
679
779
|
* `POST /v1/pipe-io` request — the crate envelope plus the hosted `method_id` selector
|
|
680
|
-
* (exactly one of
|
|
780
|
+
* (exactly one of the tree / `method_ref` / `method_id`; see
|
|
681
781
|
* {@link PipelexHostedToolingExtensions}), a pipe selector, and two opt-ins.
|
|
682
782
|
*
|
|
683
783
|
* There is no `views` field: the valid arm always carries all three artifacts.
|
|
@@ -685,8 +785,9 @@ export type CodegenResponse = CodegenValidReport | CrateInvalidReport;
|
|
|
685
785
|
export interface PipeIORequest extends CrateRequestBase, PipelexHostedToolingExtensions {
|
|
686
786
|
/**
|
|
687
787
|
* The pipe to describe, as a QUALIFIED `domain.pipe_code` ref. Omit it and the
|
|
688
|
-
* server's selection chain decides:
|
|
689
|
-
* the
|
|
788
|
+
* server's selection chain decides: the `main_pipe` of the `METHODS.toml` at the tree's
|
|
789
|
+
* root, whether the tree was sent or fetched, else the closure's single `main_pipe`
|
|
790
|
+
* declaration. A selection the server refuses is a
|
|
690
791
|
* `422` typed by what went wrong, with `error_domain: "input"` and the candidates, where
|
|
691
792
|
* there are some, in its `detail`: `EntryPipeNotFoundError` for a ref that names no pipe
|
|
692
793
|
* or (without `all_pipes`) a method with no entry pipe, `EntryPipeAmbiguousError` for a
|
|
@@ -705,9 +806,9 @@ export interface PipeIORequest extends CrateRequestBase, PipelexHostedToolingExt
|
|
|
705
806
|
*/
|
|
706
807
|
all_pipes?: boolean;
|
|
707
808
|
/**
|
|
708
|
-
* Echo the
|
|
709
|
-
*
|
|
710
|
-
*
|
|
809
|
+
* Echo the text of the method's own `.mthds` bundles on the valid arm as `files`, keyed
|
|
810
|
+
* by tree path. Defaults to `false` server-side, and the field is then absent from the
|
|
811
|
+
* answer.
|
|
711
812
|
*/
|
|
712
813
|
include_files?: boolean;
|
|
713
814
|
}
|
|
@@ -739,7 +840,8 @@ export interface PipeIOValidReport {
|
|
|
739
840
|
output_form: OutputForm;
|
|
740
841
|
/**
|
|
741
842
|
* The method's own entry pipe: the selection chain without the request's `pipe_ref` —
|
|
742
|
-
* the
|
|
843
|
+
* the `main_pipe` of the `METHODS.toml` at the tree's root, sent or fetched, else the
|
|
844
|
+
* closure's single declaration. A request
|
|
743
845
|
* that omits `pipe_ref` always answers `pipe_ref === default_pipe_ref`. A stated `null`
|
|
744
846
|
* when the chain finds none or several.
|
|
745
847
|
*
|
|
@@ -752,12 +854,13 @@ export interface PipeIOValidReport {
|
|
|
752
854
|
/** `pending_signatures` is empty, as on `validate`. No dry run backs it. */
|
|
753
855
|
is_runnable: boolean;
|
|
754
856
|
/**
|
|
755
|
-
* The
|
|
756
|
-
* when the request passed `include_files: true`:
|
|
757
|
-
*
|
|
758
|
-
*
|
|
857
|
+
* The text of each `.mthds` bundle of the method's own tree, keyed by its tree path.
|
|
858
|
+
* Present only when the request passed `include_files: true`: for a tree the request
|
|
859
|
+
* sent, its bundles, whatever entry form carried them; for a `method_ref`, the fetched
|
|
860
|
+
* package's, keyed by their path from the package root; for a hosted `method_id`, the
|
|
861
|
+
* stored tree's. The tree's other files and its dependencies' bundles are never included.
|
|
759
862
|
*/
|
|
760
|
-
files?:
|
|
863
|
+
files?: Record<string, string>;
|
|
761
864
|
}
|
|
762
865
|
/** The `POST /v1/pipe-io` 200 response — pattern-match `is_valid` before reading the arm. */
|
|
763
866
|
export type PipeIOResponse = PipeIOValidReport | CrateInvalidReport;
|
package/dist/prepare-inputs.d.ts
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
* `pipelex-storage://` in `url`) plus one upload record per prepared asset.
|
|
7
7
|
*
|
|
8
8
|
* The method is named the same three ways every other method-taking operation
|
|
9
|
-
* takes it —
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* takes it — its tree (a `directory`, `contents`, a listed `tree` or the `files`
|
|
10
|
+
* map), a `method_ref` address, or a stored `method_id` — exactly one per call.
|
|
11
|
+
* All three reach `POST /v1/pipe-io`: the tree as the `files` map `pipeIo` sends,
|
|
12
|
+
* an address resolved on the runner and an id on the platform. The route also SELECTS the pipe: the caller's qualified
|
|
13
13
|
* `pipe_ref`, else the method's own entry pipe, and the ref it answers with is
|
|
14
14
|
* the one prepared. It runs no dry run, so preparing inputs costs one static load.
|
|
15
15
|
*
|
|
@@ -30,8 +30,9 @@
|
|
|
30
30
|
* dict. See `docs/input-preparation.md`, which `pipelex-sdk-python` mirrors case
|
|
31
31
|
* for case.
|
|
32
32
|
*/
|
|
33
|
-
import type {
|
|
34
|
-
import type {
|
|
33
|
+
import type { MethodFiles } from "mthds/protocol";
|
|
34
|
+
import type { CrateRouteOptions, PipeIORequest, PipeIOResponse } from "./models.js";
|
|
35
|
+
import type { MethodTreeForm } from "./method-trees.js";
|
|
35
36
|
import type { UploadCapableClient, UploadRecord } from "./upload.js";
|
|
36
37
|
/** The shared half of the request: the target pipe and the caller's inputs. */
|
|
37
38
|
export interface PrepareInputsBase {
|
|
@@ -50,7 +51,9 @@ export interface PrepareInputsBase {
|
|
|
50
51
|
/**
|
|
51
52
|
* Stops the preparation between its steps, a file's read and its upload included: once it has
|
|
52
53
|
* aborted, neither the pipe I/O request nor any upload starts, and `prepareInputs` throws the
|
|
53
|
-
* abort. A
|
|
54
|
+
* abort. A `tree` or `contents` sent by hash counts its steps too — the version handshake, the
|
|
55
|
+
* blob route, each read and upload of a missing blob — so an abort during the handshake starts
|
|
56
|
+
* none of the rest. A request already sent runs to its end. It is not sent to the server.
|
|
54
57
|
*/
|
|
55
58
|
signal?: AbortSignal;
|
|
56
59
|
/**
|
|
@@ -63,35 +66,48 @@ export interface PrepareInputsBase {
|
|
|
63
66
|
*/
|
|
64
67
|
allowUploads?: boolean;
|
|
65
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* The method's tree, in exactly one of the forms `pipeIo` takes it (see `CrateRequestBase`):
|
|
71
|
+
* `directory`, the method's directory on disk, listed by the `mthds` package's lister (Node only);
|
|
72
|
+
* `contents`, each file's bytes or text by tree path; `tree`, a listed source such as the
|
|
73
|
+
* `MethodTree` the `mthds` package's `listMethodTree` returns; or `files`, the protocol's map of
|
|
74
|
+
* file entries, sent as given. The client sends a `directory`, `contents` or `tree` inline when
|
|
75
|
+
* small and by hash otherwise.
|
|
76
|
+
*/
|
|
77
|
+
export type PrepareInputsTree = MethodTreeForm;
|
|
78
|
+
/** What a published or stored method cannot carry: its tree is its own. */
|
|
79
|
+
interface NoTree {
|
|
80
|
+
directory?: never;
|
|
81
|
+
contents?: never;
|
|
82
|
+
tree?: never;
|
|
83
|
+
files?: never;
|
|
84
|
+
dependencies?: never;
|
|
85
|
+
}
|
|
66
86
|
/**
|
|
67
87
|
* How the method is named — exactly one of the three selectors, each pinning the
|
|
68
88
|
* other two to `never` so a second one is a compile error (the same XOR
|
|
69
89
|
* `ValidateMethodSelector` states for `validate`). All three reach the
|
|
70
|
-
* server as
|
|
71
|
-
* resolved by the platform.
|
|
90
|
+
* server: the tree as the `files` map, `method_ref` resolved by the runner,
|
|
91
|
+
* `method_id` resolved by the platform.
|
|
72
92
|
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
93
|
+
* The tree may bring `dependencies`, the method packages it calls by address, each a
|
|
94
|
+
* map of file entries keyed by its address. The files the closure's steps read, such as a
|
|
95
|
+
* `PipeDocGen` step's `template_file`, are files of the tree like any other. The pipe I/O
|
|
96
|
+
* route loads the closure, and a step whose template file is not in the tree, or a call
|
|
97
|
+
* into a package nothing shipped, makes it fail to load. A published or stored method's
|
|
98
|
+
* tree and packages are its own, so the other two selectors take no `dependencies`.
|
|
78
99
|
*/
|
|
79
|
-
export type PrepareInputsClosure = {
|
|
80
|
-
|
|
81
|
-
resources?: BundleResources | null;
|
|
100
|
+
export type PrepareInputsClosure = (PrepareInputsTree & {
|
|
101
|
+
dependencies?: Record<string, MethodFiles>;
|
|
82
102
|
method_ref?: never;
|
|
83
103
|
method_id?: never;
|
|
84
|
-
} | {
|
|
104
|
+
}) | (NoTree & {
|
|
85
105
|
method_ref: string;
|
|
86
|
-
files?: never;
|
|
87
106
|
method_id?: never;
|
|
88
|
-
|
|
89
|
-
} | {
|
|
107
|
+
}) | (NoTree & {
|
|
90
108
|
method_id: string;
|
|
91
|
-
files?: never;
|
|
92
109
|
method_ref?: never;
|
|
93
|
-
|
|
94
|
-
};
|
|
110
|
+
});
|
|
95
111
|
/** What `prepareInputs` takes: one method selector, the target pipe, the caller's inputs. */
|
|
96
112
|
export type PrepareInputsRequest = PrepareInputsBase & PrepareInputsClosure;
|
|
97
113
|
/** The result of `prepareInputs`: rewritten inputs (copy-on-write) plus upload records. */
|
|
@@ -107,7 +123,7 @@ export interface PreparedInputs {
|
|
|
107
123
|
* `PipelexApiClient` satisfies it structurally.
|
|
108
124
|
*/
|
|
109
125
|
export interface PrepareCapableClient extends UploadCapableClient {
|
|
110
|
-
pipeIo(request: PipeIORequest): Promise<PipeIOResponse>;
|
|
126
|
+
pipeIo(request: PipeIORequest, options?: CrateRouteOptions): Promise<PipeIOResponse>;
|
|
111
127
|
}
|
|
112
128
|
/**
|
|
113
129
|
* Where an input-form entry breaks the shape `prepareInputs` reads, and what was
|
|
@@ -147,8 +163,10 @@ export declare function inputFormFault(entry: unknown): InputFormFault | undefin
|
|
|
147
163
|
* that would need either throws {@link UploadNotAllowedError}, naming them too.
|
|
148
164
|
*
|
|
149
165
|
* The pipe and its signature come from one `POST /v1/pipe-io`, whatever the
|
|
150
|
-
* selector —
|
|
151
|
-
* `method_id` the platform resolves. A
|
|
166
|
+
* selector — the method's tree, a `method_ref` the runner resolves, or a
|
|
167
|
+
* `method_id` the platform resolves. A `tree` or `contents` too large to send
|
|
168
|
+
* inline goes by hash, and a blob that fails to upload throws
|
|
169
|
+
* `MethodFileTransferError` before the route is asked. A bare or alias-qualified `pipe_ref`, a
|
|
152
170
|
* closure that does not load, and a selection the route refuses (an unknown
|
|
153
171
|
* `pipe_ref`, no entry pipe, several) throw {@link InputPreparationError}. So
|
|
154
172
|
* does an answer that breaks the route's contract, with a `runtime` verdict that
|
|
@@ -160,3 +178,4 @@ export declare function inputFormFault(entry: unknown): InputFormFault | undefin
|
|
|
160
178
|
* the route) surfaces as `ApiResponseError`, unchanged.
|
|
161
179
|
*/
|
|
162
180
|
export declare function prepareInputs(client: PrepareCapableClient, request: PrepareInputsRequest): Promise<PreparedInputs>;
|
|
181
|
+
export {};
|