@mcpjam/cli 3.3.2 → 3.3.4

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/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { Command, CommanderError } from 'commander';
3
3
  import { realpathSync, readFileSync, existsSync, closeSync, mkdirSync, writeFileSync, renameSync, statSync, openSync } from 'fs';
4
4
  import { pathToFileURL, fileURLToPath } from 'url';
5
- import { probeMcpServer, runServerDoctor, collectServerSnapshot, serializeStableServerSnapshot, serializeServerSnapshot, buildServerDiffReport, validateToolCallResult, isCallToolResultError, buildToolCallValidationReport, listResources, readResource, listPrompts, getPrompt, MCPAppsConformanceTest, MCPAppsConformanceSuite, runOAuthLogin, OAuthConformanceTest, OAuthConformanceSuite, MCPConformanceTest, MCPConformanceSuite, redactSensitiveValue, withEphemeralClient, diffServerSnapshots, ServerSnapshotFormatError, renderStructuredRunJUnitXml, renderStructuredRunJson, toConformanceReport, renderConformanceReportJUnitXml, renderConformanceReportJson, formatOAuthConformanceHuman, formatOAuthConformanceSuiteHuman, fetchOAuthMetadata, executeOAuthProxy, executeDebugOAuthProxy, MCP_APPS_CHECK_CATEGORIES, MCP_APPS_CHECK_IDS, OAuthProxyError, MCP_CHECK_CATEGORIES, MCP_CHECK_IDS } from '@mcpjam/sdk';
5
+ import { probeMcpServer, redactSensitiveValue, runServerDoctor, collectServerSnapshot, serializeStableServerSnapshot, serializeServerSnapshot, buildServerDiffReport, validateToolCallResult, isCallToolResultError, buildToolCallValidationReport, listResources, readResource, listPrompts, getPrompt, MCPAppsConformanceTest, MCPAppsConformanceSuite, runOAuthLogin, OAuthConformanceTest, OAuthConformanceSuite, MCPConformanceTest, MCPConformanceSuite, withEphemeralClient, diffServerSnapshots, ServerSnapshotFormatError, renderStructuredRunJUnitXml, renderStructuredRunJson, toConformanceReport, renderConformanceReportJUnitXml, renderConformanceReportJson, formatOAuthConformanceHuman, formatOAuthConformanceSuiteHuman, fetchOAuthMetadata, executeOAuthProxy, executeDebugOAuthProxy, MCP_APPS_CHECK_CATEGORIES, MCP_APPS_CHECK_IDS, OAuthProxyError, MCP_CHECK_CATEGORIES, MCP_CHECK_IDS } from '@mcpjam/sdk';
6
6
  import { mkdir, writeFile, readFile, chmod, rename, rm } from 'fs/promises';
7
7
  import path2, { join, dirname } from 'path';
8
8
  import { randomUUID } from 'crypto';
@@ -12,7 +12,7 @@ import os, { homedir } from 'os';
12
12
 
13
13
  // package.json
14
14
  var package_default = {
15
- version: "3.3.2"};
15
+ version: "3.3.4"};
16
16
 
17
17
  // src/lib/output.ts
18
18
  var DEFAULT_OUTPUT_FORMAT = "json";
@@ -2572,7 +2572,10 @@ function registerServerCommands(program) {
2572
2572
  if (!result) {
2573
2573
  throw operationalError("Probe did not return a result.");
2574
2574
  }
2575
- writeResult(result, globalOptions.format);
2575
+ writeResult(
2576
+ redactSensitiveValue(result),
2577
+ globalOptions.format
2578
+ );
2576
2579
  if (result.status === "error") {
2577
2580
  setProcessExitCode(1);
2578
2581
  }
@@ -2598,11 +2601,12 @@ function registerServerCommands(program) {
2598
2601
  rpcLogger: collector?.rpcLogger,
2599
2602
  retryPolicy
2600
2603
  });
2601
- const jsonPayload = globalOptions.rpc ? attachCliRpcLogs(result, collector) : result;
2604
+ const rawPayload = globalOptions.rpc ? attachCliRpcLogs(result, collector) : result;
2605
+ const jsonPayload = redactSensitiveValue(rawPayload);
2602
2606
  const artifactPath = options.out ? await writeDebugArtifact(options.out, jsonPayload) : void 0;
2603
2607
  if (globalOptions.format === "human") {
2604
2608
  process.stdout.write(
2605
- `${formatServerDoctorHuman(result, { artifactPath })}
2609
+ `${formatServerDoctorHuman(jsonPayload, { artifactPath })}
2606
2610
  `
2607
2611
  );
2608
2612
  } else {
@@ -3807,9 +3811,10 @@ function assertFullFrontendMismatch(candidates) {
3807
3811
  }
3808
3812
  }
3809
3813
  async function resolveInspectorBrowserBaseUrlForHealth(baseUrl, frontendUrl, options) {
3814
+ const skipDiscovery = options.skipDiscovery || options.hasActiveClient && !options.openBrowser;
3810
3815
  try {
3811
3816
  return await resolveInspectorBrowserBaseUrl(baseUrl, frontendUrl, {
3812
- skipDiscovery: options.skipDiscovery
3817
+ skipDiscovery
3813
3818
  });
3814
3819
  } catch (error) {
3815
3820
  if (options.hasActiveClient && !options.openBrowser) {
@@ -4416,11 +4421,20 @@ async function runUiRender(options) {
4416
4421
  tab: "app-builder",
4417
4422
  timeoutMs: options.timeoutMs
4418
4423
  });
4424
+ if (openBrowser) {
4425
+ options.onProgress?.(`Inspector App Builder URL: ${ensureResult.url}`);
4426
+ if (!ensureResult.hasActiveClient) {
4427
+ options.onProgress?.(
4428
+ "Waiting for Inspector browser client to connect..."
4429
+ );
4430
+ }
4431
+ }
4419
4432
  if (!ensureResult.hasActiveClient && !openBrowser) {
4420
4433
  const startedNote = ensureResult.started ? " Inspector was just started by the CLI and is still running." : "";
4421
4434
  throw operationalError(
4422
4435
  `Inspector has no active browser client.${startedNote} Open the Inspector App Builder URL in your browser, then rerun \`tools call --ui\`; or pass \`--open\` to let the CLI open a system browser.`,
4423
4436
  {
4437
+ hasActiveClient: ensureResult.hasActiveClient,
4424
4438
  inspectorBrowserUrl: ensureResult.url,
4425
4439
  inspectorStarted: ensureResult.started
4426
4440
  }
@@ -4431,6 +4445,8 @@ async function runUiRender(options) {
4431
4445
  });
4432
4446
  const renderResult = await runInspectorAppRender({
4433
4447
  client,
4448
+ heartbeatEnabled: options.heartbeatEnabled,
4449
+ onProgress: options.onProgress,
4434
4450
  params: options.params,
4435
4451
  renderContext: options.renderContext,
4436
4452
  serverName: options.serverName,
@@ -4499,14 +4515,34 @@ async function runInspectorAppRender(options) {
4499
4515
  async function executeInspectorCommandWithClient(options, request) {
4500
4516
  const startedAt = Date.now();
4501
4517
  const deadline = startedAt + options.timeoutMs;
4518
+ let lastProgressAt = 0;
4502
4519
  let lastResponse;
4520
+ const emitWaitingProgress = (force = false) => {
4521
+ if (!options.onProgress || !options.heartbeatEnabled) {
4522
+ return;
4523
+ }
4524
+ const now = Date.now();
4525
+ if (!force && now - lastProgressAt < 2e3) {
4526
+ return;
4527
+ }
4528
+ lastProgressAt = now;
4529
+ const elapsedSeconds = Math.max(0, Math.floor((now - startedAt) / 1e3));
4530
+ options.onProgress(
4531
+ `Waiting for Inspector browser client to handle ${request.type}... (${elapsedSeconds}s)`
4532
+ );
4533
+ };
4503
4534
  do {
4504
- const response = await options.client.executeCommand(request);
4535
+ const response = await executeCommandWithProgress(
4536
+ options.client.executeCommand(request),
4537
+ emitWaitingProgress,
4538
+ Boolean(options.onProgress && options.heartbeatEnabled)
4539
+ );
4505
4540
  lastResponse = response;
4506
- const retryable = response.status === "error" && (response.error.code === "no_active_client" || response.error.code === "unsupported_in_mode" || response.error.code === "disconnected_server");
4541
+ const retryable = response.status === "error" && (response.error.code === "no_active_client" || response.error.code === "disconnected_server");
4507
4542
  if (!retryable) {
4508
4543
  return response;
4509
4544
  }
4545
+ emitWaitingProgress(true);
4510
4546
  const remaining = deadline - Date.now();
4511
4547
  if (remaining <= 0) {
4512
4548
  return response;
@@ -4518,6 +4554,18 @@ async function executeInspectorCommandWithClient(options, request) {
4518
4554
  }
4519
4555
  return lastResponse;
4520
4556
  }
4557
+ async function executeCommandWithProgress(pending, onProgress, enabled) {
4558
+ if (!enabled) {
4559
+ return await pending;
4560
+ }
4561
+ const interval = setInterval(onProgress, 2e3);
4562
+ interval.unref?.();
4563
+ try {
4564
+ return await pending;
4565
+ } finally {
4566
+ clearInterval(interval);
4567
+ }
4568
+ }
4521
4569
  function findInspectorRenderError(renderResult) {
4522
4570
  const priority = [
4523
4571
  "renderToolResult",
@@ -4642,7 +4690,7 @@ function registerToolsCommands(program) {
4642
4690
  tools.command("call").description("Call an MCP tool").option("--tool-name <tool>", "Tool name").option("--name <tool>", "Alias for --tool-name").option(
4643
4691
  "--tool-args <json>",
4644
4692
  "Tool parameter object as JSON, @path, or - for stdin"
4645
- ).option("--params <json>", "Alias for --tool-args").option(
4693
+ ).option("--params <json>", "Alias for --tool-args").option("--tool-args-stdin", "Read tool parameter JSON from stdin").option(
4646
4694
  "--validate-response",
4647
4695
  "Validate the MCP tool-call envelope returned by the server"
4648
4696
  ).option(
@@ -4654,7 +4702,16 @@ function registerToolsCommands(program) {
4654
4702
  ).option(
4655
4703
  "--debug-out <path>",
4656
4704
  "Write a structured debug artifact to a file"
4657
- ).option("--ui", "Render the tool result in Inspector App Builder").option("--open", "Open Inspector in the system browser before rendering").option(
4705
+ ).option(
4706
+ "--ui",
4707
+ "Render the tool result in Inspector App Builder; opens a browser by default in a TTY"
4708
+ ).option(
4709
+ "--require-render",
4710
+ "Treat skipped Inspector renders as errors (with --ui)"
4711
+ ).option(
4712
+ "--open",
4713
+ "Open Inspector in the system browser before rendering (default with --ui in a TTY)"
4714
+ ).option(
4658
4715
  "--no-open",
4659
4716
  "Start/use Inspector without opening a system browser"
4660
4717
  ).option(
@@ -4692,7 +4749,7 @@ function registerToolsCommands(program) {
4692
4749
  "Tool name",
4693
4750
  { required: true }
4694
4751
  );
4695
- const paramsInput = resolveAliasedStringOption(
4752
+ const resolvedParamsInput = resolveAliasedStringOption(
4696
4753
  options,
4697
4754
  [
4698
4755
  { key: "toolArgs", flag: "--tool-args" },
@@ -4700,6 +4757,12 @@ function registerToolsCommands(program) {
4700
4757
  ],
4701
4758
  "Tool parameters"
4702
4759
  );
4760
+ if (options.toolArgsStdin && resolvedParamsInput !== void 0) {
4761
+ throw usageError(
4762
+ "--tool-args-stdin cannot be used together with --tool-args or --params."
4763
+ );
4764
+ }
4765
+ const paramsInput = options.toolArgsStdin ? "-" : resolvedParamsInput;
4703
4766
  const params = parseJsonRecord(paramsInput, "Tool parameters") ?? {};
4704
4767
  const targetSummary = summarizeServerDoctorTarget(target, config);
4705
4768
  const shouldValidateResponse = options.validateResponse === true;
@@ -4707,6 +4770,9 @@ function registerToolsCommands(program) {
4707
4770
  if (options.ui && reporter) {
4708
4771
  throw usageError("--ui cannot be used together with --reporter.");
4709
4772
  }
4773
+ if (options.requireRender && !options.ui) {
4774
+ throw usageError("--require-render requires --ui.");
4775
+ }
4710
4776
  if (options.attachOnly && options.open === true) {
4711
4777
  throw usageError("--attach-only cannot be used together with --open.");
4712
4778
  }
@@ -4776,12 +4842,16 @@ function registerToolsCommands(program) {
4776
4842
  let outputPayload = result;
4777
4843
  let debugOutputPayload = outputPayload;
4778
4844
  let inspectorRenderError;
4845
+ let inspectorRenderSkipped = false;
4846
+ let inspectorRenderIssue;
4847
+ const requireRender = options.requireRender === true;
4779
4848
  if (options.ui) {
4780
4849
  const serverName = typeof options.serverName === "string" && options.serverName.trim() ? options.serverName.trim() : buildInspectorServerName(options);
4781
- const openBrowser = resolveInspectorOpenBrowser(options, globalOptions);
4850
+ const openBrowser = resolveInspectorOpenBrowser(options);
4782
4851
  const skipDiscovery = resolveInspectorSkipDiscovery(
4783
4852
  options,
4784
- globalOptions
4853
+ globalOptions,
4854
+ { openBrowser }
4785
4855
  );
4786
4856
  let uiResult;
4787
4857
  try {
@@ -4789,6 +4859,11 @@ function registerToolsCommands(program) {
4789
4859
  baseUrl: options.inspectorUrl,
4790
4860
  config,
4791
4861
  frontendUrl,
4862
+ onProgress: createInspectorUiProgressReporter({
4863
+ enabled: openBrowser && !globalOptions.quiet,
4864
+ stderrIsTTY: resolveInspectorUiStderrIsTTY()
4865
+ }),
4866
+ heartbeatEnabled: resolveInspectorUiStderrIsTTY(),
4792
4867
  openBrowser,
4793
4868
  params,
4794
4869
  renderContext,
@@ -4810,9 +4885,26 @@ function registerToolsCommands(program) {
4810
4885
  ...extractInspectorRenderErrorUrls(inspectorRenderError)
4811
4886
  };
4812
4887
  }
4813
- const compactInspectorRender = buildCompactInspectorRender(uiResult);
4888
+ const inspectorRenderClassification = classifyInspectorRenderError(
4889
+ inspectorRenderError,
4890
+ {
4891
+ noActiveClientIsSkippable: options.attachOnly !== true
4892
+ }
4893
+ );
4894
+ inspectorRenderSkipped = inspectorRenderClassification.skippable;
4895
+ inspectorRenderIssue = buildInspectorRenderIssue(
4896
+ inspectorRenderError,
4897
+ uiResult,
4898
+ inspectorRenderClassification
4899
+ );
4900
+ const compactInspectorRender = buildCompactInspectorRender(uiResult, {
4901
+ skipped: inspectorRenderSkipped,
4902
+ remediation: inspectorRenderClassification.remediation,
4903
+ issue: inspectorRenderIssue
4904
+ });
4905
+ const renderFailure = inspectorRenderError && (!inspectorRenderSkipped || requireRender);
4814
4906
  const compactOutputPayload = {
4815
- success: !inspectorRenderError && !validationFailed && !toolResultError,
4907
+ success: !renderFailure && !validationFailed && !toolResultError,
4816
4908
  command: "tools call",
4817
4909
  inspectorUi: true,
4818
4910
  ...typeof compactInspectorRender.browserUrl === "string" ? { inspectorBrowserUrl: compactInspectorRender.browserUrl } : {},
@@ -4822,7 +4914,7 @@ function registerToolsCommands(program) {
4822
4914
  parameterKeys: Object.keys(params),
4823
4915
  result,
4824
4916
  inspectorRender: compactInspectorRender,
4825
- ...inspectorRenderError ? { error: inspectorRenderError } : {}
4917
+ ...inspectorRenderError ? inspectorRenderSkipped && !requireRender ? { warning: inspectorRenderIssue ?? inspectorRenderError } : { error: inspectorRenderIssue ?? inspectorRenderError } : {}
4826
4918
  };
4827
4919
  outputPayload = compactOutputPayload;
4828
4920
  debugOutputPayload = {
@@ -4830,7 +4922,25 @@ function registerToolsCommands(program) {
4830
4922
  params,
4831
4923
  inspectorRender: uiResult
4832
4924
  };
4925
+ writeInspectorRenderWarning({
4926
+ issue: inspectorRenderIssue,
4927
+ globalOptions,
4928
+ render: compactInspectorRender,
4929
+ required: requireRender,
4930
+ skipped: inspectorRenderSkipped
4931
+ });
4833
4932
  }
4933
+ const renderIsFailure = Boolean(
4934
+ inspectorRenderError && (!inspectorRenderSkipped || requireRender)
4935
+ );
4936
+ const debugOutcomeError = renderIsFailure ? inspectorRenderIssue ?? inspectorRenderError : validationFailed ? {
4937
+ code: "validation_failed",
4938
+ message: "Tool call validation failed.",
4939
+ details: validationResult
4940
+ } : toolResultError ? {
4941
+ code: "tool_result_error",
4942
+ message: "Tool returned an error result."
4943
+ } : void 0;
4834
4944
  await writeCommandDebugArtifact({
4835
4945
  outputPath: options.debugOut,
4836
4946
  format: globalOptions.format,
@@ -4841,9 +4951,9 @@ function registerToolsCommands(program) {
4841
4951
  params
4842
4952
  },
4843
4953
  target: targetSummary,
4844
- outcome: inspectorRenderError ? {
4954
+ outcome: debugOutcomeError ? {
4845
4955
  status: "error",
4846
- error: inspectorRenderError,
4956
+ error: debugOutcomeError,
4847
4957
  result: debugOutputPayload
4848
4958
  } : {
4849
4959
  status: "success",
@@ -4882,42 +4992,57 @@ function registerToolsCommands(program) {
4882
4992
  if (toolResultError) {
4883
4993
  setProcessExitCode(1);
4884
4994
  }
4885
- if (inspectorRenderError) {
4995
+ if (inspectorRenderError && (!inspectorRenderSkipped || requireRender)) {
4886
4996
  setProcessExitCode(1);
4887
4997
  }
4888
4998
  });
4889
4999
  }
4890
- function resolveInspectorOpenBrowser(options, globalOptions) {
5000
+ function parseInspectorUiTtyOverride(name) {
5001
+ const value = process.env[name]?.trim().toLowerCase();
5002
+ if (!value) {
5003
+ return void 0;
5004
+ }
5005
+ if (value === "1" || value === "true") {
5006
+ return true;
5007
+ }
5008
+ if (value === "0" || value === "false") {
5009
+ return false;
5010
+ }
5011
+ return void 0;
5012
+ }
5013
+ function resolveInspectorUiStdoutIsTTY() {
5014
+ return parseInspectorUiTtyOverride("MCPJAM_CLI_TEST_STDOUT_TTY") ?? Boolean(process.stdout.isTTY);
5015
+ }
5016
+ function resolveInspectorUiStderrIsTTY() {
5017
+ return parseInspectorUiTtyOverride("MCPJAM_CLI_TEST_STDERR_TTY") ?? Boolean(process.stderr.isTTY);
5018
+ }
5019
+ function resolveInspectorOpenBrowser(options, environment = {}) {
5020
+ const stdoutIsTTY = environment.stdoutIsTTY ?? resolveInspectorUiStdoutIsTTY();
4891
5021
  if (options.attachOnly) {
4892
5022
  return false;
4893
5023
  }
4894
5024
  if (options.open !== void 0) {
4895
5025
  return options.open;
4896
5026
  }
4897
- return globalOptions.format === "human" && !globalOptions.quiet;
5027
+ return stdoutIsTTY;
4898
5028
  }
4899
- function parseInspectorFrontendUrl(value) {
4900
- if (value === void 0) {
4901
- return void 0;
4902
- }
4903
- const frontendUrl = normalizeInspectorFrontendUrl(value);
4904
- if (!frontendUrl) {
4905
- throw usageError(`Invalid --frontend-url "${value}".`);
4906
- }
4907
- return frontendUrl;
4908
- }
4909
- function resolveInspectorSkipDiscovery(options, globalOptions) {
5029
+ function resolveInspectorSkipDiscovery(options, globalOptions, environment = {}) {
5030
+ const stdoutIsTTY = environment.stdoutIsTTY ?? resolveInspectorUiStdoutIsTTY();
5031
+ const openBrowser = environment.openBrowser ?? resolveInspectorOpenBrowser(options, { stdoutIsTTY });
4910
5032
  if (typeof options.frontendUrl === "string" && options.frontendUrl.trim()) {
4911
5033
  return true;
4912
5034
  }
4913
5035
  if (options.attachOnly) {
4914
5036
  return true;
4915
5037
  }
4916
- if ((globalOptions.format === "json" || globalOptions.quiet) && options.open !== true) {
5038
+ if (openBrowser) {
5039
+ return false;
5040
+ }
5041
+ if (options.open === void 0 && !stdoutIsTTY) {
4917
5042
  return true;
4918
5043
  }
4919
- if (options.open === true) {
4920
- return false;
5044
+ if (options.open === false && (globalOptions.format === "json" || globalOptions.quiet)) {
5045
+ return true;
4921
5046
  }
4922
5047
  return false;
4923
5048
  }
@@ -4931,10 +5056,98 @@ function extractInspectorRenderErrorUrls(error) {
4931
5056
  const details = error.details;
4932
5057
  return {
4933
5058
  ...typeof details.inspectorBrowserUrl === "string" ? { browserUrl: details.inspectorBrowserUrl } : {},
4934
- ...typeof details.inspectorFrontendUrl === "string" ? { frontendUrl: details.inspectorFrontendUrl } : {}
5059
+ ...typeof details.inspectorFrontendUrl === "string" ? { frontendUrl: details.inspectorFrontendUrl } : {},
5060
+ ...typeof details.inspectorStarted === "boolean" ? { inspectorStarted: details.inspectorStarted } : {},
5061
+ ...typeof details.hasActiveClient === "boolean" ? { hasActiveClient: details.hasActiveClient } : {}
5062
+ };
5063
+ }
5064
+ function createInspectorUiProgressReporter(options) {
5065
+ if (!options.enabled) {
5066
+ return void 0;
5067
+ }
5068
+ let lastMessage = "";
5069
+ return (message) => {
5070
+ if (!message || message === lastMessage) {
5071
+ return;
5072
+ }
5073
+ if (!options.stderrIsTTY && /\(\d+s\)$/.test(message)) {
5074
+ return;
5075
+ }
5076
+ lastMessage = message;
5077
+ process.stderr.write(`${message}
5078
+ `);
5079
+ };
5080
+ }
5081
+ function writeInspectorRenderWarning(options) {
5082
+ if (!options.skipped || !options.issue || options.globalOptions.quiet) {
5083
+ return;
5084
+ }
5085
+ process.stderr.write(
5086
+ `${options.required ? "Error" : "Warning"}: Inspector UI render ${options.required ? "required but " : ""}skipped: ${options.issue.message}
5087
+ `
5088
+ );
5089
+ if (options.issue.code !== "no_active_client") {
5090
+ return;
5091
+ }
5092
+ const browserUrl = typeof options.render.browserUrl === "string" ? options.render.browserUrl : void 0;
5093
+ process.stderr.write(
5094
+ `Tip: open the Inspector App Builder${browserUrl ? ` at ${browserUrl}` : ""}, or rerun without --no-open or with --open to launch a browser automatically.
5095
+ `
5096
+ );
5097
+ }
5098
+ function classifyInspectorRenderError(error, options = {}) {
5099
+ if (!error) {
5100
+ return { skippable: false, remediation: "none" };
5101
+ }
5102
+ const noActiveClientIsSkippable = options.noActiveClientIsSkippable ?? true;
5103
+ const code = error.code.toLowerCase();
5104
+ if (code === "no_active_client" || isNoActiveClientMessage(error)) {
5105
+ return {
5106
+ skippable: noActiveClientIsSkippable,
5107
+ code: "no_active_client",
5108
+ remediation: "open_browser"
5109
+ };
5110
+ }
5111
+ if (code === "timeout") {
5112
+ return {
5113
+ skippable: true,
5114
+ code: "timeout",
5115
+ remediation: "retry"
5116
+ };
5117
+ }
5118
+ if (code === "disconnected_server") {
5119
+ return {
5120
+ skippable: true,
5121
+ code: "disconnected_server",
5122
+ remediation: "reconnect_server"
5123
+ };
5124
+ }
5125
+ if (code === "unsupported_in_mode") {
5126
+ return {
5127
+ skippable: true,
5128
+ code: "unsupported_in_mode",
5129
+ remediation: "none"
5130
+ };
5131
+ }
5132
+ return { skippable: false, remediation: "none" };
5133
+ }
5134
+ function buildInspectorRenderIssue(error, render, classification) {
5135
+ if (!error || !classification.code) {
5136
+ return void 0;
5137
+ }
5138
+ return {
5139
+ code: classification.code,
5140
+ message: error.message,
5141
+ remediation: classification.remediation,
5142
+ ...typeof render.browserUrl === "string" ? { browserUrl: render.browserUrl } : {},
5143
+ ...typeof render.hasActiveClient === "boolean" ? { hasActiveClient: render.hasActiveClient } : {},
5144
+ ...typeof render.inspectorStarted === "boolean" ? { inspectorStarted: render.inspectorStarted } : {}
4935
5145
  };
4936
5146
  }
4937
- function buildCompactInspectorRender(uiResult) {
5147
+ function isNoActiveClientMessage(error) {
5148
+ return error.code.toLowerCase() === "no_active_client" || /no active (browser )?client/i.test(error.message);
5149
+ }
5150
+ function buildCompactInspectorRender(uiResult, options = {}) {
4938
5151
  const commands = {};
4939
5152
  let hasCommandError = false;
4940
5153
  for (const [commandName, commandValue] of Object.entries(uiResult)) {
@@ -4947,9 +5160,10 @@ function buildCompactInspectorRender(uiResult) {
4947
5160
  hasCommandError = true;
4948
5161
  }
4949
5162
  }
4950
- const topLevelError = uiResult.status === "error" && isRecord(uiResult.error) ? { error: uiResult.error } : {};
5163
+ const topLevelError = options.skipped ? options.issue ? { warning: options.issue } : uiResult.status === "error" && isRecord(uiResult.error) ? { warning: uiResult.error } : {} : options.issue ? { error: options.issue } : uiResult.status === "error" && isRecord(uiResult.error) ? { error: uiResult.error } : {};
4951
5164
  return {
4952
- status: hasCommandError || uiResult.status === "error" ? "error" : "rendered",
5165
+ status: options.skipped ? "skipped" : hasCommandError || uiResult.status === "error" ? "error" : "rendered",
5166
+ remediation: options.remediation ?? "none",
4953
5167
  // Contract metadata: renders target the active client and fresh tabs do not
4954
5168
  // hydrate this injected state.
4955
5169
  mode: "active-client",
@@ -4964,6 +5178,16 @@ function buildCompactInspectorRender(uiResult) {
4964
5178
  ...topLevelError
4965
5179
  };
4966
5180
  }
5181
+ function parseInspectorFrontendUrl(value) {
5182
+ if (value === void 0) {
5183
+ return void 0;
5184
+ }
5185
+ const frontendUrl = normalizeInspectorFrontendUrl(value);
5186
+ if (!frontendUrl) {
5187
+ throw usageError(`Invalid --frontend-url "${value}".`);
5188
+ }
5189
+ return frontendUrl;
5190
+ }
4967
5191
  function compactInspectorCommandResponse(value) {
4968
5192
  if (!isRecord(value) || !isCompactInspectorCommandStatus(value.status)) {
4969
5193
  return void 0;