@kaleidorg/mind 0.1.0 → 0.2.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.
- package/dist/capabilities.d.ts +34 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +34 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/context/budget.d.ts +29 -0
- package/dist/context/budget.d.ts.map +1 -0
- package/dist/context/budget.js +36 -0
- package/dist/context/budget.js.map +1 -0
- package/dist/context/builder.d.ts +39 -0
- package/dist/context/builder.d.ts.map +1 -0
- package/dist/context/builder.js +77 -0
- package/dist/context/builder.js.map +1 -0
- package/dist/fastpath/fastpath.d.ts +38 -0
- package/dist/fastpath/fastpath.d.ts.map +1 -0
- package/dist/fastpath/fastpath.js +52 -0
- package/dist/fastpath/fastpath.js.map +1 -0
- package/dist/funnel.d.ts +111 -0
- package/dist/funnel.d.ts.map +1 -0
- package/dist/funnel.js +175 -0
- package/dist/funnel.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -1
- package/dist/knowledge/bitcoin-copilot.d.ts +11 -0
- package/dist/knowledge/bitcoin-copilot.d.ts.map +1 -0
- package/dist/knowledge/bitcoin-copilot.js +155 -0
- package/dist/knowledge/bitcoin-copilot.js.map +1 -0
- package/dist/knowledge/merchants.d.ts +24 -0
- package/dist/knowledge/merchants.d.ts.map +1 -0
- package/dist/knowledge/merchants.js +34 -0
- package/dist/knowledge/merchants.js.map +1 -0
- package/dist/knowledge/wallet.d.ts +34 -0
- package/dist/knowledge/wallet.d.ts.map +1 -0
- package/dist/knowledge/wallet.js +63 -0
- package/dist/knowledge/wallet.js.map +1 -0
- package/dist/memory/store.d.ts +34 -0
- package/dist/memory/store.d.ts.map +1 -0
- package/dist/memory/store.js +103 -0
- package/dist/memory/store.js.map +1 -0
- package/dist/memory/tool.d.ts +9 -0
- package/dist/memory/tool.d.ts.map +1 -0
- package/dist/memory/tool.js +70 -0
- package/dist/memory/tool.js.map +1 -0
- package/dist/memory/types.d.ts +56 -0
- package/dist/memory/types.d.ts.map +1 -0
- package/dist/memory/types.js +14 -0
- package/dist/memory/types.js.map +1 -0
- package/dist/rag/retriever.d.ts +30 -0
- package/dist/rag/retriever.d.ts.map +1 -0
- package/dist/rag/retriever.js +72 -0
- package/dist/rag/retriever.js.map +1 -0
- package/dist/rag/tool.d.ts +15 -0
- package/dist/rag/tool.d.ts.map +1 -0
- package/dist/rag/tool.js +42 -0
- package/dist/rag/tool.js.map +1 -0
- package/dist/rag/types.d.ts +44 -0
- package/dist/rag/types.d.ts.map +1 -0
- package/dist/rag/types.js +11 -0
- package/dist/rag/types.js.map +1 -0
- package/dist/rag/vector-store.d.ts +23 -0
- package/dist/rag/vector-store.d.ts.map +1 -0
- package/dist/rag/vector-store.js +72 -0
- package/dist/rag/vector-store.js.map +1 -0
- package/dist/recipe/asset-send.d.ts +15 -0
- package/dist/recipe/asset-send.d.ts.map +1 -0
- package/dist/recipe/asset-send.js +83 -0
- package/dist/recipe/asset-send.js.map +1 -0
- package/dist/recipe/payments.d.ts +15 -0
- package/dist/recipe/payments.d.ts.map +1 -0
- package/dist/recipe/payments.js +119 -0
- package/dist/recipe/payments.js.map +1 -0
- package/dist/recipe/receive.d.ts +14 -0
- package/dist/recipe/receive.d.ts.map +1 -0
- package/dist/recipe/receive.js +109 -0
- package/dist/recipe/receive.js.map +1 -0
- package/dist/recipe/runner.d.ts +42 -0
- package/dist/recipe/runner.d.ts.map +1 -0
- package/dist/recipe/runner.js +94 -0
- package/dist/recipe/runner.js.map +1 -0
- package/dist/recipe/swap.d.ts +16 -0
- package/dist/recipe/swap.d.ts.map +1 -0
- package/dist/recipe/swap.js +73 -0
- package/dist/recipe/swap.js.map +1 -0
- package/dist/recipe/types.d.ts +71 -0
- package/dist/recipe/types.d.ts.map +1 -0
- package/dist/recipe/types.js +13 -0
- package/dist/recipe/types.js.map +1 -0
- package/dist/tools/cli.d.ts +43 -0
- package/dist/tools/cli.d.ts.map +1 -0
- package/dist/tools/cli.js +61 -0
- package/dist/tools/cli.js.map +1 -0
- package/dist/tools/mcp.d.ts +3 -2
- package/dist/tools/mcp.d.ts.map +1 -1
- package/dist/tools/mcp.js +3 -2
- package/dist/tools/mcp.js.map +1 -1
- package/dist/wallet/contract.d.ts +57 -0
- package/dist/wallet/contract.d.ts.map +1 -0
- package/dist/wallet/contract.js +113 -0
- package/dist/wallet/contract.js.map +1 -0
- package/package.json +9 -5
- package/src/capabilities.ts +67 -0
- package/src/context/budget.ts +46 -0
- package/src/context/builder.ts +100 -0
- package/src/context/context.test.ts +83 -0
- package/src/fastpath/fastpath.test.ts +34 -0
- package/src/fastpath/fastpath.ts +70 -0
- package/src/funnel.test.ts +207 -0
- package/src/funnel.ts +260 -0
- package/src/index.ts +85 -0
- package/src/knowledge/bitcoin-copilot.ts +177 -0
- package/src/knowledge/knowledge.test.ts +63 -0
- package/src/knowledge/merchants.ts +49 -0
- package/src/knowledge/wallet.ts +84 -0
- package/src/memory/memory.test.ts +85 -0
- package/src/memory/store.ts +129 -0
- package/src/memory/tool.ts +76 -0
- package/src/memory/types.ts +63 -0
- package/src/rag/rag.test.ts +85 -0
- package/src/rag/retriever.ts +94 -0
- package/src/rag/tool.ts +55 -0
- package/src/rag/types.ts +49 -0
- package/src/rag/vector-store.ts +78 -0
- package/src/recipe/asset-send.ts +79 -0
- package/src/recipe/payments.ts +116 -0
- package/src/recipe/receive.ts +98 -0
- package/src/recipe/recipe.test.ts +193 -0
- package/src/recipe/runner.ts +122 -0
- package/src/recipe/swap.ts +74 -0
- package/src/recipe/types.ts +76 -0
- package/src/tools/cli.test.ts +53 -0
- package/src/tools/cli.ts +98 -0
- package/src/tools/mcp.ts +3 -2
- package/src/wallet/contract.test.ts +89 -0
- package/src/wallet/contract.ts +157 -0
package/dist/funnel.js
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
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 = 'You are KaleidoSwap, a concise, privacy-first assistant running inside a ' +
|
|
30
|
+
'non-custodial Bitcoin, Lightning and RGB wallet. Use the provided tools to ' +
|
|
31
|
+
'take actions: pay invoices and contacts, create invoices, check balances. ' +
|
|
32
|
+
'Never invent a balance, address, amount or result — always call the ' +
|
|
33
|
+
'relevant tool and report what it returns. All BTC amounts are in satoshis. ' +
|
|
34
|
+
'Keep replies short and friendly.';
|
|
35
|
+
/** Tools that stay available even when a skill narrows the set. */
|
|
36
|
+
const AMBIENT_MEMORY = ['remember', 'recall'];
|
|
37
|
+
const AMBIENT_RAG = ['search_knowledge'];
|
|
38
|
+
const DEFAULT_HISTORY = 8;
|
|
39
|
+
function defaultRenderFast(intent, r) {
|
|
40
|
+
if (intent === 'balance') {
|
|
41
|
+
const sats = Number(r?.total_sats ?? 0);
|
|
42
|
+
const n = r?.layers?.length ?? 0;
|
|
43
|
+
return `You have ${sats.toLocaleString()} sats${n > 1 ? ` across ${n} layers` : ''}.`;
|
|
44
|
+
}
|
|
45
|
+
if (intent === 'address') {
|
|
46
|
+
return r?.address ? `Here's your receive address:\n\n\`${r.address}\`` : 'No address available right now.';
|
|
47
|
+
}
|
|
48
|
+
return `Bitcoin is $${Number(r?.price_usd ?? 0).toLocaleString()}.`;
|
|
49
|
+
}
|
|
50
|
+
export class Funnel {
|
|
51
|
+
provider;
|
|
52
|
+
registry;
|
|
53
|
+
engine;
|
|
54
|
+
fastPath;
|
|
55
|
+
recipes;
|
|
56
|
+
allSkills;
|
|
57
|
+
system;
|
|
58
|
+
getSettings;
|
|
59
|
+
renderFast;
|
|
60
|
+
log;
|
|
61
|
+
/** Skill registry, rebuilt only when the disabled-skills set changes. */
|
|
62
|
+
skillsCache = null;
|
|
63
|
+
constructor(opts) {
|
|
64
|
+
this.provider = opts.provider;
|
|
65
|
+
this.registry = opts.tools;
|
|
66
|
+
this.engine = new Engine({
|
|
67
|
+
provider: opts.provider,
|
|
68
|
+
tools: opts.tools,
|
|
69
|
+
defaultMaxTurns: opts.maxTurns ?? 5,
|
|
70
|
+
});
|
|
71
|
+
this.fastPath = new FastPath(opts.fastIntents ?? WALLET_FAST_INTENTS);
|
|
72
|
+
this.recipes = new RecipeRegistry(opts.recipes ?? [assetSendRecipe, paymentsRecipe, receiveRecipe]);
|
|
73
|
+
this.allSkills = opts.skills ?? [];
|
|
74
|
+
this.system = opts.system ?? DEFAULT_WALLET_SYSTEM;
|
|
75
|
+
this.getSettings = opts.getSettings ?? (() => ({}));
|
|
76
|
+
this.renderFast = opts.renderFast ?? defaultRenderFast;
|
|
77
|
+
this.log = opts.log ?? (() => { });
|
|
78
|
+
}
|
|
79
|
+
/** Skills currently enabled (e.g. for a skills sheet). */
|
|
80
|
+
listSkills() {
|
|
81
|
+
return this.skillsFor(this.getSettings().disabledSkills).list();
|
|
82
|
+
}
|
|
83
|
+
skillsFor(disabled = []) {
|
|
84
|
+
const key = [...disabled].sort().join(',');
|
|
85
|
+
if (this.skillsCache?.key !== key) {
|
|
86
|
+
this.skillsCache = {
|
|
87
|
+
key,
|
|
88
|
+
reg: new SkillRegistry(this.allSkills.filter((s) => !disabled.includes(s.name))),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return this.skillsCache.reg;
|
|
92
|
+
}
|
|
93
|
+
async runTurn(text, cbs = {}) {
|
|
94
|
+
const settings = this.getSettings();
|
|
95
|
+
// ── T0: deterministic fast-path (no LLM) ──
|
|
96
|
+
// Only fires when the host's registry actually implements the intent's
|
|
97
|
+
// tool — a partial tool surface (e.g. desktop without the core aggregate
|
|
98
|
+
// helpers) falls through to the agentic tier instead of erroring.
|
|
99
|
+
const fast = this.fastPath.select(text);
|
|
100
|
+
if (fast && (await this.registry.getDef(fast.tool))) {
|
|
101
|
+
this.log(`tier=fast-path → ${fast.tool}`);
|
|
102
|
+
const r = await this.registry.execute(fast.tool, fast.args);
|
|
103
|
+
return { text: this.renderFast(fast.intent.name, r), tier: 'fast', intent: fast.intent.name, data: r };
|
|
104
|
+
}
|
|
105
|
+
// ── T2: recipe multi-step — fires only when the recipe is confident given
|
|
106
|
+
// its extracted slots (payments need a recipient; receive always fires),
|
|
107
|
+
// and the registry implements the recipe's final action.
|
|
108
|
+
const recipe = this.recipes.select(text);
|
|
109
|
+
const slots = recipe?.extract?.(text) ?? null;
|
|
110
|
+
const fires = !!recipe &&
|
|
111
|
+
!!slots &&
|
|
112
|
+
(recipe.confident ? recipe.confident(slots) : Object.keys(slots).length > 0) &&
|
|
113
|
+
!!(await this.registry.getDef(recipe.final.tool));
|
|
114
|
+
if (recipe && fires) {
|
|
115
|
+
this.log(`tier=recipe:${recipe.name} slots=${JSON.stringify(slots)}`);
|
|
116
|
+
const res = await runRecipe(recipe, text, {
|
|
117
|
+
provider: this.provider,
|
|
118
|
+
tools: this.registry,
|
|
119
|
+
onConfirm: cbs.onConfirm,
|
|
120
|
+
onStep: (name) => {
|
|
121
|
+
this.log(`step ${name}`);
|
|
122
|
+
cbs.onStep?.(name);
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
return { text: res.text, tier: 'recipe' };
|
|
126
|
+
}
|
|
127
|
+
// ── T1: skill-scoped agentic loop ──
|
|
128
|
+
const skills = this.skillsFor(settings.disabledSkills);
|
|
129
|
+
const skill = skills.select(text);
|
|
130
|
+
const base = settings.persona ? `${this.system}\n\n## Your persona\n${settings.persona}` : this.system;
|
|
131
|
+
const { system, allowedTools } = skills.compose(base, skill);
|
|
132
|
+
// Ambient tools stay available even when a skill narrows the set — gated
|
|
133
|
+
// by the user's memory/knowledge toggles (default on).
|
|
134
|
+
const memoryOn = settings.memoryEnabled !== false;
|
|
135
|
+
const ragOn = settings.ragEnabled !== false;
|
|
136
|
+
const ambient = [...(memoryOn ? AMBIENT_MEMORY : []), ...(ragOn ? AMBIENT_RAG : [])];
|
|
137
|
+
const disabledAmbient = [...(memoryOn ? [] : AMBIENT_MEMORY), ...(ragOn ? [] : AMBIENT_RAG)];
|
|
138
|
+
let scoped;
|
|
139
|
+
if (allowedTools) {
|
|
140
|
+
scoped = [...new Set([...allowedTools, ...ambient])];
|
|
141
|
+
}
|
|
142
|
+
else if (disabledAmbient.length) {
|
|
143
|
+
// No skill matched but a toggle is off: expose everything except the
|
|
144
|
+
// disabled ambient tools (the sources stay mounted — no rebuild).
|
|
145
|
+
const all = (await this.registry.listTools()).map((t) => t.name);
|
|
146
|
+
scoped = all.filter((n) => !disabledAmbient.includes(n));
|
|
147
|
+
}
|
|
148
|
+
// Trim history so the prompt (system + skill + tools + history) stays
|
|
149
|
+
// within the small on-device model's context window.
|
|
150
|
+
const keep = settings.historyLength ?? DEFAULT_HISTORY;
|
|
151
|
+
const history = (cbs.history ?? []).slice(-keep);
|
|
152
|
+
const messages = [
|
|
153
|
+
{ role: 'system', content: system },
|
|
154
|
+
...history,
|
|
155
|
+
{ role: 'user', content: text },
|
|
156
|
+
];
|
|
157
|
+
this.log(`tier=agentic skill=${skill?.name ?? 'none'} tools=[${(scoped ?? ['all']).join(',')}]`);
|
|
158
|
+
const res = await this.engine.runAgentic(messages, {
|
|
159
|
+
allowedTools: scoped,
|
|
160
|
+
onStart: (requestId) => cbs.onStart?.(requestId),
|
|
161
|
+
onToken: cbs.onToken,
|
|
162
|
+
onToolCall: (call) => {
|
|
163
|
+
this.log(`tool ${call.name} ${JSON.stringify(call.arguments)}`);
|
|
164
|
+
// getDef is async; fire-and-forget so the loop is never blocked on UI.
|
|
165
|
+
void this.registry
|
|
166
|
+
.getDef(call.name)
|
|
167
|
+
.then((def) => cbs.onToolCall?.(call, { requiresConfirmation: !!def?.requiresConfirmation }))
|
|
168
|
+
.catch(() => cbs.onToolCall?.(call, { requiresConfirmation: false }));
|
|
169
|
+
},
|
|
170
|
+
onConfirm: cbs.onConfirm,
|
|
171
|
+
});
|
|
172
|
+
return { text: res.text ?? '', tier: 'agentic', toolCalls: res.toolCalls, turns: res.turns };
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
//# 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,mB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AAU,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,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,44 @@ 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 { runRecipe, extractSlots, RecipeRegistry } from './recipe/runner.js';
|
|
23
|
+
export type { RunRecipeOptions } from './recipe/runner.js';
|
|
24
|
+
export { paymentsRecipe, extractPayment } from './recipe/payments.js';
|
|
25
|
+
export { swapRecipe, extractSwap } from './recipe/swap.js';
|
|
26
|
+
export { receiveRecipe, extractReceive } from './recipe/receive.js';
|
|
27
|
+
export { assetSendRecipe, extractAssetSend } from './recipe/asset-send.js';
|
|
28
|
+
export type { Recipe, RecipeStep, RecipeSlot, RecipeContext, RecipeResult, RecipeStatus } from './recipe/types.js';
|
|
29
|
+
export { FastPath, WALLET_FAST_INTENTS } from './fastpath/fastpath.js';
|
|
30
|
+
export type { FastIntent, FastHit } from './fastpath/fastpath.js';
|
|
31
|
+
export { InMemoryMemoryStore } from './memory/store.js';
|
|
32
|
+
export type { MemoryStoreOptions } from './memory/store.js';
|
|
33
|
+
export { createMemoryToolSource } from './memory/tool.js';
|
|
34
|
+
export type { AgentProfile, MemoryItem, MemoryKind, MemoryQuery, MemoryStore, MemoryIO, NewMemory, } from './memory/types.js';
|
|
35
|
+
export { Retriever, chunkText } from './rag/retriever.js';
|
|
36
|
+
export type { RetrieverOptions } from './rag/retriever.js';
|
|
37
|
+
export { InMemoryVectorStore, cosineSimilarity } from './rag/vector-store.js';
|
|
38
|
+
export { createRagToolSource } from './rag/tool.js';
|
|
39
|
+
export type { RagToolOptions } from './rag/tool.js';
|
|
40
|
+
export type { EmbeddingProvider, Chunk, RetrievedChunk, RagDocument, VectorStore, VectorStoreIO, } from './rag/types.js';
|
|
41
|
+
export { ContextBuilder } from './context/builder.js';
|
|
42
|
+
export type { ContextBuilderOptions, BuildInput } from './context/builder.js';
|
|
43
|
+
export { estimateTokens, clampToTokens, contextBudgetTokens, } from './context/budget.js';
|
|
44
|
+
export type { BudgetReserves } from './context/budget.js';
|
|
45
|
+
export { capabilityProfile } from './capabilities.js';
|
|
46
|
+
export type { CapabilityInput, MindCapabilities } from './capabilities.js';
|
|
47
|
+
export { BITCOIN_COPILOT_DOCS } from './knowledge/bitcoin-copilot.js';
|
|
48
|
+
export { walletHistoryToDocuments, contactsToDocuments } from './knowledge/wallet.js';
|
|
49
|
+
export type { WalletTx, Contact } from './knowledge/wallet.js';
|
|
50
|
+
export { merchantsToDocuments } from './knowledge/merchants.js';
|
|
51
|
+
export type { Merchant } from './knowledge/merchants.js';
|
|
18
52
|
export { Engine } from './engine.js';
|
|
19
53
|
export type { EngineOptions, AgenticOptions, AgenticResult } from './engine.js';
|
|
54
|
+
export { Funnel, DEFAULT_WALLET_SYSTEM } from './funnel.js';
|
|
55
|
+
export type { FunnelOptions, FunnelSettings, FunnelCallbacks, FunnelResult } from './funnel.js';
|
|
20
56
|
export { SkillRegistry, parseSkill, keywordSelector, READ_REFERENCE_TOOL, } from './skills/registry.js';
|
|
21
57
|
export { createSkillReferenceToolSource } from './skills/reference-source.js';
|
|
22
58
|
export { skillsFromBundle } from './skills/bundle.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,YAAY,EACV,IAAI,EACJ,OAAO,EACP,OAAO,EACP,QAAQ,EACR,UAAU,EACV,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAE/E,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EACL,oBAAoB,EACpB,kBAAkB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ACtD,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,35 @@
|
|
|
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
|
+
// ── Recipes (mobile multi-step: "recipes, not planning") ───────────────────
|
|
17
|
+
export { runRecipe, extractSlots, RecipeRegistry } from './recipe/runner.js';
|
|
18
|
+
export { paymentsRecipe, extractPayment } from './recipe/payments.js';
|
|
19
|
+
export { swapRecipe, extractSwap } from './recipe/swap.js';
|
|
20
|
+
export { receiveRecipe, extractReceive } from './recipe/receive.js';
|
|
21
|
+
export { assetSendRecipe, extractAssetSend } from './recipe/asset-send.js';
|
|
22
|
+
// ── Tier-0 deterministic fast-path (no LLM) ────────────────────────────────
|
|
23
|
+
export { FastPath, WALLET_FAST_INTENTS } from './fastpath/fastpath.js';
|
|
24
|
+
// ── Memory (soul + recall) ───────────────────────────────────────────────
|
|
25
|
+
export { InMemoryMemoryStore } from './memory/store.js';
|
|
26
|
+
export { createMemoryToolSource } from './memory/tool.js';
|
|
27
|
+
// ── RAG ──────────────────────────────────────────────────────────────────
|
|
28
|
+
export { Retriever, chunkText } from './rag/retriever.js';
|
|
29
|
+
export { InMemoryVectorStore, cosineSimilarity } from './rag/vector-store.js';
|
|
30
|
+
export { createRagToolSource } from './rag/tool.js';
|
|
31
|
+
// ── Context assembly + hardware budget ─────────────────────────────────────
|
|
32
|
+
export { ContextBuilder } from './context/builder.js';
|
|
33
|
+
export { estimateTokens, clampToTokens, contextBudgetTokens, } from './context/budget.js';
|
|
34
|
+
export { capabilityProfile } from './capabilities.js';
|
|
35
|
+
// ── Knowledge packs + corpus adapters (for RAG) ────────────────────────────
|
|
36
|
+
export { BITCOIN_COPILOT_DOCS } from './knowledge/bitcoin-copilot.js';
|
|
37
|
+
export { walletHistoryToDocuments, contactsToDocuments } from './knowledge/wallet.js';
|
|
38
|
+
export { merchantsToDocuments } from './knowledge/merchants.js';
|
|
13
39
|
export { Engine } from './engine.js';
|
|
40
|
+
// ── Funnel (T0 fast-path → T2 recipe → T1 agentic — the tiered agent) ───────
|
|
41
|
+
export { Funnel, DEFAULT_WALLET_SYSTEM } from './funnel.js';
|
|
14
42
|
export { SkillRegistry, parseSkill, keywordSelector, READ_REFERENCE_TOOL, } from './skills/registry.js';
|
|
15
43
|
export { createSkillReferenceToolSource } from './skills/reference-source.js';
|
|
16
44
|
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;
|
|
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,OAA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AE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGhE,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,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"}
|
|
@@ -0,0 +1,155 @@
|
|
|
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
|
+
export const BITCOIN_COPILOT_DOCS = [
|
|
10
|
+
{
|
|
11
|
+
id: 'inbound-liquidity',
|
|
12
|
+
text: 'To RECEIVE Lightning payments you need inbound liquidity — remote balance ' +
|
|
13
|
+
'on a channel pointing at you. Brand-new wallets have none, so they can ' +
|
|
14
|
+
'send but not receive. Get inbound liquidity by buying a channel from an ' +
|
|
15
|
+
'LSP, or by receiving an on-chain deposit and swapping it into a channel.',
|
|
16
|
+
metadata: { topic: 'liquidity' },
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: 'outbound-liquidity',
|
|
20
|
+
text: 'Outbound liquidity is your local balance on a channel — what you can ' +
|
|
21
|
+
'spend over Lightning. You get it by funding a channel yourself or being ' +
|
|
22
|
+
'pushed funds. If you can receive but not send, you lack outbound liquidity.',
|
|
23
|
+
metadata: { topic: 'liquidity' },
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: 'channel-basics',
|
|
27
|
+
text: 'A Lightning channel is a 2-of-2 multisig funding output shared by two ' +
|
|
28
|
+
'peers. It lets them send instant, low-fee payments off-chain by updating ' +
|
|
29
|
+
'who owns how much, without touching the blockchain until the channel closes.',
|
|
30
|
+
metadata: { topic: 'lightning' },
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: 'onchain-vs-lightning',
|
|
34
|
+
text: 'On-chain Bitcoin transactions settle directly on the blockchain: final, ' +
|
|
35
|
+
'but slower and with miner fees. Lightning payments are instant and cheap ' +
|
|
36
|
+
'but require channels with liquidity. Use Lightning for spending, on-chain ' +
|
|
37
|
+
'for settlement and for funding channels.',
|
|
38
|
+
metadata: { topic: 'lightning' },
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'open-channel',
|
|
42
|
+
text: 'Opening a channel funds a 2-of-2 output on-chain; it confirms in one or ' +
|
|
43
|
+
'more blocks (or is usable immediately with 0-conf if the peer allows). ' +
|
|
44
|
+
'The funder gets outbound liquidity. To get inbound, buy a channel from an ' +
|
|
45
|
+
'LSP instead of opening your own.',
|
|
46
|
+
metadata: { topic: 'channels' },
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: 'lsp-lsps1',
|
|
50
|
+
text: 'An LSP (Lightning Service Provider) sells channels. With LSPS1 you place ' +
|
|
51
|
+
'a channel order: choose capacity and how much inbound liquidity you want, ' +
|
|
52
|
+
'pay the fee, and the LSP opens a channel to you — often 0-conf, so you can ' +
|
|
53
|
+
'receive right away. KaleidoSwap acts as an LSP.',
|
|
54
|
+
metadata: { topic: 'channels' },
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: 'atomic-swap',
|
|
58
|
+
text: 'An atomic (HTLC) swap exchanges two assets so that either both legs ' +
|
|
59
|
+
'happen or neither does — no counterparty can run off with your funds. ' +
|
|
60
|
+
'KaleidoSwap uses a 5-step HTLC taker flow for trustless swaps.',
|
|
61
|
+
metadata: { topic: 'swaps' },
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: 'submarine-swap',
|
|
65
|
+
text: 'A submarine swap moves value between on-chain Bitcoin and Lightning ' +
|
|
66
|
+
'atomically via an HTLC: send on-chain BTC and receive it on Lightning, or ' +
|
|
67
|
+
'vice-versa, with no custodian. Useful to refill inbound/outbound liquidity.',
|
|
68
|
+
metadata: { topic: 'swaps' },
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 'rgb-assets',
|
|
72
|
+
text: 'RGB is a protocol for issuing assets — like USDT and XAUT — on top of ' +
|
|
73
|
+
'Bitcoin and Lightning. Validation is client-side, which keeps it private ' +
|
|
74
|
+
'and scalable. On KaleidoSwap you can hold and swap RGB assets.',
|
|
75
|
+
metadata: { topic: 'rgb' },
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: 'colored-channels',
|
|
79
|
+
text: 'A colored channel is a Lightning channel that also carries an RGB asset ' +
|
|
80
|
+
'balance, so you can send/receive USDT or XAUT over Lightning instantly. ' +
|
|
81
|
+
'Buying an asset channel from the LSP gives you inbound capacity for that asset.',
|
|
82
|
+
metadata: { topic: 'rgb' },
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: 'rgb-invoice',
|
|
86
|
+
text: 'An RGB invoice requests a specific asset and amount and includes a ' +
|
|
87
|
+
'blinded UTXO so the sender can transfer the asset privately. It differs ' +
|
|
88
|
+
'from a plain Lightning (BOLT11) invoice, which is for BTC.',
|
|
89
|
+
metadata: { topic: 'rgb' },
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: 'rfq-quote',
|
|
93
|
+
text: 'Before a swap, KaleidoSwap gives a quote via RFQ (request for quote): the ' +
|
|
94
|
+
'maker prices the pair (e.g. BTC/USDT) and returns the amount you will ' +
|
|
95
|
+
'receive and the fees. Quotes expire — re-quote if you wait.',
|
|
96
|
+
metadata: { topic: 'trading' },
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: 'maker-taker',
|
|
100
|
+
text: 'KaleidoSwap is maker-based: a maker provides liquidity and prices, you ' +
|
|
101
|
+
'are the taker who accepts a quote and executes the atomic swap. The maker ' +
|
|
102
|
+
'also runs the LSP that sells channels.',
|
|
103
|
+
metadata: { topic: 'trading' },
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
id: 'mpp',
|
|
107
|
+
text: 'Multi-path payments (MPP) split one Lightning payment across several ' +
|
|
108
|
+
'channels/routes so you can send more than any single channel allows. The ' +
|
|
109
|
+
'parts recombine at the destination atomically.',
|
|
110
|
+
metadata: { topic: 'lightning' },
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
id: 'lightning-fees',
|
|
114
|
+
text: 'Lightning fees are tiny: a base fee plus a proportional fee per hop, paid ' +
|
|
115
|
+
'to routing nodes. They are far smaller than on-chain miner fees, which is ' +
|
|
116
|
+
'why Lightning suits everyday spending.',
|
|
117
|
+
metadata: { topic: 'fees' },
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
id: 'zero-conf',
|
|
121
|
+
text: '0-conf (zero-confirmation) means a channel is usable before its funding ' +
|
|
122
|
+
'transaction is mined. It relies on trusting the channel partner not to ' +
|
|
123
|
+
'double-spend; LSPs commonly offer it so you can receive instantly.',
|
|
124
|
+
metadata: { topic: 'channels' },
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
id: 'seed-backup',
|
|
128
|
+
text: 'Your seed phrase (12/24 words) controls your funds. Write it down offline ' +
|
|
129
|
+
'and never share or photograph it. A KaleidoSwap node also needs channel ' +
|
|
130
|
+
'state backups: losing them can mean losing funds in open channels.',
|
|
131
|
+
metadata: { topic: 'security' },
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
id: 'receiving',
|
|
135
|
+
text: 'To receive: share a Lightning invoice (BOLT11) or an on-chain address. ' +
|
|
136
|
+
'For Lightning you need inbound liquidity first. For RGB assets, share an ' +
|
|
137
|
+
'RGB invoice. On-chain always works but is slower.',
|
|
138
|
+
metadata: { topic: 'usage' },
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
id: 'sending',
|
|
142
|
+
text: 'To send: pay a Lightning invoice or a Lightning address for BTC, or use ' +
|
|
143
|
+
'an on-chain address. You need outbound liquidity for Lightning. Always ' +
|
|
144
|
+
'check the amount and destination before paying.',
|
|
145
|
+
metadata: { topic: 'usage' },
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
id: 'dca',
|
|
149
|
+
text: 'Dollar-cost averaging (DCA) buys a fixed amount on a schedule to smooth ' +
|
|
150
|
+
'out price swings. KaleidoSwap can automate recurring swaps so you ' +
|
|
151
|
+
'accumulate BTC or an asset over time without timing the market.',
|
|
152
|
+
metadata: { topic: 'trading' },
|
|
153
|
+
},
|
|
154
|
+
];
|
|
155
|
+
//# sourceMappingURL=bitcoin-copilot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitcoin-copilot.js","sourceRoot":"","sources":["../../src/knowledge/bitcoin-copilot.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,CAAC,MAAM,oBAAoB,GAAkB;IACjD;QACE,EAAE,EAAE,mBAAmB;QACvB,IAAI,EACF,4EAA4E;YAC5E,yEAAyE;YACzE,0EAA0E;YAC1E,0EAA0E;QAC5E,QAAQ,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE;KACjC;IACD;QACE,EAAE,EAAE,oBAAoB;QACxB,IAAI,EACF,uEAAuE;YACvE,0EAA0E;YAC1E,6EAA6E;QAC/E,QAAQ,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE;KACjC;IACD;QACE,EAAE,EAAE,gBAAgB;QACpB,IAAI,EACF,wEAAwE;YACxE,2EAA2E;YAC3E,8EAA8E;QAChF,QAAQ,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE;KACjC;IACD;QACE,EAAE,EAAE,sBAAsB;QAC1B,IAAI,EACF,0EAA0E;YAC1E,2EAA2E;YAC3E,4EAA4E;YAC5E,0CAA0C;QAC5C,QAAQ,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE;KACjC;IACD;QACE,EAAE,EAAE,cAAc;QAClB,IAAI,EACF,0EAA0E;YAC1E,yEAAyE;YACzE,4EAA4E;YAC5E,kCAAkC;QACpC,QAAQ,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE;KAChC;IACD;QACE,EAAE,EAAE,WAAW;QACf,IAAI,EACF,2EAA2E;YAC3E,4EAA4E;YAC5E,6EAA6E;YAC7E,iDAAiD;QACnD,QAAQ,EAAE,EAAE,KA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AwC;QAC1C,QAAQ,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;KAC5B;IACD;QACE,EAAE,EAAE,WAAW;QACf,IAAI,EACF,0EAA0E;YAC1E,yEAAyE;YACzE,oEAAoE;QACtE,QAAQ,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE;KAChC;IACD;QACE,EAAE,EAAE,aAAa;QACjB,IAAI,EACF,4EAA4E;YAC5E,0EAA0E;YAC1E,oEAAoE;QACtE,QAAQ,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE;KAChC;IACD;QACE,EAAE,EAAE,WAAW;QACf,IAAI,EACF,yEAAyE;YACzE,2EAA2E;YAC3E,mDAAmD;QACrD,QAAQ,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;KAC7B;IACD;QACE,EAAE,EAAE,SAAS;QACb,IAAI,EACF,0EAA0E;YAC1E,yEAAyE;YACzE,iDAAiD;QACnD,QAAQ,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;KAC7B;IACD;QACE,EAAE,EAAE,KAAK;QACT,IAAI,EACF,0EAA0E;YAC1E,oEAAoE;YACpE,iEAAiE;QACnE,QAAQ,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE;KAC/B;CACF,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BTC map discovery — turn a merchant directory (e.g. BTCMap / a local dataset)
|
|
3
|
+
* into `RagDocument[]` so the agent can answer "where can I spend Bitcoin for
|
|
4
|
+
* coffee near me?" with on-device semantic search over places.
|
|
5
|
+
*
|
|
6
|
+
* Pure transform over a generic Merchant shape. Coordinates are kept in
|
|
7
|
+
* metadata so the host can still pin results on a map after retrieval.
|
|
8
|
+
*/
|
|
9
|
+
import type { RagDocument } from '../rag/types.js';
|
|
10
|
+
export interface Merchant {
|
|
11
|
+
id?: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
category?: string;
|
|
14
|
+
address?: string;
|
|
15
|
+
city?: string;
|
|
16
|
+
lat?: number;
|
|
17
|
+
lng?: number;
|
|
18
|
+
/** e.g. ['onchain', 'lightning', 'rgb']. */
|
|
19
|
+
acceptedAssets?: string[];
|
|
20
|
+
description?: string;
|
|
21
|
+
}
|
|
22
|
+
/** One searchable doc per merchant; lat/lng preserved in metadata for mapping. */
|
|
23
|
+
export declare function merchantsToDocuments(merchants: Merchant[]): RagDocument[];
|
|
24
|
+
//# sourceMappingURL=merchants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merchants.d.ts","sourceRoot":"","sources":["../../src/knowledge/merchants.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,WAAW,QAAQ;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,kFAAkF;AAClF,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,WAAW,EAAE,CAuBzE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BTC map discovery — turn a merchant directory (e.g. BTCMap / a local dataset)
|
|
3
|
+
* into `RagDocument[]` so the agent can answer "where can I spend Bitcoin for
|
|
4
|
+
* coffee near me?" with on-device semantic search over places.
|
|
5
|
+
*
|
|
6
|
+
* Pure transform over a generic Merchant shape. Coordinates are kept in
|
|
7
|
+
* metadata so the host can still pin results on a map after retrieval.
|
|
8
|
+
*/
|
|
9
|
+
/** One searchable doc per merchant; lat/lng preserved in metadata for mapping. */
|
|
10
|
+
export function merchantsToDocuments(merchants) {
|
|
11
|
+
return merchants
|
|
12
|
+
.filter((m) => m.name)
|
|
13
|
+
.map((m, i) => {
|
|
14
|
+
const where = [m.address, m.city].filter(Boolean).join(', ');
|
|
15
|
+
const pays = m.acceptedAssets?.length
|
|
16
|
+
? `Accepts ${m.acceptedAssets.join(', ')}.`
|
|
17
|
+
: 'Accepts Bitcoin.';
|
|
18
|
+
const cat = m.category ? ` (${m.category})` : '';
|
|
19
|
+
const desc = m.description ? ` ${m.description}` : '';
|
|
20
|
+
return {
|
|
21
|
+
id: m.id ?? `merchant_${m.name ?? i}`,
|
|
22
|
+
text: `${m.name}${cat}${where ? ` at ${where}` : ''}. ${pays}${desc}`.trim(),
|
|
23
|
+
metadata: {
|
|
24
|
+
kind: 'merchant',
|
|
25
|
+
name: m.name,
|
|
26
|
+
category: m.category,
|
|
27
|
+
city: m.city,
|
|
28
|
+
lat: m.lat,
|
|
29
|
+
lng: m.lng,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=merchants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merchants.js","sourceRoot":"","sources":["../../src/knowledge/merchants.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiBH,kFAAkF;AAClF,MAAM,UAAU,oBAAoB,CAAC,SAAqB;IACxD,OAAO,SAAS;SACb,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;SACrB,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACZ,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7D,MAAM,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,MAAM;YACnC,CAAC,CAAC,WAAW,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;YAC3C,CAAC,CAAC,kBAAkB,CAAC;QACvB,MAAM,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtD,OAAO;YACL,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,YAAY,CAAC,CAAC,IAAI,IAAI,CAAC,EAAE;YACrC,IAAI,EAAE,GAAG,CAAC,CAAC,IAAI,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,GAAG,IAAI,EAAE,CAAC,IAAI,EAAE;YAC5E,QAAQ,EAAE;gBACR,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,QAAQ,EAAE,CAAC,CAAC,QAAQ;gBACpB,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,GAAG,EAAE,CAAC,CAAC,GAAG;gBACV,GAAG,EAAE,CAAC,CAAC,GAAG;aACX;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Personal wallet knowledge — turn a user's transaction history + contacts into
|
|
3
|
+
* `RagDocument[]` so the agent can answer "what did I spend on coffee last
|
|
4
|
+
* month?", "who did I pay 50k sats to?", "summarise my swaps" — all on-device,
|
|
5
|
+
* nothing leaving the phone.
|
|
6
|
+
*
|
|
7
|
+
* Pure transforms over minimal, generic shapes (hosts map their own types in).
|
|
8
|
+
* No deps, no PII leaves: the host decides what to ingest.
|
|
9
|
+
*/
|
|
10
|
+
import type { RagDocument } from '../rag/types.js';
|
|
11
|
+
export interface WalletTx {
|
|
12
|
+
id?: string;
|
|
13
|
+
/** 'send' | 'receive' | 'swap' | 'deposit' | 'withdraw' | … */
|
|
14
|
+
type?: string;
|
|
15
|
+
amountSats?: number;
|
|
16
|
+
asset?: string;
|
|
17
|
+
/** Who/where — a name, contact, address, or merchant. */
|
|
18
|
+
counterparty?: string;
|
|
19
|
+
memo?: string;
|
|
20
|
+
status?: string;
|
|
21
|
+
/** Epoch ms. */
|
|
22
|
+
timestamp?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface Contact {
|
|
25
|
+
name?: string;
|
|
26
|
+
lightningAddress?: string;
|
|
27
|
+
npub?: string;
|
|
28
|
+
note?: string;
|
|
29
|
+
}
|
|
30
|
+
/** One short, searchable sentence per transaction. */
|
|
31
|
+
export declare function walletHistoryToDocuments(txs: WalletTx[]): RagDocument[];
|
|
32
|
+
/** One doc per contact, so "who is Bob?" / "pay my friend" can resolve. */
|
|
33
|
+
export declare function contactsToDocuments(contacts: Contact[]): RagDocument[];
|
|
34
|
+
//# sourceMappingURL=wallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/knowledge/wallet.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,WAAW,QAAQ;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAYD,sDAAsD;AACtD,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,WAAW,EAAE,CAsBvE;AAED,2EAA2E;AAC3E,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,WAAW,EAAE,CActE"}
|