@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,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `agenttrust_list_facilitators` — return the active facilitator
|
|
4
|
+
* adapter registry as a static manifest. Mirrors the four adapters
|
|
5
|
+
* shipped in `trustgate/server/src/facilitators/`: Pay.sh (live),
|
|
6
|
+
* Dexter / atxp / MCPay.
|
|
7
|
+
*
|
|
8
|
+
* Manifest is a static module-local constant. The MCP server doesn't
|
|
9
|
+
* boot the Express service, so dynamically introspecting a live
|
|
10
|
+
* `FacilitatorRegistry` would require an extra dependency the SDK
|
|
11
|
+
* doesn't expose. Per the registry/dispatch shape in
|
|
12
|
+
* `trustgate/server/src/facilitators/index.ts`, the four adapters and
|
|
13
|
+
* their protocols/status are pinned values that stay in sync with that
|
|
14
|
+
* file by review.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.listFacilitatorsTool = void 0;
|
|
18
|
+
const zod_1 = require("zod");
|
|
19
|
+
const InputSchema = zod_1.z.object({});
|
|
20
|
+
const FACILITATORS = [
|
|
21
|
+
{
|
|
22
|
+
name: "pay-sh",
|
|
23
|
+
description: "Pay.sh — first concrete x402 facilitator adapter. Live in the demo and CI integration.",
|
|
24
|
+
protocols: ["x402"],
|
|
25
|
+
status: "live",
|
|
26
|
+
docsPath: "integration-guides/pay-sh-adapter",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "dexter",
|
|
30
|
+
description: "Cascade Dexter — x402 facilitator. Wire-spec + Zod schemas + adapter wired; full integration in flight.",
|
|
31
|
+
protocols: ["x402"],
|
|
32
|
+
status: "in-flight",
|
|
33
|
+
docsPath: "integration-guides/facilitator-adapters",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "atxp",
|
|
37
|
+
description: "atxp_ai — x402 facilitator with JWT-claim issuance. Adapter shipped; payment proof validation roadmap.",
|
|
38
|
+
protocols: ["x402"],
|
|
39
|
+
status: "roadmap",
|
|
40
|
+
docsPath: "integration-guides/facilitator-adapters",
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "mcpay",
|
|
44
|
+
description: "MCPay — MCP-native facilitator. Adapter shipped against the wire spec; full integration roadmap.",
|
|
45
|
+
protocols: ["x402", "mcp"],
|
|
46
|
+
status: "roadmap",
|
|
47
|
+
docsPath: "integration-guides/facilitator-adapters",
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
exports.listFacilitatorsTool = {
|
|
51
|
+
name: "agenttrust_list_facilitators",
|
|
52
|
+
description: "List every facilitator adapter shipped in trustgate/server. Each entry " +
|
|
53
|
+
"names the wire protocol(s) it speaks (x402, mcp), its current ship status " +
|
|
54
|
+
"(live / in-flight / roadmap), and the docs path for its walkthrough.",
|
|
55
|
+
inputSchema: InputSchema,
|
|
56
|
+
async handler() {
|
|
57
|
+
return { count: FACILITATORS.length, facilitators: FACILITATORS };
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=list-facilitators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-facilitators.js","sourceRoot":"","sources":["../../../src/tools/read/list-facilitators.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAEH,6BAAwB;AAIxB,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAgBjC,MAAM,YAAY,GAAuB;IACvC;QACE,IAAI,EAAS,QAAQ;QACrB,WAAW,EAAE,wFAAwF;QACrG,SAAS,EAAI,CAAC,MAAM,CAAC;QACrB,MAAM,EAAO,MAAM;QACnB,QAAQ,EAAK,mCAAmC;KACjD;IACD;QACE,IAAI,EAAS,QAAQ;QACrB,WAAW,EAAE,yGAAyG;QACtH,SAAS,EAAI,CAAC,MAAM,CAAC;QACrB,MAAM,EAAO,WAAW;QACxB,QAAQ,EAAK,yCAAyC;KACvD;IACD;QACE,IAAI,EAAS,MAAM;QACnB,WAAW,EAAE,wGAAwG;QACrH,SAAS,EAAI,CAAC,MAAM,CAAC;QACrB,MAAM,EAAO,SAAS;QACtB,QAAQ,EAAK,yCAAyC;KACvD;IACD;QACE,IAAI,EAAS,OAAO;QACpB,WAAW,EAAE,kGAAkG;QAC/G,SAAS,EAAI,CAAC,MAAM,EAAE,KAAK,CAAC;QAC5B,MAAM,EAAO,SAAS;QACtB,QAAQ,EAAK,yCAAyC;KACvD;CACF,CAAC;AAEW,QAAA,oBAAoB,GAAwB;IACvD,IAAI,EAAS,8BAA8B;IAC3C,WAAW,EACT,yEAAyE;QACzE,4EAA4E;QAC5E,sEAAsE;IACxE,WAAW,EAAE,WAAW;IAExB,KAAK,CAAC,OAAO;QACX,OAAO,EAAE,KAAK,EAAE,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;IACpE,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agenttrust_list_policies` — enumerate every PolicyAccount registered
|
|
3
|
+
* for `agent_asset`.
|
|
4
|
+
*
|
|
5
|
+
* Implementation: getProgramAccounts with a memcmp filter at offset 8
|
|
6
|
+
* (the `payer_agent_asset` field — see `state/policy_account.rs:12`).
|
|
7
|
+
* Returns `{ policyId, pda, enabledKindsBitmask, gateMode }` per match
|
|
8
|
+
* — the lightweight summary view; clients call `agenttrust_get_policy`
|
|
9
|
+
* for the full decode.
|
|
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 PolicySummary {
|
|
22
|
+
policyId: number;
|
|
23
|
+
pda: string;
|
|
24
|
+
explorerUrl: string;
|
|
25
|
+
enabledKindsBitmask: number;
|
|
26
|
+
gateMode: number;
|
|
27
|
+
}
|
|
28
|
+
interface Output {
|
|
29
|
+
agentAsset: string;
|
|
30
|
+
policies: PolicySummary[];
|
|
31
|
+
}
|
|
32
|
+
export declare const listPoliciesTool: Tool<Input, Output>;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `agenttrust_list_policies` — enumerate every PolicyAccount registered
|
|
4
|
+
* for `agent_asset`.
|
|
5
|
+
*
|
|
6
|
+
* Implementation: getProgramAccounts with a memcmp filter at offset 8
|
|
7
|
+
* (the `payer_agent_asset` field — see `state/policy_account.rs:12`).
|
|
8
|
+
* Returns `{ policyId, pda, enabledKindsBitmask, gateMode }` per match
|
|
9
|
+
* — the lightweight summary view; clients call `agenttrust_get_policy`
|
|
10
|
+
* for the full decode.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.listPoliciesTool = void 0;
|
|
14
|
+
const zod_1 = require("zod");
|
|
15
|
+
const config_1 = require("../../config");
|
|
16
|
+
const common_1 = require("../common");
|
|
17
|
+
const InputSchema = zod_1.z.object({
|
|
18
|
+
agent_asset: common_1.PubkeySchema.describe("Quantu agent asset pubkey to enumerate policies for"),
|
|
19
|
+
});
|
|
20
|
+
// Anchor `#[account]` discriminator + field layout — payer_agent_asset is
|
|
21
|
+
// the first non-discriminator field, at offset 8.
|
|
22
|
+
const POLICY_FILTER_AGENT_OFFSET = 8;
|
|
23
|
+
exports.listPoliciesTool = {
|
|
24
|
+
name: "agenttrust_list_policies",
|
|
25
|
+
description: "List every PolicyAccount registered on-chain for the given agent_asset. " +
|
|
26
|
+
"Returns a lightweight summary (policy ID, bitmask of enabled policy kinds, " +
|
|
27
|
+
"gate mode). Use agenttrust_get_policy for the full decoded PolicyAccount.",
|
|
28
|
+
inputSchema: InputSchema,
|
|
29
|
+
async handler(input, ctx) {
|
|
30
|
+
const agent = (0, common_1.parsePubkey)(input.agent_asset, "agent_asset");
|
|
31
|
+
const policyVault = await ctx.chain.policyVault();
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
+
const accounts = await policyVault.account.policyAccount.all([
|
|
34
|
+
{ memcmp: { offset: POLICY_FILTER_AGENT_OFFSET, bytes: agent.toBase58() } },
|
|
35
|
+
]);
|
|
36
|
+
const policies = accounts.map(
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
+
(entry) => ({
|
|
39
|
+
policyId: Number(entry.account.policyId ?? 0),
|
|
40
|
+
pda: entry.publicKey.toBase58(),
|
|
41
|
+
explorerUrl: (0, config_1.explorerUrl)(ctx.chain.cfg, "address", entry.publicKey.toBase58()),
|
|
42
|
+
enabledKindsBitmask: Number(entry.account.enabledKindsBitmask ?? 0),
|
|
43
|
+
gateMode: Number(entry.account.gateMode ?? 0),
|
|
44
|
+
}));
|
|
45
|
+
policies.sort((a, b) => a.policyId - b.policyId);
|
|
46
|
+
return { agentAsset: agent.toBase58(), policies };
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=list-policies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-policies.js","sourceRoot":"","sources":["../../../src/tools/read/list-policies.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,6BAAwB;AAExB,yCAA2C;AAC3C,sCAAsD;AAGtD,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,WAAW,EAAE,qBAAY,CAAC,QAAQ,CAAC,qDAAqD,CAAC;CAC1F,CAAC,CAAC;AAgBH,0EAA0E;AAC1E,kDAAkD;AAClD,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAExB,QAAA,gBAAgB,GAAwB;IACnD,IAAI,EAAS,0BAA0B;IACvC,WAAW,EACT,0EAA0E;QAC1E,6EAA6E;QAC7E,2EAA2E;IAC7E,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,WAAW,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;QAClD,8DAA8D;QAC9D,MAAM,QAAQ,GAAG,MAAO,WAAW,CAAC,OAAe,CAAC,aAAa,CAAC,GAAG,CAAC;YACpE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,0BAA0B,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE;SAC5E,CAAC,CAAC;QACH,MAAM,QAAQ,GAAoB,QAAQ,CAAC,GAAG;QAC5C,8DAA8D;QAC9D,CAAC,KAAU,EAAE,EAAE,CAAC,CAAC;YACf,QAAQ,EAAa,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC;YACxD,GAAG,EAAkB,KAAK,CAAC,SAAS,CAAC,QAAQ,EAAE;YAC/C,WAAW,EAAU,IAAA,oBAAW,EAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;YACtF,mBAAmB,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,mBAAmB,IAAI,CAAC,CAAC;YACnE,QAAQ,EAAa,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC;SACzD,CAAC,CACH,CAAC;QACF,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;QACjD,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,CAAC;IACpD,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agenttrust_simulate_payment` — read-only `gate_payment` simulation.
|
|
3
|
+
*
|
|
4
|
+
* Calls the on-chain `gate_payment` instruction in simulate mode and
|
|
5
|
+
* decodes the GateDecision return value. The same call path the
|
|
6
|
+
* Express service's POST /verify route uses for the actual challenge.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import type { Tool } from "../types";
|
|
10
|
+
declare const InputSchema: z.ZodObject<{
|
|
11
|
+
payer_agent: z.ZodEffects<z.ZodString, string, string>;
|
|
12
|
+
payee_agent: z.ZodEffects<z.ZodString, string, string>;
|
|
13
|
+
amount: z.ZodUnion<[z.ZodNumber, z.ZodString]>;
|
|
14
|
+
mint: z.ZodEffects<z.ZodString, string, string>;
|
|
15
|
+
policy_id: z.ZodNumber;
|
|
16
|
+
caller: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
payer_agent: string;
|
|
19
|
+
payee_agent: string;
|
|
20
|
+
amount: string | number;
|
|
21
|
+
mint: string;
|
|
22
|
+
policy_id: number;
|
|
23
|
+
caller?: string | undefined;
|
|
24
|
+
}, {
|
|
25
|
+
payer_agent: string;
|
|
26
|
+
payee_agent: string;
|
|
27
|
+
amount: string | number;
|
|
28
|
+
mint: string;
|
|
29
|
+
policy_id: number;
|
|
30
|
+
caller?: string | undefined;
|
|
31
|
+
}>;
|
|
32
|
+
type Input = z.infer<typeof InputSchema>;
|
|
33
|
+
type DecisionOutput = {
|
|
34
|
+
kind: "Allow";
|
|
35
|
+
} | {
|
|
36
|
+
kind: "Deny";
|
|
37
|
+
reasonCode: number;
|
|
38
|
+
reasonName: string;
|
|
39
|
+
} | {
|
|
40
|
+
kind: "RequireValidation";
|
|
41
|
+
capabilityHashHex: string;
|
|
42
|
+
};
|
|
43
|
+
export declare const simulatePaymentTool: Tool<Input, DecisionOutput>;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `agenttrust_simulate_payment` — read-only `gate_payment` simulation.
|
|
4
|
+
*
|
|
5
|
+
* Calls the on-chain `gate_payment` instruction in simulate mode and
|
|
6
|
+
* decodes the GateDecision return value. The same call path the
|
|
7
|
+
* Express service's POST /verify route uses for the actual challenge.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.simulatePaymentTool = void 0;
|
|
11
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
12
|
+
const zod_1 = require("zod");
|
|
13
|
+
const chain_1 = require("../../chain");
|
|
14
|
+
const common_1 = require("../common");
|
|
15
|
+
const InputSchema = zod_1.z.object({
|
|
16
|
+
payer_agent: common_1.PubkeySchema.describe("Payer Quantu agent asset"),
|
|
17
|
+
payee_agent: common_1.PubkeySchema.describe("Payee Quantu agent asset"),
|
|
18
|
+
amount: zod_1.z.union([zod_1.z.number().int().nonnegative(), zod_1.z.string().regex(/^\d+$/)])
|
|
19
|
+
.describe("Amount in mint base units (u64 as number or decimal string)"),
|
|
20
|
+
mint: common_1.PubkeySchema.describe("SPL or Token-2022 mint pubkey"),
|
|
21
|
+
policy_id: zod_1.z.number().int().min(0).max(0xffffffff).describe("Policy ID to evaluate"),
|
|
22
|
+
caller: common_1.PubkeySchema.optional()
|
|
23
|
+
.describe("Signer pubkey threading the call (defaults to KEYPAIR_B58 signer if set, else throwaway)"),
|
|
24
|
+
});
|
|
25
|
+
exports.simulatePaymentTool = {
|
|
26
|
+
name: "agenttrust_simulate_payment",
|
|
27
|
+
description: "Simulate a payer→payee payment against the PolicyVault. Returns the " +
|
|
28
|
+
"decoded GateDecision: Allow, Deny with stable reasonCode 1..15, or " +
|
|
29
|
+
"RequireValidation with the 32-byte capability hash. No tx is submitted.",
|
|
30
|
+
inputSchema: InputSchema,
|
|
31
|
+
async handler(input, ctx) {
|
|
32
|
+
const policyVault = await ctx.chain.policyVault();
|
|
33
|
+
const callerPubkey = input.caller
|
|
34
|
+
? (0, common_1.parsePubkey)(input.caller, "caller")
|
|
35
|
+
: (ctx.chain.signerPubkey() ?? policyVault.provider.publicKey ?? (0, common_1.parsePubkey)(input.payer_agent, "payer_agent"));
|
|
36
|
+
const decision = await (0, chain_1.simulateGatePayment)({
|
|
37
|
+
policyVault,
|
|
38
|
+
programIds: ctx.chain.cfg.programs,
|
|
39
|
+
caller: callerPubkey,
|
|
40
|
+
payerAgentAsset: (0, common_1.parsePubkey)(input.payer_agent, "payer_agent"),
|
|
41
|
+
payeeAgentAsset: (0, common_1.parsePubkey)(input.payee_agent, "payee_agent"),
|
|
42
|
+
amount: new anchor_1.BN(input.amount.toString()),
|
|
43
|
+
mint: (0, common_1.parsePubkey)(input.mint, "mint"),
|
|
44
|
+
policyId: input.policy_id,
|
|
45
|
+
});
|
|
46
|
+
if (decision.kind === "Allow")
|
|
47
|
+
return { kind: "Allow" };
|
|
48
|
+
if (decision.kind === "Deny") {
|
|
49
|
+
return { kind: "Deny", reasonCode: decision.reasonCode, reasonName: decision.reasonName };
|
|
50
|
+
}
|
|
51
|
+
return { kind: "RequireValidation", capabilityHashHex: (0, common_1.bytesToHex)(decision.capabilityHash) };
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=simulate-payment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simulate-payment.js","sourceRoot":"","sources":["../../../src/tools/read/simulate-payment.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,8CAAuC;AACvC,6BAAwB;AAExB,uCAAkD;AAClD,sCAAkE;AAGlE,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,WAAW,EAAE,qBAAY,CAAC,QAAQ,CAAC,0BAA0B,CAAC;IAC9D,WAAW,EAAE,qBAAY,CAAC,QAAQ,CAAC,0BAA0B,CAAC;IAC9D,MAAM,EAAO,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;SAChE,QAAQ,CAAC,6DAA6D,CAAC;IACxF,IAAI,EAAS,qBAAY,CAAC,QAAQ,CAAC,+BAA+B,CAAC;IACnE,SAAS,EAAI,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,uBAAuB,CAAC;IACtF,MAAM,EAAO,qBAAY,CAAC,QAAQ,EAAE;SACnB,QAAQ,CAAC,0FAA0F,CAAC;CACtH,CAAC,CAAC;AAQU,QAAA,mBAAmB,GAAgC;IAC9D,IAAI,EAAS,6BAA6B;IAC1C,WAA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,CAAC,UAAU,EAAE,CAAC;QAC5F,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,IAAA,mBAAU,EAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;IAC/F,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool descriptor shared across read/write/discovery folders.
|
|
3
|
+
*
|
|
4
|
+
* Each tool exports a single `Tool<T>` whose `inputSchema` is a Zod
|
|
5
|
+
* schema (used for runtime validation) and whose `handler` produces a
|
|
6
|
+
* structured JSON payload. The MCP server adapter turns the payload
|
|
7
|
+
* into a `text` content block — clients can re-parse the JSON if they
|
|
8
|
+
* want structured access.
|
|
9
|
+
*/
|
|
10
|
+
import type { z } from "zod";
|
|
11
|
+
import type { ChainClient } from "../chain";
|
|
12
|
+
export interface ToolContext {
|
|
13
|
+
readonly chain: ChainClient;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* `z.ZodType<TInput, z.ZodTypeDef, any>` — the third generic parameter
|
|
17
|
+
* (Input) intentionally widens to `any` so schemas with `.default()`
|
|
18
|
+
* fields (whose pre-parse Input differs from post-parse Output) satisfy
|
|
19
|
+
* the constraint without a per-tool cast.
|
|
20
|
+
*/
|
|
21
|
+
export interface Tool<TInput, TOutput> {
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly description: string;
|
|
24
|
+
readonly inputSchema: z.ZodType<TInput, z.ZodTypeDef, any>;
|
|
25
|
+
readonly handler: (input: TInput, ctx: ToolContext) => Promise<TOutput>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Helper type that lets call-sites stay generic without leaking Zod
|
|
29
|
+
* specifics.
|
|
30
|
+
*/
|
|
31
|
+
export type AnyTool = Tool<unknown, unknown>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MCP tool descriptor shared across read/write/discovery folders.
|
|
4
|
+
*
|
|
5
|
+
* Each tool exports a single `Tool<T>` whose `inputSchema` is a Zod
|
|
6
|
+
* schema (used for runtime validation) and whose `handler` produces a
|
|
7
|
+
* structured JSON payload. The MCP server adapter turns the payload
|
|
8
|
+
* into a `text` content block — clients can re-parse the JSON if they
|
|
9
|
+
* want structured access.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agenttrust_emit_feedback` — facilitator-only `emit_feedback` CPI.
|
|
3
|
+
*
|
|
4
|
+
* Composes the trustgate.emitFeedback call directly from the MCP tool
|
|
5
|
+
* input. Requires KEYPAIR_B58 to equal the facilitator pubkey
|
|
6
|
+
* (TrustGate enforces `require_keys_eq(payer, facilitator)`). The CPI
|
|
7
|
+
* threads Quantu accounts through `remaining_accounts` per the
|
|
8
|
+
* documented order; the SDK's `deriveQuantuFeedbackAccounts` helper
|
|
9
|
+
* builds them.
|
|
10
|
+
*
|
|
11
|
+
* The signer of this tool MUST also be the facilitator whose
|
|
12
|
+
* `TrustGateAuthority` PDA is being credited.
|
|
13
|
+
*/
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
import type { Tool } from "../types";
|
|
16
|
+
declare const InputSchema: z.ZodObject<{
|
|
17
|
+
payment_id_hash_hex: z.ZodEffects<z.ZodString, string, string>;
|
|
18
|
+
payee_asset: z.ZodEffects<z.ZodString, string, string>;
|
|
19
|
+
base_collection: z.ZodEffects<z.ZodString, string, string>;
|
|
20
|
+
score: z.ZodNumber;
|
|
21
|
+
tag1: z.ZodDefault<z.ZodString>;
|
|
22
|
+
tag2: z.ZodDefault<z.ZodString>;
|
|
23
|
+
endpoint: z.ZodDefault<z.ZodString>;
|
|
24
|
+
feedback_uri: z.ZodDefault<z.ZodString>;
|
|
25
|
+
atom_enabled: z.ZodDefault<z.ZodBoolean>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
payment_id_hash_hex: string;
|
|
28
|
+
payee_asset: string;
|
|
29
|
+
base_collection: string;
|
|
30
|
+
score: number;
|
|
31
|
+
tag1: string;
|
|
32
|
+
tag2: string;
|
|
33
|
+
endpoint: string;
|
|
34
|
+
feedback_uri: string;
|
|
35
|
+
atom_enabled: boolean;
|
|
36
|
+
}, {
|
|
37
|
+
payment_id_hash_hex: string;
|
|
38
|
+
payee_asset: string;
|
|
39
|
+
base_collection: string;
|
|
40
|
+
score: number;
|
|
41
|
+
tag1?: string | undefined;
|
|
42
|
+
tag2?: string | undefined;
|
|
43
|
+
endpoint?: string | undefined;
|
|
44
|
+
feedback_uri?: string | undefined;
|
|
45
|
+
atom_enabled?: boolean | undefined;
|
|
46
|
+
}>;
|
|
47
|
+
type Input = z.infer<typeof InputSchema>;
|
|
48
|
+
interface Output {
|
|
49
|
+
txSignature: string;
|
|
50
|
+
explorerTxUrl: string;
|
|
51
|
+
feedbackLogPda: string;
|
|
52
|
+
feedbackLogExplorer: string;
|
|
53
|
+
}
|
|
54
|
+
export declare const emitFeedbackTool: Tool<Input, Output>;
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `agenttrust_emit_feedback` — facilitator-only `emit_feedback` CPI.
|
|
4
|
+
*
|
|
5
|
+
* Composes the trustgate.emitFeedback call directly from the MCP tool
|
|
6
|
+
* input. Requires KEYPAIR_B58 to equal the facilitator pubkey
|
|
7
|
+
* (TrustGate enforces `require_keys_eq(payer, facilitator)`). The CPI
|
|
8
|
+
* threads Quantu accounts through `remaining_accounts` per the
|
|
9
|
+
* documented order; the SDK's `deriveQuantuFeedbackAccounts` helper
|
|
10
|
+
* builds them.
|
|
11
|
+
*
|
|
12
|
+
* The signer of this tool MUST also be the facilitator whose
|
|
13
|
+
* `TrustGateAuthority` PDA is being credited.
|
|
14
|
+
*/
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.emitFeedbackTool = void 0;
|
|
17
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
18
|
+
const zod_1 = require("zod");
|
|
19
|
+
const trustgate_1 = require("@agenttrust-sdk/trustgate");
|
|
20
|
+
const config_1 = require("../../config");
|
|
21
|
+
const common_1 = require("../common");
|
|
22
|
+
const InputSchema = zod_1.z.object({
|
|
23
|
+
payment_id_hash_hex: common_1.HexHashSchema.describe("32-byte SHA-256 of the payment_id"),
|
|
24
|
+
payee_asset: common_1.PubkeySchema.describe("Quantu agent asset receiving feedback"),
|
|
25
|
+
base_collection: common_1.PubkeySchema.describe("Quantu base_collection pubkey (from demo state)"),
|
|
26
|
+
score: zod_1.z.number().int().min(0).max(100),
|
|
27
|
+
tag1: zod_1.z.string().max(32).default(""),
|
|
28
|
+
tag2: zod_1.z.string().max(32).default(""),
|
|
29
|
+
endpoint: zod_1.z.string().max(64).default(""),
|
|
30
|
+
feedback_uri: zod_1.z.string().max(256).default(""),
|
|
31
|
+
atom_enabled: zod_1.z.boolean().default(true).describe("Whether the agent's atom_enabled flag is set on-chain (drives the optional ATOM 4-tuple)"),
|
|
32
|
+
});
|
|
33
|
+
exports.emitFeedbackTool = {
|
|
34
|
+
name: "agenttrust_emit_feedback",
|
|
35
|
+
description: "Emit ERC-8004 feedback for a confirmed payment. Facilitator-only: " +
|
|
36
|
+
"KEYPAIR_B58 must equal the facilitator wallet whose TrustGateAuthority " +
|
|
37
|
+
"PDA is being signed. Threads Quantu agent_account/atom_stats accounts " +
|
|
38
|
+
"through remaining_accounts. Idempotent on payment_id_hash.",
|
|
39
|
+
inputSchema: InputSchema,
|
|
40
|
+
async handler(input, ctx) {
|
|
41
|
+
const facilitator = ctx.chain.requireSigner();
|
|
42
|
+
const trustgate = await ctx.chain.trustgate();
|
|
43
|
+
const paymentIdHash = (0, common_1.hexToBytes)(input.payment_id_hash_hex);
|
|
44
|
+
if (paymentIdHash.length !== 32)
|
|
45
|
+
throw new Error("payment_id_hash must decode to 32 bytes");
|
|
46
|
+
const payeeAsset = (0, common_1.parsePubkey)(input.payee_asset, "payee_asset");
|
|
47
|
+
const baseCollection = (0, common_1.parsePubkey)(input.base_collection, "base_collection");
|
|
48
|
+
const authorityPda = (0, trustgate_1.deriveTrustGateAuthorityPda)(ctx.chain.cfg.programs.trustgate, facilitator.publicKey);
|
|
49
|
+
const emissionLogPda = (0, trustgate_1.deriveFeedbackLogPda)(ctx.chain.cfg.programs.trustgate, Buffer.from(paymentIdHash));
|
|
50
|
+
const agentAccount = (0, trustgate_1.deriveAgentAccountPda)(ctx.chain.cfg.quantu, payeeAsset);
|
|
51
|
+
// remaining_accounts order documented in
|
|
52
|
+
// programs/trustgate/src/ext/agent_registry.rs::GiveFeedback:
|
|
53
|
+
// 0 agent_account, 1 asset, 2 collection, 3 system_program
|
|
54
|
+
// 4..7 optional ATOM 4-tuple
|
|
55
|
+
const remaining = [
|
|
56
|
+
{ pubkey: agentAccount, isSigner: false, isWritable: true },
|
|
57
|
+
{ pubkey: payeeAsset, isSigner: false, isWritable: false },
|
|
58
|
+
{ pubkey: baseCollection, isSigner: false, isWritable: false },
|
|
59
|
+
{ pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false },
|
|
60
|
+
];
|
|
61
|
+
if (input.atom_enabled) {
|
|
62
|
+
remaining.push({ pubkey: (0, trustgate_1.deriveAtomConfigPda)(ctx.chain.cfg.quantu), isSigner: false, isWritable: false }, { pubkey: (0, trustgate_1.deriveAtomStatsPda)(ctx.chain.cfg.quantu, payeeAsset), isSigner: false, isWritable: true }, { pubkey: ctx.chain.cfg.quantu.atomEngine, isSigner: false, isWritable: false }, { pubkey: (0, trustgate_1.deriveAtomRegistryAuthorityPda)(ctx.chain.cfg.quantu), isSigner: false, isWritable: false });
|
|
63
|
+
}
|
|
64
|
+
const txSignature = await trustgate.methods
|
|
65
|
+
.emitFeedback(Array.from(paymentIdHash), facilitator.publicKey, payeeAsset, input.score, input.tag1, input.tag2, input.endpoint, input.feedback_uri)
|
|
66
|
+
.accounts({
|
|
67
|
+
payer: facilitator.publicKey,
|
|
68
|
+
authority: authorityPda,
|
|
69
|
+
emissionLog: emissionLogPda,
|
|
70
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
72
|
+
})
|
|
73
|
+
.remainingAccounts(remaining)
|
|
74
|
+
.rpc();
|
|
75
|
+
return {
|
|
76
|
+
txSignature,
|
|
77
|
+
explorerTxUrl: (0, config_1.explorerUrl)(ctx.chain.cfg, "tx", txSignature),
|
|
78
|
+
feedbackLogPda: emissionLogPda.toBase58(),
|
|
79
|
+
feedbackLogExplorer: (0, config_1.explorerUrl)(ctx.chain.cfg, "address", emissionLogPda.toBase58()),
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=emit-feedback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit-feedback.js","sourceRoot":"","sources":["../../../src/tools/write/emit-feedback.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAGH,6CAA2D;AAC3D,6BAAwB;AAExB,yDAOmC;AAEnC,yCAA2C;AAC3C,sCAAiF;AAGjF,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,mBAAmB,EAAE,sBAAa,CAAC,QAAQ,CAAC,mCAAmC,CAAC;IAChF,WAAW,EAAU,qBAAY,CAAC,QAAQ,CAAC,uCAAuC,CAAC;IACnF,eAAe,EAAM,qBAAY,CAAC,QAAQ,CAAC,iDAAiD,CAAC;IAC7F,KAAK,EAAgB,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,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y` — initialise a PolicyAccount + VelocityLedger
|
|
3
|
+
* for the caller's `(agent_asset, policy_id)` pair. Requires the
|
|
4
|
+
* PolicyAuthority to already exist with the signer as a member; this
|
|
5
|
+
* tool surfaces a clear error pointing at `init_authority` if not.
|
|
6
|
+
*
|
|
7
|
+
* The full per-kind config is exposed as JSON; sane defaults zero every
|
|
8
|
+
* field so callers can incrementally enable kinds via the bitmask.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import type { Tool } from "../types";
|
|
12
|
+
declare const InputSchema: z.ZodObject<{
|
|
13
|
+
agent_asset: z.ZodEffects<z.ZodString, string, string>;
|
|
14
|
+
policy_id: z.ZodNumber;
|
|
15
|
+
enabled_kinds_bitmask: z.ZodNumber;
|
|
16
|
+
gate_mode: z.ZodDefault<z.ZodNumber>;
|
|
17
|
+
scope_kind: z.ZodDefault<z.ZodNumber>;
|
|
18
|
+
spending: z.ZodDefault<z.ZodObject<{
|
|
19
|
+
per_tx_max: z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
|
|
20
|
+
daily_max: z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
|
|
21
|
+
weekly_max: z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
per_tx_max: string | number;
|
|
24
|
+
daily_max: string | number;
|
|
25
|
+
weekly_max: string | number;
|
|
26
|
+
}, {
|
|
27
|
+
per_tx_max?: string | number | undefined;
|
|
28
|
+
daily_max?: string | number | undefined;
|
|
29
|
+
weekly_max?: string | number | undefined;
|
|
30
|
+
}>>;
|
|
31
|
+
velocity: z.ZodDefault<z.ZodObject<{
|
|
32
|
+
window_secs: z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
|
|
33
|
+
max_in_window: z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
|
|
34
|
+
tier0_decay_factor: z.ZodDefault<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
window_secs: string | number;
|
|
37
|
+
max_in_window: string | number;
|
|
38
|
+
tier0_decay_factor: string | number;
|
|
39
|
+
}, {
|
|
40
|
+
window_secs?: string | number | undefined;
|
|
41
|
+
max_in_window?: string | number | undefined;
|
|
42
|
+
tier0_decay_factor?: string | number | undefined;
|
|
43
|
+
}>>;
|
|
44
|
+
counterparty: z.ZodDefault<z.ZodObject<{
|
|
45
|
+
min_tier: z.ZodDefault<z.ZodNumber>;
|
|
46
|
+
max_risk_score: z.ZodDefault<z.ZodNumber>;
|
|
47
|
+
min_confidence: z.ZodDefault<z.ZodNumber>;
|
|
48
|
+
default_unrated_treatment: z.ZodDefault<z.ZodNumber>;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
min_tier: number;
|
|
51
|
+
max_risk_score: number;
|
|
52
|
+
min_confidence: number;
|
|
53
|
+
default_unrated_treatment: number;
|
|
54
|
+
}, {
|
|
55
|
+
min_tier?: number | undefined;
|
|
56
|
+
max_risk_score?: number | undefined;
|
|
57
|
+
min_confidence?: number | undefined;
|
|
58
|
+
default_unrated_treatment?: number | undefined;
|
|
59
|
+
}>>;
|
|
60
|
+
validation: z.ZodDefault<z.ZodObject<{
|
|
61
|
+
required_capability_hash_hex: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
62
|
+
accepted_attestors: z.ZodDefault<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
63
|
+
}, "strip", z.ZodTypeAny, {
|
|
64
|
+
accepted_attestors: string[];
|
|
65
|
+
required_capability_hash_hex?: string | undefined;
|
|
66
|
+
}, {
|
|
67
|
+
required_capability_hash_hex?: string | undefined;
|
|
68
|
+
accepted_attestors?: string[] | undefined;
|
|
69
|
+
}>>;
|
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
|
71
|
+
policy_id: number;
|
|
72
|
+
validation: {
|
|
73
|
+
accepted_attestors: string[];
|
|
74
|
+
required_capability_hash_hex?: string | undefined;
|
|
75
|
+
};
|
|
76
|
+
agent_asset: string;
|
|
77
|
+
enabled_kinds_bitmask: number;
|
|
78
|
+
gate_mode: number;
|
|
79
|
+
scope_kind: number;
|
|
80
|
+
spending: {
|
|
81
|
+
per_tx_max: string | number;
|
|
82
|
+
daily_max: string | number;
|
|
83
|
+
weekly_max: string | number;
|
|
84
|
+
};
|
|
85
|
+
velocity: {
|
|
86
|
+
window_secs: string | number;
|
|
87
|
+
max_in_window: string | number;
|
|
88
|
+
tier0_decay_factor: string | number;
|
|
89
|
+
};
|
|
90
|
+
counterparty: {
|
|
91
|
+
min_tier: number;
|
|
92
|
+
max_risk_score: number;
|
|
93
|
+
min_confidence: number;
|
|
94
|
+
default_unrated_treatment: number;
|
|
95
|
+
};
|
|
96
|
+
}, {
|
|
97
|
+
policy_id: number;
|
|
98
|
+
agent_asset: string;
|
|
99
|
+
enabled_kinds_bitmask: number;
|
|
100
|
+
validation?: {
|
|
101
|
+
required_capability_hash_hex?: string | undefined;
|
|
102
|
+
accepted_attestors?: string[] | undefined;
|
|
103
|
+
} | undefined;
|
|
104
|
+
gate_mode?: number | undefined;
|
|
105
|
+
scope_kind?: number | undefined;
|
|
106
|
+
spending?: {
|
|
107
|
+
per_tx_max?: string | number | undefined;
|
|
108
|
+
daily_max?: string | number | undefined;
|
|
109
|
+
weekly_max?: string | number | undefined;
|
|
110
|
+
} | undefined;
|
|
111
|
+
velocity?: {
|
|
112
|
+
window_secs?: string | number | undefined;
|
|
113
|
+
max_in_window?: string | number | undefined;
|
|
114
|
+
tier0_decay_factor?: string | number | undefined;
|
|
115
|
+
} | undefined;
|
|
116
|
+
counterparty?: {
|
|
117
|
+
min_tier?: number | undefined;
|
|
118
|
+
max_risk_score?: number | undefined;
|
|
119
|
+
min_confidence?: number | undefined;
|
|
120
|
+
default_unrated_treatment?: number | undefined;
|
|
121
|
+
} | undefined;
|
|
122
|
+
}>;
|
|
123
|
+
type Input = z.infer<typeof InputSchema>;
|
|
124
|
+
interface Output {
|
|
125
|
+
txSignature: string;
|
|
126
|
+
explorerTxUrl: string;
|
|
127
|
+
policyPda: string;
|
|
128
|
+
policyExplorer: string;
|
|
129
|
+
velocityPda: string;
|
|
130
|
+
velocityExplorer: string;
|
|
131
|
+
}
|
|
132
|
+
export declare const initPolicyTool: Tool<Input, Output>;
|
|
133
|
+
export {};
|