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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) 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-Rt-vkvmE.js} +1 -1
  3. package/build/client/assets/{home-DrlgsY_n.js → home-Cpz2_ZDM.js} +1 -1
  4. package/build/client/assets/manifest-069935e6.js +1 -0
  5. package/build/client/assets/{mermaid-3ZIDBTTL-Ddgw_y0p.js → mermaid-3ZIDBTTL-DcdZu9sS.js} +71 -66
  6. package/build/client/assets/{root-DKF4DBnS.js → root-DZgYUaDo.js} +1 -1
  7. package/build/client/assets/run-detail-xcvWVR2B.js +41 -0
  8. package/build/client/assets/{use-workflow-graph-CUAynhYD.js → use-workflow-graph-CF7nLapT.js} +1 -1
  9. package/build/server/assets/{app-BMiBNdAl.js → app-B9Eg2ZwJ.js} +1 -1
  10. package/build/server/assets/{highlighted-body-B3W2YXNL-CzB1YMLj.js → highlighted-body-B3W2YXNL-CppXFHRG.js} +3 -3
  11. package/build/server/assets/{mermaid-3ZIDBTTL-Dqygs4_q.js → mermaid-3ZIDBTTL-DB0PiTjt.js} +3 -3
  12. package/build/server/assets/{server-build-Up-_dwCR.js → server-build-HMYt9inG.js} +2005 -1534
  13. package/build/server/assets/{token-lkNtm8QO.js → token-CBxSSoxh.js} +2 -2
  14. package/build/server/assets/{token-DbisGEEb.js → token-COnBvzNW.js} +3 -3
  15. package/build/server/assets/{token-util-BtczqLw5.js → token-util-7Q4_oN66.js} +2 -2
  16. package/build/server/assets/{token-util-DNmL7drj.js → token-util-CagM_XOH.js} +2 -2
  17. package/build/server/assets/{token-util-pehEj9SJ.js → token-util-QvbM3ECv.js} +1 -1
  18. package/build/server/index.js +1 -1
  19. package/package.json +6 -6
  20. package/build/client/assets/manifest-5132e9b8.js +0 -1
  21. 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-B9Eg2ZwJ.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";
@@ -24,10 +24,10 @@ import minproc from "node:process";
24
24
  import path$2, { join as join$1, resolve, dirname, isAbsolute, sep } from "node:path";
25
25
  import { fileURLToPath } from "node:url";
26
26
  import { createRequire } from "module";
27
- import require$$0$8, { readdir, readlink, readFile, mkdir, access, constants as constants$5, writeFile, unlink } from "node:fs/promises";
27
+ import require$$0$8, { readdir, readlink, readFile, mkdir, access, constants as constants$5, writeFile, unlink, rm } from "node:fs/promises";
28
+ import crypto, { webcrypto } from "node:crypto";
28
29
  import require$$1$2 from "tty";
29
30
  import require$$0$1 from "os";
30
- import crypto, { webcrypto } from "node:crypto";
31
31
  import { createRequire as createRequire$1 } from "node:module";
32
32
  import { execFile } from "node:child_process";
33
33
  import require$$3, { promisify, inspect, types as types$2 } from "node:util";
@@ -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-CppXFHRG.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-DB0PiTjt.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,176 @@ const WaitSchema = object$1({
87113
87334
  updatedAt: date$2(),
87114
87335
  specVersion: number$1().optional()
87115
87336
  });
87337
+ const ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
87338
+ const ENCODING_LEN = 32;
87339
+ const RANDOM_LEN = 16;
87340
+ const TIME_LEN = 10;
87341
+ const TIME_MAX = 281474976710655;
87342
+ var ULIDErrorCode;
87343
+ (function(ULIDErrorCode2) {
87344
+ ULIDErrorCode2["Base32IncorrectEncoding"] = "B32_ENC_INVALID";
87345
+ ULIDErrorCode2["DecodeTimeInvalidCharacter"] = "DEC_TIME_CHAR";
87346
+ ULIDErrorCode2["DecodeTimeValueMalformed"] = "DEC_TIME_MALFORMED";
87347
+ ULIDErrorCode2["EncodeTimeNegative"] = "ENC_TIME_NEG";
87348
+ ULIDErrorCode2["EncodeTimeSizeExceeded"] = "ENC_TIME_SIZE_EXCEED";
87349
+ ULIDErrorCode2["EncodeTimeValueMalformed"] = "ENC_TIME_MALFORMED";
87350
+ ULIDErrorCode2["PRNGDetectFailure"] = "PRNG_DETECT";
87351
+ ULIDErrorCode2["ULIDInvalid"] = "ULID_INVALID";
87352
+ ULIDErrorCode2["Unexpected"] = "UNEXPECTED";
87353
+ ULIDErrorCode2["UUIDInvalid"] = "UUID_INVALID";
87354
+ })(ULIDErrorCode || (ULIDErrorCode = {}));
87355
+ class ULIDError extends Error {
87356
+ constructor(errorCode, message2) {
87357
+ super(`${message2} (${errorCode})`);
87358
+ this.name = "ULIDError";
87359
+ this.code = errorCode;
87360
+ }
87361
+ }
87362
+ function randomChar(prng) {
87363
+ const randomPosition = Math.floor(prng() * ENCODING_LEN) % ENCODING_LEN;
87364
+ return ENCODING.charAt(randomPosition);
87365
+ }
87366
+ function replaceCharAt(str, index2, char) {
87367
+ if (index2 > str.length - 1) {
87368
+ return str;
87369
+ }
87370
+ return str.substr(0, index2) + char + str.substr(index2 + 1);
87371
+ }
87372
+ function incrementBase32(str) {
87373
+ let done = void 0, index2 = str.length, char, charIndex, output = str;
87374
+ const maxCharIndex = ENCODING_LEN - 1;
87375
+ while (!done && index2-- >= 0) {
87376
+ char = output[index2];
87377
+ charIndex = ENCODING.indexOf(char);
87378
+ if (charIndex === -1) {
87379
+ throw new ULIDError(ULIDErrorCode.Base32IncorrectEncoding, "Incorrectly encoded string");
87380
+ }
87381
+ if (charIndex === maxCharIndex) {
87382
+ output = replaceCharAt(output, index2, ENCODING[0]);
87383
+ continue;
87384
+ }
87385
+ done = replaceCharAt(output, index2, ENCODING[charIndex + 1]);
87386
+ }
87387
+ if (typeof done === "string") {
87388
+ return done;
87389
+ }
87390
+ throw new ULIDError(ULIDErrorCode.Base32IncorrectEncoding, "Failed incrementing string");
87391
+ }
87392
+ function decodeTime(id2) {
87393
+ if (id2.length !== TIME_LEN + RANDOM_LEN) {
87394
+ throw new ULIDError(ULIDErrorCode.DecodeTimeValueMalformed, "Malformed ULID");
87395
+ }
87396
+ const time2 = id2.substr(0, TIME_LEN).toUpperCase().split("").reverse().reduce((carry, char, index2) => {
87397
+ const encodingIndex = ENCODING.indexOf(char);
87398
+ if (encodingIndex === -1) {
87399
+ throw new ULIDError(ULIDErrorCode.DecodeTimeInvalidCharacter, `Time decode error: Invalid character: ${char}`);
87400
+ }
87401
+ return carry += encodingIndex * Math.pow(ENCODING_LEN, index2);
87402
+ }, 0);
87403
+ if (time2 > TIME_MAX) {
87404
+ throw new ULIDError(ULIDErrorCode.DecodeTimeValueMalformed, `Malformed ULID: timestamp too large: ${time2}`);
87405
+ }
87406
+ return time2;
87407
+ }
87408
+ function detectPRNG(root2) {
87409
+ var _a3;
87410
+ const rootLookup = detectRoot();
87411
+ const globalCrypto = rootLookup && (rootLookup.crypto || rootLookup.msCrypto) || (typeof crypto !== "undefined" ? crypto : null);
87412
+ if (typeof (globalCrypto == null ? void 0 : globalCrypto.getRandomValues) === "function") {
87413
+ return () => {
87414
+ const buffer = new Uint8Array(1);
87415
+ globalCrypto.getRandomValues(buffer);
87416
+ return buffer[0] / 255;
87417
+ };
87418
+ } else if (typeof (globalCrypto == null ? void 0 : globalCrypto.randomBytes) === "function") {
87419
+ return () => globalCrypto.randomBytes(1).readUInt8() / 255;
87420
+ } else if ((_a3 = crypto) == null ? void 0 : _a3.randomBytes) {
87421
+ return () => crypto.randomBytes(1).readUInt8() / 255;
87422
+ }
87423
+ throw new ULIDError(ULIDErrorCode.PRNGDetectFailure, "Failed to find a reliable PRNG");
87424
+ }
87425
+ function detectRoot() {
87426
+ if (inWebWorker())
87427
+ return self;
87428
+ if (typeof window !== "undefined") {
87429
+ return window;
87430
+ }
87431
+ if (typeof global !== "undefined") {
87432
+ return global;
87433
+ }
87434
+ if (typeof globalThis !== "undefined") {
87435
+ return globalThis;
87436
+ }
87437
+ return null;
87438
+ }
87439
+ function encodeRandom(len, prng) {
87440
+ let str = "";
87441
+ for (; len > 0; len--) {
87442
+ str = randomChar(prng) + str;
87443
+ }
87444
+ return str;
87445
+ }
87446
+ function encodeTime(now2, len = TIME_LEN) {
87447
+ if (isNaN(now2)) {
87448
+ throw new ULIDError(ULIDErrorCode.EncodeTimeValueMalformed, `Time must be a number: ${now2}`);
87449
+ } else if (now2 > TIME_MAX) {
87450
+ throw new ULIDError(ULIDErrorCode.EncodeTimeSizeExceeded, `Cannot encode a time larger than ${TIME_MAX}: ${now2}`);
87451
+ } else if (now2 < 0) {
87452
+ throw new ULIDError(ULIDErrorCode.EncodeTimeNegative, `Time must be positive: ${now2}`);
87453
+ } else if (Number.isInteger(now2) === false) {
87454
+ throw new ULIDError(ULIDErrorCode.EncodeTimeValueMalformed, `Time must be an integer: ${now2}`);
87455
+ }
87456
+ let mod, str = "";
87457
+ for (let currentLen = len; currentLen > 0; currentLen--) {
87458
+ mod = now2 % ENCODING_LEN;
87459
+ str = ENCODING.charAt(mod) + str;
87460
+ now2 = (now2 - mod) / ENCODING_LEN;
87461
+ }
87462
+ return str;
87463
+ }
87464
+ function inWebWorker() {
87465
+ return typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope;
87466
+ }
87467
+ function monotonicFactory(prng) {
87468
+ const currentPRNG = prng || detectPRNG();
87469
+ let lastTime = 0, lastRandom;
87470
+ return function _ulid2(seedTime) {
87471
+ const seed = !seedTime || isNaN(seedTime) ? Date.now() : seedTime;
87472
+ if (seed <= lastTime) {
87473
+ const incrementedRandom = lastRandom = incrementBase32(lastRandom);
87474
+ return encodeTime(lastTime, TIME_LEN) + incrementedRandom;
87475
+ }
87476
+ lastTime = seed;
87477
+ const newRandom = lastRandom = encodeRandom(RANDOM_LEN, currentPRNG);
87478
+ return encodeTime(seed, TIME_LEN) + newRandom;
87479
+ };
87480
+ }
87481
+ const UlidSchema = string$1().ulid();
87482
+ const DEFAULT_TIMESTAMP_THRESHOLD_MS = 5 * 60 * 1e3;
87483
+ function ulidToDate(maybeUlid) {
87484
+ const ulid2 = UlidSchema.safeParse(maybeUlid);
87485
+ if (!ulid2.success) {
87486
+ return null;
87487
+ }
87488
+ return new Date(decodeTime(ulid2.data));
87489
+ }
87490
+ function validateUlidTimestamp(prefixedUlid, prefix, thresholdMs = DEFAULT_TIMESTAMP_THRESHOLD_MS) {
87491
+ const raw2 = prefixedUlid.startsWith(prefix) ? prefixedUlid.slice(prefix.length) : prefixedUlid;
87492
+ const ulidTimestamp = ulidToDate(raw2);
87493
+ if (!ulidTimestamp) {
87494
+ return `Invalid runId: "${prefixedUlid}" is not a valid ULID`;
87495
+ }
87496
+ const serverTimestamp = /* @__PURE__ */ new Date();
87497
+ const driftMs = Math.abs(serverTimestamp.getTime() - ulidTimestamp.getTime());
87498
+ if (driftMs <= thresholdMs) {
87499
+ return null;
87500
+ }
87501
+ const driftSeconds = Math.round(driftMs / 1e3);
87502
+ const thresholdSeconds = Math.round(thresholdMs / 1e3);
87503
+ return `Invalid runId timestamp: embedded timestamp differs from server time by ${driftSeconds}s (threshold: ${thresholdSeconds}s)`;
87504
+ }
87505
+ const NONCE_LENGTH = 12;
87506
+ const TAG_LENGTH = 128;
87116
87507
  const KEY_LENGTH = 32;
87117
87508
  async function importKey(raw2) {
87118
87509
  if (raw2.byteLength !== KEY_LENGTH) {
@@ -87123,6 +87514,30 @@ async function importKey(raw2) {
87123
87514
  "decrypt"
87124
87515
  ]);
87125
87516
  }
87517
+ async function encrypt(key, data) {
87518
+ const nonce = globalThis.crypto.getRandomValues(new Uint8Array(NONCE_LENGTH));
87519
+ const ciphertext = await globalThis.crypto.subtle.encrypt({ name: "AES-GCM", iv: nonce, tagLength: TAG_LENGTH }, key, data);
87520
+ const result = new Uint8Array(NONCE_LENGTH + ciphertext.byteLength);
87521
+ result.set(nonce, 0);
87522
+ result.set(new Uint8Array(ciphertext), NONCE_LENGTH);
87523
+ return result;
87524
+ }
87525
+ async function decrypt(key, data) {
87526
+ const minLength = NONCE_LENGTH + TAG_LENGTH / 8;
87527
+ if (data.byteLength < minLength) {
87528
+ throw new Error(`Encrypted data too short: expected at least ${minLength} bytes, got ${data.byteLength}`);
87529
+ }
87530
+ const nonce = data.subarray(0, NONCE_LENGTH);
87531
+ const ciphertext = data.subarray(NONCE_LENGTH);
87532
+ const plaintext = await globalThis.crypto.subtle.decrypt({ name: "AES-GCM", iv: nonce, tagLength: TAG_LENGTH }, key, ciphertext);
87533
+ return new Uint8Array(plaintext);
87534
+ }
87535
+ const encryption = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
87536
+ __proto__: null,
87537
+ decrypt,
87538
+ encrypt,
87539
+ importKey
87540
+ }, Symbol.toStringTag, { value: "Module" }));
87126
87541
  class WorkflowSuspension extends Error {
87127
87542
  constructor(stepsInput, global2) {
87128
87543
  const steps = [...stepsInput.values()];
@@ -88046,150 +88461,6 @@ const runtimeLogger = createLogger("runtime");
88046
88461
  createLogger("webhook");
88047
88462
  createLogger("events");
88048
88463
  createLogger("adapter");
88049
- const ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
88050
- const ENCODING_LEN = 32;
88051
- const RANDOM_LEN = 16;
88052
- const TIME_LEN = 10;
88053
- const TIME_MAX = 281474976710655;
88054
- var ULIDErrorCode;
88055
- (function(ULIDErrorCode2) {
88056
- ULIDErrorCode2["Base32IncorrectEncoding"] = "B32_ENC_INVALID";
88057
- ULIDErrorCode2["DecodeTimeInvalidCharacter"] = "DEC_TIME_CHAR";
88058
- ULIDErrorCode2["DecodeTimeValueMalformed"] = "DEC_TIME_MALFORMED";
88059
- ULIDErrorCode2["EncodeTimeNegative"] = "ENC_TIME_NEG";
88060
- ULIDErrorCode2["EncodeTimeSizeExceeded"] = "ENC_TIME_SIZE_EXCEED";
88061
- ULIDErrorCode2["EncodeTimeValueMalformed"] = "ENC_TIME_MALFORMED";
88062
- ULIDErrorCode2["PRNGDetectFailure"] = "PRNG_DETECT";
88063
- ULIDErrorCode2["ULIDInvalid"] = "ULID_INVALID";
88064
- ULIDErrorCode2["Unexpected"] = "UNEXPECTED";
88065
- ULIDErrorCode2["UUIDInvalid"] = "UUID_INVALID";
88066
- })(ULIDErrorCode || (ULIDErrorCode = {}));
88067
- class ULIDError extends Error {
88068
- constructor(errorCode, message2) {
88069
- super(`${message2} (${errorCode})`);
88070
- this.name = "ULIDError";
88071
- this.code = errorCode;
88072
- }
88073
- }
88074
- function randomChar(prng) {
88075
- const randomPosition = Math.floor(prng() * ENCODING_LEN) % ENCODING_LEN;
88076
- return ENCODING.charAt(randomPosition);
88077
- }
88078
- function replaceCharAt(str, index2, char) {
88079
- if (index2 > str.length - 1) {
88080
- return str;
88081
- }
88082
- return str.substr(0, index2) + char + str.substr(index2 + 1);
88083
- }
88084
- function incrementBase32(str) {
88085
- let done = void 0, index2 = str.length, char, charIndex, output = str;
88086
- const maxCharIndex = ENCODING_LEN - 1;
88087
- while (!done && index2-- >= 0) {
88088
- char = output[index2];
88089
- charIndex = ENCODING.indexOf(char);
88090
- if (charIndex === -1) {
88091
- throw new ULIDError(ULIDErrorCode.Base32IncorrectEncoding, "Incorrectly encoded string");
88092
- }
88093
- if (charIndex === maxCharIndex) {
88094
- output = replaceCharAt(output, index2, ENCODING[0]);
88095
- continue;
88096
- }
88097
- done = replaceCharAt(output, index2, ENCODING[charIndex + 1]);
88098
- }
88099
- if (typeof done === "string") {
88100
- return done;
88101
- }
88102
- throw new ULIDError(ULIDErrorCode.Base32IncorrectEncoding, "Failed incrementing string");
88103
- }
88104
- function decodeTime(id2) {
88105
- if (id2.length !== TIME_LEN + RANDOM_LEN) {
88106
- throw new ULIDError(ULIDErrorCode.DecodeTimeValueMalformed, "Malformed ULID");
88107
- }
88108
- const time2 = id2.substr(0, TIME_LEN).toUpperCase().split("").reverse().reduce((carry, char, index2) => {
88109
- const encodingIndex = ENCODING.indexOf(char);
88110
- if (encodingIndex === -1) {
88111
- throw new ULIDError(ULIDErrorCode.DecodeTimeInvalidCharacter, `Time decode error: Invalid character: ${char}`);
88112
- }
88113
- return carry += encodingIndex * Math.pow(ENCODING_LEN, index2);
88114
- }, 0);
88115
- if (time2 > TIME_MAX) {
88116
- throw new ULIDError(ULIDErrorCode.DecodeTimeValueMalformed, `Malformed ULID: timestamp too large: ${time2}`);
88117
- }
88118
- return time2;
88119
- }
88120
- function detectPRNG(root2) {
88121
- var _a3;
88122
- const rootLookup = detectRoot();
88123
- const globalCrypto = rootLookup && (rootLookup.crypto || rootLookup.msCrypto) || (typeof crypto !== "undefined" ? crypto : null);
88124
- if (typeof (globalCrypto == null ? void 0 : globalCrypto.getRandomValues) === "function") {
88125
- return () => {
88126
- const buffer = new Uint8Array(1);
88127
- globalCrypto.getRandomValues(buffer);
88128
- return buffer[0] / 255;
88129
- };
88130
- } else if (typeof (globalCrypto == null ? void 0 : globalCrypto.randomBytes) === "function") {
88131
- return () => globalCrypto.randomBytes(1).readUInt8() / 255;
88132
- } else if ((_a3 = crypto) == null ? void 0 : _a3.randomBytes) {
88133
- return () => crypto.randomBytes(1).readUInt8() / 255;
88134
- }
88135
- throw new ULIDError(ULIDErrorCode.PRNGDetectFailure, "Failed to find a reliable PRNG");
88136
- }
88137
- function detectRoot() {
88138
- if (inWebWorker())
88139
- return self;
88140
- if (typeof window !== "undefined") {
88141
- return window;
88142
- }
88143
- if (typeof global !== "undefined") {
88144
- return global;
88145
- }
88146
- if (typeof globalThis !== "undefined") {
88147
- return globalThis;
88148
- }
88149
- return null;
88150
- }
88151
- function encodeRandom(len, prng) {
88152
- let str = "";
88153
- for (; len > 0; len--) {
88154
- str = randomChar(prng) + str;
88155
- }
88156
- return str;
88157
- }
88158
- function encodeTime(now2, len = TIME_LEN) {
88159
- if (isNaN(now2)) {
88160
- throw new ULIDError(ULIDErrorCode.EncodeTimeValueMalformed, `Time must be a number: ${now2}`);
88161
- } else if (now2 > TIME_MAX) {
88162
- throw new ULIDError(ULIDErrorCode.EncodeTimeSizeExceeded, `Cannot encode a time larger than ${TIME_MAX}: ${now2}`);
88163
- } else if (now2 < 0) {
88164
- throw new ULIDError(ULIDErrorCode.EncodeTimeNegative, `Time must be positive: ${now2}`);
88165
- } else if (Number.isInteger(now2) === false) {
88166
- throw new ULIDError(ULIDErrorCode.EncodeTimeValueMalformed, `Time must be an integer: ${now2}`);
88167
- }
88168
- let mod, str = "";
88169
- for (let currentLen = len; currentLen > 0; currentLen--) {
88170
- mod = now2 % ENCODING_LEN;
88171
- str = ENCODING.charAt(mod) + str;
88172
- now2 = (now2 - mod) / ENCODING_LEN;
88173
- }
88174
- return str;
88175
- }
88176
- function inWebWorker() {
88177
- return typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope;
88178
- }
88179
- function monotonicFactory(prng) {
88180
- const currentPRNG = prng || detectPRNG();
88181
- let lastTime = 0, lastRandom;
88182
- return function _ulid2(seedTime) {
88183
- const seed = !seedTime || isNaN(seedTime) ? Date.now() : seedTime;
88184
- if (seed <= lastTime) {
88185
- const incrementedRandom = lastRandom = incrementBase32(lastRandom);
88186
- return encodeTime(lastTime, TIME_LEN) + incrementedRandom;
88187
- }
88188
- lastTime = seed;
88189
- const newRandom = lastRandom = encodeRandom(RANDOM_LEN, currentPRNG);
88190
- return encodeTime(seed, TIME_LEN) + newRandom;
88191
- };
88192
- }
88193
88464
  const execFileAsync = promisify(execFile);
88194
88465
  function parsePort$1(value, radix = 10) {
88195
88466
  const port = parseInt(value, radix);
@@ -89153,8 +89424,8 @@ function requireGetVercelOidcToken$1() {
89153
89424
  }
89154
89425
  try {
89155
89426
  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)
89427
+ await import("./token-util-CagM_XOH.js").then((n) => n.t),
89428
+ await import("./token-COnBvzNW.js").then((n) => n.t)
89158
89429
  ]);
89159
89430
  if (!token || isExpired(getTokenPayload(token))) {
89160
89431
  await refreshToken();
@@ -115274,6 +115545,7 @@ function createQueue$2(config2) {
115274
115545
  const generateId2 = monotonicFactory();
115275
115546
  const semaphore = new libExports.Sema(WORKFLOW_LOCAL_QUEUE_CONCURRENCY);
115276
115547
  const inflightMessages = /* @__PURE__ */ new Map();
115548
+ const directHandlers = /* @__PURE__ */ new Map();
115277
115549
  const queue = async (queueName, message2, opts) => {
115278
115550
  const cleanup = [];
115279
115551
  if (opts == null ? void 0 : opts.idempotencyKey) {
@@ -115284,10 +115556,13 @@ function createQueue$2(config2) {
115284
115556
  }
115285
115557
  const body2 = transport.serialize(message2);
115286
115558
  let pathname;
115559
+ let prefix;
115287
115560
  if (queueName.startsWith("__wkf_step_")) {
115288
115561
  pathname = `step`;
115562
+ prefix = "__wkf_step_";
115289
115563
  } else if (queueName.startsWith("__wkf_workflow_")) {
115290
115564
  pathname = `flow`;
115565
+ prefix = "__wkf_workflow_";
115291
115566
  } else {
115292
115567
  throw new Error("Unknown queue name prefix");
115293
115568
  }
@@ -115307,22 +115582,34 @@ function createQueue$2(config2) {
115307
115582
  }
115308
115583
  try {
115309
115584
  let defaultRetriesLeft = 3;
115310
- const baseUrl = await resolveBaseUrl$1(config2);
115585
+ const directHandler = directHandlers.get(prefix);
115311
115586
  for (let attempt = 0; defaultRetriesLeft > 0; attempt++) {
115312
115587
  defaultRetriesLeft--;
115313
- const response2 = await fetch(`${baseUrl}/.well-known/workflow/v1/${pathname}`, {
115314
- method: "POST",
115315
- duplex: "half",
115316
- dispatcher: httpAgent,
115317
- headers: {
115318
- ...opts == null ? void 0 : opts.headers,
115319
- "content-type": "application/json",
115320
- "x-vqs-queue-name": queueName,
115321
- "x-vqs-message-id": messageId,
115322
- "x-vqs-message-attempt": String(attempt + 1)
115323
- },
115324
- body: body2
115325
- });
115588
+ let response2;
115589
+ const headers2 = {
115590
+ ...opts == null ? void 0 : opts.headers,
115591
+ "content-type": "application/json",
115592
+ "x-vqs-queue-name": queueName,
115593
+ "x-vqs-message-id": messageId,
115594
+ "x-vqs-message-attempt": String(attempt + 1)
115595
+ };
115596
+ if (directHandler) {
115597
+ const req = new Request("http://localhost/.well-known/workflow/v1/" + pathname, {
115598
+ method: "POST",
115599
+ headers: headers2,
115600
+ body: body2
115601
+ });
115602
+ response2 = await directHandler(req);
115603
+ } else {
115604
+ const baseUrl = await resolveBaseUrl$1(config2);
115605
+ response2 = await fetch(`${baseUrl}/.well-known/workflow/v1/${pathname}`, {
115606
+ method: "POST",
115607
+ duplex: "half",
115608
+ dispatcher: httpAgent,
115609
+ headers: headers2,
115610
+ body: body2
115611
+ });
115612
+ }
115326
115613
  if (response2.ok) {
115327
115614
  return;
115328
115615
  }
@@ -115404,6 +115691,9 @@ function createQueue$2(config2) {
115404
115691
  queue,
115405
115692
  createQueueHandler,
115406
115693
  getDeploymentId,
115694
+ registerHandler(prefix, handler) {
115695
+ directHandlers.set(prefix, handler);
115696
+ },
115407
115697
  async close() {
115408
115698
  await httpAgent.close();
115409
115699
  }
@@ -115505,7 +115795,6 @@ function instrumentObject$1(prefix, o) {
115505
115795
  return handlers2;
115506
115796
  }
115507
115797
  const ulid$1 = monotonicFactory(() => Math.random());
115508
- const Ulid = string$1().ulid();
115509
115798
  const isWindows = process.platform === "win32";
115510
115799
  async function withWindowsRetry(fn2, maxRetries = 5) {
115511
115800
  if (!isWindows)
@@ -115526,13 +115815,6 @@ async function withWindowsRetry(fn2, maxRetries = 5) {
115526
115815
  throw new Error("Retry loop exited unexpectedly");
115527
115816
  }
115528
115817
  const createdFilesCache = /* @__PURE__ */ new Set();
115529
- function ulidToDate(maybeUlid) {
115530
- const ulid2 = Ulid.safeParse(maybeUlid);
115531
- if (!ulid2.success) {
115532
- return null;
115533
- }
115534
- return new Date(decodeTime(ulid2.data));
115535
- }
115536
115818
  async function ensureDir(dirPath) {
115537
115819
  try {
115538
115820
  await promises.mkdir(dirPath, { recursive: true });
@@ -115773,7 +116055,7 @@ function createHooksStorage(basedir) {
115773
116055
  const hookPath = path$2.join(hooksDir, `${file2}.json`);
115774
116056
  const hook = await readJSON(hookPath, HookSchema);
115775
116057
  if (hook && hook.token === token) {
115776
- return hook;
116058
+ return { ...hook, isWebhook: hook.isWebhook ?? true };
115777
116059
  }
115778
116060
  }
115779
116061
  return null;
@@ -115782,15 +116064,15 @@ function createHooksStorage(basedir) {
115782
116064
  const hookPath = path$2.join(basedir, "hooks", `${hookId}.json`);
115783
116065
  const hook = await readJSON(hookPath, HookSchema);
115784
116066
  if (!hook) {
115785
- throw new Error(`Hook ${hookId} not found`);
116067
+ throw new HookNotFoundError(hookId);
115786
116068
  }
115787
116069
  const resolveData = (params == null ? void 0 : params.resolveData) || DEFAULT_RESOLVE_DATA_OPTION$1;
115788
- return filterHookData$1(hook, resolveData);
116070
+ return filterHookData$1({ ...hook, isWebhook: hook.isWebhook ?? true }, resolveData);
115789
116071
  }
115790
116072
  async function getByToken(token) {
115791
116073
  const hook = await findHookByToken(token);
115792
116074
  if (!hook) {
115793
- throw new Error(`Hook with token ${token} not found`);
116075
+ throw new HookNotFoundError(token);
115794
116076
  }
115795
116077
  return hook;
115796
116078
  }
@@ -115801,7 +116083,7 @@ function createHooksStorage(basedir) {
115801
116083
  const result = await paginatedFileSystemQuery({
115802
116084
  directory: hooksDir,
115803
116085
  schema: HookSchema,
115804
- sortOrder: (_a3 = params.pagination) == null ? void 0 : _a3.sortOrder,
116086
+ sortOrder: ((_a3 = params.pagination) == null ? void 0 : _a3.sortOrder) ?? "asc",
115805
116087
  limit: (_b = params.pagination) == null ? void 0 : _b.limit,
115806
116088
  cursor: (_c = params.pagination) == null ? void 0 : _c.cursor,
115807
116089
  filePrefix: void 0,
@@ -115813,7 +116095,7 @@ function createHooksStorage(basedir) {
115813
116095
  return true;
115814
116096
  },
115815
116097
  getCreatedAt: () => {
115816
- return /* @__PURE__ */ new Date(0);
116098
+ return null;
115817
116099
  },
115818
116100
  getId: (hook) => hook.hookId
115819
116101
  });
@@ -115908,6 +116190,12 @@ function createEventsStorage(basedir) {
115908
116190
  } else {
115909
116191
  effectiveRunId = runId;
115910
116192
  }
116193
+ if (data.eventType === "run_created" && runId && runId !== "") {
116194
+ const validationError = validateUlidTimestamp(effectiveRunId, "wrun_");
116195
+ if (validationError) {
116196
+ throw new WorkflowAPIError(validationError, { status: 400 });
116197
+ }
116198
+ }
115911
116199
  const effectiveSpecVersion = data.specVersion ?? SPEC_VERSION_CURRENT;
115912
116200
  const isRunTerminal = (status) => ["completed", "failed", "cancelled"].includes(status);
115913
116201
  const isStepTerminal = (status) => ["completed", "failed"].includes(status);
@@ -116271,7 +116559,8 @@ function createEventsStorage(basedir) {
116271
116559
  environment: "local",
116272
116560
  createdAt: now2,
116273
116561
  // Propagate specVersion from the event to the hook entity
116274
- specVersion: effectiveSpecVersion
116562
+ specVersion: effectiveSpecVersion,
116563
+ isWebhook: hookData.isWebhook ?? false
116275
116564
  };
116276
116565
  const hookPath = path$2.join(basedir, "hooks", `${data.correlationId}.json`);
116277
116566
  await writeJSON(hookPath, hook);
@@ -116702,6 +116991,10 @@ function createLocalWorld(args) {
116702
116991
  },
116703
116992
  async close() {
116704
116993
  await queue.close();
116994
+ },
116995
+ async clear() {
116996
+ await rm(mergedConfig.dataDir, { recursive: true, force: true });
116997
+ await initDataDir(mergedConfig.dataDir);
116705
116998
  }
116706
116999
  };
116707
117000
  }
@@ -116823,8 +117116,8 @@ function requireGetVercelOidcToken() {
116823
117116
  }
116824
117117
  try {
116825
117118
  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)
117119
+ await import("./token-util-7Q4_oN66.js").then((n) => n.t),
117120
+ await import("./token-CBxSSoxh.js").then((n) => n.t)
116828
117121
  ]);
116829
117122
  if (!token || isExpired(getTokenPayload(token), options == null ? void 0 : options.expirationBufferMs)) {
116830
117123
  await refreshToken(options);
@@ -117473,7 +117766,7 @@ function createGetEncryptionKeyForRun(projectId, teamId, token) {
117473
117766
  localDeploymentKey = Buffer.from(deploymentKeyBase64, "base64");
117474
117767
  return localDeploymentKey;
117475
117768
  }
117476
- return async function getEncryptionKeyForRun(run, context) {
117769
+ return async function getEncryptionKeyForRun2(run, context) {
117477
117770
  const runId = typeof run === "string" ? run : run.runId;
117478
117771
  const deploymentId = typeof run === "string" ? context == null ? void 0 : context.deploymentId : run.deploymentId;
117479
117772
  if (!deploymentId || deploymentId === currentDeploymentId) {
@@ -117543,7 +117836,7 @@ const PeerService = SemanticConvention("peer.service");
117543
117836
  const RpcSystem = SemanticConvention("rpc.system");
117544
117837
  const RpcService = SemanticConvention("rpc.service");
117545
117838
  const RpcMethod = SemanticConvention("rpc.method");
117546
- const version$1 = "4.1.0-beta.36";
117839
+ const version$1 = "4.1.0-beta.39";
117547
117840
  const DEFAULT_RESOLVE_DATA_OPTION = "all";
117548
117841
  function deserializeError(obj) {
117549
117842
  const { error: error2, ...rest } = obj;
@@ -118168,12 +118461,18 @@ function filterEventData(event, resolveData) {
118168
118461
  }
118169
118462
  return event;
118170
118463
  }
118171
- const EventResultWireSchema = z.object({
118464
+ const EventResultResolveWireSchema = z.object({
118172
118465
  event: EventSchema,
118173
118466
  run: WorkflowRunSchema.optional(),
118174
118467
  step: StepWireSchema.optional(),
118175
118468
  hook: HookSchema.optional()
118176
118469
  });
118470
+ const EventResultLazyWireSchema = z.object({
118471
+ event: EventSchema,
118472
+ run: WorkflowRunWireBaseSchema.optional(),
118473
+ step: StepWireSchema.optional(),
118474
+ hook: HookSchema.optional()
118475
+ });
118177
118476
  const EventWithRefsSchema = z.object({
118178
118477
  eventId: z.string(),
118179
118478
  runId: z.string(),
@@ -118360,18 +118659,39 @@ async function createWorkflowRunEvent(id2, data, params, config2) {
118360
118659
  });
118361
118660
  return { event: wireResult2 };
118362
118661
  }
118662
+ if (data.eventType === "run_created" && id2) {
118663
+ const validationError = validateUlidTimestamp(id2, "wrun_");
118664
+ if (validationError) {
118665
+ throw new WorkflowAPIError(validationError, { status: 400 });
118666
+ }
118667
+ }
118363
118668
  const runIdPath = id2 === null ? "null" : id2;
118364
118669
  const remoteRefBehavior = eventsNeedingResolve.has(data.eventType) ? "resolve" : "lazy";
118670
+ if (remoteRefBehavior === "resolve") {
118671
+ const wireResult2 = await makeRequest({
118672
+ endpoint: `/v2/runs/${runIdPath}/events`,
118673
+ options: { method: "POST" },
118674
+ data: { ...data, remoteRefBehavior },
118675
+ config: config2,
118676
+ schema: EventResultResolveWireSchema
118677
+ });
118678
+ return {
118679
+ event: filterEventData(wireResult2.event, resolveData),
118680
+ run: wireResult2.run,
118681
+ step: wireResult2.step ? deserializeStep(wireResult2.step) : void 0,
118682
+ hook: wireResult2.hook
118683
+ };
118684
+ }
118365
118685
  const wireResult = await makeRequest({
118366
118686
  endpoint: `/v2/runs/${runIdPath}/events`,
118367
118687
  options: { method: "POST" },
118368
118688
  data: { ...data, remoteRefBehavior },
118369
118689
  config: config2,
118370
- schema: EventResultWireSchema
118690
+ schema: EventResultLazyWireSchema
118371
118691
  });
118372
118692
  return {
118373
118693
  event: filterEventData(wireResult.event, resolveData),
118374
- run: wireResult.run,
118694
+ run: wireResult.run ? deserializeError(wireResult.run) : void 0,
118375
118695
  step: wireResult.step ? deserializeStep(wireResult.step) : void 0,
118376
118696
  hook: wireResult.hook
118377
118697
  };
@@ -118426,14 +118746,21 @@ async function getHook(hookId, params, config2) {
118426
118746
  return filterHookData(hook, resolveData);
118427
118747
  }
118428
118748
  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
- });
118749
+ try {
118750
+ return await makeRequest({
118751
+ endpoint: `/v2/hooks/by-token?token=${encodeURIComponent(token)}`,
118752
+ options: {
118753
+ method: "GET"
118754
+ },
118755
+ config: config2,
118756
+ schema: HookSchema
118757
+ });
118758
+ } catch (error2) {
118759
+ if (WorkflowAPIError.is(error2) && error2.status === 404) {
118760
+ throw new HookNotFoundError(token);
118761
+ }
118762
+ throw error2;
118763
+ }
118437
118764
  }
118438
118765
  const WORKFLOW_SERVER_SERVICE = {
118439
118766
  peerService: "workflow-server",
@@ -118600,7 +118927,7 @@ function createStreamer(config2) {
118600
118927
  }
118601
118928
  };
118602
118929
  }
118603
- function createVercelWorld$1(config2) {
118930
+ function createVercelWorld(config2) {
118604
118931
  var _a3, _b;
118605
118932
  const projectId = ((_a3 = config2 == null ? void 0 : config2.projectConfig) == null ? void 0 : _a3.projectId) || process.env.VERCEL_PROJECT_ID;
118606
118933
  return {
@@ -118623,7 +118950,7 @@ function defaultWorld() {
118623
118950
  const createWorld = () => {
118624
118951
  const targetWorld = process.env.WORKFLOW_TARGET_WORLD || defaultWorld();
118625
118952
  if (targetWorld === "vercel") {
118626
- return createVercelWorld$1({
118953
+ return createVercelWorld({
118627
118954
  token: process.env.WORKFLOW_VERCEL_AUTH_TOKEN,
118628
118955
  projectConfig: {
118629
118956
  environment: process.env.WORKFLOW_VERCEL_ENV,
@@ -120119,7 +120446,9 @@ function getStepFunction(stepId) {
120119
120446
  }
120120
120447
  const SerializationFormat = {
120121
120448
  /** devalue stringify/parse with TextEncoder/TextDecoder */
120122
- DEVALUE_V1: "devl"
120449
+ DEVALUE_V1: "devl",
120450
+ /** Encrypted payload (inner payload has its own format prefix) */
120451
+ ENCRYPTED: "encr"
120123
120452
  };
120124
120453
  const FORMAT_PREFIX_LENGTH = 4;
120125
120454
  const formatEncoder = new TextEncoder();
@@ -120137,6 +120466,21 @@ function encodeWithFormatPrefix(format2, payload) {
120137
120466
  result.set(payload, FORMAT_PREFIX_LENGTH);
120138
120467
  return result;
120139
120468
  }
120469
+ function peekFormatPrefix(data) {
120470
+ if (!(data instanceof Uint8Array) || data.length < FORMAT_PREFIX_LENGTH) {
120471
+ return null;
120472
+ }
120473
+ const prefixBytes = data.subarray(0, FORMAT_PREFIX_LENGTH);
120474
+ const format2 = formatDecoder.decode(prefixBytes);
120475
+ const knownFormats = Object.values(SerializationFormat);
120476
+ if (!knownFormats.includes(format2)) {
120477
+ return null;
120478
+ }
120479
+ return format2;
120480
+ }
120481
+ function isEncrypted(data) {
120482
+ return peekFormatPrefix(data) === SerializationFormat.ENCRYPTED;
120483
+ }
120140
120484
  function decodeFormatPrefix(data) {
120141
120485
  if (!(data instanceof Uint8Array)) {
120142
120486
  return {
@@ -120151,7 +120495,7 @@ function decodeFormatPrefix(data) {
120151
120495
  const format2 = formatDecoder.decode(prefixBytes);
120152
120496
  const knownFormats = Object.values(SerializationFormat);
120153
120497
  if (!knownFormats.includes(format2)) {
120154
- throw new Error(`Unknown serialization format: "${format2}". Known formats: ${knownFormats.join(", ")}`);
120498
+ throw new WorkflowRuntimeError(`Unknown serialization format: "${format2}". Known formats: ${knownFormats.join(", ")}`);
120155
120499
  }
120156
120500
  const payload = data.subarray(FORMAT_PREFIX_LENGTH);
120157
120501
  return { format: format2, payload };
@@ -120180,18 +120524,27 @@ function getStreamType(stream) {
120180
120524
  } catch {
120181
120525
  }
120182
120526
  }
120183
- const FRAME_HEADER_SIZE = 4;
120184
- function getSerializeStream(reducers) {
120527
+ const FRAME_HEADER_SIZE$1 = 4;
120528
+ function getSerializeStream(reducers, cryptoKey) {
120185
120529
  const encoder = new TextEncoder();
120530
+ const keyState = { resolved: false, key: void 0 };
120186
120531
  const stream = new TransformStream({
120187
- transform(chunk, controller) {
120532
+ async transform(chunk, controller) {
120188
120533
  try {
120189
- const serialized = stringify(chunk, reducers);
120534
+ if (!keyState.resolved) {
120535
+ keyState.key = await cryptoKey;
120536
+ keyState.resolved = true;
120537
+ }
120538
+ const serialized = stringify$2(chunk, reducers);
120190
120539
  const payload = encoder.encode(serialized);
120191
- const prefixed = encodeWithFormatPrefix(SerializationFormat.DEVALUE_V1, payload);
120192
- const frame2 = new Uint8Array(FRAME_HEADER_SIZE + prefixed.length);
120540
+ let prefixed = encodeWithFormatPrefix(SerializationFormat.DEVALUE_V1, payload);
120541
+ if (keyState.key) {
120542
+ const encrypted = await encrypt(keyState.key, prefixed);
120543
+ prefixed = encodeWithFormatPrefix(SerializationFormat.ENCRYPTED, encrypted);
120544
+ }
120545
+ const frame2 = new Uint8Array(FRAME_HEADER_SIZE$1 + prefixed.length);
120193
120546
  new DataView(frame2.buffer).setUint32(0, prefixed.length, false);
120194
- frame2.set(prefixed, FRAME_HEADER_SIZE);
120547
+ frame2.set(prefixed, FRAME_HEADER_SIZE$1);
120195
120548
  controller.enqueue(frame2);
120196
120549
  } catch (error2) {
120197
120550
  controller.error(new WorkflowRuntimeError(formatSerializationError("stream chunk", error2), { slug: "serialization-failed", cause: error2 }));
@@ -120200,55 +120553,68 @@ function getSerializeStream(reducers) {
120200
120553
  });
120201
120554
  return stream;
120202
120555
  }
120203
- function getDeserializeStream(revivers) {
120556
+ function getDeserializeStream(revivers, cryptoKey) {
120204
120557
  const decoder2 = new TextDecoder();
120205
120558
  let buffer = new Uint8Array(0);
120559
+ const keyState = { resolved: false, key: void 0 };
120206
120560
  function appendToBuffer(data) {
120207
120561
  const newBuffer = new Uint8Array(buffer.length + data.length);
120208
120562
  newBuffer.set(buffer, 0);
120209
120563
  newBuffer.set(data, buffer.length);
120210
120564
  buffer = newBuffer;
120211
120565
  }
120212
- function processFrames(controller) {
120213
- while (buffer.length >= FRAME_HEADER_SIZE) {
120566
+ async function processFrames(controller) {
120567
+ if (!keyState.resolved) {
120568
+ keyState.key = await cryptoKey;
120569
+ keyState.resolved = true;
120570
+ }
120571
+ while (buffer.length >= FRAME_HEADER_SIZE$1) {
120214
120572
  const frameLength = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength).getUint32(0, false);
120215
- if (buffer.length < FRAME_HEADER_SIZE + frameLength) {
120573
+ if (buffer.length < FRAME_HEADER_SIZE$1 + frameLength) {
120216
120574
  break;
120217
120575
  }
120218
- const frameData = buffer.slice(FRAME_HEADER_SIZE, FRAME_HEADER_SIZE + frameLength);
120219
- buffer = buffer.slice(FRAME_HEADER_SIZE + frameLength);
120220
- const { format: format2, payload } = decodeFormatPrefix(frameData);
120576
+ const frameData = buffer.slice(FRAME_HEADER_SIZE$1, FRAME_HEADER_SIZE$1 + frameLength);
120577
+ buffer = buffer.slice(FRAME_HEADER_SIZE$1 + frameLength);
120578
+ let { format: format2, payload } = decodeFormatPrefix(frameData);
120579
+ if (format2 === SerializationFormat.ENCRYPTED) {
120580
+ if (!keyState.key) {
120581
+ 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."));
120582
+ return;
120583
+ }
120584
+ const decrypted = await decrypt(keyState.key, payload);
120585
+ ({ format: format2, payload } = decodeFormatPrefix(decrypted));
120586
+ }
120221
120587
  if (format2 === SerializationFormat.DEVALUE_V1) {
120222
120588
  const text2 = decoder2.decode(payload);
120223
- controller.enqueue(parse$4(text2, revivers));
120589
+ controller.enqueue(parse$7(text2, revivers));
120224
120590
  }
120225
120591
  }
120226
120592
  }
120227
120593
  const stream = new TransformStream({
120228
- transform(chunk, controller) {
120229
- if (buffer.length === 0 && chunk.length >= FRAME_HEADER_SIZE) {
120594
+ async transform(chunk, controller) {
120595
+ if (buffer.length === 0 && chunk.length >= FRAME_HEADER_SIZE$1) {
120230
120596
  const possibleLength = new DataView(chunk.buffer, chunk.byteOffset, chunk.byteLength).getUint32(0, false);
120231
120597
  if (possibleLength > 0 && possibleLength < 1e8) {
120232
120598
  appendToBuffer(chunk);
120233
- processFrames(controller);
120599
+ await processFrames(controller);
120234
120600
  return;
120235
120601
  }
120236
120602
  } else if (buffer.length > 0) {
120237
120603
  appendToBuffer(chunk);
120238
- processFrames(controller);
120604
+ await processFrames(controller);
120239
120605
  return;
120240
120606
  }
120241
120607
  const text2 = decoder2.decode(chunk);
120242
120608
  const lines = text2.split("\n");
120243
120609
  for (const line of lines) {
120244
120610
  if (line.length > 0) {
120245
- controller.enqueue(parse$4(line, revivers));
120611
+ controller.enqueue(parse$7(line, revivers));
120246
120612
  }
120247
120613
  }
120248
120614
  },
120249
- flush(controller) {
120615
+ async flush(controller) {
120250
120616
  if (buffer.length > 0) {
120251
- processFrames(controller);
120617
+ await processFrames(controller);
120252
120618
  }
120253
120619
  }
120254
120620
  });
@@ -120478,7 +120844,7 @@ function getCommonReducers(global2 = globalThis) {
120478
120844
  Uint32Array: (value) => value instanceof global2.Uint32Array && viewToBase64(value)
120479
120845
  };
120480
120846
  }
120481
- function getExternalReducers(global2 = globalThis, ops, runId) {
120847
+ function getExternalReducers(global2 = globalThis, ops, runId, cryptoKey) {
120482
120848
  return {
120483
120849
  ...getCommonReducers(global2),
120484
120850
  ReadableStream: (value) => {
@@ -120494,7 +120860,7 @@ function getExternalReducers(global2 = globalThis, ops, runId) {
120494
120860
  if (type === "bytes") {
120495
120861
  ops.push(value.pipeTo(writable));
120496
120862
  } else {
120497
- ops.push(value.pipeThrough(getSerializeStream(getExternalReducers(global2, ops, runId))).pipeTo(writable));
120863
+ ops.push(value.pipeThrough(getSerializeStream(getExternalReducers(global2, ops, runId, cryptoKey), cryptoKey)).pipeTo(writable));
120498
120864
  }
120499
120865
  const s2 = { name: name2 };
120500
120866
  if (type)
@@ -120512,7 +120878,7 @@ function getExternalReducers(global2 = globalThis, ops, runId) {
120512
120878
  }
120513
120879
  };
120514
120880
  }
120515
- function getStepReducers(global2 = globalThis, ops, runId) {
120881
+ function getStepReducers(global2 = globalThis, ops, runId, cryptoKey) {
120516
120882
  return {
120517
120883
  ...getCommonReducers(global2),
120518
120884
  ReadableStream: (value) => {
@@ -120524,9 +120890,6 @@ function getStepReducers(global2 = globalThis, ops, runId) {
120524
120890
  let name2 = value[STREAM_NAME_SYMBOL];
120525
120891
  let type = value[STREAM_TYPE_SYMBOL];
120526
120892
  if (!name2) {
120527
- if (!runId) {
120528
- throw new Error("ReadableStream cannot be serialized without a valid runId");
120529
- }
120530
120893
  const streamId = (global2[STABLE_ULID] || defaultUlid)();
120531
120894
  name2 = `strm_${streamId}`;
120532
120895
  type = getStreamType(value);
@@ -120534,7 +120897,7 @@ function getStepReducers(global2 = globalThis, ops, runId) {
120534
120897
  if (type === "bytes") {
120535
120898
  ops.push(value.pipeTo(writable));
120536
120899
  } else {
120537
- ops.push(value.pipeThrough(getSerializeStream(getStepReducers(global2, ops, runId))).pipeTo(writable));
120900
+ ops.push(value.pipeThrough(getSerializeStream(getStepReducers(global2, ops, runId, cryptoKey), cryptoKey)).pipeTo(writable));
120538
120901
  }
120539
120902
  }
120540
120903
  const s2 = { name: name2 };
@@ -120547,12 +120910,9 @@ function getStepReducers(global2 = globalThis, ops, runId) {
120547
120910
  return false;
120548
120911
  let name2 = value[STREAM_NAME_SYMBOL];
120549
120912
  if (!name2) {
120550
- if (!runId) {
120551
- throw new Error("WritableStream cannot be serialized without a valid runId");
120552
- }
120553
120913
  const streamId = (global2[STABLE_ULID] || defaultUlid)();
120554
120914
  name2 = `strm_${streamId}`;
120555
- ops.push(new WorkflowServerReadableStream(name2).pipeThrough(getDeserializeStream(getStepRevivers(global2, ops, runId))).pipeTo(value));
120915
+ ops.push(new WorkflowServerReadableStream(name2).pipeThrough(getDeserializeStream(getStepRevivers(global2, ops, runId, cryptoKey), cryptoKey)).pipeTo(value));
120556
120916
  }
120557
120917
  return { name: name2 };
120558
120918
  }
@@ -120650,7 +121010,7 @@ function getCommonRevivers(global2 = globalThis) {
120650
121010
  }
120651
121011
  };
120652
121012
  }
120653
- function getExternalRevivers(global2 = globalThis, ops, runId) {
121013
+ function getExternalRevivers(global2 = globalThis, ops, runId, cryptoKey) {
120654
121014
  return {
120655
121015
  ...getCommonRevivers(global2),
120656
121016
  // StepFunction should not be returned from workflows to clients
@@ -120688,7 +121048,7 @@ function getExternalRevivers(global2 = globalThis, ops, runId) {
120688
121048
  pollReadableLock(userReadable, state);
120689
121049
  return userReadable;
120690
121050
  } else {
120691
- const transform2 = getDeserializeStream(getExternalRevivers(global2, ops, runId));
121051
+ const transform2 = getDeserializeStream(getExternalRevivers(global2, ops, runId, cryptoKey), cryptoKey);
120692
121052
  const state = createFlushableState();
120693
121053
  ops.push(state.promise);
120694
121054
  flushablePipe(readable2, transform2.writable, state).catch(() => {
@@ -120698,7 +121058,7 @@ function getExternalRevivers(global2 = globalThis, ops, runId) {
120698
121058
  }
120699
121059
  },
120700
121060
  WritableStream: (value) => {
120701
- const serialize2 = getSerializeStream(getExternalReducers(global2, ops, runId));
121061
+ const serialize2 = getSerializeStream(getExternalReducers(global2, ops, runId, cryptoKey), cryptoKey);
120702
121062
  const serverWritable = new WorkflowServerWritableStream(value.name, runId);
120703
121063
  const state = createFlushableState();
120704
121064
  ops.push(state.promise);
@@ -120773,7 +121133,7 @@ function getWorkflowRevivers(global2 = globalThis) {
120773
121133
  }
120774
121134
  };
120775
121135
  }
120776
- function getStepRevivers(global2 = globalThis, ops, runId) {
121136
+ function getStepRevivers(global2 = globalThis, ops, runId, cryptoKey) {
120777
121137
  return {
120778
121138
  ...getCommonRevivers(global2),
120779
121139
  // StepFunction reviver for step context - returns raw step function
@@ -120853,7 +121213,7 @@ function getStepRevivers(global2 = globalThis, ops, runId) {
120853
121213
  pollReadableLock(userReadable, state);
120854
121214
  return userReadable;
120855
121215
  } else {
120856
- const transform2 = getDeserializeStream(getStepRevivers(global2, ops, runId));
121216
+ const transform2 = getDeserializeStream(getStepRevivers(global2, ops, runId, cryptoKey), cryptoKey);
120857
121217
  const state = createFlushableState();
120858
121218
  ops.push(state.promise);
120859
121219
  flushablePipe(readable2, transform2.writable, state).catch(() => {
@@ -120863,10 +121223,7 @@ function getStepRevivers(global2 = globalThis, ops, runId) {
120863
121223
  }
120864
121224
  },
120865
121225
  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));
121226
+ const serialize2 = getSerializeStream(getStepReducers(global2, ops, runId, cryptoKey), cryptoKey);
120870
121227
  const serverWritable = new WorkflowServerWritableStream(value.name, runId);
120871
121228
  const state = createFlushableState();
120872
121229
  ops.push(state.promise);
@@ -120877,29 +121234,50 @@ function getStepRevivers(global2 = globalThis, ops, runId) {
120877
121234
  }
120878
121235
  };
120879
121236
  }
120880
- async function dehydrateWorkflowArguments(value, runId, _key, ops = [], global2 = globalThis, v1Compat = false) {
121237
+ async function maybeEncrypt(data, key) {
121238
+ if (!key)
121239
+ return data;
121240
+ const encrypted = await encrypt(key, data);
121241
+ return encodeWithFormatPrefix(SerializationFormat.ENCRYPTED, encrypted);
121242
+ }
121243
+ async function maybeDecrypt(data, key) {
121244
+ if (!(data instanceof Uint8Array)) {
121245
+ return data;
121246
+ }
121247
+ if (isEncrypted(data)) {
121248
+ if (!key) {
121249
+ throw new WorkflowRuntimeError("Encrypted data encountered but no encryption key is available. Encryption is not configured or no key was provided for this run.");
121250
+ }
121251
+ const { payload } = decodeFormatPrefix(data);
121252
+ return decrypt(key, payload);
121253
+ }
121254
+ return data;
121255
+ }
121256
+ async function dehydrateWorkflowArguments(value, runId, key, ops = [], global2 = globalThis, v1Compat = false) {
120881
121257
  try {
120882
- const str = stringify(value, getExternalReducers(global2, ops, runId));
121258
+ const str = stringify$2(value, getExternalReducers(global2, ops, runId, key));
120883
121259
  if (v1Compat) {
120884
121260
  return revive(str);
120885
121261
  }
120886
121262
  const payload = new TextEncoder().encode(str);
120887
- return encodeWithFormatPrefix(SerializationFormat.DEVALUE_V1, payload);
121263
+ const serialized = encodeWithFormatPrefix(SerializationFormat.DEVALUE_V1, payload);
121264
+ return maybeEncrypt(serialized, key);
120888
121265
  } catch (error2) {
120889
121266
  throw new WorkflowRuntimeError(formatSerializationError("workflow arguments", error2), { slug: "serialization-failed", cause: error2 });
120890
121267
  }
120891
121268
  }
120892
- async function hydrateWorkflowArguments(value, _runId, _key, global2 = globalThis, extraRevivers = {}) {
120893
- if (!(value instanceof Uint8Array)) {
120894
- return unflatten(value, {
121269
+ async function hydrateWorkflowArguments(value, _runId, key, global2 = globalThis, extraRevivers = {}) {
121270
+ const decrypted = await maybeDecrypt(value, key);
121271
+ if (!(decrypted instanceof Uint8Array)) {
121272
+ return unflatten(decrypted, {
120895
121273
  ...getWorkflowRevivers(global2),
120896
121274
  ...extraRevivers
120897
121275
  });
120898
121276
  }
120899
- const { format: format2, payload } = decodeFormatPrefix(value);
121277
+ const { format: format2, payload } = decodeFormatPrefix(decrypted);
120900
121278
  if (format2 === SerializationFormat.DEVALUE_V1) {
120901
121279
  const str = new TextDecoder().decode(payload);
120902
- const obj = parse$4(str, {
121280
+ const obj = parse$7(str, {
120903
121281
  ...getWorkflowRevivers(global2),
120904
121282
  ...extraRevivers
120905
121283
  });
@@ -120907,50 +121285,53 @@ async function hydrateWorkflowArguments(value, _runId, _key, global2 = globalThi
120907
121285
  }
120908
121286
  throw new Error(`Unsupported serialization format: ${format2}`);
120909
121287
  }
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),
121288
+ async function hydrateWorkflowReturnValue(value, runId, key, ops = [], global2 = globalThis, extraRevivers = {}) {
121289
+ const decrypted = await maybeDecrypt(value, key);
121290
+ if (!(decrypted instanceof Uint8Array)) {
121291
+ return unflatten(decrypted, {
121292
+ ...getExternalRevivers(global2, ops, runId, key),
120914
121293
  ...extraRevivers
120915
121294
  });
120916
121295
  }
120917
- const { format: format2, payload } = decodeFormatPrefix(value);
121296
+ const { format: format2, payload } = decodeFormatPrefix(decrypted);
120918
121297
  if (format2 === SerializationFormat.DEVALUE_V1) {
120919
121298
  const str = new TextDecoder().decode(payload);
120920
- const obj = parse$4(str, {
120921
- ...getExternalRevivers(global2, ops, runId),
121299
+ const obj = parse$7(str, {
121300
+ ...getExternalRevivers(global2, ops, runId, key),
120922
121301
  ...extraRevivers
120923
121302
  });
120924
121303
  return obj;
120925
121304
  }
120926
121305
  throw new Error(`Unsupported serialization format: ${format2}`);
120927
121306
  }
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),
121307
+ async function hydrateStepArguments(value, runId, key, ops = [], global2 = globalThis, extraRevivers = {}) {
121308
+ const decrypted = await maybeDecrypt(value, key);
121309
+ if (!(decrypted instanceof Uint8Array)) {
121310
+ return unflatten(decrypted, {
121311
+ ...getStepRevivers(global2, ops, runId, key),
120932
121312
  ...extraRevivers
120933
121313
  });
120934
121314
  }
120935
- const { format: format2, payload } = decodeFormatPrefix(value);
121315
+ const { format: format2, payload } = decodeFormatPrefix(decrypted);
120936
121316
  if (format2 === SerializationFormat.DEVALUE_V1) {
120937
121317
  const str = new TextDecoder().decode(payload);
120938
- const obj = parse$4(str, {
120939
- ...getStepRevivers(global2, ops, runId),
121318
+ const obj = parse$7(str, {
121319
+ ...getStepRevivers(global2, ops, runId, key),
120940
121320
  ...extraRevivers
120941
121321
  });
120942
121322
  return obj;
120943
121323
  }
120944
121324
  throw new Error(`Unsupported serialization format: ${format2}`);
120945
121325
  }
120946
- async function dehydrateStepReturnValue(value, runId, _key, ops = [], global2 = globalThis, v1Compat = false) {
121326
+ async function dehydrateStepReturnValue(value, runId, key, ops = [], global2 = globalThis, v1Compat = false) {
120947
121327
  try {
120948
- const str = stringify(value, getStepReducers(global2, ops, runId));
121328
+ const str = stringify$2(value, getStepReducers(global2, ops, runId, key));
120949
121329
  if (v1Compat) {
120950
121330
  return revive(str);
120951
121331
  }
120952
121332
  const payload = new TextEncoder().encode(str);
120953
- return encodeWithFormatPrefix(SerializationFormat.DEVALUE_V1, payload);
121333
+ const serialized = encodeWithFormatPrefix(SerializationFormat.DEVALUE_V1, payload);
121334
+ return maybeEncrypt(serialized, key);
120954
121335
  } catch (error2) {
120955
121336
  throw new WorkflowRuntimeError(formatSerializationError("step return value", error2), { slug: "serialization-failed", cause: error2 });
120956
121337
  }
@@ -121726,7 +122107,7 @@ async function getHookByTokenWithKey(token) {
121726
122107
  const rawKey = await ((_a3 = world.getEncryptionKeyForRun) == null ? void 0 : _a3.call(world, run));
121727
122108
  const encryptionKey = rawKey ? await importKey(rawKey) : void 0;
121728
122109
  if (typeof hook.metadata !== "undefined") {
121729
- hook.metadata = await hydrateStepArguments(hook.metadata, hook.runId);
122110
+ hook.metadata = await hydrateStepArguments(hook.metadata, hook.runId, encryptionKey);
121730
122111
  }
121731
122112
  return { hook, run, encryptionKey };
121732
122113
  }
@@ -121801,6 +122182,188 @@ async function resumeHook$2(tokenOrHook, payload, encryptionKeyOverride) {
121801
122182
  });
121802
122183
  });
121803
122184
  }
122185
+ const version = "4.2.0-beta.65";
122186
+ const ulid = monotonicFactory();
122187
+ async function start$1(workflow, argsOrOptions, options) {
122188
+ return await waitedUntil(() => {
122189
+ const workflowName = workflow == null ? void 0 : workflow.workflowId;
122190
+ if (!workflowName) {
122191
+ throw new WorkflowRuntimeError(`'start' received an invalid workflow function. Ensure the Workflow Development Kit is configured correctly and the function includes a 'use workflow' directive.`, { slug: "start-invalid-workflow-function" });
122192
+ }
122193
+ return trace$2(`workflow.start ${workflowName}`, async (span) => {
122194
+ var _a3;
122195
+ span == null ? void 0 : span.setAttributes({
122196
+ ...WorkflowName(workflowName),
122197
+ ...WorkflowOperation("start")
122198
+ });
122199
+ let args = [];
122200
+ let opts = options ?? {};
122201
+ if (Array.isArray(argsOrOptions)) {
122202
+ args = argsOrOptions;
122203
+ } else if (typeof argsOrOptions === "object") {
122204
+ opts = argsOrOptions;
122205
+ }
122206
+ span == null ? void 0 : span.setAttributes({
122207
+ ...WorkflowArgumentsCount(args.length)
122208
+ });
122209
+ const world = (opts == null ? void 0 : opts.world) ?? getWorld();
122210
+ const deploymentId = opts.deploymentId ?? await world.getDeploymentId();
122211
+ const ops = [];
122212
+ const runId = `wrun_${ulid()}`;
122213
+ const traceCarrier = await serializeTraceCarrier();
122214
+ const specVersion = opts.specVersion ?? SPEC_VERSION_CURRENT;
122215
+ const v1Compat = isLegacySpecVersion(specVersion);
122216
+ const rawKey = await ((_a3 = world.getEncryptionKeyForRun) == null ? void 0 : _a3.call(world, runId, { ...opts }));
122217
+ const encryptionKey = rawKey ? await importKey(rawKey) : void 0;
122218
+ const workflowArguments = await dehydrateWorkflowArguments(args, runId, encryptionKey, ops, globalThis, v1Compat);
122219
+ const result = await world.events.create(runId, {
122220
+ eventType: "run_created",
122221
+ specVersion,
122222
+ eventData: {
122223
+ deploymentId,
122224
+ workflowName,
122225
+ input: workflowArguments,
122226
+ executionContext: { traceCarrier, workflowCoreVersion: version }
122227
+ }
122228
+ }, { v1Compat });
122229
+ if (!result.run) {
122230
+ throw new WorkflowRuntimeError("Missing 'run' in server response for 'run_created' event");
122231
+ }
122232
+ if (!v1Compat && result.run.runId !== runId) {
122233
+ throw new WorkflowRuntimeError(`Server returned different runId than requested: expected ${runId}, got ${result.run.runId}`);
122234
+ }
122235
+ functionsExports.waitUntil(Promise.all(ops).catch((err) => {
122236
+ const isAbortError = (err == null ? void 0 : err.name) === "AbortError" || (err == null ? void 0 : err.name) === "ResponseAborted";
122237
+ if (!isAbortError)
122238
+ throw err;
122239
+ }));
122240
+ span == null ? void 0 : span.setAttributes({
122241
+ ...WorkflowRunId(runId),
122242
+ ...WorkflowRunStatus(result.run.status),
122243
+ ...DeploymentId(deploymentId)
122244
+ });
122245
+ await world.queue(getWorkflowQueueName(workflowName), {
122246
+ runId,
122247
+ traceCarrier
122248
+ }, {
122249
+ deploymentId
122250
+ });
122251
+ return new Run(runId);
122252
+ });
122253
+ });
122254
+ }
122255
+ const normalizeWorkflowArgs = (args) => {
122256
+ return Array.isArray(args) ? args : [args];
122257
+ };
122258
+ async function recreateRunFromExisting(world, runId, options = {}) {
122259
+ var _a3;
122260
+ try {
122261
+ const run = await world.runs.get(runId, { resolveData: "all" });
122262
+ const rawKey = await ((_a3 = world.getEncryptionKeyForRun) == null ? void 0 : _a3.call(world, run));
122263
+ const encryptionKey = rawKey ? await importKey(rawKey) : void 0;
122264
+ const workflowArgs = normalizeWorkflowArgs(await hydrateWorkflowArguments(run.input, runId, encryptionKey, globalThis));
122265
+ const specVersion = options.specVersion ?? run.specVersion ?? SPEC_VERSION_LEGACY;
122266
+ const deploymentId = options.deploymentId ?? run.deploymentId;
122267
+ const newRun = await start$1({ workflowId: run.workflowName }, workflowArgs, {
122268
+ deploymentId,
122269
+ world,
122270
+ specVersion
122271
+ });
122272
+ return newRun.runId;
122273
+ } catch (err) {
122274
+ throw new Error(`Failed to recreate run from ${runId}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
122275
+ }
122276
+ }
122277
+ async function cancelRun$2(world, runId) {
122278
+ try {
122279
+ const run = await world.runs.get(runId, { resolveData: "none" });
122280
+ const specVersion = run.specVersion ?? SPEC_VERSION_LEGACY;
122281
+ const compatMode = isLegacySpecVersion(specVersion);
122282
+ const eventData = {
122283
+ eventType: "run_cancelled",
122284
+ specVersion
122285
+ };
122286
+ await world.events.create(runId, eventData, { v1Compat: compatMode });
122287
+ } catch (err) {
122288
+ throw new Error(`Failed to cancel run ${runId}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
122289
+ }
122290
+ }
122291
+ async function reenqueueRun$2(world, runId) {
122292
+ try {
122293
+ const run = await world.runs.get(runId, { resolveData: "none" });
122294
+ await world.queue(getWorkflowQueueName(run.workflowName), {
122295
+ runId
122296
+ }, {
122297
+ deploymentId: run.deploymentId
122298
+ });
122299
+ } catch (err) {
122300
+ throw new Error(`Failed to re-enqueue run ${runId}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
122301
+ }
122302
+ }
122303
+ async function wakeUpRun$2(world, runId, options) {
122304
+ try {
122305
+ const run = await world.runs.get(runId, { resolveData: "none" });
122306
+ const compatMode = isLegacySpecVersion(run.specVersion);
122307
+ const allEvents = [];
122308
+ let cursor = null;
122309
+ do {
122310
+ const eventsResult = await world.events.list({
122311
+ runId,
122312
+ pagination: { limit: 1e3, ...cursor ? { cursor } : {} },
122313
+ resolveData: "none"
122314
+ });
122315
+ allEvents.push(...eventsResult.data);
122316
+ cursor = eventsResult.hasMore ? eventsResult.cursor : null;
122317
+ } while (cursor);
122318
+ const waitCreatedEvents = allEvents.filter((event) => event.eventType === "wait_created");
122319
+ const waitCompletedCorrelationIds = new Set(allEvents.filter((event) => event.eventType === "wait_completed").map((event) => event.correlationId));
122320
+ let pendingWaits = waitCreatedEvents.filter((event) => !waitCompletedCorrelationIds.has(event.correlationId));
122321
+ if ((options == null ? void 0 : options.correlationIds) && options.correlationIds.length > 0) {
122322
+ const targetCorrelationIds = new Set(options.correlationIds);
122323
+ pendingWaits = pendingWaits.filter((event) => event.correlationId && targetCorrelationIds.has(event.correlationId));
122324
+ }
122325
+ const errors2 = [];
122326
+ let stoppedCount = 0;
122327
+ for (const waitEvent of pendingWaits) {
122328
+ if (!waitEvent.correlationId)
122329
+ continue;
122330
+ const eventData = compatMode ? {
122331
+ eventType: "wait_completed",
122332
+ correlationId: waitEvent.correlationId
122333
+ } : {
122334
+ eventType: "wait_completed",
122335
+ correlationId: waitEvent.correlationId,
122336
+ specVersion: run.specVersion
122337
+ };
122338
+ try {
122339
+ await world.events.create(runId, eventData, { v1Compat: compatMode });
122340
+ stoppedCount++;
122341
+ } catch (err) {
122342
+ if (WorkflowAPIError.is(err) && err.status === 409) {
122343
+ stoppedCount++;
122344
+ } else {
122345
+ errors2.push(err instanceof Error ? err : new Error(String(err)));
122346
+ }
122347
+ }
122348
+ }
122349
+ if (stoppedCount > 0) {
122350
+ await world.queue(getWorkflowQueueName(run.workflowName), {
122351
+ runId
122352
+ }, {
122353
+ deploymentId: run.deploymentId
122354
+ });
122355
+ }
122356
+ if (errors2.length > 0) {
122357
+ throw new AggregateError(errors2, `Failed to complete ${errors2.length}/${pendingWaits.length} pending wait(s) for run ${runId}`);
122358
+ }
122359
+ return { stoppedCount };
122360
+ } catch (err) {
122361
+ if (err instanceof AggregateError) {
122362
+ throw err;
122363
+ }
122364
+ throw new Error(`Failed to wake up run ${runId}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
122365
+ }
122366
+ }
121804
122367
  class Run {
121805
122368
  constructor(runId) {
121806
122369
  /**
@@ -121812,9 +122375,42 @@ class Run {
121812
122375
  * @internal
121813
122376
  */
121814
122377
  __publicField(this, "world");
122378
+ /**
122379
+ * Cached encryption key resolution. Resolved once on first use and
122380
+ * reused for returnValue, getReadable(), etc.
122381
+ * @internal
122382
+ */
122383
+ __publicField(this, "encryptionKeyPromise", null);
121815
122384
  this.runId = runId;
121816
122385
  this.world = getWorld();
121817
122386
  }
122387
+ /**
122388
+ * Resolves and caches the encryption key for this run.
122389
+ * The key is the same for the lifetime of a run, so it only needs
122390
+ * to be resolved once.
122391
+ * @internal
122392
+ */
122393
+ getEncryptionKey() {
122394
+ if (!this.encryptionKeyPromise) {
122395
+ this.encryptionKeyPromise = (async () => {
122396
+ var _a3, _b;
122397
+ const run = await this.world.runs.get(this.runId);
122398
+ const rawKey = await ((_b = (_a3 = this.world).getEncryptionKeyForRun) == null ? void 0 : _b.call(_a3, run));
122399
+ return rawKey ? await importKey(rawKey) : void 0;
122400
+ })();
122401
+ }
122402
+ return this.encryptionKeyPromise;
122403
+ }
122404
+ /**
122405
+ * Interrupts pending `sleep()` calls, resuming the workflow early.
122406
+ *
122407
+ * @param options - Optional settings to target specific sleep calls by correlation ID.
122408
+ * If not provided, all pending sleep calls will be interrupted.
122409
+ * @returns A {@link StopSleepResult} object containing the number of sleep calls that were interrupted.
122410
+ */
122411
+ async wakeUp(options) {
122412
+ return wakeUpRun$2(this.world, this.runId, options);
122413
+ }
121818
122414
  /**
121819
122415
  * Cancels the workflow run.
121820
122416
  */
@@ -121879,7 +122475,8 @@ class Run {
121879
122475
  getReadable(options = {}) {
121880
122476
  const { ops = [], global: global2 = globalThis, startIndex, namespace: namespace2 } = options;
121881
122477
  const name2 = getWorkflowRunStreamId(this.runId, namespace2);
121882
- return getExternalRevivers(global2, ops, this.runId).ReadableStream({
122478
+ const encryptionKey = this.getEncryptionKey();
122479
+ return getExternalRevivers(global2, ops, this.runId, encryptionKey).ReadableStream({
121883
122480
  name: name2,
121884
122481
  startIndex
121885
122482
  });
@@ -121890,13 +122487,11 @@ class Run {
121890
122487
  * @returns The workflow return value.
121891
122488
  */
121892
122489
  async pollReturnValue() {
121893
- var _a3, _b;
121894
122490
  while (true) {
121895
122491
  try {
121896
122492
  const run = await this.world.runs.get(this.runId);
121897
122493
  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;
122494
+ const encryptionKey = await this.getEncryptionKey();
121900
122495
  return await hydrateWorkflowReturnValue(run.output, this.runId, encryptionKey);
121901
122496
  }
121902
122497
  if (run.status === "cancelled") {
@@ -121916,188 +122511,6 @@ class Run {
121916
122511
  }
121917
122512
  }
121918
122513
  }
121919
- const version = "4.1.0-beta.62";
121920
- const ulid = monotonicFactory();
121921
- async function start$1(workflow, argsOrOptions, options) {
121922
- return await waitedUntil(() => {
121923
- const workflowName = workflow == null ? void 0 : workflow.workflowId;
121924
- if (!workflowName) {
121925
- throw new WorkflowRuntimeError(`'start' received an invalid workflow function. Ensure the Workflow Development Kit is configured correctly and the function includes a 'use workflow' directive.`, { slug: "start-invalid-workflow-function" });
121926
- }
121927
- return trace$2(`workflow.start ${workflowName}`, async (span) => {
121928
- var _a3;
121929
- span == null ? void 0 : span.setAttributes({
121930
- ...WorkflowName(workflowName),
121931
- ...WorkflowOperation("start")
121932
- });
121933
- let args = [];
121934
- let opts = options ?? {};
121935
- if (Array.isArray(argsOrOptions)) {
121936
- args = argsOrOptions;
121937
- } else if (typeof argsOrOptions === "object") {
121938
- opts = argsOrOptions;
121939
- }
121940
- span == null ? void 0 : span.setAttributes({
121941
- ...WorkflowArgumentsCount(args.length)
121942
- });
121943
- const world = (opts == null ? void 0 : opts.world) ?? getWorld();
121944
- const deploymentId = opts.deploymentId ?? await world.getDeploymentId();
121945
- const ops = [];
121946
- const runId = `wrun_${ulid()}`;
121947
- const traceCarrier = await serializeTraceCarrier();
121948
- const specVersion = opts.specVersion ?? SPEC_VERSION_CURRENT;
121949
- const v1Compat = isLegacySpecVersion(specVersion);
121950
- const rawKey = await ((_a3 = world.getEncryptionKeyForRun) == null ? void 0 : _a3.call(world, runId, { ...opts }));
121951
- const encryptionKey = rawKey ? await importKey(rawKey) : void 0;
121952
- const workflowArguments = await dehydrateWorkflowArguments(args, runId, encryptionKey, ops, globalThis, v1Compat);
121953
- const result = await world.events.create(runId, {
121954
- eventType: "run_created",
121955
- specVersion,
121956
- eventData: {
121957
- deploymentId,
121958
- workflowName,
121959
- input: workflowArguments,
121960
- executionContext: { traceCarrier, workflowCoreVersion: version }
121961
- }
121962
- }, { v1Compat });
121963
- if (!result.run) {
121964
- throw new WorkflowRuntimeError("Missing 'run' in server response for 'run_created' event");
121965
- }
121966
- if (!v1Compat && result.run.runId !== runId) {
121967
- throw new WorkflowRuntimeError(`Server returned different runId than requested: expected ${runId}, got ${result.run.runId}`);
121968
- }
121969
- functionsExports.waitUntil(Promise.all(ops).catch((err) => {
121970
- const isAbortError = (err == null ? void 0 : err.name) === "AbortError" || (err == null ? void 0 : err.name) === "ResponseAborted";
121971
- if (!isAbortError)
121972
- throw err;
121973
- }));
121974
- span == null ? void 0 : span.setAttributes({
121975
- ...WorkflowRunId(runId),
121976
- ...WorkflowRunStatus(result.run.status),
121977
- ...DeploymentId(deploymentId)
121978
- });
121979
- await world.queue(getWorkflowQueueName(workflowName), {
121980
- runId,
121981
- traceCarrier
121982
- }, {
121983
- deploymentId
121984
- });
121985
- return new Run(runId);
121986
- });
121987
- });
121988
- }
121989
- const normalizeWorkflowArgs = (args) => {
121990
- return Array.isArray(args) ? args : [args];
121991
- };
121992
- async function recreateRunFromExisting(world, runId, options = {}) {
121993
- var _a3;
121994
- try {
121995
- const run = await world.runs.get(runId, { resolveData: "all" });
121996
- const rawKey = await ((_a3 = world.getEncryptionKeyForRun) == null ? void 0 : _a3.call(world, run));
121997
- const encryptionKey = rawKey ? await importKey(rawKey) : void 0;
121998
- const workflowArgs = normalizeWorkflowArgs(await hydrateWorkflowArguments(run.input, runId, encryptionKey, globalThis));
121999
- const specVersion = options.specVersion ?? run.specVersion ?? SPEC_VERSION_LEGACY;
122000
- const deploymentId = options.deploymentId ?? run.deploymentId;
122001
- const newRun = await start$1({ workflowId: run.workflowName }, workflowArgs, {
122002
- deploymentId,
122003
- world,
122004
- specVersion
122005
- });
122006
- return newRun.runId;
122007
- } catch (err) {
122008
- throw new Error(`Failed to recreate run from ${runId}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
122009
- }
122010
- }
122011
- async function cancelRun$2(world, runId) {
122012
- try {
122013
- const run = await world.runs.get(runId, { resolveData: "none" });
122014
- const specVersion = run.specVersion ?? SPEC_VERSION_LEGACY;
122015
- const compatMode = isLegacySpecVersion(specVersion);
122016
- const eventData = {
122017
- eventType: "run_cancelled",
122018
- specVersion
122019
- };
122020
- await world.events.create(runId, eventData, { v1Compat: compatMode });
122021
- } catch (err) {
122022
- throw new Error(`Failed to cancel run ${runId}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
122023
- }
122024
- }
122025
- async function reenqueueRun$2(world, runId) {
122026
- try {
122027
- const run = await world.runs.get(runId, { resolveData: "none" });
122028
- await world.queue(getWorkflowQueueName(run.workflowName), {
122029
- runId
122030
- }, {
122031
- deploymentId: run.deploymentId
122032
- });
122033
- } catch (err) {
122034
- throw new Error(`Failed to re-enqueue run ${runId}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
122035
- }
122036
- }
122037
- async function wakeUpRun$2(world, runId, options) {
122038
- try {
122039
- const run = await world.runs.get(runId, { resolveData: "none" });
122040
- const compatMode = isLegacySpecVersion(run.specVersion);
122041
- const allEvents = [];
122042
- let cursor = null;
122043
- do {
122044
- const eventsResult = await world.events.list({
122045
- runId,
122046
- pagination: { limit: 1e3, ...cursor ? { cursor } : {} },
122047
- resolveData: "none"
122048
- });
122049
- allEvents.push(...eventsResult.data);
122050
- cursor = eventsResult.hasMore ? eventsResult.cursor : null;
122051
- } while (cursor);
122052
- const waitCreatedEvents = allEvents.filter((event) => event.eventType === "wait_created");
122053
- const waitCompletedCorrelationIds = new Set(allEvents.filter((event) => event.eventType === "wait_completed").map((event) => event.correlationId));
122054
- let pendingWaits = waitCreatedEvents.filter((event) => !waitCompletedCorrelationIds.has(event.correlationId));
122055
- if ((options == null ? void 0 : options.correlationIds) && options.correlationIds.length > 0) {
122056
- const targetCorrelationIds = new Set(options.correlationIds);
122057
- pendingWaits = pendingWaits.filter((event) => event.correlationId && targetCorrelationIds.has(event.correlationId));
122058
- }
122059
- const errors2 = [];
122060
- let stoppedCount = 0;
122061
- for (const waitEvent of pendingWaits) {
122062
- if (!waitEvent.correlationId)
122063
- continue;
122064
- const eventData = compatMode ? {
122065
- eventType: "wait_completed",
122066
- correlationId: waitEvent.correlationId
122067
- } : {
122068
- eventType: "wait_completed",
122069
- correlationId: waitEvent.correlationId,
122070
- specVersion: run.specVersion
122071
- };
122072
- try {
122073
- await world.events.create(runId, eventData, { v1Compat: compatMode });
122074
- stoppedCount++;
122075
- } catch (err) {
122076
- if (WorkflowAPIError.is(err) && err.status === 409) {
122077
- stoppedCount++;
122078
- } else {
122079
- errors2.push(err instanceof Error ? err : new Error(String(err)));
122080
- }
122081
- }
122082
- }
122083
- if (stoppedCount > 0) {
122084
- await world.queue(getWorkflowQueueName(run.workflowName), {
122085
- runId
122086
- }, {
122087
- deploymentId: run.deploymentId
122088
- });
122089
- }
122090
- if (errors2.length > 0) {
122091
- throw new AggregateError(errors2, `Failed to complete ${errors2.length}/${pendingWaits.length} pending wait(s) for run ${runId}`);
122092
- }
122093
- return { stoppedCount };
122094
- } catch (err) {
122095
- if (err instanceof AggregateError) {
122096
- throw err;
122097
- }
122098
- throw new Error(`Failed to wake up run ${runId}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
122099
- }
122100
- }
122101
122514
  const DEFAULT_STEP_MAX_RETRIES = 3;
122102
122515
  getWorldHandlers().createQueueHandler("__wkf_step_", async (message_, metadata) => {
122103
122516
  const healthCheck2 = parseHealthCheckPayload(message_);
@@ -122300,7 +122713,8 @@ getWorldHandlers().createQueueHandler("__wkf_step_", async (message_, metadata)
122300
122713
  url: process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : `http://localhost:${port ?? 3e3}`
122301
122714
  },
122302
122715
  ops,
122303
- closureVars: hydratedInput.closureVars
122716
+ closureVars: hydratedInput.closureVars,
122717
+ encryptionKey
122304
122718
  }, () => stepFn.apply(thisVal, args));
122305
122719
  });
122306
122720
  const executionTimeMs = Date.now() - executionStartTime;
@@ -122636,13 +123050,6 @@ async function findWorkflowDataDir(cwd) {
122636
123050
  shortName: getDirShortName(absoluteCwd)
122637
123051
  };
122638
123052
  }
122639
- function createVercelWorld(config2) {
122640
- return {
122641
- ...createQueue$1(config2),
122642
- ...createStorage(config2),
122643
- ...createStreamer(config2)
122644
- };
122645
- }
122646
123053
  function getBackendDisplayName(targetWorld) {
122647
123054
  if (!targetWorld) return "Local";
122648
123055
  switch (targetWorld) {
@@ -123177,10 +123584,7 @@ async function resumeHook$1(worldEnv, token, payload) {
123177
123584
  async function readStreamServerAction(env2, streamId, startIndex) {
123178
123585
  try {
123179
123586
  const world = await getWorldFromEnv(env2);
123180
- const stream = await world.readFromStream(streamId, startIndex);
123181
- const revivers = getExternalRevivers(globalThis, [], "");
123182
- const transform2 = getDeserializeStream(revivers);
123183
- return stream.pipeThrough(transform2);
123587
+ return await world.readFromStream(streamId, startIndex);
123184
123588
  } catch (error2) {
123185
123589
  const actionError = createServerActionError(error2, "world.readFromStream", {
123186
123590
  streamId,
@@ -123272,6 +123676,23 @@ async function runHealthCheck(worldEnv, endpoint, options) {
123272
123676
  });
123273
123677
  }
123274
123678
  }
123679
+ async function getEncryptionKeyForRun(worldEnv, runId) {
123680
+ try {
123681
+ const world = await getWorldFromEnv(worldEnv);
123682
+ if (!world.getEncryptionKeyForRun) {
123683
+ return createResponse(null);
123684
+ }
123685
+ const run = await world.runs.get(runId);
123686
+ const key = await world.getEncryptionKeyForRun(run);
123687
+ return createResponse(key ?? null);
123688
+ } catch (error2) {
123689
+ return createServerActionError(
123690
+ error2,
123691
+ "getEncryptionKeyForRun",
123692
+ { runId }
123693
+ );
123694
+ }
123695
+ }
123275
123696
  async function loader$2() {
123276
123697
  const serverConfig = await getPublicServerConfig();
123277
123698
  return {
@@ -129035,16 +129456,19 @@ async function fetchResourceWithCorrelationId(env2, resource, resourceId, option
129035
129456
  layer: "client"
129036
129457
  });
129037
129458
  }
129038
- resourceData = hydrateResourceIO(resourceData);
129039
129459
  return { data: resourceData, correlationId };
129040
129460
  }
129041
129461
  function useWorkflowResourceData(env2, resource, resourceId, options = {}) {
129042
- const { refreshInterval = 0, runId, enabled = true } = options;
129462
+ const { refreshInterval = 0, runId, enabled = true, encryptionKey } = options;
129043
129463
  const [data, setData] = reactExports.useState(
129044
129464
  null
129045
129465
  );
129046
129466
  const [loading, setLoading] = reactExports.useState(enabled);
129047
129467
  const [error2, setError] = reactExports.useState(null);
129468
+ const hydrate = reactExports.useCallback(
129469
+ async (resource2) => encryptionKey ? hydrateResourceIOWithKey(resource2, encryptionKey) : hydrateResourceIO(resource2),
129470
+ [encryptionKey]
129471
+ );
129048
129472
  const fetchData = reactExports.useCallback(async () => {
129049
129473
  if (!enabled) {
129050
129474
  setLoading(false);
@@ -129060,7 +129484,13 @@ function useWorkflowResourceData(env2, resource, resourceId, options = {}) {
129060
129484
  setError(error22);
129061
129485
  return;
129062
129486
  }
129063
- setData(hydrateResourceIO(result));
129487
+ try {
129488
+ setData(await hydrate(result));
129489
+ } catch (hydrateError) {
129490
+ setError(
129491
+ hydrateError instanceof Error ? hydrateError : new Error(String(hydrateError))
129492
+ );
129493
+ }
129064
129494
  return;
129065
129495
  }
129066
129496
  if (resource === "sleep") {
@@ -129075,17 +129505,25 @@ function useWorkflowResourceData(env2, resource, resourceId, options = {}) {
129075
129505
  setError(error22);
129076
129506
  return;
129077
129507
  }
129078
- const events2 = result.data.map(hydrateResourceIO);
129079
- const data2 = waitEventsToWaitEntity(events2);
129080
- if (data2 === null) {
129508
+ try {
129509
+ const events2 = await Promise.all(
129510
+ result.data.map(hydrate)
129511
+ );
129512
+ const data2 = waitEventsToWaitEntity(events2);
129513
+ if (data2 === null) {
129514
+ setError(
129515
+ new Error(
129516
+ `Failed to load ${resource} details: missing required event data`
129517
+ )
129518
+ );
129519
+ return;
129520
+ }
129521
+ setData(data2);
129522
+ } catch (hydrateError) {
129081
129523
  setError(
129082
- new Error(
129083
- `Failed to load ${resource} details: missing required event data`
129084
- )
129524
+ hydrateError instanceof Error ? hydrateError : new Error(String(hydrateError))
129085
129525
  );
129086
- return;
129087
129526
  }
129088
- setData(data2);
129089
129527
  return;
129090
129528
  }
129091
129529
  setLoading(true);
@@ -129096,7 +129534,7 @@ function useWorkflowResourceData(env2, resource, resourceId, options = {}) {
129096
129534
  resourceId,
129097
129535
  { runId }
129098
129536
  );
129099
- setData(resourceData);
129537
+ setData(await hydrate(resourceData));
129100
129538
  } catch (error22) {
129101
129539
  if (error22 instanceof Error) {
129102
129540
  setError(error22);
@@ -129107,7 +129545,7 @@ function useWorkflowResourceData(env2, resource, resourceId, options = {}) {
129107
129545
  } finally {
129108
129546
  setLoading(false);
129109
129547
  }
129110
- }, [env2, resource, resourceId, runId, enabled]);
129548
+ }, [env2, resource, resourceId, runId, enabled, hydrate]);
129111
129549
  reactExports.useEffect(() => {
129112
129550
  fetchData();
129113
129551
  }, [fetchData]);
@@ -129224,7 +129662,7 @@ function useWorkflowTraceViewerData(env2, runId, options = {}) {
129224
129662
  setAuxiliaryDataLoading(true);
129225
129663
  setError(null);
129226
129664
  const [runResult, stepsResult, hooksResult, eventsResult] = await Promise.all([
129227
- unwrapServerActionResult(fetchRun$1(env2, runId)),
129665
+ unwrapServerActionResult(fetchRun$1(env2, runId, "none")),
129228
129666
  unwrapServerActionResult(
129229
129667
  fetchSteps$1(env2, runId, {
129230
129668
  sortOrder: "asc",
@@ -129399,12 +129837,13 @@ function useWorkflowTraceViewerData(env2, runId, options = {}) {
129399
129837
  return false;
129400
129838
  }
129401
129839
  const { error: error22, result } = await unwrapServerActionResult(
129402
- fetchRun$1(env2, runId)
129840
+ fetchRun$1(env2, runId, "none")
129403
129841
  );
129404
129842
  if (error22) {
129405
129843
  setError(error22);
129406
129844
  return false;
129407
129845
  }
129846
+ setError(null);
129408
129847
  setRun(hydrateResourceIO(result));
129409
129848
  return true;
129410
129849
  }, [env2, runId, run == null ? void 0 : run.completedAt]);
@@ -145447,7 +145886,8 @@ function mapRunToExecution(run, steps, events2, graph) {
145447
145886
  });
145448
145887
  return result;
145449
145888
  }
145450
- function useStreamReader(env2, streamId) {
145889
+ const FRAME_HEADER_SIZE = 4;
145890
+ function useStreamReader(env2, streamId, runId, encryptionKey) {
145451
145891
  const [chunks, setChunks] = reactExports.useState([]);
145452
145892
  const [isLive, setIsLive] = reactExports.useState(false);
145453
145893
  const [error2, setError] = reactExports.useState(null);
@@ -145466,83 +145906,82 @@ function useStreamReader(env2, streamId) {
145466
145906
  abortControllerRef.current = abortController;
145467
145907
  setIsLive(true);
145468
145908
  const revivers = getWebRevivers();
145469
- const handleStreamEnd = () => {
145470
- if (mounted) {
145471
- setIsLive(false);
145472
- }
145473
- };
145474
- const handleStreamError = (err) => {
145475
- if (mounted) {
145476
- setError(err instanceof Error ? err.message : String(err));
145477
- setIsLive(false);
145478
- }
145479
- };
145480
- const addChunk = (value) => {
145481
- if (mounted && value !== void 0 && value !== null) {
145482
- const chunkId = chunkIdRef.current++;
145483
- let hydrated;
145484
- try {
145485
- hydrated = hydrateData(value, revivers);
145486
- } catch {
145487
- hydrated = value;
145488
- }
145489
- const text2 = typeof hydrated === "string" ? hydrated : JSON.stringify(hydrated, null, 2);
145490
- setChunks((prev) => [...prev, { id: chunkId, text: text2 }]);
145491
- }
145492
- };
145493
- const processFramedStream = async (reader) => {
145494
- var _a3;
145495
- let buffer = new Uint8Array(0);
145496
- const appendToBuffer = (data) => {
145497
- const newBuffer = new Uint8Array(buffer.length + data.length);
145498
- newBuffer.set(buffer, 0);
145499
- newBuffer.set(data, buffer.length);
145500
- buffer = newBuffer;
145501
- };
145502
- for (; ; ) {
145503
- if ((_a3 = abortControllerRef.current) == null ? void 0 : _a3.signal.aborted) break;
145504
- const { value, done } = await reader.read();
145505
- if (done) {
145506
- handleStreamEnd();
145507
- break;
145508
- }
145509
- appendToBuffer(value);
145510
- while (buffer.length >= 4) {
145511
- const view = new DataView(
145512
- buffer.buffer,
145513
- buffer.byteOffset,
145514
- buffer.byteLength
145515
- );
145516
- const frameLength = view.getUint32(0, false);
145517
- if (buffer.length < 4 + frameLength) {
145518
- break;
145519
- }
145520
- const frameData = buffer.slice(4, 4 + frameLength);
145521
- buffer = buffer.slice(4 + frameLength);
145522
- try {
145523
- const rawChunk = decode$2(frameData);
145524
- addChunk(rawChunk);
145525
- } catch (err) {
145526
- console.error("Failed to decode stream chunk:", err);
145527
- }
145528
- }
145529
- }
145530
- };
145531
145909
  const readStreamData = async () => {
145532
145910
  try {
145533
- const stream = await readStream(
145911
+ const rawStream = await readStream(
145534
145912
  env2,
145535
145913
  streamId,
145536
145914
  void 0,
145537
145915
  abortController.signal
145538
145916
  );
145539
- const reader = stream.getReader();
145540
- await processFramedStream(reader);
145917
+ const cryptoKey = encryptionKey ? await importKey(encryptionKey) : void 0;
145918
+ const reader = rawStream.getReader();
145919
+ let buffer = new Uint8Array(0);
145920
+ const appendToBuffer = (data) => {
145921
+ const newBuffer = new Uint8Array(buffer.length + data.length);
145922
+ newBuffer.set(buffer, 0);
145923
+ newBuffer.set(data, buffer.length);
145924
+ buffer = newBuffer;
145925
+ };
145926
+ for (; ; ) {
145927
+ if (abortController.signal.aborted) break;
145928
+ const { value, done } = await reader.read();
145929
+ if (done) {
145930
+ if (mounted) setIsLive(false);
145931
+ break;
145932
+ }
145933
+ appendToBuffer(value);
145934
+ while (buffer.length >= FRAME_HEADER_SIZE) {
145935
+ const view = new DataView(
145936
+ buffer.buffer,
145937
+ buffer.byteOffset,
145938
+ buffer.byteLength
145939
+ );
145940
+ const frameLength = view.getUint32(0, false);
145941
+ if (buffer.length < FRAME_HEADER_SIZE + frameLength) {
145942
+ break;
145943
+ }
145944
+ const frameData = buffer.slice(
145945
+ FRAME_HEADER_SIZE,
145946
+ FRAME_HEADER_SIZE + frameLength
145947
+ );
145948
+ buffer = buffer.slice(FRAME_HEADER_SIZE + frameLength);
145949
+ try {
145950
+ const { format: format2, payload } = decodeFormatPrefix$1(frameData);
145951
+ let dataToHydrate;
145952
+ if (format2 === SerializationFormat$1.ENCRYPTED) {
145953
+ if (!cryptoKey) {
145954
+ if (mounted) {
145955
+ setError(
145956
+ "This stream is encrypted. Click Decrypt to view."
145957
+ );
145958
+ setIsLive(false);
145959
+ }
145960
+ reader.cancel().catch(() => {
145961
+ });
145962
+ return;
145963
+ }
145964
+ dataToHydrate = await decrypt(cryptoKey, payload);
145965
+ } else {
145966
+ dataToHydrate = frameData;
145967
+ }
145968
+ const hydrated = hydrateData(dataToHydrate, revivers);
145969
+ if (mounted && hydrated !== void 0 && hydrated !== null) {
145970
+ const chunkId = chunkIdRef.current++;
145971
+ const text2 = typeof hydrated === "string" ? hydrated : JSON.stringify(hydrated, null, 2);
145972
+ setChunks((prev) => [...prev, { id: chunkId, text: text2 }]);
145973
+ }
145974
+ } catch (err) {
145975
+ console.error("Failed to process stream frame:", err);
145976
+ }
145977
+ }
145978
+ }
145541
145979
  } catch (err) {
145542
- if (abortController.signal.aborted) {
145543
- return;
145980
+ if (abortController.signal.aborted) return;
145981
+ if (mounted) {
145982
+ setError(err instanceof Error ? err.message : String(err));
145983
+ setIsLive(false);
145544
145984
  }
145545
- handleStreamError(err);
145546
145985
  }
145547
145986
  };
145548
145987
  void readStreamData();
@@ -145552,12 +145991,8 @@ function useStreamReader(env2, streamId) {
145552
145991
  abortControllerRef.current.abort();
145553
145992
  }
145554
145993
  };
145555
- }, [env2, streamId]);
145556
- return {
145557
- chunks,
145558
- isLive,
145559
- error: error2
145560
- };
145994
+ }, [env2, streamId, runId, encryptionKey]);
145995
+ return { chunks, isLive, error: error2 };
145561
145996
  }
145562
145997
  function LiveStatus({ hasError, errorMessage }) {
145563
145998
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
@@ -146527,6 +146962,7 @@ function RunDetailView({
146527
146962
  },
146528
146963
  [env2]
146529
146964
  );
146965
+ const encryptionKeyRef = reactExports.useRef(null);
146530
146966
  const handleResolveHook = reactExports.useCallback(
146531
146967
  async (hookToken, payload) => {
146532
146968
  await resumeHook(env2, hookToken, payload);
@@ -146548,8 +146984,9 @@ function RunDetailView({
146548
146984
  throw error3;
146549
146985
  }
146550
146986
  const rawEvent2 = result2.data.find((e) => e.eventId === event.eventId);
146551
- const fullEvent2 = rawEvent2 ? hydrateResourceIO(rawEvent2) : null;
146552
- if (fullEvent2 && "eventData" in fullEvent2) {
146987
+ if (!rawEvent2) return null;
146988
+ const fullEvent2 = encryptionKeyRef.current ? await hydrateResourceIOWithKey(rawEvent2, encryptionKeyRef.current) : hydrateResourceIO(rawEvent2);
146989
+ if ("eventData" in fullEvent2) {
146553
146990
  return fullEvent2.eventData;
146554
146991
  }
146555
146992
  return null;
@@ -146578,8 +147015,9 @@ function RunDetailView({
146578
147015
  }
146579
147016
  rawEvent = ascResult.data.find((e) => e.eventId === event.eventId);
146580
147017
  }
146581
- const fullEvent = rawEvent ? hydrateResourceIO(rawEvent) : null;
146582
- if (fullEvent && "eventData" in fullEvent) {
147018
+ if (!rawEvent) return null;
147019
+ const fullEvent = encryptionKeyRef.current ? await hydrateResourceIOWithKey(rawEvent, encryptionKeyRef.current) : hydrateResourceIO(rawEvent);
147020
+ if ("eventData" in fullEvent) {
146583
147021
  return fullEvent.eventData;
146584
147022
  }
146585
147023
  return null;
@@ -146599,8 +147037,9 @@ function RunDetailView({
146599
147037
  throw error22;
146600
147038
  }
146601
147039
  const rawEvent = result.data.find((e) => e.eventId === eventId);
146602
- const fullEvent = rawEvent ? hydrateResourceIO(rawEvent) : null;
146603
- if (fullEvent && "eventData" in fullEvent) {
147040
+ if (!rawEvent) return null;
147041
+ const fullEvent = encryptionKeyRef.current ? await hydrateResourceIOWithKey(rawEvent, encryptionKeyRef.current) : hydrateResourceIO(rawEvent);
147042
+ if ("eventData" in fullEvent) {
146604
147043
  return fullEvent.eventData;
146605
147044
  }
146606
147045
  return null;
@@ -146622,13 +147061,16 @@ function RunDetailView({
146622
147061
  isLoadingMoreTraceData
146623
147062
  } = useWorkflowTraceViewerData(env2, runId, { live: true });
146624
147063
  const run = runData ?? {};
147064
+ const [encryptionKey, setEncryptionKey] = reactExports.useState(null);
147065
+ encryptionKeyRef.current = encryptionKey;
146625
147066
  const [spanSelection, setSpanSelection] = reactExports.useState(
146626
147067
  null
146627
147068
  );
146628
147069
  const {
146629
147070
  data: spanDetailData,
146630
147071
  loading: spanDetailLoading,
146631
- error: spanDetailError
147072
+ error: spanDetailError,
147073
+ refresh: refreshSpanDetail
146632
147074
  } = useWorkflowResourceData(
146633
147075
  env2,
146634
147076
  (spanSelection == null ? void 0 : spanSelection.resource) ?? "run",
@@ -146637,9 +147079,26 @@ function RunDetailView({
146637
147079
  runId: spanSelection == null ? void 0 : spanSelection.runId,
146638
147080
  enabled: Boolean(
146639
147081
  (spanSelection == null ? void 0 : spanSelection.resource) && (spanSelection == null ? void 0 : spanSelection.resourceId) && spanSelection.resource !== "hook"
146640
- )
147082
+ ),
147083
+ encryptionKey: encryptionKey ?? void 0
146641
147084
  }
146642
147085
  );
147086
+ const handleDecrypt = reactExports.useCallback(async () => {
147087
+ if (encryptionKey) {
147088
+ refreshSpanDetail();
147089
+ return;
147090
+ }
147091
+ const { error: keyError, result: keyResult } = await unwrapServerActionResult(getEncryptionKeyForRun$1(env2, runId));
147092
+ if (keyError) {
147093
+ toast.error(`Failed to fetch encryption key: ${keyError.message}`);
147094
+ return;
147095
+ }
147096
+ if (!keyResult) {
147097
+ toast.error("Encryption is not configured for this deployment.");
147098
+ return;
147099
+ }
147100
+ setEncryptionKey(keyResult);
147101
+ }, [encryptionKey, env2, runId, refreshSpanDetail]);
146643
147102
  const handleSpanSelect = reactExports.useCallback((info) => {
146644
147103
  setSpanSelection(info);
146645
147104
  }, []);
@@ -146652,7 +147111,7 @@ function RunDetailView({
146652
147111
  chunks: streamChunks,
146653
147112
  isLive: streamIsLive,
146654
147113
  error: streamError
146655
- } = useStreamReader(env2, selectedStreamId);
147114
+ } = useStreamReader(env2, selectedStreamId, runId, encryptionKey);
146656
147115
  const handleCancelClick = () => {
146657
147116
  setShowCancelDialog(true);
146658
147117
  };
@@ -146746,6 +147205,24 @@ function RunDetailView({
146746
147205
  /* @__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
147206
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
146748
147207
  /* @__PURE__ */ jsxRuntimeExports.jsx(LiveStatus, { hasError, errorMessage }),
147208
+ (isEncryptedMarker(run.input) || isEncryptedMarker(run.output) || isEncryptedMarker(run.error) || allSteps.some(
147209
+ (s2) => isEncryptedMarker(s2.input) || isEncryptedMarker(s2.output)
147210
+ )) && /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
147211
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
147212
+ Button,
147213
+ {
147214
+ variant: "outline",
147215
+ size: "sm",
147216
+ onClick: handleDecrypt,
147217
+ disabled: !!encryptionKey,
147218
+ children: [
147219
+ encryptionKey ? /* @__PURE__ */ jsxRuntimeExports.jsx(LockOpen, { className: "h-4 w-4" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Lock, { className: "h-4 w-4" }),
147220
+ encryptionKey ? "Decrypted" : "Decrypt"
147221
+ ]
147222
+ }
147223
+ ) }) }),
147224
+ /* @__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." }) })
147225
+ ] }),
146749
147226
  /* @__PURE__ */ jsxRuntimeExports.jsx(
146750
147227
  RunActionsButtons,
146751
147228
  {
@@ -146857,7 +147334,8 @@ function RunDetailView({
146857
147334
  onLoadEventData: handleLoadSidebarEventData,
146858
147335
  onLoadMoreSpans: loadMoreTraceData,
146859
147336
  hasMoreSpans: hasMoreTraceData,
146860
- isLoadingMoreSpans: isLoadingMoreTraceData
147337
+ isLoadingMoreSpans: isLoadingMoreTraceData,
147338
+ encryptionKey: encryptionKey ?? void 0
146861
147339
  }
146862
147340
  ) }) }) }),
146863
147341
  /* @__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 +147344,8 @@ function RunDetailView({
146866
147344
  events: allEvents,
146867
147345
  steps: allSteps,
146868
147346
  run,
146869
- onLoadEventData: handleLoadEventData
147347
+ onLoadEventData: handleLoadEventData,
147348
+ encryptionKey: encryptionKey ?? void 0
146870
147349
  }
146871
147350
  ) }) }) }),
146872
147351
  /* @__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 +147482,7 @@ const handlers = {
147003
147482
  fetchStreams: (p2) => fetchStreams(p2.worldEnv ?? {}, p2.runId),
147004
147483
  fetchWorkflowsManifest: (p2) => fetchWorkflowsManifest(p2.worldEnv ?? {}),
147005
147484
  runHealthCheck: (p2) => runHealthCheck(p2.worldEnv ?? {}, p2.endpoint, p2.options),
147485
+ getEncryptionKeyForRun: (p2) => getEncryptionKeyForRun(p2.worldEnv ?? {}, p2.runId),
147006
147486
  getPublicServerConfig: () => getPublicServerConfig()
147007
147487
  };
147008
147488
  function cborResponse(data, status = 200) {
@@ -147115,16 +147595,7 @@ async function loader({
147115
147595
  status: 500
147116
147596
  });
147117
147597
  }
147118
- const cborStream = stream.pipeThrough(new TransformStream({
147119
- transform(chunk, controller) {
147120
- const encoded = encode$2(chunk);
147121
- const length = new DataView(new ArrayBuffer(4));
147122
- length.setUint32(0, encoded.byteLength, false);
147123
- controller.enqueue(new Uint8Array(length.buffer));
147124
- controller.enqueue(new Uint8Array(encoded));
147125
- }
147126
- }));
147127
- return new Response(cborStream, {
147598
+ return new Response(stream, {
147128
147599
  headers: {
147129
147600
  "Content-Type": "application/octet-stream"
147130
147601
  }
@@ -147143,7 +147614,7 @@ const route4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
147143
147614
  __proto__: null,
147144
147615
  loader
147145
147616
  }, 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 };
147617
+ 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-DZgYUaDo.js", "imports": ["/assets/index-DklpUtP3.js", "/assets/mermaid-3ZIDBTTL-DcdZu9sS.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-Cpz2_ZDM.js", "imports": ["/assets/index-DklpUtP3.js", "/assets/use-workflow-graph-CF7nLapT.js", "/assets/mermaid-3ZIDBTTL-DcdZu9sS.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-xcvWVR2B.js", "imports": ["/assets/index-DklpUtP3.js", "/assets/use-workflow-graph-CF7nLapT.js", "/assets/mermaid-3ZIDBTTL-DcdZu9sS.js", "/assets/encryption-8OvC6eoJ.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-069935e6.js", "version": "069935e6", "sri": void 0 };
147147
147618
  const assetsBuildDirectory = "build/client";
147148
147619
  const basename = "/";
147149
147620
  const future = { "unstable_optimizeDeps": false, "unstable_subResourceIntegrity": false, "unstable_trailingSlashAwareDataRequests": false, "unstable_previewServerPrerendering": false, "v8_middleware": false, "v8_splitRouteModules": false, "v8_viteEnvironmentApi": false };