@pipelex/sdk 0.14.0 → 0.16.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 +9 -0
- package/dist/client.d.ts +124 -54
- package/dist/client.js +209 -72
- package/dist/client.js.map +1 -1
- package/dist/execute-result.d.ts +11 -1
- package/dist/execute-result.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/models.d.ts +92 -27
- package/dist/prepare-inputs.d.ts +14 -38
- package/dist/prepare-inputs.js +14 -34
- package/dist/prepare-inputs.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -36,6 +36,15 @@ if (report.is_valid) {
|
|
|
36
36
|
// also rides `pipe_output` on the blocking path).
|
|
37
37
|
console.log(result.main_stuff);
|
|
38
38
|
}
|
|
39
|
+
|
|
40
|
+
// Or run a published method by address — resolved server-side (fetch at tag,
|
|
41
|
+
// commit SHA recorded as provenance on the start ack). Requires pipelex-api >= 0.21.0;
|
|
42
|
+
// on api.pipelex.com, availability follows the platform deploy that forwards it.
|
|
43
|
+
const ack = await client.start({
|
|
44
|
+
method_ref: "github.com/Pipelex/methods/documents@v0.1.0",
|
|
45
|
+
inputs: { document: { url: "https://example.com/report.pdf" } },
|
|
46
|
+
});
|
|
47
|
+
console.log(ack.method_provenance); // { address, tag, commit_sha }
|
|
39
48
|
```
|
|
40
49
|
|
|
41
50
|
### Product routes
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { MTHDSProtocol, ModelCategory, ModelDeck, RunOptions,
|
|
2
|
-
import type { BuildInputsRequest, BuildInputsResponse, BuildOutputRequest, BuildOutputResponse, BuildRunnerRequest, BuildRunnerResponse, CodegenRequest, CodegenResponse, ConceptRequest, ConceptResponse, DictPipeOutput, FormatResponse,
|
|
1
|
+
import type { MTHDSProtocol, ModelCategory, ModelDeck, RunOptions, StartOptions, VersionInfo } from "mthds/protocol";
|
|
2
|
+
import type { BuildInputsRequest, BuildInputsResponse, BuildOutputRequest, BuildOutputResponse, BuildRunnerRequest, BuildRunnerResponse, CodegenRequest, CodegenResponse, ConceptRequest, ConceptResponse, DictPipeOutput, FormatResponse, LintResponse, MthdsFileItem, PipeSpecRequest, PipeSpecResponse, PipelexRunResultStart, PipelexValidationResult, ResolveRequest, ResolveResponse } from "./models.js";
|
|
3
3
|
import { type RunRead, type RunResults, type RunResultState, type WaitForResultOptions } from "./runs.js";
|
|
4
4
|
import type { BillingPortalResponse, ChangePlanResponse, CheckoutResponse, GatewayApiKey, GatewayApiKeyStatus, InvoiceView, Membership, MembershipsResponse, ListMethodsQuery, MethodData, MethodDeletionAccepted, MethodPage, MethodSummary, MethodWriteInput, OnboardingSubmission, PipelexApiKeyCreated, PipelexApiKeyList, ListRunsQuery, PipelineRun, RunDetail, RunPage, PlanView, ResolvedStorageUrl, SubscriptionResponse, UpdateRunInput, UploadInput, UploadedFile, UserProfile } from "./product-models.js";
|
|
5
5
|
import type { UploadableAsset, UploadFileOptions, UploadRecord } from "./upload.js";
|
|
@@ -11,6 +11,37 @@ export interface MthdsFile {
|
|
|
11
11
|
/** Optional provenance URI threaded into validation diagnostics. */
|
|
12
12
|
uri?: string;
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* The Pipelex API's own run-source extension — the layer-2 argument the RUNNER
|
|
16
|
+
* itself resolves, beside the protocol's inline sources (`mthds_contents` and
|
|
17
|
+
* the bundle encodings). Served by any pipelex-api >= 0.21.0 deployment, bare
|
|
18
|
+
* or hosted (on `api.pipelex.com`, once the platform deploy carrying it lands).
|
|
19
|
+
*
|
|
20
|
+
* Named options rather than `extra` entries, for the same reason as the hosted
|
|
21
|
+
* extensions below: `extra` remains the escape hatch for an extension this
|
|
22
|
+
* client does not know about, never the way to pass one it does.
|
|
23
|
+
*/
|
|
24
|
+
export interface PipelexApiRunExtensions {
|
|
25
|
+
/**
|
|
26
|
+
* A published method's address — `github.com/<owner>/<repo>[/<selector>][@<tag>]`
|
|
27
|
+
* (e.g. `github.com/Pipelex/methods/documents@v0.1.0`). Resolved by the
|
|
28
|
+
* server: the repository is fetched at the tag (a bare address means the
|
|
29
|
+
* default branch at HEAD), the package is located by manifest identity, and
|
|
30
|
+
* the resolved commit SHA comes back as `method_provenance` on the response.
|
|
31
|
+
*
|
|
32
|
+
* A complete run source of its own — the fetched package carries its `.mthds`
|
|
33
|
+
* and its entry pipe — so it pairs with NOTHING: exclusive with inline
|
|
34
|
+
* `mthds_contents`, with a method bundle (`files` / `bundle_b64`), and with
|
|
35
|
+
* the hosted `method_id` (an address run has its own provenance and needs no
|
|
36
|
+
* linkage id). `pipe_code` beside it is fine — it overrides the manifest's
|
|
37
|
+
* `main_pipe` to pick which pipe in the fetched package to run. This client
|
|
38
|
+
* rejects the illegal pairings before anything hits the wire, mirroring the
|
|
39
|
+
* server's own 422s.
|
|
40
|
+
*
|
|
41
|
+
* An empty string is treated as absent and is not sent.
|
|
42
|
+
*/
|
|
43
|
+
method_ref?: string | null;
|
|
44
|
+
}
|
|
14
45
|
/**
|
|
15
46
|
* The hosted API's own run arguments — the layer-3 extensions this client adds
|
|
16
47
|
* on top of the MTHDS Protocol's run-argument surface (`RunOptions` /
|
|
@@ -38,34 +69,32 @@ export interface PipelexHostedRunExtensions {
|
|
|
38
69
|
* **run-history linkage** on the Run row. That linkage is what writes the
|
|
39
70
|
* index key `GET /v1/runs?method_id=` queries, so a run started without it
|
|
40
71
|
* is absent from its method's history permanently.
|
|
72
|
+
* - **Alongside `method_ref`** — rejected client-side (and a 422 on the
|
|
73
|
+
* hosted API): an address run carries its own provenance, so it takes no
|
|
74
|
+
* linkage id.
|
|
41
75
|
*
|
|
42
76
|
* An empty string is treated as absent and is not sent.
|
|
43
77
|
*/
|
|
44
78
|
method_id?: string | null;
|
|
45
79
|
}
|
|
46
|
-
/** `execute()` options — the protocol's run arguments plus the hosted extensions. */
|
|
47
|
-
export type PipelexRunOptions = RunOptions & PipelexHostedRunExtensions;
|
|
80
|
+
/** `execute()` options — the protocol's run arguments plus the Pipelex API and hosted extensions. */
|
|
81
|
+
export type PipelexRunOptions = RunOptions & PipelexApiRunExtensions & PipelexHostedRunExtensions;
|
|
48
82
|
/** `start()` / `startAndWaitForResult()` options — the same, for the durable path. */
|
|
49
|
-
export type PipelexStartOptions = StartOptions & PipelexHostedRunExtensions;
|
|
83
|
+
export type PipelexStartOptions = StartOptions & PipelexApiRunExtensions & PipelexHostedRunExtensions;
|
|
50
84
|
/**
|
|
51
|
-
* The
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* distinct from `BuildRequestBase.method_ref`, the reserved registry ref). Supply
|
|
57
|
-
* a `method_id` OR inline `files`, never both.
|
|
85
|
+
* The method selector `validate()` takes in place of inline contents: a
|
|
86
|
+
* `method_ref` address (server-resolved by the runner through the same fetch
|
|
87
|
+
* path as a `method_ref` run) OR a hosted `method_id` (platform-resolved) —
|
|
88
|
+
* never both. The tooling routes are stateless, so the strict XOR applies:
|
|
89
|
+
* exactly one of inline contents / `method_ref` / `method_id` per request.
|
|
58
90
|
*/
|
|
59
|
-
export
|
|
60
|
-
|
|
91
|
+
export type ValidateMethodSelector = {
|
|
92
|
+
method_ref: string;
|
|
93
|
+
method_id?: never;
|
|
94
|
+
} | {
|
|
61
95
|
method_id: string;
|
|
62
|
-
files?: never;
|
|
63
96
|
method_ref?: never;
|
|
64
|
-
|
|
65
|
-
pipe_ref?: string;
|
|
66
|
-
format?: InputsTemplateFormat;
|
|
67
|
-
explicit?: boolean;
|
|
68
|
-
}
|
|
97
|
+
};
|
|
69
98
|
export interface ValidateFilesOptions {
|
|
70
99
|
/** Whether unresolved pipe signatures are accepted as pending instead of invalid. */
|
|
71
100
|
allowSignatures?: boolean;
|
|
@@ -159,14 +188,17 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
|
|
|
159
188
|
/**
|
|
160
189
|
* Start a method asynchronously — `POST /v1/start` (202, no output yet).
|
|
161
190
|
*
|
|
162
|
-
* The hosted `method_id`
|
|
163
|
-
* `options.extra`
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
191
|
+
* The `method_ref` address and the hosted `method_id` are named options (see
|
|
192
|
+
* `PipelexApiRunExtensions` / `PipelexHostedRunExtensions`); `options.extra`
|
|
193
|
+
* stays the generic passthrough for extension args this client does not know
|
|
194
|
+
* about — the server you call defines and handles them (including a
|
|
195
|
+
* client-supplied run id where a server supports one). The returned
|
|
196
|
+
* `pipeline_run_id` is always authoritative; on a hosted deployment it is
|
|
197
|
+
* durable — poll `getRunStatus` / `getRunResult`. A `method_ref` run's ack
|
|
198
|
+
* additionally carries `method_provenance` — the address, the tag, and the
|
|
199
|
+
* commit SHA that was actually fetched.
|
|
168
200
|
*/
|
|
169
|
-
start(options: PipelexStartOptions): Promise<
|
|
201
|
+
start(options: PipelexStartOptions): Promise<PipelexRunResultStart>;
|
|
170
202
|
/**
|
|
171
203
|
* Parse, validate, and dry-run an MTHDS bundle — `POST /v1/validate`.
|
|
172
204
|
*
|
|
@@ -178,11 +210,32 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
|
|
|
178
210
|
* *no-verdict* condition (a malformed request, an `mthds_sources` length mismatch,
|
|
179
211
|
* auth, a server fault) is non-2xx and surfaces as `ApiResponseError`.
|
|
180
212
|
*
|
|
181
|
-
* `
|
|
213
|
+
* `source` selects WHAT is validated, in exactly one of three forms — the
|
|
214
|
+
* strict tooling XOR (the routes are stateless, so there is no linkage
|
|
215
|
+
* exception; a second selector is a request-shape `422`):
|
|
216
|
+
*
|
|
217
|
+
* - **inline contents** (a `string[]`) — the protocol's own envelope;
|
|
218
|
+
* - **`{ method_ref }`** — a published method's address, resolved by the
|
|
219
|
+
* server (pipelex-api >= 0.21.0) through the same fetch path as a
|
|
220
|
+
* `method_ref` run, the package's real file names feeding the diagnostics'
|
|
221
|
+
* source labels;
|
|
222
|
+
* - **`{ method_id }`** — a stored method's catalog id, hosted-only: the
|
|
223
|
+
* platform resolves it and injects the stored source before the runner sees
|
|
224
|
+
* the request (a bare runner rejects the request as carrying no source it
|
|
225
|
+
* understands).
|
|
226
|
+
*
|
|
227
|
+
* A selector-resolution failure (fetch failure, no package at the address, an
|
|
228
|
+
* unknown or foreign-org id) is a non-2xx `ApiResponseError` — never an
|
|
229
|
+
* `is_valid: false` verdict, which is reserved for actual MTHDS content.
|
|
230
|
+
*
|
|
231
|
+
* `mthdsSources` (optional, parallel to inline contents) names each submitted
|
|
182
232
|
* content — a Pipelex-API extension threaded onto `blueprint.source`, so
|
|
183
233
|
* cross-file diagnostics name the owning file (an unnamed content yields
|
|
184
234
|
* `source: null`). The server 422s a length mismatch; this client sends the
|
|
185
|
-
* arrays verbatim and surfaces that as an `ApiResponseError`.
|
|
235
|
+
* arrays verbatim and surfaces that as an `ApiResponseError`. It is an
|
|
236
|
+
* inline-contents companion only: a `method_ref` / `method_id` validation gets
|
|
237
|
+
* its source labels from the package's (or the stored method's) real file
|
|
238
|
+
* names, so supplying it beside a selector is rejected client-side.
|
|
186
239
|
*
|
|
187
240
|
* `render` is the Pipelex-API presentation hint — a list of view-format tokens.
|
|
188
241
|
* This client always asks for Markdown so both valid results and produced
|
|
@@ -201,7 +254,7 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
|
|
|
201
254
|
* the field regardless — which is why `PipelexValidationReport.input_form` is typed
|
|
202
255
|
* optional rather than required.
|
|
203
256
|
*/
|
|
204
|
-
validate(
|
|
257
|
+
validate(source: string[] | ValidateMethodSelector, allowSignatures?: boolean, mthdsSources?: string[], render?: string[], views?: string[], options?: {
|
|
205
258
|
timeoutMs?: number;
|
|
206
259
|
signal?: AbortSignal;
|
|
207
260
|
}): Promise<PipelexValidationResult>;
|
|
@@ -251,7 +304,8 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
|
|
|
251
304
|
* The mapping is what makes their no-verdict arms usable: a crate-family route
|
|
252
305
|
* answers `422` for a request it cannot act on (an unresolvable pipe selector on the
|
|
253
306
|
* build routes; an unknown `kind`/`target`, or a `pipe_ref` on the concept-set-wide
|
|
254
|
-
* `types` kind, on `codegen`) and `501` for the reserved `method_ref
|
|
307
|
+
* `types` kind, on `codegen`) and `501` for the reserved registry-form `method_ref`
|
|
308
|
+
* (the address form is resolved server-side as of pipelex-api 0.21.0). A caller
|
|
255
309
|
* branches on `ApiResponseError.status`, never on a message.
|
|
256
310
|
*
|
|
257
311
|
* All of these are inference-free, so they default to the management-call timeout.
|
|
@@ -298,10 +352,15 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
|
|
|
298
352
|
* Returns a **200 verdict**: pattern-match `is_valid` before reading the arm — a
|
|
299
353
|
* closure that does not parse/load/validate comes back as `is_valid: false` with
|
|
300
354
|
* `validation_errors[]`, not as a thrown error. Only a no-verdict condition throws
|
|
301
|
-
* `ApiResponseError`: a malformed selector (
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
* `
|
|
355
|
+
* `ApiResponseError`: a malformed selector (none, or more than one, of
|
|
356
|
+
* `files` / `method_ref` / `method_id`) is a 422; a selector-resolution failure
|
|
357
|
+
* (fetch failure, no package at the address, an unknown or foreign-org id) is
|
|
358
|
+
* non-2xx too — never an `is_valid: false` verdict.
|
|
359
|
+
*
|
|
360
|
+
* The closure arrives in exactly one of three forms: inline `files`, an
|
|
361
|
+
* address-form `method_ref` (server-resolved, pipelex-api >= 0.21.0; the
|
|
362
|
+
* registry form stays a `501`), or a hosted `method_id` (platform-resolved —
|
|
363
|
+
* see {@link PipelexHostedToolingExtensions}).
|
|
305
364
|
*/
|
|
306
365
|
resolve(request: ResolveRequest): Promise<ResolveResponse>;
|
|
307
366
|
/**
|
|
@@ -314,9 +373,10 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
|
|
|
314
373
|
* local `pipelex codegen types` run, so the offline `pipelex codegen check` passes on
|
|
315
374
|
* it; the SDK deliberately does not write files for you.
|
|
316
375
|
*
|
|
317
|
-
* Same 200-verdict discipline
|
|
318
|
-
*
|
|
319
|
-
* `
|
|
376
|
+
* Same 200-verdict discipline and same three-form closure selector as
|
|
377
|
+
* {@link resolve}. Only a no-verdict condition throws `ApiResponseError`: an
|
|
378
|
+
* unknown `kind`/`target`, a `pipe_ref` on the concept-set-wide `types` kind, or
|
|
379
|
+
* a malformed selector is a 422; a registry-form `method_ref` is a `501`.
|
|
320
380
|
*/
|
|
321
381
|
codegen(request: CodegenRequest): Promise<CodegenResponse>;
|
|
322
382
|
/**
|
|
@@ -331,14 +391,15 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
|
|
|
331
391
|
* unresolvable closure comes back as `is_valid: false` with `validation_errors[]`,
|
|
332
392
|
* not as a thrown error.
|
|
333
393
|
*
|
|
334
|
-
* Accepts the closure as inline `files` (the wire
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
*
|
|
394
|
+
* Accepts the closure as inline `files` or as a `method_ref` (both on the wire
|
|
395
|
+
* model {@link BuildInputsRequest}; the address form is server-resolved, the
|
|
396
|
+
* registry form `501`s) — exactly one of the two, like `buildOutput` /
|
|
397
|
+
* `buildRunner`. There is NO by-id form: the build routes take no `method_id`
|
|
398
|
+
* (the hosted tooling selector covers `validate`/`resolve`/`codegen` only), so a
|
|
399
|
+
* stored method is expanded first — `buildInputs({ files: await
|
|
400
|
+
* client.getMethodClosure(methodId) })`.
|
|
340
401
|
*/
|
|
341
|
-
buildInputs(request: BuildInputsRequest
|
|
402
|
+
buildInputs(request: BuildInputsRequest): Promise<BuildInputsResponse>;
|
|
342
403
|
/**
|
|
343
404
|
* Project a pipe's output concept — `POST /v1/build/output`. Same envelope and
|
|
344
405
|
* same 200-verdict discipline as {@link buildInputs}. `format: "schema"` (the
|
|
@@ -463,6 +524,13 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
|
|
|
463
524
|
* with `methodSourceToContents`, and labels each resulting file with the
|
|
464
525
|
* `method_id` as its `source` provenance.
|
|
465
526
|
*
|
|
527
|
+
* This is the LOCAL expansion utility — for callers that want the files in
|
|
528
|
+
* hand (to edit, to diff, to feed a route with no by-id form such as
|
|
529
|
+
* `/v1/build/*` or `prepareInputs`). The routes that accept `method_id`
|
|
530
|
+
* natively (`execute`/`start`, and `validate`/`resolve`/`codegen` on the
|
|
531
|
+
* hosted API) take the id as a pass-through instead; nothing in this client
|
|
532
|
+
* expands an id behind your back.
|
|
533
|
+
*
|
|
466
534
|
* Requires an API key: the methods catalog is org-scoped to the key's org, so
|
|
467
535
|
* an unknown OR foreign-org id is a `getMethod` `404` (`ApiResponseError`
|
|
468
536
|
* `not_found`), which propagates unchanged. A real, in-org method whose source
|
|
@@ -574,9 +642,9 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
|
|
|
574
642
|
* content carrying `pipelex-storage://` in `url`) plus one upload record per
|
|
575
643
|
* prepared asset. HTTP(S) URLs and existing `pipelex-storage://` URIs pass
|
|
576
644
|
* through unchanged; all failures are raised before any run is created. The
|
|
577
|
-
* caller supplies the method closure
|
|
578
|
-
*
|
|
579
|
-
*
|
|
645
|
+
* caller supplies the method closure as inline `files` — for a stored method,
|
|
646
|
+
* expand it first with `getMethodClosure` (requires an API key). See
|
|
647
|
+
* `docs/input-preparation.md`.
|
|
580
648
|
*/
|
|
581
649
|
prepareInputs(request: PrepareInputsRequest): Promise<PreparedInputs>;
|
|
582
650
|
/**
|
|
@@ -633,12 +701,14 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
|
|
|
633
701
|
updateRun(runId: string, input: UpdateRunInput): Promise<void>;
|
|
634
702
|
/**
|
|
635
703
|
* Blocking `POST /v1/execute` adapted onto `RunResults` — the bare-runner
|
|
636
|
-
* path. Forwards every protocol field PLUS
|
|
637
|
-
* hosted `method_id
|
|
638
|
-
* call (`{ extra }` with no
|
|
639
|
-
* `extra` must survive this
|
|
640
|
-
*
|
|
641
|
-
*
|
|
704
|
+
* path. Forwards every protocol field PLUS every extension surface: the
|
|
705
|
+
* runner-resolved `method_ref`, the hosted `method_id`, and the generic
|
|
706
|
+
* `extra` passthrough. An extension-only call (`{ extra }` with no
|
|
707
|
+
* pipe_code/bundle) or a vendor selector riding `extra` must survive this
|
|
708
|
+
* path, not just the durable one — a `method_ref` run must run the same
|
|
709
|
+
* fetched package here, and a hosted `method_id` must reach the server too,
|
|
710
|
+
* so a runner that cannot resolve it says so (Rule 4) instead of the client
|
|
711
|
+
* silently dropping it.
|
|
642
712
|
*/
|
|
643
713
|
private executeBlocking;
|
|
644
714
|
}
|