@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,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `agenttrust_explain_decision` — translate a numeric reason code into
|
|
4
|
+
* its enum name plus a one-paragraph remediation hint.
|
|
5
|
+
*
|
|
6
|
+
* Authoritative mapping comes from the SDK's `denyReasonName` (which
|
|
7
|
+
* mirrors `programs/policy-vault/src/state/decision.rs`). The hints
|
|
8
|
+
* here are MCP-specific guidance text — they describe what a developer
|
|
9
|
+
* or operator should do next when they see the code.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.explainDecisionTool = void 0;
|
|
13
|
+
const zod_1 = require("zod");
|
|
14
|
+
const trustgate_1 = require("@agenttrust-sdk/trustgate");
|
|
15
|
+
const InputSchema = zod_1.z.object({
|
|
16
|
+
reason_code: zod_1.z.number().int().min(1).max(15).describe("DenyReason stable code (1..15)"),
|
|
17
|
+
});
|
|
18
|
+
const REMEDIATION = {
|
|
19
|
+
1: {
|
|
20
|
+
category: "killswitch",
|
|
21
|
+
oneLiner: "The agent's per-agent KillSwitchState is paused.",
|
|
22
|
+
remediation: "Read the kill-switch with agenttrust_get_killswitch to see who paused " +
|
|
23
|
+
"it and when. Resume by calling agenttrust_set_killswitch(paused=false) " +
|
|
24
|
+
"as a member of the agent's PolicyAuthority that satisfies threshold.",
|
|
25
|
+
},
|
|
26
|
+
2: {
|
|
27
|
+
category: "spending",
|
|
28
|
+
oneLiner: "amount > policy.spending_per_tx_max for this single tx.",
|
|
29
|
+
remediation: "Either lower the tx amount or raise the policy's per_tx_max via a new " +
|
|
30
|
+
"init_policy under a different policy_id (current policies are not " +
|
|
31
|
+
"mutable post-init in v1).",
|
|
32
|
+
},
|
|
33
|
+
3: {
|
|
34
|
+
category: "spending",
|
|
35
|
+
oneLiner: "spending_today_used + amount would exceed spending_daily_max.",
|
|
36
|
+
remediation: "Wait for the day-anchor to advance (24h since spending_today_anchor), " +
|
|
37
|
+
"or increase the policy's daily cap via a new init_policy.",
|
|
38
|
+
},
|
|
39
|
+
4: {
|
|
40
|
+
category: "spending",
|
|
41
|
+
oneLiner: "spending_week_used + amount would exceed spending_weekly_max.",
|
|
42
|
+
remediation: "Wait for the week-anchor to roll (next Monday since 1970-01-05) or " +
|
|
43
|
+
"raise the weekly cap on a fresh policy.",
|
|
44
|
+
},
|
|
45
|
+
5: {
|
|
46
|
+
category: "velocity",
|
|
47
|
+
oneLiner: "The cumulative velocity-window total + amount exceeds the limit.",
|
|
48
|
+
remediation: "Read agenttrust_get_velocity to see window_start_slot and " +
|
|
49
|
+
"cumulative_amount. The window resets after window_secs slots elapse " +
|
|
50
|
+
"from window_start_slot.",
|
|
51
|
+
},
|
|
52
|
+
6: {
|
|
53
|
+
category: "counterparty",
|
|
54
|
+
oneLiner: "Payee tier is below policy.min_counterparty_tier.",
|
|
55
|
+
remediation: "Use agenttrust_get_quantu_reputation to confirm the payee's tier. " +
|
|
56
|
+
"Either pick a higher-tier counterparty (the demo's tier-3 pre-warm " +
|
|
57
|
+
"is the canonical happy-path) or relax min_counterparty_tier in a " +
|
|
58
|
+
"new policy.",
|
|
59
|
+
},
|
|
60
|
+
7: {
|
|
61
|
+
category: "counterparty",
|
|
62
|
+
oneLiner: "Payee risk_score is above policy.max_risk_score.",
|
|
63
|
+
remediation: "Inspect the Quantu atom_stats risk_score. Lower-risk counterparties " +
|
|
64
|
+
"or a more permissive max_risk_score in policy fix this.",
|
|
65
|
+
},
|
|
66
|
+
8: {
|
|
67
|
+
category: "counterparty",
|
|
68
|
+
oneLiner: "Payee confidence is below policy.min_confidence basis points.",
|
|
69
|
+
remediation: "Confidence climbs as the agent accrues feedback. Either accept lower " +
|
|
70
|
+
"confidence in policy or wait for the agent's history to mature.",
|
|
71
|
+
},
|
|
72
|
+
9: {
|
|
73
|
+
category: "atom",
|
|
74
|
+
oneLiner: "atom_stats account is owned by the wrong program.",
|
|
75
|
+
remediation: "Verify NETWORK and Quantu program IDs are correct. agenttrust_get_quantu_reputation " +
|
|
76
|
+
"returns ownerProgram + ownerExpected so you can confirm.",
|
|
77
|
+
},
|
|
78
|
+
10: {
|
|
79
|
+
category: "atom",
|
|
80
|
+
oneLiner: "atom_stats schema version does not match what the policy expects.",
|
|
81
|
+
remediation: "Quantu rolled a schema; either update the AgentTrust deployment's " +
|
|
82
|
+
"expected schema version or wait for the policy to be re-deployed.",
|
|
83
|
+
},
|
|
84
|
+
11: {
|
|
85
|
+
category: "validation",
|
|
86
|
+
oneLiner: "No ValidationAttestation matches required_capability_hash.",
|
|
87
|
+
remediation: "Have an attestor call agenttrust_respond_to_validation for the same " +
|
|
88
|
+
"(subject_asset, capability_name) pair. agenttrust_get_validation_attestation " +
|
|
89
|
+
"confirms the attestation lands.",
|
|
90
|
+
},
|
|
91
|
+
12: {
|
|
92
|
+
category: "validation",
|
|
93
|
+
oneLiner: "Matching attestation exists but expires_at slot has passed.",
|
|
94
|
+
remediation: "Re-attest. Each respond_to_validation call writes a fresh expires_at; " +
|
|
95
|
+
"the policy reads the most-recent one keyed by attestor.",
|
|
96
|
+
},
|
|
97
|
+
13: {
|
|
98
|
+
category: "validation",
|
|
99
|
+
oneLiner: "Matching attestation has been revoked by the attestor.",
|
|
100
|
+
remediation: "Either pick a different accepted attestor in policy.validation.accepted_attestors " +
|
|
101
|
+
"or have the attestor re-attest after addressing the revocation reason.",
|
|
102
|
+
},
|
|
103
|
+
14: {
|
|
104
|
+
category: "validation",
|
|
105
|
+
oneLiner: "Attestation exists but the attestor is not in the policy's accepted set.",
|
|
106
|
+
remediation: "Update policy.validation.accepted_attestors to include the attestor, " +
|
|
107
|
+
"or set it to all-zero (permissionless mode).",
|
|
108
|
+
},
|
|
109
|
+
15: {
|
|
110
|
+
category: "counterparty",
|
|
111
|
+
oneLiner: "Agent has no Quantu reputation yet, and policy default_unrated_treatment is Deny.",
|
|
112
|
+
remediation: "Switch policy.counterparty.default_unrated_treatment to UNRATED_ALLOW (0) " +
|
|
113
|
+
"or UNRATED_REQUIRE_VALIDATION (2), or wait for the agent to receive " +
|
|
114
|
+
"its first feedback.",
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
exports.explainDecisionTool = {
|
|
118
|
+
name: "agenttrust_explain_decision",
|
|
119
|
+
description: "Return the human-readable enum name and a remediation hint for a " +
|
|
120
|
+
"PolicyVault GateDecision::Deny reason code (1..15). Useful when a " +
|
|
121
|
+
"facilitator returns a 402 with X-Payment-Reason-Code and the caller " +
|
|
122
|
+
"needs to know what to fix.",
|
|
123
|
+
inputSchema: InputSchema,
|
|
124
|
+
async handler(input) {
|
|
125
|
+
const r = REMEDIATION[input.reason_code];
|
|
126
|
+
if (!r) {
|
|
127
|
+
return {
|
|
128
|
+
reasonCode: input.reason_code,
|
|
129
|
+
reasonName: (0, trustgate_1.denyReasonName)(input.reason_code),
|
|
130
|
+
category: "killswitch",
|
|
131
|
+
oneLiner: "Unknown reason code.",
|
|
132
|
+
remediation: "No remediation registered for this code; check the SDK's denyReasonName.",
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
reasonCode: input.reason_code,
|
|
137
|
+
reasonName: (0, trustgate_1.denyReasonName)(input.reason_code),
|
|
138
|
+
category: r.category,
|
|
139
|
+
oneLiner: r.oneLiner,
|
|
140
|
+
remediation: r.remediation,
|
|
141
|
+
};
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
//# sourceMappingURL=explain-decision.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explain-decision.js","sourceRoot":"","sources":["../../../src/tools/discovery/explain-decision.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,6BAAwB;AAGxB,yDAA2D;AAE3D,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,gCAAgC,CAAC;CACxF,CAAC,CAAC;AAWH,MAAM,WAAW,GAA4F;IAC3G,CAAC,EAAE;QACD,QAAQ,EAAE,YAAY;QACtB,QAAQ,EAAE,kDAAkD;QAC5D,WAAW,EACT,wEAAwE;YACxE,yEAAyE;YACzE,sEAAsE;KACzE;IACD,CAAC,EAAE;QACD,QAAQ,EAAE,UAAU;QACpB,QAAQ,EAAE,yDAAyD;QACnE,WAAW,EACT,wEAAwE;YACxE,oEAAoE;YACpE,2BAA2B;KAC9B;IACD,CAAC,EAAE;QACD,QAAQ,EAAE,UAAU;QACpB,QAAQ,EAAE,+DAA+D;QACzE,WAAW,EACT,wEAAwE;YACxE,2DAA2D;KAC9D;IACD,CAAC,EAAE;QACD,QAAQ,EAAE,UAAU;QACpB,QAAQ,EAAE,+DAA+D;QACzE,WAAW,EACT,qEAAqE;YACrE,yCAAyC;KAC5C;IACD,CAAC,EAAE;QACD,QAAQ,EAAE,UAAU;QACpB,QAAQ,EAAE,kEAAkE;QAC5E,WAAW,EACT,4DAA4D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tE,qBAAqB;KACxB;CACF,CAAC;AAEW,QAAA,mBAAmB,GAAwB;IACtD,IAAI,EAAS,6BAA6B;IAC1C,WAAW,EACT,mEAAmE;QACnE,oEAAoE;QACpE,sEAAsE;QACtE,4BAA4B;IAC9B,WAAW,EAAE,WAAW;IAExB,KAAK,CAAC,OAAO,CAAC,KAAY;QACxB,MAAM,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACzC,IAAI,CAAC,CAAC,EAAE,CAAC;YACP,OAAO;gBACL,UAAU,EAAG,KAAK,CAAC,WAAW;gBAC9B,UAAU,EAAG,IAAA,0BAAc,EAAC,KAAK,CAAC,WAAW,CAAC;gBAC9C,QAAQ,EAAK,YAAY;gBACzB,QAAQ,EAAK,sBAAsB;gBACnC,WAAW,EAAE,0EAA0E;aACxF,CAAC;QACJ,CAAC;QACD,OAAO;YACL,UAAU,EAAG,KAAK,CAAC,WAAW;YAC9B,UAAU,EAAG,IAAA,0BAAc,EAAC,KAAK,CAAC,WAAW,CAAC;YAC9C,QAAQ,EAAK,CAAC,CAAC,QAAQ;YACvB,QAAQ,EAAK,CAAC,CAAC,QAAQ;YACvB,WAAW,EAAE,CAAC,CAAC,WAAW;SAC3B,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agenttrust_facilitator_walkthrough` — return the per-adapter
|
|
3
|
+
* walkthrough doc, falling back to the generic adapters guide if the
|
|
4
|
+
* name isn't recognised.
|
|
5
|
+
*
|
|
6
|
+
* Mapping is static and matches the four adapters shipped in
|
|
7
|
+
* `trustgate/server/src/facilitators/`. Unknown names get the generic
|
|
8
|
+
* facilitators-adapters MDX and an explicit note that the requested
|
|
9
|
+
* name has no dedicated walkthrough.
|
|
10
|
+
*/
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
import type { Tool } from "../types";
|
|
13
|
+
declare const InputSchema: z.ZodObject<{
|
|
14
|
+
name: z.ZodString;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
name: string;
|
|
17
|
+
}, {
|
|
18
|
+
name: string;
|
|
19
|
+
}>;
|
|
20
|
+
type Input = z.infer<typeof InputSchema>;
|
|
21
|
+
interface Output {
|
|
22
|
+
name: string;
|
|
23
|
+
matched: boolean;
|
|
24
|
+
source: string;
|
|
25
|
+
content: string;
|
|
26
|
+
fallback?: string;
|
|
27
|
+
servicesReadme?: string;
|
|
28
|
+
}
|
|
29
|
+
export declare const facilitatorWalkthroughTool: Tool<Input, Output>;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `agenttrust_facilitator_walkthrough` — return the per-adapter
|
|
4
|
+
* walkthrough doc, falling back to the generic adapters guide if the
|
|
5
|
+
* name isn't recognised.
|
|
6
|
+
*
|
|
7
|
+
* Mapping is static and matches the four adapters shipped in
|
|
8
|
+
* `trustgate/server/src/facilitators/`. Unknown names get the generic
|
|
9
|
+
* facilitators-adapters MDX and an explicit note that the requested
|
|
10
|
+
* name has no dedicated walkthrough.
|
|
11
|
+
*/
|
|
12
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
16
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}) : (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
o[k2] = m[k];
|
|
22
|
+
}));
|
|
23
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
24
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
25
|
+
}) : function(o, v) {
|
|
26
|
+
o["default"] = v;
|
|
27
|
+
});
|
|
28
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
29
|
+
var ownKeys = function(o) {
|
|
30
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
31
|
+
var ar = [];
|
|
32
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
33
|
+
return ar;
|
|
34
|
+
};
|
|
35
|
+
return ownKeys(o);
|
|
36
|
+
};
|
|
37
|
+
return function (mod) {
|
|
38
|
+
if (mod && mod.__esModule) return mod;
|
|
39
|
+
var result = {};
|
|
40
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
41
|
+
__setModuleDefault(result, mod);
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.facilitatorWalkthroughTool = void 0;
|
|
47
|
+
const fs = __importStar(require("fs"));
|
|
48
|
+
const path = __importStar(require("path"));
|
|
49
|
+
const zod_1 = require("zod");
|
|
50
|
+
const InputSchema = zod_1.z.object({
|
|
51
|
+
name: zod_1.z.string().min(1).describe("Adapter name (pay-sh / dexter / atxp / mcpay) or any registered facilitator"),
|
|
52
|
+
});
|
|
53
|
+
const ADAPTER_DOCS = {
|
|
54
|
+
"pay-sh": "integration-guides/pay-sh-adapter.mdx",
|
|
55
|
+
"paysh": "integration-guides/pay-sh-adapter.mdx",
|
|
56
|
+
"pay.sh": "integration-guides/pay-sh-adapter.mdx",
|
|
57
|
+
"dexter": "integration-guides/facilitator-adapters.mdx",
|
|
58
|
+
"atxp": "integration-guides/facilitator-adapters.mdx",
|
|
59
|
+
"atxp_ai": "integration-guides/facilitator-adapters.mdx",
|
|
60
|
+
"mcpay": "integration-guides/facilitator-adapters.mdx",
|
|
61
|
+
};
|
|
62
|
+
const GENERIC_FALLBACK = "integration-guides/facilitator-adapters.mdx";
|
|
63
|
+
const SERVICES_README = "trustgate/server/src/facilitators/README.md";
|
|
64
|
+
function findRepoRoot() {
|
|
65
|
+
const candidates = [
|
|
66
|
+
path.resolve(__dirname, "../../../.."),
|
|
67
|
+
process.cwd(),
|
|
68
|
+
];
|
|
69
|
+
for (const c of candidates) {
|
|
70
|
+
try {
|
|
71
|
+
if (fs.existsSync(path.join(c, "Anchor.toml")))
|
|
72
|
+
return c;
|
|
73
|
+
}
|
|
74
|
+
catch { /* ignore */ }
|
|
75
|
+
}
|
|
76
|
+
return path.resolve(__dirname, "../../../..");
|
|
77
|
+
}
|
|
78
|
+
exports.facilitatorWalkthroughTool = {
|
|
79
|
+
name: "agenttrust_facilitator_walkthrough",
|
|
80
|
+
description: "Return the per-adapter integration walkthrough for the named facilitator. " +
|
|
81
|
+
"Recognised names: pay-sh, dexter, atxp, mcpay. Unknown names fall back " +
|
|
82
|
+
"to the generic facilitator-adapters guide plus a note. Also returns " +
|
|
83
|
+
"the trustgate/server facilitators README content for cross-reference.",
|
|
84
|
+
inputSchema: InputSchema,
|
|
85
|
+
async handler(input) {
|
|
86
|
+
const root = findRepoRoot();
|
|
87
|
+
const docKey = input.name.toLowerCase().replace(/[\s_]/g, "-");
|
|
88
|
+
const matched = !!ADAPTER_DOCS[docKey];
|
|
89
|
+
const docRel = ADAPTER_DOCS[docKey] ?? GENERIC_FALLBACK;
|
|
90
|
+
const docAbs = path.join(root, "docs-site", "content", "docs", docRel);
|
|
91
|
+
const readmeAbs = path.join(root, SERVICES_README);
|
|
92
|
+
let content = "";
|
|
93
|
+
try {
|
|
94
|
+
content = fs.readFileSync(docAbs, "utf-8");
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
content = `(failed to read ${docRel}: ${err.message})`;
|
|
98
|
+
}
|
|
99
|
+
let services = "";
|
|
100
|
+
try {
|
|
101
|
+
services = fs.readFileSync(readmeAbs, "utf-8");
|
|
102
|
+
}
|
|
103
|
+
catch { /* optional */ }
|
|
104
|
+
const out = {
|
|
105
|
+
name: input.name,
|
|
106
|
+
matched,
|
|
107
|
+
source: docRel,
|
|
108
|
+
content,
|
|
109
|
+
servicesReadme: services || undefined,
|
|
110
|
+
};
|
|
111
|
+
if (!matched) {
|
|
112
|
+
out.fallback = "Unknown facilitator; returning the generic adapter guide.";
|
|
113
|
+
}
|
|
114
|
+
return out;
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=facilitator-walkthrough.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"facilitator-walkthrough.js","sourceRoot":"","sources":["../../../src/tools/discovery/facilitator-walkthrough.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,2CAA6B;AAE7B,6BAAwB;AAIxB,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,6EAA6E,CAAC;CAChH,CAAC,CAAC;AAYH,MAAM,YAAY,GAA2B;IAC3C,QAAQ,EAAG,uCAAuC;IAClD,OAAO,EAAI,uCAAuC;IAClD,QAAQ,EAAG,uCAAuC;IAClD,QAAQ,EAAG,6CAA6C;IACxD,MAAM,EAAK,6CAA6C;IACxD,SAAS,EAAE,6CAA6C;IACxD,OAAO,EAAI,6CAA6C;CACzD,CAAC;AACF,MAAM,gBAAgB,GAAG,6CAA6C,CAAC;AACvE,MAAM,eAAe,GAAI,6CAA6C,CAAC;AAEvE,SAAS,YAAY;IACnB,MAAM,UAAU,GAAG;QACjB,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,aAAa,CAAC;QACtC,OAAO,CAAC,GAAG,EAAE;KACd,CAAC;IACF,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;QAC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,IAAI,CAAC;YAAC,QAAQ,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAAC,CAAC;QACvD,MAAM,CAAC,CAAC,cAAc,CAAC,CAAC;QAExB,MAAM,GAAG,GAAW;YAClB,IAAI,EAAY,KAAK,CAAC,IAAI;YAC1B,OAAO;YACP,MAAM,EAAU,MAAM;YACtB,OAAO;YACP,cAAc,EAAE,QAAQ,IAAI,SAAS;SACtC,CAAC;QACF,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,GAAG,CAAC,QAAQ,GAAG,2DAA2D,CAAC;QAC7E,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Aggregator: collects every tool from read/, write/, discovery/ into a
|
|
3
|
+
* single ordered list the server registers in one pass.
|
|
4
|
+
*/
|
|
5
|
+
import type { AnyTool } from "./types";
|
|
6
|
+
export declare const READ_TOOLS: ReadonlyArray<AnyTool>;
|
|
7
|
+
export declare const WRITE_TOOLS: ReadonlyArray<AnyTool>;
|
|
8
|
+
export declare const DISCOVERY_TOOLS: ReadonlyArray<AnyTool>;
|
|
9
|
+
export declare const ALL_TOOLS: ReadonlyArray<AnyTool>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Aggregator: collects every tool from read/, write/, discovery/ into a
|
|
4
|
+
* single ordered list the server registers in one pass.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ALL_TOOLS = exports.DISCOVERY_TOOLS = exports.WRITE_TOOLS = exports.READ_TOOLS = void 0;
|
|
8
|
+
const get_policy_1 = require("./read/get-policy");
|
|
9
|
+
const list_policies_1 = require("./read/list-policies");
|
|
10
|
+
const simulate_payment_1 = require("./read/simulate-payment");
|
|
11
|
+
const get_killswitch_1 = require("./read/get-killswitch");
|
|
12
|
+
const get_velocity_1 = require("./read/get-velocity");
|
|
13
|
+
const get_feedback_log_1 = require("./read/get-feedback-log");
|
|
14
|
+
const get_quantu_reputation_1 = require("./read/get-quantu-reputation");
|
|
15
|
+
const get_validation_attestation_1 = require("./read/get-validation-attestation");
|
|
16
|
+
const list_facilitators_1 = require("./read/list-facilitators");
|
|
17
|
+
const demo_state_1 = require("./read/demo-state");
|
|
18
|
+
const init_policy_1 = require("./write/init-policy");
|
|
19
|
+
const set_killswitch_1 = require("./write/set-killswitch");
|
|
20
|
+
const request_validation_1 = require("./write/request-validation");
|
|
21
|
+
const respond_to_validation_1 = require("./write/respond-to-validation");
|
|
22
|
+
const emit_feedback_1 = require("./write/emit-feedback");
|
|
23
|
+
const docs_1 = require("./discovery/docs");
|
|
24
|
+
const facilitator_walkthrough_1 = require("./discovery/facilitator-walkthrough");
|
|
25
|
+
const explain_decision_1 = require("./discovery/explain-decision");
|
|
26
|
+
exports.READ_TOOLS = [
|
|
27
|
+
get_policy_1.getPolicyTool,
|
|
28
|
+
list_policies_1.listPoliciesTool,
|
|
29
|
+
simulate_payment_1.simulatePaymentTool,
|
|
30
|
+
get_killswitch_1.getKillswitchTool,
|
|
31
|
+
get_velocity_1.getVelocityTool,
|
|
32
|
+
get_feedback_log_1.getFeedbackLogTool,
|
|
33
|
+
get_quantu_reputation_1.getQuantuReputationTool,
|
|
34
|
+
get_validation_attestation_1.getValidationAttestationTool,
|
|
35
|
+
list_facilitators_1.listFacilitatorsTool,
|
|
36
|
+
demo_state_1.demoStateTool,
|
|
37
|
+
];
|
|
38
|
+
exports.WRITE_TOOLS = [
|
|
39
|
+
init_policy_1.initPolicyTool,
|
|
40
|
+
set_killswitch_1.setKillswitchTool,
|
|
41
|
+
request_validation_1.requestValidationTool,
|
|
42
|
+
respond_to_validation_1.respondToValidationTool,
|
|
43
|
+
emit_feedback_1.emitFeedbackTool,
|
|
44
|
+
];
|
|
45
|
+
exports.DISCOVERY_TOOLS = [
|
|
46
|
+
docs_1.docsTool,
|
|
47
|
+
facilitator_walkthrough_1.facilitatorWalkthroughTool,
|
|
48
|
+
explain_decision_1.explainDecisionTool,
|
|
49
|
+
];
|
|
50
|
+
exports.ALL_TOOLS = [
|
|
51
|
+
...exports.READ_TOOLS,
|
|
52
|
+
...exports.WRITE_TOOLS,
|
|
53
|
+
...exports.DISCOVERY_TOOLS,
|
|
54
|
+
];
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,kDAA+D;AAC/D,wDAAkE;AAClE,8DAAqE;AACrE,0DAAmE;AACnE,sDAAiE;AACjE,8DAAqE;AACrE,wEAA0E;AAC1E,kFAAiF;AACjF,gEAAsE;AACtE,kDAA+D;AAE/D,qDAAiE;AACjE,2DAAoE;AACpE,mEAAwE;AACxE,yEAA2E;AAC3E,yDAAmE;AAEnE,2CAA8D;AAC9D,iFAAiF;AACjF,mEAA0E;AAE7D,QAAA,UAAU,GAA2B;IAChD,0BAAoD;IACpD,gCAAoD;IACpD,sCAAoD;IACpD,kCAAoD;IACpD,8BAAoD;IACpD,qCAAoD;IACpD,+CAAoD;IACpD,yDAAoD;IACpD,wCAAoD;IACpD,0BAAoD;CACrD,CAAC;AAEW,QAAA,WAAW,GAA2B;IACjD,4BAA6C;IAC7C,kCAA6C;IAC7C,0CAA6C;IAC7C,+CAA6C;IAC7C,gCAA6C;CAC9C,CAAC;AAEW,QAAA,eAAe,GAA2B;IACrD,eAAgD;IAChD,oDAAgD;IAChD,sCAAgD;CACjD,CAAC;AAEW,QAAA,SAAS,GAA2B;IAC/C,GAAG,kBAAU;IACb,GAAG,mBAAW;IACd,GAAG,uBAAe;CACnB,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agenttrust_demo_state` — return the three pre-warmed devnet
|
|
3
|
+
* counterparties from the pay-sh-demo's `devnet-counterparties.json`,
|
|
4
|
+
* plus the demo's network + program metadata.
|
|
5
|
+
*
|
|
6
|
+
* The file lives at `examples/pay-sh-demo/devnet-counterparties.json`
|
|
7
|
+
* and is regenerated by `scripts/prewarm-counterparties.ts`. The MCP
|
|
8
|
+
* server reads it at request time so the tool always reflects the
|
|
9
|
+
* latest pre-warm.
|
|
10
|
+
*/
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
import type { Tool } from "../types";
|
|
13
|
+
declare const InputSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
14
|
+
type Input = z.infer<typeof InputSchema>;
|
|
15
|
+
interface Counterparty {
|
|
16
|
+
id: number;
|
|
17
|
+
label: string;
|
|
18
|
+
demoTier: number;
|
|
19
|
+
asset: string;
|
|
20
|
+
agentAccount: string;
|
|
21
|
+
atomStats: string;
|
|
22
|
+
owner: string;
|
|
23
|
+
registerSig: string;
|
|
24
|
+
initializeStatsSig: string;
|
|
25
|
+
registeredAtSlot: number;
|
|
26
|
+
initializedAtSlot: number;
|
|
27
|
+
explorerUrls: {
|
|
28
|
+
asset: string;
|
|
29
|
+
agentAccount: string;
|
|
30
|
+
atomStats: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
interface Output {
|
|
34
|
+
available: boolean;
|
|
35
|
+
network?: string;
|
|
36
|
+
programs?: Record<string, string>;
|
|
37
|
+
baseCollection?: string;
|
|
38
|
+
rootConfig?: string;
|
|
39
|
+
atomConfig?: string;
|
|
40
|
+
registryConfig?: string;
|
|
41
|
+
counterparties?: Counterparty[];
|
|
42
|
+
updatedAt?: string;
|
|
43
|
+
error?: string;
|
|
44
|
+
/** Resolved path the file was read from (for diagnostics). */
|
|
45
|
+
source?: string;
|
|
46
|
+
}
|
|
47
|
+
export declare const demoStateTool: Tool<Input, Output>;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `agenttrust_demo_state` — return the three pre-warmed devnet
|
|
4
|
+
* counterparties from the pay-sh-demo's `devnet-counterparties.json`,
|
|
5
|
+
* plus the demo's network + program metadata.
|
|
6
|
+
*
|
|
7
|
+
* The file lives at `examples/pay-sh-demo/devnet-counterparties.json`
|
|
8
|
+
* and is regenerated by `scripts/prewarm-counterparties.ts`. The MCP
|
|
9
|
+
* server reads it at request time so the tool always reflects the
|
|
10
|
+
* latest pre-warm.
|
|
11
|
+
*/
|
|
12
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
16
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}) : (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
o[k2] = m[k];
|
|
22
|
+
}));
|
|
23
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
24
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
25
|
+
}) : function(o, v) {
|
|
26
|
+
o["default"] = v;
|
|
27
|
+
});
|
|
28
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
29
|
+
var ownKeys = function(o) {
|
|
30
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
31
|
+
var ar = [];
|
|
32
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
33
|
+
return ar;
|
|
34
|
+
};
|
|
35
|
+
return ownKeys(o);
|
|
36
|
+
};
|
|
37
|
+
return function (mod) {
|
|
38
|
+
if (mod && mod.__esModule) return mod;
|
|
39
|
+
var result = {};
|
|
40
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
41
|
+
__setModuleDefault(result, mod);
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.demoStateTool = void 0;
|
|
47
|
+
const fs = __importStar(require("fs"));
|
|
48
|
+
const path = __importStar(require("path"));
|
|
49
|
+
const zod_1 = require("zod");
|
|
50
|
+
const config_1 = require("../../config");
|
|
51
|
+
const InputSchema = zod_1.z.object({});
|
|
52
|
+
function findDemoFile() {
|
|
53
|
+
const candidates = [
|
|
54
|
+
// From repo root (typical npm install layout)
|
|
55
|
+
path.resolve(__dirname, "../../../../examples/pay-sh-demo/devnet-counterparties.json"),
|
|
56
|
+
// Fallback: relative to cwd
|
|
57
|
+
path.resolve(process.cwd(), "examples/pay-sh-demo/devnet-counterparties.json"),
|
|
58
|
+
// Env override
|
|
59
|
+
process.env.PAY_SH_DEMO_STATE_FILE ?? "",
|
|
60
|
+
].filter(Boolean);
|
|
61
|
+
for (const p of candidates) {
|
|
62
|
+
try {
|
|
63
|
+
if (p && fs.existsSync(p))
|
|
64
|
+
return p;
|
|
65
|
+
}
|
|
66
|
+
catch { /* ignore */ }
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
exports.demoStateTool = {
|
|
71
|
+
name: "agenttrust_demo_state",
|
|
72
|
+
description: "Return the three pre-warmed devnet demo counterparties (tier-0 untrusted, " +
|
|
73
|
+
"tier-1 low-trust, tier-3 trusted) used by examples/pay-sh-demo. Each " +
|
|
74
|
+
"entry includes the asset pubkey, Quantu agent_account / atom_stats PDAs, " +
|
|
75
|
+
"and Explorer URLs. Useful as input for agenttrust_simulate_payment.",
|
|
76
|
+
inputSchema: InputSchema,
|
|
77
|
+
async handler(_input, ctx) {
|
|
78
|
+
const file = findDemoFile();
|
|
79
|
+
if (!file) {
|
|
80
|
+
return {
|
|
81
|
+
available: false,
|
|
82
|
+
error: "demo state file not found. Looked at " +
|
|
83
|
+
"examples/pay-sh-demo/devnet-counterparties.json relative to the MCP " +
|
|
84
|
+
"package and to the current working directory. Set " +
|
|
85
|
+
"PAY_SH_DEMO_STATE_FILE to override.",
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
const raw = fs.readFileSync(file, "utf-8");
|
|
90
|
+
const parsed = JSON.parse(raw);
|
|
91
|
+
const counterparties = (parsed.counterparties ?? []).map(
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
93
|
+
(c) => ({
|
|
94
|
+
id: Number(c.id),
|
|
95
|
+
label: String(c.label),
|
|
96
|
+
demoTier: Number(c.demoTier),
|
|
97
|
+
asset: String(c.asset),
|
|
98
|
+
agentAccount: String(c.agentAccount),
|
|
99
|
+
atomStats: String(c.atomStats),
|
|
100
|
+
owner: String(c.owner),
|
|
101
|
+
registerSig: String(c.registerSig),
|
|
102
|
+
initializeStatsSig: String(c.initializeStatsSig),
|
|
103
|
+
registeredAtSlot: Number(c.registeredAtSlot),
|
|
104
|
+
initializedAtSlot: Number(c.initializedAtSlot),
|
|
105
|
+
explorerUrls: {
|
|
106
|
+
asset: (0, config_1.explorerUrl)(ctx.chain.cfg, "address", String(c.asset)),
|
|
107
|
+
agentAccount: (0, config_1.explorerUrl)(ctx.chain.cfg, "address", String(c.agentAccount)),
|
|
108
|
+
atomStats: (0, config_1.explorerUrl)(ctx.chain.cfg, "address", String(c.atomStats)),
|
|
109
|
+
},
|
|
110
|
+
}));
|
|
111
|
+
return {
|
|
112
|
+
available: true,
|
|
113
|
+
network: parsed.network,
|
|
114
|
+
programs: parsed.programs,
|
|
115
|
+
baseCollection: parsed.baseCollection,
|
|
116
|
+
rootConfig: parsed.rootConfig,
|
|
117
|
+
atomConfig: parsed.atomConfig,
|
|
118
|
+
registryConfig: parsed.registryConfig,
|
|
119
|
+
counterparties,
|
|
120
|
+
updatedAt: parsed.updatedAt,
|
|
121
|
+
source: file,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
125
|
+
return { available: false, error: `failed to read demo state: ${err.message}`, source: file };
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=demo-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demo-state.js","sourceRoot":"","sources":["../../../src/tools/read/demo-state.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,2CAA6B;AAE7B,6BAAwB;AAExB,yCAA2C;AAG3C,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAqCjC,SAAS,YAAY;IACnB,MAAM,UAAU,GAAG;QACjB,8CAA8C;QAC9C,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,6DAA6D,CAAC;QACtF,4BAA4B;QAC5B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,iDAAiD,CAAC;QAC9E,eAAe;QACf,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,EAAE;KACzC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAClB,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;QAC3B,IAAI,CAAC;YACH,IAAI,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;gBAAE,OAAO,CAAC,CAAC;QACtC,CAAC;QAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAEY,QAAA,aAAa,GAAwB;IAChD,IAAI,EAAS,uBAAuB;IACpC,WAAW,EACT,4EAA4E;QAC5E,uEAAuE;QACvE,2EAA2E;QAC3E,qEAAqE;IACvE,WAAW,EAAE,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AAS,IAAA,oBAAW,EAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;oBACpE,YAAY,EAAE,IAAA,oBAAW,EAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;oBAC3E,SAAS,EAAK,IAAA,oBAAW,EAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;iBACzE;aACF,CAAC,CACH,CAAC;YACF,OAAO;gBACL,SAAS,EAAO,IAAI;gBACpB,OAAO,EAAS,MAAM,CAAC,OAAO;gBAC9B,QAAQ,EAAQ,MAAM,CAAC,QAAQ;gBAC/B,cAAc,EAAE,MAAM,CAAC,cAAc;gBACrC,UAAU,EAAM,MAAM,CAAC,UAAU;gBACjC,UAAU,EAAM,MAAM,CAAC,UAAU;gBACjC,cAAc,EAAE,MAAM,CAAC,cAAc;gBACrC,cAAc;gBACd,SAAS,EAAO,MAAM,CAAC,SAAS;gBAChC,MAAM,EAAU,IAAI;aACrB,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,8BAA+B,GAAa,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QAC3G,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agenttrust_get_feedback_log` — fetch FeedbackEmissionLog PDA by
|
|
3
|
+
* payment_id_hash. Returns the score that was emitted, dispute flag,
|
|
4
|
+
* emission slot.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import type { Tool } from "../types";
|
|
8
|
+
declare const InputSchema: z.ZodObject<{
|
|
9
|
+
payment_id_hash: z.ZodEffects<z.ZodString, string, string>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
payment_id_hash: string;
|
|
12
|
+
}, {
|
|
13
|
+
payment_id_hash: string;
|
|
14
|
+
}>;
|
|
15
|
+
type Input = z.infer<typeof InputSchema>;
|
|
16
|
+
interface Output {
|
|
17
|
+
pda: string;
|
|
18
|
+
explorerUrl: string;
|
|
19
|
+
exists: boolean;
|
|
20
|
+
log?: {
|
|
21
|
+
paymentIdHashHex: string;
|
|
22
|
+
score: number;
|
|
23
|
+
isDispute: boolean;
|
|
24
|
+
emittedAtSlot: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export declare const getFeedbackLogTool: Tool<Input, Output>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `agenttrust_get_feedback_log` — fetch FeedbackEmissionLog PDA by
|
|
4
|
+
* payment_id_hash. Returns the score that was emitted, dispute flag,
|
|
5
|
+
* emission slot.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.getFeedbackLogTool = 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
|
+
payment_id_hash: common_1.HexHashSchema.describe("32-byte SHA-256 hash of the payment_id, hex"),
|
|
15
|
+
});
|
|
16
|
+
exports.getFeedbackLogTool = {
|
|
17
|
+
name: "agenttrust_get_feedback_log",
|
|
18
|
+
description: "Look up the FeedbackEmissionLog by 32-byte payment_id_hash (hex). " +
|
|
19
|
+
"Returns the emitted score, whether it was an emit or dispute path, " +
|
|
20
|
+
"and the slot at which feedback was finalised. exists=false when no " +
|
|
21
|
+
"feedback has been emitted for that payment yet.",
|
|
22
|
+
inputSchema: InputSchema,
|
|
23
|
+
async handler(input, ctx) {
|
|
24
|
+
const hashBytes = (0, common_1.hexToBytes)(input.payment_id_hash);
|
|
25
|
+
if (hashBytes.length !== 32)
|
|
26
|
+
throw new Error("payment_id_hash must decode to 32 bytes");
|
|
27
|
+
const pda = (0, chain_1.deriveFeedbackLogPda)(ctx.chain.cfg.programs.trustgate, Buffer.from(hashBytes));
|
|
28
|
+
const trustgate = await ctx.chain.trustgate();
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
|
+
const data = await trustgate.account.feedbackEmissionLog.fetchNullable(pda);
|
|
31
|
+
if (!data) {
|
|
32
|
+
return {
|
|
33
|
+
pda: pda.toBase58(),
|
|
34
|
+
explorerUrl: (0, config_1.explorerUrl)(ctx.chain.cfg, "address", pda.toBase58()),
|
|
35
|
+
exists: false,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
pda: pda.toBase58(),
|
|
40
|
+
explorerUrl: (0, config_1.explorerUrl)(ctx.chain.cfg, "address", pda.toBase58()),
|
|
41
|
+
exists: true,
|
|
42
|
+
log: {
|
|
43
|
+
paymentIdHashHex: (0, common_1.bytesToHex)(data.paymentIdHash ?? hashBytes),
|
|
44
|
+
score: Number(data.score ?? 0),
|
|
45
|
+
isDispute: Number(data.isDispute ?? 0) !== 0,
|
|
46
|
+
emittedAtSlot: (0, common_1.toDecString)(data.emittedAtSlot),
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=get-feedback-log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-feedback-log.js","sourceRoot":"","sources":["../../../src/tools/read/get-feedback-log.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,6BAAwB;AAExB,uCAAmD;AACnD,yCAA2C;AAC3C,sCAA+E;AAG/E,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM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