@workflow/world-testing 5.0.0-beta.52 → 5.0.0-beta.54
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.
|
@@ -20629,6 +20629,12 @@ function readRunRetention(attributes) {
|
|
|
20629
20629
|
function purgesUserDataOnFinish(attributes) {
|
|
20630
20630
|
return readRunRetention(attributes).mode === "none";
|
|
20631
20631
|
}
|
|
20632
|
+
function validateAttributeEventDataSize2(eventData) {
|
|
20633
|
+
const bytes = textEncoder3.encode(JSON.stringify(eventData)).length;
|
|
20634
|
+
if (bytes > ATTRIBUTE_EVENT_DATA_MAX_BYTES2) {
|
|
20635
|
+
throw new AttributeValidationError2(`Attribute eventData exceeds limit ${ATTRIBUTE_EVENT_DATA_MAX_BYTES2} UTF-8 JSON bytes (received ${bytes} bytes). Split the changes into smaller setAttributes() calls.`);
|
|
20636
|
+
}
|
|
20637
|
+
}
|
|
20632
20638
|
function assertValidAttributeKey2(key, allowReservedAttributes) {
|
|
20633
20639
|
if (typeof key !== "string") {
|
|
20634
20640
|
throw new AttributeValidationError2(`Attribute key must be a string, got ${typeof key}`);
|
|
@@ -20692,7 +20698,7 @@ function applyAttributeChanges(existing, changes) {
|
|
|
20692
20698
|
}
|
|
20693
20699
|
return next2;
|
|
20694
20700
|
}
|
|
20695
|
-
var RESERVED_ATTRIBUTE_KEY_PREFIX2, ROOT_RUN_ID_ATTRIBUTE2, PARENT_RUN_ID_ATTRIBUTE2, RETENTION_ATTRIBUTE2, RETENTION_ZERO, RETENTION_DEFAULT, RETENTION_INTEGER_PATTERN, ATTRIBUTE_KEY_MAX_LENGTH2, ATTRIBUTE_VALUE_MAX_BYTES2, ATTRIBUTE_MAX_PER_RUN2, textEncoder3, AttributeValidationError2;
|
|
20701
|
+
var RESERVED_ATTRIBUTE_KEY_PREFIX2, ROOT_RUN_ID_ATTRIBUTE2, PARENT_RUN_ID_ATTRIBUTE2, RETENTION_ATTRIBUTE2, RETENTION_ZERO, RETENTION_DEFAULT, RETENTION_INTEGER_PATTERN, ATTRIBUTE_KEY_MAX_LENGTH2, ATTRIBUTE_VALUE_MAX_BYTES2, ATTRIBUTE_MAX_PER_RUN2, ATTRIBUTE_EVENT_DATA_MAX_BYTES2, textEncoder3, AttributeValidationError2;
|
|
20696
20702
|
var init_attributes_validation2 = __esm({
|
|
20697
20703
|
"../world/dist/attributes-validation.js"() {
|
|
20698
20704
|
"use strict";
|
|
@@ -20708,6 +20714,7 @@ var init_attributes_validation2 = __esm({
|
|
|
20708
20714
|
ATTRIBUTE_KEY_MAX_LENGTH2 = 256;
|
|
20709
20715
|
ATTRIBUTE_VALUE_MAX_BYTES2 = 256;
|
|
20710
20716
|
ATTRIBUTE_MAX_PER_RUN2 = 64;
|
|
20717
|
+
ATTRIBUTE_EVENT_DATA_MAX_BYTES2 = 8192;
|
|
20711
20718
|
textEncoder3 = new TextEncoder();
|
|
20712
20719
|
AttributeValidationError2 = class extends Error {
|
|
20713
20720
|
static {
|
|
@@ -20718,6 +20725,7 @@ var init_attributes_validation2 = __esm({
|
|
|
20718
20725
|
this.name = "AttributeValidationError";
|
|
20719
20726
|
}
|
|
20720
20727
|
};
|
|
20728
|
+
__name(validateAttributeEventDataSize2, "validateAttributeEventDataSize");
|
|
20721
20729
|
__name(assertValidAttributeKey2, "assertValidAttributeKey");
|
|
20722
20730
|
__name(assertValidAttributeValue2, "assertValidAttributeValue");
|
|
20723
20731
|
__name(attributeCountDelta2, "attributeCountDelta");
|
|
@@ -21899,6 +21907,11 @@ var init_queue2 = __esm({
|
|
|
21899
21907
|
}));
|
|
21900
21908
|
WorkflowInvokePayloadSchema2 = external_exports2.compile(external_exports2.object({
|
|
21901
21909
|
runId: external_exports2.string(),
|
|
21910
|
+
/** Process this input and return the handler's result as response data. */
|
|
21911
|
+
invoke: external_exports2.literal(true).optional(),
|
|
21912
|
+
/** Identifies one input across retries, separately from the queue delivery ID. */
|
|
21913
|
+
requestId: external_exports2.string().optional(),
|
|
21914
|
+
input: external_exports2.unknown().optional(),
|
|
21902
21915
|
traceCarrier: TraceCarrierSchema2.optional(),
|
|
21903
21916
|
requestedAt: external_exports2.coerce.date().optional(),
|
|
21904
21917
|
/**
|
|
@@ -22509,6 +22522,7 @@ __export(dist_exports, {
|
|
|
22509
22522
|
ANALYTICS_MAX_ATTRIBUTE_FILTERS: () => ANALYTICS_MAX_ATTRIBUTE_FILTERS,
|
|
22510
22523
|
ANALYTICS_PAGE_LIMIT: () => ANALYTICS_PAGE_LIMIT,
|
|
22511
22524
|
ANALYTICS_RUN_SCOPED_PAGE_LIMIT: () => ANALYTICS_RUN_SCOPED_PAGE_LIMIT,
|
|
22525
|
+
ATTRIBUTE_EVENT_DATA_MAX_BYTES: () => ATTRIBUTE_EVENT_DATA_MAX_BYTES2,
|
|
22512
22526
|
ATTRIBUTE_KEY_MAX_LENGTH: () => ATTRIBUTE_KEY_MAX_LENGTH2,
|
|
22513
22527
|
ATTRIBUTE_MAX_PER_RUN: () => ATTRIBUTE_MAX_PER_RUN2,
|
|
22514
22528
|
ATTRIBUTE_VALUE_MAX_BYTES: () => ATTRIBUTE_VALUE_MAX_BYTES2,
|
|
@@ -22633,6 +22647,7 @@ __export(dist_exports, {
|
|
|
22633
22647
|
stripEventDataRefs: () => stripEventDataRefs,
|
|
22634
22648
|
ulidToDate: () => ulidToDate,
|
|
22635
22649
|
validateAttributeChanges: () => validateAttributeChanges2,
|
|
22650
|
+
validateAttributeEventDataSize: () => validateAttributeEventDataSize2,
|
|
22636
22651
|
validateUlidTimestamp: () => validateUlidTimestamp,
|
|
22637
22652
|
workflowRunIdSchema: () => workflowRunIdSchema2
|
|
22638
22653
|
});
|
|
@@ -29272,7 +29287,7 @@ var require_dispatcher = __commonJS({
|
|
|
29272
29287
|
"use strict";
|
|
29273
29288
|
var EventEmitter3 = __require("node:events");
|
|
29274
29289
|
var WrapHandler = require_wrap_handler();
|
|
29275
|
-
var wrapInterceptor = /* @__PURE__ */ __name((
|
|
29290
|
+
var wrapInterceptor = /* @__PURE__ */ __name((dispatch2) => (opts, handler) => dispatch2(opts, WrapHandler.wrap(handler)), "wrapInterceptor");
|
|
29276
29291
|
var Dispatcher = class extends EventEmitter3 {
|
|
29277
29292
|
static {
|
|
29278
29293
|
__name(this, "Dispatcher");
|
|
@@ -29288,7 +29303,7 @@ var require_dispatcher = __commonJS({
|
|
|
29288
29303
|
}
|
|
29289
29304
|
compose(...args) {
|
|
29290
29305
|
const interceptors = Array.isArray(args[0]) ? args[0] : args;
|
|
29291
|
-
let
|
|
29306
|
+
let dispatch2 = this.dispatch.bind(this);
|
|
29292
29307
|
for (const interceptor of interceptors) {
|
|
29293
29308
|
if (interceptor == null) {
|
|
29294
29309
|
continue;
|
|
@@ -29296,14 +29311,14 @@ var require_dispatcher = __commonJS({
|
|
|
29296
29311
|
if (typeof interceptor !== "function") {
|
|
29297
29312
|
throw new TypeError(`invalid interceptor, expected function received ${typeof interceptor}`);
|
|
29298
29313
|
}
|
|
29299
|
-
|
|
29300
|
-
|
|
29301
|
-
if (
|
|
29314
|
+
dispatch2 = interceptor(dispatch2);
|
|
29315
|
+
dispatch2 = wrapInterceptor(dispatch2);
|
|
29316
|
+
if (dispatch2 == null || typeof dispatch2 !== "function" || dispatch2.length !== 2) {
|
|
29302
29317
|
throw new TypeError("invalid interceptor");
|
|
29303
29318
|
}
|
|
29304
29319
|
}
|
|
29305
29320
|
return new Proxy(this, {
|
|
29306
|
-
get: /* @__PURE__ */ __name((target2, key) => key === "dispatch" ?
|
|
29321
|
+
get: /* @__PURE__ */ __name((target2, key) => key === "dispatch" ? dispatch2 : target2[key], "get")
|
|
29307
29322
|
});
|
|
29308
29323
|
}
|
|
29309
29324
|
};
|
|
@@ -37913,7 +37928,7 @@ var require_retry_handler = __commonJS({
|
|
|
37913
37928
|
static {
|
|
37914
37929
|
__name(this, "RetryHandler");
|
|
37915
37930
|
}
|
|
37916
|
-
constructor(opts, { dispatch, handler }) {
|
|
37931
|
+
constructor(opts, { dispatch: dispatch2, handler }) {
|
|
37917
37932
|
const { retryOptions, ...dispatchOpts } = opts;
|
|
37918
37933
|
const {
|
|
37919
37934
|
// Retry scoped
|
|
@@ -37930,7 +37945,7 @@ var require_retry_handler = __commonJS({
|
|
|
37930
37945
|
throwOnError
|
|
37931
37946
|
} = retryOptions ?? {};
|
|
37932
37947
|
this.error = null;
|
|
37933
|
-
this.dispatch =
|
|
37948
|
+
this.dispatch = dispatch2;
|
|
37934
37949
|
this.handler = WrapHandler.wrap(handler);
|
|
37935
37950
|
this.opts = { ...dispatchOpts, body: wrapRequestBody(opts.body) };
|
|
37936
37951
|
this.retryOpts = {
|
|
@@ -39779,11 +39794,11 @@ var require_mock_utils = __commonJS({
|
|
|
39779
39794
|
}
|
|
39780
39795
|
__name(addMockDispatch, "addMockDispatch");
|
|
39781
39796
|
function deleteMockDispatch(mockDispatches, key) {
|
|
39782
|
-
const index = mockDispatches.findIndex((
|
|
39783
|
-
if (!
|
|
39797
|
+
const index = mockDispatches.findIndex((dispatch2) => {
|
|
39798
|
+
if (!dispatch2.consumed) {
|
|
39784
39799
|
return false;
|
|
39785
39800
|
}
|
|
39786
|
-
return matchKey(
|
|
39801
|
+
return matchKey(dispatch2, key);
|
|
39787
39802
|
});
|
|
39788
39803
|
if (index !== -1) {
|
|
39789
39804
|
mockDispatches.splice(index, 1);
|
|
@@ -39911,7 +39926,7 @@ var require_mock_utils = __commonJS({
|
|
|
39911
39926
|
const agent = this[kMockAgent];
|
|
39912
39927
|
const origin = this[kOrigin];
|
|
39913
39928
|
const originalDispatch = this[kOriginalDispatch];
|
|
39914
|
-
return /* @__PURE__ */ __name(function
|
|
39929
|
+
return /* @__PURE__ */ __name(function dispatch2(opts, handler) {
|
|
39915
39930
|
if (agent.isMockActive) {
|
|
39916
39931
|
try {
|
|
39917
39932
|
mockDispatch.call(this, opts, handler);
|
|
@@ -40714,7 +40729,7 @@ var require_mock_agent = __commonJS({
|
|
|
40714
40729
|
}
|
|
40715
40730
|
pendingInterceptors() {
|
|
40716
40731
|
const mockAgentClients = this[kClients];
|
|
40717
|
-
return Array.from(mockAgentClients.entries()).flatMap(([origin, result2]) => result2.dispatcher[kDispatches].map((
|
|
40732
|
+
return Array.from(mockAgentClients.entries()).flatMap(([origin, result2]) => result2.dispatcher[kDispatches].map((dispatch2) => ({ ...dispatch2, origin }))).filter(({ pending }) => pending);
|
|
40718
40733
|
}
|
|
40719
40734
|
assertNoPendingInterceptors({ pendingInterceptorsFormatter = new PendingInterceptorsFormatter() } = {}) {
|
|
40720
40735
|
const pending = this.pendingInterceptors();
|
|
@@ -41648,14 +41663,14 @@ var require_redirect_handler = __commonJS({
|
|
|
41648
41663
|
if (maxRedirections != null && (!Number.isInteger(maxRedirections) || maxRedirections < 0)) {
|
|
41649
41664
|
throw new InvalidArgumentError("maxRedirections must be a positive number");
|
|
41650
41665
|
}
|
|
41651
|
-
const
|
|
41652
|
-
return (opts, originalHandler) =>
|
|
41666
|
+
const dispatch2 = dispatcher.dispatch.bind(dispatcher);
|
|
41667
|
+
return (opts, originalHandler) => dispatch2(opts, new _RedirectHandler(dispatch2, maxRedirections, opts, originalHandler));
|
|
41653
41668
|
}
|
|
41654
|
-
constructor(
|
|
41669
|
+
constructor(dispatch2, maxRedirections, opts, handler) {
|
|
41655
41670
|
if (maxRedirections != null && (!Number.isInteger(maxRedirections) || maxRedirections < 0)) {
|
|
41656
41671
|
throw new InvalidArgumentError("maxRedirections must be a positive number");
|
|
41657
41672
|
}
|
|
41658
|
-
this.dispatch =
|
|
41673
|
+
this.dispatch = dispatch2;
|
|
41659
41674
|
this.location = null;
|
|
41660
41675
|
const { maxRedirections: _, ...cleanOpts } = opts;
|
|
41661
41676
|
this.opts = cleanOpts;
|
|
@@ -41787,15 +41802,15 @@ var require_redirect = __commonJS({
|
|
|
41787
41802
|
"use strict";
|
|
41788
41803
|
var RedirectHandler = require_redirect_handler();
|
|
41789
41804
|
function createRedirectInterceptor({ maxRedirections: defaultMaxRedirections } = {}) {
|
|
41790
|
-
return (
|
|
41805
|
+
return (dispatch2) => {
|
|
41791
41806
|
return /* @__PURE__ */ __name(function Intercept(opts, handler) {
|
|
41792
41807
|
const { maxRedirections = defaultMaxRedirections, ...rest } = opts;
|
|
41793
41808
|
if (maxRedirections == null || maxRedirections === 0) {
|
|
41794
|
-
return
|
|
41809
|
+
return dispatch2(opts, handler);
|
|
41795
41810
|
}
|
|
41796
41811
|
const dispatchOpts = { ...rest };
|
|
41797
|
-
const redirectHandler = new RedirectHandler(
|
|
41798
|
-
return
|
|
41812
|
+
const redirectHandler = new RedirectHandler(dispatch2, maxRedirections, dispatchOpts, handler);
|
|
41813
|
+
return dispatch2(dispatchOpts, redirectHandler);
|
|
41799
41814
|
}, "Intercept");
|
|
41800
41815
|
};
|
|
41801
41816
|
}
|
|
@@ -41880,9 +41895,9 @@ var require_response_error = __commonJS({
|
|
|
41880
41895
|
}
|
|
41881
41896
|
};
|
|
41882
41897
|
module.exports = () => {
|
|
41883
|
-
return (
|
|
41898
|
+
return (dispatch2) => {
|
|
41884
41899
|
return /* @__PURE__ */ __name(function Intercept(opts, handler) {
|
|
41885
|
-
return
|
|
41900
|
+
return dispatch2(opts, new ResponseErrorHandler(opts, { handler }));
|
|
41886
41901
|
}, "Intercept");
|
|
41887
41902
|
};
|
|
41888
41903
|
};
|
|
@@ -41895,15 +41910,15 @@ var require_retry = __commonJS({
|
|
|
41895
41910
|
"use strict";
|
|
41896
41911
|
var RetryHandler = require_retry_handler();
|
|
41897
41912
|
module.exports = (globalOpts) => {
|
|
41898
|
-
return (
|
|
41913
|
+
return (dispatch2) => {
|
|
41899
41914
|
return /* @__PURE__ */ __name(function retryInterceptor(opts, handler) {
|
|
41900
|
-
return
|
|
41915
|
+
return dispatch2(
|
|
41901
41916
|
opts,
|
|
41902
41917
|
new RetryHandler(
|
|
41903
41918
|
{ ...opts, retryOptions: { ...globalOpts, ...opts.retryOptions } },
|
|
41904
41919
|
{
|
|
41905
41920
|
handler,
|
|
41906
|
-
dispatch
|
|
41921
|
+
dispatch: dispatch2
|
|
41907
41922
|
}
|
|
41908
41923
|
)
|
|
41909
41924
|
);
|
|
@@ -41990,11 +42005,11 @@ var require_dump = __commonJS({
|
|
|
41990
42005
|
function createDumpInterceptor({ maxSize: defaultMaxSize } = {
|
|
41991
42006
|
maxSize: 1024 * 1024
|
|
41992
42007
|
}) {
|
|
41993
|
-
return (
|
|
42008
|
+
return (dispatch2) => {
|
|
41994
42009
|
return /* @__PURE__ */ __name(function Intercept(opts, handler) {
|
|
41995
42010
|
const { dumpMaxSize = defaultMaxSize } = opts;
|
|
41996
42011
|
const dumpHandler = new DumpHandler({ maxSize: dumpMaxSize, signal: opts.signal }, handler);
|
|
41997
|
-
return
|
|
42012
|
+
return dispatch2(opts, dumpHandler);
|
|
41998
42013
|
}, "Intercept");
|
|
41999
42014
|
};
|
|
42000
42015
|
}
|
|
@@ -42329,13 +42344,13 @@ var require_dns = __commonJS({
|
|
|
42329
42344
|
#controller = null;
|
|
42330
42345
|
#newOrigin = null;
|
|
42331
42346
|
#firstTry = true;
|
|
42332
|
-
constructor(state, { origin, handler, dispatch, newOrigin }, opts) {
|
|
42347
|
+
constructor(state, { origin, handler, dispatch: dispatch2, newOrigin }, opts) {
|
|
42333
42348
|
super(handler);
|
|
42334
42349
|
this.#origin = origin;
|
|
42335
42350
|
this.#newOrigin = newOrigin;
|
|
42336
42351
|
this.#opts = { ...opts };
|
|
42337
42352
|
this.#state = state;
|
|
42338
|
-
this.#dispatch =
|
|
42353
|
+
this.#dispatch = dispatch2;
|
|
42339
42354
|
}
|
|
42340
42355
|
onResponseError(controller, err) {
|
|
42341
42356
|
switch (err.code) {
|
|
@@ -42424,11 +42439,11 @@ var require_dns = __commonJS({
|
|
|
42424
42439
|
storage: interceptorOpts?.storage
|
|
42425
42440
|
};
|
|
42426
42441
|
const instance = new DNSInstance(opts);
|
|
42427
|
-
return (
|
|
42442
|
+
return (dispatch2) => {
|
|
42428
42443
|
return /* @__PURE__ */ __name(function dnsInterceptor(origDispatchOpts, handler) {
|
|
42429
42444
|
const origin = origDispatchOpts.origin.constructor === URL ? origDispatchOpts.origin : new URL(origDispatchOpts.origin);
|
|
42430
42445
|
if (isIP(origin.hostname) !== 0) {
|
|
42431
|
-
return
|
|
42446
|
+
return dispatch2(origDispatchOpts, handler);
|
|
42432
42447
|
}
|
|
42433
42448
|
instance.runLookup(origin, origDispatchOpts, (err, newOrigin) => {
|
|
42434
42449
|
if (err) {
|
|
@@ -42441,10 +42456,10 @@ var require_dns = __commonJS({
|
|
|
42441
42456
|
origin: newOrigin.origin,
|
|
42442
42457
|
headers: withHostHeader(origin.host, origDispatchOpts.headers)
|
|
42443
42458
|
};
|
|
42444
|
-
|
|
42459
|
+
dispatch2(
|
|
42445
42460
|
dispatchOpts,
|
|
42446
42461
|
instance.getHandler(
|
|
42447
|
-
{ origin, dispatch, handler, newOrigin },
|
|
42462
|
+
{ origin, dispatch: dispatch2, handler, newOrigin },
|
|
42448
42463
|
origDispatchOpts
|
|
42449
42464
|
)
|
|
42450
42465
|
);
|
|
@@ -44465,7 +44480,7 @@ var require_cache3 = __commonJS({
|
|
|
44465
44480
|
return now2 <= staleWhileRevalidateExpiry;
|
|
44466
44481
|
}
|
|
44467
44482
|
__name(withinStaleWhileRevalidateWindow, "withinStaleWhileRevalidateWindow");
|
|
44468
|
-
function handleUncachedResponse(
|
|
44483
|
+
function handleUncachedResponse(dispatch2, globalOpts, cacheKey, handler, opts, reqCacheControl) {
|
|
44469
44484
|
if (reqCacheControl?.["only-if-cached"]) {
|
|
44470
44485
|
let aborted3 = false;
|
|
44471
44486
|
try {
|
|
@@ -44493,7 +44508,7 @@ var require_cache3 = __commonJS({
|
|
|
44493
44508
|
}
|
|
44494
44509
|
return true;
|
|
44495
44510
|
}
|
|
44496
|
-
return
|
|
44511
|
+
return dispatch2(opts, new CacheHandler(globalOpts, cacheKey, handler));
|
|
44497
44512
|
}
|
|
44498
44513
|
__name(handleUncachedResponse, "handleUncachedResponse");
|
|
44499
44514
|
function sendCachedValue(handler, opts, result2, age, context2, isStale2) {
|
|
@@ -44551,13 +44566,13 @@ var require_cache3 = __commonJS({
|
|
|
44551
44566
|
}
|
|
44552
44567
|
}
|
|
44553
44568
|
__name(sendCachedValue, "sendCachedValue");
|
|
44554
|
-
function handleResult(
|
|
44569
|
+
function handleResult(dispatch2, globalOpts, cacheKey, handler, opts, reqCacheControl, result2) {
|
|
44555
44570
|
if (!result2) {
|
|
44556
|
-
return handleUncachedResponse(
|
|
44571
|
+
return handleUncachedResponse(dispatch2, globalOpts, cacheKey, handler, opts, reqCacheControl);
|
|
44557
44572
|
}
|
|
44558
44573
|
const now2 = Date.now();
|
|
44559
44574
|
if (now2 > result2.deleteAt) {
|
|
44560
|
-
return
|
|
44575
|
+
return dispatch2(opts, new CacheHandler(globalOpts, cacheKey, handler));
|
|
44561
44576
|
}
|
|
44562
44577
|
const age = Math.round((now2 - result2.cachedAt) / 1e3);
|
|
44563
44578
|
const requestMaxAgeExpired = reqCacheControl?.["max-age"] !== void 0 && age >= reqCacheControl["max-age"];
|
|
@@ -44565,13 +44580,13 @@ var require_cache3 = __commonJS({
|
|
|
44565
44580
|
const revalidate = requestMaxAgeExpired || needsRevalidation(result2, reqCacheControl, opts);
|
|
44566
44581
|
if (stale || revalidate) {
|
|
44567
44582
|
if (util.isStream(opts.body) && util.bodyLength(opts.body) !== 0) {
|
|
44568
|
-
return
|
|
44583
|
+
return dispatch2(opts, new CacheHandler(globalOpts, cacheKey, handler));
|
|
44569
44584
|
}
|
|
44570
44585
|
if (!revalidate && withinStaleWhileRevalidateWindow(result2, globalOpts.type)) {
|
|
44571
44586
|
sendCachedValue(handler, opts, result2, age, null, true);
|
|
44572
44587
|
queueMicrotask(() => {
|
|
44573
44588
|
const headers2 = makeRevalidationHeaders(opts, result2);
|
|
44574
|
-
|
|
44589
|
+
dispatch2(
|
|
44575
44590
|
{
|
|
44576
44591
|
...opts,
|
|
44577
44592
|
headers: headers2
|
|
@@ -44603,7 +44618,7 @@ var require_cache3 = __commonJS({
|
|
|
44603
44618
|
}
|
|
44604
44619
|
}
|
|
44605
44620
|
const headers = makeRevalidationHeaders(opts, result2);
|
|
44606
|
-
return
|
|
44621
|
+
return dispatch2(
|
|
44607
44622
|
{
|
|
44608
44623
|
...opts,
|
|
44609
44624
|
headers
|
|
@@ -44617,7 +44632,7 @@ var require_cache3 = __commonJS({
|
|
|
44617
44632
|
result2.body.on("error", nop).destroy();
|
|
44618
44633
|
}
|
|
44619
44634
|
deleteCachedValue(globalOpts.store, cacheKey);
|
|
44620
|
-
return
|
|
44635
|
+
return dispatch2(opts, new CacheHandler(globalOpts, cacheKey, handler));
|
|
44621
44636
|
}
|
|
44622
44637
|
if (revalidationResponseUpdatesCacheControl(headers2)) {
|
|
44623
44638
|
deleteCachedValue(globalOpts.store, cacheKey);
|
|
@@ -44672,10 +44687,10 @@ var require_cache3 = __commonJS({
|
|
|
44672
44687
|
safeMethodsToNotCache.push(method);
|
|
44673
44688
|
}
|
|
44674
44689
|
}
|
|
44675
|
-
return (
|
|
44690
|
+
return (dispatch2) => {
|
|
44676
44691
|
return (opts2, handler) => {
|
|
44677
44692
|
if (!opts2.origin || arrayIncludes(safeMethodsToNotCache, opts2.method)) {
|
|
44678
|
-
return
|
|
44693
|
+
return dispatch2(opts2, handler);
|
|
44679
44694
|
}
|
|
44680
44695
|
if (origins !== void 0) {
|
|
44681
44696
|
const requestOrigin = opts2.origin.toString().toLowerCase();
|
|
@@ -44693,7 +44708,7 @@ var require_cache3 = __commonJS({
|
|
|
44693
44708
|
}
|
|
44694
44709
|
}
|
|
44695
44710
|
if (!isAllowed) {
|
|
44696
|
-
return
|
|
44711
|
+
return dispatch2(opts2, handler);
|
|
44697
44712
|
}
|
|
44698
44713
|
}
|
|
44699
44714
|
opts2 = {
|
|
@@ -44702,13 +44717,13 @@ var require_cache3 = __commonJS({
|
|
|
44702
44717
|
};
|
|
44703
44718
|
const reqCacheControl = opts2.headers?.["cache-control"] ? parseCacheControlHeader(opts2.headers["cache-control"]) : hasPragmaNoCache(opts2.headers) ? { "no-cache": true } : void 0;
|
|
44704
44719
|
if (reqCacheControl?.["no-store"]) {
|
|
44705
|
-
return
|
|
44720
|
+
return dispatch2(opts2, handler);
|
|
44706
44721
|
}
|
|
44707
44722
|
const cacheKey = makeCacheKey(opts2);
|
|
44708
44723
|
const result2 = store.get(cacheKey);
|
|
44709
44724
|
if (result2 && typeof result2.then === "function") {
|
|
44710
44725
|
return result2.then((result3) => handleResult(
|
|
44711
|
-
|
|
44726
|
+
dispatch2,
|
|
44712
44727
|
globalOpts,
|
|
44713
44728
|
cacheKey,
|
|
44714
44729
|
handler,
|
|
@@ -44718,7 +44733,7 @@ var require_cache3 = __commonJS({
|
|
|
44718
44733
|
));
|
|
44719
44734
|
} else {
|
|
44720
44735
|
return handleResult(
|
|
44721
|
-
|
|
44736
|
+
dispatch2,
|
|
44722
44737
|
globalOpts,
|
|
44723
44738
|
cacheKey,
|
|
44724
44739
|
handler,
|
|
@@ -44939,10 +44954,10 @@ var require_decompress = __commonJS({
|
|
|
44939
44954
|
);
|
|
44940
44955
|
warningEmitted = true;
|
|
44941
44956
|
}
|
|
44942
|
-
return (
|
|
44957
|
+
return (dispatch2) => {
|
|
44943
44958
|
return (opts, handler) => {
|
|
44944
44959
|
const decompressHandler = new DecompressHandler(handler, options);
|
|
44945
|
-
return
|
|
44960
|
+
return dispatch2(opts, decompressHandler);
|
|
44946
44961
|
};
|
|
44947
44962
|
};
|
|
44948
44963
|
}
|
|
@@ -45352,10 +45367,10 @@ var require_deduplicate = __commonJS({
|
|
|
45352
45367
|
const skipHeaderNamesSet = new Set(skipHeaderNames.map((name) => name.toLowerCase()));
|
|
45353
45368
|
const excludeHeaderNamesSet = new Set(excludeHeaderNames.map((name) => name.toLowerCase()));
|
|
45354
45369
|
const pendingRequests = /* @__PURE__ */ new Map();
|
|
45355
|
-
return (
|
|
45370
|
+
return (dispatch2) => {
|
|
45356
45371
|
return (opts2, handler) => {
|
|
45357
45372
|
if (!opts2.origin || methods.includes(opts2.method) === false) {
|
|
45358
|
-
return
|
|
45373
|
+
return dispatch2(opts2, handler);
|
|
45359
45374
|
}
|
|
45360
45375
|
opts2 = {
|
|
45361
45376
|
...opts2,
|
|
@@ -45364,7 +45379,7 @@ var require_deduplicate = __commonJS({
|
|
|
45364
45379
|
if (skipHeaderNamesSet.size > 0) {
|
|
45365
45380
|
for (const headerName of Object.keys(opts2.headers)) {
|
|
45366
45381
|
if (skipHeaderNamesSet.has(headerName.toLowerCase())) {
|
|
45367
|
-
return
|
|
45382
|
+
return dispatch2(opts2, handler);
|
|
45368
45383
|
}
|
|
45369
45384
|
}
|
|
45370
45385
|
}
|
|
@@ -45375,7 +45390,7 @@ var require_deduplicate = __commonJS({
|
|
|
45375
45390
|
if (pendingHandler.addWaitingHandler(handler)) {
|
|
45376
45391
|
return true;
|
|
45377
45392
|
}
|
|
45378
|
-
return
|
|
45393
|
+
return dispatch2(opts2, handler);
|
|
45379
45394
|
}
|
|
45380
45395
|
const deduplicationHandler = new DeduplicationHandler(
|
|
45381
45396
|
handler,
|
|
@@ -45391,7 +45406,7 @@ var require_deduplicate = __commonJS({
|
|
|
45391
45406
|
if (pendingRequestsChannel.hasSubscribers) {
|
|
45392
45407
|
pendingRequestsChannel.publish({ size: pendingRequests.size, key: dedupeKey, type: "added" });
|
|
45393
45408
|
}
|
|
45394
|
-
return
|
|
45409
|
+
return dispatch2(opts2, deduplicationHandler);
|
|
45395
45410
|
};
|
|
45396
45411
|
};
|
|
45397
45412
|
};
|
|
@@ -48451,7 +48466,7 @@ var require_fetch = __commonJS({
|
|
|
48451
48466
|
})();
|
|
48452
48467
|
}
|
|
48453
48468
|
try {
|
|
48454
|
-
const { body, status, statusText, headersList, socket } = await
|
|
48469
|
+
const { body, status, statusText, headersList, socket } = await dispatch2({ body: requestBody });
|
|
48455
48470
|
if (socket) {
|
|
48456
48471
|
response = makeResponse({ status, statusText, headersList, socket });
|
|
48457
48472
|
} else {
|
|
@@ -48548,7 +48563,7 @@ var require_fetch = __commonJS({
|
|
|
48548
48563
|
}
|
|
48549
48564
|
__name(onAborted, "onAborted");
|
|
48550
48565
|
return response;
|
|
48551
|
-
function
|
|
48566
|
+
function dispatch2({ body }) {
|
|
48552
48567
|
const url3 = requestCurrentURL(request);
|
|
48553
48568
|
const agent = fetchParams.controller.dispatcher;
|
|
48554
48569
|
const path15 = url3.pathname + url3.search;
|
|
@@ -48729,7 +48744,7 @@ var require_fetch = __commonJS({
|
|
|
48729
48744
|
}
|
|
48730
48745
|
));
|
|
48731
48746
|
}
|
|
48732
|
-
__name(
|
|
48747
|
+
__name(dispatch2, "dispatch");
|
|
48733
48748
|
}
|
|
48734
48749
|
__name(httpNetworkFetch, "httpNetworkFetch");
|
|
48735
48750
|
module.exports = {
|
|
@@ -53163,8 +53178,11 @@ function createQueue(config4) {
|
|
|
53163
53178
|
const body = await new TypedJsonTransport().deserialize(req.body);
|
|
53164
53179
|
try {
|
|
53165
53180
|
const result2 = await handler(body, { attempt, queueName, messageId });
|
|
53181
|
+
if (typeof body === "object" && body !== null && "invoke" in body && body.invoke === true) {
|
|
53182
|
+
return Response.json({ result: result2 });
|
|
53183
|
+
}
|
|
53166
53184
|
let timeoutSeconds = null;
|
|
53167
|
-
if (typeof result2
|
|
53185
|
+
if (typeof result2 === "object" && result2 !== null && "timeoutSeconds" in result2 && typeof result2.timeoutSeconds === "number") {
|
|
53168
53186
|
timeoutSeconds = Math.min(result2.timeoutSeconds, LOCAL_QUEUE_MAX_VISIBILITY);
|
|
53169
53187
|
}
|
|
53170
53188
|
if (timeoutSeconds != null) {
|
|
@@ -61824,7 +61842,7 @@ var version4;
|
|
|
61824
61842
|
var init_version3 = __esm({
|
|
61825
61843
|
"../world-vercel/dist/version.js"() {
|
|
61826
61844
|
"use strict";
|
|
61827
|
-
version4 = "5.0.0-beta.
|
|
61845
|
+
version4 = "5.0.0-beta.49";
|
|
61828
61846
|
}
|
|
61829
61847
|
});
|
|
61830
61848
|
|
|
@@ -61872,7 +61890,7 @@ function deadlineInterceptor(timeoutMs) {
|
|
|
61872
61890
|
super.onResponseError(controller, error121);
|
|
61873
61891
|
}
|
|
61874
61892
|
}
|
|
61875
|
-
return (
|
|
61893
|
+
return (dispatch2) => (opts, handler) => dispatch2(opts, new DeadlineHandler(handler));
|
|
61876
61894
|
}
|
|
61877
61895
|
function h2EventsEnabled() {
|
|
61878
61896
|
return process.env.WORKFLOW_H2_MULTIPLEX !== "0";
|
|
@@ -61885,13 +61903,13 @@ function contentLength(headers) {
|
|
|
61885
61903
|
const raw = record3["content-length"] ?? record3["Content-Length"];
|
|
61886
61904
|
return typeof raw === "string" || typeof raw === "number" ? Number(raw) : Number.NaN;
|
|
61887
61905
|
}
|
|
61888
|
-
function h2MultiplexInterceptor(
|
|
61906
|
+
function h2MultiplexInterceptor(dispatch2) {
|
|
61889
61907
|
return (opts, handler) => {
|
|
61890
61908
|
const body = opts.body;
|
|
61891
61909
|
const isAsyncIterable = !!body && typeof body !== "string" && !Buffer.isBuffer(body) && typeof body[Symbol.asyncIterator] === "function";
|
|
61892
61910
|
const length = contentLength(opts.headers);
|
|
61893
61911
|
if (!isAsyncIterable || !(length >= 0) || length > H2_REBUFFER_MAX_BYTES) {
|
|
61894
|
-
return
|
|
61912
|
+
return dispatch2({ ...opts, idempotent: true }, handler);
|
|
61895
61913
|
}
|
|
61896
61914
|
void (async () => {
|
|
61897
61915
|
try {
|
|
@@ -61899,7 +61917,7 @@ function h2MultiplexInterceptor(dispatch) {
|
|
|
61899
61917
|
for await (const chunk of body) {
|
|
61900
61918
|
chunks.push(Buffer.from(chunk));
|
|
61901
61919
|
}
|
|
61902
|
-
|
|
61920
|
+
dispatch2({ ...opts, body: Buffer.concat(chunks), idempotent: true }, handler);
|
|
61903
61921
|
} catch (error121) {
|
|
61904
61922
|
handler.onError?.(error121);
|
|
61905
61923
|
}
|
|
@@ -62133,7 +62151,15 @@ var init_http_client = __esm({
|
|
|
62133
62151
|
// Covers H2 stream timeout, frameError and GOAWAY (undici InformationalError).
|
|
62134
62152
|
"UND_ERR_INFO",
|
|
62135
62153
|
"UND_ERR_HEADERS_TIMEOUT",
|
|
62136
|
-
"UND_ERR_BODY_TIMEOUT"
|
|
62154
|
+
"UND_ERR_BODY_TIMEOUT",
|
|
62155
|
+
// Node can surface these directly instead of undici's UND_ERR_INFO. Once
|
|
62156
|
+
// repeated, retire the pool even when classification used its fallback.
|
|
62157
|
+
// Keep this scoped to session/stream failures: ERR_HTTP2_* also contains
|
|
62158
|
+
// request-validation and caller-cancellation errors a new pool cannot fix.
|
|
62159
|
+
"ERR_HTTP2_GOAWAY_SESSION",
|
|
62160
|
+
"ERR_HTTP2_INVALID_SESSION",
|
|
62161
|
+
"ERR_HTTP2_SESSION_ERROR",
|
|
62162
|
+
"ERR_HTTP2_STREAM_ERROR"
|
|
62137
62163
|
]);
|
|
62138
62164
|
MAX_CAUSE_DEPTH = 8;
|
|
62139
62165
|
__name(isRecyclableTransportError, "isRecyclableTransportError");
|
|
@@ -62327,6 +62353,38 @@ function getTransientTransportCode(error121) {
|
|
|
62327
62353
|
}
|
|
62328
62354
|
return void 0;
|
|
62329
62355
|
}
|
|
62356
|
+
function validateHttpUrl(url3) {
|
|
62357
|
+
const { protocol, username, password } = new URL(url3);
|
|
62358
|
+
if (protocol !== "http:" && protocol !== "https:") {
|
|
62359
|
+
throw new TypeError(`Unsupported URL protocol ${protocol}; expected http: or https:`);
|
|
62360
|
+
}
|
|
62361
|
+
if (username || password) {
|
|
62362
|
+
throw new TypeError("HTTP(S) URLs with embedded credentials are unsupported");
|
|
62363
|
+
}
|
|
62364
|
+
}
|
|
62365
|
+
function describeTransportFailure(error121) {
|
|
62366
|
+
const known = getTransientTransportCode(error121);
|
|
62367
|
+
if (known)
|
|
62368
|
+
return known;
|
|
62369
|
+
let firstCode;
|
|
62370
|
+
let innermostName;
|
|
62371
|
+
let current = error121;
|
|
62372
|
+
for (let depth = 0; current && depth < 8; depth++) {
|
|
62373
|
+
const { code: code3, name, message } = current;
|
|
62374
|
+
if (name === "Error" && message === "bad port" && code3 === void 0) {
|
|
62375
|
+
return void 0;
|
|
62376
|
+
}
|
|
62377
|
+
if (typeof code3 === "string" && code3) {
|
|
62378
|
+
if (REQUEST_CONSTRUCTION_ERROR_CODES.has(code3))
|
|
62379
|
+
return void 0;
|
|
62380
|
+
firstCode ??= code3;
|
|
62381
|
+
}
|
|
62382
|
+
if (typeof name === "string" && name)
|
|
62383
|
+
innermostName = name;
|
|
62384
|
+
current = current.cause;
|
|
62385
|
+
}
|
|
62386
|
+
return firstCode ?? innermostName ?? "unknown";
|
|
62387
|
+
}
|
|
62330
62388
|
function getVercelDiagnostics(headers) {
|
|
62331
62389
|
return DIAGNOSTIC_HEADERS.flatMap((header) => {
|
|
62332
62390
|
const value = headers.get(header);
|
|
@@ -62451,6 +62509,7 @@ function recordClientSpanStatus(span, status) {
|
|
|
62451
62509
|
async function instrumentedFetch(opts) {
|
|
62452
62510
|
const { method, url: url3, headers, body, dispatcher, peerService, timeoutMs = getRequestTimeoutMs(), signal: callerSignal, injectTraceContext: injectTraceContext2 = true, cacheBust = true, logLabel, buildError, spanName, attributes, durationAttribute, onTransportOutcome, deferTransportSuccessUntilBody = false, onRequestDispatched, transportErrorCode = "TRANSPORT" } = opts;
|
|
62453
62511
|
const label = logLabel ?? url3;
|
|
62512
|
+
validateHttpUrl(url3);
|
|
62454
62513
|
return withHttpClientSpan({ method, url: url3, peerService, spanName, attributes }, async (span) => {
|
|
62455
62514
|
if (injectTraceContext2)
|
|
62456
62515
|
await injectTraceContextIntoHeaders(headers);
|
|
@@ -62458,13 +62517,13 @@ async function instrumentedFetch(opts) {
|
|
|
62458
62517
|
headers.set("X-Request-Time", Date.now().toString());
|
|
62459
62518
|
const timeoutSignal = timeoutMs != null ? AbortSignal.timeout(timeoutMs) : void 0;
|
|
62460
62519
|
const signal = callerSignal && timeoutSignal ? AbortSignal.any([callerSignal, timeoutSignal]) : callerSignal ?? timeoutSignal;
|
|
62520
|
+
const nodeAgents = dispatcher ? void 0 : getNodeHttpAgents();
|
|
62521
|
+
span?.setAttributes({
|
|
62522
|
+
...WorkflowHttpTransport(nodeAgents ? "node-http" : "undici")
|
|
62523
|
+
});
|
|
62461
62524
|
const start3 = Date.now();
|
|
62462
62525
|
let response;
|
|
62463
62526
|
try {
|
|
62464
|
-
const nodeAgents = dispatcher ? void 0 : getNodeHttpAgents();
|
|
62465
|
-
span?.setAttributes({
|
|
62466
|
-
...WorkflowHttpTransport(nodeAgents ? "node-http" : "undici")
|
|
62467
|
-
});
|
|
62468
62527
|
const request = nodeAgents ? nodeHttpFetch(url3, {
|
|
62469
62528
|
method,
|
|
62470
62529
|
headers,
|
|
@@ -62502,7 +62561,7 @@ async function instrumentedFetch(opts) {
|
|
|
62502
62561
|
span?.recordException?.(timeoutError);
|
|
62503
62562
|
throw timeoutError;
|
|
62504
62563
|
}
|
|
62505
|
-
const transportCode =
|
|
62564
|
+
const transportCode = describeTransportFailure(error121);
|
|
62506
62565
|
if (transportCode) {
|
|
62507
62566
|
const message = `${method} ${label} transport failure after ${elapsed}ms (${transportCode})`;
|
|
62508
62567
|
const errorCode = transportErrorCode === "STREAM_ERROR" ? "STREAM_ERROR" : "TRANSPORT";
|
|
@@ -62569,7 +62628,7 @@ async function instrumentedFetch(opts) {
|
|
|
62569
62628
|
return response;
|
|
62570
62629
|
});
|
|
62571
62630
|
}
|
|
62572
|
-
var import_oidc, REQUEST_TIMEOUT_MS, TRANSIENT_TRANSPORT_ERROR_CODES, getRequestTimeoutMs, HTTP_DEBUG_ENABLED, DIAGNOSTIC_HEADERS;
|
|
62631
|
+
var import_oidc, REQUEST_TIMEOUT_MS, TRANSIENT_TRANSPORT_ERROR_CODES, REQUEST_CONSTRUCTION_ERROR_CODES, getRequestTimeoutMs, HTTP_DEBUG_ENABLED, DIAGNOSTIC_HEADERS;
|
|
62573
62632
|
var init_http_core = __esm({
|
|
62574
62633
|
"../world-vercel/dist/http-core.js"() {
|
|
62575
62634
|
"use strict";
|
|
@@ -62597,6 +62656,21 @@ var init_http_core = __esm({
|
|
|
62597
62656
|
"ETIMEDOUT"
|
|
62598
62657
|
]);
|
|
62599
62658
|
__name(getTransientTransportCode, "getTransientTransportCode");
|
|
62659
|
+
__name(validateHttpUrl, "validateHttpUrl");
|
|
62660
|
+
REQUEST_CONSTRUCTION_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
62661
|
+
"ERR_INVALID_URL",
|
|
62662
|
+
"ERR_INVALID_ARG_TYPE",
|
|
62663
|
+
"ERR_INVALID_ARG_VALUE",
|
|
62664
|
+
"ERR_INVALID_CHAR",
|
|
62665
|
+
"ERR_INVALID_HTTP_TOKEN",
|
|
62666
|
+
"ERR_HTTP_INVALID_HEADER_VALUE",
|
|
62667
|
+
"ERR_UNESCAPED_CHARACTERS",
|
|
62668
|
+
// Undici validates request options and headers during dispatch, after
|
|
62669
|
+
// Fetch has constructed the Request (e.g. unsupported Expect headers).
|
|
62670
|
+
"UND_ERR_INVALID_ARG",
|
|
62671
|
+
"UND_ERR_NOT_SUPPORTED"
|
|
62672
|
+
]);
|
|
62673
|
+
__name(describeTransportFailure, "describeTransportFailure");
|
|
62600
62674
|
getRequestTimeoutMs = /* @__PURE__ */ __name(() => envNumber2("WORKFLOW_REQUEST_TIMEOUT_MS", REQUEST_TIMEOUT_MS, {
|
|
62601
62675
|
integer: true,
|
|
62602
62676
|
min: 1e4,
|
|
@@ -62659,6 +62733,7 @@ async function makeRequest({ endpoint, options = {}, config: config4 = {}, schem
|
|
|
62659
62733
|
const method = (options.method || "GET").toUpperCase();
|
|
62660
62734
|
const { baseUrl, headers } = await getHttpConfig(config4);
|
|
62661
62735
|
const url3 = `${baseUrl}${endpoint}`;
|
|
62736
|
+
validateHttpUrl(url3);
|
|
62662
62737
|
return trace4(`http ${method}`, { kind: await getSpanKind3("CLIENT") }, async (span) => {
|
|
62663
62738
|
span?.setAttributes(httpClientSpanAttributes({
|
|
62664
62739
|
method,
|
|
@@ -62679,13 +62754,15 @@ async function makeRequest({ endpoint, options = {}, config: config4 = {}, schem
|
|
|
62679
62754
|
headers.set("X-Request-Time", Date.now().toString());
|
|
62680
62755
|
const timeoutSignal = AbortSignal.timeout(getRequestTimeoutMs());
|
|
62681
62756
|
const signal = options.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal;
|
|
62757
|
+
const nodeAgents = getNodeHttpAgents(config4);
|
|
62758
|
+
const undiciRequest = nodeAgents ? void 0 : new Request(url3, { ...options, body, headers, signal });
|
|
62759
|
+
const undiciDispatcher = nodeAgents ? void 0 : getDispatcher(config4);
|
|
62760
|
+
span?.setAttributes({
|
|
62761
|
+
...WorkflowHttpTransport(nodeAgents ? "node-http" : "undici")
|
|
62762
|
+
});
|
|
62682
62763
|
const fetchStart = Date.now();
|
|
62683
62764
|
let response;
|
|
62684
62765
|
try {
|
|
62685
|
-
const nodeAgents = getNodeHttpAgents(config4);
|
|
62686
|
-
span?.setAttributes({
|
|
62687
|
-
...WorkflowHttpTransport(nodeAgents ? "node-http" : "undici")
|
|
62688
|
-
});
|
|
62689
62766
|
response = nodeAgents ? await nodeHttpFetch(url3, {
|
|
62690
62767
|
method,
|
|
62691
62768
|
headers,
|
|
@@ -62697,9 +62774,9 @@ async function makeRequest({ endpoint, options = {}, config: config4 = {}, schem
|
|
|
62697
62774
|
// no stalled-socket deadline.
|
|
62698
62775
|
headersTimeoutMs: NODE_HTTP_HEADERS_TIMEOUT_MS,
|
|
62699
62776
|
bodyTimeoutMs: NODE_HTTP_BODY_TIMEOUT_MS
|
|
62700
|
-
}) : await fetch(
|
|
62777
|
+
}) : await fetch(undiciRequest, {
|
|
62701
62778
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- undici v7 dispatcher types don't match @types/node's RequestInit
|
|
62702
|
-
dispatcher:
|
|
62779
|
+
dispatcher: undiciDispatcher
|
|
62703
62780
|
});
|
|
62704
62781
|
} catch (error121) {
|
|
62705
62782
|
const elapsed = Date.now() - fetchStart;
|
|
@@ -62709,7 +62786,7 @@ async function makeRequest({ endpoint, options = {}, config: config4 = {}, schem
|
|
|
62709
62786
|
span?.recordException?.(timeoutError);
|
|
62710
62787
|
throw timeoutError;
|
|
62711
62788
|
}
|
|
62712
|
-
const transportCode =
|
|
62789
|
+
const transportCode = describeTransportFailure(error121);
|
|
62713
62790
|
if (transportCode) {
|
|
62714
62791
|
if (retryConnectTimeout && canRetryRead && transportCode === "UND_ERR_CONNECT_TIMEOUT" && attempt === 0) {
|
|
62715
62792
|
await new Promise((resolve3) => setTimeout(resolve3, BODY_PARSE_RETRY_BASE_MS));
|
|
@@ -68570,13 +68647,13 @@ var require_functions2 = __commonJS({
|
|
|
68570
68647
|
ipAddress: /* @__PURE__ */ __name(() => import_headers.ipAddress, "ipAddress"),
|
|
68571
68648
|
next: /* @__PURE__ */ __name(() => import_middleware.next, "next"),
|
|
68572
68649
|
rewrite: /* @__PURE__ */ __name(() => import_middleware.rewrite, "rewrite"),
|
|
68573
|
-
waitUntil: /* @__PURE__ */ __name(() =>
|
|
68650
|
+
waitUntil: /* @__PURE__ */ __name(() => import_wait_until5.waitUntil, "waitUntil")
|
|
68574
68651
|
});
|
|
68575
68652
|
module.exports = __toCommonJS(src_exports);
|
|
68576
68653
|
var import_headers = require_headers3();
|
|
68577
68654
|
var import_get_env = require_get_env2();
|
|
68578
68655
|
var import_deadline = require_deadline2();
|
|
68579
|
-
var
|
|
68656
|
+
var import_wait_until5 = require_wait_until2();
|
|
68580
68657
|
var import_middleware = require_middleware2();
|
|
68581
68658
|
var import_cache = require_cache5();
|
|
68582
68659
|
var import_db_connections = require_db_connections2();
|
|
@@ -74708,7 +74785,7 @@ function createQueue2(config4) {
|
|
|
74708
74785
|
attempt: metadata.deliveryCount,
|
|
74709
74786
|
requestId
|
|
74710
74787
|
});
|
|
74711
|
-
if (typeof result2
|
|
74788
|
+
if (!("invoke" in payload && payload.invoke === true) && typeof result2 === "object" && result2 !== null && "timeoutSeconds" in result2 && typeof result2.timeoutSeconds === "number") {
|
|
74712
74789
|
const delaySeconds = result2.timeoutSeconds > 0 ? Math.min(result2.timeoutSeconds, MAX_DELAY_SECONDS) : void 0;
|
|
74713
74790
|
await queue(queueName, payload, { deploymentId, delaySeconds });
|
|
74714
74791
|
}
|
|
@@ -74989,7 +75066,7 @@ function isRetryableEventPostError(err) {
|
|
|
74989
75066
|
if (EntityConflictError2.is(err) || RunExpiredError2.is(err) || TooEarlyError.is(err) || ThrottleError2.is(err)) {
|
|
74990
75067
|
return false;
|
|
74991
75068
|
}
|
|
74992
|
-
if (WorkflowWorldError2.is(err)) {
|
|
75069
|
+
if (WorkflowWorldError2.is(err) || StreamError2.is(err)) {
|
|
74993
75070
|
if (err.code === "PARSE_ERROR")
|
|
74994
75071
|
return true;
|
|
74995
75072
|
if (err.code === "TRANSPORT")
|
|
@@ -74997,6 +75074,14 @@ function isRetryableEventPostError(err) {
|
|
|
74997
75074
|
if (typeof err.status === "number") {
|
|
74998
75075
|
return err.status >= 500 && err.status <= 599;
|
|
74999
75076
|
}
|
|
75077
|
+
if (err.code === "STREAM_ERROR") {
|
|
75078
|
+
return !collectErrorMarkers(err).some((marker) => [
|
|
75079
|
+
"AbortError",
|
|
75080
|
+
"ABORT_ERR",
|
|
75081
|
+
"UND_ERR_ABORTED",
|
|
75082
|
+
"ERR_HTTP2_STREAM_CANCEL"
|
|
75083
|
+
].includes(marker));
|
|
75084
|
+
}
|
|
75000
75085
|
}
|
|
75001
75086
|
return collectErrorMarkers(err).some((m) => TRANSIENT_CODES.has(m));
|
|
75002
75087
|
}
|
|
@@ -75427,7 +75512,7 @@ async function fetchV4(url3, init, config4, opName, attributes) {
|
|
|
75427
75512
|
}
|
|
75428
75513
|
} catch (cause) {
|
|
75429
75514
|
noteEventsTransportOutcome(dispatcher, cause);
|
|
75430
|
-
const transportCode =
|
|
75515
|
+
const transportCode = describeTransportFailure(cause);
|
|
75431
75516
|
controller.error(transportCode ? new StreamError2(`v4 ${opName}: response stream transport failure (${transportCode})`, { cause, url: url3 }) : cause);
|
|
75432
75517
|
}
|
|
75433
75518
|
},
|
|
@@ -76499,6 +76584,15 @@ function validateWorkflowRunIdTimestamp(id) {
|
|
|
76499
76584
|
function assertEventDataWireContractExhaustive() {
|
|
76500
76585
|
}
|
|
76501
76586
|
function splitEventDataForV4(data) {
|
|
76587
|
+
if (data.eventType === "attr_set") {
|
|
76588
|
+
try {
|
|
76589
|
+
validateAttributeEventDataSize2(data.eventData);
|
|
76590
|
+
} catch (error121) {
|
|
76591
|
+
if (!(error121 instanceof AttributeValidationError2))
|
|
76592
|
+
throw error121;
|
|
76593
|
+
throw new WorkflowWorldError2(error121.message, { status: 400 });
|
|
76594
|
+
}
|
|
76595
|
+
}
|
|
76502
76596
|
const eventData = data.eventData ?? {};
|
|
76503
76597
|
const payloadField = getEventDataPayloadField(data.eventType);
|
|
76504
76598
|
const meta5 = {};
|
|
@@ -76838,6 +76932,7 @@ var init_events3 = __esm({
|
|
|
76838
76932
|
"use strict";
|
|
76839
76933
|
init_dist7();
|
|
76840
76934
|
init_dist6();
|
|
76935
|
+
init_attributes_validation2();
|
|
76841
76936
|
init_event_retry();
|
|
76842
76937
|
init_events_v4();
|
|
76843
76938
|
init_run_id();
|
|
@@ -78992,6 +79087,7 @@ function renderStructuredFields2(framing, body, metadata) {
|
|
|
78992
79087
|
"errorName",
|
|
78993
79088
|
"errorMessage",
|
|
78994
79089
|
"errorStack",
|
|
79090
|
+
"errorCause",
|
|
78995
79091
|
"hint",
|
|
78996
79092
|
"attempt",
|
|
78997
79093
|
"retryCount"
|
|
@@ -79034,6 +79130,10 @@ function renderStructuredFields2(framing, body, metadata) {
|
|
|
79034
79130
|
if (errorMessage && !redundant.has("errorMessage")) {
|
|
79035
79131
|
lines.push(` ${kvKey2("error")} ${formatPassthroughValue2(errorMessage)}`);
|
|
79036
79132
|
}
|
|
79133
|
+
const errorCause = pickString2(metadata, "errorCause");
|
|
79134
|
+
if (errorCause && !body.includes(errorCause)) {
|
|
79135
|
+
lines.push(` ${kvKey2("cause")} ${formatPassthroughValue2(errorCause)}`);
|
|
79136
|
+
}
|
|
79037
79137
|
const hint3 = pickString2(metadata, "hint");
|
|
79038
79138
|
if (hint3) {
|
|
79039
79139
|
lines.push(` ${hint2(hint3)}`);
|
|
@@ -79792,12 +79892,25 @@ async function awaitEarlierDeliveries(ctx, eventIndex, kind) {
|
|
|
79792
79892
|
await new Promise((resolve3) => setTimeout(resolve3, 0));
|
|
79793
79893
|
}
|
|
79794
79894
|
}
|
|
79795
|
-
function registerDeliveryBarrier(ctx, eventIndex, kind, options
|
|
79895
|
+
function registerDeliveryBarrier(ctx, eventIndex, kind, options) {
|
|
79896
|
+
let deliveredToWorkflow = false;
|
|
79897
|
+
const deliver = /* @__PURE__ */ __name(() => {
|
|
79898
|
+
if (deliveredToWorkflow) {
|
|
79899
|
+
return false;
|
|
79900
|
+
}
|
|
79901
|
+
deliveredToWorkflow = true;
|
|
79902
|
+
ctx.advanceClock?.(options.deliveredAt);
|
|
79903
|
+
return true;
|
|
79904
|
+
}, "deliver");
|
|
79796
79905
|
const barriers = ctx.pendingDeliveryBarriers;
|
|
79797
79906
|
if (!barriers || eventIndex === void 0) {
|
|
79798
|
-
return {
|
|
79799
|
-
|
|
79800
|
-
|
|
79907
|
+
return {
|
|
79908
|
+
markDelivered: /* @__PURE__ */ __name(() => {
|
|
79909
|
+
deliver();
|
|
79910
|
+
}, "markDelivered"),
|
|
79911
|
+
arm: /* @__PURE__ */ __name(() => {
|
|
79912
|
+
}, "arm")
|
|
79913
|
+
};
|
|
79801
79914
|
}
|
|
79802
79915
|
const install = /* @__PURE__ */ __name((armed) => {
|
|
79803
79916
|
if (barriers.has(eventIndex)) {
|
|
@@ -79825,13 +79938,11 @@ function registerDeliveryBarrier(ctx, eventIndex, kind, options = {}) {
|
|
|
79825
79938
|
return entry2;
|
|
79826
79939
|
}, "install");
|
|
79827
79940
|
let entry = install(options.armed ?? true);
|
|
79828
|
-
let deliveredToWorkflow = false;
|
|
79829
79941
|
return {
|
|
79830
79942
|
markDelivered: /* @__PURE__ */ __name(() => {
|
|
79831
|
-
if (
|
|
79943
|
+
if (!deliver()) {
|
|
79832
79944
|
return;
|
|
79833
79945
|
}
|
|
79834
|
-
deliveredToWorkflow = true;
|
|
79835
79946
|
entry.retire();
|
|
79836
79947
|
}, "markDelivered"),
|
|
79837
79948
|
arm: /* @__PURE__ */ __name(() => {
|
|
@@ -83740,7 +83851,9 @@ function createCreateAbortController(ctx) {
|
|
|
83740
83851
|
if (event.eventType === "hook_received") {
|
|
83741
83852
|
const rawPayload = event.eventData?.payload;
|
|
83742
83853
|
const eventIndex = ctx.eventsConsumer.eventIndex;
|
|
83743
|
-
const barrier = registerDeliveryBarrier(ctx, eventIndex, "hook"
|
|
83854
|
+
const barrier = registerDeliveryBarrier(ctx, eventIndex, "hook", {
|
|
83855
|
+
deliveredAt: +event.createdAt
|
|
83856
|
+
});
|
|
83744
83857
|
const earlierDelivered = awaitEarlierDeliveries(ctx, eventIndex, "hook");
|
|
83745
83858
|
ctx.pendingDeliveries++;
|
|
83746
83859
|
ctx.promiseQueue = ctx.promiseQueue.then(async () => {
|
|
@@ -85928,7 +86041,7 @@ var version5;
|
|
|
85928
86041
|
var init_version4 = __esm({
|
|
85929
86042
|
"../core/dist/version.js"() {
|
|
85930
86043
|
"use strict";
|
|
85931
|
-
version5 = "5.0.0-beta.
|
|
86044
|
+
version5 = "5.0.0-beta.54";
|
|
85932
86045
|
}
|
|
85933
86046
|
});
|
|
85934
86047
|
|
|
@@ -86399,6 +86512,176 @@ var init_helpers3 = __esm({
|
|
|
86399
86512
|
}
|
|
86400
86513
|
});
|
|
86401
86514
|
|
|
86515
|
+
// ../core/dist/runtime/invocations.js
|
|
86516
|
+
async function handleInvocation(world, runId, requestId, payload) {
|
|
86517
|
+
const parsed = HookInvocationSchema2.safeParse(payload);
|
|
86518
|
+
if (!parsed.success || !requestId)
|
|
86519
|
+
throw new WorkflowWorldError2("Invalid invocation input", {
|
|
86520
|
+
status: 400,
|
|
86521
|
+
code: "INVALID_INPUT"
|
|
86522
|
+
});
|
|
86523
|
+
const input3 = parsed.data;
|
|
86524
|
+
const digest = Buffer.from(await crypto.subtle.digest("SHA-256", input3.payload)).toString("hex");
|
|
86525
|
+
try {
|
|
86526
|
+
const hook = await world.hooks.get(input3.hookId);
|
|
86527
|
+
if (hook.runId !== runId || hook.token !== input3.token)
|
|
86528
|
+
throw new HookNotFoundError2(input3.token);
|
|
86529
|
+
const run3 = await world.runs.get(runId, { resolveData: "none" });
|
|
86530
|
+
if (isTerminalWorkflowRunStatus2(run3.status))
|
|
86531
|
+
throw new HookNotFoundError2(input3.token);
|
|
86532
|
+
} catch (error121) {
|
|
86533
|
+
if (!isHookGone(error121))
|
|
86534
|
+
throw error121;
|
|
86535
|
+
const run3 = await world.runs.get(runId, { resolveData: "none" });
|
|
86536
|
+
if (run3.expiredAt || isTerminalWorkflowRunStatus2(run3.status) && readRunRetention(run3.attributes).mode === "none") {
|
|
86537
|
+
throw new WorkflowWorldError2("Invocation data has expired under the run retention policy", { status: 410, code: "INVOCATION_DATA_EXPIRED" });
|
|
86538
|
+
}
|
|
86539
|
+
if (!world.capabilities?.hookResumeDedup || !await hasResume(world, runId, input3.hookId, requestId)) {
|
|
86540
|
+
throw error121;
|
|
86541
|
+
}
|
|
86542
|
+
}
|
|
86543
|
+
await world.events.create(runId, {
|
|
86544
|
+
eventType: "hook_received",
|
|
86545
|
+
correlationId: input3.hookId,
|
|
86546
|
+
specVersion: SPEC_VERSION_CURRENT2,
|
|
86547
|
+
eventData: { token: input3.token, payload: input3.payload }
|
|
86548
|
+
}, {
|
|
86549
|
+
...world.capabilities?.hookResumeDedup ? { resumeId: requestId, resumePayloadDigest: digest } : {}
|
|
86550
|
+
});
|
|
86551
|
+
return { status: "accepted" };
|
|
86552
|
+
}
|
|
86553
|
+
function isHookGone(error121) {
|
|
86554
|
+
return HookNotFoundError2.is(error121) || RunExpiredError2.is(error121) || WorkflowRunNotFoundError2.is(error121);
|
|
86555
|
+
}
|
|
86556
|
+
async function hasResume(world, runId, hookId, requestId) {
|
|
86557
|
+
let cursor = null;
|
|
86558
|
+
do {
|
|
86559
|
+
const page = await world.events.listByCorrelationId({
|
|
86560
|
+
runId,
|
|
86561
|
+
correlationId: hookId,
|
|
86562
|
+
resolveData: "none",
|
|
86563
|
+
pagination: { limit: 100, ...cursor ? { cursor } : {} }
|
|
86564
|
+
});
|
|
86565
|
+
if (page.data.some((event) => event.eventType === "hook_received" && event.resumeId === requestId))
|
|
86566
|
+
return true;
|
|
86567
|
+
cursor = page.hasMore ? page.cursor : null;
|
|
86568
|
+
} while (cursor);
|
|
86569
|
+
return false;
|
|
86570
|
+
}
|
|
86571
|
+
function withRunInputs(world) {
|
|
86572
|
+
return (handler) => {
|
|
86573
|
+
const sessions = /* @__PURE__ */ new Map();
|
|
86574
|
+
return async (message, metadata) => {
|
|
86575
|
+
if (HealthCheckPayloadSchema2.safeParse(message).success)
|
|
86576
|
+
return handler(message, metadata);
|
|
86577
|
+
const parsed = WorkflowInvokePayloadSchema2.safeParse(message);
|
|
86578
|
+
if (!world.capabilities?.invoke || !parsed.success || parsed.data.stepId)
|
|
86579
|
+
return handler(message, metadata);
|
|
86580
|
+
const input3 = parsed.data;
|
|
86581
|
+
let session = sessions.get(input3.runId);
|
|
86582
|
+
if (!session) {
|
|
86583
|
+
session = {
|
|
86584
|
+
activity: new RunInputActivity(),
|
|
86585
|
+
admission: Promise.resolve(),
|
|
86586
|
+
references: 0
|
|
86587
|
+
};
|
|
86588
|
+
sessions.set(input3.runId, session);
|
|
86589
|
+
}
|
|
86590
|
+
const current = session;
|
|
86591
|
+
current.references++;
|
|
86592
|
+
try {
|
|
86593
|
+
if (input3.invoke) {
|
|
86594
|
+
if (!input3.requestId)
|
|
86595
|
+
throw new WorkflowRuntimeError2("Invocation requestId is required");
|
|
86596
|
+
const requestId = input3.requestId;
|
|
86597
|
+
const decision = current.admission.then(() => trace5("workflow.invoke.receive", async (span) => {
|
|
86598
|
+
span?.setAttributes({
|
|
86599
|
+
...WorkflowRunId4(input3.runId),
|
|
86600
|
+
"workflow.invocation.id": requestId
|
|
86601
|
+
});
|
|
86602
|
+
const result2 = await handleInvocation(world, input3.runId, requestId, input3.input);
|
|
86603
|
+
if (result2.status === "accepted")
|
|
86604
|
+
current.activity.notify();
|
|
86605
|
+
return result2;
|
|
86606
|
+
}));
|
|
86607
|
+
current.admission = decision.catch(() => {
|
|
86608
|
+
});
|
|
86609
|
+
return await decision;
|
|
86610
|
+
}
|
|
86611
|
+
if (current.execution)
|
|
86612
|
+
return await current.execution;
|
|
86613
|
+
const execution = handler(message, metadata, current.activity);
|
|
86614
|
+
current.execution = execution;
|
|
86615
|
+
try {
|
|
86616
|
+
return await execution;
|
|
86617
|
+
} finally {
|
|
86618
|
+
if (current.execution === execution)
|
|
86619
|
+
current.execution = void 0;
|
|
86620
|
+
}
|
|
86621
|
+
} finally {
|
|
86622
|
+
current.references--;
|
|
86623
|
+
if (current.references === 0 && sessions.get(input3.runId) === current)
|
|
86624
|
+
sessions.delete(input3.runId);
|
|
86625
|
+
}
|
|
86626
|
+
};
|
|
86627
|
+
};
|
|
86628
|
+
}
|
|
86629
|
+
var HookInvocationSchema2, HookInvocationResultSchema2, RunInputActivity;
|
|
86630
|
+
var init_invocations2 = __esm({
|
|
86631
|
+
"../core/dist/runtime/invocations.js"() {
|
|
86632
|
+
"use strict";
|
|
86633
|
+
init_dist7();
|
|
86634
|
+
init_dist6();
|
|
86635
|
+
init_zod2();
|
|
86636
|
+
init_semantic_conventions2();
|
|
86637
|
+
init_telemetry4();
|
|
86638
|
+
HookInvocationSchema2 = external_exports2.object({
|
|
86639
|
+
type: external_exports2.literal("hook_resume"),
|
|
86640
|
+
version: external_exports2.literal(1),
|
|
86641
|
+
hookId: external_exports2.string(),
|
|
86642
|
+
token: external_exports2.string(),
|
|
86643
|
+
payload: external_exports2.instanceof(Uint8Array)
|
|
86644
|
+
});
|
|
86645
|
+
HookInvocationResultSchema2 = external_exports2.discriminatedUnion("status", [
|
|
86646
|
+
external_exports2.object({ status: external_exports2.literal("accepted") }),
|
|
86647
|
+
external_exports2.object({
|
|
86648
|
+
status: external_exports2.literal("rejected"),
|
|
86649
|
+
code: external_exports2.enum(["HOOK_NOT_FOUND", "INVALID_INPUT"])
|
|
86650
|
+
})
|
|
86651
|
+
]);
|
|
86652
|
+
__name(handleInvocation, "handleInvocation");
|
|
86653
|
+
__name(isHookGone, "isHookGone");
|
|
86654
|
+
__name(hasResume, "hasResume");
|
|
86655
|
+
RunInputActivity = class {
|
|
86656
|
+
static {
|
|
86657
|
+
__name(this, "RunInputActivity");
|
|
86658
|
+
}
|
|
86659
|
+
revision = 0;
|
|
86660
|
+
listeners = /* @__PURE__ */ new Set();
|
|
86661
|
+
notify() {
|
|
86662
|
+
this.revision++;
|
|
86663
|
+
for (const notify of this.listeners)
|
|
86664
|
+
notify();
|
|
86665
|
+
}
|
|
86666
|
+
async waitForActivity(since, timeoutMs = 100) {
|
|
86667
|
+
if (this.revision !== since)
|
|
86668
|
+
return true;
|
|
86669
|
+
await new Promise((resolve3) => {
|
|
86670
|
+
const finish = /* @__PURE__ */ __name(() => {
|
|
86671
|
+
clearTimeout(timer);
|
|
86672
|
+
this.listeners.delete(finish);
|
|
86673
|
+
resolve3();
|
|
86674
|
+
}, "finish");
|
|
86675
|
+
const timer = setTimeout(finish, timeoutMs);
|
|
86676
|
+
this.listeners.add(finish);
|
|
86677
|
+
});
|
|
86678
|
+
return this.revision !== since;
|
|
86679
|
+
}
|
|
86680
|
+
};
|
|
86681
|
+
__name(withRunInputs, "withRunInputs");
|
|
86682
|
+
}
|
|
86683
|
+
});
|
|
86684
|
+
|
|
86402
86685
|
// ../core/dist/runtime/wait-until.js
|
|
86403
86686
|
function waitUntil3(promise3) {
|
|
86404
86687
|
void Promise.resolve().then(() => __toESM(require_functions2(), 1)).then(({ waitUntil: waitUntil4 }) => {
|
|
@@ -86615,6 +86898,26 @@ async function resumeHookImpl2(tokenOrHook, payload, encryptionKeyOverride, hook
|
|
|
86615
86898
|
if (originLink) {
|
|
86616
86899
|
span?.addLink?.(originLink);
|
|
86617
86900
|
}
|
|
86901
|
+
if (world.capabilities?.invoke === true && !v1Compat && dehydratedPayload instanceof Uint8Array) {
|
|
86902
|
+
if (!world.invoke) {
|
|
86903
|
+
throw new WorkflowRuntimeError2("World advertises invoke without implementing it");
|
|
86904
|
+
}
|
|
86905
|
+
span?.setAttributes({ "workflow.hook.resume_strategy": "invoke" });
|
|
86906
|
+
const result2 = HookInvocationResultSchema2.parse(await world.invoke(hook.runId, {
|
|
86907
|
+
type: "hook_resume",
|
|
86908
|
+
version: 1,
|
|
86909
|
+
hookId: hook.hookId,
|
|
86910
|
+
token: hook.token,
|
|
86911
|
+
payload: dehydratedPayload
|
|
86912
|
+
}, { idempotencyKey: generateResumeId2() }));
|
|
86913
|
+
if (result2.status === "rejected") {
|
|
86914
|
+
if (result2.code === "HOOK_NOT_FOUND")
|
|
86915
|
+
throw new HookNotFoundError2(hook.token);
|
|
86916
|
+
throw new WorkflowRuntimeError2("Executor rejected the hook invocation input");
|
|
86917
|
+
}
|
|
86918
|
+
span?.setAttributes(HookResumeCommitted2(true));
|
|
86919
|
+
return asLazyMetadataHook2(hook);
|
|
86920
|
+
}
|
|
86618
86921
|
const queueName = getWorkflowQueueName2(resumeContext.workflowName);
|
|
86619
86922
|
const queueOptions = {
|
|
86620
86923
|
deploymentId: resumeContext.deploymentId,
|
|
@@ -86739,6 +87042,7 @@ var init_resume_hook2 = __esm({
|
|
|
86739
87042
|
init_telemetry4();
|
|
86740
87043
|
init_get_world_lazy2();
|
|
86741
87044
|
init_helpers3();
|
|
87045
|
+
init_invocations2();
|
|
86742
87046
|
init_wait_until2();
|
|
86743
87047
|
generateResumeId2 = monotonicFactory2();
|
|
86744
87048
|
__name(computeResumePayloadDigest2, "computeResumePayloadDigest");
|
|
@@ -87784,6 +88088,13 @@ async function getForwardedWritableEncryptionKey2(runId, deploymentId, encryptio
|
|
|
87784
88088
|
const rawKey = deploymentId ? await world.getEncryptionKeyForRun(runId, { deploymentId }) : await world.getEncryptionKeyForRun(await world.runs.get(runId));
|
|
87785
88089
|
return rawKey ? await importKey2(rawKey, ["encrypt"]) : void 0;
|
|
87786
88090
|
}
|
|
88091
|
+
function lazyForwardedWritableEncryptionKey2(runId, deploymentId, encryptionPublicKey) {
|
|
88092
|
+
let keyPromise;
|
|
88093
|
+
return () => {
|
|
88094
|
+
keyPromise ??= getForwardedWritableEncryptionKey2(runId, deploymentId, encryptionPublicKey);
|
|
88095
|
+
return keyPromise;
|
|
88096
|
+
};
|
|
88097
|
+
}
|
|
87787
88098
|
function tagForwardedWritableTarget2(writable, { deploymentId, encryptionPublicKey }) {
|
|
87788
88099
|
if (typeof deploymentId === "string") {
|
|
87789
88100
|
Object.defineProperty(writable, STREAM_SERVER_DEPLOYMENT_ID_SYMBOL2, {
|
|
@@ -87821,6 +88132,11 @@ function createForwardedWritable2({ global: global2, ops, runId, name, key, depl
|
|
|
87821
88132
|
return serialize5.writable;
|
|
87822
88133
|
}
|
|
87823
88134
|
function getRunReadableStream2(global2, ops, runId, name, startIndex, cryptoKey) {
|
|
88135
|
+
return getLazyReadableStream2((onReadableState) => getExternalRevivers2(global2, ops, runId, cryptoKey, {
|
|
88136
|
+
onReadableState
|
|
88137
|
+
}).ReadableStream({ name, startIndex }));
|
|
88138
|
+
}
|
|
88139
|
+
function getLazyReadableStream2(reviveReadable, onReadableState) {
|
|
87824
88140
|
let reader;
|
|
87825
88141
|
let lockState;
|
|
87826
88142
|
let lockPollingStarted = false;
|
|
@@ -87830,15 +88146,16 @@ function getRunReadableStream2(global2, ops, runId, name, startIndex, cryptoKey)
|
|
|
87830
88146
|
async pull(controller) {
|
|
87831
88147
|
try {
|
|
87832
88148
|
if (!reader) {
|
|
87833
|
-
const stream =
|
|
87834
|
-
|
|
87835
|
-
|
|
87836
|
-
}, "onReadableState")
|
|
87837
|
-
}).ReadableStream({ name, startIndex });
|
|
88149
|
+
const stream = reviveReadable((state) => {
|
|
88150
|
+
lockState = state;
|
|
88151
|
+
});
|
|
87838
88152
|
reader = stream.getReader();
|
|
87839
88153
|
if (lockState && !lockPollingStarted) {
|
|
87840
88154
|
lockPollingStarted = true;
|
|
87841
|
-
|
|
88155
|
+
if (onReadableState)
|
|
88156
|
+
onReadableState(lockState);
|
|
88157
|
+
else
|
|
88158
|
+
pollReadableLock2(userReadable, lockState);
|
|
87842
88159
|
}
|
|
87843
88160
|
}
|
|
87844
88161
|
const result2 = await reader.read();
|
|
@@ -87862,6 +88179,48 @@ function getRunReadableStream2(global2, ops, runId, name, startIndex, cryptoKey)
|
|
|
87862
88179
|
return userReadable;
|
|
87863
88180
|
}
|
|
87864
88181
|
function getExternalRevivers2(global2 = globalThis, ops, runId, cryptoKey, options) {
|
|
88182
|
+
function reviveReadableStream(value, onReadableState = options?.onReadableState) {
|
|
88183
|
+
if (value.type === "bytes") {
|
|
88184
|
+
const readable2 = new WorkflowServerReadableStream2(runId, value.name, value.startIndex);
|
|
88185
|
+
const state2 = createFlushableState2();
|
|
88186
|
+
ops.push(state2.promise);
|
|
88187
|
+
const { readable: userReadable, writable } = value.framing === "framed-v1" ? getByteUnframingStream2() : new global2.TransformStream();
|
|
88188
|
+
flushablePipe2(readable2, writable, state2).catch(() => {
|
|
88189
|
+
});
|
|
88190
|
+
if (onReadableState)
|
|
88191
|
+
onReadableState(state2);
|
|
88192
|
+
else
|
|
88193
|
+
pollReadableLock2(userReadable, state2);
|
|
88194
|
+
return userReadable;
|
|
88195
|
+
}
|
|
88196
|
+
let keyPromise;
|
|
88197
|
+
const resolveKey = /* @__PURE__ */ __name(() => {
|
|
88198
|
+
keyPromise ??= resolveEncryptionKey2(cryptoKey);
|
|
88199
|
+
return keyPromise;
|
|
88200
|
+
}, "resolveKey");
|
|
88201
|
+
const readable = createReconnectingFramedStream2(runId, value.name, value.startIndex, resolveKey);
|
|
88202
|
+
const transform3 = getDeserializeStream2(getExternalRevivers2(global2, ops, runId, resolveKey, {
|
|
88203
|
+
lazyStreams: options?.lazyStreams,
|
|
88204
|
+
liveAbortSignals: options?.liveAbortSignals
|
|
88205
|
+
}), resolveKey);
|
|
88206
|
+
const state = createFlushableState2();
|
|
88207
|
+
ops.push(state.promise);
|
|
88208
|
+
flushablePipe2(readable, transform3.writable, state).catch(() => {
|
|
88209
|
+
});
|
|
88210
|
+
if (onReadableState)
|
|
88211
|
+
onReadableState(state);
|
|
88212
|
+
else
|
|
88213
|
+
pollReadableLock2(transform3.readable, state);
|
|
88214
|
+
return transform3.readable;
|
|
88215
|
+
}
|
|
88216
|
+
__name(reviveReadableStream, "reviveReadableStream");
|
|
88217
|
+
function reviveAbortSnapshot(value) {
|
|
88218
|
+
const controller = new AbortController();
|
|
88219
|
+
if (value.aborted)
|
|
88220
|
+
controller.abort(value.reason);
|
|
88221
|
+
return controller;
|
|
88222
|
+
}
|
|
88223
|
+
__name(reviveAbortSnapshot, "reviveAbortSnapshot");
|
|
87865
88224
|
return {
|
|
87866
88225
|
...getCommonRevivers4(global2),
|
|
87867
88226
|
// StepFunction should not be returned from workflows to clients
|
|
@@ -87902,40 +88261,11 @@ function getExternalRevivers2(global2 = globalThis, ops, runId, cryptoKey, optio
|
|
|
87902
88261
|
const response = new global2.Response(bodyInit);
|
|
87903
88262
|
return response.body;
|
|
87904
88263
|
}
|
|
87905
|
-
|
|
87906
|
-
const readable = new WorkflowServerReadableStream2(runId, value.name, value.startIndex);
|
|
87907
|
-
const state = createFlushableState2();
|
|
87908
|
-
ops.push(state.promise);
|
|
87909
|
-
const { readable: userReadable, writable } = value.framing === "framed-v1" ? getByteUnframingStream2() : new global2.TransformStream();
|
|
87910
|
-
flushablePipe2(readable, writable, state).catch(() => {
|
|
87911
|
-
});
|
|
87912
|
-
if (options?.onReadableState)
|
|
87913
|
-
options.onReadableState(state);
|
|
87914
|
-
else
|
|
87915
|
-
pollReadableLock2(userReadable, state);
|
|
87916
|
-
return userReadable;
|
|
87917
|
-
} else {
|
|
87918
|
-
let keyPromise;
|
|
87919
|
-
const resolveKey = /* @__PURE__ */ __name(() => {
|
|
87920
|
-
keyPromise ??= resolveEncryptionKey2(cryptoKey);
|
|
87921
|
-
return keyPromise;
|
|
87922
|
-
}, "resolveKey");
|
|
87923
|
-
const readable = createReconnectingFramedStream2(runId, value.name, value.startIndex, resolveKey);
|
|
87924
|
-
const transform3 = getDeserializeStream2(getExternalRevivers2(global2, ops, runId, resolveKey), resolveKey);
|
|
87925
|
-
const state = createFlushableState2();
|
|
87926
|
-
ops.push(state.promise);
|
|
87927
|
-
flushablePipe2(readable, transform3.writable, state).catch(() => {
|
|
87928
|
-
});
|
|
87929
|
-
if (options?.onReadableState)
|
|
87930
|
-
options.onReadableState(state);
|
|
87931
|
-
else
|
|
87932
|
-
pollReadableLock2(transform3.readable, state);
|
|
87933
|
-
return transform3.readable;
|
|
87934
|
-
}
|
|
88264
|
+
return options?.lazyStreams ? getLazyReadableStream2((onReadableState) => reviveReadableStream(value, onReadableState), options.onReadableState) : reviveReadableStream(value);
|
|
87935
88265
|
}, "ReadableStream"),
|
|
87936
88266
|
WritableStream: /* @__PURE__ */ __name((value) => {
|
|
87937
88267
|
const targetRunId = typeof value.runId === "string" ? value.runId : runId;
|
|
87938
|
-
const targetKey = targetRunId === runId ? cryptoKey :
|
|
88268
|
+
const targetKey = targetRunId === runId ? cryptoKey : lazyForwardedWritableEncryptionKey2(targetRunId, value.deploymentId, value.encryptionPublicKey);
|
|
87939
88269
|
return createForwardedWritable2({
|
|
87940
88270
|
global: global2,
|
|
87941
88271
|
ops,
|
|
@@ -87946,8 +88276,8 @@ function getExternalRevivers2(global2 = globalThis, ops, runId, cryptoKey, optio
|
|
|
87946
88276
|
encryptionPublicKey: value.encryptionPublicKey
|
|
87947
88277
|
});
|
|
87948
88278
|
}, "WritableStream"),
|
|
87949
|
-
AbortController: /* @__PURE__ */ __name((value) => reviveAbortController2(value, ops, runId), "AbortController"),
|
|
87950
|
-
AbortSignal: /* @__PURE__ */ __name((value) => reviveAbortSignal2(value, ops, runId), "AbortSignal")
|
|
88279
|
+
AbortController: /* @__PURE__ */ __name((value) => options?.liveAbortSignals === false ? reviveAbortSnapshot(value) : reviveAbortController2(value, ops, runId), "AbortController"),
|
|
88280
|
+
AbortSignal: /* @__PURE__ */ __name((value) => options?.liveAbortSignals === false ? reviveAbortSnapshot(value).signal : reviveAbortSignal2(value, ops, runId), "AbortSignal")
|
|
87951
88281
|
};
|
|
87952
88282
|
}
|
|
87953
88283
|
function getWorkflowRevivers(global2 = globalThis) {
|
|
@@ -88192,7 +88522,7 @@ function getStepRevivers2(global2 = globalThis, ops, runId, cryptoKey, deploymen
|
|
|
88192
88522
|
WritableStream: /* @__PURE__ */ __name((value) => {
|
|
88193
88523
|
const targetRunId = typeof value.runId === "string" ? value.runId : runId;
|
|
88194
88524
|
const targetDeploymentId = typeof value.deploymentId === "string" ? value.deploymentId : targetRunId === runId ? deploymentId : void 0;
|
|
88195
|
-
const targetKey = targetRunId === runId ? cryptoKey :
|
|
88525
|
+
const targetKey = targetRunId === runId ? cryptoKey : lazyForwardedWritableEncryptionKey2(targetRunId, targetDeploymentId, value.encryptionPublicKey);
|
|
88196
88526
|
const serialize5 = getSerializeStream2(getStepReducers2(global2, ops, targetRunId, targetKey), targetKey);
|
|
88197
88527
|
const serverWritable = new WorkflowServerWritableStream2(targetRunId, value.name);
|
|
88198
88528
|
const state = createFlushableState2();
|
|
@@ -88819,9 +89149,11 @@ var init_serialization4 = __esm({
|
|
|
88819
89149
|
__name(reviveAbortSignal2, "reviveAbortSignal");
|
|
88820
89150
|
__name(getCommonRevivers4, "getCommonRevivers");
|
|
88821
89151
|
__name(getForwardedWritableEncryptionKey2, "getForwardedWritableEncryptionKey");
|
|
89152
|
+
__name(lazyForwardedWritableEncryptionKey2, "lazyForwardedWritableEncryptionKey");
|
|
88822
89153
|
__name(tagForwardedWritableTarget2, "tagForwardedWritableTarget");
|
|
88823
89154
|
__name(createForwardedWritable2, "createForwardedWritable");
|
|
88824
89155
|
__name(getRunReadableStream2, "getRunReadableStream");
|
|
89156
|
+
__name(getLazyReadableStream2, "getLazyReadableStream");
|
|
88825
89157
|
__name(getExternalRevivers2, "getExternalRevivers");
|
|
88826
89158
|
__name(getWorkflowRevivers, "getWorkflowRevivers");
|
|
88827
89159
|
__name(getStepRevivers2, "getStepRevivers");
|
|
@@ -89073,6 +89405,751 @@ var init_constants3 = __esm({
|
|
|
89073
89405
|
}
|
|
89074
89406
|
});
|
|
89075
89407
|
|
|
89408
|
+
// ../core/dist/types.js
|
|
89409
|
+
import { types as types6 } from "node:util";
|
|
89410
|
+
function getErrorName(v) {
|
|
89411
|
+
if (types6.isNativeError(v)) {
|
|
89412
|
+
return v.name;
|
|
89413
|
+
}
|
|
89414
|
+
return "Error";
|
|
89415
|
+
}
|
|
89416
|
+
function getErrorStack(v) {
|
|
89417
|
+
if (types6.isNativeError(v)) {
|
|
89418
|
+
return v.stack ?? "";
|
|
89419
|
+
}
|
|
89420
|
+
return "";
|
|
89421
|
+
}
|
|
89422
|
+
function describeErrorLink(value) {
|
|
89423
|
+
if (typeof value !== "object" || value === null) {
|
|
89424
|
+
return String(value);
|
|
89425
|
+
}
|
|
89426
|
+
const { name, message, code: code3 } = value;
|
|
89427
|
+
const label = typeof name === "string" && name ? name : "Error";
|
|
89428
|
+
const text = typeof message === "string" && message ? `${label}: ${message}` : label;
|
|
89429
|
+
return typeof code3 === "string" && code3 && !text.includes(code3) ? `${text} (${code3})` : text;
|
|
89430
|
+
}
|
|
89431
|
+
function formatErrorCauseChain(value) {
|
|
89432
|
+
const lines = [];
|
|
89433
|
+
const seen = /* @__PURE__ */ new Set();
|
|
89434
|
+
try {
|
|
89435
|
+
for (let current = causeOf(value); current != null && lines.length <= MAX_CAUSE_LINKS; current = causeOf(current)) {
|
|
89436
|
+
if (typeof current !== "object") {
|
|
89437
|
+
lines.push(String(current));
|
|
89438
|
+
break;
|
|
89439
|
+
}
|
|
89440
|
+
if (seen.has(current))
|
|
89441
|
+
break;
|
|
89442
|
+
seen.add(current);
|
|
89443
|
+
lines.push(describeErrorLink(current), ...aggregatedLinks(current));
|
|
89444
|
+
}
|
|
89445
|
+
} catch {
|
|
89446
|
+
lines.push("[unavailable cause]");
|
|
89447
|
+
}
|
|
89448
|
+
return lines.length > MAX_CAUSE_LINKS ? [...lines.slice(0, MAX_CAUSE_LINKS), "\u2026"].join("\n") : lines.join("\n");
|
|
89449
|
+
}
|
|
89450
|
+
function causeOf(value) {
|
|
89451
|
+
return typeof value === "object" && value !== null ? value.cause : void 0;
|
|
89452
|
+
}
|
|
89453
|
+
function aggregatedLinks(value) {
|
|
89454
|
+
const errors = value.errors;
|
|
89455
|
+
return Array.isArray(errors) ? errors.slice(0, MAX_CAUSE_LINKS).map(describeErrorLink) : [];
|
|
89456
|
+
}
|
|
89457
|
+
function isAbortError(value) {
|
|
89458
|
+
return typeof value === "object" && value !== null && "name" in value && value.name === "AbortError" && "message" in value && typeof value.message === "string" && (!("stack" in value) || value.stack === void 0 || typeof value.stack === "string");
|
|
89459
|
+
}
|
|
89460
|
+
function promoteAbortErrorToFatal(value) {
|
|
89461
|
+
if (!isAbortError(value) || FatalError2.is(value)) {
|
|
89462
|
+
return value;
|
|
89463
|
+
}
|
|
89464
|
+
const fatalError = new FatalError2(`Aborted: ${value.message}`);
|
|
89465
|
+
if (value.stack) {
|
|
89466
|
+
fatalError.stack = value.stack;
|
|
89467
|
+
}
|
|
89468
|
+
return fatalError;
|
|
89469
|
+
}
|
|
89470
|
+
function isThenable(value) {
|
|
89471
|
+
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
89472
|
+
}
|
|
89473
|
+
function normalizeSyncError(v) {
|
|
89474
|
+
if (types6.isNativeError(v)) {
|
|
89475
|
+
return {
|
|
89476
|
+
name: v.name,
|
|
89477
|
+
message: v.message,
|
|
89478
|
+
stack: v.stack ?? ""
|
|
89479
|
+
};
|
|
89480
|
+
}
|
|
89481
|
+
if (typeof v === "string") {
|
|
89482
|
+
return {
|
|
89483
|
+
name: "Error",
|
|
89484
|
+
message: v,
|
|
89485
|
+
stack: ""
|
|
89486
|
+
};
|
|
89487
|
+
}
|
|
89488
|
+
try {
|
|
89489
|
+
return {
|
|
89490
|
+
name: "Error",
|
|
89491
|
+
message: JSON.stringify(v),
|
|
89492
|
+
stack: ""
|
|
89493
|
+
};
|
|
89494
|
+
} catch {
|
|
89495
|
+
return {
|
|
89496
|
+
name: "Error",
|
|
89497
|
+
message: String(v),
|
|
89498
|
+
stack: ""
|
|
89499
|
+
};
|
|
89500
|
+
}
|
|
89501
|
+
}
|
|
89502
|
+
async function normalizeUnknownError(value) {
|
|
89503
|
+
if (isThenable(value)) {
|
|
89504
|
+
try {
|
|
89505
|
+
const resolved = await value;
|
|
89506
|
+
const normalized = await normalizeUnknownError(resolved);
|
|
89507
|
+
return {
|
|
89508
|
+
...normalized,
|
|
89509
|
+
message: `Promise rejection: ${normalized.message}`
|
|
89510
|
+
};
|
|
89511
|
+
} catch (rejection) {
|
|
89512
|
+
const normalized = await normalizeUnknownError(rejection);
|
|
89513
|
+
return {
|
|
89514
|
+
...normalized,
|
|
89515
|
+
message: `Promise rejection: ${normalized.message}`
|
|
89516
|
+
};
|
|
89517
|
+
}
|
|
89518
|
+
}
|
|
89519
|
+
return normalizeSyncError(value);
|
|
89520
|
+
}
|
|
89521
|
+
var MAX_CAUSE_LINKS;
|
|
89522
|
+
var init_types4 = __esm({
|
|
89523
|
+
"../core/dist/types.js"() {
|
|
89524
|
+
"use strict";
|
|
89525
|
+
init_dist7();
|
|
89526
|
+
__name(getErrorName, "getErrorName");
|
|
89527
|
+
__name(getErrorStack, "getErrorStack");
|
|
89528
|
+
MAX_CAUSE_LINKS = 4;
|
|
89529
|
+
__name(describeErrorLink, "describeErrorLink");
|
|
89530
|
+
__name(formatErrorCauseChain, "formatErrorCauseChain");
|
|
89531
|
+
__name(causeOf, "causeOf");
|
|
89532
|
+
__name(aggregatedLinks, "aggregatedLinks");
|
|
89533
|
+
__name(isAbortError, "isAbortError");
|
|
89534
|
+
__name(promoteAbortErrorToFatal, "promoteAbortErrorToFatal");
|
|
89535
|
+
__name(isThenable, "isThenable");
|
|
89536
|
+
__name(normalizeSyncError, "normalizeSyncError");
|
|
89537
|
+
__name(normalizeUnknownError, "normalizeUnknownError");
|
|
89538
|
+
}
|
|
89539
|
+
});
|
|
89540
|
+
|
|
89541
|
+
// ../core/dist/attribute-changes.js
|
|
89542
|
+
var init_attribute_changes = __esm({
|
|
89543
|
+
"../core/dist/attribute-changes.js"() {
|
|
89544
|
+
"use strict";
|
|
89545
|
+
init_dist7();
|
|
89546
|
+
init_attributes_validation2();
|
|
89547
|
+
}
|
|
89548
|
+
});
|
|
89549
|
+
|
|
89550
|
+
// ../core/dist/runtime/vm-mode.js
|
|
89551
|
+
function getWorkflowVmFromEnv2(env = process.env) {
|
|
89552
|
+
const raw = env.WORKFLOW_VM;
|
|
89553
|
+
if (raw === void 0 || raw === "")
|
|
89554
|
+
return void 0;
|
|
89555
|
+
if (WORKFLOW_VMS2.includes(raw)) {
|
|
89556
|
+
return raw;
|
|
89557
|
+
}
|
|
89558
|
+
throw new WorkflowRuntimeError2(`Invalid WORKFLOW_VM value: "${raw}". Expected one of: ${WORKFLOW_VMS2.join(", ")}.`);
|
|
89559
|
+
}
|
|
89560
|
+
function useQuickJSVm(workflowRun) {
|
|
89561
|
+
const vmFromRun = workflowRun.executionContext?.workflowVm;
|
|
89562
|
+
if (vmFromRun !== void 0) {
|
|
89563
|
+
if (!WORKFLOW_VMS2.includes(vmFromRun)) {
|
|
89564
|
+
throw new WorkflowRuntimeError2(`Invalid executionContext.workflowVm value: "${vmFromRun}". Expected one of: ${WORKFLOW_VMS2.join(", ")}.`);
|
|
89565
|
+
}
|
|
89566
|
+
return vmFromRun === "quickjs";
|
|
89567
|
+
}
|
|
89568
|
+
return getWorkflowVmFromEnv2() === "quickjs";
|
|
89569
|
+
}
|
|
89570
|
+
var WORKFLOW_VMS2;
|
|
89571
|
+
var init_vm_mode = __esm({
|
|
89572
|
+
"../core/dist/runtime/vm-mode.js"() {
|
|
89573
|
+
"use strict";
|
|
89574
|
+
init_dist7();
|
|
89575
|
+
WORKFLOW_VMS2 = ["node", "quickjs"];
|
|
89576
|
+
__name(getWorkflowVmFromEnv2, "getWorkflowVmFromEnv");
|
|
89577
|
+
__name(useQuickJSVm, "useQuickJSVm");
|
|
89578
|
+
}
|
|
89579
|
+
});
|
|
89580
|
+
|
|
89581
|
+
// ../core/dist/runtime/start.js
|
|
89582
|
+
var ulid7, latestNoOpWarning2;
|
|
89583
|
+
var init_start = __esm({
|
|
89584
|
+
"../core/dist/runtime/start.js"() {
|
|
89585
|
+
"use strict";
|
|
89586
|
+
init_dist7();
|
|
89587
|
+
init_dist5();
|
|
89588
|
+
init_dist6();
|
|
89589
|
+
init_node2();
|
|
89590
|
+
init_attribute_changes();
|
|
89591
|
+
init_capabilities2();
|
|
89592
|
+
init_classify_error();
|
|
89593
|
+
init_encryption4();
|
|
89594
|
+
init_logger2();
|
|
89595
|
+
init_sealed_box2();
|
|
89596
|
+
init_serialization4();
|
|
89597
|
+
init_context_storage2();
|
|
89598
|
+
init_semantic_conventions2();
|
|
89599
|
+
init_telemetry4();
|
|
89600
|
+
init_version4();
|
|
89601
|
+
init_get_world_lazy2();
|
|
89602
|
+
init_helpers3();
|
|
89603
|
+
init_run();
|
|
89604
|
+
init_vm_mode();
|
|
89605
|
+
init_wait_until2();
|
|
89606
|
+
init_world_compatibility2();
|
|
89607
|
+
ulid7 = monotonicFactory2();
|
|
89608
|
+
latestNoOpWarning2 = globalSingleton2("@workflow/core//latestNoOpWarning", 1, () => ({ warned: false }));
|
|
89609
|
+
}
|
|
89610
|
+
});
|
|
89611
|
+
|
|
89612
|
+
// ../core/dist/runtime/runs.js
|
|
89613
|
+
async function wakeUpRun2(world, runId, options) {
|
|
89614
|
+
try {
|
|
89615
|
+
const run3 = await world.runs.get(runId, { resolveData: "none" });
|
|
89616
|
+
const compatMode = isLegacySpecVersion2(run3.specVersion);
|
|
89617
|
+
const allEvents = [];
|
|
89618
|
+
let cursor = null;
|
|
89619
|
+
do {
|
|
89620
|
+
const eventsResult = await world.events.list({
|
|
89621
|
+
runId,
|
|
89622
|
+
pagination: { sortOrder: "asc", ...cursor ? { cursor } : {} },
|
|
89623
|
+
resolveData: "none"
|
|
89624
|
+
});
|
|
89625
|
+
allEvents.push(...eventsResult.data);
|
|
89626
|
+
cursor = eventsResult.hasMore ? eventsResult.cursor : null;
|
|
89627
|
+
} while (cursor);
|
|
89628
|
+
const waitCreatedEvents = allEvents.filter((event) => event.eventType === "wait_created");
|
|
89629
|
+
const waitCompletedCorrelationIds = new Set(allEvents.filter((event) => event.eventType === "wait_completed").map((event) => event.correlationId));
|
|
89630
|
+
let pendingWaits = waitCreatedEvents.filter((event) => !waitCompletedCorrelationIds.has(event.correlationId));
|
|
89631
|
+
if (options?.correlationIds && options.correlationIds.length > 0) {
|
|
89632
|
+
const targetCorrelationIds = new Set(options.correlationIds);
|
|
89633
|
+
pendingWaits = pendingWaits.filter((event) => event.correlationId && targetCorrelationIds.has(event.correlationId));
|
|
89634
|
+
}
|
|
89635
|
+
const errors = [];
|
|
89636
|
+
let stoppedCount = 0;
|
|
89637
|
+
for (const waitEvent of pendingWaits) {
|
|
89638
|
+
if (!waitEvent.correlationId)
|
|
89639
|
+
continue;
|
|
89640
|
+
const eventData = compatMode ? {
|
|
89641
|
+
eventType: "wait_completed",
|
|
89642
|
+
correlationId: waitEvent.correlationId
|
|
89643
|
+
} : {
|
|
89644
|
+
eventType: "wait_completed",
|
|
89645
|
+
correlationId: waitEvent.correlationId,
|
|
89646
|
+
specVersion: run3.specVersion,
|
|
89647
|
+
eventData: {
|
|
89648
|
+
resumeAt: waitEvent.eventData.resumeAt
|
|
89649
|
+
}
|
|
89650
|
+
};
|
|
89651
|
+
try {
|
|
89652
|
+
await world.events.create(runId, eventData, { v1Compat: compatMode });
|
|
89653
|
+
stoppedCount++;
|
|
89654
|
+
} catch (err) {
|
|
89655
|
+
if (EntityConflictError2.is(err)) {
|
|
89656
|
+
stoppedCount++;
|
|
89657
|
+
} else {
|
|
89658
|
+
errors.push(err instanceof Error ? err : new Error(String(err)));
|
|
89659
|
+
}
|
|
89660
|
+
}
|
|
89661
|
+
}
|
|
89662
|
+
if (stoppedCount > 0) {
|
|
89663
|
+
await world.queue(getWorkflowQueueName2(run3.workflowName, options?.namespace), {
|
|
89664
|
+
runId
|
|
89665
|
+
}, {
|
|
89666
|
+
deploymentId: run3.deploymentId,
|
|
89667
|
+
specVersion: run3.specVersion ?? SPEC_VERSION_LEGACY2
|
|
89668
|
+
});
|
|
89669
|
+
}
|
|
89670
|
+
if (errors.length > 0) {
|
|
89671
|
+
throw new AggregateError(errors, `Failed to complete ${errors.length}/${pendingWaits.length} pending wait(s) for run ${runId}`);
|
|
89672
|
+
}
|
|
89673
|
+
return { stoppedCount };
|
|
89674
|
+
} catch (err) {
|
|
89675
|
+
if (err instanceof AggregateError) {
|
|
89676
|
+
throw err;
|
|
89677
|
+
}
|
|
89678
|
+
throw new Error(`Failed to wake up run ${runId}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
89679
|
+
}
|
|
89680
|
+
}
|
|
89681
|
+
var init_runs4 = __esm({
|
|
89682
|
+
"../core/dist/runtime/runs.js"() {
|
|
89683
|
+
"use strict";
|
|
89684
|
+
init_dist7();
|
|
89685
|
+
init_dist6();
|
|
89686
|
+
init_encryption5();
|
|
89687
|
+
init_serialization4();
|
|
89688
|
+
init_helpers3();
|
|
89689
|
+
init_start();
|
|
89690
|
+
__name(wakeUpRun2, "wakeUpRun");
|
|
89691
|
+
}
|
|
89692
|
+
});
|
|
89693
|
+
|
|
89694
|
+
// ../core/dist/runtime/run.js
|
|
89695
|
+
function getReturnValuePollIntervalMs2() {
|
|
89696
|
+
return envNumber2("WORKFLOW_RETURN_VALUE_POLL_INTERVAL_MS", RETURN_VALUE_POLL_INTERVAL_MS2, { integer: true, min: 1 });
|
|
89697
|
+
}
|
|
89698
|
+
function getReturnValueWaitTimeoutMs2() {
|
|
89699
|
+
return envNumber2("WORKFLOW_RETURN_VALUE_WAIT_MS", RETURN_VALUE_WAIT_TIMEOUT_MS2, { integer: true, min: 1 });
|
|
89700
|
+
}
|
|
89701
|
+
function getReturnValueMaxLongPolls2() {
|
|
89702
|
+
return envNumber2("WORKFLOW_RETURN_VALUE_MAX_LONG_POLLS", RETURN_VALUE_MAX_LONG_POLLS2, { integer: true, min: 1 });
|
|
89703
|
+
}
|
|
89704
|
+
function isReturnValueLongPollEnabled2() {
|
|
89705
|
+
const raw = process.env.WORKFLOW_RETURN_VALUE_LONG_POLL;
|
|
89706
|
+
if (raw === void 0 || raw === "")
|
|
89707
|
+
return true;
|
|
89708
|
+
return !(raw === "0" || raw.toLowerCase() === "false");
|
|
89709
|
+
}
|
|
89710
|
+
var RETURN_VALUE_POLL_INTERVAL_MS2, PAYLOAD_TERMINAL_RUN_STATUSES2, NOT_FOUND_RETRY_DELAYS2, RETURN_VALUE_WAIT_TIMEOUT_MS2, RETURN_VALUE_MAX_LONG_POLLS2, Run2;
|
|
89711
|
+
var init_run = __esm({
|
|
89712
|
+
"../core/dist/runtime/run.js"() {
|
|
89713
|
+
"use strict";
|
|
89714
|
+
init_dist7();
|
|
89715
|
+
init_dist12();
|
|
89716
|
+
init_env_config2();
|
|
89717
|
+
init_spec_version2();
|
|
89718
|
+
init_encryption5();
|
|
89719
|
+
init_serialization4();
|
|
89720
|
+
init_util5();
|
|
89721
|
+
init_get_world_lazy2();
|
|
89722
|
+
init_runs4();
|
|
89723
|
+
RETURN_VALUE_POLL_INTERVAL_MS2 = 1e3;
|
|
89724
|
+
PAYLOAD_TERMINAL_RUN_STATUSES2 = /* @__PURE__ */ new Set([
|
|
89725
|
+
"completed",
|
|
89726
|
+
"failed"
|
|
89727
|
+
]);
|
|
89728
|
+
NOT_FOUND_RETRY_DELAYS2 = [1e3, 3e3, 6e3];
|
|
89729
|
+
__name(getReturnValuePollIntervalMs2, "getReturnValuePollIntervalMs");
|
|
89730
|
+
RETURN_VALUE_WAIT_TIMEOUT_MS2 = 5e4;
|
|
89731
|
+
__name(getReturnValueWaitTimeoutMs2, "getReturnValueWaitTimeoutMs");
|
|
89732
|
+
RETURN_VALUE_MAX_LONG_POLLS2 = 10;
|
|
89733
|
+
__name(getReturnValueMaxLongPolls2, "getReturnValueMaxLongPolls");
|
|
89734
|
+
__name(isReturnValueLongPollEnabled2, "isReturnValueLongPollEnabled");
|
|
89735
|
+
Run2 = class _Run2 {
|
|
89736
|
+
static {
|
|
89737
|
+
__name(this, "Run");
|
|
89738
|
+
}
|
|
89739
|
+
static [WORKFLOW_SERIALIZE2](instance) {
|
|
89740
|
+
return { runId: instance.runId, resilientStart: instance.#resilientStart };
|
|
89741
|
+
}
|
|
89742
|
+
static [WORKFLOW_DESERIALIZE2](data) {
|
|
89743
|
+
return new _Run2(data.runId, { resilientStart: data.resilientStart });
|
|
89744
|
+
}
|
|
89745
|
+
/**
|
|
89746
|
+
* The ID of the workflow run.
|
|
89747
|
+
*/
|
|
89748
|
+
runId;
|
|
89749
|
+
/**
|
|
89750
|
+
* The world object.
|
|
89751
|
+
* @internal
|
|
89752
|
+
*/
|
|
89753
|
+
#worldPromise;
|
|
89754
|
+
get #lazyWorldPromise() {
|
|
89755
|
+
if (!this.#worldPromise)
|
|
89756
|
+
this.#worldPromise = getWorldLazy2();
|
|
89757
|
+
return this.#worldPromise;
|
|
89758
|
+
}
|
|
89759
|
+
/**
|
|
89760
|
+
* Cached encryption key resolution. Resolved once on first use and
|
|
89761
|
+
* reused for returnValue, getReadable(), etc.
|
|
89762
|
+
* @internal
|
|
89763
|
+
*/
|
|
89764
|
+
#encryptionKeyPromise = null;
|
|
89765
|
+
/**
|
|
89766
|
+
* When true, run_created failed and the run may not exist yet (the
|
|
89767
|
+
* resilient start path will create it via run_started). pollReturnValue
|
|
89768
|
+
* retries on WorkflowRunNotFoundError only when this flag is set so
|
|
89769
|
+
* that normal runs fail fast on 404.
|
|
89770
|
+
* @internal
|
|
89771
|
+
*/
|
|
89772
|
+
#resilientStart = false;
|
|
89773
|
+
constructor(runId, opts) {
|
|
89774
|
+
this.runId = runId;
|
|
89775
|
+
this.#resilientStart = opts?.resilientStart ?? false;
|
|
89776
|
+
}
|
|
89777
|
+
/**
|
|
89778
|
+
* Resolves and caches the encryption key for this run.
|
|
89779
|
+
* The key is the same for the lifetime of a run, so it only needs
|
|
89780
|
+
* to be resolved once.
|
|
89781
|
+
* @internal
|
|
89782
|
+
*/
|
|
89783
|
+
#getEncryptionKey(run3) {
|
|
89784
|
+
if (!this.#encryptionKeyPromise) {
|
|
89785
|
+
this.#encryptionKeyPromise = (async () => {
|
|
89786
|
+
const world = await this.#lazyWorldPromise;
|
|
89787
|
+
const runData = run3 ?? await world.runs.get(this.runId);
|
|
89788
|
+
const rawKey = await world.getEncryptionKeyForRun?.(runData);
|
|
89789
|
+
return rawKey ? await deriveRunPayloadKeys2(rawKey) : void 0;
|
|
89790
|
+
})();
|
|
89791
|
+
}
|
|
89792
|
+
return this.#encryptionKeyPromise;
|
|
89793
|
+
}
|
|
89794
|
+
/**
|
|
89795
|
+
* Defers fetching the run and its encryption key until a readable is first
|
|
89796
|
+
* consumed. The first pull prefetches it so an encrypted first frame can join
|
|
89797
|
+
* the lookup; this also applies to an empty consumed stream.
|
|
89798
|
+
* @internal
|
|
89799
|
+
*/
|
|
89800
|
+
#getEncryptionKeyLazily() {
|
|
89801
|
+
return () => this.#getEncryptionKey();
|
|
89802
|
+
}
|
|
89803
|
+
/**
|
|
89804
|
+
* Interrupts pending `sleep()` calls, resuming the workflow early.
|
|
89805
|
+
*
|
|
89806
|
+
* @param options - Optional settings to target specific sleep calls by correlation ID.
|
|
89807
|
+
* If not provided, all pending sleep calls will be interrupted.
|
|
89808
|
+
* @returns A {@link StopSleepResult} object containing the number of sleep calls that were interrupted.
|
|
89809
|
+
*/
|
|
89810
|
+
async wakeUp(options) {
|
|
89811
|
+
"use step";
|
|
89812
|
+
return wakeUpRun2(await this.#lazyWorldPromise, this.runId, options);
|
|
89813
|
+
}
|
|
89814
|
+
/**
|
|
89815
|
+
* Cancels the workflow run.
|
|
89816
|
+
*
|
|
89817
|
+
* @param options - Optional cancellation settings. `cancelReason` records a
|
|
89818
|
+
* free-text reason (max 512 chars) on the run_cancelled event, surfaced in
|
|
89819
|
+
* the run detail view.
|
|
89820
|
+
*/
|
|
89821
|
+
async cancel(options) {
|
|
89822
|
+
"use step";
|
|
89823
|
+
const world = await this.#lazyWorldPromise;
|
|
89824
|
+
await world.events.create(this.runId, {
|
|
89825
|
+
eventType: "run_cancelled",
|
|
89826
|
+
specVersion: SPEC_VERSION_CURRENT2,
|
|
89827
|
+
...options?.cancelReason !== void 0 ? { eventData: { cancelReason: options.cancelReason } } : {}
|
|
89828
|
+
});
|
|
89829
|
+
}
|
|
89830
|
+
/**
|
|
89831
|
+
* Whether the workflow run exists.
|
|
89832
|
+
*/
|
|
89833
|
+
get exists() {
|
|
89834
|
+
"use step";
|
|
89835
|
+
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId, { resolveData: "none" }).then(() => true).catch((error121) => {
|
|
89836
|
+
if (WorkflowRunNotFoundError2.is(error121)) {
|
|
89837
|
+
return false;
|
|
89838
|
+
}
|
|
89839
|
+
throw error121;
|
|
89840
|
+
}));
|
|
89841
|
+
}
|
|
89842
|
+
/**
|
|
89843
|
+
* The status of the workflow run.
|
|
89844
|
+
*/
|
|
89845
|
+
get status() {
|
|
89846
|
+
"use step";
|
|
89847
|
+
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId, { resolveData: "none" }).then((run3) => run3.status));
|
|
89848
|
+
}
|
|
89849
|
+
/**
|
|
89850
|
+
* The return value of the workflow run.
|
|
89851
|
+
* Polls the workflow return value until the workflow run completes.
|
|
89852
|
+
*/
|
|
89853
|
+
get returnValue() {
|
|
89854
|
+
"use step";
|
|
89855
|
+
return this.#pollReturnValue();
|
|
89856
|
+
}
|
|
89857
|
+
/**
|
|
89858
|
+
* The name of the workflow.
|
|
89859
|
+
*/
|
|
89860
|
+
get workflowName() {
|
|
89861
|
+
"use step";
|
|
89862
|
+
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId, { resolveData: "none" }).then((run3) => run3.workflowName));
|
|
89863
|
+
}
|
|
89864
|
+
/**
|
|
89865
|
+
* The timestamp when the workflow run was created.
|
|
89866
|
+
*/
|
|
89867
|
+
get createdAt() {
|
|
89868
|
+
"use step";
|
|
89869
|
+
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId, { resolveData: "none" }).then((run3) => run3.createdAt));
|
|
89870
|
+
}
|
|
89871
|
+
/**
|
|
89872
|
+
* The timestamp when the workflow run started execution.
|
|
89873
|
+
* Returns undefined if the workflow has not started yet.
|
|
89874
|
+
*/
|
|
89875
|
+
get startedAt() {
|
|
89876
|
+
"use step";
|
|
89877
|
+
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId, { resolveData: "none" }).then((run3) => run3.startedAt));
|
|
89878
|
+
}
|
|
89879
|
+
/**
|
|
89880
|
+
* The timestamp when the workflow run completed.
|
|
89881
|
+
* Returns undefined if the workflow has not completed yet.
|
|
89882
|
+
*/
|
|
89883
|
+
get completedAt() {
|
|
89884
|
+
"use step";
|
|
89885
|
+
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId, { resolveData: "none" }).then((run3) => run3.completedAt));
|
|
89886
|
+
}
|
|
89887
|
+
/**
|
|
89888
|
+
* The readable stream of the workflow run.
|
|
89889
|
+
*/
|
|
89890
|
+
get readable() {
|
|
89891
|
+
return this.getReadable();
|
|
89892
|
+
}
|
|
89893
|
+
/**
|
|
89894
|
+
* Retrieves the workflow run's default readable stream, which reads chunks
|
|
89895
|
+
* written to the corresponding writable stream {@link getWritable}.
|
|
89896
|
+
*
|
|
89897
|
+
* The returned stream has an additional {@link WorkflowReadableStream.getTailIndex | getTailIndex()}
|
|
89898
|
+
* helper that returns the index of the last known chunk. This is useful when
|
|
89899
|
+
* building reconnection endpoints that need to inform clients where the
|
|
89900
|
+
* stream starts.
|
|
89901
|
+
*
|
|
89902
|
+
* @param options - The options for the readable stream.
|
|
89903
|
+
* @returns A `WorkflowReadableStream` for the workflow run.
|
|
89904
|
+
*/
|
|
89905
|
+
getReadable(options = {}) {
|
|
89906
|
+
"use step";
|
|
89907
|
+
const { ops = [], global: global2 = globalThis, startIndex, namespace } = options;
|
|
89908
|
+
const name = getWorkflowRunStreamId2(this.runId, namespace);
|
|
89909
|
+
const encryptionKey = this.#getEncryptionKeyLazily();
|
|
89910
|
+
const stream = getRunReadableStream2(global2, ops, this.runId, name, startIndex, encryptionKey);
|
|
89911
|
+
const worldPromise = this.#lazyWorldPromise;
|
|
89912
|
+
const runId = this.runId;
|
|
89913
|
+
return Object.assign(stream, {
|
|
89914
|
+
getTailIndex: /* @__PURE__ */ __name(async () => {
|
|
89915
|
+
const world = await worldPromise;
|
|
89916
|
+
const info = await world.streams.getInfo(runId, name);
|
|
89917
|
+
return info.tailIndex;
|
|
89918
|
+
}, "getTailIndex")
|
|
89919
|
+
});
|
|
89920
|
+
}
|
|
89921
|
+
/** The writable stream of the workflow run. */
|
|
89922
|
+
get writable() {
|
|
89923
|
+
return this.getWritable();
|
|
89924
|
+
}
|
|
89925
|
+
/**
|
|
89926
|
+
* Returns a writable that appends to this run's stream.
|
|
89927
|
+
*
|
|
89928
|
+
* Initialization is deferred until the first write. The run must already
|
|
89929
|
+
* exist. The writable may be forwarded through `start()` and into steps, but
|
|
89930
|
+
* grants no read access or additional authorization.
|
|
89931
|
+
*
|
|
89932
|
+
* @remarks
|
|
89933
|
+
* `writer.close()` closes the shared stream. Contributors should call
|
|
89934
|
+
* `releaseLock()`, which also drains pending writes.
|
|
89935
|
+
*
|
|
89936
|
+
* @param options - The writable stream options.
|
|
89937
|
+
*/
|
|
89938
|
+
getWritable(options = {}) {
|
|
89939
|
+
"use step";
|
|
89940
|
+
const { ops = [], global: global2 = globalThis, namespace } = options;
|
|
89941
|
+
const name = getWorkflowRunStreamId2(this.runId, namespace);
|
|
89942
|
+
let targetPromise;
|
|
89943
|
+
let writable;
|
|
89944
|
+
const resolveTarget = /* @__PURE__ */ __name(() => {
|
|
89945
|
+
targetPromise ??= this.#getMetadata().then(async (run3) => {
|
|
89946
|
+
const target2 = {
|
|
89947
|
+
key: await getForwardedWritableEncryptionKey2(this.runId, run3.deploymentId, run3.encryptionPublicKey),
|
|
89948
|
+
deploymentId: run3.deploymentId,
|
|
89949
|
+
encryptionPublicKey: run3.encryptionPublicKey
|
|
89950
|
+
};
|
|
89951
|
+
tagForwardedWritableTarget2(writable, target2);
|
|
89952
|
+
return target2;
|
|
89953
|
+
});
|
|
89954
|
+
return targetPromise;
|
|
89955
|
+
}, "resolveTarget");
|
|
89956
|
+
writable = createForwardedWritable2({
|
|
89957
|
+
global: global2,
|
|
89958
|
+
ops,
|
|
89959
|
+
runId: this.runId,
|
|
89960
|
+
name,
|
|
89961
|
+
key: /* @__PURE__ */ __name(() => resolveTarget().then(({ key }) => key), "key")
|
|
89962
|
+
});
|
|
89963
|
+
return writable;
|
|
89964
|
+
}
|
|
89965
|
+
/** Reads metadata, briefly retrying resilient starts. @internal */
|
|
89966
|
+
async #getMetadata() {
|
|
89967
|
+
const world = await this.#lazyWorldPromise;
|
|
89968
|
+
const maxRetries = this.#resilientStart ? NOT_FOUND_RETRY_DELAYS2.length : 0;
|
|
89969
|
+
let attempt = 0;
|
|
89970
|
+
while (true) {
|
|
89971
|
+
try {
|
|
89972
|
+
return await world.runs.get(this.runId, { resolveData: "none" });
|
|
89973
|
+
} catch (error121) {
|
|
89974
|
+
if (!WorkflowRunNotFoundError2.is(error121) || attempt >= maxRetries) {
|
|
89975
|
+
throw error121;
|
|
89976
|
+
}
|
|
89977
|
+
const delay = NOT_FOUND_RETRY_DELAYS2[attempt];
|
|
89978
|
+
attempt++;
|
|
89979
|
+
await new Promise((resolve3) => setTimeout(resolve3, delay));
|
|
89980
|
+
}
|
|
89981
|
+
}
|
|
89982
|
+
}
|
|
89983
|
+
/** @internal */
|
|
89984
|
+
async #resolveTerminalReturnValue(run3) {
|
|
89985
|
+
const expiredAt = run3.expiredAt;
|
|
89986
|
+
if (expiredAt != null && expiredAt <= /* @__PURE__ */ new Date()) {
|
|
89987
|
+
throw new RunExpiredError2(`Run "${this.runId}" ${run3.status === "completed" ? "completed" : `is ${run3.status}`}, but its data expired at ${expiredAt.toISOString()} and is no longer readable.`, this.runId, run3.status, expiredAt);
|
|
89988
|
+
}
|
|
89989
|
+
if (run3.status === "completed") {
|
|
89990
|
+
const encryptionKey = await this.#getEncryptionKey(run3);
|
|
89991
|
+
return await hydrateWorkflowReturnValue2(run3.output, this.runId, encryptionKey);
|
|
89992
|
+
}
|
|
89993
|
+
if (run3.status === "cancelled") {
|
|
89994
|
+
throw new WorkflowRunCancelledError2(this.runId);
|
|
89995
|
+
}
|
|
89996
|
+
if (run3.status === "failed") {
|
|
89997
|
+
const encryptionKey = await this.#getEncryptionKey(run3);
|
|
89998
|
+
let hydratedError;
|
|
89999
|
+
try {
|
|
90000
|
+
hydratedError = await hydrateRunError2(run3.error, this.runId, encryptionKey);
|
|
90001
|
+
} catch {
|
|
90002
|
+
hydratedError = new Error("Failed to hydrate workflow run error");
|
|
90003
|
+
}
|
|
90004
|
+
throw new WorkflowRunFailedError2(this.runId, hydratedError, {
|
|
90005
|
+
errorCode: run3.errorCode
|
|
90006
|
+
});
|
|
90007
|
+
}
|
|
90008
|
+
throw new WorkflowRunNotCompletedError2(this.runId, run3.status);
|
|
90009
|
+
}
|
|
90010
|
+
/**
|
|
90011
|
+
* Polls the workflow return value until the workflow run completes.
|
|
90012
|
+
* @internal
|
|
90013
|
+
* @returns The workflow return value.
|
|
90014
|
+
*/
|
|
90015
|
+
async #pollReturnValue() {
|
|
90016
|
+
const world = await this.#lazyWorldPromise;
|
|
90017
|
+
let notFoundRetries = 0;
|
|
90018
|
+
const NOT_FOUND_MAX_RETRIES = this.#resilientStart ? NOT_FOUND_RETRY_DELAYS2.length : 0;
|
|
90019
|
+
const waitForTerminalStatus = isReturnValueLongPollEnabled2() ? world.runs.waitForTerminalStatus?.bind(world.runs) : void 0;
|
|
90020
|
+
let longPolls = 0;
|
|
90021
|
+
const maxLongPolls = getReturnValueMaxLongPolls2();
|
|
90022
|
+
while (true) {
|
|
90023
|
+
const iterationStartedAt = Date.now();
|
|
90024
|
+
try {
|
|
90025
|
+
const useLongPoll = waitForTerminalStatus && longPolls < maxLongPolls;
|
|
90026
|
+
if (useLongPoll)
|
|
90027
|
+
longPolls++;
|
|
90028
|
+
const runMetadata = useLongPoll ? await waitForTerminalStatus(this.runId, {
|
|
90029
|
+
timeoutMs: getReturnValueWaitTimeoutMs2(),
|
|
90030
|
+
resolveData: "none"
|
|
90031
|
+
}) : await world.runs.get(this.runId, {
|
|
90032
|
+
resolveData: "none"
|
|
90033
|
+
});
|
|
90034
|
+
if (runMetadata.status === "cancelled") {
|
|
90035
|
+
throw new WorkflowRunCancelledError2(this.runId);
|
|
90036
|
+
}
|
|
90037
|
+
if (PAYLOAD_TERMINAL_RUN_STATUSES2.has(runMetadata.status)) {
|
|
90038
|
+
const run3 = await world.runs.get(this.runId, {
|
|
90039
|
+
resolveData: "all"
|
|
90040
|
+
});
|
|
90041
|
+
return await this.#resolveTerminalReturnValue(run3);
|
|
90042
|
+
}
|
|
90043
|
+
throw new WorkflowRunNotCompletedError2(this.runId, runMetadata.status);
|
|
90044
|
+
} catch (error121) {
|
|
90045
|
+
if (WorkflowRunNotCompletedError2.is(error121)) {
|
|
90046
|
+
const remainingIntervalMs = getReturnValuePollIntervalMs2() - (Date.now() - iterationStartedAt);
|
|
90047
|
+
if (remainingIntervalMs > 0) {
|
|
90048
|
+
await new Promise((resolve3) => setTimeout(resolve3, remainingIntervalMs));
|
|
90049
|
+
}
|
|
90050
|
+
continue;
|
|
90051
|
+
}
|
|
90052
|
+
if (WorkflowRunNotFoundError2.is(error121) && notFoundRetries < NOT_FOUND_MAX_RETRIES) {
|
|
90053
|
+
const delay = NOT_FOUND_RETRY_DELAYS2[notFoundRetries];
|
|
90054
|
+
notFoundRetries++;
|
|
90055
|
+
await new Promise((resolve3) => setTimeout(resolve3, delay));
|
|
90056
|
+
continue;
|
|
90057
|
+
}
|
|
90058
|
+
throw error121;
|
|
90059
|
+
}
|
|
90060
|
+
}
|
|
90061
|
+
}
|
|
90062
|
+
};
|
|
90063
|
+
}
|
|
90064
|
+
});
|
|
90065
|
+
|
|
90066
|
+
// ../core/dist/runtime/lifecycle-hooks.js
|
|
90067
|
+
function getRegistry3() {
|
|
90068
|
+
if (!Object.hasOwn(globalThis, REGISTRY_KEY)) {
|
|
90069
|
+
Object.defineProperty(globalThis, REGISTRY_KEY, {
|
|
90070
|
+
value: [],
|
|
90071
|
+
writable: false,
|
|
90072
|
+
enumerable: false,
|
|
90073
|
+
configurable: false
|
|
90074
|
+
});
|
|
90075
|
+
}
|
|
90076
|
+
return globalThis[REGISTRY_KEY];
|
|
90077
|
+
}
|
|
90078
|
+
function dispatch(runId, workflowName, event, prepare, invoke) {
|
|
90079
|
+
const registered = getRegistry3().filter((hooks) => hooks[event]);
|
|
90080
|
+
if (registered.length === 0) {
|
|
90081
|
+
return;
|
|
90082
|
+
}
|
|
90083
|
+
safeWaitUntil2(
|
|
90084
|
+
trace5(`workflow.lifecycle.${event}`, async () => {
|
|
90085
|
+
const params = await prepare();
|
|
90086
|
+
for (const hooks of registered) {
|
|
90087
|
+
try {
|
|
90088
|
+
await invoke(hooks, params);
|
|
90089
|
+
} catch (err) {
|
|
90090
|
+
runtimeLogger2.error(`Workflow lifecycle ${event} handler threw`, {
|
|
90091
|
+
workflowRunId: runId,
|
|
90092
|
+
workflowName,
|
|
90093
|
+
errorName: getErrorName(err),
|
|
90094
|
+
errorMessage: err instanceof Error ? err.message : String(err),
|
|
90095
|
+
errorStack: getErrorStack(err)
|
|
90096
|
+
});
|
|
90097
|
+
}
|
|
90098
|
+
}
|
|
90099
|
+
}),
|
|
90100
|
+
// Covers a `prepare()` rejection; handler failures are caught above.
|
|
90101
|
+
(err) => {
|
|
90102
|
+
runtimeLogger2.error(`Workflow lifecycle ${event} dispatch failed`, {
|
|
90103
|
+
workflowRunId: runId,
|
|
90104
|
+
workflowName,
|
|
90105
|
+
errorName: getErrorName(err),
|
|
90106
|
+
errorMessage: err instanceof Error ? err.message : String(err),
|
|
90107
|
+
errorStack: getErrorStack(err)
|
|
90108
|
+
});
|
|
90109
|
+
}
|
|
90110
|
+
);
|
|
90111
|
+
}
|
|
90112
|
+
function dispatchRunCompletedHooks(runId, workflowName) {
|
|
90113
|
+
dispatch(runId, workflowName, "onRunCompleted", async () => ({ run: new Run2(runId), workflowName }), (hooks, params) => hooks.onRunCompleted?.(params));
|
|
90114
|
+
}
|
|
90115
|
+
async function hydrateForHandlers(error121, runId, encryptionKey) {
|
|
90116
|
+
try {
|
|
90117
|
+
const ops = [];
|
|
90118
|
+
return await hydrateRunError2(error121, runId, encryptionKey, ops, globalThis, getExternalRevivers2(globalThis, ops, runId, encryptionKey, {
|
|
90119
|
+
lazyStreams: true,
|
|
90120
|
+
liveAbortSignals: false
|
|
90121
|
+
}));
|
|
90122
|
+
} catch {
|
|
90123
|
+
return new Error("Failed to hydrate workflow run error");
|
|
90124
|
+
}
|
|
90125
|
+
}
|
|
90126
|
+
function dispatchRunFailedHooks(runId, workflowName, error121, encryptionKey, errorCode) {
|
|
90127
|
+
dispatch(runId, workflowName, "onRunFailed", async () => ({
|
|
90128
|
+
run: new Run2(runId),
|
|
90129
|
+
workflowName,
|
|
90130
|
+
error: new WorkflowRunFailedError2(runId, await hydrateForHandlers(error121, runId, encryptionKey), { errorCode })
|
|
90131
|
+
}), (hooks, params) => hooks.onRunFailed?.(params));
|
|
90132
|
+
}
|
|
90133
|
+
var REGISTRY_KEY;
|
|
90134
|
+
var init_lifecycle_hooks = __esm({
|
|
90135
|
+
"../core/dist/runtime/lifecycle-hooks.js"() {
|
|
90136
|
+
"use strict";
|
|
90137
|
+
init_dist7();
|
|
90138
|
+
init_logger2();
|
|
90139
|
+
init_serialization4();
|
|
90140
|
+
init_telemetry4();
|
|
90141
|
+
init_types4();
|
|
90142
|
+
init_run();
|
|
90143
|
+
init_wait_until2();
|
|
90144
|
+
REGISTRY_KEY = /* @__PURE__ */ Symbol.for("@workflow/core//lifecycleHooks");
|
|
90145
|
+
__name(getRegistry3, "getRegistry");
|
|
90146
|
+
__name(dispatch, "dispatch");
|
|
90147
|
+
__name(dispatchRunCompletedHooks, "dispatchRunCompletedHooks");
|
|
90148
|
+
__name(hydrateForHandlers, "hydrateForHandlers");
|
|
90149
|
+
__name(dispatchRunFailedHooks, "dispatchRunFailedHooks");
|
|
90150
|
+
}
|
|
90151
|
+
});
|
|
90152
|
+
|
|
89076
90153
|
// ../core/dist/runtime/replay-budget.js
|
|
89077
90154
|
async function handleReplayBudgetExhausted(args) {
|
|
89078
90155
|
const { runId, workflowName, requestId, attempt, limitMs, slotSnapshot } = args;
|
|
@@ -89097,14 +90174,17 @@ async function handleReplayBudgetExhausted(args) {
|
|
|
89097
90174
|
});
|
|
89098
90175
|
const getEncryptionKey = memoizeEncryptionKey(world, runId);
|
|
89099
90176
|
const timeoutErr = new FatalError2(`Workflow replay exceeded maximum duration (${limitMs / 1e3}s) after ${attempt} attempts`);
|
|
90177
|
+
const encryptionKey = await getEncryptionKey();
|
|
90178
|
+
const dehydratedError = await dehydrateRunError(timeoutErr, runId, encryptionKey);
|
|
89100
90179
|
await world.events.create(runId, {
|
|
89101
90180
|
eventType: "run_failed",
|
|
89102
90181
|
specVersion: SPEC_VERSION_CURRENT2,
|
|
89103
90182
|
eventData: {
|
|
89104
|
-
error:
|
|
90183
|
+
error: dehydratedError,
|
|
89105
90184
|
errorCode: RUN_ERROR_CODES2.REPLAY_TIMEOUT
|
|
89106
90185
|
}
|
|
89107
90186
|
}, { requestId, ...slotSnapshot });
|
|
90187
|
+
dispatchRunFailedHooks(runId, workflowName, dehydratedError, encryptionKey, RUN_ERROR_CODES2.REPLAY_TIMEOUT);
|
|
89108
90188
|
}
|
|
89109
90189
|
var ReplayBudget, ReplayTimeoutRetryError;
|
|
89110
90190
|
var init_replay_budget = __esm({
|
|
@@ -89117,6 +90197,7 @@ var init_replay_budget = __esm({
|
|
|
89117
90197
|
init_serialization4();
|
|
89118
90198
|
init_constants3();
|
|
89119
90199
|
init_helpers3();
|
|
90200
|
+
init_lifecycle_hooks();
|
|
89120
90201
|
init_world();
|
|
89121
90202
|
ReplayBudget = class {
|
|
89122
90203
|
static {
|
|
@@ -89372,98 +90453,6 @@ var init_run_id_time = __esm({
|
|
|
89372
90453
|
}
|
|
89373
90454
|
});
|
|
89374
90455
|
|
|
89375
|
-
// ../core/dist/types.js
|
|
89376
|
-
import { types as types6 } from "node:util";
|
|
89377
|
-
function getErrorName(v) {
|
|
89378
|
-
if (types6.isNativeError(v)) {
|
|
89379
|
-
return v.name;
|
|
89380
|
-
}
|
|
89381
|
-
return "Error";
|
|
89382
|
-
}
|
|
89383
|
-
function getErrorStack(v) {
|
|
89384
|
-
if (types6.isNativeError(v)) {
|
|
89385
|
-
return v.stack ?? "";
|
|
89386
|
-
}
|
|
89387
|
-
return "";
|
|
89388
|
-
}
|
|
89389
|
-
function isAbortError(value) {
|
|
89390
|
-
return typeof value === "object" && value !== null && "name" in value && value.name === "AbortError" && "message" in value && typeof value.message === "string" && (!("stack" in value) || value.stack === void 0 || typeof value.stack === "string");
|
|
89391
|
-
}
|
|
89392
|
-
function promoteAbortErrorToFatal(value) {
|
|
89393
|
-
if (!isAbortError(value) || FatalError2.is(value)) {
|
|
89394
|
-
return value;
|
|
89395
|
-
}
|
|
89396
|
-
const fatalError = new FatalError2(`Aborted: ${value.message}`);
|
|
89397
|
-
if (value.stack) {
|
|
89398
|
-
fatalError.stack = value.stack;
|
|
89399
|
-
}
|
|
89400
|
-
return fatalError;
|
|
89401
|
-
}
|
|
89402
|
-
function isThenable(value) {
|
|
89403
|
-
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
89404
|
-
}
|
|
89405
|
-
function normalizeSyncError(v) {
|
|
89406
|
-
if (types6.isNativeError(v)) {
|
|
89407
|
-
return {
|
|
89408
|
-
name: v.name,
|
|
89409
|
-
message: v.message,
|
|
89410
|
-
stack: v.stack ?? ""
|
|
89411
|
-
};
|
|
89412
|
-
}
|
|
89413
|
-
if (typeof v === "string") {
|
|
89414
|
-
return {
|
|
89415
|
-
name: "Error",
|
|
89416
|
-
message: v,
|
|
89417
|
-
stack: ""
|
|
89418
|
-
};
|
|
89419
|
-
}
|
|
89420
|
-
try {
|
|
89421
|
-
return {
|
|
89422
|
-
name: "Error",
|
|
89423
|
-
message: JSON.stringify(v),
|
|
89424
|
-
stack: ""
|
|
89425
|
-
};
|
|
89426
|
-
} catch {
|
|
89427
|
-
return {
|
|
89428
|
-
name: "Error",
|
|
89429
|
-
message: String(v),
|
|
89430
|
-
stack: ""
|
|
89431
|
-
};
|
|
89432
|
-
}
|
|
89433
|
-
}
|
|
89434
|
-
async function normalizeUnknownError(value) {
|
|
89435
|
-
if (isThenable(value)) {
|
|
89436
|
-
try {
|
|
89437
|
-
const resolved = await value;
|
|
89438
|
-
const normalized = await normalizeUnknownError(resolved);
|
|
89439
|
-
return {
|
|
89440
|
-
...normalized,
|
|
89441
|
-
message: `Promise rejection: ${normalized.message}`
|
|
89442
|
-
};
|
|
89443
|
-
} catch (rejection) {
|
|
89444
|
-
const normalized = await normalizeUnknownError(rejection);
|
|
89445
|
-
return {
|
|
89446
|
-
...normalized,
|
|
89447
|
-
message: `Promise rejection: ${normalized.message}`
|
|
89448
|
-
};
|
|
89449
|
-
}
|
|
89450
|
-
}
|
|
89451
|
-
return normalizeSyncError(value);
|
|
89452
|
-
}
|
|
89453
|
-
var init_types4 = __esm({
|
|
89454
|
-
"../core/dist/types.js"() {
|
|
89455
|
-
"use strict";
|
|
89456
|
-
init_dist7();
|
|
89457
|
-
__name(getErrorName, "getErrorName");
|
|
89458
|
-
__name(getErrorStack, "getErrorStack");
|
|
89459
|
-
__name(isAbortError, "isAbortError");
|
|
89460
|
-
__name(promoteAbortErrorToFatal, "promoteAbortErrorToFatal");
|
|
89461
|
-
__name(isThenable, "isThenable");
|
|
89462
|
-
__name(normalizeSyncError, "normalizeSyncError");
|
|
89463
|
-
__name(normalizeUnknownError, "normalizeUnknownError");
|
|
89464
|
-
}
|
|
89465
|
-
});
|
|
89466
|
-
|
|
89467
90456
|
// ../core/dist/runtime/get-port-lazy.js
|
|
89468
90457
|
import { createRequire as createRequire3 } from "node:module";
|
|
89469
90458
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
@@ -90481,12 +91470,12 @@ var init_step_single_flight = __esm({
|
|
|
90481
91470
|
|
|
90482
91471
|
// ../core/dist/runtime/wait-continuation.js
|
|
90483
91472
|
function getWaitContinuationDispatch(timeoutSeconds, waitCorrelationId, now2 = Date.now(), attempt = 0) {
|
|
90484
|
-
const
|
|
91473
|
+
const dispatch2 = waitContinuationDispatchForAttemptZero(timeoutSeconds, waitCorrelationId, now2);
|
|
90485
91474
|
if (attempt <= 0)
|
|
90486
|
-
return
|
|
91475
|
+
return dispatch2;
|
|
90487
91476
|
return {
|
|
90488
|
-
delaySeconds:
|
|
90489
|
-
idempotencyKey: `${
|
|
91477
|
+
delaySeconds: dispatch2.delaySeconds,
|
|
91478
|
+
idempotencyKey: `${dispatch2.idempotencyKey}:a${attempt}`
|
|
90490
91479
|
};
|
|
90491
91480
|
}
|
|
90492
91481
|
function waitContinuationDispatchForAttemptZero(timeoutSeconds, waitCorrelationId, now2) {
|
|
@@ -97080,6 +98069,40 @@ async function startQuickJSWorkflow(options) {
|
|
|
97080
98069
|
}
|
|
97081
98070
|
}
|
|
97082
98071
|
serde.installProcessEnv(process.env);
|
|
98072
|
+
const historicalAttributeIds = /* @__PURE__ */ new Set();
|
|
98073
|
+
for (const event of events) {
|
|
98074
|
+
if (event.eventType === "attr_set" && event.correlationId !== void 0) {
|
|
98075
|
+
historicalAttributeIds.add(event.correlationId);
|
|
98076
|
+
}
|
|
98077
|
+
}
|
|
98078
|
+
{
|
|
98079
|
+
const env_5 = { stack: [], error: void 0, hasError: false };
|
|
98080
|
+
try {
|
|
98081
|
+
const validateAttributeWrite = __addDisposableResource3(env_5, vm.newFunction("__validateAttributeWrite", (correlationId, changes, allowReservedAttributes) => {
|
|
98082
|
+
if (historicalAttributeIds.has(correlationId.toString())) {
|
|
98083
|
+
return vm.undefined;
|
|
98084
|
+
}
|
|
98085
|
+
try {
|
|
98086
|
+
validateAttributeEventDataSize2({
|
|
98087
|
+
changes: vm.dump(changes),
|
|
98088
|
+
writer: { type: "workflow" },
|
|
98089
|
+
...allowReservedAttributes.toBoolean() ? { allowReservedAttributes: true } : {}
|
|
98090
|
+
});
|
|
98091
|
+
} catch (err) {
|
|
98092
|
+
if (!(err instanceof AttributeValidationError2))
|
|
98093
|
+
throw err;
|
|
98094
|
+
return vm.newString(err.message);
|
|
98095
|
+
}
|
|
98096
|
+
return vm.undefined;
|
|
98097
|
+
}), false);
|
|
98098
|
+
vm.setProp(vm.global, "__validateAttributeWrite", validateAttributeWrite);
|
|
98099
|
+
} catch (e_5) {
|
|
98100
|
+
env_5.error = e_5;
|
|
98101
|
+
env_5.hasError = true;
|
|
98102
|
+
} finally {
|
|
98103
|
+
__disposeResources3(env_5);
|
|
98104
|
+
}
|
|
98105
|
+
}
|
|
97083
98106
|
if (!baselineSnapshot) {
|
|
97084
98107
|
try {
|
|
97085
98108
|
vm.evalCode(workflowCode2, workflowId || "workflow.js").dispose();
|
|
@@ -97156,8 +98179,11 @@ async function startQuickJSWorkflow(options) {
|
|
|
97156
98179
|
let maxIterations = 100;
|
|
97157
98180
|
let madeProgress;
|
|
97158
98181
|
do {
|
|
97159
|
-
madeProgress = await processEvents(vm, serde, events, advanceClock, options.encryptionKey);
|
|
97160
98182
|
let batch;
|
|
98183
|
+
do {
|
|
98184
|
+
batch = vm.executePendingJobs();
|
|
98185
|
+
} while (batch > 0);
|
|
98186
|
+
madeProgress = await processEvents(vm, serde, events, advanceClock, options.encryptionKey);
|
|
97161
98187
|
do {
|
|
97162
98188
|
batch = vm.executePendingJobs();
|
|
97163
98189
|
if (batch > 0)
|
|
@@ -97171,7 +98197,7 @@ async function startQuickJSWorkflow(options) {
|
|
|
97171
98197
|
});
|
|
97172
98198
|
}
|
|
97173
98199
|
}
|
|
97174
|
-
return makeLiveSession(vm, serde, interruptBudget, advanceClock, options.encryptionKey);
|
|
98200
|
+
return makeLiveSession(vm, serde, interruptBudget, advanceClock, historicalAttributeIds, options.encryptionKey);
|
|
97175
98201
|
}
|
|
97176
98202
|
__name(runWorkflowInVM, "runWorkflowInVM");
|
|
97177
98203
|
}
|
|
@@ -97185,7 +98211,7 @@ function makeSettledSession(result2) {
|
|
|
97185
98211
|
}, "dispose")
|
|
97186
98212
|
};
|
|
97187
98213
|
}
|
|
97188
|
-
function makeLiveSession(vm, serde, interruptBudget, advanceClock, encryptionKey) {
|
|
98214
|
+
function makeLiveSession(vm, serde, interruptBudget, advanceClock, historicalAttributeIds, encryptionKey) {
|
|
97189
98215
|
const result2 = checkWorkflowState(vm, serde, { keepAliveOnSuspend: true });
|
|
97190
98216
|
let alive = !!result2.suspended;
|
|
97191
98217
|
const session = {
|
|
@@ -97195,11 +98221,19 @@ function makeLiveSession(vm, serde, interruptBudget, advanceClock, encryptionKey
|
|
|
97195
98221
|
throw new Error("QuickJS workflow session is not alive \u2014 continueWithEvents is only valid while suspended");
|
|
97196
98222
|
}
|
|
97197
98223
|
interruptBudget.start = Date.now();
|
|
98224
|
+
for (const event of newEvents) {
|
|
98225
|
+
if (event.eventType === "attr_set" && event.correlationId !== void 0) {
|
|
98226
|
+
historicalAttributeIds.add(event.correlationId);
|
|
98227
|
+
}
|
|
98228
|
+
}
|
|
97198
98229
|
let maxIterations = 100;
|
|
97199
98230
|
let madeProgress;
|
|
97200
98231
|
do {
|
|
97201
|
-
madeProgress = await processEvents(vm, serde, newEvents, advanceClock, encryptionKey);
|
|
97202
98232
|
let batch;
|
|
98233
|
+
do {
|
|
98234
|
+
batch = vm.executePendingJobs();
|
|
98235
|
+
} while (batch > 0);
|
|
98236
|
+
madeProgress = await processEvents(vm, serde, newEvents, advanceClock, encryptionKey);
|
|
97203
98237
|
do {
|
|
97204
98238
|
batch = vm.executePendingJobs();
|
|
97205
98239
|
if (batch > 0)
|
|
@@ -97574,9 +98608,9 @@ function ensurePendingByteCache(vm) {
|
|
|
97574
98608
|
return cache;
|
|
97575
98609
|
}
|
|
97576
98610
|
function dumpPendingOps(vm, serde, filterExpr, byteCache) {
|
|
97577
|
-
const
|
|
98611
|
+
const env_6 = { stack: [], error: void 0, hasError: false };
|
|
97578
98612
|
try {
|
|
97579
|
-
const projected = __addDisposableResource3(
|
|
98613
|
+
const projected = __addDisposableResource3(env_6, vm.evalCode(`(function(){
|
|
97580
98614
|
var ops = ${filterExpr};
|
|
97581
98615
|
globalThis.__rawFields = [];
|
|
97582
98616
|
// Settled ops \u2014 created, resolver-less, no abort in flight \u2014 are
|
|
@@ -97615,7 +98649,7 @@ function dumpPendingOps(vm, serde, filterExpr, byteCache) {
|
|
|
97615
98649
|
}
|
|
97616
98650
|
}
|
|
97617
98651
|
}
|
|
97618
|
-
const rawFields = __addDisposableResource3(
|
|
98652
|
+
const rawFields = __addDisposableResource3(env_6, vm.evalCode("globalThis.__rawFields"), false);
|
|
97619
98653
|
for (const op of plainOps) {
|
|
97620
98654
|
const rawIndices = op.__rawIndices ?? {};
|
|
97621
98655
|
delete op.__rawIndices;
|
|
@@ -97626,9 +98660,9 @@ function dumpPendingOps(vm, serde, filterExpr, byteCache) {
|
|
|
97626
98660
|
const cacheKey = `${op.correlationId}:${field}`;
|
|
97627
98661
|
let bytes = byteCache?.get(cacheKey);
|
|
97628
98662
|
if (!bytes) {
|
|
97629
|
-
const
|
|
98663
|
+
const env_7 = { stack: [], error: void 0, hasError: false };
|
|
97630
98664
|
try {
|
|
97631
|
-
const valueHandle = __addDisposableResource3(
|
|
98665
|
+
const valueHandle = __addDisposableResource3(env_7, rawFields.getProp(String(index)), false);
|
|
97632
98666
|
try {
|
|
97633
98667
|
bytes = serde.serialize(valueHandle);
|
|
97634
98668
|
} catch (err) {
|
|
@@ -97640,11 +98674,11 @@ function dumpPendingOps(vm, serde, filterExpr, byteCache) {
|
|
|
97640
98674
|
throw err;
|
|
97641
98675
|
}
|
|
97642
98676
|
byteCache?.set(cacheKey, bytes);
|
|
97643
|
-
} catch (
|
|
97644
|
-
|
|
97645
|
-
|
|
98677
|
+
} catch (e_6) {
|
|
98678
|
+
env_7.error = e_6;
|
|
98679
|
+
env_7.hasError = true;
|
|
97646
98680
|
} finally {
|
|
97647
|
-
__disposeResources3(
|
|
98681
|
+
__disposeResources3(env_7);
|
|
97648
98682
|
}
|
|
97649
98683
|
}
|
|
97650
98684
|
op[field] = bytes;
|
|
@@ -97652,11 +98686,11 @@ function dumpPendingOps(vm, serde, filterExpr, byteCache) {
|
|
|
97652
98686
|
}
|
|
97653
98687
|
vm.evalCode("delete globalThis.__rawFields").dispose();
|
|
97654
98688
|
return plainOps;
|
|
97655
|
-
} catch (
|
|
97656
|
-
|
|
97657
|
-
|
|
98689
|
+
} catch (e_7) {
|
|
98690
|
+
env_6.error = e_7;
|
|
98691
|
+
env_6.hasError = true;
|
|
97658
98692
|
} finally {
|
|
97659
|
-
__disposeResources3(
|
|
98693
|
+
__disposeResources3(env_6);
|
|
97660
98694
|
}
|
|
97661
98695
|
}
|
|
97662
98696
|
function collectDrainOperations(vm, serde) {
|
|
@@ -97694,13 +98728,13 @@ function collectDrainOperations(vm, serde) {
|
|
|
97694
98728
|
}
|
|
97695
98729
|
function checkWorkflowState(vm, serde, opts = {}) {
|
|
97696
98730
|
{
|
|
97697
|
-
const
|
|
98731
|
+
const env_8 = { stack: [], error: void 0, hasError: false };
|
|
97698
98732
|
try {
|
|
97699
|
-
const done = __addDisposableResource3(
|
|
98733
|
+
const done = __addDisposableResource3(env_8, vm.evalCode("globalThis.__workflowDone === true"), false);
|
|
97700
98734
|
if (done.toBoolean()) {
|
|
97701
|
-
const
|
|
98735
|
+
const env_9 = { stack: [], error: void 0, hasError: false };
|
|
97702
98736
|
try {
|
|
97703
|
-
const h = __addDisposableResource3(
|
|
98737
|
+
const h = __addDisposableResource3(env_9, vm.evalCode("globalThis.__workflowResult"), false);
|
|
97704
98738
|
const resultBytes = serde.serialize(h);
|
|
97705
98739
|
const drainOperations = collectDrainOperations(vm, serde);
|
|
97706
98740
|
vm.dispose();
|
|
@@ -97710,42 +98744,42 @@ function checkWorkflowState(vm, serde, opts = {}) {
|
|
|
97710
98744
|
...drainOperations.length > 0 ? { drainOperations } : {}
|
|
97711
98745
|
}
|
|
97712
98746
|
};
|
|
97713
|
-
} catch (
|
|
97714
|
-
|
|
97715
|
-
|
|
98747
|
+
} catch (e_8) {
|
|
98748
|
+
env_9.error = e_8;
|
|
98749
|
+
env_9.hasError = true;
|
|
97716
98750
|
} finally {
|
|
97717
|
-
__disposeResources3(
|
|
98751
|
+
__disposeResources3(env_9);
|
|
97718
98752
|
}
|
|
97719
98753
|
}
|
|
97720
|
-
} catch (
|
|
97721
|
-
|
|
97722
|
-
|
|
98754
|
+
} catch (e_9) {
|
|
98755
|
+
env_8.error = e_9;
|
|
98756
|
+
env_8.hasError = true;
|
|
97723
98757
|
} finally {
|
|
97724
|
-
__disposeResources3(
|
|
98758
|
+
__disposeResources3(env_8);
|
|
97725
98759
|
}
|
|
97726
98760
|
}
|
|
97727
98761
|
{
|
|
97728
|
-
const
|
|
98762
|
+
const env_10 = { stack: [], error: void 0, hasError: false };
|
|
97729
98763
|
try {
|
|
97730
|
-
const h = __addDisposableResource3(
|
|
98764
|
+
const h = __addDisposableResource3(env_10, vm.evalCode("globalThis.__workflowError"), false);
|
|
97731
98765
|
if (!h.isUndefined) {
|
|
97732
98766
|
const errorObj = h.isString ? h.toString() : (() => {
|
|
97733
|
-
const
|
|
98767
|
+
const env_13 = { stack: [], error: void 0, hasError: false };
|
|
97734
98768
|
try {
|
|
97735
|
-
const plain = __addDisposableResource3(
|
|
98769
|
+
const plain = __addDisposableResource3(env_13, vm.evalCode("(function(e){return {message: e.message, stack: e.stack, name: e.name};})(globalThis.__workflowError)"), false);
|
|
97736
98770
|
return vm.dump(plain);
|
|
97737
|
-
} catch (
|
|
97738
|
-
|
|
97739
|
-
|
|
98771
|
+
} catch (e_13) {
|
|
98772
|
+
env_13.error = e_13;
|
|
98773
|
+
env_13.hasError = true;
|
|
97740
98774
|
} finally {
|
|
97741
|
-
__disposeResources3(
|
|
98775
|
+
__disposeResources3(env_13);
|
|
97742
98776
|
}
|
|
97743
98777
|
})();
|
|
97744
98778
|
let valueBytes;
|
|
97745
98779
|
if (!h.isString) {
|
|
97746
|
-
const
|
|
98780
|
+
const env_11 = { stack: [], error: void 0, hasError: false };
|
|
97747
98781
|
try {
|
|
97748
|
-
const rawValue = __addDisposableResource3(
|
|
98782
|
+
const rawValue = __addDisposableResource3(env_11, h.getProp("value"), false);
|
|
97749
98783
|
try {
|
|
97750
98784
|
valueBytes = serde.serialize(rawValue);
|
|
97751
98785
|
} catch (serializeErr) {
|
|
@@ -97753,11 +98787,11 @@ function checkWorkflowState(vm, serde, opts = {}) {
|
|
|
97753
98787
|
message: serializeErr instanceof Error ? serializeErr.message : String(serializeErr)
|
|
97754
98788
|
});
|
|
97755
98789
|
}
|
|
97756
|
-
} catch (
|
|
97757
|
-
|
|
97758
|
-
|
|
98790
|
+
} catch (e_10) {
|
|
98791
|
+
env_11.error = e_10;
|
|
98792
|
+
env_11.hasError = true;
|
|
97759
98793
|
} finally {
|
|
97760
|
-
__disposeResources3(
|
|
98794
|
+
__disposeResources3(env_11);
|
|
97761
98795
|
}
|
|
97762
98796
|
}
|
|
97763
98797
|
const failed = typeof errorObj === "string" ? { message: errorObj } : {
|
|
@@ -97780,17 +98814,17 @@ function checkWorkflowState(vm, serde, opts = {}) {
|
|
|
97780
98814
|
}
|
|
97781
98815
|
};
|
|
97782
98816
|
}
|
|
97783
|
-
} catch (
|
|
97784
|
-
|
|
97785
|
-
|
|
98817
|
+
} catch (e_11) {
|
|
98818
|
+
env_10.error = e_11;
|
|
98819
|
+
env_10.hasError = true;
|
|
97786
98820
|
} finally {
|
|
97787
|
-
__disposeResources3(
|
|
98821
|
+
__disposeResources3(env_10);
|
|
97788
98822
|
}
|
|
97789
98823
|
}
|
|
97790
98824
|
{
|
|
97791
|
-
const
|
|
98825
|
+
const env_12 = { stack: [], error: void 0, hasError: false };
|
|
97792
98826
|
try {
|
|
97793
|
-
const h = __addDisposableResource3(
|
|
98827
|
+
const h = __addDisposableResource3(env_12, vm.evalCode("Object.keys(globalThis.__resolvers).length > 0 || globalThis.__pending.some(function(p){return!p.hasCreatedEvent;})"), false);
|
|
97794
98828
|
if (vm.dump(h)) {
|
|
97795
98829
|
const pendingOps = dumpPendingOps(vm, serde, `globalThis.__pending.filter(function(p){return!!globalThis.__resolvers[p.correlationId] || !p.hasCreatedEvent || p.abortRequested;})`, ensurePendingByteCache(vm));
|
|
97796
98830
|
if (!opts.keepAliveOnSuspend)
|
|
@@ -97801,11 +98835,11 @@ function checkWorkflowState(vm, serde, opts = {}) {
|
|
|
97801
98835
|
}
|
|
97802
98836
|
};
|
|
97803
98837
|
}
|
|
97804
|
-
} catch (
|
|
97805
|
-
|
|
97806
|
-
|
|
98838
|
+
} catch (e_12) {
|
|
98839
|
+
env_12.error = e_12;
|
|
98840
|
+
env_12.hasError = true;
|
|
97807
98841
|
} finally {
|
|
97808
|
-
__disposeResources3(
|
|
98842
|
+
__disposeResources3(env_12);
|
|
97809
98843
|
}
|
|
97810
98844
|
}
|
|
97811
98845
|
vm.dispose();
|
|
@@ -97842,6 +98876,7 @@ var init_quickjs_runtime = __esm({
|
|
|
97842
98876
|
init_dist7();
|
|
97843
98877
|
init_dist5();
|
|
97844
98878
|
init_dist6();
|
|
98879
|
+
init_attributes_validation2();
|
|
97845
98880
|
init_nanoid();
|
|
97846
98881
|
init_dist13();
|
|
97847
98882
|
import_seedrandom2 = __toESM(require_seedrandom2(), 1);
|
|
@@ -98465,18 +99500,28 @@ globalThis[Symbol.for("WORKFLOW_CREATE_HOOK")] = function(options) {
|
|
|
98465
99500
|
};
|
|
98466
99501
|
|
|
98467
99502
|
// setAttributes \u2014 attaches plaintext metadata to the current run.
|
|
98468
|
-
//
|
|
99503
|
+
// Per-change validation happens in library code (normalizeAttributeChanges) before
|
|
98469
99504
|
// this dispatcher is invoked, so "changes" is already normalized. The
|
|
98470
99505
|
// returned promise resolves when the matching attr_set event is
|
|
98471
99506
|
// observed during event processing \u2014 mirroring the node:vm engine's
|
|
98472
99507
|
// createSetAttributes (attribute-dispatcher.ts).
|
|
99508
|
+
// Baseline hydrate placeholder; module-scope calls draw a ULID and disable snapshots.
|
|
99509
|
+
globalThis.__validateAttributeWrite = function() {};
|
|
98473
99510
|
globalThis[Symbol.for("WORKFLOW_SET_ATTRIBUTES")] = function(changes, options) {
|
|
98474
99511
|
var correlationId = "attr_" + globalThis.__generateUlid();
|
|
99512
|
+
var allowReservedAttributes = !!(options && options.allowReservedAttributes);
|
|
99513
|
+
var validationError = globalThis.__validateAttributeWrite(correlationId, changes, allowReservedAttributes);
|
|
99514
|
+
if (validationError !== undefined) {
|
|
99515
|
+
var error = new Error(validationError);
|
|
99516
|
+
error.name = "FatalError";
|
|
99517
|
+
error.fatal = true;
|
|
99518
|
+
return Promise.reject(error);
|
|
99519
|
+
}
|
|
98475
99520
|
globalThis.__pending.push({
|
|
98476
99521
|
type: "attribute",
|
|
98477
99522
|
correlationId: correlationId,
|
|
98478
99523
|
changes: changes,
|
|
98479
|
-
allowReservedAttributes:
|
|
99524
|
+
allowReservedAttributes: allowReservedAttributes,
|
|
98480
99525
|
hasCreatedEvent: false,
|
|
98481
99526
|
});
|
|
98482
99527
|
return new Promise(function(resolve, reject) {
|
|
@@ -99617,6 +100662,7 @@ async function runWorkflowWithQuickJS(params) {
|
|
|
99617
100662
|
}
|
|
99618
100663
|
});
|
|
99619
100664
|
wfdiag("exit_completed", { result: "run_completed_written" });
|
|
100665
|
+
dispatchRunCompletedHooks(runId, workflowName);
|
|
99620
100666
|
} catch (err) {
|
|
99621
100667
|
if (EntityConflictError2.is(err) || RunExpiredError2.is(err)) {
|
|
99622
100668
|
runtimeLogger2.warn("Workflow already finished, skipping run_completed", { workflowRunId: runId });
|
|
@@ -99827,6 +100873,7 @@ async function runWorkflowWithQuickJS(params) {
|
|
|
99827
100873
|
});
|
|
99828
100874
|
throw err;
|
|
99829
100875
|
}
|
|
100876
|
+
dispatchRunFailedHooks(runId, workflowName, dehydratedError, encryptionKey, errorCode);
|
|
99830
100877
|
wfdiag("exit_failed", { result: "run_failed_written" });
|
|
99831
100878
|
}
|
|
99832
100879
|
}
|
|
@@ -99846,6 +100893,7 @@ var init_quickjs_entrypoint = __esm({
|
|
|
99846
100893
|
init_constants3();
|
|
99847
100894
|
init_get_port_lazy();
|
|
99848
100895
|
init_helpers3();
|
|
100896
|
+
init_lifecycle_hooks();
|
|
99849
100897
|
init_quickjs_log_view();
|
|
99850
100898
|
init_quickjs_runtime();
|
|
99851
100899
|
init_replay_budget();
|
|
@@ -125439,6 +126487,13 @@ var init_zod = __esm2({
|
|
|
125439
126487
|
init_external();
|
|
125440
126488
|
}
|
|
125441
126489
|
});
|
|
126490
|
+
function validateAttributeEventDataSize(eventData) {
|
|
126491
|
+
const bytes = textEncoder.encode(JSON.stringify(eventData)).length;
|
|
126492
|
+
if (bytes > ATTRIBUTE_EVENT_DATA_MAX_BYTES) {
|
|
126493
|
+
throw new AttributeValidationError(`Attribute eventData exceeds limit ${ATTRIBUTE_EVENT_DATA_MAX_BYTES} UTF-8 JSON bytes (received ${bytes} bytes). Split the changes into smaller setAttributes() calls.`);
|
|
126494
|
+
}
|
|
126495
|
+
}
|
|
126496
|
+
__name(validateAttributeEventDataSize, "validateAttributeEventDataSize");
|
|
125442
126497
|
function assertValidAttributeKey(key, allowReservedAttributes) {
|
|
125443
126498
|
if (typeof key !== "string") {
|
|
125444
126499
|
throw new AttributeValidationError(`Attribute key must be a string, got ${typeof key}`);
|
|
@@ -125501,6 +126556,7 @@ var RETENTION_ATTRIBUTE;
|
|
|
125501
126556
|
var ATTRIBUTE_KEY_MAX_LENGTH;
|
|
125502
126557
|
var ATTRIBUTE_VALUE_MAX_BYTES;
|
|
125503
126558
|
var ATTRIBUTE_MAX_PER_RUN;
|
|
126559
|
+
var ATTRIBUTE_EVENT_DATA_MAX_BYTES;
|
|
125504
126560
|
var textEncoder;
|
|
125505
126561
|
var AttributeValidationError;
|
|
125506
126562
|
var init_attributes_validation = __esm2({
|
|
@@ -125513,6 +126569,7 @@ var init_attributes_validation = __esm2({
|
|
|
125513
126569
|
ATTRIBUTE_KEY_MAX_LENGTH = 256;
|
|
125514
126570
|
ATTRIBUTE_VALUE_MAX_BYTES = 256;
|
|
125515
126571
|
ATTRIBUTE_MAX_PER_RUN = 64;
|
|
126572
|
+
ATTRIBUTE_EVENT_DATA_MAX_BYTES = 8192;
|
|
125516
126573
|
textEncoder = new TextEncoder();
|
|
125517
126574
|
AttributeValidationError = class extends Error {
|
|
125518
126575
|
static {
|
|
@@ -125526,6 +126583,7 @@ var init_attributes_validation = __esm2({
|
|
|
125526
126583
|
this.name = "AttributeValidationError";
|
|
125527
126584
|
}
|
|
125528
126585
|
};
|
|
126586
|
+
__name2(validateAttributeEventDataSize, "validateAttributeEventDataSize");
|
|
125529
126587
|
__name2(assertValidAttributeKey, "assertValidAttributeKey");
|
|
125530
126588
|
__name2(assertValidAttributeValue, "assertValidAttributeValue");
|
|
125531
126589
|
__name2(attributeCountDelta, "attributeCountDelta");
|
|
@@ -126610,6 +127668,11 @@ var init_queue = __esm2({
|
|
|
126610
127668
|
}));
|
|
126611
127669
|
WorkflowInvokePayloadSchema = external_exports.compile(external_exports.object({
|
|
126612
127670
|
runId: external_exports.string(),
|
|
127671
|
+
/** Process this input and return the handler's result as response data. */
|
|
127672
|
+
invoke: external_exports.literal(true).optional(),
|
|
127673
|
+
/** Identifies one input across retries, separately from the queue delivery ID. */
|
|
127674
|
+
requestId: external_exports.string().optional(),
|
|
127675
|
+
input: external_exports.unknown().optional(),
|
|
126613
127676
|
traceCarrier: TraceCarrierSchema.optional(),
|
|
126614
127677
|
requestedAt: external_exports.coerce.date().optional(),
|
|
126615
127678
|
/**
|
|
@@ -128289,6 +129352,7 @@ function renderStructuredFields(framing, body, metadata) {
|
|
|
128289
129352
|
"errorName",
|
|
128290
129353
|
"errorMessage",
|
|
128291
129354
|
"errorStack",
|
|
129355
|
+
"errorCause",
|
|
128292
129356
|
"hint",
|
|
128293
129357
|
"attempt",
|
|
128294
129358
|
"retryCount"
|
|
@@ -128331,6 +129395,10 @@ function renderStructuredFields(framing, body, metadata) {
|
|
|
128331
129395
|
if (errorMessage && !redundant.has("errorMessage")) {
|
|
128332
129396
|
lines.push(` ${kvKey("error")} ${formatPassthroughValue(errorMessage)}`);
|
|
128333
129397
|
}
|
|
129398
|
+
const errorCause = pickString(metadata, "errorCause");
|
|
129399
|
+
if (errorCause && !body.includes(errorCause)) {
|
|
129400
|
+
lines.push(` ${kvKey("cause")} ${formatPassthroughValue(errorCause)}`);
|
|
129401
|
+
}
|
|
128334
129402
|
const hint22 = pickString(metadata, "hint");
|
|
128335
129403
|
if (hint22) {
|
|
128336
129404
|
lines.push(` ${hint(hint22)}`);
|
|
@@ -133296,7 +134364,7 @@ var version2;
|
|
|
133296
134364
|
var init_version = __esm2({
|
|
133297
134365
|
"../core/dist/version.js"() {
|
|
133298
134366
|
"use strict";
|
|
133299
|
-
version2 = "5.0.0-beta.
|
|
134367
|
+
version2 = "5.0.0-beta.54";
|
|
133300
134368
|
}
|
|
133301
134369
|
});
|
|
133302
134370
|
function getWorkflowQueueName(workflowName, namespace) {
|
|
@@ -133483,6 +134551,37 @@ var init_helpers = __esm2({
|
|
|
133483
134551
|
__name2(healthCheck, "healthCheck");
|
|
133484
134552
|
}
|
|
133485
134553
|
});
|
|
134554
|
+
var HookInvocationSchema;
|
|
134555
|
+
var HookInvocationResultSchema;
|
|
134556
|
+
var init_invocations = __esm2({
|
|
134557
|
+
"../core/dist/runtime/invocations.js"() {
|
|
134558
|
+
"use strict";
|
|
134559
|
+
init_dist2();
|
|
134560
|
+
init_dist4();
|
|
134561
|
+
init_zod();
|
|
134562
|
+
init_semantic_conventions();
|
|
134563
|
+
init_telemetry();
|
|
134564
|
+
HookInvocationSchema = external_exports.object({
|
|
134565
|
+
type: external_exports.literal("hook_resume"),
|
|
134566
|
+
version: external_exports.literal(1),
|
|
134567
|
+
hookId: external_exports.string(),
|
|
134568
|
+
token: external_exports.string(),
|
|
134569
|
+
payload: external_exports.instanceof(Uint8Array)
|
|
134570
|
+
});
|
|
134571
|
+
HookInvocationResultSchema = external_exports.discriminatedUnion("status", [
|
|
134572
|
+
external_exports.object({
|
|
134573
|
+
status: external_exports.literal("accepted")
|
|
134574
|
+
}),
|
|
134575
|
+
external_exports.object({
|
|
134576
|
+
status: external_exports.literal("rejected"),
|
|
134577
|
+
code: external_exports.enum([
|
|
134578
|
+
"HOOK_NOT_FOUND",
|
|
134579
|
+
"INVALID_INPUT"
|
|
134580
|
+
])
|
|
134581
|
+
})
|
|
134582
|
+
]);
|
|
134583
|
+
}
|
|
134584
|
+
});
|
|
133486
134585
|
var require_headers = __commonJS2({
|
|
133487
134586
|
"../../node_modules/.pnpm/@vercel+functions@3.8.0_@aws-sdk+credential-provider-web-identity@3.972.49_ws@8.20.0/node_modules/@vercel/functions/headers.js"(exports, module) {
|
|
133488
134587
|
"use strict";
|
|
@@ -138682,6 +139781,29 @@ async function resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, hookF
|
|
|
138682
139781
|
if (originLink) {
|
|
138683
139782
|
span?.addLink?.(originLink);
|
|
138684
139783
|
}
|
|
139784
|
+
if (world.capabilities?.invoke === true && !v1Compat && dehydratedPayload instanceof Uint8Array) {
|
|
139785
|
+
if (!world.invoke) {
|
|
139786
|
+
throw new WorkflowRuntimeError("World advertises invoke without implementing it");
|
|
139787
|
+
}
|
|
139788
|
+
span?.setAttributes({
|
|
139789
|
+
"workflow.hook.resume_strategy": "invoke"
|
|
139790
|
+
});
|
|
139791
|
+
const result2 = HookInvocationResultSchema.parse(await world.invoke(hook.runId, {
|
|
139792
|
+
type: "hook_resume",
|
|
139793
|
+
version: 1,
|
|
139794
|
+
hookId: hook.hookId,
|
|
139795
|
+
token: hook.token,
|
|
139796
|
+
payload: dehydratedPayload
|
|
139797
|
+
}, {
|
|
139798
|
+
idempotencyKey: generateResumeId()
|
|
139799
|
+
}));
|
|
139800
|
+
if (result2.status === "rejected") {
|
|
139801
|
+
if (result2.code === "HOOK_NOT_FOUND") throw new HookNotFoundError(hook.token);
|
|
139802
|
+
throw new WorkflowRuntimeError("Executor rejected the hook invocation input");
|
|
139803
|
+
}
|
|
139804
|
+
span?.setAttributes(HookResumeCommitted(true));
|
|
139805
|
+
return asLazyMetadataHook(hook);
|
|
139806
|
+
}
|
|
138685
139807
|
const queueName = getWorkflowQueueName(resumeContext.workflowName);
|
|
138686
139808
|
const queueOptions = {
|
|
138687
139809
|
deploymentId: resumeContext.deploymentId,
|
|
@@ -138822,6 +139944,7 @@ var init_resume_hook = __esm2({
|
|
|
138822
139944
|
init_telemetry();
|
|
138823
139945
|
init_get_world_lazy();
|
|
138824
139946
|
init_helpers();
|
|
139947
|
+
init_invocations();
|
|
138825
139948
|
init_wait_until();
|
|
138826
139949
|
generateResumeId = monotonicFactory();
|
|
138827
139950
|
__name2(computeResumePayloadDigest, "computeResumePayloadDigest");
|
|
@@ -139848,6 +140971,14 @@ async function getForwardedWritableEncryptionKey(runId, deploymentId, encryption
|
|
|
139848
140971
|
]) : void 0;
|
|
139849
140972
|
}
|
|
139850
140973
|
__name(getForwardedWritableEncryptionKey, "getForwardedWritableEncryptionKey");
|
|
140974
|
+
function lazyForwardedWritableEncryptionKey(runId, deploymentId, encryptionPublicKey) {
|
|
140975
|
+
let keyPromise;
|
|
140976
|
+
return () => {
|
|
140977
|
+
keyPromise ??= getForwardedWritableEncryptionKey(runId, deploymentId, encryptionPublicKey);
|
|
140978
|
+
return keyPromise;
|
|
140979
|
+
};
|
|
140980
|
+
}
|
|
140981
|
+
__name(lazyForwardedWritableEncryptionKey, "lazyForwardedWritableEncryptionKey");
|
|
139851
140982
|
function tagForwardedWritableTarget(writable, { deploymentId, encryptionPublicKey }) {
|
|
139852
140983
|
if (typeof deploymentId === "string") {
|
|
139853
140984
|
Object.defineProperty(writable, STREAM_SERVER_DEPLOYMENT_ID_SYMBOL, {
|
|
@@ -139887,6 +141018,15 @@ function createForwardedWritable({ global: global2, ops, runId, name, key, deplo
|
|
|
139887
141018
|
}
|
|
139888
141019
|
__name(createForwardedWritable, "createForwardedWritable");
|
|
139889
141020
|
function getRunReadableStream(global2, ops, runId, name, startIndex, cryptoKey) {
|
|
141021
|
+
return getLazyReadableStream((onReadableState) => getExternalRevivers(global2, ops, runId, cryptoKey, {
|
|
141022
|
+
onReadableState
|
|
141023
|
+
}).ReadableStream({
|
|
141024
|
+
name,
|
|
141025
|
+
startIndex
|
|
141026
|
+
}));
|
|
141027
|
+
}
|
|
141028
|
+
__name(getRunReadableStream, "getRunReadableStream");
|
|
141029
|
+
function getLazyReadableStream(reviveReadable, onReadableState) {
|
|
139890
141030
|
let reader;
|
|
139891
141031
|
let lockState;
|
|
139892
141032
|
let lockPollingStarted = false;
|
|
@@ -139896,18 +141036,14 @@ function getRunReadableStream(global2, ops, runId, name, startIndex, cryptoKey)
|
|
|
139896
141036
|
async pull(controller) {
|
|
139897
141037
|
try {
|
|
139898
141038
|
if (!reader) {
|
|
139899
|
-
const stream =
|
|
139900
|
-
|
|
139901
|
-
lockState = state;
|
|
139902
|
-
}, "onReadableState")
|
|
139903
|
-
}).ReadableStream({
|
|
139904
|
-
name,
|
|
139905
|
-
startIndex
|
|
141039
|
+
const stream = reviveReadable((state) => {
|
|
141040
|
+
lockState = state;
|
|
139906
141041
|
});
|
|
139907
141042
|
reader = stream.getReader();
|
|
139908
141043
|
if (lockState && !lockPollingStarted) {
|
|
139909
141044
|
lockPollingStarted = true;
|
|
139910
|
-
|
|
141045
|
+
if (onReadableState) onReadableState(lockState);
|
|
141046
|
+
else pollReadableLock(userReadable, lockState);
|
|
139911
141047
|
}
|
|
139912
141048
|
}
|
|
139913
141049
|
const result2 = await reader.read();
|
|
@@ -139930,8 +141066,47 @@ function getRunReadableStream(global2, ops, runId, name, startIndex, cryptoKey)
|
|
|
139930
141066
|
);
|
|
139931
141067
|
return userReadable;
|
|
139932
141068
|
}
|
|
139933
|
-
__name(
|
|
141069
|
+
__name(getLazyReadableStream, "getLazyReadableStream");
|
|
139934
141070
|
function getExternalRevivers(global2 = globalThis, ops, runId, cryptoKey, options) {
|
|
141071
|
+
function reviveReadableStream(value, onReadableState = options?.onReadableState) {
|
|
141072
|
+
if (value.type === "bytes") {
|
|
141073
|
+
const readable2 = new WorkflowServerReadableStream(runId, value.name, value.startIndex);
|
|
141074
|
+
const state2 = createFlushableState();
|
|
141075
|
+
ops.push(state2.promise);
|
|
141076
|
+
const { readable: userReadable, writable } = value.framing === "framed-v1" ? getByteUnframingStream() : new global2.TransformStream();
|
|
141077
|
+
flushablePipe(readable2, writable, state2).catch(() => {
|
|
141078
|
+
});
|
|
141079
|
+
if (onReadableState) onReadableState(state2);
|
|
141080
|
+
else pollReadableLock(userReadable, state2);
|
|
141081
|
+
return userReadable;
|
|
141082
|
+
}
|
|
141083
|
+
let keyPromise;
|
|
141084
|
+
const resolveKey = /* @__PURE__ */ __name2(() => {
|
|
141085
|
+
keyPromise ??= resolveEncryptionKey(cryptoKey);
|
|
141086
|
+
return keyPromise;
|
|
141087
|
+
}, "resolveKey");
|
|
141088
|
+
const readable = createReconnectingFramedStream(runId, value.name, value.startIndex, resolveKey);
|
|
141089
|
+
const transform22 = getDeserializeStream(getExternalRevivers(global2, ops, runId, resolveKey, {
|
|
141090
|
+
lazyStreams: options?.lazyStreams,
|
|
141091
|
+
liveAbortSignals: options?.liveAbortSignals
|
|
141092
|
+
}), resolveKey);
|
|
141093
|
+
const state = createFlushableState();
|
|
141094
|
+
ops.push(state.promise);
|
|
141095
|
+
flushablePipe(readable, transform22.writable, state).catch(() => {
|
|
141096
|
+
});
|
|
141097
|
+
if (onReadableState) onReadableState(state);
|
|
141098
|
+
else pollReadableLock(transform22.readable, state);
|
|
141099
|
+
return transform22.readable;
|
|
141100
|
+
}
|
|
141101
|
+
__name(reviveReadableStream, "reviveReadableStream");
|
|
141102
|
+
__name2(reviveReadableStream, "reviveReadableStream");
|
|
141103
|
+
function reviveAbortSnapshot(value) {
|
|
141104
|
+
const controller = new AbortController();
|
|
141105
|
+
if (value.aborted) controller.abort(value.reason);
|
|
141106
|
+
return controller;
|
|
141107
|
+
}
|
|
141108
|
+
__name(reviveAbortSnapshot, "reviveAbortSnapshot");
|
|
141109
|
+
__name2(reviveAbortSnapshot, "reviveAbortSnapshot");
|
|
139935
141110
|
return {
|
|
139936
141111
|
...getCommonRevivers2(global2),
|
|
139937
141112
|
// StepFunction should not be returned from workflows to clients
|
|
@@ -139972,36 +141147,11 @@ function getExternalRevivers(global2 = globalThis, ops, runId, cryptoKey, option
|
|
|
139972
141147
|
const response = new global2.Response(bodyInit);
|
|
139973
141148
|
return response.body;
|
|
139974
141149
|
}
|
|
139975
|
-
|
|
139976
|
-
const readable = new WorkflowServerReadableStream(runId, value.name, value.startIndex);
|
|
139977
|
-
const state = createFlushableState();
|
|
139978
|
-
ops.push(state.promise);
|
|
139979
|
-
const { readable: userReadable, writable } = value.framing === "framed-v1" ? getByteUnframingStream() : new global2.TransformStream();
|
|
139980
|
-
flushablePipe(readable, writable, state).catch(() => {
|
|
139981
|
-
});
|
|
139982
|
-
if (options?.onReadableState) options.onReadableState(state);
|
|
139983
|
-
else pollReadableLock(userReadable, state);
|
|
139984
|
-
return userReadable;
|
|
139985
|
-
} else {
|
|
139986
|
-
let keyPromise;
|
|
139987
|
-
const resolveKey = /* @__PURE__ */ __name2(() => {
|
|
139988
|
-
keyPromise ??= resolveEncryptionKey(cryptoKey);
|
|
139989
|
-
return keyPromise;
|
|
139990
|
-
}, "resolveKey");
|
|
139991
|
-
const readable = createReconnectingFramedStream(runId, value.name, value.startIndex, resolveKey);
|
|
139992
|
-
const transform22 = getDeserializeStream(getExternalRevivers(global2, ops, runId, resolveKey), resolveKey);
|
|
139993
|
-
const state = createFlushableState();
|
|
139994
|
-
ops.push(state.promise);
|
|
139995
|
-
flushablePipe(readable, transform22.writable, state).catch(() => {
|
|
139996
|
-
});
|
|
139997
|
-
if (options?.onReadableState) options.onReadableState(state);
|
|
139998
|
-
else pollReadableLock(transform22.readable, state);
|
|
139999
|
-
return transform22.readable;
|
|
140000
|
-
}
|
|
141150
|
+
return options?.lazyStreams ? getLazyReadableStream((onReadableState) => reviveReadableStream(value, onReadableState), options.onReadableState) : reviveReadableStream(value);
|
|
140001
141151
|
}, "ReadableStream"),
|
|
140002
141152
|
WritableStream: /* @__PURE__ */ __name2((value) => {
|
|
140003
141153
|
const targetRunId = typeof value.runId === "string" ? value.runId : runId;
|
|
140004
|
-
const targetKey = targetRunId === runId ? cryptoKey :
|
|
141154
|
+
const targetKey = targetRunId === runId ? cryptoKey : lazyForwardedWritableEncryptionKey(targetRunId, value.deploymentId, value.encryptionPublicKey);
|
|
140005
141155
|
return createForwardedWritable({
|
|
140006
141156
|
global: global2,
|
|
140007
141157
|
ops,
|
|
@@ -140012,8 +141162,8 @@ function getExternalRevivers(global2 = globalThis, ops, runId, cryptoKey, option
|
|
|
140012
141162
|
encryptionPublicKey: value.encryptionPublicKey
|
|
140013
141163
|
});
|
|
140014
141164
|
}, "WritableStream"),
|
|
140015
|
-
AbortController: /* @__PURE__ */ __name2((value) => reviveAbortController(value, ops, runId), "AbortController"),
|
|
140016
|
-
AbortSignal: /* @__PURE__ */ __name2((value) => reviveAbortSignal(value, ops, runId), "AbortSignal")
|
|
141165
|
+
AbortController: /* @__PURE__ */ __name2((value) => options?.liveAbortSignals === false ? reviveAbortSnapshot(value) : reviveAbortController(value, ops, runId), "AbortController"),
|
|
141166
|
+
AbortSignal: /* @__PURE__ */ __name2((value) => options?.liveAbortSignals === false ? reviveAbortSnapshot(value).signal : reviveAbortSignal(value, ops, runId), "AbortSignal")
|
|
140017
141167
|
};
|
|
140018
141168
|
}
|
|
140019
141169
|
__name(getExternalRevivers, "getExternalRevivers");
|
|
@@ -140148,7 +141298,7 @@ function getStepRevivers(global2 = globalThis, ops, runId, cryptoKey, deployment
|
|
|
140148
141298
|
WritableStream: /* @__PURE__ */ __name2((value) => {
|
|
140149
141299
|
const targetRunId = typeof value.runId === "string" ? value.runId : runId;
|
|
140150
141300
|
const targetDeploymentId = typeof value.deploymentId === "string" ? value.deploymentId : targetRunId === runId ? deploymentId : void 0;
|
|
140151
|
-
const targetKey = targetRunId === runId ? cryptoKey :
|
|
141301
|
+
const targetKey = targetRunId === runId ? cryptoKey : lazyForwardedWritableEncryptionKey(targetRunId, targetDeploymentId, value.encryptionPublicKey);
|
|
140152
141302
|
const serialize32 = getSerializeStream(getStepReducers(global2, ops, targetRunId, targetKey), targetKey);
|
|
140153
141303
|
const serverWritable = new WorkflowServerWritableStream(targetRunId, value.name);
|
|
140154
141304
|
const state = createFlushableState();
|
|
@@ -140736,9 +141886,11 @@ var init_serialization2 = __esm2({
|
|
|
140736
141886
|
__name2(reviveAbortSignal, "reviveAbortSignal");
|
|
140737
141887
|
__name2(getCommonRevivers2, "getCommonRevivers");
|
|
140738
141888
|
__name2(getForwardedWritableEncryptionKey, "getForwardedWritableEncryptionKey");
|
|
141889
|
+
__name2(lazyForwardedWritableEncryptionKey, "lazyForwardedWritableEncryptionKey");
|
|
140739
141890
|
__name2(tagForwardedWritableTarget, "tagForwardedWritableTarget");
|
|
140740
141891
|
__name2(createForwardedWritable, "createForwardedWritable");
|
|
140741
141892
|
__name2(getRunReadableStream, "getRunReadableStream");
|
|
141893
|
+
__name2(getLazyReadableStream, "getLazyReadableStream");
|
|
140742
141894
|
__name2(getExternalRevivers, "getExternalRevivers");
|
|
140743
141895
|
__name2(getStepRevivers, "getStepRevivers");
|
|
140744
141896
|
__name2(dehydrateWorkflowArguments, "dehydrateWorkflowArguments");
|
|
@@ -140876,7 +142028,7 @@ init_dist4();
|
|
|
140876
142028
|
init_node();
|
|
140877
142029
|
init_dist2();
|
|
140878
142030
|
init_attributes_validation();
|
|
140879
|
-
function normalizeAttributeChanges(attrs, options = {}) {
|
|
142031
|
+
function normalizeAttributeChanges(attrs, options = {}, writer) {
|
|
140880
142032
|
if (attrs === null || typeof attrs !== "object" || Array.isArray(attrs)) {
|
|
140881
142033
|
throw new FatalError(`setAttributes requires a plain object, got ${attrs === null ? "null" : Array.isArray(attrs) ? "array" : typeof attrs}`);
|
|
140882
142034
|
}
|
|
@@ -140890,6 +142042,15 @@ function normalizeAttributeChanges(attrs, options = {}) {
|
|
|
140890
142042
|
validateAttributeChanges(changes, {
|
|
140891
142043
|
allowReservedAttributes
|
|
140892
142044
|
});
|
|
142045
|
+
if (writer) {
|
|
142046
|
+
validateAttributeEventDataSize({
|
|
142047
|
+
changes,
|
|
142048
|
+
writer,
|
|
142049
|
+
...allowReservedAttributes ? {
|
|
142050
|
+
allowReservedAttributes: true
|
|
142051
|
+
} : {}
|
|
142052
|
+
});
|
|
142053
|
+
}
|
|
140893
142054
|
} catch (err) {
|
|
140894
142055
|
if (err instanceof AttributeValidationError) {
|
|
140895
142056
|
throw new FatalError(err.message);
|
|
@@ -141240,7 +142401,7 @@ __name2(start, "start");
|
|
|
141240
142401
|
value: "start",
|
|
141241
142402
|
configurable: true
|
|
141242
142403
|
});
|
|
141243
|
-
})(start, "step//@workflow/core/runtime/start@5.0.0-beta.
|
|
142404
|
+
})(start, "step//@workflow/core/runtime/start@5.0.0-beta.54//start");
|
|
141244
142405
|
async function wakeUpRun(world, runId, options) {
|
|
141245
142406
|
try {
|
|
141246
142407
|
const run22 = await world.runs.get(runId, {
|
|
@@ -141502,27 +142663,35 @@ var Run = class _Run {
|
|
|
141502
142663
|
* The name of the workflow.
|
|
141503
142664
|
*/
|
|
141504
142665
|
get workflowName() {
|
|
141505
|
-
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId
|
|
142666
|
+
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId, {
|
|
142667
|
+
resolveData: "none"
|
|
142668
|
+
}).then((run22) => run22.workflowName));
|
|
141506
142669
|
}
|
|
141507
142670
|
/**
|
|
141508
142671
|
* The timestamp when the workflow run was created.
|
|
141509
142672
|
*/
|
|
141510
142673
|
get createdAt() {
|
|
141511
|
-
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId
|
|
142674
|
+
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId, {
|
|
142675
|
+
resolveData: "none"
|
|
142676
|
+
}).then((run22) => run22.createdAt));
|
|
141512
142677
|
}
|
|
141513
142678
|
/**
|
|
141514
142679
|
* The timestamp when the workflow run started execution.
|
|
141515
142680
|
* Returns undefined if the workflow has not started yet.
|
|
141516
142681
|
*/
|
|
141517
142682
|
get startedAt() {
|
|
141518
|
-
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId
|
|
142683
|
+
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId, {
|
|
142684
|
+
resolveData: "none"
|
|
142685
|
+
}).then((run22) => run22.startedAt));
|
|
141519
142686
|
}
|
|
141520
142687
|
/**
|
|
141521
142688
|
* The timestamp when the workflow run completed.
|
|
141522
142689
|
* Returns undefined if the workflow has not completed yet.
|
|
141523
142690
|
*/
|
|
141524
142691
|
get completedAt() {
|
|
141525
|
-
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId
|
|
142692
|
+
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId, {
|
|
142693
|
+
resolveData: "none"
|
|
142694
|
+
}).then((run22) => run22.completedAt));
|
|
141526
142695
|
}
|
|
141527
142696
|
/**
|
|
141528
142697
|
* The readable stream of the workflow run.
|
|
@@ -141707,7 +142876,7 @@ var Run = class _Run {
|
|
|
141707
142876
|
value: "wakeUp",
|
|
141708
142877
|
configurable: true
|
|
141709
142878
|
});
|
|
141710
|
-
})(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
142879
|
+
})(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.54//Run#wakeUp");
|
|
141711
142880
|
(function(__wf_fn, __wf_id) {
|
|
141712
142881
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
141713
142882
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -141716,7 +142885,7 @@ var Run = class _Run {
|
|
|
141716
142885
|
value: "cancel",
|
|
141717
142886
|
configurable: true
|
|
141718
142887
|
});
|
|
141719
|
-
})(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
142888
|
+
})(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.54//Run#cancel");
|
|
141720
142889
|
(function(__wf_fn, __wf_id) {
|
|
141721
142890
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
141722
142891
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -141725,7 +142894,7 @@ var Run = class _Run {
|
|
|
141725
142894
|
value: "getReadable",
|
|
141726
142895
|
configurable: true
|
|
141727
142896
|
});
|
|
141728
|
-
})(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
142897
|
+
})(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.54//Run#getReadable");
|
|
141729
142898
|
(function(__wf_fn, __wf_id) {
|
|
141730
142899
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
141731
142900
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -141734,7 +142903,7 @@ var Run = class _Run {
|
|
|
141734
142903
|
value: "getWritable",
|
|
141735
142904
|
configurable: true
|
|
141736
142905
|
});
|
|
141737
|
-
})(Run.prototype["getWritable"], "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
142906
|
+
})(Run.prototype["getWritable"], "step//@workflow/core/runtime/run@5.0.0-beta.54//Run#getWritable");
|
|
141738
142907
|
(function(__wf_fn, __wf_id) {
|
|
141739
142908
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
141740
142909
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -141743,7 +142912,7 @@ var Run = class _Run {
|
|
|
141743
142912
|
value: "exists",
|
|
141744
142913
|
configurable: true
|
|
141745
142914
|
});
|
|
141746
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
142915
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.54//Run#exists");
|
|
141747
142916
|
(function(__wf_fn, __wf_id) {
|
|
141748
142917
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
141749
142918
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -141752,7 +142921,7 @@ var Run = class _Run {
|
|
|
141752
142921
|
value: "status",
|
|
141753
142922
|
configurable: true
|
|
141754
142923
|
});
|
|
141755
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
142924
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.54//Run#status");
|
|
141756
142925
|
(function(__wf_fn, __wf_id) {
|
|
141757
142926
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
141758
142927
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -141761,7 +142930,7 @@ var Run = class _Run {
|
|
|
141761
142930
|
value: "returnValue",
|
|
141762
142931
|
configurable: true
|
|
141763
142932
|
});
|
|
141764
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
142933
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.54//Run#returnValue");
|
|
141765
142934
|
(function(__wf_fn, __wf_id) {
|
|
141766
142935
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
141767
142936
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -141770,7 +142939,7 @@ var Run = class _Run {
|
|
|
141770
142939
|
value: "workflowName",
|
|
141771
142940
|
configurable: true
|
|
141772
142941
|
});
|
|
141773
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
142942
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.54//Run#workflowName");
|
|
141774
142943
|
(function(__wf_fn, __wf_id) {
|
|
141775
142944
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
141776
142945
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -141779,7 +142948,7 @@ var Run = class _Run {
|
|
|
141779
142948
|
value: "createdAt",
|
|
141780
142949
|
configurable: true
|
|
141781
142950
|
});
|
|
141782
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
142951
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.54//Run#createdAt");
|
|
141783
142952
|
(function(__wf_fn, __wf_id) {
|
|
141784
142953
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
141785
142954
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -141788,7 +142957,7 @@ var Run = class _Run {
|
|
|
141788
142957
|
value: "startedAt",
|
|
141789
142958
|
configurable: true
|
|
141790
142959
|
});
|
|
141791
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
142960
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.54//Run#startedAt");
|
|
141792
142961
|
(function(__wf_fn, __wf_id) {
|
|
141793
142962
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
141794
142963
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -141797,7 +142966,7 @@ var Run = class _Run {
|
|
|
141797
142966
|
value: "completedAt",
|
|
141798
142967
|
configurable: true
|
|
141799
142968
|
});
|
|
141800
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
142969
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.54//Run#completedAt");
|
|
141801
142970
|
(function(__wf_cls, __wf_id) {
|
|
141802
142971
|
var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
141803
142972
|
__wf_reg.set(__wf_id, __wf_cls);
|
|
@@ -141807,7 +142976,7 @@ var Run = class _Run {
|
|
|
141807
142976
|
enumerable: false,
|
|
141808
142977
|
configurable: false
|
|
141809
142978
|
});
|
|
141810
|
-
})(Run, "class//@workflow/core/runtime/run@5.0.0-beta.
|
|
142979
|
+
})(Run, "class//@workflow/core/runtime/run@5.0.0-beta.54//Run");
|
|
141811
142980
|
async function fetch2(...args) {
|
|
141812
142981
|
return globalThis.fetch(...args);
|
|
141813
142982
|
}
|
|
@@ -142563,6 +143732,7 @@ init_logger2();
|
|
|
142563
143732
|
init_serialization4();
|
|
142564
143733
|
init_semantic_conventions2();
|
|
142565
143734
|
init_constants3();
|
|
143735
|
+
init_lifecycle_hooks();
|
|
142566
143736
|
var MAX_REROUTE_DELAY_SECONDS = 8;
|
|
142567
143737
|
var CONTINUE = { outcome: "continue" };
|
|
142568
143738
|
function result(outcome, pinnedDeploymentId, attempts) {
|
|
@@ -142576,7 +143746,7 @@ function result(outcome, pinnedDeploymentId, attempts) {
|
|
|
142576
143746
|
};
|
|
142577
143747
|
}
|
|
142578
143748
|
__name(result, "result");
|
|
142579
|
-
async function guardDeploymentAffinity({ world, run: run3, requestId, retryCount = 0, reenqueue, isDeploymentUnavailableError, beforeStop }) {
|
|
143749
|
+
async function guardDeploymentAffinity({ world, run: run3, workflowName, requestId, retryCount = 0, reenqueue, isDeploymentUnavailableError, beforeStop }) {
|
|
142580
143750
|
if (world.capabilities?.deploymentAffinity !== true) {
|
|
142581
143751
|
return CONTINUE;
|
|
142582
143752
|
}
|
|
@@ -142596,17 +143766,16 @@ async function guardDeploymentAffinity({ world, run: run3, requestId, retryCount
|
|
|
142596
143766
|
const failRun = /* @__PURE__ */ __name(async (recoveryAttempts, cause) => {
|
|
142597
143767
|
const error121 = new WorkflowDeploymentMismatchError(run3.runId, run3.deploymentId, currentDeploymentId, { recoveryAttempts, cause });
|
|
142598
143768
|
try {
|
|
143769
|
+
const dehydratedError = await dehydrateRunError(error121, run3.runId, void 0, void 0, (run3.specVersion ?? 0) >= SPEC_VERSION_SUPPORTS_COMPRESSION2);
|
|
142599
143770
|
await world.events.create(run3.runId, {
|
|
142600
143771
|
eventType: "run_failed",
|
|
142601
143772
|
specVersion: SPEC_VERSION_CURRENT2,
|
|
142602
143773
|
eventData: {
|
|
142603
|
-
|
|
142604
|
-
// `guardDeploymentAffinity`. dehydrate/hydrate are self-describing,
|
|
142605
|
-
// so this reads back without a key.
|
|
142606
|
-
error: await dehydrateRunError(error121, run3.runId, void 0, void 0, (run3.specVersion ?? 0) >= SPEC_VERSION_SUPPORTS_COMPRESSION2),
|
|
143774
|
+
error: dehydratedError,
|
|
142607
143775
|
errorCode: RUN_ERROR_CODES2.DEPLOYMENT_MISMATCH
|
|
142608
143776
|
}
|
|
142609
143777
|
}, { requestId });
|
|
143778
|
+
dispatchRunFailedHooks(run3.runId, workflowName, dehydratedError, void 0, RUN_ERROR_CODES2.DEPLOYMENT_MISMATCH);
|
|
142610
143779
|
} catch (failError) {
|
|
142611
143780
|
if (!EntityConflictError2.is(failError) && !RunExpiredError2.is(failError)) {
|
|
142612
143781
|
throw failError;
|
|
@@ -142645,6 +143814,8 @@ __name(guardDeploymentAffinity, "guardDeploymentAffinity");
|
|
|
142645
143814
|
|
|
142646
143815
|
// ../core/dist/runtime.js
|
|
142647
143816
|
init_helpers3();
|
|
143817
|
+
init_invocations2();
|
|
143818
|
+
init_lifecycle_hooks();
|
|
142648
143819
|
init_replay_budget();
|
|
142649
143820
|
init_replay_recovery_reporter();
|
|
142650
143821
|
init_resume_latency();
|
|
@@ -143579,32 +144750,8 @@ function isWorldValidationFailure(err) {
|
|
|
143579
144750
|
}
|
|
143580
144751
|
__name(isWorldValidationFailure, "isWorldValidationFailure");
|
|
143581
144752
|
|
|
143582
|
-
// ../core/dist/runtime/vm-mode.js
|
|
143583
|
-
init_dist7();
|
|
143584
|
-
var WORKFLOW_VMS2 = ["node", "quickjs"];
|
|
143585
|
-
function getWorkflowVmFromEnv2(env = process.env) {
|
|
143586
|
-
const raw = env.WORKFLOW_VM;
|
|
143587
|
-
if (raw === void 0 || raw === "")
|
|
143588
|
-
return void 0;
|
|
143589
|
-
if (WORKFLOW_VMS2.includes(raw)) {
|
|
143590
|
-
return raw;
|
|
143591
|
-
}
|
|
143592
|
-
throw new WorkflowRuntimeError2(`Invalid WORKFLOW_VM value: "${raw}". Expected one of: ${WORKFLOW_VMS2.join(", ")}.`);
|
|
143593
|
-
}
|
|
143594
|
-
__name(getWorkflowVmFromEnv2, "getWorkflowVmFromEnv");
|
|
143595
|
-
function useQuickJSVm(workflowRun) {
|
|
143596
|
-
const vmFromRun = workflowRun.executionContext?.workflowVm;
|
|
143597
|
-
if (vmFromRun !== void 0) {
|
|
143598
|
-
if (!WORKFLOW_VMS2.includes(vmFromRun)) {
|
|
143599
|
-
throw new WorkflowRuntimeError2(`Invalid executionContext.workflowVm value: "${vmFromRun}". Expected one of: ${WORKFLOW_VMS2.join(", ")}.`);
|
|
143600
|
-
}
|
|
143601
|
-
return vmFromRun === "quickjs";
|
|
143602
|
-
}
|
|
143603
|
-
return getWorkflowVmFromEnv2() === "quickjs";
|
|
143604
|
-
}
|
|
143605
|
-
__name(useQuickJSVm, "useQuickJSVm");
|
|
143606
|
-
|
|
143607
144753
|
// ../core/dist/runtime.js
|
|
144754
|
+
init_vm_mode();
|
|
143608
144755
|
init_wait_continuation();
|
|
143609
144756
|
init_world();
|
|
143610
144757
|
init_serialization4();
|
|
@@ -143763,7 +144910,9 @@ function createUseStep(ctx) {
|
|
|
143763
144910
|
if (event.eventType === "step_failed") {
|
|
143764
144911
|
ctx.invocationsQueue.delete(event.correlationId);
|
|
143765
144912
|
const eventIndex = ctx.eventsConsumer.eventIndex;
|
|
143766
|
-
const barrier = registerDeliveryBarrier(ctx, eventIndex, "step"
|
|
144913
|
+
const barrier = registerDeliveryBarrier(ctx, eventIndex, "step", {
|
|
144914
|
+
deliveredAt: +event.createdAt
|
|
144915
|
+
});
|
|
143767
144916
|
let rejection;
|
|
143768
144917
|
const earlierDelivered = awaitEarlierDeliveries(ctx, eventIndex, "step");
|
|
143769
144918
|
ctx.pendingDeliveries++;
|
|
@@ -143792,7 +144941,9 @@ function createUseStep(ctx) {
|
|
|
143792
144941
|
const completedEventId = event.eventId;
|
|
143793
144942
|
const serializedResult = event.eventData.result;
|
|
143794
144943
|
const eventIndex = ctx.eventsConsumer.eventIndex;
|
|
143795
|
-
const barrier = registerDeliveryBarrier(ctx, eventIndex, "step"
|
|
144944
|
+
const barrier = registerDeliveryBarrier(ctx, eventIndex, "step", {
|
|
144945
|
+
deliveredAt: +event.createdAt
|
|
144946
|
+
});
|
|
143796
144947
|
let outcome;
|
|
143797
144948
|
const earlierDelivered = awaitEarlierDeliveries(ctx, eventIndex, "step");
|
|
143798
144949
|
ctx.pendingDeliveries++;
|
|
@@ -144456,12 +145607,26 @@ init_abort_controller2();
|
|
|
144456
145607
|
// ../core/dist/workflow/attribute-dispatcher.js
|
|
144457
145608
|
init_dist7();
|
|
144458
145609
|
init_dist5();
|
|
145610
|
+
init_attributes_validation2();
|
|
144459
145611
|
init_events_consumer2();
|
|
144460
145612
|
init_private2();
|
|
144461
145613
|
function createSetAttributes(ctx) {
|
|
144462
145614
|
return /* @__PURE__ */ __name(async function setAttributes(changes, options = {}) {
|
|
144463
145615
|
const { promise: promise3, resolve: resolve3 } = withResolvers2();
|
|
144464
145616
|
const correlationId = `attr_${ctx.generateUlid()}`;
|
|
145617
|
+
try {
|
|
145618
|
+
validateAttributeEventDataSize2({
|
|
145619
|
+
changes,
|
|
145620
|
+
writer: { type: "workflow" },
|
|
145621
|
+
...options.allowReservedAttributes === true ? { allowReservedAttributes: true } : {}
|
|
145622
|
+
});
|
|
145623
|
+
} catch (error121) {
|
|
145624
|
+
if (!(error121 instanceof AttributeValidationError2))
|
|
145625
|
+
throw error121;
|
|
145626
|
+
const persisted = ctx.eventsConsumer.events.some((event) => event.eventType === "attr_set" && event.correlationId === correlationId);
|
|
145627
|
+
if (!persisted)
|
|
145628
|
+
throw new FatalError2(error121.message);
|
|
145629
|
+
}
|
|
144465
145630
|
const queueItem = {
|
|
144466
145631
|
type: "attribute",
|
|
144467
145632
|
correlationId,
|
|
@@ -144550,6 +145715,26 @@ function createCreateHook(ctx) {
|
|
|
144550
145715
|
let hasConflict = false;
|
|
144551
145716
|
let conflictErrorRef = null;
|
|
144552
145717
|
let conflictRunRef = null;
|
|
145718
|
+
let registrationDelivered = Promise.resolve();
|
|
145719
|
+
function deliverRegistration(deliveredAt, settle) {
|
|
145720
|
+
const eventIndex = ctx.eventsConsumer.eventIndex;
|
|
145721
|
+
const barrier = registerDeliveryBarrier(ctx, eventIndex, "hook", {
|
|
145722
|
+
deliveredAt
|
|
145723
|
+
});
|
|
145724
|
+
const earlierDelivered = awaitEarlierDeliveries(ctx, eventIndex, "hook");
|
|
145725
|
+
registrationDelivered = ctx.promiseQueue.then(() => earlierDelivered).then(() => {
|
|
145726
|
+
barrier.markDelivered();
|
|
145727
|
+
settle();
|
|
145728
|
+
});
|
|
145729
|
+
}
|
|
145730
|
+
__name(deliverRegistration, "deliverRegistration");
|
|
145731
|
+
function afterRegistration(settle) {
|
|
145732
|
+
const delivered = registrationDelivered;
|
|
145733
|
+
ctx.promiseQueue = ctx.promiseQueue.then(() => {
|
|
145734
|
+
void delivered.then(settle);
|
|
145735
|
+
});
|
|
145736
|
+
}
|
|
145737
|
+
__name(afterRegistration, "afterRegistration");
|
|
144553
145738
|
const seenResumeIds = /* @__PURE__ */ new Set();
|
|
144554
145739
|
webhookLogger2.debug("Hook consumer setup", { correlationId, token });
|
|
144555
145740
|
ctx.eventsConsumer.subscribe((event) => {
|
|
@@ -144579,7 +145764,7 @@ function createCreateHook(ctx) {
|
|
|
144579
145764
|
hasCreated = true;
|
|
144580
145765
|
const pendingGetConflictPromises = getConflictPromises.slice();
|
|
144581
145766
|
getConflictPromises.length = 0;
|
|
144582
|
-
|
|
145767
|
+
deliverRegistration(+event.createdAt, () => {
|
|
144583
145768
|
for (const resolver2 of pendingGetConflictPromises) {
|
|
144584
145769
|
resolver2.resolve(null);
|
|
144585
145770
|
}
|
|
@@ -144597,7 +145782,7 @@ function createCreateHook(ctx) {
|
|
|
144597
145782
|
promises.length = 0;
|
|
144598
145783
|
const pendingGetConflictPromises = getConflictPromises.slice();
|
|
144599
145784
|
getConflictPromises.length = 0;
|
|
144600
|
-
|
|
145785
|
+
deliverRegistration(+event.createdAt, () => {
|
|
144601
145786
|
for (const resolver2 of pendingPromises) {
|
|
144602
145787
|
resolver2.reject(conflictError);
|
|
144603
145788
|
}
|
|
@@ -144622,7 +145807,8 @@ function createCreateHook(ctx) {
|
|
|
144622
145807
|
const eventIndex = ctx.eventsConsumer.eventIndex;
|
|
144623
145808
|
const hasWaitingConsumer = promises.length > 0;
|
|
144624
145809
|
const barrier = registerDeliveryBarrier(ctx, eventIndex, "hook", {
|
|
144625
|
-
armed: hasWaitingConsumer
|
|
145810
|
+
armed: hasWaitingConsumer,
|
|
145811
|
+
deliveredAt: +event.createdAt
|
|
144626
145812
|
});
|
|
144627
145813
|
if (hasWaitingConsumer) {
|
|
144628
145814
|
const earlierDelivered = awaitEarlierDeliveries(ctx, eventIndex, "hook");
|
|
@@ -144694,7 +145880,7 @@ function createCreateHook(ctx) {
|
|
|
144694
145880
|
function createHookPromise() {
|
|
144695
145881
|
const resolvers = withResolvers2();
|
|
144696
145882
|
if (hasConflict && conflictErrorRef) {
|
|
144697
|
-
|
|
145883
|
+
afterRegistration(() => {
|
|
144698
145884
|
resolvers.reject(conflictErrorRef);
|
|
144699
145885
|
});
|
|
144700
145886
|
return resolvers.promise;
|
|
@@ -144715,13 +145901,13 @@ function createCreateHook(ctx) {
|
|
|
144715
145901
|
function createGetConflictPromise() {
|
|
144716
145902
|
const resolvers = withResolvers2();
|
|
144717
145903
|
if (hasCreated) {
|
|
144718
|
-
|
|
145904
|
+
afterRegistration(() => {
|
|
144719
145905
|
resolvers.resolve(null);
|
|
144720
145906
|
});
|
|
144721
145907
|
return resolvers.promise;
|
|
144722
145908
|
}
|
|
144723
145909
|
if (hasConflict) {
|
|
144724
|
-
|
|
145910
|
+
afterRegistration(() => {
|
|
144725
145911
|
if (conflictRunRef) {
|
|
144726
145912
|
resolvers.resolve(conflictRunRef);
|
|
144727
145913
|
} else {
|
|
@@ -144837,7 +146023,9 @@ function createSleep(ctx) {
|
|
|
144837
146023
|
}
|
|
144838
146024
|
ctx.invocationsQueue.delete(correlationId);
|
|
144839
146025
|
const eventIndex = ctx.eventsConsumer.eventIndex;
|
|
144840
|
-
const barrier = registerDeliveryBarrier(ctx, eventIndex, "wait"
|
|
146026
|
+
const barrier = registerDeliveryBarrier(ctx, eventIndex, "wait", {
|
|
146027
|
+
deliveredAt: +event.createdAt
|
|
146028
|
+
});
|
|
144841
146029
|
const earlierDelivered = awaitEarlierDeliveries(ctx, eventIndex, "wait");
|
|
144842
146030
|
const queueAtCompletion = ctx.promiseQueue;
|
|
144843
146031
|
void queueAtCompletion.then(() => earlierDelivered).then(() => {
|
|
@@ -145006,14 +146194,13 @@ async function createWorkflowSessionInner({ workflowCode: workflowCode2, workflo
|
|
|
145006
146194
|
const promiseQueueHolder = { current: Promise.resolve() };
|
|
145007
146195
|
const deliveryIdleHolder = { current: /* @__PURE__ */ __name(() => true, "current") };
|
|
145008
146196
|
let clock = fixedTimestamp;
|
|
146197
|
+
const advanceClock = /* @__PURE__ */ __name((at) => {
|
|
146198
|
+
if (at > clock) {
|
|
146199
|
+
clock = at;
|
|
146200
|
+
updateTimestamp(at);
|
|
146201
|
+
}
|
|
146202
|
+
}, "advanceClock");
|
|
145009
146203
|
const eventsConsumer = new EventsConsumer(events, {
|
|
145010
|
-
onConsumedEvent: /* @__PURE__ */ __name((event) => {
|
|
145011
|
-
const at = +event.createdAt;
|
|
145012
|
-
if (at > clock) {
|
|
145013
|
-
clock = at;
|
|
145014
|
-
updateTimestamp(at);
|
|
145015
|
-
}
|
|
145016
|
-
}, "onConsumedEvent"),
|
|
145017
146204
|
onUnconsumedEvent: /* @__PURE__ */ __name((event) => {
|
|
145018
146205
|
onWorkflowError(new ReplayDivergenceError(`Replay could not consume event: eventType=${event.eventType}, correlationId=${event.correlationId}, eventId=${event.eventId}. ${describeDivergenceContext(event, workflowContext.invocationsQueue, eventsConsumer)}`, { eventId: event.eventId }));
|
|
145019
146206
|
}, "onUnconsumedEvent"),
|
|
@@ -145066,6 +146253,7 @@ async function createWorkflowSessionInner({ workflowCode: workflowCode2, workflo
|
|
|
145066
146253
|
pendingDeliveries: 0,
|
|
145067
146254
|
suspensionGeneration: 0,
|
|
145068
146255
|
pendingDeliveryBarriers: /* @__PURE__ */ new Map(),
|
|
146256
|
+
advanceClock,
|
|
145069
146257
|
replayPayloadCache
|
|
145070
146258
|
};
|
|
145071
146259
|
deliveryIdleHolder.current = () => isDeliveryIdle(workflowContext);
|
|
@@ -145600,481 +146788,9 @@ __name(createWorkflowSessionInner, "createWorkflowSessionInner");
|
|
|
145600
146788
|
init_global2();
|
|
145601
146789
|
init_helpers3();
|
|
145602
146790
|
init_resume_hook2();
|
|
145603
|
-
|
|
145604
|
-
|
|
145605
|
-
|
|
145606
|
-
init_dist12();
|
|
145607
|
-
init_env_config2();
|
|
145608
|
-
init_spec_version2();
|
|
145609
|
-
init_encryption5();
|
|
145610
|
-
init_serialization4();
|
|
145611
|
-
init_util5();
|
|
145612
|
-
init_get_world_lazy2();
|
|
145613
|
-
|
|
145614
|
-
// ../core/dist/runtime/runs.js
|
|
145615
|
-
init_dist7();
|
|
145616
|
-
init_dist6();
|
|
145617
|
-
init_encryption5();
|
|
145618
|
-
init_serialization4();
|
|
145619
|
-
init_helpers3();
|
|
145620
|
-
|
|
145621
|
-
// ../core/dist/runtime/start.js
|
|
145622
|
-
init_dist7();
|
|
145623
|
-
init_dist5();
|
|
145624
|
-
init_dist6();
|
|
145625
|
-
init_node2();
|
|
145626
|
-
|
|
145627
|
-
// ../core/dist/attribute-changes.js
|
|
145628
|
-
init_dist7();
|
|
145629
|
-
init_attributes_validation2();
|
|
145630
|
-
|
|
145631
|
-
// ../core/dist/runtime/start.js
|
|
145632
|
-
init_capabilities2();
|
|
145633
|
-
init_classify_error();
|
|
145634
|
-
init_encryption4();
|
|
145635
|
-
init_logger2();
|
|
145636
|
-
init_sealed_box2();
|
|
145637
|
-
init_serialization4();
|
|
145638
|
-
init_context_storage2();
|
|
145639
|
-
init_semantic_conventions2();
|
|
145640
|
-
init_telemetry4();
|
|
145641
|
-
init_version4();
|
|
145642
|
-
init_get_world_lazy2();
|
|
145643
|
-
init_helpers3();
|
|
145644
|
-
init_wait_until2();
|
|
145645
|
-
init_world_compatibility2();
|
|
145646
|
-
var ulid7 = monotonicFactory2();
|
|
145647
|
-
var latestNoOpWarning2 = globalSingleton2("@workflow/core//latestNoOpWarning", 1, () => ({ warned: false }));
|
|
145648
|
-
|
|
145649
|
-
// ../core/dist/runtime/runs.js
|
|
145650
|
-
async function wakeUpRun2(world, runId, options) {
|
|
145651
|
-
try {
|
|
145652
|
-
const run3 = await world.runs.get(runId, { resolveData: "none" });
|
|
145653
|
-
const compatMode = isLegacySpecVersion2(run3.specVersion);
|
|
145654
|
-
const allEvents = [];
|
|
145655
|
-
let cursor = null;
|
|
145656
|
-
do {
|
|
145657
|
-
const eventsResult = await world.events.list({
|
|
145658
|
-
runId,
|
|
145659
|
-
pagination: { sortOrder: "asc", ...cursor ? { cursor } : {} },
|
|
145660
|
-
resolveData: "none"
|
|
145661
|
-
});
|
|
145662
|
-
allEvents.push(...eventsResult.data);
|
|
145663
|
-
cursor = eventsResult.hasMore ? eventsResult.cursor : null;
|
|
145664
|
-
} while (cursor);
|
|
145665
|
-
const waitCreatedEvents = allEvents.filter((event) => event.eventType === "wait_created");
|
|
145666
|
-
const waitCompletedCorrelationIds = new Set(allEvents.filter((event) => event.eventType === "wait_completed").map((event) => event.correlationId));
|
|
145667
|
-
let pendingWaits = waitCreatedEvents.filter((event) => !waitCompletedCorrelationIds.has(event.correlationId));
|
|
145668
|
-
if (options?.correlationIds && options.correlationIds.length > 0) {
|
|
145669
|
-
const targetCorrelationIds = new Set(options.correlationIds);
|
|
145670
|
-
pendingWaits = pendingWaits.filter((event) => event.correlationId && targetCorrelationIds.has(event.correlationId));
|
|
145671
|
-
}
|
|
145672
|
-
const errors = [];
|
|
145673
|
-
let stoppedCount = 0;
|
|
145674
|
-
for (const waitEvent of pendingWaits) {
|
|
145675
|
-
if (!waitEvent.correlationId)
|
|
145676
|
-
continue;
|
|
145677
|
-
const eventData = compatMode ? {
|
|
145678
|
-
eventType: "wait_completed",
|
|
145679
|
-
correlationId: waitEvent.correlationId
|
|
145680
|
-
} : {
|
|
145681
|
-
eventType: "wait_completed",
|
|
145682
|
-
correlationId: waitEvent.correlationId,
|
|
145683
|
-
specVersion: run3.specVersion,
|
|
145684
|
-
eventData: {
|
|
145685
|
-
resumeAt: waitEvent.eventData.resumeAt
|
|
145686
|
-
}
|
|
145687
|
-
};
|
|
145688
|
-
try {
|
|
145689
|
-
await world.events.create(runId, eventData, { v1Compat: compatMode });
|
|
145690
|
-
stoppedCount++;
|
|
145691
|
-
} catch (err) {
|
|
145692
|
-
if (EntityConflictError2.is(err)) {
|
|
145693
|
-
stoppedCount++;
|
|
145694
|
-
} else {
|
|
145695
|
-
errors.push(err instanceof Error ? err : new Error(String(err)));
|
|
145696
|
-
}
|
|
145697
|
-
}
|
|
145698
|
-
}
|
|
145699
|
-
if (stoppedCount > 0) {
|
|
145700
|
-
await world.queue(getWorkflowQueueName2(run3.workflowName, options?.namespace), {
|
|
145701
|
-
runId
|
|
145702
|
-
}, {
|
|
145703
|
-
deploymentId: run3.deploymentId,
|
|
145704
|
-
specVersion: run3.specVersion ?? SPEC_VERSION_LEGACY2
|
|
145705
|
-
});
|
|
145706
|
-
}
|
|
145707
|
-
if (errors.length > 0) {
|
|
145708
|
-
throw new AggregateError(errors, `Failed to complete ${errors.length}/${pendingWaits.length} pending wait(s) for run ${runId}`);
|
|
145709
|
-
}
|
|
145710
|
-
return { stoppedCount };
|
|
145711
|
-
} catch (err) {
|
|
145712
|
-
if (err instanceof AggregateError) {
|
|
145713
|
-
throw err;
|
|
145714
|
-
}
|
|
145715
|
-
throw new Error(`Failed to wake up run ${runId}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
145716
|
-
}
|
|
145717
|
-
}
|
|
145718
|
-
__name(wakeUpRun2, "wakeUpRun");
|
|
145719
|
-
|
|
145720
|
-
// ../core/dist/runtime/run.js
|
|
145721
|
-
var RETURN_VALUE_POLL_INTERVAL_MS2 = 1e3;
|
|
145722
|
-
var PAYLOAD_TERMINAL_RUN_STATUSES2 = /* @__PURE__ */ new Set([
|
|
145723
|
-
"completed",
|
|
145724
|
-
"failed"
|
|
145725
|
-
]);
|
|
145726
|
-
var NOT_FOUND_RETRY_DELAYS2 = [1e3, 3e3, 6e3];
|
|
145727
|
-
function getReturnValuePollIntervalMs2() {
|
|
145728
|
-
return envNumber2("WORKFLOW_RETURN_VALUE_POLL_INTERVAL_MS", RETURN_VALUE_POLL_INTERVAL_MS2, { integer: true, min: 1 });
|
|
145729
|
-
}
|
|
145730
|
-
__name(getReturnValuePollIntervalMs2, "getReturnValuePollIntervalMs");
|
|
145731
|
-
var RETURN_VALUE_WAIT_TIMEOUT_MS2 = 5e4;
|
|
145732
|
-
function getReturnValueWaitTimeoutMs2() {
|
|
145733
|
-
return envNumber2("WORKFLOW_RETURN_VALUE_WAIT_MS", RETURN_VALUE_WAIT_TIMEOUT_MS2, { integer: true, min: 1 });
|
|
145734
|
-
}
|
|
145735
|
-
__name(getReturnValueWaitTimeoutMs2, "getReturnValueWaitTimeoutMs");
|
|
145736
|
-
var RETURN_VALUE_MAX_LONG_POLLS2 = 10;
|
|
145737
|
-
function getReturnValueMaxLongPolls2() {
|
|
145738
|
-
return envNumber2("WORKFLOW_RETURN_VALUE_MAX_LONG_POLLS", RETURN_VALUE_MAX_LONG_POLLS2, { integer: true, min: 1 });
|
|
145739
|
-
}
|
|
145740
|
-
__name(getReturnValueMaxLongPolls2, "getReturnValueMaxLongPolls");
|
|
145741
|
-
function isReturnValueLongPollEnabled2() {
|
|
145742
|
-
const raw = process.env.WORKFLOW_RETURN_VALUE_LONG_POLL;
|
|
145743
|
-
if (raw === void 0 || raw === "")
|
|
145744
|
-
return true;
|
|
145745
|
-
return !(raw === "0" || raw.toLowerCase() === "false");
|
|
145746
|
-
}
|
|
145747
|
-
__name(isReturnValueLongPollEnabled2, "isReturnValueLongPollEnabled");
|
|
145748
|
-
var Run2 = class _Run2 {
|
|
145749
|
-
static {
|
|
145750
|
-
__name(this, "Run");
|
|
145751
|
-
}
|
|
145752
|
-
static [WORKFLOW_SERIALIZE2](instance) {
|
|
145753
|
-
return { runId: instance.runId, resilientStart: instance.#resilientStart };
|
|
145754
|
-
}
|
|
145755
|
-
static [WORKFLOW_DESERIALIZE2](data) {
|
|
145756
|
-
return new _Run2(data.runId, { resilientStart: data.resilientStart });
|
|
145757
|
-
}
|
|
145758
|
-
/**
|
|
145759
|
-
* The ID of the workflow run.
|
|
145760
|
-
*/
|
|
145761
|
-
runId;
|
|
145762
|
-
/**
|
|
145763
|
-
* The world object.
|
|
145764
|
-
* @internal
|
|
145765
|
-
*/
|
|
145766
|
-
#worldPromise;
|
|
145767
|
-
get #lazyWorldPromise() {
|
|
145768
|
-
if (!this.#worldPromise)
|
|
145769
|
-
this.#worldPromise = getWorldLazy2();
|
|
145770
|
-
return this.#worldPromise;
|
|
145771
|
-
}
|
|
145772
|
-
/**
|
|
145773
|
-
* Cached encryption key resolution. Resolved once on first use and
|
|
145774
|
-
* reused for returnValue, getReadable(), etc.
|
|
145775
|
-
* @internal
|
|
145776
|
-
*/
|
|
145777
|
-
#encryptionKeyPromise = null;
|
|
145778
|
-
/**
|
|
145779
|
-
* When true, run_created failed and the run may not exist yet (the
|
|
145780
|
-
* resilient start path will create it via run_started). pollReturnValue
|
|
145781
|
-
* retries on WorkflowRunNotFoundError only when this flag is set so
|
|
145782
|
-
* that normal runs fail fast on 404.
|
|
145783
|
-
* @internal
|
|
145784
|
-
*/
|
|
145785
|
-
#resilientStart = false;
|
|
145786
|
-
constructor(runId, opts) {
|
|
145787
|
-
this.runId = runId;
|
|
145788
|
-
this.#resilientStart = opts?.resilientStart ?? false;
|
|
145789
|
-
}
|
|
145790
|
-
/**
|
|
145791
|
-
* Resolves and caches the encryption key for this run.
|
|
145792
|
-
* The key is the same for the lifetime of a run, so it only needs
|
|
145793
|
-
* to be resolved once.
|
|
145794
|
-
* @internal
|
|
145795
|
-
*/
|
|
145796
|
-
#getEncryptionKey(run3) {
|
|
145797
|
-
if (!this.#encryptionKeyPromise) {
|
|
145798
|
-
this.#encryptionKeyPromise = (async () => {
|
|
145799
|
-
const world = await this.#lazyWorldPromise;
|
|
145800
|
-
const runData = run3 ?? await world.runs.get(this.runId);
|
|
145801
|
-
const rawKey = await world.getEncryptionKeyForRun?.(runData);
|
|
145802
|
-
return rawKey ? await deriveRunPayloadKeys2(rawKey) : void 0;
|
|
145803
|
-
})();
|
|
145804
|
-
}
|
|
145805
|
-
return this.#encryptionKeyPromise;
|
|
145806
|
-
}
|
|
145807
|
-
/**
|
|
145808
|
-
* Defers fetching the run and its encryption key until a readable is first
|
|
145809
|
-
* consumed. The first pull prefetches it so an encrypted first frame can join
|
|
145810
|
-
* the lookup; this also applies to an empty consumed stream.
|
|
145811
|
-
* @internal
|
|
145812
|
-
*/
|
|
145813
|
-
#getEncryptionKeyLazily() {
|
|
145814
|
-
return () => this.#getEncryptionKey();
|
|
145815
|
-
}
|
|
145816
|
-
/**
|
|
145817
|
-
* Interrupts pending `sleep()` calls, resuming the workflow early.
|
|
145818
|
-
*
|
|
145819
|
-
* @param options - Optional settings to target specific sleep calls by correlation ID.
|
|
145820
|
-
* If not provided, all pending sleep calls will be interrupted.
|
|
145821
|
-
* @returns A {@link StopSleepResult} object containing the number of sleep calls that were interrupted.
|
|
145822
|
-
*/
|
|
145823
|
-
async wakeUp(options) {
|
|
145824
|
-
"use step";
|
|
145825
|
-
return wakeUpRun2(await this.#lazyWorldPromise, this.runId, options);
|
|
145826
|
-
}
|
|
145827
|
-
/**
|
|
145828
|
-
* Cancels the workflow run.
|
|
145829
|
-
*
|
|
145830
|
-
* @param options - Optional cancellation settings. `cancelReason` records a
|
|
145831
|
-
* free-text reason (max 512 chars) on the run_cancelled event, surfaced in
|
|
145832
|
-
* the run detail view.
|
|
145833
|
-
*/
|
|
145834
|
-
async cancel(options) {
|
|
145835
|
-
"use step";
|
|
145836
|
-
const world = await this.#lazyWorldPromise;
|
|
145837
|
-
await world.events.create(this.runId, {
|
|
145838
|
-
eventType: "run_cancelled",
|
|
145839
|
-
specVersion: SPEC_VERSION_CURRENT2,
|
|
145840
|
-
...options?.cancelReason !== void 0 ? { eventData: { cancelReason: options.cancelReason } } : {}
|
|
145841
|
-
});
|
|
145842
|
-
}
|
|
145843
|
-
/**
|
|
145844
|
-
* Whether the workflow run exists.
|
|
145845
|
-
*/
|
|
145846
|
-
get exists() {
|
|
145847
|
-
"use step";
|
|
145848
|
-
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId, { resolveData: "none" }).then(() => true).catch((error121) => {
|
|
145849
|
-
if (WorkflowRunNotFoundError2.is(error121)) {
|
|
145850
|
-
return false;
|
|
145851
|
-
}
|
|
145852
|
-
throw error121;
|
|
145853
|
-
}));
|
|
145854
|
-
}
|
|
145855
|
-
/**
|
|
145856
|
-
* The status of the workflow run.
|
|
145857
|
-
*/
|
|
145858
|
-
get status() {
|
|
145859
|
-
"use step";
|
|
145860
|
-
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId, { resolveData: "none" }).then((run3) => run3.status));
|
|
145861
|
-
}
|
|
145862
|
-
/**
|
|
145863
|
-
* The return value of the workflow run.
|
|
145864
|
-
* Polls the workflow return value until the workflow run completes.
|
|
145865
|
-
*/
|
|
145866
|
-
get returnValue() {
|
|
145867
|
-
"use step";
|
|
145868
|
-
return this.#pollReturnValue();
|
|
145869
|
-
}
|
|
145870
|
-
/**
|
|
145871
|
-
* The name of the workflow.
|
|
145872
|
-
*/
|
|
145873
|
-
get workflowName() {
|
|
145874
|
-
"use step";
|
|
145875
|
-
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId).then((run3) => run3.workflowName));
|
|
145876
|
-
}
|
|
145877
|
-
/**
|
|
145878
|
-
* The timestamp when the workflow run was created.
|
|
145879
|
-
*/
|
|
145880
|
-
get createdAt() {
|
|
145881
|
-
"use step";
|
|
145882
|
-
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId).then((run3) => run3.createdAt));
|
|
145883
|
-
}
|
|
145884
|
-
/**
|
|
145885
|
-
* The timestamp when the workflow run started execution.
|
|
145886
|
-
* Returns undefined if the workflow has not started yet.
|
|
145887
|
-
*/
|
|
145888
|
-
get startedAt() {
|
|
145889
|
-
"use step";
|
|
145890
|
-
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId).then((run3) => run3.startedAt));
|
|
145891
|
-
}
|
|
145892
|
-
/**
|
|
145893
|
-
* The timestamp when the workflow run completed.
|
|
145894
|
-
* Returns undefined if the workflow has not completed yet.
|
|
145895
|
-
*/
|
|
145896
|
-
get completedAt() {
|
|
145897
|
-
"use step";
|
|
145898
|
-
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId).then((run3) => run3.completedAt));
|
|
145899
|
-
}
|
|
145900
|
-
/**
|
|
145901
|
-
* The readable stream of the workflow run.
|
|
145902
|
-
*/
|
|
145903
|
-
get readable() {
|
|
145904
|
-
return this.getReadable();
|
|
145905
|
-
}
|
|
145906
|
-
/**
|
|
145907
|
-
* Retrieves the workflow run's default readable stream, which reads chunks
|
|
145908
|
-
* written to the corresponding writable stream {@link getWritable}.
|
|
145909
|
-
*
|
|
145910
|
-
* The returned stream has an additional {@link WorkflowReadableStream.getTailIndex | getTailIndex()}
|
|
145911
|
-
* helper that returns the index of the last known chunk. This is useful when
|
|
145912
|
-
* building reconnection endpoints that need to inform clients where the
|
|
145913
|
-
* stream starts.
|
|
145914
|
-
*
|
|
145915
|
-
* @param options - The options for the readable stream.
|
|
145916
|
-
* @returns A `WorkflowReadableStream` for the workflow run.
|
|
145917
|
-
*/
|
|
145918
|
-
getReadable(options = {}) {
|
|
145919
|
-
"use step";
|
|
145920
|
-
const { ops = [], global: global2 = globalThis, startIndex, namespace } = options;
|
|
145921
|
-
const name = getWorkflowRunStreamId2(this.runId, namespace);
|
|
145922
|
-
const encryptionKey = this.#getEncryptionKeyLazily();
|
|
145923
|
-
const stream = getRunReadableStream2(global2, ops, this.runId, name, startIndex, encryptionKey);
|
|
145924
|
-
const worldPromise = this.#lazyWorldPromise;
|
|
145925
|
-
const runId = this.runId;
|
|
145926
|
-
return Object.assign(stream, {
|
|
145927
|
-
getTailIndex: /* @__PURE__ */ __name(async () => {
|
|
145928
|
-
const world = await worldPromise;
|
|
145929
|
-
const info = await world.streams.getInfo(runId, name);
|
|
145930
|
-
return info.tailIndex;
|
|
145931
|
-
}, "getTailIndex")
|
|
145932
|
-
});
|
|
145933
|
-
}
|
|
145934
|
-
/** The writable stream of the workflow run. */
|
|
145935
|
-
get writable() {
|
|
145936
|
-
return this.getWritable();
|
|
145937
|
-
}
|
|
145938
|
-
/**
|
|
145939
|
-
* Returns a writable that appends to this run's stream.
|
|
145940
|
-
*
|
|
145941
|
-
* Initialization is deferred until the first write. The run must already
|
|
145942
|
-
* exist. The writable may be forwarded through `start()` and into steps, but
|
|
145943
|
-
* grants no read access or additional authorization.
|
|
145944
|
-
*
|
|
145945
|
-
* @remarks
|
|
145946
|
-
* `writer.close()` closes the shared stream. Contributors should call
|
|
145947
|
-
* `releaseLock()`, which also drains pending writes.
|
|
145948
|
-
*
|
|
145949
|
-
* @param options - The writable stream options.
|
|
145950
|
-
*/
|
|
145951
|
-
getWritable(options = {}) {
|
|
145952
|
-
"use step";
|
|
145953
|
-
const { ops = [], global: global2 = globalThis, namespace } = options;
|
|
145954
|
-
const name = getWorkflowRunStreamId2(this.runId, namespace);
|
|
145955
|
-
let targetPromise;
|
|
145956
|
-
let writable;
|
|
145957
|
-
const resolveTarget = /* @__PURE__ */ __name(() => {
|
|
145958
|
-
targetPromise ??= this.#getMetadata().then(async (run3) => {
|
|
145959
|
-
const target2 = {
|
|
145960
|
-
key: await getForwardedWritableEncryptionKey2(this.runId, run3.deploymentId, run3.encryptionPublicKey),
|
|
145961
|
-
deploymentId: run3.deploymentId,
|
|
145962
|
-
encryptionPublicKey: run3.encryptionPublicKey
|
|
145963
|
-
};
|
|
145964
|
-
tagForwardedWritableTarget2(writable, target2);
|
|
145965
|
-
return target2;
|
|
145966
|
-
});
|
|
145967
|
-
return targetPromise;
|
|
145968
|
-
}, "resolveTarget");
|
|
145969
|
-
writable = createForwardedWritable2({
|
|
145970
|
-
global: global2,
|
|
145971
|
-
ops,
|
|
145972
|
-
runId: this.runId,
|
|
145973
|
-
name,
|
|
145974
|
-
key: /* @__PURE__ */ __name(() => resolveTarget().then(({ key }) => key), "key")
|
|
145975
|
-
});
|
|
145976
|
-
return writable;
|
|
145977
|
-
}
|
|
145978
|
-
/** Reads metadata, briefly retrying resilient starts. @internal */
|
|
145979
|
-
async #getMetadata() {
|
|
145980
|
-
const world = await this.#lazyWorldPromise;
|
|
145981
|
-
const maxRetries = this.#resilientStart ? NOT_FOUND_RETRY_DELAYS2.length : 0;
|
|
145982
|
-
let attempt = 0;
|
|
145983
|
-
while (true) {
|
|
145984
|
-
try {
|
|
145985
|
-
return await world.runs.get(this.runId, { resolveData: "none" });
|
|
145986
|
-
} catch (error121) {
|
|
145987
|
-
if (!WorkflowRunNotFoundError2.is(error121) || attempt >= maxRetries) {
|
|
145988
|
-
throw error121;
|
|
145989
|
-
}
|
|
145990
|
-
const delay = NOT_FOUND_RETRY_DELAYS2[attempt];
|
|
145991
|
-
attempt++;
|
|
145992
|
-
await new Promise((resolve3) => setTimeout(resolve3, delay));
|
|
145993
|
-
}
|
|
145994
|
-
}
|
|
145995
|
-
}
|
|
145996
|
-
/** @internal */
|
|
145997
|
-
async #resolveTerminalReturnValue(run3) {
|
|
145998
|
-
const expiredAt = run3.expiredAt;
|
|
145999
|
-
if (expiredAt != null && expiredAt <= /* @__PURE__ */ new Date()) {
|
|
146000
|
-
throw new RunExpiredError2(`Run "${this.runId}" ${run3.status === "completed" ? "completed" : `is ${run3.status}`}, but its data expired at ${expiredAt.toISOString()} and is no longer readable.`, this.runId, run3.status, expiredAt);
|
|
146001
|
-
}
|
|
146002
|
-
if (run3.status === "completed") {
|
|
146003
|
-
const encryptionKey = await this.#getEncryptionKey(run3);
|
|
146004
|
-
return await hydrateWorkflowReturnValue2(run3.output, this.runId, encryptionKey);
|
|
146005
|
-
}
|
|
146006
|
-
if (run3.status === "cancelled") {
|
|
146007
|
-
throw new WorkflowRunCancelledError2(this.runId);
|
|
146008
|
-
}
|
|
146009
|
-
if (run3.status === "failed") {
|
|
146010
|
-
const encryptionKey = await this.#getEncryptionKey(run3);
|
|
146011
|
-
let hydratedError;
|
|
146012
|
-
try {
|
|
146013
|
-
hydratedError = await hydrateRunError2(run3.error, this.runId, encryptionKey);
|
|
146014
|
-
} catch {
|
|
146015
|
-
hydratedError = new Error("Failed to hydrate workflow run error");
|
|
146016
|
-
}
|
|
146017
|
-
throw new WorkflowRunFailedError2(this.runId, hydratedError, {
|
|
146018
|
-
errorCode: run3.errorCode
|
|
146019
|
-
});
|
|
146020
|
-
}
|
|
146021
|
-
throw new WorkflowRunNotCompletedError2(this.runId, run3.status);
|
|
146022
|
-
}
|
|
146023
|
-
/**
|
|
146024
|
-
* Polls the workflow return value until the workflow run completes.
|
|
146025
|
-
* @internal
|
|
146026
|
-
* @returns The workflow return value.
|
|
146027
|
-
*/
|
|
146028
|
-
async #pollReturnValue() {
|
|
146029
|
-
const world = await this.#lazyWorldPromise;
|
|
146030
|
-
let notFoundRetries = 0;
|
|
146031
|
-
const NOT_FOUND_MAX_RETRIES = this.#resilientStart ? NOT_FOUND_RETRY_DELAYS2.length : 0;
|
|
146032
|
-
const waitForTerminalStatus = isReturnValueLongPollEnabled2() ? world.runs.waitForTerminalStatus?.bind(world.runs) : void 0;
|
|
146033
|
-
let longPolls = 0;
|
|
146034
|
-
const maxLongPolls = getReturnValueMaxLongPolls2();
|
|
146035
|
-
while (true) {
|
|
146036
|
-
const iterationStartedAt = Date.now();
|
|
146037
|
-
try {
|
|
146038
|
-
const useLongPoll = waitForTerminalStatus && longPolls < maxLongPolls;
|
|
146039
|
-
if (useLongPoll)
|
|
146040
|
-
longPolls++;
|
|
146041
|
-
const runMetadata = useLongPoll ? await waitForTerminalStatus(this.runId, {
|
|
146042
|
-
timeoutMs: getReturnValueWaitTimeoutMs2(),
|
|
146043
|
-
resolveData: "none"
|
|
146044
|
-
}) : await world.runs.get(this.runId, {
|
|
146045
|
-
resolveData: "none"
|
|
146046
|
-
});
|
|
146047
|
-
if (runMetadata.status === "cancelled") {
|
|
146048
|
-
throw new WorkflowRunCancelledError2(this.runId);
|
|
146049
|
-
}
|
|
146050
|
-
if (PAYLOAD_TERMINAL_RUN_STATUSES2.has(runMetadata.status)) {
|
|
146051
|
-
const run3 = await world.runs.get(this.runId, {
|
|
146052
|
-
resolveData: "all"
|
|
146053
|
-
});
|
|
146054
|
-
return await this.#resolveTerminalReturnValue(run3);
|
|
146055
|
-
}
|
|
146056
|
-
throw new WorkflowRunNotCompletedError2(this.runId, runMetadata.status);
|
|
146057
|
-
} catch (error121) {
|
|
146058
|
-
if (WorkflowRunNotCompletedError2.is(error121)) {
|
|
146059
|
-
const remainingIntervalMs = getReturnValuePollIntervalMs2() - (Date.now() - iterationStartedAt);
|
|
146060
|
-
if (remainingIntervalMs > 0) {
|
|
146061
|
-
await new Promise((resolve3) => setTimeout(resolve3, remainingIntervalMs));
|
|
146062
|
-
}
|
|
146063
|
-
continue;
|
|
146064
|
-
}
|
|
146065
|
-
if (WorkflowRunNotFoundError2.is(error121) && notFoundRetries < NOT_FOUND_MAX_RETRIES) {
|
|
146066
|
-
const delay = NOT_FOUND_RETRY_DELAYS2[notFoundRetries];
|
|
146067
|
-
notFoundRetries++;
|
|
146068
|
-
await new Promise((resolve3) => setTimeout(resolve3, delay));
|
|
146069
|
-
continue;
|
|
146070
|
-
}
|
|
146071
|
-
throw error121;
|
|
146072
|
-
}
|
|
146073
|
-
}
|
|
146074
|
-
}
|
|
146075
|
-
};
|
|
146076
|
-
|
|
146077
|
-
// ../core/dist/runtime.js
|
|
146791
|
+
init_run();
|
|
146792
|
+
init_runs4();
|
|
146793
|
+
init_start();
|
|
146078
146794
|
init_world();
|
|
146079
146795
|
function clampMaxEvents(serverValue) {
|
|
146080
146796
|
const override = getMaxEventsOverride();
|
|
@@ -146138,19 +146854,23 @@ function isStepMissingError(err) {
|
|
|
146138
146854
|
return /step/i.test(err.message) && /not found/i.test(err.message);
|
|
146139
146855
|
}
|
|
146140
146856
|
__name(isStepMissingError, "isStepMissingError");
|
|
146141
|
-
async function recordFatalRunError({ world, workflowRun, runId, requestId, err, errorCode, logMessage }) {
|
|
146857
|
+
async function recordFatalRunError({ world, workflowRun, runId, workflowName, requestId, err, errorCode, logMessage }) {
|
|
146142
146858
|
runtimeLogger2.error(logMessage, {
|
|
146143
146859
|
workflowRunId: runId,
|
|
146144
146860
|
errorCode,
|
|
146145
146861
|
error: err instanceof Error ? err.message : String(err)
|
|
146146
146862
|
});
|
|
146863
|
+
let encryptionKey;
|
|
146864
|
+
let dehydratedError;
|
|
146147
146865
|
try {
|
|
146148
146866
|
const getEncryptionKey = memoizeEncryptionKey(world, workflowRun ?? runId);
|
|
146867
|
+
encryptionKey = await getEncryptionKey();
|
|
146868
|
+
dehydratedError = await dehydrateRunError(err, runId, encryptionKey, globalThis, (workflowRun?.specVersion ?? 0) >= SPEC_VERSION_SUPPORTS_COMPRESSION2);
|
|
146149
146869
|
await world.events.create(runId, {
|
|
146150
146870
|
eventType: "run_failed",
|
|
146151
146871
|
specVersion: SPEC_VERSION_CURRENT2,
|
|
146152
146872
|
eventData: {
|
|
146153
|
-
error:
|
|
146873
|
+
error: dehydratedError,
|
|
146154
146874
|
errorCode
|
|
146155
146875
|
}
|
|
146156
146876
|
}, { requestId });
|
|
@@ -146168,6 +146888,7 @@ async function recordFatalRunError({ world, workflowRun, runId, requestId, err,
|
|
|
146168
146888
|
}
|
|
146169
146889
|
throw failErr;
|
|
146170
146890
|
}
|
|
146891
|
+
dispatchRunFailedHooks(runId, workflowName, dehydratedError, encryptionKey, errorCode);
|
|
146171
146892
|
}
|
|
146172
146893
|
__name(recordFatalRunError, "recordFatalRunError");
|
|
146173
146894
|
function findRecordedTerminalRunEvent(events, runId) {
|
|
@@ -146218,7 +146939,7 @@ function openHookAndWaitState(events) {
|
|
|
146218
146939
|
return { openHook: hooks.size > 0, openWait: waits.size > 0 };
|
|
146219
146940
|
}
|
|
146220
146941
|
__name(openHookAndWaitState, "openHookAndWaitState");
|
|
146221
|
-
function getRetentionDecision({ suspension, serializationBlockerCount, hookContinuation = false }) {
|
|
146942
|
+
function getRetentionDecision({ suspension, serializationBlockerCount, hookContinuation = false, invocationContinuation = false }) {
|
|
146222
146943
|
if (!isVmRetentionEnabled()) {
|
|
146223
146944
|
return { retain: false, reason: "disabled" };
|
|
146224
146945
|
}
|
|
@@ -146231,7 +146952,7 @@ function getRetentionDecision({ suspension, serializationBlockerCount, hookConti
|
|
|
146231
146952
|
if (hookContinuation) {
|
|
146232
146953
|
return { retain: true };
|
|
146233
146954
|
}
|
|
146234
|
-
if (suspension.stepCount === 0 && suspension.attributeCount === 0) {
|
|
146955
|
+
if (!invocationContinuation && suspension.stepCount === 0 && suspension.attributeCount === 0) {
|
|
146235
146956
|
return { retain: false, reason: "no_replay_driver" };
|
|
146236
146957
|
}
|
|
146237
146958
|
return { retain: true };
|
|
@@ -146290,7 +147011,7 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
146290
147011
|
setWorkflowBasePath(options?.basePath);
|
|
146291
147012
|
const namespace = resolveQueueNamespace2(options?.namespace);
|
|
146292
147013
|
const workflowPrefix = getQueueTopicPrefix2("workflow", namespace);
|
|
146293
|
-
const handler = /* @__PURE__ */ __name((worldHandlers) => worldHandlers.createQueueHandler(workflowPrefix, async (message_, metadata) => {
|
|
147014
|
+
const handler = /* @__PURE__ */ __name((worldHandlers) => worldHandlers.createQueueHandler(workflowPrefix, withRunInputs(worldHandlers)(async (message_, metadata, activity) => {
|
|
146294
147015
|
const handlerEnteredAtMs = Date.now();
|
|
146295
147016
|
const healthCheck3 = parseHealthCheckPayload(message_);
|
|
146296
147017
|
if (healthCheck3) {
|
|
@@ -146321,14 +147042,17 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
146321
147042
|
const world = await getWorld();
|
|
146322
147043
|
const getEncryptionKey = memoizeEncryptionKey(world, runId);
|
|
146323
147044
|
const err = new FatalError2(`Workflow exceeded maximum queue deliveries (${metadata.attempt}/${maxQueueDeliveries})`);
|
|
147045
|
+
const encryptionKey = await getEncryptionKey();
|
|
147046
|
+
const dehydratedError = await dehydrateRunError(err, runId, encryptionKey);
|
|
146324
147047
|
await world.events.create(runId, {
|
|
146325
147048
|
eventType: "run_failed",
|
|
146326
147049
|
specVersion: SPEC_VERSION_CURRENT2,
|
|
146327
147050
|
eventData: {
|
|
146328
|
-
error:
|
|
147051
|
+
error: dehydratedError,
|
|
146329
147052
|
errorCode: RUN_ERROR_CODES2.MAX_DELIVERIES_EXCEEDED
|
|
146330
147053
|
}
|
|
146331
147054
|
}, { requestId });
|
|
147055
|
+
dispatchRunFailedHooks(runId, workflowName, dehydratedError, encryptionKey, RUN_ERROR_CODES2.MAX_DELIVERIES_EXCEEDED);
|
|
146332
147056
|
} catch (err) {
|
|
146333
147057
|
if (EntityConflictError2.is(err) || RunExpiredError2.is(err)) {
|
|
146334
147058
|
return;
|
|
@@ -146486,6 +147210,7 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
146486
147210
|
world,
|
|
146487
147211
|
workflowRun,
|
|
146488
147212
|
runId,
|
|
147213
|
+
workflowName,
|
|
146489
147214
|
requestId,
|
|
146490
147215
|
err,
|
|
146491
147216
|
errorCode,
|
|
@@ -146600,6 +147325,7 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
146600
147325
|
const { outcome, spanAttributes } = await guardDeploymentAffinity({
|
|
146601
147326
|
world,
|
|
146602
147327
|
run: run3,
|
|
147328
|
+
workflowName,
|
|
146603
147329
|
requestId,
|
|
146604
147330
|
retryCount: deploymentMismatchRetryCount,
|
|
146605
147331
|
beforeStop,
|
|
@@ -146758,6 +147484,14 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
146758
147484
|
if (stepResult.type === "throttled") {
|
|
146759
147485
|
return { timeoutSeconds: stepResult.timeoutSeconds };
|
|
146760
147486
|
}
|
|
147487
|
+
if (world.capabilities?.invoke && stepResult.type !== "gone") {
|
|
147488
|
+
await queueMessage(world, getWorkflowQueueName2(workflowName, namespace), {
|
|
147489
|
+
runId,
|
|
147490
|
+
traceCarrier: await nextTraceCarrier(),
|
|
147491
|
+
requestedAt: /* @__PURE__ */ new Date()
|
|
147492
|
+
});
|
|
147493
|
+
return;
|
|
147494
|
+
}
|
|
146761
147495
|
if (stepResult.type === "completed" && stepResult.hasPendingOps) {
|
|
146762
147496
|
await queueMessage(world, getWorkflowQueueName2(workflowName, namespace), {
|
|
146763
147497
|
runId,
|
|
@@ -146841,6 +147575,7 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
146841
147575
|
world,
|
|
146842
147576
|
workflowRun,
|
|
146843
147577
|
runId,
|
|
147578
|
+
workflowName,
|
|
146844
147579
|
requestId,
|
|
146845
147580
|
err,
|
|
146846
147581
|
errorCode,
|
|
@@ -147169,6 +147904,7 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
147169
147904
|
const continuedHookIds = /* @__PURE__ */ new Set();
|
|
147170
147905
|
const publishedStepCorrelationIds = /* @__PURE__ */ new Set();
|
|
147171
147906
|
while (true) {
|
|
147907
|
+
const invocationRevision = activity?.revision ?? 0;
|
|
147172
147908
|
loopIteration++;
|
|
147173
147909
|
if (replayBudget.isExhausted()) {
|
|
147174
147910
|
await handleReplayBudgetExhausted({
|
|
@@ -147395,6 +148131,7 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
147395
148131
|
}
|
|
147396
148132
|
throw err;
|
|
147397
148133
|
}
|
|
148134
|
+
dispatchRunCompletedHooks(runId, workflowName);
|
|
147398
148135
|
span?.setAttributes({
|
|
147399
148136
|
...WorkflowRunStatus2("completed")
|
|
147400
148137
|
});
|
|
@@ -147478,13 +148215,17 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
147478
148215
|
errorName: suspensionError.name,
|
|
147479
148216
|
errorMessage: suspensionError.message
|
|
147480
148217
|
});
|
|
148218
|
+
let failureKey;
|
|
148219
|
+
let dehydratedError;
|
|
147481
148220
|
try {
|
|
147482
148221
|
await awaitRunReady();
|
|
148222
|
+
failureKey = await encryptionKey.value;
|
|
148223
|
+
dehydratedError = await dehydrateRunError(suspensionError, runId, failureKey, globalThis, (workflowRun?.specVersion ?? 0) >= SPEC_VERSION_SUPPORTS_COMPRESSION2);
|
|
147483
148224
|
await createEvent({
|
|
147484
148225
|
eventType: "run_failed",
|
|
147485
148226
|
specVersion: SPEC_VERSION_CURRENT2,
|
|
147486
148227
|
eventData: {
|
|
147487
|
-
error:
|
|
148228
|
+
error: dehydratedError,
|
|
147488
148229
|
errorCode
|
|
147489
148230
|
}
|
|
147490
148231
|
}, { requestId });
|
|
@@ -147498,6 +148239,7 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
147498
148239
|
}
|
|
147499
148240
|
throw failErr;
|
|
147500
148241
|
}
|
|
148242
|
+
dispatchRunFailedHooks(runId, workflowName, dehydratedError, failureKey, errorCode);
|
|
147501
148243
|
span?.setAttributes({
|
|
147502
148244
|
...WorkflowRunStatus2("failed"),
|
|
147503
148245
|
...WorkflowErrorCode2(errorCode),
|
|
@@ -147517,7 +148259,8 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
147517
148259
|
// This suspension committed the event a hook's
|
|
147518
148260
|
// own awaiter is parked on; the continuation
|
|
147519
148261
|
// below drives the next iteration in-process.
|
|
147520
|
-
hookContinuation: suspensionResult.hasAwaitedHookCreation || suspensionResult.hasHookConflict
|
|
148262
|
+
hookContinuation: suspensionResult.hasAwaitedHookCreation || suspensionResult.hasHookConflict,
|
|
148263
|
+
invocationContinuation: activity !== void 0
|
|
147521
148264
|
}) : void 0;
|
|
147522
148265
|
if (retentionDecision?.retain === false) {
|
|
147523
148266
|
retainedSession = null;
|
|
@@ -147726,6 +148469,10 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
147726
148469
|
}
|
|
147727
148470
|
return await reinvoke(0);
|
|
147728
148471
|
}
|
|
148472
|
+
if (activity && Date.now() - invocationStartTime < noInlineReplayAfterMs && await activity.waitForActivity(invocationRevision)) {
|
|
148473
|
+
eventLog = nextEventLogLoad(eventLog);
|
|
148474
|
+
continue;
|
|
148475
|
+
}
|
|
147729
148476
|
return;
|
|
147730
148477
|
}
|
|
147731
148478
|
const openHookWaitState = openHookWait.value;
|
|
@@ -148036,18 +148783,31 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
148036
148783
|
// shows `errorMessage` on its own row when the
|
|
148037
148784
|
// throw produced no stack to carry it.
|
|
148038
148785
|
errorMessage,
|
|
148039
|
-
errorStack
|
|
148786
|
+
errorStack,
|
|
148787
|
+
// Neither of those reaches a wrapped error's
|
|
148788
|
+
// reason: `TypeError: fetch failed` carries an
|
|
148789
|
+
// empty message by design and a stack of pure
|
|
148790
|
+
// `node:internal/` frames, and the world layer's
|
|
148791
|
+
// own wrappers name the request that failed
|
|
148792
|
+
// rather than what failed about it. Undefined
|
|
148793
|
+
// when there is no cause, so the row disappears
|
|
148794
|
+
// for an ordinary user throw.
|
|
148795
|
+
errorCause: formatErrorCauseChain(terminalError) || void 0
|
|
148040
148796
|
});
|
|
148041
148797
|
if (types9.isNativeError(terminalError) && errorStack) {
|
|
148042
148798
|
terminalError.stack = errorStack;
|
|
148043
148799
|
}
|
|
148800
|
+
let failureKey;
|
|
148801
|
+
let dehydratedError;
|
|
148044
148802
|
try {
|
|
148045
148803
|
await awaitRunReady();
|
|
148804
|
+
failureKey = await encryptionKey.value;
|
|
148805
|
+
dehydratedError = await dehydrateRunError(terminalError, runId, failureKey, globalThis, (workflowRun?.specVersion ?? 0) >= SPEC_VERSION_SUPPORTS_COMPRESSION2);
|
|
148046
148806
|
await createEvent({
|
|
148047
148807
|
eventType: "run_failed",
|
|
148048
148808
|
specVersion: SPEC_VERSION_CURRENT2,
|
|
148049
148809
|
eventData: {
|
|
148050
|
-
error:
|
|
148810
|
+
error: dehydratedError,
|
|
148051
148811
|
errorCode
|
|
148052
148812
|
}
|
|
148053
148813
|
}, {
|
|
@@ -148074,6 +148834,7 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
148074
148834
|
}
|
|
148075
148835
|
throw failErr;
|
|
148076
148836
|
}
|
|
148837
|
+
dispatchRunFailedHooks(runId, workflowName, dehydratedError, failureKey, errorCode);
|
|
148077
148838
|
span?.setAttributes({
|
|
148078
148839
|
...WorkflowRunStatus2("failed"),
|
|
148079
148840
|
...WorkflowErrorCode2(errorCode),
|
|
@@ -148088,7 +148849,7 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
148088
148849
|
});
|
|
148089
148850
|
});
|
|
148090
148851
|
});
|
|
148091
|
-
}), "handler");
|
|
148852
|
+
})), "handler");
|
|
148092
148853
|
let cachedHandler;
|
|
148093
148854
|
let invocationCount = 0;
|
|
148094
148855
|
const entrypointCreatedAt = Date.now();
|
|
@@ -148975,11 +149736,11 @@ var Run = class _Run {
|
|
|
148975
149736
|
return this.getWritable();
|
|
148976
149737
|
}
|
|
148977
149738
|
};
|
|
148978
|
-
Run.prototype["wakeUp"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
148979
|
-
Run.prototype["cancel"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
148980
|
-
Run.prototype["getReadable"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
148981
|
-
Run.prototype["getWritable"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
148982
|
-
var __step_Run$exists = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
149739
|
+
Run.prototype["wakeUp"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.54//Run#wakeUp");
|
|
149740
|
+
Run.prototype["cancel"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.54//Run#cancel");
|
|
149741
|
+
Run.prototype["getReadable"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.54//Run#getReadable");
|
|
149742
|
+
Run.prototype["getWritable"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.54//Run#getWritable");
|
|
149743
|
+
var __step_Run$exists = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.54//Run#exists");
|
|
148983
149744
|
Object.defineProperty(Run.prototype, "exists", {
|
|
148984
149745
|
get() {
|
|
148985
149746
|
return __step_Run$exists.call(this);
|
|
@@ -148987,7 +149748,7 @@ Object.defineProperty(Run.prototype, "exists", {
|
|
|
148987
149748
|
configurable: true,
|
|
148988
149749
|
enumerable: false
|
|
148989
149750
|
});
|
|
148990
|
-
var __step_Run$status = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
149751
|
+
var __step_Run$status = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.54//Run#status");
|
|
148991
149752
|
Object.defineProperty(Run.prototype, "status", {
|
|
148992
149753
|
get() {
|
|
148993
149754
|
return __step_Run$status.call(this);
|
|
@@ -148995,7 +149756,7 @@ Object.defineProperty(Run.prototype, "status", {
|
|
|
148995
149756
|
configurable: true,
|
|
148996
149757
|
enumerable: false
|
|
148997
149758
|
});
|
|
148998
|
-
var __step_Run$returnValue = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
149759
|
+
var __step_Run$returnValue = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.54//Run#returnValue");
|
|
148999
149760
|
Object.defineProperty(Run.prototype, "returnValue", {
|
|
149000
149761
|
get() {
|
|
149001
149762
|
return __step_Run$returnValue.call(this);
|
|
@@ -149003,7 +149764,7 @@ Object.defineProperty(Run.prototype, "returnValue", {
|
|
|
149003
149764
|
configurable: true,
|
|
149004
149765
|
enumerable: false
|
|
149005
149766
|
});
|
|
149006
|
-
var __step_Run$workflowName = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
149767
|
+
var __step_Run$workflowName = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.54//Run#workflowName");
|
|
149007
149768
|
Object.defineProperty(Run.prototype, "workflowName", {
|
|
149008
149769
|
get() {
|
|
149009
149770
|
return __step_Run$workflowName.call(this);
|
|
@@ -149011,7 +149772,7 @@ Object.defineProperty(Run.prototype, "workflowName", {
|
|
|
149011
149772
|
configurable: true,
|
|
149012
149773
|
enumerable: false
|
|
149013
149774
|
});
|
|
149014
|
-
var __step_Run$createdAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
149775
|
+
var __step_Run$createdAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.54//Run#createdAt");
|
|
149015
149776
|
Object.defineProperty(Run.prototype, "createdAt", {
|
|
149016
149777
|
get() {
|
|
149017
149778
|
return __step_Run$createdAt.call(this);
|
|
@@ -149019,7 +149780,7 @@ Object.defineProperty(Run.prototype, "createdAt", {
|
|
|
149019
149780
|
configurable: true,
|
|
149020
149781
|
enumerable: false
|
|
149021
149782
|
});
|
|
149022
|
-
var __step_Run$startedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
149783
|
+
var __step_Run$startedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.54//Run#startedAt");
|
|
149023
149784
|
Object.defineProperty(Run.prototype, "startedAt", {
|
|
149024
149785
|
get() {
|
|
149025
149786
|
return __step_Run$startedAt.call(this);
|
|
@@ -149027,7 +149788,7 @@ Object.defineProperty(Run.prototype, "startedAt", {
|
|
|
149027
149788
|
configurable: true,
|
|
149028
149789
|
enumerable: false
|
|
149029
149790
|
});
|
|
149030
|
-
var __step_Run$completedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
149791
|
+
var __step_Run$completedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.54//Run#completedAt");
|
|
149031
149792
|
Object.defineProperty(Run.prototype, "completedAt", {
|
|
149032
149793
|
get() {
|
|
149033
149794
|
return __step_Run$completedAt.call(this);
|
|
@@ -149044,7 +149805,7 @@ Object.defineProperty(Run.prototype, "completedAt", {
|
|
|
149044
149805
|
enumerable: false,
|
|
149045
149806
|
configurable: false
|
|
149046
149807
|
});
|
|
149047
|
-
})(Run, "class//@workflow/core/runtime/run@5.0.0-beta.
|
|
149808
|
+
})(Run, "class//@workflow/core/runtime/run@5.0.0-beta.54//Run");
|
|
149048
149809
|
|
|
149049
149810
|
// ../core/dist/workflow/create-hook.js
|
|
149050
149811
|
aliasSerializationClass(RUN_CLASS_ID, Run);
|
|
@@ -156640,7 +157401,7 @@ globalThis.__private_workflows.set("workflow//./workflows/inline-execution//hook
|
|
|
156640
157401
|
var latestNoOpWarning = globalSingleton("@workflow/core//latestNoOpWarning", 1, () => ({
|
|
156641
157402
|
warned: false
|
|
156642
157403
|
}));
|
|
156643
|
-
var start = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/start@5.0.0-beta.
|
|
157404
|
+
var start = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/start@5.0.0-beta.54//start");
|
|
156644
157405
|
|
|
156645
157406
|
// workflows/lineage.ts
|
|
156646
157407
|
var noop = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//./workflows/lineage//noop");
|