@coreguard/agent-commerce 0.1.3 → 0.1.4
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 +33 -1
- package/aer1.mjs +698 -2
- package/cgcp-mcp-tools.mjs +142 -0
- package/control-plane-cli.mjs +187 -161
- package/control-plane-http.mjs +91 -18
- package/control-plane.mjs +297 -43
- package/index.d.ts +143 -0
- package/index.mjs +51 -0
- package/machine-economy.mjs +366 -0
- package/mcp.mjs +182 -8
- package/observations.mjs +524 -0
- package/package.json +28 -6
- package/prod/kms-anchor.mjs +51 -0
- package/prod/migrate.mjs +73 -0
- package/prod/observability.mjs +35 -0
- package/prod/rbac.mjs +46 -0
- package/prod/schema.mjs +188 -0
- package/prod/sqlite-storage.mjs +135 -0
package/mcp.mjs
CHANGED
|
@@ -7,13 +7,7 @@
|
|
|
7
7
|
* (one JSON object per line, both directions) — the same shape MCP clients
|
|
8
8
|
* speak for stdio servers.
|
|
9
9
|
*
|
|
10
|
-
* Tools (all offline,
|
|
11
|
-
* coreguard_authorize intent + policy + declaredTrace + nowSeconds
|
|
12
|
-
* -> CGCR/1 consent record (pinned receipt)
|
|
13
|
-
* coreguard_verify_consent consent record -> integrity verdict
|
|
14
|
-
* coreguard_verify_execution consent + executed trace -> fail-closed
|
|
15
|
-
* verdict + AGR/1 taxonomy + named drift
|
|
16
|
-
* coreguard_assess_risk intent + policy + trace -> AGR/1 report
|
|
10
|
+
* Tools (all offline/self-hosted, deterministic, zero network keys): 10 core consent/verification tools + 10 Wave 1 Machine Economy tools + 6 Wave 2 CGCP/1 mapping tools (intent/receipt/limits/revoke/audit) = 26 total. Optional trust roots enable Ed25519 signature verification for telemetry/delegation; no custody, no broadcast, no network calls; external settlement/physical truth/device identity beyond supplied key material NOT proven.
|
|
17
11
|
*
|
|
18
12
|
* BOUNDARIES (standing): synthetic demo data is the caller's; nothing here
|
|
19
13
|
* contacts any platform or payment network (no contact/integration/endorsement
|
|
@@ -48,6 +42,21 @@ import {
|
|
|
48
42
|
SOROBAN_CONSENT_BINDING_VERSION,
|
|
49
43
|
buildSorobanConsentBinding,
|
|
50
44
|
} from "./index.mjs";
|
|
45
|
+
import {
|
|
46
|
+
parseX402Challenge,
|
|
47
|
+
authorizeX402Payment,
|
|
48
|
+
verifyX402Settlement,
|
|
49
|
+
reconcilePayment,
|
|
50
|
+
meterAgentUsage,
|
|
51
|
+
registerMachine,
|
|
52
|
+
createMachineTask,
|
|
53
|
+
verifyTelemetry,
|
|
54
|
+
verifyTaskCompletion,
|
|
55
|
+
verifyDelegationChain,
|
|
56
|
+
MACHINE_ECONOMY_VERSION,
|
|
57
|
+
MACHINE_ECONOMY_BOUNDARY,
|
|
58
|
+
} from "./machine-economy.mjs";
|
|
59
|
+
import { createIntent, issueReceipt, verifyReceipt as verifyCgcpReceipt, checkLimits, revokeConsent, auditTransaction, CGCP_MCP_BOUNDARY } from "./cgcp-mcp-tools.mjs";
|
|
51
60
|
|
|
52
61
|
const PROTOCOL_VERSION = "2025-06-18";
|
|
53
62
|
|
|
@@ -79,6 +88,22 @@ const TOOL_NAMES = Object.freeze([
|
|
|
79
88
|
"coreguard_decide_outcome",
|
|
80
89
|
"coreguard_profile_reference",
|
|
81
90
|
"coreguard_consumption_status",
|
|
91
|
+
"coreguard_parse_x402_challenge",
|
|
92
|
+
"coreguard_authorize_x402_payment",
|
|
93
|
+
"coreguard_verify_x402_settlement",
|
|
94
|
+
"coreguard_reconcile_payment",
|
|
95
|
+
"coreguard_meter_agent_usage",
|
|
96
|
+
"coreguard_register_machine",
|
|
97
|
+
"coreguard_create_machine_task",
|
|
98
|
+
"coreguard_verify_telemetry",
|
|
99
|
+
"coreguard_verify_task_completion",
|
|
100
|
+
"coreguard_verify_delegation_chain",
|
|
101
|
+
"coreguard_create_intent",
|
|
102
|
+
"coreguard_issue_receipt",
|
|
103
|
+
"coreguard_verify_receipt",
|
|
104
|
+
"coreguard_check_limits",
|
|
105
|
+
"coreguard_revoke_consent",
|
|
106
|
+
"coreguard_audit_transaction",
|
|
82
107
|
]);
|
|
83
108
|
|
|
84
109
|
/**
|
|
@@ -226,6 +251,42 @@ const VALIDATORS = Object.freeze({
|
|
|
226
251
|
}
|
|
227
252
|
return optionalObject(args, "callerContext");
|
|
228
253
|
},
|
|
254
|
+
coreguard_parse_x402_challenge(args) { return requireObjects(args, ["challenge"]) || optionalObject(args, "callerContext"); },
|
|
255
|
+
coreguard_authorize_x402_payment(args) { return requireObjects(args, ["challenge", "policy"]) || optionalObject(args, "callerContext"); },
|
|
256
|
+
coreguard_verify_x402_settlement(args) { return requireObjects(args, ["challenge", "settlement"]) || optionalObject(args, "callerContext"); },
|
|
257
|
+
coreguard_reconcile_payment(args) { return requireObjects(args, ["authorization"]) || optionalObject(args, "callerContext"); },
|
|
258
|
+
coreguard_meter_agent_usage(args) {
|
|
259
|
+
const r = requireString(args, "agentId"); if (r) return r;
|
|
260
|
+
if (args.events === undefined) return { code: ERROR_CODES.MISSING_ARGUMENT, detail: "events is required" };
|
|
261
|
+
if (!Array.isArray(args.events)) return { code: ERROR_CODES.INVALID_ARGUMENT, detail: "events must be an array" };
|
|
262
|
+
return optionalObject(args, "callerContext");
|
|
263
|
+
},
|
|
264
|
+
coreguard_register_machine(args) {
|
|
265
|
+
const r = requireString(args, "machineId"); if (r) return r;
|
|
266
|
+
return requireObjects(args, ["manifest"]) || optionalObject(args, "callerContext");
|
|
267
|
+
},
|
|
268
|
+
coreguard_create_machine_task(args) {
|
|
269
|
+
const r = requireString(args, "taskId"); if (r) return r;
|
|
270
|
+
const r2 = requireString(args, "machineId"); if (r2) return r2;
|
|
271
|
+
return requireObjects(args, ["terms"]) || optionalObject(args, "callerContext");
|
|
272
|
+
},
|
|
273
|
+
coreguard_verify_telemetry(args) {
|
|
274
|
+
const r = requireString(args, "taskId"); if (r) return r;
|
|
275
|
+
return requireObjects(args, ["telemetry"]) || optionalObject(args, "callerContext");
|
|
276
|
+
},
|
|
277
|
+
coreguard_verify_task_completion(args) { return requireObjects(args, ["task", "completion"]) || optionalObject(args, "callerContext"); },
|
|
278
|
+
coreguard_verify_delegation_chain(args) {
|
|
279
|
+
if (args.chain === undefined) return { code: ERROR_CODES.MISSING_ARGUMENT, detail: "chain is required" };
|
|
280
|
+
if (!Array.isArray(args.chain)) return { code: ERROR_CODES.INVALID_ARGUMENT, detail: "chain must be an array" };
|
|
281
|
+
if (args.trust !== undefined && (typeof args.trust !== "object" || args.trust === null || Array.isArray(args.trust))) return { code: ERROR_CODES.INVALID_ARGUMENT, detail: "trust must be an object when supplied" };
|
|
282
|
+
return optionalObject(args, "callerContext");
|
|
283
|
+
},
|
|
284
|
+
coreguard_create_intent(args) { const r=requireString(args,"storePath"); if(r) return r; const a=requireString(args,"agentId"); if(a) return a; return optionalObject(args,"callerContext"); },
|
|
285
|
+
coreguard_issue_receipt(args) { const r=requireString(args,"storePath"); if(r) return r; const a=requireString(args,"agentId"); if(a) return a; return optionalObject(args,"callerContext"); },
|
|
286
|
+
coreguard_verify_receipt(args) { const r=requireString(args,"storePath"); if(r) return r; return optionalObject(args,"callerContext"); },
|
|
287
|
+
coreguard_check_limits(args) { const r=requireString(args,"storePath"); if(r) return r; const a=requireString(args,"agentId"); if(a) return a; return optionalObject(args,"callerContext"); },
|
|
288
|
+
coreguard_revoke_consent(args) { const r=requireString(args,"storePath"); if(r) return r; const t=requireString(args,"targetType"); if(t) return t; const i=requireString(args,"targetId"); if(i) return i; return optionalObject(args,"callerContext"); },
|
|
289
|
+
coreguard_audit_transaction(args) { const r=requireString(args,"storePath"); if(r) return r; return optionalObject(args,"callerContext"); },
|
|
229
290
|
});
|
|
230
291
|
|
|
231
292
|
function integerStringSchema(description) {
|
|
@@ -503,6 +564,102 @@ const TOOLS = Object.freeze([
|
|
|
503
564
|
additionalProperties: true,
|
|
504
565
|
},
|
|
505
566
|
},
|
|
567
|
+
{
|
|
568
|
+
name: "coreguard_parse_x402_challenge",
|
|
569
|
+
description: "Parse and normalize an x402 payment challenge (HTTP 402 accepts). Offline deterministic validation only; no network contact, no payment execution.",
|
|
570
|
+
inputSchema: { type: "object", properties: { challenge: { type: "object", description: "x402 challenge/402 body with accepts[]" }, ...CALLER_CONTEXT_PROPERTY }, required: ["challenge"] },
|
|
571
|
+
outputSchema: { type: "object", description: "Parsed x402 challenge with normalized accepts, issues, and boundary; no network call.", properties: { verdict: { type: "string" }, issues: { type: "array" }, accepts: { type: "array" }, boundary: { type: "string" }, callerContext: { type: "object" } }, additionalProperties: true },
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
name: "coreguard_authorize_x402_payment",
|
|
575
|
+
description: "Evaluate an x402 challenge against a local policy and produce an authorization decision. No custody, no broadcast, no payment execution.",
|
|
576
|
+
inputSchema: { type: "object", properties: { challenge: { type: "object" }, policy: { type: "object", description: "policy: maxAmount, allowedNetworks, allowedAssets, allowedPayTo" }, selectedIndex: { type: "integer", minimum: 0 }, ...CALLER_CONTEXT_PROPERTY }, required: ["challenge", "policy"] },
|
|
577
|
+
outputSchema: { type: "object", description: "x402 authorization decision with policy issues and authorizationId; no payment executed.", properties: { verdict: { type: "string" }, authorizationId: { type: "string" }, issues: { type: "array" }, boundary: { type: "string" }, callerContext: { type: "object" } }, additionalProperties: true },
|
|
578
|
+
},
|
|
579
|
+
{
|
|
580
|
+
name: "coreguard_verify_x402_settlement",
|
|
581
|
+
description: "Verify caller-supplied x402 settlement evidence against a challenge. No network confirmation performed; evidence-only, fail-closed.",
|
|
582
|
+
inputSchema: { type: "object", properties: { challenge: { type: "object" }, settlement: { type: "object", description: "caller-supplied settlement evidence (network, asset, amount, payTo, txRef, status)" }, ...CALLER_CONTEXT_PROPERTY }, required: ["challenge", "settlement"] },
|
|
583
|
+
outputSchema: { type: "object", description: "x402 settlement verification from caller-supplied evidence; no network confirmation.", properties: { verdict: { type: "string" }, issues: { type: "array" }, boundary: { type: "string" }, callerContext: { type: "object" } }, additionalProperties: true },
|
|
584
|
+
},
|
|
585
|
+
{
|
|
586
|
+
name: "coreguard_reconcile_payment",
|
|
587
|
+
description: "Reconcile authorization, settlement evidence, and receipt. Deterministic evidence check only; no external ledger/custody.",
|
|
588
|
+
inputSchema: { type: "object", properties: { authorization: { type: "object" }, challenge: { type: "object" }, settlement: { type: "object" }, receipt: { type: "object" }, ...CALLER_CONTEXT_PROPERTY }, required: ["authorization"] },
|
|
589
|
+
outputSchema: { type: "object", description: "Payment reconciliation verdict across authorization, settlement, and receipt evidence.", properties: { verdict: { type: "string" }, issues: { type: "array" }, boundary: { type: "string" }, callerContext: { type: "object" } }, additionalProperties: true },
|
|
590
|
+
},
|
|
591
|
+
{
|
|
592
|
+
name: "coreguard_meter_agent_usage",
|
|
593
|
+
description: "Deterministically meter agent usage/cost events into an auditable total. No billing custody or external payment.",
|
|
594
|
+
inputSchema: { type: "object", properties: { agentId: { type: "string" }, events: { type: "array", items: { type: "object" } }, currency: { type: "string" }, ...CALLER_CONTEXT_PROPERTY }, required: ["agentId", "events"] },
|
|
595
|
+
outputSchema: { type: "object", description: "Deterministic agent usage metering totals and event digest; no billing custody.", properties: { totalAmount: { type: "string" }, eventCount: { type: "integer" }, boundary: { type: "string" }, callerContext: { type: "object" } }, additionalProperties: true },
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
name: "coreguard_register_machine",
|
|
599
|
+
description: "Create a local machine registration record from a manifest. No external device attestation/TPM trust root verification performed.",
|
|
600
|
+
inputSchema: { type: "object", properties: { machineId: { type: "string" }, manifest: { type: "object" }, owner: { type: "string" }, ...CALLER_CONTEXT_PROPERTY }, required: ["machineId", "manifest"] },
|
|
601
|
+
outputSchema: { type: "object", description: "Local machine registration record; external device attestation not performed.", properties: { verdict: { type: "string" }, registrationId: { type: "string" }, boundary: { type: "string" }, callerContext: { type: "object" } }, additionalProperties: true },
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
name: "coreguard_create_machine_task",
|
|
605
|
+
description: "Create a deterministic machine task record with terms/price/SLA conditions. No payment custody or physical execution guarantee.",
|
|
606
|
+
inputSchema: { type: "object", properties: { taskId: { type: "string" }, machineId: { type: "string" }, terms: { type: "object" }, ...CALLER_CONTEXT_PROPERTY }, required: ["taskId", "machineId", "terms"] },
|
|
607
|
+
outputSchema: { type: "object", description: "Deterministic machine task record with terms digest and boundary.", properties: { verdict: { type: "string" }, taskDigest: { type: "string" }, boundary: { type: "string" }, callerContext: { type: "object" } }, additionalProperties: true },
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
name: "coreguard_verify_telemetry",
|
|
611
|
+
description: "Verify caller-supplied telemetry evidence structure/digest and optionally verify Ed25519 signature when trust roots/public keys are supplied. Signature trust/physical-world truth not proven beyond supplied key material.",
|
|
612
|
+
inputSchema: { type: "object", properties: { taskId: { type: "string" }, telemetry: { type: "object" }, trust: { type: "object", description: "Optional trust roots: { publicKeyPem } or { publicKeys: [{keyId,publicKeyPem}]|{keyId:pem} } or { keyring }" }, ...CALLER_CONTEXT_PROPERTY }, required: ["taskId", "telemetry"] },
|
|
613
|
+
outputSchema: { type: "object", description: "Telemetry evidence verification result; signature trust/physical truth not proven.", properties: { verdict: { type: "string" }, issues: { type: "array" }, boundary: { type: "string" }, callerContext: { type: "object" } }, additionalProperties: true },
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
name: "coreguard_verify_task_completion",
|
|
617
|
+
description: "Verify task completion evidence against task record. Evidence acceptance is not physical-world proof; independent verification required for high-stakes actions.",
|
|
618
|
+
inputSchema: { type: "object", properties: { task: { type: "object" }, completion: { type: "object" }, telemetryVerification: { type: "object" }, ...CALLER_CONTEXT_PROPERTY }, required: ["task", "completion"] },
|
|
619
|
+
outputSchema: { type: "object", description: "Task completion evidence verification result; evidence acceptance is not physical proof.", properties: { verdict: { type: "string" }, issues: { type: "array" }, boundary: { type: "string" }, callerContext: { type: "object" } }, additionalProperties: true },
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
name: "coreguard_verify_delegation_chain",
|
|
623
|
+
description: "Verify delegation chain structure/continuity and optionally verify Ed25519 signatures when trust roots/public keys are supplied. Verification proves signatures over supplied payloads, not delegator identity beyond supplied key material.",
|
|
624
|
+
inputSchema: { type: "object", properties: { chain: { type: "array", items: { type: "object" } }, trust: { type: "object", description: "Optional trust roots: { publicKeyPem } or { publicKeys: [{keyId,publicKeyPem}]|{keyId:pem} } or { keyring }" }, ...CALLER_CONTEXT_PROPERTY }, required: ["chain"] },
|
|
625
|
+
outputSchema: { type: "object", description: "Delegation chain structural verification result; signatures require trusted roots.", properties: { verdict: { type: "string" }, issues: { type: "array" }, depth: { type: "integer" }, boundary: { type: "string" }, callerContext: { type: "object" } }, additionalProperties: true },
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
name: "coreguard_create_intent",
|
|
629
|
+
description: "CGCP/1 mapping: create an intent/approval request in a self-hosted file-backed control plane. Not a blockchain receipt and not payment execution.",
|
|
630
|
+
inputSchema: { type: "object", properties: { storePath: { type: "string" }, intentId: { type: "string" }, agentId: { type: "string" }, policyId: { type: "string" }, merchant: { type: "string" }, address: { type: "string" }, amountMinor: { type: "string" }, currency: { type: "string" }, requestedBy: { type: "string" }, expiresAt: { type: "string" }, ...CALLER_CONTEXT_PROPERTY }, required: ["storePath", "agentId"] },
|
|
631
|
+
outputSchema: { type: "object", description: "CGCP/1 intent/approval request record with mapping and boundary.", properties: { type: { type: "string" }, spec: { type: "string" }, intent: { type: "object" }, mapping: { type: "string" }, boundary: { type: "string" }, callerContext: { type: "object" } }, additionalProperties: true },
|
|
632
|
+
},
|
|
633
|
+
{
|
|
634
|
+
name: "coreguard_issue_receipt",
|
|
635
|
+
description: "CGCP/1 mapping: record an execution receipt in a self-hosted file-backed control plane. This is a local execution record, not an on-chain proof or external payment receipt.",
|
|
636
|
+
inputSchema: { type: "object", properties: { storePath: { type: "string" }, receiptId: { type: "string" }, agentId: { type: "string" }, policyId: { type: "string" }, approvalId: { type: "string" }, merchant: { type: "string" }, address: { type: "string" }, amountMinor: { type: "string" }, currency: { type: "string" }, status: { type: "string" }, txRef: { type: "string" }, metadata: { type: "object" }, ...CALLER_CONTEXT_PROPERTY }, required: ["storePath", "agentId"] },
|
|
637
|
+
outputSchema: { type: "object", description: "CGCP/1 execution receipt record with mapping and boundary.", properties: { type: { type: "string" }, spec: { type: "string" }, receipt: { type: "object" }, mapping: { type: "string" }, boundary: { type: "string" }, callerContext: { type: "object" } }, additionalProperties: true },
|
|
638
|
+
},
|
|
639
|
+
{
|
|
640
|
+
name: "coreguard_verify_receipt",
|
|
641
|
+
description: "CGCP/1 mapping: verify a receipt record and the audit chain in a file-backed control plane. No external anchor/witness/on-chain verification is performed.",
|
|
642
|
+
inputSchema: { type: "object", properties: { storePath: { type: "string" }, receiptId: { type: "string" }, ...CALLER_CONTEXT_PROPERTY }, required: ["storePath"] },
|
|
643
|
+
outputSchema: { type: "object", description: "CGCP/1 receipt verification verdict, receipt lookup, and audit chain status.", properties: { verdict: { type: "string" }, issues: { type: "array" }, receiptFound: { type: "boolean" }, auditChain: { type: "object" }, boundary: { type: "string" }, callerContext: { type: "object" } }, additionalProperties: true },
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
name: "coreguard_check_limits",
|
|
647
|
+
description: "CGCP/1 mapping: evaluate policy/limit decision for an agent request in a file-backed control plane. No funds moved and no external IdP/KMS involved.",
|
|
648
|
+
inputSchema: { type: "object", properties: { storePath: { type: "string" }, agentId: { type: "string" }, policyId: { type: "string" }, merchant: { type: "string" }, address: { type: "string" }, amountMinor: { type: "string" }, currency: { type: "string" }, approvalId: { type: "string" }, ...CALLER_CONTEXT_PROPERTY }, required: ["storePath", "agentId"] },
|
|
649
|
+
outputSchema: { type: "object", description: "CGCP/1 policy evaluation decision with mapping and boundary.", properties: { type: { type: "string" }, spec: { type: "string" }, decision: { type: "object" }, boundary: { type: "string" }, callerContext: { type: "object" } }, additionalProperties: true },
|
|
650
|
+
},
|
|
651
|
+
{
|
|
652
|
+
name: "coreguard_revoke_consent",
|
|
653
|
+
description: "CGCP/1 mapping: revoke an approval, agent, or policy in a file-backed control plane. Local single-host revocation; no distributed propagation, no external IdP lifecycle.",
|
|
654
|
+
inputSchema: { type: "object", properties: { storePath: { type: "string" }, targetType: { type: "string", enum: ["approval", "agent", "policy"] }, targetId: { type: "string" }, reason: { type: "string" }, decidedBy: { type: "string" }, ...CALLER_CONTEXT_PROPERTY }, required: ["storePath", "targetType", "targetId"] },
|
|
655
|
+
outputSchema: { type: "object", description: "CGCP/1 revocation record with mapping and boundary.", properties: { type: { type: "string" }, spec: { type: "string" }, targetType: { type: "string" }, result: { type: "object" }, boundary: { type: "string" }, callerContext: { type: "object" } }, additionalProperties: true },
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
name: "coreguard_audit_transaction",
|
|
659
|
+
description: "CGCP/1 mapping: read and optionally filter the append-only hash-chained audit report from a file-backed control plane. No external audit/audit anchoring.",
|
|
660
|
+
inputSchema: { type: "object", properties: { storePath: { type: "string" }, txRef: { type: "string" }, approvalId: { type: "string" }, agentId: { type: "string" }, limit: { type: "integer", minimum: 1 }, ...CALLER_CONTEXT_PROPERTY }, required: ["storePath"] },
|
|
661
|
+
outputSchema: { type: "object", description: "CGCP/1 audit report with chain status and optional filters.", properties: { type: { type: "string" }, spec: { type: "string" }, report: { type: "object" }, mapping: { type: "string" }, boundary: { type: "string" }, callerContext: { type: "object" } }, additionalProperties: true },
|
|
662
|
+
},
|
|
506
663
|
]);
|
|
507
664
|
|
|
508
665
|
function withCallerContext(value, args) {
|
|
@@ -574,6 +731,22 @@ async function callTool(name, args, { consumedSet } = {}) {
|
|
|
574
731
|
boundary: "process-local only; set storePath or COREGUARD_CONSUMPTION_STORE for the AC-CS/1 file ledger (cross-process on this host); cross-host sync is CG-SPEND/1 merge; on-chain anchoring NOT_BUILT",
|
|
575
732
|
}, a));
|
|
576
733
|
}
|
|
734
|
+
if (name === "coreguard_parse_x402_challenge") return success(withCallerContext(parseX402Challenge(a), a));
|
|
735
|
+
if (name === "coreguard_authorize_x402_payment") return success(withCallerContext(authorizeX402Payment(a), a));
|
|
736
|
+
if (name === "coreguard_verify_x402_settlement") return success(withCallerContext(verifyX402Settlement(a), a));
|
|
737
|
+
if (name === "coreguard_reconcile_payment") return success(withCallerContext(reconcilePayment(a), a));
|
|
738
|
+
if (name === "coreguard_meter_agent_usage") return success(withCallerContext(meterAgentUsage(a), a));
|
|
739
|
+
if (name === "coreguard_register_machine") return success(withCallerContext(registerMachine(a), a));
|
|
740
|
+
if (name === "coreguard_create_machine_task") return success(withCallerContext(createMachineTask(a), a));
|
|
741
|
+
if (name === "coreguard_verify_telemetry") return success(withCallerContext(verifyTelemetry(a), a));
|
|
742
|
+
if (name === "coreguard_verify_task_completion") return success(withCallerContext(verifyTaskCompletion(a), a));
|
|
743
|
+
if (name === "coreguard_verify_delegation_chain") return success(withCallerContext(verifyDelegationChain(a), a));
|
|
744
|
+
if (name === "coreguard_create_intent") return success(withCallerContext(createIntent(a), a));
|
|
745
|
+
if (name === "coreguard_issue_receipt") return success(withCallerContext(issueReceipt(a), a));
|
|
746
|
+
if (name === "coreguard_verify_receipt") return success(withCallerContext(verifyCgcpReceipt(a), a));
|
|
747
|
+
if (name === "coreguard_check_limits") return success(withCallerContext(checkLimits(a), a));
|
|
748
|
+
if (name === "coreguard_revoke_consent") return success(withCallerContext(revokeConsent(a), a));
|
|
749
|
+
if (name === "coreguard_audit_transaction") return success(withCallerContext(auditTransaction(a), a));
|
|
577
750
|
return failure(ERROR_CODES.UNKNOWN_TOOL, `unknown tool: ${String(name)}`);
|
|
578
751
|
} catch (err) {
|
|
579
752
|
return failure(ERROR_CODES.TOOL_ERROR, err?.message ?? String(err));
|
|
@@ -638,7 +811,7 @@ export function createMcpHandler({ write } = {}) {
|
|
|
638
811
|
|
|
639
812
|
export function selfCheck() {
|
|
640
813
|
return [
|
|
641
|
-
["tools exposed", TOOL_NAMES.length ===
|
|
814
|
+
["tools exposed", TOOL_NAMES.length === 26 && TOOL_NAMES[0] === "coreguard_authorize" && TOOL_NAMES[9] === "coreguard_consumption_status" && TOOL_NAMES[19] === "coreguard_verify_delegation_chain" && TOOL_NAMES[25] === "coreguard_audit_transaction"],
|
|
642
815
|
["protocol version pinned", PROTOCOL_VERSION === "2025-06-18"],
|
|
643
816
|
["spec surfaced", CONSENT_SPEC === "CGCR/1" && AGENT_COMMERCE_VERSION === "AC-SDK/1"],
|
|
644
817
|
["boundary travels", SERVER_BOUNDARY.includes("VERIFIED ≠ SAFE") && SERVER_BOUNDARY.includes("NOT_BUILT")],
|
|
@@ -647,6 +820,7 @@ export function selfCheck() {
|
|
|
647
820
|
["every tool declares required inputs", TOOLS.every((t) => Array.isArray(t.inputSchema?.required) && t.inputSchema.required.length > 0)],
|
|
648
821
|
["error contract is exported", ERROR_CODES.MISSING_ARGUMENT === "MISSING_ARGUMENT"],
|
|
649
822
|
["caller context supported", TOOLS.every((t) => t.inputSchema?.properties?.callerContext?.type === "object")],
|
|
823
|
+
["machine economy boundary", MACHINE_ECONOMY_BOUNDARY.includes("VERIFIED != SAFE")],
|
|
650
824
|
];
|
|
651
825
|
}
|
|
652
826
|
|