@volter/tabnode 0.5.26 → 0.5.28
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/assets/{runtime-worker-VIeZbbDr.js → runtime-worker-C6ulimZ4.js} +75 -19
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +109 -597
- package/dist/port-bridge-CixAESwA.js +655 -0
- package/dist/port-bridge.d.ts +175 -0
- package/dist/port-bridge.mjs +6 -0
- package/dist/server-bridge.d.ts +9 -130
- package/package.json +5 -1
- package/src/index.ts +1 -0
- package/src/port-bridge.ts +791 -0
- package/src/runtime.ts +63 -6
- package/src/server-bridge.ts +22 -664
- package/src/shims/child_process.ts +31 -6
|
@@ -1143,7 +1143,26 @@ function readPackageJson(cwd: string): { pkgJson: PackageJson; error?: undefined
|
|
|
1143
1143
|
* Handle `npm run [script]` — execute a script from package.json
|
|
1144
1144
|
*/
|
|
1145
1145
|
async function handleNpmRun(args: string[], ctx: CommandContext): Promise<JustBashExecResult> {
|
|
1146
|
-
|
|
1146
|
+
// npm's own options come before the script's name and are npm's
|
|
1147
|
+
// (`npm run --silent vgai -- mcp .`, as a project's `.mcp.json` launches its
|
|
1148
|
+
// server); what follows the name goes to the script, everything after `--`
|
|
1149
|
+
// untouched. The name used to be `args[0]`, so `--silent` was looked up as a
|
|
1150
|
+
// script, and the script's own arguments were dropped.
|
|
1151
|
+
let scriptName: string | undefined;
|
|
1152
|
+
let silent = false;
|
|
1153
|
+
let ifPresent = false;
|
|
1154
|
+
const passed: string[] = [];
|
|
1155
|
+
for (let index = 0; index < args.length; index++) {
|
|
1156
|
+
const arg = args[index]!;
|
|
1157
|
+
if (arg === '--') { if (scriptName !== undefined) passed.push(...args.slice(index + 1)); break; }
|
|
1158
|
+
if (arg.startsWith('-') && arg !== '-') {
|
|
1159
|
+
if (arg === '--silent' || arg === '-s' || arg === '--quiet' || arg === '-q' || arg === '--loglevel=silent') silent = true;
|
|
1160
|
+
else if (arg === '--if-present') ifPresent = true;
|
|
1161
|
+
continue;
|
|
1162
|
+
}
|
|
1163
|
+
if (scriptName === undefined) scriptName = arg;
|
|
1164
|
+
else passed.push(arg);
|
|
1165
|
+
}
|
|
1147
1166
|
|
|
1148
1167
|
// "npm run" with no script name: list available scripts
|
|
1149
1168
|
if (!scriptName) {
|
|
@@ -1158,6 +1177,7 @@ async function handleNpmRun(args: string[], ctx: CommandContext): Promise<JustBa
|
|
|
1158
1177
|
const scriptCommand = scripts[scriptName];
|
|
1159
1178
|
|
|
1160
1179
|
if (!scriptCommand) {
|
|
1180
|
+
if (ifPresent) return { stdout: '', stderr: '', exitCode: 0 };
|
|
1161
1181
|
const available = Object.keys(scripts);
|
|
1162
1182
|
let msg = `npm ERR! Missing script: "${scriptName}"\n`;
|
|
1163
1183
|
if (available.length > 0) {
|
|
@@ -1193,7 +1213,7 @@ async function handleNpmRun(args: string[], ctx: CommandContext): Promise<JustBa
|
|
|
1193
1213
|
// Run pre<script> if it exists
|
|
1194
1214
|
const preScript = scripts[`pre${scriptName}`];
|
|
1195
1215
|
if (preScript) {
|
|
1196
|
-
allStderr += `\n> ${label} pre${scriptName}\n> ${preScript}\n\n`;
|
|
1216
|
+
if (!silent) allStderr += `\n> ${label} pre${scriptName}\n> ${preScript}\n\n`;
|
|
1197
1217
|
const preResult = await ctx.exec(preScript, { cwd: ctx.cwd, env: npmEnv });
|
|
1198
1218
|
allStdout += preResult.stdout;
|
|
1199
1219
|
allStderr += preResult.stderr;
|
|
@@ -1202,9 +1222,14 @@ async function handleNpmRun(args: string[], ctx: CommandContext): Promise<JustBa
|
|
|
1202
1222
|
}
|
|
1203
1223
|
}
|
|
1204
1224
|
|
|
1205
|
-
// Run the main script
|
|
1206
|
-
|
|
1207
|
-
|
|
1225
|
+
// Run the main script, with the arguments npm passes it, each quoted.
|
|
1226
|
+
const command = passed.length > 0
|
|
1227
|
+
? `${scriptCommand} ${passed.map((arg) => /^[\w@%+=:,./-]+$/.test(arg) ? arg : `'${arg.replace(/'/g, `'\\''`)}'`).join(' ')}`
|
|
1228
|
+
: scriptCommand;
|
|
1229
|
+
if (!silent) allStderr += `\n> ${label} ${scriptName}\n> ${command}\n\n`;
|
|
1230
|
+
// The script reads npm's standard input: a `.mcp.json` server launched as
|
|
1231
|
+
// `npm run … -- serve` speaks JSON-RPC on it.
|
|
1232
|
+
const mainResult = await ctx.exec(command, { cwd: ctx.cwd, env: npmEnv, ...(typeof ctx.stdin === 'string' ? { stdin: ctx.stdin } : {}) });
|
|
1208
1233
|
allStdout += mainResult.stdout;
|
|
1209
1234
|
allStderr += mainResult.stderr;
|
|
1210
1235
|
|
|
@@ -1215,7 +1240,7 @@ async function handleNpmRun(args: string[], ctx: CommandContext): Promise<JustBa
|
|
|
1215
1240
|
// Run post<script> if it exists
|
|
1216
1241
|
const postScript = scripts[`post${scriptName}`];
|
|
1217
1242
|
if (postScript) {
|
|
1218
|
-
allStderr += `\n> ${label} post${scriptName}\n> ${postScript}\n\n`;
|
|
1243
|
+
if (!silent) allStderr += `\n> ${label} post${scriptName}\n> ${postScript}\n\n`;
|
|
1219
1244
|
const postResult = await ctx.exec(postScript, { cwd: ctx.cwd, env: npmEnv });
|
|
1220
1245
|
allStdout += postResult.stdout;
|
|
1221
1246
|
allStderr += postResult.stderr;
|