@kaleidorg/mind 0.5.1 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/autonomy/index.d.ts +21 -0
- package/dist/autonomy/index.d.ts.map +1 -0
- package/dist/autonomy/index.js +16 -0
- package/dist/autonomy/index.js.map +1 -0
- package/dist/autonomy/prompt.d.ts +21 -0
- package/dist/autonomy/prompt.d.ts.map +1 -0
- package/dist/autonomy/prompt.js +37 -0
- package/dist/autonomy/prompt.js.map +1 -0
- package/dist/autonomy/risk.d.ts +53 -0
- package/dist/autonomy/risk.d.ts.map +1 -0
- package/dist/autonomy/risk.js +74 -0
- package/dist/autonomy/risk.js.map +1 -0
- package/dist/autonomy/run-state.d.ts +39 -0
- package/dist/autonomy/run-state.d.ts.map +1 -0
- package/dist/autonomy/run-state.js +118 -0
- package/dist/autonomy/run-state.js.map +1 -0
- package/dist/autonomy/scheduler.d.ts +18 -0
- package/dist/autonomy/scheduler.d.ts.map +1 -0
- package/dist/autonomy/scheduler.js +113 -0
- package/dist/autonomy/scheduler.js.map +1 -0
- package/dist/autonomy/task-store.d.ts +44 -0
- package/dist/autonomy/task-store.d.ts.map +1 -0
- package/dist/autonomy/task-store.js +139 -0
- package/dist/autonomy/task-store.js.map +1 -0
- package/dist/autonomy/types.d.ts +164 -0
- package/dist/autonomy/types.d.ts.map +1 -0
- package/dist/autonomy/types.js +20 -0
- package/dist/autonomy/types.js.map +1 -0
- package/dist/bitrefill/contract.d.ts +60 -0
- package/dist/bitrefill/contract.d.ts.map +1 -0
- package/dist/bitrefill/contract.js +119 -0
- package/dist/bitrefill/contract.js.map +1 -0
- package/dist/context/compress.d.ts +65 -0
- package/dist/context/compress.d.ts.map +1 -0
- package/dist/context/compress.js +181 -0
- package/dist/context/compress.js.map +1 -0
- package/dist/engine.d.ts +20 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +23 -4
- package/dist/engine.js.map +1 -1
- package/dist/evidence.d.ts +62 -0
- package/dist/evidence.d.ts.map +1 -0
- package/dist/evidence.js +47 -0
- package/dist/evidence.js.map +1 -0
- package/dist/flashnet/contract.d.ts +56 -0
- package/dist/flashnet/contract.d.ts.map +1 -0
- package/dist/flashnet/contract.js +100 -0
- package/dist/flashnet/contract.js.map +1 -0
- package/dist/funnel.d.ts +11 -0
- package/dist/funnel.d.ts.map +1 -1
- package/dist/funnel.js +62 -7
- package/dist/funnel.js.map +1 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/kaleidoswap/contract.js +1 -1
- package/dist/kaleidoswap/contract.js.map +1 -1
- package/dist/knowledge/bitcoin-copilot.d.ts.map +1 -1
- package/dist/knowledge/bitcoin-copilot.js +85 -2
- package/dist/knowledge/bitcoin-copilot.js.map +1 -1
- package/dist/providers/types.d.ts +17 -0
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/qvac/index.d.ts +1 -1
- package/dist/qvac/index.d.ts.map +1 -1
- package/dist/qvac/index.js.map +1 -1
- package/dist/qvac/parse.d.ts +18 -0
- package/dist/qvac/parse.d.ts.map +1 -1
- package/dist/qvac/parse.js +1 -0
- package/dist/qvac/parse.js.map +1 -1
- package/dist/qvac/provider.d.ts +16 -0
- package/dist/qvac/provider.d.ts.map +1 -1
- package/dist/qvac/provider.js +40 -1
- package/dist/qvac/provider.js.map +1 -1
- package/dist/qvac/stream.d.ts +22 -0
- package/dist/qvac/stream.d.ts.map +1 -1
- package/dist/qvac/stream.js +33 -1
- package/dist/qvac/stream.js.map +1 -1
- package/dist/recipe/buy-asset-channel.d.ts +1 -1
- package/dist/recipe/buy-asset-channel.d.ts.map +1 -1
- package/dist/recipe/buy-asset-channel.js +4 -3
- package/dist/recipe/buy-asset-channel.js.map +1 -1
- package/dist/recipe/flashnet-swap.d.ts +35 -0
- package/dist/recipe/flashnet-swap.d.ts.map +1 -0
- package/dist/recipe/flashnet-swap.js +239 -0
- package/dist/recipe/flashnet-swap.js.map +1 -0
- package/dist/recipe/kaleidoswap-atomic.d.ts +1 -1
- package/dist/recipe/kaleidoswap-atomic.d.ts.map +1 -1
- package/dist/recipe/kaleidoswap-atomic.js +42 -20
- package/dist/recipe/kaleidoswap-atomic.js.map +1 -1
- package/dist/recipe/kaleidoswap-channel-order.d.ts.map +1 -1
- package/dist/recipe/kaleidoswap-channel-order.js +31 -10
- package/dist/recipe/kaleidoswap-channel-order.js.map +1 -1
- package/dist/recipe/kaleidoswap-price.d.ts.map +1 -1
- package/dist/recipe/kaleidoswap-price.js +7 -1
- package/dist/recipe/kaleidoswap-price.js.map +1 -1
- package/dist/recipe/runner.d.ts.map +1 -1
- package/dist/recipe/runner.js +43 -3
- package/dist/recipe/runner.js.map +1 -1
- package/dist/recipe/swap.d.ts.map +1 -1
- package/dist/recipe/swap.js +14 -1
- package/dist/recipe/swap.js.map +1 -1
- package/dist/tools/mcp.d.ts +19 -0
- package/dist/tools/mcp.d.ts.map +1 -1
- package/dist/tools/mcp.js +51 -9
- package/dist/tools/mcp.js.map +1 -1
- package/dist/wallet/confirm.d.ts.map +1 -1
- package/dist/wallet/confirm.js +1 -0
- package/dist/wallet/confirm.js.map +1 -1
- package/dist/wallet/contract.d.ts.map +1 -1
- package/dist/wallet/contract.js +20 -4
- package/dist/wallet/contract.js.map +1 -1
- package/package.json +5 -4
- package/skills/bitrefill/SKILL.md +152 -52
- package/skills/channel-manager/SKILL.md +59 -0
- package/skills/dca/SKILL.md +48 -0
- package/skills/flashnet-swaps/SKILL.md +158 -0
- package/skills/kaleido-lsps/SKILL.md +34 -17
- package/skills/kaleido-trading/SKILL.md +37 -13
- package/skills/liquidity-optimizer/SKILL.md +91 -0
- package/skills/merchant-finder/SKILL.md +2 -2
- package/skills/portfolio-manager/SKILL.md +67 -0
- package/skills/rgb-lightning-node/SKILL.md +38 -11
- package/skills/spark-wallet/SKILL.md +235 -0
- package/skills/wallet-assistant/SKILL.md +2 -2
- package/src/autonomy/autonomy.test.ts +348 -0
- package/src/autonomy/index.ts +50 -0
- package/src/autonomy/prompt.ts +48 -0
- package/src/autonomy/risk.ts +139 -0
- package/src/autonomy/run-state.ts +144 -0
- package/src/autonomy/scheduler.ts +120 -0
- package/src/autonomy/task-store.ts +167 -0
- package/src/autonomy/types.ts +186 -0
- package/src/bitrefill/contract.test.ts +89 -0
- package/src/bitrefill/contract.ts +190 -0
- package/src/context/compress.test.ts +120 -0
- package/src/context/compress.ts +230 -0
- package/src/engine.test.ts +34 -0
- package/src/engine.ts +35 -4
- package/src/evidence.test.ts +80 -0
- package/src/evidence.ts +114 -0
- package/src/flashnet/contract.test.ts +101 -0
- package/src/flashnet/contract.ts +164 -0
- package/src/funnel.mind.test.ts +390 -0
- package/src/funnel.ts +73 -8
- package/src/index.ts +92 -1
- package/src/kaleidoswap/contract.ts +1 -1
- package/src/knowledge/bitcoin-copilot.ts +96 -2
- package/src/providers/types.ts +18 -0
- package/src/qvac/index.ts +1 -0
- package/src/qvac/parse.ts +20 -0
- package/src/qvac/provider.test.ts +17 -0
- package/src/qvac/provider.ts +62 -2
- package/src/qvac/stream.test.ts +36 -0
- package/src/qvac/stream.ts +54 -1
- package/src/recipe/buy-asset-channel.test.ts +5 -0
- package/src/recipe/buy-asset-channel.ts +6 -3
- package/src/recipe/flashnet-swap.test.ts +114 -0
- package/src/recipe/flashnet-swap.ts +266 -0
- package/src/recipe/kaleidoswap-atomic.test.ts +24 -3
- package/src/recipe/kaleidoswap-atomic.ts +39 -20
- package/src/recipe/kaleidoswap-channel-order.test.ts +38 -0
- package/src/recipe/kaleidoswap-channel-order.ts +27 -9
- package/src/recipe/kaleidoswap-price.ts +7 -1
- package/src/recipe/recipe.test.ts +21 -0
- package/src/recipe/runner.ts +46 -3
- package/src/recipe/swap.ts +16 -1
- package/src/tools/mcp.live.test.ts +116 -0
- package/src/tools/mcp.parse.test.ts +37 -0
- package/src/tools/mcp.ts +55 -9
- package/src/wallet/confirm.test.ts +8 -0
- package/src/wallet/confirm.ts +1 -0
- package/src/wallet/contract.test.ts +10 -0
- package/src/wallet/contract.ts +26 -4
package/dist/qvac/parse.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/qvac/parse.ts"],"names":[],"mappings":"AAQA,qEAAqE;AACrE,MAAM,WAAW,aAAa;IAC5B,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,GAAG,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5B,uEAAuE;IACvE,SAAS,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;IACtF;;;;OAIG;IACH,UAAU,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/qvac/parse.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,+EAA+E;IAC/E,aAAa,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qEAAqE;AACrE,MAAM,WAAW,aAAa;IAC5B,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,GAAG,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5B,uEAAuE;IACvE,SAAS,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;IACtF;;;;OAIG;IACH,UAAU,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,MAAM,CAAC;IAC7C,iFAAiF;IACjF,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED,MAAM,WAAW,UAAU;IACzB,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,UAAU,EAAE,MAAM,CAAC;IACnB,oEAAoE;IACpE,SAAS,EAAE,KAAK,CAAC;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;IACpF,gFAAgF;IAChF,SAAS,EAAE,OAAO,CAAC;IACnB,mDAAmD;IACnD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAkCD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,GACX,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAAC,CAc7D;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,SAAK,GAAG,UAAU,CAoB3E"}
|
package/dist/qvac/parse.js
CHANGED
package/dist/qvac/parse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/qvac/parse.ts"],"names":[],"mappings":"AAA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;QAC3B,MAAM,SAAS,GAAG,oBAAoB,CAAC,KAAK,CAAC,GAAG,EAAE,QAAQ,IAAI,OAAO,CAAC,CAAC;QACvE,IAAI,SAAS,CAAC,MAAM;YAAE,SAAS,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACpF,CAAC;IACD,OAAO;QACL,IAAI;QACJ,UAAU,EAAE,KAAK,CAAC,GAAG,EAAE,QAAQ,IAAI,OAAO;QAC1C,SAAS;QACT,SAAS,EAAE,KAAK,CAAC,UAAU,KAAK,QAAQ;QACxC,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,KAAK,EAAE,KAAK,CAAC,KAAK;KACnB,CAAC;AACJ,CAAC"}
|
package/dist/qvac/provider.d.ts
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import type * as QvacSdk from '@qvac/sdk';
|
|
20
20
|
import type { LLMProvider, TurnInput } from '../providers/types.js';
|
|
21
|
+
import type { QvacTurnStats } from './parse.js';
|
|
21
22
|
type CompletionFn = typeof QvacSdk.completion;
|
|
22
23
|
type CancelFn = typeof QvacSdk.cancel;
|
|
23
24
|
export interface QvacProviderOptions {
|
|
@@ -35,14 +36,29 @@ export interface QvacProviderOptions {
|
|
|
35
36
|
defaultTemperature?: number;
|
|
36
37
|
/** Default max output tokens — caps a turn so it can't ramble. Omit for uncapped. */
|
|
37
38
|
defaultMaxTokens?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Cap `<think>` reasoning at this many TOKENS (not seconds — tok/s varies, and
|
|
41
|
+
* the SDK has no numeric reasoning budget). When a turn's thinking exceeds it,
|
|
42
|
+
* the run is cancelled and a short fallback is returned instead of hanging on
|
|
43
|
+
* "Thinking…". Omit for unlimited reasoning.
|
|
44
|
+
*/
|
|
45
|
+
maxThinkingTokens?: number;
|
|
38
46
|
/** Stream the model's `<think>` reasoning, when a host wants to surface it. */
|
|
39
47
|
onThinking?: (token: string) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Per-turn inference stats (real backend device + throughput), when a host
|
|
50
|
+
* wants to surface them. Fires once per turn after the `final` frame resolves.
|
|
51
|
+
*/
|
|
52
|
+
onStats?: (stats: QvacTurnStats) => void;
|
|
40
53
|
}
|
|
41
54
|
/** TurnInput plus the per-call knobs the funnel/voice paths pass through. */
|
|
42
55
|
export interface QvacTurnInput extends TurnInput {
|
|
43
56
|
temperature?: number;
|
|
44
57
|
maxTokens?: number;
|
|
58
|
+
/** Per-turn override of the thinking-token cap (see QvacProviderOptions). */
|
|
59
|
+
maxThinkingTokens?: number;
|
|
45
60
|
onThinking?: (token: string) => void;
|
|
61
|
+
onStats?: (stats: QvacTurnStats) => void;
|
|
46
62
|
}
|
|
47
63
|
export declare function createQvacProvider(options: QvacProviderOptions): LLMProvider;
|
|
48
64
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/qvac/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,KAAK,OAAO,MAAM,WAAW,CAAC;AAC1C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/qvac/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,KAAK,OAAO,MAAM,WAAW,CAAC;AAC1C,OAAO,KAAK,EAAoB,WAAW,EAAE,SAAS,EAAc,MAAM,uBAAuB,CAAC;AAClG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,KAAK,YAAY,GAAG,OAAO,OAAO,CAAC,UAAU,CAAC;AAC9C,KAAK,QAAQ,GAAG,OAAO,OAAO,CAAC,MAAM,CAAC;AAEtC,MAAM,WAAW,mBAAmB;IAClC,2DAA2D;IAC3D,UAAU,EAAE,YAAY,CAAC;IACzB,qCAAqC;IACrC,MAAM,EAAE,QAAQ,CAAC;IACjB,8EAA8E;IAC9E,UAAU,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IAChC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,+EAA+E;IAC/E,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;CAC1C;AAED,6EAA6E;AAC7E,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6EAA6E;IAC7E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;CAC1C;AAOD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,WAAW,CA+G5E"}
|
package/dist/qvac/provider.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { consumeRun } from './stream.js';
|
|
2
|
+
/** Shown when a turn is cut off because it blew its thinking-token budget. */
|
|
3
|
+
const THINKING_BUDGET_FALLBACK = 'I spent my whole thinking budget on that one without landing an answer. ' +
|
|
4
|
+
'Try asking again, more specifically.';
|
|
2
5
|
export function createQvacProvider(options) {
|
|
3
6
|
return {
|
|
4
7
|
name: 'qvac',
|
|
@@ -42,15 +45,51 @@ export function createQvacProvider(options) {
|
|
|
42
45
|
...(generationParams ? { generationParams } : {}),
|
|
43
46
|
...(tools ? { tools } : {}),
|
|
44
47
|
});
|
|
48
|
+
const maxThinkingTokens = input.maxThinkingTokens ?? options.maxThinkingTokens;
|
|
45
49
|
const result = await consumeRun(run, {
|
|
46
50
|
onToken: input.onToken,
|
|
47
51
|
onThinking: input.onThinking ?? options.onThinking,
|
|
52
|
+
maxThinkingTokens,
|
|
53
|
+
// Cancel the in-flight run the moment the thinking budget is blown — the
|
|
54
|
+
// SDK keeps generating otherwise. Fire-and-forget; `final` then resolves.
|
|
55
|
+
onThinkingBudgetExceeded: () => {
|
|
56
|
+
void options.cancel({ requestId: run.requestId }).catch(() => { });
|
|
57
|
+
},
|
|
48
58
|
});
|
|
59
|
+
// Surface the real per-turn inference stats (backend device + throughput).
|
|
60
|
+
if (result.stats)
|
|
61
|
+
(input.onStats ?? options.onStats)?.(result.stats);
|
|
62
|
+
// A turn cut off mid-reasoning has no visible answer — return a short note
|
|
63
|
+
// instead of an empty bubble so the agentic loop ends cleanly.
|
|
64
|
+
const text = result.text || (result.thinkingBudgetExceeded ? THINKING_BUDGET_FALLBACK : result.text);
|
|
65
|
+
const totalTokens = result.stats?.totalTokens;
|
|
66
|
+
const promptTokens = result.stats?.promptTokens;
|
|
67
|
+
const inference = {
|
|
68
|
+
requestId: result.requestId,
|
|
69
|
+
durationMs: result.timing.durationMs,
|
|
70
|
+
status: result.stopReason === 'cancelled'
|
|
71
|
+
? 'cancelled'
|
|
72
|
+
: result.truncated
|
|
73
|
+
? 'truncated'
|
|
74
|
+
: 'completed',
|
|
75
|
+
...(result.stats?.backendDevice ? { backendDevice: result.stats.backendDevice } : {}),
|
|
76
|
+
...(typeof promptTokens === 'number' ? { promptTokens } : {}),
|
|
77
|
+
...(typeof totalTokens === 'number' ? { totalTokens } : {}),
|
|
78
|
+
...(typeof totalTokens === 'number' && typeof promptTokens === 'number'
|
|
79
|
+
? { completionTokens: Math.max(0, totalTokens - promptTokens) }
|
|
80
|
+
: {}),
|
|
81
|
+
...(typeof result.timing.ttftMs === 'number' ? { ttftMs: result.timing.ttftMs } : {}),
|
|
82
|
+
...(typeof result.stats?.tokensPerSecond === 'number'
|
|
83
|
+
? { tokensPerSecond: result.stats.tokensPerSecond }
|
|
84
|
+
: {}),
|
|
85
|
+
...(result.stopReason ? { stopReason: result.stopReason } : {}),
|
|
86
|
+
};
|
|
49
87
|
return {
|
|
50
|
-
text
|
|
88
|
+
text,
|
|
51
89
|
rawContent: result.rawContent,
|
|
52
90
|
toolCalls: result.toolCalls,
|
|
53
91
|
requestId: result.requestId,
|
|
92
|
+
inference,
|
|
54
93
|
};
|
|
55
94
|
},
|
|
56
95
|
async cancel(requestId) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/qvac/provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/qvac/provider.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA8CzC,8EAA8E;AAC9E,MAAM,wBAAwB,GAC5B,0EAA0E;IAC1E,sCAAsC,CAAC;AAEzC,MAAM,UAAU,kBAAkB,CAAC,OAA4B;IAC7D,OAAO;QACL,IAAI,EAAE,MAAM;QAEZ,KAAK,CAAC,OAAO,CAAC,KAAoB;YAChC,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;YACrC,IAAI,CAAC,OAAO;gBAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;YAEvD,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM;gBAC1B,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC;gBAChE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC;YAEnB,uEAAuE;YACvE,sEAAsE;YACtE,uEAAuE;YACvE,+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AC,MAAM,CAAC,SAAiB;YAC5B,2EAA2E;YAC3E,oEAAoE;YACpE,IAAI,CAAC;gBACH,MAAM,OAAO,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;YACtC,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,IAAI,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/qvac/stream.d.ts
CHANGED
|
@@ -24,9 +24,31 @@ export interface StreamHandlers {
|
|
|
24
24
|
onToken?: (token: string) => void;
|
|
25
25
|
/** The model's `<think>` reasoning, streamed separately. */
|
|
26
26
|
onThinking?: (token: string) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Cap the `<think>` reasoning at this many tokens. The cap is on TOKENS, not
|
|
29
|
+
* wall-clock seconds — tok/s varies by model and hardware, so a time budget is
|
|
30
|
+
* unreliable; the SDK has no numeric reasoning budget (`reasoning_budget` is
|
|
31
|
+
* only on/off), so we count thinking tokens and stop the run once they exceed
|
|
32
|
+
* this. Omit for unlimited reasoning.
|
|
33
|
+
*/
|
|
34
|
+
maxThinkingTokens?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Fires once, the moment the thinking budget is exceeded, so the host can
|
|
37
|
+
* cancel the in-flight run (the SDK keeps generating otherwise). consumeRun
|
|
38
|
+
* stops forwarding deltas after this.
|
|
39
|
+
*/
|
|
40
|
+
onThinkingBudgetExceeded?: () => void;
|
|
41
|
+
/** Injectable monotonic-ish wall clock for deterministic timing tests. */
|
|
42
|
+
now?: () => number;
|
|
27
43
|
}
|
|
28
44
|
export interface ConsumedTurn extends ParsedTurn {
|
|
29
45
|
requestId: string;
|
|
46
|
+
/** True when the run was stopped because `<think>` hit `maxThinkingTokens`. */
|
|
47
|
+
thinkingBudgetExceeded?: boolean;
|
|
48
|
+
timing: {
|
|
49
|
+
ttftMs?: number;
|
|
50
|
+
durationMs: number;
|
|
51
|
+
};
|
|
30
52
|
}
|
|
31
53
|
/**
|
|
32
54
|
* Stream a run to completion. `contentDelta` → onToken (and the streamed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/qvac/stream.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAe,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAE9E,4DAA4D;AAC5D,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,iEAAiE;AACjE,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;IAC3C,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,cAAc;IAC7B,+DAA+D;IAC/D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,4DAA4D;IAC5D,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/qvac/stream.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAe,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAE9E,4DAA4D;AAC5D,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,iEAAiE;AACjE,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;IAC3C,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,cAAc;IAC7B,+DAA+D;IAC/D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,4DAA4D;IAC5D,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,MAAM,IAAI,CAAC;IACtC,0EAA0E;IAC1E,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,MAAM,EAAE;QACN,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAOD;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,GAAG,EAAE,iBAAiB,EACtB,QAAQ,GAAE,cAAmB,GAC5B,OAAO,CAAC,YAAY,CAAC,CAsCvB"}
|
package/dist/qvac/stream.js
CHANGED
|
@@ -7,23 +7,55 @@
|
|
|
7
7
|
* assignable to it. The actual `@qvac/sdk` import lives in `provider.ts`.
|
|
8
8
|
*/
|
|
9
9
|
import { finalToTurn } from './parse.js';
|
|
10
|
+
/** Rough token estimate (~4 chars/token) — same heuristic the context budget uses. */
|
|
11
|
+
function approxTokens(chars) {
|
|
12
|
+
return Math.ceil(chars / 4);
|
|
13
|
+
}
|
|
10
14
|
/**
|
|
11
15
|
* Stream a run to completion. `contentDelta` → onToken (and the streamed
|
|
12
16
|
* fallback text), `thinkingDelta` → onThinking. Returns the parsed turn plus the
|
|
13
17
|
* run's `requestId` (for cancellation bookkeeping by the caller).
|
|
14
18
|
*/
|
|
15
19
|
export async function consumeRun(run, handlers = {}) {
|
|
20
|
+
const now = handlers.now ?? Date.now;
|
|
21
|
+
const startedAt = now();
|
|
22
|
+
let firstTokenAt;
|
|
16
23
|
let streamed = '';
|
|
24
|
+
let thinkingChars = 0;
|
|
25
|
+
let budgetExceeded = false;
|
|
17
26
|
for await (const event of run.events) {
|
|
18
27
|
if (event.type === 'contentDelta' && typeof event.text === 'string') {
|
|
28
|
+
if (firstTokenAt === undefined && event.text.length > 0)
|
|
29
|
+
firstTokenAt = now();
|
|
19
30
|
streamed += event.text;
|
|
20
31
|
handlers.onToken?.(event.text);
|
|
21
32
|
}
|
|
22
33
|
else if (event.type === 'thinkingDelta' && typeof event.text === 'string') {
|
|
34
|
+
if (firstTokenAt === undefined && event.text.length > 0)
|
|
35
|
+
firstTokenAt = now();
|
|
23
36
|
handlers.onThinking?.(event.text);
|
|
37
|
+
if (handlers.maxThinkingTokens !== undefined && !budgetExceeded) {
|
|
38
|
+
thinkingChars += event.text.length;
|
|
39
|
+
if (approxTokens(thinkingChars) >= handlers.maxThinkingTokens) {
|
|
40
|
+
budgetExceeded = true;
|
|
41
|
+
handlers.onThinkingBudgetExceeded?.();
|
|
42
|
+
// Stop forwarding; the host cancels the run, so `final` resolves
|
|
43
|
+
// (stopReason 'cancelled') with whatever was produced so far.
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
24
47
|
}
|
|
25
48
|
}
|
|
26
49
|
const final = await run.final;
|
|
27
|
-
|
|
50
|
+
const finishedAt = now();
|
|
51
|
+
return {
|
|
52
|
+
...finalToTurn(final, streamed),
|
|
53
|
+
requestId: run.requestId,
|
|
54
|
+
thinkingBudgetExceeded: budgetExceeded,
|
|
55
|
+
timing: {
|
|
56
|
+
...(firstTokenAt === undefined ? {} : { ttftMs: Math.max(0, firstTokenAt - startedAt) }),
|
|
57
|
+
durationMs: Math.max(0, finishedAt - startedAt),
|
|
58
|
+
},
|
|
59
|
+
};
|
|
28
60
|
}
|
|
29
61
|
//# sourceMappingURL=stream.js.map
|
package/dist/qvac/stream.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/qvac/stream.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,WAAW,EAAuC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/qvac/stream.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,WAAW,EAAuC,MAAM,YAAY,CAAC;AAiD9E,sFAAsF;AACtF,SAAS,YAAY,CAAC,KAAa;IACjC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;AAC9B,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,GAAsB,EACtB,WAA2B,EAAE;IAE7B,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC;IACrC,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC;IACxB,IAAI,YAAgC,CAAC;IACrC,IAAI,QAAQ,GAAG,EAAE,CAAC;IAClB,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,IAAI,cAAc,GAAG,KAAK,CAAC;IAC3B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;QACrC,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACpE,IAAI,YAAY,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;gBAAE,YAAY,GAAG,GAAG,EAAE,CAAC;YAC9E,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC;YACvB,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;aAAM,IAAI,KAAK,CAAC,IAAI,KAAK,eA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
*/
|
|
22
22
|
import type { Recipe } from './types.js';
|
|
23
|
-
/** "buy 100 usdt" / "get me 50 xaut" / "
|
|
23
|
+
/** "buy 100 usdt" / "get me 50 xaut" / "buy a 100 usdt channel" / "purchase 10 xaut". */
|
|
24
24
|
export declare function extractBuyAsset(text: string): Record<string, unknown> | null;
|
|
25
25
|
export declare const buyAssetChannelRecipe: Recipe;
|
|
26
26
|
//# sourceMappingURL=buy-asset-channel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buy-asset-channel.d.ts","sourceRoot":"","sources":["../../src/recipe/buy-asset-channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AA4BzC,
|
|
1
|
+
{"version":3,"file":"buy-asset-channel.d.ts","sourceRoot":"","sources":["../../src/recipe/buy-asset-channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AA4BzC,yFAAyF;AACzF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAc5E;AAED,eAAO,MAAM,qBAAqB,EAAE,MAqDnC,CAAC"}
|
|
@@ -45,15 +45,16 @@ const num = (s) => {
|
|
|
45
45
|
};
|
|
46
46
|
/** Thousands separators, locale-independent (deterministic for tests). */
|
|
47
47
|
const commas = (n) => String(n).replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
48
|
-
/** "buy 100 usdt" / "get me 50 xaut" / "
|
|
48
|
+
/** "buy 100 usdt" / "get me 50 xaut" / "buy a 100 usdt channel" / "purchase 10 xaut". */
|
|
49
49
|
export function extractBuyAsset(text) {
|
|
50
50
|
const t = text.trim();
|
|
51
51
|
if (NOT_BUY.test(t) || HAS_SOURCE.test(t))
|
|
52
52
|
return null;
|
|
53
53
|
if (!RGB_ASSET.test(t))
|
|
54
54
|
return null;
|
|
55
|
-
// buy/get/want/acquire/purchase [me] <amount> <asset>
|
|
56
|
-
|
|
55
|
+
// buy/get/want/acquire/purchase [me|a|an|some|new]* <amount> <asset>
|
|
56
|
+
// Filler words (the article in "buy A 100 usdt channel") must not break extraction.
|
|
57
|
+
const m = t.match(/\b(?:buy|get|acquire|want|purchase|onboard|need)\b(?:\s+(?:me|a|an|some|new)\b)*\s+([\d.,]+)\s*([a-z]+)/i);
|
|
57
58
|
if (!m)
|
|
58
59
|
return null;
|
|
59
60
|
const asset = normAsset(m[2]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buy-asset-channel.js","sourceRoot":"","sources":["../../src/recipe/buy-asset-channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,sFAAsF;AACtF,MAAM,SAAS,GAAG,8BAA8B,CAAC;AACjD,sEAAsE;AACtE,MAAM,UAAU,GAAG,gFAAgF,CAAC;AACpG,8EAA8E;AAC9E,MAAM,OAAO,GAAG,8CAA8C,CAAC;AAC/D,oDAAoD;AACpD,MAAM,QAAQ,GAAG,mDAAmD,CAAC;AAErE,SAAS,SAAS,CAAC,CAAU;IAC3B,IAAI,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IACzB,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1B,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,MAAM,CAAC;IACzC,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,MAAM,CAAC;IACvC,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,GAAG,GAAG,CAAC,CAAU,EAAsB,EAAE;IAC7C,IAAI,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IACzB,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,OAA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gBACtB,cAAc,EAAE,CAAC,CAAC,cAAc;gBAChC,eAAe,EAAE,CAAC,CAAC,eAAe;gBAClC,UAAU,EAAE,CAAC,CAAC,UAAU;aACzB,CAAC;QACJ,CAAC;KACF;IACD,OAAO,EAAE,CAAC,GAAG,EAAE,WAAW,EAAE,EAAE;QAC5B,MAAM,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,KAA2C,CAAC;QAClE,MAAM,CAAC,GAAG,WAAgD,CAAC;QAC3D,MAAM,IAAI,GAAG,OAAO,CAAC,EAAE,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QACxF,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACvD,OAAO,oCAAoC,GAAG,CAAC,KAAK,CAAC,YAAY,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,gDAAgD,CAAC;IACnJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in "swap on Flashnet" recipe — Spark-native AMM, deterministic chain.
|
|
3
|
+
*
|
|
4
|
+
* A Flashnet swap on a small model was fragile when left to the agentic loop:
|
|
5
|
+
* the model had to discover the pool, get the asset addresses right, pick the
|
|
6
|
+
* correct simulate DIRECTION (asset_in = what the user spends), compute
|
|
7
|
+
* `min_amount_out` from slippage tolerance, and then thread all of that into
|
|
8
|
+
* execute. With Qwen3-1.7B that often produced an inverted simulate (token →
|
|
9
|
+
* BTC instead of BTC → token), and on the follow-up "yes" the skill context
|
|
10
|
+
* was lost and the model called `flashnet_simulate_swap({})` with no args.
|
|
11
|
+
*
|
|
12
|
+
* "swap 10000 sats with usdb"
|
|
13
|
+
* ↓ 1 model inference (slot extraction: from/to/amount/amount_side)
|
|
14
|
+
* flashnet_list_pools ← discover the right pool deterministically
|
|
15
|
+
* ↓
|
|
16
|
+
* flashnet_simulate_swap ← quote (read-only)
|
|
17
|
+
* ↓ [ONE confirmation gate — shows the real quote in plain English]
|
|
18
|
+
* flashnet_execute_swap ← settle (the spend)
|
|
19
|
+
*
|
|
20
|
+
* The whole chain runs with 1 LLM inference total (slot extraction), same
|
|
21
|
+
* pattern as `kaleidoswapAtomicRecipe`. The host's `flashnet_list_pools` is
|
|
22
|
+
* side-agnostic and labels symbols, so picking the right pool from the
|
|
23
|
+
* extracted asset pair is cheap and reliable.
|
|
24
|
+
*
|
|
25
|
+
* Slippage: default `max_slippage_bps = 50` (0.5%). The runner computes
|
|
26
|
+
* `min_amount_out = floor(amount_out × (1 − bps/10000))` from the simulate
|
|
27
|
+
* result before execute — never trusts the simulated value as-is.
|
|
28
|
+
*
|
|
29
|
+
* Asset taxonomy guard: matches ONLY when a Flashnet cue is present
|
|
30
|
+
* (flashnet/usdb/spark), so RGB swaps (USDT/XAUT) still go to the
|
|
31
|
+
* KaleidoSwap atomic recipe. The two recipes are disjoint.
|
|
32
|
+
*/
|
|
33
|
+
import type { Recipe } from './types.js';
|
|
34
|
+
export declare const flashnetSwapRecipe: Recipe;
|
|
35
|
+
//# sourceMappingURL=flashnet-swap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flashnet-swap.d.ts","sourceRoot":"","sources":["../../src/recipe/flashnet-swap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,YAAY,CAAC;AA2HxD,eAAO,MAAM,kBAAkB,EAAE,MA8FhC,CAAC"}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in "swap on Flashnet" recipe — Spark-native AMM, deterministic chain.
|
|
3
|
+
*
|
|
4
|
+
* A Flashnet swap on a small model was fragile when left to the agentic loop:
|
|
5
|
+
* the model had to discover the pool, get the asset addresses right, pick the
|
|
6
|
+
* correct simulate DIRECTION (asset_in = what the user spends), compute
|
|
7
|
+
* `min_amount_out` from slippage tolerance, and then thread all of that into
|
|
8
|
+
* execute. With Qwen3-1.7B that often produced an inverted simulate (token →
|
|
9
|
+
* BTC instead of BTC → token), and on the follow-up "yes" the skill context
|
|
10
|
+
* was lost and the model called `flashnet_simulate_swap({})` with no args.
|
|
11
|
+
*
|
|
12
|
+
* "swap 10000 sats with usdb"
|
|
13
|
+
* ↓ 1 model inference (slot extraction: from/to/amount/amount_side)
|
|
14
|
+
* flashnet_list_pools ← discover the right pool deterministically
|
|
15
|
+
* ↓
|
|
16
|
+
* flashnet_simulate_swap ← quote (read-only)
|
|
17
|
+
* ↓ [ONE confirmation gate — shows the real quote in plain English]
|
|
18
|
+
* flashnet_execute_swap ← settle (the spend)
|
|
19
|
+
*
|
|
20
|
+
* The whole chain runs with 1 LLM inference total (slot extraction), same
|
|
21
|
+
* pattern as `kaleidoswapAtomicRecipe`. The host's `flashnet_list_pools` is
|
|
22
|
+
* side-agnostic and labels symbols, so picking the right pool from the
|
|
23
|
+
* extracted asset pair is cheap and reliable.
|
|
24
|
+
*
|
|
25
|
+
* Slippage: default `max_slippage_bps = 50` (0.5%). The runner computes
|
|
26
|
+
* `min_amount_out = floor(amount_out × (1 − bps/10000))` from the simulate
|
|
27
|
+
* result before execute — never trusts the simulated value as-is.
|
|
28
|
+
*
|
|
29
|
+
* Asset taxonomy guard: matches ONLY when a Flashnet cue is present
|
|
30
|
+
* (flashnet/usdb/spark), so RGB swaps (USDT/XAUT) still go to the
|
|
31
|
+
* KaleidoSwap atomic recipe. The two recipes are disjoint.
|
|
32
|
+
*/
|
|
33
|
+
import { extractSwap } from './swap.js';
|
|
34
|
+
// Flashnet cue — same set the kaleidoswap-atomic recipe defers ON, so the
|
|
35
|
+
// two are disjoint by construction.
|
|
36
|
+
const FLASHNET_CUE = /\b(flashnet|usdb|spark)\b/i;
|
|
37
|
+
// Spark-token tickers that imply a Flashnet swap even without "flashnet" in
|
|
38
|
+
// the text. Keep this list small and Spark-specific — never includes RGB
|
|
39
|
+
// assets (USDT, XAUT, gold).
|
|
40
|
+
const SPARK_TOKEN = /\b(usdb)\b/i;
|
|
41
|
+
// Generic swap-intent verbs that pair with an asset name. "buy/sell/get" join
|
|
42
|
+
// the swap intent only when an ASSET is named (so "buy a gift card" doesn't
|
|
43
|
+
// route here — that's bitrefill territory).
|
|
44
|
+
const SWAP_VERB = /\b(swap|exchange|convert|trade)\b/i;
|
|
45
|
+
const BUY_VERB = /\b(buy|sell|get|purchase|acquire)\b/i;
|
|
46
|
+
const ASSET = /\b(btc|bitcoin|sats?|usdb)\b/i;
|
|
47
|
+
const NON_SWAP = /\b(gift\s?card|top-?up|esim|voucher|invoice|address|channel|inbound|liquidity|lsps?\b)\b/i;
|
|
48
|
+
const FLASHNET_INTENT = (t) => {
|
|
49
|
+
// Educational questions go to the agentic skill (which can call list_pools
|
|
50
|
+
// for an honest read).
|
|
51
|
+
if (/\b(why|how|what|when|explain|tell\s+me|do\s+I\s+need|should\s+I|can\s+I)\b/i.test(t))
|
|
52
|
+
return false;
|
|
53
|
+
// Must have a Flashnet/Spark cue OR name a Spark-native token like USDB,
|
|
54
|
+
// so this never grabs an RGB swap (those go to kaleidoswap-atomic).
|
|
55
|
+
if (!FLASHNET_CUE.test(t) && !SPARK_TOKEN.test(t))
|
|
56
|
+
return false;
|
|
57
|
+
if (NON_SWAP.test(t))
|
|
58
|
+
return false;
|
|
59
|
+
if (SWAP_VERB.test(t))
|
|
60
|
+
return true;
|
|
61
|
+
if (BUY_VERB.test(t) && ASSET.test(t))
|
|
62
|
+
return true;
|
|
63
|
+
return false;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Resolve the asset address pair from a pool row + the user's requested
|
|
67
|
+
* (from_asset, to_asset) symbols. The pool stores ONE order (typically the
|
|
68
|
+
* non-BTC token on side A, BTC on side B), but the user can phrase the swap
|
|
69
|
+
* either direction.
|
|
70
|
+
*
|
|
71
|
+
* Strategy — deduce the unknown side from the known one:
|
|
72
|
+
* 1. Match each leg to a pool side by symbol or by the BTC-ticker family.
|
|
73
|
+
* 2. If one leg resolves to a side, the other leg MUST be the opposite side
|
|
74
|
+
* (a pool only has two assets). This is the case that prevented an
|
|
75
|
+
* earlier "asset_in == asset_out" bug on regtest, where the non-BTC
|
|
76
|
+
* side carries no symbol.
|
|
77
|
+
* 3. Only as a last resort fall back to the "BTC on side B, token on side
|
|
78
|
+
* A" default — true for almost every regtest pool we've seen.
|
|
79
|
+
*/
|
|
80
|
+
function isBtcTicker(s) {
|
|
81
|
+
return s === 'BTC' || s === 'SATS' || s === 'BITCOIN';
|
|
82
|
+
}
|
|
83
|
+
function resolveLegAddresses(pool, from, to) {
|
|
84
|
+
const f = (from ?? '').toUpperCase();
|
|
85
|
+
const t = (to ?? '').toUpperCase();
|
|
86
|
+
const aSym = (pool.asset_a_symbol ?? '').toUpperCase();
|
|
87
|
+
const bSym = (pool.asset_b_symbol ?? '').toUpperCase();
|
|
88
|
+
// Which side (if any) does each leg map to?
|
|
89
|
+
const sideOf = (sym) => {
|
|
90
|
+
if (sym === aSym && aSym)
|
|
91
|
+
return 'a';
|
|
92
|
+
if (sym === bSym && bSym)
|
|
93
|
+
return 'b';
|
|
94
|
+
return undefined;
|
|
95
|
+
};
|
|
96
|
+
let fSide = sideOf(f);
|
|
97
|
+
let tSide = sideOf(t);
|
|
98
|
+
// 2. Deduce the unknown side from the known one.
|
|
99
|
+
if (!fSide && tSide)
|
|
100
|
+
fSide = tSide === 'a' ? 'b' : 'a';
|
|
101
|
+
if (!tSide && fSide)
|
|
102
|
+
tSide = fSide === 'a' ? 'b' : 'a';
|
|
103
|
+
// 3. Last-resort default — only when NEITHER side resolved. BTC on side B
|
|
104
|
+
// is the canonical layout for the Spark/Flashnet pools we've observed.
|
|
105
|
+
if (!fSide && !tSide) {
|
|
106
|
+
fSide = isBtcTicker(f) ? 'b' : 'a';
|
|
107
|
+
tSide = fSide === 'a' ? 'b' : 'a';
|
|
108
|
+
}
|
|
109
|
+
const addr = (side) => (side === 'a' ? pool.asset_a_address : pool.asset_b_address);
|
|
110
|
+
return { fromAddr: addr(fSide), toAddr: addr(tSide) };
|
|
111
|
+
}
|
|
112
|
+
/** Compute min_amount_out = floor(amount_out × (1 − bps/10000)). String-safe. */
|
|
113
|
+
function computeMinAmountOut(amountOut, slippageBps) {
|
|
114
|
+
if (!amountOut)
|
|
115
|
+
return '0';
|
|
116
|
+
try {
|
|
117
|
+
const out = BigInt(String(amountOut).replace(/[^\d]/g, ''));
|
|
118
|
+
const num = BigInt(10_000 - Math.max(0, Math.min(5_000, slippageBps)));
|
|
119
|
+
const min = (out * num) / 10000n;
|
|
120
|
+
return min.toString();
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
return '0';
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const DEFAULT_SLIPPAGE_BPS = 50;
|
|
127
|
+
export const flashnetSwapRecipe = {
|
|
128
|
+
name: 'flashnet-swap',
|
|
129
|
+
description: "Swap on Flashnet (Spark-native AMM): list pool → simulate → confirm once → execute. The user's Spark wallet IS the swap account.",
|
|
130
|
+
match: (t) => FLASHNET_INTENT(t),
|
|
131
|
+
triggers: ['flashnet', 'usdb', 'swap', 'exchange', 'convert', 'trade'],
|
|
132
|
+
slots: [
|
|
133
|
+
{ name: 'from_asset', type: 'string', description: 'Asset the user SPENDS (BTC / USDB). "swap 10000 sats with usdb" → from_asset=BTC. "sell 1 usdb" → from_asset=USDB.', required: true },
|
|
134
|
+
{ name: 'to_asset', type: 'string', description: 'Asset the user GETS (BTC / USDB). "swap 10000 sats with usdb" → to_asset=USDB. "buy USDB with sats" → to_asset=USDB.', required: true },
|
|
135
|
+
{ name: 'amount', type: 'number', description: 'The numeric amount the user named. e.g. "swap 10000 sats with usdb" → amount=10000. Always in the asset on `amount_side`.' },
|
|
136
|
+
{ name: 'amount_side', type: 'string', description: "Which leg the amount is denominated in: 'from' (the spent asset) or 'to' (the received asset). Default 'from'. 'buy 10 usdb with sats' → 'to'." },
|
|
137
|
+
],
|
|
138
|
+
// extractSwap is the same regex extractor the KaleidoSwap atomic recipe
|
|
139
|
+
// uses; it returns {from_asset, to_asset, amount, amount_side?}. With
|
|
140
|
+
// forceModelExtract=true the runner ignores the det result and always asks
|
|
141
|
+
// the model — but the det extraction still feeds the Funnel's pre-filter so
|
|
142
|
+
// bare "buy/sell" with a Spark asset routes here even before the model runs.
|
|
143
|
+
extract: extractSwap,
|
|
144
|
+
forceModelExtract: true,
|
|
145
|
+
confident: (s) => !!s.from_asset && !!s.to_asset && !!s.amount,
|
|
146
|
+
steps: [
|
|
147
|
+
// 1. Discover the pool. Side-agnostic on the host side; one row is enough.
|
|
148
|
+
{
|
|
149
|
+
tool: 'flashnet_list_pools',
|
|
150
|
+
as: 'pools',
|
|
151
|
+
args: (ctx) => ({
|
|
152
|
+
asset_a: String(ctx.slots.from_asset ?? '').toUpperCase(),
|
|
153
|
+
asset_b: String(ctx.slots.to_asset ?? '').toUpperCase(),
|
|
154
|
+
sort: 'TVL_DESC',
|
|
155
|
+
limit: 5,
|
|
156
|
+
}),
|
|
157
|
+
},
|
|
158
|
+
// 2. Quote the swap. Direction is LITERAL: asset_in = what the user
|
|
159
|
+
// spends (`from_asset`), asset_out = what they get (`to_asset`). The
|
|
160
|
+
// runner — not the model — assembles this, so the inverted-direction
|
|
161
|
+
// bug is impossible by construction.
|
|
162
|
+
{
|
|
163
|
+
tool: 'flashnet_simulate_swap',
|
|
164
|
+
as: 'sim',
|
|
165
|
+
args: (ctx) => {
|
|
166
|
+
const r = ctx.results.pools;
|
|
167
|
+
const pool = r?.pools?.[0];
|
|
168
|
+
if (!pool)
|
|
169
|
+
throw new Error(`No Flashnet pool found for ${ctx.slots.from_asset} ↔ ${ctx.slots.to_asset}.`);
|
|
170
|
+
const { fromAddr, toAddr } = resolveLegAddresses(pool, String(ctx.slots.from_asset ?? ''), String(ctx.slots.to_asset ?? ''));
|
|
171
|
+
return {
|
|
172
|
+
pool_id: pool.pool_id,
|
|
173
|
+
asset_in_address: fromAddr,
|
|
174
|
+
asset_out_address: toAddr,
|
|
175
|
+
amount_in: String(ctx.slots.amount ?? ''),
|
|
176
|
+
};
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
// 3. Settle. Confirmation-gated at the recipe level (see runner.ts).
|
|
181
|
+
// min_amount_out is computed here — never the raw simulated value — so a
|
|
182
|
+
// moving pool can't fill at a worse price than `slippage_bps` allows.
|
|
183
|
+
final: {
|
|
184
|
+
tool: 'flashnet_execute_swap',
|
|
185
|
+
as: 'exec',
|
|
186
|
+
args: (ctx) => {
|
|
187
|
+
const r = ctx.results.pools;
|
|
188
|
+
const pool = r?.pools?.[0];
|
|
189
|
+
const sim = ctx.results.sim;
|
|
190
|
+
if (!pool || !sim)
|
|
191
|
+
throw new Error('Flashnet swap: missing pool or simulation result.');
|
|
192
|
+
const { fromAddr, toAddr } = resolveLegAddresses(pool, String(ctx.slots.from_asset ?? ''), String(ctx.slots.to_asset ?? ''));
|
|
193
|
+
return {
|
|
194
|
+
pool_id: pool.pool_id,
|
|
195
|
+
asset_in_address: fromAddr,
|
|
196
|
+
asset_out_address: toAddr,
|
|
197
|
+
amount_in: String(ctx.slots.amount ?? ''),
|
|
198
|
+
min_amount_out: computeMinAmountOut(sim.amount_out, DEFAULT_SLIPPAGE_BPS),
|
|
199
|
+
max_slippage_bps: DEFAULT_SLIPPAGE_BPS,
|
|
200
|
+
};
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
// ONE confirmation, fired after simulate / before execute, with real numbers.
|
|
204
|
+
confirm: (ctx) => {
|
|
205
|
+
const sim = ctx.results.sim;
|
|
206
|
+
const from = fmtAmount(ctx.slots.amount, String(ctx.slots.from_asset ?? ''));
|
|
207
|
+
const to = fmtAmount(sim?.amount_out, String(ctx.slots.to_asset ?? ''));
|
|
208
|
+
const impact = sim?.price_impact_pct ? ` · ${sim.price_impact_pct} price impact` : '';
|
|
209
|
+
const warn = sim?.warning ? ` · ${sim.warning}` : '';
|
|
210
|
+
return `Swap ${from} → ~${to} on Flashnet (slippage cap ${DEFAULT_SLIPPAGE_BPS / 100}%)${impact}${warn}. Proceed?`;
|
|
211
|
+
},
|
|
212
|
+
summary: (ctx) => {
|
|
213
|
+
const sim = ctx.results.sim;
|
|
214
|
+
const exec = ctx.results.exec;
|
|
215
|
+
const from = fmtAmount(ctx.slots.amount, String(ctx.slots.from_asset ?? ''));
|
|
216
|
+
const got = fmtAmount(exec?.amount_out ?? sim?.amount_out, String(ctx.slots.to_asset ?? ''));
|
|
217
|
+
if (exec?.accepted === false) {
|
|
218
|
+
return `Flashnet swap rejected: ${exec?.error ?? 'unknown error'}.`;
|
|
219
|
+
}
|
|
220
|
+
return `Flashnet swap submitted: ${from} → ${got}. request_id=${exec?.request_id ?? '?'}.`;
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* Format an amount + asset for user display. BTC is rendered as "X,XXX sats"
|
|
225
|
+
* (BTC is the asset, sats is the unit; the on-the-wire amount is already in
|
|
226
|
+
* sats so no conversion is needed). Anything else is rendered as
|
|
227
|
+
* "N TICKER" with thousand-separators.
|
|
228
|
+
*/
|
|
229
|
+
function fmtAmount(amount, asset) {
|
|
230
|
+
const t = (asset ?? '').toUpperCase();
|
|
231
|
+
const n = Number(amount);
|
|
232
|
+
if (!Number.isFinite(n))
|
|
233
|
+
return `${amount ?? '?'} ${t}`;
|
|
234
|
+
const sep = n.toLocaleString('en-US');
|
|
235
|
+
if (t === 'BTC' || t === 'SATS' || t === 'BITCOIN')
|
|
236
|
+
return `${sep} sats`;
|
|
237
|
+
return `${sep} ${t}`;
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=flashnet-swap.js.map
|
|
@@ -0,0 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,IAAI,CAAC,KAAK,MAAM,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,GAAG,GAAG,OAAO,CAAC;IACzE,OAAO,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC;AACvB,CAAC"}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* ↓ [ONE confirmation gate — shows the real quote numbers]
|
|
13
13
|
* kaleidoswap_atomic_init ← MAKER locks the swap → swapstring, payment_hash
|
|
14
14
|
* rln_get_node_info ← NODE read pubkey (= taker_pubkey)
|
|
15
|
-
*
|
|
15
|
+
* rln_atomic_taker ← NODE whitelist the swapstring (taker accepts)
|
|
16
16
|
* kaleidoswap_atomic_execute ← MAKER settle (final)
|
|
17
17
|
*
|
|
18
18
|
* `forceModelExtract` ensures the model is always consulted for slot parsing
|