@workflow/web 4.1.0-beta.36 → 4.1.0-beta.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (20) hide show
  1. package/build/client/assets/encryption-8OvC6eoJ.js +1 -0
  2. package/build/client/assets/{highlighted-body-B3W2YXNL-DCpvexQb.js → highlighted-body-B3W2YXNL-BO6bNJzI.js} +1 -1
  3. package/build/client/assets/{home-DrlgsY_n.js → home-bWDrLREI.js} +1 -1
  4. package/build/client/assets/{manifest-5132e9b8.js → manifest-daa82ff1.js} +1 -1
  5. package/build/client/assets/{mermaid-3ZIDBTTL-Ddgw_y0p.js → mermaid-3ZIDBTTL-CJ6mkUFN.js} +71 -66
  6. package/build/client/assets/{root-DKF4DBnS.js → root-Ckv-c9_b.js} +1 -1
  7. package/build/client/assets/run-detail-EcdnCjQk.js +41 -0
  8. package/build/client/assets/{use-workflow-graph-CUAynhYD.js → use-workflow-graph-JKiMb5g6.js} +1 -1
  9. package/build/server/assets/{app-BMiBNdAl.js → app-CatvtWxS.js} +1 -1
  10. package/build/server/assets/{highlighted-body-B3W2YXNL-CzB1YMLj.js → highlighted-body-B3W2YXNL-DoOhy3wX.js} +2 -2
  11. package/build/server/assets/{mermaid-3ZIDBTTL-Dqygs4_q.js → mermaid-3ZIDBTTL-uuxw6-ur.js} +2 -2
  12. package/build/server/assets/{server-build-Up-_dwCR.js → server-build-XXW48t5z.js} +1633 -1198
  13. package/build/server/assets/{token-DbisGEEb.js → token-C58qysN7.js} +3 -3
  14. package/build/server/assets/{token-lkNtm8QO.js → token-CLFHo1Az.js} +2 -2
  15. package/build/server/assets/{token-util-DNmL7drj.js → token-util-C6iVpF77.js} +2 -2
  16. package/build/server/assets/{token-util-pehEj9SJ.js → token-util-CbxhzlWz.js} +1 -1
  17. package/build/server/assets/{token-util-BtczqLw5.js → token-util-CcopqG1U.js} +2 -2
  18. package/build/server/index.js +1 -1
  19. package/package.json +6 -6
  20. package/build/client/assets/run-detail-DKgwr7Ee.js +0 -36
@@ -14,7 +14,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
14
14
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
15
15
  var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
16
16
  var _a2, _reader;
17
- import { a as requireReact, S as ServerRouter, c as createReadableStreamFromReadable, r as reactExports, g as getDefaultExportFromCjs, R as React, b as ReactExports, w as withComponentProps, M as Meta, L as Links, d as ScrollRestoration, e as Scripts, O as Outlet, u as useNavigate, f as useSearchParams, h as Link$1, i as useLocation, j as useParams } from "./app-BMiBNdAl.js";
17
+ import { a as requireReact, S as ServerRouter, c as createReadableStreamFromReadable, r as reactExports, g as getDefaultExportFromCjs, R as React, b as ReactExports, w as withComponentProps, M as Meta, L as Links, d as ScrollRestoration, e as Scripts, O as Outlet, u as useNavigate, f as useSearchParams, h as Link$1, i as useLocation, j as useParams } from "./app-CatvtWxS.js";
18
18
  import require$$0$4, { PassThrough } from "node:stream";
19
19
  import require$$0 from "util";
20
20
  import require$$1$1 from "crypto";
@@ -30198,7 +30198,7 @@ const createLucideIcon = (iconName, iconNode) => {
30198
30198
  * This source code is licensed under the ISC license.
30199
30199
  * See the LICENSE file in the root directory of this source tree.
30200
30200
  */
30201
- const __iconNode$y = [
30201
+ const __iconNode$A = [
30202
30202
  [
30203
30203
  "path",
30204
30204
  {
@@ -30207,14 +30207,14 @@ const __iconNode$y = [
30207
30207
  }
30208
30208
  ]
30209
30209
  ];
30210
- const Activity = createLucideIcon("activity", __iconNode$y);
30210
+ const Activity = createLucideIcon("activity", __iconNode$A);
30211
30211
  /**
30212
30212
  * @license lucide-react v0.575.0 - ISC
30213
30213
  *
30214
30214
  * This source code is licensed under the ISC license.
30215
30215
  * See the LICENSE file in the root directory of this source tree.
30216
30216
  */
30217
- const __iconNode$x = [
30217
+ const __iconNode$z = [
30218
30218
  ["path", { d: "M6.87 6.87a8 8 0 1 0 11.26 11.26", key: "3on8tj" }],
30219
30219
  ["path", { d: "M19.9 14.25a8 8 0 0 0-9.15-9.15", key: "15ghsc" }],
30220
30220
  ["path", { d: "m22 6-3-3", key: "1opdir" }],
@@ -30222,105 +30222,105 @@ const __iconNode$x = [
30222
30222
  ["path", { d: "m2 2 20 20", key: "1ooewy" }],
30223
30223
  ["path", { d: "M4 4 2 6", key: "1ycko6" }]
30224
30224
  ];
30225
- const AlarmClockOff = createLucideIcon("alarm-clock-off", __iconNode$x);
30225
+ const AlarmClockOff = createLucideIcon("alarm-clock-off", __iconNode$z);
30226
30226
  /**
30227
30227
  * @license lucide-react v0.575.0 - ISC
30228
30228
  *
30229
30229
  * This source code is licensed under the ISC license.
30230
30230
  * See the LICENSE file in the root directory of this source tree.
30231
30231
  */
30232
- const __iconNode$w = [
30232
+ const __iconNode$y = [
30233
30233
  ["path", { d: "m3 16 4 4 4-4", key: "1co6wj" }],
30234
30234
  ["path", { d: "M7 20V4", key: "1yoxec" }],
30235
30235
  ["path", { d: "M20 8h-5", key: "1vsyxs" }],
30236
30236
  ["path", { d: "M15 10V6.5a2.5 2.5 0 0 1 5 0V10", key: "ag13bf" }],
30237
30237
  ["path", { d: "M15 14h5l-5 6h5", key: "ur5jdg" }]
30238
30238
  ];
30239
- const ArrowDownAZ = createLucideIcon("arrow-down-a-z", __iconNode$w);
30239
+ const ArrowDownAZ = createLucideIcon("arrow-down-a-z", __iconNode$y);
30240
30240
  /**
30241
30241
  * @license lucide-react v0.575.0 - ISC
30242
30242
  *
30243
30243
  * This source code is licensed under the ISC license.
30244
30244
  * See the LICENSE file in the root directory of this source tree.
30245
30245
  */
30246
- const __iconNode$v = [
30246
+ const __iconNode$x = [
30247
30247
  ["path", { d: "m3 8 4-4 4 4", key: "11wl7u" }],
30248
30248
  ["path", { d: "M7 4v16", key: "1glfcx" }],
30249
30249
  ["path", { d: "M20 8h-5", key: "1vsyxs" }],
30250
30250
  ["path", { d: "M15 10V6.5a2.5 2.5 0 0 1 5 0V10", key: "ag13bf" }],
30251
30251
  ["path", { d: "M15 14h5l-5 6h5", key: "ur5jdg" }]
30252
30252
  ];
30253
- const ArrowUpAZ = createLucideIcon("arrow-up-a-z", __iconNode$v);
30253
+ const ArrowUpAZ = createLucideIcon("arrow-up-a-z", __iconNode$x);
30254
30254
  /**
30255
30255
  * @license lucide-react v0.575.0 - ISC
30256
30256
  *
30257
30257
  * This source code is licensed under the ISC license.
30258
30258
  * See the LICENSE file in the root directory of this source tree.
30259
30259
  */
30260
- const __iconNode$u = [
30260
+ const __iconNode$w = [
30261
30261
  ["path", { d: "M7 7h10v10", key: "1tivn9" }],
30262
30262
  ["path", { d: "M7 17 17 7", key: "1vkiza" }]
30263
30263
  ];
30264
- const ArrowUpRight = createLucideIcon("arrow-up-right", __iconNode$u);
30264
+ const ArrowUpRight = createLucideIcon("arrow-up-right", __iconNode$w);
30265
30265
  /**
30266
30266
  * @license lucide-react v0.575.0 - ISC
30267
30267
  *
30268
30268
  * This source code is licensed under the ISC license.
30269
30269
  * See the LICENSE file in the root directory of this source tree.
30270
30270
  */
30271
- const __iconNode$t = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
30272
- const Check = createLucideIcon("check", __iconNode$t);
30271
+ const __iconNode$v = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
30272
+ const Check = createLucideIcon("check", __iconNode$v);
30273
30273
  /**
30274
30274
  * @license lucide-react v0.575.0 - ISC
30275
30275
  *
30276
30276
  * This source code is licensed under the ISC license.
30277
30277
  * See the LICENSE file in the root directory of this source tree.
30278
30278
  */
30279
- const __iconNode$s = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
30280
- const ChevronDown = createLucideIcon("chevron-down", __iconNode$s);
30279
+ const __iconNode$u = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
30280
+ const ChevronDown = createLucideIcon("chevron-down", __iconNode$u);
30281
30281
  /**
30282
30282
  * @license lucide-react v0.575.0 - ISC
30283
30283
  *
30284
30284
  * This source code is licensed under the ISC license.
30285
30285
  * See the LICENSE file in the root directory of this source tree.
30286
30286
  */
30287
- const __iconNode$r = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]];
30288
- const ChevronLeft = createLucideIcon("chevron-left", __iconNode$r);
30287
+ const __iconNode$t = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]];
30288
+ const ChevronLeft = createLucideIcon("chevron-left", __iconNode$t);
30289
30289
  /**
30290
30290
  * @license lucide-react v0.575.0 - ISC
30291
30291
  *
30292
30292
  * This source code is licensed under the ISC license.
30293
30293
  * See the LICENSE file in the root directory of this source tree.
30294
30294
  */
30295
- const __iconNode$q = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]];
30296
- const ChevronRight = createLucideIcon("chevron-right", __iconNode$q);
30295
+ const __iconNode$s = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]];
30296
+ const ChevronRight = createLucideIcon("chevron-right", __iconNode$s);
30297
30297
  /**
30298
30298
  * @license lucide-react v0.575.0 - ISC
30299
30299
  *
30300
30300
  * This source code is licensed under the ISC license.
30301
30301
  * See the LICENSE file in the root directory of this source tree.
30302
30302
  */
30303
- const __iconNode$p = [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]];
30304
- const ChevronUp = createLucideIcon("chevron-up", __iconNode$p);
30303
+ const __iconNode$r = [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]];
30304
+ const ChevronUp = createLucideIcon("chevron-up", __iconNode$r);
30305
30305
  /**
30306
30306
  * @license lucide-react v0.575.0 - ISC
30307
30307
  *
30308
30308
  * This source code is licensed under the ISC license.
30309
30309
  * See the LICENSE file in the root directory of this source tree.
30310
30310
  */
30311
- const __iconNode$o = [
30311
+ const __iconNode$q = [
30312
30312
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
30313
30313
  ["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
30314
30314
  ["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
30315
30315
  ];
30316
- const CircleAlert = createLucideIcon("circle-alert", __iconNode$o);
30316
+ const CircleAlert = createLucideIcon("circle-alert", __iconNode$q);
30317
30317
  /**
30318
30318
  * @license lucide-react v0.575.0 - ISC
30319
30319
  *
30320
30320
  * This source code is licensed under the ISC license.
30321
30321
  * See the LICENSE file in the root directory of this source tree.
30322
30322
  */
30323
- const __iconNode$n = [
30323
+ const __iconNode$p = [
30324
30324
  [
30325
30325
  "path",
30326
30326
  {
@@ -30330,127 +30330,127 @@ const __iconNode$n = [
30330
30330
  ],
30331
30331
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]
30332
30332
  ];
30333
- const CirclePlay = createLucideIcon("circle-play", __iconNode$n);
30333
+ const CirclePlay = createLucideIcon("circle-play", __iconNode$p);
30334
30334
  /**
30335
30335
  * @license lucide-react v0.575.0 - ISC
30336
30336
  *
30337
30337
  * This source code is licensed under the ISC license.
30338
30338
  * See the LICENSE file in the root directory of this source tree.
30339
30339
  */
30340
- const __iconNode$m = [
30340
+ const __iconNode$o = [
30341
30341
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
30342
30342
  ["path", { d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3", key: "1u773s" }],
30343
30343
  ["path", { d: "M12 17h.01", key: "p32p05" }]
30344
30344
  ];
30345
- const CircleQuestionMark = createLucideIcon("circle-question-mark", __iconNode$m);
30345
+ const CircleQuestionMark = createLucideIcon("circle-question-mark", __iconNode$o);
30346
30346
  /**
30347
30347
  * @license lucide-react v0.575.0 - ISC
30348
30348
  *
30349
30349
  * This source code is licensed under the ISC license.
30350
30350
  * See the LICENSE file in the root directory of this source tree.
30351
30351
  */
30352
- const __iconNode$l = [
30352
+ const __iconNode$n = [
30353
30353
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
30354
30354
  ["rect", { x: "9", y: "9", width: "6", height: "6", rx: "1", key: "1ssd4o" }]
30355
30355
  ];
30356
- const CircleStop = createLucideIcon("circle-stop", __iconNode$l);
30356
+ const CircleStop = createLucideIcon("circle-stop", __iconNode$n);
30357
30357
  /**
30358
30358
  * @license lucide-react v0.575.0 - ISC
30359
30359
  *
30360
30360
  * This source code is licensed under the ISC license.
30361
30361
  * See the LICENSE file in the root directory of this source tree.
30362
30362
  */
30363
- const __iconNode$k = [
30363
+ const __iconNode$m = [
30364
30364
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
30365
30365
  ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
30366
30366
  ["path", { d: "m9 9 6 6", key: "z0biqf" }]
30367
30367
  ];
30368
- const CircleX = createLucideIcon("circle-x", __iconNode$k);
30368
+ const CircleX = createLucideIcon("circle-x", __iconNode$m);
30369
30369
  /**
30370
30370
  * @license lucide-react v0.575.0 - ISC
30371
30371
  *
30372
30372
  * This source code is licensed under the ISC license.
30373
30373
  * See the LICENSE file in the root directory of this source tree.
30374
30374
  */
30375
- const __iconNode$j = [["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]];
30376
- const Circle = createLucideIcon("circle", __iconNode$j);
30375
+ const __iconNode$l = [["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]];
30376
+ const Circle = createLucideIcon("circle", __iconNode$l);
30377
30377
  /**
30378
30378
  * @license lucide-react v0.575.0 - ISC
30379
30379
  *
30380
30380
  * This source code is licensed under the ISC license.
30381
30381
  * See the LICENSE file in the root directory of this source tree.
30382
30382
  */
30383
- const __iconNode$i = [
30383
+ const __iconNode$k = [
30384
30384
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
30385
30385
  ["path", { d: "M12 6v6l4 2", key: "mmk7yg" }]
30386
30386
  ];
30387
- const Clock = createLucideIcon("clock", __iconNode$i);
30387
+ const Clock = createLucideIcon("clock", __iconNode$k);
30388
30388
  /**
30389
30389
  * @license lucide-react v0.575.0 - ISC
30390
30390
  *
30391
30391
  * This source code is licensed under the ISC license.
30392
30392
  * See the LICENSE file in the root directory of this source tree.
30393
30393
  */
30394
- const __iconNode$h = [
30394
+ const __iconNode$j = [
30395
30395
  ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
30396
30396
  ["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" }]
30397
30397
  ];
30398
- const Copy = createLucideIcon("copy", __iconNode$h);
30398
+ const Copy = createLucideIcon("copy", __iconNode$j);
30399
30399
  /**
30400
30400
  * @license lucide-react v0.575.0 - ISC
30401
30401
  *
30402
30402
  * This source code is licensed under the ISC license.
30403
30403
  * See the LICENSE file in the root directory of this source tree.
30404
30404
  */
30405
- const __iconNode$g = [
30405
+ const __iconNode$i = [
30406
30406
  ["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
30407
30407
  ["circle", { cx: "19", cy: "12", r: "1", key: "1wjl8i" }],
30408
30408
  ["circle", { cx: "5", cy: "12", r: "1", key: "1pcz8c" }]
30409
30409
  ];
30410
- const Ellipsis = createLucideIcon("ellipsis", __iconNode$g);
30410
+ const Ellipsis = createLucideIcon("ellipsis", __iconNode$i);
30411
30411
  /**
30412
30412
  * @license lucide-react v0.575.0 - ISC
30413
30413
  *
30414
30414
  * This source code is licensed under the ISC license.
30415
30415
  * See the LICENSE file in the root directory of this source tree.
30416
30416
  */
30417
- const __iconNode$f = [
30417
+ const __iconNode$h = [
30418
30418
  ["path", { d: "M15 6a9 9 0 0 0-9 9V3", key: "1cii5b" }],
30419
30419
  ["circle", { cx: "18", cy: "6", r: "3", key: "1h7g24" }],
30420
30420
  ["circle", { cx: "6", cy: "18", r: "3", key: "fqmcym" }]
30421
30421
  ];
30422
- const GitBranch = createLucideIcon("git-branch", __iconNode$f);
30422
+ const GitBranch = createLucideIcon("git-branch", __iconNode$h);
30423
30423
  /**
30424
30424
  * @license lucide-react v0.575.0 - ISC
30425
30425
  *
30426
30426
  * This source code is licensed under the ISC license.
30427
30427
  * See the LICENSE file in the root directory of this source tree.
30428
30428
  */
30429
- const __iconNode$e = [
30429
+ const __iconNode$g = [
30430
30430
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
30431
30431
  ["path", { d: "M12 16v-4", key: "1dtifu" }],
30432
30432
  ["path", { d: "M12 8h.01", key: "e9boi3" }]
30433
30433
  ];
30434
- const Info$2 = createLucideIcon("info", __iconNode$e);
30434
+ const Info$2 = createLucideIcon("info", __iconNode$g);
30435
30435
  /**
30436
30436
  * @license lucide-react v0.575.0 - ISC
30437
30437
  *
30438
30438
  * This source code is licensed under the ISC license.
30439
30439
  * See the LICENSE file in the root directory of this source tree.
30440
30440
  */
30441
- const __iconNode$d = [
30441
+ const __iconNode$f = [
30442
30442
  ["path", { d: "M9 17H7A5 5 0 0 1 7 7h2", key: "8i5ue5" }],
30443
30443
  ["path", { d: "M15 7h2a5 5 0 1 1 0 10h-2", key: "1b9ql8" }],
30444
30444
  ["line", { x1: "8", x2: "16", y1: "12", y2: "12", key: "1jonct" }]
30445
30445
  ];
30446
- const Link2 = createLucideIcon("link-2", __iconNode$d);
30446
+ const Link2 = createLucideIcon("link-2", __iconNode$f);
30447
30447
  /**
30448
30448
  * @license lucide-react v0.575.0 - ISC
30449
30449
  *
30450
30450
  * This source code is licensed under the ISC license.
30451
30451
  * See the LICENSE file in the root directory of this source tree.
30452
30452
  */
30453
- const __iconNode$c = [
30453
+ const __iconNode$e = [
30454
30454
  ["path", { d: "M3 5h.01", key: "18ugdj" }],
30455
30455
  ["path", { d: "M3 12h.01", key: "nlz23k" }],
30456
30456
  ["path", { d: "M3 19h.01", key: "noohij" }],
@@ -30458,15 +30458,37 @@ const __iconNode$c = [
30458
30458
  ["path", { d: "M8 12h13", key: "1za7za" }],
30459
30459
  ["path", { d: "M8 19h13", key: "m83p4d" }]
30460
30460
  ];
30461
- const List$1 = createLucideIcon("list", __iconNode$c);
30461
+ const List$1 = createLucideIcon("list", __iconNode$e);
30462
30462
  /**
30463
30463
  * @license lucide-react v0.575.0 - ISC
30464
30464
  *
30465
30465
  * This source code is licensed under the ISC license.
30466
30466
  * See the LICENSE file in the root directory of this source tree.
30467
30467
  */
30468
- const __iconNode$b = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
30469
- const LoaderCircle = createLucideIcon("loader-circle", __iconNode$b);
30468
+ const __iconNode$d = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
30469
+ const LoaderCircle = createLucideIcon("loader-circle", __iconNode$d);
30470
+ /**
30471
+ * @license lucide-react v0.575.0 - ISC
30472
+ *
30473
+ * This source code is licensed under the ISC license.
30474
+ * See the LICENSE file in the root directory of this source tree.
30475
+ */
30476
+ const __iconNode$c = [
30477
+ ["rect", { width: "18", height: "11", x: "3", y: "11", rx: "2", ry: "2", key: "1w4ew1" }],
30478
+ ["path", { d: "M7 11V7a5 5 0 0 1 9.9-1", key: "1mm8w8" }]
30479
+ ];
30480
+ const LockOpen = createLucideIcon("lock-open", __iconNode$c);
30481
+ /**
30482
+ * @license lucide-react v0.575.0 - ISC
30483
+ *
30484
+ * This source code is licensed under the ISC license.
30485
+ * See the LICENSE file in the root directory of this source tree.
30486
+ */
30487
+ const __iconNode$b = [
30488
+ ["rect", { width: "18", height: "11", x: "3", y: "11", rx: "2", ry: "2", key: "1w4ew1" }],
30489
+ ["path", { d: "M7 11V7a5 5 0 0 1 10 0v4", key: "fwvmzm" }]
30490
+ ];
30491
+ const Lock = createLucideIcon("lock", __iconNode$b);
30470
30492
  /**
30471
30493
  * @license lucide-react v0.575.0 - ISC
30472
30494
  *
@@ -34728,6 +34750,968 @@ const useDarkMode = () => {
34728
34750
  }, []);
34729
34751
  return isDark;
34730
34752
  };
34753
+ class DevalueError extends Error {
34754
+ /**
34755
+ * @param {string} message
34756
+ * @param {string[]} keys
34757
+ * @param {any} [value] - The value that failed to be serialized
34758
+ * @param {any} [root] - The root value being serialized
34759
+ */
34760
+ constructor(message2, keys2, value, root2) {
34761
+ super(message2);
34762
+ this.name = "DevalueError";
34763
+ this.path = keys2.join("");
34764
+ this.value = value;
34765
+ this.root = root2;
34766
+ }
34767
+ }
34768
+ function is_primitive(thing) {
34769
+ return Object(thing) !== thing;
34770
+ }
34771
+ const object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(
34772
+ Object.prototype
34773
+ ).sort().join("\0");
34774
+ function is_plain_object(thing) {
34775
+ const proto2 = Object.getPrototypeOf(thing);
34776
+ return proto2 === Object.prototype || proto2 === null || Object.getPrototypeOf(proto2) === null || Object.getOwnPropertyNames(proto2).sort().join("\0") === object_proto_names;
34777
+ }
34778
+ function get_type(thing) {
34779
+ return Object.prototype.toString.call(thing).slice(8, -1);
34780
+ }
34781
+ function get_escaped_char(char) {
34782
+ switch (char) {
34783
+ case '"':
34784
+ return '\\"';
34785
+ case "<":
34786
+ return "\\u003C";
34787
+ case "\\":
34788
+ return "\\\\";
34789
+ case "\n":
34790
+ return "\\n";
34791
+ case "\r":
34792
+ return "\\r";
34793
+ case " ":
34794
+ return "\\t";
34795
+ case "\b":
34796
+ return "\\b";
34797
+ case "\f":
34798
+ return "\\f";
34799
+ case "\u2028":
34800
+ return "\\u2028";
34801
+ case "\u2029":
34802
+ return "\\u2029";
34803
+ default:
34804
+ return char < " " ? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}` : "";
34805
+ }
34806
+ }
34807
+ function stringify_string(str) {
34808
+ let result = "";
34809
+ let last_pos = 0;
34810
+ const len = str.length;
34811
+ for (let i = 0; i < len; i += 1) {
34812
+ const char = str[i];
34813
+ const replacement = get_escaped_char(char);
34814
+ if (replacement) {
34815
+ result += str.slice(last_pos, i) + replacement;
34816
+ last_pos = i + 1;
34817
+ }
34818
+ }
34819
+ return `"${last_pos === 0 ? str : result + str.slice(last_pos)}"`;
34820
+ }
34821
+ function enumerable_symbols(object2) {
34822
+ return Object.getOwnPropertySymbols(object2).filter(
34823
+ (symbol2) => Object.getOwnPropertyDescriptor(object2, symbol2).enumerable
34824
+ );
34825
+ }
34826
+ const is_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;
34827
+ function stringify_key(key) {
34828
+ return is_identifier.test(key) ? "." + key : "[" + JSON.stringify(key) + "]";
34829
+ }
34830
+ function is_valid_array_index(s2) {
34831
+ if (s2.length === 0) return false;
34832
+ if (s2.length > 1 && s2.charCodeAt(0) === 48) return false;
34833
+ for (let i = 0; i < s2.length; i++) {
34834
+ const c = s2.charCodeAt(i);
34835
+ if (c < 48 || c > 57) return false;
34836
+ }
34837
+ const n = +s2;
34838
+ if (n >= 2 ** 32 - 1) return false;
34839
+ if (n < 0) return false;
34840
+ return true;
34841
+ }
34842
+ function valid_array_indices(array2) {
34843
+ const keys2 = Object.keys(array2);
34844
+ for (var i = keys2.length - 1; i >= 0; i--) {
34845
+ if (is_valid_array_index(keys2[i])) {
34846
+ break;
34847
+ }
34848
+ }
34849
+ keys2.length = i + 1;
34850
+ return keys2;
34851
+ }
34852
+ function encode64(arraybuffer) {
34853
+ const dv = new DataView(arraybuffer);
34854
+ let binaryString = "";
34855
+ for (let i = 0; i < arraybuffer.byteLength; i++) {
34856
+ binaryString += String.fromCharCode(dv.getUint8(i));
34857
+ }
34858
+ return binaryToAscii(binaryString);
34859
+ }
34860
+ function decode64(string2) {
34861
+ const binaryString = asciiToBinary(string2);
34862
+ const arraybuffer = new ArrayBuffer(binaryString.length);
34863
+ const dv = new DataView(arraybuffer);
34864
+ for (let i = 0; i < arraybuffer.byteLength; i++) {
34865
+ dv.setUint8(i, binaryString.charCodeAt(i));
34866
+ }
34867
+ return arraybuffer;
34868
+ }
34869
+ const KEY_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
34870
+ function asciiToBinary(data) {
34871
+ if (data.length % 4 === 0) {
34872
+ data = data.replace(/==?$/, "");
34873
+ }
34874
+ let output = "";
34875
+ let buffer = 0;
34876
+ let accumulatedBits = 0;
34877
+ for (let i = 0; i < data.length; i++) {
34878
+ buffer <<= 6;
34879
+ buffer |= KEY_STRING.indexOf(data[i]);
34880
+ accumulatedBits += 6;
34881
+ if (accumulatedBits === 24) {
34882
+ output += String.fromCharCode((buffer & 16711680) >> 16);
34883
+ output += String.fromCharCode((buffer & 65280) >> 8);
34884
+ output += String.fromCharCode(buffer & 255);
34885
+ buffer = accumulatedBits = 0;
34886
+ }
34887
+ }
34888
+ if (accumulatedBits === 12) {
34889
+ buffer >>= 4;
34890
+ output += String.fromCharCode(buffer);
34891
+ } else if (accumulatedBits === 18) {
34892
+ buffer >>= 2;
34893
+ output += String.fromCharCode((buffer & 65280) >> 8);
34894
+ output += String.fromCharCode(buffer & 255);
34895
+ }
34896
+ return output;
34897
+ }
34898
+ function binaryToAscii(str) {
34899
+ let out = "";
34900
+ for (let i = 0; i < str.length; i += 3) {
34901
+ const groupsOfSix = [void 0, void 0, void 0, void 0];
34902
+ groupsOfSix[0] = str.charCodeAt(i) >> 2;
34903
+ groupsOfSix[1] = (str.charCodeAt(i) & 3) << 4;
34904
+ if (str.length > i + 1) {
34905
+ groupsOfSix[1] |= str.charCodeAt(i + 1) >> 4;
34906
+ groupsOfSix[2] = (str.charCodeAt(i + 1) & 15) << 2;
34907
+ }
34908
+ if (str.length > i + 2) {
34909
+ groupsOfSix[2] |= str.charCodeAt(i + 2) >> 6;
34910
+ groupsOfSix[3] = str.charCodeAt(i + 2) & 63;
34911
+ }
34912
+ for (let j2 = 0; j2 < groupsOfSix.length; j2++) {
34913
+ if (typeof groupsOfSix[j2] === "undefined") {
34914
+ out += "=";
34915
+ } else {
34916
+ out += KEY_STRING[groupsOfSix[j2]];
34917
+ }
34918
+ }
34919
+ }
34920
+ return out;
34921
+ }
34922
+ const UNDEFINED = -1;
34923
+ const HOLE = -2;
34924
+ const NAN = -3;
34925
+ const POSITIVE_INFINITY = -4;
34926
+ const NEGATIVE_INFINITY = -5;
34927
+ const NEGATIVE_ZERO = -6;
34928
+ const SPARSE = -7;
34929
+ function parse$7(serialized, revivers) {
34930
+ return unflatten(JSON.parse(serialized), revivers);
34931
+ }
34932
+ function unflatten(parsed, revivers) {
34933
+ if (typeof parsed === "number") return hydrate(parsed, true);
34934
+ if (!Array.isArray(parsed) || parsed.length === 0) {
34935
+ throw new Error("Invalid input");
34936
+ }
34937
+ const values = (
34938
+ /** @type {any[]} */
34939
+ parsed
34940
+ );
34941
+ const hydrated = Array(values.length);
34942
+ let hydrating = null;
34943
+ function hydrate(index2, standalone = false) {
34944
+ if (index2 === UNDEFINED) return void 0;
34945
+ if (index2 === NAN) return NaN;
34946
+ if (index2 === POSITIVE_INFINITY) return Infinity;
34947
+ if (index2 === NEGATIVE_INFINITY) return -Infinity;
34948
+ if (index2 === NEGATIVE_ZERO) return -0;
34949
+ if (standalone || typeof index2 !== "number") {
34950
+ throw new Error(`Invalid input`);
34951
+ }
34952
+ if (index2 in hydrated) return hydrated[index2];
34953
+ const value = values[index2];
34954
+ if (!value || typeof value !== "object") {
34955
+ hydrated[index2] = value;
34956
+ } else if (Array.isArray(value)) {
34957
+ if (typeof value[0] === "string") {
34958
+ const type = value[0];
34959
+ const reviver = revivers && Object.hasOwn(revivers, type) ? revivers[type] : void 0;
34960
+ if (reviver) {
34961
+ let i = value[1];
34962
+ if (typeof i !== "number") {
34963
+ i = values.push(value[1]) - 1;
34964
+ }
34965
+ hydrating ?? (hydrating = /* @__PURE__ */ new Set());
34966
+ if (hydrating.has(i)) {
34967
+ throw new Error("Invalid circular reference");
34968
+ }
34969
+ hydrating.add(i);
34970
+ hydrated[index2] = reviver(hydrate(i));
34971
+ hydrating.delete(i);
34972
+ return hydrated[index2];
34973
+ }
34974
+ switch (type) {
34975
+ case "Date":
34976
+ hydrated[index2] = new Date(value[1]);
34977
+ break;
34978
+ case "Set":
34979
+ const set2 = /* @__PURE__ */ new Set();
34980
+ hydrated[index2] = set2;
34981
+ for (let i = 1; i < value.length; i += 1) {
34982
+ set2.add(hydrate(value[i]));
34983
+ }
34984
+ break;
34985
+ case "Map":
34986
+ const map2 = /* @__PURE__ */ new Map();
34987
+ hydrated[index2] = map2;
34988
+ for (let i = 1; i < value.length; i += 2) {
34989
+ map2.set(hydrate(value[i]), hydrate(value[i + 1]));
34990
+ }
34991
+ break;
34992
+ case "RegExp":
34993
+ hydrated[index2] = new RegExp(value[1], value[2]);
34994
+ break;
34995
+ case "Object":
34996
+ hydrated[index2] = Object(value[1]);
34997
+ break;
34998
+ case "BigInt":
34999
+ hydrated[index2] = BigInt(value[1]);
35000
+ break;
35001
+ case "null":
35002
+ const obj = /* @__PURE__ */ Object.create(null);
35003
+ hydrated[index2] = obj;
35004
+ for (let i = 1; i < value.length; i += 2) {
35005
+ obj[value[i]] = hydrate(value[i + 1]);
35006
+ }
35007
+ break;
35008
+ case "Int8Array":
35009
+ case "Uint8Array":
35010
+ case "Uint8ClampedArray":
35011
+ case "Int16Array":
35012
+ case "Uint16Array":
35013
+ case "Int32Array":
35014
+ case "Uint32Array":
35015
+ case "Float32Array":
35016
+ case "Float64Array":
35017
+ case "BigInt64Array":
35018
+ case "BigUint64Array": {
35019
+ if (values[value[1]][0] !== "ArrayBuffer") {
35020
+ throw new Error("Invalid data");
35021
+ }
35022
+ const TypedArrayConstructor = globalThis[type];
35023
+ const buffer = hydrate(value[1]);
35024
+ const typedArray = new TypedArrayConstructor(buffer);
35025
+ hydrated[index2] = value[2] !== void 0 ? typedArray.subarray(value[2], value[3]) : typedArray;
35026
+ break;
35027
+ }
35028
+ case "ArrayBuffer": {
35029
+ const base642 = value[1];
35030
+ if (typeof base642 !== "string") {
35031
+ throw new Error("Invalid ArrayBuffer encoding");
35032
+ }
35033
+ const arraybuffer = decode64(base642);
35034
+ hydrated[index2] = arraybuffer;
35035
+ break;
35036
+ }
35037
+ case "Temporal.Duration":
35038
+ case "Temporal.Instant":
35039
+ case "Temporal.PlainDate":
35040
+ case "Temporal.PlainTime":
35041
+ case "Temporal.PlainDateTime":
35042
+ case "Temporal.PlainMonthDay":
35043
+ case "Temporal.PlainYearMonth":
35044
+ case "Temporal.ZonedDateTime": {
35045
+ const temporalName = type.slice(9);
35046
+ hydrated[index2] = Temporal[temporalName].from(value[1]);
35047
+ break;
35048
+ }
35049
+ case "URL": {
35050
+ const url2 = new URL(value[1]);
35051
+ hydrated[index2] = url2;
35052
+ break;
35053
+ }
35054
+ case "URLSearchParams": {
35055
+ const url2 = new URLSearchParams(value[1]);
35056
+ hydrated[index2] = url2;
35057
+ break;
35058
+ }
35059
+ default:
35060
+ throw new Error(`Unknown type ${type}`);
35061
+ }
35062
+ } else if (value[0] === SPARSE) {
35063
+ const len = value[1];
35064
+ const array2 = new Array(len);
35065
+ hydrated[index2] = array2;
35066
+ for (let i = 2; i < value.length; i += 2) {
35067
+ const idx = value[i];
35068
+ array2[idx] = hydrate(value[i + 1]);
35069
+ }
35070
+ } else {
35071
+ const array2 = new Array(value.length);
35072
+ hydrated[index2] = array2;
35073
+ for (let i = 0; i < value.length; i += 1) {
35074
+ const n = value[i];
35075
+ if (n === HOLE) continue;
35076
+ array2[i] = hydrate(n);
35077
+ }
35078
+ }
35079
+ } else {
35080
+ const object2 = {};
35081
+ hydrated[index2] = object2;
35082
+ for (const key of Object.keys(value)) {
35083
+ if (key === "__proto__") {
35084
+ throw new Error("Cannot parse an object with a `__proto__` property");
35085
+ }
35086
+ const n = value[key];
35087
+ object2[key] = hydrate(n);
35088
+ }
35089
+ }
35090
+ return hydrated[index2];
35091
+ }
35092
+ return hydrate(0);
35093
+ }
35094
+ function stringify$2(value, reducers) {
35095
+ const stringified = [];
35096
+ const indexes = /* @__PURE__ */ new Map();
35097
+ const custom2 = [];
35098
+ if (reducers) {
35099
+ for (const key of Object.getOwnPropertyNames(reducers)) {
35100
+ custom2.push({ key, fn: reducers[key] });
35101
+ }
35102
+ }
35103
+ const keys2 = [];
35104
+ let p2 = 0;
35105
+ function flatten(thing) {
35106
+ if (thing === void 0) return UNDEFINED;
35107
+ if (Number.isNaN(thing)) return NAN;
35108
+ if (thing === Infinity) return POSITIVE_INFINITY;
35109
+ if (thing === -Infinity) return NEGATIVE_INFINITY;
35110
+ if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO;
35111
+ if (indexes.has(thing)) return indexes.get(thing);
35112
+ const index3 = p2++;
35113
+ indexes.set(thing, index3);
35114
+ for (const { key, fn: fn2 } of custom2) {
35115
+ const value2 = fn2(thing);
35116
+ if (value2) {
35117
+ stringified[index3] = `["${key}",${flatten(value2)}]`;
35118
+ return index3;
35119
+ }
35120
+ }
35121
+ if (typeof thing === "function") {
35122
+ throw new DevalueError(`Cannot stringify a function`, keys2, thing, value);
35123
+ }
35124
+ let str = "";
35125
+ if (is_primitive(thing)) {
35126
+ str = stringify_primitive(thing);
35127
+ } else {
35128
+ const type = get_type(thing);
35129
+ switch (type) {
35130
+ case "Number":
35131
+ case "String":
35132
+ case "Boolean":
35133
+ str = `["Object",${stringify_primitive(thing)}]`;
35134
+ break;
35135
+ case "BigInt":
35136
+ str = `["BigInt",${thing}]`;
35137
+ break;
35138
+ case "Date":
35139
+ const valid2 = !isNaN(thing.getDate());
35140
+ str = `["Date","${valid2 ? thing.toISOString() : ""}"]`;
35141
+ break;
35142
+ case "URL":
35143
+ str = `["URL",${stringify_string(thing.toString())}]`;
35144
+ break;
35145
+ case "URLSearchParams":
35146
+ str = `["URLSearchParams",${stringify_string(thing.toString())}]`;
35147
+ break;
35148
+ case "RegExp":
35149
+ const { source, flags } = thing;
35150
+ str = flags ? `["RegExp",${stringify_string(source)},"${flags}"]` : `["RegExp",${stringify_string(source)}]`;
35151
+ break;
35152
+ case "Array": {
35153
+ let mostly_dense = false;
35154
+ str = "[";
35155
+ for (let i = 0; i < thing.length; i += 1) {
35156
+ if (i > 0) str += ",";
35157
+ if (Object.hasOwn(thing, i)) {
35158
+ keys2.push(`[${i}]`);
35159
+ str += flatten(thing[i]);
35160
+ keys2.pop();
35161
+ } else if (mostly_dense) {
35162
+ str += HOLE;
35163
+ } else {
35164
+ const populated_keys = valid_array_indices(
35165
+ /** @type {any[]} */
35166
+ thing
35167
+ );
35168
+ const population = populated_keys.length;
35169
+ const d2 = String(thing.length).length;
35170
+ const hole_cost = (thing.length - population) * 3;
35171
+ const sparse_cost = 4 + d2 + population * (d2 + 1);
35172
+ if (hole_cost > sparse_cost) {
35173
+ str = "[" + SPARSE + "," + thing.length;
35174
+ for (let j2 = 0; j2 < populated_keys.length; j2++) {
35175
+ const key = populated_keys[j2];
35176
+ keys2.push(`[${key}]`);
35177
+ str += "," + key + "," + flatten(thing[key]);
35178
+ keys2.pop();
35179
+ }
35180
+ break;
35181
+ } else {
35182
+ mostly_dense = true;
35183
+ str += HOLE;
35184
+ }
35185
+ }
35186
+ }
35187
+ str += "]";
35188
+ break;
35189
+ }
35190
+ case "Set":
35191
+ str = '["Set"';
35192
+ for (const value2 of thing) {
35193
+ str += `,${flatten(value2)}`;
35194
+ }
35195
+ str += "]";
35196
+ break;
35197
+ case "Map":
35198
+ str = '["Map"';
35199
+ for (const [key, value2] of thing) {
35200
+ keys2.push(
35201
+ `.get(${is_primitive(key) ? stringify_primitive(key) : "..."})`
35202
+ );
35203
+ str += `,${flatten(key)},${flatten(value2)}`;
35204
+ keys2.pop();
35205
+ }
35206
+ str += "]";
35207
+ break;
35208
+ case "Int8Array":
35209
+ case "Uint8Array":
35210
+ case "Uint8ClampedArray":
35211
+ case "Int16Array":
35212
+ case "Uint16Array":
35213
+ case "Int32Array":
35214
+ case "Uint32Array":
35215
+ case "Float32Array":
35216
+ case "Float64Array":
35217
+ case "BigInt64Array":
35218
+ case "BigUint64Array": {
35219
+ const typedArray = thing;
35220
+ str = '["' + type + '",' + flatten(typedArray.buffer);
35221
+ const a2 = thing.byteOffset;
35222
+ const b2 = a2 + thing.byteLength;
35223
+ if (a2 > 0 || b2 !== typedArray.buffer.byteLength) {
35224
+ const m2 = +/(\d+)/.exec(type)[1] / 8;
35225
+ str += `,${a2 / m2},${b2 / m2}`;
35226
+ }
35227
+ str += "]";
35228
+ break;
35229
+ }
35230
+ case "ArrayBuffer": {
35231
+ const arraybuffer = thing;
35232
+ const base642 = encode64(arraybuffer);
35233
+ str = `["ArrayBuffer","${base642}"]`;
35234
+ break;
35235
+ }
35236
+ case "Temporal.Duration":
35237
+ case "Temporal.Instant":
35238
+ case "Temporal.PlainDate":
35239
+ case "Temporal.PlainTime":
35240
+ case "Temporal.PlainDateTime":
35241
+ case "Temporal.PlainMonthDay":
35242
+ case "Temporal.PlainYearMonth":
35243
+ case "Temporal.ZonedDateTime":
35244
+ str = `["${type}",${stringify_string(thing.toString())}]`;
35245
+ break;
35246
+ default:
35247
+ if (!is_plain_object(thing)) {
35248
+ throw new DevalueError(
35249
+ `Cannot stringify arbitrary non-POJOs`,
35250
+ keys2,
35251
+ thing,
35252
+ value
35253
+ );
35254
+ }
35255
+ if (enumerable_symbols(thing).length > 0) {
35256
+ throw new DevalueError(
35257
+ `Cannot stringify POJOs with symbolic keys`,
35258
+ keys2,
35259
+ thing,
35260
+ value
35261
+ );
35262
+ }
35263
+ if (Object.getPrototypeOf(thing) === null) {
35264
+ str = '["null"';
35265
+ for (const key of Object.keys(thing)) {
35266
+ if (key === "__proto__") {
35267
+ throw new DevalueError(
35268
+ `Cannot stringify objects with __proto__ keys`,
35269
+ keys2,
35270
+ thing,
35271
+ value
35272
+ );
35273
+ }
35274
+ keys2.push(stringify_key(key));
35275
+ str += `,${stringify_string(key)},${flatten(thing[key])}`;
35276
+ keys2.pop();
35277
+ }
35278
+ str += "]";
35279
+ } else {
35280
+ str = "{";
35281
+ let started = false;
35282
+ for (const key of Object.keys(thing)) {
35283
+ if (key === "__proto__") {
35284
+ throw new DevalueError(
35285
+ `Cannot stringify objects with __proto__ keys`,
35286
+ keys2,
35287
+ thing,
35288
+ value
35289
+ );
35290
+ }
35291
+ if (started) str += ",";
35292
+ started = true;
35293
+ keys2.push(stringify_key(key));
35294
+ str += `${stringify_string(key)}:${flatten(thing[key])}`;
35295
+ keys2.pop();
35296
+ }
35297
+ str += "}";
35298
+ }
35299
+ }
35300
+ }
35301
+ stringified[index3] = str;
35302
+ return index3;
35303
+ }
35304
+ const index2 = flatten(value);
35305
+ if (index2 < 0) return `${index2}`;
35306
+ return `[${stringified.join(",")}]`;
35307
+ }
35308
+ function stringify_primitive(thing) {
35309
+ const type = typeof thing;
35310
+ if (type === "string") return stringify_string(thing);
35311
+ if (thing instanceof String) return stringify_string(thing.toString());
35312
+ if (thing === void 0) return UNDEFINED.toString();
35313
+ if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO.toString();
35314
+ if (type === "bigint") return `["BigInt","${thing}"]`;
35315
+ return String(thing);
35316
+ }
35317
+ const SerializationFormat$1 = {
35318
+ /** devalue stringify/parse with TextEncoder/TextDecoder */
35319
+ DEVALUE_V1: "devl",
35320
+ /** Encrypted payload (inner payload has its own format prefix after decryption) */
35321
+ ENCRYPTED: "encr"
35322
+ };
35323
+ const FORMAT_PREFIX_LENGTH$1 = 4;
35324
+ new TextEncoder();
35325
+ const formatDecoder$1 = new TextDecoder();
35326
+ function decodeFormatPrefix$1(data) {
35327
+ if (!(data instanceof Uint8Array)) {
35328
+ return {
35329
+ format: SerializationFormat$1.DEVALUE_V1,
35330
+ payload: new TextEncoder().encode(JSON.stringify(data))
35331
+ };
35332
+ }
35333
+ if (data.length < FORMAT_PREFIX_LENGTH$1) {
35334
+ throw new Error(`Data too short to contain format prefix: expected at least ${FORMAT_PREFIX_LENGTH$1} bytes, got ${data.length}`);
35335
+ }
35336
+ const prefixBytes = data.subarray(0, FORMAT_PREFIX_LENGTH$1);
35337
+ const format2 = formatDecoder$1.decode(prefixBytes);
35338
+ const knownFormats = Object.values(SerializationFormat$1);
35339
+ if (!knownFormats.includes(format2)) {
35340
+ throw new Error(`Unknown serialization format: "${format2}". Known formats: ${knownFormats.join(", ")}`);
35341
+ }
35342
+ const payload = data.subarray(FORMAT_PREFIX_LENGTH$1);
35343
+ return { format: format2, payload };
35344
+ }
35345
+ function isEncryptedData(data) {
35346
+ if (!(data instanceof Uint8Array) || data.length < FORMAT_PREFIX_LENGTH$1) {
35347
+ return false;
35348
+ }
35349
+ const prefix = formatDecoder$1.decode(data.subarray(0, FORMAT_PREFIX_LENGTH$1));
35350
+ return prefix === SerializationFormat$1.ENCRYPTED;
35351
+ }
35352
+ function hydrateData(value, revivers) {
35353
+ if (value instanceof Uint8Array) {
35354
+ if (isEncryptedData(value)) {
35355
+ return value;
35356
+ }
35357
+ const { format: format2, payload } = decodeFormatPrefix$1(value);
35358
+ if (format2 === SerializationFormat$1.DEVALUE_V1) {
35359
+ const str = new TextDecoder().decode(payload);
35360
+ return parse$7(str, revivers);
35361
+ }
35362
+ throw new Error(`Unsupported serialization format: ${format2}`);
35363
+ }
35364
+ if (Array.isArray(value)) {
35365
+ return unflatten(value, revivers);
35366
+ }
35367
+ return value;
35368
+ }
35369
+ async function hydrateDataWithKey(value, revivers, key) {
35370
+ if (value instanceof Uint8Array && isEncryptedData(value) && key) {
35371
+ const { decrypt: decrypt2 } = await Promise.resolve().then(() => encryption);
35372
+ const { payload } = decodeFormatPrefix$1(value);
35373
+ const decrypted = await decrypt2(key, payload);
35374
+ return hydrateData(decrypted, revivers);
35375
+ }
35376
+ return hydrateData(value, revivers);
35377
+ }
35378
+ const STREAM_ID_PREFIX = "strm_";
35379
+ const STREAM_REF_TYPE$1 = "__workflow_stream_ref__";
35380
+ const CLASS_INSTANCE_REF_TYPE$1 = "__workflow_class_instance_ref__";
35381
+ class ClassInstanceRef {
35382
+ constructor(className, classId, data) {
35383
+ __publicField(this, "className");
35384
+ __publicField(this, "classId");
35385
+ __publicField(this, "data");
35386
+ __publicField(this, "__type", CLASS_INSTANCE_REF_TYPE$1);
35387
+ this.className = className;
35388
+ this.classId = classId;
35389
+ this.data = data;
35390
+ }
35391
+ toJSON() {
35392
+ return {
35393
+ __type: this.__type,
35394
+ className: this.className,
35395
+ classId: this.classId,
35396
+ data: this.data
35397
+ };
35398
+ }
35399
+ }
35400
+ const streamToStreamRef = (value) => {
35401
+ let streamId;
35402
+ if ("name" in value) {
35403
+ const name2 = String(value.name);
35404
+ if (!name2.startsWith(STREAM_ID_PREFIX)) {
35405
+ streamId = `${STREAM_ID_PREFIX}${name2}`;
35406
+ } else {
35407
+ streamId = name2;
35408
+ }
35409
+ } else {
35410
+ streamId = `${STREAM_ID_PREFIX}null`;
35411
+ }
35412
+ return { __type: STREAM_REF_TYPE$1, streamId };
35413
+ };
35414
+ const serializedStepFunctionToString = (value) => {
35415
+ if (!value)
35416
+ return "null";
35417
+ if (typeof value !== "object")
35418
+ return "null";
35419
+ if ("stepId" in value) {
35420
+ return `<step:${value.stepId}>`;
35421
+ }
35422
+ return "<function>";
35423
+ };
35424
+ const extractClassName = (classId) => {
35425
+ if (!classId)
35426
+ return "Unknown";
35427
+ const parts = classId.split("/");
35428
+ return parts[parts.length - 1] || classId;
35429
+ };
35430
+ const serializedInstanceToRef = (value) => {
35431
+ return new ClassInstanceRef(extractClassName(value.classId), value.classId, value.data);
35432
+ };
35433
+ const serializedClassToString = (value) => {
35434
+ return `<class:${extractClassName(value.classId)}>`;
35435
+ };
35436
+ const observabilityRevivers = {
35437
+ ReadableStream: streamToStreamRef,
35438
+ WritableStream: streamToStreamRef,
35439
+ TransformStream: streamToStreamRef,
35440
+ StepFunction: serializedStepFunctionToString,
35441
+ Instance: serializedInstanceToRef,
35442
+ Class: serializedClassToString
35443
+ };
35444
+ function hydrateStepIO(resource, revivers) {
35445
+ let hydratedInput = resource.input;
35446
+ let hydratedOutput = resource.output;
35447
+ if (resource.input != null) {
35448
+ try {
35449
+ hydratedInput = hydrateData(resource.input, revivers);
35450
+ } catch {
35451
+ }
35452
+ }
35453
+ if (resource.output != null) {
35454
+ try {
35455
+ hydratedOutput = hydrateData(resource.output, revivers);
35456
+ } catch {
35457
+ }
35458
+ }
35459
+ return { ...resource, input: hydratedInput, output: hydratedOutput };
35460
+ }
35461
+ function hydrateWorkflowIO(resource, revivers) {
35462
+ let hydratedInput = resource.input;
35463
+ let hydratedOutput = resource.output;
35464
+ if (resource.input != null) {
35465
+ try {
35466
+ hydratedInput = hydrateData(resource.input, revivers);
35467
+ } catch {
35468
+ }
35469
+ }
35470
+ if (resource.output != null) {
35471
+ try {
35472
+ hydratedOutput = hydrateData(resource.output, revivers);
35473
+ } catch {
35474
+ }
35475
+ }
35476
+ return { ...resource, input: hydratedInput, output: hydratedOutput };
35477
+ }
35478
+ function hydrateEventData(resource, revivers) {
35479
+ if (!resource.eventData)
35480
+ return resource;
35481
+ const eventData = { ...resource.eventData };
35482
+ if ("result" in eventData && eventData.result != null) {
35483
+ try {
35484
+ eventData.result = hydrateData(eventData.result, revivers);
35485
+ } catch {
35486
+ }
35487
+ }
35488
+ if ("input" in eventData && eventData.input != null) {
35489
+ try {
35490
+ eventData.input = hydrateData(eventData.input, revivers);
35491
+ } catch {
35492
+ }
35493
+ }
35494
+ if ("output" in eventData && eventData.output != null) {
35495
+ try {
35496
+ eventData.output = hydrateData(eventData.output, revivers);
35497
+ } catch {
35498
+ }
35499
+ }
35500
+ if ("metadata" in eventData && eventData.metadata != null) {
35501
+ try {
35502
+ eventData.metadata = hydrateData(eventData.metadata, revivers);
35503
+ } catch {
35504
+ }
35505
+ }
35506
+ if ("payload" in eventData && eventData.payload != null) {
35507
+ try {
35508
+ eventData.payload = hydrateData(eventData.payload, revivers);
35509
+ } catch {
35510
+ }
35511
+ }
35512
+ return { ...resource, eventData };
35513
+ }
35514
+ function hydrateHookMetadata(resource, revivers) {
35515
+ if (resource.metadata == null)
35516
+ return resource;
35517
+ let hydratedMetadata = resource.metadata;
35518
+ try {
35519
+ hydratedMetadata = hydrateData(resource.metadata, revivers);
35520
+ } catch {
35521
+ }
35522
+ return { ...resource, metadata: hydratedMetadata };
35523
+ }
35524
+ function hydrateResourceIO$1(resource, revivers) {
35525
+ if (!resource)
35526
+ return resource;
35527
+ let hydrated;
35528
+ if ("stepId" in resource) {
35529
+ hydrated = hydrateStepIO(resource, revivers);
35530
+ } else if ("hookId" in resource) {
35531
+ hydrated = hydrateHookMetadata(resource, revivers);
35532
+ } else if ("eventId" in resource) {
35533
+ hydrated = hydrateEventData(resource, revivers);
35534
+ } else {
35535
+ hydrated = hydrateWorkflowIO(resource, revivers);
35536
+ }
35537
+ if ("executionContext" in hydrated) {
35538
+ const { executionContext, ...rest } = hydrated;
35539
+ const workflowCoreVersion = executionContext && typeof executionContext === "object" && "workflowCoreVersion" in executionContext ? executionContext.workflowCoreVersion : void 0;
35540
+ if (workflowCoreVersion) {
35541
+ return { ...rest, workflowCoreVersion };
35542
+ }
35543
+ return rest;
35544
+ }
35545
+ return hydrated;
35546
+ }
35547
+ const serializationFormat = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
35548
+ __proto__: null,
35549
+ CLASS_INSTANCE_REF_TYPE: CLASS_INSTANCE_REF_TYPE$1,
35550
+ ClassInstanceRef,
35551
+ STREAM_REF_TYPE: STREAM_REF_TYPE$1,
35552
+ SerializationFormat: SerializationFormat$1,
35553
+ decodeFormatPrefix: decodeFormatPrefix$1,
35554
+ extractClassName,
35555
+ hydrateData,
35556
+ hydrateDataWithKey,
35557
+ hydrateResourceIO: hydrateResourceIO$1,
35558
+ isEncryptedData,
35559
+ observabilityRevivers,
35560
+ serializedClassToString,
35561
+ serializedInstanceToRef,
35562
+ serializedStepFunctionToString,
35563
+ streamToStreamRef
35564
+ }, Symbol.toStringTag, { value: "Module" }));
35565
+ function base64ToArrayBuffer(base642) {
35566
+ if (base642 === "" || base642 === ".") {
35567
+ return new ArrayBuffer(0);
35568
+ }
35569
+ const binaryString = atob(base642);
35570
+ const bytes = new Uint8Array(binaryString.length);
35571
+ for (let i = 0; i < binaryString.length; i++) {
35572
+ bytes[i] = binaryString.charCodeAt(i);
35573
+ }
35574
+ return bytes.buffer;
35575
+ }
35576
+ function getWebRevivers() {
35577
+ function reviveArrayBuffer(value) {
35578
+ return base64ToArrayBuffer(value);
35579
+ }
35580
+ return {
35581
+ // O11y-specific revivers (streams, step functions → display objects).
35582
+ // Spread FIRST so web-specific overrides below take precedence.
35583
+ ...observabilityRevivers,
35584
+ // Binary types
35585
+ ArrayBuffer: reviveArrayBuffer,
35586
+ BigInt: (value) => BigInt(value),
35587
+ BigInt64Array: (value) => new BigInt64Array(reviveArrayBuffer(value)),
35588
+ BigUint64Array: (value) => new BigUint64Array(reviveArrayBuffer(value)),
35589
+ Date: (value) => new Date(value),
35590
+ Error: (value) => {
35591
+ const error2 = new Error(value.message);
35592
+ error2.name = value.name;
35593
+ error2.stack = value.stack;
35594
+ return error2;
35595
+ },
35596
+ Float32Array: (value) => new Float32Array(reviveArrayBuffer(value)),
35597
+ Float64Array: (value) => new Float64Array(reviveArrayBuffer(value)),
35598
+ Int8Array: (value) => new Int8Array(reviveArrayBuffer(value)),
35599
+ Int16Array: (value) => new Int16Array(reviveArrayBuffer(value)),
35600
+ Int32Array: (value) => new Int32Array(reviveArrayBuffer(value)),
35601
+ Map: (value) => new Map(value),
35602
+ RegExp: (value) => new RegExp(value.source, value.flags),
35603
+ Set: (value) => new Set(value),
35604
+ Uint8Array: (value) => new Uint8Array(reviveArrayBuffer(value)),
35605
+ Uint8ClampedArray: (value) => new Uint8ClampedArray(reviveArrayBuffer(value)),
35606
+ Uint16Array: (value) => new Uint16Array(reviveArrayBuffer(value)),
35607
+ Uint32Array: (value) => new Uint32Array(reviveArrayBuffer(value)),
35608
+ Headers: (value) => new Headers(value),
35609
+ URL: (value) => new URL(value),
35610
+ URLSearchParams: (value) => new URLSearchParams(value === "." ? "" : value),
35611
+ // Web-specific overrides for class instances.
35612
+ // Create objects with a dynamically-named constructor so that
35613
+ // react-inspector shows the class name (it reads constructor.name).
35614
+ Class: (value) => `<class:${extractClassName(value.classId)}>`,
35615
+ Instance: (value) => {
35616
+ const className = extractClassName(value.classId);
35617
+ const data = value.data;
35618
+ const props = data && typeof data === "object" ? { ...data } : { value: data };
35619
+ const ctor = { [className]: function() {
35620
+ } }[className];
35621
+ const obj = Object.create(ctor.prototype);
35622
+ Object.assign(obj, props);
35623
+ return obj;
35624
+ }
35625
+ };
35626
+ }
35627
+ let cachedRevivers = null;
35628
+ function getRevivers() {
35629
+ if (!cachedRevivers) {
35630
+ cachedRevivers = getWebRevivers();
35631
+ }
35632
+ return cachedRevivers;
35633
+ }
35634
+ function hydrateResourceIO(resource) {
35635
+ const hydrated = hydrateResourceIO$1(resource, getRevivers());
35636
+ return replaceEncryptedWithMarkers(hydrated);
35637
+ }
35638
+ const ENCRYPTED_DISPLAY_NAME = "Encrypted";
35639
+ function createEncryptedMarker(data) {
35640
+ const ctor = { [ENCRYPTED_DISPLAY_NAME]: function() {
35641
+ } }[ENCRYPTED_DISPLAY_NAME];
35642
+ const obj = Object.create(ctor.prototype);
35643
+ Object.defineProperty(obj, "__encryptedData", {
35644
+ value: data,
35645
+ enumerable: false,
35646
+ configurable: false
35647
+ });
35648
+ return obj;
35649
+ }
35650
+ function isEncryptedMarker(value) {
35651
+ var _a3;
35652
+ return value !== null && typeof value === "object" && ((_a3 = value.constructor) == null ? void 0 : _a3.name) === ENCRYPTED_DISPLAY_NAME;
35653
+ }
35654
+ function replaceEncryptedWithMarkers(resource) {
35655
+ if (!resource || typeof resource !== "object")
35656
+ return resource;
35657
+ const r2 = resource;
35658
+ const result = { ...r2 };
35659
+ for (const key of ["input", "output", "metadata", "error"]) {
35660
+ if (isEncryptedData(result[key])) {
35661
+ result[key] = createEncryptedMarker(result[key]);
35662
+ }
35663
+ }
35664
+ if (result.eventData && typeof result.eventData === "object") {
35665
+ const ed = { ...result.eventData };
35666
+ for (const key of EVENT_DATA_SERIALIZED_FIELDS) {
35667
+ if (isEncryptedData(ed[key])) {
35668
+ ed[key] = createEncryptedMarker(ed[key]);
35669
+ }
35670
+ }
35671
+ result.eventData = ed;
35672
+ }
35673
+ return result;
35674
+ }
35675
+ const EVENT_DATA_SERIALIZED_FIELDS = [
35676
+ "result",
35677
+ "input",
35678
+ "output",
35679
+ "metadata",
35680
+ "payload"
35681
+ ];
35682
+ async function hydrateResourceIOWithKey(resource, key) {
35683
+ const { hydrateDataWithKey: hydrateDataWithKey2 } = await Promise.resolve().then(() => serializationFormat);
35684
+ const { importKey: importKey2 } = await Promise.resolve().then(() => encryption);
35685
+ const cryptoKey = await importKey2(key);
35686
+ const revivers = getRevivers();
35687
+ async function decryptField(value, rev, k2) {
35688
+ if (isEncryptedMarker(value)) {
35689
+ const raw2 = value.__encryptedData;
35690
+ return hydrateDataWithKey2(raw2, rev, k2);
35691
+ }
35692
+ if (value instanceof Uint8Array) {
35693
+ return hydrateDataWithKey2(value, rev, k2);
35694
+ }
35695
+ return value;
35696
+ }
35697
+ const r2 = resource;
35698
+ const result = { ...r2 };
35699
+ for (const field of ["input", "output", "metadata", "error"]) {
35700
+ if (field in result) {
35701
+ result[field] = await decryptField(result[field], revivers, cryptoKey);
35702
+ }
35703
+ }
35704
+ if (result.eventData && typeof result.eventData === "object") {
35705
+ const eventData = { ...result.eventData };
35706
+ for (const field of EVENT_DATA_SERIALIZED_FIELDS) {
35707
+ if (field in eventData) {
35708
+ eventData[field] = await decryptField(eventData[field], revivers, cryptoKey);
35709
+ }
35710
+ }
35711
+ result.eventData = eventData;
35712
+ }
35713
+ return result;
35714
+ }
34731
35715
  const inspectorThemeExtendedLight = {
34732
35716
  OBJECT_VALUE_DATE_COLOR: "#a21caf"
34733
35717
  // fuchsia-700
@@ -34828,13 +35812,13 @@ const inspectorThemeDark = {
34828
35812
  TABLE_TH_HOVER_COLOR: "var(--ds-gray-200)",
34829
35813
  TABLE_SORT_ICON_COLOR: "var(--ds-gray-500)"
34830
35814
  };
34831
- const STREAM_REF_TYPE$1 = "__workflow_stream_ref__";
34832
- const CLASS_INSTANCE_REF_TYPE$1 = "__workflow_class_instance_ref__";
35815
+ const STREAM_REF_TYPE = "__workflow_stream_ref__";
35816
+ const CLASS_INSTANCE_REF_TYPE = "__workflow_class_instance_ref__";
34833
35817
  function isStreamRef(value) {
34834
- return value !== null && typeof value === "object" && "__type" in value && value.__type === STREAM_REF_TYPE$1;
35818
+ return value !== null && typeof value === "object" && "__type" in value && value.__type === STREAM_REF_TYPE;
34835
35819
  }
34836
35820
  function isClassInstanceRef(value) {
34837
- return value !== null && typeof value === "object" && "__type" in value && value.__type === CLASS_INSTANCE_REF_TYPE$1;
35821
+ return value !== null && typeof value === "object" && "__type" in value && value.__type === CLASS_INSTANCE_REF_TYPE;
34838
35822
  }
34839
35823
  const StreamClickContext = reactExports.createContext(void 0);
34840
35824
  function StreamRefInline({ streamRef }) {
@@ -34847,7 +35831,20 @@ function StreamRefInline({ streamRef }) {
34847
35831
  }
34848
35832
  const ExtendedThemeContext = reactExports.createContext(inspectorThemeExtendedLight);
34849
35833
  function NodeRenderer$1({ depth, name: name2, data, isNonenumerable }) {
35834
+ var _a3;
34850
35835
  const extendedTheme = reactExports.useContext(ExtendedThemeContext);
35836
+ if (data !== null && typeof data === "object" && ((_a3 = data.constructor) == null ? void 0 : _a3.name) === ENCRYPTED_DISPLAY_NAME) {
35837
+ const label = jsxRuntimeExports.jsxs("span", { style: { color: "var(--ds-gray-600)", fontStyle: "italic" }, children: [jsxRuntimeExports.jsx(Lock, { className: "h-3 w-3", style: {
35838
+ display: "inline",
35839
+ verticalAlign: "middle",
35840
+ marginRight: "3px",
35841
+ marginTop: "-1px"
35842
+ } }), "Encrypted"] });
35843
+ if (depth === 0) {
35844
+ return label;
35845
+ }
35846
+ return jsxRuntimeExports.jsxs("span", { children: [name2 != null && jsxRuntimeExports.jsx(ObjectName, { name: name2 }), name2 != null && jsxRuntimeExports.jsx("span", { children: ": " }), label] });
35847
+ }
34851
35848
  if (isStreamRef(data)) {
34852
35849
  return jsxRuntimeExports.jsxs("span", { children: [name2 != null && jsxRuntimeExports.jsx(ObjectName, { name: name2 }), name2 != null && jsxRuntimeExports.jsx("span", { children: ": " }), jsxRuntimeExports.jsx(StreamRefInline, { streamRef: data })] });
34853
35850
  }
@@ -34952,7 +35949,7 @@ function isDeepEqual(a2, b2, seen = /* @__PURE__ */ new WeakMap()) {
34952
35949
  if (aKeys.length !== bKeys.length)
34953
35950
  return false;
34954
35951
  for (const key of aKeys) {
34955
- if (!Object.prototype.hasOwnProperty.call(b2, key))
35952
+ if (!Object.hasOwn(b2, key))
34956
35953
  return false;
34957
35954
  if (!isDeepEqual(a2[key], b2[key], seen))
34958
35955
  return false;
@@ -36261,6 +37258,9 @@ function deepParseJson(value) {
36261
37258
  return value.map(deepParseJson);
36262
37259
  }
36263
37260
  if (value !== null && typeof value === "object") {
37261
+ if (value.constructor !== Object) {
37262
+ return value;
37263
+ }
36264
37264
  const result = {};
36265
37265
  for (const [k2, v2] of Object.entries(value)) {
36266
37266
  result[k2] = deepParseJson(v2);
@@ -36318,7 +37318,7 @@ function PayloadBlock({ data, eventType }) {
36318
37318
  }
36319
37319
  return jsxRuntimeExports.jsxs("div", { className: "relative group/payload", children: [jsxRuntimeExports.jsx("div", { className: "overflow-x-auto p-2 text-[11px]", style: { color: "var(--ds-gray-1000)" }, children: jsxRuntimeExports.jsx(DataInspector, { data: cleaned, expandLevel: 2 }) }), jsxRuntimeExports.jsx("button", { type: "button", onClick: handleCopy, className: "absolute bottom-2 right-2 opacity-0 group-hover/payload:opacity-100 transition-opacity flex items-center gap-1 px-2 py-1 rounded-md text-xs hover:bg-[var(--ds-gray-alpha-200)]", style: { ...BUTTON_RESET_STYLE, color: "var(--ds-gray-700)" }, "aria-label": "Copy payload", children: copied ? jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(Check, { className: "h-3 w-3", style: { color: "var(--ds-green-700)" } }), jsxRuntimeExports.jsx("span", { style: { color: "var(--ds-green-700)" }, children: "Copied" })] }) : jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(Copy, { className: "h-3 w-3" }), jsxRuntimeExports.jsx("span", { children: "Copy" })] }) })] });
36320
37320
  }
36321
- function EventRow({ event, index: index2, isFirst, isLast, activeGroupKey, selectedGroupKey, selectedGroupRange, correlationNameMap, workflowName, durationMap, onSelectGroup, onHoverGroup, onLoadEventData }) {
37321
+ function EventRow({ event, index: index2, isFirst, isLast, activeGroupKey, selectedGroupKey, selectedGroupRange, correlationNameMap, workflowName, durationMap, onSelectGroup, onHoverGroup, onLoadEventData, encryptionKey }) {
36322
37322
  const [isExpanded, setIsExpanded] = reactExports.useState(false);
36323
37323
  const [isLoading, setIsLoading] = reactExports.useState(false);
36324
37324
  const [loadedEventData, setLoadedEventData] = reactExports.useState(null);
@@ -36367,6 +37367,20 @@ function EventRow({ event, index: index2, isFirst, isLast, activeGroupKey, selec
36367
37367
  setHasAttemptedLoad(true);
36368
37368
  }
36369
37369
  }, [event, loadedEventData, hasExistingEventData, onLoadEventData]);
37370
+ reactExports.useEffect(() => {
37371
+ if (encryptionKey && hasAttemptedLoad && onLoadEventData) {
37372
+ setLoadedEventData(null);
37373
+ setHasAttemptedLoad(false);
37374
+ onLoadEventData(event).then((data) => {
37375
+ if (data !== null && data !== void 0) {
37376
+ setLoadedEventData(data);
37377
+ }
37378
+ setHasAttemptedLoad(true);
37379
+ }).catch(() => {
37380
+ setHasAttemptedLoad(true);
37381
+ });
37382
+ }
37383
+ }, [encryptionKey]);
36370
37384
  const handleExpandToggle = reactExports.useCallback((e) => {
36371
37385
  e.stopPropagation();
36372
37386
  const newExpanded = !isExpanded;
@@ -36422,7 +37436,7 @@ function EventRow({ event, index: index2, isFirst, isLast, activeGroupKey, selec
36422
37436
  color: "var(--ds-red-900)"
36423
37437
  }, children: loadError }) : isLoading || !hasExistingEventData && !hasAttemptedLoad && event.correlationId ? jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2 p-3", children: [jsxRuntimeExports.jsx(Skeleton$2, { className: "h-3", style: { width: "75%" } }), jsxRuntimeExports.jsx(Skeleton$2, { className: "h-3", style: { width: "50%" } }), jsxRuntimeExports.jsx(Skeleton$2, { className: "h-3", style: { width: "60%" } })] }) : jsxRuntimeExports.jsx("div", { className: "p-2 text-xs", style: { color: "var(--ds-gray-900)" }, children: "No data" })] })] })] });
36424
37438
  }
36425
- function EventListView({ events: events2, steps, run, onLoadEventData, hasMoreEvents = false, isLoadingMoreEvents = false, onLoadMoreEvents }) {
37439
+ function EventListView({ events: events2, steps, run, onLoadEventData, hasMoreEvents = false, isLoadingMoreEvents = false, onLoadMoreEvents, encryptionKey }) {
36426
37440
  const sortedEvents2 = reactExports.useMemo(() => {
36427
37441
  if (!events2 || events2.length === 0)
36428
37442
  return [];
@@ -36524,7 +37538,7 @@ function EventListView({ events: events2, steps, run, onLoadEventData, hasMoreEv
36524
37538
  }
36525
37539
  void (onLoadMoreEvents == null ? void 0 : onLoadMoreEvents());
36526
37540
  }, itemContent: (index2) => {
36527
- return jsxRuntimeExports.jsx(EventRow, { event: sortedEvents2[index2], index: index2, isFirst: index2 === 0, isLast: index2 === sortedEvents2.length - 1, activeGroupKey, selectedGroupKey, selectedGroupRange, correlationNameMap, workflowName, durationMap, onSelectGroup, onHoverGroup, onLoadEventData });
37541
+ return jsxRuntimeExports.jsx(EventRow, { event: sortedEvents2[index2], index: index2, isFirst: index2 === 0, isLast: index2 === sortedEvents2.length - 1, activeGroupKey, selectedGroupKey, selectedGroupRange, correlationNameMap, workflowName, durationMap, onSelectGroup, onHoverGroup, onLoadEventData, encryptionKey });
36528
37542
  }, components: {
36529
37543
  Footer: () => jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [hasMoreEvents && jsxRuntimeExports.jsx("div", { className: "px-3 pt-3 flex justify-center", children: jsxRuntimeExports.jsx("button", { type: "button", onClick: () => void (onLoadMoreEvents == null ? void 0 : onLoadMoreEvents()), disabled: isLoadingMoreEvents, className: "h-8 px-3 text-xs rounded-md border transition-colors disabled:opacity-60 disabled:cursor-not-allowed", style: {
36530
37544
  borderColor: "var(--ds-gray-alpha-400)",
@@ -38649,7 +39663,7 @@ function camelcase$1($0) {
38649
39663
  }
38650
39664
  const html$4 = merge$2([aria$2, html$5, xlink$1, xmlns$1, xml$1], "html");
38651
39665
  const svg$2 = merge$2([aria$2, svg$3, xlink$1, xmlns$1, xml$1], "svg");
38652
- function parse$7(value) {
39666
+ function parse$6(value) {
38653
39667
  const tokens = [];
38654
39668
  const input = String(value || "");
38655
39669
  let index2 = input.indexOf(",");
@@ -38669,7 +39683,7 @@ function parse$7(value) {
38669
39683
  }
38670
39684
  return tokens;
38671
39685
  }
38672
- function stringify$2(values, options) {
39686
+ function stringify$1(values, options) {
38673
39687
  const settings = {};
38674
39688
  const input = values[values.length - 1] === "" ? [...values, ""] : values;
38675
39689
  return input.join(
@@ -38712,11 +39726,11 @@ function parseSelector(selector2, defaultTagName) {
38712
39726
  children: []
38713
39727
  };
38714
39728
  }
38715
- function parse$6(value) {
39729
+ function parse$5(value) {
38716
39730
  const input = String(value || "").trim();
38717
39731
  return input ? input.split(/[ \t\n\r\f]+/g) : [];
38718
39732
  }
38719
- function stringify$1(values) {
39733
+ function stringify(values) {
38720
39734
  return values.join(" ").trim();
38721
39735
  }
38722
39736
  function createH(schema, defaultTagName, caseSensitive) {
@@ -38795,11 +39809,11 @@ function addProperty(schema, properties2, key, value) {
38795
39809
  result = value;
38796
39810
  } else if (typeof value === "string") {
38797
39811
  if (info.spaceSeparated) {
38798
- result = parse$6(value);
39812
+ result = parse$5(value);
38799
39813
  } else if (info.commaSeparated) {
38800
- result = parse$7(value);
39814
+ result = parse$6(value);
38801
39815
  } else if (info.commaOrSpaceSeparated) {
38802
- result = parse$6(parse$7(value).join(" "));
39816
+ result = parse$5(parse$6(value).join(" "));
38803
39817
  } else {
38804
39818
  result = parsePrimitive(info, info.property, value);
38805
39819
  }
@@ -40434,7 +41448,7 @@ function createProperty$1(schema, prop, value) {
40434
41448
  return;
40435
41449
  }
40436
41450
  if (Array.isArray(value)) {
40437
- value = info.commaSeparated ? stringify$2(value) : stringify$1(value);
41451
+ value = info.commaSeparated ? stringify$1(value) : stringify(value);
40438
41452
  }
40439
41453
  const attribute = {
40440
41454
  name: info.attribute,
@@ -58368,7 +59382,7 @@ function createProperty(state, prop, value) {
58368
59382
  return;
58369
59383
  }
58370
59384
  if (Array.isArray(value)) {
58371
- value = info.commaSeparated ? stringify$2(value) : stringify$1(value);
59385
+ value = info.commaSeparated ? stringify$1(value) : stringify(value);
58372
59386
  }
58373
59387
  if (info.property === "style") {
58374
59388
  let styleObject = typeof value === "object" ? value : parseStyle(state, String(value));
@@ -59281,7 +60295,7 @@ function serializeChunks(chunks, expandTabs) {
59281
60295
  }
59282
60296
  return result.join("");
59283
60297
  }
59284
- function parse$5(options) {
60298
+ function parse$4(options) {
59285
60299
  const settings = options || {};
59286
60300
  const constructs2 = (
59287
60301
  /** @type {FullNormalizedExtension} */
@@ -59393,7 +60407,7 @@ function fromMarkdown(value, encoding2, options) {
59393
60407
  options = encoding2;
59394
60408
  encoding2 = void 0;
59395
60409
  }
59396
- return compiler(options)(postprocess(parse$5(options).document().write(preprocess$1()(value, encoding2, true))));
60410
+ return compiler(options)(postprocess(parse$4(options).document().write(preprocess$1()(value, encoding2, true))));
59397
60411
  }
59398
60412
  function compiler(options) {
59399
60413
  const config2 = {
@@ -63410,7 +64424,7 @@ var tn = f("block", "before:content-[counter(line)]", "before:inline-block", "be
63410
64424
  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 });
63411
64425
  var Se = reactExports.createContext({ code: "" }), de$1 = () => reactExports.useContext(Se);
63412
64426
  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 }) });
63413
- var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-CzB1YMLj.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
64427
+ var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-DoOhy3wX.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
63414
64428
  let i = reactExports.useMemo(() => e.replace(cn$1, ""), [e]), c = reactExports.useMemo(() => ({ bg: "transparent", fg: "inherit", tokens: i.split(`
63415
64429
  `).map((a2) => [{ content: a2, color: "inherit", bgColor: "transparent", htmlStyle: {}, offset: 0 }]) }), [i]);
63416
64430
  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 }) })] }) });
@@ -63732,7 +64746,7 @@ var Dt = ({ children: e, className: t, onDownload: o, onError: n }) => {
63732
64746
  }, []), jsxRuntimeExports.jsxs("div", { className: "relative", ref: i, children: [jsxRuntimeExports.jsx("button", { className: f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50", t), disabled: c, onClick: () => r2(!s2), title: "Download table", type: "button", children: e != null ? e : jsxRuntimeExports.jsx(Z, { size: 14 }) }), s2 ? jsxRuntimeExports.jsxs("div", { className: "absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg", children: [jsxRuntimeExports.jsx("button", { className: "w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40", onClick: () => a2("csv"), title: "Download table as CSV", type: "button", children: "CSV" }), jsxRuntimeExports.jsx("button", { className: "w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40", onClick: () => a2("markdown"), title: "Download table as Markdown", type: "button", children: "Markdown" })] }) : null] });
63733
64747
  };
63734
64748
  var Vt = ({ children: e, className: t, showControls: o, ...n }) => jsxRuntimeExports.jsxs("div", { className: "my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2", "data-streamdown": "table-wrapper", children: [o ? jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-end gap-1", children: [jsxRuntimeExports.jsx(Ht, {}), jsxRuntimeExports.jsx(Dt, {})] }) : null, jsxRuntimeExports.jsx("div", { className: "border-collapse overflow-x-auto overscroll-y-auto rounded-md border border-border bg-background", children: jsxRuntimeExports.jsx("table", { className: f("w-full divide-y divide-border", t), "data-streamdown": "table", ...n, children: e }) })] });
63735
- var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-Dqygs4_q.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
64749
+ var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-uuxw6-ur.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
63736
64750
  function ke(e, t) {
63737
64751
  if (!(e != null && e.position || t != null && t.position)) return true;
63738
64752
  if (!(e != null && e.position && (t != null && t.position))) return false;
@@ -64358,6 +65372,13 @@ function ConversationWithTabs({ conversation, args }) {
64358
65372
  const [activeTab, setActiveTab] = reactExports.useState("conversation");
64359
65373
  return jsxRuntimeExports.jsx(DetailCard, { summary: `Input (${conversation.length} messages)`, children: jsxRuntimeExports.jsx(TabbedContainer, { tabs: conversationTabs, activeTab, onTabChange: setActiveTab, ariaLabel: "Conversation view", children: activeTab === "conversation" ? jsxRuntimeExports.jsx(ConversationView, { messages: conversation }) : jsxRuntimeExports.jsx("div", { className: "p-3", children: Array.isArray(args) ? args.map((v2, i) => jsxRuntimeExports.jsx("div", { className: "mt-2 first:mt-0", children: JsonBlock(v2) }, i)) : JsonBlock(args) }) }) });
64360
65374
  }
65375
+ function EncryptedFieldBlock() {
65376
+ return jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1.5 rounded-md border px-3 py-2 text-xs", style: {
65377
+ borderColor: "var(--ds-gray-300)",
65378
+ backgroundColor: "var(--ds-gray-100)",
65379
+ color: "var(--ds-gray-700)"
65380
+ }, children: [jsxRuntimeExports.jsx(Lock, { className: "h-3 w-3" }), jsxRuntimeExports.jsx("span", { className: "font-medium", children: "Encrypted" })] });
65381
+ }
64361
65382
  function JsonBlock(value) {
64362
65383
  return jsxRuntimeExports.jsx(CopyableDataBlock, { data: value });
64363
65384
  }
@@ -64428,26 +65449,41 @@ const getModuleSpecifierFromName = (value) => {
64428
65449
  }
64429
65450
  return raw2;
64430
65451
  };
64431
- const localMillisecondTime = (value) => {
64432
- let date2;
65452
+ const parseDateValue = (value) => {
65453
+ if (value == null) {
65454
+ return null;
65455
+ }
64433
65456
  if (value instanceof Date) {
64434
- date2 = value;
64435
- } else if (typeof value === "number") {
64436
- date2 = new Date(value);
64437
- } else if (typeof value === "string") {
64438
- date2 = new Date(value);
64439
- } else {
64440
- date2 = new Date(String(value));
65457
+ return Number.isNaN(value.getTime()) ? null : value;
64441
65458
  }
64442
- return date2.toLocaleString(void 0, {
64443
- year: "numeric",
64444
- month: "numeric",
64445
- day: "numeric",
64446
- hour: "numeric",
64447
- minute: "numeric",
64448
- second: "numeric",
64449
- fractionalSecondDigits: 3
64450
- });
65459
+ if (typeof value === "string" && value.trim().length === 0) {
65460
+ return null;
65461
+ }
65462
+ const date2 = typeof value === "number" ? new Date(value) : new Date(String(value));
65463
+ return Number.isNaN(date2.getTime()) ? null : date2;
65464
+ };
65465
+ const formatLocalMillisecondTime = (date2) => date2.toLocaleString(void 0, {
65466
+ year: "numeric",
65467
+ month: "numeric",
65468
+ day: "numeric",
65469
+ hour: "numeric",
65470
+ minute: "numeric",
65471
+ second: "numeric",
65472
+ fractionalSecondDigits: 3
65473
+ });
65474
+ const localMillisecondTime = (value) => {
65475
+ const date2 = parseDateValue(value);
65476
+ if (!date2) {
65477
+ return "-";
65478
+ }
65479
+ return formatLocalMillisecondTime(date2);
65480
+ };
65481
+ const localMillisecondTimeOrNull = (value) => {
65482
+ const date2 = parseDateValue(value);
65483
+ if (!date2) {
65484
+ return null;
65485
+ }
65486
+ return formatLocalMillisecondTime(date2);
64451
65487
  };
64452
65488
  const attributeToDisplayFn = {
64453
65489
  // Names that need pretty-printing
@@ -64470,6 +65506,7 @@ const attributeToDisplayFn = {
64470
65506
  attempt: (value) => String(value),
64471
65507
  // Hook details
64472
65508
  token: (value) => String(value),
65509
+ isWebhook: (value) => String(value),
64473
65510
  // Event details
64474
65511
  eventType: (value) => String(value),
64475
65512
  correlationId: (value) => String(value),
@@ -64484,20 +65521,24 @@ const attributeToDisplayFn = {
64484
65521
  executionContext: (_value) => null,
64485
65522
  // Dates
64486
65523
  // TODO: relative time with tooltips for ISO times
64487
- createdAt: localMillisecondTime,
64488
- startedAt: localMillisecondTime,
64489
- updatedAt: localMillisecondTime,
64490
- completedAt: localMillisecondTime,
64491
- expiredAt: localMillisecondTime,
64492
- retryAfter: localMillisecondTime,
64493
- resumeAt: localMillisecondTime,
65524
+ createdAt: localMillisecondTimeOrNull,
65525
+ startedAt: localMillisecondTimeOrNull,
65526
+ updatedAt: localMillisecondTimeOrNull,
65527
+ completedAt: localMillisecondTimeOrNull,
65528
+ expiredAt: localMillisecondTimeOrNull,
65529
+ retryAfter: localMillisecondTimeOrNull,
65530
+ resumeAt: localMillisecondTimeOrNull,
64494
65531
  // Resolved attributes, won't actually use this function
64495
65532
  metadata: (value) => {
64496
65533
  if (!hasDisplayContent(value))
64497
65534
  return null;
65535
+ if (isEncryptedMarker(value))
65536
+ return jsxRuntimeExports.jsx(EncryptedFieldBlock, {});
64498
65537
  return JsonBlock(value);
64499
65538
  },
64500
65539
  input: (value, context) => {
65540
+ if (isEncryptedMarker(value))
65541
+ return jsxRuntimeExports.jsx(EncryptedFieldBlock, {});
64501
65542
  if (value && typeof value === "object" && "args" in value) {
64502
65543
  const { args, closureVars, thisVal } = value;
64503
65544
  const argCount2 = Array.isArray(args) ? args.length : 0;
@@ -64526,9 +65567,13 @@ const attributeToDisplayFn = {
64526
65567
  output: (value) => {
64527
65568
  if (!hasDisplayContent(value))
64528
65569
  return null;
65570
+ if (isEncryptedMarker(value))
65571
+ return jsxRuntimeExports.jsx(EncryptedFieldBlock, {});
64529
65572
  return jsxRuntimeExports.jsx(DetailCard, { summary: "Output", summaryClassName: "text-base py-2", contentClassName: "mt-0", children: JsonBlock(value) });
64530
65573
  },
64531
65574
  error: (value) => {
65575
+ if (isEncryptedMarker(value))
65576
+ return jsxRuntimeExports.jsx(EncryptedFieldBlock, {});
64532
65577
  if (!hasDisplayContent(value))
64533
65578
  return null;
64534
65579
  if (isStructuredErrorWithStack(value)) {
@@ -64537,6 +65582,8 @@ const attributeToDisplayFn = {
64537
65582
  return jsxRuntimeExports.jsx(DetailCard, { summary: "Error", summaryClassName: "text-base py-2", contentClassName: "mt-0", children: JsonBlock(value) });
64538
65583
  },
64539
65584
  eventData: (value) => {
65585
+ if (isEncryptedMarker(value))
65586
+ return jsxRuntimeExports.jsx(EncryptedFieldBlock, {});
64540
65587
  if (!hasDisplayContent(value))
64541
65588
  return null;
64542
65589
  return jsxRuntimeExports.jsx(DetailCard, { summary: "Event Data", children: JsonBlock(value) });
@@ -64643,7 +65690,7 @@ const AttributePanel = ({ data, moduleSpecifier, isLoading, error: error2, expir
64643
65690
  border: "none",
64644
65691
  padding: 0
64645
65692
  }, title: moduleSpecifierValue, onClick: () => handleCopyModuleSpecifier(moduleSpecifierValue), children: moduleSpecifierValue }) : jsxRuntimeExports.jsx("span", { className: "min-w-0 max-w-[70%] truncate text-right text-[13px] font-mono", style: { color: "var(--ds-gray-1000)" }, children: displayValue })] }), showDivider ? jsxRuntimeExports.jsx("div", { className: "mx-2.5 border-b", style: { borderColor: "var(--ds-gray-300)" } }) : null] }, attribute);
64646
- }) }), error2 ? jsxRuntimeExports.jsx(ErrorCard, { title: "Failed to load resource details", details: error2.message, className: "my-4" }) : hasExpired ? jsxRuntimeExports.jsx(ExpiredDataMessage, {}) : resolvedAttributes.map((attribute) => jsxRuntimeExports.jsx(AttributeBlock, { isLoading, attribute, value: displayData[attribute], context: displayContext }, attribute))] }) });
65693
+ }) }), error2 ? jsxRuntimeExports.jsx(ErrorCard, { title: "Failed to load resource details", details: error2.message, className: "my-4" }) : hasExpired ? jsxRuntimeExports.jsx(ExpiredDataMessage, {}) : jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: resolvedAttributes.map((attribute) => jsxRuntimeExports.jsx(AttributeBlock, { isLoading, attribute, value: displayData[attribute], context: displayContext }, attribute)) })] }) });
64647
65694
  };
64648
65695
  const ERROR_EVENT_TYPES = /* @__PURE__ */ new Set(["step_failed", "step_retrying"]);
64649
65696
  const DATA_EVENT_TYPES = /* @__PURE__ */ new Set([
@@ -64655,16 +65702,15 @@ const DATA_EVENT_TYPES = /* @__PURE__ */ new Set([
64655
65702
  "run_created",
64656
65703
  "run_completed"
64657
65704
  ]);
64658
- function EventItem({ event, onLoadEventData }) {
65705
+ function EventItem({ event, onLoadEventData, encryptionKey }) {
64659
65706
  const [loadedData, setLoadedData] = reactExports.useState(null);
64660
65707
  const [isLoading, setIsLoading] = reactExports.useState(false);
64661
65708
  const [loadError, setLoadError] = reactExports.useState(null);
65709
+ const wasExpandedRef = reactExports.useRef(false);
64662
65710
  const existingData = "eventData" in event && event.eventData != null ? event.eventData : null;
64663
65711
  const displayData = existingData ?? loadedData;
64664
65712
  const canHaveData = DATA_EVENT_TYPES.has(event.eventType);
64665
- const handleExpand = reactExports.useCallback(async () => {
64666
- if (existingData || loadedData !== null || isLoading)
64667
- return;
65713
+ const loadEventData = reactExports.useCallback(async () => {
64668
65714
  if (!onLoadEventData || !event.correlationId || !event.eventId)
64669
65715
  return;
64670
65716
  try {
@@ -64677,14 +65723,19 @@ function EventItem({ event, onLoadEventData }) {
64677
65723
  } finally {
64678
65724
  setIsLoading(false);
64679
65725
  }
64680
- }, [
64681
- existingData,
64682
- loadedData,
64683
- isLoading,
64684
- onLoadEventData,
64685
- event.correlationId,
64686
- event.eventId
64687
- ]);
65726
+ }, [onLoadEventData, event.correlationId, event.eventId]);
65727
+ const handleExpand = reactExports.useCallback(async () => {
65728
+ if (existingData || loadedData !== null || isLoading)
65729
+ return;
65730
+ wasExpandedRef.current = true;
65731
+ await loadEventData();
65732
+ }, [existingData, loadedData, isLoading, loadEventData]);
65733
+ reactExports.useEffect(() => {
65734
+ if (encryptionKey && wasExpandedRef.current && loadedData !== null) {
65735
+ setLoadedData(null);
65736
+ loadEventData();
65737
+ }
65738
+ }, [encryptionKey]);
64688
65739
  const createdAt = new Date(event.createdAt);
64689
65740
  return jsxRuntimeExports.jsxs(DetailCard, { summaryClassName: "text-base py-2", summary: jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("span", { className: "font-medium", style: { color: "var(--ds-gray-1000)" }, children: event.eventType }), " ", "-", " ", jsxRuntimeExports.jsx("span", { style: { color: "var(--ds-gray-700)" }, children: localMillisecondTime(createdAt.getTime()) })] }), onToggle: canHaveData ? (open) => {
64690
65741
  if (open)
@@ -64711,9 +65762,9 @@ function EventDataBlock({ eventType, data }) {
64711
65762
  }
64712
65763
  return jsxRuntimeExports.jsx(CopyableDataBlock, { data });
64713
65764
  }
64714
- function EventsList({ events: events2, isLoading = false, error: error2, onLoadEventData }) {
65765
+ function EventsList({ events: events2, isLoading = false, error: error2, onLoadEventData, encryptionKey }) {
64715
65766
  const sortedEvents2 = reactExports.useMemo(() => [...events2].sort((a2, b2) => new Date(a2.createdAt).getTime() - new Date(b2.createdAt).getTime()), [events2]);
64716
- return jsxRuntimeExports.jsxs("div", { className: "mt-2", style: { color: "var(--ds-gray-1000)" }, children: [jsxRuntimeExports.jsxs("h3", { className: "text-heading-16 font-medium mt-4 mb-2", style: { color: "var(--ds-gray-1000)" }, children: ["Events ", !isLoading && `(${sortedEvents2.length})`] }), isLoading ? jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-3", children: [jsxRuntimeExports.jsx(Skeleton$2, { className: "h-[48px] w-full rounded-lg border" }), jsxRuntimeExports.jsx(Skeleton$2, { className: "h-[48px] w-full rounded-lg border" }), jsxRuntimeExports.jsx(Skeleton$2, { className: "h-[48px] w-full rounded-lg border" })] }) : null, !isLoading && !error2 && sortedEvents2.length === 0 && jsxRuntimeExports.jsx("div", { className: "text-sm", children: "No events found" }), sortedEvents2.length > 0 && !error2 ? jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-4", children: sortedEvents2.map((event) => jsxRuntimeExports.jsx(EventItem, { event, onLoadEventData }, event.eventId)) }) : null] });
65767
+ return jsxRuntimeExports.jsxs("div", { className: "mt-2", style: { color: "var(--ds-gray-1000)" }, children: [jsxRuntimeExports.jsxs("h3", { className: "text-heading-16 font-medium mt-4 mb-2", style: { color: "var(--ds-gray-1000)" }, children: ["Events ", !isLoading && `(${sortedEvents2.length})`] }), isLoading ? jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-3", children: [jsxRuntimeExports.jsx(Skeleton$2, { className: "h-[48px] w-full rounded-lg border" }), jsxRuntimeExports.jsx(Skeleton$2, { className: "h-[48px] w-full rounded-lg border" }), jsxRuntimeExports.jsx(Skeleton$2, { className: "h-[48px] w-full rounded-lg border" })] }) : null, !isLoading && !error2 && sortedEvents2.length === 0 && jsxRuntimeExports.jsx("div", { className: "text-sm", children: "No events found" }), sortedEvents2.length > 0 && !error2 ? jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-4", children: sortedEvents2.map((event) => jsxRuntimeExports.jsx(EventItem, { event, onLoadEventData, encryptionKey }, event.eventId)) }) : null] });
64717
65768
  }
64718
65769
  function isStep(data) {
64719
65770
  return data !== null && typeof data === "object" && "stepId" in data;
@@ -64724,7 +65775,7 @@ function isWorkflowRun(data) {
64724
65775
  function isHook(data) {
64725
65776
  return data !== null && typeof data === "object" && "hookId" in data;
64726
65777
  }
64727
- function EntityDetailPanel({ run, hooks, onStreamClick, spanDetailData, spanDetailError, spanDetailLoading, onSpanSelect, onWakeUpSleep, onLoadEventData, onResolveHook, selectedSpan }) {
65778
+ function EntityDetailPanel({ run, hooks, onStreamClick, spanDetailData, spanDetailError, spanDetailLoading, onSpanSelect, onWakeUpSleep, onLoadEventData, onResolveHook, encryptionKey, selectedSpan }) {
64728
65779
  const [stoppingSleep, setStoppingSleep] = reactExports.useState(false);
64729
65780
  const [showResolveHookModal, setShowResolveHookModal] = reactExports.useState(false);
64730
65781
  const [resolvingHook, setResolvingHook] = reactExports.useState(false);
@@ -64923,7 +65974,7 @@ function EntityDetailPanel({ run, hooks, onStreamClick, spanDetailData, spanDeta
64923
65974
  }, children: [jsxRuntimeExports.jsx(Zap, { className: "h-4 w-4" }), stoppingSleep ? "Waking up..." : "Wake Up Sleep"] }), resource === "hook" && canResolveHook && jsxRuntimeExports.jsxs("button", { type: "button", onClick: () => setShowResolveHookModal(true), disabled: resolvingHook, className: clsx("flex items-center justify-center gap-2 rounded-md px-3 py-2 text-sm font-medium", "disabled:opacity-50 disabled:cursor-not-allowed transition-colors", resolvingHook ? "opacity-50 cursor-not-allowed" : "cursor-pointer"), style: {
64924
65975
  background: "var(--ds-gray-1000)",
64925
65976
  color: "var(--ds-background-100)"
64926
- }, children: [jsxRuntimeExports.jsx(Send, { className: "h-4 w-4" }), "Resolve Hook"] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("section", { children: [jsxRuntimeExports.jsx("h3", { className: "mb-2 text-[13px] font-medium uppercase tracking-wide", style: { color: "var(--ds-gray-700)" }, children: "Details" }), jsxRuntimeExports.jsx(AttributePanel, { data: displayData, moduleSpecifier, expiredAt: run.expiredAt, isLoading: loading, error: error2 ?? void 0, onStreamClick })] }), resource !== "run" && rawEvents && jsxRuntimeExports.jsx("section", { children: jsxRuntimeExports.jsx(EventsList, { events: rawEvents, onLoadEventData }) })] })] }), jsxRuntimeExports.jsx(ResolveHookModal, { isOpen: showResolveHookModal, onClose: () => setShowResolveHookModal(false), onSubmit: handleResolveHook, isSubmitting: resolvingHook })] });
65977
+ }, children: [jsxRuntimeExports.jsx(Send, { className: "h-4 w-4" }), "Resolve Hook"] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("section", { children: [jsxRuntimeExports.jsx("h3", { className: "mb-2 text-[13px] font-medium uppercase tracking-wide", style: { color: "var(--ds-gray-700)" }, children: "Details" }), jsxRuntimeExports.jsx(AttributePanel, { data: displayData, moduleSpecifier, expiredAt: run.expiredAt, isLoading: loading, error: error2 ?? void 0, onStreamClick })] }), resource !== "run" && rawEvents && jsxRuntimeExports.jsx("section", { children: jsxRuntimeExports.jsx(EventsList, { events: rawEvents, onLoadEventData, encryptionKey }) })] })] }), jsxRuntimeExports.jsx(ResolveHookModal, { isOpen: showResolveHookModal, onClose: () => setShowResolveHookModal(false), onSubmit: handleResolveHook, isSubmitting: resolvingHook })] });
64927
65978
  }
64928
65979
  const SEARCH_HEIGHT = 40;
64929
65980
  const SEARCH_GAP = 8;
@@ -68709,7 +69760,7 @@ function PanelResizeHandle({ onResize }) {
68709
69760
  }, [onResize]);
68710
69761
  return jsxRuntimeExports.jsx("div", { className: "absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-blue-400/50 z-10", onPointerDown: handlePointerDown });
68711
69762
  }
68712
- const WorkflowTraceViewer = ({ run, steps, hooks, events: events2, isLoading, error: error2, spanDetailData, spanDetailLoading, spanDetailError, onWakeUpSleep, onResolveHook, onCancelRun, onStreamClick, onSpanSelect, onLoadEventData, onLoadMoreSpans, hasMoreSpans = false, isLoadingMoreSpans = false }) => {
69763
+ const WorkflowTraceViewer = ({ run, steps, hooks, events: events2, isLoading, error: error2, spanDetailData, spanDetailLoading, spanDetailError, onWakeUpSleep, onResolveHook, onCancelRun, onStreamClick, onSpanSelect, onLoadEventData, onLoadMoreSpans, hasMoreSpans = false, isLoadingMoreSpans = false, encryptionKey }) => {
68713
69764
  const [selectedSpan, setSelectedSpan] = reactExports.useState(null);
68714
69765
  const [panelWidth, setPanelWidth] = reactExports.useState(DEFAULT_PANEL_WIDTH);
68715
69766
  const [deselectTrigger, setDeselectTrigger] = reactExports.useState(0);
@@ -68878,7 +69929,7 @@ const WorkflowTraceViewer = ({ run, steps, hooks, events: events2, isLoading, er
68878
69929
  e.currentTarget.style.background = "var(--ds-gray-alpha-100)";
68879
69930
  }, onMouseLeave: (e) => {
68880
69931
  e.currentTarget.style.background = "transparent";
68881
- }, children: jsxRuntimeExports.jsx(X$3, { size: 16 }) }) })] }), jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-y-auto", children: jsxRuntimeExports.jsx(ErrorBoundary, { title: "Failed to load entity details", children: jsxRuntimeExports.jsx(EntityDetailPanel, { run, hooks, onStreamClick, spanDetailData: spanDetailData ?? null, spanDetailError, spanDetailLoading, onSpanSelect: handleSpanSelect, onWakeUpSleep, onLoadEventData, onResolveHook, selectedSpan }) }) })] })] });
69932
+ }, children: jsxRuntimeExports.jsx(X$3, { size: 16 }) }) })] }), jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-y-auto", children: jsxRuntimeExports.jsx(ErrorBoundary, { title: "Failed to load entity details", children: jsxRuntimeExports.jsx(EntityDetailPanel, { run, hooks, onStreamClick, spanDetailData: spanDetailData ?? null, spanDetailError, spanDetailLoading, onSpanSelect: handleSpanSelect, onWakeUpSleep, onLoadEventData, onResolveHook, encryptionKey, selectedSpan }) }) })] })] });
68882
69933
  };
68883
69934
  function deserializeChunkText(text2) {
68884
69935
  try {
@@ -69014,851 +70065,6 @@ function analyzeEvents(events2) {
69014
70065
  lastStepCompletionAt
69015
70066
  };
69016
70067
  }
69017
- class DevalueError extends Error {
69018
- /**
69019
- * @param {string} message
69020
- * @param {string[]} keys
69021
- * @param {any} [value] - The value that failed to be serialized
69022
- * @param {any} [root] - The root value being serialized
69023
- */
69024
- constructor(message2, keys2, value, root2) {
69025
- super(message2);
69026
- this.name = "DevalueError";
69027
- this.path = keys2.join("");
69028
- this.value = value;
69029
- this.root = root2;
69030
- }
69031
- }
69032
- function is_primitive(thing) {
69033
- return Object(thing) !== thing;
69034
- }
69035
- const object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(
69036
- Object.prototype
69037
- ).sort().join("\0");
69038
- function is_plain_object(thing) {
69039
- const proto2 = Object.getPrototypeOf(thing);
69040
- return proto2 === Object.prototype || proto2 === null || Object.getPrototypeOf(proto2) === null || Object.getOwnPropertyNames(proto2).sort().join("\0") === object_proto_names;
69041
- }
69042
- function get_type(thing) {
69043
- return Object.prototype.toString.call(thing).slice(8, -1);
69044
- }
69045
- function get_escaped_char(char) {
69046
- switch (char) {
69047
- case '"':
69048
- return '\\"';
69049
- case "<":
69050
- return "\\u003C";
69051
- case "\\":
69052
- return "\\\\";
69053
- case "\n":
69054
- return "\\n";
69055
- case "\r":
69056
- return "\\r";
69057
- case " ":
69058
- return "\\t";
69059
- case "\b":
69060
- return "\\b";
69061
- case "\f":
69062
- return "\\f";
69063
- case "\u2028":
69064
- return "\\u2028";
69065
- case "\u2029":
69066
- return "\\u2029";
69067
- default:
69068
- return char < " " ? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}` : "";
69069
- }
69070
- }
69071
- function stringify_string(str) {
69072
- let result = "";
69073
- let last_pos = 0;
69074
- const len = str.length;
69075
- for (let i = 0; i < len; i += 1) {
69076
- const char = str[i];
69077
- const replacement = get_escaped_char(char);
69078
- if (replacement) {
69079
- result += str.slice(last_pos, i) + replacement;
69080
- last_pos = i + 1;
69081
- }
69082
- }
69083
- return `"${last_pos === 0 ? str : result + str.slice(last_pos)}"`;
69084
- }
69085
- function enumerable_symbols(object2) {
69086
- return Object.getOwnPropertySymbols(object2).filter(
69087
- (symbol2) => Object.getOwnPropertyDescriptor(object2, symbol2).enumerable
69088
- );
69089
- }
69090
- const is_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;
69091
- function stringify_key(key) {
69092
- return is_identifier.test(key) ? "." + key : "[" + JSON.stringify(key) + "]";
69093
- }
69094
- function is_valid_array_index(s2) {
69095
- if (s2.length === 0) return false;
69096
- if (s2.length > 1 && s2.charCodeAt(0) === 48) return false;
69097
- for (let i = 0; i < s2.length; i++) {
69098
- const c = s2.charCodeAt(i);
69099
- if (c < 48 || c > 57) return false;
69100
- }
69101
- const n = +s2;
69102
- if (n >= 2 ** 32 - 1) return false;
69103
- if (n < 0) return false;
69104
- return true;
69105
- }
69106
- function valid_array_indices(array2) {
69107
- const keys2 = Object.keys(array2);
69108
- for (var i = keys2.length - 1; i >= 0; i--) {
69109
- if (is_valid_array_index(keys2[i])) {
69110
- break;
69111
- }
69112
- }
69113
- keys2.length = i + 1;
69114
- return keys2;
69115
- }
69116
- function encode64(arraybuffer) {
69117
- const dv = new DataView(arraybuffer);
69118
- let binaryString = "";
69119
- for (let i = 0; i < arraybuffer.byteLength; i++) {
69120
- binaryString += String.fromCharCode(dv.getUint8(i));
69121
- }
69122
- return binaryToAscii(binaryString);
69123
- }
69124
- function decode64(string2) {
69125
- const binaryString = asciiToBinary(string2);
69126
- const arraybuffer = new ArrayBuffer(binaryString.length);
69127
- const dv = new DataView(arraybuffer);
69128
- for (let i = 0; i < arraybuffer.byteLength; i++) {
69129
- dv.setUint8(i, binaryString.charCodeAt(i));
69130
- }
69131
- return arraybuffer;
69132
- }
69133
- const KEY_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
69134
- function asciiToBinary(data) {
69135
- if (data.length % 4 === 0) {
69136
- data = data.replace(/==?$/, "");
69137
- }
69138
- let output = "";
69139
- let buffer = 0;
69140
- let accumulatedBits = 0;
69141
- for (let i = 0; i < data.length; i++) {
69142
- buffer <<= 6;
69143
- buffer |= KEY_STRING.indexOf(data[i]);
69144
- accumulatedBits += 6;
69145
- if (accumulatedBits === 24) {
69146
- output += String.fromCharCode((buffer & 16711680) >> 16);
69147
- output += String.fromCharCode((buffer & 65280) >> 8);
69148
- output += String.fromCharCode(buffer & 255);
69149
- buffer = accumulatedBits = 0;
69150
- }
69151
- }
69152
- if (accumulatedBits === 12) {
69153
- buffer >>= 4;
69154
- output += String.fromCharCode(buffer);
69155
- } else if (accumulatedBits === 18) {
69156
- buffer >>= 2;
69157
- output += String.fromCharCode((buffer & 65280) >> 8);
69158
- output += String.fromCharCode(buffer & 255);
69159
- }
69160
- return output;
69161
- }
69162
- function binaryToAscii(str) {
69163
- let out = "";
69164
- for (let i = 0; i < str.length; i += 3) {
69165
- const groupsOfSix = [void 0, void 0, void 0, void 0];
69166
- groupsOfSix[0] = str.charCodeAt(i) >> 2;
69167
- groupsOfSix[1] = (str.charCodeAt(i) & 3) << 4;
69168
- if (str.length > i + 1) {
69169
- groupsOfSix[1] |= str.charCodeAt(i + 1) >> 4;
69170
- groupsOfSix[2] = (str.charCodeAt(i + 1) & 15) << 2;
69171
- }
69172
- if (str.length > i + 2) {
69173
- groupsOfSix[2] |= str.charCodeAt(i + 2) >> 6;
69174
- groupsOfSix[3] = str.charCodeAt(i + 2) & 63;
69175
- }
69176
- for (let j2 = 0; j2 < groupsOfSix.length; j2++) {
69177
- if (typeof groupsOfSix[j2] === "undefined") {
69178
- out += "=";
69179
- } else {
69180
- out += KEY_STRING[groupsOfSix[j2]];
69181
- }
69182
- }
69183
- }
69184
- return out;
69185
- }
69186
- const UNDEFINED = -1;
69187
- const HOLE = -2;
69188
- const NAN = -3;
69189
- const POSITIVE_INFINITY = -4;
69190
- const NEGATIVE_INFINITY = -5;
69191
- const NEGATIVE_ZERO = -6;
69192
- const SPARSE = -7;
69193
- function parse$4(serialized, revivers) {
69194
- return unflatten(JSON.parse(serialized), revivers);
69195
- }
69196
- function unflatten(parsed, revivers) {
69197
- if (typeof parsed === "number") return hydrate(parsed, true);
69198
- if (!Array.isArray(parsed) || parsed.length === 0) {
69199
- throw new Error("Invalid input");
69200
- }
69201
- const values = (
69202
- /** @type {any[]} */
69203
- parsed
69204
- );
69205
- const hydrated = Array(values.length);
69206
- let hydrating = null;
69207
- function hydrate(index2, standalone = false) {
69208
- if (index2 === UNDEFINED) return void 0;
69209
- if (index2 === NAN) return NaN;
69210
- if (index2 === POSITIVE_INFINITY) return Infinity;
69211
- if (index2 === NEGATIVE_INFINITY) return -Infinity;
69212
- if (index2 === NEGATIVE_ZERO) return -0;
69213
- if (standalone || typeof index2 !== "number") {
69214
- throw new Error(`Invalid input`);
69215
- }
69216
- if (index2 in hydrated) return hydrated[index2];
69217
- const value = values[index2];
69218
- if (!value || typeof value !== "object") {
69219
- hydrated[index2] = value;
69220
- } else if (Array.isArray(value)) {
69221
- if (typeof value[0] === "string") {
69222
- const type = value[0];
69223
- const reviver = revivers && Object.hasOwn(revivers, type) ? revivers[type] : void 0;
69224
- if (reviver) {
69225
- let i = value[1];
69226
- if (typeof i !== "number") {
69227
- i = values.push(value[1]) - 1;
69228
- }
69229
- hydrating ?? (hydrating = /* @__PURE__ */ new Set());
69230
- if (hydrating.has(i)) {
69231
- throw new Error("Invalid circular reference");
69232
- }
69233
- hydrating.add(i);
69234
- hydrated[index2] = reviver(hydrate(i));
69235
- hydrating.delete(i);
69236
- return hydrated[index2];
69237
- }
69238
- switch (type) {
69239
- case "Date":
69240
- hydrated[index2] = new Date(value[1]);
69241
- break;
69242
- case "Set":
69243
- const set2 = /* @__PURE__ */ new Set();
69244
- hydrated[index2] = set2;
69245
- for (let i = 1; i < value.length; i += 1) {
69246
- set2.add(hydrate(value[i]));
69247
- }
69248
- break;
69249
- case "Map":
69250
- const map2 = /* @__PURE__ */ new Map();
69251
- hydrated[index2] = map2;
69252
- for (let i = 1; i < value.length; i += 2) {
69253
- map2.set(hydrate(value[i]), hydrate(value[i + 1]));
69254
- }
69255
- break;
69256
- case "RegExp":
69257
- hydrated[index2] = new RegExp(value[1], value[2]);
69258
- break;
69259
- case "Object":
69260
- hydrated[index2] = Object(value[1]);
69261
- break;
69262
- case "BigInt":
69263
- hydrated[index2] = BigInt(value[1]);
69264
- break;
69265
- case "null":
69266
- const obj = /* @__PURE__ */ Object.create(null);
69267
- hydrated[index2] = obj;
69268
- for (let i = 1; i < value.length; i += 2) {
69269
- obj[value[i]] = hydrate(value[i + 1]);
69270
- }
69271
- break;
69272
- case "Int8Array":
69273
- case "Uint8Array":
69274
- case "Uint8ClampedArray":
69275
- case "Int16Array":
69276
- case "Uint16Array":
69277
- case "Int32Array":
69278
- case "Uint32Array":
69279
- case "Float32Array":
69280
- case "Float64Array":
69281
- case "BigInt64Array":
69282
- case "BigUint64Array": {
69283
- if (values[value[1]][0] !== "ArrayBuffer") {
69284
- throw new Error("Invalid data");
69285
- }
69286
- const TypedArrayConstructor = globalThis[type];
69287
- const buffer = hydrate(value[1]);
69288
- const typedArray = new TypedArrayConstructor(buffer);
69289
- hydrated[index2] = value[2] !== void 0 ? typedArray.subarray(value[2], value[3]) : typedArray;
69290
- break;
69291
- }
69292
- case "ArrayBuffer": {
69293
- const base642 = value[1];
69294
- if (typeof base642 !== "string") {
69295
- throw new Error("Invalid ArrayBuffer encoding");
69296
- }
69297
- const arraybuffer = decode64(base642);
69298
- hydrated[index2] = arraybuffer;
69299
- break;
69300
- }
69301
- case "Temporal.Duration":
69302
- case "Temporal.Instant":
69303
- case "Temporal.PlainDate":
69304
- case "Temporal.PlainTime":
69305
- case "Temporal.PlainDateTime":
69306
- case "Temporal.PlainMonthDay":
69307
- case "Temporal.PlainYearMonth":
69308
- case "Temporal.ZonedDateTime": {
69309
- const temporalName = type.slice(9);
69310
- hydrated[index2] = Temporal[temporalName].from(value[1]);
69311
- break;
69312
- }
69313
- case "URL": {
69314
- const url2 = new URL(value[1]);
69315
- hydrated[index2] = url2;
69316
- break;
69317
- }
69318
- case "URLSearchParams": {
69319
- const url2 = new URLSearchParams(value[1]);
69320
- hydrated[index2] = url2;
69321
- break;
69322
- }
69323
- default:
69324
- throw new Error(`Unknown type ${type}`);
69325
- }
69326
- } else if (value[0] === SPARSE) {
69327
- const len = value[1];
69328
- const array2 = new Array(len);
69329
- hydrated[index2] = array2;
69330
- for (let i = 2; i < value.length; i += 2) {
69331
- const idx = value[i];
69332
- array2[idx] = hydrate(value[i + 1]);
69333
- }
69334
- } else {
69335
- const array2 = new Array(value.length);
69336
- hydrated[index2] = array2;
69337
- for (let i = 0; i < value.length; i += 1) {
69338
- const n = value[i];
69339
- if (n === HOLE) continue;
69340
- array2[i] = hydrate(n);
69341
- }
69342
- }
69343
- } else {
69344
- const object2 = {};
69345
- hydrated[index2] = object2;
69346
- for (const key of Object.keys(value)) {
69347
- if (key === "__proto__") {
69348
- throw new Error("Cannot parse an object with a `__proto__` property");
69349
- }
69350
- const n = value[key];
69351
- object2[key] = hydrate(n);
69352
- }
69353
- }
69354
- return hydrated[index2];
69355
- }
69356
- return hydrate(0);
69357
- }
69358
- function stringify(value, reducers) {
69359
- const stringified = [];
69360
- const indexes = /* @__PURE__ */ new Map();
69361
- const custom2 = [];
69362
- if (reducers) {
69363
- for (const key of Object.getOwnPropertyNames(reducers)) {
69364
- custom2.push({ key, fn: reducers[key] });
69365
- }
69366
- }
69367
- const keys2 = [];
69368
- let p2 = 0;
69369
- function flatten(thing) {
69370
- if (thing === void 0) return UNDEFINED;
69371
- if (Number.isNaN(thing)) return NAN;
69372
- if (thing === Infinity) return POSITIVE_INFINITY;
69373
- if (thing === -Infinity) return NEGATIVE_INFINITY;
69374
- if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO;
69375
- if (indexes.has(thing)) return indexes.get(thing);
69376
- const index3 = p2++;
69377
- indexes.set(thing, index3);
69378
- for (const { key, fn: fn2 } of custom2) {
69379
- const value2 = fn2(thing);
69380
- if (value2) {
69381
- stringified[index3] = `["${key}",${flatten(value2)}]`;
69382
- return index3;
69383
- }
69384
- }
69385
- if (typeof thing === "function") {
69386
- throw new DevalueError(`Cannot stringify a function`, keys2, thing, value);
69387
- }
69388
- let str = "";
69389
- if (is_primitive(thing)) {
69390
- str = stringify_primitive(thing);
69391
- } else {
69392
- const type = get_type(thing);
69393
- switch (type) {
69394
- case "Number":
69395
- case "String":
69396
- case "Boolean":
69397
- str = `["Object",${stringify_primitive(thing)}]`;
69398
- break;
69399
- case "BigInt":
69400
- str = `["BigInt",${thing}]`;
69401
- break;
69402
- case "Date":
69403
- const valid2 = !isNaN(thing.getDate());
69404
- str = `["Date","${valid2 ? thing.toISOString() : ""}"]`;
69405
- break;
69406
- case "URL":
69407
- str = `["URL",${stringify_string(thing.toString())}]`;
69408
- break;
69409
- case "URLSearchParams":
69410
- str = `["URLSearchParams",${stringify_string(thing.toString())}]`;
69411
- break;
69412
- case "RegExp":
69413
- const { source, flags } = thing;
69414
- str = flags ? `["RegExp",${stringify_string(source)},"${flags}"]` : `["RegExp",${stringify_string(source)}]`;
69415
- break;
69416
- case "Array": {
69417
- let mostly_dense = false;
69418
- str = "[";
69419
- for (let i = 0; i < thing.length; i += 1) {
69420
- if (i > 0) str += ",";
69421
- if (Object.hasOwn(thing, i)) {
69422
- keys2.push(`[${i}]`);
69423
- str += flatten(thing[i]);
69424
- keys2.pop();
69425
- } else if (mostly_dense) {
69426
- str += HOLE;
69427
- } else {
69428
- const populated_keys = valid_array_indices(
69429
- /** @type {any[]} */
69430
- thing
69431
- );
69432
- const population = populated_keys.length;
69433
- const d2 = String(thing.length).length;
69434
- const hole_cost = (thing.length - population) * 3;
69435
- const sparse_cost = 4 + d2 + population * (d2 + 1);
69436
- if (hole_cost > sparse_cost) {
69437
- str = "[" + SPARSE + "," + thing.length;
69438
- for (let j2 = 0; j2 < populated_keys.length; j2++) {
69439
- const key = populated_keys[j2];
69440
- keys2.push(`[${key}]`);
69441
- str += "," + key + "," + flatten(thing[key]);
69442
- keys2.pop();
69443
- }
69444
- break;
69445
- } else {
69446
- mostly_dense = true;
69447
- str += HOLE;
69448
- }
69449
- }
69450
- }
69451
- str += "]";
69452
- break;
69453
- }
69454
- case "Set":
69455
- str = '["Set"';
69456
- for (const value2 of thing) {
69457
- str += `,${flatten(value2)}`;
69458
- }
69459
- str += "]";
69460
- break;
69461
- case "Map":
69462
- str = '["Map"';
69463
- for (const [key, value2] of thing) {
69464
- keys2.push(
69465
- `.get(${is_primitive(key) ? stringify_primitive(key) : "..."})`
69466
- );
69467
- str += `,${flatten(key)},${flatten(value2)}`;
69468
- keys2.pop();
69469
- }
69470
- str += "]";
69471
- break;
69472
- case "Int8Array":
69473
- case "Uint8Array":
69474
- case "Uint8ClampedArray":
69475
- case "Int16Array":
69476
- case "Uint16Array":
69477
- case "Int32Array":
69478
- case "Uint32Array":
69479
- case "Float32Array":
69480
- case "Float64Array":
69481
- case "BigInt64Array":
69482
- case "BigUint64Array": {
69483
- const typedArray = thing;
69484
- str = '["' + type + '",' + flatten(typedArray.buffer);
69485
- const a2 = thing.byteOffset;
69486
- const b2 = a2 + thing.byteLength;
69487
- if (a2 > 0 || b2 !== typedArray.buffer.byteLength) {
69488
- const m2 = +/(\d+)/.exec(type)[1] / 8;
69489
- str += `,${a2 / m2},${b2 / m2}`;
69490
- }
69491
- str += "]";
69492
- break;
69493
- }
69494
- case "ArrayBuffer": {
69495
- const arraybuffer = thing;
69496
- const base642 = encode64(arraybuffer);
69497
- str = `["ArrayBuffer","${base642}"]`;
69498
- break;
69499
- }
69500
- case "Temporal.Duration":
69501
- case "Temporal.Instant":
69502
- case "Temporal.PlainDate":
69503
- case "Temporal.PlainTime":
69504
- case "Temporal.PlainDateTime":
69505
- case "Temporal.PlainMonthDay":
69506
- case "Temporal.PlainYearMonth":
69507
- case "Temporal.ZonedDateTime":
69508
- str = `["${type}",${stringify_string(thing.toString())}]`;
69509
- break;
69510
- default:
69511
- if (!is_plain_object(thing)) {
69512
- throw new DevalueError(
69513
- `Cannot stringify arbitrary non-POJOs`,
69514
- keys2,
69515
- thing,
69516
- value
69517
- );
69518
- }
69519
- if (enumerable_symbols(thing).length > 0) {
69520
- throw new DevalueError(
69521
- `Cannot stringify POJOs with symbolic keys`,
69522
- keys2,
69523
- thing,
69524
- value
69525
- );
69526
- }
69527
- if (Object.getPrototypeOf(thing) === null) {
69528
- str = '["null"';
69529
- for (const key of Object.keys(thing)) {
69530
- if (key === "__proto__") {
69531
- throw new DevalueError(
69532
- `Cannot stringify objects with __proto__ keys`,
69533
- keys2,
69534
- thing,
69535
- value
69536
- );
69537
- }
69538
- keys2.push(stringify_key(key));
69539
- str += `,${stringify_string(key)},${flatten(thing[key])}`;
69540
- keys2.pop();
69541
- }
69542
- str += "]";
69543
- } else {
69544
- str = "{";
69545
- let started = false;
69546
- for (const key of Object.keys(thing)) {
69547
- if (key === "__proto__") {
69548
- throw new DevalueError(
69549
- `Cannot stringify objects with __proto__ keys`,
69550
- keys2,
69551
- thing,
69552
- value
69553
- );
69554
- }
69555
- if (started) str += ",";
69556
- started = true;
69557
- keys2.push(stringify_key(key));
69558
- str += `${stringify_string(key)}:${flatten(thing[key])}`;
69559
- keys2.pop();
69560
- }
69561
- str += "}";
69562
- }
69563
- }
69564
- }
69565
- stringified[index3] = str;
69566
- return index3;
69567
- }
69568
- const index2 = flatten(value);
69569
- if (index2 < 0) return `${index2}`;
69570
- return `[${stringified.join(",")}]`;
69571
- }
69572
- function stringify_primitive(thing) {
69573
- const type = typeof thing;
69574
- if (type === "string") return stringify_string(thing);
69575
- if (thing instanceof String) return stringify_string(thing.toString());
69576
- if (thing === void 0) return UNDEFINED.toString();
69577
- if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO.toString();
69578
- if (type === "bigint") return `["BigInt","${thing}"]`;
69579
- return String(thing);
69580
- }
69581
- const SerializationFormat$1 = {
69582
- /** devalue stringify/parse with TextEncoder/TextDecoder */
69583
- DEVALUE_V1: "devl"
69584
- };
69585
- const FORMAT_PREFIX_LENGTH$1 = 4;
69586
- new TextEncoder();
69587
- const formatDecoder$1 = new TextDecoder();
69588
- function decodeFormatPrefix$1(data) {
69589
- if (!(data instanceof Uint8Array)) {
69590
- return {
69591
- format: SerializationFormat$1.DEVALUE_V1,
69592
- payload: new TextEncoder().encode(JSON.stringify(data))
69593
- };
69594
- }
69595
- if (data.length < FORMAT_PREFIX_LENGTH$1) {
69596
- throw new Error(`Data too short to contain format prefix: expected at least ${FORMAT_PREFIX_LENGTH$1} bytes, got ${data.length}`);
69597
- }
69598
- const prefixBytes = data.subarray(0, FORMAT_PREFIX_LENGTH$1);
69599
- const format2 = formatDecoder$1.decode(prefixBytes);
69600
- const knownFormats = Object.values(SerializationFormat$1);
69601
- if (!knownFormats.includes(format2)) {
69602
- throw new Error(`Unknown serialization format: "${format2}". Known formats: ${knownFormats.join(", ")}`);
69603
- }
69604
- const payload = data.subarray(FORMAT_PREFIX_LENGTH$1);
69605
- return { format: format2, payload };
69606
- }
69607
- function hydrateData(value, revivers) {
69608
- if (value instanceof Uint8Array) {
69609
- const { format: format2, payload } = decodeFormatPrefix$1(value);
69610
- if (format2 === SerializationFormat$1.DEVALUE_V1) {
69611
- const str = new TextDecoder().decode(payload);
69612
- return parse$4(str, revivers);
69613
- }
69614
- throw new Error(`Unsupported serialization format: ${format2}`);
69615
- }
69616
- if (Array.isArray(value)) {
69617
- return unflatten(value, revivers);
69618
- }
69619
- return value;
69620
- }
69621
- const STREAM_ID_PREFIX = "strm_";
69622
- const STREAM_REF_TYPE = "__workflow_stream_ref__";
69623
- const CLASS_INSTANCE_REF_TYPE = "__workflow_class_instance_ref__";
69624
- class ClassInstanceRef {
69625
- constructor(className, classId, data) {
69626
- __publicField(this, "className");
69627
- __publicField(this, "classId");
69628
- __publicField(this, "data");
69629
- __publicField(this, "__type", CLASS_INSTANCE_REF_TYPE);
69630
- this.className = className;
69631
- this.classId = classId;
69632
- this.data = data;
69633
- }
69634
- toJSON() {
69635
- return {
69636
- __type: this.__type,
69637
- className: this.className,
69638
- classId: this.classId,
69639
- data: this.data
69640
- };
69641
- }
69642
- }
69643
- const streamToStreamRef = (value) => {
69644
- let streamId;
69645
- if ("name" in value) {
69646
- const name2 = String(value.name);
69647
- if (!name2.startsWith(STREAM_ID_PREFIX)) {
69648
- streamId = `${STREAM_ID_PREFIX}${name2}`;
69649
- } else {
69650
- streamId = name2;
69651
- }
69652
- } else {
69653
- streamId = `${STREAM_ID_PREFIX}null`;
69654
- }
69655
- return { __type: STREAM_REF_TYPE, streamId };
69656
- };
69657
- const serializedStepFunctionToString = (value) => {
69658
- if (!value)
69659
- return "null";
69660
- if (typeof value !== "object")
69661
- return "null";
69662
- if ("stepId" in value) {
69663
- return `<step:${value.stepId}>`;
69664
- }
69665
- return "<function>";
69666
- };
69667
- const extractClassName = (classId) => {
69668
- if (!classId)
69669
- return "Unknown";
69670
- const parts = classId.split("/");
69671
- return parts[parts.length - 1] || classId;
69672
- };
69673
- const serializedInstanceToRef = (value) => {
69674
- return new ClassInstanceRef(extractClassName(value.classId), value.classId, value.data);
69675
- };
69676
- const serializedClassToString = (value) => {
69677
- return `<class:${extractClassName(value.classId)}>`;
69678
- };
69679
- const observabilityRevivers = {
69680
- ReadableStream: streamToStreamRef,
69681
- WritableStream: streamToStreamRef,
69682
- TransformStream: streamToStreamRef,
69683
- StepFunction: serializedStepFunctionToString,
69684
- Instance: serializedInstanceToRef,
69685
- Class: serializedClassToString
69686
- };
69687
- function hydrateStepIO(resource, revivers) {
69688
- let hydratedInput = resource.input;
69689
- let hydratedOutput = resource.output;
69690
- if (resource.input != null) {
69691
- try {
69692
- hydratedInput = hydrateData(resource.input, revivers);
69693
- } catch {
69694
- }
69695
- }
69696
- if (resource.output != null) {
69697
- try {
69698
- hydratedOutput = hydrateData(resource.output, revivers);
69699
- } catch {
69700
- }
69701
- }
69702
- return { ...resource, input: hydratedInput, output: hydratedOutput };
69703
- }
69704
- function hydrateWorkflowIO(resource, revivers) {
69705
- let hydratedInput = resource.input;
69706
- let hydratedOutput = resource.output;
69707
- if (resource.input != null) {
69708
- try {
69709
- hydratedInput = hydrateData(resource.input, revivers);
69710
- } catch {
69711
- }
69712
- }
69713
- if (resource.output != null) {
69714
- try {
69715
- hydratedOutput = hydrateData(resource.output, revivers);
69716
- } catch {
69717
- }
69718
- }
69719
- return { ...resource, input: hydratedInput, output: hydratedOutput };
69720
- }
69721
- function hydrateEventData(resource, revivers) {
69722
- if (!resource.eventData)
69723
- return resource;
69724
- const eventData = { ...resource.eventData };
69725
- if ("result" in eventData && eventData.result != null) {
69726
- try {
69727
- eventData.result = hydrateData(eventData.result, revivers);
69728
- } catch {
69729
- }
69730
- }
69731
- if ("input" in eventData && eventData.input != null) {
69732
- try {
69733
- eventData.input = hydrateData(eventData.input, revivers);
69734
- } catch {
69735
- }
69736
- }
69737
- if ("output" in eventData && eventData.output != null) {
69738
- try {
69739
- eventData.output = hydrateData(eventData.output, revivers);
69740
- } catch {
69741
- }
69742
- }
69743
- if ("metadata" in eventData && eventData.metadata != null) {
69744
- try {
69745
- eventData.metadata = hydrateData(eventData.metadata, revivers);
69746
- } catch {
69747
- }
69748
- }
69749
- if ("payload" in eventData && eventData.payload != null) {
69750
- try {
69751
- eventData.payload = hydrateData(eventData.payload, revivers);
69752
- } catch {
69753
- }
69754
- }
69755
- return { ...resource, eventData };
69756
- }
69757
- function hydrateHookMetadata(resource, revivers) {
69758
- if (resource.metadata == null)
69759
- return resource;
69760
- let hydratedMetadata = resource.metadata;
69761
- try {
69762
- hydratedMetadata = hydrateData(resource.metadata, revivers);
69763
- } catch {
69764
- }
69765
- return { ...resource, metadata: hydratedMetadata };
69766
- }
69767
- function hydrateResourceIO$1(resource, revivers) {
69768
- if (!resource)
69769
- return resource;
69770
- let hydrated;
69771
- if ("stepId" in resource) {
69772
- hydrated = hydrateStepIO(resource, revivers);
69773
- } else if ("hookId" in resource) {
69774
- hydrated = hydrateHookMetadata(resource, revivers);
69775
- } else if ("eventId" in resource) {
69776
- hydrated = hydrateEventData(resource, revivers);
69777
- } else {
69778
- hydrated = hydrateWorkflowIO(resource, revivers);
69779
- }
69780
- if ("executionContext" in hydrated) {
69781
- const { executionContext, ...rest } = hydrated;
69782
- const workflowCoreVersion = executionContext && typeof executionContext === "object" && "workflowCoreVersion" in executionContext ? executionContext.workflowCoreVersion : void 0;
69783
- if (workflowCoreVersion) {
69784
- return { ...rest, workflowCoreVersion };
69785
- }
69786
- return rest;
69787
- }
69788
- return hydrated;
69789
- }
69790
- function base64ToArrayBuffer(base642) {
69791
- if (base642 === "" || base642 === ".") {
69792
- return new ArrayBuffer(0);
69793
- }
69794
- const binaryString = atob(base642);
69795
- const bytes = new Uint8Array(binaryString.length);
69796
- for (let i = 0; i < binaryString.length; i++) {
69797
- bytes[i] = binaryString.charCodeAt(i);
69798
- }
69799
- return bytes.buffer;
69800
- }
69801
- function getWebRevivers() {
69802
- function reviveArrayBuffer(value) {
69803
- return base64ToArrayBuffer(value);
69804
- }
69805
- return {
69806
- // O11y-specific revivers (streams, step functions → display objects).
69807
- // Spread FIRST so web-specific overrides below take precedence.
69808
- ...observabilityRevivers,
69809
- // Binary types
69810
- ArrayBuffer: reviveArrayBuffer,
69811
- BigInt: (value) => BigInt(value),
69812
- BigInt64Array: (value) => new BigInt64Array(reviveArrayBuffer(value)),
69813
- BigUint64Array: (value) => new BigUint64Array(reviveArrayBuffer(value)),
69814
- Date: (value) => new Date(value),
69815
- Error: (value) => {
69816
- const error2 = new Error(value.message);
69817
- error2.name = value.name;
69818
- error2.stack = value.stack;
69819
- return error2;
69820
- },
69821
- Float32Array: (value) => new Float32Array(reviveArrayBuffer(value)),
69822
- Float64Array: (value) => new Float64Array(reviveArrayBuffer(value)),
69823
- Int8Array: (value) => new Int8Array(reviveArrayBuffer(value)),
69824
- Int16Array: (value) => new Int16Array(reviveArrayBuffer(value)),
69825
- Int32Array: (value) => new Int32Array(reviveArrayBuffer(value)),
69826
- Map: (value) => new Map(value),
69827
- RegExp: (value) => new RegExp(value.source, value.flags),
69828
- Set: (value) => new Set(value),
69829
- Uint8Array: (value) => new Uint8Array(reviveArrayBuffer(value)),
69830
- Uint8ClampedArray: (value) => new Uint8ClampedArray(reviveArrayBuffer(value)),
69831
- Uint16Array: (value) => new Uint16Array(reviveArrayBuffer(value)),
69832
- Uint32Array: (value) => new Uint32Array(reviveArrayBuffer(value)),
69833
- Headers: (value) => new Headers(value),
69834
- URL: (value) => new URL(value),
69835
- URLSearchParams: (value) => new URLSearchParams(value === "." ? "" : value),
69836
- // Web-specific overrides for class instances.
69837
- // Create objects with a dynamically-named constructor so that
69838
- // react-inspector shows the class name (it reads constructor.name).
69839
- Class: (value) => `<class:${extractClassName(value.classId)}>`,
69840
- Instance: (value) => {
69841
- const className = extractClassName(value.classId);
69842
- const data = value.data;
69843
- const props = data && typeof data === "object" ? { ...data } : { value: data };
69844
- const ctor = { [className]: function() {
69845
- } }[className];
69846
- const obj = Object.create(ctor.prototype);
69847
- Object.assign(obj, props);
69848
- return obj;
69849
- }
69850
- };
69851
- }
69852
- let cachedRevivers = null;
69853
- function getRevivers() {
69854
- if (!cachedRevivers) {
69855
- cachedRevivers = getWebRevivers();
69856
- }
69857
- return cachedRevivers;
69858
- }
69859
- function hydrateResourceIO(resource) {
69860
- return hydrateResourceIO$1(resource, getRevivers());
69861
- }
69862
70068
  const DEFAULT_PAGE_SIZE = 10;
69863
70069
  function cn(...inputs) {
69864
70070
  return twMerge(clsx(inputs));
@@ -72539,6 +72745,9 @@ async function fetchWorkflowsManifest$1(worldEnv) {
72539
72745
  async function runHealthCheck$1(worldEnv, endpoint, options) {
72540
72746
  return rpc("runHealthCheck", { worldEnv, endpoint, options });
72541
72747
  }
72748
+ async function getEncryptionKeyForRun$1(worldEnv, runId) {
72749
+ return rpc("getEncryptionKeyForRun", { worldEnv, runId });
72750
+ }
72542
72751
  function HealthCheckButton() {
72543
72752
  const [isChecking, setIsChecking] = reactExports.useState(false);
72544
72753
  const env2 = reactExports.useMemo(() => ({}), []);
@@ -73045,6 +73254,17 @@ class WorkflowRunNotFoundError extends WorkflowError {
73045
73254
  return isError(value) && value.name === "WorkflowRunNotFoundError";
73046
73255
  }
73047
73256
  }
73257
+ class HookNotFoundError extends WorkflowError {
73258
+ constructor(token) {
73259
+ super("Hook not found", {});
73260
+ __publicField(this, "token");
73261
+ this.name = "HookNotFoundError";
73262
+ this.token = token;
73263
+ }
73264
+ static is(value) {
73265
+ return isError(value) && value.name === "HookNotFoundError";
73266
+ }
73267
+ }
73048
73268
  class WorkflowRunCancelledError extends WorkflowError {
73049
73269
  constructor(runId) {
73050
73270
  super(`Workflow run "${runId}" cancelled`, {});
@@ -86949,7 +87169,8 @@ const HookSchema = object$1({
86949
87169
  metadata: SerializedDataSchema.optional(),
86950
87170
  createdAt: date$2(),
86951
87171
  // Optional in database for backwards compatibility, defaults to 1 (legacy) when reading
86952
- specVersion: number$1().optional()
87172
+ specVersion: number$1().optional(),
87173
+ isWebhook: boolean$1().optional()
86953
87174
  });
86954
87175
  const QueuePrefix = union([
86955
87176
  literal("__wkf_step_"),
@@ -87113,6 +87334,8 @@ const WaitSchema = object$1({
87113
87334
  updatedAt: date$2(),
87114
87335
  specVersion: number$1().optional()
87115
87336
  });
87337
+ const NONCE_LENGTH = 12;
87338
+ const TAG_LENGTH = 128;
87116
87339
  const KEY_LENGTH = 32;
87117
87340
  async function importKey(raw2) {
87118
87341
  if (raw2.byteLength !== KEY_LENGTH) {
@@ -87123,6 +87346,30 @@ async function importKey(raw2) {
87123
87346
  "decrypt"
87124
87347
  ]);
87125
87348
  }
87349
+ async function encrypt(key, data) {
87350
+ const nonce = globalThis.crypto.getRandomValues(new Uint8Array(NONCE_LENGTH));
87351
+ const ciphertext = await globalThis.crypto.subtle.encrypt({ name: "AES-GCM", iv: nonce, tagLength: TAG_LENGTH }, key, data);
87352
+ const result = new Uint8Array(NONCE_LENGTH + ciphertext.byteLength);
87353
+ result.set(nonce, 0);
87354
+ result.set(new Uint8Array(ciphertext), NONCE_LENGTH);
87355
+ return result;
87356
+ }
87357
+ async function decrypt(key, data) {
87358
+ const minLength = NONCE_LENGTH + TAG_LENGTH / 8;
87359
+ if (data.byteLength < minLength) {
87360
+ throw new Error(`Encrypted data too short: expected at least ${minLength} bytes, got ${data.byteLength}`);
87361
+ }
87362
+ const nonce = data.subarray(0, NONCE_LENGTH);
87363
+ const ciphertext = data.subarray(NONCE_LENGTH);
87364
+ const plaintext = await globalThis.crypto.subtle.decrypt({ name: "AES-GCM", iv: nonce, tagLength: TAG_LENGTH }, key, ciphertext);
87365
+ return new Uint8Array(plaintext);
87366
+ }
87367
+ const encryption = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
87368
+ __proto__: null,
87369
+ decrypt,
87370
+ encrypt,
87371
+ importKey
87372
+ }, Symbol.toStringTag, { value: "Module" }));
87126
87373
  class WorkflowSuspension extends Error {
87127
87374
  constructor(stepsInput, global2) {
87128
87375
  const steps = [...stepsInput.values()];
@@ -89153,8 +89400,8 @@ function requireGetVercelOidcToken$1() {
89153
89400
  }
89154
89401
  try {
89155
89402
  const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
89156
- await import("./token-util-DNmL7drj.js").then((n) => n.t),
89157
- await import("./token-DbisGEEb.js").then((n) => n.t)
89403
+ await import("./token-util-C6iVpF77.js").then((n) => n.t),
89404
+ await import("./token-C58qysN7.js").then((n) => n.t)
89158
89405
  ]);
89159
89406
  if (!token || isExpired(getTokenPayload(token))) {
89160
89407
  await refreshToken();
@@ -115773,7 +116020,7 @@ function createHooksStorage(basedir) {
115773
116020
  const hookPath = path$2.join(hooksDir, `${file2}.json`);
115774
116021
  const hook = await readJSON(hookPath, HookSchema);
115775
116022
  if (hook && hook.token === token) {
115776
- return hook;
116023
+ return { ...hook, isWebhook: hook.isWebhook ?? true };
115777
116024
  }
115778
116025
  }
115779
116026
  return null;
@@ -115782,15 +116029,15 @@ function createHooksStorage(basedir) {
115782
116029
  const hookPath = path$2.join(basedir, "hooks", `${hookId}.json`);
115783
116030
  const hook = await readJSON(hookPath, HookSchema);
115784
116031
  if (!hook) {
115785
- throw new Error(`Hook ${hookId} not found`);
116032
+ throw new HookNotFoundError(hookId);
115786
116033
  }
115787
116034
  const resolveData = (params == null ? void 0 : params.resolveData) || DEFAULT_RESOLVE_DATA_OPTION$1;
115788
- return filterHookData$1(hook, resolveData);
116035
+ return filterHookData$1({ ...hook, isWebhook: hook.isWebhook ?? true }, resolveData);
115789
116036
  }
115790
116037
  async function getByToken(token) {
115791
116038
  const hook = await findHookByToken(token);
115792
116039
  if (!hook) {
115793
- throw new Error(`Hook with token ${token} not found`);
116040
+ throw new HookNotFoundError(token);
115794
116041
  }
115795
116042
  return hook;
115796
116043
  }
@@ -115801,7 +116048,7 @@ function createHooksStorage(basedir) {
115801
116048
  const result = await paginatedFileSystemQuery({
115802
116049
  directory: hooksDir,
115803
116050
  schema: HookSchema,
115804
- sortOrder: (_a3 = params.pagination) == null ? void 0 : _a3.sortOrder,
116051
+ sortOrder: ((_a3 = params.pagination) == null ? void 0 : _a3.sortOrder) ?? "asc",
115805
116052
  limit: (_b = params.pagination) == null ? void 0 : _b.limit,
115806
116053
  cursor: (_c = params.pagination) == null ? void 0 : _c.cursor,
115807
116054
  filePrefix: void 0,
@@ -115813,7 +116060,7 @@ function createHooksStorage(basedir) {
115813
116060
  return true;
115814
116061
  },
115815
116062
  getCreatedAt: () => {
115816
- return /* @__PURE__ */ new Date(0);
116063
+ return null;
115817
116064
  },
115818
116065
  getId: (hook) => hook.hookId
115819
116066
  });
@@ -116271,7 +116518,8 @@ function createEventsStorage(basedir) {
116271
116518
  environment: "local",
116272
116519
  createdAt: now2,
116273
116520
  // Propagate specVersion from the event to the hook entity
116274
- specVersion: effectiveSpecVersion
116521
+ specVersion: effectiveSpecVersion,
116522
+ isWebhook: hookData.isWebhook ?? false
116275
116523
  };
116276
116524
  const hookPath = path$2.join(basedir, "hooks", `${data.correlationId}.json`);
116277
116525
  await writeJSON(hookPath, hook);
@@ -116823,8 +117071,8 @@ function requireGetVercelOidcToken() {
116823
117071
  }
116824
117072
  try {
116825
117073
  const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
116826
- await import("./token-util-BtczqLw5.js").then((n) => n.t),
116827
- await import("./token-lkNtm8QO.js").then((n) => n.t)
117074
+ await import("./token-util-CcopqG1U.js").then((n) => n.t),
117075
+ await import("./token-CLFHo1Az.js").then((n) => n.t)
116828
117076
  ]);
116829
117077
  if (!token || isExpired(getTokenPayload(token), options == null ? void 0 : options.expirationBufferMs)) {
116830
117078
  await refreshToken(options);
@@ -117473,7 +117721,7 @@ function createGetEncryptionKeyForRun(projectId, teamId, token) {
117473
117721
  localDeploymentKey = Buffer.from(deploymentKeyBase64, "base64");
117474
117722
  return localDeploymentKey;
117475
117723
  }
117476
- return async function getEncryptionKeyForRun(run, context) {
117724
+ return async function getEncryptionKeyForRun2(run, context) {
117477
117725
  const runId = typeof run === "string" ? run : run.runId;
117478
117726
  const deploymentId = typeof run === "string" ? context == null ? void 0 : context.deploymentId : run.deploymentId;
117479
117727
  if (!deploymentId || deploymentId === currentDeploymentId) {
@@ -117543,7 +117791,7 @@ const PeerService = SemanticConvention("peer.service");
117543
117791
  const RpcSystem = SemanticConvention("rpc.system");
117544
117792
  const RpcService = SemanticConvention("rpc.service");
117545
117793
  const RpcMethod = SemanticConvention("rpc.method");
117546
- const version$1 = "4.1.0-beta.36";
117794
+ const version$1 = "4.1.0-beta.38";
117547
117795
  const DEFAULT_RESOLVE_DATA_OPTION = "all";
117548
117796
  function deserializeError(obj) {
117549
117797
  const { error: error2, ...rest } = obj;
@@ -118168,12 +118416,18 @@ function filterEventData(event, resolveData) {
118168
118416
  }
118169
118417
  return event;
118170
118418
  }
118171
- const EventResultWireSchema = z.object({
118419
+ const EventResultResolveWireSchema = z.object({
118172
118420
  event: EventSchema,
118173
118421
  run: WorkflowRunSchema.optional(),
118174
118422
  step: StepWireSchema.optional(),
118175
118423
  hook: HookSchema.optional()
118176
118424
  });
118425
+ const EventResultLazyWireSchema = z.object({
118426
+ event: EventSchema,
118427
+ run: WorkflowRunWireBaseSchema.optional(),
118428
+ step: StepWireSchema.optional(),
118429
+ hook: HookSchema.optional()
118430
+ });
118177
118431
  const EventWithRefsSchema = z.object({
118178
118432
  eventId: z.string(),
118179
118433
  runId: z.string(),
@@ -118362,16 +118616,31 @@ async function createWorkflowRunEvent(id2, data, params, config2) {
118362
118616
  }
118363
118617
  const runIdPath = id2 === null ? "null" : id2;
118364
118618
  const remoteRefBehavior = eventsNeedingResolve.has(data.eventType) ? "resolve" : "lazy";
118619
+ if (remoteRefBehavior === "resolve") {
118620
+ const wireResult2 = await makeRequest({
118621
+ endpoint: `/v2/runs/${runIdPath}/events`,
118622
+ options: { method: "POST" },
118623
+ data: { ...data, remoteRefBehavior },
118624
+ config: config2,
118625
+ schema: EventResultResolveWireSchema
118626
+ });
118627
+ return {
118628
+ event: filterEventData(wireResult2.event, resolveData),
118629
+ run: wireResult2.run,
118630
+ step: wireResult2.step ? deserializeStep(wireResult2.step) : void 0,
118631
+ hook: wireResult2.hook
118632
+ };
118633
+ }
118365
118634
  const wireResult = await makeRequest({
118366
118635
  endpoint: `/v2/runs/${runIdPath}/events`,
118367
118636
  options: { method: "POST" },
118368
118637
  data: { ...data, remoteRefBehavior },
118369
118638
  config: config2,
118370
- schema: EventResultWireSchema
118639
+ schema: EventResultLazyWireSchema
118371
118640
  });
118372
118641
  return {
118373
118642
  event: filterEventData(wireResult.event, resolveData),
118374
- run: wireResult.run,
118643
+ run: wireResult.run ? deserializeError(wireResult.run) : void 0,
118375
118644
  step: wireResult.step ? deserializeStep(wireResult.step) : void 0,
118376
118645
  hook: wireResult.hook
118377
118646
  };
@@ -118426,14 +118695,21 @@ async function getHook(hookId, params, config2) {
118426
118695
  return filterHookData(hook, resolveData);
118427
118696
  }
118428
118697
  async function getHookByToken(token, config2) {
118429
- return makeRequest({
118430
- endpoint: `/v2/hooks/by-token?token=${encodeURIComponent(token)}`,
118431
- options: {
118432
- method: "GET"
118433
- },
118434
- config: config2,
118435
- schema: HookSchema
118436
- });
118698
+ try {
118699
+ return await makeRequest({
118700
+ endpoint: `/v2/hooks/by-token?token=${encodeURIComponent(token)}`,
118701
+ options: {
118702
+ method: "GET"
118703
+ },
118704
+ config: config2,
118705
+ schema: HookSchema
118706
+ });
118707
+ } catch (error2) {
118708
+ if (WorkflowAPIError.is(error2) && error2.status === 404) {
118709
+ throw new HookNotFoundError(token);
118710
+ }
118711
+ throw error2;
118712
+ }
118437
118713
  }
118438
118714
  const WORKFLOW_SERVER_SERVICE = {
118439
118715
  peerService: "workflow-server",
@@ -118600,7 +118876,7 @@ function createStreamer(config2) {
118600
118876
  }
118601
118877
  };
118602
118878
  }
118603
- function createVercelWorld$1(config2) {
118879
+ function createVercelWorld(config2) {
118604
118880
  var _a3, _b;
118605
118881
  const projectId = ((_a3 = config2 == null ? void 0 : config2.projectConfig) == null ? void 0 : _a3.projectId) || process.env.VERCEL_PROJECT_ID;
118606
118882
  return {
@@ -118623,7 +118899,7 @@ function defaultWorld() {
118623
118899
  const createWorld = () => {
118624
118900
  const targetWorld = process.env.WORKFLOW_TARGET_WORLD || defaultWorld();
118625
118901
  if (targetWorld === "vercel") {
118626
- return createVercelWorld$1({
118902
+ return createVercelWorld({
118627
118903
  token: process.env.WORKFLOW_VERCEL_AUTH_TOKEN,
118628
118904
  projectConfig: {
118629
118905
  environment: process.env.WORKFLOW_VERCEL_ENV,
@@ -120119,7 +120395,9 @@ function getStepFunction(stepId) {
120119
120395
  }
120120
120396
  const SerializationFormat = {
120121
120397
  /** devalue stringify/parse with TextEncoder/TextDecoder */
120122
- DEVALUE_V1: "devl"
120398
+ DEVALUE_V1: "devl",
120399
+ /** Encrypted payload (inner payload has its own format prefix) */
120400
+ ENCRYPTED: "encr"
120123
120401
  };
120124
120402
  const FORMAT_PREFIX_LENGTH = 4;
120125
120403
  const formatEncoder = new TextEncoder();
@@ -120137,6 +120415,21 @@ function encodeWithFormatPrefix(format2, payload) {
120137
120415
  result.set(payload, FORMAT_PREFIX_LENGTH);
120138
120416
  return result;
120139
120417
  }
120418
+ function peekFormatPrefix(data) {
120419
+ if (!(data instanceof Uint8Array) || data.length < FORMAT_PREFIX_LENGTH) {
120420
+ return null;
120421
+ }
120422
+ const prefixBytes = data.subarray(0, FORMAT_PREFIX_LENGTH);
120423
+ const format2 = formatDecoder.decode(prefixBytes);
120424
+ const knownFormats = Object.values(SerializationFormat);
120425
+ if (!knownFormats.includes(format2)) {
120426
+ return null;
120427
+ }
120428
+ return format2;
120429
+ }
120430
+ function isEncrypted(data) {
120431
+ return peekFormatPrefix(data) === SerializationFormat.ENCRYPTED;
120432
+ }
120140
120433
  function decodeFormatPrefix(data) {
120141
120434
  if (!(data instanceof Uint8Array)) {
120142
120435
  return {
@@ -120151,7 +120444,7 @@ function decodeFormatPrefix(data) {
120151
120444
  const format2 = formatDecoder.decode(prefixBytes);
120152
120445
  const knownFormats = Object.values(SerializationFormat);
120153
120446
  if (!knownFormats.includes(format2)) {
120154
- throw new Error(`Unknown serialization format: "${format2}". Known formats: ${knownFormats.join(", ")}`);
120447
+ throw new WorkflowRuntimeError(`Unknown serialization format: "${format2}". Known formats: ${knownFormats.join(", ")}`);
120155
120448
  }
120156
120449
  const payload = data.subarray(FORMAT_PREFIX_LENGTH);
120157
120450
  return { format: format2, payload };
@@ -120181,14 +120474,23 @@ function getStreamType(stream) {
120181
120474
  }
120182
120475
  }
120183
120476
  const FRAME_HEADER_SIZE = 4;
120184
- function getSerializeStream(reducers) {
120477
+ function getSerializeStream(reducers, cryptoKey) {
120185
120478
  const encoder = new TextEncoder();
120479
+ const keyState = { resolved: false, key: void 0 };
120186
120480
  const stream = new TransformStream({
120187
- transform(chunk, controller) {
120481
+ async transform(chunk, controller) {
120188
120482
  try {
120189
- const serialized = stringify(chunk, reducers);
120483
+ if (!keyState.resolved) {
120484
+ keyState.key = await cryptoKey;
120485
+ keyState.resolved = true;
120486
+ }
120487
+ const serialized = stringify$2(chunk, reducers);
120190
120488
  const payload = encoder.encode(serialized);
120191
- const prefixed = encodeWithFormatPrefix(SerializationFormat.DEVALUE_V1, payload);
120489
+ let prefixed = encodeWithFormatPrefix(SerializationFormat.DEVALUE_V1, payload);
120490
+ if (keyState.key) {
120491
+ const encrypted = await encrypt(keyState.key, prefixed);
120492
+ prefixed = encodeWithFormatPrefix(SerializationFormat.ENCRYPTED, encrypted);
120493
+ }
120192
120494
  const frame2 = new Uint8Array(FRAME_HEADER_SIZE + prefixed.length);
120193
120495
  new DataView(frame2.buffer).setUint32(0, prefixed.length, false);
120194
120496
  frame2.set(prefixed, FRAME_HEADER_SIZE);
@@ -120200,16 +120502,21 @@ function getSerializeStream(reducers) {
120200
120502
  });
120201
120503
  return stream;
120202
120504
  }
120203
- function getDeserializeStream(revivers) {
120505
+ function getDeserializeStream(revivers, cryptoKey) {
120204
120506
  const decoder2 = new TextDecoder();
120205
120507
  let buffer = new Uint8Array(0);
120508
+ const keyState = { resolved: false, key: void 0 };
120206
120509
  function appendToBuffer(data) {
120207
120510
  const newBuffer = new Uint8Array(buffer.length + data.length);
120208
120511
  newBuffer.set(buffer, 0);
120209
120512
  newBuffer.set(data, buffer.length);
120210
120513
  buffer = newBuffer;
120211
120514
  }
120212
- function processFrames(controller) {
120515
+ async function processFrames(controller) {
120516
+ if (!keyState.resolved) {
120517
+ keyState.key = await cryptoKey;
120518
+ keyState.resolved = true;
120519
+ }
120213
120520
  while (buffer.length >= FRAME_HEADER_SIZE) {
120214
120521
  const frameLength = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength).getUint32(0, false);
120215
120522
  if (buffer.length < FRAME_HEADER_SIZE + frameLength) {
@@ -120217,38 +120524,46 @@ function getDeserializeStream(revivers) {
120217
120524
  }
120218
120525
  const frameData = buffer.slice(FRAME_HEADER_SIZE, FRAME_HEADER_SIZE + frameLength);
120219
120526
  buffer = buffer.slice(FRAME_HEADER_SIZE + frameLength);
120220
- const { format: format2, payload } = decodeFormatPrefix(frameData);
120527
+ let { format: format2, payload } = decodeFormatPrefix(frameData);
120528
+ if (format2 === SerializationFormat.ENCRYPTED) {
120529
+ if (!keyState.key) {
120530
+ controller.error(new WorkflowRuntimeError("Encrypted stream data encountered but no encryption key is available. Encryption is not configured or no key was provided for this run."));
120531
+ return;
120532
+ }
120533
+ const decrypted = await decrypt(keyState.key, payload);
120534
+ ({ format: format2, payload } = decodeFormatPrefix(decrypted));
120535
+ }
120221
120536
  if (format2 === SerializationFormat.DEVALUE_V1) {
120222
120537
  const text2 = decoder2.decode(payload);
120223
- controller.enqueue(parse$4(text2, revivers));
120538
+ controller.enqueue(parse$7(text2, revivers));
120224
120539
  }
120225
120540
  }
120226
120541
  }
120227
120542
  const stream = new TransformStream({
120228
- transform(chunk, controller) {
120543
+ async transform(chunk, controller) {
120229
120544
  if (buffer.length === 0 && chunk.length >= FRAME_HEADER_SIZE) {
120230
120545
  const possibleLength = new DataView(chunk.buffer, chunk.byteOffset, chunk.byteLength).getUint32(0, false);
120231
120546
  if (possibleLength > 0 && possibleLength < 1e8) {
120232
120547
  appendToBuffer(chunk);
120233
- processFrames(controller);
120548
+ await processFrames(controller);
120234
120549
  return;
120235
120550
  }
120236
120551
  } else if (buffer.length > 0) {
120237
120552
  appendToBuffer(chunk);
120238
- processFrames(controller);
120553
+ await processFrames(controller);
120239
120554
  return;
120240
120555
  }
120241
120556
  const text2 = decoder2.decode(chunk);
120242
120557
  const lines = text2.split("\n");
120243
120558
  for (const line of lines) {
120244
120559
  if (line.length > 0) {
120245
- controller.enqueue(parse$4(line, revivers));
120560
+ controller.enqueue(parse$7(line, revivers));
120246
120561
  }
120247
120562
  }
120248
120563
  },
120249
- flush(controller) {
120564
+ async flush(controller) {
120250
120565
  if (buffer.length > 0) {
120251
- processFrames(controller);
120566
+ await processFrames(controller);
120252
120567
  }
120253
120568
  }
120254
120569
  });
@@ -120478,7 +120793,7 @@ function getCommonReducers(global2 = globalThis) {
120478
120793
  Uint32Array: (value) => value instanceof global2.Uint32Array && viewToBase64(value)
120479
120794
  };
120480
120795
  }
120481
- function getExternalReducers(global2 = globalThis, ops, runId) {
120796
+ function getExternalReducers(global2 = globalThis, ops, runId, cryptoKey) {
120482
120797
  return {
120483
120798
  ...getCommonReducers(global2),
120484
120799
  ReadableStream: (value) => {
@@ -120494,7 +120809,7 @@ function getExternalReducers(global2 = globalThis, ops, runId) {
120494
120809
  if (type === "bytes") {
120495
120810
  ops.push(value.pipeTo(writable));
120496
120811
  } else {
120497
- ops.push(value.pipeThrough(getSerializeStream(getExternalReducers(global2, ops, runId))).pipeTo(writable));
120812
+ ops.push(value.pipeThrough(getSerializeStream(getExternalReducers(global2, ops, runId, cryptoKey), cryptoKey)).pipeTo(writable));
120498
120813
  }
120499
120814
  const s2 = { name: name2 };
120500
120815
  if (type)
@@ -120512,7 +120827,7 @@ function getExternalReducers(global2 = globalThis, ops, runId) {
120512
120827
  }
120513
120828
  };
120514
120829
  }
120515
- function getStepReducers(global2 = globalThis, ops, runId) {
120830
+ function getStepReducers(global2 = globalThis, ops, runId, cryptoKey) {
120516
120831
  return {
120517
120832
  ...getCommonReducers(global2),
120518
120833
  ReadableStream: (value) => {
@@ -120524,9 +120839,6 @@ function getStepReducers(global2 = globalThis, ops, runId) {
120524
120839
  let name2 = value[STREAM_NAME_SYMBOL];
120525
120840
  let type = value[STREAM_TYPE_SYMBOL];
120526
120841
  if (!name2) {
120527
- if (!runId) {
120528
- throw new Error("ReadableStream cannot be serialized without a valid runId");
120529
- }
120530
120842
  const streamId = (global2[STABLE_ULID] || defaultUlid)();
120531
120843
  name2 = `strm_${streamId}`;
120532
120844
  type = getStreamType(value);
@@ -120534,7 +120846,7 @@ function getStepReducers(global2 = globalThis, ops, runId) {
120534
120846
  if (type === "bytes") {
120535
120847
  ops.push(value.pipeTo(writable));
120536
120848
  } else {
120537
- ops.push(value.pipeThrough(getSerializeStream(getStepReducers(global2, ops, runId))).pipeTo(writable));
120849
+ ops.push(value.pipeThrough(getSerializeStream(getStepReducers(global2, ops, runId, cryptoKey), cryptoKey)).pipeTo(writable));
120538
120850
  }
120539
120851
  }
120540
120852
  const s2 = { name: name2 };
@@ -120547,12 +120859,9 @@ function getStepReducers(global2 = globalThis, ops, runId) {
120547
120859
  return false;
120548
120860
  let name2 = value[STREAM_NAME_SYMBOL];
120549
120861
  if (!name2) {
120550
- if (!runId) {
120551
- throw new Error("WritableStream cannot be serialized without a valid runId");
120552
- }
120553
120862
  const streamId = (global2[STABLE_ULID] || defaultUlid)();
120554
120863
  name2 = `strm_${streamId}`;
120555
- ops.push(new WorkflowServerReadableStream(name2).pipeThrough(getDeserializeStream(getStepRevivers(global2, ops, runId))).pipeTo(value));
120864
+ ops.push(new WorkflowServerReadableStream(name2).pipeThrough(getDeserializeStream(getStepRevivers(global2, ops, runId, cryptoKey), cryptoKey)).pipeTo(value));
120556
120865
  }
120557
120866
  return { name: name2 };
120558
120867
  }
@@ -120650,7 +120959,7 @@ function getCommonRevivers(global2 = globalThis) {
120650
120959
  }
120651
120960
  };
120652
120961
  }
120653
- function getExternalRevivers(global2 = globalThis, ops, runId) {
120962
+ function getExternalRevivers(global2 = globalThis, ops, runId, cryptoKey) {
120654
120963
  return {
120655
120964
  ...getCommonRevivers(global2),
120656
120965
  // StepFunction should not be returned from workflows to clients
@@ -120688,7 +120997,7 @@ function getExternalRevivers(global2 = globalThis, ops, runId) {
120688
120997
  pollReadableLock(userReadable, state);
120689
120998
  return userReadable;
120690
120999
  } else {
120691
- const transform2 = getDeserializeStream(getExternalRevivers(global2, ops, runId));
121000
+ const transform2 = getDeserializeStream(getExternalRevivers(global2, ops, runId, cryptoKey), cryptoKey);
120692
121001
  const state = createFlushableState();
120693
121002
  ops.push(state.promise);
120694
121003
  flushablePipe(readable2, transform2.writable, state).catch(() => {
@@ -120698,7 +121007,7 @@ function getExternalRevivers(global2 = globalThis, ops, runId) {
120698
121007
  }
120699
121008
  },
120700
121009
  WritableStream: (value) => {
120701
- const serialize2 = getSerializeStream(getExternalReducers(global2, ops, runId));
121010
+ const serialize2 = getSerializeStream(getExternalReducers(global2, ops, runId, cryptoKey), cryptoKey);
120702
121011
  const serverWritable = new WorkflowServerWritableStream(value.name, runId);
120703
121012
  const state = createFlushableState();
120704
121013
  ops.push(state.promise);
@@ -120773,7 +121082,7 @@ function getWorkflowRevivers(global2 = globalThis) {
120773
121082
  }
120774
121083
  };
120775
121084
  }
120776
- function getStepRevivers(global2 = globalThis, ops, runId) {
121085
+ function getStepRevivers(global2 = globalThis, ops, runId, cryptoKey) {
120777
121086
  return {
120778
121087
  ...getCommonRevivers(global2),
120779
121088
  // StepFunction reviver for step context - returns raw step function
@@ -120853,7 +121162,7 @@ function getStepRevivers(global2 = globalThis, ops, runId) {
120853
121162
  pollReadableLock(userReadable, state);
120854
121163
  return userReadable;
120855
121164
  } else {
120856
- const transform2 = getDeserializeStream(getStepRevivers(global2, ops, runId));
121165
+ const transform2 = getDeserializeStream(getStepRevivers(global2, ops, runId, cryptoKey), cryptoKey);
120857
121166
  const state = createFlushableState();
120858
121167
  ops.push(state.promise);
120859
121168
  flushablePipe(readable2, transform2.writable, state).catch(() => {
@@ -120863,10 +121172,7 @@ function getStepRevivers(global2 = globalThis, ops, runId) {
120863
121172
  }
120864
121173
  },
120865
121174
  WritableStream: (value) => {
120866
- if (!runId) {
120867
- throw new Error("WritableStream cannot be revived without a valid runId");
120868
- }
120869
- const serialize2 = getSerializeStream(getStepReducers(global2, ops, runId));
121175
+ const serialize2 = getSerializeStream(getStepReducers(global2, ops, runId, cryptoKey), cryptoKey);
120870
121176
  const serverWritable = new WorkflowServerWritableStream(value.name, runId);
120871
121177
  const state = createFlushableState();
120872
121178
  ops.push(state.promise);
@@ -120877,29 +121183,50 @@ function getStepRevivers(global2 = globalThis, ops, runId) {
120877
121183
  }
120878
121184
  };
120879
121185
  }
120880
- async function dehydrateWorkflowArguments(value, runId, _key, ops = [], global2 = globalThis, v1Compat = false) {
121186
+ async function maybeEncrypt(data, key) {
121187
+ if (!key)
121188
+ return data;
121189
+ const encrypted = await encrypt(key, data);
121190
+ return encodeWithFormatPrefix(SerializationFormat.ENCRYPTED, encrypted);
121191
+ }
121192
+ async function maybeDecrypt(data, key) {
121193
+ if (!(data instanceof Uint8Array)) {
121194
+ return data;
121195
+ }
121196
+ if (isEncrypted(data)) {
121197
+ if (!key) {
121198
+ throw new WorkflowRuntimeError("Encrypted data encountered but no encryption key is available. Encryption is not configured or no key was provided for this run.");
121199
+ }
121200
+ const { payload } = decodeFormatPrefix(data);
121201
+ return decrypt(key, payload);
121202
+ }
121203
+ return data;
121204
+ }
121205
+ async function dehydrateWorkflowArguments(value, runId, key, ops = [], global2 = globalThis, v1Compat = false) {
120881
121206
  try {
120882
- const str = stringify(value, getExternalReducers(global2, ops, runId));
121207
+ const str = stringify$2(value, getExternalReducers(global2, ops, runId, key));
120883
121208
  if (v1Compat) {
120884
121209
  return revive(str);
120885
121210
  }
120886
121211
  const payload = new TextEncoder().encode(str);
120887
- return encodeWithFormatPrefix(SerializationFormat.DEVALUE_V1, payload);
121212
+ const serialized = encodeWithFormatPrefix(SerializationFormat.DEVALUE_V1, payload);
121213
+ return maybeEncrypt(serialized, key);
120888
121214
  } catch (error2) {
120889
121215
  throw new WorkflowRuntimeError(formatSerializationError("workflow arguments", error2), { slug: "serialization-failed", cause: error2 });
120890
121216
  }
120891
121217
  }
120892
- async function hydrateWorkflowArguments(value, _runId, _key, global2 = globalThis, extraRevivers = {}) {
120893
- if (!(value instanceof Uint8Array)) {
120894
- return unflatten(value, {
121218
+ async function hydrateWorkflowArguments(value, _runId, key, global2 = globalThis, extraRevivers = {}) {
121219
+ const decrypted = await maybeDecrypt(value, key);
121220
+ if (!(decrypted instanceof Uint8Array)) {
121221
+ return unflatten(decrypted, {
120895
121222
  ...getWorkflowRevivers(global2),
120896
121223
  ...extraRevivers
120897
121224
  });
120898
121225
  }
120899
- const { format: format2, payload } = decodeFormatPrefix(value);
121226
+ const { format: format2, payload } = decodeFormatPrefix(decrypted);
120900
121227
  if (format2 === SerializationFormat.DEVALUE_V1) {
120901
121228
  const str = new TextDecoder().decode(payload);
120902
- const obj = parse$4(str, {
121229
+ const obj = parse$7(str, {
120903
121230
  ...getWorkflowRevivers(global2),
120904
121231
  ...extraRevivers
120905
121232
  });
@@ -120907,50 +121234,53 @@ async function hydrateWorkflowArguments(value, _runId, _key, global2 = globalThi
120907
121234
  }
120908
121235
  throw new Error(`Unsupported serialization format: ${format2}`);
120909
121236
  }
120910
- async function hydrateWorkflowReturnValue(value, runId, _key, ops = [], global2 = globalThis, extraRevivers = {}) {
120911
- if (!(value instanceof Uint8Array)) {
120912
- return unflatten(value, {
120913
- ...getExternalRevivers(global2, ops, runId),
121237
+ async function hydrateWorkflowReturnValue(value, runId, key, ops = [], global2 = globalThis, extraRevivers = {}) {
121238
+ const decrypted = await maybeDecrypt(value, key);
121239
+ if (!(decrypted instanceof Uint8Array)) {
121240
+ return unflatten(decrypted, {
121241
+ ...getExternalRevivers(global2, ops, runId, key),
120914
121242
  ...extraRevivers
120915
121243
  });
120916
121244
  }
120917
- const { format: format2, payload } = decodeFormatPrefix(value);
121245
+ const { format: format2, payload } = decodeFormatPrefix(decrypted);
120918
121246
  if (format2 === SerializationFormat.DEVALUE_V1) {
120919
121247
  const str = new TextDecoder().decode(payload);
120920
- const obj = parse$4(str, {
120921
- ...getExternalRevivers(global2, ops, runId),
121248
+ const obj = parse$7(str, {
121249
+ ...getExternalRevivers(global2, ops, runId, key),
120922
121250
  ...extraRevivers
120923
121251
  });
120924
121252
  return obj;
120925
121253
  }
120926
121254
  throw new Error(`Unsupported serialization format: ${format2}`);
120927
121255
  }
120928
- async function hydrateStepArguments(value, runId, _key, ops = [], global2 = globalThis, extraRevivers = {}) {
120929
- if (!(value instanceof Uint8Array)) {
120930
- return unflatten(value, {
120931
- ...getStepRevivers(global2, ops, runId),
121256
+ async function hydrateStepArguments(value, runId, key, ops = [], global2 = globalThis, extraRevivers = {}) {
121257
+ const decrypted = await maybeDecrypt(value, key);
121258
+ if (!(decrypted instanceof Uint8Array)) {
121259
+ return unflatten(decrypted, {
121260
+ ...getStepRevivers(global2, ops, runId, key),
120932
121261
  ...extraRevivers
120933
121262
  });
120934
121263
  }
120935
- const { format: format2, payload } = decodeFormatPrefix(value);
121264
+ const { format: format2, payload } = decodeFormatPrefix(decrypted);
120936
121265
  if (format2 === SerializationFormat.DEVALUE_V1) {
120937
121266
  const str = new TextDecoder().decode(payload);
120938
- const obj = parse$4(str, {
120939
- ...getStepRevivers(global2, ops, runId),
121267
+ const obj = parse$7(str, {
121268
+ ...getStepRevivers(global2, ops, runId, key),
120940
121269
  ...extraRevivers
120941
121270
  });
120942
121271
  return obj;
120943
121272
  }
120944
121273
  throw new Error(`Unsupported serialization format: ${format2}`);
120945
121274
  }
120946
- async function dehydrateStepReturnValue(value, runId, _key, ops = [], global2 = globalThis, v1Compat = false) {
121275
+ async function dehydrateStepReturnValue(value, runId, key, ops = [], global2 = globalThis, v1Compat = false) {
120947
121276
  try {
120948
- const str = stringify(value, getStepReducers(global2, ops, runId));
121277
+ const str = stringify$2(value, getStepReducers(global2, ops, runId, key));
120949
121278
  if (v1Compat) {
120950
121279
  return revive(str);
120951
121280
  }
120952
121281
  const payload = new TextEncoder().encode(str);
120953
- return encodeWithFormatPrefix(SerializationFormat.DEVALUE_V1, payload);
121282
+ const serialized = encodeWithFormatPrefix(SerializationFormat.DEVALUE_V1, payload);
121283
+ return maybeEncrypt(serialized, key);
120954
121284
  } catch (error2) {
120955
121285
  throw new WorkflowRuntimeError(formatSerializationError("step return value", error2), { slug: "serialization-failed", cause: error2 });
120956
121286
  }
@@ -121726,7 +122056,7 @@ async function getHookByTokenWithKey(token) {
121726
122056
  const rawKey = await ((_a3 = world.getEncryptionKeyForRun) == null ? void 0 : _a3.call(world, run));
121727
122057
  const encryptionKey = rawKey ? await importKey(rawKey) : void 0;
121728
122058
  if (typeof hook.metadata !== "undefined") {
121729
- hook.metadata = await hydrateStepArguments(hook.metadata, hook.runId);
122059
+ hook.metadata = await hydrateStepArguments(hook.metadata, hook.runId, encryptionKey);
121730
122060
  }
121731
122061
  return { hook, run, encryptionKey };
121732
122062
  }
@@ -121801,122 +122131,7 @@ async function resumeHook$2(tokenOrHook, payload, encryptionKeyOverride) {
121801
122131
  });
121802
122132
  });
121803
122133
  }
121804
- class Run {
121805
- constructor(runId) {
121806
- /**
121807
- * The ID of the workflow run.
121808
- */
121809
- __publicField(this, "runId");
121810
- /**
121811
- * The world object.
121812
- * @internal
121813
- */
121814
- __publicField(this, "world");
121815
- this.runId = runId;
121816
- this.world = getWorld();
121817
- }
121818
- /**
121819
- * Cancels the workflow run.
121820
- */
121821
- async cancel() {
121822
- await this.world.events.create(this.runId, {
121823
- eventType: "run_cancelled",
121824
- specVersion: SPEC_VERSION_CURRENT
121825
- });
121826
- }
121827
- /**
121828
- * The status of the workflow run.
121829
- */
121830
- get status() {
121831
- return this.world.runs.get(this.runId).then((run) => run.status);
121832
- }
121833
- /**
121834
- * The return value of the workflow run.
121835
- * Polls the workflow return value until it is completed.
121836
- */
121837
- get returnValue() {
121838
- return this.pollReturnValue();
121839
- }
121840
- /**
121841
- * The name of the workflow.
121842
- */
121843
- get workflowName() {
121844
- return this.world.runs.get(this.runId).then((run) => run.workflowName);
121845
- }
121846
- /**
121847
- * The timestamp when the workflow run was created.
121848
- */
121849
- get createdAt() {
121850
- return this.world.runs.get(this.runId).then((run) => run.createdAt);
121851
- }
121852
- /**
121853
- * The timestamp when the workflow run started execution.
121854
- * Returns undefined if the workflow has not started yet.
121855
- */
121856
- get startedAt() {
121857
- return this.world.runs.get(this.runId).then((run) => run.startedAt);
121858
- }
121859
- /**
121860
- * The timestamp when the workflow run completed.
121861
- * Returns undefined if the workflow has not completed yet.
121862
- */
121863
- get completedAt() {
121864
- return this.world.runs.get(this.runId).then((run) => run.completedAt);
121865
- }
121866
- /**
121867
- * The readable stream of the workflow run.
121868
- */
121869
- get readable() {
121870
- return this.getReadable();
121871
- }
121872
- /**
121873
- * Retrieves the workflow run's default readable stream, which reads chunks
121874
- * written to the corresponding writable stream {@link getWritable}.
121875
- *
121876
- * @param options - The options for the readable stream.
121877
- * @returns The `ReadableStream` for the workflow run.
121878
- */
121879
- getReadable(options = {}) {
121880
- const { ops = [], global: global2 = globalThis, startIndex, namespace: namespace2 } = options;
121881
- const name2 = getWorkflowRunStreamId(this.runId, namespace2);
121882
- return getExternalRevivers(global2, ops, this.runId).ReadableStream({
121883
- name: name2,
121884
- startIndex
121885
- });
121886
- }
121887
- /**
121888
- * Polls the workflow return value every 1 second until it is completed.
121889
- * @internal
121890
- * @returns The workflow return value.
121891
- */
121892
- async pollReturnValue() {
121893
- var _a3, _b;
121894
- while (true) {
121895
- try {
121896
- const run = await this.world.runs.get(this.runId);
121897
- if (run.status === "completed") {
121898
- const rawKey = await ((_b = (_a3 = this.world).getEncryptionKeyForRun) == null ? void 0 : _b.call(_a3, run));
121899
- const encryptionKey = rawKey ? await importKey(rawKey) : void 0;
121900
- return await hydrateWorkflowReturnValue(run.output, this.runId, encryptionKey);
121901
- }
121902
- if (run.status === "cancelled") {
121903
- throw new WorkflowRunCancelledError(this.runId);
121904
- }
121905
- if (run.status === "failed") {
121906
- throw new WorkflowRunFailedError(this.runId, run.error);
121907
- }
121908
- throw new WorkflowRunNotCompletedError(this.runId, run.status);
121909
- } catch (error2) {
121910
- if (WorkflowRunNotCompletedError.is(error2)) {
121911
- await new Promise((resolve2) => setTimeout(resolve2, 1e3));
121912
- continue;
121913
- }
121914
- throw error2;
121915
- }
121916
- }
121917
- }
121918
- }
121919
- const version = "4.1.0-beta.62";
122134
+ const version = "4.2.0-beta.64";
121920
122135
  const ulid = monotonicFactory();
121921
122136
  async function start$1(workflow, argsOrOptions, options) {
121922
122137
  return await waitedUntil(() => {
@@ -122098,6 +122313,153 @@ async function wakeUpRun$2(world, runId, options) {
122098
122313
  throw new Error(`Failed to wake up run ${runId}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
122099
122314
  }
122100
122315
  }
122316
+ class Run {
122317
+ constructor(runId) {
122318
+ /**
122319
+ * The ID of the workflow run.
122320
+ */
122321
+ __publicField(this, "runId");
122322
+ /**
122323
+ * The world object.
122324
+ * @internal
122325
+ */
122326
+ __publicField(this, "world");
122327
+ /**
122328
+ * Cached encryption key resolution. Resolved once on first use and
122329
+ * reused for returnValue, getReadable(), etc.
122330
+ * @internal
122331
+ */
122332
+ __publicField(this, "encryptionKeyPromise", null);
122333
+ this.runId = runId;
122334
+ this.world = getWorld();
122335
+ }
122336
+ /**
122337
+ * Resolves and caches the encryption key for this run.
122338
+ * The key is the same for the lifetime of a run, so it only needs
122339
+ * to be resolved once.
122340
+ * @internal
122341
+ */
122342
+ getEncryptionKey() {
122343
+ if (!this.encryptionKeyPromise) {
122344
+ this.encryptionKeyPromise = (async () => {
122345
+ var _a3, _b;
122346
+ const run = await this.world.runs.get(this.runId);
122347
+ const rawKey = await ((_b = (_a3 = this.world).getEncryptionKeyForRun) == null ? void 0 : _b.call(_a3, run));
122348
+ return rawKey ? await importKey(rawKey) : void 0;
122349
+ })();
122350
+ }
122351
+ return this.encryptionKeyPromise;
122352
+ }
122353
+ /**
122354
+ * Interrupts pending `sleep()` calls, resuming the workflow early.
122355
+ *
122356
+ * @param options - Optional settings to target specific sleep calls by correlation ID.
122357
+ * If not provided, all pending sleep calls will be interrupted.
122358
+ * @returns A {@link StopSleepResult} object containing the number of sleep calls that were interrupted.
122359
+ */
122360
+ async wakeUp(options) {
122361
+ return wakeUpRun$2(this.world, this.runId, options);
122362
+ }
122363
+ /**
122364
+ * Cancels the workflow run.
122365
+ */
122366
+ async cancel() {
122367
+ await this.world.events.create(this.runId, {
122368
+ eventType: "run_cancelled",
122369
+ specVersion: SPEC_VERSION_CURRENT
122370
+ });
122371
+ }
122372
+ /**
122373
+ * The status of the workflow run.
122374
+ */
122375
+ get status() {
122376
+ return this.world.runs.get(this.runId).then((run) => run.status);
122377
+ }
122378
+ /**
122379
+ * The return value of the workflow run.
122380
+ * Polls the workflow return value until it is completed.
122381
+ */
122382
+ get returnValue() {
122383
+ return this.pollReturnValue();
122384
+ }
122385
+ /**
122386
+ * The name of the workflow.
122387
+ */
122388
+ get workflowName() {
122389
+ return this.world.runs.get(this.runId).then((run) => run.workflowName);
122390
+ }
122391
+ /**
122392
+ * The timestamp when the workflow run was created.
122393
+ */
122394
+ get createdAt() {
122395
+ return this.world.runs.get(this.runId).then((run) => run.createdAt);
122396
+ }
122397
+ /**
122398
+ * The timestamp when the workflow run started execution.
122399
+ * Returns undefined if the workflow has not started yet.
122400
+ */
122401
+ get startedAt() {
122402
+ return this.world.runs.get(this.runId).then((run) => run.startedAt);
122403
+ }
122404
+ /**
122405
+ * The timestamp when the workflow run completed.
122406
+ * Returns undefined if the workflow has not completed yet.
122407
+ */
122408
+ get completedAt() {
122409
+ return this.world.runs.get(this.runId).then((run) => run.completedAt);
122410
+ }
122411
+ /**
122412
+ * The readable stream of the workflow run.
122413
+ */
122414
+ get readable() {
122415
+ return this.getReadable();
122416
+ }
122417
+ /**
122418
+ * Retrieves the workflow run's default readable stream, which reads chunks
122419
+ * written to the corresponding writable stream {@link getWritable}.
122420
+ *
122421
+ * @param options - The options for the readable stream.
122422
+ * @returns The `ReadableStream` for the workflow run.
122423
+ */
122424
+ getReadable(options = {}) {
122425
+ const { ops = [], global: global2 = globalThis, startIndex, namespace: namespace2 } = options;
122426
+ const name2 = getWorkflowRunStreamId(this.runId, namespace2);
122427
+ const encryptionKey = this.getEncryptionKey();
122428
+ return getExternalRevivers(global2, ops, this.runId, encryptionKey).ReadableStream({
122429
+ name: name2,
122430
+ startIndex
122431
+ });
122432
+ }
122433
+ /**
122434
+ * Polls the workflow return value every 1 second until it is completed.
122435
+ * @internal
122436
+ * @returns The workflow return value.
122437
+ */
122438
+ async pollReturnValue() {
122439
+ while (true) {
122440
+ try {
122441
+ const run = await this.world.runs.get(this.runId);
122442
+ if (run.status === "completed") {
122443
+ const encryptionKey = await this.getEncryptionKey();
122444
+ return await hydrateWorkflowReturnValue(run.output, this.runId, encryptionKey);
122445
+ }
122446
+ if (run.status === "cancelled") {
122447
+ throw new WorkflowRunCancelledError(this.runId);
122448
+ }
122449
+ if (run.status === "failed") {
122450
+ throw new WorkflowRunFailedError(this.runId, run.error);
122451
+ }
122452
+ throw new WorkflowRunNotCompletedError(this.runId, run.status);
122453
+ } catch (error2) {
122454
+ if (WorkflowRunNotCompletedError.is(error2)) {
122455
+ await new Promise((resolve2) => setTimeout(resolve2, 1e3));
122456
+ continue;
122457
+ }
122458
+ throw error2;
122459
+ }
122460
+ }
122461
+ }
122462
+ }
122101
122463
  const DEFAULT_STEP_MAX_RETRIES = 3;
122102
122464
  getWorldHandlers().createQueueHandler("__wkf_step_", async (message_, metadata) => {
122103
122465
  const healthCheck2 = parseHealthCheckPayload(message_);
@@ -122300,7 +122662,8 @@ getWorldHandlers().createQueueHandler("__wkf_step_", async (message_, metadata)
122300
122662
  url: process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : `http://localhost:${port ?? 3e3}`
122301
122663
  },
122302
122664
  ops,
122303
- closureVars: hydratedInput.closureVars
122665
+ closureVars: hydratedInput.closureVars,
122666
+ encryptionKey
122304
122667
  }, () => stepFn.apply(thisVal, args));
122305
122668
  });
122306
122669
  const executionTimeMs = Date.now() - executionStartTime;
@@ -122636,13 +122999,6 @@ async function findWorkflowDataDir(cwd) {
122636
122999
  shortName: getDirShortName(absoluteCwd)
122637
123000
  };
122638
123001
  }
122639
- function createVercelWorld(config2) {
122640
- return {
122641
- ...createQueue$1(config2),
122642
- ...createStorage(config2),
122643
- ...createStreamer(config2)
122644
- };
122645
- }
122646
123002
  function getBackendDisplayName(targetWorld) {
122647
123003
  if (!targetWorld) return "Local";
122648
123004
  switch (targetWorld) {
@@ -123178,8 +123534,8 @@ async function readStreamServerAction(env2, streamId, startIndex) {
123178
123534
  try {
123179
123535
  const world = await getWorldFromEnv(env2);
123180
123536
  const stream = await world.readFromStream(streamId, startIndex);
123181
- const revivers = getExternalRevivers(globalThis, [], "");
123182
- const transform2 = getDeserializeStream(revivers);
123537
+ const revivers = getExternalRevivers(globalThis, [], "", void 0);
123538
+ const transform2 = getDeserializeStream(revivers, void 0);
123183
123539
  return stream.pipeThrough(transform2);
123184
123540
  } catch (error2) {
123185
123541
  const actionError = createServerActionError(error2, "world.readFromStream", {
@@ -123272,6 +123628,23 @@ async function runHealthCheck(worldEnv, endpoint, options) {
123272
123628
  });
123273
123629
  }
123274
123630
  }
123631
+ async function getEncryptionKeyForRun(worldEnv, runId) {
123632
+ try {
123633
+ const world = await getWorldFromEnv(worldEnv);
123634
+ if (!world.getEncryptionKeyForRun) {
123635
+ return createResponse(null);
123636
+ }
123637
+ const run = await world.runs.get(runId);
123638
+ const key = await world.getEncryptionKeyForRun(run);
123639
+ return createResponse(key ?? null);
123640
+ } catch (error2) {
123641
+ return createServerActionError(
123642
+ error2,
123643
+ "getEncryptionKeyForRun",
123644
+ { runId }
123645
+ );
123646
+ }
123647
+ }
123275
123648
  async function loader$2() {
123276
123649
  const serverConfig = await getPublicServerConfig();
123277
123650
  return {
@@ -129035,16 +129408,19 @@ async function fetchResourceWithCorrelationId(env2, resource, resourceId, option
129035
129408
  layer: "client"
129036
129409
  });
129037
129410
  }
129038
- resourceData = hydrateResourceIO(resourceData);
129039
129411
  return { data: resourceData, correlationId };
129040
129412
  }
129041
129413
  function useWorkflowResourceData(env2, resource, resourceId, options = {}) {
129042
- const { refreshInterval = 0, runId, enabled = true } = options;
129414
+ const { refreshInterval = 0, runId, enabled = true, encryptionKey } = options;
129043
129415
  const [data, setData] = reactExports.useState(
129044
129416
  null
129045
129417
  );
129046
129418
  const [loading, setLoading] = reactExports.useState(enabled);
129047
129419
  const [error2, setError] = reactExports.useState(null);
129420
+ const hydrate = reactExports.useCallback(
129421
+ async (resource2) => encryptionKey ? hydrateResourceIOWithKey(resource2, encryptionKey) : hydrateResourceIO(resource2),
129422
+ [encryptionKey]
129423
+ );
129048
129424
  const fetchData = reactExports.useCallback(async () => {
129049
129425
  if (!enabled) {
129050
129426
  setLoading(false);
@@ -129060,7 +129436,13 @@ function useWorkflowResourceData(env2, resource, resourceId, options = {}) {
129060
129436
  setError(error22);
129061
129437
  return;
129062
129438
  }
129063
- setData(hydrateResourceIO(result));
129439
+ try {
129440
+ setData(await hydrate(result));
129441
+ } catch (hydrateError) {
129442
+ setError(
129443
+ hydrateError instanceof Error ? hydrateError : new Error(String(hydrateError))
129444
+ );
129445
+ }
129064
129446
  return;
129065
129447
  }
129066
129448
  if (resource === "sleep") {
@@ -129075,17 +129457,25 @@ function useWorkflowResourceData(env2, resource, resourceId, options = {}) {
129075
129457
  setError(error22);
129076
129458
  return;
129077
129459
  }
129078
- const events2 = result.data.map(hydrateResourceIO);
129079
- const data2 = waitEventsToWaitEntity(events2);
129080
- if (data2 === null) {
129460
+ try {
129461
+ const events2 = await Promise.all(
129462
+ result.data.map(hydrate)
129463
+ );
129464
+ const data2 = waitEventsToWaitEntity(events2);
129465
+ if (data2 === null) {
129466
+ setError(
129467
+ new Error(
129468
+ `Failed to load ${resource} details: missing required event data`
129469
+ )
129470
+ );
129471
+ return;
129472
+ }
129473
+ setData(data2);
129474
+ } catch (hydrateError) {
129081
129475
  setError(
129082
- new Error(
129083
- `Failed to load ${resource} details: missing required event data`
129084
- )
129476
+ hydrateError instanceof Error ? hydrateError : new Error(String(hydrateError))
129085
129477
  );
129086
- return;
129087
129478
  }
129088
- setData(data2);
129089
129479
  return;
129090
129480
  }
129091
129481
  setLoading(true);
@@ -129096,7 +129486,7 @@ function useWorkflowResourceData(env2, resource, resourceId, options = {}) {
129096
129486
  resourceId,
129097
129487
  { runId }
129098
129488
  );
129099
- setData(resourceData);
129489
+ setData(await hydrate(resourceData));
129100
129490
  } catch (error22) {
129101
129491
  if (error22 instanceof Error) {
129102
129492
  setError(error22);
@@ -129107,7 +129497,7 @@ function useWorkflowResourceData(env2, resource, resourceId, options = {}) {
129107
129497
  } finally {
129108
129498
  setLoading(false);
129109
129499
  }
129110
- }, [env2, resource, resourceId, runId, enabled]);
129500
+ }, [env2, resource, resourceId, runId, enabled, hydrate]);
129111
129501
  reactExports.useEffect(() => {
129112
129502
  fetchData();
129113
129503
  }, [fetchData]);
@@ -146527,6 +146917,7 @@ function RunDetailView({
146527
146917
  },
146528
146918
  [env2]
146529
146919
  );
146920
+ const encryptionKeyRef = reactExports.useRef(null);
146530
146921
  const handleResolveHook = reactExports.useCallback(
146531
146922
  async (hookToken, payload) => {
146532
146923
  await resumeHook(env2, hookToken, payload);
@@ -146548,8 +146939,9 @@ function RunDetailView({
146548
146939
  throw error3;
146549
146940
  }
146550
146941
  const rawEvent2 = result2.data.find((e) => e.eventId === event.eventId);
146551
- const fullEvent2 = rawEvent2 ? hydrateResourceIO(rawEvent2) : null;
146552
- if (fullEvent2 && "eventData" in fullEvent2) {
146942
+ if (!rawEvent2) return null;
146943
+ const fullEvent2 = encryptionKeyRef.current ? await hydrateResourceIOWithKey(rawEvent2, encryptionKeyRef.current) : hydrateResourceIO(rawEvent2);
146944
+ if ("eventData" in fullEvent2) {
146553
146945
  return fullEvent2.eventData;
146554
146946
  }
146555
146947
  return null;
@@ -146578,8 +146970,9 @@ function RunDetailView({
146578
146970
  }
146579
146971
  rawEvent = ascResult.data.find((e) => e.eventId === event.eventId);
146580
146972
  }
146581
- const fullEvent = rawEvent ? hydrateResourceIO(rawEvent) : null;
146582
- if (fullEvent && "eventData" in fullEvent) {
146973
+ if (!rawEvent) return null;
146974
+ const fullEvent = encryptionKeyRef.current ? await hydrateResourceIOWithKey(rawEvent, encryptionKeyRef.current) : hydrateResourceIO(rawEvent);
146975
+ if ("eventData" in fullEvent) {
146583
146976
  return fullEvent.eventData;
146584
146977
  }
146585
146978
  return null;
@@ -146599,8 +146992,9 @@ function RunDetailView({
146599
146992
  throw error22;
146600
146993
  }
146601
146994
  const rawEvent = result.data.find((e) => e.eventId === eventId);
146602
- const fullEvent = rawEvent ? hydrateResourceIO(rawEvent) : null;
146603
- if (fullEvent && "eventData" in fullEvent) {
146995
+ if (!rawEvent) return null;
146996
+ const fullEvent = encryptionKeyRef.current ? await hydrateResourceIOWithKey(rawEvent, encryptionKeyRef.current) : hydrateResourceIO(rawEvent);
146997
+ if ("eventData" in fullEvent) {
146604
146998
  return fullEvent.eventData;
146605
146999
  }
146606
147000
  return null;
@@ -146622,13 +147016,16 @@ function RunDetailView({
146622
147016
  isLoadingMoreTraceData
146623
147017
  } = useWorkflowTraceViewerData(env2, runId, { live: true });
146624
147018
  const run = runData ?? {};
147019
+ const [encryptionKey, setEncryptionKey] = reactExports.useState(null);
147020
+ encryptionKeyRef.current = encryptionKey;
146625
147021
  const [spanSelection, setSpanSelection] = reactExports.useState(
146626
147022
  null
146627
147023
  );
146628
147024
  const {
146629
147025
  data: spanDetailData,
146630
147026
  loading: spanDetailLoading,
146631
- error: spanDetailError
147027
+ error: spanDetailError,
147028
+ refresh: refreshSpanDetail
146632
147029
  } = useWorkflowResourceData(
146633
147030
  env2,
146634
147031
  (spanSelection == null ? void 0 : spanSelection.resource) ?? "run",
@@ -146637,9 +147034,26 @@ function RunDetailView({
146637
147034
  runId: spanSelection == null ? void 0 : spanSelection.runId,
146638
147035
  enabled: Boolean(
146639
147036
  (spanSelection == null ? void 0 : spanSelection.resource) && (spanSelection == null ? void 0 : spanSelection.resourceId) && spanSelection.resource !== "hook"
146640
- )
147037
+ ),
147038
+ encryptionKey: encryptionKey ?? void 0
146641
147039
  }
146642
147040
  );
147041
+ const handleDecrypt = reactExports.useCallback(async () => {
147042
+ if (encryptionKey) {
147043
+ refreshSpanDetail();
147044
+ return;
147045
+ }
147046
+ const { error: keyError, result: keyResult } = await unwrapServerActionResult(getEncryptionKeyForRun$1(env2, runId));
147047
+ if (keyError) {
147048
+ toast.error(`Failed to fetch encryption key: ${keyError.message}`);
147049
+ return;
147050
+ }
147051
+ if (!keyResult) {
147052
+ toast.error("Encryption is not configured for this deployment.");
147053
+ return;
147054
+ }
147055
+ setEncryptionKey(keyResult);
147056
+ }, [encryptionKey, env2, runId, refreshSpanDetail]);
146643
147057
  const handleSpanSelect = reactExports.useCallback((info) => {
146644
147058
  setSpanSelection(info);
146645
147059
  }, []);
@@ -146746,6 +147160,24 @@ function RunDetailView({
146746
147160
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("h1", { className: "text-xl font-semibold", children: workflowName ? workflowName : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "w-[260px] h-[28px]" }) }) }),
146747
147161
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
146748
147162
  /* @__PURE__ */ jsxRuntimeExports.jsx(LiveStatus, { hasError, errorMessage }),
147163
+ (isEncryptedMarker(run.input) || isEncryptedMarker(run.output) || isEncryptedMarker(run.error) || allSteps.some(
147164
+ (s2) => isEncryptedMarker(s2.input) || isEncryptedMarker(s2.output)
147165
+ )) && /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
147166
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
147167
+ Button,
147168
+ {
147169
+ variant: "outline",
147170
+ size: "sm",
147171
+ onClick: handleDecrypt,
147172
+ disabled: !!encryptionKey,
147173
+ children: [
147174
+ encryptionKey ? /* @__PURE__ */ jsxRuntimeExports.jsx(LockOpen, { className: "h-4 w-4" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Lock, { className: "h-4 w-4" }),
147175
+ encryptionKey ? "Decrypted" : "Decrypt"
147176
+ ]
147177
+ }
147178
+ ) }) }),
147179
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: encryptionKey ? /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "Data has been decrypted for this workflow run. All encrypted input, output, and event data is now visible across all tabs." }) : /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "This run's data is end-to-end encrypted. Decrypt to reveal input, output, and event data across all tabs for this workflow run." }) })
147180
+ ] }),
146749
147181
  /* @__PURE__ */ jsxRuntimeExports.jsx(
146750
147182
  RunActionsButtons,
146751
147183
  {
@@ -146857,7 +147289,8 @@ function RunDetailView({
146857
147289
  onLoadEventData: handleLoadSidebarEventData,
146858
147290
  onLoadMoreSpans: loadMoreTraceData,
146859
147291
  hasMoreSpans: hasMoreTraceData,
146860
- isLoadingMoreSpans: isLoadingMoreTraceData
147292
+ isLoadingMoreSpans: isLoadingMoreTraceData,
147293
+ encryptionKey: encryptionKey ?? void 0
146861
147294
  }
146862
147295
  ) }) }) }),
146863
147296
  /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "events", className: "mt-0 flex-1 min-h-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary, { title: "Failed to load events list", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -146866,7 +147299,8 @@ function RunDetailView({
146866
147299
  events: allEvents,
146867
147300
  steps: allSteps,
146868
147301
  run,
146869
- onLoadEventData: handleLoadEventData
147302
+ onLoadEventData: handleLoadEventData,
147303
+ encryptionKey: encryptionKey ?? void 0
146870
147304
  }
146871
147305
  ) }) }) }),
146872
147306
  /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "streams", className: "mt-0 flex-1 min-h-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary, { title: "Failed to load stream data", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "h-full flex gap-4", children: [
@@ -147003,6 +147437,7 @@ const handlers = {
147003
147437
  fetchStreams: (p2) => fetchStreams(p2.worldEnv ?? {}, p2.runId),
147004
147438
  fetchWorkflowsManifest: (p2) => fetchWorkflowsManifest(p2.worldEnv ?? {}),
147005
147439
  runHealthCheck: (p2) => runHealthCheck(p2.worldEnv ?? {}, p2.endpoint, p2.options),
147440
+ getEncryptionKeyForRun: (p2) => getEncryptionKeyForRun(p2.worldEnv ?? {}, p2.runId),
147006
147441
  getPublicServerConfig: () => getPublicServerConfig()
147007
147442
  };
147008
147443
  function cborResponse(data, status = 200) {
@@ -147143,7 +147578,7 @@ const route4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
147143
147578
  __proto__: null,
147144
147579
  loader
147145
147580
  }, Symbol.toStringTag, { value: "Module" }));
147146
- const serverManifest = { "entry": { "module": "/assets/entry.client-BjpmGyLC.js", "imports": ["/assets/index-DklpUtP3.js"], "css": [] }, "routes": { "root": { "id": "root", "parentId": void 0, "path": "", "index": void 0, "caseSensitive": void 0, "hasAction": true, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/root-DKF4DBnS.js", "imports": ["/assets/index-DklpUtP3.js", "/assets/mermaid-3ZIDBTTL-Ddgw_y0p.js"], "css": ["/assets/root-Dr_TuMgh.css", "/assets/mermaid-3ZIDBTTL-DKxHcEOp.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/home": { "id": "routes/home", "parentId": "root", "path": void 0, "index": true, "caseSensitive": void 0, "hasAction": false, "hasLoader": false, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/home-DrlgsY_n.js", "imports": ["/assets/index-DklpUtP3.js", "/assets/use-workflow-graph-CUAynhYD.js", "/assets/mermaid-3ZIDBTTL-Ddgw_y0p.js"], "css": ["/assets/use-workflow-graph-yls6qlc0.css", "/assets/mermaid-3ZIDBTTL-DKxHcEOp.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/run-detail": { "id": "routes/run-detail", "parentId": "root", "path": "run/:runId", "index": void 0, "caseSensitive": void 0, "hasAction": false, "hasLoader": false, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/run-detail-DKgwr7Ee.js", "imports": ["/assets/index-DklpUtP3.js", "/assets/use-workflow-graph-CUAynhYD.js", "/assets/mermaid-3ZIDBTTL-Ddgw_y0p.js"], "css": ["/assets/use-workflow-graph-yls6qlc0.css", "/assets/mermaid-3ZIDBTTL-DKxHcEOp.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/api.rpc": { "id": "routes/api.rpc", "parentId": "root", "path": "api/rpc", "index": void 0, "caseSensitive": void 0, "hasAction": true, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": false, "hasErrorBoundary": false, "module": "/assets/api.rpc-l0sNRNKZ.js", "imports": [], "css": [], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/api.stream.$streamId": { "id": "routes/api.stream.$streamId", "parentId": "root", "path": "api/stream/:streamId", "index": void 0, "caseSensitive": void 0, "hasAction": false, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": false, "hasErrorBoundary": false, "module": "/assets/api.stream._streamId-l0sNRNKZ.js", "imports": [], "css": [], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 } }, "url": "/assets/manifest-5132e9b8.js", "version": "5132e9b8", "sri": void 0 };
147581
+ const serverManifest = { "entry": { "module": "/assets/entry.client-BjpmGyLC.js", "imports": ["/assets/index-DklpUtP3.js"], "css": [] }, "routes": { "root": { "id": "root", "parentId": void 0, "path": "", "index": void 0, "caseSensitive": void 0, "hasAction": true, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/root-Ckv-c9_b.js", "imports": ["/assets/index-DklpUtP3.js", "/assets/mermaid-3ZIDBTTL-CJ6mkUFN.js"], "css": ["/assets/root-Dr_TuMgh.css", "/assets/mermaid-3ZIDBTTL-DKxHcEOp.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/home": { "id": "routes/home", "parentId": "root", "path": void 0, "index": true, "caseSensitive": void 0, "hasAction": false, "hasLoader": false, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/home-bWDrLREI.js", "imports": ["/assets/index-DklpUtP3.js", "/assets/use-workflow-graph-JKiMb5g6.js", "/assets/mermaid-3ZIDBTTL-CJ6mkUFN.js"], "css": ["/assets/use-workflow-graph-yls6qlc0.css", "/assets/mermaid-3ZIDBTTL-DKxHcEOp.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/run-detail": { "id": "routes/run-detail", "parentId": "root", "path": "run/:runId", "index": void 0, "caseSensitive": void 0, "hasAction": false, "hasLoader": false, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/run-detail-EcdnCjQk.js", "imports": ["/assets/index-DklpUtP3.js", "/assets/use-workflow-graph-JKiMb5g6.js", "/assets/mermaid-3ZIDBTTL-CJ6mkUFN.js"], "css": ["/assets/use-workflow-graph-yls6qlc0.css", "/assets/mermaid-3ZIDBTTL-DKxHcEOp.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/api.rpc": { "id": "routes/api.rpc", "parentId": "root", "path": "api/rpc", "index": void 0, "caseSensitive": void 0, "hasAction": true, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": false, "hasErrorBoundary": false, "module": "/assets/api.rpc-l0sNRNKZ.js", "imports": [], "css": [], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/api.stream.$streamId": { "id": "routes/api.stream.$streamId", "parentId": "root", "path": "api/stream/:streamId", "index": void 0, "caseSensitive": void 0, "hasAction": false, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": false, "hasErrorBoundary": false, "module": "/assets/api.stream._streamId-l0sNRNKZ.js", "imports": [], "css": [], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 } }, "url": "/assets/manifest-daa82ff1.js", "version": "daa82ff1", "sri": void 0 };
147147
147582
  const assetsBuildDirectory = "build/client";
147148
147583
  const basename = "/";
147149
147584
  const future = { "unstable_optimizeDeps": false, "unstable_subResourceIntegrity": false, "unstable_trailingSlashAwareDataRequests": false, "unstable_previewServerPrerendering": false, "v8_middleware": false, "v8_splitRouteModules": false, "v8_viteEnvironmentApi": false };