@pipelex/sdk 0.11.0 → 0.13.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/dist/models.d.ts CHANGED
@@ -200,15 +200,27 @@ export interface MthdsFileItem {
200
200
  source?: string;
201
201
  }
202
202
  /**
203
- * The closure + pipe selector every `/v1/build/*` route shares.
203
+ * The closure selector every crate-family route shares — `/v1/resolve`, `/v1/codegen`,
204
+ * and `/v1/build/*` (mirror of the server's `MthdsFilesRequest`).
204
205
  *
205
206
  * Supply the closure EITHER as inline `files` OR as a `method_ref` into the method
206
- * registry — never both. `method_ref` is reserved: the registry does not exist yet,
207
- * so the server answers `501` for it today.
207
+ * registry — never both, and never neither (both arms are a request-shape `422`).
208
+ * `method_ref` is reserved: the registry does not exist yet, so the server answers
209
+ * `501` for it today.
210
+ *
211
+ * The XOR is a server-side invariant, not a type-level one: expressing it as a union
212
+ * here would make the common `{ files }` call site pick a branch for no gain, and the
213
+ * server rejects the two illegal shapes with a typed `ApiResponseError` either way.
208
214
  */
209
- export interface BuildRequestBase {
215
+ export interface CrateRequestBase {
210
216
  files?: MthdsFileItem[];
211
217
  method_ref?: string;
218
+ }
219
+ /**
220
+ * The crate envelope plus the pipe selector the `/v1/build/*` projections add
221
+ * (mirror of the server's `MthdsPipeRequest`).
222
+ */
223
+ export interface BuildRequestBase extends CrateRequestBase {
212
224
  /**
213
225
  * The pipe to project, as a QUALIFIED `domain.pipe_code` ref. Omit it to default
214
226
  * to the closure's declared `main_pipe` — which fails (422) when the closure
@@ -250,13 +262,16 @@ export interface PipeSpecRequest {
250
262
  spec: Record<string, unknown>;
251
263
  }
252
264
  /**
253
- * The `is_valid: false` arm shared by every `/v1/build/*` route.
265
+ * The `is_valid: false` arm shared by every crate-family route — `/v1/build/*`,
266
+ * `/v1/resolve`, and `/v1/codegen` (mirror of the server's one `CrateInvalidReport`).
254
267
  *
255
- * The build routes follow `/validate`'s discipline: an unresolvable closure is the
268
+ * They all follow `/validate`'s discipline: an unresolvable closure is the
256
269
  * *successful product* of the call (the request was well-formed, the library was
257
270
  * not), so it rides a **200** discriminated on `is_valid` — never a 4xx. Only a
258
- * no-verdict condition (an unknown `pipe_ref`, `method_ref`, auth, a server fault)
259
- * throws `ApiResponseError`. Branch on `is_valid`, never on the transport.
271
+ * no-verdict condition throws `ApiResponseError`: a request the route cannot act on
272
+ * (an unknown `pipe_ref` on the build routes, an unknown `kind`/`target` on codegen),
273
+ * the reserved `method_ref`, auth, a server fault. Branch on `is_valid`, never on the
274
+ * transport.
260
275
  */
261
276
  export interface CrateInvalidReport {
262
277
  is_valid: false;
@@ -314,7 +329,11 @@ interface BuildOutputPythonReport extends BuildValidReportBase {
314
329
  }
315
330
  export type BuildOutputValidReport = BuildOutputObjectReport | BuildOutputPythonReport;
316
331
  export type BuildOutputResponse = BuildOutputValidReport | CrateInvalidReport;
317
- /** One stamped generated file in the structures projection. */
332
+ /**
333
+ * One stamped generated file — shared by `/v1/build/runner`'s structures projection
334
+ * and `/v1/codegen`'s artifact set. `path` is relative to the output root the client
335
+ * chooses; `content` is complete, stamp header included, and is written verbatim.
336
+ */
318
337
  export interface GeneratedArtifact {
319
338
  path: string;
320
339
  content: string;
@@ -346,4 +365,85 @@ export interface PipeSpecResponse {
346
365
  pipe_type: string;
347
366
  toml: string;
348
367
  }
368
+ /** `POST /v1/resolve` request — the bare crate envelope, no projection axes. */
369
+ export type ResolveRequest = CrateRequestBase;
370
+ /**
371
+ * The `/v1/resolve` valid arm — the normalized library crate.
372
+ *
373
+ * `crate` is the MTHDS **Library Crate Format**: fully qualified refs, refinement
374
+ * flattened, natives materialized, top-level maps key-sorted, non-semantic provenance
375
+ * dropped. Its `fingerprint` and `mthds_version` ride INSIDE the payload, not beside it.
376
+ *
377
+ * **Do not recompute the fingerprint by hashing this object.** It is a property of the
378
+ * logical crate, not of any particular encoding: the server hashes `{concepts, pipes,
379
+ * domains}` with each object's provenance `source` stripped, excluding `source_map`,
380
+ * `mthds_version`, and `fingerprint` itself. Nor are these the same *bytes* the CLI
381
+ * prints — `pipelex resolve --format json` pretty-prints, while this rides a compact
382
+ * JSON response. Same logical crate, different serialization; compare `fingerprint`
383
+ * values, never serialized bytes.
384
+ *
385
+ * Typed as opaque transport (`Record<string, unknown>`): the crate schema is owned by the
386
+ * MTHDS standard, not by this SDK, and restating it here would be a second source of truth
387
+ * free to drift from the one the server emits.
388
+ */
389
+ export interface ResolveValidReport {
390
+ is_valid: true;
391
+ crate: Record<string, unknown>;
392
+ message: string;
393
+ }
394
+ /** The `POST /v1/resolve` 200 response — pattern-match `is_valid` before reading the arm. */
395
+ export type ResolveResponse = ResolveValidReport | CrateInvalidReport;
396
+ /**
397
+ * What `/v1/codegen` projects — the `kind` axis. `types` (the crate's whole concept set
398
+ * projected into typed models) is the only kind served today; the future per-pipe kinds
399
+ * (`docs`, `tools`, `tests`) join it and select their pipe via `pipe_ref`. Input templates
400
+ * are deliberately NOT a kind here — they are user-editable scaffolds, never stamped or
401
+ * locked, and ride `POST /v1/build/inputs` instead.
402
+ */
403
+ export type CodegenKind = "types";
404
+ /**
405
+ * For whom `/v1/codegen` projects — the `target` axis, mirroring pipelex's `CodegenTarget`.
406
+ * `ts-zod` (zod schemas + inferred types) is the natural target for TypeScript consumers;
407
+ * `python-pydantic` emits self-contained BaseModels; `python-structures` emits runtime
408
+ * StructuredContent classes for a Pipelex host.
409
+ */
410
+ export type CodegenTarget = "ts-zod" | "python-pydantic" | "python-structures";
411
+ /** `POST /v1/codegen` request — the crate envelope plus the two explicit projection axes. */
412
+ export interface CodegenRequest extends CrateRequestBase {
413
+ kind: CodegenKind;
414
+ target: CodegenTarget;
415
+ /**
416
+ * Pipe selector for per-pipe projection kinds. `kind: "types"` is concept-set-wide and
417
+ * REJECTS it with a request-shape `422` rather than silently ignoring it — the field
418
+ * exists for the future per-pipe kinds.
419
+ */
420
+ pipe_ref?: string;
421
+ }
422
+ /**
423
+ * The `/v1/codegen` valid arm — the stamped artifact set plus its lock.
424
+ *
425
+ * The trust chain: write every `artifacts[]` entry at its `path` and the `lock` content as
426
+ * `lock_filename`, both verbatim, and the tree is byte-identical to what a local `pipelex
427
+ * codegen types` run produces — same stamps, same lock — so the offline `pipelex codegen
428
+ * check` passes on it. Editing an artifact (or re-serializing the lock) breaks that chain;
429
+ * there is deliberately no server-side check route, because the check is offline by design.
430
+ */
431
+ export interface CodegenValidReport {
432
+ is_valid: true;
433
+ /** Echo of the request's projection axes. */
434
+ kind: CodegenKind;
435
+ target: CodegenTarget;
436
+ /** Fingerprint of the normalized crate the artifacts were generated from. */
437
+ crate_fingerprint: string;
438
+ /** The pipelex engine version that generated them. */
439
+ engine_version: string;
440
+ artifacts: GeneratedArtifact[];
441
+ /** The lock file's TOML content — write verbatim beside the artifacts. */
442
+ lock: string;
443
+ /** The filename `lock` must be written as (`codegen.lock`). */
444
+ lock_filename: string;
445
+ message: string;
446
+ }
447
+ /** The `POST /v1/codegen` 200 response — pattern-match `is_valid` before reading the arm. */
448
+ export type CodegenResponse = CodegenValidReport | CrateInvalidReport;
349
449
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipelex/sdk",
3
- "version": "0.11.0",
3
+ "version": "0.13.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": {
@@ -8,6 +8,9 @@
8
8
  "url": "https://github.com/Pipelex/pipelex-sdk-js"
9
9
  },
10
10
  "type": "module",
11
+ "sideEffects": [
12
+ "./dist/hooks/claude-mthds-check.js"
13
+ ],
11
14
  "main": "./dist/index.js",
12
15
  "types": "./dist/index.d.ts",
13
16
  "exports": {
@@ -56,6 +59,7 @@
56
59
  "vitest": "^4.0.18"
57
60
  },
58
61
  "dependencies": {
59
- "mthds": "^0.22.0"
62
+ "mthds": "^0.22.0",
63
+ "smol-toml": "^1.6.0"
60
64
  }
61
65
  }