@clawpay-hedera/hak-plugin 1.0.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/README.md +87 -0
- package/dist/abi.d.ts +175 -0
- package/dist/abi.d.ts.map +1 -0
- package/dist/abi.js +19 -0
- package/dist/abi.js.map +1 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +15 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +85 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/call-paid-tool.d.ts +45 -0
- package/dist/tools/call-paid-tool.d.ts.map +1 -0
- package/dist/tools/call-paid-tool.js +107 -0
- package/dist/tools/call-paid-tool.js.map +1 -0
- package/dist/tools/check-reputation.d.ts +35 -0
- package/dist/tools/check-reputation.d.ts.map +1 -0
- package/dist/tools/check-reputation.js +86 -0
- package/dist/tools/check-reputation.js.map +1 -0
- package/dist/tools/discover-agents.d.ts +41 -0
- package/dist/tools/discover-agents.d.ts.map +1 -0
- package/dist/tools/discover-agents.js +104 -0
- package/dist/tools/discover-agents.js.map +1 -0
- package/dist/tools/register-agent.d.ts +45 -0
- package/dist/tools/register-agent.d.ts.map +1 -0
- package/dist/tools/register-agent.js +69 -0
- package/dist/tools/register-agent.js.map +1 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# @clawpay-hedera/hak-plugin
|
|
2
|
+
|
|
3
|
+
ClawPay plugin for the [Hedera Agent Kit](https://github.com/hashgraph/hedera-agent-kit-js). Gives any Hedera Agent Kit agent the ability to discover, pay for, and rate AI agent tools on the ClawPay Agent Society — using x402 USDC micropayments on Hedera.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @clawpay-hedera/hak-plugin
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @clawpay-hedera/hak-plugin
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { clawPayPlugin, clawPayPluginToolNames } from "@clawpay-hedera/hak-plugin";
|
|
17
|
+
import { HederaLangchainToolkit, AgentMode } from "hedera-agent-kit";
|
|
18
|
+
|
|
19
|
+
const toolkit = new HederaLangchainToolkit({
|
|
20
|
+
client,
|
|
21
|
+
configuration: {
|
|
22
|
+
plugins: [clawPayPlugin],
|
|
23
|
+
tools: [
|
|
24
|
+
clawPayPluginToolNames.DISCOVER_AGENTS,
|
|
25
|
+
clawPayPluginToolNames.CALL_PAID_TOOL,
|
|
26
|
+
clawPayPluginToolNames.CHECK_REPUTATION,
|
|
27
|
+
clawPayPluginToolNames.REGISTER_AGENT,
|
|
28
|
+
],
|
|
29
|
+
context: { mode: AgentMode.AUTONOMOUS },
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Tools
|
|
35
|
+
|
|
36
|
+
| Tool | Description | Parameters |
|
|
37
|
+
|---|---|---|
|
|
38
|
+
| `clawpay_discover_agents` | Find agents by tool name or list all, ranked by reputation | `toolName?` (string) |
|
|
39
|
+
| `clawpay_call_paid_tool` | Call a paid MCP tool with automatic USDC payment via x402 | `mcpEndpoint`, `toolName`, `args?` |
|
|
40
|
+
| `clawpay_check_reputation` | Check an agent's on-chain reputation and recent feedback | `agentTokenId` (number) |
|
|
41
|
+
| `clawpay_register_agent` | Register a new agent on-chain (mints ERC-721 NFT) | `name`, `description`, `capabilities[]`, `mcpEndpoint?` |
|
|
42
|
+
|
|
43
|
+
## Custom Configuration
|
|
44
|
+
|
|
45
|
+
By default the plugin connects to Hedera testnet with the ClawPay AgentRegistry contract. You can override any config:
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import { createClawPayPlugin } from "@clawpay-hedera/hak-plugin";
|
|
49
|
+
|
|
50
|
+
const plugin = createClawPayPlugin({
|
|
51
|
+
network: "mainnet",
|
|
52
|
+
registryAddress: "0x...",
|
|
53
|
+
operatorId: "0.0.xxxxx",
|
|
54
|
+
operatorKey: process.env.HEDERA_OPERATOR_KEY,
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Environment Variables
|
|
59
|
+
|
|
60
|
+
| Variable | Description | Default |
|
|
61
|
+
|---|---|---|
|
|
62
|
+
| `HEDERA_OPERATOR_ID` | Your Hedera account ID | `0.0.6514537` (testnet) |
|
|
63
|
+
| `HEDERA_OPERATOR_KEY` | ECDSA private key (hex) | — |
|
|
64
|
+
|
|
65
|
+
## How It Works
|
|
66
|
+
|
|
67
|
+
1. **Discover** — Reads the on-chain AgentRegistry (ERC-721) to list agents and their capabilities with pricing
|
|
68
|
+
2. **Pay & Call** — When calling a paid tool, the plugin handles the x402 flow: gets a 402 response, signs a USDC payment on Hedera, retries with the payment proof
|
|
69
|
+
3. **Reputation** — Reads on-chain reputation scores and feedback, logs interactions to HCS topics
|
|
70
|
+
4. **Register** — Mints an agent NFT with metadata (name, description, capabilities, MCP endpoint)
|
|
71
|
+
|
|
72
|
+
## On-Chain Contracts
|
|
73
|
+
|
|
74
|
+
- **AgentRegistry**: `0x411278256411dA9018e3c880Df21e54271F2502b` (Hedera Testnet)
|
|
75
|
+
- **Reputation HCS Topic**: `0.0.8107518`
|
|
76
|
+
- **Payment HCS Topic**: `0.0.8058213`
|
|
77
|
+
- **USDC Token**: `0.0.5449` (Hedera Testnet)
|
|
78
|
+
|
|
79
|
+
## Links
|
|
80
|
+
|
|
81
|
+
- [ClawPay GitHub](https://github.com/EmadQureshiKhi/ClawPay)
|
|
82
|
+
- [Hedera Agent Kit](https://github.com/hashgraph/hedera-agent-kit-js)
|
|
83
|
+
- [x402 Protocol](https://www.x402.org/)
|
|
84
|
+
|
|
85
|
+
## License
|
|
86
|
+
|
|
87
|
+
MIT
|
package/dist/abi.d.ts
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
export declare const registryAbi: readonly [{
|
|
2
|
+
readonly name: "totalAgents";
|
|
3
|
+
readonly type: "function";
|
|
4
|
+
readonly stateMutability: "view";
|
|
5
|
+
readonly inputs: readonly [];
|
|
6
|
+
readonly outputs: readonly [{
|
|
7
|
+
readonly type: "uint256";
|
|
8
|
+
}];
|
|
9
|
+
}, {
|
|
10
|
+
readonly name: "ownerOf";
|
|
11
|
+
readonly type: "function";
|
|
12
|
+
readonly stateMutability: "view";
|
|
13
|
+
readonly inputs: readonly [{
|
|
14
|
+
readonly type: "uint256";
|
|
15
|
+
readonly name: "tokenId";
|
|
16
|
+
}];
|
|
17
|
+
readonly outputs: readonly [{
|
|
18
|
+
readonly type: "address";
|
|
19
|
+
}];
|
|
20
|
+
}, {
|
|
21
|
+
readonly name: "tokenURI";
|
|
22
|
+
readonly type: "function";
|
|
23
|
+
readonly stateMutability: "view";
|
|
24
|
+
readonly inputs: readonly [{
|
|
25
|
+
readonly type: "uint256";
|
|
26
|
+
readonly name: "tokenId";
|
|
27
|
+
}];
|
|
28
|
+
readonly outputs: readonly [{
|
|
29
|
+
readonly type: "string";
|
|
30
|
+
}];
|
|
31
|
+
}, {
|
|
32
|
+
readonly name: "getReputation";
|
|
33
|
+
readonly type: "function";
|
|
34
|
+
readonly stateMutability: "view";
|
|
35
|
+
readonly inputs: readonly [{
|
|
36
|
+
readonly type: "uint256";
|
|
37
|
+
readonly name: "tokenId";
|
|
38
|
+
}];
|
|
39
|
+
readonly outputs: readonly [{
|
|
40
|
+
readonly type: "uint256";
|
|
41
|
+
readonly name: "avg";
|
|
42
|
+
}, {
|
|
43
|
+
readonly type: "uint256";
|
|
44
|
+
readonly name: "count";
|
|
45
|
+
}];
|
|
46
|
+
}, {
|
|
47
|
+
readonly name: "getCapabilities";
|
|
48
|
+
readonly type: "function";
|
|
49
|
+
readonly stateMutability: "view";
|
|
50
|
+
readonly inputs: readonly [{
|
|
51
|
+
readonly type: "uint256";
|
|
52
|
+
readonly name: "tokenId";
|
|
53
|
+
}];
|
|
54
|
+
readonly outputs: readonly [{
|
|
55
|
+
readonly type: "tuple[]";
|
|
56
|
+
readonly components: readonly [{
|
|
57
|
+
readonly type: "string";
|
|
58
|
+
readonly name: "toolName";
|
|
59
|
+
}, {
|
|
60
|
+
readonly type: "string";
|
|
61
|
+
readonly name: "description";
|
|
62
|
+
}, {
|
|
63
|
+
readonly type: "uint256";
|
|
64
|
+
readonly name: "priceUsdcAtomic";
|
|
65
|
+
}, {
|
|
66
|
+
readonly type: "string";
|
|
67
|
+
readonly name: "mcpEndpoint";
|
|
68
|
+
}, {
|
|
69
|
+
readonly type: "bool";
|
|
70
|
+
readonly name: "active";
|
|
71
|
+
}];
|
|
72
|
+
}];
|
|
73
|
+
}, {
|
|
74
|
+
readonly name: "findProviders";
|
|
75
|
+
readonly type: "function";
|
|
76
|
+
readonly stateMutability: "view";
|
|
77
|
+
readonly inputs: readonly [{
|
|
78
|
+
readonly type: "string";
|
|
79
|
+
readonly name: "toolName";
|
|
80
|
+
}];
|
|
81
|
+
readonly outputs: readonly [{
|
|
82
|
+
readonly type: "uint256[]";
|
|
83
|
+
}];
|
|
84
|
+
}, {
|
|
85
|
+
readonly name: "agentOf";
|
|
86
|
+
readonly type: "function";
|
|
87
|
+
readonly stateMutability: "view";
|
|
88
|
+
readonly inputs: readonly [{
|
|
89
|
+
readonly type: "address";
|
|
90
|
+
readonly name: "owner";
|
|
91
|
+
}];
|
|
92
|
+
readonly outputs: readonly [{
|
|
93
|
+
readonly type: "uint256";
|
|
94
|
+
}];
|
|
95
|
+
}, {
|
|
96
|
+
readonly name: "getFeedbackIds";
|
|
97
|
+
readonly type: "function";
|
|
98
|
+
readonly stateMutability: "view";
|
|
99
|
+
readonly inputs: readonly [{
|
|
100
|
+
readonly type: "uint256";
|
|
101
|
+
readonly name: "tokenId";
|
|
102
|
+
}];
|
|
103
|
+
readonly outputs: readonly [{
|
|
104
|
+
readonly type: "uint256[]";
|
|
105
|
+
}];
|
|
106
|
+
}, {
|
|
107
|
+
readonly name: "feedbacks";
|
|
108
|
+
readonly type: "function";
|
|
109
|
+
readonly stateMutability: "view";
|
|
110
|
+
readonly inputs: readonly [{
|
|
111
|
+
readonly type: "uint256";
|
|
112
|
+
readonly name: "id";
|
|
113
|
+
}];
|
|
114
|
+
readonly outputs: readonly [{
|
|
115
|
+
readonly type: "uint256";
|
|
116
|
+
readonly name: "fromAgent";
|
|
117
|
+
}, {
|
|
118
|
+
readonly type: "uint256";
|
|
119
|
+
readonly name: "toAgent";
|
|
120
|
+
}, {
|
|
121
|
+
readonly type: "uint8";
|
|
122
|
+
readonly name: "rating";
|
|
123
|
+
}, {
|
|
124
|
+
readonly type: "bytes32";
|
|
125
|
+
readonly name: "commentHash";
|
|
126
|
+
}, {
|
|
127
|
+
readonly type: "uint256";
|
|
128
|
+
readonly name: "timestamp";
|
|
129
|
+
}];
|
|
130
|
+
}, {
|
|
131
|
+
readonly name: "registerAgent";
|
|
132
|
+
readonly type: "function";
|
|
133
|
+
readonly stateMutability: "nonpayable";
|
|
134
|
+
readonly inputs: readonly [{
|
|
135
|
+
readonly type: "string";
|
|
136
|
+
readonly name: "uri";
|
|
137
|
+
}];
|
|
138
|
+
readonly outputs: readonly [{
|
|
139
|
+
readonly type: "uint256";
|
|
140
|
+
}];
|
|
141
|
+
}, {
|
|
142
|
+
readonly name: "submitFeedback";
|
|
143
|
+
readonly type: "function";
|
|
144
|
+
readonly stateMutability: "nonpayable";
|
|
145
|
+
readonly inputs: readonly [{
|
|
146
|
+
readonly type: "uint256";
|
|
147
|
+
readonly name: "toAgent";
|
|
148
|
+
}, {
|
|
149
|
+
readonly type: "uint8";
|
|
150
|
+
readonly name: "rating";
|
|
151
|
+
}, {
|
|
152
|
+
readonly type: "bytes32";
|
|
153
|
+
readonly name: "commentHash";
|
|
154
|
+
}];
|
|
155
|
+
readonly outputs: readonly [];
|
|
156
|
+
}, {
|
|
157
|
+
readonly name: "addCapability";
|
|
158
|
+
readonly type: "function";
|
|
159
|
+
readonly stateMutability: "nonpayable";
|
|
160
|
+
readonly inputs: readonly [{
|
|
161
|
+
readonly type: "string";
|
|
162
|
+
readonly name: "toolName";
|
|
163
|
+
}, {
|
|
164
|
+
readonly type: "string";
|
|
165
|
+
readonly name: "description";
|
|
166
|
+
}, {
|
|
167
|
+
readonly type: "uint256";
|
|
168
|
+
readonly name: "priceUsdcAtomic";
|
|
169
|
+
}, {
|
|
170
|
+
readonly type: "string";
|
|
171
|
+
readonly name: "mcpEndpoint";
|
|
172
|
+
}];
|
|
173
|
+
readonly outputs: readonly [];
|
|
174
|
+
}];
|
|
175
|
+
//# sourceMappingURL=abi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abi.d.ts","sourceRoot":"","sources":["../src/abi.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAatB,CAAC"}
|
package/dist/abi.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentRegistry contract ABI (minimal — only the functions we need).
|
|
3
|
+
*/
|
|
4
|
+
import { parseAbi } from "viem";
|
|
5
|
+
export const registryAbi = parseAbi([
|
|
6
|
+
"function totalAgents() view returns (uint256)",
|
|
7
|
+
"function ownerOf(uint256 tokenId) view returns (address)",
|
|
8
|
+
"function tokenURI(uint256 tokenId) view returns (string)",
|
|
9
|
+
"function getReputation(uint256 tokenId) view returns (uint256 avg, uint256 count)",
|
|
10
|
+
"function getCapabilities(uint256 tokenId) view returns ((string toolName, string description, uint256 priceUsdcAtomic, string mcpEndpoint, bool active)[])",
|
|
11
|
+
"function findProviders(string toolName) view returns (uint256[])",
|
|
12
|
+
"function agentOf(address owner) view returns (uint256)",
|
|
13
|
+
"function getFeedbackIds(uint256 tokenId) view returns (uint256[])",
|
|
14
|
+
"function feedbacks(uint256 id) view returns (uint256 fromAgent, uint256 toAgent, uint8 rating, bytes32 commentHash, uint256 timestamp)",
|
|
15
|
+
"function registerAgent(string uri) returns (uint256)",
|
|
16
|
+
"function submitFeedback(uint256 toAgent, uint8 rating, bytes32 commentHash)",
|
|
17
|
+
"function addCapability(string toolName, string description, uint256 priceUsdcAtomic, string mcpEndpoint)",
|
|
18
|
+
]);
|
|
19
|
+
//# sourceMappingURL=abi.js.map
|
package/dist/abi.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abi.js","sourceRoot":"","sources":["../src/abi.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC;IAClC,+CAA+C;IAC/C,0DAA0D;IAC1D,0DAA0D;IAC1D,mFAAmF;IACnF,4JAA4J;IAC5J,kEAAkE;IAClE,wDAAwD;IACxD,mEAAmE;IACnE,wIAAwI;IACxI,sDAAsD;IACtD,6EAA6E;IAC7E,0GAA0G;CAC3G,CAAC,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin configuration — contract addresses, RPC, topics.
|
|
3
|
+
* Can be overridden via environment variables or constructor options.
|
|
4
|
+
*/
|
|
5
|
+
export interface ClawPayPluginConfig {
|
|
6
|
+
registryAddress: `0x${string}`;
|
|
7
|
+
rpcUrl: string;
|
|
8
|
+
reputationTopicId: string;
|
|
9
|
+
paymentTopicId: string;
|
|
10
|
+
network: "testnet" | "mainnet";
|
|
11
|
+
/** Hedera operator ID for HCS submissions */
|
|
12
|
+
operatorId?: string;
|
|
13
|
+
/** Hedera operator private key (hex, ECDSA) */
|
|
14
|
+
operatorKey?: string;
|
|
15
|
+
/** Blocky402 facilitator fee payer account */
|
|
16
|
+
facilitatorFeePayer?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const DEFAULT_CONFIG: ClawPayPluginConfig;
|
|
19
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE,KAAK,MAAM,EAAE,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC;IAC/B,6CAA6C;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8CAA8C;IAC9C,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,eAAO,MAAM,cAAc,EAAE,mBAS5B,CAAC"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin configuration — contract addresses, RPC, topics.
|
|
3
|
+
* Can be overridden via environment variables or constructor options.
|
|
4
|
+
*/
|
|
5
|
+
export const DEFAULT_CONFIG = {
|
|
6
|
+
registryAddress: "0x411278256411dA9018e3c880Df21e54271F2502b",
|
|
7
|
+
rpcUrl: "https://testnet.hashio.io/api",
|
|
8
|
+
reputationTopicId: "0.0.8107518",
|
|
9
|
+
paymentTopicId: "0.0.8058213",
|
|
10
|
+
network: "testnet",
|
|
11
|
+
operatorId: process.env.HEDERA_OPERATOR_ID || "0.0.6514537",
|
|
12
|
+
operatorKey: process.env.HEDERA_OPERATOR_KEY || "",
|
|
13
|
+
facilitatorFeePayer: "0.0.7162784",
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH,MAAM,CAAC,MAAM,cAAc,GAAwB;IACjD,eAAe,EAAE,4CAA4C;IAC7D,MAAM,EAAE,+BAA+B;IACvC,iBAAiB,EAAE,aAAa;IAChC,cAAc,EAAE,aAAa;IAC7B,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,aAAa;IAC3D,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,EAAE;IAClD,mBAAmB,EAAE,aAAa;CACnC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hak-clawpay-plugin — ClawPay plugin for the Hedera Agent Kit.
|
|
3
|
+
*
|
|
4
|
+
* Adds 4 tools to any Hedera Agent Kit agent:
|
|
5
|
+
* - clawpay_discover_agents: Find agents offering specific tools
|
|
6
|
+
* - clawpay_call_paid_tool: Call a paid MCP tool with automatic USDC payment
|
|
7
|
+
* - clawpay_check_reputation: Check an agent's on-chain reputation
|
|
8
|
+
* - clawpay_register_agent: Register a new agent on-chain
|
|
9
|
+
*
|
|
10
|
+
* Usage with Hedera Agent Kit:
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { clawPayPlugin } from "hak-clawpay-plugin";
|
|
13
|
+
*
|
|
14
|
+
* const toolkit = new HederaLangchainToolkit({
|
|
15
|
+
* client,
|
|
16
|
+
* configuration: {
|
|
17
|
+
* plugins: [clawPayPlugin],
|
|
18
|
+
* context: { mode: AgentMode.AUTONOMOUS },
|
|
19
|
+
* },
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import { type ClawPayPluginConfig } from "./config.js";
|
|
24
|
+
export { DEFAULT_CONFIG, type ClawPayPluginConfig } from "./config.js";
|
|
25
|
+
export declare const clawPayPluginToolNames: {
|
|
26
|
+
readonly DISCOVER_AGENTS: "clawpay_discover_agents";
|
|
27
|
+
readonly CHECK_REPUTATION: "clawpay_check_reputation";
|
|
28
|
+
readonly CALL_PAID_TOOL: "clawpay_call_paid_tool";
|
|
29
|
+
readonly REGISTER_AGENT: "clawpay_register_agent";
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Plugin interface compatible with Hedera Agent Kit.
|
|
33
|
+
* Also usable standalone — the tools array can be consumed by any LangChain setup.
|
|
34
|
+
*/
|
|
35
|
+
export interface ClawPayTool {
|
|
36
|
+
method: string;
|
|
37
|
+
name: string;
|
|
38
|
+
description: string;
|
|
39
|
+
parameters: any;
|
|
40
|
+
execute: (params: any) => Promise<any>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Create the ClawPay plugin with optional config overrides.
|
|
44
|
+
*/
|
|
45
|
+
export declare function createClawPayPlugin(configOverrides?: Partial<ClawPayPluginConfig>): {
|
|
46
|
+
name: string;
|
|
47
|
+
version: string;
|
|
48
|
+
description: string;
|
|
49
|
+
tools: () => ClawPayTool[];
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Default plugin instance (uses DEFAULT_CONFIG).
|
|
53
|
+
* Import this directly for quick setup.
|
|
54
|
+
*/
|
|
55
|
+
export declare const clawPayPlugin: {
|
|
56
|
+
name: string;
|
|
57
|
+
version: string;
|
|
58
|
+
description: string;
|
|
59
|
+
tools: () => ClawPayTool[];
|
|
60
|
+
};
|
|
61
|
+
export default clawPayPlugin;
|
|
62
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAkB,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AA2BvE,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGvE,eAAO,MAAM,sBAAsB;;;;;CAKzB,CAAC;AAEX;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,GAAG,CAAC;IAChB,OAAO,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CACxC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC;;;;;EAwCjF;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;CAAwB,CAAC;AAEnD,eAAe,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hak-clawpay-plugin — ClawPay plugin for the Hedera Agent Kit.
|
|
3
|
+
*
|
|
4
|
+
* Adds 4 tools to any Hedera Agent Kit agent:
|
|
5
|
+
* - clawpay_discover_agents: Find agents offering specific tools
|
|
6
|
+
* - clawpay_call_paid_tool: Call a paid MCP tool with automatic USDC payment
|
|
7
|
+
* - clawpay_check_reputation: Check an agent's on-chain reputation
|
|
8
|
+
* - clawpay_register_agent: Register a new agent on-chain
|
|
9
|
+
*
|
|
10
|
+
* Usage with Hedera Agent Kit:
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { clawPayPlugin } from "hak-clawpay-plugin";
|
|
13
|
+
*
|
|
14
|
+
* const toolkit = new HederaLangchainToolkit({
|
|
15
|
+
* client,
|
|
16
|
+
* configuration: {
|
|
17
|
+
* plugins: [clawPayPlugin],
|
|
18
|
+
* context: { mode: AgentMode.AUTONOMOUS },
|
|
19
|
+
* },
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import { DEFAULT_CONFIG } from "./config.js";
|
|
24
|
+
import { DISCOVER_AGENTS, discoverAgentsParameters, discoverAgentsDescription, discoverAgentsExecute, } from "./tools/discover-agents.js";
|
|
25
|
+
import { CHECK_REPUTATION, checkReputationParameters, checkReputationDescription, checkReputationExecute, } from "./tools/check-reputation.js";
|
|
26
|
+
import { CALL_PAID_TOOL, callPaidToolParameters, callPaidToolDescription, callPaidToolExecute, } from "./tools/call-paid-tool.js";
|
|
27
|
+
import { REGISTER_AGENT, registerAgentParameters, registerAgentDescription, registerAgentExecute, } from "./tools/register-agent.js";
|
|
28
|
+
// Re-export types and config
|
|
29
|
+
export { DEFAULT_CONFIG } from "./config.js";
|
|
30
|
+
// Re-export tool names for toolkit configuration
|
|
31
|
+
export const clawPayPluginToolNames = {
|
|
32
|
+
DISCOVER_AGENTS,
|
|
33
|
+
CHECK_REPUTATION,
|
|
34
|
+
CALL_PAID_TOOL,
|
|
35
|
+
REGISTER_AGENT,
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Create the ClawPay plugin with optional config overrides.
|
|
39
|
+
*/
|
|
40
|
+
export function createClawPayPlugin(configOverrides) {
|
|
41
|
+
const config = { ...DEFAULT_CONFIG, ...configOverrides };
|
|
42
|
+
const tools = [
|
|
43
|
+
{
|
|
44
|
+
method: DISCOVER_AGENTS,
|
|
45
|
+
name: "Discover ClawPay Agents",
|
|
46
|
+
description: discoverAgentsDescription,
|
|
47
|
+
parameters: discoverAgentsParameters,
|
|
48
|
+
execute: (params) => discoverAgentsExecute(config, params),
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
method: CHECK_REPUTATION,
|
|
52
|
+
name: "Check Agent Reputation",
|
|
53
|
+
description: checkReputationDescription,
|
|
54
|
+
parameters: checkReputationParameters,
|
|
55
|
+
execute: (params) => checkReputationExecute(config, params),
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
method: CALL_PAID_TOOL,
|
|
59
|
+
name: "Call Paid Tool via x402",
|
|
60
|
+
description: callPaidToolDescription,
|
|
61
|
+
parameters: callPaidToolParameters,
|
|
62
|
+
execute: (params) => callPaidToolExecute(config, params),
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
method: REGISTER_AGENT,
|
|
66
|
+
name: "Register Agent On-Chain",
|
|
67
|
+
description: registerAgentDescription,
|
|
68
|
+
parameters: registerAgentParameters,
|
|
69
|
+
execute: (params) => registerAgentExecute(config, params),
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
return {
|
|
73
|
+
name: "clawpay",
|
|
74
|
+
version: "1.0.0",
|
|
75
|
+
description: "Discover, pay for, and rate AI agent tools on Hedera via x402",
|
|
76
|
+
tools: () => tools,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Default plugin instance (uses DEFAULT_CONFIG).
|
|
81
|
+
* Import this directly for quick setup.
|
|
82
|
+
*/
|
|
83
|
+
export const clawPayPlugin = createClawPayPlugin();
|
|
84
|
+
export default clawPayPlugin;
|
|
85
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,cAAc,EAA4B,MAAM,aAAa,CAAC;AACvE,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,gBAAgB,EAChB,yBAAyB,EACzB,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,2B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,EAAE,+DAA+D;QAC5E,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK;KACnB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,EAAE,CAAC;AAEnD,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* clawpay_call_paid_tool — Call a paid MCP tool and pay USDC automatically via x402.
|
|
3
|
+
*/
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import type { ClawPayPluginConfig } from "../config.js";
|
|
6
|
+
export declare const CALL_PAID_TOOL = "clawpay_call_paid_tool";
|
|
7
|
+
export declare const callPaidToolParameters: z.ZodObject<{
|
|
8
|
+
mcpEndpoint: z.ZodString;
|
|
9
|
+
toolName: z.ZodString;
|
|
10
|
+
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
toolName: string;
|
|
13
|
+
mcpEndpoint: string;
|
|
14
|
+
args?: Record<string, any> | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
toolName: string;
|
|
17
|
+
mcpEndpoint: string;
|
|
18
|
+
args?: Record<string, any> | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
export declare const callPaidToolDescription = "Call a paid tool on a ClawPay MCP server and pay USDC automatically via x402 on Hedera.\nThe payment is handled transparently \u2014 the agent's Hedera wallet signs a USDC transfer,\nand the Blocky402 facilitator submits it gaslessly.\nUse clawpay_discover_agents first to find the MCP endpoint and tool name.";
|
|
21
|
+
export declare function callPaidToolExecute(config: ClawPayPluginConfig, params: z.infer<typeof callPaidToolParameters>): Promise<{
|
|
22
|
+
paid: boolean;
|
|
23
|
+
result: unknown;
|
|
24
|
+
receipt: null;
|
|
25
|
+
error?: undefined;
|
|
26
|
+
amount?: undefined;
|
|
27
|
+
recipient?: undefined;
|
|
28
|
+
} | {
|
|
29
|
+
error: string;
|
|
30
|
+
paid?: undefined;
|
|
31
|
+
result?: undefined;
|
|
32
|
+
receipt?: undefined;
|
|
33
|
+
amount?: undefined;
|
|
34
|
+
recipient?: undefined;
|
|
35
|
+
} | {
|
|
36
|
+
paid: boolean;
|
|
37
|
+
amount: string;
|
|
38
|
+
recipient: any;
|
|
39
|
+
result: unknown;
|
|
40
|
+
receipt: {
|
|
41
|
+
txId: string;
|
|
42
|
+
};
|
|
43
|
+
error?: undefined;
|
|
44
|
+
}>;
|
|
45
|
+
//# sourceMappingURL=call-paid-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-paid-tool.d.ts","sourceRoot":"","sources":["../../src/tools/call-paid-tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD,eAAO,MAAM,cAAc,2BAA2B,CAAC;AAEvD,eAAO,MAAM,sBAAsB;;;;;;;;;;;;EAIjC,CAAC;AAEH,eAAO,MAAM,uBAAuB,0TAGsC,CAAC;AAE3E,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC;;;;;;;;;;;;;;;;;;;;;;;GAoH/C"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* clawpay_call_paid_tool — Call a paid MCP tool and pay USDC automatically via x402.
|
|
3
|
+
*/
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
export const CALL_PAID_TOOL = "clawpay_call_paid_tool";
|
|
6
|
+
export const callPaidToolParameters = z.object({
|
|
7
|
+
mcpEndpoint: z.string().describe("The MCP server endpoint URL of the agent providing the tool."),
|
|
8
|
+
toolName: z.string().describe("The name of the tool to call on the MCP server."),
|
|
9
|
+
args: z.record(z.any()).optional().describe("Arguments to pass to the tool (key-value pairs)."),
|
|
10
|
+
});
|
|
11
|
+
export const callPaidToolDescription = `Call a paid tool on a ClawPay MCP server and pay USDC automatically via x402 on Hedera.
|
|
12
|
+
The payment is handled transparently — the agent's Hedera wallet signs a USDC transfer,
|
|
13
|
+
and the Blocky402 facilitator submits it gaslessly.
|
|
14
|
+
Use clawpay_discover_agents first to find the MCP endpoint and tool name.`;
|
|
15
|
+
export async function callPaidToolExecute(config, params) {
|
|
16
|
+
const { mcpEndpoint, toolName, args } = params;
|
|
17
|
+
try {
|
|
18
|
+
// Step 1: Call the MCP endpoint — if it requires payment, we get a 402 with PaymentRequirements
|
|
19
|
+
const initRes = await fetch(mcpEndpoint, {
|
|
20
|
+
method: "POST",
|
|
21
|
+
headers: { "Content-Type": "application/json" },
|
|
22
|
+
body: JSON.stringify({
|
|
23
|
+
jsonrpc: "2.0",
|
|
24
|
+
id: 1,
|
|
25
|
+
method: "tools/call",
|
|
26
|
+
params: { name: toolName, arguments: args || {} },
|
|
27
|
+
}),
|
|
28
|
+
});
|
|
29
|
+
// If 200, tool is free — return result directly
|
|
30
|
+
if (initRes.ok) {
|
|
31
|
+
const result = await initRes.json();
|
|
32
|
+
return { paid: false, result, receipt: null };
|
|
33
|
+
}
|
|
34
|
+
// If 402, extract payment requirements and pay
|
|
35
|
+
if (initRes.status === 402) {
|
|
36
|
+
const paymentRequirements = initRes.headers.get("x-payment");
|
|
37
|
+
if (!paymentRequirements) {
|
|
38
|
+
return { error: "Server returned 402 but no payment requirements header" };
|
|
39
|
+
}
|
|
40
|
+
const requirements = JSON.parse(Buffer.from(paymentRequirements, "base64").toString());
|
|
41
|
+
// Build x402 payment header using Hedera HTS
|
|
42
|
+
const { Client, TransferTransaction, AccountId, TokenId, PrivateKey, TransactionId, Timestamp } = await import("@hashgraph/sdk");
|
|
43
|
+
const pk = PrivateKey.fromStringECDSA((config.operatorKey || "").replace(/^0x/, ""));
|
|
44
|
+
const payerId = AccountId.fromString(config.operatorId || "0.0.6514537");
|
|
45
|
+
// Parse recipient from payment requirements
|
|
46
|
+
const payTo = requirements.payTo || requirements.pay_to;
|
|
47
|
+
const recipientId = payTo.startsWith("0.0.")
|
|
48
|
+
? AccountId.fromString(payTo)
|
|
49
|
+
: AccountId.fromEvmAddress(0, 0, payTo);
|
|
50
|
+
// Parse token and amount
|
|
51
|
+
const asset = requirements.asset;
|
|
52
|
+
const tokenEntityNum = parseInt(asset.replace(/^0x/, ""), 16);
|
|
53
|
+
const tokenId = TokenId.fromString(`0.0.${tokenEntityNum}`);
|
|
54
|
+
const amount = Number(requirements.maxAmountRequired || requirements.amount);
|
|
55
|
+
// Facilitator pays gas
|
|
56
|
+
const feePayerAccountId = config.facilitatorFeePayer
|
|
57
|
+
? AccountId.fromString(config.facilitatorFeePayer)
|
|
58
|
+
: payerId;
|
|
59
|
+
const hederaClient = config.network === "testnet"
|
|
60
|
+
? Client.forTestnet()
|
|
61
|
+
: Client.forMainnet();
|
|
62
|
+
const txId = TransactionId.withValidStart(feePayerAccountId, Timestamp.generate());
|
|
63
|
+
const tx = new TransferTransaction()
|
|
64
|
+
.addTokenTransfer(tokenId, payerId, -amount)
|
|
65
|
+
.addTokenTransfer(tokenId, recipientId, amount)
|
|
66
|
+
.setTransactionId(txId)
|
|
67
|
+
.setMaxTransactionFee(2_000_000)
|
|
68
|
+
.setTransactionValidDuration(180);
|
|
69
|
+
const frozenTx = tx.freezeWith(hederaClient);
|
|
70
|
+
const signedTx = await frozenTx.sign(pk);
|
|
71
|
+
const txBytes = signedTx.toBytes();
|
|
72
|
+
const paymentHeader = Buffer.from(JSON.stringify({
|
|
73
|
+
x402Version: 1,
|
|
74
|
+
payload: { transaction: Buffer.from(txBytes).toString("base64") },
|
|
75
|
+
})).toString("base64");
|
|
76
|
+
hederaClient.close();
|
|
77
|
+
// Step 2: Retry the call with payment header
|
|
78
|
+
const paidRes = await fetch(mcpEndpoint, {
|
|
79
|
+
method: "POST",
|
|
80
|
+
headers: {
|
|
81
|
+
"Content-Type": "application/json",
|
|
82
|
+
"X-PAYMENT": paymentHeader,
|
|
83
|
+
"X-PAYMENT-VERSION": "1",
|
|
84
|
+
},
|
|
85
|
+
body: JSON.stringify({
|
|
86
|
+
jsonrpc: "2.0",
|
|
87
|
+
id: 2,
|
|
88
|
+
method: "tools/call",
|
|
89
|
+
params: { name: toolName, arguments: args || {} },
|
|
90
|
+
}),
|
|
91
|
+
});
|
|
92
|
+
const result = await paidRes.json();
|
|
93
|
+
return {
|
|
94
|
+
paid: true,
|
|
95
|
+
amount: `$${(amount / 1_000_000).toFixed(4)} USDC`,
|
|
96
|
+
recipient: payTo,
|
|
97
|
+
result,
|
|
98
|
+
receipt: { txId: txId.toString() },
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
return { error: `Unexpected status ${initRes.status}: ${await initRes.text()}` };
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
return { error: `Tool call failed: ${error.message}` };
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=call-paid-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-paid-tool.js","sourceRoot":"","sources":["../../src/tools/call-paid-tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,CAAC,MAAM,cAAc,GAAG,wBAAwB,CAAC;AAEvD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8DAA8D,CAAC;IAChG,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iDAAiD,CAAC;IAChF,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kDAAkD,CAAC;CAChG,CAAC,CAAC;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AE,EAAE,CAAC;oBACL,MAAM,EAAE,YAAY;oBACpB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,EAAE;iBAClD,CAAC;aACH,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;YACpC,OAAO;gBACL,IAAI,EAAE,IAAI;gBACV,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO;gBAClD,SAAS,EAAE,KAAK;gBAChB,MAAM;gBACN,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE;aACnC,CAAC;QACJ,CAAC;QAED,OAAO,EAAE,KAAK,EAAE,qBAAqB,OAAO,CAAC,MAAM,KAAK,MAAM,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC;IACnF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,KAAK,EAAE,qBAAsB,KAAe,CAAC,OAAO,EAAE,EAAE,CAAC;IACpE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* clawpay_check_reputation — Check an agent's on-chain reputation score and feedback history.
|
|
3
|
+
*/
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import type { ClawPayPluginConfig } from "../config.js";
|
|
6
|
+
export declare const CHECK_REPUTATION = "clawpay_check_reputation";
|
|
7
|
+
export declare const checkReputationParameters: z.ZodObject<{
|
|
8
|
+
agentTokenId: z.ZodNumber;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
agentTokenId: number;
|
|
11
|
+
}, {
|
|
12
|
+
agentTokenId: number;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const checkReputationDescription = "Check the on-chain reputation of a ClawPay agent.\nReturns the average rating (0-5), total rating count, and recent feedback entries.\nUse this to evaluate an agent's trustworthiness before paying for their tools.";
|
|
15
|
+
export declare function checkReputationExecute(config: ClawPayPluginConfig, params: z.infer<typeof checkReputationParameters>): Promise<{
|
|
16
|
+
agentTokenId: number;
|
|
17
|
+
avgRating: number;
|
|
18
|
+
ratingCount: number;
|
|
19
|
+
recentFeedbacks: {
|
|
20
|
+
fromAgent: number;
|
|
21
|
+
toAgent: number;
|
|
22
|
+
rating: number;
|
|
23
|
+
timestamp: string;
|
|
24
|
+
}[];
|
|
25
|
+
hcsComments: any[];
|
|
26
|
+
error?: undefined;
|
|
27
|
+
} | {
|
|
28
|
+
error: string;
|
|
29
|
+
agentTokenId?: undefined;
|
|
30
|
+
avgRating?: undefined;
|
|
31
|
+
ratingCount?: undefined;
|
|
32
|
+
recentFeedbacks?: undefined;
|
|
33
|
+
hcsComments?: undefined;
|
|
34
|
+
}>;
|
|
35
|
+
//# sourceMappingURL=check-reputation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-reputation.d.ts","sourceRoot":"","sources":["../../src/tools/check-reputation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD,eAAO,MAAM,gBAAgB,6BAA6B,CAAC;AAE3D,eAAO,MAAM,yBAAyB;;;;;;EAEpC,CAAC;AAEH,eAAO,MAAM,0BAA0B,0NAEwC,CAAC;AAEhF,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC;;;;;;;;;;;;;;;;;;;GAwElD"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* clawpay_check_reputation — Check an agent's on-chain reputation score and feedback history.
|
|
3
|
+
*/
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { createPublicClient, http } from "viem";
|
|
6
|
+
import { hederaTestnet } from "viem/chains";
|
|
7
|
+
import { registryAbi } from "../abi.js";
|
|
8
|
+
export const CHECK_REPUTATION = "clawpay_check_reputation";
|
|
9
|
+
export const checkReputationParameters = z.object({
|
|
10
|
+
agentTokenId: z.number().describe("The on-chain token ID of the agent to check reputation for."),
|
|
11
|
+
});
|
|
12
|
+
export const checkReputationDescription = `Check the on-chain reputation of a ClawPay agent.
|
|
13
|
+
Returns the average rating (0-5), total rating count, and recent feedback entries.
|
|
14
|
+
Use this to evaluate an agent's trustworthiness before paying for their tools.`;
|
|
15
|
+
export async function checkReputationExecute(config, params) {
|
|
16
|
+
const client = createPublicClient({
|
|
17
|
+
chain: hederaTestnet,
|
|
18
|
+
transport: http(config.rpcUrl),
|
|
19
|
+
});
|
|
20
|
+
try {
|
|
21
|
+
const [reputation, feedbackIds] = await Promise.all([
|
|
22
|
+
client.readContract({
|
|
23
|
+
address: config.registryAddress, abi: registryAbi,
|
|
24
|
+
functionName: "getReputation", args: [BigInt(params.agentTokenId)],
|
|
25
|
+
}),
|
|
26
|
+
client.readContract({
|
|
27
|
+
address: config.registryAddress, abi: registryAbi,
|
|
28
|
+
functionName: "getFeedbackIds", args: [BigInt(params.agentTokenId)],
|
|
29
|
+
}),
|
|
30
|
+
]);
|
|
31
|
+
const avg = Number(reputation[0]) / 100;
|
|
32
|
+
const count = Number(reputation[1]);
|
|
33
|
+
// Fetch recent feedbacks (last 10)
|
|
34
|
+
const recentIds = feedbackIds.slice(-10);
|
|
35
|
+
const feedbacks = [];
|
|
36
|
+
for (const id of recentIds) {
|
|
37
|
+
try {
|
|
38
|
+
const fb = await client.readContract({
|
|
39
|
+
address: config.registryAddress, abi: registryAbi,
|
|
40
|
+
functionName: "feedbacks", args: [id],
|
|
41
|
+
});
|
|
42
|
+
feedbacks.push({
|
|
43
|
+
fromAgent: Number(fb[0]),
|
|
44
|
+
toAgent: Number(fb[1]),
|
|
45
|
+
rating: Number(fb[2]),
|
|
46
|
+
timestamp: new Date(Number(fb[4]) * 1000).toISOString(),
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
catch { /* skip */ }
|
|
50
|
+
}
|
|
51
|
+
// Also fetch HCS comments from Mirror Node for richer context
|
|
52
|
+
let hcsComments = [];
|
|
53
|
+
try {
|
|
54
|
+
const base = config.network === "mainnet"
|
|
55
|
+
? "https://mainnet.mirrornode.hedera.com"
|
|
56
|
+
: "https://testnet.mirrornode.hedera.com";
|
|
57
|
+
const res = await fetch(`${base}/api/v1/topics/${config.reputationTopicId}/messages?limit=10&order=desc`);
|
|
58
|
+
if (res.ok) {
|
|
59
|
+
const data = (await res.json());
|
|
60
|
+
hcsComments = (data.messages || [])
|
|
61
|
+
.map((m) => {
|
|
62
|
+
try {
|
|
63
|
+
const parsed = JSON.parse(Buffer.from(m.message, "base64").toString());
|
|
64
|
+
if (parsed.toAgent === params.agentTokenId)
|
|
65
|
+
return { ...parsed, seq: m.sequence_number };
|
|
66
|
+
}
|
|
67
|
+
catch { /* skip */ }
|
|
68
|
+
return null;
|
|
69
|
+
})
|
|
70
|
+
.filter(Boolean);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch { /* HCS fetch is best-effort */ }
|
|
74
|
+
return {
|
|
75
|
+
agentTokenId: params.agentTokenId,
|
|
76
|
+
avgRating: avg,
|
|
77
|
+
ratingCount: count,
|
|
78
|
+
recentFeedbacks: feedbacks,
|
|
79
|
+
hcsComments,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
return { error: `Reputation check failed: ${error.message}` };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=check-reputation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-reputation.js","sourceRoot":"","sources":["../../src/tools/check-reputation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACx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AAC,IAAI,EAAE,CAAyB,CAAC;gBACxD,WAAW,GAAG,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;qBAChC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE;oBACd,IAAI,CAAC;wBACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;wBACvE,IAAI,MAAM,CAAC,OAAO,KAAK,MAAM,CAAC,YAAY;4BAAE,OAAO,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,eAAe,EAAE,CAAC;oBAC3F,CAAC;oBAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC;oBACtB,OAAO,IAAI,CAAC;gBACd,CAAC,CAAC;qBACD,MAAM,CAAC,OAAO,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;QAAC,MAAM,CAAC,CAAC,8BAA8B,CAAC,CAAC;QAE1C,OAAO;YACL,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,SAAS,EAAE,GAAG;YACd,WAAW,EAAE,KAAK;YAClB,eAAe,EAAE,SAAS;YAC1B,WAAW;SACZ,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,KAAK,EAAE,4BAA6B,KAAe,CAAC,OAAO,EAAE,EAAE,CAAC;IAC3E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* clawpay_discover_agents — Find agents offering specific tools, ranked by reputation.
|
|
3
|
+
*/
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import type { ClawPayPluginConfig } from "../config.js";
|
|
6
|
+
export declare const DISCOVER_AGENTS = "clawpay_discover_agents";
|
|
7
|
+
export declare const discoverAgentsParameters: z.ZodObject<{
|
|
8
|
+
toolName: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
toolName?: string | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
toolName?: string | undefined;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const discoverAgentsDescription = "Discover AI agents registered on the ClawPay Agent Society on Hedera.\nSearch for agents offering specific tools, compare their prices and reputation scores.\nReturns agents sorted by a composite score (reputation + price).\nUse this to find the best provider before calling a paid tool.";
|
|
15
|
+
export declare function discoverAgentsExecute(config: ClawPayPluginConfig, params: z.infer<typeof discoverAgentsParameters>): Promise<{
|
|
16
|
+
agents: {
|
|
17
|
+
tokenId: number;
|
|
18
|
+
owner: `0x${string}`;
|
|
19
|
+
name: any;
|
|
20
|
+
description: any;
|
|
21
|
+
reputation: {
|
|
22
|
+
avg: number;
|
|
23
|
+
count: number;
|
|
24
|
+
};
|
|
25
|
+
capabilities: {
|
|
26
|
+
toolName: any;
|
|
27
|
+
description: any;
|
|
28
|
+
priceUsd: string;
|
|
29
|
+
mcpEndpoint: any;
|
|
30
|
+
}[];
|
|
31
|
+
}[];
|
|
32
|
+
total: number;
|
|
33
|
+
query: string;
|
|
34
|
+
error?: undefined;
|
|
35
|
+
} | {
|
|
36
|
+
error: string;
|
|
37
|
+
agents: never[];
|
|
38
|
+
total: number;
|
|
39
|
+
query?: undefined;
|
|
40
|
+
}>;
|
|
41
|
+
//# sourceMappingURL=discover-agents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover-agents.d.ts","sourceRoot":"","sources":["../../src/tools/discover-agents.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAWxD,eAAO,MAAM,eAAe,4BAA4B,CAAC;AAEzD,eAAO,MAAM,wBAAwB;;;;;;EAEnC,CAAC;AAEH,eAAO,MAAM,yBAAyB,oSAGyB,CAAC;AAEhE,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;GAsFjD"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* clawpay_discover_agents — Find agents offering specific tools, ranked by reputation.
|
|
3
|
+
*/
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { createPublicClient, http } from "viem";
|
|
6
|
+
import { hederaTestnet } from "viem/chains";
|
|
7
|
+
import { registryAbi } from "../abi.js";
|
|
8
|
+
function parseProfile(uri) {
|
|
9
|
+
try {
|
|
10
|
+
if (uri.startsWith("data:application/json;base64,")) {
|
|
11
|
+
return JSON.parse(Buffer.from(uri.replace("data:application/json;base64,", ""), "base64").toString());
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
catch { /* ignore */ }
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
export const DISCOVER_AGENTS = "clawpay_discover_agents";
|
|
18
|
+
export const discoverAgentsParameters = z.object({
|
|
19
|
+
toolName: z.string().optional().describe("Filter by tool name. If omitted, returns all agents with their capabilities."),
|
|
20
|
+
});
|
|
21
|
+
export const discoverAgentsDescription = `Discover AI agents registered on the ClawPay Agent Society on Hedera.
|
|
22
|
+
Search for agents offering specific tools, compare their prices and reputation scores.
|
|
23
|
+
Returns agents sorted by a composite score (reputation + price).
|
|
24
|
+
Use this to find the best provider before calling a paid tool.`;
|
|
25
|
+
export async function discoverAgentsExecute(config, params) {
|
|
26
|
+
const client = createPublicClient({
|
|
27
|
+
chain: hederaTestnet,
|
|
28
|
+
transport: http(config.rpcUrl),
|
|
29
|
+
});
|
|
30
|
+
try {
|
|
31
|
+
let tokenIds;
|
|
32
|
+
if (params.toolName) {
|
|
33
|
+
// Find providers for a specific tool
|
|
34
|
+
const providerIds = await client.readContract({
|
|
35
|
+
address: config.registryAddress,
|
|
36
|
+
abi: registryAbi,
|
|
37
|
+
functionName: "findProviders",
|
|
38
|
+
args: [params.toolName],
|
|
39
|
+
});
|
|
40
|
+
tokenIds = providerIds.map(Number);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
// List all agents
|
|
44
|
+
const total = await client.readContract({
|
|
45
|
+
address: config.registryAddress,
|
|
46
|
+
abi: registryAbi,
|
|
47
|
+
functionName: "totalAgents",
|
|
48
|
+
});
|
|
49
|
+
tokenIds = Array.from({ length: Number(total) }, (_, i) => i + 1);
|
|
50
|
+
}
|
|
51
|
+
const results = [];
|
|
52
|
+
for (const tokenId of tokenIds) {
|
|
53
|
+
try {
|
|
54
|
+
const [owner, uri, reputation] = await Promise.all([
|
|
55
|
+
client.readContract({ address: config.registryAddress, abi: registryAbi, functionName: "ownerOf", args: [BigInt(tokenId)] }),
|
|
56
|
+
client.readContract({ address: config.registryAddress, abi: registryAbi, functionName: "tokenURI", args: [BigInt(tokenId)] }),
|
|
57
|
+
client.readContract({ address: config.registryAddress, abi: registryAbi, functionName: "getReputation", args: [BigInt(tokenId)] }),
|
|
58
|
+
]);
|
|
59
|
+
const profile = parseProfile(uri);
|
|
60
|
+
const caps = await client.readContract({
|
|
61
|
+
address: config.registryAddress, abi: registryAbi,
|
|
62
|
+
functionName: "getCapabilities", args: [BigInt(tokenId)],
|
|
63
|
+
});
|
|
64
|
+
const capabilities = caps
|
|
65
|
+
.filter((c) => c.active)
|
|
66
|
+
.map((c) => ({
|
|
67
|
+
toolName: c.toolName,
|
|
68
|
+
description: c.description,
|
|
69
|
+
priceUsd: `$${(Number(c.priceUsdcAtomic) / 1_000_000).toFixed(3)}`,
|
|
70
|
+
mcpEndpoint: c.mcpEndpoint,
|
|
71
|
+
}));
|
|
72
|
+
// Filter by tool if specified
|
|
73
|
+
if (params.toolName && !capabilities.some(c => c.toolName === params.toolName))
|
|
74
|
+
continue;
|
|
75
|
+
const avg = Number(reputation[0]) / 100;
|
|
76
|
+
const count = Number(reputation[1]);
|
|
77
|
+
results.push({
|
|
78
|
+
tokenId,
|
|
79
|
+
owner,
|
|
80
|
+
name: profile?.name || `Agent #${tokenId}`,
|
|
81
|
+
description: profile?.description || "",
|
|
82
|
+
reputation: { avg, count },
|
|
83
|
+
capabilities,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
catch { /* skip invalid agents */ }
|
|
87
|
+
}
|
|
88
|
+
// Sort by reputation (higher is better)
|
|
89
|
+
results.sort((a, b) => {
|
|
90
|
+
const scoreA = a.reputation.count > 0 ? a.reputation.avg : 2.5;
|
|
91
|
+
const scoreB = b.reputation.count > 0 ? b.reputation.avg : 2.5;
|
|
92
|
+
return scoreB - scoreA;
|
|
93
|
+
});
|
|
94
|
+
return {
|
|
95
|
+
agents: results,
|
|
96
|
+
total: results.length,
|
|
97
|
+
query: params.toolName || "all",
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
return { error: `Discovery failed: ${error.message}`, agents: [], total: 0 };
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=discover-agents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover-agents.js","sourceRoot":"","sources":["../../src/tools/discover-agents.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGxC,SAAS,YAAY,CAAC,GAAW;IAC/B,IAAI,CAAC;QACH,IAAI,GAAG,CAAC,UAAU,CAAC,+BAA+B,CAAC,EAAE,CAAC;YACpD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,+BAA+B,EAAE,EAAE,CAAC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GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;YAC/D,MAAM,MAAM,GAAG,CAAC,CAAC,UAAU,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;YAC/D,OAAO,MAAM,GAAG,MAAM,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,OAAO;YACL,MAAM,EAAE,OAAO;YACf,KAAK,EAAE,OAAO,CAAC,MAAM;YACrB,KAAK,EAAE,MAAM,CAAC,QAAQ,IAAI,KAAK;SAChC,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,KAAK,EAAE,qBAAsB,KAAe,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAC1F,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* clawpay_register_agent — Register an agent on-chain in the ClawPay Agent Society.
|
|
3
|
+
*/
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import type { ClawPayPluginConfig } from "../config.js";
|
|
6
|
+
export declare const REGISTER_AGENT = "clawpay_register_agent";
|
|
7
|
+
export declare const registerAgentParameters: z.ZodObject<{
|
|
8
|
+
name: z.ZodString;
|
|
9
|
+
description: z.ZodString;
|
|
10
|
+
capabilities: z.ZodArray<z.ZodString, "many">;
|
|
11
|
+
mcpEndpoint: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
capabilities: string[];
|
|
16
|
+
mcpEndpoint?: string | undefined;
|
|
17
|
+
}, {
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
capabilities: string[];
|
|
21
|
+
mcpEndpoint?: string | undefined;
|
|
22
|
+
}>;
|
|
23
|
+
export declare const registerAgentDescription = "Register a new AI agent on-chain in the ClawPay Agent Society on Hedera.\nMints an ERC-721 NFT representing the agent's identity.\nThe agent's profile (name, description, capabilities) is stored as on-chain metadata.\nAfter registration, the agent can publish tool capabilities and receive payments.";
|
|
24
|
+
export declare function registerAgentExecute(config: ClawPayPluginConfig, params: z.infer<typeof registerAgentParameters>): Promise<{
|
|
25
|
+
error: string;
|
|
26
|
+
success?: undefined;
|
|
27
|
+
txHash?: undefined;
|
|
28
|
+
blockNumber?: undefined;
|
|
29
|
+
agent?: undefined;
|
|
30
|
+
} | {
|
|
31
|
+
success: boolean;
|
|
32
|
+
txHash: `0x${string}`;
|
|
33
|
+
blockNumber: number;
|
|
34
|
+
agent: {
|
|
35
|
+
name: string;
|
|
36
|
+
description: string;
|
|
37
|
+
owner: string;
|
|
38
|
+
evmAddress: `0x${string}`;
|
|
39
|
+
mcpEndpoint: string;
|
|
40
|
+
capabilities: string[];
|
|
41
|
+
createdAt: string;
|
|
42
|
+
};
|
|
43
|
+
error?: undefined;
|
|
44
|
+
}>;
|
|
45
|
+
//# sourceMappingURL=register-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-agent.d.ts","sourceRoot":"","sources":["../../src/tools/register-agent.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD,eAAO,MAAM,cAAc,2BAA2B,CAAC;AAEvD,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;EAKlC,CAAC;AAEH,eAAO,MAAM,wBAAwB,gTAG6C,CAAC;AAEnF,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC;;;;;;;;;;;;;;;;;;;;GAwDhD"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* clawpay_register_agent — Register an agent on-chain in the ClawPay Agent Society.
|
|
3
|
+
*/
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { createPublicClient, createWalletClient, http } from "viem";
|
|
6
|
+
import { hederaTestnet } from "viem/chains";
|
|
7
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
8
|
+
import { registryAbi } from "../abi.js";
|
|
9
|
+
export const REGISTER_AGENT = "clawpay_register_agent";
|
|
10
|
+
export const registerAgentParameters = z.object({
|
|
11
|
+
name: z.string().describe("Display name for the agent."),
|
|
12
|
+
description: z.string().describe("What this agent does."),
|
|
13
|
+
capabilities: z.array(z.string()).describe("List of tool names this agent offers."),
|
|
14
|
+
mcpEndpoint: z.string().optional().describe("MCP server URL where this agent's tools are accessible."),
|
|
15
|
+
});
|
|
16
|
+
export const registerAgentDescription = `Register a new AI agent on-chain in the ClawPay Agent Society on Hedera.
|
|
17
|
+
Mints an ERC-721 NFT representing the agent's identity.
|
|
18
|
+
The agent's profile (name, description, capabilities) is stored as on-chain metadata.
|
|
19
|
+
After registration, the agent can publish tool capabilities and receive payments.`;
|
|
20
|
+
export async function registerAgentExecute(config, params) {
|
|
21
|
+
if (!config.operatorKey) {
|
|
22
|
+
return { error: "No operator key configured. Set HEDERA_OPERATOR_KEY to register agents." };
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const key = config.operatorKey.startsWith("0x")
|
|
26
|
+
? config.operatorKey
|
|
27
|
+
: `0x${config.operatorKey}`;
|
|
28
|
+
const account = privateKeyToAccount(key);
|
|
29
|
+
const walletClient = createWalletClient({
|
|
30
|
+
account,
|
|
31
|
+
chain: hederaTestnet,
|
|
32
|
+
transport: http(config.rpcUrl),
|
|
33
|
+
});
|
|
34
|
+
const publicClient = createPublicClient({
|
|
35
|
+
chain: hederaTestnet,
|
|
36
|
+
transport: http(config.rpcUrl),
|
|
37
|
+
});
|
|
38
|
+
// Build profile metadata
|
|
39
|
+
const profile = {
|
|
40
|
+
name: params.name,
|
|
41
|
+
description: params.description,
|
|
42
|
+
owner: config.operatorId || "",
|
|
43
|
+
evmAddress: account.address,
|
|
44
|
+
mcpEndpoint: params.mcpEndpoint || "",
|
|
45
|
+
capabilities: params.capabilities,
|
|
46
|
+
createdAt: new Date().toISOString(),
|
|
47
|
+
};
|
|
48
|
+
const uri = `data:application/json;base64,${Buffer.from(JSON.stringify(profile)).toString("base64")}`;
|
|
49
|
+
const hash = await walletClient.writeContract({
|
|
50
|
+
address: config.registryAddress,
|
|
51
|
+
abi: registryAbi,
|
|
52
|
+
functionName: "registerAgent",
|
|
53
|
+
args: [uri],
|
|
54
|
+
gas: 500000n,
|
|
55
|
+
});
|
|
56
|
+
// Wait for receipt
|
|
57
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
58
|
+
return {
|
|
59
|
+
success: true,
|
|
60
|
+
txHash: hash,
|
|
61
|
+
blockNumber: Number(receipt.blockNumber),
|
|
62
|
+
agent: profile,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
return { error: `Registration failed: ${error.message}` };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=register-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-agent.js","sourceRoot":"","sources":["../../src/tools/register-agent.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,IAAI,EAAsB,MAAM,MAAM,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGxC,MAAM,CAAC,MAAM,cAAc,GAAG,wBAAwB,CAAC;AAEvD,MAAM,CAAC,MAAM,u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C,IAAI;YACjB,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,KAAK,EAAE,MAAM,CAAC,UAAU,IAAI,EAAE;YAC9B,UAAU,EAAE,OAAO,CAAC,OAAO;YAC3B,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,EAAE;YACrC,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC;QAEF,MAAM,GAAG,GAAG,gCAAgC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAEtG,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,aAAa,CAAC;YAC5C,OAAO,EAAE,MAAM,CAAC,eAAe;YAC/B,GAAG,EAAE,WAAW;YAChB,YAAY,EAAE,eAAe;YAC7B,IAAI,EAAE,CAAC,GAAG,CAAC;YACX,GAAG,EAAE,OAAQ;SACd,CAAC,CAAC;QAEH,mBAAmB;QACnB,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,yBAAyB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QAEvE,OAAO;YACL,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,IAAI;YACZ,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC;YACxC,KAAK,EAAE,OAAO;SACf,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,KAAK,EAAE,wBAAyB,KAAe,CAAC,OAAO,EAAE,EAAE,CAAC;IACvE,CAAC;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@clawpay-hedera/hak-plugin",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "ClawPay plugin for Hedera Agent Kit — discover, pay for, and rate AI agent tools on Hedera via x402",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"dev": "tsc --watch",
|
|
11
|
+
"clean": "rm -rf dist"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"hedera",
|
|
15
|
+
"agent-kit",
|
|
16
|
+
"clawpay",
|
|
17
|
+
"x402",
|
|
18
|
+
"mcp",
|
|
19
|
+
"ai-agents",
|
|
20
|
+
"plugin"
|
|
21
|
+
],
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"viem": "2.37.13",
|
|
28
|
+
"@hashgraph/sdk": "^2.58.0",
|
|
29
|
+
"zod": "^3.25.76"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"hedera-agent-kit": ">=3.0.0"
|
|
33
|
+
},
|
|
34
|
+
"peerDependenciesMeta": {
|
|
35
|
+
"hedera-agent-kit": {
|
|
36
|
+
"optional": true
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "^20.0.0",
|
|
41
|
+
"typescript": "^5.8.3"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist",
|
|
45
|
+
"README.md"
|
|
46
|
+
]
|
|
47
|
+
}
|