@workflow/web 5.0.3 → 5.0.4
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/server/assets/{app-C8tzXy8V.js → app-B50FKpUW.js} +576 -182
- package/build/server/assets/{highlighted-body-B3W2YXNL-B7OeHZjS.js → highlighted-body-B3W2YXNL-DwfdU2_m.js} +1 -1
- package/build/server/assets/{index-oHATtR_7.js → index-C3Gx8HYZ.js} +1 -1
- package/build/server/assets/{index-DB6rD0OI.js → index-D1YkUiuC.js} +94 -90
- package/build/server/assets/{mermaid-3ZIDBTTL-h6E4ztpF.js → mermaid-3ZIDBTTL-koYqT7Zj.js} +1 -1
- package/build/server/assets/{token-zIvY_X5M.js → token-DbFnZp4-.js} +1 -1
- package/build/server/assets/{token-util-BIJWXlXW.js → token-util-BXkc19cz.js} +1 -1
- package/build/server/assets/{wrapper-DiM8LB2q.js → wrapper-BC7AidWM.js} +9 -9
- package/build/server/assets/{zstd-browser-decoder-B2bHyQlS.js → zstd-browser-decoder-ClonRoMz.js} +1 -1
- package/build/server/index.js +2 -2
- package/package.json +8 -8
|
@@ -41075,7 +41075,7 @@ function timeSource(args) {
|
|
|
41075
41075
|
function time(args) {
|
|
41076
41076
|
return new RegExp(`^${timeSource(args)}$`);
|
|
41077
41077
|
}
|
|
41078
|
-
function datetime(args) {
|
|
41078
|
+
function datetime$1(args) {
|
|
41079
41079
|
const opts = ["Z"];
|
|
41080
41080
|
if (args.offset)
|
|
41081
41081
|
opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
@@ -41822,7 +41822,7 @@ const $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (inst, def) => {
|
|
|
41822
41822
|
$ZodStringFormat.init(inst, def);
|
|
41823
41823
|
});
|
|
41824
41824
|
const $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
|
|
41825
|
-
def.pattern ?? (def.pattern = datetime(def));
|
|
41825
|
+
def.pattern ?? (def.pattern = datetime$1(def));
|
|
41826
41826
|
$ZodStringFormat.init(inst, def);
|
|
41827
41827
|
if (def.local || def.precision === -1) {
|
|
41828
41828
|
inst._zod.bag.laxFormat = true;
|
|
@@ -47812,6 +47812,9 @@ function preprocess$1(fn2, schema) {
|
|
|
47812
47812
|
out: schema
|
|
47813
47813
|
});
|
|
47814
47814
|
}
|
|
47815
|
+
function datetime(params) {
|
|
47816
|
+
return /* @__PURE__ */ _isoDateTime(ZodISODateTime, params);
|
|
47817
|
+
}
|
|
47815
47818
|
function number$2(params) {
|
|
47816
47819
|
return /* @__PURE__ */ _coercedNumber(ZodNumber, params);
|
|
47817
47820
|
}
|
|
@@ -48504,6 +48507,7 @@ function isChildEntityCreationEvent(event) {
|
|
|
48504
48507
|
return true;
|
|
48505
48508
|
return event.eventType === "step_started" && typeof ((_a3 = event.eventData) == null ? void 0 : _a3.stepName) === "string" && event.eventData.input !== void 0;
|
|
48506
48509
|
}
|
|
48510
|
+
const IN_BAND_SEQ_AT_RUN_CREATION = 1;
|
|
48507
48511
|
const WorkflowRunStatusSchema = compile(_enum(["pending", "running", "completed", "failed", "cancelled"]));
|
|
48508
48512
|
const TerminalWorkflowRunStatusSchema = compile(WorkflowRunStatusSchema.extract(["completed", "failed", "cancelled"]));
|
|
48509
48513
|
const TERMINAL_WORKFLOW_RUN_STATUSES = TerminalWorkflowRunStatusSchema.options;
|
|
@@ -48897,6 +48901,20 @@ function getQueueTopicPrefix(kind, namespace2) {
|
|
|
48897
48901
|
}
|
|
48898
48902
|
return "__wkf_workflow_";
|
|
48899
48903
|
}
|
|
48904
|
+
const WORKFLOW_FLOW_ROUTE = "/.well-known/workflow/v1/flow";
|
|
48905
|
+
function parseQueueRoute(path2) {
|
|
48906
|
+
if (typeof path2 !== "string" || !path2.startsWith("/") || path2.startsWith("//") || /[?#\s]/.test(path2)) {
|
|
48907
|
+
throw new TypeError(`Invalid queue route "${String(path2)}": must be an absolute path such as "/api/agent/queue", without a query or fragment`);
|
|
48908
|
+
}
|
|
48909
|
+
return path2;
|
|
48910
|
+
}
|
|
48911
|
+
function getRunQueueNamespace(executionContext) {
|
|
48912
|
+
if (typeof executionContext !== "object" || executionContext === null || executionContext instanceof Uint8Array) {
|
|
48913
|
+
return void 0;
|
|
48914
|
+
}
|
|
48915
|
+
const namespace2 = executionContext.queueNamespace;
|
|
48916
|
+
return typeof namespace2 === "string" && QueueNamespace.safeParse(namespace2).success ? namespace2 : void 0;
|
|
48917
|
+
}
|
|
48900
48918
|
function parseQueueName(name2) {
|
|
48901
48919
|
const match2 = name2.match(/^(__(?:[a-z][a-z0-9]*_)?wkf_workflow_)(.+)$/);
|
|
48902
48920
|
if (!match2) {
|
|
@@ -49240,7 +49258,8 @@ function isNodeHttpEnabled(env2 = process.env) {
|
|
|
49240
49258
|
return envFlag(NODE_HTTP_ENV_VAR, NODE_HTTP_DEFAULT, env2);
|
|
49241
49259
|
}
|
|
49242
49260
|
async function reenqueueActiveRuns(runs, enqueue, label, namespace2) {
|
|
49243
|
-
const
|
|
49261
|
+
const defaultNamespace = resolveQueueNamespace(namespace2);
|
|
49262
|
+
getQueueTopicPrefix("workflow", defaultNamespace);
|
|
49244
49263
|
let reenqueued = 0;
|
|
49245
49264
|
let cursor;
|
|
49246
49265
|
let hasMore = true;
|
|
@@ -49252,7 +49271,8 @@ async function reenqueueActiveRuns(runs, enqueue, label, namespace2) {
|
|
|
49252
49271
|
});
|
|
49253
49272
|
for (const run2 of page.data) {
|
|
49254
49273
|
try {
|
|
49255
|
-
const
|
|
49274
|
+
const prefix = getQueueTopicPrefix("workflow", getRunQueueNamespace(run2.executionContext) ?? defaultNamespace);
|
|
49275
|
+
const queueName = `${prefix}${run2.workflowName}`;
|
|
49256
49276
|
await enqueue(queueName, { runId: run2.runId });
|
|
49257
49277
|
reenqueued++;
|
|
49258
49278
|
} catch (err) {
|
|
@@ -53186,7 +53206,17 @@ function createWorkflowBaseUrl(origin) {
|
|
|
53186
53206
|
function createWorkflowUrl(baseUrl, route) {
|
|
53187
53207
|
const url = new URL(baseUrl);
|
|
53188
53208
|
url.pathname = `${url.pathname.replace(/\/+$/, "")}${WORKFLOW_ROUTE_BASE}/${getWorkflowRouteEndpoint(route)}`;
|
|
53189
|
-
url.search =
|
|
53209
|
+
url.search = "";
|
|
53210
|
+
url.hash = "";
|
|
53211
|
+
return url.toString();
|
|
53212
|
+
}
|
|
53213
|
+
function createAppRouteUrl(baseUrl, path2) {
|
|
53214
|
+
if (!path2.startsWith("/")) {
|
|
53215
|
+
throw new TypeError(`App route "${path2}" must start with "/"`);
|
|
53216
|
+
}
|
|
53217
|
+
const url = new URL(baseUrl);
|
|
53218
|
+
url.pathname = `${url.pathname.replace(/\/+$/, "")}${path2}`;
|
|
53219
|
+
url.search = "";
|
|
53190
53220
|
url.hash = "";
|
|
53191
53221
|
return url.toString();
|
|
53192
53222
|
}
|
|
@@ -54208,6 +54238,20 @@ class PreconditionFailedError extends WorkflowWorldError {
|
|
|
54208
54238
|
return isError(value) && value.name === "PreconditionFailedError";
|
|
54209
54239
|
}
|
|
54210
54240
|
}
|
|
54241
|
+
const IN_BAND_SUPERSEDED_CODE = "in-band-superseded";
|
|
54242
|
+
class InBandSupersededError extends WorkflowWorldError {
|
|
54243
|
+
constructor(message2, options) {
|
|
54244
|
+
super(message2, { status: 412, code: IN_BAND_SUPERSEDED_CODE });
|
|
54245
|
+
__publicField(this, "seq");
|
|
54246
|
+
__publicField(this, "seqInBand");
|
|
54247
|
+
this.name = "InBandSupersededError";
|
|
54248
|
+
this.seq = options == null ? void 0 : options.seq;
|
|
54249
|
+
this.seqInBand = options == null ? void 0 : options.seqInBand;
|
|
54250
|
+
}
|
|
54251
|
+
static is(value) {
|
|
54252
|
+
return isError(value) && value.name === "InBandSupersededError";
|
|
54253
|
+
}
|
|
54254
|
+
}
|
|
54211
54255
|
class WorkflowRunCancelledError extends WorkflowError {
|
|
54212
54256
|
constructor(runId) {
|
|
54213
54257
|
super(`Workflow run "${runId}" cancelled`, {});
|
|
@@ -55599,7 +55643,7 @@ function replaceEncryptedAndExpiredWithMarkers(resource) {
|
|
|
55599
55643
|
}
|
|
55600
55644
|
async function hydrateResourceIOAsync(resource, key) {
|
|
55601
55645
|
const { hydrateDataWithKey: hydrateDataWithKey2, deriveRunPayloadKeys: deriveRunPayloadKeys2 } = await Promise.resolve().then(() => serializationFormat);
|
|
55602
|
-
const { ensureZstdDecoderRegistered } = await import("./zstd-browser-decoder-
|
|
55646
|
+
const { ensureZstdDecoderRegistered } = await import("./zstd-browser-decoder-ClonRoMz.js");
|
|
55603
55647
|
ensureZstdDecoderRegistered();
|
|
55604
55648
|
const cryptoKey = key ? await deriveRunPayloadKeys2(key) : void 0;
|
|
55605
55649
|
const revivers = getRevivers();
|
|
@@ -86587,7 +86631,7 @@ var tn = f("block", "before:content-[counter(line)]", "before:inline-block", "be
|
|
|
86587
86631
|
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 });
|
|
86588
86632
|
var Se = reactExports.createContext({ code: "" }), de = () => reactExports.useContext(Se);
|
|
86589
86633
|
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 }) });
|
|
86590
|
-
var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-
|
|
86634
|
+
var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-DwfdU2_m.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
|
|
86591
86635
|
let i = reactExports.useMemo(() => e.replace(cn$1, ""), [e]), c = reactExports.useMemo(() => ({ bg: "transparent", fg: "inherit", tokens: i.split(`
|
|
86592
86636
|
`).map((a2) => [{ content: a2, color: "inherit", bgColor: "transparent", htmlStyle: {}, offset: 0 }]) }), [i]);
|
|
86593
86637
|
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 }) })] }) });
|
|
@@ -86909,7 +86953,7 @@ var Dt = ({ children: e, className: t, onDownload: o, onError: n }) => {
|
|
|
86909
86953
|
}, []), 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] });
|
|
86910
86954
|
};
|
|
86911
86955
|
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 }) })] });
|
|
86912
|
-
var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-
|
|
86956
|
+
var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-koYqT7Zj.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
|
|
86913
86957
|
function ke(e, t) {
|
|
86914
86958
|
if (!(e != null && e.position || t != null && t.position)) return true;
|
|
86915
86959
|
if (!(e != null && e.position && (t != null && t.position))) return false;
|
|
@@ -97295,6 +97339,7 @@ const devalueCodec = {
|
|
|
97295
97339
|
};
|
|
97296
97340
|
const COMPRESSION_MIN_BYTES = 1024;
|
|
97297
97341
|
const COMPRESSION_MIN_SAVINGS_RATIO = 0.05;
|
|
97342
|
+
const COMPRESSION_ASYNC_MIN_BYTES = 256 * 1024;
|
|
97298
97343
|
const ZSTD_LEVEL = 3;
|
|
97299
97344
|
function isCompressionDisabledByEnv() {
|
|
97300
97345
|
var _a3;
|
|
@@ -97367,6 +97412,20 @@ function zstdBytes(data2) {
|
|
|
97367
97412
|
const z2 = getNodeZlib$1();
|
|
97368
97413
|
return new Uint8Array(z2.zstdCompressSync(data2, zstdOpts(z2)));
|
|
97369
97414
|
}
|
|
97415
|
+
function zstdBytesAsync(data2) {
|
|
97416
|
+
const z2 = getNodeZlib$1();
|
|
97417
|
+
if (typeof (z2 == null ? void 0 : z2.zstdCompress) !== "function") {
|
|
97418
|
+
return Promise.resolve(zstdBytes(data2));
|
|
97419
|
+
}
|
|
97420
|
+
return new Promise((resolve2, reject) => {
|
|
97421
|
+
z2.zstdCompress(data2, zstdOpts(z2), (err, result) => {
|
|
97422
|
+
if (err)
|
|
97423
|
+
reject(err);
|
|
97424
|
+
else
|
|
97425
|
+
resolve2(new Uint8Array(result));
|
|
97426
|
+
});
|
|
97427
|
+
});
|
|
97428
|
+
}
|
|
97370
97429
|
function unzstdBytes(data2, maxOutputBytes) {
|
|
97371
97430
|
const z2 = getNodeZlib$1();
|
|
97372
97431
|
if (!(z2 == null ? void 0 : z2.zstdDecompressSync)) {
|
|
@@ -97408,7 +97467,7 @@ async function compress(data2, mode, stats2, opts) {
|
|
|
97408
97467
|
recordStats(stats2, "none", data2.length, data2.length);
|
|
97409
97468
|
return data2;
|
|
97410
97469
|
}
|
|
97411
|
-
const compressed = codec === "zstd" ? zstdBytes(data2) : await gzipBytes(data2);
|
|
97470
|
+
const compressed = codec === "zstd" ? (opts == null ? void 0 : opts.preferAsync) && data2.length >= COMPRESSION_ASYNC_MIN_BYTES ? await zstdBytesAsync(data2) : zstdBytes(data2) : await gzipBytes(data2);
|
|
97412
97471
|
const format2 = codec === "zstd" ? SerializationFormat$1.ZSTD : SerializationFormat$1.GZIP;
|
|
97413
97472
|
const wrappedLength = 4 + compressed.length;
|
|
97414
97473
|
if (wrappedLength >= data2.length * (1 - COMPRESSION_MIN_SAVINGS_RATIO)) {
|
|
@@ -97464,7 +97523,7 @@ async function serialize$3(value, encryptionKey, options) {
|
|
|
97464
97523
|
try {
|
|
97465
97524
|
const payload = devalueCodec.serialize(value, "client", options);
|
|
97466
97525
|
const prefixed = encodeWithFormatPrefix(SerializationFormat$1.DEVALUE_V1, payload);
|
|
97467
|
-
const compressed = await compress(prefixed, (options == null ? void 0 : options.compression) ?? false, options == null ? void 0 : options.compressionStats);
|
|
97526
|
+
const compressed = await compress(prefixed, (options == null ? void 0 : options.compression) ?? false, options == null ? void 0 : options.compressionStats, { preferAsync: true });
|
|
97468
97527
|
return encrypt(compressed, encryptionKey);
|
|
97469
97528
|
} catch (error2) {
|
|
97470
97529
|
rethrowIfRuntimeError(error2);
|
|
@@ -107377,7 +107436,7 @@ function getCompressionMode(capabilities) {
|
|
|
107377
107436
|
}
|
|
107378
107437
|
return capabilities.supportedFormats.has(SerializationFormat$1.ZSTD) ? true : "gzip";
|
|
107379
107438
|
}
|
|
107380
|
-
const version$1 = "5.2.
|
|
107439
|
+
const version$1 = "5.2.1";
|
|
107381
107440
|
const DEFAULT_HEALTH_CHECK_TIMEOUT = 3e4;
|
|
107382
107441
|
const SAFE_WORKFLOW_NAME_PATTERN = /^[a-zA-Z0-9_\-./@()[\]]+$/;
|
|
107383
107442
|
function getWorkflowQueueName(workflowName, namespace2) {
|
|
@@ -107568,7 +107627,7 @@ function getSnapshotThresholdFromEnv(env2 = process.env) {
|
|
|
107568
107627
|
return parsed;
|
|
107569
107628
|
}
|
|
107570
107629
|
function waitUntil(promise2) {
|
|
107571
|
-
void import("./index-
|
|
107630
|
+
void import("./index-C3Gx8HYZ.js").then((n) => n.i).then(({ waitUntil: waitUntil2 }) => {
|
|
107572
107631
|
waitUntil2(promise2);
|
|
107573
107632
|
});
|
|
107574
107633
|
}
|
|
@@ -107856,9 +107915,11 @@ async function start$1(workflow, argsOrOptions, options) {
|
|
|
107856
107915
|
}
|
|
107857
107916
|
const workflowVm = getWorkflowVmFromEnv();
|
|
107858
107917
|
const snapshotThreshold = getSnapshotThresholdFromEnv();
|
|
107918
|
+
const queueNamespace = resolveQueueNamespace(opts.namespace);
|
|
107859
107919
|
const executionContext = {
|
|
107860
107920
|
traceCarrier,
|
|
107861
107921
|
workflowCoreVersion: version$1,
|
|
107922
|
+
...queueNamespace ? { queueNamespace } : {},
|
|
107862
107923
|
...targetNodeVersion ? { nodeVersion: targetNodeVersion } : {},
|
|
107863
107924
|
features: { encryption: !!encryptionKey },
|
|
107864
107925
|
...targetHookResumeInputVersion !== void 0 ? { hookResumeInputVersion: targetHookResumeInputVersion } : {},
|
|
@@ -107875,7 +107936,8 @@ async function start$1(workflow, argsOrOptions, options) {
|
|
|
107875
107936
|
}
|
|
107876
107937
|
}
|
|
107877
107938
|
const compression = specVersion >= SPEC_VERSION_SUPPORTS_COMPRESSION ? targetCompression : false;
|
|
107878
|
-
const
|
|
107939
|
+
const argumentCompression = opts.compressArguments === false ? false : compression;
|
|
107940
|
+
const workflowArguments = await dehydrateWorkflowArguments(args, runId, encryptionKey, ops, globalThis, v1Compat, framedByteStreams, argumentCompression);
|
|
107879
107941
|
let dynamicWorkflowCode;
|
|
107880
107942
|
let dynamicWorkflowCodeRef;
|
|
107881
107943
|
if (dynamicWorkflow) {
|
|
@@ -108783,6 +108845,25 @@ function once(fn2) {
|
|
|
108783
108845
|
};
|
|
108784
108846
|
return result;
|
|
108785
108847
|
}
|
|
108848
|
+
function withInProcessLock(locks, key, fn2) {
|
|
108849
|
+
const prev = locks.get(key);
|
|
108850
|
+
const taskBox = {};
|
|
108851
|
+
const task = (async () => {
|
|
108852
|
+
if (prev) {
|
|
108853
|
+
await prev.catch(() => void 0);
|
|
108854
|
+
}
|
|
108855
|
+
try {
|
|
108856
|
+
return await fn2();
|
|
108857
|
+
} finally {
|
|
108858
|
+
if (locks.get(key) === taskBox.task) {
|
|
108859
|
+
locks.delete(key);
|
|
108860
|
+
}
|
|
108861
|
+
}
|
|
108862
|
+
})();
|
|
108863
|
+
taskBox.task = task;
|
|
108864
|
+
locks.set(key, task);
|
|
108865
|
+
return task;
|
|
108866
|
+
}
|
|
108786
108867
|
const getDataDirFromEnv = () => {
|
|
108787
108868
|
return process.env.WORKFLOW_LOCAL_DATA_DIR || ".workflow-data";
|
|
108788
108869
|
};
|
|
@@ -111517,17 +111598,15 @@ async function inspectEntityDirs(dataDir) {
|
|
|
111517
111598
|
runScoped: false
|
|
111518
111599
|
};
|
|
111519
111600
|
for (const entityDir of RUN_SCOPED_ENTITY_DIRS) {
|
|
111520
|
-
let dir;
|
|
111521
111601
|
try {
|
|
111522
|
-
|
|
111602
|
+
for await (const entry2 of await opendir(path$3.join(dataDir, entityDir))) {
|
|
111603
|
+
classifyEntityDirEntry(layout, entityDir, entry2);
|
|
111604
|
+
}
|
|
111523
111605
|
} catch (error2) {
|
|
111524
111606
|
if (error2.code === "ENOENT")
|
|
111525
111607
|
continue;
|
|
111526
111608
|
throw error2;
|
|
111527
111609
|
}
|
|
111528
|
-
for await (const entry2 of dir) {
|
|
111529
|
-
classifyEntityDirEntry(layout, entityDir, entry2);
|
|
111530
|
-
}
|
|
111531
111610
|
}
|
|
111532
111611
|
return layout;
|
|
111533
111612
|
}
|
|
@@ -138734,6 +138813,11 @@ function createQueue$2(config2) {
|
|
|
138734
138813
|
const closeSignal = closeController.signal;
|
|
138735
138814
|
const inflightMessages = /* @__PURE__ */ new Map();
|
|
138736
138815
|
const directHandlers = /* @__PURE__ */ new Map();
|
|
138816
|
+
const routes2 = /* @__PURE__ */ new Map();
|
|
138817
|
+
const deliveryUrl = (baseUrl, prefix) => {
|
|
138818
|
+
const route = routes2.get(prefix);
|
|
138819
|
+
return route ? createAppRouteUrl(baseUrl, route) : createWorkflowUrl(baseUrl, { type: "flow" });
|
|
138820
|
+
};
|
|
138737
138821
|
const queue = async (queueName, message2, opts) => {
|
|
138738
138822
|
const cleanup = [];
|
|
138739
138823
|
if (opts == null ? void 0 : opts.idempotencyKey) {
|
|
@@ -138745,6 +138829,7 @@ function createQueue$2(config2) {
|
|
|
138745
138829
|
const body2 = transport.serialize(message2);
|
|
138746
138830
|
const { prefix } = parseQueueName(queueName);
|
|
138747
138831
|
const messageId = MessageId.parse(`msg_${generateId2()}`);
|
|
138832
|
+
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
138748
138833
|
const msg = message2;
|
|
138749
138834
|
const runId = msg.runId ?? void 0;
|
|
138750
138835
|
const stepId = msg.stepId ?? void 0;
|
|
@@ -138774,20 +138859,19 @@ function createQueue$2(config2) {
|
|
|
138774
138859
|
"content-type": "application/json",
|
|
138775
138860
|
"x-vqs-queue-name": queueName,
|
|
138776
138861
|
"x-vqs-message-id": messageId,
|
|
138777
|
-
"x-vqs-message-attempt": String(delivery + 1)
|
|
138862
|
+
"x-vqs-message-attempt": String(delivery + 1),
|
|
138863
|
+
"x-vqs-message-created-at": createdAt
|
|
138778
138864
|
};
|
|
138779
138865
|
const directHandler = directHandlers.get(prefix);
|
|
138780
138866
|
let response2;
|
|
138781
138867
|
let text2;
|
|
138782
138868
|
try {
|
|
138783
138869
|
if (directHandler) {
|
|
138784
|
-
const req = new Request(
|
|
138785
|
-
type: "flow"
|
|
138786
|
-
}), { method: "POST", headers: headers2, body: body2 });
|
|
138870
|
+
const req = new Request(deliveryUrl(resolveDirectBaseUrl(config2), prefix), { method: "POST", headers: headers2, body: body2 });
|
|
138787
138871
|
response2 = await directHandler(req);
|
|
138788
138872
|
} else {
|
|
138789
138873
|
const baseUrl = await resolveBaseUrl(config2);
|
|
138790
|
-
const url =
|
|
138874
|
+
const url = deliveryUrl(baseUrl, prefix);
|
|
138791
138875
|
response2 = nodeHttpAgents ? await nodeHttpFetch(url, {
|
|
138792
138876
|
method: "POST",
|
|
138793
138877
|
headers: new Headers(headers2),
|
|
@@ -138848,7 +138932,10 @@ function createQueue$2(config2) {
|
|
|
138848
138932
|
messageId,
|
|
138849
138933
|
...runId && { runId },
|
|
138850
138934
|
...stepId && { stepId },
|
|
138851
|
-
handlerError: text2
|
|
138935
|
+
handlerError: text2,
|
|
138936
|
+
...!directHandler && !routes2.has(prefix) && (response2.status === 400 || response2.status === 404) && {
|
|
138937
|
+
hint: `No route or handler is registered for queue prefix "${prefix}", so its messages go to the Workflow SDK's flow route (${WORKFLOW_FLOW_ROUTE}). A queue consumer of its own registers one with world.registerRoute(prefix, path) or world.registerHandler(prefix, handler).`
|
|
138938
|
+
}
|
|
138852
138939
|
});
|
|
138853
138940
|
await setTimeout$1(5e3, void 0, { signal: closeSignal });
|
|
138854
138941
|
}
|
|
@@ -138886,7 +138973,11 @@ function createQueue$2(config2) {
|
|
|
138886
138973
|
const HeaderParser = compile(object$1({
|
|
138887
138974
|
"x-vqs-queue-name": ValidQueueName,
|
|
138888
138975
|
"x-vqs-message-id": MessageId,
|
|
138889
|
-
"x-vqs-message-attempt": number$2()
|
|
138976
|
+
"x-vqs-message-attempt": number$2(),
|
|
138977
|
+
// Sent by world-postgres, whose `attempt` restarts on a reschedule.
|
|
138978
|
+
"x-vqs-message-delivery-count": number$2().int().positive().optional(),
|
|
138979
|
+
// Absent on a delivery from a sender that predates it.
|
|
138980
|
+
"x-vqs-message-created-at": datetime().optional()
|
|
138890
138981
|
}));
|
|
138891
138982
|
const createQueueHandler = (prefix, handler) => {
|
|
138892
138983
|
return async (req) => {
|
|
@@ -138899,12 +138990,25 @@ function createQueue$2(config2) {
|
|
|
138899
138990
|
const queueName = headers2.data["x-vqs-queue-name"];
|
|
138900
138991
|
const messageId = headers2.data["x-vqs-message-id"];
|
|
138901
138992
|
const attempt = headers2.data["x-vqs-message-attempt"];
|
|
138993
|
+
const deliveryCountHeader = headers2.data["x-vqs-message-delivery-count"];
|
|
138994
|
+
const createdAtHeader = headers2.data["x-vqs-message-created-at"];
|
|
138902
138995
|
if (!queueName.startsWith(prefix)) {
|
|
138903
|
-
return Response.json({
|
|
138996
|
+
return Response.json({
|
|
138997
|
+
error: "Unhandled queue",
|
|
138998
|
+
detail: `This route handles queue prefix "${prefix}", not "${queueName}".`
|
|
138999
|
+
}, { status: 400 });
|
|
138904
139000
|
}
|
|
138905
139001
|
const body2 = await new TypedJsonTransport().deserialize(req.body);
|
|
138906
139002
|
try {
|
|
138907
|
-
const result = await handler(body2, {
|
|
139003
|
+
const result = await handler(body2, {
|
|
139004
|
+
attempt,
|
|
139005
|
+
// Counts every delivery of this message that reached a handler,
|
|
139006
|
+
// starting at 1, including `{ timeoutSeconds }` redeliveries.
|
|
139007
|
+
deliveryCount: deliveryCountHeader ?? attempt,
|
|
139008
|
+
...createdAtHeader ? { createdAt: new Date(createdAtHeader) } : {},
|
|
139009
|
+
queueName,
|
|
139010
|
+
messageId
|
|
139011
|
+
});
|
|
138908
139012
|
if (typeof body2 === "object" && body2 !== null && "invoke" in body2 && body2.invoke === true) {
|
|
138909
139013
|
return Response.json({ result });
|
|
138910
139014
|
}
|
|
@@ -138932,6 +139036,9 @@ function createQueue$2(config2) {
|
|
|
138932
139036
|
registerHandler(prefix, handler) {
|
|
138933
139037
|
directHandlers.set(prefix, handler);
|
|
138934
139038
|
},
|
|
139039
|
+
registerRoute(prefix, path2) {
|
|
139040
|
+
routes2.set(QueuePrefix.parse(prefix), parseQueueRoute(path2));
|
|
139041
|
+
},
|
|
138935
139042
|
async close() {
|
|
138936
139043
|
if (closeSignal.aborted)
|
|
138937
139044
|
return;
|
|
@@ -139178,6 +139285,11 @@ const monotonicUlid = (seedTime) => chunkIds.next(seedTime);
|
|
|
139178
139285
|
const RunStreamsSchema = compile(object$1({
|
|
139179
139286
|
streams: array$1(string$2())
|
|
139180
139287
|
}));
|
|
139288
|
+
const RUN_STREAMS_LOCK_OPTIONS = {
|
|
139289
|
+
realpath: false,
|
|
139290
|
+
stale: 1e4,
|
|
139291
|
+
retries: { retries: 150, factor: 1, minTimeout: 100, maxTimeout: 100 }
|
|
139292
|
+
};
|
|
139181
139293
|
const EOF_MARKER = 1;
|
|
139182
139294
|
function isEofByte(byte) {
|
|
139183
139295
|
return byte === EOF_MARKER;
|
|
@@ -139268,21 +139380,65 @@ function createStreamer$1(basedir, tag) {
|
|
|
139268
139380
|
const tagSuffix = tag ? `.${tag}` : "";
|
|
139269
139381
|
const streamEmitter = new EventEmitter();
|
|
139270
139382
|
const registeredStreams = /* @__PURE__ */ new Set();
|
|
139271
|
-
|
|
139383
|
+
const runStreamsLocks = /* @__PURE__ */ new Map();
|
|
139384
|
+
let warnedRunStreamsLockFailure = false;
|
|
139385
|
+
async function readRunStreams(runId) {
|
|
139386
|
+
const data2 = await readJSONWithFallback(basedir, "streams/runs", runId, RunStreamsSchema, tag);
|
|
139387
|
+
return (data2 == null ? void 0 : data2.streams) ?? [];
|
|
139388
|
+
}
|
|
139389
|
+
async function registerStreamForRun(runId, streamName, { verify = false } = {}) {
|
|
139272
139390
|
assertSafeEntityId("runId", runId);
|
|
139273
139391
|
assertSafeEntityId("streamName", streamName);
|
|
139274
139392
|
const cacheKey = `${runId}:${streamName}`;
|
|
139275
139393
|
if (registeredStreams.has(cacheKey)) {
|
|
139276
|
-
|
|
139394
|
+
if (!verify)
|
|
139395
|
+
return;
|
|
139396
|
+
const listed = await readRunStreams(runId).catch(() => null);
|
|
139397
|
+
if (listed === null || listed.includes(streamName))
|
|
139398
|
+
return;
|
|
139399
|
+
registeredStreams.delete(cacheKey);
|
|
139277
139400
|
}
|
|
139278
139401
|
const runStreamsPath = taggedPath(basedir, "streams/runs", runId, tag);
|
|
139279
|
-
|
|
139280
|
-
|
|
139281
|
-
|
|
139282
|
-
|
|
139283
|
-
|
|
139402
|
+
await withInProcessLock(runStreamsLocks, runStreamsPath, async () => {
|
|
139403
|
+
if (registeredStreams.has(cacheKey))
|
|
139404
|
+
return;
|
|
139405
|
+
if (await addToRunStreams(runStreamsPath, runId, streamName)) {
|
|
139406
|
+
registeredStreams.add(cacheKey);
|
|
139407
|
+
}
|
|
139408
|
+
});
|
|
139409
|
+
}
|
|
139410
|
+
async function addToRunStreams(runStreamsPath, runId, streamName) {
|
|
139411
|
+
await fs$1.mkdir(path$3.dirname(runStreamsPath), { recursive: true });
|
|
139412
|
+
let compromised = false;
|
|
139413
|
+
let release;
|
|
139414
|
+
try {
|
|
139415
|
+
release = await properLockfileExports.lock(runStreamsPath, {
|
|
139416
|
+
...RUN_STREAMS_LOCK_OPTIONS,
|
|
139417
|
+
// The default handler throws from a timer, which would crash the
|
|
139418
|
+
// process.
|
|
139419
|
+
onCompromised: () => {
|
|
139420
|
+
compromised = true;
|
|
139421
|
+
}
|
|
139422
|
+
});
|
|
139423
|
+
} catch (error2) {
|
|
139424
|
+
if (!warnedRunStreamsLockFailure) {
|
|
139425
|
+
warnedRunStreamsLockFailure = true;
|
|
139426
|
+
console.warn(`[world-local] Could not lock the stream index of run ${runId}; updating it without the lock:`, error2 instanceof Error ? error2.message : error2);
|
|
139427
|
+
}
|
|
139428
|
+
}
|
|
139429
|
+
try {
|
|
139430
|
+
const streams = await readRunStreams(runId);
|
|
139431
|
+
if (!streams.includes(streamName)) {
|
|
139432
|
+
streams.push(streamName);
|
|
139433
|
+
await writeJSON(runStreamsPath, { streams }, { overwrite: true });
|
|
139434
|
+
}
|
|
139435
|
+
} finally {
|
|
139436
|
+
if (release && !compromised) {
|
|
139437
|
+
await release().catch(() => {
|
|
139438
|
+
});
|
|
139439
|
+
}
|
|
139284
139440
|
}
|
|
139285
|
-
|
|
139441
|
+
return !compromised;
|
|
139286
139442
|
}
|
|
139287
139443
|
function toBuffer(chunk) {
|
|
139288
139444
|
if (typeof chunk === "string") {
|
|
@@ -139294,6 +139450,9 @@ function createStreamer$1(basedir, tag) {
|
|
|
139294
139450
|
}
|
|
139295
139451
|
}
|
|
139296
139452
|
return {
|
|
139453
|
+
clearCache() {
|
|
139454
|
+
registeredStreams.clear();
|
|
139455
|
+
},
|
|
139297
139456
|
streams: {
|
|
139298
139457
|
async write(_runId, name2, chunk) {
|
|
139299
139458
|
const chunkId = `chnk_${monotonicUlid()}`;
|
|
@@ -139345,15 +139504,14 @@ function createStreamer$1(basedir, tag) {
|
|
|
139345
139504
|
async close(_runId, name2) {
|
|
139346
139505
|
const chunkId = `chnk_${monotonicUlid()}`;
|
|
139347
139506
|
const runId = await _runId;
|
|
139348
|
-
await registerStreamForRun(runId, name2);
|
|
139507
|
+
await registerStreamForRun(runId, name2, { verify: true });
|
|
139349
139508
|
const chunkPath = path$3.join(chunkDirForStream(path$3.join(basedir, "streams", "chunks"), name2), `${chunkId}${tagSuffix}.bin`);
|
|
139350
139509
|
await write(chunkPath, serializeChunk({ chunk: Buffer.from([]), eof: true }));
|
|
139351
139510
|
streamEmitter.emit(`close:${name2}`, { streamName: name2 });
|
|
139352
139511
|
},
|
|
139353
139512
|
async list(runId) {
|
|
139354
139513
|
assertSafeEntityId("runId", runId);
|
|
139355
|
-
|
|
139356
|
-
return (data2 == null ? void 0 : data2.streams) ?? [];
|
|
139514
|
+
return readRunStreams(runId);
|
|
139357
139515
|
},
|
|
139358
139516
|
async getChunks(_runId, name2, options) {
|
|
139359
139517
|
const limit = (options == null ? void 0 : options.limit) ?? 100;
|
|
@@ -140039,24 +140197,12 @@ async function pinCanonicalEventIdForLegacyClaim(basedir, token, runId, hookId,
|
|
|
140039
140197
|
const existing = await readHookRecoveryMarker(markerPath);
|
|
140040
140198
|
return (existing == null ? void 0 : existing.eventId) ?? null;
|
|
140041
140199
|
}
|
|
140042
|
-
function
|
|
140043
|
-
|
|
140044
|
-
|
|
140045
|
-
|
|
140046
|
-
|
|
140047
|
-
|
|
140048
|
-
}
|
|
140049
|
-
try {
|
|
140050
|
-
return await fn2();
|
|
140051
|
-
} finally {
|
|
140052
|
-
if (locks.get(key) === taskBox.task) {
|
|
140053
|
-
locks.delete(key);
|
|
140054
|
-
}
|
|
140055
|
-
}
|
|
140056
|
-
})();
|
|
140057
|
-
taskBox.task = task;
|
|
140058
|
-
locks.set(key, task);
|
|
140059
|
-
return task;
|
|
140200
|
+
function isDefinitiveRefusal(error2) {
|
|
140201
|
+
if (EntityConflictError.is(error2) || RunExpiredError.is(error2) || TooEarlyError.is(error2) || HookNotFoundError.is(error2) || HookForceClaimedError.is(error2) || WorkflowRunNotFoundError.is(error2) || RunNotSupportedError.is(error2)) {
|
|
140202
|
+
return true;
|
|
140203
|
+
}
|
|
140204
|
+
const status = error2 == null ? void 0 : error2.status;
|
|
140205
|
+
return typeof status === "number" && status >= 400 && status < 500;
|
|
140060
140206
|
}
|
|
140061
140207
|
async function deleteAllWaitsForRun(basedir, runId) {
|
|
140062
140208
|
const waitsDir = path$3.join(basedir, "waits");
|
|
@@ -140086,6 +140232,19 @@ async function writeRunUnderLifecycleLock(basedir, runId, tag, proposed) {
|
|
|
140086
140232
|
return { run: next2, purged };
|
|
140087
140233
|
});
|
|
140088
140234
|
}
|
|
140235
|
+
function inBandFenceState() {
|
|
140236
|
+
return globalSingleton("@workflow/world-local//inBandFence", 2, () => ({
|
|
140237
|
+
locks: /* @__PURE__ */ new Map()
|
|
140238
|
+
}));
|
|
140239
|
+
}
|
|
140240
|
+
const InBandCountSchema = object$1({
|
|
140241
|
+
seqInBand: number$3().int().nonnegative(),
|
|
140242
|
+
pending: number$3().int().nonnegative().optional()
|
|
140243
|
+
});
|
|
140244
|
+
function inBandCountPath(basedir, runId, tag) {
|
|
140245
|
+
const name2 = tag ? `${runId}.in-band.${tag}` : `${runId}.in-band`;
|
|
140246
|
+
return resolveWithinBase(basedir, ".locks", "runs", name2);
|
|
140247
|
+
}
|
|
140089
140248
|
function createEventsStorage(basedir, tag) {
|
|
140090
140249
|
const hookRetentionLimitMs = getHookRetentionLimitMs();
|
|
140091
140250
|
const maxCachedEventBytes = 4 * 1024 * 1024;
|
|
@@ -141446,7 +141605,122 @@ function createEventsStorage(basedir, tag) {
|
|
|
141446
141605
|
}
|
|
141447
141606
|
return reportSkippedSlots(result, params.eventCount, resolveData);
|
|
141448
141607
|
});
|
|
141449
|
-
|
|
141608
|
+
const fenceState = inBandFenceState();
|
|
141609
|
+
const fenceKey = (runId) => `${path$3.resolve(basedir)}\0${slotStateKey(runId)}`;
|
|
141610
|
+
const readInBandCount = async (runId) => await readJSON(inBandCountPath(basedir, runId, tag), InBandCountSchema) ?? {
|
|
141611
|
+
seqInBand: IN_BAND_SEQ_AT_RUN_CREATION
|
|
141612
|
+
};
|
|
141613
|
+
const writeInBandCount = (runId, count2) => writeJSON(inBandCountPath(basedir, runId, tag), count2, {
|
|
141614
|
+
overwrite: true
|
|
141615
|
+
});
|
|
141616
|
+
async function readTopSlot(runId) {
|
|
141617
|
+
const state = runSlotState.get(slotStateKey(runId));
|
|
141618
|
+
if (state === null)
|
|
141619
|
+
return void 0;
|
|
141620
|
+
const scan = await scanRunEventIds(basedir, runId, tag);
|
|
141621
|
+
if (state === void 0 && scan.count > 0 && !scan.usesSlots) {
|
|
141622
|
+
return void 0;
|
|
141623
|
+
}
|
|
141624
|
+
return Math.max((state == null ? void 0 : state.published) ?? 0, scan.maxSlot);
|
|
141625
|
+
}
|
|
141626
|
+
async function settledInBandCount(runId) {
|
|
141627
|
+
const count2 = await readInBandCount(runId);
|
|
141628
|
+
if (count2.pending === void 0)
|
|
141629
|
+
return count2.seqInBand;
|
|
141630
|
+
const settled = Math.max(count2.seqInBand, count2.pending + 1);
|
|
141631
|
+
await writeInBandCount(runId, { seqInBand: settled });
|
|
141632
|
+
return settled;
|
|
141633
|
+
}
|
|
141634
|
+
async function supersededAt(runId, expected, current2) {
|
|
141635
|
+
const seq = await readTopSlot(runId).catch(() => void 0);
|
|
141636
|
+
return new InBandSupersededError(`In-band write on run ${runId} expected seqInBand ${expected}, but the run is at ${current2}. Another orchestrator wrote in-band events this one has not seen; stop writing and redeliver.`, { seqInBand: current2, ...seq !== void 0 ? { seq } : {} });
|
|
141637
|
+
}
|
|
141638
|
+
function withFenceLock(runId, fn2) {
|
|
141639
|
+
return withInProcessLock(fenceState.locks, fenceKey(runId), async () => {
|
|
141640
|
+
const countPath = inBandCountPath(basedir, runId, tag);
|
|
141641
|
+
await fs$1.mkdir(path$3.dirname(countPath), { recursive: true });
|
|
141642
|
+
let compromised;
|
|
141643
|
+
let release;
|
|
141644
|
+
try {
|
|
141645
|
+
release = await properLockfileExports.lock(countPath, {
|
|
141646
|
+
realpath: false,
|
|
141647
|
+
stale: 3e4,
|
|
141648
|
+
update: 1e3,
|
|
141649
|
+
retries: {
|
|
141650
|
+
retries: 350,
|
|
141651
|
+
factor: 1,
|
|
141652
|
+
minTimeout: 100,
|
|
141653
|
+
maxTimeout: 100
|
|
141654
|
+
},
|
|
141655
|
+
onCompromised(error2) {
|
|
141656
|
+
compromised = error2;
|
|
141657
|
+
}
|
|
141658
|
+
});
|
|
141659
|
+
} catch (error2) {
|
|
141660
|
+
throw new WorkflowWorldError(`Could not acquire the in-band fence lock of run ${runId}`, { cause: error2 });
|
|
141661
|
+
}
|
|
141662
|
+
let result;
|
|
141663
|
+
try {
|
|
141664
|
+
result = await fn2();
|
|
141665
|
+
} finally {
|
|
141666
|
+
if (!compromised)
|
|
141667
|
+
await release().catch(() => {
|
|
141668
|
+
});
|
|
141669
|
+
}
|
|
141670
|
+
if (compromised) {
|
|
141671
|
+
throw new WorkflowWorldError(`The in-band fence lock of run ${runId} was lost while a write held it`, { cause: compromised });
|
|
141672
|
+
}
|
|
141673
|
+
return result;
|
|
141674
|
+
});
|
|
141675
|
+
}
|
|
141676
|
+
const fencedCreate = (async (runId, request2, params) => {
|
|
141677
|
+
const data2 = request2;
|
|
141678
|
+
if (!(params == null ? void 0 : params.inBand) || !runId || request2.eventType === "run_created") {
|
|
141679
|
+
return create2(runId, data2, params);
|
|
141680
|
+
}
|
|
141681
|
+
const expected = params.expectedSeqInBand;
|
|
141682
|
+
if (expected === void 0 || !Number.isSafeInteger(expected) || expected < 0) {
|
|
141683
|
+
throw new WorkflowWorldError(`An in-band write to run ${runId} must carry a nonnegative integer expectedSeqInBand`, { status: 400 });
|
|
141684
|
+
}
|
|
141685
|
+
assertSafeEntityId("runId", runId);
|
|
141686
|
+
return withFenceLock(runId, async () => {
|
|
141687
|
+
const current2 = await settledInBandCount(runId);
|
|
141688
|
+
if (current2 !== expected)
|
|
141689
|
+
throw await supersededAt(runId, expected, current2);
|
|
141690
|
+
await writeInBandCount(runId, { seqInBand: current2, pending: current2 });
|
|
141691
|
+
let result;
|
|
141692
|
+
try {
|
|
141693
|
+
result = await create2(runId, data2, params);
|
|
141694
|
+
} catch (error2) {
|
|
141695
|
+
await writeInBandCount(runId, {
|
|
141696
|
+
seqInBand: isDefinitiveRefusal(error2) ? current2 : current2 + 1
|
|
141697
|
+
});
|
|
141698
|
+
throw error2;
|
|
141699
|
+
}
|
|
141700
|
+
const allocated = result.event ? 1 : 0;
|
|
141701
|
+
await writeInBandCount(runId, { seqInBand: current2 + allocated });
|
|
141702
|
+
return { ...result, allocated };
|
|
141703
|
+
});
|
|
141704
|
+
});
|
|
141705
|
+
async function readEventLogSnapshot(runId) {
|
|
141706
|
+
const { seqInBand } = await readInBandCount(runId);
|
|
141707
|
+
const state = runSlotState.get(slotStateKey(runId));
|
|
141708
|
+
if (state === null)
|
|
141709
|
+
return void 0;
|
|
141710
|
+
if (state !== void 0)
|
|
141711
|
+
return { seq: state.published, seqInBand };
|
|
141712
|
+
const scan = await scanRunEventIds(basedir, runId, tag);
|
|
141713
|
+
if (scan.count > 0 && !scan.usesSlots)
|
|
141714
|
+
return void 0;
|
|
141715
|
+
return { seq: scan.maxSlot, seqInBand };
|
|
141716
|
+
}
|
|
141717
|
+
const list = (async (params) => {
|
|
141718
|
+
assertSafeEntityId("runId", params.runId);
|
|
141719
|
+
const snapshot = await readEventLogSnapshot(params.runId);
|
|
141720
|
+
const result = await storage.list(params);
|
|
141721
|
+
return snapshot ? { ...result, snapshot } : result;
|
|
141722
|
+
});
|
|
141723
|
+
return { ...storage, create: fencedCreate, list };
|
|
141450
141724
|
}
|
|
141451
141725
|
function createSnapshotsStorage$1(basedir) {
|
|
141452
141726
|
const snapshotsDir = path$3.join(basedir, "snapshots");
|
|
@@ -141559,6 +141833,7 @@ function createWorld$2(args) {
|
|
|
141559
141833
|
const tag = mergedConfig.tag;
|
|
141560
141834
|
const queue = createQueue$2(mergedConfig);
|
|
141561
141835
|
const { clearCache: clearStorageCache, ...storage } = createStorage$1(mergedConfig.dataDir, tag);
|
|
141836
|
+
const { clearCache: clearStreamerCache, ...streamer } = createStreamer$1(mergedConfig.dataDir, tag);
|
|
141562
141837
|
const recoverActiveRuns = resolveRecoverActiveRuns(mergedConfig);
|
|
141563
141838
|
return {
|
|
141564
141839
|
specVersion: mintedSpecVersion(),
|
|
@@ -141575,12 +141850,16 @@ function createWorld$2(args) {
|
|
|
141575
141850
|
// The token claim lock serializes the takeover behind
|
|
141576
141851
|
// `createHook({ experimental_force: true })`; see the hook_created
|
|
141577
141852
|
// branch of storage/events-storage.ts.
|
|
141578
|
-
hookForceClaim: true
|
|
141853
|
+
hookForceClaim: true,
|
|
141854
|
+
// A per-run in-band count on disk, under a lock file, so every process
|
|
141855
|
+
// on the data directory shares it; see the in-band writer fence in
|
|
141856
|
+
// storage/events-storage.ts.
|
|
141857
|
+
inBandFence: true
|
|
141579
141858
|
},
|
|
141580
141859
|
...queue,
|
|
141581
141860
|
...storage,
|
|
141582
141861
|
...instrumentObject$1("world.streams", {
|
|
141583
|
-
...
|
|
141862
|
+
...streamer,
|
|
141584
141863
|
...mergedConfig.streamFlushIntervalMs !== void 0 && {
|
|
141585
141864
|
streamFlushIntervalMs: mergedConfig.streamFlushIntervalMs
|
|
141586
141865
|
}
|
|
@@ -141610,7 +141889,7 @@ function createWorld$2(args) {
|
|
|
141610
141889
|
const basedir = mergedConfig.dataDir;
|
|
141611
141890
|
const hooksDir = path$3.join(basedir, "hooks");
|
|
141612
141891
|
const taggedHookFiles = await listTaggedFiles(hooksDir, tag);
|
|
141613
|
-
const { HookSchema: HookSchema2 } = await import("./index-
|
|
141892
|
+
const { HookSchema: HookSchema2 } = await import("./index-D1YkUiuC.js");
|
|
141614
141893
|
await settleAll(taggedHookFiles.map(async (hookFile) => {
|
|
141615
141894
|
const hook = await readJSON(path$3.join(hooksDir, hookFile), HookSchema2);
|
|
141616
141895
|
if (hook == null ? void 0 : hook.token) {
|
|
@@ -141676,6 +141955,7 @@ function createWorld$2(args) {
|
|
|
141676
141955
|
await rm(mergedConfig.dataDir, { recursive: true, force: true });
|
|
141677
141956
|
await initDataDir(mergedConfig.dataDir);
|
|
141678
141957
|
}
|
|
141958
|
+
clearStreamerCache();
|
|
141679
141959
|
}
|
|
141680
141960
|
};
|
|
141681
141961
|
}
|
|
@@ -141797,8 +142077,8 @@ function requireGetVercelOidcToken() {
|
|
|
141797
142077
|
}
|
|
141798
142078
|
try {
|
|
141799
142079
|
const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
|
|
141800
|
-
await import("./token-util-
|
|
141801
|
-
await import("./token-
|
|
142080
|
+
await import("./token-util-BXkc19cz.js").then((n) => n.t),
|
|
142081
|
+
await import("./token-DbFnZp4-.js").then((n) => n.t)
|
|
141802
142082
|
]);
|
|
141803
142083
|
if (!token || isExpired(getTokenPayload(token), options == null ? void 0 : options.expirationBufferMs)) {
|
|
141804
142084
|
await refreshToken(options);
|
|
@@ -142361,7 +142641,7 @@ function requireDist() {
|
|
|
142361
142641
|
return dist;
|
|
142362
142642
|
}
|
|
142363
142643
|
var distExports = requireDist();
|
|
142364
|
-
const version = "5.2.
|
|
142644
|
+
const version = "5.2.1";
|
|
142365
142645
|
const pools = globalSingleton("@workflow/world-vercel//httpPools", 1, () => ({
|
|
142366
142646
|
dispatcher: void 0,
|
|
142367
142647
|
queueDispatcher: void 0,
|
|
@@ -142842,6 +143122,9 @@ const WorkflowStreamStartIndex = SemanticConvention("workflow.stream.start_index
|
|
|
142842
143122
|
const WorkflowEventsTransport = SemanticConvention("workflow.events.transport");
|
|
142843
143123
|
const WorkflowHttpTransport = SemanticConvention("workflow.http.transport");
|
|
142844
143124
|
const WorkflowEventType = SemanticConvention("workflow.event.type");
|
|
143125
|
+
const WorkflowEventInBand = SemanticConvention("workflow.event.in_band");
|
|
143126
|
+
const WorkflowEventExpectedSeqInBand = SemanticConvention("workflow.event.expected_seq_in_band");
|
|
143127
|
+
const WorkflowEventSeqInBand = SemanticConvention("workflow.event.seq_in_band");
|
|
142845
143128
|
const WorkflowStepStartMode = SemanticConvention("workflow.step_start.mode");
|
|
142846
143129
|
const WorkflowStepStartOwnerStamped = SemanticConvention("workflow.step_start.owner_stamped");
|
|
142847
143130
|
const WorkflowClientVersion = SemanticConvention("workflow.client.version");
|
|
@@ -142973,6 +143256,14 @@ function headersToRecord$1(headers2) {
|
|
|
142973
143256
|
});
|
|
142974
143257
|
return out;
|
|
142975
143258
|
}
|
|
143259
|
+
function recordInBandRefusal(span, error2) {
|
|
143260
|
+
if (InBandSupersededError.is(error2) && error2.seqInBand !== void 0) {
|
|
143261
|
+
span == null ? void 0 : span.setAttributes(WorkflowEventSeqInBand(error2.seqInBand));
|
|
143262
|
+
}
|
|
143263
|
+
}
|
|
143264
|
+
function inBandCounter(value) {
|
|
143265
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : void 0;
|
|
143266
|
+
}
|
|
142976
143267
|
function errorForResponse(status, message2, opts = {}) {
|
|
142977
143268
|
const { retryAfter, code: code2, url, mitigated, details } = opts;
|
|
142978
143269
|
if (status === 409 && code2 === "hook-force-claimed") {
|
|
@@ -142989,6 +143280,13 @@ function errorForResponse(status, message2, opts = {}) {
|
|
|
142989
143280
|
}
|
|
142990
143281
|
return new RunExpiredError(message2);
|
|
142991
143282
|
}
|
|
143283
|
+
if (status === 412 && code2 === IN_BAND_SUPERSEDED_CODE) {
|
|
143284
|
+
const counters = details && typeof details === "object" ? details : void 0;
|
|
143285
|
+
return new InBandSupersededError(message2, {
|
|
143286
|
+
seq: inBandCounter(counters == null ? void 0 : counters.seq),
|
|
143287
|
+
seqInBand: inBandCounter(counters == null ? void 0 : counters.seqInBand)
|
|
143288
|
+
});
|
|
143289
|
+
}
|
|
142992
143290
|
if (status === 412)
|
|
142993
143291
|
return new PreconditionFailedError(message2, { retryAfter, details });
|
|
142994
143292
|
if (status === 425)
|
|
@@ -143164,6 +143462,7 @@ async function instrumentedFetch(opts) {
|
|
|
143164
143462
|
throw cause;
|
|
143165
143463
|
}
|
|
143166
143464
|
onTransportOutcome == null ? void 0 : onTransportOutcome(void 0, response2);
|
|
143465
|
+
recordInBandRefusal(span, error3);
|
|
143167
143466
|
(_d2 = span == null ? void 0 : span.recordException) == null ? void 0 : _d2.call(span, error3);
|
|
143168
143467
|
throw error3;
|
|
143169
143468
|
}
|
|
@@ -144099,7 +144398,7 @@ function validateRunExecutionContext(value) {
|
|
|
144099
144398
|
}
|
|
144100
144399
|
}
|
|
144101
144400
|
async function getDeadline() {
|
|
144102
|
-
const { getDeadline: getDeadline2 } = await import("./index-
|
|
144401
|
+
const { getDeadline: getDeadline2 } = await import("./index-C3Gx8HYZ.js").then((n) => n.i);
|
|
144103
144402
|
return getDeadline2();
|
|
144104
144403
|
}
|
|
144105
144404
|
const WORKFLOW_SERVER_SERVICE = {
|
|
@@ -149989,6 +150288,8 @@ function throttleBudgetFor(eventType, options) {
|
|
|
149989
150288
|
}
|
|
149990
150289
|
function isEligibleForTransientRetry(eventType, options) {
|
|
149991
150290
|
var _a3;
|
|
150291
|
+
if ((options == null ? void 0 : options.inBand) === true)
|
|
150292
|
+
return false;
|
|
149992
150293
|
if ((options == null ? void 0 : options.batchIdempotent) !== void 0) {
|
|
149993
150294
|
return options.batchIdempotent;
|
|
149994
150295
|
}
|
|
@@ -150411,7 +150712,14 @@ const CreateEventV4BodyBaseSchema = object$1({
|
|
|
150411
150712
|
hook: HookSchema.optional(),
|
|
150412
150713
|
wait: WaitSchema.optional(),
|
|
150413
150714
|
stepCreated: literal$1(true).optional(),
|
|
150414
|
-
maxEvents: number$3().int().positive().optional()
|
|
150715
|
+
maxEvents: number$3().int().positive().optional(),
|
|
150716
|
+
// Positions the backend allocated for this write, when it reports them
|
|
150717
|
+
// (`EventResult.allocated`): what an in-band writer advances its count by.
|
|
150718
|
+
// Passed on for a single create answered with this body. A batch's item
|
|
150719
|
+
// results reuse this schema, but a batch is one allocation for the whole
|
|
150720
|
+
// block and its count is not passed on, nor is one on the streamed
|
|
150721
|
+
// `run_started` and `hook_received` preload responses.
|
|
150722
|
+
allocated: number$3().int().nonnegative().optional()
|
|
150415
150723
|
});
|
|
150416
150724
|
const CreateEventV4PageSchema = union([
|
|
150417
150725
|
object$1({
|
|
@@ -150462,10 +150770,38 @@ const CreateEventV4BodySchemas = {
|
|
|
150462
150770
|
noop: CreateEventV4BodySchema
|
|
150463
150771
|
};
|
|
150464
150772
|
const MaxEventsHeaderSchema = compile(number$2().int().positive());
|
|
150773
|
+
const EventLogSnapshotWireSchema = compile(object$1({
|
|
150774
|
+
seq: number$3().int().nonnegative(),
|
|
150775
|
+
seqInBand: number$3().int().nonnegative()
|
|
150776
|
+
}).refine(({ seq, seqInBand }) => seqInBand <= seq));
|
|
150777
|
+
const SNAPSHOT_SEQ_HEADER = "x-wf-snapshot-seq";
|
|
150778
|
+
const SNAPSHOT_SEQ_IN_BAND_HEADER = "x-wf-snapshot-seq-in-band";
|
|
150779
|
+
const DECIMAL_COUNTER = /^\d+$/;
|
|
150780
|
+
function snapshotFromHeaders(headers2) {
|
|
150781
|
+
const seq = headers2.get(SNAPSHOT_SEQ_HEADER);
|
|
150782
|
+
const seqInBand = headers2.get(SNAPSHOT_SEQ_IN_BAND_HEADER);
|
|
150783
|
+
if (seq === null || seqInBand === null || !DECIMAL_COUNTER.test(seq) || !DECIMAL_COUNTER.test(seqInBand)) {
|
|
150784
|
+
return void 0;
|
|
150785
|
+
}
|
|
150786
|
+
const parsed = EventLogSnapshotWireSchema.safeParse({
|
|
150787
|
+
seq: Number(seq),
|
|
150788
|
+
seqInBand: Number(seqInBand)
|
|
150789
|
+
});
|
|
150790
|
+
return parsed.success ? parsed.data : void 0;
|
|
150791
|
+
}
|
|
150792
|
+
function snapshotFromEnd(snapshot) {
|
|
150793
|
+
if (snapshot === void 0)
|
|
150794
|
+
return void 0;
|
|
150795
|
+
const parsed = EventLogSnapshotWireSchema.safeParse(snapshot);
|
|
150796
|
+
return parsed.success ? parsed.data : void 0;
|
|
150797
|
+
}
|
|
150465
150798
|
const EventStreamEndSchema = compile(object$1({
|
|
150466
150799
|
_end: literal$1(1),
|
|
150467
150800
|
next: string$2().optional(),
|
|
150468
|
-
hasMore: boolean$2()
|
|
150801
|
+
hasMore: boolean$2(),
|
|
150802
|
+
// Read on its own (`snapshotFromEnd`): a malformed snapshot lists none
|
|
150803
|
+
// rather than failing the page.
|
|
150804
|
+
snapshot: unknown$1().optional()
|
|
150469
150805
|
}));
|
|
150470
150806
|
const EventStreamErrorSchema = compile(object$1({
|
|
150471
150807
|
_error: literal$1(1),
|
|
@@ -150609,8 +150945,19 @@ function buildPostFrameMeta(input) {
|
|
|
150609
150945
|
if (input.viaStepDispatch !== void 0) {
|
|
150610
150946
|
meta.viaStepDispatch = input.viaStepDispatch;
|
|
150611
150947
|
}
|
|
150948
|
+
if (input.inBand !== void 0)
|
|
150949
|
+
meta.inBand = input.inBand;
|
|
150950
|
+
if (input.expectedSeqInBand !== void 0) {
|
|
150951
|
+
meta.expectedSeqInBand = input.expectedSeqInBand;
|
|
150952
|
+
}
|
|
150612
150953
|
return meta;
|
|
150613
150954
|
}
|
|
150955
|
+
function inBandFenceAttributes(input) {
|
|
150956
|
+
return {
|
|
150957
|
+
...input.inBand !== void 0 ? WorkflowEventInBand(input.inBand) : {},
|
|
150958
|
+
...input.expectedSeqInBand !== void 0 ? WorkflowEventExpectedSeqInBand(input.expectedSeqInBand) : {}
|
|
150959
|
+
};
|
|
150960
|
+
}
|
|
150614
150961
|
function errorFromV4Response(statusCode, responseHeaders, errorBody, opName, url) {
|
|
150615
150962
|
let message2 = `v4 ${opName} failed: HTTP ${statusCode}`;
|
|
150616
150963
|
let code2;
|
|
@@ -150623,8 +150970,9 @@ function errorFromV4Response(statusCode, responseHeaders, errorBody, opName, url
|
|
|
150623
150970
|
code2 = record2.code;
|
|
150624
150971
|
else if (typeof record2.error === "string")
|
|
150625
150972
|
code2 = record2.error;
|
|
150626
|
-
if (statusCode === 412)
|
|
150627
|
-
details = decodePreconditionDetails(record2);
|
|
150973
|
+
if (statusCode === 412) {
|
|
150974
|
+
details = code2 === IN_BAND_SUPERSEDED_CODE ? decodeInBandSupersededDetails(record2) : decodePreconditionDetails(record2);
|
|
150975
|
+
}
|
|
150628
150976
|
if (statusCode === 409 && code2 === "hook-force-claimed") {
|
|
150629
150977
|
details = { claimedBy: record2.claimedBy };
|
|
150630
150978
|
}
|
|
@@ -150640,6 +150988,14 @@ function errorFromV4Response(statusCode, responseHeaders, errorBody, opName, url
|
|
|
150640
150988
|
...details !== void 0 ? { details } : {}
|
|
150641
150989
|
});
|
|
150642
150990
|
}
|
|
150991
|
+
function decodeInBandSupersededDetails(json) {
|
|
150992
|
+
const seq = inBandCounter(json.seq);
|
|
150993
|
+
const seqInBand = inBandCounter(json.seqInBand);
|
|
150994
|
+
return {
|
|
150995
|
+
...seq !== void 0 ? { seq } : {},
|
|
150996
|
+
...seqInBand !== void 0 ? { seqInBand } : {}
|
|
150997
|
+
};
|
|
150998
|
+
}
|
|
150643
150999
|
function parseV4ErrorBody(body2, contentType) {
|
|
150644
151000
|
if (typeof body2 !== "string" && (contentType == null ? void 0 : contentType.includes("application/cbor"))) {
|
|
150645
151001
|
try {
|
|
@@ -150711,6 +151067,7 @@ async function postWorkflowRunEventV4(input, responseType, config2) {
|
|
|
150711
151067
|
...WorkflowEventsTransport("http"),
|
|
150712
151068
|
...WorkflowEventType(input.eventType),
|
|
150713
151069
|
...WorkflowClientVersion(`@workflow/world-vercel/${version}`),
|
|
151070
|
+
...inBandFenceAttributes(input),
|
|
150714
151071
|
...input.eventType === "step_started" ? {
|
|
150715
151072
|
...WorkflowStepStartMode(input.payload === void 0 ? input.ownerMessageId !== void 0 ? "single_owned_recovery" : "single_bare" : "single_lazy_create_claim"),
|
|
150716
151073
|
...WorkflowStepStartOwnerStamped(input.ownerMessageId !== void 0)
|
|
@@ -150827,6 +151184,8 @@ async function createWorkflowRunEventsBatchV4(input, config2) {
|
|
|
150827
151184
|
const response2 = await fetchV4(url, { method: "POST", headers: headers2, body: body2 }, config2, "createEventBatch", {
|
|
150828
151185
|
...WorkflowEventsTransport("http"),
|
|
150829
151186
|
"workflow.batch.bytes": body2.byteLength,
|
|
151187
|
+
// Every frame of a batch carries the same fence.
|
|
151188
|
+
...inBandFenceAttributes(input.events[0]),
|
|
150830
151189
|
...input.events.some((event) => event.eventType === "step_started") ? {
|
|
150831
151190
|
...WorkflowStepStartMode(input.events.some((event) => event.eventType === "step_created") ? "batch_create_claim" : "batch_bare"),
|
|
150832
151191
|
...WorkflowStepStartOwnerStamped(input.events.some((event) => event.ownerMessageId !== void 0))
|
|
@@ -150895,6 +151254,7 @@ async function postEventFrameOverWs(input, config2) {
|
|
|
150895
151254
|
...WorkflowEventsTransport("ws"),
|
|
150896
151255
|
...WorkflowEventType(input.eventType),
|
|
150897
151256
|
...WorkflowClientVersion(`@workflow/world-vercel/${version}`),
|
|
151257
|
+
...inBandFenceAttributes(input),
|
|
150898
151258
|
...input.stso !== void 0 ? StepStsoMs(input.stso) : {},
|
|
150899
151259
|
...input.optimizations !== void 0 ? StepLatencyOptimizations(input.optimizations) : {},
|
|
150900
151260
|
...input.eventType === "step_started" ? {
|
|
@@ -150938,6 +151298,7 @@ async function postEventFrameOverWs(input, config2) {
|
|
|
150938
151298
|
recordClientSpanStatus(span, status);
|
|
150939
151299
|
if (status < 200 || status >= 300) {
|
|
150940
151300
|
const error2 = errorFromV4Response(status, headerRecord, new TextDecoder().decode(reply.body), "createEvent", endpoint);
|
|
151301
|
+
recordInBandRefusal(span, error2);
|
|
150941
151302
|
(_b2 = span == null ? void 0 : span.recordException) == null ? void 0 : _b2.call(span, error2);
|
|
150942
151303
|
throw error2;
|
|
150943
151304
|
}
|
|
@@ -151041,11 +151402,13 @@ async function consumeEventFrameStream(response2, opName, replayEventObserver) {
|
|
|
151041
151402
|
for await (const frame2 of decodeFrames(response2.body)) {
|
|
151042
151403
|
if (frame2.meta._end === 1) {
|
|
151043
151404
|
const end = EventStreamEndSchema.parse(frame2.meta);
|
|
151405
|
+
const snapshot = snapshotFromEnd(end.snapshot) ?? snapshotFromHeaders(response2.headers);
|
|
151044
151406
|
return {
|
|
151045
151407
|
kind: "complete",
|
|
151046
151408
|
events: events2,
|
|
151047
151409
|
cursor: end.next ?? null,
|
|
151048
|
-
hasMore: end.hasMore
|
|
151410
|
+
hasMore: end.hasMore,
|
|
151411
|
+
...snapshot ? { snapshot } : {}
|
|
151049
151412
|
};
|
|
151050
151413
|
}
|
|
151051
151414
|
if (frame2.meta._error === 1) {
|
|
@@ -151203,7 +151566,10 @@ async function getWorkflowRunEventsV4(runId, params = {}, config2, replayEventOb
|
|
|
151203
151566
|
return {
|
|
151204
151567
|
events: events2,
|
|
151205
151568
|
cursor: consumed.cursor || (partialStreamRetries > 0 ? cursor : null),
|
|
151206
|
-
hasMore: consumed.hasMore
|
|
151569
|
+
hasMore: consumed.hasMore,
|
|
151570
|
+
// Only a complete response reaches its sentinel, and the loop ends on
|
|
151571
|
+
// the first one, so this is the first snapshot the read saw.
|
|
151572
|
+
...consumed.kind === "complete" && consumed.snapshot ? { snapshot: consumed.snapshot } : {}
|
|
151207
151573
|
};
|
|
151208
151574
|
}
|
|
151209
151575
|
async function getEventsByCorrelationIdV4(correlationId, runId, params = {}, config2) {
|
|
@@ -151595,7 +151961,10 @@ async function getWorkflowRunEvents(params, config2) {
|
|
|
151595
151961
|
// The cursor is present even on the final page because it is also the
|
|
151596
151962
|
// incremental-load resume point. `hasMore` is the pagination signal.
|
|
151597
151963
|
cursor: result.cursor,
|
|
151598
|
-
hasMore: result.hasMore
|
|
151964
|
+
hasMore: result.hasMore,
|
|
151965
|
+
// The in-band fence's counters, read before the listing, when the
|
|
151966
|
+
// backend reports them (see `capabilities.inBandFence` in index.ts).
|
|
151967
|
+
...result.snapshot ? { snapshot: result.snapshot } : {}
|
|
151599
151968
|
};
|
|
151600
151969
|
}
|
|
151601
151970
|
async function createWorkflowRunEventBatch(runId, events2, params, config2) {
|
|
@@ -151627,11 +151996,16 @@ async function createWorkflowRunEventBatch(runId, events2, params, config2) {
|
|
|
151627
151996
|
// batched usage facts carry the same attribution.
|
|
151628
151997
|
...(params == null ? void 0 : params.requestId) ? { vercelId: params.requestId } : {},
|
|
151629
151998
|
payload,
|
|
151630
|
-
...meta
|
|
151999
|
+
...meta,
|
|
152000
|
+
// The batch is one fenced allocation: the backend requires every frame
|
|
152001
|
+
// to carry the same fence. Spread after `meta` so nothing derived from
|
|
152002
|
+
// the event data can override it.
|
|
152003
|
+
...(params == null ? void 0 : params.inBand) !== void 0 ? { inBand: params.inBand } : {},
|
|
152004
|
+
...(params == null ? void 0 : params.expectedSeqInBand) !== void 0 ? { expectedSeqInBand: params.expectedSeqInBand } : {}
|
|
151631
152005
|
};
|
|
151632
152006
|
});
|
|
151633
152007
|
const retryConvergent = events2.every(({ event }) => event.eventType !== "step_started" && event.eventType !== "step_retrying");
|
|
151634
|
-
const wire = await withEventPostRetry(() => createWorkflowRunEventsBatchV4({ runId, events: inputs }, config2), events2[0].event.eventType, { batchIdempotent: retryConvergent });
|
|
152008
|
+
const wire = await withEventPostRetry(() => createWorkflowRunEventsBatchV4({ runId, events: inputs }, config2), events2[0].event.eventType, { batchIdempotent: retryConvergent, inBand: (params == null ? void 0 : params.inBand) === true });
|
|
151635
152009
|
return {
|
|
151636
152010
|
results: wire.results.map((item) => {
|
|
151637
152011
|
if (item.error !== void 0) {
|
|
@@ -151659,7 +152033,8 @@ async function createWorkflowRunEvent(id2, data2, params, config2) {
|
|
|
151659
152033
|
// (runId, resumeId) claim, so its POST is idempotent-on-retry even
|
|
151660
152034
|
// though plain hook_received is not; see EVENT_RETRY_ELIGIBILITY.
|
|
151661
152035
|
idempotentHookResume: data2.eventType === "hook_received" && (params == null ? void 0 : params.resumeId) !== void 0 && (params == null ? void 0 : params.resumePayloadDigest) !== void 0,
|
|
151662
|
-
afterStepBody: (params == null ? void 0 : params.afterStepBody) === true
|
|
152036
|
+
afterStepBody: (params == null ? void 0 : params.afterStepBody) === true,
|
|
152037
|
+
inBand: (params == null ? void 0 : params.inBand) === true
|
|
151663
152038
|
});
|
|
151664
152039
|
if (data2.eventType === "run_created" && !result.run) {
|
|
151665
152040
|
throw new WorkflowWorldError(`${data2.eventType} response is missing the run entity`, { code: "SCHEMA_VALIDATION" });
|
|
@@ -151738,6 +152113,10 @@ async function createWorkflowRunEventInner(id2, data2, params, config2) {
|
|
|
151738
152113
|
// `eventCount`.
|
|
151739
152114
|
...(params == null ? void 0 : params.eventCount) !== void 0 ? { maxSlot: params.eventCount } : {},
|
|
151740
152115
|
replayDivergenceCount: params == null ? void 0 : params.replayDivergenceCount,
|
|
152116
|
+
// In-band writer fence. The backend refuses a stale in-band write with
|
|
152117
|
+
// 412 `in-band-superseded` (InBandSupersededError).
|
|
152118
|
+
...(params == null ? void 0 : params.inBand) !== void 0 ? { inBand: params.inBand } : {},
|
|
152119
|
+
...(params == null ? void 0 : params.expectedSeqInBand) !== void 0 ? { expectedSeqInBand: params.expectedSeqInBand } : {},
|
|
151741
152120
|
occurredAt: (params == null ? void 0 : params.occurredAt) ?? /* @__PURE__ */ new Date(),
|
|
151742
152121
|
// Opt-in inline-delta: forward the cursor the runtime held before
|
|
151743
152122
|
// this write so the server can return the authoritative event-log
|
|
@@ -152396,7 +152775,7 @@ function beginNormalWsClose(ws, reason) {
|
|
|
152396
152775
|
await observed;
|
|
152397
152776
|
span == null ? void 0 : span.setAttribute("workflow.stream.ws.close_cleanup_timeout", timedOut);
|
|
152398
152777
|
});
|
|
152399
|
-
void import("./index-
|
|
152778
|
+
void import("./index-C3Gx8HYZ.js").then((n) => n.i).then(({ waitUntil: waitUntil2 }) => waitUntil2(cleanup)).catch(() => {
|
|
152400
152779
|
});
|
|
152401
152780
|
void cleanup.catch(() => {
|
|
152402
152781
|
});
|
|
@@ -152781,7 +153160,7 @@ class VercelStreamWriteSession {
|
|
|
152781
153160
|
return http3;
|
|
152782
153161
|
});
|
|
152783
153162
|
const [{ WebSocket: WebSocketImpl }, http2] = await Promise.all([
|
|
152784
|
-
import("./wrapper-
|
|
153163
|
+
import("./wrapper-BC7AidWM.js"),
|
|
152785
153164
|
httpPromise
|
|
152786
153165
|
]);
|
|
152787
153166
|
if (this.mode !== "connecting")
|
|
@@ -157642,6 +158021,17 @@ function createWorld$1(config2) {
|
|
|
157642
158021
|
// Vercel deployments are atomic and immutable, so a deployment id names
|
|
157643
158022
|
// one fixed build for its whole lifetime.
|
|
157644
158023
|
deploymentAffinity: true,
|
|
158024
|
+
// The backend fences in-band writes on every sealed-log run (spec >= 7,
|
|
158025
|
+
// the backend's event sequencer): a stale one is refused with 412
|
|
158026
|
+
// `in-band-superseded`, carrying the run's `seq` and `seqInBand`
|
|
158027
|
+
// (`InBandSupersededError`), and nothing is allocated for it. On an
|
|
158028
|
+
// older run an in-band write is a 400 `in-band-fence-unsupported`,
|
|
158029
|
+
// never an unfenced write, so a client fences by the run's spec
|
|
158030
|
+
// version. A list response carries `snapshot` and a single create
|
|
158031
|
+
// carries `allocated` where the backend reports them (events-v4.ts); a
|
|
158032
|
+
// run whose list carries no snapshot is still fenced, and its refusals
|
|
158033
|
+
// carry the counters.
|
|
158034
|
+
inBandFence: true,
|
|
157645
158035
|
// The server implements the takeover protocol behind
|
|
157646
158036
|
// `createHook({ experimental_force: true })` (workflow-server
|
|
157647
158037
|
// docs/hook-force-claim.md). Static rather than attested per lookup,
|
|
@@ -182290,7 +182680,7 @@ function createFetchHandler(basename2 = "/") {
|
|
|
182290
182680
|
return (request2) => handler(request2, loadContext);
|
|
182291
182681
|
}
|
|
182292
182682
|
export {
|
|
182293
|
-
|
|
182683
|
+
RETENTION_DEFAULT as $,
|
|
182294
182684
|
ANALYTICS_EVENTS_GET_MANY_LIMIT as A,
|
|
182295
182685
|
BULK_CANCEL_MAX_RUN_IDS as B,
|
|
182296
182686
|
CHILD_ENTITY_CREATION_EVENT_TYPES as C,
|
|
@@ -182307,113 +182697,117 @@ export {
|
|
|
182307
182697
|
Nt as N,
|
|
182308
182698
|
HookCreatedEventSchema as O,
|
|
182309
182699
|
HookResumeCapabilitiesSchema as P,
|
|
182310
|
-
|
|
182311
|
-
|
|
182312
|
-
|
|
182313
|
-
|
|
182314
|
-
|
|
182315
|
-
|
|
182316
|
-
|
|
182317
|
-
|
|
182318
|
-
|
|
182319
|
-
|
|
182320
|
-
|
|
182700
|
+
IN_BAND_SEQ_AT_RUN_CREATION as Q,
|
|
182701
|
+
LegacySerializedDataSchemaV1 as R,
|
|
182702
|
+
MessageId as S,
|
|
182703
|
+
NODE_HTTP_DEFAULT as T,
|
|
182704
|
+
NODE_HTTP_ENV_VAR as U,
|
|
182705
|
+
PARENT_RUN_ID_ATTRIBUTE as V,
|
|
182706
|
+
PaginatedResponseSchema as W,
|
|
182707
|
+
QueuePayloadSchema as X,
|
|
182708
|
+
QueuePrefix as Y,
|
|
182709
|
+
RESERVED_ATTRIBUTE_KEY_PREFIX as Z,
|
|
182710
|
+
RETENTION_ATTRIBUTE as _,
|
|
182321
182711
|
ANALYTICS_MAX_ATTRIBUTE_FILTERS as a,
|
|
182322
|
-
|
|
182323
|
-
|
|
182324
|
-
|
|
182325
|
-
|
|
182326
|
-
|
|
182327
|
-
|
|
182328
|
-
|
|
182329
|
-
|
|
182330
|
-
|
|
182331
|
-
|
|
182332
|
-
|
|
182333
|
-
|
|
182334
|
-
|
|
182335
|
-
|
|
182336
|
-
|
|
182337
|
-
|
|
182338
|
-
|
|
182339
|
-
|
|
182340
|
-
|
|
182341
|
-
|
|
182342
|
-
|
|
182343
|
-
|
|
182344
|
-
|
|
182345
|
-
|
|
182346
|
-
|
|
182347
|
-
|
|
182348
|
-
|
|
182349
|
-
|
|
182350
|
-
|
|
182351
|
-
|
|
182352
|
-
|
|
182353
|
-
|
|
182354
|
-
|
|
182355
|
-
|
|
182356
|
-
|
|
182357
|
-
|
|
182358
|
-
|
|
182359
|
-
|
|
182360
|
-
|
|
182361
|
-
|
|
182362
|
-
|
|
182363
|
-
|
|
182364
|
-
|
|
182365
|
-
|
|
182366
|
-
|
|
182367
|
-
|
|
182368
|
-
|
|
182369
|
-
|
|
182370
|
-
|
|
182371
|
-
|
|
182372
|
-
|
|
182373
|
-
|
|
182374
|
-
|
|
182375
|
-
|
|
182376
|
-
|
|
182377
|
-
|
|
182378
|
-
|
|
182379
|
-
|
|
182380
|
-
|
|
182381
|
-
|
|
182382
|
-
|
|
182383
|
-
|
|
182384
|
-
|
|
182385
|
-
|
|
182712
|
+
isTerminalStepStatus as a$,
|
|
182713
|
+
RETENTION_ZERO as a0,
|
|
182714
|
+
ROOT_RUN_ID_ATTRIBUTE as a1,
|
|
182715
|
+
RUN_ENTITY_KEY as a2,
|
|
182716
|
+
RunInputSchema as a3,
|
|
182717
|
+
SEALED_LOG_ENV_VAR as a4,
|
|
182718
|
+
SPEC_VERSION_CURRENT as a5,
|
|
182719
|
+
SPEC_VERSION_LEGACY as a6,
|
|
182720
|
+
SPEC_VERSION_MAX_SUPPORTED as a7,
|
|
182721
|
+
SPEC_VERSION_SUPPORTS_ATTRIBUTES as a8,
|
|
182722
|
+
SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT as a9,
|
|
182723
|
+
WorkflowRunStatusSchema as aA,
|
|
182724
|
+
applyAttributeChanges as aB,
|
|
182725
|
+
classifyEntityEvent as aC,
|
|
182726
|
+
decodeSnapshotEnvelope as aD,
|
|
182727
|
+
encodeSnapshotEnvelope as aE,
|
|
182728
|
+
entityEventClass as aF,
|
|
182729
|
+
entityResolveData as aG,
|
|
182730
|
+
envFlag as aH,
|
|
182731
|
+
envNumber as aI,
|
|
182732
|
+
eventIdToSlot as aJ,
|
|
182733
|
+
getEventDataPayloadField as aK,
|
|
182734
|
+
getEventDataRefFields as aL,
|
|
182735
|
+
getMaxEventsPerRun as aM,
|
|
182736
|
+
getQueueTopicPrefix as aN,
|
|
182737
|
+
getRunQueueNamespace as aO,
|
|
182738
|
+
isChildEntityCreationEvent as aP,
|
|
182739
|
+
isChildEntityCreationEventType as aQ,
|
|
182740
|
+
isHookEventRequiringExistence as aR,
|
|
182741
|
+
isHookLifecycleEventType as aS,
|
|
182742
|
+
isLegacySpecVersion as aT,
|
|
182743
|
+
isNodeHttpEnabled as aU,
|
|
182744
|
+
isSealedNoopEvent$1 as aV,
|
|
182745
|
+
isSlotBody as aW,
|
|
182746
|
+
isSlotEventId as aX,
|
|
182747
|
+
isStepEventType as aY,
|
|
182748
|
+
isTerminalRunEventType as aZ,
|
|
182749
|
+
isTerminalStepEventType as a_,
|
|
182750
|
+
SPEC_VERSION_SUPPORTS_COMPRESSION as aa,
|
|
182751
|
+
SPEC_VERSION_SUPPORTS_EVENT_SOURCING as ab,
|
|
182752
|
+
SPEC_VERSION_SUPPORTS_HOOK_FORCE_CLAIM as ac,
|
|
182753
|
+
SPEC_VERSION_SUPPORTS_SLOT_IDENTITY as ad,
|
|
182754
|
+
STEP_EVENT_TYPES as ae,
|
|
182755
|
+
SerializedDataSchema as af,
|
|
182756
|
+
SnapshotMetadataSchema as ag,
|
|
182757
|
+
StepSchema as ah,
|
|
182758
|
+
StepStatusSchema as ai,
|
|
182759
|
+
StructuredErrorSchema as aj,
|
|
182760
|
+
TERMINAL_EVENT_CLASSES as ak,
|
|
182761
|
+
TERMINAL_RUN_EVENT_TYPES as al,
|
|
182762
|
+
TERMINAL_STEP_EVENT_TYPES as am,
|
|
182763
|
+
TERMINAL_STEP_STATUSES as an,
|
|
182764
|
+
TERMINAL_WORKFLOW_RUN_STATUSES as ao,
|
|
182765
|
+
TerminalRunEventTypeSchema as ap,
|
|
182766
|
+
TerminalStepStatusSchema as aq,
|
|
182767
|
+
TerminalWorkflowRunStatusSchema as ar,
|
|
182768
|
+
ValidQueueName as as,
|
|
182769
|
+
WAIT_EVENT_TYPES as at,
|
|
182770
|
+
WORKFLOW_FLOW_ROUTE as au,
|
|
182771
|
+
WaitSchema as av,
|
|
182772
|
+
WaitStatusSchema as aw,
|
|
182773
|
+
WorkflowInvokePayloadSchema as ax,
|
|
182774
|
+
WorkflowRunBaseSchema as ay,
|
|
182775
|
+
WorkflowRunSchema as az,
|
|
182386
182776
|
ANALYTICS_PAGE_LIMIT as b,
|
|
182387
|
-
|
|
182388
|
-
|
|
182389
|
-
|
|
182390
|
-
|
|
182391
|
-
|
|
182392
|
-
|
|
182393
|
-
|
|
182394
|
-
|
|
182395
|
-
|
|
182396
|
-
|
|
182397
|
-
|
|
182398
|
-
|
|
182399
|
-
|
|
182400
|
-
|
|
182401
|
-
|
|
182402
|
-
|
|
182403
|
-
|
|
182404
|
-
|
|
182405
|
-
|
|
182406
|
-
|
|
182407
|
-
|
|
182408
|
-
|
|
182409
|
-
|
|
182410
|
-
|
|
182411
|
-
|
|
182412
|
-
|
|
182413
|
-
|
|
182414
|
-
|
|
182415
|
-
|
|
182416
|
-
|
|
182777
|
+
isTerminalWorkflowRunStatus as b0,
|
|
182778
|
+
isWaitEventType as b1,
|
|
182779
|
+
mintedSpecVersion as b2,
|
|
182780
|
+
parseQueueName as b3,
|
|
182781
|
+
parseQueueRoute as b4,
|
|
182782
|
+
readRunRetention as b5,
|
|
182783
|
+
reenqueueActiveRuns as b6,
|
|
182784
|
+
requiresNewerWorld as b7,
|
|
182785
|
+
resolveQueueNamespace as b8,
|
|
182786
|
+
slotToEventId as b9,
|
|
182787
|
+
stripEventDataRefs as ba,
|
|
182788
|
+
ulidToDate as bb,
|
|
182789
|
+
validateAttributeChanges as bc,
|
|
182790
|
+
validateAttributeEventDataSize as bd,
|
|
182791
|
+
validateUlidTimestamp as be,
|
|
182792
|
+
workflowRunIdSchema as bf,
|
|
182793
|
+
reactExports as bg,
|
|
182794
|
+
R as bh,
|
|
182795
|
+
Ks as bi,
|
|
182796
|
+
jsxRuntimeExports as bj,
|
|
182797
|
+
Qe as bk,
|
|
182798
|
+
registerZstdDecoder as bl,
|
|
182799
|
+
WebSocket as bm,
|
|
182800
|
+
permessageDeflate as bn,
|
|
182801
|
+
receiver as bo,
|
|
182802
|
+
sender as bp,
|
|
182803
|
+
websocketServer as bq,
|
|
182804
|
+
stream as br,
|
|
182805
|
+
extension as bs,
|
|
182806
|
+
subprotocol as bt,
|
|
182807
|
+
getDefaultExportFromCjs as bu,
|
|
182808
|
+
requireTokenUtil as bv,
|
|
182809
|
+
requireTokenError as bw,
|
|
182810
|
+
createFetchHandler as bx,
|
|
182417
182811
|
ANALYTICS_RUN_SCOPED_PAGE_LIMIT as c,
|
|
182418
182812
|
ATTRIBUTE_EVENT_DATA_MAX_BYTES as d,
|
|
182419
182813
|
ATTRIBUTE_KEY_MAX_LENGTH as e,
|