@qvac/harness 1.0.0-rc.5 → 1.0.0-rc.7
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 +245 -23
- package/README.md +19 -7
- package/dist-lib/index.d.ts +5 -3
- package/dist-lib/index.js +43 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/inspecting.js +13 -3
- package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.js +8 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/preparing.js +21 -19
- package/dist-lib/lib/capabilities/completion-engine/actors/resolving.js +11 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/skill-step.js +10 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.js +9 -3
- package/dist-lib/lib/capabilities/completion-engine/actors/streaming.js +36 -19
- package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.js +9 -11
- package/dist-lib/lib/capabilities/completion-engine/driver.js +3 -0
- package/dist-lib/lib/capabilities/completion-engine/index.d.ts +4 -1
- package/dist-lib/lib/capabilities/completion-engine/index.js +3 -0
- package/dist-lib/lib/capabilities/completion-engine/model-round.d.ts +15 -1
- package/dist-lib/lib/capabilities/completion-engine/model-round.js +52 -0
- package/dist-lib/lib/capabilities/completion-engine/round.d.ts +3 -3
- package/dist-lib/lib/capabilities/completion-engine/round.js +5 -2
- package/dist-lib/lib/capabilities/completion-engine/tool-sets.d.ts +24 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-sets.js +15 -0
- package/dist-lib/lib/capabilities/completion-engine/turns.js +14 -4
- package/dist-lib/lib/capabilities/detect-language.d.ts +2 -1
- package/dist-lib/lib/capabilities/detect-language.js +14 -2
- package/dist-lib/lib/capabilities/sdk-tool.d.ts +9 -1
- package/dist-lib/lib/capabilities/sdk-tool.js +21 -2
- package/dist-lib/lib/capabilities/tool-plan.d.ts +4 -0
- package/dist-lib/lib/capabilities/tool-plan.js +15 -0
- package/dist-lib/lib/connect.d.ts +2 -0
- package/dist-lib/lib/connect.js +79 -3
- package/dist-lib/lib/contract/run.d.ts +2 -0
- package/dist-lib/lib/contract-types.d.ts +5 -0
- package/dist-lib/lib/errors.d.ts +4 -0
- package/dist-lib/lib/errors.js +6 -0
- package/dist-lib/lib/hardware/cpu-placement.d.ts +8 -0
- package/dist-lib/lib/hardware/cpu-placement.js +48 -0
- package/dist-lib/lib/helpers/goal-check.d.ts +2 -0
- package/dist-lib/lib/helpers/goal-check.js +18 -0
- package/dist-lib/lib/helpers/require-peers.d.ts +3 -0
- package/dist-lib/lib/helpers/require-peers.js +23 -0
- package/dist-lib/lib/machine/completion/actions/completion.js +30 -11
- package/dist-lib/lib/machine/completion/context.js +2 -1
- package/dist-lib/lib/machine/completion/rules.d.ts +1 -1
- package/dist-lib/lib/machine/completion/rules.js +7 -8
- package/dist-lib/lib/machine/completion/types.d.ts +1 -0
- package/dist-lib/lib/models/llm-presets.d.ts +1 -0
- package/dist-lib/lib/models/model-catalog.js +1 -1
- package/dist-lib/lib/models/model-pool.d.ts +4 -0
- package/dist-lib/lib/models/model-pool.js +4 -1
- package/dist-lib/lib/models/opencl-cache.js +2 -2
- package/dist-lib/lib/plugins/registry.d.ts +2 -0
- package/dist-lib/lib/plugins/registry.js +4 -0
- package/dist-lib/lib/prompt.d.ts +2 -1
- package/dist-lib/lib/prompt.js +12 -12
- package/dist-lib/lib/residency/completion-runtime.d.ts +9 -1
- package/dist-lib/lib/residency/completion-runtime.js +29 -26
- package/dist-lib/lib/residency/index.d.ts +4 -0
- package/dist-lib/lib/residency/index.js +6 -1
- package/dist-lib/lib/round-host.d.ts +12 -0
- package/dist-lib/lib/round-host.js +57 -0
- package/dist-lib/lib/round-port.d.ts +24 -0
- package/dist-lib/lib/round-port.js +81 -0
- package/dist-lib/lib/sdk-loader.d.ts +1 -1
- package/dist-lib/lib/sdk-loader.js +30 -6
- package/dist-lib/lib/sdk-storage.d.ts +1 -0
- package/dist-lib/lib/sdk-storage.js +18 -2
- package/dist-lib/lib/serve.js +68 -6
- package/dist-lib/lib/sidecar/index.d.ts +10 -0
- package/dist-lib/lib/sidecar/index.js +35 -3
- package/dist-lib/lib/sidecar/user-plugins.d.ts +1 -0
- package/dist-lib/lib/sidecar/user-plugins.js +1 -1
- package/dist-lib/lib/tools/files/grep.js +113 -15
- package/dist-lib/lib/tools/fs/edit-match.js +75 -7
- package/dist-lib/lib/tools/fs/search.d.ts +1 -1
- package/dist-lib/lib/tools/fs/search.js +2 -1
- package/dist-lib/lib/tools/http-request.js +1 -0
- package/dist-lib/lib/tools/index.d.ts +2 -1
- package/dist-lib/lib/tools/index.js +2 -2
- package/dist-lib/lib/tools/skills/skill-state-constants.d.ts +1 -0
- package/dist-lib/lib/tools/skills/skill-state-constants.js +4 -0
- package/dist-lib/lib/wire.d.ts +13 -0
- package/dist-lib/lib/wire.js +44 -1
- package/dist-lib/plugins/coding/read-only.d.ts +1 -0
- package/dist-lib/plugins/coding/read-only.js +264 -0
- package/dist-lib/plugins/coding/session.d.ts +3 -1
- package/dist-lib/plugins/coding/session.js +19 -2
- package/dist-lib/plugins/egress-proxy/index.d.ts +2 -2
- package/dist-lib/plugins/egress-proxy/index.js +5 -3
- package/dist-lib/plugins/image/index.js +7 -2
- package/dist-lib/plugins/language-hint/index.js +4 -1
- package/dist-lib/plugins/mcp/server.js +1 -1
- package/dist-lib/plugins/music/index.js +6 -2
- package/dist-lib/plugins/obsidian/readiness.js +2 -2
- package/dist-lib/plugins/obsidian/vault-read.js +17 -16
- package/dist-lib/plugins/python/index.js +1 -0
- package/dist-lib/plugins/python/loader.d.ts +1 -0
- package/dist-lib/plugins/python/loader.js +8 -0
- package/dist-lib/plugins/quickjs/index.js +4 -0
- package/dist-lib/plugins/quickjs/runtime.js +8 -3
- package/dist-lib/plugins/run-report/index.js +6 -2
- package/dist-lib/plugins/run-report/layout.js +1 -1
- package/dist-lib/plugins/sandbox-vm/index.js +3 -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/dist-lib/plugins/speech/audio-resample.js +2 -1
- package/dist-lib/plugins/speech/index.d.ts +1 -0
- package/dist-lib/plugins/speech/index.js +8 -1
- package/dist-lib/plugins/speech/speech-runtime.js +3 -3
- package/dist-lib/plugins/translation/index.d.ts +1 -1
- package/dist-lib/plugins/translation/index.js +7 -3
- package/dist-lib/plugins/translation/translate.d.ts +2 -2
- package/dist-lib/plugins/translation/translate.js +7 -8
- package/dist-lib/plugins/walkie-talkie/index.d.ts +2 -2
- package/dist-lib/plugins/walkie-talkie/index.js +13 -5
- package/dist-lib/plugins/walkie-talkie/wire.d.ts +5 -0
- package/dist-lib/plugins/walkie-talkie/wire.js +6 -5
- package/dist-lib/schema/harness.js +12 -2
- package/dist-lib/spec/hrpc/messages.js +208 -150
- package/dist-lib/spec/hyperschema/index.js +208 -150
- package/dist-lib/spec/hyperschema/schema.json +125 -84
- package/dist-lib/spec/hyperschema/types.d.ts +4 -3
- package/package.json +150 -25
|
@@ -65,7 +65,8 @@ export function emptyCompletionContext(opts) {
|
|
|
65
65
|
tokens: opts.goal.tokens ?? null,
|
|
66
66
|
turns: 0,
|
|
67
67
|
status: 'open',
|
|
68
|
-
checks: (opts.goal.checks ?? []).map((name) => ({ name, passed: false, output: null }))
|
|
68
|
+
checks: (opts.goal.checks ?? []).map((name) => ({ name, passed: false, output: null })),
|
|
69
|
+
named: (opts.goal.checksProve && Boolean(opts.goal.checks?.length)) || undefined
|
|
69
70
|
}
|
|
70
71
|
: null
|
|
71
72
|
};
|
|
@@ -11,7 +11,7 @@ export declare const MAX_ROUND_REPEATS = 3;
|
|
|
11
11
|
export declare const MAX_ROUND_CALLS = 32;
|
|
12
12
|
export declare function nudgeWithPlan(nudge: string, plan: readonly PlanStep[]): string;
|
|
13
13
|
export declare function goalMet({ plan, goal }: Readonly<CompletionContext>): boolean;
|
|
14
|
-
export declare function nudgeWithChecks(nudge: string, checks: readonly GoalCheck[],
|
|
14
|
+
export declare function nudgeWithChecks(nudge: string, checks: readonly GoalCheck[], unnamed?: boolean): string;
|
|
15
15
|
export declare function goalTokensLeft({ goal, metrics }: Readonly<CompletionContext>): boolean;
|
|
16
16
|
export declare function goalStalled({ outcome }: Readonly<CompletionContext>): boolean;
|
|
17
17
|
export declare function retainFailureResults(history: readonly CompletionHistoryEntry[], values: Readonly<Record<string, FailureResultValue>>, failedCalls: Readonly<Record<string, SettledCall>>): Record<string, FailureResultValue>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isFailureResultReference } from '../../helpers/failure-result.js';
|
|
2
|
-
import { GOAL_CHECKS_ASK } from '../../helpers/goal-check.js';
|
|
2
|
+
import { GOAL_CHECKS_ASK, GOAL_PROOF_ASK } from '../../helpers/goal-check.js';
|
|
3
3
|
export function runsUnasked(facts) {
|
|
4
4
|
if (facts.permission === 'ask')
|
|
5
5
|
return false;
|
|
@@ -35,20 +35,19 @@ function planDone(plan) {
|
|
|
35
35
|
}
|
|
36
36
|
export function goalMet({ plan, goal }) {
|
|
37
37
|
const checks = goal?.checks ?? [];
|
|
38
|
-
return (planDone(plan) &&
|
|
39
|
-
(checks.length > 0 || !goal?.checkable) &&
|
|
40
|
-
checks.every((check) => check.passed));
|
|
38
|
+
return (planDone(plan) && (goal?.named || !goal?.checkable) && checks.every((check) => check.passed));
|
|
41
39
|
}
|
|
42
|
-
export function nudgeWithChecks(nudge, checks,
|
|
40
|
+
export function nudgeWithChecks(nudge, checks, unnamed) {
|
|
43
41
|
if (!checks.length) {
|
|
44
|
-
return
|
|
42
|
+
return unnamed ? `${nudge}\n${GOAL_CHECKS_ASK}` : nudge;
|
|
45
43
|
}
|
|
44
|
+
const asked = unnamed ? `${nudge}\n${GOAL_PROOF_ASK}` : nudge;
|
|
46
45
|
const open = checks.filter((check) => !check.passed);
|
|
47
46
|
if (!open.length) {
|
|
48
|
-
return
|
|
47
|
+
return asked;
|
|
49
48
|
}
|
|
50
49
|
const lines = open.map(({ name, output }) => output === null ? `- ${name}: not run yet` : `- ${name}: failed. Its last output:\n${output}`);
|
|
51
|
-
return (`${
|
|
50
|
+
return (`${asked}\nChecks: the goal is met only once each of these runs as its own command and ` +
|
|
52
51
|
`exits 0, with no pipe or ; after it to hide its exit code.\n${lines.join('\n')}`);
|
|
53
52
|
}
|
|
54
53
|
export function goalTokensLeft({ goal, metrics }) {
|
|
@@ -1,4 +1,4 @@
|
|
|
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, MMPROJ_QWEN3_5_2B_MULTIMODAL_Q8_0, MMPROJ_QWEN3_5_4B_MULTIMODAL_Q8_0, MMPROJ_QWEN3_5_9B_MULTIMODAL_F16, MMPROJ_QWEN3_6_27B_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_27B_MULTIMODAL_Q4_K_XL, 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_MOSS_TTS_F16, TTS_CODEC_ENCODER_MOSS_TTS_F16, TTS_DELAY_LLM_MOSS_TTS_F16, TTS_MULTILINGUAL_SUPERTONIC3_FP16, TTS_MULTILINGUAL_SUPERTONIC3_Q4_0, TTS_MULTILINGUAL_SUPERTONIC3_Q8_0 } from '@qvac/
|
|
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, MMPROJ_QWEN3_5_2B_MULTIMODAL_Q8_0, MMPROJ_QWEN3_5_4B_MULTIMODAL_Q8_0, MMPROJ_QWEN3_5_9B_MULTIMODAL_F16, MMPROJ_QWEN3_6_27B_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_27B_MULTIMODAL_Q4_K_XL, 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_MOSS_TTS_F16, TTS_CODEC_ENCODER_MOSS_TTS_F16, TTS_DELAY_LLM_MOSS_TTS_F16, 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 } from './tts-model-default.js';
|
|
4
4
|
import { CAPABILITY_PROFILE_ORDER, QWEN_35_2B, QWEN_35_4B, QWEN_35_9B, QWEN_36_27B, QWEN_36_35B_A3B, QWEN_38_27B, 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';
|
|
@@ -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 { CpuPlacement } from '../hardware/cpu-placement.ts';
|
|
4
5
|
import { type ModelAddon } from './model-source.ts';
|
|
5
6
|
import type { GpuFaultState } from './sdk-faults.ts';
|
|
6
7
|
import type { LoadedModelInfo } from '@qvac/sdk';
|
|
@@ -55,6 +56,7 @@ export interface LlmDeviceConfig {
|
|
|
55
56
|
slots?: number;
|
|
56
57
|
contextFor?: (key: string) => number | undefined;
|
|
57
58
|
slotsFor?: (key: string) => number | undefined;
|
|
59
|
+
cpuPlacement?: () => CpuPlacement | undefined;
|
|
58
60
|
}
|
|
59
61
|
export type TrackedLoad = Promise<string> & {
|
|
60
62
|
requestId?: string;
|
|
@@ -89,6 +91,8 @@ export type ModelLifecycleSdk = Pick<SdkModule, 'unloadModel' | 'modelRegistrySe
|
|
|
89
91
|
gpu_layers?: number;
|
|
90
92
|
'main-gpu'?: string;
|
|
91
93
|
openclCacheDir?: string;
|
|
94
|
+
threads?: number;
|
|
95
|
+
'cpu-mask'?: string;
|
|
92
96
|
};
|
|
93
97
|
onProgress?: (progress: Record<string, unknown>) => void;
|
|
94
98
|
}): TrackedLoad;
|
|
@@ -423,6 +423,7 @@ export function createModelPool(loadSdk, notify, { deviceConfig = {}, loads = cr
|
|
|
423
423
|
const openclCache = deviceConfig.device !== 'cpu' && deviceConfig.openclCacheDir
|
|
424
424
|
? deviceConfig.openclCacheDir()
|
|
425
425
|
: undefined;
|
|
426
|
+
const placement = deviceConfig.device === 'cpu' ? deviceConfig.cpuPlacement?.() : undefined;
|
|
426
427
|
const config = definedFields({
|
|
427
428
|
...resolved.llama,
|
|
428
429
|
verbosity: llmVerbosity(),
|
|
@@ -436,7 +437,9 @@ export function createModelPool(loadSdk, notify, { deviceConfig = {}, loads = cr
|
|
|
436
437
|
device: deviceConfig.device,
|
|
437
438
|
gpu_layers: deviceConfig.gpuLayers,
|
|
438
439
|
'main-gpu': mainGpu,
|
|
439
|
-
openclCacheDir: openclCache || undefined
|
|
440
|
+
openclCacheDir: openclCache || undefined,
|
|
441
|
+
threads: resolved.llama?.threads ?? placement?.threads,
|
|
442
|
+
'cpu-mask': placement?.mask
|
|
440
443
|
});
|
|
441
444
|
const pending = { key, model, modelSrc, modelType: 'llamacpp-completion' };
|
|
442
445
|
const chosen = contextSize(model, modelSrc, { opts: resolved, deviceConfig });
|
|
@@ -2,11 +2,11 @@ import fs from 'fs';
|
|
|
2
2
|
import { platform } from 'os';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import process from 'process';
|
|
5
|
-
import
|
|
5
|
+
import enginePkg from '@qvac/inference/package' with { type: 'json' };
|
|
6
6
|
const OPENCL_CACHE_DIR_ENV = 'QVAC_OPENCL_CACHE_DIR';
|
|
7
7
|
export const OPENCL_CACHE_MAX_AGE_MS = 60 * 60 * 1000;
|
|
8
8
|
const noop = () => { };
|
|
9
|
-
export function openclEngineKey(sdkVersion =
|
|
9
|
+
export function openclEngineKey(sdkVersion = enginePkg.version) {
|
|
10
10
|
return `sdk-${sdkVersion}`.replace(/[^A-Za-z0-9._-]/g, '_');
|
|
11
11
|
}
|
|
12
12
|
export function openclCacheRoot(env = process.env, hostPlatform = platform()) {
|
|
@@ -6,6 +6,7 @@ import type { EmbedHost, ModelHost } from '../contract/models.ts';
|
|
|
6
6
|
import type { SpeechService } from '../contract/speech.ts';
|
|
7
7
|
import type { HarnessHook, SkillReadiness } from '../contract/index.ts';
|
|
8
8
|
import type { ExecLanguage, ExecRoute, ExecShell } from '../contract/exec.ts';
|
|
9
|
+
import { type PeerResolvers } from '../helpers/require-peers.ts';
|
|
9
10
|
import type { Context, Services } from './context.ts';
|
|
10
11
|
import type { Dispose } from './scope.ts';
|
|
11
12
|
declare module './context.ts' {
|
|
@@ -99,6 +100,7 @@ export declare class PluginRegistry {
|
|
|
99
100
|
private _closing;
|
|
100
101
|
constructor(plugins: readonly HarnessPlugin[], options?: PluginRegistryOptions);
|
|
101
102
|
static loadAddons(owner: string, addons?: AddonLoaders): Promise<void>;
|
|
103
|
+
static requirePeers(plugin: string, peers: PeerResolvers): void;
|
|
102
104
|
start(reserved: Iterable<string>, { fetch, publish }?: PluginStartOptions): Promise<StartedPlugins>;
|
|
103
105
|
add(plugin: HarnessPlugin): Promise<void>;
|
|
104
106
|
remove(name: string): Promise<void>;
|
|
@@ -3,6 +3,7 @@ import { Policy } from '../policy/index.js';
|
|
|
3
3
|
import { canonicalDenyRoots, defaultRealpath } from '../tools/fs/scope.js';
|
|
4
4
|
import { TOOLSETS } from '../tools/toolsets.js';
|
|
5
5
|
import { loadAddons } from './addons.js';
|
|
6
|
+
import { requirePeers } from '../helpers/require-peers.js';
|
|
6
7
|
import { PluginRuntime } from './runtime.js';
|
|
7
8
|
const API_VERSION = 1;
|
|
8
9
|
const EXEC_TOOL = 'exec';
|
|
@@ -283,6 +284,9 @@ export class PluginRegistry {
|
|
|
283
284
|
static loadAddons(owner, addons) {
|
|
284
285
|
return loadAddons(owner, addons);
|
|
285
286
|
}
|
|
287
|
+
static requirePeers(plugin, peers) {
|
|
288
|
+
requirePeers(`@qvac/harness/plugins/${plugin}`, peers);
|
|
289
|
+
}
|
|
286
290
|
start(reserved, { fetch, publish } = {}) {
|
|
287
291
|
if (this._closing) {
|
|
288
292
|
return Promise.reject(new Error('Plugin registry is closing or closed'));
|
package/dist-lib/lib/prompt.d.ts
CHANGED
|
@@ -2,9 +2,10 @@ import type { Message, SystemPromptParts } from './contract/index.ts';
|
|
|
2
2
|
export declare const RAG_CITATION_LINE = "After your answer, add one final line naming the files you used, written exactly as [Sources: file-a.pdf, file-b.md] - or [Sources: none] if the excerpts did not answer the question. This line is required, it is the only place square brackets belong, and it is removed before the user sees it.";
|
|
3
3
|
export declare function currentTimeAnnotation(now?: Date): string;
|
|
4
4
|
export declare function lastUserContent(messages: Message[]): string;
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function annotateUserTimes<T extends {
|
|
6
6
|
role: string;
|
|
7
7
|
content: string;
|
|
8
|
+
sentAt?: number | undefined;
|
|
8
9
|
}>(turns: ReadonlyArray<T>, now?: Date): T[];
|
|
9
10
|
export declare function toolGuidelines(name: string): string[];
|
|
10
11
|
export interface SystemPromptInput {
|
package/dist-lib/lib/prompt.js
CHANGED
|
@@ -22,9 +22,10 @@ export const RAG_CITATION_LINE = 'After your answer, add one final line naming t
|
|
|
22
22
|
const METADATA_SECTION = `## Message Metadata
|
|
23
23
|
|
|
24
24
|
User messages may include metadata such as [Current local time: ...]. This is contextual information provided by the system, not part of the user's query. Use it only when relevant and never repeat it unless the user asks about the current date or time.`;
|
|
25
|
+
const WEEKDAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
|
25
26
|
export function currentTimeAnnotation(now = new Date()) {
|
|
26
27
|
const p = (n) => String(n).padStart(2, '0');
|
|
27
|
-
const stamp = `${now.getFullYear()}-${p(now.getMonth() + 1)}-${p(now.getDate())} ${p(now.getHours())}:${p(now.getMinutes())}:${p(now.getSeconds())}`;
|
|
28
|
+
const stamp = `${WEEKDAYS[now.getDay()]} ${now.getFullYear()}-${p(now.getMonth() + 1)}-${p(now.getDate())} ${p(now.getHours())}:${p(now.getMinutes())}:${p(now.getSeconds())}`;
|
|
28
29
|
const offset = -now.getTimezoneOffset();
|
|
29
30
|
const sign = offset < 0 ? '-' : '+';
|
|
30
31
|
const abs = Math.abs(offset);
|
|
@@ -39,17 +40,16 @@ export function lastUserContent(messages) {
|
|
|
39
40
|
}
|
|
40
41
|
return '';
|
|
41
42
|
}
|
|
42
|
-
export function
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
return result;
|
|
43
|
+
export function annotateUserTimes(turns, now = new Date()) {
|
|
44
|
+
const lastUser = turns.findLastIndex((turn) => turn.role === 'user');
|
|
45
|
+
return turns.map((turn, i) => {
|
|
46
|
+
if (turn.role !== 'user')
|
|
47
|
+
return turn;
|
|
48
|
+
if (!turn.sentAt && i !== lastUser)
|
|
49
|
+
return turn;
|
|
50
|
+
const at = turn.sentAt ? new Date(turn.sentAt) : now;
|
|
51
|
+
return { ...turn, content: `${currentTimeAnnotation(at)}\n\n${turn.content}` };
|
|
52
|
+
});
|
|
53
53
|
}
|
|
54
54
|
export function toolGuidelines(name) {
|
|
55
55
|
if (name === 'exec') {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AbortSignal as BareAbortSignal } from 'bare-abort-controller';
|
|
2
2
|
import type { CompletionArgs } from '../capabilities/completion-engine/index.ts';
|
|
3
|
-
import type { CompletionSdk, ToolDefinition } from '../contract/index.ts';
|
|
3
|
+
import type { CompletionSdk, RoundModelLease, ToolDefinition } from '../contract/index.ts';
|
|
4
4
|
import type { CompletionContext } from '../../index.ts';
|
|
5
5
|
import type { CompletionSkillEntry } from '../capabilities/skill-entry.ts';
|
|
6
6
|
import { type LlmDeviceConfig, type ModelLoadOptions, type ModelLifecycleSdk, type PoolLike } from '../models/model-pool.ts';
|
|
@@ -43,6 +43,13 @@ interface RuntimeResidency {
|
|
|
43
43
|
}): Promise<boolean>;
|
|
44
44
|
loadLifecycleSdk(): Promise<ModelLifecycleSdk>;
|
|
45
45
|
}
|
|
46
|
+
export type RoundResidency = Pick<RuntimeResidency, 'pool' | 'gate' | 'sdk' | 'acquireLease' | 'makeRoomForCompletion' | 'unloadIdleGenerators'>;
|
|
47
|
+
interface RoundTarget {
|
|
48
|
+
model: string;
|
|
49
|
+
key: string;
|
|
50
|
+
loadOpts: ModelLoadOptions;
|
|
51
|
+
signal?: BareAbortSignal | undefined;
|
|
52
|
+
}
|
|
46
53
|
export interface PreparedRuntime {
|
|
47
54
|
key: string;
|
|
48
55
|
args: Partial<CompletionArgs> & {
|
|
@@ -50,4 +57,5 @@ export interface PreparedRuntime {
|
|
|
50
57
|
};
|
|
51
58
|
}
|
|
52
59
|
export declare function prepareCompletionRuntime(residency: RuntimeResidency, request: CompletionRuntimeRequest): Promise<PreparedRuntime>;
|
|
60
|
+
export declare function roundAcquirer(residency: RoundResidency, { model, key, loadOpts, signal }: RoundTarget): (invocationSignal?: BareAbortSignal) => Promise<RoundModelLease>;
|
|
53
61
|
export {};
|
|
@@ -16,7 +16,35 @@ export async function prepareCompletionRuntime(residency, request) {
|
|
|
16
16
|
const key = modelKey(model, loadOpts);
|
|
17
17
|
const resident = isResident(residency.pool, key);
|
|
18
18
|
HarnessLog.info('completion start', { model, resident, projection: Boolean(projectionModel) });
|
|
19
|
-
const acquireRound =
|
|
19
|
+
const acquireRound = roundAcquirer(residency, { model, key, loadOpts, signal });
|
|
20
|
+
const remoteRoots = driveOp && grantedDrives?.length ? createRemoteRoots(grantedDrives, driveOp) : [];
|
|
21
|
+
return {
|
|
22
|
+
key,
|
|
23
|
+
args: {
|
|
24
|
+
acquireRound,
|
|
25
|
+
ctxSize: await resolveCtxSize(() => residency.loadLifecycleSdk(), model, {
|
|
26
|
+
opts: loadOpts,
|
|
27
|
+
deviceConfig: residency.deviceConfig()
|
|
28
|
+
}),
|
|
29
|
+
messages: projectionModel ? messages : messages.map(({ attachments, ...turn }) => turn),
|
|
30
|
+
requestMessages: messages,
|
|
31
|
+
tools: withRunTools(residency.tools(), request.tools ?? []),
|
|
32
|
+
skillCatalog: await residency.skills(agent?.id ?? null, model),
|
|
33
|
+
fsRoots: [
|
|
34
|
+
...(grantedDirs?.length ? await createLocalRoots(grantedDirs) : []),
|
|
35
|
+
...remoteRoots
|
|
36
|
+
],
|
|
37
|
+
fsWriteRoots: [
|
|
38
|
+
...(request.grantedWriteDirs?.length
|
|
39
|
+
? await createLocalRoots(request.grantedWriteDirs)
|
|
40
|
+
: []),
|
|
41
|
+
...remoteRoots.filter((root) => root.writable)
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export function roundAcquirer(residency, { model, key, loadOpts, signal }) {
|
|
47
|
+
return async (invocationSignal) => {
|
|
20
48
|
const pool = residency.pool;
|
|
21
49
|
const lease = await residency.acquireLease({
|
|
22
50
|
pool,
|
|
@@ -56,31 +84,6 @@ export async function prepareCompletionRuntime(residency, request) {
|
|
|
56
84
|
throw error;
|
|
57
85
|
}
|
|
58
86
|
};
|
|
59
|
-
const remoteRoots = driveOp && grantedDrives?.length ? createRemoteRoots(grantedDrives, driveOp) : [];
|
|
60
|
-
return {
|
|
61
|
-
key,
|
|
62
|
-
args: {
|
|
63
|
-
acquireRound,
|
|
64
|
-
ctxSize: await resolveCtxSize(() => residency.loadLifecycleSdk(), model, {
|
|
65
|
-
opts: loadOpts,
|
|
66
|
-
deviceConfig: residency.deviceConfig()
|
|
67
|
-
}),
|
|
68
|
-
messages: projectionModel ? messages : messages.map(({ attachments, ...turn }) => turn),
|
|
69
|
-
requestMessages: messages,
|
|
70
|
-
tools: withRunTools(residency.tools(), request.tools ?? []),
|
|
71
|
-
skillCatalog: await residency.skills(agent?.id ?? null, model),
|
|
72
|
-
fsRoots: [
|
|
73
|
-
...(grantedDirs?.length ? await createLocalRoots(grantedDirs) : []),
|
|
74
|
-
...remoteRoots
|
|
75
|
-
],
|
|
76
|
-
fsWriteRoots: [
|
|
77
|
-
...(request.grantedWriteDirs?.length
|
|
78
|
-
? await createLocalRoots(request.grantedWriteDirs)
|
|
79
|
-
: []),
|
|
80
|
-
...remoteRoots.filter((root) => root.writable)
|
|
81
|
-
]
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
87
|
}
|
|
85
88
|
function withRunTools(builtIn, own) {
|
|
86
89
|
const names = new Set(own.map((tool) => tool.name));
|
|
@@ -180,6 +180,10 @@ export declare class Residency {
|
|
|
180
180
|
loadOptions(model: string, agent?: LoadOptionKnobs): ModelLoadOptions;
|
|
181
181
|
acquireLease({ pool, key, open, signal, prepare, onLoad }: ModelLeaseOptions): Promise<ModelLease | null>;
|
|
182
182
|
completionRuntime(request: CompletionRuntimeRequest): Promise<import("./completion-runtime.ts").PreparedRuntime>;
|
|
183
|
+
servedRound(model: string): {
|
|
184
|
+
key: string;
|
|
185
|
+
acquireRound: (invocationSignal?: BareAbortSignal) => Promise<import("../contract/completion.ts").RoundModelLease>;
|
|
186
|
+
};
|
|
183
187
|
makeRoomForCompletion(model: string, { loadOpts, signal, deadlineMs }: RoomOptions): Promise<boolean>;
|
|
184
188
|
evictWedged(model: string, key: string): Promise<WedgedEviction>;
|
|
185
189
|
private _evictAfterLeases;
|
|
@@ -13,7 +13,7 @@ import { ModelFit } from '../models/model-fit.js';
|
|
|
13
13
|
import { createModelStatusCache, invalidateModelStatusCache } from '../models/model-list.js';
|
|
14
14
|
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';
|
|
15
15
|
import { openclCacheDir } from '../models/opencl-cache.js';
|
|
16
|
-
import { prepareCompletionRuntime } from './completion-runtime.js';
|
|
16
|
+
import { prepareCompletionRuntime, roundAcquirer } from './completion-runtime.js';
|
|
17
17
|
const PLUGIN_EVICT_WAIT_MS = 15_000;
|
|
18
18
|
const WEDGED_EVICT_WAIT_MS = 10_000;
|
|
19
19
|
const MODEL_ROOM_WAIT_MS = 300_000;
|
|
@@ -822,6 +822,11 @@ export class Residency {
|
|
|
822
822
|
releaseWork();
|
|
823
823
|
}
|
|
824
824
|
}
|
|
825
|
+
servedRound(model) {
|
|
826
|
+
const loadOpts = this.loadOptions(model);
|
|
827
|
+
const key = modelKey(model, loadOpts);
|
|
828
|
+
return { key, acquireRound: roundAcquirer(this, { model, key, loadOpts }) };
|
|
829
|
+
}
|
|
825
830
|
async makeRoomForCompletion(model, { loadOpts, signal, deadlineMs = MODEL_ROOM_WAIT_MS }) {
|
|
826
831
|
if (this._capBytes !== null) {
|
|
827
832
|
await evictIdleWhere(this._models, this._replacedBy(model));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ModelRoundPort } from './capabilities/completion-engine/index.ts';
|
|
2
|
+
export declare class RoundHost {
|
|
3
|
+
private readonly _port;
|
|
4
|
+
private readonly _out;
|
|
5
|
+
private readonly _rounds;
|
|
6
|
+
constructor(port: ModelRoundPort, send: (frame: object) => void);
|
|
7
|
+
ask(callId: string, payload: unknown): void;
|
|
8
|
+
cancel(callId: string): void;
|
|
9
|
+
close(): void;
|
|
10
|
+
private _settle;
|
|
11
|
+
private _drain;
|
|
12
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { AbortController } from 'bare-abort-controller';
|
|
2
|
+
import { pushQueue } from './queue.js';
|
|
3
|
+
import { roundFailureWire, roundRequestFrom } from './wire.js';
|
|
4
|
+
export class RoundHost {
|
|
5
|
+
_port;
|
|
6
|
+
_out = pushQueue();
|
|
7
|
+
_rounds = new Map();
|
|
8
|
+
constructor(port, send) {
|
|
9
|
+
this._port = port;
|
|
10
|
+
void this._drain(send);
|
|
11
|
+
}
|
|
12
|
+
ask(callId, payload) {
|
|
13
|
+
const controller = new AbortController();
|
|
14
|
+
this._rounds.set(callId, controller);
|
|
15
|
+
let taker = 0;
|
|
16
|
+
const emitter = (generation) => (event) => {
|
|
17
|
+
if (generation !== taker || !this._rounds.has(callId))
|
|
18
|
+
return;
|
|
19
|
+
void this._out.push({ type: 'model-round-chunk', callId, payload: event });
|
|
20
|
+
};
|
|
21
|
+
const retake = () => {
|
|
22
|
+
if (!this._rounds.has(callId))
|
|
23
|
+
return noop;
|
|
24
|
+
void this._out.push({ type: 'model-round-retake', callId });
|
|
25
|
+
return emitter(++taker);
|
|
26
|
+
};
|
|
27
|
+
void Promise.resolve()
|
|
28
|
+
.then(() => this._port(roundRequestFrom(payload), {
|
|
29
|
+
signal: controller.signal,
|
|
30
|
+
emit: emitter(0),
|
|
31
|
+
retake
|
|
32
|
+
}))
|
|
33
|
+
.then((result) => this._settle(callId, { result }), (err) => this._settle(callId, roundFailureWire(err)));
|
|
34
|
+
}
|
|
35
|
+
cancel(callId) {
|
|
36
|
+
this._rounds.get(callId)?.abort(undefined);
|
|
37
|
+
this._rounds.delete(callId);
|
|
38
|
+
}
|
|
39
|
+
close() {
|
|
40
|
+
for (const callId of [...this._rounds.keys()]) {
|
|
41
|
+
this.cancel(callId);
|
|
42
|
+
}
|
|
43
|
+
this._out.end();
|
|
44
|
+
}
|
|
45
|
+
_settle(callId, frame) {
|
|
46
|
+
if (this._rounds.delete(callId)) {
|
|
47
|
+
void this._out.push({ type: 'model-round-result', callId, ...frame });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async _drain(send) {
|
|
51
|
+
for await (const frame of this._out) {
|
|
52
|
+
send(frame);
|
|
53
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function noop() { }
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ModelRoundPort } from './capabilities/completion-engine/index.ts';
|
|
2
|
+
import { type WireEvent } from './wire.ts';
|
|
3
|
+
export interface RoundFrame {
|
|
4
|
+
type: string;
|
|
5
|
+
callId?: string | null;
|
|
6
|
+
message?: string | null;
|
|
7
|
+
result?: unknown;
|
|
8
|
+
payload?: unknown;
|
|
9
|
+
}
|
|
10
|
+
export declare class RoundPort {
|
|
11
|
+
private readonly _push;
|
|
12
|
+
private readonly _asked;
|
|
13
|
+
private _calls;
|
|
14
|
+
private _cut;
|
|
15
|
+
private _closed;
|
|
16
|
+
constructor(push: (event: WireEvent) => unknown);
|
|
17
|
+
port: ModelRoundPort;
|
|
18
|
+
roundCut: (cut: (note: string) => void) => void;
|
|
19
|
+
frame(frame: RoundFrame): boolean;
|
|
20
|
+
close(): void;
|
|
21
|
+
private _retake;
|
|
22
|
+
private _settle;
|
|
23
|
+
private _take;
|
|
24
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { HarnessError } from './errors.js';
|
|
2
|
+
import { AbortedError } from './helpers/engine-error.js';
|
|
3
|
+
import { roundChunkFrom, roundResultFrom } from './wire.js';
|
|
4
|
+
export class RoundPort {
|
|
5
|
+
_push;
|
|
6
|
+
_asked = new Map();
|
|
7
|
+
_calls = 0;
|
|
8
|
+
_cut = null;
|
|
9
|
+
_closed = false;
|
|
10
|
+
constructor(push) {
|
|
11
|
+
this._push = push;
|
|
12
|
+
}
|
|
13
|
+
port = (request, io) => {
|
|
14
|
+
if (this._closed) {
|
|
15
|
+
return Promise.reject(new HarnessError('CLIENT_GONE'));
|
|
16
|
+
}
|
|
17
|
+
if (io.signal.aborted) {
|
|
18
|
+
return Promise.reject(new AbortedError());
|
|
19
|
+
}
|
|
20
|
+
const callId = String(this._calls++);
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
const cancel = () => {
|
|
23
|
+
if (!this._take(callId))
|
|
24
|
+
return;
|
|
25
|
+
this._push({ type: 'model-round-cancel', callId });
|
|
26
|
+
reject(new AbortedError());
|
|
27
|
+
};
|
|
28
|
+
this._asked.set(callId, { io, emit: io.emit, cancel, resolve, reject });
|
|
29
|
+
io.signal.addEventListener('abort', cancel, { once: true });
|
|
30
|
+
this._push({ type: 'model-round-ask', callId, payload: request });
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
roundCut = (cut) => {
|
|
34
|
+
this._cut = cut;
|
|
35
|
+
};
|
|
36
|
+
frame(frame) {
|
|
37
|
+
switch (frame.type) {
|
|
38
|
+
case 'model-round-chunk':
|
|
39
|
+
this._asked.get(frame.callId ?? '')?.emit(roundChunkFrom(frame.payload));
|
|
40
|
+
return true;
|
|
41
|
+
case 'model-round-retake':
|
|
42
|
+
this._retake(frame.callId ?? '');
|
|
43
|
+
return true;
|
|
44
|
+
case 'model-round-result':
|
|
45
|
+
this._settle(frame);
|
|
46
|
+
return true;
|
|
47
|
+
case 'round-cut':
|
|
48
|
+
this._cut?.(frame.message ?? '');
|
|
49
|
+
return true;
|
|
50
|
+
default:
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
close() {
|
|
55
|
+
this._closed = true;
|
|
56
|
+
for (const callId of [...this._asked.keys()]) {
|
|
57
|
+
this._take(callId)?.reject(new HarnessError('CLIENT_GONE'));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
_retake(callId) {
|
|
61
|
+
const asked = this._asked.get(callId);
|
|
62
|
+
if (asked) {
|
|
63
|
+
asked.emit = asked.io.retake();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
_settle(frame) {
|
|
67
|
+
const asked = this._take(frame.callId ?? '');
|
|
68
|
+
try {
|
|
69
|
+
asked?.resolve(roundResultFrom(frame));
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
asked?.reject(err);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
_take(callId) {
|
|
76
|
+
const asked = this._asked.get(callId);
|
|
77
|
+
this._asked.delete(callId);
|
|
78
|
+
asked?.io.signal.removeEventListener('abort', asked.cancel);
|
|
79
|
+
return asked;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AddonLoaders } from './contract/index.ts';
|
|
2
2
|
type Sdk = typeof import('#sdk');
|
|
3
|
-
export type SdkPlugin = Parameters<(typeof import('@qvac/
|
|
3
|
+
export type SdkPlugin = Parameters<(typeof import('@qvac/inference/plugin-registry'))['registerPlugin']>[0];
|
|
4
4
|
type Plugin = SdkPlugin;
|
|
5
5
|
interface PluginRegistry {
|
|
6
6
|
registerPlugin(plugin: Plugin): void;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { errorMessage } from './guards.js';
|
|
2
|
+
import { missingPeers, requirePeers } from './helpers/require-peers.js';
|
|
2
3
|
import { retryMemo } from './helpers/retry-memo.js';
|
|
3
4
|
import { HarnessLog } from './log.js';
|
|
4
5
|
const defaultImports = {
|
|
5
6
|
sdk: () => import('#sdk'),
|
|
6
|
-
plugins: () => import('@qvac/
|
|
7
|
-
llm: () => import('@qvac/
|
|
8
|
-
embeddings: () => import('@qvac/
|
|
7
|
+
plugins: () => import('@qvac/inference/plugin-registry'),
|
|
8
|
+
llm: () => import('@qvac/inference/llamacpp-completion/plugin'),
|
|
9
|
+
embeddings: () => import('@qvac/inference/llamacpp-embedding/plugin')
|
|
9
10
|
};
|
|
10
11
|
function register(registry, name, plugin) {
|
|
11
12
|
try {
|
|
@@ -19,8 +20,19 @@ function register(registry, name, plugin) {
|
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
const IN_PROCESS = typeof globalThis.Bare !== 'undefined';
|
|
23
|
+
const COMPLETION_PEERS = IN_PROCESS
|
|
24
|
+
? {
|
|
25
|
+
'@qvac/llm-llamacpp': () => import.meta.resolve('@qvac/llm-llamacpp/addonLogging'),
|
|
26
|
+
'@qvac/langdetect-text': () => import.meta.resolve('@qvac/langdetect-text')
|
|
27
|
+
}
|
|
28
|
+
: { '@qvac/sdk': () => import.meta.resolve('#sdk') };
|
|
29
|
+
const EMBEDDING_PEERS = {
|
|
30
|
+
'@qvac/embed-llamacpp': () => import.meta.resolve('@qvac/embed-llamacpp/addonLogging')
|
|
31
|
+
};
|
|
32
|
+
const requireCompletion = () => requirePeers('@qvac/harness completion', COMPLETION_PEERS);
|
|
22
33
|
export function createSdkLoader(imports = defaultImports) {
|
|
23
34
|
const load = retryMemo(async () => {
|
|
35
|
+
requireCompletion();
|
|
24
36
|
if (!IN_PROCESS) {
|
|
25
37
|
return imports.sdk();
|
|
26
38
|
}
|
|
@@ -34,6 +46,7 @@ export function createSdkLoader(imports = defaultImports) {
|
|
|
34
46
|
});
|
|
35
47
|
const loadEmbed = IN_PROCESS
|
|
36
48
|
? retryMemo(async () => {
|
|
49
|
+
requirePeers('@qvac/harness embeddings', EMBEDDING_PEERS);
|
|
37
50
|
const [sdk, { embeddingsPlugin }, registry] = await Promise.all([
|
|
38
51
|
load(),
|
|
39
52
|
imports.embeddings(),
|
|
@@ -43,11 +56,22 @@ export function createSdkLoader(imports = defaultImports) {
|
|
|
43
56
|
return sdk;
|
|
44
57
|
})
|
|
45
58
|
: load;
|
|
46
|
-
|
|
59
|
+
return { load, loadEmbed, peek: () => load.peek(), addons: addonLoaders(load, loadEmbed) };
|
|
60
|
+
}
|
|
61
|
+
function addonLoaders(load, loadEmbed) {
|
|
62
|
+
const completion = {
|
|
47
63
|
sdk: load,
|
|
64
|
+
'llm-llamacpp': () => {
|
|
65
|
+
requireCompletion();
|
|
66
|
+
return import('@qvac/llm-llamacpp/addonLogging');
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
if (missingPeers(EMBEDDING_PEERS).length > 0) {
|
|
70
|
+
return completion;
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
...completion,
|
|
48
74
|
embeddings: loadEmbed,
|
|
49
|
-
'llm-llamacpp': () => import('@qvac/llm-llamacpp/addonLogging'),
|
|
50
75
|
'embed-llamacpp': () => import('@qvac/embed-llamacpp/addonLogging')
|
|
51
76
|
};
|
|
52
|
-
return { load, loadEmbed, peek: () => load.peek(), addons };
|
|
53
77
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type SdkStorage } from './storage.ts';
|
|
2
2
|
export declare const SDK_CONFIG_PATH_ENV = "QVAC_CONFIG_PATH";
|
|
3
3
|
export declare const OPENCL_CACHE_DIR_ENV = "QVAC_OPENCL_CACHE_DIR";
|
|
4
|
+
export declare const SDK_OPTIONS_ENV = "QVAC_SDK_OPTIONS";
|
|
4
5
|
export interface SdkStorageChannels {
|
|
5
6
|
readonly env?: Record<string, string | undefined>;
|
|
6
7
|
readonly argv?: Array<string> | null;
|