@kleros/agentkit 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 +259 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +5696 -0
- package/dist/index.d.ts +1909 -0
- package/dist/index.js +477 -0
- package/package.json +66 -0
- package/skills/agentkit/SKILL.md +125 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kleros
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
# @kleros/agentkit
|
|
2
|
+
|
|
3
|
+
A CLI and toolkit for AI agents and humans to interact with the [Kleros](https://kleros.io) decentralized arbitration protocol.
|
|
4
|
+
|
|
5
|
+
Built with [incur](https://github.com/wevm/incur) — the CLI framework for agents and humans — and [viem](https://viem.sh) for on-chain interactions.
|
|
6
|
+
|
|
7
|
+
## Status
|
|
8
|
+
|
|
9
|
+
**0.1.0 — first public release.** Read-only command surface: courts, disputes, evidence, dispute/court policy, arbitrable classification, composite dispute brief, and juror stake/leaderboard queries across Ethereum, Gnosis, and Arbitrum Sepolia (devnet). Pre-1.0 — the API may change between minor versions. Write operations (staking, voting, dispute creation, appeals) are not yet available — see [Roadmap](#roadmap).
|
|
10
|
+
|
|
11
|
+
A programmatic `import`/`require` API is also exported from this package (see `exports` in `package.json`), but it is **undocumented and unstable pre-1.0** — the CLI/MCP/HTTP surface documented here is the supported interface, with no semver stability guarantees on internals.
|
|
12
|
+
|
|
13
|
+
## Quickstart
|
|
14
|
+
|
|
15
|
+
No installation required — run directly with `npx`:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npx -y @kleros/agentkit court list --chain ethereum
|
|
19
|
+
npx -y @kleros/agentkit dispute get 797 --chain gnosis --format json
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
For repeated use, install globally instead:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
npm i -g @kleros/agentkit
|
|
26
|
+
kleros court list --chain ethereum
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## What is this?
|
|
30
|
+
|
|
31
|
+
Kleros is a decentralized dispute resolution protocol deployed on Arbitrum, Gnosis, and Ethereum. **@kleros/agentkit** gives agents and developers a single, token-efficient interface to:
|
|
32
|
+
|
|
33
|
+
- Browse courts, disputes, and juror activity
|
|
34
|
+
- Resolve court and dispute policy (what jurors are asked to apply when ruling)
|
|
35
|
+
- Walk evidence submissions, including IPFS-hosted attachments
|
|
36
|
+
- Classify arbitrable contracts and pull a composite dispute brief in one call
|
|
37
|
+
- Rank jurors by staked PNK
|
|
38
|
+
|
|
39
|
+
Every command works from the terminal, as an MCP server, or as an HTTP API — with zero extra configuration. Write operations (staking, voting, creating disputes, submitting evidence, interacting with Curate/escrow/Reality.eth, ERC-8183 evaluators) are planned but not yet shipped — see [Roadmap](#roadmap).
|
|
40
|
+
|
|
41
|
+
## Features
|
|
42
|
+
|
|
43
|
+
- **Agent-first:** [TOON](https://github.com/toon-format/toon) output by default (40% fewer tokens than JSON), call-to-actions, token pagination, `--llms` manifest
|
|
44
|
+
- **Human-friendly:** readable table output, interactive fallbacks, shell completions
|
|
45
|
+
- **MCP built-in:** `kleros --mcp` starts an MCP stdio server. `cli.fetch` exposes an HTTP MCP endpoint at `/mcp`
|
|
46
|
+
- **Multi-chain reads:** Arbitrum Sepolia devnet (v2), Gnosis (v1), Ethereum (v1) with automatic version routing
|
|
47
|
+
|
|
48
|
+
## Architecture
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
+--------------------------------------------------+
|
|
52
|
+
| Kleros Skills (SKILL.md) | Agent-facing docs, examples,
|
|
53
|
+
| Wraps CLI with context, explains when and why | progressive disclosure
|
|
54
|
+
| to use each command |
|
|
55
|
+
+------------+--------------+----------------------+
|
|
56
|
+
| CLI | MCP Server | HTTP API | incur surfaces
|
|
57
|
+
| kleros .. | --mcp | cli.fetch | TOON output, CTAs,
|
|
58
|
+
| | | | token pagination
|
|
59
|
+
+------------+--------------+----------------------+
|
|
60
|
+
| Middleware (incur) | Chain resolution
|
|
61
|
+
| cli.use() -- chain resolution (read-only; | (no wallet middleware
|
|
62
|
+
| no wallet middleware shipped yet) | shipped yet)
|
|
63
|
+
+--------------------------------------------------+
|
|
64
|
+
| Core Functions (TypeScript) | Pure business logic,
|
|
65
|
+
| disputes, courts, evidence, policy, arbitrable | read-only,
|
|
66
|
+
| | framework-agnostic
|
|
67
|
+
+--------------------------------------------------+
|
|
68
|
+
| viem (on-chain reads) + subgraph (The Graph) + | Multi-chain
|
|
69
|
+
| IPFS (cdn.kleros.link) |
|
|
70
|
+
+--------------------------------------------------+
|
|
71
|
+
| Kleros Contracts (read paths) | Arbitrum Sepolia (v2),
|
|
72
|
+
| KlerosCore/KlerosLiquid, SortitionModule, | Gnosis (v1),
|
|
73
|
+
| DisputeKitClassic, EvidenceModule | Ethereum (v1)
|
|
74
|
+
+--------------------------------------------------+
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Write-path components (wallet providers, staking, voting, dispute creation, Curate/escrow/Reality.eth integration) are planned but not part of this diagram — see [Roadmap](#roadmap).
|
|
78
|
+
|
|
79
|
+
## Agent Usage
|
|
80
|
+
|
|
81
|
+
### In-Repo Skill
|
|
82
|
+
|
|
83
|
+
AgentKit ships a Claude Code skill at [`skills/agentkit/SKILL.md`](./skills/agentkit/SKILL.md). Loading this skill gives agents the full command surface, peer-MCP composition guidance (markitdown-mcp for binary evidence), policy intersection rules, and common gotchas — all from the repo itself without network fetches.
|
|
84
|
+
|
|
85
|
+
To install in your project: copy or reference `skills/agentkit/SKILL.md` in your Claude Code configuration.
|
|
86
|
+
|
|
87
|
+
### MCP Server (Claude Code, Cursor, Amp)
|
|
88
|
+
|
|
89
|
+
Register kleros as an MCP tool server so AI agents can call dispute queries directly. No installation required — the one-liner uses `npx`:
|
|
90
|
+
|
|
91
|
+
```sh
|
|
92
|
+
claude mcp add kleros -- npx -y @kleros/agentkit --mcp
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Already installed the binary globally? Register it directly instead:
|
|
96
|
+
|
|
97
|
+
```sh
|
|
98
|
+
npx -y @kleros/agentkit mcp add # registers for Claude Code and Cursor by default
|
|
99
|
+
kleros --mcp # or start manually (stdio transport)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Chain configuration:** MCP clients cannot switch chain per-call — set it at server-start time:
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
KLEROS_CHAIN=gnosis npx -y @kleros/agentkit --mcp
|
|
106
|
+
# Or persist: kleros config set chain gnosis
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Tool Discovery (`--llms`)
|
|
110
|
+
|
|
111
|
+
```sh
|
|
112
|
+
kleros --llms # compact table -- best for agents
|
|
113
|
+
kleros --llms-full # full docs with args, options, output schemas
|
|
114
|
+
kleros --llms --format json # JSON for structured parsing
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Example MCP Tool Call (JSON-RPC)
|
|
118
|
+
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"jsonrpc": "2.0",
|
|
122
|
+
"id": 1,
|
|
123
|
+
"method": "tools/call",
|
|
124
|
+
"params": {
|
|
125
|
+
"name": "dispute_list",
|
|
126
|
+
"arguments": { "court": "1", "limit": 10 }
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Tool names follow the pattern `group_command` (e.g., `dispute_list`, `court_get`, `juror_info`).
|
|
132
|
+
|
|
133
|
+
### Context-Aware Suggestions (CTAs)
|
|
134
|
+
|
|
135
|
+
Every response includes a `cta` block with the next logical command:
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"data": { "id": "42", "status": "Vote", "court": "1" },
|
|
140
|
+
"cta": {
|
|
141
|
+
"description": "Voting period -- review evidence and court policy",
|
|
142
|
+
"commands": [
|
|
143
|
+
{ "command": "evidence list", "description": "Review evidence before voting" },
|
|
144
|
+
{ "command": "court policy", "description": "Read court policy for this ruling" }
|
|
145
|
+
]
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
For full MCP configuration options, see the [incur documentation](https://github.com/wevm/incur).
|
|
151
|
+
|
|
152
|
+
## Configuration
|
|
153
|
+
|
|
154
|
+
Persist defaults with `config set` to avoid passing flags on every command. Configuration is stored in `~/.kleros/config.json`.
|
|
155
|
+
|
|
156
|
+
### Supported keys
|
|
157
|
+
|
|
158
|
+
<!-- Single source of truth: CONFIG_KEYS constant in src/commands/config.ts -->
|
|
159
|
+
|
|
160
|
+
| Key | Type | Values | Description |
|
|
161
|
+
|-----|------|--------|-------------|
|
|
162
|
+
| `chain` | string | `ethereum`, `gnosis`, `arbitrum-sepolia` | Default chain for all commands. Overridden by `--chain` flag per-command. |
|
|
163
|
+
|
|
164
|
+
### Commands
|
|
165
|
+
|
|
166
|
+
```sh
|
|
167
|
+
kleros config set chain gnosis # Persist default chain
|
|
168
|
+
kleros config get chain # Read current value
|
|
169
|
+
kleros config unset chain # Remove persisted value (revert to flag/env resolution)
|
|
170
|
+
kleros config list # Show all persisted keys
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
**Unknown keys** are rejected with `INVALID_CONFIG_KEY` — only the keys listed above are supported.
|
|
174
|
+
|
|
175
|
+
## Environment Variables
|
|
176
|
+
|
|
177
|
+
| Variable | Purpose |
|
|
178
|
+
|----------|---------|
|
|
179
|
+
| `KLEROS_RPC_URL_ETHEREUM` | Override the default public Ethereum RPC. Required for Reality handler integration tests on Ethereum (disputes 1650, 1651) — must be an Infura or Alchemy endpoint (public RPCs do not support historical `eth_getLogs`). Also required for `pnpm update-deployment-blocks`. |
|
|
180
|
+
| `KLEROS_RPC_URL_GNOSIS` | Override the default public Gnosis RPC (e.g. `https://rpc.gnosischain.com`). A public Gnosis RPC is accepted by default since Gnosis archives `eth_getLogs` broadly. |
|
|
181
|
+
| `KLEROS_RPC_URL_SEPOLIA` | Override the default public Arbitrum Sepolia RPC. Required for Reality handler integration tests on Sepolia (disputes 111, 112) — must be an Infura or Alchemy endpoint. Also required for `pnpm update-deployment-blocks`. |
|
|
182
|
+
| `KLEROS_INTEGRATION_TESTS` | Set to `true` to enable integration tests that hit live subgraph and IPFS endpoints. |
|
|
183
|
+
| `KLEROS_CHAIN` | Default chain for the MCP server. Use `kleros config set chain <id>` for persistent config. |
|
|
184
|
+
|
|
185
|
+
**Default RPCs are free public endpoints** — fine for light use, but may rate-limit under real traffic. Set the `KLEROS_RPC_URL_*` overrides above to a dedicated provider (Infura, Alchemy, or any RPC you trust) for reliable production use, especially right after this package's public launch.
|
|
186
|
+
|
|
187
|
+
### Feedback
|
|
188
|
+
|
|
189
|
+
`kleros report-issue create` writes a local `.md` report by default. `kleros report-issue create --submit` posts it as a GitHub issue — by default to the public [`kleros/kleros-skills`](https://github.com/kleros/kleros-skills) repository (requires `$GITHUB_TOKEN`). This repository (`kleros/agentkit`) stays private for now and would reject non-collaborator issue submissions, which is why `report-issue` targets `kleros/kleros-skills` instead.
|
|
190
|
+
|
|
191
|
+
## Development
|
|
192
|
+
|
|
193
|
+
### Setup
|
|
194
|
+
|
|
195
|
+
**Requires Node.js >=22.**
|
|
196
|
+
|
|
197
|
+
```sh
|
|
198
|
+
pnpm install
|
|
199
|
+
pnpm build
|
|
200
|
+
pnpm test
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Testing the MCP server against live source
|
|
204
|
+
|
|
205
|
+
The installed `kleros` binary is `dist/cli.js`, so code changes need a rebuild before the MCP server sees them. Three loops, fastest first:
|
|
206
|
+
|
|
207
|
+
**1. Raw stdio (no client, no rebuild)** — iterate on tools and handshake logic:
|
|
208
|
+
|
|
209
|
+
```sh
|
|
210
|
+
pnpm dev -- --mcp # runs tsx src/cli.ts --mcp
|
|
211
|
+
# pipe JSON-RPC frames in to exercise tools/list, tools/call, etc.
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**2. tsx-shimmed registration (live source, restart per change)** — iterate from inside Claude Code, Cursor, or any MCP client without rebuilding:
|
|
215
|
+
|
|
216
|
+
```sh
|
|
217
|
+
# Edit ~/.claude.json -> mcpServers.kleros:
|
|
218
|
+
# "command": "tsx",
|
|
219
|
+
# "args": ["/absolute/path/to/agentkit/src/cli.ts", "--mcp"]
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Restart the MCP client after each code change. No `pnpm build` needed — tsx reads src/*.ts directly.
|
|
223
|
+
|
|
224
|
+
**3. Globally linked binary (closest to production)** — test the real install flow end-to-end:
|
|
225
|
+
|
|
226
|
+
```sh
|
|
227
|
+
pnpm build
|
|
228
|
+
pnpm link --global # symlinks `kleros` -> this repo's dist/cli.js
|
|
229
|
+
which kleros # verify it points at your pnpm global bin
|
|
230
|
+
kleros mcp add # registers `kleros --mcp` in ~/.claude.json
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Iteration loop: `pnpm build` after each change, then restart the MCP client.
|
|
234
|
+
|
|
235
|
+
Teardown:
|
|
236
|
+
|
|
237
|
+
```sh
|
|
238
|
+
pnpm unlink --global @kleros/agentkit
|
|
239
|
+
# then re-run `kleros mcp add` against the published version, or edit ~/.claude.json manually
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Gotchas
|
|
243
|
+
|
|
244
|
+
- **Tool list is cached at session start** — adding a new command requires both rebuild AND client restart before it appears in `tools/list`.
|
|
245
|
+
- **Chain is pinned at server-start** — MCP clients start the server once per session. To switch chains, pass `chain` inside tool arguments, or set `KLEROS_CHAIN` and restart the client.
|
|
246
|
+
- **Empty `dist/cli.js` after a pull** — the `kleros` shebang will fail silently. Run `pnpm build` first.
|
|
247
|
+
- **Multiple local checkouts** — `pnpm link --global` only tracks the most-recently-linked one.
|
|
248
|
+
|
|
249
|
+
## Roadmap
|
|
250
|
+
|
|
251
|
+
Planned, not yet shipped:
|
|
252
|
+
|
|
253
|
+
- **Write operations** — staking PNK, casting votes, creating disputes, submitting evidence, appealing rulings (requires wallet middleware)
|
|
254
|
+
- **Wallet-agnostic signing** — plug in any EVM wallet (raw private key, Coinbase CDP, Privy, or any viem-compatible signer)
|
|
255
|
+
- **Curate, escrow, and Reality.eth integration** — registry entries, escrow payouts, oracle question resolution
|
|
256
|
+
- **ERC-8183 evaluator registration and invocation**
|
|
257
|
+
- **v2 beta support** — Arbitrum One reads, `dispute policy` via DisputeTemplate/`@kleros/sdk`, then v2 dispute creation (Arbitrum Sepolia *testnet* is not planned — only Arbitrum One beta and the existing devnet)
|
|
258
|
+
|
|
259
|
+
Not yet scheduled to a specific release. Tracked internally; file a [feedback report](#feedback) if there's a specific capability you need.
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|