@eigenpal/sdk 0.23.6 → 0.23.7

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @eigenpal/sdk
2
2
 
3
+ ## 0.23.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 9469d09: Stop retrying run start and rerun after a lost response, keep the server message for 409, 413 and 422 errors (new `EigenpalConflictError` and `EigenpalPayloadTooLargeError`), encode dataset review request ids in URLs, and expose the upload helpers at `@eigenpal/sdk/upload`.
8
+
3
9
  ## 0.23.1
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@eigenpal/sdk",
3
- "version": "0.23.6",
3
+ "version": "0.23.7",
4
4
  "description": "Official TypeScript SDK for the EigenPal API",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
7
7
  "types": "./src/index.ts",
8
8
  "exports": {
9
9
  ".": "./src/index.ts",
10
- "./generated": "./src/generated/index.ts"
10
+ "./generated": "./src/generated/index.ts",
11
+ "./upload": "./src/upload.ts"
11
12
  },
12
13
  "files": [
13
14
  "src",
package/src/client.ts CHANGED
@@ -18,6 +18,7 @@ import {
18
18
  type PathFileInput,
19
19
  } from './lib/files';
20
20
  import { DEFAULT_MULTIPART_MAX_BYTES, keysRequiringPreUpload } from './lib/upload-limits';
21
+ import { sleep } from './lib/upload-presigned-multipart';
21
22
  import { AuthResource } from './resources/auth';
22
23
  import { AutomationsResource } from './resources/automations';
23
24
  import { DatasetReviewRequestsResource } from './resources/dataset-review-requests';
@@ -83,6 +84,13 @@ export interface OperationResult<T> {
83
84
 
84
85
  export interface RequestDispatchOptions {
85
86
  responseKind?: 'json' | 'binary';
87
+ /**
88
+ * The request is not idempotent (run start, rerun): a lost response may mean
89
+ * the server already acted. Retry only when the server explicitly refused
90
+ * the request (429, or 503 with `Retry-After`); never on network errors,
91
+ * timeouts or other 5xx, which would create duplicate runs.
92
+ */
93
+ nonIdempotent?: boolean;
86
94
  }
87
95
 
88
96
  export type RunTarget =
@@ -266,7 +274,8 @@ export class EigenpalClient {
266
274
  bodySerializer: null,
267
275
  headers: { 'Content-Type': null },
268
276
  signal: options.signal,
269
- }) as Promise<OperationResult<RunStartResponse>>
277
+ }) as Promise<OperationResult<RunStartResponse>>,
278
+ { nonIdempotent: true }
270
279
  );
271
280
  }
272
281
 
@@ -281,7 +290,8 @@ export class EigenpalClient {
281
290
  query,
282
291
  body,
283
292
  signal: options.signal,
284
- }) as Promise<OperationResult<RunStartResponse>>
293
+ }) as Promise<OperationResult<RunStartResponse>>,
294
+ { nonIdempotent: true }
285
295
  );
286
296
  }
287
297
 
@@ -382,6 +392,8 @@ export class EigenpalClient {
382
392
  /**
383
393
  * Run an operation with automatic retries on 5xx / 429 / network errors,
384
394
  * and centralized error mapping into typed `EigenpalError` subclasses.
395
+ * Non-idempotent calls (`options.nonIdempotent`) retry only on 429 and on
396
+ * 503 with `Retry-After`.
385
397
  *
386
398
  * Resources call this via the bound `_request` they receive at construction.
387
399
  * The retry budget is `maxRetries`; backoff is exponential (250ms × 2^attempt)
@@ -406,7 +418,10 @@ export class EigenpalClient {
406
418
  // CDN is transient and should consume retry budget, not throw on
407
419
  // attempt zero. Only fire when we're about to surface the response
408
420
  // as a final result or final error.
409
- const willRetry = isRetriableStatus(status) && attempt < this.maxRetries;
421
+ const retriable = options.nonIdempotent
422
+ ? isRefusedStatus(status, response)
423
+ : isRetriableStatus(status);
424
+ const willRetry = retriable && attempt < this.maxRetries;
410
425
  if (response && !willRetry) {
411
426
  if (options.responseKind === 'binary') assertBinaryResponse(response);
412
427
  else assertJsonResponse(response);
@@ -428,7 +443,7 @@ export class EigenpalClient {
428
443
  // Network/abort error — retry if budget allows. AbortSignal aborts
429
444
  // surface as DOMException — we treat them as terminal (don't retry).
430
445
  if (isAbortError(err)) throw err;
431
- if (attempt < this.maxRetries) {
446
+ if (!options.nonIdempotent && attempt < this.maxRetries) {
432
447
  await sleep(backoff(attempt));
433
448
  continue;
434
449
  }
@@ -567,6 +582,12 @@ function isRetriableStatus(status: number): boolean {
567
582
  return status >= 500 || status === 429;
568
583
  }
569
584
 
585
+ /** The server explicitly refused the request, so retrying cannot duplicate work. */
586
+ function isRefusedStatus(status: number, response: Response | undefined): boolean {
587
+ if (status === 429) return true;
588
+ return status === 503 && response?.headers.get('retry-after') != null;
589
+ }
590
+
570
591
  function retryDelay(response: Response | undefined, attempt: number): number {
571
592
  const retryAfterSec = parseRetryAfter(response?.headers.get('retry-after') ?? null);
572
593
  return retryAfterSec !== undefined ? retryAfterSec * 1000 : backoff(attempt);
@@ -582,10 +603,6 @@ function parseRetryAfter(value: string | null): number | undefined {
582
603
  return Number.isFinite(seconds) && seconds >= 0 ? seconds : undefined;
583
604
  }
584
605
 
585
- function sleep(ms: number): Promise<void> {
586
- return new Promise((resolve) => setTimeout(resolve, ms));
587
- }
588
-
589
606
  function isAbortError(err: unknown): boolean {
590
607
  if (err instanceof EigenpalTimeoutError) return true;
591
608
  if (typeof err === 'object' && err !== null && 'name' in err) {
package/src/errors.ts CHANGED
@@ -5,6 +5,7 @@ import type { ApiErrorEnvelope } from './generated/types.gen';
5
5
  *
6
6
  * Sub-classes are dispatched on HTTP status: `EigenpalAuthError` for 401,
7
7
  * `EigenpalForbiddenError` for 403, `EigenpalNotFoundError` for 404,
8
+ * `EigenpalConflictError` for 409, `EigenpalPayloadTooLargeError` for 413,
8
9
  * `EigenpalRateLimitError` for 429, `EigenpalServerError` for 5xx.
9
10
  * Validation failures (400) come back as `EigenpalValidationError` with
10
11
  * the parsed `issues[]` from the canonical `ApiErrorEnvelope`.
@@ -63,6 +64,22 @@ export class EigenpalValidationError extends EigenpalError {
63
64
  }
64
65
  }
65
66
 
67
+ /** 409: the resource changed or already exists (e.g. a stale `expectedUpdatedAt`). */
68
+ export class EigenpalConflictError extends EigenpalError {
69
+ constructor(envelope?: ApiErrorEnvelope) {
70
+ super(envelope?.issues?.[0]?.message ?? 'conflict', { status: 409, envelope });
71
+ this.name = 'EigenpalConflictError';
72
+ }
73
+ }
74
+
75
+ /** 413: the request body or uploaded file is larger than the server accepts. */
76
+ export class EigenpalPayloadTooLargeError extends EigenpalError {
77
+ constructor(envelope?: ApiErrorEnvelope) {
78
+ super(envelope?.issues?.[0]?.message ?? 'payload too large', { status: 413, envelope });
79
+ this.name = 'EigenpalPayloadTooLargeError';
80
+ }
81
+ }
82
+
66
83
  export class EigenpalRateLimitError extends EigenpalError {
67
84
  /** Seconds until the next request may succeed. From `Retry-After`. */
68
85
  readonly retryAfter?: number;
@@ -102,7 +119,12 @@ export function errorFromResponse(
102
119
  if (status === 401) return new EigenpalAuthError(envelope);
103
120
  if (status === 403) return new EigenpalForbiddenError(envelope);
104
121
  if (status === 404) return new EigenpalNotFoundError(envelope);
122
+ if (status === 409) return new EigenpalConflictError(envelope);
123
+ if (status === 413) return new EigenpalPayloadTooLargeError(envelope);
105
124
  if (status === 429) return new EigenpalRateLimitError(envelope, retryAfter);
106
125
  if (status >= 500) return new EigenpalServerError(status, envelope);
107
- return new EigenpalError(`unexpected status ${status}`, { status, envelope });
126
+ return new EigenpalError(envelope?.issues?.[0]?.message ?? `unexpected status ${status}`, {
127
+ status,
128
+ envelope,
129
+ });
108
130
  }
@@ -564,7 +564,7 @@ export const automationsVersionsList = <ThrowOnError extends boolean = false>(op
564
564
  /**
565
565
  * Create a workflow version
566
566
  *
567
- * Create a tagged YAML workflow candidate from validated YAML or by copying an existing snapshot (`historyId`). Provide exactly one of `yaml` or `historyId`. Copy creates a new tagged row and leaves the source tag unchanged; it does not retag the original. Defaults to making the new version current. Set `activate: false` to keep it off live traffic until promote — that path requires an existing current workflow version and returns 400 if HEAD is empty. Agent automations are Git-backed and return 400. Requires a Bearer API key or a dashboard session.
567
+ * Create a tagged YAML workflow candidate from validated YAML or by copying an existing snapshot (`historyId`). Provide exactly one of `yaml` or `historyId`. Copy creates a new tagged row and leaves the source tag unchanged; it does not retag the original. Defaults to making the new version current. Set `activate: false` to keep it off live traffic until promote. That path requires an existing current workflow version and returns 400 if HEAD is empty. Agent automations are Git-backed and return 400. Requires a Bearer API key or a dashboard session.
568
568
  */
569
569
  export const automationsVersionsCreate = <ThrowOnError extends boolean = false>(options: Options<AutomationsVersionsCreateData, ThrowOnError>): RequestResult<AutomationsVersionsCreateResponses, AutomationsVersionsCreateErrors, ThrowOnError> => (options.client ?? client).post<AutomationsVersionsCreateResponses, AutomationsVersionsCreateErrors, ThrowOnError>({
570
570
  security: [{ scheme: 'bearer', type: 'http' }],
@@ -69,7 +69,7 @@ export type UpdateDatasetReviewRequest = {
69
69
 
70
70
  export type UpdateDatasetReviewItem = {
71
71
  /**
72
- * file-decision records a per-expected-file approve/remove (or a note). edit-file uploads corrected bytes and is multipart-only — JSON callers get a 400 pointing at the multipart form.
72
+ * file-decision records a per-expected-file approve/remove (or a note). edit-file uploads corrected bytes and is multipart-only; JSON callers get a 400 pointing at the multipart form.
73
73
  */
74
74
  action: 'approve' | 'edit' | 'remove' | 'reopen' | 'comment' | 'field-decision' | 'file-decision' | 'edit-file';
75
75
  expected?: unknown;
@@ -817,7 +817,7 @@ export type DatasetReviewItem = {
817
817
  [key: string]: DatasetReviewFieldDecision;
818
818
  };
819
819
  /**
820
- * Overlay of the snapshot manifest expected files. Null means pristine — the reviewer has not corrected or uploaded any file yet.
820
+ * Overlay of the snapshot manifest expected files. Null means pristine: the reviewer has not corrected or uploaded any file yet.
821
821
  */
822
822
  currentExpectedFiles: Array<DatasetReviewExpectedFile> | null;
823
823
  /**
@@ -1636,7 +1636,7 @@ export type Folder = {
1636
1636
  */
1637
1637
  workflowCount?: number;
1638
1638
  /**
1639
- * Up to a handful of item names — subfolders first, then workflows — for a peek at folder contents. Present on workflow-tree listings.
1639
+ * Up to a handful of item names (subfolders first, then workflows) for a peek at folder contents. Present on workflow-tree listings.
1640
1640
  */
1641
1641
  previewItems?: Array<{
1642
1642
  name: string;
@@ -1811,7 +1811,7 @@ export type PublicModel = {
1811
1811
  location: 'local' | 'hosted';
1812
1812
  limits?: PublicModelLimits;
1813
1813
  /**
1814
- * Static Eigenpal credit rates when known without a live vendor catalog. Omitted for OpenParser OCR and for LLMs (token prices are not part of this catalog).
1814
+ * Static EigenPal credit rates when known without a live vendor catalog. Omitted for OpenParser OCR and for LLMs (token prices are not part of this catalog).
1815
1815
  */
1816
1816
  cost?: PublicModelCost;
1817
1817
  aliases: Array<string>;
@@ -2077,7 +2077,7 @@ export type Run = {
2077
2077
  */
2078
2078
  eval?: RunEval;
2079
2079
  /**
2080
- * Completed runs only. Per-automation business result — not a generic schema. Absent until the run completes.
2080
+ * Completed runs only. Per-automation business result, not a generic schema. Absent until the run completes.
2081
2081
  */
2082
2082
  output?: {
2083
2083
  [key: string]: unknown;
@@ -2328,7 +2328,7 @@ export type RunCancelResponse = {
2328
2328
  };
2329
2329
  cancellation: {
2330
2330
  /**
2331
- * `cancelled` — the run was terminated immediately (it had not started). `requested` — the run is in-flight; cancellation was requested and the status will become `cancelled` shortly. `already_terminal` — the run had already finished; nothing changed.
2331
+ * `cancelled`: the run was terminated immediately (it had not started). `requested`: the run is in-flight; cancellation was requested and the status will become `cancelled` shortly. `already_terminal`: the run had already finished; nothing changed.
2332
2332
  */
2333
2333
  state: 'cancelled' | 'requested' | 'already_terminal';
2334
2334
  /**
@@ -7638,7 +7638,7 @@ export type RunsStartResponses = {
7638
7638
  */
7639
7639
  201: RunAccepted;
7640
7640
  /**
7641
- * Wait expired with a non-terminal status — poll GET /api/v1/runs/:id
7641
+ * Wait expired with a non-terminal status; poll GET /api/v1/runs/:id
7642
7642
  */
7643
7643
  202: RunAccepted;
7644
7644
  };
@@ -7718,7 +7718,7 @@ export type RunsArtifactsListData = {
7718
7718
  };
7719
7719
  query?: {
7720
7720
  /**
7721
- * When `1`, download output files as a ZIP instead of listing paths. Does not include trace, scores, or input — use `GET /runs/{id}/scores` and `GET /runs/{id}/trace` for those. Cloud deployments reject archives whose uncompressed inputs exceed 32 MiB (`413 artifacts_zip_too_large`); download files individually or pass a smaller `files=` subset.
7721
+ * When `1`, download output files as a ZIP instead of listing paths. Does not include trace, scores, or input; use `GET /runs/{id}/scores` and `GET /runs/{id}/trace` for those. Cloud deployments reject archives whose uncompressed inputs exceed 32 MiB (`413 artifacts_zip_too_large`); download files individually or pass a smaller `files=` subset.
7722
7722
  */
7723
7723
  zip?: '1';
7724
7724
  /**
@@ -8084,7 +8084,7 @@ export type RunsRerunResponses = {
8084
8084
  */
8085
8085
  201: RunAccepted;
8086
8086
  /**
8087
- * Wait expired with a non-terminal status — poll GET /api/v1/runs/:id
8087
+ * Wait expired with a non-terminal status; poll GET /api/v1/runs/:id
8088
8088
  */
8089
8089
  202: RunAccepted;
8090
8090
  };
package/src/index.ts CHANGED
@@ -30,9 +30,11 @@ export {
30
30
 
31
31
  export {
32
32
  EigenpalAuthError,
33
+ EigenpalConflictError,
33
34
  EigenpalError,
34
35
  EigenpalForbiddenError,
35
36
  EigenpalNotFoundError,
37
+ EigenpalPayloadTooLargeError,
36
38
  EigenpalRateLimitError,
37
39
  EigenpalServerError,
38
40
  EigenpalTimeoutError,
package/src/lib/files.ts CHANGED
@@ -292,14 +292,6 @@ export async function statUploadSize(
292
292
  );
293
293
  }
294
294
 
295
- export function isReplayableUploadSource(file: FileInput | Uint8Array | ArrayBuffer): boolean {
296
- if (file instanceof Uint8Array || file instanceof ArrayBuffer) return true;
297
- if (typeof Blob !== 'undefined' && file instanceof Blob) return true;
298
- if (isPathFileInput(file) || isStreamFactoryFileInput(file) || isFileDescriptor(file))
299
- return true;
300
- return isReadStream(file) && typeof file.path === 'string';
301
- }
302
-
303
295
  async function pathIsFile(filePath: string): Promise<boolean> {
304
296
  try {
305
297
  const { stat } = await import('node:fs/promises');
@@ -3,8 +3,6 @@
3
3
  * ingress limit can override it; `null` keeps every run file on multipart.
4
4
  */
5
5
  export const DEFAULT_MULTIPART_MAX_BYTES = Math.floor(4.5 * 1024 * 1024);
6
- /** @deprecated Use {@link DEFAULT_MULTIPART_MAX_BYTES}. */
7
- export const DIRECT_UPLOAD_BYTE_THRESHOLD = DEFAULT_MULTIPART_MAX_BYTES;
8
6
 
9
7
  /**
10
8
  * Conservative allowance for multipart boundaries, `target` / `input` /
@@ -21,41 +19,54 @@ export function multipartFileByteBudget(
21
19
  }
22
20
 
23
21
  /**
24
- * Choose which file keys must be pre-uploaded so remaining multipart file
22
+ * Choose which file positions must be pre-uploaded so remaining multipart file
25
23
  * bytes plus envelope headroom stay under the configured multipart maximum.
26
24
  *
27
- * Prefers shedding the largest files first so smaller ones can stay on the
28
- * single multipart round-trip when the aggregate still fits.
25
+ * Uses positional identity so repeated values for the same field (CLI
26
+ * `--input-file field=...`) are budgeted independently. Prefers shedding the
27
+ * largest files first so smaller ones can stay on the single multipart
28
+ * round-trip when the aggregate still fits; ties go to the earlier position.
29
29
  */
30
- export function keysRequiringPreUpload(
31
- files: ReadonlyArray<{ key: string; size: number }>,
30
+ export function indicesRequiringPreUpload(
31
+ files: ReadonlyArray<{ size: number }>,
32
32
  multipartMaxBytes: number | null = DEFAULT_MULTIPART_MAX_BYTES
33
- ): Set<string> {
33
+ ): Set<number> {
34
34
  const budget = multipartFileByteBudget(multipartMaxBytes);
35
- const toPreUpload = new Set<string>();
35
+ const toPreUpload = new Set<number>();
36
36
  if (budget === null) return toPreUpload;
37
37
 
38
- for (const file of files) {
39
- if (file.size > budget) {
40
- toPreUpload.add(file.key);
41
- }
42
- }
38
+ files.forEach((file, index) => {
39
+ if (file.size > budget) toPreUpload.add(index);
40
+ });
43
41
 
44
42
  let multipartTotal = 0;
45
- for (const file of files) {
46
- if (!toPreUpload.has(file.key)) multipartTotal += file.size;
47
- }
43
+ files.forEach((file, index) => {
44
+ if (!toPreUpload.has(index)) multipartTotal += file.size;
45
+ });
48
46
 
49
47
  const candidates = files
50
- .filter((file) => !toPreUpload.has(file.key))
51
- .slice()
52
- .sort((a, b) => b.size - a.size || a.key.localeCompare(b.key));
48
+ .map((file, index) => ({ size: file.size, index }))
49
+ .filter(({ index }) => !toPreUpload.has(index))
50
+ .sort((a, b) => b.size - a.size || a.index - b.index);
53
51
 
54
- for (const file of candidates) {
52
+ for (const { size, index } of candidates) {
55
53
  if (multipartTotal <= budget) break;
56
- toPreUpload.add(file.key);
57
- multipartTotal -= file.size;
54
+ toPreUpload.add(index);
55
+ multipartTotal -= size;
58
56
  }
59
57
 
60
58
  return toPreUpload;
61
59
  }
60
+
61
+ /**
62
+ * Field-keyed variant of {@link indicesRequiringPreUpload} for inputs where
63
+ * each key appears once. Ties between equal sizes go to the lexically first key.
64
+ */
65
+ export function keysRequiringPreUpload(
66
+ files: ReadonlyArray<{ key: string; size: number }>,
67
+ multipartMaxBytes: number | null = DEFAULT_MULTIPART_MAX_BYTES
68
+ ): Set<string> {
69
+ const ordered = files.slice().sort((a, b) => a.key.localeCompare(b.key));
70
+ const indices = indicesRequiringPreUpload(ordered, multipartMaxBytes);
71
+ return new Set([...indices].map((index) => ordered[index]!.key));
72
+ }
@@ -523,7 +523,7 @@ type DatasetReviewItemAction =
523
523
  | 'edit-file';
524
524
 
525
525
  function datasetReviewRequestsBaseUrl(automationId: string): string {
526
- return `/v1/automations/${automationId}/dataset-review-requests`;
526
+ return `/v1/automations/${encodeURIComponent(automationId)}/dataset-review-requests`;
527
527
  }
528
528
 
529
529
  function joinCsv(values: string | readonly string[] | undefined): string | undefined {
@@ -674,7 +674,7 @@ export class AutomationDatasetReviewRequestsResource {
674
674
  return this.dispatch(
675
675
  () =>
676
676
  this.client.get({
677
- url: `${datasetReviewRequestsBaseUrl(automationId)}/${reviewId}`,
677
+ url: `${datasetReviewRequestsBaseUrl(automationId)}/${encodeURIComponent(reviewId)}`,
678
678
  signal: options.signal,
679
679
  }) as Promise<OperationResult<AutomationsDatasetReviewRequestsGetResponse>>
680
680
  );
@@ -689,7 +689,7 @@ export class AutomationDatasetReviewRequestsResource {
689
689
  return this.dispatch(
690
690
  () =>
691
691
  this.client.patch({
692
- url: `${datasetReviewRequestsBaseUrl(automationId)}/${reviewId}`,
692
+ url: `${datasetReviewRequestsBaseUrl(automationId)}/${encodeURIComponent(reviewId)}`,
693
693
  body: body as never,
694
694
  signal: options.signal,
695
695
  }) as Promise<OperationResult<AutomationsDatasetReviewRequestsUpdateResponse>>
@@ -705,7 +705,7 @@ export class AutomationDatasetReviewRequestsResource {
705
705
  return this.dispatch(
706
706
  () =>
707
707
  this.client.get({
708
- url: `${datasetReviewRequestsBaseUrl(automationId)}/${reviewId}/items`,
708
+ url: `${datasetReviewRequestsBaseUrl(automationId)}/${encodeURIComponent(reviewId)}/items`,
709
709
  query: { status: joinCsv(status) },
710
710
  signal,
711
711
  }) as Promise<OperationResult<AutomationsDatasetReviewRequestsListItemsResponse>>
@@ -722,7 +722,7 @@ export class AutomationDatasetReviewRequestsResource {
722
722
  return this.dispatch(
723
723
  () =>
724
724
  this.client.patch({
725
- url: `${datasetReviewRequestsBaseUrl(automationId)}/${reviewId}/items/${itemId}`,
725
+ url: `${datasetReviewRequestsBaseUrl(automationId)}/${encodeURIComponent(reviewId)}/items/${encodeURIComponent(itemId)}`,
726
726
  body: body as never,
727
727
  signal: options.signal,
728
728
  }) as Promise<OperationResult<AutomationsDatasetReviewRequestsUpdateItemResponse>>
@@ -749,7 +749,7 @@ export class AutomationDatasetReviewRequestsResource {
749
749
  return this.dispatch(
750
750
  () =>
751
751
  this.client.get({
752
- url: `${datasetReviewRequestsBaseUrl(automationId)}/${reviewId}/items/${itemId}/files/${relative}${suffix}`,
752
+ url: `${datasetReviewRequestsBaseUrl(automationId)}/${encodeURIComponent(reviewId)}/items/${encodeURIComponent(itemId)}/files/${relative}${suffix}`,
753
753
  parseAs: 'blob',
754
754
  signal,
755
755
  }) as Promise<OperationResult<Blob>>,
@@ -772,7 +772,7 @@ export class AutomationDatasetReviewRequestsResource {
772
772
  return this.dispatch(
773
773
  () =>
774
774
  this.client.patch({
775
- url: `${datasetReviewRequestsBaseUrl(automationId)}/${reviewId}/items/${itemId}`,
775
+ url: `${datasetReviewRequestsBaseUrl(automationId)}/${encodeURIComponent(reviewId)}/items/${encodeURIComponent(itemId)}`,
776
776
  body: { action: 'file-decision', ...body } as never,
777
777
  signal: options.signal,
778
778
  }) as Promise<OperationResult<AutomationsDatasetReviewRequestsUpdateItemResponse>>
@@ -805,7 +805,7 @@ export class AutomationDatasetReviewRequestsResource {
805
805
  return this.dispatch(
806
806
  () =>
807
807
  this.client.patch({
808
- url: `${datasetReviewRequestsBaseUrl(automationId)}/${reviewId}/items/${itemId}`,
808
+ url: `${datasetReviewRequestsBaseUrl(automationId)}/${encodeURIComponent(reviewId)}/items/${encodeURIComponent(itemId)}`,
809
809
  body: formData as never,
810
810
  bodySerializer: null,
811
811
  headers: { 'Content-Type': null },
@@ -822,7 +822,7 @@ export class AutomationDatasetReviewRequestsResource {
822
822
  return this.dispatch(
823
823
  () =>
824
824
  this.client.get({
825
- url: `${datasetReviewRequestsBaseUrl(automationId)}/${reviewId}/events`,
825
+ url: `${datasetReviewRequestsBaseUrl(automationId)}/${encodeURIComponent(reviewId)}/events`,
826
826
  signal: options.signal,
827
827
  }) as Promise<OperationResult<AutomationsDatasetReviewRequestsListEventsResponse>>
828
828
  );
@@ -1,4 +1,4 @@
1
- import type { OperationResult } from '../client';
1
+ import type { OperationResult, RequestDispatchOptions } from '../client';
2
2
  import type { Client } from '../generated/client';
3
3
  import {
4
4
  runsArtifactsGet,
@@ -47,7 +47,10 @@ import type {
47
47
  } from '../generated/types.gen';
48
48
  import { buildSingleFileMultipart, type FileInput } from '../lib/files';
49
49
 
50
- type Dispatch = <T>(call: () => Promise<OperationResult<T>>) => Promise<T>;
50
+ type Dispatch = <T>(
51
+ call: () => Promise<OperationResult<T>>,
52
+ options?: RequestDispatchOptions
53
+ ) => Promise<T>;
51
54
  type SignalOptions = { signal?: AbortSignal };
52
55
 
53
56
  export type ListRunsOptions = NonNullable<RunsListData['query']> & { signal?: AbortSignal };
@@ -123,8 +126,10 @@ export class RunsResource {
123
126
  query: { version?: string; wait_for_completion?: number } = {},
124
127
  options: SignalOptions = {}
125
128
  ): Promise<RunsRerunResponse> {
126
- return this.dispatch(() =>
127
- runsRerun({ client: this.client, path: { id: runId }, query, signal: options.signal })
129
+ // Rerun starts a new billed run: never retry it on a lost response.
130
+ return this.dispatch(
131
+ () => runsRerun({ client: this.client, path: { id: runId }, query, signal: options.signal }),
132
+ { nonIdempotent: true }
128
133
  );
129
134
  }
130
135
 
@@ -165,14 +170,6 @@ export function runOutput(run: unknown): unknown {
165
170
  return isRecord(run) ? run.output : undefined;
166
171
  }
167
172
 
168
- export function runUsage(run: unknown): unknown {
169
- return isRecord(run) ? run.usage : undefined;
170
- }
171
-
172
- export function runExecutionDetails(run: unknown): unknown {
173
- return isRecord(run) ? run.execution : undefined;
174
- }
175
-
176
173
  export class RunsArtifactsResource {
177
174
  constructor(
178
175
  private readonly client: Client,
@@ -3,11 +3,10 @@ import type { CreateClientConfig } from './generated/client.gen';
3
3
  /**
4
4
  * Runtime configuration hook for the generated hey-api client.
5
5
  *
6
- * The hand-written `EigenpalClient` class in `client.ts` calls
7
- * `setClientConfig()` on construction with the user's `apiKey` and
8
- * `baseUrl`, so the generated SDK functions automatically pick up the
9
- * Authorization header. This factory returns a no-op default — values
10
- * are populated when an `EigenpalClient` instance is created.
6
+ * This hook only affects direct use of the generated SDK functions in
7
+ * `@eigenpal/sdk/generated`. `EigenpalClient` in `client.ts` creates its own
8
+ * client with `createClient(config)` and does not go through this factory.
9
+ * The default baseUrl here is used only when a caller does not pass one.
11
10
  */
12
11
  export const createClientConfig: CreateClientConfig = (config) => ({
13
12
  ...config,
package/src/telemetry.ts CHANGED
@@ -19,7 +19,7 @@
19
19
  export const SDK_LANGUAGE = 'typescript';
20
20
  // Rewritten at publish time by scripts/release/platform/render-sdk-versions.sh.
21
21
  // Keep this string literal exactly stable — sed matches on it.
22
- export const SDK_VERSION = '0.23.6';
22
+ export const SDK_VERSION = '0.23.7';
23
23
 
24
24
  function detectRuntime(): string {
25
25
  const g = globalThis as unknown as {
package/src/upload.ts ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * `@eigenpal/sdk/upload`: the canonical upload protocol helpers (presigned
3
+ * multipart, app-chunked, presigned PUT, multipart body budget).
4
+ *
5
+ * The EigenPal CLI and app import these instead of keeping their own copies,
6
+ * so abort-safety rules (never abort once storage holds the bytes) live in
7
+ * exactly one place.
8
+ */
9
+ export * from './lib/fetch-body';
10
+ export * from './lib/upload-app-chunked';
11
+ export * from './lib/upload-limits';
12
+ export * from './lib/upload-presigned-multipart';