@workflow/web 5.0.0-beta.40 → 5.0.0-beta.41
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/{arrow-up-right-Br49goey.js → arrow-up-right-jWH-UQH9.js} +1 -1
- package/build/client/assets/{highlighted-body-B3W2YXNL-B5pbFkUr.js → highlighted-body-B3W2YXNL-DmmWu7VM.js} +1 -1
- package/build/client/assets/{home-DrXIdsG5.js → home-BwYHJJJr.js} +3 -3
- package/build/client/assets/{loader-circle-3PJSFf84.js → loader-circle-fFQM94Ej.js} +1 -1
- package/build/client/assets/{manifest-0c933230.js → manifest-f6a9dca2.js} +1 -1
- package/build/client/assets/{mermaid-3ZIDBTTL-qqUSEahK.js → mermaid-3ZIDBTTL-DchhEfRL.js} +14 -4
- package/build/client/assets/{root-n7Zz0dTX.js → root-D6p4Hb4F.js} +3 -3
- package/build/client/assets/{run-detail-DHeMEsdg.js → run-detail-vPCbZIXx.js} +3 -3
- package/build/client/assets/{workflow-graph-viewer-DWdsfF3d.js → workflow-graph-viewer-t_fSwuwz.js} +1 -1
- package/build/client/assets/{zstd-browser-decoder-DemK2pIP.js → zstd-browser-decoder-BTw1glGN.js} +1 -1
- package/build/server/assets/{app-BJXoDV4n.js → app-D8GiFFR6.js} +1215 -639
- package/build/server/assets/{highlighted-body-B3W2YXNL-Kki0lKyo.js → highlighted-body-B3W2YXNL-BZVc2guG.js} +2 -1
- package/build/server/assets/index-BByEr1g6.js +154 -0
- package/build/server/assets/{index-7-uV1dU1.js → index-DTci39F3.js} +1 -1
- package/build/server/assets/{mermaid-3ZIDBTTL-Bh_zbSQ-.js → mermaid-3ZIDBTTL-DOefrphg.js} +2 -1
- package/build/server/assets/{token-D8pb4TJ8.js → token-c3byIJRC.js} +1 -1
- package/build/server/assets/{token-util-DPJj3x0B.js → token-util-C2yENsqE.js} +1 -1
- package/build/server/assets/{wrapper-CsxTXsPR.js → websocket-server-DagS_hnJ.js} +14 -53
- package/build/server/assets/wrapper-Cnumc4u1.js +67 -0
- package/build/server/assets/ws-transport-2gJL6hC2.js +493 -0
- package/build/server/assets/{zstd-browser-decoder-CWJVPmcb.js → zstd-browser-decoder-BCVvr1WT.js} +2 -1
- package/build/server/index.js +4 -3
- package/package.json +6 -6
- package/build/server/assets/index-XksKPyou.js +0 -143
|
@@ -61,6 +61,7 @@ import require$$0$9 from "constants";
|
|
|
61
61
|
import require$$5$2 from "assert";
|
|
62
62
|
import require$$2$4 from "os";
|
|
63
63
|
import * as net from "net";
|
|
64
|
+
import assert$1 from "node:assert/strict";
|
|
64
65
|
import express from "express";
|
|
65
66
|
function _mergeNamespaces(n, m2) {
|
|
66
67
|
for (var i = 0; i < m2.length; i++) {
|
|
@@ -57804,6 +57805,11 @@ function envNumber(name2, fallback, options = {}) {
|
|
|
57804
57805
|
}
|
|
57805
57806
|
return parsed;
|
|
57806
57807
|
}
|
|
57808
|
+
const DEFAULT_MAX_EVENTS_PER_RUN = 25e3;
|
|
57809
|
+
function getMaxEventsPerRun() {
|
|
57810
|
+
const maxEvents = envNumber("WORKFLOW_MAX_EVENTS", DEFAULT_MAX_EVENTS_PER_RUN, { integer: true });
|
|
57811
|
+
return maxEvents > 0 ? maxEvents : DEFAULT_MAX_EVENTS_PER_RUN;
|
|
57812
|
+
}
|
|
57807
57813
|
const QueuePrefix = string$3().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_workflow_$/, "Must match __wkf_workflow_ or __{namespace}_wkf_workflow_");
|
|
57808
57814
|
const ValidQueueName = string$3().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_workflow_.+$/, "Must be a valid queue name with a recognized prefix");
|
|
57809
57815
|
const QueueNamespace = string$3().regex(/^[a-z][a-z0-9]*$/, "Must be lowercase alphanumeric, starting with a letter");
|
|
@@ -57885,7 +57891,17 @@ const HookResumeInputSchema = object$1({
|
|
|
57885
57891
|
* `(runId, resumeId)` constraint — required because the v4 payload ref is not
|
|
57886
57892
|
* content-stable server-side.
|
|
57887
57893
|
*/
|
|
57888
|
-
payloadDigest: string$3()
|
|
57894
|
+
payloadDigest: string$3(),
|
|
57895
|
+
/**
|
|
57896
|
+
* The deployment the run is pinned to, from the producer's resume context.
|
|
57897
|
+
* Lets the consumer detect a misrouted delivery with a cheap ambient
|
|
57898
|
+
* deployment-id comparison BEFORE its hoisted `hook_received` replay-preload
|
|
57899
|
+
* write — only a detected mismatch pays for the authoritative run fetch and
|
|
57900
|
+
* the deployment-affinity guard. Optional for queued-message compatibility:
|
|
57901
|
+
* messages from older producers omit it and simply skip the pre-write
|
|
57902
|
+
* check (the authoritative guard before replay still protects them).
|
|
57903
|
+
*/
|
|
57904
|
+
deploymentId: string$3().optional()
|
|
57889
57905
|
});
|
|
57890
57906
|
const WorkflowInvokePayloadSchema = object$1({
|
|
57891
57907
|
runId: string$3(),
|
|
@@ -58060,18 +58076,58 @@ const StructuredErrorSchema = object$1({
|
|
|
58060
58076
|
code: string$3().optional()
|
|
58061
58077
|
// Populated with RunErrorCode values (USER_ERROR, RUNTIME_ERROR, etc.) for run_failed events
|
|
58062
58078
|
});
|
|
58079
|
+
const EVENT_ID_BODY_LENGTH = 26;
|
|
58080
|
+
const SLOT_LEADING_ZEROS = 10;
|
|
58081
|
+
const FIRST_EVENT_SLOT = 1;
|
|
58082
|
+
const EVENT_ID_PREFIX = "evnt_";
|
|
58083
|
+
function isSlotBody(body2) {
|
|
58084
|
+
if (body2.length !== EVENT_ID_BODY_LENGTH)
|
|
58085
|
+
return false;
|
|
58086
|
+
for (let i = 0; i < SLOT_LEADING_ZEROS; i++) {
|
|
58087
|
+
if (body2[i] !== "0")
|
|
58088
|
+
return false;
|
|
58089
|
+
}
|
|
58090
|
+
for (let i = SLOT_LEADING_ZEROS; i < EVENT_ID_BODY_LENGTH; i++) {
|
|
58091
|
+
const code2 = body2.charCodeAt(i);
|
|
58092
|
+
if (code2 < 48 || code2 > 57)
|
|
58093
|
+
return false;
|
|
58094
|
+
}
|
|
58095
|
+
return true;
|
|
58096
|
+
}
|
|
58097
|
+
function stripEventIdPrefix(eventId) {
|
|
58098
|
+
const underscore = eventId.indexOf("_");
|
|
58099
|
+
return underscore === -1 ? eventId : eventId.slice(underscore + 1);
|
|
58100
|
+
}
|
|
58101
|
+
function isSlotEventId(eventId) {
|
|
58102
|
+
return isSlotBody(stripEventIdPrefix(eventId));
|
|
58103
|
+
}
|
|
58104
|
+
function slotToEventId(slot) {
|
|
58105
|
+
if (!Number.isSafeInteger(slot) || slot < FIRST_EVENT_SLOT) {
|
|
58106
|
+
throw new RangeError(`Invalid event slot: ${slot}`);
|
|
58107
|
+
}
|
|
58108
|
+
return `${EVENT_ID_PREFIX}${String(slot).padStart(EVENT_ID_BODY_LENGTH, "0")}`;
|
|
58109
|
+
}
|
|
58110
|
+
function eventIdToSlot(eventId) {
|
|
58111
|
+
const body2 = stripEventIdPrefix(eventId);
|
|
58112
|
+
if (!isSlotBody(body2))
|
|
58113
|
+
return null;
|
|
58114
|
+
const slot = Number(body2);
|
|
58115
|
+
return Number.isSafeInteger(slot) && slot >= FIRST_EVENT_SLOT ? slot : null;
|
|
58116
|
+
}
|
|
58063
58117
|
const SPEC_VERSION_LEGACY = 1;
|
|
58064
58118
|
const SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT = 3;
|
|
58065
58119
|
const SPEC_VERSION_SUPPORTS_ATTRIBUTES = 4;
|
|
58066
58120
|
const SPEC_VERSION_SUPPORTS_COMPRESSION = 5;
|
|
58121
|
+
const SPEC_VERSION_SUPPORTS_SLOT_IDENTITY = 6;
|
|
58067
58122
|
const SPEC_VERSION_CURRENT = SPEC_VERSION_SUPPORTS_COMPRESSION;
|
|
58123
|
+
const SPEC_VERSION_MAX_SUPPORTED = SPEC_VERSION_SUPPORTS_SLOT_IDENTITY;
|
|
58068
58124
|
function isLegacySpecVersion(v2) {
|
|
58069
58125
|
return v2 === void 0 || v2 === null || v2 <= SPEC_VERSION_LEGACY;
|
|
58070
58126
|
}
|
|
58071
58127
|
function requiresNewerWorld(v2) {
|
|
58072
58128
|
if (v2 === void 0 || v2 === null)
|
|
58073
58129
|
return false;
|
|
58074
|
-
return v2 >
|
|
58130
|
+
return v2 > SPEC_VERSION_MAX_SUPPORTED;
|
|
58075
58131
|
}
|
|
58076
58132
|
const ENCODING$1 = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
58077
58133
|
const ENCODING_LEN = 32;
|
|
@@ -58227,6 +58283,9 @@ const workflowRunIdSchema = templateLiteral(["wrun_", ulid$4()]);
|
|
|
58227
58283
|
const DEFAULT_TIMESTAMP_THRESHOLD_PAST_MS = 24 * 60 * 60 * 1e3;
|
|
58228
58284
|
const DEFAULT_TIMESTAMP_THRESHOLD_FUTURE_MS = 5 * 60 * 1e3;
|
|
58229
58285
|
function ulidToDate(maybeUlid) {
|
|
58286
|
+
if (isSlotBody(maybeUlid)) {
|
|
58287
|
+
return null;
|
|
58288
|
+
}
|
|
58230
58289
|
const ulid2 = UlidSchema.safeParse(maybeUlid);
|
|
58231
58290
|
if (!ulid2.success) {
|
|
58232
58291
|
return null;
|
|
@@ -60678,7 +60737,7 @@ function replaceEncryptedAndExpiredWithMarkers(resource) {
|
|
|
60678
60737
|
}
|
|
60679
60738
|
async function hydrateResourceIOAsync(resource, key) {
|
|
60680
60739
|
const { hydrateDataWithKey: hydrateDataWithKey2, deriveRunPayloadKeys: deriveRunPayloadKeys2 } = await Promise.resolve().then(() => serializationFormat);
|
|
60681
|
-
const { ensureZstdDecoderRegistered } = await import("./zstd-browser-decoder-
|
|
60740
|
+
const { ensureZstdDecoderRegistered } = await import("./zstd-browser-decoder-BCVvr1WT.js");
|
|
60682
60741
|
ensureZstdDecoderRegistered();
|
|
60683
60742
|
const cryptoKey = key ? await deriveRunPayloadKeys2(key) : void 0;
|
|
60684
60743
|
const revivers = getRevivers();
|
|
@@ -91623,7 +91682,7 @@ var tn = f("block", "before:content-[counter(line)]", "before:inline-block", "be
|
|
|
91623
91682
|
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 });
|
|
91624
91683
|
var Se = reactExports.createContext({ code: "" }), de = () => reactExports.useContext(Se);
|
|
91625
91684
|
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 }) });
|
|
91626
|
-
var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-
|
|
91685
|
+
var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-BZVc2guG.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
|
|
91627
91686
|
let i = reactExports.useMemo(() => e.replace(cn$1, ""), [e]), c = reactExports.useMemo(() => ({ bg: "transparent", fg: "inherit", tokens: i.split(`
|
|
91628
91687
|
`).map((a2) => [{ content: a2, color: "inherit", bgColor: "transparent", htmlStyle: {}, offset: 0 }]) }), [i]);
|
|
91629
91688
|
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 }) })] }) });
|
|
@@ -91945,7 +92004,7 @@ var Dt = ({ children: e, className: t, onDownload: o, onError: n }) => {
|
|
|
91945
92004
|
}, []), 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] });
|
|
91946
92005
|
};
|
|
91947
92006
|
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 }) })] });
|
|
91948
|
-
var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-
|
|
92007
|
+
var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-DOefrphg.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
|
|
91949
92008
|
function ke(e, t) {
|
|
91950
92009
|
if (!(e != null && e.position || t != null && t.position)) return true;
|
|
91951
92010
|
if (!(e != null && e.position && (t != null && t.position))) return false;
|
|
@@ -101072,11 +101131,12 @@ async function flushablePipePerChunk(source, sink, state) {
|
|
|
101072
101131
|
}
|
|
101073
101132
|
}
|
|
101074
101133
|
function assertWorldSupportsRuntimeProtocol(world) {
|
|
101075
|
-
|
|
101134
|
+
const declared = world.specVersion;
|
|
101135
|
+
if (declared !== void 0 && declared !== null && declared >= SPEC_VERSION_CURRENT && declared <= SPEC_VERSION_MAX_SUPPORTED) {
|
|
101076
101136
|
return;
|
|
101077
101137
|
}
|
|
101078
|
-
const supportedVersion =
|
|
101079
|
-
throw new WorkflowRuntimeError(`This Workflow runtime
|
|
101138
|
+
const supportedVersion = declared ?? "none";
|
|
101139
|
+
throw new WorkflowRuntimeError(`This Workflow runtime supports Worlds with spec version ${SPEC_VERSION_CURRENT} through ${SPEC_VERSION_MAX_SUPPORTED}, but the configured World declares spec version ${supportedVersion}. Install a World package version compatible with the current Workflow runtime.`);
|
|
101080
101140
|
}
|
|
101081
101141
|
const WorldCacheKey = Symbol.for("@workflow/world//cache");
|
|
101082
101142
|
const WorldCachePromiseKey = Symbol.for("@workflow/world//cachePromise");
|
|
@@ -104016,7 +104076,7 @@ function getStreamAndRequestRevivers(allRevivers) {
|
|
|
104016
104076
|
return extra;
|
|
104017
104077
|
}
|
|
104018
104078
|
`cinst_${ulid$3()}`;
|
|
104019
|
-
const version$1 = "5.0.0-beta.
|
|
104079
|
+
const version$1 = "5.0.0-beta.41";
|
|
104020
104080
|
const DEFAULT_HEALTH_CHECK_TIMEOUT = 3e4;
|
|
104021
104081
|
const SAFE_WORKFLOW_NAME_PATTERN = /^[a-zA-Z0-9_\-./@]+$/;
|
|
104022
104082
|
function getWorkflowQueueName(workflowName, namespace2) {
|
|
@@ -104729,20 +104789,32 @@ async function listFilesByExtension(dirPath, extension2) {
|
|
|
104729
104789
|
throw error2;
|
|
104730
104790
|
}
|
|
104731
104791
|
}
|
|
104792
|
+
const SORT_KEY_CURSOR_PREFIX = "key:";
|
|
104732
104793
|
function parseCursor(cursor) {
|
|
104733
104794
|
if (!cursor)
|
|
104734
104795
|
return null;
|
|
104796
|
+
if (cursor.startsWith(SORT_KEY_CURSOR_PREFIX)) {
|
|
104797
|
+
return {
|
|
104798
|
+
timestamp: /* @__PURE__ */ new Date(0),
|
|
104799
|
+
id: null,
|
|
104800
|
+
sortKey: cursor.slice(SORT_KEY_CURSOR_PREFIX.length)
|
|
104801
|
+
};
|
|
104802
|
+
}
|
|
104735
104803
|
const parts = cursor.split("|");
|
|
104736
104804
|
return {
|
|
104737
104805
|
timestamp: new Date(parts[0]),
|
|
104738
|
-
id: parts[1] || null
|
|
104806
|
+
id: parts[1] || null,
|
|
104807
|
+
sortKey: null
|
|
104739
104808
|
};
|
|
104740
104809
|
}
|
|
104741
|
-
function createCursor(timestamp, id2) {
|
|
104810
|
+
function createCursor(timestamp, id2, sortKey) {
|
|
104811
|
+
if (sortKey) {
|
|
104812
|
+
return `${SORT_KEY_CURSOR_PREFIX}${sortKey}`;
|
|
104813
|
+
}
|
|
104742
104814
|
return id2 ? `${timestamp.toISOString()}|${id2}` : timestamp.toISOString();
|
|
104743
104815
|
}
|
|
104744
104816
|
async function paginatedFileSystemQuery(config2) {
|
|
104745
|
-
const { directory, schema, cachedItems, filePrefix, fileIdFilter, filter: filter2, sortOrder = "desc", limit = 20, cursor, getCreatedAt, getId } = config2;
|
|
104817
|
+
const { directory, schema, cachedItems, filePrefix, fileIdFilter, filter: filter2, sortOrder = "desc", limit = 20, cursor, getCreatedAt, getId, getSortKey, getSortKeyFromFileId } = config2;
|
|
104746
104818
|
if (filePrefix !== void 0) {
|
|
104747
104819
|
assertSafeEntityId("filePrefix", filePrefix);
|
|
104748
104820
|
}
|
|
@@ -104752,7 +104824,17 @@ async function paginatedFileSystemQuery(config2) {
|
|
|
104752
104824
|
const filteredFileIds = fileIdFilter ? relevantFileIds.filter(fileIdFilter) : relevantFileIds;
|
|
104753
104825
|
const parsedCursor = parseCursor(cursor);
|
|
104754
104826
|
let candidateFileIds = filteredFileIds;
|
|
104755
|
-
if (parsedCursor) {
|
|
104827
|
+
if ((parsedCursor == null ? void 0 : parsedCursor.sortKey) && getSortKeyFromFileId) {
|
|
104828
|
+
const cursorSortKey = parsedCursor.sortKey;
|
|
104829
|
+
candidateFileIds = filteredFileIds.filter((fileId) => {
|
|
104830
|
+
const key = getSortKeyFromFileId(fileId);
|
|
104831
|
+
if (key === null) {
|
|
104832
|
+
return true;
|
|
104833
|
+
}
|
|
104834
|
+
const comparison = key.localeCompare(cursorSortKey);
|
|
104835
|
+
return sortOrder === "desc" ? comparison < 0 : comparison > 0;
|
|
104836
|
+
});
|
|
104837
|
+
} else if (parsedCursor && !parsedCursor.sortKey) {
|
|
104756
104838
|
candidateFileIds = filteredFileIds.filter((fileId) => {
|
|
104757
104839
|
const filenameDate = getCreatedAt(`${fileId}.json`);
|
|
104758
104840
|
if (filenameDate) {
|
|
@@ -104789,6 +104871,17 @@ async function paginatedFileSystemQuery(config2) {
|
|
|
104789
104871
|
for (const item of loadedBatch) {
|
|
104790
104872
|
if (!item)
|
|
104791
104873
|
continue;
|
|
104874
|
+
const itemSortKey = (getSortKey == null ? void 0 : getSortKey(item)) ?? null;
|
|
104875
|
+
if (parsedCursor == null ? void 0 : parsedCursor.sortKey) {
|
|
104876
|
+
if (itemSortKey) {
|
|
104877
|
+
const comparison = itemSortKey.localeCompare(parsedCursor.sortKey);
|
|
104878
|
+
if (sortOrder === "desc" ? comparison >= 0 : comparison <= 0) {
|
|
104879
|
+
continue;
|
|
104880
|
+
}
|
|
104881
|
+
}
|
|
104882
|
+
validItems.push(item);
|
|
104883
|
+
continue;
|
|
104884
|
+
}
|
|
104792
104885
|
if (parsedCursor) {
|
|
104793
104886
|
const itemTime = item.createdAt.getTime();
|
|
104794
104887
|
const cursorTime = parsedCursor.timestamp.getTime();
|
|
@@ -104814,6 +104907,13 @@ async function paginatedFileSystemQuery(config2) {
|
|
|
104814
104907
|
}
|
|
104815
104908
|
}
|
|
104816
104909
|
validItems.sort((a2, b2) => {
|
|
104910
|
+
if (getSortKey) {
|
|
104911
|
+
const aKey = getSortKey(a2);
|
|
104912
|
+
const bKey = getSortKey(b2);
|
|
104913
|
+
if (aKey !== null && bKey !== null) {
|
|
104914
|
+
return sortOrder === "asc" ? aKey.localeCompare(bKey) : bKey.localeCompare(aKey);
|
|
104915
|
+
}
|
|
104916
|
+
}
|
|
104817
104917
|
const aTime = a2.createdAt.getTime();
|
|
104818
104918
|
const bTime = b2.createdAt.getTime();
|
|
104819
104919
|
const timeComparison = sortOrder === "asc" ? aTime - bTime : bTime - aTime;
|
|
@@ -104826,7 +104926,7 @@ async function paginatedFileSystemQuery(config2) {
|
|
|
104826
104926
|
});
|
|
104827
104927
|
const hasMore = validItems.length > limit;
|
|
104828
104928
|
const items = hasMore ? validItems.slice(0, limit) : validItems;
|
|
104829
|
-
const nextCursor = items.length > 0 ? createCursor(items[items.length - 1].createdAt, getId == null ? void 0 : getId(items[items.length - 1])) : null;
|
|
104929
|
+
const nextCursor = items.length > 0 ? createCursor(items[items.length - 1].createdAt, getId == null ? void 0 : getId(items[items.length - 1]), getSortKey == null ? void 0 : getSortKey(items[items.length - 1])) : null;
|
|
104830
104930
|
return {
|
|
104831
104931
|
data: items,
|
|
104832
104932
|
cursor: nextCursor,
|
|
@@ -133165,6 +133265,20 @@ async function reapPendingHookEvents(basedir, runId, tag) {
|
|
|
133165
133265
|
}
|
|
133166
133266
|
}
|
|
133167
133267
|
async function mintRunDominantEventKey(basedir, runId, tag) {
|
|
133268
|
+
const scan = await scanRunEventIds(basedir, runId, tag);
|
|
133269
|
+
let ts = Date.now();
|
|
133270
|
+
if (scan.maxId) {
|
|
133271
|
+
try {
|
|
133272
|
+
const maxTs = decodeTime(scan.maxId.replace(/^evnt_/, ""));
|
|
133273
|
+
if (ts <= maxTs) {
|
|
133274
|
+
ts = maxTs + 1;
|
|
133275
|
+
}
|
|
133276
|
+
} catch {
|
|
133277
|
+
}
|
|
133278
|
+
}
|
|
133279
|
+
return { eventId: `evnt_${monotonicUlid$1(ts)}`, createdAt: new Date(ts) };
|
|
133280
|
+
}
|
|
133281
|
+
async function scanRunEventIds(basedir, runId, tag) {
|
|
133168
133282
|
let files = [];
|
|
133169
133283
|
try {
|
|
133170
133284
|
files = await fs$1.readdir(path$3.join(basedir, "events"));
|
|
@@ -133174,7 +133288,11 @@ async function mintRunDominantEventKey(basedir, runId, tag) {
|
|
|
133174
133288
|
}
|
|
133175
133289
|
}
|
|
133176
133290
|
const prefix = `${runId}-`;
|
|
133177
|
-
|
|
133291
|
+
const ids = [];
|
|
133292
|
+
let maxId = null;
|
|
133293
|
+
let maxSlot = 0;
|
|
133294
|
+
let usesSlots = false;
|
|
133295
|
+
let count2 = 0;
|
|
133178
133296
|
for (const file2 of files) {
|
|
133179
133297
|
if (!file2.startsWith(prefix) || !file2.endsWith(".json")) {
|
|
133180
133298
|
continue;
|
|
@@ -133184,21 +133302,19 @@ async function mintRunDominantEventKey(basedir, runId, tag) {
|
|
|
133184
133302
|
continue;
|
|
133185
133303
|
}
|
|
133186
133304
|
const candidate = stripTag(fileId).slice(prefix.length);
|
|
133187
|
-
|
|
133188
|
-
|
|
133305
|
+
count2 += 1;
|
|
133306
|
+
ids.push(candidate);
|
|
133307
|
+
if (!maxId || candidate > maxId) {
|
|
133308
|
+
maxId = candidate;
|
|
133189
133309
|
}
|
|
133190
|
-
|
|
133191
|
-
|
|
133192
|
-
|
|
133193
|
-
|
|
133194
|
-
|
|
133195
|
-
if (ts <= maxTs) {
|
|
133196
|
-
ts = maxTs + 1;
|
|
133197
|
-
}
|
|
133198
|
-
} catch {
|
|
133310
|
+
const slot = eventIdToSlot(candidate);
|
|
133311
|
+
if (slot !== null) {
|
|
133312
|
+
usesSlots = true;
|
|
133313
|
+
if (slot > maxSlot)
|
|
133314
|
+
maxSlot = slot;
|
|
133199
133315
|
}
|
|
133200
133316
|
}
|
|
133201
|
-
return {
|
|
133317
|
+
return { maxId, usesSlots, maxSlot, count: count2, ids };
|
|
133202
133318
|
}
|
|
133203
133319
|
function hookTokenClaimPath(basedir, token) {
|
|
133204
133320
|
return path$3.join(basedir, "hooks", "tokens", `${hashToken(token)}.json`);
|
|
@@ -133901,12 +134017,6 @@ function createRunsStorage(basedir, tag) {
|
|
|
133901
134017
|
}
|
|
133902
134018
|
};
|
|
133903
134019
|
}
|
|
133904
|
-
const DEFAULT_MAX_EVENTS_PER_RUN = 25e3;
|
|
133905
|
-
function getMaxEventsPerRun() {
|
|
133906
|
-
const raw2 = process.env.WORKFLOW_MAX_EVENTS;
|
|
133907
|
-
const parsed = raw2 !== void 0 ? Number(raw2) : Number.NaN;
|
|
133908
|
-
return Number.isInteger(parsed) && parsed > 0 ? parsed : DEFAULT_MAX_EVENTS_PER_RUN;
|
|
133909
|
-
}
|
|
133910
134020
|
const DAY_MS$1 = 24 * 60 * 60 * 1e3;
|
|
133911
134021
|
function getHookRetentionLimitMs() {
|
|
133912
134022
|
const days = Number(process.env.WORKFLOW_LOCAL_HOOK_RETENTION_LIMIT_DAYS ?? 30);
|
|
@@ -133925,6 +134035,22 @@ const HookResumeClaimSchema = object$1({
|
|
|
133925
134035
|
eventId: string$3(),
|
|
133926
134036
|
payloadDigest: string$3().optional()
|
|
133927
134037
|
});
|
|
134038
|
+
function isResumeEvent(event, claim) {
|
|
134039
|
+
return event.eventType === "hook_received" && event.correlationId === claim.hookId && // `resumeId` is persisted on every hook_received written through the
|
|
134040
|
+
// resume path; an event without one predates that and can only be matched
|
|
134041
|
+
// by position.
|
|
134042
|
+
(event.resumeId === void 0 || event.resumeId === claim.resumeId);
|
|
134043
|
+
}
|
|
134044
|
+
async function findCommittedResumeEvent(basedir, runId, claim, tag) {
|
|
134045
|
+
const scan = await scanRunEventIds(basedir, runId, tag);
|
|
134046
|
+
for (const eventId of scan.ids) {
|
|
134047
|
+
const event = await readJSONWithFallback(basedir, "events", `${runId}-${eventId}`, EventSchema, tag);
|
|
134048
|
+
if (event && event.resumeId === claim.resumeId && isResumeEvent(event, claim)) {
|
|
134049
|
+
return event;
|
|
134050
|
+
}
|
|
134051
|
+
}
|
|
134052
|
+
return null;
|
|
134053
|
+
}
|
|
133928
134054
|
async function isHookTokenClaimReleasable(basedir, claim, tag) {
|
|
133929
134055
|
if (claim.hookId && await isHookDisposalCommitted(basedir, claim.hookId, tag)) {
|
|
133930
134056
|
return true;
|
|
@@ -133948,6 +134074,13 @@ async function readHookRecoveryMarker(markerPath) {
|
|
|
133948
134074
|
throw error2;
|
|
133949
134075
|
}
|
|
133950
134076
|
}
|
|
134077
|
+
function eventSortKey(event) {
|
|
134078
|
+
return isSlotEventId(event.eventId) ? event.eventId : null;
|
|
134079
|
+
}
|
|
134080
|
+
function eventSortKeyFromFileId(runId, fileId) {
|
|
134081
|
+
const eventId = stripTag(fileId).slice(runId.length + 1);
|
|
134082
|
+
return isSlotEventId(eventId) ? eventId : null;
|
|
134083
|
+
}
|
|
133951
134084
|
async function findExistingHookCreatedEventId(basedir, runId, correlationId) {
|
|
133952
134085
|
var _a3;
|
|
133953
134086
|
const result = await paginatedFileSystemQuery({
|
|
@@ -134060,6 +134193,71 @@ function createEventsStorage(basedir, tag) {
|
|
|
134060
134193
|
cachedEventBytes.clear();
|
|
134061
134194
|
cachedPathsByRunId.clear();
|
|
134062
134195
|
totalCachedEventBytes = 0;
|
|
134196
|
+
runSlotState.clear();
|
|
134197
|
+
}
|
|
134198
|
+
const runSlotState = /* @__PURE__ */ new Map();
|
|
134199
|
+
function slotStateKey(runId) {
|
|
134200
|
+
return tag ? `${runId}.${tag}` : runId;
|
|
134201
|
+
}
|
|
134202
|
+
async function slotOccupied(runId, slot) {
|
|
134203
|
+
const fileId = `${runId}-${slotToEventId(slot)}`;
|
|
134204
|
+
for (const candidate of tag ? [
|
|
134205
|
+
taggedPath(basedir, "events", fileId, tag),
|
|
134206
|
+
taggedPath(basedir, "events", fileId)
|
|
134207
|
+
] : [taggedPath(basedir, "events", fileId)]) {
|
|
134208
|
+
try {
|
|
134209
|
+
await fs$1.stat(candidate);
|
|
134210
|
+
return true;
|
|
134211
|
+
} catch (error2) {
|
|
134212
|
+
if (error2.code !== "ENOENT") {
|
|
134213
|
+
throw error2;
|
|
134214
|
+
}
|
|
134215
|
+
}
|
|
134216
|
+
}
|
|
134217
|
+
return false;
|
|
134218
|
+
}
|
|
134219
|
+
async function drawEventSlot(runId, opts) {
|
|
134220
|
+
const key = slotStateKey(runId);
|
|
134221
|
+
let state = runSlotState.get(key);
|
|
134222
|
+
if (state === void 0 || (opts == null ? void 0 : opts.rescan)) {
|
|
134223
|
+
const scan = await scanRunEventIds(basedir, runId, tag);
|
|
134224
|
+
if (state === void 0) {
|
|
134225
|
+
state = scan.count > 0 && !scan.usesSlots ? null : { published: scan.maxSlot };
|
|
134226
|
+
runSlotState.set(key, state);
|
|
134227
|
+
} else if (state !== null) {
|
|
134228
|
+
state.published = Math.max(state.published, scan.maxSlot);
|
|
134229
|
+
}
|
|
134230
|
+
}
|
|
134231
|
+
if (state === null) {
|
|
134232
|
+
return null;
|
|
134233
|
+
}
|
|
134234
|
+
let slot = Math.max(state.published + 1, FIRST_EVENT_SLOT, (opts == null ? void 0 : opts.atLeast) ?? FIRST_EVENT_SLOT);
|
|
134235
|
+
while (await slotOccupied(runId, slot)) {
|
|
134236
|
+
state.published = Math.max(state.published, slot);
|
|
134237
|
+
slot += 1;
|
|
134238
|
+
}
|
|
134239
|
+
return slot;
|
|
134240
|
+
}
|
|
134241
|
+
function notePublishedSlot(runId, eventId) {
|
|
134242
|
+
const slot = eventIdToSlot(eventId);
|
|
134243
|
+
if (slot === null) {
|
|
134244
|
+
return;
|
|
134245
|
+
}
|
|
134246
|
+
const state = runSlotState.get(slotStateKey(runId));
|
|
134247
|
+
if (state) {
|
|
134248
|
+
state.published = Math.max(state.published, slot);
|
|
134249
|
+
}
|
|
134250
|
+
}
|
|
134251
|
+
async function mintEventId(runId) {
|
|
134252
|
+
const slot = await drawEventSlot(runId);
|
|
134253
|
+
return slot === null ? `evnt_${monotonicUlid$1()}` : slotToEventId(slot);
|
|
134254
|
+
}
|
|
134255
|
+
async function mintDominantEventKey(runId) {
|
|
134256
|
+
const slot = await drawEventSlot(runId, { rescan: true });
|
|
134257
|
+
if (slot !== null) {
|
|
134258
|
+
return { eventId: slotToEventId(slot), createdAt: /* @__PURE__ */ new Date() };
|
|
134259
|
+
}
|
|
134260
|
+
return mintRunDominantEventKey(basedir, runId, tag);
|
|
134063
134261
|
}
|
|
134064
134262
|
function cacheEvent(eventPath, cachedEvent, serializedBytes) {
|
|
134065
134263
|
if (serializedBytes > maxCachedEventBytes) {
|
|
@@ -134091,14 +134289,45 @@ function createEventsStorage(basedir, tag) {
|
|
|
134091
134289
|
}
|
|
134092
134290
|
}
|
|
134093
134291
|
async function storeEvent(event) {
|
|
134094
|
-
|
|
134095
|
-
|
|
134096
|
-
|
|
134097
|
-
|
|
134292
|
+
let current = event;
|
|
134293
|
+
for (let attempt = 0; ; attempt++) {
|
|
134294
|
+
const eventPath = taggedPath(basedir, "events", `${current.runId}-${current.eventId}`, tag);
|
|
134295
|
+
const serializedEvent = JSON.stringify(current, jsonReplacer, 2);
|
|
134296
|
+
const slot = eventIdToSlot(current.eventId);
|
|
134297
|
+
if (slot === null) {
|
|
134298
|
+
await write(eventPath, serializedEvent);
|
|
134299
|
+
rememberStoredEvent(current, eventPath, serializedEvent);
|
|
134300
|
+
return current;
|
|
134301
|
+
}
|
|
134302
|
+
if (await writeExclusive(eventPath, serializedEvent)) {
|
|
134303
|
+
notePublishedSlot(current.runId, current.eventId);
|
|
134304
|
+
rememberStoredEvent(current, eventPath, serializedEvent);
|
|
134305
|
+
return current;
|
|
134306
|
+
}
|
|
134307
|
+
const next2 = await drawEventSlot(current.runId, {
|
|
134308
|
+
rescan: attempt > 0 && attempt % 8 === 0,
|
|
134309
|
+
atLeast: slot + 1
|
|
134310
|
+
});
|
|
134311
|
+
require$$0$4(next2 !== null);
|
|
134312
|
+
current = { ...current, eventId: slotToEventId(next2) };
|
|
134313
|
+
}
|
|
134098
134314
|
}
|
|
134315
|
+
const queryRunEvents = (runId, pagination) => paginatedFileSystemQuery({
|
|
134316
|
+
directory: path$3.join(basedir, "events"),
|
|
134317
|
+
schema: EventSchema,
|
|
134318
|
+
cachedItems: eventCache,
|
|
134319
|
+
filePrefix: `${runId}-`,
|
|
134320
|
+
sortOrder: pagination.sortOrder ?? "asc",
|
|
134321
|
+
limit: pagination.limit,
|
|
134322
|
+
cursor: pagination.cursor,
|
|
134323
|
+
getCreatedAt: getObjectCreatedAt("evnt"),
|
|
134324
|
+
getId: (event) => event.eventId,
|
|
134325
|
+
getSortKey: eventSortKey,
|
|
134326
|
+
getSortKeyFromFileId: (fileId) => eventSortKeyFromFileId(runId, fileId)
|
|
134327
|
+
});
|
|
134099
134328
|
const stepLocks = /* @__PURE__ */ new Map();
|
|
134100
134329
|
const hookLocks = /* @__PURE__ */ new Map();
|
|
134101
|
-
|
|
134330
|
+
const storage = {
|
|
134102
134331
|
clearCache,
|
|
134103
134332
|
async create(runId, data, params) {
|
|
134104
134333
|
if (data.eventType === "hook_created" && data.eventData.tokenRetentionUntil !== void 0 && data.eventData.tokenRetentionUntil.getTime() > Date.now() + hookRetentionLimitMs) {
|
|
@@ -134112,7 +134341,7 @@ function createEventsStorage(basedir, tag) {
|
|
|
134112
134341
|
}
|
|
134113
134342
|
if (isStepEventType(data.eventType) && runId && data.correlationId) {
|
|
134114
134343
|
const lockKey = tag ? `${runId}-${data.correlationId}.${tag}` : `${runId}-${data.correlationId}`;
|
|
134115
|
-
return withInProcessLock(stepLocks, lockKey,
|
|
134344
|
+
return withInProcessLock(stepLocks, lockKey, createImpl);
|
|
134116
134345
|
}
|
|
134117
134346
|
if (isHookLifecycleEventType(data.eventType) && runId && data.correlationId) {
|
|
134118
134347
|
const lockKey = tag ? `${runId}-${data.correlationId}.hook.${tag}` : `${runId}-${data.correlationId}.hook`;
|
|
@@ -134120,7 +134349,9 @@ function createEventsStorage(basedir, tag) {
|
|
|
134120
134349
|
}
|
|
134121
134350
|
return createImpl();
|
|
134122
134351
|
async function createImpl() {
|
|
134123
|
-
let eventId =
|
|
134352
|
+
let eventId = "";
|
|
134353
|
+
let eventIdPinned = false;
|
|
134354
|
+
let resumeClaimRecordedId = null;
|
|
134124
134355
|
const now2 = /* @__PURE__ */ new Date();
|
|
134125
134356
|
let effectiveRunId;
|
|
134126
134357
|
if (data.eventType === "run_created" && (!runId || runId === "")) {
|
|
@@ -134170,7 +134401,7 @@ function createEventsStorage(basedir, tag) {
|
|
|
134170
134401
|
const runPath = taggedPath(basedir, "runs", effectiveRunId, tag);
|
|
134171
134402
|
const created = await writeExclusive(runPath, JSON.stringify(createdRun, jsonReplacer));
|
|
134172
134403
|
if (created) {
|
|
134173
|
-
const runCreatedEventId =
|
|
134404
|
+
const runCreatedEventId = await mintEventId(effectiveRunId);
|
|
134174
134405
|
const runCreatedEvent = {
|
|
134175
134406
|
eventType: "run_created",
|
|
134176
134407
|
runId: effectiveRunId,
|
|
@@ -134195,10 +134426,8 @@ function createEventsStorage(basedir, tag) {
|
|
|
134195
134426
|
}
|
|
134196
134427
|
}
|
|
134197
134428
|
}
|
|
134198
|
-
|
|
134199
|
-
|
|
134200
|
-
}
|
|
134201
|
-
if (data.eventType === "attr_set" && !currentRun) {
|
|
134429
|
+
eventId = await mintEventId(effectiveRunId);
|
|
134430
|
+
if (!currentRun && (data.eventType === "run_failed" || data.eventType === "attr_set" || data.eventType === "run_started")) {
|
|
134202
134431
|
throw new WorkflowRunNotFoundError(effectiveRunId);
|
|
134203
134432
|
}
|
|
134204
134433
|
if (currentRun) {
|
|
@@ -134213,17 +134442,16 @@ function createEventsStorage(basedir, tag) {
|
|
|
134213
134442
|
const lazyStepStart = createsChildEntity && data.eventType === "step_started";
|
|
134214
134443
|
if (currentRun && isTerminalWorkflowRunStatus(currentRun.status)) {
|
|
134215
134444
|
if (data.eventType === "run_cancelled" && currentRun.status === "cancelled") {
|
|
134216
|
-
const
|
|
134445
|
+
const stored = await storeEvent({
|
|
134217
134446
|
...data,
|
|
134218
134447
|
runId: effectiveRunId,
|
|
134219
134448
|
eventId,
|
|
134220
134449
|
createdAt: now2,
|
|
134221
134450
|
specVersion: effectiveSpecVersion
|
|
134222
|
-
};
|
|
134223
|
-
await storeEvent(event2);
|
|
134451
|
+
});
|
|
134224
134452
|
const resolveData2 = (params == null ? void 0 : params.resolveData) ?? DEFAULT_RESOLVE_DATA_OPTION$1;
|
|
134225
134453
|
return {
|
|
134226
|
-
event: stripEventDataRefs(
|
|
134454
|
+
event: stripEventDataRefs(stored, resolveData2),
|
|
134227
134455
|
run: currentRun,
|
|
134228
134456
|
...currentRun ? { maxEvents: getMaxEventsPerRun() } : {}
|
|
134229
134457
|
};
|
|
@@ -134267,7 +134495,8 @@ function createEventsStorage(basedir, tag) {
|
|
|
134267
134495
|
if (data.eventType === "hook_received" && (params == null ? void 0 : params.resumeId)) {
|
|
134268
134496
|
const committedClaim = await readJSON(hookResumeClaimPath(basedir, effectiveRunId, params.resumeId), HookResumeClaimSchema);
|
|
134269
134497
|
if (committedClaim && committedClaim.hookId === data.correlationId && (!params.resumePayloadDigest || !committedClaim.payloadDigest || committedClaim.payloadDigest === params.resumePayloadDigest)) {
|
|
134270
|
-
const
|
|
134498
|
+
const atClaimedId = await readJSONWithFallback(basedir, "events", `${effectiveRunId}-${committedClaim.eventId}`, EventSchema, tag);
|
|
134499
|
+
const committedEvent = atClaimedId && isResumeEvent(atClaimedId, committedClaim) ? atClaimedId : await findCommittedResumeEvent(basedir, effectiveRunId, committedClaim, tag);
|
|
134271
134500
|
if (committedEvent) {
|
|
134272
134501
|
return { event: committedEvent };
|
|
134273
134502
|
}
|
|
@@ -134289,11 +134518,19 @@ function createEventsStorage(basedir, tag) {
|
|
|
134289
134518
|
if (params.resumePayloadDigest && claim.payloadDigest && claim.payloadDigest !== params.resumePayloadDigest) {
|
|
134290
134519
|
throw new EntityConflictError(`hook_received resumeId "${params.resumeId}" already recorded with a different payload`);
|
|
134291
134520
|
}
|
|
134292
|
-
const
|
|
134293
|
-
if (
|
|
134294
|
-
return { event:
|
|
134521
|
+
const atClaimedId = await readJSONWithFallback(basedir, "events", `${effectiveRunId}-${claim.eventId}`, EventSchema, tag);
|
|
134522
|
+
if (atClaimedId && isResumeEvent(atClaimedId, claim)) {
|
|
134523
|
+
return { event: atClaimedId };
|
|
134524
|
+
}
|
|
134525
|
+
const committed = await findCommittedResumeEvent(basedir, effectiveRunId, claim, tag);
|
|
134526
|
+
if (committed) {
|
|
134527
|
+
return { event: committed };
|
|
134528
|
+
}
|
|
134529
|
+
resumeClaimRecordedId = claim.eventId;
|
|
134530
|
+
if (!atClaimedId) {
|
|
134531
|
+
eventId = claim.eventId;
|
|
134532
|
+
eventIdPinned = true;
|
|
134295
134533
|
}
|
|
134296
|
-
eventId = claim.eventId;
|
|
134297
134534
|
return null;
|
|
134298
134535
|
};
|
|
134299
134536
|
const existingClaim = await readJSON(claimPath, HookResumeClaimSchema);
|
|
@@ -134303,6 +134540,8 @@ function createEventsStorage(basedir, tag) {
|
|
|
134303
134540
|
return converged;
|
|
134304
134541
|
}
|
|
134305
134542
|
} else {
|
|
134543
|
+
eventIdPinned = !isSlotEventId(eventId);
|
|
134544
|
+
resumeClaimRecordedId = eventId;
|
|
134306
134545
|
const won = await writeExclusive(claimPath, JSON.stringify({
|
|
134307
134546
|
runId: effectiveRunId,
|
|
134308
134547
|
resumeId: params.resumeId,
|
|
@@ -134311,6 +134550,7 @@ function createEventsStorage(basedir, tag) {
|
|
|
134311
134550
|
...params.resumePayloadDigest ? { payloadDigest: params.resumePayloadDigest } : {}
|
|
134312
134551
|
}));
|
|
134313
134552
|
if (!won) {
|
|
134553
|
+
resumeClaimRecordedId = null;
|
|
134314
134554
|
const winner = await readJSON(claimPath, HookResumeClaimSchema);
|
|
134315
134555
|
if (winner) {
|
|
134316
134556
|
const converged = await converge(winner);
|
|
@@ -134353,7 +134593,7 @@ function createEventsStorage(basedir, tag) {
|
|
|
134353
134593
|
if (isTerminalRunEventType(data.eventType) && currentRun) {
|
|
134354
134594
|
await writeExclusive(runTerminalMarkerPath(basedir, effectiveRunId, tag), "");
|
|
134355
134595
|
await reapPendingHookEvents(basedir, effectiveRunId, tag);
|
|
134356
|
-
const dominantKey = await
|
|
134596
|
+
const dominantKey = await mintDominantEventKey(effectiveRunId);
|
|
134357
134597
|
eventId = dominantKey.eventId;
|
|
134358
134598
|
event = { ...event, eventId, createdAt: dominantKey.createdAt };
|
|
134359
134599
|
}
|
|
@@ -134391,7 +134631,22 @@ function createEventsStorage(basedir, tag) {
|
|
|
134391
134631
|
} else if (data.eventType === "run_started") {
|
|
134392
134632
|
if (currentRun) {
|
|
134393
134633
|
if (currentRun.status === "running") {
|
|
134394
|
-
|
|
134634
|
+
if (params == null ? void 0 : params.skipPreload) {
|
|
134635
|
+
return {
|
|
134636
|
+
run: currentRun,
|
|
134637
|
+
maxEvents: getMaxEventsPerRun()
|
|
134638
|
+
};
|
|
134639
|
+
}
|
|
134640
|
+
const preloaded = await queryRunEvents(effectiveRunId, {
|
|
134641
|
+
limit: getMaxEventsPerRun()
|
|
134642
|
+
});
|
|
134643
|
+
return {
|
|
134644
|
+
run: currentRun,
|
|
134645
|
+
events: preloaded.data,
|
|
134646
|
+
cursor: preloaded.cursor,
|
|
134647
|
+
hasMore: preloaded.hasMore,
|
|
134648
|
+
maxEvents: getMaxEventsPerRun()
|
|
134649
|
+
};
|
|
134395
134650
|
}
|
|
134396
134651
|
run2 = await writeRunUnderLifecycleLock(basedir, effectiveRunId, tag, {
|
|
134397
134652
|
runId: currentRun.runId,
|
|
@@ -134570,7 +134825,7 @@ function createEventsStorage(basedir, tag) {
|
|
|
134570
134825
|
specVersion: effectiveSpecVersion
|
|
134571
134826
|
};
|
|
134572
134827
|
await writeJSON(taggedPath(basedir, "steps", `${effectiveRunId}-${data.correlationId}`, tag), createdStep);
|
|
134573
|
-
const stepCreatedEventId =
|
|
134828
|
+
const stepCreatedEventId = await mintEventId(effectiveRunId);
|
|
134574
134829
|
const stepCreatedEvent = {
|
|
134575
134830
|
eventType: "step_created",
|
|
134576
134831
|
runId: effectiveRunId,
|
|
@@ -134583,7 +134838,7 @@ function createEventsStorage(basedir, tag) {
|
|
|
134583
134838
|
input: lazyData.input
|
|
134584
134839
|
}
|
|
134585
134840
|
};
|
|
134586
|
-
await
|
|
134841
|
+
await storeEvent(stepCreatedEvent);
|
|
134587
134842
|
validatedStep = createdStep;
|
|
134588
134843
|
stepCreatedLazily = true;
|
|
134589
134844
|
}
|
|
@@ -134724,6 +134979,7 @@ function createEventsStorage(basedir, tag) {
|
|
|
134724
134979
|
canonicalEventId = pinned;
|
|
134725
134980
|
}
|
|
134726
134981
|
eventId = canonicalEventId;
|
|
134982
|
+
eventIdPinned = true;
|
|
134727
134983
|
const canonicalCreatedAt = ulidToDate(eventId.replace(/^evnt_/, "")) ?? now2;
|
|
134728
134984
|
event = {
|
|
134729
134985
|
...data,
|
|
@@ -134753,10 +135009,10 @@ function createEventsStorage(basedir, tag) {
|
|
|
134753
135009
|
createdAt: now2,
|
|
134754
135010
|
specVersion: effectiveSpecVersion
|
|
134755
135011
|
};
|
|
134756
|
-
await storeEvent(conflictEvent);
|
|
135012
|
+
const storedConflict = await storeEvent(conflictEvent);
|
|
134757
135013
|
const resolveData2 = (params == null ? void 0 : params.resolveData) ?? DEFAULT_RESOLVE_DATA_OPTION$1;
|
|
134758
135014
|
return {
|
|
134759
|
-
event: stripEventDataRefs(
|
|
135015
|
+
event: stripEventDataRefs(storedConflict, resolveData2),
|
|
134760
135016
|
run: run2,
|
|
134761
135017
|
step,
|
|
134762
135018
|
hook: void 0
|
|
@@ -134839,36 +135095,65 @@ function createEventsStorage(basedir, tag) {
|
|
|
134839
135095
|
if (data.eventType === "hook_received" && data.correlationId && await isHookDisposalCommitted(basedir, data.correlationId, tag)) {
|
|
134840
135096
|
throw new HookNotFoundError(data.correlationId);
|
|
134841
135097
|
}
|
|
134842
|
-
|
|
134843
|
-
|
|
134844
|
-
const
|
|
134845
|
-
|
|
134846
|
-
|
|
134847
|
-
|
|
134848
|
-
const runNow = terminalByMarker ? null : await readJSONWithFallback(basedir, "runs", effectiveRunId, WorkflowRunSchema, tag);
|
|
134849
|
-
if (terminalByMarker || runNow && isTerminalWorkflowRunStatus(runNow.status)) {
|
|
134850
|
-
throw new RunExpiredError(`Workflow run "${effectiveRunId}" is already in a terminal state`);
|
|
134851
|
-
}
|
|
134852
|
-
const stagedPath = pendingHookEventPath(basedir, effectiveRunId, eventId, tag);
|
|
134853
|
-
const staged = await writeExclusive(stagedPath, serializedEvent);
|
|
134854
|
-
if (!staged) {
|
|
134855
|
-
throw new EntityConflictError(`Event "${eventId}" already exists for run "${effectiveRunId}"`);
|
|
135098
|
+
let eventPath = taggedPath(basedir, "events", `${effectiveRunId}-${eventId}`, tag);
|
|
135099
|
+
let serializedEvent = JSON.stringify(event, jsonReplacer, 2);
|
|
135100
|
+
const bumpEventSlot = async (attempt) => {
|
|
135101
|
+
const current = eventIdToSlot(eventId);
|
|
135102
|
+
if (eventIdPinned || current === null) {
|
|
135103
|
+
return false;
|
|
134856
135104
|
}
|
|
134857
|
-
|
|
134858
|
-
|
|
135105
|
+
const slot = await drawEventSlot(effectiveRunId, {
|
|
135106
|
+
rescan: attempt > 0 && attempt % 8 === 0,
|
|
135107
|
+
atLeast: current + 1
|
|
135108
|
+
});
|
|
135109
|
+
if (slot === null) {
|
|
135110
|
+
return false;
|
|
135111
|
+
}
|
|
135112
|
+
eventId = slotToEventId(slot);
|
|
135113
|
+
event = { ...event, eventId };
|
|
135114
|
+
eventPath = taggedPath(basedir, "events", `${effectiveRunId}-${eventId}`, tag);
|
|
135115
|
+
serializedEvent = JSON.stringify(event, jsonReplacer, 2);
|
|
135116
|
+
return true;
|
|
135117
|
+
};
|
|
135118
|
+
let eventPublished = false;
|
|
135119
|
+
for (let attempt = 0; ; attempt++) {
|
|
135120
|
+
if (data.eventType === "hook_received") {
|
|
135121
|
+
const terminalByMarker = await isRunTerminalCommitted(basedir, effectiveRunId, tag);
|
|
135122
|
+
const runNow = terminalByMarker ? null : await readJSONWithFallback(basedir, "runs", effectiveRunId, WorkflowRunSchema, tag);
|
|
135123
|
+
if (terminalByMarker || runNow && isTerminalWorkflowRunStatus(runNow.status)) {
|
|
134859
135124
|
throw new RunExpiredError(`Workflow run "${effectiveRunId}" is already in a terminal state`);
|
|
134860
135125
|
}
|
|
134861
|
-
const
|
|
134862
|
-
|
|
134863
|
-
|
|
135126
|
+
const stagedPath = pendingHookEventPath(basedir, effectiveRunId, eventId, tag);
|
|
135127
|
+
const staged = await writeExclusive(stagedPath, serializedEvent);
|
|
135128
|
+
if (!staged) {
|
|
135129
|
+
if (await bumpEventSlot(attempt)) {
|
|
135130
|
+
continue;
|
|
135131
|
+
}
|
|
135132
|
+
throw new EntityConflictError(`Event "${eventId}" already exists for run "${effectiveRunId}"`);
|
|
134864
135133
|
}
|
|
134865
|
-
|
|
134866
|
-
|
|
134867
|
-
|
|
134868
|
-
|
|
135134
|
+
try {
|
|
135135
|
+
if (await isRunTerminalCommitted(basedir, effectiveRunId, tag)) {
|
|
135136
|
+
throw new RunExpiredError(`Workflow run "${effectiveRunId}" is already in a terminal state`);
|
|
135137
|
+
}
|
|
135138
|
+
const promoted = await promoteExclusive(stagedPath, eventPath);
|
|
135139
|
+
if (promoted === "missing") {
|
|
135140
|
+
throw new RunExpiredError(`Workflow run "${effectiveRunId}" is already in a terminal state`);
|
|
135141
|
+
}
|
|
135142
|
+
eventPublished = promoted === "linked";
|
|
135143
|
+
} finally {
|
|
135144
|
+
await deleteJSON(stagedPath).catch(() => {
|
|
135145
|
+
});
|
|
135146
|
+
}
|
|
135147
|
+
} else {
|
|
135148
|
+
eventPublished = await writeExclusive(eventPath, serializedEvent);
|
|
135149
|
+
}
|
|
135150
|
+
if (eventPublished) {
|
|
135151
|
+
notePublishedSlot(effectiveRunId, eventId);
|
|
135152
|
+
break;
|
|
135153
|
+
}
|
|
135154
|
+
if (!await bumpEventSlot(attempt)) {
|
|
135155
|
+
break;
|
|
134869
135156
|
}
|
|
134870
|
-
} else {
|
|
134871
|
-
eventPublished = await writeExclusive(eventPath, serializedEvent);
|
|
134872
135157
|
}
|
|
134873
135158
|
if (!eventPublished) {
|
|
134874
135159
|
if (data.eventType === "hook_created" && data.correlationId) {
|
|
@@ -134877,57 +135162,55 @@ function createEventsStorage(basedir, tag) {
|
|
|
134877
135162
|
throw new EntityConflictError(`Event "${eventId}" already exists for run "${effectiveRunId}"`);
|
|
134878
135163
|
}
|
|
134879
135164
|
rememberStoredEvent(event, eventPath, serializedEvent);
|
|
135165
|
+
if (data.eventType === "hook_received" && (params == null ? void 0 : params.resumeId) && resumeClaimRecordedId !== null && resumeClaimRecordedId !== eventId) {
|
|
135166
|
+
await write(hookResumeClaimPath(basedir, effectiveRunId, params.resumeId), JSON.stringify({
|
|
135167
|
+
runId: effectiveRunId,
|
|
135168
|
+
resumeId: params.resumeId,
|
|
135169
|
+
hookId: data.correlationId,
|
|
135170
|
+
eventId,
|
|
135171
|
+
...params.resumePayloadDigest ? { payloadDigest: params.resumePayloadDigest } : {}
|
|
135172
|
+
}), { overwrite: true });
|
|
135173
|
+
}
|
|
134880
135174
|
if (hook && data.eventType === "hook_created") {
|
|
134881
135175
|
await writeHookByRunMarker(basedir, hook.runId, hook.hookId, tag);
|
|
134882
135176
|
await writeJSON(taggedPath(basedir, "hooks", hook.hookId, tag), hook, hookEntityWriteOptions);
|
|
134883
135177
|
}
|
|
134884
135178
|
const resolveData = (params == null ? void 0 : params.resolveData) ?? DEFAULT_RESOLVE_DATA_OPTION$1;
|
|
134885
135179
|
const filteredEvent = stripEventDataRefs(event, resolveData);
|
|
134886
|
-
let
|
|
134887
|
-
|
|
134888
|
-
|
|
134889
|
-
|
|
134890
|
-
const allEvents = await paginatedFileSystemQuery({
|
|
134891
|
-
directory: path$3.join(basedir, "events"),
|
|
134892
|
-
schema: EventSchema,
|
|
134893
|
-
cachedItems: eventCache,
|
|
134894
|
-
filePrefix: `${effectiveRunId}-`,
|
|
134895
|
-
sortOrder: "asc",
|
|
134896
|
-
limit: 1e3,
|
|
134897
|
-
getCreatedAt: getObjectCreatedAt("evnt"),
|
|
134898
|
-
getId: (e) => e.eventId
|
|
135180
|
+
let eventPage;
|
|
135181
|
+
if (data.eventType === "run_started" && run2 && !(params == null ? void 0 : params.skipPreload)) {
|
|
135182
|
+
eventPage = await queryRunEvents(effectiveRunId, {
|
|
135183
|
+
limit: getMaxEventsPerRun()
|
|
134899
135184
|
});
|
|
134900
|
-
|
|
134901
|
-
|
|
134902
|
-
|
|
134903
|
-
}
|
|
134904
|
-
if (isTerminalStepEventType(data.eventType) && typeof (params == null ? void 0 : params.sinceCursor) === "string") {
|
|
134905
|
-
const delta = await paginatedFileSystemQuery({
|
|
134906
|
-
directory: path$3.join(basedir, "events"),
|
|
134907
|
-
schema: EventSchema,
|
|
134908
|
-
filePrefix: `${effectiveRunId}-`,
|
|
135185
|
+
}
|
|
135186
|
+
if (typeof (params == null ? void 0 : params.sinceCursor) === "string") {
|
|
135187
|
+
const delta = await queryRunEvents(effectiveRunId, {
|
|
134909
135188
|
sortOrder: "asc",
|
|
134910
|
-
cursor: params.sinceCursor
|
|
134911
|
-
getCreatedAt: getObjectCreatedAt("evnt"),
|
|
134912
|
-
getId: (e) => e.eventId
|
|
135189
|
+
cursor: params.sinceCursor
|
|
134913
135190
|
});
|
|
134914
|
-
|
|
134915
|
-
|
|
134916
|
-
|
|
135191
|
+
eventPage = resolveData === "none" ? {
|
|
135192
|
+
...delta,
|
|
135193
|
+
data: delta.data.map((event2) => stripEventDataRefs(event2, resolveData))
|
|
135194
|
+
} : delta;
|
|
134917
135195
|
}
|
|
134918
|
-
|
|
135196
|
+
const result = {
|
|
134919
135197
|
event: filteredEvent,
|
|
134920
135198
|
run: run2,
|
|
134921
135199
|
step,
|
|
134922
135200
|
hook,
|
|
134923
135201
|
wait,
|
|
134924
|
-
events: events2,
|
|
134925
|
-
cursor,
|
|
134926
|
-
hasMore,
|
|
134927
135202
|
...stepCreatedLazily ? { stepCreated: true } : {},
|
|
134928
135203
|
// Per-run event ceiling (mirrors the Vercel World).
|
|
134929
135204
|
...run2 ? { maxEvents: getMaxEventsPerRun() } : {}
|
|
134930
135205
|
};
|
|
135206
|
+
if (!eventPage)
|
|
135207
|
+
return result;
|
|
135208
|
+
return {
|
|
135209
|
+
...result,
|
|
135210
|
+
events: eventPage.data,
|
|
135211
|
+
cursor: eventPage.cursor,
|
|
135212
|
+
hasMore: eventPage.hasMore
|
|
135213
|
+
};
|
|
134931
135214
|
}
|
|
134932
135215
|
},
|
|
134933
135216
|
async get(runId, eventId, params) {
|
|
@@ -134942,22 +135225,13 @@ function createEventsStorage(basedir, tag) {
|
|
|
134942
135225
|
return stripEventDataRefs(event, resolveData);
|
|
134943
135226
|
},
|
|
134944
135227
|
async list(params) {
|
|
134945
|
-
var _a3
|
|
135228
|
+
var _a3;
|
|
134946
135229
|
const { runId } = params;
|
|
134947
135230
|
assertSafeEntityId("runId", runId);
|
|
134948
135231
|
const resolveData = params.resolveData ?? DEFAULT_RESOLVE_DATA_OPTION$1;
|
|
134949
|
-
const result = await
|
|
134950
|
-
|
|
134951
|
-
|
|
134952
|
-
cachedItems: eventCache,
|
|
134953
|
-
filePrefix: `${runId}-`,
|
|
134954
|
-
// Events in chronological order (oldest first) by default,
|
|
134955
|
-
// different from the default for other list calls.
|
|
134956
|
-
sortOrder: ((_a3 = params.pagination) == null ? void 0 : _a3.sortOrder) ?? "asc",
|
|
134957
|
-
limit: (_b2 = params.pagination) == null ? void 0 : _b2.limit,
|
|
134958
|
-
cursor: (_c2 = params.pagination) == null ? void 0 : _c2.cursor,
|
|
134959
|
-
getCreatedAt: getObjectCreatedAt("evnt"),
|
|
134960
|
-
getId: (event) => event.eventId
|
|
135232
|
+
const result = await queryRunEvents(runId, {
|
|
135233
|
+
...params.pagination,
|
|
135234
|
+
limit: ((_a3 = params.pagination) == null ? void 0 : _a3.limit) ?? getMaxEventsPerRun()
|
|
134961
135235
|
});
|
|
134962
135236
|
if (resolveData === "none") {
|
|
134963
135237
|
return {
|
|
@@ -134989,7 +135263,9 @@ function createEventsStorage(basedir, tag) {
|
|
|
134989
135263
|
limit: (_b2 = params.pagination) == null ? void 0 : _b2.limit,
|
|
134990
135264
|
cursor: (_c2 = params.pagination) == null ? void 0 : _c2.cursor,
|
|
134991
135265
|
getCreatedAt: getObjectCreatedAt("evnt"),
|
|
134992
|
-
getId: (event) => event.eventId
|
|
135266
|
+
getId: (event) => event.eventId,
|
|
135267
|
+
getSortKey: eventSortKey,
|
|
135268
|
+
getSortKeyFromFileId: (fileId) => eventSortKeyFromFileId(params.runId, fileId)
|
|
134993
135269
|
});
|
|
134994
135270
|
if (resolveData === "none") {
|
|
134995
135271
|
return {
|
|
@@ -135000,6 +135276,48 @@ function createEventsStorage(basedir, tag) {
|
|
|
135000
135276
|
return result;
|
|
135001
135277
|
}
|
|
135002
135278
|
};
|
|
135279
|
+
async function reportSkippedSlots(result, askedFor, resolveData) {
|
|
135280
|
+
if (!result.event) {
|
|
135281
|
+
return result;
|
|
135282
|
+
}
|
|
135283
|
+
const committedSlot = eventIdToSlot(result.event.eventId);
|
|
135284
|
+
if (committedSlot === null || askedFor < FIRST_EVENT_SLOT || committedSlot <= askedFor + 1) {
|
|
135285
|
+
return result;
|
|
135286
|
+
}
|
|
135287
|
+
const span = committedSlot - askedFor - 1;
|
|
135288
|
+
const page = await storage.list({
|
|
135289
|
+
runId: result.event.runId,
|
|
135290
|
+
pagination: {
|
|
135291
|
+
cursor: `${SORT_KEY_CURSOR_PREFIX}${slotToEventId(askedFor)}`,
|
|
135292
|
+
limit: span,
|
|
135293
|
+
sortOrder: "asc"
|
|
135294
|
+
},
|
|
135295
|
+
resolveData
|
|
135296
|
+
});
|
|
135297
|
+
const committedEventId = result.event.eventId;
|
|
135298
|
+
const events2 = page.data.filter((event) => event.eventId < committedEventId);
|
|
135299
|
+
return {
|
|
135300
|
+
...result,
|
|
135301
|
+
events: events2,
|
|
135302
|
+
// Deliberately no cursor: the report is a lower bound on what this write
|
|
135303
|
+
// skipped over, not a page the caller has now read to the end of, so it
|
|
135304
|
+
// must not advance the caller's read position.
|
|
135305
|
+
cursor: null,
|
|
135306
|
+
hasMore: events2.length < committedSlot - askedFor - 1
|
|
135307
|
+
};
|
|
135308
|
+
}
|
|
135309
|
+
const create2 = (async (runId, data, params) => {
|
|
135310
|
+
if ((params == null ? void 0 : params.eventCount) === void 0) {
|
|
135311
|
+
return storage.create(runId, data, params);
|
|
135312
|
+
}
|
|
135313
|
+
const resolveData = params.resolveData ?? DEFAULT_RESOLVE_DATA_OPTION$1;
|
|
135314
|
+
const result = await storage.create(runId, data, params);
|
|
135315
|
+
if (typeof params.sinceCursor === "string") {
|
|
135316
|
+
return result;
|
|
135317
|
+
}
|
|
135318
|
+
return reportSkippedSlots(result, params.eventCount, resolveData);
|
|
135319
|
+
});
|
|
135320
|
+
return { ...storage, create: create2 };
|
|
135003
135321
|
}
|
|
135004
135322
|
function createStepsStorage(basedir, tag) {
|
|
135005
135323
|
return {
|
|
@@ -135443,7 +135761,11 @@ function createWorld$2(args) {
|
|
|
135443
135761
|
// `(runId, resumeId)` via a filesystem sidecar claim (see
|
|
135444
135762
|
// events-storage.ts `claimHookResume`), so resumeHook()'s parallel fast
|
|
135445
135763
|
// path converges on one event in dev exactly as it does on Vercel.
|
|
135446
|
-
hookResumeDedup: true
|
|
135764
|
+
hookResumeDedup: true,
|
|
135765
|
+
// New runs get dense per-run slot event ids. Runs created before this
|
|
135766
|
+
// keep their ULIDs; the scheme is pinned by a run's own first event id,
|
|
135767
|
+
// not by this flag, which only says what new runs get.
|
|
135768
|
+
slotEventIds: true
|
|
135447
135769
|
},
|
|
135448
135770
|
...queue,
|
|
135449
135771
|
...storage,
|
|
@@ -135478,7 +135800,7 @@ function createWorld$2(args) {
|
|
|
135478
135800
|
const basedir = mergedConfig.dataDir;
|
|
135479
135801
|
const hooksDir = path$3.join(basedir, "hooks");
|
|
135480
135802
|
const taggedHookFiles = await listTaggedFiles(hooksDir, tag);
|
|
135481
|
-
const { HookSchema: HookSchema2 } = await import("./index-
|
|
135803
|
+
const { HookSchema: HookSchema2 } = await import("./index-BByEr1g6.js");
|
|
135482
135804
|
await Promise.all(taggedHookFiles.map(async (hookFile) => {
|
|
135483
135805
|
const hook = await readJSON(path$3.join(hooksDir, hookFile), HookSchema2);
|
|
135484
135806
|
if (hook == null ? void 0 : hook.token) {
|
|
@@ -135661,8 +135983,8 @@ function requireGetVercelOidcToken() {
|
|
|
135661
135983
|
}
|
|
135662
135984
|
try {
|
|
135663
135985
|
const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
|
|
135664
|
-
await import("./token-util-
|
|
135665
|
-
await import("./token-
|
|
135986
|
+
await import("./token-util-C2yENsqE.js").then((n) => n.t),
|
|
135987
|
+
await import("./token-c3byIJRC.js").then((n) => n.t)
|
|
135666
135988
|
]);
|
|
135667
135989
|
if (!token || isExpired(getTokenPayload(token), options == null ? void 0 : options.expirationBufferMs)) {
|
|
135668
135990
|
await refreshToken(options);
|
|
@@ -136226,7 +136548,6 @@ function requireDist() {
|
|
|
136226
136548
|
}
|
|
136227
136549
|
var distExports = requireDist();
|
|
136228
136550
|
let _dispatcher;
|
|
136229
|
-
let _eventsDispatcher;
|
|
136230
136551
|
let _streamDispatcher;
|
|
136231
136552
|
let _streamCloseDispatcher;
|
|
136232
136553
|
const BASE_AGENT_OPTIONS = {
|
|
@@ -136250,6 +136571,11 @@ const EVENTS_AGENT_OPTIONS = {
|
|
|
136250
136571
|
initialWindowSize: H2_STREAM_WINDOW_BYTES,
|
|
136251
136572
|
connectionWindowSize: H2_CONNECTION_WINDOW_BYTES
|
|
136252
136573
|
};
|
|
136574
|
+
const EVENTS_AGENT_OPTIONS_NO_H2 = {
|
|
136575
|
+
...BASE_AGENT_OPTIONS,
|
|
136576
|
+
allowH2: false,
|
|
136577
|
+
pipelining: 1
|
|
136578
|
+
};
|
|
136253
136579
|
const STREAM_AGENT_OPTIONS = {
|
|
136254
136580
|
...BASE_AGENT_OPTIONS,
|
|
136255
136581
|
allowH2: true,
|
|
@@ -136280,7 +136606,7 @@ const STREAM_CLOSE_RETRY_OPTIONS = {
|
|
|
136280
136606
|
statusCodes: [429, 500, 502, 503, 504]
|
|
136281
136607
|
};
|
|
136282
136608
|
const H2_REBUFFER_MAX_BYTES = 1 << 20;
|
|
136283
|
-
function
|
|
136609
|
+
function h2EventsEnabled() {
|
|
136284
136610
|
return process.env.WORKFLOW_H2_MULTIPLEX !== "0";
|
|
136285
136611
|
}
|
|
136286
136612
|
function contentLength(headers2) {
|
|
@@ -136314,11 +136640,84 @@ function h2MultiplexInterceptor(dispatch2) {
|
|
|
136314
136640
|
return true;
|
|
136315
136641
|
};
|
|
136316
136642
|
}
|
|
136643
|
+
const EVENTS_RECYCLE_AFTER_CONSECUTIVE_FAILURES = 3;
|
|
136644
|
+
const RECYCLE_MIN_INTERVAL_MS = 5e3;
|
|
136645
|
+
const RETIRED_CLOSE_DELAY_MS = 5e3;
|
|
136646
|
+
const RETIRED_DESTROY_DELAY_MS = 6e4;
|
|
136647
|
+
const RECYCLABLE_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
136648
|
+
// Covers H2 stream timeout, frameError and GOAWAY (undici InformationalError).
|
|
136649
|
+
"UND_ERR_INFO",
|
|
136650
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
136651
|
+
"UND_ERR_BODY_TIMEOUT"
|
|
136652
|
+
]);
|
|
136653
|
+
const MAX_CAUSE_DEPTH = 8;
|
|
136654
|
+
function isRecyclableTransportError(error2) {
|
|
136655
|
+
let current = error2;
|
|
136656
|
+
for (let depth = 0; current && depth < MAX_CAUSE_DEPTH; depth++) {
|
|
136657
|
+
const code2 = current.code;
|
|
136658
|
+
if (typeof code2 === "string" && RECYCLABLE_ERROR_CODES.has(code2)) {
|
|
136659
|
+
return true;
|
|
136660
|
+
}
|
|
136661
|
+
current = current.cause;
|
|
136662
|
+
}
|
|
136663
|
+
return false;
|
|
136664
|
+
}
|
|
136665
|
+
function createDispatcherRecycler(factory, label) {
|
|
136666
|
+
let current;
|
|
136667
|
+
let consecutiveFailures = 0;
|
|
136668
|
+
let lastRecycledAt = 0;
|
|
136669
|
+
function retire(stale) {
|
|
136670
|
+
var _a3, _b2;
|
|
136671
|
+
const closeTimer = setTimeout(() => {
|
|
136672
|
+
var _a4;
|
|
136673
|
+
void Promise.resolve((_a4 = stale.close) == null ? void 0 : _a4.call(stale)).catch(() => void 0);
|
|
136674
|
+
}, RETIRED_CLOSE_DELAY_MS);
|
|
136675
|
+
const destroyTimer = setTimeout(() => {
|
|
136676
|
+
var _a4;
|
|
136677
|
+
void Promise.resolve((_a4 = stale.destroy) == null ? void 0 : _a4.call(stale)).catch(() => void 0);
|
|
136678
|
+
}, RETIRED_DESTROY_DELAY_MS);
|
|
136679
|
+
(_a3 = closeTimer.unref) == null ? void 0 : _a3.call(closeTimer);
|
|
136680
|
+
(_b2 = destroyTimer.unref) == null ? void 0 : _b2.call(destroyTimer);
|
|
136681
|
+
}
|
|
136682
|
+
return {
|
|
136683
|
+
get() {
|
|
136684
|
+
current ?? (current = factory());
|
|
136685
|
+
return current;
|
|
136686
|
+
},
|
|
136687
|
+
note(dispatcher2, error2) {
|
|
136688
|
+
if (!current || dispatcher2 !== current)
|
|
136689
|
+
return;
|
|
136690
|
+
if (error2 === void 0) {
|
|
136691
|
+
consecutiveFailures = 0;
|
|
136692
|
+
return;
|
|
136693
|
+
}
|
|
136694
|
+
if (!isRecyclableTransportError(error2))
|
|
136695
|
+
return;
|
|
136696
|
+
consecutiveFailures++;
|
|
136697
|
+
if (consecutiveFailures < EVENTS_RECYCLE_AFTER_CONSECUTIVE_FAILURES) {
|
|
136698
|
+
return;
|
|
136699
|
+
}
|
|
136700
|
+
const now2 = Date.now();
|
|
136701
|
+
if (now2 - lastRecycledAt < RECYCLE_MIN_INTERVAL_MS)
|
|
136702
|
+
return;
|
|
136703
|
+
lastRecycledAt = now2;
|
|
136704
|
+
consecutiveFailures = 0;
|
|
136705
|
+
const stale = current;
|
|
136706
|
+
current = void 0;
|
|
136707
|
+
console.warn(`[workflow] ${label}: rebuilding connection pool after ${EVENTS_RECYCLE_AFTER_CONSECUTIVE_FAILURES} consecutive transport failures`);
|
|
136708
|
+
retire(stale);
|
|
136709
|
+
}
|
|
136710
|
+
};
|
|
136711
|
+
}
|
|
136712
|
+
const eventsRecycler = createDispatcherRecycler(() => createEventsDispatcher(), "events transport");
|
|
136713
|
+
function noteEventsTransportOutcome(dispatcher2, error2) {
|
|
136714
|
+
eventsRecycler.note(dispatcher2, error2);
|
|
136715
|
+
}
|
|
136317
136716
|
function getDispatcher(config2) {
|
|
136318
136717
|
return (config2 == null ? void 0 : config2.dispatcher) ?? getDefaultDispatcher();
|
|
136319
136718
|
}
|
|
136320
136719
|
function getEventsDispatcher(config2) {
|
|
136321
|
-
return (config2 == null ? void 0 : config2.dispatcher) ??
|
|
136720
|
+
return (config2 == null ? void 0 : config2.dispatcher) ?? eventsRecycler.get();
|
|
136322
136721
|
}
|
|
136323
136722
|
function getStreamDispatcher(config2) {
|
|
136324
136723
|
return (config2 == null ? void 0 : config2.dispatcher) ?? getDefaultStreamDispatcher();
|
|
@@ -136330,8 +136729,12 @@ function makeRetryDispatcher(agentOptions, retryOptions) {
|
|
|
136330
136729
|
return new undiciExports.RetryAgent(new undiciExports.Agent(agentOptions), retryOptions);
|
|
136331
136730
|
}
|
|
136332
136731
|
function createEventsDispatcher(agentOverrides) {
|
|
136333
|
-
const
|
|
136334
|
-
|
|
136732
|
+
const h2 = h2EventsEnabled();
|
|
136733
|
+
const agent2 = new undiciExports.RetryAgent(new undiciExports.Agent({
|
|
136734
|
+
...h2 ? EVENTS_AGENT_OPTIONS : EVENTS_AGENT_OPTIONS_NO_H2,
|
|
136735
|
+
...agentOverrides
|
|
136736
|
+
}), RETRY_AGENT_OPTIONS);
|
|
136737
|
+
if (!h2) {
|
|
136335
136738
|
return agent2;
|
|
136336
136739
|
}
|
|
136337
136740
|
return withBoundLifecycle(agent2, agent2.compose(h2MultiplexInterceptor));
|
|
@@ -136348,10 +136751,6 @@ function getDefaultDispatcher() {
|
|
|
136348
136751
|
_dispatcher ?? (_dispatcher = makeRetryDispatcher(DEFAULT_AGENT_OPTIONS, RETRY_AGENT_OPTIONS));
|
|
136349
136752
|
return _dispatcher;
|
|
136350
136753
|
}
|
|
136351
|
-
function getDefaultEventsDispatcher() {
|
|
136352
|
-
_eventsDispatcher ?? (_eventsDispatcher = createEventsDispatcher());
|
|
136353
|
-
return _eventsDispatcher;
|
|
136354
|
-
}
|
|
136355
136754
|
function getDefaultStreamDispatcher() {
|
|
136356
136755
|
_streamDispatcher ?? (_streamDispatcher = createStreamDispatcher(STREAM_RETRY_OPTIONS));
|
|
136357
136756
|
return _streamDispatcher;
|
|
@@ -136512,6 +136911,13 @@ function parseRetryAfter(value) {
|
|
|
136512
136911
|
const parsed = parseInt(value, 10);
|
|
136513
136912
|
return Number.isNaN(parsed) ? void 0 : parsed;
|
|
136514
136913
|
}
|
|
136914
|
+
function headersToRecord(headers2) {
|
|
136915
|
+
const out = {};
|
|
136916
|
+
headers2.forEach((value, key) => {
|
|
136917
|
+
out[key] = value;
|
|
136918
|
+
});
|
|
136919
|
+
return out;
|
|
136920
|
+
}
|
|
136515
136921
|
function errorForResponse(status, message2, opts = {}) {
|
|
136516
136922
|
const { retryAfter, code: code2, url: url2, mitigated, details } = opts;
|
|
136517
136923
|
if (status === 409)
|
|
@@ -136566,7 +136972,7 @@ function httpClientSpanAttributes(args) {
|
|
|
136566
136972
|
};
|
|
136567
136973
|
}
|
|
136568
136974
|
async function instrumentedFetch(opts) {
|
|
136569
|
-
const { method, url: url2, headers: headers2, body: body2, dispatcher: dispatcher2, peerService = "workflow-server", timeoutMs = getRequestTimeoutMs(), signal: callerSignal, injectTraceContext: injectTraceContext2 = true, cacheBust = true, logLabel, buildError, spanName, attributes, durationAttribute } = opts;
|
|
136975
|
+
const { method, url: url2, headers: headers2, body: body2, dispatcher: dispatcher2, peerService = "workflow-server", timeoutMs = getRequestTimeoutMs(), signal: callerSignal, injectTraceContext: injectTraceContext2 = true, cacheBust = true, logLabel, buildError, spanName, attributes, durationAttribute, onTransportOutcome } = opts;
|
|
136570
136976
|
const label = logLabel ?? url2;
|
|
136571
136977
|
return trace(spanName ?? `http ${method}`, { kind: await getSpanKind("CLIENT") }, async (span) => {
|
|
136572
136978
|
var _a3, _b2, _c2;
|
|
@@ -136601,6 +137007,7 @@ async function instrumentedFetch(opts) {
|
|
|
136601
137007
|
});
|
|
136602
137008
|
} catch (error2) {
|
|
136603
137009
|
const elapsed = Date.now() - start2;
|
|
137010
|
+
onTransportOutcome == null ? void 0 : onTransportOutcome(error2);
|
|
136604
137011
|
if (error2 instanceof Error && (error2.name === "TimeoutError" || error2.name === "AbortError")) {
|
|
136605
137012
|
const timeoutError = new WorkflowWorldError(`${method} ${label} timed out after ${elapsed}ms`, { url: url2, cause: error2 });
|
|
136606
137013
|
span == null ? void 0 : span.setAttributes({ ...ErrorType("TIMEOUT") });
|
|
@@ -136610,6 +137017,7 @@ async function instrumentedFetch(opts) {
|
|
|
136610
137017
|
throw error2;
|
|
136611
137018
|
}
|
|
136612
137019
|
const ms2 = Date.now() - start2;
|
|
137020
|
+
onTransportOutcome == null ? void 0 : onTransportOutcome();
|
|
136613
137021
|
httpLog(method, label, response2, ms2);
|
|
136614
137022
|
span == null ? void 0 : span.setAttributes({ ...HttpResponseStatusCode(response2.status) });
|
|
136615
137023
|
if (durationAttribute)
|
|
@@ -136633,7 +137041,7 @@ async function instrumentedFetch(opts) {
|
|
|
136633
137041
|
return response2;
|
|
136634
137042
|
});
|
|
136635
137043
|
}
|
|
136636
|
-
const version = "5.0.0-beta.
|
|
137044
|
+
const version = "5.0.0-beta.37";
|
|
136637
137045
|
const IDEMPOTENT_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD"]);
|
|
136638
137046
|
const MAX_BODY_PARSE_RETRIES = 2;
|
|
136639
137047
|
const BODY_PARSE_RETRY_BASE_MS = 100;
|
|
@@ -137377,7 +137785,7 @@ function createGetEncryptionKeyForRun(projectId, teamId, token, dispatcher2) {
|
|
|
137377
137785
|
};
|
|
137378
137786
|
}
|
|
137379
137787
|
async function getDeadline() {
|
|
137380
|
-
const { getDeadline: getDeadline2 } = await import("./index-
|
|
137788
|
+
const { getDeadline: getDeadline2 } = await import("./index-DTci39F3.js").then((n) => n.i);
|
|
137381
137789
|
return getDeadline2();
|
|
137382
137790
|
}
|
|
137383
137791
|
const WORKFLOW_SERVER_SERVICE = {
|
|
@@ -142194,6 +142602,9 @@ var QueueClient = class {
|
|
|
142194
142602
|
function missingDeploymentIdMessage(operation) {
|
|
142195
142603
|
return `${operation} requires VERCEL_DEPLOYMENT_ID, which Vercel sets in every deployment, so this process is not running inside one. The Vercel world is only selected automatically when that variable is set, so it was requested explicitly here — most often by WORKFLOW_TARGET_WORLD=vercel in a process that is not a deployment, such as a production server started locally or in CI. To use the local filesystem world instead, set WORKFLOW_TARGET_WORLD=local or unset it.`;
|
|
142196
142604
|
}
|
|
142605
|
+
function isWsEventsTransportEnabled() {
|
|
142606
|
+
return process.env.WORKFLOW_EVENTS_TRANSPORT === "ws";
|
|
142607
|
+
}
|
|
142197
142608
|
class CborTransport {
|
|
142198
142609
|
constructor() {
|
|
142199
142610
|
__publicField(this, "contentType", "application/cbor");
|
|
@@ -142288,6 +142699,37 @@ function getRunIdFromPayload(payload) {
|
|
|
142288
142699
|
}
|
|
142289
142700
|
return void 0;
|
|
142290
142701
|
}
|
|
142702
|
+
const wsEventsChannelForInvocation = (runId, config2) => {
|
|
142703
|
+
let claim;
|
|
142704
|
+
return {
|
|
142705
|
+
/**
|
|
142706
|
+
* Unawaited and failure-proof: callers treat the handshake as free. The
|
|
142707
|
+
* refcount therefore rises a microtask late, so a write racing the import
|
|
142708
|
+
* finds no channel and goes over HTTP — one frame, not the invocation,
|
|
142709
|
+
* since `close` awaits this same promise and so cannot release ahead of
|
|
142710
|
+
* the claim it is releasing.
|
|
142711
|
+
*/
|
|
142712
|
+
open() {
|
|
142713
|
+
if (!runId || !isWsEventsTransportEnabled())
|
|
142714
|
+
return;
|
|
142715
|
+
claim = import("./ws-transport-2gJL6hC2.js").then(({ openWsChannel }) => openWsChannel(runId, config2)).catch(() => void 0);
|
|
142716
|
+
},
|
|
142717
|
+
/**
|
|
142718
|
+
* Awaited, unlike the open: work scheduled after the handler returns is not
|
|
142719
|
+
* guaranteed to run, and an open socket is not `unref`'d, so skipping this
|
|
142720
|
+
* stops the process exiting and keeps a server invocation pinned.
|
|
142721
|
+
*
|
|
142722
|
+
* Releases the claim the open returned rather than re-resolving the run,
|
|
142723
|
+
* which is what keeps a channel this invocation never opened — a later
|
|
142724
|
+
* invocation's, registered under the same URL after ours was evicted — out
|
|
142725
|
+
* of reach of our release.
|
|
142726
|
+
*/
|
|
142727
|
+
async close() {
|
|
142728
|
+
const release = await claim;
|
|
142729
|
+
release == null ? void 0 : release();
|
|
142730
|
+
}
|
|
142731
|
+
};
|
|
142732
|
+
};
|
|
142291
142733
|
const RUN_ID_PREFIX = "wrun_";
|
|
142292
142734
|
function regionFromTaggedRunId(runId) {
|
|
142293
142735
|
if (!runId)
|
|
@@ -142432,15 +142874,21 @@ function createQueue$1(config2) {
|
|
|
142432
142874
|
}
|
|
142433
142875
|
const requestId = requestIdStorage.getStore();
|
|
142434
142876
|
const { payload, queueName, deploymentId } = MessageWrapper.parse(message2);
|
|
142435
|
-
const
|
|
142436
|
-
|
|
142437
|
-
|
|
142438
|
-
|
|
142439
|
-
|
|
142440
|
-
|
|
142441
|
-
|
|
142442
|
-
|
|
142443
|
-
|
|
142877
|
+
const wsEvents = wsEventsChannelForInvocation(getRunIdFromPayload(payload), config2);
|
|
142878
|
+
wsEvents.open();
|
|
142879
|
+
try {
|
|
142880
|
+
const result = await handler(payload, {
|
|
142881
|
+
queueName,
|
|
142882
|
+
messageId: MessageId.parse(metadata.messageId),
|
|
142883
|
+
attempt: metadata.deliveryCount,
|
|
142884
|
+
requestId
|
|
142885
|
+
});
|
|
142886
|
+
if (typeof (result == null ? void 0 : result.timeoutSeconds) === "number") {
|
|
142887
|
+
const delaySeconds = result.timeoutSeconds > 0 ? Math.min(result.timeoutSeconds, MAX_DELAY_SECONDS) : void 0;
|
|
142888
|
+
await queue(queueName, payload, { deploymentId, delaySeconds });
|
|
142889
|
+
}
|
|
142890
|
+
} finally {
|
|
142891
|
+
await wsEvents.close();
|
|
142444
142892
|
}
|
|
142445
142893
|
}, {
|
|
142446
142894
|
// Without an explicit retry directive, @vercel/queue leaves failed
|
|
@@ -142517,15 +142965,6 @@ function createResolveLatestDeploymentId(config2) {
|
|
|
142517
142965
|
return result.data.id;
|
|
142518
142966
|
};
|
|
142519
142967
|
}
|
|
142520
|
-
function coerceEventDates(raw2) {
|
|
142521
|
-
const parsed = EventSchema.safeParse(raw2);
|
|
142522
|
-
if (parsed.success)
|
|
142523
|
-
return parsed.data;
|
|
142524
|
-
if (EventTypeSchema.safeParse(raw2.eventType).success) {
|
|
142525
|
-
console.debug(`[workflow:world-vercel] v4 event ${raw2.eventId} failed EventSchema parse for known eventType '${raw2.eventType}'; passing through unparsed: ${parsed.error.message}`);
|
|
142526
|
-
}
|
|
142527
|
-
return raw2;
|
|
142528
|
-
}
|
|
142529
142968
|
const EVENT_RETRY_ELIGIBILITY = {
|
|
142530
142969
|
// Creates: conditional create → 409 EntityConflictError if it already exists.
|
|
142531
142970
|
run_created: {
|
|
@@ -142651,6 +143090,8 @@ function isRetryableEventPostError(err) {
|
|
|
142651
143090
|
if (WorkflowWorldError.is(err)) {
|
|
142652
143091
|
if (err.code === "PARSE_ERROR")
|
|
142653
143092
|
return true;
|
|
143093
|
+
if (err.code === "TRANSPORT")
|
|
143094
|
+
return true;
|
|
142654
143095
|
if (typeof err.status === "number") {
|
|
142655
143096
|
return err.status >= 500 && err.status <= 599;
|
|
142656
143097
|
}
|
|
@@ -142702,6 +143143,7 @@ async function withEventPostRetry(fn2, eventType, options) {
|
|
|
142702
143143
|
}
|
|
142703
143144
|
}
|
|
142704
143145
|
const V4_FRAME_CONTENT_TYPE = "application/vnd.workflow.v4-frames";
|
|
143146
|
+
const CborObjectSchema = record(string$3(), unknown$1());
|
|
142705
143147
|
function encodeFrame(meta2, body2) {
|
|
142706
143148
|
const metaBytes = new Uint8Array(encode$1(meta2));
|
|
142707
143149
|
const out = new Uint8Array(4 + metaBytes.byteLength + 4 + body2.byteLength);
|
|
@@ -142743,7 +143185,7 @@ async function* decodeFrames(source) {
|
|
|
142743
143185
|
if (!await refill(metaLen)) {
|
|
142744
143186
|
throw new Error("decodeFrames: truncated meta block");
|
|
142745
143187
|
}
|
|
142746
|
-
const meta2 = decode$1(take(metaLen));
|
|
143188
|
+
const meta2 = CborObjectSchema.parse(decode$1(take(metaLen)));
|
|
142747
143189
|
if (!await refill(4)) {
|
|
142748
143190
|
throw new Error("decodeFrames: truncated body length");
|
|
142749
143191
|
}
|
|
@@ -142784,35 +143226,260 @@ async function* readerToIterator(reader) {
|
|
|
142784
143226
|
closeQuietly(() => reader.cancel());
|
|
142785
143227
|
}
|
|
142786
143228
|
}
|
|
143229
|
+
const FORMAT_PREFIX_LENGTH = 4;
|
|
143230
|
+
const DEVALUE_FORMAT_PREFIX = "devl";
|
|
143231
|
+
const ENCRYPTED_FORMAT_PREFIX = "encr";
|
|
143232
|
+
const GZIP_FORMAT_PREFIX = "gzip";
|
|
143233
|
+
const ZSTD_FORMAT_PREFIX = "zstd";
|
|
143234
|
+
const formatDecoder = new TextDecoder();
|
|
143235
|
+
const SERIALIZED_DATA_FORMAT_PREFIXES = /* @__PURE__ */ new Set([
|
|
143236
|
+
DEVALUE_FORMAT_PREFIX,
|
|
143237
|
+
ENCRYPTED_FORMAT_PREFIX,
|
|
143238
|
+
GZIP_FORMAT_PREFIX,
|
|
143239
|
+
ZSTD_FORMAT_PREFIX
|
|
143240
|
+
]);
|
|
143241
|
+
function getNodeZlib() {
|
|
143242
|
+
var _a3, _b2;
|
|
143243
|
+
try {
|
|
143244
|
+
return (_b2 = (_a3 = globalThis.process) == null ? void 0 : _a3.getBuiltinModule) == null ? void 0 : _b2.call(_a3, "node:zlib");
|
|
143245
|
+
} catch {
|
|
143246
|
+
return void 0;
|
|
143247
|
+
}
|
|
143248
|
+
}
|
|
143249
|
+
function peekFormatPrefix(value) {
|
|
143250
|
+
if (!(value instanceof Uint8Array) || value.byteLength < FORMAT_PREFIX_LENGTH) {
|
|
143251
|
+
return null;
|
|
143252
|
+
}
|
|
143253
|
+
return formatDecoder.decode(value.subarray(0, FORMAT_PREFIX_LENGTH));
|
|
143254
|
+
}
|
|
143255
|
+
function hasSerializedDataFormatPrefix(value) {
|
|
143256
|
+
const format2 = peekFormatPrefix(value);
|
|
143257
|
+
return format2 !== null && SERIALIZED_DATA_FORMAT_PREFIXES.has(format2);
|
|
143258
|
+
}
|
|
143259
|
+
function decompress(format2, payload) {
|
|
143260
|
+
const zlib = getNodeZlib();
|
|
143261
|
+
const decompress2 = format2 === ZSTD_FORMAT_PREFIX ? zlib == null ? void 0 : zlib.zstdDecompressSync : zlib == null ? void 0 : zlib.gunzipSync;
|
|
143262
|
+
if (!decompress2) {
|
|
143263
|
+
throw new WorkflowWorldError(`Received ${format2}-compressed workflow data, but this Node.js runtime does not support ${format2} decompression. Use a compatible Node.js runtime or request unresolved data.`);
|
|
143264
|
+
}
|
|
143265
|
+
return new Uint8Array(decompress2(payload));
|
|
143266
|
+
}
|
|
143267
|
+
function normalizeSerializedData(value) {
|
|
143268
|
+
const format2 = peekFormatPrefix(value);
|
|
143269
|
+
if (format2 !== ZSTD_FORMAT_PREFIX && format2 !== GZIP_FORMAT_PREFIX) {
|
|
143270
|
+
return value;
|
|
143271
|
+
}
|
|
143272
|
+
const bytes = value;
|
|
143273
|
+
return decompress(format2, bytes.subarray(FORMAT_PREFIX_LENGTH));
|
|
143274
|
+
}
|
|
143275
|
+
function normalizeWorkflowRunData(run2) {
|
|
143276
|
+
return {
|
|
143277
|
+
...run2,
|
|
143278
|
+
input: normalizeSerializedData(run2.input),
|
|
143279
|
+
output: normalizeSerializedData(run2.output),
|
|
143280
|
+
error: normalizeSerializedData(run2.error)
|
|
143281
|
+
};
|
|
143282
|
+
}
|
|
143283
|
+
function normalizeStepData(step) {
|
|
143284
|
+
return {
|
|
143285
|
+
...step,
|
|
143286
|
+
input: normalizeSerializedData(step.input),
|
|
143287
|
+
output: normalizeSerializedData(step.output),
|
|
143288
|
+
error: normalizeSerializedData(step.error)
|
|
143289
|
+
};
|
|
143290
|
+
}
|
|
143291
|
+
function normalizeHookData(hook) {
|
|
143292
|
+
return {
|
|
143293
|
+
...hook,
|
|
143294
|
+
metadata: normalizeSerializedData(hook.metadata)
|
|
143295
|
+
};
|
|
143296
|
+
}
|
|
143297
|
+
const StepWireSchema = StepSchema.omit({
|
|
143298
|
+
error: true
|
|
143299
|
+
}).extend({
|
|
143300
|
+
error: union([SerializedDataSchema, any()]).optional(),
|
|
143301
|
+
errorRef: any().optional()
|
|
143302
|
+
});
|
|
143303
|
+
const StepWireWithRefsSchema = StepWireSchema.omit({
|
|
143304
|
+
input: true,
|
|
143305
|
+
output: true
|
|
143306
|
+
}).extend({
|
|
143307
|
+
// We discard the results of the refs, so we don't care about the type here
|
|
143308
|
+
inputRef: any().optional(),
|
|
143309
|
+
outputRef: any().optional(),
|
|
143310
|
+
input: _instanceof(Uint8Array).optional(),
|
|
143311
|
+
output: _instanceof(Uint8Array).optional()
|
|
143312
|
+
});
|
|
143313
|
+
function deserializeStep(wireStep) {
|
|
143314
|
+
const { error: error2, errorRef, ...rest } = wireStep;
|
|
143315
|
+
const result = { ...rest };
|
|
143316
|
+
const errorSource = error2 ?? errorRef;
|
|
143317
|
+
if (errorSource !== void 0 && errorSource !== null) {
|
|
143318
|
+
result.error = errorSource;
|
|
143319
|
+
}
|
|
143320
|
+
return result;
|
|
143321
|
+
}
|
|
143322
|
+
function filterStepData(step, resolveData) {
|
|
143323
|
+
if (resolveData === "none") {
|
|
143324
|
+
const { inputRef: _inputRef, outputRef: _outputRef, ...rest } = step;
|
|
143325
|
+
const deserialized = normalizeStepData(deserializeStep(rest));
|
|
143326
|
+
return {
|
|
143327
|
+
...deserialized,
|
|
143328
|
+
input: void 0,
|
|
143329
|
+
output: void 0
|
|
143330
|
+
};
|
|
143331
|
+
}
|
|
143332
|
+
return normalizeStepData(deserializeStep(step));
|
|
143333
|
+
}
|
|
143334
|
+
async function listWorkflowRunSteps(params, config2) {
|
|
143335
|
+
const { runId, pagination, resolveData = DEFAULT_RESOLVE_DATA_OPTION } = params;
|
|
143336
|
+
const searchParams = new URLSearchParams();
|
|
143337
|
+
if (pagination == null ? void 0 : pagination.cursor)
|
|
143338
|
+
searchParams.set("cursor", pagination.cursor);
|
|
143339
|
+
if (pagination == null ? void 0 : pagination.limit)
|
|
143340
|
+
searchParams.set("limit", pagination.limit.toString());
|
|
143341
|
+
if (pagination == null ? void 0 : pagination.sortOrder)
|
|
143342
|
+
searchParams.set("sortOrder", pagination.sortOrder);
|
|
143343
|
+
const remoteRefBehavior = resolveData === "none" ? "lazy" : "resolve";
|
|
143344
|
+
searchParams.set("remoteRefBehavior", remoteRefBehavior);
|
|
143345
|
+
const queryString = searchParams.toString();
|
|
143346
|
+
const endpoint = `/v2/runs/${encodeURIComponent(runId)}/steps${queryString ? `?${queryString}` : ""}`;
|
|
143347
|
+
const response2 = await makeRequest({
|
|
143348
|
+
endpoint,
|
|
143349
|
+
options: { method: "GET" },
|
|
143350
|
+
config: config2,
|
|
143351
|
+
schema: PaginatedResponseSchema(remoteRefBehavior === "lazy" ? StepWireWithRefsSchema : StepWireSchema)
|
|
143352
|
+
});
|
|
143353
|
+
return {
|
|
143354
|
+
...response2,
|
|
143355
|
+
data: response2.data.map((step) => filterStepData(step, resolveData))
|
|
143356
|
+
};
|
|
143357
|
+
}
|
|
143358
|
+
async function getStep(runId, stepId, params, config2) {
|
|
143359
|
+
const resolveData = (params == null ? void 0 : params.resolveData) ?? DEFAULT_RESOLVE_DATA_OPTION;
|
|
143360
|
+
const remoteRefBehavior = resolveData === "none" ? "lazy" : "resolve";
|
|
143361
|
+
const searchParams = new URLSearchParams();
|
|
143362
|
+
searchParams.set("remoteRefBehavior", remoteRefBehavior);
|
|
143363
|
+
const queryString = searchParams.toString();
|
|
143364
|
+
const endpoint = `/v2/runs/${encodeURIComponent(runId)}/steps/${encodeURIComponent(stepId)}${queryString ? `?${queryString}` : ""}`;
|
|
143365
|
+
const step = await makeRequest({
|
|
143366
|
+
endpoint,
|
|
143367
|
+
options: { method: "GET" },
|
|
143368
|
+
config: config2,
|
|
143369
|
+
schema: remoteRefBehavior === "lazy" ? StepWireWithRefsSchema : StepWireSchema
|
|
143370
|
+
});
|
|
143371
|
+
return filterStepData(step, resolveData);
|
|
143372
|
+
}
|
|
142787
143373
|
async function fetchV4(url2, init2, config2, opName) {
|
|
143374
|
+
const dispatcher2 = getEventsDispatcher(config2);
|
|
142788
143375
|
return instrumentedFetch({
|
|
142789
143376
|
method: init2.method,
|
|
142790
143377
|
url: url2,
|
|
142791
143378
|
headers: init2.headers,
|
|
142792
143379
|
body: init2.body,
|
|
142793
|
-
dispatcher:
|
|
143380
|
+
dispatcher: dispatcher2,
|
|
143381
|
+
// Repeated transport failures retire the shared events pool and the next
|
|
143382
|
+
// request builds a fresh one. undici keeps a black-holed HTTP/2 session in
|
|
143383
|
+
// service indefinitely, so without this every request routed onto it fails
|
|
143384
|
+
// until the compute instance is recycled — see noteEventsTransportOutcome.
|
|
143385
|
+
onTransportOutcome: (error2) => noteEventsTransportOutcome(dispatcher2, error2),
|
|
142794
143386
|
timeoutMs: null,
|
|
142795
143387
|
logLabel: opName,
|
|
142796
|
-
|
|
143388
|
+
// Read the body as bytes, not text: a CBOR error body (the fence 412
|
|
143389
|
+
// carries event payloads back) does not survive a UTF-8 decode.
|
|
143390
|
+
buildError: async (response2) => errorFromV4Response(response2.status, headersToRecord(response2.headers), new Uint8Array(await response2.arrayBuffer()), opName, url2)
|
|
142797
143391
|
});
|
|
142798
143392
|
}
|
|
142799
|
-
|
|
142800
|
-
|
|
142801
|
-
|
|
142802
|
-
|
|
143393
|
+
const EVENT_ID_HEADER = "x-wf-event-id";
|
|
143394
|
+
const MAX_EVENTS_HEADER = "x-wf-max-events";
|
|
143395
|
+
const CreateEventV4BodyBaseSchema = object$1({
|
|
143396
|
+
event: EventSchema,
|
|
143397
|
+
run: WorkflowRunSchema.optional(),
|
|
143398
|
+
step: StepWireSchema.transform(deserializeStep).optional(),
|
|
143399
|
+
hook: HookSchema.optional(),
|
|
143400
|
+
wait: WaitSchema.optional(),
|
|
143401
|
+
stepCreated: literal(true).optional(),
|
|
143402
|
+
maxEvents: number$3().int().positive().optional()
|
|
143403
|
+
});
|
|
143404
|
+
const CreateEventV4PageSchema = union([
|
|
143405
|
+
object$1({
|
|
143406
|
+
events: array$1(EventSchema),
|
|
143407
|
+
cursor: string$3().nullable(),
|
|
143408
|
+
hasMore: boolean$3()
|
|
143409
|
+
}),
|
|
143410
|
+
object$1({
|
|
143411
|
+
events: _undefined(),
|
|
143412
|
+
cursor: _undefined(),
|
|
143413
|
+
hasMore: _undefined()
|
|
143414
|
+
})
|
|
143415
|
+
]);
|
|
143416
|
+
const CreateEventV4BodySchema = CreateEventV4BodyBaseSchema.and(CreateEventV4PageSchema);
|
|
143417
|
+
const CreateEventV4BodySchemas = {
|
|
143418
|
+
run_created: CreateEventV4BodyBaseSchema.extend({
|
|
143419
|
+
run: WorkflowRunSchema
|
|
143420
|
+
}).and(CreateEventV4PageSchema),
|
|
143421
|
+
run_started: CreateEventV4BodyBaseSchema.extend({
|
|
143422
|
+
run: WorkflowRunSchema.and(object$1({ startedAt: date$2() }))
|
|
143423
|
+
}).and(CreateEventV4PageSchema),
|
|
143424
|
+
step_started: CreateEventV4BodyBaseSchema.extend({
|
|
143425
|
+
step: StepWireSchema.extend({
|
|
143426
|
+
startedAt: date$2()
|
|
143427
|
+
}).transform((step) => ({
|
|
143428
|
+
...deserializeStep(step),
|
|
143429
|
+
startedAt: step.startedAt
|
|
143430
|
+
}))
|
|
143431
|
+
}).and(CreateEventV4PageSchema),
|
|
143432
|
+
run_completed: CreateEventV4BodySchema,
|
|
143433
|
+
run_failed: CreateEventV4BodySchema,
|
|
143434
|
+
run_cancelled: CreateEventV4BodySchema,
|
|
143435
|
+
attr_set: CreateEventV4BodySchema,
|
|
143436
|
+
step_created: CreateEventV4BodySchema,
|
|
143437
|
+
step_completed: CreateEventV4BodySchema,
|
|
143438
|
+
step_failed: CreateEventV4BodySchema,
|
|
143439
|
+
step_retrying: CreateEventV4BodySchema,
|
|
143440
|
+
hook_created: CreateEventV4BodySchema,
|
|
143441
|
+
hook_received: CreateEventV4BodySchema,
|
|
143442
|
+
hook_disposed: CreateEventV4BodySchema,
|
|
143443
|
+
hook_conflict: CreateEventV4BodySchema,
|
|
143444
|
+
wait_created: CreateEventV4BodySchema,
|
|
143445
|
+
wait_completed: CreateEventV4BodySchema
|
|
143446
|
+
};
|
|
143447
|
+
const MaxEventsHeaderSchema = number$2().int().positive();
|
|
143448
|
+
const EventStreamEndSchema = object$1({
|
|
143449
|
+
_end: literal(1),
|
|
143450
|
+
next: string$3().optional(),
|
|
143451
|
+
hasMore: boolean$3()
|
|
143452
|
+
});
|
|
143453
|
+
const legacyStructuredErrorEventTypes = /* @__PURE__ */ new Set([
|
|
143454
|
+
"run_failed",
|
|
143455
|
+
"step_failed",
|
|
143456
|
+
"step_retrying"
|
|
143457
|
+
]);
|
|
143458
|
+
function decodeLegacyStructuredError(payload) {
|
|
143459
|
+
if (hasSerializedDataFormatPrefix(payload))
|
|
143460
|
+
return payload;
|
|
143461
|
+
try {
|
|
143462
|
+
const parsed = StructuredErrorSchema.safeParse(decode$1(payload.slice()));
|
|
143463
|
+
return parsed.success ? parsed.data : payload;
|
|
143464
|
+
} catch {
|
|
143465
|
+
return payload;
|
|
143466
|
+
}
|
|
143467
|
+
}
|
|
143468
|
+
function decodeEventFrame({ meta: meta2, body: body2 }) {
|
|
143469
|
+
const eventType = EventTypeSchema.parse(meta2.eventType);
|
|
143470
|
+
if (body2.byteLength === 0)
|
|
143471
|
+
return EventSchema.parse(meta2);
|
|
143472
|
+
const payloadField = getEventDataPayloadField(eventType);
|
|
143473
|
+
assert$1(payloadField, `Event type ${eventType} cannot carry a payload body`);
|
|
143474
|
+
assert$1(meta2.eventData && typeof meta2.eventData === "object");
|
|
143475
|
+
return EventSchema.parse({
|
|
143476
|
+
...meta2,
|
|
143477
|
+
eventData: {
|
|
143478
|
+
...meta2.eventData,
|
|
143479
|
+
[payloadField]: legacyStructuredErrorEventTypes.has(eventType) ? decodeLegacyStructuredError(body2) : body2
|
|
143480
|
+
}
|
|
142803
143481
|
});
|
|
142804
|
-
return out;
|
|
142805
143482
|
}
|
|
142806
|
-
const V4_RESPONSE_HEADERS = {
|
|
142807
|
-
eventId: "x-wf-event-id",
|
|
142808
|
-
runId: "x-wf-run-id",
|
|
142809
|
-
createdAt: "x-wf-created-at",
|
|
142810
|
-
/**
|
|
142811
|
-
* Server-owned per-run event ceiling. Set on streamed replay-log
|
|
142812
|
-
* responses, where there is no CBOR body to carry `maxEvents`.
|
|
142813
|
-
*/
|
|
142814
|
-
maxEvents: "x-wf-max-events"
|
|
142815
|
-
};
|
|
142816
143483
|
function buildPostFrameMeta(input) {
|
|
142817
143484
|
const meta2 = {
|
|
142818
143485
|
eventType: input.eventType,
|
|
@@ -142892,8 +143559,8 @@ function buildPostFrameMeta(input) {
|
|
|
142892
143559
|
}
|
|
142893
143560
|
if (input.sinceCursor !== void 0)
|
|
142894
143561
|
meta2.sinceCursor = input.sinceCursor;
|
|
142895
|
-
if (input.skipPreload
|
|
142896
|
-
meta2.skipPreload =
|
|
143562
|
+
if (input.skipPreload)
|
|
143563
|
+
meta2.skipPreload = true;
|
|
142897
143564
|
if (input.stateUpdatedAt !== void 0) {
|
|
142898
143565
|
meta2.stateUpdatedAt = input.stateUpdatedAt;
|
|
142899
143566
|
}
|
|
@@ -142902,6 +143569,8 @@ function buildPostFrameMeta(input) {
|
|
|
142902
143569
|
}
|
|
142903
143570
|
if (input.stateCursor !== void 0)
|
|
142904
143571
|
meta2.stateCursor = input.stateCursor;
|
|
143572
|
+
if (input.maxSlot !== void 0)
|
|
143573
|
+
meta2.maxSlot = input.maxSlot;
|
|
142905
143574
|
if (input.replayDivergenceCount !== void 0) {
|
|
142906
143575
|
meta2.replayDivergenceCount = input.replayDivergenceCount;
|
|
142907
143576
|
}
|
|
@@ -142914,17 +143583,16 @@ function errorFromV4Response(statusCode, responseHeaders, errorBody, opName, url
|
|
|
142914
143583
|
let message2 = `v4 ${opName} failed: HTTP ${statusCode}`;
|
|
142915
143584
|
let code2;
|
|
142916
143585
|
let details;
|
|
142917
|
-
|
|
142918
|
-
|
|
142919
|
-
if (typeof
|
|
142920
|
-
message2 =
|
|
142921
|
-
if (typeof
|
|
142922
|
-
code2 =
|
|
143586
|
+
const { record: record2, text: text2 } = parseV4ErrorBody(errorBody, readHeader(responseHeaders, "content-type"));
|
|
143587
|
+
if (record2) {
|
|
143588
|
+
if (typeof record2.message === "string")
|
|
143589
|
+
message2 = record2.message;
|
|
143590
|
+
if (typeof record2.code === "string")
|
|
143591
|
+
code2 = record2.code;
|
|
142923
143592
|
if (statusCode === 412)
|
|
142924
|
-
details = decodePreconditionDetails(
|
|
142925
|
-
}
|
|
142926
|
-
|
|
142927
|
-
message2 += ` ${errorBody}`;
|
|
143593
|
+
details = decodePreconditionDetails(record2);
|
|
143594
|
+
} else if (text2) {
|
|
143595
|
+
message2 += ` ${text2}`;
|
|
142928
143596
|
}
|
|
142929
143597
|
const retryAfter = parseRetryAfter(readHeader(responseHeaders, "retry-after"));
|
|
142930
143598
|
return errorForResponse(statusCode, message2, {
|
|
@@ -142935,6 +143603,27 @@ function errorFromV4Response(statusCode, responseHeaders, errorBody, opName, url
|
|
|
142935
143603
|
...details !== void 0 ? { details } : {}
|
|
142936
143604
|
});
|
|
142937
143605
|
}
|
|
143606
|
+
function parseV4ErrorBody(body2, contentType) {
|
|
143607
|
+
if (typeof body2 !== "string" && (contentType == null ? void 0 : contentType.includes("application/cbor"))) {
|
|
143608
|
+
try {
|
|
143609
|
+
const decoded = decode$1(body2.slice());
|
|
143610
|
+
if (typeof decoded === "object" && decoded !== null) {
|
|
143611
|
+
return { record: decoded };
|
|
143612
|
+
}
|
|
143613
|
+
} catch {
|
|
143614
|
+
}
|
|
143615
|
+
return {};
|
|
143616
|
+
}
|
|
143617
|
+
const text2 = typeof body2 === "string" ? body2 : new TextDecoder().decode(body2);
|
|
143618
|
+
try {
|
|
143619
|
+
const json2 = JSON.parse(text2);
|
|
143620
|
+
if (typeof json2 === "object" && json2 !== null) {
|
|
143621
|
+
return { record: json2 };
|
|
143622
|
+
}
|
|
143623
|
+
} catch {
|
|
143624
|
+
}
|
|
143625
|
+
return { text: text2 };
|
|
143626
|
+
}
|
|
142938
143627
|
function decodePreconditionDetails(json2) {
|
|
142939
143628
|
if (!Array.isArray(json2.events) || json2.events.length === 0)
|
|
142940
143629
|
return void 0;
|
|
@@ -142947,7 +143636,10 @@ function decodePreconditionDetails(json2) {
|
|
|
142947
143636
|
return void 0;
|
|
142948
143637
|
if (hasUnusablePayload(candidate))
|
|
142949
143638
|
return void 0;
|
|
142950
|
-
|
|
143639
|
+
const event = EventSchema.safeParse(candidate);
|
|
143640
|
+
if (!event.success)
|
|
143641
|
+
return void 0;
|
|
143642
|
+
events2.push(event.data);
|
|
142951
143643
|
}
|
|
142952
143644
|
return {
|
|
142953
143645
|
events: events2,
|
|
@@ -142969,49 +143661,118 @@ function hasUnusablePayload(candidate) {
|
|
|
142969
143661
|
return false;
|
|
142970
143662
|
return !(value instanceof Uint8Array);
|
|
142971
143663
|
}
|
|
142972
|
-
async function
|
|
143664
|
+
async function postWorkflowRunEventV4(input, responseType, config2) {
|
|
142973
143665
|
const { baseUrl, headers: baseHeaders } = await getHttpConfig(config2);
|
|
142974
143666
|
const headers2 = new Headers(baseHeaders);
|
|
142975
143667
|
headers2.set("Content-Type", "application/octet-stream");
|
|
143668
|
+
if (responseType === "event-stream") {
|
|
143669
|
+
headers2.set("Accept", V4_FRAME_CONTENT_TYPE);
|
|
143670
|
+
}
|
|
142976
143671
|
const frame2 = encodeFrame(buildPostFrameMeta(input), input.payload ?? new Uint8Array(0));
|
|
142977
143672
|
const url2 = `${baseUrl}/v4/runs/${encodeURIComponent(input.runId)}/events/${encodeURIComponent(input.eventType)}`;
|
|
142978
|
-
|
|
142979
|
-
return decodeMaterializedCreateEventResponse(response2);
|
|
143673
|
+
return fetchV4(url2, { method: "POST", headers: headers2, body: frame2 }, config2, "createEvent");
|
|
142980
143674
|
}
|
|
142981
|
-
async function
|
|
142982
|
-
|
|
142983
|
-
|
|
142984
|
-
|
|
142985
|
-
|
|
142986
|
-
throw new Error("v4 createEvent: response missing required x-wf-* headers");
|
|
143675
|
+
async function createWorkflowRunEventV4(input, config2) {
|
|
143676
|
+
if (isWsEventsTransportEnabled()) {
|
|
143677
|
+
const reply = await postEventFrameOverWs(input, config2);
|
|
143678
|
+
if (reply)
|
|
143679
|
+
return decodeCreateEventResponse(reply, input.eventType);
|
|
142987
143680
|
}
|
|
143681
|
+
const response2 = await postWorkflowRunEventV4(input, "materialized", config2);
|
|
143682
|
+
const contentType = response2.headers.get("content-type");
|
|
143683
|
+
if (contentType == null ? void 0 : contentType.startsWith(V4_FRAME_CONTENT_TYPE)) {
|
|
143684
|
+
throw new Error("v4 createEvent: unexpected event page");
|
|
143685
|
+
}
|
|
143686
|
+
return decodeCreateEventResponse(response2, input.eventType);
|
|
143687
|
+
}
|
|
143688
|
+
async function decodeCreateEventResponse(response2, eventType) {
|
|
142988
143689
|
const bodyBytes = new Uint8Array(await response2.arrayBuffer());
|
|
142989
|
-
|
|
142990
|
-
|
|
143690
|
+
if (bodyBytes.byteLength === 0) {
|
|
143691
|
+
throw new Error("v4 createEvent: empty response body");
|
|
143692
|
+
}
|
|
143693
|
+
const schema = CreateEventV4BodySchemas[eventType].refine(({ event }) => event.eventType === eventType || eventType === "hook_created" && event.eventType === "hook_conflict", { path: ["event", "eventType"] });
|
|
143694
|
+
const parsedBody = schema.safeParse(decode$1(bodyBytes));
|
|
143695
|
+
if (!parsedBody.success) {
|
|
143696
|
+
throw new WorkflowWorldError("v4 createEvent: invalid response body", {
|
|
143697
|
+
code: "SCHEMA_VALIDATION",
|
|
143698
|
+
cause: parsedBody.error
|
|
143699
|
+
});
|
|
143700
|
+
}
|
|
143701
|
+
return parsedBody.data;
|
|
143702
|
+
}
|
|
143703
|
+
async function createWorkflowRunStartedEventV4(input, config2) {
|
|
143704
|
+
const response2 = await postWorkflowRunEventV4({ ...input, eventType: "run_started" }, "event-stream", config2);
|
|
143705
|
+
const events2 = [];
|
|
143706
|
+
const page = await consumeEventFrameStream(response2, "createEvent", events2);
|
|
143707
|
+
assert$1(page.cursor, "v4 createEvent: event stream missing cursor");
|
|
143708
|
+
const maxEvents = MaxEventsHeaderSchema.safeParse(response2.headers.get(MAX_EVENTS_HEADER));
|
|
143709
|
+
if (!maxEvents.success) {
|
|
143710
|
+
throw new WorkflowWorldError("v4 createEvent: invalid max-events header", {
|
|
143711
|
+
code: "SCHEMA_VALIDATION",
|
|
143712
|
+
cause: maxEvents.error
|
|
143713
|
+
});
|
|
143714
|
+
}
|
|
143715
|
+
return { events: events2, ...page, maxEvents: maxEvents.data };
|
|
143716
|
+
}
|
|
143717
|
+
function replyMetaToHeaderRecord(meta2) {
|
|
143718
|
+
const out = {};
|
|
143719
|
+
if (typeof meta2.eventId === "string")
|
|
143720
|
+
out[EVENT_ID_HEADER] = meta2.eventId;
|
|
143721
|
+
if (typeof meta2.retryAfter === "string")
|
|
143722
|
+
out["retry-after"] = meta2.retryAfter;
|
|
143723
|
+
if (typeof meta2.mitigated === "string")
|
|
143724
|
+
out["x-vercel-mitigated"] = meta2.mitigated;
|
|
143725
|
+
return out;
|
|
143726
|
+
}
|
|
143727
|
+
function wsReplyStatus(reply, endpoint) {
|
|
143728
|
+
const { status } = reply.meta;
|
|
143729
|
+
if (typeof status !== "number") {
|
|
143730
|
+
throw new WorkflowWorldError(`Failed to parse response body for POST ${endpoint}: reply frame carried no numeric status (type: ${String(reply.meta.type ?? "absent")}). Refusing to treat an unrecognized reply as success — the write may or may not have been applied.`, { url: endpoint, code: "PARSE_ERROR" });
|
|
143731
|
+
}
|
|
143732
|
+
return status;
|
|
143733
|
+
}
|
|
143734
|
+
async function postEventFrameOverWs(input, config2) {
|
|
143735
|
+
const { resolveWsTransport } = await import("./ws-transport-2gJL6hC2.js");
|
|
143736
|
+
const { runId } = input;
|
|
143737
|
+
const resolved = resolveWsTransport(runId, config2);
|
|
143738
|
+
if (!resolved)
|
|
143739
|
+
return void 0;
|
|
143740
|
+
const { transport, wsUrl } = resolved;
|
|
143741
|
+
const endpoint = `${wsUrl}#runs/${encodeURIComponent(runId)}/events`;
|
|
143742
|
+
let reply;
|
|
143743
|
+
try {
|
|
143744
|
+
reply = await transport.request((reqId) => encodeFrame({ reqId, type: "event", event: buildPostFrameMeta(input) }, input.payload ?? new Uint8Array(0)));
|
|
143745
|
+
} catch (err) {
|
|
143746
|
+
throw new WorkflowWorldError(`POST ${endpoint} transport failure: ${err instanceof Error ? err.message : String(err)}`, { url: wsUrl, code: "TRANSPORT", cause: err });
|
|
143747
|
+
}
|
|
143748
|
+
const status = wsReplyStatus(reply, endpoint);
|
|
143749
|
+
const headerRecord = replyMetaToHeaderRecord(reply.meta);
|
|
143750
|
+
if (status < 200 || status >= 300) {
|
|
143751
|
+
throw errorFromV4Response(status, headerRecord, new TextDecoder().decode(reply.body), "createEvent", endpoint);
|
|
143752
|
+
}
|
|
143753
|
+
return {
|
|
143754
|
+
headers: { get: (name2) => headerRecord[name2.toLowerCase()] ?? null },
|
|
143755
|
+
arrayBuffer: async () => reply.body.slice().buffer
|
|
143756
|
+
};
|
|
142991
143757
|
}
|
|
142992
143758
|
async function createHookReceivedPreloadEventV4(input, config2) {
|
|
142993
|
-
const {
|
|
142994
|
-
const headers2 = new Headers(baseHeaders);
|
|
142995
|
-
headers2.set("Content-Type", "application/octet-stream");
|
|
142996
|
-
headers2.set("Accept", V4_FRAME_CONTENT_TYPE);
|
|
142997
|
-
const frame2 = encodeFrame(buildPostFrameMeta(input), input.payload ?? new Uint8Array(0));
|
|
142998
|
-
const url2 = `${baseUrl}/v4/runs/${encodeURIComponent(input.runId)}/events/${encodeURIComponent(input.eventType)}`;
|
|
142999
|
-
const response2 = await fetchV4(url2, { method: "POST", headers: headers2, body: frame2 }, config2, "createEvent");
|
|
143759
|
+
const response2 = await postWorkflowRunEventV4({ ...input, eventType: "hook_received" }, "event-stream", config2);
|
|
143000
143760
|
const contentType = response2.headers.get("content-type");
|
|
143001
143761
|
if (!(contentType == null ? void 0 : contentType.startsWith(V4_FRAME_CONTENT_TYPE))) {
|
|
143002
143762
|
return {
|
|
143003
143763
|
kind: "materialized",
|
|
143004
|
-
result: await
|
|
143764
|
+
result: await decodeCreateEventResponse(response2, "hook_received")
|
|
143005
143765
|
};
|
|
143006
143766
|
}
|
|
143007
|
-
const
|
|
143008
|
-
const
|
|
143009
|
-
const
|
|
143767
|
+
const events2 = [];
|
|
143768
|
+
const page = await consumeEventFrameStream(response2, "createEvent", events2);
|
|
143769
|
+
const maxEvents = MaxEventsHeaderSchema.safeParse(response2.headers.get(MAX_EVENTS_HEADER));
|
|
143010
143770
|
return {
|
|
143011
143771
|
kind: "stream",
|
|
143772
|
+
events: events2,
|
|
143012
143773
|
...page,
|
|
143013
|
-
canonicalEventId: response2.headers.get(
|
|
143014
|
-
maxEvents:
|
|
143774
|
+
canonicalEventId: response2.headers.get(EVENT_ID_HEADER) ?? void 0,
|
|
143775
|
+
maxEvents: maxEvents.success ? maxEvents.data : void 0
|
|
143015
143776
|
};
|
|
143016
143777
|
}
|
|
143017
143778
|
function readHeader(responseHeaders, name2) {
|
|
@@ -143022,9 +143783,9 @@ function readHeader(responseHeaders, name2) {
|
|
|
143022
143783
|
return value[0];
|
|
143023
143784
|
return void 0;
|
|
143024
143785
|
}
|
|
143025
|
-
async function getEventV4(runId, eventId, config2) {
|
|
143786
|
+
async function getEventV4(runId, eventId, remoteRefBehavior, config2) {
|
|
143026
143787
|
const { baseUrl, headers: headers2 } = await getHttpConfig(config2);
|
|
143027
|
-
const url2 = `${baseUrl}/v4/runs/${encodeURIComponent(runId)}/events/${encodeURIComponent(eventId)}`;
|
|
143788
|
+
const url2 = `${baseUrl}/v4/runs/${encodeURIComponent(runId)}/events/${encodeURIComponent(eventId)}?remoteRefBehavior=${remoteRefBehavior}`;
|
|
143028
143789
|
const response2 = await fetchV4(url2, { method: "GET", headers: headers2 }, config2, "getEvent");
|
|
143029
143790
|
const contentType = response2.headers.get("content-type");
|
|
143030
143791
|
if (!(contentType == null ? void 0 : contentType.startsWith(V4_FRAME_CONTENT_TYPE))) {
|
|
@@ -143032,46 +143793,31 @@ async function getEventV4(runId, eventId, config2) {
|
|
|
143032
143793
|
}
|
|
143033
143794
|
const chunks = response2.body;
|
|
143034
143795
|
for await (const frame2 of decodeFrames(chunks)) {
|
|
143035
|
-
return
|
|
143796
|
+
return decodeEventFrame(frame2);
|
|
143036
143797
|
}
|
|
143037
143798
|
throw new Error(`v4 getEvent: empty frame stream for ${eventId}`);
|
|
143038
143799
|
}
|
|
143039
|
-
async function
|
|
143040
|
-
const response2 = await fetchV4(url2, { method: "GET", headers: headers2 }, config2, opName);
|
|
143041
|
-
return decodeListFrameResponse(response2, opName);
|
|
143042
|
-
}
|
|
143043
|
-
async function decodeListFrameResponse(response2, opName) {
|
|
143800
|
+
async function consumeEventFrameStream(response2, opName, events2) {
|
|
143044
143801
|
const contentType = response2.headers.get("content-type");
|
|
143045
143802
|
if (!(contentType == null ? void 0 : contentType.startsWith(V4_FRAME_CONTENT_TYPE))) {
|
|
143046
143803
|
throw new Error(`v4 ${opName}: expected ${V4_FRAME_CONTENT_TYPE}, got ${contentType ?? "(none)"}`);
|
|
143047
143804
|
}
|
|
143048
143805
|
const chunks = response2.body;
|
|
143049
|
-
const events2 = [];
|
|
143050
|
-
let next2;
|
|
143051
|
-
let hasMore;
|
|
143052
|
-
let sawEndSentinel = false;
|
|
143053
143806
|
for await (const frame2 of decodeFrames(chunks)) {
|
|
143054
143807
|
if (frame2.meta._end === 1) {
|
|
143055
|
-
|
|
143056
|
-
|
|
143057
|
-
if (typeof frame2.meta.hasMore === "boolean")
|
|
143058
|
-
hasMore = frame2.meta.hasMore;
|
|
143059
|
-
sawEndSentinel = true;
|
|
143060
|
-
break;
|
|
143808
|
+
const end = EventStreamEndSchema.parse(frame2.meta);
|
|
143809
|
+
return { cursor: end.next ?? null, hasMore: end.hasMore };
|
|
143061
143810
|
}
|
|
143062
|
-
|
|
143063
|
-
|
|
143064
|
-
|
|
143065
|
-
|
|
143066
|
-
}
|
|
143067
|
-
if (!sawEndSentinel) {
|
|
143068
|
-
throw new Error(`v4 ${opName}: frame stream ended without the end-of-stream sentinel (${events2.length} events read) — truncated response?`);
|
|
143811
|
+
if (Object.keys(frame2.meta).some((key) => key.startsWith("_"))) {
|
|
143812
|
+
throw new Error(`v4 ${opName}: unexpected control frame`);
|
|
143813
|
+
}
|
|
143814
|
+
events2.push(decodeEventFrame(frame2));
|
|
143069
143815
|
}
|
|
143070
|
-
|
|
143071
|
-
|
|
143072
|
-
|
|
143073
|
-
|
|
143074
|
-
|
|
143816
|
+
throw new Error(`v4 ${opName}: frame stream ended without the end-of-stream sentinel (${events2.length} events read) — truncated response?`);
|
|
143817
|
+
}
|
|
143818
|
+
async function consumeListFrameStream(url2, headers2, config2, opName, events2) {
|
|
143819
|
+
const response2 = await fetchV4(url2, { method: "GET", headers: headers2 }, config2, opName);
|
|
143820
|
+
return consumeEventFrameStream(response2, opName, events2);
|
|
143075
143821
|
}
|
|
143076
143822
|
function appendListParams(sp, params) {
|
|
143077
143823
|
if (params.cursor)
|
|
@@ -143086,14 +143832,28 @@ function appendListParams(sp, params) {
|
|
|
143086
143832
|
}
|
|
143087
143833
|
function paginationToQuery(params) {
|
|
143088
143834
|
const sp = new URLSearchParams();
|
|
143835
|
+
if (params.limit === void 0)
|
|
143836
|
+
sp.set("returnAll", "true");
|
|
143089
143837
|
appendListParams(sp, params);
|
|
143090
|
-
|
|
143091
|
-
return qs ? `?${qs}` : "";
|
|
143838
|
+
return `?${sp.toString()}`;
|
|
143092
143839
|
}
|
|
143093
143840
|
async function getWorkflowRunEventsV4(runId, params = {}, config2) {
|
|
143094
143841
|
const { baseUrl, headers: headers2 } = await getHttpConfig(config2);
|
|
143095
|
-
const
|
|
143096
|
-
|
|
143842
|
+
const events2 = [];
|
|
143843
|
+
let cursor = params.cursor;
|
|
143844
|
+
while (true) {
|
|
143845
|
+
const url2 = `${baseUrl}/v4/runs/${encodeURIComponent(runId)}/events` + paginationToQuery({ ...params, cursor });
|
|
143846
|
+
try {
|
|
143847
|
+
const page = await consumeListFrameStream(url2, headers2, config2, "listEvents", events2);
|
|
143848
|
+
return { events: events2, ...page };
|
|
143849
|
+
} catch (error2) {
|
|
143850
|
+
const lastEvent = events2.at(-1);
|
|
143851
|
+
if (params.limit !== void 0 || !lastEvent || `eid:${lastEvent.eventId}` === cursor) {
|
|
143852
|
+
throw error2;
|
|
143853
|
+
}
|
|
143854
|
+
cursor = `eid:${lastEvent.eventId}`;
|
|
143855
|
+
}
|
|
143856
|
+
}
|
|
143097
143857
|
}
|
|
143098
143858
|
async function getEventsByCorrelationIdV4(correlationId, runId, params = {}, config2) {
|
|
143099
143859
|
const { baseUrl, headers: headers2 } = await getHttpConfig(config2);
|
|
@@ -143102,100 +143862,9 @@ async function getEventsByCorrelationIdV4(correlationId, runId, params = {}, con
|
|
|
143102
143862
|
sp.set("runId", runId);
|
|
143103
143863
|
appendListParams(sp, params);
|
|
143104
143864
|
const url2 = `${baseUrl}/v4/events?${sp.toString()}`;
|
|
143105
|
-
|
|
143106
|
-
|
|
143107
|
-
|
|
143108
|
-
const DEVALUE_FORMAT_PREFIX = "devl";
|
|
143109
|
-
const ENCRYPTED_FORMAT_PREFIX = "encr";
|
|
143110
|
-
const GZIP_FORMAT_PREFIX = "gzip";
|
|
143111
|
-
const ZSTD_FORMAT_PREFIX = "zstd";
|
|
143112
|
-
const formatDecoder = new TextDecoder();
|
|
143113
|
-
const SERIALIZED_DATA_FORMAT_PREFIXES = /* @__PURE__ */ new Set([
|
|
143114
|
-
DEVALUE_FORMAT_PREFIX,
|
|
143115
|
-
ENCRYPTED_FORMAT_PREFIX,
|
|
143116
|
-
GZIP_FORMAT_PREFIX,
|
|
143117
|
-
ZSTD_FORMAT_PREFIX
|
|
143118
|
-
]);
|
|
143119
|
-
function getNodeZlib() {
|
|
143120
|
-
var _a3, _b2;
|
|
143121
|
-
try {
|
|
143122
|
-
return (_b2 = (_a3 = globalThis.process) == null ? void 0 : _a3.getBuiltinModule) == null ? void 0 : _b2.call(_a3, "node:zlib");
|
|
143123
|
-
} catch {
|
|
143124
|
-
return void 0;
|
|
143125
|
-
}
|
|
143126
|
-
}
|
|
143127
|
-
function peekFormatPrefix(value) {
|
|
143128
|
-
if (!(value instanceof Uint8Array) || value.byteLength < FORMAT_PREFIX_LENGTH) {
|
|
143129
|
-
return null;
|
|
143130
|
-
}
|
|
143131
|
-
return formatDecoder.decode(value.subarray(0, FORMAT_PREFIX_LENGTH));
|
|
143132
|
-
}
|
|
143133
|
-
function hasSerializedDataFormatPrefix(value) {
|
|
143134
|
-
const format2 = peekFormatPrefix(value);
|
|
143135
|
-
return format2 !== null && SERIALIZED_DATA_FORMAT_PREFIXES.has(format2);
|
|
143136
|
-
}
|
|
143137
|
-
function decompress(format2, payload) {
|
|
143138
|
-
const zlib = getNodeZlib();
|
|
143139
|
-
const decompress2 = format2 === ZSTD_FORMAT_PREFIX ? zlib == null ? void 0 : zlib.zstdDecompressSync : zlib == null ? void 0 : zlib.gunzipSync;
|
|
143140
|
-
if (!decompress2) {
|
|
143141
|
-
throw new WorkflowWorldError(`Received ${format2}-compressed workflow data, but this Node.js runtime does not support ${format2} decompression. Use a compatible Node.js runtime or request unresolved data.`);
|
|
143142
|
-
}
|
|
143143
|
-
return new Uint8Array(decompress2(payload));
|
|
143144
|
-
}
|
|
143145
|
-
function normalizeSerializedData(value) {
|
|
143146
|
-
const format2 = peekFormatPrefix(value);
|
|
143147
|
-
if (format2 !== ZSTD_FORMAT_PREFIX && format2 !== GZIP_FORMAT_PREFIX) {
|
|
143148
|
-
return value;
|
|
143149
|
-
}
|
|
143150
|
-
const bytes = value;
|
|
143151
|
-
return decompress(format2, bytes.subarray(FORMAT_PREFIX_LENGTH));
|
|
143152
|
-
}
|
|
143153
|
-
function normalizeWorkflowRunData(run2) {
|
|
143154
|
-
return {
|
|
143155
|
-
...run2,
|
|
143156
|
-
input: normalizeSerializedData(run2.input),
|
|
143157
|
-
output: normalizeSerializedData(run2.output),
|
|
143158
|
-
error: normalizeSerializedData(run2.error)
|
|
143159
|
-
};
|
|
143160
|
-
}
|
|
143161
|
-
function normalizeStepData(step) {
|
|
143162
|
-
return {
|
|
143163
|
-
...step,
|
|
143164
|
-
input: normalizeSerializedData(step.input),
|
|
143165
|
-
output: normalizeSerializedData(step.output),
|
|
143166
|
-
error: normalizeSerializedData(step.error)
|
|
143167
|
-
};
|
|
143168
|
-
}
|
|
143169
|
-
function normalizeHookData(hook) {
|
|
143170
|
-
return {
|
|
143171
|
-
...hook,
|
|
143172
|
-
metadata: normalizeSerializedData(hook.metadata)
|
|
143173
|
-
};
|
|
143174
|
-
}
|
|
143175
|
-
function normalizeEventData(event) {
|
|
143176
|
-
const eventData = event.eventData;
|
|
143177
|
-
if (!eventData || typeof eventData !== "object") {
|
|
143178
|
-
return event;
|
|
143179
|
-
}
|
|
143180
|
-
const eventType = typeof event.eventType === "string" ? event.eventType : "";
|
|
143181
|
-
const refFields = getEventDataRefFields(eventType);
|
|
143182
|
-
if (refFields.length === 0) {
|
|
143183
|
-
return event;
|
|
143184
|
-
}
|
|
143185
|
-
const normalizedEventData = { ...eventData };
|
|
143186
|
-
let changed = false;
|
|
143187
|
-
for (const field of refFields) {
|
|
143188
|
-
if (!(field in normalizedEventData)) {
|
|
143189
|
-
continue;
|
|
143190
|
-
}
|
|
143191
|
-
const before = normalizedEventData[field];
|
|
143192
|
-
const after = normalizeSerializedData(before);
|
|
143193
|
-
if (after !== before) {
|
|
143194
|
-
normalizedEventData[field] = after;
|
|
143195
|
-
changed = true;
|
|
143196
|
-
}
|
|
143197
|
-
}
|
|
143198
|
-
return changed ? { ...event, eventData: normalizedEventData } : event;
|
|
143865
|
+
const events2 = [];
|
|
143866
|
+
const page = await consumeListFrameStream(url2, headers2, config2, "listEventsByCorrelationId", events2);
|
|
143867
|
+
return { events: events2, ...page };
|
|
143199
143868
|
}
|
|
143200
143869
|
const WorkflowRunWireBaseSchema = WorkflowRunBaseSchema.omit({
|
|
143201
143870
|
error: true,
|
|
@@ -143366,82 +144035,6 @@ async function experimentalSetAttributes(runId, changes, options, config2) {
|
|
|
143366
144035
|
throw error2;
|
|
143367
144036
|
}
|
|
143368
144037
|
}
|
|
143369
|
-
const StepWireSchema = StepSchema.omit({
|
|
143370
|
-
error: true
|
|
143371
|
-
}).extend({
|
|
143372
|
-
error: union([SerializedDataSchema, any()]).optional(),
|
|
143373
|
-
errorRef: any().optional()
|
|
143374
|
-
});
|
|
143375
|
-
const StepWireWithRefsSchema = StepWireSchema.omit({
|
|
143376
|
-
input: true,
|
|
143377
|
-
output: true
|
|
143378
|
-
}).extend({
|
|
143379
|
-
// We discard the results of the refs, so we don't care about the type here
|
|
143380
|
-
inputRef: any().optional(),
|
|
143381
|
-
outputRef: any().optional(),
|
|
143382
|
-
input: _instanceof(Uint8Array).optional(),
|
|
143383
|
-
output: _instanceof(Uint8Array).optional()
|
|
143384
|
-
});
|
|
143385
|
-
function deserializeStep(wireStep) {
|
|
143386
|
-
const { error: error2, errorRef, ...rest } = wireStep;
|
|
143387
|
-
const result = { ...rest };
|
|
143388
|
-
const errorSource = error2 ?? errorRef;
|
|
143389
|
-
if (errorSource !== void 0 && errorSource !== null) {
|
|
143390
|
-
result.error = errorSource;
|
|
143391
|
-
}
|
|
143392
|
-
return result;
|
|
143393
|
-
}
|
|
143394
|
-
function filterStepData(step, resolveData) {
|
|
143395
|
-
if (resolveData === "none") {
|
|
143396
|
-
const { inputRef: _inputRef, outputRef: _outputRef, ...rest } = step;
|
|
143397
|
-
const deserialized = normalizeStepData(deserializeStep(rest));
|
|
143398
|
-
return {
|
|
143399
|
-
...deserialized,
|
|
143400
|
-
input: void 0,
|
|
143401
|
-
output: void 0
|
|
143402
|
-
};
|
|
143403
|
-
}
|
|
143404
|
-
return normalizeStepData(deserializeStep(step));
|
|
143405
|
-
}
|
|
143406
|
-
async function listWorkflowRunSteps(params, config2) {
|
|
143407
|
-
const { runId, pagination, resolveData = DEFAULT_RESOLVE_DATA_OPTION } = params;
|
|
143408
|
-
const searchParams = new URLSearchParams();
|
|
143409
|
-
if (pagination == null ? void 0 : pagination.cursor)
|
|
143410
|
-
searchParams.set("cursor", pagination.cursor);
|
|
143411
|
-
if (pagination == null ? void 0 : pagination.limit)
|
|
143412
|
-
searchParams.set("limit", pagination.limit.toString());
|
|
143413
|
-
if (pagination == null ? void 0 : pagination.sortOrder)
|
|
143414
|
-
searchParams.set("sortOrder", pagination.sortOrder);
|
|
143415
|
-
const remoteRefBehavior = resolveData === "none" ? "lazy" : "resolve";
|
|
143416
|
-
searchParams.set("remoteRefBehavior", remoteRefBehavior);
|
|
143417
|
-
const queryString = searchParams.toString();
|
|
143418
|
-
const endpoint = `/v2/runs/${encodeURIComponent(runId)}/steps${queryString ? `?${queryString}` : ""}`;
|
|
143419
|
-
const response2 = await makeRequest({
|
|
143420
|
-
endpoint,
|
|
143421
|
-
options: { method: "GET" },
|
|
143422
|
-
config: config2,
|
|
143423
|
-
schema: PaginatedResponseSchema(remoteRefBehavior === "lazy" ? StepWireWithRefsSchema : StepWireSchema)
|
|
143424
|
-
});
|
|
143425
|
-
return {
|
|
143426
|
-
...response2,
|
|
143427
|
-
data: response2.data.map((step) => filterStepData(step, resolveData))
|
|
143428
|
-
};
|
|
143429
|
-
}
|
|
143430
|
-
async function getStep(runId, stepId, params, config2) {
|
|
143431
|
-
const resolveData = (params == null ? void 0 : params.resolveData) ?? DEFAULT_RESOLVE_DATA_OPTION;
|
|
143432
|
-
const remoteRefBehavior = resolveData === "none" ? "lazy" : "resolve";
|
|
143433
|
-
const searchParams = new URLSearchParams();
|
|
143434
|
-
searchParams.set("remoteRefBehavior", remoteRefBehavior);
|
|
143435
|
-
const queryString = searchParams.toString();
|
|
143436
|
-
const endpoint = `/v2/runs/${encodeURIComponent(runId)}/steps/${encodeURIComponent(stepId)}${queryString ? `?${queryString}` : ""}`;
|
|
143437
|
-
const step = await makeRequest({
|
|
143438
|
-
endpoint,
|
|
143439
|
-
options: { method: "GET" },
|
|
143440
|
-
config: config2,
|
|
143441
|
-
schema: remoteRefBehavior === "lazy" ? StepWireWithRefsSchema : StepWireSchema
|
|
143442
|
-
});
|
|
143443
|
-
return filterStepData(step, resolveData);
|
|
143444
|
-
}
|
|
143445
144038
|
function validateWorkflowRunIdTimestamp(id2) {
|
|
143446
144039
|
const raw2 = id2.startsWith("wrun_") ? id2.slice("wrun_".length) : id2;
|
|
143447
144040
|
try {
|
|
@@ -143458,11 +144051,6 @@ const eventsNeedingResolve = /* @__PURE__ */ new Set([
|
|
|
143458
144051
|
"step_started"
|
|
143459
144052
|
// runtime reads result.step (checks attempt, state)
|
|
143460
144053
|
]);
|
|
143461
|
-
const legacyStructuredErrorEventTypes = /* @__PURE__ */ new Set([
|
|
143462
|
-
"run_failed",
|
|
143463
|
-
"step_failed",
|
|
143464
|
-
"step_retrying"
|
|
143465
|
-
]);
|
|
143466
144054
|
function splitEventDataForV4(data) {
|
|
143467
144055
|
var _a3;
|
|
143468
144056
|
const eventData = data.eventData ?? {};
|
|
@@ -143566,83 +144154,43 @@ function splitEventDataForV4(data) {
|
|
|
143566
144154
|
}
|
|
143567
144155
|
return { payload, meta: meta2 };
|
|
143568
144156
|
}
|
|
143569
|
-
function coerceNormalizedEvent(raw2) {
|
|
143570
|
-
return coerceEventDates(normalizeEventData(raw2));
|
|
143571
|
-
}
|
|
143572
|
-
function decodeLegacyStructuredError(payload) {
|
|
143573
|
-
if (hasSerializedDataFormatPrefix(payload)) {
|
|
143574
|
-
return payload;
|
|
143575
|
-
}
|
|
143576
|
-
try {
|
|
143577
|
-
const parsed = StructuredErrorSchema.safeParse(decode$1(payload.slice()));
|
|
143578
|
-
return parsed.success ? parsed.data : payload;
|
|
143579
|
-
} catch {
|
|
143580
|
-
return payload;
|
|
143581
|
-
}
|
|
143582
|
-
}
|
|
143583
|
-
function buildEventFromV4(decoded, payloadBody, resolveData) {
|
|
143584
|
-
const eventData = decoded.eventData ?? {};
|
|
143585
|
-
if (payloadBody.byteLength > 0) {
|
|
143586
|
-
const payloadField = getEventDataPayloadField(decoded.eventType);
|
|
143587
|
-
const normalizedPayload = normalizeSerializedData(payloadBody);
|
|
143588
|
-
if (payloadField && normalizedPayload instanceof Uint8Array) {
|
|
143589
|
-
eventData[payloadField] = legacyStructuredErrorEventTypes.has(decoded.eventType) ? decodeLegacyStructuredError(normalizedPayload) : normalizedPayload;
|
|
143590
|
-
}
|
|
143591
|
-
}
|
|
143592
|
-
const raw2 = {
|
|
143593
|
-
eventId: decoded.eventId,
|
|
143594
|
-
runId: decoded.runId,
|
|
143595
|
-
eventType: decoded.eventType,
|
|
143596
|
-
createdAt: decoded.createdAt instanceof Date ? decoded.createdAt : new Date(decoded.createdAt),
|
|
143597
|
-
...decoded.occurredAt !== void 0 ? {
|
|
143598
|
-
occurredAt: decoded.occurredAt instanceof Date ? decoded.occurredAt : new Date(decoded.occurredAt)
|
|
143599
|
-
} : {},
|
|
143600
|
-
...decoded.correlationId ? { correlationId: decoded.correlationId } : {},
|
|
143601
|
-
eventData,
|
|
143602
|
-
...decoded.specVersion !== void 0 ? { specVersion: decoded.specVersion } : {},
|
|
143603
|
-
// The persisted lazy-resume idempotency key. The runtime matches it
|
|
143604
|
-
// against the queue message's hookInput.resumeId to recognize its own
|
|
143605
|
-
// resume in a preloaded log — dropping it here would silently disable
|
|
143606
|
-
// that check for frame-decoded events.
|
|
143607
|
-
...decoded.resumeId ? { resumeId: decoded.resumeId } : {}
|
|
143608
|
-
};
|
|
143609
|
-
const event = coerceNormalizedEvent(raw2);
|
|
143610
|
-
return resolveData === "none" ? stripEventDataRefs(event, "none") : event;
|
|
143611
|
-
}
|
|
143612
144157
|
async function getEvent(runId, eventId, params, config2) {
|
|
143613
|
-
|
|
143614
|
-
const { event, body: body2 } = await getEventV4(runId, eventId, config2);
|
|
143615
|
-
return buildEventFromV4(event, body2, resolveData);
|
|
144158
|
+
return getEventV4(runId, eventId, (params == null ? void 0 : params.resolveData) === "none" ? "lazy" : "resolve", config2);
|
|
143616
144159
|
}
|
|
143617
144160
|
async function getWorkflowRunEvents(params, config2) {
|
|
143618
144161
|
const { pagination, resolveData = DEFAULT_RESOLVE_DATA_OPTION } = params;
|
|
143619
|
-
const
|
|
143620
|
-
|
|
143621
|
-
limit: pagination == null ? void 0 : pagination.limit,
|
|
143622
|
-
sortOrder: pagination == null ? void 0 : pagination.sortOrder,
|
|
144162
|
+
const listParams = {
|
|
144163
|
+
...pagination,
|
|
143623
144164
|
remoteRefBehavior: resolveData === "none" ? "lazy" : "resolve"
|
|
143624
144165
|
};
|
|
143625
|
-
const result = await ("correlationId" in params ? getEventsByCorrelationIdV4(params.correlationId, params.runId,
|
|
143626
|
-
const events2 = result.events.map((listed) => buildEventFromV4(listed.event, listed.body, resolveData));
|
|
143627
|
-
const runScoped = "correlationId" in params ? events2.filter((event) => event.runId === params.runId) : events2;
|
|
144166
|
+
const result = await ("correlationId" in params ? getEventsByCorrelationIdV4(params.correlationId, params.runId, listParams, config2) : getWorkflowRunEventsV4(params.runId, listParams, config2));
|
|
143628
144167
|
return {
|
|
143629
|
-
data:
|
|
143630
|
-
//
|
|
143631
|
-
// resume
|
|
143632
|
-
|
|
143633
|
-
|
|
143634
|
-
cursor: result.next ?? null,
|
|
143635
|
-
hasMore: typeof result.hasMore === "boolean" ? result.hasMore : Boolean(result.next)
|
|
144168
|
+
data: "correlationId" in params ? result.events.filter((event) => event.runId === params.runId) : result.events,
|
|
144169
|
+
// The cursor is present even on the final page because it is also the
|
|
144170
|
+
// incremental-load resume point. `hasMore` is the pagination signal.
|
|
144171
|
+
cursor: result.cursor,
|
|
144172
|
+
hasMore: result.hasMore
|
|
143636
144173
|
};
|
|
143637
144174
|
}
|
|
143638
144175
|
async function createWorkflowRunEvent(id2, data, params, config2) {
|
|
144176
|
+
var _a3, _b2;
|
|
143639
144177
|
try {
|
|
143640
|
-
|
|
144178
|
+
const result = await withEventPostRetry(() => createWorkflowRunEventInner(id2, data, params, config2), data.eventType, {
|
|
143641
144179
|
// The atomic lazy-resume shape is deduplicated server-side by the
|
|
143642
144180
|
// (runId, resumeId) claim, so its POST is idempotent-on-retry even
|
|
143643
144181
|
// though plain hook_received is not — see EVENT_RETRY_ELIGIBILITY.
|
|
143644
144182
|
idempotentHookResume: data.eventType === "hook_received" && (params == null ? void 0 : params.resumeId) !== void 0 && (params == null ? void 0 : params.resumePayloadDigest) !== void 0
|
|
143645
144183
|
});
|
|
144184
|
+
if (data.eventType === "run_created" && !result.run) {
|
|
144185
|
+
throw new WorkflowWorldError(`${data.eventType} response is missing the run entity`, { code: "SCHEMA_VALIDATION" });
|
|
144186
|
+
}
|
|
144187
|
+
if (data.eventType === "run_started" && !((_a3 = result.run) == null ? void 0 : _a3.startedAt)) {
|
|
144188
|
+
throw new WorkflowWorldError("run_started response is missing run.startedAt", { code: "SCHEMA_VALIDATION" });
|
|
144189
|
+
}
|
|
144190
|
+
if (data.eventType === "step_started" && !((_b2 = result.step) == null ? void 0 : _b2.startedAt)) {
|
|
144191
|
+
throw new WorkflowWorldError("step_started response is missing step.startedAt", { code: "SCHEMA_VALIDATION" });
|
|
144192
|
+
}
|
|
144193
|
+
return result;
|
|
143646
144194
|
} catch (err) {
|
|
143647
144195
|
if (isHookEventRequiringExistence(data.eventType) && WorkflowWorldError.is(err) && err.status === 404 && data.correlationId) {
|
|
143648
144196
|
throw new HookNotFoundError(data.correlationId);
|
|
@@ -143683,88 +144231,94 @@ async function createWorkflowRunEventInner(id2, data, params, config2) {
|
|
|
143683
144231
|
}
|
|
143684
144232
|
const remoteRefBehavior = eventsNeedingResolve.has(data.eventType) ? "resolve" : "lazy";
|
|
143685
144233
|
const { payload, meta: meta2 } = splitEventDataForV4(data);
|
|
143686
|
-
const
|
|
143687
|
-
const v4Input = {
|
|
144234
|
+
const input = {
|
|
143688
144235
|
runId: id2,
|
|
143689
|
-
eventType: data.eventType,
|
|
143690
144236
|
specVersion: data.specVersion ?? 2,
|
|
143691
144237
|
...data.correlationId ? { correlationId: data.correlationId } : {},
|
|
143692
144238
|
...(params == null ? void 0 : params.requestId) ? { vercelId: params.requestId } : {},
|
|
143693
144239
|
...(params == null ? void 0 : params.computeInstanceId) ? { computeInstanceId: params.computeInstanceId } : {},
|
|
143694
|
-
|
|
143695
|
-
|
|
143696
|
-
// independently only so an older server that knows one but not the
|
|
143697
|
-
// others still gets what it understands.
|
|
143698
|
-
...(params == null ? void 0 : params.stateUpdatedAt) !== void 0 ? { stateUpdatedAt: params.stateUpdatedAt } : {},
|
|
143699
|
-
...(params == null ? void 0 : params.stateEventCount) !== void 0 ? { stateEventCount: params.stateEventCount } : {},
|
|
144240
|
+
stateUpdatedAt: params == null ? void 0 : params.stateUpdatedAt,
|
|
144241
|
+
stateEventCount: params == null ? void 0 : params.stateEventCount,
|
|
143700
144242
|
...(params == null ? void 0 : params.stateCursor) ? { stateCursor: params.stateCursor } : {},
|
|
143701
|
-
|
|
144243
|
+
// Slot-identity snapshot. The runtime sends `eventCount` instead of the
|
|
144244
|
+
// watermark triple once the run's own ids are slot-shaped; it rides as
|
|
144245
|
+
// `maxSlot` because the v4 meta already has an unrelated telemetry
|
|
144246
|
+
// `eventCount`.
|
|
144247
|
+
...(params == null ? void 0 : params.eventCount) !== void 0 ? { maxSlot: params.eventCount } : {},
|
|
144248
|
+
replayDivergenceCount: params == null ? void 0 : params.replayDivergenceCount,
|
|
143702
144249
|
occurredAt: (params == null ? void 0 : params.occurredAt) ?? /* @__PURE__ */ new Date(),
|
|
143703
144250
|
// Opt-in inline-delta: forward the cursor the runtime held before
|
|
143704
144251
|
// this write so the server can return the authoritative event-log
|
|
143705
|
-
// delta on the response (events/cursor/hasMore), letting the
|
|
143706
|
-
//
|
|
143707
|
-
//
|
|
143708
|
-
//
|
|
144252
|
+
// delta on the response (events/cursor/hasMore), letting the caller
|
|
144253
|
+
// skip a follow-up events.list. Outside turbo the runtime sends this on
|
|
144254
|
+
// every write, but a server may act on only some event types (or none);
|
|
144255
|
+
// a response without a delta just means the runtime keeps its cursor
|
|
144256
|
+
// and fetches when it next needs to.
|
|
143709
144257
|
...(params == null ? void 0 : params.sinceCursor) ? { sinceCursor: params.sinceCursor } : {},
|
|
143710
|
-
// Run-started preload opt-out: turbo backgrounds run_started as a write
|
|
143711
|
-
// barrier only and never reads the preloaded log, so tell the server to
|
|
143712
|
-
// skip the list+resolve. The server only acts on it for run_started;
|
|
143713
|
-
// older servers ignore it and simply preload as before.
|
|
143714
|
-
...(params == null ? void 0 : params.skipPreload) ? { skipPreload: true } : {},
|
|
143715
|
-
// Lazy hook resume idempotency key (hook_received only). Routes the
|
|
143716
|
-
// write through the server's (runId, resumeId) constraint so a
|
|
143717
|
-
// concurrent queue-consumer re-ensure deduplicates to one event.
|
|
143718
144258
|
...(params == null ? void 0 : params.resumeId) ? { resumeId: params.resumeId } : {},
|
|
143719
|
-
// Content digest forwarded alongside resumeId so the direct write and the
|
|
143720
|
-
// queue re-ensure record an identical digest on the server constraint.
|
|
143721
144259
|
...(params == null ? void 0 : params.resumePayloadDigest) ? { resumePayloadDigest: params.resumePayloadDigest } : {},
|
|
143722
144260
|
remoteRefBehavior,
|
|
143723
144261
|
payload,
|
|
143724
144262
|
...meta2
|
|
143725
144263
|
};
|
|
144264
|
+
if (data.eventType === "run_started" && !(params == null ? void 0 : params.skipPreload)) {
|
|
144265
|
+
const result = await createWorkflowRunStartedEventV4(input, config2);
|
|
144266
|
+
const runCreated = result.events.find((event) => event.eventType === "run_created");
|
|
144267
|
+
const runStarted = result.events.find((event) => event.eventType === "run_started");
|
|
144268
|
+
if (!runCreated) {
|
|
144269
|
+
throw new Error("v4 createEvent: run_started stream is missing run_created");
|
|
144270
|
+
}
|
|
144271
|
+
if (!runStarted) {
|
|
144272
|
+
throw new Error("v4 createEvent: run_started stream is missing run_started");
|
|
144273
|
+
}
|
|
144274
|
+
let attributes = runCreated.eventData.attributes ?? {};
|
|
144275
|
+
let updatedAt = runStarted.createdAt;
|
|
144276
|
+
for (const event of result.events) {
|
|
144277
|
+
if (event.eventType === "attr_set") {
|
|
144278
|
+
attributes = applyAttributeChanges(attributes, event.eventData.changes);
|
|
144279
|
+
updatedAt = event.createdAt;
|
|
144280
|
+
}
|
|
144281
|
+
}
|
|
144282
|
+
return {
|
|
144283
|
+
event: runStarted,
|
|
144284
|
+
run: {
|
|
144285
|
+
runId: runCreated.runId,
|
|
144286
|
+
status: "running",
|
|
144287
|
+
deploymentId: runCreated.eventData.deploymentId,
|
|
144288
|
+
workflowName: runCreated.eventData.workflowName,
|
|
144289
|
+
specVersion: runCreated.specVersion,
|
|
144290
|
+
executionContext: runCreated.eventData.executionContext,
|
|
144291
|
+
input: runCreated.eventData.input,
|
|
144292
|
+
attributes,
|
|
144293
|
+
encryptionPublicKey: runCreated.eventData.encryptionPublicKey,
|
|
144294
|
+
startedAt: runStarted.createdAt,
|
|
144295
|
+
createdAt: runCreated.createdAt,
|
|
144296
|
+
updatedAt
|
|
144297
|
+
},
|
|
144298
|
+
events: result.events,
|
|
144299
|
+
cursor: result.cursor,
|
|
144300
|
+
hasMore: result.hasMore,
|
|
144301
|
+
maxEvents: result.maxEvents
|
|
144302
|
+
};
|
|
144303
|
+
}
|
|
143726
144304
|
if (data.eventType === "hook_received" && (params == null ? void 0 : params.preloadEvents) === true && params.resumeId !== void 0 && params.resumePayloadDigest !== void 0) {
|
|
143727
|
-
const outcome = await createHookReceivedPreloadEventV4({ ...
|
|
144305
|
+
const outcome = await createHookReceivedPreloadEventV4({ ...input, remoteRefBehavior: "lazy" }, config2);
|
|
143728
144306
|
if (outcome.kind === "materialized") {
|
|
143729
|
-
return
|
|
144307
|
+
return outcome.result;
|
|
143730
144308
|
}
|
|
143731
|
-
const { canonicalEventId, maxEvents,
|
|
143732
|
-
const events2 = outcome.events.map((listed) => buildEventFromV4(listed.event, listed.body, "all"));
|
|
144309
|
+
const { canonicalEventId, maxEvents, events: events2, cursor, hasMore } = outcome;
|
|
143733
144310
|
const canonicalEvent = events2.find((event) => event.eventId === canonicalEventId);
|
|
143734
144311
|
const run2 = reconstructRunFromReplayEvents(events2);
|
|
143735
144312
|
return {
|
|
143736
144313
|
...canonicalEvent ? { event: canonicalEvent } : {},
|
|
143737
144314
|
...run2 ? { run: run2 } : {},
|
|
143738
144315
|
events: events2,
|
|
143739
|
-
cursor
|
|
143740
|
-
|
|
143741
|
-
// missing flag as "not the complete log" so the runtime falls back
|
|
143742
|
-
// rather than replaying a possibly-truncated prefix.
|
|
143743
|
-
hasMore: hasMore ?? true,
|
|
144316
|
+
cursor,
|
|
144317
|
+
hasMore,
|
|
143744
144318
|
...maxEvents !== void 0 ? { maxEvents } : {}
|
|
143745
144319
|
};
|
|
143746
144320
|
}
|
|
143747
|
-
|
|
143748
|
-
return materializedV4ToEventResult(result, resolveData);
|
|
143749
|
-
}
|
|
143750
|
-
function materializedV4ToEventResult(result, resolveData) {
|
|
143751
|
-
const body2 = result.body;
|
|
143752
|
-
return {
|
|
143753
|
-
event: body2.event ? stripEventDataRefs(coerceEventDates(body2.event), resolveData) : void 0,
|
|
143754
|
-
run: body2.run ? deserializeError(body2.run) : void 0,
|
|
143755
|
-
step: body2.step ? deserializeStep(body2.step) : void 0,
|
|
143756
|
-
hook: body2.hook,
|
|
143757
|
-
wait: body2.wait,
|
|
143758
|
-
events: body2.events ? body2.events.map(coerceEventDates) : void 0,
|
|
143759
|
-
cursor: body2.cursor ?? void 0,
|
|
143760
|
-
hasMore: body2.hasMore,
|
|
143761
|
-
// Lazy step start: thread the server's "I created the step on this call"
|
|
143762
|
-
// signal through so the owned-inline runtime path can gate body execution
|
|
143763
|
-
// on it. Absent from older servers → undefined → safe default.
|
|
143764
|
-
...body2.stepCreated ? { stepCreated: true } : {},
|
|
143765
|
-
// Server-supplied per-run event ceiling; absent from older servers.
|
|
143766
|
-
...typeof body2.maxEvents === "number" ? { maxEvents: body2.maxEvents } : {}
|
|
143767
|
-
};
|
|
144321
|
+
return createWorkflowRunEventV4(data.eventType === "run_started" ? { ...input, eventType: "run_started", skipPreload: true } : { ...input, eventType: data.eventType }, config2);
|
|
143768
144322
|
}
|
|
143769
144323
|
function reconstructRunFromReplayEvents(events2) {
|
|
143770
144324
|
const runCreated = events2.find((event) => event.eventType === "run_created");
|
|
@@ -144109,10 +144663,14 @@ function createWorld$1(config2) {
|
|
|
144109
144663
|
var _a3, _b2;
|
|
144110
144664
|
const projectId = ((_a3 = config2 == null ? void 0 : config2.projectConfig) == null ? void 0 : _a3.projectId) || process.env.VERCEL_PROJECT_ID;
|
|
144111
144665
|
return {
|
|
144112
|
-
// Spec
|
|
144113
|
-
//
|
|
144114
|
-
|
|
144666
|
+
// Spec v6 adds slot-numbered event ids on top of v5's client-side
|
|
144667
|
+
// zstd/gzip payload compression. The version is what tells the backend
|
|
144668
|
+
// which id scheme a run uses: it is stamped on `run_created` and read back
|
|
144669
|
+
// on every later write, so a run created before v6 keeps its ULIDs even
|
|
144670
|
+
// though this adapter now asks for slots.
|
|
144671
|
+
specVersion: SPEC_VERSION_SUPPORTS_SLOT_IDENTITY,
|
|
144115
144672
|
capabilities: {
|
|
144673
|
+
hookRetention: { active: true },
|
|
144116
144674
|
// workflow-server enforces the `stateUpdatedAt` optimistic-concurrency
|
|
144117
144675
|
// guard: creations carrying a stale snapshot are rejected with 412
|
|
144118
144676
|
// (PreconditionFailedError) when the run's outside-event marker is
|
|
@@ -144124,7 +144682,12 @@ function createWorld$1(config2) {
|
|
|
144124
144682
|
maxConcurrency: true,
|
|
144125
144683
|
// Vercel deployments are atomic and immutable, so a deployment id names
|
|
144126
144684
|
// one fixed build for its whole lifetime.
|
|
144127
|
-
deploymentAffinity: true
|
|
144685
|
+
deploymentAffinity: true,
|
|
144686
|
+
// New runs get dense per-run slot event ids. Runs created before the
|
|
144687
|
+
// backend adopted them keep their ULIDs; the scheme is pinned by the
|
|
144688
|
+
// spec version stamped on each run, not by this flag, which only says
|
|
144689
|
+
// what new runs get.
|
|
144690
|
+
slotEventIds: true
|
|
144128
144691
|
// NOTE: the backend half of resumeHook()'s parallel fast path — that
|
|
144129
144692
|
// the server enforces the `(runId, resumeId)` dedup constraint — is
|
|
144130
144693
|
// NO LONGER a static world capability here. It is attested per-lookup by
|
|
@@ -144133,12 +144696,6 @@ function createWorld$1(config2) {
|
|
|
144133
144696
|
// rollback or kill switch drop new resumes to the sequential path
|
|
144134
144697
|
// immediately, without a redeploy of this adapter.
|
|
144135
144698
|
},
|
|
144136
|
-
// On Vercel the platform fails the function invocation when the
|
|
144137
|
-
// process exits non-zero, and VQS redelivers the queue message via a
|
|
144138
|
-
// fresh invocation. The core runtime uses this to decide whether
|
|
144139
|
-
// `process.exit(1)` is an acceptable response to an exhausted replay
|
|
144140
|
-
// budget.
|
|
144141
|
-
processExitTriggersQueueRedelivery: true,
|
|
144142
144699
|
getRuntimeDeadline: getDeadline,
|
|
144143
144700
|
...createQueue$1(config2),
|
|
144144
144701
|
...createStorage(config2),
|
|
@@ -144281,7 +144838,7 @@ const getWorld = async () => {
|
|
|
144281
144838
|
const GetWorldFnKey = Symbol.for("@workflow/world//getWorldFn");
|
|
144282
144839
|
globalThis[GetWorldFnKey] ?? (globalThis[GetWorldFnKey] = getWorld);
|
|
144283
144840
|
function waitUntil(promise2) {
|
|
144284
|
-
void import("./index-
|
|
144841
|
+
void import("./index-DTci39F3.js").then((n) => n.i).then(({ waitUntil: waitUntil2 }) => {
|
|
144285
144842
|
waitUntil2(promise2);
|
|
144286
144843
|
});
|
|
144287
144844
|
}
|
|
@@ -147172,7 +147729,11 @@ async function resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, hookF
|
|
|
147172
147729
|
hookId: hook.hookId,
|
|
147173
147730
|
token: hook.token,
|
|
147174
147731
|
payload: dehydratedPayload,
|
|
147175
|
-
payloadDigest
|
|
147732
|
+
payloadDigest,
|
|
147733
|
+
// Deployment affinity for the consumer's cheap pre-write
|
|
147734
|
+
// check: lets a misrouted delivery re-route before its
|
|
147735
|
+
// hoisted hook_received write instead of after.
|
|
147736
|
+
deploymentId: resumeContext.deploymentId
|
|
147176
147737
|
}
|
|
147177
147738
|
}, queueOptions)
|
|
147178
147739
|
]);
|
|
@@ -147472,9 +148033,6 @@ async function start$1(workflow, argsOrOptions, options) {
|
|
|
147472
148033
|
}
|
|
147473
148034
|
} else {
|
|
147474
148035
|
const result = runCreatedResult.value;
|
|
147475
|
-
if (!result.run) {
|
|
147476
|
-
throw new WorkflowRuntimeError("Missing 'run' in server response for 'run_created' event");
|
|
147477
|
-
}
|
|
147478
148036
|
if (!v1Compat && result.run.runId !== runId) {
|
|
147479
148037
|
throw new WorkflowRuntimeError(`Server returned different runId than requested: expected ${runId}, got ${result.run.runId}`);
|
|
147480
148038
|
}
|
|
@@ -147488,7 +148046,7 @@ async function start$1(workflow, argsOrOptions, options) {
|
|
|
147488
148046
|
span == null ? void 0 : span.setAttributes({
|
|
147489
148047
|
...WorkflowRunId$2(runId),
|
|
147490
148048
|
...DeploymentId(deploymentId),
|
|
147491
|
-
...runCreatedResult.status === "fulfilled"
|
|
148049
|
+
...runCreatedResult.status === "fulfilled" ? WorkflowRunStatus(runCreatedResult.value.run.status) : {}
|
|
147492
148050
|
});
|
|
147493
148051
|
return new Run(runId, { resilientStart });
|
|
147494
148052
|
});
|
|
@@ -147624,7 +148182,7 @@ async function wakeUpRun$2(world, runId, options) {
|
|
|
147624
148182
|
do {
|
|
147625
148183
|
const eventsResult = await world.events.list({
|
|
147626
148184
|
runId,
|
|
147627
|
-
pagination: {
|
|
148185
|
+
pagination: { sortOrder: "asc", ...cursor ? { cursor } : {} },
|
|
147628
148186
|
resolveData: "none"
|
|
147629
148187
|
});
|
|
147630
148188
|
allEvents.push(...eventsResult.data);
|
|
@@ -171135,7 +171693,7 @@ const route4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
|
|
|
171135
171693
|
__proto__: null,
|
|
171136
171694
|
loader
|
|
171137
171695
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
171138
|
-
const serverManifest = { "entry": { "module": "/assets/entry.client-LwI3HNYl.js", "imports": ["/assets/index-PFjW8YjQ.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-
|
|
171696
|
+
const serverManifest = { "entry": { "module": "/assets/entry.client-LwI3HNYl.js", "imports": ["/assets/index-PFjW8YjQ.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-D6p4Hb4F.js", "imports": ["/assets/index-PFjW8YjQ.js", "/assets/mermaid-3ZIDBTTL-DchhEfRL.js", "/assets/loader-circle-fFQM94Ej.js", "/assets/arrow-up-right-jWH-UQH9.js"], "css": ["/assets/root-ZRjqDhEN.css", "/assets/mermaid-3ZIDBTTL-D8CjRQta.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-BwYHJJJr.js", "imports": ["/assets/index-PFjW8YjQ.js", "/assets/workflow-graph-viewer-t_fSwuwz.js", "/assets/mermaid-3ZIDBTTL-DchhEfRL.js", "/assets/loader-circle-fFQM94Ej.js"], "css": ["/assets/workflow-graph-viewer-DnlNuQQH.css", "/assets/mermaid-3ZIDBTTL-D8CjRQta.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-vPCbZIXx.js", "imports": ["/assets/index-PFjW8YjQ.js", "/assets/workflow-graph-viewer-t_fSwuwz.js", "/assets/mermaid-3ZIDBTTL-DchhEfRL.js", "/assets/arrow-up-right-jWH-UQH9.js"], "css": ["/assets/run-detail-CWoGxu_0.css", "/assets/workflow-graph-viewer-DnlNuQQH.css", "/assets/mermaid-3ZIDBTTL-D8CjRQta.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-f6a9dca2.js", "version": "f6a9dca2", "sri": void 0 };
|
|
171139
171697
|
const assetsBuildDirectory = "build/client";
|
|
171140
171698
|
const basename = "/";
|
|
171141
171699
|
const future = { "unstable_optimizeDeps": false, "unstable_subResourceIntegrity": false, "unstable_trailingSlashAwareDataRequests": false, "unstable_previewServerPrerendering": false, "v8_middleware": false, "v8_splitRouteModules": false, "v8_viteEnvironmentApi": false };
|
|
@@ -171344,88 +171902,106 @@ function createFetchHandler(basename2 = "/") {
|
|
|
171344
171902
|
return (request2) => handler(request2, loadContext);
|
|
171345
171903
|
}
|
|
171346
171904
|
export {
|
|
171347
|
-
|
|
171905
|
+
SerializedDataSchema as $,
|
|
171348
171906
|
ATTRIBUTE_KEY_MAX_LENGTH as A,
|
|
171349
171907
|
BULK_CANCEL_MAX_RUN_IDS as B,
|
|
171350
171908
|
CHILD_ENTITY_CREATION_EVENT_TYPES as C,
|
|
171351
171909
|
DEFAULT_TIMESTAMP_THRESHOLD_FUTURE_MS as D,
|
|
171352
171910
|
EVENT_DATA_PAYLOAD_FIELD_BY_EVENT_TYPE as E,
|
|
171353
|
-
|
|
171354
|
-
|
|
171911
|
+
FIRST_EVENT_SLOT as F,
|
|
171912
|
+
HookCreatedEventSchema as G,
|
|
171355
171913
|
HookSchema as H,
|
|
171356
|
-
|
|
171357
|
-
|
|
171358
|
-
|
|
171914
|
+
HookResumeCapabilitiesSchema as I,
|
|
171915
|
+
PaginatedResponseSchema as J,
|
|
171916
|
+
QueuePrefix as K,
|
|
171359
171917
|
LegacySerializedDataSchemaV1 as L,
|
|
171360
171918
|
MessageId as M,
|
|
171361
171919
|
Nt as N,
|
|
171362
|
-
|
|
171920
|
+
ROOT_RUN_ID_ATTRIBUTE as O,
|
|
171363
171921
|
PARENT_RUN_ID_ATTRIBUTE as P,
|
|
171364
171922
|
QueuePayloadSchema as Q,
|
|
171365
171923
|
RESERVED_ATTRIBUTE_KEY_PREFIX as R,
|
|
171366
|
-
|
|
171367
|
-
|
|
171368
|
-
|
|
171369
|
-
|
|
171370
|
-
|
|
171371
|
-
|
|
171372
|
-
|
|
171373
|
-
|
|
171374
|
-
|
|
171924
|
+
RunInputSchema as S,
|
|
171925
|
+
SPEC_VERSION_CURRENT as T,
|
|
171926
|
+
SPEC_VERSION_LEGACY as U,
|
|
171927
|
+
SPEC_VERSION_MAX_SUPPORTED as V,
|
|
171928
|
+
SPEC_VERSION_SUPPORTS_ATTRIBUTES as W,
|
|
171929
|
+
SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT as X,
|
|
171930
|
+
SPEC_VERSION_SUPPORTS_COMPRESSION as Y,
|
|
171931
|
+
SPEC_VERSION_SUPPORTS_SLOT_IDENTITY as Z,
|
|
171932
|
+
STEP_EVENT_TYPES as _,
|
|
171375
171933
|
ATTRIBUTE_MAX_PER_RUN as a,
|
|
171376
|
-
|
|
171377
|
-
|
|
171378
|
-
|
|
171379
|
-
|
|
171380
|
-
|
|
171381
|
-
|
|
171382
|
-
|
|
171383
|
-
|
|
171384
|
-
|
|
171385
|
-
|
|
171386
|
-
|
|
171387
|
-
|
|
171388
|
-
|
|
171389
|
-
|
|
171390
|
-
|
|
171391
|
-
|
|
171392
|
-
|
|
171393
|
-
|
|
171394
|
-
|
|
171395
|
-
|
|
171396
|
-
|
|
171397
|
-
|
|
171398
|
-
|
|
171399
|
-
|
|
171400
|
-
|
|
171401
|
-
|
|
171402
|
-
|
|
171403
|
-
|
|
171404
|
-
|
|
171405
|
-
|
|
171406
|
-
|
|
171407
|
-
|
|
171408
|
-
|
|
171409
|
-
|
|
171410
|
-
|
|
171411
|
-
|
|
171412
|
-
|
|
171413
|
-
|
|
171414
|
-
|
|
171415
|
-
|
|
171416
|
-
|
|
171417
|
-
|
|
171418
|
-
|
|
171419
|
-
|
|
171420
|
-
|
|
171421
|
-
|
|
171422
|
-
|
|
171423
|
-
|
|
171424
|
-
|
|
171425
|
-
|
|
171426
|
-
|
|
171427
|
-
|
|
171934
|
+
decodeFrames as a$,
|
|
171935
|
+
StepSchema as a0,
|
|
171936
|
+
StepStatusSchema as a1,
|
|
171937
|
+
StructuredErrorSchema as a2,
|
|
171938
|
+
TERMINAL_RUN_EVENT_TYPES as a3,
|
|
171939
|
+
TERMINAL_STEP_EVENT_TYPES as a4,
|
|
171940
|
+
TERMINAL_STEP_STATUSES as a5,
|
|
171941
|
+
TERMINAL_WORKFLOW_RUN_STATUSES as a6,
|
|
171942
|
+
TerminalRunEventTypeSchema as a7,
|
|
171943
|
+
TerminalStepStatusSchema as a8,
|
|
171944
|
+
TerminalWorkflowRunStatusSchema as a9,
|
|
171945
|
+
isTerminalWorkflowRunStatus as aA,
|
|
171946
|
+
isWaitEventType as aB,
|
|
171947
|
+
parseQueueName as aC,
|
|
171948
|
+
reenqueueActiveRuns as aD,
|
|
171949
|
+
requiresNewerWorld as aE,
|
|
171950
|
+
resolveQueueNamespace as aF,
|
|
171951
|
+
slotToEventId as aG,
|
|
171952
|
+
stripEventDataRefs as aH,
|
|
171953
|
+
ulidToDate as aI,
|
|
171954
|
+
validateAttributeChanges as aJ,
|
|
171955
|
+
validateAttributeKey as aK,
|
|
171956
|
+
validateAttributeValue as aL,
|
|
171957
|
+
validateUlidTimestamp as aM,
|
|
171958
|
+
workflowRunIdSchema as aN,
|
|
171959
|
+
reactExports as aO,
|
|
171960
|
+
R as aP,
|
|
171961
|
+
Ks as aQ,
|
|
171962
|
+
jsxRuntimeExports as aR,
|
|
171963
|
+
Qe as aS,
|
|
171964
|
+
registerZstdDecoder as aT,
|
|
171965
|
+
isWsEventsTransportEnabled as aU,
|
|
171966
|
+
getHttpUrl as aV,
|
|
171967
|
+
getHttpConfig as aW,
|
|
171968
|
+
headersToRecord as aX,
|
|
171969
|
+
getRequestTimeoutMs as aY,
|
|
171970
|
+
injectTraceContextIntoHeaders as aZ,
|
|
171971
|
+
distExports as a_,
|
|
171972
|
+
ValidQueueName as aa,
|
|
171973
|
+
WAIT_EVENT_TYPES as ab,
|
|
171974
|
+
WaitSchema as ac,
|
|
171975
|
+
WaitStatusSchema as ad,
|
|
171976
|
+
WorkflowInvokePayloadSchema as ae,
|
|
171977
|
+
WorkflowRunBaseSchema as af,
|
|
171978
|
+
WorkflowRunSchema as ag,
|
|
171979
|
+
WorkflowRunStatusSchema as ah,
|
|
171980
|
+
applyAttributeChanges as ai,
|
|
171981
|
+
envNumber as aj,
|
|
171982
|
+
eventIdToSlot as ak,
|
|
171983
|
+
getEventDataPayloadField as al,
|
|
171984
|
+
getEventDataRefFields as am,
|
|
171985
|
+
getMaxEventsPerRun as an,
|
|
171986
|
+
getQueueTopicPrefix as ao,
|
|
171987
|
+
isChildEntityCreationEvent as ap,
|
|
171988
|
+
isChildEntityCreationEventType as aq,
|
|
171989
|
+
isHookEventRequiringExistence as ar,
|
|
171990
|
+
isHookLifecycleEventType as as,
|
|
171991
|
+
isLegacySpecVersion as at,
|
|
171992
|
+
isSlotBody as au,
|
|
171993
|
+
isSlotEventId as av,
|
|
171994
|
+
isStepEventType as aw,
|
|
171995
|
+
isTerminalRunEventType as ax,
|
|
171996
|
+
isTerminalStepEventType as ay,
|
|
171997
|
+
isTerminalStepStatus as az,
|
|
171428
171998
|
ATTRIBUTE_VALUE_MAX_BYTES as b,
|
|
171999
|
+
getDefaultExportFromCjs as b0,
|
|
172000
|
+
requireTokenUtil as b1,
|
|
172001
|
+
requireTokenError as b2,
|
|
172002
|
+
getAugmentedNamespace as b3,
|
|
172003
|
+
app as b4,
|
|
172004
|
+
createFetchHandler as b5,
|
|
171429
172005
|
AnalyticsAttributeKeySchema as c,
|
|
171430
172006
|
AnalyticsEventSchema as d,
|
|
171431
172007
|
AnalyticsHookSchema as e,
|
|
@@ -171441,13 +172017,13 @@ export {
|
|
|
171441
172017
|
BulkCancelWorkflowRunsResultSchema as o,
|
|
171442
172018
|
DEFAULT_TIMESTAMP_THRESHOLD_PAST_MS as p,
|
|
171443
172019
|
EVENT_DATA_REF_FIELDS as q,
|
|
171444
|
-
|
|
171445
|
-
|
|
171446
|
-
|
|
171447
|
-
|
|
171448
|
-
|
|
171449
|
-
|
|
171450
|
-
|
|
171451
|
-
|
|
171452
|
-
|
|
172020
|
+
EVENT_ID_BODY_LENGTH as r,
|
|
172021
|
+
EVENT_ID_PREFIX as s,
|
|
172022
|
+
EventSchema as t,
|
|
172023
|
+
EventTypeSchema as u,
|
|
172024
|
+
HOOK_EVENTS_REQUIRING_EXISTENCE as v,
|
|
172025
|
+
HOOK_LIFECYCLE_EVENT_TYPES as w,
|
|
172026
|
+
HOOK_RESUME_DEDUP_VERSION as x,
|
|
172027
|
+
HOOK_RESUME_INPUT_VERSION as y,
|
|
172028
|
+
HealthCheckPayloadSchema as z
|
|
171453
172029
|
};
|