@workflow/web 5.0.0-beta.55 → 5.0.0-beta.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/client/assets/{arrow-up-right-Cbiblmqd.js → arrow-up-right-XpJjI06G.js} +1 -1
- package/build/client/assets/{highlighted-body-B3W2YXNL-DwU_jOoN.js → highlighted-body-B3W2YXNL-DA3N01jE.js} +1 -1
- package/build/client/assets/{home-5LIuLkPD.js → home-CLktiGIz.js} +3 -3
- package/build/client/assets/{loader-circle-DUHA29mm.js → loader-circle-Cj8CH5bR.js} +1 -1
- package/build/client/assets/{manifest-4d592c52.js → manifest-3ffb4984.js} +1 -1
- package/build/client/assets/{mermaid-3ZIDBTTL-NvETcKWB.js → mermaid-3ZIDBTTL-DG0Grjgm.js} +103 -7
- package/build/client/assets/{root-DBWIyKUW.js → root-3gE7cfR2.js} +3 -3
- package/build/client/assets/{run-detail-CBJBkl4-.js → run-detail-gOfjBB1S.js} +10 -3
- package/build/client/assets/{workflow-graph-viewer-B-jkpIk_.js → workflow-graph-viewer-Cg3Lr_h8.js} +1 -1
- package/build/client/assets/{zstd-browser-decoder-D3uoHeUt.js → zstd-browser-decoder-CEJ92wdJ.js} +1 -1
- package/build/server/assets/{app-BXpsg52W.js → app-CLgyAdH3.js} +1023 -395
- package/build/server/assets/{highlighted-body-B3W2YXNL-gkJfOpdp.js → highlighted-body-B3W2YXNL-B8wbEqnx.js} +1 -1
- package/build/server/assets/{index-BkN7taof.js → index-CD3sqsfS.js} +1 -1
- package/build/server/assets/index-qorbufop.js +179 -0
- package/build/server/assets/{mermaid-3ZIDBTTL-CPNY3RZj.js → mermaid-3ZIDBTTL-CDOlxgin.js} +1 -1
- package/build/server/assets/{token-TJVjFtpm.js → token-BfBe4cAY.js} +1 -1
- package/build/server/assets/{token-util-BMcpB3Iq.js → token-util-CYhmjL6g.js} +1 -1
- package/build/server/assets/{websocket-server-CTiYInap.js → websocket-server-DB4GPS66.js} +1 -1
- package/build/server/assets/{wrapper-DG37QKjD.js → wrapper-CUYQE5_Q.js} +3 -3
- package/build/server/assets/{ws-transport-ClaOEQbG.js → ws-transport-xTHJJcp4.js} +2 -2
- package/build/server/assets/{zstd-browser-decoder-BgChmidM.js → zstd-browser-decoder-CIXVj9sh.js} +1 -1
- package/build/server/index.js +3 -3
- package/package.json +7 -7
- package/build/server/assets/index-CPJXhpRN.js +0 -176
|
@@ -47938,7 +47938,30 @@ const HookCreatedEventSchema = compile(BaseEventSchema.extend({
|
|
|
47938
47938
|
tokenRetentionUntil: date$2().optional(),
|
|
47939
47939
|
metadata: SerializedDataSchema.optional(),
|
|
47940
47940
|
isWebhook: boolean$2().optional(),
|
|
47941
|
-
isSystem: boolean$2().optional()
|
|
47941
|
+
isSystem: boolean$2().optional(),
|
|
47942
|
+
/**
|
|
47943
|
+
* `createHook({ experimental_force: true })`: when the token belongs to
|
|
47944
|
+
* another live run, the World takes it over — journaling
|
|
47945
|
+
* `hook_disposed{forceClaimedBy}` in that run's log and re-pointing the
|
|
47946
|
+
* token — instead of answering `hook_conflict`. Requires the
|
|
47947
|
+
* `hookForceClaim` capability.
|
|
47948
|
+
*/
|
|
47949
|
+
force: boolean$2().optional(),
|
|
47950
|
+
/**
|
|
47951
|
+
* World-written on a forced creation that did take a token over: the
|
|
47952
|
+
* run and hook it was taken from, plus what a queue message to that run
|
|
47953
|
+
* needs (`workflowName`, `deploymentId`, `runSpecVersion`). Absent when
|
|
47954
|
+
* the token was free. The wake-targeting fields are in the LOG, not only
|
|
47955
|
+
* on the hook entity, so a replay can republish the victim's wake from
|
|
47956
|
+
* the row alone; see `publishForceClaimVictimWake` in @workflow/core.
|
|
47957
|
+
*/
|
|
47958
|
+
forceClaimedFrom: object$1({
|
|
47959
|
+
runId: string$2(),
|
|
47960
|
+
hookId: string$2(),
|
|
47961
|
+
workflowName: string$2().optional(),
|
|
47962
|
+
deploymentId: string$2().optional(),
|
|
47963
|
+
runSpecVersion: number$3().optional()
|
|
47964
|
+
}).optional()
|
|
47942
47965
|
})
|
|
47943
47966
|
}));
|
|
47944
47967
|
const HookReceivedEventSchema = compile(BaseEventSchema.extend({
|
|
@@ -47953,7 +47976,14 @@ const HookDisposedEventSchema = compile(BaseEventSchema.extend({
|
|
|
47953
47976
|
eventType: literal("hook_disposed"),
|
|
47954
47977
|
correlationId: string$2(),
|
|
47955
47978
|
eventData: object$1({
|
|
47956
|
-
token: string$2().optional()
|
|
47979
|
+
token: string$2().optional(),
|
|
47980
|
+
/**
|
|
47981
|
+
* World-written: this disposal was not the run's own. Another run
|
|
47982
|
+
* took the hook's token with `experimental_force`, and this names
|
|
47983
|
+
* it. The hook consumer rejects the hook's awaiters with
|
|
47984
|
+
* `HookForceClaimedError` when it reads this row.
|
|
47985
|
+
*/
|
|
47986
|
+
forceClaimedBy: object$1({ runId: string$2(), hookId: string$2() }).optional()
|
|
47957
47987
|
}).optional()
|
|
47958
47988
|
}));
|
|
47959
47989
|
const HookConflictEventSchema = compile(BaseEventSchema.extend({
|
|
@@ -47963,7 +47993,18 @@ const HookConflictEventSchema = compile(BaseEventSchema.extend({
|
|
|
47963
47993
|
token: string$2(),
|
|
47964
47994
|
// TODO: Make this required once all persisted hook_conflict events and
|
|
47965
47995
|
// remote World implementations always include the active hook owner's run ID.
|
|
47966
|
-
conflictingRunId: string$2().optional()
|
|
47996
|
+
conflictingRunId: string$2().optional(),
|
|
47997
|
+
/**
|
|
47998
|
+
* Set when the creation asked for `force` and the World declined to take
|
|
47999
|
+
* the token over. `victim-spec-version`: the run holding the token was
|
|
48000
|
+
* started at a spec version below
|
|
48001
|
+
* `SPEC_VERSION_SUPPORTS_HOOK_FORCE_CLAIM`, so its runtime would not
|
|
48002
|
+
* understand the involuntary disposal — the forced hook gets the
|
|
48003
|
+
* ordinary `HookConflictError` it opted out of instead of stranding
|
|
48004
|
+
* that run. Absent on a conflict answered by a World that does not
|
|
48005
|
+
* implement forcing at all.
|
|
48006
|
+
*/
|
|
48007
|
+
forceRefusedReason: literal("victim-spec-version").optional()
|
|
47967
48008
|
})
|
|
47968
48009
|
}));
|
|
47969
48010
|
const NoopEventSchema = compile(BaseEventSchema.extend({
|
|
@@ -48808,6 +48849,13 @@ const HookResumeCapabilitiesSchema = compile(object$1({
|
|
|
48808
48849
|
// is engaged.
|
|
48809
48850
|
hookResumeDedupVersion: number$3()
|
|
48810
48851
|
}));
|
|
48852
|
+
const HookClaimedFromSchema = compile(object$1({
|
|
48853
|
+
runId: string$2(),
|
|
48854
|
+
hookId: string$2(),
|
|
48855
|
+
workflowName: string$2().optional(),
|
|
48856
|
+
deploymentId: string$2().optional(),
|
|
48857
|
+
runSpecVersion: number$3().optional()
|
|
48858
|
+
}));
|
|
48811
48859
|
const HookSchema = compile(object$1({
|
|
48812
48860
|
runId: string$2(),
|
|
48813
48861
|
hookId: string$2(),
|
|
@@ -48835,7 +48883,12 @@ const HookSchema = compile(object$1({
|
|
|
48835
48883
|
// `resumeHook()` gates its lazy path on this being present and
|
|
48836
48884
|
// current. Absent against an older/rolled-back server or when the kill switch
|
|
48837
48885
|
// is active.
|
|
48838
|
-
resumeCapabilities: HookResumeCapabilitiesSchema.optional()
|
|
48886
|
+
resumeCapabilities: HookResumeCapabilitiesSchema.optional(),
|
|
48887
|
+
// Set when this hook took its token from another run
|
|
48888
|
+
// (`experimental_force`). The wake-targeting fields are the victim run's,
|
|
48889
|
+
// so the claimer's runtime can publish the victim's wake without reading
|
|
48890
|
+
// a run it may not be able to reach; see `HookClaimedFromSchema`.
|
|
48891
|
+
claimedFrom: HookClaimedFromSchema.optional()
|
|
48839
48892
|
}));
|
|
48840
48893
|
const NODE_HTTP_ENV_VAR = "WORKFLOW_NODE_HTTP";
|
|
48841
48894
|
const NODE_HTTP_DEFAULT = false;
|
|
@@ -48898,6 +48951,9 @@ const PaginatedResponseSchema = (dataSchema) => compile(object$1({
|
|
|
48898
48951
|
hasMore: boolean$2(),
|
|
48899
48952
|
pageInfo: PageInfoSchema.optional()
|
|
48900
48953
|
}));
|
|
48954
|
+
function entityResolveData(resolveData) {
|
|
48955
|
+
return resolveData === "skip-step-inputs" ? "all" : resolveData;
|
|
48956
|
+
}
|
|
48901
48957
|
const StructuredErrorSchema = compile(object$1({
|
|
48902
48958
|
message: string$2(),
|
|
48903
48959
|
stack: string$2().optional(),
|
|
@@ -48943,17 +48999,18 @@ function eventIdToSlot(eventId) {
|
|
|
48943
48999
|
return Number.isSafeInteger(slot) && slot >= FIRST_EVENT_SLOT ? slot : null;
|
|
48944
49000
|
}
|
|
48945
49001
|
const SPEC_VERSION_LEGACY = 1;
|
|
49002
|
+
const SPEC_VERSION_SUPPORTS_EVENT_SOURCING = 2;
|
|
48946
49003
|
const SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT = 3;
|
|
48947
49004
|
const SPEC_VERSION_SUPPORTS_ATTRIBUTES = 4;
|
|
48948
49005
|
const SPEC_VERSION_SUPPORTS_COMPRESSION = 5;
|
|
48949
49006
|
const SPEC_VERSION_SUPPORTS_SLOT_IDENTITY = 6;
|
|
48950
|
-
const
|
|
48951
|
-
const SPEC_VERSION_CURRENT =
|
|
49007
|
+
const SPEC_VERSION_SUPPORTS_HOOK_FORCE_CLAIM = 8;
|
|
49008
|
+
const SPEC_VERSION_CURRENT = SPEC_VERSION_SUPPORTS_HOOK_FORCE_CLAIM;
|
|
48952
49009
|
const SEALED_LOG_ENV_VAR = "WORKFLOW_SEALED_LOG";
|
|
48953
49010
|
function mintedSpecVersion(env2 = process.env) {
|
|
48954
49011
|
return envFlag(SEALED_LOG_ENV_VAR, true, env2) ? SPEC_VERSION_CURRENT : SPEC_VERSION_SUPPORTS_SLOT_IDENTITY;
|
|
48955
49012
|
}
|
|
48956
|
-
const SPEC_VERSION_MAX_SUPPORTED =
|
|
49013
|
+
const SPEC_VERSION_MAX_SUPPORTED = SPEC_VERSION_SUPPORTS_HOOK_FORCE_CLAIM;
|
|
48957
49014
|
function isLegacySpecVersion(v2) {
|
|
48958
49015
|
return v2 === void 0 || v2 === null || v2 <= SPEC_VERSION_LEGACY;
|
|
48959
49016
|
}
|
|
@@ -53383,6 +53440,7 @@ const ERROR_SLUGS = {
|
|
|
53383
53440
|
WEBHOOK_INVALID_RESPOND_WITH_VALUE: "webhook-invalid-respond-with-value",
|
|
53384
53441
|
WEBHOOK_RESPONSE_NOT_SENT: "webhook-response-not-sent",
|
|
53385
53442
|
HOOK_CONFLICT: "hook-conflict",
|
|
53443
|
+
HOOK_FORCE_CLAIMED: "hook-force-claimed",
|
|
53386
53444
|
CORRUPTED_EVENT_LOG: "corrupted-event-log",
|
|
53387
53445
|
RUNTIME_DECRYPTION_FAILED: "runtime-decryption-failed"
|
|
53388
53446
|
};
|
|
@@ -53436,6 +53494,17 @@ class WorkflowRunFailedError extends WorkflowError {
|
|
|
53436
53494
|
super(`Workflow run "${runId}" failed: ${message2}`, {
|
|
53437
53495
|
cause: error2
|
|
53438
53496
|
});
|
|
53497
|
+
/**
|
|
53498
|
+
* `failed` is terminal, and a run's terminal state is immutable. This error
|
|
53499
|
+
* is only ever thrown after a *successful* read of such a run, so re-running
|
|
53500
|
+
* the read returns the same record and throws the same error. Marking it
|
|
53501
|
+
* non-retryable is what stops the step executor from spending a retry budget
|
|
53502
|
+
* on that when the read happens inside a step — a parent awaiting a child's
|
|
53503
|
+
* `returnValue` — and then replacing this error with its retry-exhaustion
|
|
53504
|
+
* wrapper. A read that *fails* throws something else and stays retryable.
|
|
53505
|
+
* See `FatalError.is()`.
|
|
53506
|
+
*/
|
|
53507
|
+
__publicField(this, "fatal", true);
|
|
53439
53508
|
__publicField(this, "runId");
|
|
53440
53509
|
/**
|
|
53441
53510
|
* The high-level error category (e.g. USER_ERROR, RUNTIME_ERROR) for the
|
|
@@ -53554,6 +53623,25 @@ class HookConflictError extends WorkflowError {
|
|
|
53554
53623
|
return isError(value) && value.name === "HookConflictError";
|
|
53555
53624
|
}
|
|
53556
53625
|
}
|
|
53626
|
+
class HookForceClaimedError extends WorkflowError {
|
|
53627
|
+
constructor(token, claimedByRunId, claimedByHookId) {
|
|
53628
|
+
super(`Hook token "${token}" was force-claimed by another workflow (run "${claimedByRunId}")`, { slug: ERROR_SLUGS.HOOK_FORCE_CLAIMED });
|
|
53629
|
+
__publicField(this, "token");
|
|
53630
|
+
/** The run that took the token. */
|
|
53631
|
+
__publicField(this, "claimedByRunId");
|
|
53632
|
+
/** The hook (in `claimedByRunId`) the token now belongs to. */
|
|
53633
|
+
__publicField(this, "claimedByHookId");
|
|
53634
|
+
this.name = "HookForceClaimedError";
|
|
53635
|
+
this.token = token;
|
|
53636
|
+
this.claimedByRunId = claimedByRunId;
|
|
53637
|
+
if (claimedByHookId !== void 0) {
|
|
53638
|
+
this.claimedByHookId = claimedByHookId;
|
|
53639
|
+
}
|
|
53640
|
+
}
|
|
53641
|
+
static is(value) {
|
|
53642
|
+
return isError(value) && value.name === "HookForceClaimedError";
|
|
53643
|
+
}
|
|
53644
|
+
}
|
|
53557
53645
|
class HookNotFoundError extends WorkflowError {
|
|
53558
53646
|
constructor(token) {
|
|
53559
53647
|
super("Hook not found", {});
|
|
@@ -53652,6 +53740,8 @@ class PreconditionFailedError extends WorkflowWorldError {
|
|
|
53652
53740
|
class WorkflowRunCancelledError extends WorkflowError {
|
|
53653
53741
|
constructor(runId) {
|
|
53654
53742
|
super(`Workflow run "${runId}" cancelled`, {});
|
|
53743
|
+
/** Terminal and immutable, for the same reason as {@link WorkflowRunFailedError.fatal}. */
|
|
53744
|
+
__publicField(this, "fatal", true);
|
|
53655
53745
|
__publicField(this, "runId");
|
|
53656
53746
|
this.name = "WorkflowRunCancelledError";
|
|
53657
53747
|
this.runId = runId;
|
|
@@ -53709,6 +53799,7 @@ const VERCEL_403_ERROR_MESSAGE = "Your current vercel account does not have acce
|
|
|
53709
53799
|
const FATAL_ERROR_KEY = Symbol.for("@workflow/errors//FatalError");
|
|
53710
53800
|
const RETRYABLE_ERROR_KEY = Symbol.for("@workflow/errors//RetryableError");
|
|
53711
53801
|
const HOOK_CONFLICT_ERROR_KEY = Symbol.for("@workflow/errors//HookConflictError");
|
|
53802
|
+
const HOOK_FORCE_CLAIMED_ERROR_KEY = Symbol.for("@workflow/errors//HookForceClaimedError");
|
|
53712
53803
|
const RUNTIME_DECRYPTION_ERROR_KEY = Symbol.for("@workflow/errors//RuntimeDecryptionError");
|
|
53713
53804
|
const STREAM_ERROR_KEY = Symbol.for("@workflow/errors//StreamError");
|
|
53714
53805
|
if (typeof globalThis !== "undefined") {
|
|
@@ -53736,6 +53827,14 @@ if (typeof globalThis !== "undefined") {
|
|
|
53736
53827
|
configurable: false
|
|
53737
53828
|
});
|
|
53738
53829
|
}
|
|
53830
|
+
if (!Object.hasOwn(globalThis, HOOK_FORCE_CLAIMED_ERROR_KEY)) {
|
|
53831
|
+
Object.defineProperty(globalThis, HOOK_FORCE_CLAIMED_ERROR_KEY, {
|
|
53832
|
+
value: HookForceClaimedError,
|
|
53833
|
+
writable: false,
|
|
53834
|
+
enumerable: false,
|
|
53835
|
+
configurable: false
|
|
53836
|
+
});
|
|
53837
|
+
}
|
|
53739
53838
|
if (!Object.hasOwn(globalThis, RUNTIME_DECRYPTION_ERROR_KEY)) {
|
|
53740
53839
|
Object.defineProperty(globalThis, RUNTIME_DECRYPTION_ERROR_KEY, {
|
|
53741
53840
|
value: RuntimeDecryptionError,
|
|
@@ -54753,6 +54852,7 @@ function getWebRevivers() {
|
|
|
54753
54852
|
// `packages/core/src/serialization/reducers/common.ts`) emits a tagged
|
|
54754
54853
|
// entry for each built-in Error subclass plus the workflow-specific
|
|
54755
54854
|
// `FatalError` / `RetryableError` / `HookConflictError` /
|
|
54855
|
+
// `HookForceClaimedError` /
|
|
54756
54856
|
// `RuntimeDecryptionError` and `AggregateError`. Without
|
|
54757
54857
|
// matching revivers here, `devalue.unflatten` throws "Unknown type X",
|
|
54758
54858
|
// which surfaces in the web o11y UI as "Failed to load resource
|
|
@@ -54811,6 +54911,19 @@ function getWebRevivers() {
|
|
|
54811
54911
|
error2.stack = value.stack;
|
|
54812
54912
|
return error2;
|
|
54813
54913
|
},
|
|
54914
|
+
HookForceClaimedError: (value) => {
|
|
54915
|
+
const opts = "cause" in value ? { cause: value.cause } : void 0;
|
|
54916
|
+
const error2 = new Error(value.message, opts);
|
|
54917
|
+
error2.name = "HookForceClaimedError";
|
|
54918
|
+
error2.token = value.token;
|
|
54919
|
+
error2.claimedByRunId = value.claimedByRunId;
|
|
54920
|
+
if (value.claimedByHookId !== void 0) {
|
|
54921
|
+
error2.claimedByHookId = value.claimedByHookId;
|
|
54922
|
+
}
|
|
54923
|
+
if (value.stack !== void 0)
|
|
54924
|
+
error2.stack = value.stack;
|
|
54925
|
+
return error2;
|
|
54926
|
+
},
|
|
54814
54927
|
RetryableError: (value) => {
|
|
54815
54928
|
const opts = "cause" in value ? { cause: value.cause } : void 0;
|
|
54816
54929
|
const error2 = new Error(value.message, opts);
|
|
@@ -54995,7 +55108,7 @@ function replaceEncryptedAndExpiredWithMarkers(resource) {
|
|
|
54995
55108
|
}
|
|
54996
55109
|
async function hydrateResourceIOAsync(resource, key) {
|
|
54997
55110
|
const { hydrateDataWithKey: hydrateDataWithKey2, deriveRunPayloadKeys: deriveRunPayloadKeys2 } = await Promise.resolve().then(() => serializationFormat);
|
|
54998
|
-
const { ensureZstdDecoderRegistered } = await import("./zstd-browser-decoder-
|
|
55111
|
+
const { ensureZstdDecoderRegistered } = await import("./zstd-browser-decoder-CIXVj9sh.js");
|
|
54999
55112
|
ensureZstdDecoderRegistered();
|
|
55000
55113
|
const cryptoKey = key ? await deriveRunPayloadKeys2(key) : void 0;
|
|
55001
55114
|
const revivers = getRevivers();
|
|
@@ -85939,7 +86052,7 @@ var tn = f("block", "before:content-[counter(line)]", "before:inline-block", "be
|
|
|
85939
86052
|
var et = ({ className: e, language: t, style: o, isIncomplete: n, ...s2 }) => jsxRuntimeExports.jsx("div", { className: f("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2", e), "data-incomplete": n || void 0, "data-language": t, "data-streamdown": "code-block", style: { contentVisibility: "auto", containIntrinsicSize: "auto 200px", ...o }, ...s2 });
|
|
85940
86053
|
var Se = reactExports.createContext({ code: "" }), de = () => reactExports.useContext(Se);
|
|
85941
86054
|
var ot = ({ language: e }) => jsxRuntimeExports.jsx("div", { className: "flex h-8 items-center text-muted-foreground text-xs", "data-language": e, "data-streamdown": "code-block-header", children: jsxRuntimeExports.jsx("span", { className: "ml-1 font-mono lowercase", children: e }) });
|
|
85942
|
-
var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-
|
|
86055
|
+
var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-B8wbEqnx.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
|
|
85943
86056
|
let i = reactExports.useMemo(() => e.replace(cn$1, ""), [e]), c = reactExports.useMemo(() => ({ bg: "transparent", fg: "inherit", tokens: i.split(`
|
|
85944
86057
|
`).map((a2) => [{ content: a2, color: "inherit", bgColor: "transparent", htmlStyle: {}, offset: 0 }]) }), [i]);
|
|
85945
86058
|
return jsxRuntimeExports.jsx(Se.Provider, { value: { code: e }, children: jsxRuntimeExports.jsxs(et, { isIncomplete: s2, language: t, children: [jsxRuntimeExports.jsx(ot, { language: t }), n ? jsxRuntimeExports.jsx("div", { className: "pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end", children: jsxRuntimeExports.jsx("div", { className: "pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur", "data-streamdown": "code-block-actions", children: n }) }) : null, jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: jsxRuntimeExports.jsx(Qe, { className: o, language: t, result: c, ...r2 }), children: jsxRuntimeExports.jsx(dn, { className: o, code: i, language: t, raw: c, ...r2 }) })] }) });
|
|
@@ -86261,7 +86374,7 @@ var Dt = ({ children: e, className: t, onDownload: o, onError: n }) => {
|
|
|
86261
86374
|
}, []), jsxRuntimeExports.jsxs("div", { className: "relative", ref: i, children: [jsxRuntimeExports.jsx("button", { className: f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50", t), disabled: c, onClick: () => r2(!s2), title: "Download table", type: "button", children: e != null ? e : jsxRuntimeExports.jsx(Z, { size: 14 }) }), s2 ? jsxRuntimeExports.jsxs("div", { className: "absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg", children: [jsxRuntimeExports.jsx("button", { className: "w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40", onClick: () => a2("csv"), title: "Download table as CSV", type: "button", children: "CSV" }), jsxRuntimeExports.jsx("button", { className: "w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40", onClick: () => a2("markdown"), title: "Download table as Markdown", type: "button", children: "Markdown" })] }) : null] });
|
|
86262
86375
|
};
|
|
86263
86376
|
var Vt = ({ children: e, className: t, showControls: o, ...n }) => jsxRuntimeExports.jsxs("div", { className: "my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2", "data-streamdown": "table-wrapper", children: [o ? jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-end gap-1", children: [jsxRuntimeExports.jsx(Ht, {}), jsxRuntimeExports.jsx(Dt, {})] }) : null, jsxRuntimeExports.jsx("div", { className: "border-collapse overflow-x-auto overscroll-y-auto rounded-md border border-border bg-background", children: jsxRuntimeExports.jsx("table", { className: f("w-full divide-y divide-border", t), "data-streamdown": "table", ...n, children: e }) })] });
|
|
86264
|
-
var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-
|
|
86377
|
+
var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-CDOlxgin.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
|
|
86265
86378
|
function ke(e, t) {
|
|
86266
86379
|
if (!(e != null && e.position || t != null && t.position)) return true;
|
|
86267
86380
|
if (!(e != null && e.position && (t != null && t.position))) return false;
|
|
@@ -89084,6 +89197,7 @@ const attributeOrder = [
|
|
|
89084
89197
|
"attempt",
|
|
89085
89198
|
"token",
|
|
89086
89199
|
"tokenRetentionUntil",
|
|
89200
|
+
"claimedFrom",
|
|
89087
89201
|
"isWebhook",
|
|
89088
89202
|
"isSystem",
|
|
89089
89203
|
"receivedCount",
|
|
@@ -89132,6 +89246,7 @@ const attributeDisplayNames = {
|
|
|
89132
89246
|
runId: "Run ID",
|
|
89133
89247
|
token: "Token",
|
|
89134
89248
|
tokenRetentionUntil: "Minimum Retention Until",
|
|
89249
|
+
claimedFrom: "Token Taken From Run",
|
|
89135
89250
|
eventType: "Event Type",
|
|
89136
89251
|
errorCode: "Error Code",
|
|
89137
89252
|
correlationId: "Correlation ID",
|
|
@@ -89211,6 +89326,11 @@ const attributeToDisplayFn = {
|
|
|
89211
89326
|
// Hook details
|
|
89212
89327
|
token: (value) => String(value),
|
|
89213
89328
|
tokenRetentionUntil: timestampWithTooltipOrNull,
|
|
89329
|
+
// A force-claimed hook (`experimental_force`): the run whose token it took.
|
|
89330
|
+
claimedFrom: (value) => {
|
|
89331
|
+
const from = value;
|
|
89332
|
+
return typeof (from == null ? void 0 : from.runId) === "string" ? from.runId : null;
|
|
89333
|
+
},
|
|
89214
89334
|
isWebhook: (value) => String(value),
|
|
89215
89335
|
isSystem: (value) => String(value),
|
|
89216
89336
|
receivedCount: (value) => String(value),
|
|
@@ -95000,6 +95120,11 @@ const WorkflowRunId$2 = SemanticConvention$2("workflow.run.id");
|
|
|
95000
95120
|
const WorkflowRunStatus = SemanticConvention$2("workflow.run.status");
|
|
95001
95121
|
const WorkflowArgumentsCount = SemanticConvention$2("workflow.arguments.count");
|
|
95002
95122
|
const DeploymentId = SemanticConvention$2("deployment.id");
|
|
95123
|
+
const WorkflowRunSpecVersion = SemanticConvention$2("workflow.run.spec_version");
|
|
95124
|
+
const WorkflowRunSpecVersionSource = SemanticConvention$2("workflow.run.spec_version_source");
|
|
95125
|
+
const WorkflowCapabilityProbeLatencyMs = SemanticConvention$2("workflow.capability_probe.latency_ms");
|
|
95126
|
+
const WorkflowCapabilityProbeCached = SemanticConvention$2("workflow.capability_probe.cached");
|
|
95127
|
+
const WorkflowCapabilityProbeError = SemanticConvention$2("workflow.capability_probe.error");
|
|
95003
95128
|
const HookToken = SemanticConvention$2("workflow.hook.token");
|
|
95004
95129
|
const HookId = SemanticConvention$2("workflow.hook.id");
|
|
95005
95130
|
const HookFound = SemanticConvention$2("workflow.hook.found");
|
|
@@ -96166,6 +96291,21 @@ function getCommonReducers(_global = globalThis) {
|
|
|
96166
96291
|
}
|
|
96167
96292
|
return reduced;
|
|
96168
96293
|
},
|
|
96294
|
+
HookForceClaimedError: (value) => {
|
|
96295
|
+
const base = reduceNamedErrorSubclassBase("HookForceClaimedError", value);
|
|
96296
|
+
if (!base)
|
|
96297
|
+
return false;
|
|
96298
|
+
const reduced = {
|
|
96299
|
+
...base,
|
|
96300
|
+
token: readProperty(value, "token"),
|
|
96301
|
+
claimedByRunId: readProperty(value, "claimedByRunId")
|
|
96302
|
+
};
|
|
96303
|
+
const claimedByHookId = readProperty(value, "claimedByHookId");
|
|
96304
|
+
if (claimedByHookId !== void 0) {
|
|
96305
|
+
reduced.claimedByHookId = claimedByHookId;
|
|
96306
|
+
}
|
|
96307
|
+
return reduced;
|
|
96308
|
+
},
|
|
96169
96309
|
RangeError: makeErrorSubclassReducer("RangeError"),
|
|
96170
96310
|
ReferenceError: makeErrorSubclassReducer("ReferenceError"),
|
|
96171
96311
|
// RetryableError carries an extra `retryAfter` Date that we serialize as
|
|
@@ -96350,6 +96490,16 @@ function getCommonRevivers$1(global2 = globalThis) {
|
|
|
96350
96490
|
}
|
|
96351
96491
|
return error2;
|
|
96352
96492
|
},
|
|
96493
|
+
HookForceClaimedError: (value) => {
|
|
96494
|
+
const Ctor = global2[Symbol.for("@workflow/errors//HookForceClaimedError")] ?? HookForceClaimedError;
|
|
96495
|
+
const error2 = new Ctor(value.token, value.claimedByRunId, value.claimedByHookId);
|
|
96496
|
+
if (value.stack !== void 0)
|
|
96497
|
+
error2.stack = value.stack;
|
|
96498
|
+
if ("cause" in value) {
|
|
96499
|
+
error2.cause = value.cause;
|
|
96500
|
+
}
|
|
96501
|
+
return error2;
|
|
96502
|
+
},
|
|
96353
96503
|
RangeError: makeErrorSubclassReviver(global2, "RangeError"),
|
|
96354
96504
|
ReferenceError: makeErrorSubclassReviver(global2, "ReferenceError"),
|
|
96355
96505
|
RetryableError: (value) => {
|
|
@@ -98741,13 +98891,13 @@ async function dehydrateStepReturnValue(value, runId, key, ops = [], global2 = g
|
|
|
98741
98891
|
throw new SerializationError(message2, { hint: hint2, cause });
|
|
98742
98892
|
}
|
|
98743
98893
|
}
|
|
98744
|
-
async function hydrateRunError(value, runId, key, ops = [], global2 = globalThis, extraRevivers = {}) {
|
|
98894
|
+
async function hydrateRunError(value, runId, key, ops = [], global2 = globalThis, extraRevivers = {}, options) {
|
|
98745
98895
|
const compressionStats = {};
|
|
98746
98896
|
const decrypted = await decompress$2(await decrypt(value, key), compressionStats);
|
|
98747
98897
|
await recordCompression(compressionStats, "deserialize");
|
|
98748
98898
|
if (!(decrypted instanceof Uint8Array)) {
|
|
98749
98899
|
return unflatten(decrypted, {
|
|
98750
|
-
...getExternalRevivers(global2, ops, runId, key),
|
|
98900
|
+
...getExternalRevivers(global2, ops, runId, key, options),
|
|
98751
98901
|
...extraRevivers
|
|
98752
98902
|
});
|
|
98753
98903
|
}
|
|
@@ -98755,7 +98905,7 @@ async function hydrateRunError(value, runId, key, ops = [], global2 = globalThis
|
|
|
98755
98905
|
if (format2 === SerializationFormat$1.DEVALUE_V1) {
|
|
98756
98906
|
const str = new TextDecoder().decode(payload);
|
|
98757
98907
|
return parse$5(str, {
|
|
98758
|
-
...getExternalRevivers(global2, ops, runId, key),
|
|
98908
|
+
...getExternalRevivers(global2, ops, runId, key, options),
|
|
98759
98909
|
...extraRevivers
|
|
98760
98910
|
});
|
|
98761
98911
|
}
|
|
@@ -98798,7 +98948,10 @@ globalSingleton("@workflow/core//envWarnings", 1, () => ({
|
|
|
98798
98948
|
maxInlineStepsValues: /* @__PURE__ */ new Set(),
|
|
98799
98949
|
maxEventsValues: /* @__PURE__ */ new Set()
|
|
98800
98950
|
}));
|
|
98801
|
-
|
|
98951
|
+
function specVersionForRunWrite(runSpecVersion, whenUnknown = SPEC_VERSION_CURRENT) {
|
|
98952
|
+
return Math.min(SPEC_VERSION_CURRENT, runSpecVersion ?? whenUnknown);
|
|
98953
|
+
}
|
|
98954
|
+
const version$1 = "5.0.0-beta.57";
|
|
98802
98955
|
const DEFAULT_HEALTH_CHECK_TIMEOUT = 3e4;
|
|
98803
98956
|
const SAFE_WORKFLOW_NAME_PATTERN = /^[a-zA-Z0-9_\-./@()[\]]+$/;
|
|
98804
98957
|
function getWorkflowQueueName(workflowName, namespace2) {
|
|
@@ -98859,7 +99012,7 @@ function parseHealthCheckResponse(chunks) {
|
|
|
98859
99012
|
response2 = JSON.parse(responseText);
|
|
98860
99013
|
} catch {
|
|
98861
99014
|
if (responseText.length > 0) {
|
|
98862
|
-
return { healthy: true };
|
|
99015
|
+
return { healthy: true, format: "text" };
|
|
98863
99016
|
}
|
|
98864
99017
|
return null;
|
|
98865
99018
|
}
|
|
@@ -98868,7 +99021,8 @@ function parseHealthCheckResponse(chunks) {
|
|
|
98868
99021
|
}
|
|
98869
99022
|
const r2 = response2;
|
|
98870
99023
|
const parsed = {
|
|
98871
|
-
healthy: r2.healthy
|
|
99024
|
+
healthy: r2.healthy,
|
|
99025
|
+
format: "json"
|
|
98872
99026
|
};
|
|
98873
99027
|
if (typeof r2.specVersion === "number") {
|
|
98874
99028
|
parsed.specVersion = r2.specVersion;
|
|
@@ -100968,7 +101122,7 @@ function getWorkflowVmFromEnv(env2 = process.env) {
|
|
|
100968
101122
|
throw new WorkflowRuntimeError(`Invalid WORKFLOW_VM value: "${raw2}". Expected one of: ${WORKFLOW_VMS.join(", ")}.`);
|
|
100969
101123
|
}
|
|
100970
101124
|
function waitUntil(promise2) {
|
|
100971
|
-
void import("./index-
|
|
101125
|
+
void import("./index-CD3sqsfS.js").then((n) => n.i).then(({ waitUntil: waitUntil2 }) => {
|
|
100972
101126
|
waitUntil2(promise2);
|
|
100973
101127
|
});
|
|
100974
101128
|
}
|
|
@@ -100989,8 +101143,30 @@ async function waitedUntil(fn2) {
|
|
|
100989
101143
|
}));
|
|
100990
101144
|
return result;
|
|
100991
101145
|
}
|
|
100992
|
-
const CROSS_DEPLOYMENT_CAPABILITY_PROBE_TIMEOUT_MS =
|
|
101146
|
+
const CROSS_DEPLOYMENT_CAPABILITY_PROBE_TIMEOUT_MS = 1e4;
|
|
101147
|
+
const CROSS_DEPLOYMENT_PROBE_RETRY_TIMEOUT_MS = 2e3;
|
|
101148
|
+
const CROSS_DEPLOYMENT_PROBE_CACHE_TTL_MS = 10 * 6e4;
|
|
101149
|
+
const CROSS_DEPLOYMENT_PROBE_MISS_TTL_MS = 6e4;
|
|
101150
|
+
const CROSS_DEPLOYMENT_PROBE_CACHE_MAX_ENTRIES = 256;
|
|
100993
101151
|
const RETENTION_ZERO_ATTRIBUTE_VALUE = "0";
|
|
101152
|
+
function resolveCrossDeploymentSpecVersion(probe, callerSpecVersion) {
|
|
101153
|
+
let target2;
|
|
101154
|
+
let source;
|
|
101155
|
+
if (typeof (probe == null ? void 0 : probe.specVersion) === "number" && Number.isInteger(probe.specVersion) && probe.specVersion >= 1) {
|
|
101156
|
+
target2 = probe.specVersion;
|
|
101157
|
+
source = "probe";
|
|
101158
|
+
} else if ((probe == null ? void 0 : probe.format) === "json") {
|
|
101159
|
+
target2 = SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT;
|
|
101160
|
+
source = "probe-malformed";
|
|
101161
|
+
} else if (probe == null ? void 0 : probe.healthy) {
|
|
101162
|
+
target2 = SPEC_VERSION_SUPPORTS_EVENT_SOURCING;
|
|
101163
|
+
source = "probe-unversioned";
|
|
101164
|
+
} else {
|
|
101165
|
+
target2 = SPEC_VERSION_SUPPORTS_SLOT_IDENTITY;
|
|
101166
|
+
source = probe ? "probe-miss" : "no-probe-channel";
|
|
101167
|
+
}
|
|
101168
|
+
return { specVersion: Math.min(target2, callerSpecVersion), source };
|
|
101169
|
+
}
|
|
100994
101170
|
const ulid = monotonicFactory();
|
|
100995
101171
|
function resolveLineageAttributes() {
|
|
100996
101172
|
var _a3;
|
|
@@ -101004,6 +101180,43 @@ function resolveLineageAttributes() {
|
|
|
101004
101180
|
};
|
|
101005
101181
|
}
|
|
101006
101182
|
const latestNoOpWarning = globalSingleton("@workflow/core//latestNoOpWarning", 1, () => ({ warned: false }));
|
|
101183
|
+
const probeMissWarning = globalSingleton("@workflow/core//crossDeploymentProbeMissWarning", 1, () => ({ warned: false }));
|
|
101184
|
+
const crossDeploymentProbeCache = globalSingleton("@workflow/core//crossDeploymentProbeCache", 1, () => /* @__PURE__ */ new WeakMap());
|
|
101185
|
+
async function probeCrossDeployment(world, options) {
|
|
101186
|
+
let byDeployment = crossDeploymentProbeCache.get(world);
|
|
101187
|
+
if (!byDeployment) {
|
|
101188
|
+
byDeployment = /* @__PURE__ */ new Map();
|
|
101189
|
+
crossDeploymentProbeCache.set(world, byDeployment);
|
|
101190
|
+
}
|
|
101191
|
+
const key = `${options.namespace ?? ""}\0${options.deploymentId}`;
|
|
101192
|
+
const now2 = Date.now();
|
|
101193
|
+
const entry2 = byDeployment.get(key);
|
|
101194
|
+
if ((entry2 == null ? void 0 : entry2.probe) !== void 0 && now2 - entry2.at < CROSS_DEPLOYMENT_PROBE_CACHE_TTL_MS) {
|
|
101195
|
+
return { probe: entry2.probe, cached: true };
|
|
101196
|
+
}
|
|
101197
|
+
const recentMiss = entry2 !== void 0 && entry2.probe === void 0 && now2 - entry2.at < CROSS_DEPLOYMENT_PROBE_MISS_TTL_MS;
|
|
101198
|
+
const probe = await healthCheck(world, {
|
|
101199
|
+
deploymentId: options.deploymentId,
|
|
101200
|
+
runId: options.runId,
|
|
101201
|
+
timeout: recentMiss ? CROSS_DEPLOYMENT_PROBE_RETRY_TIMEOUT_MS : CROSS_DEPLOYMENT_CAPABILITY_PROBE_TIMEOUT_MS,
|
|
101202
|
+
namespace: options.namespace
|
|
101203
|
+
}).catch(() => void 0);
|
|
101204
|
+
const answered = (probe == null ? void 0 : probe.format) !== void 0;
|
|
101205
|
+
byDeployment.delete(key);
|
|
101206
|
+
byDeployment.set(key, {
|
|
101207
|
+
// A repeated miss keeps the first miss's time, so the short budget ends
|
|
101208
|
+
// `CROSS_DEPLOYMENT_PROBE_MISS_TTL_MS` after it.
|
|
101209
|
+
at: !answered && recentMiss ? entry2.at : Date.now(),
|
|
101210
|
+
// The run public key is per run, so it is never reused.
|
|
101211
|
+
probe: answered ? { ...probe, encryptionPublicKey: void 0 } : void 0
|
|
101212
|
+
});
|
|
101213
|
+
if (byDeployment.size > CROSS_DEPLOYMENT_PROBE_CACHE_MAX_ENTRIES) {
|
|
101214
|
+
const oldest = byDeployment.keys().next().value;
|
|
101215
|
+
if (oldest !== void 0)
|
|
101216
|
+
byDeployment.delete(oldest);
|
|
101217
|
+
}
|
|
101218
|
+
return { probe, cached: false };
|
|
101219
|
+
}
|
|
101007
101220
|
async function start$1(workflow, argsOrOptions, options) {
|
|
101008
101221
|
"use step";
|
|
101009
101222
|
return await waitedUntil(() => {
|
|
@@ -101030,17 +101243,29 @@ async function start$1(workflow, argsOrOptions, options) {
|
|
|
101030
101243
|
});
|
|
101031
101244
|
const world = opts.world ?? await getWorldLazy();
|
|
101032
101245
|
assertWorldSupportsRuntimeProtocol(world);
|
|
101033
|
-
|
|
101034
|
-
let deploymentId
|
|
101035
|
-
if (deploymentId === "latest") {
|
|
101036
|
-
|
|
101037
|
-
|
|
101038
|
-
|
|
101039
|
-
|
|
101040
|
-
|
|
101041
|
-
|
|
101246
|
+
let currentDeploymentId;
|
|
101247
|
+
let deploymentId;
|
|
101248
|
+
if (opts.deploymentId === void 0 || opts.deploymentId === "latest") {
|
|
101249
|
+
const current = await world.getDeploymentId();
|
|
101250
|
+
currentDeploymentId = current;
|
|
101251
|
+
deploymentId = opts.deploymentId ?? current;
|
|
101252
|
+
if (deploymentId === "latest") {
|
|
101253
|
+
if (world.resolveLatestDeploymentId) {
|
|
101254
|
+
deploymentId = await world.resolveLatestDeploymentId();
|
|
101255
|
+
} else {
|
|
101256
|
+
if (!latestNoOpWarning.warned) {
|
|
101257
|
+
latestNoOpWarning.warned = true;
|
|
101258
|
+
runtimeLogger.warn("deploymentId: 'latest' has no effect in this world and was ignored. It is only supported by worlds with atomic deployments, such as Vercel. The run will target the current deployment.", { currentDeploymentId });
|
|
101259
|
+
}
|
|
101260
|
+
deploymentId = current;
|
|
101042
101261
|
}
|
|
101043
|
-
|
|
101262
|
+
}
|
|
101263
|
+
} else {
|
|
101264
|
+
deploymentId = opts.deploymentId;
|
|
101265
|
+
try {
|
|
101266
|
+
currentDeploymentId = await world.getDeploymentId();
|
|
101267
|
+
} catch (err) {
|
|
101268
|
+
runtimeLogger.debug("Current deployment is unavailable; starting as a cross-deployment run", { deploymentId, error: String(err) });
|
|
101044
101269
|
}
|
|
101045
101270
|
}
|
|
101046
101271
|
const runId = `wrun_${world.createRunId ? world.createRunId(opts) : ulid()}`;
|
|
@@ -101048,36 +101273,62 @@ async function start$1(workflow, argsOrOptions, options) {
|
|
|
101048
101273
|
let targetSupportsCompression;
|
|
101049
101274
|
let targetHookResumeInputVersion;
|
|
101050
101275
|
let probedRunPublicKey;
|
|
101051
|
-
|
|
101276
|
+
let targetSpecVersion;
|
|
101277
|
+
let specVersionSource;
|
|
101278
|
+
const crossDeployment = deploymentId !== currentDeploymentId;
|
|
101279
|
+
if (!crossDeployment) {
|
|
101052
101280
|
framedByteStreams = true;
|
|
101053
101281
|
targetSupportsCompression = true;
|
|
101054
101282
|
targetHookResumeInputVersion = HOOK_RESUME_INPUT_VERSION;
|
|
101283
|
+
targetSpecVersion = world.specVersion;
|
|
101284
|
+
specVersionSource = "same-deployment";
|
|
101055
101285
|
} else if (typeof ((_a3 = world.streams) == null ? void 0 : _a3.get) !== "function") {
|
|
101056
101286
|
framedByteStreams = false;
|
|
101057
101287
|
targetSupportsCompression = false;
|
|
101058
101288
|
targetHookResumeInputVersion = void 0;
|
|
101289
|
+
({ specVersion: targetSpecVersion, source: specVersionSource } = resolveCrossDeploymentSpecVersion(void 0, world.specVersion));
|
|
101059
101290
|
} else {
|
|
101060
|
-
const probe = await
|
|
101291
|
+
const { probe, cached: cached2 } = await probeCrossDeployment(world, {
|
|
101061
101292
|
deploymentId,
|
|
101062
101293
|
runId,
|
|
101063
|
-
timeout: CROSS_DEPLOYMENT_CAPABILITY_PROBE_TIMEOUT_MS,
|
|
101064
101294
|
namespace: opts.namespace
|
|
101065
|
-
})
|
|
101295
|
+
});
|
|
101066
101296
|
probedRunPublicKey = probe == null ? void 0 : probe.encryptionPublicKey;
|
|
101067
101297
|
const capabilities = getRunCapabilities(probe == null ? void 0 : probe.workflowCoreVersion);
|
|
101068
101298
|
framedByteStreams = capabilities.framedByteStreams;
|
|
101069
101299
|
targetSupportsCompression = capabilities.supportedFormats.has(SerializationFormat$1.GZIP);
|
|
101070
101300
|
targetHookResumeInputVersion = probe == null ? void 0 : probe.hookResumeInputVersion;
|
|
101301
|
+
({ specVersion: targetSpecVersion, source: specVersionSource } = resolveCrossDeploymentSpecVersion(probe, world.specVersion));
|
|
101302
|
+
span == null ? void 0 : span.setAttributes({
|
|
101303
|
+
...WorkflowCapabilityProbeCached(cached2),
|
|
101304
|
+
...!cached2 && (probe == null ? void 0 : probe.latencyMs) !== void 0 ? WorkflowCapabilityProbeLatencyMs(probe.latencyMs) : {},
|
|
101305
|
+
...!cached2 && (probe == null ? void 0 : probe.error) ? WorkflowCapabilityProbeError(probe.error) : {}
|
|
101306
|
+
});
|
|
101307
|
+
if (specVersionSource === "probe-miss" && opts.specVersion === void 0 && !probeMissWarning.warned) {
|
|
101308
|
+
probeMissWarning.warned = true;
|
|
101309
|
+
runtimeLogger.warn("The target deployment did not answer the capability probe, so the run was stamped with a fallback spec version instead of the target's own. A target on an older major version may not be able to execute it.", {
|
|
101310
|
+
deploymentId,
|
|
101311
|
+
specVersion: targetSpecVersion,
|
|
101312
|
+
error: probe == null ? void 0 : probe.error
|
|
101313
|
+
});
|
|
101314
|
+
}
|
|
101071
101315
|
}
|
|
101072
101316
|
const ops = [];
|
|
101073
101317
|
const traceCarrier = await serializeTraceCarrier();
|
|
101074
|
-
const specVersion = opts.specVersion ??
|
|
101318
|
+
const specVersion = opts.specVersion ?? targetSpecVersion;
|
|
101319
|
+
if (opts.specVersion !== void 0)
|
|
101320
|
+
specVersionSource = "explicit";
|
|
101321
|
+
span == null ? void 0 : span.setAttributes({
|
|
101322
|
+
...WorkflowRunSpecVersion(specVersion),
|
|
101323
|
+
...WorkflowRunSpecVersionSource(specVersionSource)
|
|
101324
|
+
});
|
|
101325
|
+
const specGateError = (featureRequires) => new WorkflowRuntimeError(crossDeployment && opts.specVersion === void 0 ? `${featureRequires} spec version ${SPEC_VERSION_SUPPORTS_ATTRIBUTES} or later, but the target deployment (${deploymentId}) runs spec version ${specVersion}.` : `${featureRequires} a World that supports spec version ${SPEC_VERSION_SUPPORTS_ATTRIBUTES} or later.`);
|
|
101075
101326
|
const v1Compat = isLegacySpecVersion(specVersion);
|
|
101076
101327
|
const allowReservedAttributes = opts.allowReservedAttributes === true;
|
|
101077
101328
|
let attributes;
|
|
101078
101329
|
if (opts.attributes && Object.keys(opts.attributes).length > 0) {
|
|
101079
101330
|
if (specVersion < SPEC_VERSION_SUPPORTS_ATTRIBUTES) {
|
|
101080
|
-
throw
|
|
101331
|
+
throw specGateError("Initial workflow attributes require");
|
|
101081
101332
|
}
|
|
101082
101333
|
for (const [key, value] of Object.entries(opts.attributes)) {
|
|
101083
101334
|
if (typeof value !== "string") {
|
|
@@ -101095,7 +101346,7 @@ async function start$1(workflow, argsOrOptions, options) {
|
|
|
101095
101346
|
throw new WorkflowRuntimeError(`start({ experimental_retention }) must be 0 or 'default'; received ${JSON.stringify(opts.experimental_retention)}.`);
|
|
101096
101347
|
}
|
|
101097
101348
|
if (specVersion < SPEC_VERSION_SUPPORTS_ATTRIBUTES) {
|
|
101098
|
-
throw
|
|
101349
|
+
throw specGateError("start({ experimental_retention }) requires");
|
|
101099
101350
|
}
|
|
101100
101351
|
retentionAttribute = {
|
|
101101
101352
|
[RETENTION_ATTRIBUTE]: RETENTION_ZERO_ATTRIBUTE_VALUE
|
|
@@ -101227,8 +101478,8 @@ async function recreateRunFromExisting(world, runId, options = {}) {
|
|
|
101227
101478
|
const rawKey = await ((_a3 = world.getEncryptionKeyForRun) == null ? void 0 : _a3.call(world, run2));
|
|
101228
101479
|
const encryptionKey = rawKey ? await deriveRunPayloadKeys(rawKey) : void 0;
|
|
101229
101480
|
const workflowArgs = normalizeWorkflowArgs(await hydrateWorkflowArguments(run2.input, runId, encryptionKey, globalThis));
|
|
101230
|
-
const specVersion = options.specVersion ?? run2.specVersion ?? SPEC_VERSION_LEGACY;
|
|
101231
101481
|
const deploymentId = options.deploymentId ?? run2.deploymentId;
|
|
101482
|
+
const specVersion = options.specVersion ?? (deploymentId === run2.deploymentId ? run2.specVersion ?? SPEC_VERSION_LEGACY : void 0);
|
|
101232
101483
|
const newRun = await start$1({ workflowId: run2.workflowName }, workflowArgs, {
|
|
101233
101484
|
deploymentId,
|
|
101234
101485
|
world,
|
|
@@ -101244,7 +101495,7 @@ async function recreateRunFromExisting(world, runId, options = {}) {
|
|
|
101244
101495
|
async function cancelRun$2(world, runId, options) {
|
|
101245
101496
|
try {
|
|
101246
101497
|
const run2 = await world.runs.get(runId, { resolveData: "none" });
|
|
101247
|
-
const specVersion = run2.specVersion
|
|
101498
|
+
const specVersion = specVersionForRunWrite(run2.specVersion, SPEC_VERSION_LEGACY);
|
|
101248
101499
|
const compatMode = isLegacySpecVersion(specVersion);
|
|
101249
101500
|
const eventRequest = {
|
|
101250
101501
|
eventType: "run_cancelled",
|
|
@@ -101332,7 +101583,7 @@ async function reenqueueRun$2(world, runId, options) {
|
|
|
101332
101583
|
runId
|
|
101333
101584
|
}, {
|
|
101334
101585
|
deploymentId: run2.deploymentId,
|
|
101335
|
-
specVersion: run2.specVersion
|
|
101586
|
+
specVersion: specVersionForRunWrite(run2.specVersion, SPEC_VERSION_LEGACY)
|
|
101336
101587
|
});
|
|
101337
101588
|
} catch (err) {
|
|
101338
101589
|
throw new Error(`Failed to re-enqueue run ${runId}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
@@ -101371,7 +101622,7 @@ async function wakeUpRun$2(world, runId, options) {
|
|
|
101371
101622
|
} : {
|
|
101372
101623
|
eventType: "wait_completed",
|
|
101373
101624
|
correlationId: waitEvent.correlationId,
|
|
101374
|
-
specVersion: run2.specVersion,
|
|
101625
|
+
specVersion: specVersionForRunWrite(run2.specVersion),
|
|
101375
101626
|
eventData: {
|
|
101376
101627
|
resumeAt: waitEvent.eventData.resumeAt
|
|
101377
101628
|
}
|
|
@@ -101392,7 +101643,7 @@ async function wakeUpRun$2(world, runId, options) {
|
|
|
101392
101643
|
runId
|
|
101393
101644
|
}, {
|
|
101394
101645
|
deploymentId: run2.deploymentId,
|
|
101395
|
-
specVersion: run2.specVersion
|
|
101646
|
+
specVersion: specVersionForRunWrite(run2.specVersion, SPEC_VERSION_LEGACY)
|
|
101396
101647
|
});
|
|
101397
101648
|
}
|
|
101398
101649
|
if (errors2.length > 0) {
|
|
@@ -101485,9 +101736,10 @@ const _Run = class _Run {
|
|
|
101485
101736
|
async cancel(options) {
|
|
101486
101737
|
"use step";
|
|
101487
101738
|
const world = await __privateGet(this, _Run_instances, lazyWorldPromise_get);
|
|
101739
|
+
const run2 = await world.runs.get(this.runId, { resolveData: "none" });
|
|
101488
101740
|
await world.events.create(this.runId, {
|
|
101489
101741
|
eventType: "run_cancelled",
|
|
101490
|
-
specVersion:
|
|
101742
|
+
specVersion: specVersionForRunWrite(run2.specVersion),
|
|
101491
101743
|
...(options == null ? void 0 : options.cancelReason) !== void 0 ? { eventData: { cancelReason: options.cancelReason } } : {}
|
|
101492
101744
|
});
|
|
101493
101745
|
}
|
|
@@ -129196,8 +129448,8 @@ const LOCAL_QUEUE_MAX_VISIBILITY = parseInt(process.env.WORKFLOW_LOCAL_QUEUE_MAX
|
|
|
129196
129448
|
const MAX_SAFE_TIMEOUT_MS = 2147483647;
|
|
129197
129449
|
const DEFAULT_CONCURRENCY_LIMIT = 1e3;
|
|
129198
129450
|
const WORKFLOW_LOCAL_QUEUE_CONCURRENCY = parseInt(process.env.WORKFLOW_LOCAL_QUEUE_CONCURRENCY ?? "0", 10) || DEFAULT_CONCURRENCY_LIMIT;
|
|
129199
|
-
const DEFAULT_HEADERS_TIMEOUT_MS =
|
|
129200
|
-
const DEFAULT_BODY_TIMEOUT_MS =
|
|
129451
|
+
const DEFAULT_HEADERS_TIMEOUT_MS = 0;
|
|
129452
|
+
const DEFAULT_BODY_TIMEOUT_MS = 0;
|
|
129201
129453
|
function envTimeoutMs(name2, fallback) {
|
|
129202
129454
|
const raw2 = process.env[name2];
|
|
129203
129455
|
if (raw2 === void 0 || raw2 === "")
|
|
@@ -131031,6 +131283,35 @@ function hookDisposeLockPath(basedir, hookId, tag) {
|
|
|
131031
131283
|
const name2 = tag ? `${hookId}.disposed.${tag}` : `${hookId}.disposed`;
|
|
131032
131284
|
return resolveWithinBase(basedir, ".locks", "hooks", name2);
|
|
131033
131285
|
}
|
|
131286
|
+
async function readHookDisposeLock(basedir, hookId, tag) {
|
|
131287
|
+
const candidates = [hookDisposeLockPath(basedir, hookId)];
|
|
131288
|
+
if (tag) {
|
|
131289
|
+
candidates.push(hookDisposeLockPath(basedir, hookId, tag));
|
|
131290
|
+
}
|
|
131291
|
+
for (const lockPath of candidates) {
|
|
131292
|
+
let content2;
|
|
131293
|
+
try {
|
|
131294
|
+
content2 = await fs$1.readFile(lockPath, "utf8");
|
|
131295
|
+
} catch {
|
|
131296
|
+
continue;
|
|
131297
|
+
}
|
|
131298
|
+
if (content2.trim() === "")
|
|
131299
|
+
return { committed: true };
|
|
131300
|
+
try {
|
|
131301
|
+
const parsed = JSON.parse(content2);
|
|
131302
|
+
const by = parsed.forceClaimedBy;
|
|
131303
|
+
if (by && typeof by.runId === "string" && typeof by.hookId === "string") {
|
|
131304
|
+
return {
|
|
131305
|
+
committed: true,
|
|
131306
|
+
forceClaimedBy: { runId: by.runId, hookId: by.hookId }
|
|
131307
|
+
};
|
|
131308
|
+
}
|
|
131309
|
+
} catch {
|
|
131310
|
+
}
|
|
131311
|
+
return { committed: true };
|
|
131312
|
+
}
|
|
131313
|
+
return { committed: false };
|
|
131314
|
+
}
|
|
131034
131315
|
async function isHookDisposalCommitted(basedir, hookId, tag) {
|
|
131035
131316
|
const candidates = [hookDisposeLockPath(basedir, hookId)];
|
|
131036
131317
|
if (tag) {
|
|
@@ -131164,7 +131445,17 @@ const HookTokenClaimSchema = compile(object$1({
|
|
|
131164
131445
|
// Legacy claims also omitted eventId. Their recovery marker pins the
|
|
131165
131446
|
// canonical hook_created event before concurrent retries publish it.
|
|
131166
131447
|
eventId: string$2().optional(),
|
|
131167
|
-
tokenRetentionUntil: date$2().optional()
|
|
131448
|
+
tokenRetentionUntil: date$2().optional(),
|
|
131449
|
+
// Set when this claim took the token from another run
|
|
131450
|
+
// (`experimental_force`), so a retry that adopts the claim can still
|
|
131451
|
+
// report — and wake — the run it came from.
|
|
131452
|
+
claimedFrom: object$1({
|
|
131453
|
+
runId: string$2(),
|
|
131454
|
+
hookId: string$2(),
|
|
131455
|
+
workflowName: string$2().optional(),
|
|
131456
|
+
deploymentId: string$2().optional(),
|
|
131457
|
+
runSpecVersion: number$3().optional()
|
|
131458
|
+
}).optional()
|
|
131168
131459
|
}));
|
|
131169
131460
|
async function readHookTokenClaim(claimPath) {
|
|
131170
131461
|
try {
|
|
@@ -131302,7 +131593,7 @@ async function writeHookCreatedIndexEntries(basedir, token, runId, hookId, event
|
|
|
131302
131593
|
assertSafeEntityId("eventId", eventId);
|
|
131303
131594
|
if (tag !== void 0)
|
|
131304
131595
|
assertSafeEntityId("tag", tag);
|
|
131305
|
-
const fileName = tag ? `${eventId}.${tag}.json` : `${eventId}.json`;
|
|
131596
|
+
const fileName = tag ? `${runId}-${eventId}.${tag}.json` : `${runId}-${eventId}.json`;
|
|
131306
131597
|
const content2 = JSON.stringify({ runId });
|
|
131307
131598
|
await Promise.all([
|
|
131308
131599
|
writeExclusive(path$3.join(tokenIndexDir(basedir, token), fileName), content2),
|
|
@@ -131411,7 +131702,7 @@ async function ensureHookIndexesImpl(basedir) {
|
|
|
131411
131702
|
});
|
|
131412
131703
|
await writeExclusive(markerPath, "");
|
|
131413
131704
|
}
|
|
131414
|
-
async function
|
|
131705
|
+
async function findIndexedHookCreatedEvent(basedir, index2, accept, tag) {
|
|
131415
131706
|
await ensureHookIndexes(basedir);
|
|
131416
131707
|
let dir;
|
|
131417
131708
|
try {
|
|
@@ -131419,6 +131710,10 @@ async function findNewestIndexedHookCreatedEvent(basedir, index2, matches, tag)
|
|
|
131419
131710
|
} catch {
|
|
131420
131711
|
return null;
|
|
131421
131712
|
}
|
|
131713
|
+
const eventIdOf = (entryId, runId) => {
|
|
131714
|
+
const stripped = stripTag(entryId);
|
|
131715
|
+
return stripped.startsWith(`${runId}-`) ? stripped.slice(runId.length + 1) : stripped;
|
|
131716
|
+
};
|
|
131422
131717
|
const entryIds = (await listJSONFiles(dir)).filter((fileId) => isVisibleToTag(fileId, tag)).sort((a2, b2) => stripTag(b2).localeCompare(stripTag(a2)));
|
|
131423
131718
|
for (const entryId of entryIds) {
|
|
131424
131719
|
let entry2 = null;
|
|
@@ -131431,7 +131726,7 @@ async function findNewestIndexedHookCreatedEvent(basedir, index2, matches, tag)
|
|
|
131431
131726
|
}
|
|
131432
131727
|
if (!entry2)
|
|
131433
131728
|
continue;
|
|
131434
|
-
const eventId =
|
|
131729
|
+
const eventId = eventIdOf(entryId, entry2.runId);
|
|
131435
131730
|
let eventPath;
|
|
131436
131731
|
try {
|
|
131437
131732
|
eventPath = taggedPath(basedir, "events", `${entry2.runId}-${eventId}`, tagOf(entryId));
|
|
@@ -131445,7 +131740,7 @@ async function findNewestIndexedHookCreatedEvent(basedir, index2, matches, tag)
|
|
|
131445
131740
|
continue;
|
|
131446
131741
|
if (typeof event.correlationId !== "string")
|
|
131447
131742
|
continue;
|
|
131448
|
-
if (!
|
|
131743
|
+
if (!await accept(event))
|
|
131449
131744
|
continue;
|
|
131450
131745
|
return event;
|
|
131451
131746
|
}
|
|
@@ -131485,11 +131780,14 @@ function getHookCreatedToken(event) {
|
|
|
131485
131780
|
return typeof token === "string" ? token : void 0;
|
|
131486
131781
|
}
|
|
131487
131782
|
function hookFromCreatedEvent(event) {
|
|
131488
|
-
const { token, metadata, isWebhook, isSystem, tokenRetentionUntil } = event.eventData;
|
|
131783
|
+
const { token, metadata, isWebhook, isSystem, tokenRetentionUntil, forceClaimedFrom } = event.eventData;
|
|
131489
131784
|
return {
|
|
131490
131785
|
runId: event.runId,
|
|
131491
131786
|
hookId: event.correlationId,
|
|
131492
131787
|
token,
|
|
131788
|
+
// The journaled row is the durable record of a takeover; a rebuilt
|
|
131789
|
+
// entity must say where its token came from just as the original did.
|
|
131790
|
+
...forceClaimedFrom !== void 0 && { claimedFrom: forceClaimedFrom },
|
|
131493
131791
|
metadata,
|
|
131494
131792
|
ownerId: "local-owner",
|
|
131495
131793
|
projectId: "local-project",
|
|
@@ -131509,20 +131807,17 @@ async function isTerminalRunCache(basedir, runId, tag) {
|
|
|
131509
131807
|
return run2 ? isTerminalWorkflowRunStatus(run2.status) : false;
|
|
131510
131808
|
}
|
|
131511
131809
|
async function findAvailableHookCreatedEvent(basedir, index2, matches, tag) {
|
|
131512
|
-
const
|
|
131513
|
-
|
|
131514
|
-
|
|
131515
|
-
|
|
131516
|
-
|
|
131517
|
-
|
|
131518
|
-
if (!retainedUntil || retainedUntil.getTime() <= Date.now()) {
|
|
131519
|
-
return null;
|
|
131810
|
+
const isLive = async (event) => {
|
|
131811
|
+
if (await isTerminalRunCache(basedir, event.runId, tag)) {
|
|
131812
|
+
const retainedUntil = event.eventData.tokenRetentionUntil;
|
|
131813
|
+
if (!retainedUntil || retainedUntil.getTime() <= Date.now()) {
|
|
131814
|
+
return false;
|
|
131815
|
+
}
|
|
131520
131816
|
}
|
|
131521
|
-
|
|
131522
|
-
|
|
131523
|
-
|
|
131524
|
-
|
|
131525
|
-
return newest;
|
|
131817
|
+
return !await isHookDisposalCommitted(basedir, event.correlationId, tag);
|
|
131818
|
+
};
|
|
131819
|
+
const found = await findIndexedHookCreatedEvent(basedir, index2, (event) => isMatchingHookCreatedEvent(event, matches) && isLive(event), tag);
|
|
131820
|
+
return found && isMatchingHookCreatedEvent(found, matches) ? found : null;
|
|
131526
131821
|
}
|
|
131527
131822
|
async function restoreHookCachesFromEvent(basedir, event, tag) {
|
|
131528
131823
|
const hook = hookFromCreatedEvent(event);
|
|
@@ -131532,7 +131827,8 @@ async function restoreHookCachesFromEvent(basedir, event, tag) {
|
|
|
131532
131827
|
hookId: hook.hookId,
|
|
131533
131828
|
runId: hook.runId,
|
|
131534
131829
|
eventId: event.eventId,
|
|
131535
|
-
tokenRetentionUntil: event.eventData.tokenRetentionUntil
|
|
131830
|
+
tokenRetentionUntil: event.eventData.tokenRetentionUntil,
|
|
131831
|
+
...hook.claimedFrom && { claimedFrom: hook.claimedFrom }
|
|
131536
131832
|
}));
|
|
131537
131833
|
await writeHookByRunMarker(basedir, hook.runId, hook.hookId, tag);
|
|
131538
131834
|
await writeExclusive(taggedPath(basedir, "hooks", hook.hookId, tag), JSON.stringify(hook, jsonReplacer, 2));
|
|
@@ -131556,36 +131852,52 @@ function createHooksStorage(basedir, tag) {
|
|
|
131556
131852
|
}
|
|
131557
131853
|
return !await isTerminalRunCache(basedir, hook.runId, tag);
|
|
131558
131854
|
}
|
|
131855
|
+
async function isForceDisposed(hook) {
|
|
131856
|
+
const lock = await readHookDisposeLock(basedir, hook.hookId, tag);
|
|
131857
|
+
return lock.committed && lock.forceClaimedBy !== void 0;
|
|
131858
|
+
}
|
|
131559
131859
|
async function findHookByToken(token) {
|
|
131560
131860
|
const claim2 = await readHookTokenClaim(hookTokenClaimPath(basedir, token));
|
|
131561
131861
|
if (claim2 == null ? void 0 : claim2.hookId) {
|
|
131562
131862
|
try {
|
|
131563
131863
|
const hook = await readJSONWithFallback(basedir, "hooks", claim2.hookId, HookSchema, tag);
|
|
131564
131864
|
if ((hook == null ? void 0 : hook.token) === token) {
|
|
131565
|
-
if (
|
|
131865
|
+
if (await isHookAvailable(hook)) {
|
|
131866
|
+
return { ...hook, isWebhook: hook.isWebhook ?? true };
|
|
131867
|
+
}
|
|
131868
|
+
if (!await isForceDisposed(hook)) {
|
|
131566
131869
|
throw new HookNotFoundError(token);
|
|
131567
131870
|
}
|
|
131568
|
-
|
|
131871
|
+
} else if (hook) {
|
|
131872
|
+
return null;
|
|
131569
131873
|
}
|
|
131570
131874
|
} catch (error2) {
|
|
131571
131875
|
if (!UnsafeEntityIdError.is(error2)) {
|
|
131572
131876
|
throw error2;
|
|
131573
131877
|
}
|
|
131878
|
+
return null;
|
|
131574
131879
|
}
|
|
131575
|
-
return null;
|
|
131576
131880
|
}
|
|
131577
131881
|
const hooksDir = path$3.join(basedir, "hooks");
|
|
131578
131882
|
const files = await listJSONFiles(hooksDir);
|
|
131883
|
+
let disposedMatch = false;
|
|
131579
131884
|
for (const file of files) {
|
|
131580
131885
|
const hookPath = path$3.join(hooksDir, `${file}.json`);
|
|
131581
131886
|
const hook = await readJSON(hookPath, HookSchema);
|
|
131582
131887
|
if ((hook == null ? void 0 : hook.token) === token) {
|
|
131583
|
-
if (
|
|
131584
|
-
|
|
131888
|
+
if (await isHookAvailable(hook)) {
|
|
131889
|
+
return { ...hook, isWebhook: hook.isWebhook ?? true };
|
|
131585
131890
|
}
|
|
131586
|
-
|
|
131891
|
+
if (await isForceDisposed(hook)) {
|
|
131892
|
+
disposedMatch = true;
|
|
131893
|
+
continue;
|
|
131894
|
+
}
|
|
131895
|
+
throw new HookNotFoundError(token);
|
|
131587
131896
|
}
|
|
131588
131897
|
}
|
|
131898
|
+
if (disposedMatch) {
|
|
131899
|
+
throw new HookNotFoundError(token);
|
|
131900
|
+
}
|
|
131589
131901
|
return null;
|
|
131590
131902
|
}
|
|
131591
131903
|
async function get2(hookId, params) {
|
|
@@ -132724,6 +133036,15 @@ function createEventsStorage(basedir, tag) {
|
|
|
132724
133036
|
current = { ...current, eventId: slotToEventId(next2) };
|
|
132725
133037
|
}
|
|
132726
133038
|
}
|
|
133039
|
+
async function refuseDisposedHookDelivery(hookId, token) {
|
|
133040
|
+
const lock = await readHookDisposeLock(basedir, hookId, tag);
|
|
133041
|
+
if (!lock.committed)
|
|
133042
|
+
return;
|
|
133043
|
+
if (lock.forceClaimedBy) {
|
|
133044
|
+
throw new HookForceClaimedError(typeof token === "string" ? token : "", lock.forceClaimedBy.runId, lock.forceClaimedBy.hookId);
|
|
133045
|
+
}
|
|
133046
|
+
throw new HookNotFoundError(hookId);
|
|
133047
|
+
}
|
|
132727
133048
|
const queryRunEvents = (runId, pagination) => paginatedFileSystemQuery({
|
|
132728
133049
|
directory: path$3.join(basedir, "events"),
|
|
132729
133050
|
schema: ReadEventSchema,
|
|
@@ -132761,6 +133082,7 @@ function createEventsStorage(basedir, tag) {
|
|
|
132761
133082
|
}
|
|
132762
133083
|
return createImpl();
|
|
132763
133084
|
async function createImpl() {
|
|
133085
|
+
var _a3, _b2;
|
|
132764
133086
|
let eventId = "";
|
|
132765
133087
|
let eventIdPinned = false;
|
|
132766
133088
|
let resumeClaimRecordedId = null;
|
|
@@ -132847,7 +133169,7 @@ function createEventsStorage(basedir, tag) {
|
|
|
132847
133169
|
throw new RunNotSupportedError(currentRun.specVersion, SPEC_VERSION_CURRENT);
|
|
132848
133170
|
}
|
|
132849
133171
|
if (isLegacySpecVersion(currentRun.specVersion)) {
|
|
132850
|
-
return handleLegacyEvent(basedir, effectiveRunId, data, currentRun, params);
|
|
133172
|
+
return handleLegacyEvent(basedir, effectiveRunId, data, currentRun, params && { resolveData: entityResolveData(params.resolveData) });
|
|
132851
133173
|
}
|
|
132852
133174
|
}
|
|
132853
133175
|
const createsChildEntity = isChildEntityCreationEvent(data);
|
|
@@ -132914,8 +133236,8 @@ function createEventsStorage(basedir, tag) {
|
|
|
132914
133236
|
}
|
|
132915
133237
|
}
|
|
132916
133238
|
}
|
|
132917
|
-
if (data.eventType === "hook_received"
|
|
132918
|
-
|
|
133239
|
+
if (data.eventType === "hook_received") {
|
|
133240
|
+
await refuseDisposedHookDelivery(data.correlationId, (_a3 = data.eventData) == null ? void 0 : _a3.token);
|
|
132919
133241
|
}
|
|
132920
133242
|
const existingHook = await readJSONWithFallback(basedir, "hooks", data.correlationId, HookSchema, tag);
|
|
132921
133243
|
if (!existingHook) {
|
|
@@ -132974,6 +133296,7 @@ function createEventsStorage(basedir, tag) {
|
|
|
132974
133296
|
}
|
|
132975
133297
|
}
|
|
132976
133298
|
}
|
|
133299
|
+
let prePublishedEvent;
|
|
132977
133300
|
let event = {
|
|
132978
133301
|
...data,
|
|
132979
133302
|
runId: effectiveRunId,
|
|
@@ -133345,12 +133668,14 @@ function createEventsStorage(basedir, tag) {
|
|
|
133345
133668
|
) {
|
|
133346
133669
|
const hookData = data.eventData;
|
|
133347
133670
|
const constraintPath = hookTokenClaimPath(basedir, hookData.token);
|
|
133348
|
-
|
|
133671
|
+
let claimedFrom;
|
|
133672
|
+
const claimContent = () => JSON.stringify({
|
|
133349
133673
|
token: hookData.token,
|
|
133350
133674
|
hookId: data.correlationId,
|
|
133351
133675
|
runId: effectiveRunId,
|
|
133352
133676
|
eventId,
|
|
133353
|
-
tokenRetentionUntil: hookData.tokenRetentionUntil
|
|
133677
|
+
tokenRetentionUntil: hookData.tokenRetentionUntil,
|
|
133678
|
+
...claimedFrom && { claimedFrom }
|
|
133354
133679
|
});
|
|
133355
133680
|
const claimResult = await withHookTokenClaimLock(basedir, hookData.token, async (signal) => {
|
|
133356
133681
|
let existingClaim = await readHookTokenClaim(constraintPath);
|
|
@@ -133362,26 +133687,114 @@ function createEventsStorage(basedir, tag) {
|
|
|
133362
133687
|
}
|
|
133363
133688
|
if (!existingClaim) {
|
|
133364
133689
|
signal.throwIfAborted();
|
|
133365
|
-
require$$0$4(await writeExclusive(constraintPath, claimContent));
|
|
133690
|
+
require$$0$4(await writeExclusive(constraintPath, claimContent()));
|
|
133366
133691
|
return { status: "claimed" };
|
|
133367
133692
|
}
|
|
133368
133693
|
if (existingClaim.runId === effectiveRunId && existingClaim.hookId === data.correlationId) {
|
|
133369
133694
|
return { status: "owned", claim: existingClaim };
|
|
133370
133695
|
}
|
|
133371
133696
|
if (!await isHookTokenClaimReleasable(basedir, existingClaim, tag)) {
|
|
133372
|
-
|
|
133697
|
+
if (hookData.force !== true || !existingClaim.hookId) {
|
|
133698
|
+
return { status: "conflict", claim: existingClaim };
|
|
133699
|
+
}
|
|
133700
|
+
signal.throwIfAborted();
|
|
133701
|
+
const victimRun = await readJSONWithFallback(basedir, "runs", existingClaim.runId, WorkflowRunSchema, tag);
|
|
133702
|
+
const victimRunning = victimRun !== null && !isTerminalWorkflowRunStatus(victimRun.status);
|
|
133703
|
+
claimedFrom = {
|
|
133704
|
+
runId: existingClaim.runId,
|
|
133705
|
+
hookId: existingClaim.hookId,
|
|
133706
|
+
...victimRunning && {
|
|
133707
|
+
workflowName: victimRun.workflowName,
|
|
133708
|
+
deploymentId: victimRun.deploymentId,
|
|
133709
|
+
runSpecVersion: victimRun.specVersion
|
|
133710
|
+
}
|
|
133711
|
+
};
|
|
133712
|
+
if (victimRunning && (victimRun.specVersion ?? SPEC_VERSION_LEGACY) < SPEC_VERSION_SUPPORTS_HOOK_FORCE_CLAIM) {
|
|
133713
|
+
return {
|
|
133714
|
+
status: "conflict",
|
|
133715
|
+
claim: existingClaim,
|
|
133716
|
+
forceRefusedReason: "victim-spec-version"
|
|
133717
|
+
};
|
|
133718
|
+
}
|
|
133719
|
+
const journaledEventId = await findExistingHookCreatedEventId(basedir, effectiveRunId, data.correlationId);
|
|
133720
|
+
if (journaledEventId) {
|
|
133721
|
+
eventId = journaledEventId;
|
|
133722
|
+
prePublishedEvent = { ...event, eventId };
|
|
133723
|
+
} else {
|
|
133724
|
+
prePublishedEvent = await storeEvent({
|
|
133725
|
+
...event,
|
|
133726
|
+
eventData: {
|
|
133727
|
+
...event.eventData,
|
|
133728
|
+
forceClaimedFrom: claimedFrom
|
|
133729
|
+
}
|
|
133730
|
+
});
|
|
133731
|
+
eventId = prePublishedEvent.eventId;
|
|
133732
|
+
}
|
|
133733
|
+
await writeHookByRunMarker(basedir, effectiveRunId, data.correlationId, tag);
|
|
133734
|
+
await writeJSON(taggedPath(basedir, "hooks", data.correlationId, tag), {
|
|
133735
|
+
runId: effectiveRunId,
|
|
133736
|
+
hookId: data.correlationId,
|
|
133737
|
+
token: hookData.token,
|
|
133738
|
+
metadata: hookData.metadata,
|
|
133739
|
+
ownerId: "local-owner",
|
|
133740
|
+
projectId: "local-project",
|
|
133741
|
+
environment: "local",
|
|
133742
|
+
createdAt: now2,
|
|
133743
|
+
specVersion: effectiveSpecVersion,
|
|
133744
|
+
isWebhook: hookData.isWebhook ?? false,
|
|
133745
|
+
isSystem: hookData.isSystem ?? false,
|
|
133746
|
+
tokenRetentionUntil: hookData.tokenRetentionUntil,
|
|
133747
|
+
claimedFrom
|
|
133748
|
+
}, { overwrite: true });
|
|
133749
|
+
const lockWritten = await writeExclusive(hookDisposeLockPath(basedir, existingClaim.hookId, tag), JSON.stringify({
|
|
133750
|
+
forceClaimedBy: {
|
|
133751
|
+
runId: effectiveRunId,
|
|
133752
|
+
hookId: data.correlationId
|
|
133753
|
+
}
|
|
133754
|
+
}));
|
|
133755
|
+
if (victimRunning) {
|
|
133756
|
+
if (lockWritten) {
|
|
133757
|
+
const disposedEvent = {
|
|
133758
|
+
eventType: "hook_disposed",
|
|
133759
|
+
correlationId: existingClaim.hookId,
|
|
133760
|
+
eventData: {
|
|
133761
|
+
token: hookData.token,
|
|
133762
|
+
forceClaimedBy: {
|
|
133763
|
+
runId: effectiveRunId,
|
|
133764
|
+
hookId: data.correlationId
|
|
133765
|
+
}
|
|
133766
|
+
},
|
|
133767
|
+
runId: existingClaim.runId,
|
|
133768
|
+
eventId: await mintEventId(existingClaim.runId),
|
|
133769
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
133770
|
+
specVersion: victimRun.specVersion
|
|
133771
|
+
};
|
|
133772
|
+
await storeEvent(disposedEvent);
|
|
133773
|
+
}
|
|
133774
|
+
}
|
|
133373
133775
|
}
|
|
133374
133776
|
signal.throwIfAborted();
|
|
133375
|
-
|
|
133777
|
+
if (claimedFrom) {
|
|
133778
|
+
await write(constraintPath, claimContent(), {
|
|
133779
|
+
overwrite: true
|
|
133780
|
+
});
|
|
133781
|
+
} else {
|
|
133782
|
+
await deleteJSON(constraintPath);
|
|
133783
|
+
}
|
|
133376
133784
|
if (existingClaim.hookId) {
|
|
133377
133785
|
await deleteJSON(taggedPath(basedir, "hooks", existingClaim.hookId, tag));
|
|
133378
133786
|
await deleteJSON(hookRecoveryMarkerPath(basedir, hookData.token, existingClaim.runId, existingClaim.hookId));
|
|
133379
133787
|
await deleteHookByRunMarker(basedir, existingClaim.runId, existingClaim.hookId, tag);
|
|
133380
133788
|
}
|
|
133381
133789
|
signal.throwIfAborted();
|
|
133382
|
-
|
|
133790
|
+
if (!claimedFrom) {
|
|
133791
|
+
require$$0$4(await writeExclusive(constraintPath, claimContent()));
|
|
133792
|
+
}
|
|
133383
133793
|
return { status: "claimed" };
|
|
133384
133794
|
});
|
|
133795
|
+
if (claimResult.status === "owned" && claimResult.claim.claimedFrom) {
|
|
133796
|
+
claimedFrom = claimResult.claim.claimedFrom;
|
|
133797
|
+
}
|
|
133385
133798
|
if (claimResult.status === "owned") {
|
|
133386
133799
|
const existingClaim = claimResult.claim;
|
|
133387
133800
|
let canonicalEventId;
|
|
@@ -133423,7 +133836,10 @@ function createEventsStorage(basedir, tag) {
|
|
|
133423
133836
|
correlationId: data.correlationId,
|
|
133424
133837
|
eventData: {
|
|
133425
133838
|
token: hookData.token,
|
|
133426
|
-
conflictingRunId: existingClaim.runId
|
|
133839
|
+
conflictingRunId: existingClaim.runId,
|
|
133840
|
+
...claimResult.forceRefusedReason !== void 0 && {
|
|
133841
|
+
forceRefusedReason: claimResult.forceRefusedReason
|
|
133842
|
+
}
|
|
133427
133843
|
},
|
|
133428
133844
|
runId: effectiveRunId,
|
|
133429
133845
|
eventId,
|
|
@@ -133451,6 +133867,18 @@ function createEventsStorage(basedir, tag) {
|
|
|
133451
133867
|
hasMore: conflictDelta.hasMore
|
|
133452
133868
|
};
|
|
133453
133869
|
}
|
|
133870
|
+
if (claimedFrom) {
|
|
133871
|
+
event = {
|
|
133872
|
+
...event,
|
|
133873
|
+
eventData: {
|
|
133874
|
+
...event.eventData,
|
|
133875
|
+
// Wake-targeting fields included: a replay of this run
|
|
133876
|
+
// republishes the victim's wake from this row alone when the
|
|
133877
|
+
// invocation that created the hook died before waking it.
|
|
133878
|
+
forceClaimedFrom: claimedFrom
|
|
133879
|
+
}
|
|
133880
|
+
};
|
|
133881
|
+
}
|
|
133454
133882
|
const persistedHookData = event.eventData;
|
|
133455
133883
|
hook = {
|
|
133456
133884
|
runId: effectiveRunId,
|
|
@@ -133465,9 +133893,10 @@ function createEventsStorage(basedir, tag) {
|
|
|
133465
133893
|
specVersion: effectiveSpecVersion,
|
|
133466
133894
|
isWebhook: persistedHookData.isWebhook ?? false,
|
|
133467
133895
|
isSystem: persistedHookData.isSystem ?? false,
|
|
133468
|
-
tokenRetentionUntil: persistedHookData.tokenRetentionUntil
|
|
133896
|
+
tokenRetentionUntil: persistedHookData.tokenRetentionUntil,
|
|
133897
|
+
...claimedFrom && { claimedFrom }
|
|
133469
133898
|
};
|
|
133470
|
-
hookEntityWriteOptions = claimResult.status === "owned" ? { overwrite: true } : void 0;
|
|
133899
|
+
hookEntityWriteOptions = claimResult.status === "owned" || claimedFrom ? { overwrite: true } : void 0;
|
|
133471
133900
|
await writeHookCreatedIndexEntries(basedir, hookData.token, effectiveRunId, data.correlationId, eventId, tag);
|
|
133472
133901
|
} else if (data.eventType === "hook_disposed") {
|
|
133473
133902
|
const lockPath = hookDisposeLockPath(basedir, data.correlationId, tag);
|
|
@@ -133525,8 +133954,14 @@ function createEventsStorage(basedir, tag) {
|
|
|
133525
133954
|
};
|
|
133526
133955
|
await writeJSON(taggedPath(basedir, "waits", waitCompositeKey, tag), wait, { overwrite: true });
|
|
133527
133956
|
}
|
|
133528
|
-
if (data.eventType === "hook_received" && data.correlationId
|
|
133529
|
-
|
|
133957
|
+
if (data.eventType === "hook_received" && data.correlationId) {
|
|
133958
|
+
await refuseDisposedHookDelivery(data.correlationId, (_b2 = data.eventData) == null ? void 0 : _b2.token);
|
|
133959
|
+
}
|
|
133960
|
+
if (data.eventType === "hook_created" && data.correlationId) {
|
|
133961
|
+
const own2 = await readHookDisposeLock(basedir, data.correlationId, tag);
|
|
133962
|
+
if (own2.committed && own2.forceClaimedBy) {
|
|
133963
|
+
throw new EntityConflictError(`Hook "${data.correlationId}" was force-claimed by another run before its creation was journaled`);
|
|
133964
|
+
}
|
|
133530
133965
|
}
|
|
133531
133966
|
let eventPath = taggedPath(basedir, "events", `${effectiveRunId}-${eventId}`, tag);
|
|
133532
133967
|
let serializedEvent = JSON.stringify(event, jsonReplacer, 2);
|
|
@@ -133549,7 +133984,13 @@ function createEventsStorage(basedir, tag) {
|
|
|
133549
133984
|
return true;
|
|
133550
133985
|
};
|
|
133551
133986
|
let eventPublished = false;
|
|
133552
|
-
|
|
133987
|
+
if (prePublishedEvent) {
|
|
133988
|
+
event = prePublishedEvent;
|
|
133989
|
+
eventPath = taggedPath(basedir, "events", `${effectiveRunId}-${eventId}`, tag);
|
|
133990
|
+
serializedEvent = JSON.stringify(event, jsonReplacer, 2);
|
|
133991
|
+
eventPublished = true;
|
|
133992
|
+
}
|
|
133993
|
+
for (let attempt = 0; !eventPublished; attempt++) {
|
|
133553
133994
|
if (data.eventType === "hook_received") {
|
|
133554
133995
|
const terminalByMarker = await isRunTerminalCommitted(basedir, effectiveRunId, tag);
|
|
133555
133996
|
const runNow = terminalByMarker ? null : await readJSONWithFallback(basedir, "runs", effectiveRunId, WorkflowRunSchema, tag);
|
|
@@ -133832,7 +134273,11 @@ function createWorld$2(args) {
|
|
|
133832
134273
|
// `(runId, resumeId)` via a filesystem sidecar claim (see
|
|
133833
134274
|
// events-storage.ts `claimHookResume`), so resumeHook()'s parallel fast
|
|
133834
134275
|
// path converges on one event in dev exactly as it does on Vercel.
|
|
133835
|
-
hookResumeDedup: true
|
|
134276
|
+
hookResumeDedup: true,
|
|
134277
|
+
// The token claim lock serializes the takeover behind
|
|
134278
|
+
// `createHook({ experimental_force: true })`; see the hook_created
|
|
134279
|
+
// branch of storage/events-storage.ts.
|
|
134280
|
+
hookForceClaim: true
|
|
133836
134281
|
},
|
|
133837
134282
|
...queue,
|
|
133838
134283
|
...storage,
|
|
@@ -133867,7 +134312,7 @@ function createWorld$2(args) {
|
|
|
133867
134312
|
const basedir = mergedConfig.dataDir;
|
|
133868
134313
|
const hooksDir = path$3.join(basedir, "hooks");
|
|
133869
134314
|
const taggedHookFiles = await listTaggedFiles(hooksDir, tag);
|
|
133870
|
-
const { HookSchema: HookSchema2 } = await import("./index-
|
|
134315
|
+
const { HookSchema: HookSchema2 } = await import("./index-qorbufop.js");
|
|
133871
134316
|
await Promise.all(taggedHookFiles.map(async (hookFile) => {
|
|
133872
134317
|
const hook = await readJSON(path$3.join(hooksDir, hookFile), HookSchema2);
|
|
133873
134318
|
if (hook == null ? void 0 : hook.token) {
|
|
@@ -134050,8 +134495,8 @@ function requireGetVercelOidcToken() {
|
|
|
134050
134495
|
}
|
|
134051
134496
|
try {
|
|
134052
134497
|
const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
|
|
134053
|
-
await import("./token-util-
|
|
134054
|
-
await import("./token-
|
|
134498
|
+
await import("./token-util-CYhmjL6g.js").then((n) => n.t),
|
|
134499
|
+
await import("./token-BfBe4cAY.js").then((n) => n.t)
|
|
134055
134500
|
]);
|
|
134056
134501
|
if (!token || isExpired(getTokenPayload(token), options == null ? void 0 : options.expirationBufferMs)) {
|
|
134057
134502
|
await refreshToken(options);
|
|
@@ -134614,7 +135059,7 @@ function requireDist() {
|
|
|
134614
135059
|
return dist;
|
|
134615
135060
|
}
|
|
134616
135061
|
var distExports = requireDist();
|
|
134617
|
-
const version = "5.0.0-beta.
|
|
135062
|
+
const version = "5.0.0-beta.52";
|
|
134618
135063
|
const pools = globalSingleton("@workflow/world-vercel//httpPools", 1, () => ({
|
|
134619
135064
|
dispatcher: void 0,
|
|
134620
135065
|
queueDispatcher: void 0,
|
|
@@ -135187,6 +135632,10 @@ function headersToRecord(headers2) {
|
|
|
135187
135632
|
}
|
|
135188
135633
|
function errorForResponse(status, message2, opts = {}) {
|
|
135189
135634
|
const { retryAfter, code: code2, url, mitigated, details } = opts;
|
|
135635
|
+
if (status === 409 && code2 === "hook-force-claimed") {
|
|
135636
|
+
const claimedBy = details && typeof details === "object" ? details.claimedBy : void 0;
|
|
135637
|
+
return new HookForceClaimedError("", typeof (claimedBy == null ? void 0 : claimedBy.runId) === "string" ? claimedBy.runId : "unknown", typeof (claimedBy == null ? void 0 : claimedBy.hookId) === "string" ? claimedBy.hookId : void 0);
|
|
135638
|
+
}
|
|
135190
135639
|
if (status === 409)
|
|
135191
135640
|
return new EntityConflictError(message2);
|
|
135192
135641
|
if (status === 410) {
|
|
@@ -136267,7 +136716,7 @@ function createGetEncryptionKeyForRun(projectId, teamId, token, dispatcher2) {
|
|
|
136267
136716
|
};
|
|
136268
136717
|
}
|
|
136269
136718
|
async function getDeadline() {
|
|
136270
|
-
const { getDeadline: getDeadline2 } = await import("./index-
|
|
136719
|
+
const { getDeadline: getDeadline2 } = await import("./index-CD3sqsfS.js").then((n) => n.i);
|
|
136271
136720
|
return getDeadline2();
|
|
136272
136721
|
}
|
|
136273
136722
|
const WORKFLOW_SERVER_SERVICE = {
|
|
@@ -141414,7 +141863,7 @@ const wsEventsChannelForInvocation = (runId, config2) => {
|
|
|
141414
141863
|
open() {
|
|
141415
141864
|
if (!runId || !isWsEventsTransportEnabled())
|
|
141416
141865
|
return;
|
|
141417
|
-
claim2 = import("./ws-transport-
|
|
141866
|
+
claim2 = import("./ws-transport-xTHJJcp4.js").then(({ openWsChannel }) => openWsChannel(runId, config2)).catch(() => void 0);
|
|
141418
141867
|
},
|
|
141419
141868
|
/**
|
|
141420
141869
|
* Awaited, unlike the open: work scheduled after the handler returns is not
|
|
@@ -141864,7 +142313,9 @@ function collectErrorMarkers(err, depth = 0) {
|
|
|
141864
142313
|
function isRetryableEventPostError(err) {
|
|
141865
142314
|
if (err instanceof ReplayEventObserverError)
|
|
141866
142315
|
return false;
|
|
141867
|
-
if (EntityConflictError.is(err) ||
|
|
142316
|
+
if (EntityConflictError.is(err) || // A takeover redirect is definitive for THIS target; the runtime's
|
|
142317
|
+
// resume path follows the token instead of re-issuing the write here.
|
|
142318
|
+
HookForceClaimedError.is(err) || RunExpiredError.is(err) || TooEarlyError.is(err) || ThrottleError.is(err)) {
|
|
141868
142319
|
return false;
|
|
141869
142320
|
}
|
|
141870
142321
|
if (WorkflowWorldError.is(err) || StreamError.is(err)) {
|
|
@@ -142396,6 +142847,9 @@ function buildPostFrameMeta(input) {
|
|
|
142396
142847
|
eventType: input.eventType,
|
|
142397
142848
|
specVersion: input.specVersion
|
|
142398
142849
|
};
|
|
142850
|
+
if (input.executorSpecVersion !== void 0) {
|
|
142851
|
+
meta.executorSpecVersion = input.executorSpecVersion;
|
|
142852
|
+
}
|
|
142399
142853
|
if (input.correlationId !== void 0)
|
|
142400
142854
|
meta.correlationId = input.correlationId;
|
|
142401
142855
|
if (input.vercelId !== void 0)
|
|
@@ -142407,6 +142861,9 @@ function buildPostFrameMeta(input) {
|
|
|
142407
142861
|
if (input.remoteRefBehavior !== void 0) {
|
|
142408
142862
|
meta.remoteRefBehavior = input.remoteRefBehavior;
|
|
142409
142863
|
}
|
|
142864
|
+
if (input.eventsRemoteRefBehavior !== void 0) {
|
|
142865
|
+
meta.eventsRemoteRefBehavior = input.eventsRemoteRefBehavior;
|
|
142866
|
+
}
|
|
142410
142867
|
if (input.deploymentId !== void 0)
|
|
142411
142868
|
meta.deploymentId = input.deploymentId;
|
|
142412
142869
|
if (input.workflowName !== void 0)
|
|
@@ -142428,6 +142885,8 @@ function buildPostFrameMeta(input) {
|
|
|
142428
142885
|
meta.hookIsWebhook = input.hookIsWebhook;
|
|
142429
142886
|
if (input.hookIsSystem !== void 0)
|
|
142430
142887
|
meta.hookIsSystem = input.hookIsSystem;
|
|
142888
|
+
if (input.hookForce !== void 0)
|
|
142889
|
+
meta.hookForce = input.hookForce;
|
|
142431
142890
|
if (input.resumeId !== void 0)
|
|
142432
142891
|
meta.resumeId = input.resumeId;
|
|
142433
142892
|
if (input.errorCode !== void 0)
|
|
@@ -142495,8 +142954,13 @@ function errorFromV4Response(statusCode, responseHeaders, errorBody, opName, url
|
|
|
142495
142954
|
message2 = record2.message;
|
|
142496
142955
|
if (typeof record2.code === "string")
|
|
142497
142956
|
code2 = record2.code;
|
|
142957
|
+
else if (typeof record2.error === "string")
|
|
142958
|
+
code2 = record2.error;
|
|
142498
142959
|
if (statusCode === 412)
|
|
142499
142960
|
details = decodePreconditionDetails(record2);
|
|
142961
|
+
if (statusCode === 409 && code2 === "hook-force-claimed") {
|
|
142962
|
+
details = { claimedBy: record2.claimedBy };
|
|
142963
|
+
}
|
|
142500
142964
|
} else if (text2) {
|
|
142501
142965
|
message2 += ` ${text2}`;
|
|
142502
142966
|
}
|
|
@@ -142647,7 +143111,7 @@ async function decodeCreateEventResponse(response2, eventType) {
|
|
|
142647
143111
|
}
|
|
142648
143112
|
async function createWorkflowRunStartedEventV4(input, config2, replayEventObserver) {
|
|
142649
143113
|
const response2 = await postWorkflowRunEventV4({ ...input, eventType: "run_started" }, "event-stream", config2);
|
|
142650
|
-
const page = await consumeReplayLogResponse(response2, input
|
|
143114
|
+
const page = await consumeReplayLogResponse(response2, input, config2, replayEventObserver);
|
|
142651
143115
|
if (!page.cursor) {
|
|
142652
143116
|
throw new WorkflowWorldError("v4 createEvent: event stream missing cursor", { code: "SCHEMA_VALIDATION" });
|
|
142653
143117
|
}
|
|
@@ -142732,7 +143196,7 @@ function wsReplyStatus(reply, endpoint) {
|
|
|
142732
143196
|
return status;
|
|
142733
143197
|
}
|
|
142734
143198
|
async function postEventFrameOverWs(input, config2) {
|
|
142735
|
-
const { resolveWsTransport } = await import("./ws-transport-
|
|
143199
|
+
const { resolveWsTransport } = await import("./ws-transport-xTHJJcp4.js");
|
|
142736
143200
|
const { runId } = input;
|
|
142737
143201
|
const resolved = resolveWsTransport(runId, config2);
|
|
142738
143202
|
if (!resolved)
|
|
@@ -142799,7 +143263,7 @@ async function createHookReceivedPreloadEventV4(input, config2, replayEventObser
|
|
|
142799
143263
|
result: await decodeCreateEventResponse(response2, "hook_received")
|
|
142800
143264
|
};
|
|
142801
143265
|
}
|
|
142802
|
-
const page = await consumeReplayLogResponse(response2, input
|
|
143266
|
+
const page = await consumeReplayLogResponse(response2, input, config2, replayEventObserver);
|
|
142803
143267
|
const maxEvents = MaxEventsHeaderSchema.safeParse(response2.headers.get(MAX_EVENTS_HEADER));
|
|
142804
143268
|
return {
|
|
142805
143269
|
kind: "stream",
|
|
@@ -142925,7 +143389,7 @@ async function consumeEventFrameStream(response2, opName, replayEventObserver) {
|
|
|
142925
143389
|
}
|
|
142926
143390
|
return partialEventFrameStream(events2, new WorkflowWorldError(`v4 ${opName}: frame stream ended without the end-of-stream sentinel (${events2.length} events read)`, { code: "TRANSPORT" }));
|
|
142927
143391
|
}
|
|
142928
|
-
async function consumeReplayLogResponse(response2, runId, config2, replayEventObserver) {
|
|
143392
|
+
async function consumeReplayLogResponse(response2, { runId, eventsRemoteRefBehavior }, config2, replayEventObserver) {
|
|
142929
143393
|
const page = await consumeEventFrameStream(response2, "createEvent", replayEventObserver);
|
|
142930
143394
|
if (!page.hasMore) {
|
|
142931
143395
|
return {
|
|
@@ -142937,7 +143401,11 @@ async function consumeReplayLogResponse(response2, runId, config2, replayEventOb
|
|
|
142937
143401
|
if (!page.cursor) {
|
|
142938
143402
|
throw new WorkflowWorldError("v4 createEvent: partial event stream missing cursor", { code: "SCHEMA_VALIDATION" });
|
|
142939
143403
|
}
|
|
142940
|
-
const suffix = await getWorkflowRunEventsV4(runId, {
|
|
143404
|
+
const suffix = await getWorkflowRunEventsV4(runId, {
|
|
143405
|
+
cursor: page.cursor,
|
|
143406
|
+
// The suffix of a replay log is the same replay log.
|
|
143407
|
+
remoteRefBehavior: eventsRemoteRefBehavior === "skip-step-inputs" ? "skip-step-inputs" : "resolve"
|
|
143408
|
+
}, config2, replayEventObserver);
|
|
142941
143409
|
return {
|
|
142942
143410
|
events: [...page.events, ...suffix.events],
|
|
142943
143411
|
cursor: suffix.cursor ?? page.cursor,
|
|
@@ -142948,6 +143416,34 @@ async function consumeListFrameStream(url, headers2, config2, opName, replayEven
|
|
|
142948
143416
|
const response2 = await fetchV4(url, { method: "GET", headers: headers2 }, config2, opName);
|
|
142949
143417
|
return consumeEventFrameStream(response2, opName, replayEventObserver);
|
|
142950
143418
|
}
|
|
143419
|
+
const skipStepInputsSupport = globalSingleton("@workflow/world-vercel//skipStepInputsSupport", 2, () => ({ unsupportedSince: /* @__PURE__ */ new Map() }));
|
|
143420
|
+
const SKIP_STEP_INPUTS_REPROBE_MS = 10 * 6e4;
|
|
143421
|
+
function skipStepInputsKnownUnsupported(baseUrl) {
|
|
143422
|
+
const since = skipStepInputsSupport.unsupportedSince.get(baseUrl);
|
|
143423
|
+
if (since === void 0)
|
|
143424
|
+
return false;
|
|
143425
|
+
if (Date.now() - since < SKIP_STEP_INPUTS_REPROBE_MS)
|
|
143426
|
+
return true;
|
|
143427
|
+
skipStepInputsSupport.unsupportedSince.delete(baseUrl);
|
|
143428
|
+
return false;
|
|
143429
|
+
}
|
|
143430
|
+
function mayRejectSkipStepInputs(error2) {
|
|
143431
|
+
return error2 instanceof WorkflowWorldError && error2.status === 400 && error2.code === "validation-error";
|
|
143432
|
+
}
|
|
143433
|
+
async function consumeListWithSkipFallback(baseUrl, requested, buildUrl, headers2, config2, opName, replayEventObserver) {
|
|
143434
|
+
if (requested === "skip-step-inputs" && !skipStepInputsKnownUnsupported(baseUrl)) {
|
|
143435
|
+
try {
|
|
143436
|
+
return await consumeListFrameStream(buildUrl(requested), headers2, config2, opName, replayEventObserver);
|
|
143437
|
+
} catch (error2) {
|
|
143438
|
+
if (!mayRejectSkipStepInputs(error2))
|
|
143439
|
+
throw error2;
|
|
143440
|
+
}
|
|
143441
|
+
const result = await consumeListFrameStream(buildUrl("resolve"), headers2, config2, opName, replayEventObserver);
|
|
143442
|
+
skipStepInputsSupport.unsupportedSince.set(baseUrl, Date.now());
|
|
143443
|
+
return result;
|
|
143444
|
+
}
|
|
143445
|
+
return consumeListFrameStream(buildUrl(requested === "skip-step-inputs" ? "resolve" : requested), headers2, config2, opName, replayEventObserver);
|
|
143446
|
+
}
|
|
142951
143447
|
function appendListParams(sp, params) {
|
|
142952
143448
|
if (params.cursor)
|
|
142953
143449
|
sp.set("cursor", params.cursor);
|
|
@@ -142973,8 +143469,8 @@ async function getWorkflowRunEventsV4(runId, params = {}, config2, replayEventOb
|
|
|
142973
143469
|
let partialStreamRetries = 0;
|
|
142974
143470
|
let consumed;
|
|
142975
143471
|
do {
|
|
142976
|
-
const
|
|
142977
|
-
consumed = await
|
|
143472
|
+
const pageCursor = cursor ?? void 0;
|
|
143473
|
+
consumed = await consumeListWithSkipFallback(baseUrl, params.remoteRefBehavior, (remoteRefBehavior) => `${baseUrl}/v4/runs/${encodeURIComponent(runId)}/events` + paginationToQuery({ ...params, remoteRefBehavior, cursor: pageCursor }), headers2, config2, "listEvents", replayEventObserver);
|
|
142978
143474
|
const cursorAdvanced = !!consumed.cursor && consumed.cursor !== cursor;
|
|
142979
143475
|
if (consumed.kind === "partial") {
|
|
142980
143476
|
if (params.limit !== void 0 || !cursorAdvanced || partialStreamRetries === MAX_PARTIAL_STREAM_RETRIES) {
|
|
@@ -142997,12 +143493,13 @@ async function getWorkflowRunEventsV4(runId, params = {}, config2, replayEventOb
|
|
|
142997
143493
|
}
|
|
142998
143494
|
async function getEventsByCorrelationIdV4(correlationId, runId, params = {}, config2) {
|
|
142999
143495
|
const { baseUrl, headers: headers2 } = await getHttpConfig(config2);
|
|
143000
|
-
const
|
|
143001
|
-
|
|
143002
|
-
|
|
143003
|
-
|
|
143004
|
-
|
|
143005
|
-
|
|
143496
|
+
const consumed = await consumeListWithSkipFallback(baseUrl, params.remoteRefBehavior, (remoteRefBehavior) => {
|
|
143497
|
+
const sp = new URLSearchParams();
|
|
143498
|
+
sp.set("correlationId", correlationId);
|
|
143499
|
+
sp.set("runId", runId);
|
|
143500
|
+
appendListParams(sp, { ...params, remoteRefBehavior });
|
|
143501
|
+
return `${baseUrl}/v4/events?${sp.toString()}`;
|
|
143502
|
+
}, headers2, config2, "listEventsByCorrelationId");
|
|
143006
143503
|
if (consumed.kind === "partial")
|
|
143007
143504
|
throw consumed.error;
|
|
143008
143505
|
return {
|
|
@@ -143296,6 +143793,9 @@ function splitEventDataForV4(data) {
|
|
|
143296
143793
|
if (typeof eventData.isSystem === "boolean") {
|
|
143297
143794
|
meta.hookIsSystem = eventData.isSystem;
|
|
143298
143795
|
}
|
|
143796
|
+
if (eventData.force === true) {
|
|
143797
|
+
meta.hookForce = true;
|
|
143798
|
+
}
|
|
143299
143799
|
if (typeof eventData.errorCode === "string") {
|
|
143300
143800
|
meta.errorCode = eventData.errorCode;
|
|
143301
143801
|
}
|
|
@@ -143363,7 +143863,7 @@ async function getWorkflowRunEvents(params, config2) {
|
|
|
143363
143863
|
const { pagination, resolveData = DEFAULT_RESOLVE_DATA_OPTION } = params;
|
|
143364
143864
|
const listParams = {
|
|
143365
143865
|
...pagination,
|
|
143366
|
-
remoteRefBehavior: resolveData === "none" ? "lazy" : "resolve"
|
|
143866
|
+
remoteRefBehavior: resolveData === "none" ? "lazy" : resolveData === "skip-step-inputs" ? "skip-step-inputs" : "resolve"
|
|
143367
143867
|
};
|
|
143368
143868
|
const result = await ("correlationId" in params ? getEventsByCorrelationIdV4(params.correlationId, params.runId, listParams, config2) : getWorkflowRunEventsV4(params.runId, listParams, config2));
|
|
143369
143869
|
return {
|
|
@@ -143428,7 +143928,7 @@ async function createWorkflowRunEventBatch(runId, events2, params, config2) {
|
|
|
143428
143928
|
};
|
|
143429
143929
|
}
|
|
143430
143930
|
async function createWorkflowRunEvent(id2, data, params, config2) {
|
|
143431
|
-
var _a3, _b2;
|
|
143931
|
+
var _a3, _b2, _c2;
|
|
143432
143932
|
try {
|
|
143433
143933
|
const result = await withEventPostRetry(() => createWorkflowRunEventInner(id2, data, params, config2), data.eventType, {
|
|
143434
143934
|
// The atomic lazy-resume shape is deduplicated server-side by the
|
|
@@ -143449,6 +143949,10 @@ async function createWorkflowRunEvent(id2, data, params, config2) {
|
|
|
143449
143949
|
} catch (err) {
|
|
143450
143950
|
if (err instanceof ReplayEventObserverError)
|
|
143451
143951
|
throw err.error;
|
|
143952
|
+
if (HookForceClaimedError.is(err) && data.eventType === "hook_received") {
|
|
143953
|
+
const token = (_c2 = data.eventData) == null ? void 0 : _c2.token;
|
|
143954
|
+
throw new HookForceClaimedError(typeof token === "string" ? token : err.token, err.claimedByRunId, err.claimedByHookId);
|
|
143955
|
+
}
|
|
143452
143956
|
if (isHookEventRequiringExistence(data.eventType) && WorkflowWorldError.is(err) && err.status === 404 && data.correlationId) {
|
|
143453
143957
|
throw new HookNotFoundError(data.correlationId);
|
|
143454
143958
|
}
|
|
@@ -143458,7 +143962,7 @@ async function createWorkflowRunEvent(id2, data, params, config2) {
|
|
|
143458
143962
|
async function createWorkflowRunEventInner(id2, data, params, config2) {
|
|
143459
143963
|
if (params == null ? void 0 : params.v1Compat) {
|
|
143460
143964
|
if (data.eventType === "run_cancelled" && id2) {
|
|
143461
|
-
const run2 = await cancelWorkflowRunV1(id2, params, config2);
|
|
143965
|
+
const run2 = await cancelWorkflowRunV1(id2, { ...params, resolveData: entityResolveData(params.resolveData) }, config2);
|
|
143462
143966
|
return { run: run2 };
|
|
143463
143967
|
}
|
|
143464
143968
|
if (data.eventType === "run_created") {
|
|
@@ -143496,6 +144000,9 @@ async function createWorkflowRunEventInner(id2, data, params, config2) {
|
|
|
143496
144000
|
const input = {
|
|
143497
144001
|
runId: id2,
|
|
143498
144002
|
specVersion: data.specVersion ?? 2,
|
|
144003
|
+
...data.eventType === "run_started" ? {
|
|
144004
|
+
executorSpecVersion: (config2 == null ? void 0 : config2.mintedSpecVersion) ?? mintedSpecVersion()
|
|
144005
|
+
} : {},
|
|
143499
144006
|
...data.correlationId ? { correlationId: data.correlationId } : {},
|
|
143500
144007
|
...(params == null ? void 0 : params.requestId) ? { vercelId: params.requestId } : {},
|
|
143501
144008
|
...(params == null ? void 0 : params.computeInstanceId) ? { computeInstanceId: params.computeInstanceId } : {},
|
|
@@ -143520,6 +144027,10 @@ async function createWorkflowRunEventInner(id2, data, params, config2) {
|
|
|
143520
144027
|
// defense-in-depth when it recorded a 412 rejection for this correlation
|
|
143521
144028
|
// id and no step entity exists.
|
|
143522
144029
|
...(params == null ? void 0 : params.viaStepDispatch) ? { viaStepDispatch: true } : {},
|
|
144030
|
+
// The event-log page this POST returns (a preload or a `sinceCursor`
|
|
144031
|
+
// delta) may leave out step inputs; the created event and step entity
|
|
144032
|
+
// follow `remoteRefBehavior` and never do.
|
|
144033
|
+
...(params == null ? void 0 : params.resolveData) === "skip-step-inputs" ? { eventsRemoteRefBehavior: "skip-step-inputs" } : {},
|
|
143523
144034
|
remoteRefBehavior,
|
|
143524
144035
|
payload,
|
|
143525
144036
|
...meta
|
|
@@ -143820,7 +144331,7 @@ function beginNormalWsClose(ws, reason) {
|
|
|
143820
144331
|
await observed;
|
|
143821
144332
|
span == null ? void 0 : span.setAttribute("workflow.stream.ws.close_cleanup_timeout", timedOut);
|
|
143822
144333
|
});
|
|
143823
|
-
void import("./index-
|
|
144334
|
+
void import("./index-CD3sqsfS.js").then((n) => n.i).then(({ waitUntil: waitUntil2 }) => waitUntil2(cleanup)).catch(() => {
|
|
143824
144335
|
});
|
|
143825
144336
|
void cleanup.catch(() => {
|
|
143826
144337
|
});
|
|
@@ -144172,7 +144683,7 @@ class VercelStreamWriteSession {
|
|
|
144172
144683
|
return http3;
|
|
144173
144684
|
});
|
|
144174
144685
|
const [{ WebSocket: WebSocketImpl }, http2] = await Promise.all([
|
|
144175
|
-
import("./wrapper-
|
|
144686
|
+
import("./wrapper-CUYQE5_Q.js"),
|
|
144176
144687
|
httpPromise
|
|
144177
144688
|
]);
|
|
144178
144689
|
if (this.mode !== "connecting")
|
|
@@ -144755,6 +145266,8 @@ function createStreamer(config2) {
|
|
|
144755
145266
|
function createWorld$1(config2) {
|
|
144756
145267
|
var _a3, _b2;
|
|
144757
145268
|
const projectId = ((_a3 = config2 == null ? void 0 : config2.projectConfig) == null ? void 0 : _a3.projectId) || process.env.VERCEL_PROJECT_ID;
|
|
145269
|
+
const specVersion = mintedSpecVersion();
|
|
145270
|
+
config2 = { ...config2, mintedSpecVersion: specVersion };
|
|
144758
145271
|
return {
|
|
144759
145272
|
// The version is what tells the backend which id scheme a run uses: it is
|
|
144760
145273
|
// stamped on `run_created` and read back on every later write, so a run
|
|
@@ -144765,7 +145278,7 @@ function createWorld$1(config2) {
|
|
|
144765
145278
|
// version that introduced slots: a bump has to move this declaration with
|
|
144766
145279
|
// it, or the runtime's compatibility floor rises past the adapter shipped
|
|
144767
145280
|
// alongside it and rejects it (see `assertWorldSupportsRuntimeProtocol`).
|
|
144768
|
-
specVersion
|
|
145281
|
+
specVersion,
|
|
144769
145282
|
capabilities: {
|
|
144770
145283
|
hookRetention: { active: true },
|
|
144771
145284
|
// Vercel Queues supports maxConcurrency-limited consumers, which
|
|
@@ -144774,7 +145287,15 @@ function createWorld$1(config2) {
|
|
|
144774
145287
|
maxConcurrency: true,
|
|
144775
145288
|
// Vercel deployments are atomic and immutable, so a deployment id names
|
|
144776
145289
|
// one fixed build for its whole lifetime.
|
|
144777
|
-
deploymentAffinity: true
|
|
145290
|
+
deploymentAffinity: true,
|
|
145291
|
+
// The server implements the takeover protocol behind
|
|
145292
|
+
// `createHook({ experimental_force: true })` (workflow-server
|
|
145293
|
+
// docs/hook-force-claim.md). Static rather than attested per lookup,
|
|
145294
|
+
// because the decision is made at `createHook()` time, before any
|
|
145295
|
+
// lookup; against a server that has it switched off (or predates it)
|
|
145296
|
+
// a forced creation is answered with `hook_conflict`, which the
|
|
145297
|
+
// runtime reports as an unsupported-World failure rather than a win.
|
|
145298
|
+
hookForceClaim: true
|
|
144778
145299
|
// NOTE: the backend half of resumeHook()'s lazy path (that
|
|
144779
145300
|
// the server enforces the `(runId, resumeId)` dedup constraint) is
|
|
144780
145301
|
// NO LONGER a static world capability here. It is attested per-lookup by
|
|
@@ -144930,6 +145451,39 @@ globalSingleton("@workflow/core//devServerPort", 1, () => ({
|
|
|
144930
145451
|
inFlight: void 0
|
|
144931
145452
|
}));
|
|
144932
145453
|
globalSingleton("@workflow/core//stepSingleFlight", 1, () => ({ inFlight: /* @__PURE__ */ new Map() }));
|
|
145454
|
+
const HOOK_WAKE_RETRY_DELAYS_MS = [25, 100];
|
|
145455
|
+
function isRetryableWakeError(error2, isDeploymentUnavailableError) {
|
|
145456
|
+
if (isDeploymentUnavailableError == null ? void 0 : isDeploymentUnavailableError(error2))
|
|
145457
|
+
return false;
|
|
145458
|
+
const status = error2 ?? {};
|
|
145459
|
+
const code2 = status.status ?? status.statusCode;
|
|
145460
|
+
if (typeof code2 === "number") {
|
|
145461
|
+
return code2 >= 500 || code2 === 408 || code2 === 429;
|
|
145462
|
+
}
|
|
145463
|
+
const name2 = error2 == null ? void 0 : error2.name;
|
|
145464
|
+
return name2 !== "BadRequestError" && name2 !== "UnauthorizedError" && name2 !== "ForbiddenError";
|
|
145465
|
+
}
|
|
145466
|
+
async function publishHookWakeWithRetry(publish, isDeploymentUnavailableError) {
|
|
145467
|
+
let lastError;
|
|
145468
|
+
for (let attempt = 0; attempt <= HOOK_WAKE_RETRY_DELAYS_MS.length; attempt++) {
|
|
145469
|
+
try {
|
|
145470
|
+
await publish();
|
|
145471
|
+
return;
|
|
145472
|
+
} catch (error2) {
|
|
145473
|
+
lastError = error2;
|
|
145474
|
+
if (!isRetryableWakeError(error2, isDeploymentUnavailableError))
|
|
145475
|
+
break;
|
|
145476
|
+
const delayMs = HOOK_WAKE_RETRY_DELAYS_MS[attempt];
|
|
145477
|
+
if (delayMs !== void 0) {
|
|
145478
|
+
await new Promise((resolve2) => setTimeout(resolve2, delayMs));
|
|
145479
|
+
}
|
|
145480
|
+
}
|
|
145481
|
+
}
|
|
145482
|
+
if (HookNotFoundError.is(lastError)) {
|
|
145483
|
+
throw new WorkflowRuntimeError("The hook resume was committed, but its workflow wake could not be published", { cause: lastError });
|
|
145484
|
+
}
|
|
145485
|
+
throw lastError;
|
|
145486
|
+
}
|
|
144933
145487
|
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
144934
145488
|
var intToChar = new Uint8Array(64);
|
|
144935
145489
|
var charToInt = new Uint8Array(128);
|
|
@@ -145631,39 +146185,6 @@ async function computeResumePayloadDigest(bytes) {
|
|
|
145631
146185
|
}
|
|
145632
146186
|
return hex2;
|
|
145633
146187
|
}
|
|
145634
|
-
const HOOK_WAKE_RETRY_DELAYS_MS = [25, 100];
|
|
145635
|
-
function isRetryableWakeError(error2, isDeploymentUnavailableError) {
|
|
145636
|
-
if (isDeploymentUnavailableError == null ? void 0 : isDeploymentUnavailableError(error2))
|
|
145637
|
-
return false;
|
|
145638
|
-
const status = error2 ?? {};
|
|
145639
|
-
const code2 = status.status ?? status.statusCode;
|
|
145640
|
-
if (typeof code2 === "number") {
|
|
145641
|
-
return code2 >= 500 || code2 === 408 || code2 === 429;
|
|
145642
|
-
}
|
|
145643
|
-
const name2 = error2 == null ? void 0 : error2.name;
|
|
145644
|
-
return name2 !== "BadRequestError" && name2 !== "UnauthorizedError" && name2 !== "ForbiddenError";
|
|
145645
|
-
}
|
|
145646
|
-
async function publishHookWakeWithRetry(publish, isDeploymentUnavailableError) {
|
|
145647
|
-
let lastError;
|
|
145648
|
-
for (let attempt = 0; attempt <= HOOK_WAKE_RETRY_DELAYS_MS.length; attempt++) {
|
|
145649
|
-
try {
|
|
145650
|
-
await publish();
|
|
145651
|
-
return;
|
|
145652
|
-
} catch (error2) {
|
|
145653
|
-
lastError = error2;
|
|
145654
|
-
if (!isRetryableWakeError(error2, isDeploymentUnavailableError))
|
|
145655
|
-
break;
|
|
145656
|
-
const delayMs = HOOK_WAKE_RETRY_DELAYS_MS[attempt];
|
|
145657
|
-
if (delayMs !== void 0) {
|
|
145658
|
-
await new Promise((resolve2) => setTimeout(resolve2, delayMs));
|
|
145659
|
-
}
|
|
145660
|
-
}
|
|
145661
|
-
}
|
|
145662
|
-
if (HookNotFoundError.is(lastError)) {
|
|
145663
|
-
throw new WorkflowRuntimeError("The hook resume was committed, but its workflow wake could not be published", { cause: lastError });
|
|
145664
|
-
}
|
|
145665
|
-
throw lastError;
|
|
145666
|
-
}
|
|
145667
146188
|
function resumeContextFromRun(run2) {
|
|
145668
146189
|
var _a3, _b2, _c2;
|
|
145669
146190
|
const coreVersion = (_a3 = run2.executionContext) == null ? void 0 : _a3.workflowCoreVersion;
|
|
@@ -145742,155 +146263,259 @@ async function getHookByToken(token) {
|
|
|
145742
146263
|
async function resumeHook$2(tokenOrHook, payload, encryptionKeyOverride) {
|
|
145743
146264
|
return resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, false, Date.now());
|
|
145744
146265
|
}
|
|
145745
|
-
|
|
146266
|
+
const MAX_FORCE_CLAIM_REDIRECTS = 3;
|
|
146267
|
+
const notFoundReasons = /* @__PURE__ */ new WeakMap();
|
|
146268
|
+
async function resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, hookFreshlyLookedUp, resumeRequestedAtMs, webhookOnly = false) {
|
|
145746
146269
|
return await waitedUntil(() => {
|
|
145747
146270
|
return trace$2("hook.resume", async (span) => {
|
|
145748
|
-
var _a3, _b2, _c2, _d2, _e2;
|
|
145749
146271
|
const world = await getWorldLazy();
|
|
145750
|
-
|
|
145751
|
-
|
|
145752
|
-
|
|
145753
|
-
|
|
145754
|
-
|
|
145755
|
-
|
|
145756
|
-
|
|
145757
|
-
|
|
145758
|
-
|
|
145759
|
-
|
|
145760
|
-
|
|
145761
|
-
|
|
145762
|
-
if (info.run && isTerminalWorkflowRunStatus(info.run.status)) {
|
|
145763
|
-
throw new HookNotFoundError(hook.token);
|
|
145764
|
-
}
|
|
145765
|
-
const capabilities = getRunCapabilities(resumeContext.workflowCoreVersion);
|
|
145766
|
-
let payloadKey;
|
|
145767
|
-
const runPublicKey = encryptionKeyOverride ? (
|
|
145768
|
-
// The caller already holds a key (resumeWebhook resolved one to
|
|
145769
|
-
// hydrate hook metadata), so sealing would add an ECDH for no
|
|
145770
|
-
// saved round trip. Reuse what it resolved.
|
|
145771
|
-
void 0
|
|
145772
|
-
) : decodeRunPublicKey(resumeContext.encryptionPublicKey);
|
|
145773
|
-
if (runPublicKey) {
|
|
145774
|
-
payloadKey = sealTo(runPublicKey);
|
|
145775
|
-
} else {
|
|
145776
|
-
let encryptionKey = encryptionKeyOverride ?? await resolveHookEncryptionKey(hook, info);
|
|
145777
|
-
if (!capabilities.supportedFormats.has(SerializationFormat$1.ENCRYPTED)) {
|
|
145778
|
-
encryptionKey = void 0;
|
|
145779
|
-
}
|
|
145780
|
-
payloadKey = encryptionKey;
|
|
145781
|
-
}
|
|
145782
|
-
const compression = (resumeContext.runSpecVersion ?? 0) >= SPEC_VERSION_SUPPORTS_COMPRESSION && capabilities.supportedFormats.has(SerializationFormat$1.GZIP);
|
|
145783
|
-
const ops = [];
|
|
145784
|
-
const readbackOps = [];
|
|
145785
|
-
const v1Compat = isLegacySpecVersion(hook.specVersion);
|
|
145786
|
-
const dehydratedPayload = await dehydrateStepReturnValue(payload, hook.runId, payloadKey, ops, globalThis, v1Compat, capabilities.framedByteStreams, compression, void 0, readbackOps);
|
|
145787
|
-
await Promise.all(ops.map((op) => op.catch((error2) => {
|
|
145788
|
-
if (error2 !== void 0)
|
|
145789
|
-
throw error2;
|
|
145790
|
-
})));
|
|
145791
|
-
safeWaitUntil(Promise.all(readbackOps), (err) => {
|
|
145792
|
-
if (err === void 0)
|
|
145793
|
-
return;
|
|
145794
|
-
runtimeLogger.warn("Background readback of hook payload failed", {
|
|
145795
|
-
workflowRunId: hook.runId,
|
|
145796
|
-
hookId: hook.hookId,
|
|
145797
|
-
error: err instanceof Error ? err.message : String(err)
|
|
146272
|
+
const token = typeof tokenOrHook === "string" ? tokenOrHook : tokenOrHook.token;
|
|
146273
|
+
let target2 = tokenOrHook;
|
|
146274
|
+
let fresh = hookFreshlyLookedUp;
|
|
146275
|
+
let keyOverride = encryptionKeyOverride;
|
|
146276
|
+
let redirects = 0;
|
|
146277
|
+
let lookupsAfterRedirect = 0;
|
|
146278
|
+
const MAX_LOOKUPS_AFTER_REDIRECT = 5;
|
|
146279
|
+
const resumeId = generateResumeId();
|
|
146280
|
+
const assertResendable = (cause) => {
|
|
146281
|
+
if (payload instanceof Request && payload.body !== null && payload.bodyUsed) {
|
|
146282
|
+
span == null ? void 0 : span.setAttributes({
|
|
146283
|
+
"workflow.hook.resume_redirect_unresendable": true
|
|
145798
146284
|
});
|
|
145799
|
-
|
|
145800
|
-
span == null ? void 0 : span.setAttributes({
|
|
145801
|
-
...WorkflowName(resumeContext.workflowName)
|
|
145802
|
-
});
|
|
145803
|
-
const originLink = await linkToTraceCarrier(resumeContext.traceCarrier);
|
|
145804
|
-
if (originLink) {
|
|
145805
|
-
(_a3 = span == null ? void 0 : span.addLink) == null ? void 0 : _a3.call(span, originLink);
|
|
145806
|
-
}
|
|
145807
|
-
if (((_b2 = world.capabilities) == null ? void 0 : _b2.invoke) === true && !v1Compat && dehydratedPayload instanceof Uint8Array) {
|
|
145808
|
-
if (!world.invoke) {
|
|
145809
|
-
throw new WorkflowRuntimeError("World advertises invoke without implementing it");
|
|
145810
|
-
}
|
|
145811
|
-
span == null ? void 0 : span.setAttributes({ "workflow.hook.resume_strategy": "invoke" });
|
|
145812
|
-
const result = HookInvocationResultSchema.parse(await world.invoke(hook.runId, {
|
|
145813
|
-
type: "hook_resume",
|
|
145814
|
-
version: 1,
|
|
145815
|
-
hookId: hook.hookId,
|
|
145816
|
-
token: hook.token,
|
|
145817
|
-
payload: dehydratedPayload
|
|
145818
|
-
}, { idempotencyKey: generateResumeId() }));
|
|
145819
|
-
if (result.status === "rejected") {
|
|
145820
|
-
if (result.code === "HOOK_NOT_FOUND")
|
|
145821
|
-
throw new HookNotFoundError(hook.token);
|
|
145822
|
-
throw new WorkflowRuntimeError("Executor rejected the hook invocation input");
|
|
145823
|
-
}
|
|
145824
|
-
span == null ? void 0 : span.setAttributes(HookResumeCommitted(true));
|
|
145825
|
-
return asLazyMetadataHook(hook);
|
|
145826
|
-
}
|
|
145827
|
-
const queueName = getWorkflowQueueName(resumeContext.workflowName);
|
|
145828
|
-
const queueOptions = {
|
|
145829
|
-
deploymentId: resumeContext.deploymentId,
|
|
145830
|
-
specVersion: resumeContext.runSpecVersion ?? SPEC_VERSION_LEGACY
|
|
145831
|
-
};
|
|
145832
|
-
const backendDedupSupported = (hookResumeCapabilitiesAreFresh ? ((_c2 = hook.resumeCapabilities) == null ? void 0 : _c2.hookResumeDedupVersion) ?? 0 : 0) >= HOOK_RESUME_DEDUP_VERSION || ((_d2 = world.capabilities) == null ? void 0 : _d2.hookResumeDedup) === true;
|
|
145833
|
-
const canClaimResume = backendDedupSupported && !v1Compat && dehydratedPayload instanceof Uint8Array;
|
|
145834
|
-
span == null ? void 0 : span.setAttributes({
|
|
145835
|
-
"workflow.hook.resume_strategy": "sequential"
|
|
145836
|
-
});
|
|
145837
|
-
const resumeId = canClaimResume ? generateResumeId() : void 0;
|
|
145838
|
-
const payloadDigest = canClaimResume ? await computeResumePayloadDigest(dehydratedPayload) : void 0;
|
|
145839
|
-
if (resumeId) {
|
|
145840
|
-
span == null ? void 0 : span.setAttributes({ "workflow.hook.resume_id": resumeId });
|
|
146285
|
+
throw new WorkflowRuntimeError(`Hook token "${token}" changed owner while this webhook request was being delivered; a request body can be sent only once and it was not delivered anywhere — retry the request, which will reach the token's new owner`, { cause });
|
|
145841
146286
|
}
|
|
145842
|
-
|
|
146287
|
+
};
|
|
146288
|
+
for (; ; ) {
|
|
145843
146289
|
try {
|
|
145844
|
-
await world
|
|
145845
|
-
eventType: "hook_received",
|
|
145846
|
-
specVersion: SPEC_VERSION_CURRENT,
|
|
145847
|
-
correlationId: hook.hookId,
|
|
145848
|
-
eventData: {
|
|
145849
|
-
...v1Compat ? {} : { token: hook.token },
|
|
145850
|
-
payload: dehydratedPayload
|
|
145851
|
-
}
|
|
145852
|
-
}, {
|
|
145853
|
-
v1Compat,
|
|
145854
|
-
...resumeId && payloadDigest ? { resumeId, resumePayloadDigest: payloadDigest } : {}
|
|
145855
|
-
});
|
|
146290
|
+
return await resumeHookAttempt(world, span, target2, payload, keyOverride, fresh, resumeRequestedAtMs, resumeId, webhookOnly);
|
|
145856
146291
|
} catch (err) {
|
|
145857
|
-
if (
|
|
145858
|
-
throw
|
|
146292
|
+
if (err !== null && typeof err === "object" && notFoundReasons.get(err) === "not-webhook") {
|
|
146293
|
+
throw err;
|
|
146294
|
+
}
|
|
146295
|
+
if (redirects >= MAX_FORCE_CLAIM_REDIRECTS) {
|
|
146296
|
+
if (HookForceClaimedError.is(err)) {
|
|
146297
|
+
span == null ? void 0 : span.setAttributes({
|
|
146298
|
+
"workflow.hook.resume_redirects_exhausted": true
|
|
146299
|
+
});
|
|
146300
|
+
throw new WorkflowRuntimeError(`Hook token "${token}" changed owner ${redirects} times while this resume was in flight; nothing was delivered — retry the resume`, { cause: err });
|
|
146301
|
+
}
|
|
146302
|
+
throw err;
|
|
146303
|
+
}
|
|
146304
|
+
if (HookForceClaimedError.is(err)) {
|
|
146305
|
+
assertResendable(err);
|
|
146306
|
+
redirects++;
|
|
146307
|
+
span == null ? void 0 : span.setAttributes({
|
|
146308
|
+
"workflow.hook.resume_redirects": redirects,
|
|
146309
|
+
"workflow.hook.resume_redirect_to_run": err.claimedByRunId
|
|
146310
|
+
});
|
|
146311
|
+
target2 = token;
|
|
146312
|
+
fresh = true;
|
|
146313
|
+
keyOverride = void 0;
|
|
146314
|
+
lookupsAfterRedirect = 0;
|
|
146315
|
+
continue;
|
|
146316
|
+
}
|
|
146317
|
+
if (HookNotFoundError.is(err) && redirects > 0 && typeof target2 === "string" && lookupsAfterRedirect < MAX_LOOKUPS_AFTER_REDIRECT) {
|
|
146318
|
+
assertResendable(err);
|
|
146319
|
+
lookupsAfterRedirect++;
|
|
146320
|
+
await new Promise((resolve2) => setTimeout(resolve2, 50));
|
|
146321
|
+
continue;
|
|
146322
|
+
}
|
|
146323
|
+
if (HookNotFoundError.is(err) && notFoundReasons.get(err) !== "lookup") {
|
|
146324
|
+
const attemptedHookId = typeof target2 === "string" ? void 0 : target2.hookId;
|
|
146325
|
+
let relocated;
|
|
146326
|
+
try {
|
|
146327
|
+
relocated = await world.hooks.getByToken(token);
|
|
146328
|
+
} catch (lookupError) {
|
|
146329
|
+
if (!HookNotFoundError.is(lookupError)) {
|
|
146330
|
+
runtimeLogger.warn("Hook resume: re-resolving the token after a not-found failed; surfacing the original error", {
|
|
146331
|
+
token,
|
|
146332
|
+
error: lookupError instanceof Error ? lookupError.message : String(lookupError)
|
|
146333
|
+
});
|
|
146334
|
+
}
|
|
146335
|
+
}
|
|
146336
|
+
if ((relocated == null ? void 0 : relocated.claimedFrom) !== void 0 && relocated.hookId !== attemptedHookId && (attemptedHookId === void 0 || relocated.claimedFrom.hookId === attemptedHookId) && !(webhookOnly && relocated.isWebhook === false)) {
|
|
146337
|
+
assertResendable(err);
|
|
146338
|
+
redirects++;
|
|
146339
|
+
span == null ? void 0 : span.setAttributes({
|
|
146340
|
+
"workflow.hook.resume_redirects": redirects,
|
|
146341
|
+
"workflow.hook.resume_redirect_to_run": relocated.runId
|
|
146342
|
+
});
|
|
146343
|
+
target2 = relocated;
|
|
146344
|
+
fresh = true;
|
|
146345
|
+
keyOverride = void 0;
|
|
146346
|
+
continue;
|
|
146347
|
+
}
|
|
145859
146348
|
}
|
|
145860
146349
|
throw err;
|
|
145861
146350
|
}
|
|
145862
|
-
span == null ? void 0 : span.setAttributes(HookResumeCommitted(true));
|
|
145863
|
-
const queuePublishRequestedAtMs = Date.now();
|
|
145864
|
-
await publishHookWakeWithRetry(() => world.queue(queueName, {
|
|
145865
|
-
runId: hook.runId,
|
|
145866
|
-
traceCarrier: resumeContext.traceCarrier ?? void 0,
|
|
145867
|
-
hookResumeTiming: {
|
|
145868
|
-
resumeRequestedAtMs,
|
|
145869
|
-
queuePublishRequestedAtMs,
|
|
145870
|
-
strategy: "sequential"
|
|
145871
|
-
}
|
|
145872
|
-
}, {
|
|
145873
|
-
...queueOptions,
|
|
145874
|
-
// Dedup retried publishes whose response was lost: a
|
|
145875
|
-
// duplicate wake is harmless for correctness (deterministic
|
|
145876
|
-
// replay) but costs a full replay of the run, and the queue
|
|
145877
|
-
// accepts a repeated idempotency key by delivering only one
|
|
145878
|
-
// of the messages. Claim-less writes have no resumeId and
|
|
145879
|
-
// keep the previous behavior.
|
|
145880
|
-
...resumeId ? { idempotencyKey: `hook-${resumeId}` } : {}
|
|
145881
|
-
}), (_e2 = world.isDeploymentUnavailableError) == null ? void 0 : _e2.bind(world));
|
|
145882
|
-
span == null ? void 0 : span.setAttributes(HookWakePublished(true));
|
|
145883
|
-
return asLazyMetadataHook(hook);
|
|
145884
|
-
} catch (err) {
|
|
145885
|
-
span == null ? void 0 : span.setAttributes({
|
|
145886
|
-
...HookToken(typeof tokenOrHook === "string" ? tokenOrHook : tokenOrHook.token),
|
|
145887
|
-
...HookFound(false)
|
|
145888
|
-
});
|
|
145889
|
-
throw err;
|
|
145890
146351
|
}
|
|
145891
146352
|
});
|
|
145892
146353
|
});
|
|
145893
146354
|
}
|
|
146355
|
+
async function resumeHookAttempt(world, span, tokenOrHook, payload, encryptionKeyOverride, hookFreshlyLookedUp, resumeRequestedAtMs, logicalResumeId, webhookOnly) {
|
|
146356
|
+
var _a3, _b2, _c2, _d2, _e2;
|
|
146357
|
+
try {
|
|
146358
|
+
const suppliedToken = typeof tokenOrHook === "string";
|
|
146359
|
+
let hook;
|
|
146360
|
+
if (suppliedToken) {
|
|
146361
|
+
try {
|
|
146362
|
+
hook = await world.hooks.getByToken(tokenOrHook);
|
|
146363
|
+
} catch (lookupError) {
|
|
146364
|
+
if (HookNotFoundError.is(lookupError)) {
|
|
146365
|
+
notFoundReasons.set(lookupError, "lookup");
|
|
146366
|
+
}
|
|
146367
|
+
throw lookupError;
|
|
146368
|
+
}
|
|
146369
|
+
} else {
|
|
146370
|
+
hook = tokenOrHook;
|
|
146371
|
+
}
|
|
146372
|
+
if (webhookOnly && hook.isWebhook === false) {
|
|
146373
|
+
const notWebhook = new HookNotFoundError(hook.token);
|
|
146374
|
+
notFoundReasons.set(notWebhook, "not-webhook");
|
|
146375
|
+
throw notWebhook;
|
|
146376
|
+
}
|
|
146377
|
+
const hookResumeCapabilitiesAreFresh = suppliedToken || hookFreshlyLookedUp;
|
|
146378
|
+
const info = await resolveHookResumeInfo(hook);
|
|
146379
|
+
const { resumeContext } = info;
|
|
146380
|
+
span == null ? void 0 : span.setAttributes({
|
|
146381
|
+
...HookToken(hook.token),
|
|
146382
|
+
...HookId(hook.hookId),
|
|
146383
|
+
...WorkflowRunId$2(hook.runId),
|
|
146384
|
+
"workflow.hook.resume_context_source": info.source
|
|
146385
|
+
});
|
|
146386
|
+
if (info.run && isTerminalWorkflowRunStatus(info.run.status)) {
|
|
146387
|
+
throw new HookNotFoundError(hook.token);
|
|
146388
|
+
}
|
|
146389
|
+
const capabilities = getRunCapabilities(resumeContext.workflowCoreVersion);
|
|
146390
|
+
let payloadKey;
|
|
146391
|
+
const runPublicKey = encryptionKeyOverride ? (
|
|
146392
|
+
// The caller already holds a key (resumeWebhook resolved one to
|
|
146393
|
+
// hydrate hook metadata), so sealing would add an ECDH for no
|
|
146394
|
+
// saved round trip. Reuse what it resolved.
|
|
146395
|
+
void 0
|
|
146396
|
+
) : decodeRunPublicKey(resumeContext.encryptionPublicKey);
|
|
146397
|
+
if (runPublicKey) {
|
|
146398
|
+
payloadKey = sealTo(runPublicKey);
|
|
146399
|
+
} else {
|
|
146400
|
+
let encryptionKey = encryptionKeyOverride ?? await resolveHookEncryptionKey(hook, info);
|
|
146401
|
+
if (!capabilities.supportedFormats.has(SerializationFormat$1.ENCRYPTED)) {
|
|
146402
|
+
encryptionKey = void 0;
|
|
146403
|
+
}
|
|
146404
|
+
payloadKey = encryptionKey;
|
|
146405
|
+
}
|
|
146406
|
+
const compression = (resumeContext.runSpecVersion ?? 0) >= SPEC_VERSION_SUPPORTS_COMPRESSION && capabilities.supportedFormats.has(SerializationFormat$1.GZIP);
|
|
146407
|
+
const ops = [];
|
|
146408
|
+
const readbackOps = [];
|
|
146409
|
+
const v1Compat = isLegacySpecVersion(hook.specVersion);
|
|
146410
|
+
const dehydratedPayload = await dehydrateStepReturnValue(payload, hook.runId, payloadKey, ops, globalThis, v1Compat, capabilities.framedByteStreams, compression, void 0, readbackOps);
|
|
146411
|
+
await Promise.all(ops.map((op) => op.catch((error2) => {
|
|
146412
|
+
if (error2 !== void 0)
|
|
146413
|
+
throw error2;
|
|
146414
|
+
})));
|
|
146415
|
+
safeWaitUntil(Promise.all(readbackOps), (err) => {
|
|
146416
|
+
if (err === void 0)
|
|
146417
|
+
return;
|
|
146418
|
+
runtimeLogger.warn("Background readback of hook payload failed", {
|
|
146419
|
+
workflowRunId: hook.runId,
|
|
146420
|
+
hookId: hook.hookId,
|
|
146421
|
+
error: err instanceof Error ? err.message : String(err)
|
|
146422
|
+
});
|
|
146423
|
+
});
|
|
146424
|
+
if (((_a3 = world.capabilities) == null ? void 0 : _a3.invoke) === true && !v1Compat && dehydratedPayload instanceof Uint8Array) {
|
|
146425
|
+
if (!world.invoke) {
|
|
146426
|
+
throw new WorkflowRuntimeError("World advertises invoke without implementing it");
|
|
146427
|
+
}
|
|
146428
|
+
span == null ? void 0 : span.setAttributes({ "workflow.hook.resume_strategy": "invoke" });
|
|
146429
|
+
const result = HookInvocationResultSchema.parse(await world.invoke(hook.runId, {
|
|
146430
|
+
type: "hook_resume",
|
|
146431
|
+
version: 1,
|
|
146432
|
+
hookId: hook.hookId,
|
|
146433
|
+
token: hook.token,
|
|
146434
|
+
payload: dehydratedPayload
|
|
146435
|
+
}, { idempotencyKey: logicalResumeId }));
|
|
146436
|
+
if (result.status === "rejected") {
|
|
146437
|
+
if (result.code === "HOOK_NOT_FOUND")
|
|
146438
|
+
throw new HookNotFoundError(hook.token);
|
|
146439
|
+
throw new WorkflowRuntimeError("Executor rejected the hook invocation input");
|
|
146440
|
+
}
|
|
146441
|
+
span == null ? void 0 : span.setAttributes(HookResumeCommitted(true));
|
|
146442
|
+
return asLazyMetadataHook(hook);
|
|
146443
|
+
}
|
|
146444
|
+
span == null ? void 0 : span.setAttributes({
|
|
146445
|
+
...WorkflowName(resumeContext.workflowName)
|
|
146446
|
+
});
|
|
146447
|
+
const originLink = await linkToTraceCarrier(resumeContext.traceCarrier);
|
|
146448
|
+
if (originLink) {
|
|
146449
|
+
(_b2 = span == null ? void 0 : span.addLink) == null ? void 0 : _b2.call(span, originLink);
|
|
146450
|
+
}
|
|
146451
|
+
const queueName = getWorkflowQueueName(resumeContext.workflowName);
|
|
146452
|
+
const queueOptions = {
|
|
146453
|
+
deploymentId: resumeContext.deploymentId,
|
|
146454
|
+
specVersion: resumeContext.runSpecVersion ?? SPEC_VERSION_LEGACY
|
|
146455
|
+
};
|
|
146456
|
+
const backendDedupSupported = (hookResumeCapabilitiesAreFresh ? ((_c2 = hook.resumeCapabilities) == null ? void 0 : _c2.hookResumeDedupVersion) ?? 0 : 0) >= HOOK_RESUME_DEDUP_VERSION || ((_d2 = world.capabilities) == null ? void 0 : _d2.hookResumeDedup) === true;
|
|
146457
|
+
const canClaimResume = backendDedupSupported && !v1Compat && dehydratedPayload instanceof Uint8Array;
|
|
146458
|
+
span == null ? void 0 : span.setAttributes({
|
|
146459
|
+
"workflow.hook.resume_strategy": "sequential"
|
|
146460
|
+
});
|
|
146461
|
+
const resumeId = canClaimResume ? logicalResumeId : void 0;
|
|
146462
|
+
const payloadDigest = canClaimResume ? await computeResumePayloadDigest(dehydratedPayload) : void 0;
|
|
146463
|
+
if (resumeId) {
|
|
146464
|
+
span == null ? void 0 : span.setAttributes({ "workflow.hook.resume_id": resumeId });
|
|
146465
|
+
}
|
|
146466
|
+
const isHookGoneError = (err) => HookNotFoundError.is(err) || RunExpiredError.is(err);
|
|
146467
|
+
try {
|
|
146468
|
+
await world.events.create(hook.runId, {
|
|
146469
|
+
eventType: "hook_received",
|
|
146470
|
+
// The payload is already encoded for the run (see `compression`).
|
|
146471
|
+
specVersion: specVersionForRunWrite(resumeContext.runSpecVersion),
|
|
146472
|
+
correlationId: hook.hookId,
|
|
146473
|
+
eventData: {
|
|
146474
|
+
...v1Compat ? {} : { token: hook.token },
|
|
146475
|
+
payload: dehydratedPayload
|
|
146476
|
+
}
|
|
146477
|
+
}, {
|
|
146478
|
+
v1Compat,
|
|
146479
|
+
...resumeId && payloadDigest ? { resumeId, resumePayloadDigest: payloadDigest } : {}
|
|
146480
|
+
});
|
|
146481
|
+
} catch (err) {
|
|
146482
|
+
if (HookForceClaimedError.is(err))
|
|
146483
|
+
throw err;
|
|
146484
|
+
if (isHookGoneError(err)) {
|
|
146485
|
+
throw new HookNotFoundError(hook.token);
|
|
146486
|
+
}
|
|
146487
|
+
throw err;
|
|
146488
|
+
}
|
|
146489
|
+
span == null ? void 0 : span.setAttributes(HookResumeCommitted(true));
|
|
146490
|
+
const queuePublishRequestedAtMs = Date.now();
|
|
146491
|
+
await publishHookWakeWithRetry(() => world.queue(queueName, {
|
|
146492
|
+
runId: hook.runId,
|
|
146493
|
+
traceCarrier: resumeContext.traceCarrier ?? void 0,
|
|
146494
|
+
hookResumeTiming: {
|
|
146495
|
+
resumeRequestedAtMs,
|
|
146496
|
+
queuePublishRequestedAtMs,
|
|
146497
|
+
strategy: "sequential"
|
|
146498
|
+
}
|
|
146499
|
+
}, {
|
|
146500
|
+
...queueOptions,
|
|
146501
|
+
// Dedup retried publishes whose response was lost: a
|
|
146502
|
+
// duplicate wake is harmless for correctness (deterministic
|
|
146503
|
+
// replay) but costs a full replay of the run, and the queue
|
|
146504
|
+
// accepts a repeated idempotency key by delivering only one
|
|
146505
|
+
// of the messages. Claim-less writes have no resumeId and
|
|
146506
|
+
// keep the previous behavior.
|
|
146507
|
+
...resumeId ? { idempotencyKey: `hook-${resumeId}` } : {}
|
|
146508
|
+
}), (_e2 = world.isDeploymentUnavailableError) == null ? void 0 : _e2.bind(world));
|
|
146509
|
+
span == null ? void 0 : span.setAttributes(HookWakePublished(true));
|
|
146510
|
+
return asLazyMetadataHook(hook);
|
|
146511
|
+
} catch (err) {
|
|
146512
|
+
span == null ? void 0 : span.setAttributes({
|
|
146513
|
+
...HookToken(typeof tokenOrHook === "string" ? tokenOrHook : tokenOrHook.token),
|
|
146514
|
+
...HookFound(false)
|
|
146515
|
+
});
|
|
146516
|
+
throw err;
|
|
146517
|
+
}
|
|
146518
|
+
}
|
|
145894
146519
|
async function resumeWebhook(token, request2) {
|
|
145895
146520
|
const resumeRequestedAtMs = Date.now();
|
|
145896
146521
|
const world = await getWorldLazy();
|
|
@@ -145914,7 +146539,7 @@ async function resumeWebhook(token, request2) {
|
|
|
145914
146539
|
} else {
|
|
145915
146540
|
response2 = new Response(null, { status: 202 });
|
|
145916
146541
|
}
|
|
145917
|
-
await resumeHookImpl(hook, request2, metadataEncryptionKey(), true, resumeRequestedAtMs);
|
|
146542
|
+
await resumeHookImpl(hook, request2, metadataEncryptionKey(), true, resumeRequestedAtMs, true);
|
|
145918
146543
|
if (responseReadable) {
|
|
145919
146544
|
const reader = responseReadable.getReader();
|
|
145920
146545
|
const chunk = await reader.read();
|
|
@@ -169130,7 +169755,7 @@ const route4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
|
|
|
169130
169755
|
__proto__: null,
|
|
169131
169756
|
loader
|
|
169132
169757
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
169133
|
-
const serverManifest = { "entry": { "module": "/assets/entry.client-DmlDFlyx.js", "imports": ["/assets/index-thGVuYbY.js"], "css": [] }, "routes": { "root": { "id": "root", "parentId": void 0, "path": "", "index": void 0, "caseSensitive": void 0, "hasAction": true, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": true, "module": "/assets/root-
|
|
169758
|
+
const serverManifest = { "entry": { "module": "/assets/entry.client-DmlDFlyx.js", "imports": ["/assets/index-thGVuYbY.js"], "css": [] }, "routes": { "root": { "id": "root", "parentId": void 0, "path": "", "index": void 0, "caseSensitive": void 0, "hasAction": true, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": true, "module": "/assets/root-3gE7cfR2.js", "imports": ["/assets/index-thGVuYbY.js", "/assets/mermaid-3ZIDBTTL-DG0Grjgm.js", "/assets/loader-circle-Cj8CH5bR.js", "/assets/arrow-up-right-XpJjI06G.js"], "css": ["/assets/root-grl25rxS.css", "/assets/mermaid-3ZIDBTTL-D8CjRQta.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/home": { "id": "routes/home", "parentId": "root", "path": void 0, "index": true, "caseSensitive": void 0, "hasAction": false, "hasLoader": false, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/home-CLktiGIz.js", "imports": ["/assets/index-thGVuYbY.js", "/assets/workflow-graph-viewer-Cg3Lr_h8.js", "/assets/mermaid-3ZIDBTTL-DG0Grjgm.js", "/assets/loader-circle-Cj8CH5bR.js"], "css": ["/assets/workflow-graph-viewer-DnlNuQQH.css", "/assets/mermaid-3ZIDBTTL-D8CjRQta.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/run-detail": { "id": "routes/run-detail", "parentId": "root", "path": "run/:runId", "index": void 0, "caseSensitive": void 0, "hasAction": false, "hasLoader": false, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/run-detail-gOfjBB1S.js", "imports": ["/assets/index-thGVuYbY.js", "/assets/workflow-graph-viewer-Cg3Lr_h8.js", "/assets/mermaid-3ZIDBTTL-DG0Grjgm.js", "/assets/arrow-up-right-XpJjI06G.js"], "css": ["/assets/run-detail-CWoGxu_0.css", "/assets/workflow-graph-viewer-DnlNuQQH.css", "/assets/mermaid-3ZIDBTTL-D8CjRQta.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/api.rpc": { "id": "routes/api.rpc", "parentId": "root", "path": "api/rpc", "index": void 0, "caseSensitive": void 0, "hasAction": true, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": false, "hasErrorBoundary": false, "module": "/assets/api.rpc-l0sNRNKZ.js", "imports": [], "css": [], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/api.stream.$streamId": { "id": "routes/api.stream.$streamId", "parentId": "root", "path": "api/stream/:streamId", "index": void 0, "caseSensitive": void 0, "hasAction": false, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": false, "hasErrorBoundary": false, "module": "/assets/api.stream._streamId-l0sNRNKZ.js", "imports": [], "css": [], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 } }, "url": "/assets/manifest-3ffb4984.js", "version": "3ffb4984", "sri": void 0 };
|
|
169134
169759
|
const assetsBuildDirectory = "build/client";
|
|
169135
169760
|
const basename = "/";
|
|
169136
169761
|
const future = { "unstable_optimizeDeps": false, "unstable_subResourceIntegrity": false, "unstable_trailingSlashAwareDataRequests": false, "unstable_previewServerPrerendering": false, "v8_middleware": false, "v8_splitRouteModules": false, "v8_viteEnvironmentApi": false };
|
|
@@ -169339,7 +169964,7 @@ function createFetchHandler(basename2 = "/") {
|
|
|
169339
169964
|
return (request2) => handler(request2, loadContext);
|
|
169340
169965
|
}
|
|
169341
169966
|
export {
|
|
169342
|
-
|
|
169967
|
+
RETENTION_ZERO as $,
|
|
169343
169968
|
ANALYTICS_EVENTS_GET_MANY_LIMIT as A,
|
|
169344
169969
|
BULK_CANCEL_MAX_RUN_IDS as B,
|
|
169345
169970
|
CHILD_ENTITY_CREATION_EVENT_TYPES as C,
|
|
@@ -169352,121 +169977,124 @@ export {
|
|
|
169352
169977
|
HOOK_RESUME_DEDUP_VERSION as J,
|
|
169353
169978
|
HOOK_RESUME_INPUT_VERSION as K,
|
|
169354
169979
|
HealthCheckPayloadSchema as L,
|
|
169355
|
-
|
|
169980
|
+
HookClaimedFromSchema as M,
|
|
169356
169981
|
Nt as N,
|
|
169357
|
-
|
|
169358
|
-
|
|
169359
|
-
|
|
169360
|
-
|
|
169361
|
-
|
|
169362
|
-
|
|
169363
|
-
|
|
169364
|
-
|
|
169365
|
-
|
|
169366
|
-
|
|
169367
|
-
|
|
169368
|
-
|
|
169369
|
-
|
|
169982
|
+
HookCreatedEventSchema as O,
|
|
169983
|
+
HookResumeCapabilitiesSchema as P,
|
|
169984
|
+
LegacySerializedDataSchemaV1 as Q,
|
|
169985
|
+
MessageId as R,
|
|
169986
|
+
NODE_HTTP_DEFAULT as S,
|
|
169987
|
+
NODE_HTTP_ENV_VAR as T,
|
|
169988
|
+
PARENT_RUN_ID_ATTRIBUTE as U,
|
|
169989
|
+
PaginatedResponseSchema as V,
|
|
169990
|
+
QueuePayloadSchema as W,
|
|
169991
|
+
QueuePrefix as X,
|
|
169992
|
+
RESERVED_ATTRIBUTE_KEY_PREFIX as Y,
|
|
169993
|
+
RETENTION_ATTRIBUTE as Z,
|
|
169994
|
+
RETENTION_DEFAULT as _,
|
|
169370
169995
|
ANALYTICS_MAX_ATTRIBUTE_FILTERS as a,
|
|
169371
|
-
|
|
169372
|
-
|
|
169373
|
-
|
|
169374
|
-
|
|
169375
|
-
|
|
169376
|
-
|
|
169377
|
-
|
|
169378
|
-
|
|
169379
|
-
|
|
169380
|
-
|
|
169381
|
-
|
|
169382
|
-
|
|
169383
|
-
|
|
169384
|
-
|
|
169385
|
-
|
|
169386
|
-
|
|
169387
|
-
|
|
169388
|
-
|
|
169389
|
-
|
|
169390
|
-
|
|
169391
|
-
|
|
169392
|
-
|
|
169393
|
-
|
|
169394
|
-
|
|
169395
|
-
|
|
169396
|
-
|
|
169397
|
-
|
|
169398
|
-
|
|
169399
|
-
|
|
169400
|
-
|
|
169401
|
-
|
|
169402
|
-
|
|
169403
|
-
|
|
169404
|
-
|
|
169405
|
-
|
|
169406
|
-
|
|
169407
|
-
|
|
169408
|
-
|
|
169409
|
-
|
|
169410
|
-
|
|
169411
|
-
|
|
169412
|
-
|
|
169413
|
-
|
|
169414
|
-
|
|
169415
|
-
|
|
169416
|
-
|
|
169417
|
-
|
|
169418
|
-
|
|
169419
|
-
|
|
169420
|
-
|
|
169421
|
-
|
|
169422
|
-
|
|
169423
|
-
|
|
169424
|
-
|
|
169425
|
-
|
|
169426
|
-
|
|
169427
|
-
|
|
169428
|
-
|
|
169429
|
-
|
|
169430
|
-
|
|
169431
|
-
|
|
169432
|
-
|
|
169433
|
-
|
|
169434
|
-
|
|
169996
|
+
reenqueueActiveRuns as a$,
|
|
169997
|
+
ROOT_RUN_ID_ATTRIBUTE as a0,
|
|
169998
|
+
RUN_ENTITY_KEY as a1,
|
|
169999
|
+
RunInputSchema as a2,
|
|
170000
|
+
SEALED_LOG_ENV_VAR as a3,
|
|
170001
|
+
SPEC_VERSION_CURRENT as a4,
|
|
170002
|
+
SPEC_VERSION_LEGACY as a5,
|
|
170003
|
+
SPEC_VERSION_MAX_SUPPORTED as a6,
|
|
170004
|
+
SPEC_VERSION_SUPPORTS_ATTRIBUTES as a7,
|
|
170005
|
+
SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT as a8,
|
|
170006
|
+
SPEC_VERSION_SUPPORTS_COMPRESSION as a9,
|
|
170007
|
+
entityEventClass as aA,
|
|
170008
|
+
entityResolveData as aB,
|
|
170009
|
+
envFlag as aC,
|
|
170010
|
+
envNumber as aD,
|
|
170011
|
+
eventIdToSlot as aE,
|
|
170012
|
+
getEventDataPayloadField as aF,
|
|
170013
|
+
getEventDataRefFields as aG,
|
|
170014
|
+
getMaxEventsPerRun as aH,
|
|
170015
|
+
getQueueTopicPrefix as aI,
|
|
170016
|
+
isChildEntityCreationEvent as aJ,
|
|
170017
|
+
isChildEntityCreationEventType as aK,
|
|
170018
|
+
isHookEventRequiringExistence as aL,
|
|
170019
|
+
isHookLifecycleEventType as aM,
|
|
170020
|
+
isLegacySpecVersion as aN,
|
|
170021
|
+
isNodeHttpEnabled as aO,
|
|
170022
|
+
isSealedNoopEvent$1 as aP,
|
|
170023
|
+
isSlotBody as aQ,
|
|
170024
|
+
isSlotEventId as aR,
|
|
170025
|
+
isStepEventType as aS,
|
|
170026
|
+
isTerminalRunEventType as aT,
|
|
170027
|
+
isTerminalStepEventType as aU,
|
|
170028
|
+
isTerminalStepStatus as aV,
|
|
170029
|
+
isTerminalWorkflowRunStatus as aW,
|
|
170030
|
+
isWaitEventType as aX,
|
|
170031
|
+
mintedSpecVersion as aY,
|
|
170032
|
+
parseQueueName as aZ,
|
|
170033
|
+
readRunRetention as a_,
|
|
170034
|
+
SPEC_VERSION_SUPPORTS_EVENT_SOURCING as aa,
|
|
170035
|
+
SPEC_VERSION_SUPPORTS_HOOK_FORCE_CLAIM as ab,
|
|
170036
|
+
SPEC_VERSION_SUPPORTS_SLOT_IDENTITY as ac,
|
|
170037
|
+
STEP_EVENT_TYPES as ad,
|
|
170038
|
+
SerializedDataSchema as ae,
|
|
170039
|
+
StepSchema as af,
|
|
170040
|
+
StepStatusSchema as ag,
|
|
170041
|
+
StructuredErrorSchema as ah,
|
|
170042
|
+
TERMINAL_EVENT_CLASSES as ai,
|
|
170043
|
+
TERMINAL_RUN_EVENT_TYPES as aj,
|
|
170044
|
+
TERMINAL_STEP_EVENT_TYPES as ak,
|
|
170045
|
+
TERMINAL_STEP_STATUSES as al,
|
|
170046
|
+
TERMINAL_WORKFLOW_RUN_STATUSES as am,
|
|
170047
|
+
TerminalRunEventTypeSchema as an,
|
|
170048
|
+
TerminalStepStatusSchema as ao,
|
|
170049
|
+
TerminalWorkflowRunStatusSchema as ap,
|
|
170050
|
+
ValidQueueName as aq,
|
|
170051
|
+
WAIT_EVENT_TYPES as ar,
|
|
170052
|
+
WaitSchema as as,
|
|
170053
|
+
WaitStatusSchema as at,
|
|
170054
|
+
WorkflowInvokePayloadSchema as au,
|
|
170055
|
+
WorkflowRunBaseSchema as av,
|
|
170056
|
+
WorkflowRunSchema as aw,
|
|
170057
|
+
WorkflowRunStatusSchema as ax,
|
|
170058
|
+
applyAttributeChanges as ay,
|
|
170059
|
+
classifyEntityEvent as az,
|
|
169435
170060
|
ANALYTICS_PAGE_LIMIT as b,
|
|
169436
|
-
|
|
169437
|
-
|
|
169438
|
-
|
|
169439
|
-
|
|
169440
|
-
|
|
169441
|
-
|
|
169442
|
-
|
|
169443
|
-
|
|
169444
|
-
|
|
169445
|
-
|
|
169446
|
-
|
|
169447
|
-
|
|
169448
|
-
|
|
169449
|
-
|
|
169450
|
-
|
|
169451
|
-
|
|
169452
|
-
|
|
169453
|
-
|
|
169454
|
-
|
|
169455
|
-
|
|
169456
|
-
|
|
169457
|
-
|
|
169458
|
-
|
|
169459
|
-
|
|
169460
|
-
|
|
169461
|
-
|
|
169462
|
-
|
|
169463
|
-
|
|
169464
|
-
|
|
169465
|
-
|
|
169466
|
-
|
|
169467
|
-
|
|
169468
|
-
|
|
169469
|
-
|
|
170061
|
+
requiresNewerWorld as b0,
|
|
170062
|
+
resolveQueueNamespace as b1,
|
|
170063
|
+
slotToEventId as b2,
|
|
170064
|
+
stripEventDataRefs as b3,
|
|
170065
|
+
ulidToDate as b4,
|
|
170066
|
+
validateAttributeChanges as b5,
|
|
170067
|
+
validateAttributeEventDataSize as b6,
|
|
170068
|
+
validateUlidTimestamp as b7,
|
|
170069
|
+
workflowRunIdSchema as b8,
|
|
170070
|
+
reactExports as b9,
|
|
170071
|
+
createFetchHandler as bA,
|
|
170072
|
+
R as ba,
|
|
170073
|
+
Ks as bb,
|
|
170074
|
+
jsxRuntimeExports as bc,
|
|
170075
|
+
Qe as bd,
|
|
170076
|
+
registerZstdDecoder as be,
|
|
170077
|
+
isWsEventsTransportEnabled as bf,
|
|
170078
|
+
debugLog as bg,
|
|
170079
|
+
getHttpUrl as bh,
|
|
170080
|
+
globalSingleton as bi,
|
|
170081
|
+
version as bj,
|
|
170082
|
+
getHttpConfig as bk,
|
|
170083
|
+
headersToRecord as bl,
|
|
170084
|
+
getRequestTimeoutMs as bm,
|
|
170085
|
+
injectTraceContextIntoHeaders as bn,
|
|
170086
|
+
withHttpClientSpan as bo,
|
|
170087
|
+
ErrorType as bp,
|
|
170088
|
+
WorkflowWsReconnectAttempt as bq,
|
|
170089
|
+
NetworkProtocolName as br,
|
|
170090
|
+
WorkflowEventsTransport as bs,
|
|
170091
|
+
distExports as bt,
|
|
170092
|
+
decodeFrames as bu,
|
|
170093
|
+
getDefaultExportFromCjs as bv,
|
|
170094
|
+
requireTokenUtil as bw,
|
|
170095
|
+
requireTokenError as bx,
|
|
170096
|
+
getAugmentedNamespace as by,
|
|
170097
|
+
app as bz,
|
|
169470
170098
|
ANALYTICS_RUN_SCOPED_PAGE_LIMIT as c,
|
|
169471
170099
|
ATTRIBUTE_EVENT_DATA_MAX_BYTES as d,
|
|
169472
170100
|
ATTRIBUTE_KEY_MAX_LENGTH as e,
|