@kaleidorg/mind 0.9.0 → 0.10.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/dist/guards.d.ts.map +1 -1
- package/dist/guards.js +20 -0
- package/dist/guards.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/kaleidoswap/contract.d.ts +7 -0
- package/dist/kaleidoswap/contract.d.ts.map +1 -1
- package/dist/kaleidoswap/contract.js +71 -17
- package/dist/kaleidoswap/contract.js.map +1 -1
- package/dist/kaleidoswap/index.d.ts +1 -1
- package/dist/kaleidoswap/index.d.ts.map +1 -1
- package/dist/kaleidoswap/index.js +1 -1
- package/dist/kaleidoswap/index.js.map +1 -1
- package/dist/qvac/provider.d.ts.map +1 -1
- package/dist/qvac/provider.js +115 -96
- package/dist/qvac/provider.js.map +1 -1
- package/dist/recipe/asset-send.js +1 -1
- package/dist/recipe/asset-send.js.map +1 -1
- package/dist/testing/mock-wallet.d.ts.map +1 -1
- package/dist/testing/mock-wallet.js +6 -0
- package/dist/testing/mock-wallet.js.map +1 -1
- package/dist/wallet/contract.d.ts +5 -0
- package/dist/wallet/contract.d.ts.map +1 -1
- package/dist/wallet/contract.js +39 -6
- package/dist/wallet/contract.js.map +1 -1
- package/package.json +1 -1
- package/scripts/snapshot-mcp-tools.mjs +38 -0
- package/skills/README.md +98 -64
- package/skills/bitrefill/SKILL.md +30 -157
- package/skills/channel-manager/SKILL.md +31 -52
- package/skills/flashnet-swaps/SKILL.md +24 -150
- package/skills/kaleido-node/SKILL.md +25 -55
- package/skills/kaleido-trading/SKILL.md +28 -172
- package/skills/kaleido-trading/references/assets.md +4 -4
- package/skills/kaleido-trading/references/atomic.md +5 -7
- package/skills/merchant-finder/SKILL.md +25 -108
- package/skills/paid-data/SKILL.md +25 -58
- package/skills/portfolio-manager/SKILL.md +26 -60
- package/skills/rgb-lightning-node/SKILL.md +37 -255
- package/skills/rgb-lightning-node/references/channels.md +34 -0
- package/skills/spark-wallet/SKILL.md +26 -228
- package/skills/submarine-swaps/SKILL.md +19 -37
- package/skills/wallet-assistant/SKILL.md +26 -44
- package/src/funnel.mind.test.ts +6 -5
- package/src/guards.test.ts +12 -0
- package/src/guards.ts +20 -0
- package/src/index.ts +1 -0
- package/src/kaleidoswap/contract.test.ts +32 -3
- package/src/kaleidoswap/contract.ts +65 -17
- package/src/kaleidoswap/index.ts +1 -0
- package/src/qvac/provider.test.ts +17 -0
- package/src/qvac/provider.ts +23 -4
- package/src/recipe/asset-send.ts +1 -1
- package/src/recipe/recipe.test.ts +1 -1
- package/src/skills/catalog.test.ts +215 -0
- package/src/skills/mcp-tools.snapshot.json +1938 -0
- package/src/testing/mock-wallet.ts +6 -0
- package/src/wallet/contract.test.ts +20 -1
- package/src/wallet/contract.ts +36 -6
- package/skills/dca/SKILL.md +0 -48
- package/skills/kaleido-lsps/SKILL.md +0 -131
- package/skills/liquidity-optimizer/SKILL.md +0 -91
|
@@ -1,166 +1,39 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: bitrefill
|
|
3
|
-
description: "Buy
|
|
4
|
-
tools: bitrefill_search, bitrefill_get_product, bitrefill_get_balance, bitrefill_create_invoice, bitrefill_get_invoice, bitrefill_get_order, spark_pay_invoice,
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
description: "Buy gift cards, mobile top-ups and eSIMs on Bitrefill (1,500+ brands, 180+ countries), paid from the Bitrefill balance or over Lightning: search, pick a package, create the invoice, read the redemption code."
|
|
4
|
+
tools: bitrefill_search, bitrefill_get_product, bitrefill_get_balance, bitrefill_create_invoice, bitrefill_get_invoice, bitrefill_get_order, spark_pay_invoice, rln_pay_invoice
|
|
5
|
+
requires-tools: bitrefill_search
|
|
6
|
+
triggers: bitrefill, gift card, gift cards, giftcard, voucher, top-up, topup, top up, esim, e-sim, mobile plan, prepaid, amazon, steam, google play, app store, itunes, playstation, xbox, netflix, spotify, uber
|
|
7
|
+
compatibility: "Needs BITREFILL_API_KEY (Personal) or BITREFILL_API_ID + BITREFILL_API_SECRET (Business); without them the tools are not registered."
|
|
7
8
|
metadata:
|
|
8
9
|
author: bitrefill
|
|
9
|
-
version: "3.
|
|
10
|
+
version: "3.1.0"
|
|
10
11
|
homepage: "https://www.bitrefill.com"
|
|
11
12
|
docs: "https://docs.bitrefill.com"
|
|
12
|
-
repository: "https://github.com/bitrefill/
|
|
13
|
+
repository: "https://github.com/bitrefill/agents"
|
|
13
14
|
---
|
|
14
|
-
|
|
15
15
|
# Bitrefill
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
browse <https://www.bitrefill.com> directly."* Don't fall back to
|
|
41
|
-
inventing products.
|
|
42
|
-
|
|
43
|
-
## Happy-path playbook
|
|
44
|
-
|
|
45
|
-
For a typical buy ("a $25 Amazon US gift card with my balance"):
|
|
46
|
-
|
|
47
|
-
1. **`bitrefill_search({ query, country? })`** — find candidate products.
|
|
48
|
-
- "amazon" → `{ query: "amazon", country: "US" }` if the user named a
|
|
49
|
-
country, else just `{ query: "amazon" }`.
|
|
50
|
-
- Returns a list of `{ id, name, country, category }` rows. Pick the one
|
|
51
|
-
that matches the user's intent. If multiple plausible matches, ask the
|
|
52
|
-
user once instead of guessing.
|
|
53
|
-
|
|
54
|
-
2. **`bitrefill_get_product({ product_id })`** — read the `packages` array
|
|
55
|
-
for the right denomination. Each package has `{ id, value, price,
|
|
56
|
-
currency }`. **The `package_id` is what you pass to create_invoice**, NOT
|
|
57
|
-
the bare `value`.
|
|
58
|
-
|
|
59
|
-
3. **`bitrefill_get_balance()`** *(optional)* — when the user said "with my
|
|
60
|
-
balance" or asked "can I afford it", verify the account has enough
|
|
61
|
-
before creating the invoice. Skip when paying with Lightning / on-chain.
|
|
62
|
-
|
|
63
|
-
4. **`bitrefill_create_invoice({ products, payment_method, ... })`** —
|
|
64
|
-
confirmation-gated spend. Choose `payment_method` per the user's request:
|
|
65
|
-
- `"balance"` + `auto_pay: true` — instant settlement from account
|
|
66
|
-
balance. **Default** when the user says "with my balance" or doesn't
|
|
67
|
-
specify and balance is sufficient.
|
|
68
|
-
- `"lightning"` — fastest crypto path. Response carries a BOLT11
|
|
69
|
-
invoice the user pays out-of-band (see step 5b — Spark, if connected,
|
|
70
|
-
pays it directly). **Requires `refund_address`** in case it expires.
|
|
71
|
-
- `"bitcoin"`, `"usdc_base"`, `"usdc_polygon"`, `"usdt_tron"`,
|
|
72
|
-
`"usdt_ethereum"` — same pattern, slower confirmation; also need
|
|
73
|
-
`refund_address`.
|
|
74
|
-
|
|
75
|
-
Line items: `products: [{ product_id, package_id, quantity }]`. Up to 20
|
|
76
|
-
per invoice.
|
|
77
|
-
|
|
78
|
-
5. **Settlement.**
|
|
79
|
-
|
|
80
|
-
a. **`balance` + `auto_pay:true`** — the invoice is usually `complete`
|
|
81
|
-
on creation. Read its `order_id`(s) and skip to step 6.
|
|
82
|
-
|
|
83
|
-
b. **`lightning` with Spark connected** — the response includes a BOLT11
|
|
84
|
-
invoice (commonly under `payment.lightning_invoice`, surface whatever
|
|
85
|
-
field the host returns). Pay it with **`spark_pay_invoice({ invoice:
|
|
86
|
-
<bolt11> })`** — that's one extra confirmation gate, and Spark settles
|
|
87
|
-
it in seconds. (Same pattern if RLN is the user's Lightning layer:
|
|
88
|
-
use `rln_pay_invoice`.) Then `bitrefill_get_invoice` should already
|
|
89
|
-
report `paid` / `complete`.
|
|
90
|
-
|
|
91
|
-
c. **`lightning` or on-chain without an on-device wallet** — relay the
|
|
92
|
-
payment URI to the user and **poll** `bitrefill_get_invoice({
|
|
93
|
-
invoice_id })` until `status:"complete"`. Don't poll faster than
|
|
94
|
-
every ~5s; give up after a few minutes and hand the invoice id back
|
|
95
|
-
to the user to check later.
|
|
96
|
-
|
|
97
|
-
6. **`bitrefill_get_order({ order_id })`** — read `redemption_info`:
|
|
98
|
-
- `.code` — the gift-card code or top-up PIN. The actual product.
|
|
99
|
-
- `.pin` — additional PIN for prepaid cards (often present alongside
|
|
100
|
-
the code).
|
|
101
|
-
- `.link` — brand redemption URL when applicable.
|
|
102
|
-
- `.instructions` — brand-specific redemption steps.
|
|
103
|
-
|
|
104
|
-
Present the code in the chat ONCE, then tell the user to store it and
|
|
105
|
-
redeem ASAP. Don't echo it in subsequent replies, summaries, or memory.
|
|
106
|
-
|
|
107
|
-
## Choosing a payment method
|
|
108
|
-
|
|
109
|
-
| Method | Speed | Blast radius | Use when |
|
|
110
|
-
|---|---|---|---|
|
|
111
|
-
| `balance` + `auto_pay:true` | Instant | Capped at account balance | Default. User pre-funded the account; lowest risk. |
|
|
112
|
-
| `lightning` | Seconds | Whatever's in the user's LN wallet | User asks for "pay with Lightning" or wants no pre-funding. |
|
|
113
|
-
| `bitcoin` | 10–60 min | One on-chain UTXO | User asks for "pay on-chain" or invoice > Lightning capacity. |
|
|
114
|
-
| `usdc_base` (x402) | Seconds | Agent USDC wallet balance | Agent has an x402-capable USDC wallet. |
|
|
115
|
-
| Other on-chain (USDT/USDC variants) | Variable | One UTXO per network | User explicitly requested. |
|
|
116
|
-
|
|
117
|
-
Default to `balance` when available; ask the user before switching to a
|
|
118
|
-
crypto method.
|
|
119
|
-
|
|
120
|
-
## Failure handling
|
|
121
|
-
|
|
122
|
-
Tool errors surface as thrown messages like `"bitrefill bitrefill_create_invoice failed: HTTP 401 ..."`. Relay them as plain English:
|
|
123
|
-
|
|
124
|
-
- **401 Unauthorized** — `BITREFILL_API_KEY` is unset or wrong. Tell the
|
|
125
|
-
user; don't retry.
|
|
126
|
-
- **400 / validation errors** — usually a bad `package_id` or
|
|
127
|
-
`payment_method`. Re-read the product's `packages` array and retry once,
|
|
128
|
-
then stop and ask.
|
|
129
|
-
- **402 Payment Required** (with `balance`) — account underfunded. Show
|
|
130
|
-
the deficit; suggest topping up or switching payment method.
|
|
131
|
-
- **Invoice `expired`** — re-create the invoice; an old quote isn't
|
|
132
|
-
reusable.
|
|
133
|
-
|
|
134
|
-
## Reply style
|
|
135
|
-
|
|
136
|
-
- Show the candidate product list as a short bulleted list (≤5 rows).
|
|
137
|
-
- Before the spend, summarize in one line:
|
|
138
|
-
`Buying: 1× Amazon US $25 — total $25.00 USD, paying with balance. Confirm?`
|
|
139
|
-
- After settlement: one line on success, then the redemption details on a
|
|
140
|
-
separate line so the user can copy the code.
|
|
141
|
-
- After delivering the code, suggest redeeming ASAP and do NOT repeat the
|
|
142
|
-
code in later turns.
|
|
143
|
-
|
|
144
|
-
## References (deep-dive, on demand)
|
|
145
|
-
|
|
146
|
-
The references below cover paths and host hardening — they're for hosts
|
|
147
|
-
that **don't** have the `bitrefill_*` tools wired (browser-only,
|
|
148
|
-
MCP-capable client, npm CLI, raw REST). When the tools above are
|
|
149
|
-
available, you don't need to read them.
|
|
150
|
-
|
|
151
|
-
| File | When |
|
|
152
|
-
|------|------|
|
|
153
|
-
| [api.md](references/api.md) | Mapping the contract tools back to raw REST endpoints. |
|
|
154
|
-
| [mcp.md](references/mcp.md) | Host has the Bitrefill remote MCP wired instead of the contract. |
|
|
155
|
-
| [cli.md](references/cli.md) | `@bitrefill/cli` npm path (auth-bound). |
|
|
156
|
-
| [cli-headless-auth.md](references/cli-headless-auth.md) | Magic-link auth via an agent inbox. |
|
|
157
|
-
| [browse.md](references/browse.md) | Browser-only hosts. |
|
|
158
|
-
| [host-openclaw.md](references/host-openclaw.md) | OpenClaw-specific path. |
|
|
159
|
-
| [capability-matrix.md](references/capability-matrix.md) | Per-client cheat sheet. |
|
|
160
|
-
| [safeguards.md](references/safeguards.md) | Spending policy + per-host hardening. |
|
|
161
|
-
| [troubleshooting.md](references/troubleshooting.md) | Common errors. |
|
|
162
|
-
|
|
163
|
-
## Source of truth
|
|
164
|
-
|
|
165
|
-
Skill describes the contract + playbook. For exhaustive enums (countries,
|
|
166
|
-
payment methods, full endpoint list), see <https://docs.bitrefill.com>.
|
|
17
|
+
Product and package ids come from `bitrefill_search` and
|
|
18
|
+
`bitrefill_get_product` in this turn; never invent them.
|
|
19
|
+
|
|
20
|
+
## Do
|
|
21
|
+
1. `bitrefill_search` (`query`, optional `country`); if several products match, ask once.
|
|
22
|
+
2. `bitrefill_get_product` (`product_id`); pick the package whose `value` matches
|
|
23
|
+
and use its `id` as `package_id`.
|
|
24
|
+
3. Show product, value, total price and payment method, then
|
|
25
|
+
`bitrefill_create_invoice` (confirm-gated):
|
|
26
|
+
- default `payment_method: "balance"` with `auto_pay: true` (check
|
|
27
|
+
`bitrefill_get_balance` first);
|
|
28
|
+
- `"lightning"` needs `refund_address`; pay the returned BOLT11 with
|
|
29
|
+
`spark_pay_invoice` or `rln_pay_invoice`.
|
|
30
|
+
4. Poll `bitrefill_get_invoice` until `complete`, then `bitrefill_get_order`.
|
|
31
|
+
Show `redemption_info.code` once and never repeat it.
|
|
32
|
+
- 401 means the API key is missing or wrong: say so and stop.
|
|
33
|
+
|
|
34
|
+
## Examples
|
|
35
|
+
- "A $25 Amazon US gift card" → `bitrefill_search {"query":"amazon","country":"US"}`
|
|
36
|
+
- "Show the packages" → `bitrefill_get_product {"product_id":"amazon-us"}`
|
|
37
|
+
- "Buy it with my balance" → `bitrefill_create_invoice {"products":[{"product_id":"amazon-us","package_id":"<package id>","quantity":1}],"payment_method":"balance","auto_pay":true}`
|
|
38
|
+
|
|
39
|
+
Hosts without these tools (remote MCP, CLI, browser): see `references/`.
|
|
@@ -1,59 +1,38 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: channel-manager
|
|
3
|
-
description: "
|
|
4
|
-
tools: rln_get_node_info, rln_list_channels, rln_get_balances,
|
|
5
|
-
|
|
3
|
+
description: "Lightning channels and liquidity for the RGB Lightning Node: node health, channel audit, inbound/outbound balance, buying a channel or asset channel from the KaleidoSwap LSP, opening and closing channels. Runs the scheduled heartbeat."
|
|
4
|
+
tools: rln_get_node_info, rln_list_channels, rln_get_balances, rln_refresh_transfers, rln_connect_peer, rln_open_channel, rln_close_channel, rln_get_channel_id, rln_pay_invoice, kaleidoswap_lsp_get_info, kaleidoswap_lsp_estimate_fees, kaleidoswap_lsp_create_order, kaleidoswap_lsp_get_order, kaleidoswap_lsp_quote_asset_channel, kaleidoswap_lsp_create_asset_channel
|
|
5
|
+
requires-tools: rln_list_channels
|
|
6
|
+
triggers: channel, channels, liquidity, inbound, outbound, lsp, lsps1, capacity, rebalance channel, can't receive, open channel, close channel, channel order, heartbeat, health, stuck
|
|
6
7
|
metadata:
|
|
7
8
|
author: kaleidoswap
|
|
8
|
-
version: "0.
|
|
9
|
+
version: "0.2.0"
|
|
9
10
|
---
|
|
10
|
-
|
|
11
11
|
# Channel manager
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
-
|
|
19
|
-
`
|
|
20
|
-
-
|
|
21
|
-
|
|
22
|
-
`
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
1. `kaleidoswap_lsp_get_info` — confirm the LSP is reachable + its limits.
|
|
40
|
-
2. `kaleidoswap_lsp_estimate_fees` — show the fee for the size you'd buy.
|
|
41
|
-
3. `kaleidoswap_lsp_create_order` (spend-gated) — create the order; it returns an
|
|
42
|
-
invoice/onchain address. Pay via `rln_pay_invoice` only after approval.
|
|
43
|
-
|
|
44
|
-
## Scheduled (background) runs
|
|
45
|
-
|
|
46
|
-
When run by the `heartbeat` loop, return STRICT JSON only:
|
|
47
|
-
|
|
48
|
-
```
|
|
49
|
-
{"task":"heartbeat","timestamp":"<ISO8601>","action":"ok|flush|buy_capacity|alert","dry_run":<bool>,"reason":"<why>","details":{"channels":<n>,"outbound_sat":<n>,"inbound_sat":<n>,"pending_transfers":<n>}}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Use `ok` when nothing needs doing, `alert` when a human should look.
|
|
53
|
-
|
|
54
|
-
## Don'ts
|
|
55
|
-
|
|
56
|
-
- Don't buy capacity that isn't needed, or when within the liquidity threshold.
|
|
57
|
-
- Don't pay an LSP invoice when `dry_run` is true.
|
|
58
|
-
- Don't invent channel ids, balances, or fees — read them from tools.
|
|
59
|
-
- Don't breach the BTC reserve to open a channel.
|
|
13
|
+
Read state first: `rln_get_node_info`, `rln_list_channels`, `rln_get_balances`.
|
|
14
|
+
Outbound = what the node can send; inbound = what it can receive. Report
|
|
15
|
+
numbers from this turn's results only.
|
|
16
|
+
|
|
17
|
+
## Do
|
|
18
|
+
- Health: count usable channels, total outbound vs inbound, channels with
|
|
19
|
+
`is_usable: false`; `rln_refresh_transfers {}` flushes pending RGB transfers.
|
|
20
|
+
- Can't receive → buy inbound: `kaleidoswap_lsp_get_info` (limits and
|
|
21
|
+
`lsp_connection_url`), `rln_connect_peer`, `kaleidoswap_lsp_estimate_fees`
|
|
22
|
+
(show `total_fee`), then `kaleidoswap_lsp_create_order` with `client_pubkey`
|
|
23
|
+
from `rln_get_node_info`, pay its invoice with `rln_pay_invoice`, poll
|
|
24
|
+
`kaleidoswap_lsp_get_order` until `COMPLETED`.
|
|
25
|
+
- Wants an asset (USDT/XAUT) but has no channel →
|
|
26
|
+
`kaleidoswap_lsp_quote_asset_channel` then
|
|
27
|
+
`kaleidoswap_lsp_create_asset_channel` with the fresh `rfq_id`.
|
|
28
|
+
- Can't send → open a channel with spare on-chain BTC (`rln_open_channel`).
|
|
29
|
+
- Every order, open, close and payment is confirm-gated; recommend first,
|
|
30
|
+
execute only on an explicit request. With `dry_run` true, describe only.
|
|
31
|
+
- Heartbeat runs: `action` is `ok`, `flush`, `buy_capacity` or `alert`.
|
|
32
|
+
|
|
33
|
+
## Examples
|
|
34
|
+
- "How healthy is my node?" → `rln_list_channels {}`
|
|
35
|
+
- "Fee for 500k sats inbound?" → `kaleidoswap_lsp_estimate_fees {"lsp_balance_sat":500000,"client_balance_sat":0,"channel_expiry_blocks":4320}`
|
|
36
|
+
- "Buy 500k inbound" → `rln_get_node_info {}` then `kaleidoswap_lsp_create_order {"client_pubkey":"<pubkey>","lsp_balance_sat":500000,"client_balance_sat":0,"channel_expiry_blocks":4320}`
|
|
37
|
+
- "A channel holding 100 USDT" → `kaleidoswap_lsp_quote_asset_channel {"asset":"USDT","asset_amount":100}`
|
|
38
|
+
- "Did order 7a1b open?" → `kaleidoswap_lsp_get_order {"order_id":"7a1b"}`
|
|
@@ -1,158 +1,32 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: flashnet-swaps
|
|
3
|
-
description: "Swap
|
|
4
|
-
tools: flashnet_list_pools, flashnet_get_pool, flashnet_simulate_swap, flashnet_execute_swap, flashnet_get_balance, spark_get_balance
|
|
5
|
-
|
|
3
|
+
description: "Swap BTC and Spark tokens (e.g. USDB) on Flashnet, the Spark-native AMM, from the in-app Spark wallet: list pools, simulate, execute."
|
|
4
|
+
tools: flashnet_list_pools, flashnet_get_pool, flashnet_simulate_swap, flashnet_execute_swap, flashnet_get_balance, spark_get_balance
|
|
5
|
+
requires-tools: flashnet_simulate_swap
|
|
6
|
+
triggers: flashnet, usdb, amm, pool, pools, spark swap, btc to usdb, usdb to btc
|
|
6
7
|
metadata:
|
|
7
8
|
author: kaleidoswap
|
|
8
|
-
version: "1.
|
|
9
|
+
version: "1.1.0"
|
|
9
10
|
venue: flashnet
|
|
10
11
|
---
|
|
11
|
-
|
|
12
12
|
# Flashnet swaps
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
If the user asks for an asset you can't see in `flashnet_list_pools`, tell
|
|
35
|
-
them so plainly and (if it's a known RGB asset like USDT/XAUT) point them
|
|
36
|
-
at the kaleido-trading skill rather than inventing a Flashnet pool.
|
|
37
|
-
|
|
38
|
-
## Critical rules (read first)
|
|
39
|
-
|
|
40
|
-
1. **Never invent a pool id, asset address, or amount.** Every `pool_id`,
|
|
41
|
-
`asset_in_address`, `asset_out_address`, `amount_in` you pass MUST come
|
|
42
|
-
from `flashnet_list_pools` / `flashnet_simulate_swap` / a tool-returned
|
|
43
|
-
value in the CURRENT turn — never from history, never guessed.
|
|
44
|
-
**ALWAYS start a swap by calling `flashnet_list_pools`** to get the real
|
|
45
|
-
pool id + asset addresses. You may pass `BTC` as a literal asset (the
|
|
46
|
-
host resolves it), but for any TOKEN you must use the exact
|
|
47
|
-
`asset_a_address` / `asset_b_address` the pool returned. Token tickers
|
|
48
|
-
(e.g. `USDB`) only resolve if the network publishes them or the host is
|
|
49
|
-
configured; if a ticker doesn't resolve, the result rows carry the
|
|
50
|
-
addresses — use those. Each pool row includes `asset_a_symbol` /
|
|
51
|
-
`asset_b_symbol` when known (e.g. `"BTC"`); pick the pool whose pair
|
|
52
|
-
matches the user's intent and read its addresses from that row.
|
|
53
|
-
2. **Always simulate before executing.** Call `flashnet_simulate_swap` to
|
|
54
|
-
get `amount_out` + `price_impact_pct`, show the user the rate in plain
|
|
55
|
-
English, get explicit confirmation, then call `flashnet_execute_swap`.
|
|
56
|
-
The host fires one extra confirmation gate on execute — that's the
|
|
57
|
-
safety net, not the primary one.
|
|
58
|
-
3. **Compute `min_amount_out` yourself.** Never pass the simulated
|
|
59
|
-
`amount_out` directly to execute. The standard formula is
|
|
60
|
-
`min_amount_out = floor(amount_out × (1 − max_slippage_bps / 10000))`.
|
|
61
|
-
Default `max_slippage_bps: 50` (0.5%). Use 100 for volatile pairs or
|
|
62
|
-
high price impact (>0.5%); ask the user before going higher than 1%.
|
|
63
|
-
4. **Smallest units, as strings.** `amount_in` / `min_amount_out` are in
|
|
64
|
-
the asset's smallest unit (sats for BTC; the token's smallest decimal
|
|
65
|
-
place for tokens). Pass them as JSON strings so BigInt-sized values
|
|
66
|
-
survive round-trip. e.g. `amount_in: "100000"` for 100k sats, NOT
|
|
67
|
-
`amount_in: 100000`.
|
|
68
|
-
5. **High price impact = stop and ask.** If
|
|
69
|
-
`simulate_swap.price_impact_pct > 1.0`, surface it explicitly:
|
|
70
|
-
"This trade would move the price by 1.7%. Continue?" Don't auto-execute
|
|
71
|
-
anything with >2% impact without a clear user yes.
|
|
72
|
-
6. **Get the direction right — `asset_in` is what the user SPENDS,
|
|
73
|
-
`asset_out` is what they GET.** Parse the request literally:
|
|
74
|
-
- "spend 2000 sats to get USDB" → asset_in = BTC, asset_out = USDB,
|
|
75
|
-
amount_in = 2000 (the sats spent).
|
|
76
|
-
- "swap 10 USDB to BTC" / "sell 10 USDB for sats" → asset_in = USDB,
|
|
77
|
-
asset_out = BTC, amount_in = the USDB amount.
|
|
78
|
-
- "buy USDB with 2000 sats" → asset_in = BTC, asset_out = USDB.
|
|
79
|
-
`amount_in` is ALWAYS denominated in `asset_in`. Double-check before
|
|
80
|
-
simulating: if the user said "spend N sats", asset_in MUST be BTC and
|
|
81
|
-
amount_in MUST be N.
|
|
82
|
-
|
|
83
|
-
## Happy-path playbook
|
|
84
|
-
|
|
85
|
-
For a typical "swap 100k sats to USDB":
|
|
86
|
-
|
|
87
|
-
1. **`flashnet_list_pools({ asset_a: <BTC>, asset_b: <USDB> })`** — find a
|
|
88
|
-
pool. Pick the first result (already sorted by TVL desc). Save its
|
|
89
|
-
`pool_id`, `asset_a_address`, `asset_b_address`.
|
|
90
|
-
|
|
91
|
-
- If the user named a specific asset by *symbol* (e.g. "USDB"), the host
|
|
92
|
-
fills in the token address based on the active Spark network. The
|
|
93
|
-
model just passes the symbol or whatever address the prior tool
|
|
94
|
-
returned.
|
|
95
|
-
|
|
96
|
-
2. **`flashnet_simulate_swap({ pool_id, asset_in_address, asset_out_address, amount_in })`**
|
|
97
|
-
— get `amount_out`, `execution_price`, `price_impact_pct`,
|
|
98
|
-
`fee_paid_asset_in`. Show the user one short line:
|
|
99
|
-
|
|
100
|
-
`Swap 100,000 sats → ~497,500 USDB (0.5% pool fee, 0.18% price impact).
|
|
101
|
-
Proceed?`
|
|
102
|
-
|
|
103
|
-
3. **Compute `min_amount_out`** from the simulated `amount_out` and the
|
|
104
|
-
chosen slippage tolerance (default 0.5% / 50 bps). Don't trust the
|
|
105
|
-
simulated value as-is.
|
|
106
|
-
|
|
107
|
-
4. **`flashnet_execute_swap({ pool_id, asset_in_address, asset_out_address,
|
|
108
|
-
amount_in, min_amount_out, max_slippage_bps })`** — SPEND, gated. On
|
|
109
|
-
success returns the swap `request_id` and the actual `amount_out`.
|
|
110
|
-
Surface the realised amount on a single line.
|
|
111
|
-
|
|
112
|
-
## When to use which tool
|
|
113
|
-
|
|
114
|
-
| Tool | Use when |
|
|
115
|
-
|---|---|
|
|
116
|
-
| `flashnet_list_pools` | First step of any swap; or when the user asks "what pools exist for X/Y". |
|
|
117
|
-
| `flashnet_get_pool` | User wants pool depth / current price / TVL before swapping. |
|
|
118
|
-
| `flashnet_simulate_swap` | EVERY swap, before execute. Also for "what would I get if I swapped 5k sats?" — read-only quote. |
|
|
119
|
-
| `flashnet_execute_swap` | After user confirms the simulated quote. Confirmation-gated. |
|
|
120
|
-
| `flashnet_get_balance` | Pre-swap balance check, or "what do I have on Spark/Flashnet". (Reads from the same wallet `spark_get_balance` reads — they are not separate accounts.) |
|
|
121
|
-
|
|
122
|
-
## Cross-skill flow with spark-wallet
|
|
123
|
-
|
|
124
|
-
The Spark wallet and Flashnet share the same on-device account. Common
|
|
125
|
-
chains:
|
|
126
|
-
|
|
127
|
-
- **Pre-swap balance check.** `spark_get_balance` (or
|
|
128
|
-
`flashnet_get_balance`) → confirm the user has enough sats → quote →
|
|
129
|
-
execute.
|
|
130
|
-
- **Deposit then swap.** User has on-chain BTC → `spark_get_address` to
|
|
131
|
-
receive into Spark → wait for confirmation (the user does that
|
|
132
|
-
externally) → swap.
|
|
133
|
-
- **Swap then pay invoice.** User has USDB but needs to pay a BOLT11
|
|
134
|
-
invoice → swap USDB → BTC (this skill) → `spark_pay_invoice` (the
|
|
135
|
-
spark-wallet skill) → done.
|
|
136
|
-
|
|
137
|
-
## Failure handling
|
|
138
|
-
|
|
139
|
-
Tool errors arrive as `Error.message`. Common ones:
|
|
140
|
-
|
|
141
|
-
- **`Insufficient balance`** — the wallet doesn't hold enough
|
|
142
|
-
`asset_in`. Surface the deficit. Suggest depositing or swapping less.
|
|
143
|
-
- **`Slippage exceeded` / `min_amount_out not met`** — the pool moved
|
|
144
|
-
between simulate and execute. Re-simulate and try again (the host can
|
|
145
|
-
do this; don't loop more than 2× automatically — ask the user after
|
|
146
|
-
that).
|
|
147
|
-
- **`Pool not found` / `Asset not allowed`** — pool id stale or wrong
|
|
148
|
-
network. Re-list pools.
|
|
149
|
-
- **Authentication / connection errors** — the Spark wallet isn't
|
|
150
|
-
initialized. Say so plainly; don't fake a result.
|
|
151
|
-
|
|
152
|
-
## Reply style
|
|
153
|
-
|
|
154
|
-
- Quote line: amount in, amount out, fee, price impact — all on one line.
|
|
155
|
-
- After execute: one-line result with realised amount and tx id.
|
|
156
|
-
- Never paste a multi-line JSON of the simulate/execute response.
|
|
157
|
-
- Don't echo `amount_in` / `min_amount_out` raw numbers in subsequent
|
|
158
|
-
turns; the model isn't a ledger.
|
|
14
|
+
The Spark wallet is the swap account. Flashnet trades BTC against Spark tokens
|
|
15
|
+
only; RGB assets (USDT, XAUT) trade on KaleidoSwap (`kaleido-trading`).
|
|
16
|
+
|
|
17
|
+
## Do
|
|
18
|
+
- Start with `flashnet_list_pools`; take `pool_id` and the asset addresses
|
|
19
|
+
from its result. Never invent a pool or address.
|
|
20
|
+
- `amount_in` and `min_amount_out` are strings in the smallest unit
|
|
21
|
+
(sats for BTC). `asset_in` is what the user spends.
|
|
22
|
+
- Always `flashnet_simulate_swap` first; show `amount_out` and
|
|
23
|
+
`price_impact_pct`; ask before going on if impact is above 1%.
|
|
24
|
+
- `min_amount_out = floor(amount_out × (1 − max_slippage_bps / 10000))`,
|
|
25
|
+
default `max_slippage_bps` 50. Then `flashnet_execute_swap`
|
|
26
|
+
(confirm-gated).
|
|
27
|
+
- "Slippage exceeded": re-simulate once, then ask the user.
|
|
28
|
+
|
|
29
|
+
## Examples
|
|
30
|
+
- "Pools for BTC/USDB" → `flashnet_list_pools {"asset_a":"BTC","asset_b":"USDB"}`
|
|
31
|
+
- "What would 100k sats get me in USDB?" → `flashnet_simulate_swap {"pool_id":"<pool_id>","asset_in_address":"<BTC address>","asset_out_address":"<USDB address>","amount_in":"100000"}`
|
|
32
|
+
- "Do it" → `flashnet_execute_swap {"pool_id":"<pool_id>","asset_in_address":"<BTC address>","asset_out_address":"<USDB address>","amount_in":"100000","min_amount_out":"<computed>","max_slippage_bps":50}`
|
|
@@ -1,63 +1,33 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: kaleido-node
|
|
3
|
-
description: "Run the RGB Lightning Node
|
|
3
|
+
description: "Run the RGB Lightning Node process: list environments, start, stop or tear down the Docker stack, check reachability, initialise the wallet once and unlock it after every restart. Use when node calls fail with 'unreachable' or 'wallet locked'."
|
|
4
4
|
tools: kaleido_node_list, kaleido_node_up, kaleido_node_ps, kaleido_node_status, kaleido_node_info, kaleido_node_use, kaleido_node_init, kaleido_node_unlock, kaleido_node_lock, kaleido_node_stop, kaleido_node_down, rln_get_node_info, rln_create_utxos
|
|
5
|
-
|
|
5
|
+
requires-tools: kaleido_node_status
|
|
6
|
+
triggers: start node, stop node, node up, node down, unlock, unlock node, lock node, wallet locked, init node, initialise node, initialize node, docker, environment, node status, node unreachable
|
|
6
7
|
metadata:
|
|
7
8
|
author: kaleidoswap
|
|
8
|
-
version: "0.
|
|
9
|
+
version: "0.2.0"
|
|
9
10
|
---
|
|
10
|
-
|
|
11
11
|
# Kaleido node lifecycle
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
channels use
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
| Stop (keep data) | `kaleido_node_stop({ name? })` | `kaleido --agent node stop <NAME>` |
|
|
35
|
-
| Tear down (keep volumes) | `kaleido_node_down({ name? })` | `kaleido --agent node down <NAME>` |
|
|
36
|
-
|
|
37
|
-
`name` can be omitted when only one environment exists.
|
|
38
|
-
|
|
39
|
-
## Flows
|
|
40
|
-
|
|
41
|
-
- **First run:** `kaleido_node_up` → `kaleido_node_init` → `kaleido_node_unlock`
|
|
42
|
-
→ create colored UTXOs (`rln_create_utxos`, or
|
|
43
|
-
`kaleido --agent wallet create-utxos`). Until UTXOs exist, issuing or
|
|
44
|
-
receiving RGB assets fails.
|
|
45
|
-
- **After a restart:** `kaleido_node_up` (if containers are down) →
|
|
46
|
-
`kaleido_node_unlock`. Unlock is needed after every restart.
|
|
47
|
-
- **Node unreachable** (`rln_get_node_info` fails): `kaleido_node_status`, then
|
|
48
|
-
`kaleido_node_up` and `kaleido_node_unlock`.
|
|
49
|
-
- **"wallet locked" errors:** `kaleido_node_unlock`.
|
|
50
|
-
- **Stuck pending RGB transfers:** `kaleido --json asset fail-transfers` marks
|
|
51
|
-
them failed (CLI only).
|
|
52
|
-
|
|
53
|
-
## Safety
|
|
54
|
-
|
|
55
|
-
1. **Passwords:** ask the user for the password at the moment it is needed.
|
|
56
|
-
Never store, repeat or log it.
|
|
57
|
-
2. **Mnemonic:** `kaleido_node_init` shows the seed phrase once. Tell the user
|
|
58
|
-
to write it down offline before continuing. It cannot be recovered.
|
|
59
|
-
Never paste it back into the chat.
|
|
60
|
-
3. **State changes need a yes:** `up`, `stop`, `down`, `init`, `unlock` and
|
|
61
|
-
`lock` change the node; confirm first. `down` removes containers (volumes
|
|
62
|
-
stay); say so.
|
|
63
|
-
4. **Dry run:** describe the steps only; call no state-changing tool.
|
|
13
|
+
These tools wrap the `kaleido` CLI on the machine running kaleido-mcp. For
|
|
14
|
+
balances, invoices and channels use `rgb-lightning-node`. `name` can be
|
|
15
|
+
omitted when only one environment exists.
|
|
16
|
+
|
|
17
|
+
## Do
|
|
18
|
+
- First run: `kaleido_node_up` → `kaleido_node_init` → `kaleido_node_unlock` →
|
|
19
|
+
`rln_create_utxos {}` (needed before issuing or receiving RGB assets).
|
|
20
|
+
- After a restart: `kaleido_node_up` if containers are down, then
|
|
21
|
+
`kaleido_node_unlock`.
|
|
22
|
+
- Unreachable: `kaleido_node_status`, then up and unlock.
|
|
23
|
+
- Ask for the password when it is needed; never store or repeat it.
|
|
24
|
+
- `kaleido_node_init` shows the mnemonic once: tell the user to write it down
|
|
25
|
+
offline and never echo it back.
|
|
26
|
+
- `up`, `stop`, `down`, `init`, `unlock`, `lock` change the node: confirm
|
|
27
|
+
first. `down` removes containers; volumes stay.
|
|
28
|
+
|
|
29
|
+
## Examples
|
|
30
|
+
- "Is my node running?" → `kaleido_node_status {}`
|
|
31
|
+
- "Start my node" → `kaleido_node_up {}`
|
|
32
|
+
- "Unlock the node" → `kaleido_node_unlock {"password":"<password from the user>"}`
|
|
33
|
+
- "Use the signet environment" → `kaleido_node_use {"name":"signet"}`
|