@mcpjam/cli 3.3.3 → 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 +255 -35
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import os, { homedir } from 'os';
|
|
|
12
12
|
|
|
13
13
|
// package.json
|
|
14
14
|
var package_default = {
|
|
15
|
-
version: "3.3.
|
|
15
|
+
version: "3.3.4"};
|
|
16
16
|
|
|
17
17
|
// src/lib/output.ts
|
|
18
18
|
var DEFAULT_OUTPUT_FORMAT = "json";
|
|
@@ -3811,9 +3811,10 @@ function assertFullFrontendMismatch(candidates) {
|
|
|
3811
3811
|
}
|
|
3812
3812
|
}
|
|
3813
3813
|
async function resolveInspectorBrowserBaseUrlForHealth(baseUrl, frontendUrl, options) {
|
|
3814
|
+
const skipDiscovery = options.skipDiscovery || options.hasActiveClient && !options.openBrowser;
|
|
3814
3815
|
try {
|
|
3815
3816
|
return await resolveInspectorBrowserBaseUrl(baseUrl, frontendUrl, {
|
|
3816
|
-
skipDiscovery
|
|
3817
|
+
skipDiscovery
|
|
3817
3818
|
});
|
|
3818
3819
|
} catch (error) {
|
|
3819
3820
|
if (options.hasActiveClient && !options.openBrowser) {
|
|
@@ -4420,11 +4421,20 @@ async function runUiRender(options) {
|
|
|
4420
4421
|
tab: "app-builder",
|
|
4421
4422
|
timeoutMs: options.timeoutMs
|
|
4422
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
|
+
}
|
|
4423
4432
|
if (!ensureResult.hasActiveClient && !openBrowser) {
|
|
4424
4433
|
const startedNote = ensureResult.started ? " Inspector was just started by the CLI and is still running." : "";
|
|
4425
4434
|
throw operationalError(
|
|
4426
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.`,
|
|
4427
4436
|
{
|
|
4437
|
+
hasActiveClient: ensureResult.hasActiveClient,
|
|
4428
4438
|
inspectorBrowserUrl: ensureResult.url,
|
|
4429
4439
|
inspectorStarted: ensureResult.started
|
|
4430
4440
|
}
|
|
@@ -4435,6 +4445,8 @@ async function runUiRender(options) {
|
|
|
4435
4445
|
});
|
|
4436
4446
|
const renderResult = await runInspectorAppRender({
|
|
4437
4447
|
client,
|
|
4448
|
+
heartbeatEnabled: options.heartbeatEnabled,
|
|
4449
|
+
onProgress: options.onProgress,
|
|
4438
4450
|
params: options.params,
|
|
4439
4451
|
renderContext: options.renderContext,
|
|
4440
4452
|
serverName: options.serverName,
|
|
@@ -4503,14 +4515,34 @@ async function runInspectorAppRender(options) {
|
|
|
4503
4515
|
async function executeInspectorCommandWithClient(options, request) {
|
|
4504
4516
|
const startedAt = Date.now();
|
|
4505
4517
|
const deadline = startedAt + options.timeoutMs;
|
|
4518
|
+
let lastProgressAt = 0;
|
|
4506
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
|
+
};
|
|
4507
4534
|
do {
|
|
4508
|
-
const response = await
|
|
4535
|
+
const response = await executeCommandWithProgress(
|
|
4536
|
+
options.client.executeCommand(request),
|
|
4537
|
+
emitWaitingProgress,
|
|
4538
|
+
Boolean(options.onProgress && options.heartbeatEnabled)
|
|
4539
|
+
);
|
|
4509
4540
|
lastResponse = response;
|
|
4510
|
-
const retryable = response.status === "error" && (response.error.code === "no_active_client" || response.error.code === "
|
|
4541
|
+
const retryable = response.status === "error" && (response.error.code === "no_active_client" || response.error.code === "disconnected_server");
|
|
4511
4542
|
if (!retryable) {
|
|
4512
4543
|
return response;
|
|
4513
4544
|
}
|
|
4545
|
+
emitWaitingProgress(true);
|
|
4514
4546
|
const remaining = deadline - Date.now();
|
|
4515
4547
|
if (remaining <= 0) {
|
|
4516
4548
|
return response;
|
|
@@ -4522,6 +4554,18 @@ async function executeInspectorCommandWithClient(options, request) {
|
|
|
4522
4554
|
}
|
|
4523
4555
|
return lastResponse;
|
|
4524
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
|
+
}
|
|
4525
4569
|
function findInspectorRenderError(renderResult) {
|
|
4526
4570
|
const priority = [
|
|
4527
4571
|
"renderToolResult",
|
|
@@ -4646,7 +4690,7 @@ function registerToolsCommands(program) {
|
|
|
4646
4690
|
tools.command("call").description("Call an MCP tool").option("--tool-name <tool>", "Tool name").option("--name <tool>", "Alias for --tool-name").option(
|
|
4647
4691
|
"--tool-args <json>",
|
|
4648
4692
|
"Tool parameter object as JSON, @path, or - for stdin"
|
|
4649
|
-
).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(
|
|
4650
4694
|
"--validate-response",
|
|
4651
4695
|
"Validate the MCP tool-call envelope returned by the server"
|
|
4652
4696
|
).option(
|
|
@@ -4658,7 +4702,16 @@ function registerToolsCommands(program) {
|
|
|
4658
4702
|
).option(
|
|
4659
4703
|
"--debug-out <path>",
|
|
4660
4704
|
"Write a structured debug artifact to a file"
|
|
4661
|
-
).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(
|
|
4662
4715
|
"--no-open",
|
|
4663
4716
|
"Start/use Inspector without opening a system browser"
|
|
4664
4717
|
).option(
|
|
@@ -4696,7 +4749,7 @@ function registerToolsCommands(program) {
|
|
|
4696
4749
|
"Tool name",
|
|
4697
4750
|
{ required: true }
|
|
4698
4751
|
);
|
|
4699
|
-
const
|
|
4752
|
+
const resolvedParamsInput = resolveAliasedStringOption(
|
|
4700
4753
|
options,
|
|
4701
4754
|
[
|
|
4702
4755
|
{ key: "toolArgs", flag: "--tool-args" },
|
|
@@ -4704,6 +4757,12 @@ function registerToolsCommands(program) {
|
|
|
4704
4757
|
],
|
|
4705
4758
|
"Tool parameters"
|
|
4706
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;
|
|
4707
4766
|
const params = parseJsonRecord(paramsInput, "Tool parameters") ?? {};
|
|
4708
4767
|
const targetSummary = summarizeServerDoctorTarget(target, config);
|
|
4709
4768
|
const shouldValidateResponse = options.validateResponse === true;
|
|
@@ -4711,6 +4770,9 @@ function registerToolsCommands(program) {
|
|
|
4711
4770
|
if (options.ui && reporter) {
|
|
4712
4771
|
throw usageError("--ui cannot be used together with --reporter.");
|
|
4713
4772
|
}
|
|
4773
|
+
if (options.requireRender && !options.ui) {
|
|
4774
|
+
throw usageError("--require-render requires --ui.");
|
|
4775
|
+
}
|
|
4714
4776
|
if (options.attachOnly && options.open === true) {
|
|
4715
4777
|
throw usageError("--attach-only cannot be used together with --open.");
|
|
4716
4778
|
}
|
|
@@ -4780,12 +4842,16 @@ function registerToolsCommands(program) {
|
|
|
4780
4842
|
let outputPayload = result;
|
|
4781
4843
|
let debugOutputPayload = outputPayload;
|
|
4782
4844
|
let inspectorRenderError;
|
|
4845
|
+
let inspectorRenderSkipped = false;
|
|
4846
|
+
let inspectorRenderIssue;
|
|
4847
|
+
const requireRender = options.requireRender === true;
|
|
4783
4848
|
if (options.ui) {
|
|
4784
4849
|
const serverName = typeof options.serverName === "string" && options.serverName.trim() ? options.serverName.trim() : buildInspectorServerName(options);
|
|
4785
|
-
const openBrowser = resolveInspectorOpenBrowser(options
|
|
4850
|
+
const openBrowser = resolveInspectorOpenBrowser(options);
|
|
4786
4851
|
const skipDiscovery = resolveInspectorSkipDiscovery(
|
|
4787
4852
|
options,
|
|
4788
|
-
globalOptions
|
|
4853
|
+
globalOptions,
|
|
4854
|
+
{ openBrowser }
|
|
4789
4855
|
);
|
|
4790
4856
|
let uiResult;
|
|
4791
4857
|
try {
|
|
@@ -4793,6 +4859,11 @@ function registerToolsCommands(program) {
|
|
|
4793
4859
|
baseUrl: options.inspectorUrl,
|
|
4794
4860
|
config,
|
|
4795
4861
|
frontendUrl,
|
|
4862
|
+
onProgress: createInspectorUiProgressReporter({
|
|
4863
|
+
enabled: openBrowser && !globalOptions.quiet,
|
|
4864
|
+
stderrIsTTY: resolveInspectorUiStderrIsTTY()
|
|
4865
|
+
}),
|
|
4866
|
+
heartbeatEnabled: resolveInspectorUiStderrIsTTY(),
|
|
4796
4867
|
openBrowser,
|
|
4797
4868
|
params,
|
|
4798
4869
|
renderContext,
|
|
@@ -4814,9 +4885,26 @@ function registerToolsCommands(program) {
|
|
|
4814
4885
|
...extractInspectorRenderErrorUrls(inspectorRenderError)
|
|
4815
4886
|
};
|
|
4816
4887
|
}
|
|
4817
|
-
const
|
|
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);
|
|
4818
4906
|
const compactOutputPayload = {
|
|
4819
|
-
success: !
|
|
4907
|
+
success: !renderFailure && !validationFailed && !toolResultError,
|
|
4820
4908
|
command: "tools call",
|
|
4821
4909
|
inspectorUi: true,
|
|
4822
4910
|
...typeof compactInspectorRender.browserUrl === "string" ? { inspectorBrowserUrl: compactInspectorRender.browserUrl } : {},
|
|
@@ -4826,7 +4914,7 @@ function registerToolsCommands(program) {
|
|
|
4826
4914
|
parameterKeys: Object.keys(params),
|
|
4827
4915
|
result,
|
|
4828
4916
|
inspectorRender: compactInspectorRender,
|
|
4829
|
-
...inspectorRenderError ? { error: inspectorRenderError } : {}
|
|
4917
|
+
...inspectorRenderError ? inspectorRenderSkipped && !requireRender ? { warning: inspectorRenderIssue ?? inspectorRenderError } : { error: inspectorRenderIssue ?? inspectorRenderError } : {}
|
|
4830
4918
|
};
|
|
4831
4919
|
outputPayload = compactOutputPayload;
|
|
4832
4920
|
debugOutputPayload = {
|
|
@@ -4834,7 +4922,25 @@ function registerToolsCommands(program) {
|
|
|
4834
4922
|
params,
|
|
4835
4923
|
inspectorRender: uiResult
|
|
4836
4924
|
};
|
|
4925
|
+
writeInspectorRenderWarning({
|
|
4926
|
+
issue: inspectorRenderIssue,
|
|
4927
|
+
globalOptions,
|
|
4928
|
+
render: compactInspectorRender,
|
|
4929
|
+
required: requireRender,
|
|
4930
|
+
skipped: inspectorRenderSkipped
|
|
4931
|
+
});
|
|
4837
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;
|
|
4838
4944
|
await writeCommandDebugArtifact({
|
|
4839
4945
|
outputPath: options.debugOut,
|
|
4840
4946
|
format: globalOptions.format,
|
|
@@ -4845,9 +4951,9 @@ function registerToolsCommands(program) {
|
|
|
4845
4951
|
params
|
|
4846
4952
|
},
|
|
4847
4953
|
target: targetSummary,
|
|
4848
|
-
outcome:
|
|
4954
|
+
outcome: debugOutcomeError ? {
|
|
4849
4955
|
status: "error",
|
|
4850
|
-
error:
|
|
4956
|
+
error: debugOutcomeError,
|
|
4851
4957
|
result: debugOutputPayload
|
|
4852
4958
|
} : {
|
|
4853
4959
|
status: "success",
|
|
@@ -4886,42 +4992,57 @@ function registerToolsCommands(program) {
|
|
|
4886
4992
|
if (toolResultError) {
|
|
4887
4993
|
setProcessExitCode(1);
|
|
4888
4994
|
}
|
|
4889
|
-
if (inspectorRenderError) {
|
|
4995
|
+
if (inspectorRenderError && (!inspectorRenderSkipped || requireRender)) {
|
|
4890
4996
|
setProcessExitCode(1);
|
|
4891
4997
|
}
|
|
4892
4998
|
});
|
|
4893
4999
|
}
|
|
4894
|
-
function
|
|
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();
|
|
4895
5021
|
if (options.attachOnly) {
|
|
4896
5022
|
return false;
|
|
4897
5023
|
}
|
|
4898
5024
|
if (options.open !== void 0) {
|
|
4899
5025
|
return options.open;
|
|
4900
5026
|
}
|
|
4901
|
-
return
|
|
4902
|
-
}
|
|
4903
|
-
function parseInspectorFrontendUrl(value) {
|
|
4904
|
-
if (value === void 0) {
|
|
4905
|
-
return void 0;
|
|
4906
|
-
}
|
|
4907
|
-
const frontendUrl = normalizeInspectorFrontendUrl(value);
|
|
4908
|
-
if (!frontendUrl) {
|
|
4909
|
-
throw usageError(`Invalid --frontend-url "${value}".`);
|
|
4910
|
-
}
|
|
4911
|
-
return frontendUrl;
|
|
5027
|
+
return stdoutIsTTY;
|
|
4912
5028
|
}
|
|
4913
|
-
function resolveInspectorSkipDiscovery(options, globalOptions) {
|
|
5029
|
+
function resolveInspectorSkipDiscovery(options, globalOptions, environment = {}) {
|
|
5030
|
+
const stdoutIsTTY = environment.stdoutIsTTY ?? resolveInspectorUiStdoutIsTTY();
|
|
5031
|
+
const openBrowser = environment.openBrowser ?? resolveInspectorOpenBrowser(options, { stdoutIsTTY });
|
|
4914
5032
|
if (typeof options.frontendUrl === "string" && options.frontendUrl.trim()) {
|
|
4915
5033
|
return true;
|
|
4916
5034
|
}
|
|
4917
5035
|
if (options.attachOnly) {
|
|
4918
5036
|
return true;
|
|
4919
5037
|
}
|
|
4920
|
-
if (
|
|
5038
|
+
if (openBrowser) {
|
|
5039
|
+
return false;
|
|
5040
|
+
}
|
|
5041
|
+
if (options.open === void 0 && !stdoutIsTTY) {
|
|
4921
5042
|
return true;
|
|
4922
5043
|
}
|
|
4923
|
-
if (options.open ===
|
|
4924
|
-
return
|
|
5044
|
+
if (options.open === false && (globalOptions.format === "json" || globalOptions.quiet)) {
|
|
5045
|
+
return true;
|
|
4925
5046
|
}
|
|
4926
5047
|
return false;
|
|
4927
5048
|
}
|
|
@@ -4935,10 +5056,98 @@ function extractInspectorRenderErrorUrls(error) {
|
|
|
4935
5056
|
const details = error.details;
|
|
4936
5057
|
return {
|
|
4937
5058
|
...typeof details.inspectorBrowserUrl === "string" ? { browserUrl: details.inspectorBrowserUrl } : {},
|
|
4938
|
-
...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
|
+
`);
|
|
4939
5079
|
};
|
|
4940
5080
|
}
|
|
4941
|
-
function
|
|
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 } : {}
|
|
5145
|
+
};
|
|
5146
|
+
}
|
|
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 = {}) {
|
|
4942
5151
|
const commands = {};
|
|
4943
5152
|
let hasCommandError = false;
|
|
4944
5153
|
for (const [commandName, commandValue] of Object.entries(uiResult)) {
|
|
@@ -4951,9 +5160,10 @@ function buildCompactInspectorRender(uiResult) {
|
|
|
4951
5160
|
hasCommandError = true;
|
|
4952
5161
|
}
|
|
4953
5162
|
}
|
|
4954
|
-
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 } : {};
|
|
4955
5164
|
return {
|
|
4956
|
-
status: hasCommandError || uiResult.status === "error" ? "error" : "rendered",
|
|
5165
|
+
status: options.skipped ? "skipped" : hasCommandError || uiResult.status === "error" ? "error" : "rendered",
|
|
5166
|
+
remediation: options.remediation ?? "none",
|
|
4957
5167
|
// Contract metadata: renders target the active client and fresh tabs do not
|
|
4958
5168
|
// hydrate this injected state.
|
|
4959
5169
|
mode: "active-client",
|
|
@@ -4968,6 +5178,16 @@ function buildCompactInspectorRender(uiResult) {
|
|
|
4968
5178
|
...topLevelError
|
|
4969
5179
|
};
|
|
4970
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
|
+
}
|
|
4971
5191
|
function compactInspectorCommandResponse(value) {
|
|
4972
5192
|
if (!isRecord(value) || !isCompactInspectorCommandStatus(value.status)) {
|
|
4973
5193
|
return void 0;
|