fast-cxt-mcp 1.1.2 → 1.1.3
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/package.json +1 -1
- package/src/executor.mjs +18 -10
package/package.json
CHANGED
package/src/executor.mjs
CHANGED
|
@@ -409,6 +409,9 @@ export class ToolExecutor {
|
|
|
409
409
|
* @returns {Promise<string>}
|
|
410
410
|
*/
|
|
411
411
|
async execCommandAsync(cmd) {
|
|
412
|
+
if (!cmd || typeof cmd !== "object") {
|
|
413
|
+
return "Error: missing or invalid command";
|
|
414
|
+
}
|
|
412
415
|
const t = cmd.type || "";
|
|
413
416
|
switch (t) {
|
|
414
417
|
case "rg":
|
|
@@ -432,6 +435,9 @@ export class ToolExecutor {
|
|
|
432
435
|
* @returns {string}
|
|
433
436
|
*/
|
|
434
437
|
execCommand(cmd) {
|
|
438
|
+
if (!cmd || typeof cmd !== "object") {
|
|
439
|
+
return "Error: missing or invalid command";
|
|
440
|
+
}
|
|
435
441
|
const t = cmd.type || "";
|
|
436
442
|
switch (t) {
|
|
437
443
|
case "rg":
|
|
@@ -455,13 +461,14 @@ export class ToolExecutor {
|
|
|
455
461
|
* @returns {Promise<string>}
|
|
456
462
|
*/
|
|
457
463
|
async execToolCallAsync(args) {
|
|
464
|
+
if (!args || typeof args !== "object") {
|
|
465
|
+
return "Error: missing or invalid tool args";
|
|
466
|
+
}
|
|
458
467
|
const keys = Object.keys(args).filter((k) => k.startsWith("command")).sort();
|
|
459
|
-
const tasks = keys
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
return `<${key}_result>\n${output}\n</${key}_result>`;
|
|
464
|
-
});
|
|
468
|
+
const tasks = keys.map(async (key) => {
|
|
469
|
+
const output = await this.execCommandAsync(args[key]);
|
|
470
|
+
return `<${key}_result>\n${output}\n</${key}_result>`;
|
|
471
|
+
});
|
|
465
472
|
const results = await Promise.all(tasks);
|
|
466
473
|
return results.join("");
|
|
467
474
|
}
|
|
@@ -473,12 +480,13 @@ export class ToolExecutor {
|
|
|
473
480
|
*/
|
|
474
481
|
execToolCall(args) {
|
|
475
482
|
const parts = [];
|
|
483
|
+
if (!args || typeof args !== "object") {
|
|
484
|
+
return "Error: missing or invalid tool args";
|
|
485
|
+
}
|
|
476
486
|
const keys = Object.keys(args).filter((k) => k.startsWith("command")).sort();
|
|
477
487
|
for (const key of keys) {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
parts.push(`<${key}_result>\n${output}\n</${key}_result>`);
|
|
481
|
-
}
|
|
488
|
+
const output = this.execCommand(args[key]);
|
|
489
|
+
parts.push(`<${key}_result>\n${output}\n</${key}_result>`);
|
|
482
490
|
}
|
|
483
491
|
return parts.join("");
|
|
484
492
|
}
|