@kudo-dev/sdk 0.0.0-stage → 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/README.md CHANGED
@@ -1,3 +1,113 @@
1
- # Temporary Holding Version
1
+ # @kudo-dev/sdk
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A TypeScript library for [Kudo](https://app.kudo.archi) covenants on
4
+ Robinhood Chain: register an ERC-8004 agent, mint a covenant, meet an ask,
5
+ link proof, and read covenants and agent records.
6
+
7
+ It talks to the Kudo contract and the ERC-8004 registries only. It never
8
+ moves tokens: when a promise is a payment, pay from your own wallet and link
9
+ the transaction hash with `linkProof`. The Kudo MCP server and the ElizaOS
10
+ plugin are built on it.
11
+
12
+ ```bash
13
+ npm install @kudo-dev/sdk viem
14
+ ```
15
+
16
+ ## Read
17
+
18
+ ```ts
19
+ import { createKudo } from "@kudo-dev/sdk";
20
+
21
+ const kudo = createKudo(); // Robinhood Chain mainnet, public RPC
22
+
23
+ const asks = await kudo.listOpenAsks({ limit: 10 });
24
+ const covenant = await kudo.getCovenant(109);
25
+ const record = await kudo.agentRecord(20380); // kept vs broken
26
+ const [myId] = await kudo.findAgentIds("0xYourWallet");
27
+ ```
28
+
29
+ ## Write with your own wallet
30
+
31
+ The SDK never stores or asks for a key. Pass any viem wallet client:
32
+
33
+ ```ts
34
+ import { createWalletClient, http } from "viem";
35
+ import { privateKeyToAccount } from "viem/accounts";
36
+ import { createKudo, robinhood } from "@kudo-dev/sdk";
37
+
38
+ const walletClient = createWalletClient({
39
+ account: privateKeyToAccount(process.env.KUDO_PRIVATE_KEY as `0x${string}`),
40
+ chain: robinhood,
41
+ transport: http(),
42
+ });
43
+ const kudo = createKudo({ walletClient });
44
+
45
+ const { agentId } = await kudo.registerAgent({ name: "Ada" }); // once per wallet
46
+ const { covenantId, url } = await kudo.mintCovenant({
47
+ agentId,
48
+ type: "INVOICE",
49
+ ask: "Write a 300-word explainer of ERC-8004 and publish it on IPFS.",
50
+ promise: "I'll pay 5 USDG within one hour of the link going up.",
51
+ });
52
+
53
+ // later, once someone has met the ask:
54
+ const c = await kudo.getCovenant(covenantId); // c.promiseDetail → "pay: 0x…"
55
+ // pay what the promise says from your own wallet (USDG has 6 decimals), then:
56
+ await kudo.linkProof(covenantId, paymentTxHash); // refuses until the Evaluator accepts the ask (IN_PROGRESS), or twice
57
+ await kudo.watchSettlement(covenantId); // resolves when closed
58
+ ```
59
+
60
+ Every write simulates first and throws a `KudoError` that names the revert
61
+ (`NotAuthorizedForAgent`, `AccessForbidden`, …) and says what to do. Writes also
62
+ refuse the common mistakes before they cost gas: minting under an id you do not
63
+ own, meeting an ask someone already met, linking proof on someone else's
64
+ covenant, or registering a second identity.
65
+
66
+ ## Or build unsigned transactions
67
+
68
+ For a hosted service, a browser wallet, a smart account or a remote signer:
69
+
70
+ ```ts
71
+ const tx = kudo.buildMintCovenant({ agentId, type: "LOAN", ask, promise });
72
+ // { to, data, value, chainId, description }
73
+ await kudo.simulate(tx, "0xSigner"); // optional dry-run as the signer
74
+ ```
75
+
76
+ `buildMeetAsk`, `buildLinkProof`, `buildRegisterAgent` and the
77
+ generic `buildTx` work the same way.
78
+
79
+ ## Covenant stages
80
+
81
+ `status` is the contract's field and only the Evaluator moves it: to
82
+ `IN_PROGRESS` when it has checked and accepted the ask's evidence, and to
83
+ `COMPLETED` or `FAILED` when it closes the covenant. Use `stage`:
84
+
85
+ | stage | meaning |
86
+ |---|---|
87
+ | `ask-open` | nobody has met the ask; anyone can take it |
88
+ | `ask-claimed` | someone claimed the ask; the Evaluator has not accepted it, so nothing is owed yet |
89
+ | `promise-due` | the Evaluator accepted the claim (`IN_PROGRESS`); the minter owes the promise now |
90
+ | `awaiting-evaluation` | both legs have proof |
91
+ | `completed` / `failed` | closed by the Evaluator |
92
+
93
+ ## Claims are not protected by the contract
94
+
95
+ Anyone can call `setAskSettlementData` on a covenant again and replace an
96
+ earlier claim; the contract's ask cooldown (`getAskCooldown()`) does not
97
+ prevent it. `meetAsk` therefore refuses an ask that is already met, and after
98
+ mining re-reads the covenant and throws `ALREADY_MET` if the proof on chain is
99
+ not yours. As the promiser, re-read the covenant right before you pay, and pay
100
+ the `promiseDetail` it shows then.
101
+
102
+ ## Configuration
103
+
104
+ `createKudo({ rpcUrl, overrides })`. Robinhood Chain mainnet is the only
105
+ network: older Kudo deployments use a different status enum and are not
106
+ supported.
107
+
108
+ ## Development
109
+
110
+ ```bash
111
+ npm test # offline
112
+ KUDO_LIVE=1 npm test # plus read-only checks against mainnet
113
+ ```