@mcpjam/cli 3.2.1 → 3.2.2
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 +233 -62
- 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.2.
|
|
15
|
+
version: "3.2.2"};
|
|
16
16
|
|
|
17
17
|
// src/lib/output.ts
|
|
18
18
|
var DEFAULT_OUTPUT_FORMAT = "json";
|
|
@@ -582,7 +582,8 @@ function assertNoCredentialsFileAuthConflicts(options) {
|
|
|
582
582
|
}
|
|
583
583
|
function redactCredentialsFromResult(result, credentialsFilePath) {
|
|
584
584
|
const redacted = redactSensitiveValue(result);
|
|
585
|
-
const credentials = result.credentials;
|
|
585
|
+
const credentials = result.credentials ?? {};
|
|
586
|
+
const hasCredentials = Object.keys(credentials).length > 0;
|
|
586
587
|
const secretMarker = credentialsFilePath ? "[SAVED_TO_FILE]" : "[REDACTED]";
|
|
587
588
|
const redactedCredentials = {
|
|
588
589
|
...redacted.credentials ?? {},
|
|
@@ -595,26 +596,29 @@ function redactCredentialsFromResult(result, credentialsFilePath) {
|
|
|
595
596
|
};
|
|
596
597
|
return {
|
|
597
598
|
...redacted,
|
|
598
|
-
credentials: redactedCredentials,
|
|
599
|
+
...hasCredentials ? { credentials: redactedCredentials } : {},
|
|
599
600
|
...credentialsFilePath ? { credentialsFile: credentialsFilePath } : {}
|
|
600
601
|
};
|
|
601
602
|
}
|
|
602
603
|
function hasCredentialsToSave(result) {
|
|
603
|
-
return Boolean(
|
|
604
|
+
return Boolean(
|
|
605
|
+
result.credentials?.accessToken || result.credentials?.refreshToken
|
|
606
|
+
);
|
|
604
607
|
}
|
|
605
608
|
function buildCredentialsFileContents(result, now) {
|
|
606
609
|
if (!hasCredentialsToSave(result)) {
|
|
607
|
-
throw usageError("OAuth
|
|
610
|
+
throw usageError("OAuth flow did not return usable credentials to save.");
|
|
608
611
|
}
|
|
609
|
-
const
|
|
612
|
+
const credentials = result.credentials ?? {};
|
|
613
|
+
const expiresAt = typeof credentials.expiresIn === "number" && Number.isFinite(credentials.expiresIn) ? new Date(now.getTime() + credentials.expiresIn * 1e3).toISOString() : void 0;
|
|
610
614
|
return {
|
|
611
615
|
version: CREDENTIALS_FILE_VERSION,
|
|
612
616
|
serverUrl: result.serverUrl,
|
|
613
|
-
...
|
|
614
|
-
...
|
|
615
|
-
...
|
|
616
|
-
...
|
|
617
|
-
...
|
|
617
|
+
...credentials.accessToken ? { accessToken: credentials.accessToken } : {},
|
|
618
|
+
...credentials.refreshToken ? { refreshToken: credentials.refreshToken } : {},
|
|
619
|
+
...credentials.clientId ? { clientId: credentials.clientId } : {},
|
|
620
|
+
...credentials.clientSecret ? { clientSecret: credentials.clientSecret } : {},
|
|
621
|
+
...credentials.tokenType ? { tokenType: credentials.tokenType } : {},
|
|
618
622
|
...expiresAt ? { expiresAt } : {},
|
|
619
623
|
...result.protocolVersion ? { protocolVersion: result.protocolVersion } : {}
|
|
620
624
|
};
|
|
@@ -788,7 +792,7 @@ function addSharedServerOptions(command) {
|
|
|
788
792
|
"OAuth client secret used with --refresh-token"
|
|
789
793
|
).option(
|
|
790
794
|
"--credentials-file <path>",
|
|
791
|
-
"Load OAuth credentials from a file created by oauth login --credentials-out"
|
|
795
|
+
"Load OAuth credentials from a file created by oauth login or oauth conformance --credentials-out"
|
|
792
796
|
).option(
|
|
793
797
|
"--header <header>",
|
|
794
798
|
'HTTP header in "Key: Value" format. Repeat to send multiple headers.',
|
|
@@ -1243,7 +1247,7 @@ function registerProtocolCommands(program) {
|
|
|
1243
1247
|
const protocol = program.command("protocol").description("MCP protocol inspection and conformance checks");
|
|
1244
1248
|
protocol.command("conformance").description("Run MCP protocol conformance checks against an HTTP server").requiredOption("--url <url>", "MCP server URL").option("--access-token <token>", "Bearer access token for HTTP servers").option(
|
|
1245
1249
|
"--credentials-file <path>",
|
|
1246
|
-
"Load OAuth access token from a file created by oauth login --credentials-out"
|
|
1250
|
+
"Load OAuth access token from a file created by oauth login or oauth conformance --credentials-out"
|
|
1247
1251
|
).option(
|
|
1248
1252
|
"--header <header>",
|
|
1249
1253
|
'HTTP header in "Key: Value" format. Repeat to send multiple headers.',
|
|
@@ -1359,21 +1363,49 @@ function parseOAuthOutputFormat(value) {
|
|
|
1359
1363
|
function resolveOAuthOutputFormat(value, isTTY) {
|
|
1360
1364
|
return parseOAuthOutputFormat(value ?? (isTTY ? "human" : "json"));
|
|
1361
1365
|
}
|
|
1362
|
-
function renderOAuthConformanceResult(result, format) {
|
|
1366
|
+
function renderOAuthConformanceResult(result, format, options = {}) {
|
|
1367
|
+
const redactedResult = redactOAuthConformanceResult(result, options);
|
|
1363
1368
|
switch (format) {
|
|
1364
1369
|
case "human":
|
|
1365
|
-
return formatOAuthConformanceHuman(
|
|
1370
|
+
return formatOAuthConformanceHuman(redactedResult);
|
|
1366
1371
|
case "json":
|
|
1367
|
-
return JSON.stringify(
|
|
1372
|
+
return JSON.stringify(redactedResult);
|
|
1368
1373
|
}
|
|
1369
1374
|
}
|
|
1370
|
-
function renderOAuthConformanceSuiteResult(result, format) {
|
|
1375
|
+
function renderOAuthConformanceSuiteResult(result, format, options = {}) {
|
|
1376
|
+
const redactedResult = redactOAuthConformanceSuiteResult(result, options);
|
|
1371
1377
|
switch (format) {
|
|
1372
1378
|
case "human":
|
|
1373
|
-
return formatOAuthConformanceSuiteHuman(
|
|
1379
|
+
return formatOAuthConformanceSuiteHuman(redactedResult);
|
|
1374
1380
|
case "json":
|
|
1375
|
-
return JSON.stringify(
|
|
1381
|
+
return JSON.stringify(redactedResult);
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
function redactOAuthConformanceResult(result, options) {
|
|
1385
|
+
if (options.credentialsFilePath && result.credentials) {
|
|
1386
|
+
return redactCredentialsFromResult(
|
|
1387
|
+
result,
|
|
1388
|
+
options.credentialsFilePath
|
|
1389
|
+
);
|
|
1390
|
+
}
|
|
1391
|
+
return redactSensitiveValue(result);
|
|
1392
|
+
}
|
|
1393
|
+
function redactOAuthConformanceSuiteResult(result, options) {
|
|
1394
|
+
const redacted = redactSensitiveValue(result);
|
|
1395
|
+
if (options.credentialsFilePath) {
|
|
1396
|
+
redacted.credentialsFile = options.credentialsFilePath;
|
|
1397
|
+
}
|
|
1398
|
+
const resultIndex = options.credentialsResultIndex;
|
|
1399
|
+
if (options.credentialsFilePath && resultIndex !== void 0 && result.results[resultIndex]?.credentials && redacted.results[resultIndex]) {
|
|
1400
|
+
redacted.results[resultIndex] = {
|
|
1401
|
+
...redacted.results[resultIndex],
|
|
1402
|
+
...redactCredentialsFromResult(
|
|
1403
|
+
result.results[resultIndex],
|
|
1404
|
+
options.credentialsFilePath
|
|
1405
|
+
)
|
|
1406
|
+
};
|
|
1376
1407
|
}
|
|
1408
|
+
return redacted;
|
|
1377
1409
|
}
|
|
1378
1410
|
async function writeCommandDebugArtifact(options, dependencies = {}) {
|
|
1379
1411
|
if (!options.outputPath) {
|
|
@@ -1774,6 +1806,9 @@ function registerOAuthCommands(program) {
|
|
|
1774
1806
|
).option(
|
|
1775
1807
|
"--conformance-checks",
|
|
1776
1808
|
"Run additional OAuth negative checks (invalid client, invalid redirect, token format) after the main flow"
|
|
1809
|
+
).option(
|
|
1810
|
+
"--credentials-out <path>",
|
|
1811
|
+
"Write OAuth credentials to <path> (mode 0600); stdout output has secret fields redacted to [SAVED_TO_FILE]"
|
|
1777
1812
|
).option(
|
|
1778
1813
|
"--print-url",
|
|
1779
1814
|
"In interactive mode, print the consent URL to stderr instead of launching a browser"
|
|
@@ -1785,9 +1820,26 @@ function registerOAuthCommands(program) {
|
|
|
1785
1820
|
const format = getOAuthConformanceFormat(command, reporter);
|
|
1786
1821
|
const config = buildOAuthConformanceConfig(options);
|
|
1787
1822
|
const result = await new OAuthConformanceTest(config).run();
|
|
1823
|
+
let credentialsFilePath;
|
|
1824
|
+
let credentialsFileError;
|
|
1825
|
+
if (options.credentialsOut && hasCredentialsToSave(result)) {
|
|
1826
|
+
try {
|
|
1827
|
+
credentialsFilePath = await writeCredentialsFile(
|
|
1828
|
+
options.credentialsOut,
|
|
1829
|
+
result
|
|
1830
|
+
);
|
|
1831
|
+
} catch (error) {
|
|
1832
|
+
credentialsFileError = error;
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1788
1835
|
writeOAuthOutput(
|
|
1789
|
-
reporter ? renderConformanceReporterResult(result, reporter) : renderOAuthConformanceResult(result, format
|
|
1836
|
+
reporter ? renderConformanceReporterResult(result, reporter) : renderOAuthConformanceResult(result, format, {
|
|
1837
|
+
credentialsFilePath
|
|
1838
|
+
})
|
|
1790
1839
|
);
|
|
1840
|
+
if (credentialsFileError) {
|
|
1841
|
+
throw credentialsFileError;
|
|
1842
|
+
}
|
|
1791
1843
|
if (!result.passed) {
|
|
1792
1844
|
setProcessExitCode(1);
|
|
1793
1845
|
}
|
|
@@ -1800,6 +1852,9 @@ function registerOAuthCommands(program) {
|
|
|
1800
1852
|
).option(
|
|
1801
1853
|
"--verify-call-tool <name>",
|
|
1802
1854
|
"Also call the named tool after listing"
|
|
1855
|
+
).option(
|
|
1856
|
+
"--credentials-out <path>",
|
|
1857
|
+
"Write OAuth credentials from the first flow that returns credentials to <path> (mode 0600)"
|
|
1803
1858
|
).option(
|
|
1804
1859
|
"--reporter <reporter>",
|
|
1805
1860
|
"Structured reporter output: json-summary or junit-xml"
|
|
@@ -1822,9 +1877,28 @@ function registerOAuthCommands(program) {
|
|
|
1822
1877
|
}
|
|
1823
1878
|
const suite = new OAuthConformanceSuite(config);
|
|
1824
1879
|
const result = await suite.run();
|
|
1880
|
+
const credentialsResultIndex = findCredentialsResultIndex(result);
|
|
1881
|
+
let credentialsFilePath;
|
|
1882
|
+
let credentialsFileError;
|
|
1883
|
+
if (options.credentialsOut && credentialsResultIndex !== void 0) {
|
|
1884
|
+
try {
|
|
1885
|
+
credentialsFilePath = await writeCredentialsFile(
|
|
1886
|
+
options.credentialsOut,
|
|
1887
|
+
result.results[credentialsResultIndex]
|
|
1888
|
+
);
|
|
1889
|
+
} catch (error) {
|
|
1890
|
+
credentialsFileError = error;
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1825
1893
|
writeOAuthOutput(
|
|
1826
|
-
reporter ? renderConformanceReporterResult(result, reporter) : renderOAuthConformanceSuiteResult(result, format
|
|
1894
|
+
reporter ? renderConformanceReporterResult(result, reporter) : renderOAuthConformanceSuiteResult(result, format, {
|
|
1895
|
+
credentialsFilePath,
|
|
1896
|
+
credentialsResultIndex
|
|
1897
|
+
})
|
|
1827
1898
|
);
|
|
1899
|
+
if (credentialsFileError) {
|
|
1900
|
+
throw credentialsFileError;
|
|
1901
|
+
}
|
|
1828
1902
|
if (!result.passed) {
|
|
1829
1903
|
setProcessExitCode(1);
|
|
1830
1904
|
}
|
|
@@ -1944,6 +2018,10 @@ function buildOAuthConformanceConfig(options, defaults) {
|
|
|
1944
2018
|
oauthConformanceChecks: options.conformanceChecks ?? false
|
|
1945
2019
|
};
|
|
1946
2020
|
}
|
|
2021
|
+
function findCredentialsResultIndex(result) {
|
|
2022
|
+
const index = result.results.findIndex(hasCredentialsToSave);
|
|
2023
|
+
return index >= 0 ? index : void 0;
|
|
2024
|
+
}
|
|
1947
2025
|
function buildOAuthLoginConfig(options, defaults) {
|
|
1948
2026
|
const serverUrl = options.url.trim();
|
|
1949
2027
|
assertValidUrl2(serverUrl, "server URL");
|
|
@@ -2397,7 +2475,7 @@ function registerServerCommands(program) {
|
|
|
2397
2475
|
"OAuth bearer access token for HTTP servers"
|
|
2398
2476
|
).option(
|
|
2399
2477
|
"--credentials-file <path>",
|
|
2400
|
-
"Load OAuth access token from a file created by oauth login --credentials-out"
|
|
2478
|
+
"Load OAuth access token from a file created by oauth login or oauth conformance --credentials-out"
|
|
2401
2479
|
).option(
|
|
2402
2480
|
"--header <header>",
|
|
2403
2481
|
'HTTP header in "Key: Value" format. Repeat to send multiple headers.',
|
|
@@ -3600,6 +3678,13 @@ function normalizeInspectorFrontendUrl(frontendUrl) {
|
|
|
3600
3678
|
return void 0;
|
|
3601
3679
|
}
|
|
3602
3680
|
}
|
|
3681
|
+
function normalizeExplicitInspectorFrontendUrl(frontendUrl) {
|
|
3682
|
+
const normalized = normalizeInspectorFrontendUrl(frontendUrl);
|
|
3683
|
+
if (!normalized) {
|
|
3684
|
+
throw operationalError(`Invalid Inspector frontend URL "${frontendUrl}".`);
|
|
3685
|
+
}
|
|
3686
|
+
return normalized;
|
|
3687
|
+
}
|
|
3603
3688
|
function canonicalizeInspectorFrontendUrl(baseUrl, frontendUrl) {
|
|
3604
3689
|
if (!frontendUrl) {
|
|
3605
3690
|
return void 0;
|
|
@@ -3621,43 +3706,90 @@ function getEffectiveUrlPort(url) {
|
|
|
3621
3706
|
}
|
|
3622
3707
|
return url.protocol === "https:" ? "443" : "80";
|
|
3623
3708
|
}
|
|
3624
|
-
async function resolveInspectorBrowserBaseUrl(baseUrl, frontendUrl) {
|
|
3625
|
-
const
|
|
3709
|
+
async function resolveInspectorBrowserBaseUrl(baseUrl, frontendUrl, options = {}) {
|
|
3710
|
+
const fastResolution = await resolveInspectorBrowserBaseUrlFast(
|
|
3626
3711
|
baseUrl,
|
|
3627
|
-
|
|
3712
|
+
frontendUrl
|
|
3628
3713
|
);
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
const advertisedCandidate2 = await inspectInspectorFrontendCandidate(
|
|
3632
|
-
baseUrl,
|
|
3633
|
-
normalizedFrontendUrl,
|
|
3634
|
-
"advertised"
|
|
3635
|
-
);
|
|
3636
|
-
candidates.push(advertisedCandidate2);
|
|
3637
|
-
if (isUsableInspectorFrontendCandidate(advertisedCandidate2)) {
|
|
3638
|
-
return advertisedCandidate2.url;
|
|
3639
|
-
}
|
|
3714
|
+
if (fastResolution.browserBaseUrl) {
|
|
3715
|
+
return fastResolution.browserBaseUrl;
|
|
3640
3716
|
}
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
baseUrl
|
|
3644
|
-
"base"
|
|
3645
|
-
);
|
|
3646
|
-
candidates.push(baseCandidate);
|
|
3647
|
-
if (isUsableInspectorFrontendCandidate(baseCandidate)) {
|
|
3648
|
-
return baseCandidate.url;
|
|
3717
|
+
if (options.skipDiscovery) {
|
|
3718
|
+
assertFastFrontendMismatch(fastResolution.candidates);
|
|
3719
|
+
return fastResolution.normalizedFrontendUrl ?? baseUrl;
|
|
3649
3720
|
}
|
|
3650
3721
|
const discoveredCandidates = await discoverLocalInspectorFrontendCandidates(
|
|
3651
3722
|
baseUrl,
|
|
3652
|
-
normalizedFrontendUrl
|
|
3723
|
+
fastResolution.normalizedFrontendUrl
|
|
3653
3724
|
);
|
|
3654
|
-
candidates.push(...discoveredCandidates);
|
|
3655
3725
|
const usableDiscoveredCandidate = discoveredCandidates.find(
|
|
3656
3726
|
isUsableInspectorFrontendCandidate
|
|
3657
3727
|
);
|
|
3658
3728
|
if (usableDiscoveredCandidate) {
|
|
3659
3729
|
return usableDiscoveredCandidate.url;
|
|
3660
3730
|
}
|
|
3731
|
+
const candidates = [...fastResolution.candidates, ...discoveredCandidates];
|
|
3732
|
+
assertFullFrontendMismatch(candidates);
|
|
3733
|
+
return fastResolution.normalizedFrontendUrl ?? baseUrl;
|
|
3734
|
+
}
|
|
3735
|
+
async function resolveInspectorBrowserBaseUrlFast(baseUrl, frontendUrl) {
|
|
3736
|
+
const normalizedFrontendUrl = canonicalizeInspectorFrontendUrl(
|
|
3737
|
+
baseUrl,
|
|
3738
|
+
normalizeInspectorFrontendUrl(frontendUrl)
|
|
3739
|
+
);
|
|
3740
|
+
const targets = [];
|
|
3741
|
+
if (normalizedFrontendUrl) {
|
|
3742
|
+
targets.push({ source: "advertised", url: normalizedFrontendUrl });
|
|
3743
|
+
}
|
|
3744
|
+
if (!targets.some((target) => target.url === baseUrl)) {
|
|
3745
|
+
targets.push({ source: "base", url: baseUrl });
|
|
3746
|
+
}
|
|
3747
|
+
const candidates = await inspectInspectorFrontendCandidates(
|
|
3748
|
+
baseUrl,
|
|
3749
|
+
targets
|
|
3750
|
+
);
|
|
3751
|
+
const usableCandidate = candidates.find(isUsableInspectorFrontendCandidate);
|
|
3752
|
+
return {
|
|
3753
|
+
...usableCandidate ? { browserBaseUrl: usableCandidate.url } : {},
|
|
3754
|
+
candidates,
|
|
3755
|
+
...normalizedFrontendUrl ? { normalizedFrontendUrl } : {}
|
|
3756
|
+
};
|
|
3757
|
+
}
|
|
3758
|
+
async function inspectInspectorFrontendCandidates(apiBaseUrl, targets) {
|
|
3759
|
+
const settled = await Promise.allSettled(
|
|
3760
|
+
targets.map(
|
|
3761
|
+
(target) => inspectInspectorFrontendCandidate(apiBaseUrl, target.url, target.source)
|
|
3762
|
+
)
|
|
3763
|
+
);
|
|
3764
|
+
return settled.map((result, index) => {
|
|
3765
|
+
if (result.status === "fulfilled") {
|
|
3766
|
+
return result.value;
|
|
3767
|
+
}
|
|
3768
|
+
const target = targets[index];
|
|
3769
|
+
return {
|
|
3770
|
+
isFrontend: false,
|
|
3771
|
+
originStatus: "unknown",
|
|
3772
|
+
source: target.source,
|
|
3773
|
+
url: target.url
|
|
3774
|
+
};
|
|
3775
|
+
});
|
|
3776
|
+
}
|
|
3777
|
+
function assertFastFrontendMismatch(candidates) {
|
|
3778
|
+
const advertisedCandidate = candidates.find(
|
|
3779
|
+
(candidate) => candidate.source === "advertised"
|
|
3780
|
+
);
|
|
3781
|
+
const rejectedLiveCandidate = candidates.find(
|
|
3782
|
+
(candidate) => candidate.isFrontend && candidate.originStatus === "rejected"
|
|
3783
|
+
);
|
|
3784
|
+
if (!rejectedLiveCandidate) {
|
|
3785
|
+
return;
|
|
3786
|
+
}
|
|
3787
|
+
if (advertisedCandidate === rejectedLiveCandidate) {
|
|
3788
|
+
throw frontendMismatchError(void 0, rejectedLiveCandidate);
|
|
3789
|
+
}
|
|
3790
|
+
throw frontendMismatchError(advertisedCandidate, rejectedLiveCandidate);
|
|
3791
|
+
}
|
|
3792
|
+
function assertFullFrontendMismatch(candidates) {
|
|
3661
3793
|
const advertisedCandidate = candidates.find(
|
|
3662
3794
|
(candidate) => candidate.source === "advertised"
|
|
3663
3795
|
);
|
|
@@ -3673,11 +3805,12 @@ async function resolveInspectorBrowserBaseUrl(baseUrl, frontendUrl) {
|
|
|
3673
3805
|
if (rejectedLiveCandidate) {
|
|
3674
3806
|
throw frontendMismatchError(advertisedCandidate, rejectedLiveCandidate);
|
|
3675
3807
|
}
|
|
3676
|
-
return normalizedFrontendUrl ?? baseUrl;
|
|
3677
3808
|
}
|
|
3678
3809
|
async function resolveInspectorBrowserBaseUrlForHealth(baseUrl, frontendUrl, options) {
|
|
3679
3810
|
try {
|
|
3680
|
-
return await resolveInspectorBrowserBaseUrl(baseUrl, frontendUrl
|
|
3811
|
+
return await resolveInspectorBrowserBaseUrl(baseUrl, frontendUrl, {
|
|
3812
|
+
skipDiscovery: options.skipDiscovery
|
|
3813
|
+
});
|
|
3681
3814
|
} catch (error) {
|
|
3682
3815
|
if (options.hasActiveClient && !options.openBrowser) {
|
|
3683
3816
|
return canonicalizeInspectorFrontendUrl(
|
|
@@ -3690,16 +3823,14 @@ async function resolveInspectorBrowserBaseUrlForHealth(baseUrl, frontendUrl, opt
|
|
|
3690
3823
|
}
|
|
3691
3824
|
async function ensureInspector(options = {}) {
|
|
3692
3825
|
const baseUrl = normalizeInspectorBaseUrl(options.baseUrl);
|
|
3826
|
+
const explicitFrontendUrl = options.frontendUrl !== void 0 ? normalizeExplicitInspectorFrontendUrl(options.frontendUrl) : void 0;
|
|
3693
3827
|
const health = await getInspectorHealth(baseUrl);
|
|
3694
3828
|
if (health.healthy) {
|
|
3695
|
-
const browserBaseUrl2 = await resolveInspectorBrowserBaseUrlForHealth(
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
openBrowser: options.openBrowser === true
|
|
3701
|
-
}
|
|
3702
|
-
);
|
|
3829
|
+
const browserBaseUrl2 = explicitFrontendUrl ?? await resolveInspectorBrowserBaseUrlForHealth(baseUrl, health.frontendUrl, {
|
|
3830
|
+
hasActiveClient: health.hasActiveClient,
|
|
3831
|
+
openBrowser: options.openBrowser === true,
|
|
3832
|
+
skipDiscovery: options.skipDiscovery
|
|
3833
|
+
});
|
|
3703
3834
|
const url2 = buildInspectorUrl(browserBaseUrl2, options.tab);
|
|
3704
3835
|
if (options.openBrowser && !health.hasActiveClient) {
|
|
3705
3836
|
openUrl(url2);
|
|
@@ -3720,12 +3851,13 @@ async function ensureInspector(options = {}) {
|
|
|
3720
3851
|
await startInspector(baseUrl, options.timeoutMs ?? DEFAULT_START_TIMEOUT_MS);
|
|
3721
3852
|
clearInspectorSessionTokenCache(baseUrl);
|
|
3722
3853
|
const startedHealth = await getInspectorHealth(baseUrl);
|
|
3723
|
-
const browserBaseUrl = await resolveInspectorBrowserBaseUrlForHealth(
|
|
3854
|
+
const browserBaseUrl = explicitFrontendUrl ?? await resolveInspectorBrowserBaseUrlForHealth(
|
|
3724
3855
|
baseUrl,
|
|
3725
3856
|
startedHealth.frontendUrl,
|
|
3726
3857
|
{
|
|
3727
3858
|
hasActiveClient: startedHealth.hasActiveClient,
|
|
3728
|
-
openBrowser: options.openBrowser === true
|
|
3859
|
+
openBrowser: options.openBrowser === true,
|
|
3860
|
+
skipDiscovery: options.skipDiscovery
|
|
3729
3861
|
}
|
|
3730
3862
|
);
|
|
3731
3863
|
const url = buildInspectorUrl(browserBaseUrl, options.tab);
|
|
@@ -4074,10 +4206,12 @@ async function discoverLocalInspectorFrontendCandidates(baseUrl, frontendUrl) {
|
|
|
4074
4206
|
targets.push(candidate);
|
|
4075
4207
|
}
|
|
4076
4208
|
}
|
|
4077
|
-
const inspectedCandidates = await
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4209
|
+
const inspectedCandidates = await inspectInspectorFrontendCandidates(
|
|
4210
|
+
baseUrl,
|
|
4211
|
+
targets.map((candidate) => ({
|
|
4212
|
+
source: "discovered",
|
|
4213
|
+
url: candidate
|
|
4214
|
+
}))
|
|
4081
4215
|
);
|
|
4082
4216
|
return inspectedCandidates.filter((candidate) => candidate.isFrontend);
|
|
4083
4217
|
}
|
|
@@ -4275,7 +4409,9 @@ async function runUiRender(options) {
|
|
|
4275
4409
|
const client = new InspectorApiClient({ baseUrl: options.baseUrl });
|
|
4276
4410
|
const openBrowser = options.openBrowser === true;
|
|
4277
4411
|
const ensureResult = await client.ensure({
|
|
4412
|
+
frontendUrl: options.frontendUrl,
|
|
4278
4413
|
openBrowser,
|
|
4414
|
+
skipDiscovery: options.skipDiscovery,
|
|
4279
4415
|
startIfNeeded: options.startIfNeeded ?? true,
|
|
4280
4416
|
tab: "app-builder",
|
|
4281
4417
|
timeoutMs: options.timeoutMs
|
|
@@ -4525,6 +4661,9 @@ function registerToolsCommands(program) {
|
|
|
4525
4661
|
"--attach-only",
|
|
4526
4662
|
"Require an already-running Inspector browser client; do not start or open Inspector"
|
|
4527
4663
|
).option("--inspector-url <url>", "Local Inspector base URL (with --ui)").option(
|
|
4664
|
+
"--frontend-url <url>",
|
|
4665
|
+
"Inspector frontend URL (with --ui; overrides health-advertised frontend and skips discovery)"
|
|
4666
|
+
).option(
|
|
4528
4667
|
"--server-name <name>",
|
|
4529
4668
|
"Server name inside Inspector (with --ui)"
|
|
4530
4669
|
).option(
|
|
@@ -4583,6 +4722,7 @@ function registerToolsCommands(program) {
|
|
|
4583
4722
|
locale: trimOptional(options.locale),
|
|
4584
4723
|
timeZone: trimOptional(options.timeZone)
|
|
4585
4724
|
} : void 0;
|
|
4725
|
+
const frontendUrl = options.ui ? parseInspectorFrontendUrl(options.frontendUrl) : void 0;
|
|
4586
4726
|
let result;
|
|
4587
4727
|
let commandError;
|
|
4588
4728
|
const startedAt = Date.now();
|
|
@@ -4639,14 +4779,20 @@ function registerToolsCommands(program) {
|
|
|
4639
4779
|
if (options.ui) {
|
|
4640
4780
|
const serverName = typeof options.serverName === "string" && options.serverName.trim() ? options.serverName.trim() : buildInspectorServerName(options);
|
|
4641
4781
|
const openBrowser = resolveInspectorOpenBrowser(options, globalOptions);
|
|
4782
|
+
const skipDiscovery = resolveInspectorSkipDiscovery(
|
|
4783
|
+
options,
|
|
4784
|
+
globalOptions
|
|
4785
|
+
);
|
|
4642
4786
|
let uiResult;
|
|
4643
4787
|
try {
|
|
4644
4788
|
uiResult = await runUiRender({
|
|
4645
4789
|
baseUrl: options.inspectorUrl,
|
|
4646
4790
|
config,
|
|
4791
|
+
frontendUrl,
|
|
4647
4792
|
openBrowser,
|
|
4648
4793
|
params,
|
|
4649
4794
|
renderContext,
|
|
4795
|
+
skipDiscovery,
|
|
4650
4796
|
serverName,
|
|
4651
4797
|
startIfNeeded: resolveInspectorStartIfNeeded(options),
|
|
4652
4798
|
timeoutMs: globalOptions.timeout,
|
|
@@ -4750,6 +4896,31 @@ function resolveInspectorOpenBrowser(options, globalOptions) {
|
|
|
4750
4896
|
}
|
|
4751
4897
|
return globalOptions.format === "human" && !globalOptions.quiet;
|
|
4752
4898
|
}
|
|
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) {
|
|
4910
|
+
if (typeof options.frontendUrl === "string" && options.frontendUrl.trim()) {
|
|
4911
|
+
return true;
|
|
4912
|
+
}
|
|
4913
|
+
if (options.attachOnly) {
|
|
4914
|
+
return true;
|
|
4915
|
+
}
|
|
4916
|
+
if ((globalOptions.format === "json" || globalOptions.quiet) && options.open !== true) {
|
|
4917
|
+
return true;
|
|
4918
|
+
}
|
|
4919
|
+
if (options.open === true) {
|
|
4920
|
+
return false;
|
|
4921
|
+
}
|
|
4922
|
+
return false;
|
|
4923
|
+
}
|
|
4753
4924
|
function resolveInspectorStartIfNeeded(options) {
|
|
4754
4925
|
return options.attachOnly !== true;
|
|
4755
4926
|
}
|