@workflow/web 5.0.0-beta.5 → 5.0.0-beta.7
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.
- package/build/client/assets/{encryption-CEh0YXii.js → encryption-C69WMRfh.js} +12 -6
- package/build/client/assets/{highlighted-body-B3W2YXNL-L1CrwoL_.js → highlighted-body-B3W2YXNL-Cq4feDhL.js} +1 -1
- package/build/client/assets/{home-B6UmDDP6.js → home-B-DWbULo.js} +3 -3
- package/build/client/assets/{index-B4xuge0I.js → index-Byi8AWfe.js} +31 -0
- package/build/client/assets/{manifest-e4c1c787.js → manifest-21016363.js} +1 -1
- package/build/client/assets/{mermaid-3ZIDBTTL-BQLU7GUr.js → mermaid-3ZIDBTTL-PK-k2mDG.js} +192 -103
- package/build/client/assets/root-B527kgKt.css +1 -0
- package/build/client/assets/{root-Yk3JVwUh.js → root-DDT0W3fG.js} +1 -1
- package/build/client/assets/{run-detail-DMUaWXhb.js → run-detail-COyTZwjr.js} +31 -7
- package/build/client/assets/server-build-BUmla00D.css +1 -0
- package/build/client/assets/{workflow-graph-viewer-yqeN-U_2.js → workflow-graph-viewer-CVUKAMV1.js} +2 -2
- package/build/server/assets/{app-L1V62FgT.js → app-CASBD2Jz.js} +1 -1
- package/build/server/assets/{highlighted-body-B3W2YXNL-CZjJIpdD.js → highlighted-body-B3W2YXNL-DtYGrm0G.js} +2 -2
- package/build/server/assets/{index-BwtNigf1.js → index-B_Gtun0B.js} +3 -3
- package/build/server/assets/{mermaid-3ZIDBTTL-Cc8IPTBj.js → mermaid-3ZIDBTTL-D37Y2lwn.js} +2 -2
- package/build/server/assets/{server-build-DtcOUEHS.js → server-build-BZS28Q46.js} +1270 -959
- package/build/server/assets/{token-DHnArVm7.js → token-98GkKm4t.js} +2 -2
- package/build/server/assets/{token-util-B3uKeZ0s.js → token-util-CHxt50WW.js} +2 -2
- package/build/server/index.js +1 -1
- package/package.json +6 -6
- package/build/client/assets/root-C0Tu5TVN.css +0 -1
- package/build/client/assets/server-build-DqaxIrF0.css +0 -1
|
@@ -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, _b, _c, _listeners, _onabort, _reader, _root, _hasMagic, _uflag, _parts, _parent, _parentIndex, _negs, _filledNegs, _options, _toString, _emptyExt, _AST_instances, fillNegs_fn, _AST_static, parseAST_fn, canAdoptWithSpace_fn, canAdopt_fn, canAdoptType_fn, adoptWithSpace_fn, adopt_fn, canUsurpType_fn, canUsurp_fn, usurp_fn, flatten_fn, partsToRegExp_fn, parseGlob_fn, _Minimatch_instances, matchGlobstar_fn, matchGlobStarBodySections_fn, matchOne_fn, _worldPromise, _Run_instances, lazyWorldPromise_get, _encryptionKeyPromise, _resilientStart, getEncryptionKey_fn, pollReturnValue_fn;
|
|
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, d as withErrorBoundaryProps, M as Meta, L as Links, e as ScrollRestoration, f as Scripts, O as Outlet, u as useNavigate, h as useSearchParams, i as Link$1, j as useRouteError, k as isRouteErrorResponse, l as useLocation, m as useParams } from "./app-
|
|
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, d as withErrorBoundaryProps, M as Meta, L as Links, e as ScrollRestoration, f as Scripts, O as Outlet, u as useNavigate, h as useSearchParams, i as Link$1, j as useRouteError, k as isRouteErrorResponse, l as useLocation, m as useParams } from "./app-CASBD2Jz.js";
|
|
18
18
|
import require$$0$3, { PassThrough } from "node:stream";
|
|
19
19
|
import require$$0 from "util";
|
|
20
20
|
import require$$1 from "crypto";
|
|
@@ -48635,6 +48635,7 @@ const StepCompletedEventSchema = BaseEventSchema.extend({
|
|
|
48635
48635
|
eventType: literal("step_completed"),
|
|
48636
48636
|
correlationId: string$3(),
|
|
48637
48637
|
eventData: object$1({
|
|
48638
|
+
stepName: string$3().optional(),
|
|
48638
48639
|
result: SerializedDataSchema
|
|
48639
48640
|
})
|
|
48640
48641
|
});
|
|
@@ -48642,6 +48643,7 @@ const StepFailedEventSchema = BaseEventSchema.extend({
|
|
|
48642
48643
|
eventType: literal("step_failed"),
|
|
48643
48644
|
correlationId: string$3(),
|
|
48644
48645
|
eventData: object$1({
|
|
48646
|
+
stepName: string$3().optional(),
|
|
48645
48647
|
// The thrown value, serialized via the workflow serialization pipeline.
|
|
48646
48648
|
// Can be any JavaScript value (string, number, object, Error, etc.)
|
|
48647
48649
|
error: SerializedDataSchema
|
|
@@ -48651,6 +48653,7 @@ const StepRetryingEventSchema = BaseEventSchema.extend({
|
|
|
48651
48653
|
eventType: literal("step_retrying"),
|
|
48652
48654
|
correlationId: string$3(),
|
|
48653
48655
|
eventData: object$1({
|
|
48656
|
+
stepName: string$3().optional(),
|
|
48654
48657
|
// The thrown value, serialized via the workflow serialization pipeline.
|
|
48655
48658
|
// Can be any JavaScript value (string, number, object, Error, etc.)
|
|
48656
48659
|
error: SerializedDataSchema,
|
|
@@ -48661,6 +48664,7 @@ const StepStartedEventSchema = BaseEventSchema.extend({
|
|
|
48661
48664
|
eventType: literal("step_started"),
|
|
48662
48665
|
correlationId: string$3(),
|
|
48663
48666
|
eventData: object$1({
|
|
48667
|
+
stepName: string$3().optional(),
|
|
48664
48668
|
attempt: number$3().optional()
|
|
48665
48669
|
}).optional()
|
|
48666
48670
|
});
|
|
@@ -48686,18 +48690,25 @@ const HookReceivedEventSchema = BaseEventSchema.extend({
|
|
|
48686
48690
|
eventType: literal("hook_received"),
|
|
48687
48691
|
correlationId: string$3(),
|
|
48688
48692
|
eventData: object$1({
|
|
48693
|
+
token: string$3().optional(),
|
|
48689
48694
|
payload: SerializedDataSchema
|
|
48690
48695
|
})
|
|
48691
48696
|
});
|
|
48692
48697
|
const HookDisposedEventSchema = BaseEventSchema.extend({
|
|
48693
48698
|
eventType: literal("hook_disposed"),
|
|
48694
|
-
correlationId: string$3()
|
|
48699
|
+
correlationId: string$3(),
|
|
48700
|
+
eventData: object$1({
|
|
48701
|
+
token: string$3().optional()
|
|
48702
|
+
}).optional()
|
|
48695
48703
|
});
|
|
48696
48704
|
const HookConflictEventSchema = BaseEventSchema.extend({
|
|
48697
48705
|
eventType: literal("hook_conflict"),
|
|
48698
48706
|
correlationId: string$3(),
|
|
48699
48707
|
eventData: object$1({
|
|
48700
|
-
token: string$3()
|
|
48708
|
+
token: string$3(),
|
|
48709
|
+
// TODO: Make this required once all persisted hook_conflict events and
|
|
48710
|
+
// remote World implementations always include the active hook owner's run ID.
|
|
48711
|
+
conflictingRunId: string$3().optional()
|
|
48701
48712
|
})
|
|
48702
48713
|
});
|
|
48703
48714
|
const WaitCreatedEventSchema = BaseEventSchema.extend({
|
|
@@ -48709,7 +48720,10 @@ const WaitCreatedEventSchema = BaseEventSchema.extend({
|
|
|
48709
48720
|
});
|
|
48710
48721
|
const WaitCompletedEventSchema = BaseEventSchema.extend({
|
|
48711
48722
|
eventType: literal("wait_completed"),
|
|
48712
|
-
correlationId: string$3()
|
|
48723
|
+
correlationId: string$3(),
|
|
48724
|
+
eventData: object$1({
|
|
48725
|
+
resumeAt: date$2().optional()
|
|
48726
|
+
}).optional()
|
|
48713
48727
|
});
|
|
48714
48728
|
const RunCreatedEventSchema = BaseEventSchema.extend({
|
|
48715
48729
|
eventType: literal("run_created"),
|
|
@@ -48994,7 +49008,7 @@ object$1({
|
|
|
48994
49008
|
message: string$3(),
|
|
48995
49009
|
stack: string$3().optional(),
|
|
48996
49010
|
code: string$3().optional()
|
|
48997
|
-
// Populated with RunErrorCode values (USER_ERROR, RUNTIME_ERROR) for run_failed events
|
|
49011
|
+
// Populated with RunErrorCode values (USER_ERROR, RUNTIME_ERROR, etc.) for run_failed events
|
|
48998
49012
|
});
|
|
48999
49013
|
const SPEC_VERSION_LEGACY = 1;
|
|
49000
49014
|
const SPEC_VERSION_SUPPORTS_EVENT_SOURCING = 2;
|
|
@@ -80048,7 +80062,7 @@ var tn = f("block", "before:content-[counter(line)]", "before:inline-block", "be
|
|
|
80048
80062
|
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 });
|
|
80049
80063
|
var Se = reactExports.createContext({ code: "" }), de = () => reactExports.useContext(Se);
|
|
80050
80064
|
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 }) });
|
|
80051
|
-
var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-
|
|
80065
|
+
var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-DtYGrm0G.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
|
|
80052
80066
|
let i = reactExports.useMemo(() => e.replace(cn$1, ""), [e]), c = reactExports.useMemo(() => ({ bg: "transparent", fg: "inherit", tokens: i.split(`
|
|
80053
80067
|
`).map((a2) => [{ content: a2, color: "inherit", bgColor: "transparent", htmlStyle: {}, offset: 0 }]) }), [i]);
|
|
80054
80068
|
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 }) })] }) });
|
|
@@ -80370,7 +80384,7 @@ var Dt = ({ children: e, className: t, onDownload: o, onError: n }) => {
|
|
|
80370
80384
|
}, []), 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] });
|
|
80371
80385
|
};
|
|
80372
80386
|
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 }) })] });
|
|
80373
|
-
var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-
|
|
80387
|
+
var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-D37Y2lwn.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
|
|
80374
80388
|
function ke(e, t) {
|
|
80375
80389
|
if (!(e != null && e.position || t != null && t.position)) return true;
|
|
80376
80390
|
if (!(e != null && e.position && (t != null && t.position))) return false;
|
|
@@ -81693,7 +81707,7 @@ function EntityDetailPanel({ run, onStreamClick, onRunClick, spanDetailData, spa
|
|
|
81693
81707
|
const MAP_HEIGHT = 56;
|
|
81694
81708
|
const TIMELINE_PADDING = 8;
|
|
81695
81709
|
const ROW_PADDING = 2;
|
|
81696
|
-
const ROW_HEIGHT
|
|
81710
|
+
const ROW_HEIGHT = 24;
|
|
81697
81711
|
const MARKER_HEIGHT = 24;
|
|
81698
81712
|
const initialState = {
|
|
81699
81713
|
root: {
|
|
@@ -82429,17 +82443,17 @@ function computeIsNearRightSide(node2, root2, scrollSnapshotRef, isHovered) {
|
|
|
82429
82443
|
}
|
|
82430
82444
|
function computeDefaultLayout(node2, root2, scale, scrollSnapshotRef) {
|
|
82431
82445
|
const left = (node2.startTime - root2.startTime) * scale;
|
|
82432
|
-
let top = MARKER_HEIGHT + (ROW_HEIGHT
|
|
82446
|
+
let top = MARKER_HEIGHT + (ROW_HEIGHT + ROW_PADDING) * node2.row;
|
|
82433
82447
|
const actualWidth = node2.duration * scale;
|
|
82434
82448
|
const width = Math.max(actualWidth, MIN_SPAN_WIDTH);
|
|
82435
|
-
let height = ROW_HEIGHT
|
|
82449
|
+
let height = ROW_HEIGHT;
|
|
82436
82450
|
const isHuge = computeIsHuge(actualWidth);
|
|
82437
82451
|
const isSmall = computeIsSmall(actualWidth);
|
|
82438
82452
|
const isHovered = computeIsHovered(node2, isHuge);
|
|
82439
82453
|
const isExpanded = isHovered || Boolean(node2.isSelected);
|
|
82440
82454
|
if (isSmall && !isExpanded) {
|
|
82441
82455
|
height *= 0.4;
|
|
82442
|
-
top += (ROW_HEIGHT
|
|
82456
|
+
top += (ROW_HEIGHT - height) * 0.5;
|
|
82443
82457
|
}
|
|
82444
82458
|
const isNearRightSide = computeIsNearRightSide(node2, root2, scrollSnapshotRef, isExpanded);
|
|
82445
82459
|
return {
|
|
@@ -82605,8 +82619,8 @@ const SpanComponent = reactExports.memo(function SpanComponent2({ node: node2, r
|
|
|
82605
82619
|
layout.isSmall = liveActualWidth < 64;
|
|
82606
82620
|
layout.isHuge = liveActualWidth >= 500;
|
|
82607
82621
|
if (!layout.isSmall) {
|
|
82608
|
-
layout.height = ROW_HEIGHT
|
|
82609
|
-
layout.top = MARKER_HEIGHT + (ROW_HEIGHT
|
|
82622
|
+
layout.height = ROW_HEIGHT;
|
|
82623
|
+
layout.top = MARKER_HEIGHT + (ROW_HEIGHT + ROW_PADDING) * segmentNode.row;
|
|
82610
82624
|
}
|
|
82611
82625
|
}
|
|
82612
82626
|
reactExports.useEffect(() => {
|
|
@@ -82681,7 +82695,7 @@ const SpanEventComponent = reactExports.memo(function SpanEventComponent2({ even
|
|
|
82681
82695
|
}
|
|
82682
82696
|
}
|
|
82683
82697
|
const left = (event.timestamp - root2.startTime) * scale;
|
|
82684
|
-
const top = MARKER_HEIGHT + (ROW_HEIGHT
|
|
82698
|
+
const top = MARKER_HEIGHT + (ROW_HEIGHT + ROW_PADDING) * node2.row;
|
|
82685
82699
|
const isLeftAligned = node2.duration <= 0 || (event.timestamp - node2.startTime) / node2.duration < 0.5;
|
|
82686
82700
|
const customClassName = customSpanEventClassNameFunc ? customSpanEventClassNameFunc(event) : "";
|
|
82687
82701
|
return jsxRuntimeExports.jsxs("div", { title: phaseDuration ? `${displayLabel} ${timestamp}
|
|
@@ -82962,6 +82976,24 @@ function StreamViewer({ streamId: _streamId, chunks, isLive, error: error2, isLo
|
|
|
82962
82976
|
color: "var(--ds-gray-600)"
|
|
82963
82977
|
}, children: isLive ? "Waiting for stream data..." : "Stream is empty" }) : jsxRuntimeExports.jsx(Yr, { ref: virtuosoRef, totalCount: chunks.length, overscan: 10, endReached: () => onScrollEnd == null ? void 0 : onScrollEnd(), itemContent: (index2) => jsxRuntimeExports.jsx("div", { style: { paddingBottom: 8 }, children: jsxRuntimeExports.jsx(ChunkRow, { chunk: chunks[index2], index: index2 }) }), style: { flex: 1, minHeight: 0 } }) })] });
|
|
82964
82978
|
}
|
|
82979
|
+
const QUERY = "(prefers-reduced-motion: reduce)";
|
|
82980
|
+
const useReducedMotion = () => {
|
|
82981
|
+
const [reduced, setReduced] = reactExports.useState(() => {
|
|
82982
|
+
if (typeof window === "undefined" || !window.matchMedia)
|
|
82983
|
+
return false;
|
|
82984
|
+
return window.matchMedia(QUERY).matches;
|
|
82985
|
+
});
|
|
82986
|
+
reactExports.useEffect(() => {
|
|
82987
|
+
if (typeof window === "undefined" || !window.matchMedia)
|
|
82988
|
+
return;
|
|
82989
|
+
const media = window.matchMedia(QUERY);
|
|
82990
|
+
const onChange = () => setReduced(media.matches);
|
|
82991
|
+
media.addEventListener("change", onChange);
|
|
82992
|
+
onChange();
|
|
82993
|
+
return () => media.removeEventListener("change", onChange);
|
|
82994
|
+
}, []);
|
|
82995
|
+
return reduced;
|
|
82996
|
+
};
|
|
82965
82997
|
function CopyButton({ copyText, ariaLabel, className }) {
|
|
82966
82998
|
const [copied, setCopied] = reactExports.useState(false);
|
|
82967
82999
|
const timeoutRef = reactExports.useRef(null);
|
|
@@ -83096,11 +83128,36 @@ function computeSpanGaps(spans, viewStart, viewEnd) {
|
|
|
83096
83128
|
return gaps;
|
|
83097
83129
|
}
|
|
83098
83130
|
const RESOURCE_COLORS = {
|
|
83099
|
-
run: {
|
|
83100
|
-
|
|
83101
|
-
|
|
83102
|
-
|
|
83103
|
-
|
|
83131
|
+
run: {
|
|
83132
|
+
bg: "var(--ds-blue-200)",
|
|
83133
|
+
border: "var(--ds-blue-500)",
|
|
83134
|
+
errorBg: "var(--ds-red-200)",
|
|
83135
|
+
errorBorder: "var(--ds-red-500)"
|
|
83136
|
+
},
|
|
83137
|
+
step: {
|
|
83138
|
+
bg: "var(--ds-green-200)",
|
|
83139
|
+
border: "var(--ds-green-500)",
|
|
83140
|
+
errorBg: "var(--ds-red-200)",
|
|
83141
|
+
errorBorder: "var(--ds-red-500)"
|
|
83142
|
+
},
|
|
83143
|
+
hook: {
|
|
83144
|
+
bg: "var(--ds-amber-200)",
|
|
83145
|
+
border: "var(--ds-amber-500)",
|
|
83146
|
+
errorBg: "var(--ds-red-200)",
|
|
83147
|
+
errorBorder: "var(--ds-red-500)"
|
|
83148
|
+
},
|
|
83149
|
+
sleep: {
|
|
83150
|
+
bg: "var(--ds-purple-200)",
|
|
83151
|
+
border: "var(--ds-purple-500)",
|
|
83152
|
+
errorBg: "var(--ds-red-200)",
|
|
83153
|
+
errorBorder: "var(--ds-red-500)"
|
|
83154
|
+
},
|
|
83155
|
+
default: {
|
|
83156
|
+
bg: "var(--ds-gray-200)",
|
|
83157
|
+
border: "var(--ds-gray-500)",
|
|
83158
|
+
errorBg: "var(--ds-red-200)",
|
|
83159
|
+
errorBorder: "var(--ds-red-500)"
|
|
83160
|
+
}
|
|
83104
83161
|
};
|
|
83105
83162
|
function getResourceColor(resource) {
|
|
83106
83163
|
return RESOURCE_COLORS[resource] ?? RESOURCE_COLORS.default;
|
|
@@ -83576,7 +83633,7 @@ function MiddleTruncate({ value, className, onCopy: onCopyProp, ...props }) {
|
|
|
83576
83633
|
const eventStyles = {
|
|
83577
83634
|
run: { icon: WorkflowIcon, className: "text-blue-900" },
|
|
83578
83635
|
step: { icon: StepForwardIcon, className: "text-green-900" },
|
|
83579
|
-
hook: { icon: WebhookIcon, className: "text-
|
|
83636
|
+
hook: { icon: WebhookIcon, className: "text-gray-900" },
|
|
83580
83637
|
sleep: { icon: SleepIcon, className: "text-gray-900" }
|
|
83581
83638
|
};
|
|
83582
83639
|
const defaultStyle = {
|
|
@@ -83693,87 +83750,143 @@ function SplitPane({ children: children2, className, defaultStartWidth = DEFAULT
|
|
|
83693
83750
|
}
|
|
83694
83751
|
return jsxRuntimeExports.jsxs("div", { ref: containerRef, className: cn$4("grid h-full min-h-0 content-start overflow-x-hidden overflow-y-auto", isDragging && "select-none", className), style: { gridTemplateColumns: colTemplate, height: "100%" }, children: [start2, gutter, end] });
|
|
83695
83752
|
}
|
|
83696
|
-
const SEGMENT_CONFIG = {
|
|
83697
|
-
queued: { className: "bg-gray-500" },
|
|
83698
|
-
retrying: {
|
|
83699
|
-
className: "box-border bg-gray-500"
|
|
83700
|
-
},
|
|
83701
|
-
waiting: { className: "bg-gray-500" },
|
|
83702
|
-
running: { className: "bg-blue-700" },
|
|
83703
|
-
failed: { className: "bg-red-700" },
|
|
83704
|
-
succeeded: { className: "bg-green-700" },
|
|
83705
|
-
sleeping: { className: "bg-gray-500" },
|
|
83706
|
-
received: { className: "bg-blue-700" }
|
|
83707
|
-
};
|
|
83708
|
-
const BAR_HEIGHT_PX = 24;
|
|
83709
83753
|
const TINY_BAR_BOX_SIZE_PX = 24;
|
|
83710
83754
|
const TINY_BAR_WIDTH_PX = 4;
|
|
83711
|
-
const SEGMENT_GAP_PX = 1;
|
|
83712
|
-
const ROW_HEIGHT = 40;
|
|
83713
|
-
const CONTAINER_PAD_Y = 8;
|
|
83714
|
-
const END_CAP_HEIGHT = 8;
|
|
83715
83755
|
const TIMELINE_PADDING_PX = 16;
|
|
83716
|
-
const
|
|
83717
|
-
|
|
83718
|
-
|
|
83719
|
-
|
|
83720
|
-
|
|
83721
|
-
|
|
83722
|
-
|
|
83723
|
-
|
|
83724
|
-
|
|
83725
|
-
}
|
|
83726
|
-
const
|
|
83756
|
+
const SEGMENT_CLASSES = {
|
|
83757
|
+
queued: "bg-gray-400 border border-gray-500",
|
|
83758
|
+
retrying: "bg-gray-400 border border-gray-500",
|
|
83759
|
+
waiting: "bg-gray-400 border border-gray-500",
|
|
83760
|
+
running: "bg-blue-200 border border-blue-500",
|
|
83761
|
+
failed: "bg-red-200 border border-red-500",
|
|
83762
|
+
succeeded: "bg-green-200 border border-green-500",
|
|
83763
|
+
sleeping: "bg-gray-400 border border-gray-500",
|
|
83764
|
+
received: "bg-blue-200 border border-blue-500"
|
|
83765
|
+
};
|
|
83766
|
+
const TIMELINE_INSET_STYLE = {
|
|
83767
|
+
left: TIMELINE_PADDING_PX,
|
|
83768
|
+
right: TIMELINE_PADDING_PX
|
|
83769
|
+
};
|
|
83770
|
+
function computeBarGeometry(startMs, endMs, viewStart, viewEnd, containerWidth) {
|
|
83771
|
+
const viewDuration = viewEnd - viewStart;
|
|
83772
|
+
const visibleStartMs = Math.max(startMs, viewStart);
|
|
83773
|
+
const visibleEndMs = Math.min(endMs, viewEnd);
|
|
83774
|
+
const visibleDurationMs = Math.max(0, visibleEndMs - visibleStartMs);
|
|
83775
|
+
const widthFrac = viewDuration > 0 ? visibleDurationMs / viewDuration : 0;
|
|
83776
|
+
const visiblePixelWidth = widthFrac * containerWidth;
|
|
83777
|
+
const isTiny = containerWidth > 0 && visiblePixelWidth < TINY_BAR_BOX_SIZE_PX;
|
|
83778
|
+
const extendsOffLeft = startMs < viewStart;
|
|
83779
|
+
const extendsOffRight = endMs > viewEnd;
|
|
83780
|
+
const mode = isTiny && (extendsOffLeft || extendsOffRight) ? { kind: "arrow", direction: extendsOffRight ? "right" : "left" } : isTiny ? { kind: "tiny" } : { kind: "full" };
|
|
83781
|
+
return {
|
|
83782
|
+
mode,
|
|
83783
|
+
leftPct: viewDuration > 0 ? (visibleStartMs - viewStart) / viewDuration * 100 : 0,
|
|
83784
|
+
widthPct: widthFrac * 100,
|
|
83785
|
+
visibleStartMs,
|
|
83786
|
+
visibleEndMs,
|
|
83787
|
+
visiblePixelWidth
|
|
83788
|
+
};
|
|
83789
|
+
}
|
|
83790
|
+
function getBarPositionStyle(geometry) {
|
|
83791
|
+
switch (geometry.mode.kind) {
|
|
83792
|
+
case "arrow":
|
|
83793
|
+
return {
|
|
83794
|
+
left: geometry.mode.direction === "right" ? `calc(100% - ${TINY_BAR_BOX_SIZE_PX}px)` : "0px",
|
|
83795
|
+
width: `${TINY_BAR_BOX_SIZE_PX}px`
|
|
83796
|
+
};
|
|
83797
|
+
case "tiny":
|
|
83798
|
+
return {
|
|
83799
|
+
left: `min(${geometry.leftPct}%, calc(100% - ${TINY_BAR_WIDTH_PX}px))`,
|
|
83800
|
+
width: `${TINY_BAR_WIDTH_PX}px`
|
|
83801
|
+
};
|
|
83802
|
+
case "full":
|
|
83803
|
+
return {
|
|
83804
|
+
left: `${geometry.leftPct}%`,
|
|
83805
|
+
width: `max(${geometry.widthPct}%, 4px)`
|
|
83806
|
+
};
|
|
83807
|
+
}
|
|
83808
|
+
}
|
|
83809
|
+
function projectSegments(segments, spanStartMs, spanDurationMs, geometry) {
|
|
83810
|
+
const visibleDurationMs = geometry.visibleEndMs - geometry.visibleStartMs;
|
|
83811
|
+
if (visibleDurationMs <= 0)
|
|
83812
|
+
return [];
|
|
83813
|
+
return segments.flatMap((seg) => {
|
|
83814
|
+
const segStartMs = spanStartMs + seg.startFraction * spanDurationMs;
|
|
83815
|
+
const segEndMs = spanStartMs + seg.endFraction * spanDurationMs;
|
|
83816
|
+
const startMs = Math.max(segStartMs, geometry.visibleStartMs);
|
|
83817
|
+
const endMs = Math.min(segEndMs, geometry.visibleEndMs);
|
|
83818
|
+
if (endMs <= startMs)
|
|
83819
|
+
return [];
|
|
83820
|
+
const widthFrac = (endMs - startMs) / visibleDurationMs;
|
|
83821
|
+
return [
|
|
83822
|
+
{
|
|
83823
|
+
status: seg.status,
|
|
83824
|
+
leftPct: (startMs - geometry.visibleStartMs) / visibleDurationMs * 100,
|
|
83825
|
+
widthPct: widthFrac * 100,
|
|
83826
|
+
pixelWidth: widthFrac * geometry.visiblePixelWidth,
|
|
83827
|
+
fullDurationMs: (seg.endFraction - seg.startFraction) * spanDurationMs
|
|
83828
|
+
}
|
|
83829
|
+
];
|
|
83830
|
+
});
|
|
83831
|
+
}
|
|
83832
|
+
function DurationLabel({ label }) {
|
|
83833
|
+
return jsxRuntimeExports.jsx("span", { className: "pointer-events-none absolute inset-0 flex items-center justify-start overflow-hidden px-1 text-[10px] font-mono font-medium leading-none whitespace-nowrap text-left text-gray-1000 tabular-nums opacity-0 group-hover/timeline-row:opacity-100", children: label });
|
|
83834
|
+
}
|
|
83835
|
+
function BoundaryArrow({ direction }) {
|
|
83836
|
+
const Icon2 = direction === "right" ? ArrowRight : ArrowLeft;
|
|
83837
|
+
return jsxRuntimeExports.jsx("div", { className: "flex h-6 w-6 items-center justify-center rounded-[0.25rem]", children: jsxRuntimeExports.jsx(Icon2, { className: "size-3 text-gray-900" }) });
|
|
83838
|
+
}
|
|
83839
|
+
function PlainBar({ bg: bg2, border, label }) {
|
|
83840
|
+
return jsxRuntimeExports.jsx("div", { className: "relative h-6 w-full min-w-1 rounded-[0.25rem] border", style: { background: bg2, borderColor: border }, children: label ? jsxRuntimeExports.jsx(DurationLabel, { label }) : null });
|
|
83841
|
+
}
|
|
83842
|
+
function SegmentBar({ segments }) {
|
|
83843
|
+
return jsxRuntimeExports.jsx("div", { className: "relative h-6 w-full", children: segments.map((seg, i) => {
|
|
83844
|
+
const label = formatDuration(seg.fullDurationMs);
|
|
83845
|
+
const showLabel = seg.pixelWidth >= Math.max(40, label.length * 6 + 12);
|
|
83846
|
+
const isNarrowQueued = seg.status === "queued" && seg.pixelWidth < 20;
|
|
83847
|
+
const overrideBg = isNarrowQueued ? "var(--ds-gray-400)" : void 0;
|
|
83848
|
+
const overrideBorder = isNarrowQueued ? "var(--ds-gray-500)" : void 0;
|
|
83849
|
+
return jsxRuntimeExports.jsx("div", { className: cn$4("absolute h-full rounded-[0.25rem]", SEGMENT_CLASSES[seg.status]), style: {
|
|
83850
|
+
// 1px gap between adjacent segments, distributed equally.
|
|
83851
|
+
left: `calc(${seg.leftPct}% + 0.5px)`,
|
|
83852
|
+
width: `calc(${seg.widthPct}% - 1px)`,
|
|
83853
|
+
minWidth: 1,
|
|
83854
|
+
background: overrideBg,
|
|
83855
|
+
borderColor: overrideBorder
|
|
83856
|
+
}, children: showLabel ? jsxRuntimeExports.jsx(DurationLabel, { label }) : null }, `${seg.status}-${i}`);
|
|
83857
|
+
}) });
|
|
83858
|
+
}
|
|
83859
|
+
const TimelineBar = reactExports.memo(function TimelineBar2({ span, viewStart, viewDuration, containerWidth, isSelected, onSelect }) {
|
|
83727
83860
|
var _a3;
|
|
83728
|
-
const
|
|
83729
|
-
const
|
|
83861
|
+
const startMs = getHighResInMs(span.startTime);
|
|
83862
|
+
const endMs = getHighResInMs(span.endTime);
|
|
83730
83863
|
const totalDurationMs = getSpanDurationMs(span);
|
|
83731
|
-
const
|
|
83732
|
-
const
|
|
83733
|
-
const
|
|
83734
|
-
const leftPct = leftFracRaw * 100;
|
|
83735
|
-
const widthPct = widthFrac * 100;
|
|
83736
|
-
const pixelWidth = widthFrac * containerWidth;
|
|
83737
|
-
const visibleLeftFrac = Math.max(0, Math.min(1, leftFracRaw));
|
|
83738
|
-
const visibleRightFrac = Math.max(0, Math.min(1, rightFracRaw));
|
|
83739
|
-
const visiblePixelWidth = Math.max(0, visibleRightFrac - visibleLeftFrac) * containerWidth;
|
|
83740
|
-
const isTinyBar = containerWidth > 0 && visiblePixelWidth < TINY_BAR_BOX_SIZE_PX;
|
|
83741
|
-
const [isRowHovered, setIsRowHovered] = reactExports.useState(false);
|
|
83742
|
-
const segments = reactExports.useMemo(() => computeSpanSegments(span), [span]);
|
|
83864
|
+
const geometry = reactExports.useMemo(() => computeBarGeometry(startMs, endMs, viewStart, viewStart + viewDuration, containerWidth), [startMs, endMs, viewStart, viewDuration, containerWidth]);
|
|
83865
|
+
const baseSegments = reactExports.useMemo(() => computeSpanSegments(span), [span]);
|
|
83866
|
+
const segments = reactExports.useMemo(() => geometry.mode.kind === "full" ? projectSegments(baseSegments, startMs, totalDurationMs, geometry) : [], [geometry, baseSegments, startMs, totalDurationMs]);
|
|
83743
83867
|
const workflowStatus = (_a3 = span.attributes.data) == null ? void 0 : _a3.status;
|
|
83744
83868
|
const isErrored = span.status.code === 2 || workflowStatus === "failed";
|
|
83745
83869
|
const colors = getResourceColor(span.resource);
|
|
83746
|
-
const
|
|
83747
|
-
const
|
|
83748
|
-
const
|
|
83749
|
-
const
|
|
83750
|
-
const
|
|
83751
|
-
|
|
83752
|
-
|
|
83753
|
-
|
|
83754
|
-
|
|
83755
|
-
|
|
83756
|
-
|
|
83757
|
-
|
|
83758
|
-
|
|
83759
|
-
|
|
83760
|
-
|
|
83761
|
-
|
|
83762
|
-
|
|
83763
|
-
|
|
83764
|
-
|
|
83765
|
-
|
|
83766
|
-
minWidth: 4,
|
|
83767
|
-
background: fallbackColor
|
|
83768
|
-
}, children: showBarDurationLabel ? renderDurationLabel(totalDurationLabel) : null });
|
|
83769
|
-
return jsxRuntimeExports.jsx("div", { role: "treeitem", "aria-selected": isSelected, "aria-expanded": isSelected, "aria-level": 1, className: cn$4("h-10 relative flex items-center hover:bg-gray-100 aria-selected:bg-gray-100 aria-selected:hover:bg-gray-200"), onMouseEnter: () => setIsRowHovered(true), onMouseLeave: () => setIsRowHovered(false), onClick, children: jsxRuntimeExports.jsx("div", { className: "absolute inset-y-0", style: {
|
|
83770
|
-
left: TIMELINE_PADDING_PX,
|
|
83771
|
-
right: TIMELINE_PADDING_PX
|
|
83772
|
-
}, children: jsxRuntimeExports.jsx("div", { className: "absolute top-1/2 -translate-y-1/2", style: {
|
|
83773
|
-
left: showBoundaryArrow ? `min(max(${leftPct}%, 0px), calc(100% - ${TINY_BAR_BOX_SIZE_PX}px))` : isTinyBar ? `min(${leftPct}%, calc(100% - ${TINY_BAR_WIDTH_PX}px))` : `${leftPct}%`,
|
|
83774
|
-
width: showBoundaryArrow ? `${TINY_BAR_BOX_SIZE_PX}px` : isTinyBar ? `${TINY_BAR_WIDTH_PX}px` : `max(${widthPct}%, 4px)`,
|
|
83775
|
-
height: BAR_HEIGHT_PX
|
|
83776
|
-
}, children: barContent }) }) });
|
|
83870
|
+
const fallbackBg = isErrored ? colors.errorBg ?? "var(--ds-red-200)" : colors.bg;
|
|
83871
|
+
const fallbackBorder = isErrored ? colors.errorBorder ?? "var(--ds-red-500)" : colors.border;
|
|
83872
|
+
const totalLabel = formatDuration(totalDurationMs);
|
|
83873
|
+
const showTotalLabel = geometry.visiblePixelWidth >= Math.max(40, totalLabel.length * 6 + 12);
|
|
83874
|
+
const handleClick = reactExports.useCallback(() => {
|
|
83875
|
+
onSelect(span.spanId);
|
|
83876
|
+
}, [onSelect, span.spanId]);
|
|
83877
|
+
return jsxRuntimeExports.jsx("div", { role: "treeitem", "aria-selected": isSelected, "aria-expanded": isSelected, "aria-level": 1, className: "group/timeline-row h-10 relative flex items-center hover:bg-gray-100 aria-selected:bg-gray-100 aria-selected:hover:bg-gray-200", onClick: handleClick, children: jsxRuntimeExports.jsx("div", { className: "absolute inset-y-0", style: TIMELINE_INSET_STYLE, children: jsxRuntimeExports.jsx("div", { className: "absolute top-1/2 h-6 -translate-y-1/2", style: getBarPositionStyle(geometry), children: geometry.mode.kind === "arrow" ? jsxRuntimeExports.jsx(BoundaryArrow, { direction: geometry.mode.direction }) : geometry.mode.kind === "tiny" ? jsxRuntimeExports.jsx("div", { className: "h-6 rounded-[0.25rem] border", style: { background: fallbackBg, borderColor: fallbackBorder } }) : segments.length > 0 ? jsxRuntimeExports.jsx(SegmentBar, { segments }) : jsxRuntimeExports.jsx(PlainBar, { bg: fallbackBg, border: fallbackBorder, label: showTotalLabel ? totalLabel : null }) }) }) });
|
|
83878
|
+
});
|
|
83879
|
+
const DELTA_ROW_HEIGHT_PX = 40;
|
|
83880
|
+
const DELTA_CAP_HEIGHT_PX = 8;
|
|
83881
|
+
const DELTA_ROW_OFFSET_PX = 8;
|
|
83882
|
+
const DeltaIndicator = reactExports.memo(function DeltaIndicator2({ leftFrac, rightFrac, label, rowIndex }) {
|
|
83883
|
+
const centerY = DELTA_ROW_OFFSET_PX + (rowIndex + 1) * DELTA_ROW_HEIGHT_PX;
|
|
83884
|
+
return jsxRuntimeExports.jsxs("div", { className: "absolute pointer-events-none", style: {
|
|
83885
|
+
left: `${leftFrac * 100}%`,
|
|
83886
|
+
width: `${(rightFrac - leftFrac) * 100}%`,
|
|
83887
|
+
top: centerY - DELTA_CAP_HEIGHT_PX / 2,
|
|
83888
|
+
height: DELTA_CAP_HEIGHT_PX
|
|
83889
|
+
}, children: [jsxRuntimeExports.jsx("div", { className: "absolute left-0 top-0 w-px h-full bg-amber-800" }), jsxRuntimeExports.jsx("div", { className: "absolute left-0 right-0 top-1/2 h-px bg-amber-800" }), jsxRuntimeExports.jsx("div", { className: "absolute right-0 top-0 w-px h-full bg-amber-800" }), jsxRuntimeExports.jsx("span", { className: "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 text-label-12 leading-none whitespace-nowrap rounded-xs px-1 py-0.5 text-gray-100 bg-amber-800", children: label })] });
|
|
83777
83890
|
});
|
|
83778
83891
|
function TimelineHeader({ markers: markers2, hoverInfo: hoverInfo2 }) {
|
|
83779
83892
|
return jsxRuntimeExports.jsx("div", { className: "relative bg-background-100 border-b border-gray-alpha-400 h-10 min-h-10 flex items-end px-4 pb-1", children: jsxRuntimeExports.jsxs("div", { className: "relative h-full flex-1", children: [markers2.map((m2) => jsxRuntimeExports.jsx("span", { className: "absolute bottom-1 font-mono text-xs font-normal leading-4 text-gray-900 whitespace-nowrap", style: { left: `${m2.position * 100}%` }, children: m2.label }, `${m2.position}-${m2.label}`)), hoverInfo2 && jsxRuntimeExports.jsx("span", { className: "absolute top-1 pointer-events-none z-10 font-mono text-[11px] leading-4 text-gray-1000 whitespace-nowrap bg-background-100 border border-gray-alpha-400 rounded px-1 -translate-x-1/2", style: { left: `${hoverInfo2.fraction * 100}%` }, children: hoverInfo2.label })] }) });
|
|
@@ -83794,16 +83907,10 @@ function Timeline({ spans, viewStart, viewEnd, markers: markers2, selectedId, on
|
|
|
83794
83907
|
return () => ro2.disconnect();
|
|
83795
83908
|
}, []);
|
|
83796
83909
|
const gaps = reactExports.useMemo(() => computeSpanGaps(spans, viewStart, viewEnd), [spans, viewStart, viewEnd]);
|
|
83797
|
-
return jsxRuntimeExports.jsxs("div", { ref: containerRef, className: "relative h-full overflow-hidden", children: [jsxRuntimeExports.jsx("div", { "aria-hidden": true, className: "absolute inset-y-0 pointer-events-none", style:
|
|
83798
|
-
left
|
|
83799
|
-
|
|
83800
|
-
},
|
|
83801
|
-
left: TIMELINE_PADDING_PX,
|
|
83802
|
-
right: TIMELINE_PADDING_PX
|
|
83803
|
-
}, children: jsxRuntimeExports.jsx("div", { className: "absolute top-0 bottom-0 w-px bg-gray-alpha-400", style: { left: `${hoverFraction * 100}%` } }) }), spans.map((span) => jsxRuntimeExports.jsx(TimelineBar, { span, viewStart, viewDuration, containerWidth: timelineWidth, isSelected: selectedId === span.spanId, onClick: () => onSelect(span.spanId) }, span.spanId)), altHeld && jsxRuntimeExports.jsx("div", { "aria-hidden": true, className: "absolute inset-y-0 pointer-events-none", style: {
|
|
83804
|
-
left: TIMELINE_PADDING_PX,
|
|
83805
|
-
right: TIMELINE_PADDING_PX
|
|
83806
|
-
}, children: gaps.map((gap) => jsxRuntimeExports.jsx(DeltaIndicator, { leftFrac: gap.leftFrac, rightFrac: gap.rightFrac, label: formatDuration(gap.gapMs, true), rowIndex: gap.rowIndex }, gap.rowIndex)) })] });
|
|
83910
|
+
return jsxRuntimeExports.jsxs("div", { ref: containerRef, className: "relative h-full overflow-hidden", children: [jsxRuntimeExports.jsx("div", { "aria-hidden": true, className: "absolute inset-y-0 pointer-events-none", style: TIMELINE_INSET_STYLE, children: markers2.map((marker2) => (
|
|
83911
|
+
// Skip the "0s" origin marker since the left edge already implies it.
|
|
83912
|
+
Math.abs(marker2.value) > 1e-6 ? jsxRuntimeExports.jsx("div", { className: "absolute top-0 bottom-0 w-px bg-gray-alpha-300", style: { left: `${marker2.position * 100}%` } }, `${marker2.position}-${marker2.label}`) : null
|
|
83913
|
+
)) }), hoverFraction != null && jsxRuntimeExports.jsx("div", { className: "absolute inset-y-0 pointer-events-none z-10", style: TIMELINE_INSET_STYLE, children: jsxRuntimeExports.jsx("div", { className: "absolute top-0 bottom-0 w-px bg-gray-alpha-500", style: { left: `${hoverFraction * 100}%` } }) }), spans.map((span) => jsxRuntimeExports.jsx(TimelineBar, { span, viewStart, viewDuration, containerWidth: timelineWidth, isSelected: selectedId === span.spanId, onSelect }, span.spanId)), altHeld && jsxRuntimeExports.jsx("div", { "aria-hidden": true, className: "absolute inset-y-0 pointer-events-none", style: TIMELINE_INSET_STYLE, children: gaps.map((gap) => jsxRuntimeExports.jsx(DeltaIndicator, { leftFrac: gap.leftFrac, rightFrac: gap.rightFrac, label: formatDuration(gap.gapMs, true), rowIndex: gap.rowIndex }, gap.rowIndex)) })] });
|
|
83807
83914
|
}
|
|
83808
83915
|
const ActiveSpanContext = reactExports.createContext(null);
|
|
83809
83916
|
ActiveSpanContext.displayName = "ActiveSpanContext";
|
|
@@ -83861,6 +83968,7 @@ function useAnimatedViewport(initial) {
|
|
|
83861
83968
|
const animRef = reactExports.useRef(null);
|
|
83862
83969
|
const currentRef = reactExports.useRef(initial);
|
|
83863
83970
|
currentRef.current = viewport;
|
|
83971
|
+
const reducedMotion = useReducedMotion();
|
|
83864
83972
|
const cancel = reactExports.useCallback(() => {
|
|
83865
83973
|
if (animRef.current) {
|
|
83866
83974
|
cancelAnimationFrame(animRef.current.raf);
|
|
@@ -83869,6 +83977,11 @@ function useAnimatedViewport(initial) {
|
|
|
83869
83977
|
}, []);
|
|
83870
83978
|
const animateTo = reactExports.useCallback((target2) => {
|
|
83871
83979
|
cancel();
|
|
83980
|
+
if (reducedMotion) {
|
|
83981
|
+
currentRef.current = target2;
|
|
83982
|
+
setViewportState(target2);
|
|
83983
|
+
return;
|
|
83984
|
+
}
|
|
83872
83985
|
const from = currentRef.current;
|
|
83873
83986
|
const anim = { raf: 0, from, to: target2, start: performance.now() };
|
|
83874
83987
|
const tick = () => {
|
|
@@ -83885,7 +83998,7 @@ function useAnimatedViewport(initial) {
|
|
|
83885
83998
|
};
|
|
83886
83999
|
animRef.current = anim;
|
|
83887
84000
|
anim.raf = requestAnimationFrame(tick);
|
|
83888
|
-
}, [cancel]);
|
|
84001
|
+
}, [cancel, reducedMotion]);
|
|
83889
84002
|
const setViewport = reactExports.useCallback((update) => {
|
|
83890
84003
|
cancel();
|
|
83891
84004
|
if (typeof update === "function") {
|
|
@@ -84166,7 +84279,7 @@ function NewTraceViewerContent({ trace: trace2 }) {
|
|
|
84166
84279
|
}
|
|
84167
84280
|
return data.stepId ?? data.runId ?? data.hookId ?? selectedSpan.spanId;
|
|
84168
84281
|
}, [selectedSpan == null ? void 0 : selectedSpan.data, selectedSpan == null ? void 0 : selectedSpan.resource, selectedSpan == null ? void 0 : selectedSpan.spanId]);
|
|
84169
|
-
return jsxRuntimeExports.jsxs("div", { "data-pane": "pane-root", "data-has-detail": activeSpan ? "" : void 0, className: "grid w-full h-full max-h-full grid-cols-[minmax(100px,1fr)] data-[has-detail]:grid-cols-[minmax(100px,1fr)_clamp(280px,420px,100%)]", children: [jsxRuntimeExports.jsxs("div", { id: "trace-parent", className: "grid grid-rows-[1fr] h-full min-h-0 overflow-hidden relative bg-background-100", children: [jsxRuntimeExports.jsxs(SplitPane, { startHeader: jsxRuntimeExports.jsxs("div", { className: "bg-background-100 border-b border-gray-alpha-400 h-10 min-h-10 flex items-center px-2 gap-1.5", children: [jsxRuntimeExports.jsx(Search, { className: "w-3.5 h-3.5 shrink-0 text-gray-800" }), jsxRuntimeExports.jsx("input", { id: "trace-viewer-search", name: "trace-viewer-search", type: "text", value: searchQuery, onChange: (e) => setSearchQuery(e.target.value), placeholder: "Search spans...", "aria-label": "Search spans", className: "flex-1 min-w-0 bg-transparent text-sm text-gray-1000 placeholder:text-gray-800 outline-none" }), searchQuery && jsxRuntimeExports.jsx("button", { type: "button", onClick: () => setSearchQuery(""), className: "shrink-0 p-0.5 rounded-sm text-gray-800 hover:text-gray-1000 hover:bg-gray-200 transition-colors", children: jsxRuntimeExports.jsx(X$3, { className: "w-3 h-3" }) })] }), endHeader: jsxRuntimeExports.jsx(TimelineHeader, { markers: timeMarkers, hoverInfo: hoverInfo2 }), children: [jsxRuntimeExports.jsx("div", { className: "block overflow-visible", children: jsxRuntimeExports.jsx(EventList, { spans: filteredSpans, activeSpanId, onSelectSpan: handleSelectSpan }) }), jsxRuntimeExports.jsx("div", { ref: timelineRef, className: "block min-h-0 overflow-visible relative", onDoubleClick: resetZoom, onMouseMove: handleTimelineMouseMove, onMouseLeave: handleTimelineMouseLeave, children: jsxRuntimeExports.jsx(Timeline, { spans: filteredSpans, viewStart: viewport.start, viewEnd: viewport.end, markers: timeMarkers, selectedId: activeSpanId, onSelect: handleSelectSpan, hoverFraction, altHeld }) })] }), jsxRuntimeExports.jsxs("div", { className: "absolute right-3 bottom-3 z-[5] flex items-center border border-gray-alpha-400 rounded-lg bg-background-100 shadow-sm overflow-hidden divide-x divide-gray-alpha-400", children: [jsxRuntimeExports.jsx("button", { type: "button", className: "flex items-center justify-center w-8 h-8 text-gray-900 cursor-pointer transition-colors duration-[120ms] ease-in-out hover:text-gray-1000 hover:bg-gray-alpha-100", onClick: zoomOut, "aria-label": "Zoom out", children: jsxRuntimeExports.jsx(ZoomOut, { className: "w-4 h-4" }) }), jsxRuntimeExports.jsx("button", { type: "button", className: "flex items-center justify-center w-8 h-8 text-gray-900 cursor-pointer transition-colors duration-[120ms] ease-in-out hover:text-gray-1000 hover:bg-gray-alpha-100", onClick: resetZoom, "aria-label": "Reset zoom", children: jsxRuntimeExports.jsx(RotateCcw, { className: "w-3.5 h-3.5" }) }), jsxRuntimeExports.jsx("button", { type: "button", className: "flex items-center justify-center w-8 h-8 text-gray-900 cursor-pointer transition-colors duration-[120ms] ease-in-out hover:text-gray-1000 hover:bg-gray-alpha-100", onClick: zoomIn, "aria-label": "Zoom in", children: jsxRuntimeExports.jsx(ZoomIn, { className: "w-4 h-4" }) })] })] }), activeSpan && sidebar ? jsxRuntimeExports.jsxs("aside", { className: "flex flex-col h-full max-h-full bg-background-100 border-l border-gray-alpha-400 overflow-auto", children: [jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 px-4 pt-4 pb-3", children: jsxRuntimeExports.jsxs("div", { className: "flex items-start justify-between gap-2", children: [jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [jsxRuntimeExports.jsx("span", { className: "text-[15px] font-semibold text-gray-1000 truncate block", children: selectedSpanName }), selectedResourceId && jsxRuntimeExports.jsxs("div", { className: "mt-1 flex items-center gap-2", children: [selectedResource && jsxRuntimeExports.jsx("span", { className: `inline-flex items-center rounded-md px-1.5 py-0.5 text-[11px] font-medium leading-none shrink-0 ${selectedResource === "step" ? "bg-green-200 text-green-900" : selectedResource === "run" ? "bg-blue-200 text-blue-900" :
|
|
84282
|
+
return jsxRuntimeExports.jsxs("div", { "data-pane": "pane-root", "data-has-detail": activeSpan ? "" : void 0, className: "grid w-full h-full max-h-full grid-cols-[minmax(100px,1fr)] data-[has-detail]:grid-cols-[minmax(100px,1fr)_clamp(280px,420px,100%)]", children: [jsxRuntimeExports.jsxs("div", { id: "trace-parent", className: "grid grid-rows-[1fr] h-full min-h-0 overflow-hidden relative bg-background-100", children: [jsxRuntimeExports.jsxs(SplitPane, { startHeader: jsxRuntimeExports.jsxs("div", { className: "bg-background-100 border-b border-gray-alpha-400 h-10 min-h-10 flex items-center px-2 gap-1.5", children: [jsxRuntimeExports.jsx(Search, { className: "w-3.5 h-3.5 shrink-0 text-gray-800" }), jsxRuntimeExports.jsx("input", { id: "trace-viewer-search", name: "trace-viewer-search", type: "text", value: searchQuery, onChange: (e) => setSearchQuery(e.target.value), placeholder: "Search spans...", "aria-label": "Search spans", className: "flex-1 min-w-0 bg-transparent text-sm text-gray-1000 placeholder:text-gray-800 outline-none" }), searchQuery && jsxRuntimeExports.jsx("button", { type: "button", onClick: () => setSearchQuery(""), className: "shrink-0 p-0.5 rounded-sm text-gray-800 hover:text-gray-1000 hover:bg-gray-200 transition-colors", children: jsxRuntimeExports.jsx(X$3, { className: "w-3 h-3" }) })] }), endHeader: jsxRuntimeExports.jsx(TimelineHeader, { markers: timeMarkers, hoverInfo: hoverInfo2 }), children: [jsxRuntimeExports.jsx("div", { className: "block overflow-visible", children: jsxRuntimeExports.jsx(EventList, { spans: filteredSpans, activeSpanId, onSelectSpan: handleSelectSpan }) }), jsxRuntimeExports.jsx("div", { ref: timelineRef, className: "block min-h-0 overflow-visible relative", onDoubleClick: resetZoom, onMouseMove: handleTimelineMouseMove, onMouseLeave: handleTimelineMouseLeave, children: jsxRuntimeExports.jsx(Timeline, { spans: filteredSpans, viewStart: viewport.start, viewEnd: viewport.end, markers: timeMarkers, selectedId: activeSpanId, onSelect: handleSelectSpan, hoverFraction, altHeld }) })] }), jsxRuntimeExports.jsxs("div", { className: "absolute right-3 bottom-3 z-[5] flex items-center border border-gray-alpha-400 rounded-lg bg-background-100 shadow-sm overflow-hidden divide-x divide-gray-alpha-400", children: [jsxRuntimeExports.jsx("button", { type: "button", className: "flex items-center justify-center w-8 h-8 text-gray-900 cursor-pointer transition-colors duration-[time:120ms] ease-in-out hover:text-gray-1000 hover:bg-gray-alpha-100", onClick: zoomOut, "aria-label": "Zoom out", children: jsxRuntimeExports.jsx(ZoomOut, { className: "w-4 h-4" }) }), jsxRuntimeExports.jsx("button", { type: "button", className: "flex items-center justify-center w-8 h-8 text-gray-900 cursor-pointer transition-colors duration-[time:120ms] ease-in-out hover:text-gray-1000 hover:bg-gray-alpha-100", onClick: resetZoom, "aria-label": "Reset zoom", children: jsxRuntimeExports.jsx(RotateCcw, { className: "w-3.5 h-3.5" }) }), jsxRuntimeExports.jsx("button", { type: "button", className: "flex items-center justify-center w-8 h-8 text-gray-900 cursor-pointer transition-colors duration-[time:120ms] ease-in-out hover:text-gray-1000 hover:bg-gray-alpha-100", onClick: zoomIn, "aria-label": "Zoom in", children: jsxRuntimeExports.jsx(ZoomIn, { className: "w-4 h-4" }) })] })] }), activeSpan && sidebar ? jsxRuntimeExports.jsxs("aside", { className: "flex flex-col h-full max-h-full bg-background-100 border-l border-gray-alpha-400 overflow-auto", children: [jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 px-4 pt-4 pb-3", children: jsxRuntimeExports.jsxs("div", { className: "flex items-start justify-between gap-2", children: [jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [jsxRuntimeExports.jsx("span", { className: "text-[15px] font-semibold text-gray-1000 truncate block", children: selectedSpanName }), selectedResourceId && jsxRuntimeExports.jsxs("div", { className: "mt-1 flex items-center gap-2", children: [selectedResource && jsxRuntimeExports.jsx("span", { className: `inline-flex items-center rounded-md px-1.5 py-0.5 text-[11px] font-medium leading-none shrink-0 ${selectedResource === "step" ? "bg-green-200 text-green-900" : selectedResource === "run" ? "bg-blue-200 text-blue-900" : "bg-gray-200 text-gray-900"}`, children: selectedResource.charAt(0).toUpperCase() + selectedResource.slice(1) }), jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1 text-[13px] font-mono text-gray-700 min-w-0", title: selectedResourceId, children: [jsxRuntimeExports.jsx("span", { className: "truncate", children: selectedResourceId }), jsxRuntimeExports.jsx(CopyButton, { copyText: selectedResourceId, ariaLabel: "Copy ID", className: "shrink-0" })] })] })] }), jsxRuntimeExports.jsx("button", { type: "button", className: "p-1 rounded-md text-gray-900 hover:text-gray-1000 hover:bg-gray-alpha-200 transition-colors shrink-0", onClick: clearActiveSpan, children: jsxRuntimeExports.jsx(X$3, { className: "w-4 h-4" }) })] }) }), jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-y-auto", children: jsxRuntimeExports.jsx(ErrorBoundary$1, { children: jsxRuntimeExports.jsx(EntityDetailPanel, { run: sidebar.run, onStreamClick: sidebar.onStreamClick, onRunClick: sidebar.onRunClick, spanDetailData: sidebar.spanDetailData, spanDetailError: sidebar.spanDetailError, spanDetailLoading: sidebar.spanDetailLoading, onSpanSelect: sidebar.onSpanSelect, onWakeUpSleep: sidebar.onWakeUpSleep, onLoadEventData: sidebar.onLoadEventData, onResolveHook: sidebar.onResolveHook, encryptionKey: sidebar.encryptionKey, onDecrypt: sidebar.onDecrypt, isDecrypting: sidebar.isDecrypting, selectedSpan }) }) })] }) : activeSpan ? jsxRuntimeExports.jsx(DetailPanel, { span: activeSpan, rootStart: root2.startTime, onClose: clearActiveSpan }) : null] });
|
|
84170
84283
|
}
|
|
84171
84284
|
const NewTraceViewer = ({ run, events: events2, sidebarData }) => {
|
|
84172
84285
|
const traceWithMeta = reactExports.useMemo(() => {
|
|
@@ -87383,7 +87496,8 @@ function buildFramedDetails(hint2, slug) {
|
|
|
87383
87496
|
}
|
|
87384
87497
|
const ERROR_SLUGS = {
|
|
87385
87498
|
WEBHOOK_INVALID_RESPOND_WITH_VALUE: "webhook-invalid-respond-with-value",
|
|
87386
|
-
WEBHOOK_RESPONSE_NOT_SENT: "webhook-response-not-sent"
|
|
87499
|
+
WEBHOOK_RESPONSE_NOT_SENT: "webhook-response-not-sent",
|
|
87500
|
+
HOOK_CONFLICT: "hook-conflict"
|
|
87387
87501
|
};
|
|
87388
87502
|
class WorkflowError extends Error {
|
|
87389
87503
|
constructor(message2, options) {
|
|
@@ -87500,6 +87614,25 @@ class WorkflowRunNotFoundError extends WorkflowError {
|
|
|
87500
87614
|
return isError(value) && value.name === "WorkflowRunNotFoundError";
|
|
87501
87615
|
}
|
|
87502
87616
|
}
|
|
87617
|
+
class HookConflictError extends WorkflowError {
|
|
87618
|
+
constructor(token, conflictingRunId) {
|
|
87619
|
+
super(`Hook token "${token}" is already in use by another workflow${conflictingRunId ? ` (run "${conflictingRunId}")` : ""}`, {
|
|
87620
|
+
slug: ERROR_SLUGS.HOOK_CONFLICT
|
|
87621
|
+
});
|
|
87622
|
+
__publicField(this, "token");
|
|
87623
|
+
// TODO: Make this required once all persisted hook_conflict events and World
|
|
87624
|
+
// implementations always include the active hook owner's run ID.
|
|
87625
|
+
__publicField(this, "conflictingRunId");
|
|
87626
|
+
this.name = "HookConflictError";
|
|
87627
|
+
this.token = token;
|
|
87628
|
+
if (conflictingRunId !== void 0) {
|
|
87629
|
+
this.conflictingRunId = conflictingRunId;
|
|
87630
|
+
}
|
|
87631
|
+
}
|
|
87632
|
+
static is(value) {
|
|
87633
|
+
return isError(value) && value.name === "HookConflictError";
|
|
87634
|
+
}
|
|
87635
|
+
}
|
|
87503
87636
|
class HookNotFoundError extends WorkflowError {
|
|
87504
87637
|
constructor(token) {
|
|
87505
87638
|
super("Hook not found", {});
|
|
@@ -87608,6 +87741,7 @@ class RetryableError extends Error {
|
|
|
87608
87741
|
const VERCEL_403_ERROR_MESSAGE = "Your current vercel account does not have access to this resource. Use `vercel login` or `vercel switch` to ensure you are linked to the right account.";
|
|
87609
87742
|
const FATAL_ERROR_KEY = Symbol.for("@workflow/errors//FatalError");
|
|
87610
87743
|
const RETRYABLE_ERROR_KEY = Symbol.for("@workflow/errors//RetryableError");
|
|
87744
|
+
const HOOK_CONFLICT_ERROR_KEY = Symbol.for("@workflow/errors//HookConflictError");
|
|
87611
87745
|
if (typeof globalThis !== "undefined") {
|
|
87612
87746
|
if (!Object.hasOwn(globalThis, FATAL_ERROR_KEY)) {
|
|
87613
87747
|
Object.defineProperty(globalThis, FATAL_ERROR_KEY, {
|
|
@@ -87625,6 +87759,14 @@ if (typeof globalThis !== "undefined") {
|
|
|
87625
87759
|
configurable: false
|
|
87626
87760
|
});
|
|
87627
87761
|
}
|
|
87762
|
+
if (!Object.hasOwn(globalThis, HOOK_CONFLICT_ERROR_KEY)) {
|
|
87763
|
+
Object.defineProperty(globalThis, HOOK_CONFLICT_ERROR_KEY, {
|
|
87764
|
+
value: HookConflictError,
|
|
87765
|
+
writable: false,
|
|
87766
|
+
enumerable: false,
|
|
87767
|
+
configurable: false
|
|
87768
|
+
});
|
|
87769
|
+
}
|
|
87628
87770
|
}
|
|
87629
87771
|
const colorEnabled = (() => {
|
|
87630
87772
|
var _a3;
|
|
@@ -88062,14 +88204,20 @@ const runtimeLogger = createLogger("runtime");
|
|
|
88062
88204
|
const NONCE_LENGTH = 12;
|
|
88063
88205
|
const TAG_LENGTH = 128;
|
|
88064
88206
|
const KEY_LENGTH = 32;
|
|
88065
|
-
async function importKey(raw2) {
|
|
88207
|
+
async function importKey(raw2, usages = ["encrypt", "decrypt"]) {
|
|
88066
88208
|
if (raw2.byteLength !== KEY_LENGTH) {
|
|
88067
88209
|
throw new WorkflowRuntimeError(`Encryption key must be exactly ${KEY_LENGTH} bytes, got ${raw2.byteLength}`);
|
|
88068
88210
|
}
|
|
88069
|
-
return globalThis.crypto.subtle.importKey(
|
|
88070
|
-
"
|
|
88071
|
-
|
|
88072
|
-
|
|
88211
|
+
return globalThis.crypto.subtle.importKey(
|
|
88212
|
+
"raw",
|
|
88213
|
+
raw2,
|
|
88214
|
+
"AES-GCM",
|
|
88215
|
+
false,
|
|
88216
|
+
// `KeyUsage` is a DOM-lib type that's not in scope under `es2022`.
|
|
88217
|
+
// The `ReadonlyArray<'encrypt' | 'decrypt'>` parameter type matches
|
|
88218
|
+
// a strict subset of `KeyUsage[]`, so this cast is sound.
|
|
88219
|
+
usages
|
|
88220
|
+
);
|
|
88073
88221
|
}
|
|
88074
88222
|
async function encrypt$1(key, data) {
|
|
88075
88223
|
const nonce = globalThis.crypto.getRandomValues(new Uint8Array(NONCE_LENGTH));
|
|
@@ -88095,7 +88243,7 @@ const encryption = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
88095
88243
|
encrypt: encrypt$1,
|
|
88096
88244
|
importKey
|
|
88097
88245
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
88098
|
-
const version$1 = "5.0.0-beta.
|
|
88246
|
+
const version$1 = "5.0.0-beta.7";
|
|
88099
88247
|
const WorldCacheKey = Symbol.for("@workflow/world//cache");
|
|
88100
88248
|
const WorldCachePromiseKey = Symbol.for("@workflow/world//cachePromise");
|
|
88101
88249
|
const GetWorldFnKey$1 = Symbol.for("@workflow/world//getWorldFn");
|
|
@@ -88229,6 +88377,849 @@ async function healthCheck(world, endpoint, options) {
|
|
|
88229
88377
|
};
|
|
88230
88378
|
}
|
|
88231
88379
|
}
|
|
88380
|
+
const LOCK_POLL_INTERVAL_MS = 10;
|
|
88381
|
+
function createFlushableState() {
|
|
88382
|
+
return {
|
|
88383
|
+
...withResolvers$1(),
|
|
88384
|
+
pendingOps: 0,
|
|
88385
|
+
doneResolved: false,
|
|
88386
|
+
streamEnded: false
|
|
88387
|
+
};
|
|
88388
|
+
}
|
|
88389
|
+
function isWritableUnlockedNotClosed(writable) {
|
|
88390
|
+
if (writable.locked)
|
|
88391
|
+
return false;
|
|
88392
|
+
let writer;
|
|
88393
|
+
try {
|
|
88394
|
+
writer = writable.getWriter();
|
|
88395
|
+
} catch {
|
|
88396
|
+
return false;
|
|
88397
|
+
}
|
|
88398
|
+
try {
|
|
88399
|
+
writer.releaseLock();
|
|
88400
|
+
} catch {
|
|
88401
|
+
return false;
|
|
88402
|
+
}
|
|
88403
|
+
return true;
|
|
88404
|
+
}
|
|
88405
|
+
function isReadableUnlockedNotClosed(readable2) {
|
|
88406
|
+
if (readable2.locked)
|
|
88407
|
+
return false;
|
|
88408
|
+
let reader;
|
|
88409
|
+
try {
|
|
88410
|
+
reader = readable2.getReader();
|
|
88411
|
+
} catch {
|
|
88412
|
+
return false;
|
|
88413
|
+
}
|
|
88414
|
+
try {
|
|
88415
|
+
reader.releaseLock();
|
|
88416
|
+
} catch {
|
|
88417
|
+
return false;
|
|
88418
|
+
}
|
|
88419
|
+
return true;
|
|
88420
|
+
}
|
|
88421
|
+
function pollWritableLock(writable, state) {
|
|
88422
|
+
if (state.writablePollingInterval !== void 0) {
|
|
88423
|
+
return;
|
|
88424
|
+
}
|
|
88425
|
+
const intervalId = setInterval(() => {
|
|
88426
|
+
if (state.doneResolved || state.streamEnded) {
|
|
88427
|
+
clearInterval(intervalId);
|
|
88428
|
+
state.writablePollingInterval = void 0;
|
|
88429
|
+
return;
|
|
88430
|
+
}
|
|
88431
|
+
if (isWritableUnlockedNotClosed(writable) && state.pendingOps === 0) {
|
|
88432
|
+
state.doneResolved = true;
|
|
88433
|
+
state.resolve();
|
|
88434
|
+
clearInterval(intervalId);
|
|
88435
|
+
state.writablePollingInterval = void 0;
|
|
88436
|
+
}
|
|
88437
|
+
}, LOCK_POLL_INTERVAL_MS);
|
|
88438
|
+
state.writablePollingInterval = intervalId;
|
|
88439
|
+
}
|
|
88440
|
+
function pollReadableLock(readable2, state) {
|
|
88441
|
+
if (state.readablePollingInterval !== void 0) {
|
|
88442
|
+
return;
|
|
88443
|
+
}
|
|
88444
|
+
const intervalId = setInterval(() => {
|
|
88445
|
+
if (state.doneResolved || state.streamEnded) {
|
|
88446
|
+
clearInterval(intervalId);
|
|
88447
|
+
state.readablePollingInterval = void 0;
|
|
88448
|
+
return;
|
|
88449
|
+
}
|
|
88450
|
+
if (isReadableUnlockedNotClosed(readable2) && state.pendingOps === 0) {
|
|
88451
|
+
state.doneResolved = true;
|
|
88452
|
+
state.resolve();
|
|
88453
|
+
clearInterval(intervalId);
|
|
88454
|
+
state.readablePollingInterval = void 0;
|
|
88455
|
+
}
|
|
88456
|
+
}, LOCK_POLL_INTERVAL_MS);
|
|
88457
|
+
state.readablePollingInterval = intervalId;
|
|
88458
|
+
}
|
|
88459
|
+
async function flushablePipe(source, sink, state) {
|
|
88460
|
+
const reader = source.getReader();
|
|
88461
|
+
const writer = sink.getWriter();
|
|
88462
|
+
let cancelReason;
|
|
88463
|
+
try {
|
|
88464
|
+
while (true) {
|
|
88465
|
+
if (state.streamEnded) {
|
|
88466
|
+
return;
|
|
88467
|
+
}
|
|
88468
|
+
const readResult = await Promise.race([
|
|
88469
|
+
reader.read(),
|
|
88470
|
+
writer.closed.then(() => {
|
|
88471
|
+
throw new WorkflowRuntimeError("Writable stream closed prematurely");
|
|
88472
|
+
})
|
|
88473
|
+
]);
|
|
88474
|
+
if (state.streamEnded) {
|
|
88475
|
+
return;
|
|
88476
|
+
}
|
|
88477
|
+
if (readResult.done) {
|
|
88478
|
+
state.streamEnded = true;
|
|
88479
|
+
await writer.close();
|
|
88480
|
+
if (!state.doneResolved) {
|
|
88481
|
+
state.doneResolved = true;
|
|
88482
|
+
state.resolve();
|
|
88483
|
+
}
|
|
88484
|
+
return;
|
|
88485
|
+
}
|
|
88486
|
+
state.pendingOps++;
|
|
88487
|
+
try {
|
|
88488
|
+
await writer.write(readResult.value);
|
|
88489
|
+
} finally {
|
|
88490
|
+
state.pendingOps--;
|
|
88491
|
+
}
|
|
88492
|
+
}
|
|
88493
|
+
} catch (err) {
|
|
88494
|
+
state.streamEnded = true;
|
|
88495
|
+
cancelReason = err;
|
|
88496
|
+
if (!state.doneResolved) {
|
|
88497
|
+
state.doneResolved = true;
|
|
88498
|
+
state.reject(err);
|
|
88499
|
+
}
|
|
88500
|
+
throw err;
|
|
88501
|
+
} finally {
|
|
88502
|
+
reader.cancel(cancelReason).catch(() => {
|
|
88503
|
+
});
|
|
88504
|
+
reader.releaseLock();
|
|
88505
|
+
writer.releaseLock();
|
|
88506
|
+
}
|
|
88507
|
+
}
|
|
88508
|
+
const RegisteredStepsKey = Symbol.for("@workflow/core//registeredSteps");
|
|
88509
|
+
const globalSymbols$1 = globalThis;
|
|
88510
|
+
const registeredSteps = globalSymbols$1[RegisteredStepsKey] ?? (globalSymbols$1[RegisteredStepsKey] = /* @__PURE__ */ new Map());
|
|
88511
|
+
const BUILTIN_RESPONSE_STEP_NAMES = /* @__PURE__ */ new Set([
|
|
88512
|
+
"__builtin_response_array_buffer",
|
|
88513
|
+
"__builtin_response_json",
|
|
88514
|
+
"__builtin_response_text"
|
|
88515
|
+
]);
|
|
88516
|
+
function getStepIdAliasCandidates(stepId) {
|
|
88517
|
+
const parts = stepId.split("//");
|
|
88518
|
+
if (parts.length !== 3 || parts[0] !== "step") {
|
|
88519
|
+
return [];
|
|
88520
|
+
}
|
|
88521
|
+
const modulePath = parts[1];
|
|
88522
|
+
const fnName = parts[2];
|
|
88523
|
+
const modulePathAliases = /* @__PURE__ */ new Set();
|
|
88524
|
+
const addAlias = (aliasModulePath) => {
|
|
88525
|
+
if (aliasModulePath !== modulePath) {
|
|
88526
|
+
modulePathAliases.add(aliasModulePath);
|
|
88527
|
+
}
|
|
88528
|
+
};
|
|
88529
|
+
if (modulePath.startsWith("./workflows/")) {
|
|
88530
|
+
const workflowRelativePath = modulePath.slice("./".length);
|
|
88531
|
+
addAlias(`./example/${workflowRelativePath}`);
|
|
88532
|
+
addAlias(`./src/${workflowRelativePath}`);
|
|
88533
|
+
} else if (modulePath.startsWith("./example/workflows/")) {
|
|
88534
|
+
const workflowRelativePath = modulePath.slice("./example/".length);
|
|
88535
|
+
addAlias(`./${workflowRelativePath}`);
|
|
88536
|
+
addAlias(`./src/${workflowRelativePath}`);
|
|
88537
|
+
} else if (modulePath.startsWith("./src/workflows/")) {
|
|
88538
|
+
const workflowRelativePath = modulePath.slice("./src/".length);
|
|
88539
|
+
addAlias(`./${workflowRelativePath}`);
|
|
88540
|
+
addAlias(`./example/${workflowRelativePath}`);
|
|
88541
|
+
}
|
|
88542
|
+
return Array.from(modulePathAliases, (aliasModulePath) => `step//${aliasModulePath}//${fnName}`);
|
|
88543
|
+
}
|
|
88544
|
+
function getBuiltinResponseStepAlias(stepId) {
|
|
88545
|
+
if (!BUILTIN_RESPONSE_STEP_NAMES.has(stepId)) {
|
|
88546
|
+
return void 0;
|
|
88547
|
+
}
|
|
88548
|
+
for (const [registeredStepId, stepFn] of registeredSteps.entries()) {
|
|
88549
|
+
if (registeredStepId.endsWith(`//${stepId}`)) {
|
|
88550
|
+
return stepFn;
|
|
88551
|
+
}
|
|
88552
|
+
}
|
|
88553
|
+
return void 0;
|
|
88554
|
+
}
|
|
88555
|
+
function getStepFunction(stepId) {
|
|
88556
|
+
const directMatch = registeredSteps.get(stepId);
|
|
88557
|
+
if (directMatch) {
|
|
88558
|
+
return directMatch;
|
|
88559
|
+
}
|
|
88560
|
+
for (const aliasStepId of getStepIdAliasCandidates(stepId)) {
|
|
88561
|
+
const aliasMatch = registeredSteps.get(aliasStepId);
|
|
88562
|
+
if (aliasMatch) {
|
|
88563
|
+
return aliasMatch;
|
|
88564
|
+
}
|
|
88565
|
+
}
|
|
88566
|
+
const builtinAliasMatch = getBuiltinResponseStepAlias(stepId);
|
|
88567
|
+
if (builtinAliasMatch) {
|
|
88568
|
+
return builtinAliasMatch;
|
|
88569
|
+
}
|
|
88570
|
+
return void 0;
|
|
88571
|
+
}
|
|
88572
|
+
const WORKFLOW_SERIALIZE = Symbol.for("workflow-serialize");
|
|
88573
|
+
const WORKFLOW_DESERIALIZE = Symbol.for("workflow-deserialize");
|
|
88574
|
+
const STABLE_ULID = Symbol.for("WORKFLOW_STABLE_ULID");
|
|
88575
|
+
const STREAM_NAME_SYMBOL = Symbol.for("WORKFLOW_STREAM_NAME");
|
|
88576
|
+
const STREAM_TYPE_SYMBOL = Symbol.for("WORKFLOW_STREAM_TYPE");
|
|
88577
|
+
const STREAM_SERVER_RUN_ID_SYMBOL = Symbol.for("WORKFLOW_STREAM_SERVER_RUN_ID");
|
|
88578
|
+
const BODY_INIT_SYMBOL = Symbol.for("BODY_INIT");
|
|
88579
|
+
const WEBHOOK_RESPONSE_WRITABLE = Symbol.for("WEBHOOK_RESPONSE_WRITABLE");
|
|
88580
|
+
const WORKFLOW_CLASS_REGISTRY = Symbol.for("workflow-class-registry");
|
|
88581
|
+
const ABORT_STREAM_NAME = Symbol.for("WORKFLOW_ABORT_STREAM_NAME");
|
|
88582
|
+
const ABORT_HOOK_TOKEN = Symbol.for("WORKFLOW_ABORT_HOOK_TOKEN");
|
|
88583
|
+
const ABORT_LISTENER_ATTACHED = Symbol.for("WORKFLOW_ABORT_LISTENER_ATTACHED");
|
|
88584
|
+
const ABORT_READER_CANCEL = Symbol.for("WORKFLOW_ABORT_READER_CANCEL");
|
|
88585
|
+
function getRegistry(global2 = globalThis) {
|
|
88586
|
+
const g2 = global2;
|
|
88587
|
+
let registry2 = g2[WORKFLOW_CLASS_REGISTRY];
|
|
88588
|
+
if (!registry2) {
|
|
88589
|
+
registry2 = /* @__PURE__ */ new Map();
|
|
88590
|
+
g2[WORKFLOW_CLASS_REGISTRY] = registry2;
|
|
88591
|
+
}
|
|
88592
|
+
return registry2;
|
|
88593
|
+
}
|
|
88594
|
+
function getSerializationClass(classId, global2) {
|
|
88595
|
+
return getRegistry(global2).get(classId);
|
|
88596
|
+
}
|
|
88597
|
+
function getClassReducers() {
|
|
88598
|
+
return {
|
|
88599
|
+
// Class and Instance are intentionally placed before Error so that
|
|
88600
|
+
// custom Error subclasses with WORKFLOW_SERIALIZE take precedence
|
|
88601
|
+
// over the generic Error serialization (devalue uses first-match-wins).
|
|
88602
|
+
Class: (value) => {
|
|
88603
|
+
if (typeof value !== "function")
|
|
88604
|
+
return false;
|
|
88605
|
+
const classId = value.classId;
|
|
88606
|
+
if (typeof classId !== "string")
|
|
88607
|
+
return false;
|
|
88608
|
+
return { classId };
|
|
88609
|
+
},
|
|
88610
|
+
Instance: (value) => {
|
|
88611
|
+
if (value === null || typeof value !== "object")
|
|
88612
|
+
return false;
|
|
88613
|
+
const cls = value.constructor;
|
|
88614
|
+
if (!cls || typeof cls !== "function")
|
|
88615
|
+
return false;
|
|
88616
|
+
const serialize2 = cls[WORKFLOW_SERIALIZE];
|
|
88617
|
+
if (typeof serialize2 !== "function")
|
|
88618
|
+
return false;
|
|
88619
|
+
const classId = cls.classId;
|
|
88620
|
+
if (typeof classId !== "string") {
|
|
88621
|
+
throw new Error(`Class "${cls.name}" with ${String(WORKFLOW_SERIALIZE)} must have a static "classId" property.`);
|
|
88622
|
+
}
|
|
88623
|
+
const data = serialize2.call(cls, value);
|
|
88624
|
+
return { classId, data };
|
|
88625
|
+
}
|
|
88626
|
+
};
|
|
88627
|
+
}
|
|
88628
|
+
function getClassRevivers(global2 = globalThis) {
|
|
88629
|
+
return {
|
|
88630
|
+
Class: (value) => {
|
|
88631
|
+
const classId = value.classId;
|
|
88632
|
+
const cls = getSerializationClass(classId, global2);
|
|
88633
|
+
if (!cls) {
|
|
88634
|
+
throw new Error(`Class "${classId}" not found. Make sure the class is registered with registerSerializationClass.`);
|
|
88635
|
+
}
|
|
88636
|
+
return cls;
|
|
88637
|
+
},
|
|
88638
|
+
Instance: (value) => {
|
|
88639
|
+
const classId = value.classId;
|
|
88640
|
+
const data = value.data;
|
|
88641
|
+
const cls = getSerializationClass(classId, global2);
|
|
88642
|
+
if (!cls) {
|
|
88643
|
+
throw new Error(`Class "${classId}" not found. Make sure the class is registered with registerSerializationClass.`);
|
|
88644
|
+
}
|
|
88645
|
+
const deserialize2 = cls[WORKFLOW_DESERIALIZE];
|
|
88646
|
+
if (typeof deserialize2 !== "function") {
|
|
88647
|
+
throw new Error(`Class "${classId}" does not have a static ${String(WORKFLOW_DESERIALIZE)} method.`);
|
|
88648
|
+
}
|
|
88649
|
+
return deserialize2.call(cls, data);
|
|
88650
|
+
}
|
|
88651
|
+
};
|
|
88652
|
+
}
|
|
88653
|
+
function arrayBufferToBase64(value, offset2, length) {
|
|
88654
|
+
if (length === 0)
|
|
88655
|
+
return ".";
|
|
88656
|
+
const uint8 = new Uint8Array(value, offset2, length);
|
|
88657
|
+
return Buffer.from(uint8).toString("base64");
|
|
88658
|
+
}
|
|
88659
|
+
function viewToBase64(value) {
|
|
88660
|
+
return arrayBufferToBase64(value.buffer, value.byteOffset, value.byteLength);
|
|
88661
|
+
}
|
|
88662
|
+
function reviveArrayBuffer(value, global2) {
|
|
88663
|
+
const base642 = value === "." ? "" : value;
|
|
88664
|
+
const buffer = Buffer.from(base642, "base64");
|
|
88665
|
+
const arrayBuffer = new global2.ArrayBuffer(buffer.length);
|
|
88666
|
+
const uint8Array = new global2.Uint8Array(arrayBuffer);
|
|
88667
|
+
uint8Array.set(buffer);
|
|
88668
|
+
return arrayBuffer;
|
|
88669
|
+
}
|
|
88670
|
+
function revive(str) {
|
|
88671
|
+
return JSON.parse(str);
|
|
88672
|
+
}
|
|
88673
|
+
function reduceErrorBase(value) {
|
|
88674
|
+
if (!types$3.isNativeError(value))
|
|
88675
|
+
return false;
|
|
88676
|
+
const reduced = {
|
|
88677
|
+
message: value.message,
|
|
88678
|
+
stack: value.stack
|
|
88679
|
+
};
|
|
88680
|
+
if ("cause" in value)
|
|
88681
|
+
reduced.cause = value.cause;
|
|
88682
|
+
return reduced;
|
|
88683
|
+
}
|
|
88684
|
+
function reduceNamedErrorSubclassBase(subclassName, value) {
|
|
88685
|
+
if (!types$3.isNativeError(value))
|
|
88686
|
+
return false;
|
|
88687
|
+
if (value.name !== subclassName)
|
|
88688
|
+
return false;
|
|
88689
|
+
return reduceErrorBase(value);
|
|
88690
|
+
}
|
|
88691
|
+
function makeErrorSubclassReducer(subclassName) {
|
|
88692
|
+
return (value) => {
|
|
88693
|
+
const base = reduceNamedErrorSubclassBase(subclassName, value);
|
|
88694
|
+
if (!base)
|
|
88695
|
+
return false;
|
|
88696
|
+
return base;
|
|
88697
|
+
};
|
|
88698
|
+
}
|
|
88699
|
+
function makeErrorSubclassReviver(global2, ctorName) {
|
|
88700
|
+
return (value) => {
|
|
88701
|
+
const v2 = value;
|
|
88702
|
+
const opts = "cause" in v2 ? { cause: v2.cause } : void 0;
|
|
88703
|
+
const Ctor = global2[ctorName];
|
|
88704
|
+
const error2 = new Ctor(v2.message, opts);
|
|
88705
|
+
if (v2.stack !== void 0)
|
|
88706
|
+
error2.stack = v2.stack;
|
|
88707
|
+
return error2;
|
|
88708
|
+
};
|
|
88709
|
+
}
|
|
88710
|
+
function getCommonReducers(global2 = globalThis) {
|
|
88711
|
+
return {
|
|
88712
|
+
ArrayBuffer: (value) => value instanceof global2.ArrayBuffer && arrayBufferToBase64(value, 0, value.byteLength),
|
|
88713
|
+
BigInt: (value) => typeof value === "bigint" && value.toString(),
|
|
88714
|
+
BigInt64Array: (value) => value instanceof global2.BigInt64Array && viewToBase64(value),
|
|
88715
|
+
BigUint64Array: (value) => value instanceof global2.BigUint64Array && viewToBase64(value),
|
|
88716
|
+
Date: (value) => {
|
|
88717
|
+
if (!(value instanceof global2.Date))
|
|
88718
|
+
return false;
|
|
88719
|
+
const valid2 = !Number.isNaN(value.getDate());
|
|
88720
|
+
return valid2 ? value.toISOString() : ".";
|
|
88721
|
+
},
|
|
88722
|
+
// DOMException is a special case: it `instanceof Error` is true in Node,
|
|
88723
|
+
// but `types.isNativeError()` returns FALSE for it, so the generic Error
|
|
88724
|
+
// reducer (which gates on isNativeError) won't match. Check it explicitly
|
|
88725
|
+
// by constructor name + Error inheritance so we catch DOMExceptions from
|
|
88726
|
+
// any realm (cross-VM safety: instanceof global.DOMException would fail
|
|
88727
|
+
// for instances minted in another context).
|
|
88728
|
+
DOMException: (value) => {
|
|
88729
|
+
var _a3;
|
|
88730
|
+
if (value === null || typeof value !== "object")
|
|
88731
|
+
return false;
|
|
88732
|
+
if (((_a3 = value.constructor) == null ? void 0 : _a3.name) !== "DOMException")
|
|
88733
|
+
return false;
|
|
88734
|
+
const e = value;
|
|
88735
|
+
const reduced = {
|
|
88736
|
+
message: e.message,
|
|
88737
|
+
name: e.name,
|
|
88738
|
+
stack: e.stack
|
|
88739
|
+
};
|
|
88740
|
+
if ("cause" in e)
|
|
88741
|
+
reduced.cause = e.cause;
|
|
88742
|
+
return reduced;
|
|
88743
|
+
},
|
|
88744
|
+
// Error subclass reducers are intentionally placed before the base Error
|
|
88745
|
+
// reducer because devalue uses first-match-wins. Subclass-specific reducers
|
|
88746
|
+
// must be checked first so that e.g. a TypeError is serialized as "TypeError"
|
|
88747
|
+
// rather than falling through to the generic "Error" reducer.
|
|
88748
|
+
// See `makeErrorSubclassReducer` for implementation details.
|
|
88749
|
+
EvalError: makeErrorSubclassReducer("EvalError"),
|
|
88750
|
+
FatalError: makeErrorSubclassReducer("FatalError"),
|
|
88751
|
+
HookConflictError: (value) => {
|
|
88752
|
+
const base = reduceNamedErrorSubclassBase("HookConflictError", value);
|
|
88753
|
+
if (!base)
|
|
88754
|
+
return false;
|
|
88755
|
+
const error2 = value;
|
|
88756
|
+
const reduced = {
|
|
88757
|
+
...base,
|
|
88758
|
+
token: error2.token
|
|
88759
|
+
};
|
|
88760
|
+
if (error2.conflictingRunId !== void 0) {
|
|
88761
|
+
reduced.conflictingRunId = error2.conflictingRunId;
|
|
88762
|
+
}
|
|
88763
|
+
return reduced;
|
|
88764
|
+
},
|
|
88765
|
+
RangeError: makeErrorSubclassReducer("RangeError"),
|
|
88766
|
+
ReferenceError: makeErrorSubclassReducer("ReferenceError"),
|
|
88767
|
+
// RetryableError carries an extra `retryAfter` Date that we serialize as
|
|
88768
|
+
// a numeric epoch timestamp. The Date reducer uses `instanceof global.Date`,
|
|
88769
|
+
// which fails for Dates from a different VM realm; serializing as a
|
|
88770
|
+
// number sidesteps that issue.
|
|
88771
|
+
RetryableError: (value) => {
|
|
88772
|
+
const base = reduceNamedErrorSubclassBase("RetryableError", value);
|
|
88773
|
+
if (!base)
|
|
88774
|
+
return false;
|
|
88775
|
+
const retryAfterRaw = value.retryAfter;
|
|
88776
|
+
let retryAfter;
|
|
88777
|
+
if (retryAfterRaw && typeof retryAfterRaw === "object" && typeof retryAfterRaw.getTime === "function") {
|
|
88778
|
+
const t = retryAfterRaw.getTime();
|
|
88779
|
+
retryAfter = Number.isNaN(t) ? Date.now() + 1e3 : t;
|
|
88780
|
+
} else if (typeof retryAfterRaw === "string" || typeof retryAfterRaw === "number") {
|
|
88781
|
+
const t = new Date(retryAfterRaw).getTime();
|
|
88782
|
+
retryAfter = Number.isNaN(t) ? Date.now() + 1e3 : t;
|
|
88783
|
+
} else {
|
|
88784
|
+
retryAfter = Date.now() + 1e3;
|
|
88785
|
+
}
|
|
88786
|
+
return {
|
|
88787
|
+
...base,
|
|
88788
|
+
retryAfter
|
|
88789
|
+
};
|
|
88790
|
+
},
|
|
88791
|
+
SyntaxError: makeErrorSubclassReducer("SyntaxError"),
|
|
88792
|
+
TypeError: makeErrorSubclassReducer("TypeError"),
|
|
88793
|
+
URIError: makeErrorSubclassReducer("URIError"),
|
|
88794
|
+
// AggregateError is similar to other subclasses but also preserves the
|
|
88795
|
+
// `errors` array. We extend the base helper's output here.
|
|
88796
|
+
AggregateError: (value) => {
|
|
88797
|
+
const base = reduceNamedErrorSubclassBase("AggregateError", value);
|
|
88798
|
+
if (!base)
|
|
88799
|
+
return false;
|
|
88800
|
+
return {
|
|
88801
|
+
...base,
|
|
88802
|
+
errors: value.errors
|
|
88803
|
+
};
|
|
88804
|
+
},
|
|
88805
|
+
// Base Error reducer — catch-all for any Error instance not matched by a
|
|
88806
|
+
// specific subclass reducer above (including user Error subclasses without
|
|
88807
|
+
// WORKFLOW_SERIALIZE). Preserves `name` so the error's identity is retained
|
|
88808
|
+
// even though the exact class cannot be reconstructed.
|
|
88809
|
+
Error: (value) => {
|
|
88810
|
+
if (!types$3.isNativeError(value))
|
|
88811
|
+
return false;
|
|
88812
|
+
const reduced = {
|
|
88813
|
+
name: value.name,
|
|
88814
|
+
message: value.message,
|
|
88815
|
+
stack: value.stack
|
|
88816
|
+
};
|
|
88817
|
+
if ("cause" in value)
|
|
88818
|
+
reduced.cause = value.cause;
|
|
88819
|
+
return reduced;
|
|
88820
|
+
},
|
|
88821
|
+
Float32Array: (value) => value instanceof global2.Float32Array && viewToBase64(value),
|
|
88822
|
+
Float64Array: (value) => value instanceof global2.Float64Array && viewToBase64(value),
|
|
88823
|
+
Headers: (value) => value instanceof global2.Headers && Array.from(value),
|
|
88824
|
+
Int8Array: (value) => value instanceof global2.Int8Array && viewToBase64(value),
|
|
88825
|
+
Int16Array: (value) => value instanceof global2.Int16Array && viewToBase64(value),
|
|
88826
|
+
Int32Array: (value) => value instanceof global2.Int32Array && viewToBase64(value),
|
|
88827
|
+
Map: (value) => value instanceof global2.Map && Array.from(value),
|
|
88828
|
+
RegExp: (value) => value instanceof global2.RegExp && {
|
|
88829
|
+
source: value.source,
|
|
88830
|
+
flags: value.flags
|
|
88831
|
+
},
|
|
88832
|
+
// Request and Response are intentionally NOT in common reducers.
|
|
88833
|
+
// They require mode-specific revivers (stream handling, etc.) and
|
|
88834
|
+
// including them here without matching revivers would cause them
|
|
88835
|
+
// to deserialize as plain objects.
|
|
88836
|
+
Set: (value) => value instanceof global2.Set && Array.from(value),
|
|
88837
|
+
URL: (value) => value instanceof global2.URL && value.href,
|
|
88838
|
+
WorkflowFunction: (value) => {
|
|
88839
|
+
if (typeof value !== "function")
|
|
88840
|
+
return false;
|
|
88841
|
+
const workflowId = value.workflowId;
|
|
88842
|
+
if (typeof workflowId !== "string")
|
|
88843
|
+
return false;
|
|
88844
|
+
return { workflowId };
|
|
88845
|
+
},
|
|
88846
|
+
URLSearchParams: (value) => {
|
|
88847
|
+
if (!(value instanceof global2.URLSearchParams))
|
|
88848
|
+
return false;
|
|
88849
|
+
if (value.size === 0)
|
|
88850
|
+
return ".";
|
|
88851
|
+
return String(value);
|
|
88852
|
+
},
|
|
88853
|
+
Uint8Array: (value) => value instanceof global2.Uint8Array && viewToBase64(value),
|
|
88854
|
+
Uint8ClampedArray: (value) => value instanceof global2.Uint8ClampedArray && viewToBase64(value),
|
|
88855
|
+
Uint16Array: (value) => value instanceof global2.Uint16Array && viewToBase64(value),
|
|
88856
|
+
Uint32Array: (value) => value instanceof global2.Uint32Array && viewToBase64(value)
|
|
88857
|
+
};
|
|
88858
|
+
}
|
|
88859
|
+
function getCommonRevivers$1(global2 = globalThis) {
|
|
88860
|
+
return {
|
|
88861
|
+
ArrayBuffer: (value) => reviveArrayBuffer(value, global2),
|
|
88862
|
+
BigInt: (value) => global2.BigInt(value),
|
|
88863
|
+
BigInt64Array: (value) => new global2.BigInt64Array(reviveArrayBuffer(value, global2)),
|
|
88864
|
+
BigUint64Array: (value) => new global2.BigUint64Array(reviveArrayBuffer(value, global2)),
|
|
88865
|
+
Date: (value) => new global2.Date(value),
|
|
88866
|
+
DOMException: (value) => {
|
|
88867
|
+
const error2 = new global2.DOMException(value.message, value.name);
|
|
88868
|
+
if (value.stack !== void 0)
|
|
88869
|
+
error2.stack = value.stack;
|
|
88870
|
+
if ("cause" in value)
|
|
88871
|
+
error2.cause = value.cause;
|
|
88872
|
+
return error2;
|
|
88873
|
+
},
|
|
88874
|
+
// Error subclass revivers reconstruct the correct built-in Error type.
|
|
88875
|
+
// See `makeErrorSubclassReviver` for implementation details.
|
|
88876
|
+
EvalError: makeErrorSubclassReviver(global2, "EvalError"),
|
|
88877
|
+
// `FatalError` and `RetryableError` are not built-ins, so we resolve them
|
|
88878
|
+
// from the consumer's `globalThis` via a `Symbol.for(...)` key registered
|
|
88879
|
+
// by `@workflow/errors` on load. This makes `instanceof FatalError` work
|
|
88880
|
+
// in user code that lives in a different realm than this reducer module
|
|
88881
|
+
// (e.g. when the host hydrates a value destined for a workflow VM
|
|
88882
|
+
// context). See the registration block at the bottom of
|
|
88883
|
+
// `packages/errors/src/index.ts` for details. Falls back to the imported
|
|
88884
|
+
// class for environments where no bundled `@workflow/errors` has loaded
|
|
88885
|
+
// in the consumer realm.
|
|
88886
|
+
FatalError: (value) => {
|
|
88887
|
+
const Ctor = global2[Symbol.for("@workflow/errors//FatalError")] ?? FatalError;
|
|
88888
|
+
const error2 = new Ctor(value.message);
|
|
88889
|
+
if (value.stack !== void 0)
|
|
88890
|
+
error2.stack = value.stack;
|
|
88891
|
+
if ("cause" in value)
|
|
88892
|
+
error2.cause = value.cause;
|
|
88893
|
+
return error2;
|
|
88894
|
+
},
|
|
88895
|
+
HookConflictError: (value) => {
|
|
88896
|
+
const Ctor = global2[Symbol.for("@workflow/errors//HookConflictError")] ?? HookConflictError;
|
|
88897
|
+
const error2 = new Ctor(value.token, value.conflictingRunId);
|
|
88898
|
+
if (value.stack !== void 0)
|
|
88899
|
+
error2.stack = value.stack;
|
|
88900
|
+
if ("cause" in value) {
|
|
88901
|
+
error2.cause = value.cause;
|
|
88902
|
+
}
|
|
88903
|
+
return error2;
|
|
88904
|
+
},
|
|
88905
|
+
RangeError: makeErrorSubclassReviver(global2, "RangeError"),
|
|
88906
|
+
ReferenceError: makeErrorSubclassReviver(global2, "ReferenceError"),
|
|
88907
|
+
RetryableError: (value) => {
|
|
88908
|
+
const Ctor = global2[Symbol.for("@workflow/errors//RetryableError")] ?? RetryableError;
|
|
88909
|
+
const error2 = new Ctor(value.message, {
|
|
88910
|
+
retryAfter: new global2.Date(value.retryAfter)
|
|
88911
|
+
});
|
|
88912
|
+
if (value.stack !== void 0)
|
|
88913
|
+
error2.stack = value.stack;
|
|
88914
|
+
if ("cause" in value)
|
|
88915
|
+
error2.cause = value.cause;
|
|
88916
|
+
return error2;
|
|
88917
|
+
},
|
|
88918
|
+
SyntaxError: makeErrorSubclassReviver(global2, "SyntaxError"),
|
|
88919
|
+
TypeError: makeErrorSubclassReviver(global2, "TypeError"),
|
|
88920
|
+
URIError: makeErrorSubclassReviver(global2, "URIError"),
|
|
88921
|
+
AggregateError: (value) => {
|
|
88922
|
+
const opts = "cause" in value ? { cause: value.cause } : void 0;
|
|
88923
|
+
const error2 = new global2.AggregateError(value.errors, value.message, opts);
|
|
88924
|
+
if (value.stack !== void 0)
|
|
88925
|
+
error2.stack = value.stack;
|
|
88926
|
+
return error2;
|
|
88927
|
+
},
|
|
88928
|
+
// Base Error reviver — used for plain Error instances and unrecognized
|
|
88929
|
+
// Error subclasses. Preserves `name` so the error's identity is retained.
|
|
88930
|
+
Error: (value) => {
|
|
88931
|
+
const opts = "cause" in value ? { cause: value.cause } : void 0;
|
|
88932
|
+
const error2 = new global2.Error(value.message, opts);
|
|
88933
|
+
error2.name = value.name;
|
|
88934
|
+
if (value.stack !== void 0)
|
|
88935
|
+
error2.stack = value.stack;
|
|
88936
|
+
return error2;
|
|
88937
|
+
},
|
|
88938
|
+
Float32Array: (value) => new global2.Float32Array(reviveArrayBuffer(value, global2)),
|
|
88939
|
+
Float64Array: (value) => new global2.Float64Array(reviveArrayBuffer(value, global2)),
|
|
88940
|
+
Headers: (value) => new global2.Headers(value),
|
|
88941
|
+
Int8Array: (value) => new global2.Int8Array(reviveArrayBuffer(value, global2)),
|
|
88942
|
+
Int16Array: (value) => new global2.Int16Array(reviveArrayBuffer(value, global2)),
|
|
88943
|
+
Int32Array: (value) => new global2.Int32Array(reviveArrayBuffer(value, global2)),
|
|
88944
|
+
Map: (value) => new global2.Map(value),
|
|
88945
|
+
RegExp: (value) => new global2.RegExp(value.source, value.flags),
|
|
88946
|
+
Set: (value) => new global2.Set(value),
|
|
88947
|
+
URL: (value) => new global2.URL(value),
|
|
88948
|
+
WorkflowFunction: (value) => Object.assign(() => {
|
|
88949
|
+
throw new Error("Workflow functions cannot be called directly. Use start() to invoke them.");
|
|
88950
|
+
}, { workflowId: value.workflowId }),
|
|
88951
|
+
URLSearchParams: (value) => new global2.URLSearchParams(value === "." ? "" : value),
|
|
88952
|
+
Uint8Array: (value) => new global2.Uint8Array(reviveArrayBuffer(value, global2)),
|
|
88953
|
+
Uint8ClampedArray: (value) => new global2.Uint8ClampedArray(reviveArrayBuffer(value, global2)),
|
|
88954
|
+
Uint16Array: (value) => new global2.Uint16Array(reviveArrayBuffer(value, global2)),
|
|
88955
|
+
Uint32Array: (value) => new global2.Uint32Array(reviveArrayBuffer(value, global2))
|
|
88956
|
+
};
|
|
88957
|
+
}
|
|
88958
|
+
function getStepFunctionReducer() {
|
|
88959
|
+
return {
|
|
88960
|
+
StepFunction: (value) => {
|
|
88961
|
+
if (typeof value !== "function")
|
|
88962
|
+
return false;
|
|
88963
|
+
const stepId = value.stepId;
|
|
88964
|
+
if (typeof stepId !== "string")
|
|
88965
|
+
return false;
|
|
88966
|
+
const closureVarsFn = value.__closureVarsFn;
|
|
88967
|
+
const closureVars = closureVarsFn && typeof closureVarsFn === "function" ? closureVarsFn() : void 0;
|
|
88968
|
+
const hasBoundThis = "__boundThis" in value;
|
|
88969
|
+
const boundThis = hasBoundThis ? value.__boundThis : void 0;
|
|
88970
|
+
const boundArgs = value.__boundArgs;
|
|
88971
|
+
const payload = { stepId };
|
|
88972
|
+
if (closureVars !== void 0)
|
|
88973
|
+
payload.closureVars = closureVars;
|
|
88974
|
+
if (hasBoundThis)
|
|
88975
|
+
payload.boundThis = boundThis;
|
|
88976
|
+
if (Array.isArray(boundArgs) && boundArgs.length > 0) {
|
|
88977
|
+
payload.boundArgs = boundArgs;
|
|
88978
|
+
}
|
|
88979
|
+
return payload;
|
|
88980
|
+
}
|
|
88981
|
+
};
|
|
88982
|
+
}
|
|
88983
|
+
function getStepFunctionReviver(global2 = globalThis) {
|
|
88984
|
+
const useStep = global2[Symbol.for("WORKFLOW_USE_STEP")];
|
|
88985
|
+
return {
|
|
88986
|
+
StepFunction: (value) => {
|
|
88987
|
+
const stepId = value.stepId;
|
|
88988
|
+
const closureVars = value.closureVars;
|
|
88989
|
+
if (!useStep) {
|
|
88990
|
+
throw new Error("WORKFLOW_USE_STEP not found on global object. Step functions cannot be deserialized outside workflow context.");
|
|
88991
|
+
}
|
|
88992
|
+
const proxy = closureVars ? useStep(stepId, () => closureVars) : useStep(stepId);
|
|
88993
|
+
if ("boundThis" in value) {
|
|
88994
|
+
const boundArgs = Array.isArray(value.boundArgs) ? value.boundArgs : [];
|
|
88995
|
+
return proxy.bind(value.boundThis, ...boundArgs);
|
|
88996
|
+
}
|
|
88997
|
+
return proxy;
|
|
88998
|
+
}
|
|
88999
|
+
};
|
|
89000
|
+
}
|
|
89001
|
+
function isFormatPrefix(value) {
|
|
89002
|
+
return value.length === 4 && /^[a-z0-9]{4}$/.test(value);
|
|
89003
|
+
}
|
|
89004
|
+
const SerializationFormat = {
|
|
89005
|
+
/** devalue stringify/parse with TextEncoder/TextDecoder */
|
|
89006
|
+
DEVALUE_V1: "devl",
|
|
89007
|
+
/** Encrypted payload (inner payload has its own format prefix) */
|
|
89008
|
+
ENCRYPTED: "encr"
|
|
89009
|
+
};
|
|
89010
|
+
const encoder = new TextEncoder();
|
|
89011
|
+
const decoder = new TextDecoder();
|
|
89012
|
+
function getReducersForMode(mode, global2 = globalThis, extraReducers) {
|
|
89013
|
+
let base;
|
|
89014
|
+
switch (mode) {
|
|
89015
|
+
case "workflow":
|
|
89016
|
+
base = {
|
|
89017
|
+
...getClassReducers(),
|
|
89018
|
+
...getStepFunctionReducer(),
|
|
89019
|
+
...getCommonReducers(global2)
|
|
89020
|
+
};
|
|
89021
|
+
break;
|
|
89022
|
+
case "step":
|
|
89023
|
+
base = {
|
|
89024
|
+
...getClassReducers(),
|
|
89025
|
+
...getCommonReducers(global2)
|
|
89026
|
+
};
|
|
89027
|
+
break;
|
|
89028
|
+
case "client":
|
|
89029
|
+
base = {
|
|
89030
|
+
...getClassReducers(),
|
|
89031
|
+
...getCommonReducers(global2)
|
|
89032
|
+
};
|
|
89033
|
+
break;
|
|
89034
|
+
}
|
|
89035
|
+
if (extraReducers) {
|
|
89036
|
+
return { ...base, ...extraReducers };
|
|
89037
|
+
}
|
|
89038
|
+
return base;
|
|
89039
|
+
}
|
|
89040
|
+
function getReviversForMode(mode, global2 = globalThis, extraRevivers) {
|
|
89041
|
+
let base;
|
|
89042
|
+
switch (mode) {
|
|
89043
|
+
case "workflow":
|
|
89044
|
+
base = {
|
|
89045
|
+
...getClassRevivers(global2),
|
|
89046
|
+
...getStepFunctionReviver(global2),
|
|
89047
|
+
...getCommonRevivers$1(global2)
|
|
89048
|
+
};
|
|
89049
|
+
break;
|
|
89050
|
+
case "step":
|
|
89051
|
+
base = {
|
|
89052
|
+
...getClassRevivers(global2),
|
|
89053
|
+
...getCommonRevivers$1(global2)
|
|
89054
|
+
};
|
|
89055
|
+
break;
|
|
89056
|
+
case "client":
|
|
89057
|
+
base = {
|
|
89058
|
+
...getClassRevivers(global2),
|
|
89059
|
+
...getCommonRevivers$1(global2),
|
|
89060
|
+
StepFunction: () => {
|
|
89061
|
+
throw new Error("Step functions cannot be deserialized in client context.");
|
|
89062
|
+
}
|
|
89063
|
+
};
|
|
89064
|
+
break;
|
|
89065
|
+
}
|
|
89066
|
+
if (extraRevivers) {
|
|
89067
|
+
return { ...base, ...extraRevivers };
|
|
89068
|
+
}
|
|
89069
|
+
return base;
|
|
89070
|
+
}
|
|
89071
|
+
const devalueCodec = {
|
|
89072
|
+
formatPrefix: SerializationFormat.DEVALUE_V1,
|
|
89073
|
+
serialize(value, mode, options) {
|
|
89074
|
+
const reducers = getReducersForMode(mode, options == null ? void 0 : options.global, options == null ? void 0 : options.extraReducers);
|
|
89075
|
+
const str = stringify$2(value, reducers);
|
|
89076
|
+
return encoder.encode(str);
|
|
89077
|
+
},
|
|
89078
|
+
deserialize(data, mode, options) {
|
|
89079
|
+
const revivers = getReviversForMode(mode, options == null ? void 0 : options.global, options == null ? void 0 : options.extraRevivers);
|
|
89080
|
+
const str = decoder.decode(data);
|
|
89081
|
+
return parse$7(str, revivers);
|
|
89082
|
+
},
|
|
89083
|
+
deserializeLegacy(data, mode, options) {
|
|
89084
|
+
const revivers = getReviversForMode(mode, options == null ? void 0 : options.global, options == null ? void 0 : options.extraRevivers);
|
|
89085
|
+
return unflatten(data, revivers);
|
|
89086
|
+
}
|
|
89087
|
+
};
|
|
89088
|
+
const FORMAT_PREFIX_LENGTH = 4;
|
|
89089
|
+
const formatEncoder = new TextEncoder();
|
|
89090
|
+
const formatDecoder = new TextDecoder();
|
|
89091
|
+
function encodeWithFormatPrefix(format2, payload) {
|
|
89092
|
+
if (!(payload instanceof Uint8Array)) {
|
|
89093
|
+
return payload;
|
|
89094
|
+
}
|
|
89095
|
+
const prefixBytes = formatEncoder.encode(format2);
|
|
89096
|
+
const result = new Uint8Array(FORMAT_PREFIX_LENGTH + payload.length);
|
|
89097
|
+
result.set(prefixBytes, 0);
|
|
89098
|
+
result.set(payload, FORMAT_PREFIX_LENGTH);
|
|
89099
|
+
return result;
|
|
89100
|
+
}
|
|
89101
|
+
function peekFormatPrefix(data) {
|
|
89102
|
+
if (!(data instanceof Uint8Array) || data.length < FORMAT_PREFIX_LENGTH) {
|
|
89103
|
+
return null;
|
|
89104
|
+
}
|
|
89105
|
+
const prefixBytes = data.subarray(0, FORMAT_PREFIX_LENGTH);
|
|
89106
|
+
const str = formatDecoder.decode(prefixBytes);
|
|
89107
|
+
return isFormatPrefix(str) ? str : null;
|
|
89108
|
+
}
|
|
89109
|
+
function decodeFormatPrefix(data) {
|
|
89110
|
+
if (!(data instanceof Uint8Array)) {
|
|
89111
|
+
return {
|
|
89112
|
+
format: SerializationFormat.DEVALUE_V1,
|
|
89113
|
+
payload: new TextEncoder().encode(JSON.stringify(data))
|
|
89114
|
+
};
|
|
89115
|
+
}
|
|
89116
|
+
if (data.length < FORMAT_PREFIX_LENGTH) {
|
|
89117
|
+
throw new Error(`Data too short to contain format prefix: expected at least ${FORMAT_PREFIX_LENGTH} bytes, got ${data.length}`);
|
|
89118
|
+
}
|
|
89119
|
+
const prefixBytes = data.subarray(0, FORMAT_PREFIX_LENGTH);
|
|
89120
|
+
const str = formatDecoder.decode(prefixBytes);
|
|
89121
|
+
if (!isFormatPrefix(str)) {
|
|
89122
|
+
throw new Error(`Invalid format prefix: "${str}". Must be 4 characters of [a-z0-9].`);
|
|
89123
|
+
}
|
|
89124
|
+
const payload = data.subarray(FORMAT_PREFIX_LENGTH);
|
|
89125
|
+
return { format: str, payload };
|
|
89126
|
+
}
|
|
89127
|
+
async function encrypt(data, key) {
|
|
89128
|
+
if (!key || !(data instanceof Uint8Array))
|
|
89129
|
+
return data;
|
|
89130
|
+
const encrypted = await encrypt$1(key, data);
|
|
89131
|
+
return encodeWithFormatPrefix(SerializationFormat.ENCRYPTED, encrypted);
|
|
89132
|
+
}
|
|
89133
|
+
async function decrypt(data, key) {
|
|
89134
|
+
if (!(data instanceof Uint8Array))
|
|
89135
|
+
return data;
|
|
89136
|
+
const format2 = peekFormatPrefix(data);
|
|
89137
|
+
if (format2 === SerializationFormat.ENCRYPTED && !key) {
|
|
89138
|
+
throw new WorkflowRuntimeError("Encrypted data encountered but no encryption key is available. Encryption is not configured or no key was provided for this run.");
|
|
89139
|
+
}
|
|
89140
|
+
if (format2 !== SerializationFormat.ENCRYPTED)
|
|
89141
|
+
return data;
|
|
89142
|
+
const { payload } = decodeFormatPrefix(data);
|
|
89143
|
+
return decrypt$1(key, payload);
|
|
89144
|
+
}
|
|
89145
|
+
function formatSerializationError(context, error2) {
|
|
89146
|
+
const verb = context.includes("return value") ? "returning" : "passing";
|
|
89147
|
+
let message2 = `Failed to serialize ${context}`;
|
|
89148
|
+
if (error2 instanceof DevalueError && error2.path) {
|
|
89149
|
+
message2 += ` at path "${error2.path}"`;
|
|
89150
|
+
}
|
|
89151
|
+
const hint2 = `Ensure you're ${verb} workflow serializable types. Check the serialization docs to see what's serializable: https://workflow-sdk.dev/docs/foundations/serialization`;
|
|
89152
|
+
if (error2 instanceof DevalueError && error2.value !== void 0) {
|
|
89153
|
+
runtimeLogger.error("Serialization failed", {
|
|
89154
|
+
context,
|
|
89155
|
+
problematicValue: error2.value
|
|
89156
|
+
});
|
|
89157
|
+
}
|
|
89158
|
+
return { message: message2, hint: hint2 };
|
|
89159
|
+
}
|
|
89160
|
+
async function serialize$1(value, encryptionKey, options) {
|
|
89161
|
+
try {
|
|
89162
|
+
const payload = devalueCodec.serialize(value, "client", options);
|
|
89163
|
+
const prefixed = encodeWithFormatPrefix(SerializationFormat.DEVALUE_V1, payload);
|
|
89164
|
+
return encrypt(prefixed, encryptionKey);
|
|
89165
|
+
} catch (error2) {
|
|
89166
|
+
const { message: message2, hint: hint2 } = formatSerializationError("client value", error2);
|
|
89167
|
+
throw new SerializationError(message2, { hint: hint2, cause: error2 });
|
|
89168
|
+
}
|
|
89169
|
+
}
|
|
89170
|
+
async function deserialize$2(data, encryptionKey, options) {
|
|
89171
|
+
const decrypted = await decrypt(data, encryptionKey);
|
|
89172
|
+
if (!(decrypted instanceof Uint8Array)) {
|
|
89173
|
+
if (devalueCodec.deserializeLegacy) {
|
|
89174
|
+
return devalueCodec.deserializeLegacy(decrypted, "client", options);
|
|
89175
|
+
}
|
|
89176
|
+
throw new Error("Cannot deserialize non-binary data without legacy support");
|
|
89177
|
+
}
|
|
89178
|
+
const { format: format2, payload } = decodeFormatPrefix(decrypted);
|
|
89179
|
+
if (format2 === SerializationFormat.DEVALUE_V1) {
|
|
89180
|
+
return devalueCodec.deserialize(payload, "client", options);
|
|
89181
|
+
}
|
|
89182
|
+
throw new Error(`Unsupported serialization format: ${format2}`);
|
|
89183
|
+
}
|
|
89184
|
+
async function serialize(value, encryptionKey, options) {
|
|
89185
|
+
try {
|
|
89186
|
+
const payload = devalueCodec.serialize(value, "step", options);
|
|
89187
|
+
const prefixed = encodeWithFormatPrefix(SerializationFormat.DEVALUE_V1, payload);
|
|
89188
|
+
return encrypt(prefixed, encryptionKey);
|
|
89189
|
+
} catch (error2) {
|
|
89190
|
+
const { message: message2, hint: hint2 } = formatSerializationError("step value", error2);
|
|
89191
|
+
throw new SerializationError(message2, { hint: hint2, cause: error2 });
|
|
89192
|
+
}
|
|
89193
|
+
}
|
|
89194
|
+
async function deserialize$1(data, encryptionKey, options) {
|
|
89195
|
+
const decrypted = await decrypt(data, encryptionKey);
|
|
89196
|
+
if (!(decrypted instanceof Uint8Array)) {
|
|
89197
|
+
if (devalueCodec.deserializeLegacy) {
|
|
89198
|
+
return devalueCodec.deserializeLegacy(decrypted, "step", options);
|
|
89199
|
+
}
|
|
89200
|
+
throw new Error("Cannot deserialize non-binary data without legacy support");
|
|
89201
|
+
}
|
|
89202
|
+
const { format: format2, payload } = decodeFormatPrefix(decrypted);
|
|
89203
|
+
if (format2 === SerializationFormat.DEVALUE_V1) {
|
|
89204
|
+
return devalueCodec.deserialize(payload, "step", options);
|
|
89205
|
+
}
|
|
89206
|
+
throw new Error(`Unsupported serialization format: ${format2}`);
|
|
89207
|
+
}
|
|
89208
|
+
function deserialize(data, options) {
|
|
89209
|
+
if (!(data instanceof Uint8Array)) {
|
|
89210
|
+
if (devalueCodec.deserializeLegacy) {
|
|
89211
|
+
return devalueCodec.deserializeLegacy(data, "workflow", options);
|
|
89212
|
+
}
|
|
89213
|
+
throw new Error("Cannot deserialize non-binary data without legacy support");
|
|
89214
|
+
}
|
|
89215
|
+
const { format: format2, payload } = decodeFormatPrefix(data);
|
|
89216
|
+
if (format2 === SerializationFormat.DEVALUE_V1) {
|
|
89217
|
+
return devalueCodec.deserialize(payload, "workflow", options);
|
|
89218
|
+
}
|
|
89219
|
+
throw new Error(`Unsupported serialization format: ${format2}`);
|
|
89220
|
+
}
|
|
89221
|
+
const CONTEXT_STORAGE_SYMBOL = Symbol.for("WORKFLOW_STEP_CONTEXT_STORAGE");
|
|
89222
|
+
const contextStorage = globalThis[CONTEXT_STORAGE_SYMBOL] ?? (globalThis[CONTEXT_STORAGE_SYMBOL] = new AsyncLocalStorage());
|
|
88232
89223
|
var headers$1;
|
|
88233
89224
|
var hasRequiredHeaders$1;
|
|
88234
89225
|
function requireHeaders$1() {
|
|
@@ -89321,824 +90312,6 @@ function requireFunctions() {
|
|
|
89321
90312
|
return functions;
|
|
89322
90313
|
}
|
|
89323
90314
|
var functionsExports = requireFunctions();
|
|
89324
|
-
const RegisteredStepsKey = Symbol.for("@workflow/core//registeredSteps");
|
|
89325
|
-
const globalSymbols$1 = globalThis;
|
|
89326
|
-
const registeredSteps = globalSymbols$1[RegisteredStepsKey] ?? (globalSymbols$1[RegisteredStepsKey] = /* @__PURE__ */ new Map());
|
|
89327
|
-
const BUILTIN_RESPONSE_STEP_NAMES = /* @__PURE__ */ new Set([
|
|
89328
|
-
"__builtin_response_array_buffer",
|
|
89329
|
-
"__builtin_response_json",
|
|
89330
|
-
"__builtin_response_text"
|
|
89331
|
-
]);
|
|
89332
|
-
function getStepIdAliasCandidates(stepId) {
|
|
89333
|
-
const parts = stepId.split("//");
|
|
89334
|
-
if (parts.length !== 3 || parts[0] !== "step") {
|
|
89335
|
-
return [];
|
|
89336
|
-
}
|
|
89337
|
-
const modulePath = parts[1];
|
|
89338
|
-
const fnName = parts[2];
|
|
89339
|
-
const modulePathAliases = /* @__PURE__ */ new Set();
|
|
89340
|
-
const addAlias = (aliasModulePath) => {
|
|
89341
|
-
if (aliasModulePath !== modulePath) {
|
|
89342
|
-
modulePathAliases.add(aliasModulePath);
|
|
89343
|
-
}
|
|
89344
|
-
};
|
|
89345
|
-
if (modulePath.startsWith("./workflows/")) {
|
|
89346
|
-
const workflowRelativePath = modulePath.slice("./".length);
|
|
89347
|
-
addAlias(`./example/${workflowRelativePath}`);
|
|
89348
|
-
addAlias(`./src/${workflowRelativePath}`);
|
|
89349
|
-
} else if (modulePath.startsWith("./example/workflows/")) {
|
|
89350
|
-
const workflowRelativePath = modulePath.slice("./example/".length);
|
|
89351
|
-
addAlias(`./${workflowRelativePath}`);
|
|
89352
|
-
addAlias(`./src/${workflowRelativePath}`);
|
|
89353
|
-
} else if (modulePath.startsWith("./src/workflows/")) {
|
|
89354
|
-
const workflowRelativePath = modulePath.slice("./src/".length);
|
|
89355
|
-
addAlias(`./${workflowRelativePath}`);
|
|
89356
|
-
addAlias(`./example/${workflowRelativePath}`);
|
|
89357
|
-
}
|
|
89358
|
-
return Array.from(modulePathAliases, (aliasModulePath) => `step//${aliasModulePath}//${fnName}`);
|
|
89359
|
-
}
|
|
89360
|
-
function getBuiltinResponseStepAlias(stepId) {
|
|
89361
|
-
if (!BUILTIN_RESPONSE_STEP_NAMES.has(stepId)) {
|
|
89362
|
-
return void 0;
|
|
89363
|
-
}
|
|
89364
|
-
for (const [registeredStepId, stepFn] of registeredSteps.entries()) {
|
|
89365
|
-
if (registeredStepId.endsWith(`//${stepId}`)) {
|
|
89366
|
-
return stepFn;
|
|
89367
|
-
}
|
|
89368
|
-
}
|
|
89369
|
-
return void 0;
|
|
89370
|
-
}
|
|
89371
|
-
function getStepFunction(stepId) {
|
|
89372
|
-
const directMatch = registeredSteps.get(stepId);
|
|
89373
|
-
if (directMatch) {
|
|
89374
|
-
return directMatch;
|
|
89375
|
-
}
|
|
89376
|
-
for (const aliasStepId of getStepIdAliasCandidates(stepId)) {
|
|
89377
|
-
const aliasMatch = registeredSteps.get(aliasStepId);
|
|
89378
|
-
if (aliasMatch) {
|
|
89379
|
-
return aliasMatch;
|
|
89380
|
-
}
|
|
89381
|
-
}
|
|
89382
|
-
const builtinAliasMatch = getBuiltinResponseStepAlias(stepId);
|
|
89383
|
-
if (builtinAliasMatch) {
|
|
89384
|
-
return builtinAliasMatch;
|
|
89385
|
-
}
|
|
89386
|
-
return void 0;
|
|
89387
|
-
}
|
|
89388
|
-
const LOCK_POLL_INTERVAL_MS = 10;
|
|
89389
|
-
function createFlushableState() {
|
|
89390
|
-
return {
|
|
89391
|
-
...withResolvers$1(),
|
|
89392
|
-
pendingOps: 0,
|
|
89393
|
-
doneResolved: false,
|
|
89394
|
-
streamEnded: false
|
|
89395
|
-
};
|
|
89396
|
-
}
|
|
89397
|
-
function isWritableUnlockedNotClosed(writable) {
|
|
89398
|
-
if (writable.locked)
|
|
89399
|
-
return false;
|
|
89400
|
-
let writer;
|
|
89401
|
-
try {
|
|
89402
|
-
writer = writable.getWriter();
|
|
89403
|
-
} catch {
|
|
89404
|
-
return false;
|
|
89405
|
-
}
|
|
89406
|
-
try {
|
|
89407
|
-
writer.releaseLock();
|
|
89408
|
-
} catch {
|
|
89409
|
-
return false;
|
|
89410
|
-
}
|
|
89411
|
-
return true;
|
|
89412
|
-
}
|
|
89413
|
-
function isReadableUnlockedNotClosed(readable2) {
|
|
89414
|
-
if (readable2.locked)
|
|
89415
|
-
return false;
|
|
89416
|
-
let reader;
|
|
89417
|
-
try {
|
|
89418
|
-
reader = readable2.getReader();
|
|
89419
|
-
} catch {
|
|
89420
|
-
return false;
|
|
89421
|
-
}
|
|
89422
|
-
try {
|
|
89423
|
-
reader.releaseLock();
|
|
89424
|
-
} catch {
|
|
89425
|
-
return false;
|
|
89426
|
-
}
|
|
89427
|
-
return true;
|
|
89428
|
-
}
|
|
89429
|
-
function pollWritableLock(writable, state) {
|
|
89430
|
-
if (state.writablePollingInterval !== void 0) {
|
|
89431
|
-
return;
|
|
89432
|
-
}
|
|
89433
|
-
const intervalId = setInterval(() => {
|
|
89434
|
-
if (state.doneResolved || state.streamEnded) {
|
|
89435
|
-
clearInterval(intervalId);
|
|
89436
|
-
state.writablePollingInterval = void 0;
|
|
89437
|
-
return;
|
|
89438
|
-
}
|
|
89439
|
-
if (isWritableUnlockedNotClosed(writable) && state.pendingOps === 0) {
|
|
89440
|
-
state.doneResolved = true;
|
|
89441
|
-
state.resolve();
|
|
89442
|
-
clearInterval(intervalId);
|
|
89443
|
-
state.writablePollingInterval = void 0;
|
|
89444
|
-
}
|
|
89445
|
-
}, LOCK_POLL_INTERVAL_MS);
|
|
89446
|
-
state.writablePollingInterval = intervalId;
|
|
89447
|
-
}
|
|
89448
|
-
function pollReadableLock(readable2, state) {
|
|
89449
|
-
if (state.readablePollingInterval !== void 0) {
|
|
89450
|
-
return;
|
|
89451
|
-
}
|
|
89452
|
-
const intervalId = setInterval(() => {
|
|
89453
|
-
if (state.doneResolved || state.streamEnded) {
|
|
89454
|
-
clearInterval(intervalId);
|
|
89455
|
-
state.readablePollingInterval = void 0;
|
|
89456
|
-
return;
|
|
89457
|
-
}
|
|
89458
|
-
if (isReadableUnlockedNotClosed(readable2) && state.pendingOps === 0) {
|
|
89459
|
-
state.doneResolved = true;
|
|
89460
|
-
state.resolve();
|
|
89461
|
-
clearInterval(intervalId);
|
|
89462
|
-
state.readablePollingInterval = void 0;
|
|
89463
|
-
}
|
|
89464
|
-
}, LOCK_POLL_INTERVAL_MS);
|
|
89465
|
-
state.readablePollingInterval = intervalId;
|
|
89466
|
-
}
|
|
89467
|
-
async function flushablePipe(source, sink, state) {
|
|
89468
|
-
const reader = source.getReader();
|
|
89469
|
-
const writer = sink.getWriter();
|
|
89470
|
-
let cancelReason;
|
|
89471
|
-
try {
|
|
89472
|
-
while (true) {
|
|
89473
|
-
if (state.streamEnded) {
|
|
89474
|
-
return;
|
|
89475
|
-
}
|
|
89476
|
-
const readResult = await Promise.race([
|
|
89477
|
-
reader.read(),
|
|
89478
|
-
writer.closed.then(() => {
|
|
89479
|
-
throw new WorkflowRuntimeError("Writable stream closed prematurely");
|
|
89480
|
-
})
|
|
89481
|
-
]);
|
|
89482
|
-
if (state.streamEnded) {
|
|
89483
|
-
return;
|
|
89484
|
-
}
|
|
89485
|
-
if (readResult.done) {
|
|
89486
|
-
state.streamEnded = true;
|
|
89487
|
-
await writer.close();
|
|
89488
|
-
if (!state.doneResolved) {
|
|
89489
|
-
state.doneResolved = true;
|
|
89490
|
-
state.resolve();
|
|
89491
|
-
}
|
|
89492
|
-
return;
|
|
89493
|
-
}
|
|
89494
|
-
state.pendingOps++;
|
|
89495
|
-
try {
|
|
89496
|
-
await writer.write(readResult.value);
|
|
89497
|
-
} finally {
|
|
89498
|
-
state.pendingOps--;
|
|
89499
|
-
}
|
|
89500
|
-
}
|
|
89501
|
-
} catch (err) {
|
|
89502
|
-
state.streamEnded = true;
|
|
89503
|
-
cancelReason = err;
|
|
89504
|
-
if (!state.doneResolved) {
|
|
89505
|
-
state.doneResolved = true;
|
|
89506
|
-
state.reject(err);
|
|
89507
|
-
}
|
|
89508
|
-
throw err;
|
|
89509
|
-
} finally {
|
|
89510
|
-
reader.cancel(cancelReason).catch(() => {
|
|
89511
|
-
});
|
|
89512
|
-
reader.releaseLock();
|
|
89513
|
-
writer.releaseLock();
|
|
89514
|
-
}
|
|
89515
|
-
}
|
|
89516
|
-
const WORKFLOW_SERIALIZE = Symbol.for("workflow-serialize");
|
|
89517
|
-
const WORKFLOW_DESERIALIZE = Symbol.for("workflow-deserialize");
|
|
89518
|
-
const STABLE_ULID = Symbol.for("WORKFLOW_STABLE_ULID");
|
|
89519
|
-
const STREAM_NAME_SYMBOL = Symbol.for("WORKFLOW_STREAM_NAME");
|
|
89520
|
-
const STREAM_TYPE_SYMBOL = Symbol.for("WORKFLOW_STREAM_TYPE");
|
|
89521
|
-
const BODY_INIT_SYMBOL = Symbol.for("BODY_INIT");
|
|
89522
|
-
const WEBHOOK_RESPONSE_WRITABLE = Symbol.for("WEBHOOK_RESPONSE_WRITABLE");
|
|
89523
|
-
const WORKFLOW_CLASS_REGISTRY = Symbol.for("workflow-class-registry");
|
|
89524
|
-
const ABORT_STREAM_NAME = Symbol.for("WORKFLOW_ABORT_STREAM_NAME");
|
|
89525
|
-
const ABORT_HOOK_TOKEN = Symbol.for("WORKFLOW_ABORT_HOOK_TOKEN");
|
|
89526
|
-
const ABORT_LISTENER_ATTACHED = Symbol.for("WORKFLOW_ABORT_LISTENER_ATTACHED");
|
|
89527
|
-
const ABORT_READER_CANCEL = Symbol.for("WORKFLOW_ABORT_READER_CANCEL");
|
|
89528
|
-
function getRegistry(global2 = globalThis) {
|
|
89529
|
-
const g2 = global2;
|
|
89530
|
-
let registry2 = g2[WORKFLOW_CLASS_REGISTRY];
|
|
89531
|
-
if (!registry2) {
|
|
89532
|
-
registry2 = /* @__PURE__ */ new Map();
|
|
89533
|
-
g2[WORKFLOW_CLASS_REGISTRY] = registry2;
|
|
89534
|
-
}
|
|
89535
|
-
return registry2;
|
|
89536
|
-
}
|
|
89537
|
-
function getSerializationClass(classId, global2) {
|
|
89538
|
-
return getRegistry(global2).get(classId);
|
|
89539
|
-
}
|
|
89540
|
-
function getClassReducers() {
|
|
89541
|
-
return {
|
|
89542
|
-
// Class and Instance are intentionally placed before Error so that
|
|
89543
|
-
// custom Error subclasses with WORKFLOW_SERIALIZE take precedence
|
|
89544
|
-
// over the generic Error serialization (devalue uses first-match-wins).
|
|
89545
|
-
Class: (value) => {
|
|
89546
|
-
if (typeof value !== "function")
|
|
89547
|
-
return false;
|
|
89548
|
-
const classId = value.classId;
|
|
89549
|
-
if (typeof classId !== "string")
|
|
89550
|
-
return false;
|
|
89551
|
-
return { classId };
|
|
89552
|
-
},
|
|
89553
|
-
Instance: (value) => {
|
|
89554
|
-
if (value === null || typeof value !== "object")
|
|
89555
|
-
return false;
|
|
89556
|
-
const cls = value.constructor;
|
|
89557
|
-
if (!cls || typeof cls !== "function")
|
|
89558
|
-
return false;
|
|
89559
|
-
const serialize2 = cls[WORKFLOW_SERIALIZE];
|
|
89560
|
-
if (typeof serialize2 !== "function")
|
|
89561
|
-
return false;
|
|
89562
|
-
const classId = cls.classId;
|
|
89563
|
-
if (typeof classId !== "string") {
|
|
89564
|
-
throw new Error(`Class "${cls.name}" with ${String(WORKFLOW_SERIALIZE)} must have a static "classId" property.`);
|
|
89565
|
-
}
|
|
89566
|
-
const data = serialize2.call(cls, value);
|
|
89567
|
-
return { classId, data };
|
|
89568
|
-
}
|
|
89569
|
-
};
|
|
89570
|
-
}
|
|
89571
|
-
function getClassRevivers(global2 = globalThis) {
|
|
89572
|
-
return {
|
|
89573
|
-
Class: (value) => {
|
|
89574
|
-
const classId = value.classId;
|
|
89575
|
-
const cls = getSerializationClass(classId, global2);
|
|
89576
|
-
if (!cls) {
|
|
89577
|
-
throw new Error(`Class "${classId}" not found. Make sure the class is registered with registerSerializationClass.`);
|
|
89578
|
-
}
|
|
89579
|
-
return cls;
|
|
89580
|
-
},
|
|
89581
|
-
Instance: (value) => {
|
|
89582
|
-
const classId = value.classId;
|
|
89583
|
-
const data = value.data;
|
|
89584
|
-
const cls = getSerializationClass(classId, global2);
|
|
89585
|
-
if (!cls) {
|
|
89586
|
-
throw new Error(`Class "${classId}" not found. Make sure the class is registered with registerSerializationClass.`);
|
|
89587
|
-
}
|
|
89588
|
-
const deserialize2 = cls[WORKFLOW_DESERIALIZE];
|
|
89589
|
-
if (typeof deserialize2 !== "function") {
|
|
89590
|
-
throw new Error(`Class "${classId}" does not have a static ${String(WORKFLOW_DESERIALIZE)} method.`);
|
|
89591
|
-
}
|
|
89592
|
-
return deserialize2.call(cls, data);
|
|
89593
|
-
}
|
|
89594
|
-
};
|
|
89595
|
-
}
|
|
89596
|
-
function arrayBufferToBase64(value, offset2, length) {
|
|
89597
|
-
if (length === 0)
|
|
89598
|
-
return ".";
|
|
89599
|
-
const uint8 = new Uint8Array(value, offset2, length);
|
|
89600
|
-
return Buffer.from(uint8).toString("base64");
|
|
89601
|
-
}
|
|
89602
|
-
function viewToBase64(value) {
|
|
89603
|
-
return arrayBufferToBase64(value.buffer, value.byteOffset, value.byteLength);
|
|
89604
|
-
}
|
|
89605
|
-
function reviveArrayBuffer(value, global2) {
|
|
89606
|
-
const base642 = value === "." ? "" : value;
|
|
89607
|
-
const buffer = Buffer.from(base642, "base64");
|
|
89608
|
-
const arrayBuffer = new global2.ArrayBuffer(buffer.length);
|
|
89609
|
-
const uint8Array = new global2.Uint8Array(arrayBuffer);
|
|
89610
|
-
uint8Array.set(buffer);
|
|
89611
|
-
return arrayBuffer;
|
|
89612
|
-
}
|
|
89613
|
-
function revive(str) {
|
|
89614
|
-
return JSON.parse(str);
|
|
89615
|
-
}
|
|
89616
|
-
function reduceErrorBase(value) {
|
|
89617
|
-
if (!types$3.isNativeError(value))
|
|
89618
|
-
return false;
|
|
89619
|
-
const reduced = {
|
|
89620
|
-
message: value.message,
|
|
89621
|
-
stack: value.stack
|
|
89622
|
-
};
|
|
89623
|
-
if ("cause" in value)
|
|
89624
|
-
reduced.cause = value.cause;
|
|
89625
|
-
return reduced;
|
|
89626
|
-
}
|
|
89627
|
-
function reduceNamedErrorSubclassBase(subclassName, value) {
|
|
89628
|
-
if (!types$3.isNativeError(value))
|
|
89629
|
-
return false;
|
|
89630
|
-
if (value.name !== subclassName)
|
|
89631
|
-
return false;
|
|
89632
|
-
return reduceErrorBase(value);
|
|
89633
|
-
}
|
|
89634
|
-
function makeErrorSubclassReducer(subclassName) {
|
|
89635
|
-
return (value) => {
|
|
89636
|
-
const base = reduceNamedErrorSubclassBase(subclassName, value);
|
|
89637
|
-
if (!base)
|
|
89638
|
-
return false;
|
|
89639
|
-
return base;
|
|
89640
|
-
};
|
|
89641
|
-
}
|
|
89642
|
-
function makeErrorSubclassReviver(global2, ctorName) {
|
|
89643
|
-
return (value) => {
|
|
89644
|
-
const v2 = value;
|
|
89645
|
-
const opts = "cause" in v2 ? { cause: v2.cause } : void 0;
|
|
89646
|
-
const Ctor = global2[ctorName];
|
|
89647
|
-
const error2 = new Ctor(v2.message, opts);
|
|
89648
|
-
if (v2.stack !== void 0)
|
|
89649
|
-
error2.stack = v2.stack;
|
|
89650
|
-
return error2;
|
|
89651
|
-
};
|
|
89652
|
-
}
|
|
89653
|
-
function getCommonReducers(global2 = globalThis) {
|
|
89654
|
-
return {
|
|
89655
|
-
ArrayBuffer: (value) => value instanceof global2.ArrayBuffer && arrayBufferToBase64(value, 0, value.byteLength),
|
|
89656
|
-
BigInt: (value) => typeof value === "bigint" && value.toString(),
|
|
89657
|
-
BigInt64Array: (value) => value instanceof global2.BigInt64Array && viewToBase64(value),
|
|
89658
|
-
BigUint64Array: (value) => value instanceof global2.BigUint64Array && viewToBase64(value),
|
|
89659
|
-
Date: (value) => {
|
|
89660
|
-
if (!(value instanceof global2.Date))
|
|
89661
|
-
return false;
|
|
89662
|
-
const valid2 = !Number.isNaN(value.getDate());
|
|
89663
|
-
return valid2 ? value.toISOString() : ".";
|
|
89664
|
-
},
|
|
89665
|
-
// DOMException is a special case: it `instanceof Error` is true in Node,
|
|
89666
|
-
// but `types.isNativeError()` returns FALSE for it, so the generic Error
|
|
89667
|
-
// reducer (which gates on isNativeError) won't match. Check it explicitly
|
|
89668
|
-
// by constructor name + Error inheritance so we catch DOMExceptions from
|
|
89669
|
-
// any realm (cross-VM safety: instanceof global.DOMException would fail
|
|
89670
|
-
// for instances minted in another context).
|
|
89671
|
-
DOMException: (value) => {
|
|
89672
|
-
var _a3;
|
|
89673
|
-
if (value === null || typeof value !== "object")
|
|
89674
|
-
return false;
|
|
89675
|
-
if (((_a3 = value.constructor) == null ? void 0 : _a3.name) !== "DOMException")
|
|
89676
|
-
return false;
|
|
89677
|
-
const e = value;
|
|
89678
|
-
const reduced = {
|
|
89679
|
-
message: e.message,
|
|
89680
|
-
name: e.name,
|
|
89681
|
-
stack: e.stack
|
|
89682
|
-
};
|
|
89683
|
-
if ("cause" in e)
|
|
89684
|
-
reduced.cause = e.cause;
|
|
89685
|
-
return reduced;
|
|
89686
|
-
},
|
|
89687
|
-
// Error subclass reducers are intentionally placed before the base Error
|
|
89688
|
-
// reducer because devalue uses first-match-wins. Subclass-specific reducers
|
|
89689
|
-
// must be checked first so that e.g. a TypeError is serialized as "TypeError"
|
|
89690
|
-
// rather than falling through to the generic "Error" reducer.
|
|
89691
|
-
// See `makeErrorSubclassReducer` for implementation details.
|
|
89692
|
-
EvalError: makeErrorSubclassReducer("EvalError"),
|
|
89693
|
-
FatalError: makeErrorSubclassReducer("FatalError"),
|
|
89694
|
-
RangeError: makeErrorSubclassReducer("RangeError"),
|
|
89695
|
-
ReferenceError: makeErrorSubclassReducer("ReferenceError"),
|
|
89696
|
-
// RetryableError carries an extra `retryAfter` Date that we serialize as
|
|
89697
|
-
// a numeric epoch timestamp. The Date reducer uses `instanceof global.Date`,
|
|
89698
|
-
// which fails for Dates from a different VM realm; serializing as a
|
|
89699
|
-
// number sidesteps that issue.
|
|
89700
|
-
RetryableError: (value) => {
|
|
89701
|
-
const base = reduceNamedErrorSubclassBase("RetryableError", value);
|
|
89702
|
-
if (!base)
|
|
89703
|
-
return false;
|
|
89704
|
-
const retryAfterRaw = value.retryAfter;
|
|
89705
|
-
let retryAfter;
|
|
89706
|
-
if (retryAfterRaw && typeof retryAfterRaw === "object" && typeof retryAfterRaw.getTime === "function") {
|
|
89707
|
-
const t = retryAfterRaw.getTime();
|
|
89708
|
-
retryAfter = Number.isNaN(t) ? Date.now() + 1e3 : t;
|
|
89709
|
-
} else if (typeof retryAfterRaw === "string" || typeof retryAfterRaw === "number") {
|
|
89710
|
-
const t = new Date(retryAfterRaw).getTime();
|
|
89711
|
-
retryAfter = Number.isNaN(t) ? Date.now() + 1e3 : t;
|
|
89712
|
-
} else {
|
|
89713
|
-
retryAfter = Date.now() + 1e3;
|
|
89714
|
-
}
|
|
89715
|
-
return {
|
|
89716
|
-
...base,
|
|
89717
|
-
retryAfter
|
|
89718
|
-
};
|
|
89719
|
-
},
|
|
89720
|
-
SyntaxError: makeErrorSubclassReducer("SyntaxError"),
|
|
89721
|
-
TypeError: makeErrorSubclassReducer("TypeError"),
|
|
89722
|
-
URIError: makeErrorSubclassReducer("URIError"),
|
|
89723
|
-
// AggregateError is similar to other subclasses but also preserves the
|
|
89724
|
-
// `errors` array. We extend the base helper's output here.
|
|
89725
|
-
AggregateError: (value) => {
|
|
89726
|
-
const base = reduceNamedErrorSubclassBase("AggregateError", value);
|
|
89727
|
-
if (!base)
|
|
89728
|
-
return false;
|
|
89729
|
-
return {
|
|
89730
|
-
...base,
|
|
89731
|
-
errors: value.errors
|
|
89732
|
-
};
|
|
89733
|
-
},
|
|
89734
|
-
// Base Error reducer — catch-all for any Error instance not matched by a
|
|
89735
|
-
// specific subclass reducer above (including user Error subclasses without
|
|
89736
|
-
// WORKFLOW_SERIALIZE). Preserves `name` so the error's identity is retained
|
|
89737
|
-
// even though the exact class cannot be reconstructed.
|
|
89738
|
-
Error: (value) => {
|
|
89739
|
-
if (!types$3.isNativeError(value))
|
|
89740
|
-
return false;
|
|
89741
|
-
const reduced = {
|
|
89742
|
-
name: value.name,
|
|
89743
|
-
message: value.message,
|
|
89744
|
-
stack: value.stack
|
|
89745
|
-
};
|
|
89746
|
-
if ("cause" in value)
|
|
89747
|
-
reduced.cause = value.cause;
|
|
89748
|
-
return reduced;
|
|
89749
|
-
},
|
|
89750
|
-
Float32Array: (value) => value instanceof global2.Float32Array && viewToBase64(value),
|
|
89751
|
-
Float64Array: (value) => value instanceof global2.Float64Array && viewToBase64(value),
|
|
89752
|
-
Headers: (value) => value instanceof global2.Headers && Array.from(value),
|
|
89753
|
-
Int8Array: (value) => value instanceof global2.Int8Array && viewToBase64(value),
|
|
89754
|
-
Int16Array: (value) => value instanceof global2.Int16Array && viewToBase64(value),
|
|
89755
|
-
Int32Array: (value) => value instanceof global2.Int32Array && viewToBase64(value),
|
|
89756
|
-
Map: (value) => value instanceof global2.Map && Array.from(value),
|
|
89757
|
-
RegExp: (value) => value instanceof global2.RegExp && {
|
|
89758
|
-
source: value.source,
|
|
89759
|
-
flags: value.flags
|
|
89760
|
-
},
|
|
89761
|
-
// Request and Response are intentionally NOT in common reducers.
|
|
89762
|
-
// They require mode-specific revivers (stream handling, etc.) and
|
|
89763
|
-
// including them here without matching revivers would cause them
|
|
89764
|
-
// to deserialize as plain objects.
|
|
89765
|
-
Set: (value) => value instanceof global2.Set && Array.from(value),
|
|
89766
|
-
URL: (value) => value instanceof global2.URL && value.href,
|
|
89767
|
-
WorkflowFunction: (value) => {
|
|
89768
|
-
if (typeof value !== "function")
|
|
89769
|
-
return false;
|
|
89770
|
-
const workflowId = value.workflowId;
|
|
89771
|
-
if (typeof workflowId !== "string")
|
|
89772
|
-
return false;
|
|
89773
|
-
return { workflowId };
|
|
89774
|
-
},
|
|
89775
|
-
URLSearchParams: (value) => {
|
|
89776
|
-
if (!(value instanceof global2.URLSearchParams))
|
|
89777
|
-
return false;
|
|
89778
|
-
if (value.size === 0)
|
|
89779
|
-
return ".";
|
|
89780
|
-
return String(value);
|
|
89781
|
-
},
|
|
89782
|
-
Uint8Array: (value) => value instanceof global2.Uint8Array && viewToBase64(value),
|
|
89783
|
-
Uint8ClampedArray: (value) => value instanceof global2.Uint8ClampedArray && viewToBase64(value),
|
|
89784
|
-
Uint16Array: (value) => value instanceof global2.Uint16Array && viewToBase64(value),
|
|
89785
|
-
Uint32Array: (value) => value instanceof global2.Uint32Array && viewToBase64(value)
|
|
89786
|
-
};
|
|
89787
|
-
}
|
|
89788
|
-
function getCommonRevivers$1(global2 = globalThis) {
|
|
89789
|
-
return {
|
|
89790
|
-
ArrayBuffer: (value) => reviveArrayBuffer(value, global2),
|
|
89791
|
-
BigInt: (value) => global2.BigInt(value),
|
|
89792
|
-
BigInt64Array: (value) => new global2.BigInt64Array(reviveArrayBuffer(value, global2)),
|
|
89793
|
-
BigUint64Array: (value) => new global2.BigUint64Array(reviveArrayBuffer(value, global2)),
|
|
89794
|
-
Date: (value) => new global2.Date(value),
|
|
89795
|
-
DOMException: (value) => {
|
|
89796
|
-
const error2 = new global2.DOMException(value.message, value.name);
|
|
89797
|
-
if (value.stack !== void 0)
|
|
89798
|
-
error2.stack = value.stack;
|
|
89799
|
-
if ("cause" in value)
|
|
89800
|
-
error2.cause = value.cause;
|
|
89801
|
-
return error2;
|
|
89802
|
-
},
|
|
89803
|
-
// Error subclass revivers reconstruct the correct built-in Error type.
|
|
89804
|
-
// See `makeErrorSubclassReviver` for implementation details.
|
|
89805
|
-
EvalError: makeErrorSubclassReviver(global2, "EvalError"),
|
|
89806
|
-
// `FatalError` and `RetryableError` are not built-ins, so we resolve them
|
|
89807
|
-
// from the consumer's `globalThis` via a `Symbol.for(...)` key registered
|
|
89808
|
-
// by `@workflow/errors` on load. This makes `instanceof FatalError` work
|
|
89809
|
-
// in user code that lives in a different realm than this reducer module
|
|
89810
|
-
// (e.g. when the host hydrates a value destined for a workflow VM
|
|
89811
|
-
// context). See the registration block at the bottom of
|
|
89812
|
-
// `packages/errors/src/index.ts` for details. Falls back to the imported
|
|
89813
|
-
// class for environments where no bundled `@workflow/errors` has loaded
|
|
89814
|
-
// in the consumer realm.
|
|
89815
|
-
FatalError: (value) => {
|
|
89816
|
-
const Ctor = global2[Symbol.for("@workflow/errors//FatalError")] ?? FatalError;
|
|
89817
|
-
const error2 = new Ctor(value.message);
|
|
89818
|
-
if (value.stack !== void 0)
|
|
89819
|
-
error2.stack = value.stack;
|
|
89820
|
-
if ("cause" in value)
|
|
89821
|
-
error2.cause = value.cause;
|
|
89822
|
-
return error2;
|
|
89823
|
-
},
|
|
89824
|
-
RangeError: makeErrorSubclassReviver(global2, "RangeError"),
|
|
89825
|
-
ReferenceError: makeErrorSubclassReviver(global2, "ReferenceError"),
|
|
89826
|
-
RetryableError: (value) => {
|
|
89827
|
-
const Ctor = global2[Symbol.for("@workflow/errors//RetryableError")] ?? RetryableError;
|
|
89828
|
-
const error2 = new Ctor(value.message, {
|
|
89829
|
-
retryAfter: new global2.Date(value.retryAfter)
|
|
89830
|
-
});
|
|
89831
|
-
if (value.stack !== void 0)
|
|
89832
|
-
error2.stack = value.stack;
|
|
89833
|
-
if ("cause" in value)
|
|
89834
|
-
error2.cause = value.cause;
|
|
89835
|
-
return error2;
|
|
89836
|
-
},
|
|
89837
|
-
SyntaxError: makeErrorSubclassReviver(global2, "SyntaxError"),
|
|
89838
|
-
TypeError: makeErrorSubclassReviver(global2, "TypeError"),
|
|
89839
|
-
URIError: makeErrorSubclassReviver(global2, "URIError"),
|
|
89840
|
-
AggregateError: (value) => {
|
|
89841
|
-
const opts = "cause" in value ? { cause: value.cause } : void 0;
|
|
89842
|
-
const error2 = new global2.AggregateError(value.errors, value.message, opts);
|
|
89843
|
-
if (value.stack !== void 0)
|
|
89844
|
-
error2.stack = value.stack;
|
|
89845
|
-
return error2;
|
|
89846
|
-
},
|
|
89847
|
-
// Base Error reviver — used for plain Error instances and unrecognized
|
|
89848
|
-
// Error subclasses. Preserves `name` so the error's identity is retained.
|
|
89849
|
-
Error: (value) => {
|
|
89850
|
-
const opts = "cause" in value ? { cause: value.cause } : void 0;
|
|
89851
|
-
const error2 = new global2.Error(value.message, opts);
|
|
89852
|
-
error2.name = value.name;
|
|
89853
|
-
if (value.stack !== void 0)
|
|
89854
|
-
error2.stack = value.stack;
|
|
89855
|
-
return error2;
|
|
89856
|
-
},
|
|
89857
|
-
Float32Array: (value) => new global2.Float32Array(reviveArrayBuffer(value, global2)),
|
|
89858
|
-
Float64Array: (value) => new global2.Float64Array(reviveArrayBuffer(value, global2)),
|
|
89859
|
-
Headers: (value) => new global2.Headers(value),
|
|
89860
|
-
Int8Array: (value) => new global2.Int8Array(reviveArrayBuffer(value, global2)),
|
|
89861
|
-
Int16Array: (value) => new global2.Int16Array(reviveArrayBuffer(value, global2)),
|
|
89862
|
-
Int32Array: (value) => new global2.Int32Array(reviveArrayBuffer(value, global2)),
|
|
89863
|
-
Map: (value) => new global2.Map(value),
|
|
89864
|
-
RegExp: (value) => new global2.RegExp(value.source, value.flags),
|
|
89865
|
-
Set: (value) => new global2.Set(value),
|
|
89866
|
-
URL: (value) => new global2.URL(value),
|
|
89867
|
-
WorkflowFunction: (value) => Object.assign(() => {
|
|
89868
|
-
throw new Error("Workflow functions cannot be called directly. Use start() to invoke them.");
|
|
89869
|
-
}, { workflowId: value.workflowId }),
|
|
89870
|
-
URLSearchParams: (value) => new global2.URLSearchParams(value === "." ? "" : value),
|
|
89871
|
-
Uint8Array: (value) => new global2.Uint8Array(reviveArrayBuffer(value, global2)),
|
|
89872
|
-
Uint8ClampedArray: (value) => new global2.Uint8ClampedArray(reviveArrayBuffer(value, global2)),
|
|
89873
|
-
Uint16Array: (value) => new global2.Uint16Array(reviveArrayBuffer(value, global2)),
|
|
89874
|
-
Uint32Array: (value) => new global2.Uint32Array(reviveArrayBuffer(value, global2))
|
|
89875
|
-
};
|
|
89876
|
-
}
|
|
89877
|
-
function getStepFunctionReducer() {
|
|
89878
|
-
return {
|
|
89879
|
-
StepFunction: (value) => {
|
|
89880
|
-
if (typeof value !== "function")
|
|
89881
|
-
return false;
|
|
89882
|
-
const stepId = value.stepId;
|
|
89883
|
-
if (typeof stepId !== "string")
|
|
89884
|
-
return false;
|
|
89885
|
-
const closureVarsFn = value.__closureVarsFn;
|
|
89886
|
-
const closureVars = closureVarsFn && typeof closureVarsFn === "function" ? closureVarsFn() : void 0;
|
|
89887
|
-
const hasBoundThis = "__boundThis" in value;
|
|
89888
|
-
const boundThis = hasBoundThis ? value.__boundThis : void 0;
|
|
89889
|
-
const boundArgs = value.__boundArgs;
|
|
89890
|
-
const payload = { stepId };
|
|
89891
|
-
if (closureVars !== void 0)
|
|
89892
|
-
payload.closureVars = closureVars;
|
|
89893
|
-
if (hasBoundThis)
|
|
89894
|
-
payload.boundThis = boundThis;
|
|
89895
|
-
if (Array.isArray(boundArgs) && boundArgs.length > 0) {
|
|
89896
|
-
payload.boundArgs = boundArgs;
|
|
89897
|
-
}
|
|
89898
|
-
return payload;
|
|
89899
|
-
}
|
|
89900
|
-
};
|
|
89901
|
-
}
|
|
89902
|
-
function getStepFunctionReviver(global2 = globalThis) {
|
|
89903
|
-
const useStep = global2[Symbol.for("WORKFLOW_USE_STEP")];
|
|
89904
|
-
return {
|
|
89905
|
-
StepFunction: (value) => {
|
|
89906
|
-
const stepId = value.stepId;
|
|
89907
|
-
const closureVars = value.closureVars;
|
|
89908
|
-
if (!useStep) {
|
|
89909
|
-
throw new Error("WORKFLOW_USE_STEP not found on global object. Step functions cannot be deserialized outside workflow context.");
|
|
89910
|
-
}
|
|
89911
|
-
const proxy = closureVars ? useStep(stepId, () => closureVars) : useStep(stepId);
|
|
89912
|
-
if ("boundThis" in value) {
|
|
89913
|
-
const boundArgs = Array.isArray(value.boundArgs) ? value.boundArgs : [];
|
|
89914
|
-
return proxy.bind(value.boundThis, ...boundArgs);
|
|
89915
|
-
}
|
|
89916
|
-
return proxy;
|
|
89917
|
-
}
|
|
89918
|
-
};
|
|
89919
|
-
}
|
|
89920
|
-
function isFormatPrefix(value) {
|
|
89921
|
-
return value.length === 4 && /^[a-z0-9]{4}$/.test(value);
|
|
89922
|
-
}
|
|
89923
|
-
const SerializationFormat = {
|
|
89924
|
-
/** devalue stringify/parse with TextEncoder/TextDecoder */
|
|
89925
|
-
DEVALUE_V1: "devl",
|
|
89926
|
-
/** Encrypted payload (inner payload has its own format prefix) */
|
|
89927
|
-
ENCRYPTED: "encr"
|
|
89928
|
-
};
|
|
89929
|
-
const encoder = new TextEncoder();
|
|
89930
|
-
const decoder = new TextDecoder();
|
|
89931
|
-
function getReducersForMode(mode, global2 = globalThis, extraReducers) {
|
|
89932
|
-
let base;
|
|
89933
|
-
switch (mode) {
|
|
89934
|
-
case "workflow":
|
|
89935
|
-
base = {
|
|
89936
|
-
...getClassReducers(),
|
|
89937
|
-
...getStepFunctionReducer(),
|
|
89938
|
-
...getCommonReducers(global2)
|
|
89939
|
-
};
|
|
89940
|
-
break;
|
|
89941
|
-
case "step":
|
|
89942
|
-
base = {
|
|
89943
|
-
...getClassReducers(),
|
|
89944
|
-
...getCommonReducers(global2)
|
|
89945
|
-
};
|
|
89946
|
-
break;
|
|
89947
|
-
case "client":
|
|
89948
|
-
base = {
|
|
89949
|
-
...getClassReducers(),
|
|
89950
|
-
...getCommonReducers(global2)
|
|
89951
|
-
};
|
|
89952
|
-
break;
|
|
89953
|
-
}
|
|
89954
|
-
if (extraReducers) {
|
|
89955
|
-
return { ...base, ...extraReducers };
|
|
89956
|
-
}
|
|
89957
|
-
return base;
|
|
89958
|
-
}
|
|
89959
|
-
function getReviversForMode(mode, global2 = globalThis, extraRevivers) {
|
|
89960
|
-
let base;
|
|
89961
|
-
switch (mode) {
|
|
89962
|
-
case "workflow":
|
|
89963
|
-
base = {
|
|
89964
|
-
...getClassRevivers(global2),
|
|
89965
|
-
...getStepFunctionReviver(global2),
|
|
89966
|
-
...getCommonRevivers$1(global2)
|
|
89967
|
-
};
|
|
89968
|
-
break;
|
|
89969
|
-
case "step":
|
|
89970
|
-
base = {
|
|
89971
|
-
...getClassRevivers(global2),
|
|
89972
|
-
...getCommonRevivers$1(global2)
|
|
89973
|
-
};
|
|
89974
|
-
break;
|
|
89975
|
-
case "client":
|
|
89976
|
-
base = {
|
|
89977
|
-
...getClassRevivers(global2),
|
|
89978
|
-
...getCommonRevivers$1(global2),
|
|
89979
|
-
StepFunction: () => {
|
|
89980
|
-
throw new Error("Step functions cannot be deserialized in client context.");
|
|
89981
|
-
}
|
|
89982
|
-
};
|
|
89983
|
-
break;
|
|
89984
|
-
}
|
|
89985
|
-
if (extraRevivers) {
|
|
89986
|
-
return { ...base, ...extraRevivers };
|
|
89987
|
-
}
|
|
89988
|
-
return base;
|
|
89989
|
-
}
|
|
89990
|
-
const devalueCodec = {
|
|
89991
|
-
formatPrefix: SerializationFormat.DEVALUE_V1,
|
|
89992
|
-
serialize(value, mode, options) {
|
|
89993
|
-
const reducers = getReducersForMode(mode, options == null ? void 0 : options.global, options == null ? void 0 : options.extraReducers);
|
|
89994
|
-
const str = stringify$2(value, reducers);
|
|
89995
|
-
return encoder.encode(str);
|
|
89996
|
-
},
|
|
89997
|
-
deserialize(data, mode, options) {
|
|
89998
|
-
const revivers = getReviversForMode(mode, options == null ? void 0 : options.global, options == null ? void 0 : options.extraRevivers);
|
|
89999
|
-
const str = decoder.decode(data);
|
|
90000
|
-
return parse$7(str, revivers);
|
|
90001
|
-
},
|
|
90002
|
-
deserializeLegacy(data, mode, options) {
|
|
90003
|
-
const revivers = getReviversForMode(mode, options == null ? void 0 : options.global, options == null ? void 0 : options.extraRevivers);
|
|
90004
|
-
return unflatten(data, revivers);
|
|
90005
|
-
}
|
|
90006
|
-
};
|
|
90007
|
-
const FORMAT_PREFIX_LENGTH = 4;
|
|
90008
|
-
const formatEncoder = new TextEncoder();
|
|
90009
|
-
const formatDecoder = new TextDecoder();
|
|
90010
|
-
function encodeWithFormatPrefix(format2, payload) {
|
|
90011
|
-
if (!(payload instanceof Uint8Array)) {
|
|
90012
|
-
return payload;
|
|
90013
|
-
}
|
|
90014
|
-
const prefixBytes = formatEncoder.encode(format2);
|
|
90015
|
-
const result = new Uint8Array(FORMAT_PREFIX_LENGTH + payload.length);
|
|
90016
|
-
result.set(prefixBytes, 0);
|
|
90017
|
-
result.set(payload, FORMAT_PREFIX_LENGTH);
|
|
90018
|
-
return result;
|
|
90019
|
-
}
|
|
90020
|
-
function peekFormatPrefix(data) {
|
|
90021
|
-
if (!(data instanceof Uint8Array) || data.length < FORMAT_PREFIX_LENGTH) {
|
|
90022
|
-
return null;
|
|
90023
|
-
}
|
|
90024
|
-
const prefixBytes = data.subarray(0, FORMAT_PREFIX_LENGTH);
|
|
90025
|
-
const str = formatDecoder.decode(prefixBytes);
|
|
90026
|
-
return isFormatPrefix(str) ? str : null;
|
|
90027
|
-
}
|
|
90028
|
-
function decodeFormatPrefix(data) {
|
|
90029
|
-
if (!(data instanceof Uint8Array)) {
|
|
90030
|
-
return {
|
|
90031
|
-
format: SerializationFormat.DEVALUE_V1,
|
|
90032
|
-
payload: new TextEncoder().encode(JSON.stringify(data))
|
|
90033
|
-
};
|
|
90034
|
-
}
|
|
90035
|
-
if (data.length < FORMAT_PREFIX_LENGTH) {
|
|
90036
|
-
throw new Error(`Data too short to contain format prefix: expected at least ${FORMAT_PREFIX_LENGTH} bytes, got ${data.length}`);
|
|
90037
|
-
}
|
|
90038
|
-
const prefixBytes = data.subarray(0, FORMAT_PREFIX_LENGTH);
|
|
90039
|
-
const str = formatDecoder.decode(prefixBytes);
|
|
90040
|
-
if (!isFormatPrefix(str)) {
|
|
90041
|
-
throw new Error(`Invalid format prefix: "${str}". Must be 4 characters of [a-z0-9].`);
|
|
90042
|
-
}
|
|
90043
|
-
const payload = data.subarray(FORMAT_PREFIX_LENGTH);
|
|
90044
|
-
return { format: str, payload };
|
|
90045
|
-
}
|
|
90046
|
-
async function encrypt(data, key) {
|
|
90047
|
-
if (!key || !(data instanceof Uint8Array))
|
|
90048
|
-
return data;
|
|
90049
|
-
const encrypted = await encrypt$1(key, data);
|
|
90050
|
-
return encodeWithFormatPrefix(SerializationFormat.ENCRYPTED, encrypted);
|
|
90051
|
-
}
|
|
90052
|
-
async function decrypt(data, key) {
|
|
90053
|
-
if (!(data instanceof Uint8Array))
|
|
90054
|
-
return data;
|
|
90055
|
-
const format2 = peekFormatPrefix(data);
|
|
90056
|
-
if (format2 === SerializationFormat.ENCRYPTED && !key) {
|
|
90057
|
-
throw new WorkflowRuntimeError("Encrypted data encountered but no encryption key is available. Encryption is not configured or no key was provided for this run.");
|
|
90058
|
-
}
|
|
90059
|
-
if (format2 !== SerializationFormat.ENCRYPTED)
|
|
90060
|
-
return data;
|
|
90061
|
-
const { payload } = decodeFormatPrefix(data);
|
|
90062
|
-
return decrypt$1(key, payload);
|
|
90063
|
-
}
|
|
90064
|
-
function formatSerializationError(context, error2) {
|
|
90065
|
-
const verb = context.includes("return value") ? "returning" : "passing";
|
|
90066
|
-
let message2 = `Failed to serialize ${context}`;
|
|
90067
|
-
if (error2 instanceof DevalueError && error2.path) {
|
|
90068
|
-
message2 += ` at path "${error2.path}"`;
|
|
90069
|
-
}
|
|
90070
|
-
const hint2 = `Ensure you're ${verb} workflow serializable types. Check the serialization docs to see what's serializable: https://workflow-sdk.dev/docs/foundations/serialization`;
|
|
90071
|
-
if (error2 instanceof DevalueError && error2.value !== void 0) {
|
|
90072
|
-
runtimeLogger.error("Serialization failed", {
|
|
90073
|
-
context,
|
|
90074
|
-
problematicValue: error2.value
|
|
90075
|
-
});
|
|
90076
|
-
}
|
|
90077
|
-
return { message: message2, hint: hint2 };
|
|
90078
|
-
}
|
|
90079
|
-
async function serialize$1(value, encryptionKey, options) {
|
|
90080
|
-
try {
|
|
90081
|
-
const payload = devalueCodec.serialize(value, "client", options);
|
|
90082
|
-
const prefixed = encodeWithFormatPrefix(SerializationFormat.DEVALUE_V1, payload);
|
|
90083
|
-
return encrypt(prefixed, encryptionKey);
|
|
90084
|
-
} catch (error2) {
|
|
90085
|
-
const { message: message2, hint: hint2 } = formatSerializationError("client value", error2);
|
|
90086
|
-
throw new SerializationError(message2, { hint: hint2, cause: error2 });
|
|
90087
|
-
}
|
|
90088
|
-
}
|
|
90089
|
-
async function deserialize$2(data, encryptionKey, options) {
|
|
90090
|
-
const decrypted = await decrypt(data, encryptionKey);
|
|
90091
|
-
if (!(decrypted instanceof Uint8Array)) {
|
|
90092
|
-
if (devalueCodec.deserializeLegacy) {
|
|
90093
|
-
return devalueCodec.deserializeLegacy(decrypted, "client", options);
|
|
90094
|
-
}
|
|
90095
|
-
throw new Error("Cannot deserialize non-binary data without legacy support");
|
|
90096
|
-
}
|
|
90097
|
-
const { format: format2, payload } = decodeFormatPrefix(decrypted);
|
|
90098
|
-
if (format2 === SerializationFormat.DEVALUE_V1) {
|
|
90099
|
-
return devalueCodec.deserialize(payload, "client", options);
|
|
90100
|
-
}
|
|
90101
|
-
throw new Error(`Unsupported serialization format: ${format2}`);
|
|
90102
|
-
}
|
|
90103
|
-
async function serialize(value, encryptionKey, options) {
|
|
90104
|
-
try {
|
|
90105
|
-
const payload = devalueCodec.serialize(value, "step", options);
|
|
90106
|
-
const prefixed = encodeWithFormatPrefix(SerializationFormat.DEVALUE_V1, payload);
|
|
90107
|
-
return encrypt(prefixed, encryptionKey);
|
|
90108
|
-
} catch (error2) {
|
|
90109
|
-
const { message: message2, hint: hint2 } = formatSerializationError("step value", error2);
|
|
90110
|
-
throw new SerializationError(message2, { hint: hint2, cause: error2 });
|
|
90111
|
-
}
|
|
90112
|
-
}
|
|
90113
|
-
async function deserialize$1(data, encryptionKey, options) {
|
|
90114
|
-
const decrypted = await decrypt(data, encryptionKey);
|
|
90115
|
-
if (!(decrypted instanceof Uint8Array)) {
|
|
90116
|
-
if (devalueCodec.deserializeLegacy) {
|
|
90117
|
-
return devalueCodec.deserializeLegacy(decrypted, "step", options);
|
|
90118
|
-
}
|
|
90119
|
-
throw new Error("Cannot deserialize non-binary data without legacy support");
|
|
90120
|
-
}
|
|
90121
|
-
const { format: format2, payload } = decodeFormatPrefix(decrypted);
|
|
90122
|
-
if (format2 === SerializationFormat.DEVALUE_V1) {
|
|
90123
|
-
return devalueCodec.deserialize(payload, "step", options);
|
|
90124
|
-
}
|
|
90125
|
-
throw new Error(`Unsupported serialization format: ${format2}`);
|
|
90126
|
-
}
|
|
90127
|
-
function deserialize(data, options) {
|
|
90128
|
-
if (!(data instanceof Uint8Array)) {
|
|
90129
|
-
if (devalueCodec.deserializeLegacy) {
|
|
90130
|
-
return devalueCodec.deserializeLegacy(data, "workflow", options);
|
|
90131
|
-
}
|
|
90132
|
-
throw new Error("Cannot deserialize non-binary data without legacy support");
|
|
90133
|
-
}
|
|
90134
|
-
const { format: format2, payload } = decodeFormatPrefix(data);
|
|
90135
|
-
if (format2 === SerializationFormat.DEVALUE_V1) {
|
|
90136
|
-
return devalueCodec.deserialize(payload, "workflow", options);
|
|
90137
|
-
}
|
|
90138
|
-
throw new Error(`Unsupported serialization format: ${format2}`);
|
|
90139
|
-
}
|
|
90140
|
-
const CONTEXT_STORAGE_SYMBOL = Symbol.for("WORKFLOW_STEP_CONTEXT_STORAGE");
|
|
90141
|
-
const contextStorage = globalThis[CONTEXT_STORAGE_SYMBOL] ?? (globalThis[CONTEXT_STORAGE_SYMBOL] = new AsyncLocalStorage());
|
|
90142
90315
|
function getWorkflowRunStreamId(runId, namespace2) {
|
|
90143
90316
|
const streamId = `${runId.replace("wrun_", "strm_")}_user`;
|
|
90144
90317
|
if (!namespace2) {
|
|
@@ -90590,6 +90763,11 @@ function getExternalReducers(global2 = globalThis, ops, runId, cryptoKey) {
|
|
|
90590
90763
|
WritableStream: (value) => {
|
|
90591
90764
|
if (!(value instanceof global2.WritableStream))
|
|
90592
90765
|
return false;
|
|
90766
|
+
const existingName = value[STREAM_NAME_SYMBOL];
|
|
90767
|
+
const existingRunId = value[STREAM_SERVER_RUN_ID_SYMBOL];
|
|
90768
|
+
if (typeof existingName === "string" && typeof existingRunId === "string") {
|
|
90769
|
+
return { name: existingName, runId: existingRunId };
|
|
90770
|
+
}
|
|
90593
90771
|
const streamId = (global2[STABLE_ULID] || defaultUlid)();
|
|
90594
90772
|
const name2 = `strm_${streamId}`;
|
|
90595
90773
|
const readable2 = new WorkflowServerReadableStream(runId, name2);
|
|
@@ -90637,7 +90815,11 @@ function getWorkflowReducers(global2 = globalThis) {
|
|
|
90637
90815
|
if (!name2) {
|
|
90638
90816
|
throw new WorkflowRuntimeError("WritableStream `name` is not set");
|
|
90639
90817
|
}
|
|
90640
|
-
|
|
90818
|
+
const s2 = { name: name2 };
|
|
90819
|
+
const foreignRunId = value[STREAM_SERVER_RUN_ID_SYMBOL];
|
|
90820
|
+
if (typeof foreignRunId === "string")
|
|
90821
|
+
s2.runId = foreignRunId;
|
|
90822
|
+
return s2;
|
|
90641
90823
|
},
|
|
90642
90824
|
// AbortController/AbortSignal in workflow context — just read symbols (handles).
|
|
90643
90825
|
// In the workflow VM, global.AbortController is a class but global.AbortSignal
|
|
@@ -90697,12 +90879,16 @@ function getStepReducers(global2 = globalThis, ops, runId, cryptoKey) {
|
|
|
90697
90879
|
if (!(value instanceof global2.WritableStream))
|
|
90698
90880
|
return false;
|
|
90699
90881
|
let name2 = value[STREAM_NAME_SYMBOL];
|
|
90882
|
+
const foreignRunId = value[STREAM_SERVER_RUN_ID_SYMBOL];
|
|
90700
90883
|
if (!name2) {
|
|
90701
90884
|
const streamId = (global2[STABLE_ULID] || defaultUlid)();
|
|
90702
90885
|
name2 = `strm_${streamId}`;
|
|
90703
90886
|
ops.push(new WorkflowServerReadableStream(runId, name2).pipeThrough(getDeserializeStream(getStepRevivers(global2, ops, runId, cryptoKey), cryptoKey)).pipeTo(value));
|
|
90704
90887
|
}
|
|
90705
|
-
|
|
90888
|
+
const s2 = { name: name2 };
|
|
90889
|
+
if (typeof foreignRunId === "string")
|
|
90890
|
+
s2.runId = foreignRunId;
|
|
90891
|
+
return s2;
|
|
90706
90892
|
},
|
|
90707
90893
|
AbortController: (value) => {
|
|
90708
90894
|
if (!global2.AbortController || typeof global2.AbortController !== "function" || !(value instanceof global2.AbortController))
|
|
@@ -90896,13 +91082,28 @@ function getExternalRevivers(global2 = globalThis, ops, runId, cryptoKey) {
|
|
|
90896
91082
|
}
|
|
90897
91083
|
},
|
|
90898
91084
|
WritableStream: (value) => {
|
|
90899
|
-
const
|
|
90900
|
-
const
|
|
91085
|
+
const targetRunId = typeof value.runId === "string" ? value.runId : runId;
|
|
91086
|
+
const targetKey = targetRunId === runId ? cryptoKey : (async () => {
|
|
91087
|
+
var _a3;
|
|
91088
|
+
const world = await getWorldLazy();
|
|
91089
|
+
const rawKey = await ((_a3 = world.getEncryptionKeyForRun) == null ? void 0 : _a3.call(world, targetRunId));
|
|
91090
|
+
return rawKey ? await importKey(rawKey, ["encrypt"]) : void 0;
|
|
91091
|
+
})();
|
|
91092
|
+
const serialize2 = getSerializeStream(getExternalReducers(global2, ops, targetRunId, targetKey), targetKey);
|
|
91093
|
+
const serverWritable = new WorkflowServerWritableStream(targetRunId, value.name);
|
|
90901
91094
|
const state = createFlushableState();
|
|
90902
91095
|
ops.push(state.promise);
|
|
90903
91096
|
flushablePipe(serialize2.readable, serverWritable, state).catch(() => {
|
|
90904
91097
|
});
|
|
90905
91098
|
pollWritableLock(serialize2.writable, state);
|
|
91099
|
+
Object.defineProperty(serialize2.writable, STREAM_NAME_SYMBOL, {
|
|
91100
|
+
value: value.name,
|
|
91101
|
+
writable: false
|
|
91102
|
+
});
|
|
91103
|
+
Object.defineProperty(serialize2.writable, STREAM_SERVER_RUN_ID_SYMBOL, {
|
|
91104
|
+
value: targetRunId,
|
|
91105
|
+
writable: false
|
|
91106
|
+
});
|
|
90906
91107
|
return serialize2.writable;
|
|
90907
91108
|
},
|
|
90908
91109
|
AbortController: (value) => reviveAbortController(value, ops, runId),
|
|
@@ -90961,12 +91162,19 @@ function getWorkflowRevivers(global2 = globalThis) {
|
|
|
90961
91162
|
});
|
|
90962
91163
|
},
|
|
90963
91164
|
WritableStream: (value) => {
|
|
90964
|
-
|
|
91165
|
+
const descriptor = {
|
|
90965
91166
|
[STREAM_NAME_SYMBOL]: {
|
|
90966
91167
|
value: value.name,
|
|
90967
91168
|
writable: false
|
|
90968
91169
|
}
|
|
90969
|
-
}
|
|
91170
|
+
};
|
|
91171
|
+
if (typeof value.runId === "string") {
|
|
91172
|
+
descriptor[STREAM_SERVER_RUN_ID_SYMBOL] = {
|
|
91173
|
+
value: value.runId,
|
|
91174
|
+
writable: false
|
|
91175
|
+
};
|
|
91176
|
+
}
|
|
91177
|
+
return Object.create(global2.WritableStream.prototype, descriptor);
|
|
90970
91178
|
},
|
|
90971
91179
|
// AbortController/AbortSignal revived inside the workflow VM. Use the
|
|
90972
91180
|
// real WorkflowAbortSignal class so addEventListener('abort', fn) actually
|
|
@@ -91121,13 +91329,28 @@ function getStepRevivers(global2 = globalThis, ops, runId, cryptoKey) {
|
|
|
91121
91329
|
}
|
|
91122
91330
|
},
|
|
91123
91331
|
WritableStream: (value) => {
|
|
91124
|
-
const
|
|
91125
|
-
const
|
|
91332
|
+
const targetRunId = typeof value.runId === "string" ? value.runId : runId;
|
|
91333
|
+
const targetKey = targetRunId === runId ? cryptoKey : (async () => {
|
|
91334
|
+
var _a3;
|
|
91335
|
+
const world = await getWorldLazy();
|
|
91336
|
+
const rawKey = await ((_a3 = world.getEncryptionKeyForRun) == null ? void 0 : _a3.call(world, targetRunId));
|
|
91337
|
+
return rawKey ? await importKey(rawKey, ["encrypt"]) : void 0;
|
|
91338
|
+
})();
|
|
91339
|
+
const serialize2 = getSerializeStream(getStepReducers(global2, ops, targetRunId, targetKey), targetKey);
|
|
91340
|
+
const serverWritable = new WorkflowServerWritableStream(targetRunId, value.name);
|
|
91126
91341
|
const state = createFlushableState();
|
|
91127
91342
|
ops.push(state.promise);
|
|
91128
91343
|
flushablePipe(serialize2.readable, serverWritable, state).catch(() => {
|
|
91129
91344
|
});
|
|
91130
91345
|
pollWritableLock(serialize2.writable, state);
|
|
91346
|
+
Object.defineProperty(serialize2.writable, STREAM_NAME_SYMBOL, {
|
|
91347
|
+
value: value.name,
|
|
91348
|
+
writable: false
|
|
91349
|
+
});
|
|
91350
|
+
Object.defineProperty(serialize2.writable, STREAM_SERVER_RUN_ID_SYMBOL, {
|
|
91351
|
+
value: targetRunId,
|
|
91352
|
+
writable: false
|
|
91353
|
+
});
|
|
91131
91354
|
return serialize2.writable;
|
|
91132
91355
|
},
|
|
91133
91356
|
AbortController: (value) => reviveAbortController(value, ops, runId),
|
|
@@ -116276,6 +116499,20 @@ const LOCAL_QUEUE_MAX_VISIBILITY = parseInt(process.env.WORKFLOW_LOCAL_QUEUE_MAX
|
|
|
116276
116499
|
const MAX_SAFE_TIMEOUT_MS = 2147483647;
|
|
116277
116500
|
const DEFAULT_CONCURRENCY_LIMIT = 1e3;
|
|
116278
116501
|
const WORKFLOW_LOCAL_QUEUE_CONCURRENCY = parseInt(process.env.WORKFLOW_LOCAL_QUEUE_CONCURRENCY ?? "0", 10) || DEFAULT_CONCURRENCY_LIMIT;
|
|
116502
|
+
const DETACHED_ARRAYBUFFER_ERROR = "Cannot perform ArrayBuffer.prototype.slice on a detached ArrayBuffer";
|
|
116503
|
+
const PROXY_HANDLER_DOCS_URL = "https://workflow-sdk.dev/docs/getting-started/next#configure-proxy-handler";
|
|
116504
|
+
function isDetachedArrayBufferQueueError(error2) {
|
|
116505
|
+
let current = error2;
|
|
116506
|
+
const visited = /* @__PURE__ */ new Set();
|
|
116507
|
+
while (current && typeof current === "object" && !visited.has(current)) {
|
|
116508
|
+
visited.add(current);
|
|
116509
|
+
if ("message" in current && typeof current.message === "string" && current.message.includes(DETACHED_ARRAYBUFFER_ERROR)) {
|
|
116510
|
+
return true;
|
|
116511
|
+
}
|
|
116512
|
+
current = "cause" in current ? current.cause : void 0;
|
|
116513
|
+
}
|
|
116514
|
+
return false;
|
|
116515
|
+
}
|
|
116279
116516
|
function getQueueRoute(queueName) {
|
|
116280
116517
|
if (queueName.startsWith("__wkf_step_")) {
|
|
116281
116518
|
return { pathname: "step", prefix: "__wkf_step_" };
|
|
@@ -116388,7 +116625,17 @@ function createQueue$2(config2) {
|
|
|
116388
116625
|
})().catch((err) => {
|
|
116389
116626
|
const isAbortError = (err == null ? void 0 : err.name) === "AbortError" || (err == null ? void 0 : err.name) === "ResponseAborted";
|
|
116390
116627
|
if (!isAbortError) {
|
|
116391
|
-
|
|
116628
|
+
if (isDetachedArrayBufferQueueError(err)) {
|
|
116629
|
+
console.error(`[local world] Queue operation failed: detected "${DETACHED_ARRAYBUFFER_ERROR}". This usually means a Next.js proxy/middleware consumed Workflow's internal request before the executor could read it. Exclude \`/.well-known/workflow/*\` from your matcher. See ${PROXY_HANDLER_DOCS_URL}`, {
|
|
116630
|
+
queueName,
|
|
116631
|
+
messageId,
|
|
116632
|
+
...runId && { runId },
|
|
116633
|
+
...stepId && { stepId },
|
|
116634
|
+
originalError: err
|
|
116635
|
+
});
|
|
116636
|
+
} else {
|
|
116637
|
+
console.error("[local world] Queue operation failed:", err);
|
|
116638
|
+
}
|
|
116392
116639
|
}
|
|
116393
116640
|
}).finally(() => {
|
|
116394
116641
|
for (const fn2 of cleanup) {
|
|
@@ -116617,6 +116864,19 @@ async function handleLegacyEvent(basedir, runId, data, currentRun, params) {
|
|
|
116617
116864
|
}
|
|
116618
116865
|
}
|
|
116619
116866
|
const stepLocks = /* @__PURE__ */ new Map();
|
|
116867
|
+
const HookTokenClaimSchema = object$1({
|
|
116868
|
+
runId: string$3()
|
|
116869
|
+
});
|
|
116870
|
+
async function readHookTokenClaim(constraintPath) {
|
|
116871
|
+
try {
|
|
116872
|
+
return await readJSON(constraintPath, HookTokenClaimSchema);
|
|
116873
|
+
} catch (error2) {
|
|
116874
|
+
if (error2 instanceof SyntaxError || error2 instanceof ZodError) {
|
|
116875
|
+
return null;
|
|
116876
|
+
}
|
|
116877
|
+
throw error2;
|
|
116878
|
+
}
|
|
116879
|
+
}
|
|
116620
116880
|
function withStepLock(key, fn2) {
|
|
116621
116881
|
const prev = stepLocks.get(key);
|
|
116622
116882
|
const taskBox = {};
|
|
@@ -117053,11 +117313,13 @@ function createEventsStorage(basedir, tag) {
|
|
|
117053
117313
|
runId: effectiveRunId
|
|
117054
117314
|
}));
|
|
117055
117315
|
if (!tokenClaimed) {
|
|
117316
|
+
const existingClaim = await readHookTokenClaim(constraintPath);
|
|
117056
117317
|
const conflictEvent = {
|
|
117057
117318
|
eventType: "hook_conflict",
|
|
117058
117319
|
correlationId: data.correlationId,
|
|
117059
117320
|
eventData: {
|
|
117060
|
-
token: hookData.token
|
|
117321
|
+
token: hookData.token,
|
|
117322
|
+
...existingClaim ? { conflictingRunId: existingClaim.runId } : {}
|
|
117061
117323
|
},
|
|
117062
117324
|
runId: effectiveRunId,
|
|
117063
117325
|
eventId,
|
|
@@ -117151,16 +117413,21 @@ function createEventsStorage(basedir, tag) {
|
|
|
117151
117413
|
const resolveData = (params == null ? void 0 : params.resolveData) ?? DEFAULT_RESOLVE_DATA_OPTION$1;
|
|
117152
117414
|
const filteredEvent = stripEventDataRefs(event, resolveData);
|
|
117153
117415
|
let events2;
|
|
117416
|
+
let cursor;
|
|
117417
|
+
let hasMore;
|
|
117154
117418
|
if (data.eventType === "run_started" && run) {
|
|
117155
117419
|
const allEvents = await paginatedFileSystemQuery({
|
|
117156
117420
|
directory: path$3.join(basedir, "events"),
|
|
117157
117421
|
schema: EventSchema,
|
|
117158
117422
|
filePrefix: `${effectiveRunId}-`,
|
|
117159
117423
|
sortOrder: "asc",
|
|
117424
|
+
limit: 1e3,
|
|
117160
117425
|
getCreatedAt: getObjectCreatedAt("evnt"),
|
|
117161
117426
|
getId: (e) => e.eventId
|
|
117162
117427
|
});
|
|
117163
117428
|
events2 = allEvents.data;
|
|
117429
|
+
cursor = allEvents.cursor;
|
|
117430
|
+
hasMore = allEvents.hasMore;
|
|
117164
117431
|
}
|
|
117165
117432
|
return {
|
|
117166
117433
|
event: filteredEvent,
|
|
@@ -117168,7 +117435,9 @@ function createEventsStorage(basedir, tag) {
|
|
|
117168
117435
|
step,
|
|
117169
117436
|
hook,
|
|
117170
117437
|
wait,
|
|
117171
|
-
events: events2
|
|
117438
|
+
events: events2,
|
|
117439
|
+
cursor,
|
|
117440
|
+
hasMore
|
|
117172
117441
|
};
|
|
117173
117442
|
}
|
|
117174
117443
|
},
|
|
@@ -117740,7 +118009,7 @@ function createLocalWorld(args) {
|
|
|
117740
118009
|
const basedir = mergedConfig.dataDir;
|
|
117741
118010
|
const hooksDir = path$3.join(basedir, "hooks");
|
|
117742
118011
|
const taggedHookFiles = await listTaggedFiles(hooksDir, tag);
|
|
117743
|
-
const { HookSchema: HookSchema2 } = await import("./index-
|
|
118012
|
+
const { HookSchema: HookSchema2 } = await import("./index-B_Gtun0B.js");
|
|
117744
118013
|
await Promise.all(taggedHookFiles.map(async (hookFile) => {
|
|
117745
118014
|
const hook = await readJSON(path$3.join(hooksDir, hookFile), HookSchema2);
|
|
117746
118015
|
if (hook == null ? void 0 : hook.token) {
|
|
@@ -117892,8 +118161,8 @@ function requireGetVercelOidcToken() {
|
|
|
117892
118161
|
}
|
|
117893
118162
|
try {
|
|
117894
118163
|
const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
|
|
117895
|
-
await import("./token-util-
|
|
117896
|
-
await import("./token-
|
|
118164
|
+
await import("./token-util-CHxt50WW.js").then((n) => n.t),
|
|
118165
|
+
await import("./token-98GkKm4t.js").then((n) => n.t)
|
|
117897
118166
|
]);
|
|
117898
118167
|
if (!token || isExpired(getTokenPayload(token), options == null ? void 0 : options.expirationBufferMs)) {
|
|
117899
118168
|
await refreshToken(options);
|
|
@@ -118935,16 +119204,22 @@ var StreamingMultipartParser = class {
|
|
|
118935
119204
|
let index2 = 0;
|
|
118936
119205
|
let chunkLength = chunk.length;
|
|
118937
119206
|
if (this.buffer !== null) {
|
|
118938
|
-
const
|
|
118939
|
-
const
|
|
118940
|
-
if (
|
|
119207
|
+
const bufferLength = this.buffer.length;
|
|
119208
|
+
const newSize = bufferLength + chunkLength;
|
|
119209
|
+
if (this.state === 2) {
|
|
119210
|
+
if (newSize > this.maxHeaderSize) {
|
|
119211
|
+
throw new MultipartParseError(
|
|
119212
|
+
`Buffer size limit exceeded: ${newSize} bytes > ${this.maxHeaderSize} bytes. This may indicate malformed multipart data with oversized headers.`
|
|
119213
|
+
);
|
|
119214
|
+
}
|
|
119215
|
+
} else if (bufferLength > this.maxBoundaryBuffer) {
|
|
118941
119216
|
throw new MultipartParseError(
|
|
118942
|
-
`
|
|
119217
|
+
`Boundary buffer limit exceeded: ${bufferLength} bytes > ${this.maxBoundaryBuffer} bytes. This may indicate malformed multipart data with invalid boundaries.`
|
|
118943
119218
|
);
|
|
118944
119219
|
}
|
|
118945
119220
|
const newChunk = new Uint8Array(newSize);
|
|
118946
119221
|
newChunk.set(this.buffer, 0);
|
|
118947
|
-
newChunk.set(chunk,
|
|
119222
|
+
newChunk.set(chunk, bufferLength);
|
|
118948
119223
|
chunk = newChunk;
|
|
118949
119224
|
chunkLength = chunk.length;
|
|
118950
119225
|
this.buffer = null;
|
|
@@ -122516,7 +122791,7 @@ Cause: ${cause}`
|
|
|
122516
122791
|
}
|
|
122517
122792
|
console.debug("[VQS Debug] Request:", JSON.stringify(logData, null, 2));
|
|
122518
122793
|
}
|
|
122519
|
-
init2.headers.set("User-Agent", `@vercel/queue/${"0.1.
|
|
122794
|
+
init2.headers.set("User-Agent", `@vercel/queue/${"0.1.7"}`);
|
|
122520
122795
|
init2.headers.set("Vqs-Client-Ts", (/* @__PURE__ */ new Date()).toISOString());
|
|
122521
122796
|
const fetchInit = this.dispatcher ? { ...init2, dispatcher: this.dispatcher } : init2;
|
|
122522
122797
|
const response2 = await fetch(url2, fetchInit);
|
|
@@ -123058,7 +123333,7 @@ var QueueClient = class {
|
|
|
123058
123333
|
setApi(this, new ApiClient({ ...options, region }));
|
|
123059
123334
|
}
|
|
123060
123335
|
};
|
|
123061
|
-
const version = "5.0.0-beta.
|
|
123336
|
+
const version = "5.0.0-beta.6";
|
|
123062
123337
|
const HTTP_DEBUG_ENABLED = typeof process !== "undefined" && typeof process.env.DEBUG === "string" && (process.env.DEBUG.includes("workflow:") || process.env.DEBUG === "*");
|
|
123063
123338
|
function httpLog(method, endpoint, status, ms2) {
|
|
123064
123339
|
if (HTTP_DEBUG_ENABLED) {
|
|
@@ -123249,7 +123524,7 @@ curl -X ${request2.method} ${stringifiedHeaders} "${url2}"`);
|
|
|
123249
123524
|
const contentType = response2.headers.get("Content-Type") || "unknown";
|
|
123250
123525
|
throw new WorkflowWorldError(`Failed to parse response body for ${request2.method} ${endpoint} (Content-Type: ${contentType}):
|
|
123251
123526
|
|
|
123252
|
-
${error2}`, { url: url2, cause: error2 });
|
|
123527
|
+
${error2}`, { url: url2, code: "PARSE_ERROR", cause: error2 });
|
|
123253
123528
|
}
|
|
123254
123529
|
const result = await trace("world.validate", async () => {
|
|
123255
123530
|
const validationResult = schema.safeParse(parseResult.data);
|
|
@@ -123259,7 +123534,7 @@ ${error2}`, { url: url2, cause: error2 });
|
|
|
123259
123534
|
|
|
123260
123535
|
Response context: ${parseResult.getDebugContext()}` : "";
|
|
123261
123536
|
throw new WorkflowWorldError(`Schema validation failed for ${method} ${endpoint}:
|
|
123262
|
-
${issues}${debugContext}`, { url: url2, cause: validationResult.error });
|
|
123537
|
+
${issues}${debugContext}`, { url: url2, code: "SCHEMA_VALIDATION", cause: validationResult.error });
|
|
123263
123538
|
}
|
|
123264
123539
|
return validationResult.data;
|
|
123265
123540
|
});
|
|
@@ -123367,6 +123642,14 @@ const MAX_DELAY_SECONDS = Number(
|
|
|
123367
123642
|
process.env.VERCEL_QUEUE_MAX_DELAY_SECONDS || 82800
|
|
123368
123643
|
// 23 hours - leave 1h buffer before 24h retention limit
|
|
123369
123644
|
);
|
|
123645
|
+
const HANDLER_ERROR_RETRY_AFTER_SECONDS = 1;
|
|
123646
|
+
const HANDLER_ERROR_MAX_RETRY_AFTER_SECONDS = 60;
|
|
123647
|
+
const HANDLER_ERROR_RETRY_JITTER_RATIO = 0.25;
|
|
123648
|
+
function getHandlerErrorRetryAfterSeconds(deliveryCount) {
|
|
123649
|
+
const backoffSeconds = Math.min(Math.max(HANDLER_ERROR_RETRY_AFTER_SECONDS, 2 ** (deliveryCount - 1)), HANDLER_ERROR_MAX_RETRY_AFTER_SECONDS);
|
|
123650
|
+
const jitterSeconds = Math.floor(Math.random() * (Math.ceil(backoffSeconds * HANDLER_ERROR_RETRY_JITTER_RATIO) + 1));
|
|
123651
|
+
return Math.max(HANDLER_ERROR_RETRY_AFTER_SECONDS, backoffSeconds - jitterSeconds);
|
|
123652
|
+
}
|
|
123370
123653
|
function getHeadersFromPayload(payload) {
|
|
123371
123654
|
const headers2 = {};
|
|
123372
123655
|
if ("runId" in payload && typeof payload.runId === "string") {
|
|
@@ -123459,6 +123742,16 @@ function createQueue$1(config2) {
|
|
|
123459
123742
|
const delaySeconds = result.timeoutSeconds > 0 ? Math.min(result.timeoutSeconds, MAX_DELAY_SECONDS) : void 0;
|
|
123460
123743
|
await queue(queueName, payload, { deploymentId, delaySeconds });
|
|
123461
123744
|
}
|
|
123745
|
+
}, {
|
|
123746
|
+
// Without an explicit retry directive, @vercel/queue leaves failed
|
|
123747
|
+
// handler messages invisible until the default 300s visibility timeout
|
|
123748
|
+
// expires. Start retrying quickly, then back off by delivery count
|
|
123749
|
+
// with jitter so an outage or poison message cannot hot-loop or
|
|
123750
|
+
// redrive in lockstep. Workflow handlers are event-sourced and must
|
|
123751
|
+
// remain idempotent because queue retries can happen close together.
|
|
123752
|
+
retry: (_error, { deliveryCount }) => ({
|
|
123753
|
+
afterSeconds: getHandlerErrorRetryAfterSeconds(deliveryCount)
|
|
123754
|
+
})
|
|
123462
123755
|
});
|
|
123463
123756
|
return async (req) => {
|
|
123464
123757
|
const rawId = req.headers.get("x-vercel-id");
|
|
@@ -123797,14 +124090,18 @@ const EventResultResolveWireSchema = z$2.object({
|
|
|
123797
124090
|
run: WorkflowRunSchema.optional(),
|
|
123798
124091
|
step: StepWireSchema.optional(),
|
|
123799
124092
|
hook: HookSchema.optional(),
|
|
123800
|
-
events: z$2.array(EventSchema).optional()
|
|
124093
|
+
events: z$2.array(EventSchema).optional(),
|
|
124094
|
+
cursor: z$2.string().nullable().optional(),
|
|
124095
|
+
hasMore: z$2.boolean().optional()
|
|
123801
124096
|
});
|
|
123802
124097
|
const EventResultLazyWireSchema = z$2.object({
|
|
123803
124098
|
event: EventSchema.optional(),
|
|
123804
124099
|
run: WorkflowRunWireBaseSchema.optional(),
|
|
123805
124100
|
step: StepWireSchema.optional(),
|
|
123806
124101
|
hook: HookSchema.optional(),
|
|
123807
|
-
events: z$2.array(EventSchema).optional()
|
|
124102
|
+
events: z$2.array(EventSchema).optional(),
|
|
124103
|
+
cursor: z$2.string().nullable().optional(),
|
|
124104
|
+
hasMore: z$2.boolean().optional()
|
|
123808
124105
|
});
|
|
123809
124106
|
const EventWithRefsSchema = z$2.object({
|
|
123810
124107
|
eventId: z$2.string(),
|
|
@@ -124047,7 +124344,9 @@ async function createWorkflowRunEventInner(id2, data, params, config2) {
|
|
|
124047
124344
|
run: wireResult2.run,
|
|
124048
124345
|
step: wireResult2.step ? deserializeStep(wireResult2.step) : void 0,
|
|
124049
124346
|
hook: wireResult2.hook,
|
|
124050
|
-
events: wireResult2.events
|
|
124347
|
+
events: wireResult2.events,
|
|
124348
|
+
cursor: wireResult2.cursor,
|
|
124349
|
+
hasMore: wireResult2.hasMore
|
|
124051
124350
|
};
|
|
124052
124351
|
}
|
|
124053
124352
|
const wireResult = await makeRequest({
|
|
@@ -124066,7 +124365,9 @@ async function createWorkflowRunEventInner(id2, data, params, config2) {
|
|
|
124066
124365
|
run: wireResult.run ? deserializeError(wireResult.run) : void 0,
|
|
124067
124366
|
step: wireResult.step ? deserializeStep(wireResult.step) : void 0,
|
|
124068
124367
|
hook: wireResult.hook,
|
|
124069
|
-
events: wireResult.events
|
|
124368
|
+
events: wireResult.events,
|
|
124369
|
+
cursor: wireResult.cursor,
|
|
124370
|
+
hasMore: wireResult.hasMore
|
|
124070
124371
|
};
|
|
124071
124372
|
}
|
|
124072
124373
|
function filterHookData(hook, resolveData) {
|
|
@@ -124311,6 +124612,12 @@ function createVercelWorld(config2) {
|
|
|
124311
124612
|
const projectId = ((_a3 = config2 == null ? void 0 : config2.projectConfig) == null ? void 0 : _a3.projectId) || process.env.VERCEL_PROJECT_ID;
|
|
124312
124613
|
return {
|
|
124313
124614
|
specVersion: SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT,
|
|
124615
|
+
// On Vercel the platform fails the function invocation when the
|
|
124616
|
+
// process exits non-zero, and VQS redelivers the queue message via a
|
|
124617
|
+
// fresh invocation. The core runtime uses this to decide whether
|
|
124618
|
+
// `process.exit(1)` is an acceptable response to an exhausted replay
|
|
124619
|
+
// budget.
|
|
124620
|
+
processExitTriggersQueueRedelivery: true,
|
|
124314
124621
|
...createQueue$1(config2),
|
|
124315
124622
|
...createStorage(config2),
|
|
124316
124623
|
...instrumentObject("world.streams", createStreamer(config2)),
|
|
@@ -127102,6 +127409,7 @@ async function resumeHook$2(tokenOrHook, payload, encryptionKeyOverride) {
|
|
|
127102
127409
|
specVersion: SPEC_VERSION_CURRENT,
|
|
127103
127410
|
correlationId: hook.hookId,
|
|
127104
127411
|
eventData: {
|
|
127412
|
+
...v1Compat ? {} : { token: hook.token },
|
|
127105
127413
|
payload: dehydratedPayload
|
|
127106
127414
|
}
|
|
127107
127415
|
}, { v1Compat });
|
|
@@ -127377,7 +127685,10 @@ async function wakeUpRun$2(world, runId, options) {
|
|
|
127377
127685
|
} : {
|
|
127378
127686
|
eventType: "wait_completed",
|
|
127379
127687
|
correlationId: waitEvent.correlationId,
|
|
127380
|
-
specVersion: run.specVersion
|
|
127688
|
+
specVersion: run.specVersion,
|
|
127689
|
+
eventData: {
|
|
127690
|
+
resumeAt: waitEvent.eventData.resumeAt
|
|
127691
|
+
}
|
|
127381
127692
|
};
|
|
127382
127693
|
try {
|
|
127383
127694
|
await world.events.create(runId, eventData, { v1Compat: compatMode });
|
|
@@ -150877,7 +151188,7 @@ const route4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
|
|
|
150877
151188
|
__proto__: null,
|
|
150878
151189
|
loader
|
|
150879
151190
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
150880
|
-
const serverManifest = { "entry": { "module": "/assets/entry.client-DtOpLtMQ.js", "imports": ["/assets/index-BsV8i_Jn.js"], "css": [] }, "routes": { "root": { "id": "root", "parentId": void 0, "path": "", "index": void 0, "caseSensitive": void 0, "hasAction": true, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": true, "module": "/assets/root-
|
|
151191
|
+
const serverManifest = { "entry": { "module": "/assets/entry.client-DtOpLtMQ.js", "imports": ["/assets/index-BsV8i_Jn.js"], "css": [] }, "routes": { "root": { "id": "root", "parentId": void 0, "path": "", "index": void 0, "caseSensitive": void 0, "hasAction": true, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": true, "module": "/assets/root-DDT0W3fG.js", "imports": ["/assets/index-BsV8i_Jn.js", "/assets/mermaid-3ZIDBTTL-PK-k2mDG.js"], "css": ["/assets/root-B527kgKt.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-B-DWbULo.js", "imports": ["/assets/index-BsV8i_Jn.js", "/assets/workflow-graph-viewer-CVUKAMV1.js", "/assets/mermaid-3ZIDBTTL-PK-k2mDG.js", "/assets/index-Byi8AWfe.js"], "css": ["/assets/workflow-graph-viewer-DnlNuQQH.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-COyTZwjr.js", "imports": ["/assets/index-BsV8i_Jn.js", "/assets/workflow-graph-viewer-CVUKAMV1.js", "/assets/mermaid-3ZIDBTTL-PK-k2mDG.js", "/assets/encryption-C69WMRfh.js", "/assets/index-Byi8AWfe.js"], "css": ["/assets/workflow-graph-viewer-DnlNuQQH.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-21016363.js", "version": "21016363", "sri": void 0 };
|
|
150881
151192
|
const assetsBuildDirectory = "build/client";
|
|
150882
151193
|
const basename = "/";
|
|
150883
151194
|
const future = { "unstable_optimizeDeps": false, "unstable_subResourceIntegrity": false, "unstable_trailingSlashAwareDataRequests": false, "unstable_previewServerPrerendering": false, "v8_middleware": false, "v8_splitRouteModules": false, "v8_viteEnvironmentApi": false };
|