@pipelex/sdk 0.41.0 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -72,6 +72,23 @@ const saved = await client.start({ method_id: "mt_abc123@3", inputs: {} });
72
72
  console.log(saved.method_version); // 3
73
73
  ```
74
74
 
75
+ ### A start you can retry: `idempotencyKey`
76
+
77
+ `start` and `startAndWaitForResult` take an optional `idempotencyKey`, sent as the `Idempotency-Key` header of `POST /v1/start`. The hosted API binds the key to the run the first request starts, so the same start sent again under the same key is answered with that run and starts nothing: a start whose answer was lost can be sent again without paying for a second run. Generate one key per run, and keep it with the options, unchanged, across that start's retries:
78
+
79
+ ```ts
80
+ import { runMayHaveStartedOf } from "@pipelex/sdk";
81
+
82
+ const options = { method_id: "mt_abc123", inputs, idempotencyKey: crypto.randomUUID() };
83
+ const ack = await client.start(options).catch((err: unknown) => {
84
+ // The run may exist: under the same key, the same start is answered with it.
85
+ if (runMayHaveStartedOf(err)) return client.start(options);
86
+ throw err;
87
+ });
88
+ ```
89
+
90
+ A key is 1 to 255 visible ASCII characters; a key reused with other options is refused with a `409` `conflict`, and one whose earlier start is still being handled with a retryable `409` `idempotency_key_in_use` ([`docs/errors.md`](./docs/errors.md#a-starts-idempotency-key--idempotencykey)). A bare runner ignores the header.
91
+
75
92
  ### Checking a model reference
76
93
 
77
94
  `checkModelReference` asks the runner whether a reference a method's `model` field could name resolves, as what kind and to which model (`GET /v1/models/check`, served by `pipelex-api` from pipelex 0.78.0). A reference that resolves nowhere is a verdict, not an error, and narrowing on `kind` types its `matches`:
@@ -124,6 +141,21 @@ else console.log(`version ${published.version.version}`); // "published" or "unc
124
141
  const versions = await client.listMethodVersions(created.method_id); // newest first
125
142
  const { method_id, version } = parseMethodSelector("mt_abc123@3"); // the method routes take a bare id
126
143
 
144
+ // A saved example is a named set of inputs with the latest run of exactly those inputs. Record a
145
+ // run against the revision whose inputs it used: an edit since answers `stale`, never an error.
146
+ const example = await client.createMethodExample(created.method_id, {
147
+ name: "March receipt",
148
+ inputs: { total: 3 },
149
+ });
150
+ const run = await client.start({ method_id: created.method_id, inputs: example.inputs });
151
+ const verdict = await client.recordMethodExampleLatestRun(created.method_id, example.example_id, {
152
+ run_id: run.pipeline_run_id,
153
+ input_revision: example.input_revision,
154
+ });
155
+ for await (const saved of client.iterateMethodExamples(created.method_id)) {
156
+ // every example, oldest first
157
+ }
158
+
127
159
  try {
128
160
  const { portal_url } = await client.getBillingPortal();
129
161
  // open portal_url ...
@@ -136,7 +168,7 @@ try {
136
168
 
137
169
  ### Errors
138
170
 
139
- Every error the SDK throws carries a verdict: `retryable`, whether asking again can succeed, and `errorDomain`, who can fix the failure (`input` for the caller, `config` for a change to the environment such as the credential, the plan or the base URL, `runtime` for nobody beforehand). Both are always decided, and `errorVerdictOf` reads them from anything a `catch` holds, returning `undefined` for what is not an SDK error, such as a bug in the calling code or your own abort. A failed `start` or blocking `execute` also says whether it may have created a run anyway, as `runMayHaveStarted`, read with `runMayHaveStartedOf`: when it is `true`, `retryable` is `false`, since asking again could start a second paid run, and the person should look the run up in the run history first ([`docs/errors.md`](./docs/errors.md#a-failed-run-start--runmayhavestarted)).
171
+ Every error the SDK throws carries a verdict: `retryable`, whether asking again can succeed, and `errorDomain`, who can fix the failure (`input` for the caller, `config` for a change to the environment such as the credential, the plan or the base URL, `runtime` for nobody beforehand). Both are always decided, and `errorVerdictOf` reads them from anything a `catch` holds, returning `undefined` for what is not an SDK error, such as a bug in the calling code or your own abort. A failed `start` or blocking `execute` also says whether it may have created a run anyway, as `runMayHaveStarted`, read with `runMayHaveStartedOf`: when it is `true`, `retryable` is `false`, since asking again could start a second paid run, and the person should look the run up in the run history first ([`docs/errors.md`](./docs/errors.md#a-failed-run-start--runmayhavestarted)), unless the start carried an `idempotencyKey`, in which case sending it again unchanged recovers the run ([above](#a-start-you-can-retry-idempotencykey)).
140
172
 
141
173
  ```ts
142
174
  import { errorVerdictOf } from "@pipelex/sdk";
@@ -212,6 +244,8 @@ These pages ship inside the published package, so a reader who has only installe
212
244
  | [`docs/artifact-download.md`](./docs/artifact-download.md) | Turning the `pipelex-storage://` references a run produced back into bytes: `locateArtifacts`, `collectArtifacts`, `resolveArtifacts`, `fetchArtifact`, `downloadArtifacts`, and how a saved file is named after the field it fills |
213
245
  | [`docs/input-preparation.md`](./docs/input-preparation.md) | The other direction — `uploadFile` and `prepareInputs`, which turn local files into references a run can take, and the upload grant a browser page sends a file with |
214
246
  | [`docs/bundle-resources.md`](./docs/bundle-resources.md) | Sending the files a bundle's steps read, such as a `PipeDocGen` step's template, as `resources` beside its `.mthds` contents: where they go, what is refused and by whom, and the template check's warnings |
247
+ | [`docs/method-examples.md`](./docs/method-examples.md) | A method's saved examples: the create, the paged list and its iterator, the edit that raises the input revision, the latest-run write and its `recorded` or `stale` verdict, how an integer past `Number.MAX_SAFE_INTEGER` in the inputs stays exact, and what is refused before sending |
248
+ | [`docs/exact-integers.md`](./docs/exact-integers.md) | Which reads keep an integer past `Number.MAX_SAFE_INTEGER` exact, as a `bigint` (a run's inputs and outputs, an example's inputs), how a request body writes it back with its digits, and `parseExactJson` and `stringifyExactJson` for code showing such data as JSON text |
215
249
  | [`docs/crate-routes.md`](./docs/crate-routes.md) | `resolve`, `codegen` and `pipeIo` — the normalized crate, the stamped types, and a method's I/O artifacts without a validation — and the offline `runCodegenCheck` that guards a committed tree |
216
250
  | [`docs/client-identification.md`](./docs/client-identification.md) | The `User-Agent` every API request carries, and `appInfo`, the option that puts your program's name in front of it |
217
251
  | [`docs/errors.md`](./docs/errors.md) | The verdict every error carries (`retryable`, `errorDomain`, `errorVerdictOf`), a failed run's stored error report on `RunFailedError` and `RunRead`, and every member of a refused request's `ApiResponseError`, with the fields to branch on |
@@ -43,7 +43,8 @@ export declare function validationLine(item: Pick<ValidationErrorItem, "message"
43
43
  export declare function isAbsence(mainStuff: unknown): boolean;
44
44
  /**
45
45
  * Print a finished run's main output on stdout, as the method produced it: indented JSON,
46
- * unvalidated and unrepaired, a list included whichever shape it arrived in. An output the method
47
- * left absent prints `null`, and a line on stderr says so.
46
+ * unvalidated and unrepaired, a list included whichever shape it arrived in, an integer past
47
+ * `Number.MAX_SAFE_INTEGER`, which the client reads as a `bigint`, printed with its exact digits.
48
+ * An output the method left absent prints `null`, and a line on stderr says so.
48
49
  */
49
50
  export declare function printResult(mainStuff: unknown, io: CommandIO): void;
@@ -13,7 +13,7 @@
13
13
  * alone names what could not be read (`API POST /v1/start answered 202 with a body that is not
14
14
  * JSON`). Both SDKs word those messages alike, and the case table holds the ones both meet.
15
15
  */
16
- import { ApiResponseError, ApiUnreachableError, InputPreparationError, InvalidInputValueError, InvalidLocalSourceError, MethodLoadError, PipelineRequestError, RejectedAssetError, RunFailedError, UnsupportedUploadCapabilityError, UploadAuthenticationError, UploadTransportError, } from "../index.js";
16
+ import { ApiResponseError, ApiUnreachableError, InputPreparationError, InvalidInputValueError, InvalidLocalSourceError, MethodLoadError, PipelineRequestError, RejectedAssetError, RunFailedError, UnsupportedUploadCapabilityError, UploadAuthenticationError, UploadTransportError, stringifyExactJson, } from "../index.js";
17
17
  import { CommandError, EXIT_FAILED, EXIT_USAGE } from "./io.js";
18
18
  /** Word any failure for stderr and choose its exit code. */
19
19
  export function presentError(error) {
@@ -189,8 +189,9 @@ export function isAbsence(mainStuff) {
189
189
  }
190
190
  /**
191
191
  * Print a finished run's main output on stdout, as the method produced it: indented JSON,
192
- * unvalidated and unrepaired, a list included whichever shape it arrived in. An output the method
193
- * left absent prints `null`, and a line on stderr says so.
192
+ * unvalidated and unrepaired, a list included whichever shape it arrived in, an integer past
193
+ * `Number.MAX_SAFE_INTEGER`, which the client reads as a `bigint`, printed with its exact digits.
194
+ * An output the method left absent prints `null`, and a line on stderr says so.
194
195
  */
195
196
  export function printResult(mainStuff, io) {
196
197
  if (isAbsence(mainStuff)) {
@@ -203,6 +204,6 @@ export function printResult(mainStuff, io) {
203
204
  }
204
205
  return;
205
206
  }
206
- io.writeStdout(`${JSON.stringify(mainStuff, null, 2)}\n`);
207
+ io.writeStdout(`${stringifyExactJson(mainStuff, 2)}\n`);
207
208
  }
208
209
  //# sourceMappingURL=present.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"present.js","sourceRoot":"","sources":["../../src/cli/present.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,gCAAgC,EAChC,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAShE,4DAA4D;AAC5D,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,IAAI,KAAK,YAAY,YAAY,EAAE,CAAC;QAClC,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,KAAK,CAAC,OAAO,EAAE,CAAC;QACrE,OAAO,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;IACxE,CAAC;IACD,IAAI,KAAK,YAAY,cAAc,EAAE,CAAC;QACpC,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC;QAC3B,MAAM,KAAK,GAAG,CAAC,cAAc,KAAK,CAAC,KAAK,sBAAsB,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;QAC/E,KAAK,CAAC,IAAI,CAAC,WAAW,MAAM,EAAE,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC1D,IAAI,MAAM,EAAE,WAAW,EAAE,MAAM;YAAE,KAAK,CAAC,IA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+15,7 @@ import type { CommandIO } from "./io.js";
15
15
  * update notice and npm 12's run notices off the script's stderr, which carries the command's
16
16
  * own lines, while npm's warnings and errors still print.
17
17
  */
18
- export declare const SCRIPT_RUNNER = "npx --yes --no-update-notifier --loglevel=warn @pipelex/sdk@0.41.0";
18
+ export declare const SCRIPT_RUNNER = "npx --yes --no-update-notifier --loglevel=warn @pipelex/sdk@0.43.0";
19
19
  export declare const SCRIPT_WRITER = "@pipelex/sdk";
20
20
  export declare const SCRIPT_NEEDS = "Node 22.12 or later";
21
21
  /** Run `pipelex-sdk script` and return its exit code. */
package/dist/client.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { MTHDSProtocol, ModelCategory, ModelDeck, RunOptions, StartOptions, VersionInfo } from "mthds/protocol";
2
2
  import type { CodegenRequest, CodegenResponse, DictPipeOutput, FormatResponse, LintResponse, ModelCheckCategory, ModelReferenceVerdict, MthdsFileItem, PipeIORequest, PipeIOResponse, PipelexRunResultStart, PipelexValidationResult, ResolveRequest, ResolveResponse, ValidateMethodSelector } from "./models.js";
3
3
  import { type GetRunResultOptions, type RunRead, type RunResults, type RunResultState, type StartAndWaitForResultOptions, type WaitForResultOptions } from "./runs.js";
4
- import type { BillingPortalResponse, ChangePlanResponse, CheckoutResponse, InvoiceView, Membership, MembershipsResponse, ListMethodsQuery, ListMethodVersionsQuery, MethodData, MethodDeletionAccepted, MethodDraftInput, MethodPage, MethodPublishInput, MethodPublishResult, MethodRenameInput, MethodSummary, MethodVersion, MethodVersionPage, MethodWriteInput, OnboardingSubmission, PipelexApiKeyCreated, PipelexApiKeyList, ListRunsQuery, RunHistoryItem, RunDetail, RunPage, PlanView, ResolvedStorageUrl, SubscriptionResponse, UpdateRunInput, UploadGrant, UploadGrantInput, UploadInput, UploadedFile, UserProfile } from "./product-models.js";
4
+ import type { BillingPortalResponse, ChangePlanResponse, CheckoutResponse, InvoiceView, Membership, MembershipsResponse, ListMethodExamplesQuery, ListMethodsQuery, ListMethodVersionsQuery, MethodData, MethodDeletionAccepted, MethodDraftInput, MethodExample, MethodExampleCreateInput, MethodExampleLatestRunInput, MethodExampleLatestRunResult, MethodExamplePage, MethodExampleUpdateInput, MethodPage, MethodPublishInput, MethodPublishResult, MethodRenameInput, MethodSummary, MethodVersion, MethodVersionPage, MethodWriteInput, OnboardingSubmission, PipelexApiKeyCreated, PipelexApiKeyList, ListRunsQuery, RunHistoryItem, RunDetail, RunPage, PlanView, ResolvedStorageUrl, SubscriptionResponse, UpdateRunInput, UploadGrant, UploadGrantInput, UploadInput, UploadedFile, UserProfile } from "./product-models.js";
5
5
  import type { AppInfo } from "./user-agent.js";
6
6
  import type { UploadableAsset, UploadFileOptions, UploadRecord } from "./upload.js";
7
7
  import type { BundleResources } from "./bundle-resources.js";
@@ -105,8 +105,37 @@ export interface PipelexHostedRunExtensions {
105
105
  }
106
106
  /** `execute()` options — the protocol's run arguments plus the Pipelex API and hosted extensions. */
107
107
  export type PipelexRunOptions = RunOptions & PipelexApiRunExtensions & PipelexHostedRunExtensions;
108
- /** `start()` / `startAndWaitForResult()` options — the same, for the durable path. */
109
- export type PipelexStartOptions = StartOptions & PipelexApiRunExtensions & PipelexHostedRunExtensions;
108
+ /**
109
+ * What a run start sends beside its body: the request's own headers, which no run argument
110
+ * reaches. Each is camelCase, since none of them is a wire field of the run request.
111
+ */
112
+ export interface PipelexStartRequestOptions {
113
+ /**
114
+ * The start's idempotency key, sent as the `Idempotency-Key` header of `POST /v1/start`, and
115
+ * not sent at all when absent or `null`. Generate one per run the caller means to start (a
116
+ * `crypto.randomUUID()` is a good key), and keep it, with every other option unchanged, across
117
+ * that start's retries.
118
+ *
119
+ * The hosted API binds the key to the run the first request starts, before it dispatches it, so
120
+ * the same start sent again under the same key is answered with that run's acknowledgement and
121
+ * starts nothing, whatever became of the first attempt, for 24 hours. A failed start whose
122
+ * `runMayHaveStarted` is true can therefore be sent again unchanged, and recovers the run instead
123
+ * of paying for a second one. The same key with a different body is refused (`409` `conflict`),
124
+ * as is a key whose earlier request is still being handled (`409` `idempotency_key_in_use`,
125
+ * retryable: send it again under the same key in a few seconds); see `docs/errors.md`. A bare
126
+ * runner ignores the header.
127
+ *
128
+ * A key is 1 to 255 visible ASCII characters (`!` to `~`, so no space); anything else, an empty
129
+ * string included, is a `RequestArgumentError` before any request is sent, since a start sent
130
+ * without the key the caller asked for would lose the protection silently.
131
+ */
132
+ idempotencyKey?: string | null;
133
+ }
134
+ /**
135
+ * `start()` / `startAndWaitForResult()` options — the same, for the durable path, plus the start
136
+ * request's own `idempotencyKey`.
137
+ */
138
+ export type PipelexStartOptions = StartOptions & PipelexApiRunExtensions & PipelexHostedRunExtensions & PipelexStartRequestOptions;
110
139
  /**
111
140
  * The method selector `validate()` takes in place of inline contents — declared
112
141
  * beside the other wire shapes in `./models.js` and re-exported here, the import
@@ -205,6 +234,8 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
205
234
  * cleanly. Non-2xx interpretation is left to the caller. `url` is a fully
206
235
  * resolved absolute URL. `mayStartRun` marks a request that may create a run,
207
236
  * whose `ApiUnreachableError` then says whether it may have (see `RunCreation`).
237
+ * `idempotencyKey`, already checked by `idempotencyKeyOf`, is sent as the
238
+ * `Idempotency-Key` header; only `start` passes one.
208
239
  */
209
240
  private requestRaw;
210
241
  /**
@@ -239,14 +270,45 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
239
270
  */
240
271
  private readStoredSources;
241
272
  /**
242
- * One page of a cursor-paged product route (`listMethods`, `listMethodVersions`, `listRuns`),
243
- * read as the platform always serializes it: `items` an array, `next_cursor` a string or
244
- * `null`. A page breaking either is an answer the SDK cannot read, so it throws the
245
- * `ApiResponseError` `unreadableAnswer` builds, `runtime` and not retryable, rather than
246
- * handing the iterators a page they cannot walk: `items` that is not iterable, or a missing
247
- * cursor that is neither the end nor a next page, which `iterateRuns` would follow forever.
273
+ * A verdict, the `200` a route answers discriminated on `outcome` with the object the verdict
274
+ * is about as one `member`: `publishMethod`'s `method`, `recordMethodExampleLatestRun`'s
275
+ * `example`. The answer is read as `readObjectAnswer` reads it, then an `outcome` that is none
276
+ * of `outcomes` is an answer the SDK cannot read, and so is a `member` that is not an object,
277
+ * the check `readObjectAnswerAt` holds a route's whole answer to: each throws the
278
+ * `ApiResponseError` `unreadableAnswer` builds, `verdict` naming the answer in the message.
279
+ * A route whose member has a reader of its own passes it as `readMember`, which then checks the
280
+ * member in place of that object check, so the member is checked once. `parse` reads the
281
+ * answer's text, `readJson` unless the route names another. Returns the answer, its `outcome`
282
+ * and the member as `subject`, for the route to read further.
283
+ */
284
+ private readVerdict;
285
+ /**
286
+ * One page of a cursor-paged product route (`listMethods`, `listMethodVersions`,
287
+ * `listMethodExamples`, `listRuns`), read as the platform always serializes it: `items` an
288
+ * array, `next_cursor` a string or `null`. A page breaking either is an answer the SDK cannot
289
+ * read, so it throws the `ApiResponseError` `unreadableAnswer` builds, `runtime` and not
290
+ * retryable, rather than handing the iterators a page they cannot walk: `items` that is not
291
+ * iterable, or a missing cursor that is neither the end nor a next page, which `iterateRuns`
292
+ * would follow forever. A route reading its rows itself passes `rows`: `parse` reads the page's
293
+ * text, and `item` reads each row, throwing as `unreadableAnswer` does for one it cannot read.
248
294
  */
249
295
  private requestPage;
296
+ /**
297
+ * A route answering one method example (`createMethodExample`, `getMethodExample`,
298
+ * `updateMethodExample`), its answer read with `parseExactJson`, so an integer past the safe
299
+ * range in the inputs is a `bigint` holding its exact digits, and checked by
300
+ * `readMethodExample`.
301
+ */
302
+ private requestMethodExample;
303
+ /**
304
+ * A method example as `res` carried it, checked against `METHOD_EXAMPLE_FIELDS`: a value that
305
+ * is not an object, or that misses a field the Python SDK's model requires or holds one of
306
+ * another type, is an answer the SDK cannot read, thrown as the `ApiResponseError`
307
+ * `unreadableAnswer` builds, `where` naming the example's place in the answer in the message.
308
+ * Every route answering an example reads it here, the page rows and the latest-run verdict's
309
+ * member included.
310
+ */
311
+ private readMethodExample;
250
312
  /** Issue a product request and return its 2xx answer, a non-2xx thrown as `ApiResponseError`. */
251
313
  private requestProductAnswer;
252
314
  private throwApiResponseError;
@@ -256,9 +318,11 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
256
318
  private readObjectAnswer;
257
319
  /**
258
320
  * The JSON body of a 2xx answer, naming the route by its `path` from the origin as a refusal
259
- * does. A body that is not UTF-8, or not JSON, an empty one included, is an answer the SDK
260
- * cannot read, so it throws the `ApiResponseError` `unreadableAnswer` builds, with the parse
261
- * failure as `cause`.
321
+ * does, its text read by `parse`: `JSON.parse`, or `parseExactJson` for an answer carrying a
322
+ * person's data. A body that is not UTF-8, or not JSON, an empty one included, is an answer the
323
+ * SDK cannot read, so it throws the `ApiResponseError` `unreadableAnswer` builds, with the parse
324
+ * failure as `cause`; so is a body holding a number `parseExactJson` cannot read exactly on this
325
+ * runtime (`ExactJsonUnsupportedError`), rather than read rounded.
262
326
  * The one place a success body is parsed.
263
327
  */
264
328
  private readAnswerAt;
@@ -323,6 +387,9 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
323
387
  * that exceeds that surfaces as `PipelineExecuteTimeoutError` pointing at the
324
388
  * durable start+poll path. Throws `RunStillRunningError` on the protocol's
325
389
  * optional 202 degrade.
390
+ *
391
+ * The answer is read with `parseExactJson`, so an integer past `Number.MAX_SAFE_INTEGER` in the
392
+ * working memory, the main output included, is a `bigint` holding its exact digits.
326
393
  */
327
394
  execute(options: PipelexRunOptions): Promise<PipelexExecuteResult>;
328
395
  /**
@@ -337,6 +404,13 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
337
404
  * durable — poll `getRunStatus` / `getRunResult`. A `method_ref` run's ack
338
405
  * additionally carries `method_provenance` — the address, the tag, and the
339
406
  * commit SHA that was actually fetched.
407
+ *
408
+ * `options.idempotencyKey` is sent as the `Idempotency-Key` header, and nothing
409
+ * is sent without it: the hosted API answers the same start sent again under the
410
+ * same key with the run the first one started, so a failure whose
411
+ * `runMayHaveStarted` is true can be retried unchanged (see
412
+ * `PipelexStartRequestOptions`). A malformed key is a `RequestArgumentError`
413
+ * before anything is sent.
340
414
  */
341
415
  start(options: PipelexStartOptions): Promise<PipelexRunResultStart>;
342
416
  /**
@@ -638,6 +712,11 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
638
712
  * before any request. `MissingMainStuffError` is thrown only for a read that asked
639
713
  * for `main_stuff` — no selection, or one naming it.
640
714
  *
715
+ * A completed result is read with `parseExactJson`, so an integer past
716
+ * `Number.MAX_SAFE_INTEGER` anywhere in it, the main output, the working memory and the graph
717
+ * included, is a `bigint` holding its exact digits, and an output passed back to `start` goes
718
+ * back as the run produced it.
719
+ *
641
720
  * Throws `RunLifecycleUnavailableError` when the lifecycle routes are absent
642
721
  * (a bare runner).
643
722
  */
@@ -687,6 +766,12 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
687
766
  * up in the run history first. An error from the wait, once `onStarted` has named the run,
688
767
  * started nothing, so its `runMayHaveStarted` is false, and its `retryable` is about waiting
689
768
  * again on that id with `waitForResult`, never about calling this method again.
769
+ *
770
+ * `options.idempotencyKey` rides the durable start, so a call that failed while its start may
771
+ * have created a run can be made again with the same options and the same key: the hosted API
772
+ * answers the start with the run the first call started, and the wait follows it. The blocking
773
+ * execute of a bare runner carries no key, a bare runner having no idempotency to honour it. A
774
+ * malformed key is refused before the version handshake.
690
775
  */
691
776
  startAndWaitForResult(options: PipelexStartOptions, pollOptions?: StartAndWaitForResultOptions): Promise<RunResults>;
692
777
  /** The authenticated user's profile — `GET /v1/me`. */
@@ -746,7 +831,9 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
746
831
  * Takes a bare catalog id: the method routes address the method itself, never a version of
747
832
  * it. A caller holding `mt_…@3` strips the suffix with `parseMethodSelector` and reads that
748
833
  * version with `getMethodVersion`. Every method route throws `RequestArgumentError` for a
749
- * suffixed id, before any request, rather than read back the `404` the platform would answer.
834
+ * suffixed id, before any request, rather than read back the `404` the platform would answer,
835
+ * and for an id that is empty, `.` or `..`, which the URL would resolve into another route's
836
+ * path.
750
837
  */
751
838
  getMethod(methodId: string): Promise<MethodData>;
752
839
  /**
@@ -894,6 +981,124 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
894
981
  * as `getMethod` does: the whole method is erased, never one of its versions.
895
982
  */
896
983
  deleteMethod(methodId: string): Promise<MethodDeletionAccepted>;
984
+ /**
985
+ * Save an example on a method — `POST /v1/methods/{id}/examples`: a named set of inputs, and
986
+ * with `run_id`, a run of this method that used exactly those inputs, recorded as its latest
987
+ * run. Answers the example as stored, at `input_revision` 1.
988
+ *
989
+ * Sends `name`, `inputs` and, when given, `run_id`, and nothing else: the route's body is
990
+ * closed, and a `null` `run_id` reads as not given. Throws `RequestArgumentError` before any
991
+ * request when `name` or `inputs` is not given (`null` counting as not given), and for a
992
+ * `run_id` that is given but is not a non-empty string. Throws `ApiResponseError`: `404`
993
+ * `run_not_found` for a `run_id` that is not one of this method's runs in the caller's
994
+ * organization, with nothing written; `413` `payload_too_large` for an example larger than one
995
+ * stored item holds; `422` for a name that is empty, blank or over 200 characters, or inputs
996
+ * that are not a JSON object; and the codes every example route answers.
997
+ */
998
+ createMethodExample(methodId: string, input: MethodExampleCreateInput): Promise<MethodExample>;
999
+ /**
1000
+ * One page of a method's examples, oldest first, inputs included —
1001
+ * `GET /v1/methods/{id}/examples`.
1002
+ *
1003
+ * Pass the page's `nextCursor` back as `cursor` to continue; `null` is the last page. A page
1004
+ * may be short while `nextCursor` is set, because the platform reads examples whole and stops
1005
+ * a read at 1 MB; `iterateMethodExamples` follows the cursor for a caller that wants them all.
1006
+ *
1007
+ * Throws `ApiResponseError`: `400` `malformed_request` for a cursor the listing did not issue
1008
+ * for this method, `422` for a `limit` outside 1 to 100, and the codes every example route
1009
+ * answers. A page whose `items` is not an array, whose `next_cursor` is neither a string nor
1010
+ * `null`, or one of whose items is not an example `readMethodExample` can read, is an answer
1011
+ * the SDK cannot read, thrown as an `ApiResponseError` too. An example whose inputs hold an
1012
+ * integer past the safe range is read like any other, that integer as a `bigint`.
1013
+ */
1014
+ listMethodExamples(methodId: string, query?: ListMethodExamplesQuery): Promise<MethodExamplePage>;
1015
+ /**
1016
+ * Every example of a method, oldest first, streamed — follows the cursor of
1017
+ * `listMethodExamples` for you.
1018
+ *
1019
+ * ```ts
1020
+ * for await (const example of client.iterateMethodExamples(methodId)) {
1021
+ * rerun(example); // stop whenever you like
1022
+ * }
1023
+ * ```
1024
+ *
1025
+ * An iterator rather than an all-at-once list, for the reason `iterateMethods` is one: a
1026
+ * helper returning an array needs a page cap, and a cap returns a truncated list with no
1027
+ * error. It runs the same loop as `iterateMethods` and `iterateRuns`, so it keeps going through
1028
+ * a short or empty page that carries a cursor, stops on a `null` cursor or on a cursor the
1029
+ * server failed to advance, and throws `PagingNotTerminatingError` past the same page ceiling.
1030
+ *
1031
+ * Throws `RequestArgumentError` at the call, before the iterator is pulled or anything is sent,
1032
+ * for a method id `listMethodExamples` refuses: a suffixed one, or one that is empty, `.` or `..`
1033
+ * or holds a lone surrogate.
1034
+ */
1035
+ iterateMethodExamples(methodId: string, query?: Omit<ListMethodExamplesQuery, "cursor">): AsyncGenerator<MethodExample, void, undefined>;
1036
+ /**
1037
+ * One example of a method — `GET /v1/methods/{id}/examples/{example_id}`, read consistently,
1038
+ * so an example saved a moment ago is found.
1039
+ *
1040
+ * Throws `RequestArgumentError` for an example id that is empty, `.` or `..`, or holds a lone
1041
+ * surrogate, before any request. Throws `ApiResponseError`: `422` for an example id longer
1042
+ * than one can be (64 characters), and the codes every example route answers.
1043
+ */
1044
+ getMethodExample(methodId: string, exampleId: string): Promise<MethodExample>;
1045
+ /**
1046
+ * Rename an example, give it new inputs, or both —
1047
+ * `PATCH /v1/methods/{id}/examples/{example_id}` — and return it as it now stands.
1048
+ *
1049
+ * **New inputs raise `input_revision` by one and clear `latest_run_id`**, since the run no
1050
+ * longer shows what the inputs produce; inputs that are the same as the stored ones, their
1051
+ * keys in another order included, change nothing, while `3` becoming `3.0` is a change. A
1052
+ * rename alone keeps both. The edit takes no revision or token: the latest-run write is what
1053
+ * the revision guards. Sends `name` and `inputs` when given, and nothing else; `null` reads as
1054
+ * not given, as the platform reads it.
1055
+ *
1056
+ * **Send `inputs` only when they changed.** Inputs read from an example and sent back unchanged
1057
+ * are a change for the platform when they hold a float with no fractional part, `3.0`, which
1058
+ * JavaScript reads as `3` (see `MethodExample.inputs`): they raise the revision and clear the
1059
+ * latest run. A rename sent alone never does. An integer past `Number.MAX_SAFE_INTEGER` is no
1060
+ * such case: it reads as a `bigint` and is sent back as its exact digits.
1061
+ *
1062
+ * Throws `RequestArgumentError` before any request for an example id that is empty, `.` or
1063
+ * `..`, or when neither `name` nor `inputs` is given. Throws `ApiResponseError`: `413`
1064
+ * `payload_too_large` for inputs larger than one stored item holds, `422` for a name that is
1065
+ * empty, blank or over 200 characters, or inputs that are not a JSON object, a `503` that wrote
1066
+ * nothing, safe to retry, when concurrent edits kept landing under the write, and the codes
1067
+ * every example route answers.
1068
+ */
1069
+ updateMethodExample(methodId: string, exampleId: string, input: MethodExampleUpdateInput): Promise<MethodExample>;
1070
+ /**
1071
+ * Record a run as an example's latest —
1072
+ * `PUT /v1/methods/{id}/examples/{example_id}/latest-run` — **only while the example still
1073
+ * holds the revision whose inputs the run used**.
1074
+ *
1075
+ * `input_revision` is the example's `input_revision` the caller read when it started the run
1076
+ * with the example's inputs; the platform trusts it and does not compare the run's own inputs.
1077
+ * The answer is a `MethodExampleLatestRunResult` discriminated on `outcome` — branch on it:
1078
+ * `recorded`, the run is now the example's latest; `stale`, the example's inputs were edited
1079
+ * since and nothing was written. A stale run is the expected end of a run that outlasted an
1080
+ * edit, so it is answered, never thrown. Both arms carry the `example` as it stands.
1081
+ *
1082
+ * Throws `RequestArgumentError` before any request, checking in this order: an example id that
1083
+ * is empty, `.` or `..`, or holds a lone surrogate, a `run_id` that is not a non-empty string,
1084
+ * and an `input_revision` that is not a positive integer. Throws `ApiResponseError` when no
1085
+ * verdict was produced: `404` `not_found` for an example deleted since, `404` `run_not_found`
1086
+ * for a run that is not one of this method's, with nothing written, and the codes every example
1087
+ * route answers. An answer whose `outcome` is neither arm's, or whose `example` is not an
1088
+ * example `readMethodExample` can read, is an answer the SDK cannot read, thrown as an
1089
+ * `ApiResponseError` too, read as `publishMethod` reads its verdict.
1090
+ */
1091
+ recordMethodExampleLatestRun(methodId: string, exampleId: string, input: MethodExampleLatestRunInput): Promise<MethodExampleLatestRunResult>;
1092
+ /**
1093
+ * Delete an example — `DELETE /v1/methods/{id}/examples/{example_id}`. The platform answers
1094
+ * `204`. Deleting the example leaves its latest run in the method's history.
1095
+ *
1096
+ * Throws `RequestArgumentError` for an example id that is empty, `.` or `..`, before any
1097
+ * request: `..` would address the method, and its erasure would answer the delete. Throws
1098
+ * `ApiResponseError`: `404` `not_found` when there is no such example, one already deleted
1099
+ * included, and the codes every example route answers.
1100
+ */
1101
+ deleteMethodExample(methodId: string, exampleId: string): Promise<void>;
897
1102
  /** The caller's org memberships + active-org feature flags — `GET /v1/organizations/memberships`. */
898
1103
  listMemberships(): Promise<MembershipsResponse>;
899
1104
  /** Create an organization — `POST /v1/organizations`. */
@@ -1125,6 +1330,10 @@ export declare class PipelexApiClient implements MTHDSProtocol<DictPipeOutput> {
1125
1330
  * executed) and `inputs`. Kept off the status read, which pollers hit every
1126
1331
  * few seconds. A failed run's stored report, `error`, is checked field by
1127
1332
  * field (see `RunErrorReport`).
1333
+ *
1334
+ * Read with `parseExactJson`, so an integer past `Number.MAX_SAFE_INTEGER` in the inputs is a
1335
+ * `bigint` holding its exact digits, and the inputs passed back to `start` or saved as an
1336
+ * example's go back as the run used them.
1128
1337
  */
1129
1338
  getRunDetail(runId: string): Promise<RunDetail>;
1130
1339
  /** Patch a run's status (admin/manual) — `PUT /v1/runs/{id}`. */