@kaleidorg/mind 0.2.0 → 0.3.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 (77) hide show
  1. package/dist/capabilities.d.ts +4 -0
  2. package/dist/capabilities.d.ts.map +1 -1
  3. package/dist/capabilities.js +7 -0
  4. package/dist/capabilities.js.map +1 -1
  5. package/dist/engine.d.ts +9 -0
  6. package/dist/engine.d.ts.map +1 -1
  7. package/dist/engine.js +1 -0
  8. package/dist/engine.js.map +1 -1
  9. package/dist/funnel.d.ts +6 -0
  10. package/dist/funnel.d.ts.map +1 -1
  11. package/dist/funnel.js +26 -6
  12. package/dist/funnel.js.map +1 -1
  13. package/dist/index.d.ts +9 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +8 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/kaleidoswap/contract.d.ts +72 -0
  18. package/dist/kaleidoswap/contract.d.ts.map +1 -0
  19. package/dist/kaleidoswap/contract.js +125 -0
  20. package/dist/kaleidoswap/contract.js.map +1 -0
  21. package/dist/knowledge/btc-map.d.ts +87 -0
  22. package/dist/knowledge/btc-map.d.ts.map +1 -0
  23. package/dist/knowledge/btc-map.js +365 -0
  24. package/dist/knowledge/btc-map.js.map +1 -0
  25. package/dist/lsps1/contract.d.ts +55 -0
  26. package/dist/lsps1/contract.d.ts.map +1 -0
  27. package/dist/lsps1/contract.js +91 -0
  28. package/dist/lsps1/contract.js.map +1 -0
  29. package/dist/memory/store.d.ts +7 -1
  30. package/dist/memory/store.d.ts.map +1 -1
  31. package/dist/memory/store.js +43 -3
  32. package/dist/memory/store.js.map +1 -1
  33. package/dist/memory/types.d.ts +12 -0
  34. package/dist/memory/types.d.ts.map +1 -1
  35. package/dist/recipe/kaleidoswap-atomic.d.ts +27 -0
  36. package/dist/recipe/kaleidoswap-atomic.d.ts.map +1 -0
  37. package/dist/recipe/kaleidoswap-atomic.js +111 -0
  38. package/dist/recipe/kaleidoswap-atomic.js.map +1 -0
  39. package/dist/recipe/runner.d.ts.map +1 -1
  40. package/dist/recipe/runner.js +13 -1
  41. package/dist/recipe/runner.js.map +1 -1
  42. package/dist/skills/registry.d.ts.map +1 -1
  43. package/dist/skills/registry.js +20 -2
  44. package/dist/skills/registry.js.map +1 -1
  45. package/dist/wallet/confirm.d.ts +12 -0
  46. package/dist/wallet/confirm.d.ts.map +1 -0
  47. package/dist/wallet/confirm.js +67 -0
  48. package/dist/wallet/confirm.js.map +1 -0
  49. package/package.json +2 -1
  50. package/skills/README.md +6 -1
  51. package/skills/kaleido-lsps/SKILL.md +56 -0
  52. package/skills/kaleido-trading/SKILL.md +85 -18
  53. package/skills/merchant-finder/SKILL.md +87 -0
  54. package/skills/paid-data/SKILL.md +12 -0
  55. package/skills/wallet-assistant/SKILL.md +38 -0
  56. package/src/capabilities.ts +12 -0
  57. package/src/context/context.test.ts +6 -2
  58. package/src/engine.ts +6 -0
  59. package/src/funnel.ts +32 -7
  60. package/src/index.ts +43 -0
  61. package/src/kaleidoswap/contract.test.ts +147 -0
  62. package/src/kaleidoswap/contract.ts +212 -0
  63. package/src/knowledge/btc-map.test.ts +188 -0
  64. package/src/knowledge/btc-map.ts +446 -0
  65. package/src/lsps1/contract.test.ts +81 -0
  66. package/src/lsps1/contract.ts +132 -0
  67. package/src/memory/memory.test.ts +55 -0
  68. package/src/memory/store.ts +49 -4
  69. package/src/memory/types.ts +13 -0
  70. package/src/recipe/kaleidoswap-atomic.test.ts +138 -0
  71. package/src/recipe/kaleidoswap-atomic.ts +117 -0
  72. package/src/recipe/runner.ts +13 -1
  73. package/src/skills/registry.ts +21 -2
  74. package/src/skills/skills.test.ts +42 -0
  75. package/src/wallet/confirm.test.ts +57 -0
  76. package/src/wallet/confirm.ts +74 -0
  77. package/skills/kaleido-wallet/SKILL.md +0 -28
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Confirm-sheet readback — a deterministic, voice-first summary of a spend that
3
+ * the host speaks before executing it ("Send 4,800 sats to bob over Spark.
4
+ * Confirm?"). Built from the resolved tool call, not the model: zero inference,
5
+ * identical on every surface, and impossible for the model to phrase around.
6
+ */
7
+
8
+ import { getWalletTool } from './contract.js';
9
+
10
+ const LAYER_LABEL: Record<string, string> = {
11
+ spark: 'Spark',
12
+ rln: 'RLN',
13
+ arkade: 'Arkade',
14
+ liquid: 'Liquid',
15
+ };
16
+
17
+ /** Group an integer with thousands separators, locale-independently (test-stable). */
18
+ function fmtNum(n: number): string {
19
+ if (!Number.isFinite(n)) return String(n);
20
+ const neg = n < 0;
21
+ const [int, frac] = Math.abs(n).toString().split('.');
22
+ const grouped = int!.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
23
+ return (neg ? '-' : '') + (frac ? `${grouped}.${frac}` : grouped);
24
+ }
25
+
26
+ /** Looks like an address/invoice/lnurl (vs a human contact name). */
27
+ function isRef(s: string): boolean {
28
+ return /^(ln(bc|tb|bcrt)|bc1|tb1|lq1|lnurl)/i.test(s) || (s.length > 20 && !/\s/.test(s));
29
+ }
30
+
31
+ /** Shorten an address/invoice for speech; leave contact names intact. */
32
+ function shortRef(s: string): string {
33
+ const v = s.trim();
34
+ return isRef(v) ? `${v.slice(0, 6)}…${v.slice(-4)}` : v;
35
+ }
36
+
37
+ /** " over Spark" suffix for the call's layer (explicit arg wins, else the tool's). */
38
+ function over(name: string, args: Record<string, unknown>): string {
39
+ const layer = typeof args.layer === 'string' ? args.layer : getWalletTool(name)?.layer;
40
+ const label = layer ? LAYER_LABEL[layer] : undefined;
41
+ return label ? ` over ${label}` : '';
42
+ }
43
+
44
+ const sats = (v: unknown) => `${fmtNum(Number(v))} sats`;
45
+ const asset = (amount: unknown, ticker: unknown) => `${fmtNum(Number(amount))} ${String(ticker)}`;
46
+
47
+ /** A spoken confirmation ending in "Confirm?", or null for non-spend tools. */
48
+ export function confirmReadback(call: { name: string; arguments: Record<string, unknown> }): string | null {
49
+ const { name, arguments: a } = call;
50
+ const to = (k = 'to') => shortRef(String(a[k] ?? ''));
51
+ const ask = (s: string) => `${s}. Confirm?`;
52
+
53
+ switch (name) {
54
+ case 'send_payment': {
55
+ const amt = a.amount_sats != null ? sats(a.amount_sats)
56
+ : a.asset != null && a.amount != null ? asset(a.amount, a.asset)
57
+ : undefined;
58
+ return ask(amt ? `Send ${amt} to ${to()}${over(name, a)}` : `Send a payment to ${to()}${over(name, a)}`);
59
+ }
60
+ case 'spark_send':
61
+ case 'arkade_send':
62
+ return ask(`Send ${sats(a.amount_sats)} to ${to()}${over(name, a)}`);
63
+ case 'rln_send_asset':
64
+ case 'liquid_send':
65
+ return ask(`Send ${asset(a.amount, a.asset)} to ${to()}${over(name, a)}`);
66
+ case 'rln_pay_invoice':
67
+ return ask(`Pay Lightning invoice ${shortRef(String(a.invoice ?? ''))}${over(name, a)}`);
68
+ case 'execute_swap':
69
+ return ask(`Swap ${fmtNum(Number(a.amount))} ${String(a.from_asset)} for ${String(a.to_asset)}`);
70
+ default:
71
+ // Unknown but spend-flagged tool → a generic, still-honest readback.
72
+ return getWalletTool(name)?.spend ? ask(`Confirm ${name.replace(/_/g, ' ')}`) : null;
73
+ }
74
+ }
@@ -1,28 +0,0 @@
1
- ---
2
- name: kaleido-wallet
3
- description: "Manage a KaleidoSwap Lightning + RGB wallet: check BTC and asset balances, get a receive address, create or pay Lightning invoices, send on-chain BTC, open or list channels. Triggers when the user asks about their balance, wants to receive or send funds, pay an invoice, or manage Lightning channels."
4
- tools: wdk_get_balances, wdk_get_asset_balance, wdk_get_address, wdk_create_ln_invoice, wdk_pay_invoice, wdk_send_btc, wdk_list_channels, wdk_open_channel, wdk_get_node_info
5
- triggers: balance, receive, address, send, pay, invoice, channel, deposit, withdraw, funds
6
- metadata:
7
- author: kaleidoswap
8
- version: "0.1.0"
9
- surface: "kaleido-mcp (WDK node)"
10
- ---
11
-
12
- # KaleidoSwap wallet
13
-
14
- Operate the user's KaleidoSwap node (Lightning + RGB assets) through the
15
- `wdk_*` MCP tools.
16
-
17
- ## Rules
18
-
19
- - **Read before you write.** Check the balance (`wdk_get_balances`) before any
20
- send or channel open, and confirm the node is healthy (`wdk_get_node_info`).
21
- - **Confirm every spend.** State the amount, destination, and resulting balance,
22
- then wait for explicit approval before calling `wdk_send_btc`,
23
- `wdk_pay_invoice`, or `wdk_open_channel`.
24
- - **Match the rail to the asset.** Lightning for fast BTC/asset payments,
25
- on-chain for settlement or channel funding. Use `wdk_get_asset_balance` for
26
- RGB assets (USDT, XAUT, …).
27
- - Never reveal seeds or private keys — this skill operates a node, it is not a
28
- key vault.