@agenttrust-sdk/mcp 0.3.0 → 0.3.2
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 +25 -3
- package/dist/chain.js +4 -2
- package/dist/chain.js.map +1 -1
- package/dist/config.d.ts +22 -2
- package/dist/config.js +165 -15
- package/dist/config.js.map +1 -1
- package/dist/embedded-docs/mcp/hosted-endpoint.mdx +1 -1
- package/dist/embedded-docs/mcp/install.mdx +12 -3
- package/dist/embedded-docs/mcp/tools.mdx +2 -2
- package/dist/embedded-docs/quickstart.mdx +83 -0
- package/dist/errors.d.ts +79 -0
- package/dist/errors.js +277 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.js +13 -6
- package/dist/index.js.map +1 -1
- package/dist/server.js +19 -16
- package/dist/server.js.map +1 -1
- package/dist/tools/discovery/docs.d.ts +6 -0
- package/dist/tools/discovery/docs.js +13 -1
- package/dist/tools/discovery/docs.js.map +1 -1
- package/dist/tools/discovery/facilitator-walkthrough.d.ts +5 -0
- package/dist/tools/discovery/facilitator-walkthrough.js +13 -2
- package/dist/tools/discovery/facilitator-walkthrough.js.map +1 -1
- package/dist/tools/index.js +2 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/read/get-quantu-reputation.d.ts +23 -3
- package/dist/tools/read/get-quantu-reputation.js +32 -7
- package/dist/tools/read/get-quantu-reputation.js.map +1 -1
- package/dist/tools/read/simulate-payment.js +13 -13
- package/dist/tools/read/simulate-payment.js.map +1 -1
- package/dist/tools/write/emit-feedback.d.ts +4 -4
- package/dist/tools/write/emit-feedback.js +55 -12
- package/dist/tools/write/emit-feedback.js.map +1 -1
- package/dist/tools/write/init-authority.d.ts +43 -0
- package/dist/tools/write/init-authority.js +92 -0
- package/dist/tools/write/init-authority.js.map +1 -0
- package/dist/tools/write/init-policy.d.ts +23 -3
- package/dist/tools/write/init-policy.js +92 -15
- package/dist/tools/write/init-policy.js.map +1 -1
- package/dist/tools/write/request-validation.js +6 -2
- package/dist/tools/write/request-validation.js.map +1 -1
- package/dist/tools/write/respond-to-validation.d.ts +3 -2
- package/dist/tools/write/respond-to-validation.js +10 -7
- package/dist/tools/write/respond-to-validation.js.map +1 -1
- package/dist/tools/write/set-killswitch.d.ts +10 -0
- package/dist/tools/write/set-killswitch.js +63 -14
- package/dist/tools/write/set-killswitch.js.map +1 -1
- package/package.json +1 -1
- package/dist/embedded-docs/getting-started/architecture-overview.mdx +0 -85
- package/dist/embedded-docs/reference/formal-verification.mdx +0 -19
- package/dist/embedded-docs/sdk/atomic-tx-invariant.mdx +0 -37
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* `agenttrust_init_policy` — initialise a PolicyAccount + VelocityLedger
|
|
4
|
-
* for the caller's `(agent_asset, policy_id)` pair.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* for the caller's `(agent_asset, policy_id)` pair.
|
|
5
|
+
*
|
|
6
|
+
* Self-healing: if the agent's `PolicyAuthority` PDA does not yet
|
|
7
|
+
* exist, the tool transparently prepends an `init_authority` instruction
|
|
8
|
+
* (single-member = signer, threshold = 1) and submits both in a single
|
|
9
|
+
* atomic transaction. The user never has to learn about Anchor 3012
|
|
10
|
+
* (AccountNotInitialized) or run a bootstrap script.
|
|
11
|
+
*
|
|
12
|
+
* Cap defaults: when the caller specifies ANY spending cap, unspecified
|
|
13
|
+
* peers default to the MAX of the specified caps rather than 0.
|
|
14
|
+
* Rationale: v1 policies are immutable post-init, so 0 (literal hard
|
|
15
|
+
* cap) is hostile — every gated payment fails with
|
|
16
|
+
* `SpendingPerTxExceeded`. The MAX-of-peers default keeps the explicit
|
|
17
|
+
* cap binding and leaves the others permissive.
|
|
7
18
|
*
|
|
8
19
|
* The full per-kind config is exposed as JSON; sane defaults zero every
|
|
9
20
|
* field so callers can incrementally enable kinds via the bitmask.
|
|
@@ -18,14 +29,16 @@ const config_1 = require("../../config");
|
|
|
18
29
|
const common_1 = require("../common");
|
|
19
30
|
const POLICY_AUTHORITY_PREFIX = Buffer.from("policy_authority");
|
|
20
31
|
const SpendingSchema = zod_1.z.object({
|
|
21
|
-
per_tx_max: zod_1.z.union([zod_1.z.number().int().nonnegative(), zod_1.z.string().regex(/^\d+$/)]).default(0),
|
|
22
|
-
daily_max: zod_1.z.union([zod_1.z.number().int().nonnegative(), zod_1.z.string().regex(/^\d+$/)]).default(0),
|
|
23
|
-
weekly_max: zod_1.z.union([zod_1.z.number().int().nonnegative(), zod_1.z.string().regex(/^\d+$/)]).default(0),
|
|
32
|
+
per_tx_max: zod_1.z.union([zod_1.z.number().int().nonnegative(), zod_1.z.string().regex(/^\d+$/)]).default(0).describe("Max per-transaction amount. If 0 and any peer cap is non-zero, defaults to the largest specified cap."),
|
|
33
|
+
daily_max: zod_1.z.union([zod_1.z.number().int().nonnegative(), zod_1.z.string().regex(/^\d+$/)]).default(0).describe("Max daily aggregate. If 0 and any peer cap is non-zero, defaults to the largest specified cap."),
|
|
34
|
+
weekly_max: zod_1.z.union([zod_1.z.number().int().nonnegative(), zod_1.z.string().regex(/^\d+$/)]).default(0).describe("Max weekly aggregate. If 0 and any peer cap is non-zero, defaults to the largest specified cap."),
|
|
24
35
|
}).default({ per_tx_max: 0, daily_max: 0, weekly_max: 0 });
|
|
25
36
|
const VelocitySchema = zod_1.z.object({
|
|
26
37
|
window_secs: zod_1.z.union([zod_1.z.number().int().nonnegative(), zod_1.z.string().regex(/^\d+$/)]).default(0),
|
|
27
38
|
max_in_window: zod_1.z.union([zod_1.z.number().int().nonnegative(), zod_1.z.string().regex(/^\d+$/)]).default(0),
|
|
28
|
-
tier0_decay_factor: zod_1.z.union([zod_1.z.number().int().nonnegative(), zod_1.z.string().regex(/^\d+$/)]).default(10000)
|
|
39
|
+
tier0_decay_factor: zod_1.z.union([zod_1.z.number().int().nonnegative(), zod_1.z.string().regex(/^\d+$/)]).default(10000).describe("Basis points (10_000 = 100%). Rate the velocity counter decays toward zero per slot. " +
|
|
40
|
+
"10_000 means full decay every slot (no rollover). 0 means the counter persists forever. " +
|
|
41
|
+
"Tune per agent's usage pattern."),
|
|
29
42
|
}).default({ window_secs: 0, max_in_window: 0, tier0_decay_factor: 10000 });
|
|
30
43
|
const CounterpartySchema = zod_1.z.object({
|
|
31
44
|
min_tier: zod_1.z.number().int().min(0).max(4).default(0),
|
|
@@ -49,12 +62,45 @@ const InputSchema = zod_1.z.object({
|
|
|
49
62
|
validation: ValidationSchema,
|
|
50
63
|
});
|
|
51
64
|
const ZERO_PUBKEY = new web3_js_1.PublicKey(new Uint8Array(32));
|
|
65
|
+
/**
|
|
66
|
+
* Apply max-of-peers default-fill. Returns a copy of `spending` where any
|
|
67
|
+
* `0` field is rewritten to the largest specified (non-zero) cap among
|
|
68
|
+
* its peers. If every field is `0`, returns the input unchanged — that
|
|
69
|
+
* means the user explicitly disabled the Spending kind via the bitmask
|
|
70
|
+
* and we honour it.
|
|
71
|
+
*/
|
|
72
|
+
function applySpendingCapDefaults(spending) {
|
|
73
|
+
const toBig = (v) => BigInt(typeof v === "string" ? v : v.toString());
|
|
74
|
+
const perTx = toBig(spending.per_tx_max);
|
|
75
|
+
const daily = toBig(spending.daily_max);
|
|
76
|
+
const weekly = toBig(spending.weekly_max);
|
|
77
|
+
const peers = [perTx, daily, weekly];
|
|
78
|
+
const maxPeer = peers.reduce((a, b) => (a > b ? a : b), 0n);
|
|
79
|
+
if (maxPeer === 0n) {
|
|
80
|
+
// All zero — user didn't specify any cap. Leave as zero (bitmask
|
|
81
|
+
// gating decides whether Spending is enabled at all).
|
|
82
|
+
return {
|
|
83
|
+
per_tx_max: perTx.toString(),
|
|
84
|
+
daily_max: daily.toString(),
|
|
85
|
+
weekly_max: weekly.toString(),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
per_tx_max: (perTx === 0n ? maxPeer : perTx).toString(),
|
|
90
|
+
daily_max: (daily === 0n ? maxPeer : daily).toString(),
|
|
91
|
+
weekly_max: (weekly === 0n ? maxPeer : weekly).toString(),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
52
94
|
exports.initPolicyTool = {
|
|
53
95
|
name: "agenttrust_init_policy",
|
|
54
96
|
description: "Create a PolicyAccount + VelocityLedger PDA for the caller's agent. " +
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
97
|
+
"Self-healing: if the agent's PolicyAuthority PDA does not yet exist, " +
|
|
98
|
+
"the tool prepends init_authority (single-member = signer, threshold 1) " +
|
|
99
|
+
"in the same atomic transaction. Sensible cap defaults: when the caller " +
|
|
100
|
+
"sets at least one spending cap, unspecified peer caps default to the " +
|
|
101
|
+
"MAX of the specified caps rather than 0 — important because v1 " +
|
|
102
|
+
"policies are immutable post-init and 0 is a hostile always-deny. " +
|
|
103
|
+
"Requires a signer (KEYPAIR_B58 / KEYPAIR_PATH / Solana CLI default).",
|
|
58
104
|
inputSchema: InputSchema,
|
|
59
105
|
async handler(input, ctx) {
|
|
60
106
|
const signer = ctx.chain.requireSigner();
|
|
@@ -63,6 +109,7 @@ exports.initPolicyTool = {
|
|
|
63
109
|
const policyPda = (0, chain_1.derivePolicyPda)(ctx.chain.cfg.programs.policyVault, agent, input.policy_id);
|
|
64
110
|
const velocityPda = (0, chain_1.deriveVelocityPda)(ctx.chain.cfg.programs.policyVault, agent, input.policy_id);
|
|
65
111
|
const authorityPda = web3_js_1.PublicKey.findProgramAddressSync([POLICY_AUTHORITY_PREFIX, agent.toBuffer()], ctx.chain.cfg.programs.policyVault)[0];
|
|
112
|
+
const effectiveSpending = applySpendingCapDefaults(input.spending);
|
|
66
113
|
const validationHash = input.validation.required_capability_hash_hex
|
|
67
114
|
? Array.from((0, common_1.hexToBytes)(input.validation.required_capability_hash_hex))
|
|
68
115
|
: Array.from(new Uint8Array(32));
|
|
@@ -80,9 +127,9 @@ exports.initPolicyTool = {
|
|
|
80
127
|
gateMode: input.gate_mode,
|
|
81
128
|
scopeKind: input.scope_kind,
|
|
82
129
|
spending: {
|
|
83
|
-
perTxMax: new anchor_1.BN(
|
|
84
|
-
dailyMax: new anchor_1.BN(
|
|
85
|
-
weeklyMax: new anchor_1.BN(
|
|
130
|
+
perTxMax: new anchor_1.BN(effectiveSpending.per_tx_max),
|
|
131
|
+
dailyMax: new anchor_1.BN(effectiveSpending.daily_max),
|
|
132
|
+
weeklyMax: new anchor_1.BN(effectiveSpending.weekly_max),
|
|
86
133
|
},
|
|
87
134
|
velocity: {
|
|
88
135
|
windowSecs: new anchor_1.BN(input.velocity.window_secs.toString()),
|
|
@@ -100,7 +147,28 @@ exports.initPolicyTool = {
|
|
|
100
147
|
acceptedAttestors,
|
|
101
148
|
},
|
|
102
149
|
};
|
|
103
|
-
|
|
150
|
+
// Self-heal: if PolicyAuthority is missing, prepend init_authority
|
|
151
|
+
// (single-member = signer, threshold = 1) in the same tx. The
|
|
152
|
+
// existing on-chain account is otherwise the source of truth — we
|
|
153
|
+
// never overwrite different members/threshold silently.
|
|
154
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
155
|
+
const existingAuth = await policyVault.account.policyAuthority.fetchNullable(authorityPda);
|
|
156
|
+
const healedSteps = [];
|
|
157
|
+
const tx = new web3_js_1.Transaction();
|
|
158
|
+
if (!existingAuth) {
|
|
159
|
+
const initAuthIx = await policyVault.methods
|
|
160
|
+
.initAuthority(agent, [signer.publicKey], 1)
|
|
161
|
+
.accounts({
|
|
162
|
+
payer: signer.publicKey,
|
|
163
|
+
policyAuthority: authorityPda,
|
|
164
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
165
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
166
|
+
})
|
|
167
|
+
.instruction();
|
|
168
|
+
tx.add(initAuthIx);
|
|
169
|
+
healedSteps.push("init_authority");
|
|
170
|
+
}
|
|
171
|
+
const initPolicyIx = await policyVault.methods
|
|
104
172
|
.initPolicy(agent, args)
|
|
105
173
|
.accounts({
|
|
106
174
|
payer: signer.publicKey,
|
|
@@ -110,7 +178,9 @@ exports.initPolicyTool = {
|
|
|
110
178
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
111
179
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
112
180
|
})
|
|
113
|
-
.
|
|
181
|
+
.instruction();
|
|
182
|
+
tx.add(initPolicyIx);
|
|
183
|
+
const txSignature = await ctx.chain.provider.sendAndConfirm(tx, [signer]);
|
|
114
184
|
return {
|
|
115
185
|
txSignature,
|
|
116
186
|
explorerTxUrl: (0, config_1.explorerUrl)(ctx.chain.cfg, "tx", txSignature),
|
|
@@ -118,6 +188,13 @@ exports.initPolicyTool = {
|
|
|
118
188
|
policyExplorer: (0, config_1.explorerUrl)(ctx.chain.cfg, "address", policyPda.toBase58()),
|
|
119
189
|
velocityPda: velocityPda.toBase58(),
|
|
120
190
|
velocityExplorer: (0, config_1.explorerUrl)(ctx.chain.cfg, "address", velocityPda.toBase58()),
|
|
191
|
+
effectiveSpending: {
|
|
192
|
+
perTxMax: effectiveSpending.per_tx_max,
|
|
193
|
+
dailyMax: effectiveSpending.daily_max,
|
|
194
|
+
weeklyMax: effectiveSpending.weekly_max,
|
|
195
|
+
},
|
|
196
|
+
selfHealed: healedSteps.length > 0,
|
|
197
|
+
healedSteps,
|
|
121
198
|
};
|
|
122
199
|
},
|
|
123
200
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-policy.js","sourceRoot":"","sources":["../../../src/tools/write/init-policy.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"init-policy.js","sourceRoot":"","sources":["../../../src/tools/write/init-policy.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,8CAAuC;AACvC,6CAAwE;AACxE,6BAAwB;AAExB,uCAAiE;AACjE,yCAA2C;AAC3C,sCAAiF;AAGjF,MAAM,uBAAuB,GAAG,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,C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claim_uri_hash_hex: common_1.HexHashSchema.describe("32-byte hash of the off-chain claim URI"),
|
|
24
24
|
deadline_slot: zod_1.z.union([zod_1.z.number().int().positive(), zod_1.z.string().regex(/^\d+$/)])
|
|
25
|
-
.describe("Slot by which an attestor must respond"
|
|
25
|
+
.describe("Slot by which an attestor must respond. Must be greater than the " +
|
|
26
|
+
"current Solana slot. Devnet slots advance roughly every 400ms " +
|
|
27
|
+
"(so `current_slot + 60 * 1000 / 400 = current_slot + 150` is " +
|
|
28
|
+
"approximately one minute in the future)."),
|
|
26
29
|
});
|
|
27
30
|
exports.requestValidationTool = {
|
|
28
31
|
name: "agenttrust_request_validation",
|
|
29
32
|
description: "Open a ValidationRequest PDA inviting attestors to attest to a " +
|
|
30
33
|
"subject's capability. Pass either capability_name (preferred — the SDK " +
|
|
31
34
|
"computes SHA256(name) and stamps it as the hash) or capability_hash_hex " +
|
|
32
|
-
"directly. Requires KEYPAIR_B58
|
|
35
|
+
"directly. Requires a signer (KEYPAIR_B58 / KEYPAIR_PATH / Solana CLI " +
|
|
36
|
+
"default). Returns the request PDA's Explorer URL.",
|
|
33
37
|
inputSchema: InputSchema,
|
|
34
38
|
async handler(input, ctx) {
|
|
35
39
|
const signer = ctx.chain.requireSigner();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-validation.js","sourceRoot":"","sources":["../../../src/tools/write/request-validation.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,6CAA8C;AAC9C,6BAAwB;AAExB,uCAIqB;AACrB,yCAA2C;AAC3C,sCAA6F;AAG7F,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,aAAa,EAAS,qBAAY,CAAC,QAAQ,CAAC,uDAAuD,CAAC;IACpG,eAAe,EAAO,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;SACjC,QAAQ,CAAC,sEAA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,QAAQ,EAAE,CAAC;SACvD,CAAC,CAAC;QAEH,MAAM,EAAE,GAAG,IAAI,qBAAW,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACrC,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1E,MAAM,UAAU,GAAG,IAAA,kCAA0B,EAC3C,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,kBAAkB,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,SAAS,CAC9E,CAAC;QAEF,OAAO;YACL,WAAW;YACX,aAAa,EAAM,IAAA,oBAAW,EAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,EAAO,WAAW,CAAC;YACrE,UAAU,EAAS,UAAU,CAAC,QAAQ,EAAE;YACxC,eAAe,EAAI,IAAA,oBAAW,EAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,UAAU,CAAC,QAAQ,EAAE,CAAC;YAC/E,iBAAiB,EAAE,IAAA,mBAAU,EAAC,OAAO,CAAC;SACvC,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
* must be the attestor (matches `attestor_profile.attestor`).
|
|
8
8
|
*
|
|
9
9
|
* If the attestor profile doesn't exist yet, this tool surfaces a clear
|
|
10
|
-
* error pointing at the
|
|
11
|
-
*
|
|
10
|
+
* error pointing at the attestor-demo bootstrap script and the SDK's
|
|
11
|
+
* validation-registry helpers — there's no MCP `register_attestor`
|
|
12
|
+
* tool, the SDK + demo path is the canonical bootstrap surface.
|
|
12
13
|
*/
|
|
13
14
|
import { z } from "zod";
|
|
14
15
|
import type { Tool } from "../types";
|
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
* must be the attestor (matches `attestor_profile.attestor`).
|
|
9
9
|
*
|
|
10
10
|
* If the attestor profile doesn't exist yet, this tool surfaces a clear
|
|
11
|
-
* error pointing at the
|
|
12
|
-
*
|
|
11
|
+
* error pointing at the attestor-demo bootstrap script and the SDK's
|
|
12
|
+
* validation-registry helpers — there's no MCP `register_attestor`
|
|
13
|
+
* tool, the SDK + demo path is the canonical bootstrap surface.
|
|
13
14
|
*/
|
|
14
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
16
|
exports.respondToValidationTool = void 0;
|
|
@@ -30,10 +31,10 @@ const InputSchema = zod_1.z.object({
|
|
|
30
31
|
exports.respondToValidationTool = {
|
|
31
32
|
name: "agenttrust_respond_to_validation",
|
|
32
33
|
description: "Attestor responds to a ValidationRequest by creating a " +
|
|
33
|
-
"ValidationAttestation PDA. Requires
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"RequireValidation reads.",
|
|
34
|
+
"ValidationAttestation PDA. Requires a signer (KEYPAIR_B58 / " +
|
|
35
|
+
"KEYPAIR_PATH / Solana CLI default) whose pubkey must equal the " +
|
|
36
|
+
"attestor registered in AttestorProfile. Surfaces the attestation " +
|
|
37
|
+
"PDA + Explorer URL for downstream PolicyVault RequireValidation reads.",
|
|
37
38
|
inputSchema: InputSchema,
|
|
38
39
|
async handler(input, ctx) {
|
|
39
40
|
const signer = ctx.chain.requireSigner();
|
|
@@ -52,7 +53,9 @@ exports.respondToValidationTool = {
|
|
|
52
53
|
const profile = await (0, chain_1.fetchAttestorProfile)(program, signer.publicKey);
|
|
53
54
|
if (!profile.data) {
|
|
54
55
|
throw new Error(`AttestorProfile not initialised for signer ${signer.publicKey.toBase58()}. ` +
|
|
55
|
-
`
|
|
56
|
+
`Bootstrap an attestor profile by running the demo script at ` +
|
|
57
|
+
`examples/attestor-demo/scripts/init.ts or composing a register_attestor ` +
|
|
58
|
+
`transaction with @agenttrust-sdk/trustgate's validation-registry helpers.`);
|
|
56
59
|
}
|
|
57
60
|
const ix = await (0, chain_1.buildRespondToValidationIx)({
|
|
58
61
|
program,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"respond-to-validation.js","sourceRoot":"","sources":["../../../src/tools/write/respond-to-validation.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"respond-to-validation.js","sourceRoot":"","sources":["../../../src/tools/write/respond-to-validation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAEH,6CAA8C;AAC9C,6BAAwB;AAExB,uCAMqB;AACrB,yCAA2C;AAC3C,sCAA6F;AAG7F,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,aAAa,EAAS,qBAAY;IAClC,eAAe,EAAO,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC1D,mBAAmB,EAAG,sBAAa,CAAC,QAAQ,EAAE;IAC9C,sBAAsB,EAAE,sBAAa,CAAC,QAAQ,CAAC,qDAAqD,CAAC;IACrG,kBAAkB,EAAI,sBAAa,CAAC,QAAQ,CAAC,yCAAyC,CAAC;IACvF,eAAe,EAAO,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;SAC9D,QAAQ,CAAC,qCAAqC,CAAC;CACzE,CAAC,CAAC;AAYU,QAAA,uBAAuB,GAAwB;IAC1D,IAAI,EAAS,kCAAkC;IAC/C,WAAW,EACT,yDAAyD;QACzD,8DAA8D;QAC9D,iEAAiE;QACjE,mEAAmE;QACnE,wEAAwE;IAC1E,WAAW,EAAE,WAAW;IAExB,KAAK,CAAC,OAAO,CAAC,KAAY,EAAE,GAAgB;QAC1C,MAAM,MAAM,GAAI,GAAG,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;QAC1C,MAAM,OAAO,GAAG,IAAA,oBAA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AAK,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC;SAC3D,CAAC,CAAC;QAEH,MAAM,EAAE,GAAG,IAAI,qBAAW,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACrC,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QAE1E,MAAM,cAAc,GAAG,IAAA,sCAA8B,EACnD,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,kBAAkB,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,SAAS,CAC9E,CAAC;QACF,MAAM,kBAAkB,GAAG,IAAA,gCAAwB,EACjD,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC,SAAS,CAC5D,CAAC;QAEF,OAAO;YACL,WAAW;YACX,aAAa,EAAS,IAAA,oBAAW,EAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,EAAO,WAAW,CAAC;YACxE,cAAc,EAAQ,cAAc,CAAC,QAAQ,EAAE;YAC/C,mBAAmB,EAAG,IAAA,oBAAW,EAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,cAAc,CAAC,QAAQ,EAAE,CAAC;YACtF,kBAAkB,EAAI,kBAAkB,CAAC,QAAQ,EAAE;YACnD,iBAAiB,EAAK,IAAA,mBAAU,EAAC,OAAO,CAAC;SAC1C,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -4,6 +4,13 @@
|
|
|
4
4
|
* signers in `remainingAccounts` must reach the PolicyAuthority's
|
|
5
5
|
* threshold count.
|
|
6
6
|
*
|
|
7
|
+
* Self-healing: this tool depends on two PDAs being initialised —
|
|
8
|
+
* `PolicyAuthority` (created by `init_authority`) and `KillSwitchState`
|
|
9
|
+
* (created by `init_killswitch`). When either is missing, the tool
|
|
10
|
+
* prepends the corresponding init instruction in the same atomic
|
|
11
|
+
* transaction. The user never has to learn about Anchor 3012
|
|
12
|
+
* (AccountNotInitialized) or run a bootstrap script.
|
|
13
|
+
*
|
|
7
14
|
* v1 ships the lead-signer-only happy path; thresholds > 1 require the
|
|
8
15
|
* caller to assemble the multisig out-of-band and pass cosigner pubkeys
|
|
9
16
|
* via `cosigner_pubkeys` (each must be available in the local keypair
|
|
@@ -29,6 +36,9 @@ interface Output {
|
|
|
29
36
|
killSwitchPda: string;
|
|
30
37
|
killSwitchExplorer: string;
|
|
31
38
|
paused: boolean;
|
|
39
|
+
/** True when the tool transparently bootstrapped any prerequisite PDA in the same tx. */
|
|
40
|
+
selfHealed: boolean;
|
|
41
|
+
healedSteps: string[];
|
|
32
42
|
}
|
|
33
43
|
export declare const setKillswitchTool: Tool<Input, Output>;
|
|
34
44
|
export {};
|
|
@@ -5,6 +5,13 @@
|
|
|
5
5
|
* signers in `remainingAccounts` must reach the PolicyAuthority's
|
|
6
6
|
* threshold count.
|
|
7
7
|
*
|
|
8
|
+
* Self-healing: this tool depends on two PDAs being initialised —
|
|
9
|
+
* `PolicyAuthority` (created by `init_authority`) and `KillSwitchState`
|
|
10
|
+
* (created by `init_killswitch`). When either is missing, the tool
|
|
11
|
+
* prepends the corresponding init instruction in the same atomic
|
|
12
|
+
* transaction. The user never has to learn about Anchor 3012
|
|
13
|
+
* (AccountNotInitialized) or run a bootstrap script.
|
|
14
|
+
*
|
|
8
15
|
* v1 ships the lead-signer-only happy path; thresholds > 1 require the
|
|
9
16
|
* caller to assemble the multisig out-of-band and pass cosigner pubkeys
|
|
10
17
|
* via `cosigner_pubkeys` (each must be available in the local keypair
|
|
@@ -25,10 +32,12 @@ const InputSchema = zod_1.z.object({
|
|
|
25
32
|
});
|
|
26
33
|
exports.setKillswitchTool = {
|
|
27
34
|
name: "agenttrust_set_killswitch",
|
|
28
|
-
description: "Pause or unpause an agent's KillSwitchState.
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
35
|
+
description: "Pause or unpause an agent's KillSwitchState. Self-healing: if " +
|
|
36
|
+
"PolicyAuthority or KillSwitchState is missing, the tool prepends " +
|
|
37
|
+
"init_authority (single-member = signer, threshold 1) and/or " +
|
|
38
|
+
"init_killswitch in the same atomic transaction. Lead-signer must be a " +
|
|
39
|
+
"member of the PolicyAuthority; threshold > 1 (multi-sig) is not yet " +
|
|
40
|
+
"supported by this tool. Requires a signer.",
|
|
32
41
|
inputSchema: InputSchema,
|
|
33
42
|
async handler(input, ctx) {
|
|
34
43
|
const signer = ctx.chain.requireSigner();
|
|
@@ -36,20 +45,56 @@ exports.setKillswitchTool = {
|
|
|
36
45
|
const policy = await ctx.chain.policyVault();
|
|
37
46
|
const ksPda = (0, chain_1.deriveKillSwitchPda)(ctx.chain.cfg.programs.policyVault, agent);
|
|
38
47
|
const authPda = web3_js_1.PublicKey.findProgramAddressSync([POLICY_AUTHORITY_PREFIX, agent.toBuffer()], ctx.chain.cfg.programs.policyVault)[0];
|
|
39
|
-
//
|
|
40
|
-
//
|
|
48
|
+
// Self-heal preflight: confirm PolicyAuthority + KillSwitchState
|
|
49
|
+
// exist; if not, prepend the matching init instructions to the same
|
|
50
|
+
// transaction. Existing accounts are the source of truth — we never
|
|
51
|
+
// overwrite different members/threshold silently.
|
|
41
52
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
53
|
const auth = await policy.account.policyAuthority.fetchNullable(authPda);
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
+
const ks = await policy.account.killSwitchState.fetchNullable(ksPda);
|
|
56
|
+
const healedSteps = [];
|
|
57
|
+
const tx = new web3_js_1.Transaction();
|
|
43
58
|
if (!auth) {
|
|
44
|
-
|
|
45
|
-
|
|
59
|
+
const initAuthIx = await policy.methods
|
|
60
|
+
.initAuthority(agent, [signer.publicKey], 1)
|
|
61
|
+
.accounts({
|
|
62
|
+
payer: signer.publicKey,
|
|
63
|
+
policyAuthority: authPda,
|
|
64
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
66
|
+
})
|
|
67
|
+
.instruction();
|
|
68
|
+
tx.add(initAuthIx);
|
|
69
|
+
healedSteps.push("init_authority");
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
// Lead-signer-only constraint — only checkable when authority exists.
|
|
73
|
+
// When self-healed in-tx, threshold = 1 by construction.
|
|
74
|
+
const threshold = Number(auth.threshold ?? 0);
|
|
75
|
+
if (threshold > 1) {
|
|
76
|
+
throw new Error(`PolicyAuthority threshold is ${threshold}. This tool only supports ` +
|
|
77
|
+
`lead-only signing (threshold=1). Cosigner support is roadmap. ` +
|
|
78
|
+
`To run a multi-sig killswitch today, use the Anchor CLI flow at ` +
|
|
79
|
+
`https://docs.agenttrust.tech/programs/policy-vault/kill-switch-policy ` +
|
|
80
|
+
`(or build a custom transaction via @agenttrust-sdk/trustgate's ` +
|
|
81
|
+
`set_killswitch composer).`);
|
|
82
|
+
}
|
|
46
83
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
84
|
+
if (!ks) {
|
|
85
|
+
const initKsIx = await policy.methods
|
|
86
|
+
.initKillswitch(agent)
|
|
87
|
+
.accounts({
|
|
88
|
+
payer: signer.publicKey,
|
|
89
|
+
killSwitchState: ksPda,
|
|
90
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
|
+
})
|
|
93
|
+
.instruction();
|
|
94
|
+
tx.add(initKsIx);
|
|
95
|
+
healedSteps.push("init_killswitch");
|
|
51
96
|
}
|
|
52
|
-
const
|
|
97
|
+
const setKsIx = await policy.methods
|
|
53
98
|
.setKillswitch(agent, input.paused)
|
|
54
99
|
.accounts({
|
|
55
100
|
signer: signer.publicKey,
|
|
@@ -57,13 +102,17 @@ exports.setKillswitchTool = {
|
|
|
57
102
|
killSwitchState: ksPda,
|
|
58
103
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
104
|
})
|
|
60
|
-
.
|
|
105
|
+
.instruction();
|
|
106
|
+
tx.add(setKsIx);
|
|
107
|
+
const txSignature = await ctx.chain.provider.sendAndConfirm(tx, [signer]);
|
|
61
108
|
return {
|
|
62
109
|
txSignature,
|
|
63
110
|
explorerTxUrl: (0, config_1.explorerUrl)(ctx.chain.cfg, "tx", txSignature),
|
|
64
111
|
killSwitchPda: ksPda.toBase58(),
|
|
65
112
|
killSwitchExplorer: (0, config_1.explorerUrl)(ctx.chain.cfg, "address", ksPda.toBase58()),
|
|
66
113
|
paused: input.paused,
|
|
114
|
+
selfHealed: healedSteps.length > 0,
|
|
115
|
+
healedSteps,
|
|
67
116
|
};
|
|
68
117
|
},
|
|
69
118
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-killswitch.js","sourceRoot":"","sources":["../../../src/tools/write/set-killswitch.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"set-killswitch.js","sourceRoot":"","sources":["../../../src/tools/write/set-killswitch.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AAEH,6CAAwE;AACxE,6BAAwB;AAExB,uCAAkD;AAClD,yCAA2C;AAC3C,sCAAsD;AAGtD,MAAM,uBAAuB,GAAG,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;AAEhE,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,WAAW,EAAE,qBAAY,CAAC,QAAQ,CAAC,oBAAoB,CAAC;IACxD,MAAM,EAAO,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;CACrE,CAAC,CAAC;AAcU,QAAA,iBAAiB,GAAwB;IACpD,IAAI,EAAS,2BAA2B;IACxC,WAAW,EACT,gEAAgE;QAChE,mEAAmE;QACnE,8D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CAAC;QACjB,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAEhB,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QAE1E,OAAO;YACL,WAAW;YACX,aAAa,EAAO,IAAA,oBAAW,EAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,EAAO,WAAW,CAAC;YACtE,aAAa,EAAO,KAAK,CAAC,QAAQ,EAAE;YACpC,kBAAkB,EAAE,IAAA,oBAAW,EAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;YAC3E,MAAM,EAAc,KAAK,CAAC,MAAM;YAChC,UAAU,EAAU,WAAW,CAAC,MAAM,GAAG,CAAC;YAC1C,WAAW;SACZ,CAAC;IACJ,CAAC;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agenttrust-sdk/mcp",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "MCP server for AgentTrust \u2014 query and call deployed Solana programs from Claude Desktop / Cursor / any MCP client",
|
|
5
5
|
"author": "AgentTrust Labs (https://agenttrust.tech)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Architecture overview
|
|
3
|
-
description: How AgentTrust composes x402 facilitators, Solana policy, settlement, and feedback.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
AgentTrust has three on-chain programs, one TypeScript SDK, and one facilitator-adapter layer. Pay.sh is the first concrete adapter. The design keeps protocol-specific wire shapes outside the policy and feedback path.
|
|
7
|
-
|
|
8
|
-
## Current flow
|
|
9
|
-
|
|
10
|
-
```txt
|
|
11
|
-
agent request
|
|
12
|
-
-> x402 facilitator (Pay.sh today)
|
|
13
|
-
-> FacilitatorAdapter.parseRequest
|
|
14
|
-
-> VerifyContext
|
|
15
|
-
-> PolicyVault gate_payment
|
|
16
|
-
-> Allow | Deny | RequireValidation
|
|
17
|
-
-> signed settlement path
|
|
18
|
-
-> SPL transfer
|
|
19
|
-
-> TrustGate emit_feedback
|
|
20
|
-
-> Quantu agent_registry_8004 give_feedback
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Components
|
|
24
|
-
|
|
25
|
-
| Component | Location | Responsibility |
|
|
26
|
-
| --- | --- | --- |
|
|
27
|
-
| PolicyVault | `programs/policy-vault` | compose five policy kinds and return a decision |
|
|
28
|
-
| TrustGate | `programs/trustgate` | sign feedback CPI as the facilitator PDA |
|
|
29
|
-
| ValidationRegistry | `programs/validation-registry` | store capability attestations read by PolicyVault |
|
|
30
|
-
| Facilitator adapters | `trustgate/server/src/facilitators` | translate Pay.sh / Dexter / atxp_ai / MCPay wire shapes into `VerifyContext` |
|
|
31
|
-
| SDK | `trustgate/sdk` | expose client helpers and Express routes |
|
|
32
|
-
|
|
33
|
-
## Why adapters exist
|
|
34
|
-
|
|
35
|
-
Every x402 facilitator carries the same payment intent but differs in headers, body shape, proof payload, retry behavior, and settlement metadata. AgentTrust isolates those differences in five adapter methods:
|
|
36
|
-
|
|
37
|
-
| Method | Responsibility |
|
|
38
|
-
| --- | --- |
|
|
39
|
-
| `parseRequest` | turn a facilitator request into `VerifyContext` |
|
|
40
|
-
| `formatChallenge` | render Allow / Deny / RequireValidation back into that facilitator's wire shape |
|
|
41
|
-
| `formatSettlement` | produce settlement metadata or an unsigned transaction skeleton |
|
|
42
|
-
| `validatePaymentProof` | verify proof shape and cross-check transfer context |
|
|
43
|
-
| `emitFeedback` | call the feedback CPI idempotently |
|
|
44
|
-
|
|
45
|
-
Routes, policy logic, and registry reads do not branch on a facilitator name.
|
|
46
|
-
|
|
47
|
-
## Decision path
|
|
48
|
-
|
|
49
|
-
PolicyVault is deliberately fail-fast:
|
|
50
|
-
|
|
51
|
-
1. `KillSwitch`
|
|
52
|
-
2. `Spending`
|
|
53
|
-
3. `Velocity`
|
|
54
|
-
4. `CounterpartyTier`
|
|
55
|
-
5. `RequireValidation`
|
|
56
|
-
|
|
57
|
-
State changes are applied only on `Allow`. `Deny` and `RequireValidation` return a decision without mutating spending or velocity counters.
|
|
58
|
-
|
|
59
|
-
## Trust reads
|
|
60
|
-
|
|
61
|
-
PolicyVault reads foreign PDAs defensively:
|
|
62
|
-
|
|
63
|
-
| Data | Parser | Locked offset |
|
|
64
|
-
| --- | --- | --- |
|
|
65
|
-
| Quantu `AtomStats.risk_score` | `policy-vault/src/ext/atom_engine.rs` | byte `549` |
|
|
66
|
-
| Quantu `AtomStats.trust_tier` | `policy-vault/src/ext/atom_engine.rs` | byte `551` |
|
|
67
|
-
| Quantu `AtomStats.confidence` | `policy-vault/src/ext/atom_engine.rs` | bytes `557..558` |
|
|
68
|
-
| AgentTrust attestation subject | `policy-vault/src/ext/validation_registry.rs` | byte `8` |
|
|
69
|
-
| AgentTrust attestation expiry | `policy-vault/src/ext/validation_registry.rs` | byte `208` |
|
|
70
|
-
|
|
71
|
-
## Verification boundary
|
|
72
|
-
|
|
73
|
-
<KaniProofBadge />
|
|
74
|
-
|
|
75
|
-
The Kani harnesses target the pure Rust policy/composer layer rather than the Anchor wrappers. That keeps proofs short, deterministic, and tied to the code that makes decisions.
|
|
76
|
-
|
|
77
|
-
## Atomic settlement boundary
|
|
78
|
-
|
|
79
|
-
For production settlement, the policy check, SPL transfer, and feedback emission must share the same signed transaction path. If one part fails, the user should not get a successful payment with missing feedback or feedback for a missing payment.
|
|
80
|
-
|
|
81
|
-
The Pay.sh demo uses stubs for RPC and CPI so local tests run quickly. Those seams are the same seams a production factory fills with devnet programs and SPL transfer parsing.
|
|
82
|
-
|
|
83
|
-
## Deployment boundary
|
|
84
|
-
|
|
85
|
-
The docs and SDK default to devnet program IDs. Quantu mainnet IDs are used for local validator cloning and reference-grade byte layouts.
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Formal verification
|
|
3
|
-
description: Kani proof harnesses that guard PolicyVault invariants.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
`In progress`
|
|
7
|
-
|
|
8
|
-
AgentTrust runs five Kani harnesses for the current PolicyVault safety surface.
|
|
9
|
-
|
|
10
|
-
| Harness | Property |
|
|
11
|
-
| --- | --- |
|
|
12
|
-
| `paused_implies_no_allow` | paused KillSwitch cannot allow |
|
|
13
|
-
| `velocity_counter_le_limit` | allow-path counter stays within limit |
|
|
14
|
-
| `counterparty_tier_monotone` | looser tier requirement cannot fail after tighter pass |
|
|
15
|
-
| `validation_expiry_correct` | expired attestation cannot allow |
|
|
16
|
-
| `multisig_threshold_enforced` | threshold requires distinct signing members |
|
|
17
|
-
|
|
18
|
-
Sources: [`programs/policy-vault/src/proofs`](https://github.com/agenttrust-labs/agenttrust/tree/main/programs/policy-vault/src/proofs), [`.github/workflows/kani-prove.yml`](https://github.com/agenttrust-labs/agenttrust/blob/main/.github/workflows/kani-prove.yml)
|
|
19
|
-
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Atomic-tx invariant
|
|
3
|
-
description: SDK and facilitator rules that keep policy checks tied to settlement.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
AgentTrust treats a policy check as useful only when the facilitator enforces the same payment context through settlement.
|
|
7
|
-
|
|
8
|
-
Production settlement must compose:
|
|
9
|
-
|
|
10
|
-
1. `gate_payment`
|
|
11
|
-
2. SPL transfer
|
|
12
|
-
3. `emit_feedback`
|
|
13
|
-
|
|
14
|
-
All three succeed, or all three revert. That is the invariant that keeps a Pay.sh payment from settling without the AgentTrust feedback record, and keeps feedback from being emitted for a payment that never moved.
|
|
15
|
-
|
|
16
|
-
## Adapter responsibilities
|
|
17
|
-
|
|
18
|
-
The adapter validates that the retry proof still matches the verify-time context:
|
|
19
|
-
|
|
20
|
-
| Check | Why it exists |
|
|
21
|
-
| --- | --- |
|
|
22
|
-
| `paymentIdHash` replay binding | prevents duplicate or raced settlement calls |
|
|
23
|
-
| amount, mint, recipient cross-check | prevents paying a different asset or recipient than the policy checked |
|
|
24
|
-
| facilitator fee payer != transfer authority | prevents self-pay feedback |
|
|
25
|
-
| SERVICE-signed challenge | prevents forged `paymentRequirements` racing a legitimate one |
|
|
26
|
-
| idempotent feedback lookup | makes retries return a stable receipt instead of double-emitting |
|
|
27
|
-
|
|
28
|
-
## Demo vs production
|
|
29
|
-
|
|
30
|
-
`examples/pay-sh-demo` stubs `validateOnChainTx` and `emitFeedbackCpi` so the route can run in CI. Production fills those same dependency seams with RPC parsing and the Anchor feedback call.
|
|
31
|
-
|
|
32
|
-
| Source | Path |
|
|
33
|
-
| --- | --- |
|
|
34
|
-
| facilitator routes | [`trustgate/server/src/routes/settle.ts`](https://github.com/agenttrust-labs/agenttrust/blob/main/trustgate/server/src/routes/settle.ts) |
|
|
35
|
-
| Pay.sh proof validator | [`trustgate/server/src/facilitators/pay-sh/proof-validator.ts`](https://github.com/agenttrust-labs/agenttrust/blob/main/trustgate/server/src/facilitators/pay-sh/proof-validator.ts) |
|
|
36
|
-
| Pay.sh feedback helper | [`trustgate/server/src/facilitators/pay-sh/feedback.ts`](https://github.com/agenttrust-labs/agenttrust/blob/main/trustgate/server/src/facilitators/pay-sh/feedback.ts) |
|
|
37
|
-
| Pay.sh demo deps | [`examples/pay-sh-demo/src/deps.ts`](https://github.com/agenttrust-labs/agenttrust/blob/main/examples/pay-sh-demo/src/deps.ts) |
|