@fluidgrids/cli 2026.1115.6 → 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 +31 -2
- package/dist/cli.js +581 -157
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -4797,6 +4797,19 @@ var init_n8n_import = __esm(() => {
|
|
|
4797
4797
|
IMPORT_SOURCES = ["n8n"];
|
|
4798
4798
|
});
|
|
4799
4799
|
|
|
4800
|
+
// src/output/confirm.ts
|
|
4801
|
+
import { createInterface } from "readline/promises";
|
|
4802
|
+
async function confirmOnTerminal(question) {
|
|
4803
|
+
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
4804
|
+
try {
|
|
4805
|
+
const answer = await rl.question(`${question} [y/N] `);
|
|
4806
|
+
return /^y(es)?$/i.test(answer.trim());
|
|
4807
|
+
} finally {
|
|
4808
|
+
rl.close();
|
|
4809
|
+
}
|
|
4810
|
+
}
|
|
4811
|
+
var init_confirm = () => {};
|
|
4812
|
+
|
|
4800
4813
|
// src/phase-d/operations.ts
|
|
4801
4814
|
var FIDELITY_FIELDS = "level items { kind nodeId path detail }", GENERATION_FIELDS = `
|
|
4802
4815
|
id status message attempts prompt template modelUsed createdAt updatedAt
|
|
@@ -4950,7 +4963,7 @@ var init_api2 = __esm(() => {
|
|
|
4950
4963
|
import { isAbsolute as isAbsolute2 } from "path";
|
|
4951
4964
|
import { CliUserError as CliUserError26 } from "@burdenoff/cli-sdk/core";
|
|
4952
4965
|
function phaseDEnv(env) {
|
|
4953
|
-
return { ...env, pd: createPhaseDApi(env.ctx) };
|
|
4966
|
+
return { ...env, pd: createPhaseDApi(env.ctx), confirm: confirmOnTerminal };
|
|
4954
4967
|
}
|
|
4955
4968
|
function safeRelativePath2(raw, what) {
|
|
4956
4969
|
const bad = raw === "" || raw.length > 512 || isAbsolute2(raw) || raw.startsWith("/") || /^[A-Za-z]:/.test(raw) || raw.includes("\\") || [...raw].some((char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127) || raw.split("/").some((segment) => segment === "" || segment === "." || segment === "..");
|
|
@@ -4974,6 +4987,7 @@ function parseJsonObjectArg(raw, flag, readFile) {
|
|
|
4974
4987
|
return parsed;
|
|
4975
4988
|
}
|
|
4976
4989
|
var init_shared2 = __esm(() => {
|
|
4990
|
+
init_confirm();
|
|
4977
4991
|
init_api2();
|
|
4978
4992
|
});
|
|
4979
4993
|
|
|
@@ -5803,7 +5817,7 @@ var init_parity = __esm(() => {
|
|
|
5803
5817
|
// src/code-first/commands/runs.ts
|
|
5804
5818
|
import { writeFileSync as writeFileSync6 } from "fs";
|
|
5805
5819
|
import { resolve as resolve7 } from "path";
|
|
5806
|
-
import { createInterface } from "readline/promises";
|
|
5820
|
+
import { createInterface as createInterface2 } from "readline/promises";
|
|
5807
5821
|
import { CliUserError as CliUserError31 } from "@burdenoff/cli-sdk/core";
|
|
5808
5822
|
import { serializeHistoryFile as serializeHistoryFile2 } from "@fluidgrids/workflows/history";
|
|
5809
5823
|
function parityRows(run) {
|
|
@@ -6094,7 +6108,7 @@ async function runSignal(env, first, second, options) {
|
|
|
6094
6108
|
return result;
|
|
6095
6109
|
}
|
|
6096
6110
|
async function confirm(question) {
|
|
6097
|
-
const rl =
|
|
6111
|
+
const rl = createInterface2({ input: process.stdin, output: process.stderr });
|
|
6098
6112
|
try {
|
|
6099
6113
|
const answer = await rl.question(`${question} [y/N] `);
|
|
6100
6114
|
return /^y(es)?$/i.test(answer.trim());
|
|
@@ -6850,6 +6864,27 @@ function inspectMatches(raw, address) {
|
|
|
6850
6864
|
return false;
|
|
6851
6865
|
}
|
|
6852
6866
|
}
|
|
6867
|
+
function remoteCodeWarning(what) {
|
|
6868
|
+
return `Replaying the stored code of ${what} on this machine: a Node vm is not a sandbox, so the code can reach this process, your files and your credentials. Only debug code from people you trust.`;
|
|
6869
|
+
}
|
|
6870
|
+
async function confirmRemoteCode(env, options, what) {
|
|
6871
|
+
const warning = remoteCodeWarning(what);
|
|
6872
|
+
console.error(warning);
|
|
6873
|
+
reportDiagnostics(env.ctx.output, [
|
|
6874
|
+
diagnostic({ severity: "warning", code: "debug.untrustedCode", message: warning })
|
|
6875
|
+
]);
|
|
6876
|
+
if (options.yes === true)
|
|
6877
|
+
return;
|
|
6878
|
+
const question = `Run the stored code of ${what} on this machine?`;
|
|
6879
|
+
if (isEnvelopeOutput(env.ctx.output) || !env.interactive()) {
|
|
6880
|
+
throw new CliUserError34(`${question} This needs confirmation.`, {
|
|
6881
|
+
hint: "Pass --yes to replay it without a prompt, once you trust whoever pushed that version."
|
|
6882
|
+
});
|
|
6883
|
+
}
|
|
6884
|
+
if (!await env.confirm(question)) {
|
|
6885
|
+
throw new CliUserError34("Aborted: the stored code was not downloaded or run.");
|
|
6886
|
+
}
|
|
6887
|
+
}
|
|
6853
6888
|
async function reexecUnderInspector(env, options, facts) {
|
|
6854
6889
|
const address = inspectAddress(options.inspect ?? true);
|
|
6855
6890
|
if (!facts.node) {
|
|
@@ -6860,8 +6895,19 @@ async function reexecUnderInspector(env, options, facts) {
|
|
|
6860
6895
|
const script = facts.argv[1];
|
|
6861
6896
|
if (script === undefined)
|
|
6862
6897
|
throw new CliUserError34("--inspect: the CLI script path is unknown.");
|
|
6898
|
+
const args = childArgs(facts.argv, address);
|
|
6899
|
+
if (options.remoteCode === true) {
|
|
6900
|
+
await confirmRemoteCode(env, options, "the run");
|
|
6901
|
+
if (!args.includes("--yes")) {
|
|
6902
|
+
const end = args.indexOf("--");
|
|
6903
|
+
if (end < 0)
|
|
6904
|
+
args.push("--yes");
|
|
6905
|
+
else
|
|
6906
|
+
args.splice(end, 0, "--yes");
|
|
6907
|
+
}
|
|
6908
|
+
}
|
|
6863
6909
|
console.error(`Debugger listening on ${address}; attach to continue (the replay stops at the mismatch).`);
|
|
6864
|
-
const status = await env.exec(facts.execPath, [`--inspect-brk=${address}`, script, ...
|
|
6910
|
+
const status = await env.exec(facts.execPath, [`--inspect-brk=${address}`, script, ...args], env.cwd(), { stdout: "inherit" });
|
|
6865
6911
|
throw new DelegatedExit(status);
|
|
6866
6912
|
}
|
|
6867
6913
|
async function loadHistory(env, target) {
|
|
@@ -6873,7 +6919,7 @@ async function loadHistory(env, target) {
|
|
|
6873
6919
|
throw new CliUserError34(`History file not found: ${target}`);
|
|
6874
6920
|
return { file: (await fetchHistory(env, target)).file, name: target };
|
|
6875
6921
|
}
|
|
6876
|
-
async function remoteScript(env, file, name) {
|
|
6922
|
+
async function remoteScript(env, options, file, name) {
|
|
6877
6923
|
const key = file.info?.workflowKey;
|
|
6878
6924
|
const version = file.info?.version;
|
|
6879
6925
|
const buildId = file.info?.buildId;
|
|
@@ -6893,7 +6939,7 @@ async function remoteScript(env, file, name) {
|
|
|
6893
6939
|
});
|
|
6894
6940
|
}
|
|
6895
6941
|
presignedUrl(archive.url, "source archive");
|
|
6896
|
-
|
|
6942
|
+
await confirmRemoteCode(env, options, `${key} ${String(version)}`);
|
|
6897
6943
|
let response;
|
|
6898
6944
|
try {
|
|
6899
6945
|
response = await env.fetch(archive.url, { method: "GET" });
|
|
@@ -6983,9 +7029,9 @@ async function runDebugReplay(env, target, options, facts = currentProcess()) {
|
|
|
6983
7029
|
throw new CliUserError34(`${name} is marked "replay": false (it uses Phase C features).`);
|
|
6984
7030
|
}
|
|
6985
7031
|
const remote = options.remoteCode === true;
|
|
6986
|
-
const script = remote ? await remoteScript(env, file, name) : await localScript(env, options, file, name);
|
|
7032
|
+
const script = remote ? await remoteScript(env, options, file, name) : await localScript(env, options, file, name);
|
|
6987
7033
|
const breakOnMismatch = options.breakOnMismatch === true;
|
|
6988
|
-
const trace = await traceReplay(script.script, replayRequest2(file.workflowFn, file.events, file.info ?? {}, file.nowMs), breakOnMismatch ? { breakOnMismatch: true, onBreak: breakAtMismatch } : {});
|
|
7034
|
+
const trace = await traceReplay(script.script, replayRequest2(file.workflowFn, file.events, file.info ?? {}, file.nowMs), breakOnMismatch ? { trustedCode: true, breakOnMismatch: true, onBreak: breakAtMismatch } : { trustedCode: true });
|
|
6989
7035
|
const runBuildId = file.info?.buildId ?? null;
|
|
6990
7036
|
const result = {
|
|
6991
7037
|
name,
|
|
@@ -7339,7 +7385,7 @@ var init_suite = __esm(() => {
|
|
|
7339
7385
|
});
|
|
7340
7386
|
|
|
7341
7387
|
// src/code-first/commands/versions.ts
|
|
7342
|
-
import { createInterface as
|
|
7388
|
+
import { createInterface as createInterface3 } from "readline/promises";
|
|
7343
7389
|
import { CliUserError as CliUserError36 } from "@burdenoff/cli-sdk/core";
|
|
7344
7390
|
async function runVersionsList(env, workflowKey, options) {
|
|
7345
7391
|
const versions = sortVersions(await env.api.workflowVersions(workflowKey));
|
|
@@ -7426,7 +7472,7 @@ function rolloutDeleteOptions(options, parent) {
|
|
|
7426
7472
|
return { ...options, environment: inherited };
|
|
7427
7473
|
}
|
|
7428
7474
|
async function confirm2(question) {
|
|
7429
|
-
const rl =
|
|
7475
|
+
const rl = createInterface3({ input: process.stdin, output: process.stderr });
|
|
7430
7476
|
try {
|
|
7431
7477
|
const answer = await rl.question(`${question} [y/N] `);
|
|
7432
7478
|
return /^y(es)?$/i.test(answer.trim());
|
|
@@ -7710,6 +7756,335 @@ var init_deploy = __esm(() => {
|
|
|
7710
7756
|
};
|
|
7711
7757
|
});
|
|
7712
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
|
+
|
|
7713
8088
|
// src/phase-c/operations.ts
|
|
7714
8089
|
function hierarchyChildren(depth) {
|
|
7715
8090
|
if (depth === 0)
|
|
@@ -8214,7 +8589,7 @@ var init_operations3 = __esm(() => {
|
|
|
8214
8589
|
});
|
|
8215
8590
|
|
|
8216
8591
|
// src/phase-c/api.ts
|
|
8217
|
-
import { CliAuthError as CliAuthError6, CliUserError as
|
|
8592
|
+
import { CliAuthError as CliAuthError6, CliUserError as CliUserError40 } from "@burdenoff/cli-sdk/core";
|
|
8218
8593
|
function runVariables(run) {
|
|
8219
8594
|
return run.runId !== undefined ? { runId: run.runId } : { target: run.target };
|
|
8220
8595
|
}
|
|
@@ -8234,7 +8609,7 @@ function createPhaseCApi(ctx) {
|
|
|
8234
8609
|
function context() {
|
|
8235
8610
|
const workspaceId = ctx.auth.read()?.workspaceId;
|
|
8236
8611
|
if (!workspaceId) {
|
|
8237
|
-
throw new
|
|
8612
|
+
throw new CliUserError40("No workspace is selected.", {
|
|
8238
8613
|
hint: `Run \`${ctx.productName} workspace set <id>\` or set FLUIDGRIDS_WORKSPACE_ID.`
|
|
8239
8614
|
});
|
|
8240
8615
|
}
|
|
@@ -8367,7 +8742,7 @@ function createPhaseCApi(ctx) {
|
|
|
8367
8742
|
});
|
|
8368
8743
|
const found = data.workflowRunByWorkflowId;
|
|
8369
8744
|
if (!found) {
|
|
8370
|
-
throw new
|
|
8745
|
+
throw new CliUserError40(`No run with workflow id ${run.target.workflowId} of ${run.target.workflowKey} (NOT_FOUND)`);
|
|
8371
8746
|
}
|
|
8372
8747
|
return found.id;
|
|
8373
8748
|
},
|
|
@@ -8502,7 +8877,7 @@ function createPhaseCApi(ctx) {
|
|
|
8502
8877
|
if (!pagination?.hasMore || jobs.length === 0)
|
|
8503
8878
|
return all;
|
|
8504
8879
|
}
|
|
8505
|
-
throw new
|
|
8880
|
+
throw new CliUserError40(`The schedule listing did not end after ${MAX_SCHEDULE_PAGES} pages; refusing to continue.`);
|
|
8506
8881
|
},
|
|
8507
8882
|
async describeSchedule(workflowKey, triggerNodeId) {
|
|
8508
8883
|
const data = await request(PC_SCHEDULE_DESCRIBE, { workflowKey, triggerNodeId }, P);
|
|
@@ -8536,17 +8911,17 @@ var init_api3 = __esm(() => {
|
|
|
8536
8911
|
});
|
|
8537
8912
|
|
|
8538
8913
|
// src/phase-c/commands/queues.ts
|
|
8539
|
-
import { CliUserError as
|
|
8914
|
+
import { CliUserError as CliUserError41 } from "@burdenoff/cli-sdk/core";
|
|
8540
8915
|
function parseEnvironment2(raw) {
|
|
8541
8916
|
return parseEnumOption(raw, "--environment", ENVIRONMENTS3);
|
|
8542
8917
|
}
|
|
8543
8918
|
function checkQueueName(name) {
|
|
8544
8919
|
const value = name.trim();
|
|
8545
8920
|
if (value === "managed") {
|
|
8546
|
-
throw new
|
|
8921
|
+
throw new CliUserError41("`managed` is the platform queue; it cannot be created or changed.");
|
|
8547
8922
|
}
|
|
8548
8923
|
if (!QUEUE_NAME.test(value)) {
|
|
8549
|
-
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.`);
|
|
8550
8925
|
}
|
|
8551
8926
|
return value;
|
|
8552
8927
|
}
|
|
@@ -8558,7 +8933,7 @@ function checkWorkerQueue(raw) {
|
|
|
8558
8933
|
const name = checkQueueName(value.slice(0, at));
|
|
8559
8934
|
const environment = value.slice(at + 1).toLowerCase();
|
|
8560
8935
|
if (!ENVIRONMENTS3.some((allowed) => allowed.toLowerCase() === environment)) {
|
|
8561
|
-
throw new
|
|
8936
|
+
throw new CliUserError41(`Invalid queue '${raw}': the environment after @ must be dev, staging or prod.`);
|
|
8562
8937
|
}
|
|
8563
8938
|
return `${name}@${environment}`;
|
|
8564
8939
|
}
|
|
@@ -8571,7 +8946,7 @@ function bindWorkerQueues(queues, raw) {
|
|
|
8571
8946
|
if (at < 0)
|
|
8572
8947
|
return `${queue}@${environment}`;
|
|
8573
8948
|
if (queue.slice(at + 1) !== environment) {
|
|
8574
|
-
throw new
|
|
8949
|
+
throw new CliUserError41(`Queue '${queue}' is bound to ${queue.slice(at + 1)}, but --environment is ${environment}.`);
|
|
8575
8950
|
}
|
|
8576
8951
|
return queue;
|
|
8577
8952
|
});
|
|
@@ -8587,11 +8962,11 @@ async function findQueue(env, name, environment) {
|
|
|
8587
8962
|
if (found)
|
|
8588
8963
|
return found;
|
|
8589
8964
|
if (environment === undefined && rows.length > 0) {
|
|
8590
|
-
throw new
|
|
8965
|
+
throw new CliUserError41(`Queue ${name} has only environment-scoped rows.`, {
|
|
8591
8966
|
hint: `Pass --environment (one of ${rows.map((queue) => queue.environment ?? "-").join(", ")}).`
|
|
8592
8967
|
});
|
|
8593
8968
|
}
|
|
8594
|
-
throw new
|
|
8969
|
+
throw new CliUserError41(`The workspace has no task queue ${environment ? `${name}@${environment}` : name}.`, { hint: "List them with `fluidgrids queues list`." });
|
|
8595
8970
|
}
|
|
8596
8971
|
async function runQueuesList(env, options) {
|
|
8597
8972
|
const queues = await env.pc.taskQueues();
|
|
@@ -8652,7 +9027,7 @@ async function runQueuesUpdate(env, name, options) {
|
|
|
8652
9027
|
const environment = parseEnvironment2(options.environment);
|
|
8653
9028
|
const maxTasksPerSecond = parseNumberOption(options.maxTasksPerSecond, "--max-tasks-per-second");
|
|
8654
9029
|
if (maxTasksPerSecond !== undefined && options.clearMaxTasksPerSecond) {
|
|
8655
|
-
throw new
|
|
9030
|
+
throw new CliUserError41("Give --max-tasks-per-second or --clear-max-tasks-per-second, not both.");
|
|
8656
9031
|
}
|
|
8657
9032
|
const timeout = parseNonNegativeInt(options.workerUnavailableTimeout, "--worker-unavailable-timeout");
|
|
8658
9033
|
const input = {
|
|
@@ -8662,7 +9037,7 @@ async function runQueuesUpdate(env, name, options) {
|
|
|
8662
9037
|
...timeout !== undefined ? { workerUnavailableTimeoutSeconds: timeout } : {}
|
|
8663
9038
|
};
|
|
8664
9039
|
if (Object.keys(input).length === 0) {
|
|
8665
|
-
throw new
|
|
9040
|
+
throw new CliUserError41("Nothing to change.", {
|
|
8666
9041
|
hint: "Give --description, --max-tasks-per-second, --clear-max-tasks-per-second or --worker-unavailable-timeout."
|
|
8667
9042
|
});
|
|
8668
9043
|
}
|
|
@@ -8741,7 +9116,7 @@ import { existsSync as existsSync14 } from "fs";
|
|
|
8741
9116
|
import { hostname } from "os";
|
|
8742
9117
|
import { extname as extname3, isAbsolute as isAbsolute3, join as join12, resolve as resolve11 } from "path";
|
|
8743
9118
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
8744
|
-
import { CliUserError as
|
|
9119
|
+
import { CliUserError as CliUserError42 } from "@burdenoff/cli-sdk/core";
|
|
8745
9120
|
function isRecord19(value) {
|
|
8746
9121
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8747
9122
|
}
|
|
@@ -8752,11 +9127,11 @@ function bridgeUrlFor(env, explicit, issued) {
|
|
|
8752
9127
|
try {
|
|
8753
9128
|
url = new URL(raw);
|
|
8754
9129
|
} catch {
|
|
8755
|
-
throw new
|
|
9130
|
+
throw new CliUserError42(`Invalid bridge URL '${raw}'.`);
|
|
8756
9131
|
}
|
|
8757
9132
|
const local = url.hostname === "localhost" || url.hostname === "127.0.0.1";
|
|
8758
9133
|
if (url.protocol !== "wss:" && !(url.protocol === "ws:" && local)) {
|
|
8759
|
-
throw new
|
|
9134
|
+
throw new CliUserError42(`The bridge URL must be wss:// (ws:// only to this machine): ${raw}`);
|
|
8760
9135
|
}
|
|
8761
9136
|
return url.toString();
|
|
8762
9137
|
}
|
|
@@ -8772,18 +9147,18 @@ function bridgeHeaders(env) {
|
|
|
8772
9147
|
const id = env.getEnv("FLUIDGRIDS_CF_ACCESS_CLIENT_ID")?.trim();
|
|
8773
9148
|
const secret = env.getEnv("FLUIDGRIDS_CF_ACCESS_CLIENT_SECRET")?.trim();
|
|
8774
9149
|
if ((id === undefined || id === "") !== (secret === undefined || secret === "")) {
|
|
8775
|
-
throw new
|
|
9150
|
+
throw new CliUserError42("Set both FLUIDGRIDS_CF_ACCESS_CLIENT_ID and FLUIDGRIDS_CF_ACCESS_CLIENT_SECRET, or neither.");
|
|
8776
9151
|
}
|
|
8777
9152
|
return id && secret ? { "CF-Access-Client-Id": id, "CF-Access-Client-Secret": secret } : {};
|
|
8778
9153
|
}
|
|
8779
9154
|
function workerToken(env, tokenEnv) {
|
|
8780
9155
|
const variable = tokenEnv?.trim() || WORKER_TOKEN_ENV;
|
|
8781
9156
|
if (!ENV_NAME2.test(variable)) {
|
|
8782
|
-
throw new
|
|
9157
|
+
throw new CliUserError42("Invalid environment variable name for --token-env.");
|
|
8783
9158
|
}
|
|
8784
9159
|
const token = env.getEnv(variable)?.trim() ?? "";
|
|
8785
9160
|
if (!WORKER_TOKEN.test(token)) {
|
|
8786
|
-
throw new
|
|
9161
|
+
throw new CliUserError42(`${variable} must hold a worker token (fgr_ and 43 characters).`, {
|
|
8787
9162
|
hint: "Issue one with `fluidgrids workers tokens create <name> --queue <queue>`."
|
|
8788
9163
|
});
|
|
8789
9164
|
}
|
|
@@ -8796,7 +9171,7 @@ async function buildWorkerBundle(project) {
|
|
|
8796
9171
|
explainUnresolved: (names) => [...names]
|
|
8797
9172
|
});
|
|
8798
9173
|
if (!lowered.workflows.some((workflow) => workflow.durable)) {
|
|
8799
|
-
throw new
|
|
9174
|
+
throw new CliUserError42("The project defines no durable functions for a worker to serve.");
|
|
8800
9175
|
}
|
|
8801
9176
|
await prepareProjectBundle(project, lowered);
|
|
8802
9177
|
return bundlePathOf(project);
|
|
@@ -8810,23 +9185,23 @@ function activitiesFor(project, raw) {
|
|
|
8810
9185
|
return;
|
|
8811
9186
|
const value = raw.trim();
|
|
8812
9187
|
if (value === "")
|
|
8813
|
-
throw new
|
|
9188
|
+
throw new CliUserError42("--activities cannot be empty.");
|
|
8814
9189
|
if (project.config.language === "py") {
|
|
8815
9190
|
if (!/^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$/.test(value)) {
|
|
8816
|
-
throw new
|
|
9191
|
+
throw new CliUserError42(`--activities for a Python project is a module name importable from the project (for example activities), not '${raw}'.`);
|
|
8817
9192
|
}
|
|
8818
9193
|
return value;
|
|
8819
9194
|
}
|
|
8820
9195
|
const path = isAbsolute3(value) ? value : resolve11(project.root, value);
|
|
8821
9196
|
if (!existsSync14(path))
|
|
8822
|
-
throw new
|
|
9197
|
+
throw new CliUserError42(`--activities: ${raw} not found.`);
|
|
8823
9198
|
return path;
|
|
8824
9199
|
}
|
|
8825
9200
|
function launchOf(settings) {
|
|
8826
9201
|
const { project, options } = settings;
|
|
8827
9202
|
const activities = activitiesFor(project, options.activities);
|
|
8828
9203
|
if (!settings.bundlePath && !activities) {
|
|
8829
|
-
throw new
|
|
9204
|
+
throw new CliUserError42("The worker would serve nothing: give workflows, --activities or both.");
|
|
8830
9205
|
}
|
|
8831
9206
|
const maxActivities = parsePositiveInt(options.maxConcurrentActivities, "--max-concurrent-activities");
|
|
8832
9207
|
const maxWorkflowTasks = parsePositiveInt(options.maxConcurrentWorkflowTasks, "--max-concurrent-workflow-tasks");
|
|
@@ -8859,7 +9234,7 @@ async function workflowBundle(project, options, build) {
|
|
|
8859
9234
|
if (!existsSync14(path)) {
|
|
8860
9235
|
if (options.activities !== undefined)
|
|
8861
9236
|
return;
|
|
8862
|
-
throw new
|
|
9237
|
+
throw new CliUserError42(`No workflow bundle at ${path}.`, {
|
|
8863
9238
|
hint: "Run `fluidgrids push` first, or pass --build to build it now (or --no-workflows)."
|
|
8864
9239
|
});
|
|
8865
9240
|
}
|
|
@@ -8868,7 +9243,7 @@ async function workflowBundle(project, options, build) {
|
|
|
8868
9243
|
async function runWorkerRun(env, options) {
|
|
8869
9244
|
const queues = bindWorkerQueues(parseList(options.queue).map(checkWorkerQueue), options.environment);
|
|
8870
9245
|
if (queues.length === 0)
|
|
8871
|
-
throw new
|
|
9246
|
+
throw new CliUserError42("Name the task queue(s) to serve with --queue.");
|
|
8872
9247
|
const project = loadProject(options.project, env.cwd());
|
|
8873
9248
|
const token = workerToken(env, options.tokenEnv);
|
|
8874
9249
|
const launch = launchOf({
|
|
@@ -8891,7 +9266,7 @@ function devQueueName() {
|
|
|
8891
9266
|
async function runDev(env, options) {
|
|
8892
9267
|
const project = loadProject(options.project, env.cwd());
|
|
8893
9268
|
if (options.lang !== undefined && options.lang !== project.config.language) {
|
|
8894
|
-
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 …`)." });
|
|
8895
9270
|
}
|
|
8896
9271
|
const bundlePath = await workflowBundle(project, options, options.workflows !== false);
|
|
8897
9272
|
const queueName = devQueueName();
|
|
@@ -8994,7 +9369,7 @@ async function loadTypeScriptActivities(root, path) {
|
|
|
8994
9369
|
}
|
|
8995
9370
|
}
|
|
8996
9371
|
if (found.length === 0) {
|
|
8997
|
-
throw new
|
|
9372
|
+
throw new CliUserError42(`${path} exports no activity implementations.`, {
|
|
8998
9373
|
hint: "Export `implementActivity(...)` or `defineActivity(...)` values from it."
|
|
8999
9374
|
});
|
|
9000
9375
|
}
|
|
@@ -9020,21 +9395,21 @@ async function runTypeScriptWorker(launch) {
|
|
|
9020
9395
|
}
|
|
9021
9396
|
function pythonWorkerExitError(python, code, signal) {
|
|
9022
9397
|
if (signal)
|
|
9023
|
-
return new
|
|
9398
|
+
return new CliUserError42(`The Python worker was stopped by ${signal}.`);
|
|
9024
9399
|
const status = String(code);
|
|
9025
9400
|
switch (code) {
|
|
9026
9401
|
case PYTHON_EXIT_NO_WORKER:
|
|
9027
|
-
return new
|
|
9402
|
+
return new CliUserError42(`The Python worker could not import fluidgrids_workflows.worker (status ${status}).`, {
|
|
9028
9403
|
hint: `Install the worker extra: \`${python} -m pip install 'fluidgrids-workflows[worker]'\`.`
|
|
9029
9404
|
});
|
|
9030
9405
|
case PYTHON_EXIT_NO_ACTIVITIES:
|
|
9031
|
-
return new
|
|
9406
|
+
return new CliUserError42(`The Python worker exited with status ${status}: the activities module defines no activities.`, {
|
|
9032
9407
|
hint: "Decorate the activities with @define_activity in the module --activities names, or pass the module that defines them."
|
|
9033
9408
|
});
|
|
9034
9409
|
case PYTHON_EXIT_BRIDGE_CLOSED:
|
|
9035
|
-
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).`);
|
|
9036
9411
|
default:
|
|
9037
|
-
return new
|
|
9412
|
+
return new CliUserError42(`The Python worker exited with status ${status}.`);
|
|
9038
9413
|
}
|
|
9039
9414
|
}
|
|
9040
9415
|
function pythonWorkerSpec(launch) {
|
|
@@ -9078,7 +9453,7 @@ function runPythonWorker(launch) {
|
|
|
9078
9453
|
};
|
|
9079
9454
|
child.on("error", (error) => {
|
|
9080
9455
|
done();
|
|
9081
|
-
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}`));
|
|
9082
9457
|
});
|
|
9083
9458
|
child.on("close", (code, signal) => {
|
|
9084
9459
|
done();
|
|
@@ -9160,17 +9535,7 @@ except BridgeClosedError as error:
|
|
|
9160
9535
|
});
|
|
9161
9536
|
|
|
9162
9537
|
// src/phase-c/shared.ts
|
|
9163
|
-
import {
|
|
9164
|
-
import { CliUserError as CliUserError42 } from "@burdenoff/cli-sdk/core";
|
|
9165
|
-
async function confirmOnTerminal(question) {
|
|
9166
|
-
const rl = createInterface3({ input: process.stdin, output: process.stderr });
|
|
9167
|
-
try {
|
|
9168
|
-
const answer = await rl.question(`${question} [y/N] `);
|
|
9169
|
-
return /^y(es)?$/i.test(answer.trim());
|
|
9170
|
-
} finally {
|
|
9171
|
-
rl.close();
|
|
9172
|
-
}
|
|
9173
|
-
}
|
|
9538
|
+
import { CliUserError as CliUserError43 } from "@burdenoff/cli-sdk/core";
|
|
9174
9539
|
function phaseCEnv(env) {
|
|
9175
9540
|
return {
|
|
9176
9541
|
...env,
|
|
@@ -9183,32 +9548,32 @@ async function requireConfirmation(env, question, force) {
|
|
|
9183
9548
|
if (force)
|
|
9184
9549
|
return;
|
|
9185
9550
|
if (!env.interactive()) {
|
|
9186
|
-
throw new
|
|
9551
|
+
throw new CliUserError43(`${question} needs confirmation.`, {
|
|
9187
9552
|
hint: "Pass --force to go ahead without a prompt."
|
|
9188
9553
|
});
|
|
9189
9554
|
}
|
|
9190
9555
|
if (!await env.confirm(question))
|
|
9191
|
-
throw new
|
|
9556
|
+
throw new CliUserError43("Aborted: nothing was changed.");
|
|
9192
9557
|
}
|
|
9193
9558
|
function runSelectorOf(runId, flags) {
|
|
9194
9559
|
const targeted = flags.workflowId !== undefined || flags.key !== undefined || flags.firstRunId !== undefined;
|
|
9195
9560
|
if (!targeted) {
|
|
9196
9561
|
if (runId === undefined || runId.trim() === "") {
|
|
9197
|
-
throw new
|
|
9562
|
+
throw new CliUserError43("Give a run id, or --workflow-id with --key.");
|
|
9198
9563
|
}
|
|
9199
9564
|
return { runId: runId.trim() };
|
|
9200
9565
|
}
|
|
9201
9566
|
if (runId !== undefined) {
|
|
9202
|
-
throw new
|
|
9567
|
+
throw new CliUserError43("Give a run id or --workflow-id with --key, not both.");
|
|
9203
9568
|
}
|
|
9204
9569
|
const workflowId = flags.workflowId?.trim() ?? "";
|
|
9205
9570
|
const key = flags.key?.trim() ?? "";
|
|
9206
9571
|
if (workflowId === "" || key === "") {
|
|
9207
|
-
throw new
|
|
9572
|
+
throw new CliUserError43("--workflow-id and --key go together (the workflow id of that key).");
|
|
9208
9573
|
}
|
|
9209
9574
|
const firstRunId = flags.firstRunId?.trim();
|
|
9210
9575
|
if (flags.firstRunId !== undefined && !firstRunId) {
|
|
9211
|
-
throw new
|
|
9576
|
+
throw new CliUserError43("--first-run-id cannot be empty.");
|
|
9212
9577
|
}
|
|
9213
9578
|
return {
|
|
9214
9579
|
target: { workflowKey: key, workflowId, ...firstRunId ? { firstRunId } : {} }
|
|
@@ -9224,7 +9589,7 @@ function parseEnumOption(raw, flag, allowed) {
|
|
|
9224
9589
|
const match = allowed.find((value) => value === normal);
|
|
9225
9590
|
if (match === undefined) {
|
|
9226
9591
|
const shown = allowed.map((value) => value.toLowerCase().replace(/_/g, "-"));
|
|
9227
|
-
throw new
|
|
9592
|
+
throw new CliUserError43(`Invalid value '${raw}' for ${flag}. Allowed: ${shown.join(", ")}`);
|
|
9228
9593
|
}
|
|
9229
9594
|
return match;
|
|
9230
9595
|
}
|
|
@@ -9233,7 +9598,7 @@ function parseNonNegativeInt(raw, flag) {
|
|
|
9233
9598
|
return;
|
|
9234
9599
|
const value = raw.trim();
|
|
9235
9600
|
if (!/^\d+$/.test(value) || !Number.isSafeInteger(Number(value))) {
|
|
9236
|
-
throw new
|
|
9601
|
+
throw new CliUserError43(`Invalid value '${raw}' for ${flag}: expected a whole number.`);
|
|
9237
9602
|
}
|
|
9238
9603
|
return Number(value);
|
|
9239
9604
|
}
|
|
@@ -9242,14 +9607,14 @@ function parseNumberOption(raw, flag) {
|
|
|
9242
9607
|
return;
|
|
9243
9608
|
const value = Number(raw.trim());
|
|
9244
9609
|
if (raw.trim() === "" || !Number.isFinite(value)) {
|
|
9245
|
-
throw new
|
|
9610
|
+
throw new CliUserError43(`Invalid value '${raw}' for ${flag}: expected a number.`);
|
|
9246
9611
|
}
|
|
9247
9612
|
return value;
|
|
9248
9613
|
}
|
|
9249
9614
|
function requireText(raw, flag) {
|
|
9250
9615
|
const value = raw?.trim() ?? "";
|
|
9251
9616
|
if (value === "")
|
|
9252
|
-
throw new
|
|
9617
|
+
throw new CliUserError43(`${flag} is required.`);
|
|
9253
9618
|
return value;
|
|
9254
9619
|
}
|
|
9255
9620
|
function parseList(raw) {
|
|
@@ -9279,16 +9644,17 @@ function parseInstant(raw, flag) {
|
|
|
9279
9644
|
const value = raw.trim();
|
|
9280
9645
|
const ms = Date.parse(value);
|
|
9281
9646
|
if (value === "" || !Number.isFinite(ms) || !/^\d{4}-\d{2}-\d{2}/.test(value)) {
|
|
9282
|
-
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.`);
|
|
9283
9648
|
}
|
|
9284
9649
|
return new Date(ms).toISOString();
|
|
9285
9650
|
}
|
|
9286
9651
|
var init_shared3 = __esm(() => {
|
|
9652
|
+
init_confirm();
|
|
9287
9653
|
init_api3();
|
|
9288
9654
|
});
|
|
9289
9655
|
|
|
9290
9656
|
// src/config/commands.ts
|
|
9291
|
-
import { CliUserError as
|
|
9657
|
+
import { CliUserError as CliUserError44 } from "@burdenoff/cli-sdk/core";
|
|
9292
9658
|
function output(env, options, data, rows, headers) {
|
|
9293
9659
|
env.ctx.output.formatAndOutput(options, data, { headers, rows });
|
|
9294
9660
|
}
|
|
@@ -9304,7 +9670,7 @@ function isLocal(url) {
|
|
|
9304
9670
|
function checkProfileValue(key, value, profile) {
|
|
9305
9671
|
const trimmed = value.trim();
|
|
9306
9672
|
if (trimmed === "" || trimmed.length > 2048) {
|
|
9307
|
-
throw new
|
|
9673
|
+
throw new CliUserError44(`${key} must be 1 to 2048 characters.`);
|
|
9308
9674
|
}
|
|
9309
9675
|
switch (key) {
|
|
9310
9676
|
case "apiUrl":
|
|
@@ -9313,20 +9679,20 @@ function checkProfileValue(key, value, profile) {
|
|
|
9313
9679
|
try {
|
|
9314
9680
|
url = new URL(trimmed);
|
|
9315
9681
|
} catch {
|
|
9316
|
-
throw new
|
|
9682
|
+
throw new CliUserError44(`${key} must be a URL.`);
|
|
9317
9683
|
}
|
|
9318
9684
|
if (url.protocol !== "https:" && !(url.protocol === "http:" && isLocal(url))) {
|
|
9319
|
-
throw new
|
|
9685
|
+
throw new CliUserError44(`${key} must use https (http only for localhost).`);
|
|
9320
9686
|
}
|
|
9321
9687
|
if (url.username || url.password) {
|
|
9322
|
-
throw new
|
|
9688
|
+
throw new CliUserError44(`${key} must not carry credentials.`);
|
|
9323
9689
|
}
|
|
9324
9690
|
return trimmed;
|
|
9325
9691
|
}
|
|
9326
9692
|
case "environment": {
|
|
9327
9693
|
const upper = trimmed.toUpperCase();
|
|
9328
9694
|
if (!ENVIRONMENTS4.includes(upper)) {
|
|
9329
|
-
throw new
|
|
9695
|
+
throw new CliUserError44(`environment must be one of ${ENVIRONMENTS4.join(", ")}.`);
|
|
9330
9696
|
}
|
|
9331
9697
|
return upper;
|
|
9332
9698
|
}
|
|
@@ -9340,15 +9706,15 @@ function checkProfileValue(key, value, profile) {
|
|
|
9340
9706
|
async function readToken(env, fromEnv) {
|
|
9341
9707
|
if (fromEnv !== undefined) {
|
|
9342
9708
|
if (!ENV_NAME3.test(fromEnv))
|
|
9343
|
-
throw new
|
|
9709
|
+
throw new CliUserError44("Invalid environment variable name for --from-env.");
|
|
9344
9710
|
const value = env.env[fromEnv]?.trim() ?? "";
|
|
9345
9711
|
if (value === "")
|
|
9346
|
-
throw new
|
|
9712
|
+
throw new CliUserError44(`The environment variable ${fromEnv} is empty or unset.`);
|
|
9347
9713
|
return value;
|
|
9348
9714
|
}
|
|
9349
9715
|
const piped = (await env.readStdin()).trim();
|
|
9350
9716
|
if (piped === "") {
|
|
9351
|
-
throw new
|
|
9717
|
+
throw new CliUserError44("Pipe the token on standard input, or pass --from-env <VAR>.", {
|
|
9352
9718
|
hint: 'For example: `printf %s "$TOKEN" | fluidgrids config set token --profile prod`.'
|
|
9353
9719
|
});
|
|
9354
9720
|
}
|
|
@@ -9368,7 +9734,7 @@ async function runConfigSet(env, key, value, options) {
|
|
|
9368
9734
|
const profile = profileName(env, options);
|
|
9369
9735
|
if (key === "token") {
|
|
9370
9736
|
if (value !== undefined) {
|
|
9371
|
-
throw new
|
|
9737
|
+
throw new CliUserError44("A token is never given on the command line.", {
|
|
9372
9738
|
hint: "Pipe it on standard input, or pass --from-env <VAR>."
|
|
9373
9739
|
});
|
|
9374
9740
|
}
|
|
@@ -9385,12 +9751,12 @@ async function runConfigSet(env, key, value, options) {
|
|
|
9385
9751
|
return out;
|
|
9386
9752
|
}
|
|
9387
9753
|
if (!isProfileKey(key)) {
|
|
9388
|
-
throw new
|
|
9754
|
+
throw new CliUserError44(`Unknown profile key ${key}.`, {
|
|
9389
9755
|
hint: `Keys: ${PROFILE_KEYS.join(", ")}, token, defaultProfile.`
|
|
9390
9756
|
});
|
|
9391
9757
|
}
|
|
9392
9758
|
if (value === undefined)
|
|
9393
|
-
throw new
|
|
9759
|
+
throw new CliUserError44(`Give a value for ${key}.`);
|
|
9394
9760
|
const checked = checkProfileValue(key, value, profile);
|
|
9395
9761
|
updateConfig(file, (document) => {
|
|
9396
9762
|
const table = profileTable(document, profile, true);
|
|
@@ -9406,7 +9772,7 @@ async function runConfigGet(env, key, options) {
|
|
|
9406
9772
|
const config = readConfig(file);
|
|
9407
9773
|
const resolved = resolveProfile(config, env.env, options.profile, file);
|
|
9408
9774
|
if (key !== undefined && !isProfileKey(key)) {
|
|
9409
|
-
throw new
|
|
9775
|
+
throw new CliUserError44(`Unknown profile key ${key}.`, {
|
|
9410
9776
|
hint: `Keys: ${PROFILE_KEYS.join(", ")}.`
|
|
9411
9777
|
});
|
|
9412
9778
|
}
|
|
@@ -9451,10 +9817,10 @@ async function runConfigDelete(env, key, options) {
|
|
|
9451
9817
|
const profile = profileName(env, options);
|
|
9452
9818
|
const existing = readConfig(file).profiles[profile];
|
|
9453
9819
|
if (existing === undefined)
|
|
9454
|
-
throw new
|
|
9820
|
+
throw new CliUserError44(`There is no profile ${profile} in ${file}.`);
|
|
9455
9821
|
if (key !== undefined) {
|
|
9456
9822
|
if (!isProfileKey(key))
|
|
9457
|
-
throw new
|
|
9823
|
+
throw new CliUserError44(`Unknown profile key ${key}.`);
|
|
9458
9824
|
updateConfig(file, (document) => {
|
|
9459
9825
|
const table = profileTable(document, profile, false);
|
|
9460
9826
|
if (table)
|
|
@@ -9491,7 +9857,7 @@ async function runConfigMigrate(env, options) {
|
|
|
9491
9857
|
values.workspace = workspace;
|
|
9492
9858
|
if (options.tokenEnv !== undefined) {
|
|
9493
9859
|
if (!ENV_NAME3.test(options.tokenEnv))
|
|
9494
|
-
throw new
|
|
9860
|
+
throw new CliUserError44("Invalid environment variable name for --token-env.");
|
|
9495
9861
|
values.tokenRef = `env:${options.tokenEnv}`;
|
|
9496
9862
|
}
|
|
9497
9863
|
updateConfig(file, (document) => {
|
|
@@ -9516,7 +9882,7 @@ var init_commands = __esm(() => {
|
|
|
9516
9882
|
});
|
|
9517
9883
|
|
|
9518
9884
|
// src/phase-c/commands/workers.ts
|
|
9519
|
-
import { CliUserError as
|
|
9885
|
+
import { CliUserError as CliUserError45 } from "@burdenoff/cli-sdk/core";
|
|
9520
9886
|
function workerRows(workers) {
|
|
9521
9887
|
return workers.map((worker) => [
|
|
9522
9888
|
worker.identity,
|
|
@@ -9530,7 +9896,7 @@ function workerRows(workers) {
|
|
|
9530
9896
|
}
|
|
9531
9897
|
async function runWorkersList(env, options) {
|
|
9532
9898
|
if (options.stale && options.notStale) {
|
|
9533
|
-
throw new
|
|
9899
|
+
throw new CliUserError45("Give --stale or --not-stale, not both.");
|
|
9534
9900
|
}
|
|
9535
9901
|
const filter = {
|
|
9536
9902
|
...options.queue ? { taskQueue: checkWorkerQueue(options.queue) } : {},
|
|
@@ -9573,7 +9939,7 @@ function connectionNames(raw) {
|
|
|
9573
9939
|
const names = parseList(raw);
|
|
9574
9940
|
for (const name of names) {
|
|
9575
9941
|
if (!CONNECTION_NAME.test(name)) {
|
|
9576
|
-
throw new
|
|
9942
|
+
throw new CliUserError45(`Invalid connection name '${name}'.`);
|
|
9577
9943
|
}
|
|
9578
9944
|
}
|
|
9579
9945
|
return names;
|
|
@@ -9588,10 +9954,10 @@ function issued(env, options, result) {
|
|
|
9588
9954
|
async function runTokensCreate(env, name, options) {
|
|
9589
9955
|
const tokenName = name.trim();
|
|
9590
9956
|
if (tokenName === "")
|
|
9591
|
-
throw new
|
|
9957
|
+
throw new CliUserError45("A worker token needs a name.");
|
|
9592
9958
|
const taskQueues = parseList(options.queue).map(checkWorkerQueue);
|
|
9593
9959
|
if (taskQueues.length === 0) {
|
|
9594
|
-
throw new
|
|
9960
|
+
throw new CliUserError45("A worker token needs at least one --queue.", {
|
|
9595
9961
|
hint: "Create the queue first with `fluidgrids queues create <name>`."
|
|
9596
9962
|
});
|
|
9597
9963
|
}
|
|
@@ -9620,10 +9986,10 @@ async function runTokensDelete(env, id, options) {
|
|
|
9620
9986
|
async function runTokensAllowConnections(env, id, names, options) {
|
|
9621
9987
|
const list = connectionNames(names);
|
|
9622
9988
|
if (list.length === 0 && !options.clear) {
|
|
9623
|
-
throw new
|
|
9989
|
+
throw new CliUserError45("Name the connections to allow, or pass --clear to allow none.");
|
|
9624
9990
|
}
|
|
9625
9991
|
if (list.length > 0 && options.clear) {
|
|
9626
|
-
throw new
|
|
9992
|
+
throw new CliUserError45("Give connection names or --clear, not both.");
|
|
9627
9993
|
}
|
|
9628
9994
|
const token = await env.pc.setWorkerTokenConnectionAllowlist(id, list);
|
|
9629
9995
|
emit(env, options, token, { headers: TOKEN_HEADERS, rows: [tokenRow(token)] }, [
|
|
@@ -9643,17 +10009,17 @@ var init_workers = __esm(() => {
|
|
|
9643
10009
|
|
|
9644
10010
|
// src/phase-c/commands/run-control.ts
|
|
9645
10011
|
import { randomUUID } from "crypto";
|
|
9646
|
-
import { CliUserError as
|
|
10012
|
+
import { CliUserError as CliUserError46 } from "@burdenoff/cli-sdk/core";
|
|
9647
10013
|
function runAndName(first, second, flags) {
|
|
9648
10014
|
const targeted = flags.workflowId !== undefined || flags.key !== undefined;
|
|
9649
10015
|
if (targeted) {
|
|
9650
10016
|
if (second !== undefined) {
|
|
9651
|
-
throw new
|
|
10017
|
+
throw new CliUserError46("With --workflow-id, give only the name: `<name> --workflow-id <id> --key <key>`.");
|
|
9652
10018
|
}
|
|
9653
10019
|
return { run: runSelectorOf(undefined, flags), name: first };
|
|
9654
10020
|
}
|
|
9655
10021
|
if (second === undefined) {
|
|
9656
|
-
throw new
|
|
10022
|
+
throw new CliUserError46("Give the run id and the name: `<runId> <name>`.");
|
|
9657
10023
|
}
|
|
9658
10024
|
return { run: runSelectorOf(first, flags), name: second };
|
|
9659
10025
|
}
|
|
@@ -9667,7 +10033,7 @@ async function runQuery(env, first, second, options) {
|
|
|
9667
10033
|
rows: [[result.name, String(result.rejected), JSON.stringify(result.value ?? null)]]
|
|
9668
10034
|
}, result.error ? [`error: ${result.error}`] : []);
|
|
9669
10035
|
if (result.rejected) {
|
|
9670
|
-
throw new
|
|
10036
|
+
throw new CliUserError46(`The query ${name} was refused: ${result.error ?? "no reason given"}`);
|
|
9671
10037
|
}
|
|
9672
10038
|
return result;
|
|
9673
10039
|
}
|
|
@@ -9709,13 +10075,13 @@ async function runUpdate(env, first, second, options) {
|
|
|
9709
10075
|
rows: [[result.updateId, result.name, result.status, JSON.stringify(result.result ?? null)]]
|
|
9710
10076
|
});
|
|
9711
10077
|
if (!reached(result.status, waitFor)) {
|
|
9712
|
-
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}\`.`);
|
|
9713
10079
|
}
|
|
9714
10080
|
if (result.status === "REJECTED") {
|
|
9715
|
-
throw new
|
|
10081
|
+
throw new CliUserError46(`The update ${name} was rejected: ${failureMessage(result.failure)}`);
|
|
9716
10082
|
}
|
|
9717
10083
|
if (result.status === "COMPLETED" && result.failure !== null && result.failure !== undefined) {
|
|
9718
|
-
throw new
|
|
10084
|
+
throw new CliUserError46(`The update handler of ${name} failed: ${failureMessage(result.failure)}`);
|
|
9719
10085
|
}
|
|
9720
10086
|
return result;
|
|
9721
10087
|
}
|
|
@@ -9731,33 +10097,33 @@ async function runUpdateStatus(env, first, second, options) {
|
|
|
9731
10097
|
function parseResetTo(raw, buildId) {
|
|
9732
10098
|
const value = raw?.trim() ?? "";
|
|
9733
10099
|
if (value === "") {
|
|
9734
|
-
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.");
|
|
9735
10101
|
}
|
|
9736
10102
|
if (/^\d+$/.test(value)) {
|
|
9737
10103
|
if (buildId !== undefined)
|
|
9738
|
-
throw new
|
|
10104
|
+
throw new CliUserError46("--build-id goes with --to build-id only.");
|
|
9739
10105
|
const seq = Number(value);
|
|
9740
10106
|
if (!Number.isSafeInteger(seq) || seq <= 0) {
|
|
9741
|
-
throw new
|
|
10107
|
+
throw new CliUserError46(`Invalid value '${raw}' for --to: a seq is a positive integer.`);
|
|
9742
10108
|
}
|
|
9743
10109
|
return { seq };
|
|
9744
10110
|
}
|
|
9745
10111
|
const normal = value.toUpperCase().replace(/-/g, "_");
|
|
9746
10112
|
if (normal === "LAST_CLEAN_TASK") {
|
|
9747
10113
|
if (buildId !== undefined)
|
|
9748
|
-
throw new
|
|
10114
|
+
throw new CliUserError46("--build-id goes with --to build-id only.");
|
|
9749
10115
|
return "LAST_CLEAN_TASK";
|
|
9750
10116
|
}
|
|
9751
10117
|
const type = parseEnumOption(normal === "LAST_CONTINUE_AS_NEW" ? "LAST_CONTINUED_AS_NEW" : normal, "--to", RESET_TYPES);
|
|
9752
10118
|
if (type === "BUILD_ID") {
|
|
9753
10119
|
const id = buildId?.trim() ?? "";
|
|
9754
10120
|
if (!/^sha256:[0-9a-f]{64}$/.test(id)) {
|
|
9755
|
-
throw new
|
|
10121
|
+
throw new CliUserError46("--to build-id needs --build-id sha256:<64 hex>.");
|
|
9756
10122
|
}
|
|
9757
10123
|
return { type, buildId: id };
|
|
9758
10124
|
}
|
|
9759
10125
|
if (buildId !== undefined)
|
|
9760
|
-
throw new
|
|
10126
|
+
throw new CliUserError46("--build-id goes with --to build-id only.");
|
|
9761
10127
|
return { type };
|
|
9762
10128
|
}
|
|
9763
10129
|
async function runReset(env, runId, options) {
|
|
@@ -9816,7 +10182,7 @@ async function runTrace(env, runIdArg, options) {
|
|
|
9816
10182
|
const runId = await env.pc.runIdOf(runSelectorOf(runIdArg, options));
|
|
9817
10183
|
const hierarchy = await env.pc.runHierarchy(runId);
|
|
9818
10184
|
if (!hierarchy)
|
|
9819
|
-
throw new
|
|
10185
|
+
throw new CliUserError46(`Run ${runId} not found (NOT_FOUND)`);
|
|
9820
10186
|
const entries = flatten(hierarchy);
|
|
9821
10187
|
const open = entries.filter((entry) => OPEN_STATUSES.includes(entry.run.status));
|
|
9822
10188
|
const read = new Map;
|
|
@@ -9856,32 +10222,32 @@ var init_run_control = __esm(() => {
|
|
|
9856
10222
|
});
|
|
9857
10223
|
|
|
9858
10224
|
// src/phase-c/commands/activities.ts
|
|
9859
|
-
import { CliUserError as
|
|
10225
|
+
import { CliUserError as CliUserError47 } from "@burdenoff/cli-sdk/core";
|
|
9860
10226
|
import { durationMs as durationMs2 } from "@fluidgrids/workflows/ir";
|
|
9861
10227
|
function completionOf(env, first, second, options) {
|
|
9862
10228
|
if (options.taskTokenEnv !== undefined) {
|
|
9863
10229
|
if (first !== undefined || options.workflowId !== undefined || options.key !== undefined) {
|
|
9864
|
-
throw new
|
|
10230
|
+
throw new CliUserError47("Give --task-token-env, or the run and activity id, not both.");
|
|
9865
10231
|
}
|
|
9866
10232
|
const variable = options.taskTokenEnv.trim();
|
|
9867
10233
|
if (!ENV_NAME4.test(variable)) {
|
|
9868
|
-
throw new
|
|
10234
|
+
throw new CliUserError47("Invalid environment variable name for --task-token-env.");
|
|
9869
10235
|
}
|
|
9870
10236
|
const taskToken = env.getEnv(variable)?.trim() ?? "";
|
|
9871
10237
|
if (taskToken === "") {
|
|
9872
|
-
throw new
|
|
10238
|
+
throw new CliUserError47(`The environment variable ${variable} (--task-token-env) is empty or unset.`);
|
|
9873
10239
|
}
|
|
9874
10240
|
return { kind: "token", taskToken };
|
|
9875
10241
|
}
|
|
9876
10242
|
const targeted = options.workflowId !== undefined || options.key !== undefined;
|
|
9877
10243
|
if (targeted) {
|
|
9878
10244
|
if (first === undefined || second !== undefined) {
|
|
9879
|
-
throw new
|
|
10245
|
+
throw new CliUserError47("With --workflow-id, give only the activity id.");
|
|
9880
10246
|
}
|
|
9881
10247
|
return { kind: "id", run: runSelectorOf(undefined, options), activityId: first };
|
|
9882
10248
|
}
|
|
9883
10249
|
if (first === undefined || second === undefined) {
|
|
9884
|
-
throw new
|
|
10250
|
+
throw new CliUserError47("Give `<runId> <activityId>`, `<activityId> --workflow-id <id> --key <key>`, or --task-token-env.");
|
|
9885
10251
|
}
|
|
9886
10252
|
return { kind: "id", run: runSelectorOf(first, options), activityId: second };
|
|
9887
10253
|
}
|
|
@@ -9939,7 +10305,7 @@ function selectorOf(options) {
|
|
|
9939
10305
|
options.all === true
|
|
9940
10306
|
];
|
|
9941
10307
|
if (given.filter(Boolean).length !== 1) {
|
|
9942
|
-
throw new
|
|
10308
|
+
throw new CliUserError47("Choose the activities with exactly one of --activity-id, --type or --all.");
|
|
9943
10309
|
}
|
|
9944
10310
|
if (options.activityId !== undefined) {
|
|
9945
10311
|
return { activityId: requireText(options.activityId, "--activity-id") };
|
|
@@ -9980,18 +10346,18 @@ function parseMs(raw, flag) {
|
|
|
9980
10346
|
const value = raw.trim();
|
|
9981
10347
|
const ms = /^\d+$/.test(value) ? Number(value) : value === "" ? undefined : durationMs2(value, "ms");
|
|
9982
10348
|
if (ms === undefined || !Number.isFinite(ms) || ms <= 0 || !Number.isSafeInteger(Math.round(ms))) {
|
|
9983
|
-
throw new
|
|
10349
|
+
throw new CliUserError47(`Invalid value '${raw}' for ${flag}: expected milliseconds or a duration such as 1.5s, 5m or PT2H.`);
|
|
9984
10350
|
}
|
|
9985
10351
|
return Math.round(ms);
|
|
9986
10352
|
}
|
|
9987
10353
|
function activityOptionsOf(options) {
|
|
9988
10354
|
const maxRetries = options.maxRetries === undefined ? undefined : /^\d+$/.test(options.maxRetries.trim()) ? Number(options.maxRetries.trim()) : NaN;
|
|
9989
10355
|
if (Number.isNaN(maxRetries)) {
|
|
9990
|
-
throw new
|
|
10356
|
+
throw new CliUserError47(`Invalid value '${options.maxRetries}' for --max-retries.`);
|
|
9991
10357
|
}
|
|
9992
10358
|
const backoff = options.backoff === undefined ? undefined : Number(options.backoff.trim());
|
|
9993
10359
|
if (backoff !== undefined && (!Number.isFinite(backoff) || backoff < 1)) {
|
|
9994
|
-
throw new
|
|
10360
|
+
throw new CliUserError47(`Invalid value '${options.backoff}' for --backoff: at least 1.`);
|
|
9995
10361
|
}
|
|
9996
10362
|
const retryOn = [];
|
|
9997
10363
|
for (const value of parseList(options.retryOn)) {
|
|
@@ -10015,7 +10381,7 @@ function activityOptionsOf(options) {
|
|
|
10015
10381
|
};
|
|
10016
10382
|
const out = { ...timeouts, ...Object.keys(retry).length > 0 ? { retry } : {} };
|
|
10017
10383
|
if (Object.keys(out).length === 0) {
|
|
10018
|
-
throw new
|
|
10384
|
+
throw new CliUserError47("Nothing to change: give a retry option or a timeout.");
|
|
10019
10385
|
}
|
|
10020
10386
|
return out;
|
|
10021
10387
|
}
|
|
@@ -10042,10 +10408,10 @@ async function runPauseRulesList(env, options) {
|
|
|
10042
10408
|
}
|
|
10043
10409
|
async function runPauseRulesCreate(env, options) {
|
|
10044
10410
|
if (options.activityType === undefined && options.nodeType === undefined && options.workflowKey === undefined) {
|
|
10045
|
-
throw new
|
|
10411
|
+
throw new CliUserError47("A pause rule needs --activity-type, --node-type or --workflow-key.");
|
|
10046
10412
|
}
|
|
10047
10413
|
if (options.expiresAt !== undefined && options.expiresIn !== undefined) {
|
|
10048
|
-
throw new
|
|
10414
|
+
throw new CliUserError47("Give --expires-at or --expires-in, not both.");
|
|
10049
10415
|
}
|
|
10050
10416
|
const expiresIn = parseMs(options.expiresIn, "--expires-in");
|
|
10051
10417
|
const expiresAt = expiresIn !== undefined ? new Date(Date.now() + expiresIn).toISOString() : parseInstant(options.expiresAt, "--expires-at");
|
|
@@ -10083,7 +10449,7 @@ var init_activities = __esm(() => {
|
|
|
10083
10449
|
});
|
|
10084
10450
|
|
|
10085
10451
|
// src/phase-c/commands/batch.ts
|
|
10086
|
-
import { CliUserError as
|
|
10452
|
+
import { CliUserError as CliUserError48 } from "@burdenoff/cli-sdk/core";
|
|
10087
10453
|
function isBatchType(name) {
|
|
10088
10454
|
return Object.hasOwn(BATCH_TYPES, name);
|
|
10089
10455
|
}
|
|
@@ -10096,7 +10462,7 @@ function batchSelection(options) {
|
|
|
10096
10462
|
if (options.filter !== undefined) {
|
|
10097
10463
|
const raw = parseJsonOption(options.filter, "--filter");
|
|
10098
10464
|
if (!isRecord20(raw))
|
|
10099
|
-
throw new
|
|
10465
|
+
throw new CliUserError48("--filter must be a JSON object (ListWorkflowRunsInput).");
|
|
10100
10466
|
Object.assign(filter, raw);
|
|
10101
10467
|
delete filter["limit"];
|
|
10102
10468
|
delete filter["offset"];
|
|
@@ -10116,19 +10482,19 @@ function batchSelection(options) {
|
|
|
10116
10482
|
if (options.searchAttributes !== undefined) {
|
|
10117
10483
|
const query = parseJsonOption(options.searchAttributes, "--search-attributes");
|
|
10118
10484
|
if (!isRecord20(query)) {
|
|
10119
|
-
throw new
|
|
10485
|
+
throw new CliUserError48("--search-attributes must be a JSON object ({and, or, text}).");
|
|
10120
10486
|
}
|
|
10121
10487
|
filter["searchAttributes"] = query;
|
|
10122
10488
|
}
|
|
10123
10489
|
const filtered = Object.keys(filter).length > 0;
|
|
10124
10490
|
if (runIds.length > 0 && filtered) {
|
|
10125
|
-
throw new
|
|
10491
|
+
throw new CliUserError48("Choose the runs with --run-id or with filter options, not both.");
|
|
10126
10492
|
}
|
|
10127
10493
|
if (runIds.length > MAX_BATCH_RUN_IDS) {
|
|
10128
|
-
throw new
|
|
10494
|
+
throw new CliUserError48(`At most ${MAX_BATCH_RUN_IDS} --run-id values; use a filter for more.`);
|
|
10129
10495
|
}
|
|
10130
10496
|
if (runIds.length === 0 && !filtered) {
|
|
10131
|
-
throw new
|
|
10497
|
+
throw new CliUserError48("Choose the runs: --run-id, or a filter (--key, --status, --kind, --workflow-id, --search-attributes, --filter).");
|
|
10132
10498
|
}
|
|
10133
10499
|
const rate = parsePositiveInt(options.rate, "--rate");
|
|
10134
10500
|
return {
|
|
@@ -10190,7 +10556,7 @@ function batchPayload(type, options) {
|
|
|
10190
10556
|
options.clearOverride === true
|
|
10191
10557
|
];
|
|
10192
10558
|
if (chosen.filter(Boolean).length !== 1) {
|
|
10193
|
-
throw new
|
|
10559
|
+
throw new CliUserError48("Give exactly one of --pin <version>, --auto-upgrade or --clear-override.");
|
|
10194
10560
|
}
|
|
10195
10561
|
if (options.clearOverride)
|
|
10196
10562
|
return { clearVersioningOverride: true };
|
|
@@ -10224,7 +10590,7 @@ function refuseUnused(type, options) {
|
|
|
10224
10590
|
unused.push("--activity-id/--type/--all");
|
|
10225
10591
|
}
|
|
10226
10592
|
if (unused.length > 0) {
|
|
10227
|
-
throw new
|
|
10593
|
+
throw new CliUserError48(`${unused.join(", ")} do not apply to a ${type} batch.`);
|
|
10228
10594
|
}
|
|
10229
10595
|
}
|
|
10230
10596
|
function jobRow(job) {
|
|
@@ -10252,7 +10618,7 @@ function jobDetails(job) {
|
|
|
10252
10618
|
}
|
|
10253
10619
|
async function runBatchStart(env, typeName, options) {
|
|
10254
10620
|
if (!isBatchType(typeName)) {
|
|
10255
|
-
throw new
|
|
10621
|
+
throw new CliUserError48(`Unknown batch type '${typeName}'. Allowed: ${Object.keys(BATCH_TYPES).join(", ")}`);
|
|
10256
10622
|
}
|
|
10257
10623
|
const type = BATCH_TYPES[typeName];
|
|
10258
10624
|
refuseUnused(type, options);
|
|
@@ -10302,10 +10668,10 @@ async function runBatchDescribe(env, id, options) {
|
|
|
10302
10668
|
}
|
|
10303
10669
|
emit(env, options, job, { headers: JOB_HEADERS, rows: [jobRow(job)] }, jobDetails(job));
|
|
10304
10670
|
if (options.watch && !TERMINAL_JOB.includes(job.status)) {
|
|
10305
|
-
throw new
|
|
10671
|
+
throw new CliUserError48(`Batch job ${id} is still ${job.status} after ${timeout} ms.`);
|
|
10306
10672
|
}
|
|
10307
10673
|
if (options.watch && (job.status === "FAILED" || job.status === "CANCELLED")) {
|
|
10308
|
-
throw new
|
|
10674
|
+
throw new CliUserError48(`Batch job ${id} ended ${job.status}${job.failureMessage ? `: ${job.failureMessage}` : ""}.`);
|
|
10309
10675
|
}
|
|
10310
10676
|
return job;
|
|
10311
10677
|
}
|
|
@@ -10349,7 +10715,7 @@ var init_batch = __esm(() => {
|
|
|
10349
10715
|
});
|
|
10350
10716
|
|
|
10351
10717
|
// src/phase-d/duration.ts
|
|
10352
|
-
import { CliUserError as
|
|
10718
|
+
import { CliUserError as CliUserError49 } from "@burdenoff/cli-sdk/core";
|
|
10353
10719
|
import { toMs } from "@fluidgrids/workflows";
|
|
10354
10720
|
function parseDurationOption(raw, flag) {
|
|
10355
10721
|
if (raw === undefined)
|
|
@@ -10359,7 +10725,7 @@ function parseDurationOption(raw, flag) {
|
|
|
10359
10725
|
try {
|
|
10360
10726
|
toMs(sent, flag);
|
|
10361
10727
|
} catch {
|
|
10362
|
-
throw new
|
|
10728
|
+
throw new CliUserError49(`Invalid value '${raw}' for ${flag}: expected a duration such as 1500 (milliseconds), 30s, 5m, 2h or PT2H.`);
|
|
10363
10729
|
}
|
|
10364
10730
|
return sent;
|
|
10365
10731
|
}
|
|
@@ -10368,14 +10734,14 @@ var init_duration = () => {};
|
|
|
10368
10734
|
// src/phase-d/commands/activity-start.ts
|
|
10369
10735
|
import { existsSync as existsSync15, readFileSync as readFileSync12 } from "fs";
|
|
10370
10736
|
import { resolve as resolve12 } from "path";
|
|
10371
|
-
import { CliUserError as
|
|
10737
|
+
import { CliUserError as CliUserError50 } from "@burdenoff/cli-sdk/core";
|
|
10372
10738
|
function retryPolicy(raw, maxAttempts, readFile) {
|
|
10373
10739
|
const parsed = parseJsonObjectArg(raw, "--retry", readFile);
|
|
10374
10740
|
const policy = {};
|
|
10375
10741
|
if (parsed !== undefined) {
|
|
10376
10742
|
for (const key of Object.keys(parsed)) {
|
|
10377
10743
|
if (!RETRY_KEYS.some((known) => known === key)) {
|
|
10378
|
-
throw new
|
|
10744
|
+
throw new CliUserError50(`--retry: unknown field ${key}. Allowed: ${RETRY_KEYS.join(", ")}`);
|
|
10379
10745
|
}
|
|
10380
10746
|
}
|
|
10381
10747
|
const text = (key) => {
|
|
@@ -10383,7 +10749,7 @@ function retryPolicy(raw, maxAttempts, readFile) {
|
|
|
10383
10749
|
if (value === undefined)
|
|
10384
10750
|
return;
|
|
10385
10751
|
if (typeof value !== "string")
|
|
10386
|
-
throw new
|
|
10752
|
+
throw new CliUserError50(`--retry: ${key} must be a duration.`);
|
|
10387
10753
|
policy[key] = parseDurationOption(value, `--retry ${key}`);
|
|
10388
10754
|
};
|
|
10389
10755
|
text("initialInterval");
|
|
@@ -10391,21 +10757,21 @@ function retryPolicy(raw, maxAttempts, readFile) {
|
|
|
10391
10757
|
const backoff = parsed["backoffCoefficient"];
|
|
10392
10758
|
if (backoff !== undefined) {
|
|
10393
10759
|
if (typeof backoff !== "number" || !Number.isFinite(backoff) || backoff < 1) {
|
|
10394
|
-
throw new
|
|
10760
|
+
throw new CliUserError50("--retry: backoffCoefficient must be a number of at least 1.");
|
|
10395
10761
|
}
|
|
10396
10762
|
policy.backoffCoefficient = backoff;
|
|
10397
10763
|
}
|
|
10398
10764
|
const attempts = parsed["maximumAttempts"];
|
|
10399
10765
|
if (attempts !== undefined) {
|
|
10400
10766
|
if (typeof attempts !== "number" || !Number.isSafeInteger(attempts) || attempts < 0) {
|
|
10401
|
-
throw new
|
|
10767
|
+
throw new CliUserError50("--retry: maximumAttempts must be a whole number (0 = unlimited).");
|
|
10402
10768
|
}
|
|
10403
10769
|
policy.maximumAttempts = attempts;
|
|
10404
10770
|
}
|
|
10405
10771
|
const types = parsed["nonRetryableErrorTypes"];
|
|
10406
10772
|
if (types !== undefined) {
|
|
10407
10773
|
if (!Array.isArray(types) || types.some((type) => typeof type !== "string")) {
|
|
10408
|
-
throw new
|
|
10774
|
+
throw new CliUserError50("--retry: nonRetryableErrorTypes must be a list of strings.");
|
|
10409
10775
|
}
|
|
10410
10776
|
policy.nonRetryableErrorTypes = types.filter((type) => typeof type === "string");
|
|
10411
10777
|
}
|
|
@@ -10413,7 +10779,7 @@ function retryPolicy(raw, maxAttempts, readFile) {
|
|
|
10413
10779
|
if (maxAttempts !== undefined) {
|
|
10414
10780
|
const value = maxAttempts.trim();
|
|
10415
10781
|
if (!/^\d+$/.test(value) || !Number.isSafeInteger(Number(value))) {
|
|
10416
|
-
throw new
|
|
10782
|
+
throw new CliUserError50(`Invalid value '${maxAttempts}' for --max-attempts: expected a whole number (0 = unlimited).`);
|
|
10417
10783
|
}
|
|
10418
10784
|
policy.maximumAttempts = Number(value);
|
|
10419
10785
|
}
|
|
@@ -10422,29 +10788,29 @@ function retryPolicy(raw, maxAttempts, readFile) {
|
|
|
10422
10788
|
function requireName(raw, what) {
|
|
10423
10789
|
const value = raw.trim();
|
|
10424
10790
|
if (value === "")
|
|
10425
|
-
throw new
|
|
10791
|
+
throw new CliUserError50(`The ${what} is empty.`);
|
|
10426
10792
|
return value;
|
|
10427
10793
|
}
|
|
10428
10794
|
async function runActivityStart(env, nodeType, operation, options) {
|
|
10429
10795
|
const readFile = (path) => {
|
|
10430
10796
|
const absolute = resolve12(env.cwd(), path);
|
|
10431
10797
|
if (!existsSync15(absolute))
|
|
10432
|
-
throw new
|
|
10798
|
+
throw new CliUserError50(`${path} does not exist.`);
|
|
10433
10799
|
return readFileSync12(absolute, "utf8");
|
|
10434
10800
|
};
|
|
10435
10801
|
if (options.args === undefined) {
|
|
10436
|
-
throw new
|
|
10802
|
+
throw new CliUserError50("--args is required: the operation arguments as a JSON object.", {
|
|
10437
10803
|
hint: `For example --args '{"url":"https://example.com"}', or --args @args.json.`
|
|
10438
10804
|
});
|
|
10439
10805
|
}
|
|
10440
10806
|
const args = parseJsonObjectArg(options.args, "--args", readFile) ?? {};
|
|
10441
10807
|
const summary = options.summary?.trim();
|
|
10442
10808
|
if (summary !== undefined && (summary === "" || summary.length > MAX_SUMMARY_CHARS)) {
|
|
10443
|
-
throw new
|
|
10809
|
+
throw new CliUserError50(`--summary is 1 to ${MAX_SUMMARY_CHARS} characters.`);
|
|
10444
10810
|
}
|
|
10445
10811
|
const key = options.idempotencyKey?.trim();
|
|
10446
10812
|
if (key !== undefined && !IDEMPOTENCY_KEY.test(key)) {
|
|
10447
|
-
throw new
|
|
10813
|
+
throw new CliUserError50(`--idempotency-key is 1 to ${MAX_IDEMPOTENCY_KEY_CHARS} letters, digits, dots, underscores, colons or dashes.`);
|
|
10448
10814
|
}
|
|
10449
10815
|
const retry = retryPolicy(options.retry, options.maxAttempts, readFile);
|
|
10450
10816
|
const nodeVersion = options.nodeVersion?.trim();
|
|
@@ -10488,7 +10854,7 @@ async function runActivityStart(env, nodeType, operation, options) {
|
|
|
10488
10854
|
rows: [[result.run.id, finalStatus, started.existing ? "yes" : "no"]]
|
|
10489
10855
|
}, details);
|
|
10490
10856
|
if (options.wait && finalStatus !== "COMPLETED") {
|
|
10491
|
-
throw new
|
|
10857
|
+
throw new CliUserError50(`Run ${started.run.id} ended ${finalStatus}.`);
|
|
10492
10858
|
}
|
|
10493
10859
|
return result;
|
|
10494
10860
|
}
|
|
@@ -10509,7 +10875,7 @@ var init_activity_start = __esm(() => {
|
|
|
10509
10875
|
});
|
|
10510
10876
|
|
|
10511
10877
|
// src/phase-c/commands/signal-tokens.ts
|
|
10512
|
-
import { CliUserError as
|
|
10878
|
+
import { CliUserError as CliUserError51 } from "@burdenoff/cli-sdk/core";
|
|
10513
10879
|
function row(token) {
|
|
10514
10880
|
return [
|
|
10515
10881
|
token.id,
|
|
@@ -10526,12 +10892,12 @@ async function runSignalTokenCreate(env, runId, options) {
|
|
|
10526
10892
|
const signalName = requireText(options.signal, "--signal");
|
|
10527
10893
|
const ttlMs = parseMs(options.ttl, "--ttl");
|
|
10528
10894
|
if (ttlMs !== undefined && ttlMs % 1000 !== 0) {
|
|
10529
|
-
throw new
|
|
10895
|
+
throw new CliUserError51("--ttl is counted in whole seconds.");
|
|
10530
10896
|
}
|
|
10531
10897
|
const ipAllowlist = parseList(options.allowIp);
|
|
10532
10898
|
for (const entry of ipAllowlist) {
|
|
10533
10899
|
if (!IPV4_OR_CIDR.test(entry)) {
|
|
10534
|
-
throw new
|
|
10900
|
+
throw new CliUserError51(`Invalid --allow-ip '${entry}': an IPv4 address or CIDR range.`);
|
|
10535
10901
|
}
|
|
10536
10902
|
}
|
|
10537
10903
|
const created = await env.pc.createSignalToken({
|
|
@@ -10567,7 +10933,7 @@ var init_signal_tokens = __esm(() => {
|
|
|
10567
10933
|
});
|
|
10568
10934
|
|
|
10569
10935
|
// src/phase-c/commands/search-attributes.ts
|
|
10570
|
-
import { CliUserError as
|
|
10936
|
+
import { CliUserError as CliUserError52 } from "@burdenoff/cli-sdk/core";
|
|
10571
10937
|
function row2(attribute) {
|
|
10572
10938
|
return [
|
|
10573
10939
|
attribute.name,
|
|
@@ -10584,11 +10950,11 @@ async function runSearchAttributesList(env, options) {
|
|
|
10584
10950
|
}
|
|
10585
10951
|
async function runSearchAttributesCreate(env, name, options) {
|
|
10586
10952
|
if (!NAME.test(name)) {
|
|
10587
|
-
throw new
|
|
10953
|
+
throw new CliUserError52(`Invalid search attribute name '${name}': a letter, then letters, digits and underscores (at most 64).`);
|
|
10588
10954
|
}
|
|
10589
10955
|
const type = parseEnumOption(options.type, "--type", SEARCH_ATTRIBUTE_TYPES);
|
|
10590
10956
|
if (type === undefined) {
|
|
10591
|
-
throw new
|
|
10957
|
+
throw new CliUserError52(`--type is required: ${SEARCH_ATTRIBUTE_TYPES.join(", ")}.`);
|
|
10592
10958
|
}
|
|
10593
10959
|
const attribute = await env.pc.createSearchAttribute({
|
|
10594
10960
|
name,
|
|
@@ -10601,7 +10967,7 @@ async function runSearchAttributesCreate(env, name, options) {
|
|
|
10601
10967
|
async function runSearchAttributesDelete(env, name, options) {
|
|
10602
10968
|
const attribute = (await env.pc.searchAttributes()).find((entry) => entry.name === name);
|
|
10603
10969
|
if (!attribute) {
|
|
10604
|
-
throw new
|
|
10970
|
+
throw new CliUserError52(`The workspace has no search attribute ${name}.`, {
|
|
10605
10971
|
hint: "List them with `fluidgrids search-attributes list`."
|
|
10606
10972
|
});
|
|
10607
10973
|
}
|
|
@@ -10629,7 +10995,7 @@ var init_search_attributes = __esm(() => {
|
|
|
10629
10995
|
});
|
|
10630
10996
|
|
|
10631
10997
|
// src/phase-c/commands/schedules.ts
|
|
10632
|
-
import { CliUserError as
|
|
10998
|
+
import { CliUserError as CliUserError53 } from "@burdenoff/cli-sdk/core";
|
|
10633
10999
|
function isRecord21(value) {
|
|
10634
11000
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10635
11001
|
}
|
|
@@ -10754,9 +11120,9 @@ async function runSchedulesBackfill(env, workflowKey, triggerNodeId, options) {
|
|
|
10754
11120
|
const from = parseInstant(requireText(options.from, "--from"), "--from") ?? "";
|
|
10755
11121
|
const to = parseInstant(requireText(options.to, "--to"), "--to") ?? "";
|
|
10756
11122
|
if (from >= to)
|
|
10757
|
-
throw new
|
|
11123
|
+
throw new CliUserError53("--from must be before --to.");
|
|
10758
11124
|
if (Date.parse(to) > Date.now())
|
|
10759
|
-
throw new
|
|
11125
|
+
throw new CliUserError53("--to must be in the past.");
|
|
10760
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);
|
|
10761
11127
|
const overlapPolicy = parseOverlap(options.overlapPolicy);
|
|
10762
11128
|
const result = await env.pc.backfillSchedule({
|
|
@@ -10808,7 +11174,7 @@ init_json_contract();
|
|
|
10808
11174
|
import { readFileSync as readFileSync13 } from "fs";
|
|
10809
11175
|
import { join as join13, dirname as dirname7 } from "path";
|
|
10810
11176
|
import { fileURLToPath } from "url";
|
|
10811
|
-
import { CliUserError as
|
|
11177
|
+
import { CliUserError as CliUserError54, defaultOutputAdapter } from "@burdenoff/cli-sdk/core";
|
|
10812
11178
|
|
|
10813
11179
|
// src/output/run-envelope.ts
|
|
10814
11180
|
init_json_contract();
|
|
@@ -11373,7 +11739,7 @@ function registerDurable(program, env) {
|
|
|
11373
11739
|
});
|
|
11374
11740
|
addHistory(program, env, "history");
|
|
11375
11741
|
addSignal(program, env, "signal");
|
|
11376
|
-
program.command("replay <history>").description("Replay a history file, a run archive's history.jsonl.gz or a run id against the local code; fails on non-determinism").option("--isolate", "Replay in the QuickJS isolate the managed workers use").option("--debug", "Print the full task result (commands, logs, stack)").option("--trace", "Print every step: the command, the recorded event and the source line").option("--break-on-mismatch", "Stop in an attached debugger where the code diverges").option("--inspect [address]", "Re-run under node --inspect-brk (loopback host:port, default 127.0.0.1:9229); implies --break-on-mismatch").option("--remote-code", "Rebuild the run's exact code from its source archive instead of the local project").option(...PROJECT_OPTION).option(...OUTPUT_OPTION).action(async (history, options, command) => {
|
|
11742
|
+
program.command("replay <history>").description("Replay a history file, a run archive's history.jsonl.gz or a run id against the local code; fails on non-determinism").option("--isolate", "Replay in the QuickJS isolate the managed workers use").option("--debug", "Print the full task result (commands, logs, stack)").option("--trace", "Print every step: the command, the recorded event and the source line").option("--break-on-mismatch", "Stop in an attached debugger where the code diverges").option("--inspect [address]", "Re-run under node --inspect-brk (loopback host:port, default 127.0.0.1:9229); implies --break-on-mismatch").option("--remote-code", "Rebuild the run's exact code from its source archive instead of the local project (asks first: it runs that code here)").option("--yes", "With --remote-code: run the stored code without asking (for scripts)").option(...PROJECT_OPTION).option(...OUTPUT_OPTION).action(async (history, options, command) => {
|
|
11377
11743
|
const resolved = withGlobalFormat(options, command);
|
|
11378
11744
|
if (resolved.trace || resolved.breakOnMismatch || resolved.inspect !== undefined || resolved.remoteCode) {
|
|
11379
11745
|
await Promise.resolve().then(() => init_replay_debug());
|
|
@@ -11452,6 +11818,63 @@ var codeFirstModule = {
|
|
|
11452
11818
|
};
|
|
11453
11819
|
var code_first_default = codeFirstModule;
|
|
11454
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
|
+
|
|
11455
11878
|
// src/phase-c/index.ts
|
|
11456
11879
|
init_shared();
|
|
11457
11880
|
|
|
@@ -11804,7 +12227,8 @@ var modules = [
|
|
|
11804
12227
|
devportalModule,
|
|
11805
12228
|
healthModule,
|
|
11806
12229
|
code_first_default,
|
|
11807
|
-
phase_c_default
|
|
12230
|
+
phase_c_default,
|
|
12231
|
+
mcp_default
|
|
11808
12232
|
];
|
|
11809
12233
|
|
|
11810
12234
|
// src/program.ts
|
|
@@ -11903,7 +12327,7 @@ try {
|
|
|
11903
12327
|
}
|
|
11904
12328
|
} catch (error) {
|
|
11905
12329
|
console.error(`✗ ${error instanceof Error ? error.message : String(error)}`);
|
|
11906
|
-
if (error instanceof
|
|
12330
|
+
if (error instanceof CliUserError54 && error.hint)
|
|
11907
12331
|
console.error(`ℹ ${error.hint}`);
|
|
11908
|
-
process.exitCode = error instanceof
|
|
12332
|
+
process.exitCode = error instanceof CliUserError54 ? error.exitCode : 1;
|
|
11909
12333
|
}
|