@devlab.group/agent-commerce 2.7.2 → 2.8.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.
- package/README.md +71 -24
- package/dist/ap2.d.ts +3 -11
- package/dist/ap2.js +96 -27
- package/dist/ap2.js.map +1 -1
- package/dist/{chunk-77HLISG4.js → chunk-2PVRHMVT.js} +14 -10
- package/dist/chunk-2PVRHMVT.js.map +1 -0
- package/dist/chunk-ENK63GKR.js +22 -0
- package/dist/chunk-ENK63GKR.js.map +1 -0
- package/dist/{chunk-YHNTTMED.js → chunk-MDOGXTZD.js} +2 -2
- package/dist/chunk-MDOGXTZD.js.map +1 -0
- package/dist/chunk-MNI6APE6.js +64 -0
- package/dist/chunk-MNI6APE6.js.map +1 -0
- package/dist/{chunk-XXHC6AA3.js → chunk-QZW5YL3G.js} +160 -41
- package/dist/chunk-QZW5YL3G.js.map +1 -0
- package/dist/{chunk-DJRWYDKJ.js → chunk-RXYGC7A3.js} +3 -3
- package/dist/{chunk-DJRWYDKJ.js.map → chunk-RXYGC7A3.js.map} +1 -1
- package/dist/{chunk-5AO5N2XY.js → chunk-VHS6MGXJ.js} +621 -4
- package/dist/chunk-VHS6MGXJ.js.map +1 -0
- package/dist/cli/{ap2-O3HJSS2E.js → ap2-GYKFGE66.js} +35 -8
- package/dist/cli/ap2-GYKFGE66.js.map +1 -0
- package/dist/cli/chunk-2PO65227.js +619 -0
- package/dist/cli/chunk-2PO65227.js.map +1 -0
- package/dist/cli/{chunk-GBBG66O6.js → chunk-3PGFOEVJ.js} +132 -103
- package/dist/cli/chunk-3PGFOEVJ.js.map +1 -0
- package/dist/cli/chunk-4YZULHX2.js +64 -0
- package/dist/cli/chunk-4YZULHX2.js.map +1 -0
- package/dist/cli/chunk-526C4KZA.js +93 -0
- package/dist/cli/chunk-526C4KZA.js.map +1 -0
- package/dist/cli/{chunk-FETTSOMT.js → chunk-5CH5VFC6.js} +139 -4
- package/dist/cli/chunk-5CH5VFC6.js.map +1 -0
- package/dist/cli/chunk-6BWEHQPJ.js +215 -0
- package/dist/cli/chunk-6BWEHQPJ.js.map +1 -0
- package/dist/cli/chunk-GISJ73ML.js +20 -0
- package/dist/cli/chunk-GISJ73ML.js.map +1 -0
- package/dist/cli/chunk-MASLG557.js +26 -0
- package/dist/cli/chunk-MASLG557.js.map +1 -0
- package/dist/cli/chunk-RQ7W3NA5.js +143 -0
- package/dist/cli/chunk-RQ7W3NA5.js.map +1 -0
- package/dist/cli/chunk-RWBUHDU7.js +48 -0
- package/dist/cli/chunk-RWBUHDU7.js.map +1 -0
- package/dist/cli/chunk-SAAT2XFX.js +8 -0
- package/dist/cli/{chunk-B4QJV7OC.js.map → chunk-SAAT2XFX.js.map} +1 -1
- package/dist/cli/{chunk-S5TQXKQ7.js → chunk-SYXLQ5BS.js} +7 -5
- package/dist/cli/chunk-SYXLQ5BS.js.map +1 -0
- package/dist/cli/{chunk-FL4HPCD4.js → chunk-THH7Y3OO.js} +3 -35
- package/dist/cli/chunk-THH7Y3OO.js.map +1 -0
- package/dist/cli/{chunk-55AI6CLW.js → chunk-USIXWAXZ.js} +2 -2
- package/dist/cli/chunk-USIXWAXZ.js.map +1 -0
- package/dist/cli/{chunk-QUFFT5K3.js → chunk-VWQMSWDF.js} +141 -42
- package/dist/cli/chunk-VWQMSWDF.js.map +1 -0
- package/dist/cli/{chunk-OETKXDGA.js → chunk-WFIR374D.js} +89 -272
- package/dist/cli/chunk-WFIR374D.js.map +1 -0
- package/dist/cli/{chunk-XRG5UTIC.js → chunk-YXXPZFWC.js} +4 -4
- package/dist/cli/{chunk-XRG5UTIC.js.map → chunk-YXXPZFWC.js.map} +1 -1
- package/dist/cli/config-JWMHWVRT.js +14 -0
- package/dist/cli/{config-ODN4IEMZ.js.map → config-JWMHWVRT.js.map} +1 -1
- package/dist/cli/index.js +349 -78
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/{mcp-G2D2Z77G.js → mcp-OW5GY7TT.js} +84 -45
- package/dist/cli/mcp-OW5GY7TT.js.map +1 -0
- package/dist/cli/payment-providers-QL2BJYMD.js +6 -0
- package/dist/cli/{payment-providers-7RIIZ5OF.js.map → payment-providers-QL2BJYMD.js.map} +1 -1
- package/dist/cli/{provider-ARV3VAQ7.js → provider-3A2LVEQS.js} +145 -23
- package/dist/cli/provider-3A2LVEQS.js.map +1 -0
- package/dist/cli/receipts-FQUFGEQD.js +9 -0
- package/dist/cli/{receipts-HLQ7D722.js.map → receipts-FQUFGEQD.js.map} +1 -1
- package/dist/cli/{run-BHODKC6H.js → run-KF5OQYPL.js} +92 -63
- package/dist/cli/run-KF5OQYPL.js.map +1 -0
- package/dist/cli/{x402-LHW2YQ6W.js → x402-5A7CVCIJ.js} +12 -8
- package/dist/cli/x402-5A7CVCIJ.js.map +1 -0
- package/dist/index.d.ts +36 -12
- package/dist/index.js +340 -394
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +80 -42
- package/dist/mcp.js.map +1 -1
- package/dist/mpp.d.ts +3 -2
- package/dist/mpp.js +139 -20
- package/dist/mpp.js.map +1 -1
- package/dist/{protocol-adapter-DdFL5LBU.d.ts → protocol-adapter-D6JH_kk-.d.ts} +2 -2
- package/dist/{runtime-BmaSp2Ce.d.ts → runtime-D8u6lYfx.d.ts} +10 -0
- package/dist/{store-DQwbKhnc.d.ts → store-BzgwHOPu.d.ts} +2 -2
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/{transaction-BXXJltZ-.d.ts → transaction-F9ZvhokH.d.ts} +1 -1
- package/dist/types-Dl27vhEc.d.ts +167 -0
- package/dist/x402.d.ts +7 -110
- package/dist/x402.js +6 -5
- package/dist/x402.js.map +1 -1
- package/package.json +3 -1
- package/dist/chunk-2573DASO.js +0 -8
- package/dist/chunk-2573DASO.js.map +0 -1
- package/dist/chunk-5AO5N2XY.js.map +0 -1
- package/dist/chunk-77HLISG4.js.map +0 -1
- package/dist/chunk-XXHC6AA3.js.map +0 -1
- package/dist/chunk-YHNTTMED.js.map +0 -1
- package/dist/cli/ap2-O3HJSS2E.js.map +0 -1
- package/dist/cli/chunk-3NVJAQRO.js +0 -119
- package/dist/cli/chunk-3NVJAQRO.js.map +0 -1
- package/dist/cli/chunk-55AI6CLW.js.map +0 -1
- package/dist/cli/chunk-66NTYSXI.js +0 -277
- package/dist/cli/chunk-66NTYSXI.js.map +0 -1
- package/dist/cli/chunk-B4QJV7OC.js +0 -8
- package/dist/cli/chunk-FETTSOMT.js.map +0 -1
- package/dist/cli/chunk-FL4HPCD4.js.map +0 -1
- package/dist/cli/chunk-GBBG66O6.js.map +0 -1
- package/dist/cli/chunk-H7EBJ4I3.js +0 -53
- package/dist/cli/chunk-H7EBJ4I3.js.map +0 -1
- package/dist/cli/chunk-OETKXDGA.js.map +0 -1
- package/dist/cli/chunk-QUFFT5K3.js.map +0 -1
- package/dist/cli/chunk-S5TQXKQ7.js.map +0 -1
- package/dist/cli/chunk-TPC4EJLT.js +0 -11
- package/dist/cli/chunk-TPC4EJLT.js.map +0 -1
- package/dist/cli/config-ODN4IEMZ.js +0 -13
- package/dist/cli/mcp-G2D2Z77G.js.map +0 -1
- package/dist/cli/payment-providers-7RIIZ5OF.js +0 -6
- package/dist/cli/provider-ARV3VAQ7.js.map +0 -1
- package/dist/cli/receipts-HLQ7D722.js +0 -9
- package/dist/cli/run-BHODKC6H.js.map +0 -1
- package/dist/cli/x402-LHW2YQ6W.js.map +0 -1
- package/dist/networks-DDHYJLcg.d.ts +0 -39
package/dist/cli/index.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { A2A_SPEC_VERSION, A2A_PROTOCOL_VERSION, A2A_PROTOCOL_BINDING, A2A_AGENT_CARD_PATH,
|
|
4
|
-
import { DEFAULT_CONFIG_FILENAME,
|
|
2
|
+
import { ap2_default } from './chunk-526C4KZA.js';
|
|
3
|
+
import { a2a_default, A2A_SPEC_VERSION, A2A_PROTOCOL_VERSION, A2A_PROTOCOL_BINDING, A2A_AGENT_CARD_PATH, acp_default } from './chunk-6BWEHQPJ.js';
|
|
4
|
+
import { DEFAULT_CONFIG_FILENAME, listEnvPlaceholders, ACP_SPEC_VERSION, ACP_API_VERSION, ACP_WELL_KNOWN_PATH } from './chunk-WFIR374D.js';
|
|
5
5
|
import { AP2_SPEC_VERSION, AP2_CHECKOUT_MANDATE_VCT, AP2_CHECKOUT_PROFILE } from './chunk-DKWO6LLX.js';
|
|
6
|
-
import { MCP_TOOL_NAME_MAX_LENGTH, MCP_TOOL_NAME_CHARS } from './chunk-
|
|
7
|
-
import { createSqliteReceiptStore, openSqliteReceiptStoreReadOnly, readMissingLegacyImports, SCHEMA_VERSION, hasTable } from './chunk-
|
|
6
|
+
import { publicEndpointUrl, MCP_TOOL_NAME_MAX_LENGTH, MCP_TOOL_NAME_CHARS } from './chunk-RWBUHDU7.js';
|
|
7
|
+
import { createSqliteReceiptStore, openSqliteReceiptStoreReadOnly, readMissingLegacyImports, SCHEMA_VERSION, hasTable } from './chunk-YXXPZFWC.js';
|
|
8
8
|
import './chunk-6EBDOH37.js';
|
|
9
9
|
import './chunk-APC5BTQM.js';
|
|
10
10
|
import { DEFAULT_RECONCILE_MIN_AGE_MS } from './chunk-VSSSU4AU.js';
|
|
11
11
|
import { MPP_PROFILE, MPP_SPEC_DRAFTS, MPPX_VERSION, MPP_SPEC_COMMIT, MPP_DEFAULT_PAYMENT_FLOW } from './chunk-AA3FIEAR.js';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
12
|
+
import { gotNoAnswer } from './chunk-MASLG557.js';
|
|
13
|
+
import { x402_default } from './chunk-RQ7W3NA5.js';
|
|
14
|
+
import { featureStatus, exclusionNames } from './chunk-GISJ73ML.js';
|
|
15
|
+
import { ANVIL_WELL_KNOWN_ACCOUNTS, extractPathParameterNames, describeDeploymentMode, X402_DEFAULT_PAYMENT_FLOW, findX402Network, isEvmAddress, LOCAL_CHAIN_ID, resolveDeploymentMode, findUnparsedBraceToken, sameAddress } from './chunk-2PO65227.js';
|
|
16
|
+
import { PACKAGE_VERSION } from './chunk-SAAT2XFX.js';
|
|
17
|
+
import { PROTOCOL_NAMES, systemClock, NOOP_LOGGER } from './chunk-USIXWAXZ.js';
|
|
15
18
|
import { isCommerceError, redactedErrorText, CommerceError } from './chunk-C5YISPT6.js';
|
|
16
19
|
import { isRecord } from './chunk-3M6U7ILB.js';
|
|
17
20
|
import { CommanderError, Command } from 'commander';
|
|
@@ -31,7 +34,7 @@ import { userInfo } from 'os';
|
|
|
31
34
|
// src/cli/lib/config-client.ts
|
|
32
35
|
async function importConfig() {
|
|
33
36
|
try {
|
|
34
|
-
return await import('./config-
|
|
37
|
+
return await import('./config-JWMHWVRT.js');
|
|
35
38
|
} catch (err) {
|
|
36
39
|
throw new CommerceError(
|
|
37
40
|
"INTERNAL_ERROR",
|
|
@@ -42,6 +45,9 @@ async function importConfig() {
|
|
|
42
45
|
async function loadConfigDynamic(options = {}) {
|
|
43
46
|
return (await importConfig()).loadConfig(options);
|
|
44
47
|
}
|
|
48
|
+
async function readConfigFileDynamic(options = {}) {
|
|
49
|
+
return (await importConfig()).readConfigFile(options);
|
|
50
|
+
}
|
|
45
51
|
async function parseConfigDynamic(raw, env = process.env) {
|
|
46
52
|
return (await importConfig()).parseConfig(raw, env);
|
|
47
53
|
}
|
|
@@ -388,10 +394,17 @@ async function fetchJson(fetchImpl, url, timeoutMs = 1500) {
|
|
|
388
394
|
return {
|
|
389
395
|
ok: false,
|
|
390
396
|
status: 0,
|
|
391
|
-
error: err
|
|
397
|
+
error: errorText(err),
|
|
398
|
+
...gotNoAnswer(err) ? { noAnswer: true } : {}
|
|
392
399
|
};
|
|
393
400
|
}
|
|
394
401
|
}
|
|
402
|
+
function errorText(err) {
|
|
403
|
+
if (!(err instanceof Error)) return "unknown fetch error";
|
|
404
|
+
let root = err;
|
|
405
|
+
for (let depth = 0; depth < 10 && root.cause instanceof Error; depth++) root = root.cause;
|
|
406
|
+
return root === err ? err.message : `${err.message}: ${root.message}`;
|
|
407
|
+
}
|
|
395
408
|
|
|
396
409
|
// package.json
|
|
397
410
|
var package_default = {
|
|
@@ -454,6 +467,17 @@ function readVersionReport() {
|
|
|
454
467
|
});
|
|
455
468
|
return { cliVersion: PACKAGE_VERSION, pinned };
|
|
456
469
|
}
|
|
470
|
+
|
|
471
|
+
// src/cli/commands/doctor/types.ts
|
|
472
|
+
function undeterminedField(reason) {
|
|
473
|
+
return reason !== void 0 ? { undetermined: reason } : {};
|
|
474
|
+
}
|
|
475
|
+
var SKIPPED_CONFIG_INVALID = {
|
|
476
|
+
detail: "skipped: config invalid",
|
|
477
|
+
undetermined: "skipped"
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
// src/cli/commands/doctor/storage.ts
|
|
457
481
|
function isWritableFile(path) {
|
|
458
482
|
try {
|
|
459
483
|
accessSync(path, constants.W_OK);
|
|
@@ -528,7 +552,7 @@ function refusedSchema(err) {
|
|
|
528
552
|
async function storageChecks(config, openStore) {
|
|
529
553
|
if (config === void 0) {
|
|
530
554
|
return {
|
|
531
|
-
checks: [{ name: "Storage", status: "WARN",
|
|
555
|
+
checks: [{ name: "Storage", status: "WARN", ...SKIPPED_CONFIG_INVALID }],
|
|
532
556
|
legacy: void 0
|
|
533
557
|
};
|
|
534
558
|
}
|
|
@@ -656,14 +680,14 @@ function ap2Checks(config, legacy) {
|
|
|
656
680
|
const checks = [];
|
|
657
681
|
const ap2 = config?.authorization?.ap2;
|
|
658
682
|
if (config === void 0) {
|
|
659
|
-
checks.push({ name: "AP2", status: "WARN",
|
|
683
|
+
checks.push({ name: "AP2", status: "WARN", ...SKIPPED_CONFIG_INVALID });
|
|
660
684
|
} else if (ap2 === void 0 || !ap2.enabled) {
|
|
661
685
|
checks.push({ name: "AP2", status: "INFO", detail: "disabled" });
|
|
662
686
|
} else {
|
|
663
687
|
checks.push({
|
|
664
688
|
name: "AP2",
|
|
665
689
|
status: "PASS",
|
|
666
|
-
detail:
|
|
690
|
+
detail: `${ap2_default.status} \xB7 spec ${AP2_SPEC_VERSION} \xB7 mode ${ap2.mode} \xB7 ${AP2_CHECKOUT_MANDATE_VCT} \xB7 profile ${AP2_CHECKOUT_PROFILE} \xB7 clock skew ${ap2.clockSkewSeconds}s \xB7 mandate aud ${ap2.requireMandateAudience === true ? "required" : "optional"} \xB7 mandate exp ${ap2.requireMandateExpiry === true ? "required" : "optional"}`
|
|
667
691
|
});
|
|
668
692
|
checks.push({
|
|
669
693
|
name: "AP2 trust",
|
|
@@ -690,7 +714,7 @@ function ap2Checks(config, legacy) {
|
|
|
690
714
|
checks.push({
|
|
691
715
|
name: "AP2 unsupported",
|
|
692
716
|
status: "INFO",
|
|
693
|
-
detail:
|
|
717
|
+
detail: exclusionNames(ap2_default).join(", ")
|
|
694
718
|
});
|
|
695
719
|
}
|
|
696
720
|
return checks;
|
|
@@ -821,13 +845,14 @@ function maskMiddle(value, keep = 6) {
|
|
|
821
845
|
}
|
|
822
846
|
|
|
823
847
|
// src/cli/commands/doctor/payments.ts
|
|
848
|
+
var QUOTE_STATUS = featureStatus(x402_default, "erc-8409-quotes");
|
|
824
849
|
function describePaymentFlow(rail, defaultFlow) {
|
|
825
850
|
const overrides = Object.keys(rail.resourcePaymentFlows ?? {}).length;
|
|
826
851
|
const overrideCount = overrides > 0 ? ` (${overrides} resource ${overrides === 1 ? "override" : "overrides"})` : "";
|
|
827
852
|
return `paymentFlow=${rail.paymentFlow ?? defaultFlow}${overrideCount}`;
|
|
828
853
|
}
|
|
829
854
|
function readOffer(rec, rail) {
|
|
830
|
-
const { asset, network, assetDecimals, assetTransferMethod, status } = rec;
|
|
855
|
+
const { asset, network, assetDecimals, assetTransferMethod, status, undetermined } = rec;
|
|
831
856
|
const payTo = rec[rail === "mpp" ? "recipient" : "payTo"];
|
|
832
857
|
if (typeof asset !== "string" || typeof network !== "string" || typeof payTo !== "string") {
|
|
833
858
|
return void 0;
|
|
@@ -838,7 +863,8 @@ function readOffer(rec, rail) {
|
|
|
838
863
|
payTo,
|
|
839
864
|
...typeof assetDecimals === "number" ? { assetDecimals } : {},
|
|
840
865
|
...typeof assetTransferMethod === "string" ? { assetTransferMethod } : {},
|
|
841
|
-
...typeof status === "string" ? { status } : {}
|
|
866
|
+
...typeof status === "string" ? { status } : {},
|
|
867
|
+
...undetermined === "unreachable" ? { undetermined } : {}
|
|
842
868
|
};
|
|
843
869
|
}
|
|
844
870
|
function readOffers(value, rail) {
|
|
@@ -963,7 +989,7 @@ function railOffer(option) {
|
|
|
963
989
|
...assetTransferMethod !== void 0 ? { assetTransferMethod } : {}
|
|
964
990
|
};
|
|
965
991
|
}
|
|
966
|
-
function offerHealthCheck(live, named) {
|
|
992
|
+
function offerHealthCheck(live, named, name) {
|
|
967
993
|
const all = [...live.offers, ...Object.values(live.resourceOffers ?? {}).flat()];
|
|
968
994
|
const offers = [
|
|
969
995
|
...new Map(
|
|
@@ -979,7 +1005,7 @@ function offerHealthCheck(live, named) {
|
|
|
979
1005
|
).join("; ");
|
|
980
1006
|
if (failing.length === 0 && degraded.length === 0) {
|
|
981
1007
|
return {
|
|
982
|
-
name
|
|
1008
|
+
name,
|
|
983
1009
|
status: "PASS",
|
|
984
1010
|
detail: `${reported.length} offer(s) pass their health checks`
|
|
985
1011
|
};
|
|
@@ -988,10 +1014,12 @@ function offerHealthCheck(live, named) {
|
|
|
988
1014
|
...failing.length > 0 ? [`failing: ${describe2(failing)}`] : [],
|
|
989
1015
|
...degraded.length > 0 ? [`degraded: ${describe2(degraded)}`] : []
|
|
990
1016
|
];
|
|
1017
|
+
const unanswered = [...failing, ...degraded].every((offer) => offer.undetermined !== void 0);
|
|
991
1018
|
return {
|
|
992
|
-
name
|
|
1019
|
+
name,
|
|
993
1020
|
status: failing.length > 0 ? "FAIL" : "WARN",
|
|
994
|
-
detail: `${problems.join("; ")}. The gateway logs each reason at debug level
|
|
1021
|
+
detail: `${problems.join("; ")}. The gateway logs each reason at debug level`,
|
|
1022
|
+
...undeterminedField(unanswered ? "unreachable" : void 0)
|
|
995
1023
|
};
|
|
996
1024
|
}
|
|
997
1025
|
function extractLiveQuote(body) {
|
|
@@ -1016,7 +1044,7 @@ async function localQuoteIssuer(signerPrivateKey, loadAccounts) {
|
|
|
1016
1044
|
return "invalid";
|
|
1017
1045
|
}
|
|
1018
1046
|
}
|
|
1019
|
-
function quoteCheck(enabled, local, live, body, gatewayUrl, stale) {
|
|
1047
|
+
function quoteCheck(enabled, local, live, body, gatewayUrl, stale, liveCause) {
|
|
1020
1048
|
const name = "Payments (quotes)";
|
|
1021
1049
|
if (enabled && local === "invalid") {
|
|
1022
1050
|
return {
|
|
@@ -1031,7 +1059,8 @@ function quoteCheck(enabled, local, live, body, gatewayUrl, stale) {
|
|
|
1031
1059
|
return enabled ? {
|
|
1032
1060
|
name,
|
|
1033
1061
|
status: "INFO",
|
|
1034
|
-
detail: `ERC-8409 quotes enabled (
|
|
1062
|
+
detail: `ERC-8409 quotes enabled (${QUOTE_STATUS})${localIssuer !== void 0 ? `, issuer=${localIssuer} from the local key` : ""}; the gateway's issuer could not be read`,
|
|
1063
|
+
...undeterminedField(liveCause)
|
|
1035
1064
|
} : void 0;
|
|
1036
1065
|
}
|
|
1037
1066
|
if (quote === void 0) {
|
|
@@ -1059,14 +1088,16 @@ function quoteCheck(enabled, local, live, body, gatewayUrl, stale) {
|
|
|
1059
1088
|
return {
|
|
1060
1089
|
name,
|
|
1061
1090
|
status: "PASS",
|
|
1062
|
-
detail: `ERC-8409 quotes (
|
|
1091
|
+
detail: `ERC-8409 quotes (${QUOTE_STATUS}) - issuer=${issuer}${local === void 0 ? " as the gateway publishes it (viem could not be loaded to check it against the local key)" : ""}, requestScheme=${quote.requestScheme}, extension=${quote.extension}`
|
|
1063
1092
|
};
|
|
1064
1093
|
}
|
|
1065
|
-
async function paymentChecks(config, wellKnown, gatewayUrl, chainDeploy = false, loadAccounts = () => import('viem/accounts')) {
|
|
1094
|
+
async function paymentChecks(config, wellKnown, gatewayUrl, chainDeploy = false, loadAccounts = () => import('viem/accounts'), liveCause) {
|
|
1066
1095
|
const checks = [];
|
|
1067
1096
|
const stale = `; the gateway may be running against an older deployment - restart it${chainDeploy ? " or re-run chain:deploy" : ""}`;
|
|
1068
1097
|
const x402 = config?.payments.x402;
|
|
1069
|
-
if (
|
|
1098
|
+
if (config === void 0) {
|
|
1099
|
+
checks.push({ name: "Payments", status: "INFO", ...SKIPPED_CONFIG_INVALID });
|
|
1100
|
+
} else if (x402 === void 0 || !x402.enabled) {
|
|
1070
1101
|
checks.push({ name: "Payments", status: "INFO", detail: "x402 not configured" });
|
|
1071
1102
|
} else {
|
|
1072
1103
|
const options = x402.options ?? [x402];
|
|
@@ -1097,7 +1128,8 @@ async function paymentChecks(config, wellKnown, gatewayUrl, chainDeploy = false,
|
|
|
1097
1128
|
checks.push({
|
|
1098
1129
|
name: "Payments",
|
|
1099
1130
|
status: "INFO",
|
|
1100
|
-
detail: `${summary} (gateway's live settlement config could not be verified)
|
|
1131
|
+
detail: `${summary} (gateway's live settlement config could not be verified)`,
|
|
1132
|
+
...undeterminedField(liveCause)
|
|
1101
1133
|
});
|
|
1102
1134
|
} else {
|
|
1103
1135
|
const configured = {
|
|
@@ -1114,7 +1146,7 @@ async function paymentChecks(config, wellKnown, gatewayUrl, chainDeploy = false,
|
|
|
1114
1146
|
checks.push(
|
|
1115
1147
|
mismatch === void 0 ? { name: "Payments", status: "PASS", detail: summary } : { name: "Payments", status: "FAIL", detail: `${mismatch}${stale}` }
|
|
1116
1148
|
);
|
|
1117
|
-
const offerHealth = offerHealthCheck(live, named);
|
|
1149
|
+
const offerHealth = offerHealthCheck(live, named, "Payments (offers)");
|
|
1118
1150
|
if (offerHealth !== void 0) checks.push(offerHealth);
|
|
1119
1151
|
}
|
|
1120
1152
|
const quotes = quoteCheck(
|
|
@@ -1123,7 +1155,8 @@ async function paymentChecks(config, wellKnown, gatewayUrl, chainDeploy = false,
|
|
|
1123
1155
|
live,
|
|
1124
1156
|
wellKnown?.ok ? wellKnown.body : void 0,
|
|
1125
1157
|
gatewayUrl,
|
|
1126
|
-
stale
|
|
1158
|
+
stale,
|
|
1159
|
+
liveCause
|
|
1127
1160
|
);
|
|
1128
1161
|
if (quotes !== void 0) checks.push(quotes);
|
|
1129
1162
|
if (mode === "mainnet") {
|
|
@@ -1139,7 +1172,9 @@ async function paymentChecks(config, wellKnown, gatewayUrl, chainDeploy = false,
|
|
|
1139
1172
|
}
|
|
1140
1173
|
}
|
|
1141
1174
|
const mpp = config?.payments.mpp;
|
|
1142
|
-
if (
|
|
1175
|
+
if (config === void 0) {
|
|
1176
|
+
checks.push({ name: "Payments (MPP)", status: "INFO", ...SKIPPED_CONFIG_INVALID });
|
|
1177
|
+
} else if (mpp === void 0 || !mpp.enabled) {
|
|
1143
1178
|
checks.push({ name: "Payments (MPP)", status: "INFO", detail: "MPP not configured" });
|
|
1144
1179
|
} else {
|
|
1145
1180
|
const { mode, where, via } = describeSettlement(mpp.network, mpp.facilitator);
|
|
@@ -1167,13 +1202,20 @@ async function paymentChecks(config, wellKnown, gatewayUrl, chainDeploy = false,
|
|
|
1167
1202
|
checks.push({
|
|
1168
1203
|
name: "Payments (MPP)",
|
|
1169
1204
|
status: "INFO",
|
|
1170
|
-
detail: `${summary} (live MPP settlement config unavailable for comparison)
|
|
1205
|
+
detail: `${summary} (live MPP settlement config unavailable for comparison)`,
|
|
1206
|
+
...undeterminedField(liveCause)
|
|
1171
1207
|
});
|
|
1172
1208
|
} else {
|
|
1173
1209
|
const mismatch = findRailMismatch(configured, live, "recipient");
|
|
1174
1210
|
checks.push(
|
|
1175
1211
|
mismatch === void 0 ? { name: "Payments (MPP)", status: "PASS", detail: summary } : { name: "Payments (MPP)", status: "FAIL", detail: `${mismatch}${stale}` }
|
|
1176
1212
|
);
|
|
1213
|
+
const offerHealth = offerHealthCheck(
|
|
1214
|
+
live,
|
|
1215
|
+
(network) => `${findX402Network(network)?.displayName ?? "unknown network"} (${network})`,
|
|
1216
|
+
"Payments (MPP offers)"
|
|
1217
|
+
);
|
|
1218
|
+
if (offerHealth !== void 0) checks.push(offerHealth);
|
|
1177
1219
|
}
|
|
1178
1220
|
if (mode === "mainnet") {
|
|
1179
1221
|
checks.push(
|
|
@@ -1216,12 +1258,17 @@ function acpMappingCheck(config, operations) {
|
|
|
1216
1258
|
detail: `5 operations mapped to free acp-exposed resources (${Object.values(operations).join(", ")})`
|
|
1217
1259
|
};
|
|
1218
1260
|
}
|
|
1219
|
-
function protocolChecks(config, wellKnown, legacy) {
|
|
1261
|
+
function protocolChecks(config, wellKnown, legacy, liveCause) {
|
|
1220
1262
|
const checks = [];
|
|
1221
1263
|
if (config === void 0) {
|
|
1222
|
-
checks.push({ name: "Protocols", status: "WARN",
|
|
1264
|
+
checks.push({ name: "Protocols", status: "WARN", ...SKIPPED_CONFIG_INVALID });
|
|
1223
1265
|
} else if (wellKnown === void 0 || !wellKnown.ok) {
|
|
1224
|
-
checks.push({
|
|
1266
|
+
checks.push({
|
|
1267
|
+
name: "Protocols",
|
|
1268
|
+
status: "FAIL",
|
|
1269
|
+
detail: wellKnown === void 0 || wellKnown.status === 0 ? "well-known document unreachable" : `well-known document unavailable (HTTP ${wellKnown.status})`,
|
|
1270
|
+
...undeterminedField(liveCause)
|
|
1271
|
+
});
|
|
1225
1272
|
} else {
|
|
1226
1273
|
const mcpMountPath = config.protocols.mcp.enabled ? config.protocols.mcp.mountPath : void 0;
|
|
1227
1274
|
const a2aMountPath = config.protocols.a2a.enabled ? config.protocols.a2a.mountPath : void 0;
|
|
@@ -1232,23 +1279,23 @@ function protocolChecks(config, wellKnown, legacy) {
|
|
|
1232
1279
|
});
|
|
1233
1280
|
}
|
|
1234
1281
|
if (config === void 0) {
|
|
1235
|
-
checks.push({ name: "A2A", status: "WARN",
|
|
1282
|
+
checks.push({ name: "A2A", status: "WARN", ...SKIPPED_CONFIG_INVALID });
|
|
1236
1283
|
} else if (!config.protocols.a2a.enabled) {
|
|
1237
1284
|
checks.push({ name: "A2A", status: "INFO", detail: "disabled" });
|
|
1238
1285
|
} else {
|
|
1239
1286
|
checks.push({
|
|
1240
1287
|
name: "A2A",
|
|
1241
1288
|
status: "PASS",
|
|
1242
|
-
detail:
|
|
1289
|
+
detail: `${a2a_default.status} \xB7 spec ${A2A_SPEC_VERSION} \xB7 protocol ${A2A_PROTOCOL_VERSION} \xB7 binding ${A2A_PROTOCOL_BINDING} \xB7 mount ${config.protocols.a2a.mountPath} \xB7 card ${A2A_AGENT_CARD_PATH}`
|
|
1243
1290
|
});
|
|
1244
1291
|
checks.push({
|
|
1245
1292
|
name: "A2A unsupported",
|
|
1246
1293
|
status: "INFO",
|
|
1247
|
-
detail:
|
|
1294
|
+
detail: exclusionNames(a2a_default).join(", ")
|
|
1248
1295
|
});
|
|
1249
1296
|
}
|
|
1250
1297
|
if (config === void 0) {
|
|
1251
|
-
checks.push({ name: "ACP", status: "WARN",
|
|
1298
|
+
checks.push({ name: "ACP", status: "WARN", ...SKIPPED_CONFIG_INVALID });
|
|
1252
1299
|
} else if (!config.protocols.acp.enabled) {
|
|
1253
1300
|
checks.push({ name: "ACP", status: "INFO", detail: "disabled" });
|
|
1254
1301
|
} else {
|
|
@@ -1256,7 +1303,7 @@ function protocolChecks(config, wellKnown, legacy) {
|
|
|
1256
1303
|
checks.push({
|
|
1257
1304
|
name: "ACP",
|
|
1258
1305
|
status: "PASS",
|
|
1259
|
-
detail:
|
|
1306
|
+
detail: `${acp_default.status} \xB7 spec ${ACP_SPEC_VERSION} \xB7 API-Version ${ACP_API_VERSION} \xB7 service checkout \xB7 mount ${acp.mountPath} \xB7 discovery ${ACP_WELL_KNOWN_PATH}`
|
|
1260
1307
|
});
|
|
1261
1308
|
checks.push({
|
|
1262
1309
|
name: "ACP auth",
|
|
@@ -1277,11 +1324,160 @@ function protocolChecks(config, wellKnown, legacy) {
|
|
|
1277
1324
|
checks.push({
|
|
1278
1325
|
name: "ACP unsupported",
|
|
1279
1326
|
status: "INFO",
|
|
1280
|
-
detail:
|
|
1327
|
+
detail: exclusionNames(acp_default).join(", ")
|
|
1281
1328
|
});
|
|
1282
1329
|
}
|
|
1283
1330
|
return checks;
|
|
1284
1331
|
}
|
|
1332
|
+
|
|
1333
|
+
// src/cli/lib/mcp-registry.ts
|
|
1334
|
+
var SERVER_JSON_SCHEMA = "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json";
|
|
1335
|
+
function serverJson(config) {
|
|
1336
|
+
const { mcp } = config.protocols;
|
|
1337
|
+
const problems = [];
|
|
1338
|
+
if (!mcp.enabled) {
|
|
1339
|
+
problems.push({
|
|
1340
|
+
key: "protocols.mcp.enabled",
|
|
1341
|
+
message: "is false: the listing would name a server that does not run"
|
|
1342
|
+
});
|
|
1343
|
+
}
|
|
1344
|
+
if (mcp.registry === void 0) {
|
|
1345
|
+
problems.push({
|
|
1346
|
+
key: "protocols.mcp.registry",
|
|
1347
|
+
message: "is not set: it holds the listing name, version and description"
|
|
1348
|
+
});
|
|
1349
|
+
}
|
|
1350
|
+
const url = remoteUrl(config.merchant.publicBaseUrl, mcp.mountPath);
|
|
1351
|
+
if ("problem" in url) problems.push({ key: "merchant.publicBaseUrl", message: url.problem });
|
|
1352
|
+
if (mcp.registry === void 0 || "problem" in url || problems.length > 0) {
|
|
1353
|
+
return { problems };
|
|
1354
|
+
}
|
|
1355
|
+
return {
|
|
1356
|
+
document: {
|
|
1357
|
+
$schema: SERVER_JSON_SCHEMA,
|
|
1358
|
+
name: mcp.registry.name,
|
|
1359
|
+
description: mcp.registry.description,
|
|
1360
|
+
version: mcp.registry.version,
|
|
1361
|
+
remotes: [{ type: "streamable-http", url: url.url }]
|
|
1362
|
+
}
|
|
1363
|
+
};
|
|
1364
|
+
}
|
|
1365
|
+
function remoteUrl(publicBaseUrl, mountPath) {
|
|
1366
|
+
let url;
|
|
1367
|
+
try {
|
|
1368
|
+
url = publicEndpointUrl(publicBaseUrl, mountPath);
|
|
1369
|
+
} catch {
|
|
1370
|
+
return { problem: "is not a URL" };
|
|
1371
|
+
}
|
|
1372
|
+
const parsed = new URL(url);
|
|
1373
|
+
if (parsed.protocol !== "https:") {
|
|
1374
|
+
return { problem: "must be an https:// URL: the MCP Registry refuses others" };
|
|
1375
|
+
}
|
|
1376
|
+
const host = parsed.hostname;
|
|
1377
|
+
if (host === "localhost" || host === "127.0.0.1" || host.endsWith(".localhost")) {
|
|
1378
|
+
return { problem: `names ${host}, which the MCP Registry refuses` };
|
|
1379
|
+
}
|
|
1380
|
+
return { url };
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
// src/cli/commands/doctor/registry.ts
|
|
1384
|
+
var MCP_REGISTRY_URL = "https://registry.modelcontextprotocol.io";
|
|
1385
|
+
var NAME = "MCP Registry";
|
|
1386
|
+
var REGISTRY_TIMEOUT_MS = 5e3;
|
|
1387
|
+
var OFFICIAL_META = "io.modelcontextprotocol.registry/official";
|
|
1388
|
+
async function registryCheck(config, fetchImpl) {
|
|
1389
|
+
if (config === void 0) return { name: NAME, status: "WARN", ...SKIPPED_CONFIG_INVALID };
|
|
1390
|
+
if (config.protocols.mcp.registry === void 0) {
|
|
1391
|
+
return { name: NAME, status: "INFO", detail: "protocols.mcp.registry not configured" };
|
|
1392
|
+
}
|
|
1393
|
+
const built = serverJson(config);
|
|
1394
|
+
if ("problems" in built) {
|
|
1395
|
+
return {
|
|
1396
|
+
name: NAME,
|
|
1397
|
+
status: "WARN",
|
|
1398
|
+
detail: built.problems.map((problem) => `${problem.key} ${problem.message}`).join("; ")
|
|
1399
|
+
};
|
|
1400
|
+
}
|
|
1401
|
+
const local = built.document;
|
|
1402
|
+
const answer = await fetchJson(
|
|
1403
|
+
fetchImpl,
|
|
1404
|
+
`${MCP_REGISTRY_URL}/v0.1/servers/${encodeURIComponent(local.name)}/versions/latest?include_deleted=true`,
|
|
1405
|
+
REGISTRY_TIMEOUT_MS
|
|
1406
|
+
);
|
|
1407
|
+
if (answer.status === 0) {
|
|
1408
|
+
return answer.noAnswer === true ? {
|
|
1409
|
+
name: NAME,
|
|
1410
|
+
status: "WARN",
|
|
1411
|
+
detail: "no answer from the registry",
|
|
1412
|
+
undetermined: "unreachable"
|
|
1413
|
+
} : { name: NAME, status: "WARN", detail: "the registry request failed" };
|
|
1414
|
+
}
|
|
1415
|
+
if (answer.status === 404) {
|
|
1416
|
+
return { name: NAME, status: "WARN", detail: `${local.name} is not listed` };
|
|
1417
|
+
}
|
|
1418
|
+
if (!answer.ok || !isRecord(answer.body) || !isRecord(answer.body["server"])) {
|
|
1419
|
+
return {
|
|
1420
|
+
name: NAME,
|
|
1421
|
+
status: "WARN",
|
|
1422
|
+
detail: answer.ok ? "the registry answer is not a server listing" : `the registry answered HTTP ${answer.status}`
|
|
1423
|
+
};
|
|
1424
|
+
}
|
|
1425
|
+
const problems = [
|
|
1426
|
+
...lifecycle(answer.body["_meta"]),
|
|
1427
|
+
...differences(answer.body["server"], local)
|
|
1428
|
+
];
|
|
1429
|
+
return problems.length === 0 ? {
|
|
1430
|
+
name: NAME,
|
|
1431
|
+
status: "PASS",
|
|
1432
|
+
detail: `${local.name} ${local.version} is listed as configured`
|
|
1433
|
+
} : { name: NAME, status: "WARN", detail: `${local.name}: ${problems.join("; ")}` };
|
|
1434
|
+
}
|
|
1435
|
+
function lifecycle(meta) {
|
|
1436
|
+
const official = isRecord(meta) ? meta[OFFICIAL_META] : void 0;
|
|
1437
|
+
const status = isRecord(official) ? official["status"] : void 0;
|
|
1438
|
+
if (status === "active") return [];
|
|
1439
|
+
if (status === "deprecated" || status === "deleted") return [`listing is ${status}`];
|
|
1440
|
+
return ["listing has no known status"];
|
|
1441
|
+
}
|
|
1442
|
+
function differences(listed, local) {
|
|
1443
|
+
const fields = ["name", "version", "description"].filter(
|
|
1444
|
+
(field) => listed[field] !== local[field]
|
|
1445
|
+
);
|
|
1446
|
+
const remotes = listed["remotes"];
|
|
1447
|
+
const remote = Array.isArray(remotes) && remotes.length === 1 ? remotes[0] : void 0;
|
|
1448
|
+
const sameRemote = isRecord(remote) && remote["type"] === local.remotes[0].type && remote["url"] === local.remotes[0].url;
|
|
1449
|
+
const differing = sameRemote ? fields : [...fields, "remotes"];
|
|
1450
|
+
return differing.length > 0 ? [`listing differs from config in ${differing.join(", ")}`] : [];
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
// src/cli/commands/doctor/secrets.ts
|
|
1454
|
+
async function secretsCheck(read, path, env) {
|
|
1455
|
+
let raw;
|
|
1456
|
+
try {
|
|
1457
|
+
raw = await read({ ...path !== void 0 ? { path } : {}, env });
|
|
1458
|
+
} catch {
|
|
1459
|
+
return {
|
|
1460
|
+
name: "Secrets",
|
|
1461
|
+
status: "WARN",
|
|
1462
|
+
detail: "skipped: config file unreadable",
|
|
1463
|
+
undetermined: "skipped"
|
|
1464
|
+
};
|
|
1465
|
+
}
|
|
1466
|
+
const { missing, set, defaulted } = listEnvPlaceholders(raw, env);
|
|
1467
|
+
const groups = [
|
|
1468
|
+
...missing.length > 0 ? [`${missing.length} missing (${missing.join(", ")})`] : [],
|
|
1469
|
+
...set.length > 0 ? [`${set.length} set (${set.join(", ")})`] : [],
|
|
1470
|
+
...defaulted.length > 0 ? [`${defaulted.length} defaulted (${defaulted.join(", ")})`] : []
|
|
1471
|
+
];
|
|
1472
|
+
if (groups.length === 0) {
|
|
1473
|
+
return { name: "Secrets", status: "INFO", detail: "config reads no environment variable" };
|
|
1474
|
+
}
|
|
1475
|
+
return {
|
|
1476
|
+
name: "Secrets",
|
|
1477
|
+
status: missing.length > 0 ? "FAIL" : "PASS",
|
|
1478
|
+
detail: groups.join("; ")
|
|
1479
|
+
};
|
|
1480
|
+
}
|
|
1285
1481
|
function statusColor(status, text2) {
|
|
1286
1482
|
switch (status) {
|
|
1287
1483
|
case "PASS":
|
|
@@ -1301,7 +1497,8 @@ function printDoctorReport(report, io, json) {
|
|
|
1301
1497
|
}
|
|
1302
1498
|
for (const check of report.checks) {
|
|
1303
1499
|
const label = statusColor(check.status, check.status.padEnd(5));
|
|
1304
|
-
|
|
1500
|
+
const mark = check.undetermined !== void 0 ? ` [not determined: ${check.undetermined}]` : "";
|
|
1501
|
+
io.stdout(`${label} ${check.name.padEnd(20)} ${check.detail}${mark}`);
|
|
1305
1502
|
}
|
|
1306
1503
|
io.stdout("");
|
|
1307
1504
|
io.stdout(`Score: ${report.score.passed}/${report.score.total} checks passed`);
|
|
@@ -1355,18 +1552,26 @@ async function runDoctor(options, deps = {}) {
|
|
|
1355
1552
|
detail: `${err instanceof Error ? err.message : String(err)}${hint}`
|
|
1356
1553
|
});
|
|
1357
1554
|
}
|
|
1555
|
+
const readConfigFile = deps.readConfigFile ?? (deps.loadConfig === void 0 ? readConfigFileDynamic : void 0);
|
|
1556
|
+
if (readConfigFile !== void 0) {
|
|
1557
|
+
checks.push(await secretsCheck(readConfigFile, options.configPath, env));
|
|
1558
|
+
}
|
|
1358
1559
|
const gatewayUrl = deriveGatewayUrl(options.gatewayUrl, config);
|
|
1359
1560
|
const health = await fetchJson(fetchImpl, `${gatewayUrl}/health`, CHECK_TIMEOUT_MS);
|
|
1360
1561
|
let gatewayUp = false;
|
|
1562
|
+
let liveCause;
|
|
1361
1563
|
if (!health.ok) {
|
|
1564
|
+
liveCause = health.noAnswer ? "unreachable" : "skipped";
|
|
1362
1565
|
checks.push({
|
|
1363
1566
|
name: "Gateway",
|
|
1364
1567
|
status: "FAIL",
|
|
1365
|
-
detail: `unreachable at ${gatewayUrl} (${health.error ?? `HTTP ${health.status}
|
|
1568
|
+
detail: health.status === 0 ? `unreachable at ${gatewayUrl} (${health.error ?? "no answer"})` : `unhealthy at ${gatewayUrl} (HTTP ${health.status})`,
|
|
1569
|
+
...undeterminedField(health.noAnswer ? "unreachable" : void 0)
|
|
1366
1570
|
});
|
|
1367
1571
|
} else {
|
|
1368
1572
|
const ready = await fetchJson(fetchImpl, `${gatewayUrl}/ready`, CHECK_TIMEOUT_MS);
|
|
1369
1573
|
if (ready.status === 403) {
|
|
1574
|
+
liveCause = "skipped";
|
|
1370
1575
|
checks.push({
|
|
1371
1576
|
name: "Gateway",
|
|
1372
1577
|
status: "FAIL",
|
|
@@ -1378,13 +1583,14 @@ async function runDoctor(options, deps = {}) {
|
|
|
1378
1583
|
ready.ok ? { name: "Gateway", status: "PASS", detail: `healthy and ready at ${gatewayUrl}` } : {
|
|
1379
1584
|
name: "Gateway",
|
|
1380
1585
|
status: "WARN",
|
|
1381
|
-
detail: `healthy but not ready at ${gatewayUrl} (${ready.error ?? `HTTP ${ready.status}`})
|
|
1586
|
+
detail: `healthy but not ready at ${gatewayUrl} (${ready.error ?? `HTTP ${ready.status}`})`,
|
|
1587
|
+
...undeterminedField(ready.noAnswer ? "unreachable" : void 0)
|
|
1382
1588
|
}
|
|
1383
1589
|
);
|
|
1384
1590
|
}
|
|
1385
1591
|
}
|
|
1386
1592
|
if (config === void 0) {
|
|
1387
|
-
checks.push({ name: "Backend", status: "WARN",
|
|
1593
|
+
checks.push({ name: "Backend", status: "WARN", ...SKIPPED_CONFIG_INVALID });
|
|
1388
1594
|
} else if (config.resources.length === 0) {
|
|
1389
1595
|
checks.push({ name: "Backend", status: "INFO", detail: "no resources configured" });
|
|
1390
1596
|
} else {
|
|
@@ -1393,12 +1599,16 @@ async function runDoctor(options, deps = {}) {
|
|
|
1393
1599
|
const results = await Promise.all(
|
|
1394
1600
|
urls.map((url) => fetchJson(fetchImpl, url, CHECK_TIMEOUT_MS))
|
|
1395
1601
|
);
|
|
1396
|
-
const
|
|
1602
|
+
const unreached = results.filter((r) => r.status === 0);
|
|
1603
|
+
const reachable = urls.length - unreached.length;
|
|
1397
1604
|
const status = reachable === urls.length ? "PASS" : reachable === 0 ? "FAIL" : "WARN";
|
|
1398
1605
|
checks.push({
|
|
1399
1606
|
name: "Backend",
|
|
1400
1607
|
status,
|
|
1401
|
-
detail: `${reachable}/${urls.length} backend host(s) reachable
|
|
1608
|
+
detail: `${reachable}/${urls.length} backend host(s) reachable`,
|
|
1609
|
+
...undeterminedField(
|
|
1610
|
+
unreached.length > 0 && unreached.every((r) => r.noAnswer) ? "unreachable" : void 0
|
|
1611
|
+
)
|
|
1402
1612
|
});
|
|
1403
1613
|
}
|
|
1404
1614
|
const wellKnown = gatewayUp ? await fetchJson(
|
|
@@ -1406,11 +1616,19 @@ async function runDoctor(options, deps = {}) {
|
|
|
1406
1616
|
`${gatewayUrl}/.well-known/agent-commerce`,
|
|
1407
1617
|
CHECK_TIMEOUT_MS
|
|
1408
1618
|
) : void 0;
|
|
1619
|
+
if (wellKnown !== void 0) liveCause = wellKnown.noAnswer ? "unreachable" : void 0;
|
|
1409
1620
|
const storage = await storageChecks(config, createStore);
|
|
1410
|
-
checks.push(...protocolChecks(config, wellKnown, storage.legacy));
|
|
1621
|
+
checks.push(...protocolChecks(config, wellKnown, storage.legacy, liveCause));
|
|
1411
1622
|
checks.push(...ap2Checks(config, storage.legacy));
|
|
1412
1623
|
checks.push(
|
|
1413
|
-
...await paymentChecks(
|
|
1624
|
+
...await paymentChecks(
|
|
1625
|
+
config,
|
|
1626
|
+
wellKnown,
|
|
1627
|
+
gatewayUrl,
|
|
1628
|
+
chainDeploy,
|
|
1629
|
+
deps.loadViemAccounts,
|
|
1630
|
+
liveCause
|
|
1631
|
+
)
|
|
1414
1632
|
);
|
|
1415
1633
|
checks.push(...storage.checks);
|
|
1416
1634
|
if (wellKnown?.ok) {
|
|
@@ -1424,14 +1642,63 @@ async function runDoctor(options, deps = {}) {
|
|
|
1424
1642
|
checks.push({
|
|
1425
1643
|
name: "Protocol versions",
|
|
1426
1644
|
status: "INFO",
|
|
1427
|
-
detail:
|
|
1645
|
+
detail: `${liveCause === "unreachable" ? "gateway unreachable" : "gateway versions unavailable"}; local pins: ${local.pinned.map((p) => `${p.name}@${p.version}`).join(", ")}`,
|
|
1646
|
+
...undeterminedField(liveCause)
|
|
1428
1647
|
});
|
|
1429
1648
|
}
|
|
1649
|
+
if (options.registry === true) checks.push(await registryCheck(config, fetchImpl));
|
|
1430
1650
|
const scored = checks.filter((c) => c.status !== "INFO");
|
|
1431
1651
|
const passed = scored.filter((c) => c.status === "PASS").length;
|
|
1432
1652
|
const exitCode = checks.some((c) => c.status === "FAIL") ? 1 : 0;
|
|
1433
1653
|
return { checks, score: { passed, total: scored.length }, exitCode };
|
|
1434
1654
|
}
|
|
1655
|
+
async function writeAtomically(outputPath, content) {
|
|
1656
|
+
const target = resolve(outputPath);
|
|
1657
|
+
const temporary = `${target}.${process.pid}.tmp`;
|
|
1658
|
+
try {
|
|
1659
|
+
await mkdir(dirname(target), { recursive: true });
|
|
1660
|
+
await writeFile(temporary, content, "utf8");
|
|
1661
|
+
await rename(temporary, target);
|
|
1662
|
+
} catch (error) {
|
|
1663
|
+
await rm(temporary, { force: true });
|
|
1664
|
+
throw error;
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
// src/cli/commands/export-mcp-registry.ts
|
|
1669
|
+
async function runExportMcpRegistry(options, io, deps = {}) {
|
|
1670
|
+
const { output } = options;
|
|
1671
|
+
if (existsSync(output) && options.force !== true) {
|
|
1672
|
+
io.stderr(`FAIL ${output} already exists. Re-run with --force to overwrite.`);
|
|
1673
|
+
return 1;
|
|
1674
|
+
}
|
|
1675
|
+
let config;
|
|
1676
|
+
try {
|
|
1677
|
+
config = await (deps.loadConfig ?? loadConfigDynamic)(
|
|
1678
|
+
options.configPath !== void 0 ? { path: options.configPath } : {}
|
|
1679
|
+
);
|
|
1680
|
+
} catch (error) {
|
|
1681
|
+
io.stderr(formatConfigError(error, false, false));
|
|
1682
|
+
return 1;
|
|
1683
|
+
}
|
|
1684
|
+
const result = serverJson(config);
|
|
1685
|
+
if ("problems" in result) {
|
|
1686
|
+
for (const problem of result.problems) io.stderr(`FAIL ${problem.key} ${problem.message}`);
|
|
1687
|
+
return 1;
|
|
1688
|
+
}
|
|
1689
|
+
try {
|
|
1690
|
+
await writeAtomically(output, `${JSON.stringify(result.document, null, 2)}
|
|
1691
|
+
`);
|
|
1692
|
+
} catch (error) {
|
|
1693
|
+
io.stderr(
|
|
1694
|
+
`FAIL ${output} could not be written: ${error instanceof Error ? error.message : String(error)}`
|
|
1695
|
+
);
|
|
1696
|
+
return 1;
|
|
1697
|
+
}
|
|
1698
|
+
io.stdout(`Wrote ${output} for ${result.document.name} ${result.document.version}.`);
|
|
1699
|
+
io.stdout("Publish it with mcp-publisher after verifying the namespace.");
|
|
1700
|
+
return 0;
|
|
1701
|
+
}
|
|
1435
1702
|
|
|
1436
1703
|
// src/openapi/refs.ts
|
|
1437
1704
|
var MAX_REF_DEPTH = 100;
|
|
@@ -2497,7 +2764,7 @@ async function runImportOpenApi(options, io, deps = {}) {
|
|
|
2497
2764
|
const wrote = failures.length === 0;
|
|
2498
2765
|
if (wrote) {
|
|
2499
2766
|
try {
|
|
2500
|
-
await writeAtomically(outputPath, renderResourcesYaml(result)
|
|
2767
|
+
await (deps.writeFile ?? writeAtomically)(outputPath, renderResourcesYaml(result));
|
|
2501
2768
|
} catch (error) {
|
|
2502
2769
|
io.stderr(`FAIL ${outputPath} could not be written: ${describe(error)}`);
|
|
2503
2770
|
return 1;
|
|
@@ -2550,22 +2817,6 @@ function buildPolicy(options) {
|
|
|
2550
2817
|
}
|
|
2551
2818
|
return policy;
|
|
2552
2819
|
}
|
|
2553
|
-
async function writeAtomically(outputPath, content, deps) {
|
|
2554
|
-
if (deps.writeFile !== void 0) {
|
|
2555
|
-
await deps.writeFile(outputPath, content);
|
|
2556
|
-
return;
|
|
2557
|
-
}
|
|
2558
|
-
const target = resolve(outputPath);
|
|
2559
|
-
const temporary = `${target}.${process.pid}.tmp`;
|
|
2560
|
-
try {
|
|
2561
|
-
await mkdir(dirname(target), { recursive: true });
|
|
2562
|
-
await writeFile(temporary, content, "utf8");
|
|
2563
|
-
await rename(temporary, target);
|
|
2564
|
-
} catch (error) {
|
|
2565
|
-
await rm(temporary, { force: true });
|
|
2566
|
-
throw error;
|
|
2567
|
-
}
|
|
2568
|
-
}
|
|
2569
2820
|
function printSummary(result, context, io) {
|
|
2570
2821
|
const skipped = result.diagnostics.filter((entry) => entry.severity === "error");
|
|
2571
2822
|
const warnings = result.diagnostics.filter((entry) => entry.severity === "warning");
|
|
@@ -2754,7 +3005,7 @@ async function runReconcileCommand(options, io, deps = {}) {
|
|
|
2754
3005
|
try {
|
|
2755
3006
|
const logger = stderrLogger(io);
|
|
2756
3007
|
const { runReconcile } = await import('./reconcile-GS25MQ42.js');
|
|
2757
|
-
const providers = await (await import('./payment-providers-
|
|
3008
|
+
const providers = await (await import('./payment-providers-QL2BJYMD.js')).createConfiguredPaymentProviders(config.payments, logger);
|
|
2758
3009
|
let report;
|
|
2759
3010
|
await withJournal(config, logger, async (store, authorizationProviders) => {
|
|
2760
3011
|
report = await runReconcile({
|
|
@@ -2787,8 +3038,8 @@ async function withJournal(config, logger, fn) {
|
|
|
2787
3038
|
{ createConfiguredAuthorizationProviders },
|
|
2788
3039
|
{ createSqliteReceiptStore: createSqliteReceiptStore2, openSqliteReceiptStoreReadOnly: openSqliteReceiptStoreReadOnly2 }
|
|
2789
3040
|
] = await Promise.all([
|
|
2790
|
-
import('./payment-providers-
|
|
2791
|
-
import('./receipts-
|
|
3041
|
+
import('./payment-providers-QL2BJYMD.js'),
|
|
3042
|
+
import('./receipts-FQUFGEQD.js')
|
|
2792
3043
|
]);
|
|
2793
3044
|
const path = config.storage.receipts.path;
|
|
2794
3045
|
if (path !== ":memory:" && existsSync(path)) {
|
|
@@ -3016,7 +3267,7 @@ var ENV_FILE_HELP = "load environment variables from this file; variables alread
|
|
|
3016
3267
|
function buildProgram(io = processIo) {
|
|
3017
3268
|
const program = new Command();
|
|
3018
3269
|
program.name("agent-commerce").description(
|
|
3019
|
-
"CLI for the Agent Commerce Gateway: init, import, validate, start, doctor, reconcile, backup, demo."
|
|
3270
|
+
"CLI for the Agent Commerce Gateway: init, import, export, validate, start, doctor, reconcile, backup, demo."
|
|
3020
3271
|
).version(readVersionReport().cliVersion, "-v, --version", "Print the CLI version.").exitOverride().configureOutput({
|
|
3021
3272
|
writeOut: (str) => io.stdout(str.replace(/\n+$/, "")),
|
|
3022
3273
|
writeErr: (str) => io.stderr(str.replace(/\n+$/, ""))
|
|
@@ -3045,7 +3296,7 @@ function buildProgram(io = processIo) {
|
|
|
3045
3296
|
`Start the gateway from ${DEFAULT_CONFIG_FILENAME} and serve until SIGTERM or SIGINT.`
|
|
3046
3297
|
).option("--config <path>", `path to ${DEFAULT_CONFIG_FILENAME}`).option("--env-file <path>", ENV_FILE_HELP).action(async (opts) => {
|
|
3047
3298
|
try {
|
|
3048
|
-
const { runGateway } = await import('./run-
|
|
3299
|
+
const { runGateway } = await import('./run-KF5OQYPL.js');
|
|
3049
3300
|
await runGateway(opts.config !== void 0 ? { configPath: opts.config } : {});
|
|
3050
3301
|
} catch (error) {
|
|
3051
3302
|
io.stderr(formatConfigError(error, false, false));
|
|
@@ -3055,14 +3306,21 @@ function buildProgram(io = processIo) {
|
|
|
3055
3306
|
program.command("doctor").description("Diagnose config, gateway, backend, protocol and payment health.").option("--config <path>", `path to ${DEFAULT_CONFIG_FILENAME}`).option("--env-file <path>", ENV_FILE_HELP).option(
|
|
3056
3307
|
"--gateway <url>",
|
|
3057
3308
|
"gateway base URL (default: derived from config, else http://localhost:8080)"
|
|
3058
|
-
).option("--json", "emit machine-readable JSON instead of a formatted report", false).
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3309
|
+
).option("--json", "emit machine-readable JSON instead of a formatted report", false).option(
|
|
3310
|
+
"--registry",
|
|
3311
|
+
"also compare the MCP Registry listing named in protocols.mcp.registry with config (calls registry.modelcontextprotocol.io)",
|
|
3312
|
+
false
|
|
3313
|
+
).action(
|
|
3314
|
+
async (opts) => {
|
|
3315
|
+
const report = await runDoctor({
|
|
3316
|
+
...opts.config !== void 0 ? { configPath: opts.config } : {},
|
|
3317
|
+
...opts.gateway !== void 0 ? { gatewayUrl: opts.gateway } : {},
|
|
3318
|
+
registry: opts.registry
|
|
3319
|
+
});
|
|
3320
|
+
printDoctorReport(report, io, opts.json === true);
|
|
3321
|
+
process.exitCode = report.exitCode;
|
|
3322
|
+
}
|
|
3323
|
+
);
|
|
3066
3324
|
program.command("reconcile").description(
|
|
3067
3325
|
"Resolve uncertain payment attempts using chain evidence. Never settles or refunds."
|
|
3068
3326
|
).option("--config <path>", `path to ${DEFAULT_CONFIG_FILENAME}`).option("--env-file <path>", ENV_FILE_HELP).option("--dry-run", "read evidence and report without recording resolutions", false).option("--json", "emit machine-readable JSON instead of a formatted report", false).option("--actor <name>", "who ran it, stored with each resolution (default: the OS user)").option(
|
|
@@ -3149,6 +3407,19 @@ function buildProgram(io = processIo) {
|
|
|
3149
3407
|
);
|
|
3150
3408
|
}
|
|
3151
3409
|
);
|
|
3410
|
+
const exportCommand = program.command("export").description("Generate catalog listings for the gateway from config.");
|
|
3411
|
+
exportCommand.command("mcp-registry").description(
|
|
3412
|
+
"Write server.json for the MCP Registry from protocols.mcp.registry (experimental)."
|
|
3413
|
+
).option("--config <path>", `path to ${DEFAULT_CONFIG_FILENAME}`).option("--env-file <path>", ENV_FILE_HELP).option("--output <path>", "output path", "server.json").option("--force", "overwrite an existing output file", false).action(async (opts) => {
|
|
3414
|
+
process.exitCode = await runExportMcpRegistry(
|
|
3415
|
+
{
|
|
3416
|
+
...opts.config !== void 0 ? { configPath: opts.config } : {},
|
|
3417
|
+
output: opts.output,
|
|
3418
|
+
force: opts.force
|
|
3419
|
+
},
|
|
3420
|
+
io
|
|
3421
|
+
);
|
|
3422
|
+
});
|
|
3152
3423
|
program.command("demo").description(
|
|
3153
3424
|
"Start the local stack with docker compose (waiting for healthy services), then run the demo agent. Run it from a repo clone."
|
|
3154
3425
|
).action(async () => {
|