@kaleidorg/mind 0.6.4 → 0.8.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/README.md +345 -0
- package/dist/autonomy/risk.js.map +1 -1
- package/dist/autonomy/run-state.d.ts.map +1 -1
- package/dist/autonomy/run-state.js.map +1 -1
- package/dist/autonomy/task-store.d.ts.map +1 -1
- package/dist/autonomy/task-store.js.map +1 -1
- package/dist/bitrefill/contract.js.map +1 -1
- package/dist/context/budget.js.map +1 -1
- package/dist/context/builder.d.ts.map +1 -1
- package/dist/context/builder.js.map +1 -1
- package/dist/context/compress.d.ts.map +1 -1
- package/dist/context/compress.js +1 -0
- package/dist/context/compress.js.map +1 -1
- package/dist/context/rgb-units.d.ts +18 -0
- package/dist/context/rgb-units.d.ts.map +1 -0
- package/dist/context/rgb-units.js +86 -0
- package/dist/context/rgb-units.js.map +1 -0
- package/dist/engine.d.ts +53 -1
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +179 -17
- package/dist/engine.js.map +1 -1
- package/dist/evidence.d.ts +1 -1
- package/dist/evidence.d.ts.map +1 -1
- package/dist/evidence.js.map +1 -1
- package/dist/fastpath/fastpath.d.ts.map +1 -1
- package/dist/fastpath/fastpath.js.map +1 -1
- package/dist/flashnet/contract.js.map +1 -1
- package/dist/funnel.d.ts.map +1 -1
- package/dist/funnel.js +23 -4
- package/dist/funnel.js.map +1 -1
- package/dist/guards.d.ts +63 -0
- package/dist/guards.d.ts.map +1 -0
- package/dist/guards.js +284 -0
- package/dist/guards.js.map +1 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/kaleidoswap/contract.d.ts +3 -4
- package/dist/kaleidoswap/contract.d.ts.map +1 -1
- package/dist/kaleidoswap/contract.js +3 -17
- package/dist/kaleidoswap/contract.js.map +1 -1
- package/dist/knowledge/btc-map.js.map +1 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js.map +1 -1
- package/dist/lsps1/contract.js.map +1 -1
- package/dist/memory/store.d.ts.map +1 -1
- package/dist/memory/store.js.map +1 -1
- package/dist/providers/openai.d.ts +64 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +233 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/providers/types.d.ts +20 -0
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/qvac/assistant.js.map +1 -1
- package/dist/qvac/config.d.ts +7 -7
- package/dist/qvac/config.d.ts.map +1 -1
- package/dist/qvac/config.js +1 -1
- package/dist/qvac/delegate.d.ts +2 -0
- package/dist/qvac/delegate.d.ts.map +1 -1
- package/dist/qvac/delegate.js +2 -0
- package/dist/qvac/delegate.js.map +1 -1
- package/dist/qvac/index.d.ts +2 -0
- package/dist/qvac/index.d.ts.map +1 -1
- package/dist/qvac/index.js +2 -0
- package/dist/qvac/index.js.map +1 -1
- package/dist/qvac/models.d.ts +31 -0
- package/dist/qvac/models.d.ts.map +1 -0
- package/dist/qvac/models.js +80 -0
- package/dist/qvac/models.js.map +1 -0
- package/dist/qvac/parse.d.ts +16 -2
- package/dist/qvac/parse.d.ts.map +1 -1
- package/dist/qvac/parse.js +29 -7
- package/dist/qvac/parse.js.map +1 -1
- package/dist/qvac/provider.d.ts +5 -4
- package/dist/qvac/provider.d.ts.map +1 -1
- package/dist/qvac/provider.js +30 -21
- package/dist/qvac/provider.js.map +1 -1
- package/dist/qvac/stream.d.ts +3 -5
- package/dist/qvac/stream.d.ts.map +1 -1
- package/dist/qvac/stream.js +29 -1
- package/dist/qvac/stream.js.map +1 -1
- package/dist/qvac/tools.d.ts +37 -0
- package/dist/qvac/tools.d.ts.map +1 -0
- package/dist/qvac/tools.js +94 -0
- package/dist/qvac/tools.js.map +1 -0
- package/dist/qvac/voice.js.map +1 -1
- package/dist/rag/retriever.d.ts.map +1 -1
- package/dist/rag/tool.js.map +1 -1
- package/dist/rag/vector-store.d.ts.map +1 -1
- package/dist/rag/vector-store.js.map +1 -1
- package/dist/recipe/issue-asset.d.ts +16 -0
- package/dist/recipe/issue-asset.d.ts.map +1 -0
- package/dist/recipe/issue-asset.js +120 -0
- package/dist/recipe/issue-asset.js.map +1 -0
- package/dist/recipe/runner.d.ts.map +1 -1
- package/dist/recipe/runner.js +1 -0
- package/dist/recipe/runner.js.map +1 -1
- package/dist/recipe/submarine-pay.d.ts +17 -0
- package/dist/recipe/submarine-pay.d.ts.map +1 -0
- package/dist/recipe/submarine-pay.js +79 -0
- package/dist/recipe/submarine-pay.js.map +1 -0
- package/dist/skills/loader.js.map +1 -1
- package/dist/skills/registry.d.ts.map +1 -1
- package/dist/skills/registry.js +1 -1
- package/dist/skills/registry.js.map +1 -1
- package/dist/skills/select.d.ts +20 -0
- package/dist/skills/select.d.ts.map +1 -0
- package/dist/skills/select.js +32 -0
- package/dist/skills/select.js.map +1 -0
- package/dist/submarine/contract.d.ts +42 -0
- package/dist/submarine/contract.d.ts.map +1 -0
- package/dist/submarine/contract.js +73 -0
- package/dist/submarine/contract.js.map +1 -0
- package/dist/testing/index.d.ts +14 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +12 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/mock-wallet.d.ts +103 -0
- package/dist/testing/mock-wallet.d.ts.map +1 -0
- package/dist/testing/mock-wallet.js +249 -0
- package/dist/testing/mock-wallet.js.map +1 -0
- package/dist/testing/scripted-provider.d.ts +17 -0
- package/dist/testing/scripted-provider.d.ts.map +1 -0
- package/dist/testing/scripted-provider.js +26 -0
- package/dist/testing/scripted-provider.js.map +1 -0
- package/dist/tools/in-process.d.ts.map +1 -1
- package/dist/tools/mcp.d.ts.map +1 -1
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/registry.js.map +1 -1
- package/dist/wallet/confirm.d.ts.map +1 -1
- package/dist/wallet/confirm.js +43 -5
- package/dist/wallet/confirm.js.map +1 -1
- package/dist/wallet/contract.d.ts.map +1 -1
- package/dist/wallet/contract.js +36 -0
- package/dist/wallet/contract.js.map +1 -1
- package/package.json +15 -5
- package/skills/README.md +2 -1
- package/skills/kaleido-node/SKILL.md +63 -0
- package/skills/kaleido-trading/SKILL.md +34 -27
- package/skills/kaleido-trading/references/api.md +61 -0
- package/skills/kaleido-trading/references/assets.md +57 -0
- package/skills/kaleido-trading/references/atomic.md +93 -0
- package/skills/paid-data/SKILL.md +59 -6
- package/skills/rgb-lightning-node/SKILL.md +142 -17
- package/skills/spark-wallet/SKILL.md +1 -0
- package/skills/submarine-swaps/SKILL.md +48 -0
- package/src/context/compress.ts +1 -0
- package/src/context/rgb-units.test.ts +42 -0
- package/src/context/rgb-units.ts +89 -0
- package/src/engine.test.ts +94 -3
- package/src/engine.ts +234 -19
- package/src/funnel.mind.test.ts +4 -2
- package/src/funnel.ts +23 -4
- package/src/guards.test.ts +399 -0
- package/src/guards.ts +299 -0
- package/src/index.ts +40 -1
- package/src/kaleidoswap/contract.test.ts +8 -16
- package/src/kaleidoswap/contract.ts +4 -32
- package/src/providers/openai.test.ts +127 -0
- package/src/providers/openai.ts +282 -0
- package/src/providers/types.ts +22 -0
- package/src/qvac/config.ts +1 -1
- package/src/qvac/delegate.ts +2 -0
- package/src/qvac/index.ts +12 -0
- package/src/qvac/models.ts +98 -0
- package/src/qvac/parse.test.ts +7 -0
- package/src/qvac/parse.ts +38 -3
- package/src/qvac/provider.test.ts +72 -1
- package/src/qvac/provider.ts +40 -27
- package/src/qvac/stream.test.ts +28 -0
- package/src/qvac/stream.ts +33 -6
- package/src/qvac/tools.test.ts +86 -0
- package/src/qvac/tools.ts +116 -0
- package/src/recipe/issue-asset.test.ts +131 -0
- package/src/recipe/issue-asset.ts +123 -0
- package/src/recipe/runner.ts +1 -0
- package/src/recipe/submarine-pay.test.ts +87 -0
- package/src/recipe/submarine-pay.ts +78 -0
- package/src/skills/registry.ts +1 -1
- package/src/skills/select.ts +41 -0
- package/src/submarine/contract.ts +112 -0
- package/src/testing/index.ts +14 -0
- package/src/testing/mock-wallet.ts +278 -0
- package/src/testing/scripted-provider.ts +37 -0
- package/src/wallet/confirm.test.ts +16 -0
- package/src/wallet/confirm.ts +43 -5
- package/src/wallet/contract.test.ts +38 -0
- package/src/wallet/contract.ts +36 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool-aware skill selection: pick a skill that can actually act with the tools
|
|
3
|
+
* a host has, before any inference runs.
|
|
4
|
+
*/
|
|
5
|
+
import { READ_REFERENCE_TOOL, SkillRegistry } from './registry.js';
|
|
6
|
+
/**
|
|
7
|
+
* Whether a skill can act given the live tool names. A `requires-tools`
|
|
8
|
+
* frontmatter list must be fully live; otherwise at least one of the skill's
|
|
9
|
+
* scoped tools must be.
|
|
10
|
+
*/
|
|
11
|
+
export function skillAvailable(skill, present) {
|
|
12
|
+
const required = skill.metadata?.['requires-tools'];
|
|
13
|
+
if (required) {
|
|
14
|
+
return required.split(',').map((t) => t.trim()).filter(Boolean).every((t) => present.has(t));
|
|
15
|
+
}
|
|
16
|
+
if (!skill.tools?.length)
|
|
17
|
+
return true;
|
|
18
|
+
return skill.tools.some((t) => t !== READ_REFERENCE_TOOL && present.has(t));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Select the best skill for `query` among those that can act with `liveTools`.
|
|
22
|
+
* Skills whose `requires-tools` are missing are never picked; a skill with zero
|
|
23
|
+
* live tools is only a last resort.
|
|
24
|
+
*/
|
|
25
|
+
export function selectAvailableSkill(skills, query, liveTools) {
|
|
26
|
+
const list = skills instanceof SkillRegistry ? skills.list() : [...skills];
|
|
27
|
+
const present = new Set([...liveTools].map((t) => (typeof t === 'string' ? t : t.name)));
|
|
28
|
+
const usable = list.filter((s) => skillAvailable(s, present));
|
|
29
|
+
return (new SkillRegistry(usable).select(query) ??
|
|
30
|
+
new SkillRegistry(list.filter((s) => !s.metadata?.['requires-tools'] && !usable.includes(s))).select(query));
|
|
31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AC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACzF,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;IAC9D,OAAO,CACL,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;QACvC,IAAI,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAC5G,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical submarine-swap tool contract — pay a Lightning invoice from Liquid
|
|
3
|
+
* funds through the KaleidoSwap Boltz /v2 maker (kaleidoswap-maker-rs).
|
|
4
|
+
*
|
|
5
|
+
* The names match kaleido-mcp, which implements them over @kaleidorg/swap-sdk.
|
|
6
|
+
* Hosts with the SDK in-process (desktop sidecar, React Native) bind the same
|
|
7
|
+
* names with `bindSubmarineTools`.
|
|
8
|
+
*
|
|
9
|
+
* Keys and preimages never cross this contract: the host derives the refund key
|
|
10
|
+
* from its wallet mnemonic and persists the swap. `kaleidoswap_submarine_fund`
|
|
11
|
+
* — the only spend — takes nothing but the swap id, so the model cannot alter
|
|
12
|
+
* the amount, asset or lockup address it pays.
|
|
13
|
+
*
|
|
14
|
+
* Pure data — no deps, no fetch, RN-safe.
|
|
15
|
+
*/
|
|
16
|
+
import type { ToolDef } from '../types.js';
|
|
17
|
+
import { InProcessToolSource } from '../tools/in-process.js';
|
|
18
|
+
export interface SubmarineToolDef extends ToolDef {
|
|
19
|
+
/** Moves funds → confirmation-gated. */
|
|
20
|
+
spend?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Assets a submarine swap can be paid from, as the maker names them. */
|
|
23
|
+
export declare const SUBMARINE_FROM_ASSETS: readonly ['L-USDT', 'L-BTC'];
|
|
24
|
+
export type SubmarineFromAsset = typeof SUBMARINE_FROM_ASSETS[number];
|
|
25
|
+
/** Smallest-unit decimals of each source asset (L-USDT: 8, L-BTC: sats). */
|
|
26
|
+
export declare const SUBMARINE_ASSET_DECIMALS: Record<SubmarineFromAsset, number>;
|
|
27
|
+
export declare const SUBMARINE_TOOLS: SubmarineToolDef[];
|
|
28
|
+
export declare const SUBMARINE_SPEND_TOOLS: Set<string>;
|
|
29
|
+
export declare function isSubmarineSpendTool(name: string): boolean;
|
|
30
|
+
export declare function getSubmarineTool(name: string): SubmarineToolDef | undefined;
|
|
31
|
+
/** Format a smallest-unit amount of a source asset for display ("52.3 L-USDT", "1,200 sats"). */
|
|
32
|
+
export declare function formatSubmarineAmount(asset: string, smallestUnits: unknown): string;
|
|
33
|
+
export type SubmarineHandler = (args: Record<string, unknown>) => Promise<unknown>;
|
|
34
|
+
export interface BindSubmarineOptions {
|
|
35
|
+
/** Skip tools without a handler instead of throwing (default false). */
|
|
36
|
+
allowMissing?: boolean;
|
|
37
|
+
/** ToolSource id for the registry (default 'submarine'). */
|
|
38
|
+
id?: string;
|
|
39
|
+
}
|
|
40
|
+
/** Bind the submarine contract to in-process handlers → an InProcessToolSource. */
|
|
41
|
+
export declare function bindSubmarineTools(handlers: Record<string, SubmarineHandler>, opts?: BindSubmarineOptions): InProcessToolSource;
|
|
42
|
+
//# sourceMappingURL=contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/submarine/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3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ract — pay a Lightning invoice from Liquid
|
|
3
|
+
* funds through the KaleidoSwap Boltz /v2 maker (kaleidoswap-maker-rs).
|
|
4
|
+
*
|
|
5
|
+
* The names match kaleido-mcp, which implements them over @kaleidorg/swap-sdk.
|
|
6
|
+
* Hosts with the SDK in-process (desktop sidecar, React Native) bind the same
|
|
7
|
+
* names with `bindSubmarineTools`.
|
|
8
|
+
*
|
|
9
|
+
* Keys and preimages never cross this contract: the host derives the refund key
|
|
10
|
+
* from its wallet mnemonic and persists the swap. `kaleidoswap_submarine_fund`
|
|
11
|
+
* — the only spend — takes nothing but the swap id, so the model cannot alter
|
|
12
|
+
* the amount, asset or lockup address it pays.
|
|
13
|
+
*
|
|
14
|
+
* Pure data — no deps, no fetch, RN-safe.
|
|
15
|
+
*/
|
|
16
|
+
import { InProcessToolSource } from '../tools/in-process.js';
|
|
17
|
+
function t(name, description, properties = {}, required = [], spend = false) {
|
|
18
|
+
return { name, description, spend, requiresConfirmation: spend, parameters: { type: 'object', properties, required } };
|
|
19
|
+
}
|
|
20
|
+
/** Assets a submarine swap can be paid from, as the maker names them. */
|
|
21
|
+
export const SUBMARINE_FROM_ASSETS = ['L-USDT', 'L-BTC'];
|
|
22
|
+
/** Smallest-unit decimals of each source asset (L-USDT: 8, L-BTC: sats). */
|
|
23
|
+
export const SUBMARINE_ASSET_DECIMALS = { 'L-USDT': 8, 'L-BTC': 8 };
|
|
24
|
+
const swapId = { type: 'string', description: 'Swap id returned by kaleidoswap_submarine_create' };
|
|
25
|
+
export const SUBMARINE_TOOLS = [
|
|
26
|
+
t('kaleidoswap_submarine_pairs', 'List what can pay a Lightning invoice through a submarine swap (e.g. L-USDT on Liquid → Lightning BTC): rate, min/max, fees. No args.'),
|
|
27
|
+
t('kaleidoswap_submarine_create', 'Open a submarine swap that pays a Lightning (BOLT11) invoice from Liquid funds. No funds move: returns swap_id and expected_amount (source asset smallest unit). Then confirm with the user and call kaleidoswap_submarine_fund.', {
|
|
28
|
+
invoice: { type: 'string', description: 'BOLT11 Lightning invoice to pay (must carry an amount)' },
|
|
29
|
+
from_asset: { type: 'string', enum: [...SUBMARINE_FROM_ASSETS], description: 'Asset to pay with (default L-USDT)' },
|
|
30
|
+
}, ['invoice']),
|
|
31
|
+
t('kaleidoswap_submarine_fund', 'SPEND: lock the funds for a swap from kaleidoswap_submarine_create. Takes only the swap id — amount, asset and address come from the stored swap. The maker then pays the invoice.', { swap_id: swapId }, ['swap_id'],
|
|
32
|
+
/* spend */ true),
|
|
33
|
+
t('kaleidoswap_submarine_status', 'Status of a submarine swap. "transaction.claimed" = invoice paid, done. A failed funded swap needs a refund.', { swap_id: swapId }, ['swap_id']),
|
|
34
|
+
];
|
|
35
|
+
export const SUBMARINE_SPEND_TOOLS = new Set(SUBMARINE_TOOLS.filter((d) => d.spend).map((d) => d.name));
|
|
36
|
+
export function isSubmarineSpendTool(name) {
|
|
37
|
+
return SUBMARINE_SPEND_TOOLS.has(name);
|
|
38
|
+
}
|
|
39
|
+
export function getSubmarineTool(name) {
|
|
40
|
+
return SUBMARINE_TOOLS.find((d) => d.name === name);
|
|
41
|
+
}
|
|
42
|
+
/** Format a smallest-unit amount of a source asset for display ("52.3 L-USDT", "1,200 sats"). */
|
|
43
|
+
export function formatSubmarineAmount(asset, smallestUnits) {
|
|
44
|
+
const n = Number(smallestUnits);
|
|
45
|
+
if (!Number.isFinite(n))
|
|
46
|
+
return `${String(smallestUnits)} ${asset}`;
|
|
47
|
+
if (asset === 'L-BTC')
|
|
48
|
+
return `${n.toLocaleString('en-US')} sats of L-BTC`;
|
|
49
|
+
const decimals = SUBMARINE_ASSET_DECIMALS[asset] ?? 0;
|
|
50
|
+
const value = n / 10 ** decimals;
|
|
51
|
+
return `${value.toLocaleString('en-US', { maximumFractionDigits: decimals })} ${asset}`;
|
|
52
|
+
}
|
|
53
|
+
/** Bind the submarine contract to in-process handlers → an InProcessToolSource. */
|
|
54
|
+
export function bindSubmarineTools(handlers, opts = {}) {
|
|
55
|
+
const bound = [];
|
|
56
|
+
for (const def of SUBMARINE_TOOLS) {
|
|
57
|
+
const handler = handlers[def.name];
|
|
58
|
+
if (!handler) {
|
|
59
|
+
if (opts.allowMissing)
|
|
60
|
+
continue;
|
|
61
|
+
throw new Error(`bindSubmarineTools: no handler for "${def.name}"`);
|
|
62
|
+
}
|
|
63
|
+
bound.push({
|
|
64
|
+
name: def.name,
|
|
65
|
+
description: def.description,
|
|
66
|
+
parameters: def.parameters,
|
|
67
|
+
requiresConfirmation: def.requiresConfirmation,
|
|
68
|
+
handler,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return new InProcessToolSource(opts.id ?? 'submarine', bound);
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/submarine/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAU7D,SAAS,CAAC,CAAC,IAAY,EAAE,WAAmB,EAAE,UAAU,GAAU,EAAE,EAAE,QAAQ,GAAa,EAAE,EAAE,KAAK,GAAG,KAAK;IAC1G,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,oBAAoB,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,CAAC;AACzH,CAAC;AAED,yEAAyE;AACzE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAU,CAAC;AAGlE,4EAA4E;AAC5E,MAAM,CAAC,MAAM,wBAAwB,GAAuC,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;AAExG,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,kDAAkD,EAAW,CAAC;AAE5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
|
|
2
|
+
* @kaleidorg/mind/testing — build and demo an agent with no node, no funds and
|
|
3
|
+
* no model: a stateful mock wallet bound to the canonical contract, plus a
|
|
4
|
+
* scripted provider.
|
|
5
|
+
*
|
|
6
|
+
* import { MockWallet, scriptedProvider } from '@kaleidorg/mind/testing';
|
|
7
|
+
* const wallet = new MockWallet();
|
|
8
|
+
* const funnel = new Funnel({ provider: scriptedProvider(), tools: wallet.registry(), … });
|
|
9
|
+
*/
|
|
10
|
+
export { MockWallet } from './mock-wallet.js';
|
|
11
|
+
export type { MockWalletOptions, MockContact, MockRgbAsset, MockTransfer, SendRecord } from './mock-wallet.js';
|
|
12
|
+
export { scriptedProvider } from './scripted-provider.js';
|
|
13
|
+
export type { ScriptedTurn } from './scripted-provider.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC/G,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @kaleidorg/mind/testing — build and demo an agent with no node, no funds and
|
|
3
|
+
* no model: a stateful mock wallet bound to the canonical contract, plus a
|
|
4
|
+
* scripted provider.
|
|
5
|
+
*
|
|
6
|
+
* import { MockWallet, scriptedProvider } from '@kaleidorg/mind/testing';
|
|
7
|
+
* const wallet = new MockWallet();
|
|
8
|
+
* const funnel = new Funnel({ provider: scriptedProvider(), tools: wallet.registry(), … });
|
|
9
|
+
*/
|
|
10
|
+
export { MockWallet } from './mock-wallet.js';
|
|
11
|
+
export { scriptedProvider } from './scripted-provider.js';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A stateful mock wallet — balances per layer, contacts (incl. ambiguous +
|
|
3
|
+
* injectable), a price, validation (insufficient funds, no route, unknown
|
|
4
|
+
* contact, no colored UTXOs), RGB issuance, and a record of what actually got
|
|
5
|
+
* "sent". The canonical contract tools bind to it, so the agent sees real
|
|
6
|
+
* schemas and real failure modes — not trivial canned stubs.
|
|
7
|
+
*
|
|
8
|
+
* Used by the eval harness and exported as `@kaleidorg/mind/testing` so hosts
|
|
9
|
+
* can build and demo an agent with no node, no funds and no network.
|
|
10
|
+
*/
|
|
11
|
+
import { type WalletHandler } from '../wallet/contract.js';
|
|
12
|
+
import { ToolRegistry } from '../tools/registry.js';
|
|
13
|
+
import { type SubmarineHandler } from '../submarine/contract.js';
|
|
14
|
+
export interface SendRecord {
|
|
15
|
+
tool: string;
|
|
16
|
+
to: string;
|
|
17
|
+
amount_sats?: number;
|
|
18
|
+
asset?: string;
|
|
19
|
+
amount?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface MockContact {
|
|
22
|
+
name: string;
|
|
23
|
+
ln_address: string;
|
|
24
|
+
note?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface MockWalletOptions {
|
|
27
|
+
priceUsd?: number;
|
|
28
|
+
failRoute?: boolean;
|
|
29
|
+
contacts?: MockContact[];
|
|
30
|
+
balances?: {
|
|
31
|
+
spark: number;
|
|
32
|
+
rln: number;
|
|
33
|
+
arkade: number;
|
|
34
|
+
};
|
|
35
|
+
assets?: Record<string, number>;
|
|
36
|
+
/** Free colored UTXOs on the RLN node (issuance / RGB receive consume one). */
|
|
37
|
+
utxos?: number;
|
|
38
|
+
/** Liquid balances in smallest units (L-USDT: 8 decimals, L-BTC: sats) for submarine swaps. */
|
|
39
|
+
liquid?: {
|
|
40
|
+
'L-USDT': number;
|
|
41
|
+
'L-BTC': number;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export interface MockRgbAsset {
|
|
45
|
+
asset_id: string;
|
|
46
|
+
ticker: string;
|
|
47
|
+
name: string;
|
|
48
|
+
precision: number;
|
|
49
|
+
schema: 'NIA' | 'CFA' | 'UDA';
|
|
50
|
+
issued_supply: number;
|
|
51
|
+
}
|
|
52
|
+
export interface MockTransfer {
|
|
53
|
+
idx: number;
|
|
54
|
+
asset_id: string;
|
|
55
|
+
kind: 'Issuance' | 'Send' | 'ReceiveBlind';
|
|
56
|
+
status: 'Settled' | 'WaitingCounterparty';
|
|
57
|
+
amount: number;
|
|
58
|
+
}
|
|
59
|
+
export declare class MockWallet {
|
|
60
|
+
priceUsd: number;
|
|
61
|
+
failRoute: boolean;
|
|
62
|
+
balances: {
|
|
63
|
+
spark: number;
|
|
64
|
+
rln: number;
|
|
65
|
+
arkade: number;
|
|
66
|
+
};
|
|
67
|
+
assets: Record<string, number>;
|
|
68
|
+
contacts: MockContact[];
|
|
69
|
+
utxos: number;
|
|
70
|
+
liquid: {
|
|
71
|
+
'L-USDT': number;
|
|
72
|
+
'L-BTC': number;
|
|
73
|
+
};
|
|
74
|
+
/** Submarine swaps opened against the mock /v2 maker, by id. */
|
|
75
|
+
submarineSwaps: Record<string, {
|
|
76
|
+
from: 'L-USDT' | 'L-BTC';
|
|
77
|
+
invoice: string;
|
|
78
|
+
expected: number;
|
|
79
|
+
funded: boolean;
|
|
80
|
+
}>;
|
|
81
|
+
/** RGB assets the node knows about (seeded USDT/XAUT + anything issued). */
|
|
82
|
+
rgbAssets: MockRgbAsset[];
|
|
83
|
+
transfers: MockTransfer[];
|
|
84
|
+
sends: SendRecord[];
|
|
85
|
+
private readonly opts;
|
|
86
|
+
constructor(o?: MockWalletOptions);
|
|
87
|
+
private findAsset;
|
|
88
|
+
/** Issue a new RGB asset — mirrors the node: needs a free colored UTXO. */
|
|
89
|
+
issueAsset(args: Record<string, unknown>): MockRgbAsset;
|
|
90
|
+
totalSats(): number;
|
|
91
|
+
/** Back to the constructor state: balances, contacts, UTXOs, issued assets, history. */
|
|
92
|
+
reset(): void;
|
|
93
|
+
private send;
|
|
94
|
+
handlers(): Record<string, WalletHandler>;
|
|
95
|
+
/**
|
|
96
|
+
* The KaleidoSwap /v2 submarine contract against a toy maker: 0.5% fee, the
|
|
97
|
+
* invoice amount read from its BOLT11 human-readable part, L-USDT at `priceUsd`.
|
|
98
|
+
*/
|
|
99
|
+
submarineHandlers(): Record<string, SubmarineHandler>;
|
|
100
|
+
/** Bind the contract tools to this wallet (optionally overriding some — e.g. to inject). */
|
|
101
|
+
registry(overrides?: Partial<Record<string, WalletHandler>>): ToolRegistry;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=mock-wallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-wallet.d.ts","sourceRoot":"","sources":["../../src/testing/mock-wallet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAsB,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAErF,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC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
|
|
1
|
+
/**
|
|
2
|
+
* A stateful mock wallet — balances per layer, contacts (incl. ambiguous +
|
|
3
|
+
* injectable), a price, validation (insufficient funds, no route, unknown
|
|
4
|
+
* contact, no colored UTXOs), RGB issuance, and a record of what actually got
|
|
5
|
+
* "sent". The canonical contract tools bind to it, so the agent sees real
|
|
6
|
+
* schemas and real failure modes — not trivial canned stubs.
|
|
7
|
+
*
|
|
8
|
+
* Used by the eval harness and exported as `@kaleidorg/mind/testing` so hosts
|
|
9
|
+
* can build and demo an agent with no node, no funds and no network.
|
|
10
|
+
*/
|
|
11
|
+
import { bindWalletTools } from '../wallet/contract.js';
|
|
12
|
+
import { ToolRegistry } from '../tools/registry.js';
|
|
13
|
+
import { bindSubmarineTools } from '../submarine/contract.js';
|
|
14
|
+
export class MockWallet {
|
|
15
|
+
priceUsd;
|
|
16
|
+
failRoute;
|
|
17
|
+
balances;
|
|
18
|
+
assets;
|
|
19
|
+
contacts;
|
|
20
|
+
utxos;
|
|
21
|
+
liquid;
|
|
22
|
+
/** Submarine swaps opened against the mock /v2 maker, by id. */
|
|
23
|
+
submarineSwaps = {};
|
|
24
|
+
/** RGB assets the node knows about (seeded USDT/XAUT + anything issued). */
|
|
25
|
+
rgbAssets;
|
|
26
|
+
transfers = [];
|
|
27
|
+
sends = [];
|
|
28
|
+
opts;
|
|
29
|
+
constructor(o = {}) {
|
|
30
|
+
this.opts = o;
|
|
31
|
+
this.priceUsd = o.priceUsd ?? 65_000;
|
|
32
|
+
this.failRoute = o.failRoute ?? false;
|
|
33
|
+
// Copies: the wallet mutates its state, and reset() rebuilds from `o`.
|
|
34
|
+
this.balances = { ...(o.balances ?? { spark: 500_000, rln: 300_000, arkade: 200_000 }) };
|
|
35
|
+
this.assets = { ...(o.assets ?? { USDT: 25_000_000, XAUT: 0 }) };
|
|
36
|
+
this.contacts = o.contacts ? [...o.contacts] : [
|
|
37
|
+
{ name: 'bob', ln_address: 'bob@kaleidoswap.com' },
|
|
38
|
+
{ name: 'alice', ln_address: 'alice@kaleidoswap.com' },
|
|
39
|
+
{ name: 'john', ln_address: 'john.smith@kaleidoswap.com' },
|
|
40
|
+
{ name: 'john', ln_address: 'john.doe@kaleidoswap.com' }, // ambiguous on purpose
|
|
41
|
+
];
|
|
42
|
+
this.utxos = o.utxos ?? 5;
|
|
43
|
+
this.liquid = { ...(o.liquid ?? { 'L-USDT': 100 * 1e8, 'L-BTC': 200_000 }) };
|
|
44
|
+
this.rgbAssets = Object.keys(this.assets).map((ticker) => ({
|
|
45
|
+
asset_id: mockAssetId(ticker),
|
|
46
|
+
ticker,
|
|
47
|
+
name: ticker === 'USDT' ? 'Tether USD' : ticker === 'XAUT' ? 'Tether Gold' : ticker,
|
|
48
|
+
precision: 0,
|
|
49
|
+
schema: 'NIA',
|
|
50
|
+
issued_supply: this.assets[ticker],
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
findAsset(ref) {
|
|
54
|
+
const q = String(ref ?? '');
|
|
55
|
+
return this.rgbAssets.find((a) => a.asset_id === q || a.ticker.toUpperCase() === q.toUpperCase());
|
|
56
|
+
}
|
|
57
|
+
/** Issue a new RGB asset — mirrors the node: needs a free colored UTXO. */
|
|
58
|
+
issueAsset(args) {
|
|
59
|
+
if (this.utxos < 1)
|
|
60
|
+
throw new Error('No available colored UTXOs — call rln_create_utxos first.');
|
|
61
|
+
const schema = (['NIA', 'CFA', 'UDA'].includes(String(args.schema)) ? args.schema : 'NIA');
|
|
62
|
+
const ticker = String(args.ticker ?? '').toUpperCase();
|
|
63
|
+
if (!/^[A-Z0-9]{1,8}$/.test(ticker))
|
|
64
|
+
throw new Error('ticker must be 1-8 uppercase letters/digits.');
|
|
65
|
+
if (this.findAsset(ticker))
|
|
66
|
+
throw new Error(`An asset with ticker ${ticker} already exists.`);
|
|
67
|
+
const supply = schema === 'UDA' ? 1 : Number(args.amount);
|
|
68
|
+
if (!(supply > 0))
|
|
69
|
+
throw new Error('amount must be positive.');
|
|
70
|
+
const asset = {
|
|
71
|
+
asset_id: mockAssetId(ticker),
|
|
72
|
+
ticker,
|
|
73
|
+
name: String(args.name ?? ticker),
|
|
74
|
+
precision: Number(args.precision ?? 0),
|
|
75
|
+
schema,
|
|
76
|
+
issued_supply: supply,
|
|
77
|
+
};
|
|
78
|
+
this.utxos -= 1;
|
|
79
|
+
this.rgbAssets.push(asset);
|
|
80
|
+
this.assets[ticker] = supply;
|
|
81
|
+
this.transfers.push({ idx: this.transfers.length + 1, asset_id: asset.asset_id, kind: 'Issuance', status: 'Settled', amount: supply });
|
|
82
|
+
this.sends.push({ tool: 'rln_issue_asset', to: 'self', asset: ticker, amount: supply });
|
|
83
|
+
return asset;
|
|
84
|
+
}
|
|
85
|
+
totalSats() {
|
|
86
|
+
return this.balances.spark + this.balances.rln + this.balances.arkade;
|
|
87
|
+
}
|
|
88
|
+
/** Back to the constructor state: balances, contacts, UTXOs, issued assets, history. */
|
|
89
|
+
reset() {
|
|
90
|
+
Object.assign(this, new MockWallet(this.opts));
|
|
91
|
+
}
|
|
92
|
+
send(tool, rec) {
|
|
93
|
+
if (this.failRoute)
|
|
94
|
+
throw new Error('No route to destination.');
|
|
95
|
+
if (rec.amount_sats != null && rec.amount_sats > this.totalSats()) {
|
|
96
|
+
throw new Error(`Insufficient funds: have ${this.totalSats()} sats, need ${rec.amount_sats}.`);
|
|
97
|
+
}
|
|
98
|
+
this.sends.push({ tool, ...rec });
|
|
99
|
+
return { status: 'SUCCESS', payment_hash: 'mock' + this.sends.length };
|
|
100
|
+
}
|
|
101
|
+
handlers() {
|
|
102
|
+
return {
|
|
103
|
+
get_balances: async () => ({
|
|
104
|
+
total_sats: this.totalSats(),
|
|
105
|
+
layers: [
|
|
106
|
+
{ layer: 'spark', btc_sats: this.balances.spark, assets: [] },
|
|
107
|
+
{ layer: 'rln', btc_sats: this.balances.rln, assets: Object.entries(this.assets).filter(([, v]) => v > 0).map(([ticker, amount]) => ({ ticker, amount })) },
|
|
108
|
+
{ layer: 'arkade', btc_sats: this.balances.arkade, assets: [] },
|
|
109
|
+
],
|
|
110
|
+
}),
|
|
111
|
+
spark_get_balance: async () => ({ btc_sats: this.balances.spark }),
|
|
112
|
+
rln_get_balances: async () => ({ btc_sats: this.balances.rln, assets: this.assets }),
|
|
113
|
+
arkade_get_balance: async () => ({ btc_sats: this.balances.arkade }),
|
|
114
|
+
spark_get_address: async () => ({ address: 'bc1qspark0mockreceiveaddr' }),
|
|
115
|
+
arkade_get_address: async () => ({ address: 'ark1q0mockreceiveaddr' }),
|
|
116
|
+
get_price: async ({ fiat }) => ({ asset: 'BTC', price_usd: this.priceUsd, fiat: fiat ?? 'USD' }),
|
|
117
|
+
fiat_to_sats: async ({ amount }) => ({ sats: Math.round((Number(amount) / this.priceUsd) * 1e8) }),
|
|
118
|
+
resolve_contact: async ({ name }) => {
|
|
119
|
+
const q = String(name).toLowerCase();
|
|
120
|
+
const matches = this.contacts.filter((c) => c.name.toLowerCase() === q);
|
|
121
|
+
if (matches.length === 0)
|
|
122
|
+
throw new Error(`No contact named "${name}".`);
|
|
123
|
+
if (matches.length > 1)
|
|
124
|
+
throw new Error(`Ambiguous: ${matches.length} contacts named "${name}" — ask the user which one.`);
|
|
125
|
+
return matches[0];
|
|
126
|
+
},
|
|
127
|
+
rln_create_ln_invoice: async ({ amount_sats }) => ({ invoice: `lnbcmock${amount_sats ?? ''}` }),
|
|
128
|
+
rln_create_rgb_invoice: async ({ asset, amount }) => ({ invoice: 'rgb:mockinvoice', asset, amount }),
|
|
129
|
+
send_payment: async ({ to, amount_sats }) => this.send('send_payment', { to: String(to), amount_sats: amount_sats != null ? Number(amount_sats) : undefined }),
|
|
130
|
+
rln_pay_invoice: async ({ invoice }) => this.send('rln_pay_invoice', { to: String(invoice) }),
|
|
131
|
+
rln_send_asset: async ({ asset, amount, to }) => {
|
|
132
|
+
const a = String(asset);
|
|
133
|
+
if ((this.assets[a] ?? 0) < Number(amount))
|
|
134
|
+
throw new Error(`Insufficient ${a} balance.`);
|
|
135
|
+
const res = this.send('rln_send_asset', { to: String(to), asset: a, amount: Number(amount) });
|
|
136
|
+
const found = this.findAsset(a);
|
|
137
|
+
if (found)
|
|
138
|
+
this.transfers.push({ idx: this.transfers.length + 1, asset_id: found.asset_id, kind: 'Send', status: 'Settled', amount: Number(amount) });
|
|
139
|
+
return res;
|
|
140
|
+
},
|
|
141
|
+
rln_list_assets: async () => ({
|
|
142
|
+
assets: this.rgbAssets.map((a) => ({ ...a, balance: { spendable: this.assets[a.ticker] ?? 0 } })),
|
|
143
|
+
}),
|
|
144
|
+
rln_list_transfers: async ({ asset_id, asset }) => {
|
|
145
|
+
const ref = asset_id ?? asset;
|
|
146
|
+
const found = this.findAsset(ref);
|
|
147
|
+
if (!found)
|
|
148
|
+
throw new Error(`Unknown asset "${String(ref)}".`);
|
|
149
|
+
return { transfers: this.transfers.filter((x) => x.asset_id === found.asset_id) };
|
|
150
|
+
},
|
|
151
|
+
rln_create_utxos: async ({ num }) => {
|
|
152
|
+
const n = Number(num ?? 5);
|
|
153
|
+
this.utxos += n;
|
|
154
|
+
this.sends.push({ tool: 'rln_create_utxos', to: 'self', amount: n });
|
|
155
|
+
return { created: true, num: n, free_utxos: this.utxos };
|
|
156
|
+
},
|
|
157
|
+
rln_issue_asset: async (args) => {
|
|
158
|
+
const a = this.issueAsset(args);
|
|
159
|
+
return { issued: true, asset_id: a.asset_id, ticker: a.ticker, name: a.name, schema: a.schema, issued_supply: a.issued_supply };
|
|
160
|
+
},
|
|
161
|
+
get_swap_quote: async ({ from_asset, to_asset, amount }) => ({
|
|
162
|
+
quote_id: 'quote-mock',
|
|
163
|
+
from_asset,
|
|
164
|
+
to_asset,
|
|
165
|
+
amount: Number(amount),
|
|
166
|
+
// toy rate: 1 USDT ≈ 1538 sats at $65k; otherwise echo.
|
|
167
|
+
receive_amount: String(from_asset).toUpperCase() === 'USDT' ? Math.round(Number(amount) * (1e8 / this.priceUsd)) : Number(amount),
|
|
168
|
+
}),
|
|
169
|
+
execute_swap: async ({ from_asset, to_asset, amount }) => {
|
|
170
|
+
this.sends.push({ tool: 'execute_swap', to: `${from_asset}->${to_asset}`, amount: Number(amount) });
|
|
171
|
+
return { status: 'SUCCESS', swap_id: 'swap' + this.sends.length };
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* The KaleidoSwap /v2 submarine contract against a toy maker: 0.5% fee, the
|
|
177
|
+
* invoice amount read from its BOLT11 human-readable part, L-USDT at `priceUsd`.
|
|
178
|
+
*/
|
|
179
|
+
submarineHandlers() {
|
|
180
|
+
return {
|
|
181
|
+
kaleidoswap_submarine_pairs: async () => ({
|
|
182
|
+
pairs: [
|
|
183
|
+
{ from: 'L-USDT', to: 'BTC', fees: { percentage: 0.5 }, limits: { minimal: 10 * 1e8, maximal: 1_000 * 1e8 } },
|
|
184
|
+
{ from: 'L-BTC', to: 'BTC', fees: { percentage: 0.5 }, limits: { minimal: 10_000, maximal: 1_000_000 } },
|
|
185
|
+
],
|
|
186
|
+
}),
|
|
187
|
+
kaleidoswap_submarine_create: async ({ invoice, from_asset }) => {
|
|
188
|
+
const from = (from_asset ?? 'L-USDT');
|
|
189
|
+
if (from !== 'L-USDT' && from !== 'L-BTC')
|
|
190
|
+
throw new Error(`Unsupported from_asset "${String(from_asset)}".`);
|
|
191
|
+
const sats = bolt11Sats(String(invoice));
|
|
192
|
+
if (sats == null)
|
|
193
|
+
throw new Error('invalid_invoice: the invoice must be BOLT11 with an amount.');
|
|
194
|
+
const withFee = sats * 1.005;
|
|
195
|
+
const expected = Math.ceil(from === 'L-USDT' ? (withFee / 1e8) * this.priceUsd * 1e8 : withFee);
|
|
196
|
+
const id = `sub${Object.keys(this.submarineSwaps).length + 1}`;
|
|
197
|
+
this.submarineSwaps[id] = { from, invoice: String(invoice), expected, funded: false };
|
|
198
|
+
return { swap_id: id, from_asset: from, expected_amount: String(expected), lockup_address: `tlq1qmock${id}` };
|
|
199
|
+
},
|
|
200
|
+
kaleidoswap_submarine_fund: async ({ swap_id }) => {
|
|
201
|
+
const swap = this.submarineSwaps[String(swap_id)];
|
|
202
|
+
if (!swap)
|
|
203
|
+
throw new Error(`No submarine swap "${String(swap_id)}" was created by this server.`);
|
|
204
|
+
if (swap.funded)
|
|
205
|
+
throw new Error(`Swap ${String(swap_id)} is already funded.`);
|
|
206
|
+
if (this.liquid[swap.from] < swap.expected)
|
|
207
|
+
throw new Error(`Insufficient ${swap.from} balance.`);
|
|
208
|
+
this.liquid[swap.from] -= swap.expected;
|
|
209
|
+
swap.funded = true;
|
|
210
|
+
this.sends.push({ tool: 'kaleidoswap_submarine_fund', to: swap.invoice, asset: swap.from, amount: swap.expected });
|
|
211
|
+
return { funded: true, swap_id, asset: swap.from, amount: String(swap.expected), txid: `mocktx${String(swap_id)}` };
|
|
212
|
+
},
|
|
213
|
+
kaleidoswap_submarine_status: async ({ swap_id }) => {
|
|
214
|
+
const swap = this.submarineSwaps[String(swap_id)];
|
|
215
|
+
if (!swap)
|
|
216
|
+
throw new Error(`invalid_swap_id: "${String(swap_id)}" is not a swap id`);
|
|
217
|
+
const status = swap.funded ? 'transaction.claimed' : 'swap.created';
|
|
218
|
+
return { swap_id, status, done: swap.funded, failed: false, funded: swap.funded };
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
/** Bind the contract tools to this wallet (optionally overriding some — e.g. to inject). */
|
|
223
|
+
registry(overrides) {
|
|
224
|
+
const h = { ...this.handlers(), ...(overrides ?? {}) };
|
|
225
|
+
const sub = { ...this.submarineHandlers(), ...(overrides ?? {}) };
|
|
226
|
+
return new ToolRegistry([
|
|
227
|
+
bindWalletTools(h, { layers: ['spark', 'rln', 'arkade', 'core'], allowMissing: true }),
|
|
228
|
+
bindSubmarineTools(sub, { allowMissing: true }),
|
|
229
|
+
]);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/** Deterministic fake RGB contract id per ticker (stable across runs). */
|
|
233
|
+
function mockAssetId(ticker) {
|
|
234
|
+
let h = 0;
|
|
235
|
+
for (const c of ticker)
|
|
236
|
+
h = (h * 31 + c.charCodeAt(0)) >>> 0;
|
|
237
|
+
return `rgb:mock-${ticker.toLowerCase()}-${h.toString(36)}`;
|
|
238
|
+
}
|
|
239
|
+
/** Amount in sats from a BOLT11 human-readable part ("lntbs10u…" → 1000), or null. */
|
|
240
|
+
function bolt11Sats(invoice) {
|
|
241
|
+
const m = invoice.toLowerCase().match(/^ln(?:bcrt|tbs|bc|tb)(\d+)([munp])?1/);
|
|
242
|
+
if (!m)
|
|
243
|
+
return null;
|
|
244
|
+
const n = Number(m[1]);
|
|
245
|
+
const mult = { m: 1e5, u: 100, n: 0.1, p: 0.0001 }[m[2] ?? ''] ?? 1e8;
|
|
246
|
+
const sats = n * mult;
|
|
247
|
+
return sats >= 1 ? Math.round(sats) : null;
|
|
248
|
+
}
|
|
249
|
+
//# sourceMappingURL=mock-wallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-wallet.js","sourceRoot":"","sources":["../../src/testing/mock-wallet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,eAAe,EAAsB,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAyB,MAAM,0BAA0B,CAAC;AAqCrF,MAAM,OAAO,UAAU;IACrB,QAAQ,CAAS;IACjB,SAAS,CAAU;IACnB,QAAQ,CAAiD;IACzD,MAAM,CAAyB;IAC/B,QAAQ,CAAgB;IACxB,KAAK,CAAS;IACd,MAAM,CAAwC;IAC9C,gEAAgE;IAChE,cAAc,GAAqG,EAAE,CAAC;IACtH,4EAA4E;IAC5E,SAAS,CAAiB;IAC1B,SAAS,GAAmB,EAAE,CAAC;IAC/B,KAAK,GAAiB,EAAE,CAAC;IAER,IAAI,CAAoB;IAEzC,YAAY,CAAC,GAAsB,EAAE;Q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AAW,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;AAC9D,CAAC;AAED,sFAAsF;AACtF,SAAS,UAAU,CAAC,OAAe;IACjC,MAAM,CAAC,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC9E,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACpB,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvB,MAAM,IAAI,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,GAAG,CAAC;IACtE,MAAM,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC;IACtB,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A scripted LLMProvider — replays planned turns instead of running a model.
|
|
3
|
+
*
|
|
4
|
+
* Lets hosts wire the full Engine / Funnel (skills, recipes, confirm gate) in
|
|
5
|
+
* unit tests, CI and demos without loading a QVAC model. Deterministic tiers
|
|
6
|
+
* (fast-path, recipes with regex extraction) never call it at all.
|
|
7
|
+
*/
|
|
8
|
+
import type { LLMProvider } from '../providers/types.js';
|
|
9
|
+
export interface ScriptedTurn {
|
|
10
|
+
/** Assistant text for this turn. */
|
|
11
|
+
text?: string;
|
|
12
|
+
/** Tool to call — ignored when the tool is not in the turn's scoped tool list. */
|
|
13
|
+
tool?: string;
|
|
14
|
+
args?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
export declare function scriptedProvider(turns?: ScriptedTurn[], fallback?: string): LLMProvider;
|
|
17
|
+
//# sourceMappingURL=scripted-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scripted-provider.d.ts","sourceRoot":"","sources":["../../src/testing/scripted-provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,WAAW,YAAY;IAC3B,oCAAoC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kFAAkF;IAClF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,wBAAgB,gBAAgB,CAAC,KAAK,GAAE,YAAY,EAAO,EAAE,QAAQ,SAA6B,GAAG,WAAW,CAiB/G"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A scripted LLMProvider — replays planned turns instead of running a model.
|
|
3
|
+
*
|
|
4
|
+
* Lets hosts wire the full Engine / Funnel (skills, recipes, confirm gate) in
|
|
5
|
+
* unit tests, CI and demos without loading a QVAC model. Deterministic tiers
|
|
6
|
+
* (fast-path, recipes with regex extraction) never call it at all.
|
|
7
|
+
*/
|
|
8
|
+
export function scriptedProvider(turns = [], fallback = 'I need more information.') {
|
|
9
|
+
let index = 0;
|
|
10
|
+
return {
|
|
11
|
+
name: 'scripted',
|
|
12
|
+
async runTurn(input) {
|
|
13
|
+
const planned = turns[index++] ?? { text: fallback };
|
|
14
|
+
const call = planned.tool && input.tools.some((t) => t.name === planned.tool)
|
|
15
|
+
? { id: `scripted-${index}`, name: planned.tool, arguments: planned.args ?? {} }
|
|
16
|
+
: undefined;
|
|
17
|
+
return {
|
|
18
|
+
text: planned.text ?? '',
|
|
19
|
+
rawContent: planned.text ?? '',
|
|
20
|
+
toolCalls: call ? [call] : [],
|
|
21
|
+
inference: { durationMs: 0, status: 'completed' },
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=scripted-provider.js.map
|