@workflow/web 5.0.0-beta.35 → 5.0.0-beta.37

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 (28) hide show
  1. package/build/client/assets/{arrow-up-right-B9knAxIp.js → arrow-up-right-DDNPFYmg.js} +1 -1
  2. package/build/client/assets/{entry.client-Q4eUIqMI.js → entry.client-LwI3HNYl.js} +1 -1
  3. package/build/client/assets/{highlighted-body-B3W2YXNL-nasOj6sE.js → highlighted-body-B3W2YXNL-CRgNr0YA.js} +2 -2
  4. package/build/client/assets/{home-BasVp7zv.js → home-BqvW8ODs.js} +6 -7
  5. package/build/client/assets/{index-Q81MFBxC.js → index-PFjW8YjQ.js} +20 -20
  6. package/build/client/assets/manifest-7f03c136.js +1 -0
  7. package/build/client/assets/{mermaid-3ZIDBTTL-g3vDTGSb.js → mermaid-3ZIDBTTL-CMP9Tato.js} +971 -186
  8. package/build/client/assets/root-15oK726f.css +1 -0
  9. package/build/client/assets/{root-DfwDd0Zj.js → root-2ub-CsWS.js} +11 -30
  10. package/build/client/assets/{run-detail-BGMnsQO5.js → run-detail-B1PK-m7y.js} +48 -41
  11. package/build/client/assets/server-build-DblSGQ6A.css +1 -0
  12. package/build/client/assets/{workflow-graph-viewer-VUIB71kS.js → workflow-graph-viewer-DOLwtzSv.js} +2 -3
  13. package/build/client/assets/{zstd-browser-decoder-B6lDon6D.js → zstd-browser-decoder-BAY5XtBl.js} +2 -2
  14. package/build/server/assets/{app-BpmTURgx.js → app-BaJoK9ck.js} +1 -1
  15. package/build/server/assets/{highlighted-body-B3W2YXNL-BGkarUSx.js → highlighted-body-B3W2YXNL-DE3KXslx.js} +2 -2
  16. package/build/server/assets/{index-Dt3nkvmG.js → index-M4Ai7vsa.js} +6 -6
  17. package/build/server/assets/{mermaid-3ZIDBTTL-DUb3plqq.js → mermaid-3ZIDBTTL-DjL45D7x.js} +2 -2
  18. package/build/server/assets/{server-build-vDim5aBz.js → server-build-C11Xqmwk.js} +2533 -1426
  19. package/build/server/assets/{token-BaQZqFlF.js → token-Ulh8Tdgw.js} +2 -2
  20. package/build/server/assets/{token-util-DHXhfd_v.js → token-util-CiVcDWD3.js} +2 -2
  21. package/build/server/assets/{zstd-browser-decoder-Bnx_AJNv.js → zstd-browser-decoder-tQARkzJ5.js} +2 -2
  22. package/build/server/index.js +1 -1
  23. package/package.json +8 -8
  24. package/build/client/assets/encryption-CLVP4klT.js +0 -51
  25. package/build/client/assets/index-STTN0-2V.js +0 -306
  26. package/build/client/assets/manifest-47657566.js +0 -1
  27. package/build/client/assets/root-CQggqXow.css +0 -1
  28. package/build/client/assets/server-build-C5ehvmav.css +0 -1
@@ -1,9 +1,9 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/encryption-CLVP4klT.js","assets/index-STTN0-2V.js","assets/index-Q81MFBxC.js","assets/zstd-browser-decoder-B6lDon6D.js","assets/highlighted-body-B3W2YXNL-nasOj6sE.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/zstd-browser-decoder-BAY5XtBl.js","assets/index-PFjW8YjQ.js","assets/highlighted-body-B3W2YXNL-CRgNr0YA.js"])))=>i.map(i=>d[i]);
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  var _a2, _b;
6
- import { r as reactExports, j as jsxRuntimeExports, p as reactDomExports, I as React, G as ReactDOM, R as ReactExports, g as getDefaultExportFromCjs } from "./index-Q81MFBxC.js";
6
+ import { r as reactExports, j as jsxRuntimeExports, o as reactDomExports, H as React, D as ReactDOM, R as ReactExports, I as getDefaultExportFromCjs } from "./index-PFjW8YjQ.js";
7
7
  function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
8
8
  return function handleEvent(event) {
9
9
  originalEventHandler == null ? void 0 : originalEventHandler(event);
@@ -2164,7 +2164,7 @@ function useFloating(options) {
2164
2164
  } = {},
2165
2165
  transform: transform2 = true,
2166
2166
  whileElementsMounted,
2167
- open
2167
+ open: open2
2168
2168
  } = options;
2169
2169
  const [data, setData] = reactExports.useState({
2170
2170
  x: 0,
@@ -2200,7 +2200,7 @@ function useFloating(options) {
2200
2200
  const hasWhileElementsMounted = whileElementsMounted != null;
2201
2201
  const whileElementsMountedRef = useLatestRef(whileElementsMounted);
2202
2202
  const platformRef = useLatestRef(platform2);
2203
- const openRef = useLatestRef(open);
2203
+ const openRef = useLatestRef(open2);
2204
2204
  const update = reactExports.useCallback(() => {
2205
2205
  if (!referenceRef.current || !floatingRef.current) {
2206
2206
  return;
@@ -2231,14 +2231,14 @@ function useFloating(options) {
2231
2231
  });
2232
2232
  }, [latestMiddleware, placement, strategy, platformRef, openRef]);
2233
2233
  index$1(() => {
2234
- if (open === false && dataRef.current.isPositioned) {
2234
+ if (open2 === false && dataRef.current.isPositioned) {
2235
2235
  dataRef.current.isPositioned = false;
2236
2236
  setData((data2) => ({
2237
2237
  ...data2,
2238
2238
  isPositioned: false
2239
2239
  }));
2240
2240
  }
2241
- }, [open]);
2241
+ }, [open2]);
2242
2242
  const isMountedRef = reactExports.useRef(false);
2243
2243
  index$1(() => {
2244
2244
  isMountedRef.current = true;
@@ -2979,23 +2979,23 @@ var Tooltip$2 = (props) => {
2979
2979
  const disableHoverableContent = disableHoverableContentProp ?? providerContext.disableHoverableContent;
2980
2980
  const delayDuration = delayDurationProp ?? providerContext.delayDuration;
2981
2981
  const wasOpenDelayedRef = reactExports.useRef(false);
2982
- const [open, setOpen] = useControllableState({
2982
+ const [open2, setOpen] = useControllableState({
2983
2983
  prop: openProp,
2984
2984
  defaultProp: defaultOpen ?? false,
2985
- onChange: (open2) => {
2986
- if (open2) {
2985
+ onChange: (open22) => {
2986
+ if (open22) {
2987
2987
  providerContext.onOpen();
2988
2988
  document.dispatchEvent(new CustomEvent(TOOLTIP_OPEN));
2989
2989
  } else {
2990
2990
  providerContext.onClose();
2991
2991
  }
2992
- onOpenChange == null ? void 0 : onOpenChange(open2);
2992
+ onOpenChange == null ? void 0 : onOpenChange(open22);
2993
2993
  },
2994
2994
  caller: TOOLTIP_NAME
2995
2995
  });
2996
2996
  const stateAttribute = reactExports.useMemo(() => {
2997
- return open ? wasOpenDelayedRef.current ? "delayed-open" : "instant-open" : "closed";
2998
- }, [open]);
2997
+ return open2 ? wasOpenDelayedRef.current ? "delayed-open" : "instant-open" : "closed";
2998
+ }, [open2]);
2999
2999
  const handleOpen = reactExports.useCallback(() => {
3000
3000
  window.clearTimeout(openTimerRef.current);
3001
3001
  openTimerRef.current = 0;
@@ -3028,7 +3028,7 @@ var Tooltip$2 = (props) => {
3028
3028
  {
3029
3029
  scope: __scopeTooltip,
3030
3030
  contentId,
3031
- open,
3031
+ open: open2,
3032
3032
  stateAttribute,
3033
3033
  trigger,
3034
3034
  onTriggerChange: setTrigger,
@@ -15100,6 +15100,7 @@ const HookCreatedEventSchema = BaseEventSchema.extend({
15100
15100
  correlationId: string$2(),
15101
15101
  eventData: object({
15102
15102
  token: string$2(),
15103
+ tokenRetentionUntil: date().optional(),
15103
15104
  metadata: SerializedDataSchema.optional(),
15104
15105
  isWebhook: boolean$2().optional(),
15105
15106
  isSystem: boolean$2().optional()
@@ -15171,7 +15172,14 @@ const RunCreatedEventSchema = BaseEventSchema.extend({
15171
15172
  input: SerializedDataSchema,
15172
15173
  executionContext: record(string$2(), any()).optional(),
15173
15174
  attributes: record(string$2(), string$2()).optional(),
15174
- allowReservedAttributes: literal(true).optional()
15175
+ allowReservedAttributes: literal(true).optional(),
15176
+ /**
15177
+ * The run's X25519 public key (base64), stamped by SDKs that support
15178
+ * sealed (`encp`) envelopes. Persisted onto the run entity so that
15179
+ * cross-run writers can seal payloads to this run without holding its
15180
+ * symmetric key. Not secret — see `WorkflowRunBaseSchema`.
15181
+ */
15182
+ encryptionPublicKey: string$2().optional()
15175
15183
  })
15176
15184
  });
15177
15185
  const RunStartedEventSchema = BaseEventSchema.extend({
@@ -15182,7 +15190,14 @@ const RunStartedEventSchema = BaseEventSchema.extend({
15182
15190
  workflowName: string$2().optional(),
15183
15191
  executionContext: record(string$2(), any()).optional(),
15184
15192
  attributes: record(string$2(), string$2()).optional(),
15185
- allowReservedAttributes: literal(true).optional()
15193
+ allowReservedAttributes: literal(true).optional(),
15194
+ /**
15195
+ * Mirrors `run_created.eventData.encryptionPublicKey`. Carried here for
15196
+ * the resilient-start path: when the `run_created` write failed, the
15197
+ * server creates the run from this event instead, and without the key
15198
+ * the run would silently lose its ability to receive sealed writes.
15199
+ */
15200
+ encryptionPublicKey: string$2().optional()
15186
15201
  }).optional()
15187
15202
  });
15188
15203
  const RunCompletedEventSchema = BaseEventSchema.extend({
@@ -15344,6 +15359,26 @@ const WorkflowRunBaseSchema = object({
15344
15359
  * the attributes-mvp changelog entry.
15345
15360
  */
15346
15361
  attributes: record(string$2(), string$2()).default({}),
15362
+ /**
15363
+ * The run's X25519 public key, base64-encoded (~44 chars).
15364
+ *
15365
+ * Lets any party that can read this run seal a payload *to* it without
15366
+ * being able to read the run's data — used for cross-run writes such as a
15367
+ * hook resumption from another deployment, or a child workflow writing into
15368
+ * a forwarded stream. The matching private scalar is never stored: it is
15369
+ * re-derived on demand from the deployment's own key material, so this
15370
+ * field is not secret and its presence does not weaken the run's
15371
+ * confidentiality.
15372
+ *
15373
+ * Stamped at run creation by SDKs that support sealed (`encp`) envelopes.
15374
+ * **Presence is the writer-side gate**: a run only carries a public key if
15375
+ * the runtime that created it could also open sealed payloads, and runs are
15376
+ * pinned to their creating deployment. Writers therefore seal iff this
15377
+ * field is set, and otherwise fall back to fetching the symmetric per-run
15378
+ * key. Absent on runs created by older SDKs, and on worlds that do not
15379
+ * implement `getEncryptionKeyForRun` (encryption disabled).
15380
+ */
15381
+ encryptionPublicKey: string$2().optional(),
15347
15382
  expiredAt: date().optional(),
15348
15383
  startedAt: date().optional(),
15349
15384
  completedAt: date().optional(),
@@ -15548,22 +15583,8 @@ object({
15548
15583
  firstSeenAt: date(),
15549
15584
  lastSeenAt: date()
15550
15585
  });
15551
- object({
15552
- runId: string$2(),
15553
- hookId: string$2(),
15554
- token: string$2(),
15555
- ownerId: string$2(),
15556
- projectId: string$2(),
15557
- environment: string$2(),
15558
- metadata: SerializedDataSchema.optional(),
15559
- createdAt: date(),
15560
- // Optional in database for backwards compatibility, defaults to 1 (legacy) when reading
15561
- specVersion: number$3().optional(),
15562
- isWebhook: boolean$2().optional(),
15563
- isSystem: boolean$2().optional()
15564
- });
15565
- string$2().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_(?:workflow|step)_$/, "Must match __wkf_{workflow|step}_ or __{namespace}_wkf_{workflow|step}_");
15566
- string$2().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_(?:workflow|step)_.+$/, "Must be a valid queue name with a recognized prefix");
15586
+ string$2().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_workflow_$/, "Must match __wkf_workflow_ or __{namespace}_wkf_workflow_");
15587
+ string$2().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_workflow_.+$/, "Must be a valid queue name with a recognized prefix");
15567
15588
  string$2().regex(/^[a-z][a-z0-9]*$/, "Must be lowercase alphanumeric, starting with a letter");
15568
15589
  string$2().brand().describe("A stored queue message ID");
15569
15590
  const TraceCarrierSchema = record(string$2(), string$2());
@@ -15601,23 +15622,57 @@ const WorkflowInvokePayloadSchema = object({
15601
15622
  /** Run creation data, only present on the first queue delivery from start() */
15602
15623
  runInput: RunInputSchema.optional()
15603
15624
  });
15604
- const StepInvokePayloadSchema = object({
15605
- workflowName: string$2(),
15606
- workflowRunId: string$2(),
15607
- workflowStartedAt: number$3(),
15608
- stepId: string$2(),
15609
- traceCarrier: TraceCarrierSchema.optional(),
15610
- requestedAt: date().optional()
15611
- });
15612
15625
  const HealthCheckPayloadSchema = object({
15613
15626
  __healthCheck: literal(true),
15614
- correlationId: string$2()
15627
+ correlationId: string$2(),
15628
+ /**
15629
+ * The run id the caller is about to create, when the probe is being used to
15630
+ * prepare a cross-deployment `start()`.
15631
+ *
15632
+ * The responder runs inside the target deployment, so it can derive that
15633
+ * run's public key locally from its own key material and return it in the
15634
+ * probe response. That lets the caller seal the workflow arguments without
15635
+ * a separate key lookup. Absent for probes issued for other reasons (CLI
15636
+ * health command, dashboard), in which case no key is returned.
15637
+ */
15638
+ runId: string$2().optional()
15615
15639
  });
15616
15640
  union([
15617
- WorkflowInvokePayloadSchema,
15618
- StepInvokePayloadSchema,
15619
- HealthCheckPayloadSchema
15641
+ HealthCheckPayloadSchema,
15642
+ WorkflowInvokePayloadSchema
15620
15643
  ]);
15644
+ const HookResumeContextSchema = object({
15645
+ deploymentId: string$2(),
15646
+ workflowName: string$2(),
15647
+ // Named `runSpecVersion` to distinguish it from the hook's own `specVersion`.
15648
+ runSpecVersion: number$3().optional(),
15649
+ workflowCoreVersion: string$2().optional(),
15650
+ traceCarrier: TraceCarrierSchema.optional(),
15651
+ // The run's published X25519 public key (base64), mirrored from the run
15652
+ // entity. Lets a resume seal (`encp`) its payload to the run without reading
15653
+ // the run or fetching its symmetric key. Absent on runs created before
15654
+ // sealed envelopes and on projects with encryption disabled, where the
15655
+ // resume falls back to the symmetric per-run key.
15656
+ encryptionPublicKey: string$2().optional()
15657
+ });
15658
+ object({
15659
+ runId: string$2(),
15660
+ hookId: string$2(),
15661
+ token: string$2(),
15662
+ ownerId: string$2(),
15663
+ projectId: string$2(),
15664
+ environment: string$2(),
15665
+ metadata: SerializedDataSchema.optional(),
15666
+ createdAt: date(),
15667
+ // Optional in database for backwards compatibility, defaults to 1 (legacy) when reading
15668
+ specVersion: number$3().optional(),
15669
+ isWebhook: boolean$2().optional(),
15670
+ isSystem: boolean$2().optional(),
15671
+ // Present when the server stored it (new hooks) or synthesized it from the
15672
+ // run (old hooks). Absent only against an old server, where the resume path
15673
+ // falls back to `runs.get`.
15674
+ resumeContext: HookResumeContextSchema.optional()
15675
+ });
15621
15676
  const zodJsonSchema = lazy(() => {
15622
15677
  return union([
15623
15678
  string$2(),
@@ -15865,11 +15920,659 @@ function unflatten(parsed, revivers) {
15865
15920
  }
15866
15921
  return hydrate(0);
15867
15922
  }
15923
+ var ms$1;
15924
+ var hasRequiredMs;
15925
+ function requireMs() {
15926
+ if (hasRequiredMs) return ms$1;
15927
+ hasRequiredMs = 1;
15928
+ var s2 = 1e3;
15929
+ var m2 = s2 * 60;
15930
+ var h2 = m2 * 60;
15931
+ var d2 = h2 * 24;
15932
+ var w2 = d2 * 7;
15933
+ var y2 = d2 * 365.25;
15934
+ ms$1 = function(val, options) {
15935
+ options = options || {};
15936
+ var type = typeof val;
15937
+ if (type === "string" && val.length > 0) {
15938
+ return parse2(val);
15939
+ } else if (type === "number" && isFinite(val)) {
15940
+ return options.long ? fmtLong(val) : fmtShort(val);
15941
+ }
15942
+ throw new Error(
15943
+ "val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
15944
+ );
15945
+ };
15946
+ function parse2(str) {
15947
+ str = String(str);
15948
+ if (str.length > 100) {
15949
+ return;
15950
+ }
15951
+ var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
15952
+ str
15953
+ );
15954
+ if (!match) {
15955
+ return;
15956
+ }
15957
+ var n = parseFloat(match[1]);
15958
+ var type = (match[2] || "ms").toLowerCase();
15959
+ switch (type) {
15960
+ case "years":
15961
+ case "year":
15962
+ case "yrs":
15963
+ case "yr":
15964
+ case "y":
15965
+ return n * y2;
15966
+ case "weeks":
15967
+ case "week":
15968
+ case "w":
15969
+ return n * w2;
15970
+ case "days":
15971
+ case "day":
15972
+ case "d":
15973
+ return n * d2;
15974
+ case "hours":
15975
+ case "hour":
15976
+ case "hrs":
15977
+ case "hr":
15978
+ case "h":
15979
+ return n * h2;
15980
+ case "minutes":
15981
+ case "minute":
15982
+ case "mins":
15983
+ case "min":
15984
+ case "m":
15985
+ return n * m2;
15986
+ case "seconds":
15987
+ case "second":
15988
+ case "secs":
15989
+ case "sec":
15990
+ case "s":
15991
+ return n * s2;
15992
+ case "milliseconds":
15993
+ case "millisecond":
15994
+ case "msecs":
15995
+ case "msec":
15996
+ case "ms":
15997
+ return n;
15998
+ default:
15999
+ return void 0;
16000
+ }
16001
+ }
16002
+ function fmtShort(ms2) {
16003
+ var msAbs = Math.abs(ms2);
16004
+ if (msAbs >= d2) {
16005
+ return Math.round(ms2 / d2) + "d";
16006
+ }
16007
+ if (msAbs >= h2) {
16008
+ return Math.round(ms2 / h2) + "h";
16009
+ }
16010
+ if (msAbs >= m2) {
16011
+ return Math.round(ms2 / m2) + "m";
16012
+ }
16013
+ if (msAbs >= s2) {
16014
+ return Math.round(ms2 / s2) + "s";
16015
+ }
16016
+ return ms2 + "ms";
16017
+ }
16018
+ function fmtLong(ms2) {
16019
+ var msAbs = Math.abs(ms2);
16020
+ if (msAbs >= d2) {
16021
+ return plural(ms2, msAbs, d2, "day");
16022
+ }
16023
+ if (msAbs >= h2) {
16024
+ return plural(ms2, msAbs, h2, "hour");
16025
+ }
16026
+ if (msAbs >= m2) {
16027
+ return plural(ms2, msAbs, m2, "minute");
16028
+ }
16029
+ if (msAbs >= s2) {
16030
+ return plural(ms2, msAbs, s2, "second");
16031
+ }
16032
+ return ms2 + " ms";
16033
+ }
16034
+ function plural(ms2, msAbs, n, name2) {
16035
+ var isPlural = msAbs >= n * 1.5;
16036
+ return Math.round(ms2 / n) + " " + name2 + (isPlural ? "s" : "");
16037
+ }
16038
+ return ms$1;
16039
+ }
16040
+ var msExports = requireMs();
16041
+ const ms = /* @__PURE__ */ getDefaultExportFromCjs(msExports);
16042
+ function parseDurationToDate(param) {
16043
+ if (typeof param === "string") {
16044
+ const durationMs = ms(param);
16045
+ if (typeof durationMs !== "number" || durationMs < 0) {
16046
+ throw new Error(`Invalid duration: "${param}". Expected a valid duration string like "1s", "1m", "1h", etc.`);
16047
+ }
16048
+ return new Date(Date.now() + durationMs);
16049
+ } else if (typeof param === "number") {
16050
+ if (param < 0 || !Number.isFinite(param)) {
16051
+ throw new Error(`Invalid duration: ${param}. Expected a non-negative finite number of milliseconds.`);
16052
+ }
16053
+ return new Date(Date.now() + param);
16054
+ } else if (param instanceof Date || param && typeof param === "object" && typeof param.getTime === "function") {
16055
+ return param instanceof Date ? param : new Date(param.getTime());
16056
+ } else {
16057
+ throw new Error(`Invalid duration parameter. Expected a duration string, number (milliseconds), or Date object.`);
16058
+ }
16059
+ }
16060
+ const BASE_URL = "https://workflow-sdk.dev/err";
16061
+ function isError(value) {
16062
+ return typeof value === "object" && value !== null && "name" in value && "message" in value;
16063
+ }
16064
+ function appendFramedDetails(title, details) {
16065
+ if (details.length === 0)
16066
+ return title;
16067
+ const lines = [title];
16068
+ details.forEach((detail, index2) => {
16069
+ const isLast = index2 === details.length - 1;
16070
+ const head = isLast ? "╰▶ " : "├▶ ";
16071
+ const cont = isLast ? " " : "│ ";
16072
+ const text2 = `${detail.label}: ${detail.value}`;
16073
+ text2.split("\n").forEach((line, i) => lines.push(`${i === 0 ? head : cont}${line}`));
16074
+ });
16075
+ return lines.join("\n");
16076
+ }
16077
+ function buildFramedDetails(hint, slug) {
16078
+ const out = [];
16079
+ if (slug)
16080
+ out.push({ label: "docs", value: `${BASE_URL}/${slug}` });
16081
+ return out;
16082
+ }
16083
+ const ERROR_SLUGS = {
16084
+ HOOK_CONFLICT: "hook-conflict",
16085
+ RUNTIME_DECRYPTION_FAILED: "runtime-decryption-failed"
16086
+ };
16087
+ class WorkflowError extends Error {
16088
+ constructor(message, options) {
16089
+ const msgDocs = appendFramedDetails(message, buildFramedDetails(void 0, options == null ? void 0 : options.slug));
16090
+ super(msgDocs, { cause: options == null ? void 0 : options.cause });
16091
+ __publicField(this, "cause");
16092
+ if ((options == null ? void 0 : options.cause) !== void 0) {
16093
+ this.cause = options.cause;
16094
+ }
16095
+ if ((options == null ? void 0 : options.cause) instanceof Error) {
16096
+ this.stack = `${this.stack}
16097
+ Caused by: ${options.cause.stack}`;
16098
+ }
16099
+ }
16100
+ static is(value) {
16101
+ return isError(value) && value.name === "WorkflowError";
16102
+ }
16103
+ }
16104
+ class WorkflowRuntimeError extends WorkflowError {
16105
+ constructor(message, options) {
16106
+ super(message, {
16107
+ ...options
16108
+ });
16109
+ this.name = "WorkflowRuntimeError";
16110
+ }
16111
+ static is(value) {
16112
+ return isError(value) && value.name === "WorkflowRuntimeError";
16113
+ }
16114
+ }
16115
+ class RuntimeDecryptionError extends WorkflowRuntimeError {
16116
+ constructor(message, options) {
16117
+ super(message, {
16118
+ cause: options == null ? void 0 : options.cause,
16119
+ slug: ERROR_SLUGS.RUNTIME_DECRYPTION_FAILED
16120
+ });
16121
+ this.name = "RuntimeDecryptionError";
16122
+ if ((options == null ? void 0 : options.context) !== void 0) {
16123
+ this.context = options.context;
16124
+ }
16125
+ }
16126
+ static is(value) {
16127
+ return isError(value) && value.name === "RuntimeDecryptionError";
16128
+ }
16129
+ }
16130
+ class HookConflictError extends WorkflowError {
16131
+ constructor(token, conflictingRunId) {
16132
+ super(`Hook token "${token}" is already in use by another workflow${conflictingRunId ? ` (run "${conflictingRunId}")` : ""}`, {
16133
+ slug: ERROR_SLUGS.HOOK_CONFLICT
16134
+ });
16135
+ __publicField(this, "token");
16136
+ // TODO: Make this required once all persisted hook_conflict events and World
16137
+ // implementations always include the active hook owner's run ID.
16138
+ __publicField(this, "conflictingRunId");
16139
+ this.name = "HookConflictError";
16140
+ this.token = token;
16141
+ if (conflictingRunId !== void 0) {
16142
+ this.conflictingRunId = conflictingRunId;
16143
+ }
16144
+ }
16145
+ static is(value) {
16146
+ return isError(value) && value.name === "HookConflictError";
16147
+ }
16148
+ }
16149
+ class FatalError extends Error {
16150
+ constructor(message) {
16151
+ super(message);
16152
+ __publicField(this, "fatal", true);
16153
+ this.name = "FatalError";
16154
+ }
16155
+ static is(value) {
16156
+ if (!isError(value))
16157
+ return false;
16158
+ if (value.name === "FatalError")
16159
+ return true;
16160
+ return value.fatal === true;
16161
+ }
16162
+ }
16163
+ class RetryableError extends Error {
16164
+ constructor(message, options = {}) {
16165
+ super(message);
16166
+ /**
16167
+ * The Date when the step should be retried.
16168
+ */
16169
+ __publicField(this, "retryAfter");
16170
+ this.name = "RetryableError";
16171
+ if (options.retryAfter !== void 0) {
16172
+ this.retryAfter = parseDurationToDate(options.retryAfter);
16173
+ } else {
16174
+ this.retryAfter = new Date(Date.now() + 1e3);
16175
+ }
16176
+ }
16177
+ static is(value) {
16178
+ return isError(value) && value.name === "RetryableError";
16179
+ }
16180
+ }
16181
+ const VERCEL_403_ERROR_MESSAGE = "Your current vercel account does not have access to this resource. Use `vercel login` or `vercel switch` to ensure you are linked to the right account.";
16182
+ const FATAL_ERROR_KEY = Symbol.for("@workflow/errors//FatalError");
16183
+ const RETRYABLE_ERROR_KEY = Symbol.for("@workflow/errors//RetryableError");
16184
+ const HOOK_CONFLICT_ERROR_KEY = Symbol.for("@workflow/errors//HookConflictError");
16185
+ const RUNTIME_DECRYPTION_ERROR_KEY = Symbol.for("@workflow/errors//RuntimeDecryptionError");
16186
+ if (typeof globalThis !== "undefined") {
16187
+ if (!Object.hasOwn(globalThis, FATAL_ERROR_KEY)) {
16188
+ Object.defineProperty(globalThis, FATAL_ERROR_KEY, {
16189
+ value: FatalError,
16190
+ writable: false,
16191
+ enumerable: false,
16192
+ configurable: false
16193
+ });
16194
+ }
16195
+ if (!Object.hasOwn(globalThis, RETRYABLE_ERROR_KEY)) {
16196
+ Object.defineProperty(globalThis, RETRYABLE_ERROR_KEY, {
16197
+ value: RetryableError,
16198
+ writable: false,
16199
+ enumerable: false,
16200
+ configurable: false
16201
+ });
16202
+ }
16203
+ if (!Object.hasOwn(globalThis, HOOK_CONFLICT_ERROR_KEY)) {
16204
+ Object.defineProperty(globalThis, HOOK_CONFLICT_ERROR_KEY, {
16205
+ value: HookConflictError,
16206
+ writable: false,
16207
+ enumerable: false,
16208
+ configurable: false
16209
+ });
16210
+ }
16211
+ if (!Object.hasOwn(globalThis, RUNTIME_DECRYPTION_ERROR_KEY)) {
16212
+ Object.defineProperty(globalThis, RUNTIME_DECRYPTION_ERROR_KEY, {
16213
+ value: RuntimeDecryptionError,
16214
+ writable: false,
16215
+ enumerable: false,
16216
+ configurable: false
16217
+ });
16218
+ }
16219
+ }
16220
+ const NONCE_LENGTH = 12;
16221
+ const TAG_LENGTH = 128;
16222
+ const TAG_BYTES = TAG_LENGTH / 8;
16223
+ const KEY_LENGTH = 32;
16224
+ async function importKey(raw2, usages = ["encrypt", "decrypt"]) {
16225
+ if (raw2.byteLength !== KEY_LENGTH) {
16226
+ throw new WorkflowRuntimeError(`Encryption key must be exactly ${KEY_LENGTH} bytes, got ${raw2.byteLength}`);
16227
+ }
16228
+ return globalThis.crypto.subtle.importKey(
16229
+ "raw",
16230
+ raw2,
16231
+ "AES-GCM",
16232
+ false,
16233
+ // `KeyUsage` is a DOM-lib type that's not in scope under `es2022`.
16234
+ // The `ReadonlyArray<'encrypt' | 'decrypt'>` parameter type matches
16235
+ // a strict subset of `KeyUsage[]`, so this cast is sound.
16236
+ usages
16237
+ );
16238
+ }
16239
+ async function decrypt$1(key, data, aad) {
16240
+ const minLength = NONCE_LENGTH + TAG_LENGTH / 8;
16241
+ if (data.byteLength < minLength) {
16242
+ throw new RuntimeDecryptionError(`Encrypted data too short: expected at least ${minLength} bytes, got ${data.byteLength}`, {
16243
+ context: {
16244
+ operation: "decrypt",
16245
+ byteLength: data.byteLength
16246
+ }
16247
+ });
16248
+ }
16249
+ const nonce = data.subarray(0, NONCE_LENGTH);
16250
+ const ciphertext = data.subarray(NONCE_LENGTH);
16251
+ let plaintext;
16252
+ try {
16253
+ plaintext = await globalThis.crypto.subtle.decrypt({
16254
+ name: "AES-GCM",
16255
+ iv: nonce,
16256
+ tagLength: TAG_LENGTH,
16257
+ ...aad ? { additionalData: aad } : {}
16258
+ }, key, ciphertext);
16259
+ } catch (cause) {
16260
+ const causeMsg = cause instanceof Error ? cause.message : String(cause);
16261
+ throw new RuntimeDecryptionError(`AES-256-GCM decryption failed: ${causeMsg}`, {
16262
+ cause,
16263
+ context: {
16264
+ operation: "decrypt",
16265
+ byteLength: data.byteLength
16266
+ }
16267
+ });
16268
+ }
16269
+ return new Uint8Array(plaintext);
16270
+ }
16271
+ const X25519_KEY_LENGTH = 32;
16272
+ const CONTENT_KEY_LENGTH = 32;
16273
+ const SCALAR_INFO = "workflow/encp/x25519/v1";
16274
+ const CONTENT_KEY_INFO = "workflow/encp/aes256gcm/v1";
16275
+ const PKCS8_X25519_PREFIX = new Uint8Array([
16276
+ 48,
16277
+ 46,
16278
+ 2,
16279
+ 1,
16280
+ 0,
16281
+ 48,
16282
+ 5,
16283
+ 6,
16284
+ 3,
16285
+ 43,
16286
+ 101,
16287
+ 110,
16288
+ 4,
16289
+ 34,
16290
+ 4,
16291
+ 32
16292
+ ]);
16293
+ const infoEncoder = new TextEncoder();
16294
+ function assertKeyMaterialLength(runKeyMaterial) {
16295
+ if (runKeyMaterial.byteLength !== CONTENT_KEY_LENGTH) {
16296
+ throw new WorkflowRuntimeError(`Run key material must be exactly ${CONTENT_KEY_LENGTH} bytes, got ${runKeyMaterial.byteLength}`);
16297
+ }
16298
+ }
16299
+ async function deriveRunKeyPair(runKeyMaterial) {
16300
+ assertKeyMaterialLength(runKeyMaterial);
16301
+ const hkdfKey = await globalThis.crypto.subtle.importKey("raw", runKeyMaterial, "HKDF", false, ["deriveBits"]);
16302
+ const scalarBits = await globalThis.crypto.subtle.deriveBits({
16303
+ name: "HKDF",
16304
+ hash: "SHA-256",
16305
+ salt: new Uint8Array(32),
16306
+ info: infoEncoder.encode(SCALAR_INFO)
16307
+ }, hkdfKey, X25519_KEY_LENGTH * 8);
16308
+ const scalar = new Uint8Array(scalarBits);
16309
+ const publicKey = await derivePublicKeyFromScalar(scalar);
16310
+ return { scalar, publicKey };
16311
+ }
16312
+ async function derivePublicKeyFromScalar(scalar) {
16313
+ const privateKey = await importScalar(
16314
+ scalar,
16315
+ /* extractable */
16316
+ true
16317
+ );
16318
+ const jwk = await globalThis.crypto.subtle.exportKey("jwk", privateKey);
16319
+ if (!jwk.x) {
16320
+ throw new WorkflowRuntimeError('X25519 JWK export did not include a public key component ("x")');
16321
+ }
16322
+ const publicKey = base64UrlToBytes(jwk.x);
16323
+ if (publicKey.byteLength !== X25519_KEY_LENGTH) {
16324
+ throw new WorkflowRuntimeError(`X25519 JWK export produced a ${publicKey.byteLength}-byte public key, expected ${X25519_KEY_LENGTH}`);
16325
+ }
16326
+ return publicKey;
16327
+ }
16328
+ async function importScalar(scalar, extractable) {
16329
+ const pkcs8 = new Uint8Array(PKCS8_X25519_PREFIX.length + scalar.byteLength);
16330
+ pkcs8.set(PKCS8_X25519_PREFIX, 0);
16331
+ pkcs8.set(scalar, PKCS8_X25519_PREFIX.length);
16332
+ return globalThis.crypto.subtle.importKey("pkcs8", pkcs8, { name: "X25519" }, extractable, ["deriveBits"]);
16333
+ }
16334
+ function importPublicKey(publicKey) {
16335
+ return globalThis.crypto.subtle.importKey(
16336
+ "raw",
16337
+ publicKey,
16338
+ { name: "X25519" },
16339
+ /* extractable */
16340
+ true,
16341
+ // Public keys carry no usages for X25519 — the private key does the
16342
+ // deriving; the public key is only ever an argument to it.
16343
+ []
16344
+ );
16345
+ }
16346
+ const BASE64URL_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
16347
+ function base64UrlToBytes(value) {
16348
+ let accumulator = 0;
16349
+ let bitCount = 0;
16350
+ const bytes = [];
16351
+ for (let i = 0; i < value.length; i++) {
16352
+ const char = value[i];
16353
+ if (char === "=")
16354
+ break;
16355
+ const index2 = BASE64URL_CHARS.indexOf(char);
16356
+ if (index2 === -1) {
16357
+ throw new WorkflowRuntimeError(`Invalid base64url character "${char}" in X25519 JWK key component`);
16358
+ }
16359
+ accumulator = accumulator << 6 | index2;
16360
+ bitCount += 6;
16361
+ if (bitCount >= 8) {
16362
+ bitCount -= 8;
16363
+ bytes.push(accumulator >> bitCount & 255);
16364
+ }
16365
+ }
16366
+ return new Uint8Array(bytes);
16367
+ }
16368
+ async function deriveContentKey(sharedSecret, ephemeralPublicKey, recipientPublicKey, usages) {
16369
+ const label = infoEncoder.encode(CONTENT_KEY_INFO);
16370
+ const info = new Uint8Array(label.length + ephemeralPublicKey.length + recipientPublicKey.length);
16371
+ info.set(label, 0);
16372
+ info.set(ephemeralPublicKey, label.length);
16373
+ info.set(recipientPublicKey, label.length + ephemeralPublicKey.length);
16374
+ const hkdfKey = await globalThis.crypto.subtle.importKey("raw", sharedSecret, "HKDF", false, ["deriveBits"]);
16375
+ const contentKeyBits = await globalThis.crypto.subtle.deriveBits({ name: "HKDF", hash: "SHA-256", salt: new Uint8Array(32), info }, hkdfKey, CONTENT_KEY_LENGTH * 8);
16376
+ return globalThis.crypto.subtle.importKey(
16377
+ "raw",
16378
+ new Uint8Array(contentKeyBits),
16379
+ "AES-GCM",
16380
+ false,
16381
+ // `KeyUsage` is a DOM-lib type that is not in scope under `es2022`; the
16382
+ // parameter type is a strict subset of it, so this cast is sound.
16383
+ usages
16384
+ );
16385
+ }
16386
+ async function decapsulate(keyPair, ephemeralPublicKey) {
16387
+ if (ephemeralPublicKey.byteLength !== X25519_KEY_LENGTH) {
16388
+ throw new RuntimeDecryptionError(`Sealed payload has a malformed ephemeral public key: expected ${X25519_KEY_LENGTH} bytes, got ${ephemeralPublicKey.byteLength}`, {
16389
+ context: {
16390
+ operation: "decrypt",
16391
+ byteLength: ephemeralPublicKey.byteLength
16392
+ }
16393
+ });
16394
+ }
16395
+ let sharedSecretBits;
16396
+ try {
16397
+ const [privateKey, senderKey] = await Promise.all([
16398
+ importScalar(
16399
+ keyPair.scalar,
16400
+ /* extractable */
16401
+ false
16402
+ ),
16403
+ importPublicKey(ephemeralPublicKey)
16404
+ ]);
16405
+ sharedSecretBits = await globalThis.crypto.subtle.deriveBits({ name: "X25519", public: senderKey }, privateKey, X25519_KEY_LENGTH * 8);
16406
+ } catch (cause) {
16407
+ throw new RuntimeDecryptionError(`X25519 key agreement failed while opening a sealed payload: ${cause instanceof Error ? cause.message : String(cause)}`, {
16408
+ cause,
16409
+ context: {
16410
+ operation: "decrypt",
16411
+ byteLength: ephemeralPublicKey.byteLength
16412
+ }
16413
+ });
16414
+ }
16415
+ return deriveContentKey(new Uint8Array(sharedSecretBits), ephemeralPublicKey, keyPair.publicKey, ["decrypt"]);
16416
+ }
16417
+ async function open(keyPair, sealed, aad) {
16418
+ const minLength = X25519_KEY_LENGTH + NONCE_LENGTH + TAG_BYTES;
16419
+ if (sealed.byteLength < minLength) {
16420
+ throw new RuntimeDecryptionError(`Sealed payload too short: expected at least ${minLength} bytes, got ${sealed.byteLength}`, { context: { operation: "decrypt", byteLength: sealed.byteLength } });
16421
+ }
16422
+ const ephemeralPublicKey = sealed.subarray(0, X25519_KEY_LENGTH);
16423
+ const encrypted = sealed.subarray(X25519_KEY_LENGTH);
16424
+ const contentKey = await decapsulate(keyPair, ephemeralPublicKey);
16425
+ return decrypt$1(contentKey, encrypted, aad);
16426
+ }
16427
+ function isFormatPrefix(value) {
16428
+ return value.length === 4 && /^[a-z0-9]{4}$/.test(value);
16429
+ }
16430
+ const SerializationFormat$1 = {
16431
+ /** devalue stringify/parse with TextEncoder/TextDecoder */
16432
+ DEVALUE_V1: "devl",
16433
+ /** Encrypted payload (inner payload has its own format prefix) */
16434
+ ENCRYPTED: "encr",
16435
+ /**
16436
+ * Sealed payload — asymmetrically encrypted to a run's X25519 public key
16437
+ * (inner payload has its own format prefix).
16438
+ *
16439
+ * Used for *cross-run* writes (hook payloads, forwarded stream frames),
16440
+ * where the writer holds only the recipient run's public key and therefore
16441
+ * cannot decrypt. A run's own payloads continue to use {@link ENCRYPTED}.
16442
+ * See `sealed-box.ts` for the construction.
16443
+ */
16444
+ SEALED: "encp"
16445
+ };
16446
+ const FORMAT_PREFIX_LENGTH$1 = 4;
16447
+ new TextEncoder();
16448
+ const formatDecoder$1 = new TextDecoder();
16449
+ function peekFormatPrefix(data) {
16450
+ if (!(data instanceof Uint8Array) || data.length < FORMAT_PREFIX_LENGTH$1) {
16451
+ return null;
16452
+ }
16453
+ const prefixBytes = data.subarray(0, FORMAT_PREFIX_LENGTH$1);
16454
+ const str = formatDecoder$1.decode(prefixBytes);
16455
+ return isFormatPrefix(str) ? str : null;
16456
+ }
16457
+ function decodeFormatPrefix$1(data) {
16458
+ if (!(data instanceof Uint8Array)) {
16459
+ return {
16460
+ format: SerializationFormat$1.DEVALUE_V1,
16461
+ payload: new TextEncoder().encode(JSON.stringify(data))
16462
+ };
16463
+ }
16464
+ if (data.length < FORMAT_PREFIX_LENGTH$1) {
16465
+ throw new Error(`Data too short to contain format prefix: expected at least ${FORMAT_PREFIX_LENGTH$1} bytes, got ${data.length}`);
16466
+ }
16467
+ const prefixBytes = data.subarray(0, FORMAT_PREFIX_LENGTH$1);
16468
+ const str = formatDecoder$1.decode(prefixBytes);
16469
+ if (!isFormatPrefix(str)) {
16470
+ throw new Error(`Invalid format prefix: "${str}". Must be 4 characters of [a-z0-9].`);
16471
+ }
16472
+ const payload = data.subarray(FORMAT_PREFIX_LENGTH$1);
16473
+ return { format: str, payload };
16474
+ }
16475
+ const SEAL_TARGET_BRAND = Symbol.for("workflow.serialization.sealTarget");
16476
+ const RUN_KEYS_BRAND = Symbol.for("workflow.serialization.runKeys");
16477
+ function runPayloadKeys(aes, keyPair, aad) {
16478
+ return { [RUN_KEYS_BRAND]: true, aes, keyPair, aad };
16479
+ }
16480
+ async function deriveRunPayloadKeys(runKeyMaterial) {
16481
+ const [aes, keyPair] = await Promise.all([
16482
+ importKey(runKeyMaterial),
16483
+ deriveRunKeyPair(runKeyMaterial)
16484
+ ]);
16485
+ return runPayloadKeys(aes, keyPair);
16486
+ }
16487
+ function isSealTarget(value) {
16488
+ return typeof value === "object" && value !== null && value[SEAL_TARGET_BRAND] === true;
16489
+ }
16490
+ function isRunPayloadKeys(value) {
16491
+ return typeof value === "object" && value !== null && value[RUN_KEYS_BRAND] === true;
16492
+ }
16493
+ function aesKeyOf(key) {
16494
+ if (!key)
16495
+ return void 0;
16496
+ if (isRunPayloadKeys(key))
16497
+ return key.aes;
16498
+ if (isSealTarget(key))
16499
+ return void 0;
16500
+ return key;
16501
+ }
16502
+ async function openSealedEnvelope(data, key) {
16503
+ if (!isRunPayloadKeys(key)) {
16504
+ throw new RuntimeDecryptionError("Sealed data encountered but no run keypair is available. Opening a sealed payload requires the run's own encryption key material; a symmetric key or a seal-only target cannot decrypt it.", {
16505
+ context: {
16506
+ operation: "decrypt",
16507
+ byteLength: data.byteLength,
16508
+ formatPrefix: "encp"
16509
+ }
16510
+ });
16511
+ }
16512
+ const { payload } = decodeFormatPrefix$1(data);
16513
+ try {
16514
+ return await open(key.keyPair, payload, key.aad);
16515
+ } catch (error) {
16516
+ if (RuntimeDecryptionError.is(error) && error.context) {
16517
+ error.context.formatPrefix = SerializationFormat$1.SEALED;
16518
+ }
16519
+ throw error;
16520
+ }
16521
+ }
16522
+ async function decrypt(data, key) {
16523
+ if (!(data instanceof Uint8Array))
16524
+ return data;
16525
+ const format = peekFormatPrefix(data);
16526
+ if (format === SerializationFormat$1.SEALED) {
16527
+ return openSealedEnvelope(data, key);
16528
+ }
16529
+ if (format !== SerializationFormat$1.ENCRYPTED)
16530
+ return data;
16531
+ const aesKey = aesKeyOf(key);
16532
+ if (!aesKey) {
16533
+ throw new RuntimeDecryptionError("Encrypted data encountered but no encryption key is available. Encryption is not configured or no key was provided for this run.", {
16534
+ context: {
16535
+ operation: "decrypt",
16536
+ byteLength: data.byteLength,
16537
+ formatPrefix: "encr"
16538
+ }
16539
+ });
16540
+ }
16541
+ const { payload } = decodeFormatPrefix$1(data);
16542
+ try {
16543
+ return await decrypt$1(aesKey, payload);
16544
+ } catch (error) {
16545
+ if (RuntimeDecryptionError.is(error) && error.context) {
16546
+ error.context.formatPrefix = format;
16547
+ }
16548
+ throw error;
16549
+ }
16550
+ }
16551
+ const encryption = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
16552
+ __proto__: null,
16553
+ aesKeyOf,
16554
+ decrypt,
16555
+ deriveRunPayloadKeys,
16556
+ isRunPayloadKeys,
16557
+ isSealTarget,
16558
+ runPayloadKeys
16559
+ }, Symbol.toStringTag, { value: "Module" }));
15868
16560
  const SerializationFormat = {
15869
16561
  /** devalue stringify/parse with TextEncoder/TextDecoder */
15870
16562
  DEVALUE_V1: "devl",
15871
16563
  /** Encrypted payload (inner payload has its own format prefix after decryption) */
15872
16564
  ENCRYPTED: "encr",
16565
+ /**
16566
+ * Sealed payload — asymmetrically encrypted to a run's X25519 public key
16567
+ * (inner payload has its own format prefix after opening).
16568
+ *
16569
+ * Written by cross-run writers that hold only the recipient run's public
16570
+ * key. Opening it requires the run's private scalar rather than the
16571
+ * symmetric per-run key, so o11y display treats it as ciphertext via
16572
+ * {@link isEncryptedData} but {@link hydrateDataWithKey} does not attempt
16573
+ * an AES-GCM decrypt on it.
16574
+ */
16575
+ SEALED: "encp",
15873
16576
  /** Gzip-compressed payload (inner payload has its own format prefix after decompression) */
15874
16577
  GZIP: "gzip",
15875
16578
  /** Zstandard-compressed payload (inner payload has its own format prefix after decompression) */
@@ -15917,7 +16620,14 @@ function isEncryptedData(data) {
15917
16620
  return false;
15918
16621
  }
15919
16622
  const prefix = formatDecoder.decode(data.subarray(0, FORMAT_PREFIX_LENGTH));
15920
- return prefix === SerializationFormat.ENCRYPTED;
16623
+ return prefix === SerializationFormat.ENCRYPTED || prefix === SerializationFormat.SEALED;
16624
+ }
16625
+ function isSealedData(data) {
16626
+ if (!(data instanceof Uint8Array) || data.length < FORMAT_PREFIX_LENGTH) {
16627
+ return false;
16628
+ }
16629
+ const prefix = formatDecoder.decode(data.subarray(0, FORMAT_PREFIX_LENGTH));
16630
+ return prefix === SerializationFormat.SEALED;
15921
16631
  }
15922
16632
  function isCompressedData(data) {
15923
16633
  if (!(data instanceof Uint8Array) || data.length < FORMAT_PREFIX_LENGTH) {
@@ -16011,12 +16721,13 @@ function hydrateData(value, revivers) {
16011
16721
  async function hydrateDataWithKey(value, revivers, key) {
16012
16722
  let data = value;
16013
16723
  if (data instanceof Uint8Array && isEncryptedData(data) && key) {
16014
- const { decrypt } = await __vitePreload(async () => {
16015
- const { decrypt: decrypt2 } = await import("./encryption-CLVP4klT.js");
16016
- return { decrypt: decrypt2 };
16017
- }, true ? __vite__mapDeps([0,1,2]) : void 0);
16018
- const { payload } = decodeFormatPrefix(data);
16019
- data = await decrypt(key, payload);
16724
+ const { decrypt: decrypt2, isRunPayloadKeys: isRunPayloadKeys2 } = await __vitePreload(async () => {
16725
+ const { decrypt: decrypt3, isRunPayloadKeys: isRunPayloadKeys3 } = await Promise.resolve().then(() => encryption);
16726
+ return { decrypt: decrypt3, isRunPayloadKeys: isRunPayloadKeys3 };
16727
+ }, true ? void 0 : void 0);
16728
+ if (!isSealedData(data) || isRunPayloadKeys2(key)) {
16729
+ data = await decrypt2(data, key);
16730
+ }
16020
16731
  }
16021
16732
  if (data instanceof Uint8Array && isCompressedData(data)) {
16022
16733
  const { format, payload } = decodeFormatPrefix(data);
@@ -16243,6 +16954,8 @@ const serializationFormat = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object
16243
16954
  STREAM_REF_TYPE: STREAM_REF_TYPE$1,
16244
16955
  SerializationFormat,
16245
16956
  decodeFormatPrefix,
16957
+ decryptEnvelope: decrypt,
16958
+ deriveRunPayloadKeys,
16246
16959
  extractClassName,
16247
16960
  hydrateData,
16248
16961
  hydrateDataWithKey,
@@ -16250,9 +16963,13 @@ const serializationFormat = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object
16250
16963
  isCompressedData,
16251
16964
  isEncryptedData,
16252
16965
  isExpiredStub,
16966
+ isRunPayloadKeys,
16253
16967
  isRunRef: isRunRef$1,
16968
+ isSealTarget,
16969
+ isSealedData,
16254
16970
  observabilityRevivers,
16255
16971
  registerZstdDecoder,
16972
+ runPayloadKeys,
16256
16973
  serializedClassToString,
16257
16974
  serializedInstanceToRef,
16258
16975
  serializedRunToRunRef,
@@ -16532,19 +17249,16 @@ function replaceEncryptedAndExpiredWithMarkers(resource) {
16532
17249
  return result;
16533
17250
  }
16534
17251
  async function hydrateResourceIOAsync(resource, key) {
16535
- const { hydrateDataWithKey: hydrateDataWithKey2 } = await __vitePreload(async () => {
16536
- const { hydrateDataWithKey: hydrateDataWithKey3 } = await Promise.resolve().then(() => serializationFormat);
16537
- return { hydrateDataWithKey: hydrateDataWithKey3 };
17252
+ const { hydrateDataWithKey: hydrateDataWithKey2, deriveRunPayloadKeys: deriveRunPayloadKeys2 } = await __vitePreload(async () => {
17253
+ const { hydrateDataWithKey: hydrateDataWithKey3, deriveRunPayloadKeys: deriveRunPayloadKeys3 } = await Promise.resolve().then(() => serializationFormat);
17254
+ return { hydrateDataWithKey: hydrateDataWithKey3, deriveRunPayloadKeys: deriveRunPayloadKeys3 };
16538
17255
  }, true ? void 0 : void 0);
16539
17256
  const { ensureZstdDecoderRegistered } = await __vitePreload(async () => {
16540
- const { ensureZstdDecoderRegistered: ensureZstdDecoderRegistered2 } = await import("./zstd-browser-decoder-B6lDon6D.js");
17257
+ const { ensureZstdDecoderRegistered: ensureZstdDecoderRegistered2 } = await import("./zstd-browser-decoder-BAY5XtBl.js");
16541
17258
  return { ensureZstdDecoderRegistered: ensureZstdDecoderRegistered2 };
16542
- }, true ? __vite__mapDeps([3,2]) : void 0);
17259
+ }, true ? __vite__mapDeps([0,1]) : void 0);
16543
17260
  ensureZstdDecoderRegistered();
16544
- const cryptoKey = key ? await __vitePreload(async () => {
16545
- const { importKey } = await import("./encryption-CLVP4klT.js");
16546
- return { importKey };
16547
- }, true ? __vite__mapDeps([0,1,2]) : void 0).then(({ importKey }) => importKey(key)) : void 0;
17261
+ const cryptoKey = key ? await deriveRunPayloadKeys2(key) : void 0;
16548
17262
  const revivers = getRevivers();
16549
17263
  async function hydrateField(value) {
16550
17264
  if (isEncryptedMarker$1(value)) {
@@ -17688,15 +18402,15 @@ const MS_IN_SECOND$1 = 1e3;
17688
18402
  const MS_IN_MINUTE = 60 * MS_IN_SECOND$1;
17689
18403
  const MS_IN_HOUR = 60 * MS_IN_MINUTE;
17690
18404
  const MS_IN_DAY = 24 * MS_IN_HOUR;
17691
- function formatDuration(ms, compact = false) {
17692
- if (ms === 0) {
18405
+ function formatDuration(ms2, compact = false) {
18406
+ if (ms2 === 0) {
17693
18407
  return "0s";
17694
18408
  }
17695
- if (ms < MS_IN_SECOND$1) {
17696
- const roundedMs2 = Math.round(ms);
18409
+ if (ms2 < MS_IN_SECOND$1) {
18410
+ const roundedMs2 = Math.round(ms2);
17697
18411
  return roundedMs2 < MS_IN_SECOND$1 ? `${roundedMs2}ms` : "1s";
17698
18412
  }
17699
- const roundedMs = Math.round(ms / MS_IN_SECOND$1) * MS_IN_SECOND$1;
18413
+ const roundedMs = Math.round(ms2 / MS_IN_SECOND$1) * MS_IN_SECOND$1;
17700
18414
  if (roundedMs < MS_IN_MINUTE) {
17701
18415
  return `${Math.floor(roundedMs / MS_IN_SECOND$1)}s`;
17702
18416
  }
@@ -17727,18 +18441,18 @@ function formatDuration(ms, compact = false) {
17727
18441
  parts.push(`${seconds}s`);
17728
18442
  return parts.join(" ");
17729
18443
  }
17730
- function formatDurationPrecise(ms, fractionDigits = 2) {
17731
- if (ms === 0) {
18444
+ function formatDurationPrecise(ms2, fractionDigits = 2) {
18445
+ if (ms2 === 0) {
17732
18446
  return "0s";
17733
18447
  }
17734
- if (ms < MS_IN_SECOND$1) {
17735
- const roundedMs = Math.round(ms);
18448
+ if (ms2 < MS_IN_SECOND$1) {
18449
+ const roundedMs = Math.round(ms2);
17736
18450
  if (roundedMs < MS_IN_SECOND$1) {
17737
18451
  return `${roundedMs}ms`;
17738
18452
  }
17739
18453
  }
17740
18454
  const granularityMs = MS_IN_SECOND$1 / 10 ** fractionDigits;
17741
- const normalizedMs = Math.round(ms / granularityMs) * granularityMs;
18455
+ const normalizedMs = Math.round(ms2 / granularityMs) * granularityMs;
17742
18456
  if (normalizedMs < MS_IN_MINUTE) {
17743
18457
  return `${Number((normalizedMs / MS_IN_SECOND$1).toFixed(fractionDigits))}s`;
17744
18458
  }
@@ -17824,7 +18538,7 @@ function useCollapsibleContext(part) {
17824
18538
  return context;
17825
18539
  }
17826
18540
  function CollapsibleRoot({ children: children2, variant = "section", disabled = false, defaultOpen = false, onOpenChange, className }) {
17827
- const [open, setOpen] = reactExports.useState(defaultOpen);
18541
+ const [open2, setOpen] = reactExports.useState(defaultOpen);
17828
18542
  const handleToggle = (event) => {
17829
18543
  if (event.target !== event.currentTarget)
17830
18544
  return;
@@ -17832,7 +18546,7 @@ function CollapsibleRoot({ children: children2, variant = "section", disabled =
17832
18546
  setOpen(next2);
17833
18547
  onOpenChange == null ? void 0 : onOpenChange(next2);
17834
18548
  };
17835
- const details = jsxRuntimeExports.jsx("details", { "data-slot": "collapsible", "data-state": open ? "open" : "closed", open, onToggle: disabled ? void 0 : handleToggle, className: cn$4(variant === "card" ? "group/card border-gray-alpha-400 last:border-b" : "group", className), children: jsxRuntimeExports.jsx(CollapsibleContext.Provider, { value: { variant, disabled }, children: children2 }) });
18549
+ const details = jsxRuntimeExports.jsx("details", { "data-slot": "collapsible", "data-state": open2 ? "open" : "closed", open: open2, onToggle: disabled ? void 0 : handleToggle, className: cn$4(variant === "card" ? "group/card border-gray-alpha-400 last:border-b" : "group", className), children: jsxRuntimeExports.jsx(CollapsibleContext.Provider, { value: { variant, disabled }, children: children2 }) });
17836
18550
  if (variant === "card") {
17837
18551
  return details;
17838
18552
  }
@@ -18248,8 +18962,8 @@ function PrimitiveValue({ field, value, isLast }) {
18248
18962
  const { text: text2, cls } = describePrimitive(value);
18249
18963
  return jsxRuntimeExports.jsx(LeafRow, { field, isLast, children: jsxRuntimeExports.jsx("span", { className: cls, children: text2 }) });
18250
18964
  }
18251
- function EmptyContainer({ field, prefix, open, close, isLast }) {
18252
- return jsxRuntimeExports.jsxs("div", { className: CLS.child, role: "treeitem", tabIndex: -1, children: [jsxRuntimeExports.jsx(Label, { field }), prefix ? jsxRuntimeExports.jsx("span", { className: CLS.className, children: prefix }) : null, jsxRuntimeExports.jsx("span", { className: CLS.punctuation, children: open }), jsxRuntimeExports.jsx("span", { className: CLS.punctuation, children: close }), jsxRuntimeExports.jsx(Comma, { isLast })] });
18965
+ function EmptyContainer({ field, prefix, open: open2, close, isLast }) {
18966
+ return jsxRuntimeExports.jsxs("div", { className: CLS.child, role: "treeitem", tabIndex: -1, children: [jsxRuntimeExports.jsx(Label, { field }), prefix ? jsxRuntimeExports.jsx("span", { className: CLS.className, children: prefix }) : null, jsxRuntimeExports.jsx("span", { className: CLS.punctuation, children: open2 }), jsxRuntimeExports.jsx("span", { className: CLS.punctuation, children: close }), jsxRuntimeExports.jsx(Comma, { isLast })] });
18253
18967
  }
18254
18968
  function focusExpander(button, outerRef) {
18255
18969
  var _a3;
@@ -18278,13 +18992,13 @@ function moveExpanderFocus(outerRef, direction) {
18278
18992
  buttons[next2].tabIndex = 0;
18279
18993
  buttons[next2].focus();
18280
18994
  }
18281
- function ExpandableContainer({ field, entries, open, close, prefix, ctx, isLast }) {
18995
+ function ExpandableContainer({ field, entries, open: open2, close, prefix, ctx, isLast }) {
18282
18996
  const { level, shouldExpand, outerRef } = ctx;
18283
18997
  const [expanded2, setExpanded] = reactExports.useState(() => shouldExpand(level));
18284
18998
  const rowRef = reactExports.useRef(null);
18285
18999
  const contentsId = reactExports.useId();
18286
19000
  if (entries.length === 0) {
18287
- return jsxRuntimeExports.jsx(EmptyContainer, { field, prefix, open, close, isLast });
19001
+ return jsxRuntimeExports.jsx(EmptyContainer, { field, prefix, open: open2, close, isLast });
18288
19002
  }
18289
19003
  const toggle = () => {
18290
19004
  setExpanded((value) => !value);
@@ -18313,7 +19027,7 @@ function ExpandableContainer({ field, entries, open, close, prefix, ctx, isLast
18313
19027
  }
18314
19028
  };
18315
19029
  const lastIndex = entries.length - 1;
18316
- return jsxRuntimeExports.jsxs("div", { className: CLS.child, role: "treeitem", "aria-expanded": expanded2, "aria-controls": expanded2 ? contentsId : void 0, "data-json-expander": true, ref: rowRef, tabIndex: level === 0 ? 0 : -1, onClick, onKeyDown, children: [jsxRuntimeExports.jsx("span", { className: expanded2 ? CLS.collapseIcon : CLS.expandIcon, "aria-hidden": "true" }), field !== void 0 && jsxRuntimeExports.jsx("span", { className: CLS.clickableLabel, children: `${formatField(field)}:` }), prefix ? jsxRuntimeExports.jsx("span", { className: CLS.className, children: prefix }) : null, jsxRuntimeExports.jsx("span", { className: CLS.punctuation, children: open }), expanded2 ? jsxRuntimeExports.jsx("ul", { id: contentsId, className: CLS.childFields, role: "group", children: entries.map(([childField, childValue], index2) => jsxRuntimeExports.jsx(DataRender, { field: childField, value: childValue, isLast: index2 === lastIndex, ctx: { ...ctx, level: level + 1 } }, childField ?? index2)) }) : jsxRuntimeExports.jsx("span", { className: CLS.collapsedContent, "aria-hidden": "true" }), jsxRuntimeExports.jsx("span", { className: CLS.punctuation, children: close }), jsxRuntimeExports.jsx(Comma, { isLast })] });
19030
+ return jsxRuntimeExports.jsxs("div", { className: CLS.child, role: "treeitem", "aria-expanded": expanded2, "aria-controls": expanded2 ? contentsId : void 0, "data-json-expander": true, ref: rowRef, tabIndex: level === 0 ? 0 : -1, onClick, onKeyDown, children: [jsxRuntimeExports.jsx("span", { className: expanded2 ? CLS.collapseIcon : CLS.expandIcon, "aria-hidden": "true" }), field !== void 0 && jsxRuntimeExports.jsx("span", { className: CLS.clickableLabel, children: `${formatField(field)}:` }), prefix ? jsxRuntimeExports.jsx("span", { className: CLS.className, children: prefix }) : null, jsxRuntimeExports.jsx("span", { className: CLS.punctuation, children: open2 }), expanded2 ? jsxRuntimeExports.jsx("ul", { id: contentsId, className: CLS.childFields, role: "group", children: entries.map(([childField, childValue], index2) => jsxRuntimeExports.jsx(DataRender, { field: childField, value: childValue, isLast: index2 === lastIndex, ctx: { ...ctx, level: level + 1 } }, childField ?? index2)) }) : jsxRuntimeExports.jsx("span", { className: CLS.collapsedContent, "aria-hidden": "true" }), jsxRuntimeExports.jsx("span", { className: CLS.punctuation, children: close }), jsxRuntimeExports.jsx(Comma, { isLast })] });
18317
19031
  }
18318
19032
  function DataRender({ field, value, isLast, ctx }) {
18319
19033
  if (isBytesDisplay(value)) {
@@ -19240,11 +19954,11 @@ const TIME_UNITS = [
19240
19954
  function formatTimeDifference(diff) {
19241
19955
  let remaining = Math.abs(diff);
19242
19956
  const result = [];
19243
- for (const { unit, ms } of TIME_UNITS) {
19244
- const value = Math.floor(remaining / ms);
19957
+ for (const { unit, ms: ms2 } of TIME_UNITS) {
19958
+ const value = Math.floor(remaining / ms2);
19245
19959
  if (value > 0 || result.length > 0) {
19246
19960
  result.push(`${value} ${unit}${value !== 1 ? "s" : ""}`);
19247
- remaining %= ms;
19961
+ remaining %= ms2;
19248
19962
  }
19249
19963
  if (result.length === 3)
19250
19964
  break;
@@ -32550,12 +33264,12 @@ function emphasis$1(node2, _2, state, info) {
32550
33264
  })
32551
33265
  );
32552
33266
  const betweenHead = between.charCodeAt(0);
32553
- const open = encodeInfo(
33267
+ const open2 = encodeInfo(
32554
33268
  info.before.charCodeAt(info.before.length - 1),
32555
33269
  betweenHead,
32556
33270
  marker2
32557
33271
  );
32558
- if (open.inside) {
33272
+ if (open2.inside) {
32559
33273
  between = encodeCharacterReference(betweenHead) + between.slice(1);
32560
33274
  }
32561
33275
  const betweenTail = between.charCodeAt(between.length - 1);
@@ -32567,7 +33281,7 @@ function emphasis$1(node2, _2, state, info) {
32567
33281
  exit2();
32568
33282
  state.attentionEncodeSurroundingInfo = {
32569
33283
  after: close.outside,
32570
- before: open.outside
33284
+ before: open2.outside
32571
33285
  };
32572
33286
  return before + between + after;
32573
33287
  }
@@ -33100,12 +33814,12 @@ function strong$1(node2, _2, state, info) {
33100
33814
  })
33101
33815
  );
33102
33816
  const betweenHead = between.charCodeAt(0);
33103
- const open = encodeInfo(
33817
+ const open2 = encodeInfo(
33104
33818
  info.before.charCodeAt(info.before.length - 1),
33105
33819
  betweenHead,
33106
33820
  marker2
33107
33821
  );
33108
- if (open.inside) {
33822
+ if (open2.inside) {
33109
33823
  between = encodeCharacterReference(betweenHead) + between.slice(1);
33110
33824
  }
33111
33825
  const betweenTail = between.charCodeAt(between.length - 1);
@@ -33117,7 +33831,7 @@ function strong$1(node2, _2, state, info) {
33117
33831
  exit2();
33118
33832
  state.attentionEncodeSurroundingInfo = {
33119
33833
  after: close.outside,
33120
- before: open.outside
33834
+ before: open2.outside
33121
33835
  };
33122
33836
  return before + between + after;
33123
33837
  }
@@ -33914,7 +34628,7 @@ const attention = {
33914
34628
  };
33915
34629
  function resolveAllAttention(events, context) {
33916
34630
  let index2 = -1;
33917
- let open;
34631
+ let open2;
33918
34632
  let group;
33919
34633
  let text2;
33920
34634
  let openingSequence;
@@ -33924,16 +34638,16 @@ function resolveAllAttention(events, context) {
33924
34638
  let offset2;
33925
34639
  while (++index2 < events.length) {
33926
34640
  if (events[index2][0] === "enter" && events[index2][1].type === "attentionSequence" && events[index2][1]._close) {
33927
- open = index2;
33928
- while (open--) {
33929
- if (events[open][0] === "exit" && events[open][1].type === "attentionSequence" && events[open][1]._open && // If the markers are the same:
33930
- context.sliceSerialize(events[open][1]).charCodeAt(0) === context.sliceSerialize(events[index2][1]).charCodeAt(0)) {
33931
- if ((events[open][1]._close || events[index2][1]._open) && (events[index2][1].end.offset - events[index2][1].start.offset) % 3 && !((events[open][1].end.offset - events[open][1].start.offset + events[index2][1].end.offset - events[index2][1].start.offset) % 3)) {
34641
+ open2 = index2;
34642
+ while (open2--) {
34643
+ if (events[open2][0] === "exit" && events[open2][1].type === "attentionSequence" && events[open2][1]._open && // If the markers are the same:
34644
+ context.sliceSerialize(events[open2][1]).charCodeAt(0) === context.sliceSerialize(events[index2][1]).charCodeAt(0)) {
34645
+ if ((events[open2][1]._close || events[index2][1]._open) && (events[index2][1].end.offset - events[index2][1].start.offset) % 3 && !((events[open2][1].end.offset - events[open2][1].start.offset + events[index2][1].end.offset - events[index2][1].start.offset) % 3)) {
33932
34646
  continue;
33933
34647
  }
33934
- use = events[open][1].end.offset - events[open][1].start.offset > 1 && events[index2][1].end.offset - events[index2][1].start.offset > 1 ? 2 : 1;
34648
+ use = events[open2][1].end.offset - events[open2][1].start.offset > 1 && events[index2][1].end.offset - events[index2][1].start.offset > 1 ? 2 : 1;
33935
34649
  const start = {
33936
- ...events[open][1].end
34650
+ ...events[open2][1].end
33937
34651
  };
33938
34652
  const end = {
33939
34653
  ...events[index2][1].start
@@ -33944,7 +34658,7 @@ function resolveAllAttention(events, context) {
33944
34658
  type: use > 1 ? "strongSequence" : "emphasisSequence",
33945
34659
  start,
33946
34660
  end: {
33947
- ...events[open][1].end
34661
+ ...events[open2][1].end
33948
34662
  }
33949
34663
  };
33950
34664
  closingSequence = {
@@ -33957,7 +34671,7 @@ function resolveAllAttention(events, context) {
33957
34671
  text2 = {
33958
34672
  type: use > 1 ? "strongText" : "emphasisText",
33959
34673
  start: {
33960
- ...events[open][1].end
34674
+ ...events[open2][1].end
33961
34675
  },
33962
34676
  end: {
33963
34677
  ...events[index2][1].start
@@ -33972,18 +34686,18 @@ function resolveAllAttention(events, context) {
33972
34686
  ...closingSequence.end
33973
34687
  }
33974
34688
  };
33975
- events[open][1].end = {
34689
+ events[open2][1].end = {
33976
34690
  ...openingSequence.start
33977
34691
  };
33978
34692
  events[index2][1].start = {
33979
34693
  ...closingSequence.end
33980
34694
  };
33981
34695
  nextEvents = [];
33982
- if (events[open][1].end.offset - events[open][1].start.offset) {
33983
- nextEvents = push(nextEvents, [["enter", events[open][1], context], ["exit", events[open][1], context]]);
34696
+ if (events[open2][1].end.offset - events[open2][1].start.offset) {
34697
+ nextEvents = push(nextEvents, [["enter", events[open2][1], context], ["exit", events[open2][1], context]]);
33984
34698
  }
33985
34699
  nextEvents = push(nextEvents, [["enter", group, context], ["enter", openingSequence, context], ["exit", openingSequence, context], ["enter", text2, context]]);
33986
- nextEvents = push(nextEvents, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + 1, index2), context));
34700
+ nextEvents = push(nextEvents, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open2 + 1, index2), context));
33987
34701
  nextEvents = push(nextEvents, [["exit", text2, context], ["enter", closingSequence, context], ["exit", closingSequence, context], ["exit", group, context]]);
33988
34702
  if (events[index2][1].end.offset - events[index2][1].start.offset) {
33989
34703
  offset2 = 2;
@@ -33991,8 +34705,8 @@ function resolveAllAttention(events, context) {
33991
34705
  } else {
33992
34706
  offset2 = 0;
33993
34707
  }
33994
- splice(events, open - 1, index2 - open + 3, nextEvents);
33995
- index2 = open + nextEvents.length - offset2 - 2;
34708
+ splice(events, open2 - 1, index2 - open2 + 3, nextEvents);
34709
+ index2 = open2 + nextEvents.length - offset2 - 2;
33996
34710
  break;
33997
34711
  }
33998
34712
  }
@@ -34024,10 +34738,10 @@ function tokenizeAttention(effects, ok2) {
34024
34738
  }
34025
34739
  const token = effects.exit("attentionSequence");
34026
34740
  const after = classifyCharacter(code2);
34027
- const open = !after || after === 2 && before || attentionMarkers2.includes(code2);
34741
+ const open2 = !after || after === 2 && before || attentionMarkers2.includes(code2);
34028
34742
  const close = !before || before === 2 && after || attentionMarkers2.includes(previous2);
34029
- token._open = Boolean(marker2 === 42 ? open : open && (before || !close));
34030
- token._close = Boolean(marker2 === 42 ? close : close && (after || !open));
34743
+ token._open = Boolean(marker2 === 42 ? open2 : open2 && (before || !close));
34744
+ token._close = Boolean(marker2 === 42 ? close : close && (after || !open2));
34031
34745
  return ok2(code2);
34032
34746
  }
34033
34747
  }
@@ -34049,9 +34763,9 @@ function tokenizeAutolink(effects, ok2, nok) {
34049
34763
  effects.consume(code2);
34050
34764
  effects.exit("autolinkMarker");
34051
34765
  effects.enter("autolinkProtocol");
34052
- return open;
34766
+ return open2;
34053
34767
  }
34054
- function open(code2) {
34768
+ function open2(code2) {
34055
34769
  if (asciiAlpha(code2)) {
34056
34770
  effects.consume(code2);
34057
34771
  return schemeOrEmailAtext;
@@ -34263,9 +34977,9 @@ function tokenizeCharacterReference(effects, ok2, nok) {
34263
34977
  effects.enter("characterReferenceMarker");
34264
34978
  effects.consume(code2);
34265
34979
  effects.exit("characterReferenceMarker");
34266
- return open;
34980
+ return open2;
34267
34981
  }
34268
- function open(code2) {
34982
+ function open2(code2) {
34269
34983
  if (code2 === 35) {
34270
34984
  effects.enter("characterReferenceMarkerNumeric");
34271
34985
  effects.consume(code2);
@@ -35603,9 +36317,9 @@ function tokenizeHtmlFlow(effects, ok2, nok) {
35603
36317
  effects.enter("htmlFlow");
35604
36318
  effects.enter("htmlFlowData");
35605
36319
  effects.consume(code2);
35606
- return open;
36320
+ return open2;
35607
36321
  }
35608
- function open(code2) {
36322
+ function open2(code2) {
35609
36323
  if (code2 === 33) {
35610
36324
  effects.consume(code2);
35611
36325
  return declarationOpen;
@@ -35951,9 +36665,9 @@ function tokenizeHtmlText(effects, ok2, nok) {
35951
36665
  effects.enter("htmlText");
35952
36666
  effects.enter("htmlTextData");
35953
36667
  effects.consume(code2);
35954
- return open;
36668
+ return open2;
35955
36669
  }
35956
- function open(code2) {
36670
+ function open2(code2) {
35957
36671
  if (code2 === 33) {
35958
36672
  effects.consume(code2);
35959
36673
  return declarationOpen;
@@ -36277,12 +36991,12 @@ function resolveToLabelEnd(events, context) {
36277
36991
  let index2 = events.length;
36278
36992
  let offset2 = 0;
36279
36993
  let token;
36280
- let open;
36994
+ let open2;
36281
36995
  let close;
36282
36996
  let media;
36283
36997
  while (index2--) {
36284
36998
  token = events[index2][1];
36285
- if (open) {
36999
+ if (open2) {
36286
37000
  if (token.type === "link" || token.type === "labelLink" && token._inactive) {
36287
37001
  break;
36288
37002
  }
@@ -36291,7 +37005,7 @@ function resolveToLabelEnd(events, context) {
36291
37005
  }
36292
37006
  } else if (close) {
36293
37007
  if (events[index2][0] === "enter" && (token.type === "labelImage" || token.type === "labelLink") && !token._balanced) {
36294
- open = index2;
37008
+ open2 = index2;
36295
37009
  if (token.type !== "labelLink") {
36296
37010
  offset2 = 2;
36297
37011
  break;
@@ -36302,9 +37016,9 @@ function resolveToLabelEnd(events, context) {
36302
37016
  }
36303
37017
  }
36304
37018
  const group = {
36305
- type: events[open][1].type === "labelLink" ? "link" : "image",
37019
+ type: events[open2][1].type === "labelLink" ? "link" : "image",
36306
37020
  start: {
36307
- ...events[open][1].start
37021
+ ...events[open2][1].start
36308
37022
  },
36309
37023
  end: {
36310
37024
  ...events[events.length - 1][1].end
@@ -36313,7 +37027,7 @@ function resolveToLabelEnd(events, context) {
36313
37027
  const label = {
36314
37028
  type: "label",
36315
37029
  start: {
36316
- ...events[open][1].start
37030
+ ...events[open2][1].start
36317
37031
  },
36318
37032
  end: {
36319
37033
  ...events[close][1].end
@@ -36322,20 +37036,20 @@ function resolveToLabelEnd(events, context) {
36322
37036
  const text2 = {
36323
37037
  type: "labelText",
36324
37038
  start: {
36325
- ...events[open + offset2 + 2][1].end
37039
+ ...events[open2 + offset2 + 2][1].end
36326
37040
  },
36327
37041
  end: {
36328
37042
  ...events[close - 2][1].start
36329
37043
  }
36330
37044
  };
36331
37045
  media = [["enter", group, context], ["enter", label, context]];
36332
- media = push(media, events.slice(open + 1, open + offset2 + 3));
37046
+ media = push(media, events.slice(open2 + 1, open2 + offset2 + 3));
36333
37047
  media = push(media, [["enter", text2, context]]);
36334
- media = push(media, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + offset2 + 4, close - 3), context));
37048
+ media = push(media, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open2 + offset2 + 4, close - 3), context));
36335
37049
  media = push(media, [["exit", text2, context], events[close - 2], events[close - 1], ["exit", label, context]]);
36336
37050
  media = push(media, events.slice(close + 1));
36337
37051
  media = push(media, [["exit", group, context]]);
36338
- splice(events, open, events.length, media);
37052
+ splice(events, open2, events.length, media);
36339
37053
  return events;
36340
37054
  }
36341
37055
  function tokenizeLabelEnd(effects, ok2, nok) {
@@ -36478,9 +37192,9 @@ function tokenizeLabelStartImage(effects, ok2, nok) {
36478
37192
  effects.enter("labelImageMarker");
36479
37193
  effects.consume(code2);
36480
37194
  effects.exit("labelImageMarker");
36481
- return open;
37195
+ return open2;
36482
37196
  }
36483
- function open(code2) {
37197
+ function open2(code2) {
36484
37198
  if (code2 === 91) {
36485
37199
  effects.enter("labelMarker");
36486
37200
  effects.consume(code2);
@@ -37080,30 +37794,30 @@ function gfmStrikethrough(options) {
37080
37794
  let index2 = -1;
37081
37795
  while (++index2 < events.length) {
37082
37796
  if (events[index2][0] === "enter" && events[index2][1].type === "strikethroughSequenceTemporary" && events[index2][1]._close) {
37083
- let open = index2;
37084
- while (open--) {
37085
- if (events[open][0] === "exit" && events[open][1].type === "strikethroughSequenceTemporary" && events[open][1]._open && // If the sizes are the same:
37086
- events[index2][1].end.offset - events[index2][1].start.offset === events[open][1].end.offset - events[open][1].start.offset) {
37797
+ let open2 = index2;
37798
+ while (open2--) {
37799
+ if (events[open2][0] === "exit" && events[open2][1].type === "strikethroughSequenceTemporary" && events[open2][1]._open && // If the sizes are the same:
37800
+ events[index2][1].end.offset - events[index2][1].start.offset === events[open2][1].end.offset - events[open2][1].start.offset) {
37087
37801
  events[index2][1].type = "strikethroughSequence";
37088
- events[open][1].type = "strikethroughSequence";
37802
+ events[open2][1].type = "strikethroughSequence";
37089
37803
  const strikethrough2 = {
37090
37804
  type: "strikethrough",
37091
- start: Object.assign({}, events[open][1].start),
37805
+ start: Object.assign({}, events[open2][1].start),
37092
37806
  end: Object.assign({}, events[index2][1].end)
37093
37807
  };
37094
37808
  const text2 = {
37095
37809
  type: "strikethroughText",
37096
- start: Object.assign({}, events[open][1].end),
37810
+ start: Object.assign({}, events[open2][1].end),
37097
37811
  end: Object.assign({}, events[index2][1].start)
37098
37812
  };
37099
- const nextEvents = [["enter", strikethrough2, context], ["enter", events[open][1], context], ["exit", events[open][1], context], ["enter", text2, context]];
37813
+ const nextEvents = [["enter", strikethrough2, context], ["enter", events[open2][1], context], ["exit", events[open2][1], context], ["enter", text2, context]];
37100
37814
  const insideSpan2 = context.parser.constructs.insideSpan.null;
37101
37815
  if (insideSpan2) {
37102
- splice(nextEvents, nextEvents.length, 0, resolveAll(insideSpan2, events.slice(open + 1, index2), context));
37816
+ splice(nextEvents, nextEvents.length, 0, resolveAll(insideSpan2, events.slice(open2 + 1, index2), context));
37103
37817
  }
37104
37818
  splice(nextEvents, nextEvents.length, 0, [["exit", text2, context], ["enter", events[index2][1], context], ["exit", events[index2][1], context], ["exit", strikethrough2, context]]);
37105
- splice(events, open - 1, index2 - open + 3, nextEvents);
37106
- index2 = open + nextEvents.length - 2;
37819
+ splice(events, open2 - 1, index2 - open2 + 3, nextEvents);
37820
+ index2 = open2 + nextEvents.length - 2;
37107
37821
  break;
37108
37822
  }
37109
37823
  }
@@ -37645,8 +38359,8 @@ function gfmTaskListItem() {
37645
38359
  }
37646
38360
  function tokenizeTasklistCheck(effects, ok2, nok) {
37647
38361
  const self2 = this;
37648
- return open;
37649
- function open(code2) {
38362
+ return open2;
38363
+ function open2(code2) {
37650
38364
  if (
37651
38365
  // Exit if there’s stuff before.
37652
38366
  self2.previous !== null || // Exit if not in the first content that is the first child of a list
@@ -40079,8 +40793,8 @@ function compiler(options) {
40079
40793
  return length;
40080
40794
  }
40081
40795
  function opener(create2, and) {
40082
- return open;
40083
- function open(token) {
40796
+ return open2;
40797
+ function open2(token) {
40084
40798
  enter.call(this, create2(token), token);
40085
40799
  if (and) and.call(this, token);
40086
40800
  }
@@ -40112,18 +40826,18 @@ function compiler(options) {
40112
40826
  }
40113
40827
  function exit2(token, onExitError) {
40114
40828
  const node2 = this.stack.pop();
40115
- const open = this.tokenStack.pop();
40116
- if (!open) {
40829
+ const open2 = this.tokenStack.pop();
40830
+ if (!open2) {
40117
40831
  throw new Error("Cannot close `" + token.type + "` (" + stringifyPosition({
40118
40832
  start: token.start,
40119
40833
  end: token.end
40120
40834
  }) + "): it’s not open");
40121
- } else if (open[0].type !== token.type) {
40835
+ } else if (open2[0].type !== token.type) {
40122
40836
  if (onExitError) {
40123
- onExitError.call(this, token, open[0]);
40837
+ onExitError.call(this, token, open2[0]);
40124
40838
  } else {
40125
- const handler = open[1] || defaultOnError;
40126
- handler.call(this, token, open[0]);
40839
+ const handler = open2[1] || defaultOnError;
40840
+ handler.call(this, token, open2[0]);
40127
40841
  }
40128
40842
  }
40129
40843
  node2.position.end = point(token.end);
@@ -44099,7 +44813,7 @@ var tn = f("block", "before:content-[counter(line)]", "before:inline-block", "be
44099
44813
  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 });
44100
44814
  var Se = reactExports.createContext({ code: "" }), de = () => reactExports.useContext(Se);
44101
44815
  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 }) });
44102
- var cn$1 = /\n+$/, dn = reactExports.lazy(() => __vitePreload(() => import("./highlighted-body-B3W2YXNL-nasOj6sE.js"), true ? __vite__mapDeps([4,2]) : void 0).then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
44816
+ var cn$1 = /\n+$/, dn = reactExports.lazy(() => __vitePreload(() => import("./highlighted-body-B3W2YXNL-CRgNr0YA.js"), true ? __vite__mapDeps([2,1]) : void 0).then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
44103
44817
  let i = reactExports.useMemo(() => e.replace(cn$1, ""), [e]), c = reactExports.useMemo(() => ({ bg: "transparent", fg: "inherit", tokens: i.split(`
44104
44818
  `).map((a2) => [{ content: a2, color: "inherit", bgColor: "transparent", htmlStyle: {}, offset: 0 }]) }), [i]);
44105
44819
  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 }) })] }) });
@@ -46440,6 +47154,9 @@ function computeTimeMarkers(viewDuration, offset2) {
46440
47154
  }
46441
47155
  return markers2;
46442
47156
  }
47157
+ function toViewportFrac(ms2, viewStart, range) {
47158
+ return Math.min(Math.max((ms2 - viewStart) / range, 0), 1);
47159
+ }
46443
47160
  function computeSpanGaps(spans, viewStart, viewEnd) {
46444
47161
  const range = viewEnd - viewStart;
46445
47162
  if (range <= 0)
@@ -46451,14 +47168,40 @@ function computeSpanGaps(spans, viewStart, viewEnd) {
46451
47168
  const gapMs = startTime - endTime;
46452
47169
  if (gapMs <= 0)
46453
47170
  continue;
46454
- const leftFrac = Math.min(Math.max((endTime - viewStart) / range, 0), 1);
46455
- const rightFrac = Math.min(Math.max((startTime - viewStart) / range, 0), 1);
47171
+ const leftFrac = toViewportFrac(endTime, viewStart, range);
47172
+ const rightFrac = toViewportFrac(startTime, viewStart, range);
46456
47173
  if (rightFrac - leftFrac < 1e-3)
46457
47174
  continue;
46458
47175
  gaps.push({ gapMs, leftFrac, rightFrac, rowIndex: i });
46459
47176
  }
46460
47177
  return gaps;
46461
47178
  }
47179
+ function computeSpanDelta(anchor, hovered, viewStart, viewEnd) {
47180
+ const range = viewEnd - viewStart;
47181
+ if (range <= 0)
47182
+ return null;
47183
+ const anchorStart = getHighResInMs(anchor.startTime);
47184
+ const hoveredStart = getHighResInMs(hovered.startTime);
47185
+ const anchorIsEarlier = anchorStart <= hoveredStart;
47186
+ const earlierStart = anchorIsEarlier ? anchorStart : hoveredStart;
47187
+ const earlierEnd = getHighResInMs(anchorIsEarlier ? anchor.endTime : hovered.endTime);
47188
+ const laterStart = anchorIsEarlier ? hoveredStart : anchorStart;
47189
+ const originMs = earlierEnd <= laterStart ? earlierEnd : earlierStart;
47190
+ const deltaMs = laterStart - originMs;
47191
+ if (laterStart < viewStart || originMs > viewEnd) {
47192
+ return null;
47193
+ }
47194
+ const originFrac = toViewportFrac(originMs, viewStart, range);
47195
+ const laterFrac = toViewportFrac(laterStart, viewStart, range);
47196
+ const hoveredEnd = getHighResInMs(hovered.endTime);
47197
+ return {
47198
+ deltaMs,
47199
+ anchorFrac: anchorIsEarlier ? originFrac : laterFrac,
47200
+ hoveredFrac: anchorIsEarlier ? laterFrac : originFrac,
47201
+ anchorEdge: anchorIsEarlier && earlierEnd <= laterStart ? "end" : "start",
47202
+ hoveredOffscreen: hoveredStart > viewEnd ? "right" : hoveredEnd < viewStart ? "left" : null
47203
+ };
47204
+ }
46462
47205
  const RESOURCE_COLORS = {
46463
47206
  run: {
46464
47207
  bg: "var(--ds-blue-200)",
@@ -46912,6 +47655,9 @@ function projectSegments(segments, spanStartMs, spanDurationMs, geometry) {
46912
47655
  ];
46913
47656
  });
46914
47657
  }
47658
+ function estimateLabelWidthPx(label) {
47659
+ return label.length * 6 + 12;
47660
+ }
46915
47661
  function DurationLabel({ label, className }) {
46916
47662
  return jsxRuntimeExports.jsx("span", { className: cn$4("pointer-events-none absolute inset-0 flex items-center justify-start overflow-hidden px-1 text-[10px] font-mono font-medium leading-none whitespace-nowrap text-left text-gray-1000 tabular-nums opacity-0 group-hover/timeline-row:opacity-100", className), children: label });
46917
47663
  }
@@ -46932,14 +47678,14 @@ function SegmentBar({ segments, showLabels = true }) {
46932
47678
  return jsxRuntimeExports.jsx("div", { className: "relative h-6 w-full", children: segments.map((seg, i) => {
46933
47679
  if (seg.status === "queued") {
46934
47680
  const leadInLabel = formatDurationPrecise(seg.fullDurationMs);
46935
- const showLeadInLabel = showLabels && seg.pixelWidth >= Math.max(40, leadInLabel.length * 6 + 12);
47681
+ const showLeadInLabel = showLabels && seg.pixelWidth >= Math.max(40, estimateLabelWidthPx(leadInLabel));
46936
47682
  const isFullWidthQueued = segments.length === 1;
46937
47683
  return jsxRuntimeExports.jsxs(reactExports.Fragment, { children: [jsxRuntimeExports.jsx(LeadInConnector, { leftPct: seg.leftPct, widthPct: seg.widthPct, label: showLeadInLabel ? leadInLabel : null }), isFullWidthQueued ? jsxRuntimeExports.jsx("div", { className: "absolute top-1/2 h-4 w-px -translate-y-1/2 bg-gray-500", style: {
46938
47684
  left: `calc(${seg.leftPct + seg.widthPct}% - 1.5px)`
46939
47685
  } }) : null] }, i);
46940
47686
  }
46941
47687
  const label = formatDurationPrecise(seg.fullDurationMs);
46942
- const showLabel = showLabels && seg.pixelWidth >= Math.max(40, label.length * 6 + 12);
47688
+ const showLabel = showLabels && seg.pixelWidth >= Math.max(40, estimateLabelWidthPx(label));
46943
47689
  return jsxRuntimeExports.jsxs("div", { className: cn$4("absolute h-full overflow-hidden rounded-[0.25rem]", SEGMENT_CLASSES[seg.status]), style: {
46944
47690
  // 1px gap between adjacent segments, distributed equally.
46945
47691
  left: `calc(${seg.leftPct}% + 0.5px)`,
@@ -46964,7 +47710,7 @@ const TimelineBar = reactExports.memo(function TimelineBar2({ span, viewStart, v
46964
47710
  const fallbackBg = isErrored ? colors.errorBg ?? "var(--ds-red-200)" : colors.bg;
46965
47711
  const fallbackBorder = isErrored ? colors.errorBorder ?? "var(--ds-red-500)" : colors.border;
46966
47712
  const totalLabel = formatDurationPrecise(totalDurationMs);
46967
- const showTotalLabel = geometry.visiblePixelWidth >= Math.max(40, totalLabel.length * 6 + 12);
47713
+ const showTotalLabel = geometry.visiblePixelWidth >= Math.max(40, estimateLabelWidthPx(totalLabel));
46968
47714
  const handleClick = reactExports.useCallback(() => {
46969
47715
  onSelect(span.spanId);
46970
47716
  }, [onSelect, span.spanId]);
@@ -46974,21 +47720,35 @@ const TimelineBar = reactExports.memo(function TimelineBar2({ span, viewStart, v
46974
47720
  className: offscreen.left ? "pl-10" : void 0
46975
47721
  }) : null] }) : null] }) });
46976
47722
  });
46977
- const DELTA_CAP_HEIGHT_PX = 8;
46978
- const DELTA_ROW_OFFSET_PX = 8;
46979
- const DeltaIndicator = reactExports.memo(function DeltaIndicator2({ leftFrac, rightFrac, label, rowIndex }) {
46980
- const centerY = DELTA_ROW_OFFSET_PX + (rowIndex + 1) * ROW_HEIGHT_PX;
46981
- return jsxRuntimeExports.jsxs("div", { className: "absolute pointer-events-none", style: {
46982
- left: `${leftFrac * 100}%`,
46983
- width: `${(rightFrac - leftFrac) * 100}%`,
46984
- top: centerY - DELTA_CAP_HEIGHT_PX / 2,
46985
- height: DELTA_CAP_HEIGHT_PX
46986
- }, children: [jsxRuntimeExports.jsx("div", { className: "absolute left-0 top-0 w-px h-full bg-amber-800" }), jsxRuntimeExports.jsx("div", { className: "absolute left-0 right-0 top-1/2 h-px bg-amber-800" }), jsxRuntimeExports.jsx("div", { className: "absolute right-0 top-0 w-px h-full bg-amber-800" }), jsxRuntimeExports.jsx("span", { className: "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 text-label-12 leading-none whitespace-nowrap rounded-xs px-1 py-0.5 text-gray-100 bg-amber-800", children: label })] });
47723
+ const MEASURE_GUIDE_OUTSET_PX = 4;
47724
+ const DeltaMeasureLine = reactExports.memo(function DeltaMeasureLine2({ delta, anchorRowIndex, hoveredRowIndex, timelineWidth }) {
47725
+ const anchorCenterY = anchorRowIndex * ROW_HEIGHT_PX + ROW_HEIGHT_PX / 2;
47726
+ const lineY = hoveredRowIndex * ROW_HEIGHT_PX + ROW_HEIGHT_PX / 2;
47727
+ const guideTop = Math.min(anchorCenterY, lineY);
47728
+ const guideBottom = Math.max(anchorCenterY, lineY);
47729
+ const anchorX = delta.anchorFrac * timelineWidth;
47730
+ const guideX = anchorX + (delta.anchorEdge === "end" ? MEASURE_GUIDE_OUTSET_PX : -MEASURE_GUIDE_OUTSET_PX);
47731
+ const arrowClearance = delta.hoveredOffscreen === "right" ? -28 : delta.hoveredOffscreen === "left" ? TINY_BAR_BOX_SIZE_PX + 4 : 0;
47732
+ const hoveredX = delta.hoveredFrac * timelineWidth + arrowClearance;
47733
+ const startX = Math.min(guideX, hoveredX);
47734
+ const endX = Math.max(guideX, hoveredX);
47735
+ const label = formatDurationPrecise(delta.deltaMs);
47736
+ const labelWidthPx = estimateLabelWidthPx(label);
47737
+ const labelPlacement = endX - startX >= labelWidthPx ? { left: (startX + endX) / 2, translate: "-translate-x-1/2" } : endX + 4 + labelWidthPx <= timelineWidth ? { left: endX + 4, translate: "" } : { left: startX - 4, translate: "-translate-x-full" };
47738
+ return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("div", { className: "absolute h-px bg-amber-800", style: {
47739
+ left: Math.min(anchorX, guideX),
47740
+ width: MEASURE_GUIDE_OUTSET_PX,
47741
+ top: anchorCenterY
47742
+ } }), jsxRuntimeExports.jsx("div", { className: "absolute w-px bg-amber-800", style: {
47743
+ left: guideX,
47744
+ top: guideTop,
47745
+ height: guideBottom - guideTop
47746
+ } }), jsxRuntimeExports.jsx("div", { className: "absolute h-px bg-amber-800", style: { left: startX, width: Math.max(endX - startX, 1), top: lineY } }), jsxRuntimeExports.jsx("span", { className: cn$4("absolute -translate-y-1/2 font-mono text-[10px] font-medium leading-none tabular-nums whitespace-nowrap rounded-xs bg-background-100 px-1 py-0.5 text-amber-800", labelPlacement.translate), style: { left: labelPlacement.left, top: lineY }, children: label })] });
46987
47747
  });
46988
47748
  function TimelineHeader({ markers: markers2, hoverInfo: hoverInfo2 }) {
46989
47749
  return jsxRuntimeExports.jsx("div", { className: "relative bg-background-100 border-b border-gray-alpha-400 h-10 min-h-10 flex items-end px-4 pb-1", children: jsxRuntimeExports.jsxs("div", { className: "relative h-full flex-1", children: [markers2.map((m2) => jsxRuntimeExports.jsx("span", { className: "absolute bottom-1 font-mono text-xs font-normal leading-4 text-gray-900 whitespace-nowrap", style: { left: `${m2.position * 100}%` }, children: m2.label }, String(m2.value))), hoverInfo2 && jsxRuntimeExports.jsx("span", { className: "absolute top-1 pointer-events-none z-10 font-mono text-[11px] leading-4 text-gray-1000 whitespace-nowrap bg-background-100 border border-gray-alpha-400 rounded px-1 -translate-x-1/2", style: { left: `${hoverInfo2.fraction * 100}%` }, children: hoverInfo2.label })] }) });
46990
47750
  }
46991
- function Timeline({ spans, viewStart, viewEnd, markers: markers2, selectedId, searchResult, onSelect, onRevealTime, hoverFraction, altHeld = false }) {
47751
+ function Timeline({ spans, viewStart, viewEnd, markers: markers2, selectedId, searchResult, onSelect, onRevealTime, hover, altHeld = false }) {
46992
47752
  const containerRef = reactExports.useRef(null);
46993
47753
  const [containerWidth, setContainerWidth] = reactExports.useState(0);
46994
47754
  const viewDuration = viewEnd - viewStart;
@@ -47004,11 +47764,33 @@ function Timeline({ spans, viewStart, viewEnd, markers: markers2, selectedId, se
47004
47764
  ro2.observe(el);
47005
47765
  return () => ro2.disconnect();
47006
47766
  }, []);
47007
- const gaps = reactExports.useMemo(() => computeSpanGaps(spans, viewStart, viewEnd), [spans, viewStart, viewEnd]);
47767
+ const gapMeasurements = reactExports.useMemo(() => computeSpanGaps(spans, viewStart, viewEnd).map((gap) => ({
47768
+ delta: {
47769
+ deltaMs: gap.gapMs,
47770
+ anchorFrac: gap.leftFrac,
47771
+ hoveredFrac: gap.rightFrac,
47772
+ anchorEdge: "end",
47773
+ hoveredOffscreen: null
47774
+ },
47775
+ anchorRowIndex: gap.rowIndex,
47776
+ hoveredRowIndex: gap.rowIndex + 1
47777
+ })), [spans, viewStart, viewEnd]);
47778
+ const anchorIndex = reactExports.useMemo(() => selectedId ? spans.findIndex((s2) => s2.spanId === selectedId) : -1, [spans, selectedId]);
47779
+ const measurement = reactExports.useMemo(() => {
47780
+ if (!altHeld || hover == null || hover.rowIndex === anchorIndex) {
47781
+ return null;
47782
+ }
47783
+ const anchorSpan = spans[anchorIndex];
47784
+ const hoveredSpan = spans[hover.rowIndex];
47785
+ if (!anchorSpan || !hoveredSpan)
47786
+ return null;
47787
+ const delta = computeSpanDelta(anchorSpan, hoveredSpan, viewStart, viewEnd);
47788
+ return delta ? { delta, anchorRowIndex: anchorIndex, hoveredRowIndex: hover.rowIndex } : null;
47789
+ }, [altHeld, anchorIndex, hover, spans, viewStart, viewEnd]);
47008
47790
  return jsxRuntimeExports.jsxs("div", { ref: containerRef, className: "relative h-full overflow-hidden", style: { minHeight: spans.length * ROW_HEIGHT_PX }, children: [jsxRuntimeExports.jsx("div", { "aria-hidden": true, className: "absolute inset-y-0 pointer-events-none", style: TIMELINE_INSET_STYLE, children: markers2.map((marker2) => (
47009
47791
  // Skip the "0s" origin marker since the left edge already implies it.
47010
47792
  Math.abs(marker2.value) > 1e-6 ? jsxRuntimeExports.jsx("div", { className: "absolute top-0 bottom-0 w-px bg-gray-alpha-300", style: { left: `${marker2.position * 100}%` } }, String(marker2.value)) : null
47011
- )) }), hoverFraction != null && jsxRuntimeExports.jsx("div", { className: "absolute inset-y-0 pointer-events-none z-10", style: TIMELINE_INSET_STYLE, children: jsxRuntimeExports.jsx("div", { className: "absolute top-0 bottom-0 w-px bg-gray-alpha-500", style: { left: `${hoverFraction * 100}%` } }) }), jsxRuntimeExports.jsx("div", { style: { transform: `translateY(${start * ROW_HEIGHT_PX}px)` }, children: spans.slice(start, end).map((span) => jsxRuntimeExports.jsx(TimelineBar, { span, viewStart, viewDuration, containerWidth: timelineWidth, isSelected: selectedId === span.spanId, isDimmed: isSpanDimmedBySearch(span.spanId, searchResult), onSelect, onRevealTime }, span.spanId)) }), altHeld && jsxRuntimeExports.jsx("div", { "aria-hidden": true, className: "absolute inset-y-0 pointer-events-none", style: TIMELINE_INSET_STYLE, children: gaps.map((gap) => jsxRuntimeExports.jsx(DeltaIndicator, { leftFrac: gap.leftFrac, rightFrac: gap.rightFrac, label: formatDurationPrecise(gap.gapMs), rowIndex: gap.rowIndex }, gap.rowIndex)) })] });
47793
+ )) }), hover != null && jsxRuntimeExports.jsx("div", { className: "absolute inset-y-0 pointer-events-none z-10", style: TIMELINE_INSET_STYLE, children: jsxRuntimeExports.jsx("div", { className: "absolute top-0 bottom-0 w-px bg-gray-alpha-500", style: { left: `${hover.fraction * 100}%` } }) }), jsxRuntimeExports.jsx("div", { style: { transform: `translateY(${start * ROW_HEIGHT_PX}px)` }, children: spans.slice(start, end).map((span) => jsxRuntimeExports.jsx(TimelineBar, { span, viewStart, viewDuration, containerWidth: timelineWidth, isSelected: selectedId === span.spanId, isDimmed: isSpanDimmedBySearch(span.spanId, searchResult), onSelect, onRevealTime }, span.spanId)) }), altHeld && anchorIndex < 0 && jsxRuntimeExports.jsx("div", { "aria-hidden": true, className: "absolute inset-y-0 pointer-events-none", style: TIMELINE_INSET_STYLE, children: gapMeasurements.map((gap) => jsxRuntimeExports.jsx(DeltaMeasureLine, { ...gap, timelineWidth }, gap.anchorRowIndex)) }), measurement && jsxRuntimeExports.jsx("div", { "aria-hidden": true, className: "absolute inset-y-0 pointer-events-none z-20", style: TIMELINE_INSET_STYLE, children: jsxRuntimeExports.jsx(DeltaMeasureLine, { ...measurement, timelineWidth }) })] });
47012
47794
  }
47013
47795
  const CANVAS_PAD_Y_PX = 6;
47014
47796
  const MIN_LINE_HEIGHT_PX = 1.5;
@@ -49678,8 +50460,8 @@ async function fetchStreams(worldEnv, runId) {
49678
50460
  async function fetchWorkflowsManifest(worldEnv) {
49679
50461
  return rpc("fetchWorkflowsManifest", { worldEnv });
49680
50462
  }
49681
- async function runHealthCheck(worldEnv, endpoint, options) {
49682
- return rpc("runHealthCheck", { worldEnv, endpoint, options });
50463
+ async function runHealthCheck(worldEnv, options) {
50464
+ return rpc("runHealthCheck", { worldEnv, options });
49683
50465
  }
49684
50466
  async function getEncryptionKeyForRun(worldEnv, runId) {
49685
50467
  return rpc("getEncryptionKeyForRun", { worldEnv, runId });
@@ -49786,26 +50568,29 @@ export {
49786
50568
  fetchEventsByCorrelationId as b0,
49787
50569
  isEncryptedData as b1,
49788
50570
  hydrateData as b2,
49789
- getWebRevivers as b3,
49790
- LIVE_UPDATE_INTERVAL_MS as b4,
49791
- getEncryptionKeyForRun as b5,
49792
- StreamViewer as b6,
49793
- composeRefs as b7,
49794
- useFloating as b8,
49795
- offset as b9,
49796
- shift as ba,
49797
- limitShift as bb,
49798
- flip as bc,
49799
- size as bd,
49800
- arrow as be,
49801
- hide as bf,
49802
- autoUpdate as bg,
49803
- cancelRun as bh,
49804
- reenqueueRun as bi,
49805
- wakeUpRun as bj,
49806
- resumeHook as bk,
49807
- fetchHookToken as bl,
49808
- recreateRun as bm,
50571
+ decrypt as b3,
50572
+ deriveRunPayloadKeys as b4,
50573
+ getWebRevivers as b5,
50574
+ LIVE_UPDATE_INTERVAL_MS as b6,
50575
+ getEncryptionKeyForRun as b7,
50576
+ StreamViewer as b8,
50577
+ composeRefs as b9,
50578
+ useFloating as ba,
50579
+ offset as bb,
50580
+ shift as bc,
50581
+ limitShift as bd,
50582
+ flip as be,
50583
+ size as bf,
50584
+ arrow as bg,
50585
+ hide as bh,
50586
+ autoUpdate as bi,
50587
+ VERCEL_403_ERROR_MESSAGE as bj,
50588
+ cancelRun as bk,
50589
+ reenqueueRun as bl,
50590
+ wakeUpRun as bm,
50591
+ resumeHook as bn,
50592
+ fetchHookToken as bo,
50593
+ recreateRun as bp,
49809
50594
  createLucideIcon as c,
49810
50595
  runHealthCheck as d,
49811
50596
  cn as e,