@kairoguard/sdk 0.0.2 → 0.0.4
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 +92 -92
- package/dist/cli.js +32 -28
- package/dist/skill-templates.d.ts +1 -1
- package/dist/skill-templates.js +243 -243
- package/package.json +29 -29
package/README.md
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
# `@kairo/sdk` (MVP)
|
|
2
|
-
|
|
3
|
-
MVP helpers for:
|
|
4
|
-
|
|
5
|
-
- computing an **EVM intent hash** (Keccak256 over serialized unsigned tx bytes)
|
|
6
|
-
- building a Sui transaction to mint a **hard-gate** `PolicyReceipt`
|
|
7
|
-
- fetching + validating a `PolicyReceipt` / `PolicyReceiptV2` object for gating
|
|
8
|
-
- verifying a Sui custody `CustodyEvent` hash (v2/v3 canonical BCS hashing)
|
|
9
|
-
|
|
10
|
-
## Install
|
|
11
|
-
|
|
12
|
-
From repo root:
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
npm install
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## DApp flow (user mints receipt with their Sui wallet)
|
|
19
|
-
|
|
20
|
-
1) Your app computes the EVM unsigned tx bytes and intent hash:
|
|
21
|
-
|
|
22
|
-
```ts
|
|
23
|
-
import { computeEvmIntentFromUnsignedTxBytes } from "@kairo/sdk";
|
|
24
|
-
|
|
25
|
-
const { intentHash } = computeEvmIntentFromUnsignedTxBytes({
|
|
26
|
-
chainId: 84532, // Base Sepolia (example)
|
|
27
|
-
unsignedTxBytesHex, // 0x... serialized unsigned EIP-1559 tx bytes
|
|
28
|
-
});
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
2) Build a Sui tx that mints a receipt:
|
|
32
|
-
|
|
33
|
-
```ts
|
|
34
|
-
import { buildMintEvmReceiptTx } from "@kairo/sdk";
|
|
35
|
-
|
|
36
|
-
const tx = buildMintEvmReceiptTx({
|
|
37
|
-
packageId,
|
|
38
|
-
policyObjectId,
|
|
39
|
-
evmChainId: 84532,
|
|
40
|
-
intentHash,
|
|
41
|
-
toEvm,
|
|
42
|
-
});
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
3) Have the user sign+execute the Sui tx with their wallet (example using Sui dApp kit):
|
|
46
|
-
|
|
47
|
-
```ts
|
|
48
|
-
// Pseudocode: your wallet adapter will differ depending on your stack.
|
|
49
|
-
const result = await wallet.signAndExecuteTransaction({
|
|
50
|
-
transaction: tx,
|
|
51
|
-
chain: "sui:testnet",
|
|
52
|
-
});
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
4) Extract the created receipt object id from the execution result, then hard-gate EVM signing:
|
|
56
|
-
|
|
57
|
-
```ts
|
|
58
|
-
// We’ll add a helper for extracting created receipt IDs once we standardize receipt type strings.
|
|
59
|
-
// For now, you can scan result.effects.created for the created object id of PolicyReceipt.
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## Demo/extension flow (backend mints receipt)
|
|
63
|
-
|
|
64
|
-
In this repo’s Key‑Spring demo, the backend mints the receipt (so the extension UX stays “approve action” instead of “approve Sui tx”).
|
|
65
|
-
The verifier helper `fetchAndValidatePolicyReceipt` supports both receipt types:
|
|
66
|
-
|
|
67
|
-
- legacy `PolicyReceipt` (MVP)
|
|
68
|
-
- `PolicyReceiptV2` (includes `policy_root` + `policy_version_id` + optional selector/amount)
|
|
69
|
-
|
|
70
|
-
If you also log to the custody ledger, you can verify a specific custody event hash:
|
|
71
|
-
|
|
72
|
-
```ts
|
|
73
|
-
import { fetchAndVerifyCustodyEvent } from "@kairo/sdk";
|
|
74
|
-
|
|
75
|
-
const res = await fetchAndVerifyCustodyEvent({
|
|
76
|
-
suiRpcUrl,
|
|
77
|
-
custodyEventObjectId: "0x...",
|
|
78
|
-
});
|
|
79
|
-
if (!res.ok) throw new Error(res.error);
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
1
|
+
# `@kairo/sdk` (MVP)
|
|
2
|
+
|
|
3
|
+
MVP helpers for:
|
|
4
|
+
|
|
5
|
+
- computing an **EVM intent hash** (Keccak256 over serialized unsigned tx bytes)
|
|
6
|
+
- building a Sui transaction to mint a **hard-gate** `PolicyReceipt`
|
|
7
|
+
- fetching + validating a `PolicyReceipt` / `PolicyReceiptV2` object for gating
|
|
8
|
+
- verifying a Sui custody `CustodyEvent` hash (v2/v3 canonical BCS hashing)
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
From repo root:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## DApp flow (user mints receipt with their Sui wallet)
|
|
19
|
+
|
|
20
|
+
1) Your app computes the EVM unsigned tx bytes and intent hash:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { computeEvmIntentFromUnsignedTxBytes } from "@kairo/sdk";
|
|
24
|
+
|
|
25
|
+
const { intentHash } = computeEvmIntentFromUnsignedTxBytes({
|
|
26
|
+
chainId: 84532, // Base Sepolia (example)
|
|
27
|
+
unsignedTxBytesHex, // 0x... serialized unsigned EIP-1559 tx bytes
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
2) Build a Sui tx that mints a receipt:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { buildMintEvmReceiptTx } from "@kairo/sdk";
|
|
35
|
+
|
|
36
|
+
const tx = buildMintEvmReceiptTx({
|
|
37
|
+
packageId,
|
|
38
|
+
policyObjectId,
|
|
39
|
+
evmChainId: 84532,
|
|
40
|
+
intentHash,
|
|
41
|
+
toEvm,
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
3) Have the user sign+execute the Sui tx with their wallet (example using Sui dApp kit):
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
// Pseudocode: your wallet adapter will differ depending on your stack.
|
|
49
|
+
const result = await wallet.signAndExecuteTransaction({
|
|
50
|
+
transaction: tx,
|
|
51
|
+
chain: "sui:testnet",
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
4) Extract the created receipt object id from the execution result, then hard-gate EVM signing:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
// We’ll add a helper for extracting created receipt IDs once we standardize receipt type strings.
|
|
59
|
+
// For now, you can scan result.effects.created for the created object id of PolicyReceipt.
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Demo/extension flow (backend mints receipt)
|
|
63
|
+
|
|
64
|
+
In this repo’s Key‑Spring demo, the backend mints the receipt (so the extension UX stays “approve action” instead of “approve Sui tx”).
|
|
65
|
+
The verifier helper `fetchAndValidatePolicyReceipt` supports both receipt types:
|
|
66
|
+
|
|
67
|
+
- legacy `PolicyReceipt` (MVP)
|
|
68
|
+
- `PolicyReceiptV2` (includes `policy_root` + `policy_version_id` + optional selector/amount)
|
|
69
|
+
|
|
70
|
+
If you also log to the custody ledger, you can verify a specific custody event hash:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { fetchAndVerifyCustodyEvent } from "@kairo/sdk";
|
|
74
|
+
|
|
75
|
+
const res = await fetchAndVerifyCustodyEvent({
|
|
76
|
+
suiRpcUrl,
|
|
77
|
+
custodyEventObjectId: "0x...",
|
|
78
|
+
});
|
|
79
|
+
if (!res.ok) throw new Error(res.error);
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
package/dist/cli.js
CHANGED
|
@@ -7,6 +7,7 @@ import { BackendClient } from "./backend.js";
|
|
|
7
7
|
import { SKILL_MD, API_REFERENCE_MD, SDK_REFERENCE_MD } from "./skill-templates.js";
|
|
8
8
|
const CONFIG_DIR = join(homedir(), ".kairo");
|
|
9
9
|
const CONFIG_PATH = join(CONFIG_DIR, "config.json");
|
|
10
|
+
const DEFAULT_BACKEND_URL = "https://backend.0xlegacy.link";
|
|
10
11
|
function loadConfig() {
|
|
11
12
|
if (!existsSync(CONFIG_PATH))
|
|
12
13
|
return null;
|
|
@@ -20,14 +21,16 @@ function loadConfig() {
|
|
|
20
21
|
function requireConfig() {
|
|
21
22
|
const cfg = loadConfig();
|
|
22
23
|
if (!cfg) {
|
|
23
|
-
console.error("No Kairo config found. Run: npx @kairo/sdk init <
|
|
24
|
+
console.error("No Kairo config found. Run: npx @kairo/sdk init <YOUR_KEY>");
|
|
24
25
|
process.exit(1);
|
|
25
26
|
}
|
|
26
27
|
return cfg;
|
|
27
28
|
}
|
|
28
|
-
function getClient(apiKeyOverride) {
|
|
29
|
-
const
|
|
30
|
-
|
|
29
|
+
function getClient(apiKeyOverride, backendUrlOverride) {
|
|
30
|
+
const cfg = requireConfig();
|
|
31
|
+
const key = apiKeyOverride ?? cfg.apiKey;
|
|
32
|
+
const backendUrl = backendUrlOverride ?? cfg.backendUrl ?? DEFAULT_BACKEND_URL;
|
|
33
|
+
return new BackendClient({ apiKey: key, backendUrl });
|
|
31
34
|
}
|
|
32
35
|
// ── Arg helpers ─────────────────────────────────────────────────────────────
|
|
33
36
|
function flag(args, name) {
|
|
@@ -47,12 +50,13 @@ function requireFlag(args, name, label) {
|
|
|
47
50
|
// ── Commands ────────────────────────────────────────────────────────────────
|
|
48
51
|
async function cmdInit(args) {
|
|
49
52
|
const apiKey = args[0];
|
|
53
|
+
const backendUrl = flag(args, "--backend-url") ?? DEFAULT_BACKEND_URL;
|
|
50
54
|
if (!apiKey) {
|
|
51
|
-
console.error("Usage: kairo init <
|
|
55
|
+
console.error("Usage: kairo init <YOUR_KEY> [--backend-url <url>]");
|
|
52
56
|
process.exit(1);
|
|
53
57
|
}
|
|
54
58
|
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
55
|
-
writeFileSync(CONFIG_PATH, JSON.stringify({ apiKey }, null, 2) + "\n", "utf8");
|
|
59
|
+
writeFileSync(CONFIG_PATH, JSON.stringify({ apiKey, backendUrl }, null, 2) + "\n", "utf8");
|
|
56
60
|
console.log(` Config written to ${CONFIG_PATH}`);
|
|
57
61
|
const skillDir = join(process.cwd(), ".cursor", "skills", "kairo");
|
|
58
62
|
const refsDir = join(skillDir, "references");
|
|
@@ -61,13 +65,13 @@ async function cmdInit(args) {
|
|
|
61
65
|
writeFileSync(join(refsDir, "api.md"), API_REFERENCE_MD, "utf8");
|
|
62
66
|
writeFileSync(join(refsDir, "sdk.md"), SDK_REFERENCE_MD, "utf8");
|
|
63
67
|
console.log(` Skill files installed to ${skillDir}`);
|
|
64
|
-
const client = new BackendClient({ apiKey });
|
|
68
|
+
const client = new BackendClient({ apiKey, backendUrl });
|
|
65
69
|
try {
|
|
66
70
|
await client.getHealth();
|
|
67
|
-
console.log(
|
|
71
|
+
console.log(` Backend connection verified (${backendUrl}).`);
|
|
68
72
|
}
|
|
69
73
|
catch {
|
|
70
|
-
console.log(
|
|
74
|
+
console.log(` Warning: could not reach backend ${backendUrl} (check your network).`);
|
|
71
75
|
}
|
|
72
76
|
console.log("\nKairo is ready. Your AI agent can now read the skill at .cursor/skills/kairo/SKILL.md");
|
|
73
77
|
}
|
|
@@ -171,25 +175,25 @@ async function cmdAuditVerify(args) {
|
|
|
171
175
|
console.log("OK");
|
|
172
176
|
}
|
|
173
177
|
function printUsage() {
|
|
174
|
-
console.log(`Kairo CLI — Agent Wallet Operations
|
|
175
|
-
|
|
176
|
-
Usage: kairo <command> [options]
|
|
177
|
-
|
|
178
|
-
Setup:
|
|
179
|
-
init <
|
|
180
|
-
|
|
181
|
-
Wallet & Policy:
|
|
182
|
-
health Server health check
|
|
183
|
-
register --label <name> Register new API key
|
|
184
|
-
policy-create --stable-id <id> --allow <addrs> Create policy
|
|
185
|
-
policy-register --policy-id <id> Register policy version
|
|
186
|
-
policy-details --policy-id <id> Get policy details
|
|
187
|
-
vault-status --wallet-id <id> Check vault registration
|
|
188
|
-
vault-provision --wallet-id <id> --policy-id <id> --stable-id <id>
|
|
189
|
-
receipt-mint --policy-id <id> --binding-id <id> --destination <hex> --intent-hash <hex>
|
|
190
|
-
|
|
191
|
-
Utility:
|
|
192
|
-
audit --limit <n> List audit events
|
|
178
|
+
console.log(`Kairo CLI — Agent Wallet Operations
|
|
179
|
+
|
|
180
|
+
Usage: kairo <command> [options]
|
|
181
|
+
|
|
182
|
+
Setup:
|
|
183
|
+
init <YOUR_KEY> [--backend-url <url>] Store API key, backend URL, and install skill files
|
|
184
|
+
|
|
185
|
+
Wallet & Policy:
|
|
186
|
+
health Server health check
|
|
187
|
+
register --label <name> Register new API key
|
|
188
|
+
policy-create --stable-id <id> --allow <addrs> Create policy
|
|
189
|
+
policy-register --policy-id <id> Register policy version
|
|
190
|
+
policy-details --policy-id <id> Get policy details
|
|
191
|
+
vault-status --wallet-id <id> Check vault registration
|
|
192
|
+
vault-provision --wallet-id <id> --policy-id <id> --stable-id <id>
|
|
193
|
+
receipt-mint --policy-id <id> --binding-id <id> --destination <hex> --intent-hash <hex>
|
|
194
|
+
|
|
195
|
+
Utility:
|
|
196
|
+
audit --limit <n> List audit events
|
|
193
197
|
audit verify --sui <url> --bundle <path> Verify audit bundle`);
|
|
194
198
|
}
|
|
195
199
|
// ── Main ────────────────────────────────────────────────────────────────────
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
* All backend URLs are intentionally omitted -- the SDK and CLI
|
|
5
5
|
* resolve the endpoint internally.
|
|
6
6
|
*/
|
|
7
|
-
export declare const SKILL_MD = "---\nname: kairo\ndescription: Manage Kairo policy-enforced agent wallets. Use when creating wallets, setting transaction policies, checking vault status, minting policy receipts, or signing transactions through the Kairo SDK/CLI. Supports full wallet lifecycle: register API key -> create wallet (DKG) -> create policy -> bind -> vault provision -> mint receipt -> sign. Uses @kairo/sdk for non-custodial wallet creation (agent keeps secret share locally).\n---\n\n# Kairo \u2014 Agent Wallet Management\n\n## Quick Reference\n\nCLI: `npx kairo <command>`\nSDK reference: `.cursor/skills/kairo/references/sdk.md`\nAPI reference: `.cursor/skills/kairo/references/api.md`\n\n## Setup\n\nRun the one-line installer (already done if you see this file):\n```bash\nnpx @kairo/sdk init <
|
|
7
|
+
export declare const SKILL_MD = "---\nname: kairo\ndescription: Manage Kairo policy-enforced agent wallets. Use when creating wallets, setting transaction policies, checking vault status, minting policy receipts, or signing transactions through the Kairo SDK/CLI. Supports full wallet lifecycle: register API key -> create wallet (DKG) -> create policy -> bind -> vault provision -> mint receipt -> sign. Uses @kairo/sdk for non-custodial wallet creation (agent keeps secret share locally).\n---\n\n# Kairo \u2014 Agent Wallet Management\n\n## Quick Reference\n\nCLI: `npx kairo <command>`\nSDK reference: `.cursor/skills/kairo/references/sdk.md`\nAPI reference: `.cursor/skills/kairo/references/api.md`\n\n## Setup\n\nRun the one-line installer (already done if you see this file):\n```bash\nnpx @kairo/sdk init <YOUR_KEY>\n```\n\nThe API key is stored in `~/.kairo/config.json`. All CLI commands read it automatically.\n\n## Common Workflows\n\n### Check API Health\n```bash\nnpx kairo health\n```\n\n### Create a Policy\n```bash\nnpx kairo policy-create --stable-id \"my-policy\" --allow \"0x742d35Cc6634C0532925a3b844Bc9e7595f2bD18\"\n```\nThen register the version:\n```bash\nnpx kairo policy-register --policy-id \"0x...\"\n```\n\n### Create Wallet (via SDK)\nFor wallet creation, use the Node.js SDK (handles DKG client-side):\n```typescript\nimport { KairoClient } from \"@kairo/sdk\";\nconst kairo = new KairoClient({ apiKey: process.env.KAIRO_API_KEY! });\nconst wallet = await kairo.createWallet({ curve: \"secp256k1\" });\n```\nSee `.cursor/skills/kairo/references/sdk.md` for full SDK docs.\n\n### Provision Wallet into Vault\nRequires: policy version registered first.\n```bash\nnpx kairo vault-provision --wallet-id \"0x...\" --policy-id \"0x...\" --stable-id \"my-policy\"\n```\n\n### Mint Policy Receipt\n```bash\nnpx kairo receipt-mint --policy-id \"0x...\" --binding-id \"0x...\" --destination \"0x742d35Cc...\" --intent-hash \"0xabab...\"\n```\n\n### Check Vault Status\n```bash\nnpx kairo vault-status --wallet-id \"0x...\"\n```\n\n### View Audit Events\n```bash\nnpx kairo audit --limit 20\n```\n\n## Full Agent Flow (End to End)\n\n1. `npx @kairo/sdk init <YOUR_KEY>` \u2014 store API key, install skill\n2. `npx kairo policy-create` \u2014 create transaction policy with allowed addresses\n3. `npx kairo policy-register` \u2014 register version in on-chain registry\n4. Create wallet via SDK `createWallet()` \u2014 runs DKG locally, secret share stays on agent\n5. `npx kairo vault-provision` \u2014 bind policy + register wallet in vault (atomic)\n6. `npx kairo receipt-mint` \u2014 request policy check for a transaction\n7. Sign via SDK \u2014 both shares combine, only if policy allows\n\n## Trust Model\n\n- Agent's key share stays local (`~/.kairo/keys/`)\n- Server's key share stays on Kairo backend\n- Neither party can sign alone\n- Policy engine gates every transaction before server releases its share\n- All policy decisions are on-chain (Sui) and verifiable\n\n## Troubleshooting\n\n- **401 Unauthorized**: API key missing/invalid or not registered in backend key store. Re-run `npx @kairo/sdk init <YOUR_KEY>` with a valid key.\n- **403 Forbidden: key does not own wallet**: Wallet wasn't created/provisioned with this API key (ownership mismatch).\n- **429 Rate limit**: Public Sui RPC throttled \u2014 use Shinami or own RPC provider.\n- **MoveAbort code 102**: Policy version not registered \u2014 call `npx kairo policy-register` before `vault-provision`.\n- **`nonce too low` / `already known`**: Rapid reruns or duplicate raw tx; wait for pending tx, then re-sign and rebroadcast.\n- **AwaitingKeyHolderSignature**: Wallet needs activation after DKG \u2014 SDK activation flow required.\n";
|
|
8
8
|
export declare const API_REFERENCE_MD = "# Kairo API Reference\n\n## Authentication\nAll write endpoints require `X-Kairo-Api-Key` header.\nThe CLI reads the key from `~/.kairo/config.json` automatically.\nOpen endpoints: `/health`, `/api/vault/info`, `/api/vault/status/:id`, `/api/audit/events`\n\n## Key Registration\n```bash\nnpx kairo register --label \"my-agent\"\n```\n\n## Wallet Creation (via SDK)\nThe SDK handles DKG client-side. Agent keeps their secret share locally.\n```typescript\nimport { KairoClient } from \"@kairo/sdk\";\nconst kairo = new KairoClient({ apiKey: process.env.KAIRO_API_KEY! });\nconst wallet = await kairo.createWallet({ curve: \"secp256k1\" });\n// wallet.walletId, wallet.address\n```\n\n## Policy Management\n\n### Create Policy\n```bash\nnpx kairo policy-create --stable-id \"my-policy\" --version \"1.0.0\" --allow \"0x<address>\"\n```\n\nRule types:\n- `1` = MaxNativeValue (max single transaction value)\n- `10` = PeriodLimit (cumulative spend limit per time window)\n\n### Register Policy Version\n```bash\nnpx kairo policy-register --policy-id \"0x...\"\n```\n\n### Get Policy Details\n```bash\nnpx kairo policy-details --policy-id \"0x...\"\n```\n\n## Vault\n\n### Provision (atomic binding + vault registration)\n```bash\nnpx kairo vault-provision --wallet-id \"0x...\" --policy-id \"0x...\" --stable-id \"my-policy\"\n```\nNote: Register policy version BEFORE calling provision.\n\n### Check Status\n```bash\nnpx kairo vault-status --wallet-id \"0x...\"\n```\n\n## Receipt Minting\n```bash\nnpx kairo receipt-mint --policy-id \"0x...\" --binding-id \"0x...\" --destination \"0x...\" --intent-hash \"0x...\"\n```\nNamespace: 1=EVM, 2=Bitcoin, 3=Solana\n\n## Utility\n```bash\nnpx kairo health # Server health\nnpx kairo audit --limit 20 # Recent audit events\n```\n";
|
|
9
9
|
export declare const SDK_REFERENCE_MD = "# Kairo SDK Reference\n\n## Installation\n```bash\nnpm install @kairo/sdk\n```\n\nRequires: `@ika.xyz/sdk`, `@mysten/sui`\n\n## KairoClient\n\n```typescript\nimport { KairoClient } from \"@kairo/sdk\";\n\nconst kairo = new KairoClient({\n apiKey: process.env.KAIRO_API_KEY!,\n storePath: \"~/.kairo/keys\", // local secret share storage (default)\n network: \"testnet\", // or \"mainnet\"\n suiRpcUrl: \"https://...\", // optional, defaults to public testnet\n});\n```\n\n### createWallet(opts?)\nCreates a dWallet via client-side DKG. Secret share stays local.\n\n```typescript\nconst wallet = await kairo.createWallet({\n curve: \"secp256k1\", // or \"ed25519\" for Solana\n policyObjectId: \"0x...\", // optional: auto-provision into vault\n stableId: \"my-policy\", // optional: binding label\n});\n// Returns: { walletId, address, curve, bindingObjectId?, createdAt }\n```\n\n**Important:** If providing `policyObjectId`, register the policy version first.\n\n### listWallets()\nLists all wallets in local key store.\n```typescript\nconst wallets = kairo.listWallets();\n```\n\n### getWallet(walletId)\nGets a specific wallet from local store.\n```typescript\nconst w = kairo.getWallet(\"0x...\");\n```\n\n## BackendClient (HTTP wrapper)\nLower-level HTTP client for direct API calls.\n\n```typescript\nimport { BackendClient } from \"@kairo/sdk\";\n\nconst client = new BackendClient({ apiKey: \"your-key\" });\n\nawait client.register(\"my-agent\");\nawait client.getHealth();\nawait client.submitDKG({...});\nawait client.getDKGStatus(requestId);\nawait client.provision({...});\nawait client.mintReceipt({...});\n```\n\n## KeyStore (local storage)\nFile-based secret share storage at `~/.kairo/keys/`.\n\n```typescript\nimport { KeyStore } from \"@kairo/sdk\";\n\nconst store = new KeyStore(\"~/.kairo/keys\");\nstore.save(record);\nstore.load(\"0x...\");\nstore.list();\nstore.delete(\"0x...\");\n```\n\n## Trust Model\n- Agent's secret share -> stored locally (KeyStore), never sent to server\n- Server's share -> held by Kairo backend\n- Full signing -> requires BOTH shares + policy approval\n- Kairo alone cannot sign (missing agent share)\n- Agent alone cannot sign (missing server share)\n";
|
package/dist/skill-templates.js
CHANGED
|
@@ -4,249 +4,249 @@
|
|
|
4
4
|
* All backend URLs are intentionally omitted -- the SDK and CLI
|
|
5
5
|
* resolve the endpoint internally.
|
|
6
6
|
*/
|
|
7
|
-
export const SKILL_MD = `---
|
|
8
|
-
name: kairo
|
|
9
|
-
description: Manage Kairo policy-enforced agent wallets. Use when creating wallets, setting transaction policies, checking vault status, minting policy receipts, or signing transactions through the Kairo SDK/CLI. Supports full wallet lifecycle: register API key -> create wallet (DKG) -> create policy -> bind -> vault provision -> mint receipt -> sign. Uses @kairo/sdk for non-custodial wallet creation (agent keeps secret share locally).
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
# Kairo — Agent Wallet Management
|
|
13
|
-
|
|
14
|
-
## Quick Reference
|
|
15
|
-
|
|
16
|
-
CLI: \`npx kairo <command>\`
|
|
17
|
-
SDK reference: \`.cursor/skills/kairo/references/sdk.md\`
|
|
18
|
-
API reference: \`.cursor/skills/kairo/references/api.md\`
|
|
19
|
-
|
|
20
|
-
## Setup
|
|
21
|
-
|
|
22
|
-
Run the one-line installer (already done if you see this file):
|
|
23
|
-
\`\`\`bash
|
|
24
|
-
npx @kairo/sdk init <
|
|
25
|
-
\`\`\`
|
|
26
|
-
|
|
27
|
-
The API key is stored in \`~/.kairo/config.json\`. All CLI commands read it automatically.
|
|
28
|
-
|
|
29
|
-
## Common Workflows
|
|
30
|
-
|
|
31
|
-
### Check API Health
|
|
32
|
-
\`\`\`bash
|
|
33
|
-
npx kairo health
|
|
34
|
-
\`\`\`
|
|
35
|
-
|
|
36
|
-
### Create a Policy
|
|
37
|
-
\`\`\`bash
|
|
38
|
-
npx kairo policy-create --stable-id "my-policy" --allow "0x742d35Cc6634C0532925a3b844Bc9e7595f2bD18"
|
|
39
|
-
\`\`\`
|
|
40
|
-
Then register the version:
|
|
41
|
-
\`\`\`bash
|
|
42
|
-
npx kairo policy-register --policy-id "0x..."
|
|
43
|
-
\`\`\`
|
|
44
|
-
|
|
45
|
-
### Create Wallet (via SDK)
|
|
46
|
-
For wallet creation, use the Node.js SDK (handles DKG client-side):
|
|
47
|
-
\`\`\`typescript
|
|
48
|
-
import { KairoClient } from "@kairo/sdk";
|
|
49
|
-
const kairo = new KairoClient({ apiKey: process.env.KAIRO_API_KEY! });
|
|
50
|
-
const wallet = await kairo.createWallet({ curve: "secp256k1" });
|
|
51
|
-
\`\`\`
|
|
52
|
-
See \`.cursor/skills/kairo/references/sdk.md\` for full SDK docs.
|
|
53
|
-
|
|
54
|
-
### Provision Wallet into Vault
|
|
55
|
-
Requires: policy version registered first.
|
|
56
|
-
\`\`\`bash
|
|
57
|
-
npx kairo vault-provision --wallet-id "0x..." --policy-id "0x..." --stable-id "my-policy"
|
|
58
|
-
\`\`\`
|
|
59
|
-
|
|
60
|
-
### Mint Policy Receipt
|
|
61
|
-
\`\`\`bash
|
|
62
|
-
npx kairo receipt-mint --policy-id "0x..." --binding-id "0x..." --destination "0x742d35Cc..." --intent-hash "0xabab..."
|
|
63
|
-
\`\`\`
|
|
64
|
-
|
|
65
|
-
### Check Vault Status
|
|
66
|
-
\`\`\`bash
|
|
67
|
-
npx kairo vault-status --wallet-id "0x..."
|
|
68
|
-
\`\`\`
|
|
69
|
-
|
|
70
|
-
### View Audit Events
|
|
71
|
-
\`\`\`bash
|
|
72
|
-
npx kairo audit --limit 20
|
|
73
|
-
\`\`\`
|
|
74
|
-
|
|
75
|
-
## Full Agent Flow (End to End)
|
|
76
|
-
|
|
77
|
-
1. \`npx @kairo/sdk init <
|
|
78
|
-
2. \`npx kairo policy-create\` — create transaction policy with allowed addresses
|
|
79
|
-
3. \`npx kairo policy-register\` — register version in on-chain registry
|
|
80
|
-
4. Create wallet via SDK \`createWallet()\` — runs DKG locally, secret share stays on agent
|
|
81
|
-
5. \`npx kairo vault-provision\` — bind policy + register wallet in vault (atomic)
|
|
82
|
-
6. \`npx kairo receipt-mint\` — request policy check for a transaction
|
|
83
|
-
7. Sign via SDK — both shares combine, only if policy allows
|
|
84
|
-
|
|
85
|
-
## Trust Model
|
|
86
|
-
|
|
87
|
-
- Agent's key share stays local (\`~/.kairo/keys/\`)
|
|
88
|
-
- Server's key share stays on Kairo backend
|
|
89
|
-
- Neither party can sign alone
|
|
90
|
-
- Policy engine gates every transaction before server releases its share
|
|
91
|
-
- All policy decisions are on-chain (Sui) and verifiable
|
|
92
|
-
|
|
93
|
-
## Troubleshooting
|
|
94
|
-
|
|
95
|
-
- **401 Unauthorized**: API key missing/invalid or not registered in backend key store. Re-run \`npx @kairo/sdk init <
|
|
96
|
-
- **403 Forbidden: key does not own wallet**: Wallet wasn't created/provisioned with this API key (ownership mismatch).
|
|
97
|
-
- **429 Rate limit**: Public Sui RPC throttled — use Shinami or own RPC provider.
|
|
98
|
-
- **MoveAbort code 102**: Policy version not registered — call \`npx kairo policy-register\` before \`vault-provision\`.
|
|
99
|
-
- **\`nonce too low\` / \`already known\`**: Rapid reruns or duplicate raw tx; wait for pending tx, then re-sign and rebroadcast.
|
|
100
|
-
- **AwaitingKeyHolderSignature**: Wallet needs activation after DKG — SDK activation flow required.
|
|
7
|
+
export const SKILL_MD = `---
|
|
8
|
+
name: kairo
|
|
9
|
+
description: Manage Kairo policy-enforced agent wallets. Use when creating wallets, setting transaction policies, checking vault status, minting policy receipts, or signing transactions through the Kairo SDK/CLI. Supports full wallet lifecycle: register API key -> create wallet (DKG) -> create policy -> bind -> vault provision -> mint receipt -> sign. Uses @kairo/sdk for non-custodial wallet creation (agent keeps secret share locally).
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Kairo — Agent Wallet Management
|
|
13
|
+
|
|
14
|
+
## Quick Reference
|
|
15
|
+
|
|
16
|
+
CLI: \`npx kairo <command>\`
|
|
17
|
+
SDK reference: \`.cursor/skills/kairo/references/sdk.md\`
|
|
18
|
+
API reference: \`.cursor/skills/kairo/references/api.md\`
|
|
19
|
+
|
|
20
|
+
## Setup
|
|
21
|
+
|
|
22
|
+
Run the one-line installer (already done if you see this file):
|
|
23
|
+
\`\`\`bash
|
|
24
|
+
npx @kairo/sdk init <YOUR_KEY>
|
|
25
|
+
\`\`\`
|
|
26
|
+
|
|
27
|
+
The API key is stored in \`~/.kairo/config.json\`. All CLI commands read it automatically.
|
|
28
|
+
|
|
29
|
+
## Common Workflows
|
|
30
|
+
|
|
31
|
+
### Check API Health
|
|
32
|
+
\`\`\`bash
|
|
33
|
+
npx kairo health
|
|
34
|
+
\`\`\`
|
|
35
|
+
|
|
36
|
+
### Create a Policy
|
|
37
|
+
\`\`\`bash
|
|
38
|
+
npx kairo policy-create --stable-id "my-policy" --allow "0x742d35Cc6634C0532925a3b844Bc9e7595f2bD18"
|
|
39
|
+
\`\`\`
|
|
40
|
+
Then register the version:
|
|
41
|
+
\`\`\`bash
|
|
42
|
+
npx kairo policy-register --policy-id "0x..."
|
|
43
|
+
\`\`\`
|
|
44
|
+
|
|
45
|
+
### Create Wallet (via SDK)
|
|
46
|
+
For wallet creation, use the Node.js SDK (handles DKG client-side):
|
|
47
|
+
\`\`\`typescript
|
|
48
|
+
import { KairoClient } from "@kairo/sdk";
|
|
49
|
+
const kairo = new KairoClient({ apiKey: process.env.KAIRO_API_KEY! });
|
|
50
|
+
const wallet = await kairo.createWallet({ curve: "secp256k1" });
|
|
51
|
+
\`\`\`
|
|
52
|
+
See \`.cursor/skills/kairo/references/sdk.md\` for full SDK docs.
|
|
53
|
+
|
|
54
|
+
### Provision Wallet into Vault
|
|
55
|
+
Requires: policy version registered first.
|
|
56
|
+
\`\`\`bash
|
|
57
|
+
npx kairo vault-provision --wallet-id "0x..." --policy-id "0x..." --stable-id "my-policy"
|
|
58
|
+
\`\`\`
|
|
59
|
+
|
|
60
|
+
### Mint Policy Receipt
|
|
61
|
+
\`\`\`bash
|
|
62
|
+
npx kairo receipt-mint --policy-id "0x..." --binding-id "0x..." --destination "0x742d35Cc..." --intent-hash "0xabab..."
|
|
63
|
+
\`\`\`
|
|
64
|
+
|
|
65
|
+
### Check Vault Status
|
|
66
|
+
\`\`\`bash
|
|
67
|
+
npx kairo vault-status --wallet-id "0x..."
|
|
68
|
+
\`\`\`
|
|
69
|
+
|
|
70
|
+
### View Audit Events
|
|
71
|
+
\`\`\`bash
|
|
72
|
+
npx kairo audit --limit 20
|
|
73
|
+
\`\`\`
|
|
74
|
+
|
|
75
|
+
## Full Agent Flow (End to End)
|
|
76
|
+
|
|
77
|
+
1. \`npx @kairo/sdk init <YOUR_KEY>\` — store API key, install skill
|
|
78
|
+
2. \`npx kairo policy-create\` — create transaction policy with allowed addresses
|
|
79
|
+
3. \`npx kairo policy-register\` — register version in on-chain registry
|
|
80
|
+
4. Create wallet via SDK \`createWallet()\` — runs DKG locally, secret share stays on agent
|
|
81
|
+
5. \`npx kairo vault-provision\` — bind policy + register wallet in vault (atomic)
|
|
82
|
+
6. \`npx kairo receipt-mint\` — request policy check for a transaction
|
|
83
|
+
7. Sign via SDK — both shares combine, only if policy allows
|
|
84
|
+
|
|
85
|
+
## Trust Model
|
|
86
|
+
|
|
87
|
+
- Agent's key share stays local (\`~/.kairo/keys/\`)
|
|
88
|
+
- Server's key share stays on Kairo backend
|
|
89
|
+
- Neither party can sign alone
|
|
90
|
+
- Policy engine gates every transaction before server releases its share
|
|
91
|
+
- All policy decisions are on-chain (Sui) and verifiable
|
|
92
|
+
|
|
93
|
+
## Troubleshooting
|
|
94
|
+
|
|
95
|
+
- **401 Unauthorized**: API key missing/invalid or not registered in backend key store. Re-run \`npx @kairo/sdk init <YOUR_KEY>\` with a valid key.
|
|
96
|
+
- **403 Forbidden: key does not own wallet**: Wallet wasn't created/provisioned with this API key (ownership mismatch).
|
|
97
|
+
- **429 Rate limit**: Public Sui RPC throttled — use Shinami or own RPC provider.
|
|
98
|
+
- **MoveAbort code 102**: Policy version not registered — call \`npx kairo policy-register\` before \`vault-provision\`.
|
|
99
|
+
- **\`nonce too low\` / \`already known\`**: Rapid reruns or duplicate raw tx; wait for pending tx, then re-sign and rebroadcast.
|
|
100
|
+
- **AwaitingKeyHolderSignature**: Wallet needs activation after DKG — SDK activation flow required.
|
|
101
101
|
`;
|
|
102
|
-
export const API_REFERENCE_MD = `# Kairo API Reference
|
|
103
|
-
|
|
104
|
-
## Authentication
|
|
105
|
-
All write endpoints require \`X-Kairo-Api-Key\` header.
|
|
106
|
-
The CLI reads the key from \`~/.kairo/config.json\` automatically.
|
|
107
|
-
Open endpoints: \`/health\`, \`/api/vault/info\`, \`/api/vault/status/:id\`, \`/api/audit/events\`
|
|
108
|
-
|
|
109
|
-
## Key Registration
|
|
110
|
-
\`\`\`bash
|
|
111
|
-
npx kairo register --label "my-agent"
|
|
112
|
-
\`\`\`
|
|
113
|
-
|
|
114
|
-
## Wallet Creation (via SDK)
|
|
115
|
-
The SDK handles DKG client-side. Agent keeps their secret share locally.
|
|
116
|
-
\`\`\`typescript
|
|
117
|
-
import { KairoClient } from "@kairo/sdk";
|
|
118
|
-
const kairo = new KairoClient({ apiKey: process.env.KAIRO_API_KEY! });
|
|
119
|
-
const wallet = await kairo.createWallet({ curve: "secp256k1" });
|
|
120
|
-
// wallet.walletId, wallet.address
|
|
121
|
-
\`\`\`
|
|
122
|
-
|
|
123
|
-
## Policy Management
|
|
124
|
-
|
|
125
|
-
### Create Policy
|
|
126
|
-
\`\`\`bash
|
|
127
|
-
npx kairo policy-create --stable-id "my-policy" --version "1.0.0" --allow "0x<address>"
|
|
128
|
-
\`\`\`
|
|
129
|
-
|
|
130
|
-
Rule types:
|
|
131
|
-
- \`1\` = MaxNativeValue (max single transaction value)
|
|
132
|
-
- \`10\` = PeriodLimit (cumulative spend limit per time window)
|
|
133
|
-
|
|
134
|
-
### Register Policy Version
|
|
135
|
-
\`\`\`bash
|
|
136
|
-
npx kairo policy-register --policy-id "0x..."
|
|
137
|
-
\`\`\`
|
|
138
|
-
|
|
139
|
-
### Get Policy Details
|
|
140
|
-
\`\`\`bash
|
|
141
|
-
npx kairo policy-details --policy-id "0x..."
|
|
142
|
-
\`\`\`
|
|
143
|
-
|
|
144
|
-
## Vault
|
|
145
|
-
|
|
146
|
-
### Provision (atomic binding + vault registration)
|
|
147
|
-
\`\`\`bash
|
|
148
|
-
npx kairo vault-provision --wallet-id "0x..." --policy-id "0x..." --stable-id "my-policy"
|
|
149
|
-
\`\`\`
|
|
150
|
-
Note: Register policy version BEFORE calling provision.
|
|
151
|
-
|
|
152
|
-
### Check Status
|
|
153
|
-
\`\`\`bash
|
|
154
|
-
npx kairo vault-status --wallet-id "0x..."
|
|
155
|
-
\`\`\`
|
|
156
|
-
|
|
157
|
-
## Receipt Minting
|
|
158
|
-
\`\`\`bash
|
|
159
|
-
npx kairo receipt-mint --policy-id "0x..." --binding-id "0x..." --destination "0x..." --intent-hash "0x..."
|
|
160
|
-
\`\`\`
|
|
161
|
-
Namespace: 1=EVM, 2=Bitcoin, 3=Solana
|
|
162
|
-
|
|
163
|
-
## Utility
|
|
164
|
-
\`\`\`bash
|
|
165
|
-
npx kairo health # Server health
|
|
166
|
-
npx kairo audit --limit 20 # Recent audit events
|
|
167
|
-
\`\`\`
|
|
102
|
+
export const API_REFERENCE_MD = `# Kairo API Reference
|
|
103
|
+
|
|
104
|
+
## Authentication
|
|
105
|
+
All write endpoints require \`X-Kairo-Api-Key\` header.
|
|
106
|
+
The CLI reads the key from \`~/.kairo/config.json\` automatically.
|
|
107
|
+
Open endpoints: \`/health\`, \`/api/vault/info\`, \`/api/vault/status/:id\`, \`/api/audit/events\`
|
|
108
|
+
|
|
109
|
+
## Key Registration
|
|
110
|
+
\`\`\`bash
|
|
111
|
+
npx kairo register --label "my-agent"
|
|
112
|
+
\`\`\`
|
|
113
|
+
|
|
114
|
+
## Wallet Creation (via SDK)
|
|
115
|
+
The SDK handles DKG client-side. Agent keeps their secret share locally.
|
|
116
|
+
\`\`\`typescript
|
|
117
|
+
import { KairoClient } from "@kairo/sdk";
|
|
118
|
+
const kairo = new KairoClient({ apiKey: process.env.KAIRO_API_KEY! });
|
|
119
|
+
const wallet = await kairo.createWallet({ curve: "secp256k1" });
|
|
120
|
+
// wallet.walletId, wallet.address
|
|
121
|
+
\`\`\`
|
|
122
|
+
|
|
123
|
+
## Policy Management
|
|
124
|
+
|
|
125
|
+
### Create Policy
|
|
126
|
+
\`\`\`bash
|
|
127
|
+
npx kairo policy-create --stable-id "my-policy" --version "1.0.0" --allow "0x<address>"
|
|
128
|
+
\`\`\`
|
|
129
|
+
|
|
130
|
+
Rule types:
|
|
131
|
+
- \`1\` = MaxNativeValue (max single transaction value)
|
|
132
|
+
- \`10\` = PeriodLimit (cumulative spend limit per time window)
|
|
133
|
+
|
|
134
|
+
### Register Policy Version
|
|
135
|
+
\`\`\`bash
|
|
136
|
+
npx kairo policy-register --policy-id "0x..."
|
|
137
|
+
\`\`\`
|
|
138
|
+
|
|
139
|
+
### Get Policy Details
|
|
140
|
+
\`\`\`bash
|
|
141
|
+
npx kairo policy-details --policy-id "0x..."
|
|
142
|
+
\`\`\`
|
|
143
|
+
|
|
144
|
+
## Vault
|
|
145
|
+
|
|
146
|
+
### Provision (atomic binding + vault registration)
|
|
147
|
+
\`\`\`bash
|
|
148
|
+
npx kairo vault-provision --wallet-id "0x..." --policy-id "0x..." --stable-id "my-policy"
|
|
149
|
+
\`\`\`
|
|
150
|
+
Note: Register policy version BEFORE calling provision.
|
|
151
|
+
|
|
152
|
+
### Check Status
|
|
153
|
+
\`\`\`bash
|
|
154
|
+
npx kairo vault-status --wallet-id "0x..."
|
|
155
|
+
\`\`\`
|
|
156
|
+
|
|
157
|
+
## Receipt Minting
|
|
158
|
+
\`\`\`bash
|
|
159
|
+
npx kairo receipt-mint --policy-id "0x..." --binding-id "0x..." --destination "0x..." --intent-hash "0x..."
|
|
160
|
+
\`\`\`
|
|
161
|
+
Namespace: 1=EVM, 2=Bitcoin, 3=Solana
|
|
162
|
+
|
|
163
|
+
## Utility
|
|
164
|
+
\`\`\`bash
|
|
165
|
+
npx kairo health # Server health
|
|
166
|
+
npx kairo audit --limit 20 # Recent audit events
|
|
167
|
+
\`\`\`
|
|
168
168
|
`;
|
|
169
|
-
export const SDK_REFERENCE_MD = `# Kairo SDK Reference
|
|
170
|
-
|
|
171
|
-
## Installation
|
|
172
|
-
\`\`\`bash
|
|
173
|
-
npm install @kairo/sdk
|
|
174
|
-
\`\`\`
|
|
175
|
-
|
|
176
|
-
Requires: \`@ika.xyz/sdk\`, \`@mysten/sui\`
|
|
177
|
-
|
|
178
|
-
## KairoClient
|
|
179
|
-
|
|
180
|
-
\`\`\`typescript
|
|
181
|
-
import { KairoClient } from "@kairo/sdk";
|
|
182
|
-
|
|
183
|
-
const kairo = new KairoClient({
|
|
184
|
-
apiKey: process.env.KAIRO_API_KEY!,
|
|
185
|
-
storePath: "~/.kairo/keys", // local secret share storage (default)
|
|
186
|
-
network: "testnet", // or "mainnet"
|
|
187
|
-
suiRpcUrl: "https://...", // optional, defaults to public testnet
|
|
188
|
-
});
|
|
189
|
-
\`\`\`
|
|
190
|
-
|
|
191
|
-
### createWallet(opts?)
|
|
192
|
-
Creates a dWallet via client-side DKG. Secret share stays local.
|
|
193
|
-
|
|
194
|
-
\`\`\`typescript
|
|
195
|
-
const wallet = await kairo.createWallet({
|
|
196
|
-
curve: "secp256k1", // or "ed25519" for Solana
|
|
197
|
-
policyObjectId: "0x...", // optional: auto-provision into vault
|
|
198
|
-
stableId: "my-policy", // optional: binding label
|
|
199
|
-
});
|
|
200
|
-
// Returns: { walletId, address, curve, bindingObjectId?, createdAt }
|
|
201
|
-
\`\`\`
|
|
202
|
-
|
|
203
|
-
**Important:** If providing \`policyObjectId\`, register the policy version first.
|
|
204
|
-
|
|
205
|
-
### listWallets()
|
|
206
|
-
Lists all wallets in local key store.
|
|
207
|
-
\`\`\`typescript
|
|
208
|
-
const wallets = kairo.listWallets();
|
|
209
|
-
\`\`\`
|
|
210
|
-
|
|
211
|
-
### getWallet(walletId)
|
|
212
|
-
Gets a specific wallet from local store.
|
|
213
|
-
\`\`\`typescript
|
|
214
|
-
const w = kairo.getWallet("0x...");
|
|
215
|
-
\`\`\`
|
|
216
|
-
|
|
217
|
-
## BackendClient (HTTP wrapper)
|
|
218
|
-
Lower-level HTTP client for direct API calls.
|
|
219
|
-
|
|
220
|
-
\`\`\`typescript
|
|
221
|
-
import { BackendClient } from "@kairo/sdk";
|
|
222
|
-
|
|
223
|
-
const client = new BackendClient({ apiKey: "your-key" });
|
|
224
|
-
|
|
225
|
-
await client.register("my-agent");
|
|
226
|
-
await client.getHealth();
|
|
227
|
-
await client.submitDKG({...});
|
|
228
|
-
await client.getDKGStatus(requestId);
|
|
229
|
-
await client.provision({...});
|
|
230
|
-
await client.mintReceipt({...});
|
|
231
|
-
\`\`\`
|
|
232
|
-
|
|
233
|
-
## KeyStore (local storage)
|
|
234
|
-
File-based secret share storage at \`~/.kairo/keys/\`.
|
|
235
|
-
|
|
236
|
-
\`\`\`typescript
|
|
237
|
-
import { KeyStore } from "@kairo/sdk";
|
|
238
|
-
|
|
239
|
-
const store = new KeyStore("~/.kairo/keys");
|
|
240
|
-
store.save(record);
|
|
241
|
-
store.load("0x...");
|
|
242
|
-
store.list();
|
|
243
|
-
store.delete("0x...");
|
|
244
|
-
\`\`\`
|
|
245
|
-
|
|
246
|
-
## Trust Model
|
|
247
|
-
- Agent's secret share -> stored locally (KeyStore), never sent to server
|
|
248
|
-
- Server's share -> held by Kairo backend
|
|
249
|
-
- Full signing -> requires BOTH shares + policy approval
|
|
250
|
-
- Kairo alone cannot sign (missing agent share)
|
|
251
|
-
- Agent alone cannot sign (missing server share)
|
|
169
|
+
export const SDK_REFERENCE_MD = `# Kairo SDK Reference
|
|
170
|
+
|
|
171
|
+
## Installation
|
|
172
|
+
\`\`\`bash
|
|
173
|
+
npm install @kairo/sdk
|
|
174
|
+
\`\`\`
|
|
175
|
+
|
|
176
|
+
Requires: \`@ika.xyz/sdk\`, \`@mysten/sui\`
|
|
177
|
+
|
|
178
|
+
## KairoClient
|
|
179
|
+
|
|
180
|
+
\`\`\`typescript
|
|
181
|
+
import { KairoClient } from "@kairo/sdk";
|
|
182
|
+
|
|
183
|
+
const kairo = new KairoClient({
|
|
184
|
+
apiKey: process.env.KAIRO_API_KEY!,
|
|
185
|
+
storePath: "~/.kairo/keys", // local secret share storage (default)
|
|
186
|
+
network: "testnet", // or "mainnet"
|
|
187
|
+
suiRpcUrl: "https://...", // optional, defaults to public testnet
|
|
188
|
+
});
|
|
189
|
+
\`\`\`
|
|
190
|
+
|
|
191
|
+
### createWallet(opts?)
|
|
192
|
+
Creates a dWallet via client-side DKG. Secret share stays local.
|
|
193
|
+
|
|
194
|
+
\`\`\`typescript
|
|
195
|
+
const wallet = await kairo.createWallet({
|
|
196
|
+
curve: "secp256k1", // or "ed25519" for Solana
|
|
197
|
+
policyObjectId: "0x...", // optional: auto-provision into vault
|
|
198
|
+
stableId: "my-policy", // optional: binding label
|
|
199
|
+
});
|
|
200
|
+
// Returns: { walletId, address, curve, bindingObjectId?, createdAt }
|
|
201
|
+
\`\`\`
|
|
202
|
+
|
|
203
|
+
**Important:** If providing \`policyObjectId\`, register the policy version first.
|
|
204
|
+
|
|
205
|
+
### listWallets()
|
|
206
|
+
Lists all wallets in local key store.
|
|
207
|
+
\`\`\`typescript
|
|
208
|
+
const wallets = kairo.listWallets();
|
|
209
|
+
\`\`\`
|
|
210
|
+
|
|
211
|
+
### getWallet(walletId)
|
|
212
|
+
Gets a specific wallet from local store.
|
|
213
|
+
\`\`\`typescript
|
|
214
|
+
const w = kairo.getWallet("0x...");
|
|
215
|
+
\`\`\`
|
|
216
|
+
|
|
217
|
+
## BackendClient (HTTP wrapper)
|
|
218
|
+
Lower-level HTTP client for direct API calls.
|
|
219
|
+
|
|
220
|
+
\`\`\`typescript
|
|
221
|
+
import { BackendClient } from "@kairo/sdk";
|
|
222
|
+
|
|
223
|
+
const client = new BackendClient({ apiKey: "your-key" });
|
|
224
|
+
|
|
225
|
+
await client.register("my-agent");
|
|
226
|
+
await client.getHealth();
|
|
227
|
+
await client.submitDKG({...});
|
|
228
|
+
await client.getDKGStatus(requestId);
|
|
229
|
+
await client.provision({...});
|
|
230
|
+
await client.mintReceipt({...});
|
|
231
|
+
\`\`\`
|
|
232
|
+
|
|
233
|
+
## KeyStore (local storage)
|
|
234
|
+
File-based secret share storage at \`~/.kairo/keys/\`.
|
|
235
|
+
|
|
236
|
+
\`\`\`typescript
|
|
237
|
+
import { KeyStore } from "@kairo/sdk";
|
|
238
|
+
|
|
239
|
+
const store = new KeyStore("~/.kairo/keys");
|
|
240
|
+
store.save(record);
|
|
241
|
+
store.load("0x...");
|
|
242
|
+
store.list();
|
|
243
|
+
store.delete("0x...");
|
|
244
|
+
\`\`\`
|
|
245
|
+
|
|
246
|
+
## Trust Model
|
|
247
|
+
- Agent's secret share -> stored locally (KeyStore), never sent to server
|
|
248
|
+
- Server's share -> held by Kairo backend
|
|
249
|
+
- Full signing -> requires BOTH shares + policy approval
|
|
250
|
+
- Kairo alone cannot sign (missing agent share)
|
|
251
|
+
- Agent alone cannot sign (missing server share)
|
|
252
252
|
`;
|
package/package.json
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@kairoguard/sdk",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist"
|
|
9
|
-
],
|
|
10
|
-
"bin": {
|
|
11
|
-
"kairo": "dist/cli.js",
|
|
12
|
-
"kairo-audit": "dist/cli.js"
|
|
13
|
-
},
|
|
14
|
-
"scripts": {
|
|
15
|
-
"build": "tsc -p tsconfig.json",
|
|
16
|
-
"test": "node --test"
|
|
17
|
-
},
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"@ika.xyz/sdk": "^0.2.7",
|
|
20
|
-
"@mysten/sui": "^1.44.0",
|
|
21
|
-
"@noble/hashes": "^1.7.2",
|
|
22
|
-
"viem": "^2.23.10"
|
|
23
|
-
},
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"@types/node": "^20.11.30",
|
|
26
|
-
"typescript": "^5.4.5"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@kairoguard/sdk",
|
|
3
|
+
"version": "0.0.4",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"bin": {
|
|
11
|
+
"kairo": "dist/cli.js",
|
|
12
|
+
"kairo-audit": "dist/cli.js"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc -p tsconfig.json",
|
|
16
|
+
"test": "node --test"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@ika.xyz/sdk": "^0.2.7",
|
|
20
|
+
"@mysten/sui": "^1.44.0",
|
|
21
|
+
"@noble/hashes": "^1.7.2",
|
|
22
|
+
"viem": "^2.23.10"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^20.11.30",
|
|
26
|
+
"typescript": "^5.4.5"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|