@workflow/world-testing 4.1.0-beta.68 → 4.1.0-beta.70
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.
|
@@ -2730,7 +2730,7 @@ var require_token_util = __commonJS({
|
|
|
2730
2730
|
getTokenPayload: /* @__PURE__ */ __name(() => getTokenPayload, "getTokenPayload"),
|
|
2731
2731
|
getVercelCliToken: /* @__PURE__ */ __name(() => getVercelCliToken, "getVercelCliToken"),
|
|
2732
2732
|
getVercelDataDir: /* @__PURE__ */ __name(() => getVercelDataDir, "getVercelDataDir"),
|
|
2733
|
-
getVercelOidcToken: /* @__PURE__ */ __name(() =>
|
|
2733
|
+
getVercelOidcToken: /* @__PURE__ */ __name(() => getVercelOidcToken6, "getVercelOidcToken"),
|
|
2734
2734
|
isExpired: /* @__PURE__ */ __name(() => isExpired, "isExpired"),
|
|
2735
2735
|
loadToken: /* @__PURE__ */ __name(() => loadToken, "loadToken"),
|
|
2736
2736
|
saveToken: /* @__PURE__ */ __name(() => saveToken, "saveToken")
|
|
@@ -2765,7 +2765,7 @@ var require_token_util = __commonJS({
|
|
|
2765
2765
|
return JSON.parse(token).token;
|
|
2766
2766
|
}
|
|
2767
2767
|
__name(getVercelCliToken, "getVercelCliToken");
|
|
2768
|
-
async function
|
|
2768
|
+
async function getVercelOidcToken6(authToken, projectId, teamId) {
|
|
2769
2769
|
try {
|
|
2770
2770
|
const url2 = `https://api.vercel.com/v1/projects/${projectId}/token?source=vercel-oidc-refresh${teamId ? `&teamId=${teamId}` : ""}`;
|
|
2771
2771
|
const res = await fetch(url2, {
|
|
@@ -2786,7 +2786,7 @@ var require_token_util = __commonJS({
|
|
|
2786
2786
|
throw new import_token_error.VercelOidcTokenError(`Failed to refresh OIDC token`, e);
|
|
2787
2787
|
}
|
|
2788
2788
|
}
|
|
2789
|
-
__name(
|
|
2789
|
+
__name(getVercelOidcToken6, "getVercelOidcToken");
|
|
2790
2790
|
function assertVercelOidcTokenResponse(res) {
|
|
2791
2791
|
if (!res || typeof res !== "object") {
|
|
2792
2792
|
throw new TypeError("Expected an object");
|
|
@@ -2950,13 +2950,13 @@ var require_get_vercel_oidc_token = __commonJS({
|
|
|
2950
2950
|
var __toCommonJS2 = /* @__PURE__ */ __name((mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod), "__toCommonJS");
|
|
2951
2951
|
var get_vercel_oidc_token_exports = {};
|
|
2952
2952
|
__export2(get_vercel_oidc_token_exports, {
|
|
2953
|
-
getVercelOidcToken: /* @__PURE__ */ __name(() =>
|
|
2953
|
+
getVercelOidcToken: /* @__PURE__ */ __name(() => getVercelOidcToken6, "getVercelOidcToken"),
|
|
2954
2954
|
getVercelOidcTokenSync: /* @__PURE__ */ __name(() => getVercelOidcTokenSync2, "getVercelOidcTokenSync")
|
|
2955
2955
|
});
|
|
2956
2956
|
module2.exports = __toCommonJS2(get_vercel_oidc_token_exports);
|
|
2957
2957
|
var import_get_context = require_get_context();
|
|
2958
2958
|
var import_token_error = require_token_error();
|
|
2959
|
-
async function
|
|
2959
|
+
async function getVercelOidcToken6() {
|
|
2960
2960
|
let token = "";
|
|
2961
2961
|
let err;
|
|
2962
2962
|
try {
|
|
@@ -2982,7 +2982,7 @@ ${error48.message}`;
|
|
|
2982
2982
|
}
|
|
2983
2983
|
return token;
|
|
2984
2984
|
}
|
|
2985
|
-
__name(
|
|
2985
|
+
__name(getVercelOidcToken6, "getVercelOidcToken");
|
|
2986
2986
|
function getVercelOidcTokenSync2() {
|
|
2987
2987
|
const token = (0, import_get_context.getContext)().headers?.["x-vercel-oidc-token"] ?? process.env.VERCEL_OIDC_TOKEN;
|
|
2988
2988
|
if (!token) {
|
|
@@ -28043,7 +28043,7 @@ var require_token_util2 = __commonJS({
|
|
|
28043
28043
|
findProjectInfo: /* @__PURE__ */ __name(() => findProjectInfo, "findProjectInfo"),
|
|
28044
28044
|
getTokenPayload: /* @__PURE__ */ __name(() => getTokenPayload, "getTokenPayload"),
|
|
28045
28045
|
getVercelDataDir: /* @__PURE__ */ __name(() => getVercelDataDir, "getVercelDataDir"),
|
|
28046
|
-
getVercelOidcToken: /* @__PURE__ */ __name(() =>
|
|
28046
|
+
getVercelOidcToken: /* @__PURE__ */ __name(() => getVercelOidcToken6, "getVercelOidcToken"),
|
|
28047
28047
|
getVercelToken: /* @__PURE__ */ __name(() => getVercelToken2, "getVercelToken"),
|
|
28048
28048
|
isExpired: /* @__PURE__ */ __name(() => isExpired, "isExpired"),
|
|
28049
28049
|
loadToken: /* @__PURE__ */ __name(() => loadToken, "loadToken"),
|
|
@@ -28105,7 +28105,7 @@ var require_token_util2 = __commonJS({
|
|
|
28105
28105
|
}
|
|
28106
28106
|
}
|
|
28107
28107
|
__name(getVercelToken2, "getVercelToken");
|
|
28108
|
-
async function
|
|
28108
|
+
async function getVercelOidcToken6(authToken, projectId, teamId) {
|
|
28109
28109
|
const url2 = `https://api.vercel.com/v1/projects/${projectId}/token?source=vercel-oidc-refresh${teamId ? `&teamId=${teamId}` : ""}`;
|
|
28110
28110
|
const res = await fetch(url2, {
|
|
28111
28111
|
method: "POST",
|
|
@@ -28122,7 +28122,7 @@ var require_token_util2 = __commonJS({
|
|
|
28122
28122
|
assertVercelOidcTokenResponse(tokenRes);
|
|
28123
28123
|
return tokenRes;
|
|
28124
28124
|
}
|
|
28125
|
-
__name(
|
|
28125
|
+
__name(getVercelOidcToken6, "getVercelOidcToken");
|
|
28126
28126
|
function assertVercelOidcTokenResponse(res) {
|
|
28127
28127
|
if (!res || typeof res !== "object") {
|
|
28128
28128
|
throw new TypeError(
|
|
@@ -28297,13 +28297,13 @@ var require_get_vercel_oidc_token2 = __commonJS({
|
|
|
28297
28297
|
var __toCommonJS2 = /* @__PURE__ */ __name((mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod), "__toCommonJS");
|
|
28298
28298
|
var get_vercel_oidc_token_exports = {};
|
|
28299
28299
|
__export2(get_vercel_oidc_token_exports, {
|
|
28300
|
-
getVercelOidcToken: /* @__PURE__ */ __name(() =>
|
|
28300
|
+
getVercelOidcToken: /* @__PURE__ */ __name(() => getVercelOidcToken6, "getVercelOidcToken"),
|
|
28301
28301
|
getVercelOidcTokenSync: /* @__PURE__ */ __name(() => getVercelOidcTokenSync2, "getVercelOidcTokenSync")
|
|
28302
28302
|
});
|
|
28303
28303
|
module2.exports = __toCommonJS2(get_vercel_oidc_token_exports);
|
|
28304
28304
|
var import_get_context = require_get_context2();
|
|
28305
28305
|
var import_token_error = require_token_error2();
|
|
28306
|
-
async function
|
|
28306
|
+
async function getVercelOidcToken6(options) {
|
|
28307
28307
|
let token = "";
|
|
28308
28308
|
let err;
|
|
28309
28309
|
try {
|
|
@@ -28333,7 +28333,7 @@ ${error48.message}`;
|
|
|
28333
28333
|
}
|
|
28334
28334
|
return token;
|
|
28335
28335
|
}
|
|
28336
|
-
__name(
|
|
28336
|
+
__name(getVercelOidcToken6, "getVercelOidcToken");
|
|
28337
28337
|
function getVercelOidcTokenSync2() {
|
|
28338
28338
|
const token = (0, import_get_context.getContext)().headers?.["x-vercel-oidc-token"] ?? process.env.VERCEL_OIDC_TOKEN;
|
|
28339
28339
|
if (!token) {
|
|
@@ -30831,6 +30831,20 @@ function parseDurationToDate(param) {
|
|
|
30831
30831
|
}
|
|
30832
30832
|
__name(parseDurationToDate, "parseDurationToDate");
|
|
30833
30833
|
|
|
30834
|
+
// ../utils/dist/world-target.js
|
|
30835
|
+
function resolveWorkflowTargetWorld(env = process.env) {
|
|
30836
|
+
const configuredWorld = env.WORKFLOW_TARGET_WORLD;
|
|
30837
|
+
if (configuredWorld) {
|
|
30838
|
+
return configuredWorld;
|
|
30839
|
+
}
|
|
30840
|
+
return env.VERCEL_DEPLOYMENT_ID ? "vercel" : "local";
|
|
30841
|
+
}
|
|
30842
|
+
__name(resolveWorkflowTargetWorld, "resolveWorkflowTargetWorld");
|
|
30843
|
+
function isVercelWorldTarget(targetWorld) {
|
|
30844
|
+
return targetWorld === "vercel" || targetWorld === "@workflow/world-vercel";
|
|
30845
|
+
}
|
|
30846
|
+
__name(isVercelWorldTarget, "isVercelWorldTarget");
|
|
30847
|
+
|
|
30834
30848
|
// ../errors/dist/index.js
|
|
30835
30849
|
var BASE_URL = "https://useworkflow.dev/err";
|
|
30836
30850
|
function isError(value) {
|
|
@@ -49003,17 +49017,86 @@ var LOCAL_QUEUE_MAX_VISIBILITY = parseInt(process.env.WORKFLOW_LOCAL_QUEUE_MAX_V
|
|
|
49003
49017
|
var MAX_SAFE_TIMEOUT_MS = 2147483647;
|
|
49004
49018
|
var DEFAULT_CONCURRENCY_LIMIT = 1e3;
|
|
49005
49019
|
var WORKFLOW_LOCAL_QUEUE_CONCURRENCY = parseInt(process.env.WORKFLOW_LOCAL_QUEUE_CONCURRENCY ?? "0", 10) || DEFAULT_CONCURRENCY_LIMIT;
|
|
49006
|
-
function
|
|
49020
|
+
function getQueueRoute(queueName) {
|
|
49021
|
+
if (queueName.startsWith("__wkf_step_")) {
|
|
49022
|
+
return { pathname: "step", prefix: "__wkf_step_" };
|
|
49023
|
+
}
|
|
49024
|
+
if (queueName.startsWith("__wkf_workflow_")) {
|
|
49025
|
+
return { pathname: "flow", prefix: "__wkf_workflow_" };
|
|
49026
|
+
}
|
|
49027
|
+
throw new Error("Unknown queue name prefix");
|
|
49028
|
+
}
|
|
49029
|
+
__name(getQueueRoute, "getQueueRoute");
|
|
49030
|
+
function createQueueExecutor(config3) {
|
|
49007
49031
|
const httpAgent = new import_undici.Agent({
|
|
49008
49032
|
headersTimeout: 0,
|
|
49009
49033
|
connections: 1e3,
|
|
49010
49034
|
keepAliveTimeout: 3e4
|
|
49011
49035
|
});
|
|
49036
|
+
const directHandlers = /* @__PURE__ */ new Map();
|
|
49037
|
+
const executeMessage = /* @__PURE__ */ __name(async ({ queueName, messageId, attempt, body, headers: extraHeaders }) => {
|
|
49038
|
+
const { pathname, prefix } = getQueueRoute(queueName);
|
|
49039
|
+
const headers = {
|
|
49040
|
+
...extraHeaders,
|
|
49041
|
+
"content-type": "application/json",
|
|
49042
|
+
"x-vqs-queue-name": queueName,
|
|
49043
|
+
"x-vqs-message-id": messageId,
|
|
49044
|
+
"x-vqs-message-attempt": String(attempt)
|
|
49045
|
+
};
|
|
49046
|
+
const directHandler = directHandlers.get(prefix);
|
|
49047
|
+
let response;
|
|
49048
|
+
if (directHandler) {
|
|
49049
|
+
const req = new Request("http://localhost/.well-known/workflow/v1/" + pathname, {
|
|
49050
|
+
method: "POST",
|
|
49051
|
+
headers,
|
|
49052
|
+
body
|
|
49053
|
+
});
|
|
49054
|
+
response = await directHandler(req);
|
|
49055
|
+
} else {
|
|
49056
|
+
const baseUrl = await resolveBaseUrl(config3);
|
|
49057
|
+
response = await fetch(`${baseUrl}/.well-known/workflow/v1/${pathname}`, {
|
|
49058
|
+
method: "POST",
|
|
49059
|
+
duplex: "half",
|
|
49060
|
+
dispatcher: httpAgent,
|
|
49061
|
+
headers,
|
|
49062
|
+
body
|
|
49063
|
+
});
|
|
49064
|
+
}
|
|
49065
|
+
const text = await response.text();
|
|
49066
|
+
if (!response.ok) {
|
|
49067
|
+
return {
|
|
49068
|
+
type: "error",
|
|
49069
|
+
status: response.status,
|
|
49070
|
+
text,
|
|
49071
|
+
headers: Object.fromEntries(response.headers.entries())
|
|
49072
|
+
};
|
|
49073
|
+
}
|
|
49074
|
+
try {
|
|
49075
|
+
const timeoutSeconds = Number(JSON.parse(text).timeoutSeconds);
|
|
49076
|
+
if (Number.isFinite(timeoutSeconds) && timeoutSeconds >= 0) {
|
|
49077
|
+
return { type: "reschedule", timeoutSeconds };
|
|
49078
|
+
}
|
|
49079
|
+
} catch {
|
|
49080
|
+
}
|
|
49081
|
+
return { type: "completed" };
|
|
49082
|
+
}, "executeMessage");
|
|
49083
|
+
return {
|
|
49084
|
+
executeMessage,
|
|
49085
|
+
registerHandler(prefix, handler) {
|
|
49086
|
+
directHandlers.set(prefix, handler);
|
|
49087
|
+
},
|
|
49088
|
+
async close() {
|
|
49089
|
+
await httpAgent.close();
|
|
49090
|
+
}
|
|
49091
|
+
};
|
|
49092
|
+
}
|
|
49093
|
+
__name(createQueueExecutor, "createQueueExecutor");
|
|
49094
|
+
function createQueue(config3) {
|
|
49095
|
+
const executor = createQueueExecutor(config3);
|
|
49012
49096
|
const transport = new JsonTransport();
|
|
49013
49097
|
const generateId2 = monotonicFactory();
|
|
49014
49098
|
const semaphore = new import_async_sema.Sema(WORKFLOW_LOCAL_QUEUE_CONCURRENCY);
|
|
49015
49099
|
const inflightMessages = /* @__PURE__ */ new Map();
|
|
49016
|
-
const directHandlers = /* @__PURE__ */ new Map();
|
|
49017
49100
|
const queue = /* @__PURE__ */ __name(async (queueName, message, opts) => {
|
|
49018
49101
|
const cleanup = [];
|
|
49019
49102
|
if (opts?.idempotencyKey) {
|
|
@@ -49023,17 +49106,7 @@ function createQueue(config3) {
|
|
|
49023
49106
|
}
|
|
49024
49107
|
}
|
|
49025
49108
|
const body = transport.serialize(message);
|
|
49026
|
-
|
|
49027
|
-
let prefix;
|
|
49028
|
-
if (queueName.startsWith("__wkf_step_")) {
|
|
49029
|
-
pathname = `step`;
|
|
49030
|
-
prefix = "__wkf_step_";
|
|
49031
|
-
} else if (queueName.startsWith("__wkf_workflow_")) {
|
|
49032
|
-
pathname = `flow`;
|
|
49033
|
-
prefix = "__wkf_workflow_";
|
|
49034
|
-
} else {
|
|
49035
|
-
throw new Error("Unknown queue name prefix");
|
|
49036
|
-
}
|
|
49109
|
+
getQueueRoute(queueName);
|
|
49037
49110
|
const messageId = MessageId.parse(`msg_${generateId2()}`);
|
|
49038
49111
|
if (opts?.idempotencyKey) {
|
|
49039
49112
|
const key = opts.idempotencyKey;
|
|
@@ -49050,53 +49123,31 @@ function createQueue(config3) {
|
|
|
49050
49123
|
}
|
|
49051
49124
|
try {
|
|
49052
49125
|
let defaultRetriesLeft = 3;
|
|
49053
|
-
const directHandler = directHandlers.get(prefix);
|
|
49054
49126
|
for (let attempt = 0; defaultRetriesLeft > 0; attempt++) {
|
|
49055
49127
|
defaultRetriesLeft--;
|
|
49056
|
-
|
|
49057
|
-
|
|
49058
|
-
|
|
49059
|
-
|
|
49060
|
-
|
|
49061
|
-
|
|
49062
|
-
|
|
49063
|
-
|
|
49064
|
-
if (directHandler) {
|
|
49065
|
-
const req = new Request("http://localhost/.well-known/workflow/v1/" + pathname, {
|
|
49066
|
-
method: "POST",
|
|
49067
|
-
headers,
|
|
49068
|
-
body
|
|
49069
|
-
});
|
|
49070
|
-
response = await directHandler(req);
|
|
49071
|
-
} else {
|
|
49072
|
-
const baseUrl = await resolveBaseUrl(config3);
|
|
49073
|
-
response = await fetch(`${baseUrl}/.well-known/workflow/v1/${pathname}`, {
|
|
49074
|
-
method: "POST",
|
|
49075
|
-
duplex: "half",
|
|
49076
|
-
dispatcher: httpAgent,
|
|
49077
|
-
headers,
|
|
49078
|
-
body
|
|
49079
|
-
});
|
|
49080
|
-
}
|
|
49081
|
-
if (response.ok) {
|
|
49128
|
+
const result = await executor.executeMessage({
|
|
49129
|
+
queueName,
|
|
49130
|
+
messageId,
|
|
49131
|
+
attempt: attempt + 1,
|
|
49132
|
+
body,
|
|
49133
|
+
headers: opts?.headers
|
|
49134
|
+
});
|
|
49135
|
+
if (result.type === "completed") {
|
|
49082
49136
|
return;
|
|
49083
49137
|
}
|
|
49084
|
-
|
|
49085
|
-
|
|
49086
|
-
|
|
49087
|
-
const timeoutSeconds = Number(JSON.parse(text).timeoutSeconds);
|
|
49088
|
-
const timeoutMs = Math.min(timeoutSeconds * 1e3, MAX_SAFE_TIMEOUT_MS);
|
|
49138
|
+
if (result.type === "reschedule") {
|
|
49139
|
+
if (result.timeoutSeconds > 0) {
|
|
49140
|
+
const timeoutMs = Math.min(result.timeoutSeconds * 1e3, MAX_SAFE_TIMEOUT_MS);
|
|
49089
49141
|
await (0, import_promises3.setTimeout)(timeoutMs);
|
|
49090
|
-
defaultRetriesLeft++;
|
|
49091
|
-
continue;
|
|
49092
|
-
} catch {
|
|
49093
49142
|
}
|
|
49143
|
+
defaultRetriesLeft++;
|
|
49144
|
+
continue;
|
|
49094
49145
|
}
|
|
49095
49146
|
console.error(`[local world] Failed to queue message`, {
|
|
49096
49147
|
queueName,
|
|
49097
|
-
text,
|
|
49098
|
-
status:
|
|
49099
|
-
headers:
|
|
49148
|
+
text: result.text,
|
|
49149
|
+
status: result.status,
|
|
49150
|
+
headers: result.headers,
|
|
49100
49151
|
body: body.toString()
|
|
49101
49152
|
});
|
|
49102
49153
|
}
|
|
@@ -49143,7 +49194,7 @@ function createQueue(config3) {
|
|
|
49143
49194
|
timeoutSeconds = Math.min(result.timeoutSeconds, LOCAL_QUEUE_MAX_VISIBILITY);
|
|
49144
49195
|
}
|
|
49145
49196
|
if (timeoutSeconds != null) {
|
|
49146
|
-
return Response.json({ timeoutSeconds }
|
|
49197
|
+
return Response.json({ timeoutSeconds });
|
|
49147
49198
|
}
|
|
49148
49199
|
return Response.json({ ok: true });
|
|
49149
49200
|
} catch (error48) {
|
|
@@ -49159,11 +49210,9 @@ function createQueue(config3) {
|
|
|
49159
49210
|
queue,
|
|
49160
49211
|
createQueueHandler,
|
|
49161
49212
|
getDeploymentId,
|
|
49162
|
-
registerHandler
|
|
49163
|
-
directHandlers.set(prefix, handler);
|
|
49164
|
-
},
|
|
49213
|
+
registerHandler: executor.registerHandler,
|
|
49165
49214
|
async close() {
|
|
49166
|
-
await
|
|
49215
|
+
await executor.close();
|
|
49167
49216
|
}
|
|
49168
49217
|
};
|
|
49169
49218
|
}
|
|
@@ -50618,11 +50667,17 @@ async function fetchRunKey(deploymentId, projectId, runId, options) {
|
|
|
50618
50667
|
headers: {
|
|
50619
50668
|
authorization: `Bearer ${token}`
|
|
50620
50669
|
},
|
|
50670
|
+
// @ts-expect-error -- undici dispatcher is accepted by Node.js fetch but not in @types/node's RequestInit
|
|
50621
50671
|
dispatcher: getDispatcher()
|
|
50622
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- undici v7 dispatcher types don't match @types/node's RequestInit
|
|
50623
50672
|
});
|
|
50624
50673
|
if (!response.ok) {
|
|
50625
|
-
|
|
50674
|
+
let body;
|
|
50675
|
+
try {
|
|
50676
|
+
body = await response.text();
|
|
50677
|
+
} catch {
|
|
50678
|
+
body = "<unable to read response body>";
|
|
50679
|
+
}
|
|
50680
|
+
throw new Error(`Failed to fetch run key for ${runId} (deployment ${deploymentId}): HTTP ${response.status} ${response.statusText}${body ? ` \u2014 ${body}` : ""}`);
|
|
50626
50681
|
}
|
|
50627
50682
|
const data = await response.json();
|
|
50628
50683
|
const result = object({ key: string2().nullable() }).safeParse(data);
|
|
@@ -50638,7 +50693,7 @@ __name(fetchRunKey, "fetchRunKey");
|
|
|
50638
50693
|
function createGetEncryptionKeyForRun(projectId, teamId, token) {
|
|
50639
50694
|
if (!projectId)
|
|
50640
50695
|
return void 0;
|
|
50641
|
-
const
|
|
50696
|
+
const isServerlessRuntime = process.env.VERCEL === "1";
|
|
50642
50697
|
let localDeploymentKey;
|
|
50643
50698
|
function getLocalDeploymentKey() {
|
|
50644
50699
|
if (localDeploymentKey)
|
|
@@ -50653,12 +50708,16 @@ function createGetEncryptionKeyForRun(projectId, teamId, token) {
|
|
|
50653
50708
|
return /* @__PURE__ */ __name(async function getEncryptionKeyForRun(run, context2) {
|
|
50654
50709
|
const runId = typeof run === "string" ? run : run.runId;
|
|
50655
50710
|
const deploymentId = typeof run === "string" ? context2?.deploymentId : run.deploymentId;
|
|
50656
|
-
if (
|
|
50657
|
-
|
|
50658
|
-
|
|
50659
|
-
|
|
50660
|
-
|
|
50711
|
+
if (isServerlessRuntime) {
|
|
50712
|
+
if (!deploymentId || deploymentId === process.env.VERCEL_DEPLOYMENT_ID) {
|
|
50713
|
+
const localKey = getLocalDeploymentKey();
|
|
50714
|
+
if (!localKey)
|
|
50715
|
+
return void 0;
|
|
50716
|
+
return deriveRunKey(localKey, projectId, runId);
|
|
50717
|
+
}
|
|
50661
50718
|
}
|
|
50719
|
+
if (!deploymentId)
|
|
50720
|
+
return void 0;
|
|
50662
50721
|
return fetchRunKey(deploymentId, projectId, runId, { token, teamId });
|
|
50663
50722
|
}, "getEncryptionKeyForRun");
|
|
50664
50723
|
}
|
|
@@ -53086,7 +53145,7 @@ var RpcService3 = SemanticConvention3("rpc.service");
|
|
|
53086
53145
|
var RpcMethod3 = SemanticConvention3("rpc.method");
|
|
53087
53146
|
|
|
53088
53147
|
// ../world-vercel/dist/version.js
|
|
53089
|
-
var version2 = "4.1.0-beta.
|
|
53148
|
+
var version2 = "4.1.0-beta.43";
|
|
53090
53149
|
|
|
53091
53150
|
// ../world-vercel/dist/utils.js
|
|
53092
53151
|
var WORKFLOW_SERVER_URL_OVERRIDE = "";
|
|
@@ -53414,6 +53473,50 @@ function createQueue2(config3) {
|
|
|
53414
53473
|
}
|
|
53415
53474
|
__name(createQueue2, "createQueue");
|
|
53416
53475
|
|
|
53476
|
+
// ../world-vercel/dist/resolve-latest-deployment.js
|
|
53477
|
+
var import_oidc4 = __toESM(require_dist2(), 1);
|
|
53478
|
+
var ResolveLatestDeploymentResponseSchema = object({
|
|
53479
|
+
id: string2()
|
|
53480
|
+
});
|
|
53481
|
+
function createResolveLatestDeploymentId(config3) {
|
|
53482
|
+
return /* @__PURE__ */ __name(async function resolveLatestDeploymentId() {
|
|
53483
|
+
const currentDeploymentId = process.env.VERCEL_DEPLOYMENT_ID;
|
|
53484
|
+
if (!currentDeploymentId) {
|
|
53485
|
+
throw new Error("Cannot resolve latest deployment: VERCEL_DEPLOYMENT_ID environment variable is not set");
|
|
53486
|
+
}
|
|
53487
|
+
const oidcToken = await (0, import_oidc4.getVercelOidcToken)().catch(() => null);
|
|
53488
|
+
const token = config3?.token ?? oidcToken ?? process.env.VERCEL_TOKEN;
|
|
53489
|
+
if (!token) {
|
|
53490
|
+
throw new Error("Cannot resolve latest deployment: no OIDC token or VERCEL_TOKEN available");
|
|
53491
|
+
}
|
|
53492
|
+
const url2 = `https://api.vercel.com/v1/workflow/resolve-latest-deployment/${encodeURIComponent(currentDeploymentId)}`;
|
|
53493
|
+
const response = await fetch(url2, {
|
|
53494
|
+
method: "GET",
|
|
53495
|
+
headers: {
|
|
53496
|
+
authorization: `Bearer ${token}`
|
|
53497
|
+
},
|
|
53498
|
+
// @ts-expect-error -- undici dispatcher is accepted by Node.js fetch but not in @types/node's RequestInit
|
|
53499
|
+
dispatcher: getDispatcher()
|
|
53500
|
+
});
|
|
53501
|
+
if (!response.ok) {
|
|
53502
|
+
let body;
|
|
53503
|
+
try {
|
|
53504
|
+
body = await response.text();
|
|
53505
|
+
} catch {
|
|
53506
|
+
body = "<unable to read response body>";
|
|
53507
|
+
}
|
|
53508
|
+
throw new Error(`Failed to resolve latest deployment for ${currentDeploymentId}: HTTP ${response.status} ${response.statusText}${body ? ` \u2014 ${body}` : ""}`);
|
|
53509
|
+
}
|
|
53510
|
+
const data = await response.json();
|
|
53511
|
+
const result = ResolveLatestDeploymentResponseSchema.safeParse(data);
|
|
53512
|
+
if (!result.success) {
|
|
53513
|
+
throw new Error(`Invalid response from Vercel API: expected { id: string }. Zod error: ${result.error.message}`);
|
|
53514
|
+
}
|
|
53515
|
+
return result.data.id;
|
|
53516
|
+
}, "resolveLatestDeploymentId");
|
|
53517
|
+
}
|
|
53518
|
+
__name(createResolveLatestDeploymentId, "createResolveLatestDeploymentId");
|
|
53519
|
+
|
|
53417
53520
|
// ../world-vercel/dist/refs.js
|
|
53418
53521
|
function isRefDescriptor(value) {
|
|
53419
53522
|
return typeof value === "object" && value !== null && "_type" in value && "_ref" in value && typeof value._ref === "string" && value._type === "RemoteRef";
|
|
@@ -53579,7 +53682,7 @@ async function getWorkflowRun(id, params, config3) {
|
|
|
53579
53682
|
const searchParams = new URLSearchParams();
|
|
53580
53683
|
searchParams.set("remoteRefBehavior", remoteRefBehavior);
|
|
53581
53684
|
const queryString = searchParams.toString();
|
|
53582
|
-
const endpoint = `/v2/runs/${id}${queryString ? `?${queryString}` : ""}`;
|
|
53685
|
+
const endpoint = `/v2/runs/${encodeURIComponent(id)}${queryString ? `?${queryString}` : ""}`;
|
|
53583
53686
|
try {
|
|
53584
53687
|
const run = await makeRequest({
|
|
53585
53688
|
endpoint,
|
|
@@ -53602,7 +53705,7 @@ async function cancelWorkflowRunV1(id, params, config3) {
|
|
|
53602
53705
|
const searchParams = new URLSearchParams();
|
|
53603
53706
|
searchParams.set("remoteRefBehavior", remoteRefBehavior);
|
|
53604
53707
|
const queryString = searchParams.toString();
|
|
53605
|
-
const endpoint = `/v1/runs/${id}/cancel${queryString ? `?${queryString}` : ""}`;
|
|
53708
|
+
const endpoint = `/v1/runs/${encodeURIComponent(id)}/cancel${queryString ? `?${queryString}` : ""}`;
|
|
53606
53709
|
try {
|
|
53607
53710
|
const run = await makeRequest({
|
|
53608
53711
|
endpoint,
|
|
@@ -53706,7 +53809,7 @@ async function listWorkflowRunSteps(params, config3) {
|
|
|
53706
53809
|
const remoteRefBehavior = resolveData === "none" ? "lazy" : "resolve";
|
|
53707
53810
|
searchParams.set("remoteRefBehavior", remoteRefBehavior);
|
|
53708
53811
|
const queryString = searchParams.toString();
|
|
53709
|
-
const endpoint = `/v2/runs/${runId}/steps${queryString ? `?${queryString}` : ""}`;
|
|
53812
|
+
const endpoint = `/v2/runs/${encodeURIComponent(runId)}/steps${queryString ? `?${queryString}` : ""}`;
|
|
53710
53813
|
const response = await makeRequest({
|
|
53711
53814
|
endpoint,
|
|
53712
53815
|
options: { method: "GET" },
|
|
@@ -53725,7 +53828,7 @@ async function getStep(runId, stepId, params, config3) {
|
|
|
53725
53828
|
const searchParams = new URLSearchParams();
|
|
53726
53829
|
searchParams.set("remoteRefBehavior", remoteRefBehavior);
|
|
53727
53830
|
const queryString = searchParams.toString();
|
|
53728
|
-
const endpoint = runId ? `/v2/runs/${runId}/steps/${stepId}${queryString ? `?${queryString}` : ""}` : `/v2/steps/${stepId}${queryString ? `?${queryString}` : ""}`;
|
|
53831
|
+
const endpoint = runId ? `/v2/runs/${encodeURIComponent(runId)}/steps/${encodeURIComponent(stepId)}${queryString ? `?${queryString}` : ""}` : `/v2/steps/${encodeURIComponent(stepId)}${queryString ? `?${queryString}` : ""}`;
|
|
53729
53832
|
const step = await makeRequest({
|
|
53730
53833
|
endpoint,
|
|
53731
53834
|
options: { method: "GET" },
|
|
@@ -53868,7 +53971,7 @@ async function getEvent(runId, eventId, params, config3) {
|
|
|
53868
53971
|
const searchParams = new URLSearchParams();
|
|
53869
53972
|
searchParams.set("remoteRefBehavior", remoteRefBehavior);
|
|
53870
53973
|
const queryString = searchParams.toString();
|
|
53871
|
-
const endpoint = `/v2/runs/${runId}/events/${eventId}${queryString ? `?${queryString}` : ""}`;
|
|
53974
|
+
const endpoint = `/v2/runs/${encodeURIComponent(runId)}/events/${encodeURIComponent(eventId)}${queryString ? `?${queryString}` : ""}`;
|
|
53872
53975
|
const event = await makeRequest({
|
|
53873
53976
|
endpoint,
|
|
53874
53977
|
options: { method: "GET" },
|
|
@@ -53902,7 +54005,7 @@ async function getWorkflowRunEvents(params, config3) {
|
|
|
53902
54005
|
searchParams.set("remoteRefBehavior", "lazy");
|
|
53903
54006
|
const queryString = searchParams.toString();
|
|
53904
54007
|
const query = queryString ? `?${queryString}` : "";
|
|
53905
|
-
const endpoint = correlationId ? `/v2/events${query}` : `/v2/runs/${runId}/events${query}`;
|
|
54008
|
+
const endpoint = correlationId ? `/v2/events${query}` : `/v2/runs/${encodeURIComponent(runId)}/events${query}`;
|
|
53906
54009
|
let refResolveConcurrency;
|
|
53907
54010
|
const response = await makeRequest({
|
|
53908
54011
|
endpoint,
|
|
@@ -53954,7 +54057,7 @@ async function createWorkflowRunEvent(id, data, params, config3) {
|
|
|
53954
54057
|
return { run };
|
|
53955
54058
|
}
|
|
53956
54059
|
const wireResult2 = await makeRequest({
|
|
53957
|
-
endpoint: `/v1/runs/${id}/events`,
|
|
54060
|
+
endpoint: `/v1/runs/${encodeURIComponent(id)}/events`,
|
|
53958
54061
|
options: { method: "POST" },
|
|
53959
54062
|
data,
|
|
53960
54063
|
config: config3,
|
|
@@ -53968,7 +54071,7 @@ async function createWorkflowRunEvent(id, data, params, config3) {
|
|
|
53968
54071
|
throw new WorkflowAPIError(validationError, { status: 400 });
|
|
53969
54072
|
}
|
|
53970
54073
|
}
|
|
53971
|
-
const runIdPath = id === null ? "null" : id;
|
|
54074
|
+
const runIdPath = id === null ? "null" : encodeURIComponent(id);
|
|
53972
54075
|
const remoteRefBehavior = eventsNeedingResolve.has(data.eventType) ? "resolve" : "lazy";
|
|
53973
54076
|
if (remoteRefBehavior === "resolve") {
|
|
53974
54077
|
const wireResult2 = await makeRequest({
|
|
@@ -54044,7 +54147,7 @@ async function listHooks(params, config3) {
|
|
|
54044
54147
|
__name(listHooks, "listHooks");
|
|
54045
54148
|
async function getHook(hookId, params, config3) {
|
|
54046
54149
|
const resolveData = params?.resolveData || "all";
|
|
54047
|
-
const endpoint = `/v2/hooks/${hookId}`;
|
|
54150
|
+
const endpoint = `/v2/hooks/${encodeURIComponent(hookId)}`;
|
|
54048
54151
|
const hook = await makeRequest({
|
|
54049
54152
|
endpoint,
|
|
54050
54153
|
options: { method: "GET" },
|
|
@@ -54157,7 +54260,7 @@ __name(createStorage2, "createStorage");
|
|
|
54157
54260
|
// ../world-vercel/dist/streamer.js
|
|
54158
54261
|
function getStreamUrl(name, runId, httpConfig) {
|
|
54159
54262
|
if (runId) {
|
|
54160
|
-
return new URL(`${httpConfig.baseUrl}/v2/runs/${runId}/stream/${encodeURIComponent(name)}`);
|
|
54263
|
+
return new URL(`${httpConfig.baseUrl}/v2/runs/${encodeURIComponent(runId)}/stream/${encodeURIComponent(name)}`);
|
|
54161
54264
|
}
|
|
54162
54265
|
return new URL(`${httpConfig.baseUrl}/v2/stream/${encodeURIComponent(name)}`);
|
|
54163
54266
|
}
|
|
@@ -54238,7 +54341,7 @@ function createStreamer2(config3) {
|
|
|
54238
54341
|
},
|
|
54239
54342
|
async listStreamsByRunId(runId) {
|
|
54240
54343
|
const httpConfig = await getHttpConfig(config3);
|
|
54241
|
-
const url2 = new URL(`${httpConfig.baseUrl}/v2/runs/${runId}/streams`);
|
|
54344
|
+
const url2 = new URL(`${httpConfig.baseUrl}/v2/runs/${encodeURIComponent(runId)}/streams`);
|
|
54242
54345
|
const response = await fetch(url2, {
|
|
54243
54346
|
headers: httpConfig.headers
|
|
54244
54347
|
});
|
|
@@ -54258,7 +54361,8 @@ function createVercelWorld(config3) {
|
|
|
54258
54361
|
...createQueue2(config3),
|
|
54259
54362
|
...createStorage2(config3),
|
|
54260
54363
|
...createStreamer2(config3),
|
|
54261
|
-
getEncryptionKeyForRun: createGetEncryptionKeyForRun(projectId, config3?.projectConfig?.teamId, config3?.token)
|
|
54364
|
+
getEncryptionKeyForRun: createGetEncryptionKeyForRun(projectId, config3?.projectConfig?.teamId, config3?.token),
|
|
54365
|
+
resolveLatestDeploymentId: createResolveLatestDeploymentId(config3)
|
|
54262
54366
|
};
|
|
54263
54367
|
}
|
|
54264
54368
|
__name(createVercelWorld, "createVercelWorld");
|
|
@@ -54268,27 +54372,19 @@ var require2 = (0, import_node_module.createRequire)((0, import_node_path9.join)
|
|
|
54268
54372
|
var WorldCache = /* @__PURE__ */ Symbol.for("@workflow/world//cache");
|
|
54269
54373
|
var StubbedWorldCache = /* @__PURE__ */ Symbol.for("@workflow/world//stubbedCache");
|
|
54270
54374
|
var globalSymbols = globalThis;
|
|
54271
|
-
function defaultWorld() {
|
|
54272
|
-
if (process.env.VERCEL_DEPLOYMENT_ID) {
|
|
54273
|
-
return "vercel";
|
|
54274
|
-
}
|
|
54275
|
-
return "local";
|
|
54276
|
-
}
|
|
54277
|
-
__name(defaultWorld, "defaultWorld");
|
|
54278
54375
|
var createWorld = /* @__PURE__ */ __name(() => {
|
|
54279
|
-
const targetWorld =
|
|
54280
|
-
if (targetWorld
|
|
54281
|
-
|
|
54282
|
-
|
|
54283
|
-
|
|
54284
|
-
|
|
54285
|
-
|
|
54286
|
-
|
|
54287
|
-
|
|
54288
|
-
|
|
54289
|
-
|
|
54290
|
-
|
|
54291
|
-
});
|
|
54376
|
+
const targetWorld = resolveWorkflowTargetWorld();
|
|
54377
|
+
if (isVercelWorldTarget(targetWorld)) {
|
|
54378
|
+
const staleEnvVars = [
|
|
54379
|
+
"WORKFLOW_VERCEL_PROJECT",
|
|
54380
|
+
"WORKFLOW_VERCEL_TEAM",
|
|
54381
|
+
"WORKFLOW_VERCEL_AUTH_TOKEN",
|
|
54382
|
+
"WORKFLOW_VERCEL_ENV"
|
|
54383
|
+
].filter((key) => process.env[key]);
|
|
54384
|
+
if (staleEnvVars.length > 0) {
|
|
54385
|
+
console.warn(`[workflow] Warning: ${staleEnvVars.join(", ")} env var(s) are set but have no effect at runtime. These are only used by the Workflow CLI. Remove them from your Vercel project environment variables.`);
|
|
54386
|
+
}
|
|
54387
|
+
return createVercelWorld();
|
|
54292
54388
|
}
|
|
54293
54389
|
if (targetWorld === "local") {
|
|
54294
54390
|
return createLocalWorld({
|
|
@@ -58994,7 +59090,7 @@ function getWritable(options = {}) {
|
|
|
58994
59090
|
__name(getWritable, "getWritable");
|
|
58995
59091
|
|
|
58996
59092
|
// ../workflow/dist/stdlib.js
|
|
58997
|
-
var fetch = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//workflow@4.2.0-beta.
|
|
59093
|
+
var fetch = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//workflow@4.2.0-beta.69//fetch");
|
|
58998
59094
|
|
|
58999
59095
|
// ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.js
|
|
59000
59096
|
var NEVER = Object.freeze({
|