@devlab.group/agent-commerce 2.7.2 → 2.9.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 +79 -30
- package/dist/ap2.d.ts +3 -11
- package/dist/ap2.js +97 -28
- 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-WDD2ZUR3.js → chunk-46Y5M7BA.js} +3 -2
- package/dist/chunk-46Y5M7BA.js.map +1 -0
- package/dist/{chunk-XXHC6AA3.js → chunk-5Q6W7YTK.js} +160 -41
- package/dist/chunk-5Q6W7YTK.js.map +1 -0
- package/dist/chunk-JF45GSNA.js +22 -0
- package/dist/chunk-JF45GSNA.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-IWXVQYG5.js → chunk-RF3DFVXH.js} +2 -2
- package/dist/{chunk-IWXVQYG5.js.map → chunk-RF3DFVXH.js.map} +1 -1
- 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-SJZAZQIR.js} +36 -9
- package/dist/cli/ap2-SJZAZQIR.js.map +1 -0
- package/dist/cli/chunk-25WJIUJU.js +8 -0
- package/dist/cli/{chunk-B4QJV7OC.js.map → chunk-25WJIUJU.js.map} +1 -1
- package/dist/cli/chunk-2PO65227.js +619 -0
- package/dist/cli/chunk-2PO65227.js.map +1 -0
- package/dist/cli/{chunk-DKWO6LLX.js → chunk-4WPHZLVO.js} +3 -2
- package/dist/cli/chunk-4WPHZLVO.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-GISJ73ML.js +20 -0
- package/dist/cli/chunk-GISJ73ML.js.map +1 -0
- package/dist/cli/chunk-IJFPWT4I.js +435 -0
- package/dist/cli/chunk-IJFPWT4I.js.map +1 -0
- package/dist/cli/{chunk-QUFFT5K3.js → chunk-K34CRXKX.js} +141 -42
- package/dist/cli/chunk-K34CRXKX.js.map +1 -0
- package/dist/cli/{chunk-OETKXDGA.js → chunk-L264N3ZV.js} +127 -274
- package/dist/cli/chunk-L264N3ZV.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-S5TQXKQ7.js → chunk-NM7V2Y4I.js} +7 -5
- package/dist/cli/chunk-NM7V2Y4I.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-GBBG66O6.js → chunk-SHIA2B6G.js} +161 -106
- package/dist/cli/chunk-SHIA2B6G.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-XRG5UTIC.js → chunk-U3SEGD4H.js} +127 -19
- package/dist/cli/chunk-U3SEGD4H.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-APC5BTQM.js → chunk-UV23DWUY.js} +2 -2
- package/dist/cli/{chunk-APC5BTQM.js.map → chunk-UV23DWUY.js.map} +1 -1
- package/dist/cli/config-IBG46HTQ.js +14 -0
- package/dist/cli/{config-ODN4IEMZ.js.map → config-IBG46HTQ.js.map} +1 -1
- package/dist/cli/index.js +373 -82
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/{mcp-G2D2Z77G.js → mcp-F3EQQWDZ.js} +84 -45
- package/dist/cli/mcp-F3EQQWDZ.js.map +1 -0
- package/dist/cli/payment-providers-FPTGQBU7.js +6 -0
- package/dist/cli/{payment-providers-7RIIZ5OF.js.map → payment-providers-FPTGQBU7.js.map} +1 -1
- package/dist/cli/{provider-ARV3VAQ7.js → provider-XACFJ7MG.js} +145 -23
- package/dist/cli/provider-XACFJ7MG.js.map +1 -0
- package/dist/cli/receipts-AXCPPGOK.js +9 -0
- package/dist/cli/{receipts-HLQ7D722.js.map → receipts-AXCPPGOK.js.map} +1 -1
- package/dist/cli/{run-BHODKC6H.js → run-C3VWMM57.js} +912 -237
- package/dist/cli/run-C3VWMM57.js.map +1 -0
- package/dist/cli/{x402-LHW2YQ6W.js → x402-SUXWULOP.js} +12 -8
- package/dist/cli/x402-SUXWULOP.js.map +1 -0
- package/dist/index.d.ts +108 -41
- package/dist/index.js +1614 -633
- 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-04pazhFP.d.ts} +54 -3
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +469 -274
- package/dist/testing.js.map +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-WDD2ZUR3.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-DKWO6LLX.js.map +0 -1
- 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/chunk-XRG5UTIC.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 {
|
|
4
|
-
import { DEFAULT_CONFIG_FILENAME,
|
|
5
|
-
import { AP2_SPEC_VERSION, AP2_CHECKOUT_MANDATE_VCT, AP2_CHECKOUT_PROFILE } from './chunk-
|
|
6
|
-
import { MCP_TOOL_NAME_MAX_LENGTH, MCP_TOOL_NAME_CHARS } from './chunk-
|
|
7
|
-
import { createSqliteReceiptStore, openSqliteReceiptStoreReadOnly,
|
|
2
|
+
import { ap2_default } from './chunk-526C4KZA.js';
|
|
3
|
+
import { a2a_default, acp_default } from './chunk-IJFPWT4I.js';
|
|
4
|
+
import { DEFAULT_CONFIG_FILENAME, listEnvPlaceholders, A2A_SPEC_VERSION, A2A_PROTOCOL_VERSION, A2A_PROTOCOL_BINDING, A2A_AGENT_CARD_PATH, ACP_SPEC_VERSION, ACP_API_VERSION, ACP_WELL_KNOWN_PATH } from './chunk-L264N3ZV.js';
|
|
5
|
+
import { AP2_SPEC_VERSION, AP2_CHECKOUT_MANDATE_VCT, AP2_CHECKOUT_PROFILE } from './chunk-4WPHZLVO.js';
|
|
6
|
+
import { publicEndpointUrl, MCP_TOOL_NAME_MAX_LENGTH, MCP_TOOL_NAME_CHARS } from './chunk-RWBUHDU7.js';
|
|
7
|
+
import { createSqliteReceiptStore, openSqliteReceiptStoreReadOnly, readLegacyImportState, SCHEMA_VERSION, hasTable } from './chunk-U3SEGD4H.js';
|
|
8
8
|
import './chunk-6EBDOH37.js';
|
|
9
|
-
import './chunk-
|
|
9
|
+
import './chunk-UV23DWUY.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-25WJIUJU.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-IBG46HTQ.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
|
}
|
|
@@ -586,7 +610,7 @@ async function storageChecks(config, openStore) {
|
|
|
586
610
|
} catch (err) {
|
|
587
611
|
const refused = refusedSchema(err);
|
|
588
612
|
if (refused !== void 0 && refused.schemaVersion < refused.expected) {
|
|
589
|
-
const
|
|
613
|
+
const legacy = readLegacyImportState(path);
|
|
590
614
|
return {
|
|
591
615
|
checks: [
|
|
592
616
|
{
|
|
@@ -595,7 +619,7 @@ async function storageChecks(config, openStore) {
|
|
|
595
619
|
detail: `sqlite schema v${refused.schemaVersion}; the next start migrates it to v${refused.expected}, which earlier versions cannot open. Run agent-commerce backup first to keep a copy they can`
|
|
596
620
|
}
|
|
597
621
|
],
|
|
598
|
-
legacy
|
|
622
|
+
legacy
|
|
599
623
|
};
|
|
600
624
|
}
|
|
601
625
|
checks.push({
|
|
@@ -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(
|
|
@@ -1191,6 +1233,18 @@ async function paymentChecks(config, wellKnown, gatewayUrl, chainDeploy = false,
|
|
|
1191
1233
|
}
|
|
1192
1234
|
|
|
1193
1235
|
// src/cli/commands/doctor/protocols.ts
|
|
1236
|
+
function unencryptedPublicHost(publicBaseUrl) {
|
|
1237
|
+
let url;
|
|
1238
|
+
try {
|
|
1239
|
+
url = new URL(publicBaseUrl);
|
|
1240
|
+
} catch {
|
|
1241
|
+
return void 0;
|
|
1242
|
+
}
|
|
1243
|
+
if (url.protocol !== "http:") return void 0;
|
|
1244
|
+
const host = url.hostname.replace(/^\[|\]$/g, "");
|
|
1245
|
+
const loopback = host === "localhost" || host.endsWith(".localhost") || host === "::1" || /^127\.\d+\.\d+\.\d+$/.test(host);
|
|
1246
|
+
return loopback ? void 0 : host;
|
|
1247
|
+
}
|
|
1194
1248
|
function acpMappingCheck(config, operations) {
|
|
1195
1249
|
const byId = new Map(config.resources.map((resource) => [resource.id, resource]));
|
|
1196
1250
|
const problems = [];
|
|
@@ -1216,12 +1270,17 @@ function acpMappingCheck(config, operations) {
|
|
|
1216
1270
|
detail: `5 operations mapped to free acp-exposed resources (${Object.values(operations).join(", ")})`
|
|
1217
1271
|
};
|
|
1218
1272
|
}
|
|
1219
|
-
function protocolChecks(config, wellKnown, legacy) {
|
|
1273
|
+
function protocolChecks(config, wellKnown, legacy, liveCause) {
|
|
1220
1274
|
const checks = [];
|
|
1221
1275
|
if (config === void 0) {
|
|
1222
|
-
checks.push({ name: "Protocols", status: "WARN",
|
|
1276
|
+
checks.push({ name: "Protocols", status: "WARN", ...SKIPPED_CONFIG_INVALID });
|
|
1223
1277
|
} else if (wellKnown === void 0 || !wellKnown.ok) {
|
|
1224
|
-
checks.push({
|
|
1278
|
+
checks.push({
|
|
1279
|
+
name: "Protocols",
|
|
1280
|
+
status: "FAIL",
|
|
1281
|
+
detail: wellKnown === void 0 || wellKnown.status === 0 ? "well-known document unreachable" : `well-known document unavailable (HTTP ${wellKnown.status})`,
|
|
1282
|
+
...undeterminedField(liveCause)
|
|
1283
|
+
});
|
|
1225
1284
|
} else {
|
|
1226
1285
|
const mcpMountPath = config.protocols.mcp.enabled ? config.protocols.mcp.mountPath : void 0;
|
|
1227
1286
|
const a2aMountPath = config.protocols.a2a.enabled ? config.protocols.a2a.mountPath : void 0;
|
|
@@ -1232,23 +1291,31 @@ function protocolChecks(config, wellKnown, legacy) {
|
|
|
1232
1291
|
});
|
|
1233
1292
|
}
|
|
1234
1293
|
if (config === void 0) {
|
|
1235
|
-
checks.push({ name: "A2A", status: "WARN",
|
|
1294
|
+
checks.push({ name: "A2A", status: "WARN", ...SKIPPED_CONFIG_INVALID });
|
|
1236
1295
|
} else if (!config.protocols.a2a.enabled) {
|
|
1237
1296
|
checks.push({ name: "A2A", status: "INFO", detail: "disabled" });
|
|
1238
1297
|
} else {
|
|
1239
1298
|
checks.push({
|
|
1240
1299
|
name: "A2A",
|
|
1241
1300
|
status: "PASS",
|
|
1242
|
-
detail:
|
|
1301
|
+
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
1302
|
});
|
|
1244
1303
|
checks.push({
|
|
1245
1304
|
name: "A2A unsupported",
|
|
1246
1305
|
status: "INFO",
|
|
1247
|
-
detail:
|
|
1306
|
+
detail: exclusionNames(a2a_default).join(", ")
|
|
1248
1307
|
});
|
|
1308
|
+
const host = unencryptedPublicHost(config.merchant.publicBaseUrl);
|
|
1309
|
+
if (host !== void 0) {
|
|
1310
|
+
checks.push({
|
|
1311
|
+
name: "A2A transport",
|
|
1312
|
+
status: "WARN",
|
|
1313
|
+
detail: `merchant.publicBaseUrl uses http:// on ${host}, which is not a loopback host: the Agent Card publishes an unencrypted endpoint, and A2A requires encryption in production (spec section 7.1). Serve the gateway at an https:// URL.`
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1249
1316
|
}
|
|
1250
1317
|
if (config === void 0) {
|
|
1251
|
-
checks.push({ name: "ACP", status: "WARN",
|
|
1318
|
+
checks.push({ name: "ACP", status: "WARN", ...SKIPPED_CONFIG_INVALID });
|
|
1252
1319
|
} else if (!config.protocols.acp.enabled) {
|
|
1253
1320
|
checks.push({ name: "ACP", status: "INFO", detail: "disabled" });
|
|
1254
1321
|
} else {
|
|
@@ -1256,7 +1323,7 @@ function protocolChecks(config, wellKnown, legacy) {
|
|
|
1256
1323
|
checks.push({
|
|
1257
1324
|
name: "ACP",
|
|
1258
1325
|
status: "PASS",
|
|
1259
|
-
detail:
|
|
1326
|
+
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
1327
|
});
|
|
1261
1328
|
checks.push({
|
|
1262
1329
|
name: "ACP auth",
|
|
@@ -1277,11 +1344,160 @@ function protocolChecks(config, wellKnown, legacy) {
|
|
|
1277
1344
|
checks.push({
|
|
1278
1345
|
name: "ACP unsupported",
|
|
1279
1346
|
status: "INFO",
|
|
1280
|
-
detail:
|
|
1347
|
+
detail: exclusionNames(acp_default).join(", ")
|
|
1281
1348
|
});
|
|
1282
1349
|
}
|
|
1283
1350
|
return checks;
|
|
1284
1351
|
}
|
|
1352
|
+
|
|
1353
|
+
// src/cli/lib/mcp-registry.ts
|
|
1354
|
+
var SERVER_JSON_SCHEMA = "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json";
|
|
1355
|
+
function serverJson(config) {
|
|
1356
|
+
const { mcp } = config.protocols;
|
|
1357
|
+
const problems = [];
|
|
1358
|
+
if (!mcp.enabled) {
|
|
1359
|
+
problems.push({
|
|
1360
|
+
key: "protocols.mcp.enabled",
|
|
1361
|
+
message: "is false: the listing would name a server that does not run"
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
if (mcp.registry === void 0) {
|
|
1365
|
+
problems.push({
|
|
1366
|
+
key: "protocols.mcp.registry",
|
|
1367
|
+
message: "is not set: it holds the listing name, version and description"
|
|
1368
|
+
});
|
|
1369
|
+
}
|
|
1370
|
+
const url = remoteUrl(config.merchant.publicBaseUrl, mcp.mountPath);
|
|
1371
|
+
if ("problem" in url) problems.push({ key: "merchant.publicBaseUrl", message: url.problem });
|
|
1372
|
+
if (mcp.registry === void 0 || "problem" in url || problems.length > 0) {
|
|
1373
|
+
return { problems };
|
|
1374
|
+
}
|
|
1375
|
+
return {
|
|
1376
|
+
document: {
|
|
1377
|
+
$schema: SERVER_JSON_SCHEMA,
|
|
1378
|
+
name: mcp.registry.name,
|
|
1379
|
+
description: mcp.registry.description,
|
|
1380
|
+
version: mcp.registry.version,
|
|
1381
|
+
remotes: [{ type: "streamable-http", url: url.url }]
|
|
1382
|
+
}
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1385
|
+
function remoteUrl(publicBaseUrl, mountPath) {
|
|
1386
|
+
let url;
|
|
1387
|
+
try {
|
|
1388
|
+
url = publicEndpointUrl(publicBaseUrl, mountPath);
|
|
1389
|
+
} catch {
|
|
1390
|
+
return { problem: "is not a URL" };
|
|
1391
|
+
}
|
|
1392
|
+
const parsed = new URL(url);
|
|
1393
|
+
if (parsed.protocol !== "https:") {
|
|
1394
|
+
return { problem: "must be an https:// URL: the MCP Registry refuses others" };
|
|
1395
|
+
}
|
|
1396
|
+
const host = parsed.hostname;
|
|
1397
|
+
if (host === "localhost" || host === "127.0.0.1" || host.endsWith(".localhost")) {
|
|
1398
|
+
return { problem: `names ${host}, which the MCP Registry refuses` };
|
|
1399
|
+
}
|
|
1400
|
+
return { url };
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
// src/cli/commands/doctor/registry.ts
|
|
1404
|
+
var MCP_REGISTRY_URL = "https://registry.modelcontextprotocol.io";
|
|
1405
|
+
var NAME = "MCP Registry";
|
|
1406
|
+
var REGISTRY_TIMEOUT_MS = 5e3;
|
|
1407
|
+
var OFFICIAL_META = "io.modelcontextprotocol.registry/official";
|
|
1408
|
+
async function registryCheck(config, fetchImpl) {
|
|
1409
|
+
if (config === void 0) return { name: NAME, status: "WARN", ...SKIPPED_CONFIG_INVALID };
|
|
1410
|
+
if (config.protocols.mcp.registry === void 0) {
|
|
1411
|
+
return { name: NAME, status: "INFO", detail: "protocols.mcp.registry not configured" };
|
|
1412
|
+
}
|
|
1413
|
+
const built = serverJson(config);
|
|
1414
|
+
if ("problems" in built) {
|
|
1415
|
+
return {
|
|
1416
|
+
name: NAME,
|
|
1417
|
+
status: "WARN",
|
|
1418
|
+
detail: built.problems.map((problem) => `${problem.key} ${problem.message}`).join("; ")
|
|
1419
|
+
};
|
|
1420
|
+
}
|
|
1421
|
+
const local = built.document;
|
|
1422
|
+
const answer = await fetchJson(
|
|
1423
|
+
fetchImpl,
|
|
1424
|
+
`${MCP_REGISTRY_URL}/v0.1/servers/${encodeURIComponent(local.name)}/versions/latest?include_deleted=true`,
|
|
1425
|
+
REGISTRY_TIMEOUT_MS
|
|
1426
|
+
);
|
|
1427
|
+
if (answer.status === 0) {
|
|
1428
|
+
return answer.noAnswer === true ? {
|
|
1429
|
+
name: NAME,
|
|
1430
|
+
status: "WARN",
|
|
1431
|
+
detail: "no answer from the registry",
|
|
1432
|
+
undetermined: "unreachable"
|
|
1433
|
+
} : { name: NAME, status: "WARN", detail: "the registry request failed" };
|
|
1434
|
+
}
|
|
1435
|
+
if (answer.status === 404) {
|
|
1436
|
+
return { name: NAME, status: "WARN", detail: `${local.name} is not listed` };
|
|
1437
|
+
}
|
|
1438
|
+
if (!answer.ok || !isRecord(answer.body) || !isRecord(answer.body["server"])) {
|
|
1439
|
+
return {
|
|
1440
|
+
name: NAME,
|
|
1441
|
+
status: "WARN",
|
|
1442
|
+
detail: answer.ok ? "the registry answer is not a server listing" : `the registry answered HTTP ${answer.status}`
|
|
1443
|
+
};
|
|
1444
|
+
}
|
|
1445
|
+
const problems = [
|
|
1446
|
+
...lifecycle(answer.body["_meta"]),
|
|
1447
|
+
...differences(answer.body["server"], local)
|
|
1448
|
+
];
|
|
1449
|
+
return problems.length === 0 ? {
|
|
1450
|
+
name: NAME,
|
|
1451
|
+
status: "PASS",
|
|
1452
|
+
detail: `${local.name} ${local.version} is listed as configured`
|
|
1453
|
+
} : { name: NAME, status: "WARN", detail: `${local.name}: ${problems.join("; ")}` };
|
|
1454
|
+
}
|
|
1455
|
+
function lifecycle(meta) {
|
|
1456
|
+
const official = isRecord(meta) ? meta[OFFICIAL_META] : void 0;
|
|
1457
|
+
const status = isRecord(official) ? official["status"] : void 0;
|
|
1458
|
+
if (status === "active") return [];
|
|
1459
|
+
if (status === "deprecated" || status === "deleted") return [`listing is ${status}`];
|
|
1460
|
+
return ["listing has no known status"];
|
|
1461
|
+
}
|
|
1462
|
+
function differences(listed, local) {
|
|
1463
|
+
const fields = ["name", "version", "description"].filter(
|
|
1464
|
+
(field) => listed[field] !== local[field]
|
|
1465
|
+
);
|
|
1466
|
+
const remotes = listed["remotes"];
|
|
1467
|
+
const remote = Array.isArray(remotes) && remotes.length === 1 ? remotes[0] : void 0;
|
|
1468
|
+
const sameRemote = isRecord(remote) && remote["type"] === local.remotes[0].type && remote["url"] === local.remotes[0].url;
|
|
1469
|
+
const differing = sameRemote ? fields : [...fields, "remotes"];
|
|
1470
|
+
return differing.length > 0 ? [`listing differs from config in ${differing.join(", ")}`] : [];
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
// src/cli/commands/doctor/secrets.ts
|
|
1474
|
+
async function secretsCheck(read, path, env) {
|
|
1475
|
+
let raw;
|
|
1476
|
+
try {
|
|
1477
|
+
raw = await read({ ...path !== void 0 ? { path } : {}, env });
|
|
1478
|
+
} catch {
|
|
1479
|
+
return {
|
|
1480
|
+
name: "Secrets",
|
|
1481
|
+
status: "WARN",
|
|
1482
|
+
detail: "skipped: config file unreadable",
|
|
1483
|
+
undetermined: "skipped"
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1486
|
+
const { missing, set, defaulted } = listEnvPlaceholders(raw, env);
|
|
1487
|
+
const groups = [
|
|
1488
|
+
...missing.length > 0 ? [`${missing.length} missing (${missing.join(", ")})`] : [],
|
|
1489
|
+
...set.length > 0 ? [`${set.length} set (${set.join(", ")})`] : [],
|
|
1490
|
+
...defaulted.length > 0 ? [`${defaulted.length} defaulted (${defaulted.join(", ")})`] : []
|
|
1491
|
+
];
|
|
1492
|
+
if (groups.length === 0) {
|
|
1493
|
+
return { name: "Secrets", status: "INFO", detail: "config reads no environment variable" };
|
|
1494
|
+
}
|
|
1495
|
+
return {
|
|
1496
|
+
name: "Secrets",
|
|
1497
|
+
status: missing.length > 0 ? "FAIL" : "PASS",
|
|
1498
|
+
detail: groups.join("; ")
|
|
1499
|
+
};
|
|
1500
|
+
}
|
|
1285
1501
|
function statusColor(status, text2) {
|
|
1286
1502
|
switch (status) {
|
|
1287
1503
|
case "PASS":
|
|
@@ -1301,7 +1517,8 @@ function printDoctorReport(report, io, json) {
|
|
|
1301
1517
|
}
|
|
1302
1518
|
for (const check of report.checks) {
|
|
1303
1519
|
const label = statusColor(check.status, check.status.padEnd(5));
|
|
1304
|
-
|
|
1520
|
+
const mark = check.undetermined !== void 0 ? ` [not determined: ${check.undetermined}]` : "";
|
|
1521
|
+
io.stdout(`${label} ${check.name.padEnd(20)} ${check.detail}${mark}`);
|
|
1305
1522
|
}
|
|
1306
1523
|
io.stdout("");
|
|
1307
1524
|
io.stdout(`Score: ${report.score.passed}/${report.score.total} checks passed`);
|
|
@@ -1355,18 +1572,26 @@ async function runDoctor(options, deps = {}) {
|
|
|
1355
1572
|
detail: `${err instanceof Error ? err.message : String(err)}${hint}`
|
|
1356
1573
|
});
|
|
1357
1574
|
}
|
|
1575
|
+
const readConfigFile = deps.readConfigFile ?? (deps.loadConfig === void 0 ? readConfigFileDynamic : void 0);
|
|
1576
|
+
if (readConfigFile !== void 0) {
|
|
1577
|
+
checks.push(await secretsCheck(readConfigFile, options.configPath, env));
|
|
1578
|
+
}
|
|
1358
1579
|
const gatewayUrl = deriveGatewayUrl(options.gatewayUrl, config);
|
|
1359
1580
|
const health = await fetchJson(fetchImpl, `${gatewayUrl}/health`, CHECK_TIMEOUT_MS);
|
|
1360
1581
|
let gatewayUp = false;
|
|
1582
|
+
let liveCause;
|
|
1361
1583
|
if (!health.ok) {
|
|
1584
|
+
liveCause = health.noAnswer ? "unreachable" : "skipped";
|
|
1362
1585
|
checks.push({
|
|
1363
1586
|
name: "Gateway",
|
|
1364
1587
|
status: "FAIL",
|
|
1365
|
-
detail: `unreachable at ${gatewayUrl} (${health.error ?? `HTTP ${health.status}
|
|
1588
|
+
detail: health.status === 0 ? `unreachable at ${gatewayUrl} (${health.error ?? "no answer"})` : `unhealthy at ${gatewayUrl} (HTTP ${health.status})`,
|
|
1589
|
+
...undeterminedField(health.noAnswer ? "unreachable" : void 0)
|
|
1366
1590
|
});
|
|
1367
1591
|
} else {
|
|
1368
1592
|
const ready = await fetchJson(fetchImpl, `${gatewayUrl}/ready`, CHECK_TIMEOUT_MS);
|
|
1369
1593
|
if (ready.status === 403) {
|
|
1594
|
+
liveCause = "skipped";
|
|
1370
1595
|
checks.push({
|
|
1371
1596
|
name: "Gateway",
|
|
1372
1597
|
status: "FAIL",
|
|
@@ -1378,13 +1603,14 @@ async function runDoctor(options, deps = {}) {
|
|
|
1378
1603
|
ready.ok ? { name: "Gateway", status: "PASS", detail: `healthy and ready at ${gatewayUrl}` } : {
|
|
1379
1604
|
name: "Gateway",
|
|
1380
1605
|
status: "WARN",
|
|
1381
|
-
detail: `healthy but not ready at ${gatewayUrl} (${ready.error ?? `HTTP ${ready.status}`})
|
|
1606
|
+
detail: `healthy but not ready at ${gatewayUrl} (${ready.error ?? `HTTP ${ready.status}`})`,
|
|
1607
|
+
...undeterminedField(ready.noAnswer ? "unreachable" : void 0)
|
|
1382
1608
|
}
|
|
1383
1609
|
);
|
|
1384
1610
|
}
|
|
1385
1611
|
}
|
|
1386
1612
|
if (config === void 0) {
|
|
1387
|
-
checks.push({ name: "Backend", status: "WARN",
|
|
1613
|
+
checks.push({ name: "Backend", status: "WARN", ...SKIPPED_CONFIG_INVALID });
|
|
1388
1614
|
} else if (config.resources.length === 0) {
|
|
1389
1615
|
checks.push({ name: "Backend", status: "INFO", detail: "no resources configured" });
|
|
1390
1616
|
} else {
|
|
@@ -1393,12 +1619,16 @@ async function runDoctor(options, deps = {}) {
|
|
|
1393
1619
|
const results = await Promise.all(
|
|
1394
1620
|
urls.map((url) => fetchJson(fetchImpl, url, CHECK_TIMEOUT_MS))
|
|
1395
1621
|
);
|
|
1396
|
-
const
|
|
1622
|
+
const unreached = results.filter((r) => r.status === 0);
|
|
1623
|
+
const reachable = urls.length - unreached.length;
|
|
1397
1624
|
const status = reachable === urls.length ? "PASS" : reachable === 0 ? "FAIL" : "WARN";
|
|
1398
1625
|
checks.push({
|
|
1399
1626
|
name: "Backend",
|
|
1400
1627
|
status,
|
|
1401
|
-
detail: `${reachable}/${urls.length} backend host(s) reachable
|
|
1628
|
+
detail: `${reachable}/${urls.length} backend host(s) reachable`,
|
|
1629
|
+
...undeterminedField(
|
|
1630
|
+
unreached.length > 0 && unreached.every((r) => r.noAnswer) ? "unreachable" : void 0
|
|
1631
|
+
)
|
|
1402
1632
|
});
|
|
1403
1633
|
}
|
|
1404
1634
|
const wellKnown = gatewayUp ? await fetchJson(
|
|
@@ -1406,11 +1636,19 @@ async function runDoctor(options, deps = {}) {
|
|
|
1406
1636
|
`${gatewayUrl}/.well-known/agent-commerce`,
|
|
1407
1637
|
CHECK_TIMEOUT_MS
|
|
1408
1638
|
) : void 0;
|
|
1639
|
+
if (wellKnown !== void 0) liveCause = wellKnown.noAnswer ? "unreachable" : void 0;
|
|
1409
1640
|
const storage = await storageChecks(config, createStore);
|
|
1410
|
-
checks.push(...protocolChecks(config, wellKnown, storage.legacy));
|
|
1641
|
+
checks.push(...protocolChecks(config, wellKnown, storage.legacy, liveCause));
|
|
1411
1642
|
checks.push(...ap2Checks(config, storage.legacy));
|
|
1412
1643
|
checks.push(
|
|
1413
|
-
...await paymentChecks(
|
|
1644
|
+
...await paymentChecks(
|
|
1645
|
+
config,
|
|
1646
|
+
wellKnown,
|
|
1647
|
+
gatewayUrl,
|
|
1648
|
+
chainDeploy,
|
|
1649
|
+
deps.loadViemAccounts,
|
|
1650
|
+
liveCause
|
|
1651
|
+
)
|
|
1414
1652
|
);
|
|
1415
1653
|
checks.push(...storage.checks);
|
|
1416
1654
|
if (wellKnown?.ok) {
|
|
@@ -1424,14 +1662,63 @@ async function runDoctor(options, deps = {}) {
|
|
|
1424
1662
|
checks.push({
|
|
1425
1663
|
name: "Protocol versions",
|
|
1426
1664
|
status: "INFO",
|
|
1427
|
-
detail:
|
|
1665
|
+
detail: `${liveCause === "unreachable" ? "gateway unreachable" : "gateway versions unavailable"}; local pins: ${local.pinned.map((p) => `${p.name}@${p.version}`).join(", ")}`,
|
|
1666
|
+
...undeterminedField(liveCause)
|
|
1428
1667
|
});
|
|
1429
1668
|
}
|
|
1669
|
+
if (options.registry === true) checks.push(await registryCheck(config, fetchImpl));
|
|
1430
1670
|
const scored = checks.filter((c) => c.status !== "INFO");
|
|
1431
1671
|
const passed = scored.filter((c) => c.status === "PASS").length;
|
|
1432
1672
|
const exitCode = checks.some((c) => c.status === "FAIL") ? 1 : 0;
|
|
1433
1673
|
return { checks, score: { passed, total: scored.length }, exitCode };
|
|
1434
1674
|
}
|
|
1675
|
+
async function writeAtomically(outputPath, content) {
|
|
1676
|
+
const target = resolve(outputPath);
|
|
1677
|
+
const temporary = `${target}.${process.pid}.tmp`;
|
|
1678
|
+
try {
|
|
1679
|
+
await mkdir(dirname(target), { recursive: true });
|
|
1680
|
+
await writeFile(temporary, content, "utf8");
|
|
1681
|
+
await rename(temporary, target);
|
|
1682
|
+
} catch (error) {
|
|
1683
|
+
await rm(temporary, { force: true });
|
|
1684
|
+
throw error;
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
// src/cli/commands/export-mcp-registry.ts
|
|
1689
|
+
async function runExportMcpRegistry(options, io, deps = {}) {
|
|
1690
|
+
const { output } = options;
|
|
1691
|
+
if (existsSync(output) && options.force !== true) {
|
|
1692
|
+
io.stderr(`FAIL ${output} already exists. Re-run with --force to overwrite.`);
|
|
1693
|
+
return 1;
|
|
1694
|
+
}
|
|
1695
|
+
let config;
|
|
1696
|
+
try {
|
|
1697
|
+
config = await (deps.loadConfig ?? loadConfigDynamic)(
|
|
1698
|
+
options.configPath !== void 0 ? { path: options.configPath } : {}
|
|
1699
|
+
);
|
|
1700
|
+
} catch (error) {
|
|
1701
|
+
io.stderr(formatConfigError(error, false, false));
|
|
1702
|
+
return 1;
|
|
1703
|
+
}
|
|
1704
|
+
const result = serverJson(config);
|
|
1705
|
+
if ("problems" in result) {
|
|
1706
|
+
for (const problem of result.problems) io.stderr(`FAIL ${problem.key} ${problem.message}`);
|
|
1707
|
+
return 1;
|
|
1708
|
+
}
|
|
1709
|
+
try {
|
|
1710
|
+
await writeAtomically(output, `${JSON.stringify(result.document, null, 2)}
|
|
1711
|
+
`);
|
|
1712
|
+
} catch (error) {
|
|
1713
|
+
io.stderr(
|
|
1714
|
+
`FAIL ${output} could not be written: ${error instanceof Error ? error.message : String(error)}`
|
|
1715
|
+
);
|
|
1716
|
+
return 1;
|
|
1717
|
+
}
|
|
1718
|
+
io.stdout(`Wrote ${output} for ${result.document.name} ${result.document.version}.`);
|
|
1719
|
+
io.stdout("Publish it with mcp-publisher after verifying the namespace.");
|
|
1720
|
+
return 0;
|
|
1721
|
+
}
|
|
1435
1722
|
|
|
1436
1723
|
// src/openapi/refs.ts
|
|
1437
1724
|
var MAX_REF_DEPTH = 100;
|
|
@@ -2497,7 +2784,7 @@ async function runImportOpenApi(options, io, deps = {}) {
|
|
|
2497
2784
|
const wrote = failures.length === 0;
|
|
2498
2785
|
if (wrote) {
|
|
2499
2786
|
try {
|
|
2500
|
-
await writeAtomically(outputPath, renderResourcesYaml(result)
|
|
2787
|
+
await (deps.writeFile ?? writeAtomically)(outputPath, renderResourcesYaml(result));
|
|
2501
2788
|
} catch (error) {
|
|
2502
2789
|
io.stderr(`FAIL ${outputPath} could not be written: ${describe(error)}`);
|
|
2503
2790
|
return 1;
|
|
@@ -2550,22 +2837,6 @@ function buildPolicy(options) {
|
|
|
2550
2837
|
}
|
|
2551
2838
|
return policy;
|
|
2552
2839
|
}
|
|
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
2840
|
function printSummary(result, context, io) {
|
|
2570
2841
|
const skipped = result.diagnostics.filter((entry) => entry.severity === "error");
|
|
2571
2842
|
const warnings = result.diagnostics.filter((entry) => entry.severity === "warning");
|
|
@@ -2754,7 +3025,7 @@ async function runReconcileCommand(options, io, deps = {}) {
|
|
|
2754
3025
|
try {
|
|
2755
3026
|
const logger = stderrLogger(io);
|
|
2756
3027
|
const { runReconcile } = await import('./reconcile-GS25MQ42.js');
|
|
2757
|
-
const providers = await (await import('./payment-providers-
|
|
3028
|
+
const providers = await (await import('./payment-providers-FPTGQBU7.js')).createConfiguredPaymentProviders(config.payments, logger);
|
|
2758
3029
|
let report;
|
|
2759
3030
|
await withJournal(config, logger, async (store, authorizationProviders) => {
|
|
2760
3031
|
report = await runReconcile({
|
|
@@ -2787,8 +3058,8 @@ async function withJournal(config, logger, fn) {
|
|
|
2787
3058
|
{ createConfiguredAuthorizationProviders },
|
|
2788
3059
|
{ createSqliteReceiptStore: createSqliteReceiptStore2, openSqliteReceiptStoreReadOnly: openSqliteReceiptStoreReadOnly2 }
|
|
2789
3060
|
] = await Promise.all([
|
|
2790
|
-
import('./payment-providers-
|
|
2791
|
-
import('./receipts-
|
|
3061
|
+
import('./payment-providers-FPTGQBU7.js'),
|
|
3062
|
+
import('./receipts-AXCPPGOK.js')
|
|
2792
3063
|
]);
|
|
2793
3064
|
const path = config.storage.receipts.path;
|
|
2794
3065
|
if (path !== ":memory:" && existsSync(path)) {
|
|
@@ -3016,7 +3287,7 @@ var ENV_FILE_HELP = "load environment variables from this file; variables alread
|
|
|
3016
3287
|
function buildProgram(io = processIo) {
|
|
3017
3288
|
const program = new Command();
|
|
3018
3289
|
program.name("agent-commerce").description(
|
|
3019
|
-
"CLI for the Agent Commerce Gateway: init, import, validate, start, doctor, reconcile, backup, demo."
|
|
3290
|
+
"CLI for the Agent Commerce Gateway: init, import, export, validate, start, doctor, reconcile, backup, demo."
|
|
3020
3291
|
).version(readVersionReport().cliVersion, "-v, --version", "Print the CLI version.").exitOverride().configureOutput({
|
|
3021
3292
|
writeOut: (str) => io.stdout(str.replace(/\n+$/, "")),
|
|
3022
3293
|
writeErr: (str) => io.stderr(str.replace(/\n+$/, ""))
|
|
@@ -3045,7 +3316,7 @@ function buildProgram(io = processIo) {
|
|
|
3045
3316
|
`Start the gateway from ${DEFAULT_CONFIG_FILENAME} and serve until SIGTERM or SIGINT.`
|
|
3046
3317
|
).option("--config <path>", `path to ${DEFAULT_CONFIG_FILENAME}`).option("--env-file <path>", ENV_FILE_HELP).action(async (opts) => {
|
|
3047
3318
|
try {
|
|
3048
|
-
const { runGateway } = await import('./run-
|
|
3319
|
+
const { runGateway } = await import('./run-C3VWMM57.js');
|
|
3049
3320
|
await runGateway(opts.config !== void 0 ? { configPath: opts.config } : {});
|
|
3050
3321
|
} catch (error) {
|
|
3051
3322
|
io.stderr(formatConfigError(error, false, false));
|
|
@@ -3055,14 +3326,21 @@ function buildProgram(io = processIo) {
|
|
|
3055
3326
|
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
3327
|
"--gateway <url>",
|
|
3057
3328
|
"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
|
-
|
|
3329
|
+
).option("--json", "emit machine-readable JSON instead of a formatted report", false).option(
|
|
3330
|
+
"--registry",
|
|
3331
|
+
"also compare the MCP Registry listing named in protocols.mcp.registry with config (calls registry.modelcontextprotocol.io)",
|
|
3332
|
+
false
|
|
3333
|
+
).action(
|
|
3334
|
+
async (opts) => {
|
|
3335
|
+
const report = await runDoctor({
|
|
3336
|
+
...opts.config !== void 0 ? { configPath: opts.config } : {},
|
|
3337
|
+
...opts.gateway !== void 0 ? { gatewayUrl: opts.gateway } : {},
|
|
3338
|
+
registry: opts.registry
|
|
3339
|
+
});
|
|
3340
|
+
printDoctorReport(report, io, opts.json === true);
|
|
3341
|
+
process.exitCode = report.exitCode;
|
|
3342
|
+
}
|
|
3343
|
+
);
|
|
3066
3344
|
program.command("reconcile").description(
|
|
3067
3345
|
"Resolve uncertain payment attempts using chain evidence. Never settles or refunds."
|
|
3068
3346
|
).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 +3427,19 @@ function buildProgram(io = processIo) {
|
|
|
3149
3427
|
);
|
|
3150
3428
|
}
|
|
3151
3429
|
);
|
|
3430
|
+
const exportCommand = program.command("export").description("Generate catalog listings for the gateway from config.");
|
|
3431
|
+
exportCommand.command("mcp-registry").description(
|
|
3432
|
+
"Write server.json for the MCP Registry from protocols.mcp.registry (experimental)."
|
|
3433
|
+
).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) => {
|
|
3434
|
+
process.exitCode = await runExportMcpRegistry(
|
|
3435
|
+
{
|
|
3436
|
+
...opts.config !== void 0 ? { configPath: opts.config } : {},
|
|
3437
|
+
output: opts.output,
|
|
3438
|
+
force: opts.force
|
|
3439
|
+
},
|
|
3440
|
+
io
|
|
3441
|
+
);
|
|
3442
|
+
});
|
|
3152
3443
|
program.command("demo").description(
|
|
3153
3444
|
"Start the local stack with docker compose (waiting for healthy services), then run the demo agent. Run it from a repo clone."
|
|
3154
3445
|
).action(async () => {
|