@workflow/world-testing 4.1.5 → 4.1.6
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.
|
@@ -15370,7 +15370,7 @@ var init_runs = __esm({
|
|
|
15370
15370
|
// Optional in database for backwards compatibility, defaults to 1 (legacy) when reading
|
|
15371
15371
|
specVersion: external_exports.number().optional(),
|
|
15372
15372
|
executionContext: external_exports.record(external_exports.string(), external_exports.any()).optional(),
|
|
15373
|
-
input: SerializedDataSchema,
|
|
15373
|
+
input: SerializedDataSchema.optional(),
|
|
15374
15374
|
output: SerializedDataSchema.optional(),
|
|
15375
15375
|
error: StructuredErrorSchema.optional(),
|
|
15376
15376
|
expiredAt: external_exports.coerce.date().optional(),
|
|
@@ -15474,7 +15474,7 @@ var init_steps = __esm({
|
|
|
15474
15474
|
*/
|
|
15475
15475
|
stepName: external_exports.string(),
|
|
15476
15476
|
status: StepStatusSchema,
|
|
15477
|
-
input: SerializedDataSchema,
|
|
15477
|
+
input: SerializedDataSchema.optional(),
|
|
15478
15478
|
output: SerializedDataSchema.optional(),
|
|
15479
15479
|
/**
|
|
15480
15480
|
* The error from a step_retrying or step_failed event.
|
|
@@ -42942,7 +42942,7 @@ var require_auth_config = __commonJS({
|
|
|
42942
42942
|
writeAuthConfig: /* @__PURE__ */ __name(() => writeAuthConfig, "writeAuthConfig")
|
|
42943
42943
|
});
|
|
42944
42944
|
module2.exports = __toCommonJS2(auth_config_exports);
|
|
42945
|
-
var
|
|
42945
|
+
var fs6 = __toESM2(require("fs"));
|
|
42946
42946
|
var path11 = __toESM2(require("path"));
|
|
42947
42947
|
var import_token_util = require_token_util();
|
|
42948
42948
|
function getAuthConfigPath() {
|
|
@@ -42958,10 +42958,10 @@ var require_auth_config = __commonJS({
|
|
|
42958
42958
|
function readAuthConfig() {
|
|
42959
42959
|
try {
|
|
42960
42960
|
const authPath = getAuthConfigPath();
|
|
42961
|
-
if (!
|
|
42961
|
+
if (!fs6.existsSync(authPath)) {
|
|
42962
42962
|
return null;
|
|
42963
42963
|
}
|
|
42964
|
-
const content =
|
|
42964
|
+
const content = fs6.readFileSync(authPath, "utf8");
|
|
42965
42965
|
if (!content) {
|
|
42966
42966
|
return null;
|
|
42967
42967
|
}
|
|
@@ -42974,10 +42974,10 @@ var require_auth_config = __commonJS({
|
|
|
42974
42974
|
function writeAuthConfig(config3) {
|
|
42975
42975
|
const authPath = getAuthConfigPath();
|
|
42976
42976
|
const authDir = path11.dirname(authPath);
|
|
42977
|
-
if (!
|
|
42978
|
-
|
|
42977
|
+
if (!fs6.existsSync(authDir)) {
|
|
42978
|
+
fs6.mkdirSync(authDir, { mode: 504, recursive: true });
|
|
42979
42979
|
}
|
|
42980
|
-
|
|
42980
|
+
fs6.writeFileSync(authPath, JSON.stringify(config3, null, 2), { mode: 384 });
|
|
42981
42981
|
}
|
|
42982
42982
|
__name(writeAuthConfig, "writeAuthConfig");
|
|
42983
42983
|
function isValidAccessToken(authConfig, expirationBufferMs = 0) {
|
|
@@ -43180,7 +43180,7 @@ var require_token_util = __commonJS({
|
|
|
43180
43180
|
});
|
|
43181
43181
|
module2.exports = __toCommonJS2(token_util_exports);
|
|
43182
43182
|
var path11 = __toESM2(require("path"));
|
|
43183
|
-
var
|
|
43183
|
+
var fs6 = __toESM2(require("fs"));
|
|
43184
43184
|
var import_token_error = require_token_error();
|
|
43185
43185
|
var import_token_io = require_token_io();
|
|
43186
43186
|
var import_auth_config = require_auth_config();
|
|
@@ -43273,12 +43273,12 @@ var require_token_util = __commonJS({
|
|
|
43273
43273
|
);
|
|
43274
43274
|
}
|
|
43275
43275
|
const prjPath = path11.join(dir, ".vercel", "project.json");
|
|
43276
|
-
if (!
|
|
43276
|
+
if (!fs6.existsSync(prjPath)) {
|
|
43277
43277
|
throw new import_token_error.VercelOidcTokenError(
|
|
43278
43278
|
"project.json not found, have you linked your project with `vc link?`"
|
|
43279
43279
|
);
|
|
43280
43280
|
}
|
|
43281
|
-
const prj = JSON.parse(
|
|
43281
|
+
const prj = JSON.parse(fs6.readFileSync(prjPath, "utf8"));
|
|
43282
43282
|
if (typeof prj.projectId !== "string" && typeof prj.orgId !== "string") {
|
|
43283
43283
|
throw new TypeError(
|
|
43284
43284
|
"Expected a string-valued projectId property. Try running `vc link` to re-link your project."
|
|
@@ -43296,9 +43296,9 @@ var require_token_util = __commonJS({
|
|
|
43296
43296
|
}
|
|
43297
43297
|
const tokenPath = path11.join(dir, "com.vercel.token", `${projectId}.json`);
|
|
43298
43298
|
const tokenJson = JSON.stringify(token);
|
|
43299
|
-
|
|
43300
|
-
|
|
43301
|
-
|
|
43299
|
+
fs6.mkdirSync(path11.dirname(tokenPath), { mode: 504, recursive: true });
|
|
43300
|
+
fs6.writeFileSync(tokenPath, tokenJson);
|
|
43301
|
+
fs6.chmodSync(tokenPath, 432);
|
|
43302
43302
|
return;
|
|
43303
43303
|
}
|
|
43304
43304
|
__name(saveToken, "saveToken");
|
|
@@ -43310,10 +43310,10 @@ var require_token_util = __commonJS({
|
|
|
43310
43310
|
);
|
|
43311
43311
|
}
|
|
43312
43312
|
const tokenPath = path11.join(dir, "com.vercel.token", `${projectId}.json`);
|
|
43313
|
-
if (!
|
|
43313
|
+
if (!fs6.existsSync(tokenPath)) {
|
|
43314
43314
|
return null;
|
|
43315
43315
|
}
|
|
43316
|
-
const token = JSON.parse(
|
|
43316
|
+
const token = JSON.parse(fs6.readFileSync(tokenPath, "utf8"));
|
|
43317
43317
|
assertVercelOidcTokenResponse(token);
|
|
43318
43318
|
return token;
|
|
43319
43319
|
}
|
|
@@ -43613,27 +43613,27 @@ var require_process = __commonJS({
|
|
|
43613
43613
|
var require_filesystem = __commonJS({
|
|
43614
43614
|
"../../node_modules/.pnpm/detect-libc@2.1.2/node_modules/detect-libc/lib/filesystem.js"(exports2, module2) {
|
|
43615
43615
|
"use strict";
|
|
43616
|
-
var
|
|
43616
|
+
var fs6 = require("fs");
|
|
43617
43617
|
var LDD_PATH = "/usr/bin/ldd";
|
|
43618
43618
|
var SELF_PATH = "/proc/self/exe";
|
|
43619
43619
|
var MAX_LENGTH = 2048;
|
|
43620
43620
|
var readFileSync2 = /* @__PURE__ */ __name((path11) => {
|
|
43621
|
-
const fd =
|
|
43621
|
+
const fd = fs6.openSync(path11, "r");
|
|
43622
43622
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
43623
|
-
const bytesRead =
|
|
43624
|
-
|
|
43623
|
+
const bytesRead = fs6.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
43624
|
+
fs6.close(fd, () => {
|
|
43625
43625
|
});
|
|
43626
43626
|
return buffer.subarray(0, bytesRead);
|
|
43627
43627
|
}, "readFileSync");
|
|
43628
43628
|
var readFile3 = /* @__PURE__ */ __name((path11) => new Promise((resolve3, reject) => {
|
|
43629
|
-
|
|
43629
|
+
fs6.open(path11, "r", (err, fd) => {
|
|
43630
43630
|
if (err) {
|
|
43631
43631
|
reject(err);
|
|
43632
43632
|
} else {
|
|
43633
43633
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
43634
|
-
|
|
43634
|
+
fs6.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
|
|
43635
43635
|
resolve3(buffer.subarray(0, bytesRead));
|
|
43636
|
-
|
|
43636
|
+
fs6.close(fd, () => {
|
|
43637
43637
|
});
|
|
43638
43638
|
});
|
|
43639
43639
|
}
|
|
@@ -43943,7 +43943,7 @@ var require_detect_libc = __commonJS({
|
|
|
43943
43943
|
// ../../node_modules/.pnpm/node-gyp-build-optional-packages@5.1.1/node_modules/node-gyp-build-optional-packages/index.js
|
|
43944
43944
|
var require_node_gyp_build_optional_packages = __commonJS({
|
|
43945
43945
|
"../../node_modules/.pnpm/node-gyp-build-optional-packages@5.1.1/node_modules/node-gyp-build-optional-packages/index.js"(exports2, module2) {
|
|
43946
|
-
var
|
|
43946
|
+
var fs6 = require("fs");
|
|
43947
43947
|
var path11 = require("path");
|
|
43948
43948
|
var url2 = require("url");
|
|
43949
43949
|
var vars = process.config && process.config.variables || {};
|
|
@@ -44026,7 +44026,7 @@ var require_node_gyp_build_optional_packages = __commonJS({
|
|
|
44026
44026
|
};
|
|
44027
44027
|
function readdirSync(dir) {
|
|
44028
44028
|
try {
|
|
44029
|
-
return
|
|
44029
|
+
return fs6.readdirSync(dir);
|
|
44030
44030
|
} catch (err) {
|
|
44031
44031
|
return [];
|
|
44032
44032
|
}
|
|
@@ -48688,7 +48688,7 @@ init_dist();
|
|
|
48688
48688
|
init_node();
|
|
48689
48689
|
|
|
48690
48690
|
// ../core/dist/version.js
|
|
48691
|
-
var version2 = "4.2.
|
|
48691
|
+
var version2 = "4.2.6";
|
|
48692
48692
|
|
|
48693
48693
|
// ../core/dist/runtime/world.js
|
|
48694
48694
|
var import_node_module = require("node:module");
|
|
@@ -48696,7 +48696,7 @@ var import_node_path9 = require("node:path");
|
|
|
48696
48696
|
|
|
48697
48697
|
// ../world-local/dist/index.js
|
|
48698
48698
|
var import_node_fs2 = require("node:fs");
|
|
48699
|
-
var
|
|
48699
|
+
var import_promises6 = require("node:fs/promises");
|
|
48700
48700
|
var import_node_path8 = __toESM(require("node:path"), 1);
|
|
48701
48701
|
init_dist();
|
|
48702
48702
|
|
|
@@ -49180,6 +49180,17 @@ async function readBuffer(filePath) {
|
|
|
49180
49180
|
return content;
|
|
49181
49181
|
}
|
|
49182
49182
|
__name(readBuffer, "readBuffer");
|
|
49183
|
+
async function readFirstByte(filePath) {
|
|
49184
|
+
const file2 = await import_node_fs.promises.open(filePath, "r");
|
|
49185
|
+
try {
|
|
49186
|
+
const byte = Buffer.allocUnsafe(1);
|
|
49187
|
+
const { bytesRead } = await file2.read(byte, 0, 1, 0);
|
|
49188
|
+
return bytesRead === 0 ? void 0 : byte[0];
|
|
49189
|
+
} finally {
|
|
49190
|
+
await file2.close();
|
|
49191
|
+
}
|
|
49192
|
+
}
|
|
49193
|
+
__name(readFirstByte, "readFirstByte");
|
|
49183
49194
|
async function deleteJSON(filePath) {
|
|
49184
49195
|
try {
|
|
49185
49196
|
await import_node_fs.promises.unlink(filePath);
|
|
@@ -50762,6 +50773,7 @@ __name(createStorage, "createStorage");
|
|
|
50762
50773
|
|
|
50763
50774
|
// ../world-local/dist/streamer.js
|
|
50764
50775
|
var import_node_events = require("node:events");
|
|
50776
|
+
var import_promises5 = __toESM(require("node:fs/promises"), 1);
|
|
50765
50777
|
var import_node_path7 = __toESM(require("node:path"), 1);
|
|
50766
50778
|
init_node();
|
|
50767
50779
|
init_zod();
|
|
@@ -50769,43 +50781,56 @@ var monotonicUlid2 = monotonicFactory(() => Math.random());
|
|
|
50769
50781
|
var RunStreamsSchema = external_exports.object({
|
|
50770
50782
|
streams: external_exports.array(external_exports.string())
|
|
50771
50783
|
});
|
|
50784
|
+
var EOF_MARKER = 1;
|
|
50785
|
+
function isEofByte(byte) {
|
|
50786
|
+
return byte === EOF_MARKER;
|
|
50787
|
+
}
|
|
50788
|
+
__name(isEofByte, "isEofByte");
|
|
50772
50789
|
function serializeChunk(chunk) {
|
|
50773
|
-
const eofByte = Buffer.from([chunk.eof ?
|
|
50790
|
+
const eofByte = Buffer.from([chunk.eof ? EOF_MARKER : 0]);
|
|
50774
50791
|
return Buffer.concat([eofByte, chunk.chunk]);
|
|
50775
50792
|
}
|
|
50776
50793
|
__name(serializeChunk, "serializeChunk");
|
|
50777
50794
|
function isEofChunk(serialized) {
|
|
50778
|
-
return serialized[0]
|
|
50795
|
+
return isEofByte(serialized[0]);
|
|
50779
50796
|
}
|
|
50780
50797
|
__name(isEofChunk, "isEofChunk");
|
|
50781
50798
|
function deserializeChunk(serialized) {
|
|
50782
|
-
const eof = serialized
|
|
50799
|
+
const eof = isEofChunk(serialized);
|
|
50783
50800
|
const chunk = Buffer.from(serialized.subarray(1));
|
|
50784
50801
|
return { eof, chunk };
|
|
50785
50802
|
}
|
|
50786
50803
|
__name(deserializeChunk, "deserializeChunk");
|
|
50804
|
+
async function listChunkEntries(chunksDir) {
|
|
50805
|
+
try {
|
|
50806
|
+
return await import_promises5.default.readdir(chunksDir);
|
|
50807
|
+
} catch (error48) {
|
|
50808
|
+
if (error48.code === "ENOENT")
|
|
50809
|
+
return [];
|
|
50810
|
+
throw error48;
|
|
50811
|
+
}
|
|
50812
|
+
}
|
|
50813
|
+
__name(listChunkEntries, "listChunkEntries");
|
|
50814
|
+
function addChunkFilesByExtension(extMap, entries, sourceExtension, fileExtension = sourceExtension, include = () => true) {
|
|
50815
|
+
for (const entry of entries) {
|
|
50816
|
+
if (!entry.endsWith(sourceExtension))
|
|
50817
|
+
continue;
|
|
50818
|
+
const file2 = entry.slice(0, -sourceExtension.length);
|
|
50819
|
+
if (include(file2))
|
|
50820
|
+
extMap.set(file2, fileExtension);
|
|
50821
|
+
}
|
|
50822
|
+
}
|
|
50823
|
+
__name(addChunkFilesByExtension, "addChunkFilesByExtension");
|
|
50787
50824
|
async function listChunkFilesForStream(chunksDir, name, tag) {
|
|
50788
50825
|
assertSafeEntityId("streamName", name);
|
|
50789
|
-
const
|
|
50790
|
-
listFilesByExtension(chunksDir, ".bin"),
|
|
50791
|
-
listFilesByExtension(chunksDir, ".json")
|
|
50792
|
-
];
|
|
50793
|
-
if (tag) {
|
|
50794
|
-
listPromises.push(listFilesByExtension(chunksDir, `.${tag}.bin`));
|
|
50795
|
-
}
|
|
50796
|
-
const [binFiles, jsonFiles, ...taggedResults] = await Promise.all(listPromises);
|
|
50797
|
-
const taggedBinFiles = taggedResults[0] ?? [];
|
|
50826
|
+
const entries = await listChunkEntries(chunksDir);
|
|
50798
50827
|
const extMap = /* @__PURE__ */ new Map();
|
|
50799
|
-
|
|
50800
|
-
|
|
50801
|
-
|
|
50802
|
-
|
|
50803
|
-
|
|
50804
|
-
continue;
|
|
50805
|
-
extMap.set(f, ".bin");
|
|
50828
|
+
addChunkFilesByExtension(extMap, entries, ".json");
|
|
50829
|
+
addChunkFilesByExtension(extMap, entries, ".bin", ".bin", tag ? (file2) => !file2.endsWith(`.${tag}`) : void 0);
|
|
50830
|
+
if (tag) {
|
|
50831
|
+
const taggedExtension = `.${tag}.bin`;
|
|
50832
|
+
addChunkFilesByExtension(extMap, entries, taggedExtension);
|
|
50806
50833
|
}
|
|
50807
|
-
for (const f of taggedBinFiles)
|
|
50808
|
-
extMap.set(f, `.${tag}.bin`);
|
|
50809
50834
|
const files = [...extMap.keys()].filter((file2) => file2.startsWith(`${name}-`)).sort();
|
|
50810
50835
|
return { files, extMap };
|
|
50811
50836
|
}
|
|
@@ -50922,7 +50947,7 @@ function createStreamer(basedir, tag) {
|
|
|
50922
50947
|
const ext2 = fileExtMap.get(file2) ?? ".bin";
|
|
50923
50948
|
const filePath = import_node_path7.default.join(chunksDir, `${file2}${ext2}`);
|
|
50924
50949
|
if (dataIndex < startIndex) {
|
|
50925
|
-
if (
|
|
50950
|
+
if (isEofByte(await readFirstByte(filePath))) {
|
|
50926
50951
|
streamDone = true;
|
|
50927
50952
|
break;
|
|
50928
50953
|
}
|
|
@@ -50930,7 +50955,7 @@ function createStreamer(basedir, tag) {
|
|
|
50930
50955
|
continue;
|
|
50931
50956
|
}
|
|
50932
50957
|
if (resultChunks.length >= limit) {
|
|
50933
|
-
if (
|
|
50958
|
+
if (isEofByte(await readFirstByte(filePath))) {
|
|
50934
50959
|
streamDone = true;
|
|
50935
50960
|
} else {
|
|
50936
50961
|
dataIndex++;
|
|
@@ -50965,7 +50990,7 @@ function createStreamer(basedir, tag) {
|
|
|
50965
50990
|
let dataCount = 0;
|
|
50966
50991
|
for (const file2 of chunkFiles) {
|
|
50967
50992
|
const ext2 = fileExtMap.get(file2) ?? ".bin";
|
|
50968
|
-
if (
|
|
50993
|
+
if (isEofByte(await readFirstByte(import_node_path7.default.join(chunksDir, `${file2}${ext2}`)))) {
|
|
50969
50994
|
streamDone = true;
|
|
50970
50995
|
break;
|
|
50971
50996
|
}
|
|
@@ -51026,8 +51051,7 @@ function createStreamer(basedir, tag) {
|
|
|
51026
51051
|
if (typeof startIndex === "number" && startIndex < 0 && chunkFiles.length > 0) {
|
|
51027
51052
|
const lastFile = chunkFiles[chunkFiles.length - 1];
|
|
51028
51053
|
const lastExt = fileExtMap.get(lastFile) ?? ".bin";
|
|
51029
|
-
|
|
51030
|
-
if (lastChunk?.eof === true) {
|
|
51054
|
+
if (isEofByte(await readFirstByte(import_node_path7.default.join(chunksDir, `${lastFile}${lastExt}`)))) {
|
|
51031
51055
|
dataChunkCount--;
|
|
51032
51056
|
}
|
|
51033
51057
|
}
|
|
@@ -51204,7 +51228,7 @@ function createLocalWorld(args) {
|
|
|
51204
51228
|
})));
|
|
51205
51229
|
clearCreatedFilesCache();
|
|
51206
51230
|
} else {
|
|
51207
|
-
await (0,
|
|
51231
|
+
await (0, import_promises6.rm)(mergedConfig.dataDir, { recursive: true, force: true });
|
|
51208
51232
|
await initDataDir(mergedConfig.dataDir);
|
|
51209
51233
|
}
|
|
51210
51234
|
}
|
|
@@ -51923,7 +51947,7 @@ var StreamingMultipartParser = class {
|
|
|
51923
51947
|
};
|
|
51924
51948
|
|
|
51925
51949
|
// ../../node_modules/.pnpm/@vercel+queue@0.1.7/node_modules/@vercel/queue/dist/index.mjs
|
|
51926
|
-
var
|
|
51950
|
+
var fs5 = __toESM(require("fs"), 1);
|
|
51927
51951
|
var net = __toESM(require("net"), 1);
|
|
51928
51952
|
var path10 = __toESM(require("path"), 1);
|
|
51929
51953
|
|
|
@@ -54490,11 +54514,11 @@ function getDevRouteMappings() {
|
|
|
54490
54514
|
}
|
|
54491
54515
|
try {
|
|
54492
54516
|
const vercelJsonPath = path10.join(process.cwd(), "vercel.json");
|
|
54493
|
-
if (!
|
|
54517
|
+
if (!fs5.existsSync(vercelJsonPath)) {
|
|
54494
54518
|
g[ROUTE_MAPPINGS_KEY] = null;
|
|
54495
54519
|
return null;
|
|
54496
54520
|
}
|
|
54497
|
-
const vercelJson = JSON.parse(
|
|
54521
|
+
const vercelJson = JSON.parse(fs5.readFileSync(vercelJsonPath, "utf-8"));
|
|
54498
54522
|
if (!vercelJson.functions) {
|
|
54499
54523
|
g[ROUTE_MAPPINGS_KEY] = null;
|
|
54500
54524
|
return null;
|
|
@@ -54619,7 +54643,7 @@ function extractCallerFilePath() {
|
|
|
54619
54643
|
const absolute = path10.isAbsolute(fp) ? fp : path10.resolve(process.cwd(), fp);
|
|
54620
54644
|
let realFp;
|
|
54621
54645
|
try {
|
|
54622
|
-
realFp =
|
|
54646
|
+
realFp = fs5.realpathSync(absolute);
|
|
54623
54647
|
} catch {
|
|
54624
54648
|
realFp = absolute;
|
|
54625
54649
|
}
|
|
@@ -58273,7 +58297,7 @@ var import_oidc3 = __toESM(require_dist(), 1);
|
|
|
58273
58297
|
init_dist();
|
|
58274
58298
|
|
|
58275
58299
|
// ../world-vercel/dist/version.js
|
|
58276
|
-
var version3 = "4.
|
|
58300
|
+
var version3 = "4.3.0";
|
|
58277
58301
|
|
|
58278
58302
|
// ../world-vercel/dist/utils.js
|
|
58279
58303
|
var HTTP_DEBUG_ENABLED = typeof process !== "undefined" && typeof process.env.DEBUG === "string" && (process.env.DEBUG.includes("workflow:") || process.env.DEBUG === "*");
|
|
@@ -59566,6 +59590,17 @@ async function fetchStreamMutation(url2, init, operation) {
|
|
|
59566
59590
|
}
|
|
59567
59591
|
}
|
|
59568
59592
|
__name(fetchStreamMutation, "fetchStreamMutation");
|
|
59593
|
+
function createStreamRequestError(operation, url2, response, text) {
|
|
59594
|
+
const context2 = [`PUT ${url2.origin}${url2.pathname}`];
|
|
59595
|
+
for (const header of ["x-vercel-id", "x-vercel-error"]) {
|
|
59596
|
+
const value = response.headers.get(header);
|
|
59597
|
+
if (value) {
|
|
59598
|
+
context2.push(`${header}=${value}`);
|
|
59599
|
+
}
|
|
59600
|
+
}
|
|
59601
|
+
return new Error(`Stream ${operation} failed: HTTP ${response.status} (${context2.join("; ")}): ${text}`);
|
|
59602
|
+
}
|
|
59603
|
+
__name(createStreamRequestError, "createStreamRequestError");
|
|
59569
59604
|
function encodeMultiChunks(chunks) {
|
|
59570
59605
|
const encoder = new TextEncoder();
|
|
59571
59606
|
const binaryChunks = [];
|
|
@@ -59605,14 +59640,15 @@ function createStreamer2(config3) {
|
|
|
59605
59640
|
async writeToStream(name, runId, chunk) {
|
|
59606
59641
|
const resolvedRunId = await runId;
|
|
59607
59642
|
const httpConfig = await getHttpConfig(config3);
|
|
59608
|
-
const
|
|
59643
|
+
const url2 = getStreamUrl(name, resolvedRunId, httpConfig);
|
|
59644
|
+
const response = await fetchStreamMutation(url2, {
|
|
59609
59645
|
method: "PUT",
|
|
59610
59646
|
body: chunk,
|
|
59611
59647
|
headers: httpConfig.headers
|
|
59612
59648
|
}, "write");
|
|
59613
59649
|
const text = await response.text();
|
|
59614
59650
|
if (!response.ok) {
|
|
59615
|
-
throw
|
|
59651
|
+
throw createStreamRequestError("write", url2, response, text);
|
|
59616
59652
|
}
|
|
59617
59653
|
},
|
|
59618
59654
|
async writeToStreamMulti(name, runId, chunks) {
|
|
@@ -59624,14 +59660,15 @@ function createStreamer2(config3) {
|
|
|
59624
59660
|
for (let i = 0; i < chunks.length; i += MAX_CHUNKS_PER_REQUEST) {
|
|
59625
59661
|
const batch = chunks.slice(i, i + MAX_CHUNKS_PER_REQUEST);
|
|
59626
59662
|
const body = encodeMultiChunks(batch);
|
|
59627
|
-
const
|
|
59663
|
+
const url2 = getStreamUrl(name, resolvedRunId, httpConfig);
|
|
59664
|
+
const response = await fetchStreamMutation(url2, {
|
|
59628
59665
|
method: "PUT",
|
|
59629
59666
|
body,
|
|
59630
59667
|
headers: httpConfig.headers
|
|
59631
59668
|
}, "write");
|
|
59632
59669
|
const text = await response.text();
|
|
59633
59670
|
if (!response.ok) {
|
|
59634
|
-
throw
|
|
59671
|
+
throw createStreamRequestError("write", url2, response, text);
|
|
59635
59672
|
}
|
|
59636
59673
|
}
|
|
59637
59674
|
},
|
|
@@ -59639,13 +59676,14 @@ function createStreamer2(config3) {
|
|
|
59639
59676
|
const resolvedRunId = await runId;
|
|
59640
59677
|
const httpConfig = await getHttpConfig(config3);
|
|
59641
59678
|
httpConfig.headers.set("X-Stream-Done", "true");
|
|
59642
|
-
const
|
|
59679
|
+
const url2 = getStreamUrl(name, resolvedRunId, httpConfig);
|
|
59680
|
+
const response = await fetchStreamMutation(url2, {
|
|
59643
59681
|
method: "PUT",
|
|
59644
59682
|
headers: httpConfig.headers
|
|
59645
59683
|
}, "close");
|
|
59646
59684
|
const text = await response.text();
|
|
59647
59685
|
if (!response.ok) {
|
|
59648
|
-
throw
|
|
59686
|
+
throw createStreamRequestError("close", url2, response, text);
|
|
59649
59687
|
}
|
|
59650
59688
|
},
|
|
59651
59689
|
async readFromStream(name, startIndex) {
|
|
@@ -59813,29 +59851,80 @@ async function handleHealthCheckMessage(healthCheck2, endpoint, worldSpecVersion
|
|
|
59813
59851
|
await world.closeStream(streamName, fakeRunId);
|
|
59814
59852
|
}
|
|
59815
59853
|
__name(handleHealthCheckMessage, "handleHealthCheckMessage");
|
|
59854
|
+
function eventPaginationContractError(runId, message) {
|
|
59855
|
+
return new WorkflowWorldError(`Event pagination ${message} for workflow run "${runId}".`, { code: RUN_ERROR_CODES.WORLD_CONTRACT_ERROR });
|
|
59856
|
+
}
|
|
59857
|
+
__name(eventPaginationContractError, "eventPaginationContractError");
|
|
59858
|
+
function appendUniqueEvents(target2, targetIds, events) {
|
|
59859
|
+
for (const event of events) {
|
|
59860
|
+
if (!targetIds.has(event.eventId)) {
|
|
59861
|
+
targetIds.add(event.eventId);
|
|
59862
|
+
target2.push(event);
|
|
59863
|
+
}
|
|
59864
|
+
}
|
|
59865
|
+
}
|
|
59866
|
+
__name(appendUniqueEvents, "appendUniqueEvents");
|
|
59867
|
+
function assertEventPaginationProgress(runId, hasMore, cursor, requestedCursors) {
|
|
59868
|
+
if (!hasMore) {
|
|
59869
|
+
return;
|
|
59870
|
+
}
|
|
59871
|
+
if (cursor === null) {
|
|
59872
|
+
throw eventPaginationContractError(runId, "returned more pages without a cursor");
|
|
59873
|
+
}
|
|
59874
|
+
if (requestedCursors.has(cursor)) {
|
|
59875
|
+
throw eventPaginationContractError(runId, "repeated a cursor");
|
|
59876
|
+
}
|
|
59877
|
+
}
|
|
59878
|
+
__name(assertEventPaginationProgress, "assertEventPaginationProgress");
|
|
59879
|
+
function shouldRetryWithoutEventCursor(error48, cursor, alreadyRetried) {
|
|
59880
|
+
return cursor !== null && !alreadyRetried && WorkflowWorldError.is(error48) && error48.status === 400;
|
|
59881
|
+
}
|
|
59882
|
+
__name(shouldRetryWithoutEventCursor, "shouldRetryWithoutEventCursor");
|
|
59816
59883
|
async function getWorkflowRunEvents2(runId, cursor) {
|
|
59817
59884
|
return trace2("workflow.loadEvents", async (span) => {
|
|
59818
59885
|
span?.setAttributes({
|
|
59819
59886
|
...WorkflowRunId(runId)
|
|
59820
59887
|
});
|
|
59821
59888
|
const allEvents = [];
|
|
59889
|
+
const loadedEventIds = /* @__PURE__ */ new Set();
|
|
59890
|
+
const requestedCursors = /* @__PURE__ */ new Set();
|
|
59822
59891
|
let nextCursor = cursor ?? null;
|
|
59823
59892
|
let hasMore = true;
|
|
59824
59893
|
let pagesLoaded = 0;
|
|
59894
|
+
let retriedWithoutCursor = false;
|
|
59825
59895
|
const world = getWorld();
|
|
59826
59896
|
const loadStart = Date.now();
|
|
59827
59897
|
while (hasMore) {
|
|
59828
59898
|
const pageStart = Date.now();
|
|
59829
|
-
const
|
|
59830
|
-
|
|
59831
|
-
|
|
59832
|
-
|
|
59833
|
-
|
|
59834
|
-
|
|
59899
|
+
const requestedCursor = nextCursor;
|
|
59900
|
+
if (requestedCursor) {
|
|
59901
|
+
requestedCursors.add(requestedCursor);
|
|
59902
|
+
}
|
|
59903
|
+
let response;
|
|
59904
|
+
try {
|
|
59905
|
+
response = await world.events.list({
|
|
59906
|
+
runId,
|
|
59907
|
+
pagination: {
|
|
59908
|
+
sortOrder: "asc",
|
|
59909
|
+
// Required: events must be in chronological order for replay
|
|
59910
|
+
cursor: requestedCursor ?? void 0
|
|
59911
|
+
}
|
|
59912
|
+
});
|
|
59913
|
+
} catch (error48) {
|
|
59914
|
+
if (shouldRetryWithoutEventCursor(error48, requestedCursor, retriedWithoutCursor)) {
|
|
59915
|
+
runtimeLogger.warn("Event cursor was rejected; retrying with a full event reload.", { workflowRunId: runId });
|
|
59916
|
+
allEvents.length = 0;
|
|
59917
|
+
loadedEventIds.clear();
|
|
59918
|
+
requestedCursors.clear();
|
|
59919
|
+
nextCursor = null;
|
|
59920
|
+
retriedWithoutCursor = true;
|
|
59921
|
+
continue;
|
|
59835
59922
|
}
|
|
59836
|
-
|
|
59837
|
-
|
|
59923
|
+
throw error48;
|
|
59924
|
+
}
|
|
59925
|
+
appendUniqueEvents(allEvents, loadedEventIds, response.data);
|
|
59838
59926
|
hasMore = response.hasMore;
|
|
59927
|
+
assertEventPaginationProgress(runId, hasMore, response.cursor, requestedCursors);
|
|
59839
59928
|
nextCursor = response.cursor ?? nextCursor;
|
|
59840
59929
|
pagesLoaded++;
|
|
59841
59930
|
runtimeLogger.debug("Loaded event page", {
|
|
@@ -60575,12 +60664,15 @@ __name(getSerializationClass, "getSerializationClass");
|
|
|
60575
60664
|
// ../core/dist/flushable-stream.js
|
|
60576
60665
|
var LOCK_POLL_INTERVAL_MS = 100;
|
|
60577
60666
|
function createFlushableState() {
|
|
60578
|
-
|
|
60667
|
+
const state = {
|
|
60579
60668
|
...withResolvers(),
|
|
60580
60669
|
pendingOps: 0,
|
|
60581
60670
|
doneResolved: false,
|
|
60582
60671
|
streamEnded: false
|
|
60583
60672
|
};
|
|
60673
|
+
state.promise.catch(() => {
|
|
60674
|
+
});
|
|
60675
|
+
return state;
|
|
60584
60676
|
}
|
|
60585
60677
|
__name(createFlushableState, "createFlushableState");
|
|
60586
60678
|
function isWritableUnlockedNotClosed(writable) {
|
|
@@ -60781,6 +60873,45 @@ function getStepFunction(stepId) {
|
|
|
60781
60873
|
return void 0;
|
|
60782
60874
|
}
|
|
60783
60875
|
__name(getStepFunction, "getStepFunction");
|
|
60876
|
+
async function awaitEarlierDeliveries(ctx, eventIndex, deferBehindKinds) {
|
|
60877
|
+
if (eventIndex === void 0 || !ctx.pendingDeliveryBarriers || ctx.pendingDeliveryBarriers.size === 0) {
|
|
60878
|
+
return;
|
|
60879
|
+
}
|
|
60880
|
+
const earlier = [];
|
|
60881
|
+
for (const [index, entry] of ctx.pendingDeliveryBarriers) {
|
|
60882
|
+
if (index < eventIndex && deferBehindKinds.includes(entry.kind)) {
|
|
60883
|
+
earlier.push(entry.delivered);
|
|
60884
|
+
}
|
|
60885
|
+
}
|
|
60886
|
+
if (earlier.length > 0) {
|
|
60887
|
+
await Promise.all(earlier);
|
|
60888
|
+
}
|
|
60889
|
+
}
|
|
60890
|
+
__name(awaitEarlierDeliveries, "awaitEarlierDeliveries");
|
|
60891
|
+
function registerDeliveryBarrier(ctx, eventIndex, kind) {
|
|
60892
|
+
const barriers = ctx.pendingDeliveryBarriers;
|
|
60893
|
+
if (!barriers || eventIndex === void 0) {
|
|
60894
|
+
return { markDelivered: /* @__PURE__ */ __name(() => {
|
|
60895
|
+
}, "markDelivered") };
|
|
60896
|
+
}
|
|
60897
|
+
let done = false;
|
|
60898
|
+
const { promise: promise2, resolve: resolve3 } = withResolvers();
|
|
60899
|
+
const entry = { kind, delivered: promise2 };
|
|
60900
|
+
barriers.set(eventIndex, entry);
|
|
60901
|
+
const finish = /* @__PURE__ */ __name(() => {
|
|
60902
|
+
if (done) {
|
|
60903
|
+
return;
|
|
60904
|
+
}
|
|
60905
|
+
done = true;
|
|
60906
|
+
if (barriers.get(eventIndex) === entry) {
|
|
60907
|
+
barriers.delete(eventIndex);
|
|
60908
|
+
}
|
|
60909
|
+
resolve3();
|
|
60910
|
+
}, "finish");
|
|
60911
|
+
scheduleWhenIdle(ctx, finish);
|
|
60912
|
+
return { markDelivered: finish };
|
|
60913
|
+
}
|
|
60914
|
+
__name(registerDeliveryBarrier, "registerDeliveryBarrier");
|
|
60784
60915
|
function scheduleWhenIdle(ctx, fn) {
|
|
60785
60916
|
const check2 = /* @__PURE__ */ __name(() => {
|
|
60786
60917
|
if (ctx.pendingDeliveries > 0) {
|
|
@@ -62455,13 +62586,49 @@ function traceSegmentInternal(segments, memo, line, column, bias) {
|
|
|
62455
62586
|
__name(traceSegmentInternal, "traceSegmentInternal");
|
|
62456
62587
|
|
|
62457
62588
|
// ../core/dist/source-map.js
|
|
62589
|
+
function isBase64Char(code) {
|
|
62590
|
+
return code >= 65 && code <= 90 || code >= 97 && code <= 122 || code >= 48 && code <= 57 || code === 43 || code === 47 || code === 61;
|
|
62591
|
+
}
|
|
62592
|
+
__name(isBase64Char, "isBase64Char");
|
|
62593
|
+
function extractInlineSourceMapBase64(source) {
|
|
62594
|
+
const sourceMapPrefix = "//# sourceMappingURL=data:application/json";
|
|
62595
|
+
const base64Marker = ";base64,";
|
|
62596
|
+
let scanFrom = 0;
|
|
62597
|
+
while (scanFrom < source.length) {
|
|
62598
|
+
const prefixIdx = source.indexOf(sourceMapPrefix, scanFrom);
|
|
62599
|
+
if (prefixIdx === -1)
|
|
62600
|
+
return void 0;
|
|
62601
|
+
const base64Start = source.indexOf(base64Marker, prefixIdx + sourceMapPrefix.length);
|
|
62602
|
+
if (base64Start === -1) {
|
|
62603
|
+
scanFrom = prefixIdx + sourceMapPrefix.length;
|
|
62604
|
+
continue;
|
|
62605
|
+
}
|
|
62606
|
+
const commaBefore = source.indexOf(",", prefixIdx);
|
|
62607
|
+
if (commaBefore !== -1 && commaBefore < base64Start) {
|
|
62608
|
+
scanFrom = base64Start + base64Marker.length;
|
|
62609
|
+
continue;
|
|
62610
|
+
}
|
|
62611
|
+
const valueStart = base64Start + base64Marker.length;
|
|
62612
|
+
let valueEnd = valueStart;
|
|
62613
|
+
while (valueEnd < source.length) {
|
|
62614
|
+
if (!isBase64Char(source.charCodeAt(valueEnd))) {
|
|
62615
|
+
break;
|
|
62616
|
+
}
|
|
62617
|
+
valueEnd++;
|
|
62618
|
+
}
|
|
62619
|
+
if (valueEnd > valueStart) {
|
|
62620
|
+
return source.slice(valueStart, valueEnd);
|
|
62621
|
+
}
|
|
62622
|
+
scanFrom = valueEnd;
|
|
62623
|
+
}
|
|
62624
|
+
}
|
|
62625
|
+
__name(extractInlineSourceMapBase64, "extractInlineSourceMapBase64");
|
|
62458
62626
|
function remapErrorStack(stack, filename, workflowCode2) {
|
|
62459
|
-
const
|
|
62460
|
-
if (!
|
|
62627
|
+
const base643 = extractInlineSourceMapBase64(workflowCode2);
|
|
62628
|
+
if (!base643) {
|
|
62461
62629
|
return stack;
|
|
62462
62630
|
}
|
|
62463
62631
|
try {
|
|
62464
|
-
const base643 = sourceMapMatch[1];
|
|
62465
62632
|
const sourceMapJson = Buffer.from(base643, "base64").toString("utf-8");
|
|
62466
62633
|
const sourceMapData = JSON.parse(sourceMapJson);
|
|
62467
62634
|
const tracer = new TraceMap(sourceMapData);
|
|
@@ -62489,7 +62656,7 @@ function remapErrorStack(stack, filename, workflowCode2) {
|
|
|
62489
62656
|
return line;
|
|
62490
62657
|
});
|
|
62491
62658
|
return remappedLines.join("\n");
|
|
62492
|
-
} catch
|
|
62659
|
+
} catch {
|
|
62493
62660
|
return stack;
|
|
62494
62661
|
}
|
|
62495
62662
|
}
|
|
@@ -63426,23 +63593,55 @@ function createCreateHook(ctx) {
|
|
|
63426
63593
|
return EventConsumerResult.Consumed;
|
|
63427
63594
|
}
|
|
63428
63595
|
if (event.eventType === "hook_received") {
|
|
63596
|
+
const eventIndex = ctx.eventsConsumer.eventIndex;
|
|
63597
|
+
const barrier = registerDeliveryBarrier(ctx, eventIndex, "hook");
|
|
63429
63598
|
if (promises.length > 0) {
|
|
63430
63599
|
const next2 = promises.shift();
|
|
63431
63600
|
if (next2) {
|
|
63432
63601
|
ctx.pendingDeliveries++;
|
|
63602
|
+
let hydrateOutcome;
|
|
63433
63603
|
ctx.promiseQueue = ctx.promiseQueue.then(async () => {
|
|
63434
63604
|
try {
|
|
63435
63605
|
const payload = await hydrateStepReturnValue(event.eventData.payload, ctx.runId, ctx.encryptionKey, ctx.globalThis);
|
|
63436
|
-
|
|
63606
|
+
hydrateOutcome = { ok: true, value: payload };
|
|
63437
63607
|
} catch (error48) {
|
|
63438
|
-
|
|
63608
|
+
hydrateOutcome = { ok: false, error: error48 };
|
|
63439
63609
|
} finally {
|
|
63440
63610
|
ctx.pendingDeliveries--;
|
|
63441
63611
|
}
|
|
63612
|
+
void awaitEarlierDeliveries(ctx, eventIndex, ["wait"]).then(() => {
|
|
63613
|
+
barrier.markDelivered();
|
|
63614
|
+
if (hydrateOutcome.ok) {
|
|
63615
|
+
next2.resolve(hydrateOutcome.value);
|
|
63616
|
+
} else {
|
|
63617
|
+
next2.reject(hydrateOutcome.error);
|
|
63618
|
+
}
|
|
63619
|
+
});
|
|
63442
63620
|
});
|
|
63443
63621
|
}
|
|
63444
63622
|
} else {
|
|
63445
|
-
|
|
63623
|
+
let outcome;
|
|
63624
|
+
const hydrated = withResolvers();
|
|
63625
|
+
const claim = /* @__PURE__ */ __name(() => hydrated.promise.then(() => awaitEarlierDeliveries(ctx, eventIndex, ["wait"])).then(() => {
|
|
63626
|
+
barrier.markDelivered();
|
|
63627
|
+
if (outcome && !outcome.ok) {
|
|
63628
|
+
throw outcome.error;
|
|
63629
|
+
}
|
|
63630
|
+
return outcome.value;
|
|
63631
|
+
}), "claim");
|
|
63632
|
+
ctx.pendingDeliveries++;
|
|
63633
|
+
ctx.promiseQueue = ctx.promiseQueue.then(async () => {
|
|
63634
|
+
try {
|
|
63635
|
+
const payload = await hydrateStepReturnValue(event.eventData.payload, ctx.runId, ctx.encryptionKey, ctx.globalThis);
|
|
63636
|
+
outcome = { ok: true, value: payload };
|
|
63637
|
+
} catch (error48) {
|
|
63638
|
+
outcome = { ok: false, error: error48 };
|
|
63639
|
+
} finally {
|
|
63640
|
+
ctx.pendingDeliveries--;
|
|
63641
|
+
hydrated.resolve();
|
|
63642
|
+
}
|
|
63643
|
+
});
|
|
63644
|
+
payloadsQueue.push({ claim });
|
|
63446
63645
|
}
|
|
63447
63646
|
return EventConsumerResult.Consumed;
|
|
63448
63647
|
}
|
|
@@ -63466,20 +63665,9 @@ function createCreateHook(ctx) {
|
|
|
63466
63665
|
return resolvers.promise;
|
|
63467
63666
|
}
|
|
63468
63667
|
if (payloadsQueue.length > 0) {
|
|
63469
|
-
const
|
|
63470
|
-
if (
|
|
63471
|
-
|
|
63472
|
-
ctx.promiseQueue = ctx.promiseQueue.then(async () => {
|
|
63473
|
-
try {
|
|
63474
|
-
const payload = await hydrateStepReturnValue(nextPayload.eventData.payload, ctx.runId, ctx.encryptionKey, ctx.globalThis);
|
|
63475
|
-
resolvers.resolve(payload);
|
|
63476
|
-
} catch (error48) {
|
|
63477
|
-
resolvers.reject(error48);
|
|
63478
|
-
} finally {
|
|
63479
|
-
ctx.pendingDeliveries--;
|
|
63480
|
-
}
|
|
63481
|
-
});
|
|
63482
|
-
return resolvers.promise;
|
|
63668
|
+
const nextDelivery = payloadsQueue.shift();
|
|
63669
|
+
if (nextDelivery) {
|
|
63670
|
+
return nextDelivery.claim();
|
|
63483
63671
|
}
|
|
63484
63672
|
}
|
|
63485
63673
|
if (eventLogEmpty) {
|
|
@@ -63583,7 +63771,11 @@ function createSleep(ctx) {
|
|
|
63583
63771
|
}
|
|
63584
63772
|
}
|
|
63585
63773
|
ctx.invocationsQueue.delete(correlationId);
|
|
63586
|
-
|
|
63774
|
+
const eventIndex = ctx.eventsConsumer.eventIndex;
|
|
63775
|
+
const barrier = registerDeliveryBarrier(ctx, eventIndex, "wait");
|
|
63776
|
+
const queueAtCompletion = ctx.promiseQueue;
|
|
63777
|
+
void queueAtCompletion.then(() => awaitEarlierDeliveries(ctx, eventIndex, ["hook"])).then(() => {
|
|
63778
|
+
barrier.markDelivered();
|
|
63587
63779
|
resolve3();
|
|
63588
63780
|
});
|
|
63589
63781
|
return EventConsumerResult.Finished;
|
|
@@ -63663,7 +63855,8 @@ async function runWorkflow(workflowCode2, workflowRun, events, encryptionKey) {
|
|
|
63663
63855
|
set promiseQueue(value) {
|
|
63664
63856
|
promiseQueueHolder.current = value;
|
|
63665
63857
|
},
|
|
63666
|
-
pendingDeliveries: 0
|
|
63858
|
+
pendingDeliveries: 0,
|
|
63859
|
+
pendingDeliveryBarriers: /* @__PURE__ */ new Map()
|
|
63667
63860
|
};
|
|
63668
63861
|
workflowContext.eventsConsumer.subscribe((event) => {
|
|
63669
63862
|
const createdAt = event?.createdAt;
|
|
@@ -64972,7 +65165,13 @@ function workflowEntrypoint(workflowCode2) {
|
|
|
64972
65165
|
const completedWaitIdsAfterCursor = new Set(newEvents.events.filter((e) => e.eventType === "wait_completed").map((e) => e.correlationId));
|
|
64973
65166
|
const sawAllWaitCompletions = waitsToComplete.every((waitEvent) => completedWaitIdsAfterCursor.has(waitEvent.correlationId));
|
|
64974
65167
|
if (sawAllWaitCompletions) {
|
|
64975
|
-
events.
|
|
65168
|
+
const existingIds = new Set(events.map((event) => event.eventId));
|
|
65169
|
+
for (const event of newEvents.events) {
|
|
65170
|
+
if (!existingIds.has(event.eventId)) {
|
|
65171
|
+
existingIds.add(event.eventId);
|
|
65172
|
+
events.push(event);
|
|
65173
|
+
}
|
|
65174
|
+
}
|
|
64976
65175
|
} else {
|
|
64977
65176
|
const loadedEvents = await getWorkflowRunEvents2(workflowRun.runId);
|
|
64978
65177
|
events = loadedEvents.events;
|