@synergenius/flow-weaver 0.10.9 → 0.10.10
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/dist/cli/commands/mcp-setup.d.ts +45 -0
- package/dist/cli/commands/mcp-setup.js +374 -0
- package/dist/cli/flow-weaver.mjs +664 -375
- package/dist/cli/index.js +30 -13
- package/dist/mcp/editor-connection.d.ts +11 -9
- package/dist/mcp/editor-connection.js +29 -12
- package/dist/mcp/resources.d.ts +3 -3
- package/dist/mcp/resources.js +5 -5
- package/dist/mcp/server.js +3 -5
- package/dist/mcp/tools-editor.js +22 -22
- package/dist/mcp/types.d.ts +3 -3
- package/package.json +1 -1
package/dist/cli/flow-weaver.mjs
CHANGED
|
@@ -936,7 +936,7 @@ var require_command = __commonJS({
|
|
|
936
936
|
var EventEmitter2 = __require("events").EventEmitter;
|
|
937
937
|
var childProcess = __require("child_process");
|
|
938
938
|
var path42 = __require("path");
|
|
939
|
-
var
|
|
939
|
+
var fs42 = __require("fs");
|
|
940
940
|
var process6 = __require("process");
|
|
941
941
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
942
942
|
var { CommanderError: CommanderError2 } = require_error();
|
|
@@ -1760,9 +1760,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1760
1760
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
1761
1761
|
function findFile(baseDir, baseName) {
|
|
1762
1762
|
const localBin = path42.resolve(baseDir, baseName);
|
|
1763
|
-
if (
|
|
1763
|
+
if (fs42.existsSync(localBin)) return localBin;
|
|
1764
1764
|
if (sourceExt.includes(path42.extname(baseName))) return void 0;
|
|
1765
|
-
const foundExt = sourceExt.find((ext2) =>
|
|
1765
|
+
const foundExt = sourceExt.find((ext2) => fs42.existsSync(`${localBin}${ext2}`));
|
|
1766
1766
|
if (foundExt) return `${localBin}${foundExt}`;
|
|
1767
1767
|
return void 0;
|
|
1768
1768
|
}
|
|
@@ -1773,7 +1773,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1773
1773
|
if (this._scriptPath) {
|
|
1774
1774
|
let resolvedScriptPath;
|
|
1775
1775
|
try {
|
|
1776
|
-
resolvedScriptPath =
|
|
1776
|
+
resolvedScriptPath = fs42.realpathSync(this._scriptPath);
|
|
1777
1777
|
} catch (err) {
|
|
1778
1778
|
resolvedScriptPath = this._scriptPath;
|
|
1779
1779
|
}
|
|
@@ -6458,10 +6458,10 @@ var init_esm3 = __esm({
|
|
|
6458
6458
|
* Return a void Promise that resolves once the stream ends.
|
|
6459
6459
|
*/
|
|
6460
6460
|
async promise() {
|
|
6461
|
-
return new Promise((
|
|
6461
|
+
return new Promise((resolve30, reject2) => {
|
|
6462
6462
|
this.on(DESTROYED, () => reject2(new Error("stream destroyed")));
|
|
6463
6463
|
this.on("error", (er) => reject2(er));
|
|
6464
|
-
this.on("end", () =>
|
|
6464
|
+
this.on("end", () => resolve30());
|
|
6465
6465
|
});
|
|
6466
6466
|
}
|
|
6467
6467
|
/**
|
|
@@ -6485,7 +6485,7 @@ var init_esm3 = __esm({
|
|
|
6485
6485
|
return Promise.resolve({ done: false, value: res });
|
|
6486
6486
|
if (this[EOF])
|
|
6487
6487
|
return stop();
|
|
6488
|
-
let
|
|
6488
|
+
let resolve30;
|
|
6489
6489
|
let reject2;
|
|
6490
6490
|
const onerr = (er) => {
|
|
6491
6491
|
this.off("data", ondata);
|
|
@@ -6499,19 +6499,19 @@ var init_esm3 = __esm({
|
|
|
6499
6499
|
this.off("end", onend);
|
|
6500
6500
|
this.off(DESTROYED, ondestroy);
|
|
6501
6501
|
this.pause();
|
|
6502
|
-
|
|
6502
|
+
resolve30({ value: value2, done: !!this[EOF] });
|
|
6503
6503
|
};
|
|
6504
6504
|
const onend = () => {
|
|
6505
6505
|
this.off("error", onerr);
|
|
6506
6506
|
this.off("data", ondata);
|
|
6507
6507
|
this.off(DESTROYED, ondestroy);
|
|
6508
6508
|
stop();
|
|
6509
|
-
|
|
6509
|
+
resolve30({ done: true, value: void 0 });
|
|
6510
6510
|
};
|
|
6511
6511
|
const ondestroy = () => onerr(new Error("stream destroyed"));
|
|
6512
6512
|
return new Promise((res2, rej) => {
|
|
6513
6513
|
reject2 = rej;
|
|
6514
|
-
|
|
6514
|
+
resolve30 = res2;
|
|
6515
6515
|
this.once(DESTROYED, ondestroy);
|
|
6516
6516
|
this.once("error", onerr);
|
|
6517
6517
|
this.once("end", onend);
|
|
@@ -7495,9 +7495,9 @@ var init_esm4 = __esm({
|
|
|
7495
7495
|
if (this.#asyncReaddirInFlight) {
|
|
7496
7496
|
await this.#asyncReaddirInFlight;
|
|
7497
7497
|
} else {
|
|
7498
|
-
let
|
|
7498
|
+
let resolve30 = () => {
|
|
7499
7499
|
};
|
|
7500
|
-
this.#asyncReaddirInFlight = new Promise((res) =>
|
|
7500
|
+
this.#asyncReaddirInFlight = new Promise((res) => resolve30 = res);
|
|
7501
7501
|
try {
|
|
7502
7502
|
for (const e of await this.#fs.promises.readdir(fullpath, {
|
|
7503
7503
|
withFileTypes: true
|
|
@@ -7510,7 +7510,7 @@ var init_esm4 = __esm({
|
|
|
7510
7510
|
children.provisional = 0;
|
|
7511
7511
|
}
|
|
7512
7512
|
this.#asyncReaddirInFlight = void 0;
|
|
7513
|
-
|
|
7513
|
+
resolve30();
|
|
7514
7514
|
}
|
|
7515
7515
|
return children.slice(0, children.provisional);
|
|
7516
7516
|
}
|
|
@@ -7740,8 +7740,8 @@ var init_esm4 = __esm({
|
|
|
7740
7740
|
*
|
|
7741
7741
|
* @internal
|
|
7742
7742
|
*/
|
|
7743
|
-
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs:
|
|
7744
|
-
this.#fs = fsFromOption(
|
|
7743
|
+
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs42 = defaultFS } = {}) {
|
|
7744
|
+
this.#fs = fsFromOption(fs42);
|
|
7745
7745
|
if (cwd instanceof URL || cwd.startsWith("file://")) {
|
|
7746
7746
|
cwd = fileURLToPath(cwd);
|
|
7747
7747
|
}
|
|
@@ -8178,14 +8178,14 @@ var init_esm4 = __esm({
|
|
|
8178
8178
|
if (er)
|
|
8179
8179
|
return results.emit("error", er);
|
|
8180
8180
|
if (follow && !didRealpaths) {
|
|
8181
|
-
const
|
|
8181
|
+
const promises3 = [];
|
|
8182
8182
|
for (const e of entries) {
|
|
8183
8183
|
if (e.isSymbolicLink()) {
|
|
8184
|
-
|
|
8184
|
+
promises3.push(e.realpath().then((r) => r?.isUnknown() ? r.lstat() : r));
|
|
8185
8185
|
}
|
|
8186
8186
|
}
|
|
8187
|
-
if (
|
|
8188
|
-
Promise.all(
|
|
8187
|
+
if (promises3.length) {
|
|
8188
|
+
Promise.all(promises3).then(() => onReaddir(null, entries, true));
|
|
8189
8189
|
return;
|
|
8190
8190
|
}
|
|
8191
8191
|
}
|
|
@@ -8299,8 +8299,8 @@ var init_esm4 = __esm({
|
|
|
8299
8299
|
/**
|
|
8300
8300
|
* @internal
|
|
8301
8301
|
*/
|
|
8302
|
-
newRoot(
|
|
8303
|
-
return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
8302
|
+
newRoot(fs42) {
|
|
8303
|
+
return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs42 });
|
|
8304
8304
|
}
|
|
8305
8305
|
/**
|
|
8306
8306
|
* Return true if the provided path string is an absolute path
|
|
@@ -8328,8 +8328,8 @@ var init_esm4 = __esm({
|
|
|
8328
8328
|
/**
|
|
8329
8329
|
* @internal
|
|
8330
8330
|
*/
|
|
8331
|
-
newRoot(
|
|
8332
|
-
return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
8331
|
+
newRoot(fs42) {
|
|
8332
|
+
return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs42 });
|
|
8333
8333
|
}
|
|
8334
8334
|
/**
|
|
8335
8335
|
* Return true if the provided path string is an absolute path
|
|
@@ -9904,7 +9904,7 @@ var require_util = __commonJS({
|
|
|
9904
9904
|
var normalize2 = createSafeHandler((url2) => {
|
|
9905
9905
|
});
|
|
9906
9906
|
exports2.normalize = normalize2;
|
|
9907
|
-
function
|
|
9907
|
+
function join23(aRoot, aPath) {
|
|
9908
9908
|
const pathType = getURLType(aPath);
|
|
9909
9909
|
const rootType = getURLType(aRoot);
|
|
9910
9910
|
aRoot = ensureDirectory(aRoot);
|
|
@@ -9934,7 +9934,7 @@ var require_util = __commonJS({
|
|
|
9934
9934
|
const newPath = withBase(aPath, withBase(aRoot, base));
|
|
9935
9935
|
return computeRelativeURL(base, newPath);
|
|
9936
9936
|
}
|
|
9937
|
-
exports2.join =
|
|
9937
|
+
exports2.join = join23;
|
|
9938
9938
|
function relative6(rootURL, targetURL) {
|
|
9939
9939
|
const result = relativeIfPossible(rootURL, targetURL);
|
|
9940
9940
|
return typeof result === "string" ? result : normalize2(targetURL);
|
|
@@ -9963,8 +9963,8 @@ var require_util = __commonJS({
|
|
|
9963
9963
|
sourceURL = sourceURL.replace(/^\//, "");
|
|
9964
9964
|
}
|
|
9965
9965
|
let url2 = normalize2(sourceURL || "");
|
|
9966
|
-
if (sourceRoot) url2 =
|
|
9967
|
-
if (sourceMapURL) url2 =
|
|
9966
|
+
if (sourceRoot) url2 = join23(sourceRoot, url2);
|
|
9967
|
+
if (sourceMapURL) url2 = join23(trimFilename(sourceMapURL), url2);
|
|
9968
9968
|
return url2;
|
|
9969
9969
|
}
|
|
9970
9970
|
exports2.computeSourceURL = computeSourceURL;
|
|
@@ -10515,17 +10515,17 @@ var require_binary_search = __commonJS({
|
|
|
10515
10515
|
var require_read_wasm = __commonJS({
|
|
10516
10516
|
"node_modules/source-map/lib/read-wasm.js"(exports2, module2) {
|
|
10517
10517
|
"use strict";
|
|
10518
|
-
var
|
|
10518
|
+
var fs42 = __require("fs");
|
|
10519
10519
|
var path42 = __require("path");
|
|
10520
10520
|
module2.exports = function readWasm() {
|
|
10521
|
-
return new Promise((
|
|
10521
|
+
return new Promise((resolve30, reject2) => {
|
|
10522
10522
|
const wasmPath = path42.join(__dirname, "mappings.wasm");
|
|
10523
|
-
|
|
10523
|
+
fs42.readFile(wasmPath, null, (error2, data) => {
|
|
10524
10524
|
if (error2) {
|
|
10525
10525
|
reject2(error2);
|
|
10526
10526
|
return;
|
|
10527
10527
|
}
|
|
10528
|
-
|
|
10528
|
+
resolve30(data.buffer);
|
|
10529
10529
|
});
|
|
10530
10530
|
});
|
|
10531
10531
|
};
|
|
@@ -16002,7 +16002,7 @@ var require_lib4 = __commonJS({
|
|
|
16002
16002
|
// node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js
|
|
16003
16003
|
var require_XMLHttpRequest = __commonJS({
|
|
16004
16004
|
"node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js"(exports2, module2) {
|
|
16005
|
-
var
|
|
16005
|
+
var fs42 = __require("fs");
|
|
16006
16006
|
var Url = __require("url");
|
|
16007
16007
|
var spawn2 = __require("child_process").spawn;
|
|
16008
16008
|
module2.exports = XMLHttpRequest3;
|
|
@@ -16160,7 +16160,7 @@ var require_XMLHttpRequest = __commonJS({
|
|
|
16160
16160
|
throw new Error("XMLHttpRequest: Only GET method is supported");
|
|
16161
16161
|
}
|
|
16162
16162
|
if (settings.async) {
|
|
16163
|
-
|
|
16163
|
+
fs42.readFile(unescape(url2.pathname), function(error2, data2) {
|
|
16164
16164
|
if (error2) {
|
|
16165
16165
|
self2.handleError(error2, error2.errno || -1);
|
|
16166
16166
|
} else {
|
|
@@ -16172,7 +16172,7 @@ var require_XMLHttpRequest = __commonJS({
|
|
|
16172
16172
|
});
|
|
16173
16173
|
} else {
|
|
16174
16174
|
try {
|
|
16175
|
-
this.response =
|
|
16175
|
+
this.response = fs42.readFileSync(unescape(url2.pathname));
|
|
16176
16176
|
this.responseText = this.response.toString("utf8");
|
|
16177
16177
|
this.status = 200;
|
|
16178
16178
|
setState(self2.DONE);
|
|
@@ -16298,15 +16298,15 @@ var require_XMLHttpRequest = __commonJS({
|
|
|
16298
16298
|
} else {
|
|
16299
16299
|
var contentFile = ".node-xmlhttprequest-content-" + process.pid;
|
|
16300
16300
|
var syncFile = ".node-xmlhttprequest-sync-" + process.pid;
|
|
16301
|
-
|
|
16301
|
+
fs42.writeFileSync(syncFile, "", "utf8");
|
|
16302
16302
|
var execString = "var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http" + (ssl ? "s" : "") + ".request;var options = " + JSON.stringify(options) + ";var responseText = '';var responseData = Buffer.alloc(0);var req = doRequest(options, function(response) {response.on('data', function(chunk) { var data = Buffer.from(chunk); responseText += data.toString('utf8'); responseData = Buffer.concat([responseData, data]);});response.on('end', function() {fs.writeFileSync('" + contentFile + "', JSON.stringify({err: null, data: {statusCode: response.statusCode, headers: response.headers, text: responseText, data: responseData.toString('base64')}}), 'utf8');fs.unlinkSync('" + syncFile + "');});response.on('error', function(error) {fs.writeFileSync('" + contentFile + "', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('" + syncFile + "');});}).on('error', function(error) {fs.writeFileSync('" + contentFile + "', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('" + syncFile + "');});" + (data ? "req.write('" + JSON.stringify(data).slice(1, -1).replace(/'/g, "\\'") + "');" : "") + "req.end();";
|
|
16303
16303
|
var syncProc = spawn2(process.argv[0], ["-e", execString]);
|
|
16304
16304
|
var statusText;
|
|
16305
|
-
while (
|
|
16305
|
+
while (fs42.existsSync(syncFile)) {
|
|
16306
16306
|
}
|
|
16307
|
-
self2.responseText =
|
|
16307
|
+
self2.responseText = fs42.readFileSync(contentFile, "utf8");
|
|
16308
16308
|
syncProc.stdin.end();
|
|
16309
|
-
|
|
16309
|
+
fs42.unlinkSync(contentFile);
|
|
16310
16310
|
if (self2.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)) {
|
|
16311
16311
|
var errorObj = JSON.parse(self2.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/, ""));
|
|
16312
16312
|
self2.handleError(errorObj, 503);
|
|
@@ -16959,7 +16959,7 @@ var require_has_flag = __commonJS({
|
|
|
16959
16959
|
var require_supports_color = __commonJS({
|
|
16960
16960
|
"node_modules/supports-color/index.js"(exports2, module2) {
|
|
16961
16961
|
"use strict";
|
|
16962
|
-
var
|
|
16962
|
+
var os4 = __require("os");
|
|
16963
16963
|
var tty = __require("tty");
|
|
16964
16964
|
var hasFlag = require_has_flag();
|
|
16965
16965
|
var { env } = process;
|
|
@@ -17007,7 +17007,7 @@ var require_supports_color = __commonJS({
|
|
|
17007
17007
|
return min;
|
|
17008
17008
|
}
|
|
17009
17009
|
if (process.platform === "win32") {
|
|
17010
|
-
const osRelease =
|
|
17010
|
+
const osRelease = os4.release().split(".");
|
|
17011
17011
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
17012
17012
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
17013
17013
|
}
|
|
@@ -23801,7 +23801,7 @@ var require_compile = __commonJS({
|
|
|
23801
23801
|
const schOrFunc = root2.refs[ref];
|
|
23802
23802
|
if (schOrFunc)
|
|
23803
23803
|
return schOrFunc;
|
|
23804
|
-
let _sch =
|
|
23804
|
+
let _sch = resolve30.call(this, root2, ref);
|
|
23805
23805
|
if (_sch === void 0) {
|
|
23806
23806
|
const schema2 = (_a = root2.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
|
|
23807
23807
|
const { schemaId } = this.opts;
|
|
@@ -23828,7 +23828,7 @@ var require_compile = __commonJS({
|
|
|
23828
23828
|
function sameSchemaEnv(s1, s2) {
|
|
23829
23829
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
23830
23830
|
}
|
|
23831
|
-
function
|
|
23831
|
+
function resolve30(root2, ref) {
|
|
23832
23832
|
let sch;
|
|
23833
23833
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
23834
23834
|
ref = sch;
|
|
@@ -24403,7 +24403,7 @@ var require_fast_uri = __commonJS({
|
|
|
24403
24403
|
}
|
|
24404
24404
|
return uri;
|
|
24405
24405
|
}
|
|
24406
|
-
function
|
|
24406
|
+
function resolve30(baseURI, relativeURI, options) {
|
|
24407
24407
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
24408
24408
|
const resolved = resolveComponent(parse7(baseURI, schemelessOptions), parse7(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
24409
24409
|
schemelessOptions.skipEscape = true;
|
|
@@ -24630,7 +24630,7 @@ var require_fast_uri = __commonJS({
|
|
|
24630
24630
|
var fastUri = {
|
|
24631
24631
|
SCHEMES,
|
|
24632
24632
|
normalize: normalize2,
|
|
24633
|
-
resolve:
|
|
24633
|
+
resolve: resolve30,
|
|
24634
24634
|
resolveComponent,
|
|
24635
24635
|
equal,
|
|
24636
24636
|
serialize,
|
|
@@ -27606,12 +27606,12 @@ var require_dist = __commonJS({
|
|
|
27606
27606
|
throw new Error(`Unknown format "${name}"`);
|
|
27607
27607
|
return f;
|
|
27608
27608
|
};
|
|
27609
|
-
function addFormats(ajv, list,
|
|
27609
|
+
function addFormats(ajv, list, fs42, exportName) {
|
|
27610
27610
|
var _a;
|
|
27611
27611
|
var _b;
|
|
27612
27612
|
(_a = (_b = ajv.opts.code).formats) !== null && _a !== void 0 ? _a : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
27613
27613
|
for (const f of list)
|
|
27614
|
-
ajv.addFormat(f,
|
|
27614
|
+
ajv.addFormat(f, fs42[f]);
|
|
27615
27615
|
}
|
|
27616
27616
|
module2.exports = exports2 = formatsPlugin;
|
|
27617
27617
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -65501,13 +65501,13 @@ var PromisePolyfill = class extends Promise {
|
|
|
65501
65501
|
// Available starting from Node 22
|
|
65502
65502
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers
|
|
65503
65503
|
static withResolver() {
|
|
65504
|
-
let
|
|
65504
|
+
let resolve30;
|
|
65505
65505
|
let reject2;
|
|
65506
65506
|
const promise = new Promise((res, rej) => {
|
|
65507
|
-
|
|
65507
|
+
resolve30 = res;
|
|
65508
65508
|
reject2 = rej;
|
|
65509
65509
|
});
|
|
65510
|
-
return { promise, resolve:
|
|
65510
|
+
return { promise, resolve: resolve30, reject: reject2 };
|
|
65511
65511
|
}
|
|
65512
65512
|
};
|
|
65513
65513
|
|
|
@@ -65541,7 +65541,7 @@ function createPrompt(view) {
|
|
|
65541
65541
|
output
|
|
65542
65542
|
});
|
|
65543
65543
|
const screen = new ScreenManager(rl);
|
|
65544
|
-
const { promise, resolve:
|
|
65544
|
+
const { promise, resolve: resolve30, reject: reject2 } = PromisePolyfill.withResolver();
|
|
65545
65545
|
const cancel = () => reject2(new CancelPromptError());
|
|
65546
65546
|
if (signal) {
|
|
65547
65547
|
const abort = () => reject2(new AbortPromptError({ cause: signal.reason }));
|
|
@@ -65568,7 +65568,7 @@ function createPrompt(view) {
|
|
|
65568
65568
|
cycle(() => {
|
|
65569
65569
|
try {
|
|
65570
65570
|
const nextView = view(config2, (value2) => {
|
|
65571
|
-
setImmediate(() =>
|
|
65571
|
+
setImmediate(() => resolve30(value2));
|
|
65572
65572
|
});
|
|
65573
65573
|
if (nextView === void 0) {
|
|
65574
65574
|
const callerFilename = callSites[1]?.getFileName();
|
|
@@ -66149,13 +66149,13 @@ var PromisePolyfill2 = class extends Promise {
|
|
|
66149
66149
|
// Available starting from Node 22
|
|
66150
66150
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers
|
|
66151
66151
|
static withResolver() {
|
|
66152
|
-
let
|
|
66152
|
+
let resolve30;
|
|
66153
66153
|
let reject2;
|
|
66154
66154
|
const promise = new Promise((res, rej) => {
|
|
66155
|
-
|
|
66155
|
+
resolve30 = res;
|
|
66156
66156
|
reject2 = rej;
|
|
66157
66157
|
});
|
|
66158
|
-
return { promise, resolve:
|
|
66158
|
+
return { promise, resolve: resolve30, reject: reject2 };
|
|
66159
66159
|
}
|
|
66160
66160
|
};
|
|
66161
66161
|
|
|
@@ -66189,7 +66189,7 @@ function createPrompt2(view) {
|
|
|
66189
66189
|
output
|
|
66190
66190
|
});
|
|
66191
66191
|
const screen = new ScreenManager2(rl);
|
|
66192
|
-
const { promise, resolve:
|
|
66192
|
+
const { promise, resolve: resolve30, reject: reject2 } = PromisePolyfill2.withResolver();
|
|
66193
66193
|
const cancel = () => reject2(new CancelPromptError2());
|
|
66194
66194
|
if (signal) {
|
|
66195
66195
|
const abort = () => reject2(new AbortPromptError2({ cause: signal.reason }));
|
|
@@ -66216,7 +66216,7 @@ function createPrompt2(view) {
|
|
|
66216
66216
|
cycle(() => {
|
|
66217
66217
|
try {
|
|
66218
66218
|
const nextView = view(config2, (value2) => {
|
|
66219
|
-
setImmediate(() =>
|
|
66219
|
+
setImmediate(() => resolve30(value2));
|
|
66220
66220
|
});
|
|
66221
66221
|
if (nextView === void 0) {
|
|
66222
66222
|
const callerFilename = callSites[1]?.getFileName();
|
|
@@ -66768,13 +66768,13 @@ var PromisePolyfill3 = class extends Promise {
|
|
|
66768
66768
|
// Available starting from Node 22
|
|
66769
66769
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers
|
|
66770
66770
|
static withResolver() {
|
|
66771
|
-
let
|
|
66771
|
+
let resolve30;
|
|
66772
66772
|
let reject2;
|
|
66773
66773
|
const promise = new Promise((res, rej) => {
|
|
66774
|
-
|
|
66774
|
+
resolve30 = res;
|
|
66775
66775
|
reject2 = rej;
|
|
66776
66776
|
});
|
|
66777
|
-
return { promise, resolve:
|
|
66777
|
+
return { promise, resolve: resolve30, reject: reject2 };
|
|
66778
66778
|
}
|
|
66779
66779
|
};
|
|
66780
66780
|
|
|
@@ -66808,7 +66808,7 @@ function createPrompt3(view) {
|
|
|
66808
66808
|
output
|
|
66809
66809
|
});
|
|
66810
66810
|
const screen = new ScreenManager3(rl);
|
|
66811
|
-
const { promise, resolve:
|
|
66811
|
+
const { promise, resolve: resolve30, reject: reject2 } = PromisePolyfill3.withResolver();
|
|
66812
66812
|
const cancel = () => reject2(new CancelPromptError3());
|
|
66813
66813
|
if (signal) {
|
|
66814
66814
|
const abort = () => reject2(new AbortPromptError3({ cause: signal.reason }));
|
|
@@ -66835,7 +66835,7 @@ function createPrompt3(view) {
|
|
|
66835
66835
|
cycle(() => {
|
|
66836
66836
|
try {
|
|
66837
66837
|
const nextView = view(config2, (value2) => {
|
|
66838
|
-
setImmediate(() =>
|
|
66838
|
+
setImmediate(() => resolve30(value2));
|
|
66839
66839
|
});
|
|
66840
66840
|
if (nextView === void 0) {
|
|
66841
66841
|
const callerFilename = callSites[1]?.getFileName();
|
|
@@ -70643,9 +70643,9 @@ var Socket2 = class extends import_component_emitter5.Emitter {
|
|
|
70643
70643
|
* @return a Promise that will be fulfilled when the server acknowledges the event
|
|
70644
70644
|
*/
|
|
70645
70645
|
emitWithAck(ev, ...args) {
|
|
70646
|
-
return new Promise((
|
|
70646
|
+
return new Promise((resolve30, reject2) => {
|
|
70647
70647
|
const fn = (arg1, arg2) => {
|
|
70648
|
-
return arg1 ? reject2(arg1) :
|
|
70648
|
+
return arg1 ? reject2(arg1) : resolve30(arg2);
|
|
70649
70649
|
};
|
|
70650
70650
|
fn.withError = true;
|
|
70651
70651
|
args.push(fn);
|
|
@@ -75928,8 +75928,8 @@ function getElementAtPath(obj, path42) {
|
|
|
75928
75928
|
}
|
|
75929
75929
|
function promiseAllObject(promisesObj) {
|
|
75930
75930
|
const keys2 = Object.keys(promisesObj);
|
|
75931
|
-
const
|
|
75932
|
-
return Promise.all(
|
|
75931
|
+
const promises3 = keys2.map((key) => promisesObj[key]);
|
|
75932
|
+
return Promise.all(promises3).then((results) => {
|
|
75933
75933
|
const resolvedObj = {};
|
|
75934
75934
|
for (let i = 0; i < keys2.length; i++) {
|
|
75935
75935
|
resolvedObj[keys2[i]] = results[i];
|
|
@@ -83757,7 +83757,7 @@ var Protocol = class {
|
|
|
83757
83757
|
return;
|
|
83758
83758
|
}
|
|
83759
83759
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
83760
|
-
await new Promise((
|
|
83760
|
+
await new Promise((resolve30) => setTimeout(resolve30, pollInterval));
|
|
83761
83761
|
options?.signal?.throwIfAborted();
|
|
83762
83762
|
}
|
|
83763
83763
|
} catch (error2) {
|
|
@@ -83774,7 +83774,7 @@ var Protocol = class {
|
|
|
83774
83774
|
*/
|
|
83775
83775
|
request(request, resultSchema, options) {
|
|
83776
83776
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
83777
|
-
return new Promise((
|
|
83777
|
+
return new Promise((resolve30, reject2) => {
|
|
83778
83778
|
const earlyReject = (error2) => {
|
|
83779
83779
|
reject2(error2);
|
|
83780
83780
|
};
|
|
@@ -83852,7 +83852,7 @@ var Protocol = class {
|
|
|
83852
83852
|
if (!parseResult.success) {
|
|
83853
83853
|
reject2(parseResult.error);
|
|
83854
83854
|
} else {
|
|
83855
|
-
|
|
83855
|
+
resolve30(parseResult.data);
|
|
83856
83856
|
}
|
|
83857
83857
|
} catch (error2) {
|
|
83858
83858
|
reject2(error2);
|
|
@@ -84113,12 +84113,12 @@ var Protocol = class {
|
|
|
84113
84113
|
}
|
|
84114
84114
|
} catch {
|
|
84115
84115
|
}
|
|
84116
|
-
return new Promise((
|
|
84116
|
+
return new Promise((resolve30, reject2) => {
|
|
84117
84117
|
if (signal.aborted) {
|
|
84118
84118
|
reject2(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
84119
84119
|
return;
|
|
84120
84120
|
}
|
|
84121
|
-
const timeoutId = setTimeout(
|
|
84121
|
+
const timeoutId = setTimeout(resolve30, interval);
|
|
84122
84122
|
signal.addEventListener("abort", () => {
|
|
84123
84123
|
clearTimeout(timeoutId);
|
|
84124
84124
|
reject2(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -85077,7 +85077,7 @@ var McpServer = class {
|
|
|
85077
85077
|
let task = createTaskResult.task;
|
|
85078
85078
|
const pollInterval = task.pollInterval ?? 5e3;
|
|
85079
85079
|
while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
|
|
85080
|
-
await new Promise((
|
|
85080
|
+
await new Promise((resolve30) => setTimeout(resolve30, pollInterval));
|
|
85081
85081
|
const updatedTask = await extra.taskStore.getTask(taskId);
|
|
85082
85082
|
if (!updatedTask) {
|
|
85083
85083
|
throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
|
|
@@ -85720,12 +85720,12 @@ var StdioServerTransport = class {
|
|
|
85720
85720
|
this.onclose?.();
|
|
85721
85721
|
}
|
|
85722
85722
|
send(message) {
|
|
85723
|
-
return new Promise((
|
|
85723
|
+
return new Promise((resolve30) => {
|
|
85724
85724
|
const json2 = serializeMessage(message);
|
|
85725
85725
|
if (this._stdout.write(json2)) {
|
|
85726
|
-
|
|
85726
|
+
resolve30();
|
|
85727
85727
|
} else {
|
|
85728
|
-
this._stdout.once("drain",
|
|
85728
|
+
this._stdout.once("drain", resolve30);
|
|
85729
85729
|
}
|
|
85730
85730
|
});
|
|
85731
85731
|
}
|
|
@@ -85875,8 +85875,10 @@ var EditorConnection = class {
|
|
|
85875
85875
|
buffer;
|
|
85876
85876
|
ioFactory;
|
|
85877
85877
|
ackTimeout;
|
|
85878
|
+
hasLoggedDisconnect = false;
|
|
85879
|
+
wasConnected = false;
|
|
85878
85880
|
/**
|
|
85879
|
-
* @param serverUrl - The base URL of the
|
|
85881
|
+
* @param serverUrl - The base URL of the Studio WebSocket server.
|
|
85880
85882
|
* @param buffer - The event buffer to push incoming events into.
|
|
85881
85883
|
* @param options - Optional connection configuration (custom io factory, ack timeout).
|
|
85882
85884
|
*/
|
|
@@ -85887,7 +85889,7 @@ var EditorConnection = class {
|
|
|
85887
85889
|
this.ackTimeout = options?.ackTimeout ?? 1e4;
|
|
85888
85890
|
}
|
|
85889
85891
|
/**
|
|
85890
|
-
* Establishes a WebSocket connection to
|
|
85892
|
+
* Establishes a WebSocket connection to Studio's `/integrations` namespace.
|
|
85891
85893
|
* Cleans up any previous connection first. Incoming `fw:` and `integration:` events
|
|
85892
85894
|
* are automatically forwarded to the event buffer.
|
|
85893
85895
|
* @param log - Optional logging callback for connection lifecycle events.
|
|
@@ -85907,15 +85909,25 @@ var EditorConnection = class {
|
|
|
85907
85909
|
reconnectionAttempts: Infinity
|
|
85908
85910
|
});
|
|
85909
85911
|
this.socket.on("connect", () => {
|
|
85910
|
-
|
|
85912
|
+
const msg = this.wasConnected ? `Reconnected to Studio at ${this.serverUrl}` : `Connected to Studio at ${this.serverUrl}`;
|
|
85913
|
+
log?.(msg);
|
|
85914
|
+
this.hasLoggedDisconnect = false;
|
|
85915
|
+
this.wasConnected = true;
|
|
85911
85916
|
this.buffer.push("mcp:status", { status: "connected", server: this.serverUrl });
|
|
85912
85917
|
});
|
|
85913
85918
|
if (log) {
|
|
85914
|
-
this.socket.on("disconnect", (
|
|
85915
|
-
|
|
85916
|
-
|
|
85917
|
-
|
|
85918
|
-
|
|
85919
|
+
this.socket.on("disconnect", () => {
|
|
85920
|
+
if (!this.hasLoggedDisconnect) {
|
|
85921
|
+
log("Studio disconnected");
|
|
85922
|
+
this.hasLoggedDisconnect = true;
|
|
85923
|
+
}
|
|
85924
|
+
});
|
|
85925
|
+
this.socket.on("connect_error", () => {
|
|
85926
|
+
if (!this.hasLoggedDisconnect) {
|
|
85927
|
+
log(`Studio not reachable at ${this.serverUrl}`);
|
|
85928
|
+
this.hasLoggedDisconnect = true;
|
|
85929
|
+
}
|
|
85930
|
+
});
|
|
85919
85931
|
}
|
|
85920
85932
|
this.socket.onAny((event, data) => {
|
|
85921
85933
|
if (event.startsWith("fw:") || event.startsWith("integration:")) {
|
|
@@ -85923,128 +85935,72 @@ var EditorConnection = class {
|
|
|
85923
85935
|
}
|
|
85924
85936
|
});
|
|
85925
85937
|
}
|
|
85926
|
-
/** Whether the socket is currently connected to
|
|
85938
|
+
/** Whether the socket is currently connected to Studio. */
|
|
85927
85939
|
get isConnected() {
|
|
85928
85940
|
return this.socket?.connected ?? false;
|
|
85929
85941
|
}
|
|
85930
85942
|
/**
|
|
85931
|
-
* Sends a single command to
|
|
85943
|
+
* Sends a single command to Studio and waits for an acknowledgement.
|
|
85932
85944
|
* Returns an error response if not connected or if the ack times out.
|
|
85933
85945
|
* @param action - The command action name (e.g. "get-state", "add-node").
|
|
85934
85946
|
* @param params - Parameters for the command.
|
|
85935
|
-
* @returns
|
|
85947
|
+
* @returns Studio's acknowledgement response.
|
|
85936
85948
|
*/
|
|
85937
85949
|
async sendCommand(action, params) {
|
|
85938
85950
|
if (!this.socket) {
|
|
85939
85951
|
return { requestId: "", success: false, error: "Not connected" };
|
|
85940
85952
|
}
|
|
85941
85953
|
const requestId = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
85942
|
-
return new Promise((
|
|
85954
|
+
return new Promise((resolve30) => {
|
|
85943
85955
|
const handler = (data) => {
|
|
85944
85956
|
if (data.requestId === requestId) {
|
|
85945
85957
|
clearTimeout(timeout);
|
|
85946
85958
|
this.socket.off("fw:ack", handler);
|
|
85947
|
-
|
|
85959
|
+
resolve30(data);
|
|
85948
85960
|
}
|
|
85949
85961
|
};
|
|
85950
85962
|
const timeout = setTimeout(() => {
|
|
85951
85963
|
this.socket.off("fw:ack", handler);
|
|
85952
|
-
|
|
85964
|
+
resolve30({ requestId, success: false, error: "Timeout" });
|
|
85953
85965
|
}, this.ackTimeout);
|
|
85954
85966
|
this.socket.on("fw:ack", handler);
|
|
85955
85967
|
this.socket.emit("integration:command", { requestId, action, params });
|
|
85956
85968
|
});
|
|
85957
85969
|
}
|
|
85958
85970
|
/**
|
|
85959
|
-
* Sends a batch of commands to
|
|
85971
|
+
* Sends a batch of commands to Studio as a single request and waits for acknowledgement.
|
|
85960
85972
|
* Returns an error response if not connected or if the ack times out.
|
|
85961
85973
|
* @param commands - Array of commands, each with an action name and optional params.
|
|
85962
|
-
* @returns
|
|
85974
|
+
* @returns Studio's acknowledgement response for the entire batch.
|
|
85963
85975
|
*/
|
|
85964
85976
|
async sendBatch(commands) {
|
|
85965
85977
|
if (!this.socket) {
|
|
85966
85978
|
return { requestId: "", success: false, error: "Not connected" };
|
|
85967
85979
|
}
|
|
85968
85980
|
const requestId = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
85969
|
-
return new Promise((
|
|
85981
|
+
return new Promise((resolve30) => {
|
|
85970
85982
|
const handler = (data) => {
|
|
85971
85983
|
if (data.requestId === requestId) {
|
|
85972
85984
|
clearTimeout(timeout);
|
|
85973
85985
|
this.socket.off("fw:ack", handler);
|
|
85974
|
-
|
|
85986
|
+
resolve30(data);
|
|
85975
85987
|
}
|
|
85976
85988
|
};
|
|
85977
85989
|
const timeout = setTimeout(() => {
|
|
85978
85990
|
this.socket.off("fw:ack", handler);
|
|
85979
|
-
|
|
85991
|
+
resolve30({ requestId, success: false, error: "Timeout" });
|
|
85980
85992
|
}, this.ackTimeout);
|
|
85981
85993
|
this.socket.on("fw:ack", handler);
|
|
85982
85994
|
this.socket.emit("integration:batch", { requestId, commands });
|
|
85983
85995
|
});
|
|
85984
85996
|
}
|
|
85985
|
-
/** Disconnects from
|
|
85997
|
+
/** Disconnects from Studio and releases the socket. */
|
|
85986
85998
|
disconnect() {
|
|
85987
85999
|
this.socket?.disconnect();
|
|
85988
86000
|
this.socket = null;
|
|
85989
86001
|
}
|
|
85990
86002
|
};
|
|
85991
86003
|
|
|
85992
|
-
// src/mcp/auto-registration.ts
|
|
85993
|
-
import { execSync as execSync3 } from "child_process";
|
|
85994
|
-
import * as readline8 from "readline";
|
|
85995
|
-
import * as path20 from "path";
|
|
85996
|
-
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
85997
|
-
function defaultRegistrationDeps() {
|
|
85998
|
-
return {
|
|
85999
|
-
execCommand: async (cmd) => {
|
|
86000
|
-
try {
|
|
86001
|
-
const stdout = execSync3(cmd, { encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] });
|
|
86002
|
-
return { stdout: stdout.trim(), exitCode: 0 };
|
|
86003
|
-
} catch {
|
|
86004
|
-
return { stdout: "", exitCode: 1 };
|
|
86005
|
-
}
|
|
86006
|
-
},
|
|
86007
|
-
prompt: (question) => new Promise((resolve31) => {
|
|
86008
|
-
const rl = readline8.createInterface({ input: process.stdin, output: process.stderr });
|
|
86009
|
-
rl.question(question, (answer) => {
|
|
86010
|
-
rl.close();
|
|
86011
|
-
resolve31(answer.trim().toLowerCase());
|
|
86012
|
-
});
|
|
86013
|
-
}),
|
|
86014
|
-
log: (msg) => process.stderr.write(msg + "\n"),
|
|
86015
|
-
resolveCliPath: () => {
|
|
86016
|
-
try {
|
|
86017
|
-
return path20.resolve(path20.dirname(fileURLToPath3(import.meta.url)), "..");
|
|
86018
|
-
} catch {
|
|
86019
|
-
return path20.resolve(__dirname, "..");
|
|
86020
|
-
}
|
|
86021
|
-
}
|
|
86022
|
-
};
|
|
86023
|
-
}
|
|
86024
|
-
async function offerClaudeRegistration(options, deps) {
|
|
86025
|
-
const d = deps ?? defaultRegistrationDeps();
|
|
86026
|
-
const whichCmd = process.platform === "win32" ? "where claude" : "which claude";
|
|
86027
|
-
const whichResult = await d.execCommand(whichCmd);
|
|
86028
|
-
if (whichResult.exitCode !== 0) {
|
|
86029
|
-
d.log("Claude Code not found in PATH. Skipping auto-registration.");
|
|
86030
|
-
return;
|
|
86031
|
-
}
|
|
86032
|
-
const listResult = await d.execCommand("claude mcp list");
|
|
86033
|
-
if (listResult.stdout.includes("flow-weaver")) {
|
|
86034
|
-
d.log("Flow Weaver MCP server already registered in Claude Code.");
|
|
86035
|
-
return;
|
|
86036
|
-
}
|
|
86037
|
-
const answer = await d.prompt("Claude Code detected. Register Flow Weaver MCP server? (y/N) ");
|
|
86038
|
-
if (answer !== "y" && answer !== "yes") {
|
|
86039
|
-
d.log("Skipped MCP server registration.");
|
|
86040
|
-
return;
|
|
86041
|
-
}
|
|
86042
|
-
const cliPath = d.resolveCliPath();
|
|
86043
|
-
const cmd = `claude mcp add --scope project flow-weaver -- npx tsx ${cliPath}/index.ts mcp-server --stdio`;
|
|
86044
|
-
await d.execCommand(cmd);
|
|
86045
|
-
d.log("Registered Flow Weaver MCP server. Restart Claude Code to activate.");
|
|
86046
|
-
}
|
|
86047
|
-
|
|
86048
86004
|
// src/mcp/response-utils.ts
|
|
86049
86005
|
function makeToolResult(data) {
|
|
86050
86006
|
return {
|
|
@@ -86125,8 +86081,8 @@ var AgentChannel = class {
|
|
|
86125
86081
|
*/
|
|
86126
86082
|
async request(agentRequest) {
|
|
86127
86083
|
this._pauseResolve?.(agentRequest);
|
|
86128
|
-
return new Promise((
|
|
86129
|
-
this._resolve =
|
|
86084
|
+
return new Promise((resolve30, reject2) => {
|
|
86085
|
+
this._resolve = resolve30;
|
|
86130
86086
|
this._reject = reject2;
|
|
86131
86087
|
});
|
|
86132
86088
|
}
|
|
@@ -86156,8 +86112,8 @@ var AgentChannel = class {
|
|
|
86156
86112
|
this._pausePromise = this._createPausePromise();
|
|
86157
86113
|
}
|
|
86158
86114
|
_createPausePromise() {
|
|
86159
|
-
return new Promise((
|
|
86160
|
-
this._pauseResolve =
|
|
86115
|
+
return new Promise((resolve30) => {
|
|
86116
|
+
this._pauseResolve = resolve30;
|
|
86161
86117
|
});
|
|
86162
86118
|
}
|
|
86163
86119
|
};
|
|
@@ -86193,7 +86149,7 @@ function unwrapAckResult(ack) {
|
|
|
86193
86149
|
function registerEditorTools(mcp, connection, buffer) {
|
|
86194
86150
|
mcp.tool(
|
|
86195
86151
|
"fw_check_events",
|
|
86196
|
-
"Get buffered
|
|
86152
|
+
"Get buffered Studio events. Returns and clears the event buffer unless peek=true.",
|
|
86197
86153
|
{ peek: external_exports.boolean().optional().describe("If true, read events without clearing the buffer") },
|
|
86198
86154
|
async (args) => {
|
|
86199
86155
|
const events = args.peek ? buffer.peek() : buffer.drain();
|
|
@@ -86202,13 +86158,13 @@ function registerEditorTools(mcp, connection, buffer) {
|
|
|
86202
86158
|
);
|
|
86203
86159
|
mcp.tool(
|
|
86204
86160
|
"fw_get_state",
|
|
86205
|
-
"Get the current
|
|
86161
|
+
"Get the current Studio/workflow state from Flow Weaver.",
|
|
86206
86162
|
{},
|
|
86207
86163
|
async () => {
|
|
86208
86164
|
if (!connection.isConnected) {
|
|
86209
86165
|
return makeErrorResult(
|
|
86210
86166
|
"EDITOR_NOT_CONNECTED",
|
|
86211
|
-
"Not connected to
|
|
86167
|
+
"Not connected to Studio. Is Studio running?"
|
|
86212
86168
|
);
|
|
86213
86169
|
}
|
|
86214
86170
|
const result = await connection.sendCommand("get-state", {});
|
|
@@ -86217,13 +86173,13 @@ function registerEditorTools(mcp, connection, buffer) {
|
|
|
86217
86173
|
);
|
|
86218
86174
|
mcp.tool(
|
|
86219
86175
|
"fw_focus_node",
|
|
86220
|
-
"Select and center a node in
|
|
86176
|
+
"Select and center a node in Flow Weaver Studio.",
|
|
86221
86177
|
{ nodeId: external_exports.string().describe("The ID of the node to focus") },
|
|
86222
86178
|
async (args) => {
|
|
86223
86179
|
if (!connection.isConnected) {
|
|
86224
86180
|
return makeErrorResult(
|
|
86225
86181
|
"EDITOR_NOT_CONNECTED",
|
|
86226
|
-
"Not connected to
|
|
86182
|
+
"Not connected to Studio. Is Studio running?"
|
|
86227
86183
|
);
|
|
86228
86184
|
}
|
|
86229
86185
|
const result = await connection.sendCommand("focus-node", { nodeId: args.nodeId });
|
|
@@ -86232,7 +86188,7 @@ function registerEditorTools(mcp, connection, buffer) {
|
|
|
86232
86188
|
);
|
|
86233
86189
|
mcp.tool(
|
|
86234
86190
|
"fw_add_node",
|
|
86235
|
-
"Add a new node to the workflow in
|
|
86191
|
+
"Add a new node to the workflow in Flow Weaver Studio.",
|
|
86236
86192
|
{
|
|
86237
86193
|
nodeTypeName: external_exports.string().describe("The name of the node type to add"),
|
|
86238
86194
|
nodeTypeDefinition: external_exports.record(external_exports.unknown()).optional().describe("Optional node type definition object")
|
|
@@ -86241,7 +86197,7 @@ function registerEditorTools(mcp, connection, buffer) {
|
|
|
86241
86197
|
if (!connection.isConnected) {
|
|
86242
86198
|
return makeErrorResult(
|
|
86243
86199
|
"EDITOR_NOT_CONNECTED",
|
|
86244
|
-
"Not connected to
|
|
86200
|
+
"Not connected to Studio. Is Studio running?"
|
|
86245
86201
|
);
|
|
86246
86202
|
}
|
|
86247
86203
|
const params = { nodeTypeName: args.nodeTypeName };
|
|
@@ -86254,13 +86210,13 @@ function registerEditorTools(mcp, connection, buffer) {
|
|
|
86254
86210
|
);
|
|
86255
86211
|
mcp.tool(
|
|
86256
86212
|
"fw_open_workflow",
|
|
86257
|
-
"Open a workflow file in
|
|
86213
|
+
"Open a workflow file in Flow Weaver Studio.",
|
|
86258
86214
|
{ filePath: external_exports.string().describe("The path to the workflow file to open") },
|
|
86259
86215
|
async (args) => {
|
|
86260
86216
|
if (!connection.isConnected) {
|
|
86261
86217
|
return makeErrorResult(
|
|
86262
86218
|
"EDITOR_NOT_CONNECTED",
|
|
86263
|
-
"Not connected to
|
|
86219
|
+
"Not connected to Studio. Is Studio running?"
|
|
86264
86220
|
);
|
|
86265
86221
|
}
|
|
86266
86222
|
const result = await connection.sendCommand("open-workflow", { filePath: args.filePath });
|
|
@@ -86269,7 +86225,7 @@ function registerEditorTools(mcp, connection, buffer) {
|
|
|
86269
86225
|
);
|
|
86270
86226
|
mcp.tool(
|
|
86271
86227
|
"fw_send_command",
|
|
86272
|
-
"Send a generic command to
|
|
86228
|
+
"Send a generic command to Flow Weaver Studio.",
|
|
86273
86229
|
{
|
|
86274
86230
|
action: external_exports.string().describe("The command action name"),
|
|
86275
86231
|
params: external_exports.record(external_exports.unknown()).optional().describe("Optional parameters for the command")
|
|
@@ -86278,7 +86234,7 @@ function registerEditorTools(mcp, connection, buffer) {
|
|
|
86278
86234
|
if (!connection.isConnected) {
|
|
86279
86235
|
return makeErrorResult(
|
|
86280
86236
|
"EDITOR_NOT_CONNECTED",
|
|
86281
|
-
"Not connected to
|
|
86237
|
+
"Not connected to Studio. Is Studio running?"
|
|
86282
86238
|
);
|
|
86283
86239
|
}
|
|
86284
86240
|
const result = await connection.sendCommand(args.action, args.params ?? {});
|
|
@@ -86300,7 +86256,7 @@ function registerEditorTools(mcp, connection, buffer) {
|
|
|
86300
86256
|
if (!connection.isConnected) {
|
|
86301
86257
|
return makeErrorResult(
|
|
86302
86258
|
"EDITOR_NOT_CONNECTED",
|
|
86303
|
-
"Not connected to
|
|
86259
|
+
"Not connected to Studio. Is Studio running?"
|
|
86304
86260
|
);
|
|
86305
86261
|
}
|
|
86306
86262
|
const result = await connection.sendBatch(args.commands);
|
|
@@ -86315,7 +86271,7 @@ function registerEditorTools(mcp, connection, buffer) {
|
|
|
86315
86271
|
if (!connection.isConnected) {
|
|
86316
86272
|
return makeErrorResult(
|
|
86317
86273
|
"EDITOR_NOT_CONNECTED",
|
|
86318
|
-
"Not connected to
|
|
86274
|
+
"Not connected to Studio. Is Studio running?"
|
|
86319
86275
|
);
|
|
86320
86276
|
}
|
|
86321
86277
|
const result = await connection.sendCommand("remove-node", { nodeName: args.nodeName });
|
|
@@ -86338,7 +86294,7 @@ function registerEditorTools(mcp, connection, buffer) {
|
|
|
86338
86294
|
if (!connection.isConnected) {
|
|
86339
86295
|
return makeErrorResult(
|
|
86340
86296
|
"EDITOR_NOT_CONNECTED",
|
|
86341
|
-
"Not connected to
|
|
86297
|
+
"Not connected to Studio. Is Studio running?"
|
|
86342
86298
|
);
|
|
86343
86299
|
}
|
|
86344
86300
|
const bridgeAction = args.action === "add" ? "add-connection" : "remove-connection";
|
|
@@ -86356,7 +86312,7 @@ function registerEditorTools(mcp, connection, buffer) {
|
|
|
86356
86312
|
if (!connection.isConnected) {
|
|
86357
86313
|
return makeErrorResult(
|
|
86358
86314
|
"EDITOR_NOT_CONNECTED",
|
|
86359
|
-
"Not connected to
|
|
86315
|
+
"Not connected to Studio. Is Studio running?"
|
|
86360
86316
|
);
|
|
86361
86317
|
}
|
|
86362
86318
|
const result = await connection.sendCommand(args.action, {});
|
|
@@ -86368,7 +86324,7 @@ function registerEditorTools(mcp, connection, buffer) {
|
|
|
86368
86324
|
'Run the current workflow with optional parameters and return the result. Includes per-node execution trace by default (STATUS_CHANGED, VARIABLE_SET events) \u2014 use includeTrace: false to disable. If the workflow pauses at a waitForAgent node, returns immediately with status "waiting" and a runId \u2014 use fw_resume_workflow to continue.',
|
|
86369
86325
|
{
|
|
86370
86326
|
filePath: external_exports.string().optional().describe(
|
|
86371
|
-
"Path to workflow file. When provided, compiles and executes directly (no
|
|
86327
|
+
"Path to workflow file. When provided, compiles and executes directly (no Studio needed)"
|
|
86372
86328
|
),
|
|
86373
86329
|
workflowName: external_exports.string().optional().describe("Specific workflow function name (for multi-workflow files)"),
|
|
86374
86330
|
params: external_exports.record(external_exports.unknown()).optional().describe("Optional execution parameters"),
|
|
@@ -86432,7 +86388,7 @@ function registerEditorTools(mcp, connection, buffer) {
|
|
|
86432
86388
|
if (!connection.isConnected) {
|
|
86433
86389
|
return makeErrorResult(
|
|
86434
86390
|
"EDITOR_NOT_CONNECTED",
|
|
86435
|
-
"Not connected to
|
|
86391
|
+
"Not connected to Studio. Is Studio running?"
|
|
86436
86392
|
);
|
|
86437
86393
|
}
|
|
86438
86394
|
const result = await connection.sendCommand("execute-workflow", args.params ?? {});
|
|
@@ -86495,7 +86451,7 @@ function registerEditorTools(mcp, connection, buffer) {
|
|
|
86495
86451
|
if (!connection.isConnected) {
|
|
86496
86452
|
return makeErrorResult(
|
|
86497
86453
|
"EDITOR_NOT_CONNECTED",
|
|
86498
|
-
"Not connected to
|
|
86454
|
+
"Not connected to Studio. Is Studio running?"
|
|
86499
86455
|
);
|
|
86500
86456
|
}
|
|
86501
86457
|
const result = await connection.sendCommand("get-workflow-details", {});
|
|
@@ -86524,7 +86480,7 @@ function registerEditorTools(mcp, connection, buffer) {
|
|
|
86524
86480
|
}
|
|
86525
86481
|
|
|
86526
86482
|
// src/mcp/tools-query.ts
|
|
86527
|
-
import * as
|
|
86483
|
+
import * as path20 from "path";
|
|
86528
86484
|
function parseErrorCode(errors2) {
|
|
86529
86485
|
if (errors2.some((e) => e.includes("[MULTIPLE_WORKFLOWS_FOUND]"))) {
|
|
86530
86486
|
return "MULTIPLE_WORKFLOWS_FOUND";
|
|
@@ -86543,7 +86499,7 @@ function registerQueryTools(mcp) {
|
|
|
86543
86499
|
},
|
|
86544
86500
|
async (args) => {
|
|
86545
86501
|
try {
|
|
86546
|
-
const filePath =
|
|
86502
|
+
const filePath = path20.resolve(args.filePath);
|
|
86547
86503
|
const parseResult = await parseWorkflow(filePath, { workflowName: args.workflowName });
|
|
86548
86504
|
if (parseResult.errors.length > 0 && parseResult.errors.some((e) => typeof e === "string" && e.includes("No workflows found"))) {
|
|
86549
86505
|
try {
|
|
@@ -86592,7 +86548,7 @@ ${parseResult.errors.join("\n")}`
|
|
|
86592
86548
|
},
|
|
86593
86549
|
async (args) => {
|
|
86594
86550
|
try {
|
|
86595
|
-
const filePath =
|
|
86551
|
+
const filePath = path20.resolve(args.filePath);
|
|
86596
86552
|
const parseResult = await parseWorkflow(filePath, { workflowName: args.workflowName });
|
|
86597
86553
|
if (parseResult.errors.length > 0 && parseResult.errors.some((e) => typeof e === "string" && e.includes("No workflows found"))) {
|
|
86598
86554
|
try {
|
|
@@ -86672,7 +86628,7 @@ ${parseResult.errors.join("\n")}`
|
|
|
86672
86628
|
},
|
|
86673
86629
|
async (args) => {
|
|
86674
86630
|
try {
|
|
86675
|
-
const filePath =
|
|
86631
|
+
const filePath = path20.resolve(args.filePath);
|
|
86676
86632
|
if (args.target === "inngest") {
|
|
86677
86633
|
const parser3 = new AnnotationParser();
|
|
86678
86634
|
const parseResult = parser3.parse(filePath);
|
|
@@ -86709,8 +86665,8 @@ ${parseResult.errors.join("\n")}`);
|
|
|
86709
86665
|
});
|
|
86710
86666
|
const outputFile = filePath.replace(/\.ts$/, ".inngest.ts");
|
|
86711
86667
|
if (args.write !== false) {
|
|
86712
|
-
const
|
|
86713
|
-
|
|
86668
|
+
const fs42 = await import("fs");
|
|
86669
|
+
fs42.writeFileSync(outputFile, code, "utf8");
|
|
86714
86670
|
}
|
|
86715
86671
|
return makeToolResult({
|
|
86716
86672
|
target: "inngest",
|
|
@@ -86748,8 +86704,8 @@ ${parseResult.errors.join("\n")}`);
|
|
|
86748
86704
|
async (args) => {
|
|
86749
86705
|
try {
|
|
86750
86706
|
const [result1, result2] = await Promise.all([
|
|
86751
|
-
parseWorkflow(
|
|
86752
|
-
parseWorkflow(
|
|
86707
|
+
parseWorkflow(path20.resolve(args.file1), { workflowName: args.workflowName }),
|
|
86708
|
+
parseWorkflow(path20.resolve(args.file2), { workflowName: args.workflowName })
|
|
86753
86709
|
]);
|
|
86754
86710
|
if (result1.errors.length > 0) {
|
|
86755
86711
|
return makeErrorResult(
|
|
@@ -86811,7 +86767,7 @@ Query types:
|
|
|
86811
86767
|
},
|
|
86812
86768
|
async (args) => {
|
|
86813
86769
|
try {
|
|
86814
|
-
const filePath =
|
|
86770
|
+
const filePath = path20.resolve(args.filePath);
|
|
86815
86771
|
let parseResult = await parseWorkflow(filePath, { workflowName: args.workflowName });
|
|
86816
86772
|
if (parseResult.errors.length > 0 && args.query === "node-types" && parseResult.errors.some((e) => typeof e === "string" && e.includes("No workflows found"))) {
|
|
86817
86773
|
try {
|
|
@@ -86910,7 +86866,7 @@ ${parseResult.errors.join("\n")}`
|
|
|
86910
86866
|
},
|
|
86911
86867
|
async (args) => {
|
|
86912
86868
|
try {
|
|
86913
|
-
const dir =
|
|
86869
|
+
const dir = path20.resolve(args.directory ?? process.cwd());
|
|
86914
86870
|
const report = runDoctorChecks(dir);
|
|
86915
86871
|
return makeToolResult(report);
|
|
86916
86872
|
} catch (err) {
|
|
@@ -86924,7 +86880,7 @@ ${parseResult.errors.join("\n")}`
|
|
|
86924
86880
|
}
|
|
86925
86881
|
|
|
86926
86882
|
// src/mcp/tools-template.ts
|
|
86927
|
-
import * as
|
|
86883
|
+
import * as path21 from "path";
|
|
86928
86884
|
import * as fs20 from "fs";
|
|
86929
86885
|
function registerTemplateTools(mcp) {
|
|
86930
86886
|
mcp.tool(
|
|
@@ -86967,7 +86923,7 @@ function registerTemplateTools(mcp) {
|
|
|
86967
86923
|
},
|
|
86968
86924
|
async (args) => {
|
|
86969
86925
|
try {
|
|
86970
|
-
const outPath =
|
|
86926
|
+
const outPath = path21.resolve(args.filePath);
|
|
86971
86927
|
const wt = getWorkflowTemplate2(args.template);
|
|
86972
86928
|
if (wt) {
|
|
86973
86929
|
const code = generateWorkflowFromTemplate(args.template, {
|
|
@@ -87035,7 +86991,7 @@ function registerTemplateTools(mcp) {
|
|
|
87035
86991
|
|
|
87036
86992
|
// src/mcp/tools-pattern.ts
|
|
87037
86993
|
init_esm5();
|
|
87038
|
-
import * as
|
|
86994
|
+
import * as path22 from "path";
|
|
87039
86995
|
import * as fs21 from "fs";
|
|
87040
86996
|
|
|
87041
86997
|
// src/migration/registry.ts
|
|
@@ -87237,7 +87193,7 @@ function registerPatternTools(mcp) {
|
|
|
87237
87193
|
},
|
|
87238
87194
|
async (args) => {
|
|
87239
87195
|
try {
|
|
87240
|
-
const filePath =
|
|
87196
|
+
const filePath = path22.resolve(args.filePath);
|
|
87241
87197
|
const patterns = listPatterns(filePath);
|
|
87242
87198
|
return makeToolResult(patterns);
|
|
87243
87199
|
} catch (err) {
|
|
@@ -87260,8 +87216,8 @@ function registerPatternTools(mcp) {
|
|
|
87260
87216
|
},
|
|
87261
87217
|
async (args) => {
|
|
87262
87218
|
try {
|
|
87263
|
-
const patternFilePath =
|
|
87264
|
-
const targetFilePath =
|
|
87219
|
+
const patternFilePath = path22.resolve(args.patternFile);
|
|
87220
|
+
const targetFilePath = path22.resolve(args.targetFile);
|
|
87265
87221
|
const annotationParser = new AnnotationParser();
|
|
87266
87222
|
const patternResult = annotationParser.parse(patternFilePath);
|
|
87267
87223
|
if (patternResult.patterns.length === 0) {
|
|
@@ -87326,7 +87282,7 @@ function registerPatternTools(mcp) {
|
|
|
87326
87282
|
},
|
|
87327
87283
|
async (args) => {
|
|
87328
87284
|
try {
|
|
87329
|
-
const dir =
|
|
87285
|
+
const dir = path22.resolve(args.directory);
|
|
87330
87286
|
const results = await findWorkflows(dir, args.pattern);
|
|
87331
87287
|
return makeToolResult(results);
|
|
87332
87288
|
} catch (err) {
|
|
@@ -87363,7 +87319,7 @@ function registerPatternTools(mcp) {
|
|
|
87363
87319
|
if (!paramValidation.success) {
|
|
87364
87320
|
return makeErrorResult("INVALID_PARAMS", paramValidation.error);
|
|
87365
87321
|
}
|
|
87366
|
-
const filePath =
|
|
87322
|
+
const filePath = path22.resolve(args.filePath);
|
|
87367
87323
|
const sourceCode = fs21.readFileSync(filePath, "utf8");
|
|
87368
87324
|
const parseResult = await parseWorkflow(filePath, { workflowName: args.workflowName });
|
|
87369
87325
|
if (parseResult.errors.length > 0) {
|
|
@@ -87656,7 +87612,7 @@ ${parseResult.errors.join("\n")}`);
|
|
|
87656
87612
|
);
|
|
87657
87613
|
}
|
|
87658
87614
|
}
|
|
87659
|
-
const filePath =
|
|
87615
|
+
const filePath = path22.resolve(args.filePath);
|
|
87660
87616
|
const sourceCode = fs21.readFileSync(filePath, "utf8");
|
|
87661
87617
|
const parseResult = await parseWorkflow(filePath, { workflowName: args.workflowName });
|
|
87662
87618
|
if (parseResult.errors.length > 0) {
|
|
@@ -87767,7 +87723,7 @@ ${parseResult.errors.join("\n")}`);
|
|
|
87767
87723
|
},
|
|
87768
87724
|
async (args) => {
|
|
87769
87725
|
try {
|
|
87770
|
-
const filePath =
|
|
87726
|
+
const filePath = path22.resolve(args.sourceFile);
|
|
87771
87727
|
const parseResult = await parseWorkflow(filePath);
|
|
87772
87728
|
if (parseResult.errors.length > 0) {
|
|
87773
87729
|
return makeErrorResult("PARSE_ERROR", `Parse errors:
|
|
@@ -87783,7 +87739,7 @@ ${parseResult.errors.join("\n")}`);
|
|
|
87783
87739
|
name: args.name
|
|
87784
87740
|
});
|
|
87785
87741
|
if (args.outputFile) {
|
|
87786
|
-
const outPath =
|
|
87742
|
+
const outPath = path22.resolve(args.outputFile);
|
|
87787
87743
|
fs21.writeFileSync(outPath, result.patternCode, "utf8");
|
|
87788
87744
|
return makeToolResult({
|
|
87789
87745
|
success: true,
|
|
@@ -87828,7 +87784,7 @@ ${parseResult.errors.join("\n")}`);
|
|
|
87828
87784
|
}
|
|
87829
87785
|
const results = [];
|
|
87830
87786
|
for (const file of files) {
|
|
87831
|
-
const filePath =
|
|
87787
|
+
const filePath = path22.resolve(file);
|
|
87832
87788
|
try {
|
|
87833
87789
|
const sourceCode = fs21.readFileSync(filePath, "utf8");
|
|
87834
87790
|
const parseResult = await parseWorkflow(filePath);
|
|
@@ -87874,7 +87830,7 @@ ${parseResult.errors.join("\n")}`);
|
|
|
87874
87830
|
}
|
|
87875
87831
|
|
|
87876
87832
|
// src/mcp/tools-export.ts
|
|
87877
|
-
import * as
|
|
87833
|
+
import * as path24 from "path";
|
|
87878
87834
|
import * as fs22 from "fs";
|
|
87879
87835
|
|
|
87880
87836
|
// src/deployment/config/defaults.ts
|
|
@@ -88419,7 +88375,7 @@ ${valueStr}`;
|
|
|
88419
88375
|
}
|
|
88420
88376
|
|
|
88421
88377
|
// src/deployment/targets/base.ts
|
|
88422
|
-
import * as
|
|
88378
|
+
import * as path23 from "path";
|
|
88423
88379
|
var BaseExportTarget = class {
|
|
88424
88380
|
/**
|
|
88425
88381
|
* Generate a standard package.json
|
|
@@ -88465,7 +88421,7 @@ var BaseExportTarget = class {
|
|
|
88465
88421
|
createFile(outputDir, relativePath, content, type2) {
|
|
88466
88422
|
return {
|
|
88467
88423
|
relativePath,
|
|
88468
|
-
absolutePath:
|
|
88424
|
+
absolutePath: path23.join(outputDir, relativePath),
|
|
88469
88425
|
content,
|
|
88470
88426
|
type: type2
|
|
88471
88427
|
};
|
|
@@ -88518,7 +88474,7 @@ var BaseExportTarget = class {
|
|
|
88518
88474
|
* Get relative import path for the workflow
|
|
88519
88475
|
*/
|
|
88520
88476
|
getWorkflowImport(workflowFile) {
|
|
88521
|
-
const basename18 =
|
|
88477
|
+
const basename18 = path23.basename(workflowFile, path23.extname(workflowFile));
|
|
88522
88478
|
return `./${basename18}.js`;
|
|
88523
88479
|
}
|
|
88524
88480
|
/**
|
|
@@ -93064,8 +93020,8 @@ function registerExportTools(mcp) {
|
|
|
93064
93020
|
},
|
|
93065
93021
|
async (args) => {
|
|
93066
93022
|
try {
|
|
93067
|
-
const filePath =
|
|
93068
|
-
const outputDir =
|
|
93023
|
+
const filePath = path24.resolve(args.filePath);
|
|
93024
|
+
const outputDir = path24.resolve(args.outputDir);
|
|
93069
93025
|
const preview = args.preview ?? false;
|
|
93070
93026
|
const includeDocs = args.includeDocs ?? true;
|
|
93071
93027
|
try {
|
|
@@ -93116,7 +93072,7 @@ function registerExportTools(mcp) {
|
|
|
93116
93072
|
const uniqueNodeTypes = [
|
|
93117
93073
|
...new Map(allNodeTypes.map((nt) => [nt.name, nt])).values()
|
|
93118
93074
|
];
|
|
93119
|
-
const serviceName = args.serviceName ||
|
|
93075
|
+
const serviceName = args.serviceName || path24.basename(filePath, ".ts").replace(/[^a-zA-Z0-9-]/g, "-");
|
|
93120
93076
|
const bundleWorkflows = allWorkflows.filter((w) => args.workflows ? args.workflows.includes(w.name) : true).map((w) => ({
|
|
93121
93077
|
name: w.name,
|
|
93122
93078
|
functionName: w.functionName,
|
|
@@ -93163,8 +93119,8 @@ function registerExportTools(mcp) {
|
|
|
93163
93119
|
if (!preview) {
|
|
93164
93120
|
await fs22.promises.mkdir(outputDir, { recursive: true });
|
|
93165
93121
|
for (const file of artifacts.files) {
|
|
93166
|
-
const fullPath =
|
|
93167
|
-
await fs22.promises.mkdir(
|
|
93122
|
+
const fullPath = path24.join(outputDir, file.relativePath);
|
|
93123
|
+
await fs22.promises.mkdir(path24.dirname(fullPath), { recursive: true });
|
|
93168
93124
|
await fs22.promises.writeFile(fullPath, file.content, "utf-8");
|
|
93169
93125
|
}
|
|
93170
93126
|
}
|
|
@@ -93204,12 +93160,12 @@ function registerExportTools(mcp) {
|
|
|
93204
93160
|
}
|
|
93205
93161
|
|
|
93206
93162
|
// src/mcp/tools-marketplace.ts
|
|
93207
|
-
import { execSync as
|
|
93163
|
+
import { execSync as execSync3 } from "child_process";
|
|
93208
93164
|
|
|
93209
93165
|
// src/marketplace/manifest.ts
|
|
93210
93166
|
init_esm5();
|
|
93211
93167
|
import * as fs23 from "fs";
|
|
93212
|
-
import * as
|
|
93168
|
+
import * as path25 from "path";
|
|
93213
93169
|
function toManifestPort(port) {
|
|
93214
93170
|
return {
|
|
93215
93171
|
dataType: port.dataType,
|
|
@@ -93280,7 +93236,7 @@ function patternToManifest(pat, relativeFile) {
|
|
|
93280
93236
|
}
|
|
93281
93237
|
async function generateManifest(options) {
|
|
93282
93238
|
const { directory, srcDir = "src", distDir = "dist" } = options;
|
|
93283
|
-
const pkgPath =
|
|
93239
|
+
const pkgPath = path25.join(directory, "package.json");
|
|
93284
93240
|
if (!fs23.existsSync(pkgPath)) {
|
|
93285
93241
|
return {
|
|
93286
93242
|
manifest: emptyManifest("unknown", "0.0.0"),
|
|
@@ -93289,8 +93245,8 @@ async function generateManifest(options) {
|
|
|
93289
93245
|
};
|
|
93290
93246
|
}
|
|
93291
93247
|
const pkg = JSON.parse(fs23.readFileSync(pkgPath, "utf-8"));
|
|
93292
|
-
const srcRoot =
|
|
93293
|
-
const pattern =
|
|
93248
|
+
const srcRoot = path25.join(directory, srcDir);
|
|
93249
|
+
const pattern = path25.join(srcRoot, "**/*.ts").replace(/\\/g, "/");
|
|
93294
93250
|
const files = await glob(pattern, { absolute: true });
|
|
93295
93251
|
const tsFiles = files.filter((f) => !f.endsWith(".d.ts") && !f.includes("node_modules"));
|
|
93296
93252
|
const parser3 = new AnnotationParser();
|
|
@@ -93303,8 +93259,8 @@ async function generateManifest(options) {
|
|
|
93303
93259
|
try {
|
|
93304
93260
|
const result = parser3.parse(file);
|
|
93305
93261
|
parsedFiles.push(file);
|
|
93306
|
-
const relFromSrc =
|
|
93307
|
-
const distRelative =
|
|
93262
|
+
const relFromSrc = path25.relative(srcRoot, file);
|
|
93263
|
+
const distRelative = path25.join(distDir, relFromSrc.replace(/\.ts$/, ".js"));
|
|
93308
93264
|
for (const nt of result.nodeTypes) {
|
|
93309
93265
|
allNodeTypes.push(nodeTypeToManifest(nt, distRelative));
|
|
93310
93266
|
}
|
|
@@ -93340,12 +93296,12 @@ async function generateManifest(options) {
|
|
|
93340
93296
|
return { manifest, parsedFiles, errors: errors2 };
|
|
93341
93297
|
}
|
|
93342
93298
|
function writeManifest(directory, manifest) {
|
|
93343
|
-
const outPath =
|
|
93299
|
+
const outPath = path25.join(directory, "flowweaver.manifest.json");
|
|
93344
93300
|
fs23.writeFileSync(outPath, JSON.stringify(manifest, null, 2) + "\n", "utf-8");
|
|
93345
93301
|
return outPath;
|
|
93346
93302
|
}
|
|
93347
93303
|
function readManifest(directory) {
|
|
93348
|
-
const manifestPath =
|
|
93304
|
+
const manifestPath = path25.join(directory, "flowweaver.manifest.json");
|
|
93349
93305
|
if (!fs23.existsSync(manifestPath)) return null;
|
|
93350
93306
|
return JSON.parse(fs23.readFileSync(manifestPath, "utf-8"));
|
|
93351
93307
|
}
|
|
@@ -93362,7 +93318,7 @@ function emptyManifest(name, version3) {
|
|
|
93362
93318
|
|
|
93363
93319
|
// src/marketplace/validator.ts
|
|
93364
93320
|
import * as fs24 from "fs";
|
|
93365
|
-
import * as
|
|
93321
|
+
import * as path26 from "path";
|
|
93366
93322
|
function issue2(code, severity, message) {
|
|
93367
93323
|
return { code, severity, message };
|
|
93368
93324
|
}
|
|
@@ -93409,7 +93365,7 @@ function validatePackageJson(pkg, directory) {
|
|
|
93409
93365
|
if (pkg.private === true) {
|
|
93410
93366
|
issues.push(issue2("PKG-004", "error", 'Package must not be "private: true"'));
|
|
93411
93367
|
}
|
|
93412
|
-
if (!fs24.existsSync(
|
|
93368
|
+
if (!fs24.existsSync(path26.join(directory, "README.md"))) {
|
|
93413
93369
|
issues.push(issue2("PKG-007", "warning", "README.md should exist"));
|
|
93414
93370
|
}
|
|
93415
93371
|
return issues;
|
|
@@ -93463,7 +93419,7 @@ function validateManifestContents(manifest) {
|
|
|
93463
93419
|
async function validateWorkflows(manifest, directory) {
|
|
93464
93420
|
const issues = [];
|
|
93465
93421
|
for (const wf of manifest.workflows) {
|
|
93466
|
-
const srcFile =
|
|
93422
|
+
const srcFile = path26.join(
|
|
93467
93423
|
directory,
|
|
93468
93424
|
wf.file.replace(/^dist\//, "src/").replace(/\.js$/, ".ts")
|
|
93469
93425
|
);
|
|
@@ -93487,7 +93443,7 @@ async function validateWorkflows(manifest, directory) {
|
|
|
93487
93443
|
return issues;
|
|
93488
93444
|
}
|
|
93489
93445
|
async function validatePackage(directory, manifest) {
|
|
93490
|
-
const pkgPath =
|
|
93446
|
+
const pkgPath = path26.join(directory, "package.json");
|
|
93491
93447
|
if (!fs24.existsSync(pkgPath)) {
|
|
93492
93448
|
return {
|
|
93493
93449
|
valid: false,
|
|
@@ -93507,7 +93463,7 @@ async function validatePackage(directory, manifest) {
|
|
|
93507
93463
|
// src/marketplace/registry.ts
|
|
93508
93464
|
init_esm5();
|
|
93509
93465
|
import * as fs25 from "fs";
|
|
93510
|
-
import * as
|
|
93466
|
+
import * as path27 from "path";
|
|
93511
93467
|
var MARKETPLACE_KEYWORD2 = "flowweaver-marketplace-pack";
|
|
93512
93468
|
var NPM_SEARCH_URL = "https://registry.npmjs.org/-/v1/search";
|
|
93513
93469
|
var PACK_NAME_RE2 = /^(@[^/]+\/)?flowweaver-pack-.+$/;
|
|
@@ -93535,22 +93491,22 @@ async function searchPackages(options = {}) {
|
|
|
93535
93491
|
}));
|
|
93536
93492
|
}
|
|
93537
93493
|
async function listInstalledPackages(projectDir) {
|
|
93538
|
-
const nodeModules =
|
|
93494
|
+
const nodeModules = path27.join(projectDir, "node_modules");
|
|
93539
93495
|
if (!fs25.existsSync(nodeModules)) return [];
|
|
93540
93496
|
const patterns = [
|
|
93541
|
-
|
|
93542
|
-
|
|
93497
|
+
path27.join(nodeModules, "flowweaver-pack-*", "flowweaver.manifest.json"),
|
|
93498
|
+
path27.join(nodeModules, "@*", "flowweaver-pack-*", "flowweaver.manifest.json")
|
|
93543
93499
|
];
|
|
93544
93500
|
const results = [];
|
|
93545
93501
|
for (const pattern of patterns) {
|
|
93546
93502
|
const manifestPaths = await glob(pattern.replace(/\\/g, "/"), { absolute: true });
|
|
93547
93503
|
for (const manifestPath of manifestPaths) {
|
|
93548
93504
|
try {
|
|
93549
|
-
const pkgDir =
|
|
93505
|
+
const pkgDir = path27.dirname(manifestPath);
|
|
93550
93506
|
const manifest = JSON.parse(
|
|
93551
93507
|
fs25.readFileSync(manifestPath, "utf-8")
|
|
93552
93508
|
);
|
|
93553
|
-
const pkgJsonPath =
|
|
93509
|
+
const pkgJsonPath = path27.join(pkgDir, "package.json");
|
|
93554
93510
|
let version3 = manifest.version;
|
|
93555
93511
|
if (fs25.existsSync(pkgJsonPath)) {
|
|
93556
93512
|
const pkg = JSON.parse(fs25.readFileSync(pkgJsonPath, "utf-8"));
|
|
@@ -93569,8 +93525,8 @@ async function listInstalledPackages(projectDir) {
|
|
|
93569
93525
|
return results;
|
|
93570
93526
|
}
|
|
93571
93527
|
function getInstalledPackageManifest(projectDir, packageName) {
|
|
93572
|
-
const packageDir =
|
|
93573
|
-
const manifestPath =
|
|
93528
|
+
const packageDir = path27.join(projectDir, "node_modules", packageName);
|
|
93529
|
+
const manifestPath = path27.join(packageDir, "flowweaver.manifest.json");
|
|
93574
93530
|
if (!fs25.existsSync(manifestPath)) return null;
|
|
93575
93531
|
try {
|
|
93576
93532
|
return JSON.parse(fs25.readFileSync(manifestPath, "utf-8"));
|
|
@@ -93623,7 +93579,7 @@ function registerMarketplaceTools(mcp) {
|
|
|
93623
93579
|
},
|
|
93624
93580
|
async (args) => {
|
|
93625
93581
|
try {
|
|
93626
|
-
|
|
93582
|
+
execSync3(`npm install ${args.package}`, {
|
|
93627
93583
|
cwd: process.cwd(),
|
|
93628
93584
|
stdio: "pipe"
|
|
93629
93585
|
});
|
|
@@ -93709,7 +93665,7 @@ function resolvePackageName(spec) {
|
|
|
93709
93665
|
|
|
93710
93666
|
// src/mcp/tools-diagram.ts
|
|
93711
93667
|
import * as fs26 from "fs";
|
|
93712
|
-
import * as
|
|
93668
|
+
import * as path28 from "path";
|
|
93713
93669
|
var ASCII_FORMATS2 = /* @__PURE__ */ new Set(["ascii", "ascii-compact", "text"]);
|
|
93714
93670
|
function registerDiagramTools(mcp) {
|
|
93715
93671
|
mcp.tool(
|
|
@@ -93746,7 +93702,7 @@ function registerDiagramTools(mcp) {
|
|
|
93746
93702
|
result = sourceToSVG(args.source, diagramOptions);
|
|
93747
93703
|
}
|
|
93748
93704
|
} else {
|
|
93749
|
-
const resolvedPath =
|
|
93705
|
+
const resolvedPath = path28.resolve(args.filePath);
|
|
93750
93706
|
if (!fs26.existsSync(resolvedPath)) {
|
|
93751
93707
|
return makeErrorResult("FILE_NOT_FOUND", `File not found: ${resolvedPath}`);
|
|
93752
93708
|
}
|
|
@@ -93759,7 +93715,7 @@ function registerDiagramTools(mcp) {
|
|
|
93759
93715
|
}
|
|
93760
93716
|
}
|
|
93761
93717
|
if (args.outputPath) {
|
|
93762
|
-
const outputResolved =
|
|
93718
|
+
const outputResolved = path28.resolve(args.outputPath);
|
|
93763
93719
|
fs26.writeFileSync(outputResolved, result, "utf-8");
|
|
93764
93720
|
return makeToolResult({ written: outputResolved, size: result.length });
|
|
93765
93721
|
}
|
|
@@ -93776,12 +93732,12 @@ function registerDiagramTools(mcp) {
|
|
|
93776
93732
|
|
|
93777
93733
|
// src/docs/index.ts
|
|
93778
93734
|
import * as fs27 from "fs";
|
|
93779
|
-
import * as
|
|
93780
|
-
import { fileURLToPath as
|
|
93735
|
+
import * as path29 from "path";
|
|
93736
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
93781
93737
|
function getDocsDir() {
|
|
93782
|
-
const thisFile =
|
|
93783
|
-
const packageRoot =
|
|
93784
|
-
return
|
|
93738
|
+
const thisFile = fileURLToPath3(import.meta.url);
|
|
93739
|
+
const packageRoot = path29.resolve(path29.dirname(thisFile), "..", "..");
|
|
93740
|
+
return path29.join(packageRoot, "docs", "reference");
|
|
93785
93741
|
}
|
|
93786
93742
|
function parseFrontmatter(raw) {
|
|
93787
93743
|
const fmMatch = raw.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
|
|
@@ -93857,7 +93813,7 @@ function listTopics() {
|
|
|
93857
93813
|
if (!fs27.existsSync(docsDir)) return [];
|
|
93858
93814
|
const files = fs27.readdirSync(docsDir).filter((f) => f.endsWith(".md")).sort();
|
|
93859
93815
|
return files.map((file) => {
|
|
93860
|
-
const raw = fs27.readFileSync(
|
|
93816
|
+
const raw = fs27.readFileSync(path29.join(docsDir, file), "utf-8");
|
|
93861
93817
|
const { frontmatter } = parseFrontmatter(raw);
|
|
93862
93818
|
return {
|
|
93863
93819
|
slug: file.replace(/\.md$/, ""),
|
|
@@ -93869,7 +93825,7 @@ function listTopics() {
|
|
|
93869
93825
|
}
|
|
93870
93826
|
function readTopic(slug, compact2) {
|
|
93871
93827
|
const docsDir = getDocsDir();
|
|
93872
|
-
const filePath =
|
|
93828
|
+
const filePath = path29.join(docsDir, `${slug}.md`);
|
|
93873
93829
|
if (!fs27.existsSync(filePath)) return null;
|
|
93874
93830
|
const raw = fs27.readFileSync(filePath, "utf-8");
|
|
93875
93831
|
const { frontmatter, body } = parseFrontmatter(raw);
|
|
@@ -93884,7 +93840,7 @@ function readTopic(slug, compact2) {
|
|
|
93884
93840
|
}
|
|
93885
93841
|
function readTopicStructured(slug) {
|
|
93886
93842
|
const docsDir = getDocsDir();
|
|
93887
|
-
const filePath =
|
|
93843
|
+
const filePath = path29.join(docsDir, `${slug}.md`);
|
|
93888
93844
|
if (!fs27.existsSync(filePath)) return null;
|
|
93889
93845
|
const raw = fs27.readFileSync(filePath, "utf-8");
|
|
93890
93846
|
const { frontmatter, body } = parseFrontmatter(raw);
|
|
@@ -93907,7 +93863,7 @@ function searchDocs(query) {
|
|
|
93907
93863
|
const keywordMatch = topic.keywords.some(
|
|
93908
93864
|
(kw) => queryTerms.some((term) => kw.toLowerCase().includes(term))
|
|
93909
93865
|
);
|
|
93910
|
-
const filePath =
|
|
93866
|
+
const filePath = path29.join(docsDir, `${topic.slug}.md`);
|
|
93911
93867
|
const raw = fs27.readFileSync(filePath, "utf-8");
|
|
93912
93868
|
const { body } = parseFrontmatter(raw);
|
|
93913
93869
|
const sections = splitSections(body);
|
|
@@ -94057,7 +94013,7 @@ function registerDocsTools(mcp) {
|
|
|
94057
94013
|
|
|
94058
94014
|
// src/mcp/tools-model.ts
|
|
94059
94015
|
import * as fs28 from "fs";
|
|
94060
|
-
import * as
|
|
94016
|
+
import * as path30 from "path";
|
|
94061
94017
|
var stepSchema = external_exports.object({
|
|
94062
94018
|
name: external_exports.string().describe("Function name for this node"),
|
|
94063
94019
|
description: external_exports.string().optional().describe("Brief description of what this node does"),
|
|
@@ -94094,7 +94050,7 @@ function registerModelTools(mcp) {
|
|
|
94094
94050
|
},
|
|
94095
94051
|
async (args) => {
|
|
94096
94052
|
try {
|
|
94097
|
-
const outputPath =
|
|
94053
|
+
const outputPath = path30.resolve(args.filePath);
|
|
94098
94054
|
const lines = [];
|
|
94099
94055
|
for (const step of args.steps) {
|
|
94100
94056
|
lines.push("/** @flowWeaver node */");
|
|
@@ -94122,7 +94078,7 @@ function registerModelTools(mcp) {
|
|
|
94122
94078
|
lines.push(...jsdocLines);
|
|
94123
94079
|
lines.push("");
|
|
94124
94080
|
const content = lines.join("\n");
|
|
94125
|
-
const dir =
|
|
94081
|
+
const dir = path30.dirname(outputPath);
|
|
94126
94082
|
if (!fs28.existsSync(dir)) {
|
|
94127
94083
|
fs28.mkdirSync(dir, { recursive: true });
|
|
94128
94084
|
}
|
|
@@ -94150,7 +94106,7 @@ function registerModelTools(mcp) {
|
|
|
94150
94106
|
},
|
|
94151
94107
|
async (args) => {
|
|
94152
94108
|
try {
|
|
94153
|
-
const filePath =
|
|
94109
|
+
const filePath = path30.resolve(args.filePath);
|
|
94154
94110
|
const parseResult = await parseWorkflow(filePath, { workflowName: args.workflowName });
|
|
94155
94111
|
if (parseResult.errors.length > 0) {
|
|
94156
94112
|
return makeErrorResult("PARSE_ERROR", `Parse errors:
|
|
@@ -94219,7 +94175,7 @@ ${parseResult.errors.join("\n")}`);
|
|
|
94219
94175
|
},
|
|
94220
94176
|
async (args) => {
|
|
94221
94177
|
try {
|
|
94222
|
-
const filePath =
|
|
94178
|
+
const filePath = path30.resolve(args.filePath);
|
|
94223
94179
|
if (!fs28.existsSync(filePath)) {
|
|
94224
94180
|
return makeErrorResult("FILE_NOT_FOUND", `File not found: ${args.filePath}`);
|
|
94225
94181
|
}
|
|
@@ -94316,14 +94272,14 @@ function registerResources(mcp, connection, buffer) {
|
|
|
94316
94272
|
mcp.resource(
|
|
94317
94273
|
"state",
|
|
94318
94274
|
"fw://state",
|
|
94319
|
-
{ description: "Current
|
|
94275
|
+
{ description: "Current Studio/workflow state" },
|
|
94320
94276
|
async () => {
|
|
94321
94277
|
if (!connection.isConnected) {
|
|
94322
94278
|
return {
|
|
94323
94279
|
contents: [
|
|
94324
94280
|
{
|
|
94325
94281
|
uri: "fw://state",
|
|
94326
|
-
text: JSON.stringify({ error: "Not connected to
|
|
94282
|
+
text: JSON.stringify({ error: "Not connected to Studio" })
|
|
94327
94283
|
}
|
|
94328
94284
|
]
|
|
94329
94285
|
};
|
|
@@ -94482,8 +94438,8 @@ async function mcpServerCommand(options) {
|
|
|
94482
94438
|
const serverUrl = options.server || DEFAULT_SERVER_URL;
|
|
94483
94439
|
const log = options.stdio ? (msg) => process.stderr.write(msg + "\n") : (msg) => process.stdout.write(msg + "\n");
|
|
94484
94440
|
if (!options.stdio) {
|
|
94485
|
-
|
|
94486
|
-
log(`Starting MCP server (
|
|
94441
|
+
log('Tip: run "flow-weaver mcp-setup" to register with your AI tools.');
|
|
94442
|
+
log(`Starting MCP server (Studio: ${serverUrl})...`);
|
|
94487
94443
|
}
|
|
94488
94444
|
await startMcpServer(options);
|
|
94489
94445
|
if (!options.stdio) {
|
|
@@ -94503,20 +94459,20 @@ async function sendCommand(serverUrl, action, params) {
|
|
|
94503
94459
|
transports: ["websocket", "polling"]
|
|
94504
94460
|
});
|
|
94505
94461
|
try {
|
|
94506
|
-
await new Promise((
|
|
94507
|
-
socket.on("connect", () =>
|
|
94462
|
+
await new Promise((resolve30, reject2) => {
|
|
94463
|
+
socket.on("connect", () => resolve30());
|
|
94508
94464
|
socket.on("connect_error", (err) => reject2(err));
|
|
94509
94465
|
setTimeout(() => reject2(new Error("Connection timeout")), ACK_TIMEOUT);
|
|
94510
94466
|
});
|
|
94511
94467
|
const requestId = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
94512
|
-
const result = await new Promise((
|
|
94468
|
+
const result = await new Promise((resolve30) => {
|
|
94513
94469
|
const timeout = setTimeout(() => {
|
|
94514
|
-
|
|
94470
|
+
resolve30({ requestId, success: false, error: "Timeout" });
|
|
94515
94471
|
}, ACK_TIMEOUT);
|
|
94516
94472
|
socket.on("fw:ack", (data) => {
|
|
94517
94473
|
if (data.requestId === requestId) {
|
|
94518
94474
|
clearTimeout(timeout);
|
|
94519
|
-
|
|
94475
|
+
resolve30(data);
|
|
94520
94476
|
}
|
|
94521
94477
|
});
|
|
94522
94478
|
socket.emit("integration:command", { requestId, action, params });
|
|
@@ -94546,20 +94502,20 @@ async function sendBatch(serverUrl, commands) {
|
|
|
94546
94502
|
transports: ["websocket", "polling"]
|
|
94547
94503
|
});
|
|
94548
94504
|
try {
|
|
94549
|
-
await new Promise((
|
|
94550
|
-
socket.on("connect", () =>
|
|
94505
|
+
await new Promise((resolve30, reject2) => {
|
|
94506
|
+
socket.on("connect", () => resolve30());
|
|
94551
94507
|
socket.on("connect_error", (err) => reject2(err));
|
|
94552
94508
|
setTimeout(() => reject2(new Error("Connection timeout")), ACK_TIMEOUT);
|
|
94553
94509
|
});
|
|
94554
94510
|
const requestId = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
94555
|
-
const result = await new Promise((
|
|
94511
|
+
const result = await new Promise((resolve30) => {
|
|
94556
94512
|
const timeout = setTimeout(() => {
|
|
94557
|
-
|
|
94513
|
+
resolve30({ requestId, success: false, error: "Timeout" });
|
|
94558
94514
|
}, ACK_TIMEOUT);
|
|
94559
94515
|
socket.on("fw:ack", (data) => {
|
|
94560
94516
|
if (data.requestId === requestId) {
|
|
94561
94517
|
clearTimeout(timeout);
|
|
94562
|
-
|
|
94518
|
+
resolve30(data);
|
|
94563
94519
|
}
|
|
94564
94520
|
});
|
|
94565
94521
|
socket.emit("integration:batch", { requestId, commands });
|
|
@@ -94644,11 +94600,11 @@ async function grammarCommand(options = {}) {
|
|
|
94644
94600
|
}
|
|
94645
94601
|
|
|
94646
94602
|
// src/cli/commands/run.ts
|
|
94647
|
-
import * as
|
|
94603
|
+
import * as path31 from "path";
|
|
94648
94604
|
import * as fs30 from "fs";
|
|
94649
|
-
import * as
|
|
94605
|
+
import * as readline8 from "readline";
|
|
94650
94606
|
async function runCommand(input, options) {
|
|
94651
|
-
const filePath =
|
|
94607
|
+
const filePath = path31.resolve(input);
|
|
94652
94608
|
if (!fs30.existsSync(filePath)) {
|
|
94653
94609
|
throw new Error(`File not found: ${filePath}`);
|
|
94654
94610
|
}
|
|
@@ -94660,7 +94616,7 @@ async function runCommand(input, options) {
|
|
|
94660
94616
|
throw new Error(`Invalid JSON in --params: ${options.params}`);
|
|
94661
94617
|
}
|
|
94662
94618
|
} else if (options.paramsFile) {
|
|
94663
|
-
const paramsFilePath =
|
|
94619
|
+
const paramsFilePath = path31.resolve(options.paramsFile);
|
|
94664
94620
|
if (!fs30.existsSync(paramsFilePath)) {
|
|
94665
94621
|
throw new Error(`Params file not found: ${paramsFilePath}`);
|
|
94666
94622
|
}
|
|
@@ -94679,7 +94635,7 @@ async function runCommand(input, options) {
|
|
|
94679
94635
|
throw new Error(`Invalid JSON in --mocks: ${options.mocks}`);
|
|
94680
94636
|
}
|
|
94681
94637
|
} else if (options.mocksFile) {
|
|
94682
|
-
const mocksFilePath =
|
|
94638
|
+
const mocksFilePath = path31.resolve(options.mocksFile);
|
|
94683
94639
|
if (!fs30.existsSync(mocksFilePath)) {
|
|
94684
94640
|
throw new Error(`Mocks file not found: ${mocksFilePath}`);
|
|
94685
94641
|
}
|
|
@@ -94877,21 +94833,21 @@ async function validateMockConfig(mocks, filePath, workflowName) {
|
|
|
94877
94833
|
}
|
|
94878
94834
|
}
|
|
94879
94835
|
function promptForInput(question) {
|
|
94880
|
-
return new Promise((
|
|
94881
|
-
const rl =
|
|
94836
|
+
return new Promise((resolve30) => {
|
|
94837
|
+
const rl = readline8.createInterface({
|
|
94882
94838
|
input: process.stdin,
|
|
94883
94839
|
output: process.stderr
|
|
94884
94840
|
// prompts to stderr, not stdout
|
|
94885
94841
|
});
|
|
94886
94842
|
rl.question(question, (answer) => {
|
|
94887
94843
|
rl.close();
|
|
94888
|
-
|
|
94844
|
+
resolve30(answer.trim());
|
|
94889
94845
|
});
|
|
94890
94846
|
});
|
|
94891
94847
|
}
|
|
94892
94848
|
|
|
94893
94849
|
// src/cli/commands/serve.ts
|
|
94894
|
-
import * as
|
|
94850
|
+
import * as path32 from "path";
|
|
94895
94851
|
import * as fs32 from "fs";
|
|
94896
94852
|
|
|
94897
94853
|
// src/server/workflow-registry.ts
|
|
@@ -95323,7 +95279,7 @@ var WebhookServer = class {
|
|
|
95323
95279
|
|
|
95324
95280
|
// src/cli/commands/serve.ts
|
|
95325
95281
|
async function serveCommand(dir, options) {
|
|
95326
|
-
const workflowDir =
|
|
95282
|
+
const workflowDir = path32.resolve(dir || ".");
|
|
95327
95283
|
if (!fs32.existsSync(workflowDir)) {
|
|
95328
95284
|
throw new Error(`Directory not found: ${workflowDir}`);
|
|
95329
95285
|
}
|
|
@@ -95370,10 +95326,10 @@ async function serveCommand(dir, options) {
|
|
|
95370
95326
|
}
|
|
95371
95327
|
|
|
95372
95328
|
// src/export/index.ts
|
|
95373
|
-
import * as
|
|
95329
|
+
import * as path33 from "path";
|
|
95374
95330
|
import * as fs33 from "fs";
|
|
95375
95331
|
import * as os2 from "os";
|
|
95376
|
-
import { fileURLToPath as
|
|
95332
|
+
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
95377
95333
|
|
|
95378
95334
|
// src/export/templates.ts
|
|
95379
95335
|
var LAMBDA_TEMPLATE = `{{GENERATED_HEADER}}
|
|
@@ -95545,11 +95501,11 @@ Outputs:
|
|
|
95545
95501
|
`;
|
|
95546
95502
|
|
|
95547
95503
|
// src/export/index.ts
|
|
95548
|
-
var __filename =
|
|
95549
|
-
var __dirname2 =
|
|
95504
|
+
var __filename = fileURLToPath4(import.meta.url);
|
|
95505
|
+
var __dirname2 = path33.dirname(__filename);
|
|
95550
95506
|
async function exportMultiWorkflow(options) {
|
|
95551
|
-
const inputPath =
|
|
95552
|
-
const outputDir =
|
|
95507
|
+
const inputPath = path33.resolve(options.input);
|
|
95508
|
+
const outputDir = path33.resolve(options.output);
|
|
95553
95509
|
const isDryRun = options.dryRun ?? false;
|
|
95554
95510
|
if (!fs33.existsSync(inputPath)) {
|
|
95555
95511
|
throw new Error(`Input file not found: ${inputPath}`);
|
|
@@ -95569,14 +95525,14 @@ async function exportMultiWorkflow(options) {
|
|
|
95569
95525
|
throw new Error(`None of the requested workflows found. Available: ${available}`);
|
|
95570
95526
|
}
|
|
95571
95527
|
}
|
|
95572
|
-
const workDir = isDryRun ?
|
|
95528
|
+
const workDir = isDryRun ? path33.join(os2.tmpdir(), `fw-export-multi-dryrun-${Date.now()}`) : outputDir;
|
|
95573
95529
|
fs33.mkdirSync(workDir, { recursive: true });
|
|
95574
|
-
fs33.mkdirSync(
|
|
95575
|
-
fs33.mkdirSync(
|
|
95530
|
+
fs33.mkdirSync(path33.join(workDir, "workflows"), { recursive: true });
|
|
95531
|
+
fs33.mkdirSync(path33.join(workDir, "runtime"), { recursive: true });
|
|
95576
95532
|
const compiledWorkflows = [];
|
|
95577
95533
|
try {
|
|
95578
95534
|
for (const workflow of selectedWorkflows) {
|
|
95579
|
-
const workflowOutputPath =
|
|
95535
|
+
const workflowOutputPath = path33.join(workDir, "workflows", `${workflow.name}.ts`);
|
|
95580
95536
|
fs33.copyFileSync(inputPath, workflowOutputPath);
|
|
95581
95537
|
await compileWorkflow(workflowOutputPath, {
|
|
95582
95538
|
write: true,
|
|
@@ -95592,12 +95548,12 @@ async function exportMultiWorkflow(options) {
|
|
|
95592
95548
|
code: compiledCode
|
|
95593
95549
|
});
|
|
95594
95550
|
}
|
|
95595
|
-
const runtimeDir =
|
|
95596
|
-
const libraryRuntimeDir =
|
|
95551
|
+
const runtimeDir = path33.join(workDir, "runtime");
|
|
95552
|
+
const libraryRuntimeDir = path33.resolve(__dirname2, "../runtime");
|
|
95597
95553
|
const runtimeFiles = ["function-registry.ts", "parameter-resolver.ts", "builtin-functions.ts"];
|
|
95598
95554
|
for (const file of runtimeFiles) {
|
|
95599
|
-
const srcPath =
|
|
95600
|
-
const destPath =
|
|
95555
|
+
const srcPath = path33.join(libraryRuntimeDir, file);
|
|
95556
|
+
const destPath = path33.join(runtimeDir, file);
|
|
95601
95557
|
if (fs33.existsSync(srcPath)) {
|
|
95602
95558
|
fs33.copyFileSync(srcPath, destPath);
|
|
95603
95559
|
}
|
|
@@ -95605,7 +95561,7 @@ async function exportMultiWorkflow(options) {
|
|
|
95605
95561
|
const result = generateMultiHandler(options.target, compiledWorkflows, workDir, options);
|
|
95606
95562
|
if (!isDryRun) {
|
|
95607
95563
|
for (const file of result.files) {
|
|
95608
|
-
const dirPath =
|
|
95564
|
+
const dirPath = path33.dirname(file.path);
|
|
95609
95565
|
if (!fs33.existsSync(dirPath)) {
|
|
95610
95566
|
fs33.mkdirSync(dirPath, { recursive: true });
|
|
95611
95567
|
}
|
|
@@ -95630,28 +95586,28 @@ async function exportMultiWorkflow(options) {
|
|
|
95630
95586
|
}
|
|
95631
95587
|
function generateMultiHandler(target, workflows, outputDir, options) {
|
|
95632
95588
|
const files = [];
|
|
95633
|
-
const serviceName =
|
|
95589
|
+
const serviceName = path33.basename(options.input, path33.extname(options.input)) + "-service";
|
|
95634
95590
|
const workflowImports = workflows.map((w) => `import { ${w.functionName} } from './workflows/${w.name}.js';`).join("\n");
|
|
95635
95591
|
const workflowEntries = workflows.map((w) => ` '${w.name}': ${w.functionName},`).join("\n");
|
|
95636
95592
|
const openApiSpec = generateMultiWorkflowOpenAPI(workflows, serviceName);
|
|
95637
95593
|
switch (target) {
|
|
95638
95594
|
case "lambda":
|
|
95639
95595
|
files.push({
|
|
95640
|
-
path:
|
|
95596
|
+
path: path33.join(outputDir, "handler.ts"),
|
|
95641
95597
|
content: generateLambdaMultiHandler(workflowImports, workflowEntries, serviceName)
|
|
95642
95598
|
});
|
|
95643
95599
|
files.push({
|
|
95644
|
-
path:
|
|
95600
|
+
path: path33.join(outputDir, "openapi.ts"),
|
|
95645
95601
|
content: `// Generated OpenAPI specification
|
|
95646
95602
|
export const openApiSpec = ${JSON.stringify(openApiSpec, null, 2)};
|
|
95647
95603
|
`
|
|
95648
95604
|
});
|
|
95649
95605
|
files.push({
|
|
95650
|
-
path:
|
|
95606
|
+
path: path33.join(outputDir, "template.yaml"),
|
|
95651
95607
|
content: generateLambdaSAMMultiTemplate(serviceName, workflows.length)
|
|
95652
95608
|
});
|
|
95653
95609
|
files.push({
|
|
95654
|
-
path:
|
|
95610
|
+
path: path33.join(outputDir, "package.json"),
|
|
95655
95611
|
content: JSON.stringify(
|
|
95656
95612
|
{
|
|
95657
95613
|
name: `fw-${serviceName}`,
|
|
@@ -95672,7 +95628,7 @@ export const openApiSpec = ${JSON.stringify(openApiSpec, null, 2)};
|
|
|
95672
95628
|
)
|
|
95673
95629
|
});
|
|
95674
95630
|
files.push({
|
|
95675
|
-
path:
|
|
95631
|
+
path: path33.join(outputDir, "tsconfig.json"),
|
|
95676
95632
|
content: JSON.stringify(
|
|
95677
95633
|
{
|
|
95678
95634
|
compilerOptions: {
|
|
@@ -95693,17 +95649,17 @@ export const openApiSpec = ${JSON.stringify(openApiSpec, null, 2)};
|
|
|
95693
95649
|
break;
|
|
95694
95650
|
case "vercel":
|
|
95695
95651
|
files.push({
|
|
95696
|
-
path:
|
|
95652
|
+
path: path33.join(outputDir, "api", "[workflow].ts"),
|
|
95697
95653
|
content: generateVercelMultiHandler(workflowImports, workflowEntries, serviceName)
|
|
95698
95654
|
});
|
|
95699
95655
|
files.push({
|
|
95700
|
-
path:
|
|
95656
|
+
path: path33.join(outputDir, "openapi.ts"),
|
|
95701
95657
|
content: `// Generated OpenAPI specification
|
|
95702
95658
|
export const openApiSpec = ${JSON.stringify(openApiSpec, null, 2)};
|
|
95703
95659
|
`
|
|
95704
95660
|
});
|
|
95705
95661
|
files.push({
|
|
95706
|
-
path:
|
|
95662
|
+
path: path33.join(outputDir, "vercel.json"),
|
|
95707
95663
|
content: JSON.stringify(
|
|
95708
95664
|
{
|
|
95709
95665
|
functions: {
|
|
@@ -95720,17 +95676,17 @@ export const openApiSpec = ${JSON.stringify(openApiSpec, null, 2)};
|
|
|
95720
95676
|
break;
|
|
95721
95677
|
case "cloudflare":
|
|
95722
95678
|
files.push({
|
|
95723
|
-
path:
|
|
95679
|
+
path: path33.join(outputDir, "index.ts"),
|
|
95724
95680
|
content: generateCloudflareMultiHandler(workflowImports, workflowEntries, serviceName)
|
|
95725
95681
|
});
|
|
95726
95682
|
files.push({
|
|
95727
|
-
path:
|
|
95683
|
+
path: path33.join(outputDir, "openapi.ts"),
|
|
95728
95684
|
content: `// Generated OpenAPI specification
|
|
95729
95685
|
export const openApiSpec = ${JSON.stringify(openApiSpec, null, 2)};
|
|
95730
95686
|
`
|
|
95731
95687
|
});
|
|
95732
95688
|
files.push({
|
|
95733
|
-
path:
|
|
95689
|
+
path: path33.join(outputDir, "wrangler.toml"),
|
|
95734
95690
|
content: `name = "${serviceName}"
|
|
95735
95691
|
main = "dist/index.js"
|
|
95736
95692
|
compatibility_date = "2024-01-01"
|
|
@@ -95740,7 +95696,7 @@ command = "npm run build"
|
|
|
95740
95696
|
`
|
|
95741
95697
|
});
|
|
95742
95698
|
files.push({
|
|
95743
|
-
path:
|
|
95699
|
+
path: path33.join(outputDir, "package.json"),
|
|
95744
95700
|
content: JSON.stringify(
|
|
95745
95701
|
{
|
|
95746
95702
|
name: `fw-${serviceName}`,
|
|
@@ -95762,7 +95718,7 @@ command = "npm run build"
|
|
|
95762
95718
|
)
|
|
95763
95719
|
});
|
|
95764
95720
|
files.push({
|
|
95765
|
-
path:
|
|
95721
|
+
path: path33.join(outputDir, "tsconfig.json"),
|
|
95766
95722
|
content: JSON.stringify(
|
|
95767
95723
|
{
|
|
95768
95724
|
compilerOptions: {
|
|
@@ -95783,17 +95739,17 @@ command = "npm run build"
|
|
|
95783
95739
|
break;
|
|
95784
95740
|
case "inngest":
|
|
95785
95741
|
files.push({
|
|
95786
|
-
path:
|
|
95742
|
+
path: path33.join(outputDir, "handler.ts"),
|
|
95787
95743
|
content: generateInngestMultiHandler(workflowImports, workflowEntries, serviceName, workflows)
|
|
95788
95744
|
});
|
|
95789
95745
|
files.push({
|
|
95790
|
-
path:
|
|
95746
|
+
path: path33.join(outputDir, "openapi.ts"),
|
|
95791
95747
|
content: `// Generated OpenAPI specification
|
|
95792
95748
|
export const openApiSpec = ${JSON.stringify(openApiSpec, null, 2)};
|
|
95793
95749
|
`
|
|
95794
95750
|
});
|
|
95795
95751
|
files.push({
|
|
95796
|
-
path:
|
|
95752
|
+
path: path33.join(outputDir, "package.json"),
|
|
95797
95753
|
content: JSON.stringify(
|
|
95798
95754
|
{
|
|
95799
95755
|
name: `fw-${serviceName}`,
|
|
@@ -95819,7 +95775,7 @@ export const openApiSpec = ${JSON.stringify(openApiSpec, null, 2)};
|
|
|
95819
95775
|
)
|
|
95820
95776
|
});
|
|
95821
95777
|
files.push({
|
|
95822
|
-
path:
|
|
95778
|
+
path: path33.join(outputDir, "tsconfig.json"),
|
|
95823
95779
|
content: JSON.stringify(
|
|
95824
95780
|
{
|
|
95825
95781
|
compilerOptions: {
|
|
@@ -96275,8 +96231,8 @@ async function exportWorkflow(options) {
|
|
|
96275
96231
|
if (options.multi) {
|
|
96276
96232
|
return exportMultiWorkflow(options);
|
|
96277
96233
|
}
|
|
96278
|
-
const inputPath =
|
|
96279
|
-
const outputDir =
|
|
96234
|
+
const inputPath = path33.resolve(options.input);
|
|
96235
|
+
const outputDir = path33.resolve(options.output);
|
|
96280
96236
|
const isDryRun = options.dryRun ?? false;
|
|
96281
96237
|
if (!fs33.existsSync(inputPath)) {
|
|
96282
96238
|
throw new Error(`Input file not found: ${inputPath}`);
|
|
@@ -96293,7 +96249,7 @@ async function exportWorkflow(options) {
|
|
|
96293
96249
|
const available = parseResult.workflows.map((w) => w.name).join(", ");
|
|
96294
96250
|
throw new Error(`Workflow "${options.workflow}" not found. Available: ${available}`);
|
|
96295
96251
|
}
|
|
96296
|
-
const workDir = isDryRun ?
|
|
96252
|
+
const workDir = isDryRun ? path33.join(os2.tmpdir(), `fw-export-dryrun-${Date.now()}`) : outputDir;
|
|
96297
96253
|
fs33.mkdirSync(workDir, { recursive: true });
|
|
96298
96254
|
let compiledContent;
|
|
96299
96255
|
let compiledPath;
|
|
@@ -96323,8 +96279,8 @@ async function exportWorkflow(options) {
|
|
|
96323
96279
|
handler = generateHandler(options.target, compiledPath, workflow.functionName);
|
|
96324
96280
|
}
|
|
96325
96281
|
const handlerFileName = getHandlerFileName(options.target, workflow.name);
|
|
96326
|
-
const handlerPath =
|
|
96327
|
-
const workflowOutputPath =
|
|
96282
|
+
const handlerPath = path33.join(outputDir, handlerFileName);
|
|
96283
|
+
const workflowOutputPath = path33.join(outputDir, "workflow.ts");
|
|
96328
96284
|
const configFiles = generateConfigFiles(
|
|
96329
96285
|
options.target,
|
|
96330
96286
|
workflow.name,
|
|
@@ -96333,7 +96289,7 @@ async function exportWorkflow(options) {
|
|
|
96333
96289
|
);
|
|
96334
96290
|
if (!isDryRun) {
|
|
96335
96291
|
fs33.mkdirSync(outputDir, { recursive: true });
|
|
96336
|
-
const handlerDir =
|
|
96292
|
+
const handlerDir = path33.dirname(handlerPath);
|
|
96337
96293
|
if (!fs33.existsSync(handlerDir)) {
|
|
96338
96294
|
fs33.mkdirSync(handlerDir, { recursive: true });
|
|
96339
96295
|
}
|
|
@@ -96356,7 +96312,7 @@ async function exportWorkflow(options) {
|
|
|
96356
96312
|
};
|
|
96357
96313
|
}
|
|
96358
96314
|
async function compileToOutput(inputPath, functionName, outputDir, production) {
|
|
96359
|
-
const outputPath =
|
|
96315
|
+
const outputPath = path33.join(outputDir, "workflow.ts");
|
|
96360
96316
|
fs33.copyFileSync(inputPath, outputPath);
|
|
96361
96317
|
await compileWorkflow(outputPath, {
|
|
96362
96318
|
write: true,
|
|
@@ -96368,7 +96324,7 @@ async function compileToOutput(inputPath, functionName, outputDir, production) {
|
|
|
96368
96324
|
}
|
|
96369
96325
|
function generateHandler(target, workflowPath, functionName) {
|
|
96370
96326
|
const template = getTemplate(target);
|
|
96371
|
-
const relativePath = target === "vercel" ? `../${
|
|
96327
|
+
const relativePath = target === "vercel" ? `../${path33.basename(workflowPath).replace(".ts", ".js")}` : `./${path33.basename(workflowPath).replace(".ts", ".js")}`;
|
|
96372
96328
|
return template.replace("{{GENERATED_HEADER}}", getGeneratedBranding().header(`export --target ${target}`)).replace("{{WORKFLOW_IMPORT}}", `import { ${functionName} } from '${relativePath}';`).replace(/\{\{FUNCTION_NAME\}\}/g, functionName).replace("{{MAX_DURATION}}", "60");
|
|
96373
96329
|
}
|
|
96374
96330
|
function getTemplate(target) {
|
|
@@ -96400,14 +96356,14 @@ function generateConfigFiles(target, workflowName, outputDir, description) {
|
|
|
96400
96356
|
switch (target) {
|
|
96401
96357
|
case "lambda":
|
|
96402
96358
|
files.push({
|
|
96403
|
-
path:
|
|
96359
|
+
path: path33.join(outputDir, "template.yaml"),
|
|
96404
96360
|
content: SAM_TEMPLATE2.replace(/\{\{WORKFLOW_NAME\}\}/g, workflowName).replace(
|
|
96405
96361
|
"{{WORKFLOW_DESCRIPTION}}",
|
|
96406
96362
|
description || `Flow Weaver workflow: ${workflowName}`
|
|
96407
96363
|
).replace(/\{\{WORKFLOW_PATH\}\}/g, workflowName)
|
|
96408
96364
|
});
|
|
96409
96365
|
files.push({
|
|
96410
|
-
path:
|
|
96366
|
+
path: path33.join(outputDir, "package.json"),
|
|
96411
96367
|
content: JSON.stringify(
|
|
96412
96368
|
{
|
|
96413
96369
|
name: `fw-${workflowName}`,
|
|
@@ -96428,7 +96384,7 @@ function generateConfigFiles(target, workflowName, outputDir, description) {
|
|
|
96428
96384
|
)
|
|
96429
96385
|
});
|
|
96430
96386
|
files.push({
|
|
96431
|
-
path:
|
|
96387
|
+
path: path33.join(outputDir, "tsconfig.json"),
|
|
96432
96388
|
content: JSON.stringify(
|
|
96433
96389
|
{
|
|
96434
96390
|
compilerOptions: {
|
|
@@ -96449,7 +96405,7 @@ function generateConfigFiles(target, workflowName, outputDir, description) {
|
|
|
96449
96405
|
break;
|
|
96450
96406
|
case "vercel":
|
|
96451
96407
|
files.push({
|
|
96452
|
-
path:
|
|
96408
|
+
path: path33.join(outputDir, "vercel.json"),
|
|
96453
96409
|
content: JSON.stringify(
|
|
96454
96410
|
{
|
|
96455
96411
|
functions: {
|
|
@@ -96466,7 +96422,7 @@ function generateConfigFiles(target, workflowName, outputDir, description) {
|
|
|
96466
96422
|
break;
|
|
96467
96423
|
case "cloudflare":
|
|
96468
96424
|
files.push({
|
|
96469
|
-
path:
|
|
96425
|
+
path: path33.join(outputDir, "wrangler.toml"),
|
|
96470
96426
|
content: `name = "${workflowName}"
|
|
96471
96427
|
main = "dist/index.js"
|
|
96472
96428
|
compatibility_date = "2024-01-01"
|
|
@@ -96476,7 +96432,7 @@ command = "npm run build"
|
|
|
96476
96432
|
`
|
|
96477
96433
|
});
|
|
96478
96434
|
files.push({
|
|
96479
|
-
path:
|
|
96435
|
+
path: path33.join(outputDir, "package.json"),
|
|
96480
96436
|
content: JSON.stringify(
|
|
96481
96437
|
{
|
|
96482
96438
|
name: `fw-${workflowName}`,
|
|
@@ -96498,7 +96454,7 @@ command = "npm run build"
|
|
|
96498
96454
|
)
|
|
96499
96455
|
});
|
|
96500
96456
|
files.push({
|
|
96501
|
-
path:
|
|
96457
|
+
path: path33.join(outputDir, "tsconfig.json"),
|
|
96502
96458
|
content: JSON.stringify(
|
|
96503
96459
|
{
|
|
96504
96460
|
compilerOptions: {
|
|
@@ -96519,7 +96475,7 @@ command = "npm run build"
|
|
|
96519
96475
|
break;
|
|
96520
96476
|
case "inngest":
|
|
96521
96477
|
files.push({
|
|
96522
|
-
path:
|
|
96478
|
+
path: path33.join(outputDir, "package.json"),
|
|
96523
96479
|
content: JSON.stringify(
|
|
96524
96480
|
{
|
|
96525
96481
|
name: `fw-${workflowName}`,
|
|
@@ -96543,7 +96499,7 @@ command = "npm run build"
|
|
|
96543
96499
|
)
|
|
96544
96500
|
});
|
|
96545
96501
|
files.push({
|
|
96546
|
-
path:
|
|
96502
|
+
path: path33.join(outputDir, "tsconfig.json"),
|
|
96547
96503
|
content: JSON.stringify(
|
|
96548
96504
|
{
|
|
96549
96505
|
compilerOptions: {
|
|
@@ -96695,10 +96651,10 @@ async function exportCommand(input, options) {
|
|
|
96695
96651
|
}
|
|
96696
96652
|
|
|
96697
96653
|
// src/cli/commands/openapi.ts
|
|
96698
|
-
import * as
|
|
96654
|
+
import * as path34 from "path";
|
|
96699
96655
|
import * as fs34 from "fs";
|
|
96700
96656
|
async function openapiCommand(dir, options) {
|
|
96701
|
-
const workflowDir =
|
|
96657
|
+
const workflowDir = path34.resolve(dir);
|
|
96702
96658
|
if (!fs34.existsSync(workflowDir)) {
|
|
96703
96659
|
throw new Error(`Directory not found: ${workflowDir}`);
|
|
96704
96660
|
}
|
|
@@ -96721,7 +96677,7 @@ async function openapiCommand(dir, options) {
|
|
|
96721
96677
|
const format = options.format || "json";
|
|
96722
96678
|
const spec = format === "yaml" ? generateOpenAPIYaml(endpoints, generatorOptions) : generateOpenAPIJson(endpoints, generatorOptions);
|
|
96723
96679
|
if (options.output) {
|
|
96724
|
-
const outputPath =
|
|
96680
|
+
const outputPath = path34.resolve(options.output);
|
|
96725
96681
|
fs34.writeFileSync(outputPath, spec);
|
|
96726
96682
|
logger.success(`OpenAPI specification written to ${outputPath}`);
|
|
96727
96683
|
} else {
|
|
@@ -96731,7 +96687,7 @@ async function openapiCommand(dir, options) {
|
|
|
96731
96687
|
|
|
96732
96688
|
// src/cli/commands/plugin.ts
|
|
96733
96689
|
import * as fs35 from "fs";
|
|
96734
|
-
import * as
|
|
96690
|
+
import * as path35 from "path";
|
|
96735
96691
|
var PLUGIN_NAME_RE = /^[a-zA-Z0-9][-a-zA-Z0-9_.]*$/;
|
|
96736
96692
|
var VALID_AREAS = ["sidebar", "main", "toolbar", "modal", "panel"];
|
|
96737
96693
|
function validatePluginName(name) {
|
|
@@ -96858,12 +96814,12 @@ async function pluginInitCommand(name, options) {
|
|
|
96858
96814
|
}
|
|
96859
96815
|
return;
|
|
96860
96816
|
}
|
|
96861
|
-
const targetDir =
|
|
96817
|
+
const targetDir = path35.resolve("plugins", name);
|
|
96862
96818
|
const filesCreated = [];
|
|
96863
96819
|
const filesSkipped = [];
|
|
96864
96820
|
for (const [relativePath, content] of Object.entries(files)) {
|
|
96865
|
-
const absPath =
|
|
96866
|
-
const dir =
|
|
96821
|
+
const absPath = path35.join(targetDir, relativePath);
|
|
96822
|
+
const dir = path35.dirname(absPath);
|
|
96867
96823
|
fs35.mkdirSync(dir, { recursive: true });
|
|
96868
96824
|
if (fs35.existsSync(absPath) && !force) {
|
|
96869
96825
|
filesSkipped.push(relativePath);
|
|
@@ -96889,7 +96845,7 @@ async function pluginInitCommand(name, options) {
|
|
|
96889
96845
|
// src/cli/commands/migrate.ts
|
|
96890
96846
|
init_esm5();
|
|
96891
96847
|
import * as fs36 from "fs";
|
|
96892
|
-
import * as
|
|
96848
|
+
import * as path36 from "path";
|
|
96893
96849
|
async function migrateCommand(globPattern, options = {}) {
|
|
96894
96850
|
const { dryRun = false, diff = false } = options;
|
|
96895
96851
|
const files = globSync(globPattern, { ignore: ["**/node_modules/**", "**/*.generated.ts"] });
|
|
@@ -96905,7 +96861,7 @@ async function migrateCommand(globPattern, options = {}) {
|
|
|
96905
96861
|
let skippedCount = 0;
|
|
96906
96862
|
let errorCount = 0;
|
|
96907
96863
|
for (const file of files) {
|
|
96908
|
-
const filePath =
|
|
96864
|
+
const filePath = path36.resolve(file);
|
|
96909
96865
|
try {
|
|
96910
96866
|
const sourceCode = fs36.readFileSync(filePath, "utf8");
|
|
96911
96867
|
const parseResult = await parseWorkflow(filePath);
|
|
@@ -96957,7 +96913,7 @@ ${file}:`);
|
|
|
96957
96913
|
}
|
|
96958
96914
|
|
|
96959
96915
|
// src/cli/commands/changelog.ts
|
|
96960
|
-
import { execSync as
|
|
96916
|
+
import { execSync as execSync4 } from "child_process";
|
|
96961
96917
|
var CATEGORIES2 = [
|
|
96962
96918
|
{ name: "Grammar", match: (f) => /parser|chevrotain|grammar/.test(f) },
|
|
96963
96919
|
{ name: "Code Generation", match: (f) => /generator|body-generator|generate/.test(f) },
|
|
@@ -96984,7 +96940,7 @@ function getGitRange(options) {
|
|
|
96984
96940
|
}
|
|
96985
96941
|
if (options.lastTag) {
|
|
96986
96942
|
try {
|
|
96987
|
-
const lastTag =
|
|
96943
|
+
const lastTag = execSync4("git describe --tags --abbrev=0", {
|
|
96988
96944
|
encoding: "utf8"
|
|
96989
96945
|
}).trim();
|
|
96990
96946
|
return `${lastTag}..HEAD`;
|
|
@@ -97009,7 +96965,7 @@ function getCommits(rangeArg) {
|
|
|
97009
96965
|
} else {
|
|
97010
96966
|
logCmd = `git log ${rangeArg} --format="%H %s" --no-merges`;
|
|
97011
96967
|
}
|
|
97012
|
-
const logOutput =
|
|
96968
|
+
const logOutput = execSync4(logCmd, { encoding: "utf8" }).trim();
|
|
97013
96969
|
if (!logOutput) {
|
|
97014
96970
|
return [];
|
|
97015
96971
|
}
|
|
@@ -97021,7 +96977,7 @@ function getCommits(rangeArg) {
|
|
|
97021
96977
|
const message = line.slice(spaceIdx + 1);
|
|
97022
96978
|
let files;
|
|
97023
96979
|
try {
|
|
97024
|
-
const filesOutput =
|
|
96980
|
+
const filesOutput = execSync4(`git diff-tree --no-commit-id --name-only -r ${hash}`, {
|
|
97025
96981
|
encoding: "utf8"
|
|
97026
96982
|
}).trim();
|
|
97027
96983
|
files = filesOutput ? filesOutput.split(/\r?\n/) : [];
|
|
@@ -97073,13 +97029,13 @@ async function changelogCommand(options = {}) {
|
|
|
97073
97029
|
// src/cli/commands/strip.ts
|
|
97074
97030
|
init_esm5();
|
|
97075
97031
|
import * as fs37 from "fs";
|
|
97076
|
-
import * as
|
|
97032
|
+
import * as path37 from "path";
|
|
97077
97033
|
async function stripCommand(input, options = {}) {
|
|
97078
97034
|
const { output, dryRun = false, verbose = false } = options;
|
|
97079
97035
|
let pattern = input;
|
|
97080
97036
|
try {
|
|
97081
97037
|
if (fs37.existsSync(input) && fs37.statSync(input).isDirectory()) {
|
|
97082
|
-
pattern =
|
|
97038
|
+
pattern = path37.join(input, "**/*.ts");
|
|
97083
97039
|
}
|
|
97084
97040
|
} catch {
|
|
97085
97041
|
}
|
|
@@ -97102,24 +97058,24 @@ async function stripCommand(input, options = {}) {
|
|
|
97102
97058
|
if (!hasInPlaceMarkers(content)) {
|
|
97103
97059
|
skipped++;
|
|
97104
97060
|
if (verbose) {
|
|
97105
|
-
logger.info(`Skipped (no markers): ${
|
|
97061
|
+
logger.info(`Skipped (no markers): ${path37.relative(process.cwd(), filePath)}`);
|
|
97106
97062
|
}
|
|
97107
97063
|
continue;
|
|
97108
97064
|
}
|
|
97109
97065
|
const result = stripGeneratedSections(content);
|
|
97110
97066
|
if (dryRun) {
|
|
97111
|
-
logger.info(`Would strip: ${
|
|
97067
|
+
logger.info(`Would strip: ${path37.relative(process.cwd(), filePath)}`);
|
|
97112
97068
|
stripped++;
|
|
97113
97069
|
continue;
|
|
97114
97070
|
}
|
|
97115
|
-
const outPath = output ?
|
|
97071
|
+
const outPath = output ? path37.join(path37.resolve(output), path37.basename(filePath)) : filePath;
|
|
97116
97072
|
if (output) {
|
|
97117
|
-
fs37.mkdirSync(
|
|
97073
|
+
fs37.mkdirSync(path37.dirname(outPath), { recursive: true });
|
|
97118
97074
|
}
|
|
97119
97075
|
fs37.writeFileSync(outPath, result);
|
|
97120
97076
|
stripped++;
|
|
97121
97077
|
if (verbose) {
|
|
97122
|
-
logger.success(`Stripped: ${
|
|
97078
|
+
logger.success(`Stripped: ${path37.relative(process.cwd(), outPath)}`);
|
|
97123
97079
|
}
|
|
97124
97080
|
}
|
|
97125
97081
|
logger.success(`${stripped} file${stripped !== 1 ? "s" : ""} stripped, ${skipped} skipped`);
|
|
@@ -97200,7 +97156,7 @@ async function docsSearchCommand(query, options) {
|
|
|
97200
97156
|
|
|
97201
97157
|
// src/cli/commands/status.ts
|
|
97202
97158
|
import * as fs38 from "fs";
|
|
97203
|
-
import * as
|
|
97159
|
+
import * as path38 from "path";
|
|
97204
97160
|
init_validator();
|
|
97205
97161
|
function formatPortList(ports) {
|
|
97206
97162
|
return Object.entries(ports).filter(([name]) => name !== "execute" && name !== "onSuccess" && name !== "onFailure").map(([name, port]) => `${name}(${port.dataType.toLowerCase()})`);
|
|
@@ -97208,7 +97164,7 @@ function formatPortList(ports) {
|
|
|
97208
97164
|
async function statusCommand(input, options = {}) {
|
|
97209
97165
|
const { workflowName, json: json2 = false } = options;
|
|
97210
97166
|
try {
|
|
97211
|
-
const filePath =
|
|
97167
|
+
const filePath = path38.resolve(input);
|
|
97212
97168
|
if (!fs38.existsSync(filePath)) {
|
|
97213
97169
|
if (json2) {
|
|
97214
97170
|
console.log(JSON.stringify({ error: `File not found: ${input}` }));
|
|
@@ -97300,7 +97256,7 @@ async function statusCommand(input, options = {}) {
|
|
|
97300
97256
|
|
|
97301
97257
|
// src/cli/commands/implement.ts
|
|
97302
97258
|
import * as fs39 from "fs";
|
|
97303
|
-
import * as
|
|
97259
|
+
import * as path39 from "path";
|
|
97304
97260
|
function findDeclareFunction2(source, functionName) {
|
|
97305
97261
|
const lines = source.split("\n");
|
|
97306
97262
|
const escaped = functionName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -97322,7 +97278,7 @@ function findDeclareFunction2(source, functionName) {
|
|
|
97322
97278
|
async function implementCommand(input, nodeName, options = {}) {
|
|
97323
97279
|
const { workflowName, preview = false } = options;
|
|
97324
97280
|
try {
|
|
97325
|
-
const filePath =
|
|
97281
|
+
const filePath = path39.resolve(input);
|
|
97326
97282
|
if (!fs39.existsSync(filePath)) {
|
|
97327
97283
|
logger.error(`File not found: ${input}`);
|
|
97328
97284
|
process.exit(1);
|
|
@@ -97369,7 +97325,7 @@ async function implementCommand(input, nodeName, options = {}) {
|
|
|
97369
97325
|
} else {
|
|
97370
97326
|
const updated = source.replace(found.match, replacement);
|
|
97371
97327
|
fs39.writeFileSync(filePath, updated, "utf8");
|
|
97372
|
-
logger.success(`Implemented ${stubNodeType.functionName} in ${
|
|
97328
|
+
logger.success(`Implemented ${stubNodeType.functionName} in ${path39.basename(filePath)}`);
|
|
97373
97329
|
}
|
|
97374
97330
|
} catch (error2) {
|
|
97375
97331
|
logger.error(`Implement failed: ${getErrorMessage(error2)}`);
|
|
@@ -97379,15 +97335,15 @@ async function implementCommand(input, nodeName, options = {}) {
|
|
|
97379
97335
|
|
|
97380
97336
|
// src/cli/commands/market.ts
|
|
97381
97337
|
import * as fs40 from "fs";
|
|
97382
|
-
import * as
|
|
97383
|
-
import { execSync as
|
|
97338
|
+
import * as path40 from "path";
|
|
97339
|
+
import { execSync as execSync5 } from "child_process";
|
|
97384
97340
|
async function marketInitCommand(name, options = {}) {
|
|
97385
97341
|
if (!name.startsWith("flowweaver-pack-")) {
|
|
97386
97342
|
const suggested = `flowweaver-pack-${name}`;
|
|
97387
97343
|
logger.warn(`Name should follow "flowweaver-pack-*" convention, using "${suggested}"`);
|
|
97388
97344
|
name = suggested;
|
|
97389
97345
|
}
|
|
97390
|
-
const targetDir =
|
|
97346
|
+
const targetDir = path40.resolve(name);
|
|
97391
97347
|
if (fs40.existsSync(targetDir)) {
|
|
97392
97348
|
const stat = fs40.statSync(targetDir);
|
|
97393
97349
|
if (stat.isDirectory()) {
|
|
@@ -97406,10 +97362,10 @@ async function marketInitCommand(name, options = {}) {
|
|
|
97406
97362
|
logger.newline();
|
|
97407
97363
|
const dirs = [
|
|
97408
97364
|
targetDir,
|
|
97409
|
-
|
|
97410
|
-
|
|
97411
|
-
|
|
97412
|
-
|
|
97365
|
+
path40.join(targetDir, "src"),
|
|
97366
|
+
path40.join(targetDir, "src", "node-types"),
|
|
97367
|
+
path40.join(targetDir, "src", "workflows"),
|
|
97368
|
+
path40.join(targetDir, "src", "patterns")
|
|
97413
97369
|
];
|
|
97414
97370
|
for (const dir of dirs) {
|
|
97415
97371
|
fs40.mkdirSync(dir, { recursive: true });
|
|
@@ -97444,7 +97400,7 @@ async function marketInitCommand(name, options = {}) {
|
|
|
97444
97400
|
files: ["dist", "flowweaver.manifest.json", "README.md", "LICENSE"]
|
|
97445
97401
|
};
|
|
97446
97402
|
fs40.writeFileSync(
|
|
97447
|
-
|
|
97403
|
+
path40.join(targetDir, "package.json"),
|
|
97448
97404
|
JSON.stringify(pkg, null, 2) + "\n"
|
|
97449
97405
|
);
|
|
97450
97406
|
const tsconfig = {
|
|
@@ -97463,7 +97419,7 @@ async function marketInitCommand(name, options = {}) {
|
|
|
97463
97419
|
exclude: ["node_modules", "dist"]
|
|
97464
97420
|
};
|
|
97465
97421
|
fs40.writeFileSync(
|
|
97466
|
-
|
|
97422
|
+
path40.join(targetDir, "tsconfig.json"),
|
|
97467
97423
|
JSON.stringify(tsconfig, null, 2) + "\n"
|
|
97468
97424
|
);
|
|
97469
97425
|
const sampleNodeType = `/**
|
|
@@ -97481,21 +97437,21 @@ export function sample(execute: () => void, data: string): { result: string } {
|
|
|
97481
97437
|
return { result: data.toUpperCase() };
|
|
97482
97438
|
}
|
|
97483
97439
|
`;
|
|
97484
|
-
fs40.writeFileSync(
|
|
97440
|
+
fs40.writeFileSync(path40.join(targetDir, "src", "node-types", "sample.ts"), sampleNodeType);
|
|
97485
97441
|
fs40.writeFileSync(
|
|
97486
|
-
|
|
97442
|
+
path40.join(targetDir, "src", "node-types", "index.ts"),
|
|
97487
97443
|
"export { sample } from './sample.js';\n"
|
|
97488
97444
|
);
|
|
97489
97445
|
fs40.writeFileSync(
|
|
97490
|
-
|
|
97446
|
+
path40.join(targetDir, "src", "workflows", "index.ts"),
|
|
97491
97447
|
"// Export workflows here\n"
|
|
97492
97448
|
);
|
|
97493
97449
|
fs40.writeFileSync(
|
|
97494
|
-
|
|
97450
|
+
path40.join(targetDir, "src", "patterns", "index.ts"),
|
|
97495
97451
|
"// Export patterns here\n"
|
|
97496
97452
|
);
|
|
97497
97453
|
fs40.writeFileSync(
|
|
97498
|
-
|
|
97454
|
+
path40.join(targetDir, "src", "index.ts"),
|
|
97499
97455
|
[
|
|
97500
97456
|
"export * from './node-types/index.js';",
|
|
97501
97457
|
"export * from './workflows/index.js';",
|
|
@@ -97528,9 +97484,9 @@ npm run pack # Generate flowweaver.manifest.json
|
|
|
97528
97484
|
npm publish # Publish to npm
|
|
97529
97485
|
\`\`\`
|
|
97530
97486
|
`;
|
|
97531
|
-
fs40.writeFileSync(
|
|
97487
|
+
fs40.writeFileSync(path40.join(targetDir, "README.md"), readme);
|
|
97532
97488
|
fs40.writeFileSync(
|
|
97533
|
-
|
|
97489
|
+
path40.join(targetDir, ".gitignore"),
|
|
97534
97490
|
["node_modules", "dist", "*.tgz", ""].join("\n")
|
|
97535
97491
|
);
|
|
97536
97492
|
logger.success("Created package.json");
|
|
@@ -97550,7 +97506,7 @@ npm publish # Publish to npm
|
|
|
97550
97506
|
logger.newline();
|
|
97551
97507
|
}
|
|
97552
97508
|
async function marketPackCommand(directory, options = {}) {
|
|
97553
|
-
const dir =
|
|
97509
|
+
const dir = path40.resolve(directory ?? ".");
|
|
97554
97510
|
const { json: json2 = false, verbose = false } = options;
|
|
97555
97511
|
if (!json2) {
|
|
97556
97512
|
logger.section("Packing Marketplace Package");
|
|
@@ -97589,28 +97545,28 @@ async function marketPackCommand(directory, options = {}) {
|
|
|
97589
97545
|
}
|
|
97590
97546
|
const outPath = writeManifest(dir, manifest);
|
|
97591
97547
|
logger.newline();
|
|
97592
|
-
logger.success(`Manifest written to ${
|
|
97548
|
+
logger.success(`Manifest written to ${path40.relative(dir, outPath)}`);
|
|
97593
97549
|
if (warnings.length > 0) {
|
|
97594
97550
|
logger.warn(`${warnings.length} warning(s) \u2014 consider fixing before publishing`);
|
|
97595
97551
|
}
|
|
97596
97552
|
logger.newline();
|
|
97597
97553
|
}
|
|
97598
97554
|
async function marketPublishCommand(directory, options = {}) {
|
|
97599
|
-
const dir =
|
|
97555
|
+
const dir = path40.resolve(directory ?? ".");
|
|
97600
97556
|
const { dryRun = false, tag } = options;
|
|
97601
97557
|
logger.section("Publishing Marketplace Package");
|
|
97602
97558
|
await marketPackCommand(dir, { json: false });
|
|
97603
|
-
if (!fs40.existsSync(
|
|
97559
|
+
if (!fs40.existsSync(path40.join(dir, "LICENSE"))) {
|
|
97604
97560
|
logger.warn("LICENSE file not found \u2014 consider adding one");
|
|
97605
97561
|
}
|
|
97606
|
-
const pkg = JSON.parse(fs40.readFileSync(
|
|
97562
|
+
const pkg = JSON.parse(fs40.readFileSync(path40.join(dir, "package.json"), "utf-8"));
|
|
97607
97563
|
logger.info(`Publishing ${pkg.name}@${pkg.version}`);
|
|
97608
97564
|
const npmArgs = ["publish"];
|
|
97609
97565
|
if (dryRun) npmArgs.push("--dry-run");
|
|
97610
97566
|
if (tag) npmArgs.push("--tag", tag);
|
|
97611
97567
|
try {
|
|
97612
97568
|
logger.newline();
|
|
97613
|
-
|
|
97569
|
+
execSync5(`npm ${npmArgs.join(" ")}`, { cwd: dir, stdio: "inherit" });
|
|
97614
97570
|
if (!dryRun) {
|
|
97615
97571
|
logger.newline();
|
|
97616
97572
|
logger.success(`Published ${pkg.name}@${pkg.version} to npm`);
|
|
@@ -97628,7 +97584,7 @@ async function marketInstallCommand(packageSpec, options = {}) {
|
|
|
97628
97584
|
logger.newline();
|
|
97629
97585
|
}
|
|
97630
97586
|
try {
|
|
97631
|
-
|
|
97587
|
+
execSync5(`npm install ${packageSpec}`, { stdio: json2 ? "pipe" : "inherit" });
|
|
97632
97588
|
} catch (err) {
|
|
97633
97589
|
if (json2) {
|
|
97634
97590
|
console.log(JSON.stringify({ success: false, error: getErrorMessage(err) }));
|
|
@@ -97638,7 +97594,7 @@ async function marketInstallCommand(packageSpec, options = {}) {
|
|
|
97638
97594
|
process.exit(1);
|
|
97639
97595
|
}
|
|
97640
97596
|
const packageName = resolvePackageName2(packageSpec);
|
|
97641
|
-
const manifest = readManifest(
|
|
97597
|
+
const manifest = readManifest(path40.join(process.cwd(), "node_modules", packageName));
|
|
97642
97598
|
if (json2) {
|
|
97643
97599
|
console.log(JSON.stringify({
|
|
97644
97600
|
success: true,
|
|
@@ -97722,7 +97678,7 @@ async function marketListCommand(options = {}) {
|
|
|
97722
97678
|
}
|
|
97723
97679
|
function resolvePackageName2(spec) {
|
|
97724
97680
|
if (spec.endsWith(".tgz") || spec.endsWith(".tar.gz")) {
|
|
97725
|
-
const base =
|
|
97681
|
+
const base = path40.basename(spec, spec.endsWith(".tar.gz") ? ".tar.gz" : ".tgz");
|
|
97726
97682
|
const match2 = base.match(/^(.+)-\d+\.\d+\.\d+/);
|
|
97727
97683
|
return match2 ? match2[1] : base;
|
|
97728
97684
|
}
|
|
@@ -97770,8 +97726,333 @@ function displayInstalledPackage(pkg) {
|
|
|
97770
97726
|
logger.newline();
|
|
97771
97727
|
}
|
|
97772
97728
|
|
|
97729
|
+
// src/cli/commands/mcp-setup.ts
|
|
97730
|
+
import { execSync as execSync6 } from "child_process";
|
|
97731
|
+
import * as fs41 from "fs";
|
|
97732
|
+
import * as path41 from "path";
|
|
97733
|
+
import * as os3 from "os";
|
|
97734
|
+
var MCP_COMMAND = "npx";
|
|
97735
|
+
var MCP_ARGS = ["@synergenius/flow-weaver@latest", "mcp-server", "--stdio"];
|
|
97736
|
+
var MCP_ENTRY = { command: MCP_COMMAND, args: [...MCP_ARGS] };
|
|
97737
|
+
function defaultDeps() {
|
|
97738
|
+
return {
|
|
97739
|
+
execCommand: async (cmd) => {
|
|
97740
|
+
try {
|
|
97741
|
+
const stdout = execSync6(cmd, { encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] });
|
|
97742
|
+
return { stdout: stdout.trim(), exitCode: 0 };
|
|
97743
|
+
} catch {
|
|
97744
|
+
return { stdout: "", exitCode: 1 };
|
|
97745
|
+
}
|
|
97746
|
+
},
|
|
97747
|
+
fileExists: async (filePath) => {
|
|
97748
|
+
try {
|
|
97749
|
+
await fs41.promises.access(filePath);
|
|
97750
|
+
return true;
|
|
97751
|
+
} catch {
|
|
97752
|
+
return false;
|
|
97753
|
+
}
|
|
97754
|
+
},
|
|
97755
|
+
readFile: async (filePath) => {
|
|
97756
|
+
try {
|
|
97757
|
+
return await fs41.promises.readFile(filePath, "utf8");
|
|
97758
|
+
} catch {
|
|
97759
|
+
return null;
|
|
97760
|
+
}
|
|
97761
|
+
},
|
|
97762
|
+
writeFile: async (filePath, content) => {
|
|
97763
|
+
await fs41.promises.writeFile(filePath, content, "utf8");
|
|
97764
|
+
},
|
|
97765
|
+
mkdir: async (dirPath) => {
|
|
97766
|
+
await fs41.promises.mkdir(dirPath, { recursive: true });
|
|
97767
|
+
},
|
|
97768
|
+
cwd: () => process.cwd(),
|
|
97769
|
+
homedir: () => os3.homedir(),
|
|
97770
|
+
log: (msg) => process.stdout.write(msg + "\n")
|
|
97771
|
+
};
|
|
97772
|
+
}
|
|
97773
|
+
function whichCmd(binary2) {
|
|
97774
|
+
return process.platform === "win32" ? `where ${binary2}` : `which ${binary2}`;
|
|
97775
|
+
}
|
|
97776
|
+
async function binaryExists(binary2, deps) {
|
|
97777
|
+
const result = await deps.execCommand(whichCmd(binary2));
|
|
97778
|
+
return result.exitCode === 0;
|
|
97779
|
+
}
|
|
97780
|
+
async function mergeJsonConfig(deps, filePath, rootKey) {
|
|
97781
|
+
const existing = await deps.readFile(filePath);
|
|
97782
|
+
if (existing === null) {
|
|
97783
|
+
const dir = path41.dirname(filePath);
|
|
97784
|
+
await deps.mkdir(dir);
|
|
97785
|
+
const config3 = { [rootKey]: { "flow-weaver": MCP_ENTRY } };
|
|
97786
|
+
await deps.writeFile(filePath, JSON.stringify(config3, null, 2) + "\n");
|
|
97787
|
+
return { action: "created", detail: `created ${filePath}` };
|
|
97788
|
+
}
|
|
97789
|
+
let config2;
|
|
97790
|
+
try {
|
|
97791
|
+
config2 = JSON.parse(existing);
|
|
97792
|
+
} catch {
|
|
97793
|
+
throw new Error(`invalid JSON in ${filePath}`);
|
|
97794
|
+
}
|
|
97795
|
+
if (!config2[rootKey] || typeof config2[rootKey] !== "object") {
|
|
97796
|
+
config2[rootKey] = {};
|
|
97797
|
+
}
|
|
97798
|
+
const servers = config2[rootKey];
|
|
97799
|
+
if (servers["flow-weaver"]) {
|
|
97800
|
+
return { action: "already-configured", detail: `already in ${filePath}` };
|
|
97801
|
+
}
|
|
97802
|
+
servers["flow-weaver"] = MCP_ENTRY;
|
|
97803
|
+
await deps.writeFile(filePath, JSON.stringify(config2, null, 2) + "\n");
|
|
97804
|
+
return { action: "added", detail: `added to ${filePath}` };
|
|
97805
|
+
}
|
|
97806
|
+
var TOOL_REGISTRY = [
|
|
97807
|
+
// Claude Code
|
|
97808
|
+
{
|
|
97809
|
+
id: "claude",
|
|
97810
|
+
displayName: "Claude Code",
|
|
97811
|
+
detect: (deps) => binaryExists("claude", deps),
|
|
97812
|
+
isConfigured: async (deps) => {
|
|
97813
|
+
const result = await deps.execCommand("claude mcp list");
|
|
97814
|
+
return result.exitCode === 0 && result.stdout.includes("flow-weaver");
|
|
97815
|
+
},
|
|
97816
|
+
configure: async (deps) => {
|
|
97817
|
+
const cmd = `claude mcp add --scope project flow-weaver -- ${MCP_COMMAND} ${MCP_ARGS.join(" ")}`;
|
|
97818
|
+
const result = await deps.execCommand(cmd);
|
|
97819
|
+
if (result.exitCode !== 0) {
|
|
97820
|
+
throw new Error("claude mcp add failed");
|
|
97821
|
+
}
|
|
97822
|
+
return "registered via claude mcp add";
|
|
97823
|
+
}
|
|
97824
|
+
},
|
|
97825
|
+
// Cursor
|
|
97826
|
+
{
|
|
97827
|
+
id: "cursor",
|
|
97828
|
+
displayName: "Cursor",
|
|
97829
|
+
detect: async (deps) => {
|
|
97830
|
+
const dirExists = await deps.fileExists(path41.join(deps.cwd(), ".cursor"));
|
|
97831
|
+
if (dirExists) return true;
|
|
97832
|
+
return binaryExists("cursor", deps);
|
|
97833
|
+
},
|
|
97834
|
+
isConfigured: async (deps) => {
|
|
97835
|
+
const filePath = path41.join(deps.cwd(), ".cursor", "mcp.json");
|
|
97836
|
+
const content = await deps.readFile(filePath);
|
|
97837
|
+
if (!content) return false;
|
|
97838
|
+
try {
|
|
97839
|
+
const config2 = JSON.parse(content);
|
|
97840
|
+
return !!config2?.mcpServers?.["flow-weaver"];
|
|
97841
|
+
} catch {
|
|
97842
|
+
return false;
|
|
97843
|
+
}
|
|
97844
|
+
},
|
|
97845
|
+
configure: async (deps) => {
|
|
97846
|
+
const filePath = path41.join(deps.cwd(), ".cursor", "mcp.json");
|
|
97847
|
+
const result = await mergeJsonConfig(deps, filePath, "mcpServers");
|
|
97848
|
+
return result.detail;
|
|
97849
|
+
}
|
|
97850
|
+
},
|
|
97851
|
+
// VS Code Copilot
|
|
97852
|
+
{
|
|
97853
|
+
id: "vscode",
|
|
97854
|
+
displayName: "VS Code Copilot",
|
|
97855
|
+
detect: (deps) => binaryExists("code", deps),
|
|
97856
|
+
isConfigured: async (deps) => {
|
|
97857
|
+
const filePath = path41.join(deps.cwd(), ".vscode", "mcp.json");
|
|
97858
|
+
const content = await deps.readFile(filePath);
|
|
97859
|
+
if (!content) return false;
|
|
97860
|
+
try {
|
|
97861
|
+
const config2 = JSON.parse(content);
|
|
97862
|
+
return !!config2?.servers?.["flow-weaver"];
|
|
97863
|
+
} catch {
|
|
97864
|
+
return false;
|
|
97865
|
+
}
|
|
97866
|
+
},
|
|
97867
|
+
configure: async (deps) => {
|
|
97868
|
+
const filePath = path41.join(deps.cwd(), ".vscode", "mcp.json");
|
|
97869
|
+
const result = await mergeJsonConfig(deps, filePath, "servers");
|
|
97870
|
+
return result.detail;
|
|
97871
|
+
}
|
|
97872
|
+
},
|
|
97873
|
+
// Windsurf
|
|
97874
|
+
{
|
|
97875
|
+
id: "windsurf",
|
|
97876
|
+
displayName: "Windsurf",
|
|
97877
|
+
detect: async (deps) => {
|
|
97878
|
+
const configDir = path41.join(deps.homedir(), ".codeium", "windsurf");
|
|
97879
|
+
const dirExists = await deps.fileExists(configDir);
|
|
97880
|
+
if (dirExists) return true;
|
|
97881
|
+
return binaryExists("windsurf", deps);
|
|
97882
|
+
},
|
|
97883
|
+
isConfigured: async (deps) => {
|
|
97884
|
+
const filePath = path41.join(deps.homedir(), ".codeium", "windsurf", "mcp_config.json");
|
|
97885
|
+
const content = await deps.readFile(filePath);
|
|
97886
|
+
if (!content) return false;
|
|
97887
|
+
try {
|
|
97888
|
+
const config2 = JSON.parse(content);
|
|
97889
|
+
return !!config2?.mcpServers?.["flow-weaver"];
|
|
97890
|
+
} catch {
|
|
97891
|
+
return false;
|
|
97892
|
+
}
|
|
97893
|
+
},
|
|
97894
|
+
configure: async (deps) => {
|
|
97895
|
+
const filePath = path41.join(deps.homedir(), ".codeium", "windsurf", "mcp_config.json");
|
|
97896
|
+
const result = await mergeJsonConfig(deps, filePath, "mcpServers");
|
|
97897
|
+
return result.detail;
|
|
97898
|
+
}
|
|
97899
|
+
},
|
|
97900
|
+
// Codex (OpenAI)
|
|
97901
|
+
{
|
|
97902
|
+
id: "codex",
|
|
97903
|
+
displayName: "Codex",
|
|
97904
|
+
detect: (deps) => binaryExists("codex", deps),
|
|
97905
|
+
isConfigured: async (deps) => {
|
|
97906
|
+
const result = await deps.execCommand("codex mcp list");
|
|
97907
|
+
return result.exitCode === 0 && result.stdout.includes("flow-weaver");
|
|
97908
|
+
},
|
|
97909
|
+
configure: async (deps) => {
|
|
97910
|
+
const cmd = `codex mcp add flow-weaver -- ${MCP_COMMAND} ${MCP_ARGS.join(" ")}`;
|
|
97911
|
+
const result = await deps.execCommand(cmd);
|
|
97912
|
+
if (result.exitCode !== 0) {
|
|
97913
|
+
throw new Error("codex mcp add failed");
|
|
97914
|
+
}
|
|
97915
|
+
return "registered via codex mcp add";
|
|
97916
|
+
}
|
|
97917
|
+
},
|
|
97918
|
+
// OpenClaw
|
|
97919
|
+
{
|
|
97920
|
+
id: "openclaw",
|
|
97921
|
+
displayName: "OpenClaw",
|
|
97922
|
+
detect: async (deps) => {
|
|
97923
|
+
return deps.fileExists(path41.join(deps.cwd(), "openclaw.json"));
|
|
97924
|
+
},
|
|
97925
|
+
isConfigured: async (deps) => {
|
|
97926
|
+
const filePath = path41.join(deps.cwd(), "openclaw.json");
|
|
97927
|
+
const content = await deps.readFile(filePath);
|
|
97928
|
+
if (!content) return false;
|
|
97929
|
+
try {
|
|
97930
|
+
const config2 = JSON.parse(content);
|
|
97931
|
+
return !!config2?.mcpServers?.["flow-weaver"];
|
|
97932
|
+
} catch {
|
|
97933
|
+
return false;
|
|
97934
|
+
}
|
|
97935
|
+
},
|
|
97936
|
+
configure: async (deps) => {
|
|
97937
|
+
const filePath = path41.join(deps.cwd(), "openclaw.json");
|
|
97938
|
+
const result = await mergeJsonConfig(deps, filePath, "mcpServers");
|
|
97939
|
+
return result.detail;
|
|
97940
|
+
}
|
|
97941
|
+
}
|
|
97942
|
+
];
|
|
97943
|
+
async function detectTools(deps) {
|
|
97944
|
+
const results = await Promise.all(
|
|
97945
|
+
TOOL_REGISTRY.map(async (tool) => {
|
|
97946
|
+
const detected = await tool.detect(deps);
|
|
97947
|
+
const configured = detected ? await tool.isConfigured(deps) : false;
|
|
97948
|
+
return { id: tool.id, displayName: tool.displayName, detected, configured };
|
|
97949
|
+
})
|
|
97950
|
+
);
|
|
97951
|
+
return results;
|
|
97952
|
+
}
|
|
97953
|
+
async function configureTool(tool, deps) {
|
|
97954
|
+
try {
|
|
97955
|
+
const already = await tool.isConfigured(deps);
|
|
97956
|
+
if (already) {
|
|
97957
|
+
return { id: tool.id, displayName: tool.displayName, action: "already-configured", detail: "already configured" };
|
|
97958
|
+
}
|
|
97959
|
+
const detail = await tool.configure(deps);
|
|
97960
|
+
return { id: tool.id, displayName: tool.displayName, action: "configured", detail };
|
|
97961
|
+
} catch (err) {
|
|
97962
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
97963
|
+
return { id: tool.id, displayName: tool.displayName, action: "failed", detail: msg };
|
|
97964
|
+
}
|
|
97965
|
+
}
|
|
97966
|
+
async function mcpSetupCommand(options, deps) {
|
|
97967
|
+
const d = deps ?? defaultDeps();
|
|
97968
|
+
const detected = await detectTools(d);
|
|
97969
|
+
if (options.list) {
|
|
97970
|
+
d.log("");
|
|
97971
|
+
for (const t of detected) {
|
|
97972
|
+
const status = t.detected ? t.configured ? "detected, configured" : "detected" : "not found";
|
|
97973
|
+
const icon = t.detected ? t.configured ? "\u25CF" : "\u25CB" : "\xB7";
|
|
97974
|
+
d.log(` ${icon} ${t.displayName.padEnd(18)} ${status}`);
|
|
97975
|
+
}
|
|
97976
|
+
d.log("");
|
|
97977
|
+
return;
|
|
97978
|
+
}
|
|
97979
|
+
let toolIds;
|
|
97980
|
+
if (options.tool && options.tool.length > 0) {
|
|
97981
|
+
const valid = new Set(TOOL_REGISTRY.map((t) => t.id));
|
|
97982
|
+
for (const name of options.tool) {
|
|
97983
|
+
if (!valid.has(name)) {
|
|
97984
|
+
d.log(`Unknown tool: "${name}". Valid tools: ${[...valid].join(", ")}`);
|
|
97985
|
+
return;
|
|
97986
|
+
}
|
|
97987
|
+
}
|
|
97988
|
+
toolIds = options.tool;
|
|
97989
|
+
} else if (options.all) {
|
|
97990
|
+
toolIds = detected.filter((t) => t.detected).map((t) => t.id);
|
|
97991
|
+
} else if (isNonInteractive()) {
|
|
97992
|
+
toolIds = detected.filter((t) => t.detected).map((t) => t.id);
|
|
97993
|
+
} else {
|
|
97994
|
+
const detectedTools = detected.filter((t) => t.detected);
|
|
97995
|
+
if (detectedTools.length === 0) {
|
|
97996
|
+
d.log("No AI coding tools detected. You can specify tools manually with --tool.");
|
|
97997
|
+
return;
|
|
97998
|
+
}
|
|
97999
|
+
d.log("");
|
|
98000
|
+
d.log("Detected tools:");
|
|
98001
|
+
for (const t of detected) {
|
|
98002
|
+
const icon = t.detected ? "\u2713" : "\u2717";
|
|
98003
|
+
d.log(` ${icon} ${t.displayName}`);
|
|
98004
|
+
}
|
|
98005
|
+
d.log("");
|
|
98006
|
+
toolIds = [];
|
|
98007
|
+
try {
|
|
98008
|
+
for (const t of detectedTools) {
|
|
98009
|
+
if (t.configured) {
|
|
98010
|
+
d.log(` ${t.displayName}: already configured, skipping`);
|
|
98011
|
+
continue;
|
|
98012
|
+
}
|
|
98013
|
+
const yes = await dist_default6({
|
|
98014
|
+
message: `Configure ${t.displayName}?`,
|
|
98015
|
+
default: true
|
|
98016
|
+
});
|
|
98017
|
+
if (yes) toolIds.push(t.id);
|
|
98018
|
+
}
|
|
98019
|
+
} catch (err) {
|
|
98020
|
+
if (err instanceof ExitPromptError4) return;
|
|
98021
|
+
throw err;
|
|
98022
|
+
}
|
|
98023
|
+
d.log("");
|
|
98024
|
+
}
|
|
98025
|
+
if (toolIds.length === 0) {
|
|
98026
|
+
const anyDetected = detected.some((t) => t.detected);
|
|
98027
|
+
if (!anyDetected) {
|
|
98028
|
+
d.log("No AI coding tools detected. You can specify tools manually with --tool.");
|
|
98029
|
+
} else {
|
|
98030
|
+
d.log("No tools selected.");
|
|
98031
|
+
}
|
|
98032
|
+
return;
|
|
98033
|
+
}
|
|
98034
|
+
const toolMap = new Map(TOOL_REGISTRY.map((t) => [t.id, t]));
|
|
98035
|
+
const results = [];
|
|
98036
|
+
for (const id of toolIds) {
|
|
98037
|
+
const tool = toolMap.get(id);
|
|
98038
|
+
const result = await configureTool(tool, d);
|
|
98039
|
+
results.push(result);
|
|
98040
|
+
const icon = result.action === "configured" ? "\u2713" : result.action === "already-configured" ? "\u25CF" : "\u2717";
|
|
98041
|
+
d.log(`${icon} ${result.displayName}: ${result.detail}`);
|
|
98042
|
+
}
|
|
98043
|
+
const configured = results.filter((r) => r.action === "configured").length;
|
|
98044
|
+
const alreadyDone = results.filter((r) => r.action === "already-configured").length;
|
|
98045
|
+
const failed = results.filter((r) => r.action === "failed").length;
|
|
98046
|
+
const parts2 = [];
|
|
98047
|
+
if (configured > 0) parts2.push(`${configured} configured`);
|
|
98048
|
+
if (alreadyDone > 0) parts2.push(`${alreadyDone} already configured`);
|
|
98049
|
+
if (failed > 0) parts2.push(`${failed} failed`);
|
|
98050
|
+
d.log("");
|
|
98051
|
+
d.log(`Done. ${parts2.join(", ")}.`);
|
|
98052
|
+
}
|
|
98053
|
+
|
|
97773
98054
|
// src/cli/index.ts
|
|
97774
|
-
var version2 = true ? "0.10.
|
|
98055
|
+
var version2 = true ? "0.10.10" : "0.0.0-dev";
|
|
97775
98056
|
var program2 = new Command();
|
|
97776
98057
|
program2.name("flow-weaver").description("Flow Weaver Annotations - Compile and validate workflow files").version(version2, "-v, --version", "Output the current version");
|
|
97777
98058
|
program2.configureOutput({
|
|
@@ -97866,7 +98147,7 @@ program2.command("dev <input>").description("Watch, compile, and run workflow on
|
|
|
97866
98147
|
process.exit(1);
|
|
97867
98148
|
}
|
|
97868
98149
|
});
|
|
97869
|
-
program2.command("listen").description("Connect to
|
|
98150
|
+
program2.command("listen").description("Connect to Studio and stream integration events as JSON lines").option("-s, --server <url>", "Studio URL", DEFAULT_SERVER_URL).action(async (options) => {
|
|
97870
98151
|
try {
|
|
97871
98152
|
await listenCommand(options);
|
|
97872
98153
|
} catch (error2) {
|
|
@@ -97874,7 +98155,7 @@ program2.command("listen").description("Connect to the editor and stream integra
|
|
|
97874
98155
|
process.exit(1);
|
|
97875
98156
|
}
|
|
97876
98157
|
});
|
|
97877
|
-
program2.command("mcp-server").description("Start MCP server for Claude Code integration").option("-s, --server <url>", "
|
|
98158
|
+
program2.command("mcp-server").description("Start MCP server for Claude Code integration").option("-s, --server <url>", "Studio URL", DEFAULT_SERVER_URL).option("--stdio", "Run in MCP stdio mode (skip interactive registration)").action(async (options) => {
|
|
97878
98159
|
try {
|
|
97879
98160
|
await mcpServerCommand(options);
|
|
97880
98161
|
} catch (error2) {
|
|
@@ -97882,8 +98163,16 @@ program2.command("mcp-server").description("Start MCP server for Claude Code int
|
|
|
97882
98163
|
process.exit(1);
|
|
97883
98164
|
}
|
|
97884
98165
|
});
|
|
97885
|
-
|
|
97886
|
-
|
|
98166
|
+
program2.command("mcp-setup").description("Configure MCP server for AI coding tools (Claude, Cursor, VS Code, Windsurf, Codex, OpenClaw)").option("--tool <tools...>", "Specific tools to configure (claude, cursor, vscode, windsurf, codex, openclaw)").option("--all", "Configure all detected tools without prompting").option("--list", "List detected tools without configuring").action(async (options) => {
|
|
98167
|
+
try {
|
|
98168
|
+
await mcpSetupCommand(options);
|
|
98169
|
+
} catch (error2) {
|
|
98170
|
+
logger.error(`Command failed: ${getErrorMessage(error2)}`);
|
|
98171
|
+
process.exit(1);
|
|
98172
|
+
}
|
|
98173
|
+
});
|
|
98174
|
+
var uiCmd = program2.command("ui").description("Send commands to Studio");
|
|
98175
|
+
uiCmd.command("focus-node <nodeId>").description("Select and center a node in Studio").option("-s, --server <url>", "Studio URL", DEFAULT_SERVER_URL).action(async (nodeId, options) => {
|
|
97887
98176
|
try {
|
|
97888
98177
|
await uiFocusNode(nodeId, options);
|
|
97889
98178
|
} catch (error2) {
|
|
@@ -97891,7 +98180,7 @@ uiCmd.command("focus-node <nodeId>").description("Select and center a node in th
|
|
|
97891
98180
|
process.exit(1);
|
|
97892
98181
|
}
|
|
97893
98182
|
});
|
|
97894
|
-
uiCmd.command("add-node <nodeTypeName>").description("Add a node at viewport center").option("-s, --server <url>", "
|
|
98183
|
+
uiCmd.command("add-node <nodeTypeName>").description("Add a node at viewport center").option("-s, --server <url>", "Studio URL", DEFAULT_SERVER_URL).action(async (nodeTypeName, options) => {
|
|
97895
98184
|
try {
|
|
97896
98185
|
await uiAddNode(nodeTypeName, options);
|
|
97897
98186
|
} catch (error2) {
|
|
@@ -97899,7 +98188,7 @@ uiCmd.command("add-node <nodeTypeName>").description("Add a node at viewport cen
|
|
|
97899
98188
|
process.exit(1);
|
|
97900
98189
|
}
|
|
97901
98190
|
});
|
|
97902
|
-
uiCmd.command("open-workflow <filePath>").description("Open a workflow file in
|
|
98191
|
+
uiCmd.command("open-workflow <filePath>").description("Open a workflow file in Studio").option("-s, --server <url>", "Studio URL", DEFAULT_SERVER_URL).action(async (filePath, options) => {
|
|
97903
98192
|
try {
|
|
97904
98193
|
await uiOpenWorkflow(filePath, options);
|
|
97905
98194
|
} catch (error2) {
|
|
@@ -97907,7 +98196,7 @@ uiCmd.command("open-workflow <filePath>").description("Open a workflow file in t
|
|
|
97907
98196
|
process.exit(1);
|
|
97908
98197
|
}
|
|
97909
98198
|
});
|
|
97910
|
-
uiCmd.command("get-state").description("Return current workflow state from
|
|
98199
|
+
uiCmd.command("get-state").description("Return current workflow state from Studio").option("-s, --server <url>", "Studio URL", DEFAULT_SERVER_URL).action(async (options) => {
|
|
97911
98200
|
try {
|
|
97912
98201
|
await uiGetState(options);
|
|
97913
98202
|
} catch (error2) {
|
|
@@ -97915,7 +98204,7 @@ uiCmd.command("get-state").description("Return current workflow state from the e
|
|
|
97915
98204
|
process.exit(1);
|
|
97916
98205
|
}
|
|
97917
98206
|
});
|
|
97918
|
-
uiCmd.command("batch <json>").description("Execute a batch of commands with auto-snapshot rollback").option("-s, --server <url>", "
|
|
98207
|
+
uiCmd.command("batch <json>").description("Execute a batch of commands with auto-snapshot rollback").option("-s, --server <url>", "Studio URL", DEFAULT_SERVER_URL).action(async (json2, options) => {
|
|
97919
98208
|
try {
|
|
97920
98209
|
await uiBatch(json2, options);
|
|
97921
98210
|
} catch (error2) {
|