@fluidgrids/cli 2026.1116.1 → 2026.1124.2
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/README.md +21 -0
- package/dist/cli.js +540 -136
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -7756,6 +7756,351 @@ var init_deploy = __esm(() => {
|
|
|
7756
7756
|
};
|
|
7757
7757
|
});
|
|
7758
7758
|
|
|
7759
|
+
// src/mcp/bridge.ts
|
|
7760
|
+
function parseMcpTarget(raw, workspaceEndpoint) {
|
|
7761
|
+
let url;
|
|
7762
|
+
try {
|
|
7763
|
+
url = new URL(raw);
|
|
7764
|
+
} catch {
|
|
7765
|
+
throw new McpBridgeConfigError(`Not a URL: ${raw}`);
|
|
7766
|
+
}
|
|
7767
|
+
const match = MCP_PATH.exec(url.pathname);
|
|
7768
|
+
if (!match?.[1] || !match[2]) {
|
|
7769
|
+
throw new McpBridgeConfigError("The URL must be a FluidGrids MCP endpoint: https://<workspace gateway>/mcp/<product>/<workspace id>[/s/<path>]");
|
|
7770
|
+
}
|
|
7771
|
+
const gateway = new URL(workspaceEndpoint);
|
|
7772
|
+
if (url.origin !== gateway.origin) {
|
|
7773
|
+
throw new McpBridgeConfigError(`The URL is not on the workspace gateway ${gateway.origin}; set FLUIDGRIDS_WORKSPACE_ENDPOINT for another environment`);
|
|
7774
|
+
}
|
|
7775
|
+
if (url.protocol !== "https:" && url.hostname !== "localhost" && url.hostname !== "127.0.0.1") {
|
|
7776
|
+
throw new McpBridgeConfigError("The URL must use https");
|
|
7777
|
+
}
|
|
7778
|
+
return {
|
|
7779
|
+
url,
|
|
7780
|
+
productKey: match[1].toLowerCase(),
|
|
7781
|
+
workspaceId: match[2].toLowerCase(),
|
|
7782
|
+
serverPath: match[3]?.toLowerCase() ?? null
|
|
7783
|
+
};
|
|
7784
|
+
}
|
|
7785
|
+
function jwtExpiryMs(token) {
|
|
7786
|
+
const payload = token.split(".")[1];
|
|
7787
|
+
if (!payload)
|
|
7788
|
+
return null;
|
|
7789
|
+
try {
|
|
7790
|
+
const claims = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
|
|
7791
|
+
return typeof claims.exp === "number" && Number.isFinite(claims.exp) ? claims.exp * 1000 : null;
|
|
7792
|
+
} catch {
|
|
7793
|
+
return null;
|
|
7794
|
+
}
|
|
7795
|
+
}
|
|
7796
|
+
async function graphql(fetchImpl, endpoint, query, variables, headers = {}) {
|
|
7797
|
+
const response = await fetchImpl(endpoint, {
|
|
7798
|
+
method: "POST",
|
|
7799
|
+
headers: { "content-type": "application/json", accept: "application/json", ...headers },
|
|
7800
|
+
body: JSON.stringify({ query, variables }),
|
|
7801
|
+
redirect: "error",
|
|
7802
|
+
signal: AbortSignal.timeout(30000)
|
|
7803
|
+
});
|
|
7804
|
+
let body;
|
|
7805
|
+
try {
|
|
7806
|
+
body = await response.json();
|
|
7807
|
+
} catch {
|
|
7808
|
+
throw new Error(`the gateway answered HTTP ${response.status}`);
|
|
7809
|
+
}
|
|
7810
|
+
const message = body.errors?.map((error) => error.message).filter(Boolean)[0];
|
|
7811
|
+
if (message)
|
|
7812
|
+
throw new Error(message);
|
|
7813
|
+
if (!body.data)
|
|
7814
|
+
throw new Error(`the gateway answered HTTP ${response.status} without data`);
|
|
7815
|
+
return body.data;
|
|
7816
|
+
}
|
|
7817
|
+
|
|
7818
|
+
class TokenSource {
|
|
7819
|
+
options;
|
|
7820
|
+
app = null;
|
|
7821
|
+
workspace = null;
|
|
7822
|
+
pending = null;
|
|
7823
|
+
now;
|
|
7824
|
+
constructor(options) {
|
|
7825
|
+
this.options = options;
|
|
7826
|
+
this.now = options.now ?? Date.now;
|
|
7827
|
+
}
|
|
7828
|
+
get() {
|
|
7829
|
+
if (this.fresh(this.app) && this.fresh(this.workspace) && this.app && this.workspace) {
|
|
7830
|
+
return Promise.resolve({ appToken: this.app.value, workspaceToken: this.workspace.value });
|
|
7831
|
+
}
|
|
7832
|
+
this.pending ??= this.renew().finally(() => {
|
|
7833
|
+
this.pending = null;
|
|
7834
|
+
});
|
|
7835
|
+
return this.pending;
|
|
7836
|
+
}
|
|
7837
|
+
invalidate() {
|
|
7838
|
+
this.app = null;
|
|
7839
|
+
this.workspace = null;
|
|
7840
|
+
}
|
|
7841
|
+
fresh(token) {
|
|
7842
|
+
return token !== null && token.expiresAt - RENEW_MARGIN_MS > this.now();
|
|
7843
|
+
}
|
|
7844
|
+
async renew() {
|
|
7845
|
+
const { options } = this;
|
|
7846
|
+
if (!this.fresh(this.app)) {
|
|
7847
|
+
const data = await graphql(options.fetch, options.globalEndpoint, "mutation ($input: APIKeyInput!) { authenticateAPIKey(input: $input) { success token expiresIn } }", { input: { apiKey: options.apiKey, apiSecret: options.apiSecret } }, { ...options.extraHeaders }).catch((error) => {
|
|
7848
|
+
throw new Error(`The API key was not accepted: ${error instanceof Error ? error.message : "unknown error"}`);
|
|
7849
|
+
});
|
|
7850
|
+
const token = data.authenticateAPIKey?.token;
|
|
7851
|
+
if (!data.authenticateAPIKey?.success || !token)
|
|
7852
|
+
throw new Error("The API key was not accepted");
|
|
7853
|
+
const expiresIn = data.authenticateAPIKey.expiresIn;
|
|
7854
|
+
this.app = {
|
|
7855
|
+
value: token,
|
|
7856
|
+
expiresAt: jwtExpiryMs(token) ?? this.now() + (typeof expiresIn === "number" ? expiresIn * 1000 : WORKSPACE_TOKEN_FALLBACK_MS)
|
|
7857
|
+
};
|
|
7858
|
+
this.workspace = null;
|
|
7859
|
+
}
|
|
7860
|
+
const app = this.app;
|
|
7861
|
+
if (!app)
|
|
7862
|
+
throw new Error("The API key was not accepted");
|
|
7863
|
+
if (!this.fresh(this.workspace)) {
|
|
7864
|
+
const input = { workspaceId: options.workspaceId };
|
|
7865
|
+
if (options.organizationId)
|
|
7866
|
+
input.organizationId = options.organizationId;
|
|
7867
|
+
const data = await graphql(options.fetch, options.workspaceEndpoint, "mutation ($input: IssueWorkspaceTokenInput!) { issueWorkspaceToken(input: $input) { token } }", { input }, {
|
|
7868
|
+
...options.extraHeaders,
|
|
7869
|
+
authorization: `Bearer ${app.value}`,
|
|
7870
|
+
...options.productOrigin ? { origin: options.productOrigin } : {}
|
|
7871
|
+
}).catch((error) => {
|
|
7872
|
+
throw new Error(`No workspace token for workspace ${options.workspaceId}: ${error instanceof Error ? error.message : "unknown error"}. ` + "Check that the app is authorised for this workspace.");
|
|
7873
|
+
});
|
|
7874
|
+
const token = data.issueWorkspaceToken?.token;
|
|
7875
|
+
if (!token)
|
|
7876
|
+
throw new Error(`No workspace token for workspace ${options.workspaceId}`);
|
|
7877
|
+
this.workspace = {
|
|
7878
|
+
value: token,
|
|
7879
|
+
expiresAt: jwtExpiryMs(token) ?? this.now() + WORKSPACE_TOKEN_FALLBACK_MS
|
|
7880
|
+
};
|
|
7881
|
+
}
|
|
7882
|
+
const workspace = this.workspace;
|
|
7883
|
+
if (!workspace)
|
|
7884
|
+
throw new Error(`No workspace token for workspace ${options.workspaceId}`);
|
|
7885
|
+
return { appToken: app.value, workspaceToken: workspace.value };
|
|
7886
|
+
}
|
|
7887
|
+
}
|
|
7888
|
+
function rpcError(id, message, code = -32000) {
|
|
7889
|
+
return JSON.stringify({ jsonrpc: "2.0", id, error: { code, message } });
|
|
7890
|
+
}
|
|
7891
|
+
|
|
7892
|
+
class EventStreamParser {
|
|
7893
|
+
buffer = "";
|
|
7894
|
+
push(chunk) {
|
|
7895
|
+
this.buffer += chunk;
|
|
7896
|
+
const events = [];
|
|
7897
|
+
let boundary = /\r?\n\r?\n/.exec(this.buffer);
|
|
7898
|
+
while (boundary) {
|
|
7899
|
+
events.push(this.buffer.slice(0, boundary.index));
|
|
7900
|
+
this.buffer = this.buffer.slice(boundary.index + boundary[0].length);
|
|
7901
|
+
boundary = /\r?\n\r?\n/.exec(this.buffer);
|
|
7902
|
+
}
|
|
7903
|
+
return events.map(eventData).filter((data) => data.trim() !== "");
|
|
7904
|
+
}
|
|
7905
|
+
end() {
|
|
7906
|
+
const rest = eventData(this.buffer);
|
|
7907
|
+
this.buffer = "";
|
|
7908
|
+
return rest.trim() ? [rest] : [];
|
|
7909
|
+
}
|
|
7910
|
+
}
|
|
7911
|
+
function eventData(event) {
|
|
7912
|
+
return event.split(/\r?\n/).filter((line) => line.startsWith("data:")).map((line) => line.slice(5).replace(/^ /, "")).join(`
|
|
7913
|
+
`);
|
|
7914
|
+
}
|
|
7915
|
+
function rpcMessagesOf(text) {
|
|
7916
|
+
let parsed;
|
|
7917
|
+
try {
|
|
7918
|
+
parsed = JSON.parse(text);
|
|
7919
|
+
} catch {
|
|
7920
|
+
return [];
|
|
7921
|
+
}
|
|
7922
|
+
return (Array.isArray(parsed) ? parsed : [parsed]).filter((item) => typeof item === "object" && item !== null && ("jsonrpc" in item) && item.jsonrpc === "2.0");
|
|
7923
|
+
}
|
|
7924
|
+
function errorDetail(text) {
|
|
7925
|
+
let parsed;
|
|
7926
|
+
try {
|
|
7927
|
+
parsed = JSON.parse(text);
|
|
7928
|
+
} catch {
|
|
7929
|
+
return "";
|
|
7930
|
+
}
|
|
7931
|
+
if (typeof parsed !== "object" || parsed === null)
|
|
7932
|
+
return "";
|
|
7933
|
+
const detail = "error" in parsed && typeof parsed.error === "string" ? parsed.error : ("message" in parsed) ? parsed.message : undefined;
|
|
7934
|
+
return typeof detail === "string" && detail.trim() ? `: ${detail.trim().slice(0, 300)}` : "";
|
|
7935
|
+
}
|
|
7936
|
+
|
|
7937
|
+
class McpBridge {
|
|
7938
|
+
options;
|
|
7939
|
+
protocolVersion = null;
|
|
7940
|
+
sessionId = null;
|
|
7941
|
+
inFlight = new Set;
|
|
7942
|
+
constructor(options) {
|
|
7943
|
+
this.options = options;
|
|
7944
|
+
}
|
|
7945
|
+
accept(line) {
|
|
7946
|
+
const text = line.trim();
|
|
7947
|
+
if (!text)
|
|
7948
|
+
return;
|
|
7949
|
+
const task = this.handle(text).catch((error) => {
|
|
7950
|
+
this.options.log(`mcp connect: ${error instanceof Error ? error.message : "unexpected error"}`);
|
|
7951
|
+
});
|
|
7952
|
+
this.inFlight.add(task);
|
|
7953
|
+
task.finally(() => this.inFlight.delete(task));
|
|
7954
|
+
}
|
|
7955
|
+
async drain() {
|
|
7956
|
+
while (this.inFlight.size > 0)
|
|
7957
|
+
await Promise.all([...this.inFlight]);
|
|
7958
|
+
}
|
|
7959
|
+
async handle(text) {
|
|
7960
|
+
let message;
|
|
7961
|
+
try {
|
|
7962
|
+
message = JSON.parse(text);
|
|
7963
|
+
} catch {
|
|
7964
|
+
this.options.send(rpcError(null, "Parse error", -32700));
|
|
7965
|
+
return;
|
|
7966
|
+
}
|
|
7967
|
+
const id = message.id ?? null;
|
|
7968
|
+
const isRequest = typeof message.method === "string" && message.id !== undefined && message.id !== null;
|
|
7969
|
+
let response;
|
|
7970
|
+
try {
|
|
7971
|
+
response = await this.post(text, false);
|
|
7972
|
+
if (response.status === 401) {
|
|
7973
|
+
this.options.tokens.invalidate();
|
|
7974
|
+
response = await this.post(text, true);
|
|
7975
|
+
}
|
|
7976
|
+
} catch (error) {
|
|
7977
|
+
if (isRequest)
|
|
7978
|
+
this.options.send(rpcError(id, error instanceof Error ? error.message : "Request failed"));
|
|
7979
|
+
return;
|
|
7980
|
+
}
|
|
7981
|
+
const session = response.headers.get("mcp-session-id");
|
|
7982
|
+
if (session)
|
|
7983
|
+
this.sessionId = session;
|
|
7984
|
+
let sent = 0;
|
|
7985
|
+
const dispatch = (data) => {
|
|
7986
|
+
for (const out of rpcMessagesOf(data)) {
|
|
7987
|
+
if (isRequest && out.id === null && out.error !== undefined)
|
|
7988
|
+
out.id = id;
|
|
7989
|
+
this.rememberProtocolVersion(message, out);
|
|
7990
|
+
this.options.send(JSON.stringify(out));
|
|
7991
|
+
sent += 1;
|
|
7992
|
+
}
|
|
7993
|
+
};
|
|
7994
|
+
let detail = "";
|
|
7995
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
7996
|
+
try {
|
|
7997
|
+
if (contentType.includes("text/event-stream") && response.body) {
|
|
7998
|
+
const parser = new EventStreamParser;
|
|
7999
|
+
const decoder = new TextDecoder;
|
|
8000
|
+
for await (const chunk of response.body) {
|
|
8001
|
+
for (const data of parser.push(decoder.decode(chunk, { stream: true })))
|
|
8002
|
+
dispatch(data);
|
|
8003
|
+
}
|
|
8004
|
+
for (const data of parser.push(decoder.decode()))
|
|
8005
|
+
dispatch(data);
|
|
8006
|
+
for (const data of parser.end())
|
|
8007
|
+
dispatch(data);
|
|
8008
|
+
} else {
|
|
8009
|
+
const body = await response.text();
|
|
8010
|
+
if (body.trim())
|
|
8011
|
+
dispatch(body);
|
|
8012
|
+
if (sent === 0)
|
|
8013
|
+
detail = errorDetail(body);
|
|
8014
|
+
}
|
|
8015
|
+
} catch (error) {
|
|
8016
|
+
if (sent === 0 && isRequest) {
|
|
8017
|
+
this.options.send(rpcError(id, `The MCP endpoint's answer was cut off: ${error instanceof Error ? error.message : "read failed"}`));
|
|
8018
|
+
}
|
|
8019
|
+
return;
|
|
8020
|
+
}
|
|
8021
|
+
if (sent === 0 && response.status >= 400 && isRequest) {
|
|
8022
|
+
this.options.send(rpcError(id, `The MCP endpoint answered HTTP ${response.status}${detail}`));
|
|
8023
|
+
}
|
|
8024
|
+
}
|
|
8025
|
+
async post(body, retried) {
|
|
8026
|
+
const tokens = await this.options.tokens.get();
|
|
8027
|
+
const headers = {
|
|
8028
|
+
...this.options.extraHeaders,
|
|
8029
|
+
"content-type": "application/json",
|
|
8030
|
+
accept: "application/json, text/event-stream",
|
|
8031
|
+
authorization: `Bearer ${tokens.appToken}`,
|
|
8032
|
+
"x-workspace-authorization": `Bearer ${tokens.workspaceToken}`
|
|
8033
|
+
};
|
|
8034
|
+
if (this.protocolVersion)
|
|
8035
|
+
headers["mcp-protocol-version"] = this.protocolVersion;
|
|
8036
|
+
if (this.sessionId)
|
|
8037
|
+
headers["mcp-session-id"] = this.sessionId;
|
|
8038
|
+
const response = await this.options.fetch(this.options.target.url.toString(), {
|
|
8039
|
+
method: "POST",
|
|
8040
|
+
headers,
|
|
8041
|
+
body,
|
|
8042
|
+
redirect: "error",
|
|
8043
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS2)
|
|
8044
|
+
});
|
|
8045
|
+
if (retried && response.status === 401) {
|
|
8046
|
+
this.options.log("mcp connect: the endpoint refused fresh tokens (HTTP 401); check the API key and its scopes");
|
|
8047
|
+
}
|
|
8048
|
+
return response;
|
|
8049
|
+
}
|
|
8050
|
+
rememberProtocolVersion(request, out) {
|
|
8051
|
+
if (request.method !== "initialize")
|
|
8052
|
+
return;
|
|
8053
|
+
const result = out.result;
|
|
8054
|
+
if (typeof result === "object" && result !== null && "protocolVersion" in result && typeof result.protocolVersion === "string") {
|
|
8055
|
+
this.protocolVersion = result.protocolVersion;
|
|
8056
|
+
}
|
|
8057
|
+
}
|
|
8058
|
+
}
|
|
8059
|
+
async function runMcpConnect(options, io) {
|
|
8060
|
+
const apiKey = io.env[API_KEY_ENV]?.trim();
|
|
8061
|
+
const apiSecret = io.env[API_SECRET_ENV]?.trim();
|
|
8062
|
+
if (!apiKey || !apiSecret) {
|
|
8063
|
+
throw new McpBridgeConfigError(`Set ${API_KEY_ENV} and ${API_SECRET_ENV} to the API key and secret of an app authorised for the workspace`);
|
|
8064
|
+
}
|
|
8065
|
+
const cfId = io.env[CF_ACCESS_ID_ENV]?.trim();
|
|
8066
|
+
const cfSecret = io.env[CF_ACCESS_SECRET_ENV]?.trim();
|
|
8067
|
+
if (!cfId !== !cfSecret) {
|
|
8068
|
+
throw new McpBridgeConfigError(`Set both ${CF_ACCESS_ID_ENV} and ${CF_ACCESS_SECRET_ENV}, or neither`);
|
|
8069
|
+
}
|
|
8070
|
+
const extraHeaders = cfId && cfSecret ? { "cf-access-client-id": cfId, "cf-access-client-secret": cfSecret } : {};
|
|
8071
|
+
const target = parseMcpTarget(options.url, options.workspaceEndpoint);
|
|
8072
|
+
const tokens = new TokenSource({
|
|
8073
|
+
apiKey,
|
|
8074
|
+
apiSecret,
|
|
8075
|
+
workspaceId: target.workspaceId,
|
|
8076
|
+
...options.organizationId ? { organizationId: options.organizationId } : {},
|
|
8077
|
+
globalEndpoint: options.globalEndpoint,
|
|
8078
|
+
workspaceEndpoint: options.workspaceEndpoint,
|
|
8079
|
+
...options.productOrigin ? { productOrigin: options.productOrigin } : {},
|
|
8080
|
+
extraHeaders,
|
|
8081
|
+
fetch: io.fetch
|
|
8082
|
+
});
|
|
8083
|
+
const bridge = new McpBridge({
|
|
8084
|
+
target,
|
|
8085
|
+
tokens,
|
|
8086
|
+
fetch: io.fetch,
|
|
8087
|
+
send: io.send,
|
|
8088
|
+
log: io.log,
|
|
8089
|
+
extraHeaders
|
|
8090
|
+
});
|
|
8091
|
+
io.log(`mcp connect: relaying to ${target.url.origin}${target.url.pathname}` + (target.serverPath ? ` (MCP Server Trigger "${target.serverPath}")` : " (published tool set)"));
|
|
8092
|
+
for await (const line of io.lines)
|
|
8093
|
+
bridge.accept(line);
|
|
8094
|
+
await bridge.drain();
|
|
8095
|
+
}
|
|
8096
|
+
var MCP_PATH, RENEW_MARGIN_MS = 60000, WORKSPACE_TOKEN_FALLBACK_MS, REQUEST_TIMEOUT_MS2 = 90000, API_KEY_ENV = "FLUIDGRIDS_MCP_API_KEY", API_SECRET_ENV = "FLUIDGRIDS_MCP_API_SECRET", CF_ACCESS_ID_ENV = "FLUIDGRIDS_CF_ACCESS_CLIENT_ID", CF_ACCESS_SECRET_ENV = "FLUIDGRIDS_CF_ACCESS_CLIENT_SECRET", McpBridgeConfigError;
|
|
8097
|
+
var init_bridge = __esm(() => {
|
|
8098
|
+
MCP_PATH = /^\/mcp\/([a-z][a-z0-9-]{1,63})\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:\/s\/([a-z0-9][a-z0-9-]{2,63})(?:\/test)?)?\/?$/i;
|
|
8099
|
+
WORKSPACE_TOKEN_FALLBACK_MS = 15 * 60000;
|
|
8100
|
+
McpBridgeConfigError = class McpBridgeConfigError extends Error {
|
|
8101
|
+
};
|
|
8102
|
+
});
|
|
8103
|
+
|
|
7759
8104
|
// src/phase-c/operations.ts
|
|
7760
8105
|
function hierarchyChildren(depth) {
|
|
7761
8106
|
if (depth === 0)
|
|
@@ -8260,7 +8605,7 @@ var init_operations3 = __esm(() => {
|
|
|
8260
8605
|
});
|
|
8261
8606
|
|
|
8262
8607
|
// src/phase-c/api.ts
|
|
8263
|
-
import { CliAuthError as CliAuthError6, CliUserError as
|
|
8608
|
+
import { CliAuthError as CliAuthError6, CliUserError as CliUserError40 } from "@burdenoff/cli-sdk/core";
|
|
8264
8609
|
function runVariables(run) {
|
|
8265
8610
|
return run.runId !== undefined ? { runId: run.runId } : { target: run.target };
|
|
8266
8611
|
}
|
|
@@ -8280,7 +8625,7 @@ function createPhaseCApi(ctx) {
|
|
|
8280
8625
|
function context() {
|
|
8281
8626
|
const workspaceId = ctx.auth.read()?.workspaceId;
|
|
8282
8627
|
if (!workspaceId) {
|
|
8283
|
-
throw new
|
|
8628
|
+
throw new CliUserError40("No workspace is selected.", {
|
|
8284
8629
|
hint: `Run \`${ctx.productName} workspace set <id>\` or set FLUIDGRIDS_WORKSPACE_ID.`
|
|
8285
8630
|
});
|
|
8286
8631
|
}
|
|
@@ -8413,7 +8758,7 @@ function createPhaseCApi(ctx) {
|
|
|
8413
8758
|
});
|
|
8414
8759
|
const found = data.workflowRunByWorkflowId;
|
|
8415
8760
|
if (!found) {
|
|
8416
|
-
throw new
|
|
8761
|
+
throw new CliUserError40(`No run with workflow id ${run.target.workflowId} of ${run.target.workflowKey} (NOT_FOUND)`);
|
|
8417
8762
|
}
|
|
8418
8763
|
return found.id;
|
|
8419
8764
|
},
|
|
@@ -8548,7 +8893,7 @@ function createPhaseCApi(ctx) {
|
|
|
8548
8893
|
if (!pagination?.hasMore || jobs.length === 0)
|
|
8549
8894
|
return all;
|
|
8550
8895
|
}
|
|
8551
|
-
throw new
|
|
8896
|
+
throw new CliUserError40(`The schedule listing did not end after ${MAX_SCHEDULE_PAGES} pages; refusing to continue.`);
|
|
8552
8897
|
},
|
|
8553
8898
|
async describeSchedule(workflowKey, triggerNodeId) {
|
|
8554
8899
|
const data = await request(PC_SCHEDULE_DESCRIBE, { workflowKey, triggerNodeId }, P);
|
|
@@ -8582,17 +8927,17 @@ var init_api3 = __esm(() => {
|
|
|
8582
8927
|
});
|
|
8583
8928
|
|
|
8584
8929
|
// src/phase-c/commands/queues.ts
|
|
8585
|
-
import { CliUserError as
|
|
8930
|
+
import { CliUserError as CliUserError41 } from "@burdenoff/cli-sdk/core";
|
|
8586
8931
|
function parseEnvironment2(raw) {
|
|
8587
8932
|
return parseEnumOption(raw, "--environment", ENVIRONMENTS3);
|
|
8588
8933
|
}
|
|
8589
8934
|
function checkQueueName(name) {
|
|
8590
8935
|
const value = name.trim();
|
|
8591
8936
|
if (value === "managed") {
|
|
8592
|
-
throw new
|
|
8937
|
+
throw new CliUserError41("`managed` is the platform queue; it cannot be created or changed.");
|
|
8593
8938
|
}
|
|
8594
8939
|
if (!QUEUE_NAME.test(value)) {
|
|
8595
|
-
throw new
|
|
8940
|
+
throw new CliUserError41(`Invalid queue name '${name}': lower-case letters, digits and dashes, at most 63, starting with a letter or digit.`);
|
|
8596
8941
|
}
|
|
8597
8942
|
return value;
|
|
8598
8943
|
}
|
|
@@ -8604,7 +8949,7 @@ function checkWorkerQueue(raw) {
|
|
|
8604
8949
|
const name = checkQueueName(value.slice(0, at));
|
|
8605
8950
|
const environment = value.slice(at + 1).toLowerCase();
|
|
8606
8951
|
if (!ENVIRONMENTS3.some((allowed) => allowed.toLowerCase() === environment)) {
|
|
8607
|
-
throw new
|
|
8952
|
+
throw new CliUserError41(`Invalid queue '${raw}': the environment after @ must be dev, staging or prod.`);
|
|
8608
8953
|
}
|
|
8609
8954
|
return `${name}@${environment}`;
|
|
8610
8955
|
}
|
|
@@ -8617,7 +8962,7 @@ function bindWorkerQueues(queues, raw) {
|
|
|
8617
8962
|
if (at < 0)
|
|
8618
8963
|
return `${queue}@${environment}`;
|
|
8619
8964
|
if (queue.slice(at + 1) !== environment) {
|
|
8620
|
-
throw new
|
|
8965
|
+
throw new CliUserError41(`Queue '${queue}' is bound to ${queue.slice(at + 1)}, but --environment is ${environment}.`);
|
|
8621
8966
|
}
|
|
8622
8967
|
return queue;
|
|
8623
8968
|
});
|
|
@@ -8633,11 +8978,11 @@ async function findQueue(env, name, environment) {
|
|
|
8633
8978
|
if (found)
|
|
8634
8979
|
return found;
|
|
8635
8980
|
if (environment === undefined && rows.length > 0) {
|
|
8636
|
-
throw new
|
|
8981
|
+
throw new CliUserError41(`Queue ${name} has only environment-scoped rows.`, {
|
|
8637
8982
|
hint: `Pass --environment (one of ${rows.map((queue) => queue.environment ?? "-").join(", ")}).`
|
|
8638
8983
|
});
|
|
8639
8984
|
}
|
|
8640
|
-
throw new
|
|
8985
|
+
throw new CliUserError41(`The workspace has no task queue ${environment ? `${name}@${environment}` : name}.`, { hint: "List them with `fluidgrids queues list`." });
|
|
8641
8986
|
}
|
|
8642
8987
|
async function runQueuesList(env, options) {
|
|
8643
8988
|
const queues = await env.pc.taskQueues();
|
|
@@ -8698,7 +9043,7 @@ async function runQueuesUpdate(env, name, options) {
|
|
|
8698
9043
|
const environment = parseEnvironment2(options.environment);
|
|
8699
9044
|
const maxTasksPerSecond = parseNumberOption(options.maxTasksPerSecond, "--max-tasks-per-second");
|
|
8700
9045
|
if (maxTasksPerSecond !== undefined && options.clearMaxTasksPerSecond) {
|
|
8701
|
-
throw new
|
|
9046
|
+
throw new CliUserError41("Give --max-tasks-per-second or --clear-max-tasks-per-second, not both.");
|
|
8702
9047
|
}
|
|
8703
9048
|
const timeout = parseNonNegativeInt(options.workerUnavailableTimeout, "--worker-unavailable-timeout");
|
|
8704
9049
|
const input = {
|
|
@@ -8708,7 +9053,7 @@ async function runQueuesUpdate(env, name, options) {
|
|
|
8708
9053
|
...timeout !== undefined ? { workerUnavailableTimeoutSeconds: timeout } : {}
|
|
8709
9054
|
};
|
|
8710
9055
|
if (Object.keys(input).length === 0) {
|
|
8711
|
-
throw new
|
|
9056
|
+
throw new CliUserError41("Nothing to change.", {
|
|
8712
9057
|
hint: "Give --description, --max-tasks-per-second, --clear-max-tasks-per-second or --worker-unavailable-timeout."
|
|
8713
9058
|
});
|
|
8714
9059
|
}
|
|
@@ -8787,7 +9132,7 @@ import { existsSync as existsSync14 } from "fs";
|
|
|
8787
9132
|
import { hostname } from "os";
|
|
8788
9133
|
import { extname as extname3, isAbsolute as isAbsolute3, join as join12, resolve as resolve11 } from "path";
|
|
8789
9134
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
8790
|
-
import { CliUserError as
|
|
9135
|
+
import { CliUserError as CliUserError42 } from "@burdenoff/cli-sdk/core";
|
|
8791
9136
|
function isRecord19(value) {
|
|
8792
9137
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8793
9138
|
}
|
|
@@ -8798,11 +9143,11 @@ function bridgeUrlFor(env, explicit, issued) {
|
|
|
8798
9143
|
try {
|
|
8799
9144
|
url = new URL(raw);
|
|
8800
9145
|
} catch {
|
|
8801
|
-
throw new
|
|
9146
|
+
throw new CliUserError42(`Invalid bridge URL '${raw}'.`);
|
|
8802
9147
|
}
|
|
8803
9148
|
const local = url.hostname === "localhost" || url.hostname === "127.0.0.1";
|
|
8804
9149
|
if (url.protocol !== "wss:" && !(url.protocol === "ws:" && local)) {
|
|
8805
|
-
throw new
|
|
9150
|
+
throw new CliUserError42(`The bridge URL must be wss:// (ws:// only to this machine): ${raw}`);
|
|
8806
9151
|
}
|
|
8807
9152
|
return url.toString();
|
|
8808
9153
|
}
|
|
@@ -8818,18 +9163,18 @@ function bridgeHeaders(env) {
|
|
|
8818
9163
|
const id = env.getEnv("FLUIDGRIDS_CF_ACCESS_CLIENT_ID")?.trim();
|
|
8819
9164
|
const secret = env.getEnv("FLUIDGRIDS_CF_ACCESS_CLIENT_SECRET")?.trim();
|
|
8820
9165
|
if ((id === undefined || id === "") !== (secret === undefined || secret === "")) {
|
|
8821
|
-
throw new
|
|
9166
|
+
throw new CliUserError42("Set both FLUIDGRIDS_CF_ACCESS_CLIENT_ID and FLUIDGRIDS_CF_ACCESS_CLIENT_SECRET, or neither.");
|
|
8822
9167
|
}
|
|
8823
9168
|
return id && secret ? { "CF-Access-Client-Id": id, "CF-Access-Client-Secret": secret } : {};
|
|
8824
9169
|
}
|
|
8825
9170
|
function workerToken(env, tokenEnv) {
|
|
8826
9171
|
const variable = tokenEnv?.trim() || WORKER_TOKEN_ENV;
|
|
8827
9172
|
if (!ENV_NAME2.test(variable)) {
|
|
8828
|
-
throw new
|
|
9173
|
+
throw new CliUserError42("Invalid environment variable name for --token-env.");
|
|
8829
9174
|
}
|
|
8830
9175
|
const token = env.getEnv(variable)?.trim() ?? "";
|
|
8831
9176
|
if (!WORKER_TOKEN.test(token)) {
|
|
8832
|
-
throw new
|
|
9177
|
+
throw new CliUserError42(`${variable} must hold a worker token (fgr_ and 43 characters).`, {
|
|
8833
9178
|
hint: "Issue one with `fluidgrids workers tokens create <name> --queue <queue>`."
|
|
8834
9179
|
});
|
|
8835
9180
|
}
|
|
@@ -8842,7 +9187,7 @@ async function buildWorkerBundle(project) {
|
|
|
8842
9187
|
explainUnresolved: (names) => [...names]
|
|
8843
9188
|
});
|
|
8844
9189
|
if (!lowered.workflows.some((workflow) => workflow.durable)) {
|
|
8845
|
-
throw new
|
|
9190
|
+
throw new CliUserError42("The project defines no durable functions for a worker to serve.");
|
|
8846
9191
|
}
|
|
8847
9192
|
await prepareProjectBundle(project, lowered);
|
|
8848
9193
|
return bundlePathOf(project);
|
|
@@ -8856,23 +9201,23 @@ function activitiesFor(project, raw) {
|
|
|
8856
9201
|
return;
|
|
8857
9202
|
const value = raw.trim();
|
|
8858
9203
|
if (value === "")
|
|
8859
|
-
throw new
|
|
9204
|
+
throw new CliUserError42("--activities cannot be empty.");
|
|
8860
9205
|
if (project.config.language === "py") {
|
|
8861
9206
|
if (!/^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$/.test(value)) {
|
|
8862
|
-
throw new
|
|
9207
|
+
throw new CliUserError42(`--activities for a Python project is a module name importable from the project (for example activities), not '${raw}'.`);
|
|
8863
9208
|
}
|
|
8864
9209
|
return value;
|
|
8865
9210
|
}
|
|
8866
9211
|
const path = isAbsolute3(value) ? value : resolve11(project.root, value);
|
|
8867
9212
|
if (!existsSync14(path))
|
|
8868
|
-
throw new
|
|
9213
|
+
throw new CliUserError42(`--activities: ${raw} not found.`);
|
|
8869
9214
|
return path;
|
|
8870
9215
|
}
|
|
8871
9216
|
function launchOf(settings) {
|
|
8872
9217
|
const { project, options } = settings;
|
|
8873
9218
|
const activities = activitiesFor(project, options.activities);
|
|
8874
9219
|
if (!settings.bundlePath && !activities) {
|
|
8875
|
-
throw new
|
|
9220
|
+
throw new CliUserError42("The worker would serve nothing: give workflows, --activities or both.");
|
|
8876
9221
|
}
|
|
8877
9222
|
const maxActivities = parsePositiveInt(options.maxConcurrentActivities, "--max-concurrent-activities");
|
|
8878
9223
|
const maxWorkflowTasks = parsePositiveInt(options.maxConcurrentWorkflowTasks, "--max-concurrent-workflow-tasks");
|
|
@@ -8905,7 +9250,7 @@ async function workflowBundle(project, options, build) {
|
|
|
8905
9250
|
if (!existsSync14(path)) {
|
|
8906
9251
|
if (options.activities !== undefined)
|
|
8907
9252
|
return;
|
|
8908
|
-
throw new
|
|
9253
|
+
throw new CliUserError42(`No workflow bundle at ${path}.`, {
|
|
8909
9254
|
hint: "Run `fluidgrids push` first, or pass --build to build it now (or --no-workflows)."
|
|
8910
9255
|
});
|
|
8911
9256
|
}
|
|
@@ -8914,7 +9259,7 @@ async function workflowBundle(project, options, build) {
|
|
|
8914
9259
|
async function runWorkerRun(env, options) {
|
|
8915
9260
|
const queues = bindWorkerQueues(parseList(options.queue).map(checkWorkerQueue), options.environment);
|
|
8916
9261
|
if (queues.length === 0)
|
|
8917
|
-
throw new
|
|
9262
|
+
throw new CliUserError42("Name the task queue(s) to serve with --queue.");
|
|
8918
9263
|
const project = loadProject(options.project, env.cwd());
|
|
8919
9264
|
const token = workerToken(env, options.tokenEnv);
|
|
8920
9265
|
const launch = launchOf({
|
|
@@ -8937,7 +9282,7 @@ function devQueueName() {
|
|
|
8937
9282
|
async function runDev(env, options) {
|
|
8938
9283
|
const project = loadProject(options.project, env.cwd());
|
|
8939
9284
|
if (options.lang !== undefined && options.lang !== project.config.language) {
|
|
8940
|
-
throw new
|
|
9285
|
+
throw new CliUserError42(`--lang ${options.lang} does not match the project language (${project.config.language}).`, { hint: "Run `fluidgrids dev` in a project of that language (`fluidgrids init --lang …`)." });
|
|
8941
9286
|
}
|
|
8942
9287
|
const bundlePath = await workflowBundle(project, options, options.workflows !== false);
|
|
8943
9288
|
const queueName = devQueueName();
|
|
@@ -9040,7 +9385,7 @@ async function loadTypeScriptActivities(root, path) {
|
|
|
9040
9385
|
}
|
|
9041
9386
|
}
|
|
9042
9387
|
if (found.length === 0) {
|
|
9043
|
-
throw new
|
|
9388
|
+
throw new CliUserError42(`${path} exports no activity implementations.`, {
|
|
9044
9389
|
hint: "Export `implementActivity(...)` or `defineActivity(...)` values from it."
|
|
9045
9390
|
});
|
|
9046
9391
|
}
|
|
@@ -9066,21 +9411,21 @@ async function runTypeScriptWorker(launch) {
|
|
|
9066
9411
|
}
|
|
9067
9412
|
function pythonWorkerExitError(python, code, signal) {
|
|
9068
9413
|
if (signal)
|
|
9069
|
-
return new
|
|
9414
|
+
return new CliUserError42(`The Python worker was stopped by ${signal}.`);
|
|
9070
9415
|
const status = String(code);
|
|
9071
9416
|
switch (code) {
|
|
9072
9417
|
case PYTHON_EXIT_NO_WORKER:
|
|
9073
|
-
return new
|
|
9418
|
+
return new CliUserError42(`The Python worker could not import fluidgrids_workflows.worker (status ${status}).`, {
|
|
9074
9419
|
hint: `Install the worker extra: \`${python} -m pip install 'fluidgrids-workflows[worker]'\`.`
|
|
9075
9420
|
});
|
|
9076
9421
|
case PYTHON_EXIT_NO_ACTIVITIES:
|
|
9077
|
-
return new
|
|
9422
|
+
return new CliUserError42(`The Python worker exited with status ${status}: the activities module defines no activities.`, {
|
|
9078
9423
|
hint: "Decorate the activities with @define_activity in the module --activities names, or pass the module that defines them."
|
|
9079
9424
|
});
|
|
9080
9425
|
case PYTHON_EXIT_BRIDGE_CLOSED:
|
|
9081
|
-
return new
|
|
9426
|
+
return new CliUserError42(`The Python worker exited with status ${status}: the worker bridge closed the connection (the close code and its meaning are above).`);
|
|
9082
9427
|
default:
|
|
9083
|
-
return new
|
|
9428
|
+
return new CliUserError42(`The Python worker exited with status ${status}.`);
|
|
9084
9429
|
}
|
|
9085
9430
|
}
|
|
9086
9431
|
function pythonWorkerSpec(launch) {
|
|
@@ -9124,7 +9469,7 @@ function runPythonWorker(launch) {
|
|
|
9124
9469
|
};
|
|
9125
9470
|
child.on("error", (error) => {
|
|
9126
9471
|
done();
|
|
9127
|
-
reject(error.code === "ENOENT" ? new
|
|
9472
|
+
reject(error.code === "ENOENT" ? new CliUserError42(`Python interpreter "${python}" was not found.`) : new CliUserError42(`Could not start ${python}: ${error.message}`));
|
|
9128
9473
|
});
|
|
9129
9474
|
child.on("close", (code, signal) => {
|
|
9130
9475
|
done();
|
|
@@ -9206,7 +9551,7 @@ except BridgeClosedError as error:
|
|
|
9206
9551
|
});
|
|
9207
9552
|
|
|
9208
9553
|
// src/phase-c/shared.ts
|
|
9209
|
-
import { CliUserError as
|
|
9554
|
+
import { CliUserError as CliUserError43 } from "@burdenoff/cli-sdk/core";
|
|
9210
9555
|
function phaseCEnv(env) {
|
|
9211
9556
|
return {
|
|
9212
9557
|
...env,
|
|
@@ -9219,32 +9564,32 @@ async function requireConfirmation(env, question, force) {
|
|
|
9219
9564
|
if (force)
|
|
9220
9565
|
return;
|
|
9221
9566
|
if (!env.interactive()) {
|
|
9222
|
-
throw new
|
|
9567
|
+
throw new CliUserError43(`${question} needs confirmation.`, {
|
|
9223
9568
|
hint: "Pass --force to go ahead without a prompt."
|
|
9224
9569
|
});
|
|
9225
9570
|
}
|
|
9226
9571
|
if (!await env.confirm(question))
|
|
9227
|
-
throw new
|
|
9572
|
+
throw new CliUserError43("Aborted: nothing was changed.");
|
|
9228
9573
|
}
|
|
9229
9574
|
function runSelectorOf(runId, flags) {
|
|
9230
9575
|
const targeted = flags.workflowId !== undefined || flags.key !== undefined || flags.firstRunId !== undefined;
|
|
9231
9576
|
if (!targeted) {
|
|
9232
9577
|
if (runId === undefined || runId.trim() === "") {
|
|
9233
|
-
throw new
|
|
9578
|
+
throw new CliUserError43("Give a run id, or --workflow-id with --key.");
|
|
9234
9579
|
}
|
|
9235
9580
|
return { runId: runId.trim() };
|
|
9236
9581
|
}
|
|
9237
9582
|
if (runId !== undefined) {
|
|
9238
|
-
throw new
|
|
9583
|
+
throw new CliUserError43("Give a run id or --workflow-id with --key, not both.");
|
|
9239
9584
|
}
|
|
9240
9585
|
const workflowId = flags.workflowId?.trim() ?? "";
|
|
9241
9586
|
const key = flags.key?.trim() ?? "";
|
|
9242
9587
|
if (workflowId === "" || key === "") {
|
|
9243
|
-
throw new
|
|
9588
|
+
throw new CliUserError43("--workflow-id and --key go together (the workflow id of that key).");
|
|
9244
9589
|
}
|
|
9245
9590
|
const firstRunId = flags.firstRunId?.trim();
|
|
9246
9591
|
if (flags.firstRunId !== undefined && !firstRunId) {
|
|
9247
|
-
throw new
|
|
9592
|
+
throw new CliUserError43("--first-run-id cannot be empty.");
|
|
9248
9593
|
}
|
|
9249
9594
|
return {
|
|
9250
9595
|
target: { workflowKey: key, workflowId, ...firstRunId ? { firstRunId } : {} }
|
|
@@ -9260,7 +9605,7 @@ function parseEnumOption(raw, flag, allowed) {
|
|
|
9260
9605
|
const match = allowed.find((value) => value === normal);
|
|
9261
9606
|
if (match === undefined) {
|
|
9262
9607
|
const shown = allowed.map((value) => value.toLowerCase().replace(/_/g, "-"));
|
|
9263
|
-
throw new
|
|
9608
|
+
throw new CliUserError43(`Invalid value '${raw}' for ${flag}. Allowed: ${shown.join(", ")}`);
|
|
9264
9609
|
}
|
|
9265
9610
|
return match;
|
|
9266
9611
|
}
|
|
@@ -9269,7 +9614,7 @@ function parseNonNegativeInt(raw, flag) {
|
|
|
9269
9614
|
return;
|
|
9270
9615
|
const value = raw.trim();
|
|
9271
9616
|
if (!/^\d+$/.test(value) || !Number.isSafeInteger(Number(value))) {
|
|
9272
|
-
throw new
|
|
9617
|
+
throw new CliUserError43(`Invalid value '${raw}' for ${flag}: expected a whole number.`);
|
|
9273
9618
|
}
|
|
9274
9619
|
return Number(value);
|
|
9275
9620
|
}
|
|
@@ -9278,14 +9623,14 @@ function parseNumberOption(raw, flag) {
|
|
|
9278
9623
|
return;
|
|
9279
9624
|
const value = Number(raw.trim());
|
|
9280
9625
|
if (raw.trim() === "" || !Number.isFinite(value)) {
|
|
9281
|
-
throw new
|
|
9626
|
+
throw new CliUserError43(`Invalid value '${raw}' for ${flag}: expected a number.`);
|
|
9282
9627
|
}
|
|
9283
9628
|
return value;
|
|
9284
9629
|
}
|
|
9285
9630
|
function requireText(raw, flag) {
|
|
9286
9631
|
const value = raw?.trim() ?? "";
|
|
9287
9632
|
if (value === "")
|
|
9288
|
-
throw new
|
|
9633
|
+
throw new CliUserError43(`${flag} is required.`);
|
|
9289
9634
|
return value;
|
|
9290
9635
|
}
|
|
9291
9636
|
function parseList(raw) {
|
|
@@ -9315,7 +9660,7 @@ function parseInstant(raw, flag) {
|
|
|
9315
9660
|
const value = raw.trim();
|
|
9316
9661
|
const ms = Date.parse(value);
|
|
9317
9662
|
if (value === "" || !Number.isFinite(ms) || !/^\d{4}-\d{2}-\d{2}/.test(value)) {
|
|
9318
|
-
throw new
|
|
9663
|
+
throw new CliUserError43(`Invalid value '${raw}' for ${flag}: expected an ISO-8601 date and time such as 2026-10-01T00:00:00Z.`);
|
|
9319
9664
|
}
|
|
9320
9665
|
return new Date(ms).toISOString();
|
|
9321
9666
|
}
|
|
@@ -9325,7 +9670,7 @@ var init_shared3 = __esm(() => {
|
|
|
9325
9670
|
});
|
|
9326
9671
|
|
|
9327
9672
|
// src/config/commands.ts
|
|
9328
|
-
import { CliUserError as
|
|
9673
|
+
import { CliUserError as CliUserError44 } from "@burdenoff/cli-sdk/core";
|
|
9329
9674
|
function output(env, options, data, rows, headers) {
|
|
9330
9675
|
env.ctx.output.formatAndOutput(options, data, { headers, rows });
|
|
9331
9676
|
}
|
|
@@ -9341,7 +9686,7 @@ function isLocal(url) {
|
|
|
9341
9686
|
function checkProfileValue(key, value, profile) {
|
|
9342
9687
|
const trimmed = value.trim();
|
|
9343
9688
|
if (trimmed === "" || trimmed.length > 2048) {
|
|
9344
|
-
throw new
|
|
9689
|
+
throw new CliUserError44(`${key} must be 1 to 2048 characters.`);
|
|
9345
9690
|
}
|
|
9346
9691
|
switch (key) {
|
|
9347
9692
|
case "apiUrl":
|
|
@@ -9350,20 +9695,20 @@ function checkProfileValue(key, value, profile) {
|
|
|
9350
9695
|
try {
|
|
9351
9696
|
url = new URL(trimmed);
|
|
9352
9697
|
} catch {
|
|
9353
|
-
throw new
|
|
9698
|
+
throw new CliUserError44(`${key} must be a URL.`);
|
|
9354
9699
|
}
|
|
9355
9700
|
if (url.protocol !== "https:" && !(url.protocol === "http:" && isLocal(url))) {
|
|
9356
|
-
throw new
|
|
9701
|
+
throw new CliUserError44(`${key} must use https (http only for localhost).`);
|
|
9357
9702
|
}
|
|
9358
9703
|
if (url.username || url.password) {
|
|
9359
|
-
throw new
|
|
9704
|
+
throw new CliUserError44(`${key} must not carry credentials.`);
|
|
9360
9705
|
}
|
|
9361
9706
|
return trimmed;
|
|
9362
9707
|
}
|
|
9363
9708
|
case "environment": {
|
|
9364
9709
|
const upper = trimmed.toUpperCase();
|
|
9365
9710
|
if (!ENVIRONMENTS4.includes(upper)) {
|
|
9366
|
-
throw new
|
|
9711
|
+
throw new CliUserError44(`environment must be one of ${ENVIRONMENTS4.join(", ")}.`);
|
|
9367
9712
|
}
|
|
9368
9713
|
return upper;
|
|
9369
9714
|
}
|
|
@@ -9377,15 +9722,15 @@ function checkProfileValue(key, value, profile) {
|
|
|
9377
9722
|
async function readToken(env, fromEnv) {
|
|
9378
9723
|
if (fromEnv !== undefined) {
|
|
9379
9724
|
if (!ENV_NAME3.test(fromEnv))
|
|
9380
|
-
throw new
|
|
9725
|
+
throw new CliUserError44("Invalid environment variable name for --from-env.");
|
|
9381
9726
|
const value = env.env[fromEnv]?.trim() ?? "";
|
|
9382
9727
|
if (value === "")
|
|
9383
|
-
throw new
|
|
9728
|
+
throw new CliUserError44(`The environment variable ${fromEnv} is empty or unset.`);
|
|
9384
9729
|
return value;
|
|
9385
9730
|
}
|
|
9386
9731
|
const piped = (await env.readStdin()).trim();
|
|
9387
9732
|
if (piped === "") {
|
|
9388
|
-
throw new
|
|
9733
|
+
throw new CliUserError44("Pipe the token on standard input, or pass --from-env <VAR>.", {
|
|
9389
9734
|
hint: 'For example: `printf %s "$TOKEN" | fluidgrids config set token --profile prod`.'
|
|
9390
9735
|
});
|
|
9391
9736
|
}
|
|
@@ -9405,7 +9750,7 @@ async function runConfigSet(env, key, value, options) {
|
|
|
9405
9750
|
const profile = profileName(env, options);
|
|
9406
9751
|
if (key === "token") {
|
|
9407
9752
|
if (value !== undefined) {
|
|
9408
|
-
throw new
|
|
9753
|
+
throw new CliUserError44("A token is never given on the command line.", {
|
|
9409
9754
|
hint: "Pipe it on standard input, or pass --from-env <VAR>."
|
|
9410
9755
|
});
|
|
9411
9756
|
}
|
|
@@ -9422,12 +9767,12 @@ async function runConfigSet(env, key, value, options) {
|
|
|
9422
9767
|
return out;
|
|
9423
9768
|
}
|
|
9424
9769
|
if (!isProfileKey(key)) {
|
|
9425
|
-
throw new
|
|
9770
|
+
throw new CliUserError44(`Unknown profile key ${key}.`, {
|
|
9426
9771
|
hint: `Keys: ${PROFILE_KEYS.join(", ")}, token, defaultProfile.`
|
|
9427
9772
|
});
|
|
9428
9773
|
}
|
|
9429
9774
|
if (value === undefined)
|
|
9430
|
-
throw new
|
|
9775
|
+
throw new CliUserError44(`Give a value for ${key}.`);
|
|
9431
9776
|
const checked = checkProfileValue(key, value, profile);
|
|
9432
9777
|
updateConfig(file, (document) => {
|
|
9433
9778
|
const table = profileTable(document, profile, true);
|
|
@@ -9443,7 +9788,7 @@ async function runConfigGet(env, key, options) {
|
|
|
9443
9788
|
const config = readConfig(file);
|
|
9444
9789
|
const resolved = resolveProfile(config, env.env, options.profile, file);
|
|
9445
9790
|
if (key !== undefined && !isProfileKey(key)) {
|
|
9446
|
-
throw new
|
|
9791
|
+
throw new CliUserError44(`Unknown profile key ${key}.`, {
|
|
9447
9792
|
hint: `Keys: ${PROFILE_KEYS.join(", ")}.`
|
|
9448
9793
|
});
|
|
9449
9794
|
}
|
|
@@ -9488,10 +9833,10 @@ async function runConfigDelete(env, key, options) {
|
|
|
9488
9833
|
const profile = profileName(env, options);
|
|
9489
9834
|
const existing = readConfig(file).profiles[profile];
|
|
9490
9835
|
if (existing === undefined)
|
|
9491
|
-
throw new
|
|
9836
|
+
throw new CliUserError44(`There is no profile ${profile} in ${file}.`);
|
|
9492
9837
|
if (key !== undefined) {
|
|
9493
9838
|
if (!isProfileKey(key))
|
|
9494
|
-
throw new
|
|
9839
|
+
throw new CliUserError44(`Unknown profile key ${key}.`);
|
|
9495
9840
|
updateConfig(file, (document) => {
|
|
9496
9841
|
const table = profileTable(document, profile, false);
|
|
9497
9842
|
if (table)
|
|
@@ -9528,7 +9873,7 @@ async function runConfigMigrate(env, options) {
|
|
|
9528
9873
|
values.workspace = workspace;
|
|
9529
9874
|
if (options.tokenEnv !== undefined) {
|
|
9530
9875
|
if (!ENV_NAME3.test(options.tokenEnv))
|
|
9531
|
-
throw new
|
|
9876
|
+
throw new CliUserError44("Invalid environment variable name for --token-env.");
|
|
9532
9877
|
values.tokenRef = `env:${options.tokenEnv}`;
|
|
9533
9878
|
}
|
|
9534
9879
|
updateConfig(file, (document) => {
|
|
@@ -9553,7 +9898,7 @@ var init_commands = __esm(() => {
|
|
|
9553
9898
|
});
|
|
9554
9899
|
|
|
9555
9900
|
// src/phase-c/commands/workers.ts
|
|
9556
|
-
import { CliUserError as
|
|
9901
|
+
import { CliUserError as CliUserError45 } from "@burdenoff/cli-sdk/core";
|
|
9557
9902
|
function workerRows(workers) {
|
|
9558
9903
|
return workers.map((worker) => [
|
|
9559
9904
|
worker.identity,
|
|
@@ -9567,7 +9912,7 @@ function workerRows(workers) {
|
|
|
9567
9912
|
}
|
|
9568
9913
|
async function runWorkersList(env, options) {
|
|
9569
9914
|
if (options.stale && options.notStale) {
|
|
9570
|
-
throw new
|
|
9915
|
+
throw new CliUserError45("Give --stale or --not-stale, not both.");
|
|
9571
9916
|
}
|
|
9572
9917
|
const filter = {
|
|
9573
9918
|
...options.queue ? { taskQueue: checkWorkerQueue(options.queue) } : {},
|
|
@@ -9610,7 +9955,7 @@ function connectionNames(raw) {
|
|
|
9610
9955
|
const names = parseList(raw);
|
|
9611
9956
|
for (const name of names) {
|
|
9612
9957
|
if (!CONNECTION_NAME.test(name)) {
|
|
9613
|
-
throw new
|
|
9958
|
+
throw new CliUserError45(`Invalid connection name '${name}'.`);
|
|
9614
9959
|
}
|
|
9615
9960
|
}
|
|
9616
9961
|
return names;
|
|
@@ -9625,10 +9970,10 @@ function issued(env, options, result) {
|
|
|
9625
9970
|
async function runTokensCreate(env, name, options) {
|
|
9626
9971
|
const tokenName = name.trim();
|
|
9627
9972
|
if (tokenName === "")
|
|
9628
|
-
throw new
|
|
9973
|
+
throw new CliUserError45("A worker token needs a name.");
|
|
9629
9974
|
const taskQueues = parseList(options.queue).map(checkWorkerQueue);
|
|
9630
9975
|
if (taskQueues.length === 0) {
|
|
9631
|
-
throw new
|
|
9976
|
+
throw new CliUserError45("A worker token needs at least one --queue.", {
|
|
9632
9977
|
hint: "Create the queue first with `fluidgrids queues create <name>`."
|
|
9633
9978
|
});
|
|
9634
9979
|
}
|
|
@@ -9657,10 +10002,10 @@ async function runTokensDelete(env, id, options) {
|
|
|
9657
10002
|
async function runTokensAllowConnections(env, id, names, options) {
|
|
9658
10003
|
const list = connectionNames(names);
|
|
9659
10004
|
if (list.length === 0 && !options.clear) {
|
|
9660
|
-
throw new
|
|
10005
|
+
throw new CliUserError45("Name the connections to allow, or pass --clear to allow none.");
|
|
9661
10006
|
}
|
|
9662
10007
|
if (list.length > 0 && options.clear) {
|
|
9663
|
-
throw new
|
|
10008
|
+
throw new CliUserError45("Give connection names or --clear, not both.");
|
|
9664
10009
|
}
|
|
9665
10010
|
const token = await env.pc.setWorkerTokenConnectionAllowlist(id, list);
|
|
9666
10011
|
emit(env, options, token, { headers: TOKEN_HEADERS, rows: [tokenRow(token)] }, [
|
|
@@ -9680,17 +10025,17 @@ var init_workers = __esm(() => {
|
|
|
9680
10025
|
|
|
9681
10026
|
// src/phase-c/commands/run-control.ts
|
|
9682
10027
|
import { randomUUID } from "crypto";
|
|
9683
|
-
import { CliUserError as
|
|
10028
|
+
import { CliUserError as CliUserError46 } from "@burdenoff/cli-sdk/core";
|
|
9684
10029
|
function runAndName(first, second, flags) {
|
|
9685
10030
|
const targeted = flags.workflowId !== undefined || flags.key !== undefined;
|
|
9686
10031
|
if (targeted) {
|
|
9687
10032
|
if (second !== undefined) {
|
|
9688
|
-
throw new
|
|
10033
|
+
throw new CliUserError46("With --workflow-id, give only the name: `<name> --workflow-id <id> --key <key>`.");
|
|
9689
10034
|
}
|
|
9690
10035
|
return { run: runSelectorOf(undefined, flags), name: first };
|
|
9691
10036
|
}
|
|
9692
10037
|
if (second === undefined) {
|
|
9693
|
-
throw new
|
|
10038
|
+
throw new CliUserError46("Give the run id and the name: `<runId> <name>`.");
|
|
9694
10039
|
}
|
|
9695
10040
|
return { run: runSelectorOf(first, flags), name: second };
|
|
9696
10041
|
}
|
|
@@ -9704,7 +10049,7 @@ async function runQuery(env, first, second, options) {
|
|
|
9704
10049
|
rows: [[result.name, String(result.rejected), JSON.stringify(result.value ?? null)]]
|
|
9705
10050
|
}, result.error ? [`error: ${result.error}`] : []);
|
|
9706
10051
|
if (result.rejected) {
|
|
9707
|
-
throw new
|
|
10052
|
+
throw new CliUserError46(`The query ${name} was refused: ${result.error ?? "no reason given"}`);
|
|
9708
10053
|
}
|
|
9709
10054
|
return result;
|
|
9710
10055
|
}
|
|
@@ -9746,13 +10091,13 @@ async function runUpdate(env, first, second, options) {
|
|
|
9746
10091
|
rows: [[result.updateId, result.name, result.status, JSON.stringify(result.result ?? null)]]
|
|
9747
10092
|
});
|
|
9748
10093
|
if (!reached(result.status, waitFor)) {
|
|
9749
|
-
throw new
|
|
10094
|
+
throw new CliUserError46(`The update ${name} is still ${result.status} after ${timeoutMs} ms (waiting for ${waitFor}); check it later with \`fluidgrids runs update-status ${result.runId} ${updateId}\`.`);
|
|
9750
10095
|
}
|
|
9751
10096
|
if (result.status === "REJECTED") {
|
|
9752
|
-
throw new
|
|
10097
|
+
throw new CliUserError46(`The update ${name} was rejected: ${failureMessage(result.failure)}`);
|
|
9753
10098
|
}
|
|
9754
10099
|
if (result.status === "COMPLETED" && result.failure !== null && result.failure !== undefined) {
|
|
9755
|
-
throw new
|
|
10100
|
+
throw new CliUserError46(`The update handler of ${name} failed: ${failureMessage(result.failure)}`);
|
|
9756
10101
|
}
|
|
9757
10102
|
return result;
|
|
9758
10103
|
}
|
|
@@ -9768,33 +10113,33 @@ async function runUpdateStatus(env, first, second, options) {
|
|
|
9768
10113
|
function parseResetTo(raw, buildId) {
|
|
9769
10114
|
const value = raw?.trim() ?? "";
|
|
9770
10115
|
if (value === "") {
|
|
9771
|
-
throw new
|
|
10116
|
+
throw new CliUserError46("--to is required: a history seq, first-task, last-task, last-continue-as-new, build-id or last-clean-task.");
|
|
9772
10117
|
}
|
|
9773
10118
|
if (/^\d+$/.test(value)) {
|
|
9774
10119
|
if (buildId !== undefined)
|
|
9775
|
-
throw new
|
|
10120
|
+
throw new CliUserError46("--build-id goes with --to build-id only.");
|
|
9776
10121
|
const seq = Number(value);
|
|
9777
10122
|
if (!Number.isSafeInteger(seq) || seq <= 0) {
|
|
9778
|
-
throw new
|
|
10123
|
+
throw new CliUserError46(`Invalid value '${raw}' for --to: a seq is a positive integer.`);
|
|
9779
10124
|
}
|
|
9780
10125
|
return { seq };
|
|
9781
10126
|
}
|
|
9782
10127
|
const normal = value.toUpperCase().replace(/-/g, "_");
|
|
9783
10128
|
if (normal === "LAST_CLEAN_TASK") {
|
|
9784
10129
|
if (buildId !== undefined)
|
|
9785
|
-
throw new
|
|
10130
|
+
throw new CliUserError46("--build-id goes with --to build-id only.");
|
|
9786
10131
|
return "LAST_CLEAN_TASK";
|
|
9787
10132
|
}
|
|
9788
10133
|
const type = parseEnumOption(normal === "LAST_CONTINUE_AS_NEW" ? "LAST_CONTINUED_AS_NEW" : normal, "--to", RESET_TYPES);
|
|
9789
10134
|
if (type === "BUILD_ID") {
|
|
9790
10135
|
const id = buildId?.trim() ?? "";
|
|
9791
10136
|
if (!/^sha256:[0-9a-f]{64}$/.test(id)) {
|
|
9792
|
-
throw new
|
|
10137
|
+
throw new CliUserError46("--to build-id needs --build-id sha256:<64 hex>.");
|
|
9793
10138
|
}
|
|
9794
10139
|
return { type, buildId: id };
|
|
9795
10140
|
}
|
|
9796
10141
|
if (buildId !== undefined)
|
|
9797
|
-
throw new
|
|
10142
|
+
throw new CliUserError46("--build-id goes with --to build-id only.");
|
|
9798
10143
|
return { type };
|
|
9799
10144
|
}
|
|
9800
10145
|
async function runReset(env, runId, options) {
|
|
@@ -9853,7 +10198,7 @@ async function runTrace(env, runIdArg, options) {
|
|
|
9853
10198
|
const runId = await env.pc.runIdOf(runSelectorOf(runIdArg, options));
|
|
9854
10199
|
const hierarchy = await env.pc.runHierarchy(runId);
|
|
9855
10200
|
if (!hierarchy)
|
|
9856
|
-
throw new
|
|
10201
|
+
throw new CliUserError46(`Run ${runId} not found (NOT_FOUND)`);
|
|
9857
10202
|
const entries = flatten(hierarchy);
|
|
9858
10203
|
const open = entries.filter((entry) => OPEN_STATUSES.includes(entry.run.status));
|
|
9859
10204
|
const read = new Map;
|
|
@@ -9893,32 +10238,32 @@ var init_run_control = __esm(() => {
|
|
|
9893
10238
|
});
|
|
9894
10239
|
|
|
9895
10240
|
// src/phase-c/commands/activities.ts
|
|
9896
|
-
import { CliUserError as
|
|
10241
|
+
import { CliUserError as CliUserError47 } from "@burdenoff/cli-sdk/core";
|
|
9897
10242
|
import { durationMs as durationMs2 } from "@fluidgrids/workflows/ir";
|
|
9898
10243
|
function completionOf(env, first, second, options) {
|
|
9899
10244
|
if (options.taskTokenEnv !== undefined) {
|
|
9900
10245
|
if (first !== undefined || options.workflowId !== undefined || options.key !== undefined) {
|
|
9901
|
-
throw new
|
|
10246
|
+
throw new CliUserError47("Give --task-token-env, or the run and activity id, not both.");
|
|
9902
10247
|
}
|
|
9903
10248
|
const variable = options.taskTokenEnv.trim();
|
|
9904
10249
|
if (!ENV_NAME4.test(variable)) {
|
|
9905
|
-
throw new
|
|
10250
|
+
throw new CliUserError47("Invalid environment variable name for --task-token-env.");
|
|
9906
10251
|
}
|
|
9907
10252
|
const taskToken = env.getEnv(variable)?.trim() ?? "";
|
|
9908
10253
|
if (taskToken === "") {
|
|
9909
|
-
throw new
|
|
10254
|
+
throw new CliUserError47(`The environment variable ${variable} (--task-token-env) is empty or unset.`);
|
|
9910
10255
|
}
|
|
9911
10256
|
return { kind: "token", taskToken };
|
|
9912
10257
|
}
|
|
9913
10258
|
const targeted = options.workflowId !== undefined || options.key !== undefined;
|
|
9914
10259
|
if (targeted) {
|
|
9915
10260
|
if (first === undefined || second !== undefined) {
|
|
9916
|
-
throw new
|
|
10261
|
+
throw new CliUserError47("With --workflow-id, give only the activity id.");
|
|
9917
10262
|
}
|
|
9918
10263
|
return { kind: "id", run: runSelectorOf(undefined, options), activityId: first };
|
|
9919
10264
|
}
|
|
9920
10265
|
if (first === undefined || second === undefined) {
|
|
9921
|
-
throw new
|
|
10266
|
+
throw new CliUserError47("Give `<runId> <activityId>`, `<activityId> --workflow-id <id> --key <key>`, or --task-token-env.");
|
|
9922
10267
|
}
|
|
9923
10268
|
return { kind: "id", run: runSelectorOf(first, options), activityId: second };
|
|
9924
10269
|
}
|
|
@@ -9976,7 +10321,7 @@ function selectorOf(options) {
|
|
|
9976
10321
|
options.all === true
|
|
9977
10322
|
];
|
|
9978
10323
|
if (given.filter(Boolean).length !== 1) {
|
|
9979
|
-
throw new
|
|
10324
|
+
throw new CliUserError47("Choose the activities with exactly one of --activity-id, --type or --all.");
|
|
9980
10325
|
}
|
|
9981
10326
|
if (options.activityId !== undefined) {
|
|
9982
10327
|
return { activityId: requireText(options.activityId, "--activity-id") };
|
|
@@ -10017,18 +10362,18 @@ function parseMs(raw, flag) {
|
|
|
10017
10362
|
const value = raw.trim();
|
|
10018
10363
|
const ms = /^\d+$/.test(value) ? Number(value) : value === "" ? undefined : durationMs2(value, "ms");
|
|
10019
10364
|
if (ms === undefined || !Number.isFinite(ms) || ms <= 0 || !Number.isSafeInteger(Math.round(ms))) {
|
|
10020
|
-
throw new
|
|
10365
|
+
throw new CliUserError47(`Invalid value '${raw}' for ${flag}: expected milliseconds or a duration such as 1.5s, 5m or PT2H.`);
|
|
10021
10366
|
}
|
|
10022
10367
|
return Math.round(ms);
|
|
10023
10368
|
}
|
|
10024
10369
|
function activityOptionsOf(options) {
|
|
10025
10370
|
const maxRetries = options.maxRetries === undefined ? undefined : /^\d+$/.test(options.maxRetries.trim()) ? Number(options.maxRetries.trim()) : NaN;
|
|
10026
10371
|
if (Number.isNaN(maxRetries)) {
|
|
10027
|
-
throw new
|
|
10372
|
+
throw new CliUserError47(`Invalid value '${options.maxRetries}' for --max-retries.`);
|
|
10028
10373
|
}
|
|
10029
10374
|
const backoff = options.backoff === undefined ? undefined : Number(options.backoff.trim());
|
|
10030
10375
|
if (backoff !== undefined && (!Number.isFinite(backoff) || backoff < 1)) {
|
|
10031
|
-
throw new
|
|
10376
|
+
throw new CliUserError47(`Invalid value '${options.backoff}' for --backoff: at least 1.`);
|
|
10032
10377
|
}
|
|
10033
10378
|
const retryOn = [];
|
|
10034
10379
|
for (const value of parseList(options.retryOn)) {
|
|
@@ -10052,7 +10397,7 @@ function activityOptionsOf(options) {
|
|
|
10052
10397
|
};
|
|
10053
10398
|
const out = { ...timeouts, ...Object.keys(retry).length > 0 ? { retry } : {} };
|
|
10054
10399
|
if (Object.keys(out).length === 0) {
|
|
10055
|
-
throw new
|
|
10400
|
+
throw new CliUserError47("Nothing to change: give a retry option or a timeout.");
|
|
10056
10401
|
}
|
|
10057
10402
|
return out;
|
|
10058
10403
|
}
|
|
@@ -10079,10 +10424,10 @@ async function runPauseRulesList(env, options) {
|
|
|
10079
10424
|
}
|
|
10080
10425
|
async function runPauseRulesCreate(env, options) {
|
|
10081
10426
|
if (options.activityType === undefined && options.nodeType === undefined && options.workflowKey === undefined) {
|
|
10082
|
-
throw new
|
|
10427
|
+
throw new CliUserError47("A pause rule needs --activity-type, --node-type or --workflow-key.");
|
|
10083
10428
|
}
|
|
10084
10429
|
if (options.expiresAt !== undefined && options.expiresIn !== undefined) {
|
|
10085
|
-
throw new
|
|
10430
|
+
throw new CliUserError47("Give --expires-at or --expires-in, not both.");
|
|
10086
10431
|
}
|
|
10087
10432
|
const expiresIn = parseMs(options.expiresIn, "--expires-in");
|
|
10088
10433
|
const expiresAt = expiresIn !== undefined ? new Date(Date.now() + expiresIn).toISOString() : parseInstant(options.expiresAt, "--expires-at");
|
|
@@ -10120,7 +10465,7 @@ var init_activities = __esm(() => {
|
|
|
10120
10465
|
});
|
|
10121
10466
|
|
|
10122
10467
|
// src/phase-c/commands/batch.ts
|
|
10123
|
-
import { CliUserError as
|
|
10468
|
+
import { CliUserError as CliUserError48 } from "@burdenoff/cli-sdk/core";
|
|
10124
10469
|
function isBatchType(name) {
|
|
10125
10470
|
return Object.hasOwn(BATCH_TYPES, name);
|
|
10126
10471
|
}
|
|
@@ -10133,7 +10478,7 @@ function batchSelection(options) {
|
|
|
10133
10478
|
if (options.filter !== undefined) {
|
|
10134
10479
|
const raw = parseJsonOption(options.filter, "--filter");
|
|
10135
10480
|
if (!isRecord20(raw))
|
|
10136
|
-
throw new
|
|
10481
|
+
throw new CliUserError48("--filter must be a JSON object (ListWorkflowRunsInput).");
|
|
10137
10482
|
Object.assign(filter, raw);
|
|
10138
10483
|
delete filter["limit"];
|
|
10139
10484
|
delete filter["offset"];
|
|
@@ -10153,19 +10498,19 @@ function batchSelection(options) {
|
|
|
10153
10498
|
if (options.searchAttributes !== undefined) {
|
|
10154
10499
|
const query = parseJsonOption(options.searchAttributes, "--search-attributes");
|
|
10155
10500
|
if (!isRecord20(query)) {
|
|
10156
|
-
throw new
|
|
10501
|
+
throw new CliUserError48("--search-attributes must be a JSON object ({and, or, text}).");
|
|
10157
10502
|
}
|
|
10158
10503
|
filter["searchAttributes"] = query;
|
|
10159
10504
|
}
|
|
10160
10505
|
const filtered = Object.keys(filter).length > 0;
|
|
10161
10506
|
if (runIds.length > 0 && filtered) {
|
|
10162
|
-
throw new
|
|
10507
|
+
throw new CliUserError48("Choose the runs with --run-id or with filter options, not both.");
|
|
10163
10508
|
}
|
|
10164
10509
|
if (runIds.length > MAX_BATCH_RUN_IDS) {
|
|
10165
|
-
throw new
|
|
10510
|
+
throw new CliUserError48(`At most ${MAX_BATCH_RUN_IDS} --run-id values; use a filter for more.`);
|
|
10166
10511
|
}
|
|
10167
10512
|
if (runIds.length === 0 && !filtered) {
|
|
10168
|
-
throw new
|
|
10513
|
+
throw new CliUserError48("Choose the runs: --run-id, or a filter (--key, --status, --kind, --workflow-id, --search-attributes, --filter).");
|
|
10169
10514
|
}
|
|
10170
10515
|
const rate = parsePositiveInt(options.rate, "--rate");
|
|
10171
10516
|
return {
|
|
@@ -10227,7 +10572,7 @@ function batchPayload(type, options) {
|
|
|
10227
10572
|
options.clearOverride === true
|
|
10228
10573
|
];
|
|
10229
10574
|
if (chosen.filter(Boolean).length !== 1) {
|
|
10230
|
-
throw new
|
|
10575
|
+
throw new CliUserError48("Give exactly one of --pin <version>, --auto-upgrade or --clear-override.");
|
|
10231
10576
|
}
|
|
10232
10577
|
if (options.clearOverride)
|
|
10233
10578
|
return { clearVersioningOverride: true };
|
|
@@ -10261,7 +10606,7 @@ function refuseUnused(type, options) {
|
|
|
10261
10606
|
unused.push("--activity-id/--type/--all");
|
|
10262
10607
|
}
|
|
10263
10608
|
if (unused.length > 0) {
|
|
10264
|
-
throw new
|
|
10609
|
+
throw new CliUserError48(`${unused.join(", ")} do not apply to a ${type} batch.`);
|
|
10265
10610
|
}
|
|
10266
10611
|
}
|
|
10267
10612
|
function jobRow(job) {
|
|
@@ -10289,7 +10634,7 @@ function jobDetails(job) {
|
|
|
10289
10634
|
}
|
|
10290
10635
|
async function runBatchStart(env, typeName, options) {
|
|
10291
10636
|
if (!isBatchType(typeName)) {
|
|
10292
|
-
throw new
|
|
10637
|
+
throw new CliUserError48(`Unknown batch type '${typeName}'. Allowed: ${Object.keys(BATCH_TYPES).join(", ")}`);
|
|
10293
10638
|
}
|
|
10294
10639
|
const type = BATCH_TYPES[typeName];
|
|
10295
10640
|
refuseUnused(type, options);
|
|
@@ -10339,10 +10684,10 @@ async function runBatchDescribe(env, id, options) {
|
|
|
10339
10684
|
}
|
|
10340
10685
|
emit(env, options, job, { headers: JOB_HEADERS, rows: [jobRow(job)] }, jobDetails(job));
|
|
10341
10686
|
if (options.watch && !TERMINAL_JOB.includes(job.status)) {
|
|
10342
|
-
throw new
|
|
10687
|
+
throw new CliUserError48(`Batch job ${id} is still ${job.status} after ${timeout} ms.`);
|
|
10343
10688
|
}
|
|
10344
10689
|
if (options.watch && (job.status === "FAILED" || job.status === "CANCELLED")) {
|
|
10345
|
-
throw new
|
|
10690
|
+
throw new CliUserError48(`Batch job ${id} ended ${job.status}${job.failureMessage ? `: ${job.failureMessage}` : ""}.`);
|
|
10346
10691
|
}
|
|
10347
10692
|
return job;
|
|
10348
10693
|
}
|
|
@@ -10386,7 +10731,7 @@ var init_batch = __esm(() => {
|
|
|
10386
10731
|
});
|
|
10387
10732
|
|
|
10388
10733
|
// src/phase-d/duration.ts
|
|
10389
|
-
import { CliUserError as
|
|
10734
|
+
import { CliUserError as CliUserError49 } from "@burdenoff/cli-sdk/core";
|
|
10390
10735
|
import { toMs } from "@fluidgrids/workflows";
|
|
10391
10736
|
function parseDurationOption(raw, flag) {
|
|
10392
10737
|
if (raw === undefined)
|
|
@@ -10396,7 +10741,7 @@ function parseDurationOption(raw, flag) {
|
|
|
10396
10741
|
try {
|
|
10397
10742
|
toMs(sent, flag);
|
|
10398
10743
|
} catch {
|
|
10399
|
-
throw new
|
|
10744
|
+
throw new CliUserError49(`Invalid value '${raw}' for ${flag}: expected a duration such as 1500 (milliseconds), 30s, 5m, 2h or PT2H.`);
|
|
10400
10745
|
}
|
|
10401
10746
|
return sent;
|
|
10402
10747
|
}
|
|
@@ -10405,14 +10750,14 @@ var init_duration = () => {};
|
|
|
10405
10750
|
// src/phase-d/commands/activity-start.ts
|
|
10406
10751
|
import { existsSync as existsSync15, readFileSync as readFileSync12 } from "fs";
|
|
10407
10752
|
import { resolve as resolve12 } from "path";
|
|
10408
|
-
import { CliUserError as
|
|
10753
|
+
import { CliUserError as CliUserError50 } from "@burdenoff/cli-sdk/core";
|
|
10409
10754
|
function retryPolicy(raw, maxAttempts, readFile) {
|
|
10410
10755
|
const parsed = parseJsonObjectArg(raw, "--retry", readFile);
|
|
10411
10756
|
const policy = {};
|
|
10412
10757
|
if (parsed !== undefined) {
|
|
10413
10758
|
for (const key of Object.keys(parsed)) {
|
|
10414
10759
|
if (!RETRY_KEYS.some((known) => known === key)) {
|
|
10415
|
-
throw new
|
|
10760
|
+
throw new CliUserError50(`--retry: unknown field ${key}. Allowed: ${RETRY_KEYS.join(", ")}`);
|
|
10416
10761
|
}
|
|
10417
10762
|
}
|
|
10418
10763
|
const text = (key) => {
|
|
@@ -10420,7 +10765,7 @@ function retryPolicy(raw, maxAttempts, readFile) {
|
|
|
10420
10765
|
if (value === undefined)
|
|
10421
10766
|
return;
|
|
10422
10767
|
if (typeof value !== "string")
|
|
10423
|
-
throw new
|
|
10768
|
+
throw new CliUserError50(`--retry: ${key} must be a duration.`);
|
|
10424
10769
|
policy[key] = parseDurationOption(value, `--retry ${key}`);
|
|
10425
10770
|
};
|
|
10426
10771
|
text("initialInterval");
|
|
@@ -10428,21 +10773,21 @@ function retryPolicy(raw, maxAttempts, readFile) {
|
|
|
10428
10773
|
const backoff = parsed["backoffCoefficient"];
|
|
10429
10774
|
if (backoff !== undefined) {
|
|
10430
10775
|
if (typeof backoff !== "number" || !Number.isFinite(backoff) || backoff < 1) {
|
|
10431
|
-
throw new
|
|
10776
|
+
throw new CliUserError50("--retry: backoffCoefficient must be a number of at least 1.");
|
|
10432
10777
|
}
|
|
10433
10778
|
policy.backoffCoefficient = backoff;
|
|
10434
10779
|
}
|
|
10435
10780
|
const attempts = parsed["maximumAttempts"];
|
|
10436
10781
|
if (attempts !== undefined) {
|
|
10437
10782
|
if (typeof attempts !== "number" || !Number.isSafeInteger(attempts) || attempts < 0) {
|
|
10438
|
-
throw new
|
|
10783
|
+
throw new CliUserError50("--retry: maximumAttempts must be a whole number (0 = unlimited).");
|
|
10439
10784
|
}
|
|
10440
10785
|
policy.maximumAttempts = attempts;
|
|
10441
10786
|
}
|
|
10442
10787
|
const types = parsed["nonRetryableErrorTypes"];
|
|
10443
10788
|
if (types !== undefined) {
|
|
10444
10789
|
if (!Array.isArray(types) || types.some((type) => typeof type !== "string")) {
|
|
10445
|
-
throw new
|
|
10790
|
+
throw new CliUserError50("--retry: nonRetryableErrorTypes must be a list of strings.");
|
|
10446
10791
|
}
|
|
10447
10792
|
policy.nonRetryableErrorTypes = types.filter((type) => typeof type === "string");
|
|
10448
10793
|
}
|
|
@@ -10450,7 +10795,7 @@ function retryPolicy(raw, maxAttempts, readFile) {
|
|
|
10450
10795
|
if (maxAttempts !== undefined) {
|
|
10451
10796
|
const value = maxAttempts.trim();
|
|
10452
10797
|
if (!/^\d+$/.test(value) || !Number.isSafeInteger(Number(value))) {
|
|
10453
|
-
throw new
|
|
10798
|
+
throw new CliUserError50(`Invalid value '${maxAttempts}' for --max-attempts: expected a whole number (0 = unlimited).`);
|
|
10454
10799
|
}
|
|
10455
10800
|
policy.maximumAttempts = Number(value);
|
|
10456
10801
|
}
|
|
@@ -10459,29 +10804,29 @@ function retryPolicy(raw, maxAttempts, readFile) {
|
|
|
10459
10804
|
function requireName(raw, what) {
|
|
10460
10805
|
const value = raw.trim();
|
|
10461
10806
|
if (value === "")
|
|
10462
|
-
throw new
|
|
10807
|
+
throw new CliUserError50(`The ${what} is empty.`);
|
|
10463
10808
|
return value;
|
|
10464
10809
|
}
|
|
10465
10810
|
async function runActivityStart(env, nodeType, operation, options) {
|
|
10466
10811
|
const readFile = (path) => {
|
|
10467
10812
|
const absolute = resolve12(env.cwd(), path);
|
|
10468
10813
|
if (!existsSync15(absolute))
|
|
10469
|
-
throw new
|
|
10814
|
+
throw new CliUserError50(`${path} does not exist.`);
|
|
10470
10815
|
return readFileSync12(absolute, "utf8");
|
|
10471
10816
|
};
|
|
10472
10817
|
if (options.args === undefined) {
|
|
10473
|
-
throw new
|
|
10818
|
+
throw new CliUserError50("--args is required: the operation arguments as a JSON object.", {
|
|
10474
10819
|
hint: `For example --args '{"url":"https://example.com"}', or --args @args.json.`
|
|
10475
10820
|
});
|
|
10476
10821
|
}
|
|
10477
10822
|
const args = parseJsonObjectArg(options.args, "--args", readFile) ?? {};
|
|
10478
10823
|
const summary = options.summary?.trim();
|
|
10479
10824
|
if (summary !== undefined && (summary === "" || summary.length > MAX_SUMMARY_CHARS)) {
|
|
10480
|
-
throw new
|
|
10825
|
+
throw new CliUserError50(`--summary is 1 to ${MAX_SUMMARY_CHARS} characters.`);
|
|
10481
10826
|
}
|
|
10482
10827
|
const key = options.idempotencyKey?.trim();
|
|
10483
10828
|
if (key !== undefined && !IDEMPOTENCY_KEY.test(key)) {
|
|
10484
|
-
throw new
|
|
10829
|
+
throw new CliUserError50(`--idempotency-key is 1 to ${MAX_IDEMPOTENCY_KEY_CHARS} letters, digits, dots, underscores, colons or dashes.`);
|
|
10485
10830
|
}
|
|
10486
10831
|
const retry = retryPolicy(options.retry, options.maxAttempts, readFile);
|
|
10487
10832
|
const nodeVersion = options.nodeVersion?.trim();
|
|
@@ -10525,7 +10870,7 @@ async function runActivityStart(env, nodeType, operation, options) {
|
|
|
10525
10870
|
rows: [[result.run.id, finalStatus, started.existing ? "yes" : "no"]]
|
|
10526
10871
|
}, details);
|
|
10527
10872
|
if (options.wait && finalStatus !== "COMPLETED") {
|
|
10528
|
-
throw new
|
|
10873
|
+
throw new CliUserError50(`Run ${started.run.id} ended ${finalStatus}.`);
|
|
10529
10874
|
}
|
|
10530
10875
|
return result;
|
|
10531
10876
|
}
|
|
@@ -10546,7 +10891,7 @@ var init_activity_start = __esm(() => {
|
|
|
10546
10891
|
});
|
|
10547
10892
|
|
|
10548
10893
|
// src/phase-c/commands/signal-tokens.ts
|
|
10549
|
-
import { CliUserError as
|
|
10894
|
+
import { CliUserError as CliUserError51 } from "@burdenoff/cli-sdk/core";
|
|
10550
10895
|
function row(token) {
|
|
10551
10896
|
return [
|
|
10552
10897
|
token.id,
|
|
@@ -10563,12 +10908,12 @@ async function runSignalTokenCreate(env, runId, options) {
|
|
|
10563
10908
|
const signalName = requireText(options.signal, "--signal");
|
|
10564
10909
|
const ttlMs = parseMs(options.ttl, "--ttl");
|
|
10565
10910
|
if (ttlMs !== undefined && ttlMs % 1000 !== 0) {
|
|
10566
|
-
throw new
|
|
10911
|
+
throw new CliUserError51("--ttl is counted in whole seconds.");
|
|
10567
10912
|
}
|
|
10568
10913
|
const ipAllowlist = parseList(options.allowIp);
|
|
10569
10914
|
for (const entry of ipAllowlist) {
|
|
10570
10915
|
if (!IPV4_OR_CIDR.test(entry)) {
|
|
10571
|
-
throw new
|
|
10916
|
+
throw new CliUserError51(`Invalid --allow-ip '${entry}': an IPv4 address or CIDR range.`);
|
|
10572
10917
|
}
|
|
10573
10918
|
}
|
|
10574
10919
|
const created = await env.pc.createSignalToken({
|
|
@@ -10604,7 +10949,7 @@ var init_signal_tokens = __esm(() => {
|
|
|
10604
10949
|
});
|
|
10605
10950
|
|
|
10606
10951
|
// src/phase-c/commands/search-attributes.ts
|
|
10607
|
-
import { CliUserError as
|
|
10952
|
+
import { CliUserError as CliUserError52 } from "@burdenoff/cli-sdk/core";
|
|
10608
10953
|
function row2(attribute) {
|
|
10609
10954
|
return [
|
|
10610
10955
|
attribute.name,
|
|
@@ -10621,11 +10966,11 @@ async function runSearchAttributesList(env, options) {
|
|
|
10621
10966
|
}
|
|
10622
10967
|
async function runSearchAttributesCreate(env, name, options) {
|
|
10623
10968
|
if (!NAME.test(name)) {
|
|
10624
|
-
throw new
|
|
10969
|
+
throw new CliUserError52(`Invalid search attribute name '${name}': a letter, then letters, digits and underscores (at most 64).`);
|
|
10625
10970
|
}
|
|
10626
10971
|
const type = parseEnumOption(options.type, "--type", SEARCH_ATTRIBUTE_TYPES);
|
|
10627
10972
|
if (type === undefined) {
|
|
10628
|
-
throw new
|
|
10973
|
+
throw new CliUserError52(`--type is required: ${SEARCH_ATTRIBUTE_TYPES.join(", ")}.`);
|
|
10629
10974
|
}
|
|
10630
10975
|
const attribute = await env.pc.createSearchAttribute({
|
|
10631
10976
|
name,
|
|
@@ -10638,7 +10983,7 @@ async function runSearchAttributesCreate(env, name, options) {
|
|
|
10638
10983
|
async function runSearchAttributesDelete(env, name, options) {
|
|
10639
10984
|
const attribute = (await env.pc.searchAttributes()).find((entry) => entry.name === name);
|
|
10640
10985
|
if (!attribute) {
|
|
10641
|
-
throw new
|
|
10986
|
+
throw new CliUserError52(`The workspace has no search attribute ${name}.`, {
|
|
10642
10987
|
hint: "List them with `fluidgrids search-attributes list`."
|
|
10643
10988
|
});
|
|
10644
10989
|
}
|
|
@@ -10666,7 +11011,7 @@ var init_search_attributes = __esm(() => {
|
|
|
10666
11011
|
});
|
|
10667
11012
|
|
|
10668
11013
|
// src/phase-c/commands/schedules.ts
|
|
10669
|
-
import { CliUserError as
|
|
11014
|
+
import { CliUserError as CliUserError53 } from "@burdenoff/cli-sdk/core";
|
|
10670
11015
|
function isRecord21(value) {
|
|
10671
11016
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10672
11017
|
}
|
|
@@ -10791,9 +11136,9 @@ async function runSchedulesBackfill(env, workflowKey, triggerNodeId, options) {
|
|
|
10791
11136
|
const from = parseInstant(requireText(options.from, "--from"), "--from") ?? "";
|
|
10792
11137
|
const to = parseInstant(requireText(options.to, "--to"), "--to") ?? "";
|
|
10793
11138
|
if (from >= to)
|
|
10794
|
-
throw new
|
|
11139
|
+
throw new CliUserError53("--from must be before --to.");
|
|
10795
11140
|
if (Date.parse(to) > Date.now())
|
|
10796
|
-
throw new
|
|
11141
|
+
throw new CliUserError53("--to must be in the past.");
|
|
10797
11142
|
await requireConfirmation(env, `Backfill ${workflowKey} ${triggerNodeId} from ${from} to ${to}? Each fire time starts a run (at most ${MAX_BACKFILL_FIRES}) and counts toward the monthly runs.`, options.force);
|
|
10798
11143
|
const overlapPolicy = parseOverlap(options.overlapPolicy);
|
|
10799
11144
|
const result = await env.pc.backfillSchedule({
|
|
@@ -10845,7 +11190,7 @@ init_json_contract();
|
|
|
10845
11190
|
import { readFileSync as readFileSync13 } from "fs";
|
|
10846
11191
|
import { join as join13, dirname as dirname7 } from "path";
|
|
10847
11192
|
import { fileURLToPath } from "url";
|
|
10848
|
-
import { CliUserError as
|
|
11193
|
+
import { CliUserError as CliUserError54, defaultOutputAdapter } from "@burdenoff/cli-sdk/core";
|
|
10849
11194
|
|
|
10850
11195
|
// src/output/run-envelope.ts
|
|
10851
11196
|
init_json_contract();
|
|
@@ -11489,6 +11834,64 @@ var codeFirstModule = {
|
|
|
11489
11834
|
};
|
|
11490
11835
|
var code_first_default = codeFirstModule;
|
|
11491
11836
|
|
|
11837
|
+
// src/mcp/index.ts
|
|
11838
|
+
init_bridge();
|
|
11839
|
+
import { createInterface as createInterface4 } from "readline";
|
|
11840
|
+
import { CliUserError as CliUserError39 } from "@burdenoff/cli-sdk/core";
|
|
11841
|
+
var mcpModule = {
|
|
11842
|
+
id: "fluidgrids-mcp",
|
|
11843
|
+
version: "1.0.0",
|
|
11844
|
+
displayName: "FluidGrids MCP client bridge",
|
|
11845
|
+
dependsOn: ["auth"],
|
|
11846
|
+
register(program, ctx) {
|
|
11847
|
+
const mcp = program.command("mcp").description("Use FluidGrids MCP endpoints from desktop MCP clients");
|
|
11848
|
+
mcp.command("connect <url>").description("Bridge a stdio MCP client (Claude Desktop, Cursor, Claude Code) to a FluidGrids MCP endpoint. " + `Reads the app API key from ${API_KEY_ENV} and ${API_SECRET_ENV}, and renews the tokens itself.`).option("--organization <id>", "Organisation of the workspace, when the app belongs to several").addHelpText("after", [
|
|
11849
|
+
"",
|
|
11850
|
+
"Example (an MCP Server Trigger served at /s/crm-tools):",
|
|
11851
|
+
` ${API_KEY_ENV}=... ${API_SECRET_ENV}=... \\`,
|
|
11852
|
+
" fluidgrids mcp connect https://graphqlworkspaces.burdenoff.com/mcp/fluidgrids/<workspace id>/s/crm-tools",
|
|
11853
|
+
"",
|
|
11854
|
+
"stdout carries MCP messages only; the client starts this command and talks to it over stdio.",
|
|
11855
|
+
"A gateway behind Cloudflare Access also needs FLUIDGRIDS_CF_ACCESS_CLIENT_ID and FLUIDGRIDS_CF_ACCESS_CLIENT_SECRET.",
|
|
11856
|
+
"Documentation: https://docs.fluidgrids.ai/users/mcp-server-trigger"
|
|
11857
|
+
].join(`
|
|
11858
|
+
`)).action(async (url, flags) => {
|
|
11859
|
+
await Promise.resolve().then(() => init_bridge());
|
|
11860
|
+
const config = ctx.config.read();
|
|
11861
|
+
const productOrigin = ctx.config.resolveProductOrigin();
|
|
11862
|
+
const lines = createInterface4({ input: process.stdin, crlfDelay: Infinity });
|
|
11863
|
+
try {
|
|
11864
|
+
await runMcpConnect({
|
|
11865
|
+
url,
|
|
11866
|
+
...flags.organization ? { organizationId: flags.organization } : {},
|
|
11867
|
+
workspaceEndpoint: config.workspaceEndpoint,
|
|
11868
|
+
globalEndpoint: config.globalEndpoint,
|
|
11869
|
+
...productOrigin ? { productOrigin } : {}
|
|
11870
|
+
}, {
|
|
11871
|
+
env: process.env,
|
|
11872
|
+
fetch: (target, init) => fetch(target, init),
|
|
11873
|
+
lines,
|
|
11874
|
+
send: (line) => {
|
|
11875
|
+
process.stdout.write(`${line}
|
|
11876
|
+
`);
|
|
11877
|
+
},
|
|
11878
|
+
log: (message) => {
|
|
11879
|
+
process.stderr.write(`${message}
|
|
11880
|
+
`);
|
|
11881
|
+
}
|
|
11882
|
+
});
|
|
11883
|
+
} catch (error) {
|
|
11884
|
+
if (error instanceof McpBridgeConfigError)
|
|
11885
|
+
throw new CliUserError39(error.message);
|
|
11886
|
+
throw error;
|
|
11887
|
+
} finally {
|
|
11888
|
+
lines.close();
|
|
11889
|
+
}
|
|
11890
|
+
});
|
|
11891
|
+
}
|
|
11892
|
+
};
|
|
11893
|
+
var mcp_default = mcpModule;
|
|
11894
|
+
|
|
11492
11895
|
// src/phase-c/index.ts
|
|
11493
11896
|
init_shared();
|
|
11494
11897
|
|
|
@@ -11841,7 +12244,8 @@ var modules = [
|
|
|
11841
12244
|
devportalModule,
|
|
11842
12245
|
healthModule,
|
|
11843
12246
|
code_first_default,
|
|
11844
|
-
phase_c_default
|
|
12247
|
+
phase_c_default,
|
|
12248
|
+
mcp_default
|
|
11845
12249
|
];
|
|
11846
12250
|
|
|
11847
12251
|
// src/program.ts
|
|
@@ -11940,7 +12344,7 @@ try {
|
|
|
11940
12344
|
}
|
|
11941
12345
|
} catch (error) {
|
|
11942
12346
|
console.error(`✗ ${error instanceof Error ? error.message : String(error)}`);
|
|
11943
|
-
if (error instanceof
|
|
12347
|
+
if (error instanceof CliUserError54 && error.hint)
|
|
11944
12348
|
console.error(`ℹ ${error.hint}`);
|
|
11945
|
-
process.exitCode = error instanceof
|
|
12349
|
+
process.exitCode = error instanceof CliUserError54 ? error.exitCode : 1;
|
|
11946
12350
|
}
|