@kaleidorg/mind 0.4.0 → 0.5.1

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 (89) hide show
  1. package/dist/funnel.d.ts +19 -0
  2. package/dist/funnel.d.ts.map +1 -1
  3. package/dist/funnel.js +48 -10
  4. package/dist/funnel.js.map +1 -1
  5. package/dist/index.d.ts +5 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +10 -3
  8. package/dist/index.js.map +1 -1
  9. package/dist/kaleidoswap/contract.d.ts +3 -3
  10. package/dist/kaleidoswap/contract.d.ts.map +1 -1
  11. package/dist/kaleidoswap/contract.js +16 -4
  12. package/dist/kaleidoswap/contract.js.map +1 -1
  13. package/dist/knowledge/bitcoin-copilot.d.ts.map +1 -1
  14. package/dist/knowledge/bitcoin-copilot.js +102 -0
  15. package/dist/knowledge/bitcoin-copilot.js.map +1 -1
  16. package/dist/knowledge/btc-map.d.ts +14 -17
  17. package/dist/knowledge/btc-map.d.ts.map +1 -1
  18. package/dist/knowledge/btc-map.js +66 -266
  19. package/dist/knowledge/btc-map.js.map +1 -1
  20. package/dist/lsps1/contract.d.ts.map +1 -1
  21. package/dist/lsps1/contract.js +28 -10
  22. package/dist/lsps1/contract.js.map +1 -1
  23. package/dist/qvac/parse.d.ts +15 -0
  24. package/dist/qvac/parse.d.ts.map +1 -1
  25. package/dist/qvac/parse.js +68 -5
  26. package/dist/qvac/parse.js.map +1 -1
  27. package/dist/qvac/text.d.ts.map +1 -1
  28. package/dist/qvac/text.js +4 -0
  29. package/dist/qvac/text.js.map +1 -1
  30. package/dist/recipe/buy-asset-channel.d.ts +26 -0
  31. package/dist/recipe/buy-asset-channel.d.ts.map +1 -0
  32. package/dist/recipe/buy-asset-channel.js +112 -0
  33. package/dist/recipe/buy-asset-channel.js.map +1 -0
  34. package/dist/recipe/kaleidoswap-atomic.d.ts +26 -18
  35. package/dist/recipe/kaleidoswap-atomic.d.ts.map +1 -1
  36. package/dist/recipe/kaleidoswap-atomic.js +101 -63
  37. package/dist/recipe/kaleidoswap-atomic.js.map +1 -1
  38. package/dist/recipe/kaleidoswap-channel-order.d.ts +35 -0
  39. package/dist/recipe/kaleidoswap-channel-order.d.ts.map +1 -0
  40. package/dist/recipe/kaleidoswap-channel-order.js +493 -0
  41. package/dist/recipe/kaleidoswap-channel-order.js.map +1 -0
  42. package/dist/recipe/kaleidoswap-price.d.ts +21 -0
  43. package/dist/recipe/kaleidoswap-price.d.ts.map +1 -0
  44. package/dist/recipe/kaleidoswap-price.js +57 -0
  45. package/dist/recipe/kaleidoswap-price.js.map +1 -0
  46. package/dist/recipe/runner.d.ts +7 -1
  47. package/dist/recipe/runner.d.ts.map +1 -1
  48. package/dist/recipe/runner.js +115 -29
  49. package/dist/recipe/runner.js.map +1 -1
  50. package/dist/recipe/swap.d.ts +26 -1
  51. package/dist/recipe/swap.d.ts.map +1 -1
  52. package/dist/recipe/swap.js +108 -13
  53. package/dist/recipe/swap.js.map +1 -1
  54. package/dist/recipe/types.d.ts +25 -1
  55. package/dist/recipe/types.d.ts.map +1 -1
  56. package/dist/skills/registry.d.ts +33 -1
  57. package/dist/skills/registry.d.ts.map +1 -1
  58. package/dist/skills/registry.js +45 -1
  59. package/dist/skills/registry.js.map +1 -1
  60. package/package.json +1 -1
  61. package/skills/README.md +3 -0
  62. package/skills/kaleido-lsps/SKILL.md +101 -43
  63. package/skills/kaleido-trading/SKILL.md +81 -31
  64. package/skills/merchant-finder/SKILL.md +96 -66
  65. package/skills/rgb-lightning-node/SKILL.md +108 -0
  66. package/skills/wallet-assistant/SKILL.md +32 -21
  67. package/src/funnel.ts +66 -11
  68. package/src/index.ts +14 -2
  69. package/src/kaleidoswap/contract.test.ts +7 -2
  70. package/src/kaleidoswap/contract.ts +27 -5
  71. package/src/knowledge/bitcoin-copilot.ts +111 -0
  72. package/src/knowledge/btc-map.test.ts +53 -96
  73. package/src/knowledge/btc-map.ts +72 -287
  74. package/src/lsps1/contract.ts +32 -14
  75. package/src/qvac/parse.test.ts +70 -1
  76. package/src/qvac/parse.ts +71 -5
  77. package/src/qvac/text.ts +4 -0
  78. package/src/recipe/buy-asset-channel.test.ts +148 -0
  79. package/src/recipe/buy-asset-channel.ts +118 -0
  80. package/src/recipe/kaleidoswap-atomic.test.ts +134 -61
  81. package/src/recipe/kaleidoswap-atomic.ts +112 -66
  82. package/src/recipe/kaleidoswap-channel-order.test.ts +333 -0
  83. package/src/recipe/kaleidoswap-channel-order.ts +548 -0
  84. package/src/recipe/kaleidoswap-price.ts +68 -0
  85. package/src/recipe/recipe.test.ts +61 -5
  86. package/src/recipe/runner.ts +128 -31
  87. package/src/recipe/swap.ts +109 -13
  88. package/src/recipe/types.ts +25 -1
  89. package/src/skills/registry.ts +52 -1
@@ -1 +1 @@
1
- {"version":3,"file":"btc-map.d.ts","sourceRoot":"","sources":["../../src/knowledge/btc-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAK/C,iDAAiD;AACjD,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qFAAqF;IACrF,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uEAAuE;IACvE,UAAU,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACrC,wEAAwE;IACxE,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACnD;AAED,mDAAmD;AACnD,MAAM,WAAW,cAAe,SAAQ,QAAQ;IAC9C,+CAA+C;IAC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find_merchant_locations` and
3
- * `get_merchant_info` so the agent can answer "where can I spend Bitcoin
4
- * near me?" using the SAME tool names on every surface.
2
+ * BTC Map tool source — exposes `find_merchant_locations` so the agent can
3
+ * answer "where can I spend Bitcoin near me?" using the SAME tool name on
4
+ * every surface.
5
5
  *
6
6
  * - mobile → injects device GPS + a live BTC Map fetch
7
7
  * - desktop → injects a live fetch (or a server-side cache)
8
- * - eval / playground → no injection, falls back to the bundled offline list
9
8
  *
10
9
  * Pure data + orchestration — NO network in core. The host injects the
11
- * `location` resolver and the `fetch` adapter; without them the source still
12
- * runs against an offline `Merchant[]` so the skill is never dead on arrival.
10
+ * `location` resolver and the `fetch` adapter. Without them the tool returns
11
+ * a clear error: there is NO offline / sample fallback (intentional fake
12
+ * data is worse than a clean failure that tells the user what's wrong).
13
13
  *
14
14
  * The result shape mirrors what rate's host returns today, so a mobile host
15
15
  * can swap its bespoke merchant tools for this factory verbatim.
16
16
  */
17
17
  const FIND = 'find_merchant_locations';
18
- const INFO = 'get_merchant_info';
19
- /** A tiny, hand-curated sample so the skill works offline out of the box. */
20
- export const BTC_MAP_SAMPLE = [
21
- {
22
- id: 'lugano-bitcoinpeople-cafe',
23
- name: 'Bitcoin People Café',
24
- category: 'cafe',
25
- address: 'Via Pessina 12',
26
- city: 'Lugano',
27
- lat: 46.0037,
28
- lng: 8.9511,
29
- acceptedAssets: ['lightning', 'onchain'],
30
- description: 'Specialty espresso bar; Plan ₿ Lugano partner.',
31
- },
32
- {
33
- id: 'lugano-bistro-libertine',
34
- name: 'Bistro Libertine',
35
- category: 'restaurant',
36
- address: 'Piazza della Riforma 3',
37
- city: 'Lugano',
38
- lat: 46.004,
39
- lng: 8.952,
40
- acceptedAssets: ['lightning', 'usdt', 'onchain'],
41
- description: 'Italian-Swiss bistro, lunch + dinner. Accepts Tether on Liquid.',
42
- },
43
- {
44
- id: 'lugano-bookshop-volta',
45
- name: 'Libreria Volta',
46
- category: 'shop',
47
- address: 'Via Cattedrale 8',
48
- city: 'Lugano',
49
- lat: 46.0055,
50
- lng: 8.9499,
51
- acceptedAssets: ['lightning'],
52
- description: 'Independent bookshop; Italian, English and German titles.',
53
- },
54
- {
55
- id: 'lisbon-meson-andaluz',
56
- name: 'Mesón Andaluz',
57
- category: 'restaurant',
58
- address: 'Rua das Flores 42',
59
- city: 'Lisbon',
60
- lat: 38.71,
61
- lng: -9.143,
62
- acceptedAssets: ['lightning', 'onchain'],
63
- description: 'Andalusian tapas in Chiado. Bitcoin accepted since 2022.',
64
- },
65
- {
66
- id: 'lisbon-surf-bitcoin',
67
- name: 'Surf & Sats',
68
- category: 'shop',
69
- address: 'Av. da Liberdade 180',
70
- city: 'Lisbon',
71
- lat: 38.7211,
72
- lng: -9.1466,
73
- acceptedAssets: ['lightning'],
74
- description: 'Surfboard rental and lessons in Costa da Caparica.',
75
- },
76
- {
77
- id: 'sansalvador-elzonte-hope',
78
- name: 'Hope House El Zonte',
79
- category: 'cafe',
80
- address: 'Calle Principal',
81
- city: 'El Zonte',
82
- lat: 13.492,
83
- lng: -89.4395,
84
- acceptedAssets: ['lightning', 'onchain'],
85
- description: 'Bitcoin Beach hub. Coffee, community, and a Lightning ATM.',
86
- },
87
- {
88
- id: 'sansalvador-elzonte-garten',
89
- name: 'Garten Restaurante',
90
- category: 'restaurant',
91
- address: 'Bitcoin Beach',
92
- city: 'El Zonte',
93
- lat: 13.4925,
94
- lng: -89.438,
95
- acceptedAssets: ['lightning'],
96
- description: 'Beachfront restaurant, full Bitcoin payments since 2021.',
97
- },
98
- {
99
- id: 'nyc-pubkey',
100
- name: 'PubKey',
101
- category: 'bar',
102
- address: '85 Washington Pl',
103
- city: 'New York',
104
- lat: 40.732,
105
- lng: -73.999,
106
- acceptedAssets: ['lightning', 'onchain'],
107
- description: 'Bitcoin bar in Greenwich Village — meetups, Lightning tap.',
108
- },
109
- {
110
- id: 'prague-paralelni-polis',
111
- name: 'Paralelní Polis',
112
- category: 'cafe',
113
- address: 'Dělnická 43',
114
- city: 'Prague',
115
- lat: 50.105,
116
- lng: 14.448,
117
- acceptedAssets: ['lightning', 'onchain', 'monero'],
118
- description: 'Crypto-only café and hackerspace — no fiat accepted, ever.',
119
- },
120
- {
121
- id: 'amsterdam-bitcoin-embassy',
122
- name: 'Bitcoin Embassy Amsterdam',
123
- category: 'cafe',
124
- address: 'Nieuwezijds Voorburgwal 162',
125
- city: 'Amsterdam',
126
- lat: 52.374,
127
- lng: 4.893,
128
- acceptedAssets: ['lightning', 'onchain'],
129
- description: 'Co-working café and meetup hub, Lightning tap on draft beer.',
130
- },
131
- ];
132
18
  /** Clamp a value to a numeric range, returning the default when input is bad. */
133
19
  function clamp(n, lo, hi, dflt) {
134
20
  const v = Number(n);
@@ -136,24 +22,6 @@ function clamp(n, lo, hi, dflt) {
136
22
  return dflt;
137
23
  return Math.min(hi, Math.max(lo, v));
138
24
  }
139
- /** Substring scoring used by the offline fallback (matches the old behavior). */
140
- function fuzzyScore(query, text) {
141
- const q = query.toLowerCase();
142
- const t = text.toLowerCase();
143
- if (!q)
144
- return 1;
145
- if (t.includes(q))
146
- return 1;
147
- let hits = 0;
148
- let qi = 0;
149
- for (let i = 0; i < t.length && qi < q.length; i++) {
150
- if (t[i] === q[qi]) {
151
- hits++;
152
- qi++;
153
- }
154
- }
155
- return hits / q.length;
156
- }
157
25
  /** Map a Merchant → the response row the model sees (stable for rate parity). */
158
26
  function row(m) {
159
27
  return {
@@ -171,90 +39,42 @@ function row(m) {
171
39
  accepts_lightning: m.acceptedAssets?.includes('lightning') ?? true,
172
40
  };
173
41
  }
174
- /** Offline search: substring + optional category over the bundled list. */
175
- function searchOffline(merchants, query, category, limit) {
176
- let filtered = merchants;
177
- if (category) {
178
- const c = category.toLowerCase().trim();
179
- filtered = filtered.filter((m) => (m.category ?? '').toLowerCase() === c);
180
- }
181
- const q = (query ?? '').trim();
182
- if (q.length >= 2) {
183
- filtered = filtered
184
- .map((m) => {
185
- const hay = `${m.name ?? ''} ${m.description ?? ''} ${m.address ?? ''} ${m.city ?? ''}`;
186
- const score = fuzzyScore(q, m.name ?? '') * 3 +
187
- fuzzyScore(q, m.address ?? '') * 2 +
188
- fuzzyScore(q, hay) * 1;
189
- return { m, score };
190
- })
191
- .filter((x) => x.score > 0.3)
192
- .sort((a, b) => b.score - a.score)
193
- .map((x) => x.m);
194
- }
195
- return filtered.slice(0, limit);
196
- }
197
42
  /**
198
- * Build a ToolSource exposing `find_merchant_locations` + `get_merchant_info`.
43
+ * Build a ToolSource exposing `find_merchant_locations`.
199
44
  *
200
- * Resolution order for `find_merchant_locations`:
45
+ * Resolution order:
201
46
  * 1. `near_address` provided → opts.location.geocode → opts.fetch (live)
202
47
  * 2. opts.location.getCurrent → opts.fetch (live)
203
- * 3. fall through to offline substring search over opts.offlineMerchants
204
48
  *
205
- * Any step that fails silently falls through to the next, so the skill is
206
- * always answerable.
49
+ * Any step that fails returns `{success:false, error}` with a message that
50
+ * tells the user (and the model) what's actually wrong — no fake-data
51
+ * fallback. Either we have a real merchant list or we say we don't.
207
52
  */
208
53
  export function createBtcMapToolSource(opts = {}) {
209
- const offline = opts.offlineMerchants ?? BTC_MAP_SAMPLE;
210
54
  const defaultLimit = opts.k ?? 10;
211
55
  const find = {
212
56
  name: FIND,
213
57
  description: "Find Bitcoin-accepting merchants near the user using live BTC Map data " +
214
58
  "and the device's real location when available. Use when the user wants " +
215
59
  'merchants, shops, restaurants, cafes, bars, ATMs, or places to spend ' +
216
- 'Bitcoin nearby. Pass ONLY the fields the user actually named do not ' +
217
- 'invent constraints (e.g. omit `query` when they just say "near me").',
218
- parameters: {
219
- type: 'object',
220
- properties: {
221
- query: { type: 'string', description: 'Optional filter for merchant name or type, e.g. "coffee"' },
222
- category: { type: 'string', description: 'restaurant | cafe | bar | shop | grocery | lodging | atm' },
223
- near_address: { type: 'string', description: 'Address/city to search around instead of the current location' },
224
- radius_km: { type: 'number', description: 'Search radius in km (0.25–50, default 5)' },
225
- limit: { type: 'number', description: 'Max number of results (1–20, default 10)' },
226
- },
227
- },
228
- };
229
- const info = {
230
- name: INFO,
231
- description: 'Get detailed information about one specific merchant by id or name — ' +
232
- 'full address, accepted assets, contact details. Use after ' +
233
- 'find_merchant_locations when the user asks for more on a specific result.',
60
+ 'Bitcoin nearby. Map the request to the smallest useful set of arguments. ' +
61
+ 'For generic "where can I spend sats / bitcoin merchants in X" use only ' +
62
+ 'near_address (or nothing). Never put "sats", "btc", "bitcoin" or spend verbs ' +
63
+ 'into query or category — this source is already Bitcoin-only. When uncertain ' +
64
+ 'or the request is generic, prefer fewer fields rather than guessing. ' +
65
+ 'The returned merchants (or a clean error) are the only factual source ' +
66
+ 'never invent places.',
234
67
  parameters: {
235
68
  type: 'object',
236
69
  properties: {
237
- merchant_id: { type: 'string', description: 'Merchant id from find_merchant_locations (string or number)' },
238
- merchant_name: { type: 'string', description: 'Merchant name (used when id is unknown)' },
70
+ query: { type: 'string', description: 'OPTIONAL a name, food type, or descriptive term implied by the user (e.g. "coffee", "pizza", "food", "atm", "shop"). Good for vague or natural phrasing. **OMIT** for generic "spend sats", "where can I spend", "merchants", or "places to spend btc". **NEVER** include "sats", "btc", "bitcoin", "spend", or currency terms — the source is already Bitcoin-only and this over-filters to zero results.' },
71
+ category: { type: 'string', description: 'OPTIONAL set only when the request cleanly matches one specific allowed venue type: restaurant, cafe, bar, shop, grocery, lodging, atm. Leave empty for generic or mixed "spend sats / where to spend bitcoin" requests. Never guess a category (e.g. "shop") for a generic spend query. Never use generic nouns like merchant/place/store as the category value.' },
72
+ near_address: { type: 'string', description: 'City or address to search around when the user names a location instead of (or with) "near me". e.g. "Lugano", "Lisbon", "the center". The host will attempt to geocode it.' },
73
+ radius_km: { type: 'number', description: 'OPTIONAL — search radius in km (0.25–50). OMIT entirely unless the user explicitly named a distance ("within 2 km"). The default (5) is already applied server-side.' },
74
+ limit: { type: 'number', description: 'OPTIONAL — max results (1–20, default 10). Omit unless the user named a count.' },
239
75
  },
240
76
  },
241
77
  };
242
- async function tryLive(center, radiusMeters, query, category, limit) {
243
- if (!opts.fetch)
244
- return null;
245
- try {
246
- return await opts.fetch({
247
- center: { lat: center.lat, lng: center.lng },
248
- radiusMeters,
249
- query,
250
- category,
251
- limit,
252
- });
253
- }
254
- catch {
255
- return null;
256
- }
257
- }
258
78
  async function resolveCenter(near_address) {
259
79
  if (!opts.location)
260
80
  return null;
@@ -265,7 +85,7 @@ export function createBtcMapToolSource(opts = {}) {
265
85
  return { ...pt, label: near_address, precise: false };
266
86
  }
267
87
  catch {
268
- /* fall through */
88
+ /* geocode failed — fall through to getCurrent */
269
89
  }
270
90
  }
271
91
  try {
@@ -282,83 +102,63 @@ export function createBtcMapToolSource(opts = {}) {
282
102
  const radius_km = clamp(args.radius_km, 0.25, 50, 5);
283
103
  const limit = clamp(args.limit, 1, 20, defaultLimit);
284
104
  const radiusMeters = radius_km * 1000;
285
- // 1 + 2. Try the live path when we can.
286
- const center = await resolveCenter(near_address);
287
- if (center) {
288
- const live = await tryLive(center, radiusMeters, query, category, limit);
289
- if (live) {
290
- const where = center.label || (center.precise ? 'your location' : 'the default location');
291
- return {
292
- success: true,
293
- source: 'btcmap',
294
- precise_location: !!center.precise,
295
- center: { lat: center.lat, lng: center.lng },
296
- merchants: live.map(row),
297
- total_found: live.length,
298
- message: live.length > 0
299
- ? `Found ${live.length} Bitcoin merchant${live.length === 1 ? '' : 's'} near ${where}${query ? ` matching "${query}"` : ''}.`
300
- : `No Bitcoin merchants found within ${radius_km} km of ${where}. Try widening the radius.`,
301
- };
302
- }
105
+ // Live path requires BOTH a location resolver and a fetch adapter — they
106
+ // are host-injected. Without either, the tool can't produce real merchant
107
+ // data, and we refuse to invent.
108
+ if (!opts.fetch) {
109
+ return {
110
+ success: false,
111
+ error: 'Merchant search is unavailable: the host has not injected a BTC Map fetch adapter. ' +
112
+ 'No offline / sample data is used — connect a fetcher or try again later.',
113
+ };
303
114
  }
304
- // 3. Offline fallback.
305
- const found = searchOffline(offline, query, category, limit);
306
- return {
307
- success: true,
308
- source: 'offline',
309
- precise_location: false,
310
- merchants: found.map(row),
311
- total_found: found.length,
312
- message: found.length > 0
313
- ? `Showing ${found.length} merchant${found.length === 1 ? '' : 's'} from the offline list${query ? ` matching "${query}"` : ''}.`
314
- : `No merchants in the offline list matched${query ? ` "${query}"` : ''}. The host hasn't injected a live BTC Map fetch.`,
315
- };
316
- }
317
- async function getInfo(args) {
318
- const idArg = args.merchant_id;
319
- const nameArg = args.merchant_name ? String(args.merchant_name).trim() : '';
320
- let m;
321
- if (idArg !== undefined && idArg !== null && idArg !== '') {
322
- const want = String(idArg);
323
- m = offline.find((x) => String(x.id) === want);
115
+ const center = await resolveCenter(near_address);
116
+ if (!center) {
117
+ return {
118
+ success: false,
119
+ error: near_address
120
+ ? `Could not locate "${near_address}". Check the spelling or try a nearby city.`
121
+ : 'Could not determine your location. Pass `near_address` (a city or address) to search a specific area.',
122
+ };
324
123
  }
325
- if (!m && nameArg.length >= 2) {
326
- const q = nameArg.toLowerCase();
327
- m =
328
- offline.find((x) => (x.name ?? '').toLowerCase() === q) ??
329
- offline
330
- .map((x) => ({ x, score: fuzzyScore(q, (x.name ?? '').toLowerCase()) }))
331
- .filter((r) => r.score > 0.5)
332
- .sort((a, b) => b.score - a.score)[0]?.x;
124
+ let merchants;
125
+ try {
126
+ merchants = await opts.fetch({
127
+ center: { lat: center.lat, lng: center.lng },
128
+ radiusMeters,
129
+ query,
130
+ category,
131
+ limit,
132
+ });
333
133
  }
334
- if (!m) {
335
- const suggestions = nameArg
336
- ? offline
337
- .map((x) => ({ name: x.name ?? '', score: fuzzyScore(nameArg.toLowerCase(), (x.name ?? '').toLowerCase()) }))
338
- .filter((r) => r.score > 0.3)
339
- .sort((a, b) => b.score - a.score)
340
- .slice(0, 3)
341
- .map((r) => r.name)
342
- : [];
134
+ catch (e) {
343
135
  return {
344
136
  success: false,
345
- error: `Could not find merchant${nameArg ? ` "${nameArg}"` : idArg !== undefined ? ` with id ${idArg}` : ''}.`,
346
- suggestions: suggestions.length ? suggestions : undefined,
137
+ error: `BTC Map fetch failed: ${e?.message ?? String(e)}.`,
347
138
  };
348
139
  }
349
- return { success: true, merchant: { ...row(m), city: m.city } };
140
+ const where = center.label || (center.precise ? 'your location' : 'the requested area');
141
+ return {
142
+ success: true,
143
+ source: 'btcmap',
144
+ precise_location: !!center.precise,
145
+ center: { lat: center.lat, lng: center.lng },
146
+ merchants: merchants.map(row),
147
+ total_found: merchants.length,
148
+ message: merchants.length > 0
149
+ ? `Found ${merchants.length} Bitcoin merchant${merchants.length === 1 ? '' : 's'} near ${where}${query ? ` matching "${query}"` : ''}.`
150
+ : `No Bitcoin merchants found within ${radius_km} km of ${where}. Try widening the radius.`,
151
+ };
350
152
  }
351
153
  async function execute(name, args) {
352
154
  if (name === FIND)
353
155
  return findLocations(args);
354
- if (name === INFO)
355
- return getInfo(args);
356
156
  throw new Error(`btc-map: unknown tool "${name}"`);
357
157
  }
358
158
  return {
359
159
  id: 'btc-map',
360
- listTools: () => [find, info],
361
- has: (name) => name === FIND || name === INFO,
160
+ listTools: () => [find],
161
+ has: (name) => name === FIND,
362
162
  execute,
363
163
  };
364
164
  }
@@ -1 +1 @@
1
- {"version":3,"file":"btc-map.js","sourceRoot":"","sources":["../../src/knowledge/btc-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,MAAM,IAAI,GAAG,yBAAyB,CAAC;AACvC,MAAM,IAAI,GAAG,mBAAmB,CAAC;AA0DjC,6EAA6E;AAC7E,MAAM,CAAC,MAAM,cAAc,GAAe;IACxC;QACE,EAAE,EAAE,2BAA2B;QAC/B,IAAI,EAAE,qBAAqB;QAC3B,QAAQ,EAAE,MAAM;QAChB,OAAO,EAAE,gBAAgB;QACzB,IAAI,EAAE,QAAQ;QACd,GAAG,EAAE,OAAO;QACZ,GAAG,EAAE,MAAM;QACX,cAAc,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC;QACxC,WAAW,EAAE,gDAAgD;KAC9D;IACD;QACE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,CAAC,MAAM,CAEzC,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAEnE;AAED,yCAAyC;AACzC,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAE/E,MAAM,WAAW,gBAAgB;IAC/B,wEAAwE;IACxE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,wDAAwD;IACxD,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,IAAI,GAAE,gBAAqB,GAAG,mBAAmB,CAiBvH"}
@@ -33,21 +33,39 @@ function t(name, description, properties = {}, required = [], spend = false) {
33
33
  export const LSPS1_TOOLS = [
34
34
  t('lsp_get_info', "Get the LSP's capabilities: minimum/maximum channel size, supported expiries, fee structure, accepted payment options. Use this before estimating or ordering a channel. No args."),
35
35
  t('lsp_get_network_info', "Get the LSP's Lightning network info: pubkey, host, port, connect URI. Useful to display the counterparty or pre-connect a peer. No args."),
36
- t('lsp_estimate_fees', "Estimate the fee for a channel order BEFORE committing. Returns the total cost in sats plus any LSP routing fee. Re-estimate rather than reusing a stale value.", {
36
+ t('lsp_estimate_fees', "Estimate the channel-order fee BEFORE committing. Returns setup_fee, capacity_fee, duration_fee, total_fee (all in sats). Re-estimate rather than reusing a stale value.", {
37
37
  lsp_balance_sat: { type: 'number', description: "Sats the LSP commits on their side (inbound capacity for the user)." },
38
- client_balance_sat: { type: 'number', description: "Sats the user pre-funds into the channel (push amount). Often 0." },
39
- channel_expiry_blocks: { type: 'number', description: 'Optional minimum lease in blocks. Defaults to the LSP minimum.' },
40
- }, ['lsp_balance_sat']),
41
- t('lsp_create_order', "Create a channel order. SPEND: confirmation-gated. Returns an order id + a Lightning invoice the user pays to lock the order. The channel opens only after payment.", {
38
+ client_balance_sat: { type: 'number', description: "Sats the user pre-funds into the channel (push amount). Default 0." },
39
+ channel_expiry_blocks: { type: 'number', description: 'Lease duration in blocks. Default 4320 (~30 days). Maker maximum is typically 20160 (~140 days).' },
40
+ // RGB asset channels (optional):
41
+ asset_id: { type: 'string', description: 'For RGB asset channels the asset to provision liquidity for.' },
42
+ lsp_asset_amount: { type: 'number', description: 'Asset units the LSP commits (RGB channels only).' },
43
+ client_asset_amount: { type: 'number', description: 'Asset units the user pre-funds (RGB channels only). Requires rfq_id.' },
44
+ rfq_id: { type: 'string', description: 'Quote id from kaleidoswap_get_quote — required when client_asset_amount > 0.' },
45
+ token: { type: 'string', description: 'Optional discount/affiliate token.' },
46
+ }, ['lsp_balance_sat', 'client_balance_sat', 'channel_expiry_blocks']),
47
+ t('lsp_create_order', "Create a channel order. SPEND: confirmation-gated. Returns order_id + access_token + a payment.bolt11.invoice the user pays to lock the order. The channel opens only after payment.", {
48
+ client_pubkey: { type: 'string', description: "User's Lightning node pubkey — the LSP opens the channel TO this node. Get it from rln_get_node_info." },
42
49
  lsp_balance_sat: { type: 'number', description: "Sats the LSP commits on their side (inbound capacity for the user)." },
43
- client_balance_sat: { type: 'number', description: 'Sats the user pre-funds. Often 0.' },
44
- channel_expiry_blocks: { type: 'number', description: 'Minimum lease in blocks. Defaults to LSP minimum from lsp_get_info.' },
50
+ client_balance_sat: { type: 'number', description: "Sats the user pre-funds. Default 0." },
51
+ required_channel_confirmations: { type: 'number', description: 'Number of confs the user wants before considering the channel usable. Default 1.' },
52
+ funding_confirms_within_blocks: { type: 'number', description: 'Max blocks within which funding must confirm. Default 6.' },
53
+ channel_expiry_blocks: { type: 'number', description: 'Lease duration in blocks. Default 4320 (~30 days).' },
54
+ announce_channel: { type: 'boolean', description: 'Public (true) or unannounced (false). Default true.' },
45
55
  refund_onchain_address: { type: 'string', description: 'Optional on-chain refund address if the LSP cannot open the channel.' },
46
- }, ['lsp_balance_sat'],
56
+ // RGB asset channels (optional):
57
+ asset_id: { type: 'string', description: 'For RGB asset channels.' },
58
+ lsp_asset_amount: { type: 'number', description: 'Asset units the LSP commits.' },
59
+ client_asset_amount: { type: 'number', description: 'Asset units the user pre-funds.' },
60
+ rfq_id: { type: 'string', description: 'Required when client_asset_amount > 0.' },
61
+ token: { type: 'string', description: 'Optional discount/affiliate token.' },
62
+ email: { type: 'string', description: 'Optional contact for order updates.' },
63
+ }, ['client_pubkey', 'lsp_balance_sat'],
47
64
  /* spend */ true),
48
- t('lsp_get_order', 'Check the status of an LSPS1 order pending / paid / opening / completed / failed. Poll after creating an order until the channel opens.', {
65
+ t('lsp_get_order', 'Check the status of an LSPS1 order. order_state progresses CREATED CHANNEL_OPENING COMPLETED (or FAILED). ALWAYS pass BOTH the order_id and the access_token from lsp_create_order (the access_token is required for order status).', {
49
66
  order_id: { type: 'string', description: 'The order id from lsp_create_order.' },
50
- }, ['order_id']),
67
+ access_token: { type: 'string', description: 'The per-order access token returned by lsp_create_order. Required for non-admin reads.' },
68
+ }, ['order_id', 'access_token']),
51
69
  ];
52
70
  /** All LSPS1 tool names that move funds (confirmation-gated). */
53
71
  export const LSPS1_SPEND_TOOLS = new Set(LSPS1_TOOLS.filter((t) => t.spend).map((t) => t.name));
@@ -1 +1 @@
1
- {"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/lsps1/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAU7D,SAAS,CAAC,CAAC,IAAY,EAAE,WAAmB,EAAE,aAAoB,EAAE,EAAE,WAAqB,EAAE,EAAE,KAAK,GAAG,KAAK;IAC1G,OAAO;QACL,IAAI;QACJ,WAAW;QACX,KAAK;QACL,oBAAoB,EAAE,KAAK;QAC3B,UAAU,EAAE,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C5B,UAAU,EAAE,GAAG,CAAC,UAAU;YAC1B,oBAAoB,EAAE,GAAG,CAAC,oBAAoB;YAC9C,OAAO;SACR,CAAC,CAAC;IACL,CAAC;IACD,OAAO,IAAI,mBAAmB,CAAC,IAAI,CAAC,EAAE,IAAI,OAAO,EAAE,KAAK,CAAC,CAAC;AAC5D,CAAC"}
@@ -35,10 +35,25 @@ export interface ParsedTurn {
35
35
  /** Raw stop reason from the SDK, when provided. */
36
36
  stopReason?: string;
37
37
  }
38
+ /**
39
+ * Recover tool calls a model emitted as PLAIN TEXT instead of structured frames
40
+ * — `<tool_call>{"name":…,"arguments":…}</tool_call>` (Qwen/Hermes) or a bare
41
+ * leading `{"name":…,"arguments":…}`. Small local models (and SDK builds that
42
+ * don't apply the tool grammar) do this; without recovery the call leaks into
43
+ * the visible answer and never runs.
44
+ */
45
+ export declare function extractTextToolCalls(text: string): Array<{
46
+ name: string;
47
+ arguments: Record<string, unknown>;
48
+ }>;
38
49
  /**
39
50
  * Map a completion `final` (plus the streamed fallback text) into a ParsedTurn.
40
51
  * `rawContent` prefers the SDK's framed `raw.fullText` so the Engine can anchor
41
52
  * the next turn; falls back to the visible text when a provider has no raw form.
53
+ *
54
+ * When the SDK reports no structured tool calls, we re-scan the raw text for
55
+ * tool calls the model emitted inline (see `extractTextToolCalls`) so they still
56
+ * execute instead of leaking into the chat.
42
57
  */
43
58
  export declare function finalToTurn(final: QvacFinalLike, streamed?: string): ParsedTurn;
44
59
  //# sourceMappingURL=parse.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/qvac/parse.ts"],"names":[],"mappings":"AAQA,qEAAqE;AACrE,MAAM,WAAW,aAAa;IAC5B,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,GAAG,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5B,uEAAuE;IACvE,SAAS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