@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,158 +1,32 @@
1
1
  ---
2
2
  name: flashnet-swaps
3
- description: "Swap between BTC and Spark tokens (e.g. USDB) using Flashnet — a Spark-native AMM. Run by quoting `flashnet_simulate_swap` first, then `flashnet_execute_swap` on confirmation. Pairs with the spark-wallet skill: the same Spark wallet that holds your BTC is what signs the swap. Triggers on swap/exchange/convert/trade phrasings involving BTC + a Spark token, or explicit mention of Flashnet."
4
- tools: flashnet_list_pools, flashnet_get_pool, flashnet_simulate_swap, flashnet_execute_swap, flashnet_get_balance, spark_get_balance, spark_get_address, get_price, fiat_to_sats
5
- triggers: flashnet, swap, exchange, convert, trade, usdb, amm, pool, liquidity, btc to usdb, usdb to btc, spark swap
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.0.0"
9
+ version: "1.1.0"
9
10
  venue: flashnet
10
11
  ---
11
-
12
12
  # Flashnet swaps
13
13
 
14
- Flashnet is a Spark-native AMM. The user's Spark wallet IS the swap account —
15
- there's no separate exchange balance. A swap takes one asset from the wallet,
16
- sends it through a pool, and returns the other asset to the same wallet, in
17
- seconds. Two pool curve types exist (constant-product and V3 concentrated
18
- liquidity) — the model doesn't need to care; the pool id is enough.
19
-
20
- ## What Flashnet trades (and what it does NOT)
21
-
22
- **Flashnet trades:**
23
- - **BTC** ↔ **Spark-native tokens**. The canonical example is **USDB**.
24
- - Whatever pools `flashnet_list_pools` returns — that list is the
25
- authoritative answer to "what can I trade here?".
26
-
27
- **Flashnet does NOT trade:**
28
- - **RGB assets** (USDT, XAUT, …). RGB assets live on the RLN layer and
29
- trade via the **KaleidoSwap maker** (`kaleido-trading` skill), not here.
30
- USDT on Flashnet does not exist — never offer it.
31
- - Assets the user holds on Arkade, on-chain BTC reserves, or any external
32
- chain. The trade-account is the Spark wallet.
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 itself: list environments, start/stop/tear down the Docker stack, check reachability, initialise the wallet once, unlock it after every restart, and recover from a down or locked node. Triggers when the user wants to start, stop, unlock or set up their node, or when node calls fail with 'unreachable' or 'wallet locked'. Uses kaleido-mcp's kaleido_node_* tools (or the kaleido CLI)."
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
- triggers: start node, stop node, start my node, stop my node, node up, node down, unlock, unlock node, lock node, wallet locked, init node, initialise node, initialize node, docker, environment, node status, node unreachable, mnemonic, seed phrase
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.1.0"
9
+ version: "0.2.0"
9
10
  ---
10
-
11
11
  # Kaleido node lifecycle
12
12
 
13
- Operate the node process, not the wallet. For balances, invoices, payments and
14
- channels use the `rgb-lightning-node` skill.
15
-
16
- These tools come from kaleido-mcp and wrap the `kaleido` CLI, which must be
17
- installed on the machine running the MCP server. In-app wallets don't have
18
- them. If a tool is not in your list, say what the user should run instead
19
- (CLI column below).
20
-
21
- ## Tools
22
-
23
- | Step | MCP tool | CLI equivalent |
24
- |---|---|---|
25
- | List environments | `kaleido_node_list()` | `kaleido --json --agent node list` |
26
- | Start | `kaleido_node_up({ name? })` | `kaleido --agent node up <NAME>` |
27
- | Container status | `kaleido_node_ps({ name? })` | `kaleido --agent node ps <NAME>` |
28
- | Reachability | `kaleido_node_status()` | `kaleido --json --agent node info` |
29
- | Node + network info | `kaleido_node_info()` | `kaleido --json --agent node info` |
30
- | Select active node | `kaleido_node_use({ name, node? })` | — |
31
- | First-time wallet init | `kaleido_node_init({ password, mnemonic? })` | `kaleido --agent node init` |
32
- | Unlock after restart | `kaleido_node_unlock({ password, announce_alias?, announce_address? })` | `kaleido --agent node unlock <PASSWORD>` |
33
- | Lock | `kaleido_node_lock()` | — |
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"}`
@@ -1,179 +1,35 @@
1
1
  ---
2
2
  name: kaleido-trading
3
- description: "Trade on KaleidoSwap — quote and execute swaps between BTC and RGB assets (USDT, XAUT). Get assets and pairs, pull an executable quote, or run/poll an atomic swap end-to-end. Triggers when the user wants a quote, to swap or trade assets, to rebalance between BTC and stablecoins, or to check the status of a swap / atomic swap."
4
- tools: kaleidoswap_get_assets, kaleidoswap_get_pairs, kaleidoswap_get_quote, kaleidoswap_atomic_init, kaleidoswap_atomic_execute, kaleidoswap_atomic_status, rln_get_node_info, rln_atomic_taker, rln_refresh_transfers, rln_get_asset_balance, rln_list_channels, rln_list_swaps, rln_get_swap
5
- triggers: quote, swap, trade, rebalance, slippage, pair, pairs, usdt, xaut, kaleidoswap, rfq, check status, order status, check the order, swap status, check my swap, atomic status
3
+ description: "Quote and run KaleidoSwap atomic swaps between BTC and RGB assets (USDT, XAUT): pairs, assets, quotes, swap execution and swap status."
4
+ tools: kaleidoswap_get_pairs, kaleidoswap_get_assets, kaleidoswap_get_quote, kaleidoswap_atomic_init, rln_atomic_taker, rln_get_node_info, kaleidoswap_atomic_execute, kaleidoswap_atomic_status, rln_refresh_transfers
5
+ requires-tools: kaleidoswap_get_quote
6
+ triggers: quote, swap, trade, pair, pairs, usdt, xaut, kaleidoswap, rfq, atomic, swap status
6
7
  metadata:
7
8
  author: kaleidoswap
8
- version: "0.5.0"
9
+ version: "0.6.0"
9
10
  ---
10
-
11
11
  # KaleidoSwap trading
12
12
 
13
- Quote and execute swaps on the KaleidoSwap maker. The model picks tools by
14
- name; the host binds them through whichever transport it runs over (WDK on
15
- mobile, HTTP/MCP/CLI on desktop).
16
-
17
- ## Critical rules — these override everything else
18
-
19
- You have **no knowledge** of any price, quote, fee, pair, or order. Every
20
- number, pair, or quote id in your reply MUST come from a tool result returned
21
- in the CURRENT turn:
22
-
23
- - "What pairs are listed?" → call `kaleidoswap_get_pairs` and list them.
24
- - "Quote 100k sats to USDT" → call `kaleidoswap_get_quote(BTC, USDT, 100000)`,
25
- then state the receive amount + fee from the result.
26
-
27
- **Calling the tool IS the answer.** Never write "the pairs are listed using
28
- kaleidoswap_get_pairs" or "the function returns the quote" — just call it.
29
-
30
- **Never reuse a number across turns.** If the user asks a new question, the
31
- previous turn's quote, price, or fee is irrelevant — fetch fresh.
32
-
33
- **Never invent a quote.** Without an `rfq_id` and a `to_asset.amount` returned
34
- this turn, you do not have a quote. Say so and re-quote.
35
-
36
- This skill is for tradeable pair quotes on the maker. It does NOT do generic
37
- "what is bitcoin worth in USD" spot prices — that's the wallet's job. If the
38
- user asks for a plain BTC price (not a swap), say you can quote a swap and ask
39
- which pair + amount.
40
-
41
- ## Asset codes (canonical)
42
-
43
- KaleidoSwap is the maker for **BTC ↔ RGB asset** atomic swaps. The asset
44
- family is **RGB**: USDT, XAUT, and any other RGB asset the maker prices.
45
- The RGB assets live on the user's **RLN** (RGB Lightning Node) — NOT on
46
- Spark, Arkade, or any other chain.
47
-
48
- Only these codes are accepted:
49
-
50
- - `BTC` (Bitcoin, amounts always in satoshis)
51
- - `USDT` (Tether, the RGB asset) — **not** `USD`, **not** `tether`
52
- - `XAUT` (Tether Gold, the RGB asset) — **not** `XAU`, **not** `gold`
53
-
54
- When the user types `USD` they almost always mean `USDT` — confirm before
55
- quoting. Same for `gold` → `XAUT`. Don't silently substitute.
56
-
57
- **Do NOT trade here:**
58
-
59
- - `USDB` and any other **Spark-native token** — those are on the Spark
60
- layer and trade on **Flashnet** (skill: `flashnet-swaps`), not on
61
- KaleidoSwap. Route the user there instead of inventing a maker pair.
62
- - Tokens from external chains (Ethereum USDT, Solana, etc.). They are
63
- not in the maker's catalog and the wallet does not custody them.
64
-
65
- ## Tools
66
-
67
- ### `kaleidoswap_get_pairs` — no args
68
- Use when the user asks "what can I trade", "list pairs", "what's available",
69
- or before quoting an unfamiliar pair.
70
-
71
- ### `kaleidoswap_get_quote` — REQUIRES `amount`
72
- Required args: `from_asset` AND `to_asset` AND `amount`. The maker rejects a
73
- quote that has no amount.
74
-
75
- **If the user didn't give an amount, ASK for it. Do NOT call the tool with
76
- from/to alone, and do NOT make up an amount.**
77
-
78
- `amount` is in the smallest unit of `from_asset`. Use the EXACT number the user
79
- typed (scaled if they used "k"/"m"/"M" shorthand: 100k → 100000, 2m → 2000000).
80
- **Never** copy an amount from a previous turn or from these instructions.
81
-
82
- Critical unit-and-leg anchor:
83
- - If the user says **sats** or **satoshis** anywhere, the BTC leg is implied
84
- (sats = the smallest unit of BTC). `BTC` is always `from_asset` OR `to_asset`
85
- depending on the verb.
86
- - "X sats TO Y" → `from_asset: "BTC"`, `to_asset: "Y"`, `amount: X-as-sats`.
87
- - "X Y TO BTC" (Y ∈ {USDT, XAUT}) → `from_asset: "Y"`, `to_asset: "BTC"`,
88
- `amount: X-in-Y-units`.
89
- - "buy Z of A with B" → spent = B → `from_asset: "B"`, received = A → `to_asset: "A"`,
90
- `amount: <amount of B the user wants to spend>`.
91
- - "rate of X to Y" with NO number → no amount → ASK: "How much do you want to
92
- swap?" → do NOT call the tool yet.
93
-
94
- ### Reading the quote response
95
-
96
- `kaleidoswap_get_quote` returns ready-to-read display fields — **use them
97
- verbatim. Do NOT do any arithmetic yourself.** The response looks like:
98
-
99
- ```
100
- {
101
- "rfq_id": "<id>",
102
- "from_amount_display": "100,000 BTC-sats", ← what the user spends
103
- "to_amount_display": "0.063176 USDT", ← what the user receives
104
- "fee_display": "0.000638 USDT", ← the fee
105
- "expires_at": <epoch>,
106
- ...raw numeric fields you should ignore...
107
- }
108
- ```
109
-
110
- To state the answer, copy the strings:
111
- - Receive amount → `to_amount_display`.
112
- - Fee → `fee_display`.
113
- - `rfq_id` is the quote handle (needed to start the atomic swap), short-lived (~60s) —
114
- mention it expires soon.
115
-
116
- **Read `to_amount_display` / `fee_display` exactly as given.** Do NOT compute
117
- `amount ÷ 10^precision`, do NOT restate the raw `price`/`amount` integers, and
118
- do NOT copy the numbers from this document — they are placeholders. The only
119
- correct numbers are the `*_display` strings in the CURRENT tool result.
120
-
121
- A good reply: *"100,000 sats → <to_amount_display> (fee <fee_display>). Quote
122
- <rfq_id> is valid ~60s — want me to place it?"*
123
-
124
- ### `kaleidoswap_atomic_init` 🔒 spend
125
- Only after `kaleidoswap_get_quote` returned an `rfq_id` THIS turn, and only when
126
- the user has explicitly approved the amount + direction. Starts the atomic
127
- swap from that quote; the rest of the chain (`rln_atomic_taker` →
128
- `kaleidoswap_atomic_execute` → `kaleidoswap_atomic_status`) is described
129
- below and in `references/atomic.md`.
130
-
131
- ### `kaleidoswap_atomic_status`
132
- Poll after executing an atomic swap until it reaches a terminal state
133
- (completed / failed / expired). Pass the exact ids returned by
134
- `kaleidoswap_atomic_init` (or surfaced in the most recent swap summary) — never
135
- invent them. Report the outcome plainly.
136
-
137
- ## Flow
138
-
139
- 1. **Pick a pair** — skip when obvious (`BTC/USDT`, `BTC/XAUT`).
140
- 2. **Quote** — `kaleidoswap_get_quote`. REQUIRES amount; ask if missing.
141
- 3. **Read + present** — compute the receive amount + fee from the response (see
142
- "Reading the quote response"). **Never hide cost.**
143
- 4. **Swap** — `kaleidoswap_atomic_init` → `rln_atomic_taker` →
144
- `kaleidoswap_atomic_execute`. Spend-gated by the engine; the host pauses for
145
- the user.
146
- 5. **Track** — poll `kaleidoswap_atomic_status` with the ids from
147
- `kaleidoswap_atomic_init` until it terminates.
148
-
149
- ## Don'ts
150
-
151
- - Don't invent prices, quotes, rfq_ids, swap ids, or access_tokens.
152
- - Don't reuse a number from a previous turn.
153
- - Don't describe how a tool works — call it.
154
- - Don't call `kaleidoswap_get_quote` with from/to only — ask for the amount.
155
- - Don't make up an amount the user didn't give.
156
- - Don't do unit math or restate raw integers — read the `*_display` strings.
157
- - Don't copy numbers from the skill docs — only the current tool result is real.
158
- - Don't accept `XAU` as `XAUT` or `USD` as `USDT` silently — confirm.
159
- - Don't retry the same failing tool call in a loop. If a call fails, read the
160
- error and either ask the user, fix the args, or stop.
161
- - Don't claim a swap completed without polling `kaleidoswap_atomic_status`
162
- and seeing a terminal state.
163
-
164
- For the full atomic-swap flow (init → whitelist on the RGB node → execute), a
165
- deterministic recipe drives the chain — the agentic loop is not safe to plan a
166
- multi-step, two-service swap on a small model. Status for atomics uses the
167
- `atomic_id` (or payment_hash) surfaced in the recipe summary.
168
-
169
- ## Over kaleido-mcp (desktop, Claude Code)
170
-
171
- kaleido-mcp 0.3.0+ is **atomic-only**. Its quote takes `from_asset_id` / `from_layer` /
172
- `from_amount` (display units) and returns `amount_raw` values that
173
- `kaleidoswap_atomic_init` takes unchanged. The full chain is quote →
174
- `kaleidoswap_atomic_init` → `rln_atomic_taker` + `rln_get_node_info` →
175
- `kaleidoswap_atomic_execute` → poll `kaleidoswap_atomic_status` →
176
- `rln_refresh_transfers`. Read `references/atomic.md` before the first swap,
177
- and `references/assets.md` for units and precision. Always follow the
178
- argument names in the tool schema you were given.
179
-
13
+ Amounts in `kaleidoswap_get_quote` are **display units**: `from_amount: 0.0005`
14
+ means 0.0005 BTC (50,000 sats; 1 BTC = 100,000,000 sats). Asset ids accept a
15
+ ticker (`BTC`, `USDT`, `XAUT`) or an `rgb:…` id.
16
+
17
+ ## Do
18
+ - Quote with exactly one amount: `from_amount` to sell a fixed input,
19
+ `to_amount` to buy a fixed output. No amount given → ask for one.
20
+ - Report `from_asset.amount_display`, `to_asset.amount_display` and
21
+ `expires_at` as given; `price` is in the maker's raw units, don't quote it.
22
+ The quote expires in about 60 s.
23
+ - Executing a swap moves funds: only after the user says yes to that quote.
24
+ Chain: `kaleidoswap_atomic_init` (rfq_id, both asset ids, both `amount_raw`
25
+ values unchanged) → `rln_atomic_taker` (swapstring) → `rln_get_node_info`
26
+ (pubkey) → `kaleidoswap_atomic_execute` → poll `kaleidoswap_atomic_status`.
27
+ Details and errors: `references/atomic.md`.
28
+ - `USD` is not `USDT` and `gold` is not `XAUT`: confirm before quoting.
29
+ Spark tokens such as USDB trade on Flashnet (`flashnet-swaps`), not here.
30
+
31
+ ## Examples
32
+ - "Quote 0.0005 BTC to USDT" → `kaleidoswap_get_quote {"from_asset_id":"BTC","to_asset_id":"USDT","from_amount":0.0005}`
33
+ - "Swap 100k sats into XAUT" → `kaleidoswap_get_quote {"from_asset_id":"BTC","to_asset_id":"XAUT","from_amount":0.001}`
34
+ - "I want to receive 10 USDT, how much BTC?" → `kaleidoswap_get_quote {"from_asset_id":"BTC","to_asset_id":"USDT","to_amount":10}`
35
+ - "Status of swap 9f2c…" → `kaleidoswap_atomic_status {"payment_hash":"9f2c…"}`
@@ -40,10 +40,10 @@ Read precision from the API; the table is illustrative.
40
40
 
41
41
  | Tool | Units |
42
42
  |---|---|
43
- | `kaleidoswap_get_quote` (kaleido-mcp) | display (`0.001` BTC, `65.0` USDT) |
44
- | `kaleidoswap_atomic_init` (kaleido-mcp) | raw: pass `quote.*.amount_raw` unchanged |
45
- | `kaleidoswap_get_quote` (in-app contract) | sats for BTC, asset units otherwise |
46
- | `rln_send_asset` / `rln_create_rgb_invoice` (kaleido-mcp) | display units |
43
+ | `kaleidoswap_get_quote` | display (`0.001` BTC, `65.0` USDT) |
44
+ | `kaleidoswap_atomic_init` | raw: pass `quote.*.amount_raw` unchanged |
45
+ | `rln_send_asset` / `rln_create_rgb_invoice` / `rln_issue_asset` | display units |
46
+ | `rln_list_assets` / `rln_get_asset_balance` balances | raw: divide by 10^precision |
47
47
 
48
48
  ## Mapping user words
49
49
 
@@ -1,13 +1,11 @@
1
- # Atomic swap over kaleido-mcp
1
+ # Atomic swap
2
2
 
3
3
  Every KaleidoSwap swap settles as an atomic HTLC swap between the maker and
4
- the user's RGB Lightning Node (RLN). There is no deposit or order flow on
5
- kaleido-mcp 0.3.0+. If either side fails, nothing settles. Typical end-to-end
4
+ the user's RGB Lightning Node (RLN). There is no deposit or order flow. If either side fails, nothing settles. Typical end-to-end
6
5
  time: 2–15 s.
7
6
 
8
- These are kaleido-mcp's argument names. In-app wallets that bind the
9
- `@kaleidorg/mind` KaleidoSwap contract use the simpler `from_asset` /
10
- `to_asset` / `amount` quote and run the chain through a recipe instead.
7
+ The argument names are the same in kaleido-mcp and in the `@kaleidorg/mind`
8
+ KaleidoSwap contract.
11
9
 
12
10
  ## Steps
13
11
 
@@ -58,7 +56,7 @@ and is not an order id.
58
56
 
59
57
  The swap needs outbound capacity on the asset you send and inbound capacity on
60
58
  the asset you receive. If either side is short, `atomic_execute` fails. Buy a
61
- channel first (skill: `kaleido-lsps`).
59
+ channel first (skill: `channel-manager`).
62
60
 
63
61
  ## Reading the result
64
62