x402-trust-layer 5.1.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/CHANGELOG.md +55 -0
- package/DEPLOY.md +53 -0
- package/Dockerfile +30 -0
- package/LICENSE +21 -0
- package/README.md +294 -0
- package/dist/agents/a2a-payment.d.ts +37 -0
- package/dist/agents/a2a-payment.js +105 -0
- package/dist/agents/agent-escrow.d.ts +30 -0
- package/dist/agents/agent-escrow.js +23 -0
- package/dist/agents/agent-verify.d.ts +15 -0
- package/dist/agents/agent-verify.js +112 -0
- package/dist/agents/api-router.d.ts +32 -0
- package/dist/agents/api-router.js +228 -0
- package/dist/agents/attestation-registry.d.ts +35 -0
- package/dist/agents/attestation-registry.js +76 -0
- package/dist/agents/audition-coach.d.ts +45 -0
- package/dist/agents/audition-coach.js +257 -0
- package/dist/agents/bedrock-bridge.d.ts +3 -0
- package/dist/agents/bedrock-bridge.js +60 -0
- package/dist/agents/budget-allocator.d.ts +24 -0
- package/dist/agents/budget-allocator.js +31 -0
- package/dist/agents/compliance-ledger.d.ts +66 -0
- package/dist/agents/compliance-ledger.js +80 -0
- package/dist/agents/dispute-resolver.d.ts +62 -0
- package/dist/agents/dispute-resolver.js +124 -0
- package/dist/agents/evidence-locker.d.ts +30 -0
- package/dist/agents/evidence-locker.js +47 -0
- package/dist/agents/facilitator-failover.d.ts +15 -0
- package/dist/agents/facilitator-failover.js +18 -0
- package/dist/agents/identity-gate.d.ts +20 -0
- package/dist/agents/identity-gate.js +79 -0
- package/dist/agents/mandate-compiler.d.ts +51 -0
- package/dist/agents/mandate-compiler.js +73 -0
- package/dist/agents/mandate-diff.d.ts +41 -0
- package/dist/agents/mandate-diff.js +170 -0
- package/dist/agents/market-buy-advisor.d.ts +65 -0
- package/dist/agents/market-buy-advisor.js +234 -0
- package/dist/agents/merchant-trust.d.ts +38 -0
- package/dist/agents/merchant-trust.js +171 -0
- package/dist/agents/mpp-session-broker.d.ts +27 -0
- package/dist/agents/mpp-session-broker.js +29 -0
- package/dist/agents/mpp-session-v2.d.ts +76 -0
- package/dist/agents/mpp-session-v2.js +269 -0
- package/dist/agents/payment-intent-compiler.d.ts +21 -0
- package/dist/agents/payment-intent-compiler.js +45 -0
- package/dist/agents/pipeline-execute.d.ts +40 -0
- package/dist/agents/pipeline-execute.js +100 -0
- package/dist/agents/pipeline-trust-v2.d.ts +31 -0
- package/dist/agents/pipeline-trust-v2.js +111 -0
- package/dist/agents/pre-x402-guard.d.ts +35 -0
- package/dist/agents/pre-x402-guard.js +84 -0
- package/dist/agents/quality-escrow-semantic.d.ts +88 -0
- package/dist/agents/quality-escrow-semantic.js +137 -0
- package/dist/agents/quality-escrow.d.ts +65 -0
- package/dist/agents/quality-escrow.js +104 -0
- package/dist/agents/quality-monitor.d.ts +32 -0
- package/dist/agents/quality-monitor.js +77 -0
- package/dist/agents/rail-optimizer.d.ts +33 -0
- package/dist/agents/rail-optimizer.js +133 -0
- package/dist/agents/receipt-auditor.d.ts +14 -0
- package/dist/agents/receipt-auditor.js +145 -0
- package/dist/agents/refund-arbiter.d.ts +24 -0
- package/dist/agents/refund-arbiter.js +70 -0
- package/dist/agents/research-brief.d.ts +14 -0
- package/dist/agents/research-brief.js +66 -0
- package/dist/agents/risk-gate.d.ts +11 -0
- package/dist/agents/risk-gate.js +78 -0
- package/dist/agents/settlement-graph.d.ts +16 -0
- package/dist/agents/settlement-graph.js +38 -0
- package/dist/agents/spend-governor.d.ts +2 -0
- package/dist/agents/spend-governor.js +70 -0
- package/dist/agents/trust-network.d.ts +138 -0
- package/dist/agents/trust-network.js +244 -0
- package/dist/agents/x402-proxy.d.ts +32 -0
- package/dist/agents/x402-proxy.js +90 -0
- package/dist/client/demo-alchemy-live.d.ts +1 -0
- package/dist/client/demo-alchemy-live.js +226 -0
- package/dist/client/demo-tail.d.ts +1 -0
- package/dist/client/demo-tail.js +100 -0
- package/dist/client/demo.d.ts +1 -0
- package/dist/client/demo.js +293 -0
- package/dist/config.d.ts +94 -0
- package/dist/config.js +223 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +389 -0
- package/dist/lib/agent-response.d.ts +14 -0
- package/dist/lib/agent-response.js +13 -0
- package/dist/lib/agentic-gateways.d.ts +5 -0
- package/dist/lib/agentic-gateways.js +15 -0
- package/dist/lib/agentic-probes.d.ts +10 -0
- package/dist/lib/agentic-probes.js +49 -0
- package/dist/lib/alchemy-x402-fetch.d.ts +16 -0
- package/dist/lib/alchemy-x402-fetch.js +95 -0
- package/dist/lib/apply-verifier-body.d.ts +7 -0
- package/dist/lib/apply-verifier-body.js +179 -0
- package/dist/lib/attestation.d.ts +30 -0
- package/dist/lib/attestation.js +107 -0
- package/dist/lib/bazaar-extension.d.ts +15 -0
- package/dist/lib/bazaar-extension.js +265 -0
- package/dist/lib/bazaar.d.ts +100 -0
- package/dist/lib/bazaar.js +341 -0
- package/dist/lib/certified-sellers.d.ts +41 -0
- package/dist/lib/certified-sellers.js +129 -0
- package/dist/lib/chains.d.ts +20 -0
- package/dist/lib/chains.js +78 -0
- package/dist/lib/db-persistence.d.ts +7 -0
- package/dist/lib/db-persistence.js +65 -0
- package/dist/lib/db.d.ts +5 -0
- package/dist/lib/db.js +113 -0
- package/dist/lib/discovery-page.d.ts +2 -0
- package/dist/lib/discovery-page.js +71 -0
- package/dist/lib/ecosystem-telemetry.d.ts +20 -0
- package/dist/lib/ecosystem-telemetry.js +80 -0
- package/dist/lib/erc8004/agent-card.d.ts +34 -0
- package/dist/lib/erc8004/agent-card.js +151 -0
- package/dist/lib/erc8004/cache.d.ts +3 -0
- package/dist/lib/erc8004/cache.js +17 -0
- package/dist/lib/erc8004/constants.d.ts +22 -0
- package/dist/lib/erc8004/constants.js +35 -0
- package/dist/lib/erc8004/registry.d.ts +19 -0
- package/dist/lib/erc8004/registry.js +171 -0
- package/dist/lib/erc8004/resolve-agent.d.ts +7 -0
- package/dist/lib/erc8004/resolve-agent.js +70 -0
- package/dist/lib/erc8004/trust-score.d.ts +33 -0
- package/dist/lib/erc8004/trust-score.js +136 -0
- package/dist/lib/escrow-ledger.d.ts +14 -0
- package/dist/lib/escrow-ledger.js +54 -0
- package/dist/lib/escrow-unified.d.ts +15 -0
- package/dist/lib/escrow-unified.js +28 -0
- package/dist/lib/facilitator-extra.d.ts +13 -0
- package/dist/lib/facilitator-extra.js +52 -0
- package/dist/lib/facilitators.d.ts +20 -0
- package/dist/lib/facilitators.js +89 -0
- package/dist/lib/host-policy.d.ts +4 -0
- package/dist/lib/host-policy.js +20 -0
- package/dist/lib/idempotency.d.ts +4 -0
- package/dist/lib/idempotency.js +120 -0
- package/dist/lib/ledger.d.ts +2 -0
- package/dist/lib/ledger.js +17 -0
- package/dist/lib/logger.d.ts +6 -0
- package/dist/lib/logger.js +24 -0
- package/dist/lib/mandate-vc.d.ts +20 -0
- package/dist/lib/mandate-vc.js +25 -0
- package/dist/lib/mandate.d.ts +44 -0
- package/dist/lib/mandate.js +190 -0
- package/dist/lib/marketplace.d.ts +7 -0
- package/dist/lib/marketplace.js +127 -0
- package/dist/lib/migrations.d.ts +2 -0
- package/dist/lib/migrations.js +130 -0
- package/dist/lib/nonce-store.d.ts +6 -0
- package/dist/lib/nonce-store.js +109 -0
- package/dist/lib/openapi-agentcash.d.ts +5 -0
- package/dist/lib/openapi-agentcash.js +288 -0
- package/dist/lib/openapi-meta.d.ts +5 -0
- package/dist/lib/openapi-meta.js +235 -0
- package/dist/lib/otel.d.ts +2 -0
- package/dist/lib/otel.js +25 -0
- package/dist/lib/paid-resource-url.d.ts +6 -0
- package/dist/lib/paid-resource-url.js +47 -0
- package/dist/lib/parse-with-verifier-fallback.d.ts +3 -0
- package/dist/lib/parse-with-verifier-fallback.js +13 -0
- package/dist/lib/payment-request-context.d.ts +10 -0
- package/dist/lib/payment-request-context.js +5 -0
- package/dist/lib/payment-response.d.ts +13 -0
- package/dist/lib/payment-response.js +39 -0
- package/dist/lib/payto-guard.d.ts +10 -0
- package/dist/lib/payto-guard.js +20 -0
- package/dist/lib/probe.d.ts +29 -0
- package/dist/lib/probe.js +157 -0
- package/dist/lib/problem-detail.d.ts +10 -0
- package/dist/lib/problem-detail.js +14 -0
- package/dist/lib/rate-limit.d.ts +12 -0
- package/dist/lib/rate-limit.js +126 -0
- package/dist/lib/replay-middleware.d.ts +3 -0
- package/dist/lib/replay-middleware.js +27 -0
- package/dist/lib/response-guard.d.ts +5 -0
- package/dist/lib/response-guard.js +40 -0
- package/dist/lib/safe-fetch.d.ts +5 -0
- package/dist/lib/safe-fetch.js +19 -0
- package/dist/lib/security.d.ts +13 -0
- package/dist/lib/security.js +61 -0
- package/dist/lib/semantic-judge.d.ts +14 -0
- package/dist/lib/semantic-judge.js +107 -0
- package/dist/lib/semantic-judge.test.d.ts +1 -0
- package/dist/lib/semantic-judge.test.js +11 -0
- package/dist/lib/ssrf.d.ts +10 -0
- package/dist/lib/ssrf.js +130 -0
- package/dist/lib/ssrf.test.d.ts +1 -0
- package/dist/lib/ssrf.test.js +16 -0
- package/dist/lib/suite-catalog.d.ts +83 -0
- package/dist/lib/suite-catalog.js +131 -0
- package/dist/lib/telemetry.d.ts +5 -0
- package/dist/lib/telemetry.js +37 -0
- package/dist/lib/verifier-fast-path.d.ts +10 -0
- package/dist/lib/verifier-fast-path.js +44 -0
- package/dist/lib/verifier-probe-protocol.d.ts +7 -0
- package/dist/lib/verifier-probe-protocol.js +115 -0
- package/dist/lib/verify-examples.d.ts +2 -0
- package/dist/lib/verify-examples.js +438 -0
- package/dist/lib/version.d.ts +2 -0
- package/dist/lib/version.js +2 -0
- package/dist/lib/webhook-auth.d.ts +3 -0
- package/dist/lib/webhook-auth.js +34 -0
- package/dist/lib/webhook-routes.d.ts +2 -0
- package/dist/lib/webhook-routes.js +112 -0
- package/dist/lib/webhooks.d.ts +23 -0
- package/dist/lib/webhooks.js +123 -0
- package/dist/lib/webhooks.test.d.ts +1 -0
- package/dist/lib/webhooks.test.js +16 -0
- package/dist/lib/x402-client-options.d.ts +28 -0
- package/dist/lib/x402-client-options.js +138 -0
- package/dist/lib/x402-headers.d.ts +10 -0
- package/dist/lib/x402-headers.js +27 -0
- package/dist/lib/x402-paid.d.ts +5 -0
- package/dist/lib/x402-paid.js +252 -0
- package/dist/lib/x402-payment-replay.d.ts +22 -0
- package/dist/lib/x402-payment-replay.js +57 -0
- package/dist/lib/x402gle-host-verify.d.ts +3 -0
- package/dist/lib/x402gle-host-verify.js +27 -0
- package/dist/protocol/agent-passport.d.ts +34 -0
- package/dist/protocol/agent-passport.js +44 -0
- package/dist/protocol/compliance-v2.d.ts +21 -0
- package/dist/protocol/compliance-v2.js +19 -0
- package/dist/protocol/credit-bureau.d.ts +18 -0
- package/dist/protocol/credit-bureau.js +44 -0
- package/dist/protocol/crypto.d.ts +6 -0
- package/dist/protocol/crypto.js +41 -0
- package/dist/protocol/escrow-fsm.d.ts +33 -0
- package/dist/protocol/escrow-fsm.js +99 -0
- package/dist/protocol/fraud-engine.d.ts +28 -0
- package/dist/protocol/fraud-engine.js +77 -0
- package/dist/protocol/observability.d.ts +14 -0
- package/dist/protocol/observability.js +21 -0
- package/dist/protocol/pipeline-full-trust.d.ts +40 -0
- package/dist/protocol/pipeline-full-trust.js +96 -0
- package/dist/protocol/proof-of-execution.d.ts +36 -0
- package/dist/protocol/proof-of-execution.js +48 -0
- package/dist/protocol/reasoning-audit.d.ts +27 -0
- package/dist/protocol/reasoning-audit.js +51 -0
- package/dist/protocol/replay-guard.d.ts +28 -0
- package/dist/protocol/replay-guard.js +76 -0
- package/dist/protocol/replay-guard.test.d.ts +1 -0
- package/dist/protocol/replay-guard.test.js +10 -0
- package/dist/protocol/security-audit.d.ts +18 -0
- package/dist/protocol/security-audit.js +45 -0
- package/dist/protocol/store.d.ts +5 -0
- package/dist/protocol/store.js +59 -0
- package/dist/protocol/threat-catalog.d.ts +13 -0
- package/dist/protocol/threat-catalog.js +75 -0
- package/dist/protocol/trust-oracle.d.ts +23 -0
- package/dist/protocol/trust-oracle.js +30 -0
- package/dist/protocol/trust-score-v2.d.ts +33 -0
- package/dist/protocol/trust-score-v2.js +78 -0
- package/dist/protocol/zk-proofs.d.ts +24 -0
- package/dist/protocol/zk-proofs.js +32 -0
- package/dist/routes/a2a-agent-card.d.ts +3 -0
- package/dist/routes/a2a-agent-card.js +28 -0
- package/dist/routes/catalog.d.ts +5 -0
- package/dist/routes/catalog.js +47 -0
- package/dist/routes/register-all.d.ts +3 -0
- package/dist/routes/register-all.js +1240 -0
- package/dist/routes/schemas.d.ts +83 -0
- package/dist/routes/schemas.js +38 -0
- package/dist/routes/shared.d.ts +16 -0
- package/dist/routes/shared.js +27 -0
- package/dist/routes-protocol.d.ts +10 -0
- package/dist/routes-protocol.js +322 -0
- package/dist/routes.d.ts +2 -0
- package/dist/routes.js +2 -0
- package/dist/types.d.ts +66 -0
- package/dist/types.js +1 -0
- package/openapi.json +7940 -0
- package/package.json +124 -0
- package/public/.well-known/ai-plugin.json +12 -0
- package/public/assets/aegis-logo-blue.png +0 -0
- package/public/assets/aegis-logo-gold.png +0 -0
- package/public/assets/aegis-logo-green.png +0 -0
- package/public/assets/aegis-logo-purple.png +0 -0
- package/public/assets/aegis-logo-red.png +0 -0
- package/public/assets/aegis-logo-white.png +0 -0
- package/public/assets/aegis-logo.png +0 -0
- package/public/assets/x402-trustlayer-logo.png +0 -0
- package/public/assets/x402-trustlayer-logo.svg +5 -0
- package/public/data/agents.json +1528 -0
- package/public/index.html +198 -0
- package/public/landing.css +342 -0
- package/public/landing.js +405 -0
- package/public/llms-full.txt +582 -0
- package/public/llms.txt +132 -0
- package/public/skill.md +135 -0
- package/railway.toml +9 -0
- package/scripts/docker-entrypoint.sh +7 -0
- package/scripts/patch-facilitator-timeout.mjs +61 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { config } from "../config.js";
|
|
2
|
+
import { buildBazaarExtension } from "../lib/bazaar-extension.js";
|
|
3
|
+
import { agentTrustMeta, withAgentTrust } from "../lib/agent-response.js";
|
|
4
|
+
import { hostOf, probeEndpoint } from "../lib/probe.js";
|
|
5
|
+
import { assertSafeOutboundUrl } from "../lib/ssrf.js";
|
|
6
|
+
import { VERIFY_EXAMPLES } from "../lib/verify-examples.js";
|
|
7
|
+
async function fetchJson(url, timeoutMs = 15_000) {
|
|
8
|
+
assertSafeOutboundUrl(url);
|
|
9
|
+
const controller = new AbortController();
|
|
10
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
11
|
+
try {
|
|
12
|
+
const res = await fetch(url, {
|
|
13
|
+
headers: { accept: "application/json" },
|
|
14
|
+
signal: controller.signal,
|
|
15
|
+
redirect: "manual",
|
|
16
|
+
});
|
|
17
|
+
clearTimeout(timer);
|
|
18
|
+
const text = await res.text();
|
|
19
|
+
let data = null;
|
|
20
|
+
try {
|
|
21
|
+
data = text ? JSON.parse(text) : null;
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
data = { raw: text.slice(0, 300) };
|
|
25
|
+
}
|
|
26
|
+
return { ok: res.ok, status: res.status, data };
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
clearTimeout(timer);
|
|
30
|
+
return { ok: false, status: 0, data: { error: err instanceof Error ? err.message : String(err) } };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function extractWellKnownUrls(data, origin) {
|
|
34
|
+
if (!data || typeof data !== "object")
|
|
35
|
+
return [];
|
|
36
|
+
const record = data;
|
|
37
|
+
const resources = record.resources;
|
|
38
|
+
if (!Array.isArray(resources))
|
|
39
|
+
return [];
|
|
40
|
+
return resources
|
|
41
|
+
.map((r) => (typeof r === "string" ? r : typeof r === "object" && r && "url" in r ? String(r.url) : null))
|
|
42
|
+
.filter((u) => typeof u === "string" && u.startsWith("http"));
|
|
43
|
+
}
|
|
44
|
+
function extractOpenApiPaidPaths(data, origin) {
|
|
45
|
+
if (!data || typeof data !== "object")
|
|
46
|
+
return [];
|
|
47
|
+
const paths = data.paths;
|
|
48
|
+
if (!paths || typeof paths !== "object")
|
|
49
|
+
return [];
|
|
50
|
+
const base = origin.replace(/\/$/, "");
|
|
51
|
+
const out = [];
|
|
52
|
+
for (const [path, methods] of Object.entries(paths)) {
|
|
53
|
+
if (path === "/health")
|
|
54
|
+
continue;
|
|
55
|
+
if (!methods || typeof methods !== "object")
|
|
56
|
+
continue;
|
|
57
|
+
for (const method of Object.keys(methods)) {
|
|
58
|
+
if (["get", "post", "put", "delete"].includes(method)) {
|
|
59
|
+
out.push({ method: method.toUpperCase(), path, url: `${base}${path}` });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
function bazaarShapeOk(path, method, example) {
|
|
66
|
+
const ext = buildBazaarExtension(path, method, example);
|
|
67
|
+
const schema = ext.schema;
|
|
68
|
+
const props = schema.properties;
|
|
69
|
+
if (!props?.input)
|
|
70
|
+
return false;
|
|
71
|
+
const inputProps = props.input;
|
|
72
|
+
const inputInner = inputProps.properties;
|
|
73
|
+
const hasInput = Boolean(inputInner?.body) ||
|
|
74
|
+
Boolean(inputInner?.queryParams) ||
|
|
75
|
+
method === "GET";
|
|
76
|
+
const outputProps = props.output;
|
|
77
|
+
const hasOutput = Boolean(ext.info.output) || Boolean(outputProps);
|
|
78
|
+
return hasInput && hasOutput && Boolean(schema.$schema);
|
|
79
|
+
}
|
|
80
|
+
function auditRoute(url, method, fastProbe) {
|
|
81
|
+
return (async () => {
|
|
82
|
+
const issues = [];
|
|
83
|
+
const fixInstructions = [];
|
|
84
|
+
const probeMethod = method === "GET" ? "GET" : "POST";
|
|
85
|
+
const probe = await probeEndpoint(url, {
|
|
86
|
+
method: probeMethod,
|
|
87
|
+
body: probeMethod === "POST" ? "{}" : undefined,
|
|
88
|
+
fastSynthetic: fastProbe,
|
|
89
|
+
timeoutMs: fastProbe ? 1_500 : 6_000,
|
|
90
|
+
});
|
|
91
|
+
let score = 50;
|
|
92
|
+
if (probe.status === 402) {
|
|
93
|
+
score += 25;
|
|
94
|
+
}
|
|
95
|
+
else if (probe.status === 200 && method === "POST") {
|
|
96
|
+
issues.push("POST route returns 200 without payment — verifiers expect 402 or paid 200 with body");
|
|
97
|
+
fixInstructions.push("Wrap route with x402 middleware; return 402 for unpaid POST.");
|
|
98
|
+
score -= 15;
|
|
99
|
+
}
|
|
100
|
+
else if (probe.status === 0) {
|
|
101
|
+
issues.push("Endpoint unreachable from coach probe");
|
|
102
|
+
fixInstructions.push("Check Railway/deploy URL, TLS, and firewall.");
|
|
103
|
+
score -= 40;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
issues.push(`Unexpected probe status ${probe.status}`);
|
|
107
|
+
fixInstructions.push("Ensure unpaid probe returns HTTP 402 with paymentOptions.");
|
|
108
|
+
score -= 10;
|
|
109
|
+
}
|
|
110
|
+
if (probe.priceUsdc == null && probe.requiresPayment) {
|
|
111
|
+
issues.push("402 missing parseable USDC price");
|
|
112
|
+
fixInstructions.push("Include paymentOptions[].price per chain in 402 body.");
|
|
113
|
+
score -= 10;
|
|
114
|
+
}
|
|
115
|
+
else if (probe.priceUsdc != null && probe.priceUsdc > 0) {
|
|
116
|
+
score += 8;
|
|
117
|
+
}
|
|
118
|
+
if (!url.startsWith("https://")) {
|
|
119
|
+
issues.push("Resource URL is not HTTPS");
|
|
120
|
+
fixInstructions.push("Set PUBLIC_BASE_URL to https:// in production.");
|
|
121
|
+
score -= 20;
|
|
122
|
+
}
|
|
123
|
+
const path = new URL(url).pathname;
|
|
124
|
+
if (method === "POST" && fastProbe) {
|
|
125
|
+
const example = VERIFY_EXAMPLES[path];
|
|
126
|
+
if (!example) {
|
|
127
|
+
issues.push("Missing VERIFY_EXAMPLES entry for verifier empty-body merge");
|
|
128
|
+
fixInstructions.push(`Add canonical body to src/lib/verify-examples.ts for ${path}`);
|
|
129
|
+
score -= 12;
|
|
130
|
+
}
|
|
131
|
+
else if (!bazaarShapeOk(path, method, example)) {
|
|
132
|
+
issues.push("Bazaar schema shape may fail AgentCash discovery");
|
|
133
|
+
fixInstructions.push("Use schema.properties.input.properties.body and output.properties.example (see bazaar-extension.ts).");
|
|
134
|
+
score -= 15;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
score += 10;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (probe.paymentOptions.length >= 2)
|
|
141
|
+
score += 5;
|
|
142
|
+
score = Math.max(0, Math.min(100, score));
|
|
143
|
+
const status = score >= 75 ? "pass" : score >= 55 ? "warn" : "fail";
|
|
144
|
+
return {
|
|
145
|
+
url,
|
|
146
|
+
method,
|
|
147
|
+
probeStatus: probe.status,
|
|
148
|
+
requiresPayment: probe.requiresPayment,
|
|
149
|
+
priceUsdc: probe.priceUsdc,
|
|
150
|
+
scoreEstimate: score,
|
|
151
|
+
status,
|
|
152
|
+
issues,
|
|
153
|
+
fixInstructions,
|
|
154
|
+
};
|
|
155
|
+
})();
|
|
156
|
+
}
|
|
157
|
+
export async function runAuditionCoach(input) {
|
|
158
|
+
const origin = input.origin.replace(/\/$/, "");
|
|
159
|
+
assertSafeOutboundUrl(origin);
|
|
160
|
+
const isOwnSuite = hostOf(origin) === hostOf(config.canonicalOrigin) ||
|
|
161
|
+
hostOf(origin) === hostOf(config.publicBaseUrl);
|
|
162
|
+
const fastProbe = isOwnSuite;
|
|
163
|
+
const maxRoutes = fastProbe
|
|
164
|
+
? Math.min(Math.max(input.maxRoutes ?? 3, 1), 3)
|
|
165
|
+
: Math.min(Math.max(input.maxRoutes ?? 24, 1), 30);
|
|
166
|
+
const globalFixes = [];
|
|
167
|
+
const routes = [];
|
|
168
|
+
const [openapiRes, wellKnownRes, rootHead] = await Promise.all([
|
|
169
|
+
fetchJson(`${origin}/openapi.json`, fastProbe ? 4_000 : 15_000),
|
|
170
|
+
fetchJson(`${origin}/.well-known/x402`, fastProbe ? 4_000 : 15_000),
|
|
171
|
+
fetch(`${origin}/`, { method: "HEAD" }).catch(() => null),
|
|
172
|
+
]);
|
|
173
|
+
if (!openapiRes.ok) {
|
|
174
|
+
globalFixes.push("Publish GET /openapi.json with x-payment-info and requestBody examples.");
|
|
175
|
+
}
|
|
176
|
+
if (!wellKnownRes.ok) {
|
|
177
|
+
globalFixes.push("Publish GET /.well-known/x402 listing all paid resource URLs.");
|
|
178
|
+
}
|
|
179
|
+
const openapiPaths = openapiRes.ok ? extractOpenApiPaidPaths(openapiRes.data, origin) : [];
|
|
180
|
+
const wellKnownUrls = wellKnownRes.ok ? extractWellKnownUrls(wellKnownRes.data, origin) : [];
|
|
181
|
+
if (openapiRes.ok && typeof openapiRes.data === "object") {
|
|
182
|
+
const paths = openapiRes.data.paths;
|
|
183
|
+
if (paths && "/health" in paths) {
|
|
184
|
+
globalFixes.push("Remove /health from OpenAPI paid paths (x402scan registers it incorrectly).");
|
|
185
|
+
}
|
|
186
|
+
const info = openapiRes.data.info;
|
|
187
|
+
if (!info?.["x-guidance"]) {
|
|
188
|
+
globalFixes.push("Add info.x-guidance in OpenAPI for agent instructions.");
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const x402gleHeader = rootHead?.headers.get("x-x402gle-verify");
|
|
192
|
+
if (!x402gleHeader) {
|
|
193
|
+
globalFixes.push("Set X402GLE_CHALLENGE_TOKEN on host and emit X-X402GLE-VERIFY header for x402gle domain claim.");
|
|
194
|
+
}
|
|
195
|
+
if (wellKnownUrls.length && openapiPaths.length && wellKnownUrls.length !== openapiPaths.length) {
|
|
196
|
+
globalFixes.push(`Align /.well-known/x402 (${wellKnownUrls.length} URLs) with OpenAPI paid paths (${openapiPaths.length}).`);
|
|
197
|
+
}
|
|
198
|
+
const urlsToAudit = new Map();
|
|
199
|
+
for (const u of wellKnownUrls.slice(0, maxRoutes)) {
|
|
200
|
+
urlsToAudit.set(u, u.includes("registry") ? "GET" : "POST");
|
|
201
|
+
}
|
|
202
|
+
for (const p of openapiPaths.slice(0, maxRoutes)) {
|
|
203
|
+
const full = `${origin}${p.path}`;
|
|
204
|
+
urlsToAudit.set(full, p.method);
|
|
205
|
+
}
|
|
206
|
+
const routeAudits = await Promise.all([...urlsToAudit.entries()].map(([url, method]) => auditRoute(url, method, fastProbe)));
|
|
207
|
+
routes.push(...routeAudits);
|
|
208
|
+
const avg = routes.length > 0 ? routes.reduce((s, r) => s + r.scoreEstimate, 0) / routes.length : 0;
|
|
209
|
+
const failCount = routes.filter((r) => r.status === "fail").length;
|
|
210
|
+
const hostScoreEstimate = Math.round(avg);
|
|
211
|
+
const summary = routes.length === 0
|
|
212
|
+
? "No routes discovered — fix OpenAPI and .well-known/x402 first."
|
|
213
|
+
: `${routes.length} routes audited; ~${hostScoreEstimate} avg score; ${failCount} need fixes before Dexter/x402gle pass (75+).`;
|
|
214
|
+
const coaching = {
|
|
215
|
+
hostScoreEstimate,
|
|
216
|
+
failCount,
|
|
217
|
+
passCount: routes.filter((r) => r.status === "pass").length,
|
|
218
|
+
warnCount: routes.filter((r) => r.status === "warn").length,
|
|
219
|
+
topFixes: routes.flatMap((r) => r.fixInstructions).slice(0, 8),
|
|
220
|
+
};
|
|
221
|
+
return withAgentTrust({
|
|
222
|
+
status: "ok",
|
|
223
|
+
ok: true,
|
|
224
|
+
coached: true,
|
|
225
|
+
allowed: hostScoreEstimate >= 75 && failCount === 0,
|
|
226
|
+
origin,
|
|
227
|
+
auditedAt: new Date().toISOString(),
|
|
228
|
+
hostScoreEstimate,
|
|
229
|
+
summary,
|
|
230
|
+
discovery: {
|
|
231
|
+
openapiOk: openapiRes.ok,
|
|
232
|
+
wellKnownOk: wellKnownRes.ok,
|
|
233
|
+
resourceCount: wellKnownUrls.length || null,
|
|
234
|
+
openapiPathCount: openapiPaths.length || null,
|
|
235
|
+
},
|
|
236
|
+
globalFixes,
|
|
237
|
+
routes: routes.sort((a, b) => a.scoreEstimate - b.scoreEstimate),
|
|
238
|
+
routeAudits: routes.sort((a, b) => a.scoreEstimate - b.scoreEstimate),
|
|
239
|
+
coaching,
|
|
240
|
+
nextCommands: [
|
|
241
|
+
`npx -y @dexterai/opendexter@latest audition "${origin}" --json`,
|
|
242
|
+
`npm run discovery:check -- ${origin}/api/x402/proxy`,
|
|
243
|
+
"Fix fixInstructions per route → redeploy → re-run coach",
|
|
244
|
+
],
|
|
245
|
+
dexterAuditionNote: "Coach is static + unpaid probes. Dexter audition runs real paid tests and updates catalog quality scores.",
|
|
246
|
+
}, agentTrustMeta([
|
|
247
|
+
"openapi_checked",
|
|
248
|
+
"well_known_checked",
|
|
249
|
+
openapiRes.ok ? "openapi_ok" : "openapi_missing",
|
|
250
|
+
wellKnownRes.ok ? "well_known_ok" : "well_known_missing",
|
|
251
|
+
routes.length > 0 ? "routes_audited" : "no_routes_found",
|
|
252
|
+
], {
|
|
253
|
+
confidence: routes.length > 0 ? 0.88 : 0.55,
|
|
254
|
+
sources: ["audition-coach", "x402gle-aligned"],
|
|
255
|
+
accuracy_note: "Coach uses unpaid 402 probes only; Dexter/x402gle paid auditions grade live settlement responses.",
|
|
256
|
+
}));
|
|
257
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { config } from "../config.js";
|
|
3
|
+
import { parseWithVerifierFallback } from "../lib/parse-with-verifier-fallback.js";
|
|
4
|
+
const bedrockSchema = z.object({
|
|
5
|
+
actionGroup: z.string().optional(),
|
|
6
|
+
apiPath: z.string().optional(),
|
|
7
|
+
requestBody: z
|
|
8
|
+
.object({
|
|
9
|
+
content: z
|
|
10
|
+
.record(z.object({
|
|
11
|
+
properties: z.record(z.unknown()).optional(),
|
|
12
|
+
}))
|
|
13
|
+
.optional(),
|
|
14
|
+
})
|
|
15
|
+
.optional(),
|
|
16
|
+
});
|
|
17
|
+
function extractBedrockProperties(body) {
|
|
18
|
+
const content = body.requestBody?.content;
|
|
19
|
+
if (!content)
|
|
20
|
+
return {};
|
|
21
|
+
const json = content["application/json"];
|
|
22
|
+
return json?.properties ?? {};
|
|
23
|
+
}
|
|
24
|
+
/** AWS Bedrock AgentCore action-group → Trust Layer guard preflight. */
|
|
25
|
+
export async function handleBedrockPreflight(req, res) {
|
|
26
|
+
const parsed = parseWithVerifierFallback("/api/bedrock/preflight", bedrockSchema, req.body);
|
|
27
|
+
if (!parsed.success) {
|
|
28
|
+
res.status(400).json({ error: parsed.error.flatten() });
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const params = extractBedrockProperties(parsed.data);
|
|
32
|
+
const upstream = await fetch(`${config.publicBaseUrl}/api/guard/pre-x402`, {
|
|
33
|
+
method: "POST",
|
|
34
|
+
headers: { "content-type": "application/json" },
|
|
35
|
+
body: JSON.stringify({
|
|
36
|
+
agentId: String(params.agentId ?? "bedrock-agent"),
|
|
37
|
+
walletAddress: String(params.walletAddress ?? config.payToEvm ?? config.payTo),
|
|
38
|
+
targetUrl: String(params.targetUrl ?? config.publicBaseUrl),
|
|
39
|
+
estimatedCostUsdc: Number(params.estimatedCostUsdc ?? 0.05),
|
|
40
|
+
policy: params.policy ?? {
|
|
41
|
+
dailyCapUsdc: 50,
|
|
42
|
+
perCallCapUsdc: 1,
|
|
43
|
+
allowedHosts: ["*"],
|
|
44
|
+
},
|
|
45
|
+
}),
|
|
46
|
+
});
|
|
47
|
+
const result = await upstream.json();
|
|
48
|
+
res.json({
|
|
49
|
+
messageVersion: "1.0",
|
|
50
|
+
response: {
|
|
51
|
+
actionGroup: parsed.data.actionGroup ?? "TrustLayerGuard",
|
|
52
|
+
apiPath: parsed.data.apiPath ?? "/guard/pre-x402",
|
|
53
|
+
httpMethod: "POST",
|
|
54
|
+
httpStatusCode: upstream.status,
|
|
55
|
+
responseBody: {
|
|
56
|
+
"application/json": { body: JSON.stringify(result) },
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type FleetAgent = {
|
|
2
|
+
agentId: string;
|
|
3
|
+
priority: number;
|
|
4
|
+
requestedUsdc: number;
|
|
5
|
+
dailyRemainingUsdc: number;
|
|
6
|
+
};
|
|
7
|
+
export type BudgetAllocatorInput = {
|
|
8
|
+
fleetId: string;
|
|
9
|
+
poolRemainingUsdc: number;
|
|
10
|
+
agents: FleetAgent[];
|
|
11
|
+
};
|
|
12
|
+
export type Allocation = {
|
|
13
|
+
agentId: string;
|
|
14
|
+
allocatedUsdc: number;
|
|
15
|
+
approved: boolean;
|
|
16
|
+
reason: string;
|
|
17
|
+
};
|
|
18
|
+
export type BudgetAllocatorResult = {
|
|
19
|
+
fleetId: string;
|
|
20
|
+
poolRemainingUsdc: number;
|
|
21
|
+
poolAfterUsdc: number;
|
|
22
|
+
allocations: Allocation[];
|
|
23
|
+
};
|
|
24
|
+
export declare function runBudgetAllocator(input: BudgetAllocatorInput): BudgetAllocatorResult;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export function runBudgetAllocator(input) {
|
|
2
|
+
const sorted = [...input.agents].sort((a, b) => b.priority - a.priority);
|
|
3
|
+
let pool = input.poolRemainingUsdc;
|
|
4
|
+
const allocations = [];
|
|
5
|
+
for (const agent of sorted) {
|
|
6
|
+
const cap = Math.min(agent.requestedUsdc, agent.dailyRemainingUsdc);
|
|
7
|
+
if (pool >= cap && cap > 0) {
|
|
8
|
+
allocations.push({
|
|
9
|
+
agentId: agent.agentId,
|
|
10
|
+
allocatedUsdc: cap,
|
|
11
|
+
approved: true,
|
|
12
|
+
reason: "Approved within fleet pool and agent daily cap",
|
|
13
|
+
});
|
|
14
|
+
pool -= cap;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
allocations.push({
|
|
18
|
+
agentId: agent.agentId,
|
|
19
|
+
allocatedUsdc: 0,
|
|
20
|
+
approved: false,
|
|
21
|
+
reason: pool <= 0 ? "Fleet pool exhausted" : "Exceeds daily remaining or pool",
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
fleetId: input.fleetId,
|
|
27
|
+
poolRemainingUsdc: input.poolRemainingUsdc,
|
|
28
|
+
poolAfterUsdc: Number(pool.toFixed(4)),
|
|
29
|
+
allocations,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export type ComplianceRecord = {
|
|
2
|
+
merchant: string;
|
|
3
|
+
endpoint?: string;
|
|
4
|
+
amountUsdc: number;
|
|
5
|
+
rail?: string;
|
|
6
|
+
network?: string;
|
|
7
|
+
category?: string;
|
|
8
|
+
agentId?: string;
|
|
9
|
+
transactionHash?: string;
|
|
10
|
+
timestamp?: string;
|
|
11
|
+
};
|
|
12
|
+
export type CompliancePolicy = {
|
|
13
|
+
monthlyCapUsdc?: number;
|
|
14
|
+
perMerchantCapUsdc?: number;
|
|
15
|
+
disallowedCategories?: string[];
|
|
16
|
+
requireTxHash?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export type ComplianceLedgerInput = {
|
|
19
|
+
organizationId: string;
|
|
20
|
+
period?: string;
|
|
21
|
+
records: ComplianceRecord[];
|
|
22
|
+
policy?: CompliancePolicy;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* CFO-grade Spend Compliance & Audit agent.
|
|
26
|
+
* Reconciles a fleet's agentic spend into a tamper-evident, SOC2/tax-ready
|
|
27
|
+
* ledger: spend by merchant/category/rail/agent, policy-violation flags, and
|
|
28
|
+
* a deterministic ledger hash. Complements evidence-locker (raw bundle export)
|
|
29
|
+
* with the analytics + reconciliation layer enterprises actually file.
|
|
30
|
+
*/
|
|
31
|
+
export declare function runComplianceLedger(input: ComplianceLedgerInput): {
|
|
32
|
+
organizationId: string;
|
|
33
|
+
period: string;
|
|
34
|
+
summary: {
|
|
35
|
+
recordCount: number;
|
|
36
|
+
totalUsdc: number;
|
|
37
|
+
averageUsdc: number;
|
|
38
|
+
unreconciledRecords: number;
|
|
39
|
+
policyCompliant: boolean;
|
|
40
|
+
};
|
|
41
|
+
breakdown: {
|
|
42
|
+
byMerchant: Record<string, {
|
|
43
|
+
count: number;
|
|
44
|
+
totalUsdc: number;
|
|
45
|
+
}>;
|
|
46
|
+
byCategory: Record<string, {
|
|
47
|
+
count: number;
|
|
48
|
+
totalUsdc: number;
|
|
49
|
+
}>;
|
|
50
|
+
byRail: Record<string, {
|
|
51
|
+
count: number;
|
|
52
|
+
totalUsdc: number;
|
|
53
|
+
}>;
|
|
54
|
+
byAgent: Record<string, {
|
|
55
|
+
count: number;
|
|
56
|
+
totalUsdc: number;
|
|
57
|
+
}>;
|
|
58
|
+
};
|
|
59
|
+
violations: {
|
|
60
|
+
type: string;
|
|
61
|
+
detail: string;
|
|
62
|
+
}[];
|
|
63
|
+
ledgerHash: string;
|
|
64
|
+
exportFormats: string[];
|
|
65
|
+
auditNote: string;
|
|
66
|
+
} & import("../lib/agent-response.js").AgentTrustMeta;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { agentTrustMeta, withAgentTrust } from "../lib/agent-response.js";
|
|
3
|
+
function group(rows, key) {
|
|
4
|
+
const out = {};
|
|
5
|
+
for (const r of rows) {
|
|
6
|
+
const k = key(r) || "unknown";
|
|
7
|
+
out[k] ??= { count: 0, totalUsdc: 0 };
|
|
8
|
+
out[k].count += 1;
|
|
9
|
+
out[k].totalUsdc = Number((out[k].totalUsdc + r.amountUsdc).toFixed(6));
|
|
10
|
+
}
|
|
11
|
+
return out;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* CFO-grade Spend Compliance & Audit agent.
|
|
15
|
+
* Reconciles a fleet's agentic spend into a tamper-evident, SOC2/tax-ready
|
|
16
|
+
* ledger: spend by merchant/category/rail/agent, policy-violation flags, and
|
|
17
|
+
* a deterministic ledger hash. Complements evidence-locker (raw bundle export)
|
|
18
|
+
* with the analytics + reconciliation layer enterprises actually file.
|
|
19
|
+
*/
|
|
20
|
+
export function runComplianceLedger(input) {
|
|
21
|
+
const rows = input.records;
|
|
22
|
+
const totalUsdc = Number(rows.reduce((a, r) => a + r.amountUsdc, 0).toFixed(6));
|
|
23
|
+
const policy = input.policy ?? {};
|
|
24
|
+
const byMerchant = group(rows, (r) => r.merchant ?? r.endpoint ?? "unknown");
|
|
25
|
+
const byCategory = group(rows, (r) => r.category ?? "uncategorized");
|
|
26
|
+
const byRail = group(rows, (r) => r.rail ?? r.network ?? "unknown");
|
|
27
|
+
const byAgent = group(rows, (r) => r.agentId ?? "unknown");
|
|
28
|
+
const violations = [];
|
|
29
|
+
if (policy.monthlyCapUsdc != null && totalUsdc > policy.monthlyCapUsdc) {
|
|
30
|
+
violations.push({ type: "monthly_cap", detail: `Total $${totalUsdc} exceeds monthly cap $${policy.monthlyCapUsdc}` });
|
|
31
|
+
}
|
|
32
|
+
if (policy.perMerchantCapUsdc != null) {
|
|
33
|
+
for (const [m, agg] of Object.entries(byMerchant)) {
|
|
34
|
+
if (agg.totalUsdc > policy.perMerchantCapUsdc) {
|
|
35
|
+
violations.push({ type: "per_merchant_cap", detail: `${m}: $${agg.totalUsdc} > $${policy.perMerchantCapUsdc}` });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (policy.disallowedCategories?.length) {
|
|
40
|
+
for (const cat of policy.disallowedCategories) {
|
|
41
|
+
if (byCategory[cat])
|
|
42
|
+
violations.push({ type: "disallowed_category", detail: `Category ${cat} present ($${byCategory[cat].totalUsdc})` });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const unreconciled = policy.requireTxHash
|
|
46
|
+
? rows.filter((r) => !r.transactionHash).length
|
|
47
|
+
: rows.filter((r) => !r.transactionHash).length;
|
|
48
|
+
const canonical = JSON.stringify({
|
|
49
|
+
organizationId: input.organizationId,
|
|
50
|
+
period: input.period ?? null,
|
|
51
|
+
records: rows.map((r) => ({
|
|
52
|
+
merchant: r.merchant ?? r.endpoint,
|
|
53
|
+
amountUsdc: r.amountUsdc,
|
|
54
|
+
rail: r.rail ?? r.network,
|
|
55
|
+
txHash: r.transactionHash ?? null,
|
|
56
|
+
ts: r.timestamp ?? null,
|
|
57
|
+
})),
|
|
58
|
+
});
|
|
59
|
+
const ledgerHash = createHash("sha256").update(canonical).digest("hex");
|
|
60
|
+
return withAgentTrust({
|
|
61
|
+
organizationId: input.organizationId,
|
|
62
|
+
period: input.period ?? "unspecified",
|
|
63
|
+
summary: {
|
|
64
|
+
recordCount: rows.length,
|
|
65
|
+
totalUsdc,
|
|
66
|
+
averageUsdc: rows.length ? Number((totalUsdc / rows.length).toFixed(6)) : 0,
|
|
67
|
+
unreconciledRecords: unreconciled,
|
|
68
|
+
policyCompliant: violations.length === 0,
|
|
69
|
+
},
|
|
70
|
+
breakdown: { byMerchant, byCategory, byRail, byAgent },
|
|
71
|
+
violations,
|
|
72
|
+
ledgerHash,
|
|
73
|
+
exportFormats: ["json", "csv-ready", "soc2-bundle"],
|
|
74
|
+
auditNote: "Persist ledgerHash off-system; recompute to detect tampering. Pair with /api/evidence-locker/export for signed bundles.",
|
|
75
|
+
}, agentTrustMeta(["aggregation", "policy_eval", "tamper_hash"], {
|
|
76
|
+
confidence: 0.9,
|
|
77
|
+
sources: ["compliance-ledger"],
|
|
78
|
+
accuracy_note: "Reconciliation is based on supplied records; on-chain verification of each txHash should be done via /api/receipt-auditor/verify.",
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export type DisputeReason = "non_delivery" | "quality_mismatch" | "overcharge" | "duplicate" | "unauthorized";
|
|
2
|
+
export type DisputeRail = "visa-cli" | "card" | "base-x402" | "solana-x402" | "circle-nano" | "stripe-mpp";
|
|
3
|
+
export type DisputeEvidence = {
|
|
4
|
+
expectedSchema?: string[];
|
|
5
|
+
actualResponseEmpty?: boolean;
|
|
6
|
+
verificationScore?: number;
|
|
7
|
+
receiptValid?: boolean;
|
|
8
|
+
duplicateOfTx?: string;
|
|
9
|
+
chargedUsdc?: number;
|
|
10
|
+
quotedUsdc?: number;
|
|
11
|
+
};
|
|
12
|
+
export type DisputeResolveInput = {
|
|
13
|
+
rail: DisputeRail;
|
|
14
|
+
merchant: string;
|
|
15
|
+
amountUsdc: number;
|
|
16
|
+
reason: DisputeReason;
|
|
17
|
+
transactionHash?: string;
|
|
18
|
+
evidence?: DisputeEvidence;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Dispute & Chargeback Auto-Resolver.
|
|
22
|
+
* Visa CLI brings chargeback rights to agentic payments — but nobody automates
|
|
23
|
+
* the filing. For card rails this builds a Visa chargeback dossier (reason code,
|
|
24
|
+
* required evidence, filing steps). For final/stablecoin rails (no chargeback)
|
|
25
|
+
* it routes to an escrow/refund claim instead. Bridges card dispute rules with
|
|
26
|
+
* on-chain receipts.
|
|
27
|
+
*/
|
|
28
|
+
export declare function runDisputeResolve(input: DisputeResolveInput): ({
|
|
29
|
+
path: string;
|
|
30
|
+
rail: DisputeRail;
|
|
31
|
+
merchant: string;
|
|
32
|
+
amountUsdc: number;
|
|
33
|
+
reason: DisputeReason;
|
|
34
|
+
reasonCode: string;
|
|
35
|
+
reasonFamily: string;
|
|
36
|
+
disputeStrength: number;
|
|
37
|
+
likelihood: string;
|
|
38
|
+
autoFileable: boolean;
|
|
39
|
+
requiredEvidence: string[];
|
|
40
|
+
evidenceCaptured: string[];
|
|
41
|
+
filingSteps: string[];
|
|
42
|
+
nextStep: {
|
|
43
|
+
method: string;
|
|
44
|
+
path: string;
|
|
45
|
+
note: string;
|
|
46
|
+
};
|
|
47
|
+
} & import("../lib/agent-response.js").AgentTrustMeta) | ({
|
|
48
|
+
path: string;
|
|
49
|
+
rail: DisputeRail;
|
|
50
|
+
merchant: string;
|
|
51
|
+
amountUsdc: number;
|
|
52
|
+
reason: DisputeReason;
|
|
53
|
+
finality: string;
|
|
54
|
+
disputeStrength: number;
|
|
55
|
+
likelihood: string;
|
|
56
|
+
autoFileable: boolean;
|
|
57
|
+
requiredEvidence: string[];
|
|
58
|
+
evidenceCaptured: string[];
|
|
59
|
+
recommendedRoute: string[];
|
|
60
|
+
escrowUrl: string;
|
|
61
|
+
refundArbiterUrl: string;
|
|
62
|
+
} & import("../lib/agent-response.js").AgentTrustMeta);
|