ScuttleBot

scuttlebot / tests / e2e / node_modules / playwright / lib / mcp / terminal / command.js
Source Blame History 56 lines
f7eb47b… lmata 1 "use strict";
f7eb47b… lmata 2 var __defProp = Object.defineProperty;
f7eb47b… lmata 3 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
f7eb47b… lmata 4 var __getOwnPropNames = Object.getOwnPropertyNames;
f7eb47b… lmata 5 var __hasOwnProp = Object.prototype.hasOwnProperty;
f7eb47b… lmata 6 var __export = (target, all) => {
f7eb47b… lmata 7 for (var name in all)
f7eb47b… lmata 8 __defProp(target, name, { get: all[name], enumerable: true });
f7eb47b… lmata 9 };
f7eb47b… lmata 10 var __copyProps = (to, from, except, desc) => {
f7eb47b… lmata 11 if (from && typeof from === "object" || typeof from === "function") {
f7eb47b… lmata 12 for (let key of __getOwnPropNames(from))
f7eb47b… lmata 13 if (!__hasOwnProp.call(to, key) && key !== except)
f7eb47b… lmata 14 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
f7eb47b… lmata 15 }
f7eb47b… lmata 16 return to;
f7eb47b… lmata 17 };
f7eb47b… lmata 18 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
f7eb47b… lmata 19 var command_exports = {};
f7eb47b… lmata 20 __export(command_exports, {
f7eb47b… lmata 21 declareCommand: () => declareCommand,
f7eb47b… lmata 22 parseCommand: () => parseCommand
f7eb47b… lmata 23 });
f7eb47b… lmata 24 module.exports = __toCommonJS(command_exports);
f7eb47b… lmata 25 function declareCommand(command) {
f7eb47b… lmata 26 return command;
f7eb47b… lmata 27 }
f7eb47b… lmata 28 function parseCommand(command, args) {
f7eb47b… lmata 29 const shape = command.args ? command.args.shape : {};
f7eb47b… lmata 30 const argv = args["_"];
f7eb47b… lmata 31 const options = command.options?.parse({ ...args, _: void 0 }) ?? {};
f7eb47b… lmata 32 const argsObject = {};
f7eb47b… lmata 33 let i = 0;
f7eb47b… lmata 34 for (const name of Object.keys(shape))
f7eb47b… lmata 35 argsObject[name] = argv[++i];
f7eb47b… lmata 36 let parsedArgsObject = {};
f7eb47b… lmata 37 try {
f7eb47b… lmata 38 parsedArgsObject = command.args?.parse(argsObject) ?? {};
f7eb47b… lmata 39 } catch (e) {
f7eb47b… lmata 40 throw new Error(formatZodError(e));
f7eb47b… lmata 41 }
f7eb47b… lmata 42 const toolName = typeof command.toolName === "function" ? command.toolName(parsedArgsObject, options) : command.toolName;
f7eb47b… lmata 43 const toolParams = command.toolParams(parsedArgsObject, options);
f7eb47b… lmata 44 return { toolName, toolParams };
f7eb47b… lmata 45 }
f7eb47b… lmata 46 function formatZodError(error) {
f7eb47b… lmata 47 const issue = error.issues[0];
f7eb47b… lmata 48 if (issue.code === "invalid_type")
f7eb47b… lmata 49 return `${issue.message} in <${issue.path.join(".")}>`;
f7eb47b… lmata 50 return error.issues.map((i) => i.message).join("\n");
f7eb47b… lmata 51 }
f7eb47b… lmata 52 // Annotate the CommonJS export names for ESM import in node:
f7eb47b… lmata 53 0 && (module.exports = {
f7eb47b… lmata 54 declareCommand,
f7eb47b… lmata 55 parseCommand
f7eb47b… lmata 56 });

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button