@workflow/world-testing 5.0.0-beta.53 → 5.0.0-beta.55
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.50";
|
|
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
|
}
|
|
@@ -68629,13 +68647,13 @@ var require_functions2 = __commonJS({
|
|
|
68629
68647
|
ipAddress: /* @__PURE__ */ __name(() => import_headers.ipAddress, "ipAddress"),
|
|
68630
68648
|
next: /* @__PURE__ */ __name(() => import_middleware.next, "next"),
|
|
68631
68649
|
rewrite: /* @__PURE__ */ __name(() => import_middleware.rewrite, "rewrite"),
|
|
68632
|
-
waitUntil: /* @__PURE__ */ __name(() =>
|
|
68650
|
+
waitUntil: /* @__PURE__ */ __name(() => import_wait_until5.waitUntil, "waitUntil")
|
|
68633
68651
|
});
|
|
68634
68652
|
module.exports = __toCommonJS(src_exports);
|
|
68635
68653
|
var import_headers = require_headers3();
|
|
68636
68654
|
var import_get_env = require_get_env2();
|
|
68637
68655
|
var import_deadline = require_deadline2();
|
|
68638
|
-
var
|
|
68656
|
+
var import_wait_until5 = require_wait_until2();
|
|
68639
68657
|
var import_middleware = require_middleware2();
|
|
68640
68658
|
var import_cache = require_cache5();
|
|
68641
68659
|
var import_db_connections = require_db_connections2();
|
|
@@ -74561,10 +74579,20 @@ function toBatchResult(outcome) {
|
|
|
74561
74579
|
messageId: outcome.messageId ? MessageId2.parse(outcome.messageId) : null
|
|
74562
74580
|
};
|
|
74563
74581
|
}
|
|
74564
|
-
function
|
|
74582
|
+
function getErrorRetryAfterSeconds(error121) {
|
|
74583
|
+
if (typeof error121 !== "object" || error121 === null)
|
|
74584
|
+
return void 0;
|
|
74585
|
+
const retryAfter = error121.retryAfter;
|
|
74586
|
+
if (typeof retryAfter !== "number" || !Number.isFinite(retryAfter) || retryAfter <= 0) {
|
|
74587
|
+
return void 0;
|
|
74588
|
+
}
|
|
74589
|
+
return Math.min(Math.ceil(retryAfter), HANDLER_ERROR_MAX_RETRY_AFTER_SECONDS);
|
|
74590
|
+
}
|
|
74591
|
+
function getHandlerErrorRetryAfterSeconds(error121, deliveryCount) {
|
|
74565
74592
|
const backoffSeconds = Math.min(Math.max(HANDLER_ERROR_RETRY_AFTER_SECONDS, 2 ** (deliveryCount - 1)), HANDLER_ERROR_MAX_RETRY_AFTER_SECONDS);
|
|
74566
74593
|
const jitterSeconds = Math.floor(Math.random() * (Math.ceil(backoffSeconds * HANDLER_ERROR_RETRY_JITTER_RATIO) + 1));
|
|
74567
|
-
|
|
74594
|
+
const jitteredBackoffSeconds = Math.max(HANDLER_ERROR_RETRY_AFTER_SECONDS, backoffSeconds - jitterSeconds);
|
|
74595
|
+
return Math.max(jitteredBackoffSeconds, getErrorRetryAfterSeconds(error121) ?? HANDLER_ERROR_RETRY_AFTER_SECONDS);
|
|
74568
74596
|
}
|
|
74569
74597
|
function getRunIdFromPayload(payload) {
|
|
74570
74598
|
if ("runId" in payload && typeof payload.runId === "string") {
|
|
@@ -74767,7 +74795,7 @@ function createQueue2(config4) {
|
|
|
74767
74795
|
attempt: metadata.deliveryCount,
|
|
74768
74796
|
requestId
|
|
74769
74797
|
});
|
|
74770
|
-
if (typeof result2
|
|
74798
|
+
if (!("invoke" in payload && payload.invoke === true) && typeof result2 === "object" && result2 !== null && "timeoutSeconds" in result2 && typeof result2.timeoutSeconds === "number") {
|
|
74771
74799
|
const delaySeconds = result2.timeoutSeconds > 0 ? Math.min(result2.timeoutSeconds, MAX_DELAY_SECONDS) : void 0;
|
|
74772
74800
|
await queue(queueName, payload, { deploymentId, delaySeconds });
|
|
74773
74801
|
}
|
|
@@ -74782,7 +74810,7 @@ function createQueue2(config4) {
|
|
|
74782
74810
|
// redrive in lockstep. Workflow handlers are event-sourced and must
|
|
74783
74811
|
// remain idempotent because queue retries can happen close together.
|
|
74784
74812
|
retry: /* @__PURE__ */ __name((error121, { messageId, deliveryCount }) => {
|
|
74785
|
-
const afterSeconds = getHandlerErrorRetryAfterSeconds(deliveryCount);
|
|
74813
|
+
const afterSeconds = getHandlerErrorRetryAfterSeconds(error121, deliveryCount);
|
|
74786
74814
|
console.error(`[workflow] Queue handler failed for message "${messageId}" on delivery attempt ${deliveryCount}; retrying in ${afterSeconds}s:`, error121);
|
|
74787
74815
|
return { afterSeconds };
|
|
74788
74816
|
}, "retry")
|
|
@@ -74913,6 +74941,7 @@ var init_queue4 = __esm({
|
|
|
74913
74941
|
HANDLER_ERROR_RETRY_AFTER_SECONDS = 1;
|
|
74914
74942
|
HANDLER_ERROR_MAX_RETRY_AFTER_SECONDS = 900;
|
|
74915
74943
|
HANDLER_ERROR_RETRY_JITTER_RATIO = 0.25;
|
|
74944
|
+
__name(getErrorRetryAfterSeconds, "getErrorRetryAfterSeconds");
|
|
74916
74945
|
__name(getHandlerErrorRetryAfterSeconds, "getHandlerErrorRetryAfterSeconds");
|
|
74917
74946
|
FALLBACK_REGION = "iad1";
|
|
74918
74947
|
__name(getRunIdFromPayload, "getRunIdFromPayload");
|
|
@@ -76566,6 +76595,15 @@ function validateWorkflowRunIdTimestamp(id) {
|
|
|
76566
76595
|
function assertEventDataWireContractExhaustive() {
|
|
76567
76596
|
}
|
|
76568
76597
|
function splitEventDataForV4(data) {
|
|
76598
|
+
if (data.eventType === "attr_set") {
|
|
76599
|
+
try {
|
|
76600
|
+
validateAttributeEventDataSize2(data.eventData);
|
|
76601
|
+
} catch (error121) {
|
|
76602
|
+
if (!(error121 instanceof AttributeValidationError2))
|
|
76603
|
+
throw error121;
|
|
76604
|
+
throw new WorkflowWorldError2(error121.message, { status: 400 });
|
|
76605
|
+
}
|
|
76606
|
+
}
|
|
76569
76607
|
const eventData = data.eventData ?? {};
|
|
76570
76608
|
const payloadField = getEventDataPayloadField(data.eventType);
|
|
76571
76609
|
const meta5 = {};
|
|
@@ -76905,6 +76943,7 @@ var init_events3 = __esm({
|
|
|
76905
76943
|
"use strict";
|
|
76906
76944
|
init_dist7();
|
|
76907
76945
|
init_dist6();
|
|
76946
|
+
init_attributes_validation2();
|
|
76908
76947
|
init_event_retry();
|
|
76909
76948
|
init_events_v4();
|
|
76910
76949
|
init_run_id();
|
|
@@ -79864,12 +79903,25 @@ async function awaitEarlierDeliveries(ctx, eventIndex, kind) {
|
|
|
79864
79903
|
await new Promise((resolve3) => setTimeout(resolve3, 0));
|
|
79865
79904
|
}
|
|
79866
79905
|
}
|
|
79867
|
-
function registerDeliveryBarrier(ctx, eventIndex, kind, options
|
|
79906
|
+
function registerDeliveryBarrier(ctx, eventIndex, kind, options) {
|
|
79907
|
+
let deliveredToWorkflow = false;
|
|
79908
|
+
const deliver = /* @__PURE__ */ __name(() => {
|
|
79909
|
+
if (deliveredToWorkflow) {
|
|
79910
|
+
return false;
|
|
79911
|
+
}
|
|
79912
|
+
deliveredToWorkflow = true;
|
|
79913
|
+
ctx.advanceClock?.(options.deliveredAt);
|
|
79914
|
+
return true;
|
|
79915
|
+
}, "deliver");
|
|
79868
79916
|
const barriers = ctx.pendingDeliveryBarriers;
|
|
79869
79917
|
if (!barriers || eventIndex === void 0) {
|
|
79870
|
-
return {
|
|
79871
|
-
|
|
79872
|
-
|
|
79918
|
+
return {
|
|
79919
|
+
markDelivered: /* @__PURE__ */ __name(() => {
|
|
79920
|
+
deliver();
|
|
79921
|
+
}, "markDelivered"),
|
|
79922
|
+
arm: /* @__PURE__ */ __name(() => {
|
|
79923
|
+
}, "arm")
|
|
79924
|
+
};
|
|
79873
79925
|
}
|
|
79874
79926
|
const install = /* @__PURE__ */ __name((armed) => {
|
|
79875
79927
|
if (barriers.has(eventIndex)) {
|
|
@@ -79897,13 +79949,11 @@ function registerDeliveryBarrier(ctx, eventIndex, kind, options = {}) {
|
|
|
79897
79949
|
return entry2;
|
|
79898
79950
|
}, "install");
|
|
79899
79951
|
let entry = install(options.armed ?? true);
|
|
79900
|
-
let deliveredToWorkflow = false;
|
|
79901
79952
|
return {
|
|
79902
79953
|
markDelivered: /* @__PURE__ */ __name(() => {
|
|
79903
|
-
if (
|
|
79954
|
+
if (!deliver()) {
|
|
79904
79955
|
return;
|
|
79905
79956
|
}
|
|
79906
|
-
deliveredToWorkflow = true;
|
|
79907
79957
|
entry.retire();
|
|
79908
79958
|
}, "markDelivered"),
|
|
79909
79959
|
arm: /* @__PURE__ */ __name(() => {
|
|
@@ -83812,7 +83862,9 @@ function createCreateAbortController(ctx) {
|
|
|
83812
83862
|
if (event.eventType === "hook_received") {
|
|
83813
83863
|
const rawPayload = event.eventData?.payload;
|
|
83814
83864
|
const eventIndex = ctx.eventsConsumer.eventIndex;
|
|
83815
|
-
const barrier = registerDeliveryBarrier(ctx, eventIndex, "hook"
|
|
83865
|
+
const barrier = registerDeliveryBarrier(ctx, eventIndex, "hook", {
|
|
83866
|
+
deliveredAt: +event.createdAt
|
|
83867
|
+
});
|
|
83816
83868
|
const earlierDelivered = awaitEarlierDeliveries(ctx, eventIndex, "hook");
|
|
83817
83869
|
ctx.pendingDeliveries++;
|
|
83818
83870
|
ctx.promiseQueue = ctx.promiseQueue.then(async () => {
|
|
@@ -86000,7 +86052,7 @@ var version5;
|
|
|
86000
86052
|
var init_version4 = __esm({
|
|
86001
86053
|
"../core/dist/version.js"() {
|
|
86002
86054
|
"use strict";
|
|
86003
|
-
version5 = "5.0.0-beta.
|
|
86055
|
+
version5 = "5.0.0-beta.55";
|
|
86004
86056
|
}
|
|
86005
86057
|
});
|
|
86006
86058
|
|
|
@@ -86471,6 +86523,176 @@ var init_helpers3 = __esm({
|
|
|
86471
86523
|
}
|
|
86472
86524
|
});
|
|
86473
86525
|
|
|
86526
|
+
// ../core/dist/runtime/invocations.js
|
|
86527
|
+
async function handleInvocation(world, runId, requestId, payload) {
|
|
86528
|
+
const parsed = HookInvocationSchema2.safeParse(payload);
|
|
86529
|
+
if (!parsed.success || !requestId)
|
|
86530
|
+
throw new WorkflowWorldError2("Invalid invocation input", {
|
|
86531
|
+
status: 400,
|
|
86532
|
+
code: "INVALID_INPUT"
|
|
86533
|
+
});
|
|
86534
|
+
const input3 = parsed.data;
|
|
86535
|
+
const digest = Buffer.from(await crypto.subtle.digest("SHA-256", input3.payload)).toString("hex");
|
|
86536
|
+
try {
|
|
86537
|
+
const hook = await world.hooks.get(input3.hookId);
|
|
86538
|
+
if (hook.runId !== runId || hook.token !== input3.token)
|
|
86539
|
+
throw new HookNotFoundError2(input3.token);
|
|
86540
|
+
const run3 = await world.runs.get(runId, { resolveData: "none" });
|
|
86541
|
+
if (isTerminalWorkflowRunStatus2(run3.status))
|
|
86542
|
+
throw new HookNotFoundError2(input3.token);
|
|
86543
|
+
} catch (error121) {
|
|
86544
|
+
if (!isHookGone(error121))
|
|
86545
|
+
throw error121;
|
|
86546
|
+
const run3 = await world.runs.get(runId, { resolveData: "none" });
|
|
86547
|
+
if (run3.expiredAt || isTerminalWorkflowRunStatus2(run3.status) && readRunRetention(run3.attributes).mode === "none") {
|
|
86548
|
+
throw new WorkflowWorldError2("Invocation data has expired under the run retention policy", { status: 410, code: "INVOCATION_DATA_EXPIRED" });
|
|
86549
|
+
}
|
|
86550
|
+
if (!world.capabilities?.hookResumeDedup || !await hasResume(world, runId, input3.hookId, requestId)) {
|
|
86551
|
+
throw error121;
|
|
86552
|
+
}
|
|
86553
|
+
}
|
|
86554
|
+
await world.events.create(runId, {
|
|
86555
|
+
eventType: "hook_received",
|
|
86556
|
+
correlationId: input3.hookId,
|
|
86557
|
+
specVersion: SPEC_VERSION_CURRENT2,
|
|
86558
|
+
eventData: { token: input3.token, payload: input3.payload }
|
|
86559
|
+
}, {
|
|
86560
|
+
...world.capabilities?.hookResumeDedup ? { resumeId: requestId, resumePayloadDigest: digest } : {}
|
|
86561
|
+
});
|
|
86562
|
+
return { status: "accepted" };
|
|
86563
|
+
}
|
|
86564
|
+
function isHookGone(error121) {
|
|
86565
|
+
return HookNotFoundError2.is(error121) || RunExpiredError2.is(error121) || WorkflowRunNotFoundError2.is(error121);
|
|
86566
|
+
}
|
|
86567
|
+
async function hasResume(world, runId, hookId, requestId) {
|
|
86568
|
+
let cursor = null;
|
|
86569
|
+
do {
|
|
86570
|
+
const page = await world.events.listByCorrelationId({
|
|
86571
|
+
runId,
|
|
86572
|
+
correlationId: hookId,
|
|
86573
|
+
resolveData: "none",
|
|
86574
|
+
pagination: { limit: 100, ...cursor ? { cursor } : {} }
|
|
86575
|
+
});
|
|
86576
|
+
if (page.data.some((event) => event.eventType === "hook_received" && event.resumeId === requestId))
|
|
86577
|
+
return true;
|
|
86578
|
+
cursor = page.hasMore ? page.cursor : null;
|
|
86579
|
+
} while (cursor);
|
|
86580
|
+
return false;
|
|
86581
|
+
}
|
|
86582
|
+
function withRunInputs(world) {
|
|
86583
|
+
return (handler) => {
|
|
86584
|
+
const sessions = /* @__PURE__ */ new Map();
|
|
86585
|
+
return async (message, metadata) => {
|
|
86586
|
+
if (HealthCheckPayloadSchema2.safeParse(message).success)
|
|
86587
|
+
return handler(message, metadata);
|
|
86588
|
+
const parsed = WorkflowInvokePayloadSchema2.safeParse(message);
|
|
86589
|
+
if (!world.capabilities?.invoke || !parsed.success || parsed.data.stepId)
|
|
86590
|
+
return handler(message, metadata);
|
|
86591
|
+
const input3 = parsed.data;
|
|
86592
|
+
let session = sessions.get(input3.runId);
|
|
86593
|
+
if (!session) {
|
|
86594
|
+
session = {
|
|
86595
|
+
activity: new RunInputActivity(),
|
|
86596
|
+
admission: Promise.resolve(),
|
|
86597
|
+
references: 0
|
|
86598
|
+
};
|
|
86599
|
+
sessions.set(input3.runId, session);
|
|
86600
|
+
}
|
|
86601
|
+
const current = session;
|
|
86602
|
+
current.references++;
|
|
86603
|
+
try {
|
|
86604
|
+
if (input3.invoke) {
|
|
86605
|
+
if (!input3.requestId)
|
|
86606
|
+
throw new WorkflowRuntimeError2("Invocation requestId is required");
|
|
86607
|
+
const requestId = input3.requestId;
|
|
86608
|
+
const decision = current.admission.then(() => trace5("workflow.invoke.receive", async (span) => {
|
|
86609
|
+
span?.setAttributes({
|
|
86610
|
+
...WorkflowRunId4(input3.runId),
|
|
86611
|
+
"workflow.invocation.id": requestId
|
|
86612
|
+
});
|
|
86613
|
+
const result2 = await handleInvocation(world, input3.runId, requestId, input3.input);
|
|
86614
|
+
if (result2.status === "accepted")
|
|
86615
|
+
current.activity.notify();
|
|
86616
|
+
return result2;
|
|
86617
|
+
}));
|
|
86618
|
+
current.admission = decision.catch(() => {
|
|
86619
|
+
});
|
|
86620
|
+
return await decision;
|
|
86621
|
+
}
|
|
86622
|
+
if (current.execution)
|
|
86623
|
+
return await current.execution;
|
|
86624
|
+
const execution = handler(message, metadata, current.activity);
|
|
86625
|
+
current.execution = execution;
|
|
86626
|
+
try {
|
|
86627
|
+
return await execution;
|
|
86628
|
+
} finally {
|
|
86629
|
+
if (current.execution === execution)
|
|
86630
|
+
current.execution = void 0;
|
|
86631
|
+
}
|
|
86632
|
+
} finally {
|
|
86633
|
+
current.references--;
|
|
86634
|
+
if (current.references === 0 && sessions.get(input3.runId) === current)
|
|
86635
|
+
sessions.delete(input3.runId);
|
|
86636
|
+
}
|
|
86637
|
+
};
|
|
86638
|
+
};
|
|
86639
|
+
}
|
|
86640
|
+
var HookInvocationSchema2, HookInvocationResultSchema2, RunInputActivity;
|
|
86641
|
+
var init_invocations2 = __esm({
|
|
86642
|
+
"../core/dist/runtime/invocations.js"() {
|
|
86643
|
+
"use strict";
|
|
86644
|
+
init_dist7();
|
|
86645
|
+
init_dist6();
|
|
86646
|
+
init_zod2();
|
|
86647
|
+
init_semantic_conventions2();
|
|
86648
|
+
init_telemetry4();
|
|
86649
|
+
HookInvocationSchema2 = external_exports2.object({
|
|
86650
|
+
type: external_exports2.literal("hook_resume"),
|
|
86651
|
+
version: external_exports2.literal(1),
|
|
86652
|
+
hookId: external_exports2.string(),
|
|
86653
|
+
token: external_exports2.string(),
|
|
86654
|
+
payload: external_exports2.instanceof(Uint8Array)
|
|
86655
|
+
});
|
|
86656
|
+
HookInvocationResultSchema2 = external_exports2.discriminatedUnion("status", [
|
|
86657
|
+
external_exports2.object({ status: external_exports2.literal("accepted") }),
|
|
86658
|
+
external_exports2.object({
|
|
86659
|
+
status: external_exports2.literal("rejected"),
|
|
86660
|
+
code: external_exports2.enum(["HOOK_NOT_FOUND", "INVALID_INPUT"])
|
|
86661
|
+
})
|
|
86662
|
+
]);
|
|
86663
|
+
__name(handleInvocation, "handleInvocation");
|
|
86664
|
+
__name(isHookGone, "isHookGone");
|
|
86665
|
+
__name(hasResume, "hasResume");
|
|
86666
|
+
RunInputActivity = class {
|
|
86667
|
+
static {
|
|
86668
|
+
__name(this, "RunInputActivity");
|
|
86669
|
+
}
|
|
86670
|
+
revision = 0;
|
|
86671
|
+
listeners = /* @__PURE__ */ new Set();
|
|
86672
|
+
notify() {
|
|
86673
|
+
this.revision++;
|
|
86674
|
+
for (const notify of this.listeners)
|
|
86675
|
+
notify();
|
|
86676
|
+
}
|
|
86677
|
+
async waitForActivity(since, timeoutMs = 100) {
|
|
86678
|
+
if (this.revision !== since)
|
|
86679
|
+
return true;
|
|
86680
|
+
await new Promise((resolve3) => {
|
|
86681
|
+
const finish = /* @__PURE__ */ __name(() => {
|
|
86682
|
+
clearTimeout(timer);
|
|
86683
|
+
this.listeners.delete(finish);
|
|
86684
|
+
resolve3();
|
|
86685
|
+
}, "finish");
|
|
86686
|
+
const timer = setTimeout(finish, timeoutMs);
|
|
86687
|
+
this.listeners.add(finish);
|
|
86688
|
+
});
|
|
86689
|
+
return this.revision !== since;
|
|
86690
|
+
}
|
|
86691
|
+
};
|
|
86692
|
+
__name(withRunInputs, "withRunInputs");
|
|
86693
|
+
}
|
|
86694
|
+
});
|
|
86695
|
+
|
|
86474
86696
|
// ../core/dist/runtime/wait-until.js
|
|
86475
86697
|
function waitUntil3(promise3) {
|
|
86476
86698
|
void Promise.resolve().then(() => __toESM(require_functions2(), 1)).then(({ waitUntil: waitUntil4 }) => {
|
|
@@ -86687,6 +86909,26 @@ async function resumeHookImpl2(tokenOrHook, payload, encryptionKeyOverride, hook
|
|
|
86687
86909
|
if (originLink) {
|
|
86688
86910
|
span?.addLink?.(originLink);
|
|
86689
86911
|
}
|
|
86912
|
+
if (world.capabilities?.invoke === true && !v1Compat && dehydratedPayload instanceof Uint8Array) {
|
|
86913
|
+
if (!world.invoke) {
|
|
86914
|
+
throw new WorkflowRuntimeError2("World advertises invoke without implementing it");
|
|
86915
|
+
}
|
|
86916
|
+
span?.setAttributes({ "workflow.hook.resume_strategy": "invoke" });
|
|
86917
|
+
const result2 = HookInvocationResultSchema2.parse(await world.invoke(hook.runId, {
|
|
86918
|
+
type: "hook_resume",
|
|
86919
|
+
version: 1,
|
|
86920
|
+
hookId: hook.hookId,
|
|
86921
|
+
token: hook.token,
|
|
86922
|
+
payload: dehydratedPayload
|
|
86923
|
+
}, { idempotencyKey: generateResumeId2() }));
|
|
86924
|
+
if (result2.status === "rejected") {
|
|
86925
|
+
if (result2.code === "HOOK_NOT_FOUND")
|
|
86926
|
+
throw new HookNotFoundError2(hook.token);
|
|
86927
|
+
throw new WorkflowRuntimeError2("Executor rejected the hook invocation input");
|
|
86928
|
+
}
|
|
86929
|
+
span?.setAttributes(HookResumeCommitted2(true));
|
|
86930
|
+
return asLazyMetadataHook2(hook);
|
|
86931
|
+
}
|
|
86690
86932
|
const queueName = getWorkflowQueueName2(resumeContext.workflowName);
|
|
86691
86933
|
const queueOptions = {
|
|
86692
86934
|
deploymentId: resumeContext.deploymentId,
|
|
@@ -86811,6 +87053,7 @@ var init_resume_hook2 = __esm({
|
|
|
86811
87053
|
init_telemetry4();
|
|
86812
87054
|
init_get_world_lazy2();
|
|
86813
87055
|
init_helpers3();
|
|
87056
|
+
init_invocations2();
|
|
86814
87057
|
init_wait_until2();
|
|
86815
87058
|
generateResumeId2 = monotonicFactory2();
|
|
86816
87059
|
__name(computeResumePayloadDigest2, "computeResumePayloadDigest");
|
|
@@ -87900,6 +88143,11 @@ function createForwardedWritable2({ global: global2, ops, runId, name, key, depl
|
|
|
87900
88143
|
return serialize5.writable;
|
|
87901
88144
|
}
|
|
87902
88145
|
function getRunReadableStream2(global2, ops, runId, name, startIndex, cryptoKey) {
|
|
88146
|
+
return getLazyReadableStream2((onReadableState) => getExternalRevivers2(global2, ops, runId, cryptoKey, {
|
|
88147
|
+
onReadableState
|
|
88148
|
+
}).ReadableStream({ name, startIndex }));
|
|
88149
|
+
}
|
|
88150
|
+
function getLazyReadableStream2(reviveReadable, onReadableState) {
|
|
87903
88151
|
let reader;
|
|
87904
88152
|
let lockState;
|
|
87905
88153
|
let lockPollingStarted = false;
|
|
@@ -87909,15 +88157,16 @@ function getRunReadableStream2(global2, ops, runId, name, startIndex, cryptoKey)
|
|
|
87909
88157
|
async pull(controller) {
|
|
87910
88158
|
try {
|
|
87911
88159
|
if (!reader) {
|
|
87912
|
-
const stream =
|
|
87913
|
-
|
|
87914
|
-
|
|
87915
|
-
}, "onReadableState")
|
|
87916
|
-
}).ReadableStream({ name, startIndex });
|
|
88160
|
+
const stream = reviveReadable((state) => {
|
|
88161
|
+
lockState = state;
|
|
88162
|
+
});
|
|
87917
88163
|
reader = stream.getReader();
|
|
87918
88164
|
if (lockState && !lockPollingStarted) {
|
|
87919
88165
|
lockPollingStarted = true;
|
|
87920
|
-
|
|
88166
|
+
if (onReadableState)
|
|
88167
|
+
onReadableState(lockState);
|
|
88168
|
+
else
|
|
88169
|
+
pollReadableLock2(userReadable, lockState);
|
|
87921
88170
|
}
|
|
87922
88171
|
}
|
|
87923
88172
|
const result2 = await reader.read();
|
|
@@ -87941,6 +88190,48 @@ function getRunReadableStream2(global2, ops, runId, name, startIndex, cryptoKey)
|
|
|
87941
88190
|
return userReadable;
|
|
87942
88191
|
}
|
|
87943
88192
|
function getExternalRevivers2(global2 = globalThis, ops, runId, cryptoKey, options) {
|
|
88193
|
+
function reviveReadableStream(value, onReadableState = options?.onReadableState) {
|
|
88194
|
+
if (value.type === "bytes") {
|
|
88195
|
+
const readable2 = new WorkflowServerReadableStream2(runId, value.name, value.startIndex);
|
|
88196
|
+
const state2 = createFlushableState2();
|
|
88197
|
+
ops.push(state2.promise);
|
|
88198
|
+
const { readable: userReadable, writable } = value.framing === "framed-v1" ? getByteUnframingStream2() : new global2.TransformStream();
|
|
88199
|
+
flushablePipe2(readable2, writable, state2).catch(() => {
|
|
88200
|
+
});
|
|
88201
|
+
if (onReadableState)
|
|
88202
|
+
onReadableState(state2);
|
|
88203
|
+
else
|
|
88204
|
+
pollReadableLock2(userReadable, state2);
|
|
88205
|
+
return userReadable;
|
|
88206
|
+
}
|
|
88207
|
+
let keyPromise;
|
|
88208
|
+
const resolveKey = /* @__PURE__ */ __name(() => {
|
|
88209
|
+
keyPromise ??= resolveEncryptionKey2(cryptoKey);
|
|
88210
|
+
return keyPromise;
|
|
88211
|
+
}, "resolveKey");
|
|
88212
|
+
const readable = createReconnectingFramedStream2(runId, value.name, value.startIndex, resolveKey);
|
|
88213
|
+
const transform3 = getDeserializeStream2(getExternalRevivers2(global2, ops, runId, resolveKey, {
|
|
88214
|
+
lazyStreams: options?.lazyStreams,
|
|
88215
|
+
liveAbortSignals: options?.liveAbortSignals
|
|
88216
|
+
}), resolveKey);
|
|
88217
|
+
const state = createFlushableState2();
|
|
88218
|
+
ops.push(state.promise);
|
|
88219
|
+
flushablePipe2(readable, transform3.writable, state).catch(() => {
|
|
88220
|
+
});
|
|
88221
|
+
if (onReadableState)
|
|
88222
|
+
onReadableState(state);
|
|
88223
|
+
else
|
|
88224
|
+
pollReadableLock2(transform3.readable, state);
|
|
88225
|
+
return transform3.readable;
|
|
88226
|
+
}
|
|
88227
|
+
__name(reviveReadableStream, "reviveReadableStream");
|
|
88228
|
+
function reviveAbortSnapshot(value) {
|
|
88229
|
+
const controller = new AbortController();
|
|
88230
|
+
if (value.aborted)
|
|
88231
|
+
controller.abort(value.reason);
|
|
88232
|
+
return controller;
|
|
88233
|
+
}
|
|
88234
|
+
__name(reviveAbortSnapshot, "reviveAbortSnapshot");
|
|
87944
88235
|
return {
|
|
87945
88236
|
...getCommonRevivers4(global2),
|
|
87946
88237
|
// StepFunction should not be returned from workflows to clients
|
|
@@ -87981,36 +88272,7 @@ function getExternalRevivers2(global2 = globalThis, ops, runId, cryptoKey, optio
|
|
|
87981
88272
|
const response = new global2.Response(bodyInit);
|
|
87982
88273
|
return response.body;
|
|
87983
88274
|
}
|
|
87984
|
-
|
|
87985
|
-
const readable = new WorkflowServerReadableStream2(runId, value.name, value.startIndex);
|
|
87986
|
-
const state = createFlushableState2();
|
|
87987
|
-
ops.push(state.promise);
|
|
87988
|
-
const { readable: userReadable, writable } = value.framing === "framed-v1" ? getByteUnframingStream2() : new global2.TransformStream();
|
|
87989
|
-
flushablePipe2(readable, writable, state).catch(() => {
|
|
87990
|
-
});
|
|
87991
|
-
if (options?.onReadableState)
|
|
87992
|
-
options.onReadableState(state);
|
|
87993
|
-
else
|
|
87994
|
-
pollReadableLock2(userReadable, state);
|
|
87995
|
-
return userReadable;
|
|
87996
|
-
} else {
|
|
87997
|
-
let keyPromise;
|
|
87998
|
-
const resolveKey = /* @__PURE__ */ __name(() => {
|
|
87999
|
-
keyPromise ??= resolveEncryptionKey2(cryptoKey);
|
|
88000
|
-
return keyPromise;
|
|
88001
|
-
}, "resolveKey");
|
|
88002
|
-
const readable = createReconnectingFramedStream2(runId, value.name, value.startIndex, resolveKey);
|
|
88003
|
-
const transform3 = getDeserializeStream2(getExternalRevivers2(global2, ops, runId, resolveKey), resolveKey);
|
|
88004
|
-
const state = createFlushableState2();
|
|
88005
|
-
ops.push(state.promise);
|
|
88006
|
-
flushablePipe2(readable, transform3.writable, state).catch(() => {
|
|
88007
|
-
});
|
|
88008
|
-
if (options?.onReadableState)
|
|
88009
|
-
options.onReadableState(state);
|
|
88010
|
-
else
|
|
88011
|
-
pollReadableLock2(transform3.readable, state);
|
|
88012
|
-
return transform3.readable;
|
|
88013
|
-
}
|
|
88275
|
+
return options?.lazyStreams ? getLazyReadableStream2((onReadableState) => reviveReadableStream(value, onReadableState), options.onReadableState) : reviveReadableStream(value);
|
|
88014
88276
|
}, "ReadableStream"),
|
|
88015
88277
|
WritableStream: /* @__PURE__ */ __name((value) => {
|
|
88016
88278
|
const targetRunId = typeof value.runId === "string" ? value.runId : runId;
|
|
@@ -88025,8 +88287,8 @@ function getExternalRevivers2(global2 = globalThis, ops, runId, cryptoKey, optio
|
|
|
88025
88287
|
encryptionPublicKey: value.encryptionPublicKey
|
|
88026
88288
|
});
|
|
88027
88289
|
}, "WritableStream"),
|
|
88028
|
-
AbortController: /* @__PURE__ */ __name((value) => reviveAbortController2(value, ops, runId), "AbortController"),
|
|
88029
|
-
AbortSignal: /* @__PURE__ */ __name((value) => reviveAbortSignal2(value, ops, runId), "AbortSignal")
|
|
88290
|
+
AbortController: /* @__PURE__ */ __name((value) => options?.liveAbortSignals === false ? reviveAbortSnapshot(value) : reviveAbortController2(value, ops, runId), "AbortController"),
|
|
88291
|
+
AbortSignal: /* @__PURE__ */ __name((value) => options?.liveAbortSignals === false ? reviveAbortSnapshot(value).signal : reviveAbortSignal2(value, ops, runId), "AbortSignal")
|
|
88030
88292
|
};
|
|
88031
88293
|
}
|
|
88032
88294
|
function getWorkflowRevivers(global2 = globalThis) {
|
|
@@ -88902,6 +89164,7 @@ var init_serialization4 = __esm({
|
|
|
88902
89164
|
__name(tagForwardedWritableTarget2, "tagForwardedWritableTarget");
|
|
88903
89165
|
__name(createForwardedWritable2, "createForwardedWritable");
|
|
88904
89166
|
__name(getRunReadableStream2, "getRunReadableStream");
|
|
89167
|
+
__name(getLazyReadableStream2, "getLazyReadableStream");
|
|
88905
89168
|
__name(getExternalRevivers2, "getExternalRevivers");
|
|
88906
89169
|
__name(getWorkflowRevivers, "getWorkflowRevivers");
|
|
88907
89170
|
__name(getStepRevivers2, "getStepRevivers");
|
|
@@ -89153,6 +89416,751 @@ var init_constants3 = __esm({
|
|
|
89153
89416
|
}
|
|
89154
89417
|
});
|
|
89155
89418
|
|
|
89419
|
+
// ../core/dist/types.js
|
|
89420
|
+
import { types as types6 } from "node:util";
|
|
89421
|
+
function getErrorName(v) {
|
|
89422
|
+
if (types6.isNativeError(v)) {
|
|
89423
|
+
return v.name;
|
|
89424
|
+
}
|
|
89425
|
+
return "Error";
|
|
89426
|
+
}
|
|
89427
|
+
function getErrorStack(v) {
|
|
89428
|
+
if (types6.isNativeError(v)) {
|
|
89429
|
+
return v.stack ?? "";
|
|
89430
|
+
}
|
|
89431
|
+
return "";
|
|
89432
|
+
}
|
|
89433
|
+
function describeErrorLink(value) {
|
|
89434
|
+
if (typeof value !== "object" || value === null) {
|
|
89435
|
+
return String(value);
|
|
89436
|
+
}
|
|
89437
|
+
const { name, message, code: code3 } = value;
|
|
89438
|
+
const label = typeof name === "string" && name ? name : "Error";
|
|
89439
|
+
const text = typeof message === "string" && message ? `${label}: ${message}` : label;
|
|
89440
|
+
return typeof code3 === "string" && code3 && !text.includes(code3) ? `${text} (${code3})` : text;
|
|
89441
|
+
}
|
|
89442
|
+
function formatErrorCauseChain(value) {
|
|
89443
|
+
const lines = [];
|
|
89444
|
+
const seen = /* @__PURE__ */ new Set();
|
|
89445
|
+
try {
|
|
89446
|
+
for (let current = causeOf(value); current != null && lines.length <= MAX_CAUSE_LINKS; current = causeOf(current)) {
|
|
89447
|
+
if (typeof current !== "object") {
|
|
89448
|
+
lines.push(String(current));
|
|
89449
|
+
break;
|
|
89450
|
+
}
|
|
89451
|
+
if (seen.has(current))
|
|
89452
|
+
break;
|
|
89453
|
+
seen.add(current);
|
|
89454
|
+
lines.push(describeErrorLink(current), ...aggregatedLinks(current));
|
|
89455
|
+
}
|
|
89456
|
+
} catch {
|
|
89457
|
+
lines.push("[unavailable cause]");
|
|
89458
|
+
}
|
|
89459
|
+
return lines.length > MAX_CAUSE_LINKS ? [...lines.slice(0, MAX_CAUSE_LINKS), "\u2026"].join("\n") : lines.join("\n");
|
|
89460
|
+
}
|
|
89461
|
+
function causeOf(value) {
|
|
89462
|
+
return typeof value === "object" && value !== null ? value.cause : void 0;
|
|
89463
|
+
}
|
|
89464
|
+
function aggregatedLinks(value) {
|
|
89465
|
+
const errors = value.errors;
|
|
89466
|
+
return Array.isArray(errors) ? errors.slice(0, MAX_CAUSE_LINKS).map(describeErrorLink) : [];
|
|
89467
|
+
}
|
|
89468
|
+
function isAbortError(value) {
|
|
89469
|
+
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");
|
|
89470
|
+
}
|
|
89471
|
+
function promoteAbortErrorToFatal(value) {
|
|
89472
|
+
if (!isAbortError(value) || FatalError2.is(value)) {
|
|
89473
|
+
return value;
|
|
89474
|
+
}
|
|
89475
|
+
const fatalError = new FatalError2(`Aborted: ${value.message}`);
|
|
89476
|
+
if (value.stack) {
|
|
89477
|
+
fatalError.stack = value.stack;
|
|
89478
|
+
}
|
|
89479
|
+
return fatalError;
|
|
89480
|
+
}
|
|
89481
|
+
function isThenable(value) {
|
|
89482
|
+
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
89483
|
+
}
|
|
89484
|
+
function normalizeSyncError(v) {
|
|
89485
|
+
if (types6.isNativeError(v)) {
|
|
89486
|
+
return {
|
|
89487
|
+
name: v.name,
|
|
89488
|
+
message: v.message,
|
|
89489
|
+
stack: v.stack ?? ""
|
|
89490
|
+
};
|
|
89491
|
+
}
|
|
89492
|
+
if (typeof v === "string") {
|
|
89493
|
+
return {
|
|
89494
|
+
name: "Error",
|
|
89495
|
+
message: v,
|
|
89496
|
+
stack: ""
|
|
89497
|
+
};
|
|
89498
|
+
}
|
|
89499
|
+
try {
|
|
89500
|
+
return {
|
|
89501
|
+
name: "Error",
|
|
89502
|
+
message: JSON.stringify(v),
|
|
89503
|
+
stack: ""
|
|
89504
|
+
};
|
|
89505
|
+
} catch {
|
|
89506
|
+
return {
|
|
89507
|
+
name: "Error",
|
|
89508
|
+
message: String(v),
|
|
89509
|
+
stack: ""
|
|
89510
|
+
};
|
|
89511
|
+
}
|
|
89512
|
+
}
|
|
89513
|
+
async function normalizeUnknownError(value) {
|
|
89514
|
+
if (isThenable(value)) {
|
|
89515
|
+
try {
|
|
89516
|
+
const resolved = await value;
|
|
89517
|
+
const normalized = await normalizeUnknownError(resolved);
|
|
89518
|
+
return {
|
|
89519
|
+
...normalized,
|
|
89520
|
+
message: `Promise rejection: ${normalized.message}`
|
|
89521
|
+
};
|
|
89522
|
+
} catch (rejection) {
|
|
89523
|
+
const normalized = await normalizeUnknownError(rejection);
|
|
89524
|
+
return {
|
|
89525
|
+
...normalized,
|
|
89526
|
+
message: `Promise rejection: ${normalized.message}`
|
|
89527
|
+
};
|
|
89528
|
+
}
|
|
89529
|
+
}
|
|
89530
|
+
return normalizeSyncError(value);
|
|
89531
|
+
}
|
|
89532
|
+
var MAX_CAUSE_LINKS;
|
|
89533
|
+
var init_types4 = __esm({
|
|
89534
|
+
"../core/dist/types.js"() {
|
|
89535
|
+
"use strict";
|
|
89536
|
+
init_dist7();
|
|
89537
|
+
__name(getErrorName, "getErrorName");
|
|
89538
|
+
__name(getErrorStack, "getErrorStack");
|
|
89539
|
+
MAX_CAUSE_LINKS = 4;
|
|
89540
|
+
__name(describeErrorLink, "describeErrorLink");
|
|
89541
|
+
__name(formatErrorCauseChain, "formatErrorCauseChain");
|
|
89542
|
+
__name(causeOf, "causeOf");
|
|
89543
|
+
__name(aggregatedLinks, "aggregatedLinks");
|
|
89544
|
+
__name(isAbortError, "isAbortError");
|
|
89545
|
+
__name(promoteAbortErrorToFatal, "promoteAbortErrorToFatal");
|
|
89546
|
+
__name(isThenable, "isThenable");
|
|
89547
|
+
__name(normalizeSyncError, "normalizeSyncError");
|
|
89548
|
+
__name(normalizeUnknownError, "normalizeUnknownError");
|
|
89549
|
+
}
|
|
89550
|
+
});
|
|
89551
|
+
|
|
89552
|
+
// ../core/dist/attribute-changes.js
|
|
89553
|
+
var init_attribute_changes = __esm({
|
|
89554
|
+
"../core/dist/attribute-changes.js"() {
|
|
89555
|
+
"use strict";
|
|
89556
|
+
init_dist7();
|
|
89557
|
+
init_attributes_validation2();
|
|
89558
|
+
}
|
|
89559
|
+
});
|
|
89560
|
+
|
|
89561
|
+
// ../core/dist/runtime/vm-mode.js
|
|
89562
|
+
function getWorkflowVmFromEnv2(env = process.env) {
|
|
89563
|
+
const raw = env.WORKFLOW_VM;
|
|
89564
|
+
if (raw === void 0 || raw === "")
|
|
89565
|
+
return void 0;
|
|
89566
|
+
if (WORKFLOW_VMS2.includes(raw)) {
|
|
89567
|
+
return raw;
|
|
89568
|
+
}
|
|
89569
|
+
throw new WorkflowRuntimeError2(`Invalid WORKFLOW_VM value: "${raw}". Expected one of: ${WORKFLOW_VMS2.join(", ")}.`);
|
|
89570
|
+
}
|
|
89571
|
+
function useQuickJSVm(workflowRun) {
|
|
89572
|
+
const vmFromRun = workflowRun.executionContext?.workflowVm;
|
|
89573
|
+
if (vmFromRun !== void 0) {
|
|
89574
|
+
if (!WORKFLOW_VMS2.includes(vmFromRun)) {
|
|
89575
|
+
throw new WorkflowRuntimeError2(`Invalid executionContext.workflowVm value: "${vmFromRun}". Expected one of: ${WORKFLOW_VMS2.join(", ")}.`);
|
|
89576
|
+
}
|
|
89577
|
+
return vmFromRun === "quickjs";
|
|
89578
|
+
}
|
|
89579
|
+
return getWorkflowVmFromEnv2() === "quickjs";
|
|
89580
|
+
}
|
|
89581
|
+
var WORKFLOW_VMS2;
|
|
89582
|
+
var init_vm_mode = __esm({
|
|
89583
|
+
"../core/dist/runtime/vm-mode.js"() {
|
|
89584
|
+
"use strict";
|
|
89585
|
+
init_dist7();
|
|
89586
|
+
WORKFLOW_VMS2 = ["node", "quickjs"];
|
|
89587
|
+
__name(getWorkflowVmFromEnv2, "getWorkflowVmFromEnv");
|
|
89588
|
+
__name(useQuickJSVm, "useQuickJSVm");
|
|
89589
|
+
}
|
|
89590
|
+
});
|
|
89591
|
+
|
|
89592
|
+
// ../core/dist/runtime/start.js
|
|
89593
|
+
var ulid7, latestNoOpWarning2;
|
|
89594
|
+
var init_start = __esm({
|
|
89595
|
+
"../core/dist/runtime/start.js"() {
|
|
89596
|
+
"use strict";
|
|
89597
|
+
init_dist7();
|
|
89598
|
+
init_dist5();
|
|
89599
|
+
init_dist6();
|
|
89600
|
+
init_node2();
|
|
89601
|
+
init_attribute_changes();
|
|
89602
|
+
init_capabilities2();
|
|
89603
|
+
init_classify_error();
|
|
89604
|
+
init_encryption4();
|
|
89605
|
+
init_logger2();
|
|
89606
|
+
init_sealed_box2();
|
|
89607
|
+
init_serialization4();
|
|
89608
|
+
init_context_storage2();
|
|
89609
|
+
init_semantic_conventions2();
|
|
89610
|
+
init_telemetry4();
|
|
89611
|
+
init_version4();
|
|
89612
|
+
init_get_world_lazy2();
|
|
89613
|
+
init_helpers3();
|
|
89614
|
+
init_run();
|
|
89615
|
+
init_vm_mode();
|
|
89616
|
+
init_wait_until2();
|
|
89617
|
+
init_world_compatibility2();
|
|
89618
|
+
ulid7 = monotonicFactory2();
|
|
89619
|
+
latestNoOpWarning2 = globalSingleton2("@workflow/core//latestNoOpWarning", 1, () => ({ warned: false }));
|
|
89620
|
+
}
|
|
89621
|
+
});
|
|
89622
|
+
|
|
89623
|
+
// ../core/dist/runtime/runs.js
|
|
89624
|
+
async function wakeUpRun2(world, runId, options) {
|
|
89625
|
+
try {
|
|
89626
|
+
const run3 = await world.runs.get(runId, { resolveData: "none" });
|
|
89627
|
+
const compatMode = isLegacySpecVersion2(run3.specVersion);
|
|
89628
|
+
const allEvents = [];
|
|
89629
|
+
let cursor = null;
|
|
89630
|
+
do {
|
|
89631
|
+
const eventsResult = await world.events.list({
|
|
89632
|
+
runId,
|
|
89633
|
+
pagination: { sortOrder: "asc", ...cursor ? { cursor } : {} },
|
|
89634
|
+
resolveData: "none"
|
|
89635
|
+
});
|
|
89636
|
+
allEvents.push(...eventsResult.data);
|
|
89637
|
+
cursor = eventsResult.hasMore ? eventsResult.cursor : null;
|
|
89638
|
+
} while (cursor);
|
|
89639
|
+
const waitCreatedEvents = allEvents.filter((event) => event.eventType === "wait_created");
|
|
89640
|
+
const waitCompletedCorrelationIds = new Set(allEvents.filter((event) => event.eventType === "wait_completed").map((event) => event.correlationId));
|
|
89641
|
+
let pendingWaits = waitCreatedEvents.filter((event) => !waitCompletedCorrelationIds.has(event.correlationId));
|
|
89642
|
+
if (options?.correlationIds && options.correlationIds.length > 0) {
|
|
89643
|
+
const targetCorrelationIds = new Set(options.correlationIds);
|
|
89644
|
+
pendingWaits = pendingWaits.filter((event) => event.correlationId && targetCorrelationIds.has(event.correlationId));
|
|
89645
|
+
}
|
|
89646
|
+
const errors = [];
|
|
89647
|
+
let stoppedCount = 0;
|
|
89648
|
+
for (const waitEvent of pendingWaits) {
|
|
89649
|
+
if (!waitEvent.correlationId)
|
|
89650
|
+
continue;
|
|
89651
|
+
const eventData = compatMode ? {
|
|
89652
|
+
eventType: "wait_completed",
|
|
89653
|
+
correlationId: waitEvent.correlationId
|
|
89654
|
+
} : {
|
|
89655
|
+
eventType: "wait_completed",
|
|
89656
|
+
correlationId: waitEvent.correlationId,
|
|
89657
|
+
specVersion: run3.specVersion,
|
|
89658
|
+
eventData: {
|
|
89659
|
+
resumeAt: waitEvent.eventData.resumeAt
|
|
89660
|
+
}
|
|
89661
|
+
};
|
|
89662
|
+
try {
|
|
89663
|
+
await world.events.create(runId, eventData, { v1Compat: compatMode });
|
|
89664
|
+
stoppedCount++;
|
|
89665
|
+
} catch (err) {
|
|
89666
|
+
if (EntityConflictError2.is(err)) {
|
|
89667
|
+
stoppedCount++;
|
|
89668
|
+
} else {
|
|
89669
|
+
errors.push(err instanceof Error ? err : new Error(String(err)));
|
|
89670
|
+
}
|
|
89671
|
+
}
|
|
89672
|
+
}
|
|
89673
|
+
if (stoppedCount > 0) {
|
|
89674
|
+
await world.queue(getWorkflowQueueName2(run3.workflowName, options?.namespace), {
|
|
89675
|
+
runId
|
|
89676
|
+
}, {
|
|
89677
|
+
deploymentId: run3.deploymentId,
|
|
89678
|
+
specVersion: run3.specVersion ?? SPEC_VERSION_LEGACY2
|
|
89679
|
+
});
|
|
89680
|
+
}
|
|
89681
|
+
if (errors.length > 0) {
|
|
89682
|
+
throw new AggregateError(errors, `Failed to complete ${errors.length}/${pendingWaits.length} pending wait(s) for run ${runId}`);
|
|
89683
|
+
}
|
|
89684
|
+
return { stoppedCount };
|
|
89685
|
+
} catch (err) {
|
|
89686
|
+
if (err instanceof AggregateError) {
|
|
89687
|
+
throw err;
|
|
89688
|
+
}
|
|
89689
|
+
throw new Error(`Failed to wake up run ${runId}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
89690
|
+
}
|
|
89691
|
+
}
|
|
89692
|
+
var init_runs4 = __esm({
|
|
89693
|
+
"../core/dist/runtime/runs.js"() {
|
|
89694
|
+
"use strict";
|
|
89695
|
+
init_dist7();
|
|
89696
|
+
init_dist6();
|
|
89697
|
+
init_encryption5();
|
|
89698
|
+
init_serialization4();
|
|
89699
|
+
init_helpers3();
|
|
89700
|
+
init_start();
|
|
89701
|
+
__name(wakeUpRun2, "wakeUpRun");
|
|
89702
|
+
}
|
|
89703
|
+
});
|
|
89704
|
+
|
|
89705
|
+
// ../core/dist/runtime/run.js
|
|
89706
|
+
function getReturnValuePollIntervalMs2() {
|
|
89707
|
+
return envNumber2("WORKFLOW_RETURN_VALUE_POLL_INTERVAL_MS", RETURN_VALUE_POLL_INTERVAL_MS2, { integer: true, min: 1 });
|
|
89708
|
+
}
|
|
89709
|
+
function getReturnValueWaitTimeoutMs2() {
|
|
89710
|
+
return envNumber2("WORKFLOW_RETURN_VALUE_WAIT_MS", RETURN_VALUE_WAIT_TIMEOUT_MS2, { integer: true, min: 1 });
|
|
89711
|
+
}
|
|
89712
|
+
function getReturnValueMaxLongPolls2() {
|
|
89713
|
+
return envNumber2("WORKFLOW_RETURN_VALUE_MAX_LONG_POLLS", RETURN_VALUE_MAX_LONG_POLLS2, { integer: true, min: 1 });
|
|
89714
|
+
}
|
|
89715
|
+
function isReturnValueLongPollEnabled2() {
|
|
89716
|
+
const raw = process.env.WORKFLOW_RETURN_VALUE_LONG_POLL;
|
|
89717
|
+
if (raw === void 0 || raw === "")
|
|
89718
|
+
return true;
|
|
89719
|
+
return !(raw === "0" || raw.toLowerCase() === "false");
|
|
89720
|
+
}
|
|
89721
|
+
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;
|
|
89722
|
+
var init_run = __esm({
|
|
89723
|
+
"../core/dist/runtime/run.js"() {
|
|
89724
|
+
"use strict";
|
|
89725
|
+
init_dist7();
|
|
89726
|
+
init_dist12();
|
|
89727
|
+
init_env_config2();
|
|
89728
|
+
init_spec_version2();
|
|
89729
|
+
init_encryption5();
|
|
89730
|
+
init_serialization4();
|
|
89731
|
+
init_util5();
|
|
89732
|
+
init_get_world_lazy2();
|
|
89733
|
+
init_runs4();
|
|
89734
|
+
RETURN_VALUE_POLL_INTERVAL_MS2 = 1e3;
|
|
89735
|
+
PAYLOAD_TERMINAL_RUN_STATUSES2 = /* @__PURE__ */ new Set([
|
|
89736
|
+
"completed",
|
|
89737
|
+
"failed"
|
|
89738
|
+
]);
|
|
89739
|
+
NOT_FOUND_RETRY_DELAYS2 = [1e3, 3e3, 6e3];
|
|
89740
|
+
__name(getReturnValuePollIntervalMs2, "getReturnValuePollIntervalMs");
|
|
89741
|
+
RETURN_VALUE_WAIT_TIMEOUT_MS2 = 5e4;
|
|
89742
|
+
__name(getReturnValueWaitTimeoutMs2, "getReturnValueWaitTimeoutMs");
|
|
89743
|
+
RETURN_VALUE_MAX_LONG_POLLS2 = 10;
|
|
89744
|
+
__name(getReturnValueMaxLongPolls2, "getReturnValueMaxLongPolls");
|
|
89745
|
+
__name(isReturnValueLongPollEnabled2, "isReturnValueLongPollEnabled");
|
|
89746
|
+
Run2 = class _Run2 {
|
|
89747
|
+
static {
|
|
89748
|
+
__name(this, "Run");
|
|
89749
|
+
}
|
|
89750
|
+
static [WORKFLOW_SERIALIZE2](instance) {
|
|
89751
|
+
return { runId: instance.runId, resilientStart: instance.#resilientStart };
|
|
89752
|
+
}
|
|
89753
|
+
static [WORKFLOW_DESERIALIZE2](data) {
|
|
89754
|
+
return new _Run2(data.runId, { resilientStart: data.resilientStart });
|
|
89755
|
+
}
|
|
89756
|
+
/**
|
|
89757
|
+
* The ID of the workflow run.
|
|
89758
|
+
*/
|
|
89759
|
+
runId;
|
|
89760
|
+
/**
|
|
89761
|
+
* The world object.
|
|
89762
|
+
* @internal
|
|
89763
|
+
*/
|
|
89764
|
+
#worldPromise;
|
|
89765
|
+
get #lazyWorldPromise() {
|
|
89766
|
+
if (!this.#worldPromise)
|
|
89767
|
+
this.#worldPromise = getWorldLazy2();
|
|
89768
|
+
return this.#worldPromise;
|
|
89769
|
+
}
|
|
89770
|
+
/**
|
|
89771
|
+
* Cached encryption key resolution. Resolved once on first use and
|
|
89772
|
+
* reused for returnValue, getReadable(), etc.
|
|
89773
|
+
* @internal
|
|
89774
|
+
*/
|
|
89775
|
+
#encryptionKeyPromise = null;
|
|
89776
|
+
/**
|
|
89777
|
+
* When true, run_created failed and the run may not exist yet (the
|
|
89778
|
+
* resilient start path will create it via run_started). pollReturnValue
|
|
89779
|
+
* retries on WorkflowRunNotFoundError only when this flag is set so
|
|
89780
|
+
* that normal runs fail fast on 404.
|
|
89781
|
+
* @internal
|
|
89782
|
+
*/
|
|
89783
|
+
#resilientStart = false;
|
|
89784
|
+
constructor(runId, opts) {
|
|
89785
|
+
this.runId = runId;
|
|
89786
|
+
this.#resilientStart = opts?.resilientStart ?? false;
|
|
89787
|
+
}
|
|
89788
|
+
/**
|
|
89789
|
+
* Resolves and caches the encryption key for this run.
|
|
89790
|
+
* The key is the same for the lifetime of a run, so it only needs
|
|
89791
|
+
* to be resolved once.
|
|
89792
|
+
* @internal
|
|
89793
|
+
*/
|
|
89794
|
+
#getEncryptionKey(run3) {
|
|
89795
|
+
if (!this.#encryptionKeyPromise) {
|
|
89796
|
+
this.#encryptionKeyPromise = (async () => {
|
|
89797
|
+
const world = await this.#lazyWorldPromise;
|
|
89798
|
+
const runData = run3 ?? await world.runs.get(this.runId);
|
|
89799
|
+
const rawKey = await world.getEncryptionKeyForRun?.(runData);
|
|
89800
|
+
return rawKey ? await deriveRunPayloadKeys2(rawKey) : void 0;
|
|
89801
|
+
})();
|
|
89802
|
+
}
|
|
89803
|
+
return this.#encryptionKeyPromise;
|
|
89804
|
+
}
|
|
89805
|
+
/**
|
|
89806
|
+
* Defers fetching the run and its encryption key until a readable is first
|
|
89807
|
+
* consumed. The first pull prefetches it so an encrypted first frame can join
|
|
89808
|
+
* the lookup; this also applies to an empty consumed stream.
|
|
89809
|
+
* @internal
|
|
89810
|
+
*/
|
|
89811
|
+
#getEncryptionKeyLazily() {
|
|
89812
|
+
return () => this.#getEncryptionKey();
|
|
89813
|
+
}
|
|
89814
|
+
/**
|
|
89815
|
+
* Interrupts pending `sleep()` calls, resuming the workflow early.
|
|
89816
|
+
*
|
|
89817
|
+
* @param options - Optional settings to target specific sleep calls by correlation ID.
|
|
89818
|
+
* If not provided, all pending sleep calls will be interrupted.
|
|
89819
|
+
* @returns A {@link StopSleepResult} object containing the number of sleep calls that were interrupted.
|
|
89820
|
+
*/
|
|
89821
|
+
async wakeUp(options) {
|
|
89822
|
+
"use step";
|
|
89823
|
+
return wakeUpRun2(await this.#lazyWorldPromise, this.runId, options);
|
|
89824
|
+
}
|
|
89825
|
+
/**
|
|
89826
|
+
* Cancels the workflow run.
|
|
89827
|
+
*
|
|
89828
|
+
* @param options - Optional cancellation settings. `cancelReason` records a
|
|
89829
|
+
* free-text reason (max 512 chars) on the run_cancelled event, surfaced in
|
|
89830
|
+
* the run detail view.
|
|
89831
|
+
*/
|
|
89832
|
+
async cancel(options) {
|
|
89833
|
+
"use step";
|
|
89834
|
+
const world = await this.#lazyWorldPromise;
|
|
89835
|
+
await world.events.create(this.runId, {
|
|
89836
|
+
eventType: "run_cancelled",
|
|
89837
|
+
specVersion: SPEC_VERSION_CURRENT2,
|
|
89838
|
+
...options?.cancelReason !== void 0 ? { eventData: { cancelReason: options.cancelReason } } : {}
|
|
89839
|
+
});
|
|
89840
|
+
}
|
|
89841
|
+
/**
|
|
89842
|
+
* Whether the workflow run exists.
|
|
89843
|
+
*/
|
|
89844
|
+
get exists() {
|
|
89845
|
+
"use step";
|
|
89846
|
+
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId, { resolveData: "none" }).then(() => true).catch((error121) => {
|
|
89847
|
+
if (WorkflowRunNotFoundError2.is(error121)) {
|
|
89848
|
+
return false;
|
|
89849
|
+
}
|
|
89850
|
+
throw error121;
|
|
89851
|
+
}));
|
|
89852
|
+
}
|
|
89853
|
+
/**
|
|
89854
|
+
* The status of the workflow run.
|
|
89855
|
+
*/
|
|
89856
|
+
get status() {
|
|
89857
|
+
"use step";
|
|
89858
|
+
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId, { resolveData: "none" }).then((run3) => run3.status));
|
|
89859
|
+
}
|
|
89860
|
+
/**
|
|
89861
|
+
* The return value of the workflow run.
|
|
89862
|
+
* Polls the workflow return value until the workflow run completes.
|
|
89863
|
+
*/
|
|
89864
|
+
get returnValue() {
|
|
89865
|
+
"use step";
|
|
89866
|
+
return this.#pollReturnValue();
|
|
89867
|
+
}
|
|
89868
|
+
/**
|
|
89869
|
+
* The name of the workflow.
|
|
89870
|
+
*/
|
|
89871
|
+
get workflowName() {
|
|
89872
|
+
"use step";
|
|
89873
|
+
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId, { resolveData: "none" }).then((run3) => run3.workflowName));
|
|
89874
|
+
}
|
|
89875
|
+
/**
|
|
89876
|
+
* The timestamp when the workflow run was created.
|
|
89877
|
+
*/
|
|
89878
|
+
get createdAt() {
|
|
89879
|
+
"use step";
|
|
89880
|
+
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId, { resolveData: "none" }).then((run3) => run3.createdAt));
|
|
89881
|
+
}
|
|
89882
|
+
/**
|
|
89883
|
+
* The timestamp when the workflow run started execution.
|
|
89884
|
+
* Returns undefined if the workflow has not started yet.
|
|
89885
|
+
*/
|
|
89886
|
+
get startedAt() {
|
|
89887
|
+
"use step";
|
|
89888
|
+
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId, { resolveData: "none" }).then((run3) => run3.startedAt));
|
|
89889
|
+
}
|
|
89890
|
+
/**
|
|
89891
|
+
* The timestamp when the workflow run completed.
|
|
89892
|
+
* Returns undefined if the workflow has not completed yet.
|
|
89893
|
+
*/
|
|
89894
|
+
get completedAt() {
|
|
89895
|
+
"use step";
|
|
89896
|
+
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId, { resolveData: "none" }).then((run3) => run3.completedAt));
|
|
89897
|
+
}
|
|
89898
|
+
/**
|
|
89899
|
+
* The readable stream of the workflow run.
|
|
89900
|
+
*/
|
|
89901
|
+
get readable() {
|
|
89902
|
+
return this.getReadable();
|
|
89903
|
+
}
|
|
89904
|
+
/**
|
|
89905
|
+
* Retrieves the workflow run's default readable stream, which reads chunks
|
|
89906
|
+
* written to the corresponding writable stream {@link getWritable}.
|
|
89907
|
+
*
|
|
89908
|
+
* The returned stream has an additional {@link WorkflowReadableStream.getTailIndex | getTailIndex()}
|
|
89909
|
+
* helper that returns the index of the last known chunk. This is useful when
|
|
89910
|
+
* building reconnection endpoints that need to inform clients where the
|
|
89911
|
+
* stream starts.
|
|
89912
|
+
*
|
|
89913
|
+
* @param options - The options for the readable stream.
|
|
89914
|
+
* @returns A `WorkflowReadableStream` for the workflow run.
|
|
89915
|
+
*/
|
|
89916
|
+
getReadable(options = {}) {
|
|
89917
|
+
"use step";
|
|
89918
|
+
const { ops = [], global: global2 = globalThis, startIndex, namespace } = options;
|
|
89919
|
+
const name = getWorkflowRunStreamId2(this.runId, namespace);
|
|
89920
|
+
const encryptionKey = this.#getEncryptionKeyLazily();
|
|
89921
|
+
const stream = getRunReadableStream2(global2, ops, this.runId, name, startIndex, encryptionKey);
|
|
89922
|
+
const worldPromise = this.#lazyWorldPromise;
|
|
89923
|
+
const runId = this.runId;
|
|
89924
|
+
return Object.assign(stream, {
|
|
89925
|
+
getTailIndex: /* @__PURE__ */ __name(async () => {
|
|
89926
|
+
const world = await worldPromise;
|
|
89927
|
+
const info = await world.streams.getInfo(runId, name);
|
|
89928
|
+
return info.tailIndex;
|
|
89929
|
+
}, "getTailIndex")
|
|
89930
|
+
});
|
|
89931
|
+
}
|
|
89932
|
+
/** The writable stream of the workflow run. */
|
|
89933
|
+
get writable() {
|
|
89934
|
+
return this.getWritable();
|
|
89935
|
+
}
|
|
89936
|
+
/**
|
|
89937
|
+
* Returns a writable that appends to this run's stream.
|
|
89938
|
+
*
|
|
89939
|
+
* Initialization is deferred until the first write. The run must already
|
|
89940
|
+
* exist. The writable may be forwarded through `start()` and into steps, but
|
|
89941
|
+
* grants no read access or additional authorization.
|
|
89942
|
+
*
|
|
89943
|
+
* @remarks
|
|
89944
|
+
* `writer.close()` closes the shared stream. Contributors should call
|
|
89945
|
+
* `releaseLock()`, which also drains pending writes.
|
|
89946
|
+
*
|
|
89947
|
+
* @param options - The writable stream options.
|
|
89948
|
+
*/
|
|
89949
|
+
getWritable(options = {}) {
|
|
89950
|
+
"use step";
|
|
89951
|
+
const { ops = [], global: global2 = globalThis, namespace } = options;
|
|
89952
|
+
const name = getWorkflowRunStreamId2(this.runId, namespace);
|
|
89953
|
+
let targetPromise;
|
|
89954
|
+
let writable;
|
|
89955
|
+
const resolveTarget = /* @__PURE__ */ __name(() => {
|
|
89956
|
+
targetPromise ??= this.#getMetadata().then(async (run3) => {
|
|
89957
|
+
const target2 = {
|
|
89958
|
+
key: await getForwardedWritableEncryptionKey2(this.runId, run3.deploymentId, run3.encryptionPublicKey),
|
|
89959
|
+
deploymentId: run3.deploymentId,
|
|
89960
|
+
encryptionPublicKey: run3.encryptionPublicKey
|
|
89961
|
+
};
|
|
89962
|
+
tagForwardedWritableTarget2(writable, target2);
|
|
89963
|
+
return target2;
|
|
89964
|
+
});
|
|
89965
|
+
return targetPromise;
|
|
89966
|
+
}, "resolveTarget");
|
|
89967
|
+
writable = createForwardedWritable2({
|
|
89968
|
+
global: global2,
|
|
89969
|
+
ops,
|
|
89970
|
+
runId: this.runId,
|
|
89971
|
+
name,
|
|
89972
|
+
key: /* @__PURE__ */ __name(() => resolveTarget().then(({ key }) => key), "key")
|
|
89973
|
+
});
|
|
89974
|
+
return writable;
|
|
89975
|
+
}
|
|
89976
|
+
/** Reads metadata, briefly retrying resilient starts. @internal */
|
|
89977
|
+
async #getMetadata() {
|
|
89978
|
+
const world = await this.#lazyWorldPromise;
|
|
89979
|
+
const maxRetries = this.#resilientStart ? NOT_FOUND_RETRY_DELAYS2.length : 0;
|
|
89980
|
+
let attempt = 0;
|
|
89981
|
+
while (true) {
|
|
89982
|
+
try {
|
|
89983
|
+
return await world.runs.get(this.runId, { resolveData: "none" });
|
|
89984
|
+
} catch (error121) {
|
|
89985
|
+
if (!WorkflowRunNotFoundError2.is(error121) || attempt >= maxRetries) {
|
|
89986
|
+
throw error121;
|
|
89987
|
+
}
|
|
89988
|
+
const delay = NOT_FOUND_RETRY_DELAYS2[attempt];
|
|
89989
|
+
attempt++;
|
|
89990
|
+
await new Promise((resolve3) => setTimeout(resolve3, delay));
|
|
89991
|
+
}
|
|
89992
|
+
}
|
|
89993
|
+
}
|
|
89994
|
+
/** @internal */
|
|
89995
|
+
async #resolveTerminalReturnValue(run3) {
|
|
89996
|
+
const expiredAt = run3.expiredAt;
|
|
89997
|
+
if (expiredAt != null && expiredAt <= /* @__PURE__ */ new Date()) {
|
|
89998
|
+
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);
|
|
89999
|
+
}
|
|
90000
|
+
if (run3.status === "completed") {
|
|
90001
|
+
const encryptionKey = await this.#getEncryptionKey(run3);
|
|
90002
|
+
return await hydrateWorkflowReturnValue2(run3.output, this.runId, encryptionKey);
|
|
90003
|
+
}
|
|
90004
|
+
if (run3.status === "cancelled") {
|
|
90005
|
+
throw new WorkflowRunCancelledError2(this.runId);
|
|
90006
|
+
}
|
|
90007
|
+
if (run3.status === "failed") {
|
|
90008
|
+
const encryptionKey = await this.#getEncryptionKey(run3);
|
|
90009
|
+
let hydratedError;
|
|
90010
|
+
try {
|
|
90011
|
+
hydratedError = await hydrateRunError2(run3.error, this.runId, encryptionKey);
|
|
90012
|
+
} catch {
|
|
90013
|
+
hydratedError = new Error("Failed to hydrate workflow run error");
|
|
90014
|
+
}
|
|
90015
|
+
throw new WorkflowRunFailedError2(this.runId, hydratedError, {
|
|
90016
|
+
errorCode: run3.errorCode
|
|
90017
|
+
});
|
|
90018
|
+
}
|
|
90019
|
+
throw new WorkflowRunNotCompletedError2(this.runId, run3.status);
|
|
90020
|
+
}
|
|
90021
|
+
/**
|
|
90022
|
+
* Polls the workflow return value until the workflow run completes.
|
|
90023
|
+
* @internal
|
|
90024
|
+
* @returns The workflow return value.
|
|
90025
|
+
*/
|
|
90026
|
+
async #pollReturnValue() {
|
|
90027
|
+
const world = await this.#lazyWorldPromise;
|
|
90028
|
+
let notFoundRetries = 0;
|
|
90029
|
+
const NOT_FOUND_MAX_RETRIES = this.#resilientStart ? NOT_FOUND_RETRY_DELAYS2.length : 0;
|
|
90030
|
+
const waitForTerminalStatus = isReturnValueLongPollEnabled2() ? world.runs.waitForTerminalStatus?.bind(world.runs) : void 0;
|
|
90031
|
+
let longPolls = 0;
|
|
90032
|
+
const maxLongPolls = getReturnValueMaxLongPolls2();
|
|
90033
|
+
while (true) {
|
|
90034
|
+
const iterationStartedAt = Date.now();
|
|
90035
|
+
try {
|
|
90036
|
+
const useLongPoll = waitForTerminalStatus && longPolls < maxLongPolls;
|
|
90037
|
+
if (useLongPoll)
|
|
90038
|
+
longPolls++;
|
|
90039
|
+
const runMetadata = useLongPoll ? await waitForTerminalStatus(this.runId, {
|
|
90040
|
+
timeoutMs: getReturnValueWaitTimeoutMs2(),
|
|
90041
|
+
resolveData: "none"
|
|
90042
|
+
}) : await world.runs.get(this.runId, {
|
|
90043
|
+
resolveData: "none"
|
|
90044
|
+
});
|
|
90045
|
+
if (runMetadata.status === "cancelled") {
|
|
90046
|
+
throw new WorkflowRunCancelledError2(this.runId);
|
|
90047
|
+
}
|
|
90048
|
+
if (PAYLOAD_TERMINAL_RUN_STATUSES2.has(runMetadata.status)) {
|
|
90049
|
+
const run3 = await world.runs.get(this.runId, {
|
|
90050
|
+
resolveData: "all"
|
|
90051
|
+
});
|
|
90052
|
+
return await this.#resolveTerminalReturnValue(run3);
|
|
90053
|
+
}
|
|
90054
|
+
throw new WorkflowRunNotCompletedError2(this.runId, runMetadata.status);
|
|
90055
|
+
} catch (error121) {
|
|
90056
|
+
if (WorkflowRunNotCompletedError2.is(error121)) {
|
|
90057
|
+
const remainingIntervalMs = getReturnValuePollIntervalMs2() - (Date.now() - iterationStartedAt);
|
|
90058
|
+
if (remainingIntervalMs > 0) {
|
|
90059
|
+
await new Promise((resolve3) => setTimeout(resolve3, remainingIntervalMs));
|
|
90060
|
+
}
|
|
90061
|
+
continue;
|
|
90062
|
+
}
|
|
90063
|
+
if (WorkflowRunNotFoundError2.is(error121) && notFoundRetries < NOT_FOUND_MAX_RETRIES) {
|
|
90064
|
+
const delay = NOT_FOUND_RETRY_DELAYS2[notFoundRetries];
|
|
90065
|
+
notFoundRetries++;
|
|
90066
|
+
await new Promise((resolve3) => setTimeout(resolve3, delay));
|
|
90067
|
+
continue;
|
|
90068
|
+
}
|
|
90069
|
+
throw error121;
|
|
90070
|
+
}
|
|
90071
|
+
}
|
|
90072
|
+
}
|
|
90073
|
+
};
|
|
90074
|
+
}
|
|
90075
|
+
});
|
|
90076
|
+
|
|
90077
|
+
// ../core/dist/runtime/lifecycle-hooks.js
|
|
90078
|
+
function getRegistry3() {
|
|
90079
|
+
if (!Object.hasOwn(globalThis, REGISTRY_KEY)) {
|
|
90080
|
+
Object.defineProperty(globalThis, REGISTRY_KEY, {
|
|
90081
|
+
value: [],
|
|
90082
|
+
writable: false,
|
|
90083
|
+
enumerable: false,
|
|
90084
|
+
configurable: false
|
|
90085
|
+
});
|
|
90086
|
+
}
|
|
90087
|
+
return globalThis[REGISTRY_KEY];
|
|
90088
|
+
}
|
|
90089
|
+
function dispatch(runId, workflowName, event, prepare, invoke) {
|
|
90090
|
+
const registered = getRegistry3().filter((hooks) => hooks[event]);
|
|
90091
|
+
if (registered.length === 0) {
|
|
90092
|
+
return;
|
|
90093
|
+
}
|
|
90094
|
+
safeWaitUntil2(
|
|
90095
|
+
trace5(`workflow.lifecycle.${event}`, async () => {
|
|
90096
|
+
const params = await prepare();
|
|
90097
|
+
for (const hooks of registered) {
|
|
90098
|
+
try {
|
|
90099
|
+
await invoke(hooks, params);
|
|
90100
|
+
} catch (err) {
|
|
90101
|
+
runtimeLogger2.error(`Workflow lifecycle ${event} handler threw`, {
|
|
90102
|
+
workflowRunId: runId,
|
|
90103
|
+
workflowName,
|
|
90104
|
+
errorName: getErrorName(err),
|
|
90105
|
+
errorMessage: err instanceof Error ? err.message : String(err),
|
|
90106
|
+
errorStack: getErrorStack(err)
|
|
90107
|
+
});
|
|
90108
|
+
}
|
|
90109
|
+
}
|
|
90110
|
+
}),
|
|
90111
|
+
// Covers a `prepare()` rejection; handler failures are caught above.
|
|
90112
|
+
(err) => {
|
|
90113
|
+
runtimeLogger2.error(`Workflow lifecycle ${event} dispatch failed`, {
|
|
90114
|
+
workflowRunId: runId,
|
|
90115
|
+
workflowName,
|
|
90116
|
+
errorName: getErrorName(err),
|
|
90117
|
+
errorMessage: err instanceof Error ? err.message : String(err),
|
|
90118
|
+
errorStack: getErrorStack(err)
|
|
90119
|
+
});
|
|
90120
|
+
}
|
|
90121
|
+
);
|
|
90122
|
+
}
|
|
90123
|
+
function dispatchRunCompletedHooks(runId, workflowName) {
|
|
90124
|
+
dispatch(runId, workflowName, "onRunCompleted", async () => ({ run: new Run2(runId), workflowName }), (hooks, params) => hooks.onRunCompleted?.(params));
|
|
90125
|
+
}
|
|
90126
|
+
async function hydrateForHandlers(error121, runId, encryptionKey) {
|
|
90127
|
+
try {
|
|
90128
|
+
const ops = [];
|
|
90129
|
+
return await hydrateRunError2(error121, runId, encryptionKey, ops, globalThis, getExternalRevivers2(globalThis, ops, runId, encryptionKey, {
|
|
90130
|
+
lazyStreams: true,
|
|
90131
|
+
liveAbortSignals: false
|
|
90132
|
+
}));
|
|
90133
|
+
} catch {
|
|
90134
|
+
return new Error("Failed to hydrate workflow run error");
|
|
90135
|
+
}
|
|
90136
|
+
}
|
|
90137
|
+
function dispatchRunFailedHooks(runId, workflowName, error121, encryptionKey, errorCode) {
|
|
90138
|
+
dispatch(runId, workflowName, "onRunFailed", async () => ({
|
|
90139
|
+
run: new Run2(runId),
|
|
90140
|
+
workflowName,
|
|
90141
|
+
error: new WorkflowRunFailedError2(runId, await hydrateForHandlers(error121, runId, encryptionKey), { errorCode })
|
|
90142
|
+
}), (hooks, params) => hooks.onRunFailed?.(params));
|
|
90143
|
+
}
|
|
90144
|
+
var REGISTRY_KEY;
|
|
90145
|
+
var init_lifecycle_hooks = __esm({
|
|
90146
|
+
"../core/dist/runtime/lifecycle-hooks.js"() {
|
|
90147
|
+
"use strict";
|
|
90148
|
+
init_dist7();
|
|
90149
|
+
init_logger2();
|
|
90150
|
+
init_serialization4();
|
|
90151
|
+
init_telemetry4();
|
|
90152
|
+
init_types4();
|
|
90153
|
+
init_run();
|
|
90154
|
+
init_wait_until2();
|
|
90155
|
+
REGISTRY_KEY = /* @__PURE__ */ Symbol.for("@workflow/core//lifecycleHooks");
|
|
90156
|
+
__name(getRegistry3, "getRegistry");
|
|
90157
|
+
__name(dispatch, "dispatch");
|
|
90158
|
+
__name(dispatchRunCompletedHooks, "dispatchRunCompletedHooks");
|
|
90159
|
+
__name(hydrateForHandlers, "hydrateForHandlers");
|
|
90160
|
+
__name(dispatchRunFailedHooks, "dispatchRunFailedHooks");
|
|
90161
|
+
}
|
|
90162
|
+
});
|
|
90163
|
+
|
|
89156
90164
|
// ../core/dist/runtime/replay-budget.js
|
|
89157
90165
|
async function handleReplayBudgetExhausted(args) {
|
|
89158
90166
|
const { runId, workflowName, requestId, attempt, limitMs, slotSnapshot } = args;
|
|
@@ -89177,14 +90185,17 @@ async function handleReplayBudgetExhausted(args) {
|
|
|
89177
90185
|
});
|
|
89178
90186
|
const getEncryptionKey = memoizeEncryptionKey(world, runId);
|
|
89179
90187
|
const timeoutErr = new FatalError2(`Workflow replay exceeded maximum duration (${limitMs / 1e3}s) after ${attempt} attempts`);
|
|
90188
|
+
const encryptionKey = await getEncryptionKey();
|
|
90189
|
+
const dehydratedError = await dehydrateRunError(timeoutErr, runId, encryptionKey);
|
|
89180
90190
|
await world.events.create(runId, {
|
|
89181
90191
|
eventType: "run_failed",
|
|
89182
90192
|
specVersion: SPEC_VERSION_CURRENT2,
|
|
89183
90193
|
eventData: {
|
|
89184
|
-
error:
|
|
90194
|
+
error: dehydratedError,
|
|
89185
90195
|
errorCode: RUN_ERROR_CODES2.REPLAY_TIMEOUT
|
|
89186
90196
|
}
|
|
89187
90197
|
}, { requestId, ...slotSnapshot });
|
|
90198
|
+
dispatchRunFailedHooks(runId, workflowName, dehydratedError, encryptionKey, RUN_ERROR_CODES2.REPLAY_TIMEOUT);
|
|
89188
90199
|
}
|
|
89189
90200
|
var ReplayBudget, ReplayTimeoutRetryError;
|
|
89190
90201
|
var init_replay_budget = __esm({
|
|
@@ -89197,6 +90208,7 @@ var init_replay_budget = __esm({
|
|
|
89197
90208
|
init_serialization4();
|
|
89198
90209
|
init_constants3();
|
|
89199
90210
|
init_helpers3();
|
|
90211
|
+
init_lifecycle_hooks();
|
|
89200
90212
|
init_world();
|
|
89201
90213
|
ReplayBudget = class {
|
|
89202
90214
|
static {
|
|
@@ -89452,139 +90464,6 @@ var init_run_id_time = __esm({
|
|
|
89452
90464
|
}
|
|
89453
90465
|
});
|
|
89454
90466
|
|
|
89455
|
-
// ../core/dist/types.js
|
|
89456
|
-
import { types as types6 } from "node:util";
|
|
89457
|
-
function getErrorName(v) {
|
|
89458
|
-
if (types6.isNativeError(v)) {
|
|
89459
|
-
return v.name;
|
|
89460
|
-
}
|
|
89461
|
-
return "Error";
|
|
89462
|
-
}
|
|
89463
|
-
function getErrorStack(v) {
|
|
89464
|
-
if (types6.isNativeError(v)) {
|
|
89465
|
-
return v.stack ?? "";
|
|
89466
|
-
}
|
|
89467
|
-
return "";
|
|
89468
|
-
}
|
|
89469
|
-
function describeErrorLink(value) {
|
|
89470
|
-
if (typeof value !== "object" || value === null) {
|
|
89471
|
-
return String(value);
|
|
89472
|
-
}
|
|
89473
|
-
const { name, message, code: code3 } = value;
|
|
89474
|
-
const label = typeof name === "string" && name ? name : "Error";
|
|
89475
|
-
const text = typeof message === "string" && message ? `${label}: ${message}` : label;
|
|
89476
|
-
return typeof code3 === "string" && code3 && !text.includes(code3) ? `${text} (${code3})` : text;
|
|
89477
|
-
}
|
|
89478
|
-
function formatErrorCauseChain(value) {
|
|
89479
|
-
const lines = [];
|
|
89480
|
-
const seen = /* @__PURE__ */ new Set();
|
|
89481
|
-
try {
|
|
89482
|
-
for (let current = causeOf(value); current != null && lines.length <= MAX_CAUSE_LINKS; current = causeOf(current)) {
|
|
89483
|
-
if (typeof current !== "object") {
|
|
89484
|
-
lines.push(String(current));
|
|
89485
|
-
break;
|
|
89486
|
-
}
|
|
89487
|
-
if (seen.has(current))
|
|
89488
|
-
break;
|
|
89489
|
-
seen.add(current);
|
|
89490
|
-
lines.push(describeErrorLink(current), ...aggregatedLinks(current));
|
|
89491
|
-
}
|
|
89492
|
-
} catch {
|
|
89493
|
-
lines.push("[unavailable cause]");
|
|
89494
|
-
}
|
|
89495
|
-
return lines.length > MAX_CAUSE_LINKS ? [...lines.slice(0, MAX_CAUSE_LINKS), "\u2026"].join("\n") : lines.join("\n");
|
|
89496
|
-
}
|
|
89497
|
-
function causeOf(value) {
|
|
89498
|
-
return typeof value === "object" && value !== null ? value.cause : void 0;
|
|
89499
|
-
}
|
|
89500
|
-
function aggregatedLinks(value) {
|
|
89501
|
-
const errors = value.errors;
|
|
89502
|
-
return Array.isArray(errors) ? errors.slice(0, MAX_CAUSE_LINKS).map(describeErrorLink) : [];
|
|
89503
|
-
}
|
|
89504
|
-
function isAbortError(value) {
|
|
89505
|
-
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");
|
|
89506
|
-
}
|
|
89507
|
-
function promoteAbortErrorToFatal(value) {
|
|
89508
|
-
if (!isAbortError(value) || FatalError2.is(value)) {
|
|
89509
|
-
return value;
|
|
89510
|
-
}
|
|
89511
|
-
const fatalError = new FatalError2(`Aborted: ${value.message}`);
|
|
89512
|
-
if (value.stack) {
|
|
89513
|
-
fatalError.stack = value.stack;
|
|
89514
|
-
}
|
|
89515
|
-
return fatalError;
|
|
89516
|
-
}
|
|
89517
|
-
function isThenable(value) {
|
|
89518
|
-
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
89519
|
-
}
|
|
89520
|
-
function normalizeSyncError(v) {
|
|
89521
|
-
if (types6.isNativeError(v)) {
|
|
89522
|
-
return {
|
|
89523
|
-
name: v.name,
|
|
89524
|
-
message: v.message,
|
|
89525
|
-
stack: v.stack ?? ""
|
|
89526
|
-
};
|
|
89527
|
-
}
|
|
89528
|
-
if (typeof v === "string") {
|
|
89529
|
-
return {
|
|
89530
|
-
name: "Error",
|
|
89531
|
-
message: v,
|
|
89532
|
-
stack: ""
|
|
89533
|
-
};
|
|
89534
|
-
}
|
|
89535
|
-
try {
|
|
89536
|
-
return {
|
|
89537
|
-
name: "Error",
|
|
89538
|
-
message: JSON.stringify(v),
|
|
89539
|
-
stack: ""
|
|
89540
|
-
};
|
|
89541
|
-
} catch {
|
|
89542
|
-
return {
|
|
89543
|
-
name: "Error",
|
|
89544
|
-
message: String(v),
|
|
89545
|
-
stack: ""
|
|
89546
|
-
};
|
|
89547
|
-
}
|
|
89548
|
-
}
|
|
89549
|
-
async function normalizeUnknownError(value) {
|
|
89550
|
-
if (isThenable(value)) {
|
|
89551
|
-
try {
|
|
89552
|
-
const resolved = await value;
|
|
89553
|
-
const normalized = await normalizeUnknownError(resolved);
|
|
89554
|
-
return {
|
|
89555
|
-
...normalized,
|
|
89556
|
-
message: `Promise rejection: ${normalized.message}`
|
|
89557
|
-
};
|
|
89558
|
-
} catch (rejection) {
|
|
89559
|
-
const normalized = await normalizeUnknownError(rejection);
|
|
89560
|
-
return {
|
|
89561
|
-
...normalized,
|
|
89562
|
-
message: `Promise rejection: ${normalized.message}`
|
|
89563
|
-
};
|
|
89564
|
-
}
|
|
89565
|
-
}
|
|
89566
|
-
return normalizeSyncError(value);
|
|
89567
|
-
}
|
|
89568
|
-
var MAX_CAUSE_LINKS;
|
|
89569
|
-
var init_types4 = __esm({
|
|
89570
|
-
"../core/dist/types.js"() {
|
|
89571
|
-
"use strict";
|
|
89572
|
-
init_dist7();
|
|
89573
|
-
__name(getErrorName, "getErrorName");
|
|
89574
|
-
__name(getErrorStack, "getErrorStack");
|
|
89575
|
-
MAX_CAUSE_LINKS = 4;
|
|
89576
|
-
__name(describeErrorLink, "describeErrorLink");
|
|
89577
|
-
__name(formatErrorCauseChain, "formatErrorCauseChain");
|
|
89578
|
-
__name(causeOf, "causeOf");
|
|
89579
|
-
__name(aggregatedLinks, "aggregatedLinks");
|
|
89580
|
-
__name(isAbortError, "isAbortError");
|
|
89581
|
-
__name(promoteAbortErrorToFatal, "promoteAbortErrorToFatal");
|
|
89582
|
-
__name(isThenable, "isThenable");
|
|
89583
|
-
__name(normalizeSyncError, "normalizeSyncError");
|
|
89584
|
-
__name(normalizeUnknownError, "normalizeUnknownError");
|
|
89585
|
-
}
|
|
89586
|
-
});
|
|
89587
|
-
|
|
89588
90467
|
// ../core/dist/runtime/get-port-lazy.js
|
|
89589
90468
|
import { createRequire as createRequire3 } from "node:module";
|
|
89590
90469
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
@@ -90570,11 +91449,11 @@ var init_step_executor = __esm({
|
|
|
90570
91449
|
});
|
|
90571
91450
|
|
|
90572
91451
|
// ../core/dist/runtime/step-single-flight.js
|
|
90573
|
-
async function runStepSingleFlight(runId, correlationId, execute) {
|
|
91452
|
+
async function runStepSingleFlight(runId, correlationId, execute, logLevel = "warn") {
|
|
90574
91453
|
const key = `${runId}:${correlationId}`;
|
|
90575
91454
|
const existing = singleFlight.inFlight.get(key);
|
|
90576
91455
|
if (existing) {
|
|
90577
|
-
runtimeLogger2
|
|
91456
|
+
runtimeLogger2[logLevel]("Step execution already in flight in this process; awaiting its settlement instead of executing again", { workflowRunId: runId, stepId: correlationId });
|
|
90578
91457
|
try {
|
|
90579
91458
|
await existing;
|
|
90580
91459
|
} catch {
|
|
@@ -90602,12 +91481,12 @@ var init_step_single_flight = __esm({
|
|
|
90602
91481
|
|
|
90603
91482
|
// ../core/dist/runtime/wait-continuation.js
|
|
90604
91483
|
function getWaitContinuationDispatch(timeoutSeconds, waitCorrelationId, now2 = Date.now(), attempt = 0) {
|
|
90605
|
-
const
|
|
91484
|
+
const dispatch2 = waitContinuationDispatchForAttemptZero(timeoutSeconds, waitCorrelationId, now2);
|
|
90606
91485
|
if (attempt <= 0)
|
|
90607
|
-
return
|
|
91486
|
+
return dispatch2;
|
|
90608
91487
|
return {
|
|
90609
|
-
delaySeconds:
|
|
90610
|
-
idempotencyKey: `${
|
|
91488
|
+
delaySeconds: dispatch2.delaySeconds,
|
|
91489
|
+
idempotencyKey: `${dispatch2.idempotencyKey}:a${attempt}`
|
|
90611
91490
|
};
|
|
90612
91491
|
}
|
|
90613
91492
|
function waitContinuationDispatchForAttemptZero(timeoutSeconds, waitCorrelationId, now2) {
|
|
@@ -97201,6 +98080,40 @@ async function startQuickJSWorkflow(options) {
|
|
|
97201
98080
|
}
|
|
97202
98081
|
}
|
|
97203
98082
|
serde.installProcessEnv(process.env);
|
|
98083
|
+
const historicalAttributeIds = /* @__PURE__ */ new Set();
|
|
98084
|
+
for (const event of events) {
|
|
98085
|
+
if (event.eventType === "attr_set" && event.correlationId !== void 0) {
|
|
98086
|
+
historicalAttributeIds.add(event.correlationId);
|
|
98087
|
+
}
|
|
98088
|
+
}
|
|
98089
|
+
{
|
|
98090
|
+
const env_5 = { stack: [], error: void 0, hasError: false };
|
|
98091
|
+
try {
|
|
98092
|
+
const validateAttributeWrite = __addDisposableResource3(env_5, vm.newFunction("__validateAttributeWrite", (correlationId, changes, allowReservedAttributes) => {
|
|
98093
|
+
if (historicalAttributeIds.has(correlationId.toString())) {
|
|
98094
|
+
return vm.undefined;
|
|
98095
|
+
}
|
|
98096
|
+
try {
|
|
98097
|
+
validateAttributeEventDataSize2({
|
|
98098
|
+
changes: vm.dump(changes),
|
|
98099
|
+
writer: { type: "workflow" },
|
|
98100
|
+
...allowReservedAttributes.toBoolean() ? { allowReservedAttributes: true } : {}
|
|
98101
|
+
});
|
|
98102
|
+
} catch (err) {
|
|
98103
|
+
if (!(err instanceof AttributeValidationError2))
|
|
98104
|
+
throw err;
|
|
98105
|
+
return vm.newString(err.message);
|
|
98106
|
+
}
|
|
98107
|
+
return vm.undefined;
|
|
98108
|
+
}), false);
|
|
98109
|
+
vm.setProp(vm.global, "__validateAttributeWrite", validateAttributeWrite);
|
|
98110
|
+
} catch (e_5) {
|
|
98111
|
+
env_5.error = e_5;
|
|
98112
|
+
env_5.hasError = true;
|
|
98113
|
+
} finally {
|
|
98114
|
+
__disposeResources3(env_5);
|
|
98115
|
+
}
|
|
98116
|
+
}
|
|
97204
98117
|
if (!baselineSnapshot) {
|
|
97205
98118
|
try {
|
|
97206
98119
|
vm.evalCode(workflowCode2, workflowId || "workflow.js").dispose();
|
|
@@ -97277,8 +98190,11 @@ async function startQuickJSWorkflow(options) {
|
|
|
97277
98190
|
let maxIterations = 100;
|
|
97278
98191
|
let madeProgress;
|
|
97279
98192
|
do {
|
|
97280
|
-
madeProgress = await processEvents(vm, serde, events, advanceClock, options.encryptionKey);
|
|
97281
98193
|
let batch;
|
|
98194
|
+
do {
|
|
98195
|
+
batch = vm.executePendingJobs();
|
|
98196
|
+
} while (batch > 0);
|
|
98197
|
+
madeProgress = await processEvents(vm, serde, events, advanceClock, options.encryptionKey);
|
|
97282
98198
|
do {
|
|
97283
98199
|
batch = vm.executePendingJobs();
|
|
97284
98200
|
if (batch > 0)
|
|
@@ -97292,7 +98208,7 @@ async function startQuickJSWorkflow(options) {
|
|
|
97292
98208
|
});
|
|
97293
98209
|
}
|
|
97294
98210
|
}
|
|
97295
|
-
return makeLiveSession(vm, serde, interruptBudget, advanceClock, options.encryptionKey);
|
|
98211
|
+
return makeLiveSession(vm, serde, interruptBudget, advanceClock, historicalAttributeIds, options.encryptionKey);
|
|
97296
98212
|
}
|
|
97297
98213
|
__name(runWorkflowInVM, "runWorkflowInVM");
|
|
97298
98214
|
}
|
|
@@ -97306,7 +98222,7 @@ function makeSettledSession(result2) {
|
|
|
97306
98222
|
}, "dispose")
|
|
97307
98223
|
};
|
|
97308
98224
|
}
|
|
97309
|
-
function makeLiveSession(vm, serde, interruptBudget, advanceClock, encryptionKey) {
|
|
98225
|
+
function makeLiveSession(vm, serde, interruptBudget, advanceClock, historicalAttributeIds, encryptionKey) {
|
|
97310
98226
|
const result2 = checkWorkflowState(vm, serde, { keepAliveOnSuspend: true });
|
|
97311
98227
|
let alive = !!result2.suspended;
|
|
97312
98228
|
const session = {
|
|
@@ -97316,11 +98232,19 @@ function makeLiveSession(vm, serde, interruptBudget, advanceClock, encryptionKey
|
|
|
97316
98232
|
throw new Error("QuickJS workflow session is not alive \u2014 continueWithEvents is only valid while suspended");
|
|
97317
98233
|
}
|
|
97318
98234
|
interruptBudget.start = Date.now();
|
|
98235
|
+
for (const event of newEvents) {
|
|
98236
|
+
if (event.eventType === "attr_set" && event.correlationId !== void 0) {
|
|
98237
|
+
historicalAttributeIds.add(event.correlationId);
|
|
98238
|
+
}
|
|
98239
|
+
}
|
|
97319
98240
|
let maxIterations = 100;
|
|
97320
98241
|
let madeProgress;
|
|
97321
98242
|
do {
|
|
97322
|
-
madeProgress = await processEvents(vm, serde, newEvents, advanceClock, encryptionKey);
|
|
97323
98243
|
let batch;
|
|
98244
|
+
do {
|
|
98245
|
+
batch = vm.executePendingJobs();
|
|
98246
|
+
} while (batch > 0);
|
|
98247
|
+
madeProgress = await processEvents(vm, serde, newEvents, advanceClock, encryptionKey);
|
|
97324
98248
|
do {
|
|
97325
98249
|
batch = vm.executePendingJobs();
|
|
97326
98250
|
if (batch > 0)
|
|
@@ -97695,9 +98619,9 @@ function ensurePendingByteCache(vm) {
|
|
|
97695
98619
|
return cache;
|
|
97696
98620
|
}
|
|
97697
98621
|
function dumpPendingOps(vm, serde, filterExpr, byteCache) {
|
|
97698
|
-
const
|
|
98622
|
+
const env_6 = { stack: [], error: void 0, hasError: false };
|
|
97699
98623
|
try {
|
|
97700
|
-
const projected = __addDisposableResource3(
|
|
98624
|
+
const projected = __addDisposableResource3(env_6, vm.evalCode(`(function(){
|
|
97701
98625
|
var ops = ${filterExpr};
|
|
97702
98626
|
globalThis.__rawFields = [];
|
|
97703
98627
|
// Settled ops \u2014 created, resolver-less, no abort in flight \u2014 are
|
|
@@ -97736,7 +98660,7 @@ function dumpPendingOps(vm, serde, filterExpr, byteCache) {
|
|
|
97736
98660
|
}
|
|
97737
98661
|
}
|
|
97738
98662
|
}
|
|
97739
|
-
const rawFields = __addDisposableResource3(
|
|
98663
|
+
const rawFields = __addDisposableResource3(env_6, vm.evalCode("globalThis.__rawFields"), false);
|
|
97740
98664
|
for (const op of plainOps) {
|
|
97741
98665
|
const rawIndices = op.__rawIndices ?? {};
|
|
97742
98666
|
delete op.__rawIndices;
|
|
@@ -97747,9 +98671,9 @@ function dumpPendingOps(vm, serde, filterExpr, byteCache) {
|
|
|
97747
98671
|
const cacheKey = `${op.correlationId}:${field}`;
|
|
97748
98672
|
let bytes = byteCache?.get(cacheKey);
|
|
97749
98673
|
if (!bytes) {
|
|
97750
|
-
const
|
|
98674
|
+
const env_7 = { stack: [], error: void 0, hasError: false };
|
|
97751
98675
|
try {
|
|
97752
|
-
const valueHandle = __addDisposableResource3(
|
|
98676
|
+
const valueHandle = __addDisposableResource3(env_7, rawFields.getProp(String(index)), false);
|
|
97753
98677
|
try {
|
|
97754
98678
|
bytes = serde.serialize(valueHandle);
|
|
97755
98679
|
} catch (err) {
|
|
@@ -97761,11 +98685,11 @@ function dumpPendingOps(vm, serde, filterExpr, byteCache) {
|
|
|
97761
98685
|
throw err;
|
|
97762
98686
|
}
|
|
97763
98687
|
byteCache?.set(cacheKey, bytes);
|
|
97764
|
-
} catch (
|
|
97765
|
-
|
|
97766
|
-
|
|
98688
|
+
} catch (e_6) {
|
|
98689
|
+
env_7.error = e_6;
|
|
98690
|
+
env_7.hasError = true;
|
|
97767
98691
|
} finally {
|
|
97768
|
-
__disposeResources3(
|
|
98692
|
+
__disposeResources3(env_7);
|
|
97769
98693
|
}
|
|
97770
98694
|
}
|
|
97771
98695
|
op[field] = bytes;
|
|
@@ -97773,11 +98697,11 @@ function dumpPendingOps(vm, serde, filterExpr, byteCache) {
|
|
|
97773
98697
|
}
|
|
97774
98698
|
vm.evalCode("delete globalThis.__rawFields").dispose();
|
|
97775
98699
|
return plainOps;
|
|
97776
|
-
} catch (
|
|
97777
|
-
|
|
97778
|
-
|
|
98700
|
+
} catch (e_7) {
|
|
98701
|
+
env_6.error = e_7;
|
|
98702
|
+
env_6.hasError = true;
|
|
97779
98703
|
} finally {
|
|
97780
|
-
__disposeResources3(
|
|
98704
|
+
__disposeResources3(env_6);
|
|
97781
98705
|
}
|
|
97782
98706
|
}
|
|
97783
98707
|
function collectDrainOperations(vm, serde) {
|
|
@@ -97815,13 +98739,13 @@ function collectDrainOperations(vm, serde) {
|
|
|
97815
98739
|
}
|
|
97816
98740
|
function checkWorkflowState(vm, serde, opts = {}) {
|
|
97817
98741
|
{
|
|
97818
|
-
const
|
|
98742
|
+
const env_8 = { stack: [], error: void 0, hasError: false };
|
|
97819
98743
|
try {
|
|
97820
|
-
const done = __addDisposableResource3(
|
|
98744
|
+
const done = __addDisposableResource3(env_8, vm.evalCode("globalThis.__workflowDone === true"), false);
|
|
97821
98745
|
if (done.toBoolean()) {
|
|
97822
|
-
const
|
|
98746
|
+
const env_9 = { stack: [], error: void 0, hasError: false };
|
|
97823
98747
|
try {
|
|
97824
|
-
const h = __addDisposableResource3(
|
|
98748
|
+
const h = __addDisposableResource3(env_9, vm.evalCode("globalThis.__workflowResult"), false);
|
|
97825
98749
|
const resultBytes = serde.serialize(h);
|
|
97826
98750
|
const drainOperations = collectDrainOperations(vm, serde);
|
|
97827
98751
|
vm.dispose();
|
|
@@ -97831,42 +98755,42 @@ function checkWorkflowState(vm, serde, opts = {}) {
|
|
|
97831
98755
|
...drainOperations.length > 0 ? { drainOperations } : {}
|
|
97832
98756
|
}
|
|
97833
98757
|
};
|
|
97834
|
-
} catch (
|
|
97835
|
-
|
|
97836
|
-
|
|
98758
|
+
} catch (e_8) {
|
|
98759
|
+
env_9.error = e_8;
|
|
98760
|
+
env_9.hasError = true;
|
|
97837
98761
|
} finally {
|
|
97838
|
-
__disposeResources3(
|
|
98762
|
+
__disposeResources3(env_9);
|
|
97839
98763
|
}
|
|
97840
98764
|
}
|
|
97841
|
-
} catch (
|
|
97842
|
-
|
|
97843
|
-
|
|
98765
|
+
} catch (e_9) {
|
|
98766
|
+
env_8.error = e_9;
|
|
98767
|
+
env_8.hasError = true;
|
|
97844
98768
|
} finally {
|
|
97845
|
-
__disposeResources3(
|
|
98769
|
+
__disposeResources3(env_8);
|
|
97846
98770
|
}
|
|
97847
98771
|
}
|
|
97848
98772
|
{
|
|
97849
|
-
const
|
|
98773
|
+
const env_10 = { stack: [], error: void 0, hasError: false };
|
|
97850
98774
|
try {
|
|
97851
|
-
const h = __addDisposableResource3(
|
|
98775
|
+
const h = __addDisposableResource3(env_10, vm.evalCode("globalThis.__workflowError"), false);
|
|
97852
98776
|
if (!h.isUndefined) {
|
|
97853
98777
|
const errorObj = h.isString ? h.toString() : (() => {
|
|
97854
|
-
const
|
|
98778
|
+
const env_13 = { stack: [], error: void 0, hasError: false };
|
|
97855
98779
|
try {
|
|
97856
|
-
const plain = __addDisposableResource3(
|
|
98780
|
+
const plain = __addDisposableResource3(env_13, vm.evalCode("(function(e){return {message: e.message, stack: e.stack, name: e.name};})(globalThis.__workflowError)"), false);
|
|
97857
98781
|
return vm.dump(plain);
|
|
97858
|
-
} catch (
|
|
97859
|
-
|
|
97860
|
-
|
|
98782
|
+
} catch (e_13) {
|
|
98783
|
+
env_13.error = e_13;
|
|
98784
|
+
env_13.hasError = true;
|
|
97861
98785
|
} finally {
|
|
97862
|
-
__disposeResources3(
|
|
98786
|
+
__disposeResources3(env_13);
|
|
97863
98787
|
}
|
|
97864
98788
|
})();
|
|
97865
98789
|
let valueBytes;
|
|
97866
98790
|
if (!h.isString) {
|
|
97867
|
-
const
|
|
98791
|
+
const env_11 = { stack: [], error: void 0, hasError: false };
|
|
97868
98792
|
try {
|
|
97869
|
-
const rawValue = __addDisposableResource3(
|
|
98793
|
+
const rawValue = __addDisposableResource3(env_11, h.getProp("value"), false);
|
|
97870
98794
|
try {
|
|
97871
98795
|
valueBytes = serde.serialize(rawValue);
|
|
97872
98796
|
} catch (serializeErr) {
|
|
@@ -97874,11 +98798,11 @@ function checkWorkflowState(vm, serde, opts = {}) {
|
|
|
97874
98798
|
message: serializeErr instanceof Error ? serializeErr.message : String(serializeErr)
|
|
97875
98799
|
});
|
|
97876
98800
|
}
|
|
97877
|
-
} catch (
|
|
97878
|
-
|
|
97879
|
-
|
|
98801
|
+
} catch (e_10) {
|
|
98802
|
+
env_11.error = e_10;
|
|
98803
|
+
env_11.hasError = true;
|
|
97880
98804
|
} finally {
|
|
97881
|
-
__disposeResources3(
|
|
98805
|
+
__disposeResources3(env_11);
|
|
97882
98806
|
}
|
|
97883
98807
|
}
|
|
97884
98808
|
const failed = typeof errorObj === "string" ? { message: errorObj } : {
|
|
@@ -97901,17 +98825,17 @@ function checkWorkflowState(vm, serde, opts = {}) {
|
|
|
97901
98825
|
}
|
|
97902
98826
|
};
|
|
97903
98827
|
}
|
|
97904
|
-
} catch (
|
|
97905
|
-
|
|
97906
|
-
|
|
98828
|
+
} catch (e_11) {
|
|
98829
|
+
env_10.error = e_11;
|
|
98830
|
+
env_10.hasError = true;
|
|
97907
98831
|
} finally {
|
|
97908
|
-
__disposeResources3(
|
|
98832
|
+
__disposeResources3(env_10);
|
|
97909
98833
|
}
|
|
97910
98834
|
}
|
|
97911
98835
|
{
|
|
97912
|
-
const
|
|
98836
|
+
const env_12 = { stack: [], error: void 0, hasError: false };
|
|
97913
98837
|
try {
|
|
97914
|
-
const h = __addDisposableResource3(
|
|
98838
|
+
const h = __addDisposableResource3(env_12, vm.evalCode("Object.keys(globalThis.__resolvers).length > 0 || globalThis.__pending.some(function(p){return!p.hasCreatedEvent;})"), false);
|
|
97915
98839
|
if (vm.dump(h)) {
|
|
97916
98840
|
const pendingOps = dumpPendingOps(vm, serde, `globalThis.__pending.filter(function(p){return!!globalThis.__resolvers[p.correlationId] || !p.hasCreatedEvent || p.abortRequested;})`, ensurePendingByteCache(vm));
|
|
97917
98841
|
if (!opts.keepAliveOnSuspend)
|
|
@@ -97922,11 +98846,11 @@ function checkWorkflowState(vm, serde, opts = {}) {
|
|
|
97922
98846
|
}
|
|
97923
98847
|
};
|
|
97924
98848
|
}
|
|
97925
|
-
} catch (
|
|
97926
|
-
|
|
97927
|
-
|
|
98849
|
+
} catch (e_12) {
|
|
98850
|
+
env_12.error = e_12;
|
|
98851
|
+
env_12.hasError = true;
|
|
97928
98852
|
} finally {
|
|
97929
|
-
__disposeResources3(
|
|
98853
|
+
__disposeResources3(env_12);
|
|
97930
98854
|
}
|
|
97931
98855
|
}
|
|
97932
98856
|
vm.dispose();
|
|
@@ -97963,6 +98887,7 @@ var init_quickjs_runtime = __esm({
|
|
|
97963
98887
|
init_dist7();
|
|
97964
98888
|
init_dist5();
|
|
97965
98889
|
init_dist6();
|
|
98890
|
+
init_attributes_validation2();
|
|
97966
98891
|
init_nanoid();
|
|
97967
98892
|
init_dist13();
|
|
97968
98893
|
import_seedrandom2 = __toESM(require_seedrandom2(), 1);
|
|
@@ -98586,18 +99511,28 @@ globalThis[Symbol.for("WORKFLOW_CREATE_HOOK")] = function(options) {
|
|
|
98586
99511
|
};
|
|
98587
99512
|
|
|
98588
99513
|
// setAttributes \u2014 attaches plaintext metadata to the current run.
|
|
98589
|
-
//
|
|
99514
|
+
// Per-change validation happens in library code (normalizeAttributeChanges) before
|
|
98590
99515
|
// this dispatcher is invoked, so "changes" is already normalized. The
|
|
98591
99516
|
// returned promise resolves when the matching attr_set event is
|
|
98592
99517
|
// observed during event processing \u2014 mirroring the node:vm engine's
|
|
98593
99518
|
// createSetAttributes (attribute-dispatcher.ts).
|
|
99519
|
+
// Baseline hydrate placeholder; module-scope calls draw a ULID and disable snapshots.
|
|
99520
|
+
globalThis.__validateAttributeWrite = function() {};
|
|
98594
99521
|
globalThis[Symbol.for("WORKFLOW_SET_ATTRIBUTES")] = function(changes, options) {
|
|
98595
99522
|
var correlationId = "attr_" + globalThis.__generateUlid();
|
|
99523
|
+
var allowReservedAttributes = !!(options && options.allowReservedAttributes);
|
|
99524
|
+
var validationError = globalThis.__validateAttributeWrite(correlationId, changes, allowReservedAttributes);
|
|
99525
|
+
if (validationError !== undefined) {
|
|
99526
|
+
var error = new Error(validationError);
|
|
99527
|
+
error.name = "FatalError";
|
|
99528
|
+
error.fatal = true;
|
|
99529
|
+
return Promise.reject(error);
|
|
99530
|
+
}
|
|
98596
99531
|
globalThis.__pending.push({
|
|
98597
99532
|
type: "attribute",
|
|
98598
99533
|
correlationId: correlationId,
|
|
98599
99534
|
changes: changes,
|
|
98600
|
-
allowReservedAttributes:
|
|
99535
|
+
allowReservedAttributes: allowReservedAttributes,
|
|
98601
99536
|
hasCreatedEvent: false,
|
|
98602
99537
|
});
|
|
98603
99538
|
return new Promise(function(resolve, reject) {
|
|
@@ -99634,7 +100569,7 @@ async function runWorkflowWithQuickJS(params) {
|
|
|
99634
100569
|
// attempt.
|
|
99635
100570
|
authoritativeAttempt: 1,
|
|
99636
100571
|
...inlineDeltaSinceCursor !== void 0 ? { inlineDeltaSinceCursor } : {}
|
|
99637
|
-
}))())));
|
|
100572
|
+
}))(), "debug")));
|
|
99638
100573
|
} finally {
|
|
99639
100574
|
budget.resume();
|
|
99640
100575
|
}
|
|
@@ -99738,6 +100673,7 @@ async function runWorkflowWithQuickJS(params) {
|
|
|
99738
100673
|
}
|
|
99739
100674
|
});
|
|
99740
100675
|
wfdiag("exit_completed", { result: "run_completed_written" });
|
|
100676
|
+
dispatchRunCompletedHooks(runId, workflowName);
|
|
99741
100677
|
} catch (err) {
|
|
99742
100678
|
if (EntityConflictError2.is(err) || RunExpiredError2.is(err)) {
|
|
99743
100679
|
runtimeLogger2.warn("Workflow already finished, skipping run_completed", { workflowRunId: runId });
|
|
@@ -99948,6 +100884,7 @@ async function runWorkflowWithQuickJS(params) {
|
|
|
99948
100884
|
});
|
|
99949
100885
|
throw err;
|
|
99950
100886
|
}
|
|
100887
|
+
dispatchRunFailedHooks(runId, workflowName, dehydratedError, encryptionKey, errorCode);
|
|
99951
100888
|
wfdiag("exit_failed", { result: "run_failed_written" });
|
|
99952
100889
|
}
|
|
99953
100890
|
}
|
|
@@ -99967,6 +100904,7 @@ var init_quickjs_entrypoint = __esm({
|
|
|
99967
100904
|
init_constants3();
|
|
99968
100905
|
init_get_port_lazy();
|
|
99969
100906
|
init_helpers3();
|
|
100907
|
+
init_lifecycle_hooks();
|
|
99970
100908
|
init_quickjs_log_view();
|
|
99971
100909
|
init_quickjs_runtime();
|
|
99972
100910
|
init_replay_budget();
|
|
@@ -125560,6 +126498,13 @@ var init_zod = __esm2({
|
|
|
125560
126498
|
init_external();
|
|
125561
126499
|
}
|
|
125562
126500
|
});
|
|
126501
|
+
function validateAttributeEventDataSize(eventData) {
|
|
126502
|
+
const bytes = textEncoder.encode(JSON.stringify(eventData)).length;
|
|
126503
|
+
if (bytes > ATTRIBUTE_EVENT_DATA_MAX_BYTES) {
|
|
126504
|
+
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.`);
|
|
126505
|
+
}
|
|
126506
|
+
}
|
|
126507
|
+
__name(validateAttributeEventDataSize, "validateAttributeEventDataSize");
|
|
125563
126508
|
function assertValidAttributeKey(key, allowReservedAttributes) {
|
|
125564
126509
|
if (typeof key !== "string") {
|
|
125565
126510
|
throw new AttributeValidationError(`Attribute key must be a string, got ${typeof key}`);
|
|
@@ -125622,6 +126567,7 @@ var RETENTION_ATTRIBUTE;
|
|
|
125622
126567
|
var ATTRIBUTE_KEY_MAX_LENGTH;
|
|
125623
126568
|
var ATTRIBUTE_VALUE_MAX_BYTES;
|
|
125624
126569
|
var ATTRIBUTE_MAX_PER_RUN;
|
|
126570
|
+
var ATTRIBUTE_EVENT_DATA_MAX_BYTES;
|
|
125625
126571
|
var textEncoder;
|
|
125626
126572
|
var AttributeValidationError;
|
|
125627
126573
|
var init_attributes_validation = __esm2({
|
|
@@ -125634,6 +126580,7 @@ var init_attributes_validation = __esm2({
|
|
|
125634
126580
|
ATTRIBUTE_KEY_MAX_LENGTH = 256;
|
|
125635
126581
|
ATTRIBUTE_VALUE_MAX_BYTES = 256;
|
|
125636
126582
|
ATTRIBUTE_MAX_PER_RUN = 64;
|
|
126583
|
+
ATTRIBUTE_EVENT_DATA_MAX_BYTES = 8192;
|
|
125637
126584
|
textEncoder = new TextEncoder();
|
|
125638
126585
|
AttributeValidationError = class extends Error {
|
|
125639
126586
|
static {
|
|
@@ -125647,6 +126594,7 @@ var init_attributes_validation = __esm2({
|
|
|
125647
126594
|
this.name = "AttributeValidationError";
|
|
125648
126595
|
}
|
|
125649
126596
|
};
|
|
126597
|
+
__name2(validateAttributeEventDataSize, "validateAttributeEventDataSize");
|
|
125650
126598
|
__name2(assertValidAttributeKey, "assertValidAttributeKey");
|
|
125651
126599
|
__name2(assertValidAttributeValue, "assertValidAttributeValue");
|
|
125652
126600
|
__name2(attributeCountDelta, "attributeCountDelta");
|
|
@@ -126731,6 +127679,11 @@ var init_queue = __esm2({
|
|
|
126731
127679
|
}));
|
|
126732
127680
|
WorkflowInvokePayloadSchema = external_exports.compile(external_exports.object({
|
|
126733
127681
|
runId: external_exports.string(),
|
|
127682
|
+
/** Process this input and return the handler's result as response data. */
|
|
127683
|
+
invoke: external_exports.literal(true).optional(),
|
|
127684
|
+
/** Identifies one input across retries, separately from the queue delivery ID. */
|
|
127685
|
+
requestId: external_exports.string().optional(),
|
|
127686
|
+
input: external_exports.unknown().optional(),
|
|
126734
127687
|
traceCarrier: TraceCarrierSchema.optional(),
|
|
126735
127688
|
requestedAt: external_exports.coerce.date().optional(),
|
|
126736
127689
|
/**
|
|
@@ -133422,7 +134375,7 @@ var version2;
|
|
|
133422
134375
|
var init_version = __esm2({
|
|
133423
134376
|
"../core/dist/version.js"() {
|
|
133424
134377
|
"use strict";
|
|
133425
|
-
version2 = "5.0.0-beta.
|
|
134378
|
+
version2 = "5.0.0-beta.55";
|
|
133426
134379
|
}
|
|
133427
134380
|
});
|
|
133428
134381
|
function getWorkflowQueueName(workflowName, namespace) {
|
|
@@ -133609,6 +134562,37 @@ var init_helpers = __esm2({
|
|
|
133609
134562
|
__name2(healthCheck, "healthCheck");
|
|
133610
134563
|
}
|
|
133611
134564
|
});
|
|
134565
|
+
var HookInvocationSchema;
|
|
134566
|
+
var HookInvocationResultSchema;
|
|
134567
|
+
var init_invocations = __esm2({
|
|
134568
|
+
"../core/dist/runtime/invocations.js"() {
|
|
134569
|
+
"use strict";
|
|
134570
|
+
init_dist2();
|
|
134571
|
+
init_dist4();
|
|
134572
|
+
init_zod();
|
|
134573
|
+
init_semantic_conventions();
|
|
134574
|
+
init_telemetry();
|
|
134575
|
+
HookInvocationSchema = external_exports.object({
|
|
134576
|
+
type: external_exports.literal("hook_resume"),
|
|
134577
|
+
version: external_exports.literal(1),
|
|
134578
|
+
hookId: external_exports.string(),
|
|
134579
|
+
token: external_exports.string(),
|
|
134580
|
+
payload: external_exports.instanceof(Uint8Array)
|
|
134581
|
+
});
|
|
134582
|
+
HookInvocationResultSchema = external_exports.discriminatedUnion("status", [
|
|
134583
|
+
external_exports.object({
|
|
134584
|
+
status: external_exports.literal("accepted")
|
|
134585
|
+
}),
|
|
134586
|
+
external_exports.object({
|
|
134587
|
+
status: external_exports.literal("rejected"),
|
|
134588
|
+
code: external_exports.enum([
|
|
134589
|
+
"HOOK_NOT_FOUND",
|
|
134590
|
+
"INVALID_INPUT"
|
|
134591
|
+
])
|
|
134592
|
+
})
|
|
134593
|
+
]);
|
|
134594
|
+
}
|
|
134595
|
+
});
|
|
133612
134596
|
var require_headers = __commonJS2({
|
|
133613
134597
|
"../../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) {
|
|
133614
134598
|
"use strict";
|
|
@@ -138808,6 +139792,29 @@ async function resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, hookF
|
|
|
138808
139792
|
if (originLink) {
|
|
138809
139793
|
span?.addLink?.(originLink);
|
|
138810
139794
|
}
|
|
139795
|
+
if (world.capabilities?.invoke === true && !v1Compat && dehydratedPayload instanceof Uint8Array) {
|
|
139796
|
+
if (!world.invoke) {
|
|
139797
|
+
throw new WorkflowRuntimeError("World advertises invoke without implementing it");
|
|
139798
|
+
}
|
|
139799
|
+
span?.setAttributes({
|
|
139800
|
+
"workflow.hook.resume_strategy": "invoke"
|
|
139801
|
+
});
|
|
139802
|
+
const result2 = HookInvocationResultSchema.parse(await world.invoke(hook.runId, {
|
|
139803
|
+
type: "hook_resume",
|
|
139804
|
+
version: 1,
|
|
139805
|
+
hookId: hook.hookId,
|
|
139806
|
+
token: hook.token,
|
|
139807
|
+
payload: dehydratedPayload
|
|
139808
|
+
}, {
|
|
139809
|
+
idempotencyKey: generateResumeId()
|
|
139810
|
+
}));
|
|
139811
|
+
if (result2.status === "rejected") {
|
|
139812
|
+
if (result2.code === "HOOK_NOT_FOUND") throw new HookNotFoundError(hook.token);
|
|
139813
|
+
throw new WorkflowRuntimeError("Executor rejected the hook invocation input");
|
|
139814
|
+
}
|
|
139815
|
+
span?.setAttributes(HookResumeCommitted(true));
|
|
139816
|
+
return asLazyMetadataHook(hook);
|
|
139817
|
+
}
|
|
138811
139818
|
const queueName = getWorkflowQueueName(resumeContext.workflowName);
|
|
138812
139819
|
const queueOptions = {
|
|
138813
139820
|
deploymentId: resumeContext.deploymentId,
|
|
@@ -138948,6 +139955,7 @@ var init_resume_hook = __esm2({
|
|
|
138948
139955
|
init_telemetry();
|
|
138949
139956
|
init_get_world_lazy();
|
|
138950
139957
|
init_helpers();
|
|
139958
|
+
init_invocations();
|
|
138951
139959
|
init_wait_until();
|
|
138952
139960
|
generateResumeId = monotonicFactory();
|
|
138953
139961
|
__name2(computeResumePayloadDigest, "computeResumePayloadDigest");
|
|
@@ -140021,6 +141029,15 @@ function createForwardedWritable({ global: global2, ops, runId, name, key, deplo
|
|
|
140021
141029
|
}
|
|
140022
141030
|
__name(createForwardedWritable, "createForwardedWritable");
|
|
140023
141031
|
function getRunReadableStream(global2, ops, runId, name, startIndex, cryptoKey) {
|
|
141032
|
+
return getLazyReadableStream((onReadableState) => getExternalRevivers(global2, ops, runId, cryptoKey, {
|
|
141033
|
+
onReadableState
|
|
141034
|
+
}).ReadableStream({
|
|
141035
|
+
name,
|
|
141036
|
+
startIndex
|
|
141037
|
+
}));
|
|
141038
|
+
}
|
|
141039
|
+
__name(getRunReadableStream, "getRunReadableStream");
|
|
141040
|
+
function getLazyReadableStream(reviveReadable, onReadableState) {
|
|
140024
141041
|
let reader;
|
|
140025
141042
|
let lockState;
|
|
140026
141043
|
let lockPollingStarted = false;
|
|
@@ -140030,18 +141047,14 @@ function getRunReadableStream(global2, ops, runId, name, startIndex, cryptoKey)
|
|
|
140030
141047
|
async pull(controller) {
|
|
140031
141048
|
try {
|
|
140032
141049
|
if (!reader) {
|
|
140033
|
-
const stream =
|
|
140034
|
-
|
|
140035
|
-
lockState = state;
|
|
140036
|
-
}, "onReadableState")
|
|
140037
|
-
}).ReadableStream({
|
|
140038
|
-
name,
|
|
140039
|
-
startIndex
|
|
141050
|
+
const stream = reviveReadable((state) => {
|
|
141051
|
+
lockState = state;
|
|
140040
141052
|
});
|
|
140041
141053
|
reader = stream.getReader();
|
|
140042
141054
|
if (lockState && !lockPollingStarted) {
|
|
140043
141055
|
lockPollingStarted = true;
|
|
140044
|
-
|
|
141056
|
+
if (onReadableState) onReadableState(lockState);
|
|
141057
|
+
else pollReadableLock(userReadable, lockState);
|
|
140045
141058
|
}
|
|
140046
141059
|
}
|
|
140047
141060
|
const result2 = await reader.read();
|
|
@@ -140064,8 +141077,47 @@ function getRunReadableStream(global2, ops, runId, name, startIndex, cryptoKey)
|
|
|
140064
141077
|
);
|
|
140065
141078
|
return userReadable;
|
|
140066
141079
|
}
|
|
140067
|
-
__name(
|
|
141080
|
+
__name(getLazyReadableStream, "getLazyReadableStream");
|
|
140068
141081
|
function getExternalRevivers(global2 = globalThis, ops, runId, cryptoKey, options) {
|
|
141082
|
+
function reviveReadableStream(value, onReadableState = options?.onReadableState) {
|
|
141083
|
+
if (value.type === "bytes") {
|
|
141084
|
+
const readable2 = new WorkflowServerReadableStream(runId, value.name, value.startIndex);
|
|
141085
|
+
const state2 = createFlushableState();
|
|
141086
|
+
ops.push(state2.promise);
|
|
141087
|
+
const { readable: userReadable, writable } = value.framing === "framed-v1" ? getByteUnframingStream() : new global2.TransformStream();
|
|
141088
|
+
flushablePipe(readable2, writable, state2).catch(() => {
|
|
141089
|
+
});
|
|
141090
|
+
if (onReadableState) onReadableState(state2);
|
|
141091
|
+
else pollReadableLock(userReadable, state2);
|
|
141092
|
+
return userReadable;
|
|
141093
|
+
}
|
|
141094
|
+
let keyPromise;
|
|
141095
|
+
const resolveKey = /* @__PURE__ */ __name2(() => {
|
|
141096
|
+
keyPromise ??= resolveEncryptionKey(cryptoKey);
|
|
141097
|
+
return keyPromise;
|
|
141098
|
+
}, "resolveKey");
|
|
141099
|
+
const readable = createReconnectingFramedStream(runId, value.name, value.startIndex, resolveKey);
|
|
141100
|
+
const transform22 = getDeserializeStream(getExternalRevivers(global2, ops, runId, resolveKey, {
|
|
141101
|
+
lazyStreams: options?.lazyStreams,
|
|
141102
|
+
liveAbortSignals: options?.liveAbortSignals
|
|
141103
|
+
}), resolveKey);
|
|
141104
|
+
const state = createFlushableState();
|
|
141105
|
+
ops.push(state.promise);
|
|
141106
|
+
flushablePipe(readable, transform22.writable, state).catch(() => {
|
|
141107
|
+
});
|
|
141108
|
+
if (onReadableState) onReadableState(state);
|
|
141109
|
+
else pollReadableLock(transform22.readable, state);
|
|
141110
|
+
return transform22.readable;
|
|
141111
|
+
}
|
|
141112
|
+
__name(reviveReadableStream, "reviveReadableStream");
|
|
141113
|
+
__name2(reviveReadableStream, "reviveReadableStream");
|
|
141114
|
+
function reviveAbortSnapshot(value) {
|
|
141115
|
+
const controller = new AbortController();
|
|
141116
|
+
if (value.aborted) controller.abort(value.reason);
|
|
141117
|
+
return controller;
|
|
141118
|
+
}
|
|
141119
|
+
__name(reviveAbortSnapshot, "reviveAbortSnapshot");
|
|
141120
|
+
__name2(reviveAbortSnapshot, "reviveAbortSnapshot");
|
|
140069
141121
|
return {
|
|
140070
141122
|
...getCommonRevivers2(global2),
|
|
140071
141123
|
// StepFunction should not be returned from workflows to clients
|
|
@@ -140106,32 +141158,7 @@ function getExternalRevivers(global2 = globalThis, ops, runId, cryptoKey, option
|
|
|
140106
141158
|
const response = new global2.Response(bodyInit);
|
|
140107
141159
|
return response.body;
|
|
140108
141160
|
}
|
|
140109
|
-
|
|
140110
|
-
const readable = new WorkflowServerReadableStream(runId, value.name, value.startIndex);
|
|
140111
|
-
const state = createFlushableState();
|
|
140112
|
-
ops.push(state.promise);
|
|
140113
|
-
const { readable: userReadable, writable } = value.framing === "framed-v1" ? getByteUnframingStream() : new global2.TransformStream();
|
|
140114
|
-
flushablePipe(readable, writable, state).catch(() => {
|
|
140115
|
-
});
|
|
140116
|
-
if (options?.onReadableState) options.onReadableState(state);
|
|
140117
|
-
else pollReadableLock(userReadable, state);
|
|
140118
|
-
return userReadable;
|
|
140119
|
-
} else {
|
|
140120
|
-
let keyPromise;
|
|
140121
|
-
const resolveKey = /* @__PURE__ */ __name2(() => {
|
|
140122
|
-
keyPromise ??= resolveEncryptionKey(cryptoKey);
|
|
140123
|
-
return keyPromise;
|
|
140124
|
-
}, "resolveKey");
|
|
140125
|
-
const readable = createReconnectingFramedStream(runId, value.name, value.startIndex, resolveKey);
|
|
140126
|
-
const transform22 = getDeserializeStream(getExternalRevivers(global2, ops, runId, resolveKey), resolveKey);
|
|
140127
|
-
const state = createFlushableState();
|
|
140128
|
-
ops.push(state.promise);
|
|
140129
|
-
flushablePipe(readable, transform22.writable, state).catch(() => {
|
|
140130
|
-
});
|
|
140131
|
-
if (options?.onReadableState) options.onReadableState(state);
|
|
140132
|
-
else pollReadableLock(transform22.readable, state);
|
|
140133
|
-
return transform22.readable;
|
|
140134
|
-
}
|
|
141161
|
+
return options?.lazyStreams ? getLazyReadableStream((onReadableState) => reviveReadableStream(value, onReadableState), options.onReadableState) : reviveReadableStream(value);
|
|
140135
141162
|
}, "ReadableStream"),
|
|
140136
141163
|
WritableStream: /* @__PURE__ */ __name2((value) => {
|
|
140137
141164
|
const targetRunId = typeof value.runId === "string" ? value.runId : runId;
|
|
@@ -140146,8 +141173,8 @@ function getExternalRevivers(global2 = globalThis, ops, runId, cryptoKey, option
|
|
|
140146
141173
|
encryptionPublicKey: value.encryptionPublicKey
|
|
140147
141174
|
});
|
|
140148
141175
|
}, "WritableStream"),
|
|
140149
|
-
AbortController: /* @__PURE__ */ __name2((value) => reviveAbortController(value, ops, runId), "AbortController"),
|
|
140150
|
-
AbortSignal: /* @__PURE__ */ __name2((value) => reviveAbortSignal(value, ops, runId), "AbortSignal")
|
|
141176
|
+
AbortController: /* @__PURE__ */ __name2((value) => options?.liveAbortSignals === false ? reviveAbortSnapshot(value) : reviveAbortController(value, ops, runId), "AbortController"),
|
|
141177
|
+
AbortSignal: /* @__PURE__ */ __name2((value) => options?.liveAbortSignals === false ? reviveAbortSnapshot(value).signal : reviveAbortSignal(value, ops, runId), "AbortSignal")
|
|
140151
141178
|
};
|
|
140152
141179
|
}
|
|
140153
141180
|
__name(getExternalRevivers, "getExternalRevivers");
|
|
@@ -140874,6 +141901,7 @@ var init_serialization2 = __esm2({
|
|
|
140874
141901
|
__name2(tagForwardedWritableTarget, "tagForwardedWritableTarget");
|
|
140875
141902
|
__name2(createForwardedWritable, "createForwardedWritable");
|
|
140876
141903
|
__name2(getRunReadableStream, "getRunReadableStream");
|
|
141904
|
+
__name2(getLazyReadableStream, "getLazyReadableStream");
|
|
140877
141905
|
__name2(getExternalRevivers, "getExternalRevivers");
|
|
140878
141906
|
__name2(getStepRevivers, "getStepRevivers");
|
|
140879
141907
|
__name2(dehydrateWorkflowArguments, "dehydrateWorkflowArguments");
|
|
@@ -141011,7 +142039,7 @@ init_dist4();
|
|
|
141011
142039
|
init_node();
|
|
141012
142040
|
init_dist2();
|
|
141013
142041
|
init_attributes_validation();
|
|
141014
|
-
function normalizeAttributeChanges(attrs, options = {}) {
|
|
142042
|
+
function normalizeAttributeChanges(attrs, options = {}, writer) {
|
|
141015
142043
|
if (attrs === null || typeof attrs !== "object" || Array.isArray(attrs)) {
|
|
141016
142044
|
throw new FatalError(`setAttributes requires a plain object, got ${attrs === null ? "null" : Array.isArray(attrs) ? "array" : typeof attrs}`);
|
|
141017
142045
|
}
|
|
@@ -141025,6 +142053,15 @@ function normalizeAttributeChanges(attrs, options = {}) {
|
|
|
141025
142053
|
validateAttributeChanges(changes, {
|
|
141026
142054
|
allowReservedAttributes
|
|
141027
142055
|
});
|
|
142056
|
+
if (writer) {
|
|
142057
|
+
validateAttributeEventDataSize({
|
|
142058
|
+
changes,
|
|
142059
|
+
writer,
|
|
142060
|
+
...allowReservedAttributes ? {
|
|
142061
|
+
allowReservedAttributes: true
|
|
142062
|
+
} : {}
|
|
142063
|
+
});
|
|
142064
|
+
}
|
|
141028
142065
|
} catch (err) {
|
|
141029
142066
|
if (err instanceof AttributeValidationError) {
|
|
141030
142067
|
throw new FatalError(err.message);
|
|
@@ -141375,7 +142412,7 @@ __name2(start, "start");
|
|
|
141375
142412
|
value: "start",
|
|
141376
142413
|
configurable: true
|
|
141377
142414
|
});
|
|
141378
|
-
})(start, "step//@workflow/core/runtime/start@5.0.0-beta.
|
|
142415
|
+
})(start, "step//@workflow/core/runtime/start@5.0.0-beta.55//start");
|
|
141379
142416
|
async function wakeUpRun(world, runId, options) {
|
|
141380
142417
|
try {
|
|
141381
142418
|
const run22 = await world.runs.get(runId, {
|
|
@@ -141637,27 +142674,35 @@ var Run = class _Run {
|
|
|
141637
142674
|
* The name of the workflow.
|
|
141638
142675
|
*/
|
|
141639
142676
|
get workflowName() {
|
|
141640
|
-
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId
|
|
142677
|
+
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId, {
|
|
142678
|
+
resolveData: "none"
|
|
142679
|
+
}).then((run22) => run22.workflowName));
|
|
141641
142680
|
}
|
|
141642
142681
|
/**
|
|
141643
142682
|
* The timestamp when the workflow run was created.
|
|
141644
142683
|
*/
|
|
141645
142684
|
get createdAt() {
|
|
141646
|
-
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId
|
|
142685
|
+
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId, {
|
|
142686
|
+
resolveData: "none"
|
|
142687
|
+
}).then((run22) => run22.createdAt));
|
|
141647
142688
|
}
|
|
141648
142689
|
/**
|
|
141649
142690
|
* The timestamp when the workflow run started execution.
|
|
141650
142691
|
* Returns undefined if the workflow has not started yet.
|
|
141651
142692
|
*/
|
|
141652
142693
|
get startedAt() {
|
|
141653
|
-
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId
|
|
142694
|
+
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId, {
|
|
142695
|
+
resolveData: "none"
|
|
142696
|
+
}).then((run22) => run22.startedAt));
|
|
141654
142697
|
}
|
|
141655
142698
|
/**
|
|
141656
142699
|
* The timestamp when the workflow run completed.
|
|
141657
142700
|
* Returns undefined if the workflow has not completed yet.
|
|
141658
142701
|
*/
|
|
141659
142702
|
get completedAt() {
|
|
141660
|
-
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId
|
|
142703
|
+
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId, {
|
|
142704
|
+
resolveData: "none"
|
|
142705
|
+
}).then((run22) => run22.completedAt));
|
|
141661
142706
|
}
|
|
141662
142707
|
/**
|
|
141663
142708
|
* The readable stream of the workflow run.
|
|
@@ -141842,7 +142887,7 @@ var Run = class _Run {
|
|
|
141842
142887
|
value: "wakeUp",
|
|
141843
142888
|
configurable: true
|
|
141844
142889
|
});
|
|
141845
|
-
})(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
142890
|
+
})(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.55//Run#wakeUp");
|
|
141846
142891
|
(function(__wf_fn, __wf_id) {
|
|
141847
142892
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
141848
142893
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -141851,7 +142896,7 @@ var Run = class _Run {
|
|
|
141851
142896
|
value: "cancel",
|
|
141852
142897
|
configurable: true
|
|
141853
142898
|
});
|
|
141854
|
-
})(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
142899
|
+
})(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.55//Run#cancel");
|
|
141855
142900
|
(function(__wf_fn, __wf_id) {
|
|
141856
142901
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
141857
142902
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -141860,7 +142905,7 @@ var Run = class _Run {
|
|
|
141860
142905
|
value: "getReadable",
|
|
141861
142906
|
configurable: true
|
|
141862
142907
|
});
|
|
141863
|
-
})(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
142908
|
+
})(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.55//Run#getReadable");
|
|
141864
142909
|
(function(__wf_fn, __wf_id) {
|
|
141865
142910
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
141866
142911
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -141869,7 +142914,7 @@ var Run = class _Run {
|
|
|
141869
142914
|
value: "getWritable",
|
|
141870
142915
|
configurable: true
|
|
141871
142916
|
});
|
|
141872
|
-
})(Run.prototype["getWritable"], "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
142917
|
+
})(Run.prototype["getWritable"], "step//@workflow/core/runtime/run@5.0.0-beta.55//Run#getWritable");
|
|
141873
142918
|
(function(__wf_fn, __wf_id) {
|
|
141874
142919
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
141875
142920
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -141878,7 +142923,7 @@ var Run = class _Run {
|
|
|
141878
142923
|
value: "exists",
|
|
141879
142924
|
configurable: true
|
|
141880
142925
|
});
|
|
141881
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
142926
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.55//Run#exists");
|
|
141882
142927
|
(function(__wf_fn, __wf_id) {
|
|
141883
142928
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
141884
142929
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -141887,7 +142932,7 @@ var Run = class _Run {
|
|
|
141887
142932
|
value: "status",
|
|
141888
142933
|
configurable: true
|
|
141889
142934
|
});
|
|
141890
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
142935
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.55//Run#status");
|
|
141891
142936
|
(function(__wf_fn, __wf_id) {
|
|
141892
142937
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
141893
142938
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -141896,7 +142941,7 @@ var Run = class _Run {
|
|
|
141896
142941
|
value: "returnValue",
|
|
141897
142942
|
configurable: true
|
|
141898
142943
|
});
|
|
141899
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
142944
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.55//Run#returnValue");
|
|
141900
142945
|
(function(__wf_fn, __wf_id) {
|
|
141901
142946
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
141902
142947
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -141905,7 +142950,7 @@ var Run = class _Run {
|
|
|
141905
142950
|
value: "workflowName",
|
|
141906
142951
|
configurable: true
|
|
141907
142952
|
});
|
|
141908
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
142953
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.55//Run#workflowName");
|
|
141909
142954
|
(function(__wf_fn, __wf_id) {
|
|
141910
142955
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
141911
142956
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -141914,7 +142959,7 @@ var Run = class _Run {
|
|
|
141914
142959
|
value: "createdAt",
|
|
141915
142960
|
configurable: true
|
|
141916
142961
|
});
|
|
141917
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
142962
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.55//Run#createdAt");
|
|
141918
142963
|
(function(__wf_fn, __wf_id) {
|
|
141919
142964
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
141920
142965
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -141923,7 +142968,7 @@ var Run = class _Run {
|
|
|
141923
142968
|
value: "startedAt",
|
|
141924
142969
|
configurable: true
|
|
141925
142970
|
});
|
|
141926
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
142971
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.55//Run#startedAt");
|
|
141927
142972
|
(function(__wf_fn, __wf_id) {
|
|
141928
142973
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
141929
142974
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -141932,7 +142977,7 @@ var Run = class _Run {
|
|
|
141932
142977
|
value: "completedAt",
|
|
141933
142978
|
configurable: true
|
|
141934
142979
|
});
|
|
141935
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
142980
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.55//Run#completedAt");
|
|
141936
142981
|
(function(__wf_cls, __wf_id) {
|
|
141937
142982
|
var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
141938
142983
|
__wf_reg.set(__wf_id, __wf_cls);
|
|
@@ -141942,7 +142987,7 @@ var Run = class _Run {
|
|
|
141942
142987
|
enumerable: false,
|
|
141943
142988
|
configurable: false
|
|
141944
142989
|
});
|
|
141945
|
-
})(Run, "class//@workflow/core/runtime/run@5.0.0-beta.
|
|
142990
|
+
})(Run, "class//@workflow/core/runtime/run@5.0.0-beta.55//Run");
|
|
141946
142991
|
async function fetch2(...args) {
|
|
141947
142992
|
return globalThis.fetch(...args);
|
|
141948
142993
|
}
|
|
@@ -142698,6 +143743,7 @@ init_logger2();
|
|
|
142698
143743
|
init_serialization4();
|
|
142699
143744
|
init_semantic_conventions2();
|
|
142700
143745
|
init_constants3();
|
|
143746
|
+
init_lifecycle_hooks();
|
|
142701
143747
|
var MAX_REROUTE_DELAY_SECONDS = 8;
|
|
142702
143748
|
var CONTINUE = { outcome: "continue" };
|
|
142703
143749
|
function result(outcome, pinnedDeploymentId, attempts) {
|
|
@@ -142711,7 +143757,7 @@ function result(outcome, pinnedDeploymentId, attempts) {
|
|
|
142711
143757
|
};
|
|
142712
143758
|
}
|
|
142713
143759
|
__name(result, "result");
|
|
142714
|
-
async function guardDeploymentAffinity({ world, run: run3, requestId, retryCount = 0, reenqueue, isDeploymentUnavailableError, beforeStop }) {
|
|
143760
|
+
async function guardDeploymentAffinity({ world, run: run3, workflowName, requestId, retryCount = 0, reenqueue, isDeploymentUnavailableError, beforeStop }) {
|
|
142715
143761
|
if (world.capabilities?.deploymentAffinity !== true) {
|
|
142716
143762
|
return CONTINUE;
|
|
142717
143763
|
}
|
|
@@ -142731,17 +143777,16 @@ async function guardDeploymentAffinity({ world, run: run3, requestId, retryCount
|
|
|
142731
143777
|
const failRun = /* @__PURE__ */ __name(async (recoveryAttempts, cause) => {
|
|
142732
143778
|
const error121 = new WorkflowDeploymentMismatchError(run3.runId, run3.deploymentId, currentDeploymentId, { recoveryAttempts, cause });
|
|
142733
143779
|
try {
|
|
143780
|
+
const dehydratedError = await dehydrateRunError(error121, run3.runId, void 0, void 0, (run3.specVersion ?? 0) >= SPEC_VERSION_SUPPORTS_COMPRESSION2);
|
|
142734
143781
|
await world.events.create(run3.runId, {
|
|
142735
143782
|
eventType: "run_failed",
|
|
142736
143783
|
specVersion: SPEC_VERSION_CURRENT2,
|
|
142737
143784
|
eventData: {
|
|
142738
|
-
|
|
142739
|
-
// `guardDeploymentAffinity`. dehydrate/hydrate are self-describing,
|
|
142740
|
-
// so this reads back without a key.
|
|
142741
|
-
error: await dehydrateRunError(error121, run3.runId, void 0, void 0, (run3.specVersion ?? 0) >= SPEC_VERSION_SUPPORTS_COMPRESSION2),
|
|
143785
|
+
error: dehydratedError,
|
|
142742
143786
|
errorCode: RUN_ERROR_CODES2.DEPLOYMENT_MISMATCH
|
|
142743
143787
|
}
|
|
142744
143788
|
}, { requestId });
|
|
143789
|
+
dispatchRunFailedHooks(run3.runId, workflowName, dehydratedError, void 0, RUN_ERROR_CODES2.DEPLOYMENT_MISMATCH);
|
|
142745
143790
|
} catch (failError) {
|
|
142746
143791
|
if (!EntityConflictError2.is(failError) && !RunExpiredError2.is(failError)) {
|
|
142747
143792
|
throw failError;
|
|
@@ -142780,6 +143825,8 @@ __name(guardDeploymentAffinity, "guardDeploymentAffinity");
|
|
|
142780
143825
|
|
|
142781
143826
|
// ../core/dist/runtime.js
|
|
142782
143827
|
init_helpers3();
|
|
143828
|
+
init_invocations2();
|
|
143829
|
+
init_lifecycle_hooks();
|
|
142783
143830
|
init_replay_budget();
|
|
142784
143831
|
init_replay_recovery_reporter();
|
|
142785
143832
|
init_resume_latency();
|
|
@@ -143714,32 +144761,8 @@ function isWorldValidationFailure(err) {
|
|
|
143714
144761
|
}
|
|
143715
144762
|
__name(isWorldValidationFailure, "isWorldValidationFailure");
|
|
143716
144763
|
|
|
143717
|
-
// ../core/dist/runtime/vm-mode.js
|
|
143718
|
-
init_dist7();
|
|
143719
|
-
var WORKFLOW_VMS2 = ["node", "quickjs"];
|
|
143720
|
-
function getWorkflowVmFromEnv2(env = process.env) {
|
|
143721
|
-
const raw = env.WORKFLOW_VM;
|
|
143722
|
-
if (raw === void 0 || raw === "")
|
|
143723
|
-
return void 0;
|
|
143724
|
-
if (WORKFLOW_VMS2.includes(raw)) {
|
|
143725
|
-
return raw;
|
|
143726
|
-
}
|
|
143727
|
-
throw new WorkflowRuntimeError2(`Invalid WORKFLOW_VM value: "${raw}". Expected one of: ${WORKFLOW_VMS2.join(", ")}.`);
|
|
143728
|
-
}
|
|
143729
|
-
__name(getWorkflowVmFromEnv2, "getWorkflowVmFromEnv");
|
|
143730
|
-
function useQuickJSVm(workflowRun) {
|
|
143731
|
-
const vmFromRun = workflowRun.executionContext?.workflowVm;
|
|
143732
|
-
if (vmFromRun !== void 0) {
|
|
143733
|
-
if (!WORKFLOW_VMS2.includes(vmFromRun)) {
|
|
143734
|
-
throw new WorkflowRuntimeError2(`Invalid executionContext.workflowVm value: "${vmFromRun}". Expected one of: ${WORKFLOW_VMS2.join(", ")}.`);
|
|
143735
|
-
}
|
|
143736
|
-
return vmFromRun === "quickjs";
|
|
143737
|
-
}
|
|
143738
|
-
return getWorkflowVmFromEnv2() === "quickjs";
|
|
143739
|
-
}
|
|
143740
|
-
__name(useQuickJSVm, "useQuickJSVm");
|
|
143741
|
-
|
|
143742
144764
|
// ../core/dist/runtime.js
|
|
144765
|
+
init_vm_mode();
|
|
143743
144766
|
init_wait_continuation();
|
|
143744
144767
|
init_world();
|
|
143745
144768
|
init_serialization4();
|
|
@@ -143898,7 +144921,9 @@ function createUseStep(ctx) {
|
|
|
143898
144921
|
if (event.eventType === "step_failed") {
|
|
143899
144922
|
ctx.invocationsQueue.delete(event.correlationId);
|
|
143900
144923
|
const eventIndex = ctx.eventsConsumer.eventIndex;
|
|
143901
|
-
const barrier = registerDeliveryBarrier(ctx, eventIndex, "step"
|
|
144924
|
+
const barrier = registerDeliveryBarrier(ctx, eventIndex, "step", {
|
|
144925
|
+
deliveredAt: +event.createdAt
|
|
144926
|
+
});
|
|
143902
144927
|
let rejection;
|
|
143903
144928
|
const earlierDelivered = awaitEarlierDeliveries(ctx, eventIndex, "step");
|
|
143904
144929
|
ctx.pendingDeliveries++;
|
|
@@ -143927,7 +144952,9 @@ function createUseStep(ctx) {
|
|
|
143927
144952
|
const completedEventId = event.eventId;
|
|
143928
144953
|
const serializedResult = event.eventData.result;
|
|
143929
144954
|
const eventIndex = ctx.eventsConsumer.eventIndex;
|
|
143930
|
-
const barrier = registerDeliveryBarrier(ctx, eventIndex, "step"
|
|
144955
|
+
const barrier = registerDeliveryBarrier(ctx, eventIndex, "step", {
|
|
144956
|
+
deliveredAt: +event.createdAt
|
|
144957
|
+
});
|
|
143931
144958
|
let outcome;
|
|
143932
144959
|
const earlierDelivered = awaitEarlierDeliveries(ctx, eventIndex, "step");
|
|
143933
144960
|
ctx.pendingDeliveries++;
|
|
@@ -144591,12 +145618,26 @@ init_abort_controller2();
|
|
|
144591
145618
|
// ../core/dist/workflow/attribute-dispatcher.js
|
|
144592
145619
|
init_dist7();
|
|
144593
145620
|
init_dist5();
|
|
145621
|
+
init_attributes_validation2();
|
|
144594
145622
|
init_events_consumer2();
|
|
144595
145623
|
init_private2();
|
|
144596
145624
|
function createSetAttributes(ctx) {
|
|
144597
145625
|
return /* @__PURE__ */ __name(async function setAttributes(changes, options = {}) {
|
|
144598
145626
|
const { promise: promise3, resolve: resolve3 } = withResolvers2();
|
|
144599
145627
|
const correlationId = `attr_${ctx.generateUlid()}`;
|
|
145628
|
+
try {
|
|
145629
|
+
validateAttributeEventDataSize2({
|
|
145630
|
+
changes,
|
|
145631
|
+
writer: { type: "workflow" },
|
|
145632
|
+
...options.allowReservedAttributes === true ? { allowReservedAttributes: true } : {}
|
|
145633
|
+
});
|
|
145634
|
+
} catch (error121) {
|
|
145635
|
+
if (!(error121 instanceof AttributeValidationError2))
|
|
145636
|
+
throw error121;
|
|
145637
|
+
const persisted = ctx.eventsConsumer.events.some((event) => event.eventType === "attr_set" && event.correlationId === correlationId);
|
|
145638
|
+
if (!persisted)
|
|
145639
|
+
throw new FatalError2(error121.message);
|
|
145640
|
+
}
|
|
144600
145641
|
const queueItem = {
|
|
144601
145642
|
type: "attribute",
|
|
144602
145643
|
correlationId,
|
|
@@ -144685,6 +145726,26 @@ function createCreateHook(ctx) {
|
|
|
144685
145726
|
let hasConflict = false;
|
|
144686
145727
|
let conflictErrorRef = null;
|
|
144687
145728
|
let conflictRunRef = null;
|
|
145729
|
+
let registrationDelivered = Promise.resolve();
|
|
145730
|
+
function deliverRegistration(deliveredAt, settle) {
|
|
145731
|
+
const eventIndex = ctx.eventsConsumer.eventIndex;
|
|
145732
|
+
const barrier = registerDeliveryBarrier(ctx, eventIndex, "hook", {
|
|
145733
|
+
deliveredAt
|
|
145734
|
+
});
|
|
145735
|
+
const earlierDelivered = awaitEarlierDeliveries(ctx, eventIndex, "hook");
|
|
145736
|
+
registrationDelivered = ctx.promiseQueue.then(() => earlierDelivered).then(() => {
|
|
145737
|
+
barrier.markDelivered();
|
|
145738
|
+
settle();
|
|
145739
|
+
});
|
|
145740
|
+
}
|
|
145741
|
+
__name(deliverRegistration, "deliverRegistration");
|
|
145742
|
+
function afterRegistration(settle) {
|
|
145743
|
+
const delivered = registrationDelivered;
|
|
145744
|
+
ctx.promiseQueue = ctx.promiseQueue.then(() => {
|
|
145745
|
+
void delivered.then(settle);
|
|
145746
|
+
});
|
|
145747
|
+
}
|
|
145748
|
+
__name(afterRegistration, "afterRegistration");
|
|
144688
145749
|
const seenResumeIds = /* @__PURE__ */ new Set();
|
|
144689
145750
|
webhookLogger2.debug("Hook consumer setup", { correlationId, token });
|
|
144690
145751
|
ctx.eventsConsumer.subscribe((event) => {
|
|
@@ -144714,7 +145775,7 @@ function createCreateHook(ctx) {
|
|
|
144714
145775
|
hasCreated = true;
|
|
144715
145776
|
const pendingGetConflictPromises = getConflictPromises.slice();
|
|
144716
145777
|
getConflictPromises.length = 0;
|
|
144717
|
-
|
|
145778
|
+
deliverRegistration(+event.createdAt, () => {
|
|
144718
145779
|
for (const resolver2 of pendingGetConflictPromises) {
|
|
144719
145780
|
resolver2.resolve(null);
|
|
144720
145781
|
}
|
|
@@ -144732,7 +145793,7 @@ function createCreateHook(ctx) {
|
|
|
144732
145793
|
promises.length = 0;
|
|
144733
145794
|
const pendingGetConflictPromises = getConflictPromises.slice();
|
|
144734
145795
|
getConflictPromises.length = 0;
|
|
144735
|
-
|
|
145796
|
+
deliverRegistration(+event.createdAt, () => {
|
|
144736
145797
|
for (const resolver2 of pendingPromises) {
|
|
144737
145798
|
resolver2.reject(conflictError);
|
|
144738
145799
|
}
|
|
@@ -144757,7 +145818,8 @@ function createCreateHook(ctx) {
|
|
|
144757
145818
|
const eventIndex = ctx.eventsConsumer.eventIndex;
|
|
144758
145819
|
const hasWaitingConsumer = promises.length > 0;
|
|
144759
145820
|
const barrier = registerDeliveryBarrier(ctx, eventIndex, "hook", {
|
|
144760
|
-
armed: hasWaitingConsumer
|
|
145821
|
+
armed: hasWaitingConsumer,
|
|
145822
|
+
deliveredAt: +event.createdAt
|
|
144761
145823
|
});
|
|
144762
145824
|
if (hasWaitingConsumer) {
|
|
144763
145825
|
const earlierDelivered = awaitEarlierDeliveries(ctx, eventIndex, "hook");
|
|
@@ -144829,7 +145891,7 @@ function createCreateHook(ctx) {
|
|
|
144829
145891
|
function createHookPromise() {
|
|
144830
145892
|
const resolvers = withResolvers2();
|
|
144831
145893
|
if (hasConflict && conflictErrorRef) {
|
|
144832
|
-
|
|
145894
|
+
afterRegistration(() => {
|
|
144833
145895
|
resolvers.reject(conflictErrorRef);
|
|
144834
145896
|
});
|
|
144835
145897
|
return resolvers.promise;
|
|
@@ -144850,13 +145912,13 @@ function createCreateHook(ctx) {
|
|
|
144850
145912
|
function createGetConflictPromise() {
|
|
144851
145913
|
const resolvers = withResolvers2();
|
|
144852
145914
|
if (hasCreated) {
|
|
144853
|
-
|
|
145915
|
+
afterRegistration(() => {
|
|
144854
145916
|
resolvers.resolve(null);
|
|
144855
145917
|
});
|
|
144856
145918
|
return resolvers.promise;
|
|
144857
145919
|
}
|
|
144858
145920
|
if (hasConflict) {
|
|
144859
|
-
|
|
145921
|
+
afterRegistration(() => {
|
|
144860
145922
|
if (conflictRunRef) {
|
|
144861
145923
|
resolvers.resolve(conflictRunRef);
|
|
144862
145924
|
} else {
|
|
@@ -144972,7 +146034,9 @@ function createSleep(ctx) {
|
|
|
144972
146034
|
}
|
|
144973
146035
|
ctx.invocationsQueue.delete(correlationId);
|
|
144974
146036
|
const eventIndex = ctx.eventsConsumer.eventIndex;
|
|
144975
|
-
const barrier = registerDeliveryBarrier(ctx, eventIndex, "wait"
|
|
146037
|
+
const barrier = registerDeliveryBarrier(ctx, eventIndex, "wait", {
|
|
146038
|
+
deliveredAt: +event.createdAt
|
|
146039
|
+
});
|
|
144976
146040
|
const earlierDelivered = awaitEarlierDeliveries(ctx, eventIndex, "wait");
|
|
144977
146041
|
const queueAtCompletion = ctx.promiseQueue;
|
|
144978
146042
|
void queueAtCompletion.then(() => earlierDelivered).then(() => {
|
|
@@ -145141,14 +146205,13 @@ async function createWorkflowSessionInner({ workflowCode: workflowCode2, workflo
|
|
|
145141
146205
|
const promiseQueueHolder = { current: Promise.resolve() };
|
|
145142
146206
|
const deliveryIdleHolder = { current: /* @__PURE__ */ __name(() => true, "current") };
|
|
145143
146207
|
let clock = fixedTimestamp;
|
|
146208
|
+
const advanceClock = /* @__PURE__ */ __name((at) => {
|
|
146209
|
+
if (at > clock) {
|
|
146210
|
+
clock = at;
|
|
146211
|
+
updateTimestamp(at);
|
|
146212
|
+
}
|
|
146213
|
+
}, "advanceClock");
|
|
145144
146214
|
const eventsConsumer = new EventsConsumer(events, {
|
|
145145
|
-
onConsumedEvent: /* @__PURE__ */ __name((event) => {
|
|
145146
|
-
const at = +event.createdAt;
|
|
145147
|
-
if (at > clock) {
|
|
145148
|
-
clock = at;
|
|
145149
|
-
updateTimestamp(at);
|
|
145150
|
-
}
|
|
145151
|
-
}, "onConsumedEvent"),
|
|
145152
146215
|
onUnconsumedEvent: /* @__PURE__ */ __name((event) => {
|
|
145153
146216
|
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 }));
|
|
145154
146217
|
}, "onUnconsumedEvent"),
|
|
@@ -145201,6 +146264,7 @@ async function createWorkflowSessionInner({ workflowCode: workflowCode2, workflo
|
|
|
145201
146264
|
pendingDeliveries: 0,
|
|
145202
146265
|
suspensionGeneration: 0,
|
|
145203
146266
|
pendingDeliveryBarriers: /* @__PURE__ */ new Map(),
|
|
146267
|
+
advanceClock,
|
|
145204
146268
|
replayPayloadCache
|
|
145205
146269
|
};
|
|
145206
146270
|
deliveryIdleHolder.current = () => isDeliveryIdle(workflowContext);
|
|
@@ -145735,481 +146799,9 @@ __name(createWorkflowSessionInner, "createWorkflowSessionInner");
|
|
|
145735
146799
|
init_global2();
|
|
145736
146800
|
init_helpers3();
|
|
145737
146801
|
init_resume_hook2();
|
|
145738
|
-
|
|
145739
|
-
|
|
145740
|
-
|
|
145741
|
-
init_dist12();
|
|
145742
|
-
init_env_config2();
|
|
145743
|
-
init_spec_version2();
|
|
145744
|
-
init_encryption5();
|
|
145745
|
-
init_serialization4();
|
|
145746
|
-
init_util5();
|
|
145747
|
-
init_get_world_lazy2();
|
|
145748
|
-
|
|
145749
|
-
// ../core/dist/runtime/runs.js
|
|
145750
|
-
init_dist7();
|
|
145751
|
-
init_dist6();
|
|
145752
|
-
init_encryption5();
|
|
145753
|
-
init_serialization4();
|
|
145754
|
-
init_helpers3();
|
|
145755
|
-
|
|
145756
|
-
// ../core/dist/runtime/start.js
|
|
145757
|
-
init_dist7();
|
|
145758
|
-
init_dist5();
|
|
145759
|
-
init_dist6();
|
|
145760
|
-
init_node2();
|
|
145761
|
-
|
|
145762
|
-
// ../core/dist/attribute-changes.js
|
|
145763
|
-
init_dist7();
|
|
145764
|
-
init_attributes_validation2();
|
|
145765
|
-
|
|
145766
|
-
// ../core/dist/runtime/start.js
|
|
145767
|
-
init_capabilities2();
|
|
145768
|
-
init_classify_error();
|
|
145769
|
-
init_encryption4();
|
|
145770
|
-
init_logger2();
|
|
145771
|
-
init_sealed_box2();
|
|
145772
|
-
init_serialization4();
|
|
145773
|
-
init_context_storage2();
|
|
145774
|
-
init_semantic_conventions2();
|
|
145775
|
-
init_telemetry4();
|
|
145776
|
-
init_version4();
|
|
145777
|
-
init_get_world_lazy2();
|
|
145778
|
-
init_helpers3();
|
|
145779
|
-
init_wait_until2();
|
|
145780
|
-
init_world_compatibility2();
|
|
145781
|
-
var ulid7 = monotonicFactory2();
|
|
145782
|
-
var latestNoOpWarning2 = globalSingleton2("@workflow/core//latestNoOpWarning", 1, () => ({ warned: false }));
|
|
145783
|
-
|
|
145784
|
-
// ../core/dist/runtime/runs.js
|
|
145785
|
-
async function wakeUpRun2(world, runId, options) {
|
|
145786
|
-
try {
|
|
145787
|
-
const run3 = await world.runs.get(runId, { resolveData: "none" });
|
|
145788
|
-
const compatMode = isLegacySpecVersion2(run3.specVersion);
|
|
145789
|
-
const allEvents = [];
|
|
145790
|
-
let cursor = null;
|
|
145791
|
-
do {
|
|
145792
|
-
const eventsResult = await world.events.list({
|
|
145793
|
-
runId,
|
|
145794
|
-
pagination: { sortOrder: "asc", ...cursor ? { cursor } : {} },
|
|
145795
|
-
resolveData: "none"
|
|
145796
|
-
});
|
|
145797
|
-
allEvents.push(...eventsResult.data);
|
|
145798
|
-
cursor = eventsResult.hasMore ? eventsResult.cursor : null;
|
|
145799
|
-
} while (cursor);
|
|
145800
|
-
const waitCreatedEvents = allEvents.filter((event) => event.eventType === "wait_created");
|
|
145801
|
-
const waitCompletedCorrelationIds = new Set(allEvents.filter((event) => event.eventType === "wait_completed").map((event) => event.correlationId));
|
|
145802
|
-
let pendingWaits = waitCreatedEvents.filter((event) => !waitCompletedCorrelationIds.has(event.correlationId));
|
|
145803
|
-
if (options?.correlationIds && options.correlationIds.length > 0) {
|
|
145804
|
-
const targetCorrelationIds = new Set(options.correlationIds);
|
|
145805
|
-
pendingWaits = pendingWaits.filter((event) => event.correlationId && targetCorrelationIds.has(event.correlationId));
|
|
145806
|
-
}
|
|
145807
|
-
const errors = [];
|
|
145808
|
-
let stoppedCount = 0;
|
|
145809
|
-
for (const waitEvent of pendingWaits) {
|
|
145810
|
-
if (!waitEvent.correlationId)
|
|
145811
|
-
continue;
|
|
145812
|
-
const eventData = compatMode ? {
|
|
145813
|
-
eventType: "wait_completed",
|
|
145814
|
-
correlationId: waitEvent.correlationId
|
|
145815
|
-
} : {
|
|
145816
|
-
eventType: "wait_completed",
|
|
145817
|
-
correlationId: waitEvent.correlationId,
|
|
145818
|
-
specVersion: run3.specVersion,
|
|
145819
|
-
eventData: {
|
|
145820
|
-
resumeAt: waitEvent.eventData.resumeAt
|
|
145821
|
-
}
|
|
145822
|
-
};
|
|
145823
|
-
try {
|
|
145824
|
-
await world.events.create(runId, eventData, { v1Compat: compatMode });
|
|
145825
|
-
stoppedCount++;
|
|
145826
|
-
} catch (err) {
|
|
145827
|
-
if (EntityConflictError2.is(err)) {
|
|
145828
|
-
stoppedCount++;
|
|
145829
|
-
} else {
|
|
145830
|
-
errors.push(err instanceof Error ? err : new Error(String(err)));
|
|
145831
|
-
}
|
|
145832
|
-
}
|
|
145833
|
-
}
|
|
145834
|
-
if (stoppedCount > 0) {
|
|
145835
|
-
await world.queue(getWorkflowQueueName2(run3.workflowName, options?.namespace), {
|
|
145836
|
-
runId
|
|
145837
|
-
}, {
|
|
145838
|
-
deploymentId: run3.deploymentId,
|
|
145839
|
-
specVersion: run3.specVersion ?? SPEC_VERSION_LEGACY2
|
|
145840
|
-
});
|
|
145841
|
-
}
|
|
145842
|
-
if (errors.length > 0) {
|
|
145843
|
-
throw new AggregateError(errors, `Failed to complete ${errors.length}/${pendingWaits.length} pending wait(s) for run ${runId}`);
|
|
145844
|
-
}
|
|
145845
|
-
return { stoppedCount };
|
|
145846
|
-
} catch (err) {
|
|
145847
|
-
if (err instanceof AggregateError) {
|
|
145848
|
-
throw err;
|
|
145849
|
-
}
|
|
145850
|
-
throw new Error(`Failed to wake up run ${runId}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
145851
|
-
}
|
|
145852
|
-
}
|
|
145853
|
-
__name(wakeUpRun2, "wakeUpRun");
|
|
145854
|
-
|
|
145855
|
-
// ../core/dist/runtime/run.js
|
|
145856
|
-
var RETURN_VALUE_POLL_INTERVAL_MS2 = 1e3;
|
|
145857
|
-
var PAYLOAD_TERMINAL_RUN_STATUSES2 = /* @__PURE__ */ new Set([
|
|
145858
|
-
"completed",
|
|
145859
|
-
"failed"
|
|
145860
|
-
]);
|
|
145861
|
-
var NOT_FOUND_RETRY_DELAYS2 = [1e3, 3e3, 6e3];
|
|
145862
|
-
function getReturnValuePollIntervalMs2() {
|
|
145863
|
-
return envNumber2("WORKFLOW_RETURN_VALUE_POLL_INTERVAL_MS", RETURN_VALUE_POLL_INTERVAL_MS2, { integer: true, min: 1 });
|
|
145864
|
-
}
|
|
145865
|
-
__name(getReturnValuePollIntervalMs2, "getReturnValuePollIntervalMs");
|
|
145866
|
-
var RETURN_VALUE_WAIT_TIMEOUT_MS2 = 5e4;
|
|
145867
|
-
function getReturnValueWaitTimeoutMs2() {
|
|
145868
|
-
return envNumber2("WORKFLOW_RETURN_VALUE_WAIT_MS", RETURN_VALUE_WAIT_TIMEOUT_MS2, { integer: true, min: 1 });
|
|
145869
|
-
}
|
|
145870
|
-
__name(getReturnValueWaitTimeoutMs2, "getReturnValueWaitTimeoutMs");
|
|
145871
|
-
var RETURN_VALUE_MAX_LONG_POLLS2 = 10;
|
|
145872
|
-
function getReturnValueMaxLongPolls2() {
|
|
145873
|
-
return envNumber2("WORKFLOW_RETURN_VALUE_MAX_LONG_POLLS", RETURN_VALUE_MAX_LONG_POLLS2, { integer: true, min: 1 });
|
|
145874
|
-
}
|
|
145875
|
-
__name(getReturnValueMaxLongPolls2, "getReturnValueMaxLongPolls");
|
|
145876
|
-
function isReturnValueLongPollEnabled2() {
|
|
145877
|
-
const raw = process.env.WORKFLOW_RETURN_VALUE_LONG_POLL;
|
|
145878
|
-
if (raw === void 0 || raw === "")
|
|
145879
|
-
return true;
|
|
145880
|
-
return !(raw === "0" || raw.toLowerCase() === "false");
|
|
145881
|
-
}
|
|
145882
|
-
__name(isReturnValueLongPollEnabled2, "isReturnValueLongPollEnabled");
|
|
145883
|
-
var Run2 = class _Run2 {
|
|
145884
|
-
static {
|
|
145885
|
-
__name(this, "Run");
|
|
145886
|
-
}
|
|
145887
|
-
static [WORKFLOW_SERIALIZE2](instance) {
|
|
145888
|
-
return { runId: instance.runId, resilientStart: instance.#resilientStart };
|
|
145889
|
-
}
|
|
145890
|
-
static [WORKFLOW_DESERIALIZE2](data) {
|
|
145891
|
-
return new _Run2(data.runId, { resilientStart: data.resilientStart });
|
|
145892
|
-
}
|
|
145893
|
-
/**
|
|
145894
|
-
* The ID of the workflow run.
|
|
145895
|
-
*/
|
|
145896
|
-
runId;
|
|
145897
|
-
/**
|
|
145898
|
-
* The world object.
|
|
145899
|
-
* @internal
|
|
145900
|
-
*/
|
|
145901
|
-
#worldPromise;
|
|
145902
|
-
get #lazyWorldPromise() {
|
|
145903
|
-
if (!this.#worldPromise)
|
|
145904
|
-
this.#worldPromise = getWorldLazy2();
|
|
145905
|
-
return this.#worldPromise;
|
|
145906
|
-
}
|
|
145907
|
-
/**
|
|
145908
|
-
* Cached encryption key resolution. Resolved once on first use and
|
|
145909
|
-
* reused for returnValue, getReadable(), etc.
|
|
145910
|
-
* @internal
|
|
145911
|
-
*/
|
|
145912
|
-
#encryptionKeyPromise = null;
|
|
145913
|
-
/**
|
|
145914
|
-
* When true, run_created failed and the run may not exist yet (the
|
|
145915
|
-
* resilient start path will create it via run_started). pollReturnValue
|
|
145916
|
-
* retries on WorkflowRunNotFoundError only when this flag is set so
|
|
145917
|
-
* that normal runs fail fast on 404.
|
|
145918
|
-
* @internal
|
|
145919
|
-
*/
|
|
145920
|
-
#resilientStart = false;
|
|
145921
|
-
constructor(runId, opts) {
|
|
145922
|
-
this.runId = runId;
|
|
145923
|
-
this.#resilientStart = opts?.resilientStart ?? false;
|
|
145924
|
-
}
|
|
145925
|
-
/**
|
|
145926
|
-
* Resolves and caches the encryption key for this run.
|
|
145927
|
-
* The key is the same for the lifetime of a run, so it only needs
|
|
145928
|
-
* to be resolved once.
|
|
145929
|
-
* @internal
|
|
145930
|
-
*/
|
|
145931
|
-
#getEncryptionKey(run3) {
|
|
145932
|
-
if (!this.#encryptionKeyPromise) {
|
|
145933
|
-
this.#encryptionKeyPromise = (async () => {
|
|
145934
|
-
const world = await this.#lazyWorldPromise;
|
|
145935
|
-
const runData = run3 ?? await world.runs.get(this.runId);
|
|
145936
|
-
const rawKey = await world.getEncryptionKeyForRun?.(runData);
|
|
145937
|
-
return rawKey ? await deriveRunPayloadKeys2(rawKey) : void 0;
|
|
145938
|
-
})();
|
|
145939
|
-
}
|
|
145940
|
-
return this.#encryptionKeyPromise;
|
|
145941
|
-
}
|
|
145942
|
-
/**
|
|
145943
|
-
* Defers fetching the run and its encryption key until a readable is first
|
|
145944
|
-
* consumed. The first pull prefetches it so an encrypted first frame can join
|
|
145945
|
-
* the lookup; this also applies to an empty consumed stream.
|
|
145946
|
-
* @internal
|
|
145947
|
-
*/
|
|
145948
|
-
#getEncryptionKeyLazily() {
|
|
145949
|
-
return () => this.#getEncryptionKey();
|
|
145950
|
-
}
|
|
145951
|
-
/**
|
|
145952
|
-
* Interrupts pending `sleep()` calls, resuming the workflow early.
|
|
145953
|
-
*
|
|
145954
|
-
* @param options - Optional settings to target specific sleep calls by correlation ID.
|
|
145955
|
-
* If not provided, all pending sleep calls will be interrupted.
|
|
145956
|
-
* @returns A {@link StopSleepResult} object containing the number of sleep calls that were interrupted.
|
|
145957
|
-
*/
|
|
145958
|
-
async wakeUp(options) {
|
|
145959
|
-
"use step";
|
|
145960
|
-
return wakeUpRun2(await this.#lazyWorldPromise, this.runId, options);
|
|
145961
|
-
}
|
|
145962
|
-
/**
|
|
145963
|
-
* Cancels the workflow run.
|
|
145964
|
-
*
|
|
145965
|
-
* @param options - Optional cancellation settings. `cancelReason` records a
|
|
145966
|
-
* free-text reason (max 512 chars) on the run_cancelled event, surfaced in
|
|
145967
|
-
* the run detail view.
|
|
145968
|
-
*/
|
|
145969
|
-
async cancel(options) {
|
|
145970
|
-
"use step";
|
|
145971
|
-
const world = await this.#lazyWorldPromise;
|
|
145972
|
-
await world.events.create(this.runId, {
|
|
145973
|
-
eventType: "run_cancelled",
|
|
145974
|
-
specVersion: SPEC_VERSION_CURRENT2,
|
|
145975
|
-
...options?.cancelReason !== void 0 ? { eventData: { cancelReason: options.cancelReason } } : {}
|
|
145976
|
-
});
|
|
145977
|
-
}
|
|
145978
|
-
/**
|
|
145979
|
-
* Whether the workflow run exists.
|
|
145980
|
-
*/
|
|
145981
|
-
get exists() {
|
|
145982
|
-
"use step";
|
|
145983
|
-
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId, { resolveData: "none" }).then(() => true).catch((error121) => {
|
|
145984
|
-
if (WorkflowRunNotFoundError2.is(error121)) {
|
|
145985
|
-
return false;
|
|
145986
|
-
}
|
|
145987
|
-
throw error121;
|
|
145988
|
-
}));
|
|
145989
|
-
}
|
|
145990
|
-
/**
|
|
145991
|
-
* The status of the workflow run.
|
|
145992
|
-
*/
|
|
145993
|
-
get status() {
|
|
145994
|
-
"use step";
|
|
145995
|
-
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId, { resolveData: "none" }).then((run3) => run3.status));
|
|
145996
|
-
}
|
|
145997
|
-
/**
|
|
145998
|
-
* The return value of the workflow run.
|
|
145999
|
-
* Polls the workflow return value until the workflow run completes.
|
|
146000
|
-
*/
|
|
146001
|
-
get returnValue() {
|
|
146002
|
-
"use step";
|
|
146003
|
-
return this.#pollReturnValue();
|
|
146004
|
-
}
|
|
146005
|
-
/**
|
|
146006
|
-
* The name of the workflow.
|
|
146007
|
-
*/
|
|
146008
|
-
get workflowName() {
|
|
146009
|
-
"use step";
|
|
146010
|
-
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId).then((run3) => run3.workflowName));
|
|
146011
|
-
}
|
|
146012
|
-
/**
|
|
146013
|
-
* The timestamp when the workflow run was created.
|
|
146014
|
-
*/
|
|
146015
|
-
get createdAt() {
|
|
146016
|
-
"use step";
|
|
146017
|
-
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId).then((run3) => run3.createdAt));
|
|
146018
|
-
}
|
|
146019
|
-
/**
|
|
146020
|
-
* The timestamp when the workflow run started execution.
|
|
146021
|
-
* Returns undefined if the workflow has not started yet.
|
|
146022
|
-
*/
|
|
146023
|
-
get startedAt() {
|
|
146024
|
-
"use step";
|
|
146025
|
-
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId).then((run3) => run3.startedAt));
|
|
146026
|
-
}
|
|
146027
|
-
/**
|
|
146028
|
-
* The timestamp when the workflow run completed.
|
|
146029
|
-
* Returns undefined if the workflow has not completed yet.
|
|
146030
|
-
*/
|
|
146031
|
-
get completedAt() {
|
|
146032
|
-
"use step";
|
|
146033
|
-
return this.#lazyWorldPromise.then((world) => world.runs.get(this.runId).then((run3) => run3.completedAt));
|
|
146034
|
-
}
|
|
146035
|
-
/**
|
|
146036
|
-
* The readable stream of the workflow run.
|
|
146037
|
-
*/
|
|
146038
|
-
get readable() {
|
|
146039
|
-
return this.getReadable();
|
|
146040
|
-
}
|
|
146041
|
-
/**
|
|
146042
|
-
* Retrieves the workflow run's default readable stream, which reads chunks
|
|
146043
|
-
* written to the corresponding writable stream {@link getWritable}.
|
|
146044
|
-
*
|
|
146045
|
-
* The returned stream has an additional {@link WorkflowReadableStream.getTailIndex | getTailIndex()}
|
|
146046
|
-
* helper that returns the index of the last known chunk. This is useful when
|
|
146047
|
-
* building reconnection endpoints that need to inform clients where the
|
|
146048
|
-
* stream starts.
|
|
146049
|
-
*
|
|
146050
|
-
* @param options - The options for the readable stream.
|
|
146051
|
-
* @returns A `WorkflowReadableStream` for the workflow run.
|
|
146052
|
-
*/
|
|
146053
|
-
getReadable(options = {}) {
|
|
146054
|
-
"use step";
|
|
146055
|
-
const { ops = [], global: global2 = globalThis, startIndex, namespace } = options;
|
|
146056
|
-
const name = getWorkflowRunStreamId2(this.runId, namespace);
|
|
146057
|
-
const encryptionKey = this.#getEncryptionKeyLazily();
|
|
146058
|
-
const stream = getRunReadableStream2(global2, ops, this.runId, name, startIndex, encryptionKey);
|
|
146059
|
-
const worldPromise = this.#lazyWorldPromise;
|
|
146060
|
-
const runId = this.runId;
|
|
146061
|
-
return Object.assign(stream, {
|
|
146062
|
-
getTailIndex: /* @__PURE__ */ __name(async () => {
|
|
146063
|
-
const world = await worldPromise;
|
|
146064
|
-
const info = await world.streams.getInfo(runId, name);
|
|
146065
|
-
return info.tailIndex;
|
|
146066
|
-
}, "getTailIndex")
|
|
146067
|
-
});
|
|
146068
|
-
}
|
|
146069
|
-
/** The writable stream of the workflow run. */
|
|
146070
|
-
get writable() {
|
|
146071
|
-
return this.getWritable();
|
|
146072
|
-
}
|
|
146073
|
-
/**
|
|
146074
|
-
* Returns a writable that appends to this run's stream.
|
|
146075
|
-
*
|
|
146076
|
-
* Initialization is deferred until the first write. The run must already
|
|
146077
|
-
* exist. The writable may be forwarded through `start()` and into steps, but
|
|
146078
|
-
* grants no read access or additional authorization.
|
|
146079
|
-
*
|
|
146080
|
-
* @remarks
|
|
146081
|
-
* `writer.close()` closes the shared stream. Contributors should call
|
|
146082
|
-
* `releaseLock()`, which also drains pending writes.
|
|
146083
|
-
*
|
|
146084
|
-
* @param options - The writable stream options.
|
|
146085
|
-
*/
|
|
146086
|
-
getWritable(options = {}) {
|
|
146087
|
-
"use step";
|
|
146088
|
-
const { ops = [], global: global2 = globalThis, namespace } = options;
|
|
146089
|
-
const name = getWorkflowRunStreamId2(this.runId, namespace);
|
|
146090
|
-
let targetPromise;
|
|
146091
|
-
let writable;
|
|
146092
|
-
const resolveTarget = /* @__PURE__ */ __name(() => {
|
|
146093
|
-
targetPromise ??= this.#getMetadata().then(async (run3) => {
|
|
146094
|
-
const target2 = {
|
|
146095
|
-
key: await getForwardedWritableEncryptionKey2(this.runId, run3.deploymentId, run3.encryptionPublicKey),
|
|
146096
|
-
deploymentId: run3.deploymentId,
|
|
146097
|
-
encryptionPublicKey: run3.encryptionPublicKey
|
|
146098
|
-
};
|
|
146099
|
-
tagForwardedWritableTarget2(writable, target2);
|
|
146100
|
-
return target2;
|
|
146101
|
-
});
|
|
146102
|
-
return targetPromise;
|
|
146103
|
-
}, "resolveTarget");
|
|
146104
|
-
writable = createForwardedWritable2({
|
|
146105
|
-
global: global2,
|
|
146106
|
-
ops,
|
|
146107
|
-
runId: this.runId,
|
|
146108
|
-
name,
|
|
146109
|
-
key: /* @__PURE__ */ __name(() => resolveTarget().then(({ key }) => key), "key")
|
|
146110
|
-
});
|
|
146111
|
-
return writable;
|
|
146112
|
-
}
|
|
146113
|
-
/** Reads metadata, briefly retrying resilient starts. @internal */
|
|
146114
|
-
async #getMetadata() {
|
|
146115
|
-
const world = await this.#lazyWorldPromise;
|
|
146116
|
-
const maxRetries = this.#resilientStart ? NOT_FOUND_RETRY_DELAYS2.length : 0;
|
|
146117
|
-
let attempt = 0;
|
|
146118
|
-
while (true) {
|
|
146119
|
-
try {
|
|
146120
|
-
return await world.runs.get(this.runId, { resolveData: "none" });
|
|
146121
|
-
} catch (error121) {
|
|
146122
|
-
if (!WorkflowRunNotFoundError2.is(error121) || attempt >= maxRetries) {
|
|
146123
|
-
throw error121;
|
|
146124
|
-
}
|
|
146125
|
-
const delay = NOT_FOUND_RETRY_DELAYS2[attempt];
|
|
146126
|
-
attempt++;
|
|
146127
|
-
await new Promise((resolve3) => setTimeout(resolve3, delay));
|
|
146128
|
-
}
|
|
146129
|
-
}
|
|
146130
|
-
}
|
|
146131
|
-
/** @internal */
|
|
146132
|
-
async #resolveTerminalReturnValue(run3) {
|
|
146133
|
-
const expiredAt = run3.expiredAt;
|
|
146134
|
-
if (expiredAt != null && expiredAt <= /* @__PURE__ */ new Date()) {
|
|
146135
|
-
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);
|
|
146136
|
-
}
|
|
146137
|
-
if (run3.status === "completed") {
|
|
146138
|
-
const encryptionKey = await this.#getEncryptionKey(run3);
|
|
146139
|
-
return await hydrateWorkflowReturnValue2(run3.output, this.runId, encryptionKey);
|
|
146140
|
-
}
|
|
146141
|
-
if (run3.status === "cancelled") {
|
|
146142
|
-
throw new WorkflowRunCancelledError2(this.runId);
|
|
146143
|
-
}
|
|
146144
|
-
if (run3.status === "failed") {
|
|
146145
|
-
const encryptionKey = await this.#getEncryptionKey(run3);
|
|
146146
|
-
let hydratedError;
|
|
146147
|
-
try {
|
|
146148
|
-
hydratedError = await hydrateRunError2(run3.error, this.runId, encryptionKey);
|
|
146149
|
-
} catch {
|
|
146150
|
-
hydratedError = new Error("Failed to hydrate workflow run error");
|
|
146151
|
-
}
|
|
146152
|
-
throw new WorkflowRunFailedError2(this.runId, hydratedError, {
|
|
146153
|
-
errorCode: run3.errorCode
|
|
146154
|
-
});
|
|
146155
|
-
}
|
|
146156
|
-
throw new WorkflowRunNotCompletedError2(this.runId, run3.status);
|
|
146157
|
-
}
|
|
146158
|
-
/**
|
|
146159
|
-
* Polls the workflow return value until the workflow run completes.
|
|
146160
|
-
* @internal
|
|
146161
|
-
* @returns The workflow return value.
|
|
146162
|
-
*/
|
|
146163
|
-
async #pollReturnValue() {
|
|
146164
|
-
const world = await this.#lazyWorldPromise;
|
|
146165
|
-
let notFoundRetries = 0;
|
|
146166
|
-
const NOT_FOUND_MAX_RETRIES = this.#resilientStart ? NOT_FOUND_RETRY_DELAYS2.length : 0;
|
|
146167
|
-
const waitForTerminalStatus = isReturnValueLongPollEnabled2() ? world.runs.waitForTerminalStatus?.bind(world.runs) : void 0;
|
|
146168
|
-
let longPolls = 0;
|
|
146169
|
-
const maxLongPolls = getReturnValueMaxLongPolls2();
|
|
146170
|
-
while (true) {
|
|
146171
|
-
const iterationStartedAt = Date.now();
|
|
146172
|
-
try {
|
|
146173
|
-
const useLongPoll = waitForTerminalStatus && longPolls < maxLongPolls;
|
|
146174
|
-
if (useLongPoll)
|
|
146175
|
-
longPolls++;
|
|
146176
|
-
const runMetadata = useLongPoll ? await waitForTerminalStatus(this.runId, {
|
|
146177
|
-
timeoutMs: getReturnValueWaitTimeoutMs2(),
|
|
146178
|
-
resolveData: "none"
|
|
146179
|
-
}) : await world.runs.get(this.runId, {
|
|
146180
|
-
resolveData: "none"
|
|
146181
|
-
});
|
|
146182
|
-
if (runMetadata.status === "cancelled") {
|
|
146183
|
-
throw new WorkflowRunCancelledError2(this.runId);
|
|
146184
|
-
}
|
|
146185
|
-
if (PAYLOAD_TERMINAL_RUN_STATUSES2.has(runMetadata.status)) {
|
|
146186
|
-
const run3 = await world.runs.get(this.runId, {
|
|
146187
|
-
resolveData: "all"
|
|
146188
|
-
});
|
|
146189
|
-
return await this.#resolveTerminalReturnValue(run3);
|
|
146190
|
-
}
|
|
146191
|
-
throw new WorkflowRunNotCompletedError2(this.runId, runMetadata.status);
|
|
146192
|
-
} catch (error121) {
|
|
146193
|
-
if (WorkflowRunNotCompletedError2.is(error121)) {
|
|
146194
|
-
const remainingIntervalMs = getReturnValuePollIntervalMs2() - (Date.now() - iterationStartedAt);
|
|
146195
|
-
if (remainingIntervalMs > 0) {
|
|
146196
|
-
await new Promise((resolve3) => setTimeout(resolve3, remainingIntervalMs));
|
|
146197
|
-
}
|
|
146198
|
-
continue;
|
|
146199
|
-
}
|
|
146200
|
-
if (WorkflowRunNotFoundError2.is(error121) && notFoundRetries < NOT_FOUND_MAX_RETRIES) {
|
|
146201
|
-
const delay = NOT_FOUND_RETRY_DELAYS2[notFoundRetries];
|
|
146202
|
-
notFoundRetries++;
|
|
146203
|
-
await new Promise((resolve3) => setTimeout(resolve3, delay));
|
|
146204
|
-
continue;
|
|
146205
|
-
}
|
|
146206
|
-
throw error121;
|
|
146207
|
-
}
|
|
146208
|
-
}
|
|
146209
|
-
}
|
|
146210
|
-
};
|
|
146211
|
-
|
|
146212
|
-
// ../core/dist/runtime.js
|
|
146802
|
+
init_run();
|
|
146803
|
+
init_runs4();
|
|
146804
|
+
init_start();
|
|
146213
146805
|
init_world();
|
|
146214
146806
|
function clampMaxEvents(serverValue) {
|
|
146215
146807
|
const override = getMaxEventsOverride();
|
|
@@ -146273,19 +146865,23 @@ function isStepMissingError(err) {
|
|
|
146273
146865
|
return /step/i.test(err.message) && /not found/i.test(err.message);
|
|
146274
146866
|
}
|
|
146275
146867
|
__name(isStepMissingError, "isStepMissingError");
|
|
146276
|
-
async function recordFatalRunError({ world, workflowRun, runId, requestId, err, errorCode, logMessage }) {
|
|
146868
|
+
async function recordFatalRunError({ world, workflowRun, runId, workflowName, requestId, err, errorCode, logMessage }) {
|
|
146277
146869
|
runtimeLogger2.error(logMessage, {
|
|
146278
146870
|
workflowRunId: runId,
|
|
146279
146871
|
errorCode,
|
|
146280
146872
|
error: err instanceof Error ? err.message : String(err)
|
|
146281
146873
|
});
|
|
146874
|
+
let encryptionKey;
|
|
146875
|
+
let dehydratedError;
|
|
146282
146876
|
try {
|
|
146283
146877
|
const getEncryptionKey = memoizeEncryptionKey(world, workflowRun ?? runId);
|
|
146878
|
+
encryptionKey = await getEncryptionKey();
|
|
146879
|
+
dehydratedError = await dehydrateRunError(err, runId, encryptionKey, globalThis, (workflowRun?.specVersion ?? 0) >= SPEC_VERSION_SUPPORTS_COMPRESSION2);
|
|
146284
146880
|
await world.events.create(runId, {
|
|
146285
146881
|
eventType: "run_failed",
|
|
146286
146882
|
specVersion: SPEC_VERSION_CURRENT2,
|
|
146287
146883
|
eventData: {
|
|
146288
|
-
error:
|
|
146884
|
+
error: dehydratedError,
|
|
146289
146885
|
errorCode
|
|
146290
146886
|
}
|
|
146291
146887
|
}, { requestId });
|
|
@@ -146303,6 +146899,7 @@ async function recordFatalRunError({ world, workflowRun, runId, requestId, err,
|
|
|
146303
146899
|
}
|
|
146304
146900
|
throw failErr;
|
|
146305
146901
|
}
|
|
146902
|
+
dispatchRunFailedHooks(runId, workflowName, dehydratedError, encryptionKey, errorCode);
|
|
146306
146903
|
}
|
|
146307
146904
|
__name(recordFatalRunError, "recordFatalRunError");
|
|
146308
146905
|
function findRecordedTerminalRunEvent(events, runId) {
|
|
@@ -146353,7 +146950,7 @@ function openHookAndWaitState(events) {
|
|
|
146353
146950
|
return { openHook: hooks.size > 0, openWait: waits.size > 0 };
|
|
146354
146951
|
}
|
|
146355
146952
|
__name(openHookAndWaitState, "openHookAndWaitState");
|
|
146356
|
-
function getRetentionDecision({ suspension, serializationBlockerCount, hookContinuation = false }) {
|
|
146953
|
+
function getRetentionDecision({ suspension, serializationBlockerCount, hookContinuation = false, invocationContinuation = false }) {
|
|
146357
146954
|
if (!isVmRetentionEnabled()) {
|
|
146358
146955
|
return { retain: false, reason: "disabled" };
|
|
146359
146956
|
}
|
|
@@ -146366,7 +146963,7 @@ function getRetentionDecision({ suspension, serializationBlockerCount, hookConti
|
|
|
146366
146963
|
if (hookContinuation) {
|
|
146367
146964
|
return { retain: true };
|
|
146368
146965
|
}
|
|
146369
|
-
if (suspension.stepCount === 0 && suspension.attributeCount === 0) {
|
|
146966
|
+
if (!invocationContinuation && suspension.stepCount === 0 && suspension.attributeCount === 0) {
|
|
146370
146967
|
return { retain: false, reason: "no_replay_driver" };
|
|
146371
146968
|
}
|
|
146372
146969
|
return { retain: true };
|
|
@@ -146425,7 +147022,7 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
146425
147022
|
setWorkflowBasePath(options?.basePath);
|
|
146426
147023
|
const namespace = resolveQueueNamespace2(options?.namespace);
|
|
146427
147024
|
const workflowPrefix = getQueueTopicPrefix2("workflow", namespace);
|
|
146428
|
-
const handler = /* @__PURE__ */ __name((worldHandlers) => worldHandlers.createQueueHandler(workflowPrefix, async (message_, metadata) => {
|
|
147025
|
+
const handler = /* @__PURE__ */ __name((worldHandlers) => worldHandlers.createQueueHandler(workflowPrefix, withRunInputs(worldHandlers)(async (message_, metadata, activity) => {
|
|
146429
147026
|
const handlerEnteredAtMs = Date.now();
|
|
146430
147027
|
const healthCheck3 = parseHealthCheckPayload(message_);
|
|
146431
147028
|
if (healthCheck3) {
|
|
@@ -146456,14 +147053,17 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
146456
147053
|
const world = await getWorld();
|
|
146457
147054
|
const getEncryptionKey = memoizeEncryptionKey(world, runId);
|
|
146458
147055
|
const err = new FatalError2(`Workflow exceeded maximum queue deliveries (${metadata.attempt}/${maxQueueDeliveries})`);
|
|
147056
|
+
const encryptionKey = await getEncryptionKey();
|
|
147057
|
+
const dehydratedError = await dehydrateRunError(err, runId, encryptionKey);
|
|
146459
147058
|
await world.events.create(runId, {
|
|
146460
147059
|
eventType: "run_failed",
|
|
146461
147060
|
specVersion: SPEC_VERSION_CURRENT2,
|
|
146462
147061
|
eventData: {
|
|
146463
|
-
error:
|
|
147062
|
+
error: dehydratedError,
|
|
146464
147063
|
errorCode: RUN_ERROR_CODES2.MAX_DELIVERIES_EXCEEDED
|
|
146465
147064
|
}
|
|
146466
147065
|
}, { requestId });
|
|
147066
|
+
dispatchRunFailedHooks(runId, workflowName, dehydratedError, encryptionKey, RUN_ERROR_CODES2.MAX_DELIVERIES_EXCEEDED);
|
|
146467
147067
|
} catch (err) {
|
|
146468
147068
|
if (EntityConflictError2.is(err) || RunExpiredError2.is(err)) {
|
|
146469
147069
|
return;
|
|
@@ -146621,6 +147221,7 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
146621
147221
|
world,
|
|
146622
147222
|
workflowRun,
|
|
146623
147223
|
runId,
|
|
147224
|
+
workflowName,
|
|
146624
147225
|
requestId,
|
|
146625
147226
|
err,
|
|
146626
147227
|
errorCode,
|
|
@@ -146735,6 +147336,7 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
146735
147336
|
const { outcome, spanAttributes } = await guardDeploymentAffinity({
|
|
146736
147337
|
world,
|
|
146737
147338
|
run: run3,
|
|
147339
|
+
workflowName,
|
|
146738
147340
|
requestId,
|
|
146739
147341
|
retryCount: deploymentMismatchRetryCount,
|
|
146740
147342
|
beforeStop,
|
|
@@ -146893,6 +147495,14 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
146893
147495
|
if (stepResult.type === "throttled") {
|
|
146894
147496
|
return { timeoutSeconds: stepResult.timeoutSeconds };
|
|
146895
147497
|
}
|
|
147498
|
+
if (world.capabilities?.invoke && stepResult.type !== "gone") {
|
|
147499
|
+
await queueMessage(world, getWorkflowQueueName2(workflowName, namespace), {
|
|
147500
|
+
runId,
|
|
147501
|
+
traceCarrier: await nextTraceCarrier(),
|
|
147502
|
+
requestedAt: /* @__PURE__ */ new Date()
|
|
147503
|
+
});
|
|
147504
|
+
return;
|
|
147505
|
+
}
|
|
146896
147506
|
if (stepResult.type === "completed" && stepResult.hasPendingOps) {
|
|
146897
147507
|
await queueMessage(world, getWorkflowQueueName2(workflowName, namespace), {
|
|
146898
147508
|
runId,
|
|
@@ -146976,6 +147586,7 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
146976
147586
|
world,
|
|
146977
147587
|
workflowRun,
|
|
146978
147588
|
runId,
|
|
147589
|
+
workflowName,
|
|
146979
147590
|
requestId,
|
|
146980
147591
|
err,
|
|
146981
147592
|
errorCode,
|
|
@@ -147304,6 +147915,7 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
147304
147915
|
const continuedHookIds = /* @__PURE__ */ new Set();
|
|
147305
147916
|
const publishedStepCorrelationIds = /* @__PURE__ */ new Set();
|
|
147306
147917
|
while (true) {
|
|
147918
|
+
const invocationRevision = activity?.revision ?? 0;
|
|
147307
147919
|
loopIteration++;
|
|
147308
147920
|
if (replayBudget.isExhausted()) {
|
|
147309
147921
|
await handleReplayBudgetExhausted({
|
|
@@ -147530,6 +148142,7 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
147530
148142
|
}
|
|
147531
148143
|
throw err;
|
|
147532
148144
|
}
|
|
148145
|
+
dispatchRunCompletedHooks(runId, workflowName);
|
|
147533
148146
|
span?.setAttributes({
|
|
147534
148147
|
...WorkflowRunStatus2("completed")
|
|
147535
148148
|
});
|
|
@@ -147613,13 +148226,17 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
147613
148226
|
errorName: suspensionError.name,
|
|
147614
148227
|
errorMessage: suspensionError.message
|
|
147615
148228
|
});
|
|
148229
|
+
let failureKey;
|
|
148230
|
+
let dehydratedError;
|
|
147616
148231
|
try {
|
|
147617
148232
|
await awaitRunReady();
|
|
148233
|
+
failureKey = await encryptionKey.value;
|
|
148234
|
+
dehydratedError = await dehydrateRunError(suspensionError, runId, failureKey, globalThis, (workflowRun?.specVersion ?? 0) >= SPEC_VERSION_SUPPORTS_COMPRESSION2);
|
|
147618
148235
|
await createEvent({
|
|
147619
148236
|
eventType: "run_failed",
|
|
147620
148237
|
specVersion: SPEC_VERSION_CURRENT2,
|
|
147621
148238
|
eventData: {
|
|
147622
|
-
error:
|
|
148239
|
+
error: dehydratedError,
|
|
147623
148240
|
errorCode
|
|
147624
148241
|
}
|
|
147625
148242
|
}, { requestId });
|
|
@@ -147633,6 +148250,7 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
147633
148250
|
}
|
|
147634
148251
|
throw failErr;
|
|
147635
148252
|
}
|
|
148253
|
+
dispatchRunFailedHooks(runId, workflowName, dehydratedError, failureKey, errorCode);
|
|
147636
148254
|
span?.setAttributes({
|
|
147637
148255
|
...WorkflowRunStatus2("failed"),
|
|
147638
148256
|
...WorkflowErrorCode2(errorCode),
|
|
@@ -147652,7 +148270,8 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
147652
148270
|
// This suspension committed the event a hook's
|
|
147653
148271
|
// own awaiter is parked on; the continuation
|
|
147654
148272
|
// below drives the next iteration in-process.
|
|
147655
|
-
hookContinuation: suspensionResult.hasAwaitedHookCreation || suspensionResult.hasHookConflict
|
|
148273
|
+
hookContinuation: suspensionResult.hasAwaitedHookCreation || suspensionResult.hasHookConflict,
|
|
148274
|
+
invocationContinuation: activity !== void 0
|
|
147656
148275
|
}) : void 0;
|
|
147657
148276
|
if (retentionDecision?.retain === false) {
|
|
147658
148277
|
retainedSession = null;
|
|
@@ -147861,6 +148480,10 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
147861
148480
|
}
|
|
147862
148481
|
return await reinvoke(0);
|
|
147863
148482
|
}
|
|
148483
|
+
if (activity && Date.now() - invocationStartTime < noInlineReplayAfterMs && await activity.waitForActivity(invocationRevision)) {
|
|
148484
|
+
eventLog = nextEventLogLoad(eventLog);
|
|
148485
|
+
continue;
|
|
148486
|
+
}
|
|
147864
148487
|
return;
|
|
147865
148488
|
}
|
|
147866
148489
|
const openHookWaitState = openHookWait.value;
|
|
@@ -148185,13 +148808,17 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
148185
148808
|
if (types9.isNativeError(terminalError) && errorStack) {
|
|
148186
148809
|
terminalError.stack = errorStack;
|
|
148187
148810
|
}
|
|
148811
|
+
let failureKey;
|
|
148812
|
+
let dehydratedError;
|
|
148188
148813
|
try {
|
|
148189
148814
|
await awaitRunReady();
|
|
148815
|
+
failureKey = await encryptionKey.value;
|
|
148816
|
+
dehydratedError = await dehydrateRunError(terminalError, runId, failureKey, globalThis, (workflowRun?.specVersion ?? 0) >= SPEC_VERSION_SUPPORTS_COMPRESSION2);
|
|
148190
148817
|
await createEvent({
|
|
148191
148818
|
eventType: "run_failed",
|
|
148192
148819
|
specVersion: SPEC_VERSION_CURRENT2,
|
|
148193
148820
|
eventData: {
|
|
148194
|
-
error:
|
|
148821
|
+
error: dehydratedError,
|
|
148195
148822
|
errorCode
|
|
148196
148823
|
}
|
|
148197
148824
|
}, {
|
|
@@ -148218,6 +148845,7 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
148218
148845
|
}
|
|
148219
148846
|
throw failErr;
|
|
148220
148847
|
}
|
|
148848
|
+
dispatchRunFailedHooks(runId, workflowName, dehydratedError, failureKey, errorCode);
|
|
148221
148849
|
span?.setAttributes({
|
|
148222
148850
|
...WorkflowRunStatus2("failed"),
|
|
148223
148851
|
...WorkflowErrorCode2(errorCode),
|
|
@@ -148232,7 +148860,7 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
148232
148860
|
});
|
|
148233
148861
|
});
|
|
148234
148862
|
});
|
|
148235
|
-
}), "handler");
|
|
148863
|
+
})), "handler");
|
|
148236
148864
|
let cachedHandler;
|
|
148237
148865
|
let invocationCount = 0;
|
|
148238
148866
|
const entrypointCreatedAt = Date.now();
|
|
@@ -149119,11 +149747,11 @@ var Run = class _Run {
|
|
|
149119
149747
|
return this.getWritable();
|
|
149120
149748
|
}
|
|
149121
149749
|
};
|
|
149122
|
-
Run.prototype["wakeUp"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
149123
|
-
Run.prototype["cancel"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
149124
|
-
Run.prototype["getReadable"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
149125
|
-
Run.prototype["getWritable"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
149126
|
-
var __step_Run$exists = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
149750
|
+
Run.prototype["wakeUp"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.55//Run#wakeUp");
|
|
149751
|
+
Run.prototype["cancel"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.55//Run#cancel");
|
|
149752
|
+
Run.prototype["getReadable"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.55//Run#getReadable");
|
|
149753
|
+
Run.prototype["getWritable"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.55//Run#getWritable");
|
|
149754
|
+
var __step_Run$exists = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.55//Run#exists");
|
|
149127
149755
|
Object.defineProperty(Run.prototype, "exists", {
|
|
149128
149756
|
get() {
|
|
149129
149757
|
return __step_Run$exists.call(this);
|
|
@@ -149131,7 +149759,7 @@ Object.defineProperty(Run.prototype, "exists", {
|
|
|
149131
149759
|
configurable: true,
|
|
149132
149760
|
enumerable: false
|
|
149133
149761
|
});
|
|
149134
|
-
var __step_Run$status = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
149762
|
+
var __step_Run$status = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.55//Run#status");
|
|
149135
149763
|
Object.defineProperty(Run.prototype, "status", {
|
|
149136
149764
|
get() {
|
|
149137
149765
|
return __step_Run$status.call(this);
|
|
@@ -149139,7 +149767,7 @@ Object.defineProperty(Run.prototype, "status", {
|
|
|
149139
149767
|
configurable: true,
|
|
149140
149768
|
enumerable: false
|
|
149141
149769
|
});
|
|
149142
|
-
var __step_Run$returnValue = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
149770
|
+
var __step_Run$returnValue = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.55//Run#returnValue");
|
|
149143
149771
|
Object.defineProperty(Run.prototype, "returnValue", {
|
|
149144
149772
|
get() {
|
|
149145
149773
|
return __step_Run$returnValue.call(this);
|
|
@@ -149147,7 +149775,7 @@ Object.defineProperty(Run.prototype, "returnValue", {
|
|
|
149147
149775
|
configurable: true,
|
|
149148
149776
|
enumerable: false
|
|
149149
149777
|
});
|
|
149150
|
-
var __step_Run$workflowName = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
149778
|
+
var __step_Run$workflowName = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.55//Run#workflowName");
|
|
149151
149779
|
Object.defineProperty(Run.prototype, "workflowName", {
|
|
149152
149780
|
get() {
|
|
149153
149781
|
return __step_Run$workflowName.call(this);
|
|
@@ -149155,7 +149783,7 @@ Object.defineProperty(Run.prototype, "workflowName", {
|
|
|
149155
149783
|
configurable: true,
|
|
149156
149784
|
enumerable: false
|
|
149157
149785
|
});
|
|
149158
|
-
var __step_Run$createdAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
149786
|
+
var __step_Run$createdAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.55//Run#createdAt");
|
|
149159
149787
|
Object.defineProperty(Run.prototype, "createdAt", {
|
|
149160
149788
|
get() {
|
|
149161
149789
|
return __step_Run$createdAt.call(this);
|
|
@@ -149163,7 +149791,7 @@ Object.defineProperty(Run.prototype, "createdAt", {
|
|
|
149163
149791
|
configurable: true,
|
|
149164
149792
|
enumerable: false
|
|
149165
149793
|
});
|
|
149166
|
-
var __step_Run$startedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
149794
|
+
var __step_Run$startedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.55//Run#startedAt");
|
|
149167
149795
|
Object.defineProperty(Run.prototype, "startedAt", {
|
|
149168
149796
|
get() {
|
|
149169
149797
|
return __step_Run$startedAt.call(this);
|
|
@@ -149171,7 +149799,7 @@ Object.defineProperty(Run.prototype, "startedAt", {
|
|
|
149171
149799
|
configurable: true,
|
|
149172
149800
|
enumerable: false
|
|
149173
149801
|
});
|
|
149174
|
-
var __step_Run$completedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
149802
|
+
var __step_Run$completedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.55//Run#completedAt");
|
|
149175
149803
|
Object.defineProperty(Run.prototype, "completedAt", {
|
|
149176
149804
|
get() {
|
|
149177
149805
|
return __step_Run$completedAt.call(this);
|
|
@@ -149188,7 +149816,7 @@ Object.defineProperty(Run.prototype, "completedAt", {
|
|
|
149188
149816
|
enumerable: false,
|
|
149189
149817
|
configurable: false
|
|
149190
149818
|
});
|
|
149191
|
-
})(Run, "class//@workflow/core/runtime/run@5.0.0-beta.
|
|
149819
|
+
})(Run, "class//@workflow/core/runtime/run@5.0.0-beta.55//Run");
|
|
149192
149820
|
|
|
149193
149821
|
// ../core/dist/workflow/create-hook.js
|
|
149194
149822
|
aliasSerializationClass(RUN_CLASS_ID, Run);
|
|
@@ -156784,7 +157412,7 @@ globalThis.__private_workflows.set("workflow//./workflows/inline-execution//hook
|
|
|
156784
157412
|
var latestNoOpWarning = globalSingleton("@workflow/core//latestNoOpWarning", 1, () => ({
|
|
156785
157413
|
warned: false
|
|
156786
157414
|
}));
|
|
156787
|
-
var start = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/start@5.0.0-beta.
|
|
157415
|
+
var start = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/start@5.0.0-beta.55//start");
|
|
156788
157416
|
|
|
156789
157417
|
// workflows/lineage.ts
|
|
156790
157418
|
var noop = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//./workflows/lineage//noop");
|