@workflow/web 5.0.0-beta.36 → 5.0.0-beta.38

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 (33) hide show
  1. package/build/client/assets/app-_i85JgUF.css +1 -0
  2. package/build/client/assets/{arrow-up-right-Dv3gGqIf.js → arrow-up-right-BRTGGI7c.js} +1 -1
  3. package/build/client/assets/{entry.client-Q4eUIqMI.js → entry.client-LwI3HNYl.js} +1 -1
  4. package/build/client/assets/{highlighted-body-B3W2YXNL-C5gyMelW.js → highlighted-body-B3W2YXNL-DwhUiBi7.js} +2 -2
  5. package/build/client/assets/{home-0OfTSXd1.js → home-DBrnNvHF.js} +7 -7
  6. package/build/client/assets/{index-Q81MFBxC.js → index-PFjW8YjQ.js} +20 -20
  7. package/build/client/assets/loader-circle-WvWWlrvM.js +12 -0
  8. package/build/client/assets/manifest-70ec0eba.js +1 -0
  9. package/build/client/assets/{mermaid-3ZIDBTTL-C_EWPx9a.js → mermaid-3ZIDBTTL-xYKZZytQ.js} +1063 -288
  10. package/build/client/assets/root-CINgYZFD.css +1 -0
  11. package/build/client/assets/{root-BPK1T9Ck.js → root-Cimnh7R3.js} +15 -30
  12. package/build/client/assets/{run-detail-CrqNzQ_y.js → run-detail-Dr7nmBuO.js} +74 -168
  13. package/build/client/assets/{workflow-graph-viewer-DrfqsDRu.js → workflow-graph-viewer-tTf4FHzV.js} +65 -87
  14. package/build/client/assets/{zstd-browser-decoder-Ds2MNSdp.js → zstd-browser-decoder-B15ptsR4.js} +2 -2
  15. package/build/server/assets/{server-build-4Pq8AwvA.js → app-BUMjG2-y.js} +129788 -119883
  16. package/build/server/assets/{highlighted-body-B3W2YXNL-C7tx66m_.js → highlighted-body-B3W2YXNL-Bkx5Bh9I.js} +3 -4
  17. package/build/server/assets/{index-Cnj8rNtV.js → index-DVvcuTAp.js} +50 -52
  18. package/build/server/assets/{mermaid-3ZIDBTTL-DStR4R-M.js → mermaid-3ZIDBTTL-CSJYRI2g.js} +4 -5
  19. package/build/server/assets/{token-CYc8-6E0.js → token-BXRDO8X7.js} +1 -2
  20. package/build/server/assets/{token-util-D94FNaX0.js → token-util-2RA-Rh-5.js} +1 -2
  21. package/build/server/assets/{zstd-browser-decoder-DXnLXD-w.js → zstd-browser-decoder-Cqnyq-Ly.js} +4 -5
  22. package/build/server/index.js +41 -2
  23. package/handler.d.ts +22 -0
  24. package/handler.js +186 -0
  25. package/package.json +20 -8
  26. package/registry.d.ts +29 -0
  27. package/registry.js +89 -0
  28. package/build/client/assets/encryption-CLVP4klT.js +0 -51
  29. package/build/client/assets/index-STTN0-2V.js +0 -306
  30. package/build/client/assets/manifest-485c4078.js +0 -1
  31. package/build/client/assets/root-15oK726f.css +0 -1
  32. package/build/client/assets/server-build-DblSGQ6A.css +0 -1
  33. package/build/server/assets/app-BSsmG188.js +0 -9217
@@ -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-Ds2MNSdp.js","assets/highlighted-body-B3W2YXNL-C5gyMelW.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/zstd-browser-decoder-B15ptsR4.js","assets/index-PFjW8YjQ.js","assets/highlighted-body-B3W2YXNL-DwhUiBi7.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,
@@ -6746,22 +6746,30 @@ const createLucideIcon = (iconName, iconNode) => {
6746
6746
  * This source code is licensed under the ISC license.
6747
6747
  * See the LICENSE file in the root directory of this source tree.
6748
6748
  */
6749
- const __iconNode$5 = [
6749
+ const __iconNode$6 = [
6750
6750
  ["path", { d: "m12 19-7-7 7-7", key: "1l729n" }],
6751
6751
  ["path", { d: "M19 12H5", key: "x3x0zl" }]
6752
6752
  ];
6753
- const ArrowLeft = createLucideIcon("arrow-left", __iconNode$5);
6753
+ const ArrowLeft = createLucideIcon("arrow-left", __iconNode$6);
6754
6754
  /**
6755
6755
  * @license lucide-react v0.575.0 - ISC
6756
6756
  *
6757
6757
  * This source code is licensed under the ISC license.
6758
6758
  * See the LICENSE file in the root directory of this source tree.
6759
6759
  */
6760
- const __iconNode$4 = [
6760
+ const __iconNode$5 = [
6761
6761
  ["path", { d: "M5 12h14", key: "1ays0h" }],
6762
6762
  ["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }]
6763
6763
  ];
6764
- const ArrowRight = createLucideIcon("arrow-right", __iconNode$4);
6764
+ const ArrowRight = createLucideIcon("arrow-right", __iconNode$5);
6765
+ /**
6766
+ * @license lucide-react v0.575.0 - ISC
6767
+ *
6768
+ * This source code is licensed under the ISC license.
6769
+ * See the LICENSE file in the root directory of this source tree.
6770
+ */
6771
+ const __iconNode$4 = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
6772
+ const Check = createLucideIcon("check", __iconNode$4);
6765
6773
  /**
6766
6774
  * @license lucide-react v0.575.0 - ISC
6767
6775
  *
@@ -6784,8 +6792,11 @@ const ChevronRight = createLucideIcon("chevron-right", __iconNode$2);
6784
6792
  * This source code is licensed under the ISC license.
6785
6793
  * See the LICENSE file in the root directory of this source tree.
6786
6794
  */
6787
- const __iconNode$1 = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
6788
- const LoaderCircle = createLucideIcon("loader-circle", __iconNode$1);
6795
+ const __iconNode$1 = [
6796
+ ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
6797
+ ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
6798
+ ];
6799
+ const Copy = createLucideIcon("copy", __iconNode$1);
6789
6800
  /**
6790
6801
  * @license lucide-react v0.575.0 - ISC
6791
6802
  *
@@ -15172,7 +15183,14 @@ const RunCreatedEventSchema = BaseEventSchema.extend({
15172
15183
  input: SerializedDataSchema,
15173
15184
  executionContext: record(string$2(), any()).optional(),
15174
15185
  attributes: record(string$2(), string$2()).optional(),
15175
- allowReservedAttributes: literal(true).optional()
15186
+ allowReservedAttributes: literal(true).optional(),
15187
+ /**
15188
+ * The run's X25519 public key (base64), stamped by SDKs that support
15189
+ * sealed (`encp`) envelopes. Persisted onto the run entity so that
15190
+ * cross-run writers can seal payloads to this run without holding its
15191
+ * symmetric key. Not secret — see `WorkflowRunBaseSchema`.
15192
+ */
15193
+ encryptionPublicKey: string$2().optional()
15176
15194
  })
15177
15195
  });
15178
15196
  const RunStartedEventSchema = BaseEventSchema.extend({
@@ -15183,7 +15201,14 @@ const RunStartedEventSchema = BaseEventSchema.extend({
15183
15201
  workflowName: string$2().optional(),
15184
15202
  executionContext: record(string$2(), any()).optional(),
15185
15203
  attributes: record(string$2(), string$2()).optional(),
15186
- allowReservedAttributes: literal(true).optional()
15204
+ allowReservedAttributes: literal(true).optional(),
15205
+ /**
15206
+ * Mirrors `run_created.eventData.encryptionPublicKey`. Carried here for
15207
+ * the resilient-start path: when the `run_created` write failed, the
15208
+ * server creates the run from this event instead, and without the key
15209
+ * the run would silently lose its ability to receive sealed writes.
15210
+ */
15211
+ encryptionPublicKey: string$2().optional()
15187
15212
  }).optional()
15188
15213
  });
15189
15214
  const RunCompletedEventSchema = BaseEventSchema.extend({
@@ -15345,6 +15370,26 @@ const WorkflowRunBaseSchema = object({
15345
15370
  * the attributes-mvp changelog entry.
15346
15371
  */
15347
15372
  attributes: record(string$2(), string$2()).default({}),
15373
+ /**
15374
+ * The run's X25519 public key, base64-encoded (~44 chars).
15375
+ *
15376
+ * Lets any party that can read this run seal a payload *to* it without
15377
+ * being able to read the run's data — used for cross-run writes such as a
15378
+ * hook resumption from another deployment, or a child workflow writing into
15379
+ * a forwarded stream. The matching private scalar is never stored: it is
15380
+ * re-derived on demand from the deployment's own key material, so this
15381
+ * field is not secret and its presence does not weaken the run's
15382
+ * confidentiality.
15383
+ *
15384
+ * Stamped at run creation by SDKs that support sealed (`encp`) envelopes.
15385
+ * **Presence is the writer-side gate**: a run only carries a public key if
15386
+ * the runtime that created it could also open sealed payloads, and runs are
15387
+ * pinned to their creating deployment. Writers therefore seal iff this
15388
+ * field is set, and otherwise fall back to fetching the symmetric per-run
15389
+ * key. Absent on runs created by older SDKs, and on worlds that do not
15390
+ * implement `getEncryptionKeyForRun` (encryption disabled).
15391
+ */
15392
+ encryptionPublicKey: string$2().optional(),
15348
15393
  expiredAt: date().optional(),
15349
15394
  startedAt: date().optional(),
15350
15395
  completedAt: date().optional(),
@@ -15549,22 +15594,8 @@ object({
15549
15594
  firstSeenAt: date(),
15550
15595
  lastSeenAt: date()
15551
15596
  });
15552
- object({
15553
- runId: string$2(),
15554
- hookId: string$2(),
15555
- token: string$2(),
15556
- ownerId: string$2(),
15557
- projectId: string$2(),
15558
- environment: string$2(),
15559
- metadata: SerializedDataSchema.optional(),
15560
- createdAt: date(),
15561
- // Optional in database for backwards compatibility, defaults to 1 (legacy) when reading
15562
- specVersion: number$3().optional(),
15563
- isWebhook: boolean$2().optional(),
15564
- isSystem: boolean$2().optional()
15565
- });
15566
- string$2().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_(?:workflow|step)_$/, "Must match __wkf_{workflow|step}_ or __{namespace}_wkf_{workflow|step}_");
15567
- string$2().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_(?:workflow|step)_.+$/, "Must be a valid queue name with a recognized prefix");
15597
+ string$2().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_workflow_$/, "Must match __wkf_workflow_ or __{namespace}_wkf_workflow_");
15598
+ string$2().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_workflow_.+$/, "Must be a valid queue name with a recognized prefix");
15568
15599
  string$2().regex(/^[a-z][a-z0-9]*$/, "Must be lowercase alphanumeric, starting with a letter");
15569
15600
  string$2().brand().describe("A stored queue message ID");
15570
15601
  const TraceCarrierSchema = record(string$2(), string$2());
@@ -15602,23 +15633,57 @@ const WorkflowInvokePayloadSchema = object({
15602
15633
  /** Run creation data, only present on the first queue delivery from start() */
15603
15634
  runInput: RunInputSchema.optional()
15604
15635
  });
15605
- const StepInvokePayloadSchema = object({
15606
- workflowName: string$2(),
15607
- workflowRunId: string$2(),
15608
- workflowStartedAt: number$3(),
15609
- stepId: string$2(),
15610
- traceCarrier: TraceCarrierSchema.optional(),
15611
- requestedAt: date().optional()
15612
- });
15613
15636
  const HealthCheckPayloadSchema = object({
15614
15637
  __healthCheck: literal(true),
15615
- correlationId: string$2()
15638
+ correlationId: string$2(),
15639
+ /**
15640
+ * The run id the caller is about to create, when the probe is being used to
15641
+ * prepare a cross-deployment `start()`.
15642
+ *
15643
+ * The responder runs inside the target deployment, so it can derive that
15644
+ * run's public key locally from its own key material and return it in the
15645
+ * probe response. That lets the caller seal the workflow arguments without
15646
+ * a separate key lookup. Absent for probes issued for other reasons (CLI
15647
+ * health command, dashboard), in which case no key is returned.
15648
+ */
15649
+ runId: string$2().optional()
15616
15650
  });
15617
15651
  union([
15618
- WorkflowInvokePayloadSchema,
15619
- StepInvokePayloadSchema,
15620
- HealthCheckPayloadSchema
15652
+ HealthCheckPayloadSchema,
15653
+ WorkflowInvokePayloadSchema
15621
15654
  ]);
15655
+ const HookResumeContextSchema = object({
15656
+ deploymentId: string$2(),
15657
+ workflowName: string$2(),
15658
+ // Named `runSpecVersion` to distinguish it from the hook's own `specVersion`.
15659
+ runSpecVersion: number$3().optional(),
15660
+ workflowCoreVersion: string$2().optional(),
15661
+ traceCarrier: TraceCarrierSchema.optional(),
15662
+ // The run's published X25519 public key (base64), mirrored from the run
15663
+ // entity. Lets a resume seal (`encp`) its payload to the run without reading
15664
+ // the run or fetching its symmetric key. Absent on runs created before
15665
+ // sealed envelopes and on projects with encryption disabled, where the
15666
+ // resume falls back to the symmetric per-run key.
15667
+ encryptionPublicKey: string$2().optional()
15668
+ });
15669
+ object({
15670
+ runId: string$2(),
15671
+ hookId: string$2(),
15672
+ token: string$2(),
15673
+ ownerId: string$2(),
15674
+ projectId: string$2(),
15675
+ environment: string$2(),
15676
+ metadata: SerializedDataSchema.optional(),
15677
+ createdAt: date(),
15678
+ // Optional in database for backwards compatibility, defaults to 1 (legacy) when reading
15679
+ specVersion: number$3().optional(),
15680
+ isWebhook: boolean$2().optional(),
15681
+ isSystem: boolean$2().optional(),
15682
+ // Present when the server stored it (new hooks) or synthesized it from the
15683
+ // run (old hooks). Absent only against an old server, where the resume path
15684
+ // falls back to `runs.get`.
15685
+ resumeContext: HookResumeContextSchema.optional()
15686
+ });
15622
15687
  const zodJsonSchema = lazy(() => {
15623
15688
  return union([
15624
15689
  string$2(),
@@ -15866,11 +15931,659 @@ function unflatten(parsed, revivers) {
15866
15931
  }
15867
15932
  return hydrate(0);
15868
15933
  }
15934
+ var ms$1;
15935
+ var hasRequiredMs;
15936
+ function requireMs() {
15937
+ if (hasRequiredMs) return ms$1;
15938
+ hasRequiredMs = 1;
15939
+ var s2 = 1e3;
15940
+ var m2 = s2 * 60;
15941
+ var h2 = m2 * 60;
15942
+ var d2 = h2 * 24;
15943
+ var w2 = d2 * 7;
15944
+ var y2 = d2 * 365.25;
15945
+ ms$1 = function(val, options) {
15946
+ options = options || {};
15947
+ var type = typeof val;
15948
+ if (type === "string" && val.length > 0) {
15949
+ return parse2(val);
15950
+ } else if (type === "number" && isFinite(val)) {
15951
+ return options.long ? fmtLong(val) : fmtShort(val);
15952
+ }
15953
+ throw new Error(
15954
+ "val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
15955
+ );
15956
+ };
15957
+ function parse2(str) {
15958
+ str = String(str);
15959
+ if (str.length > 100) {
15960
+ return;
15961
+ }
15962
+ 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(
15963
+ str
15964
+ );
15965
+ if (!match) {
15966
+ return;
15967
+ }
15968
+ var n = parseFloat(match[1]);
15969
+ var type = (match[2] || "ms").toLowerCase();
15970
+ switch (type) {
15971
+ case "years":
15972
+ case "year":
15973
+ case "yrs":
15974
+ case "yr":
15975
+ case "y":
15976
+ return n * y2;
15977
+ case "weeks":
15978
+ case "week":
15979
+ case "w":
15980
+ return n * w2;
15981
+ case "days":
15982
+ case "day":
15983
+ case "d":
15984
+ return n * d2;
15985
+ case "hours":
15986
+ case "hour":
15987
+ case "hrs":
15988
+ case "hr":
15989
+ case "h":
15990
+ return n * h2;
15991
+ case "minutes":
15992
+ case "minute":
15993
+ case "mins":
15994
+ case "min":
15995
+ case "m":
15996
+ return n * m2;
15997
+ case "seconds":
15998
+ case "second":
15999
+ case "secs":
16000
+ case "sec":
16001
+ case "s":
16002
+ return n * s2;
16003
+ case "milliseconds":
16004
+ case "millisecond":
16005
+ case "msecs":
16006
+ case "msec":
16007
+ case "ms":
16008
+ return n;
16009
+ default:
16010
+ return void 0;
16011
+ }
16012
+ }
16013
+ function fmtShort(ms2) {
16014
+ var msAbs = Math.abs(ms2);
16015
+ if (msAbs >= d2) {
16016
+ return Math.round(ms2 / d2) + "d";
16017
+ }
16018
+ if (msAbs >= h2) {
16019
+ return Math.round(ms2 / h2) + "h";
16020
+ }
16021
+ if (msAbs >= m2) {
16022
+ return Math.round(ms2 / m2) + "m";
16023
+ }
16024
+ if (msAbs >= s2) {
16025
+ return Math.round(ms2 / s2) + "s";
16026
+ }
16027
+ return ms2 + "ms";
16028
+ }
16029
+ function fmtLong(ms2) {
16030
+ var msAbs = Math.abs(ms2);
16031
+ if (msAbs >= d2) {
16032
+ return plural(ms2, msAbs, d2, "day");
16033
+ }
16034
+ if (msAbs >= h2) {
16035
+ return plural(ms2, msAbs, h2, "hour");
16036
+ }
16037
+ if (msAbs >= m2) {
16038
+ return plural(ms2, msAbs, m2, "minute");
16039
+ }
16040
+ if (msAbs >= s2) {
16041
+ return plural(ms2, msAbs, s2, "second");
16042
+ }
16043
+ return ms2 + " ms";
16044
+ }
16045
+ function plural(ms2, msAbs, n, name2) {
16046
+ var isPlural = msAbs >= n * 1.5;
16047
+ return Math.round(ms2 / n) + " " + name2 + (isPlural ? "s" : "");
16048
+ }
16049
+ return ms$1;
16050
+ }
16051
+ var msExports = requireMs();
16052
+ const ms = /* @__PURE__ */ getDefaultExportFromCjs(msExports);
16053
+ function parseDurationToDate(param) {
16054
+ if (typeof param === "string") {
16055
+ const durationMs = ms(param);
16056
+ if (typeof durationMs !== "number" || durationMs < 0) {
16057
+ throw new Error(`Invalid duration: "${param}". Expected a valid duration string like "1s", "1m", "1h", etc.`);
16058
+ }
16059
+ return new Date(Date.now() + durationMs);
16060
+ } else if (typeof param === "number") {
16061
+ if (param < 0 || !Number.isFinite(param)) {
16062
+ throw new Error(`Invalid duration: ${param}. Expected a non-negative finite number of milliseconds.`);
16063
+ }
16064
+ return new Date(Date.now() + param);
16065
+ } else if (param instanceof Date || param && typeof param === "object" && typeof param.getTime === "function") {
16066
+ return param instanceof Date ? param : new Date(param.getTime());
16067
+ } else {
16068
+ throw new Error(`Invalid duration parameter. Expected a duration string, number (milliseconds), or Date object.`);
16069
+ }
16070
+ }
16071
+ const BASE_URL = "https://workflow-sdk.dev/err";
16072
+ function isError(value) {
16073
+ return typeof value === "object" && value !== null && "name" in value && "message" in value;
16074
+ }
16075
+ function appendFramedDetails(title, details) {
16076
+ if (details.length === 0)
16077
+ return title;
16078
+ const lines = [title];
16079
+ details.forEach((detail, index2) => {
16080
+ const isLast = index2 === details.length - 1;
16081
+ const head = isLast ? "╰▶ " : "├▶ ";
16082
+ const cont = isLast ? " " : "│ ";
16083
+ const text2 = `${detail.label}: ${detail.value}`;
16084
+ text2.split("\n").forEach((line, i) => lines.push(`${i === 0 ? head : cont}${line}`));
16085
+ });
16086
+ return lines.join("\n");
16087
+ }
16088
+ function buildFramedDetails(hint, slug) {
16089
+ const out = [];
16090
+ if (slug)
16091
+ out.push({ label: "docs", value: `${BASE_URL}/${slug}` });
16092
+ return out;
16093
+ }
16094
+ const ERROR_SLUGS = {
16095
+ HOOK_CONFLICT: "hook-conflict",
16096
+ RUNTIME_DECRYPTION_FAILED: "runtime-decryption-failed"
16097
+ };
16098
+ class WorkflowError extends Error {
16099
+ constructor(message, options) {
16100
+ const msgDocs = appendFramedDetails(message, buildFramedDetails(void 0, options == null ? void 0 : options.slug));
16101
+ super(msgDocs, { cause: options == null ? void 0 : options.cause });
16102
+ __publicField(this, "cause");
16103
+ if ((options == null ? void 0 : options.cause) !== void 0) {
16104
+ this.cause = options.cause;
16105
+ }
16106
+ if ((options == null ? void 0 : options.cause) instanceof Error) {
16107
+ this.stack = `${this.stack}
16108
+ Caused by: ${options.cause.stack}`;
16109
+ }
16110
+ }
16111
+ static is(value) {
16112
+ return isError(value) && value.name === "WorkflowError";
16113
+ }
16114
+ }
16115
+ class WorkflowRuntimeError extends WorkflowError {
16116
+ constructor(message, options) {
16117
+ super(message, {
16118
+ ...options
16119
+ });
16120
+ this.name = "WorkflowRuntimeError";
16121
+ }
16122
+ static is(value) {
16123
+ return isError(value) && value.name === "WorkflowRuntimeError";
16124
+ }
16125
+ }
16126
+ class RuntimeDecryptionError extends WorkflowRuntimeError {
16127
+ constructor(message, options) {
16128
+ super(message, {
16129
+ cause: options == null ? void 0 : options.cause,
16130
+ slug: ERROR_SLUGS.RUNTIME_DECRYPTION_FAILED
16131
+ });
16132
+ this.name = "RuntimeDecryptionError";
16133
+ if ((options == null ? void 0 : options.context) !== void 0) {
16134
+ this.context = options.context;
16135
+ }
16136
+ }
16137
+ static is(value) {
16138
+ return isError(value) && value.name === "RuntimeDecryptionError";
16139
+ }
16140
+ }
16141
+ class HookConflictError extends WorkflowError {
16142
+ constructor(token, conflictingRunId) {
16143
+ super(`Hook token "${token}" is already in use by another workflow${conflictingRunId ? ` (run "${conflictingRunId}")` : ""}`, {
16144
+ slug: ERROR_SLUGS.HOOK_CONFLICT
16145
+ });
16146
+ __publicField(this, "token");
16147
+ // TODO: Make this required once all persisted hook_conflict events and World
16148
+ // implementations always include the active hook owner's run ID.
16149
+ __publicField(this, "conflictingRunId");
16150
+ this.name = "HookConflictError";
16151
+ this.token = token;
16152
+ if (conflictingRunId !== void 0) {
16153
+ this.conflictingRunId = conflictingRunId;
16154
+ }
16155
+ }
16156
+ static is(value) {
16157
+ return isError(value) && value.name === "HookConflictError";
16158
+ }
16159
+ }
16160
+ class FatalError extends Error {
16161
+ constructor(message) {
16162
+ super(message);
16163
+ __publicField(this, "fatal", true);
16164
+ this.name = "FatalError";
16165
+ }
16166
+ static is(value) {
16167
+ if (!isError(value))
16168
+ return false;
16169
+ if (value.name === "FatalError")
16170
+ return true;
16171
+ return value.fatal === true;
16172
+ }
16173
+ }
16174
+ class RetryableError extends Error {
16175
+ constructor(message, options = {}) {
16176
+ super(message);
16177
+ /**
16178
+ * The Date when the step should be retried.
16179
+ */
16180
+ __publicField(this, "retryAfter");
16181
+ this.name = "RetryableError";
16182
+ if (options.retryAfter !== void 0) {
16183
+ this.retryAfter = parseDurationToDate(options.retryAfter);
16184
+ } else {
16185
+ this.retryAfter = new Date(Date.now() + 1e3);
16186
+ }
16187
+ }
16188
+ static is(value) {
16189
+ return isError(value) && value.name === "RetryableError";
16190
+ }
16191
+ }
16192
+ 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.";
16193
+ const FATAL_ERROR_KEY = Symbol.for("@workflow/errors//FatalError");
16194
+ const RETRYABLE_ERROR_KEY = Symbol.for("@workflow/errors//RetryableError");
16195
+ const HOOK_CONFLICT_ERROR_KEY = Symbol.for("@workflow/errors//HookConflictError");
16196
+ const RUNTIME_DECRYPTION_ERROR_KEY = Symbol.for("@workflow/errors//RuntimeDecryptionError");
16197
+ if (typeof globalThis !== "undefined") {
16198
+ if (!Object.hasOwn(globalThis, FATAL_ERROR_KEY)) {
16199
+ Object.defineProperty(globalThis, FATAL_ERROR_KEY, {
16200
+ value: FatalError,
16201
+ writable: false,
16202
+ enumerable: false,
16203
+ configurable: false
16204
+ });
16205
+ }
16206
+ if (!Object.hasOwn(globalThis, RETRYABLE_ERROR_KEY)) {
16207
+ Object.defineProperty(globalThis, RETRYABLE_ERROR_KEY, {
16208
+ value: RetryableError,
16209
+ writable: false,
16210
+ enumerable: false,
16211
+ configurable: false
16212
+ });
16213
+ }
16214
+ if (!Object.hasOwn(globalThis, HOOK_CONFLICT_ERROR_KEY)) {
16215
+ Object.defineProperty(globalThis, HOOK_CONFLICT_ERROR_KEY, {
16216
+ value: HookConflictError,
16217
+ writable: false,
16218
+ enumerable: false,
16219
+ configurable: false
16220
+ });
16221
+ }
16222
+ if (!Object.hasOwn(globalThis, RUNTIME_DECRYPTION_ERROR_KEY)) {
16223
+ Object.defineProperty(globalThis, RUNTIME_DECRYPTION_ERROR_KEY, {
16224
+ value: RuntimeDecryptionError,
16225
+ writable: false,
16226
+ enumerable: false,
16227
+ configurable: false
16228
+ });
16229
+ }
16230
+ }
16231
+ const NONCE_LENGTH = 12;
16232
+ const TAG_LENGTH = 128;
16233
+ const TAG_BYTES = TAG_LENGTH / 8;
16234
+ const KEY_LENGTH = 32;
16235
+ async function importKey(raw2, usages = ["encrypt", "decrypt"]) {
16236
+ if (raw2.byteLength !== KEY_LENGTH) {
16237
+ throw new WorkflowRuntimeError(`Encryption key must be exactly ${KEY_LENGTH} bytes, got ${raw2.byteLength}`);
16238
+ }
16239
+ return globalThis.crypto.subtle.importKey(
16240
+ "raw",
16241
+ raw2,
16242
+ "AES-GCM",
16243
+ false,
16244
+ // `KeyUsage` is a DOM-lib type that's not in scope under `es2022`.
16245
+ // The `ReadonlyArray<'encrypt' | 'decrypt'>` parameter type matches
16246
+ // a strict subset of `KeyUsage[]`, so this cast is sound.
16247
+ usages
16248
+ );
16249
+ }
16250
+ async function decrypt$1(key, data, aad) {
16251
+ const minLength = NONCE_LENGTH + TAG_LENGTH / 8;
16252
+ if (data.byteLength < minLength) {
16253
+ throw new RuntimeDecryptionError(`Encrypted data too short: expected at least ${minLength} bytes, got ${data.byteLength}`, {
16254
+ context: {
16255
+ operation: "decrypt",
16256
+ byteLength: data.byteLength
16257
+ }
16258
+ });
16259
+ }
16260
+ const nonce = data.subarray(0, NONCE_LENGTH);
16261
+ const ciphertext = data.subarray(NONCE_LENGTH);
16262
+ let plaintext;
16263
+ try {
16264
+ plaintext = await globalThis.crypto.subtle.decrypt({
16265
+ name: "AES-GCM",
16266
+ iv: nonce,
16267
+ tagLength: TAG_LENGTH,
16268
+ ...aad ? { additionalData: aad } : {}
16269
+ }, key, ciphertext);
16270
+ } catch (cause) {
16271
+ const causeMsg = cause instanceof Error ? cause.message : String(cause);
16272
+ throw new RuntimeDecryptionError(`AES-256-GCM decryption failed: ${causeMsg}`, {
16273
+ cause,
16274
+ context: {
16275
+ operation: "decrypt",
16276
+ byteLength: data.byteLength
16277
+ }
16278
+ });
16279
+ }
16280
+ return new Uint8Array(plaintext);
16281
+ }
16282
+ const X25519_KEY_LENGTH = 32;
16283
+ const CONTENT_KEY_LENGTH = 32;
16284
+ const SCALAR_INFO = "workflow/encp/x25519/v1";
16285
+ const CONTENT_KEY_INFO = "workflow/encp/aes256gcm/v1";
16286
+ const PKCS8_X25519_PREFIX = new Uint8Array([
16287
+ 48,
16288
+ 46,
16289
+ 2,
16290
+ 1,
16291
+ 0,
16292
+ 48,
16293
+ 5,
16294
+ 6,
16295
+ 3,
16296
+ 43,
16297
+ 101,
16298
+ 110,
16299
+ 4,
16300
+ 34,
16301
+ 4,
16302
+ 32
16303
+ ]);
16304
+ const infoEncoder = new TextEncoder();
16305
+ function assertKeyMaterialLength(runKeyMaterial) {
16306
+ if (runKeyMaterial.byteLength !== CONTENT_KEY_LENGTH) {
16307
+ throw new WorkflowRuntimeError(`Run key material must be exactly ${CONTENT_KEY_LENGTH} bytes, got ${runKeyMaterial.byteLength}`);
16308
+ }
16309
+ }
16310
+ async function deriveRunKeyPair(runKeyMaterial) {
16311
+ assertKeyMaterialLength(runKeyMaterial);
16312
+ const hkdfKey = await globalThis.crypto.subtle.importKey("raw", runKeyMaterial, "HKDF", false, ["deriveBits"]);
16313
+ const scalarBits = await globalThis.crypto.subtle.deriveBits({
16314
+ name: "HKDF",
16315
+ hash: "SHA-256",
16316
+ salt: new Uint8Array(32),
16317
+ info: infoEncoder.encode(SCALAR_INFO)
16318
+ }, hkdfKey, X25519_KEY_LENGTH * 8);
16319
+ const scalar = new Uint8Array(scalarBits);
16320
+ const publicKey = await derivePublicKeyFromScalar(scalar);
16321
+ return { scalar, publicKey };
16322
+ }
16323
+ async function derivePublicKeyFromScalar(scalar) {
16324
+ const privateKey = await importScalar(
16325
+ scalar,
16326
+ /* extractable */
16327
+ true
16328
+ );
16329
+ const jwk = await globalThis.crypto.subtle.exportKey("jwk", privateKey);
16330
+ if (!jwk.x) {
16331
+ throw new WorkflowRuntimeError('X25519 JWK export did not include a public key component ("x")');
16332
+ }
16333
+ const publicKey = base64UrlToBytes(jwk.x);
16334
+ if (publicKey.byteLength !== X25519_KEY_LENGTH) {
16335
+ throw new WorkflowRuntimeError(`X25519 JWK export produced a ${publicKey.byteLength}-byte public key, expected ${X25519_KEY_LENGTH}`);
16336
+ }
16337
+ return publicKey;
16338
+ }
16339
+ async function importScalar(scalar, extractable) {
16340
+ const pkcs8 = new Uint8Array(PKCS8_X25519_PREFIX.length + scalar.byteLength);
16341
+ pkcs8.set(PKCS8_X25519_PREFIX, 0);
16342
+ pkcs8.set(scalar, PKCS8_X25519_PREFIX.length);
16343
+ return globalThis.crypto.subtle.importKey("pkcs8", pkcs8, { name: "X25519" }, extractable, ["deriveBits"]);
16344
+ }
16345
+ function importPublicKey(publicKey) {
16346
+ return globalThis.crypto.subtle.importKey(
16347
+ "raw",
16348
+ publicKey,
16349
+ { name: "X25519" },
16350
+ /* extractable */
16351
+ true,
16352
+ // Public keys carry no usages for X25519 — the private key does the
16353
+ // deriving; the public key is only ever an argument to it.
16354
+ []
16355
+ );
16356
+ }
16357
+ const BASE64URL_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
16358
+ function base64UrlToBytes(value) {
16359
+ let accumulator = 0;
16360
+ let bitCount = 0;
16361
+ const bytes = [];
16362
+ for (let i = 0; i < value.length; i++) {
16363
+ const char = value[i];
16364
+ if (char === "=")
16365
+ break;
16366
+ const index2 = BASE64URL_CHARS.indexOf(char);
16367
+ if (index2 === -1) {
16368
+ throw new WorkflowRuntimeError(`Invalid base64url character "${char}" in X25519 JWK key component`);
16369
+ }
16370
+ accumulator = accumulator << 6 | index2;
16371
+ bitCount += 6;
16372
+ if (bitCount >= 8) {
16373
+ bitCount -= 8;
16374
+ bytes.push(accumulator >> bitCount & 255);
16375
+ }
16376
+ }
16377
+ return new Uint8Array(bytes);
16378
+ }
16379
+ async function deriveContentKey(sharedSecret, ephemeralPublicKey, recipientPublicKey, usages) {
16380
+ const label = infoEncoder.encode(CONTENT_KEY_INFO);
16381
+ const info = new Uint8Array(label.length + ephemeralPublicKey.length + recipientPublicKey.length);
16382
+ info.set(label, 0);
16383
+ info.set(ephemeralPublicKey, label.length);
16384
+ info.set(recipientPublicKey, label.length + ephemeralPublicKey.length);
16385
+ const hkdfKey = await globalThis.crypto.subtle.importKey("raw", sharedSecret, "HKDF", false, ["deriveBits"]);
16386
+ const contentKeyBits = await globalThis.crypto.subtle.deriveBits({ name: "HKDF", hash: "SHA-256", salt: new Uint8Array(32), info }, hkdfKey, CONTENT_KEY_LENGTH * 8);
16387
+ return globalThis.crypto.subtle.importKey(
16388
+ "raw",
16389
+ new Uint8Array(contentKeyBits),
16390
+ "AES-GCM",
16391
+ false,
16392
+ // `KeyUsage` is a DOM-lib type that is not in scope under `es2022`; the
16393
+ // parameter type is a strict subset of it, so this cast is sound.
16394
+ usages
16395
+ );
16396
+ }
16397
+ async function decapsulate(keyPair, ephemeralPublicKey) {
16398
+ if (ephemeralPublicKey.byteLength !== X25519_KEY_LENGTH) {
16399
+ throw new RuntimeDecryptionError(`Sealed payload has a malformed ephemeral public key: expected ${X25519_KEY_LENGTH} bytes, got ${ephemeralPublicKey.byteLength}`, {
16400
+ context: {
16401
+ operation: "decrypt",
16402
+ byteLength: ephemeralPublicKey.byteLength
16403
+ }
16404
+ });
16405
+ }
16406
+ let sharedSecretBits;
16407
+ try {
16408
+ const [privateKey, senderKey] = await Promise.all([
16409
+ importScalar(
16410
+ keyPair.scalar,
16411
+ /* extractable */
16412
+ false
16413
+ ),
16414
+ importPublicKey(ephemeralPublicKey)
16415
+ ]);
16416
+ sharedSecretBits = await globalThis.crypto.subtle.deriveBits({ name: "X25519", public: senderKey }, privateKey, X25519_KEY_LENGTH * 8);
16417
+ } catch (cause) {
16418
+ throw new RuntimeDecryptionError(`X25519 key agreement failed while opening a sealed payload: ${cause instanceof Error ? cause.message : String(cause)}`, {
16419
+ cause,
16420
+ context: {
16421
+ operation: "decrypt",
16422
+ byteLength: ephemeralPublicKey.byteLength
16423
+ }
16424
+ });
16425
+ }
16426
+ return deriveContentKey(new Uint8Array(sharedSecretBits), ephemeralPublicKey, keyPair.publicKey, ["decrypt"]);
16427
+ }
16428
+ async function open(keyPair, sealed, aad) {
16429
+ const minLength = X25519_KEY_LENGTH + NONCE_LENGTH + TAG_BYTES;
16430
+ if (sealed.byteLength < minLength) {
16431
+ throw new RuntimeDecryptionError(`Sealed payload too short: expected at least ${minLength} bytes, got ${sealed.byteLength}`, { context: { operation: "decrypt", byteLength: sealed.byteLength } });
16432
+ }
16433
+ const ephemeralPublicKey = sealed.subarray(0, X25519_KEY_LENGTH);
16434
+ const encrypted = sealed.subarray(X25519_KEY_LENGTH);
16435
+ const contentKey = await decapsulate(keyPair, ephemeralPublicKey);
16436
+ return decrypt$1(contentKey, encrypted, aad);
16437
+ }
16438
+ function isFormatPrefix(value) {
16439
+ return value.length === 4 && /^[a-z0-9]{4}$/.test(value);
16440
+ }
16441
+ const SerializationFormat$1 = {
16442
+ /** devalue stringify/parse with TextEncoder/TextDecoder */
16443
+ DEVALUE_V1: "devl",
16444
+ /** Encrypted payload (inner payload has its own format prefix) */
16445
+ ENCRYPTED: "encr",
16446
+ /**
16447
+ * Sealed payload — asymmetrically encrypted to a run's X25519 public key
16448
+ * (inner payload has its own format prefix).
16449
+ *
16450
+ * Used for *cross-run* writes (hook payloads, forwarded stream frames),
16451
+ * where the writer holds only the recipient run's public key and therefore
16452
+ * cannot decrypt. A run's own payloads continue to use {@link ENCRYPTED}.
16453
+ * See `sealed-box.ts` for the construction.
16454
+ */
16455
+ SEALED: "encp"
16456
+ };
16457
+ const FORMAT_PREFIX_LENGTH$1 = 4;
16458
+ new TextEncoder();
16459
+ const formatDecoder$1 = new TextDecoder();
16460
+ function peekFormatPrefix(data) {
16461
+ if (!(data instanceof Uint8Array) || data.length < FORMAT_PREFIX_LENGTH$1) {
16462
+ return null;
16463
+ }
16464
+ const prefixBytes = data.subarray(0, FORMAT_PREFIX_LENGTH$1);
16465
+ const str = formatDecoder$1.decode(prefixBytes);
16466
+ return isFormatPrefix(str) ? str : null;
16467
+ }
16468
+ function decodeFormatPrefix$1(data) {
16469
+ if (!(data instanceof Uint8Array)) {
16470
+ return {
16471
+ format: SerializationFormat$1.DEVALUE_V1,
16472
+ payload: new TextEncoder().encode(JSON.stringify(data))
16473
+ };
16474
+ }
16475
+ if (data.length < FORMAT_PREFIX_LENGTH$1) {
16476
+ throw new Error(`Data too short to contain format prefix: expected at least ${FORMAT_PREFIX_LENGTH$1} bytes, got ${data.length}`);
16477
+ }
16478
+ const prefixBytes = data.subarray(0, FORMAT_PREFIX_LENGTH$1);
16479
+ const str = formatDecoder$1.decode(prefixBytes);
16480
+ if (!isFormatPrefix(str)) {
16481
+ throw new Error(`Invalid format prefix: "${str}". Must be 4 characters of [a-z0-9].`);
16482
+ }
16483
+ const payload = data.subarray(FORMAT_PREFIX_LENGTH$1);
16484
+ return { format: str, payload };
16485
+ }
16486
+ const SEAL_TARGET_BRAND = Symbol.for("workflow.serialization.sealTarget");
16487
+ const RUN_KEYS_BRAND = Symbol.for("workflow.serialization.runKeys");
16488
+ function runPayloadKeys(aes, keyPair, aad) {
16489
+ return { [RUN_KEYS_BRAND]: true, aes, keyPair, aad };
16490
+ }
16491
+ async function deriveRunPayloadKeys(runKeyMaterial) {
16492
+ const [aes, keyPair] = await Promise.all([
16493
+ importKey(runKeyMaterial),
16494
+ deriveRunKeyPair(runKeyMaterial)
16495
+ ]);
16496
+ return runPayloadKeys(aes, keyPair);
16497
+ }
16498
+ function isSealTarget(value) {
16499
+ return typeof value === "object" && value !== null && value[SEAL_TARGET_BRAND] === true;
16500
+ }
16501
+ function isRunPayloadKeys(value) {
16502
+ return typeof value === "object" && value !== null && value[RUN_KEYS_BRAND] === true;
16503
+ }
16504
+ function aesKeyOf(key) {
16505
+ if (!key)
16506
+ return void 0;
16507
+ if (isRunPayloadKeys(key))
16508
+ return key.aes;
16509
+ if (isSealTarget(key))
16510
+ return void 0;
16511
+ return key;
16512
+ }
16513
+ async function openSealedEnvelope(data, key) {
16514
+ if (!isRunPayloadKeys(key)) {
16515
+ 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.", {
16516
+ context: {
16517
+ operation: "decrypt",
16518
+ byteLength: data.byteLength,
16519
+ formatPrefix: "encp"
16520
+ }
16521
+ });
16522
+ }
16523
+ const { payload } = decodeFormatPrefix$1(data);
16524
+ try {
16525
+ return await open(key.keyPair, payload, key.aad);
16526
+ } catch (error) {
16527
+ if (RuntimeDecryptionError.is(error) && error.context) {
16528
+ error.context.formatPrefix = SerializationFormat$1.SEALED;
16529
+ }
16530
+ throw error;
16531
+ }
16532
+ }
16533
+ async function decrypt(data, key) {
16534
+ if (!(data instanceof Uint8Array))
16535
+ return data;
16536
+ const format = peekFormatPrefix(data);
16537
+ if (format === SerializationFormat$1.SEALED) {
16538
+ return openSealedEnvelope(data, key);
16539
+ }
16540
+ if (format !== SerializationFormat$1.ENCRYPTED)
16541
+ return data;
16542
+ const aesKey = aesKeyOf(key);
16543
+ if (!aesKey) {
16544
+ throw new RuntimeDecryptionError("Encrypted data encountered but no encryption key is available. Encryption is not configured or no key was provided for this run.", {
16545
+ context: {
16546
+ operation: "decrypt",
16547
+ byteLength: data.byteLength,
16548
+ formatPrefix: "encr"
16549
+ }
16550
+ });
16551
+ }
16552
+ const { payload } = decodeFormatPrefix$1(data);
16553
+ try {
16554
+ return await decrypt$1(aesKey, payload);
16555
+ } catch (error) {
16556
+ if (RuntimeDecryptionError.is(error) && error.context) {
16557
+ error.context.formatPrefix = format;
16558
+ }
16559
+ throw error;
16560
+ }
16561
+ }
16562
+ const encryption = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
16563
+ __proto__: null,
16564
+ aesKeyOf,
16565
+ decrypt,
16566
+ deriveRunPayloadKeys,
16567
+ isRunPayloadKeys,
16568
+ isSealTarget,
16569
+ runPayloadKeys
16570
+ }, Symbol.toStringTag, { value: "Module" }));
15869
16571
  const SerializationFormat = {
15870
16572
  /** devalue stringify/parse with TextEncoder/TextDecoder */
15871
16573
  DEVALUE_V1: "devl",
15872
16574
  /** Encrypted payload (inner payload has its own format prefix after decryption) */
15873
16575
  ENCRYPTED: "encr",
16576
+ /**
16577
+ * Sealed payload — asymmetrically encrypted to a run's X25519 public key
16578
+ * (inner payload has its own format prefix after opening).
16579
+ *
16580
+ * Written by cross-run writers that hold only the recipient run's public
16581
+ * key. Opening it requires the run's private scalar rather than the
16582
+ * symmetric per-run key, so o11y display treats it as ciphertext via
16583
+ * {@link isEncryptedData} but {@link hydrateDataWithKey} does not attempt
16584
+ * an AES-GCM decrypt on it.
16585
+ */
16586
+ SEALED: "encp",
15874
16587
  /** Gzip-compressed payload (inner payload has its own format prefix after decompression) */
15875
16588
  GZIP: "gzip",
15876
16589
  /** Zstandard-compressed payload (inner payload has its own format prefix after decompression) */
@@ -15918,7 +16631,14 @@ function isEncryptedData(data) {
15918
16631
  return false;
15919
16632
  }
15920
16633
  const prefix = formatDecoder.decode(data.subarray(0, FORMAT_PREFIX_LENGTH));
15921
- return prefix === SerializationFormat.ENCRYPTED;
16634
+ return prefix === SerializationFormat.ENCRYPTED || prefix === SerializationFormat.SEALED;
16635
+ }
16636
+ function isSealedData(data) {
16637
+ if (!(data instanceof Uint8Array) || data.length < FORMAT_PREFIX_LENGTH) {
16638
+ return false;
16639
+ }
16640
+ const prefix = formatDecoder.decode(data.subarray(0, FORMAT_PREFIX_LENGTH));
16641
+ return prefix === SerializationFormat.SEALED;
15922
16642
  }
15923
16643
  function isCompressedData(data) {
15924
16644
  if (!(data instanceof Uint8Array) || data.length < FORMAT_PREFIX_LENGTH) {
@@ -16012,12 +16732,13 @@ function hydrateData(value, revivers) {
16012
16732
  async function hydrateDataWithKey(value, revivers, key) {
16013
16733
  let data = value;
16014
16734
  if (data instanceof Uint8Array && isEncryptedData(data) && key) {
16015
- const { decrypt } = await __vitePreload(async () => {
16016
- const { decrypt: decrypt2 } = await import("./encryption-CLVP4klT.js");
16017
- return { decrypt: decrypt2 };
16018
- }, true ? __vite__mapDeps([0,1,2]) : void 0);
16019
- const { payload } = decodeFormatPrefix(data);
16020
- data = await decrypt(key, payload);
16735
+ const { decrypt: decrypt2, isRunPayloadKeys: isRunPayloadKeys2 } = await __vitePreload(async () => {
16736
+ const { decrypt: decrypt3, isRunPayloadKeys: isRunPayloadKeys3 } = await Promise.resolve().then(() => encryption);
16737
+ return { decrypt: decrypt3, isRunPayloadKeys: isRunPayloadKeys3 };
16738
+ }, true ? void 0 : void 0);
16739
+ if (!isSealedData(data) || isRunPayloadKeys2(key)) {
16740
+ data = await decrypt2(data, key);
16741
+ }
16021
16742
  }
16022
16743
  if (data instanceof Uint8Array && isCompressedData(data)) {
16023
16744
  const { format, payload } = decodeFormatPrefix(data);
@@ -16244,6 +16965,8 @@ const serializationFormat = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object
16244
16965
  STREAM_REF_TYPE: STREAM_REF_TYPE$1,
16245
16966
  SerializationFormat,
16246
16967
  decodeFormatPrefix,
16968
+ decryptEnvelope: decrypt,
16969
+ deriveRunPayloadKeys,
16247
16970
  extractClassName,
16248
16971
  hydrateData,
16249
16972
  hydrateDataWithKey,
@@ -16251,9 +16974,13 @@ const serializationFormat = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object
16251
16974
  isCompressedData,
16252
16975
  isEncryptedData,
16253
16976
  isExpiredStub,
16977
+ isRunPayloadKeys,
16254
16978
  isRunRef: isRunRef$1,
16979
+ isSealTarget,
16980
+ isSealedData,
16255
16981
  observabilityRevivers,
16256
16982
  registerZstdDecoder,
16983
+ runPayloadKeys,
16257
16984
  serializedClassToString,
16258
16985
  serializedInstanceToRef,
16259
16986
  serializedRunToRunRef,
@@ -16533,19 +17260,16 @@ function replaceEncryptedAndExpiredWithMarkers(resource) {
16533
17260
  return result;
16534
17261
  }
16535
17262
  async function hydrateResourceIOAsync(resource, key) {
16536
- const { hydrateDataWithKey: hydrateDataWithKey2 } = await __vitePreload(async () => {
16537
- const { hydrateDataWithKey: hydrateDataWithKey3 } = await Promise.resolve().then(() => serializationFormat);
16538
- return { hydrateDataWithKey: hydrateDataWithKey3 };
17263
+ const { hydrateDataWithKey: hydrateDataWithKey2, deriveRunPayloadKeys: deriveRunPayloadKeys2 } = await __vitePreload(async () => {
17264
+ const { hydrateDataWithKey: hydrateDataWithKey3, deriveRunPayloadKeys: deriveRunPayloadKeys3 } = await Promise.resolve().then(() => serializationFormat);
17265
+ return { hydrateDataWithKey: hydrateDataWithKey3, deriveRunPayloadKeys: deriveRunPayloadKeys3 };
16539
17266
  }, true ? void 0 : void 0);
16540
17267
  const { ensureZstdDecoderRegistered } = await __vitePreload(async () => {
16541
- const { ensureZstdDecoderRegistered: ensureZstdDecoderRegistered2 } = await import("./zstd-browser-decoder-Ds2MNSdp.js");
17268
+ const { ensureZstdDecoderRegistered: ensureZstdDecoderRegistered2 } = await import("./zstd-browser-decoder-B15ptsR4.js");
16542
17269
  return { ensureZstdDecoderRegistered: ensureZstdDecoderRegistered2 };
16543
- }, true ? __vite__mapDeps([3,2]) : void 0);
17270
+ }, true ? __vite__mapDeps([0,1]) : void 0);
16544
17271
  ensureZstdDecoderRegistered();
16545
- const cryptoKey = key ? await __vitePreload(async () => {
16546
- const { importKey } = await import("./encryption-CLVP4klT.js");
16547
- return { importKey };
16548
- }, true ? __vite__mapDeps([0,1,2]) : void 0).then(({ importKey }) => importKey(key)) : void 0;
17272
+ const cryptoKey = key ? await deriveRunPayloadKeys2(key) : void 0;
16549
17273
  const revivers = getRevivers();
16550
17274
  async function hydrateField(value) {
16551
17275
  if (isEncryptedMarker$1(value)) {
@@ -17689,15 +18413,15 @@ const MS_IN_SECOND$1 = 1e3;
17689
18413
  const MS_IN_MINUTE = 60 * MS_IN_SECOND$1;
17690
18414
  const MS_IN_HOUR = 60 * MS_IN_MINUTE;
17691
18415
  const MS_IN_DAY = 24 * MS_IN_HOUR;
17692
- function formatDuration(ms, compact = false) {
17693
- if (ms === 0) {
18416
+ function formatDuration(ms2, compact = false) {
18417
+ if (ms2 === 0) {
17694
18418
  return "0s";
17695
18419
  }
17696
- if (ms < MS_IN_SECOND$1) {
17697
- const roundedMs2 = Math.round(ms);
18420
+ if (ms2 < MS_IN_SECOND$1) {
18421
+ const roundedMs2 = Math.round(ms2);
17698
18422
  return roundedMs2 < MS_IN_SECOND$1 ? `${roundedMs2}ms` : "1s";
17699
18423
  }
17700
- const roundedMs = Math.round(ms / MS_IN_SECOND$1) * MS_IN_SECOND$1;
18424
+ const roundedMs = Math.round(ms2 / MS_IN_SECOND$1) * MS_IN_SECOND$1;
17701
18425
  if (roundedMs < MS_IN_MINUTE) {
17702
18426
  return `${Math.floor(roundedMs / MS_IN_SECOND$1)}s`;
17703
18427
  }
@@ -17728,18 +18452,18 @@ function formatDuration(ms, compact = false) {
17728
18452
  parts.push(`${seconds}s`);
17729
18453
  return parts.join(" ");
17730
18454
  }
17731
- function formatDurationPrecise(ms, fractionDigits = 2) {
17732
- if (ms === 0) {
18455
+ function formatDurationPrecise(ms2, fractionDigits = 2) {
18456
+ if (ms2 === 0) {
17733
18457
  return "0s";
17734
18458
  }
17735
- if (ms < MS_IN_SECOND$1) {
17736
- const roundedMs = Math.round(ms);
18459
+ if (ms2 < MS_IN_SECOND$1) {
18460
+ const roundedMs = Math.round(ms2);
17737
18461
  if (roundedMs < MS_IN_SECOND$1) {
17738
18462
  return `${roundedMs}ms`;
17739
18463
  }
17740
18464
  }
17741
18465
  const granularityMs = MS_IN_SECOND$1 / 10 ** fractionDigits;
17742
- const normalizedMs = Math.round(ms / granularityMs) * granularityMs;
18466
+ const normalizedMs = Math.round(ms2 / granularityMs) * granularityMs;
17743
18467
  if (normalizedMs < MS_IN_MINUTE) {
17744
18468
  return `${Number((normalizedMs / MS_IN_SECOND$1).toFixed(fractionDigits))}s`;
17745
18469
  }
@@ -17816,6 +18540,27 @@ const cva = (base, config2) => (props) => {
17816
18540
  }, []);
17817
18541
  return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
17818
18542
  };
18543
+ function CopyButton({ copyText, ariaLabel, className }) {
18544
+ const [copied, setCopied] = reactExports.useState(false);
18545
+ const timeoutRef = reactExports.useRef(null);
18546
+ reactExports.useEffect(() => {
18547
+ return () => {
18548
+ if (timeoutRef.current) {
18549
+ clearTimeout(timeoutRef.current);
18550
+ }
18551
+ };
18552
+ }, []);
18553
+ return jsxRuntimeExports.jsx("button", { type: "button", "aria-label": ariaLabel, className: cn$4("cursor-pointer text-gray-800 hover:text-gray-1000 bg-transparent border-0 p-1 m-0", className), onClick: (e) => {
18554
+ e.stopPropagation();
18555
+ if (timeoutRef.current) {
18556
+ clearTimeout(timeoutRef.current);
18557
+ }
18558
+ void navigator.clipboard.writeText(copyText).then(() => {
18559
+ setCopied(true);
18560
+ timeoutRef.current = setTimeout(() => setCopied(false), 1e3);
18561
+ });
18562
+ }, children: jsxRuntimeExports.jsxs("div", { className: "relative w-3 h-3", children: [jsxRuntimeExports.jsx("div", { className: cn$4("absolute inset-0 flex items-center justify-center transition-all duration-150 ease-out", copied ? "scale-100 opacity-100" : "scale-0 opacity-0"), children: jsxRuntimeExports.jsx(Check, { className: "w-3 h-3" }) }), jsxRuntimeExports.jsx("div", { className: cn$4("absolute inset-0 flex items-center justify-center transition-all duration-150 ease-out", copied ? "scale-0 opacity-0" : "scale-100 opacity-100"), children: jsxRuntimeExports.jsx(Copy, { className: "w-3 h-3" }) })] }) });
18563
+ }
17819
18564
  const CollapsibleContext = reactExports.createContext(null);
17820
18565
  function useCollapsibleContext(part) {
17821
18566
  const context = reactExports.useContext(CollapsibleContext);
@@ -17825,7 +18570,7 @@ function useCollapsibleContext(part) {
17825
18570
  return context;
17826
18571
  }
17827
18572
  function CollapsibleRoot({ children: children2, variant = "section", disabled = false, defaultOpen = false, onOpenChange, className }) {
17828
- const [open, setOpen] = reactExports.useState(defaultOpen);
18573
+ const [open2, setOpen] = reactExports.useState(defaultOpen);
17829
18574
  const handleToggle = (event) => {
17830
18575
  if (event.target !== event.currentTarget)
17831
18576
  return;
@@ -17833,7 +18578,7 @@ function CollapsibleRoot({ children: children2, variant = "section", disabled =
17833
18578
  setOpen(next2);
17834
18579
  onOpenChange == null ? void 0 : onOpenChange(next2);
17835
18580
  };
17836
- 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 }) });
18581
+ 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 }) });
17837
18582
  if (variant === "card") {
17838
18583
  return details;
17839
18584
  }
@@ -18249,8 +18994,8 @@ function PrimitiveValue({ field, value, isLast }) {
18249
18994
  const { text: text2, cls } = describePrimitive(value);
18250
18995
  return jsxRuntimeExports.jsx(LeafRow, { field, isLast, children: jsxRuntimeExports.jsx("span", { className: cls, children: text2 }) });
18251
18996
  }
18252
- function EmptyContainer({ field, prefix, open, close, isLast }) {
18253
- 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 })] });
18997
+ function EmptyContainer({ field, prefix, open: open2, close, isLast }) {
18998
+ 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 })] });
18254
18999
  }
18255
19000
  function focusExpander(button, outerRef) {
18256
19001
  var _a3;
@@ -18279,13 +19024,13 @@ function moveExpanderFocus(outerRef, direction) {
18279
19024
  buttons[next2].tabIndex = 0;
18280
19025
  buttons[next2].focus();
18281
19026
  }
18282
- function ExpandableContainer({ field, entries, open, close, prefix, ctx, isLast }) {
19027
+ function ExpandableContainer({ field, entries, open: open2, close, prefix, ctx, isLast }) {
18283
19028
  const { level, shouldExpand, outerRef } = ctx;
18284
19029
  const [expanded2, setExpanded] = reactExports.useState(() => shouldExpand(level));
18285
19030
  const rowRef = reactExports.useRef(null);
18286
19031
  const contentsId = reactExports.useId();
18287
19032
  if (entries.length === 0) {
18288
- return jsxRuntimeExports.jsx(EmptyContainer, { field, prefix, open, close, isLast });
19033
+ return jsxRuntimeExports.jsx(EmptyContainer, { field, prefix, open: open2, close, isLast });
18289
19034
  }
18290
19035
  const toggle = () => {
18291
19036
  setExpanded((value) => !value);
@@ -18314,7 +19059,7 @@ function ExpandableContainer({ field, entries, open, close, prefix, ctx, isLast
18314
19059
  }
18315
19060
  };
18316
19061
  const lastIndex = entries.length - 1;
18317
- 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 })] });
19062
+ 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 })] });
18318
19063
  }
18319
19064
  function DataRender({ field, value, isLast, ctx }) {
18320
19065
  if (isBytesDisplay(value)) {
@@ -18498,6 +19243,29 @@ function isDeepEqual(a2, b2, seen2 = /* @__PURE__ */ new WeakMap()) {
18498
19243
  }
18499
19244
  return true;
18500
19245
  }
19246
+ const encryptedPlaceholderPreview = `{
19247
+ "input": "[encrypted]",
19248
+ "result": "[encrypted]"
19249
+ }`;
19250
+ function EncryptedDataBlock() {
19251
+ const ctx = reactExports.useContext(DecryptClickContext);
19252
+ return jsxRuntimeExports.jsxs("div", { className: "relative min-h-20 overflow-hidden rounded-md border border-gray-alpha-400 bg-background-100", children: [jsxRuntimeExports.jsx("pre", { "aria-hidden": "true", className: "pointer-events-none m-0 select-none p-3 font-mono text-label-12 text-gray-900 blur-[4px]", children: encryptedPlaceholderPreview }), jsxRuntimeExports.jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: ctx ? jsxRuntimeExports.jsxs(Button$1, { onClick: ctx.onDecrypt, disabled: ctx.isDecrypting, size: "xs", children: [ctx.isDecrypting ? jsxRuntimeExports.jsx(Spinner, { size: 10 }) : jsxRuntimeExports.jsx(Lock, { className: "h-3 w-3" }), jsxRuntimeExports.jsx("span", { children: "Decrypt" })] }) : jsxRuntimeExports.jsxs("span", { className: "inline-flex items-center gap-1 rounded border border-gray-alpha-400 bg-gray-100 px-1.5 py-0.5 text-button-12 font-medium text-gray-700", children: [jsxRuntimeExports.jsx(Lock, { className: "h-3 w-3" }), "Encrypted"] }) })] });
19253
+ }
19254
+ const serializeForClipboard = (value) => {
19255
+ if (typeof value === "string")
19256
+ return value;
19257
+ if (typeof value === "number" || typeof value === "boolean" || value === null) {
19258
+ return String(value);
19259
+ }
19260
+ try {
19261
+ return JSON.stringify(value, null, 2);
19262
+ } catch {
19263
+ return String(value);
19264
+ }
19265
+ };
19266
+ function CopyableDataBlock({ data }) {
19267
+ return jsxRuntimeExports.jsxs("div", { className: "relative overflow-x-auto rounded-md border border-gray-alpha-400 p-3", children: [jsxRuntimeExports.jsx(CopyButton, { copyText: serializeForClipboard(data), ariaLabel: "Copy data", className: "absolute right-2 top-2 z-10 flex h-6 w-6 items-center justify-center rounded-md border border-gray-alpha-400 !bg-background-100 p-0 text-gray-900 transition-transform transition-colors duration-100 hover:bg-gray-200 active:scale-95 active:bg-gray-300" }), jsxRuntimeExports.jsx(DataInspector, { data })] });
19268
+ }
18501
19269
  function setRef(ref, value) {
18502
19270
  if (typeof ref === "function") {
18503
19271
  return ref(value);
@@ -19241,11 +20009,11 @@ const TIME_UNITS = [
19241
20009
  function formatTimeDifference(diff) {
19242
20010
  let remaining = Math.abs(diff);
19243
20011
  const result = [];
19244
- for (const { unit, ms } of TIME_UNITS) {
19245
- const value = Math.floor(remaining / ms);
20012
+ for (const { unit, ms: ms2 } of TIME_UNITS) {
20013
+ const value = Math.floor(remaining / ms2);
19246
20014
  if (value > 0 || result.length > 0) {
19247
20015
  result.push(`${value} ${unit}${value !== 1 ? "s" : ""}`);
19248
- remaining %= ms;
20016
+ remaining %= ms2;
19249
20017
  }
19250
20018
  if (result.length === 3)
19251
20019
  break;
@@ -32551,12 +33319,12 @@ function emphasis$1(node2, _2, state, info) {
32551
33319
  })
32552
33320
  );
32553
33321
  const betweenHead = between.charCodeAt(0);
32554
- const open = encodeInfo(
33322
+ const open2 = encodeInfo(
32555
33323
  info.before.charCodeAt(info.before.length - 1),
32556
33324
  betweenHead,
32557
33325
  marker2
32558
33326
  );
32559
- if (open.inside) {
33327
+ if (open2.inside) {
32560
33328
  between = encodeCharacterReference(betweenHead) + between.slice(1);
32561
33329
  }
32562
33330
  const betweenTail = between.charCodeAt(between.length - 1);
@@ -32568,7 +33336,7 @@ function emphasis$1(node2, _2, state, info) {
32568
33336
  exit2();
32569
33337
  state.attentionEncodeSurroundingInfo = {
32570
33338
  after: close.outside,
32571
- before: open.outside
33339
+ before: open2.outside
32572
33340
  };
32573
33341
  return before + between + after;
32574
33342
  }
@@ -33101,12 +33869,12 @@ function strong$1(node2, _2, state, info) {
33101
33869
  })
33102
33870
  );
33103
33871
  const betweenHead = between.charCodeAt(0);
33104
- const open = encodeInfo(
33872
+ const open2 = encodeInfo(
33105
33873
  info.before.charCodeAt(info.before.length - 1),
33106
33874
  betweenHead,
33107
33875
  marker2
33108
33876
  );
33109
- if (open.inside) {
33877
+ if (open2.inside) {
33110
33878
  between = encodeCharacterReference(betweenHead) + between.slice(1);
33111
33879
  }
33112
33880
  const betweenTail = between.charCodeAt(between.length - 1);
@@ -33118,7 +33886,7 @@ function strong$1(node2, _2, state, info) {
33118
33886
  exit2();
33119
33887
  state.attentionEncodeSurroundingInfo = {
33120
33888
  after: close.outside,
33121
- before: open.outside
33889
+ before: open2.outside
33122
33890
  };
33123
33891
  return before + between + after;
33124
33892
  }
@@ -33915,7 +34683,7 @@ const attention = {
33915
34683
  };
33916
34684
  function resolveAllAttention(events, context) {
33917
34685
  let index2 = -1;
33918
- let open;
34686
+ let open2;
33919
34687
  let group;
33920
34688
  let text2;
33921
34689
  let openingSequence;
@@ -33925,16 +34693,16 @@ function resolveAllAttention(events, context) {
33925
34693
  let offset2;
33926
34694
  while (++index2 < events.length) {
33927
34695
  if (events[index2][0] === "enter" && events[index2][1].type === "attentionSequence" && events[index2][1]._close) {
33928
- open = index2;
33929
- while (open--) {
33930
- if (events[open][0] === "exit" && events[open][1].type === "attentionSequence" && events[open][1]._open && // If the markers are the same:
33931
- context.sliceSerialize(events[open][1]).charCodeAt(0) === context.sliceSerialize(events[index2][1]).charCodeAt(0)) {
33932
- 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)) {
34696
+ open2 = index2;
34697
+ while (open2--) {
34698
+ if (events[open2][0] === "exit" && events[open2][1].type === "attentionSequence" && events[open2][1]._open && // If the markers are the same:
34699
+ context.sliceSerialize(events[open2][1]).charCodeAt(0) === context.sliceSerialize(events[index2][1]).charCodeAt(0)) {
34700
+ 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)) {
33933
34701
  continue;
33934
34702
  }
33935
- 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;
34703
+ 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;
33936
34704
  const start = {
33937
- ...events[open][1].end
34705
+ ...events[open2][1].end
33938
34706
  };
33939
34707
  const end = {
33940
34708
  ...events[index2][1].start
@@ -33945,7 +34713,7 @@ function resolveAllAttention(events, context) {
33945
34713
  type: use > 1 ? "strongSequence" : "emphasisSequence",
33946
34714
  start,
33947
34715
  end: {
33948
- ...events[open][1].end
34716
+ ...events[open2][1].end
33949
34717
  }
33950
34718
  };
33951
34719
  closingSequence = {
@@ -33958,7 +34726,7 @@ function resolveAllAttention(events, context) {
33958
34726
  text2 = {
33959
34727
  type: use > 1 ? "strongText" : "emphasisText",
33960
34728
  start: {
33961
- ...events[open][1].end
34729
+ ...events[open2][1].end
33962
34730
  },
33963
34731
  end: {
33964
34732
  ...events[index2][1].start
@@ -33973,18 +34741,18 @@ function resolveAllAttention(events, context) {
33973
34741
  ...closingSequence.end
33974
34742
  }
33975
34743
  };
33976
- events[open][1].end = {
34744
+ events[open2][1].end = {
33977
34745
  ...openingSequence.start
33978
34746
  };
33979
34747
  events[index2][1].start = {
33980
34748
  ...closingSequence.end
33981
34749
  };
33982
34750
  nextEvents = [];
33983
- if (events[open][1].end.offset - events[open][1].start.offset) {
33984
- nextEvents = push(nextEvents, [["enter", events[open][1], context], ["exit", events[open][1], context]]);
34751
+ if (events[open2][1].end.offset - events[open2][1].start.offset) {
34752
+ nextEvents = push(nextEvents, [["enter", events[open2][1], context], ["exit", events[open2][1], context]]);
33985
34753
  }
33986
34754
  nextEvents = push(nextEvents, [["enter", group, context], ["enter", openingSequence, context], ["exit", openingSequence, context], ["enter", text2, context]]);
33987
- nextEvents = push(nextEvents, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + 1, index2), context));
34755
+ nextEvents = push(nextEvents, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open2 + 1, index2), context));
33988
34756
  nextEvents = push(nextEvents, [["exit", text2, context], ["enter", closingSequence, context], ["exit", closingSequence, context], ["exit", group, context]]);
33989
34757
  if (events[index2][1].end.offset - events[index2][1].start.offset) {
33990
34758
  offset2 = 2;
@@ -33992,8 +34760,8 @@ function resolveAllAttention(events, context) {
33992
34760
  } else {
33993
34761
  offset2 = 0;
33994
34762
  }
33995
- splice(events, open - 1, index2 - open + 3, nextEvents);
33996
- index2 = open + nextEvents.length - offset2 - 2;
34763
+ splice(events, open2 - 1, index2 - open2 + 3, nextEvents);
34764
+ index2 = open2 + nextEvents.length - offset2 - 2;
33997
34765
  break;
33998
34766
  }
33999
34767
  }
@@ -34025,10 +34793,10 @@ function tokenizeAttention(effects, ok2) {
34025
34793
  }
34026
34794
  const token = effects.exit("attentionSequence");
34027
34795
  const after = classifyCharacter(code2);
34028
- const open = !after || after === 2 && before || attentionMarkers2.includes(code2);
34796
+ const open2 = !after || after === 2 && before || attentionMarkers2.includes(code2);
34029
34797
  const close = !before || before === 2 && after || attentionMarkers2.includes(previous2);
34030
- token._open = Boolean(marker2 === 42 ? open : open && (before || !close));
34031
- token._close = Boolean(marker2 === 42 ? close : close && (after || !open));
34798
+ token._open = Boolean(marker2 === 42 ? open2 : open2 && (before || !close));
34799
+ token._close = Boolean(marker2 === 42 ? close : close && (after || !open2));
34032
34800
  return ok2(code2);
34033
34801
  }
34034
34802
  }
@@ -34050,9 +34818,9 @@ function tokenizeAutolink(effects, ok2, nok) {
34050
34818
  effects.consume(code2);
34051
34819
  effects.exit("autolinkMarker");
34052
34820
  effects.enter("autolinkProtocol");
34053
- return open;
34821
+ return open2;
34054
34822
  }
34055
- function open(code2) {
34823
+ function open2(code2) {
34056
34824
  if (asciiAlpha(code2)) {
34057
34825
  effects.consume(code2);
34058
34826
  return schemeOrEmailAtext;
@@ -34264,9 +35032,9 @@ function tokenizeCharacterReference(effects, ok2, nok) {
34264
35032
  effects.enter("characterReferenceMarker");
34265
35033
  effects.consume(code2);
34266
35034
  effects.exit("characterReferenceMarker");
34267
- return open;
35035
+ return open2;
34268
35036
  }
34269
- function open(code2) {
35037
+ function open2(code2) {
34270
35038
  if (code2 === 35) {
34271
35039
  effects.enter("characterReferenceMarkerNumeric");
34272
35040
  effects.consume(code2);
@@ -35604,9 +36372,9 @@ function tokenizeHtmlFlow(effects, ok2, nok) {
35604
36372
  effects.enter("htmlFlow");
35605
36373
  effects.enter("htmlFlowData");
35606
36374
  effects.consume(code2);
35607
- return open;
36375
+ return open2;
35608
36376
  }
35609
- function open(code2) {
36377
+ function open2(code2) {
35610
36378
  if (code2 === 33) {
35611
36379
  effects.consume(code2);
35612
36380
  return declarationOpen;
@@ -35952,9 +36720,9 @@ function tokenizeHtmlText(effects, ok2, nok) {
35952
36720
  effects.enter("htmlText");
35953
36721
  effects.enter("htmlTextData");
35954
36722
  effects.consume(code2);
35955
- return open;
36723
+ return open2;
35956
36724
  }
35957
- function open(code2) {
36725
+ function open2(code2) {
35958
36726
  if (code2 === 33) {
35959
36727
  effects.consume(code2);
35960
36728
  return declarationOpen;
@@ -36278,12 +37046,12 @@ function resolveToLabelEnd(events, context) {
36278
37046
  let index2 = events.length;
36279
37047
  let offset2 = 0;
36280
37048
  let token;
36281
- let open;
37049
+ let open2;
36282
37050
  let close;
36283
37051
  let media;
36284
37052
  while (index2--) {
36285
37053
  token = events[index2][1];
36286
- if (open) {
37054
+ if (open2) {
36287
37055
  if (token.type === "link" || token.type === "labelLink" && token._inactive) {
36288
37056
  break;
36289
37057
  }
@@ -36292,7 +37060,7 @@ function resolveToLabelEnd(events, context) {
36292
37060
  }
36293
37061
  } else if (close) {
36294
37062
  if (events[index2][0] === "enter" && (token.type === "labelImage" || token.type === "labelLink") && !token._balanced) {
36295
- open = index2;
37063
+ open2 = index2;
36296
37064
  if (token.type !== "labelLink") {
36297
37065
  offset2 = 2;
36298
37066
  break;
@@ -36303,9 +37071,9 @@ function resolveToLabelEnd(events, context) {
36303
37071
  }
36304
37072
  }
36305
37073
  const group = {
36306
- type: events[open][1].type === "labelLink" ? "link" : "image",
37074
+ type: events[open2][1].type === "labelLink" ? "link" : "image",
36307
37075
  start: {
36308
- ...events[open][1].start
37076
+ ...events[open2][1].start
36309
37077
  },
36310
37078
  end: {
36311
37079
  ...events[events.length - 1][1].end
@@ -36314,7 +37082,7 @@ function resolveToLabelEnd(events, context) {
36314
37082
  const label = {
36315
37083
  type: "label",
36316
37084
  start: {
36317
- ...events[open][1].start
37085
+ ...events[open2][1].start
36318
37086
  },
36319
37087
  end: {
36320
37088
  ...events[close][1].end
@@ -36323,20 +37091,20 @@ function resolveToLabelEnd(events, context) {
36323
37091
  const text2 = {
36324
37092
  type: "labelText",
36325
37093
  start: {
36326
- ...events[open + offset2 + 2][1].end
37094
+ ...events[open2 + offset2 + 2][1].end
36327
37095
  },
36328
37096
  end: {
36329
37097
  ...events[close - 2][1].start
36330
37098
  }
36331
37099
  };
36332
37100
  media = [["enter", group, context], ["enter", label, context]];
36333
- media = push(media, events.slice(open + 1, open + offset2 + 3));
37101
+ media = push(media, events.slice(open2 + 1, open2 + offset2 + 3));
36334
37102
  media = push(media, [["enter", text2, context]]);
36335
- media = push(media, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + offset2 + 4, close - 3), context));
37103
+ media = push(media, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open2 + offset2 + 4, close - 3), context));
36336
37104
  media = push(media, [["exit", text2, context], events[close - 2], events[close - 1], ["exit", label, context]]);
36337
37105
  media = push(media, events.slice(close + 1));
36338
37106
  media = push(media, [["exit", group, context]]);
36339
- splice(events, open, events.length, media);
37107
+ splice(events, open2, events.length, media);
36340
37108
  return events;
36341
37109
  }
36342
37110
  function tokenizeLabelEnd(effects, ok2, nok) {
@@ -36479,9 +37247,9 @@ function tokenizeLabelStartImage(effects, ok2, nok) {
36479
37247
  effects.enter("labelImageMarker");
36480
37248
  effects.consume(code2);
36481
37249
  effects.exit("labelImageMarker");
36482
- return open;
37250
+ return open2;
36483
37251
  }
36484
- function open(code2) {
37252
+ function open2(code2) {
36485
37253
  if (code2 === 91) {
36486
37254
  effects.enter("labelMarker");
36487
37255
  effects.consume(code2);
@@ -37081,30 +37849,30 @@ function gfmStrikethrough(options) {
37081
37849
  let index2 = -1;
37082
37850
  while (++index2 < events.length) {
37083
37851
  if (events[index2][0] === "enter" && events[index2][1].type === "strikethroughSequenceTemporary" && events[index2][1]._close) {
37084
- let open = index2;
37085
- while (open--) {
37086
- if (events[open][0] === "exit" && events[open][1].type === "strikethroughSequenceTemporary" && events[open][1]._open && // If the sizes are the same:
37087
- events[index2][1].end.offset - events[index2][1].start.offset === events[open][1].end.offset - events[open][1].start.offset) {
37852
+ let open2 = index2;
37853
+ while (open2--) {
37854
+ if (events[open2][0] === "exit" && events[open2][1].type === "strikethroughSequenceTemporary" && events[open2][1]._open && // If the sizes are the same:
37855
+ events[index2][1].end.offset - events[index2][1].start.offset === events[open2][1].end.offset - events[open2][1].start.offset) {
37088
37856
  events[index2][1].type = "strikethroughSequence";
37089
- events[open][1].type = "strikethroughSequence";
37857
+ events[open2][1].type = "strikethroughSequence";
37090
37858
  const strikethrough2 = {
37091
37859
  type: "strikethrough",
37092
- start: Object.assign({}, events[open][1].start),
37860
+ start: Object.assign({}, events[open2][1].start),
37093
37861
  end: Object.assign({}, events[index2][1].end)
37094
37862
  };
37095
37863
  const text2 = {
37096
37864
  type: "strikethroughText",
37097
- start: Object.assign({}, events[open][1].end),
37865
+ start: Object.assign({}, events[open2][1].end),
37098
37866
  end: Object.assign({}, events[index2][1].start)
37099
37867
  };
37100
- const nextEvents = [["enter", strikethrough2, context], ["enter", events[open][1], context], ["exit", events[open][1], context], ["enter", text2, context]];
37868
+ const nextEvents = [["enter", strikethrough2, context], ["enter", events[open2][1], context], ["exit", events[open2][1], context], ["enter", text2, context]];
37101
37869
  const insideSpan2 = context.parser.constructs.insideSpan.null;
37102
37870
  if (insideSpan2) {
37103
- splice(nextEvents, nextEvents.length, 0, resolveAll(insideSpan2, events.slice(open + 1, index2), context));
37871
+ splice(nextEvents, nextEvents.length, 0, resolveAll(insideSpan2, events.slice(open2 + 1, index2), context));
37104
37872
  }
37105
37873
  splice(nextEvents, nextEvents.length, 0, [["exit", text2, context], ["enter", events[index2][1], context], ["exit", events[index2][1], context], ["exit", strikethrough2, context]]);
37106
- splice(events, open - 1, index2 - open + 3, nextEvents);
37107
- index2 = open + nextEvents.length - 2;
37874
+ splice(events, open2 - 1, index2 - open2 + 3, nextEvents);
37875
+ index2 = open2 + nextEvents.length - 2;
37108
37876
  break;
37109
37877
  }
37110
37878
  }
@@ -37646,8 +38414,8 @@ function gfmTaskListItem() {
37646
38414
  }
37647
38415
  function tokenizeTasklistCheck(effects, ok2, nok) {
37648
38416
  const self2 = this;
37649
- return open;
37650
- function open(code2) {
38417
+ return open2;
38418
+ function open2(code2) {
37651
38419
  if (
37652
38420
  // Exit if there’s stuff before.
37653
38421
  self2.previous !== null || // Exit if not in the first content that is the first child of a list
@@ -40080,8 +40848,8 @@ function compiler(options) {
40080
40848
  return length;
40081
40849
  }
40082
40850
  function opener(create2, and) {
40083
- return open;
40084
- function open(token) {
40851
+ return open2;
40852
+ function open2(token) {
40085
40853
  enter.call(this, create2(token), token);
40086
40854
  if (and) and.call(this, token);
40087
40855
  }
@@ -40113,18 +40881,18 @@ function compiler(options) {
40113
40881
  }
40114
40882
  function exit2(token, onExitError) {
40115
40883
  const node2 = this.stack.pop();
40116
- const open = this.tokenStack.pop();
40117
- if (!open) {
40884
+ const open2 = this.tokenStack.pop();
40885
+ if (!open2) {
40118
40886
  throw new Error("Cannot close `" + token.type + "` (" + stringifyPosition({
40119
40887
  start: token.start,
40120
40888
  end: token.end
40121
40889
  }) + "): it’s not open");
40122
- } else if (open[0].type !== token.type) {
40890
+ } else if (open2[0].type !== token.type) {
40123
40891
  if (onExitError) {
40124
- onExitError.call(this, token, open[0]);
40892
+ onExitError.call(this, token, open2[0]);
40125
40893
  } else {
40126
- const handler = open[1] || defaultOnError;
40127
- handler.call(this, token, open[0]);
40894
+ const handler = open2[1] || defaultOnError;
40895
+ handler.call(this, token, open2[0]);
40128
40896
  }
40129
40897
  }
40130
40898
  node2.position.end = point(token.end);
@@ -44100,7 +44868,7 @@ var tn = f("block", "before:content-[counter(line)]", "before:inline-block", "be
44100
44868
  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 });
44101
44869
  var Se = reactExports.createContext({ code: "" }), de = () => reactExports.useContext(Se);
44102
44870
  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 }) });
44103
- var cn$1 = /\n+$/, dn = reactExports.lazy(() => __vitePreload(() => import("./highlighted-body-B3W2YXNL-C5gyMelW.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 }) => {
44871
+ var cn$1 = /\n+$/, dn = reactExports.lazy(() => __vitePreload(() => import("./highlighted-body-B3W2YXNL-DwhUiBi7.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 }) => {
44104
44872
  let i = reactExports.useMemo(() => e.replace(cn$1, ""), [e]), c = reactExports.useMemo(() => ({ bg: "transparent", fg: "inherit", tokens: i.split(`
44105
44873
  `).map((a2) => [{ content: a2, color: "inherit", bgColor: "transparent", htmlStyle: {}, offset: 0 }]) }), [i]);
44106
44874
  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 }) })] }) });
@@ -46109,15 +46877,18 @@ reactExports.memo(function MiniMap({ timelineRef, rows, scale }) {
46109
46877
  height: MAP_HEIGHT - 4
46110
46878
  } })] });
46111
46879
  });
46112
- const ChunkRow = ReactExports.memo(function ChunkRow2({ chunk, index: index2 }) {
46113
- return jsxRuntimeExports.jsx("div", { className: "text-[11px] rounded-md border p-3", style: {
46114
- borderColor: "var(--ds-gray-300)",
46115
- backgroundColor: "var(--ds-gray-100)"
46116
- }, children: jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-2", children: [jsxRuntimeExports.jsxs("span", { className: "select-none pt-px", style: { color: "var(--ds-gray-500)" }, children: ["[", index2, "]"] }), jsxRuntimeExports.jsx("div", { className: "min-w-0 flex-1", children: typeof chunk.value === "string" ? jsxRuntimeExports.jsx("span", { className: "whitespace-pre-wrap break-words", style: { color: "var(--ds-gray-1000)" }, children: chunk.value }) : jsxRuntimeExports.jsx(DataInspector, { data: chunk.value, expandLevel: 1 }) })] }) });
46117
- });
46118
- function StreamSkeleton() {
46119
- return jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-3 animate-in fade-in", children: [jsxRuntimeExports.jsx(Skeleton$1, { style: { width: 120, height: 16, borderRadius: 4 } }), [1, 2, 3, 4].map((i) => jsxRuntimeExports.jsx(Skeleton$1, { style: { height: 56, borderRadius: 6 } }, i))] });
46880
+ const STREAM_SKELETON_ROWS = [
46881
+ { id: "stream-skeleton-row-1", width: "72%" },
46882
+ { id: "stream-skeleton-row-2", width: "58%" },
46883
+ { id: "stream-skeleton-row-3", width: "80%" },
46884
+ { id: "stream-skeleton-row-4", width: "64%" }
46885
+ ];
46886
+ function StreamViewerSkeleton() {
46887
+ return jsxRuntimeExports.jsxs("output", { "aria-busy": "true", "aria-label": "Loading stream", className: "flex h-full min-h-0 w-full flex-col overflow-hidden bg-background-100", children: [jsxRuntimeExports.jsx("span", { className: "sr-only", children: "Loading stream…" }), jsxRuntimeExports.jsx("div", { className: "flex h-10 min-h-10 items-center border-b border-gray-alpha-400 px-3", children: jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3 w-10" }) }), jsxRuntimeExports.jsx("div", { className: "flex flex-col", children: STREAM_SKELETON_ROWS.map((row) => jsxRuntimeExports.jsxs("div", { className: "flex h-10 items-center gap-2 border-b border-gray-alpha-400 px-3", children: [jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3", style: { width: row.width } }), jsxRuntimeExports.jsx(Skeleton$1, { className: "h-4 w-4 shrink-0 rounded-sm" })] }, row.id)) })] });
46120
46888
  }
46889
+ const ChunkRow = ReactExports.memo(function ChunkRow2({ chunk }) {
46890
+ return jsxRuntimeExports.jsxs("div", { className: "flex w-full items-start gap-1 border-b border-gray-alpha-400 px-3 py-2", children: [jsxRuntimeExports.jsx("div", { className: "min-w-0 flex-1", children: typeof chunk.value === "string" ? jsxRuntimeExports.jsx("span", { className: "whitespace-pre-wrap break-words text-label-12 font-mono text-gray-1000", children: chunk.value }) : jsxRuntimeExports.jsx(DataInspector, { data: chunk.value, expandLevel: 1 }) }), jsxRuntimeExports.jsx(CopyButton, { copyText: serializeForClipboard(chunk.value), ariaLabel: "Copy chunk", className: "shrink-0 -mr-1 [&>div]:h-4 [&>div]:w-4 [&_svg]:h-4 [&_svg]:w-4" })] });
46891
+ });
46121
46892
  function StreamViewer({ streamId: _streamId, chunks, isLive, error, isLoading, onScrollEnd }) {
46122
46893
  const virtuosoRef = reactExports.useRef(null);
46123
46894
  const prevChunkCountRef = reactExports.useRef(0);
@@ -46132,17 +46903,9 @@ function StreamViewer({ streamId: _streamId, chunks, isLive, error, isLoading, o
46132
46903
  prevChunkCountRef.current = chunks.length;
46133
46904
  }, [chunks.length]);
46134
46905
  if (isLoading && chunks.length === 0) {
46135
- return jsxRuntimeExports.jsx("div", { className: "flex flex-col h-full", children: jsxRuntimeExports.jsx(StreamSkeleton, {}) });
46136
- }
46137
- return jsxRuntimeExports.jsxs("div", { className: "flex flex-col h-full", children: [isLive && jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1.5 mb-2 px-1", children: [jsxRuntimeExports.jsx("span", { className: "inline-block w-2 h-2 rounded-full", style: { backgroundColor: "var(--ds-green-600)" } }), jsxRuntimeExports.jsx("span", { className: "text-xs", style: { color: "var(--ds-green-700)" }, children: "Live" })] }), chunks.length > 0 && jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 mb-2 px-1", children: [jsxRuntimeExports.jsx("span", { className: "text-[13px] font-medium", style: { color: "var(--ds-gray-900)" }, children: "Stream Chunks" }), jsxRuntimeExports.jsxs("span", { className: "text-xs tabular-nums", style: { color: "var(--ds-gray-600)" }, children: ["(", chunks.length, ")"] })] }), jsxRuntimeExports.jsx("div", { className: "flex-1 min-h-0", children: error ? jsxRuntimeExports.jsxs("div", { className: "text-[11px] rounded-md border p-3", style: {
46138
- borderColor: "var(--ds-red-300)",
46139
- backgroundColor: "var(--ds-red-100)",
46140
- color: "var(--ds-red-700)"
46141
- }, children: [jsxRuntimeExports.jsx("div", { children: "Error reading stream:" }), jsxRuntimeExports.jsx("div", { children: error })] }) : chunks.length === 0 ? jsxRuntimeExports.jsx("div", { className: "text-[11px] rounded-md border p-3", style: {
46142
- borderColor: "var(--ds-gray-300)",
46143
- backgroundColor: "var(--ds-gray-100)",
46144
- color: "var(--ds-gray-600)"
46145
- }, children: isLive ? "Waiting for stream data..." : "Stream is empty" }) : jsxRuntimeExports.jsx(Yr, { ref: virtuosoRef, totalCount: chunks.length, overscan: 10, endReached: () => onScrollEnd == null ? void 0 : onScrollEnd(), itemContent: (index2) => jsxRuntimeExports.jsx("div", { style: { paddingBottom: 8 }, children: jsxRuntimeExports.jsx(ChunkRow, { chunk: chunks[index2], index: index2 }) }), style: { flex: 1, minHeight: 0 } }) })] });
46906
+ return jsxRuntimeExports.jsx(StreamViewerSkeleton, {});
46907
+ }
46908
+ return jsxRuntimeExports.jsxs("div", { className: "flex h-full w-full flex-col overflow-hidden bg-background-100", children: [jsxRuntimeExports.jsx("div", { className: "flex h-10 min-h-10 items-center gap-1.5 border-b border-gray-alpha-400 px-3", children: isLive && jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("span", { className: "inline-block h-2 w-2 rounded-full bg-green-600" }), jsxRuntimeExports.jsx("span", { className: "text-label-12 text-green-700", children: "Live" })] }) }), jsxRuntimeExports.jsx("div", { className: "flex-1 min-h-0", children: error ? jsxRuntimeExports.jsxs("div", { className: "border-b border-red-400 bg-red-100 px-3 py-2 text-label-12 text-red-900", children: [jsxRuntimeExports.jsx("div", { children: "Error reading stream:" }), jsxRuntimeExports.jsx("div", { children: error })] }) : chunks.length === 0 ? jsxRuntimeExports.jsx("div", { className: "flex h-10 items-center border-b border-gray-alpha-400 bg-background-200 px-3 text-label-12 text-gray-900", children: isLive ? "Waiting for stream data..." : "Stream is empty" }) : jsxRuntimeExports.jsx(Yr, { ref: virtuosoRef, totalCount: chunks.length, overscan: 10, endReached: () => onScrollEnd == null ? void 0 : onScrollEnd(), itemContent: (index2) => jsxRuntimeExports.jsx("div", { className: "w-full", children: jsxRuntimeExports.jsx(ChunkRow, { chunk: chunks[index2] }) }), style: { flex: 1, minHeight: 0 } }) })] });
46146
46909
  }
46147
46910
  const iconButtonVariants = cva([
46148
46911
  "m-0 inline-flex shrink-0 appearance-none items-center justify-center border-0 bg-transparent p-0 align-baseline font-inherit no-underline [background:none] [-webkit-appearance:none] [-webkit-tap-highlight-color:transparent]",
@@ -46441,8 +47204,8 @@ function computeTimeMarkers(viewDuration, offset2) {
46441
47204
  }
46442
47205
  return markers2;
46443
47206
  }
46444
- function toViewportFrac(ms, viewStart, range) {
46445
- return Math.min(Math.max((ms - viewStart) / range, 0), 1);
47207
+ function toViewportFrac(ms2, viewStart, range) {
47208
+ return Math.min(Math.max((ms2 - viewStart) / range, 0), 1);
46446
47209
  }
46447
47210
  function computeSpanGaps(spans, viewStart, viewEnd) {
46448
47211
  const range = viewEnd - viewStart;
@@ -49666,9 +50429,13 @@ defaultEncoder.encodeAsAsyncIterable;
49666
50429
  const REUSE_BUFFER_MODE = 512;
49667
50430
  const RESET_BUFFER_MODE = 1024;
49668
50431
  const THROW_ON_ITERABLE = 2048;
50432
+ function apiBase() {
50433
+ if (typeof window === "undefined") return "";
50434
+ return window.__WORKFLOW_BASENAME__ ?? "";
50435
+ }
49669
50436
  async function rpc(method, params) {
49670
50437
  var _a3;
49671
- const res = await fetch("/api/rpc", {
50438
+ const res = await fetch(`${apiBase()}/api/rpc`, {
49672
50439
  method: "POST",
49673
50440
  headers: {
49674
50441
  "Content-Type": "application/cbor",
@@ -49747,8 +50514,8 @@ async function fetchStreams(worldEnv, runId) {
49747
50514
  async function fetchWorkflowsManifest(worldEnv) {
49748
50515
  return rpc("fetchWorkflowsManifest", { worldEnv });
49749
50516
  }
49750
- async function runHealthCheck(worldEnv, endpoint, options) {
49751
- return rpc("runHealthCheck", { worldEnv, endpoint, options });
50517
+ async function runHealthCheck(worldEnv, options) {
50518
+ return rpc("runHealthCheck", { worldEnv, options });
49752
50519
  }
49753
50520
  async function getEncryptionKeyForRun(worldEnv, runId) {
49754
50521
  return rpc("getEncryptionKeyForRun", { worldEnv, runId });
@@ -49758,123 +50525,131 @@ const mermaid3ZIDBTTL = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.def
49758
50525
  Mermaid: Nt
49759
50526
  }, Symbol.toStringTag, { value: "Module" }));
49760
50527
  export {
49761
- Spinner as $,
50528
+ CollapsibleTrigger as $,
49762
50529
  Anchor as A,
49763
50530
  Button as B,
49764
- ChevronRight as C,
50531
+ Check as C,
49765
50532
  DEFAULT_PAGE_SIZE as D,
49766
- useControllableState as E,
49767
- Root2 as F,
49768
- Arrow as G,
49769
- ChevronDown as H,
49770
- useComposedRefs as I,
49771
- fetchRun as J,
50533
+ createSlot as E,
50534
+ Content as F,
50535
+ useControllableState as G,
50536
+ Root2 as H,
50537
+ Arrow as I,
50538
+ ChevronDown as J,
49772
50539
  Ks as K,
49773
- LoaderCircle as L,
49774
- cva as M,
49775
- Presence as N,
49776
- createContext2 as O,
50540
+ useComposedRefs as L,
50541
+ fetchRun as M,
50542
+ cva as N,
50543
+ Presence as O,
49777
50544
  Primitive as P,
49778
50545
  Qe as Q,
49779
50546
  R,
49780
50547
  ServerConfigProvider as S,
49781
50548
  Tooltip as T,
49782
- fetchWorkflowsManifest as U,
50549
+ createContext2 as U,
49783
50550
  VISUALLY_HIDDEN_STYLES as V,
49784
- cn$4 as W,
49785
- DataInspector as X,
49786
- DecryptClickContext as Y,
49787
- Button$1 as Z,
50551
+ fetchWorkflowsManifest as W,
50552
+ cn$4 as X,
50553
+ CopyableDataBlock as Y,
50554
+ CollapsibleRoot as Z,
49788
50555
  __vitePreload as _,
49789
50556
  TooltipTrigger as a,
49790
- fetchEvent as a$,
49791
- Lock as a0,
49792
- CollapsibleRoot as a1,
49793
- CollapsibleTrigger as a2,
49794
- CollapsibleContent as a3,
49795
- RESERVED_ATTRIBUTE_KEY_PREFIX as a4,
49796
- ContextCardProvider as a5,
49797
- Skeleton$1 as a6,
50557
+ Slot as a$,
50558
+ CollapsibleContent as a0,
50559
+ CopyButton as a1,
50560
+ RESERVED_ATTRIBUTE_KEY_PREFIX as a2,
50561
+ Spinner as a3,
50562
+ ContextCardProvider as a4,
50563
+ Skeleton$1 as a5,
50564
+ DecryptClickContext as a6,
49798
50565
  Yr as a7,
49799
50566
  isEncryptedMarker$1 as a8,
49800
50567
  TimestampTooltip as a9,
49801
- getSpanDurationMs as aA,
49802
- isSpanErrored as aB,
49803
- formatDurationPrecise as aC,
49804
- TooltipProvider as aD,
49805
- ActiveSpanProvider as aE,
49806
- useReducedMotion as aF,
49807
- searchSpans as aG,
49808
- computeRootBounds as aH,
49809
- computeTimeMarkers as aI,
49810
- clampViewportToRoot as aJ,
49811
- getHighResInMs as aK,
49812
- scrollRowIntoView as aL,
49813
- TIMELINE_PADDING_PX as aM,
49814
- Minimap as aN,
49815
- Timeline as aO,
49816
- TimelineHeader as aP,
49817
- wheelZoomScaleFactor as aQ,
49818
- wheelDeltaToPixels as aR,
49819
- SidebarDataProvider as aS,
49820
- fetchHook as aT,
49821
- hydrateResourceIOAsync as aU,
49822
- fetchStep as aV,
49823
- hydrateResourceIO as aW,
49824
- fetchStreams as aX,
49825
- Slot as aY,
49826
- Slottable as aZ,
49827
- buttonVariants as a_,
50568
+ isSpanDimmedBySearch as aA,
50569
+ ROW_HEIGHT_PX as aB,
50570
+ getSpanDurationMs as aC,
50571
+ isSpanErrored as aD,
50572
+ formatDurationPrecise as aE,
50573
+ TooltipProvider as aF,
50574
+ ActiveSpanProvider as aG,
50575
+ useReducedMotion as aH,
50576
+ searchSpans as aI,
50577
+ computeRootBounds as aJ,
50578
+ computeTimeMarkers as aK,
50579
+ clampViewportToRoot as aL,
50580
+ getHighResInMs as aM,
50581
+ scrollRowIntoView as aN,
50582
+ TIMELINE_PADDING_PX as aO,
50583
+ Minimap as aP,
50584
+ Timeline as aQ,
50585
+ TimelineHeader as aR,
50586
+ wheelZoomScaleFactor as aS,
50587
+ wheelDeltaToPixels as aT,
50588
+ SidebarDataProvider as aU,
50589
+ fetchHook as aV,
50590
+ hydrateResourceIOAsync as aW,
50591
+ fetchStep as aX,
50592
+ hydrateResourceIO as aY,
50593
+ fetchStreams as aZ,
50594
+ apiBase as a_,
49828
50595
  formatDuration as aa,
49829
- isHookLifecycleEventType as ab,
49830
- isTerminalStepEventType as ac,
49831
- isWaitEventType as ad,
49832
- isStepEventType as ae,
49833
- _r as af,
49834
- RunClickContext as ag,
49835
- StreamClickContext as ah,
49836
- Collapsible as ai,
49837
- isExpiredMarker as aj,
49838
- isDoStreamStep as ak,
49839
- extractConversation as al,
49840
- getEventDataRefFields as am,
49841
- hasEncryptedFields as an,
49842
- useSidebarDataOptional as ao,
49843
- isTerminalWorkflowRunStatus as ap,
49844
- clsx as aq,
49845
- useActiveSpan as ar,
49846
- useSidebarData as as,
49847
- Tooltip$1 as at,
49848
- TooltipTrigger$1 as au,
49849
- IconButton as av,
49850
- TooltipContent$1 as aw,
49851
- useRowWindow as ax,
49852
- isSpanDimmedBySearch as ay,
49853
- ROW_HEIGHT_PX as az,
50596
+ DataInspector as ab,
50597
+ isHookLifecycleEventType as ac,
50598
+ isTerminalStepEventType as ad,
50599
+ isWaitEventType as ae,
50600
+ isStepEventType as af,
50601
+ _r as ag,
50602
+ RunClickContext as ah,
50603
+ StreamClickContext as ai,
50604
+ Collapsible as aj,
50605
+ isExpiredMarker as ak,
50606
+ isDoStreamStep as al,
50607
+ extractConversation as am,
50608
+ EncryptedDataBlock as an,
50609
+ getEventDataRefFields as ao,
50610
+ hasEncryptedFields as ap,
50611
+ useSidebarDataOptional as aq,
50612
+ isTerminalWorkflowRunStatus as ar,
50613
+ clsx as as,
50614
+ useActiveSpan as at,
50615
+ useSidebarData as au,
50616
+ Tooltip$1 as av,
50617
+ TooltipTrigger$1 as aw,
50618
+ IconButton as ax,
50619
+ TooltipContent$1 as ay,
50620
+ useRowWindow as az,
49854
50621
  TooltipContent as b,
49855
- fetchEventsByCorrelationId as b0,
49856
- isEncryptedData as b1,
49857
- hydrateData as b2,
49858
- getWebRevivers as b3,
49859
- LIVE_UPDATE_INTERVAL_MS as b4,
49860
- getEncryptionKeyForRun as b5,
49861
- StreamViewer as b6,
49862
- composeRefs as b7,
49863
- useFloating as b8,
49864
- offset as b9,
49865
- shift as ba,
49866
- limitShift as bb,
49867
- flip as bc,
49868
- size as bd,
49869
- arrow as be,
49870
- hide as bf,
49871
- autoUpdate as bg,
49872
- cancelRun as bh,
49873
- reenqueueRun as bi,
49874
- wakeUpRun as bj,
49875
- resumeHook as bk,
49876
- fetchHookToken as bl,
49877
- recreateRun as bm,
50622
+ Slottable as b0,
50623
+ buttonVariants as b1,
50624
+ fetchEvent as b2,
50625
+ fetchEventsByCorrelationId as b3,
50626
+ isEncryptedData as b4,
50627
+ hydrateData as b5,
50628
+ decrypt as b6,
50629
+ deriveRunPayloadKeys as b7,
50630
+ getWebRevivers as b8,
50631
+ LIVE_UPDATE_INTERVAL_MS as b9,
50632
+ getEncryptionKeyForRun as ba,
50633
+ StreamViewerSkeleton as bb,
50634
+ Lock as bc,
50635
+ StreamViewer as bd,
50636
+ composeRefs as be,
50637
+ useFloating as bf,
50638
+ offset as bg,
50639
+ shift as bh,
50640
+ limitShift as bi,
50641
+ flip as bj,
50642
+ size as bk,
50643
+ arrow as bl,
50644
+ hide as bm,
50645
+ autoUpdate as bn,
50646
+ VERCEL_403_ERROR_MESSAGE as bo,
50647
+ cancelRun as bp,
50648
+ reenqueueRun as bq,
50649
+ wakeUpRun as br,
50650
+ resumeHook as bs,
50651
+ fetchHookToken as bt,
50652
+ recreateRun as bu,
49878
50653
  createLucideIcon as c,
49879
50654
  runHealthCheck as d,
49880
50655
  cn as e,
@@ -49884,19 +50659,19 @@ export {
49884
50659
  fetchRuns as i,
49885
50660
  fetchHooks as j,
49886
50661
  getPaginationDisplay as k,
49887
- fetchEvents as l,
49888
- useCallbackRef as m,
49889
- useComposedRefs$1 as n,
49890
- composeEventHandlers as o,
49891
- useLayoutEffect2 as p,
49892
- Portal$1 as q,
50662
+ Copy as l,
50663
+ ChevronRight as m,
50664
+ fetchEvents as n,
50665
+ useCallbackRef as o,
50666
+ useComposedRefs$1 as p,
50667
+ composeEventHandlers as q,
49893
50668
  registerZstdDecoder as r,
49894
- useId as s,
50669
+ useLayoutEffect2 as s,
49895
50670
  toast as t,
49896
50671
  useServerConfig as u,
49897
- createPopperScope as v,
49898
- DismissableLayer as w,
49899
- createContextScope as x,
49900
- createSlot as y,
49901
- Content as z
50672
+ Portal$1 as v,
50673
+ useId as w,
50674
+ createPopperScope as x,
50675
+ DismissableLayer as y,
50676
+ createContextScope as z
49902
50677
  };