@kaleidorg/mind 0.8.1 → 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.
Files changed (133) hide show
  1. package/README.md +7 -5
  2. package/dist/bitrefill/index.d.ts +4 -0
  3. package/dist/bitrefill/index.d.ts.map +1 -0
  4. package/dist/bitrefill/index.js +3 -0
  5. package/dist/bitrefill/index.js.map +1 -0
  6. package/dist/capabilities.d.ts +3 -3
  7. package/dist/capabilities.d.ts.map +1 -1
  8. package/dist/capabilities.js +4 -4
  9. package/dist/capabilities.js.map +1 -1
  10. package/dist/engine/answer.d.ts +37 -0
  11. package/dist/engine/answer.d.ts.map +1 -0
  12. package/dist/engine/answer.js +35 -0
  13. package/dist/engine/answer.js.map +1 -0
  14. package/dist/engine.d.ts +9 -3
  15. package/dist/engine.d.ts.map +1 -1
  16. package/dist/engine.js +159 -175
  17. package/dist/engine.js.map +1 -1
  18. package/dist/evidence.d.ts +1 -1
  19. package/dist/evidence.d.ts.map +1 -1
  20. package/dist/flashnet/index.d.ts +5 -0
  21. package/dist/flashnet/index.d.ts.map +1 -0
  22. package/dist/flashnet/index.js +4 -0
  23. package/dist/flashnet/index.js.map +1 -0
  24. package/dist/guards.d.ts.map +1 -1
  25. package/dist/guards.js +20 -0
  26. package/dist/guards.js.map +1 -1
  27. package/dist/index.d.ts +7 -24
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +11 -28
  30. package/dist/index.js.map +1 -1
  31. package/dist/kaleidoswap/contract.d.ts +7 -0
  32. package/dist/kaleidoswap/contract.d.ts.map +1 -1
  33. package/dist/kaleidoswap/contract.js +71 -17
  34. package/dist/kaleidoswap/contract.js.map +1 -1
  35. package/dist/kaleidoswap/index.d.ts +8 -0
  36. package/dist/kaleidoswap/index.d.ts.map +1 -0
  37. package/dist/kaleidoswap/index.js +7 -0
  38. package/dist/kaleidoswap/index.js.map +1 -0
  39. package/dist/knowledge/index.d.ts +9 -0
  40. package/dist/knowledge/index.d.ts.map +1 -0
  41. package/dist/knowledge/index.js +6 -0
  42. package/dist/knowledge/index.js.map +1 -0
  43. package/dist/lsps1/index.d.ts +4 -0
  44. package/dist/lsps1/index.d.ts.map +1 -0
  45. package/dist/lsps1/index.js +3 -0
  46. package/dist/lsps1/index.js.map +1 -0
  47. package/dist/providers/types.d.ts +3 -3
  48. package/dist/providers/types.js +3 -3
  49. package/dist/qvac/index.d.ts +0 -1
  50. package/dist/qvac/index.d.ts.map +1 -1
  51. package/dist/qvac/index.js +0 -1
  52. package/dist/qvac/index.js.map +1 -1
  53. package/dist/qvac/provider.d.ts +9 -9
  54. package/dist/qvac/provider.d.ts.map +1 -1
  55. package/dist/qvac/provider.js +115 -109
  56. package/dist/qvac/provider.js.map +1 -1
  57. package/dist/qvac/stream.d.ts +4 -3
  58. package/dist/qvac/stream.d.ts.map +1 -1
  59. package/dist/qvac/stream.js.map +1 -1
  60. package/dist/qvac/voice.d.ts +1 -1
  61. package/dist/recipe/asset-send.js +1 -1
  62. package/dist/recipe/asset-send.js.map +1 -1
  63. package/dist/submarine/index.d.ts +5 -0
  64. package/dist/submarine/index.d.ts.map +1 -0
  65. package/dist/submarine/index.js +4 -0
  66. package/dist/submarine/index.js.map +1 -0
  67. package/dist/testing/mock-wallet.d.ts.map +1 -1
  68. package/dist/testing/mock-wallet.js +6 -0
  69. package/dist/testing/mock-wallet.js.map +1 -1
  70. package/dist/tools/in-process.d.ts +2 -2
  71. package/dist/tools/in-process.js +2 -2
  72. package/dist/wallet/contract.d.ts +5 -0
  73. package/dist/wallet/contract.d.ts.map +1 -1
  74. package/dist/wallet/contract.js +39 -6
  75. package/dist/wallet/contract.js.map +1 -1
  76. package/package.json +32 -2
  77. package/scripts/snapshot-mcp-tools.mjs +38 -0
  78. package/skills/README.md +98 -64
  79. package/skills/bitrefill/SKILL.md +30 -157
  80. package/skills/channel-manager/SKILL.md +31 -52
  81. package/skills/flashnet-swaps/SKILL.md +24 -150
  82. package/skills/kaleido-node/SKILL.md +25 -55
  83. package/skills/kaleido-trading/SKILL.md +28 -172
  84. package/skills/kaleido-trading/references/assets.md +4 -4
  85. package/skills/kaleido-trading/references/atomic.md +5 -7
  86. package/skills/merchant-finder/SKILL.md +25 -108
  87. package/skills/paid-data/SKILL.md +25 -58
  88. package/skills/portfolio-manager/SKILL.md +26 -60
  89. package/skills/rgb-lightning-node/SKILL.md +37 -255
  90. package/skills/rgb-lightning-node/references/channels.md +34 -0
  91. package/skills/spark-wallet/SKILL.md +26 -228
  92. package/skills/submarine-swaps/SKILL.md +19 -37
  93. package/skills/wallet-assistant/SKILL.md +26 -44
  94. package/src/bitrefill/index.ts +13 -0
  95. package/src/capabilities.ts +7 -7
  96. package/src/context/context.test.ts +2 -2
  97. package/src/engine/answer.ts +66 -0
  98. package/src/engine.ts +185 -194
  99. package/src/evidence.ts +1 -1
  100. package/src/flashnet/index.ts +14 -0
  101. package/src/funnel.mind.test.ts +6 -5
  102. package/src/guards.test.ts +12 -0
  103. package/src/guards.ts +20 -0
  104. package/src/index.ts +11 -107
  105. package/src/kaleidoswap/contract.test.ts +32 -3
  106. package/src/kaleidoswap/contract.ts +65 -17
  107. package/src/kaleidoswap/index.ts +20 -0
  108. package/src/knowledge/index.ts +14 -0
  109. package/src/lsps1/index.ts +13 -0
  110. package/src/providers/types.ts +3 -3
  111. package/src/qvac/index.ts +0 -8
  112. package/src/qvac/provider.test.ts +17 -17
  113. package/src/qvac/provider.ts +33 -31
  114. package/src/qvac/stream.ts +4 -3
  115. package/src/qvac/voice.ts +1 -1
  116. package/src/recipe/asset-send.ts +1 -1
  117. package/src/recipe/recipe.test.ts +1 -1
  118. package/src/skills/catalog.test.ts +215 -0
  119. package/src/skills/mcp-tools.snapshot.json +1938 -0
  120. package/src/submarine/index.ts +17 -0
  121. package/src/testing/mock-wallet.ts +6 -0
  122. package/src/tools/in-process.ts +2 -2
  123. package/src/wallet/contract.test.ts +20 -1
  124. package/src/wallet/contract.ts +36 -6
  125. package/dist/qvac/delegate.d.ts +0 -50
  126. package/dist/qvac/delegate.d.ts.map +0 -1
  127. package/dist/qvac/delegate.js +0 -53
  128. package/dist/qvac/delegate.js.map +0 -1
  129. package/skills/dca/SKILL.md +0 -48
  130. package/skills/kaleido-lsps/SKILL.md +0 -131
  131. package/skills/liquidity-optimizer/SKILL.md +0 -91
  132. package/src/qvac/delegate.test.ts +0 -68
  133. package/src/qvac/delegate.ts +0 -73
@@ -1,260 +1,42 @@
1
1
  ---
2
2
  name: rgb-lightning-node
3
- description: "Drive the user's local RGB Lightning Node (RLN) — read its pubkey/status, list channels and their capacities, check RGB asset balances, manage channels/peers, whitelist a swap, or create Lightning/RGB receive invoices. Triggers when the user asks about the node, their channels or capacities, needs an invoice, wants to issue/mint a new RGB token or NFT, or is mid-atomic-swap and the maker needs the node pubkey or a swapstring whitelisted."
4
- tools: rln_get_node_info, rln_get_balances, rln_list_channels, rln_list_assets, rln_get_asset_balance, rln_refresh_transfers, rln_get_address, rln_send_btc, rln_send_asset, rln_pay_invoice, rln_open_channel, rln_close_channel, rln_connect_peer, rln_get_channel_id, rln_atomic_taker, rln_list_swaps, rln_get_swap, rln_list_payments, rln_create_ln_invoice, rln_create_rgb_invoice, rln_list_transfers, rln_create_utxos, rln_issue_asset
5
- triggers: node, nodeinfo, pubkey, peer, channels, channel capacity, list channels, open channel, close channel, inbound, capacity, asset balance, whitelist, taker, swapstring, swaps, payments, invoice, receive, send asset, send rgb, on-chain address, deposit, rgb invoice, ln invoice, issue, mint, new token, nft, utxos, transfers
3
+ description: "Operate the user's RGB Lightning Node: RGB asset balances, issue a new RGB token or NFT, RGB and Lightning invoices, send assets or BTC, pay invoices, channels and node status."
4
+ tools: rln_get_node_info, rln_get_balances, rln_list_assets, rln_get_asset_balance, rln_refresh_transfers, rln_list_transfers, rln_create_utxos, rln_issue_asset, rln_create_rgb_invoice, rln_send_asset, rln_create_ln_invoice, rln_pay_invoice, rln_get_address, rln_send_btc, rln_list_channels, rln_list_payments
5
+ requires-tools: rln_get_node_info
6
+ triggers: node, pubkey, balance, balances, rgb, asset, assets, token, nft, issue, mint, utxos, transfers, invoice, receive, send asset, pay invoice, on-chain address, channels, payments
6
7
  metadata:
7
8
  author: kaleidoswap
8
- version: "0.3.3"
9
+ version: "0.4.0"
9
10
  ---
10
-
11
- # RGB Lightning Node (taker-side)
12
-
13
- You drive the **user's own** RGB Lightning Node running locally. In a KaleidoSwap
14
- atomic swap the **maker** owns init / execute / status (those are
15
- `kaleidoswap_atomic_*` tools, separate REST endpoints). The node's job in a
16
- swap is narrow: **expose its pubkey and whitelist the maker's swapstring**.
17
- The node does NOT init or execute swaps.
18
-
19
- ## Critical rules
20
-
21
- You have **no knowledge** of the node's pubkey, channel state, balance, or any
22
- invoice contents. Every value in your reply MUST come from a tool result
23
- returned in the CURRENT turn — never invent a pubkey, channel id, invoice
24
- string, or sats balance. Never reuse a value from a previous turn.
25
-
26
- **Calling the tool IS the answer.** If the user asks "what's my pubkey?", call
27
- `rln_get_node_info` — do not describe how to fetch it.
28
-
29
- ## When to use each tool
30
-
31
- ### `rln_get_node_info` — no args
32
- Returns:
33
- - `pubkey` — the node's identity (32-byte hex).
34
- - `num_channels` — total channels (may include unusable ones).
35
- - `num_usable_channels` — subset that can route a payment right now.
36
- - `local_balance_sat` — **sats YOU own** across all channels. This is your
37
- **spend** capacity (outbound). It is **NOT** receive capacity, **NOT**
38
- inbound liquidity, and **NOT** total channel capacity.
39
- - `pending_outbound_payments_sat` — in-flight, temporarily locked.
40
- - `num_peers` — currently connected peers.
41
-
42
- Call this when:
43
- - The user asks about the node, pubkey, peers, channel count, or how much
44
- they can **spend**.
45
- - An atomic swap is in progress and the maker needs `taker_pubkey` —
46
- fetch the pubkey from this tool's `pubkey` field and pass it to
47
- `kaleidoswap_atomic_execute`.
48
-
49
- **Do NOT** use this tool's `local_balance_sat` to answer a question about
50
- **inbound liquidity / receive capacity** — that is a different quantity (the
51
- peer's side of each channel). For per-channel inbound/outbound and total
52
- capacity, use `rln_list_channels` (below), NOT this tool.
53
-
54
- ### `rln_list_channels` — no args
55
- Returns `{ channels: [...], count }`. Each channel carries:
56
- - `channel_id`, `peer_alias`, `status`, `ready`, `is_usable`
57
- - `capacity_sat` — total channel size.
58
- - `outbound_sat` — what YOU can send (your local balance).
59
- - `inbound_sat` — what you can RECEIVE on this channel (the peer's side).
60
- - `asset_id`, `asset_local_amount`, `asset_remote_amount` — for RGB asset
61
- channels: the asset and how much is on each side.
62
-
63
- Call this when the user asks to **list channels**, asks about **per-channel
64
- capacity**, **inbound/receive capacity**, or wants to **verify a channel they
65
- just bought** opened with the requested size. Report each channel as one line:
66
- `capacity_sat total — outbound_sat / inbound_sat (asset if present), status`.
67
-
68
- When verifying a freshly-bought channel: a channel order opens
69
- ASYNCHRONOUSLY (seconds to minutes after payment). If the new channel isn't
70
- listed yet, say it's still opening and suggest checking again — don't claim
71
- failure.
72
-
73
- ### `rln_list_assets` — { schemas? }
74
- Lists RGB assets known to the node: `asset_id`, `ticker`, `name`, `precision`
75
- (in-app wallets also return balances). `schemas` is an optional filter — an
76
- array of `"Nia"`, `"Uda"`, `"Cfa"`; call it with `{}` to list everything.
77
- Use for "what assets do I hold / what's my USDT balance".
78
-
79
- Call it **once** per question. An empty list is a real answer: the node holds
80
- no RGB assets yet — tell the user that (and offer to issue one) instead of
81
- calling it again.
82
-
83
- ### Tickers are not asset ids
84
- `asset_id` arguments take the full RGB id (`rgb:…`), never a ticker like
85
- `USDT` or `HCK`. When the user names an asset by ticker or name, first call
86
- `rln_list_assets`, find the entry whose `ticker`/`name` matches, and pass its
87
- `asset_id`. If nothing matches, say the node has no such asset — do not guess
88
- an id.
89
-
90
- ### `rln_get_asset_balance` — { asset_id }
91
- Balance for one RGB asset by id. Resolve a ticker to its `asset_id` with
92
- `rln_list_assets` first.
93
-
94
- | Field | Meaning |
95
- |---|---|
96
- | `settled` / `spendable` | On-chain (RGB_L1), UTXO-bound |
97
- | `future` | Pending settlement |
98
- | `offchain_outbound` | In a Lightning channel: what you can **send** |
99
- | `offchain_inbound` | Channel receive capacity for this asset |
100
-
101
- For USDT/XAUT held in an RGB channel, report `offchain_outbound`; `spendable`
102
- is 0 and that is normal.
103
-
104
- ### `rln_refresh_transfers` — no args
105
- Syncs pending RGB transfers. Call it before re-reading a balance or transfer
106
- status that looks stale (e.g. right after an invoice was paid or a swap filled).
107
-
108
- ### `rln_get_address` — no args
109
- An on-chain BTC address of the node, for funding it. Not an RGB invoice and not
110
- a Lightning invoice.
111
-
112
- ### `rln_send_btc` — { address, amount_sat, fee_rate? } — 🔒 confirm-gated
113
- Sends on-chain BTC from the node. Only when the user gave both the address and
114
- the amount.
115
-
116
- ### `rln_send_asset` — 🔒 confirm-gated
117
- Sends an RGB asset to the recipient encoded in an RGB invoice. Use the argument
118
- names of the schema you were given: in-app wallets take `{ asset, amount, to }`
119
- (ticker or asset_id, units, the invoice); kaleido-mcp takes
120
- `{ asset_id, amount, recipient_id }`, where `asset_id` is the `rgb:…` id from
121
- `rln_list_assets`. Never invent a recipient.
122
-
123
- ### `rln_pay_invoice` — { invoice } — 🔒 confirm-gated
124
- Pays a BOLT11 Lightning invoice from the node. Pass the full invoice string.
125
-
126
- ### Channels and peers
127
- - `rln_connect_peer { peer_pubkey_and_addr }` — `pubkey@host:port`. Needed
128
- before opening a channel to a peer the node has never seen.
129
- - `rln_open_channel { peer_pubkey_and_addr, capacity_sat, asset_id?, asset_amount?, push_msat?, is_public? }`
130
- — 🔒 confirm-gated. Locks on-chain BTC (and optionally an RGB asset) into a
131
- channel. Opening is asynchronous: report the `temporary_channel_id` and
132
- suggest checking `rln_list_channels`.
133
- - `rln_get_channel_id { temporary_channel_id }` — the final `channel_id` once
134
- the channel is established.
135
- - `rln_close_channel { channel_id, peer_pubkey, force? }` — 🔒 confirm-gated.
136
- Both values come from `rln_list_channels`. `force` only for an unresponsive
137
- peer.
138
-
139
- ### `rln_list_payments` — { limit? }
140
- Recent Lightning payments, sent and received. Use for "did I get paid" /
141
- "what did I pay" over Lightning.
142
-
143
- ### `rln_list_swaps` / `rln_get_swap { payment_hash, taker? }`
144
- Atomic swaps as the node sees them (HTLC status). For the maker-side status use
145
- `kaleidoswap_atomic_status`.
146
-
147
- ### `rln_atomic_taker` — { swapstring } — 🔒 confirm-gated
148
- Tell the node "I accept this swap." Args: the `swapstring` returned by
149
- `kaleidoswap_atomic_init`. The node validates and stores it; **no funds move
150
- here**, but the user is committing to the swap so the engine pauses for
151
- confirmation.
152
-
153
- Call this **after** `kaleidoswap_atomic_init` and **before**
154
- `kaleidoswap_atomic_execute`. Never call with an empty or invented swapstring
155
- — the node will reject it.
156
-
157
- ### `rln_create_ln_invoice` — Lightning invoice for receiving sats
158
- Args:
159
- - `amount_sats` (optional) — omit for an amountless invoice.
160
- - `description` (optional, kaleido-mcp) — memo shown to the payer.
161
- - `expiry_sec` (default 3600, kaleido-mcp only) — invoice TTL in seconds.
162
-
163
- Reply with the full `invoice` string from the result — never write an invoice
164
- yourself.
165
-
166
- Use when the user wants to **receive** a Lightning payment. Do NOT call inside
167
- an atomic swap flow unless the user explicitly asked to invoice someone.
168
-
169
- ### `rln_create_rgb_invoice` — on-chain RGB receive invoice
170
- Args (use the names in your schema):
171
- - in-app wallets: `asset` (ticker or asset_id) + `amount`.
172
- - kaleido-mcp: `asset_id` (the `rgb:…` id from `rln_list_assets` — never a
173
- ticker; omit for an any-asset invoice), `amount` (display units),
174
- `duration_seconds` (default 86400).
175
-
176
- Reply with the full `invoice` string; the payer needs all of it.
177
-
178
- Use when the user wants to **receive** an RGB asset directly (not over
179
- Lightning). Outside the atomic swap flow.
180
-
181
- ### `rln_list_transfers` — { asset_id }
182
- Transfers for one asset (issuance, sends, receives) with `status`
183
- (`WaitingCounterparty`, `WaitingConfirmations`, `Settled`, `Failed`). Use it to
184
- answer "has my RGB invoice been paid?". Pass the `asset_id` (`rgb:…`) from
185
- `rln_list_assets` or `rln_issue_asset`; in-app wallets also accept a ticker.
186
-
187
- ### `rln_create_utxos` — { num?, size?, up_to?, fee_rate? } — 🔒 confirm-gated
188
- Creates colorable UTXOs (spends a little on-chain BTC). A fresh node needs
189
- these before it can **issue** or **receive** RGB assets. Call it when an RGB
190
- call fails with "no available UTXOs", then retry the original action. The
191
- defaults (`num` 5, `fee_rate` 1) are fine; set `up_to: true` to only top up to
192
- `num` free UTXOs.
193
-
194
- ### `rln_issue_asset` — { name, ticker?, amount?, precision?, schema?, details? } — 🔒 confirm-gated
195
- Creates a **new** RGB asset owned by this node. `schema`: `NIA` fungible token
196
- (default), `CFA` collectible, `UDA` unique asset / NFT (supply 1).
197
- - `ticker` (uppercase, 1–8 letters/digits, nothing else) is required for `NIA`
198
- and `UDA`.
199
- - `amount` is the total supply in display units (a number), required for `NIA`
200
- and `CFA` — if the user did not say how many, ask before calling;
201
- the raw supply is `amount × 10^precision` (`precision` defaults to 0).
202
- - `details` is an optional description for `CFA` and `UDA`.
203
-
204
- Reply with the returned `asset_id` — the user needs it to invoice or send the
205
- new asset.
206
-
207
- Examples:
208
- - "issue 1000 TICKET tokens called Hackathon Ticket" →
209
- `rln_issue_asset { name: "Hackathon Ticket", ticker: "TICKET", amount: 1000 }`
210
- - "mint an NFT called Genesis Badge" →
211
- `rln_issue_asset { name: "Genesis Badge", ticker: "GENESISB", schema: "UDA" }`
212
- - "has anyone paid my TICKET invoice?" → `rln_refresh_transfers` →
213
- `rln_list_transfers { asset_id: "<TICKET asset_id from rln_list_assets>" }`
214
-
215
- kaleido-mcp exposes these three as `wdk_issue_asset`, `wdk_create_utxos` and
216
- `wdk_list_transfers`, with the same arguments and `rln_*` aliases.
217
-
218
- ### Recipe: issue your own RGB asset
219
- 1. `rln_get_node_info` — the node is reachable and unlocked.
220
- 2. `rln_create_utxos {}` — skip if the node already has free colored UTXOs;
221
- wait for the funding tx to confirm before issuing.
222
- 3. `rln_issue_asset { name, ticker, amount }` — confirm with the user first.
223
- 4. `rln_create_rgb_invoice` on the receiver's node, then `rln_send_asset` with
224
- the new `asset_id` to distribute it.
225
- 5. `rln_refresh_transfers` → `rln_list_transfers { asset_id }` until the
226
- transfer is `Settled`.
227
-
228
- ## The maker / node split
229
-
230
- A user-driven swap on KaleidoSwap is a two-service flow. Keep them straight:
231
-
232
- | Step | Owner | Tool |
233
- |------|-------|------|
234
- | Quote | maker | `kaleidoswap_get_quote` |
235
- | Init | maker | `kaleidoswap_atomic_init` (returns swapstring + payment_hash) |
236
- | Pubkey | **node** | `rln_get_node_info` (read `pubkey`) |
237
- | Whitelist | **node** | `rln_atomic_taker` (pass the swapstring) |
238
- | Execute | maker | `kaleidoswap_atomic_execute` (needs swapstring + taker_pubkey + payment_hash) |
239
- | Status | maker | `kaleidoswap_atomic_status` (pass atomic_id or payment_hash from the atomic recipe summary or prior init result; see "remember" line in history) |
240
-
241
- The node's two contributions to the swap are the **pubkey** and the
242
- **whitelist ack** — nothing more. Don't reach for `/makerinit` or
243
- `/makerexecute`; those are for nodes that act AS the maker, which is not us.
244
-
245
- ## Safety
246
-
247
- - Show amount, recipient and asset before any send; the engine also asks for
248
- confirmation on every 🔒 tool.
249
- - Flag a send above half of the available balance.
250
- - If the node is unreachable or the wallet is locked, use the `kaleido-node`
251
- skill (start / unlock) before retrying.
252
-
253
- ## Reply style
254
-
255
- - One short sentence built from the tool result.
256
- - Pubkeys are long hex strings — quote them in monospace if you can, never
257
- truncate them when the user explicitly asked for them.
258
- - For `rln_get_node_info`, if the user just said "what's my node status?",
259
- surface pubkey + num_usable_channels + local_balance_sat. Don't dump the
260
- whole `details` object.
11
+ # RGB Lightning Node
12
+
13
+ Every value in a reply comes from a tool result in this turn. RGB `asset_id`s
14
+ look like `rgb:…`; a ticker is not an id — find the id with `rln_list_assets`.
15
+ Amounts are display units (10 = 10 USDT) except fields named `*_sat`/`*_sats`.
16
+
17
+ ## Do
18
+ - Holdings: one `rln_list_assets {}` call. Each asset already carries
19
+ `balance` (`spendable`, `settled`, `future`, `offchain_outbound`,
20
+ `offchain_inbound`) in raw units: divide by 10^`precision`. Assets held in a
21
+ Lightning channel show in `offchain_outbound`. Use `rln_get_asset_balance`
22
+ only for a single asset the user names.
23
+ - Issue: `rln_issue_asset` (confirm-gated). `ticker` 1–8 uppercase letters or
24
+ digits; `amount` is the total supply; `precision` defaults to 0;
25
+ `schema` is `NIA` (token, default), `CFA` (collectible, no ticker) or `UDA`
26
+ (NFT, supply 1). If it fails with "no available UTXOs", call
27
+ `rln_create_utxos {}` and retry. Reply with the new `asset_id`.
28
+ - Send an asset: `recipient_id` is the `utxob:…`/`wvout:…` part of the RGB
29
+ invoice. Never invent a recipient or an invoice.
30
+ - Receive: `rln_create_rgb_invoice` (RGB) or `rln_create_ln_invoice` (BTC over
31
+ Lightning); reply with the full `invoice` string.
32
+ - Stale balance or transfer: `rln_refresh_transfers {}` once, then re-read.
33
+ - Node unreachable or locked: switch to the `kaleido-node` skill.
34
+
35
+ ## Examples
36
+ - "Which RGB assets do I hold?" → `rln_list_assets {}`
37
+ - "Issue a token named Skill Test, ticker SKT, supply 1000" → `rln_issue_asset {"name":"Skill Test","ticker":"SKT","amount":1000,"precision":0}`
38
+ - "Send 5 SKT to rgb:~/~/~/sig/any/1/utxob:abc" → `rln_list_assets {}` then `rln_send_asset {"asset_id":"<SKT asset_id>","recipient_id":"utxob:abc","amount":5}`
39
+ - "Invoice me 10 USDT" → `rln_create_rgb_invoice {"asset_id":"<USDT asset_id>","amount":10}`
40
+ - "Lightning invoice for 5000 sats" → `rln_create_ln_invoice {"amount_sats":5000}`
41
+
42
+ Channels, peers and swap internals: read `references/channels.md`.
@@ -0,0 +1,34 @@
1
+ # Channels, peers, payments and swaps
2
+
3
+ | Tool | Arguments | Notes |
4
+ |---|---|---|
5
+ | `rln_get_node_info` | — | `pubkey`, `num_channels`, `num_usable_channels`, `local_balance_sat` (what you can **send**, not receive) |
6
+ | `rln_list_channels` | `usable_only?` | Per channel: `capacity_sat`, outbound (send) and inbound (receive) balance, `is_usable`, RGB `asset_id` + local/remote asset amounts |
7
+ | `rln_get_balances` | `skip_sync?` | On-chain BTC (vanilla + colored) and Lightning BTC. RGB assets are in `rln_list_assets` |
8
+ | `rln_connect_peer` | `peer_pubkey_and_addr` | `pubkey@host:port` |
9
+ | `rln_open_channel` | `peer_pubkey_and_addr`, `capacity_sat`, `push_msat?`, `asset_id?`, `asset_amount?`, `is_public?` | Confirm-gated. Opens asynchronously: report `temporary_channel_id` |
10
+ | `rln_get_channel_id` | `temporary_channel_id` | Final `channel_id` once open |
11
+ | `rln_close_channel` | `channel_id`, `peer_pubkey`, `force?` | Confirm-gated. `force` only for an unresponsive peer |
12
+ | `rln_list_payments` | `limit?` | Lightning payments sent and received |
13
+ | `rln_pay_invoice` | `invoice` | Confirm-gated. The BOLT11 string, unchanged |
14
+ | `rln_get_address` | — | On-chain BTC deposit address (not an invoice) |
15
+ | `rln_send_btc` | `address`, `amount_sat`, `fee_rate?` | Confirm-gated |
16
+ | `rln_list_transfers` | `asset_id` | RGB transfers with status `WaitingCounterparty` → `WaitingConfirmations` → `Settled` / `Failed` |
17
+ | `rln_list_swaps` / `rln_get_swap` | — / `payment_hash`, `taker?` | The node's view of atomic swaps |
18
+ | `rln_atomic_taker` | `swapstring` | Confirm-gated. Whitelists a maker swap; see the `kaleido-trading` skill |
19
+
20
+ A channel bought from an LSP appears in `rln_list_channels` only after its
21
+ funding transaction confirms; if it is missing, say it is still opening.
22
+
23
+ ## Issuing and distributing an asset
24
+
25
+ 1. `rln_get_node_info {}` — node reachable and unlocked.
26
+ 2. `rln_create_utxos {}` — only on a fresh node or after "no available UTXOs";
27
+ wait for the funding transaction to confirm.
28
+ 3. `rln_issue_asset {"name":"Hackathon Ticket","ticker":"TICKET","amount":1000}`.
29
+ 4. The receiver runs `rln_create_rgb_invoice`; you run `rln_send_asset` with
30
+ the new `asset_id` and the invoice's `recipient_id`.
31
+ 5. `rln_refresh_transfers {}` then `rln_list_transfers {"asset_id":"<asset_id>"}`
32
+ until the transfer is `Settled`.
33
+
34
+ kaleido-mcp also exposes every `rln_*` tool as `wdk_*` with the same arguments.
@@ -1,236 +1,34 @@
1
1
  ---
2
2
  name: spark-wallet
3
- description: "Operate the user's Spark BTC wallet on this device — check Spark balance, get a Spark deposit address, create a Spark Lightning invoice to receive, pay any BOLT11 Lightning invoice with Spark, or send BTC on-chain from Spark. Use this when the user names Spark explicitly OR when paying a Lightning invoice on a phone where Spark is the connected layer. Pairs with the bitrefill skill: a Bitrefill purchase that returns a Lightning invoice is paid with `spark_pay_invoice`."
4
- tools: spark_get_balance, spark_get_address, spark_get_onchain_address, spark_create_invoice, spark_pay_invoice, spark_send, get_price, fiat_to_sats, bitrefill_search, bitrefill_get_product, bitrefill_get_balance, bitrefill_create_invoice, bitrefill_get_invoice, bitrefill_get_order
5
- triggers: spark, sprak, spakr, spark wallet, pay with spark, send with spark, spark balance, spark address, spark invoice, lightning invoice, pay invoice, bolt11, ln invoice, pay this invoice, on-chain address, onchain address, deposit address, deposit btc, fund spark
6
- requires-tools: spark_get_balance
3
+ description: "The in-app Spark wallet: Spark balance and tokens (e.g. USDB), Spark address, on-chain deposit address, Lightning invoice to receive, pay a BOLT11 invoice, send BTC on-chain."
4
+ tools: spark_get_balance, spark_get_address, spark_get_onchain_address, spark_create_invoice, spark_pay_invoice, spark_send, get_price, fiat_to_sats
5
+ requires-tools: spark_create_invoice
6
+ triggers: spark, spark wallet, pay with spark, spark balance, spark address, spark invoice, deposit address, fund spark, usdb balance
7
7
  metadata:
8
8
  author: kaleidoswap
9
- version: "1.0.0"
9
+ version: "1.1.0"
10
10
  layer: spark
11
11
  ---
12
-
13
12
  # Spark wallet
14
13
 
15
- Spark is one of the user's connected BTC layers (alongside RLN/RGB and Arkade
16
- on some hosts). It speaks Lightning natively — receive via `spark_create_invoice`,
17
- send via `spark_pay_invoice` (BOLT11) or `spark_send` (on-chain). All numbers
18
- are in **satoshis** unless stated otherwise.
19
-
20
- ## Three "addresses", three different tools (read this carefully)
21
-
22
- The word "address" can mean three completely different things on Spark.
23
- Each has a DIFFERENT tool, a DIFFERENT shape, and a DIFFERENT use. If you
24
- return the wrong one, the user loses money on a bad deposit. Pick by what
25
- the user is trying to DO, not just by the word "address":
26
-
27
- | User intent | Tool | What you get | Looks like |
28
- |---|---|---|---|
29
- | Receive a **Spark-to-Spark** transfer (off-chain, within Spark) | `spark_get_address` | Spark identity / pubkey | `sparkrt1…` / `spark1…` |
30
- | Deposit **L1 Bitcoin** into Spark from the on-chain world | `spark_get_onchain_address` | Real Bitcoin on-chain address | `bc1…` / `tb1…` / `bcrt1…` |
31
- | Receive over **Lightning** (BOLT11) | `spark_create_invoice` | A Lightning invoice string | `lnbc…` / `lntb…` / `lnbcrt…` |
32
-
33
- **Disambiguation by phrasing — examples:**
34
-
35
- - "give me my **on-chain address**" / "**bitcoin address** to fund Spark"
36
- / "**deposit address**" / "where do I send BTC from my hardware wallet
37
- / mainnet" → `spark_get_onchain_address`. Result starts with bc1/tb1/
38
- bcrt1 — verify before replying.
39
- - "my **Spark address**" / "give me a **Spark address**" / "where do I
40
- receive a **Spark transfer**" → `spark_get_address`. Result starts with
41
- spark1/sparkrt1. **DO NOT label this as an on-chain address — it is
42
- off-chain.**
43
- - "give me an **invoice for N sats**" / "an **LN invoice**" / "**pay me**
44
- N sats" → `spark_create_invoice({amount_sats: N})`. Result is a `lnbc…`
45
- string.
46
-
47
- **Critical: when the user says "on-chain", they mean L1 Bitcoin.** Never
48
- return a `sparkrt1…` and call it "on-chain". If you return a
49
- `spark_get_address` result, you MUST describe it as a Spark (off-chain)
50
- address — never as an on-chain or Bitcoin address. If you return a
51
- `spark_get_onchain_address` result, you can call it an on-chain Bitcoin
52
- deposit address.
53
-
54
- A useful sanity check before you send the reply: glance at the
55
- `address` string's prefix. If it begins with `spark`, it's the off-chain
56
- Spark identity. If it begins with `bc1`/`tb1`/`bcrt1`, it's an on-chain
57
- BTC address. If it begins with `lnbc`/`lntb`/`lnbcrt`, it's a Lightning
58
- invoice. Whatever you call it in your reply MUST match its actual prefix.
59
-
60
- ## What Spark holds (and what it does NOT)
61
-
62
- This is the single most important thing to get right when the user asks
63
- about "assets on Spark" or "what can I trade on Spark".
64
-
65
- **Spark holds:**
66
- - **BTC** (sats) — Spark's native on-chain-pegged BTC.
67
- - **Spark-native tokens** — e.g. **USDB**. These are tokens issued on the
68
- Spark protocol itself, traded on **Flashnet** (Spark-native AMM).
69
-
70
- **Spark does NOT hold:**
71
- - **RGB assets** (USDT, XAUT, …). RGB assets are a DIFFERENT protocol on
72
- Bitcoin/Lightning — they live on the user's **RLN** (RGB Lightning Node),
73
- NOT Spark. A USDT balance, if the user has one, is on RLN — never on
74
- Spark.
75
- - Tokens from any other chain (Ethereum USDT, Tron USDT, Solana, …). The
76
- wallet does not custody those at all.
77
-
78
- **Asset → which skill / venue:**
79
-
80
- | Asset | Layer | Swap venue | Skill |
81
- |---|---|---|---|
82
- | BTC / sats | Spark / RLN / on-chain | Either (depends on direction) | spark-wallet (Spark side), wallet-assistant |
83
- | USDB (and other Spark tokens) | Spark | **Flashnet** (AMM) | **flashnet-swaps** |
84
- | USDT, XAUT (RGB assets) | RLN/RGB | **KaleidoSwap maker** | **kaleido-trading** |
85
-
86
- If the user asks "what can I trade on Spark?", the correct answer lists
87
- Spark-native tokens (BTC + USDB and anything else
88
- `flashnet_list_pools` shows). **Never** answer USDT/XAUT for Spark.
89
- Conversely, if asked "what can I trade on KaleidoSwap?", that's RGB
90
- assets (USDT, XAUT) — **not** USDB.
91
-
92
- When in doubt about what's actually tradeable, the source of truth is the
93
- TOOL, not your training data — call `flashnet_list_pools` (Spark side) or
94
- `kaleidoswap_get_assets` (RGB side) and report what comes back.
95
-
96
- ## Critical rules (read first)
97
-
98
- 1. **Always re-fetch volatile state — every turn, every time.** Balance,
99
- address, invoice status, and any number that can change MUST come from a
100
- tool call THIS turn. Do NOT reuse a value from a previous turn, even if
101
- the user asked the exact same question 30 seconds ago. The user wouldn't
102
- ask twice if they didn't want a fresh check.
103
-
104
- - "what's my balance?" → ALWAYS call `spark_get_balance`. Yes, even if
105
- you just called it. The whole point of asking again is to get a new
106
- reading.
107
- - "give me my address" → ALWAYS call `spark_get_address`. Spark may
108
- rotate or surface a fresh address.
109
- - "did my invoice settle?" → ALWAYS re-fetch the invoice/order status.
110
-
111
- The ONLY thing you can reuse from history is the user's own input
112
- (e.g. "the invoice I just made" → look up its id in history and call
113
- the status tool on it).
114
-
115
- 2. **Never invent a balance, invoice or address.** Every BTC number, BOLT11
116
- string, and address in your reply MUST come from a Spark tool result
117
- returned in the CURRENT turn — never guessed, never quoted from memory.
118
-
119
- 3. **Read the tool result exactly.** `spark_get_balance` returns
120
- `{ total, layer, network, connected }`. `connected: true` means the
121
- Spark wallet IS active and reachable; `total: 0` with `connected: true`
122
- simply means the user has no sats yet (perfectly normal for a fresh
123
- wallet on regtest). Do NOT say "your wallet isn't connected" unless
124
- `connected: false` or the tool threw an error. Say "your Spark wallet
125
- is connected but empty — fund it with `spark_get_address`" when
126
- `total: 0, connected: true`.
127
-
128
- 4. **Choose the right send tool by destination shape.**
129
- - Starts with `lnbc…` / `lntb…` / `lnbcrt…` → BOLT11 Lightning invoice → use
130
- **`spark_pay_invoice`**.
131
- - Starts with `bc1…` / `tb1…` / `bcrt1…` → on-chain Bitcoin address → use
132
- **`spark_send`**.
133
- - Looks like `name@domain` (a Lightning address) → not a Spark target;
134
- either ask the host to resolve it first or use the cross-cutting
135
- `send_payment` router. Spark itself doesn't dereference LNURL.
136
-
137
- 5. **BOLT11 invoices encode their amount.** Don't pass `amount_sats` to
138
- `spark_pay_invoice` unless the invoice is amount-less. Re-stating the
139
- amount can produce silently-wrong sends on amount-less invoices.
140
-
141
- 6. **Confirm before spending.** `spark_pay_invoice` and `spark_send` are
142
- confirmation-gated by the contract — the host fires the gate
143
- automatically. Before the call, summarize in one line:
144
- `Paying 12,540 sats to lnbc12540n… from Spark. Confirm?`
145
-
146
- 7. **Spark genuinely unavailable = stop, don't guess.** If the tool
147
- THROWS with "Your SPARK wallet isn't connected yet" (an actual error,
148
- not a 0 balance), say so plainly and stop — don't substitute RLN or
149
- Arkade silently. The user may genuinely want Spark.
150
-
151
- 8. **Never refuse an action a listed tool performs.** If a tool in your
152
- set does what the user asked, CALL IT — do not reason about whether
153
- "get" means "create", whether the wording is an exact match, or
154
- whether some other tool would be "more correct". The user asking to
155
- "create an address" when you have `spark_get_address` means: call
156
- `spark_get_address`. Refusing to use an available tool is always wrong.
157
-
158
- ## How to call the tools
159
-
160
- ### Reads
161
-
162
- - **`spark_get_balance({})`** — current Spark balances. Returns the BTC
163
- balance (`total` in sats) AND every Spark-native **token** the wallet
164
- holds (`tokens[]` — each with `address`, `balance`, optional `symbol`
165
- and `decimals`). When the user asks "what do I have on Spark" or
166
- "what's my Spark balance", surface BOTH the sats AND any non-zero
167
- token balances; an answer that only mentions BTC when tokens are
168
- present is incomplete.
169
- - `flashnet_get_balance` returns the same numbers (it's the AMM-client
170
- view of the same wallet) — there's no need to call it just to learn
171
- the token balance.
172
- - **`spark_get_address({})`** — the user's **Spark identity**
173
- (`sparkrt1…`/`spark1…`), an OFF-CHAIN Spark-to-Spark receive target.
174
- Reusable — getting and creating are the same operation, so the right
175
- response to "create a Spark address" is ALSO this tool. NEVER call its
176
- result an on-chain address or a Bitcoin address; it is neither. NEVER
177
- reply "I cannot create an address" — this tool IS how you create one.
178
- - **`spark_get_onchain_address({})`** — a real Bitcoin **on-chain
179
- deposit** address (`bc1…`/`tb1…`/`bcrt1…`) for funding Spark from L1.
180
- Use whenever the user says "on-chain", "bitcoin address", "deposit
181
- address", "fund Spark", or otherwise indicates they want to send L1
182
- BTC. NEVER substitute `spark_get_address` here.
183
-
184
- ### Receive
185
-
186
- - **`spark_create_invoice({ amount_sats? })`** — Spark Lightning invoice.
187
- - Omit `amount_sats` for an "any amount" invoice.
188
- - Returns `{ invoice: "lnbc…", … }`.
189
- - This is the tool for "give me an invoice for N sats", NOT for any
190
- "address" ask.
191
-
192
- ### Send — pick by destination
193
-
194
- - **`spark_pay_invoice({ invoice, amount_sats? })`** — pay a BOLT11 invoice.
195
- - The model's default Lightning spend tool. Use this for invoices from
196
- Bitrefill, a contact's invoice paste, or any `ln…` string.
197
- - Pass `amount_sats` ONLY when the invoice is amount-less (a 0-amount
198
- invoice). For ordinary amount-bound invoices, OMIT it.
199
- - **`spark_send({ amount_sats, to })`** — on-chain Bitcoin send.
200
- - Use only when `to` is an on-chain address (`bc1…`). Never pass a BOLT11
201
- invoice here.
202
-
203
- ### Helpers
204
-
205
- - **`get_price({ fiat? })`** / **`fiat_to_sats({ amount, currency })`** —
206
- for "how many sats is €10" style sub-questions before a Spark spend.
207
-
208
- ## Cross-skill flow with Bitrefill
209
-
210
- When the user wants to buy something from Bitrefill and pay with Spark, the
211
- typical chain is:
212
-
213
- 1. Call `bitrefill_search` / `bitrefill_get_product` to confirm the product +
214
- the right `package_id` (see the `bitrefill` skill).
215
- 2. Call `bitrefill_create_invoice({ products, payment_method: "lightning",
216
- refund_address: <a Spark or on-chain address> })` — Bitrefill returns a
217
- BOLT11 invoice on the response under `payment.lightning_invoice` (or
218
- similar — relay whatever the host surfaces).
219
- 3. **Pay with Spark**: `spark_pay_invoice({ invoice: <that BOLT11> })`. One
220
- confirmation gate; Spark settles the invoice in seconds.
221
- 4. Poll `bitrefill_get_invoice` until `status:"complete"`, then
222
- `bitrefill_get_order` for the redemption code.
223
-
224
- If the user pre-funded a Bitrefill account, prefer
225
- `payment_method:"balance"` instead — no Spark spend, instant settlement. Use
226
- the Lightning path when the user explicitly says "pay with Spark/Lightning"
227
- or has no Bitrefill balance.
228
-
229
- ## Reply style
230
-
231
- - One short sentence per fact ("Spark holds 124,500 sats.").
232
- - For invoices: show the invoice on its own line so the user can copy it.
233
- - For sends: one-line pre-spend summary (amount + destination + "from
234
- Spark"), then the result.
235
- - When `spark_get_balance` says zero and the user asked to spend, stop and
236
- say so — don't try to source funds from another layer silently.
14
+ Spark holds BTC (sats) and Spark-native tokens such as USDB. RGB assets (USDT,
15
+ XAUT) live on the RGB Lightning Node, not on Spark.
16
+
17
+ ## Do
18
+ - Balance: `spark_get_balance` returns `total` sats and `tokens[]`; report
19
+ both. `total: 0` with `connected: true` is an empty wallet, not an error.
20
+ - Three different "addresses" — pick by intent and check the prefix:
21
+ - Spark-to-Spark receive → `spark_get_address` (`spark1…`/`sparkrt1…`, off-chain).
22
+ - Deposit on-chain BTC → `spark_get_onchain_address` (`bc1…`/`tb1…`/`bcrt1…`).
23
+ - Receive over Lightning → `spark_create_invoice` (`lnbc…`/`lntb…`).
24
+ - Pay a BOLT11 invoice → `spark_pay_invoice`; pass `amount_sats` only for an
25
+ amount-less invoice. On-chain address → `spark_send`. Both are
26
+ confirm-gated.
27
+ - If a tool errors with "not connected", say so; don't switch layers.
28
+
29
+ ## Examples
30
+ - "Spark balance?" → `spark_get_balance {}`
31
+ - "Address to deposit BTC into Spark" → `spark_get_onchain_address {}`
32
+ - "Invoice for 1500 sats" → `spark_create_invoice {"amount_sats":1500}`
33
+ - "Pay lnbc12540n1p…" → `spark_pay_invoice {"invoice":"lnbc12540n1p…"}`
34
+ - "Send 20000 sats to bc1q…" → `spark_send {"amount_sats":20000,"to":"bc1q…"}`