@kaleidorg/mind 0.1.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 (182) hide show
  1. package/dist/capabilities.d.ts +38 -0
  2. package/dist/capabilities.d.ts.map +1 -0
  3. package/dist/capabilities.js +41 -0
  4. package/dist/capabilities.js.map +1 -0
  5. package/dist/context/budget.d.ts +29 -0
  6. package/dist/context/budget.d.ts.map +1 -0
  7. package/dist/context/budget.js +36 -0
  8. package/dist/context/budget.js.map +1 -0
  9. package/dist/context/builder.d.ts +39 -0
  10. package/dist/context/builder.d.ts.map +1 -0
  11. package/dist/context/builder.js +77 -0
  12. package/dist/context/builder.js.map +1 -0
  13. package/dist/engine.d.ts +9 -0
  14. package/dist/engine.d.ts.map +1 -1
  15. package/dist/engine.js +1 -0
  16. package/dist/engine.js.map +1 -1
  17. package/dist/fastpath/fastpath.d.ts +38 -0
  18. package/dist/fastpath/fastpath.d.ts.map +1 -0
  19. package/dist/fastpath/fastpath.js +52 -0
  20. package/dist/fastpath/fastpath.js.map +1 -0
  21. package/dist/funnel.d.ts +117 -0
  22. package/dist/funnel.d.ts.map +1 -0
  23. package/dist/funnel.js +195 -0
  24. package/dist/funnel.js.map +1 -0
  25. package/dist/index.d.ts +44 -0
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +36 -0
  28. package/dist/index.js.map +1 -1
  29. package/dist/kaleidoswap/contract.d.ts +72 -0
  30. package/dist/kaleidoswap/contract.d.ts.map +1 -0
  31. package/dist/kaleidoswap/contract.js +125 -0
  32. package/dist/kaleidoswap/contract.js.map +1 -0
  33. package/dist/knowledge/bitcoin-copilot.d.ts +11 -0
  34. package/dist/knowledge/bitcoin-copilot.d.ts.map +1 -0
  35. package/dist/knowledge/bitcoin-copilot.js +155 -0
  36. package/dist/knowledge/bitcoin-copilot.js.map +1 -0
  37. package/dist/knowledge/btc-map.d.ts +87 -0
  38. package/dist/knowledge/btc-map.d.ts.map +1 -0
  39. package/dist/knowledge/btc-map.js +365 -0
  40. package/dist/knowledge/btc-map.js.map +1 -0
  41. package/dist/knowledge/merchants.d.ts +24 -0
  42. package/dist/knowledge/merchants.d.ts.map +1 -0
  43. package/dist/knowledge/merchants.js +34 -0
  44. package/dist/knowledge/merchants.js.map +1 -0
  45. package/dist/knowledge/wallet.d.ts +34 -0
  46. package/dist/knowledge/wallet.d.ts.map +1 -0
  47. package/dist/knowledge/wallet.js +63 -0
  48. package/dist/knowledge/wallet.js.map +1 -0
  49. package/dist/lsps1/contract.d.ts +55 -0
  50. package/dist/lsps1/contract.d.ts.map +1 -0
  51. package/dist/lsps1/contract.js +91 -0
  52. package/dist/lsps1/contract.js.map +1 -0
  53. package/dist/memory/store.d.ts +40 -0
  54. package/dist/memory/store.d.ts.map +1 -0
  55. package/dist/memory/store.js +143 -0
  56. package/dist/memory/store.js.map +1 -0
  57. package/dist/memory/tool.d.ts +9 -0
  58. package/dist/memory/tool.d.ts.map +1 -0
  59. package/dist/memory/tool.js +70 -0
  60. package/dist/memory/tool.js.map +1 -0
  61. package/dist/memory/types.d.ts +68 -0
  62. package/dist/memory/types.d.ts.map +1 -0
  63. package/dist/memory/types.js +14 -0
  64. package/dist/memory/types.js.map +1 -0
  65. package/dist/rag/retriever.d.ts +30 -0
  66. package/dist/rag/retriever.d.ts.map +1 -0
  67. package/dist/rag/retriever.js +72 -0
  68. package/dist/rag/retriever.js.map +1 -0
  69. package/dist/rag/tool.d.ts +15 -0
  70. package/dist/rag/tool.d.ts.map +1 -0
  71. package/dist/rag/tool.js +42 -0
  72. package/dist/rag/tool.js.map +1 -0
  73. package/dist/rag/types.d.ts +44 -0
  74. package/dist/rag/types.d.ts.map +1 -0
  75. package/dist/rag/types.js +11 -0
  76. package/dist/rag/types.js.map +1 -0
  77. package/dist/rag/vector-store.d.ts +23 -0
  78. package/dist/rag/vector-store.d.ts.map +1 -0
  79. package/dist/rag/vector-store.js +72 -0
  80. package/dist/rag/vector-store.js.map +1 -0
  81. package/dist/recipe/asset-send.d.ts +15 -0
  82. package/dist/recipe/asset-send.d.ts.map +1 -0
  83. package/dist/recipe/asset-send.js +83 -0
  84. package/dist/recipe/asset-send.js.map +1 -0
  85. package/dist/recipe/kaleidoswap-atomic.d.ts +27 -0
  86. package/dist/recipe/kaleidoswap-atomic.d.ts.map +1 -0
  87. package/dist/recipe/kaleidoswap-atomic.js +111 -0
  88. package/dist/recipe/kaleidoswap-atomic.js.map +1 -0
  89. package/dist/recipe/payments.d.ts +15 -0
  90. package/dist/recipe/payments.d.ts.map +1 -0
  91. package/dist/recipe/payments.js +119 -0
  92. package/dist/recipe/payments.js.map +1 -0
  93. package/dist/recipe/receive.d.ts +14 -0
  94. package/dist/recipe/receive.d.ts.map +1 -0
  95. package/dist/recipe/receive.js +109 -0
  96. package/dist/recipe/receive.js.map +1 -0
  97. package/dist/recipe/runner.d.ts +42 -0
  98. package/dist/recipe/runner.d.ts.map +1 -0
  99. package/dist/recipe/runner.js +106 -0
  100. package/dist/recipe/runner.js.map +1 -0
  101. package/dist/recipe/swap.d.ts +16 -0
  102. package/dist/recipe/swap.d.ts.map +1 -0
  103. package/dist/recipe/swap.js +73 -0
  104. package/dist/recipe/swap.js.map +1 -0
  105. package/dist/recipe/types.d.ts +71 -0
  106. package/dist/recipe/types.d.ts.map +1 -0
  107. package/dist/recipe/types.js +13 -0
  108. package/dist/recipe/types.js.map +1 -0
  109. package/dist/skills/registry.d.ts.map +1 -1
  110. package/dist/skills/registry.js +20 -2
  111. package/dist/skills/registry.js.map +1 -1
  112. package/dist/tools/cli.d.ts +43 -0
  113. package/dist/tools/cli.d.ts.map +1 -0
  114. package/dist/tools/cli.js +61 -0
  115. package/dist/tools/cli.js.map +1 -0
  116. package/dist/tools/mcp.d.ts +3 -2
  117. package/dist/tools/mcp.d.ts.map +1 -1
  118. package/dist/tools/mcp.js +3 -2
  119. package/dist/tools/mcp.js.map +1 -1
  120. package/dist/wallet/confirm.d.ts +12 -0
  121. package/dist/wallet/confirm.d.ts.map +1 -0
  122. package/dist/wallet/confirm.js +67 -0
  123. package/dist/wallet/confirm.js.map +1 -0
  124. package/dist/wallet/contract.d.ts +57 -0
  125. package/dist/wallet/contract.d.ts.map +1 -0
  126. package/dist/wallet/contract.js +113 -0
  127. package/dist/wallet/contract.js.map +1 -0
  128. package/package.json +10 -5
  129. package/skills/README.md +6 -1
  130. package/skills/kaleido-lsps/SKILL.md +56 -0
  131. package/skills/kaleido-trading/SKILL.md +85 -18
  132. package/skills/merchant-finder/SKILL.md +87 -0
  133. package/skills/paid-data/SKILL.md +12 -0
  134. package/skills/wallet-assistant/SKILL.md +38 -0
  135. package/src/capabilities.ts +79 -0
  136. package/src/context/budget.ts +46 -0
  137. package/src/context/builder.ts +100 -0
  138. package/src/context/context.test.ts +87 -0
  139. package/src/engine.ts +6 -0
  140. package/src/fastpath/fastpath.test.ts +34 -0
  141. package/src/fastpath/fastpath.ts +70 -0
  142. package/src/funnel.test.ts +207 -0
  143. package/src/funnel.ts +285 -0
  144. package/src/index.ts +128 -0
  145. package/src/kaleidoswap/contract.test.ts +147 -0
  146. package/src/kaleidoswap/contract.ts +212 -0
  147. package/src/knowledge/bitcoin-copilot.ts +177 -0
  148. package/src/knowledge/btc-map.test.ts +188 -0
  149. package/src/knowledge/btc-map.ts +446 -0
  150. package/src/knowledge/knowledge.test.ts +63 -0
  151. package/src/knowledge/merchants.ts +49 -0
  152. package/src/knowledge/wallet.ts +84 -0
  153. package/src/lsps1/contract.test.ts +81 -0
  154. package/src/lsps1/contract.ts +132 -0
  155. package/src/memory/memory.test.ts +140 -0
  156. package/src/memory/store.ts +174 -0
  157. package/src/memory/tool.ts +76 -0
  158. package/src/memory/types.ts +76 -0
  159. package/src/rag/rag.test.ts +85 -0
  160. package/src/rag/retriever.ts +94 -0
  161. package/src/rag/tool.ts +55 -0
  162. package/src/rag/types.ts +49 -0
  163. package/src/rag/vector-store.ts +78 -0
  164. package/src/recipe/asset-send.ts +79 -0
  165. package/src/recipe/kaleidoswap-atomic.test.ts +138 -0
  166. package/src/recipe/kaleidoswap-atomic.ts +117 -0
  167. package/src/recipe/payments.ts +116 -0
  168. package/src/recipe/receive.ts +98 -0
  169. package/src/recipe/recipe.test.ts +193 -0
  170. package/src/recipe/runner.ts +134 -0
  171. package/src/recipe/swap.ts +74 -0
  172. package/src/recipe/types.ts +76 -0
  173. package/src/skills/registry.ts +21 -2
  174. package/src/skills/skills.test.ts +42 -0
  175. package/src/tools/cli.test.ts +53 -0
  176. package/src/tools/cli.ts +98 -0
  177. package/src/tools/mcp.ts +3 -2
  178. package/src/wallet/confirm.test.ts +57 -0
  179. package/src/wallet/confirm.ts +74 -0
  180. package/src/wallet/contract.test.ts +89 -0
  181. package/src/wallet/contract.ts +157 -0
  182. package/skills/kaleido-wallet/SKILL.md +0 -28
package/dist/funnel.js ADDED
@@ -0,0 +1,195 @@
1
+ /**
2
+ * Funnel — the tiered agent loop (T0 fast-path → T2 recipe → T1 agentic).
3
+ *
4
+ * This is the mobile-optimized funnel from the roadmap, lifted out of the
5
+ * hosts so every surface (rate chat + voice, desktop provider, agent) runs
6
+ * the SAME routing:
7
+ *
8
+ * request
9
+ * ├─ T0 deterministic fast-path (no LLM) balance / address / price
10
+ * ├─ T2 recipe multi-step (~1 inference) "pay bob 3 EUR"
11
+ * └─ T1 skill-scoped agentic loop everything else
12
+ *
13
+ * Hosts inject the provider, the tool registry, and a `getSettings` closure
14
+ * read fresh each turn — so user-tunable settings (persona, history length,
15
+ * memory/RAG toggles, disabled skills) never require rebuilding the funnel
16
+ * or dropping host state like an embedded RAG index.
17
+ *
18
+ * Safety is unchanged from the Engine: spend tools are confirmation-gated by
19
+ * the contract; with no `onConfirm` the gate fails closed.
20
+ */
21
+ import { Engine } from './engine.js';
22
+ import { FastPath, WALLET_FAST_INTENTS } from './fastpath/fastpath.js';
23
+ import { RecipeRegistry, runRecipe } from './recipe/runner.js';
24
+ import { paymentsRecipe } from './recipe/payments.js';
25
+ import { receiveRecipe } from './recipe/receive.js';
26
+ import { assetSendRecipe } from './recipe/asset-send.js';
27
+ import { SkillRegistry } from './skills/registry.js';
28
+ /** Base system prompt for the wallet assistant. Hosts may override. */
29
+ export const DEFAULT_WALLET_SYSTEM = [
30
+ 'You are KaleidoSwap, a concise, privacy-first assistant running inside a',
31
+ 'non-custodial Bitcoin, Lightning and RGB wallet.',
32
+ '',
33
+ 'CORE RULES (these override every skill instruction):',
34
+ "1. If a tool can answer the user's question, CALL IT. Never describe how a",
35
+ " tool works (\"the pairs are listed using kaleidoswap_get_pairs\") — calling",
36
+ ' the tool IS the answer.',
37
+ '2. Never invent a balance, address, amount, price, quote, fee, pair, or any',
38
+ " other value. Every number or identifier in your reply MUST come from a tool",
39
+ ' result returned in the CURRENT turn.',
40
+ '3. Never reuse a number, name, or detail from a previous turn unless the user',
41
+ ' is explicitly asking about that earlier result. Each new question gets a',
42
+ ' fresh tool call.',
43
+ '4. If a tool needs a required argument the user did not give (e.g. an amount',
44
+ " for a quote), ASK for it. Do not invent values. Do not call the tool with",
45
+ ' the required field missing.',
46
+ '5. All BTC amounts are in satoshis. Asset codes are case-insensitive but the',
47
+ ' canonical forms are BTC, USDT, XAUT — do not silently shorten to USD, XAU.',
48
+ '',
49
+ 'Keep replies short and friendly. When a tool returns multiple fields, surface',
50
+ "the ones that matter — never collapse a structured result to a single number",
51
+ 'when other fields are non-zero or safety-relevant (e.g. pending balances,',
52
+ 'fees, slippage).',
53
+ ].join('\n');
54
+ /** Tools that stay available even when a skill narrows the set. */
55
+ const AMBIENT_MEMORY = ['remember', 'recall'];
56
+ const AMBIENT_RAG = ['search_knowledge'];
57
+ const DEFAULT_HISTORY = 8;
58
+ function defaultRenderFast(intent, r) {
59
+ if (intent === 'balance') {
60
+ const sats = Number(r?.total_sats ?? 0);
61
+ const n = r?.layers?.length ?? 0;
62
+ return `You have ${sats.toLocaleString()} sats${n > 1 ? ` across ${n} layers` : ''}.`;
63
+ }
64
+ if (intent === 'address') {
65
+ return r?.address ? `Here's your receive address:\n\n\`${r.address}\`` : 'No address available right now.';
66
+ }
67
+ return `Bitcoin is $${Number(r?.price_usd ?? 0).toLocaleString()}.`;
68
+ }
69
+ export class Funnel {
70
+ provider;
71
+ registry;
72
+ engine;
73
+ fastPath;
74
+ recipes;
75
+ allSkills;
76
+ system;
77
+ getSettings;
78
+ renderFast;
79
+ log;
80
+ /** Skill registry, rebuilt only when the disabled-skills set changes. */
81
+ skillsCache = null;
82
+ constructor(opts) {
83
+ this.provider = opts.provider;
84
+ this.registry = opts.tools;
85
+ this.engine = new Engine({
86
+ provider: opts.provider,
87
+ tools: opts.tools,
88
+ defaultMaxTurns: opts.maxTurns ?? 5,
89
+ });
90
+ this.fastPath = new FastPath(opts.fastIntents ?? WALLET_FAST_INTENTS);
91
+ this.recipes = new RecipeRegistry(opts.recipes ?? [assetSendRecipe, paymentsRecipe, receiveRecipe]);
92
+ this.allSkills = opts.skills ?? [];
93
+ this.system = opts.system ?? DEFAULT_WALLET_SYSTEM;
94
+ this.getSettings = opts.getSettings ?? (() => ({}));
95
+ this.renderFast = opts.renderFast ?? defaultRenderFast;
96
+ this.log = opts.log ?? (() => { });
97
+ }
98
+ /** Skills currently enabled (e.g. for a skills sheet). */
99
+ listSkills() {
100
+ return this.skillsFor(this.getSettings().disabledSkills).list();
101
+ }
102
+ skillsFor(disabled = []) {
103
+ const key = [...disabled].sort().join(',');
104
+ if (this.skillsCache?.key !== key) {
105
+ this.skillsCache = {
106
+ key,
107
+ reg: new SkillRegistry(this.allSkills.filter((s) => !disabled.includes(s.name))),
108
+ };
109
+ }
110
+ return this.skillsCache.reg;
111
+ }
112
+ async runTurn(text, cbs = {}) {
113
+ const settings = this.getSettings();
114
+ // ── T0: deterministic fast-path (no LLM) ──
115
+ // Only fires when the host's registry actually implements the intent's
116
+ // tool — a partial tool surface (e.g. desktop without the core aggregate
117
+ // helpers) falls through to the agentic tier instead of erroring.
118
+ const fast = this.fastPath.select(text);
119
+ if (fast && (await this.registry.getDef(fast.tool))) {
120
+ this.log(`tier=fast-path → ${fast.tool}`);
121
+ const r = await this.registry.execute(fast.tool, fast.args);
122
+ return { text: this.renderFast(fast.intent.name, r), tier: 'fast', intent: fast.intent.name, data: r };
123
+ }
124
+ // ── T2: recipe multi-step — fires only when the recipe is confident given
125
+ // its extracted slots (payments need a recipient; receive always fires),
126
+ // and the registry implements the recipe's final action.
127
+ const recipe = this.recipes.select(text);
128
+ const slots = recipe?.extract?.(text) ?? null;
129
+ const fires = !!recipe &&
130
+ !!slots &&
131
+ (recipe.confident ? recipe.confident(slots) : Object.keys(slots).length > 0) &&
132
+ !!(await this.registry.getDef(recipe.final.tool));
133
+ if (recipe && fires) {
134
+ this.log(`tier=recipe:${recipe.name} slots=${JSON.stringify(slots)}`);
135
+ const res = await runRecipe(recipe, text, {
136
+ provider: this.provider,
137
+ tools: this.registry,
138
+ onConfirm: cbs.onConfirm,
139
+ onStep: (name) => {
140
+ this.log(`step ${name}`);
141
+ cbs.onStep?.(name);
142
+ },
143
+ });
144
+ return { text: res.text, tier: 'recipe' };
145
+ }
146
+ // ── T1: skill-scoped agentic loop ──
147
+ const skills = this.skillsFor(settings.disabledSkills);
148
+ const skill = skills.select(text);
149
+ const base = settings.persona ? `${this.system}\n\n## Your persona\n${settings.persona}` : this.system;
150
+ const { system, allowedTools } = skills.compose(base, skill);
151
+ // Ambient tools stay available even when a skill narrows the set — gated
152
+ // by the user's memory/knowledge toggles (default on).
153
+ const memoryOn = settings.memoryEnabled !== false;
154
+ const ragOn = settings.ragEnabled !== false;
155
+ const ambient = [...(memoryOn ? AMBIENT_MEMORY : []), ...(ragOn ? AMBIENT_RAG : [])];
156
+ const disabledAmbient = [...(memoryOn ? [] : AMBIENT_MEMORY), ...(ragOn ? [] : AMBIENT_RAG)];
157
+ let scoped;
158
+ if (allowedTools) {
159
+ scoped = [...new Set([...allowedTools, ...ambient])];
160
+ }
161
+ else if (disabledAmbient.length) {
162
+ // No skill matched but a toggle is off: expose everything except the
163
+ // disabled ambient tools (the sources stay mounted — no rebuild).
164
+ const all = (await this.registry.listTools()).map((t) => t.name);
165
+ scoped = all.filter((n) => !disabledAmbient.includes(n));
166
+ }
167
+ // Trim history so the prompt (system + skill + tools + history) stays
168
+ // within the small on-device model's context window.
169
+ const keep = settings.historyLength ?? DEFAULT_HISTORY;
170
+ const history = (cbs.history ?? []).slice(-keep);
171
+ const messages = [
172
+ { role: 'system', content: system },
173
+ ...history,
174
+ { role: 'user', content: text },
175
+ ];
176
+ this.log(`tier=agentic skill=${skill?.name ?? 'none'} tools=[${(scoped ?? ['all']).join(',')}]`);
177
+ const res = await this.engine.runAgentic(messages, {
178
+ allowedTools: scoped,
179
+ onStart: (requestId) => cbs.onStart?.(requestId),
180
+ onToken: cbs.onToken,
181
+ onToolCall: (call) => {
182
+ this.log(`tool ${call.name} ${JSON.stringify(call.arguments)}`);
183
+ // getDef is async; fire-and-forget so the loop is never blocked on UI.
184
+ void this.registry
185
+ .getDef(call.name)
186
+ .then((def) => cbs.onToolCall?.(call, { requiresConfirmation: !!def?.requiresConfirmation }))
187
+ .catch(() => cbs.onToolCall?.(call, { requiresConfirmation: false }));
188
+ },
189
+ onToolResult: cbs.onToolResult,
190
+ onConfirm: cbs.onConfirm,
191
+ });
192
+ return { text: res.text ?? '', tier: 'agentic', toolCalls: res.toolCalls, turns: res.turns };
193
+ }
194
+ }
195
+ //# sourceMappingURL=funnel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"funnel.js","sourceRoot":"","sources":["../src/funnel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAs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YAAY,EAAE,MAAM;YACpB,OAAO,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC;YAChD,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE;gBACnB,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;gBAChE,uEAAuE;gBACvE,KAAK,IAAI,CAAC,QAAQ;qBACf,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;qBACjB,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,oBAAoB,EAAE,CAAC,CAAC,GAAG,EAAE,oBAAoB,EAAE,CAAC,CAAC;qBAC5F,KAAK,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;YAC1E,CAAC;YACD,YAAY,EAAE,GAAG,CAAC,YAAY;YAC9B,SAAS,EAAE,GAAG,CAAC,SAAS;SACzB,CAAC,CAAC;QACH,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC;IAC/F,CAAC;CACF"}
package/dist/index.d.ts CHANGED
@@ -15,8 +15,52 @@ export type { InProcessTool } from './tools/in-process.js';
15
15
  export { ToolRegistry } from './tools/registry.js';
16
16
  export { createL402ToolSource, parseL402Challenge, bolt11AmountSats, } from './tools/l402.js';
17
17
  export type { L402Options, L402PayResult } from './tools/l402.js';
18
+ export { createCliToolSource, isAllowed } from './tools/cli.js';
19
+ export type { CliToolOptions, CommandRunner, CommandResult } from './tools/cli.js';
20
+ export { WALLET_TOOLS, WALLET_LAYERS, SPEND_TOOLS, isSpendTool, getWalletTool, walletTools, toToolDefs, bindWalletTools, } from './wallet/contract.js';
21
+ export type { WalletLayer, WalletToolDef, WalletHandler, BindWalletOptions, } from './wallet/contract.js';
22
+ export { confirmReadback } from './wallet/confirm.js';
23
+ export { KALEIDOSWAP_TOOLS, KALEIDOSWAP_SPEND_TOOLS, isKaleidoswapSpendTool, getKaleidoswapTool, kaleidoswapTools, bindKaleidoswapTools, } from './kaleidoswap/contract.js';
24
+ export type { KaleidoswapGroup, KaleidoswapToolDef, KaleidoswapHandler, BindKaleidoswapOptions, } from './kaleidoswap/contract.js';
25
+ export { LSPS1_TOOLS, LSPS1_SPEND_TOOLS, isLsps1SpendTool, getLsps1Tool, bindLsps1Tools, } from './lsps1/contract.js';
26
+ export type { Lsps1ToolDef, Lsps1Handler, BindLsps1Options, } from './lsps1/contract.js';
27
+ export { kaleidoswapAtomicRecipe } from './recipe/kaleidoswap-atomic.js';
28
+ export { runRecipe, extractSlots, RecipeRegistry } from './recipe/runner.js';
29
+ export type { RunRecipeOptions } from './recipe/runner.js';
30
+ export { paymentsRecipe, extractPayment } from './recipe/payments.js';
31
+ export { swapRecipe, extractSwap } from './recipe/swap.js';
32
+ export { receiveRecipe, extractReceive } from './recipe/receive.js';
33
+ export { assetSendRecipe, extractAssetSend } from './recipe/asset-send.js';
34
+ export type { Recipe, RecipeStep, RecipeSlot, RecipeContext, RecipeResult, RecipeStatus } from './recipe/types.js';
35
+ export { FastPath, WALLET_FAST_INTENTS } from './fastpath/fastpath.js';
36
+ export type { FastIntent, FastHit } from './fastpath/fastpath.js';
37
+ export { InMemoryMemoryStore } from './memory/store.js';
38
+ export type { MemoryStoreOptions } from './memory/store.js';
39
+ export { createMemoryToolSource } from './memory/tool.js';
40
+ export type { AgentProfile, MemoryConsolidation, MemoryItem, MemoryKind, MemoryQuery, MemoryStore, MemoryIO, NewMemory, } from './memory/types.js';
41
+ export { Retriever, chunkText } from './rag/retriever.js';
42
+ export type { RetrieverOptions } from './rag/retriever.js';
43
+ export { InMemoryVectorStore, cosineSimilarity } from './rag/vector-store.js';
44
+ export { createRagToolSource } from './rag/tool.js';
45
+ export type { RagToolOptions } from './rag/tool.js';
46
+ export type { EmbeddingProvider, Chunk, RetrievedChunk, RagDocument, VectorStore, VectorStoreIO, } from './rag/types.js';
47
+ export { ContextBuilder } from './context/builder.js';
48
+ export type { ContextBuilderOptions, BuildInput } from './context/builder.js';
49
+ export { estimateTokens, clampToTokens, contextBudgetTokens, } from './context/budget.js';
50
+ export type { BudgetReserves } from './context/budget.js';
51
+ export { capabilityProfile } from './capabilities.js';
52
+ export type { CapabilityInput, MindCapabilities } from './capabilities.js';
53
+ export { BITCOIN_COPILOT_DOCS } from './knowledge/bitcoin-copilot.js';
54
+ export { walletHistoryToDocuments, contactsToDocuments } from './knowledge/wallet.js';
55
+ export type { WalletTx, Contact } from './knowledge/wallet.js';
56
+ export { merchantsToDocuments } from './knowledge/merchants.js';
57
+ export type { Merchant } from './knowledge/merchants.js';
58
+ export { createBtcMapToolSource, BTC_MAP_SAMPLE } from './knowledge/btc-map.js';
59
+ export type { BtcMapToolOptions, BtcMapMerchant, BtcMapFetch, LocationProvider, LatLng, } from './knowledge/btc-map.js';
18
60
  export { Engine } from './engine.js';
19
61
  export type { EngineOptions, AgenticOptions, AgenticResult } from './engine.js';
62
+ export { Funnel, DEFAULT_WALLET_SYSTEM } from './funnel.js';
63
+ export type { FunnelOptions, FunnelSettings, FunnelCallbacks, FunnelResult } from './funnel.js';
20
64
  export { SkillRegistry, parseSkill, keywordSelector, READ_REFERENCE_TOOL, } from './skills/registry.js';
21
65
  export { createSkillReferenceToolSource } from './skills/reference-source.js';
22
66
  export { skillsFromBundle } from './skills/bundle.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;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C5D,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhG,OAAO,EACL,aAAa,EACb,UAAU,EACV,eAAe,EACf,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,8BAA8B,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACpE,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE9E,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -10,7 +10,43 @@
10
10
  export { InProcessToolSource } from './tools/in-process.js';
11
11
  export { ToolRegistry } from './tools/registry.js';
12
12
  export { createL402ToolSource, parseL402Challenge, bolt11AmountSats, } from './tools/l402.js';
13
+ export { createCliToolSource, isAllowed } from './tools/cli.js';
14
+ // ── Multi-L2 wallet tool contract (single source of truth) ─────────────────
15
+ export { WALLET_TOOLS, WALLET_LAYERS, SPEND_TOOLS, isSpendTool, getWalletTool, walletTools, toToolDefs, bindWalletTools, } from './wallet/contract.js';
16
+ export { confirmReadback } from './wallet/confirm.js';
17
+ // ── KaleidoSwap maker tool contract (single source of truth) ────────────────
18
+ export { KALEIDOSWAP_TOOLS, KALEIDOSWAP_SPEND_TOOLS, isKaleidoswapSpendTool, getKaleidoswapTool, kaleidoswapTools, bindKaleidoswapTools, } from './kaleidoswap/contract.js';
19
+ // ── LSPS1 (Lightning Service Provider channel orders) ───────────────────────
20
+ export { LSPS1_TOOLS, LSPS1_SPEND_TOOLS, isLsps1SpendTool, getLsps1Tool, bindLsps1Tools, } from './lsps1/contract.js';
21
+ // ── KaleidoSwap atomic-swap recipe (opt-in — register via Funnel.recipes) ──
22
+ export { kaleidoswapAtomicRecipe } from './recipe/kaleidoswap-atomic.js';
23
+ // ── Recipes (mobile multi-step: "recipes, not planning") ───────────────────
24
+ export { runRecipe, extractSlots, RecipeRegistry } from './recipe/runner.js';
25
+ export { paymentsRecipe, extractPayment } from './recipe/payments.js';
26
+ export { swapRecipe, extractSwap } from './recipe/swap.js';
27
+ export { receiveRecipe, extractReceive } from './recipe/receive.js';
28
+ export { assetSendRecipe, extractAssetSend } from './recipe/asset-send.js';
29
+ // ── Tier-0 deterministic fast-path (no LLM) ────────────────────────────────
30
+ export { FastPath, WALLET_FAST_INTENTS } from './fastpath/fastpath.js';
31
+ // ── Memory (soul + recall) ───────────────────────────────────────────────
32
+ export { InMemoryMemoryStore } from './memory/store.js';
33
+ export { createMemoryToolSource } from './memory/tool.js';
34
+ // ── RAG ──────────────────────────────────────────────────────────────────
35
+ export { Retriever, chunkText } from './rag/retriever.js';
36
+ export { InMemoryVectorStore, cosineSimilarity } from './rag/vector-store.js';
37
+ export { createRagToolSource } from './rag/tool.js';
38
+ // ── Context assembly + hardware budget ─────────────────────────────────────
39
+ export { ContextBuilder } from './context/builder.js';
40
+ export { estimateTokens, clampToTokens, contextBudgetTokens, } from './context/budget.js';
41
+ export { capabilityProfile } from './capabilities.js';
42
+ // ── Knowledge packs + corpus adapters (for RAG) ────────────────────────────
43
+ export { BITCOIN_COPILOT_DOCS } from './knowledge/bitcoin-copilot.js';
44
+ export { walletHistoryToDocuments, contactsToDocuments } from './knowledge/wallet.js';
45
+ export { merchantsToDocuments } from './knowledge/merchants.js';
46
+ export { createBtcMapToolSource, BTC_MAP_SAMPLE } from './knowledge/btc-map.js';
13
47
  export { Engine } from './engine.js';
48
+ // ── Funnel (T0 fast-path → T2 recipe → T1 agentic — the tiered agent) ───────
49
+ export { Funnel, DEFAULT_WALLET_SYSTEM } from './funnel.js';
14
50
  export { SkillRegistry, parseSkill, keywordSelector, READ_REFERENCE_TOOL, } from './skills/registry.js';
15
51
  export { createSkillReferenceToolSource } from './skills/reference-source.js';
16
52
  export { skillsFromBundle } from './skills/bundle.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAcH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EACL,aAAa,EACb,UAAU,EACV,eAAe,EACf,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,8BAA8B,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAcH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhE,8EAA8E;AAC9E,OAAO,EACL,YAAY,EACZ,aAAa,EACb,WAAW,EACX,WAAW,EACX,aAAa,EACb,WAAW,EACX,UAAU,EACV,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAO9B,OAAO,EAAE,eAAe,E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qBAAqB,CAAC;AAE7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGtD,8EAA8E;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAShF,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,+EAA+E;AAC/E,OAAO,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAG5D,OAAO,EACL,aAAa,EACb,UAAU,EACV,eAAe,EACf,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,8BAA8B,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Canonical KaleidoSwap tool contract — the single source of truth for the
3
+ * agent-facing tools that drive the KaleidoSwap maker.
4
+ *
5
+ * Every surface implements THESE EXACT tools, only the transport differs:
6
+ * - mobile → in-process handlers over the WDK protocol package
7
+ * (`@kaleidorg/wdk-protocol-swap-kaleidoswap`) via `bindKaleidoswapTools`
8
+ * - desktop → HTTP / kaleido-mcp / kaleido-cli, also via `bindKaleidoswapTools`
9
+ * - eval → stub handlers, also via `bindKaleidoswapTools`
10
+ *
11
+ * Because the schemas are identical everywhere, skills are portable and the
12
+ * model comparison is honest. Tools are grouped (`market`, `orders`, `atomic`)
13
+ * so a host can expose a read-only subset for sandbox/eval modes.
14
+ *
15
+ * Spend tools (place an order, init/execute an atomic swap) carry
16
+ * `spend: true` → `requiresConfirmation: true`, so the Engine always pauses
17
+ * for the host's confirm gate before executing.
18
+ *
19
+ * Pure data — no deps, no fetch, RN-safe.
20
+ */
21
+ import type { ToolDef } from '../types.js';
22
+ import { InProcessToolSource } from '../tools/in-process.js';
23
+ /** Functional grouping for selective binding (e.g. read-only sandbox). */
24
+ export type KaleidoswapGroup = 'market' | 'orders' | 'atomic';
25
+ export interface KaleidoswapToolDef extends ToolDef {
26
+ /** Functional group — lets a host expose a subset. */
27
+ group: KaleidoswapGroup;
28
+ /** Moves funds → confirmation-gated. */
29
+ spend?: boolean;
30
+ }
31
+ /**
32
+ * The canonical KaleidoSwap tool list. Schema is intentionally agent-facing —
33
+ * each host's adapter translates these args into the underlying transport's
34
+ * request body (maker REST JSON, WDK protocol calls, MCP, etc.).
35
+ */
36
+ export declare const KALEIDOSWAP_TOOLS: KaleidoswapToolDef[];
37
+ /** All tool names that move funds (confirmation-gated). */
38
+ export declare const KALEIDOSWAP_SPEND_TOOLS: Set<string>;
39
+ /** Quick lookup. */
40
+ export declare function isKaleidoswapSpendTool(name: string): boolean;
41
+ /** Quick lookup. */
42
+ export declare function getKaleidoswapTool(name: string): KaleidoswapToolDef | undefined;
43
+ /** Pick the contract tools for the given groups (all by default). */
44
+ export declare function kaleidoswapTools(opts?: {
45
+ groups?: KaleidoswapGroup[];
46
+ }): KaleidoswapToolDef[];
47
+ /** A handler bound to one contract tool. Args validated by JSON schema upstream. */
48
+ export type KaleidoswapHandler = (args: Record<string, unknown>) => Promise<unknown>;
49
+ export interface BindKaleidoswapOptions {
50
+ /** Restrict the surface to a subset (e.g. read-only on eval). */
51
+ groups?: KaleidoswapGroup[];
52
+ /** Skip tools that have no handler instead of throwing (default false). */
53
+ allowMissing?: boolean;
54
+ /** ToolSource id for the registry (default 'kaleidoswap'). */
55
+ id?: string;
56
+ }
57
+ /**
58
+ * Bind contract tools to in-process handlers → an InProcessToolSource.
59
+ *
60
+ * The host is responsible for the actual transport (HTTP/WDK/CLI/MCP) — this
61
+ * function is a pure shape adapter that preserves names, descriptions,
62
+ * parameter schemas, and the spend gate.
63
+ *
64
+ * const source = bindKaleidoswapTools({
65
+ * kaleidoswap_get_quote: async (args) => makerSdk.quote(args),
66
+ * kaleidoswap_place_order: async ({ quote_id }) => makerSdk.placeOrder({ quoteId: quote_id }),
67
+ * // …
68
+ * });
69
+ * tools.register(source);
70
+ */
71
+ export declare function bindKaleidoswapTools(handlers: Record<string, KaleidoswapHandler>, opts?: BindKaleidoswapOptions): InProcessToolSource;
72
+ //# sourceMappingURL=contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/kaleidoswap/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7D,0EAA0E;AAC1E,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE9D,MAAM,WAAW,kBAAmB,SAAQ,OAAO;IACjD,sDAAsD;IACtD,KAAK,EAAE,gBAAgB,CAAC;IACxB,wCAAwC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAsBD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,kBAAkB,EA8EjD,CAAC;AAEF,2DAA2D;AAC3D,eAAO,MAAM,uBAAuB,EAAE,GAAG,CAAC,MAAM,CAE/C,CAAC;AAEF,oBAAoB;AACpB,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED,oBAAoB;AACpB,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAE/E;AAED,qEAAqE;AACrE,wBAAgB,gBAAgB,CAC9B,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAA;CAAO,GACzC,kBAAkB,EAAE,CAItB;AAED,oFAAoF;AACpF,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAErF,MAAM,WAAW,sBAAsB;IACrC,iEAAiE;IACjE,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC5B,2EAA2E;IAC3E,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,8DAA8D;IAC9D,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAC5C,IAAI,GAAE,sBAA2B,GAChC,mBAAmB,CAkBrB"}
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Canonical KaleidoSwap tool contract — the single source of truth for the
3
+ * agent-facing tools that drive the KaleidoSwap maker.
4
+ *
5
+ * Every surface implements THESE EXACT tools, only the transport differs:
6
+ * - mobile → in-process handlers over the WDK protocol package
7
+ * (`@kaleidorg/wdk-protocol-swap-kaleidoswap`) via `bindKaleidoswapTools`
8
+ * - desktop → HTTP / kaleido-mcp / kaleido-cli, also via `bindKaleidoswapTools`
9
+ * - eval → stub handlers, also via `bindKaleidoswapTools`
10
+ *
11
+ * Because the schemas are identical everywhere, skills are portable and the
12
+ * model comparison is honest. Tools are grouped (`market`, `orders`, `atomic`)
13
+ * so a host can expose a read-only subset for sandbox/eval modes.
14
+ *
15
+ * Spend tools (place an order, init/execute an atomic swap) carry
16
+ * `spend: true` → `requiresConfirmation: true`, so the Engine always pauses
17
+ * for the host's confirm gate before executing.
18
+ *
19
+ * Pure data — no deps, no fetch, RN-safe.
20
+ */
21
+ import { InProcessToolSource } from '../tools/in-process.js';
22
+ function t(group, name, description, properties = {}, required = [], spend = false) {
23
+ return {
24
+ group,
25
+ name,
26
+ description,
27
+ spend,
28
+ requiresConfirmation: spend,
29
+ parameters: { type: 'object', properties, required },
30
+ };
31
+ }
32
+ /**
33
+ * The canonical KaleidoSwap tool list. Schema is intentionally agent-facing —
34
+ * each host's adapter translates these args into the underlying transport's
35
+ * request body (maker REST JSON, WDK protocol calls, MCP, etc.).
36
+ */
37
+ export const KALEIDOSWAP_TOOLS = [
38
+ // ─── market (read) ─────────────────────────────────────────────────────
39
+ t('market', 'kaleidoswap_get_assets', 'List the assets KaleidoSwap supports — BTC plus the RGB assets the maker has inventory for (e.g. USDT, XAUT). Returns symbol, precision, and issuer/contract id. No args.'),
40
+ t('market', 'kaleidoswap_get_pairs', 'List the trading pairs currently quoted by the maker, with the latest bid/ask and the minimum/maximum executable size on each side. Use this before quoting to pick a valid pair. No args.'),
41
+ t('market', 'kaleidoswap_get_quote', 'Get an executable quote for swapping a specific amount on one pair. Returns a quote id (use it with place_order or atomic_init), the expected receive amount, fees, slippage, and how long the quote is valid for. Re-quote rather than reusing a stale id.', {
42
+ from_asset: { type: 'string', description: 'Asset to spend, e.g. "BTC" or "USDT".' },
43
+ to_asset: { type: 'string', description: 'Asset to receive, e.g. "USDT" or "BTC".' },
44
+ amount: { type: 'number', description: 'Amount of from_asset to swap. BTC is in satoshis; RGB assets use their asset-defined precision.' },
45
+ side: { type: 'string', enum: ['buy', 'sell'], description: 'Default "sell" (you sell from_asset). Use "buy" only when from_asset is the quote currency you spend to acquire to_asset.' },
46
+ }, ['from_asset', 'to_asset', 'amount']),
47
+ t('market', 'kaleidoswap_get_nodeinfo', "Get info about the maker's Lightning node — pubkey, host, port, connect URI. Useful before opening a channel or when the user wants to see the counterparty. No args."),
48
+ // ─── orders (orderbook / market-order flow) ─────────────────────────────
49
+ t('orders', 'kaleidoswap_place_order', 'Place an order using an executable quote. Returns an order id. SPEND: the host pauses for user confirmation before the maker is called. Use only after kaleidoswap_get_quote and only when the user has explicitly approved the amount + destination.', {
50
+ quote_id: { type: 'string', description: 'The quote id returned by kaleidoswap_get_quote (must still be valid).' },
51
+ }, ['quote_id'],
52
+ /* spend */ true),
53
+ t('orders', 'kaleidoswap_get_order_status', 'Check the status of an order by id — pending / settling / completed / failed. Poll this after place_order until the order settles.', {
54
+ order_id: { type: 'string', description: 'The order id returned by kaleidoswap_place_order.' },
55
+ }, ['order_id']),
56
+ t('orders', 'kaleidoswap_get_order_history', "Get the user's recent KaleidoSwap orders for context (last N, paginated). Read-only.", {
57
+ limit: { type: 'number', description: 'Max rows (default 20, max 100).' },
58
+ cursor: { type: 'string', description: 'Pagination cursor from a previous call.' },
59
+ }),
60
+ // ─── atomic (the trust-minimised swap chain — used by the recipe) ───────
61
+ t('atomic', 'kaleidoswap_atomic_init', "Initialise an atomic swap from a quote. Requires the receiver's RGB/LN invoice so the maker can lock the outgoing leg. SPEND: confirmation-gated. Returns the maker's invoice for the user to pay and an atomic id to track.", {
62
+ quote_id: { type: 'string', description: 'The quote id from kaleidoswap_get_quote.' },
63
+ receive_invoice: { type: 'string', description: "The user's RGB or Lightning invoice for to_asset, created on the user's own node." },
64
+ }, ['quote_id', 'receive_invoice'],
65
+ /* spend */ true),
66
+ t('atomic', 'kaleidoswap_atomic_execute', "Tell the maker to release the receive leg now that the user has paid the maker's invoice. SPEND: confirmation-gated (committing the swap). Returns an updated atomic status.", {
67
+ atomic_id: { type: 'string', description: 'The atomic id from kaleidoswap_atomic_init.' },
68
+ }, ['atomic_id'],
69
+ /* spend */ true),
70
+ t('atomic', 'kaleidoswap_atomic_status', 'Poll the status of an atomic swap — pending_payment / paid / settling / completed / failed / expired. Use this in a loop after execute until it terminates.', {
71
+ atomic_id: { type: 'string', description: 'The atomic id from kaleidoswap_atomic_init.' },
72
+ }, ['atomic_id']),
73
+ ];
74
+ /** All tool names that move funds (confirmation-gated). */
75
+ export const KALEIDOSWAP_SPEND_TOOLS = new Set(KALEIDOSWAP_TOOLS.filter((t) => t.spend).map((t) => t.name));
76
+ /** Quick lookup. */
77
+ export function isKaleidoswapSpendTool(name) {
78
+ return KALEIDOSWAP_SPEND_TOOLS.has(name);
79
+ }
80
+ /** Quick lookup. */
81
+ export function getKaleidoswapTool(name) {
82
+ return KALEIDOSWAP_TOOLS.find((t) => t.name === name);
83
+ }
84
+ /** Pick the contract tools for the given groups (all by default). */
85
+ export function kaleidoswapTools(opts = {}) {
86
+ if (!opts.groups)
87
+ return [...KALEIDOSWAP_TOOLS];
88
+ const groups = new Set(opts.groups);
89
+ return KALEIDOSWAP_TOOLS.filter((x) => groups.has(x.group));
90
+ }
91
+ /**
92
+ * Bind contract tools to in-process handlers → an InProcessToolSource.
93
+ *
94
+ * The host is responsible for the actual transport (HTTP/WDK/CLI/MCP) — this
95
+ * function is a pure shape adapter that preserves names, descriptions,
96
+ * parameter schemas, and the spend gate.
97
+ *
98
+ * const source = bindKaleidoswapTools({
99
+ * kaleidoswap_get_quote: async (args) => makerSdk.quote(args),
100
+ * kaleidoswap_place_order: async ({ quote_id }) => makerSdk.placeOrder({ quoteId: quote_id }),
101
+ * // …
102
+ * });
103
+ * tools.register(source);
104
+ */
105
+ export function bindKaleidoswapTools(handlers, opts = {}) {
106
+ const defs = kaleidoswapTools(opts);
107
+ const bound = [];
108
+ for (const def of defs) {
109
+ const handler = handlers[def.name];
110
+ if (!handler) {
111
+ if (opts.allowMissing)
112
+ continue;
113
+ throw new Error(`bindKaleidoswapTools: no handler for "${def.name}"`);
114
+ }
115
+ bound.push({
116
+ name: def.name,
117
+ description: def.description,
118
+ parameters: def.parameters,
119
+ requiresConfirmation: def.requiresConfirmation,
120
+ handler,
121
+ });
122
+ }
123
+ return new InProcessToolSource(opts.id ?? 'kaleidoswap', bound);
124
+ }
125
+ //# sourceMappingURL=contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/kaleidoswap/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAe7D,SAAS,C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I,EAAE,GAAG,CAAC,IAAI;YACd,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,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,aAAa,EAAE,KAAK,CAAC,CAAC;AAClE,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Bitcoin-copilot knowledge pack — a curated, on-brand corpus to RAG over so an
3
+ * on-device assistant can answer Bitcoin / Lightning / RGB / KaleidoSwap
4
+ * questions privately. Ship it, ingest it with a Retriever, done.
5
+ *
6
+ * Concise + accurate. Extend or replace with your own docs (BOLT specs, RGB
7
+ * docs, app help, FAQs) — the format is just `RagDocument[]`.
8
+ */
9
+ import type { RagDocument } from '../rag/types.js';
10
+ export declare const BITCOIN_COPILOT_DOCS: RagDocument[];
11
+ //# sourceMappingURL=bitcoin-copilot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bitcoin-copilot.d.ts","sourceRoot":"","sources":["../../src/knowledge/bitcoin-copilot.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,eAAO,MAAM,oBAAoB,EAAE,WAAW,EAqK7C,CAAC"}