@kaleidorg/mind 0.7.0 → 0.8.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/README.md +96 -8
- 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 +59 -1
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +196 -17
- package/dist/engine.js.map +1 -1
- package/dist/fastpath/fastpath.d.ts +6 -1
- package/dist/fastpath/fastpath.d.ts.map +1 -1
- package/dist/fastpath/fastpath.js +16 -2
- package/dist/fastpath/fastpath.js.map +1 -1
- package/dist/fastpath/render.d.ts +2 -0
- package/dist/fastpath/render.d.ts.map +1 -0
- package/dist/fastpath/render.js +58 -0
- package/dist/fastpath/render.js.map +1 -0
- package/dist/funnel.d.ts.map +1 -1
- package/dist/funnel.js +34 -18
- 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 +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -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/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 +33 -0
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/qvac/config.d.ts +1 -1
- package/dist/qvac/config.js +1 -1
- package/dist/qvac/index.d.ts +1 -0
- package/dist/qvac/index.d.ts.map +1 -1
- package/dist/qvac/index.js +1 -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 +11 -0
- 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 +14 -4
- package/dist/qvac/provider.d.ts.map +1 -1
- package/dist/qvac/provider.js +33 -8
- 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.map +1 -1
- package/dist/qvac/tools.d.ts +5 -0
- package/dist/qvac/tools.d.ts.map +1 -1
- package/dist/qvac/tools.js +10 -0
- package/dist/qvac/tools.js.map +1 -1
- package/dist/recipe/issue-asset.d.ts.map +1 -1
- package/dist/recipe/issue-asset.js +42 -16
- package/dist/recipe/issue-asset.js.map +1 -1
- 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/registry.js +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/mock-wallet.d.ts +24 -0
- package/dist/testing/mock-wallet.d.ts.map +1 -1
- package/dist/testing/mock-wallet.js +75 -6
- package/dist/testing/mock-wallet.js.map +1 -1
- package/dist/wallet/confirm.d.ts.map +1 -1
- package/dist/wallet/confirm.js +27 -9
- package/dist/wallet/confirm.js.map +1 -1
- package/package.json +6 -1
- package/skills/README.md +1 -0
- package/skills/kaleido-trading/SKILL.md +22 -28
- package/skills/kaleido-trading/references/api.md +3 -3
- package/skills/rgb-lightning-node/SKILL.md +32 -12
- 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 +133 -3
- package/src/engine.ts +254 -19
- package/src/fastpath/fastpath.ts +22 -2
- package/src/fastpath/render.test.ts +39 -0
- package/src/fastpath/render.ts +56 -0
- package/src/funnel.mind.test.ts +15 -17
- package/src/funnel.ts +34 -19
- package/src/guards.test.ts +399 -0
- package/src/guards.ts +299 -0
- package/src/index.ts +37 -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 +35 -0
- package/src/qvac/config.ts +1 -1
- package/src/qvac/index.ts +10 -0
- package/src/qvac/models.ts +98 -0
- package/src/qvac/parse.test.ts +7 -0
- package/src/qvac/parse.ts +33 -1
- package/src/qvac/provider.test.ts +54 -1
- package/src/qvac/provider.ts +49 -13
- package/src/qvac/stream.ts +3 -5
- package/src/qvac/tools.ts +10 -0
- package/src/recipe/issue-asset.test.ts +39 -0
- package/src/recipe/issue-asset.ts +41 -13
- 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/mock-wallet.ts +73 -6
- package/src/wallet/confirm.ts +27 -9
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
* - eval → stub handlers, also via `bindKaleidoswapTools`
|
|
10
10
|
*
|
|
11
11
|
* Because the schemas are identical everywhere, skills are portable and the
|
|
12
|
-
* model comparison is honest. Tools are grouped (`market`, `
|
|
12
|
+
* model comparison is honest. Tools are grouped (`market`, `atomic`,
|
|
13
13
|
* `liquidity`) so a host can expose a read-only subset for sandbox/eval modes.
|
|
14
14
|
*
|
|
15
|
-
* Spend tools (
|
|
15
|
+
* Spend tools (init/execute an atomic swap, buy an asset channel) carry
|
|
16
16
|
* `spend: true` → `requiresConfirmation: true`, so the Engine always pauses
|
|
17
17
|
* for the host's confirm gate before executing.
|
|
18
18
|
*
|
|
@@ -38,26 +38,13 @@ export const KALEIDOSWAP_TOOLS = [
|
|
|
38
38
|
// ─── market (read) ─────────────────────────────────────────────────────
|
|
39
39
|
t('market', 'kaleidoswap_get_assets', 'List the assets KaleidoSwap supports — BTC plus the RGB assets the maker has inventory for (e.g. USDT, XAUT). Returns symbol, precision, and issuer/contract id. No args.'),
|
|
40
40
|
t('market', 'kaleidoswap_get_pairs', 'List the trading pairs currently quoted by the maker, with the latest bid/ask and the minimum/maximum executable size on each side. Use this before quoting to pick a valid pair. No args.'),
|
|
41
|
-
t('market', 'kaleidoswap_get_quote', 'Get an executable quote for swapping a specific amount on one pair. Returns a quote id (use it with
|
|
41
|
+
t('market', 'kaleidoswap_get_quote', 'Get an executable quote for swapping a specific amount on one pair. Returns a quote id (use it with atomic_init), the expected receive amount, fees, slippage, and how long the quote is valid for. Re-quote rather than reusing a stale id.', {
|
|
42
42
|
from_asset: { type: 'string', description: 'Asset to spend, e.g. "BTC" or "USDT".' },
|
|
43
43
|
to_asset: { type: 'string', description: 'Asset to receive, e.g. "USDT" or "BTC".' },
|
|
44
44
|
amount: { type: 'number', description: 'Amount of from_asset to swap. BTC is in satoshis; RGB assets use their asset-defined precision.' },
|
|
45
45
|
side: { type: 'string', enum: ['buy', 'sell'], description: 'Default "sell" (you sell from_asset). Use "buy" only when from_asset is the quote currency you spend to acquire to_asset.' },
|
|
46
46
|
}, ['from_asset', 'to_asset', 'amount']),
|
|
47
47
|
t('market', 'kaleidoswap_get_nodeinfo', "Get info about the maker's Lightning node — pubkey, host, port, connect URI. Useful before opening a channel or when the user wants to see the counterparty. No args."),
|
|
48
|
-
// ─── orders (orderbook / market-order flow) ─────────────────────────────
|
|
49
|
-
t('orders', 'kaleidoswap_place_order', 'Place an order using an executable quote. Returns order_id + access_token (save the token — required for get_order_status). SPEND: the host pauses for user confirmation before the maker is called. Use only after kaleidoswap_get_quote and only when the user has explicitly approved the amount + destination.', {
|
|
50
|
-
quote_id: { type: 'string', description: 'The quote id returned by kaleidoswap_get_quote (must still be valid).' },
|
|
51
|
-
}, ['quote_id'],
|
|
52
|
-
/* spend */ true),
|
|
53
|
-
t('orders', 'kaleidoswap_get_order_status', 'Check the status of an order by id — pending / settling / completed / failed. Poll this after place_order until the order settles. Requires the access_token returned by place_order for authenticated orders.', {
|
|
54
|
-
order_id: { type: 'string', description: 'The order id returned by kaleidoswap_place_order.' },
|
|
55
|
-
access_token: { type: 'string', description: 'The per-order access token returned by kaleidoswap_place_order. Required for status checks on the order.' },
|
|
56
|
-
}, ['order_id', 'access_token']),
|
|
57
|
-
t('orders', 'kaleidoswap_get_order_history', "Get the user's recent KaleidoSwap orders for context (last N, paginated). Read-only.", {
|
|
58
|
-
limit: { type: 'number', description: 'Max rows (default 20, max 100).' },
|
|
59
|
-
cursor: { type: 'string', description: 'Pagination cursor from a previous call.' },
|
|
60
|
-
}),
|
|
61
48
|
// ─── atomic (the trust-minimised swap chain — used by the recipe) ───────
|
|
62
49
|
t('atomic', 'kaleidoswap_atomic_init', "Initialise an atomic swap from a quote. Requires the receiver's RGB/LN invoice so the maker can lock the outgoing leg. SPEND: confirmation-gated. Returns the maker's invoice for the user to pay and an atomic id to track.", {
|
|
63
50
|
quote_id: { type: 'string', description: 'The quote id from kaleidoswap_get_quote.' },
|
|
@@ -109,7 +96,6 @@ export function kaleidoswapTools(opts = {}) {
|
|
|
109
96
|
*
|
|
110
97
|
* const source = bindKaleidoswapTools({
|
|
111
98
|
* kaleidoswap_get_quote: async (args) => makerSdk.quote(args),
|
|
112
|
-
* kaleidoswap_place_order: async ({ quote_id }) => makerSdk.placeOrder({ quoteId: quote_id }),
|
|
113
99
|
* // …
|
|
114
100
|
* });
|
|
115
101
|
* tools.register(source);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/kaleidoswap/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAe7D,SAAS,CAAC,CACR,KAAuB,EACvB,IAAY,EACZ,WAAmB,EACnB,UAAU,GAAU,EAAE,EACtB,QAAQ,GAAa,EAAE,EACvB,KAAK,GAAG,KAAK;IAEb,OAAO;QACL,KAAK;QACL,IAAI;QACJ,WAAW;QACX,KAAK;QACL,oBAAoB,EAAE,KAAK;QAC3B,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE;KACrD,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAyB;IACrD,0EAA0E;IAC1E,CAAC,CAAC,QAAQ,EACR,wBAAwB,EACxB,2KAA2K,CAAC;IAE9K,CAAC,CAAC,QAAQ,EACR,uBAAuB,EACvB,4LAA4L,CAAC;IAE/L,CAAC,CAAC,QAAQ,EACR,uBAAuB,EACvB,
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/kaleidoswap/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAe7D,SAAS,CAAC,CACR,KAAuB,EACvB,IAAY,EACZ,WAAmB,EACnB,UAAU,GAAU,EAAE,EACtB,QAA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,CAAC,IAAI;YACd,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,UAAU,EAAE,GAAG,CAAC,UAAU;YAC1B,oBAAoB,EAAE,GAAG,CAAC,oBAAoB;YAC9C,OAAO;SACR,CAAC,CAAC;IACL,CAAC;IACD,OAAO,IAAI,mBAAmB,CAAC,IAAI,CAAC,EAAE,IAAI,aAAa,EAAE,KAAK,CAAC,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createOpenAICompatibleProvider — an LLMProvider over any server that speaks
|
|
3
|
+
* the OpenAI Chat Completions API with tool calling: Ollama, llama.cpp
|
|
4
|
+
* `llama-server`, LM Studio, vLLM, `qvac serve`, or a hosted API.
|
|
5
|
+
*
|
|
6
|
+
* No dependencies: it uses `fetch` (pass your own for older runtimes or tests).
|
|
7
|
+
*
|
|
8
|
+
* The Engine keeps history as plain `{ role, content }` messages. Tool calls
|
|
9
|
+
* are written into the assistant's `rawContent` as `<tool_call>{json}</tool_call>`
|
|
10
|
+
* blocks and turned back into `tool_calls` / `tool_call_id` pairs on the next
|
|
11
|
+
* request, so the server always receives a valid tool-calling conversation.
|
|
12
|
+
*/
|
|
13
|
+
import type { Message, ToolCall } from '../types.js';
|
|
14
|
+
import type { LLMProvider, TurnInput } from './types.js';
|
|
15
|
+
export interface OpenAICompatibleOptions {
|
|
16
|
+
/** API root including the version, e.g. `http://localhost:11434/v1`. */
|
|
17
|
+
baseUrl: string;
|
|
18
|
+
/** Model name as the server knows it, e.g. `qwen3.5:4b`. */
|
|
19
|
+
model: string;
|
|
20
|
+
/** Sent as `Authorization: Bearer …` when set. */
|
|
21
|
+
apiKey?: string;
|
|
22
|
+
defaultTemperature?: number;
|
|
23
|
+
defaultMaxTokens?: number;
|
|
24
|
+
/** Stream tokens (default true). Set false for servers without SSE. */
|
|
25
|
+
stream?: boolean;
|
|
26
|
+
/** Extra JSON merged into every request body (e.g. `{ reasoning_effort: 'low' }`). */
|
|
27
|
+
extraBody?: Record<string, unknown>;
|
|
28
|
+
/** Extra request headers. */
|
|
29
|
+
headers?: Record<string, string>;
|
|
30
|
+
/** Reasoning deltas (`reasoning_content` / `reasoning`), when the server sends them. */
|
|
31
|
+
onThinking?: (token: string) => void;
|
|
32
|
+
fetch?: typeof fetch;
|
|
33
|
+
}
|
|
34
|
+
export interface OpenAITurnInput extends TurnInput {
|
|
35
|
+
temperature?: number;
|
|
36
|
+
maxTokens?: number;
|
|
37
|
+
}
|
|
38
|
+
type WireMessage = {
|
|
39
|
+
role: 'system' | 'user';
|
|
40
|
+
content: string;
|
|
41
|
+
} | {
|
|
42
|
+
role: 'assistant';
|
|
43
|
+
content: string | null;
|
|
44
|
+
tool_calls?: WireToolCall[];
|
|
45
|
+
} | {
|
|
46
|
+
role: 'tool';
|
|
47
|
+
content: string;
|
|
48
|
+
tool_call_id: string;
|
|
49
|
+
};
|
|
50
|
+
interface WireToolCall {
|
|
51
|
+
id: string;
|
|
52
|
+
type: 'function';
|
|
53
|
+
function: {
|
|
54
|
+
name: string;
|
|
55
|
+
arguments: string;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** The assistant frame the Engine stores: visible text plus one block per call. */
|
|
59
|
+
export declare function encodeToolCalls(text: string, calls: ToolCall[]): string;
|
|
60
|
+
/** Engine history → Chat Completions messages, with ids pairing calls and results. */
|
|
61
|
+
export declare function toWireMessages(messages: Message[], system?: string): WireMessage[];
|
|
62
|
+
export declare function createOpenAICompatibleProvider(options: OpenAICompatibleOptions): LLMProvider;
|
|
63
|
+
export {};
|
|
64
|
+
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/providers/openai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAo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E,MAAM,CAAA;KAAE,CAAC;CAC/C;AAID,mFAAmF;AACnF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,MAAM,CAGvE;AAED,sFAAsF;AACtF,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,EAAE,CAgClF;AAqDD,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,uBAAuB,GAAG,WAAW,CAsI5F"}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { extractTextToolCalls } from '../qvac/parse.js';
|
|
2
|
+
import { toolParametersSchema } from '../qvac/tools.js';
|
|
3
|
+
const TOOL_CALL_BLOCK = /<tool_call\b[^>]*>[\s\S]*?<\/tool_call>/gi;
|
|
4
|
+
/** The assistant frame the Engine stores: visible text plus one block per call. */
|
|
5
|
+
export function encodeToolCalls(text, calls) {
|
|
6
|
+
const blocks = calls.map((c) => `<tool_call>${JSON.stringify({ name: c.name, arguments: c.arguments })}</tool_call>`);
|
|
7
|
+
return [text.trim(), ...blocks].filter(Boolean).join('\n');
|
|
8
|
+
}
|
|
9
|
+
/** Engine history → Chat Completions messages, with ids pairing calls and results. */
|
|
10
|
+
export function toWireMessages(messages, system) {
|
|
11
|
+
const out = system ? [{ role: 'system', content: system }] : [];
|
|
12
|
+
let pending = [];
|
|
13
|
+
messages.forEach((m, i) => {
|
|
14
|
+
if (m.role === 'assistant') {
|
|
15
|
+
const calls = extractTextToolCalls(m.content);
|
|
16
|
+
const text = m.content.replace(TOOL_CALL_BLOCK, '').trim();
|
|
17
|
+
pending = calls.map((_, j) => `call_${i}_${j}`);
|
|
18
|
+
out.push(calls.length
|
|
19
|
+
? {
|
|
20
|
+
role: 'assistant',
|
|
21
|
+
content: text || null,
|
|
22
|
+
tool_calls: calls.map((c, j) => ({
|
|
23
|
+
id: pending[j],
|
|
24
|
+
type: 'function',
|
|
25
|
+
function: { name: c.name, arguments: JSON.stringify(c.arguments) },
|
|
26
|
+
})),
|
|
27
|
+
}
|
|
28
|
+
: { role: 'assistant', content: m.content });
|
|
29
|
+
}
|
|
30
|
+
else if (m.role === 'tool') {
|
|
31
|
+
const id = pending.shift();
|
|
32
|
+
// A tool message with no call to answer (e.g. a parse-error note) would
|
|
33
|
+
// be rejected by the server; send it as user context instead.
|
|
34
|
+
out.push(id ? { role: 'tool', content: m.content, tool_call_id: id } : { role: 'user', content: `Tool result: ${m.content}` });
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
pending = [];
|
|
38
|
+
out.push({ role: m.role, content: m.content });
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
function wireToolChoice(choice) {
|
|
44
|
+
if (!choice)
|
|
45
|
+
return undefined;
|
|
46
|
+
if (choice === 'auto' || choice === 'none' || choice === 'required')
|
|
47
|
+
return choice;
|
|
48
|
+
return { type: 'function', function: { name: choice } };
|
|
49
|
+
}
|
|
50
|
+
function absorbDelta(acc, delta, onToken, onThinking) {
|
|
51
|
+
if (typeof delta?.content === 'string' && delta.content) {
|
|
52
|
+
acc.content += delta.content;
|
|
53
|
+
onToken?.(delta.content);
|
|
54
|
+
}
|
|
55
|
+
const reasoning = delta?.reasoning_content ?? delta?.reasoning;
|
|
56
|
+
if (typeof reasoning === 'string' && reasoning)
|
|
57
|
+
onThinking?.(reasoning);
|
|
58
|
+
for (const tc of delta?.tool_calls ?? []) {
|
|
59
|
+
const index = typeof tc.index === 'number' ? tc.index : acc.calls.size;
|
|
60
|
+
const cur = acc.calls.get(index) ?? { name: '', args: '' };
|
|
61
|
+
if (tc.id)
|
|
62
|
+
cur.id = tc.id;
|
|
63
|
+
if (tc.function?.name)
|
|
64
|
+
cur.name += tc.function.name;
|
|
65
|
+
if (tc.function?.arguments) {
|
|
66
|
+
cur.args += typeof tc.function.arguments === 'string' ? tc.function.arguments : JSON.stringify(tc.function.arguments);
|
|
67
|
+
}
|
|
68
|
+
acc.calls.set(index, cur);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async function readSse(body, onEvent) {
|
|
72
|
+
const reader = body.getReader();
|
|
73
|
+
const decoder = new TextDecoder();
|
|
74
|
+
let buffer = '';
|
|
75
|
+
for (;;) {
|
|
76
|
+
const { value, done } = await reader.read();
|
|
77
|
+
if (done)
|
|
78
|
+
break;
|
|
79
|
+
buffer += decoder.decode(value, { stream: true });
|
|
80
|
+
let nl;
|
|
81
|
+
while ((nl = buffer.indexOf('\n')) >= 0) {
|
|
82
|
+
const line = buffer.slice(0, nl).trim();
|
|
83
|
+
buffer = buffer.slice(nl + 1);
|
|
84
|
+
if (line.startsWith('data:'))
|
|
85
|
+
onEvent(line.slice(5).trim());
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const last = buffer.trim();
|
|
89
|
+
if (last.startsWith('data:'))
|
|
90
|
+
onEvent(last.slice(5).trim());
|
|
91
|
+
}
|
|
92
|
+
export function createOpenAICompatibleProvider(options) {
|
|
93
|
+
const doFetch = options.fetch ?? globalThis.fetch;
|
|
94
|
+
if (!doFetch)
|
|
95
|
+
throw new Error('No fetch available; pass options.fetch');
|
|
96
|
+
const url = `${options.baseUrl.replace(/\/+$/, '')}/chat/completions`;
|
|
97
|
+
const inflight = new Map();
|
|
98
|
+
let seq = 0;
|
|
99
|
+
return {
|
|
100
|
+
name: 'openai-compatible',
|
|
101
|
+
async runTurn(input) {
|
|
102
|
+
const requestId = `oai-${Date.now().toString(36)}-${++seq}`;
|
|
103
|
+
const controller = new AbortController();
|
|
104
|
+
inflight.set(requestId, controller);
|
|
105
|
+
const onAbort = () => controller.abort();
|
|
106
|
+
input.signal?.addEventListener('abort', onAbort, { once: true });
|
|
107
|
+
if (input.signal?.aborted)
|
|
108
|
+
controller.abort();
|
|
109
|
+
const stream = options.stream ?? true;
|
|
110
|
+
const temperature = input.temperature ?? options.defaultTemperature;
|
|
111
|
+
const maxTokens = input.maxTokens ?? options.defaultMaxTokens;
|
|
112
|
+
const tools = input.tools.map((t) => ({
|
|
113
|
+
type: 'function',
|
|
114
|
+
function: { name: t.name, description: t.description ?? '', parameters: toolParametersSchema(t) },
|
|
115
|
+
}));
|
|
116
|
+
const toolChoice = tools.length ? wireToolChoice(input.toolChoice) : undefined;
|
|
117
|
+
const body = {
|
|
118
|
+
model: options.model,
|
|
119
|
+
messages: toWireMessages(input.messages, input.system),
|
|
120
|
+
stream,
|
|
121
|
+
...(stream ? { stream_options: { include_usage: true } } : {}),
|
|
122
|
+
...(temperature !== undefined ? { temperature } : {}),
|
|
123
|
+
...(maxTokens !== undefined ? { max_tokens: maxTokens } : {}),
|
|
124
|
+
...(tools.length ? { tools } : {}),
|
|
125
|
+
...(toolChoice ? { tool_choice: toolChoice } : {}),
|
|
126
|
+
...options.extraBody,
|
|
127
|
+
};
|
|
128
|
+
const startedAt = Date.now();
|
|
129
|
+
let firstTokenAt;
|
|
130
|
+
const mark = (f) => (t) => {
|
|
131
|
+
firstTokenAt ??= Date.now();
|
|
132
|
+
f?.(t);
|
|
133
|
+
};
|
|
134
|
+
const acc = { content: '', calls: new Map() };
|
|
135
|
+
let cancelled = false;
|
|
136
|
+
try {
|
|
137
|
+
const res = await doFetch(url, {
|
|
138
|
+
method: 'POST',
|
|
139
|
+
headers: {
|
|
140
|
+
'content-type': 'application/json',
|
|
141
|
+
...(options.apiKey ? { authorization: `Bearer ${options.apiKey}` } : {}),
|
|
142
|
+
...options.headers,
|
|
143
|
+
},
|
|
144
|
+
body: JSON.stringify(body),
|
|
145
|
+
signal: controller.signal,
|
|
146
|
+
});
|
|
147
|
+
if (!res.ok) {
|
|
148
|
+
const detail = await res.text().catch(() => '');
|
|
149
|
+
throw new Error(`${options.baseUrl} returned ${res.status}: ${detail.slice(0, 300)}`);
|
|
150
|
+
}
|
|
151
|
+
if (stream && res.body) {
|
|
152
|
+
await readSse(res.body, (data) => {
|
|
153
|
+
if (data === '[DONE]')
|
|
154
|
+
return;
|
|
155
|
+
let chunk;
|
|
156
|
+
try {
|
|
157
|
+
chunk = JSON.parse(data);
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (chunk.usage)
|
|
163
|
+
acc.usage = chunk.usage;
|
|
164
|
+
const choice = chunk.choices?.[0];
|
|
165
|
+
if (!choice)
|
|
166
|
+
return;
|
|
167
|
+
absorbDelta(acc, choice.delta, mark(input.onToken), mark(options.onThinking));
|
|
168
|
+
if (choice.finish_reason)
|
|
169
|
+
acc.finishReason = choice.finish_reason;
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
const json = await res.json();
|
|
174
|
+
const choice = json.choices?.[0];
|
|
175
|
+
absorbDelta(acc, { ...choice?.message, tool_calls: choice?.message?.tool_calls?.map((c, index) => ({ index, ...c })) }, input.onToken, options.onThinking);
|
|
176
|
+
acc.finishReason = choice?.finish_reason;
|
|
177
|
+
acc.usage = json.usage;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
catch (err) {
|
|
181
|
+
if (!controller.signal.aborted)
|
|
182
|
+
throw err;
|
|
183
|
+
cancelled = true;
|
|
184
|
+
}
|
|
185
|
+
finally {
|
|
186
|
+
inflight.delete(requestId);
|
|
187
|
+
input.signal?.removeEventListener('abort', onAbort);
|
|
188
|
+
}
|
|
189
|
+
const toolCalls = [];
|
|
190
|
+
const toolErrors = [];
|
|
191
|
+
for (const c of [...acc.calls.entries()].sort(([a], [b]) => a - b).map(([, v]) => v)) {
|
|
192
|
+
if (!c.name)
|
|
193
|
+
continue;
|
|
194
|
+
try {
|
|
195
|
+
const args = c.args.trim() ? JSON.parse(c.args) : {};
|
|
196
|
+
toolCalls.push({ ...(c.id ? { id: c.id } : {}), name: c.name, arguments: args && typeof args === 'object' ? args : {} });
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
toolErrors.push({ code: 'PARSE_ERROR', message: `arguments for ${c.name} are not valid JSON`, raw: c.args });
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
// Models that ignore the tools API sometimes write the call as text.
|
|
203
|
+
if (!toolCalls.length && !toolErrors.length) {
|
|
204
|
+
for (const c of extractTextToolCalls(acc.content))
|
|
205
|
+
toolCalls.push(c);
|
|
206
|
+
}
|
|
207
|
+
const text = acc.content.replace(TOOL_CALL_BLOCK, '').trim();
|
|
208
|
+
const truncated = acc.finishReason === 'length';
|
|
209
|
+
const inference = {
|
|
210
|
+
requestId,
|
|
211
|
+
durationMs: Date.now() - startedAt,
|
|
212
|
+
status: cancelled ? 'cancelled' : truncated ? 'truncated' : 'completed',
|
|
213
|
+
...(firstTokenAt !== undefined ? { ttftMs: firstTokenAt - startedAt } : {}),
|
|
214
|
+
...(acc.usage?.prompt_tokens !== undefined ? { promptTokens: acc.usage.prompt_tokens } : {}),
|
|
215
|
+
...(acc.usage?.completion_tokens !== undefined ? { completionTokens: acc.usage.completion_tokens } : {}),
|
|
216
|
+
...(acc.usage?.total_tokens !== undefined ? { totalTokens: acc.usage.total_tokens } : {}),
|
|
217
|
+
...(acc.finishReason ? { stopReason: acc.finishReason } : {}),
|
|
218
|
+
};
|
|
219
|
+
return {
|
|
220
|
+
text,
|
|
221
|
+
rawContent: encodeToolCalls(text, toolCalls),
|
|
222
|
+
toolCalls,
|
|
223
|
+
...(toolErrors.length && !toolCalls.length ? { toolErrors } : {}),
|
|
224
|
+
requestId,
|
|
225
|
+
inference,
|
|
226
|
+
};
|
|
227
|
+
},
|
|
228
|
+
async cancel(requestId) {
|
|
229
|
+
inflight.get(requestId)?.abort();
|
|
230
|
+
},
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=openai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../../src/providers/openai.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAA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gBAC5F,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,iBAAiB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,GAAG,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxG,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,GAAG,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACzF,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC9D,CAAC;YAEF,OAAO;gBACL,IAAI;gBACJ,UAAU,EAAE,eAAe,CAAC,IAAI,EAAE,SAAS,CAAC;gBAC5C,SAAS;gBACT,GAAG,CAAC,UAAU,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACjE,SAAS;gBACT,SAAS;aACV,CAAC;QACJ,CAAC;QAED,KAAK,CAAC,MAAM,CAAC,SAAiB;YAC5B,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC;QACnC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -15,10 +15,34 @@ export interface TurnInput {
|
|
|
15
15
|
tools: ToolDef[];
|
|
16
16
|
/** System prompt, when not already present as a message. */
|
|
17
17
|
system?: string;
|
|
18
|
+
/**
|
|
19
|
+
* `'required'` forces a tool call, a tool name forces that tool, `'none'`
|
|
20
|
+
* forbids tools. Omit for the model's own choice. Ignored when `tools` is
|
|
21
|
+
* empty or the provider has no such control.
|
|
22
|
+
*/
|
|
23
|
+
toolChoice?: ToolChoice;
|
|
24
|
+
/**
|
|
25
|
+
* `'off'` asks the provider to skip reasoning for this turn (e.g. a forced
|
|
26
|
+
* tool call). Ignored by providers without reasoning control.
|
|
27
|
+
*/
|
|
28
|
+
thinking?: 'off';
|
|
29
|
+
/**
|
|
30
|
+
* Same value on every call of one agentic run, whose history only grows.
|
|
31
|
+
* Providers with a session cache (QVAC `kvCache`) can then send only the new
|
|
32
|
+
* message instead of the whole prompt.
|
|
33
|
+
*/
|
|
34
|
+
sessionKey?: string;
|
|
18
35
|
/** Visible content tokens as they stream. */
|
|
19
36
|
onToken?: (token: string) => void;
|
|
20
37
|
signal?: AbortSignal;
|
|
21
38
|
}
|
|
39
|
+
export type ToolChoice = 'auto' | 'none' | 'required' | (string & {});
|
|
40
|
+
/** A tool-call region the model emitted that the provider could not turn into a call. */
|
|
41
|
+
export interface ToolCallError {
|
|
42
|
+
code: 'PARSE_ERROR' | 'VALIDATION_ERROR' | 'UNKNOWN_TOOL' | (string & {});
|
|
43
|
+
message: string;
|
|
44
|
+
raw?: string;
|
|
45
|
+
}
|
|
22
46
|
/** Judge-auditable metrics for one provider inference request. */
|
|
23
47
|
export interface InferenceMetrics {
|
|
24
48
|
requestId?: string;
|
|
@@ -46,15 +70,24 @@ export interface TurnOutput {
|
|
|
46
70
|
rawContent: string;
|
|
47
71
|
/** Tool calls the model requested this turn (empty ⇒ final answer). */
|
|
48
72
|
toolCalls: ToolCall[];
|
|
73
|
+
/** Tool-call attempts that failed to parse or validate this turn. */
|
|
74
|
+
toolErrors?: ToolCallError[];
|
|
49
75
|
/** Provider request id, for cancellation. */
|
|
50
76
|
requestId?: string;
|
|
51
77
|
/** Optional local-inference receipt. Hosts may persist this as JSONL evidence. */
|
|
52
78
|
inference?: InferenceMetrics;
|
|
79
|
+
/**
|
|
80
|
+
* True when the turn produced no visible answer because it ran out of budget
|
|
81
|
+
* (e.g. reasoning used the whole output cap). `text` may hold a placeholder.
|
|
82
|
+
*/
|
|
83
|
+
incomplete?: boolean;
|
|
53
84
|
}
|
|
54
85
|
export interface LLMProvider {
|
|
55
86
|
readonly name: string;
|
|
56
87
|
/** Run one completion turn. */
|
|
57
88
|
runTurn(input: TurnInput): Promise<TurnOutput>;
|
|
89
|
+
/** Drop whatever the provider cached for `sessionKey` (end of an agentic run). */
|
|
90
|
+
endSession?(sessionKey: string): Promise<void>;
|
|
58
91
|
/** Cancel an in-flight turn by request id, if the provider supports it. */
|
|
59
92
|
cancel?(requestId: string): Promise<void>;
|
|
60
93
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/providers/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE9D,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,kEAAkE;AAClE,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,QAAQ,CAAC;CAC5D;AAED,M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ONFIG_GPU: {
|
|
|
27
27
|
};
|
|
28
28
|
/**
|
|
29
29
|
* Delegated to a desktop provider — it has the RAM to run a big context, so give
|
|
30
|
-
* the agentic prompt plenty of room (Qwen3
|
|
30
|
+
* the agentic prompt plenty of room (Qwen3.5 supports far more than this). 2048
|
|
31
31
|
* overflowed with the system prompt + tool/skill definitions alone.
|
|
32
32
|
*/
|
|
33
33
|
export declare const DELEGATE_LLM_CONFIG: {
|
package/dist/qvac/config.js
CHANGED
|
@@ -27,7 +27,7 @@ export const LOCAL_LLM_CONFIG_GPU = {
|
|
|
27
27
|
};
|
|
28
28
|
/**
|
|
29
29
|
* Delegated to a desktop provider — it has the RAM to run a big context, so give
|
|
30
|
-
* the agentic prompt plenty of room (Qwen3
|
|
30
|
+
* the agentic prompt plenty of room (Qwen3.5 supports far more than this). 2048
|
|
31
31
|
* overflowed with the system prompt + tool/skill definitions alone.
|
|
32
32
|
*/
|
|
33
33
|
export const DELEGATE_LLM_CONFIG = {
|
package/dist/qvac/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export { cleanAssistantVisibleText, sanitizeForSupertonic, } from './text.js';
|
|
12
12
|
export { LOCAL_LLM_CONFIG, LOCAL_LLM_CONFIG_GPU, DELEGATE_LLM_CONFIG, TTS_SAMPLE_RATE, DEFAULT_VOICE_STREAM_PARAMS, WHISPER_LANGS, normalizeWhisperLang, } from './config.js';
|
|
13
|
+
export { QWEN35_MODELS, DEFAULT_MODEL_ID, DEFAULT_SMALL_DEVICE_MODEL_ID, DEFAULT_QVAC_MODEL, DEFAULT_SMALL_DEVICE_QVAC_MODEL, getRecommendedModel, type RecommendedModel, } from './models.js';
|
|
13
14
|
export { finalToTurn, type QvacFinalLike, type ParsedTurn, type QvacTurnStats, } from './parse.js';
|
|
14
15
|
export { consumeRun, type CompletionEventLike, type CompletionRunLike, type StreamHandlers, type ConsumedTurn, } from './stream.js';
|
|
15
16
|
export { toQvacTools, type QvacTool, type QvacToolProp } from './tools.js';
|
package/dist/qvac/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/qvac/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,2BAA2B,EAC3B,aAAa,EACb,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,aAAa,GACnB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,UAAU,EACV,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,YAAY,GAClB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAE3E,OAAO,EACL,kBAAkB,EAClB,KAAK,mBAAmB,EACxB,KAAK,aAAa,GACnB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,eAAe,EACf,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,QAAQ,GACd,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,0BAA0B,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,GAC1B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,KAAK,gBAAgB,EACrB,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"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AM,eAAe,CAAC"}
|
package/dist/qvac/index.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export { cleanAssistantVisibleText, sanitizeForSupertonic, } from './text.js';
|
|
12
12
|
export { LOCAL_LLM_CONFIG, LOCAL_LLM_CONFIG_GPU, DELEGATE_LLM_CONFIG, TTS_SAMPLE_RATE, DEFAULT_VOICE_STREAM_PARAMS, WHISPER_LANGS, normalizeWhisperLang, } from './config.js';
|
|
13
|
+
export { QWEN35_MODELS, DEFAULT_MODEL_ID, DEFAULT_SMALL_DEVICE_MODEL_ID, DEFAULT_QVAC_MODEL, DEFAULT_SMALL_DEVICE_QVAC_MODEL, getRecommendedModel, } from './models.js';
|
|
13
14
|
export { finalToTurn, } from './parse.js';
|
|
14
15
|
export { consumeRun, } from './stream.js';
|
|
15
16
|
export { toQvacTools } from './tools.js';
|
package/dist/qvac/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/qvac/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,2BAA2B,EAC3B,aAAa,EACb,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,WAAW,GAIZ,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,UAAU,GAKX,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,WAAW,EAAoC,MAAM,YAAY,CAAC;AAE3E,OAAO,EACL,kBAAkB,GAGnB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,eAAe,GAKhB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,0BAA0B,GAM3B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,GAGpB,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/qvac/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,2BAA2B,EAC3B,aAAa,EACb,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,6BAA6B,EAC7B,kBAAkB,EAClB,+BAA+B,EAC/B,mBAAmB,GAEpB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,WAAW,GAIZ,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,UAAU,GAKX,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,WAAW,EAAoC,MAAM,YAAY,CAAC;AAE3E,OAAO,EACL,kBAAkB,GAGnB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,eAAe,GAKhB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,0BAA0B,GAM3B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,GAGpB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recommended local models. Plain data (no SDK import): `qvacConstant` is the
|
|
3
|
+
* name of the matching @qvac/sdk registry export (present since @qvac/sdk
|
|
4
|
+
* 0.13.1), `hfRepo`/`hfFile` the same GGUF on Hugging Face for hosts that
|
|
5
|
+
* download directly. Sizes are the exact file sizes.
|
|
6
|
+
*/
|
|
7
|
+
export interface RecommendedModel {
|
|
8
|
+
id: string;
|
|
9
|
+
family: string;
|
|
10
|
+
displayName: string;
|
|
11
|
+
/** Name of the @qvac/sdk model constant, e.g. `QWEN3_5_4B_MULTIMODAL_Q4_K_M`. */
|
|
12
|
+
qvacConstant: string;
|
|
13
|
+
quant: string;
|
|
14
|
+
sizeBytes: number;
|
|
15
|
+
hfRepo: string;
|
|
16
|
+
hfFile: string;
|
|
17
|
+
/** Rough RAM needed to run it with the agent's context window. */
|
|
18
|
+
ramHintGb: number;
|
|
19
|
+
notes: string;
|
|
20
|
+
}
|
|
21
|
+
export declare const QWEN35_MODELS: readonly RecommendedModel[];
|
|
22
|
+
/** Default model for every host (provider sidecar, CLI, examples). */
|
|
23
|
+
export declare const DEFAULT_MODEL_ID = "qwen3.5-2b-q4_k_m";
|
|
24
|
+
/** Default model for phones and other small devices. */
|
|
25
|
+
export declare const DEFAULT_SMALL_DEVICE_MODEL_ID = "qwen3.5-2b-q4_k_m";
|
|
26
|
+
export declare function getRecommendedModel(id: string): RecommendedModel | undefined;
|
|
27
|
+
/** @qvac/sdk constant name of the default, e.g. for `sdk[DEFAULT_QVAC_MODEL]`. */
|
|
28
|
+
export declare const DEFAULT_QVAC_MODEL: string;
|
|
29
|
+
/** @qvac/sdk constant name of the small-device default. */
|
|
30
|
+
export declare const DEFAULT_SMALL_DEVICE_QVAC_MODEL: string;
|
|
31
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/qvac/models.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,aAAa,EAAE,SAAS,gBAAgB,EA6DpD,CAAC;AAEF,sEAAsE;AACtE,eAAO,MAAM,gBAAgB,sBAAsB,CAAC;AACpD,wDAAwD;AACxD,eAAO,MAAM,6BAA6B,sBAAsB,CAAC;AAEjE,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAE5E;AAED,kFAAkF;AAClF,eAAO,MAAM,kBAAkB,QAAsD,CAAC;AACtF,2DAA2D;AAC3D,eAAO,MAAM,+BAA+B,QAAmE,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recommended local models. Plain data (no SDK import): `qvacConstant` is the
|
|
3
|
+
* name of the matching @qvac/sdk registry export (present since @qvac/sdk
|
|
4
|
+
* 0.13.1), `hfRepo`/`hfFile` the same GGUF on Hugging Face for hosts that
|
|
5
|
+
* download directly. Sizes are the exact file sizes.
|
|
6
|
+
*/
|
|
7
|
+
export const QWEN35_MODELS = [
|
|
8
|
+
{
|
|
9
|
+
id: 'qwen3.5-0.8b-q4_k_m',
|
|
10
|
+
family: 'qwen3.5',
|
|
11
|
+
displayName: 'Qwen 3.5 · 0.8B',
|
|
12
|
+
qvacConstant: 'QWEN3_5_0_8B_MULTIMODAL_Q4_K_M',
|
|
13
|
+
quant: 'Q4_K_M',
|
|
14
|
+
sizeBytes: 532_517_120,
|
|
15
|
+
hfRepo: 'unsloth/Qwen3.5-0.8B-GGUF',
|
|
16
|
+
hfFile: 'Qwen3.5-0.8B-Q4_K_M.gguf',
|
|
17
|
+
ramHintGb: 1.5,
|
|
18
|
+
notes: 'Smoke tests only. Loops on wallet actions in our signet bench; fine for chat and single read-only calls.',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: 'qwen3.5-2b-q4_k_m',
|
|
22
|
+
family: 'qwen3.5',
|
|
23
|
+
displayName: 'Qwen 3.5 · 2B',
|
|
24
|
+
qvacConstant: 'QWEN3_5_2B_MULTIMODAL_Q4_K_M',
|
|
25
|
+
quant: 'Q4_K_M',
|
|
26
|
+
sizeBytes: 1_280_835_840,
|
|
27
|
+
hfRepo: 'unsloth/Qwen3.5-2B-GGUF',
|
|
28
|
+
hfFile: 'Qwen3.5-2B-Q4_K_M.gguf',
|
|
29
|
+
ramHintGb: 3,
|
|
30
|
+
notes: 'Recommended default. Passed all 7 wallet tasks of our signet RGB bench at 45–150 s per question on an M4 laptop; also fits phones.',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: 'qwen3.5-4b-q4_k_m',
|
|
34
|
+
family: 'qwen3.5',
|
|
35
|
+
displayName: 'Qwen 3.5 · 4B',
|
|
36
|
+
qvacConstant: 'QWEN3_5_4B_MULTIMODAL_Q4_K_M',
|
|
37
|
+
quant: 'Q4_K_M',
|
|
38
|
+
sizeBytes: 2_740_937_888,
|
|
39
|
+
hfRepo: 'unsloth/Qwen3.5-4B-GGUF',
|
|
40
|
+
hfFile: 'Qwen3.5-4B-Q4_K_M.gguf',
|
|
41
|
+
ramHintGb: 5,
|
|
42
|
+
notes: 'Same correctness as 2B in our bench, about twice as slow (105–330 s per question on an M4). Pick it for longer free-form answers.',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'qwen3.5-9b-q4_k_m',
|
|
46
|
+
family: 'qwen3.5',
|
|
47
|
+
displayName: 'Qwen 3.5 · 9B',
|
|
48
|
+
qvacConstant: 'QWEN3_5_9B_MULTIMODAL_Q4_K_M',
|
|
49
|
+
quant: 'Q4_K_M',
|
|
50
|
+
sizeBytes: 5_680_522_464,
|
|
51
|
+
hfRepo: 'unsloth/Qwen3.5-9B-GGUF',
|
|
52
|
+
hfFile: 'Qwen3.5-9B-Q4_K_M.gguf',
|
|
53
|
+
ramHintGb: 9,
|
|
54
|
+
notes: 'Needs 16 GB of RAM. Slow for interactive use (180–690 s per question on an M4); for unattended multi-step tasks.',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: 'qwen3.6-35b-a3b-q4_k_m',
|
|
58
|
+
family: 'qwen3.6',
|
|
59
|
+
displayName: 'Qwen 3.6 · 35B-A3B (MoE)',
|
|
60
|
+
qvacConstant: 'QWEN3_6_35B_A3B_MULTIMODAL_Q4_K_M',
|
|
61
|
+
quant: 'UD-Q4_K_M',
|
|
62
|
+
sizeBytes: 22_134_528_992,
|
|
63
|
+
hfRepo: 'unsloth/Qwen3.6-35B-A3B-GGUF',
|
|
64
|
+
hfFile: 'Qwen3.6-35B-A3B-UD-Q4_K_M.gguf',
|
|
65
|
+
ramHintGb: 26,
|
|
66
|
+
notes: 'Big machines only (32 GB+). MoE with ~3B active parameters: best quality, 22 GB download.',
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
/** Default model for every host (provider sidecar, CLI, examples). */
|
|
70
|
+
export const DEFAULT_MODEL_ID = 'qwen3.5-2b-q4_k_m';
|
|
71
|
+
/** Default model for phones and other small devices. */
|
|
72
|
+
export const DEFAULT_SMALL_DEVICE_MODEL_ID = 'qwen3.5-2b-q4_k_m';
|
|
73
|
+
export function getRecommendedModel(id) {
|
|
74
|
+
return QWEN35_MODELS.find((m) => m.id === id);
|
|
75
|
+
}
|
|
76
|
+
/** @qvac/sdk constant name of the default, e.g. for `sdk[DEFAULT_QVAC_MODEL]`. */
|
|
77
|
+
export const DEFAULT_QVAC_MODEL = getRecommendedModel(DEFAULT_MODEL_ID).qvacConstant;
|
|
78
|
+
/** @qvac/sdk constant name of the small-device default. */
|
|
79
|
+
export const DEFAULT_SMALL_DEVICE_QVAC_MODEL = getRecommendedModel(DEFAULT_SMALL_DEVICE_MODEL_ID).qvacConstant;
|
|
80
|
+
//# sourceMappingURL=models.js.map
|