@qvac/harness 1.0.0-rc.22 → 1.0.0-rc.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +1 -0
  3. package/dist-lib/index.d.ts +4 -1
  4. package/dist-lib/index.js +12 -4
  5. package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.js +2 -1
  6. package/dist-lib/lib/contract/completion.d.ts +1 -1
  7. package/dist-lib/lib/contract/drive.d.ts +24 -0
  8. package/dist-lib/lib/contract/root-search.d.ts +34 -0
  9. package/dist-lib/lib/contract/root-search.js +1 -0
  10. package/dist-lib/lib/contract/run.d.ts +2 -0
  11. package/dist-lib/lib/helpers/root-search.d.ts +3 -0
  12. package/dist-lib/lib/helpers/root-search.js +74 -0
  13. package/dist-lib/lib/machine/completion/metrics.js +3 -1
  14. package/dist-lib/lib/machine/completion/types.d.ts +2 -0
  15. package/dist-lib/lib/models/model-catalog-constants.d.ts +1 -0
  16. package/dist-lib/lib/models/model-catalog-constants.js +5 -1
  17. package/dist-lib/lib/models/model-catalog.d.ts +10 -3
  18. package/dist-lib/lib/models/model-catalog.js +14 -8
  19. package/dist-lib/lib/models/model-delete.js +3 -0
  20. package/dist-lib/lib/models/model-list.d.ts +2 -1
  21. package/dist-lib/lib/models/model-list.js +5 -1
  22. package/dist-lib/lib/models/model-pool.d.ts +5 -0
  23. package/dist-lib/lib/models/model-pool.js +16 -4
  24. package/dist-lib/lib/plugins/registry.d.ts +2 -0
  25. package/dist-lib/lib/residency/index.js +9 -6
  26. package/dist-lib/lib/spawn.d.ts +9 -0
  27. package/dist-lib/lib/tools/files/glob.js +24 -2
  28. package/dist-lib/lib/tools/files/grep.js +47 -18
  29. package/dist-lib/lib/tools/fs/engine.d.ts +9 -0
  30. package/dist-lib/lib/tools/fs/engine.js +28 -0
  31. package/dist-lib/lib/tools/fs/walk.d.ts +3 -0
  32. package/dist-lib/lib/tools/fs/walk.js +20 -20
  33. package/dist-lib/lib/tools/toolsets.d.ts +1 -1
  34. package/dist-lib/lib/tools/toolsets.js +1 -0
  35. package/dist-lib/plugins/charts/chart-tool.d.ts +8 -0
  36. package/dist-lib/plugins/charts/chart-tool.js +175 -0
  37. package/dist-lib/plugins/charts/index.d.ts +16 -0
  38. package/dist-lib/plugins/charts/index.js +21 -0
  39. package/dist-lib/plugins/ripgrep/index.d.ts +15 -0
  40. package/dist-lib/plugins/ripgrep/index.js +28 -0
  41. package/dist-lib/plugins/sandbox-windows/prebuilds/win32-arm64/qvac-sandbox.exe +0 -0
  42. package/dist-lib/plugins/sandbox-windows/prebuilds/win32-x64/qvac-sandbox.exe +0 -0
  43. package/package.json +24 -2
  44. package/worker/harness-sidecar.mjs +3 -0
package/CHANGELOG.md CHANGED
@@ -21,11 +21,24 @@ breaking change is listed under Changed and Removed.
21
21
 
22
22
  ### Added
23
23
 
24
+ - `plugins/ripgrep` lets `grep` and `glob` search a shared local folder with ripgrep's engine instead
25
+ of walking and reading the drive in JavaScript, so a tree past the 10,000-entry walk cap is searched
26
+ whole. A regex the engine rejects falls back to the JS engine. A local root takes an optional `search`
27
+ and `walk`, set from the new `rootSearch` service; with no such plugin nothing changes. The native
28
+ addon is `bare-ripgrep`, a new optional peer. (#889)
29
+
24
30
  - `grep` takes `caseSensitive` to match exact case, and `grep` and `glob` take `includeIgnored` to also
25
31
  search what `.gitignore`, `.ignore` and cache folders leave out; `.git`, `node_modules` and `.trash`
26
32
  stay skipped. `glob` takes `limit` (default 100, at most 500) and `offset`. A `glob` that finds more
27
33
  than 100 paths, with neither set, now samples across the top-level folders instead of taking the
28
34
  newest 100, and says so in a `note`; with `limit` or `offset` it pages newest first as before.
35
+ (#888)
36
+ - A host turns on speculative decoding with `llmLoad: { speculative: true }`. Qwen3.8-27B, the one
37
+ catalog model with a drafter (`QWEN3_8_27B_DFLASH2_Q8_0`), then decodes about 1.5× faster: 79 to
38
+ 119 tokens a second on an H100, for about 45 ms more to the first token. The drafter downloads with
39
+ the model, counts toward the memory cap and is deleted with it, and a round's metrics carry
40
+ `draftTokens` and `draftAcceptedTokens`. It is read when the harness is created, so switching it
41
+ means a restart. (#884)
29
42
  - A `Diagrams` plugin gives the model `draw_diagram`: a diagram type and its links in, and the
30
43
  Mermaid block the app renders out, as the run's reply. It draws flowcharts, sequence, state,
31
44
  ER and class diagrams, mind maps, timelines, Gantt charts and pies, escapes every label itself,
@@ -43,6 +56,21 @@ breaking change is listed under Changed and Removed.
43
56
  rebuilds a chat from its own record replays it with these, before the run's reply. (#892)
44
57
  - `ToolExecuteContext.userTurns`: the user's turns as the host sent them, so a tool can check an
45
58
  argument the model sent against what was asked. (#892)
59
+ - A `Charts` plugin gives the model `create_chart`: the model describes the numbers, and
60
+ [qvac-charts](https://github.com/tetherto/qvac-charts) picks the chart, computes shares and
61
+ growth, and draws a 1080×1350 SVG, saved as a chat attachment. A map of countries is drawn on
62
+ the world, or on the one continent that holds them all. The result carries a one-line
63
+ summary of what was drawn, so the model can talk about it without seeing it. A host sets the
64
+ default theme, which the model overrides when the user asks for a light or dark chart, and
65
+ passes its own brand mark; the plugin ships no logo. It sits in a new `charts`
66
+ toolset, is skill-gated, and the shipped sidecar registers it with its read grant and the
67
+ options in `pluginOptions.charts`. `qvac-charts` is a new optional peer.
68
+
69
+ ```js
70
+ new Harness({ plugins: [new Charts({ read: ['create_chart'], theme: 'light', mark })] })
71
+ ```
72
+
73
+ (#901)
46
74
 
47
75
  - Workspace skills run in every chat of the workspace. Send them as `workspaceSkills`, shaped like
48
76
  `projectSkills`. On a name clash the project's skill wins over the workspace's, and the workspace's
@@ -609,9 +637,40 @@ breaking change is listed under Changed and Removed.
609
637
 
610
638
  ### Changed
611
639
 
640
+ - **Breaking** for a host that spawns the shipped sidecar: install `qvac-charts`, which the
641
+ `charts` plugin checks on import, or the sidecar throws at boot. npm does not install an
642
+ optional peer, and a host with its own entry that leaves out `Charts` needs nothing. See
643
+ [Plugin dependencies](docs/hosting.md#plugin-dependencies). (#901)
644
+
612
645
  - Two calls in one round whose results each answer the run (`{ content, answer: true }`) both
613
646
  reach the reply, joined in order; only the first did before. (#892)
614
647
 
648
+ - **Breaking:** image generation defaults to FLUX.2 Klein off phones.
649
+ `DEFAULT_IMAGE_MODEL_CHOICE` is `flux2-klein`, where it was `sd2`, so an
650
+ agent with the image-generation skill and no `imageModelChoice` has
651
+ `skillModelsForAgent` and `modelsForAgent` answer `FLUX.2-Klein-4B-Q4_0`.
652
+ FLUX.2 Klein is 5.1 GB with its text encoder and VAE (Stable Diffusion 2.1
653
+ is 2.3 GB), needs a GPU, and edits from several reference images. On a
654
+ mobile host the default stays `sd2`, the one choice that runs on a CPU:
655
+ `modelsForAgent(agent, host)` answers it, and `defaultImageModelChoice(host)`
656
+ gives a host the same answer for its `Image` plugin, which still takes its
657
+ model from the host. `skillModelsForAgent` now requires the host as its
658
+ second argument, `null` when there is none, so a caller on a phone cannot
659
+ get the desktop default by leaving it out. An `imageModelChoice` the agent
660
+ set is never changed. Set it to `sd2` to keep Stable Diffusion 2.1 on a
661
+ desktop. (#867)
662
+
663
+ ```js
664
+ // before: an agent with no choice resolved to StableDiffusion-2.1-Q8_0
665
+ // after: off phones it resolves to FLUX.2-Klein-4B-Q4_0; to keep the old model
666
+ const agent = { ...saved, imageModelChoice: 'sd2' }
667
+
668
+ // before
669
+ skillModelsForAgent(agent)
670
+ // after
671
+ skillModelsForAgent(agent, await harness.capability())
672
+ ```
673
+
615
674
  - **Breaking:** speech defaults to Audio8. A `speak` or `speakStream` that
616
675
  names no model loads `Audio8-Q8_0` on every device profile, where it loaded
617
676
  Supertonic 3. Audio8 is 1.05 GB with its codec decoder (Supertonic was 85 MB
package/README.md CHANGED
@@ -328,6 +328,7 @@ itself.
328
328
  | [`LanguageHint`](plugins/language-hint/README.md) | A prompt in another language, in English too, for the model |
329
329
  | [`Weather`](plugins/weather/README.md) | Weather lookup |
330
330
  | [`Diagrams`](plugins/diagrams/README.md) | Diagrams drawn from a type and its links, as the Mermaid the app renders |
331
+ | [`Charts`](plugins/charts/README.md) | Charts drawn from numbers the model describes, as an SVG attachment |
331
332
  | [`ObsidianRoute`](plugins/obsidian/README.md) | `obsidian …` commands against a vault |
332
333
 
333
334
  Each plugin is imported from `@qvac/harness/plugins/<folder>`. Its own dependencies are optional
@@ -46,6 +46,7 @@ export type { ModelFitBasis, ModelFitEvidence, ModelFitVerdict } from './lib/mod
46
46
  export * from './lib/capabilities/download.ts';
47
47
  export type { EmbedContext } from './lib/capabilities/embed.ts';
48
48
  export type { OcrImage, OcrPage, OcrReadContext, OcrService } from './lib/contract/ocr.ts';
49
+ export type { RootSearch, RootSearchQuery, RootSearchResult, RootSearchScope, RootWalkResult } from './lib/contract/root-search.ts';
49
50
  export type { SpeakContext, SpeakResult, SpeakStreamContext, SpeechService, TranscribeContext } from './lib/contract/speech.ts';
50
51
  export type { EmbedDevice } from './lib/models/embed-config.ts';
51
52
  export type { MemoryBudget } from './lib/hardware/memory-budget.ts';
@@ -54,7 +55,7 @@ export * from './lib/models/model-list.ts';
54
55
  export type { ModelTaskType } from './lib/models/model-task.ts';
55
56
  export type { DeleteModelResult, DeleteModelSummary } from './lib/models/model-delete.ts';
56
57
  export type { RecoveryResolution } from './lib/run-log/index.ts';
57
- export { harnessChild, spawnHarness, type HarnessChildOptions, type HarnessKnowledgeConfig, type HarnessMcpServer, type HarnessPluginOptions, type HarnessSpeechOptions, type SpawnHarnessOptions } from './lib/spawn.ts';
58
+ export { harnessChild, spawnHarness, type HarnessChartsOptions, type HarnessChildOptions, type HarnessKnowledgeConfig, type HarnessMcpServer, type HarnessPluginOptions, type HarnessSpeechOptions, type SpawnHarnessOptions } from './lib/spawn.ts';
58
59
  export * from './lib/tools/skills/catalog.ts';
59
60
  export { requiredSettings, settingEnvName, type SkillSettingEntry, type SkillSettingsFn } from './lib/tools/skills/skill-settings.ts';
60
61
  export type { ToolCatalogEntry } from './lib/tools/catalog.ts';
@@ -218,6 +219,7 @@ export declare class Harness extends ReadyResource {
218
219
  private _shell;
219
220
  private _projectionModel;
220
221
  private _customProjection;
222
+ private readonly _speculative;
221
223
  private readonly _contextSize?;
222
224
  private readonly _recentFits;
223
225
  private readonly _gpuStats?;
@@ -260,6 +262,7 @@ export declare class Harness extends ReadyResource {
260
262
  get toolNames(): string[];
261
263
  get supportsImages(): boolean;
262
264
  supportsImagesFor(model: string): boolean;
265
+ private _draftFor;
263
266
  private _projectionFor;
264
267
  setCustomModels(entries: ReadonlyArray<CustomModelEntry>): void;
265
268
  setModelIdleTimeout(ms: number): void;
package/dist-lib/index.js CHANGED
@@ -19,7 +19,7 @@ import { Embeddings } from './lib/embeddings/index.js';
19
19
  import { deleteAllKvCaches, deleteKvCacheKey } from './lib/capabilities/kv-cache.js';
20
20
  import { pushQueue } from './lib/queue.js';
21
21
  import { AbortedError } from './lib/helpers/race-abort.js';
22
- import { audioGenDownloadMetadata, categoryDownloadMetadata, customProjectionMap, defaultProjectionMap, catalogModelName, defaultVoiceModel, diffusionDownloadMetadata, infraModelsFor, modelNameToCapabilityProfile, residentSrc, setCustomModels } from './lib/models/model-catalog.js';
22
+ import { audioGenDownloadMetadata, categoryDownloadMetadata, customProjectionMap, defaultProjectionMap, catalogModelName, defaultVoiceModel, diffusionDownloadMetadata, infraModelsFor, speculativeDraft, modelNameToCapabilityProfile, residentSrc, setCustomModels } from './lib/models/model-catalog.js';
23
23
  import { customModelRows, isModelSourceCached, mergeCustomRows, listModels } from './lib/models/model-list.js';
24
24
  import { createDownloadGate } from './lib/models/download-gate.js';
25
25
  import { deleteModelFiles, summarizeDelete } from './lib/models/model-delete.js';
@@ -109,6 +109,7 @@ export class Harness extends ReadyResource {
109
109
  _shell;
110
110
  _projectionModel;
111
111
  _customProjection = {};
112
+ _speculative;
112
113
  _contextSize;
113
114
  _recentFits = new Map();
114
115
  _gpuStats;
@@ -168,6 +169,7 @@ export class Harness extends ReadyResource {
168
169
  this._hostTools = tools;
169
170
  this._tools = tools;
170
171
  this._projectionModel = projectionModel ?? defaultProjectionMap();
172
+ this._speculative = llmLoad?.speculative === true;
171
173
  this._modelsDir = modelsDir;
172
174
  this._skillsDir = skillsDir;
173
175
  this._skills = new SkillsHost({
@@ -448,6 +450,9 @@ export class Harness extends ReadyResource {
448
450
  supportsImagesFor(model) {
449
451
  return Boolean(this._projectionFor(model));
450
452
  }
453
+ _draftFor(model) {
454
+ return this._speculative ? speculativeDraft(model)?.model?.src : undefined;
455
+ }
451
456
  _projectionFor(model) {
452
457
  const custom = this._customProjection[model];
453
458
  if (custom) {
@@ -584,7 +589,9 @@ export class Harness extends ReadyResource {
584
589
  download(args) {
585
590
  this._lifecycle.assertNotClosing();
586
591
  let releaseWork = null;
587
- const projection = (args.addon ?? 'llm') === 'llm' ? this._projectionFor(args.model) : undefined;
592
+ const llm = (args.addon ?? 'llm') === 'llm';
593
+ const projection = llm ? this._projectionFor(args.model) : undefined;
594
+ const draft = llm ? this._draftFor(args.model) : undefined;
588
595
  const multiFile = diffusionDownloadMetadata(args.model, args.addon) ??
589
596
  audioGenDownloadMetadata(args.model, args.addon) ??
590
597
  categoryDownloadMetadata(args.model, args.addon);
@@ -605,7 +612,7 @@ export class Harness extends ReadyResource {
605
612
  }, {
606
613
  ...args,
607
614
  projection,
608
- companions: multiFile?.companions,
615
+ companions: draft ? [...(multiFile?.companions ?? []), draft] : multiFile?.companions,
609
616
  assetSizes: multiFile?.assetSizes
610
617
  }, (event) => {
611
618
  this._residency.invalidateStatus();
@@ -700,7 +707,8 @@ export class Harness extends ReadyResource {
700
707
  this._lifecycle.assertNotClosing();
701
708
  const rows = await listModels(sdk, options, {
702
709
  cache: this._residency.status,
703
- projectionFor: (name) => this._projectionFor(name)
710
+ projectionFor: (name) => this._projectionFor(name),
711
+ draftFor: (name) => this._draftFor(name)
704
712
  });
705
713
  const loaded = this._residency.settled();
706
714
  const loading = this._residency.loading();
@@ -6,6 +6,7 @@ import { modelTurns, trustedSourcesFrom } from '../turns.js';
6
6
  import { skillNameOf } from '../../tool-plan.js';
7
7
  import { unreadySkillState } from '../../skill-entry.js';
8
8
  import { runSpill } from '../../../spill.js';
9
+ import { withRootSearch } from '../../../helpers/root-search.js';
9
10
  export function resolvedCall(session, call) {
10
11
  const tool = session.enabled.find((tool) => tool.name === call.name);
11
12
  return {
@@ -29,7 +30,7 @@ export function toolContext({ deps, context, name }) {
29
30
  skillsLoadedThisTurn: [...session.loadedThisTurn],
30
31
  settings: args.toolConfigs?.[name],
31
32
  toolOps: session.grantedOps,
32
- fsRoots: args.fsRoots ?? [],
33
+ fsRoots: withRootSearch(args.fsRoots ?? [], deps.services?.rootSearch),
33
34
  fsWriteRoots: session.writableRoots,
34
35
  policy: session.access,
35
36
  toolNames: session.enabled.map((tool) => tool.name),
@@ -195,7 +195,7 @@ export interface CallTool {
195
195
  (name: string, args: unknown): Promise<unknown>;
196
196
  readonly names: readonly string[];
197
197
  }
198
- export type Toolset = 'web-search' | 'knowledge' | 'files' | 'exec' | 'http-request' | 'mcp-call' | 'image' | 'diagrams' | 'music' | 'coding' | 'team';
198
+ export type Toolset = 'web-search' | 'knowledge' | 'files' | 'exec' | 'http-request' | 'mcp-call' | 'image' | 'diagrams' | 'charts' | 'music' | 'coding' | 'team';
199
199
  export interface ToolsetScoped {
200
200
  toolset?: string | null;
201
201
  }
@@ -1,3 +1,4 @@
1
+ import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
1
2
  import type { Writable } from 'streamx';
2
3
  export interface DriveEntry {
3
4
  key: string;
@@ -114,10 +115,33 @@ export interface WalkSummary {
114
115
  }
115
116
  export interface FolderSearchResult extends SearchResult, WalkSummary {
116
117
  }
118
+ export interface LocalSearchQuery extends DriveSearchQuery {
119
+ include?: string;
120
+ deny: readonly string[];
121
+ signal?: BareAbortSignal | undefined;
122
+ }
123
+ export interface LocalWalkQuery {
124
+ folder: string;
125
+ include?: string;
126
+ includeIgnored: boolean;
127
+ deny: readonly string[];
128
+ maxMs: number;
129
+ signal?: BareAbortSignal | undefined;
130
+ }
131
+ export interface LocalWalkResult {
132
+ files: Array<{
133
+ path: string;
134
+ key: string;
135
+ mtime: number;
136
+ }>;
137
+ truncated: boolean;
138
+ }
117
139
  export interface LocalRoot {
118
140
  readonly kind: 'local';
119
141
  readonly root: string;
120
142
  readonly drive: Drive;
143
+ readonly search?: (query: LocalSearchQuery) => Promise<FolderSearchResult>;
144
+ readonly walk?: (query: LocalWalkQuery) => Promise<LocalWalkResult>;
121
145
  }
122
146
  export interface HyperRoot {
123
147
  readonly kind: 'hyper';
@@ -0,0 +1,34 @@
1
+ export interface RootSearchScope {
2
+ root: string;
3
+ folder: string;
4
+ include?: string;
5
+ deny: readonly string[];
6
+ includeIgnored: boolean;
7
+ signal?: AbortSignal;
8
+ }
9
+ export interface RootSearchQuery extends RootSearchScope {
10
+ queries: string[];
11
+ regex: boolean;
12
+ caseSensitive: boolean;
13
+ maxMatches: number;
14
+ }
15
+ export interface RootSearchResult {
16
+ hits: Array<{
17
+ path: string;
18
+ line: number;
19
+ text: string;
20
+ }>;
21
+ truncated: boolean;
22
+ cut: boolean;
23
+ }
24
+ export interface RootWalkResult {
25
+ files: Array<{
26
+ path: string;
27
+ mtime: number;
28
+ }>;
29
+ truncated: boolean;
30
+ }
31
+ export interface RootSearch {
32
+ search(query: RootSearchQuery): Promise<RootSearchResult>;
33
+ walk(scope: RootSearchScope): Promise<RootWalkResult>;
34
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -153,6 +153,8 @@ export interface RoundSpeed {
153
153
  tokensPerSecond?: number;
154
154
  timeToFirstToken?: number;
155
155
  avgConcurrentSeq?: number;
156
+ draftTokens?: number;
157
+ draftAcceptedTokens?: number;
156
158
  stopReason?: string;
157
159
  overflows?: number;
158
160
  contextBoundary?: true;
@@ -0,0 +1,3 @@
1
+ import type { RootSearch } from '../contract/root-search.ts';
2
+ import type { DriveRoot } from '../contract/drive.ts';
3
+ export declare function withRootSearch(roots: readonly DriveRoot[], engine: RootSearch | undefined): readonly DriveRoot[];
@@ -0,0 +1,74 @@
1
+ import path from 'path';
2
+ export function withRootSearch(roots, engine) {
3
+ if (!engine) {
4
+ return roots;
5
+ }
6
+ return roots.map((root) => (root.kind === 'local' ? searchable(root, engine) : root));
7
+ }
8
+ function searchable(root, engine) {
9
+ return {
10
+ ...root,
11
+ async search({ maxMs, signal, ...query }) {
12
+ const found = await bounded((stop) => engine.search({
13
+ ...query,
14
+ root: root.root,
15
+ folder: query.folder.slice(1),
16
+ signal: stop
17
+ }), { maxMs, signal, late: { hits: [], truncated: true, cut: false } });
18
+ const capped = found.hits.length >= query.maxMatches;
19
+ return {
20
+ hits: found.hits.map(({ path: rel, line, text }) => ({
21
+ file: path.join(root.root, rel),
22
+ line,
23
+ text
24
+ })),
25
+ capped,
26
+ cut: found.cut,
27
+ truncated: found.truncated && !capped,
28
+ skippedLinks: 0
29
+ };
30
+ },
31
+ async walk({ maxMs, signal, ...query }) {
32
+ const found = await bounded((stop) => engine.walk({
33
+ ...query,
34
+ root: root.root,
35
+ folder: query.folder.slice(1),
36
+ signal: stop
37
+ }), { maxMs, signal, late: { files: [], truncated: true } });
38
+ return {
39
+ files: found.files.map(({ path: rel, mtime }) => ({
40
+ path: path.join(root.root, rel),
41
+ key: `/${rel}`,
42
+ mtime
43
+ })),
44
+ truncated: found.truncated
45
+ };
46
+ }
47
+ };
48
+ }
49
+ async function bounded(run, { maxMs, signal, late }) {
50
+ const controller = new AbortController();
51
+ const abort = () => controller.abort();
52
+ let expired = false;
53
+ const timer = setTimeout(() => {
54
+ expired = true;
55
+ abort();
56
+ }, maxMs);
57
+ signal?.addEventListener('abort', abort);
58
+ if (signal?.aborted) {
59
+ abort();
60
+ }
61
+ try {
62
+ return await run(controller.signal);
63
+ }
64
+ catch (err) {
65
+ if (expired && !signal?.aborted) {
66
+ return late;
67
+ }
68
+ throw err;
69
+ }
70
+ finally {
71
+ clearTimeout(timer);
72
+ signal?.removeEventListener('abort', abort);
73
+ }
74
+ }
@@ -39,7 +39,9 @@ const ROUND_STATS = [
39
39
  'promptTokensPerSecond',
40
40
  'tokensPerSecond',
41
41
  'timeToFirstToken',
42
- 'avgConcurrentSeq'
42
+ 'avgConcurrentSeq',
43
+ 'draftTokens',
44
+ 'draftAcceptedTokens'
43
45
  ];
44
46
  function roundSpeed(round, { stats, stopReason, durationMs, overflows, reasoningDeltas, keyed }) {
45
47
  const speed = { round, durationMs: durationMs ?? 0 };
@@ -9,6 +9,8 @@ export interface CompletionStats {
9
9
  promptTokens?: number | undefined;
10
10
  cacheTokens?: number | undefined;
11
11
  avgConcurrentSeq?: number | undefined;
12
+ draftTokens?: number | undefined;
13
+ draftAcceptedTokens?: number | undefined;
12
14
  contextBoundary?: boolean | undefined;
13
15
  }
14
16
  export interface EngineEvent {
@@ -27,6 +27,7 @@ export declare function capabilityProfileModelLabel(profile: CapabilityProfile):
27
27
  export declare function isMultimodalLlm(modelName: string): boolean;
28
28
  export type ImageModelChoice = 'sd2' | 'sdxl' | 'flux2-klein';
29
29
  export declare const DEFAULT_IMAGE_MODEL_CHOICE: ImageModelChoice;
30
+ export declare function defaultImageModelChoice(host: HostCapability | null): ImageModelChoice;
30
31
  export interface ImageChoiceEntry {
31
32
  readonly choice: ImageModelChoice;
32
33
  readonly label: string;
@@ -99,7 +99,11 @@ const MULTIMODAL_LLMS = new Set([
99
99
  export function isMultimodalLlm(modelName) {
100
100
  return MULTIMODAL_LLMS.has(modelName);
101
101
  }
102
- export const DEFAULT_IMAGE_MODEL_CHOICE = 'sd2';
102
+ export const DEFAULT_IMAGE_MODEL_CHOICE = 'flux2-klein';
103
+ const MOBILE_IMAGE_MODEL_CHOICE = 'sd2';
104
+ export function defaultImageModelChoice(host) {
105
+ return host?.mobile ? MOBILE_IMAGE_MODEL_CHOICE : DEFAULT_IMAGE_MODEL_CHOICE;
106
+ }
103
107
  export const IMAGE_CHOICE_CATALOG = [
104
108
  {
105
109
  choice: 'sd2',
@@ -4,8 +4,8 @@ import type { ModelAddon } from './model-source.ts';
4
4
  export interface SdkModelAsset extends ModelRegistryEntry {
5
5
  readonly src: string;
6
6
  }
7
- import { CAPABILITY_PROFILE_ORDER, QWEN_35_2B, QWEN_35_4B, QWEN_35_9B, QWEN_36_35B_A3B, QWEN_38_27B, KAT_CODER_25_35B, BONSAI_2_27B_PQ2, BONSAI_2_27B_PTQ1, MEDPSY_1_7B, MEDPSY_4B, isCapabilityProfile, meetsMinCapabilityProfile, modelNameToCapabilityProfile, capabilityProfileToModelName, isMultimodalLlm, AGENT_MODEL_NAMES, modelDisplayName, capabilityProfileModelLabel, DEFAULT_IMAGE_MODEL_CHOICE, IMAGE_CHOICE_CATALOG, isMobilePlatform, runnableModelName, type CapabilityProfile, type HostCapability, type ImageModelChoice, type ImageChoiceEntry } from './model-catalog-constants.ts';
8
- export { CAPABILITY_PROFILE_ORDER, QWEN_35_2B, QWEN_35_4B, QWEN_35_9B, QWEN_36_35B_A3B, QWEN_38_27B, KAT_CODER_25_35B, BONSAI_2_27B_PQ2, BONSAI_2_27B_PTQ1, MEDPSY_1_7B, MEDPSY_4B, isCapabilityProfile, meetsMinCapabilityProfile, modelNameToCapabilityProfile, capabilityProfileToModelName, isMultimodalLlm, AGENT_MODEL_NAMES, modelDisplayName, capabilityProfileModelLabel, DEFAULT_IMAGE_MODEL_CHOICE, IMAGE_CHOICE_CATALOG, isMobilePlatform, runnableModelName };
7
+ import { CAPABILITY_PROFILE_ORDER, QWEN_35_2B, QWEN_35_4B, QWEN_35_9B, QWEN_36_35B_A3B, QWEN_38_27B, KAT_CODER_25_35B, BONSAI_2_27B_PQ2, BONSAI_2_27B_PTQ1, MEDPSY_1_7B, MEDPSY_4B, isCapabilityProfile, meetsMinCapabilityProfile, modelNameToCapabilityProfile, capabilityProfileToModelName, isMultimodalLlm, AGENT_MODEL_NAMES, modelDisplayName, capabilityProfileModelLabel, DEFAULT_IMAGE_MODEL_CHOICE, defaultImageModelChoice, IMAGE_CHOICE_CATALOG, isMobilePlatform, runnableModelName, type CapabilityProfile, type HostCapability, type ImageModelChoice, type ImageChoiceEntry } from './model-catalog-constants.ts';
8
+ export { CAPABILITY_PROFILE_ORDER, QWEN_35_2B, QWEN_35_4B, QWEN_35_9B, QWEN_36_35B_A3B, QWEN_38_27B, KAT_CODER_25_35B, BONSAI_2_27B_PQ2, BONSAI_2_27B_PTQ1, MEDPSY_1_7B, MEDPSY_4B, isCapabilityProfile, meetsMinCapabilityProfile, modelNameToCapabilityProfile, capabilityProfileToModelName, isMultimodalLlm, AGENT_MODEL_NAMES, modelDisplayName, capabilityProfileModelLabel, DEFAULT_IMAGE_MODEL_CHOICE, defaultImageModelChoice, IMAGE_CHOICE_CATALOG, isMobilePlatform, runnableModelName };
9
9
  export type { CapabilityProfile, HostCapability, ImageModelChoice, ImageChoiceEntry };
10
10
  export interface LlmCatalogEntry {
11
11
  readonly name: string;
@@ -14,8 +14,14 @@ export interface LlmCatalogEntry {
14
14
  readonly projection?: SdkModelAsset;
15
15
  readonly textOnly?: true;
16
16
  readonly toolDialect?: ToolDialect;
17
+ readonly draft?: SpeculativeDraft;
18
+ }
19
+ export interface SpeculativeDraft {
20
+ readonly specType: 'draft-dflash' | 'draft-mtp';
21
+ readonly model?: SdkModelAsset;
17
22
  }
18
23
  export declare const LLM_CATALOG: ReadonlyArray<LlmCatalogEntry>;
24
+ export declare function speculativeDraft(model: string): SpeculativeDraft | undefined;
19
25
  export declare function defaultProjectionMap(): Record<string, string>;
20
26
  export type ModelCategory = 'tts' | 'transcription' | 'embedding';
21
27
  export interface CategoryDefault {
@@ -98,7 +104,7 @@ export interface AgentModel extends CatalogModel {
98
104
  export interface AgentModelInput extends AgentSkillModelInput {
99
105
  readonly modelName?: string | null;
100
106
  }
101
- export declare function skillModelsForAgent(agent: AgentSkillModelInput): ReadonlyArray<AgentModel>;
107
+ export declare function skillModelsForAgent(agent: AgentSkillModelInput, host: HostCapability | null): ReadonlyArray<AgentModel>;
102
108
  export declare function modelsForAgent(agent: AgentModelInput, host: HostCapability | null): ReadonlyArray<AgentModel>;
103
109
  export declare function diffusionSizeBytes(entry: DiffusionCatalogEntry): number;
104
110
  export declare function imageModelFor(choice: string | undefined): ImageModelSet | null;
@@ -129,6 +135,7 @@ export interface CuratedListable {
129
135
  readonly asset: SdkModelAsset;
130
136
  readonly companions: SdkModelAsset[];
131
137
  readonly projection?: SdkModelAsset;
138
+ readonly draft?: SdkModelAsset;
132
139
  }
133
140
  export declare function curatedListables(): CuratedListable[];
134
141
  export declare function curatedModelAsset(name: string, addon: ModelRegistryEntry['addon']): SdkModelAsset | undefined;
@@ -1,8 +1,8 @@
1
- import { AUDIOGEN_ACESTEP_5HZ_LM_0_6B_Q8_0, AUDIOGEN_ACESTEP_V15_BASE_Q4_K_M, AUDIOGEN_ACESTEP_V15_SFT_Q8_0, AUDIOGEN_ACESTEP_V15_TURBO_Q4_K_M, AUDIOGEN_ACESTEP_V15_TURBO_Q8_0, AUDIOGEN_QWEN3_EMBEDDING_0_6B_Q8_0, AUDIOGEN_VAE_BF16, EMBEDDINGGEMMA_300M_Q4_0, FLUX_2_KLEIN_4B_Q4_0, FLUX_2_KLEIN_4B_VAE, HEALTHCARE_1_7B_MEDICAL_Q4_K_M, HEALTHCARE_4B_MEDICAL_Q4_K_M, MOE_35B_INST_Q4_K_M, MMPROJ_QWEN3_5_2B_MULTIMODAL_Q8_0, MMPROJ_QWEN3_5_4B_MULTIMODAL_Q8_0, MMPROJ_QWEN3_5_9B_MULTIMODAL_F16, MMPROJ_QWEN3_6_35B_A3B_MULTIMODAL_F16, MMPROJ_QWEN3_8_27B_MULTIMODAL_F16, MMPROJ_TERNARY_BONSAI_2_27B_MULTIMODAL_Q8_0, QWEN3_5_2B_MULTIMODAL_Q4_K_M, QWEN3_5_4B_MULTIMODAL_Q4_K_M, QWEN3_5_9B_MULTIMODAL_Q4_K_M, PARAKEET_TDT_0_6B_V3_Q8_0, PARAKEET_TDT_1_1B_Q8_0, QWEN3_4B_Q4_K_M, QWEN3_6_35B_A3B_MULTIMODAL_Q4_K_M, QWEN3_8_27B_MULTIMODAL_UD_Q4_K_XL, SD_V2_1_1B_Q8_0, SDXL_BASE_1_0_3B_Q4_0, TERNARY_BONSAI_2_27B_MULTIMODAL_PQ2_0, TERNARY_BONSAI_2_27B_MULTIMODAL_PTQ1_0, TTS_CODEC_DECODER_AUDIO8_Q8_0, TTS_CODEC_DECODER_MOSS_TTS_F16, TTS_CODEC_ENCODER_MOSS_TTS_F16, TTS_DELAY_LLM_MOSS_TTS_F16, TTS_LM_MULTILINGUAL_AUDIO8_Q8_0, TTS_MULTILINGUAL_SUPERTONIC3_FP16, TTS_MULTILINGUAL_SUPERTONIC3_Q4_0, TTS_MULTILINGUAL_SUPERTONIC3_Q8_0 } from '@qvac/inference/models';
1
+ import { AUDIOGEN_ACESTEP_5HZ_LM_0_6B_Q8_0, AUDIOGEN_ACESTEP_V15_BASE_Q4_K_M, AUDIOGEN_ACESTEP_V15_SFT_Q8_0, AUDIOGEN_ACESTEP_V15_TURBO_Q4_K_M, AUDIOGEN_ACESTEP_V15_TURBO_Q8_0, AUDIOGEN_QWEN3_EMBEDDING_0_6B_Q8_0, AUDIOGEN_VAE_BF16, EMBEDDINGGEMMA_300M_Q4_0, FLUX_2_KLEIN_4B_Q4_0, FLUX_2_KLEIN_4B_VAE, HEALTHCARE_1_7B_MEDICAL_Q4_K_M, HEALTHCARE_4B_MEDICAL_Q4_K_M, MOE_35B_INST_Q4_K_M, MMPROJ_QWEN3_5_2B_MULTIMODAL_Q8_0, MMPROJ_QWEN3_5_4B_MULTIMODAL_Q8_0, MMPROJ_QWEN3_5_9B_MULTIMODAL_F16, MMPROJ_QWEN3_6_35B_A3B_MULTIMODAL_F16, MMPROJ_QWEN3_8_27B_MULTIMODAL_F16, MMPROJ_TERNARY_BONSAI_2_27B_MULTIMODAL_Q8_0, QWEN3_5_2B_MULTIMODAL_Q4_K_M, QWEN3_5_4B_MULTIMODAL_Q4_K_M, QWEN3_5_9B_MULTIMODAL_Q4_K_M, PARAKEET_TDT_0_6B_V3_Q8_0, PARAKEET_TDT_1_1B_Q8_0, QWEN3_4B_Q4_K_M, QWEN3_6_35B_A3B_MULTIMODAL_Q4_K_M, QWEN3_8_27B_DFLASH2_Q8_0, QWEN3_8_27B_MULTIMODAL_UD_Q4_K_XL, SD_V2_1_1B_Q8_0, SDXL_BASE_1_0_3B_Q4_0, TERNARY_BONSAI_2_27B_MULTIMODAL_PQ2_0, TERNARY_BONSAI_2_27B_MULTIMODAL_PTQ1_0, TTS_CODEC_DECODER_AUDIO8_Q8_0, TTS_CODEC_DECODER_MOSS_TTS_F16, TTS_CODEC_ENCODER_MOSS_TTS_F16, TTS_DELAY_LLM_MOSS_TTS_F16, TTS_LM_MULTILINGUAL_AUDIO8_Q8_0, TTS_MULTILINGUAL_SUPERTONIC3_FP16, TTS_MULTILINGUAL_SUPERTONIC3_Q4_0, TTS_MULTILINGUAL_SUPERTONIC3_Q8_0 } from '@qvac/inference/models';
2
2
  import { detectToolDialect } from './tool-dialect.js';
3
3
  import { defaultTtsModelName, supertonicModelName } from './tts-model-default.js';
4
- import { CAPABILITY_PROFILE_ORDER, QWEN_35_2B, QWEN_35_4B, QWEN_35_9B, QWEN_36_35B_A3B, QWEN_38_27B, KAT_CODER_25_35B, BONSAI_2_27B_PQ2, BONSAI_2_27B_PTQ1, MEDPSY_1_7B, MEDPSY_4B, isCapabilityProfile, meetsMinCapabilityProfile, modelNameToCapabilityProfile, capabilityProfileToModelName, isMultimodalLlm, AGENT_MODEL_NAMES, modelDisplayName, capabilityProfileModelLabel, DEFAULT_IMAGE_MODEL_CHOICE, IMAGE_CHOICE_CATALOG, isMobilePlatform, runnableModelName } from './model-catalog-constants.js';
5
- export { CAPABILITY_PROFILE_ORDER, QWEN_35_2B, QWEN_35_4B, QWEN_35_9B, QWEN_36_35B_A3B, QWEN_38_27B, KAT_CODER_25_35B, BONSAI_2_27B_PQ2, BONSAI_2_27B_PTQ1, MEDPSY_1_7B, MEDPSY_4B, isCapabilityProfile, meetsMinCapabilityProfile, modelNameToCapabilityProfile, capabilityProfileToModelName, isMultimodalLlm, AGENT_MODEL_NAMES, modelDisplayName, capabilityProfileModelLabel, DEFAULT_IMAGE_MODEL_CHOICE, IMAGE_CHOICE_CATALOG, isMobilePlatform, runnableModelName };
4
+ import { CAPABILITY_PROFILE_ORDER, QWEN_35_2B, QWEN_35_4B, QWEN_35_9B, QWEN_36_35B_A3B, QWEN_38_27B, KAT_CODER_25_35B, BONSAI_2_27B_PQ2, BONSAI_2_27B_PTQ1, MEDPSY_1_7B, MEDPSY_4B, isCapabilityProfile, meetsMinCapabilityProfile, modelNameToCapabilityProfile, capabilityProfileToModelName, isMultimodalLlm, AGENT_MODEL_NAMES, modelDisplayName, capabilityProfileModelLabel, DEFAULT_IMAGE_MODEL_CHOICE, defaultImageModelChoice, IMAGE_CHOICE_CATALOG, isMobilePlatform, runnableModelName } from './model-catalog-constants.js';
5
+ export { CAPABILITY_PROFILE_ORDER, QWEN_35_2B, QWEN_35_4B, QWEN_35_9B, QWEN_36_35B_A3B, QWEN_38_27B, KAT_CODER_25_35B, BONSAI_2_27B_PQ2, BONSAI_2_27B_PTQ1, MEDPSY_1_7B, MEDPSY_4B, isCapabilityProfile, meetsMinCapabilityProfile, modelNameToCapabilityProfile, capabilityProfileToModelName, isMultimodalLlm, AGENT_MODEL_NAMES, modelDisplayName, capabilityProfileModelLabel, DEFAULT_IMAGE_MODEL_CHOICE, defaultImageModelChoice, IMAGE_CHOICE_CATALOG, isMobilePlatform, runnableModelName };
6
6
  export const LLM_CATALOG = [
7
7
  {
8
8
  name: QWEN_35_2B,
@@ -44,7 +44,8 @@ export const LLM_CATALOG = [
44
44
  name: QWEN_38_27B,
45
45
  weight: QWEN3_8_27B_MULTIMODAL_UD_Q4_K_XL,
46
46
  capabilityProfile: 'xhigh',
47
- projection: MMPROJ_QWEN3_8_27B_MULTIMODAL_F16
47
+ projection: MMPROJ_QWEN3_8_27B_MULTIMODAL_F16,
48
+ draft: { specType: 'draft-dflash', model: QWEN3_8_27B_DFLASH2_Q8_0 }
48
49
  },
49
50
  {
50
51
  name: KAT_CODER_25_35B,
@@ -68,6 +69,9 @@ export const LLM_CATALOG = [
68
69
  toolDialect: 'qwen35'
69
70
  }
70
71
  ];
72
+ export function speculativeDraft(model) {
73
+ return LLM_CATALOG.find((entry) => entry.name === model)?.draft;
74
+ }
71
75
  export function defaultProjectionMap() {
72
76
  const map = {};
73
77
  for (const entry of LLM_CATALOG) {
@@ -246,6 +250,7 @@ export function assetBytes(src) {
246
250
  const assets = [
247
251
  ...curatedListables().map((entry) => entry.asset),
248
252
  ...LLM_CATALOG.flatMap((entry) => (entry.projection ? [entry.projection] : [])),
253
+ ...LLM_CATALOG.flatMap((entry) => (entry.draft?.model ? [entry.draft.model] : [])),
249
254
  ...DIFFUSION_CATALOG.flatMap(diffusionAssets),
250
255
  ...AUDIOGEN_CATALOG.flatMap((entry) => [entry.dit, entry.textEnc, entry.lm, entry.vae])
251
256
  ];
@@ -342,10 +347,10 @@ function agentHasSkill(agent, skill) {
342
347
  const installed = agent.installedSkills?.includes(skill) === true;
343
348
  return installed && (agent.skillsScope === 'all' || agent.enabledSkills?.includes(skill) === true);
344
349
  }
345
- export function skillModelsForAgent(agent) {
350
+ export function skillModelsForAgent(agent, host) {
346
351
  const models = [];
347
352
  if (agentHasSkill(agent, IMAGE_GENERATION_SKILL)) {
348
- const choice = agent.imageModelChoice ?? DEFAULT_IMAGE_MODEL_CHOICE;
353
+ const choice = agent.imageModelChoice ?? defaultImageModelChoice(host);
349
354
  const entry = DIFFUSION_CATALOG.find((candidate) => candidate.choice === choice);
350
355
  if (entry) {
351
356
  models.push({ name: entry.name, addon: entry.model.addon, use: 'image' });
@@ -361,7 +366,7 @@ export function skillModelsForAgent(agent) {
361
366
  return models;
362
367
  }
363
368
  export function modelsForAgent(agent, host) {
364
- const skills = skillModelsForAgent(agent);
369
+ const skills = skillModelsForAgent(agent, host);
365
370
  if (!agent.modelName) {
366
371
  return skills;
367
372
  }
@@ -424,7 +429,8 @@ export function curatedListables() {
424
429
  name: entry.name,
425
430
  asset: entry.weight,
426
431
  companions: [],
427
- projection: entry.projection
432
+ projection: entry.projection,
433
+ draft: entry.draft?.model
428
434
  })),
429
435
  ...CATEGORY_DEFAULTS.map((entry) => ({
430
436
  name: entry.name,
@@ -52,6 +52,9 @@ function namesToPurge(name) {
52
52
  if (curated.projection) {
53
53
  names.push(curated.projection.name);
54
54
  }
55
+ if (curated.draft) {
56
+ names.push(curated.draft.name);
57
+ }
55
58
  return names;
56
59
  }
57
60
  const music = musicListables().find((entry) => entry.name === name || entry.asset.name === name);
@@ -51,8 +51,9 @@ export declare function invalidateModelStatusCache(cache: ModelStatusCache): voi
51
51
  export interface ListModelsRuntime {
52
52
  cache?: ModelStatusCache | undefined;
53
53
  projectionFor?: ((name: string) => string | undefined) | undefined;
54
+ draftFor?: ((name: string) => string | undefined) | undefined;
54
55
  }
55
- export declare function listModels(sdk: ModelListSdk, { type, cachedOnly, fullRegistry }?: ListModelsOptions, { cache, projectionFor }?: ListModelsRuntime): Promise<CatalogRow[]>;
56
+ export declare function listModels(sdk: ModelListSdk, { type, cachedOnly, fullRegistry }?: ListModelsOptions, { cache, projectionFor, draftFor }?: ListModelsRuntime): Promise<CatalogRow[]>;
56
57
  export interface CustomModelRowsContext {
57
58
  readonly modelsDir?: string;
58
59
  readonly loaded: ReadonlySet<string>;
@@ -50,7 +50,7 @@ async function musicRows(hydrate) {
50
50
  }
51
51
  return rows;
52
52
  }
53
- export async function listModels(sdk, { type, cachedOnly, fullRegistry } = {}, { cache, projectionFor } = {}) {
53
+ export async function listModels(sdk, { type, cachedOnly, fullRegistry } = {}, { cache, projectionFor, draftFor } = {}) {
54
54
  const now = Date.now();
55
55
  const seesImages = (name, addon) => addon === 'llm' && Boolean(projectionFor?.(name));
56
56
  const hydrate = async (registryPath, catalogName) => {
@@ -87,6 +87,10 @@ export async function listModels(sdk, { type, cachedOnly, fullRegistry } = {}, {
87
87
  const projection = await hydrate(listable.projection.registryPath, listable.projection.name);
88
88
  companionsCached = projection.isCached && companionsCached;
89
89
  }
90
+ if (listable.draft && draftFor?.(listable.name) === listable.draft.src) {
91
+ const draft = await hydrate(listable.draft.registryPath, listable.draft.name);
92
+ companionsCached = draft.isCached && companionsCached;
93
+ }
90
94
  return {
91
95
  name: listable.name,
92
96
  type: listable.asset.addon,
@@ -1,6 +1,7 @@
1
1
  import ResourcePuddle from 'resource-puddle';
2
2
  import { ModelHandle } from './model-handle.ts';
3
3
  import { type ModelSrc } from './context.ts';
4
+ import { type SpeculativeDraft } from './model-catalog.ts';
4
5
  import type { CpuPlacement } from '../hardware/cpu-placement.ts';
5
6
  import { type ModelAddon } from './model-source.ts';
6
7
  import type { GpuFaultState } from './sdk-faults.ts';
@@ -30,6 +31,8 @@ export interface LlamaLoadKnobs {
30
31
  'ubatch-size'?: number;
31
32
  'kv-offload'?: false;
32
33
  'n-cpu-moe'?: number;
34
+ speculative?: boolean;
35
+ spec_draft_n_max?: number;
33
36
  }
34
37
  export interface PendingLoad {
35
38
  readonly key: string;
@@ -87,6 +90,8 @@ export type ModelLifecycleSdk = Pick<SdkModule, 'unloadModel' | 'modelRegistrySe
87
90
  'cache-type-k'?: string;
88
91
  'cache-type-v'?: string;
89
92
  projectionModelSrc?: ModelSrc;
93
+ spec_type?: SpeculativeDraft['specType'];
94
+ draftModelSrc?: ModelSrc;
90
95
  device?: 'cpu' | 'gpu';
91
96
  gpu_layers?: number;
92
97
  'main-gpu'?: string;