@workflow/world-testing 5.0.0-beta.47 → 5.0.0-beta.49
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.
|
@@ -370,6 +370,8 @@ var init_error_codes = __esm({
|
|
|
370
370
|
MAX_EVENTS_EXCEEDED: "MAX_EVENTS_EXCEEDED",
|
|
371
371
|
/** Workflow replay exceeded the maximum allowed duration */
|
|
372
372
|
REPLAY_TIMEOUT: "REPLAY_TIMEOUT",
|
|
373
|
+
/** Workflow stream infrastructure failed while reading or writing data */
|
|
374
|
+
STREAM_ERROR: "STREAM_ERROR",
|
|
373
375
|
/** World response violated the SDK contract and cannot be retried safely */
|
|
374
376
|
WORLD_CONTRACT_ERROR: "WORLD_CONTRACT_ERROR",
|
|
375
377
|
/** Run was delivered to a deployment other than the one it is pinned to */
|
|
@@ -410,12 +412,13 @@ function buildFramedDetails(hint2, slug) {
|
|
|
410
412
|
});
|
|
411
413
|
return out;
|
|
412
414
|
}
|
|
413
|
-
var BASE_URL, ERROR_SLUGS, WorkflowError, WorkflowWorldError, WorkflowRunFailedError, WorkflowRunNotCompletedError, WorkflowRuntimeError, RuntimeDecryptionError, SerializationError, StepNotRegisteredError, WorkflowNotRegisteredError, WorkflowRunNotFoundError, HookConflictError, HookNotFoundError, EntityConflictError, RunExpiredError, StreamExpiredError, ThrottleError, WorkflowRunCancelledError, FatalError, RetryableError, FATAL_ERROR_KEY, RETRYABLE_ERROR_KEY, HOOK_CONFLICT_ERROR_KEY, RUNTIME_DECRYPTION_ERROR_KEY;
|
|
415
|
+
var BASE_URL, ERROR_SLUGS, WorkflowError, WorkflowWorldError, WorkflowRunFailedError, WorkflowRunNotCompletedError, WorkflowRuntimeError, RuntimeDecryptionError, SerializationError, StepNotRegisteredError, WorkflowNotRegisteredError, WorkflowRunNotFoundError, HookConflictError, HookNotFoundError, EntityConflictError, RunExpiredError, StreamError, StreamExpiredError, ThrottleError, WorkflowRunCancelledError, FatalError, RetryableError, FATAL_ERROR_KEY, RETRYABLE_ERROR_KEY, HOOK_CONFLICT_ERROR_KEY, RUNTIME_DECRYPTION_ERROR_KEY, STREAM_ERROR_KEY;
|
|
414
416
|
var init_dist2 = __esm({
|
|
415
417
|
"../errors/dist/index.js"() {
|
|
416
418
|
"use strict";
|
|
417
419
|
init_dist();
|
|
418
420
|
init_error_codes();
|
|
421
|
+
init_error_codes();
|
|
419
422
|
BASE_URL = "https://workflow-sdk.dev/err";
|
|
420
423
|
__name(isError, "isError");
|
|
421
424
|
__name(appendFramedDetails, "appendFramedDetails");
|
|
@@ -467,6 +470,12 @@ Caused by: ${options.cause.stack}`;
|
|
|
467
470
|
url;
|
|
468
471
|
/** Retry-After value in seconds, present on 429 and 425 responses */
|
|
469
472
|
retryAfter;
|
|
473
|
+
/**
|
|
474
|
+
* The offending argument, present on client-side validation failures
|
|
475
|
+
* (`code: 'INVALID_ARGUMENT'`). Lets a caller correct the specific
|
|
476
|
+
* parameter without parsing the message.
|
|
477
|
+
*/
|
|
478
|
+
field;
|
|
470
479
|
constructor(message, options) {
|
|
471
480
|
super(message, {
|
|
472
481
|
cause: options?.cause
|
|
@@ -476,6 +485,7 @@ Caused by: ${options.cause.stack}`;
|
|
|
476
485
|
this.code = options?.code;
|
|
477
486
|
this.url = options?.url;
|
|
478
487
|
this.retryAfter = options?.retryAfter;
|
|
488
|
+
this.field = options?.field;
|
|
479
489
|
}
|
|
480
490
|
static is(value) {
|
|
481
491
|
return isError(value) && value.name === "WorkflowWorldError";
|
|
@@ -678,14 +688,40 @@ Caused by: ${options.cause.stack}`;
|
|
|
678
688
|
static {
|
|
679
689
|
__name(this, "RunExpiredError");
|
|
680
690
|
}
|
|
681
|
-
|
|
682
|
-
|
|
691
|
+
runId;
|
|
692
|
+
runStatus;
|
|
693
|
+
expiredAt;
|
|
694
|
+
constructor(message, runId, runStatus, expiredAt) {
|
|
695
|
+
super(message, {
|
|
696
|
+
status: 410,
|
|
697
|
+
code: "run-expired"
|
|
698
|
+
});
|
|
699
|
+
this.runId = runId;
|
|
700
|
+
this.runStatus = runStatus;
|
|
701
|
+
this.expiredAt = expiredAt;
|
|
683
702
|
this.name = "RunExpiredError";
|
|
684
703
|
}
|
|
685
704
|
static is(value) {
|
|
686
705
|
return isError(value) && value.name === "RunExpiredError";
|
|
687
706
|
}
|
|
688
707
|
};
|
|
708
|
+
StreamError = class extends WorkflowWorldError {
|
|
709
|
+
static {
|
|
710
|
+
__name(this, "StreamError");
|
|
711
|
+
}
|
|
712
|
+
constructor(message, options) {
|
|
713
|
+
super(message, {
|
|
714
|
+
code: RUN_ERROR_CODES.STREAM_ERROR,
|
|
715
|
+
cause: options?.cause,
|
|
716
|
+
url: options?.url,
|
|
717
|
+
status: options?.status
|
|
718
|
+
});
|
|
719
|
+
this.name = "StreamError";
|
|
720
|
+
}
|
|
721
|
+
static is(value) {
|
|
722
|
+
return isError(value) && value.name === "StreamError";
|
|
723
|
+
}
|
|
724
|
+
};
|
|
689
725
|
StreamExpiredError = class extends WorkflowWorldError {
|
|
690
726
|
static {
|
|
691
727
|
__name(this, "StreamExpiredError");
|
|
@@ -775,6 +811,7 @@ Caused by: ${options.cause.stack}`;
|
|
|
775
811
|
RETRYABLE_ERROR_KEY = /* @__PURE__ */ Symbol.for("@workflow/errors//RetryableError");
|
|
776
812
|
HOOK_CONFLICT_ERROR_KEY = /* @__PURE__ */ Symbol.for("@workflow/errors//HookConflictError");
|
|
777
813
|
RUNTIME_DECRYPTION_ERROR_KEY = /* @__PURE__ */ Symbol.for("@workflow/errors//RuntimeDecryptionError");
|
|
814
|
+
STREAM_ERROR_KEY = /* @__PURE__ */ Symbol.for("@workflow/errors//StreamError");
|
|
778
815
|
if (typeof globalThis !== "undefined") {
|
|
779
816
|
if (!Object.hasOwn(globalThis, FATAL_ERROR_KEY)) {
|
|
780
817
|
Object.defineProperty(globalThis, FATAL_ERROR_KEY, {
|
|
@@ -808,6 +845,14 @@ Caused by: ${options.cause.stack}`;
|
|
|
808
845
|
configurable: false
|
|
809
846
|
});
|
|
810
847
|
}
|
|
848
|
+
if (!Object.hasOwn(globalThis, STREAM_ERROR_KEY)) {
|
|
849
|
+
Object.defineProperty(globalThis, STREAM_ERROR_KEY, {
|
|
850
|
+
value: StreamError,
|
|
851
|
+
writable: false,
|
|
852
|
+
enumerable: false,
|
|
853
|
+
configurable: false
|
|
854
|
+
});
|
|
855
|
+
}
|
|
811
856
|
}
|
|
812
857
|
}
|
|
813
858
|
});
|
|
@@ -18493,13 +18538,14 @@ function validateAttributeChanges(changes, context = {}) {
|
|
|
18493
18538
|
}
|
|
18494
18539
|
validateAttributeBatchConstraints(changes, context);
|
|
18495
18540
|
}
|
|
18496
|
-
var RESERVED_ATTRIBUTE_KEY_PREFIX, ROOT_RUN_ID_ATTRIBUTE, PARENT_RUN_ID_ATTRIBUTE, ATTRIBUTE_KEY_MAX_LENGTH, ATTRIBUTE_VALUE_MAX_BYTES, ATTRIBUTE_MAX_PER_RUN, textEncoder, AttributeValidationError;
|
|
18541
|
+
var RESERVED_ATTRIBUTE_KEY_PREFIX, ROOT_RUN_ID_ATTRIBUTE, PARENT_RUN_ID_ATTRIBUTE, RETENTION_ATTRIBUTE, ATTRIBUTE_KEY_MAX_LENGTH, ATTRIBUTE_VALUE_MAX_BYTES, ATTRIBUTE_MAX_PER_RUN, textEncoder, AttributeValidationError;
|
|
18497
18542
|
var init_attributes_validation = __esm({
|
|
18498
18543
|
"../world/dist/attributes-validation.js"() {
|
|
18499
18544
|
"use strict";
|
|
18500
18545
|
RESERVED_ATTRIBUTE_KEY_PREFIX = "$";
|
|
18501
18546
|
ROOT_RUN_ID_ATTRIBUTE = `${RESERVED_ATTRIBUTE_KEY_PREFIX}rootRunId`;
|
|
18502
18547
|
PARENT_RUN_ID_ATTRIBUTE = `${RESERVED_ATTRIBUTE_KEY_PREFIX}parentRunId`;
|
|
18548
|
+
RETENTION_ATTRIBUTE = `${RESERVED_ATTRIBUTE_KEY_PREFIX}retention`;
|
|
18503
18549
|
ATTRIBUTE_KEY_MAX_LENGTH = 256;
|
|
18504
18550
|
ATTRIBUTE_VALUE_MAX_BYTES = 256;
|
|
18505
18551
|
ATTRIBUTE_MAX_PER_RUN = 64;
|
|
@@ -19109,7 +19155,7 @@ var init_runs = __esm({
|
|
|
19109
19155
|
// Completed state - output can be v1 or v2 format
|
|
19110
19156
|
WorkflowRunBaseSchema.extend({
|
|
19111
19157
|
status: external_exports.literal("completed"),
|
|
19112
|
-
output: SerializedDataSchema,
|
|
19158
|
+
output: SerializedDataSchema.optional(),
|
|
19113
19159
|
error: external_exports.undefined().optional(),
|
|
19114
19160
|
completedAt: external_exports.coerce.date()
|
|
19115
19161
|
}),
|
|
@@ -19117,7 +19163,7 @@ var init_runs = __esm({
|
|
|
19117
19163
|
WorkflowRunBaseSchema.extend({
|
|
19118
19164
|
status: external_exports.literal("failed"),
|
|
19119
19165
|
output: external_exports.undefined().optional(),
|
|
19120
|
-
error: SerializedDataSchema,
|
|
19166
|
+
error: SerializedDataSchema.optional(),
|
|
19121
19167
|
completedAt: external_exports.coerce.date()
|
|
19122
19168
|
})
|
|
19123
19169
|
]);
|
|
@@ -19373,8 +19419,8 @@ var init_analytics = __esm({
|
|
|
19373
19419
|
AnalyticsAttributeKeySchema = external_exports.object({
|
|
19374
19420
|
key: external_exports.string(),
|
|
19375
19421
|
runCount: external_exports.coerce.number(),
|
|
19376
|
-
firstSeenAt:
|
|
19377
|
-
lastSeenAt:
|
|
19422
|
+
firstSeenAt: UTCDateSchema,
|
|
19423
|
+
lastSeenAt: UTCDateSchema
|
|
19378
19424
|
});
|
|
19379
19425
|
}
|
|
19380
19426
|
});
|
|
@@ -20442,6 +20488,18 @@ function getCommonReducers(_global = globalThis) {
|
|
|
20442
20488
|
}
|
|
20443
20489
|
return reduced;
|
|
20444
20490
|
}, "RuntimeDecryptionError"),
|
|
20491
|
+
StreamError: /* @__PURE__ */ __name((value) => {
|
|
20492
|
+
const base = reduceNamedErrorSubclassBase("StreamError", value);
|
|
20493
|
+
if (!base) return false;
|
|
20494
|
+
const reduced = {
|
|
20495
|
+
...base
|
|
20496
|
+
};
|
|
20497
|
+
const status = readProperty(value, "status");
|
|
20498
|
+
const url2 = readProperty(value, "url");
|
|
20499
|
+
if (typeof status === "number") reduced.status = status;
|
|
20500
|
+
if (typeof url2 === "string") reduced.url = url2;
|
|
20501
|
+
return reduced;
|
|
20502
|
+
}, "StreamError"),
|
|
20445
20503
|
SyntaxError: makeErrorSubclassReducer("SyntaxError"),
|
|
20446
20504
|
TypeError: makeErrorSubclassReducer("TypeError"),
|
|
20447
20505
|
URIError: makeErrorSubclassReducer("URIError"),
|
|
@@ -20575,6 +20633,18 @@ function getCommonRevivers(global2 = globalThis) {
|
|
|
20575
20633
|
if (value.stack !== void 0) error48.stack = value.stack;
|
|
20576
20634
|
return error48;
|
|
20577
20635
|
}, "RuntimeDecryptionError"),
|
|
20636
|
+
StreamError: /* @__PURE__ */ __name((value) => {
|
|
20637
|
+
const Ctor = global2[/* @__PURE__ */ Symbol.for("@workflow/errors//StreamError")] ?? StreamError;
|
|
20638
|
+
const error48 = new Ctor(value.message, {
|
|
20639
|
+
..."cause" in value ? {
|
|
20640
|
+
cause: value.cause
|
|
20641
|
+
} : {},
|
|
20642
|
+
status: value.status,
|
|
20643
|
+
url: value.url
|
|
20644
|
+
});
|
|
20645
|
+
if (value.stack !== void 0) error48.stack = value.stack;
|
|
20646
|
+
return error48;
|
|
20647
|
+
}, "StreamError"),
|
|
20578
20648
|
SyntaxError: makeErrorSubclassReviver(global2, "SyntaxError"),
|
|
20579
20649
|
TypeError: makeErrorSubclassReviver(global2, "TypeError"),
|
|
20580
20650
|
URIError: makeErrorSubclassReviver(global2, "URIError"),
|
|
@@ -25982,7 +26052,7 @@ var version2;
|
|
|
25982
26052
|
var init_version = __esm({
|
|
25983
26053
|
"../core/dist/version.js"() {
|
|
25984
26054
|
"use strict";
|
|
25985
|
-
version2 = "5.0.0-beta.
|
|
26055
|
+
version2 = "5.0.0-beta.49";
|
|
25986
26056
|
}
|
|
25987
26057
|
});
|
|
25988
26058
|
|
|
@@ -31690,6 +31760,18 @@ function recordReadTimeToFirstChunk(startEpochMs, runId, name, startIndex, conne
|
|
|
31690
31760
|
});
|
|
31691
31761
|
})();
|
|
31692
31762
|
}
|
|
31763
|
+
function recordStreamReadKeyResolution(startEpochMs, runId, name, succeeded) {
|
|
31764
|
+
void (async () => {
|
|
31765
|
+
await recordElapsedSpan("workflow.stream.read.resolve_key", startEpochMs, {
|
|
31766
|
+
kind: await getSpanKind("CLIENT"),
|
|
31767
|
+
attributes: {
|
|
31768
|
+
"workflow.run.id": runId,
|
|
31769
|
+
"workflow.stream.name": name,
|
|
31770
|
+
"workflow.stream.read.key_succeeded": succeeded
|
|
31771
|
+
}
|
|
31772
|
+
});
|
|
31773
|
+
})();
|
|
31774
|
+
}
|
|
31693
31775
|
function recordStreamReadComplete(startEpochMs, runId, name, chunkCount, byteCount, reconnects) {
|
|
31694
31776
|
void (async () => {
|
|
31695
31777
|
await recordElapsedSpan("workflow.stream.read.complete", startEpochMs, {
|
|
@@ -31708,26 +31790,46 @@ function recordStreamReadComplete(startEpochMs, runId, name, chunkCount, byteCou
|
|
|
31708
31790
|
});
|
|
31709
31791
|
})();
|
|
31710
31792
|
}
|
|
31711
|
-
function createReconnectingFramedStream(runId, name, startIndex) {
|
|
31793
|
+
function createReconnectingFramedStream(runId, name, startIndex, prefetchEncryptionKey = async () => void 0) {
|
|
31712
31794
|
const reconnectSupported = startIndex === void 0 || startIndex >= 0;
|
|
31713
31795
|
let currentStartIndex = startIndex ?? 0;
|
|
31714
31796
|
let consumedFrames = 0;
|
|
31715
31797
|
let reconnectCount = 0;
|
|
31716
31798
|
let totalReconnectCount = 0;
|
|
31717
31799
|
let reader;
|
|
31800
|
+
let canceled = false;
|
|
31801
|
+
let cancelReason;
|
|
31718
31802
|
let buffer2 = new Uint8Array(0);
|
|
31719
31803
|
let readStart;
|
|
31720
31804
|
let connectMs;
|
|
31721
31805
|
let firstChunkReported = false;
|
|
31722
31806
|
let chunksDelivered = 0;
|
|
31723
31807
|
let bytesDelivered = 0;
|
|
31808
|
+
let keyPrefetched = false;
|
|
31809
|
+
function prefetchKey() {
|
|
31810
|
+
if (keyPrefetched) return;
|
|
31811
|
+
keyPrefetched = true;
|
|
31812
|
+
const keyStart = Date.now();
|
|
31813
|
+
void prefetchEncryptionKey().then((key) => {
|
|
31814
|
+
if (key) recordStreamReadKeyResolution(keyStart, runId, name, true);
|
|
31815
|
+
}, () => recordStreamReadKeyResolution(keyStart, runId, name, false));
|
|
31816
|
+
}
|
|
31817
|
+
__name(prefetchKey, "prefetchKey");
|
|
31724
31818
|
async function connect() {
|
|
31819
|
+
if (canceled) return false;
|
|
31725
31820
|
const world = await getWorldLazy();
|
|
31821
|
+
if (canceled) return false;
|
|
31726
31822
|
const effectiveStartIndex = reconnectSupported ? currentStartIndex + consumedFrames : startIndex;
|
|
31727
31823
|
const connectStart = Date.now();
|
|
31728
31824
|
const stream = await world.streams.get(runId, name, effectiveStartIndex);
|
|
31825
|
+
if (canceled) {
|
|
31826
|
+
await stream.cancel(cancelReason).catch(() => {
|
|
31827
|
+
});
|
|
31828
|
+
return false;
|
|
31829
|
+
}
|
|
31729
31830
|
if (connectMs === void 0) connectMs = Date.now() - connectStart;
|
|
31730
31831
|
reader = stream.getReader();
|
|
31832
|
+
return true;
|
|
31731
31833
|
}
|
|
31732
31834
|
__name(connect, "connect");
|
|
31733
31835
|
async function isVerifiedComplete() {
|
|
@@ -31741,11 +31843,13 @@ function createReconnectingFramedStream(runId, name, startIndex) {
|
|
|
31741
31843
|
}
|
|
31742
31844
|
__name(isVerifiedComplete, "isVerifiedComplete");
|
|
31743
31845
|
async function reconnect() {
|
|
31846
|
+
if (canceled) return false;
|
|
31744
31847
|
if (reader) {
|
|
31745
31848
|
await reader.cancel().catch(() => {
|
|
31746
31849
|
});
|
|
31747
31850
|
reader = void 0;
|
|
31748
31851
|
}
|
|
31852
|
+
if (canceled) return false;
|
|
31749
31853
|
currentStartIndex += consumedFrames;
|
|
31750
31854
|
consumedFrames = 0;
|
|
31751
31855
|
buffer2 = new Uint8Array(0);
|
|
@@ -31755,15 +31859,16 @@ function createReconnectingFramedStream(runId, name, startIndex) {
|
|
|
31755
31859
|
reconnectCount++;
|
|
31756
31860
|
totalReconnectCount++;
|
|
31757
31861
|
if (reconnectCount > maxReconnects) {
|
|
31758
|
-
throw new
|
|
31862
|
+
throw new StreamError(`Stream "${name}" exceeded maximum reconnection attempts (${maxReconnects})`);
|
|
31759
31863
|
}
|
|
31760
31864
|
if (totalReconnectCount > maxTotalReconnects) {
|
|
31761
|
-
throw new
|
|
31865
|
+
throw new StreamError(`Stream "${name}" exceeded maximum total reconnection attempts (${maxTotalReconnects})`);
|
|
31762
31866
|
}
|
|
31763
31867
|
try {
|
|
31764
|
-
await connect();
|
|
31765
|
-
return;
|
|
31868
|
+
if (!await connect()) return false;
|
|
31869
|
+
return true;
|
|
31766
31870
|
} catch (error48) {
|
|
31871
|
+
if (canceled) return false;
|
|
31767
31872
|
if (StreamExpiredError.is(error48)) throw error48;
|
|
31768
31873
|
}
|
|
31769
31874
|
}
|
|
@@ -31771,12 +31876,15 @@ function createReconnectingFramedStream(runId, name, startIndex) {
|
|
|
31771
31876
|
__name(reconnect, "reconnect");
|
|
31772
31877
|
return new ReadableStream({
|
|
31773
31878
|
pull: /* @__PURE__ */ __name(async (controller) => {
|
|
31879
|
+
if (canceled) return;
|
|
31774
31880
|
if (readStart === void 0) readStart = Date.now();
|
|
31881
|
+
prefetchKey();
|
|
31775
31882
|
for (; ; ) {
|
|
31776
31883
|
if (!reader) {
|
|
31777
31884
|
try {
|
|
31778
|
-
await connect();
|
|
31885
|
+
if (!await connect()) return;
|
|
31779
31886
|
} catch (err) {
|
|
31887
|
+
if (canceled) return;
|
|
31780
31888
|
controller.error(err);
|
|
31781
31889
|
return;
|
|
31782
31890
|
}
|
|
@@ -31785,23 +31893,27 @@ function createReconnectingFramedStream(runId, name, startIndex) {
|
|
|
31785
31893
|
try {
|
|
31786
31894
|
result = await reader.read();
|
|
31787
31895
|
} catch (err) {
|
|
31896
|
+
if (canceled) return;
|
|
31788
31897
|
if (!reconnectSupported) {
|
|
31789
31898
|
controller.error(err);
|
|
31790
31899
|
return;
|
|
31791
31900
|
}
|
|
31792
31901
|
try {
|
|
31793
|
-
await reconnect();
|
|
31902
|
+
if (!await reconnect()) return;
|
|
31794
31903
|
} catch (reconnectErr) {
|
|
31795
31904
|
controller.error(reconnectErr);
|
|
31796
31905
|
return;
|
|
31797
31906
|
}
|
|
31798
31907
|
continue;
|
|
31799
31908
|
}
|
|
31909
|
+
if (canceled) return;
|
|
31800
31910
|
if (result.done || !result.value) {
|
|
31801
31911
|
reader = void 0;
|
|
31802
|
-
|
|
31912
|
+
const verifiedComplete = !reconnectSupported || await isVerifiedComplete();
|
|
31913
|
+
if (canceled) return;
|
|
31914
|
+
if (!verifiedComplete) {
|
|
31803
31915
|
try {
|
|
31804
|
-
await reconnect();
|
|
31916
|
+
if (!await reconnect()) return;
|
|
31805
31917
|
} catch (reconnectErr) {
|
|
31806
31918
|
controller.error(reconnectErr);
|
|
31807
31919
|
return;
|
|
@@ -31843,12 +31955,15 @@ function createReconnectingFramedStream(runId, name, startIndex) {
|
|
|
31843
31955
|
}
|
|
31844
31956
|
}
|
|
31845
31957
|
}, "pull"),
|
|
31846
|
-
cancel: /* @__PURE__ */ __name(async () => {
|
|
31847
|
-
|
|
31848
|
-
|
|
31958
|
+
cancel: /* @__PURE__ */ __name(async (reason) => {
|
|
31959
|
+
canceled = true;
|
|
31960
|
+
cancelReason = reason;
|
|
31961
|
+
const currentReader = reader;
|
|
31962
|
+
reader = void 0;
|
|
31963
|
+
if (currentReader) {
|
|
31964
|
+
await currentReader.cancel(reason).catch((err) => {
|
|
31849
31965
|
console.warn("Error closing ReadableStream reader:", err);
|
|
31850
31966
|
});
|
|
31851
|
-
reader = void 0;
|
|
31852
31967
|
}
|
|
31853
31968
|
}, "cancel")
|
|
31854
31969
|
});
|
|
@@ -32353,7 +32468,87 @@ async function getForwardedWritableEncryptionKey(runId, deploymentId, encryption
|
|
|
32353
32468
|
"encrypt"
|
|
32354
32469
|
]) : void 0;
|
|
32355
32470
|
}
|
|
32356
|
-
function
|
|
32471
|
+
function tagForwardedWritableTarget(writable, { deploymentId, encryptionPublicKey }) {
|
|
32472
|
+
if (typeof deploymentId === "string") {
|
|
32473
|
+
Object.defineProperty(writable, STREAM_SERVER_DEPLOYMENT_ID_SYMBOL, {
|
|
32474
|
+
value: deploymentId,
|
|
32475
|
+
writable: false
|
|
32476
|
+
});
|
|
32477
|
+
}
|
|
32478
|
+
if (typeof encryptionPublicKey === "string") {
|
|
32479
|
+
Object.defineProperty(writable, STREAM_SERVER_PUBLIC_KEY_SYMBOL, {
|
|
32480
|
+
value: encryptionPublicKey,
|
|
32481
|
+
writable: false
|
|
32482
|
+
});
|
|
32483
|
+
}
|
|
32484
|
+
}
|
|
32485
|
+
function createForwardedWritable({ global: global2, ops, runId, name, key, deploymentId, encryptionPublicKey, runReadyBarrier }) {
|
|
32486
|
+
const serialize3 = getSerializeStream(getExternalReducers(global2, ops, runId, key), key);
|
|
32487
|
+
const serverWritable = new WorkflowServerWritableStream(runId, name, runReadyBarrier);
|
|
32488
|
+
const state = createFlushableState();
|
|
32489
|
+
ops.push(state.promise);
|
|
32490
|
+
flushablePipe(serialize3.readable, serverWritable, state).catch(() => {
|
|
32491
|
+
});
|
|
32492
|
+
pollWritableLock(serialize3.writable, state);
|
|
32493
|
+
Object.defineProperty(serialize3.writable, STREAM_NAME_SYMBOL, {
|
|
32494
|
+
value: name,
|
|
32495
|
+
writable: false
|
|
32496
|
+
});
|
|
32497
|
+
Object.defineProperty(serialize3.writable, STREAM_SERVER_RUN_ID_SYMBOL, {
|
|
32498
|
+
value: runId,
|
|
32499
|
+
writable: false
|
|
32500
|
+
});
|
|
32501
|
+
tagForwardedWritableTarget(serialize3.writable, {
|
|
32502
|
+
deploymentId,
|
|
32503
|
+
encryptionPublicKey
|
|
32504
|
+
});
|
|
32505
|
+
return serialize3.writable;
|
|
32506
|
+
}
|
|
32507
|
+
function getRunReadableStream(global2, ops, runId, name, startIndex, cryptoKey) {
|
|
32508
|
+
let reader;
|
|
32509
|
+
let lockState;
|
|
32510
|
+
let lockPollingStarted = false;
|
|
32511
|
+
let userReadable;
|
|
32512
|
+
userReadable = new ReadableStream(
|
|
32513
|
+
{
|
|
32514
|
+
async pull(controller) {
|
|
32515
|
+
try {
|
|
32516
|
+
if (!reader) {
|
|
32517
|
+
const stream = getExternalRevivers(global2, ops, runId, cryptoKey, {
|
|
32518
|
+
onReadableState: /* @__PURE__ */ __name((state) => {
|
|
32519
|
+
lockState = state;
|
|
32520
|
+
}, "onReadableState")
|
|
32521
|
+
}).ReadableStream({
|
|
32522
|
+
name,
|
|
32523
|
+
startIndex
|
|
32524
|
+
});
|
|
32525
|
+
reader = stream.getReader();
|
|
32526
|
+
if (lockState && !lockPollingStarted) {
|
|
32527
|
+
lockPollingStarted = true;
|
|
32528
|
+
pollReadableLock(userReadable, lockState);
|
|
32529
|
+
}
|
|
32530
|
+
}
|
|
32531
|
+
const result = await reader.read();
|
|
32532
|
+
if (result.done) controller.close();
|
|
32533
|
+
else controller.enqueue(result.value);
|
|
32534
|
+
} catch (error48) {
|
|
32535
|
+
controller.error(error48);
|
|
32536
|
+
}
|
|
32537
|
+
},
|
|
32538
|
+
async cancel(reason) {
|
|
32539
|
+
await reader?.cancel(reason).catch(() => {
|
|
32540
|
+
});
|
|
32541
|
+
}
|
|
32542
|
+
},
|
|
32543
|
+
// A positive default high-water mark would run pull at construction to
|
|
32544
|
+
// fill the queue, turning an unread Run.getReadable() into I/O.
|
|
32545
|
+
{
|
|
32546
|
+
highWaterMark: 0
|
|
32547
|
+
}
|
|
32548
|
+
);
|
|
32549
|
+
return userReadable;
|
|
32550
|
+
}
|
|
32551
|
+
function getExternalRevivers(global2 = globalThis, ops, runId, cryptoKey, options) {
|
|
32357
32552
|
return {
|
|
32358
32553
|
...getCommonRevivers2(global2),
|
|
32359
32554
|
// StepFunction should not be returned from workflows to clients
|
|
@@ -32401,50 +32596,38 @@ function getExternalRevivers(global2 = globalThis, ops, runId, cryptoKey) {
|
|
|
32401
32596
|
const { readable: userReadable, writable } = value.framing === "framed-v1" ? getByteUnframingStream() : new global2.TransformStream();
|
|
32402
32597
|
flushablePipe(readable, writable, state).catch(() => {
|
|
32403
32598
|
});
|
|
32404
|
-
|
|
32599
|
+
if (options?.onReadableState) options.onReadableState(state);
|
|
32600
|
+
else pollReadableLock(userReadable, state);
|
|
32405
32601
|
return userReadable;
|
|
32406
32602
|
} else {
|
|
32407
|
-
|
|
32408
|
-
const
|
|
32603
|
+
let keyPromise;
|
|
32604
|
+
const resolveKey = /* @__PURE__ */ __name(() => {
|
|
32605
|
+
keyPromise ??= resolveEncryptionKey(cryptoKey);
|
|
32606
|
+
return keyPromise;
|
|
32607
|
+
}, "resolveKey");
|
|
32608
|
+
const readable = createReconnectingFramedStream(runId, value.name, value.startIndex, resolveKey);
|
|
32609
|
+
const transform2 = getDeserializeStream(getExternalRevivers(global2, ops, runId, resolveKey), resolveKey);
|
|
32409
32610
|
const state = createFlushableState();
|
|
32410
32611
|
ops.push(state.promise);
|
|
32411
32612
|
flushablePipe(readable, transform2.writable, state).catch(() => {
|
|
32412
32613
|
});
|
|
32413
|
-
|
|
32614
|
+
if (options?.onReadableState) options.onReadableState(state);
|
|
32615
|
+
else pollReadableLock(transform2.readable, state);
|
|
32414
32616
|
return transform2.readable;
|
|
32415
32617
|
}
|
|
32416
32618
|
}, "ReadableStream"),
|
|
32417
32619
|
WritableStream: /* @__PURE__ */ __name((value) => {
|
|
32418
32620
|
const targetRunId = typeof value.runId === "string" ? value.runId : runId;
|
|
32419
32621
|
const targetKey = targetRunId === runId ? cryptoKey : getForwardedWritableEncryptionKey(targetRunId, value.deploymentId, value.encryptionPublicKey);
|
|
32420
|
-
|
|
32421
|
-
|
|
32422
|
-
|
|
32423
|
-
|
|
32424
|
-
|
|
32425
|
-
|
|
32426
|
-
|
|
32427
|
-
|
|
32428
|
-
value: value.name,
|
|
32429
|
-
writable: false
|
|
32430
|
-
});
|
|
32431
|
-
Object.defineProperty(serialize3.writable, STREAM_SERVER_RUN_ID_SYMBOL, {
|
|
32432
|
-
value: targetRunId,
|
|
32433
|
-
writable: false
|
|
32622
|
+
return createForwardedWritable({
|
|
32623
|
+
global: global2,
|
|
32624
|
+
ops,
|
|
32625
|
+
runId: targetRunId,
|
|
32626
|
+
name: value.name,
|
|
32627
|
+
key: targetKey,
|
|
32628
|
+
deploymentId: value.deploymentId,
|
|
32629
|
+
encryptionPublicKey: value.encryptionPublicKey
|
|
32434
32630
|
});
|
|
32435
|
-
if (typeof value.deploymentId === "string") {
|
|
32436
|
-
Object.defineProperty(serialize3.writable, STREAM_SERVER_DEPLOYMENT_ID_SYMBOL, {
|
|
32437
|
-
value: value.deploymentId,
|
|
32438
|
-
writable: false
|
|
32439
|
-
});
|
|
32440
|
-
}
|
|
32441
|
-
if (typeof value.encryptionPublicKey === "string") {
|
|
32442
|
-
Object.defineProperty(serialize3.writable, STREAM_SERVER_PUBLIC_KEY_SYMBOL, {
|
|
32443
|
-
value: value.encryptionPublicKey,
|
|
32444
|
-
writable: false
|
|
32445
|
-
});
|
|
32446
|
-
}
|
|
32447
|
-
return serialize3.writable;
|
|
32448
32631
|
}, "WritableStream"),
|
|
32449
32632
|
AbortController: /* @__PURE__ */ __name((value) => reviveAbortController(value, ops, runId), "AbortController"),
|
|
32450
32633
|
AbortSignal: /* @__PURE__ */ __name((value) => reviveAbortSignal(value, ops, runId), "AbortSignal")
|
|
@@ -32806,6 +32989,7 @@ var init_serialization2 = __esm({
|
|
|
32806
32989
|
__name(getByteFramingStream, "getByteFramingStream");
|
|
32807
32990
|
__name(getByteUnframingStream, "getByteUnframingStream");
|
|
32808
32991
|
__name(recordReadTimeToFirstChunk, "recordReadTimeToFirstChunk");
|
|
32992
|
+
__name(recordStreamReadKeyResolution, "recordStreamReadKeyResolution");
|
|
32809
32993
|
__name(recordStreamReadComplete, "recordStreamReadComplete");
|
|
32810
32994
|
WorkflowServerReadableStream = class extends ReadableStream {
|
|
32811
32995
|
static {
|
|
@@ -32916,6 +33100,14 @@ var init_serialization2 = __esm({
|
|
|
32916
33100
|
pendingRunReady = void 0;
|
|
32917
33101
|
}
|
|
32918
33102
|
}, "ensureRunReady");
|
|
33103
|
+
const writerId = `wrtr_${defaultUlid()}`;
|
|
33104
|
+
const writeSessionPromise = ensureRunReady().then(async () => {
|
|
33105
|
+
const world = await worldPromise;
|
|
33106
|
+
return world.streams.createWriteSession?.(runId, name, {
|
|
33107
|
+
writerId
|
|
33108
|
+
});
|
|
33109
|
+
});
|
|
33110
|
+
let nextChunkSeq = 0;
|
|
32919
33111
|
let buffer2 = [];
|
|
32920
33112
|
let bufferBytes = 0;
|
|
32921
33113
|
let inFlightChunks = 0;
|
|
@@ -32961,14 +33153,18 @@ var init_serialization2 = __esm({
|
|
|
32961
33153
|
const sendGroup = /* @__PURE__ */ __name(async (group, bytes, groupT0) => {
|
|
32962
33154
|
await ensureRunReady();
|
|
32963
33155
|
const world = await worldPromise;
|
|
33156
|
+
const session = await writeSessionPromise;
|
|
32964
33157
|
const dispatchAt = Date.now();
|
|
32965
|
-
if (
|
|
33158
|
+
if (session) {
|
|
33159
|
+
await session.write(nextChunkSeq, group);
|
|
33160
|
+
} else if (typeof world.streams.writeMulti === "function" && group.length > 1) {
|
|
32966
33161
|
await world.streams.writeMulti(runId, name, group);
|
|
32967
33162
|
} else {
|
|
32968
33163
|
for (const chunk of group) {
|
|
32969
33164
|
await world.streams.write(runId, name, chunk);
|
|
32970
33165
|
}
|
|
32971
33166
|
}
|
|
33167
|
+
nextChunkSeq += group.length;
|
|
32972
33168
|
if (groupT0 !== void 0) {
|
|
32973
33169
|
recordStreamWriteFlush(groupT0, dispatchAt, runId, name, group.length, bytes, Date.now() - dispatchAt);
|
|
32974
33170
|
}
|
|
@@ -33079,8 +33275,13 @@ var init_serialization2 = __esm({
|
|
|
33079
33275
|
await drain();
|
|
33080
33276
|
await ensureRunReady();
|
|
33081
33277
|
const world = await worldPromise;
|
|
33278
|
+
const session = await writeSessionPromise;
|
|
33082
33279
|
const closeStart = Date.now();
|
|
33083
|
-
|
|
33280
|
+
if (session) {
|
|
33281
|
+
await session.close();
|
|
33282
|
+
} else {
|
|
33283
|
+
await world.streams.close(runId, name);
|
|
33284
|
+
}
|
|
33084
33285
|
recordStreamClose(closeStart, runId, name);
|
|
33085
33286
|
},
|
|
33086
33287
|
async abort(reason) {
|
|
@@ -33096,6 +33297,8 @@ var init_serialization2 = __esm({
|
|
|
33096
33297
|
bufferBytes = 0;
|
|
33097
33298
|
sinkError ??= reason ?? new Error("Stream aborted");
|
|
33098
33299
|
rejectWaiters(sinkError);
|
|
33300
|
+
const session = await writeSessionPromise.catch(() => void 0);
|
|
33301
|
+
await session?.dispose?.();
|
|
33099
33302
|
}
|
|
33100
33303
|
});
|
|
33101
33304
|
Object.defineProperty(this, STREAM_DRAIN_SYMBOL, {
|
|
@@ -33120,6 +33323,9 @@ var init_serialization2 = __esm({
|
|
|
33120
33323
|
__name(reviveAbortSignal, "reviveAbortSignal");
|
|
33121
33324
|
__name(getCommonRevivers2, "getCommonRevivers");
|
|
33122
33325
|
__name(getForwardedWritableEncryptionKey, "getForwardedWritableEncryptionKey");
|
|
33326
|
+
__name(tagForwardedWritableTarget, "tagForwardedWritableTarget");
|
|
33327
|
+
__name(createForwardedWritable, "createForwardedWritable");
|
|
33328
|
+
__name(getRunReadableStream, "getRunReadableStream");
|
|
33123
33329
|
__name(getExternalRevivers, "getExternalRevivers");
|
|
33124
33330
|
__name(getStepRevivers, "getStepRevivers");
|
|
33125
33331
|
__name(dehydrateWorkflowArguments, "dehydrateWorkflowArguments");
|
|
@@ -33298,7 +33504,8 @@ var WORLD_CONTRACT_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
|
33298
33504
|
]);
|
|
33299
33505
|
var RETRYABLE_WORLD_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
33300
33506
|
"TRANSPORT",
|
|
33301
|
-
"TIMEOUT"
|
|
33507
|
+
"TIMEOUT",
|
|
33508
|
+
RUN_ERROR_CODES.STREAM_ERROR
|
|
33302
33509
|
]);
|
|
33303
33510
|
var RUNTIME_ERROR_CHECKS = [
|
|
33304
33511
|
WorkflowRuntimeError.is,
|
|
@@ -33314,6 +33521,9 @@ function isRetryableWorldError(err) {
|
|
|
33314
33521
|
if (ThrottleError.is(err)) {
|
|
33315
33522
|
return true;
|
|
33316
33523
|
}
|
|
33524
|
+
if (StreamError.is(err)) {
|
|
33525
|
+
return err.status === void 0 || err.status >= 500;
|
|
33526
|
+
}
|
|
33317
33527
|
if (!WorkflowWorldError.is(err)) {
|
|
33318
33528
|
return false;
|
|
33319
33529
|
}
|
|
@@ -33356,6 +33566,7 @@ __name(getWorkflowVmFromEnv, "getWorkflowVmFromEnv");
|
|
|
33356
33566
|
init_wait_until();
|
|
33357
33567
|
init_world_compatibility();
|
|
33358
33568
|
var CROSS_DEPLOYMENT_CAPABILITY_PROBE_TIMEOUT_MS = 2e3;
|
|
33569
|
+
var RETENTION_ZERO_ATTRIBUTE_VALUE = "0";
|
|
33359
33570
|
var ulid3 = monotonicFactory();
|
|
33360
33571
|
function resolveLineageAttributes() {
|
|
33361
33572
|
const store = contextStorage.getStore();
|
|
@@ -33460,14 +33671,27 @@ async function start(workflow, argsOrOptions, options) {
|
|
|
33460
33671
|
value
|
|
33461
33672
|
]));
|
|
33462
33673
|
}
|
|
33674
|
+
let retentionAttribute;
|
|
33675
|
+
if (opts.experimental_retention !== void 0 && opts.experimental_retention !== "default") {
|
|
33676
|
+
if (opts.experimental_retention !== 0) {
|
|
33677
|
+
throw new WorkflowRuntimeError(`start({ experimental_retention }) must be 0 or 'default'; received ${JSON.stringify(opts.experimental_retention)}.`);
|
|
33678
|
+
}
|
|
33679
|
+
if (specVersion < SPEC_VERSION_SUPPORTS_ATTRIBUTES) {
|
|
33680
|
+
throw new WorkflowRuntimeError("start({ experimental_retention }) requires a World that supports spec version 4 or later.");
|
|
33681
|
+
}
|
|
33682
|
+
retentionAttribute = {
|
|
33683
|
+
[RETENTION_ATTRIBUTE]: RETENTION_ZERO_ATTRIBUTE_VALUE
|
|
33684
|
+
};
|
|
33685
|
+
}
|
|
33463
33686
|
const lineage = specVersion >= SPEC_VERSION_SUPPORTS_ATTRIBUTES ? resolveLineageAttributes() : void 0;
|
|
33464
|
-
const runAttributes = lineage ? {
|
|
33687
|
+
const runAttributes = lineage || retentionAttribute ? {
|
|
33465
33688
|
...lineage,
|
|
33466
|
-
...attributes
|
|
33689
|
+
...attributes,
|
|
33690
|
+
...retentionAttribute
|
|
33467
33691
|
} : attributes;
|
|
33468
33692
|
const attributeSeed = runAttributes ? {
|
|
33469
33693
|
attributes: runAttributes,
|
|
33470
|
-
...allowReservedAttributes || lineage != null ? {
|
|
33694
|
+
...allowReservedAttributes || lineage != null || retentionAttribute != null ? {
|
|
33471
33695
|
allowReservedAttributes: true
|
|
33472
33696
|
} : {}
|
|
33473
33697
|
} : {};
|
|
@@ -33613,7 +33837,7 @@ __name(start, "start");
|
|
|
33613
33837
|
value: "start",
|
|
33614
33838
|
configurable: true
|
|
33615
33839
|
});
|
|
33616
|
-
})(start, "step//@workflow/core/runtime/start@5.0.0-beta.
|
|
33840
|
+
})(start, "step//@workflow/core/runtime/start@5.0.0-beta.49//start");
|
|
33617
33841
|
|
|
33618
33842
|
// ../core/dist/runtime/runs.js
|
|
33619
33843
|
async function wakeUpRun(world, runId, options) {
|
|
@@ -33704,6 +33928,11 @@ var PAYLOAD_TERMINAL_RUN_STATUSES = /* @__PURE__ */ new Set([
|
|
|
33704
33928
|
"completed",
|
|
33705
33929
|
"failed"
|
|
33706
33930
|
]);
|
|
33931
|
+
var NOT_FOUND_RETRY_DELAYS = [
|
|
33932
|
+
1e3,
|
|
33933
|
+
3e3,
|
|
33934
|
+
6e3
|
|
33935
|
+
];
|
|
33707
33936
|
function getReturnValuePollIntervalMs() {
|
|
33708
33937
|
return envNumber("WORKFLOW_RETURN_VALUE_POLL_INTERVAL_MS", RETURN_VALUE_POLL_INTERVAL_MS, {
|
|
33709
33938
|
integer: true,
|
|
@@ -33797,9 +34026,9 @@ var Run = class _Run {
|
|
|
33797
34026
|
return this.#encryptionKeyPromise;
|
|
33798
34027
|
}
|
|
33799
34028
|
/**
|
|
33800
|
-
*
|
|
33801
|
-
*
|
|
33802
|
-
*
|
|
34029
|
+
* Defers fetching the run and its encryption key until a readable is first
|
|
34030
|
+
* consumed. The first pull prefetches it so an encrypted first frame can join
|
|
34031
|
+
* the lookup; this also applies to an empty consumed stream.
|
|
33803
34032
|
* @internal
|
|
33804
34033
|
*/
|
|
33805
34034
|
#getEncryptionKeyLazily() {
|
|
@@ -33910,10 +34139,7 @@ var Run = class _Run {
|
|
|
33910
34139
|
const { ops = [], global: global2 = globalThis, startIndex, namespace } = options;
|
|
33911
34140
|
const name = getWorkflowRunStreamId(this.runId, namespace);
|
|
33912
34141
|
const encryptionKey = this.#getEncryptionKeyLazily();
|
|
33913
|
-
const stream =
|
|
33914
|
-
name,
|
|
33915
|
-
startIndex
|
|
33916
|
-
});
|
|
34142
|
+
const stream = getRunReadableStream(global2, ops, this.runId, name, startIndex, encryptionKey);
|
|
33917
34143
|
const worldPromise = this.#lazyWorldPromise;
|
|
33918
34144
|
const runId = this.runId;
|
|
33919
34145
|
return Object.assign(stream, {
|
|
@@ -33924,8 +34150,75 @@ var Run = class _Run {
|
|
|
33924
34150
|
}, "getTailIndex")
|
|
33925
34151
|
});
|
|
33926
34152
|
}
|
|
34153
|
+
/** The writable stream of the workflow run. */
|
|
34154
|
+
get writable() {
|
|
34155
|
+
return this.getWritable();
|
|
34156
|
+
}
|
|
34157
|
+
/**
|
|
34158
|
+
* Returns a writable that appends to this run's stream.
|
|
34159
|
+
*
|
|
34160
|
+
* Initialization is deferred until the first write. The run must already
|
|
34161
|
+
* exist. The writable may be forwarded through `start()` and into steps, but
|
|
34162
|
+
* grants no read access or additional authorization.
|
|
34163
|
+
*
|
|
34164
|
+
* @remarks
|
|
34165
|
+
* `writer.close()` closes the shared stream. Contributors should call
|
|
34166
|
+
* `releaseLock()`, which also drains pending writes.
|
|
34167
|
+
*
|
|
34168
|
+
* @param options - The writable stream options.
|
|
34169
|
+
*/
|
|
34170
|
+
getWritable(options = {}) {
|
|
34171
|
+
const { ops = [], global: global2 = globalThis, namespace } = options;
|
|
34172
|
+
const name = getWorkflowRunStreamId(this.runId, namespace);
|
|
34173
|
+
let targetPromise;
|
|
34174
|
+
let writable;
|
|
34175
|
+
const resolveTarget = /* @__PURE__ */ __name(() => {
|
|
34176
|
+
targetPromise ??= this.#getMetadata().then(async (run2) => {
|
|
34177
|
+
const target = {
|
|
34178
|
+
key: await getForwardedWritableEncryptionKey(this.runId, run2.deploymentId, run2.encryptionPublicKey),
|
|
34179
|
+
deploymentId: run2.deploymentId,
|
|
34180
|
+
encryptionPublicKey: run2.encryptionPublicKey
|
|
34181
|
+
};
|
|
34182
|
+
tagForwardedWritableTarget(writable, target);
|
|
34183
|
+
return target;
|
|
34184
|
+
});
|
|
34185
|
+
return targetPromise;
|
|
34186
|
+
}, "resolveTarget");
|
|
34187
|
+
writable = createForwardedWritable({
|
|
34188
|
+
global: global2,
|
|
34189
|
+
ops,
|
|
34190
|
+
runId: this.runId,
|
|
34191
|
+
name,
|
|
34192
|
+
key: /* @__PURE__ */ __name(() => resolveTarget().then(({ key }) => key), "key")
|
|
34193
|
+
});
|
|
34194
|
+
return writable;
|
|
34195
|
+
}
|
|
34196
|
+
/** Reads metadata, briefly retrying resilient starts. @internal */
|
|
34197
|
+
async #getMetadata() {
|
|
34198
|
+
const world = await this.#lazyWorldPromise;
|
|
34199
|
+
const maxRetries = this.#resilientStart ? NOT_FOUND_RETRY_DELAYS.length : 0;
|
|
34200
|
+
let attempt = 0;
|
|
34201
|
+
while (true) {
|
|
34202
|
+
try {
|
|
34203
|
+
return await world.runs.get(this.runId, {
|
|
34204
|
+
resolveData: "none"
|
|
34205
|
+
});
|
|
34206
|
+
} catch (error48) {
|
|
34207
|
+
if (!WorkflowRunNotFoundError.is(error48) || attempt >= maxRetries) {
|
|
34208
|
+
throw error48;
|
|
34209
|
+
}
|
|
34210
|
+
const delay = NOT_FOUND_RETRY_DELAYS[attempt];
|
|
34211
|
+
attempt++;
|
|
34212
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
34213
|
+
}
|
|
34214
|
+
}
|
|
34215
|
+
}
|
|
33927
34216
|
/** @internal */
|
|
33928
34217
|
async #resolveTerminalReturnValue(run2) {
|
|
34218
|
+
const expiredAt = run2.expiredAt;
|
|
34219
|
+
if (expiredAt != null && expiredAt <= /* @__PURE__ */ new Date()) {
|
|
34220
|
+
throw new RunExpiredError(`Run "${this.runId}" ${run2.status === "completed" ? "completed" : `is ${run2.status}`}, but its data expired at ${expiredAt.toISOString()} and is no longer readable.`, this.runId, run2.status, expiredAt);
|
|
34221
|
+
}
|
|
33929
34222
|
if (run2.status === "completed") {
|
|
33930
34223
|
const encryptionKey = await this.#getEncryptionKey(run2);
|
|
33931
34224
|
return await hydrateWorkflowReturnValue(run2.output, this.runId, encryptionKey);
|
|
@@ -33955,12 +34248,7 @@ var Run = class _Run {
|
|
|
33955
34248
|
async #pollReturnValue() {
|
|
33956
34249
|
const world = await this.#lazyWorldPromise;
|
|
33957
34250
|
let notFoundRetries = 0;
|
|
33958
|
-
const NOT_FOUND_MAX_RETRIES = this.#resilientStart ?
|
|
33959
|
-
const NOT_FOUND_DELAYS = [
|
|
33960
|
-
1e3,
|
|
33961
|
-
3e3,
|
|
33962
|
-
6e3
|
|
33963
|
-
];
|
|
34251
|
+
const NOT_FOUND_MAX_RETRIES = this.#resilientStart ? NOT_FOUND_RETRY_DELAYS.length : 0;
|
|
33964
34252
|
const waitForTerminalStatus = isReturnValueLongPollEnabled() ? world.runs.waitForTerminalStatus?.bind(world.runs) : void 0;
|
|
33965
34253
|
let longPolls = 0;
|
|
33966
34254
|
const maxLongPolls = getReturnValueMaxLongPolls();
|
|
@@ -33994,7 +34282,7 @@ var Run = class _Run {
|
|
|
33994
34282
|
continue;
|
|
33995
34283
|
}
|
|
33996
34284
|
if (WorkflowRunNotFoundError.is(error48) && notFoundRetries < NOT_FOUND_MAX_RETRIES) {
|
|
33997
|
-
const delay =
|
|
34285
|
+
const delay = NOT_FOUND_RETRY_DELAYS[notFoundRetries];
|
|
33998
34286
|
notFoundRetries++;
|
|
33999
34287
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
34000
34288
|
continue;
|
|
@@ -34012,7 +34300,7 @@ var Run = class _Run {
|
|
|
34012
34300
|
value: "wakeUp",
|
|
34013
34301
|
configurable: true
|
|
34014
34302
|
});
|
|
34015
|
-
})(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
34303
|
+
})(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.49//Run#wakeUp");
|
|
34016
34304
|
(function(__wf_fn, __wf_id) {
|
|
34017
34305
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
34018
34306
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -34021,7 +34309,7 @@ var Run = class _Run {
|
|
|
34021
34309
|
value: "cancel",
|
|
34022
34310
|
configurable: true
|
|
34023
34311
|
});
|
|
34024
|
-
})(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
34312
|
+
})(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.49//Run#cancel");
|
|
34025
34313
|
(function(__wf_fn, __wf_id) {
|
|
34026
34314
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
34027
34315
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -34030,7 +34318,16 @@ var Run = class _Run {
|
|
|
34030
34318
|
value: "getReadable",
|
|
34031
34319
|
configurable: true
|
|
34032
34320
|
});
|
|
34033
|
-
})(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
34321
|
+
})(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.49//Run#getReadable");
|
|
34322
|
+
(function(__wf_fn, __wf_id) {
|
|
34323
|
+
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
34324
|
+
__wf_reg.set(__wf_id, __wf_fn);
|
|
34325
|
+
__wf_fn.stepId = __wf_id;
|
|
34326
|
+
Object.defineProperty(__wf_fn, "name", {
|
|
34327
|
+
value: "getWritable",
|
|
34328
|
+
configurable: true
|
|
34329
|
+
});
|
|
34330
|
+
})(Run.prototype["getWritable"], "step//@workflow/core/runtime/run@5.0.0-beta.49//Run#getWritable");
|
|
34034
34331
|
(function(__wf_fn, __wf_id) {
|
|
34035
34332
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
34036
34333
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -34039,7 +34336,7 @@ var Run = class _Run {
|
|
|
34039
34336
|
value: "exists",
|
|
34040
34337
|
configurable: true
|
|
34041
34338
|
});
|
|
34042
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
34339
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.49//Run#exists");
|
|
34043
34340
|
(function(__wf_fn, __wf_id) {
|
|
34044
34341
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
34045
34342
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -34048,7 +34345,7 @@ var Run = class _Run {
|
|
|
34048
34345
|
value: "status",
|
|
34049
34346
|
configurable: true
|
|
34050
34347
|
});
|
|
34051
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
34348
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.49//Run#status");
|
|
34052
34349
|
(function(__wf_fn, __wf_id) {
|
|
34053
34350
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
34054
34351
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -34057,7 +34354,7 @@ var Run = class _Run {
|
|
|
34057
34354
|
value: "returnValue",
|
|
34058
34355
|
configurable: true
|
|
34059
34356
|
});
|
|
34060
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
34357
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.49//Run#returnValue");
|
|
34061
34358
|
(function(__wf_fn, __wf_id) {
|
|
34062
34359
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
34063
34360
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -34066,7 +34363,7 @@ var Run = class _Run {
|
|
|
34066
34363
|
value: "workflowName",
|
|
34067
34364
|
configurable: true
|
|
34068
34365
|
});
|
|
34069
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
34366
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.49//Run#workflowName");
|
|
34070
34367
|
(function(__wf_fn, __wf_id) {
|
|
34071
34368
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
34072
34369
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -34075,7 +34372,7 @@ var Run = class _Run {
|
|
|
34075
34372
|
value: "createdAt",
|
|
34076
34373
|
configurable: true
|
|
34077
34374
|
});
|
|
34078
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
34375
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.49//Run#createdAt");
|
|
34079
34376
|
(function(__wf_fn, __wf_id) {
|
|
34080
34377
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
34081
34378
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -34084,7 +34381,7 @@ var Run = class _Run {
|
|
|
34084
34381
|
value: "startedAt",
|
|
34085
34382
|
configurable: true
|
|
34086
34383
|
});
|
|
34087
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
34384
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.49//Run#startedAt");
|
|
34088
34385
|
(function(__wf_fn, __wf_id) {
|
|
34089
34386
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
34090
34387
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -34093,7 +34390,7 @@ var Run = class _Run {
|
|
|
34093
34390
|
value: "completedAt",
|
|
34094
34391
|
configurable: true
|
|
34095
34392
|
});
|
|
34096
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
34393
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.49//Run#completedAt");
|
|
34097
34394
|
(function(__wf_cls, __wf_id) {
|
|
34098
34395
|
var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
34099
34396
|
__wf_reg.set(__wf_id, __wf_cls);
|
|
@@ -34103,7 +34400,7 @@ var Run = class _Run {
|
|
|
34103
34400
|
enumerable: false,
|
|
34104
34401
|
configurable: false
|
|
34105
34402
|
});
|
|
34106
|
-
})(Run, "class//@workflow/core/runtime/run@5.0.0-beta.
|
|
34403
|
+
})(Run, "class//@workflow/core/runtime/run@5.0.0-beta.49//Run");
|
|
34107
34404
|
|
|
34108
34405
|
// ../workflow/dist/stdlib.js
|
|
34109
34406
|
async function fetch2(...args) {
|