@aignostics/sdk 3.5.0 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,6 @@
1
- import { R as RunReadResponse, I as ItemResultReadResponse, A as ApplicationReadShortResponse, a as ApplicationReadResponse, b as RunCreationRequest, c as RunCreationResponse, d as ItemState, e as ItemTerminationReason, V as VersionReadResponse } from './api-CrZaHZZr.cjs';
2
- export { f as ApplicationVersion, g as ArtifactOutput, h as ArtifactState, i as ArtifactTerminationReason, an as Configuration, am as ConfigurationParameters, C as CustomMetadataUpdateRequest, j as CustomMetadataUpdateResponse, G as GrantCreateRequest, k as GrantReadResponse, l as GrantRelation, H as HTTPValidationError, m as InputArtifact, n as InputArtifactCreationRequest, o as InputArtifactResultReadResponse, p as ItemCreationRequest, q as ItemOutput, M as MeReadResponse, O as OrganizationReadResponse, r as OutputArtifact, s as OutputArtifactResultReadResponse, t as OutputArtifactScope, u as OutputArtifactVisibility, al as PublicApi, Y as PublicApiApplicationVersionDetailsV1ApplicationsApplicationIdVersionsVersionGetRequest, Q as PublicApiAxiosParamCreator, Z as PublicApiCancelRunV1RunsRunIdCancelPostRequest, _ as PublicApiCreateGrantV1AccessGrantsPostRequest, $ as PublicApiCreateRunV1RunsPostRequest, a0 as PublicApiCreateShareTokenV1AccessShareTokensPostRequest, a1 as PublicApiDeleteRunItemsV1RunsRunIdArtifactsDeleteRequest, W as PublicApiFactory, T as PublicApiFp, a2 as PublicApiGetArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGetRequest, a3 as PublicApiGetGrantV1AccessGrantsGrantIdGetRequest, a4 as PublicApiGetItemByRunV1RunsRunIdItemsExternalIdGetRequest, a5 as PublicApiGetRunV1RunsRunIdGetRequest, a6 as PublicApiGetShareTokenV1AccessShareTokensShareTokenIdGetRequest, a8 as PublicApiGetVersionDocumentContentRequest, a9 as PublicApiGetVersionDocumentFileRequest, a7 as PublicApiGetVersionDocumentRequest, X as PublicApiInterface, aa as PublicApiListApplicationsV1ApplicationsGetRequest, ab as PublicApiListGrantsV1AccessGrantsGetRequest, ac as PublicApiListRunItemsV1RunsRunIdItemsGetRequest, ad as PublicApiListRunsV1RunsGetRequest, ae as PublicApiListShareTokensV1AccessShareTokensGetRequest, af as PublicApiListVersionDocumentsRequest, ag as PublicApiPutItemCustomMetadataByRunV1RunsRunIdItemsExternalIdCustomMetadataPutRequest, ah as PublicApiPutRunCustomMetadataV1RunsRunIdCustomMetadataPutRequest, ai as PublicApiReadApplicationByIdV1ApplicationsApplicationIdGetRequest, aj as PublicApiRevokeGrantV1AccessGrantsGrantIdDeleteRequest, ak as PublicApiRevokeShareTokenV1AccessShareTokensShareTokenIdDeleteRequest, v as ResourceType, w as RunItemStatistics, x as RunOutput, y as RunState, z as RunTerminationReason, S as SchedulingRequest, B as SchedulingResponse, D as ShareTokenCreateRequest, E as ShareTokenCreateResponse, F as ShareTokenReadResponse, J as SubjectType, U as UserReadResponse, K as ValidationError, L as ValidationErrorLocInner, N as VersionDocumentResponse, P as VersionDocumentVisibility } from './api-CrZaHZZr.cjs';
1
+ import { R as RunReadResponse, I as ItemResultReadResponse, A as ApplicationReadShortResponse, a as ApplicationReadResponse, b as RunCreationRequest, c as RunCreationResponse, d as ItemState, e as ItemTerminationReason, V as VersionReadResponse } from './api-B0sQ1mLM.cjs';
2
+ export { f as ApplicationVersion, g as ArtifactOutput, h as ArtifactState, i as ArtifactTerminationReason, an as Configuration, am as ConfigurationParameters, C as CustomMetadataUpdateRequest, j as CustomMetadataUpdateResponse, G as GrantCreateRequest, k as GrantReadResponse, l as GrantRelation, H as HTTPValidationError, m as InputArtifact, n as InputArtifactCreationRequest, o as InputArtifactResultReadResponse, p as ItemCreationRequest, q as ItemOutput, M as MeReadResponse, O as OrganizationReadResponse, r as OutputArtifact, s as OutputArtifactResultReadResponse, t as OutputArtifactScope, u as OutputArtifactVisibility, al as PublicApi, Y as PublicApiApplicationVersionDetailsV1ApplicationsApplicationIdVersionsVersionGetRequest, Q as PublicApiAxiosParamCreator, Z as PublicApiCancelRunV1RunsRunIdCancelPostRequest, _ as PublicApiCreateGrantV1AccessGrantsPostRequest, $ as PublicApiCreateRunV1RunsPostRequest, a0 as PublicApiCreateShareTokenV1AccessShareTokensPostRequest, a1 as PublicApiDeleteRunItemsV1RunsRunIdArtifactsDeleteRequest, W as PublicApiFactory, T as PublicApiFp, a2 as PublicApiGetArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGetRequest, a3 as PublicApiGetGrantV1AccessGrantsGrantIdGetRequest, a4 as PublicApiGetItemByRunV1RunsRunIdItemsExternalIdGetRequest, a5 as PublicApiGetRunV1RunsRunIdGetRequest, a6 as PublicApiGetShareTokenV1AccessShareTokensShareTokenIdGetRequest, a8 as PublicApiGetVersionDocumentContentRequest, a9 as PublicApiGetVersionDocumentFileRequest, a7 as PublicApiGetVersionDocumentRequest, X as PublicApiInterface, aa as PublicApiListApplicationsV1ApplicationsGetRequest, ab as PublicApiListGrantsV1AccessGrantsGetRequest, ac as PublicApiListRunItemsV1RunsRunIdItemsGetRequest, ad as PublicApiListRunsV1RunsGetRequest, ae as PublicApiListShareTokensV1AccessShareTokensGetRequest, af as PublicApiListVersionDocumentsRequest, ag as PublicApiPutItemCustomMetadataByRunV1RunsRunIdItemsExternalIdCustomMetadataPutRequest, ah as PublicApiPutRunCustomMetadataV1RunsRunIdCustomMetadataPutRequest, ai as PublicApiReadApplicationByIdV1ApplicationsApplicationIdGetRequest, aj as PublicApiRevokeGrantV1AccessGrantsGrantIdDeleteRequest, ak as PublicApiRevokeShareTokenV1AccessShareTokensShareTokenIdDeleteRequest, v as ResourceType, w as RunItemStatistics, x as RunOutput, y as RunState, z as RunTerminationReason, S as SchedulingRequest, B as SchedulingResponse, D as ShareTokenCreateRequest, E as ShareTokenCreateResponse, F as ShareTokenReadResponse, J as SubjectType, U as UserReadResponse, K as ValidationError, L as ValidationErrorLocInner, N as VersionDocumentResponse, P as VersionDocumentVisibility } from './api-B0sQ1mLM.cjs';
3
+ import { Readable } from 'node:stream';
3
4
  import 'axios';
4
5
 
5
6
  /**
@@ -18,7 +19,7 @@ interface ApplicationRun extends RunReadResponse {
18
19
  can_download: boolean;
19
20
  }
20
21
  /** Derived run status that simplifies the raw `state` + `termination_reason` combination. */
21
- type RunStatus = 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'COMPLETED_WITH_ERRORS' | 'CANCELED' | 'FAILED';
22
+ type RunStatus = 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'COMPLETED_WITH_ERRORS' | 'CANCELED' | 'FAILED' | 'UNKNOWN';
22
23
 
23
24
  /**
24
25
  * Enriched run-item entity that extends the raw API response
@@ -34,7 +35,7 @@ interface ApplicationRunItem extends ItemResultReadResponse {
34
35
  status: string;
35
36
  }
36
37
  /** Derived item status that simplifies the raw `state` + `termination_reason` combination. */
37
- type ItemStatus = 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'FAILED' | 'SKIPPED';
38
+ type ItemStatus = 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'FAILED' | 'SKIPPED' | 'UNKNOWN';
38
39
 
39
40
  /**
40
41
  * Token provider function that returns a valid access token
@@ -85,6 +86,7 @@ interface PlatformSDK {
85
86
  }): Promise<ApplicationRunItem[]>;
86
87
  getApplicationVersionDetails(applicationId: string, version: string): Promise<VersionReadResponse>;
87
88
  downloadArtifact(runId: string, artifactId: string): Promise<ArrayBuffer>;
89
+ downloadArtifactStream(runId: string, artifactId: string): Promise<Readable>;
88
90
  }
89
91
  /**
90
92
  * Main SDK class for interacting with the Aignostics Platform
@@ -453,6 +455,40 @@ declare class PlatformSDKHttp implements PlatformSDK {
453
455
  * ```
454
456
  */
455
457
  downloadArtifact(runId: string, artifactId: string): Promise<ArrayBuffer>;
458
+ /**
459
+ * Download an artifact file from a completed application run as a stream
460
+ *
461
+ * Prefer this method over `downloadArtifact` when downloading large (e.g. multi-gigabyte)
462
+ * artifacts: instead of buffering the entire file into memory before returning it, this
463
+ * method streams the artifact's bytes as they arrive, keeping memory usage low regardless
464
+ * of the artifact's size.
465
+ *
466
+ * The download is performed with automatic retries for transient failures.
467
+ * Non-retryable HTTP status codes (403, 404, 410, 422) will abort immediately.
468
+ *
469
+ * @param runId - The unique identifier of the application run
470
+ * @param artifactId - The unique identifier of the artifact to download
471
+ * @returns A promise that resolves to a Node.js `Readable` stream yielding the artifact's binary content
472
+ * @throws {AuthenticationError} If no valid authentication token is available
473
+ * @throws {APIError} If the API request fails (e.g., 403, 404, 410, 422, or other HTTP errors)
474
+ * @throws {UnexpectedError} If a non-HTTP error occurs
475
+ *
476
+ * @example
477
+ * ```typescript
478
+ * import { pipeline } from 'node:stream/promises';
479
+ * import { createWriteStream } from 'node:fs';
480
+ *
481
+ * const stream = await sdk.downloadArtifactStream('run-123', 'artifact-456');
482
+ * await pipeline(stream, createWriteStream('output.bin'));
483
+ * ```
484
+ *
485
+ * @remarks
486
+ * Retries only cover failures at the initial-request stage (a non-2xx status surfaced from
487
+ * the response headers before the body begins streaming). Once the response body has started
488
+ * streaming, a mid-stream connection drop CANNOT be retried by this method — the consumer must
489
+ * listen for the stream's `error` event and re-download if needed.
490
+ */
491
+ downloadArtifactStream(runId: string, artifactId: string): Promise<Readable>;
456
492
  }
457
493
 
458
494
  type ErrorCode = 'AUTHENTICATION_ERROR' | 'API_ERROR' | 'CONFIGURATION_ERROR' | 'UNEXPECTED_ERROR';
@@ -564,14 +600,18 @@ declare const processApplicationRun: (run: RunReadResponse) => ApplicationRun;
564
600
  */
565
601
  declare function getRunProgress(run: RunReadResponse): number;
566
602
  /**
567
- * Derive a human-readable {@link RunStatus} from the raw API `state` and `termination_reason`.
603
+ * Derive a human-readable {@link RunStatus} from the raw API `state`,
604
+ * `termination_reason`, and `output`.
568
605
  *
569
606
  * Mapping rules:
570
607
  * - PENDING / PROCESSING → passed through as-is
571
608
  * - TERMINATED + CANCELED_BY_USER → CANCELED
572
- * - TERMINATED + CANCELED_BY_SYSTEM → FAILED
573
- * - TERMINATED + not all items succeeded → COMPLETED_WITH_ERRORS
574
- * - TERMINATED + all items succeeded → COMPLETED
609
+ * - TERMINATED + CANCELED_BY_SYSTEM or ALL_ITEMS_PROCESSED → derived from `output`:
610
+ * - NONE → FAILED (no items succeeded)
611
+ * - PARTIAL → COMPLETED_WITH_ERRORS (some items succeeded)
612
+ * - FULL → COMPLETED (all items succeeded)
613
+ * - otherwise → UNKNOWN
614
+ * - any other termination reason, or non-terminal state, → UNKNOWN
575
615
  *
576
616
  * @param run - Raw run response from the API
577
617
  */
@@ -610,9 +650,11 @@ declare const canDownloadItem: (item: ItemResultReadResponse) => boolean;
610
650
  *
611
651
  * Mapping rules:
612
652
  * - PENDING / PROCESSING → passed through as-is
613
- * - TERMINATED + SYSTEM_ERROR or USER_ERROR → FAILED
653
+ * - TERMINATED + no termination_reason → UNKNOWN
654
+ * - TERMINATED + an error reason (SYSTEM_ERROR, USER_ERROR, CANCELED_BY_SYSTEM, CANCELED_BY_USER) → FAILED
614
655
  * - TERMINATED + SKIPPED → SKIPPED
615
- * - TERMINATED (otherwise) → COMPLETED
656
+ * - TERMINATED + SUCCEEDED → COMPLETED
657
+ * - TERMINATED + any unrecognized reason → UNKNOWN
616
658
  *
617
659
  * @param item - Raw item response from the API
618
660
  */
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { R as RunReadResponse, I as ItemResultReadResponse, A as ApplicationReadShortResponse, a as ApplicationReadResponse, b as RunCreationRequest, c as RunCreationResponse, d as ItemState, e as ItemTerminationReason, V as VersionReadResponse } from './api-CrZaHZZr.js';
2
- export { f as ApplicationVersion, g as ArtifactOutput, h as ArtifactState, i as ArtifactTerminationReason, an as Configuration, am as ConfigurationParameters, C as CustomMetadataUpdateRequest, j as CustomMetadataUpdateResponse, G as GrantCreateRequest, k as GrantReadResponse, l as GrantRelation, H as HTTPValidationError, m as InputArtifact, n as InputArtifactCreationRequest, o as InputArtifactResultReadResponse, p as ItemCreationRequest, q as ItemOutput, M as MeReadResponse, O as OrganizationReadResponse, r as OutputArtifact, s as OutputArtifactResultReadResponse, t as OutputArtifactScope, u as OutputArtifactVisibility, al as PublicApi, Y as PublicApiApplicationVersionDetailsV1ApplicationsApplicationIdVersionsVersionGetRequest, Q as PublicApiAxiosParamCreator, Z as PublicApiCancelRunV1RunsRunIdCancelPostRequest, _ as PublicApiCreateGrantV1AccessGrantsPostRequest, $ as PublicApiCreateRunV1RunsPostRequest, a0 as PublicApiCreateShareTokenV1AccessShareTokensPostRequest, a1 as PublicApiDeleteRunItemsV1RunsRunIdArtifactsDeleteRequest, W as PublicApiFactory, T as PublicApiFp, a2 as PublicApiGetArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGetRequest, a3 as PublicApiGetGrantV1AccessGrantsGrantIdGetRequest, a4 as PublicApiGetItemByRunV1RunsRunIdItemsExternalIdGetRequest, a5 as PublicApiGetRunV1RunsRunIdGetRequest, a6 as PublicApiGetShareTokenV1AccessShareTokensShareTokenIdGetRequest, a8 as PublicApiGetVersionDocumentContentRequest, a9 as PublicApiGetVersionDocumentFileRequest, a7 as PublicApiGetVersionDocumentRequest, X as PublicApiInterface, aa as PublicApiListApplicationsV1ApplicationsGetRequest, ab as PublicApiListGrantsV1AccessGrantsGetRequest, ac as PublicApiListRunItemsV1RunsRunIdItemsGetRequest, ad as PublicApiListRunsV1RunsGetRequest, ae as PublicApiListShareTokensV1AccessShareTokensGetRequest, af as PublicApiListVersionDocumentsRequest, ag as PublicApiPutItemCustomMetadataByRunV1RunsRunIdItemsExternalIdCustomMetadataPutRequest, ah as PublicApiPutRunCustomMetadataV1RunsRunIdCustomMetadataPutRequest, ai as PublicApiReadApplicationByIdV1ApplicationsApplicationIdGetRequest, aj as PublicApiRevokeGrantV1AccessGrantsGrantIdDeleteRequest, ak as PublicApiRevokeShareTokenV1AccessShareTokensShareTokenIdDeleteRequest, v as ResourceType, w as RunItemStatistics, x as RunOutput, y as RunState, z as RunTerminationReason, S as SchedulingRequest, B as SchedulingResponse, D as ShareTokenCreateRequest, E as ShareTokenCreateResponse, F as ShareTokenReadResponse, J as SubjectType, U as UserReadResponse, K as ValidationError, L as ValidationErrorLocInner, N as VersionDocumentResponse, P as VersionDocumentVisibility } from './api-CrZaHZZr.js';
1
+ import { R as RunReadResponse, I as ItemResultReadResponse, A as ApplicationReadShortResponse, a as ApplicationReadResponse, b as RunCreationRequest, c as RunCreationResponse, d as ItemState, e as ItemTerminationReason, V as VersionReadResponse } from './api-B0sQ1mLM.js';
2
+ export { f as ApplicationVersion, g as ArtifactOutput, h as ArtifactState, i as ArtifactTerminationReason, an as Configuration, am as ConfigurationParameters, C as CustomMetadataUpdateRequest, j as CustomMetadataUpdateResponse, G as GrantCreateRequest, k as GrantReadResponse, l as GrantRelation, H as HTTPValidationError, m as InputArtifact, n as InputArtifactCreationRequest, o as InputArtifactResultReadResponse, p as ItemCreationRequest, q as ItemOutput, M as MeReadResponse, O as OrganizationReadResponse, r as OutputArtifact, s as OutputArtifactResultReadResponse, t as OutputArtifactScope, u as OutputArtifactVisibility, al as PublicApi, Y as PublicApiApplicationVersionDetailsV1ApplicationsApplicationIdVersionsVersionGetRequest, Q as PublicApiAxiosParamCreator, Z as PublicApiCancelRunV1RunsRunIdCancelPostRequest, _ as PublicApiCreateGrantV1AccessGrantsPostRequest, $ as PublicApiCreateRunV1RunsPostRequest, a0 as PublicApiCreateShareTokenV1AccessShareTokensPostRequest, a1 as PublicApiDeleteRunItemsV1RunsRunIdArtifactsDeleteRequest, W as PublicApiFactory, T as PublicApiFp, a2 as PublicApiGetArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGetRequest, a3 as PublicApiGetGrantV1AccessGrantsGrantIdGetRequest, a4 as PublicApiGetItemByRunV1RunsRunIdItemsExternalIdGetRequest, a5 as PublicApiGetRunV1RunsRunIdGetRequest, a6 as PublicApiGetShareTokenV1AccessShareTokensShareTokenIdGetRequest, a8 as PublicApiGetVersionDocumentContentRequest, a9 as PublicApiGetVersionDocumentFileRequest, a7 as PublicApiGetVersionDocumentRequest, X as PublicApiInterface, aa as PublicApiListApplicationsV1ApplicationsGetRequest, ab as PublicApiListGrantsV1AccessGrantsGetRequest, ac as PublicApiListRunItemsV1RunsRunIdItemsGetRequest, ad as PublicApiListRunsV1RunsGetRequest, ae as PublicApiListShareTokensV1AccessShareTokensGetRequest, af as PublicApiListVersionDocumentsRequest, ag as PublicApiPutItemCustomMetadataByRunV1RunsRunIdItemsExternalIdCustomMetadataPutRequest, ah as PublicApiPutRunCustomMetadataV1RunsRunIdCustomMetadataPutRequest, ai as PublicApiReadApplicationByIdV1ApplicationsApplicationIdGetRequest, aj as PublicApiRevokeGrantV1AccessGrantsGrantIdDeleteRequest, ak as PublicApiRevokeShareTokenV1AccessShareTokensShareTokenIdDeleteRequest, v as ResourceType, w as RunItemStatistics, x as RunOutput, y as RunState, z as RunTerminationReason, S as SchedulingRequest, B as SchedulingResponse, D as ShareTokenCreateRequest, E as ShareTokenCreateResponse, F as ShareTokenReadResponse, J as SubjectType, U as UserReadResponse, K as ValidationError, L as ValidationErrorLocInner, N as VersionDocumentResponse, P as VersionDocumentVisibility } from './api-B0sQ1mLM.js';
3
+ import { Readable } from 'node:stream';
3
4
  import 'axios';
4
5
 
5
6
  /**
@@ -18,7 +19,7 @@ interface ApplicationRun extends RunReadResponse {
18
19
  can_download: boolean;
19
20
  }
20
21
  /** Derived run status that simplifies the raw `state` + `termination_reason` combination. */
21
- type RunStatus = 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'COMPLETED_WITH_ERRORS' | 'CANCELED' | 'FAILED';
22
+ type RunStatus = 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'COMPLETED_WITH_ERRORS' | 'CANCELED' | 'FAILED' | 'UNKNOWN';
22
23
 
23
24
  /**
24
25
  * Enriched run-item entity that extends the raw API response
@@ -34,7 +35,7 @@ interface ApplicationRunItem extends ItemResultReadResponse {
34
35
  status: string;
35
36
  }
36
37
  /** Derived item status that simplifies the raw `state` + `termination_reason` combination. */
37
- type ItemStatus = 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'FAILED' | 'SKIPPED';
38
+ type ItemStatus = 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'FAILED' | 'SKIPPED' | 'UNKNOWN';
38
39
 
39
40
  /**
40
41
  * Token provider function that returns a valid access token
@@ -85,6 +86,7 @@ interface PlatformSDK {
85
86
  }): Promise<ApplicationRunItem[]>;
86
87
  getApplicationVersionDetails(applicationId: string, version: string): Promise<VersionReadResponse>;
87
88
  downloadArtifact(runId: string, artifactId: string): Promise<ArrayBuffer>;
89
+ downloadArtifactStream(runId: string, artifactId: string): Promise<Readable>;
88
90
  }
89
91
  /**
90
92
  * Main SDK class for interacting with the Aignostics Platform
@@ -453,6 +455,40 @@ declare class PlatformSDKHttp implements PlatformSDK {
453
455
  * ```
454
456
  */
455
457
  downloadArtifact(runId: string, artifactId: string): Promise<ArrayBuffer>;
458
+ /**
459
+ * Download an artifact file from a completed application run as a stream
460
+ *
461
+ * Prefer this method over `downloadArtifact` when downloading large (e.g. multi-gigabyte)
462
+ * artifacts: instead of buffering the entire file into memory before returning it, this
463
+ * method streams the artifact's bytes as they arrive, keeping memory usage low regardless
464
+ * of the artifact's size.
465
+ *
466
+ * The download is performed with automatic retries for transient failures.
467
+ * Non-retryable HTTP status codes (403, 404, 410, 422) will abort immediately.
468
+ *
469
+ * @param runId - The unique identifier of the application run
470
+ * @param artifactId - The unique identifier of the artifact to download
471
+ * @returns A promise that resolves to a Node.js `Readable` stream yielding the artifact's binary content
472
+ * @throws {AuthenticationError} If no valid authentication token is available
473
+ * @throws {APIError} If the API request fails (e.g., 403, 404, 410, 422, or other HTTP errors)
474
+ * @throws {UnexpectedError} If a non-HTTP error occurs
475
+ *
476
+ * @example
477
+ * ```typescript
478
+ * import { pipeline } from 'node:stream/promises';
479
+ * import { createWriteStream } from 'node:fs';
480
+ *
481
+ * const stream = await sdk.downloadArtifactStream('run-123', 'artifact-456');
482
+ * await pipeline(stream, createWriteStream('output.bin'));
483
+ * ```
484
+ *
485
+ * @remarks
486
+ * Retries only cover failures at the initial-request stage (a non-2xx status surfaced from
487
+ * the response headers before the body begins streaming). Once the response body has started
488
+ * streaming, a mid-stream connection drop CANNOT be retried by this method — the consumer must
489
+ * listen for the stream's `error` event and re-download if needed.
490
+ */
491
+ downloadArtifactStream(runId: string, artifactId: string): Promise<Readable>;
456
492
  }
457
493
 
458
494
  type ErrorCode = 'AUTHENTICATION_ERROR' | 'API_ERROR' | 'CONFIGURATION_ERROR' | 'UNEXPECTED_ERROR';
@@ -564,14 +600,18 @@ declare const processApplicationRun: (run: RunReadResponse) => ApplicationRun;
564
600
  */
565
601
  declare function getRunProgress(run: RunReadResponse): number;
566
602
  /**
567
- * Derive a human-readable {@link RunStatus} from the raw API `state` and `termination_reason`.
603
+ * Derive a human-readable {@link RunStatus} from the raw API `state`,
604
+ * `termination_reason`, and `output`.
568
605
  *
569
606
  * Mapping rules:
570
607
  * - PENDING / PROCESSING → passed through as-is
571
608
  * - TERMINATED + CANCELED_BY_USER → CANCELED
572
- * - TERMINATED + CANCELED_BY_SYSTEM → FAILED
573
- * - TERMINATED + not all items succeeded → COMPLETED_WITH_ERRORS
574
- * - TERMINATED + all items succeeded → COMPLETED
609
+ * - TERMINATED + CANCELED_BY_SYSTEM or ALL_ITEMS_PROCESSED → derived from `output`:
610
+ * - NONE → FAILED (no items succeeded)
611
+ * - PARTIAL → COMPLETED_WITH_ERRORS (some items succeeded)
612
+ * - FULL → COMPLETED (all items succeeded)
613
+ * - otherwise → UNKNOWN
614
+ * - any other termination reason, or non-terminal state, → UNKNOWN
575
615
  *
576
616
  * @param run - Raw run response from the API
577
617
  */
@@ -610,9 +650,11 @@ declare const canDownloadItem: (item: ItemResultReadResponse) => boolean;
610
650
  *
611
651
  * Mapping rules:
612
652
  * - PENDING / PROCESSING → passed through as-is
613
- * - TERMINATED + SYSTEM_ERROR or USER_ERROR → FAILED
653
+ * - TERMINATED + no termination_reason → UNKNOWN
654
+ * - TERMINATED + an error reason (SYSTEM_ERROR, USER_ERROR, CANCELED_BY_SYSTEM, CANCELED_BY_USER) → FAILED
614
655
  * - TERMINATED + SKIPPED → SKIPPED
615
- * - TERMINATED (otherwise) → COMPLETED
656
+ * - TERMINATED + SUCCEEDED → COMPLETED
657
+ * - TERMINATED + any unrecognized reason → UNKNOWN
616
658
  *
617
659
  * @param item - Raw item response from the API
618
660
  */
package/dist/index.js CHANGED
@@ -638,6 +638,7 @@ var PublicApiAxiosParamCreator = function(configuration) {
638
638
  * @param {string | null} [resourceId]
639
639
  * @param {SubjectType | null} [subjectType]
640
640
  * @param {string | null} [subjectId]
641
+ * @param {Array<GrantRelation> | null} [relation] Filter grants by relation type. Can be specified multiple times.
641
642
  * @param {boolean | null} [revoked]
642
643
  * @param {number} [page]
643
644
  * @param {number} [pageSize]
@@ -645,7 +646,7 @@ var PublicApiAxiosParamCreator = function(configuration) {
645
646
  * @param {*} [options] Override http request option.
646
647
  * @throws {RequiredError}
647
648
  */
648
- listGrantsV1AccessGrantsGet: async (resourceType, resourceId, subjectType, subjectId, revoked, page, pageSize, sort, options = {}) => {
649
+ listGrantsV1AccessGrantsGet: async (resourceType, resourceId, subjectType, subjectId, relation, revoked, page, pageSize, sort, options = {}) => {
649
650
  const localVarPath = `/v1/access/grants`;
650
651
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
651
652
  let baseOptions;
@@ -668,6 +669,9 @@ var PublicApiAxiosParamCreator = function(configuration) {
668
669
  if (subjectId !== void 0) {
669
670
  localVarQueryParameter["subject_id"] = subjectId;
670
671
  }
672
+ if (relation) {
673
+ localVarQueryParameter["relation"] = relation;
674
+ }
671
675
  if (revoked !== void 0) {
672
676
  localVarQueryParameter["revoked"] = revoked;
673
677
  }
@@ -760,12 +764,14 @@ var PublicApiAxiosParamCreator = function(configuration) {
760
764
  * @param {string | null} [customMetadata] Use PostgreSQL JSONPath expressions to filter runs by their custom_metadata. #### URL Encoding Required **Important**: JSONPath expressions contain special characters that must be URL-encoded when used in query parameters. Most HTTP clients handle this automatically, but when constructing URLs manually, please ensure proper encoding. #### Examples (Clear Format): - **Field existence**: &#x60;$.study&#x60; - Runs that have a study field defined - **Exact value match**: &#x60;$.study ? (@ &#x3D;&#x3D; \&quot;high\&quot;)&#x60; - Runs with specific study value - **Numeric comparison**: &#x60;$.confidence_score ? (@ &gt; 0.75)&#x60; - Runs with confidence score greater than 0.75 - **Array operations**: &#x60;$.tags[*] ? (@ &#x3D;&#x3D; \&quot;draft\&quot;)&#x60; - Runs with tags array containing \&quot;draft\&quot; - **Complex conditions**: &#x60;$.resources ? (@.gpu_count &gt; 2 &amp;&amp; @.memory_gb &gt;&#x3D; 16)&#x60; - Runs with high resource requirements #### Examples (URL-Encoded Format): - **Field existence**: &#x60;%24.study&#x60; - **Exact value match**: &#x60;%24.study%20%3F%20(%40%20%3D%3D%20%22high%22)&#x60; - **Numeric comparison**: &#x60;%24.confidence_score%20%3F%20(%40%20%3E%200.75)&#x60; - **Array operations**: &#x60;%24.tags%5B*%5D%20%3F%20(%40%20%3D%3D%20%22draft%22)&#x60; - **Complex conditions**: &#x60;%24.resources%20%3F%20(%40.gpu_count%20%3E%202%20%26%26%20%40.memory_gb%20%3E%3D%2016)&#x60; #### Notes - JSONPath expressions are evaluated using PostgreSQL\&#39;s &#x60;@?&#x60; operator - The &#x60;$.&#x60; prefix is automatically added to root-level field references if missing - String values in conditions must be enclosed in double quotes - Use &#x60;&amp;&amp;&#x60; for AND operations and &#x60;||&#x60; for OR operations - Regular expressions use &#x60;like_regex&#x60; with standard regex syntax - **Please remember to URL-encode the entire JSONPath expression when making HTTP requests**
761
765
  * @param {number} [page]
762
766
  * @param {number} [pageSize]
767
+ * @param {string | null} [submittedBy] Filter runs by the user who submitted them. Use the special value &#x60;me&#x60; to return only runs submitted by the current user.
768
+ * @param {string | null} [organizationId] Filter runs by the organization of the submitter. Use the special value &#x60;my_org&#x60; to filter by the current user\&#39;s organization.
763
769
  * @param {string | null} [forOrganization] Filter runs by organization ID. Available for superadmins (any org) and admins (own org only). When provided, returns all runs for the specified organization instead of only the caller\&#39;s own runs.
764
770
  * @param {Array<string> | null} [sort] Sort the results by one or more fields. Use &#x60;+&#x60; for ascending and &#x60;-&#x60; for descending order. **Available fields:** - &#x60;run_id&#x60; - &#x60;application_id&#x60; - &#x60;version_number&#x60; - &#x60;custom_metadata&#x60; - &#x60;submitted_at&#x60; - &#x60;submitted_by&#x60; - &#x60;terminated_at&#x60; - &#x60;termination_reason&#x60; **Examples:** - &#x60;?sort&#x3D;submitted_at&#x60; - Sort by creation time (ascending) - &#x60;?sort&#x3D;-submitted_at&#x60; - Sort by creation time (descending) - &#x60;?sort&#x3D;state&amp;sort&#x3D;-submitted_at&#x60; - Sort by state, then by time (descending)
765
771
  * @param {*} [options] Override http request option.
766
772
  * @throws {RequiredError}
767
773
  */
768
- listRunsV1RunsGet: async (applicationId, applicationVersion, externalId, customMetadata, page, pageSize, forOrganization, sort, options = {}) => {
774
+ listRunsV1RunsGet: async (applicationId, applicationVersion, externalId, customMetadata, page, pageSize, submittedBy, organizationId, forOrganization, sort, options = {}) => {
769
775
  const localVarPath = `/v1/runs`;
770
776
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
771
777
  let baseOptions;
@@ -794,6 +800,12 @@ var PublicApiAxiosParamCreator = function(configuration) {
794
800
  if (pageSize !== void 0) {
795
801
  localVarQueryParameter["page_size"] = pageSize;
796
802
  }
803
+ if (submittedBy !== void 0) {
804
+ localVarQueryParameter["submitted_by"] = submittedBy;
805
+ }
806
+ if (organizationId !== void 0) {
807
+ localVarQueryParameter["organization_id"] = organizationId;
808
+ }
797
809
  if (forOrganization !== void 0) {
798
810
  localVarQueryParameter["for_organization"] = forOrganization;
799
811
  }
@@ -1264,6 +1276,7 @@ var PublicApiFp = function(configuration) {
1264
1276
  * @param {string | null} [resourceId]
1265
1277
  * @param {SubjectType | null} [subjectType]
1266
1278
  * @param {string | null} [subjectId]
1279
+ * @param {Array<GrantRelation> | null} [relation] Filter grants by relation type. Can be specified multiple times.
1267
1280
  * @param {boolean | null} [revoked]
1268
1281
  * @param {number} [page]
1269
1282
  * @param {number} [pageSize]
@@ -1271,8 +1284,8 @@ var PublicApiFp = function(configuration) {
1271
1284
  * @param {*} [options] Override http request option.
1272
1285
  * @throws {RequiredError}
1273
1286
  */
1274
- async listGrantsV1AccessGrantsGet(resourceType, resourceId, subjectType, subjectId, revoked, page, pageSize, sort, options) {
1275
- const localVarAxiosArgs = await localVarAxiosParamCreator.listGrantsV1AccessGrantsGet(resourceType, resourceId, subjectType, subjectId, revoked, page, pageSize, sort, options);
1287
+ async listGrantsV1AccessGrantsGet(resourceType, resourceId, subjectType, subjectId, relation, revoked, page, pageSize, sort, options) {
1288
+ const localVarAxiosArgs = await localVarAxiosParamCreator.listGrantsV1AccessGrantsGet(resourceType, resourceId, subjectType, subjectId, relation, revoked, page, pageSize, sort, options);
1276
1289
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
1277
1290
  const localVarOperationServerBasePath = operationServerMap["PublicApi.listGrantsV1AccessGrantsGet"]?.[localVarOperationServerIndex]?.url;
1278
1291
  return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
@@ -1308,13 +1321,15 @@ var PublicApiFp = function(configuration) {
1308
1321
  * @param {string | null} [customMetadata] Use PostgreSQL JSONPath expressions to filter runs by their custom_metadata. #### URL Encoding Required **Important**: JSONPath expressions contain special characters that must be URL-encoded when used in query parameters. Most HTTP clients handle this automatically, but when constructing URLs manually, please ensure proper encoding. #### Examples (Clear Format): - **Field existence**: &#x60;$.study&#x60; - Runs that have a study field defined - **Exact value match**: &#x60;$.study ? (@ &#x3D;&#x3D; \&quot;high\&quot;)&#x60; - Runs with specific study value - **Numeric comparison**: &#x60;$.confidence_score ? (@ &gt; 0.75)&#x60; - Runs with confidence score greater than 0.75 - **Array operations**: &#x60;$.tags[*] ? (@ &#x3D;&#x3D; \&quot;draft\&quot;)&#x60; - Runs with tags array containing \&quot;draft\&quot; - **Complex conditions**: &#x60;$.resources ? (@.gpu_count &gt; 2 &amp;&amp; @.memory_gb &gt;&#x3D; 16)&#x60; - Runs with high resource requirements #### Examples (URL-Encoded Format): - **Field existence**: &#x60;%24.study&#x60; - **Exact value match**: &#x60;%24.study%20%3F%20(%40%20%3D%3D%20%22high%22)&#x60; - **Numeric comparison**: &#x60;%24.confidence_score%20%3F%20(%40%20%3E%200.75)&#x60; - **Array operations**: &#x60;%24.tags%5B*%5D%20%3F%20(%40%20%3D%3D%20%22draft%22)&#x60; - **Complex conditions**: &#x60;%24.resources%20%3F%20(%40.gpu_count%20%3E%202%20%26%26%20%40.memory_gb%20%3E%3D%2016)&#x60; #### Notes - JSONPath expressions are evaluated using PostgreSQL\&#39;s &#x60;@?&#x60; operator - The &#x60;$.&#x60; prefix is automatically added to root-level field references if missing - String values in conditions must be enclosed in double quotes - Use &#x60;&amp;&amp;&#x60; for AND operations and &#x60;||&#x60; for OR operations - Regular expressions use &#x60;like_regex&#x60; with standard regex syntax - **Please remember to URL-encode the entire JSONPath expression when making HTTP requests**
1309
1322
  * @param {number} [page]
1310
1323
  * @param {number} [pageSize]
1324
+ * @param {string | null} [submittedBy] Filter runs by the user who submitted them. Use the special value &#x60;me&#x60; to return only runs submitted by the current user.
1325
+ * @param {string | null} [organizationId] Filter runs by the organization of the submitter. Use the special value &#x60;my_org&#x60; to filter by the current user\&#39;s organization.
1311
1326
  * @param {string | null} [forOrganization] Filter runs by organization ID. Available for superadmins (any org) and admins (own org only). When provided, returns all runs for the specified organization instead of only the caller\&#39;s own runs.
1312
1327
  * @param {Array<string> | null} [sort] Sort the results by one or more fields. Use &#x60;+&#x60; for ascending and &#x60;-&#x60; for descending order. **Available fields:** - &#x60;run_id&#x60; - &#x60;application_id&#x60; - &#x60;version_number&#x60; - &#x60;custom_metadata&#x60; - &#x60;submitted_at&#x60; - &#x60;submitted_by&#x60; - &#x60;terminated_at&#x60; - &#x60;termination_reason&#x60; **Examples:** - &#x60;?sort&#x3D;submitted_at&#x60; - Sort by creation time (ascending) - &#x60;?sort&#x3D;-submitted_at&#x60; - Sort by creation time (descending) - &#x60;?sort&#x3D;state&amp;sort&#x3D;-submitted_at&#x60; - Sort by state, then by time (descending)
1313
1328
  * @param {*} [options] Override http request option.
1314
1329
  * @throws {RequiredError}
1315
1330
  */
1316
- async listRunsV1RunsGet(applicationId, applicationVersion, externalId, customMetadata, page, pageSize, forOrganization, sort, options) {
1317
- const localVarAxiosArgs = await localVarAxiosParamCreator.listRunsV1RunsGet(applicationId, applicationVersion, externalId, customMetadata, page, pageSize, forOrganization, sort, options);
1331
+ async listRunsV1RunsGet(applicationId, applicationVersion, externalId, customMetadata, page, pageSize, submittedBy, organizationId, forOrganization, sort, options) {
1332
+ const localVarAxiosArgs = await localVarAxiosParamCreator.listRunsV1RunsGet(applicationId, applicationVersion, externalId, customMetadata, page, pageSize, submittedBy, organizationId, forOrganization, sort, options);
1318
1333
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
1319
1334
  const localVarOperationServerBasePath = operationServerMap["PublicApi.listRunsV1RunsGet"]?.[localVarOperationServerIndex]?.url;
1320
1335
  return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios2, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
@@ -1591,7 +1606,7 @@ var PublicApiFactory = function(configuration, basePath, axios) {
1591
1606
  * @throws {RequiredError}
1592
1607
  */
1593
1608
  listGrantsV1AccessGrantsGet(requestParameters = {}, options) {
1594
- return localVarFp.listGrantsV1AccessGrantsGet(requestParameters.resourceType, requestParameters.resourceId, requestParameters.subjectType, requestParameters.subjectId, requestParameters.revoked, requestParameters.page, requestParameters.pageSize, requestParameters.sort, options).then((request) => request(axios, basePath));
1609
+ return localVarFp.listGrantsV1AccessGrantsGet(requestParameters.resourceType, requestParameters.resourceId, requestParameters.subjectType, requestParameters.subjectId, requestParameters.relation, requestParameters.revoked, requestParameters.page, requestParameters.pageSize, requestParameters.sort, options).then((request) => request(axios, basePath));
1595
1610
  },
1596
1611
  /**
1597
1612
  * List items in a run with filtering, sorting, and pagination capabilities. Returns paginated items within a specific run. Results can be filtered by `item_id`, `external_ids`, `custom_metadata`, `terminated_at`, and `termination_reason` using JSONPath expressions. ## JSONPath Metadata Filtering Use PostgreSQL JSONPath expressions to filter items using their custom_metadata. ### Examples: - **Field existence**: `$.case_id` - Results that have a case_id field defined - **Exact value match**: `$.priority ? (@ == \"high\")` - Results with high priority - **Numeric comparison**: `$.confidence_score ? (@ > 0.95)` - Results with high confidence - **Array operations**: `$.flags[*] ? (@ == \"reviewed\")` - Results flagged as reviewed - **Complex conditions**: `$.metrics ? (@.accuracy > 0.9 && @.recall > 0.8)` - Results meeting performance thresholds ## Notes - JSONPath expressions are evaluated using PostgreSQL\'s `@?` operator - The `$.` prefix is automatically added to root-level field references if missing - String values in conditions must be enclosed in double quotes - Use `&&` for AND operations and `||` for OR operations
@@ -1611,7 +1626,7 @@ var PublicApiFactory = function(configuration, basePath, axios) {
1611
1626
  * @throws {RequiredError}
1612
1627
  */
1613
1628
  listRunsV1RunsGet(requestParameters = {}, options) {
1614
- return localVarFp.listRunsV1RunsGet(requestParameters.applicationId, requestParameters.applicationVersion, requestParameters.externalId, requestParameters.customMetadata, requestParameters.page, requestParameters.pageSize, requestParameters.forOrganization, requestParameters.sort, options).then((request) => request(axios, basePath));
1629
+ return localVarFp.listRunsV1RunsGet(requestParameters.applicationId, requestParameters.applicationVersion, requestParameters.externalId, requestParameters.customMetadata, requestParameters.page, requestParameters.pageSize, requestParameters.submittedBy, requestParameters.organizationId, requestParameters.forOrganization, requestParameters.sort, options).then((request) => request(axios, basePath));
1615
1630
  },
1616
1631
  /**
1617
1632
  * List share tokens. Service and Superadmin see all tokens; other users see only their own.
@@ -1870,7 +1885,7 @@ var PublicApi = class extends BaseAPI {
1870
1885
  * @memberof PublicApi
1871
1886
  */
1872
1887
  listGrantsV1AccessGrantsGet(requestParameters = {}, options) {
1873
- return PublicApiFp(this.configuration).listGrantsV1AccessGrantsGet(requestParameters.resourceType, requestParameters.resourceId, requestParameters.subjectType, requestParameters.subjectId, requestParameters.revoked, requestParameters.page, requestParameters.pageSize, requestParameters.sort, options).then((request) => request(this.axios, this.basePath));
1888
+ return PublicApiFp(this.configuration).listGrantsV1AccessGrantsGet(requestParameters.resourceType, requestParameters.resourceId, requestParameters.subjectType, requestParameters.subjectId, requestParameters.relation, requestParameters.revoked, requestParameters.page, requestParameters.pageSize, requestParameters.sort, options).then((request) => request(this.axios, this.basePath));
1874
1889
  }
1875
1890
  /**
1876
1891
  * List items in a run with filtering, sorting, and pagination capabilities. Returns paginated items within a specific run. Results can be filtered by `item_id`, `external_ids`, `custom_metadata`, `terminated_at`, and `termination_reason` using JSONPath expressions. ## JSONPath Metadata Filtering Use PostgreSQL JSONPath expressions to filter items using their custom_metadata. ### Examples: - **Field existence**: `$.case_id` - Results that have a case_id field defined - **Exact value match**: `$.priority ? (@ == \"high\")` - Results with high priority - **Numeric comparison**: `$.confidence_score ? (@ > 0.95)` - Results with high confidence - **Array operations**: `$.flags[*] ? (@ == \"reviewed\")` - Results flagged as reviewed - **Complex conditions**: `$.metrics ? (@.accuracy > 0.9 && @.recall > 0.8)` - Results meeting performance thresholds ## Notes - JSONPath expressions are evaluated using PostgreSQL\'s `@?` operator - The `$.` prefix is automatically added to root-level field references if missing - String values in conditions must be enclosed in double quotes - Use `&&` for AND operations and `||` for OR operations
@@ -1892,7 +1907,7 @@ var PublicApi = class extends BaseAPI {
1892
1907
  * @memberof PublicApi
1893
1908
  */
1894
1909
  listRunsV1RunsGet(requestParameters = {}, options) {
1895
- return PublicApiFp(this.configuration).listRunsV1RunsGet(requestParameters.applicationId, requestParameters.applicationVersion, requestParameters.externalId, requestParameters.customMetadata, requestParameters.page, requestParameters.pageSize, requestParameters.forOrganization, requestParameters.sort, options).then((request) => request(this.axios, this.basePath));
1910
+ return PublicApiFp(this.configuration).listRunsV1RunsGet(requestParameters.applicationId, requestParameters.applicationVersion, requestParameters.externalId, requestParameters.customMetadata, requestParameters.page, requestParameters.pageSize, requestParameters.submittedBy, requestParameters.organizationId, requestParameters.forOrganization, requestParameters.sort, options).then((request) => request(this.axios, this.basePath));
1896
1911
  }
1897
1912
  /**
1898
1913
  * List share tokens. Service and Superadmin see all tokens; other users see only their own.
@@ -2161,23 +2176,33 @@ function getRunProgress(run) {
2161
2176
  return Math.round(processed / item_count * 100);
2162
2177
  }
2163
2178
  function getRunStatus(run) {
2164
- const { state, statistics, termination_reason } = run;
2179
+ const { state, termination_reason, output } = run;
2165
2180
  switch (state) {
2166
2181
  case "PENDING":
2167
2182
  return "PENDING";
2168
2183
  case "PROCESSING":
2169
2184
  return "PROCESSING";
2170
2185
  case "TERMINATED":
2171
- if (termination_reason === "CANCELED_BY_USER") {
2172
- return "CANCELED";
2173
- }
2174
- if (termination_reason === "CANCELED_BY_SYSTEM") {
2175
- return "FAILED";
2176
- }
2177
- if (statistics.item_count !== statistics.item_succeeded_count) {
2178
- return "COMPLETED_WITH_ERRORS";
2186
+ switch (termination_reason) {
2187
+ case "CANCELED_BY_USER":
2188
+ return "CANCELED";
2189
+ case "CANCELED_BY_SYSTEM":
2190
+ case "ALL_ITEMS_PROCESSED":
2191
+ switch (output) {
2192
+ case "NONE":
2193
+ return "FAILED";
2194
+ case "PARTIAL":
2195
+ return "COMPLETED_WITH_ERRORS";
2196
+ case "FULL":
2197
+ return "COMPLETED";
2198
+ default:
2199
+ return "UNKNOWN";
2200
+ }
2201
+ default:
2202
+ return "UNKNOWN";
2179
2203
  }
2180
- return "COMPLETED";
2204
+ default:
2205
+ return "UNKNOWN";
2181
2206
  }
2182
2207
  }
2183
2208
  var canDownloadRunItems = (run) => {
@@ -2199,6 +2224,12 @@ var processApplicationRun = (run) => {
2199
2224
  var canDownloadItem = (item) => {
2200
2225
  return getItemStatus(item) === "COMPLETED";
2201
2226
  };
2227
+ var ERROR_TERMINATION_REASONS = /* @__PURE__ */ new Set([
2228
+ "CANCELED_BY_SYSTEM",
2229
+ "CANCELED_BY_USER",
2230
+ "SYSTEM_ERROR",
2231
+ "USER_ERROR"
2232
+ ]);
2202
2233
  function getItemStatus(item) {
2203
2234
  const { state, termination_reason } = item;
2204
2235
  switch (state) {
@@ -2207,13 +2238,19 @@ function getItemStatus(item) {
2207
2238
  case "PROCESSING":
2208
2239
  return "PROCESSING";
2209
2240
  case "TERMINATED":
2210
- if (termination_reason === "SYSTEM_ERROR" || termination_reason === "USER_ERROR") {
2241
+ if (!termination_reason) {
2242
+ return "UNKNOWN";
2243
+ }
2244
+ if (ERROR_TERMINATION_REASONS.has(termination_reason)) {
2211
2245
  return "FAILED";
2212
2246
  }
2213
2247
  if (termination_reason === "SKIPPED") {
2214
2248
  return "SKIPPED";
2215
2249
  }
2216
- return "COMPLETED";
2250
+ if (termination_reason === "SUCCEEDED") {
2251
+ return "COMPLETED";
2252
+ }
2253
+ return "UNKNOWN";
2217
2254
  }
2218
2255
  }
2219
2256
 
@@ -3036,6 +3073,59 @@ var PlatformSDKHttp = class {
3036
3073
  handleRequestError(error);
3037
3074
  }
3038
3075
  }
3076
+ /**
3077
+ * Download an artifact file from a completed application run as a stream
3078
+ *
3079
+ * Prefer this method over `downloadArtifact` when downloading large (e.g. multi-gigabyte)
3080
+ * artifacts: instead of buffering the entire file into memory before returning it, this
3081
+ * method streams the artifact's bytes as they arrive, keeping memory usage low regardless
3082
+ * of the artifact's size.
3083
+ *
3084
+ * The download is performed with automatic retries for transient failures.
3085
+ * Non-retryable HTTP status codes (403, 404, 410, 422) will abort immediately.
3086
+ *
3087
+ * @param runId - The unique identifier of the application run
3088
+ * @param artifactId - The unique identifier of the artifact to download
3089
+ * @returns A promise that resolves to a Node.js `Readable` stream yielding the artifact's binary content
3090
+ * @throws {AuthenticationError} If no valid authentication token is available
3091
+ * @throws {APIError} If the API request fails (e.g., 403, 404, 410, 422, or other HTTP errors)
3092
+ * @throws {UnexpectedError} If a non-HTTP error occurs
3093
+ *
3094
+ * @example
3095
+ * ```typescript
3096
+ * import { pipeline } from 'node:stream/promises';
3097
+ * import { createWriteStream } from 'node:fs';
3098
+ *
3099
+ * const stream = await sdk.downloadArtifactStream('run-123', 'artifact-456');
3100
+ * await pipeline(stream, createWriteStream('output.bin'));
3101
+ * ```
3102
+ *
3103
+ * @remarks
3104
+ * Retries only cover failures at the initial-request stage (a non-2xx status surfaced from
3105
+ * the response headers before the body begins streaming). Once the response body has started
3106
+ * streaming, a mid-stream connection drop CANNOT be retried by this method — the consumer must
3107
+ * listen for the stream's `error` event and re-download if needed.
3108
+ */
3109
+ async downloadArtifactStream(runId, artifactId) {
3110
+ const client = await this.#getClient();
3111
+ try {
3112
+ const response = await downloadWithRetry(
3113
+ () => client.getArtifactUrlV1RunsRunIdArtifactsArtifactIdFileGet(
3114
+ {
3115
+ runId,
3116
+ artifactId
3117
+ },
3118
+ {
3119
+ responseType: "stream"
3120
+ }
3121
+ ),
3122
+ [403, 404, 410, 422]
3123
+ );
3124
+ return response.data;
3125
+ } catch (error) {
3126
+ handleRequestError(error);
3127
+ }
3128
+ }
3039
3129
  };
3040
3130
 
3041
3131
  // src/index.ts