@fluidgrids/cli 2026.1116.1 → 2026.1124.1
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 +523 -136
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -7756,6 +7756,335 @@ 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 } }).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
|
+
authorization: `Bearer ${app.value}`,
|
|
7869
|
+
...options.productOrigin ? { origin: options.productOrigin } : {}
|
|
7870
|
+
}).catch((error) => {
|
|
7871
|
+
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.");
|
|
7872
|
+
});
|
|
7873
|
+
const token = data.issueWorkspaceToken?.token;
|
|
7874
|
+
if (!token)
|
|
7875
|
+
throw new Error(`No workspace token for workspace ${options.workspaceId}`);
|
|
7876
|
+
this.workspace = {
|
|
7877
|
+
value: token,
|
|
7878
|
+
expiresAt: jwtExpiryMs(token) ?? this.now() + WORKSPACE_TOKEN_FALLBACK_MS
|
|
7879
|
+
};
|
|
7880
|
+
}
|
|
7881
|
+
const workspace = this.workspace;
|
|
7882
|
+
if (!workspace)
|
|
7883
|
+
throw new Error(`No workspace token for workspace ${options.workspaceId}`);
|
|
7884
|
+
return { appToken: app.value, workspaceToken: workspace.value };
|
|
7885
|
+
}
|
|
7886
|
+
}
|
|
7887
|
+
function rpcError(id, message, code = -32000) {
|
|
7888
|
+
return JSON.stringify({ jsonrpc: "2.0", id, error: { code, message } });
|
|
7889
|
+
}
|
|
7890
|
+
|
|
7891
|
+
class EventStreamParser {
|
|
7892
|
+
buffer = "";
|
|
7893
|
+
push(chunk) {
|
|
7894
|
+
this.buffer += chunk;
|
|
7895
|
+
const events = [];
|
|
7896
|
+
let boundary = /\r?\n\r?\n/.exec(this.buffer);
|
|
7897
|
+
while (boundary) {
|
|
7898
|
+
events.push(this.buffer.slice(0, boundary.index));
|
|
7899
|
+
this.buffer = this.buffer.slice(boundary.index + boundary[0].length);
|
|
7900
|
+
boundary = /\r?\n\r?\n/.exec(this.buffer);
|
|
7901
|
+
}
|
|
7902
|
+
return events.map(eventData).filter((data) => data.trim() !== "");
|
|
7903
|
+
}
|
|
7904
|
+
end() {
|
|
7905
|
+
const rest = eventData(this.buffer);
|
|
7906
|
+
this.buffer = "";
|
|
7907
|
+
return rest.trim() ? [rest] : [];
|
|
7908
|
+
}
|
|
7909
|
+
}
|
|
7910
|
+
function eventData(event) {
|
|
7911
|
+
return event.split(/\r?\n/).filter((line) => line.startsWith("data:")).map((line) => line.slice(5).replace(/^ /, "")).join(`
|
|
7912
|
+
`);
|
|
7913
|
+
}
|
|
7914
|
+
function rpcMessagesOf(text) {
|
|
7915
|
+
let parsed;
|
|
7916
|
+
try {
|
|
7917
|
+
parsed = JSON.parse(text);
|
|
7918
|
+
} catch {
|
|
7919
|
+
return [];
|
|
7920
|
+
}
|
|
7921
|
+
return (Array.isArray(parsed) ? parsed : [parsed]).filter((item) => typeof item === "object" && item !== null && ("jsonrpc" in item) && item.jsonrpc === "2.0");
|
|
7922
|
+
}
|
|
7923
|
+
function errorDetail(text) {
|
|
7924
|
+
let parsed;
|
|
7925
|
+
try {
|
|
7926
|
+
parsed = JSON.parse(text);
|
|
7927
|
+
} catch {
|
|
7928
|
+
return "";
|
|
7929
|
+
}
|
|
7930
|
+
if (typeof parsed !== "object" || parsed === null)
|
|
7931
|
+
return "";
|
|
7932
|
+
const detail = "error" in parsed && typeof parsed.error === "string" ? parsed.error : ("message" in parsed) ? parsed.message : undefined;
|
|
7933
|
+
return typeof detail === "string" && detail.trim() ? `: ${detail.trim().slice(0, 300)}` : "";
|
|
7934
|
+
}
|
|
7935
|
+
|
|
7936
|
+
class McpBridge {
|
|
7937
|
+
options;
|
|
7938
|
+
protocolVersion = null;
|
|
7939
|
+
sessionId = null;
|
|
7940
|
+
inFlight = new Set;
|
|
7941
|
+
constructor(options) {
|
|
7942
|
+
this.options = options;
|
|
7943
|
+
}
|
|
7944
|
+
accept(line) {
|
|
7945
|
+
const text = line.trim();
|
|
7946
|
+
if (!text)
|
|
7947
|
+
return;
|
|
7948
|
+
const task = this.handle(text).catch((error) => {
|
|
7949
|
+
this.options.log(`mcp connect: ${error instanceof Error ? error.message : "unexpected error"}`);
|
|
7950
|
+
});
|
|
7951
|
+
this.inFlight.add(task);
|
|
7952
|
+
task.finally(() => this.inFlight.delete(task));
|
|
7953
|
+
}
|
|
7954
|
+
async drain() {
|
|
7955
|
+
while (this.inFlight.size > 0)
|
|
7956
|
+
await Promise.all([...this.inFlight]);
|
|
7957
|
+
}
|
|
7958
|
+
async handle(text) {
|
|
7959
|
+
let message;
|
|
7960
|
+
try {
|
|
7961
|
+
message = JSON.parse(text);
|
|
7962
|
+
} catch {
|
|
7963
|
+
this.options.send(rpcError(null, "Parse error", -32700));
|
|
7964
|
+
return;
|
|
7965
|
+
}
|
|
7966
|
+
const id = message.id ?? null;
|
|
7967
|
+
const isRequest = typeof message.method === "string" && message.id !== undefined && message.id !== null;
|
|
7968
|
+
let response;
|
|
7969
|
+
try {
|
|
7970
|
+
response = await this.post(text, false);
|
|
7971
|
+
if (response.status === 401) {
|
|
7972
|
+
this.options.tokens.invalidate();
|
|
7973
|
+
response = await this.post(text, true);
|
|
7974
|
+
}
|
|
7975
|
+
} catch (error) {
|
|
7976
|
+
if (isRequest)
|
|
7977
|
+
this.options.send(rpcError(id, error instanceof Error ? error.message : "Request failed"));
|
|
7978
|
+
return;
|
|
7979
|
+
}
|
|
7980
|
+
const session = response.headers.get("mcp-session-id");
|
|
7981
|
+
if (session)
|
|
7982
|
+
this.sessionId = session;
|
|
7983
|
+
let sent = 0;
|
|
7984
|
+
const dispatch = (data) => {
|
|
7985
|
+
for (const out of rpcMessagesOf(data)) {
|
|
7986
|
+
if (isRequest && out.id === null && out.error !== undefined)
|
|
7987
|
+
out.id = id;
|
|
7988
|
+
this.rememberProtocolVersion(message, out);
|
|
7989
|
+
this.options.send(JSON.stringify(out));
|
|
7990
|
+
sent += 1;
|
|
7991
|
+
}
|
|
7992
|
+
};
|
|
7993
|
+
let detail = "";
|
|
7994
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
7995
|
+
try {
|
|
7996
|
+
if (contentType.includes("text/event-stream") && response.body) {
|
|
7997
|
+
const parser = new EventStreamParser;
|
|
7998
|
+
const decoder = new TextDecoder;
|
|
7999
|
+
for await (const chunk of response.body) {
|
|
8000
|
+
for (const data of parser.push(decoder.decode(chunk, { stream: true })))
|
|
8001
|
+
dispatch(data);
|
|
8002
|
+
}
|
|
8003
|
+
for (const data of parser.push(decoder.decode()))
|
|
8004
|
+
dispatch(data);
|
|
8005
|
+
for (const data of parser.end())
|
|
8006
|
+
dispatch(data);
|
|
8007
|
+
} else {
|
|
8008
|
+
const body = await response.text();
|
|
8009
|
+
if (body.trim())
|
|
8010
|
+
dispatch(body);
|
|
8011
|
+
if (sent === 0)
|
|
8012
|
+
detail = errorDetail(body);
|
|
8013
|
+
}
|
|
8014
|
+
} catch (error) {
|
|
8015
|
+
if (sent === 0 && isRequest) {
|
|
8016
|
+
this.options.send(rpcError(id, `The MCP endpoint's answer was cut off: ${error instanceof Error ? error.message : "read failed"}`));
|
|
8017
|
+
}
|
|
8018
|
+
return;
|
|
8019
|
+
}
|
|
8020
|
+
if (sent === 0 && response.status >= 400 && isRequest) {
|
|
8021
|
+
this.options.send(rpcError(id, `The MCP endpoint answered HTTP ${response.status}${detail}`));
|
|
8022
|
+
}
|
|
8023
|
+
}
|
|
8024
|
+
async post(body, retried) {
|
|
8025
|
+
const tokens = await this.options.tokens.get();
|
|
8026
|
+
const headers = {
|
|
8027
|
+
"content-type": "application/json",
|
|
8028
|
+
accept: "application/json, text/event-stream",
|
|
8029
|
+
authorization: `Bearer ${tokens.appToken}`,
|
|
8030
|
+
"x-workspace-authorization": `Bearer ${tokens.workspaceToken}`
|
|
8031
|
+
};
|
|
8032
|
+
if (this.protocolVersion)
|
|
8033
|
+
headers["mcp-protocol-version"] = this.protocolVersion;
|
|
8034
|
+
if (this.sessionId)
|
|
8035
|
+
headers["mcp-session-id"] = this.sessionId;
|
|
8036
|
+
const response = await this.options.fetch(this.options.target.url.toString(), {
|
|
8037
|
+
method: "POST",
|
|
8038
|
+
headers,
|
|
8039
|
+
body,
|
|
8040
|
+
redirect: "error",
|
|
8041
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS2)
|
|
8042
|
+
});
|
|
8043
|
+
if (retried && response.status === 401) {
|
|
8044
|
+
this.options.log("mcp connect: the endpoint refused fresh tokens (HTTP 401); check the API key and its scopes");
|
|
8045
|
+
}
|
|
8046
|
+
return response;
|
|
8047
|
+
}
|
|
8048
|
+
rememberProtocolVersion(request, out) {
|
|
8049
|
+
if (request.method !== "initialize")
|
|
8050
|
+
return;
|
|
8051
|
+
const result = out.result;
|
|
8052
|
+
if (typeof result === "object" && result !== null && "protocolVersion" in result && typeof result.protocolVersion === "string") {
|
|
8053
|
+
this.protocolVersion = result.protocolVersion;
|
|
8054
|
+
}
|
|
8055
|
+
}
|
|
8056
|
+
}
|
|
8057
|
+
async function runMcpConnect(options, io) {
|
|
8058
|
+
const apiKey = io.env[API_KEY_ENV]?.trim();
|
|
8059
|
+
const apiSecret = io.env[API_SECRET_ENV]?.trim();
|
|
8060
|
+
if (!apiKey || !apiSecret) {
|
|
8061
|
+
throw new McpBridgeConfigError(`Set ${API_KEY_ENV} and ${API_SECRET_ENV} to the API key and secret of an app authorised for the workspace`);
|
|
8062
|
+
}
|
|
8063
|
+
const target = parseMcpTarget(options.url, options.workspaceEndpoint);
|
|
8064
|
+
const tokens = new TokenSource({
|
|
8065
|
+
apiKey,
|
|
8066
|
+
apiSecret,
|
|
8067
|
+
workspaceId: target.workspaceId,
|
|
8068
|
+
...options.organizationId ? { organizationId: options.organizationId } : {},
|
|
8069
|
+
globalEndpoint: options.globalEndpoint,
|
|
8070
|
+
workspaceEndpoint: options.workspaceEndpoint,
|
|
8071
|
+
...options.productOrigin ? { productOrigin: options.productOrigin } : {},
|
|
8072
|
+
fetch: io.fetch
|
|
8073
|
+
});
|
|
8074
|
+
const bridge = new McpBridge({ target, tokens, fetch: io.fetch, send: io.send, log: io.log });
|
|
8075
|
+
io.log(`mcp connect: relaying to ${target.url.origin}${target.url.pathname}` + (target.serverPath ? ` (MCP Server Trigger "${target.serverPath}")` : " (published tool set)"));
|
|
8076
|
+
for await (const line of io.lines)
|
|
8077
|
+
bridge.accept(line);
|
|
8078
|
+
await bridge.drain();
|
|
8079
|
+
}
|
|
8080
|
+
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", McpBridgeConfigError;
|
|
8081
|
+
var init_bridge = __esm(() => {
|
|
8082
|
+
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;
|
|
8083
|
+
WORKSPACE_TOKEN_FALLBACK_MS = 15 * 60000;
|
|
8084
|
+
McpBridgeConfigError = class McpBridgeConfigError extends Error {
|
|
8085
|
+
};
|
|
8086
|
+
});
|
|
8087
|
+
|
|
7759
8088
|
// src/phase-c/operations.ts
|
|
7760
8089
|
function hierarchyChildren(depth) {
|
|
7761
8090
|
if (depth === 0)
|
|
@@ -8260,7 +8589,7 @@ var init_operations3 = __esm(() => {
|
|
|
8260
8589
|
});
|
|
8261
8590
|
|
|
8262
8591
|
// src/phase-c/api.ts
|
|
8263
|
-
import { CliAuthError as CliAuthError6, CliUserError as
|
|
8592
|
+
import { CliAuthError as CliAuthError6, CliUserError as CliUserError40 } from "@burdenoff/cli-sdk/core";
|
|
8264
8593
|
function runVariables(run) {
|
|
8265
8594
|
return run.runId !== undefined ? { runId: run.runId } : { target: run.target };
|
|
8266
8595
|
}
|
|
@@ -8280,7 +8609,7 @@ function createPhaseCApi(ctx) {
|
|
|
8280
8609
|
function context() {
|
|
8281
8610
|
const workspaceId = ctx.auth.read()?.workspaceId;
|
|
8282
8611
|
if (!workspaceId) {
|
|
8283
|
-
throw new
|
|
8612
|
+
throw new CliUserError40("No workspace is selected.", {
|
|
8284
8613
|
hint: `Run \`${ctx.productName} workspace set <id>\` or set FLUIDGRIDS_WORKSPACE_ID.`
|
|
8285
8614
|
});
|
|
8286
8615
|
}
|
|
@@ -8413,7 +8742,7 @@ function createPhaseCApi(ctx) {
|
|
|
8413
8742
|
});
|
|
8414
8743
|
const found = data.workflowRunByWorkflowId;
|
|
8415
8744
|
if (!found) {
|
|
8416
|
-
throw new
|
|
8745
|
+
throw new CliUserError40(`No run with workflow id ${run.target.workflowId} of ${run.target.workflowKey} (NOT_FOUND)`);
|
|
8417
8746
|
}
|
|
8418
8747
|
return found.id;
|
|
8419
8748
|
},
|
|
@@ -8548,7 +8877,7 @@ function createPhaseCApi(ctx) {
|
|
|
8548
8877
|
if (!pagination?.hasMore || jobs.length === 0)
|
|
8549
8878
|
return all;
|
|
8550
8879
|
}
|
|
8551
|
-
throw new
|
|
8880
|
+
throw new CliUserError40(`The schedule listing did not end after ${MAX_SCHEDULE_PAGES} pages; refusing to continue.`);
|
|
8552
8881
|
},
|
|
8553
8882
|
async describeSchedule(workflowKey, triggerNodeId) {
|
|
8554
8883
|
const data = await request(PC_SCHEDULE_DESCRIBE, { workflowKey, triggerNodeId }, P);
|
|
@@ -8582,17 +8911,17 @@ var init_api3 = __esm(() => {
|
|
|
8582
8911
|
});
|
|
8583
8912
|
|
|
8584
8913
|
// src/phase-c/commands/queues.ts
|
|
8585
|
-
import { CliUserError as
|
|
8914
|
+
import { CliUserError as CliUserError41 } from "@burdenoff/cli-sdk/core";
|
|
8586
8915
|
function parseEnvironment2(raw) {
|
|
8587
8916
|
return parseEnumOption(raw, "--environment", ENVIRONMENTS3);
|
|
8588
8917
|
}
|
|
8589
8918
|
function checkQueueName(name) {
|
|
8590
8919
|
const value = name.trim();
|
|
8591
8920
|
if (value === "managed") {
|
|
8592
|
-
throw new
|
|
8921
|
+
throw new CliUserError41("`managed` is the platform queue; it cannot be created or changed.");
|
|
8593
8922
|
}
|
|
8594
8923
|
if (!QUEUE_NAME.test(value)) {
|
|
8595
|
-
throw new
|
|
8924
|
+
throw new CliUserError41(`Invalid queue name '${name}': lower-case letters, digits and dashes, at most 63, starting with a letter or digit.`);
|
|
8596
8925
|
}
|
|
8597
8926
|
return value;
|
|
8598
8927
|
}
|
|
@@ -8604,7 +8933,7 @@ function checkWorkerQueue(raw) {
|
|
|
8604
8933
|
const name = checkQueueName(value.slice(0, at));
|
|
8605
8934
|
const environment = value.slice(at + 1).toLowerCase();
|
|
8606
8935
|
if (!ENVIRONMENTS3.some((allowed) => allowed.toLowerCase() === environment)) {
|
|
8607
|
-
throw new
|
|
8936
|
+
throw new CliUserError41(`Invalid queue '${raw}': the environment after @ must be dev, staging or prod.`);
|
|
8608
8937
|
}
|
|
8609
8938
|
return `${name}@${environment}`;
|
|
8610
8939
|
}
|
|
@@ -8617,7 +8946,7 @@ function bindWorkerQueues(queues, raw) {
|
|
|
8617
8946
|
if (at < 0)
|
|
8618
8947
|
return `${queue}@${environment}`;
|
|
8619
8948
|
if (queue.slice(at + 1) !== environment) {
|
|
8620
|
-
throw new
|
|
8949
|
+
throw new CliUserError41(`Queue '${queue}' is bound to ${queue.slice(at + 1)}, but --environment is ${environment}.`);
|
|
8621
8950
|
}
|
|
8622
8951
|
return queue;
|
|
8623
8952
|
});
|
|
@@ -8633,11 +8962,11 @@ async function findQueue(env, name, environment) {
|
|
|
8633
8962
|
if (found)
|
|
8634
8963
|
return found;
|
|
8635
8964
|
if (environment === undefined && rows.length > 0) {
|
|
8636
|
-
throw new
|
|
8965
|
+
throw new CliUserError41(`Queue ${name} has only environment-scoped rows.`, {
|
|
8637
8966
|
hint: `Pass --environment (one of ${rows.map((queue) => queue.environment ?? "-").join(", ")}).`
|
|
8638
8967
|
});
|
|
8639
8968
|
}
|
|
8640
|
-
throw new
|
|
8969
|
+
throw new CliUserError41(`The workspace has no task queue ${environment ? `${name}@${environment}` : name}.`, { hint: "List them with `fluidgrids queues list`." });
|
|
8641
8970
|
}
|
|
8642
8971
|
async function runQueuesList(env, options) {
|
|
8643
8972
|
const queues = await env.pc.taskQueues();
|
|
@@ -8698,7 +9027,7 @@ async function runQueuesUpdate(env, name, options) {
|
|
|
8698
9027
|
const environment = parseEnvironment2(options.environment);
|
|
8699
9028
|
const maxTasksPerSecond = parseNumberOption(options.maxTasksPerSecond, "--max-tasks-per-second");
|
|
8700
9029
|
if (maxTasksPerSecond !== undefined && options.clearMaxTasksPerSecond) {
|
|
8701
|
-
throw new
|
|
9030
|
+
throw new CliUserError41("Give --max-tasks-per-second or --clear-max-tasks-per-second, not both.");
|
|
8702
9031
|
}
|
|
8703
9032
|
const timeout = parseNonNegativeInt(options.workerUnavailableTimeout, "--worker-unavailable-timeout");
|
|
8704
9033
|
const input = {
|
|
@@ -8708,7 +9037,7 @@ async function runQueuesUpdate(env, name, options) {
|
|
|
8708
9037
|
...timeout !== undefined ? { workerUnavailableTimeoutSeconds: timeout } : {}
|
|
8709
9038
|
};
|
|
8710
9039
|
if (Object.keys(input).length === 0) {
|
|
8711
|
-
throw new
|
|
9040
|
+
throw new CliUserError41("Nothing to change.", {
|
|
8712
9041
|
hint: "Give --description, --max-tasks-per-second, --clear-max-tasks-per-second or --worker-unavailable-timeout."
|
|
8713
9042
|
});
|
|
8714
9043
|
}
|
|
@@ -8787,7 +9116,7 @@ import { existsSync as existsSync14 } from "fs";
|
|
|
8787
9116
|
import { hostname } from "os";
|
|
8788
9117
|
import { extname as extname3, isAbsolute as isAbsolute3, join as join12, resolve as resolve11 } from "path";
|
|
8789
9118
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
8790
|
-
import { CliUserError as
|
|
9119
|
+
import { CliUserError as CliUserError42 } from "@burdenoff/cli-sdk/core";
|
|
8791
9120
|
function isRecord19(value) {
|
|
8792
9121
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8793
9122
|
}
|
|
@@ -8798,11 +9127,11 @@ function bridgeUrlFor(env, explicit, issued) {
|
|
|
8798
9127
|
try {
|
|
8799
9128
|
url = new URL(raw);
|
|
8800
9129
|
} catch {
|
|
8801
|
-
throw new
|
|
9130
|
+
throw new CliUserError42(`Invalid bridge URL '${raw}'.`);
|
|
8802
9131
|
}
|
|
8803
9132
|
const local = url.hostname === "localhost" || url.hostname === "127.0.0.1";
|
|
8804
9133
|
if (url.protocol !== "wss:" && !(url.protocol === "ws:" && local)) {
|
|
8805
|
-
throw new
|
|
9134
|
+
throw new CliUserError42(`The bridge URL must be wss:// (ws:// only to this machine): ${raw}`);
|
|
8806
9135
|
}
|
|
8807
9136
|
return url.toString();
|
|
8808
9137
|
}
|
|
@@ -8818,18 +9147,18 @@ function bridgeHeaders(env) {
|
|
|
8818
9147
|
const id = env.getEnv("FLUIDGRIDS_CF_ACCESS_CLIENT_ID")?.trim();
|
|
8819
9148
|
const secret = env.getEnv("FLUIDGRIDS_CF_ACCESS_CLIENT_SECRET")?.trim();
|
|
8820
9149
|
if ((id === undefined || id === "") !== (secret === undefined || secret === "")) {
|
|
8821
|
-
throw new
|
|
9150
|
+
throw new CliUserError42("Set both FLUIDGRIDS_CF_ACCESS_CLIENT_ID and FLUIDGRIDS_CF_ACCESS_CLIENT_SECRET, or neither.");
|
|
8822
9151
|
}
|
|
8823
9152
|
return id && secret ? { "CF-Access-Client-Id": id, "CF-Access-Client-Secret": secret } : {};
|
|
8824
9153
|
}
|
|
8825
9154
|
function workerToken(env, tokenEnv) {
|
|
8826
9155
|
const variable = tokenEnv?.trim() || WORKER_TOKEN_ENV;
|
|
8827
9156
|
if (!ENV_NAME2.test(variable)) {
|
|
8828
|
-
throw new
|
|
9157
|
+
throw new CliUserError42("Invalid environment variable name for --token-env.");
|
|
8829
9158
|
}
|
|
8830
9159
|
const token = env.getEnv(variable)?.trim() ?? "";
|
|
8831
9160
|
if (!WORKER_TOKEN.test(token)) {
|
|
8832
|
-
throw new
|
|
9161
|
+
throw new CliUserError42(`${variable} must hold a worker token (fgr_ and 43 characters).`, {
|
|
8833
9162
|
hint: "Issue one with `fluidgrids workers tokens create <name> --queue <queue>`."
|
|
8834
9163
|
});
|
|
8835
9164
|
}
|
|
@@ -8842,7 +9171,7 @@ async function buildWorkerBundle(project) {
|
|
|
8842
9171
|
explainUnresolved: (names) => [...names]
|
|
8843
9172
|
});
|
|
8844
9173
|
if (!lowered.workflows.some((workflow) => workflow.durable)) {
|
|
8845
|
-
throw new
|
|
9174
|
+
throw new CliUserError42("The project defines no durable functions for a worker to serve.");
|
|
8846
9175
|
}
|
|
8847
9176
|
await prepareProjectBundle(project, lowered);
|
|
8848
9177
|
return bundlePathOf(project);
|
|
@@ -8856,23 +9185,23 @@ function activitiesFor(project, raw) {
|
|
|
8856
9185
|
return;
|
|
8857
9186
|
const value = raw.trim();
|
|
8858
9187
|
if (value === "")
|
|
8859
|
-
throw new
|
|
9188
|
+
throw new CliUserError42("--activities cannot be empty.");
|
|
8860
9189
|
if (project.config.language === "py") {
|
|
8861
9190
|
if (!/^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$/.test(value)) {
|
|
8862
|
-
throw new
|
|
9191
|
+
throw new CliUserError42(`--activities for a Python project is a module name importable from the project (for example activities), not '${raw}'.`);
|
|
8863
9192
|
}
|
|
8864
9193
|
return value;
|
|
8865
9194
|
}
|
|
8866
9195
|
const path = isAbsolute3(value) ? value : resolve11(project.root, value);
|
|
8867
9196
|
if (!existsSync14(path))
|
|
8868
|
-
throw new
|
|
9197
|
+
throw new CliUserError42(`--activities: ${raw} not found.`);
|
|
8869
9198
|
return path;
|
|
8870
9199
|
}
|
|
8871
9200
|
function launchOf(settings) {
|
|
8872
9201
|
const { project, options } = settings;
|
|
8873
9202
|
const activities = activitiesFor(project, options.activities);
|
|
8874
9203
|
if (!settings.bundlePath && !activities) {
|
|
8875
|
-
throw new
|
|
9204
|
+
throw new CliUserError42("The worker would serve nothing: give workflows, --activities or both.");
|
|
8876
9205
|
}
|
|
8877
9206
|
const maxActivities = parsePositiveInt(options.maxConcurrentActivities, "--max-concurrent-activities");
|
|
8878
9207
|
const maxWorkflowTasks = parsePositiveInt(options.maxConcurrentWorkflowTasks, "--max-concurrent-workflow-tasks");
|
|
@@ -8905,7 +9234,7 @@ async function workflowBundle(project, options, build) {
|
|
|
8905
9234
|
if (!existsSync14(path)) {
|
|
8906
9235
|
if (options.activities !== undefined)
|
|
8907
9236
|
return;
|
|
8908
|
-
throw new
|
|
9237
|
+
throw new CliUserError42(`No workflow bundle at ${path}.`, {
|
|
8909
9238
|
hint: "Run `fluidgrids push` first, or pass --build to build it now (or --no-workflows)."
|
|
8910
9239
|
});
|
|
8911
9240
|
}
|
|
@@ -8914,7 +9243,7 @@ async function workflowBundle(project, options, build) {
|
|
|
8914
9243
|
async function runWorkerRun(env, options) {
|
|
8915
9244
|
const queues = bindWorkerQueues(parseList(options.queue).map(checkWorkerQueue), options.environment);
|
|
8916
9245
|
if (queues.length === 0)
|
|
8917
|
-
throw new
|
|
9246
|
+
throw new CliUserError42("Name the task queue(s) to serve with --queue.");
|
|
8918
9247
|
const project = loadProject(options.project, env.cwd());
|
|
8919
9248
|
const token = workerToken(env, options.tokenEnv);
|
|
8920
9249
|
const launch = launchOf({
|
|
@@ -8937,7 +9266,7 @@ function devQueueName() {
|
|
|
8937
9266
|
async function runDev(env, options) {
|
|
8938
9267
|
const project = loadProject(options.project, env.cwd());
|
|
8939
9268
|
if (options.lang !== undefined && options.lang !== project.config.language) {
|
|
8940
|
-
throw new
|
|
9269
|
+
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
9270
|
}
|
|
8942
9271
|
const bundlePath = await workflowBundle(project, options, options.workflows !== false);
|
|
8943
9272
|
const queueName = devQueueName();
|
|
@@ -9040,7 +9369,7 @@ async function loadTypeScriptActivities(root, path) {
|
|
|
9040
9369
|
}
|
|
9041
9370
|
}
|
|
9042
9371
|
if (found.length === 0) {
|
|
9043
|
-
throw new
|
|
9372
|
+
throw new CliUserError42(`${path} exports no activity implementations.`, {
|
|
9044
9373
|
hint: "Export `implementActivity(...)` or `defineActivity(...)` values from it."
|
|
9045
9374
|
});
|
|
9046
9375
|
}
|
|
@@ -9066,21 +9395,21 @@ async function runTypeScriptWorker(launch) {
|
|
|
9066
9395
|
}
|
|
9067
9396
|
function pythonWorkerExitError(python, code, signal) {
|
|
9068
9397
|
if (signal)
|
|
9069
|
-
return new
|
|
9398
|
+
return new CliUserError42(`The Python worker was stopped by ${signal}.`);
|
|
9070
9399
|
const status = String(code);
|
|
9071
9400
|
switch (code) {
|
|
9072
9401
|
case PYTHON_EXIT_NO_WORKER:
|
|
9073
|
-
return new
|
|
9402
|
+
return new CliUserError42(`The Python worker could not import fluidgrids_workflows.worker (status ${status}).`, {
|
|
9074
9403
|
hint: `Install the worker extra: \`${python} -m pip install 'fluidgrids-workflows[worker]'\`.`
|
|
9075
9404
|
});
|
|
9076
9405
|
case PYTHON_EXIT_NO_ACTIVITIES:
|
|
9077
|
-
return new
|
|
9406
|
+
return new CliUserError42(`The Python worker exited with status ${status}: the activities module defines no activities.`, {
|
|
9078
9407
|
hint: "Decorate the activities with @define_activity in the module --activities names, or pass the module that defines them."
|
|
9079
9408
|
});
|
|
9080
9409
|
case PYTHON_EXIT_BRIDGE_CLOSED:
|
|
9081
|
-
return new
|
|
9410
|
+
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
9411
|
default:
|
|
9083
|
-
return new
|
|
9412
|
+
return new CliUserError42(`The Python worker exited with status ${status}.`);
|
|
9084
9413
|
}
|
|
9085
9414
|
}
|
|
9086
9415
|
function pythonWorkerSpec(launch) {
|
|
@@ -9124,7 +9453,7 @@ function runPythonWorker(launch) {
|
|
|
9124
9453
|
};
|
|
9125
9454
|
child.on("error", (error) => {
|
|
9126
9455
|
done();
|
|
9127
|
-
reject(error.code === "ENOENT" ? new
|
|
9456
|
+
reject(error.code === "ENOENT" ? new CliUserError42(`Python interpreter "${python}" was not found.`) : new CliUserError42(`Could not start ${python}: ${error.message}`));
|
|
9128
9457
|
});
|
|
9129
9458
|
child.on("close", (code, signal) => {
|
|
9130
9459
|
done();
|
|
@@ -9206,7 +9535,7 @@ except BridgeClosedError as error:
|
|
|
9206
9535
|
});
|
|
9207
9536
|
|
|
9208
9537
|
// src/phase-c/shared.ts
|
|
9209
|
-
import { CliUserError as
|
|
9538
|
+
import { CliUserError as CliUserError43 } from "@burdenoff/cli-sdk/core";
|
|
9210
9539
|
function phaseCEnv(env) {
|
|
9211
9540
|
return {
|
|
9212
9541
|
...env,
|
|
@@ -9219,32 +9548,32 @@ async function requireConfirmation(env, question, force) {
|
|
|
9219
9548
|
if (force)
|
|
9220
9549
|
return;
|
|
9221
9550
|
if (!env.interactive()) {
|
|
9222
|
-
throw new
|
|
9551
|
+
throw new CliUserError43(`${question} needs confirmation.`, {
|
|
9223
9552
|
hint: "Pass --force to go ahead without a prompt."
|
|
9224
9553
|
});
|
|
9225
9554
|
}
|
|
9226
9555
|
if (!await env.confirm(question))
|
|
9227
|
-
throw new
|
|
9556
|
+
throw new CliUserError43("Aborted: nothing was changed.");
|
|
9228
9557
|
}
|
|
9229
9558
|
function runSelectorOf(runId, flags) {
|
|
9230
9559
|
const targeted = flags.workflowId !== undefined || flags.key !== undefined || flags.firstRunId !== undefined;
|
|
9231
9560
|
if (!targeted) {
|
|
9232
9561
|
if (runId === undefined || runId.trim() === "") {
|
|
9233
|
-
throw new
|
|
9562
|
+
throw new CliUserError43("Give a run id, or --workflow-id with --key.");
|
|
9234
9563
|
}
|
|
9235
9564
|
return { runId: runId.trim() };
|
|
9236
9565
|
}
|
|
9237
9566
|
if (runId !== undefined) {
|
|
9238
|
-
throw new
|
|
9567
|
+
throw new CliUserError43("Give a run id or --workflow-id with --key, not both.");
|
|
9239
9568
|
}
|
|
9240
9569
|
const workflowId = flags.workflowId?.trim() ?? "";
|
|
9241
9570
|
const key = flags.key?.trim() ?? "";
|
|
9242
9571
|
if (workflowId === "" || key === "") {
|
|
9243
|
-
throw new
|
|
9572
|
+
throw new CliUserError43("--workflow-id and --key go together (the workflow id of that key).");
|
|
9244
9573
|
}
|
|
9245
9574
|
const firstRunId = flags.firstRunId?.trim();
|
|
9246
9575
|
if (flags.firstRunId !== undefined && !firstRunId) {
|
|
9247
|
-
throw new
|
|
9576
|
+
throw new CliUserError43("--first-run-id cannot be empty.");
|
|
9248
9577
|
}
|
|
9249
9578
|
return {
|
|
9250
9579
|
target: { workflowKey: key, workflowId, ...firstRunId ? { firstRunId } : {} }
|
|
@@ -9260,7 +9589,7 @@ function parseEnumOption(raw, flag, allowed) {
|
|
|
9260
9589
|
const match = allowed.find((value) => value === normal);
|
|
9261
9590
|
if (match === undefined) {
|
|
9262
9591
|
const shown = allowed.map((value) => value.toLowerCase().replace(/_/g, "-"));
|
|
9263
|
-
throw new
|
|
9592
|
+
throw new CliUserError43(`Invalid value '${raw}' for ${flag}. Allowed: ${shown.join(", ")}`);
|
|
9264
9593
|
}
|
|
9265
9594
|
return match;
|
|
9266
9595
|
}
|
|
@@ -9269,7 +9598,7 @@ function parseNonNegativeInt(raw, flag) {
|
|
|
9269
9598
|
return;
|
|
9270
9599
|
const value = raw.trim();
|
|
9271
9600
|
if (!/^\d+$/.test(value) || !Number.isSafeInteger(Number(value))) {
|
|
9272
|
-
throw new
|
|
9601
|
+
throw new CliUserError43(`Invalid value '${raw}' for ${flag}: expected a whole number.`);
|
|
9273
9602
|
}
|
|
9274
9603
|
return Number(value);
|
|
9275
9604
|
}
|
|
@@ -9278,14 +9607,14 @@ function parseNumberOption(raw, flag) {
|
|
|
9278
9607
|
return;
|
|
9279
9608
|
const value = Number(raw.trim());
|
|
9280
9609
|
if (raw.trim() === "" || !Number.isFinite(value)) {
|
|
9281
|
-
throw new
|
|
9610
|
+
throw new CliUserError43(`Invalid value '${raw}' for ${flag}: expected a number.`);
|
|
9282
9611
|
}
|
|
9283
9612
|
return value;
|
|
9284
9613
|
}
|
|
9285
9614
|
function requireText(raw, flag) {
|
|
9286
9615
|
const value = raw?.trim() ?? "";
|
|
9287
9616
|
if (value === "")
|
|
9288
|
-
throw new
|
|
9617
|
+
throw new CliUserError43(`${flag} is required.`);
|
|
9289
9618
|
return value;
|
|
9290
9619
|
}
|
|
9291
9620
|
function parseList(raw) {
|
|
@@ -9315,7 +9644,7 @@ function parseInstant(raw, flag) {
|
|
|
9315
9644
|
const value = raw.trim();
|
|
9316
9645
|
const ms = Date.parse(value);
|
|
9317
9646
|
if (value === "" || !Number.isFinite(ms) || !/^\d{4}-\d{2}-\d{2}/.test(value)) {
|
|
9318
|
-
throw new
|
|
9647
|
+
throw new CliUserError43(`Invalid value '${raw}' for ${flag}: expected an ISO-8601 date and time such as 2026-10-01T00:00:00Z.`);
|
|
9319
9648
|
}
|
|
9320
9649
|
return new Date(ms).toISOString();
|
|
9321
9650
|
}
|
|
@@ -9325,7 +9654,7 @@ var init_shared3 = __esm(() => {
|
|
|
9325
9654
|
});
|
|
9326
9655
|
|
|
9327
9656
|
// src/config/commands.ts
|
|
9328
|
-
import { CliUserError as
|
|
9657
|
+
import { CliUserError as CliUserError44 } from "@burdenoff/cli-sdk/core";
|
|
9329
9658
|
function output(env, options, data, rows, headers) {
|
|
9330
9659
|
env.ctx.output.formatAndOutput(options, data, { headers, rows });
|
|
9331
9660
|
}
|
|
@@ -9341,7 +9670,7 @@ function isLocal(url) {
|
|
|
9341
9670
|
function checkProfileValue(key, value, profile) {
|
|
9342
9671
|
const trimmed = value.trim();
|
|
9343
9672
|
if (trimmed === "" || trimmed.length > 2048) {
|
|
9344
|
-
throw new
|
|
9673
|
+
throw new CliUserError44(`${key} must be 1 to 2048 characters.`);
|
|
9345
9674
|
}
|
|
9346
9675
|
switch (key) {
|
|
9347
9676
|
case "apiUrl":
|
|
@@ -9350,20 +9679,20 @@ function checkProfileValue(key, value, profile) {
|
|
|
9350
9679
|
try {
|
|
9351
9680
|
url = new URL(trimmed);
|
|
9352
9681
|
} catch {
|
|
9353
|
-
throw new
|
|
9682
|
+
throw new CliUserError44(`${key} must be a URL.`);
|
|
9354
9683
|
}
|
|
9355
9684
|
if (url.protocol !== "https:" && !(url.protocol === "http:" && isLocal(url))) {
|
|
9356
|
-
throw new
|
|
9685
|
+
throw new CliUserError44(`${key} must use https (http only for localhost).`);
|
|
9357
9686
|
}
|
|
9358
9687
|
if (url.username || url.password) {
|
|
9359
|
-
throw new
|
|
9688
|
+
throw new CliUserError44(`${key} must not carry credentials.`);
|
|
9360
9689
|
}
|
|
9361
9690
|
return trimmed;
|
|
9362
9691
|
}
|
|
9363
9692
|
case "environment": {
|
|
9364
9693
|
const upper = trimmed.toUpperCase();
|
|
9365
9694
|
if (!ENVIRONMENTS4.includes(upper)) {
|
|
9366
|
-
throw new
|
|
9695
|
+
throw new CliUserError44(`environment must be one of ${ENVIRONMENTS4.join(", ")}.`);
|
|
9367
9696
|
}
|
|
9368
9697
|
return upper;
|
|
9369
9698
|
}
|
|
@@ -9377,15 +9706,15 @@ function checkProfileValue(key, value, profile) {
|
|
|
9377
9706
|
async function readToken(env, fromEnv) {
|
|
9378
9707
|
if (fromEnv !== undefined) {
|
|
9379
9708
|
if (!ENV_NAME3.test(fromEnv))
|
|
9380
|
-
throw new
|
|
9709
|
+
throw new CliUserError44("Invalid environment variable name for --from-env.");
|
|
9381
9710
|
const value = env.env[fromEnv]?.trim() ?? "";
|
|
9382
9711
|
if (value === "")
|
|
9383
|
-
throw new
|
|
9712
|
+
throw new CliUserError44(`The environment variable ${fromEnv} is empty or unset.`);
|
|
9384
9713
|
return value;
|
|
9385
9714
|
}
|
|
9386
9715
|
const piped = (await env.readStdin()).trim();
|
|
9387
9716
|
if (piped === "") {
|
|
9388
|
-
throw new
|
|
9717
|
+
throw new CliUserError44("Pipe the token on standard input, or pass --from-env <VAR>.", {
|
|
9389
9718
|
hint: 'For example: `printf %s "$TOKEN" | fluidgrids config set token --profile prod`.'
|
|
9390
9719
|
});
|
|
9391
9720
|
}
|
|
@@ -9405,7 +9734,7 @@ async function runConfigSet(env, key, value, options) {
|
|
|
9405
9734
|
const profile = profileName(env, options);
|
|
9406
9735
|
if (key === "token") {
|
|
9407
9736
|
if (value !== undefined) {
|
|
9408
|
-
throw new
|
|
9737
|
+
throw new CliUserError44("A token is never given on the command line.", {
|
|
9409
9738
|
hint: "Pipe it on standard input, or pass --from-env <VAR>."
|
|
9410
9739
|
});
|
|
9411
9740
|
}
|
|
@@ -9422,12 +9751,12 @@ async function runConfigSet(env, key, value, options) {
|
|
|
9422
9751
|
return out;
|
|
9423
9752
|
}
|
|
9424
9753
|
if (!isProfileKey(key)) {
|
|
9425
|
-
throw new
|
|
9754
|
+
throw new CliUserError44(`Unknown profile key ${key}.`, {
|
|
9426
9755
|
hint: `Keys: ${PROFILE_KEYS.join(", ")}, token, defaultProfile.`
|
|
9427
9756
|
});
|
|
9428
9757
|
}
|
|
9429
9758
|
if (value === undefined)
|
|
9430
|
-
throw new
|
|
9759
|
+
throw new CliUserError44(`Give a value for ${key}.`);
|
|
9431
9760
|
const checked = checkProfileValue(key, value, profile);
|
|
9432
9761
|
updateConfig(file, (document) => {
|
|
9433
9762
|
const table = profileTable(document, profile, true);
|
|
@@ -9443,7 +9772,7 @@ async function runConfigGet(env, key, options) {
|
|
|
9443
9772
|
const config = readConfig(file);
|
|
9444
9773
|
const resolved = resolveProfile(config, env.env, options.profile, file);
|
|
9445
9774
|
if (key !== undefined && !isProfileKey(key)) {
|
|
9446
|
-
throw new
|
|
9775
|
+
throw new CliUserError44(`Unknown profile key ${key}.`, {
|
|
9447
9776
|
hint: `Keys: ${PROFILE_KEYS.join(", ")}.`
|
|
9448
9777
|
});
|
|
9449
9778
|
}
|
|
@@ -9488,10 +9817,10 @@ async function runConfigDelete(env, key, options) {
|
|
|
9488
9817
|
const profile = profileName(env, options);
|
|
9489
9818
|
const existing = readConfig(file).profiles[profile];
|
|
9490
9819
|
if (existing === undefined)
|
|
9491
|
-
throw new
|
|
9820
|
+
throw new CliUserError44(`There is no profile ${profile} in ${file}.`);
|
|
9492
9821
|
if (key !== undefined) {
|
|
9493
9822
|
if (!isProfileKey(key))
|
|
9494
|
-
throw new
|
|
9823
|
+
throw new CliUserError44(`Unknown profile key ${key}.`);
|
|
9495
9824
|
updateConfig(file, (document) => {
|
|
9496
9825
|
const table = profileTable(document, profile, false);
|
|
9497
9826
|
if (table)
|
|
@@ -9528,7 +9857,7 @@ async function runConfigMigrate(env, options) {
|
|
|
9528
9857
|
values.workspace = workspace;
|
|
9529
9858
|
if (options.tokenEnv !== undefined) {
|
|
9530
9859
|
if (!ENV_NAME3.test(options.tokenEnv))
|
|
9531
|
-
throw new
|
|
9860
|
+
throw new CliUserError44("Invalid environment variable name for --token-env.");
|
|
9532
9861
|
values.tokenRef = `env:${options.tokenEnv}`;
|
|
9533
9862
|
}
|
|
9534
9863
|
updateConfig(file, (document) => {
|
|
@@ -9553,7 +9882,7 @@ var init_commands = __esm(() => {
|
|
|
9553
9882
|
});
|
|
9554
9883
|
|
|
9555
9884
|
// src/phase-c/commands/workers.ts
|
|
9556
|
-
import { CliUserError as
|
|
9885
|
+
import { CliUserError as CliUserError45 } from "@burdenoff/cli-sdk/core";
|
|
9557
9886
|
function workerRows(workers) {
|
|
9558
9887
|
return workers.map((worker) => [
|
|
9559
9888
|
worker.identity,
|
|
@@ -9567,7 +9896,7 @@ function workerRows(workers) {
|
|
|
9567
9896
|
}
|
|
9568
9897
|
async function runWorkersList(env, options) {
|
|
9569
9898
|
if (options.stale && options.notStale) {
|
|
9570
|
-
throw new
|
|
9899
|
+
throw new CliUserError45("Give --stale or --not-stale, not both.");
|
|
9571
9900
|
}
|
|
9572
9901
|
const filter = {
|
|
9573
9902
|
...options.queue ? { taskQueue: checkWorkerQueue(options.queue) } : {},
|
|
@@ -9610,7 +9939,7 @@ function connectionNames(raw) {
|
|
|
9610
9939
|
const names = parseList(raw);
|
|
9611
9940
|
for (const name of names) {
|
|
9612
9941
|
if (!CONNECTION_NAME.test(name)) {
|
|
9613
|
-
throw new
|
|
9942
|
+
throw new CliUserError45(`Invalid connection name '${name}'.`);
|
|
9614
9943
|
}
|
|
9615
9944
|
}
|
|
9616
9945
|
return names;
|
|
@@ -9625,10 +9954,10 @@ function issued(env, options, result) {
|
|
|
9625
9954
|
async function runTokensCreate(env, name, options) {
|
|
9626
9955
|
const tokenName = name.trim();
|
|
9627
9956
|
if (tokenName === "")
|
|
9628
|
-
throw new
|
|
9957
|
+
throw new CliUserError45("A worker token needs a name.");
|
|
9629
9958
|
const taskQueues = parseList(options.queue).map(checkWorkerQueue);
|
|
9630
9959
|
if (taskQueues.length === 0) {
|
|
9631
|
-
throw new
|
|
9960
|
+
throw new CliUserError45("A worker token needs at least one --queue.", {
|
|
9632
9961
|
hint: "Create the queue first with `fluidgrids queues create <name>`."
|
|
9633
9962
|
});
|
|
9634
9963
|
}
|
|
@@ -9657,10 +9986,10 @@ async function runTokensDelete(env, id, options) {
|
|
|
9657
9986
|
async function runTokensAllowConnections(env, id, names, options) {
|
|
9658
9987
|
const list = connectionNames(names);
|
|
9659
9988
|
if (list.length === 0 && !options.clear) {
|
|
9660
|
-
throw new
|
|
9989
|
+
throw new CliUserError45("Name the connections to allow, or pass --clear to allow none.");
|
|
9661
9990
|
}
|
|
9662
9991
|
if (list.length > 0 && options.clear) {
|
|
9663
|
-
throw new
|
|
9992
|
+
throw new CliUserError45("Give connection names or --clear, not both.");
|
|
9664
9993
|
}
|
|
9665
9994
|
const token = await env.pc.setWorkerTokenConnectionAllowlist(id, list);
|
|
9666
9995
|
emit(env, options, token, { headers: TOKEN_HEADERS, rows: [tokenRow(token)] }, [
|
|
@@ -9680,17 +10009,17 @@ var init_workers = __esm(() => {
|
|
|
9680
10009
|
|
|
9681
10010
|
// src/phase-c/commands/run-control.ts
|
|
9682
10011
|
import { randomUUID } from "crypto";
|
|
9683
|
-
import { CliUserError as
|
|
10012
|
+
import { CliUserError as CliUserError46 } from "@burdenoff/cli-sdk/core";
|
|
9684
10013
|
function runAndName(first, second, flags) {
|
|
9685
10014
|
const targeted = flags.workflowId !== undefined || flags.key !== undefined;
|
|
9686
10015
|
if (targeted) {
|
|
9687
10016
|
if (second !== undefined) {
|
|
9688
|
-
throw new
|
|
10017
|
+
throw new CliUserError46("With --workflow-id, give only the name: `<name> --workflow-id <id> --key <key>`.");
|
|
9689
10018
|
}
|
|
9690
10019
|
return { run: runSelectorOf(undefined, flags), name: first };
|
|
9691
10020
|
}
|
|
9692
10021
|
if (second === undefined) {
|
|
9693
|
-
throw new
|
|
10022
|
+
throw new CliUserError46("Give the run id and the name: `<runId> <name>`.");
|
|
9694
10023
|
}
|
|
9695
10024
|
return { run: runSelectorOf(first, flags), name: second };
|
|
9696
10025
|
}
|
|
@@ -9704,7 +10033,7 @@ async function runQuery(env, first, second, options) {
|
|
|
9704
10033
|
rows: [[result.name, String(result.rejected), JSON.stringify(result.value ?? null)]]
|
|
9705
10034
|
}, result.error ? [`error: ${result.error}`] : []);
|
|
9706
10035
|
if (result.rejected) {
|
|
9707
|
-
throw new
|
|
10036
|
+
throw new CliUserError46(`The query ${name} was refused: ${result.error ?? "no reason given"}`);
|
|
9708
10037
|
}
|
|
9709
10038
|
return result;
|
|
9710
10039
|
}
|
|
@@ -9746,13 +10075,13 @@ async function runUpdate(env, first, second, options) {
|
|
|
9746
10075
|
rows: [[result.updateId, result.name, result.status, JSON.stringify(result.result ?? null)]]
|
|
9747
10076
|
});
|
|
9748
10077
|
if (!reached(result.status, waitFor)) {
|
|
9749
|
-
throw new
|
|
10078
|
+
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
10079
|
}
|
|
9751
10080
|
if (result.status === "REJECTED") {
|
|
9752
|
-
throw new
|
|
10081
|
+
throw new CliUserError46(`The update ${name} was rejected: ${failureMessage(result.failure)}`);
|
|
9753
10082
|
}
|
|
9754
10083
|
if (result.status === "COMPLETED" && result.failure !== null && result.failure !== undefined) {
|
|
9755
|
-
throw new
|
|
10084
|
+
throw new CliUserError46(`The update handler of ${name} failed: ${failureMessage(result.failure)}`);
|
|
9756
10085
|
}
|
|
9757
10086
|
return result;
|
|
9758
10087
|
}
|
|
@@ -9768,33 +10097,33 @@ async function runUpdateStatus(env, first, second, options) {
|
|
|
9768
10097
|
function parseResetTo(raw, buildId) {
|
|
9769
10098
|
const value = raw?.trim() ?? "";
|
|
9770
10099
|
if (value === "") {
|
|
9771
|
-
throw new
|
|
10100
|
+
throw new CliUserError46("--to is required: a history seq, first-task, last-task, last-continue-as-new, build-id or last-clean-task.");
|
|
9772
10101
|
}
|
|
9773
10102
|
if (/^\d+$/.test(value)) {
|
|
9774
10103
|
if (buildId !== undefined)
|
|
9775
|
-
throw new
|
|
10104
|
+
throw new CliUserError46("--build-id goes with --to build-id only.");
|
|
9776
10105
|
const seq = Number(value);
|
|
9777
10106
|
if (!Number.isSafeInteger(seq) || seq <= 0) {
|
|
9778
|
-
throw new
|
|
10107
|
+
throw new CliUserError46(`Invalid value '${raw}' for --to: a seq is a positive integer.`);
|
|
9779
10108
|
}
|
|
9780
10109
|
return { seq };
|
|
9781
10110
|
}
|
|
9782
10111
|
const normal = value.toUpperCase().replace(/-/g, "_");
|
|
9783
10112
|
if (normal === "LAST_CLEAN_TASK") {
|
|
9784
10113
|
if (buildId !== undefined)
|
|
9785
|
-
throw new
|
|
10114
|
+
throw new CliUserError46("--build-id goes with --to build-id only.");
|
|
9786
10115
|
return "LAST_CLEAN_TASK";
|
|
9787
10116
|
}
|
|
9788
10117
|
const type = parseEnumOption(normal === "LAST_CONTINUE_AS_NEW" ? "LAST_CONTINUED_AS_NEW" : normal, "--to", RESET_TYPES);
|
|
9789
10118
|
if (type === "BUILD_ID") {
|
|
9790
10119
|
const id = buildId?.trim() ?? "";
|
|
9791
10120
|
if (!/^sha256:[0-9a-f]{64}$/.test(id)) {
|
|
9792
|
-
throw new
|
|
10121
|
+
throw new CliUserError46("--to build-id needs --build-id sha256:<64 hex>.");
|
|
9793
10122
|
}
|
|
9794
10123
|
return { type, buildId: id };
|
|
9795
10124
|
}
|
|
9796
10125
|
if (buildId !== undefined)
|
|
9797
|
-
throw new
|
|
10126
|
+
throw new CliUserError46("--build-id goes with --to build-id only.");
|
|
9798
10127
|
return { type };
|
|
9799
10128
|
}
|
|
9800
10129
|
async function runReset(env, runId, options) {
|
|
@@ -9853,7 +10182,7 @@ async function runTrace(env, runIdArg, options) {
|
|
|
9853
10182
|
const runId = await env.pc.runIdOf(runSelectorOf(runIdArg, options));
|
|
9854
10183
|
const hierarchy = await env.pc.runHierarchy(runId);
|
|
9855
10184
|
if (!hierarchy)
|
|
9856
|
-
throw new
|
|
10185
|
+
throw new CliUserError46(`Run ${runId} not found (NOT_FOUND)`);
|
|
9857
10186
|
const entries = flatten(hierarchy);
|
|
9858
10187
|
const open = entries.filter((entry) => OPEN_STATUSES.includes(entry.run.status));
|
|
9859
10188
|
const read = new Map;
|
|
@@ -9893,32 +10222,32 @@ var init_run_control = __esm(() => {
|
|
|
9893
10222
|
});
|
|
9894
10223
|
|
|
9895
10224
|
// src/phase-c/commands/activities.ts
|
|
9896
|
-
import { CliUserError as
|
|
10225
|
+
import { CliUserError as CliUserError47 } from "@burdenoff/cli-sdk/core";
|
|
9897
10226
|
import { durationMs as durationMs2 } from "@fluidgrids/workflows/ir";
|
|
9898
10227
|
function completionOf(env, first, second, options) {
|
|
9899
10228
|
if (options.taskTokenEnv !== undefined) {
|
|
9900
10229
|
if (first !== undefined || options.workflowId !== undefined || options.key !== undefined) {
|
|
9901
|
-
throw new
|
|
10230
|
+
throw new CliUserError47("Give --task-token-env, or the run and activity id, not both.");
|
|
9902
10231
|
}
|
|
9903
10232
|
const variable = options.taskTokenEnv.trim();
|
|
9904
10233
|
if (!ENV_NAME4.test(variable)) {
|
|
9905
|
-
throw new
|
|
10234
|
+
throw new CliUserError47("Invalid environment variable name for --task-token-env.");
|
|
9906
10235
|
}
|
|
9907
10236
|
const taskToken = env.getEnv(variable)?.trim() ?? "";
|
|
9908
10237
|
if (taskToken === "") {
|
|
9909
|
-
throw new
|
|
10238
|
+
throw new CliUserError47(`The environment variable ${variable} (--task-token-env) is empty or unset.`);
|
|
9910
10239
|
}
|
|
9911
10240
|
return { kind: "token", taskToken };
|
|
9912
10241
|
}
|
|
9913
10242
|
const targeted = options.workflowId !== undefined || options.key !== undefined;
|
|
9914
10243
|
if (targeted) {
|
|
9915
10244
|
if (first === undefined || second !== undefined) {
|
|
9916
|
-
throw new
|
|
10245
|
+
throw new CliUserError47("With --workflow-id, give only the activity id.");
|
|
9917
10246
|
}
|
|
9918
10247
|
return { kind: "id", run: runSelectorOf(undefined, options), activityId: first };
|
|
9919
10248
|
}
|
|
9920
10249
|
if (first === undefined || second === undefined) {
|
|
9921
|
-
throw new
|
|
10250
|
+
throw new CliUserError47("Give `<runId> <activityId>`, `<activityId> --workflow-id <id> --key <key>`, or --task-token-env.");
|
|
9922
10251
|
}
|
|
9923
10252
|
return { kind: "id", run: runSelectorOf(first, options), activityId: second };
|
|
9924
10253
|
}
|
|
@@ -9976,7 +10305,7 @@ function selectorOf(options) {
|
|
|
9976
10305
|
options.all === true
|
|
9977
10306
|
];
|
|
9978
10307
|
if (given.filter(Boolean).length !== 1) {
|
|
9979
|
-
throw new
|
|
10308
|
+
throw new CliUserError47("Choose the activities with exactly one of --activity-id, --type or --all.");
|
|
9980
10309
|
}
|
|
9981
10310
|
if (options.activityId !== undefined) {
|
|
9982
10311
|
return { activityId: requireText(options.activityId, "--activity-id") };
|
|
@@ -10017,18 +10346,18 @@ function parseMs(raw, flag) {
|
|
|
10017
10346
|
const value = raw.trim();
|
|
10018
10347
|
const ms = /^\d+$/.test(value) ? Number(value) : value === "" ? undefined : durationMs2(value, "ms");
|
|
10019
10348
|
if (ms === undefined || !Number.isFinite(ms) || ms <= 0 || !Number.isSafeInteger(Math.round(ms))) {
|
|
10020
|
-
throw new
|
|
10349
|
+
throw new CliUserError47(`Invalid value '${raw}' for ${flag}: expected milliseconds or a duration such as 1.5s, 5m or PT2H.`);
|
|
10021
10350
|
}
|
|
10022
10351
|
return Math.round(ms);
|
|
10023
10352
|
}
|
|
10024
10353
|
function activityOptionsOf(options) {
|
|
10025
10354
|
const maxRetries = options.maxRetries === undefined ? undefined : /^\d+$/.test(options.maxRetries.trim()) ? Number(options.maxRetries.trim()) : NaN;
|
|
10026
10355
|
if (Number.isNaN(maxRetries)) {
|
|
10027
|
-
throw new
|
|
10356
|
+
throw new CliUserError47(`Invalid value '${options.maxRetries}' for --max-retries.`);
|
|
10028
10357
|
}
|
|
10029
10358
|
const backoff = options.backoff === undefined ? undefined : Number(options.backoff.trim());
|
|
10030
10359
|
if (backoff !== undefined && (!Number.isFinite(backoff) || backoff < 1)) {
|
|
10031
|
-
throw new
|
|
10360
|
+
throw new CliUserError47(`Invalid value '${options.backoff}' for --backoff: at least 1.`);
|
|
10032
10361
|
}
|
|
10033
10362
|
const retryOn = [];
|
|
10034
10363
|
for (const value of parseList(options.retryOn)) {
|
|
@@ -10052,7 +10381,7 @@ function activityOptionsOf(options) {
|
|
|
10052
10381
|
};
|
|
10053
10382
|
const out = { ...timeouts, ...Object.keys(retry).length > 0 ? { retry } : {} };
|
|
10054
10383
|
if (Object.keys(out).length === 0) {
|
|
10055
|
-
throw new
|
|
10384
|
+
throw new CliUserError47("Nothing to change: give a retry option or a timeout.");
|
|
10056
10385
|
}
|
|
10057
10386
|
return out;
|
|
10058
10387
|
}
|
|
@@ -10079,10 +10408,10 @@ async function runPauseRulesList(env, options) {
|
|
|
10079
10408
|
}
|
|
10080
10409
|
async function runPauseRulesCreate(env, options) {
|
|
10081
10410
|
if (options.activityType === undefined && options.nodeType === undefined && options.workflowKey === undefined) {
|
|
10082
|
-
throw new
|
|
10411
|
+
throw new CliUserError47("A pause rule needs --activity-type, --node-type or --workflow-key.");
|
|
10083
10412
|
}
|
|
10084
10413
|
if (options.expiresAt !== undefined && options.expiresIn !== undefined) {
|
|
10085
|
-
throw new
|
|
10414
|
+
throw new CliUserError47("Give --expires-at or --expires-in, not both.");
|
|
10086
10415
|
}
|
|
10087
10416
|
const expiresIn = parseMs(options.expiresIn, "--expires-in");
|
|
10088
10417
|
const expiresAt = expiresIn !== undefined ? new Date(Date.now() + expiresIn).toISOString() : parseInstant(options.expiresAt, "--expires-at");
|
|
@@ -10120,7 +10449,7 @@ var init_activities = __esm(() => {
|
|
|
10120
10449
|
});
|
|
10121
10450
|
|
|
10122
10451
|
// src/phase-c/commands/batch.ts
|
|
10123
|
-
import { CliUserError as
|
|
10452
|
+
import { CliUserError as CliUserError48 } from "@burdenoff/cli-sdk/core";
|
|
10124
10453
|
function isBatchType(name) {
|
|
10125
10454
|
return Object.hasOwn(BATCH_TYPES, name);
|
|
10126
10455
|
}
|
|
@@ -10133,7 +10462,7 @@ function batchSelection(options) {
|
|
|
10133
10462
|
if (options.filter !== undefined) {
|
|
10134
10463
|
const raw = parseJsonOption(options.filter, "--filter");
|
|
10135
10464
|
if (!isRecord20(raw))
|
|
10136
|
-
throw new
|
|
10465
|
+
throw new CliUserError48("--filter must be a JSON object (ListWorkflowRunsInput).");
|
|
10137
10466
|
Object.assign(filter, raw);
|
|
10138
10467
|
delete filter["limit"];
|
|
10139
10468
|
delete filter["offset"];
|
|
@@ -10153,19 +10482,19 @@ function batchSelection(options) {
|
|
|
10153
10482
|
if (options.searchAttributes !== undefined) {
|
|
10154
10483
|
const query = parseJsonOption(options.searchAttributes, "--search-attributes");
|
|
10155
10484
|
if (!isRecord20(query)) {
|
|
10156
|
-
throw new
|
|
10485
|
+
throw new CliUserError48("--search-attributes must be a JSON object ({and, or, text}).");
|
|
10157
10486
|
}
|
|
10158
10487
|
filter["searchAttributes"] = query;
|
|
10159
10488
|
}
|
|
10160
10489
|
const filtered = Object.keys(filter).length > 0;
|
|
10161
10490
|
if (runIds.length > 0 && filtered) {
|
|
10162
|
-
throw new
|
|
10491
|
+
throw new CliUserError48("Choose the runs with --run-id or with filter options, not both.");
|
|
10163
10492
|
}
|
|
10164
10493
|
if (runIds.length > MAX_BATCH_RUN_IDS) {
|
|
10165
|
-
throw new
|
|
10494
|
+
throw new CliUserError48(`At most ${MAX_BATCH_RUN_IDS} --run-id values; use a filter for more.`);
|
|
10166
10495
|
}
|
|
10167
10496
|
if (runIds.length === 0 && !filtered) {
|
|
10168
|
-
throw new
|
|
10497
|
+
throw new CliUserError48("Choose the runs: --run-id, or a filter (--key, --status, --kind, --workflow-id, --search-attributes, --filter).");
|
|
10169
10498
|
}
|
|
10170
10499
|
const rate = parsePositiveInt(options.rate, "--rate");
|
|
10171
10500
|
return {
|
|
@@ -10227,7 +10556,7 @@ function batchPayload(type, options) {
|
|
|
10227
10556
|
options.clearOverride === true
|
|
10228
10557
|
];
|
|
10229
10558
|
if (chosen.filter(Boolean).length !== 1) {
|
|
10230
|
-
throw new
|
|
10559
|
+
throw new CliUserError48("Give exactly one of --pin <version>, --auto-upgrade or --clear-override.");
|
|
10231
10560
|
}
|
|
10232
10561
|
if (options.clearOverride)
|
|
10233
10562
|
return { clearVersioningOverride: true };
|
|
@@ -10261,7 +10590,7 @@ function refuseUnused(type, options) {
|
|
|
10261
10590
|
unused.push("--activity-id/--type/--all");
|
|
10262
10591
|
}
|
|
10263
10592
|
if (unused.length > 0) {
|
|
10264
|
-
throw new
|
|
10593
|
+
throw new CliUserError48(`${unused.join(", ")} do not apply to a ${type} batch.`);
|
|
10265
10594
|
}
|
|
10266
10595
|
}
|
|
10267
10596
|
function jobRow(job) {
|
|
@@ -10289,7 +10618,7 @@ function jobDetails(job) {
|
|
|
10289
10618
|
}
|
|
10290
10619
|
async function runBatchStart(env, typeName, options) {
|
|
10291
10620
|
if (!isBatchType(typeName)) {
|
|
10292
|
-
throw new
|
|
10621
|
+
throw new CliUserError48(`Unknown batch type '${typeName}'. Allowed: ${Object.keys(BATCH_TYPES).join(", ")}`);
|
|
10293
10622
|
}
|
|
10294
10623
|
const type = BATCH_TYPES[typeName];
|
|
10295
10624
|
refuseUnused(type, options);
|
|
@@ -10339,10 +10668,10 @@ async function runBatchDescribe(env, id, options) {
|
|
|
10339
10668
|
}
|
|
10340
10669
|
emit(env, options, job, { headers: JOB_HEADERS, rows: [jobRow(job)] }, jobDetails(job));
|
|
10341
10670
|
if (options.watch && !TERMINAL_JOB.includes(job.status)) {
|
|
10342
|
-
throw new
|
|
10671
|
+
throw new CliUserError48(`Batch job ${id} is still ${job.status} after ${timeout} ms.`);
|
|
10343
10672
|
}
|
|
10344
10673
|
if (options.watch && (job.status === "FAILED" || job.status === "CANCELLED")) {
|
|
10345
|
-
throw new
|
|
10674
|
+
throw new CliUserError48(`Batch job ${id} ended ${job.status}${job.failureMessage ? `: ${job.failureMessage}` : ""}.`);
|
|
10346
10675
|
}
|
|
10347
10676
|
return job;
|
|
10348
10677
|
}
|
|
@@ -10386,7 +10715,7 @@ var init_batch = __esm(() => {
|
|
|
10386
10715
|
});
|
|
10387
10716
|
|
|
10388
10717
|
// src/phase-d/duration.ts
|
|
10389
|
-
import { CliUserError as
|
|
10718
|
+
import { CliUserError as CliUserError49 } from "@burdenoff/cli-sdk/core";
|
|
10390
10719
|
import { toMs } from "@fluidgrids/workflows";
|
|
10391
10720
|
function parseDurationOption(raw, flag) {
|
|
10392
10721
|
if (raw === undefined)
|
|
@@ -10396,7 +10725,7 @@ function parseDurationOption(raw, flag) {
|
|
|
10396
10725
|
try {
|
|
10397
10726
|
toMs(sent, flag);
|
|
10398
10727
|
} catch {
|
|
10399
|
-
throw new
|
|
10728
|
+
throw new CliUserError49(`Invalid value '${raw}' for ${flag}: expected a duration such as 1500 (milliseconds), 30s, 5m, 2h or PT2H.`);
|
|
10400
10729
|
}
|
|
10401
10730
|
return sent;
|
|
10402
10731
|
}
|
|
@@ -10405,14 +10734,14 @@ var init_duration = () => {};
|
|
|
10405
10734
|
// src/phase-d/commands/activity-start.ts
|
|
10406
10735
|
import { existsSync as existsSync15, readFileSync as readFileSync12 } from "fs";
|
|
10407
10736
|
import { resolve as resolve12 } from "path";
|
|
10408
|
-
import { CliUserError as
|
|
10737
|
+
import { CliUserError as CliUserError50 } from "@burdenoff/cli-sdk/core";
|
|
10409
10738
|
function retryPolicy(raw, maxAttempts, readFile) {
|
|
10410
10739
|
const parsed = parseJsonObjectArg(raw, "--retry", readFile);
|
|
10411
10740
|
const policy = {};
|
|
10412
10741
|
if (parsed !== undefined) {
|
|
10413
10742
|
for (const key of Object.keys(parsed)) {
|
|
10414
10743
|
if (!RETRY_KEYS.some((known) => known === key)) {
|
|
10415
|
-
throw new
|
|
10744
|
+
throw new CliUserError50(`--retry: unknown field ${key}. Allowed: ${RETRY_KEYS.join(", ")}`);
|
|
10416
10745
|
}
|
|
10417
10746
|
}
|
|
10418
10747
|
const text = (key) => {
|
|
@@ -10420,7 +10749,7 @@ function retryPolicy(raw, maxAttempts, readFile) {
|
|
|
10420
10749
|
if (value === undefined)
|
|
10421
10750
|
return;
|
|
10422
10751
|
if (typeof value !== "string")
|
|
10423
|
-
throw new
|
|
10752
|
+
throw new CliUserError50(`--retry: ${key} must be a duration.`);
|
|
10424
10753
|
policy[key] = parseDurationOption(value, `--retry ${key}`);
|
|
10425
10754
|
};
|
|
10426
10755
|
text("initialInterval");
|
|
@@ -10428,21 +10757,21 @@ function retryPolicy(raw, maxAttempts, readFile) {
|
|
|
10428
10757
|
const backoff = parsed["backoffCoefficient"];
|
|
10429
10758
|
if (backoff !== undefined) {
|
|
10430
10759
|
if (typeof backoff !== "number" || !Number.isFinite(backoff) || backoff < 1) {
|
|
10431
|
-
throw new
|
|
10760
|
+
throw new CliUserError50("--retry: backoffCoefficient must be a number of at least 1.");
|
|
10432
10761
|
}
|
|
10433
10762
|
policy.backoffCoefficient = backoff;
|
|
10434
10763
|
}
|
|
10435
10764
|
const attempts = parsed["maximumAttempts"];
|
|
10436
10765
|
if (attempts !== undefined) {
|
|
10437
10766
|
if (typeof attempts !== "number" || !Number.isSafeInteger(attempts) || attempts < 0) {
|
|
10438
|
-
throw new
|
|
10767
|
+
throw new CliUserError50("--retry: maximumAttempts must be a whole number (0 = unlimited).");
|
|
10439
10768
|
}
|
|
10440
10769
|
policy.maximumAttempts = attempts;
|
|
10441
10770
|
}
|
|
10442
10771
|
const types = parsed["nonRetryableErrorTypes"];
|
|
10443
10772
|
if (types !== undefined) {
|
|
10444
10773
|
if (!Array.isArray(types) || types.some((type) => typeof type !== "string")) {
|
|
10445
|
-
throw new
|
|
10774
|
+
throw new CliUserError50("--retry: nonRetryableErrorTypes must be a list of strings.");
|
|
10446
10775
|
}
|
|
10447
10776
|
policy.nonRetryableErrorTypes = types.filter((type) => typeof type === "string");
|
|
10448
10777
|
}
|
|
@@ -10450,7 +10779,7 @@ function retryPolicy(raw, maxAttempts, readFile) {
|
|
|
10450
10779
|
if (maxAttempts !== undefined) {
|
|
10451
10780
|
const value = maxAttempts.trim();
|
|
10452
10781
|
if (!/^\d+$/.test(value) || !Number.isSafeInteger(Number(value))) {
|
|
10453
|
-
throw new
|
|
10782
|
+
throw new CliUserError50(`Invalid value '${maxAttempts}' for --max-attempts: expected a whole number (0 = unlimited).`);
|
|
10454
10783
|
}
|
|
10455
10784
|
policy.maximumAttempts = Number(value);
|
|
10456
10785
|
}
|
|
@@ -10459,29 +10788,29 @@ function retryPolicy(raw, maxAttempts, readFile) {
|
|
|
10459
10788
|
function requireName(raw, what) {
|
|
10460
10789
|
const value = raw.trim();
|
|
10461
10790
|
if (value === "")
|
|
10462
|
-
throw new
|
|
10791
|
+
throw new CliUserError50(`The ${what} is empty.`);
|
|
10463
10792
|
return value;
|
|
10464
10793
|
}
|
|
10465
10794
|
async function runActivityStart(env, nodeType, operation, options) {
|
|
10466
10795
|
const readFile = (path) => {
|
|
10467
10796
|
const absolute = resolve12(env.cwd(), path);
|
|
10468
10797
|
if (!existsSync15(absolute))
|
|
10469
|
-
throw new
|
|
10798
|
+
throw new CliUserError50(`${path} does not exist.`);
|
|
10470
10799
|
return readFileSync12(absolute, "utf8");
|
|
10471
10800
|
};
|
|
10472
10801
|
if (options.args === undefined) {
|
|
10473
|
-
throw new
|
|
10802
|
+
throw new CliUserError50("--args is required: the operation arguments as a JSON object.", {
|
|
10474
10803
|
hint: `For example --args '{"url":"https://example.com"}', or --args @args.json.`
|
|
10475
10804
|
});
|
|
10476
10805
|
}
|
|
10477
10806
|
const args = parseJsonObjectArg(options.args, "--args", readFile) ?? {};
|
|
10478
10807
|
const summary = options.summary?.trim();
|
|
10479
10808
|
if (summary !== undefined && (summary === "" || summary.length > MAX_SUMMARY_CHARS)) {
|
|
10480
|
-
throw new
|
|
10809
|
+
throw new CliUserError50(`--summary is 1 to ${MAX_SUMMARY_CHARS} characters.`);
|
|
10481
10810
|
}
|
|
10482
10811
|
const key = options.idempotencyKey?.trim();
|
|
10483
10812
|
if (key !== undefined && !IDEMPOTENCY_KEY.test(key)) {
|
|
10484
|
-
throw new
|
|
10813
|
+
throw new CliUserError50(`--idempotency-key is 1 to ${MAX_IDEMPOTENCY_KEY_CHARS} letters, digits, dots, underscores, colons or dashes.`);
|
|
10485
10814
|
}
|
|
10486
10815
|
const retry = retryPolicy(options.retry, options.maxAttempts, readFile);
|
|
10487
10816
|
const nodeVersion = options.nodeVersion?.trim();
|
|
@@ -10525,7 +10854,7 @@ async function runActivityStart(env, nodeType, operation, options) {
|
|
|
10525
10854
|
rows: [[result.run.id, finalStatus, started.existing ? "yes" : "no"]]
|
|
10526
10855
|
}, details);
|
|
10527
10856
|
if (options.wait && finalStatus !== "COMPLETED") {
|
|
10528
|
-
throw new
|
|
10857
|
+
throw new CliUserError50(`Run ${started.run.id} ended ${finalStatus}.`);
|
|
10529
10858
|
}
|
|
10530
10859
|
return result;
|
|
10531
10860
|
}
|
|
@@ -10546,7 +10875,7 @@ var init_activity_start = __esm(() => {
|
|
|
10546
10875
|
});
|
|
10547
10876
|
|
|
10548
10877
|
// src/phase-c/commands/signal-tokens.ts
|
|
10549
|
-
import { CliUserError as
|
|
10878
|
+
import { CliUserError as CliUserError51 } from "@burdenoff/cli-sdk/core";
|
|
10550
10879
|
function row(token) {
|
|
10551
10880
|
return [
|
|
10552
10881
|
token.id,
|
|
@@ -10563,12 +10892,12 @@ async function runSignalTokenCreate(env, runId, options) {
|
|
|
10563
10892
|
const signalName = requireText(options.signal, "--signal");
|
|
10564
10893
|
const ttlMs = parseMs(options.ttl, "--ttl");
|
|
10565
10894
|
if (ttlMs !== undefined && ttlMs % 1000 !== 0) {
|
|
10566
|
-
throw new
|
|
10895
|
+
throw new CliUserError51("--ttl is counted in whole seconds.");
|
|
10567
10896
|
}
|
|
10568
10897
|
const ipAllowlist = parseList(options.allowIp);
|
|
10569
10898
|
for (const entry of ipAllowlist) {
|
|
10570
10899
|
if (!IPV4_OR_CIDR.test(entry)) {
|
|
10571
|
-
throw new
|
|
10900
|
+
throw new CliUserError51(`Invalid --allow-ip '${entry}': an IPv4 address or CIDR range.`);
|
|
10572
10901
|
}
|
|
10573
10902
|
}
|
|
10574
10903
|
const created = await env.pc.createSignalToken({
|
|
@@ -10604,7 +10933,7 @@ var init_signal_tokens = __esm(() => {
|
|
|
10604
10933
|
});
|
|
10605
10934
|
|
|
10606
10935
|
// src/phase-c/commands/search-attributes.ts
|
|
10607
|
-
import { CliUserError as
|
|
10936
|
+
import { CliUserError as CliUserError52 } from "@burdenoff/cli-sdk/core";
|
|
10608
10937
|
function row2(attribute) {
|
|
10609
10938
|
return [
|
|
10610
10939
|
attribute.name,
|
|
@@ -10621,11 +10950,11 @@ async function runSearchAttributesList(env, options) {
|
|
|
10621
10950
|
}
|
|
10622
10951
|
async function runSearchAttributesCreate(env, name, options) {
|
|
10623
10952
|
if (!NAME.test(name)) {
|
|
10624
|
-
throw new
|
|
10953
|
+
throw new CliUserError52(`Invalid search attribute name '${name}': a letter, then letters, digits and underscores (at most 64).`);
|
|
10625
10954
|
}
|
|
10626
10955
|
const type = parseEnumOption(options.type, "--type", SEARCH_ATTRIBUTE_TYPES);
|
|
10627
10956
|
if (type === undefined) {
|
|
10628
|
-
throw new
|
|
10957
|
+
throw new CliUserError52(`--type is required: ${SEARCH_ATTRIBUTE_TYPES.join(", ")}.`);
|
|
10629
10958
|
}
|
|
10630
10959
|
const attribute = await env.pc.createSearchAttribute({
|
|
10631
10960
|
name,
|
|
@@ -10638,7 +10967,7 @@ async function runSearchAttributesCreate(env, name, options) {
|
|
|
10638
10967
|
async function runSearchAttributesDelete(env, name, options) {
|
|
10639
10968
|
const attribute = (await env.pc.searchAttributes()).find((entry) => entry.name === name);
|
|
10640
10969
|
if (!attribute) {
|
|
10641
|
-
throw new
|
|
10970
|
+
throw new CliUserError52(`The workspace has no search attribute ${name}.`, {
|
|
10642
10971
|
hint: "List them with `fluidgrids search-attributes list`."
|
|
10643
10972
|
});
|
|
10644
10973
|
}
|
|
@@ -10666,7 +10995,7 @@ var init_search_attributes = __esm(() => {
|
|
|
10666
10995
|
});
|
|
10667
10996
|
|
|
10668
10997
|
// src/phase-c/commands/schedules.ts
|
|
10669
|
-
import { CliUserError as
|
|
10998
|
+
import { CliUserError as CliUserError53 } from "@burdenoff/cli-sdk/core";
|
|
10670
10999
|
function isRecord21(value) {
|
|
10671
11000
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10672
11001
|
}
|
|
@@ -10791,9 +11120,9 @@ async function runSchedulesBackfill(env, workflowKey, triggerNodeId, options) {
|
|
|
10791
11120
|
const from = parseInstant(requireText(options.from, "--from"), "--from") ?? "";
|
|
10792
11121
|
const to = parseInstant(requireText(options.to, "--to"), "--to") ?? "";
|
|
10793
11122
|
if (from >= to)
|
|
10794
|
-
throw new
|
|
11123
|
+
throw new CliUserError53("--from must be before --to.");
|
|
10795
11124
|
if (Date.parse(to) > Date.now())
|
|
10796
|
-
throw new
|
|
11125
|
+
throw new CliUserError53("--to must be in the past.");
|
|
10797
11126
|
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
11127
|
const overlapPolicy = parseOverlap(options.overlapPolicy);
|
|
10799
11128
|
const result = await env.pc.backfillSchedule({
|
|
@@ -10845,7 +11174,7 @@ init_json_contract();
|
|
|
10845
11174
|
import { readFileSync as readFileSync13 } from "fs";
|
|
10846
11175
|
import { join as join13, dirname as dirname7 } from "path";
|
|
10847
11176
|
import { fileURLToPath } from "url";
|
|
10848
|
-
import { CliUserError as
|
|
11177
|
+
import { CliUserError as CliUserError54, defaultOutputAdapter } from "@burdenoff/cli-sdk/core";
|
|
10849
11178
|
|
|
10850
11179
|
// src/output/run-envelope.ts
|
|
10851
11180
|
init_json_contract();
|
|
@@ -11489,6 +11818,63 @@ var codeFirstModule = {
|
|
|
11489
11818
|
};
|
|
11490
11819
|
var code_first_default = codeFirstModule;
|
|
11491
11820
|
|
|
11821
|
+
// src/mcp/index.ts
|
|
11822
|
+
init_bridge();
|
|
11823
|
+
import { createInterface as createInterface4 } from "readline";
|
|
11824
|
+
import { CliUserError as CliUserError39 } from "@burdenoff/cli-sdk/core";
|
|
11825
|
+
var mcpModule = {
|
|
11826
|
+
id: "fluidgrids-mcp",
|
|
11827
|
+
version: "1.0.0",
|
|
11828
|
+
displayName: "FluidGrids MCP client bridge",
|
|
11829
|
+
dependsOn: ["auth"],
|
|
11830
|
+
register(program, ctx) {
|
|
11831
|
+
const mcp = program.command("mcp").description("Use FluidGrids MCP endpoints from desktop MCP clients");
|
|
11832
|
+
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", [
|
|
11833
|
+
"",
|
|
11834
|
+
"Example (an MCP Server Trigger served at /s/crm-tools):",
|
|
11835
|
+
` ${API_KEY_ENV}=... ${API_SECRET_ENV}=... \\`,
|
|
11836
|
+
" fluidgrids mcp connect https://graphqlworkspaces.burdenoff.com/mcp/fluidgrids/<workspace id>/s/crm-tools",
|
|
11837
|
+
"",
|
|
11838
|
+
"stdout carries MCP messages only; the client starts this command and talks to it over stdio.",
|
|
11839
|
+
"Documentation: https://docs.fluidgrids.ai/users/mcp-server-trigger"
|
|
11840
|
+
].join(`
|
|
11841
|
+
`)).action(async (url, flags) => {
|
|
11842
|
+
await Promise.resolve().then(() => init_bridge());
|
|
11843
|
+
const config = ctx.config.read();
|
|
11844
|
+
const productOrigin = ctx.config.resolveProductOrigin();
|
|
11845
|
+
const lines = createInterface4({ input: process.stdin, crlfDelay: Infinity });
|
|
11846
|
+
try {
|
|
11847
|
+
await runMcpConnect({
|
|
11848
|
+
url,
|
|
11849
|
+
...flags.organization ? { organizationId: flags.organization } : {},
|
|
11850
|
+
workspaceEndpoint: config.workspaceEndpoint,
|
|
11851
|
+
globalEndpoint: config.globalEndpoint,
|
|
11852
|
+
...productOrigin ? { productOrigin } : {}
|
|
11853
|
+
}, {
|
|
11854
|
+
env: process.env,
|
|
11855
|
+
fetch: (target, init) => fetch(target, init),
|
|
11856
|
+
lines,
|
|
11857
|
+
send: (line) => {
|
|
11858
|
+
process.stdout.write(`${line}
|
|
11859
|
+
`);
|
|
11860
|
+
},
|
|
11861
|
+
log: (message) => {
|
|
11862
|
+
process.stderr.write(`${message}
|
|
11863
|
+
`);
|
|
11864
|
+
}
|
|
11865
|
+
});
|
|
11866
|
+
} catch (error) {
|
|
11867
|
+
if (error instanceof McpBridgeConfigError)
|
|
11868
|
+
throw new CliUserError39(error.message);
|
|
11869
|
+
throw error;
|
|
11870
|
+
} finally {
|
|
11871
|
+
lines.close();
|
|
11872
|
+
}
|
|
11873
|
+
});
|
|
11874
|
+
}
|
|
11875
|
+
};
|
|
11876
|
+
var mcp_default = mcpModule;
|
|
11877
|
+
|
|
11492
11878
|
// src/phase-c/index.ts
|
|
11493
11879
|
init_shared();
|
|
11494
11880
|
|
|
@@ -11841,7 +12227,8 @@ var modules = [
|
|
|
11841
12227
|
devportalModule,
|
|
11842
12228
|
healthModule,
|
|
11843
12229
|
code_first_default,
|
|
11844
|
-
phase_c_default
|
|
12230
|
+
phase_c_default,
|
|
12231
|
+
mcp_default
|
|
11845
12232
|
];
|
|
11846
12233
|
|
|
11847
12234
|
// src/program.ts
|
|
@@ -11940,7 +12327,7 @@ try {
|
|
|
11940
12327
|
}
|
|
11941
12328
|
} catch (error) {
|
|
11942
12329
|
console.error(`✗ ${error instanceof Error ? error.message : String(error)}`);
|
|
11943
|
-
if (error instanceof
|
|
12330
|
+
if (error instanceof CliUserError54 && error.hint)
|
|
11944
12331
|
console.error(`ℹ ${error.hint}`);
|
|
11945
|
-
process.exitCode = error instanceof
|
|
12332
|
+
process.exitCode = error instanceof CliUserError54 ? error.exitCode : 1;
|
|
11946
12333
|
}
|