@devlab.group/agent-commerce 2.2.1 → 2.4.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 +20 -16
- package/dist/ap2.d.ts +6 -5
- package/dist/ap2.js +3 -3
- package/dist/{authorization-CMkIuAkO.d.ts → authorization-DjAecwuW.d.ts} +1 -1
- package/dist/{chunk-REBY2IEP.js → chunk-4OEXK3YG.js} +4 -4
- package/dist/{chunk-REBY2IEP.js.map → chunk-4OEXK3YG.js.map} +1 -1
- package/dist/{chunk-2DAJAJI7.js → chunk-6WACRJVT.js} +3 -3
- package/dist/{chunk-2DAJAJI7.js.map → chunk-6WACRJVT.js.map} +1 -1
- package/dist/{chunk-XYHDQ22D.js → chunk-AITMDXKW.js} +3 -3
- package/dist/{chunk-XYHDQ22D.js.map → chunk-AITMDXKW.js.map} +1 -1
- package/dist/{chunk-BNUD4RBN.js → chunk-WUIAUAA7.js} +200 -8
- package/dist/chunk-WUIAUAA7.js.map +1 -0
- package/dist/cli/{ap2-HLBIUSTK.js → ap2-QDHPRSTF.js} +3 -3
- package/dist/cli/{ap2-HLBIUSTK.js.map → ap2-QDHPRSTF.js.map} +1 -1
- package/dist/cli/{chunk-QZ6TOMX6.js → chunk-AZDWFVDW.js} +200 -8
- package/dist/cli/chunk-AZDWFVDW.js.map +1 -0
- package/dist/cli/{chunk-SNM3OVCY.js → chunk-DCMW67JM.js} +19 -5
- package/dist/cli/chunk-DCMW67JM.js.map +1 -0
- package/dist/cli/{chunk-ILUYEQSV.js → chunk-G2JEY7MB.js} +26 -9
- package/dist/cli/chunk-G2JEY7MB.js.map +1 -0
- package/dist/cli/{chunk-2LN5PO5I.js → chunk-PIMFPCNZ.js} +3 -2
- package/dist/cli/chunk-PIMFPCNZ.js.map +1 -0
- package/dist/cli/chunk-UXB65XCS.js +8 -0
- package/dist/cli/{chunk-QY3K6PEQ.js.map → chunk-UXB65XCS.js.map} +1 -1
- package/dist/cli/{chunk-KTV52MCU.js → chunk-WYOGIANL.js} +3 -3
- package/dist/cli/{chunk-KTV52MCU.js.map → chunk-WYOGIANL.js.map} +1 -1
- package/dist/cli/{config-VYAJGZXE.js → config-UI4EDG4L.js} +5 -5
- package/dist/cli/{config-VYAJGZXE.js.map → config-UI4EDG4L.js.map} +1 -1
- package/dist/cli/index.js +98 -12
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/{mcp-HFD7ZNCQ.js → mcp-26LJMN4N.js} +3 -3
- package/dist/cli/{mcp-HFD7ZNCQ.js.map → mcp-26LJMN4N.js.map} +1 -1
- package/dist/cli/{provider-JV5HCQGR.js → provider-Z4OJNAYI.js} +5 -5
- package/dist/cli/{provider-JV5HCQGR.js.map → provider-Z4OJNAYI.js.map} +1 -1
- package/dist/cli/{run-WV44B62Y.js → run-TEPYJUHG.js} +33 -12
- package/dist/cli/run-TEPYJUHG.js.map +1 -0
- package/dist/cli/{x402-NADFV5CD.js → x402-BMVONZKA.js} +6 -6
- package/dist/cli/{x402-NADFV5CD.js.map → x402-BMVONZKA.js.map} +1 -1
- package/dist/{constants-nackLItD.d.ts → constants-BG22tE8S.d.ts} +2 -1
- package/dist/index.d.ts +35 -12
- package/dist/index.js +61 -11
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.ts +5 -4
- package/dist/mcp.js +1 -1
- package/dist/mpp.d.ts +5 -4
- package/dist/mpp.js +3 -3
- package/dist/{networks-DTWRlj-K.d.ts → networks-DDHYJLcg.d.ts} +2 -1
- package/dist/{protocol-adapter-CfxU8Z2T.d.ts → protocol-adapter-C9odYl6l.d.ts} +4 -3
- package/dist/{runtime-7vLNYvmU.d.ts → runtime-Cl_BLVZV.d.ts} +8 -1
- package/dist/{types-CVw6Sf46.d.ts → types-j7MnUXYN.d.ts} +2 -1
- package/dist/x402.d.ts +27 -18
- package/dist/x402.js +4 -4
- package/package.json +6 -6
- package/dist/chunk-BNUD4RBN.js.map +0 -1
- package/dist/cli/chunk-2LN5PO5I.js.map +0 -1
- package/dist/cli/chunk-ILUYEQSV.js.map +0 -1
- package/dist/cli/chunk-QY3K6PEQ.js +0 -8
- package/dist/cli/chunk-QZ6TOMX6.js.map +0 -1
- package/dist/cli/chunk-SNM3OVCY.js.map +0 -1
- package/dist/cli/index.d.ts +0 -1
- package/dist/cli/run-WV44B62Y.js.map +0 -1
package/dist/cli/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { createSqliteReceiptStore, A2A_SPEC_VERSION, A2A_PROTOCOL_VERSION, A2A_PROTOCOL_BINDING, A2A_AGENT_CARD_PATH, A2A_UNSUPPORTED, ACP_UNSUPPORTED } from './chunk-
|
|
3
|
-
import { DEFAULT_CONFIG_FILENAME, extractPathParameterNames, ACP_SPEC_VERSION, ACP_API_VERSION, ACP_WELL_KNOWN_PATH, findUnparsedBraceToken } from './chunk-
|
|
2
|
+
import { createSqliteReceiptStore, A2A_SPEC_VERSION, A2A_PROTOCOL_VERSION, A2A_PROTOCOL_BINDING, A2A_AGENT_CARD_PATH, A2A_UNSUPPORTED, ACP_UNSUPPORTED } from './chunk-DCMW67JM.js';
|
|
3
|
+
import { DEFAULT_CONFIG_FILENAME, extractPathParameterNames, ACP_SPEC_VERSION, ACP_API_VERSION, ACP_WELL_KNOWN_PATH, findUnparsedBraceToken } from './chunk-PIMFPCNZ.js';
|
|
4
4
|
import { MPP_PROFILE, MPP_SPEC_DRAFTS, MPPX_VERSION, MPP_SPEC_COMMIT, MPP_DEFAULT_PAYMENT_FLOW } from './chunk-AA3FIEAR.js';
|
|
5
5
|
import { ANVIL_WELL_KNOWN_ACCOUNTS, describeDeploymentMode, X402_DEFAULT_PAYMENT_FLOW, findX402Network, isEvmAddress, LOCAL_CHAIN_ID, resolveDeploymentMode, sameAddress } from './chunk-OZ4LAWBK.js';
|
|
6
6
|
import { AP2_UNSUPPORTED } from './chunk-3EQBCFZY.js';
|
|
7
7
|
import './chunk-3MGAJ5FX.js';
|
|
8
8
|
import { AP2_SPEC_VERSION, AP2_CHECKOUT_MANDATE_VCT, AP2_CHECKOUT_PROFILE } from './chunk-FHCFR2GS.js';
|
|
9
9
|
import { MCP_TOOL_NAME_MAX_LENGTH, MCP_TOOL_NAME_CHARS } from './chunk-TPC4EJLT.js';
|
|
10
|
-
import { PACKAGE_VERSION } from './chunk-
|
|
10
|
+
import { PACKAGE_VERSION } from './chunk-UXB65XCS.js';
|
|
11
11
|
import { PROTOCOL_NAMES, isCommerceError, CommerceError } from './chunk-QQ3WY5L3.js';
|
|
12
12
|
import { isRecord } from './chunk-3M6U7ILB.js';
|
|
13
13
|
import { CommanderError, Command } from 'commander';
|
|
@@ -78,7 +78,7 @@ async function execCommand(command, args) {
|
|
|
78
78
|
// src/cli/lib/config-client.ts
|
|
79
79
|
async function importConfig() {
|
|
80
80
|
try {
|
|
81
|
-
return await import('./config-
|
|
81
|
+
return await import('./config-UI4EDG4L.js');
|
|
82
82
|
} catch (err) {
|
|
83
83
|
throw new CommerceError(
|
|
84
84
|
"INTERNAL_ERROR",
|
|
@@ -219,7 +219,7 @@ var package_default = {
|
|
|
219
219
|
"ajv-formats": "3.0.1",
|
|
220
220
|
"better-sqlite3": "13.0.3",
|
|
221
221
|
commander: "15.0.0",
|
|
222
|
-
fastify: "5.12.
|
|
222
|
+
fastify: "5.12.7",
|
|
223
223
|
picocolors: "1.1.1",
|
|
224
224
|
pino: "10.3.1",
|
|
225
225
|
yaml: "2.9.0",
|
|
@@ -337,12 +337,19 @@ async function storageChecks(config, createStore) {
|
|
|
337
337
|
} catch {
|
|
338
338
|
undeliveredCount = void 0;
|
|
339
339
|
}
|
|
340
|
+
let uncertainCount;
|
|
341
|
+
try {
|
|
342
|
+
uncertainCount = await store.countUncertainPaymentAttempts();
|
|
343
|
+
} catch {
|
|
344
|
+
uncertainCount = void 0;
|
|
345
|
+
}
|
|
340
346
|
const status = storeHealth.status === "pass" ? "PASS" : storeHealth.status === "warn" ? "WARN" : "FAIL";
|
|
341
347
|
const receiptsSuffix = receiptCount !== void 0 ? `; receipts=${receiptCount}${undeliveredCount !== void 0 && undeliveredCount > 0 ? ` (${undeliveredCount} undelivered)` : ""}` : "";
|
|
348
|
+
const uncertainSuffix = uncertainCount !== void 0 && uncertainCount > 0 ? `; ${uncertainCount} payment(s) with unknown settlement outcome, see GET /api/payment-attempts?uncertain=true` : "";
|
|
342
349
|
checks.push({
|
|
343
350
|
name: "Storage",
|
|
344
351
|
status,
|
|
345
|
-
detail: `${storeHealth.detail ?? "sqlite"}${receiptsSuffix}`
|
|
352
|
+
detail: `${storeHealth.detail ?? "sqlite"}${receiptsSuffix}${uncertainSuffix}`
|
|
346
353
|
});
|
|
347
354
|
} catch (err) {
|
|
348
355
|
checks.push({
|
|
@@ -508,9 +515,9 @@ var HEADER = `# Generated by \`agent-commerce init\`.
|
|
|
508
515
|
#
|
|
509
516
|
# server.adminToken and server.allowedOrigins are left unset, so no secret
|
|
510
517
|
# lands in a file you might commit. Without a token the operator routes
|
|
511
|
-
# (/api/receipts, /api/events) return 404.
|
|
512
|
-
# ledger: payer addresses, amounts and settlement
|
|
513
|
-
# these keys to the server block below:
|
|
518
|
+
# (/api/receipts, /api/events, /api/payment-attempts) return 404. These routes
|
|
519
|
+
# expose the merchant's commerce ledger: payer addresses, amounts and settlement
|
|
520
|
+
# hashes. To enable them, add these keys to the server block below:
|
|
514
521
|
# server:
|
|
515
522
|
# adminToken: \${ADMIN_TOKEN}
|
|
516
523
|
# allowedOrigins:
|
|
@@ -703,7 +710,75 @@ function offerHealthCheck(live, named) {
|
|
|
703
710
|
detail: `${problems.join("; ")}. The gateway logs each reason at debug level`
|
|
704
711
|
};
|
|
705
712
|
}
|
|
706
|
-
function
|
|
713
|
+
function extractLiveQuote(body) {
|
|
714
|
+
const payments = body?.["payments"];
|
|
715
|
+
const x402 = isRecord(payments) ? payments["x402"] : void 0;
|
|
716
|
+
const quote = isRecord(x402) ? x402["quote"] : void 0;
|
|
717
|
+
if (quote === void 0) return void 0;
|
|
718
|
+
if (!isRecord(quote)) return "unreadable";
|
|
719
|
+
const { issuer, requestScheme, extension } = quote;
|
|
720
|
+
return typeof issuer === "string" && typeof requestScheme === "string" && typeof extension === "string" ? { issuer, requestScheme, extension } : "unreadable";
|
|
721
|
+
}
|
|
722
|
+
async function localQuoteIssuer(signerPrivateKey, loadAccounts) {
|
|
723
|
+
let accounts;
|
|
724
|
+
try {
|
|
725
|
+
accounts = await loadAccounts();
|
|
726
|
+
} catch {
|
|
727
|
+
return void 0;
|
|
728
|
+
}
|
|
729
|
+
try {
|
|
730
|
+
return accounts.privateKeyToAccount(signerPrivateKey).address;
|
|
731
|
+
} catch {
|
|
732
|
+
return "invalid";
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
function quoteCheck(enabled, local, live, body, gatewayUrl, stale) {
|
|
736
|
+
const name = "Payments (quotes)";
|
|
737
|
+
if (enabled && local === "invalid") {
|
|
738
|
+
return {
|
|
739
|
+
name,
|
|
740
|
+
status: "FAIL",
|
|
741
|
+
detail: 'quote.signerPrivateKey is not a valid private key (expected "0x" followed by 64 hex characters), so start refuses it'
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
const localIssuer = local === void 0 ? void 0 : maskMiddle(local);
|
|
745
|
+
const quote = live === void 0 || live === "disabled" ? "unreadable" : extractLiveQuote(body);
|
|
746
|
+
if (quote === "unreadable") {
|
|
747
|
+
return enabled ? {
|
|
748
|
+
name,
|
|
749
|
+
status: "INFO",
|
|
750
|
+
detail: `ERC-8409 quotes enabled (experimental)${localIssuer !== void 0 ? `, issuer=${localIssuer} from the local key` : ""}; the gateway's issuer could not be read`
|
|
751
|
+
} : void 0;
|
|
752
|
+
}
|
|
753
|
+
if (quote === void 0) {
|
|
754
|
+
return enabled ? {
|
|
755
|
+
name,
|
|
756
|
+
status: "FAIL",
|
|
757
|
+
detail: `Local config enables ERC-8409 quotes, but the gateway at ${gatewayUrl} publishes no quote issuer${stale}`
|
|
758
|
+
} : void 0;
|
|
759
|
+
}
|
|
760
|
+
const issuer = maskMiddle(quote.issuer);
|
|
761
|
+
if (!enabled) {
|
|
762
|
+
return {
|
|
763
|
+
name,
|
|
764
|
+
status: "FAIL",
|
|
765
|
+
detail: `The gateway at ${gatewayUrl} signs ERC-8409 quotes as ${issuer}, but local config does not enable them${stale}`
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
if (local !== void 0 && local.toLowerCase() !== quote.issuer.toLowerCase()) {
|
|
769
|
+
return {
|
|
770
|
+
name,
|
|
771
|
+
status: "FAIL",
|
|
772
|
+
detail: `The gateway at ${gatewayUrl} signs ERC-8409 quotes as ${issuer}, but quote.signerPrivateKey belongs to ${localIssuer}${stale}`
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
return {
|
|
776
|
+
name,
|
|
777
|
+
status: "PASS",
|
|
778
|
+
detail: `ERC-8409 quotes (experimental) - 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}`
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
async function paymentChecks(config, wellKnown, gatewayUrl, chainDeploy = false, loadAccounts = () => import('viem/accounts')) {
|
|
707
782
|
const checks = [];
|
|
708
783
|
const stale = `; the gateway may be running against an older deployment - restart it${chainDeploy ? " or re-run chain:deploy" : ""}`;
|
|
709
784
|
const x402 = config?.payments.x402;
|
|
@@ -758,6 +833,15 @@ function paymentChecks(config, wellKnown, gatewayUrl, chainDeploy = false) {
|
|
|
758
833
|
const offerHealth = offerHealthCheck(live, named);
|
|
759
834
|
if (offerHealth !== void 0) checks.push(offerHealth);
|
|
760
835
|
}
|
|
836
|
+
const quotes = quoteCheck(
|
|
837
|
+
x402.quote !== void 0,
|
|
838
|
+
x402.quote !== void 0 ? await localQuoteIssuer(x402.quote.signerPrivateKey, loadAccounts) : void 0,
|
|
839
|
+
live,
|
|
840
|
+
wellKnown?.ok ? wellKnown.body : void 0,
|
|
841
|
+
gatewayUrl,
|
|
842
|
+
stale
|
|
843
|
+
);
|
|
844
|
+
if (quotes !== void 0) checks.push(quotes);
|
|
761
845
|
if (mode === "mainnet") {
|
|
762
846
|
checks.push(
|
|
763
847
|
mainnetSafetyCheck("Mainnet safety", "payTo", x402.facilitator, [
|
|
@@ -1025,7 +1109,9 @@ async function runDoctor(options, deps = {}) {
|
|
|
1025
1109
|
) : void 0;
|
|
1026
1110
|
checks.push(...protocolChecks(config, wellKnown));
|
|
1027
1111
|
checks.push(...ap2Checks(config));
|
|
1028
|
-
checks.push(
|
|
1112
|
+
checks.push(
|
|
1113
|
+
...await paymentChecks(config, wellKnown, gatewayUrl, chainDeploy, deps.loadViemAccounts)
|
|
1114
|
+
);
|
|
1029
1115
|
checks.push(...await storageChecks(config, createStore));
|
|
1030
1116
|
if (wellKnown?.ok) {
|
|
1031
1117
|
checks.push({
|
|
@@ -2450,7 +2536,7 @@ function buildProgram(io = processIo) {
|
|
|
2450
2536
|
`Start the gateway from ${DEFAULT_CONFIG_FILENAME} and serve until SIGTERM or SIGINT.`
|
|
2451
2537
|
).option("--config <path>", `path to ${DEFAULT_CONFIG_FILENAME}`).option("--env-file <path>", ENV_FILE_HELP).action(async (opts) => {
|
|
2452
2538
|
try {
|
|
2453
|
-
const { runGateway } = await import('./run-
|
|
2539
|
+
const { runGateway } = await import('./run-TEPYJUHG.js');
|
|
2454
2540
|
await runGateway(opts.config !== void 0 ? { configPath: opts.config } : {});
|
|
2455
2541
|
} catch (error) {
|
|
2456
2542
|
io.stderr(formatConfigError(error, false, false));
|