@pipelex/sdk 0.25.1 → 0.26.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 +24 -2
- package/dist/artifacts.js +1 -1
- package/dist/artifacts.js.map +1 -1
- package/dist/client.d.ts +6 -3
- package/dist/client.js +106 -34
- package/dist/client.js.map +1 -1
- package/dist/error-models.d.ts +198 -0
- package/dist/error-models.js +26 -0
- package/dist/error-models.js.map +1 -0
- package/dist/errors.d.ts +132 -26
- package/dist/errors.js +134 -23
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js.map +1 -1
- package/dist/models.d.ts +47 -8
- package/dist/product-models.d.ts +4 -15
- package/dist/runs.d.ts +22 -8
- package/dist/runs.js +4 -3
- package/dist/runs.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/architecture.md +5 -4
- package/docs/artifact-download.md +1 -1
- package/docs/errors.md +143 -0
- package/docs/run-results.md +3 -1
- package/package.json +2 -2
package/dist/errors.js
CHANGED
|
@@ -227,19 +227,37 @@ export class PipelineExecuteTimeoutError extends PipelineRequestError {
|
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
/**
|
|
230
|
-
* Thrown when a run reaches a terminal state that is not `COMPLETED`
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
230
|
+
* Thrown when a run reaches a terminal state that is not `COMPLETED` (`FAILED`, `CANCELLED`,
|
|
231
|
+
* `TERMINATED`, `TIMED_OUT`) — by `waitForResult`, `startAndWaitForResult` and the artifact
|
|
232
|
+
* download when the platform answers the results read with HTTP 409. (`getRunResult` returns
|
|
233
|
+
* the same facts as its `failed` arm instead of throwing.)
|
|
234
|
+
*
|
|
235
|
+
* - `status` is the run's terminal status, read from the problem's `run_status` member, or from
|
|
236
|
+
* its `detail` sentence on a platform that predates the member.
|
|
237
|
+
* - `error` is the run's stored error report, typed whole as `RunErrorReport`: the runner's
|
|
238
|
+
* `error_type`, `message`, `title`, `type_uri`, `error_domain`, `error_category`,
|
|
239
|
+
* `retryable`, `user_action`, `model`, `provider`, `provider_metadata`, `validation_errors`
|
|
240
|
+
* and anything newer through its index signature. Branch on `error.error_domain`,
|
|
241
|
+
* `error.type_uri` and `error.retryable`; show `error.user_action` as the next step. It is
|
|
242
|
+
* the runner's VERBOSE report, so `message` and `provider_metadata` can hold a provider's raw
|
|
243
|
+
* text — deciding what a person sees is the consumer's. `null` when the run ended with no
|
|
244
|
+
* stored report (a cancelled, terminated or timed-out run, or one the platform finalized
|
|
245
|
+
* itself).
|
|
246
|
+
* - The error's own `message` is the problem's `detail`, which names the status and then the
|
|
247
|
+
* report's message (`Run finished with status FAILED: <message>`), so printing the error
|
|
248
|
+
* already tells the reason.
|
|
249
|
+
* - `runId` locates the run, for a status read or a support request.
|
|
234
250
|
*/
|
|
235
251
|
export class RunFailedError extends PipelineRequestError {
|
|
236
252
|
runId;
|
|
237
253
|
status;
|
|
254
|
+
error;
|
|
238
255
|
constructor(message, runId, status, options) {
|
|
239
|
-
super(message, options);
|
|
256
|
+
super(message, options?.cause === undefined ? undefined : { cause: options.cause });
|
|
240
257
|
this.name = "RunFailedError";
|
|
241
258
|
this.runId = runId;
|
|
242
259
|
this.status = status;
|
|
260
|
+
this.error = options?.error ?? null;
|
|
243
261
|
}
|
|
244
262
|
}
|
|
245
263
|
/**
|
|
@@ -315,15 +333,36 @@ export class RunLifecycleUnavailableError extends PipelineRequestError {
|
|
|
315
333
|
}
|
|
316
334
|
}
|
|
317
335
|
/**
|
|
318
|
-
* A non-2xx response that DID come back from the API
|
|
319
|
-
*
|
|
320
|
-
*
|
|
336
|
+
* A non-2xx response that DID come back from the API, with its problem document parsed.
|
|
337
|
+
*
|
|
338
|
+
* Every error the hosted API answers is an RFC 9457 `application/problem+json` document, and
|
|
339
|
+
* this error carries its members as typed fields, each `undefined` when the document did not
|
|
340
|
+
* carry it (a member of the wrong type reads as absent rather than as a wrong value):
|
|
321
341
|
*
|
|
322
|
-
* `
|
|
323
|
-
* (`
|
|
324
|
-
*
|
|
325
|
-
* the HTTP status
|
|
326
|
-
*
|
|
342
|
+
* - **The branch fields.** `errorDomain` says who can fix the failure — `input` (the caller),
|
|
343
|
+
* `config` (a configuration change), `runtime` (nobody beforehand) — and `type` is the stable
|
|
344
|
+
* URI naming the error class. `retryable` says whether a retry can succeed, `undefined`
|
|
345
|
+
* meaning unknown. Branch on these, never on the HTTP status or on the wording of a message.
|
|
346
|
+
* - **The native codes.** `code` is the platform's own closed code (`conflict`, `not_found`,
|
|
347
|
+
* `pipelex_api_key_limit_reached`, …) and `errorType` the runner's open exception class
|
|
348
|
+
* name. Each is finer than `errorDomain` and specific to the surface that emits it; the
|
|
349
|
+
* platform's `type` is one-to-one with its `code` (`https://pipelex.com/errors/<code>`).
|
|
350
|
+
* - **For a person.** `title` is the stable label of the error class, `serverMessage` the
|
|
351
|
+
* per-occurrence `detail`, `userAction` the advised next step, and `errorCategory`, `model`,
|
|
352
|
+
* `provider` and `providerMetadata` describe an inference failure.
|
|
353
|
+
* - **For support.** `requestId` correlates the response with the server's logs; it is read
|
|
354
|
+
* from the body, or from the `X-Request-ID` response header when the body has none.
|
|
355
|
+
* `instance` is the occurrence's URN or request path.
|
|
356
|
+
* - **Per-item failures.** `errors` is the platform's field-level list (`field`, `code`,
|
|
357
|
+
* `detail`), and `validationErrors` the structured diagnostics of a bundle that failed
|
|
358
|
+
* validation.
|
|
359
|
+
*
|
|
360
|
+
* `problemDocument` is the decoded document whole, so a member this SDK does not name stays
|
|
361
|
+
* reachable without re-parsing `responseBody`, which is the raw text; it is `undefined` when
|
|
362
|
+
* the body was not a JSON object. The members `mthds`'s own `ApiResponseError` carries have the
|
|
363
|
+
* same names and types here, and the rest (`code`, `errorCategory`, `model`, `provider`,
|
|
364
|
+
* `providerMetadata`, `migration`, `errors`) are the Pipelex members the standard's client
|
|
365
|
+
* leaves to this SDK.
|
|
327
366
|
*/
|
|
328
367
|
export class ApiResponseError extends PipelineRequestError {
|
|
329
368
|
apiUrl;
|
|
@@ -332,23 +371,80 @@ export class ApiResponseError extends PipelineRequestError {
|
|
|
332
371
|
responseBody;
|
|
333
372
|
errorType;
|
|
334
373
|
serverMessage;
|
|
374
|
+
/**
|
|
375
|
+
* The platform's native code — a closed set (`conflict`, `not_found`, `run_not_found`,
|
|
376
|
+
* `pipelex_api_key_limit_reached`, …), one-to-one with `type`. Finer than `errorDomain` and
|
|
377
|
+
* specific to the platform: a runner's problem carries `errorType` instead. `undefined` for a
|
|
378
|
+
* body that carries no `code`.
|
|
379
|
+
*/
|
|
335
380
|
code;
|
|
381
|
+
/**
|
|
382
|
+
* RFC 9457 `type`: the stable URI naming the error class. With `errorDomain`, the field a
|
|
383
|
+
* machine consumer branches on — the same class carries the same URI on every occurrence.
|
|
384
|
+
*/
|
|
385
|
+
type;
|
|
386
|
+
/** RFC 9457 `title`: the short human label of the error class. */
|
|
387
|
+
title;
|
|
388
|
+
/** RFC 9457 `instance`: the occurrence — the request path, or a request URN. */
|
|
389
|
+
instance;
|
|
390
|
+
/**
|
|
391
|
+
* The request's correlation id — the body's `request_id`, or the `X-Request-ID` response
|
|
392
|
+
* header when the body carries none. The id to hand to support: it finds the server's log
|
|
393
|
+
* lines for this request.
|
|
394
|
+
*/
|
|
395
|
+
requestId;
|
|
396
|
+
/**
|
|
397
|
+
* The body's `error_domain`: who can fix the failure. `input` — the caller (a malformed
|
|
398
|
+
* bundle, a bad argument, a missing input); `config` — a configuration change (a missing
|
|
399
|
+
* secret, a model the backend does not serve); `runtime` — nobody beforehand (a provider
|
|
400
|
+
* outage during execution). Typed open, as the server owns the vocabulary; `undefined` when
|
|
401
|
+
* the server did not classify it.
|
|
402
|
+
*/
|
|
403
|
+
errorDomain;
|
|
404
|
+
/**
|
|
405
|
+
* The body's `error_category`: the finer classification of an inference failure — known
|
|
406
|
+
* values `transient`, `configuration`, `content`, `capacity`, `ambiguous`, `unknown`.
|
|
407
|
+
*/
|
|
408
|
+
errorCategory;
|
|
409
|
+
/**
|
|
410
|
+
* The body's `retryable`: whether retrying the same request can plausibly succeed.
|
|
411
|
+
* `undefined` means unknown, which is not the same as `false`.
|
|
412
|
+
*/
|
|
413
|
+
retryable;
|
|
414
|
+
/** The body's `user_action`: what the caller should do next, when the server can say. */
|
|
415
|
+
userAction;
|
|
416
|
+
/** The body's `model`: the model an inference failure used. */
|
|
417
|
+
model;
|
|
418
|
+
/** The body's `provider`: the provider an inference failure reached. */
|
|
419
|
+
provider;
|
|
420
|
+
/** The body's `provider_metadata`: what the provider's SDK said, raw text included. */
|
|
421
|
+
providerMetadata;
|
|
422
|
+
/** The body's `migration`: a pending configuration migration that explains the failure. */
|
|
423
|
+
migration;
|
|
424
|
+
/** The platform's field-level `errors[]` — one item per offending request field. */
|
|
425
|
+
errors;
|
|
426
|
+
/**
|
|
427
|
+
* The decoded problem document whole — every member, named or not, such as a failed run's
|
|
428
|
+
* `run_status` and `error` or a member a newer server adds. `undefined` when the body was not
|
|
429
|
+
* a JSON object.
|
|
430
|
+
*/
|
|
431
|
+
problemDocument;
|
|
336
432
|
/**
|
|
337
433
|
* Structured per-error diagnostics on a problem body that carries a top-level
|
|
338
|
-
* `validation_errors[]` — the **
|
|
339
|
-
*
|
|
434
|
+
* `validation_errors[]` — the 422 a **run route** (`execute`, `start`) answers when the
|
|
435
|
+
* runner refuses the method for its validation errors.
|
|
340
436
|
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
* per-error list (auth, transport, a request-shape 422
|
|
346
|
-
* assume a given `error_type` implies a
|
|
347
|
-
* `serverMessage` when this is empty.
|
|
437
|
+
* Everywhere else an invalid bundle is a produced verdict, not an `ApiResponseError`:
|
|
438
|
+
* `POST /v1/validate` answers it with a **200** `PipelexInvalidReport`, and the build
|
|
439
|
+
* and crate routes with a **200** `CrateInvalidReport`, whose `validation_errors[]` the
|
|
440
|
+
* caller reads off the returned value. This field is `undefined` for any error that
|
|
441
|
+
* carries no per-error list (auth, transport, a request-shape 422, a build route's 422
|
|
442
|
+
* for a pipe it cannot build). A consumer must NOT assume a given `error_type` implies a
|
|
443
|
+
* populated list — fall back to `serverMessage` when this is empty.
|
|
348
444
|
*/
|
|
349
445
|
validationErrors;
|
|
350
446
|
constructor(message, apiUrl, status, statusText, responseBody, errorType, serverMessage, validationErrors, code, options) {
|
|
351
|
-
super(message, options);
|
|
447
|
+
super(message, options?.cause === undefined ? undefined : { cause: options.cause });
|
|
352
448
|
this.name = "ApiResponseError";
|
|
353
449
|
this.apiUrl = apiUrl;
|
|
354
450
|
this.status = status;
|
|
@@ -358,6 +454,21 @@ export class ApiResponseError extends PipelineRequestError {
|
|
|
358
454
|
this.serverMessage = serverMessage;
|
|
359
455
|
this.validationErrors = validationErrors;
|
|
360
456
|
this.code = code;
|
|
457
|
+
const problem = options?.problem;
|
|
458
|
+
this.type = problem?.type;
|
|
459
|
+
this.title = problem?.title;
|
|
460
|
+
this.instance = problem?.instance;
|
|
461
|
+
this.requestId = problem?.requestId;
|
|
462
|
+
this.errorDomain = problem?.errorDomain;
|
|
463
|
+
this.errorCategory = problem?.errorCategory;
|
|
464
|
+
this.retryable = problem?.retryable;
|
|
465
|
+
this.userAction = problem?.userAction;
|
|
466
|
+
this.model = problem?.model;
|
|
467
|
+
this.provider = problem?.provider;
|
|
468
|
+
this.providerMetadata = problem?.providerMetadata;
|
|
469
|
+
this.migration = problem?.migration;
|
|
470
|
+
this.errors = problem?.errors;
|
|
471
|
+
this.problemDocument = options?.problemDocument;
|
|
361
472
|
}
|
|
362
473
|
}
|
|
363
474
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;
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js";
|
|
|
20
20
|
export type { PrepareInputsBase, PrepareInputsClosure, PrepareInputsRequest, PreparedInputs, } from "./prepare-inputs.js";
|
|
21
21
|
export { locateArtifacts, collectArtifacts, artifactFilename, PIPELEX_STORAGE_SCHEME, BULK_RESOLVE_MAX_URIS, DEFAULT_ARTIFACT_MAX_BYTES, DEFAULT_ARTIFACT_TIMEOUT_MS, DEFAULT_DOWNLOAD_MAX_TOTAL_BYTES, DEFAULT_DOWNLOAD_CONCURRENCY, } from "./artifacts.js";
|
|
22
22
|
export type { ArtifactItemError, ArtifactLocation, ArtifactScope, BulkResolveStorageUrlsInput, BulkResolvedStorageUrls, DownloadArtifactsOptions, DownloadArtifactsRequest, DownloadArtifactsResult, DownloadedArtifact, FetchArtifactOptions, ResolvedArtifact, } from "./artifacts.js";
|
|
23
|
-
export type { DiagnosticKind, DiagnosticRange, Diagnostic, LintResponse, FormatResponse, DictStuff, DictWorkingMemory, DictPipeOutput, DictRunResultExecute, MethodProvenance, PipelexRunResultStart, PipelexHostedToolingExtensions, DryRunStatus, ValidatedPipeEntry, LiftablePipeEntry, PipelexValidationReport, PipelexInvalidReport, PipelexValidationResult, ValidationErrorCategory, ValidationErrorItem, FixSafety, FixOpKind, TomlScalar, TomlValue, SetKeyOp, EnsureTableOp, DeleteKeyOp, DeleteTableOp, RenameTableKeyOp, MoveKeyOp, RemapValueOp, FixOp, SuggestedFix, ConceptRepresentationFormat, InputsTemplateFormat, MthdsFileItem, CrateRequestBase, BuildRequestBase, BuildInputsRequest, BuildOutputRequest, BuildRunnerRequest, ConceptRequest, PipeSpecRequest, CrateInvalidReport, BuildInputsValidReport, BuildOutputValidReport, BuildRunnerValidReport, GeneratedArtifact, RunnerStructures, BuildInputsResponse, BuildOutputResponse, BuildRunnerResponse, ConceptResponse, PipeSpecResponse, ResolveRequest, ResolveValidReport, ResolveResponse, CodegenKind, CodegenTarget, CodegenRequest, CodegenValidReport, CodegenResponse, } from "./models.js";
|
|
23
|
+
export type { DiagnosticKind, DiagnosticRange, Diagnostic, LintResponse, FormatResponse, DictStuff, DictWorkingMemory, DictPipeOutput, DictRunResultExecute, MethodProvenance, PipelexRunResultStart, PipelexHostedToolingExtensions, DryRunStatus, ValidatedPipeEntry, LiftablePipeEntry, PipelexValidationReport, PipelexInvalidReport, PipelexValidationResult, ValidationErrorCategory, ValidationErrorItem, FixSafety, FixOpKind, TomlScalar, TomlValue, FixValue, SetKeyOp, EnsureTableOp, DeleteKeyOp, DeleteTableOp, RenameTableKeyOp, MoveKeyOp, RemapValueOp, FixOp, SuggestedFix, ConceptRepresentationFormat, InputsTemplateFormat, MthdsFileItem, CrateRequestBase, BuildRequestBase, BuildInputsRequest, BuildOutputRequest, BuildRunnerRequest, ConceptRequest, PipeSpecRequest, CrateInvalidReport, BuildInputsValidReport, BuildOutputValidReport, BuildRunnerValidReport, GeneratedArtifact, RunnerStructures, BuildInputsResponse, BuildOutputResponse, BuildRunnerResponse, ConceptResponse, PipeSpecResponse, ResolveRequest, ResolveValidReport, ResolveResponse, CodegenKind, CodegenTarget, CodegenRequest, CodegenValidReport, CodegenResponse, } from "./models.js";
|
|
24
24
|
export { runCodegenCheck, isStampableArtifactPath, STAMPABLE_ARTIFACT_SUFFIXES, CodegenLockError, } from "./codegen-check.js";
|
|
25
25
|
export type { CodegenCheckInput, CodegenCheckReport, CodegenDrift, CodegenDriftCategory, CodegenTreeFile, } from "./codegen-check.js";
|
|
26
|
-
export type { UserProfile, ListMethodsQuery, MethodData, MethodDeletionAccepted, MethodDeletionState, MethodPage, MethodSummary, MethodWriteInput, Membership, MembershipsResponse, SubscriptionResponse, PlanView, InvoiceView, CheckoutResponse, ChangePlanResponse, BillingPortalResponse, PipelexApiKey, PipelexApiKeyCreated, PipelexApiKeyList, OnboardingRole, OnboardingCurrentTool, OnboardingInputType, OnboardingHeardFrom, OnboardingSubmission, ResolvedStorageUrl, UploadInput, UploadedFile, UploadGrantInput, UploadGrant, PipeStatus, ListRunsQuery, PipelineRun, RunDetail,
|
|
26
|
+
export type { UserProfile, ListMethodsQuery, MethodData, MethodDeletionAccepted, MethodDeletionState, MethodPage, MethodSummary, MethodWriteInput, Membership, MembershipsResponse, SubscriptionResponse, PlanView, InvoiceView, CheckoutResponse, ChangePlanResponse, BillingPortalResponse, PipelexApiKey, PipelexApiKeyCreated, PipelexApiKeyList, OnboardingRole, OnboardingCurrentTool, OnboardingInputType, OnboardingHeardFrom, OnboardingSubmission, ResolvedStorageUrl, UploadInput, UploadedFile, UploadGrantInput, UploadGrant, PipeStatus, ListRunsQuery, PipelineRun, RunDetail, RunPage, UpdateRunInput, } from "./product-models.js";
|
|
27
27
|
export { isTerminalRunStatus, isSuccessRunStatus } from "./runs.js";
|
|
28
28
|
export type { RunStatus, RunPublic, RunRead, RunResults, RunResultState, TokensUsageRecord, WaitForResultOptions, } from "./runs.js";
|
|
29
29
|
export { summarizeUsage } from "./usage.js";
|
|
30
30
|
export type { PipeUsageSummary, RunUsagePair, UsageSummary, UsageSummaryState, UsageTokenTotals, } from "./usage.js";
|
|
31
31
|
export { ApiResponseError, ApiUnreachableError, ClientAuthenticationError, MissingMainStuffError, PipelineExecuteTimeoutError, RunFailedError, RunTimeoutError, RunStillRunningError, RunLifecycleUnavailableError, InputPreparationError, EmptyMethodSourceError, InvalidLocalSourceError, RejectedAssetError, UnsupportedUploadCapabilityError, UploadAuthenticationError, UploadTransportError, ArtifactOperationError, ArtifactAuthenticationError, ArtifactFetchError, ScopeUnavailableError, } from "./errors.js";
|
|
32
|
-
export type { RejectedAssetCode, UploadTransportCode } from "./errors.js";
|
|
32
|
+
export type { ApiResponseErrorOptions, RejectedAssetCode, UploadTransportCode } from "./errors.js";
|
|
33
|
+
export type { FieldError, MigrationErrorBlock, ProblemDetails, ProviderErrorMetadata, RunErrorReport, UserAction, } from "./error-models.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings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EAAsE;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AASpD,uEAAuE;AACvE,wFAAwF;AACxF,0FAA0F;AAC1F,iFAAiF;AACjF,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,0BAA0B,EAC1B,2BAA2B,EAC3B,gCAAgC,EAChC,4BAA4B,GAC7B,MAAM,gBAAgB,CAAC;AAkFxB,+EAA+E;AAC/E,4EAA4E;AAC5E,iFAAiF;AACjF,0EAA0E;AAC1E,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,2BAA2B,EAC3B,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAgD5B,wEAAwE;AACxE,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAWpE,oFAAoF;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAS5C,+EAA+E;AAC/E,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EACzB,qBAAqB,EACrB,2BAA2B,EAC3B,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,4BAA4B,EAC5B,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,gCAAgC,EAChC,yBAAyB,EACzB,oBAAoB,EACpB,sBAAsB,EACtB,2BAA2B,EAC3B,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,aAAa,CAAC"}
|
package/dist/models.d.ts
CHANGED
|
@@ -271,19 +271,35 @@ export type ValidationErrorCategory = "blueprint_validation" | "pipe_factory" |
|
|
|
271
271
|
* One structured bundle-validation error — mirror of pipelex's `ValidationErrorItem`.
|
|
272
272
|
* Carried by `PipelexInvalidReport.validation_errors[]` on the **200** invalid arm of
|
|
273
273
|
* `POST /v1/validate` (NOT a 422 — an invalid bundle is a produced verdict), by the
|
|
274
|
-
* VALID arm's advisory `warnings[]`,
|
|
275
|
-
* (`
|
|
274
|
+
* VALID arm's advisory `warnings[]`, by the build and crate routes' **200** invalid arm
|
|
275
|
+
* (`CrateInvalidReport.validation_errors[]`), by the 422 problem body a run route answers
|
|
276
|
+
* when the runner refuses the method for its validation errors
|
|
277
|
+
* (`ApiResponseError.validationErrors`), and by a failed run's stored report.
|
|
278
|
+
*
|
|
279
|
+
* **The shape is `mthds`'s.** The standard's client declares the same item, member for
|
|
280
|
+
* member under the same names, and a consumer reads one vocabulary whichever client
|
|
281
|
+
* handed it the item. It is restated here rather than imported because `mthds` exports it
|
|
282
|
+
* only from its package root, which this SDK does not import (it takes `mthds` through
|
|
283
|
+
* `mthds/protocol` alone, the rule `.dependency-cruiser.cjs` enforces); a type-level test
|
|
284
|
+
* (`tests/validation-items.test.ts`) pins this declaration and `SuggestedFix`'s to the
|
|
285
|
+
* standard's, so a member added on one side and not the other fails the typecheck.
|
|
276
286
|
*
|
|
277
287
|
* Only `category` and `message` are always present; the rest are populated per
|
|
278
|
-
* `category`. Every other member is `?: T | null`
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
288
|
+
* `category`. Every other member is `?: T | null` — the one way this declaration
|
|
289
|
+
* differs from `mthds`'s — because the two channels serialize an unset locator
|
|
290
|
+
* differently: the invalid arm and the crate routes drop the key (`exclude_none`
|
|
291
|
+
* server-side) while the valid arm — which carries `warnings[]` — does not, so the same
|
|
292
|
+
* item arrives with explicit `null`s there. A truthiness check reads both; an
|
|
293
|
+
* `=== undefined` check would be wrong on one of them.
|
|
283
294
|
*
|
|
284
295
|
* `source` is the declaring file path (CLI) or the per-content `mthds_sources` name
|
|
285
296
|
* the API threads onto the in-memory load path — the owning file for cross-file
|
|
286
297
|
* diagnostics.
|
|
298
|
+
*
|
|
299
|
+
* An `unknown_model` item (a model reference the runner's model deck does not know)
|
|
300
|
+
* carries the reference as written, the kind of model the field takes and the close
|
|
301
|
+
* matches, and, when there is exactly one close match, a `suggested_fix` that remaps
|
|
302
|
+
* the reference to it.
|
|
287
303
|
*/
|
|
288
304
|
export interface ValidationErrorItem {
|
|
289
305
|
category: ValidationErrorCategory;
|
|
@@ -297,8 +313,21 @@ export interface ValidationErrorItem {
|
|
|
297
313
|
field_name?: string | null;
|
|
298
314
|
variable_names?: string[] | null;
|
|
299
315
|
missing_concept_code?: string | null;
|
|
316
|
+
/** The pipe a reference names that the bundle does not declare. */
|
|
300
317
|
missing_pipe_code?: string | null;
|
|
301
318
|
declared_concepts?: string[] | null;
|
|
319
|
+
/**
|
|
320
|
+
* On an `unknown_model` item: the model reference exactly as the author wrote it
|
|
321
|
+
* (`gpt-5.1`, `@best-sonet`, `$writting-factual`).
|
|
322
|
+
*/
|
|
323
|
+
model_reference?: string | null;
|
|
324
|
+
/** On an `unknown_model` item: the kind of model the field takes (`llm`, `img_gen`, …). */
|
|
325
|
+
model_type?: string | null;
|
|
326
|
+
/**
|
|
327
|
+
* On an `unknown_model` item: the close matches of the same kind, each spelled as a
|
|
328
|
+
* reference the field accepts.
|
|
329
|
+
*/
|
|
330
|
+
suggestions?: string[] | null;
|
|
302
331
|
/** The server's deterministic repair proposal for this error, when it has one. */
|
|
303
332
|
suggested_fix?: SuggestedFix | null;
|
|
304
333
|
}
|
|
@@ -314,6 +343,8 @@ export type TomlScalar = string | number | boolean;
|
|
|
314
343
|
* the server does not emit it.
|
|
315
344
|
*/
|
|
316
345
|
export type TomlValue = TomlScalar | Record<string, TomlScalar>;
|
|
346
|
+
/** `TomlValue` under the name `mthds` gives it, so either client's vocabulary reads here. */
|
|
347
|
+
export type FixValue = TomlValue;
|
|
317
348
|
/**
|
|
318
349
|
* What every fix op carries: the table it acts in. `table_path` addresses the containing
|
|
319
350
|
* table (e.g. `["pipe", "my_seq"]`), aligned with the `field_path` conventions of
|
|
@@ -358,7 +389,11 @@ export interface MoveKeyOp extends FixOpBase {
|
|
|
358
389
|
new_table_path: string[];
|
|
359
390
|
new_key: string;
|
|
360
391
|
}
|
|
361
|
-
/**
|
|
392
|
+
/**
|
|
393
|
+
* Rewrite `key`'s value through `mapping`, leaving an unmapped value untouched. The
|
|
394
|
+
* unknown-model fix is one: it maps the reference as written to its one close match, so
|
|
395
|
+
* it changes nothing once the author has edited the field.
|
|
396
|
+
*/
|
|
362
397
|
export interface RemapValueOp extends FixOpBase {
|
|
363
398
|
kind: "remap_value";
|
|
364
399
|
key: string;
|
|
@@ -370,6 +405,10 @@ export type FixOp = SetKeyOp | EnsureTableOp | DeleteKeyOp | DeleteTableOp | Ren
|
|
|
370
405
|
* A deterministic fix for one validation error, ready for a style-preserving applier —
|
|
371
406
|
* mirror of pipelex's `SuggestedFix`. The ops are semantic patches over the `.mthds`
|
|
372
407
|
* document, not a text diff, so an applier keeps the author's formatting.
|
|
408
|
+
*
|
|
409
|
+
* The shape is `mthds`'s `SuggestedFix`, its op vocabulary included (this SDK's
|
|
410
|
+
* `TomlValue` is the standard's `FixValue`), restated and pinned for the reason
|
|
411
|
+
* `ValidationErrorItem` gives; `source` alone is widened to `| null`.
|
|
373
412
|
*/
|
|
374
413
|
export interface SuggestedFix {
|
|
375
414
|
/** The kebab-case rule id, e.g. `"match-sequence-output"`. */
|
package/dist/product-models.d.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* consumes — not a speculative mirror of every server field.
|
|
11
11
|
*/
|
|
12
12
|
import type { MethodFile } from "mthds/protocol";
|
|
13
|
+
import type { RunErrorReport } from "./error-models.js";
|
|
13
14
|
import type { RunStatus } from "./runs.js";
|
|
14
15
|
export interface UserProfile {
|
|
15
16
|
email: string;
|
|
@@ -270,18 +271,6 @@ export interface UploadGrant {
|
|
|
270
271
|
}
|
|
271
272
|
/** Per-pipe progress marker surfaced in a run's `pipe_statuses` map. */
|
|
272
273
|
export type PipeStatus = "scheduled" | "running" | "succeeded" | "failed" | "skipped";
|
|
273
|
-
/**
|
|
274
|
-
* The runner's structured failure report, as stored on a terminal-failed run.
|
|
275
|
-
*
|
|
276
|
-
* The wire payload carries the full VERBOSE `ErrorReport`; these are the two
|
|
277
|
-
* fields a consumer can rely on. Optional throughout: the shape is owned by the
|
|
278
|
-
* runner, and a failure whose callback carried no report has none of it.
|
|
279
|
-
*/
|
|
280
|
-
export interface RunErrorReport {
|
|
281
|
-
message?: string;
|
|
282
|
-
error_type?: string;
|
|
283
|
-
[key: string]: unknown;
|
|
284
|
-
}
|
|
285
274
|
export interface PipelineRun {
|
|
286
275
|
pipeline_run_id: string;
|
|
287
276
|
/** `null` on an ad-hoc run — one started from an inline bundle belongs to no
|
|
@@ -300,9 +289,9 @@ export interface PipelineRun {
|
|
|
300
289
|
pipe_statuses?: Record<string, PipeStatus> | null;
|
|
301
290
|
created_at: string;
|
|
302
291
|
finished_at?: string | null;
|
|
303
|
-
/**
|
|
304
|
-
* This is how a consumer tells the user
|
|
305
|
-
* a generic message. */
|
|
292
|
+
/** The runner's stored error report, typed whole — present only on a failed run
|
|
293
|
+
* whose completion callback carried one. This is how a consumer tells the user
|
|
294
|
+
* WHY a run failed rather than showing a generic message. */
|
|
306
295
|
error?: RunErrorReport | null;
|
|
307
296
|
}
|
|
308
297
|
/**
|
package/dist/runs.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { InputForm, OutputForm, PipeIOContracts } from "mthds/protocol";
|
|
2
|
+
import type { RunErrorReport } from "./error-models.js";
|
|
2
3
|
import type { DictPipeOutput, DictWorkingMemory } from "./models.js";
|
|
3
4
|
/**
|
|
4
5
|
* Run-lifecycle types + polling for the hosted polling surface (`/v1/runs/*`).
|
|
@@ -32,11 +33,11 @@ export declare function isSuccessRunStatus(status: RunStatus): boolean;
|
|
|
32
33
|
/**
|
|
33
34
|
* A run record — the BASE shape of the run-lifecycle read surface.
|
|
34
35
|
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* signature keeps them accessible, mirroring the
|
|
39
|
-
* passthrough.
|
|
36
|
+
* The base fields are declared, and so is `error`, the stored report of a failed run, which
|
|
37
|
+
* is how a caller learns why a run failed. An implementation may return more (identity,
|
|
38
|
+
* workflow ids, storage URLs, anything else) — those are server-specific response fields,
|
|
39
|
+
* not named in this SDK; the index signature keeps them accessible, mirroring the
|
|
40
|
+
* request-side `extra` passthrough.
|
|
40
41
|
*/
|
|
41
42
|
export interface RunPublic {
|
|
42
43
|
pipeline_run_id: string;
|
|
@@ -44,6 +45,14 @@ export interface RunPublic {
|
|
|
44
45
|
status: RunStatus;
|
|
45
46
|
created_at: string;
|
|
46
47
|
finished_at?: string | null;
|
|
48
|
+
/**
|
|
49
|
+
* Why the run failed: the runner's stored error report, typed whole (see `RunErrorReport`).
|
|
50
|
+
* `null` on a completed run and on a run that ended without a report — a cancelled,
|
|
51
|
+
* terminated or timed-out run, or one the platform finalized itself; absent on a server that
|
|
52
|
+
* does not serve it. The results read of the same run carries the same object in its `409`,
|
|
53
|
+
* which is where `getRunResult`'s failed arm and `RunFailedError` take it from.
|
|
54
|
+
*/
|
|
55
|
+
error?: RunErrorReport | null;
|
|
47
56
|
/** Server-specific response fields (defined by the server you call). */
|
|
48
57
|
[extension: string]: unknown;
|
|
49
58
|
}
|
|
@@ -236,7 +245,10 @@ export interface RunResults {
|
|
|
236
245
|
* Single-shot result lookup outcome, discriminated on `state`:
|
|
237
246
|
* - `running` — HTTP 202; poll again after `retry_after_seconds`.
|
|
238
247
|
* - `completed` — HTTP 200; `result` carries the artifacts.
|
|
239
|
-
* - `failed` — HTTP 409; run reached a terminal non-`COMPLETED` status.
|
|
248
|
+
* - `failed` — HTTP 409; run reached a terminal non-`COMPLETED` status. `status` is the
|
|
249
|
+
* problem's `run_status` member (recovered from `detail` on a platform that predates it),
|
|
250
|
+
* `message` its `detail` (`Run finished with status FAILED: <the report's message>`), and
|
|
251
|
+
* `error` the run's stored error report, typed, or `null` when the run ended without one.
|
|
240
252
|
*/
|
|
241
253
|
export type RunResultState = {
|
|
242
254
|
state: "running";
|
|
@@ -251,6 +263,7 @@ export type RunResultState = {
|
|
|
251
263
|
pipeline_run_id: string;
|
|
252
264
|
status: RunStatus;
|
|
253
265
|
message: string;
|
|
266
|
+
error: RunErrorReport | null;
|
|
254
267
|
};
|
|
255
268
|
export interface WaitForResultOptions {
|
|
256
269
|
/**
|
|
@@ -286,8 +299,9 @@ export declare function assertWaitOptions(options?: WaitForResultOptions): void;
|
|
|
286
299
|
/**
|
|
287
300
|
* Poll a single-shot result lookup (`fetchOnce`) until the run reaches a
|
|
288
301
|
* terminal state. Returns the artifacts on `COMPLETED`, throws `RunFailedError`
|
|
289
|
-
* on any other terminal status
|
|
290
|
-
*
|
|
302
|
+
* on any other terminal status — carrying the run's status and its stored error
|
|
303
|
+
* report — and throws `RunTimeoutError` if `timeoutMs` elapses first (the run
|
|
304
|
+
* keeps executing server-side — re-poll by id later).
|
|
291
305
|
*
|
|
292
306
|
* The single owner of the wait/poll/Retry-After/abort logic — `PipelexApiClient.waitForResult`
|
|
293
307
|
* delegates here, so the behavior can never drift.
|
package/dist/runs.js
CHANGED
|
@@ -33,8 +33,9 @@ export function assertWaitOptions(options = {}) {
|
|
|
33
33
|
/**
|
|
34
34
|
* Poll a single-shot result lookup (`fetchOnce`) until the run reaches a
|
|
35
35
|
* terminal state. Returns the artifacts on `COMPLETED`, throws `RunFailedError`
|
|
36
|
-
* on any other terminal status
|
|
37
|
-
*
|
|
36
|
+
* on any other terminal status — carrying the run's status and its stored error
|
|
37
|
+
* report — and throws `RunTimeoutError` if `timeoutMs` elapses first (the run
|
|
38
|
+
* keeps executing server-side — re-poll by id later).
|
|
38
39
|
*
|
|
39
40
|
* The single owner of the wait/poll/Retry-After/abort logic — `PipelexApiClient.waitForResult`
|
|
40
41
|
* delegates here, so the behavior can never drift.
|
|
@@ -59,7 +60,7 @@ export async function pollUntilResult(fetchOnce, runId, options = {}) {
|
|
|
59
60
|
return state.result;
|
|
60
61
|
}
|
|
61
62
|
if (state.state === "failed") {
|
|
62
|
-
throw new RunFailedError(state.message, runId, state.status);
|
|
63
|
+
throw new RunFailedError(state.message, runId, state.status, { error: state.error });
|
|
63
64
|
}
|
|
64
65
|
attempt += 1;
|
|
65
66
|
options.onPoll?.({ attempt, elapsedMs });
|
package/dist/runs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runs.js","sourceRoot":"","sources":["../src/runs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"runs.js","sourceRoot":"","sources":["../src/runs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAyCjD,MAAM,qBAAqB,GAA2B,IAAI,GAAG,CAAY;IACvE,WAAW;IACX,QAAQ;IACR,WAAW;IACX,YAAY;IACZ,WAAW;CACZ,CAAC,CAAC;AAEH,6EAA6E;AAC7E,MAAM,UAAU,mBAAmB,CAAC,MAAiB;IACnD,OAAO,qBAAqB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAC3C,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,kBAAkB,CAAC,MAAiB;IAClD,OAAO,MAAM,KAAK,WAAW,CAAC;AAChC,CAAC;AAkQD,uEAAuE;AAEvE,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAC9C,MAAM,CAAC,MAAM,uBAAuB,GAAG,SAAS,CAAC,CAAC,0DAA0D;AAQ5G;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAgC,EAAE;IAClE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC1C,IAAI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;QAC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ACpF,iEAAiE;QACjE,MAAM,KAAK,GAAG,UAAU,CACtB,GAAG,EAAE;YACH,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC9C,OAAO,EAAE,CAAC;QACZ,CAAC,EACD,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,kBAAkB,CAAC,CACjC,CAAC;QACF,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,YAAY,CAAC,KAAK,CAAC,CAAC;gBACpB,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC3B,OAAO;YACT,CAAC;YACD,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/docs/architecture.md
CHANGED
|
@@ -82,8 +82,9 @@ A run request carries its method inline exactly one of three ways: `mthds_conten
|
|
|
82
82
|
Flat `src/` (mirrors `mthds-js`'s `runners/api` flatness — the SDK has one client, so no runner/registry abstraction):
|
|
83
83
|
|
|
84
84
|
- `client.ts` — `PipelexApiClient`: the `request()` pipeline (auth, base URL, timeouts/abort, problem-details parsing) and every route. `implements MTHDSProtocol<DictPipeOutput>` so the protocol-execution methods stay shaped like the standard.
|
|
85
|
-
- `models.ts` — Dict-serialized concretes (`DictStuff` / `DictWorkingMemory` / `DictPipeOutput` / `DictRunResultExecute`), the `/v1/validate` surface (`PipelexValidationResult`, `ValidationErrorItem`, and the `SuggestedFix` / `FixOp` repair vocabulary its items carry), the tools surface (`Diagnostic` / `LintResponse` / `FormatResponse`), and the crate-family request/response models — the shared `CrateRequestBase` / `CrateInvalidReport` / `GeneratedArtifact` vocabulary plus the `/v1/build/*`, `/v1/resolve` and `/v1/codegen` shapes built on it.
|
|
85
|
+
- `models.ts` — Dict-serialized concretes (`DictStuff` / `DictWorkingMemory` / `DictPipeOutput` / `DictRunResultExecute`), the `/v1/validate` surface (`PipelexValidationResult`, `ValidationErrorItem`, and the `SuggestedFix` / `FixOp` repair vocabulary its items carry — the standard's declarations, restated because `mthds` exports them only from its package root and pinned to it by a type-level test, see [errors.md](./errors.md#a-validation-item--validationerroritem)), the tools surface (`Diagnostic` / `LintResponse` / `FormatResponse`), and the crate-family request/response models — the shared `CrateRequestBase` / `CrateInvalidReport` / `GeneratedArtifact` vocabulary plus the `/v1/build/*`, `/v1/resolve` and `/v1/codegen` shapes built on it.
|
|
86
86
|
- `product-models.ts` — the snake_case wire shapes for the hosted-product management routes (profile, methods catalog, organizations, billing, API keys, onboarding, storage, runs list/detail/update). Each interface models only the fields the product actually consumes — no speculative mirrors.
|
|
87
|
+
- `error-models.ts` — the error-report wire models: `RunErrorReport`, the runner's `ErrorReport` typed with every field it carries (with `UserAction`, `ProviderErrorMetadata` and `MigrationErrorBlock`), which is the one type for a failed run's report on `RunPublic.error`, `PipelineRun.error`, the failed arm of `RunResultState` and `RunFailedError.error`; and `ProblemDetails` / `FieldError`, the typed members of a problem document that `ApiResponseError` exposes. Every field is optional and every interface keeps an index signature, because the runner owns the shape and adds fields without asking. Types only: it imports the `ValidationErrorItem` type and nothing else. See [errors.md](./errors.md).
|
|
87
88
|
- `method-source.ts` — `methodSourceToContents`, the canonical parser turning a stored method's polymorphic `mthds` source (raw single-bundle text XOR a JSON `{name, content}[]` file array) into a flat list of file contents. A verbatim port of the platform's `_method_source_to_contents` so the SDK and runtime read a stored source identically; exported from the barrel and consumed by `getMethodClosure`. See [input-preparation.md](./input-preparation.md#getmethodclosure--the-explicit-expansion-utility).
|
|
88
89
|
- `codegen-check.ts` — `runCodegenCheck`, the **pure** offline drift check over a committed codegen tree: the stamp grammar, the `codegen.lock` parser, the hash, and the drift taxonomy, ported from pipelex's `codegen/check.py` so a verdict computed here equals the one `pipelex codegen check` computes over the same bytes (the drift `detail` sentences included, verbatim). It touches neither the client nor `mthds/protocol` — its only import is `smol-toml` — and it hashes through WebCrypto rather than `node:crypto` so it adds no Node builtin to the barrel's import graph (`upload.ts` still names `node:fs/promises`, so a browser-targeting bundler must mark `node:*` external). It raises `CodegenLockError`, which extends `Error` rather than the protocol base. No filesystem, no fetch, no API key — the caller walks its own tree and hands in the text. See [crate-routes.md](./crate-routes.md#the-offline-check--runcodegencheck).
|
|
89
90
|
- `upload-grant.ts` — `uploadWithGrant`, the sender of an upload grant (`requestUploadGrant`, `POST /v1/upload/grant`): the file as the raw body of a `PUT` to the grant's URL with its signed headers unchanged, redirects refused, the whole exchange bounded by a time limit scaled by the file's size unless the caller passes `timeoutMs`, only the first 16 KiB of storage's error body read, and storage's refusals mapped onto the input-preparation errors (`RejectedAssetError` with a `code` for a `4xx` such as the `412` of a used grant or the `403` of a signature mismatch, `UploadTransportError` with a `code` for the time limit running out, a `5xx`, storage's `RequestTimeout`, a `409` conflict, a redirect or no response). It is the browser-safe `@pipelex/sdk/upload` entry, so it imports the error classes, the timer bound in `timers.ts` and the wire types only, never the client. See [input-preparation.md](./input-preparation.md#uploading-with-a-grant--requestuploadgrant--uploadwithgrant).
|
|
@@ -91,7 +92,7 @@ Flat `src/` (mirrors `mthds-js`'s `runners/api` flatness — the SDK has one cli
|
|
|
91
92
|
- `runs.ts` — the run-lifecycle types (`RunStatus`, `RunRead`, `RunResults`, `RunResultState`) and the single poll loop (`pollUntilResult`). `RunResults.main_stuff` (the resolved main output content) is always present for a completed run: on the hosted path it is the `main_stuff.json` S3 artifact; on the bare-runner blocking path the SDK resolves it from the returned working memory via the response's `main_stuff_name`, so both paths deliver the same shape. Consumers read `main_stuff` directly. `working_memory` — every named stuff of the run, `{ root, aliases }`, typed `DictWorkingMemory` from `models.ts` — reads the same on both paths: the hosted path relays the `working_memory.json` artifact, and the blocking path lifts it off `pipe_output`, which still rides whole (blocking path only). `graph_spec` — the executed graph — also reaches the client on both paths: the hosted path relays the `graphspec.json` artifact, and the blocking path lifts it off `pipe_output` beside `graph_assembly_error`, the graph's twin of `usage_assembly_error`. That error field is declared ahead of the wire on the hosted side, where the platform's results body relays no such key and the field is therefore absent, reading `undefined` rather than `null`. A completed run that cannot deliver a main stuff throws `MissingMainStuffError`. `runs.ts` also owns `TokensUsageRecord` — one client-facing usage record per inference call, carried by `RunResults.tokens_usages` on both paths. That is a mirror of a wire contract this SDK does not own (inference accounting is a Pipelex runtime extension rather than part of the MTHDS standard): every field is optional and the interface carries an index signature so pre-contract artifacts (relayed verbatim, never migrated) still type-check. See [`run-usage.md`](./run-usage.md) for the field reference, the cost/null semantics, and the old-artifact rules, and [`run-results.md`](./run-results.md) for the field-by-field account of `RunResults` — the durable handle, the output and how to read it, the run's working memory, the executed graph and how to render or keep it, and the produced files with their short-lived links.
|
|
92
93
|
- `usage.ts` — `summarizeUsage`, the **pure** fold of a run's usage pair (`tokens_usages` / `usage_assembly_error`) into one `UsageSummary`: a `state` (`records`, `no_inference` or `unavailable`), the null-aware total cost with its `cost_partial` flag, the `input` and `output` token totals, the call count, the relayed assembly error, and a `by_pipe` rollup sorted by cost with the unattributed calls grouped under a `null` `pipe_code`. It applies the rules [`run-usage.md`](./run-usage.md#summarizing-a-run--summarizeusage) states, so that every consumer reads one computation rather than re-deriving those rules by hand. It imports types from `runs.ts` and nothing else: no client, no fetch, no `mthds/protocol`.
|
|
93
94
|
- `execute-result.ts` — `PipelexExecuteResult`, a `DictRunResultExecute` subtype that adds a resolved `.main_stuff` accessor (dug out of `pipe_output`'s working memory via the response's `main_stuff_name`, throwing `MissingMainStuffError` if unlocatable). `execute()` returns it, giving blocking and durable results the **same output accessor** — `result.main_stuff` — so callers never branch on which path ran. The neutral `mthds` wire model leaves `main_stuff_name` in its extension index signature; this Pipelex-branded subtype declares it as a typed field (Pipelex owns that concept). `resultsFromExecute` (the public lift from that result onto `RunResults`, in the same module) reads that accessor too, keeping the resolution single-sourced; the `executeBlocking` fallback is its only caller inside the SDK, and a consumer driving `execute()` directly calls it by name.
|
|
94
|
-
- `errors.ts` — the transport and run-lifecycle typed errors, the input-preparation family under `InputPreparationError`, and the artifact family under `ArtifactOperationError` (`ScopeUnavailableError`, `ArtifactFetchError`, `ArtifactAuthenticationError`, the last carrying the download verdict so far); all derive from the protocol-base `PipelineRequestError` (re-exported from `mthds/protocol`) except `ClientAuthenticationError`. It is not the whole error surface: `codegen-check.ts` exports `CodegenLockError`, which extends plain `Error` because nothing was requested over the wire.
|
|
95
|
+
- `errors.ts` — the transport and run-lifecycle typed errors, the input-preparation family under `InputPreparationError`, and the artifact family under `ArtifactOperationError` (`ScopeUnavailableError`, `ArtifactFetchError`, `ArtifactAuthenticationError`, the last carrying the download verdict so far); all derive from the protocol-base `PipelineRequestError` (re-exported from `mthds/protocol`) except `ClientAuthenticationError`. `ApiResponseError` carries every member of the problem document it was built from — the branch fields `errorDomain` and `type`, `retryable`, `userAction`, `requestId` (the body's, else the `X-Request-ID` header's), the native `code` and `errorType`, the platform's `errors[]`, the inference members, and the decoded document whole as `problemDocument`; its member names and types match `mthds`'s own `ApiResponseError` wherever the two overlap, which a type-level test pins because this package may not import `mthds/errors`. `RunFailedError` carries the run's `status` and its stored report as `error`. It is not the whole error surface: `codegen-check.ts` exports `CodegenLockError`, which extends plain `Error` because nothing was requested over the wire.
|
|
95
96
|
- `user-agent.ts` — client identification per the workspace spec `docs/specs/client-identification.md`: 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 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).
|
|
96
97
|
- `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.
|
|
97
98
|
- `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.
|
|
@@ -107,12 +108,12 @@ Flat `src/` (mirrors `mthds-js`'s `runners/api` flatness — the SDK has one cli
|
|
|
107
108
|
- **Build helpers (`/v1/build/*`):** `buildInputs`, `buildOutput`, `buildRunner`, `concept`, `pipeSpec`. The three projections share one closure envelope (`files: [{content, source?}]` XOR a `method_ref` — the address form server-resolved, the registry form still `501`) plus an optional **qualified** `pipe_ref` that defaults to the closure's `main_pipe`, and each returns a **discriminated 200 verdict** (`is_valid`) rather than a bare payload — same discipline as `validate`. The build routes take **no `method_id`** (`method_id?: never` on `BuildRequestBase`): the hosted tooling selector deliberately excludes them, so a stored method is expanded first with `getMethodClosure`. **Nothing inside this SDK calls them** — `prepareInputs` reads its signature from the input-form descriptor on the validate report — so they exist for external consumers only, and are retired with the rest of `/v1/build/*` once those consumers project the template client-side. See [build-routes.md](./build-routes.md).
|
|
108
109
|
- **Crate routes (`/v1/resolve`, `/v1/codegen`):** `resolve` emits the **normalized library crate** (the MTHDS standard's Library Crate Format, fingerprint riding inside the payload); `codegen` projects that crate through two explicit axes — `kind` (`types`) × `target` (`ts-zod` / `python-pydantic` / `python-structures`) — into stamped artifacts plus their `codegen.lock`. They share the build routes' closure envelope and its **discriminated 200 verdict** (`CrateInvalidReport` is literally the same invalid arm), and additionally take the hosted `method_id` (`PipelexHostedToolingExtensions`) as a third closure form under the strict three-way XOR — a pass-through the platform resolves, meaningless against a bare runner. Writing the artifacts and lock verbatim reproduces a local `pipelex codegen types` run byte-for-byte, so the offline `pipelex codegen check` passes — the SDK stays transport-only and does not write files. Verifying such a tree afterwards is `runCodegenCheck`, a standalone pure helper rather than a client method, because it needs no server at all. See [crate-routes.md](./crate-routes.md).
|
|
109
110
|
- **Tools (`/v1/lint`, `/v1/format`):** `lint`, `format` — single-file static diagnostics and canonical formatting, served by any pipelex-api runner (no inference, no bundle load). Both are **diagnostic endpoints** like `validate`: a malformed `.mthds` file is a produced verdict on a **200** carrying `diagnostics[]`, never a thrown error — `format` additionally echoes the content back unchanged with `changed: false`. Only a no-verdict condition is non-2xx: a malformed body, **malformed formatter `options`** (e.g. a non-numeric `column_width` ⇒ 422), auth, or a server fault, all mapped to the typed `ApiResponseError`. `lint` is the cheap static check (syntax / schema / semantic); it does not replace `validate`, which loads the bundle, resolves across files, and dry-runs the pipes.
|
|
110
|
-
- **Durable run lifecycle (hosted extension — NOT protocol):** `getRunStatus`, `getRunResult`, `waitForResult`, `startAndWaitForResult` (handshakes `/v1/version`, takes the durable start+poll path on a hosted deployment, and self-heals to the blocking `execute` against a bare runner). Reading what a completed run consumed is `summarizeUsage(results)`, a standalone pure helper rather than a client method, because it folds the usage pair the results already carry and needs no server. See [run-usage.md](./run-usage.md#summarizing-a-run--summarizeusage).
|
|
111
|
+
- **Durable run lifecycle (hosted extension — NOT protocol):** `getRunStatus`, `getRunResult`, `waitForResult`, `startAndWaitForResult` (handshakes `/v1/version`, takes the durable start+poll path on a hosted deployment, and self-heals to the blocking `execute` against a bare runner). A run that ended without completing answers the results read with a `409` whose `run_status` and `error` members carry its status and its stored error report; `getRunResult` turns it into the `failed` arm (`status`, `message` from `detail`, `error`) and the waiting calls on the durable path into a `RunFailedError` carrying the same (the blocking fallback's failure is the runner's `ApiResponseError`), the status read from the member, or from the `detail` sentence on a platform that does not send it yet. The status read serves the same report as `RunRead.error`. See [errors.md](./errors.md#a-failed-run--runerrorreport). Reading what a completed run consumed is `summarizeUsage(results)`, a standalone pure helper rather than a client method, because it folds the usage pair the results already carry and needs no server. See [run-usage.md](./run-usage.md#summarizing-a-run--summarizeusage).
|
|
111
112
|
- **Health:** `health` (origin-level `/health`).
|
|
112
113
|
|
|
113
114
|
### Product routes (hosted management surface)
|
|
114
115
|
|
|
115
|
-
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`. Consumers branch on the
|
|
116
|
+
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`. Consumers branch on **`type` and `errorDomain`**, as the workspace's hosted-envelope spec says, never on the HTTP status. The platform's `type` is `https://pipelex.com/errors/<code>`, one-to-one with its native `code` (`conflict`, `not_found`, `pipelex_api_key_limit_reached`, …), which stays on the error as the finer surface-specific code; the platform does not emit `error_domain` yet. See [errors.md](./errors.md).
|
|
116
117
|
|
|
117
118
|
- **User profile:** `getMe` (`GET /v1/me`).
|
|
118
119
|
- **Methods catalog:** `listMethods`, `getMethod`, `createMethod`, `updateMethod` (rename = changed `name`), `deleteMethod`. **`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 conflict` rather than a second cascade over the same runs, and an unknown or foreign-org id is a `404`. (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** `MethodData`: no `mthds`, no `python`, no `updated_at`, because none of them is in the projection and putting `mthds` back is what restored the truncation. Reach for `getMethod(id)` when you need a method's source. `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. `iterateMethods` is the async iterator that follows the cursor for callers who genuinely want everything (`for await (const m of client.iterateMethods())`); unlike `iterateRuns` it must keep going **past empty pages**, because `q` is a post-read filter over a bounded index slice per request, so `{items: [], nextCursor: "…"}` means "nothing matched in the slice I just read, keep going" — the difference is the server, not the client. 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 (`MethodData`, from `getMethod`) carry `org_id`, `created_by_user_id`, and a server-derived `description` (parsed read-side from the bundle's top-level `description`) on top of the write contract's `name` / `mthds` / `input_data`. `getMethodClosure` is a client-side semantic layer over `getMethod` (not a route) that parses the stored method's polymorphic `mthds` source into a runnable, provenance-labelled closure — see [input-preparation.md](./input-preparation.md#getmethodclosure--the-explicit-expansion-utility).
|