@pipelex/sdk 0.73.0 → 0.74.2
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/artifacts.d.ts +24 -1
- package/dist/artifacts.js +95 -15
- package/dist/artifacts.js.map +1 -1
- package/dist/cli/run.d.ts +2 -0
- package/dist/cli/run.js +13 -5
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/script.d.ts +1 -1
- package/dist/client.d.ts +25 -2
- package/dist/client.js +65 -7
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +6 -4
- package/dist/errors.js +6 -4
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/run-artifact-links.d.ts +73 -0
- package/dist/run-artifact-links.js +167 -0
- package/dist/run-artifact-links.js.map +1 -0
- package/dist/runs.d.ts +53 -3
- package/dist/runs.js +7 -4
- package/dist/runs.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/cli.md +1 -1
- package/docs/errors.md +1 -1
- package/docs/organization-branding.md +1 -1
- package/docs/run-results.md +32 -1
- package/package.json +2 -2
package/dist/client.d.ts
CHANGED
|
@@ -2,13 +2,14 @@ import type { MTHDSProtocol, ModelCategory, ModelDeck, RunOptions, StartOptions,
|
|
|
2
2
|
import type { CodegenRequest, CodegenResponse, CrateRouteOptions, DictPipeOutput, FormatResponse, LintResponse, ModelCheckCategory, ModelReferenceVerdict, PipeIORequest, PipeIOResponse, PipelexRunResultStart, PipelexValidateSource, PipelexValidationResult, ResolveRequest, ResolveResponse, ValidateMethodSelector, ValidateView } from "./models.js";
|
|
3
3
|
import type { MethodLayout, MethodLayoutInput, MethodLayoutList } from "./method-layouts.js";
|
|
4
4
|
import type { MethodShowcaseDetail, MethodShowcaseFreezeResult, MethodShowcaseInput, MethodShowcaseList } from "./method-showcases.js";
|
|
5
|
-
import { type GetRunResultOptions, type RunProgress, type RunRead, type RunResults, type RunResultState, type StartAndWaitForResultOptions, type WaitForResultOptions } from "./runs.js";
|
|
5
|
+
import { type GetRunResultOptions, type RunArtifactLink, type RunProgress, type RunRead, type RunResultArtifact, type RunResults, type RunResultState, type StartAndWaitForResultOptions, type WaitForResultOptions } from "./runs.js";
|
|
6
6
|
import type { BillingPortalResponse, ChangePlanResponse, CheckoutResponse, DraftFileFromFileInput, DraftFileFromFileResult, FileArchive, FileArchiveRequest, FileDetail, FileLinkTarget, FileLinksResult, FilePage, FilePreview, FileRecord, FileRecordList, FileRenameInput, FileSummary, GetFileQuery, GetFilesByUriOptions, InvoiceView, Membership, MembershipsResponse, OrganizationBranding, OrganizationBrandingUpdate, ListFilesQuery, ListMethodExamplesQuery, ListMethodsQuery, ListMethodTemplatesQuery, ListMethodVersionsQuery, ListRunFilesQuery, MethodCategoryList, MethodCopyInput, MethodCopyResult, MethodData, MethodDeletionAccepted, MethodDetail, MethodDraftInput, MethodExample, MethodExampleAssistantSaveInput, MethodExampleAssistantSaveResult, MethodExampleCreateInput, MethodExampleLatestRunInput, MethodExampleLatestRunResult, MethodExamplePage, MethodExampleUpdateInput, MethodPage, MethodPublishInput, MethodPublishResult, MethodRenameInput, MethodSummary, MethodTemplate, MethodTemplatePage, MethodVersion, MethodVersionPage, MethodWriteInput, OnboardingSubmission, PublicMethodDetail, PipelexApiKeyCreated, PipelexApiKeyList, ListRunsQuery, RunHistoryItem, RunDetail, RunFilesPage, RunPage, PlanView, ResolvedStorageUrl, SavedMethodFile, SubscriptionResponse, UpdateRunInput, UploadGrant, UploadGrantInput, UploadInput, UploadedFile, UserProfile } from "./product-models.js";
|
|
7
7
|
import type { MethodTreeForms, MethodTreeLimits } from "./method-trees.js";
|
|
8
8
|
import type { AppInfo } from "./user-agent.js";
|
|
9
9
|
import type { WebhookDeliveryDetail, WebhookDeliveryList, WebhookReplayAccepted, WebhookReplayOptions, WebhookSecret, WebhookSecretRotateOptions } from "./webhooks.js";
|
|
10
10
|
import type { UploadableAsset, UploadFileOptions, UploadRecord } from "./upload.js";
|
|
11
11
|
import type { PrepareInputsRequest, PreparedInputs } from "./prepare-inputs.js";
|
|
12
|
+
import type { FollowArtifactLinksOptions } from "./run-artifact-links.js";
|
|
12
13
|
import type { BulkResolveStorageUrlsInput, BulkResolvedStorageUrls, DownloadArtifactsRequest, DownloadArtifactsResult, FetchArtifactOptions, ResolvedArtifact } from "./artifacts.js";
|
|
13
14
|
import { PipelexExecuteResult } from "./execute-result.js";
|
|
14
15
|
/**
|
|
@@ -940,7 +941,13 @@ export declare class PipelexApiClient implements HostedProtocolSurface {
|
|
|
940
941
|
* selected one the run never wrote is `null`. Omitted, every artifact is
|
|
941
942
|
* read. An empty selection or an unknown name throws a `RequestArgumentError`
|
|
942
943
|
* before any request. `MissingMainStuffError` is thrown only for a read that asked
|
|
943
|
-
* for `main_stuff` — no selection, or one naming it.
|
|
944
|
+
* for `main_stuff` — no selection, or one naming it — and found it `null` with no link.
|
|
945
|
+
*
|
|
946
|
+
* An artifact the platform handed back by reference, because inline it would have taken the
|
|
947
|
+
* body past the API Gateway's limit, is fetched from its signed link into its field by default
|
|
948
|
+
* (`followArtifactLinks`), before the main-stuff check and the stored-text load, so it reads as
|
|
949
|
+
* its content. `followArtifactLinks: false` hands the links back on `artifact_links`, each such
|
|
950
|
+
* field `null`, for a caller that passes the link on rather than pull the file through itself.
|
|
944
951
|
*
|
|
945
952
|
* A completed result is read with `parseExactJson`, so an integer past
|
|
946
953
|
* `Number.MAX_SAFE_INTEGER` anywhere in it, the main output, the working memory and the graph
|
|
@@ -2098,6 +2105,22 @@ export declare class PipelexApiClient implements HostedProtocolSurface {
|
|
|
2098
2105
|
* same-origin proxy share. See `docs/artifact-download.md`.
|
|
2099
2106
|
*/
|
|
2100
2107
|
fetchArtifact(uri: string, options?: FetchArtifactOptions): Promise<Response>;
|
|
2108
|
+
/**
|
|
2109
|
+
* Fetch one result artifact the platform handed back by reference — an entry of
|
|
2110
|
+
* `RunResults.artifact_links` — and read it as the result fields it fills: `{ graph_spec }`,
|
|
2111
|
+
* `{ main_stuff }`, …, and `{ tokens_usages, usage_assembly_error }` unpacked from the usage
|
|
2112
|
+
* envelope. Read exactly (`parseExactJson`), under `fetchArtifact`'s bounds. The links inside the
|
|
2113
|
+
* artifact are as stored, never re-signed. See `docs/run-results.md`, "Artifacts handed back by
|
|
2114
|
+
* reference".
|
|
2115
|
+
*/
|
|
2116
|
+
fetchRunArtifact(artifact: RunResultArtifact, link: RunArtifactLink, options?: FetchArtifactOptions): Promise<Partial<RunResults>>;
|
|
2117
|
+
/**
|
|
2118
|
+
* A result with the artifacts it handed back by reference fetched into their fields, every one
|
|
2119
|
+
* or those `options.artifacts` names, each followed entry dropped from `artifact_links`. What the
|
|
2120
|
+
* result readers do by default; for a result read with `followArtifactLinks: false`. Returns a
|
|
2121
|
+
* new result, or the same one when it holds no link to follow.
|
|
2122
|
+
*/
|
|
2123
|
+
followArtifactLinks(results: RunResults, options?: FollowArtifactLinksOptions): Promise<RunResults>;
|
|
2101
2124
|
/**
|
|
2102
2125
|
* Save a run's produced files under a directory — the download twin of
|
|
2103
2126
|
* {@link prepareInputs}, Node-only. Keyed on a `run_id` (the results are
|
package/dist/client.js
CHANGED
|
@@ -13,7 +13,8 @@ import { HANDSHAKE_TTL_MS, INLINE_TREE_MAX_BYTES, MAX_CONCURRENT_TRANSFERS, REQU
|
|
|
13
13
|
import { buildUserAgent } from "./user-agent.js";
|
|
14
14
|
import { uploadFile as uploadFileImpl } from "./upload.js";
|
|
15
15
|
import { prepareInputs as prepareInputsImpl } from "./prepare-inputs.js";
|
|
16
|
-
import { carriesConceptArtifacts, downloadArtifacts as downloadArtifactsImpl, fetchArtifact as fetchArtifactImpl, loadStoredTexts as loadStoredTextsImpl, mayHoldStoredTexts, resolveArtifacts as resolveArtifactsImpl, withConceptArtifacts, } from "./artifacts.js";
|
|
16
|
+
import { carriesConceptArtifacts, CONCEPT_ARTIFACTS, downloadArtifacts as downloadArtifactsImpl, fetchArtifact as fetchArtifactImpl, loadStoredTexts as loadStoredTextsImpl, mayHoldStoredTexts, resolveArtifacts as resolveArtifactsImpl, withConceptArtifacts, } from "./artifacts.js";
|
|
17
|
+
import { fetchRunArtifact as fetchRunArtifactImpl, followArtifactLinks as followArtifactLinksImpl, holdsArtifactLinks, } from "./run-artifact-links.js";
|
|
17
18
|
import { PipelexExecuteResult, resultsFromExecute } from "./execute-result.js";
|
|
18
19
|
import { ExactJsonUnsupportedError, parseExactJson, stringifyExactJson } from "./exact-json.js";
|
|
19
20
|
import { eitherSignal } from "./signals.js";
|
|
@@ -119,6 +120,8 @@ const DEFAULT_REQUEST_TIMEOUT_MS = 1_200_000; // 20 min — matches the runner's
|
|
|
119
120
|
const POLL_REQUEST_TIMEOUT_MS = 30_000; // single status/result GETs; the hosted gateway caps responses at ~30s.
|
|
120
121
|
const DEFAULT_DEGRADED_RETRY_SECONDS = 5; // matches the platform's `_DEGRADE_RETRY_AFTER_SECONDS`.
|
|
121
122
|
const VALIDATE_MARKDOWN_RENDER_FORMAT = "markdown";
|
|
123
|
+
/** What the stored-text load reads: the main stuff, and the artifacts telling its texts by concept. */
|
|
124
|
+
const LOAD_ARTIFACTS = ["main_stuff", ...CONCEPT_ARTIFACTS];
|
|
122
125
|
/**
|
|
123
126
|
* `VersionInfo.implementation` of the bare open-source runner (no run store).
|
|
124
127
|
* Anything else — the hosted `pipelex-hosted` first — is assumed to serve the
|
|
@@ -1751,7 +1754,13 @@ export class PipelexApiClient {
|
|
|
1751
1754
|
* selected one the run never wrote is `null`. Omitted, every artifact is
|
|
1752
1755
|
* read. An empty selection or an unknown name throws a `RequestArgumentError`
|
|
1753
1756
|
* before any request. `MissingMainStuffError` is thrown only for a read that asked
|
|
1754
|
-
* for `main_stuff` — no selection, or one naming it.
|
|
1757
|
+
* for `main_stuff` — no selection, or one naming it — and found it `null` with no link.
|
|
1758
|
+
*
|
|
1759
|
+
* An artifact the platform handed back by reference, because inline it would have taken the
|
|
1760
|
+
* body past the API Gateway's limit, is fetched from its signed link into its field by default
|
|
1761
|
+
* (`followArtifactLinks`), before the main-stuff check and the stored-text load, so it reads as
|
|
1762
|
+
* its content. `followArtifactLinks: false` hands the links back on `artifact_links`, each such
|
|
1763
|
+
* field `null`, for a caller that passes the link on rather than pull the file through itself.
|
|
1755
1764
|
*
|
|
1756
1765
|
* A completed result is read with `parseExactJson`, so an integer past
|
|
1757
1766
|
* `Number.MAX_SAFE_INTEGER` anywhere in it, the main output, the working memory and the graph
|
|
@@ -1792,8 +1801,15 @@ export class PipelexApiClient {
|
|
|
1792
1801
|
this.throwApiResponseError("GET", endpoint, res);
|
|
1793
1802
|
}
|
|
1794
1803
|
// Read exactly: the output, the working memory and the graph hold the run's data.
|
|
1795
|
-
|
|
1796
|
-
if (
|
|
1804
|
+
let result = this.readObjectAnswer("GET", endpoint, res, {}, parseExactJson);
|
|
1805
|
+
if (options.followArtifactLinks !== false) {
|
|
1806
|
+
result = await followArtifactLinksImpl(this, result, { signal: options.signal });
|
|
1807
|
+
}
|
|
1808
|
+
// A `main_stuff` handed back by reference is there, at the end of its link: only a null one
|
|
1809
|
+
// with no link breaks the main-stuff invariant.
|
|
1810
|
+
if (selectionIncludesMainStuff(options.artifacts) &&
|
|
1811
|
+
result.main_stuff == null &&
|
|
1812
|
+
result.artifact_links?.main_stuff == null) {
|
|
1797
1813
|
throw new MissingMainStuffError(`Completed run '${runId}' returned no main stuff — a completed run always delivers a main stuff.`, runId);
|
|
1798
1814
|
}
|
|
1799
1815
|
if (options.loadStoredTexts === false || !selectionIncludesMainStuff(options.artifacts)) {
|
|
@@ -1814,9 +1830,14 @@ export class PipelexApiClient {
|
|
|
1814
1830
|
async withStoredTextsLoaded(result, selection, signal) {
|
|
1815
1831
|
if (result.main_stuff == null)
|
|
1816
1832
|
return result;
|
|
1817
|
-
|
|
1833
|
+
// A concept artifact handed back by reference, from a read that did not follow its links,
|
|
1834
|
+
// says nothing until fetched: read like one the selection left out, only when worth it.
|
|
1835
|
+
const linkedConcepts = holdsArtifactLinks(result, CONCEPT_ARTIFACTS);
|
|
1836
|
+
if ((!carriesConceptArtifacts(selection) || linkedConcepts) &&
|
|
1837
|
+
!mayHoldStoredTexts(result.main_stuff)) {
|
|
1818
1838
|
return result;
|
|
1819
1839
|
}
|
|
1840
|
+
// The loader fetches a linked concept artifact for the load alone: the result keeps its links.
|
|
1820
1841
|
const source = await withConceptArtifacts(this, result, selection, signal);
|
|
1821
1842
|
const loaded = await loadStoredTextsImpl(this, { ...result, ...source }, {
|
|
1822
1843
|
signal,
|
|
@@ -1835,9 +1856,26 @@ export class PipelexApiClient {
|
|
|
1835
1856
|
*/
|
|
1836
1857
|
async waitForResult(runId, options) {
|
|
1837
1858
|
const selection = options?.artifacts;
|
|
1838
|
-
|
|
1859
|
+
const follows = options?.followArtifactLinks !== false;
|
|
1860
|
+
const loads = options?.loadStoredTexts !== false && selectionIncludesMainStuff(selection);
|
|
1861
|
+
return pollUntilResult((id, opts) => this.getRunResult(id, opts), runId, options, (id, opts) => this.getRunProgress(id, opts), !follows && !loads
|
|
1839
1862
|
? undefined
|
|
1840
|
-
: (result, opts) =>
|
|
1863
|
+
: async (result, opts) => {
|
|
1864
|
+
let current = result;
|
|
1865
|
+
if (follows && loads) {
|
|
1866
|
+
// What the load reads first, and only that: a load that finds the concepts missing
|
|
1867
|
+
// polls again, so nothing else is fetched before it has passed.
|
|
1868
|
+
current = await followArtifactLinksImpl(this, current, {
|
|
1869
|
+
artifacts: LOAD_ARTIFACTS,
|
|
1870
|
+
signal: opts.signal,
|
|
1871
|
+
});
|
|
1872
|
+
}
|
|
1873
|
+
if (loads)
|
|
1874
|
+
current = await this.withStoredTextsLoaded(current, selection, opts.signal);
|
|
1875
|
+
return follows
|
|
1876
|
+
? followArtifactLinksImpl(this, current, { signal: opts.signal })
|
|
1877
|
+
: current;
|
|
1878
|
+
});
|
|
1841
1879
|
}
|
|
1842
1880
|
/**
|
|
1843
1881
|
* Whether the configured server serves the durable run lifecycle, decided
|
|
@@ -3652,6 +3690,26 @@ export class PipelexApiClient {
|
|
|
3652
3690
|
async fetchArtifact(uri, options) {
|
|
3653
3691
|
return fetchArtifactImpl(this, uri, options);
|
|
3654
3692
|
}
|
|
3693
|
+
/**
|
|
3694
|
+
* Fetch one result artifact the platform handed back by reference — an entry of
|
|
3695
|
+
* `RunResults.artifact_links` — and read it as the result fields it fills: `{ graph_spec }`,
|
|
3696
|
+
* `{ main_stuff }`, …, and `{ tokens_usages, usage_assembly_error }` unpacked from the usage
|
|
3697
|
+
* envelope. Read exactly (`parseExactJson`), under `fetchArtifact`'s bounds. The links inside the
|
|
3698
|
+
* artifact are as stored, never re-signed. See `docs/run-results.md`, "Artifacts handed back by
|
|
3699
|
+
* reference".
|
|
3700
|
+
*/
|
|
3701
|
+
async fetchRunArtifact(artifact, link, options) {
|
|
3702
|
+
return fetchRunArtifactImpl(this, artifact, link, options);
|
|
3703
|
+
}
|
|
3704
|
+
/**
|
|
3705
|
+
* A result with the artifacts it handed back by reference fetched into their fields, every one
|
|
3706
|
+
* or those `options.artifacts` names, each followed entry dropped from `artifact_links`. What the
|
|
3707
|
+
* result readers do by default; for a result read with `followArtifactLinks: false`. Returns a
|
|
3708
|
+
* new result, or the same one when it holds no link to follow.
|
|
3709
|
+
*/
|
|
3710
|
+
async followArtifactLinks(results, options) {
|
|
3711
|
+
return followArtifactLinksImpl(this, results, options);
|
|
3712
|
+
}
|
|
3655
3713
|
/**
|
|
3656
3714
|
* Save a run's produced files under a directory — the download twin of
|
|
3657
3715
|
* {@link prepareInputs}, Node-only. Keyed on a `run_id` (the results are
|