@agenttrust-sdk/mcp 0.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/LICENSE +21 -0
- package/README.md +233 -0
- package/dist/chain.d.ts +41 -0
- package/dist/chain.js +164 -0
- package/dist/chain.js.map +1 -0
- package/dist/config.d.ts +35 -0
- package/dist/config.js +99 -0
- package/dist/config.js.map +1 -0
- package/dist/idl/policy_vault.json +1723 -0
- package/dist/idl/trustgate.json +623 -0
- package/dist/idl/validation_registry.json +1052 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +123 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts/audit-payment.d.ts +10 -0
- package/dist/prompts/audit-payment.js +55 -0
- package/dist/prompts/audit-payment.js.map +1 -0
- package/dist/prompts/explain-failure.d.ts +7 -0
- package/dist/prompts/explain-failure.js +57 -0
- package/dist/prompts/explain-failure.js.map +1 -0
- package/dist/prompts/index.d.ts +3 -0
- package/dist/prompts/index.js +12 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/setup-agent.d.ts +6 -0
- package/dist/prompts/setup-agent.js +43 -0
- package/dist/prompts/setup-agent.js.map +1 -0
- package/dist/prompts/types.d.ts +23 -0
- package/dist/prompts/types.js +6 -0
- package/dist/prompts/types.js.map +1 -0
- package/dist/resources/docs.d.ts +23 -0
- package/dist/resources/docs.js +147 -0
- package/dist/resources/docs.js.map +1 -0
- package/dist/resources/programs.d.ts +14 -0
- package/dist/resources/programs.js +69 -0
- package/dist/resources/programs.js.map +1 -0
- package/dist/server.d.ts +19 -0
- package/dist/server.js +136 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/common.d.ts +18 -0
- package/dist/tools/common.js +77 -0
- package/dist/tools/common.js.map +1 -0
- package/dist/tools/discovery/docs.d.ts +48 -0
- package/dist/tools/discovery/docs.js +200 -0
- package/dist/tools/discovery/docs.js.map +1 -0
- package/dist/tools/discovery/explain-decision.d.ts +28 -0
- package/dist/tools/discovery/explain-decision.js +144 -0
- package/dist/tools/discovery/explain-decision.js.map +1 -0
- package/dist/tools/discovery/facilitator-walkthrough.d.ts +30 -0
- package/dist/tools/discovery/facilitator-walkthrough.js +117 -0
- package/dist/tools/discovery/facilitator-walkthrough.js.map +1 -0
- package/dist/tools/index.d.ts +9 -0
- package/dist/tools/index.js +55 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/read/demo-state.d.ts +48 -0
- package/dist/tools/read/demo-state.js +129 -0
- package/dist/tools/read/demo-state.js.map +1 -0
- package/dist/tools/read/get-feedback-log.d.ts +28 -0
- package/dist/tools/read/get-feedback-log.js +51 -0
- package/dist/tools/read/get-feedback-log.js.map +1 -0
- package/dist/tools/read/get-killswitch.d.ts +38 -0
- package/dist/tools/read/get-killswitch.js +63 -0
- package/dist/tools/read/get-killswitch.js.map +1 -0
- package/dist/tools/read/get-policy.d.ts +51 -0
- package/dist/tools/read/get-policy.js +71 -0
- package/dist/tools/read/get-policy.js.map +1 -0
- package/dist/tools/read/get-quantu-reputation.d.ts +39 -0
- package/dist/tools/read/get-quantu-reputation.js +65 -0
- package/dist/tools/read/get-quantu-reputation.js.map +1 -0
- package/dist/tools/read/get-validation-attestation.d.ts +45 -0
- package/dist/tools/read/get-validation-attestation.js +76 -0
- package/dist/tools/read/get-validation-attestation.js.map +1 -0
- package/dist/tools/read/get-velocity.d.ts +31 -0
- package/dist/tools/read/get-velocity.js +50 -0
- package/dist/tools/read/get-velocity.js.map +1 -0
- package/dist/tools/read/list-facilitators.d.ts +31 -0
- package/dist/tools/read/list-facilitators.js +60 -0
- package/dist/tools/read/list-facilitators.js.map +1 -0
- package/dist/tools/read/list-policies.d.ts +33 -0
- package/dist/tools/read/list-policies.js +49 -0
- package/dist/tools/read/list-policies.js.map +1 -0
- package/dist/tools/read/simulate-payment.d.ts +44 -0
- package/dist/tools/read/simulate-payment.js +54 -0
- package/dist/tools/read/simulate-payment.js.map +1 -0
- package/dist/tools/types.d.ts +31 -0
- package/dist/tools/types.js +12 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tools/write/emit-feedback.d.ts +55 -0
- package/dist/tools/write/emit-feedback.js +83 -0
- package/dist/tools/write/emit-feedback.js.map +1 -0
- package/dist/tools/write/init-policy.d.ts +133 -0
- package/dist/tools/write/init-policy.js +124 -0
- package/dist/tools/write/init-policy.js.map +1 -0
- package/dist/tools/write/request-validation.d.ts +39 -0
- package/dist/tools/write/request-validation.js +69 -0
- package/dist/tools/write/request-validation.js.map +1 -0
- package/dist/tools/write/respond-to-validation.d.ts +47 -0
- package/dist/tools/write/respond-to-validation.js +81 -0
- package/dist/tools/write/respond-to-validation.js.map +1 -0
- package/dist/tools/write/set-killswitch.d.ts +34 -0
- package/dist/tools/write/set-killswitch.js +70 -0
- package/dist/tools/write/set-killswitch.js.map +1 -0
- package/package.json +72 -0
- package/scripts/install-claude-desktop.sh +72 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agenttrust_get_killswitch` — fetch the per-agent KillSwitchState plus
|
|
3
|
+
* the PolicyAuthority (multisig members + threshold) that gates pause
|
|
4
|
+
* mutations.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import type { Tool } from "../types";
|
|
8
|
+
declare const InputSchema: z.ZodObject<{
|
|
9
|
+
agent_asset: z.ZodEffects<z.ZodString, string, string>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
agent_asset: string;
|
|
12
|
+
}, {
|
|
13
|
+
agent_asset: string;
|
|
14
|
+
}>;
|
|
15
|
+
type Input = z.infer<typeof InputSchema>;
|
|
16
|
+
interface Output {
|
|
17
|
+
killSwitchPda: string;
|
|
18
|
+
killSwitchExplorer: string;
|
|
19
|
+
killSwitchExists: boolean;
|
|
20
|
+
killSwitch?: {
|
|
21
|
+
paused: boolean;
|
|
22
|
+
scopeKind: number;
|
|
23
|
+
scopeKeyHex: string;
|
|
24
|
+
pausedAtSlot: string;
|
|
25
|
+
unpausedAtSlot: string;
|
|
26
|
+
pausedBy: string | null;
|
|
27
|
+
};
|
|
28
|
+
authorityPda: string;
|
|
29
|
+
authorityExplorer: string;
|
|
30
|
+
authorityExists: boolean;
|
|
31
|
+
authority?: {
|
|
32
|
+
threshold: number;
|
|
33
|
+
memberCount: number;
|
|
34
|
+
members: (string | null)[];
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export declare const getKillswitchTool: Tool<Input, Output>;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `agenttrust_get_killswitch` — fetch the per-agent KillSwitchState plus
|
|
4
|
+
* the PolicyAuthority (multisig members + threshold) that gates pause
|
|
5
|
+
* mutations.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.getKillswitchTool = void 0;
|
|
9
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
10
|
+
const zod_1 = require("zod");
|
|
11
|
+
const chain_1 = require("../../chain");
|
|
12
|
+
const config_1 = require("../../config");
|
|
13
|
+
const common_1 = require("../common");
|
|
14
|
+
const InputSchema = zod_1.z.object({
|
|
15
|
+
agent_asset: common_1.PubkeySchema.describe("Quantu agent asset"),
|
|
16
|
+
});
|
|
17
|
+
const POLICY_AUTHORITY_PREFIX = Buffer.from("policy_authority");
|
|
18
|
+
exports.getKillswitchTool = {
|
|
19
|
+
name: "agenttrust_get_killswitch",
|
|
20
|
+
description: "Read the per-agent KillSwitchState (paused / unpaused, slot timestamps, " +
|
|
21
|
+
"who pressed it) and the PolicyAuthority that controls the multisig " +
|
|
22
|
+
"(members + threshold). Both PDAs are derived from the agent_asset.",
|
|
23
|
+
inputSchema: InputSchema,
|
|
24
|
+
async handler(input, ctx) {
|
|
25
|
+
const agent = (0, common_1.parsePubkey)(input.agent_asset, "agent_asset");
|
|
26
|
+
const policy = await ctx.chain.policyVault();
|
|
27
|
+
const ksPda = (0, chain_1.deriveKillSwitchPda)(ctx.chain.cfg.programs.policyVault, agent);
|
|
28
|
+
const authPda = web3_js_1.PublicKey.findProgramAddressSync([POLICY_AUTHORITY_PREFIX, agent.toBuffer()], ctx.chain.cfg.programs.policyVault)[0];
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
|
+
const ks = await policy.account.killSwitchState.fetchNullable(ksPda);
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
+
const auth = await policy.account.policyAuthority.fetchNullable(authPda);
|
|
33
|
+
const out = {
|
|
34
|
+
killSwitchPda: ksPda.toBase58(),
|
|
35
|
+
killSwitchExplorer: (0, config_1.explorerUrl)(ctx.chain.cfg, "address", ksPda.toBase58()),
|
|
36
|
+
killSwitchExists: !!ks,
|
|
37
|
+
authorityPda: authPda.toBase58(),
|
|
38
|
+
authorityExplorer: (0, config_1.explorerUrl)(ctx.chain.cfg, "address", authPda.toBase58()),
|
|
39
|
+
authorityExists: !!auth,
|
|
40
|
+
};
|
|
41
|
+
if (ks) {
|
|
42
|
+
out.killSwitch = {
|
|
43
|
+
paused: !!ks.paused,
|
|
44
|
+
scopeKind: Number(ks.scopeKind ?? 0),
|
|
45
|
+
scopeKeyHex: (0, common_1.bytesToHex)(ks.scopeKey ?? []),
|
|
46
|
+
pausedAtSlot: (0, common_1.toDecString)(ks.pausedAtSlot),
|
|
47
|
+
unpausedAtSlot: (0, common_1.toDecString)(ks.unpausedAtSlot),
|
|
48
|
+
pausedBy: (0, common_1.pubkeyOrNull)(ks.pausedBy),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
if (auth) {
|
|
52
|
+
const members = (auth.members ?? []).map(common_1.pubkeyOrNull);
|
|
53
|
+
const memberCount = Number(auth.memberCount ?? 0);
|
|
54
|
+
out.authority = {
|
|
55
|
+
threshold: Number(auth.threshold ?? 0),
|
|
56
|
+
memberCount,
|
|
57
|
+
members: members.slice(0, memberCount),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return out;
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=get-killswitch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-killswitch.js","sourceRoot":"","sources":["../../../src/tools/read/get-killswitch.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,6CAA4C;AAC5C,6BAAwB;AAExB,uCAAkD;AAClD,yCAA2C;AAC3C,sCAA6F;AAG7F,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,WAAW,EAAE,qBAAY,CAAC,QAAQ,CAAC,oBAAoB,CAAC;CACzD,CAAC,CAAC;AAGH,MAAM,uBAAuB,GAAG,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;AAwBnD,QAAA,iBAAiB,GAAwB;IACpD,IAAI,EAAS,2BAA2B;IACxC,WAAW,EACT,0EAA0E;QAC1E,qEAAqE;QACrE,oEAAoE;IACtE,WAAW,EAAE,WAAW;IAExB,KAAK,CAAC,OAAO,CAAC,KAAY,EAAE,GAAgB;QAC1C,MAAM,KAAK,GAAG,IAAA,oBAAW,EAAC,KAAK,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QAC5D,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;QAC7C,MAAM,KAAK,GAAG,IAAA,2BAAmB,EAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QAC7E,MAAM,OAAO,GAAG,mBAAS,CAAC,sBAAsB,CAC9C,CAAC,uBAAuB,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,EAC3C,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,CACnC,CAAC,CAAC,CAAC,CAAC;QAEL,8DAA8D;QAC9D,MAAM,EAAE,GAAU,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AC1E,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,CAAC,CAAC;YAClD,GAAG,CAAC,SAAS,GAAG;gBACd,SAAS,EAAI,MAAM,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC;gBACxC,WAAW;gBACX,OAAO,EAAM,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC;aAC3C,CAAC;QACJ,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agenttrust_get_policy` — fetch a single PolicyAccount and return its
|
|
3
|
+
* decoded fields (counters + bitmasks + tier thresholds).
|
|
4
|
+
*
|
|
5
|
+
* Reads the PolicyAccount PDA derived from `(agent_asset, policy_id)`.
|
|
6
|
+
* Returns `{ exists: false, pda }` if the account is not initialized,
|
|
7
|
+
* which is the common case for an agent that hasn't called `init_policy`.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
import type { Tool } from "../types";
|
|
11
|
+
declare const InputSchema: z.ZodObject<{
|
|
12
|
+
agent_asset: z.ZodEffects<z.ZodString, string, string>;
|
|
13
|
+
policy_id: z.ZodNumber;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
policy_id: number;
|
|
16
|
+
agent_asset: string;
|
|
17
|
+
}, {
|
|
18
|
+
policy_id: number;
|
|
19
|
+
agent_asset: string;
|
|
20
|
+
}>;
|
|
21
|
+
type Input = z.infer<typeof InputSchema>;
|
|
22
|
+
interface DecodedPolicy {
|
|
23
|
+
pda: string;
|
|
24
|
+
explorerUrl: string;
|
|
25
|
+
exists: boolean;
|
|
26
|
+
fields?: {
|
|
27
|
+
payerAgentAsset: string;
|
|
28
|
+
policyId: number;
|
|
29
|
+
enabledKindsBitmask: number;
|
|
30
|
+
gateMode: number;
|
|
31
|
+
spendingPerTxMax: string;
|
|
32
|
+
spendingDailyMax: string;
|
|
33
|
+
spendingWeeklyMax: string;
|
|
34
|
+
spendingTodayUsed: string;
|
|
35
|
+
spendingWeekUsed: string;
|
|
36
|
+
spendingTodayAnchor: string;
|
|
37
|
+
spendingWeekAnchor: string;
|
|
38
|
+
velocityWindowSecs: string;
|
|
39
|
+
velocityMaxInWindow: string;
|
|
40
|
+
velocityTier0DecayFactor: string;
|
|
41
|
+
minCounterpartyTier: number;
|
|
42
|
+
maxRiskScore: number;
|
|
43
|
+
minConfidence: number;
|
|
44
|
+
defaultUnratedTreatment: number;
|
|
45
|
+
requiredCapabilityHashHex: string;
|
|
46
|
+
acceptedAttestors: (string | null)[];
|
|
47
|
+
scopeKind: number;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export declare const getPolicyTool: Tool<Input, DecodedPolicy>;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `agenttrust_get_policy` — fetch a single PolicyAccount and return its
|
|
4
|
+
* decoded fields (counters + bitmasks + tier thresholds).
|
|
5
|
+
*
|
|
6
|
+
* Reads the PolicyAccount PDA derived from `(agent_asset, policy_id)`.
|
|
7
|
+
* Returns `{ exists: false, pda }` if the account is not initialized,
|
|
8
|
+
* which is the common case for an agent that hasn't called `init_policy`.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.getPolicyTool = void 0;
|
|
12
|
+
const zod_1 = require("zod");
|
|
13
|
+
const chain_1 = require("../../chain");
|
|
14
|
+
const config_1 = require("../../config");
|
|
15
|
+
const common_1 = require("../common");
|
|
16
|
+
const InputSchema = zod_1.z.object({
|
|
17
|
+
agent_asset: common_1.PubkeySchema.describe("Quantu agent asset pubkey (base58)"),
|
|
18
|
+
policy_id: zod_1.z.number().int().min(0).max(0xffffffff).describe("u32 per-agent policy ID"),
|
|
19
|
+
});
|
|
20
|
+
exports.getPolicyTool = {
|
|
21
|
+
name: "agenttrust_get_policy",
|
|
22
|
+
description: "Fetch the PolicyAccount on-chain for (agent_asset, policy_id). Returns " +
|
|
23
|
+
"decoded fields: spending caps, velocity window, counterparty-tier " +
|
|
24
|
+
"thresholds, RequireValidation capability hash, accepted attestors, and " +
|
|
25
|
+
"live counters (today/week spend used). exists=false when the policy has " +
|
|
26
|
+
"never been initialized.",
|
|
27
|
+
inputSchema: InputSchema,
|
|
28
|
+
async handler(input, ctx) {
|
|
29
|
+
const agent = (0, common_1.parsePubkey)(input.agent_asset, "agent_asset");
|
|
30
|
+
const pda = (0, chain_1.derivePolicyPda)(ctx.chain.cfg.programs.policyVault, agent, input.policy_id);
|
|
31
|
+
const policy = await ctx.chain.policyVault();
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
+
const data = await policy.account.policyAccount.fetchNullable(pda);
|
|
34
|
+
if (!data) {
|
|
35
|
+
return {
|
|
36
|
+
pda: pda.toBase58(),
|
|
37
|
+
explorerUrl: (0, config_1.explorerUrl)(ctx.chain.cfg, "address", pda.toBase58()),
|
|
38
|
+
exists: false,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
pda: pda.toBase58(),
|
|
43
|
+
explorerUrl: (0, config_1.explorerUrl)(ctx.chain.cfg, "address", pda.toBase58()),
|
|
44
|
+
exists: true,
|
|
45
|
+
fields: {
|
|
46
|
+
payerAgentAsset: (0, common_1.pubkeyOrNull)(data.payerAgentAsset) ?? "",
|
|
47
|
+
policyId: Number(data.policyId),
|
|
48
|
+
enabledKindsBitmask: Number(data.enabledKindsBitmask),
|
|
49
|
+
gateMode: Number(data.gateMode),
|
|
50
|
+
spendingPerTxMax: (0, common_1.toDecString)(data.spendingPerTxMax),
|
|
51
|
+
spendingDailyMax: (0, common_1.toDecString)(data.spendingDailyMax),
|
|
52
|
+
spendingWeeklyMax: (0, common_1.toDecString)(data.spendingWeeklyMax),
|
|
53
|
+
spendingTodayUsed: (0, common_1.toDecString)(data.spendingTodayUsed),
|
|
54
|
+
spendingWeekUsed: (0, common_1.toDecString)(data.spendingWeekUsed),
|
|
55
|
+
spendingTodayAnchor: (0, common_1.toDecString)(data.spendingTodayAnchor),
|
|
56
|
+
spendingWeekAnchor: (0, common_1.toDecString)(data.spendingWeekAnchor),
|
|
57
|
+
velocityWindowSecs: (0, common_1.toDecString)(data.velocityWindowSecs),
|
|
58
|
+
velocityMaxInWindow: (0, common_1.toDecString)(data.velocityMaxInWindow),
|
|
59
|
+
velocityTier0DecayFactor: (0, common_1.toDecString)(data.velocityTier0DecayFactor),
|
|
60
|
+
minCounterpartyTier: Number(data.minCounterpartyTier),
|
|
61
|
+
maxRiskScore: Number(data.maxRiskScore),
|
|
62
|
+
minConfidence: Number(data.minConfidence),
|
|
63
|
+
defaultUnratedTreatment: Number(data.defaultUnratedTreatment),
|
|
64
|
+
requiredCapabilityHashHex: (0, common_1.bytesToHex)(data.requiredCapabilityHash ?? []),
|
|
65
|
+
acceptedAttestors: (data.acceptedAttestors ?? []).map(common_1.pubkeyOrNull),
|
|
66
|
+
scopeKind: Number(data.scopeKind ?? 0),
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=get-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-policy.js","sourceRoot":"","sources":["../../../src/tools/read/get-policy.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,6BAAwB;AAExB,uCAA8C;AAC9C,yCAA2C;AAC3C,sCAA6F;AAG7F,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,WAAW,EAAE,qBAAY,CAAC,QAAQ,CAAC,oCAAoC,CAAC;IACxE,SAAS,EAAI,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC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,CAAC,CAAC,GAAG,CAAC,qBAAY,CAAC;gBAC3E,SAAS,EAAkB,MAAM,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC;aACvD;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agenttrust_get_quantu_reputation` — read the Quantu atom_stats PDA
|
|
3
|
+
* for an agent and surface the on-chain reputation tier + counts.
|
|
4
|
+
*
|
|
5
|
+
* Quantu's atom_stats account isn't in our IDL — we fetch raw account
|
|
6
|
+
* bytes and decode the byte-offset surface PolicyVault's AtomStats
|
|
7
|
+
* parser uses (`programs/policy-vault/src/ext/atom_stats.rs`). The
|
|
8
|
+
* exact offsets are pinned there; this tool mirrors them so what the
|
|
9
|
+
* gate sees is what the tool reports.
|
|
10
|
+
*/
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
import type { Tool } from "../types";
|
|
13
|
+
declare const InputSchema: z.ZodObject<{
|
|
14
|
+
agent_asset: z.ZodEffects<z.ZodString, string, string>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
agent_asset: string;
|
|
17
|
+
}, {
|
|
18
|
+
agent_asset: string;
|
|
19
|
+
}>;
|
|
20
|
+
type Input = z.infer<typeof InputSchema>;
|
|
21
|
+
interface Output {
|
|
22
|
+
pda: string;
|
|
23
|
+
explorerUrl: string;
|
|
24
|
+
exists: boolean;
|
|
25
|
+
/** Owner program — must equal Quantu atom_engine for the policy gate to honour it. */
|
|
26
|
+
ownerProgram: string | null;
|
|
27
|
+
ownerExpected: string;
|
|
28
|
+
ownerMatches: boolean;
|
|
29
|
+
reputation?: {
|
|
30
|
+
tier: number;
|
|
31
|
+
feedbackCount: string;
|
|
32
|
+
averageScore: number | null;
|
|
33
|
+
riskScore: number | null;
|
|
34
|
+
confidence: number | null;
|
|
35
|
+
};
|
|
36
|
+
rawByteLen: number;
|
|
37
|
+
}
|
|
38
|
+
export declare const getQuantuReputationTool: Tool<Input, Output>;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `agenttrust_get_quantu_reputation` — read the Quantu atom_stats PDA
|
|
4
|
+
* for an agent and surface the on-chain reputation tier + counts.
|
|
5
|
+
*
|
|
6
|
+
* Quantu's atom_stats account isn't in our IDL — we fetch raw account
|
|
7
|
+
* bytes and decode the byte-offset surface PolicyVault's AtomStats
|
|
8
|
+
* parser uses (`programs/policy-vault/src/ext/atom_stats.rs`). The
|
|
9
|
+
* exact offsets are pinned there; this tool mirrors them so what the
|
|
10
|
+
* gate sees is what the tool reports.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.getQuantuReputationTool = void 0;
|
|
14
|
+
const zod_1 = require("zod");
|
|
15
|
+
const chain_1 = require("../../chain");
|
|
16
|
+
const config_1 = require("../../config");
|
|
17
|
+
const common_1 = require("../common");
|
|
18
|
+
const InputSchema = zod_1.z.object({
|
|
19
|
+
agent_asset: common_1.PubkeySchema.describe("Quantu agent asset pubkey"),
|
|
20
|
+
});
|
|
21
|
+
// PolicyVault's AtomStats byte-offset surface (mirrors
|
|
22
|
+
// programs/policy-vault/src/ext/atom_stats.rs constants). We re-derive
|
|
23
|
+
// here rather than import to keep the MCP package free of the on-chain
|
|
24
|
+
// crate dep.
|
|
25
|
+
const AS_TIER_OFFSET = 8 + 32; // post-discriminator + asset
|
|
26
|
+
const AS_FEEDBACK_COUNT_OFFSET = AS_TIER_OFFSET + 1;
|
|
27
|
+
const AS_AVERAGE_SCORE_OFFSET = AS_FEEDBACK_COUNT_OFFSET + 8;
|
|
28
|
+
const AS_RISK_SCORE_OFFSET = AS_AVERAGE_SCORE_OFFSET + 1;
|
|
29
|
+
const AS_CONFIDENCE_OFFSET = AS_RISK_SCORE_OFFSET + 1;
|
|
30
|
+
exports.getQuantuReputationTool = {
|
|
31
|
+
name: "agenttrust_get_quantu_reputation",
|
|
32
|
+
description: "Read the Quantu atom_stats PDA for an agent and decode tier (0..3), " +
|
|
33
|
+
"feedback count, average score, risk score, and confidence. The same " +
|
|
34
|
+
"values PolicyVault's CounterpartyTier policy reads at gate time.",
|
|
35
|
+
inputSchema: InputSchema,
|
|
36
|
+
async handler(input, ctx) {
|
|
37
|
+
const agent = (0, common_1.parsePubkey)(input.agent_asset, "agent_asset");
|
|
38
|
+
const atomEngine = ctx.chain.cfg.quantu.atomEngine;
|
|
39
|
+
const pda = (0, chain_1.deriveAtomStatsPda)(ctx.chain.cfg.quantu, agent);
|
|
40
|
+
const accountInfo = await ctx.chain.connection.getAccountInfo(pda, "confirmed");
|
|
41
|
+
const out = {
|
|
42
|
+
pda: pda.toBase58(),
|
|
43
|
+
explorerUrl: (0, config_1.explorerUrl)(ctx.chain.cfg, "address", pda.toBase58()),
|
|
44
|
+
exists: !!accountInfo,
|
|
45
|
+
ownerProgram: accountInfo?.owner.toBase58() ?? null,
|
|
46
|
+
ownerExpected: atomEngine.toBase58(),
|
|
47
|
+
ownerMatches: accountInfo ? accountInfo.owner.equals(atomEngine) : false,
|
|
48
|
+
rawByteLen: accountInfo?.data.length ?? 0,
|
|
49
|
+
};
|
|
50
|
+
if (!accountInfo)
|
|
51
|
+
return out;
|
|
52
|
+
const data = accountInfo.data;
|
|
53
|
+
if (data.length < AS_CONFIDENCE_OFFSET + 2)
|
|
54
|
+
return out;
|
|
55
|
+
out.reputation = {
|
|
56
|
+
tier: data.readUInt8(AS_TIER_OFFSET),
|
|
57
|
+
feedbackCount: (0, common_1.toDecString)(data.readBigUInt64LE(AS_FEEDBACK_COUNT_OFFSET)),
|
|
58
|
+
averageScore: data.readUInt8(AS_AVERAGE_SCORE_OFFSET),
|
|
59
|
+
riskScore: data.readUInt8(AS_RISK_SCORE_OFFSET),
|
|
60
|
+
confidence: data.readUInt16LE(AS_CONFIDENCE_OFFSET),
|
|
61
|
+
};
|
|
62
|
+
return out;
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=get-quantu-reputation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-quantu-reputation.js","sourceRoot":"","sources":["../../../src/tools/read/get-quantu-reputation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,6BAAwB;AAExB,uCAAiD;AACjD,yCAA2C;AAC3C,sCAAmE;AAGnE,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,WAAW,EAAE,qBAAY,CAAC,QAAQ,CAAC,2BAA2B,CAAC;CAChE,CAAC,CAAC;AAqBH,uDAAuD;AACvD,uEAAuE;AACvE,uEAAuE;AACvE,aAAa;AACb,MAAM,cAAc,GAAc,CAAC,GAAG,EAAE,CAAC,CAAO,6BAA6B;AAC7E,MAAM,wBAAwB,GAAI,cAAc,GAAG,CAAC,CAAC;AACrD,MAAM,uBAAuB,GAAK,wBAAwB,GAAG,CAAC,CAAC;AAC/D,MAAM,oBAAoB,GAAQ,uBAAuB,GAAG,CAAC,CAAC;AAC9D,MAAM,oBAAoB,GAAQ,oBAAoB,GAAG,CAAC,CAAC;AAE9C,QAAA,uBAAuB,GAAwB;IAC1D,IAAI,EAAS,kCAAkC;IAC/C,WAAW,EACT,sEAAsE;QACtE,sEAAsE;QACtE,kEAAkE;IACpE,WAAW,EAAE,WAAW;IAExB,KAAK,CAAC,OAAO,CAAC,KAAY,EAAE,GAAgB;QAC1C,MAAM,KAAK,GAAS,IAAA,oBAAW,EAAC,KAAK,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QAClE,MAAM,UAAU,GAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC;QACpD,MAAM,GAAG,GAAW,IAAA,0BAAkB,EAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACpE,MAAM,WAAW,GAAG,MAAM,G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agenttrust_get_validation_attestation` — query the ValidationRegistry
|
|
3
|
+
* for an attestation matching `(subject_asset, capability_hash)`.
|
|
4
|
+
*
|
|
5
|
+
* ValidationAttestation PDAs are keyed by (subject, capability, attestor),
|
|
6
|
+
* so a (subject, capability) pair may have 0..N attestations from
|
|
7
|
+
* different attestors. We list every match via getProgramAccounts +
|
|
8
|
+
* memcmp filters at offsets 8 and 40 (the layout pinned in
|
|
9
|
+
* `state/validation_attestation.rs`).
|
|
10
|
+
*/
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
import type { Tool } from "../types";
|
|
13
|
+
declare const InputSchema: z.ZodObject<{
|
|
14
|
+
subject_asset: z.ZodEffects<z.ZodString, string, string>;
|
|
15
|
+
capability_hash: z.ZodEffects<z.ZodString, string, string>;
|
|
16
|
+
attestor: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
subject_asset: string;
|
|
19
|
+
capability_hash: string;
|
|
20
|
+
attestor?: string | undefined;
|
|
21
|
+
}, {
|
|
22
|
+
subject_asset: string;
|
|
23
|
+
capability_hash: string;
|
|
24
|
+
attestor?: string | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
type Input = z.infer<typeof InputSchema>;
|
|
27
|
+
interface AttestationRow {
|
|
28
|
+
pda: string;
|
|
29
|
+
explorerUrl: string;
|
|
30
|
+
attestor: string;
|
|
31
|
+
expiresAt: string;
|
|
32
|
+
issuedAt: string;
|
|
33
|
+
revoked: boolean;
|
|
34
|
+
revokedAt: string;
|
|
35
|
+
claimPayloadHashHex: string;
|
|
36
|
+
claimUriHashHex: string;
|
|
37
|
+
}
|
|
38
|
+
interface Output {
|
|
39
|
+
subjectAsset: string;
|
|
40
|
+
capabilityHashHex: string;
|
|
41
|
+
count: number;
|
|
42
|
+
attestations: AttestationRow[];
|
|
43
|
+
}
|
|
44
|
+
export declare const getValidationAttestationTool: Tool<Input, Output>;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `agenttrust_get_validation_attestation` — query the ValidationRegistry
|
|
4
|
+
* for an attestation matching `(subject_asset, capability_hash)`.
|
|
5
|
+
*
|
|
6
|
+
* ValidationAttestation PDAs are keyed by (subject, capability, attestor),
|
|
7
|
+
* so a (subject, capability) pair may have 0..N attestations from
|
|
8
|
+
* different attestors. We list every match via getProgramAccounts +
|
|
9
|
+
* memcmp filters at offsets 8 and 40 (the layout pinned in
|
|
10
|
+
* `state/validation_attestation.rs`).
|
|
11
|
+
*/
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.getValidationAttestationTool = void 0;
|
|
17
|
+
const bs58_1 = __importDefault(require("bs58"));
|
|
18
|
+
const zod_1 = require("zod");
|
|
19
|
+
const config_1 = require("../../config");
|
|
20
|
+
const common_1 = require("../common");
|
|
21
|
+
const InputSchema = zod_1.z.object({
|
|
22
|
+
subject_asset: common_1.PubkeySchema.describe("Quantu agent asset whose capability is being attested"),
|
|
23
|
+
capability_hash: common_1.HexHashSchema.describe("32-byte capability hash (hex)"),
|
|
24
|
+
attestor: common_1.PubkeySchema.optional()
|
|
25
|
+
.describe("Optional: filter to this attestor's attestation (returns 0 or 1)"),
|
|
26
|
+
});
|
|
27
|
+
// state/validation_attestation.rs layout — pinned offsets.
|
|
28
|
+
const VA_SUBJECT_OFFSET = 8; // off 8..40
|
|
29
|
+
const VA_CAPABILITY_OFFSET = 40; // off 40..72
|
|
30
|
+
const VA_ATTESTOR_OFFSET = 72; // off 72..104
|
|
31
|
+
exports.getValidationAttestationTool = {
|
|
32
|
+
name: "agenttrust_get_validation_attestation",
|
|
33
|
+
description: "Query the ValidationRegistry for ValidationAttestation PDAs matching " +
|
|
34
|
+
"(subject_asset, capability_hash). Each attestor produces a separate " +
|
|
35
|
+
"attestation; the optional `attestor` filter narrows to one. Returns " +
|
|
36
|
+
"expiresAt slot, revoked flag, claim payload hash — exactly the fields " +
|
|
37
|
+
"PolicyVault's RequireValidation policy reads at gate time.",
|
|
38
|
+
inputSchema: InputSchema,
|
|
39
|
+
async handler(input, ctx) {
|
|
40
|
+
const subject = (0, common_1.parsePubkey)(input.subject_asset, "subject_asset");
|
|
41
|
+
const capHash = (0, common_1.hexToBytes)(input.capability_hash);
|
|
42
|
+
if (capHash.length !== 32)
|
|
43
|
+
throw new Error("capability_hash must decode to 32 bytes");
|
|
44
|
+
const program = await ctx.chain.validationRegistry();
|
|
45
|
+
const filters = [
|
|
46
|
+
{ memcmp: { offset: VA_SUBJECT_OFFSET, bytes: subject.toBase58() } },
|
|
47
|
+
{ memcmp: { offset: VA_CAPABILITY_OFFSET, bytes: bs58_1.default.encode(capHash) } },
|
|
48
|
+
];
|
|
49
|
+
if (input.attestor) {
|
|
50
|
+
const attestor = (0, common_1.parsePubkey)(input.attestor, "attestor");
|
|
51
|
+
filters.push({ memcmp: { offset: VA_ATTESTOR_OFFSET, bytes: attestor.toBase58() } });
|
|
52
|
+
}
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
const accounts = await program.account.validationAttestation.all(filters);
|
|
55
|
+
const attestations = accounts.map(
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
+
(entry) => ({
|
|
58
|
+
pda: entry.publicKey.toBase58(),
|
|
59
|
+
explorerUrl: (0, config_1.explorerUrl)(ctx.chain.cfg, "address", entry.publicKey.toBase58()),
|
|
60
|
+
attestor: (0, common_1.pubkeyOrNull)(entry.account.attestor) ?? "",
|
|
61
|
+
expiresAt: (0, common_1.toDecString)(entry.account.expiresAt),
|
|
62
|
+
issuedAt: (0, common_1.toDecString)(entry.account.issuedAt),
|
|
63
|
+
revoked: !!entry.account.revoked,
|
|
64
|
+
revokedAt: (0, common_1.toDecString)(entry.account.revokedAt),
|
|
65
|
+
claimPayloadHashHex: (0, common_1.bytesToHex)(entry.account.claimPayloadHash ?? []),
|
|
66
|
+
claimUriHashHex: (0, common_1.bytesToHex)(entry.account.claimUriHash ?? []),
|
|
67
|
+
}));
|
|
68
|
+
return {
|
|
69
|
+
subjectAsset: subject.toBase58(),
|
|
70
|
+
capabilityHashHex: (0, common_1.bytesToHex)(capHash),
|
|
71
|
+
count: attestations.length,
|
|
72
|
+
attestations,
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=get-validation-attestation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-validation-attestation.js","sourceRoot":"","sources":["../../../src/tools/read/get-validation-attestation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;AAEH,gDAAwB;AACxB,6BAAwB;AAExB,yCAA2C;AAC3C,sCAAwH;AAGxH,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,aAAa,EAAK,qBAAY,CAAC,QAAQ,CAAC,uDAAuD,CAAC;IAChG,eAAe,EAAG,sBAAa,CAAC,QAAQ,CAAC,+BAA+B,CAAC;IACzE,QAAQ,EAAU,qBAAY,CAAC,QAAQ,EAAE;SACnB,QAAQ,CAAC,kEAAkE,CAAC;CACnG,CAAC,CAAC;AAsBH,2DAA2D;AAC3D,MAAM,iBAAiB,GAAM,CAAC,CAAC,CAAO,aAAa;AACnD,MAAM,oBAAoB,GAAG,EAAE,CAAC,CAAM,aAAa;AACnD,MAAM,kBAAkB,GAAK,EAAE,CAAC,CAAM,cAAc;AAEvC,QAAA,4BAA4B,GAAwB;IAC/D,IAAI,EAAS,uCAAuC;IACpD,WAAW,EACT,uEAAuE;QACvE,sEAAsE;QACtE,sEAAsE;QACtE,wEAAwE;QACxE,4DAA4D;IAC9D,WAAW,EAAE,WAAW;IAExB,KAAK,CAAC,OAAO,CA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,GAAG,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;YACtF,QAAQ,EAAa,IAAA,qBAAY,EAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE;YAC/D,SAAS,EAAY,IAAA,oBAAW,EAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;YACzD,QAAQ,EAAa,IAAA,oBAAW,EAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;YACxD,OAAO,EAAc,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO;YAC5C,SAAS,EAAY,IAAA,oBAAW,EAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;YACzD,mBAAmB,EAAE,IAAA,mBAAU,EAAC,KAAK,CAAC,OAAO,CAAC,gBAAgB,IAAI,EAAE,CAAC;YACrE,eAAe,EAAM,IAAA,mBAAU,EAAC,KAAK,CAAC,OAAO,CAAC,YAAY,IAAI,EAAE,CAAC;SAClE,CAAC,CACH,CAAC;QAEF,OAAO;YACL,YAAY,EAAO,OAAO,CAAC,QAAQ,EAAE;YACrC,iBAAiB,EAAE,IAAA,mBAAU,EAAC,OAAO,CAAC;YACtC,KAAK,EAAc,YAAY,CAAC,MAAM;YACtC,YAAY;SACb,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agenttrust_get_velocity` — fetch the VelocityLedger PDA for
|
|
3
|
+
* (agent, policy_id). Returns the current sliding-window cumulative
|
|
4
|
+
* spend, last commit slot, and window start slot.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import type { Tool } from "../types";
|
|
8
|
+
declare const InputSchema: z.ZodObject<{
|
|
9
|
+
agent_asset: z.ZodEffects<z.ZodString, string, string>;
|
|
10
|
+
policy_id: z.ZodNumber;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
policy_id: number;
|
|
13
|
+
agent_asset: string;
|
|
14
|
+
}, {
|
|
15
|
+
policy_id: number;
|
|
16
|
+
agent_asset: string;
|
|
17
|
+
}>;
|
|
18
|
+
type Input = z.infer<typeof InputSchema>;
|
|
19
|
+
interface Output {
|
|
20
|
+
pda: string;
|
|
21
|
+
explorerUrl: string;
|
|
22
|
+
exists: boolean;
|
|
23
|
+
ledger?: {
|
|
24
|
+
cumulativeAmount: string;
|
|
25
|
+
lastCommitSlot: string;
|
|
26
|
+
windowStartSlot: string;
|
|
27
|
+
policyId: number;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export declare const getVelocityTool: Tool<Input, Output>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `agenttrust_get_velocity` — fetch the VelocityLedger PDA for
|
|
4
|
+
* (agent, policy_id). Returns the current sliding-window cumulative
|
|
5
|
+
* spend, last commit slot, and window start slot.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.getVelocityTool = void 0;
|
|
9
|
+
const zod_1 = require("zod");
|
|
10
|
+
const chain_1 = require("../../chain");
|
|
11
|
+
const config_1 = require("../../config");
|
|
12
|
+
const common_1 = require("../common");
|
|
13
|
+
const InputSchema = zod_1.z.object({
|
|
14
|
+
agent_asset: common_1.PubkeySchema.describe("Quantu agent asset"),
|
|
15
|
+
policy_id: zod_1.z.number().int().min(0).max(0xffffffff).describe("u32 policy ID"),
|
|
16
|
+
});
|
|
17
|
+
exports.getVelocityTool = {
|
|
18
|
+
name: "agenttrust_get_velocity",
|
|
19
|
+
description: "Fetch the VelocityLedger PDA for (agent, policy_id). Returns the " +
|
|
20
|
+
"cumulative-spend counter, last commit slot, and the slot the current " +
|
|
21
|
+
"window opened. Compare against the policy's velocity_max_in_window to " +
|
|
22
|
+
"see how much budget remains in the window.",
|
|
23
|
+
inputSchema: InputSchema,
|
|
24
|
+
async handler(input, ctx) {
|
|
25
|
+
const agent = (0, common_1.parsePubkey)(input.agent_asset, "agent_asset");
|
|
26
|
+
const pda = (0, chain_1.deriveVelocityPda)(ctx.chain.cfg.programs.policyVault, agent, input.policy_id);
|
|
27
|
+
const policy = await ctx.chain.policyVault();
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
+
const data = await policy.account.velocityLedger.fetchNullable(pda);
|
|
30
|
+
if (!data) {
|
|
31
|
+
return {
|
|
32
|
+
pda: pda.toBase58(),
|
|
33
|
+
explorerUrl: (0, config_1.explorerUrl)(ctx.chain.cfg, "address", pda.toBase58()),
|
|
34
|
+
exists: false,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
pda: pda.toBase58(),
|
|
39
|
+
explorerUrl: (0, config_1.explorerUrl)(ctx.chain.cfg, "address", pda.toBase58()),
|
|
40
|
+
exists: true,
|
|
41
|
+
ledger: {
|
|
42
|
+
cumulativeAmount: (0, common_1.toDecString)(data.cumulativeAmount),
|
|
43
|
+
lastCommitSlot: (0, common_1.toDecString)(data.lastCommitSlot),
|
|
44
|
+
windowStartSlot: (0, common_1.toDecString)(data.windowStartSlot),
|
|
45
|
+
policyId: Number(data.policyId ?? input.policy_id),
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=get-velocity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-velocity.js","sourceRoot":"","sources":["../../../src/tools/read/get-velocity.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,6BAAwB;AAExB,uCAAgD;AAChD,yCAA2C;AAC3C,sCAAmE;AAGnE,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,WAAW,EAAE,qBAAY,CAAC,QAAQ,CAAC,oBAAoB,CAAC;IACxD,SAAS,EAAI,OAAC,CAAC,MAAM,EAA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gB,EAAE,IAAA,oBAAW,EAAC,IAAI,CAAC,gBAAgB,CAAC;gBACpD,cAAc,EAAI,IAAA,oBAAW,EAAC,IAAI,CAAC,cAAc,CAAC;gBAClD,eAAe,EAAG,IAAA,oBAAW,EAAC,IAAI,CAAC,eAAe,CAAC;gBACnD,QAAQ,EAAU,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,SAAS,CAAC;aAC3D;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agenttrust_list_facilitators` — return the active facilitator
|
|
3
|
+
* adapter registry as a static manifest. Mirrors the four adapters
|
|
4
|
+
* shipped in `trustgate/server/src/facilitators/`: Pay.sh (live),
|
|
5
|
+
* Dexter / atxp / MCPay.
|
|
6
|
+
*
|
|
7
|
+
* Manifest is a static module-local constant. The MCP server doesn't
|
|
8
|
+
* boot the Express service, so dynamically introspecting a live
|
|
9
|
+
* `FacilitatorRegistry` would require an extra dependency the SDK
|
|
10
|
+
* doesn't expose. Per the registry/dispatch shape in
|
|
11
|
+
* `trustgate/server/src/facilitators/index.ts`, the four adapters and
|
|
12
|
+
* their protocols/status are pinned values that stay in sync with that
|
|
13
|
+
* file by review.
|
|
14
|
+
*/
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
import type { Tool } from "../types";
|
|
17
|
+
declare const InputSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
18
|
+
type Input = z.infer<typeof InputSchema>;
|
|
19
|
+
interface FacilitatorEntry {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
protocols: string[];
|
|
23
|
+
status: "live" | "in-flight" | "roadmap";
|
|
24
|
+
docsPath: string;
|
|
25
|
+
}
|
|
26
|
+
interface Output {
|
|
27
|
+
count: number;
|
|
28
|
+
facilitators: FacilitatorEntry[];
|
|
29
|
+
}
|
|
30
|
+
export declare const listFacilitatorsTool: Tool<Input, Output>;
|
|
31
|
+
export {};
|