@agenticvault/agentic-vault 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/.claude-plugin/plugin.json +19 -0
- package/.env.example +16 -0
- package/.mcp.json.example +18 -0
- package/LICENSE +21 -0
- package/README.ja.md +163 -0
- package/README.ko.md +163 -0
- package/README.md +161 -0
- package/README.zh-CN.md +163 -0
- package/README.zh-TW.md +163 -0
- package/dist/agentic/audit/logger.d.ts +7 -0
- package/dist/agentic/audit/logger.js +19 -0
- package/dist/agentic/audit/logger.js.map +1 -0
- package/dist/agentic/audit/types.d.ts +11 -0
- package/dist/agentic/audit/types.js +2 -0
- package/dist/agentic/audit/types.js.map +1 -0
- package/dist/agentic/cli.d.ts +8 -0
- package/dist/agentic/cli.js +87 -0
- package/dist/agentic/cli.js.map +1 -0
- package/dist/agentic/index.d.ts +5 -0
- package/dist/agentic/index.js +7 -0
- package/dist/agentic/index.js.map +1 -0
- package/dist/agentic/mcp/server.d.ts +8 -0
- package/dist/agentic/mcp/server.js +25 -0
- package/dist/agentic/mcp/server.js.map +1 -0
- package/dist/agentic/mcp/tools/decoded-call-pipeline.d.ts +14 -0
- package/dist/agentic/mcp/tools/decoded-call-pipeline.js +18 -0
- package/dist/agentic/mcp/tools/decoded-call-pipeline.js.map +1 -0
- package/dist/agentic/mcp/tools/get-address.d.ts +3 -0
- package/dist/agentic/mcp/tools/get-address.js +25 -0
- package/dist/agentic/mcp/tools/get-address.js.map +1 -0
- package/dist/agentic/mcp/tools/health-check.d.ts +3 -0
- package/dist/agentic/mcp/tools/health-check.js +25 -0
- package/dist/agentic/mcp/tools/health-check.js.map +1 -0
- package/dist/agentic/mcp/tools/index.d.ts +7 -0
- package/dist/agentic/mcp/tools/index.js +21 -0
- package/dist/agentic/mcp/tools/index.js.map +1 -0
- package/dist/agentic/mcp/tools/result-adapter.d.ts +10 -0
- package/dist/agentic/mcp/tools/result-adapter.js +15 -0
- package/dist/agentic/mcp/tools/result-adapter.js.map +1 -0
- package/dist/agentic/mcp/tools/shared.d.ts +71 -0
- package/dist/agentic/mcp/tools/shared.js +12 -0
- package/dist/agentic/mcp/tools/shared.js.map +1 -0
- package/dist/agentic/mcp/tools/sign-defi-call.d.ts +3 -0
- package/dist/agentic/mcp/tools/sign-defi-call.js +23 -0
- package/dist/agentic/mcp/tools/sign-defi-call.js.map +1 -0
- package/dist/agentic/mcp/tools/sign-permit.d.ts +3 -0
- package/dist/agentic/mcp/tools/sign-permit.js +39 -0
- package/dist/agentic/mcp/tools/sign-permit.js.map +1 -0
- package/dist/agentic/mcp/tools/sign-swap.d.ts +3 -0
- package/dist/agentic/mcp/tools/sign-swap.js +23 -0
- package/dist/agentic/mcp/tools/sign-swap.js.map +1 -0
- package/dist/agentic/mcp/tools/sign-transaction.d.ts +3 -0
- package/dist/agentic/mcp/tools/sign-transaction.js +68 -0
- package/dist/agentic/mcp/tools/sign-transaction.js.map +1 -0
- package/dist/agentic/mcp/tools/sign-typed-data.d.ts +3 -0
- package/dist/agentic/mcp/tools/sign-typed-data.js +50 -0
- package/dist/agentic/mcp/tools/sign-typed-data.js.map +1 -0
- package/dist/agentic/policy/engine.d.ts +2 -0
- package/dist/agentic/policy/engine.js +3 -0
- package/dist/agentic/policy/engine.js.map +1 -0
- package/dist/agentic/policy/types.d.ts +2 -0
- package/dist/agentic/policy/types.js +2 -0
- package/dist/agentic/policy/types.js.map +1 -0
- package/dist/cli/commands/decode.d.ts +1 -0
- package/dist/cli/commands/decode.js +51 -0
- package/dist/cli/commands/decode.js.map +1 -0
- package/dist/cli/commands/dry-run.d.ts +2 -0
- package/dist/cli/commands/dry-run.js +56 -0
- package/dist/cli/commands/dry-run.js.map +1 -0
- package/dist/cli/commands/encode.d.ts +1 -0
- package/dist/cli/commands/encode.js +77 -0
- package/dist/cli/commands/encode.js.map +1 -0
- package/dist/cli/commands/get-address.d.ts +3 -0
- package/dist/cli/commands/get-address.js +26 -0
- package/dist/cli/commands/get-address.js.map +1 -0
- package/dist/cli/commands/health.d.ts +3 -0
- package/dist/cli/commands/health.js +26 -0
- package/dist/cli/commands/health.js.map +1 -0
- package/dist/cli/commands/mcp.d.ts +6 -0
- package/dist/cli/commands/mcp.js +40 -0
- package/dist/cli/commands/mcp.js.map +1 -0
- package/dist/cli/commands/sign-permit.d.ts +2 -0
- package/dist/cli/commands/sign-permit.js +110 -0
- package/dist/cli/commands/sign-permit.js.map +1 -0
- package/dist/cli/commands/sign.d.ts +2 -0
- package/dist/cli/commands/sign.js +82 -0
- package/dist/cli/commands/sign.js.map +1 -0
- package/dist/cli/context.d.ts +10 -0
- package/dist/cli/context.js +84 -0
- package/dist/cli/context.js.map +1 -0
- package/dist/cli/formatters.d.ts +18 -0
- package/dist/cli/formatters.js +74 -0
- package/dist/cli/formatters.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +108 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/evm-signer-adapter.d.ts +42 -0
- package/dist/core/evm-signer-adapter.js +92 -0
- package/dist/core/evm-signer-adapter.js.map +1 -0
- package/dist/core/signing-provider.d.ts +14 -0
- package/dist/core/signing-provider.js +2 -0
- package/dist/core/signing-provider.js.map +1 -0
- package/dist/crypto/evm-signer.util.d.ts +43 -0
- package/dist/crypto/evm-signer.util.js +151 -0
- package/dist/crypto/evm-signer.util.js.map +1 -0
- package/dist/evm-signer.util.d.ts +1 -0
- package/dist/evm-signer.util.js +4 -0
- package/dist/evm-signer.util.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/kms-client.d.ts +1 -0
- package/dist/kms-client.js +4 -0
- package/dist/kms-client.js.map +1 -0
- package/dist/kms-signer.d.ts +1 -0
- package/dist/kms-signer.js +4 -0
- package/dist/kms-signer.js.map +1 -0
- package/dist/protocols/catalog.d.ts +310 -0
- package/dist/protocols/catalog.js +162 -0
- package/dist/protocols/catalog.js.map +1 -0
- package/dist/protocols/decoders/aave-v3.d.ts +2 -0
- package/dist/protocols/decoders/aave-v3.js +105 -0
- package/dist/protocols/decoders/aave-v3.js.map +1 -0
- package/dist/protocols/decoders/erc20.d.ts +2 -0
- package/dist/protocols/decoders/erc20.js +51 -0
- package/dist/protocols/decoders/erc20.js.map +1 -0
- package/dist/protocols/decoders/uniswap-v3.d.ts +2 -0
- package/dist/protocols/decoders/uniswap-v3.js +57 -0
- package/dist/protocols/decoders/uniswap-v3.js.map +1 -0
- package/dist/protocols/dispatcher.d.ts +8 -0
- package/dist/protocols/dispatcher.js +32 -0
- package/dist/protocols/dispatcher.js.map +1 -0
- package/dist/protocols/index.d.ts +16 -0
- package/dist/protocols/index.js +19 -0
- package/dist/protocols/index.js.map +1 -0
- package/dist/protocols/policy/engine.d.ts +11 -0
- package/dist/protocols/policy/engine.js +67 -0
- package/dist/protocols/policy/engine.js.map +1 -0
- package/dist/protocols/policy/evaluators/aave-v3.d.ts +2 -0
- package/dist/protocols/policy/evaluators/aave-v3.js +118 -0
- package/dist/protocols/policy/evaluators/aave-v3.js.map +1 -0
- package/dist/protocols/policy/evaluators/erc20.d.ts +2 -0
- package/dist/protocols/policy/evaluators/erc20.js +55 -0
- package/dist/protocols/policy/evaluators/erc20.js.map +1 -0
- package/dist/protocols/policy/evaluators/uniswap-v3.d.ts +2 -0
- package/dist/protocols/policy/evaluators/uniswap-v3.js +46 -0
- package/dist/protocols/policy/evaluators/uniswap-v3.js.map +1 -0
- package/dist/protocols/policy/loader.d.ts +11 -0
- package/dist/protocols/policy/loader.js +70 -0
- package/dist/protocols/policy/loader.js.map +1 -0
- package/dist/protocols/policy/types.d.ts +38 -0
- package/dist/protocols/policy/types.js +2 -0
- package/dist/protocols/policy/types.js.map +1 -0
- package/dist/protocols/registry.d.ts +21 -0
- package/dist/protocols/registry.js +52 -0
- package/dist/protocols/registry.js.map +1 -0
- package/dist/protocols/types.d.ts +90 -0
- package/dist/protocols/types.js +2 -0
- package/dist/protocols/types.js.map +1 -0
- package/dist/protocols/workflows/get-address.d.ts +2 -0
- package/dist/protocols/workflows/get-address.js +41 -0
- package/dist/protocols/workflows/get-address.js.map +1 -0
- package/dist/protocols/workflows/health-check.d.ts +2 -0
- package/dist/protocols/workflows/health-check.js +41 -0
- package/dist/protocols/workflows/health-check.js.map +1 -0
- package/dist/protocols/workflows/index.d.ts +5 -0
- package/dist/protocols/workflows/index.js +5 -0
- package/dist/protocols/workflows/index.js.map +1 -0
- package/dist/protocols/workflows/sign-defi-call.d.ts +14 -0
- package/dist/protocols/workflows/sign-defi-call.js +157 -0
- package/dist/protocols/workflows/sign-defi-call.js.map +1 -0
- package/dist/protocols/workflows/sign-permit.d.ts +21 -0
- package/dist/protocols/workflows/sign-permit.js +320 -0
- package/dist/protocols/workflows/sign-permit.js.map +1 -0
- package/dist/protocols/workflows/types.d.ts +79 -0
- package/dist/protocols/workflows/types.js +2 -0
- package/dist/protocols/workflows/types.js.map +1 -0
- package/dist/provider/factory.d.ts +12 -0
- package/dist/provider/factory.js +19 -0
- package/dist/provider/factory.js.map +1 -0
- package/dist/providers/aws-kms/aws-kms-client.d.ts +19 -0
- package/dist/providers/aws-kms/aws-kms-client.js +47 -0
- package/dist/providers/aws-kms/aws-kms-client.js.map +1 -0
- package/dist/providers/aws-kms/aws-kms-provider.d.ts +17 -0
- package/dist/providers/aws-kms/aws-kms-provider.js +40 -0
- package/dist/providers/aws-kms/aws-kms-provider.js.map +1 -0
- package/dist/providers/aws-kms/index.d.ts +3 -0
- package/dist/providers/aws-kms/index.js +4 -0
- package/dist/providers/aws-kms/index.js.map +1 -0
- package/dist/providers/aws-kms/kms-signer-adapter.d.ts +41 -0
- package/dist/providers/aws-kms/kms-signer-adapter.js +101 -0
- package/dist/providers/aws-kms/kms-signer-adapter.js.map +1 -0
- package/dist/types.d.ts +13 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +109 -0
- package/policy.example.json +43 -0
- package/skills/audit-log/SKILL.md +32 -0
- package/skills/check-wallet/SKILL.md +23 -0
- package/skills/sign-permit/SKILL.md +29 -0
- package/skills/sign-swap/SKILL.md +29 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { hashTypedData, keccak256, serializeTransaction, toHex, } from 'viem';
|
|
2
|
+
import { normalizeSignature, parseDerSignature, publicToAddress, resolveRecoveryParam, } from '../../evm-signer.util.js';
|
|
3
|
+
export class KmsSignerAdapter {
|
|
4
|
+
keyId;
|
|
5
|
+
expectedAddress;
|
|
6
|
+
kmsClient;
|
|
7
|
+
addressPromise = null;
|
|
8
|
+
constructor(kmsClient, config) {
|
|
9
|
+
this.kmsClient = kmsClient;
|
|
10
|
+
this.keyId = config.keyId;
|
|
11
|
+
this.expectedAddress = config.expectedAddress;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get the Ethereum address derived from the KMS public key.
|
|
15
|
+
* Uses promise memoization to avoid concurrent GetPublicKey calls during cold start.
|
|
16
|
+
*/
|
|
17
|
+
getAddress() {
|
|
18
|
+
if (!this.addressPromise) {
|
|
19
|
+
this.addressPromise = this.deriveAddress();
|
|
20
|
+
}
|
|
21
|
+
return this.addressPromise;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Sign a transaction: serialize -> keccak256 -> KMS sign -> DER decode -> assemble signed tx.
|
|
25
|
+
*/
|
|
26
|
+
async signTransaction(tx) {
|
|
27
|
+
const serialized = serializeTransaction(tx);
|
|
28
|
+
const digest = keccak256(serialized, 'bytes');
|
|
29
|
+
const { r, s, yParity } = await this.signDigestAndRecover(digest);
|
|
30
|
+
return serializeTransaction(tx, {
|
|
31
|
+
r: toHex(r, { size: 32 }),
|
|
32
|
+
s: toHex(s, { size: 32 }),
|
|
33
|
+
yParity,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Sign EIP-712 typed data. Returns {v, r, s} for permit-style calls.
|
|
38
|
+
* v = yParity + 27 (legacy recovery id format expected by EIP-2612 selfPermit).
|
|
39
|
+
*/
|
|
40
|
+
async signTypedData(params) {
|
|
41
|
+
const hash = hashTypedData(params);
|
|
42
|
+
const digest = hexToBytes(hash);
|
|
43
|
+
const { r, s, yParity } = await this.signDigestAndRecover(digest);
|
|
44
|
+
return {
|
|
45
|
+
v: yParity + 27,
|
|
46
|
+
r: toHex(r, { size: 32 }),
|
|
47
|
+
s: toHex(s, { size: 32 }),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Health check: verify KMS key is configured correctly and address matches expectations.
|
|
52
|
+
*/
|
|
53
|
+
async healthCheck() {
|
|
54
|
+
// 1. Verify key metadata
|
|
55
|
+
const metadata = await this.kmsClient.describeKey(this.keyId);
|
|
56
|
+
if (metadata.keySpec !== 'ECC_SECG_P256K1') {
|
|
57
|
+
throw new Error(`KMS key has invalid KeySpec: ${metadata.keySpec}, expected ECC_SECG_P256K1`);
|
|
58
|
+
}
|
|
59
|
+
if (metadata.keyUsage !== 'SIGN_VERIFY') {
|
|
60
|
+
throw new Error(`KMS key has invalid KeyUsage: ${metadata.keyUsage}, expected SIGN_VERIFY`);
|
|
61
|
+
}
|
|
62
|
+
if (metadata.keyState !== 'Enabled') {
|
|
63
|
+
throw new Error(`KMS key is not enabled: ${metadata.keyState}`);
|
|
64
|
+
}
|
|
65
|
+
// 2. Verify derived address matches expected address (if configured)
|
|
66
|
+
if (this.expectedAddress) {
|
|
67
|
+
const derivedAddress = await this.getAddress();
|
|
68
|
+
if (derivedAddress.toLowerCase() !== this.expectedAddress.toLowerCase()) {
|
|
69
|
+
throw new Error(`KMS derived address ${derivedAddress} does not match expected ${this.expectedAddress}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Internal: sign a 32-byte digest via KMS and resolve the recovery parameter.
|
|
75
|
+
*/
|
|
76
|
+
async signDigestAndRecover(digest) {
|
|
77
|
+
const address = await this.getAddress();
|
|
78
|
+
const derSignature = await this.kmsClient.signDigest(this.keyId, digest);
|
|
79
|
+
const { r, s: rawS } = parseDerSignature(derSignature);
|
|
80
|
+
const { r: normalizedR, s } = normalizeSignature(r, rawS);
|
|
81
|
+
const yParity = await resolveRecoveryParam(digest, normalizedR, s, address);
|
|
82
|
+
return { r: normalizedR, s, yParity };
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Internal: derive address from KMS public key.
|
|
86
|
+
*/
|
|
87
|
+
async deriveAddress() {
|
|
88
|
+
const publicKey = await this.kmsClient.getPublicKey(this.keyId);
|
|
89
|
+
return publicToAddress(publicKey);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** Convert a 0x-prefixed hex string to Uint8Array */
|
|
93
|
+
function hexToBytes(hex) {
|
|
94
|
+
const stripped = hex.startsWith('0x') ? hex.slice(2) : hex;
|
|
95
|
+
const bytes = new Uint8Array(stripped.length / 2);
|
|
96
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
97
|
+
bytes[i] = parseInt(stripped.slice(i * 2, i * 2 + 2), 16);
|
|
98
|
+
}
|
|
99
|
+
return bytes;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=kms-signer-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kms-signer-adapter.js","sourceRoot":"","sources":["../../../src/providers/aws-kms/kms-signer-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,aAAa,EACb,SAAS,EACT,oBAAoB,EACpB,KAAK,GACN,MAAM,MAAM,CAAC;AAGd,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAQlC,MAAM,OAAO,gBAAgB;IACV,KAAK,CAAS;IACd,eAAe,CAAW;IAC1B,SAAS,CAAa;IAC/B,cAAc,GAA4B,IAAI,CAAC;IAEvD,YAAY,SAAqB,EAAE,MAAuB;QACxD,IAAI,CAAC,SAAS,GAAG,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|
1
|
+
import type { Address, Hex, TransactionSerializable, TypedDataDefinition } from 'viem';
|
|
2
|
+
export type SignatureComponents = {
|
|
3
|
+
v: number;
|
|
4
|
+
r: Hex;
|
|
5
|
+
s: Hex;
|
|
6
|
+
};
|
|
7
|
+
export type SignTypedDataParams = TypedDataDefinition;
|
|
8
|
+
export interface SignerAdapter {
|
|
9
|
+
getAddress(): Promise<Address>;
|
|
10
|
+
signTransaction(tx: TransactionSerializable): Promise<Hex>;
|
|
11
|
+
signTypedData(params: SignTypedDataParams): Promise<SignatureComponents>;
|
|
12
|
+
healthCheck(): Promise<void>;
|
|
13
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agenticvault/agentic-vault",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Server-side EVM signing with AWS KMS and built-in DeFi protocol awareness. Expose your wallet to AI agents via MCP, CLI, or OpenClaw.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./protocols": {
|
|
14
|
+
"types": "./dist/protocols/index.d.ts",
|
|
15
|
+
"import": "./dist/protocols/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./agentic": {
|
|
18
|
+
"types": "./dist/agentic/index.d.ts",
|
|
19
|
+
"import": "./dist/agentic/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"!dist/.tsbuildinfo",
|
|
25
|
+
"README.md",
|
|
26
|
+
"LICENSE",
|
|
27
|
+
".claude-plugin",
|
|
28
|
+
"skills",
|
|
29
|
+
".mcp.json.example",
|
|
30
|
+
"policy.example.json",
|
|
31
|
+
".env.example"
|
|
32
|
+
],
|
|
33
|
+
"bin": {
|
|
34
|
+
"agentic-vault": "./dist/cli/index.js",
|
|
35
|
+
"agentic-vault-mcp": "./dist/agentic/cli.js"
|
|
36
|
+
},
|
|
37
|
+
"packageManager": "pnpm@10.29.1",
|
|
38
|
+
"sideEffects": false,
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=24"
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/agenticvault/agentic-vault"
|
|
45
|
+
},
|
|
46
|
+
"license": "MIT",
|
|
47
|
+
"keywords": [
|
|
48
|
+
"agentic",
|
|
49
|
+
"vault",
|
|
50
|
+
"wallet",
|
|
51
|
+
"aws",
|
|
52
|
+
"kms",
|
|
53
|
+
"cdp",
|
|
54
|
+
"ethereum",
|
|
55
|
+
"signer",
|
|
56
|
+
"evm",
|
|
57
|
+
"secp256k1",
|
|
58
|
+
"eip-712",
|
|
59
|
+
"typed-data",
|
|
60
|
+
"viem",
|
|
61
|
+
"server-wallet",
|
|
62
|
+
"mcp",
|
|
63
|
+
"ai-agent",
|
|
64
|
+
"claude-code",
|
|
65
|
+
"defi",
|
|
66
|
+
"uniswap",
|
|
67
|
+
"aave",
|
|
68
|
+
"openclaw",
|
|
69
|
+
"protocol-decoder",
|
|
70
|
+
"policy-engine"
|
|
71
|
+
],
|
|
72
|
+
"bugs": {
|
|
73
|
+
"url": "https://github.com/agenticvault/agentic-vault/issues"
|
|
74
|
+
},
|
|
75
|
+
"homepage": "https://github.com/agenticvault/agentic-vault#readme",
|
|
76
|
+
"publishConfig": {
|
|
77
|
+
"access": "public",
|
|
78
|
+
"registry": "https://registry.npmjs.org"
|
|
79
|
+
},
|
|
80
|
+
"scripts": {
|
|
81
|
+
"build": "tsc -b",
|
|
82
|
+
"typecheck": "tsc -p tsconfig.check.json",
|
|
83
|
+
"lint": "eslint src/ test/",
|
|
84
|
+
"lint:fix": "eslint src/ test/ --fix",
|
|
85
|
+
"test": "vitest run",
|
|
86
|
+
"test:unit": "vitest run test/unit",
|
|
87
|
+
"test:integration": "vitest run test/integration",
|
|
88
|
+
"test:e2e": "vitest run test/e2e",
|
|
89
|
+
"test:coverage": "vitest run test/unit --coverage",
|
|
90
|
+
"prepack": "pnpm build"
|
|
91
|
+
},
|
|
92
|
+
"dependencies": {
|
|
93
|
+
"@aws-sdk/client-kms": "^3.985.0",
|
|
94
|
+
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
95
|
+
"viem": "^2.45.1",
|
|
96
|
+
"zod": "^4.3.6"
|
|
97
|
+
},
|
|
98
|
+
"devDependencies": {
|
|
99
|
+
"@eslint/js": "^9.39.2",
|
|
100
|
+
"@types/node": "^25.2.1",
|
|
101
|
+
"dotenv": "^17.2.4",
|
|
102
|
+
"eslint": "^9.39.2",
|
|
103
|
+
"tsx": "^4.19.4",
|
|
104
|
+
"typescript": "^5.9.3",
|
|
105
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
106
|
+
"typescript-eslint": "^8.55.0",
|
|
107
|
+
"vitest": "^4.0.18"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"allowedChainIds": [1, 11155111],
|
|
3
|
+
"allowedContracts": [
|
|
4
|
+
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
5
|
+
"0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45",
|
|
6
|
+
"0x87870bca3f3fd6335c3f4ce8392d69350b4fa4e2"
|
|
7
|
+
],
|
|
8
|
+
"allowedSelectors": [
|
|
9
|
+
"0x095ea7b3",
|
|
10
|
+
"0xa9059cbb",
|
|
11
|
+
"0x04e45aaf",
|
|
12
|
+
"0x617ba037",
|
|
13
|
+
"0xa415bcad",
|
|
14
|
+
"0x573ade81",
|
|
15
|
+
"0x69328dec"
|
|
16
|
+
],
|
|
17
|
+
"maxAmountWei": "1000000000000000000",
|
|
18
|
+
"maxDeadlineSeconds": 1800,
|
|
19
|
+
"protocolPolicies": {
|
|
20
|
+
"erc20": {
|
|
21
|
+
"maxAllowanceWei": "1000000000000000000",
|
|
22
|
+
"tokenAllowlist": [
|
|
23
|
+
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
"uniswap_v3": {
|
|
27
|
+
"maxSlippageBps": 100,
|
|
28
|
+
"tokenAllowlist": [
|
|
29
|
+
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
30
|
+
"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
|
|
31
|
+
],
|
|
32
|
+
"recipientAllowlist": []
|
|
33
|
+
},
|
|
34
|
+
"aave_v3": {
|
|
35
|
+
"tokenAllowlist": [
|
|
36
|
+
"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
|
|
37
|
+
],
|
|
38
|
+
"maxInterestRateMode": 2,
|
|
39
|
+
"maxAmountWei": "1000000000000000000",
|
|
40
|
+
"recipientAllowlist": []
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Audit Log
|
|
2
|
+
|
|
3
|
+
Review and analyze audit logs from the Agentic Vault MCP server.
|
|
4
|
+
|
|
5
|
+
## When to use
|
|
6
|
+
|
|
7
|
+
Use this skill when the user wants to:
|
|
8
|
+
- Review past signing operations
|
|
9
|
+
- Check audit trail for security review
|
|
10
|
+
- Analyze transaction signing history
|
|
11
|
+
|
|
12
|
+
## Instructions
|
|
13
|
+
|
|
14
|
+
1. Audit logs are written to stderr by the MCP server in JSON format.
|
|
15
|
+
2. Each log entry contains:
|
|
16
|
+
- `timestamp`: When the operation occurred
|
|
17
|
+
- `traceId`: Unique trace identifier
|
|
18
|
+
- `service`: Always 'agentic-vault-mcp'
|
|
19
|
+
- `action`: The tool name (e.g., 'sign_swap')
|
|
20
|
+
- `who`: Caller identity
|
|
21
|
+
- `what`: Description of the operation
|
|
22
|
+
- `why`: Context/reason
|
|
23
|
+
- `result`: 'approved', 'denied', or 'error'
|
|
24
|
+
- `details`: Additional operation details
|
|
25
|
+
|
|
26
|
+
3. Logs never contain private keys, secrets, or full addresses.
|
|
27
|
+
|
|
28
|
+
## Example
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
Review the audit logs to show all recent signing operations and their results.
|
|
32
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Check Wallet
|
|
2
|
+
|
|
3
|
+
Check the wallet address and health status through the Agentic Vault MCP server.
|
|
4
|
+
|
|
5
|
+
## When to use
|
|
6
|
+
|
|
7
|
+
Use this skill when the user wants to:
|
|
8
|
+
- View their wallet address
|
|
9
|
+
- Verify KMS key configuration
|
|
10
|
+
- Check wallet health status
|
|
11
|
+
|
|
12
|
+
## Instructions
|
|
13
|
+
|
|
14
|
+
1. Use the `get_address` MCP tool to retrieve the wallet's Ethereum address.
|
|
15
|
+
2. Use the `health_check` MCP tool to verify the KMS key configuration is valid.
|
|
16
|
+
|
|
17
|
+
3. Never import or access signing keys directly. Always use the MCP tools.
|
|
18
|
+
|
|
19
|
+
## Example
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
Use get_address to show the wallet address, then use health_check to verify the setup.
|
|
23
|
+
```
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Sign Permit
|
|
2
|
+
|
|
3
|
+
Sign an EIP-2612 permit through the Agentic Vault MCP server.
|
|
4
|
+
|
|
5
|
+
## When to use
|
|
6
|
+
|
|
7
|
+
Use this skill when the user wants to sign a gasless token approval (EIP-2612 permit).
|
|
8
|
+
|
|
9
|
+
## Instructions
|
|
10
|
+
|
|
11
|
+
1. Use the `sign_permit` MCP tool with the following parameters:
|
|
12
|
+
- `chainId`: The target chain ID
|
|
13
|
+
- `token`: The ERC-20 token contract address
|
|
14
|
+
- `spender`: The approved spender address
|
|
15
|
+
- `value`: The approval amount in token units (string)
|
|
16
|
+
- `deadline`: Unix timestamp for permit expiry
|
|
17
|
+
- `domain`: The EIP-712 domain object
|
|
18
|
+
- `types`: The EIP-712 types definition
|
|
19
|
+
- `message`: The EIP-712 message object
|
|
20
|
+
|
|
21
|
+
2. The tool enforces policy constraints before signing.
|
|
22
|
+
|
|
23
|
+
3. Never import or access signing keys directly. Always use the MCP tool.
|
|
24
|
+
|
|
25
|
+
## Example
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
Use the sign_permit tool to approve 1000 USDC for spender 0x... on chain 1
|
|
29
|
+
```
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Sign Swap
|
|
2
|
+
|
|
3
|
+
Sign a swap transaction through the Agentic Vault MCP server.
|
|
4
|
+
|
|
5
|
+
## When to use
|
|
6
|
+
|
|
7
|
+
Use this skill when the user wants to sign a token swap transaction on a supported chain.
|
|
8
|
+
|
|
9
|
+
## Instructions
|
|
10
|
+
|
|
11
|
+
1. Use the `sign_swap` MCP tool with the following parameters:
|
|
12
|
+
- `chainId`: The target chain ID (e.g., 1 for Ethereum mainnet)
|
|
13
|
+
- `to`: The DEX router contract address
|
|
14
|
+
- `data`: The encoded swap calldata
|
|
15
|
+
- `value`: (Optional) ETH value in wei
|
|
16
|
+
|
|
17
|
+
2. The tool enforces policy constraints:
|
|
18
|
+
- Chain ID must be whitelisted
|
|
19
|
+
- Contract must be whitelisted
|
|
20
|
+
- Function selector must be whitelisted
|
|
21
|
+
- Transaction value must be within limits
|
|
22
|
+
|
|
23
|
+
3. Never import or access signing keys directly. Always use the MCP tool.
|
|
24
|
+
|
|
25
|
+
## Example
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
Use the sign_swap tool to sign a swap on chain 1 to router 0x... with calldata 0x...
|
|
29
|
+
```
|