@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
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* AgentTrust MCP server entry point. Selects transport from env:
|
|
4
|
+
* - stdio (default; used by Claude Desktop, Cursor, generic MCP clients)
|
|
5
|
+
* - http (used for hosted deployments — Vercel, Fly, etc.)
|
|
6
|
+
*
|
|
7
|
+
* To use as an installed binary the package.json `bin` field exposes
|
|
8
|
+
* `agenttrust-mcp` → this file.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* AgentTrust MCP server entry point. Selects transport from env:
|
|
5
|
+
* - stdio (default; used by Claude Desktop, Cursor, generic MCP clients)
|
|
6
|
+
* - http (used for hosted deployments — Vercel, Fly, etc.)
|
|
7
|
+
*
|
|
8
|
+
* To use as an installed binary the package.json `bin` field exposes
|
|
9
|
+
* `agenttrust-mcp` → this file.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
13
|
+
const config_1 = require("./config");
|
|
14
|
+
const server_1 = require("./server");
|
|
15
|
+
const HELP_TEXT = `agenttrust-mcp — Model Context Protocol server for AgentTrust
|
|
16
|
+
|
|
17
|
+
USAGE
|
|
18
|
+
agenttrust-mcp Start in stdio mode (Claude Desktop / Cursor)
|
|
19
|
+
MCP_TRANSPORT=http agenttrust-mcp Start in HTTP mode on \$MCP_HTTP_PORT (default 8080)
|
|
20
|
+
|
|
21
|
+
INSTALL — Claude Desktop
|
|
22
|
+
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
|
|
23
|
+
"mcpServers": {
|
|
24
|
+
"agenttrust": {
|
|
25
|
+
"command": "npx",
|
|
26
|
+
"args": ["-y", "@agenttrust-sdk/mcp"],
|
|
27
|
+
"env": { "RPC_URL": "https://api.devnet.solana.com",
|
|
28
|
+
"NETWORK": "solana-devnet" }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
INSTALL — Cursor
|
|
33
|
+
Same shape in ~/.cursor/mcp.json.
|
|
34
|
+
|
|
35
|
+
ENVIRONMENT
|
|
36
|
+
RPC_URL Solana RPC endpoint (default: devnet)
|
|
37
|
+
NETWORK solana-devnet | solana-mainnet
|
|
38
|
+
KEYPAIR_B58 Base58 64-byte secret. Required for write tools.
|
|
39
|
+
MCP_TRANSPORT stdio (default) | http
|
|
40
|
+
MCP_HTTP_PORT 8080 (default; Fly.io also injects PORT)
|
|
41
|
+
|
|
42
|
+
DOCS
|
|
43
|
+
Tools / resources / prompts: https://agenttrust-labs.github.io/agenttrust/mcp
|
|
44
|
+
Repo: https://github.com/agenttrust-labs/agenttrust
|
|
45
|
+
`;
|
|
46
|
+
async function main() {
|
|
47
|
+
// --help / -h: print install instructions and exit. Some launchers
|
|
48
|
+
// (npx, package managers) probe entry points with --help before
|
|
49
|
+
// wiring up stdio transports.
|
|
50
|
+
if (process.argv.slice(2).some((arg) => arg === "--help" || arg === "-h")) {
|
|
51
|
+
process.stdout.write(HELP_TEXT);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
// --version / -v: print package version and exit.
|
|
55
|
+
if (process.argv.slice(2).some((arg) => arg === "--version" || arg === "-v")) {
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
57
|
+
const pkg = require("../package.json");
|
|
58
|
+
process.stdout.write(`${pkg.name} ${pkg.version}\n`);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const cfg = (0, config_1.loadConfig)();
|
|
62
|
+
const server = (0, server_1.createMcpServer)(cfg);
|
|
63
|
+
if (cfg.transport === "http") {
|
|
64
|
+
// Lazy-import the streamable-HTTP transport so the stdio path
|
|
65
|
+
// doesn't pay the cost of pulling Node's http module on cold start.
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
67
|
+
const { StreamableHTTPServerTransport } = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
69
|
+
const http = require("http");
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
71
|
+
const pkg = require("../package.json");
|
|
72
|
+
const startedAt = Date.now();
|
|
73
|
+
const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: () => Math.random().toString(36).slice(2) });
|
|
74
|
+
await server.connect(transport);
|
|
75
|
+
const httpServer = http.createServer((req, res) => {
|
|
76
|
+
// /healthz: lightweight Fly.io / status-page probe. NOT part
|
|
77
|
+
// of MCP protocol — handled before the transport sees it.
|
|
78
|
+
// Returns the same JSON shape as the facilitator + demo
|
|
79
|
+
// surfaces so the status-page poller can treat them
|
|
80
|
+
// uniformly (ok, network, version, uptimeSeconds).
|
|
81
|
+
const path = (req.url ?? "").split("?")[0];
|
|
82
|
+
if (req.method === "GET" && (path === "/healthz" || path === "/")) {
|
|
83
|
+
res.writeHead(200, { "content-type": "application/json" });
|
|
84
|
+
res.end(JSON.stringify({
|
|
85
|
+
ok: true,
|
|
86
|
+
service: "agenttrust-mcp",
|
|
87
|
+
version: pkg.version,
|
|
88
|
+
network: cfg.network,
|
|
89
|
+
rpcUrl: cfg.rpcUrl,
|
|
90
|
+
uptimeSeconds: Math.round((Date.now() - startedAt) / 1000),
|
|
91
|
+
// Tools count is the load-bearing surface signal — if
|
|
92
|
+
// an upstream regression dropped a tool, the status
|
|
93
|
+
// page would show the count drop.
|
|
94
|
+
// The actual count lives in tools/list; we publish a
|
|
95
|
+
// pinned expected count here so monitors can alert on
|
|
96
|
+
// mismatch without parsing JSON-RPC.
|
|
97
|
+
toolCount: 18,
|
|
98
|
+
}) + "\n");
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
transport.handleRequest(req, res).catch((err) => {
|
|
102
|
+
// eslint-disable-next-line no-console
|
|
103
|
+
console.error("transport error:", err);
|
|
104
|
+
res.writeHead(500).end();
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
httpServer.listen(cfg.httpPort, () => {
|
|
108
|
+
// eslint-disable-next-line no-console
|
|
109
|
+
console.error(`AgentTrust MCP server listening on http://0.0.0.0:${cfg.httpPort}`);
|
|
110
|
+
});
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
// stdio (default)
|
|
114
|
+
const transport = new stdio_js_1.StdioServerTransport();
|
|
115
|
+
await server.connect(transport);
|
|
116
|
+
// Stay alive — stdio's stdin close terminates us cleanly via the SDK.
|
|
117
|
+
}
|
|
118
|
+
main().catch((err) => {
|
|
119
|
+
// eslint-disable-next-line no-console
|
|
120
|
+
console.error("fatal:", err);
|
|
121
|
+
process.exit(1);
|
|
122
|
+
});
|
|
123
|
+
//# sourceMappingURL=index.js.map
|
|
@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I,CAAC;oBAC3D,sDAAsD;oBACtD,oDAAoD;oBACpD,kCAAkC;oBAClC,qDAAqD;oBACrD,sDAAsD;oBACtD,qCAAqC;oBACrC,SAAS,EAAO,EAAE;iBACnB,CAAC,GAAG,IAAI,CAAC,CAAC;gBACX,OAAO;YACT,CAAC;YACD,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,GAAU,EAAE,EAAE;gBACrD,sCAAsC;gBACtC,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;gBACvC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;YAC3B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE;YACnC,sCAAsC;YACtC,OAAO,CAAC,KAAK,CAAC,qDAAqD,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;QACrF,CAAC,CAAC,CAAC;QACH,OAAO;IACT,CAAC;IAED,kBAAkB;IAClB,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,sEAAsE;AACxE,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,sCAAsC;IACtC,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC7B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agenttrust_audit_payment` — guided workflow for inspecting a single
|
|
3
|
+
* payer→payee payment. Walks the user through:
|
|
4
|
+
* 1. simulate the gate decision
|
|
5
|
+
* 2. read the policy
|
|
6
|
+
* 3. read the payee's reputation
|
|
7
|
+
* 4. summarise the decision in plain English
|
|
8
|
+
*/
|
|
9
|
+
import type { Prompt } from "./types";
|
|
10
|
+
export declare const auditPaymentPrompt: Prompt;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `agenttrust_audit_payment` — guided workflow for inspecting a single
|
|
4
|
+
* payer→payee payment. Walks the user through:
|
|
5
|
+
* 1. simulate the gate decision
|
|
6
|
+
* 2. read the policy
|
|
7
|
+
* 3. read the payee's reputation
|
|
8
|
+
* 4. summarise the decision in plain English
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.auditPaymentPrompt = void 0;
|
|
12
|
+
const zod_1 = require("zod");
|
|
13
|
+
const ArgsSchema = zod_1.z.object({
|
|
14
|
+
payer_agent: zod_1.z.string().describe("Payer Quantu agent asset"),
|
|
15
|
+
payee_agent: zod_1.z.string().describe("Payee Quantu agent asset"),
|
|
16
|
+
amount: zod_1.z.string().describe("Amount in mint base units"),
|
|
17
|
+
mint: zod_1.z.string().describe("SPL or Token-2022 mint pubkey"),
|
|
18
|
+
policy_id: zod_1.z.string().describe("u32 policy ID as string"),
|
|
19
|
+
});
|
|
20
|
+
exports.auditPaymentPrompt = {
|
|
21
|
+
name: "agenttrust_audit_payment",
|
|
22
|
+
description: "Audit a payment by simulating the gate decision, reading the active policy, and resolving the payee's Quantu reputation tier.",
|
|
23
|
+
arguments: [
|
|
24
|
+
{ name: "payer_agent", description: "Payer Quantu agent asset", required: true },
|
|
25
|
+
{ name: "payee_agent", description: "Payee Quantu agent asset", required: true },
|
|
26
|
+
{ name: "amount", description: "Amount in mint base units", required: true },
|
|
27
|
+
{ name: "mint", description: "SPL or Token-2022 mint pubkey", required: true },
|
|
28
|
+
{ name: "policy_id", description: "u32 policy ID as a string", required: true },
|
|
29
|
+
],
|
|
30
|
+
argsSchema: ArgsSchema,
|
|
31
|
+
build(args) {
|
|
32
|
+
return [
|
|
33
|
+
{
|
|
34
|
+
role: "user",
|
|
35
|
+
content: {
|
|
36
|
+
type: "text",
|
|
37
|
+
text: `Audit this payment end-to-end:\n\n` +
|
|
38
|
+
`payer_agent = ${args.payer_agent}\n` +
|
|
39
|
+
`payee_agent = ${args.payee_agent}\n` +
|
|
40
|
+
`amount = ${args.amount}\n` +
|
|
41
|
+
`mint = ${args.mint}\n` +
|
|
42
|
+
`policy_id = ${args.policy_id}\n\n` +
|
|
43
|
+
`Steps to perform:\n` +
|
|
44
|
+
`1. Call agenttrust_simulate_payment with the inputs above. Capture the GateDecision.\n` +
|
|
45
|
+
`2. Call agenttrust_get_policy(payer_agent, policy_id) to surface the active spending caps and tier thresholds.\n` +
|
|
46
|
+
`3. Call agenttrust_get_quantu_reputation(payee_agent) to surface the payee's tier and risk score.\n` +
|
|
47
|
+
`4. If the decision is Deny, call agenttrust_explain_decision with the reasonCode for the remediation hint.\n` +
|
|
48
|
+
`5. If the decision is RequireValidation, call agenttrust_get_validation_attestation(payer_agent, capabilityHashHex) to check whether an attestation already exists.\n\n` +
|
|
49
|
+
`Summarise in plain English: what would happen, why, and what (if anything) the operator should do next.`,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=audit-payment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-payment.js","sourceRoot":"","sources":["../../src/prompts/audit-payment.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,6BAAwB;AAIxB,MAAM,UAAU,GAAG,OAAC,CAAC,MAAM,CAAC;IAC1B,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0BAA0B,CAAC;IAC5D,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0BAA0B,CAAC;IAC5D,MAAM,EAAO,OAAC,CAAC,MAAM,EAAE,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F,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agenttrust_explain_failure` — given a failed payment's reason code
|
|
3
|
+
* (the value of `X-Payment-Reason-Code`), produce a developer-readable
|
|
4
|
+
* explanation + remediation steps the operator can act on.
|
|
5
|
+
*/
|
|
6
|
+
import type { Prompt } from "./types";
|
|
7
|
+
export declare const explainFailurePrompt: Prompt;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `agenttrust_explain_failure` — given a failed payment's reason code
|
|
4
|
+
* (the value of `X-Payment-Reason-Code`), produce a developer-readable
|
|
5
|
+
* explanation + remediation steps the operator can act on.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.explainFailurePrompt = void 0;
|
|
9
|
+
const zod_1 = require("zod");
|
|
10
|
+
const ArgsSchema = zod_1.z.object({
|
|
11
|
+
reason_code: zod_1.z.string().describe("DenyReason stable code (1..15) as a decimal string"),
|
|
12
|
+
payer_agent: zod_1.z.string().optional().describe("Payer agent (helps resolve killswitch / velocity)"),
|
|
13
|
+
payee_agent: zod_1.z.string().optional().describe("Payee agent (helps resolve counterparty / atom)"),
|
|
14
|
+
policy_id: zod_1.z.string().optional().describe("Policy ID (helps resolve spending / velocity)"),
|
|
15
|
+
});
|
|
16
|
+
exports.explainFailurePrompt = {
|
|
17
|
+
name: "agenttrust_explain_failure",
|
|
18
|
+
description: "Explain a failed payment given its reason code, and walk through the chain reads needed to confirm root cause + propose remediation.",
|
|
19
|
+
arguments: [
|
|
20
|
+
{ name: "reason_code", description: "DenyReason stable code (1..15) as a decimal string", required: true },
|
|
21
|
+
{ name: "payer_agent", description: "Payer agent (optional)", required: false },
|
|
22
|
+
{ name: "payee_agent", description: "Payee agent (optional)", required: false },
|
|
23
|
+
{ name: "policy_id", description: "Policy ID (optional)", required: false },
|
|
24
|
+
],
|
|
25
|
+
argsSchema: ArgsSchema,
|
|
26
|
+
build(args) {
|
|
27
|
+
const ctx = [];
|
|
28
|
+
if (args.payer_agent)
|
|
29
|
+
ctx.push(`payer_agent = ${args.payer_agent}`);
|
|
30
|
+
if (args.payee_agent)
|
|
31
|
+
ctx.push(`payee_agent = ${args.payee_agent}`);
|
|
32
|
+
if (args.policy_id)
|
|
33
|
+
ctx.push(`policy_id = ${args.policy_id}`);
|
|
34
|
+
const ctxBlock = ctx.length > 0 ? ctx.join("\n") + "\n\n" : "";
|
|
35
|
+
return [
|
|
36
|
+
{
|
|
37
|
+
role: "user",
|
|
38
|
+
content: {
|
|
39
|
+
type: "text",
|
|
40
|
+
text: `Explain why a payment failed with reason_code = ${args.reason_code}.\n\n` +
|
|
41
|
+
ctxBlock +
|
|
42
|
+
`Steps to perform:\n` +
|
|
43
|
+
`1. Call agenttrust_explain_decision(reason_code) to surface the enum name + remediation hint.\n` +
|
|
44
|
+
`2. Based on the category in the response, call the relevant read tool to confirm root cause:\n` +
|
|
45
|
+
` - killswitch → agenttrust_get_killswitch(payer_agent)\n` +
|
|
46
|
+
` - spending → agenttrust_get_policy(payer_agent, policy_id)\n` +
|
|
47
|
+
` - velocity → agenttrust_get_velocity(payer_agent, policy_id)\n` +
|
|
48
|
+
` - counterparty → agenttrust_get_quantu_reputation(payee_agent)\n` +
|
|
49
|
+
` - validation → agenttrust_get_validation_attestation(payer_agent, capability_hash) — capability hash comes from policy.fields.requiredCapabilityHashHex\n` +
|
|
50
|
+
` - atom → agenttrust_get_quantu_reputation(payee_agent) — verify ownerMatches\n` +
|
|
51
|
+
`3. Synthesise a short answer: what the chain currently says, why the policy denies, and the smallest change that would flip the decision.`,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=explain-failure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explain-failure.js","sour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IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACpE,IAAI,IAAI,CAAC,SAAS;YAAI,GAAG,CAAC,IAAI,CAAC,iBAAiB,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;QAClE,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/D,OAAO;YACL;gBACE,IAAI,EAAK,MAAM;gBACf,OAAO,EAAE;oBACP,IAAI,EAAE,MAAM;oBACZ,IAAI,EACF,mDAAmD,IAAI,CAAC,WAAW,OAAO;wBAC1E,QAAQ;wBACR,qBAAqB;wBACrB,iGAAiG;wBACjG,gGAAgG;wBAChG,6DAA6D;wBAC7D,oEAAoE;wBACpE,sEAAsE;wBACtE,qEAAqE;wBACrE,+JAA+J;wBAC/J,0FAA0F;wBAC1F,2IAA2I;iBAC9I;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ALL_PROMPTS = void 0;
|
|
4
|
+
const audit_payment_1 = require("./audit-payment");
|
|
5
|
+
const setup_agent_1 = require("./setup-agent");
|
|
6
|
+
const explain_failure_1 = require("./explain-failure");
|
|
7
|
+
exports.ALL_PROMPTS = [
|
|
8
|
+
audit_payment_1.auditPaymentPrompt,
|
|
9
|
+
setup_agent_1.setupAgentPrompt,
|
|
10
|
+
explain_failure_1.explainFailurePrompt,
|
|
11
|
+
];
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":";;;AAEA,mDAAuD;AACvD,+CAAqD;AACrD,uDAAyD;AAE5C,QAAA,WAAW,GAA0B;IAChD,kCAAkB;IAClB,8BAAgB;IAChB,sCAAoB;CACrB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `agenttrust_setup_agent` — guided onboarding flow for an agent that
|
|
4
|
+
* needs PolicyAuthority + KillSwitchState + at least one PolicyAccount.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.setupAgentPrompt = void 0;
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
const ArgsSchema = zod_1.z.object({
|
|
10
|
+
agent_asset: zod_1.z.string().describe("Quantu agent asset"),
|
|
11
|
+
use_case: zod_1.z.string().optional()
|
|
12
|
+
.describe("Optional one-line description of what this agent will do (e.g., 'pay-per-call API agent')"),
|
|
13
|
+
});
|
|
14
|
+
exports.setupAgentPrompt = {
|
|
15
|
+
name: "agenttrust_setup_agent",
|
|
16
|
+
description: "Walk through the bootstrap sequence for an agent: PolicyAuthority → KillSwitchState → first PolicyAccount with sane defaults.",
|
|
17
|
+
arguments: [
|
|
18
|
+
{ name: "agent_asset", description: "Quantu agent asset", required: true },
|
|
19
|
+
{ name: "use_case", description: "Optional one-line description", required: false },
|
|
20
|
+
],
|
|
21
|
+
argsSchema: ArgsSchema,
|
|
22
|
+
build(args) {
|
|
23
|
+
const useCase = args.use_case ? `Use-case context: ${args.use_case}` : "Use-case context: generic agent.";
|
|
24
|
+
return [
|
|
25
|
+
{
|
|
26
|
+
role: "user",
|
|
27
|
+
content: {
|
|
28
|
+
type: "text",
|
|
29
|
+
text: `Set up AgentTrust for agent ${args.agent_asset}.\n\n` +
|
|
30
|
+
`${useCase}\n\n` +
|
|
31
|
+
`Required steps in order:\n` +
|
|
32
|
+
`1. Confirm the agent already has Quantu agent_account + atom_stats. Use agenttrust_get_quantu_reputation; if exists=false the agent must be registered with Quantu first (out-of-scope for AgentTrust).\n` +
|
|
33
|
+
`2. Initialise PolicyAuthority — out-of-scope for the MCP write tools in v1; surface that the user must call init_authority directly via the SDK or Anchor CLI to seed the multisig (members + threshold).\n` +
|
|
34
|
+
`3. Initialise KillSwitchState — also out-of-scope for the MCP write tools in v1; surface the SDK / Anchor CLI invocation pointing at programs/policy-vault/src/instructions/init_killswitch.rs.\n` +
|
|
35
|
+
`4. Create the first PolicyAccount via agenttrust_init_policy. Recommend an enabled_kinds_bitmask covering at least KillSwitch (1) + Spending (2) for the first policy.\n` +
|
|
36
|
+
`5. Verify with agenttrust_get_policy + agenttrust_list_policies.\n\n` +
|
|
37
|
+
`Output: a step-by-step checklist with the exact tool calls (or, where v1 is missing a write tool, the SDK / Anchor CLI command equivalent), and a one-paragraph summary of what's now on-chain for this agent.`,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=setup-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-agent.js","sourceRoot":"","sources":["../../src/prompts/setup-agent.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAAwB;AAIxB,MAAM,UAAU,GAAG,OAAC,CAAC,MAAM,CAAC;IAC1B,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC;IACtD,QAAQ,EAAK,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;SACjB,QAAQ,CAAC,2FAA2F,CAAC;CACvH,CAAC,CAAC;AAEU,QAAA,gBAAgB,GAAW;IACtC,IAAI,EAAS,wBAAwB;IACrC,WAAW,EAAE,+HAA+H;IAC5I,SAAS,EAAE;QACT,EAAE,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,oBAAoB,EAAqB,QAAQ,EAAE,IAAI,EAAE;QAC7F,EAAE,IAAI,EAAE,UAAU,EAAK,WAAW,EAAE,+BAA+B,EAAW,QAAQ,EAAE,KAAK,EAAE;KAChG;IACD,UAAU,EAAE,UAAU;IACtB,KAAK,CAAC,IAAI;QACR,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,qBAAqB,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,kCAAkC,CAAC;QAC1G,OAAO;YACL;gBACE,IAAI,EAAK,MAAM;gBACf,OAAO,EAAE;oBACP,IAAI,EAAE,MAAM;oBACZ,IAAI,EACF,+BAA+B,IAAI,CAAC,WAAW,OAAO;wBACtD,GAAG,OAAO,MAAM;wBAChB,4BAA4B;wBAC5B,2MAA2M;wBAC3M,6MAA6M;wBAC7M,mMAAmM;wBACnM,0KAA0K;wBAC1K,sEAAsE;wBACtE,gNAAgN;iBACnN;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared shape for MCP prompt templates.
|
|
3
|
+
*/
|
|
4
|
+
import type { z } from "zod";
|
|
5
|
+
export interface PromptArgument {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly description: string;
|
|
8
|
+
readonly required: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface PromptMessage {
|
|
11
|
+
readonly role: "user" | "assistant" | "system";
|
|
12
|
+
readonly content: {
|
|
13
|
+
type: "text";
|
|
14
|
+
text: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface Prompt {
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly description: string;
|
|
20
|
+
readonly arguments: ReadonlyArray<PromptArgument>;
|
|
21
|
+
readonly argsSchema: z.ZodType<Record<string, string>>;
|
|
22
|
+
build(args: Record<string, string>): PromptMessage[];
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/prompts/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP resources backed by the docs corpus + the example demo source
|
|
3
|
+
* trees. Each MDX page is exposed as `agenttrust://docs/<rel-path>`;
|
|
4
|
+
* each example is a hierarchical resource rooted at
|
|
5
|
+
* `agenttrust://examples/<demo-name>/...`.
|
|
6
|
+
*/
|
|
7
|
+
import { findDocsRoot } from "../tools/discovery/docs";
|
|
8
|
+
export interface ResourceDescriptor {
|
|
9
|
+
uri: string;
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
mimeType: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ResourceContent {
|
|
15
|
+
uri: string;
|
|
16
|
+
mimeType: string;
|
|
17
|
+
text: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function listDocsResources(): ResourceDescriptor[];
|
|
20
|
+
export declare function readDocsResource(uri: string): ResourceContent | null;
|
|
21
|
+
export declare function listExampleResources(): ResourceDescriptor[];
|
|
22
|
+
export declare function readExampleResource(uri: string): ResourceContent | null;
|
|
23
|
+
export { findDocsRoot };
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MCP resources backed by the docs corpus + the example demo source
|
|
4
|
+
* trees. Each MDX page is exposed as `agenttrust://docs/<rel-path>`;
|
|
5
|
+
* each example is a hierarchical resource rooted at
|
|
6
|
+
* `agenttrust://examples/<demo-name>/...`.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.findDocsRoot = void 0;
|
|
43
|
+
exports.listDocsResources = listDocsResources;
|
|
44
|
+
exports.readDocsResource = readDocsResource;
|
|
45
|
+
exports.listExampleResources = listExampleResources;
|
|
46
|
+
exports.readExampleResource = readExampleResource;
|
|
47
|
+
const fs = __importStar(require("fs"));
|
|
48
|
+
const path = __importStar(require("path"));
|
|
49
|
+
const docs_1 = require("../tools/discovery/docs");
|
|
50
|
+
Object.defineProperty(exports, "findDocsRoot", { enumerable: true, get: function () { return docs_1.findDocsRoot; } });
|
|
51
|
+
const DOCS_PROTOCOL = "agenttrust://docs/";
|
|
52
|
+
const EXAMPLES_PROT = "agenttrust://examples/";
|
|
53
|
+
function findRepoRoot() {
|
|
54
|
+
const candidates = [
|
|
55
|
+
path.resolve(__dirname, "../../.."),
|
|
56
|
+
process.cwd(),
|
|
57
|
+
];
|
|
58
|
+
for (const c of candidates) {
|
|
59
|
+
try {
|
|
60
|
+
if (fs.existsSync(path.join(c, "Anchor.toml")))
|
|
61
|
+
return c;
|
|
62
|
+
}
|
|
63
|
+
catch { /* ignore */ }
|
|
64
|
+
}
|
|
65
|
+
return path.resolve(__dirname, "../../..");
|
|
66
|
+
}
|
|
67
|
+
function listDocsResources() {
|
|
68
|
+
const corpus = (0, docs_1.loadDocsCorpus)();
|
|
69
|
+
return corpus.map((p) => ({
|
|
70
|
+
uri: p.uri,
|
|
71
|
+
name: p.title,
|
|
72
|
+
description: p.description || `MDX doc: ${p.uri.replace(DOCS_PROTOCOL, "")}`,
|
|
73
|
+
mimeType: "text/markdown",
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
function readDocsResource(uri) {
|
|
77
|
+
if (!uri.startsWith(DOCS_PROTOCOL))
|
|
78
|
+
return null;
|
|
79
|
+
const corpus = (0, docs_1.loadDocsCorpus)();
|
|
80
|
+
const page = corpus.find((p) => p.uri === uri);
|
|
81
|
+
if (!page)
|
|
82
|
+
return null;
|
|
83
|
+
return {
|
|
84
|
+
uri,
|
|
85
|
+
mimeType: "text/markdown",
|
|
86
|
+
text: fs.readFileSync(page.filePath, "utf-8"),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const EXAMPLE_DEMOS = ["pay-sh-demo", "attestor-demo"];
|
|
90
|
+
function listExampleResources() {
|
|
91
|
+
const root = findRepoRoot();
|
|
92
|
+
const out = [];
|
|
93
|
+
for (const demo of EXAMPLE_DEMOS) {
|
|
94
|
+
const demoDir = path.join(root, "examples", demo);
|
|
95
|
+
if (!fs.existsSync(demoDir))
|
|
96
|
+
continue;
|
|
97
|
+
out.push({
|
|
98
|
+
uri: `${EXAMPLES_PROT}${demo}/README.md`,
|
|
99
|
+
name: `examples/${demo}/README.md`,
|
|
100
|
+
description: `${demo} README — install + smoke walkthrough`,
|
|
101
|
+
mimeType: "text/markdown",
|
|
102
|
+
});
|
|
103
|
+
// List the source files non-recursively (one level deep keeps the
|
|
104
|
+
// resource list compact; clients fetch full content via read).
|
|
105
|
+
const srcDir = path.join(demoDir, "src");
|
|
106
|
+
if (fs.existsSync(srcDir)) {
|
|
107
|
+
for (const ent of fs.readdirSync(srcDir, { withFileTypes: true })) {
|
|
108
|
+
if (!ent.isFile())
|
|
109
|
+
continue;
|
|
110
|
+
if (!ent.name.endsWith(".ts"))
|
|
111
|
+
continue;
|
|
112
|
+
out.push({
|
|
113
|
+
uri: `${EXAMPLES_PROT}${demo}/src/${ent.name}`,
|
|
114
|
+
name: `examples/${demo}/src/${ent.name}`,
|
|
115
|
+
description: `${demo} source: ${ent.name}`,
|
|
116
|
+
mimeType: "text/x-typescript",
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return out;
|
|
122
|
+
}
|
|
123
|
+
function readExampleResource(uri) {
|
|
124
|
+
if (!uri.startsWith(EXAMPLES_PROT))
|
|
125
|
+
return null;
|
|
126
|
+
const rest = uri.slice(EXAMPLES_PROT.length);
|
|
127
|
+
// Validate: only allow accessing files inside examples/<demo>/
|
|
128
|
+
const parts = rest.split("/");
|
|
129
|
+
if (parts.length < 2)
|
|
130
|
+
return null;
|
|
131
|
+
const demo = parts[0];
|
|
132
|
+
if (!EXAMPLE_DEMOS.includes(demo))
|
|
133
|
+
return null;
|
|
134
|
+
const root = findRepoRoot();
|
|
135
|
+
const fullPath = path.resolve(root, "examples", demo, ...parts.slice(1));
|
|
136
|
+
// Path-traversal guard: resolve must remain within the demo dir.
|
|
137
|
+
const allowed = path.resolve(root, "examples", demo);
|
|
138
|
+
if (!fullPath.startsWith(allowed + path.sep) && fullPath !== allowed)
|
|
139
|
+
return null;
|
|
140
|
+
if (!fs.existsSync(fullPath) || !fs.statSync(fullPath).isFile())
|
|
141
|
+
return null;
|
|
142
|
+
const mime = fullPath.endsWith(".ts") ? "text/x-typescript"
|
|
143
|
+
: fullPath.endsWith(".md") ? "text/markdown"
|
|
144
|
+
: "text/plain";
|
|
145
|
+
return { uri, mimeType: mime, text: fs.readFileSync(fullPath, "utf-8") };
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=docs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.js","sourceRoot":"","sources":["../../src/resources/docs.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCH,8CAQC;AAED,4CAUC;AAID,oDA6BC;AAED,kDAkBC;AAzGD,uCAAyB;AACzB,2CAA6B;AAE7B,kDAAuE;AAyG9D,6FAzGA,mBAAY,OAyGA;AA1FrB,MAAM,aAAa,GAAM,oBAAoB,CAAC;AAC9C,MAAM,aAAa,GAAM,wBAAwB,CAAC;AAElD,SAAS,YAAY;IACnB,MAAM,UAAU,GAAG;QACjB,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC;QACnC,OAAO,CAAC,GAAG,EAAE;KACd,CAAC;IACF,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;QAC3B,IAAI,CAAC;YAAC,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;gBAAE,OAAO,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;IAC1F,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAC7C,CAAC;AAED,SAAgB,iBAAiB;IAC/B,MAAM,MAAM,GAAG,IAAA,qBAAc,GAAE,CAAC;IAChC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACxB,GAAG,EAAU,CAAC,CAAC,GAAG;QAClB,IAAI,EAAS,CAAC,CAAC,KAAK;QACpB,WAA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AAM,IAAI,GAAG,YAAY,EAAE,CAAC;IAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACzE,iEAAiE;IACjE,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IACrD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,QAAQ,KAAK,OAAO;QAAE,OAAO,IAAI,CAAC;IAClF,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE;QAAE,OAAO,IAAI,CAAC;IAC7E,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,mBAAmB;QAChD,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,eAAe;YAC5C,CAAC,CAAC,YAAY,CAAC;IAC1B,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agenttrust://devnet/programs` — JSON resource enumerating every
|
|
3
|
+
* deployed program ID + the URL clients can use to fetch the IDL.
|
|
4
|
+
*
|
|
5
|
+
* Anchor publishes IDLs per-program-per-network; the canonical fetch
|
|
6
|
+
* is `Program.fetchIdl(programId, provider)`. We surface the program
|
|
7
|
+
* IDs + a deep-link to Solana Explorer's "Anchor IDL" view as the
|
|
8
|
+
* easiest external pointer.
|
|
9
|
+
*/
|
|
10
|
+
import { AgentTrustConfig } from "../config";
|
|
11
|
+
import type { ResourceContent, ResourceDescriptor } from "./docs";
|
|
12
|
+
export declare const PROGRAMS_RESOURCE_URI = "agenttrust://devnet/programs";
|
|
13
|
+
export declare function describeProgramsResource(): ResourceDescriptor;
|
|
14
|
+
export declare function readProgramsResource(cfg: AgentTrustConfig): ResourceContent;
|