@qvac/harness 1.0.0-rc.21 → 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.
- package/CHANGELOG.md +103 -0
- package/README.md +2 -0
- package/dist-lib/index.d.ts +4 -1
- package/dist-lib/index.js +12 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.js +3 -1
- package/dist-lib/lib/capabilities/completion-engine/tool-outcome.js +2 -4
- package/dist-lib/lib/capabilities/tool-turns/answered.d.ts +15 -0
- package/dist-lib/lib/capabilities/tool-turns/answered.js +16 -0
- package/dist-lib/lib/capabilities/tool-turns.d.ts +2 -0
- package/dist-lib/lib/capabilities/tool-turns.js +1 -0
- package/dist-lib/lib/contract/completion.d.ts +2 -1
- package/dist-lib/lib/contract/drive.d.ts +24 -0
- package/dist-lib/lib/contract/root-search.d.ts +34 -0
- package/dist-lib/lib/contract/root-search.js +1 -0
- package/dist-lib/lib/contract/run.d.ts +2 -0
- package/dist-lib/lib/helpers/root-search.d.ts +3 -0
- package/dist-lib/lib/helpers/root-search.js +74 -0
- package/dist-lib/lib/machine/completion/actions/tools.js +7 -1
- package/dist-lib/lib/machine/completion/metrics.js +3 -1
- package/dist-lib/lib/machine/completion/types.d.ts +2 -0
- package/dist-lib/lib/models/model-catalog-constants.d.ts +1 -0
- package/dist-lib/lib/models/model-catalog-constants.js +5 -1
- package/dist-lib/lib/models/model-catalog.d.ts +10 -3
- package/dist-lib/lib/models/model-catalog.js +14 -8
- package/dist-lib/lib/models/model-delete.js +3 -0
- package/dist-lib/lib/models/model-list.d.ts +2 -1
- package/dist-lib/lib/models/model-list.js +5 -1
- package/dist-lib/lib/models/model-pool.d.ts +5 -0
- package/dist-lib/lib/models/model-pool.js +16 -4
- package/dist-lib/lib/plugins/registry.d.ts +2 -0
- package/dist-lib/lib/residency/index.js +9 -6
- package/dist-lib/lib/spawn.d.ts +9 -0
- package/dist-lib/lib/tools/files/glob.js +71 -10
- package/dist-lib/lib/tools/files/grep.js +65 -22
- package/dist-lib/lib/tools/files/read-file.js +120 -76
- package/dist-lib/lib/tools/fs/engine.d.ts +9 -0
- package/dist-lib/lib/tools/fs/engine.js +28 -0
- package/dist-lib/lib/tools/fs/suggest.d.ts +8 -0
- package/dist-lib/lib/tools/fs/suggest.js +110 -0
- package/dist-lib/lib/tools/fs/tool-path.d.ts +3 -0
- package/dist-lib/lib/tools/fs/tool-path.js +13 -0
- package/dist-lib/lib/tools/fs/walk.d.ts +3 -0
- package/dist-lib/lib/tools/fs/walk.js +20 -20
- package/dist-lib/lib/tools/toolsets.d.ts +1 -1
- package/dist-lib/lib/tools/toolsets.js +2 -0
- package/dist-lib/plugins/charts/chart-tool.d.ts +8 -0
- package/dist-lib/plugins/charts/chart-tool.js +175 -0
- package/dist-lib/plugins/charts/index.d.ts +16 -0
- package/dist-lib/plugins/charts/index.js +21 -0
- package/dist-lib/plugins/diagrams/draw.d.ts +10 -0
- package/dist-lib/plugins/diagrams/draw.js +90 -0
- package/dist-lib/plugins/diagrams/index.d.ts +13 -0
- package/dist-lib/plugins/diagrams/index.js +15 -0
- package/dist-lib/plugins/diagrams/render.d.ts +16 -0
- package/dist-lib/plugins/diagrams/render.js +285 -0
- package/dist-lib/plugins/ripgrep/index.d.ts +15 -0
- package/dist-lib/plugins/ripgrep/index.js +28 -0
- package/dist-lib/plugins/sandbox-windows/prebuilds/win32-arm64/qvac-sandbox.exe +0 -0
- package/dist-lib/plugins/sandbox-windows/prebuilds/win32-x64/qvac-sandbox.exe +0 -0
- package/package.json +28 -2
- package/worker/harness-sidecar.mjs +5 -0
|
@@ -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 ??
|
|
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;
|
|
@@ -4,7 +4,7 @@ import { transferProgress } from '../model-download-progress.js';
|
|
|
4
4
|
import ResourcePuddle from 'resource-puddle';
|
|
5
5
|
import { ModelHandle } from './model-handle.js';
|
|
6
6
|
import { defaultContextSize } from './context.js';
|
|
7
|
-
import { customContextLength } from './model-catalog.js';
|
|
7
|
+
import { customContextLength, speculativeDraft } from './model-catalog.js';
|
|
8
8
|
import { localWeightFile } from './custom-model-cache.js';
|
|
9
9
|
import { GGUF_STUB_MAX_BYTES, parseGgufHeader, readGgufHeaderBytes } from './gguf-header.js';
|
|
10
10
|
import { adrenoSafeKvCache, headSafeKvCache } from './kv-cache.js';
|
|
@@ -94,6 +94,8 @@ export function modelKey(model, opts = {}) {
|
|
|
94
94
|
opts.llama?.['ubatch-size'] ?? '',
|
|
95
95
|
opts.llama?.['kv-offload'] ?? '',
|
|
96
96
|
opts.llama?.['n-cpu-moe'] ?? '',
|
|
97
|
+
opts.llama?.speculative ? 'spec' : '',
|
|
98
|
+
opts.llama?.spec_draft_n_max ?? '',
|
|
97
99
|
opts.slots && opts.slots > 1 ? opts.slots : ''
|
|
98
100
|
].join('\0');
|
|
99
101
|
}
|
|
@@ -424,8 +426,13 @@ export function createModelPool(loadSdk, notify, { deviceConfig = {}, loads = cr
|
|
|
424
426
|
? deviceConfig.openclCacheDir()
|
|
425
427
|
: undefined;
|
|
426
428
|
const placement = deviceConfig.device === 'cpu' ? deviceConfig.cpuPlacement?.() : undefined;
|
|
429
|
+
const { speculative, ...llama } = resolved.llama ?? {};
|
|
430
|
+
const draft = speculative ? speculativeDraft(model) : undefined;
|
|
427
431
|
const config = definedFields({
|
|
428
|
-
...
|
|
432
|
+
...llama,
|
|
433
|
+
spec_type: draft?.specType,
|
|
434
|
+
spec_draft_n_max: draft ? llama.spec_draft_n_max : undefined,
|
|
435
|
+
draftModelSrc: draft?.model?.src,
|
|
429
436
|
verbosity: llmVerbosity(),
|
|
430
437
|
system_prompt: '',
|
|
431
438
|
tools: true,
|
|
@@ -446,8 +453,13 @@ export function createModelPool(loadSdk, notify, { deviceConfig = {}, loads = cr
|
|
|
446
453
|
? chosen
|
|
447
454
|
: await chooseContext({ ...pending, modelConfig: { ...config } }, chosen);
|
|
448
455
|
const modelConfig = { ...config, ctx_size: ctxSize * slots };
|
|
449
|
-
const { projectionModelSrc: projection, ...loggedConfig } = modelConfig;
|
|
450
|
-
HarnessLog.debug('llm load config', {
|
|
456
|
+
const { projectionModelSrc: projection, draftModelSrc, ...loggedConfig } = modelConfig;
|
|
457
|
+
HarnessLog.debug('llm load config', {
|
|
458
|
+
model,
|
|
459
|
+
projection: Boolean(projection),
|
|
460
|
+
draft: Boolean(draftModelSrc),
|
|
461
|
+
...loggedConfig
|
|
462
|
+
});
|
|
451
463
|
const admission = await beforeLoad?.({ ...pending, modelConfig });
|
|
452
464
|
const loadStarted = Date.now();
|
|
453
465
|
const modelId = await loadClockGuard(model, sdk)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AddonLoaders, ToolDefinition, ToolExecuteContext, ToolFetch } from '../contract/index.ts';
|
|
2
2
|
import type { KnowledgeService } from '../contract/knowledge.ts';
|
|
3
3
|
import type { OcrService } from '../contract/ocr.ts';
|
|
4
|
+
import type { RootSearch } from '../contract/root-search.ts';
|
|
4
5
|
import type { SandboxService } from '../contract/sandbox.ts';
|
|
5
6
|
import type { EgressProxyService } from '../contract/egress-proxy.ts';
|
|
6
7
|
import type { EmbedHost, ModelHost } from '../contract/models.ts';
|
|
@@ -18,6 +19,7 @@ declare module './context.ts' {
|
|
|
18
19
|
embed: EmbedHost;
|
|
19
20
|
knowledge: KnowledgeService;
|
|
20
21
|
ocr: OcrService;
|
|
22
|
+
rootSearch: RootSearch;
|
|
21
23
|
sandbox: SandboxService;
|
|
22
24
|
'egress-proxy': EgressProxyService;
|
|
23
25
|
'image-rounds': MediaRoundServer;
|
|
@@ -10,7 +10,7 @@ import { resolveMainGpu } from '../models/gpu-selection.js';
|
|
|
10
10
|
import { createIdleReaper } from '../models/idle-unload.js';
|
|
11
11
|
import { createLoadRequests } from '../models/load-requests.js';
|
|
12
12
|
import { memoryCapBytes, nextVictim, VictimRank } from '../models/memory-cap.js';
|
|
13
|
-
import { assetBytes, curatedListables, curatedModelAsset, customContextLength, customModelSrc, modelAddonOf } from '../models/model-catalog.js';
|
|
13
|
+
import { assetBytes, curatedListables, curatedModelAsset, customContextLength, customModelSrc, modelAddonOf, speculativeDraft } from '../models/model-catalog.js';
|
|
14
14
|
import { ModelFit } from '../models/model-fit.js';
|
|
15
15
|
import { createModelStatusCache, invalidateModelStatusCache } from '../models/model-list.js';
|
|
16
16
|
import { awaitModelCapacity, contextSize, slotCount, createModelPool, evictIdle, evictIdleWhere, evictIdleWithin, evictModel, evictModelWithin, isResident, leaseCount, loadedModels, loadingModels, modelKey, modelOf, releaseModel, resolveLoadOptions, settledEntries, settledModels } from '../models/model-pool.js';
|
|
@@ -526,7 +526,10 @@ export class Residency {
|
|
|
526
526
|
modelConfig = {
|
|
527
527
|
ctx_size: ctxSize,
|
|
528
528
|
parallel: slots > 1 ? slots : undefined,
|
|
529
|
-
projectionModelSrc: this._projectionFor(model)
|
|
529
|
+
projectionModelSrc: this._projectionFor(model),
|
|
530
|
+
draftModelSrc: target.loadOpts.llama?.speculative
|
|
531
|
+
? speculativeDraft(model)?.model?.src
|
|
532
|
+
: undefined
|
|
530
533
|
};
|
|
531
534
|
}
|
|
532
535
|
const sized = await this._sizeLoad({
|
|
@@ -582,8 +585,8 @@ export class Residency {
|
|
|
582
585
|
}
|
|
583
586
|
async _sizeLoad({ model, modelSrc, modelType, modelConfig }) {
|
|
584
587
|
const downloaded = downloadBytes(modelSrc);
|
|
585
|
-
const { projectionModelSrc, ...config } = modelConfig ?? {};
|
|
586
|
-
const
|
|
588
|
+
const { projectionModelSrc, draftModelSrc, spec_type, spec_draft_n_max, ...config } = modelConfig ?? {};
|
|
589
|
+
const companions = (downloadBytes(projectionModelSrc) ?? 0) + (downloadBytes(draftModelSrc) ?? 0);
|
|
587
590
|
try {
|
|
588
591
|
const sdk = await this.sdk.load();
|
|
589
592
|
const { models } = await sdk.assessModelFit({
|
|
@@ -592,7 +595,7 @@ export class Residency {
|
|
|
592
595
|
const [fit] = models;
|
|
593
596
|
const bytes = fit?.floorBytes ?? downloaded;
|
|
594
597
|
return {
|
|
595
|
-
bytes: bytes === undefined ? undefined : bytes +
|
|
598
|
+
bytes: bytes === undefined ? undefined : bytes + companions,
|
|
596
599
|
tooLarge: fit?.verdict === 'likely-too-large',
|
|
597
600
|
confirmed: fit?.verdict === 'likely-fits' && fit.evidence === 'native-fit'
|
|
598
601
|
};
|
|
@@ -600,7 +603,7 @@ export class Residency {
|
|
|
600
603
|
catch (err) {
|
|
601
604
|
HarnessLog.warn('fit estimate failed', { model, err: errorMessage(err) });
|
|
602
605
|
return {
|
|
603
|
-
bytes: downloaded === undefined ? undefined : downloaded +
|
|
606
|
+
bytes: downloaded === undefined ? undefined : downloaded + companions,
|
|
604
607
|
tooLarge: false,
|
|
605
608
|
confirmed: false
|
|
606
609
|
};
|
package/dist-lib/lib/spawn.d.ts
CHANGED
|
@@ -44,11 +44,20 @@ export interface HarnessMcpServer {
|
|
|
44
44
|
};
|
|
45
45
|
defer?: boolean;
|
|
46
46
|
}
|
|
47
|
+
export interface HarnessChartsOptions {
|
|
48
|
+
theme?: 'dark' | 'light';
|
|
49
|
+
mark?: {
|
|
50
|
+
href: string;
|
|
51
|
+
width: number;
|
|
52
|
+
height: number;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
47
55
|
export interface HarnessPluginOptions {
|
|
48
56
|
speech?: HarnessSpeechOptions;
|
|
49
57
|
mcp?: {
|
|
50
58
|
servers?: HarnessMcpServer[];
|
|
51
59
|
};
|
|
60
|
+
charts?: HarnessChartsOptions;
|
|
52
61
|
ocr?: boolean;
|
|
53
62
|
[name: string]: unknown;
|
|
54
63
|
}
|
|
@@ -1,16 +1,36 @@
|
|
|
1
1
|
import { relativeKey, searchTargets } from '../fs/targets.js';
|
|
2
2
|
import { compileGlob } from '../fs/glob.js';
|
|
3
3
|
import { callDenyRoots, defaultRealpath, isDeniedPath } from '../fs/scope.js';
|
|
4
|
-
import { anchorOf, shownPath, stringArg } from '../fs/tool-path.js';
|
|
5
|
-
import {
|
|
4
|
+
import { anchorOf, MAX_LIMIT, pagingError, shownPath, stringArg } from '../fs/tool-path.js';
|
|
5
|
+
import { engineAnswer } from '../fs/engine.js';
|
|
6
|
+
import { MAX_WALK_MS, walkFiles } from '../fs/walk.js';
|
|
6
7
|
import { folderArg, folderPaths } from './list-dir.js';
|
|
7
8
|
const GLOB_MATCHES = 100;
|
|
9
|
+
function interleaveTopLevel(hits) {
|
|
10
|
+
const groups = new Map();
|
|
11
|
+
for (const hit of hits) {
|
|
12
|
+
const list = groups.get(hit.group) ?? [];
|
|
13
|
+
list.push(hit);
|
|
14
|
+
groups.set(hit.group, list);
|
|
15
|
+
}
|
|
16
|
+
const order = [];
|
|
17
|
+
for (let round = 0; order.length < hits.length; round++) {
|
|
18
|
+
for (const list of groups.values()) {
|
|
19
|
+
if (round < list.length) {
|
|
20
|
+
order.push(list[round]);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return order;
|
|
25
|
+
}
|
|
8
26
|
export function createGlobTool({ realpath = defaultRealpath, deniedRoots } = {}) {
|
|
9
27
|
return {
|
|
10
28
|
name: 'glob',
|
|
11
29
|
toolset: 'files',
|
|
12
30
|
description: 'Find files in the shared folder by name pattern, newest first. "**" crosses folders: ' +
|
|
13
|
-
'"**/*.md" finds every Markdown file, "*report*" matches names anywhere.'
|
|
31
|
+
'"**/*.md" finds every Markdown file, "*report*" matches names anywhere. ' +
|
|
32
|
+
'Ignored files and cache folders are skipped (set includeIgnored to find them; .git and node_modules stay out). A long answer samples every ' +
|
|
33
|
+
'top-level folder and offset pages that sample.',
|
|
14
34
|
parameters: {
|
|
15
35
|
type: 'object',
|
|
16
36
|
properties: {
|
|
@@ -18,7 +38,13 @@ export function createGlobTool({ realpath = defaultRealpath, deniedRoots } = {})
|
|
|
18
38
|
dir: {
|
|
19
39
|
type: 'string',
|
|
20
40
|
description: 'Folder to search, relative to the shared folder (optional)'
|
|
21
|
-
}
|
|
41
|
+
},
|
|
42
|
+
includeIgnored: {
|
|
43
|
+
type: 'boolean',
|
|
44
|
+
description: 'Also find files .gitignore and cache folders leave out'
|
|
45
|
+
},
|
|
46
|
+
limit: { type: 'number', description: `Most paths to return (default ${GLOB_MATCHES})` },
|
|
47
|
+
offset: { type: 'number', description: 'Paths to skip, to page past a cut-off answer' }
|
|
22
48
|
},
|
|
23
49
|
required: ['pattern']
|
|
24
50
|
},
|
|
@@ -27,7 +53,7 @@ export function createGlobTool({ realpath = defaultRealpath, deniedRoots } = {})
|
|
|
27
53
|
stableRead: true,
|
|
28
54
|
autoApprove: true,
|
|
29
55
|
rootsRequired: true,
|
|
30
|
-
validate: (args) => (stringArg(args, 'pattern') ?
|
|
56
|
+
validate: (args) => (stringArg(args, 'pattern') ? pagingError(args) : 'pattern is required'),
|
|
31
57
|
paths: (args, ctx) => folderPaths(args, ctx),
|
|
32
58
|
resource: (args) => ({ kind: 'file', label: `glob ${String(args.pattern ?? '')}` }),
|
|
33
59
|
async execute(args, ctx) {
|
|
@@ -40,10 +66,19 @@ export function createGlobTool({ realpath = defaultRealpath, deniedRoots } = {})
|
|
|
40
66
|
const pattern = String(args.pattern);
|
|
41
67
|
const test = compileGlob(pattern);
|
|
42
68
|
const byName = !pattern.includes('/');
|
|
69
|
+
const limit = Math.min(Number(args.limit ?? GLOB_MATCHES), MAX_LIMIT);
|
|
70
|
+
const offset = Number(args.offset ?? 0);
|
|
71
|
+
const includeIgnored = args.includeIgnored === true;
|
|
43
72
|
const hits = [];
|
|
44
73
|
let walkTruncated = false;
|
|
45
|
-
for (const target of scoped.targets) {
|
|
46
|
-
const
|
|
74
|
+
for (const [index, target] of scoped.targets.entries()) {
|
|
75
|
+
const base = target.folder.replace(/^\/+|\/+$/g, '');
|
|
76
|
+
const walk = await walkTarget(target, {
|
|
77
|
+
include: byName || !base ? pattern : `${base}/${pattern}`,
|
|
78
|
+
includeIgnored,
|
|
79
|
+
deny,
|
|
80
|
+
signal: ctx?.signal
|
|
81
|
+
});
|
|
47
82
|
walkTruncated ||= walk.truncated;
|
|
48
83
|
for (const file of walk.files) {
|
|
49
84
|
const rel = relativeKey(file.key, target.folder);
|
|
@@ -52,14 +87,40 @@ export function createGlobTool({ realpath = defaultRealpath, deniedRoots } = {})
|
|
|
52
87
|
continue;
|
|
53
88
|
}
|
|
54
89
|
const mtime = file.mtime ?? (await target.root.drive.entry(file.key))?.mtime ?? 0;
|
|
55
|
-
|
|
90
|
+
const group = `${index}/${rel.includes('/') ? rel.slice(0, rel.indexOf('/')) : ''}`;
|
|
91
|
+
hits.push({ path: shownPath(file.path, anchorOf(ctx)), mtime, group });
|
|
56
92
|
}
|
|
57
93
|
}
|
|
58
94
|
hits.sort((a, b) => b.mtime - a.mtime);
|
|
95
|
+
const sampled = hits.length > GLOB_MATCHES;
|
|
96
|
+
const order = sampled ? interleaveTopLevel(hits) : hits;
|
|
97
|
+
const page = order.slice(offset, offset + limit);
|
|
98
|
+
const truncated = walkTruncated || hits.length > offset + limit || undefined;
|
|
99
|
+
if (!sampled) {
|
|
100
|
+
return { matches: page.map((hit) => hit.path), truncated };
|
|
101
|
+
}
|
|
102
|
+
const groups = new Set(hits.map((hit) => hit.group)).size;
|
|
103
|
+
const shown = new Set(page.map((hit) => hit.group)).size;
|
|
59
104
|
return {
|
|
60
|
-
matches:
|
|
61
|
-
truncated
|
|
105
|
+
matches: page.map((hit) => hit.path),
|
|
106
|
+
truncated,
|
|
107
|
+
note: `showing ${page.length} of ${hits.length} paths, sampled across ${shown} of ${groups} top-level folders; page with offset`
|
|
62
108
|
};
|
|
63
109
|
}
|
|
64
110
|
};
|
|
65
111
|
}
|
|
112
|
+
async function walkTarget({ root, folder }, { include, includeIgnored, deny, signal }) {
|
|
113
|
+
const native = root.kind === 'local' ? root.walk : undefined;
|
|
114
|
+
if (native) {
|
|
115
|
+
const walked = await engineAnswer(root, folder, {
|
|
116
|
+
run: () => native({ folder, include, includeIgnored, deny, maxMs: MAX_WALK_MS, signal }),
|
|
117
|
+
found: (answer) => answer.files.length > 0 || answer.truncated,
|
|
118
|
+
includeIgnored,
|
|
119
|
+
signal
|
|
120
|
+
});
|
|
121
|
+
if (walked) {
|
|
122
|
+
return walked;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return walkFiles(root, folder, { includeIgnored });
|
|
126
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { errorMessage } from '../../guards.js';
|
|
2
2
|
import { searchTargets } from '../fs/targets.js';
|
|
3
3
|
import { compileGlob } from '../fs/glob.js';
|
|
4
|
-
import { callDenyRoots, defaultRealpath } from '../fs/scope.js';
|
|
4
|
+
import { callDenyRoots, defaultRealpath, isDeniedPath } from '../fs/scope.js';
|
|
5
5
|
import { DriveSearch } from '../fs/search.js';
|
|
6
|
-
import { anchorOf, shownPath, stringArg } from '../fs/tool-path.js';
|
|
6
|
+
import { anchorOf, MAX_LIMIT, pagingError, shownPath, stringArg } from '../fs/tool-path.js';
|
|
7
|
+
import { engineAnswer } from '../fs/engine.js';
|
|
7
8
|
import { MAX_WALK_ENTRIES, MAX_WALK_MS } from '../fs/walk.js';
|
|
8
9
|
import { folderArg, folderPaths } from './list-dir.js';
|
|
9
10
|
const GREP_MATCHES = 100;
|
|
10
|
-
const MAX_LIMIT = 500;
|
|
11
11
|
const MAX_LINE_CHARS = 300;
|
|
12
12
|
const TALLY_MATCHES = 5000;
|
|
13
13
|
const SPREAD_MATCHES = 1000;
|
|
@@ -21,8 +21,10 @@ export function createGrepTool({ realpath = defaultRealpath, deniedRoots, maxWal
|
|
|
21
21
|
return {
|
|
22
22
|
name: 'grep',
|
|
23
23
|
toolset: 'files',
|
|
24
|
-
description: 'Search inside the files of the shared folder. The pattern is plain text, case-insensitive
|
|
25
|
-
'"a|b" finds either; set regex for a regular expression.
|
|
24
|
+
description: 'Search inside the files of the shared folder. The pattern is plain text, case-insensitive ' +
|
|
25
|
+
'(set caseSensitive to match case); "a|b" finds either; set regex for a regular expression. ' +
|
|
26
|
+
'Ignored files and cache folders are skipped (set includeIgnored to search them; .git and node_modules stay out). ' +
|
|
27
|
+
'Returns "path:line: text"; output ' +
|
|
26
28
|
'"files" lists matching files with the first line and count, "count" counts per file. Narrow with include (e.g. "*.ts").',
|
|
27
29
|
parameters: {
|
|
28
30
|
type: 'object',
|
|
@@ -37,6 +39,11 @@ export function createGrepTool({ realpath = defaultRealpath, deniedRoots, maxWal
|
|
|
37
39
|
description: 'Only files whose name matches this pattern (optional)'
|
|
38
40
|
},
|
|
39
41
|
regex: { type: 'boolean', description: 'Treat pattern as a regular expression' },
|
|
42
|
+
caseSensitive: { type: 'boolean', description: "Match the pattern's exact case" },
|
|
43
|
+
includeIgnored: {
|
|
44
|
+
type: 'boolean',
|
|
45
|
+
description: 'Also search files .gitignore and cache folders leave out'
|
|
46
|
+
},
|
|
40
47
|
output: {
|
|
41
48
|
type: 'string',
|
|
42
49
|
enum: [...OUTPUTS],
|
|
@@ -58,10 +65,9 @@ export function createGrepTool({ realpath = defaultRealpath, deniedRoots, maxWal
|
|
|
58
65
|
if (args.output !== undefined && !isOutput(args.output)) {
|
|
59
66
|
return `output is one of ${OUTPUTS.join(', ')}`;
|
|
60
67
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
68
|
+
const paging = pagingError(args);
|
|
69
|
+
if (paging) {
|
|
70
|
+
return paging;
|
|
65
71
|
}
|
|
66
72
|
if (args.regex !== true) {
|
|
67
73
|
return null;
|
|
@@ -86,16 +92,21 @@ export function createGrepTool({ realpath = defaultRealpath, deniedRoots, maxWal
|
|
|
86
92
|
const pattern = String(args.pattern);
|
|
87
93
|
const regex = args.regex === true;
|
|
88
94
|
const queries = regex ? [pattern] : alternatives(pattern);
|
|
95
|
+
const caseSensitive = args.caseSensitive === true;
|
|
89
96
|
const output = isOutput(args.output) ? args.output : 'content';
|
|
90
97
|
const limit = Math.min(Number(args.limit ?? GREP_MATCHES), MAX_LIMIT);
|
|
91
98
|
const offset = Number(args.offset ?? 0);
|
|
92
99
|
const spread = args.output === undefined && args.limit === undefined && offset === 0;
|
|
93
100
|
const wanted = spread ? SPREAD_MATCHES : reach(output, offset + limit);
|
|
94
101
|
const query = {
|
|
95
|
-
search: new DriveSearch(queries, { regex }),
|
|
102
|
+
search: new DriveSearch(queries, { regex, caseSensitive }),
|
|
96
103
|
queries,
|
|
97
104
|
regex,
|
|
98
|
-
|
|
105
|
+
caseSensitive,
|
|
106
|
+
includeIgnored: args.includeIgnored === true,
|
|
107
|
+
include: stringArg(args, 'include') ? String(args.include).replace(/^\.\//, '') : undefined,
|
|
108
|
+
anchor: anchorOf(ctx),
|
|
109
|
+
signal: ctx?.signal,
|
|
99
110
|
deny,
|
|
100
111
|
maxEntries: maxWalkEntries
|
|
101
112
|
};
|
|
@@ -136,7 +147,7 @@ export function createGrepTool({ realpath = defaultRealpath, deniedRoots, maxWal
|
|
|
136
147
|
};
|
|
137
148
|
}
|
|
138
149
|
function includes(pattern, anchor) {
|
|
139
|
-
const glob = compileGlob(pattern
|
|
150
|
+
const glob = compileGlob(pattern);
|
|
140
151
|
return pattern.includes('/') ? (_name, full) => glob(shownPath(full, anchor)) : glob;
|
|
141
152
|
}
|
|
142
153
|
const reach = (output, lines) => output === 'content' ? lines : TALLY_MATCHES;
|
|
@@ -195,18 +206,50 @@ function noMatches(pattern, { regex, offset, found }) {
|
|
|
195
206
|
}
|
|
196
207
|
return 'no matches';
|
|
197
208
|
}
|
|
198
|
-
function searchTarget({ root, folder }, { search, queries, regex, include, deny, maxEntries, maxMatches }) {
|
|
209
|
+
async function searchTarget({ root, folder }, { search, queries, regex, caseSensitive, includeIgnored, include, anchor, signal, deny, maxEntries, maxMatches }) {
|
|
210
|
+
const query = {
|
|
211
|
+
folder,
|
|
212
|
+
queries: [...queries],
|
|
213
|
+
regex,
|
|
214
|
+
caseSensitive,
|
|
215
|
+
includeIgnored,
|
|
216
|
+
maxMatches,
|
|
217
|
+
maxEntries,
|
|
218
|
+
maxMs: MAX_WALK_MS
|
|
219
|
+
};
|
|
199
220
|
if (root.kind === 'hyper' && root.search && !include) {
|
|
200
|
-
return root.search(
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
includeIgnored: false,
|
|
221
|
+
return root.search(query);
|
|
222
|
+
}
|
|
223
|
+
const native = root.kind === 'local' ? await nativeSearch(root, { ...query, include, deny, signal }) : null;
|
|
224
|
+
return (native ??
|
|
225
|
+
search.searchFolder(root, folder, {
|
|
206
226
|
maxMatches,
|
|
207
227
|
maxEntries,
|
|
208
|
-
|
|
209
|
-
|
|
228
|
+
include: include ? includes(include, anchor) : null,
|
|
229
|
+
deny,
|
|
230
|
+
includeIgnored
|
|
231
|
+
}));
|
|
232
|
+
}
|
|
233
|
+
async function nativeSearch(root, query) {
|
|
234
|
+
const native = root.search;
|
|
235
|
+
if (!native) {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
const found = await engineAnswer(root, query.folder, {
|
|
239
|
+
run: () => native(query),
|
|
240
|
+
found: (answer) => answer.hits.length > 0 || answer.truncated,
|
|
241
|
+
includeIgnored: query.includeIgnored,
|
|
242
|
+
signal: query.signal
|
|
243
|
+
});
|
|
244
|
+
if (!found) {
|
|
245
|
+
return null;
|
|
210
246
|
}
|
|
211
|
-
|
|
247
|
+
const hits = found.hits.filter((hit) => !isDeniedPath(hit.file, query.deny));
|
|
248
|
+
const cutShort = found.capped && hits.length < found.hits.length;
|
|
249
|
+
return {
|
|
250
|
+
...found,
|
|
251
|
+
hits,
|
|
252
|
+
capped: hits.length >= query.maxMatches,
|
|
253
|
+
truncated: found.truncated || cutShort
|
|
254
|
+
};
|
|
212
255
|
}
|