@kaleidorg/mind 0.6.0 → 0.6.2
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/bitrefill/contract.d.ts +60 -0
- package/dist/bitrefill/contract.d.ts.map +1 -0
- package/dist/bitrefill/contract.js +119 -0
- package/dist/bitrefill/contract.js.map +1 -0
- package/dist/context/compress.d.ts +65 -0
- package/dist/context/compress.d.ts.map +1 -0
- package/dist/context/compress.js +181 -0
- package/dist/context/compress.js.map +1 -0
- package/dist/engine.d.ts +20 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +23 -4
- package/dist/engine.js.map +1 -1
- package/dist/evidence.d.ts +62 -0
- package/dist/evidence.d.ts.map +1 -0
- package/dist/evidence.js +47 -0
- package/dist/evidence.js.map +1 -0
- package/dist/flashnet/contract.d.ts +56 -0
- package/dist/flashnet/contract.d.ts.map +1 -0
- package/dist/flashnet/contract.js +100 -0
- package/dist/flashnet/contract.js.map +1 -0
- package/dist/funnel.d.ts +11 -0
- package/dist/funnel.d.ts.map +1 -1
- package/dist/funnel.js +50 -7
- package/dist/funnel.js.map +1 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/kaleidoswap/contract.js +1 -1
- package/dist/kaleidoswap/contract.js.map +1 -1
- package/dist/knowledge/bitcoin-copilot.d.ts.map +1 -1
- package/dist/knowledge/bitcoin-copilot.js +83 -0
- package/dist/knowledge/bitcoin-copilot.js.map +1 -1
- package/dist/providers/types.d.ts +17 -0
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/qvac/provider.d.ts.map +1 -1
- package/dist/qvac/provider.js +23 -0
- package/dist/qvac/provider.js.map +1 -1
- package/dist/qvac/stream.d.ts +6 -0
- package/dist/qvac/stream.d.ts.map +1 -1
- package/dist/qvac/stream.js +12 -0
- package/dist/qvac/stream.js.map +1 -1
- package/dist/recipe/flashnet-swap.d.ts +35 -0
- package/dist/recipe/flashnet-swap.d.ts.map +1 -0
- package/dist/recipe/flashnet-swap.js +239 -0
- package/dist/recipe/flashnet-swap.js.map +1 -0
- package/dist/recipe/kaleidoswap-atomic.d.ts.map +1 -1
- package/dist/recipe/kaleidoswap-atomic.js +66 -32
- package/dist/recipe/kaleidoswap-atomic.js.map +1 -1
- package/dist/recipe/kaleidoswap-channel-order.d.ts.map +1 -1
- package/dist/recipe/kaleidoswap-channel-order.js +31 -10
- package/dist/recipe/kaleidoswap-channel-order.js.map +1 -1
- package/dist/recipe/kaleidoswap-price.d.ts.map +1 -1
- package/dist/recipe/kaleidoswap-price.js +7 -1
- package/dist/recipe/kaleidoswap-price.js.map +1 -1
- package/dist/recipe/runner.d.ts.map +1 -1
- package/dist/recipe/runner.js +5 -3
- package/dist/recipe/runner.js.map +1 -1
- package/dist/recipe/swap.d.ts.map +1 -1
- package/dist/recipe/swap.js +14 -1
- package/dist/recipe/swap.js.map +1 -1
- package/dist/wallet/confirm.d.ts.map +1 -1
- package/dist/wallet/confirm.js +1 -0
- package/dist/wallet/confirm.js.map +1 -1
- package/dist/wallet/contract.d.ts.map +1 -1
- package/dist/wallet/contract.js +20 -4
- package/dist/wallet/contract.js.map +1 -1
- package/package.json +4 -4
- package/skills/bitrefill/SKILL.md +152 -52
- package/skills/flashnet-swaps/SKILL.md +158 -0
- package/skills/kaleido-lsps/SKILL.md +25 -8
- package/skills/kaleido-trading/SKILL.md +36 -12
- package/skills/merchant-finder/SKILL.md +1 -1
- package/skills/rgb-lightning-node/SKILL.md +35 -8
- package/skills/spark-wallet/SKILL.md +235 -0
- package/skills/wallet-assistant/SKILL.md +2 -2
- package/src/bitrefill/contract.test.ts +89 -0
- package/src/bitrefill/contract.ts +190 -0
- package/src/context/compress.test.ts +120 -0
- package/src/context/compress.ts +230 -0
- package/src/engine.test.ts +34 -0
- package/src/engine.ts +35 -4
- package/src/evidence.test.ts +80 -0
- package/src/evidence.ts +114 -0
- package/src/flashnet/contract.test.ts +101 -0
- package/src/flashnet/contract.ts +164 -0
- package/src/funnel.mind.test.ts +3 -5
- package/src/funnel.ts +59 -8
- package/src/index.ts +51 -1
- package/src/kaleidoswap/contract.ts +1 -1
- package/src/knowledge/bitcoin-copilot.ts +94 -0
- package/src/providers/types.ts +18 -0
- package/src/qvac/provider.ts +25 -1
- package/src/qvac/stream.test.ts +11 -0
- package/src/qvac/stream.ts +16 -0
- package/src/recipe/flashnet-swap.test.ts +114 -0
- package/src/recipe/flashnet-swap.ts +266 -0
- package/src/recipe/kaleidoswap-atomic.test.ts +52 -6
- package/src/recipe/kaleidoswap-atomic.ts +71 -34
- package/src/recipe/kaleidoswap-channel-order.test.ts +38 -0
- package/src/recipe/kaleidoswap-channel-order.ts +27 -9
- package/src/recipe/kaleidoswap-price.ts +7 -1
- package/src/recipe/recipe.test.ts +5 -0
- package/src/recipe/runner.ts +5 -3
- package/src/recipe/swap.ts +16 -1
- package/src/wallet/confirm.test.ts +8 -0
- package/src/wallet/confirm.ts +1 -0
- package/src/wallet/contract.test.ts +10 -0
- package/src/wallet/contract.ts +26 -4
package/dist/wallet/contract.js
CHANGED
|
@@ -32,10 +32,26 @@ const asset = { type: 'string', description: "Asset ticker, e.g. 'USDT', 'XAUT',
|
|
|
32
32
|
/** The full contract. Keep descriptions terse — small models read every word. */
|
|
33
33
|
export const WALLET_TOOLS = [
|
|
34
34
|
// ── Spark ──────────────────────────────────────────────────────────────
|
|
35
|
-
t('spark', 'spark_get_balance', 'Get the Spark wallet BTC balance.'),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
t('spark', 'spark_get_balance', 'Get the Spark wallet balances — BTC sats AND every Spark-native token (e.g. USDB). Returns `{ total: <sats>, tokens: [{ address, balance, symbol?, decimals?, available_to_send? }], connected, layer, network }`. Use for ANY "balance / how much / what do I have on Spark" question — call it fresh every time, balances change. The `tokens` array surfaces ALL Spark-native tokens the wallet holds, so you do NOT need to call flashnet_get_balance separately for that (flashnet_get_balance is the AMM-client view of the same wallet and returns the same numbers). For RGB asset balances (USDT, XAUT) use the RLN tools — RGB assets are NOT on Spark.'),
|
|
36
|
+
// The user-facing "Spark address" — an off-chain Spark identity (sparkrt1…/
|
|
37
|
+
// spark1…). For OFF-CHAIN peer transfers WITHIN Spark. NOT a Bitcoin
|
|
38
|
+
// on-chain address. Use spark_get_onchain_address for the on-chain deposit
|
|
39
|
+
// path; use spark_create_invoice for a Lightning invoice.
|
|
40
|
+
t('spark', 'spark_get_address', 'Get the user\'s Spark address (sparkrt1…/spark1…) — an OFF-CHAIN Spark identity for receiving Spark-to-Spark transfers. NOT a Bitcoin on-chain address (does not start with bc1/tb1/bcrt1) and NOT a Lightning invoice. For "an on-chain address to deposit BTC into Spark" use spark_get_onchain_address. For a Lightning invoice use spark_create_invoice.'),
|
|
41
|
+
// Real on-chain Bitcoin address used to deposit BTC FROM mainnet INTO the
|
|
42
|
+
// Spark wallet. The SDK calls this a "static deposit address" — bc1…/tb1…/
|
|
43
|
+
// bcrt1…. The opposite of spark_get_address.
|
|
44
|
+
t('spark', 'spark_get_onchain_address', 'Get a real Bitcoin ON-CHAIN address (bc1…/tb1…/bcrt1…) for depositing BTC from the Bitcoin L1 into the Spark wallet. Use ANY time the user asks for "an on-chain address", "deposit address", "Bitcoin address to fund Spark", "where do I send my on-chain BTC". This is NOT the Spark identity (spark_get_address) and NOT a Lightning invoice (spark_create_invoice).'),
|
|
45
|
+
t('spark', 'spark_create_invoice', 'Create a Spark Lightning invoice (BOLT11) to receive BTC over Lightning. Returns an invoice string the user can share. Use when the user asks for "an invoice", "a lightning invoice", "pay me", or names an amount they want received. NOT an address.', { amount_sats: sats }),
|
|
46
|
+
// Explicit Lightning-invoice payer. BOLT11 invoices encode the amount, so
|
|
47
|
+
// `amount_sats` is optional and only used for amount-less ("any-amount")
|
|
48
|
+
// invoices. Prefer this over `spark_send` when the destination is a BOLT11
|
|
49
|
+
// invoice — it removes ambiguity for small models and gives the cross-skill
|
|
50
|
+
// bitrefill flow a single, unambiguous target.
|
|
51
|
+
t('spark', 'spark_pay_invoice', 'Pay a Lightning (BOLT11) invoice from the Spark wallet. The invoice already encodes the amount; pass amount_sats ONLY for amount-less invoices. Use this for any BOLT11 destination (Bitrefill, contact, raw invoice).', { invoice: { type: 'string', description: 'BOLT11 Lightning invoice (lnbc…/lntb…/lnbcrt…).' }, amount_sats: { type: 'number', description: 'Required ONLY when the invoice has no amount; omit otherwise.' } }, ['invoice'],
|
|
52
|
+
/* spend */ true),
|
|
53
|
+
t('spark', 'spark_send', 'Send BTC from Spark to an on-chain address (bc1…/tb1…). For BOLT11 invoices, prefer spark_pay_invoice.', { amount_sats: sats, to: { type: 'string', description: 'On-chain Bitcoin address.' } }, ['amount_sats', 'to'],
|
|
54
|
+
/* spend */ true),
|
|
39
55
|
// ── RLN / RGB ──────────────────────────────────────────────────────────
|
|
40
56
|
t('rln', 'rln_get_balances', 'Get RLN node balances (BTC + RGB assets).'),
|
|
41
57
|
t('rln', 'rln_get_node_info', 'Get RLN node status and sync state.'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/wallet/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAc7D,SAAS,CAAC,CACR,KAAkB,EAClB,IAAY,EACZ,WAAmB,EACnB,aAAoB,EAAE,EACtB,WAAqB,EAAE,EACvB,KAAK,GAAG,KAAK;IAEb,OAAO;QACL,KAAK;QACL,IAAI;QACJ,WAAW;QACX,KAAK;QACL,oBAAoB,EAAE,KAAK;QAC3B,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE;KACrD,CAAC;AACJ,CAAC;AAED,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,oBAAoB,EAAW,CAAC;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oBAAoB;YAC9C,OAAO;SACR,CAAC,CAAC;IACL,CAAC;IACD,OAAO,IAAI,mBAAmB,CAAC,IAAI,CAAC,EAAE,IAAI,QAAQ,EAAE,KAAK,CAAC,CAAC;AAC7D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaleidorg/mind",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Local-first reasoning + function-calling engine for KaleidoSwap. QVAC-powered.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@qvac/sdk": "^0.13.
|
|
70
|
-
"@types/node": "^20.
|
|
71
|
-
"vitest": "^1.6.
|
|
69
|
+
"@qvac/sdk": "^0.13.5",
|
|
70
|
+
"@types/node": "^20.19.43",
|
|
71
|
+
"vitest": "^1.6.1"
|
|
72
72
|
}
|
|
73
73
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: bitrefill
|
|
3
|
-
description: "Buy or browse Bitrefill — 1,500+ gift cards, mobile top-ups, and eSIMs across 180+ countries, payable in crypto, Lightning, USDC via x402, or pre-funded account balance.
|
|
4
|
-
|
|
3
|
+
description: "Buy or browse Bitrefill — 1,500+ gift cards, mobile top-ups, and eSIMs across 180+ countries, payable in crypto, Lightning, USDC via x402, or pre-funded account balance. Use these tools to actually transact: bitrefill_search → bitrefill_get_product → bitrefill_create_invoice (spend, confirmed) → bitrefill_get_invoice/bitrefill_get_order for 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, spark_get_balance, rln_pay_invoice
|
|
5
|
+
triggers: bitrefill, gift card, gift cards, giftcard, voucher, vouchers, top-up, topup, top up, refill, esim, e-sim, mobile plan, mobile top-up, prepaid, amazon, steam, google play, app store, itunes, playstation, xbox, netflix, spotify, uber
|
|
6
|
+
compatibility: "Live REST adapter on the CLI/desktop when BITREFILL_API_KEY (Personal) or BITREFILL_API_ID + BITREFILL_API_SECRET (Business) are set. Without those env vars the tools aren't registered — tell the user and stop."
|
|
5
7
|
metadata:
|
|
6
8
|
author: bitrefill
|
|
7
|
-
version: "
|
|
9
|
+
version: "3.0.0"
|
|
8
10
|
homepage: "https://www.bitrefill.com"
|
|
9
11
|
docs: "https://docs.bitrefill.com"
|
|
10
12
|
repository: "https://github.com/bitrefill/cli"
|
|
@@ -12,55 +14,153 @@ metadata:
|
|
|
12
14
|
|
|
13
15
|
# Bitrefill
|
|
14
16
|
|
|
15
|
-
Bitrefill sells digital goods (gift cards, mobile top-ups, eSIMs) across 180+
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
17
|
+
Bitrefill sells digital goods (gift cards, mobile top-ups, eSIMs) across 180+
|
|
18
|
+
countries. Codes deliver instantly after the invoice settles.
|
|
19
|
+
|
|
20
|
+
This skill is **action-shaped**: when the host has the `bitrefill_*` tools
|
|
21
|
+
wired, you transact through them directly. Don't navigate browser / MCP / CLI
|
|
22
|
+
fallbacks unless the tools are absent.
|
|
23
|
+
|
|
24
|
+
## Critical rules (read first)
|
|
25
|
+
|
|
26
|
+
1. **Never invent product or package ids.** Every `product_id` and
|
|
27
|
+
`package_id` MUST come from a `bitrefill_search` + `bitrefill_get_product`
|
|
28
|
+
result in the current turn.
|
|
29
|
+
2. **Confirm before spending.** `bitrefill_create_invoice` is the spend — it
|
|
30
|
+
is automatically confirmation-gated by the host. Before calling it, show
|
|
31
|
+
the user product, denomination, total price, and payment method in plain
|
|
32
|
+
English, then call the tool. The host will fire one confirmation; on
|
|
33
|
+
approve, the invoice is created.
|
|
34
|
+
3. **Codes are cash.** When you read `redemption_info.code` from
|
|
35
|
+
`bitrefill_get_order`, return it once, advise the user to store it
|
|
36
|
+
securely, and **never** repeat it in summaries or future turns.
|
|
37
|
+
4. **No tools wired = no purchase.** If `bitrefill_search` isn't available
|
|
38
|
+
in this session (no API key configured), say so directly: *"Bitrefill
|
|
39
|
+
purchases need a `BITREFILL_API_KEY` env var. Set one and restart, or
|
|
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. |
|
|
63
162
|
|
|
64
163
|
## Source of truth
|
|
65
164
|
|
|
66
|
-
Skill
|
|
165
|
+
Skill describes the contract + playbook. For exhaustive enums (countries,
|
|
166
|
+
payment methods, full endpoint list), see <https://docs.bitrefill.com>.
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
---
|
|
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
|
|
6
|
+
metadata:
|
|
7
|
+
author: kaleidoswap
|
|
8
|
+
version: "1.0.0"
|
|
9
|
+
venue: flashnet
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Flashnet swaps
|
|
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.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: kaleido-lsps
|
|
3
3
|
description: "Buy inbound Lightning channel capacity from a Lightning Service Provider (LSPS1). Quote a channel, estimate fees, place a channel order, and check order status. Triggers when the user wants inbound liquidity, says they can't receive a payment, needs a channel, asks about LSP fees, or wants to check the status of a channel order / LSP order."
|
|
4
|
-
tools:
|
|
5
|
-
triggers: inbound, liquidity, channel order, lsp, lsps1, receive limit, can't receive, open channel, channel from, check status, order status, check the order, channel status, lsp status, check my channel
|
|
4
|
+
tools: lsp_get_info, lsp_get_network_info, lsp_estimate_fees, lsp_create_order, lsp_get_order, 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, rln_get_node_info, rln_list_channels, rln_pay_invoice
|
|
5
|
+
triggers: inbound, liquidity, channel order, lsp, lsps1, receive limit, can't receive, open channel, channel from, check status, order status, check the order, channel status, lsp status, check my channel, check lsp order, did the channel open, lsp order status, list my channels, my channels, channel capacity
|
|
6
6
|
metadata:
|
|
7
7
|
author: kaleidoswap
|
|
8
8
|
version: "0.2.0"
|
|
@@ -82,11 +82,26 @@ Returns:
|
|
|
82
82
|
Hand the `payment.bolt11.invoice` to `rln_pay_invoice`. This is a separate
|
|
83
83
|
spend gate at the wallet contract; the user confirms paying the LSP.
|
|
84
84
|
|
|
85
|
-
###
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
### Verify the opened channel — `rln_list_channels`
|
|
86
|
+
After an order completes (or when the user asks "do I have a channel with X
|
|
87
|
+
inbound?", "list my channels", "did my channel open?"), call
|
|
88
|
+
`rln_list_channels`. It returns each channel's `capacity_sat`, `inbound_sat`,
|
|
89
|
+
`outbound_sat`, `ready`/`status`, and RGB `asset_*` amounts. Match the
|
|
90
|
+
requested capacity against an actual channel to confirm it opened correctly.
|
|
91
|
+
A freshly-bought channel opens ASYNCHRONOUSLY — if it isn't listed yet, say
|
|
92
|
+
it's still opening, don't claim failure. Do NOT use `rln_get_node_info` for
|
|
93
|
+
this (it only has counts + aggregate balance, not per-channel capacity).
|
|
94
|
+
|
|
95
|
+
### Step 6 — poll the order (`lsp_get_order` / `kaleidoswap_lsp_get_order`)
|
|
96
|
+
Use `lsp_get_order` on CLI hosts, `kaleidoswap_lsp_get_order` on desktop —
|
|
97
|
+
whichever your host exposes. **Args: `order_id`, `access_token` (BOTH
|
|
98
|
+
required — never omit either).** `order_state` progresses
|
|
99
|
+
`CREATED → CHANNEL_OPENING → COMPLETED` (or `FAILED`). Poll until terminal.
|
|
100
|
+
Always pass the exact order_id and access_token from the previous
|
|
101
|
+
create-order result **or from the most recent assistant message/summary**
|
|
102
|
+
(the one that said something like "order_id=xxx access_token=yyy" or "To
|
|
103
|
+
check status use: lsp_get_order(order_id=..., access_token=...)"). If
|
|
104
|
+
memory/remember is available, first recall the last LSPS1 order details.
|
|
90
105
|
Report the outcome plainly with the new channel id from `channel.channel_id` if present.
|
|
91
106
|
|
|
92
107
|
## Don'ts
|
|
@@ -101,7 +116,9 @@ Report the outcome plainly with the new channel id from `channel.channel_id` if
|
|
|
101
116
|
`order_id` and `access_token` and seeing `order_state: COMPLETED`.
|
|
102
117
|
- Never call `kaleidoswap_lsp_get_order` with only the access_token or only the order_id.
|
|
103
118
|
Always extract the exact values from the previous turn's summary (the one that
|
|
104
|
-
said "order_id=... access_token=..."
|
|
119
|
+
said "order_id=... access_token=..." or the explicit "To check status use..." line)
|
|
120
|
+
and pass them as separate arguments. If using the `remember` tool, first recall
|
|
121
|
+
the last channel/LSPS1 order details.
|
|
105
122
|
- Don't ask the user for their node pubkey — fetch it from `rln_get_node_info`.
|
|
106
123
|
|
|
107
124
|
## When the deterministic recipe handles it
|
|
@@ -1,8 +1,8 @@
|
|
|
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, place a market order, or
|
|
3
|
+
description: "Trade on KaleidoSwap — quote and execute swaps between BTC and RGB assets (USDT, XAUT). Get assets and pairs, pull an executable quote, place a market order, track orders, 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 an order / swap / atomic swap."
|
|
4
4
|
tools: kaleidoswap_get_assets, kaleidoswap_get_pairs, kaleidoswap_get_quote, kaleidoswap_place_order, kaleidoswap_get_order_status, kaleidoswap_atomic_init, kaleidoswap_atomic_execute, kaleidoswap_atomic_status, rln_get_node_info, rln_atomic_taker
|
|
5
|
-
triggers: quote, swap, trade, rebalance, slippage, pair, pairs, usdt, xaut, kaleidoswap, rfq
|
|
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
|
|
6
6
|
metadata:
|
|
7
7
|
author: kaleidoswap
|
|
8
8
|
version: "0.4.0"
|
|
@@ -40,15 +40,28 @@ which pair + amount.
|
|
|
40
40
|
|
|
41
41
|
## Asset codes (canonical)
|
|
42
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
|
+
|
|
43
48
|
Only these codes are accepted:
|
|
44
49
|
|
|
45
50
|
- `BTC` (Bitcoin, amounts always in satoshis)
|
|
46
|
-
- `USDT` (Tether) — **not** `USD`, **not** `tether`
|
|
47
|
-
- `XAUT` (Tether Gold) — **not** `XAU`, **not** `gold`
|
|
51
|
+
- `USDT` (Tether, the RGB asset) — **not** `USD`, **not** `tether`
|
|
52
|
+
- `XAUT` (Tether Gold, the RGB asset) — **not** `XAU`, **not** `gold`
|
|
48
53
|
|
|
49
54
|
When the user types `USD` they almost always mean `USDT` — confirm before
|
|
50
55
|
quoting. Same for `gold` → `XAUT`. Don't silently substitute.
|
|
51
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
|
+
|
|
52
65
|
## Tools
|
|
53
66
|
|
|
54
67
|
### `kaleidoswap_get_pairs` — no args
|
|
@@ -113,13 +126,16 @@ Only after `kaleidoswap_get_quote` returned an `rfq_id` THIS turn, and only when
|
|
|
113
126
|
the user has explicitly approved the amount + direction. Pass the `rfq_id` as
|
|
114
127
|
`quote_id`.
|
|
115
128
|
|
|
116
|
-
**Save the `order_id` AND `access_token` from the result** —
|
|
117
|
-
for polling status later.
|
|
129
|
+
**Save the `order_id` AND `access_token` from the result** (BOTH required — never omit either). Extract them verbatim from the tool result (or the most recent assistant summary that listed "order_id=... access_token=..."). If memory/remember is available, first recall the last order details before polling status. You will need both for `kaleidoswap_get_order_status` later.
|
|
118
130
|
|
|
119
131
|
### `kaleidoswap_get_order_status(order_id, access_token)`
|
|
120
|
-
|
|
121
|
-
(
|
|
122
|
-
|
|
132
|
+
**Args: `order_id`, `access_token` (BOTH required — never omit either).**
|
|
133
|
+
Poll after placing an order (or atomic). `order_state` (or equivalent) progresses
|
|
134
|
+
to terminal states. Always pass the exact values from the previous
|
|
135
|
+
`kaleidoswap_place_order` result **or from the most recent assistant message/summary**
|
|
136
|
+
(the one that said something like "order_id=xxx access_token=yyy" or "To check status use: kaleidoswap_get_order_status(order_id=..., access_token=...)").
|
|
137
|
+
If memory/remember is available, first recall the last order/swap details.
|
|
138
|
+
Report the outcome plainly.
|
|
123
139
|
|
|
124
140
|
## Flow
|
|
125
141
|
|
|
@@ -128,11 +144,11 @@ completed, failed.
|
|
|
128
144
|
3. **Read + present** — compute the receive amount + fee from the response (see
|
|
129
145
|
"Reading the quote response"). **Never hide cost.**
|
|
130
146
|
4. **Place** — spend-gated by the engine. The host pauses for the user.
|
|
131
|
-
5. **Track** — poll `kaleidoswap_get_order_status(order_id, access_token)` (use both values saved from place_order) until it terminates.
|
|
147
|
+
5. **Track** — poll `kaleidoswap_get_order_status(order_id, access_token)` (use both values saved from place_order or the explicit "To check status..." template) until it terminates. For atomic swaps the status tool is `kaleidoswap_atomic_status(atomic_id)`.
|
|
132
148
|
|
|
133
149
|
## Don'ts
|
|
134
150
|
|
|
135
|
-
- Don't invent prices, quotes, rfq_ids, or
|
|
151
|
+
- Don't invent prices, quotes, rfq_ids, order_ids, or access_tokens.
|
|
136
152
|
- Don't reuse a number from a previous turn.
|
|
137
153
|
- Don't describe how a tool works — call it.
|
|
138
154
|
- Don't call `kaleidoswap_get_quote` with from/to only — ask for the amount.
|
|
@@ -142,7 +158,15 @@ completed, failed.
|
|
|
142
158
|
- Don't accept `XAU` as `XAUT` or `USD` as `USDT` silently — confirm.
|
|
143
159
|
- Don't retry the same failing tool call in a loop. If a call fails, read the
|
|
144
160
|
error and either ask the user, fix the args, or stop.
|
|
161
|
+
- Don't claim an order completed without polling the status tool with BOTH
|
|
162
|
+
required ids/tokens and seeing a terminal state.
|
|
163
|
+
- Never call `kaleidoswap_get_order_status` with only the access_token or only
|
|
164
|
+
the order_id. Always extract the exact values from the previous turn's summary
|
|
165
|
+
(the one that said "order_id=... access_token=..." or the explicit "To check
|
|
166
|
+
status use..." line) and pass them as separate arguments. If using the
|
|
167
|
+
`remember` tool, first recall the last order details.
|
|
145
168
|
|
|
146
169
|
For the full atomic-swap flow (init → whitelist on the RGB node → execute), a
|
|
147
170
|
deterministic recipe drives the chain — the agentic loop is not safe to plan a
|
|
148
|
-
multi-step, two-service swap on a small model.
|
|
171
|
+
multi-step, two-service swap on a small model. Status for atomics uses the
|
|
172
|
+
`atomic_id` (or payment_hash) surfaced in the recipe summary.
|