@workflow/web 5.0.0-beta.55 → 5.0.0-beta.56

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.
Files changed (23) hide show
  1. package/build/client/assets/{arrow-up-right-Cbiblmqd.js → arrow-up-right-XpJjI06G.js} +1 -1
  2. package/build/client/assets/{highlighted-body-B3W2YXNL-DwU_jOoN.js → highlighted-body-B3W2YXNL-DA3N01jE.js} +1 -1
  3. package/build/client/assets/{home-5LIuLkPD.js → home-CLktiGIz.js} +3 -3
  4. package/build/client/assets/{loader-circle-DUHA29mm.js → loader-circle-Cj8CH5bR.js} +1 -1
  5. package/build/client/assets/{manifest-4d592c52.js → manifest-3ffb4984.js} +1 -1
  6. package/build/client/assets/{mermaid-3ZIDBTTL-NvETcKWB.js → mermaid-3ZIDBTTL-DG0Grjgm.js} +103 -7
  7. package/build/client/assets/{root-DBWIyKUW.js → root-3gE7cfR2.js} +3 -3
  8. package/build/client/assets/{run-detail-CBJBkl4-.js → run-detail-gOfjBB1S.js} +10 -3
  9. package/build/client/assets/{workflow-graph-viewer-B-jkpIk_.js → workflow-graph-viewer-Cg3Lr_h8.js} +1 -1
  10. package/build/client/assets/{zstd-browser-decoder-D3uoHeUt.js → zstd-browser-decoder-CEJ92wdJ.js} +1 -1
  11. package/build/server/assets/{app-BXpsg52W.js → app-Bl4MnK_A.js} +801 -348
  12. package/build/server/assets/{highlighted-body-B3W2YXNL-gkJfOpdp.js → highlighted-body-B3W2YXNL-DEO_Ibma.js} +1 -1
  13. package/build/server/assets/{index-BkN7taof.js → index-B_qUqg3k.js} +1 -1
  14. package/build/server/assets/{index-CPJXhpRN.js → index-bN9Oj_dl.js} +88 -87
  15. package/build/server/assets/{mermaid-3ZIDBTTL-CPNY3RZj.js → mermaid-3ZIDBTTL-Dr7Wk8Bh.js} +1 -1
  16. package/build/server/assets/{token-TJVjFtpm.js → token-CUWJi08Y.js} +1 -1
  17. package/build/server/assets/{token-util-BMcpB3Iq.js → token-util-B4OMKRZB.js} +1 -1
  18. package/build/server/assets/{websocket-server-CTiYInap.js → websocket-server-FV9R_mnP.js} +1 -1
  19. package/build/server/assets/{wrapper-DG37QKjD.js → wrapper-Cs9Wzu7M.js} +3 -3
  20. package/build/server/assets/{ws-transport-ClaOEQbG.js → ws-transport-B4h16CAX.js} +2 -2
  21. package/build/server/assets/{zstd-browser-decoder-BgChmidM.js → zstd-browser-decoder-DSPBib47.js} +1 -1
  22. package/build/server/index.js +3 -3
  23. package/package.json +7 -7
@@ -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;
@@ -48947,13 +49000,13 @@ const SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT = 3;
48947
49000
  const SPEC_VERSION_SUPPORTS_ATTRIBUTES = 4;
48948
49001
  const SPEC_VERSION_SUPPORTS_COMPRESSION = 5;
48949
49002
  const SPEC_VERSION_SUPPORTS_SLOT_IDENTITY = 6;
48950
- const SPEC_VERSION_SUPPORTS_SEALED_LOG = 7;
48951
- const SPEC_VERSION_CURRENT = SPEC_VERSION_SUPPORTS_SEALED_LOG;
49003
+ const SPEC_VERSION_SUPPORTS_HOOK_FORCE_CLAIM = 8;
49004
+ const SPEC_VERSION_CURRENT = SPEC_VERSION_SUPPORTS_HOOK_FORCE_CLAIM;
48952
49005
  const SEALED_LOG_ENV_VAR = "WORKFLOW_SEALED_LOG";
48953
49006
  function mintedSpecVersion(env2 = process.env) {
48954
49007
  return envFlag(SEALED_LOG_ENV_VAR, true, env2) ? SPEC_VERSION_CURRENT : SPEC_VERSION_SUPPORTS_SLOT_IDENTITY;
48955
49008
  }
48956
- const SPEC_VERSION_MAX_SUPPORTED = SPEC_VERSION_SUPPORTS_SEALED_LOG;
49009
+ const SPEC_VERSION_MAX_SUPPORTED = SPEC_VERSION_SUPPORTS_HOOK_FORCE_CLAIM;
48957
49010
  function isLegacySpecVersion(v2) {
48958
49011
  return v2 === void 0 || v2 === null || v2 <= SPEC_VERSION_LEGACY;
48959
49012
  }
@@ -53383,6 +53436,7 @@ const ERROR_SLUGS = {
53383
53436
  WEBHOOK_INVALID_RESPOND_WITH_VALUE: "webhook-invalid-respond-with-value",
53384
53437
  WEBHOOK_RESPONSE_NOT_SENT: "webhook-response-not-sent",
53385
53438
  HOOK_CONFLICT: "hook-conflict",
53439
+ HOOK_FORCE_CLAIMED: "hook-force-claimed",
53386
53440
  CORRUPTED_EVENT_LOG: "corrupted-event-log",
53387
53441
  RUNTIME_DECRYPTION_FAILED: "runtime-decryption-failed"
53388
53442
  };
@@ -53554,6 +53608,25 @@ class HookConflictError extends WorkflowError {
53554
53608
  return isError(value) && value.name === "HookConflictError";
53555
53609
  }
53556
53610
  }
53611
+ class HookForceClaimedError extends WorkflowError {
53612
+ constructor(token, claimedByRunId, claimedByHookId) {
53613
+ super(`Hook token "${token}" was force-claimed by another workflow (run "${claimedByRunId}")`, { slug: ERROR_SLUGS.HOOK_FORCE_CLAIMED });
53614
+ __publicField(this, "token");
53615
+ /** The run that took the token. */
53616
+ __publicField(this, "claimedByRunId");
53617
+ /** The hook (in `claimedByRunId`) the token now belongs to. */
53618
+ __publicField(this, "claimedByHookId");
53619
+ this.name = "HookForceClaimedError";
53620
+ this.token = token;
53621
+ this.claimedByRunId = claimedByRunId;
53622
+ if (claimedByHookId !== void 0) {
53623
+ this.claimedByHookId = claimedByHookId;
53624
+ }
53625
+ }
53626
+ static is(value) {
53627
+ return isError(value) && value.name === "HookForceClaimedError";
53628
+ }
53629
+ }
53557
53630
  class HookNotFoundError extends WorkflowError {
53558
53631
  constructor(token) {
53559
53632
  super("Hook not found", {});
@@ -53709,6 +53782,7 @@ const VERCEL_403_ERROR_MESSAGE = "Your current vercel account does not have acce
53709
53782
  const FATAL_ERROR_KEY = Symbol.for("@workflow/errors//FatalError");
53710
53783
  const RETRYABLE_ERROR_KEY = Symbol.for("@workflow/errors//RetryableError");
53711
53784
  const HOOK_CONFLICT_ERROR_KEY = Symbol.for("@workflow/errors//HookConflictError");
53785
+ const HOOK_FORCE_CLAIMED_ERROR_KEY = Symbol.for("@workflow/errors//HookForceClaimedError");
53712
53786
  const RUNTIME_DECRYPTION_ERROR_KEY = Symbol.for("@workflow/errors//RuntimeDecryptionError");
53713
53787
  const STREAM_ERROR_KEY = Symbol.for("@workflow/errors//StreamError");
53714
53788
  if (typeof globalThis !== "undefined") {
@@ -53736,6 +53810,14 @@ if (typeof globalThis !== "undefined") {
53736
53810
  configurable: false
53737
53811
  });
53738
53812
  }
53813
+ if (!Object.hasOwn(globalThis, HOOK_FORCE_CLAIMED_ERROR_KEY)) {
53814
+ Object.defineProperty(globalThis, HOOK_FORCE_CLAIMED_ERROR_KEY, {
53815
+ value: HookForceClaimedError,
53816
+ writable: false,
53817
+ enumerable: false,
53818
+ configurable: false
53819
+ });
53820
+ }
53739
53821
  if (!Object.hasOwn(globalThis, RUNTIME_DECRYPTION_ERROR_KEY)) {
53740
53822
  Object.defineProperty(globalThis, RUNTIME_DECRYPTION_ERROR_KEY, {
53741
53823
  value: RuntimeDecryptionError,
@@ -54753,6 +54835,7 @@ function getWebRevivers() {
54753
54835
  // `packages/core/src/serialization/reducers/common.ts`) emits a tagged
54754
54836
  // entry for each built-in Error subclass plus the workflow-specific
54755
54837
  // `FatalError` / `RetryableError` / `HookConflictError` /
54838
+ // `HookForceClaimedError` /
54756
54839
  // `RuntimeDecryptionError` and `AggregateError`. Without
54757
54840
  // matching revivers here, `devalue.unflatten` throws "Unknown type X",
54758
54841
  // which surfaces in the web o11y UI as "Failed to load resource
@@ -54811,6 +54894,19 @@ function getWebRevivers() {
54811
54894
  error2.stack = value.stack;
54812
54895
  return error2;
54813
54896
  },
54897
+ HookForceClaimedError: (value) => {
54898
+ const opts = "cause" in value ? { cause: value.cause } : void 0;
54899
+ const error2 = new Error(value.message, opts);
54900
+ error2.name = "HookForceClaimedError";
54901
+ error2.token = value.token;
54902
+ error2.claimedByRunId = value.claimedByRunId;
54903
+ if (value.claimedByHookId !== void 0) {
54904
+ error2.claimedByHookId = value.claimedByHookId;
54905
+ }
54906
+ if (value.stack !== void 0)
54907
+ error2.stack = value.stack;
54908
+ return error2;
54909
+ },
54814
54910
  RetryableError: (value) => {
54815
54911
  const opts = "cause" in value ? { cause: value.cause } : void 0;
54816
54912
  const error2 = new Error(value.message, opts);
@@ -54995,7 +55091,7 @@ function replaceEncryptedAndExpiredWithMarkers(resource) {
54995
55091
  }
54996
55092
  async function hydrateResourceIOAsync(resource, key) {
54997
55093
  const { hydrateDataWithKey: hydrateDataWithKey2, deriveRunPayloadKeys: deriveRunPayloadKeys2 } = await Promise.resolve().then(() => serializationFormat);
54998
- const { ensureZstdDecoderRegistered } = await import("./zstd-browser-decoder-BgChmidM.js");
55094
+ const { ensureZstdDecoderRegistered } = await import("./zstd-browser-decoder-DSPBib47.js");
54999
55095
  ensureZstdDecoderRegistered();
55000
55096
  const cryptoKey = key ? await deriveRunPayloadKeys2(key) : void 0;
55001
55097
  const revivers = getRevivers();
@@ -85939,7 +86035,7 @@ var tn = f("block", "before:content-[counter(line)]", "before:inline-block", "be
85939
86035
  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
86036
  var Se = reactExports.createContext({ code: "" }), de = () => reactExports.useContext(Se);
85941
86037
  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-gkJfOpdp.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
86038
+ var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-DEO_Ibma.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
85943
86039
  let i = reactExports.useMemo(() => e.replace(cn$1, ""), [e]), c = reactExports.useMemo(() => ({ bg: "transparent", fg: "inherit", tokens: i.split(`
85944
86040
  `).map((a2) => [{ content: a2, color: "inherit", bgColor: "transparent", htmlStyle: {}, offset: 0 }]) }), [i]);
85945
86041
  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 +86357,7 @@ var Dt = ({ children: e, className: t, onDownload: o, onError: n }) => {
86261
86357
  }, []), 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
86358
  };
86263
86359
  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-CPNY3RZj.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
86360
+ var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-Dr7Wk8Bh.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
86265
86361
  function ke(e, t) {
86266
86362
  if (!(e != null && e.position || t != null && t.position)) return true;
86267
86363
  if (!(e != null && e.position && (t != null && t.position))) return false;
@@ -89084,6 +89180,7 @@ const attributeOrder = [
89084
89180
  "attempt",
89085
89181
  "token",
89086
89182
  "tokenRetentionUntil",
89183
+ "claimedFrom",
89087
89184
  "isWebhook",
89088
89185
  "isSystem",
89089
89186
  "receivedCount",
@@ -89132,6 +89229,7 @@ const attributeDisplayNames = {
89132
89229
  runId: "Run ID",
89133
89230
  token: "Token",
89134
89231
  tokenRetentionUntil: "Minimum Retention Until",
89232
+ claimedFrom: "Token Taken From Run",
89135
89233
  eventType: "Event Type",
89136
89234
  errorCode: "Error Code",
89137
89235
  correlationId: "Correlation ID",
@@ -89211,6 +89309,11 @@ const attributeToDisplayFn = {
89211
89309
  // Hook details
89212
89310
  token: (value) => String(value),
89213
89311
  tokenRetentionUntil: timestampWithTooltipOrNull,
89312
+ // A force-claimed hook (`experimental_force`): the run whose token it took.
89313
+ claimedFrom: (value) => {
89314
+ const from = value;
89315
+ return typeof (from == null ? void 0 : from.runId) === "string" ? from.runId : null;
89316
+ },
89214
89317
  isWebhook: (value) => String(value),
89215
89318
  isSystem: (value) => String(value),
89216
89319
  receivedCount: (value) => String(value),
@@ -96166,6 +96269,21 @@ function getCommonReducers(_global = globalThis) {
96166
96269
  }
96167
96270
  return reduced;
96168
96271
  },
96272
+ HookForceClaimedError: (value) => {
96273
+ const base = reduceNamedErrorSubclassBase("HookForceClaimedError", value);
96274
+ if (!base)
96275
+ return false;
96276
+ const reduced = {
96277
+ ...base,
96278
+ token: readProperty(value, "token"),
96279
+ claimedByRunId: readProperty(value, "claimedByRunId")
96280
+ };
96281
+ const claimedByHookId = readProperty(value, "claimedByHookId");
96282
+ if (claimedByHookId !== void 0) {
96283
+ reduced.claimedByHookId = claimedByHookId;
96284
+ }
96285
+ return reduced;
96286
+ },
96169
96287
  RangeError: makeErrorSubclassReducer("RangeError"),
96170
96288
  ReferenceError: makeErrorSubclassReducer("ReferenceError"),
96171
96289
  // RetryableError carries an extra `retryAfter` Date that we serialize as
@@ -96350,6 +96468,16 @@ function getCommonRevivers$1(global2 = globalThis) {
96350
96468
  }
96351
96469
  return error2;
96352
96470
  },
96471
+ HookForceClaimedError: (value) => {
96472
+ const Ctor = global2[Symbol.for("@workflow/errors//HookForceClaimedError")] ?? HookForceClaimedError;
96473
+ const error2 = new Ctor(value.token, value.claimedByRunId, value.claimedByHookId);
96474
+ if (value.stack !== void 0)
96475
+ error2.stack = value.stack;
96476
+ if ("cause" in value) {
96477
+ error2.cause = value.cause;
96478
+ }
96479
+ return error2;
96480
+ },
96353
96481
  RangeError: makeErrorSubclassReviver(global2, "RangeError"),
96354
96482
  ReferenceError: makeErrorSubclassReviver(global2, "ReferenceError"),
96355
96483
  RetryableError: (value) => {
@@ -98798,7 +98926,7 @@ globalSingleton("@workflow/core//envWarnings", 1, () => ({
98798
98926
  maxInlineStepsValues: /* @__PURE__ */ new Set(),
98799
98927
  maxEventsValues: /* @__PURE__ */ new Set()
98800
98928
  }));
98801
- const version$1 = "5.0.0-beta.55";
98929
+ const version$1 = "5.0.0-beta.56";
98802
98930
  const DEFAULT_HEALTH_CHECK_TIMEOUT = 3e4;
98803
98931
  const SAFE_WORKFLOW_NAME_PATTERN = /^[a-zA-Z0-9_\-./@()[\]]+$/;
98804
98932
  function getWorkflowQueueName(workflowName, namespace2) {
@@ -100968,7 +101096,7 @@ function getWorkflowVmFromEnv(env2 = process.env) {
100968
101096
  throw new WorkflowRuntimeError(`Invalid WORKFLOW_VM value: "${raw2}". Expected one of: ${WORKFLOW_VMS.join(", ")}.`);
100969
101097
  }
100970
101098
  function waitUntil(promise2) {
100971
- void import("./index-BkN7taof.js").then((n) => n.i).then(({ waitUntil: waitUntil2 }) => {
101099
+ void import("./index-B_qUqg3k.js").then((n) => n.i).then(({ waitUntil: waitUntil2 }) => {
100972
101100
  waitUntil2(promise2);
100973
101101
  });
100974
101102
  }
@@ -131031,6 +131159,35 @@ function hookDisposeLockPath(basedir, hookId, tag) {
131031
131159
  const name2 = tag ? `${hookId}.disposed.${tag}` : `${hookId}.disposed`;
131032
131160
  return resolveWithinBase(basedir, ".locks", "hooks", name2);
131033
131161
  }
131162
+ async function readHookDisposeLock(basedir, hookId, tag) {
131163
+ const candidates = [hookDisposeLockPath(basedir, hookId)];
131164
+ if (tag) {
131165
+ candidates.push(hookDisposeLockPath(basedir, hookId, tag));
131166
+ }
131167
+ for (const lockPath of candidates) {
131168
+ let content2;
131169
+ try {
131170
+ content2 = await fs$1.readFile(lockPath, "utf8");
131171
+ } catch {
131172
+ continue;
131173
+ }
131174
+ if (content2.trim() === "")
131175
+ return { committed: true };
131176
+ try {
131177
+ const parsed = JSON.parse(content2);
131178
+ const by = parsed.forceClaimedBy;
131179
+ if (by && typeof by.runId === "string" && typeof by.hookId === "string") {
131180
+ return {
131181
+ committed: true,
131182
+ forceClaimedBy: { runId: by.runId, hookId: by.hookId }
131183
+ };
131184
+ }
131185
+ } catch {
131186
+ }
131187
+ return { committed: true };
131188
+ }
131189
+ return { committed: false };
131190
+ }
131034
131191
  async function isHookDisposalCommitted(basedir, hookId, tag) {
131035
131192
  const candidates = [hookDisposeLockPath(basedir, hookId)];
131036
131193
  if (tag) {
@@ -131164,7 +131321,17 @@ const HookTokenClaimSchema = compile(object$1({
131164
131321
  // Legacy claims also omitted eventId. Their recovery marker pins the
131165
131322
  // canonical hook_created event before concurrent retries publish it.
131166
131323
  eventId: string$2().optional(),
131167
- tokenRetentionUntil: date$2().optional()
131324
+ tokenRetentionUntil: date$2().optional(),
131325
+ // Set when this claim took the token from another run
131326
+ // (`experimental_force`), so a retry that adopts the claim can still
131327
+ // report — and wake — the run it came from.
131328
+ claimedFrom: object$1({
131329
+ runId: string$2(),
131330
+ hookId: string$2(),
131331
+ workflowName: string$2().optional(),
131332
+ deploymentId: string$2().optional(),
131333
+ runSpecVersion: number$3().optional()
131334
+ }).optional()
131168
131335
  }));
131169
131336
  async function readHookTokenClaim(claimPath) {
131170
131337
  try {
@@ -131302,7 +131469,7 @@ async function writeHookCreatedIndexEntries(basedir, token, runId, hookId, event
131302
131469
  assertSafeEntityId("eventId", eventId);
131303
131470
  if (tag !== void 0)
131304
131471
  assertSafeEntityId("tag", tag);
131305
- const fileName = tag ? `${eventId}.${tag}.json` : `${eventId}.json`;
131472
+ const fileName = tag ? `${runId}-${eventId}.${tag}.json` : `${runId}-${eventId}.json`;
131306
131473
  const content2 = JSON.stringify({ runId });
131307
131474
  await Promise.all([
131308
131475
  writeExclusive(path$3.join(tokenIndexDir(basedir, token), fileName), content2),
@@ -131411,7 +131578,7 @@ async function ensureHookIndexesImpl(basedir) {
131411
131578
  });
131412
131579
  await writeExclusive(markerPath, "");
131413
131580
  }
131414
- async function findNewestIndexedHookCreatedEvent(basedir, index2, matches, tag) {
131581
+ async function findIndexedHookCreatedEvent(basedir, index2, accept, tag) {
131415
131582
  await ensureHookIndexes(basedir);
131416
131583
  let dir;
131417
131584
  try {
@@ -131419,6 +131586,10 @@ async function findNewestIndexedHookCreatedEvent(basedir, index2, matches, tag)
131419
131586
  } catch {
131420
131587
  return null;
131421
131588
  }
131589
+ const eventIdOf = (entryId, runId) => {
131590
+ const stripped = stripTag(entryId);
131591
+ return stripped.startsWith(`${runId}-`) ? stripped.slice(runId.length + 1) : stripped;
131592
+ };
131422
131593
  const entryIds = (await listJSONFiles(dir)).filter((fileId) => isVisibleToTag(fileId, tag)).sort((a2, b2) => stripTag(b2).localeCompare(stripTag(a2)));
131423
131594
  for (const entryId of entryIds) {
131424
131595
  let entry2 = null;
@@ -131431,7 +131602,7 @@ async function findNewestIndexedHookCreatedEvent(basedir, index2, matches, tag)
131431
131602
  }
131432
131603
  if (!entry2)
131433
131604
  continue;
131434
- const eventId = stripTag(entryId);
131605
+ const eventId = eventIdOf(entryId, entry2.runId);
131435
131606
  let eventPath;
131436
131607
  try {
131437
131608
  eventPath = taggedPath(basedir, "events", `${entry2.runId}-${eventId}`, tagOf(entryId));
@@ -131445,7 +131616,7 @@ async function findNewestIndexedHookCreatedEvent(basedir, index2, matches, tag)
131445
131616
  continue;
131446
131617
  if (typeof event.correlationId !== "string")
131447
131618
  continue;
131448
- if (!matches(event))
131619
+ if (!await accept(event))
131449
131620
  continue;
131450
131621
  return event;
131451
131622
  }
@@ -131485,11 +131656,14 @@ function getHookCreatedToken(event) {
131485
131656
  return typeof token === "string" ? token : void 0;
131486
131657
  }
131487
131658
  function hookFromCreatedEvent(event) {
131488
- const { token, metadata, isWebhook, isSystem, tokenRetentionUntil } = event.eventData;
131659
+ const { token, metadata, isWebhook, isSystem, tokenRetentionUntil, forceClaimedFrom } = event.eventData;
131489
131660
  return {
131490
131661
  runId: event.runId,
131491
131662
  hookId: event.correlationId,
131492
131663
  token,
131664
+ // The journaled row is the durable record of a takeover; a rebuilt
131665
+ // entity must say where its token came from just as the original did.
131666
+ ...forceClaimedFrom !== void 0 && { claimedFrom: forceClaimedFrom },
131493
131667
  metadata,
131494
131668
  ownerId: "local-owner",
131495
131669
  projectId: "local-project",
@@ -131509,20 +131683,17 @@ async function isTerminalRunCache(basedir, runId, tag) {
131509
131683
  return run2 ? isTerminalWorkflowRunStatus(run2.status) : false;
131510
131684
  }
131511
131685
  async function findAvailableHookCreatedEvent(basedir, index2, matches, tag) {
131512
- const newest = await findNewestIndexedHookCreatedEvent(basedir, index2, (event) => isMatchingHookCreatedEvent(event, matches), tag);
131513
- if (!newest || !isMatchingHookCreatedEvent(newest, matches)) {
131514
- return null;
131515
- }
131516
- if (await isTerminalRunCache(basedir, newest.runId, tag)) {
131517
- const retainedUntil = newest.eventData.tokenRetentionUntil;
131518
- if (!retainedUntil || retainedUntil.getTime() <= Date.now()) {
131519
- return null;
131686
+ const isLive = async (event) => {
131687
+ if (await isTerminalRunCache(basedir, event.runId, tag)) {
131688
+ const retainedUntil = event.eventData.tokenRetentionUntil;
131689
+ if (!retainedUntil || retainedUntil.getTime() <= Date.now()) {
131690
+ return false;
131691
+ }
131520
131692
  }
131521
- }
131522
- if (await isHookDisposalCommitted(basedir, newest.correlationId, tag)) {
131523
- return null;
131524
- }
131525
- return newest;
131693
+ return !await isHookDisposalCommitted(basedir, event.correlationId, tag);
131694
+ };
131695
+ const found = await findIndexedHookCreatedEvent(basedir, index2, (event) => isMatchingHookCreatedEvent(event, matches) && isLive(event), tag);
131696
+ return found && isMatchingHookCreatedEvent(found, matches) ? found : null;
131526
131697
  }
131527
131698
  async function restoreHookCachesFromEvent(basedir, event, tag) {
131528
131699
  const hook = hookFromCreatedEvent(event);
@@ -131532,7 +131703,8 @@ async function restoreHookCachesFromEvent(basedir, event, tag) {
131532
131703
  hookId: hook.hookId,
131533
131704
  runId: hook.runId,
131534
131705
  eventId: event.eventId,
131535
- tokenRetentionUntil: event.eventData.tokenRetentionUntil
131706
+ tokenRetentionUntil: event.eventData.tokenRetentionUntil,
131707
+ ...hook.claimedFrom && { claimedFrom: hook.claimedFrom }
131536
131708
  }));
131537
131709
  await writeHookByRunMarker(basedir, hook.runId, hook.hookId, tag);
131538
131710
  await writeExclusive(taggedPath(basedir, "hooks", hook.hookId, tag), JSON.stringify(hook, jsonReplacer, 2));
@@ -131556,36 +131728,52 @@ function createHooksStorage(basedir, tag) {
131556
131728
  }
131557
131729
  return !await isTerminalRunCache(basedir, hook.runId, tag);
131558
131730
  }
131731
+ async function isForceDisposed(hook) {
131732
+ const lock = await readHookDisposeLock(basedir, hook.hookId, tag);
131733
+ return lock.committed && lock.forceClaimedBy !== void 0;
131734
+ }
131559
131735
  async function findHookByToken(token) {
131560
131736
  const claim2 = await readHookTokenClaim(hookTokenClaimPath(basedir, token));
131561
131737
  if (claim2 == null ? void 0 : claim2.hookId) {
131562
131738
  try {
131563
131739
  const hook = await readJSONWithFallback(basedir, "hooks", claim2.hookId, HookSchema, tag);
131564
131740
  if ((hook == null ? void 0 : hook.token) === token) {
131565
- if (!await isHookAvailable(hook)) {
131741
+ if (await isHookAvailable(hook)) {
131742
+ return { ...hook, isWebhook: hook.isWebhook ?? true };
131743
+ }
131744
+ if (!await isForceDisposed(hook)) {
131566
131745
  throw new HookNotFoundError(token);
131567
131746
  }
131568
- return { ...hook, isWebhook: hook.isWebhook ?? true };
131747
+ } else if (hook) {
131748
+ return null;
131569
131749
  }
131570
131750
  } catch (error2) {
131571
131751
  if (!UnsafeEntityIdError.is(error2)) {
131572
131752
  throw error2;
131573
131753
  }
131754
+ return null;
131574
131755
  }
131575
- return null;
131576
131756
  }
131577
131757
  const hooksDir = path$3.join(basedir, "hooks");
131578
131758
  const files = await listJSONFiles(hooksDir);
131759
+ let disposedMatch = false;
131579
131760
  for (const file of files) {
131580
131761
  const hookPath = path$3.join(hooksDir, `${file}.json`);
131581
131762
  const hook = await readJSON(hookPath, HookSchema);
131582
131763
  if ((hook == null ? void 0 : hook.token) === token) {
131583
- if (!await isHookAvailable(hook)) {
131584
- throw new HookNotFoundError(token);
131764
+ if (await isHookAvailable(hook)) {
131765
+ return { ...hook, isWebhook: hook.isWebhook ?? true };
131585
131766
  }
131586
- return { ...hook, isWebhook: hook.isWebhook ?? true };
131767
+ if (await isForceDisposed(hook)) {
131768
+ disposedMatch = true;
131769
+ continue;
131770
+ }
131771
+ throw new HookNotFoundError(token);
131587
131772
  }
131588
131773
  }
131774
+ if (disposedMatch) {
131775
+ throw new HookNotFoundError(token);
131776
+ }
131589
131777
  return null;
131590
131778
  }
131591
131779
  async function get2(hookId, params) {
@@ -132724,6 +132912,15 @@ function createEventsStorage(basedir, tag) {
132724
132912
  current = { ...current, eventId: slotToEventId(next2) };
132725
132913
  }
132726
132914
  }
132915
+ async function refuseDisposedHookDelivery(hookId, token) {
132916
+ const lock = await readHookDisposeLock(basedir, hookId, tag);
132917
+ if (!lock.committed)
132918
+ return;
132919
+ if (lock.forceClaimedBy) {
132920
+ throw new HookForceClaimedError(typeof token === "string" ? token : "", lock.forceClaimedBy.runId, lock.forceClaimedBy.hookId);
132921
+ }
132922
+ throw new HookNotFoundError(hookId);
132923
+ }
132727
132924
  const queryRunEvents = (runId, pagination) => paginatedFileSystemQuery({
132728
132925
  directory: path$3.join(basedir, "events"),
132729
132926
  schema: ReadEventSchema,
@@ -132761,6 +132958,7 @@ function createEventsStorage(basedir, tag) {
132761
132958
  }
132762
132959
  return createImpl();
132763
132960
  async function createImpl() {
132961
+ var _a3, _b2;
132764
132962
  let eventId = "";
132765
132963
  let eventIdPinned = false;
132766
132964
  let resumeClaimRecordedId = null;
@@ -132914,8 +133112,8 @@ function createEventsStorage(basedir, tag) {
132914
133112
  }
132915
133113
  }
132916
133114
  }
132917
- if (data.eventType === "hook_received" && await isHookDisposalCommitted(basedir, data.correlationId, tag)) {
132918
- throw new HookNotFoundError(data.correlationId);
133115
+ if (data.eventType === "hook_received") {
133116
+ await refuseDisposedHookDelivery(data.correlationId, (_a3 = data.eventData) == null ? void 0 : _a3.token);
132919
133117
  }
132920
133118
  const existingHook = await readJSONWithFallback(basedir, "hooks", data.correlationId, HookSchema, tag);
132921
133119
  if (!existingHook) {
@@ -132974,6 +133172,7 @@ function createEventsStorage(basedir, tag) {
132974
133172
  }
132975
133173
  }
132976
133174
  }
133175
+ let prePublishedEvent;
132977
133176
  let event = {
132978
133177
  ...data,
132979
133178
  runId: effectiveRunId,
@@ -133345,12 +133544,14 @@ function createEventsStorage(basedir, tag) {
133345
133544
  ) {
133346
133545
  const hookData = data.eventData;
133347
133546
  const constraintPath = hookTokenClaimPath(basedir, hookData.token);
133348
- const claimContent = JSON.stringify({
133547
+ let claimedFrom;
133548
+ const claimContent = () => JSON.stringify({
133349
133549
  token: hookData.token,
133350
133550
  hookId: data.correlationId,
133351
133551
  runId: effectiveRunId,
133352
133552
  eventId,
133353
- tokenRetentionUntil: hookData.tokenRetentionUntil
133553
+ tokenRetentionUntil: hookData.tokenRetentionUntil,
133554
+ ...claimedFrom && { claimedFrom }
133354
133555
  });
133355
133556
  const claimResult = await withHookTokenClaimLock(basedir, hookData.token, async (signal) => {
133356
133557
  let existingClaim = await readHookTokenClaim(constraintPath);
@@ -133362,26 +133563,114 @@ function createEventsStorage(basedir, tag) {
133362
133563
  }
133363
133564
  if (!existingClaim) {
133364
133565
  signal.throwIfAborted();
133365
- require$$0$4(await writeExclusive(constraintPath, claimContent));
133566
+ require$$0$4(await writeExclusive(constraintPath, claimContent()));
133366
133567
  return { status: "claimed" };
133367
133568
  }
133368
133569
  if (existingClaim.runId === effectiveRunId && existingClaim.hookId === data.correlationId) {
133369
133570
  return { status: "owned", claim: existingClaim };
133370
133571
  }
133371
133572
  if (!await isHookTokenClaimReleasable(basedir, existingClaim, tag)) {
133372
- return { status: "conflict", claim: existingClaim };
133573
+ if (hookData.force !== true || !existingClaim.hookId) {
133574
+ return { status: "conflict", claim: existingClaim };
133575
+ }
133576
+ signal.throwIfAborted();
133577
+ const victimRun = await readJSONWithFallback(basedir, "runs", existingClaim.runId, WorkflowRunSchema, tag);
133578
+ const victimRunning = victimRun !== null && !isTerminalWorkflowRunStatus(victimRun.status);
133579
+ claimedFrom = {
133580
+ runId: existingClaim.runId,
133581
+ hookId: existingClaim.hookId,
133582
+ ...victimRunning && {
133583
+ workflowName: victimRun.workflowName,
133584
+ deploymentId: victimRun.deploymentId,
133585
+ runSpecVersion: victimRun.specVersion
133586
+ }
133587
+ };
133588
+ if (victimRunning && (victimRun.specVersion ?? SPEC_VERSION_LEGACY) < SPEC_VERSION_SUPPORTS_HOOK_FORCE_CLAIM) {
133589
+ return {
133590
+ status: "conflict",
133591
+ claim: existingClaim,
133592
+ forceRefusedReason: "victim-spec-version"
133593
+ };
133594
+ }
133595
+ const journaledEventId = await findExistingHookCreatedEventId(basedir, effectiveRunId, data.correlationId);
133596
+ if (journaledEventId) {
133597
+ eventId = journaledEventId;
133598
+ prePublishedEvent = { ...event, eventId };
133599
+ } else {
133600
+ prePublishedEvent = await storeEvent({
133601
+ ...event,
133602
+ eventData: {
133603
+ ...event.eventData,
133604
+ forceClaimedFrom: claimedFrom
133605
+ }
133606
+ });
133607
+ eventId = prePublishedEvent.eventId;
133608
+ }
133609
+ await writeHookByRunMarker(basedir, effectiveRunId, data.correlationId, tag);
133610
+ await writeJSON(taggedPath(basedir, "hooks", data.correlationId, tag), {
133611
+ runId: effectiveRunId,
133612
+ hookId: data.correlationId,
133613
+ token: hookData.token,
133614
+ metadata: hookData.metadata,
133615
+ ownerId: "local-owner",
133616
+ projectId: "local-project",
133617
+ environment: "local",
133618
+ createdAt: now2,
133619
+ specVersion: effectiveSpecVersion,
133620
+ isWebhook: hookData.isWebhook ?? false,
133621
+ isSystem: hookData.isSystem ?? false,
133622
+ tokenRetentionUntil: hookData.tokenRetentionUntil,
133623
+ claimedFrom
133624
+ }, { overwrite: true });
133625
+ const lockWritten = await writeExclusive(hookDisposeLockPath(basedir, existingClaim.hookId, tag), JSON.stringify({
133626
+ forceClaimedBy: {
133627
+ runId: effectiveRunId,
133628
+ hookId: data.correlationId
133629
+ }
133630
+ }));
133631
+ if (victimRunning) {
133632
+ if (lockWritten) {
133633
+ const disposedEvent = {
133634
+ eventType: "hook_disposed",
133635
+ correlationId: existingClaim.hookId,
133636
+ eventData: {
133637
+ token: hookData.token,
133638
+ forceClaimedBy: {
133639
+ runId: effectiveRunId,
133640
+ hookId: data.correlationId
133641
+ }
133642
+ },
133643
+ runId: existingClaim.runId,
133644
+ eventId: await mintEventId(existingClaim.runId),
133645
+ createdAt: /* @__PURE__ */ new Date(),
133646
+ specVersion: victimRun.specVersion
133647
+ };
133648
+ await storeEvent(disposedEvent);
133649
+ }
133650
+ }
133373
133651
  }
133374
133652
  signal.throwIfAborted();
133375
- await deleteJSON(constraintPath);
133653
+ if (claimedFrom) {
133654
+ await write(constraintPath, claimContent(), {
133655
+ overwrite: true
133656
+ });
133657
+ } else {
133658
+ await deleteJSON(constraintPath);
133659
+ }
133376
133660
  if (existingClaim.hookId) {
133377
133661
  await deleteJSON(taggedPath(basedir, "hooks", existingClaim.hookId, tag));
133378
133662
  await deleteJSON(hookRecoveryMarkerPath(basedir, hookData.token, existingClaim.runId, existingClaim.hookId));
133379
133663
  await deleteHookByRunMarker(basedir, existingClaim.runId, existingClaim.hookId, tag);
133380
133664
  }
133381
133665
  signal.throwIfAborted();
133382
- require$$0$4(await writeExclusive(constraintPath, claimContent));
133666
+ if (!claimedFrom) {
133667
+ require$$0$4(await writeExclusive(constraintPath, claimContent()));
133668
+ }
133383
133669
  return { status: "claimed" };
133384
133670
  });
133671
+ if (claimResult.status === "owned" && claimResult.claim.claimedFrom) {
133672
+ claimedFrom = claimResult.claim.claimedFrom;
133673
+ }
133385
133674
  if (claimResult.status === "owned") {
133386
133675
  const existingClaim = claimResult.claim;
133387
133676
  let canonicalEventId;
@@ -133423,7 +133712,10 @@ function createEventsStorage(basedir, tag) {
133423
133712
  correlationId: data.correlationId,
133424
133713
  eventData: {
133425
133714
  token: hookData.token,
133426
- conflictingRunId: existingClaim.runId
133715
+ conflictingRunId: existingClaim.runId,
133716
+ ...claimResult.forceRefusedReason !== void 0 && {
133717
+ forceRefusedReason: claimResult.forceRefusedReason
133718
+ }
133427
133719
  },
133428
133720
  runId: effectiveRunId,
133429
133721
  eventId,
@@ -133451,6 +133743,18 @@ function createEventsStorage(basedir, tag) {
133451
133743
  hasMore: conflictDelta.hasMore
133452
133744
  };
133453
133745
  }
133746
+ if (claimedFrom) {
133747
+ event = {
133748
+ ...event,
133749
+ eventData: {
133750
+ ...event.eventData,
133751
+ // Wake-targeting fields included: a replay of this run
133752
+ // republishes the victim's wake from this row alone when the
133753
+ // invocation that created the hook died before waking it.
133754
+ forceClaimedFrom: claimedFrom
133755
+ }
133756
+ };
133757
+ }
133454
133758
  const persistedHookData = event.eventData;
133455
133759
  hook = {
133456
133760
  runId: effectiveRunId,
@@ -133465,9 +133769,10 @@ function createEventsStorage(basedir, tag) {
133465
133769
  specVersion: effectiveSpecVersion,
133466
133770
  isWebhook: persistedHookData.isWebhook ?? false,
133467
133771
  isSystem: persistedHookData.isSystem ?? false,
133468
- tokenRetentionUntil: persistedHookData.tokenRetentionUntil
133772
+ tokenRetentionUntil: persistedHookData.tokenRetentionUntil,
133773
+ ...claimedFrom && { claimedFrom }
133469
133774
  };
133470
- hookEntityWriteOptions = claimResult.status === "owned" ? { overwrite: true } : void 0;
133775
+ hookEntityWriteOptions = claimResult.status === "owned" || claimedFrom ? { overwrite: true } : void 0;
133471
133776
  await writeHookCreatedIndexEntries(basedir, hookData.token, effectiveRunId, data.correlationId, eventId, tag);
133472
133777
  } else if (data.eventType === "hook_disposed") {
133473
133778
  const lockPath = hookDisposeLockPath(basedir, data.correlationId, tag);
@@ -133525,8 +133830,14 @@ function createEventsStorage(basedir, tag) {
133525
133830
  };
133526
133831
  await writeJSON(taggedPath(basedir, "waits", waitCompositeKey, tag), wait, { overwrite: true });
133527
133832
  }
133528
- if (data.eventType === "hook_received" && data.correlationId && await isHookDisposalCommitted(basedir, data.correlationId, tag)) {
133529
- throw new HookNotFoundError(data.correlationId);
133833
+ if (data.eventType === "hook_received" && data.correlationId) {
133834
+ await refuseDisposedHookDelivery(data.correlationId, (_b2 = data.eventData) == null ? void 0 : _b2.token);
133835
+ }
133836
+ if (data.eventType === "hook_created" && data.correlationId) {
133837
+ const own2 = await readHookDisposeLock(basedir, data.correlationId, tag);
133838
+ if (own2.committed && own2.forceClaimedBy) {
133839
+ throw new EntityConflictError(`Hook "${data.correlationId}" was force-claimed by another run before its creation was journaled`);
133840
+ }
133530
133841
  }
133531
133842
  let eventPath = taggedPath(basedir, "events", `${effectiveRunId}-${eventId}`, tag);
133532
133843
  let serializedEvent = JSON.stringify(event, jsonReplacer, 2);
@@ -133549,7 +133860,13 @@ function createEventsStorage(basedir, tag) {
133549
133860
  return true;
133550
133861
  };
133551
133862
  let eventPublished = false;
133552
- for (let attempt = 0; ; attempt++) {
133863
+ if (prePublishedEvent) {
133864
+ event = prePublishedEvent;
133865
+ eventPath = taggedPath(basedir, "events", `${effectiveRunId}-${eventId}`, tag);
133866
+ serializedEvent = JSON.stringify(event, jsonReplacer, 2);
133867
+ eventPublished = true;
133868
+ }
133869
+ for (let attempt = 0; !eventPublished; attempt++) {
133553
133870
  if (data.eventType === "hook_received") {
133554
133871
  const terminalByMarker = await isRunTerminalCommitted(basedir, effectiveRunId, tag);
133555
133872
  const runNow = terminalByMarker ? null : await readJSONWithFallback(basedir, "runs", effectiveRunId, WorkflowRunSchema, tag);
@@ -133832,7 +134149,11 @@ function createWorld$2(args) {
133832
134149
  // `(runId, resumeId)` via a filesystem sidecar claim (see
133833
134150
  // events-storage.ts `claimHookResume`), so resumeHook()'s parallel fast
133834
134151
  // path converges on one event in dev exactly as it does on Vercel.
133835
- hookResumeDedup: true
134152
+ hookResumeDedup: true,
134153
+ // The token claim lock serializes the takeover behind
134154
+ // `createHook({ experimental_force: true })`; see the hook_created
134155
+ // branch of storage/events-storage.ts.
134156
+ hookForceClaim: true
133836
134157
  },
133837
134158
  ...queue,
133838
134159
  ...storage,
@@ -133867,7 +134188,7 @@ function createWorld$2(args) {
133867
134188
  const basedir = mergedConfig.dataDir;
133868
134189
  const hooksDir = path$3.join(basedir, "hooks");
133869
134190
  const taggedHookFiles = await listTaggedFiles(hooksDir, tag);
133870
- const { HookSchema: HookSchema2 } = await import("./index-CPJXhpRN.js");
134191
+ const { HookSchema: HookSchema2 } = await import("./index-bN9Oj_dl.js");
133871
134192
  await Promise.all(taggedHookFiles.map(async (hookFile) => {
133872
134193
  const hook = await readJSON(path$3.join(hooksDir, hookFile), HookSchema2);
133873
134194
  if (hook == null ? void 0 : hook.token) {
@@ -134050,8 +134371,8 @@ function requireGetVercelOidcToken() {
134050
134371
  }
134051
134372
  try {
134052
134373
  const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
134053
- await import("./token-util-BMcpB3Iq.js").then((n) => n.t),
134054
- await import("./token-TJVjFtpm.js").then((n) => n.t)
134374
+ await import("./token-util-B4OMKRZB.js").then((n) => n.t),
134375
+ await import("./token-CUWJi08Y.js").then((n) => n.t)
134055
134376
  ]);
134056
134377
  if (!token || isExpired(getTokenPayload(token), options == null ? void 0 : options.expirationBufferMs)) {
134057
134378
  await refreshToken(options);
@@ -134614,7 +134935,7 @@ function requireDist() {
134614
134935
  return dist;
134615
134936
  }
134616
134937
  var distExports = requireDist();
134617
- const version = "5.0.0-beta.50";
134938
+ const version = "5.0.0-beta.51";
134618
134939
  const pools = globalSingleton("@workflow/world-vercel//httpPools", 1, () => ({
134619
134940
  dispatcher: void 0,
134620
134941
  queueDispatcher: void 0,
@@ -135187,6 +135508,10 @@ function headersToRecord(headers2) {
135187
135508
  }
135188
135509
  function errorForResponse(status, message2, opts = {}) {
135189
135510
  const { retryAfter, code: code2, url, mitigated, details } = opts;
135511
+ if (status === 409 && code2 === "hook-force-claimed") {
135512
+ const claimedBy = details && typeof details === "object" ? details.claimedBy : void 0;
135513
+ 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);
135514
+ }
135190
135515
  if (status === 409)
135191
135516
  return new EntityConflictError(message2);
135192
135517
  if (status === 410) {
@@ -136267,7 +136592,7 @@ function createGetEncryptionKeyForRun(projectId, teamId, token, dispatcher2) {
136267
136592
  };
136268
136593
  }
136269
136594
  async function getDeadline() {
136270
- const { getDeadline: getDeadline2 } = await import("./index-BkN7taof.js").then((n) => n.i);
136595
+ const { getDeadline: getDeadline2 } = await import("./index-B_qUqg3k.js").then((n) => n.i);
136271
136596
  return getDeadline2();
136272
136597
  }
136273
136598
  const WORKFLOW_SERVER_SERVICE = {
@@ -141414,7 +141739,7 @@ const wsEventsChannelForInvocation = (runId, config2) => {
141414
141739
  open() {
141415
141740
  if (!runId || !isWsEventsTransportEnabled())
141416
141741
  return;
141417
- claim2 = import("./ws-transport-ClaOEQbG.js").then(({ openWsChannel }) => openWsChannel(runId, config2)).catch(() => void 0);
141742
+ claim2 = import("./ws-transport-B4h16CAX.js").then(({ openWsChannel }) => openWsChannel(runId, config2)).catch(() => void 0);
141418
141743
  },
141419
141744
  /**
141420
141745
  * Awaited, unlike the open: work scheduled after the handler returns is not
@@ -141864,7 +142189,9 @@ function collectErrorMarkers(err, depth = 0) {
141864
142189
  function isRetryableEventPostError(err) {
141865
142190
  if (err instanceof ReplayEventObserverError)
141866
142191
  return false;
141867
- if (EntityConflictError.is(err) || RunExpiredError.is(err) || TooEarlyError.is(err) || ThrottleError.is(err)) {
142192
+ if (EntityConflictError.is(err) || // A takeover redirect is definitive for THIS target; the runtime's
142193
+ // resume path follows the token instead of re-issuing the write here.
142194
+ HookForceClaimedError.is(err) || RunExpiredError.is(err) || TooEarlyError.is(err) || ThrottleError.is(err)) {
141868
142195
  return false;
141869
142196
  }
141870
142197
  if (WorkflowWorldError.is(err) || StreamError.is(err)) {
@@ -142428,6 +142755,8 @@ function buildPostFrameMeta(input) {
142428
142755
  meta.hookIsWebhook = input.hookIsWebhook;
142429
142756
  if (input.hookIsSystem !== void 0)
142430
142757
  meta.hookIsSystem = input.hookIsSystem;
142758
+ if (input.hookForce !== void 0)
142759
+ meta.hookForce = input.hookForce;
142431
142760
  if (input.resumeId !== void 0)
142432
142761
  meta.resumeId = input.resumeId;
142433
142762
  if (input.errorCode !== void 0)
@@ -142495,8 +142824,13 @@ function errorFromV4Response(statusCode, responseHeaders, errorBody, opName, url
142495
142824
  message2 = record2.message;
142496
142825
  if (typeof record2.code === "string")
142497
142826
  code2 = record2.code;
142827
+ else if (typeof record2.error === "string")
142828
+ code2 = record2.error;
142498
142829
  if (statusCode === 412)
142499
142830
  details = decodePreconditionDetails(record2);
142831
+ if (statusCode === 409 && code2 === "hook-force-claimed") {
142832
+ details = { claimedBy: record2.claimedBy };
142833
+ }
142500
142834
  } else if (text2) {
142501
142835
  message2 += ` ${text2}`;
142502
142836
  }
@@ -142732,7 +143066,7 @@ function wsReplyStatus(reply, endpoint) {
142732
143066
  return status;
142733
143067
  }
142734
143068
  async function postEventFrameOverWs(input, config2) {
142735
- const { resolveWsTransport } = await import("./ws-transport-ClaOEQbG.js");
143069
+ const { resolveWsTransport } = await import("./ws-transport-B4h16CAX.js");
142736
143070
  const { runId } = input;
142737
143071
  const resolved = resolveWsTransport(runId, config2);
142738
143072
  if (!resolved)
@@ -143296,6 +143630,9 @@ function splitEventDataForV4(data) {
143296
143630
  if (typeof eventData.isSystem === "boolean") {
143297
143631
  meta.hookIsSystem = eventData.isSystem;
143298
143632
  }
143633
+ if (eventData.force === true) {
143634
+ meta.hookForce = true;
143635
+ }
143299
143636
  if (typeof eventData.errorCode === "string") {
143300
143637
  meta.errorCode = eventData.errorCode;
143301
143638
  }
@@ -143428,7 +143765,7 @@ async function createWorkflowRunEventBatch(runId, events2, params, config2) {
143428
143765
  };
143429
143766
  }
143430
143767
  async function createWorkflowRunEvent(id2, data, params, config2) {
143431
- var _a3, _b2;
143768
+ var _a3, _b2, _c2;
143432
143769
  try {
143433
143770
  const result = await withEventPostRetry(() => createWorkflowRunEventInner(id2, data, params, config2), data.eventType, {
143434
143771
  // The atomic lazy-resume shape is deduplicated server-side by the
@@ -143449,6 +143786,10 @@ async function createWorkflowRunEvent(id2, data, params, config2) {
143449
143786
  } catch (err) {
143450
143787
  if (err instanceof ReplayEventObserverError)
143451
143788
  throw err.error;
143789
+ if (HookForceClaimedError.is(err) && data.eventType === "hook_received") {
143790
+ const token = (_c2 = data.eventData) == null ? void 0 : _c2.token;
143791
+ throw new HookForceClaimedError(typeof token === "string" ? token : err.token, err.claimedByRunId, err.claimedByHookId);
143792
+ }
143452
143793
  if (isHookEventRequiringExistence(data.eventType) && WorkflowWorldError.is(err) && err.status === 404 && data.correlationId) {
143453
143794
  throw new HookNotFoundError(data.correlationId);
143454
143795
  }
@@ -143820,7 +144161,7 @@ function beginNormalWsClose(ws, reason) {
143820
144161
  await observed;
143821
144162
  span == null ? void 0 : span.setAttribute("workflow.stream.ws.close_cleanup_timeout", timedOut);
143822
144163
  });
143823
- void import("./index-BkN7taof.js").then((n) => n.i).then(({ waitUntil: waitUntil2 }) => waitUntil2(cleanup)).catch(() => {
144164
+ void import("./index-B_qUqg3k.js").then((n) => n.i).then(({ waitUntil: waitUntil2 }) => waitUntil2(cleanup)).catch(() => {
143824
144165
  });
143825
144166
  void cleanup.catch(() => {
143826
144167
  });
@@ -144172,7 +144513,7 @@ class VercelStreamWriteSession {
144172
144513
  return http3;
144173
144514
  });
144174
144515
  const [{ WebSocket: WebSocketImpl }, http2] = await Promise.all([
144175
- import("./wrapper-DG37QKjD.js"),
144516
+ import("./wrapper-Cs9Wzu7M.js"),
144176
144517
  httpPromise
144177
144518
  ]);
144178
144519
  if (this.mode !== "connecting")
@@ -144774,7 +145115,15 @@ function createWorld$1(config2) {
144774
145115
  maxConcurrency: true,
144775
145116
  // Vercel deployments are atomic and immutable, so a deployment id names
144776
145117
  // one fixed build for its whole lifetime.
144777
- deploymentAffinity: true
145118
+ deploymentAffinity: true,
145119
+ // The server implements the takeover protocol behind
145120
+ // `createHook({ experimental_force: true })` (workflow-server
145121
+ // docs/hook-force-claim.md). Static rather than attested per lookup,
145122
+ // because the decision is made at `createHook()` time, before any
145123
+ // lookup; against a server that has it switched off (or predates it)
145124
+ // a forced creation is answered with `hook_conflict`, which the
145125
+ // runtime reports as an unsupported-World failure rather than a win.
145126
+ hookForceClaim: true
144778
145127
  // NOTE: the backend half of resumeHook()'s lazy path (that
144779
145128
  // the server enforces the `(runId, resumeId)` dedup constraint) is
144780
145129
  // NO LONGER a static world capability here. It is attested per-lookup by
@@ -144930,6 +145279,39 @@ globalSingleton("@workflow/core//devServerPort", 1, () => ({
144930
145279
  inFlight: void 0
144931
145280
  }));
144932
145281
  globalSingleton("@workflow/core//stepSingleFlight", 1, () => ({ inFlight: /* @__PURE__ */ new Map() }));
145282
+ const HOOK_WAKE_RETRY_DELAYS_MS = [25, 100];
145283
+ function isRetryableWakeError(error2, isDeploymentUnavailableError) {
145284
+ if (isDeploymentUnavailableError == null ? void 0 : isDeploymentUnavailableError(error2))
145285
+ return false;
145286
+ const status = error2 ?? {};
145287
+ const code2 = status.status ?? status.statusCode;
145288
+ if (typeof code2 === "number") {
145289
+ return code2 >= 500 || code2 === 408 || code2 === 429;
145290
+ }
145291
+ const name2 = error2 == null ? void 0 : error2.name;
145292
+ return name2 !== "BadRequestError" && name2 !== "UnauthorizedError" && name2 !== "ForbiddenError";
145293
+ }
145294
+ async function publishHookWakeWithRetry(publish, isDeploymentUnavailableError) {
145295
+ let lastError;
145296
+ for (let attempt = 0; attempt <= HOOK_WAKE_RETRY_DELAYS_MS.length; attempt++) {
145297
+ try {
145298
+ await publish();
145299
+ return;
145300
+ } catch (error2) {
145301
+ lastError = error2;
145302
+ if (!isRetryableWakeError(error2, isDeploymentUnavailableError))
145303
+ break;
145304
+ const delayMs = HOOK_WAKE_RETRY_DELAYS_MS[attempt];
145305
+ if (delayMs !== void 0) {
145306
+ await new Promise((resolve2) => setTimeout(resolve2, delayMs));
145307
+ }
145308
+ }
145309
+ }
145310
+ if (HookNotFoundError.is(lastError)) {
145311
+ throw new WorkflowRuntimeError("The hook resume was committed, but its workflow wake could not be published", { cause: lastError });
145312
+ }
145313
+ throw lastError;
145314
+ }
144933
145315
  var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
144934
145316
  var intToChar = new Uint8Array(64);
144935
145317
  var charToInt = new Uint8Array(128);
@@ -145631,39 +146013,6 @@ async function computeResumePayloadDigest(bytes) {
145631
146013
  }
145632
146014
  return hex2;
145633
146015
  }
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
146016
  function resumeContextFromRun(run2) {
145668
146017
  var _a3, _b2, _c2;
145669
146018
  const coreVersion = (_a3 = run2.executionContext) == null ? void 0 : _a3.workflowCoreVersion;
@@ -145742,155 +146091,258 @@ async function getHookByToken(token) {
145742
146091
  async function resumeHook$2(tokenOrHook, payload, encryptionKeyOverride) {
145743
146092
  return resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, false, Date.now());
145744
146093
  }
145745
- async function resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, hookFreshlyLookedUp, resumeRequestedAtMs) {
146094
+ const MAX_FORCE_CLAIM_REDIRECTS = 3;
146095
+ const notFoundReasons = /* @__PURE__ */ new WeakMap();
146096
+ async function resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, hookFreshlyLookedUp, resumeRequestedAtMs, webhookOnly = false) {
145746
146097
  return await waitedUntil(() => {
145747
146098
  return trace$2("hook.resume", async (span) => {
145748
- var _a3, _b2, _c2, _d2, _e2;
145749
146099
  const world = await getWorldLazy();
145750
- try {
145751
- const suppliedToken = typeof tokenOrHook === "string";
145752
- const hook = suppliedToken ? await world.hooks.getByToken(tokenOrHook) : tokenOrHook;
145753
- const hookResumeCapabilitiesAreFresh = suppliedToken || hookFreshlyLookedUp;
145754
- const info = await resolveHookResumeInfo(hook);
145755
- const { resumeContext } = info;
145756
- span == null ? void 0 : span.setAttributes({
145757
- ...HookToken(hook.token),
145758
- ...HookId(hook.hookId),
145759
- ...WorkflowRunId$2(hook.runId),
145760
- "workflow.hook.resume_context_source": info.source
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)
146100
+ const token = typeof tokenOrHook === "string" ? tokenOrHook : tokenOrHook.token;
146101
+ let target2 = tokenOrHook;
146102
+ let fresh = hookFreshlyLookedUp;
146103
+ let keyOverride = encryptionKeyOverride;
146104
+ let redirects = 0;
146105
+ let lookupsAfterRedirect = 0;
146106
+ const MAX_LOOKUPS_AFTER_REDIRECT = 5;
146107
+ const resumeId = generateResumeId();
146108
+ const assertResendable = (cause) => {
146109
+ if (payload instanceof Request && payload.body !== null && payload.bodyUsed) {
146110
+ span == null ? void 0 : span.setAttributes({
146111
+ "workflow.hook.resume_redirect_unresendable": true
145798
146112
  });
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 });
146113
+ 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
146114
  }
145842
- const isHookGoneError = (err) => HookNotFoundError.is(err) || RunExpiredError.is(err);
146115
+ };
146116
+ for (; ; ) {
145843
146117
  try {
145844
- await world.events.create(hook.runId, {
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
- });
146118
+ return await resumeHookAttempt(world, span, target2, payload, keyOverride, fresh, resumeRequestedAtMs, resumeId, webhookOnly);
145856
146119
  } catch (err) {
145857
- if (isHookGoneError(err)) {
145858
- throw new HookNotFoundError(hook.token);
146120
+ if (err !== null && typeof err === "object" && notFoundReasons.get(err) === "not-webhook") {
146121
+ throw err;
146122
+ }
146123
+ if (redirects >= MAX_FORCE_CLAIM_REDIRECTS) {
146124
+ if (HookForceClaimedError.is(err)) {
146125
+ span == null ? void 0 : span.setAttributes({
146126
+ "workflow.hook.resume_redirects_exhausted": true
146127
+ });
146128
+ throw new WorkflowRuntimeError(`Hook token "${token}" changed owner ${redirects} times while this resume was in flight; nothing was delivered — retry the resume`, { cause: err });
146129
+ }
146130
+ throw err;
146131
+ }
146132
+ if (HookForceClaimedError.is(err)) {
146133
+ assertResendable(err);
146134
+ redirects++;
146135
+ span == null ? void 0 : span.setAttributes({
146136
+ "workflow.hook.resume_redirects": redirects,
146137
+ "workflow.hook.resume_redirect_to_run": err.claimedByRunId
146138
+ });
146139
+ target2 = token;
146140
+ fresh = true;
146141
+ keyOverride = void 0;
146142
+ lookupsAfterRedirect = 0;
146143
+ continue;
146144
+ }
146145
+ if (HookNotFoundError.is(err) && redirects > 0 && typeof target2 === "string" && lookupsAfterRedirect < MAX_LOOKUPS_AFTER_REDIRECT) {
146146
+ assertResendable(err);
146147
+ lookupsAfterRedirect++;
146148
+ await new Promise((resolve2) => setTimeout(resolve2, 50));
146149
+ continue;
146150
+ }
146151
+ if (HookNotFoundError.is(err) && notFoundReasons.get(err) !== "lookup") {
146152
+ const attemptedHookId = typeof target2 === "string" ? void 0 : target2.hookId;
146153
+ let relocated;
146154
+ try {
146155
+ relocated = await world.hooks.getByToken(token);
146156
+ } catch (lookupError) {
146157
+ if (!HookNotFoundError.is(lookupError)) {
146158
+ runtimeLogger.warn("Hook resume: re-resolving the token after a not-found failed; surfacing the original error", {
146159
+ token,
146160
+ error: lookupError instanceof Error ? lookupError.message : String(lookupError)
146161
+ });
146162
+ }
146163
+ }
146164
+ if ((relocated == null ? void 0 : relocated.claimedFrom) !== void 0 && relocated.hookId !== attemptedHookId && (attemptedHookId === void 0 || relocated.claimedFrom.hookId === attemptedHookId) && !(webhookOnly && relocated.isWebhook === false)) {
146165
+ assertResendable(err);
146166
+ redirects++;
146167
+ span == null ? void 0 : span.setAttributes({
146168
+ "workflow.hook.resume_redirects": redirects,
146169
+ "workflow.hook.resume_redirect_to_run": relocated.runId
146170
+ });
146171
+ target2 = relocated;
146172
+ fresh = true;
146173
+ keyOverride = void 0;
146174
+ continue;
146175
+ }
145859
146176
  }
145860
146177
  throw err;
145861
146178
  }
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
146179
  }
145891
146180
  });
145892
146181
  });
145893
146182
  }
146183
+ async function resumeHookAttempt(world, span, tokenOrHook, payload, encryptionKeyOverride, hookFreshlyLookedUp, resumeRequestedAtMs, logicalResumeId, webhookOnly) {
146184
+ var _a3, _b2, _c2, _d2, _e2;
146185
+ try {
146186
+ const suppliedToken = typeof tokenOrHook === "string";
146187
+ let hook;
146188
+ if (suppliedToken) {
146189
+ try {
146190
+ hook = await world.hooks.getByToken(tokenOrHook);
146191
+ } catch (lookupError) {
146192
+ if (HookNotFoundError.is(lookupError)) {
146193
+ notFoundReasons.set(lookupError, "lookup");
146194
+ }
146195
+ throw lookupError;
146196
+ }
146197
+ } else {
146198
+ hook = tokenOrHook;
146199
+ }
146200
+ if (webhookOnly && hook.isWebhook === false) {
146201
+ const notWebhook = new HookNotFoundError(hook.token);
146202
+ notFoundReasons.set(notWebhook, "not-webhook");
146203
+ throw notWebhook;
146204
+ }
146205
+ const hookResumeCapabilitiesAreFresh = suppliedToken || hookFreshlyLookedUp;
146206
+ const info = await resolveHookResumeInfo(hook);
146207
+ const { resumeContext } = info;
146208
+ span == null ? void 0 : span.setAttributes({
146209
+ ...HookToken(hook.token),
146210
+ ...HookId(hook.hookId),
146211
+ ...WorkflowRunId$2(hook.runId),
146212
+ "workflow.hook.resume_context_source": info.source
146213
+ });
146214
+ if (info.run && isTerminalWorkflowRunStatus(info.run.status)) {
146215
+ throw new HookNotFoundError(hook.token);
146216
+ }
146217
+ const capabilities = getRunCapabilities(resumeContext.workflowCoreVersion);
146218
+ let payloadKey;
146219
+ const runPublicKey = encryptionKeyOverride ? (
146220
+ // The caller already holds a key (resumeWebhook resolved one to
146221
+ // hydrate hook metadata), so sealing would add an ECDH for no
146222
+ // saved round trip. Reuse what it resolved.
146223
+ void 0
146224
+ ) : decodeRunPublicKey(resumeContext.encryptionPublicKey);
146225
+ if (runPublicKey) {
146226
+ payloadKey = sealTo(runPublicKey);
146227
+ } else {
146228
+ let encryptionKey = encryptionKeyOverride ?? await resolveHookEncryptionKey(hook, info);
146229
+ if (!capabilities.supportedFormats.has(SerializationFormat$1.ENCRYPTED)) {
146230
+ encryptionKey = void 0;
146231
+ }
146232
+ payloadKey = encryptionKey;
146233
+ }
146234
+ const compression = (resumeContext.runSpecVersion ?? 0) >= SPEC_VERSION_SUPPORTS_COMPRESSION && capabilities.supportedFormats.has(SerializationFormat$1.GZIP);
146235
+ const ops = [];
146236
+ const readbackOps = [];
146237
+ const v1Compat = isLegacySpecVersion(hook.specVersion);
146238
+ const dehydratedPayload = await dehydrateStepReturnValue(payload, hook.runId, payloadKey, ops, globalThis, v1Compat, capabilities.framedByteStreams, compression, void 0, readbackOps);
146239
+ await Promise.all(ops.map((op) => op.catch((error2) => {
146240
+ if (error2 !== void 0)
146241
+ throw error2;
146242
+ })));
146243
+ safeWaitUntil(Promise.all(readbackOps), (err) => {
146244
+ if (err === void 0)
146245
+ return;
146246
+ runtimeLogger.warn("Background readback of hook payload failed", {
146247
+ workflowRunId: hook.runId,
146248
+ hookId: hook.hookId,
146249
+ error: err instanceof Error ? err.message : String(err)
146250
+ });
146251
+ });
146252
+ if (((_a3 = world.capabilities) == null ? void 0 : _a3.invoke) === true && !v1Compat && dehydratedPayload instanceof Uint8Array) {
146253
+ if (!world.invoke) {
146254
+ throw new WorkflowRuntimeError("World advertises invoke without implementing it");
146255
+ }
146256
+ span == null ? void 0 : span.setAttributes({ "workflow.hook.resume_strategy": "invoke" });
146257
+ const result = HookInvocationResultSchema.parse(await world.invoke(hook.runId, {
146258
+ type: "hook_resume",
146259
+ version: 1,
146260
+ hookId: hook.hookId,
146261
+ token: hook.token,
146262
+ payload: dehydratedPayload
146263
+ }, { idempotencyKey: logicalResumeId }));
146264
+ if (result.status === "rejected") {
146265
+ if (result.code === "HOOK_NOT_FOUND")
146266
+ throw new HookNotFoundError(hook.token);
146267
+ throw new WorkflowRuntimeError("Executor rejected the hook invocation input");
146268
+ }
146269
+ span == null ? void 0 : span.setAttributes(HookResumeCommitted(true));
146270
+ return asLazyMetadataHook(hook);
146271
+ }
146272
+ span == null ? void 0 : span.setAttributes({
146273
+ ...WorkflowName(resumeContext.workflowName)
146274
+ });
146275
+ const originLink = await linkToTraceCarrier(resumeContext.traceCarrier);
146276
+ if (originLink) {
146277
+ (_b2 = span == null ? void 0 : span.addLink) == null ? void 0 : _b2.call(span, originLink);
146278
+ }
146279
+ const queueName = getWorkflowQueueName(resumeContext.workflowName);
146280
+ const queueOptions = {
146281
+ deploymentId: resumeContext.deploymentId,
146282
+ specVersion: resumeContext.runSpecVersion ?? SPEC_VERSION_LEGACY
146283
+ };
146284
+ 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;
146285
+ const canClaimResume = backendDedupSupported && !v1Compat && dehydratedPayload instanceof Uint8Array;
146286
+ span == null ? void 0 : span.setAttributes({
146287
+ "workflow.hook.resume_strategy": "sequential"
146288
+ });
146289
+ const resumeId = canClaimResume ? logicalResumeId : void 0;
146290
+ const payloadDigest = canClaimResume ? await computeResumePayloadDigest(dehydratedPayload) : void 0;
146291
+ if (resumeId) {
146292
+ span == null ? void 0 : span.setAttributes({ "workflow.hook.resume_id": resumeId });
146293
+ }
146294
+ const isHookGoneError = (err) => HookNotFoundError.is(err) || RunExpiredError.is(err);
146295
+ try {
146296
+ await world.events.create(hook.runId, {
146297
+ eventType: "hook_received",
146298
+ specVersion: SPEC_VERSION_CURRENT,
146299
+ correlationId: hook.hookId,
146300
+ eventData: {
146301
+ ...v1Compat ? {} : { token: hook.token },
146302
+ payload: dehydratedPayload
146303
+ }
146304
+ }, {
146305
+ v1Compat,
146306
+ ...resumeId && payloadDigest ? { resumeId, resumePayloadDigest: payloadDigest } : {}
146307
+ });
146308
+ } catch (err) {
146309
+ if (HookForceClaimedError.is(err))
146310
+ throw err;
146311
+ if (isHookGoneError(err)) {
146312
+ throw new HookNotFoundError(hook.token);
146313
+ }
146314
+ throw err;
146315
+ }
146316
+ span == null ? void 0 : span.setAttributes(HookResumeCommitted(true));
146317
+ const queuePublishRequestedAtMs = Date.now();
146318
+ await publishHookWakeWithRetry(() => world.queue(queueName, {
146319
+ runId: hook.runId,
146320
+ traceCarrier: resumeContext.traceCarrier ?? void 0,
146321
+ hookResumeTiming: {
146322
+ resumeRequestedAtMs,
146323
+ queuePublishRequestedAtMs,
146324
+ strategy: "sequential"
146325
+ }
146326
+ }, {
146327
+ ...queueOptions,
146328
+ // Dedup retried publishes whose response was lost: a
146329
+ // duplicate wake is harmless for correctness (deterministic
146330
+ // replay) but costs a full replay of the run, and the queue
146331
+ // accepts a repeated idempotency key by delivering only one
146332
+ // of the messages. Claim-less writes have no resumeId and
146333
+ // keep the previous behavior.
146334
+ ...resumeId ? { idempotencyKey: `hook-${resumeId}` } : {}
146335
+ }), (_e2 = world.isDeploymentUnavailableError) == null ? void 0 : _e2.bind(world));
146336
+ span == null ? void 0 : span.setAttributes(HookWakePublished(true));
146337
+ return asLazyMetadataHook(hook);
146338
+ } catch (err) {
146339
+ span == null ? void 0 : span.setAttributes({
146340
+ ...HookToken(typeof tokenOrHook === "string" ? tokenOrHook : tokenOrHook.token),
146341
+ ...HookFound(false)
146342
+ });
146343
+ throw err;
146344
+ }
146345
+ }
145894
146346
  async function resumeWebhook(token, request2) {
145895
146347
  const resumeRequestedAtMs = Date.now();
145896
146348
  const world = await getWorldLazy();
@@ -145914,7 +146366,7 @@ async function resumeWebhook(token, request2) {
145914
146366
  } else {
145915
146367
  response2 = new Response(null, { status: 202 });
145916
146368
  }
145917
- await resumeHookImpl(hook, request2, metadataEncryptionKey(), true, resumeRequestedAtMs);
146369
+ await resumeHookImpl(hook, request2, metadataEncryptionKey(), true, resumeRequestedAtMs, true);
145918
146370
  if (responseReadable) {
145919
146371
  const reader = responseReadable.getReader();
145920
146372
  const chunk = await reader.read();
@@ -169130,7 +169582,7 @@ const route4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
169130
169582
  __proto__: null,
169131
169583
  loader
169132
169584
  }, 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-DBWIyKUW.js", "imports": ["/assets/index-thGVuYbY.js", "/assets/mermaid-3ZIDBTTL-NvETcKWB.js", "/assets/loader-circle-DUHA29mm.js", "/assets/arrow-up-right-Cbiblmqd.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-5LIuLkPD.js", "imports": ["/assets/index-thGVuYbY.js", "/assets/workflow-graph-viewer-B-jkpIk_.js", "/assets/mermaid-3ZIDBTTL-NvETcKWB.js", "/assets/loader-circle-DUHA29mm.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-CBJBkl4-.js", "imports": ["/assets/index-thGVuYbY.js", "/assets/workflow-graph-viewer-B-jkpIk_.js", "/assets/mermaid-3ZIDBTTL-NvETcKWB.js", "/assets/arrow-up-right-Cbiblmqd.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-4d592c52.js", "version": "4d592c52", "sri": void 0 };
169585
+ 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
169586
  const assetsBuildDirectory = "build/client";
169135
169587
  const basename = "/";
169136
169588
  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 +169791,7 @@ function createFetchHandler(basename2 = "/") {
169339
169791
  return (request2) => handler(request2, loadContext);
169340
169792
  }
169341
169793
  export {
169342
- ROOT_RUN_ID_ATTRIBUTE as $,
169794
+ RETENTION_ZERO as $,
169343
169795
  ANALYTICS_EVENTS_GET_MANY_LIMIT as A,
169344
169796
  BULK_CANCEL_MAX_RUN_IDS as B,
169345
169797
  CHILD_ENTITY_CREATION_EVENT_TYPES as C,
@@ -169352,121 +169804,122 @@ export {
169352
169804
  HOOK_RESUME_DEDUP_VERSION as J,
169353
169805
  HOOK_RESUME_INPUT_VERSION as K,
169354
169806
  HealthCheckPayloadSchema as L,
169355
- HookCreatedEventSchema as M,
169807
+ HookClaimedFromSchema as M,
169356
169808
  Nt as N,
169357
- HookResumeCapabilitiesSchema as O,
169358
- LegacySerializedDataSchemaV1 as P,
169359
- MessageId as Q,
169360
- NODE_HTTP_DEFAULT as R,
169361
- NODE_HTTP_ENV_VAR as S,
169362
- PARENT_RUN_ID_ATTRIBUTE as T,
169363
- PaginatedResponseSchema as U,
169364
- QueuePayloadSchema as V,
169365
- QueuePrefix as W,
169366
- RESERVED_ATTRIBUTE_KEY_PREFIX as X,
169367
- RETENTION_ATTRIBUTE as Y,
169368
- RETENTION_DEFAULT as Z,
169369
- RETENTION_ZERO as _,
169809
+ HookCreatedEventSchema as O,
169810
+ HookResumeCapabilitiesSchema as P,
169811
+ LegacySerializedDataSchemaV1 as Q,
169812
+ MessageId as R,
169813
+ NODE_HTTP_DEFAULT as S,
169814
+ NODE_HTTP_ENV_VAR as T,
169815
+ PARENT_RUN_ID_ATTRIBUTE as U,
169816
+ PaginatedResponseSchema as V,
169817
+ QueuePayloadSchema as W,
169818
+ QueuePrefix as X,
169819
+ RESERVED_ATTRIBUTE_KEY_PREFIX as Y,
169820
+ RETENTION_ATTRIBUTE as Z,
169821
+ RETENTION_DEFAULT as _,
169370
169822
  ANALYTICS_MAX_ATTRIBUTE_FILTERS as a,
169371
- slotToEventId as a$,
169372
- RUN_ENTITY_KEY as a0,
169373
- RunInputSchema as a1,
169374
- SEALED_LOG_ENV_VAR as a2,
169375
- SPEC_VERSION_CURRENT as a3,
169376
- SPEC_VERSION_LEGACY as a4,
169377
- SPEC_VERSION_MAX_SUPPORTED as a5,
169378
- SPEC_VERSION_SUPPORTS_ATTRIBUTES as a6,
169379
- SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT as a7,
169380
- SPEC_VERSION_SUPPORTS_COMPRESSION as a8,
169381
- SPEC_VERSION_SUPPORTS_SEALED_LOG as a9,
169382
- envNumber as aA,
169383
- eventIdToSlot as aB,
169384
- getEventDataPayloadField as aC,
169385
- getEventDataRefFields as aD,
169386
- getMaxEventsPerRun as aE,
169387
- getQueueTopicPrefix as aF,
169388
- isChildEntityCreationEvent as aG,
169389
- isChildEntityCreationEventType as aH,
169390
- isHookEventRequiringExistence as aI,
169391
- isHookLifecycleEventType as aJ,
169392
- isLegacySpecVersion as aK,
169393
- isNodeHttpEnabled as aL,
169394
- isSealedNoopEvent$1 as aM,
169395
- isSlotBody as aN,
169396
- isSlotEventId as aO,
169397
- isStepEventType as aP,
169398
- isTerminalRunEventType as aQ,
169399
- isTerminalStepEventType as aR,
169400
- isTerminalStepStatus as aS,
169401
- isTerminalWorkflowRunStatus as aT,
169402
- isWaitEventType as aU,
169403
- mintedSpecVersion as aV,
169404
- parseQueueName as aW,
169405
- readRunRetention as aX,
169406
- reenqueueActiveRuns as aY,
169407
- requiresNewerWorld as aZ,
169408
- resolveQueueNamespace as a_,
169409
- SPEC_VERSION_SUPPORTS_SLOT_IDENTITY as aa,
169410
- STEP_EVENT_TYPES as ab,
169411
- SerializedDataSchema as ac,
169412
- StepSchema as ad,
169413
- StepStatusSchema as ae,
169414
- StructuredErrorSchema as af,
169415
- TERMINAL_EVENT_CLASSES as ag,
169416
- TERMINAL_RUN_EVENT_TYPES as ah,
169417
- TERMINAL_STEP_EVENT_TYPES as ai,
169418
- TERMINAL_STEP_STATUSES as aj,
169419
- TERMINAL_WORKFLOW_RUN_STATUSES as ak,
169420
- TerminalRunEventTypeSchema as al,
169421
- TerminalStepStatusSchema as am,
169422
- TerminalWorkflowRunStatusSchema as an,
169423
- ValidQueueName as ao,
169424
- WAIT_EVENT_TYPES as ap,
169425
- WaitSchema as aq,
169426
- WaitStatusSchema as ar,
169427
- WorkflowInvokePayloadSchema as as,
169428
- WorkflowRunBaseSchema as at,
169429
- WorkflowRunSchema as au,
169430
- WorkflowRunStatusSchema as av,
169431
- applyAttributeChanges as aw,
169432
- classifyEntityEvent as ax,
169433
- entityEventClass as ay,
169434
- envFlag as az,
169823
+ resolveQueueNamespace as a$,
169824
+ ROOT_RUN_ID_ATTRIBUTE as a0,
169825
+ RUN_ENTITY_KEY as a1,
169826
+ RunInputSchema as a2,
169827
+ SEALED_LOG_ENV_VAR as a3,
169828
+ SPEC_VERSION_CURRENT as a4,
169829
+ SPEC_VERSION_LEGACY as a5,
169830
+ SPEC_VERSION_MAX_SUPPORTED as a6,
169831
+ SPEC_VERSION_SUPPORTS_ATTRIBUTES as a7,
169832
+ SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT as a8,
169833
+ SPEC_VERSION_SUPPORTS_COMPRESSION as a9,
169834
+ envFlag as aA,
169835
+ envNumber as aB,
169836
+ eventIdToSlot as aC,
169837
+ getEventDataPayloadField as aD,
169838
+ getEventDataRefFields as aE,
169839
+ getMaxEventsPerRun as aF,
169840
+ getQueueTopicPrefix as aG,
169841
+ isChildEntityCreationEvent as aH,
169842
+ isChildEntityCreationEventType as aI,
169843
+ isHookEventRequiringExistence as aJ,
169844
+ isHookLifecycleEventType as aK,
169845
+ isLegacySpecVersion as aL,
169846
+ isNodeHttpEnabled as aM,
169847
+ isSealedNoopEvent$1 as aN,
169848
+ isSlotBody as aO,
169849
+ isSlotEventId as aP,
169850
+ isStepEventType as aQ,
169851
+ isTerminalRunEventType as aR,
169852
+ isTerminalStepEventType as aS,
169853
+ isTerminalStepStatus as aT,
169854
+ isTerminalWorkflowRunStatus as aU,
169855
+ isWaitEventType as aV,
169856
+ mintedSpecVersion as aW,
169857
+ parseQueueName as aX,
169858
+ readRunRetention as aY,
169859
+ reenqueueActiveRuns as aZ,
169860
+ requiresNewerWorld as a_,
169861
+ SPEC_VERSION_SUPPORTS_HOOK_FORCE_CLAIM as aa,
169862
+ SPEC_VERSION_SUPPORTS_SLOT_IDENTITY as ab,
169863
+ STEP_EVENT_TYPES as ac,
169864
+ SerializedDataSchema as ad,
169865
+ StepSchema as ae,
169866
+ StepStatusSchema as af,
169867
+ StructuredErrorSchema as ag,
169868
+ TERMINAL_EVENT_CLASSES as ah,
169869
+ TERMINAL_RUN_EVENT_TYPES as ai,
169870
+ TERMINAL_STEP_EVENT_TYPES as aj,
169871
+ TERMINAL_STEP_STATUSES as ak,
169872
+ TERMINAL_WORKFLOW_RUN_STATUSES as al,
169873
+ TerminalRunEventTypeSchema as am,
169874
+ TerminalStepStatusSchema as an,
169875
+ TerminalWorkflowRunStatusSchema as ao,
169876
+ ValidQueueName as ap,
169877
+ WAIT_EVENT_TYPES as aq,
169878
+ WaitSchema as ar,
169879
+ WaitStatusSchema as as,
169880
+ WorkflowInvokePayloadSchema as at,
169881
+ WorkflowRunBaseSchema as au,
169882
+ WorkflowRunSchema as av,
169883
+ WorkflowRunStatusSchema as aw,
169884
+ applyAttributeChanges as ax,
169885
+ classifyEntityEvent as ay,
169886
+ entityEventClass as az,
169435
169887
  ANALYTICS_PAGE_LIMIT as b,
169436
- stripEventDataRefs as b0,
169437
- ulidToDate as b1,
169438
- validateAttributeChanges as b2,
169439
- validateAttributeEventDataSize as b3,
169440
- validateUlidTimestamp as b4,
169441
- workflowRunIdSchema as b5,
169442
- reactExports as b6,
169443
- R as b7,
169444
- Ks as b8,
169445
- jsxRuntimeExports as b9,
169446
- Qe as ba,
169447
- registerZstdDecoder as bb,
169448
- isWsEventsTransportEnabled as bc,
169449
- debugLog as bd,
169450
- getHttpUrl as be,
169451
- globalSingleton as bf,
169452
- version as bg,
169453
- getHttpConfig as bh,
169454
- headersToRecord as bi,
169455
- getRequestTimeoutMs as bj,
169456
- injectTraceContextIntoHeaders as bk,
169457
- withHttpClientSpan as bl,
169458
- ErrorType as bm,
169459
- WorkflowWsReconnectAttempt as bn,
169460
- NetworkProtocolName as bo,
169461
- WorkflowEventsTransport as bp,
169462
- distExports as bq,
169463
- decodeFrames as br,
169464
- getDefaultExportFromCjs as bs,
169465
- requireTokenUtil as bt,
169466
- requireTokenError as bu,
169467
- getAugmentedNamespace as bv,
169468
- app as bw,
169469
- createFetchHandler as bx,
169888
+ slotToEventId as b0,
169889
+ stripEventDataRefs as b1,
169890
+ ulidToDate as b2,
169891
+ validateAttributeChanges as b3,
169892
+ validateAttributeEventDataSize as b4,
169893
+ validateUlidTimestamp as b5,
169894
+ workflowRunIdSchema as b6,
169895
+ reactExports as b7,
169896
+ R as b8,
169897
+ Ks as b9,
169898
+ jsxRuntimeExports as ba,
169899
+ Qe as bb,
169900
+ registerZstdDecoder as bc,
169901
+ isWsEventsTransportEnabled as bd,
169902
+ debugLog as be,
169903
+ getHttpUrl as bf,
169904
+ globalSingleton as bg,
169905
+ version as bh,
169906
+ getHttpConfig as bi,
169907
+ headersToRecord as bj,
169908
+ getRequestTimeoutMs as bk,
169909
+ injectTraceContextIntoHeaders as bl,
169910
+ withHttpClientSpan as bm,
169911
+ ErrorType as bn,
169912
+ WorkflowWsReconnectAttempt as bo,
169913
+ NetworkProtocolName as bp,
169914
+ WorkflowEventsTransport as bq,
169915
+ distExports as br,
169916
+ decodeFrames as bs,
169917
+ getDefaultExportFromCjs as bt,
169918
+ requireTokenUtil as bu,
169919
+ requireTokenError as bv,
169920
+ getAugmentedNamespace as bw,
169921
+ app as bx,
169922
+ createFetchHandler as by,
169470
169923
  ANALYTICS_RUN_SCOPED_PAGE_LIMIT as c,
169471
169924
  ATTRIBUTE_EVENT_DATA_MAX_BYTES as d,
169472
169925
  ATTRIBUTE_KEY_MAX_LENGTH as e,