@mcpjam/inspector 3.12.9 → 3.14.0

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.
Files changed (56) hide show
  1. package/bin/runtime-profile.mjs +774 -0
  2. package/bin/start.js +138 -19
  3. package/dist/client/assets/OAuthDesktopReturnNotice-BZEaGzn6.css +2 -0
  4. package/dist/client/assets/{OAuthDesktopReturnNotice-DlTJhJwy.js → OAuthDesktopReturnNotice-D7d-faB1.js} +2 -2
  5. package/dist/client/assets/{app-bootstrap-BtbHLWDU.js → app-bootstrap-BtDjj9nz.js} +370 -387
  6. package/dist/client/assets/{button-12hqsTUk.js → button-B99pZFz_.js} +2 -2
  7. package/dist/client/assets/chunk-D32TOXHM-Bcyg0ZVj.js +160 -0
  8. package/dist/client/assets/dead-clicks-autocapture-CnUHv5CB.js +3 -0
  9. package/dist/client/assets/error-reporting-BohBwcQQ.js +120 -0
  10. package/dist/client/assets/{error-reporting-D3byeSLw.js → error-reporting-p6G1ojum.js} +1 -1
  11. package/dist/client/assets/{exception-autocapture-CzpTtsxv.js → exception-autocapture-Q-isBTHp.js} +4 -4
  12. package/dist/client/assets/{failed-request-tracker-CmHxaDPF.js → failed-request-tracker-BBJW8izb.js} +2 -2
  13. package/dist/client/assets/highlighted-body-KQOG7T2V-zsXWRnSM.js +3 -0
  14. package/dist/client/assets/{index-C0SfPmai.js → index-C9oFRqoK.js} +3 -3
  15. package/dist/client/assets/{jszip.min-BmAHHtmZ.js → jszip.min-C86zG41a.js} +2 -2
  16. package/dist/client/assets/mermaid-MCJ5UELQ-DAW4LYwz.js +1 -0
  17. package/dist/client/assets/posthog-recorder-trUd0BXy.js +110 -0
  18. package/dist/client/assets/{preload-helper-B22rzauv.js → preload-helper-Buauuydw.js} +2 -2
  19. package/dist/client/assets/{react-BzkNdoI5.js → react-CZb-kDOs.js} +2 -2
  20. package/dist/client/assets/{rolldown-runtime-BNuWddGb.js → rolldown-runtime-Bkua2_Tb.js} +1 -1
  21. package/dist/client/assets/surveys-BISK_WOT.js +3 -0
  22. package/dist/client/assets/trace-timeline-CRewsP1E.js +71 -0
  23. package/dist/client/assets/{trace-timeline-Bg58ukyI.js → trace-timeline-D-DWE-sO.js} +1 -1
  24. package/dist/client/assets/{web-vitals-D4bU8W1t.js → web-vitals-DqmZ9w02.js} +2 -2
  25. package/dist/client/index.html +8 -8
  26. package/dist/server/authorization-MA42CNYT.js +22 -0
  27. package/dist/server/chunk-7M3XVZCQ.js +381 -0
  28. package/dist/server/{chunk-SH24KJBI.js → chunk-7ZIR7SX7.js} +17 -45
  29. package/dist/server/chunk-C47PTIDS.js +487 -0
  30. package/dist/server/chunk-DHRTCKJA.js +3979 -0
  31. package/dist/server/chunk-HJTKF2X6.js +45 -0
  32. package/dist/server/{chunk-DGAFFBDM.js → chunk-KNO4KZJF.js} +728 -682
  33. package/dist/server/{chunk-4PYR7GMQ.js → chunk-RWFTW2EW.js} +7 -5
  34. package/dist/server/chunk-SDWJSPSI.js +252 -0
  35. package/dist/server/chunk-VFRLMHOC.js +33 -0
  36. package/dist/server/chunk-XSQ2GC45.js +438 -0
  37. package/dist/server/chunk-YQ2BTE46.js +88 -0
  38. package/dist/server/{consent-lifetime-M7PS6RUU.js → consent-lifetime-OXQM37RV.js} +4 -3
  39. package/dist/server/grants-UVE62NGN.js +37 -0
  40. package/dist/server/harness-install-cli.js +259 -7
  41. package/dist/server/index.js +14252 -12005
  42. package/dist/server/local-turn-XSUGEKTL.js +19 -0
  43. package/dist/server/runtime-health-TCF3ZEKS.js +28 -0
  44. package/dist/server/runtime-lifecycle-YQ3KWDLJ.js +53 -0
  45. package/package.json +62 -59
  46. package/dist/client/assets/OAuthDesktopReturnNotice-FnFv52Ym.css +0 -2
  47. package/dist/client/assets/chunk-YOKDWASO--Bd-6XAf.js +0 -145
  48. package/dist/client/assets/dead-clicks-autocapture-RCao2exY.js +0 -3
  49. package/dist/client/assets/error-reporting-StyhxjHz.js +0 -102
  50. package/dist/client/assets/highlighted-body-KPVGNVTW-BweERQbm.js +0 -3
  51. package/dist/client/assets/mermaid-HWGCJPDP-C6s_jIuz.js +0 -1
  52. package/dist/client/assets/posthog-recorder-wc41pimR.js +0 -110
  53. package/dist/client/assets/surveys-D-NcCeqw.js +0 -3
  54. package/dist/client/assets/trace-timeline-CxoCCEiW.js +0 -137
  55. package/dist/server/chunk-WZVZ6LQX.js +0 -2876
  56. package/dist/server/local-turn-ZWMMQGV3.js +0 -12
package/bin/start.js CHANGED
@@ -5,7 +5,7 @@ import { spawn } from "child_process";
5
5
  import { fileURLToPath, pathToFileURL } from "url";
6
6
  import { createServer, createConnection } from "net";
7
7
  import { execSync } from "child_process";
8
- import { existsSync, readFileSync } from "fs";
8
+ import { existsSync, readFileSync, writeFileSync } from "fs";
9
9
  import open from "open";
10
10
  import {
11
11
  createLaunchToken,
@@ -14,6 +14,7 @@ import {
14
14
  networkAccessLinks,
15
15
  } from "./access-link.mjs";
16
16
  import { launchWorkspaceCandidate } from "./launch-workspace.mjs";
17
+ import { computeInstanceEnv } from "./runtime-profile.mjs";
17
18
 
18
19
  const __dirname = dirname(fileURLToPath(import.meta.url));
19
20
 
@@ -435,19 +436,56 @@ async function setupOllamaInSingleTerminal(model) {
435
436
  }
436
437
 
437
438
  /**
438
- * `mcpjam-inspector harness install` — download and verify the local-harness
439
- * runtime pack, then exit.
439
+ * `mcpjam-inspector harness <install|status|doctor|repair>` — the local-harness
440
+ * runtime, from a terminal.
440
441
  *
441
- * A subcommand rather than a flag on the server, and handled before the server
442
- * spawn, because installing a 515 MB agent runtime is a thing somebody asks
443
- * for and watches finish. Nothing about starting the Inspector installs it.
442
+ * install [--harness <id>] [--from <archive>] download (or, with --from,
443
+ * pre-provision from a local signed archive, no network) and verify
444
+ * status [--harness <id>] the selected runtime, as JSON
445
+ * doctor [--harness <id>] [--json] [--verify] [--export <file>]
446
+ * what runs, what is installed, the last failure and its stage, disk,
447
+ * proxy, update policy, and the repair to run; --export writes it
448
+ * redacted (no home path, no credential) for a support ticket
449
+ * repair [--harness <id>] [--from <archive>] re-verify, reinstall if
450
+ * corrupt, clear staging, re-probe an unhealthy runtime
451
+ *
452
+ * Subcommands rather than server flags, and handled before the server spawn:
453
+ * nothing about starting the Inspector installs a runtime by itself here.
444
454
  */
445
455
  async function runHarnessSubcommand(args) {
446
456
  const action = args[1];
447
- if (action !== "install" && action !== "status") {
448
- logError("usage: mcpjam-inspector harness <install|status>");
457
+ const usage =
458
+ "usage: mcpjam-inspector harness <install|status|doctor|repair> [--harness <id>] " +
459
+ "[--from <archive>] [--json] [--verify] [--export <file>]";
460
+ if (!["install", "status", "doctor", "repair"].includes(action)) {
461
+ logError(usage);
449
462
  return 2;
450
463
  }
464
+ // Which harness's pack. Omitted means Claude Code for install/status/repair
465
+ // (as it always did) and every harness for doctor.
466
+ let harnessId;
467
+ let fromArchive;
468
+ let exportPath;
469
+ let json = false;
470
+ let verify = false;
471
+ for (let i = 2; i < args.length; i++) {
472
+ const arg = args[i];
473
+ const value = (name) => {
474
+ if (arg === `--${name}` && typeof args[i + 1] === "string") return args[++i];
475
+ if (arg.startsWith(`--${name}=`)) return arg.slice(name.length + 3);
476
+ return undefined;
477
+ };
478
+ let v;
479
+ if ((v = value("harness")) !== undefined) harnessId = v;
480
+ else if ((v = value("from")) !== undefined && (action === "install" || action === "repair")) fromArchive = resolve(v);
481
+ else if ((v = value("export")) !== undefined && action === "doctor") exportPath = resolve(v);
482
+ else if (arg === "--json" && (action === "doctor" || action === "status")) json = true;
483
+ else if (arg === "--verify" && action === "doctor") verify = true;
484
+ else {
485
+ logError(usage);
486
+ return 2;
487
+ }
488
+ }
451
489
 
452
490
  // A dedicated bundle: importing the server entry would start a server.
453
491
  const cliEntry = resolve(__dirname, "../dist/server/harness-install-cli.js");
@@ -482,26 +520,82 @@ async function runHarnessSubcommand(args) {
482
520
  );
483
521
  return 1;
484
522
  }
523
+ const supported = Array.isArray(mod?.supportedHarnessIds)
524
+ ? mod.supportedHarnessIds
525
+ : ["claude-code"];
526
+ if (harnessId !== undefined && !supported.includes(harnessId)) {
527
+ logError(
528
+ `unknown harness ${JSON.stringify(harnessId)}; this Inspector can ` +
529
+ `install: ${supported.join(", ")}`,
530
+ );
531
+ return 2;
532
+ }
533
+ if (fromArchive !== undefined && !existsSync(fromArchive)) {
534
+ logError(`no archive at ${fromArchive}`);
535
+ return 2;
536
+ }
537
+ const harnessName =
538
+ mod?.harnessDisplayNames?.[harnessId ?? "claude-code"] ?? "Claude Code";
539
+ const harnessFlag = harnessId ? ` --harness ${harnessId}` : "";
485
540
 
486
541
  if (action === "status") {
487
- const current = await status();
542
+ const current = await status(harnessId);
488
543
  log(JSON.stringify(current, null, 2));
489
544
  return current.state === "ready" ? 0 : 1;
490
545
  }
491
546
 
492
- logStep("1", "Installing the local Claude Code runtime pack");
547
+ if (action === "doctor") {
548
+ if (typeof mod?.harnessDoctor !== "function") {
549
+ logError("this Inspector build has no `harness doctor`");
550
+ return 1;
551
+ }
552
+ const exported = exportPath !== undefined;
553
+ const result = await mod.harnessDoctor({ harnessId, verify, exported });
554
+ if (exported) {
555
+ writeFileSync(exportPath, `${JSON.stringify(result.report, null, 2)}\n`, { mode: 0o600 });
556
+ logSuccess(`Wrote a redacted report to ${exportPath}`);
557
+ }
558
+ if (json) log(JSON.stringify(result.report, null, 2));
559
+ else if (!exported) log(result.text);
560
+ return result.healthy ? 0 : 1;
561
+ }
562
+
493
563
  let lastPercent = -1;
494
- const result = await install((progress) => {
564
+ const onProgress = (progress) => {
495
565
  if (progress.state === "downloading" && progress.percent !== lastPercent) {
496
566
  lastPercent = progress.percent;
497
567
  process.stdout.write(`\r downloading ${progress.percent}% `);
498
568
  } else if (progress.state === "verifying") {
499
569
  process.stdout.write("\r verifying… ");
500
570
  }
501
- });
502
- process.stdout.write("\r");
571
+ };
572
+
573
+ let result;
574
+ if (action === "repair") {
575
+ if (typeof mod?.harnessRepair !== "function") {
576
+ logError("this Inspector build has no `harness repair`");
577
+ return 1;
578
+ }
579
+ logStep("1", `Repairing the local ${harnessName} runtime`);
580
+ const repaired = await mod.harnessRepair(onProgress, harnessId, fromArchive ? { fromArchive } : {});
581
+ process.stdout.write("\r");
582
+ for (const done of repaired.actions) logInfo(done);
583
+ result = repaired.status;
584
+ } else {
585
+ logStep(
586
+ "1",
587
+ fromArchive
588
+ ? `Installing the local ${harnessName} runtime pack from ${fromArchive} (no network)`
589
+ : `Installing the local ${harnessName} runtime pack`,
590
+ );
591
+ result = await install(onProgress, harnessId, fromArchive ? { fromArchive } : {});
592
+ process.stdout.write("\r");
593
+ }
503
594
  if (result.state === "ready") {
504
- logSuccess(`Runtime pack ${result.packVersion} installed and verified`);
595
+ logSuccess(
596
+ `Runtime pack ${result.packVersion} ${action === "repair" ? "is usable" : "installed and verified"}` +
597
+ (result.role === "permitted" ? " (the previous pack; the current one is not installed)" : ""),
598
+ );
505
599
  return 0;
506
600
  }
507
601
  // The reason, where the installer could establish one. Each of these sends a
@@ -509,24 +603,28 @@ async function runHarnessSubcommand(args) {
509
603
  // bad artifact — so collapsing them into "it failed" is what makes an
510
604
  // installer message useless.
511
605
  const REASONS = {
512
- network: "the runtime could not be downloaded",
606
+ network:
607
+ "the runtime could not be downloaded (behind a proxy? set HTTPS_PROXY, " +
608
+ "and NODE_EXTRA_CA_CERTS for a TLS-inspecting one)",
513
609
  verification:
514
- "the downloaded runtime did not match what this Inspector expected, " +
515
- "so it was not installed",
610
+ "the runtime did not match what this Inspector expected, so it was not " +
611
+ "installed",
516
612
  disk: "the runtime could not be written to its install location",
613
+ probe: "the runtime verified but this Inspector could not start on it",
517
614
  unknown: "the install did not complete",
518
615
  };
519
616
  if (result.state === "failed") {
520
617
  logError(
521
618
  `${REASONS[result.reason] ?? REASONS.unknown}` +
619
+ (result.stage ? ` [stage: ${result.stage}]` : "") +
522
620
  (result.message ? `: ${result.message}` : ""),
523
621
  );
524
- logInfo("Run `mcpjam-inspector harness install` again to retry.");
622
+ logInfo(`Run \`mcpjam-inspector harness doctor${harnessFlag}\` for what to do next.`);
525
623
  return 1;
526
624
  }
527
625
  if (result.state === "interrupted") {
528
626
  logError("Setup was interrupted before it finished.");
529
- logInfo("Run `mcpjam-inspector harness install` again to continue.");
627
+ logInfo(`Run \`mcpjam-inspector harness ${action}${harnessFlag}\` again to continue.`);
530
628
  return 1;
531
629
  }
532
630
  logError(
@@ -921,6 +1019,27 @@ async function main() {
921
1019
  process.env.ENVIRONMENT === "dev" ? "localhost" : "127.0.0.1";
922
1020
  const baseHost = process.env.HOST || defaultHost;
923
1021
  envVars.BASE_URL = `http://${baseHost}:${PORT}`;
1022
+ // This instance's own addresses. The packaged server serves the app
1023
+ // itself, so the browser port IS the server port: it names this
1024
+ // instance's session namespace, and the public callback origins (CLI
1025
+ // login, Slack/Discord linking) follow it. A configured NON-loopback
1026
+ // origin is a deliberate public deployment and is kept; a loopback one
1027
+ // from another port never survives `--port`.
1028
+ const instanceEnv = computeInstanceEnv({
1029
+ ports: { server: Number(PORT) },
1030
+ browserPort: Number(PORT),
1031
+ host: baseHost,
1032
+ profile: process.env,
1033
+ });
1034
+ for (const key of [
1035
+ "MCPJAM_BROWSER_PORT",
1036
+ "CLI_AUTH_PUBLIC_ORIGIN",
1037
+ "SLACK_LINK_PUBLIC_ORIGIN",
1038
+ "DISCORD_LINK_PUBLIC_ORIGIN",
1039
+ ]) {
1040
+ envVars[key] = instanceEnv[key];
1041
+ }
1042
+ verboseInfo(`Browser origin ${envVars.CLI_AUTH_PUBLIC_ORIGIN}`);
924
1043
  Object.assign(process.env, envVars);
925
1044
  } catch (error) {
926
1045
  logError(`Port configuration failed: ${error.message}`);