@qvac/core 0.6.6 → 0.7.0
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 +185 -1
- package/README.md +2 -0
- package/dist-lib/lib/api/app-config.d.ts +3 -1
- package/dist-lib/lib/api/app-config.js +15 -4
- package/dist-lib/lib/assistant/fake-models.d.ts +22 -0
- package/dist-lib/lib/assistant/fake-models.js +112 -0
- package/dist-lib/lib/assistant/harness.d.ts +10 -0
- package/dist-lib/lib/assistant/harness.js +26 -0
- package/dist-lib/lib/assistant/history.d.ts +5 -1
- package/dist-lib/lib/assistant/history.js +14 -2
- package/dist-lib/lib/assistant-tree.d.ts +4 -0
- package/dist-lib/lib/assistant-tree.js +45 -7
- package/dist-lib/lib/assistant.d.ts +16 -2
- package/dist-lib/lib/assistant.js +184 -44
- package/dist-lib/lib/constants.d.ts +6 -0
- package/dist-lib/lib/constants.js +6 -0
- package/dist-lib/lib/core/chat-activity.d.ts +1 -1
- package/dist-lib/lib/core/chat-activity.js +3 -0
- package/dist-lib/lib/core/collections.d.ts +1 -0
- package/dist-lib/lib/core/collections.js +1 -0
- package/dist-lib/lib/core/contract/compute.d.ts +1 -1
- package/dist-lib/lib/core/contract/compute.js +2 -1
- package/dist-lib/lib/core/contract/index.js +6 -1
- package/dist-lib/lib/core/contract/invites.d.ts +1 -11
- package/dist-lib/lib/core/contract/invites.js +3 -3
- package/dist-lib/lib/core/contract/mesh-seeds.d.ts +2 -0
- package/dist-lib/lib/core/contract/mesh-seeds.js +26 -0
- package/dist-lib/lib/core/contract/open-join.d.ts +2 -0
- package/dist-lib/lib/core/contract/open-join.js +57 -0
- package/dist-lib/lib/core/departures.d.ts +3 -0
- package/dist-lib/lib/core/departures.js +44 -1
- package/dist-lib/lib/core/fs-drives.js +9 -6
- package/dist-lib/lib/core/handoff-channel.d.ts +1 -0
- package/dist-lib/lib/core/handoff-channel.js +7 -2
- package/dist-lib/lib/core/harness-loan.d.ts +1 -0
- package/dist-lib/lib/core/harness-loan.js +7 -2
- package/dist-lib/lib/core/identity.d.ts +1 -1
- package/dist-lib/lib/core/identity.js +6 -4
- package/dist-lib/lib/core/invite.d.ts +2 -0
- package/dist-lib/lib/core/invite.js +6 -2
- package/dist-lib/lib/core/membership.d.ts +1 -12
- package/dist-lib/lib/core/membership.js +1 -94
- package/dist-lib/lib/core/mesh.d.ts +8 -13
- package/dist-lib/lib/core/mesh.js +41 -87
- package/dist-lib/lib/core/protocol-pairing.d.ts +11 -0
- package/dist-lib/lib/core/protocol-pairing.js +22 -0
- package/dist-lib/lib/core/sync/index.js +2 -16
- package/dist-lib/lib/core.d.ts +43 -49
- package/dist-lib/lib/core.js +451 -909
- package/dist-lib/lib/diagnostics.d.ts +7 -0
- package/dist-lib/lib/diagnostics.js +22 -0
- package/dist-lib/lib/doctor/checks.d.ts +15 -0
- package/dist-lib/lib/doctor/checks.js +269 -0
- package/dist-lib/lib/doctor/redact.d.ts +4 -0
- package/dist-lib/lib/doctor/redact.js +31 -0
- package/dist-lib/lib/doctor/render.d.ts +8 -0
- package/dist-lib/lib/doctor/render.js +83 -0
- package/dist-lib/lib/doctor/tree.d.ts +5 -0
- package/dist-lib/lib/doctor/tree.js +167 -0
- package/dist-lib/lib/downloads-allowed-pusher.d.ts +10 -0
- package/dist-lib/lib/downloads-allowed-pusher.js +37 -0
- package/dist-lib/lib/guards.d.ts +1 -0
- package/dist-lib/lib/guards.js +4 -0
- package/dist-lib/lib/inference-calls.js +1 -5
- package/dist-lib/lib/kv-cache-reclaim.d.ts +2 -1
- package/dist-lib/lib/kv-cache-reclaim.js +24 -0
- package/dist-lib/lib/mesh-scoped-engine.js +1 -0
- package/dist-lib/lib/model-download-status.d.ts +1 -1
- package/dist-lib/lib/model-download.d.ts +9 -1
- package/dist-lib/lib/model-download.js +48 -3
- package/dist-lib/lib/model-memory-cap.d.ts +29 -0
- package/dist-lib/lib/model-memory-cap.js +69 -0
- package/dist-lib/lib/models-watch.d.ts +1 -1
- package/dist-lib/lib/models-watch.js +4 -4
- package/dist-lib/lib/oauth/flow.js +1 -1
- package/dist-lib/lib/oauth/loopback.js +16 -2
- package/dist-lib/lib/oauth/redirect-types.d.ts +1 -0
- package/dist-lib/lib/run-replay.d.ts +26 -0
- package/dist-lib/lib/run-replay.js +107 -0
- package/dist-lib/schema/config.d.ts +1 -1
- package/dist-lib/schema/config.js +1 -1
- package/dist-lib/schema/content.js +9 -1
- package/dist-lib/schema/engine.js +30 -5
- package/dist-lib/schema/local.js +3 -2
- package/dist-lib/schema/qvac.js +18 -1
- package/dist-lib/spec/bind.js +3 -0
- package/dist-lib/spec/calls.js +1 -0
- package/dist-lib/spec/capabilities.d.ts +2 -0
- package/dist-lib/spec/config/hyperconf/index.js +1 -1
- package/dist-lib/spec/hrpc/hrpc.json +13 -0
- package/dist-lib/spec/hrpc/index.js +15 -3
- package/dist-lib/spec/hrpc/messages.js +646 -557
- package/dist-lib/spec/hyperschema/index.js +646 -557
- package/dist-lib/spec/hyperschema/schema.json +80 -0
- package/dist-lib/spec/hyperschema/types.d.ts +20 -3
- package/dist-lib/spec/local/hyperdb/messages.js +22 -10
- package/dist-lib/spec/local/hyperschema/index.js +16 -7
- package/dist-lib/spec/local/hyperschema/schema.json +10 -1
- package/dist-lib/spec/local/hyperschema/types.d.ts +3 -2
- package/dist-lib/spec/mesh/hyperdb/db.json +16 -1
- package/dist-lib/spec/mesh/hyperdb/index.js +71 -2
- package/dist-lib/spec/mesh/hyperdb/messages.js +477 -240
- package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +13 -1
- package/dist-lib/spec/mesh/hyperdispatch/index.js +35 -1
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +180 -7
- package/dist-lib/spec/mesh/hyperschema/index.js +180 -7
- package/dist-lib/spec/mesh/hyperschema/schema.json +98 -1
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +26 -2
- package/package.json +9 -17
- package/tui/README.md +7 -1
- package/tui/app.mjs +245 -11
- package/tui/boot.mjs +1 -0
- package/tui/index.mjs +1 -0
- package/tui/lib/render.mjs +25 -1
- package/worker/assistant-sidecar.mjs +5 -2
- package/dist-lib/lib/core/device-invites.d.ts +0 -11
- package/dist-lib/lib/core/device-invites.js +0 -63
- package/dist-lib/lib/core/grant-expiry.d.ts +0 -11
- package/dist-lib/lib/core/grant-expiry.js +0 -66
- package/dist-lib/lib/core/mesh-seed-handoff.d.ts +0 -27
- package/dist-lib/lib/core/mesh-seed-handoff.js +0 -53
- package/dist-lib/lib/oauth/loopback.stub.d.ts +0 -3
- package/dist-lib/lib/oauth/loopback.stub.js +0 -6
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import Supervisor, {} from 'bare-supervisor';
|
|
2
2
|
import { harnessClearKvCache, harnessListModels, harnessPreviewModelSource, harnessSkillCatalog, harnessSkillManagement, harnessDetectLanguage, harnessSpeak, harnessSpeakStream, harnessTools, harnessTranscribe, QvacAssistant } from './assistant.js';
|
|
3
3
|
import { Client } from './client.js';
|
|
4
|
+
import { readFakeModels, watchFakeModels, withFakeModels } from './assistant/fake-models.js';
|
|
4
5
|
import { startCustomModelPusher } from './custom-model-pusher.js';
|
|
5
6
|
import { startModelIdlePusher } from './model-idle-pusher.js';
|
|
7
|
+
import { startModelMemoryCap } from './model-memory-cap.js';
|
|
8
|
+
import { startDownloadsAllowedPusher } from './downloads-allowed-pusher.js';
|
|
6
9
|
import { serveHarness } from '@qvac/harness';
|
|
7
10
|
import { duplexPair } from '@qvac/harness/transport';
|
|
8
11
|
export function assistantTree(opts) {
|
|
9
|
-
const { core, harness, logger = null, imageCacheDir, inferenceCallsDir, imageCacheMaxBytes, imageCacheMaxAgeMs, embedder, extractors, onHarness, platform, preloadCurrentAgentModel } = opts;
|
|
12
|
+
const { core, harness, logger = null, imageCacheDir, inferenceCallsDir, runReplayDir, imageCacheMaxBytes, imageCacheMaxAgeMs, embedder, extractors, onHarness, platform, preloadCurrentAgentModel, fakeModels = false } = opts;
|
|
10
13
|
const sup = new Supervisor();
|
|
11
14
|
const logged = ['child-died', 'child-restarting', 'child-ready', 'gave-up', 'stall'];
|
|
12
15
|
for (const event of logged) {
|
|
@@ -37,6 +40,10 @@ export function assistantTree(opts) {
|
|
|
37
40
|
let offModelCatalogWatch = null;
|
|
38
41
|
let offCustomModels = null;
|
|
39
42
|
let offModelIdle = null;
|
|
43
|
+
let modelMemoryCap = null;
|
|
44
|
+
let offModelMemory = null;
|
|
45
|
+
let offDownloadsAllowed = null;
|
|
46
|
+
let offFakeModels = null;
|
|
40
47
|
let offLoanableHarness = null;
|
|
41
48
|
sup.add('engine', {
|
|
42
49
|
start: async () => {
|
|
@@ -60,13 +67,16 @@ export function assistantTree(opts) {
|
|
|
60
67
|
}
|
|
61
68
|
sup.add('assistant', {
|
|
62
69
|
deps: ['engine', 'harness'],
|
|
63
|
-
start: (ctx) => {
|
|
64
|
-
|
|
70
|
+
start: async (ctx) => {
|
|
71
|
+
let fakeModelsOn = fakeModels || (await readFakeModels(core.local));
|
|
72
|
+
const supervised = ctx.get('harness');
|
|
73
|
+
const harness = withFakeModels(supervised, { enabled: () => fakeModelsOn });
|
|
65
74
|
const engine = ctx.get('engine');
|
|
66
75
|
const assistant = new QvacAssistant(engine, harness, {
|
|
67
76
|
logger,
|
|
68
77
|
imageCacheDir,
|
|
69
78
|
inferenceCallsDir,
|
|
79
|
+
runReplayDir,
|
|
70
80
|
imageCacheMaxBytes,
|
|
71
81
|
imageCacheMaxAgeMs,
|
|
72
82
|
platform,
|
|
@@ -81,7 +91,7 @@ export function assistantTree(opts) {
|
|
|
81
91
|
});
|
|
82
92
|
offListModels = core.registerListModels(harnessListModels(harness));
|
|
83
93
|
offDeleteModel = core.registerDeleteModel(({ name }) => assistant.deleteModel(name));
|
|
84
|
-
offClearKvCache = core.registerClearKvCache(
|
|
94
|
+
offClearKvCache = core.registerClearKvCache(() => assistant.clearKvCache());
|
|
85
95
|
offDeleteChatKvCache = core.registerDeleteChatKvCache((chatId) => assistant.deleteChatKvCache(chatId));
|
|
86
96
|
offCompactChat = core.registerCompactChat((chatId, meshId) => assistant.compactChat(chatId, { meshId }));
|
|
87
97
|
offModelCatalogWatch = core.registerModelCatalogWatch(() => assistant.modelCatalogWatch());
|
|
@@ -90,6 +100,24 @@ export function assistantTree(opts) {
|
|
|
90
100
|
onPushed: () => assistant.notifyModelCatalog()
|
|
91
101
|
});
|
|
92
102
|
offModelIdle = startModelIdlePusher(harness, core.local, logger);
|
|
103
|
+
modelMemoryCap = assistant.mobileClass
|
|
104
|
+
? null
|
|
105
|
+
: startModelMemoryCap(harness, core.local, {
|
|
106
|
+
logger,
|
|
107
|
+
onPushed: () => assistant.notifyModelCatalog()
|
|
108
|
+
});
|
|
109
|
+
offModelMemory = core.registerModelMemory(async () => (await modelMemoryCap?.summary()) ?? null);
|
|
110
|
+
offDownloadsAllowed = startDownloadsAllowedPusher(harness, core.local, logger);
|
|
111
|
+
offFakeModels = fakeModels
|
|
112
|
+
? null
|
|
113
|
+
: watchFakeModels(core.local, {
|
|
114
|
+
initial: fakeModelsOn,
|
|
115
|
+
onChange: (enabled) => {
|
|
116
|
+
fakeModelsOn = enabled;
|
|
117
|
+
assistant.cachedModelsChanged();
|
|
118
|
+
},
|
|
119
|
+
logger
|
|
120
|
+
});
|
|
93
121
|
offLoanableHarness = core.registerLoanableHarness((stream) => serveHarness(stream, harness));
|
|
94
122
|
offRetryModelDownload = core.registerRetryModelDownload((name) => assistant.retryModelDownload(name));
|
|
95
123
|
offModelResidency = core.registerModelResidency({
|
|
@@ -132,7 +160,7 @@ export function assistantTree(opts) {
|
|
|
132
160
|
};
|
|
133
161
|
offEmbedder = core.registerEmbedder(wrapped, extractors);
|
|
134
162
|
}
|
|
135
|
-
const off = onHarness?.(
|
|
163
|
+
const off = onHarness?.(supervised, { engine });
|
|
136
164
|
if (typeof off === 'function') {
|
|
137
165
|
offHarness = off;
|
|
138
166
|
}
|
|
@@ -159,6 +187,14 @@ export function assistantTree(opts) {
|
|
|
159
187
|
offCustomModels = null;
|
|
160
188
|
await offModelIdle?.();
|
|
161
189
|
offModelIdle = null;
|
|
190
|
+
offModelMemory?.();
|
|
191
|
+
offModelMemory = null;
|
|
192
|
+
await modelMemoryCap?.stop();
|
|
193
|
+
modelMemoryCap = null;
|
|
194
|
+
await offDownloadsAllowed?.();
|
|
195
|
+
offDownloadsAllowed = null;
|
|
196
|
+
await offFakeModels?.();
|
|
197
|
+
offFakeModels = null;
|
|
162
198
|
offLoanableHarness?.();
|
|
163
199
|
offLoanableHarness = null;
|
|
164
200
|
offRetryModelDownload?.();
|
|
@@ -199,7 +235,7 @@ export function assistantTree(opts) {
|
|
|
199
235
|
return sup;
|
|
200
236
|
}
|
|
201
237
|
export function assistantChild(opts) {
|
|
202
|
-
const { harness, core = 'core', logger = null, imageCacheDir, inferenceCallsDir, imageCacheMaxBytes, imageCacheMaxAgeMs, embedder, extractors, onHarness, preloadCurrentAgentModel, ...spec } = opts;
|
|
238
|
+
const { harness, core = 'core', logger = null, imageCacheDir, inferenceCallsDir, runReplayDir, imageCacheMaxBytes, imageCacheMaxAgeMs, embedder, extractors, onHarness, preloadCurrentAgentModel, fakeModels, ...spec } = opts;
|
|
203
239
|
return {
|
|
204
240
|
...spec,
|
|
205
241
|
deps: [core],
|
|
@@ -210,12 +246,14 @@ export function assistantChild(opts) {
|
|
|
210
246
|
logger,
|
|
211
247
|
imageCacheDir,
|
|
212
248
|
inferenceCallsDir,
|
|
249
|
+
runReplayDir,
|
|
213
250
|
imageCacheMaxBytes,
|
|
214
251
|
imageCacheMaxAgeMs,
|
|
215
252
|
embedder,
|
|
216
253
|
extractors,
|
|
217
254
|
onHarness,
|
|
218
|
-
preloadCurrentAgentModel
|
|
255
|
+
preloadCurrentAgentModel,
|
|
256
|
+
fakeModels
|
|
219
257
|
});
|
|
220
258
|
tree.on('gave-up', ({ error }) => ctx.onDeath(error));
|
|
221
259
|
return tree;
|
|
@@ -22,6 +22,7 @@ export interface AssistantOptions {
|
|
|
22
22
|
logger?: Logger | null;
|
|
23
23
|
imageCacheDir?: string;
|
|
24
24
|
inferenceCallsDir?: string;
|
|
25
|
+
runReplayDir?: string;
|
|
25
26
|
imageCacheMaxBytes?: number;
|
|
26
27
|
imageCacheMaxAgeMs?: number;
|
|
27
28
|
downloadRetryMs?: number;
|
|
@@ -61,6 +62,7 @@ export declare class QvacAssistant extends ReadyResource {
|
|
|
61
62
|
private readonly _lastCapabilities;
|
|
62
63
|
private _sharedMeshes;
|
|
63
64
|
private readonly _hostedIn;
|
|
65
|
+
private _accountHosted;
|
|
64
66
|
private _readySkills;
|
|
65
67
|
private _recordingReadiness;
|
|
66
68
|
private _readinessDirty;
|
|
@@ -73,6 +75,7 @@ export declare class QvacAssistant extends ReadyResource {
|
|
|
73
75
|
private _harnessDiagnostics;
|
|
74
76
|
private _harnessDeath;
|
|
75
77
|
private _refreshingDiagnostics;
|
|
78
|
+
private readonly _backendUse;
|
|
76
79
|
private _meshList;
|
|
77
80
|
private _accountFrames;
|
|
78
81
|
private _accountMeshId;
|
|
@@ -83,6 +86,7 @@ export declare class QvacAssistant extends ReadyResource {
|
|
|
83
86
|
private readonly _runs;
|
|
84
87
|
private readonly _seen;
|
|
85
88
|
private readonly _inferenceCalls;
|
|
89
|
+
private readonly _runReplay;
|
|
86
90
|
private readonly _lifecycle;
|
|
87
91
|
private readonly _audioTranscripts;
|
|
88
92
|
private readonly _pdfPages;
|
|
@@ -93,7 +97,7 @@ export declare class QvacAssistant extends ReadyResource {
|
|
|
93
97
|
private readonly _modelCatalog;
|
|
94
98
|
private readonly _onHarnessStatus;
|
|
95
99
|
private readonly _onModelCatalogEvent;
|
|
96
|
-
constructor(engine: Capabilities, harness: Harness, { logger, imageCacheDir, inferenceCallsDir, imageCacheMaxBytes, imageCacheMaxAgeMs, downloadRetryMs, platform, preloadCurrentAgentModel, drives, borrowHarness, blobReadTimeoutMs, pdfRasterizer: pdfRasterizerOption }?: AssistantOptions);
|
|
100
|
+
constructor(engine: Capabilities, harness: Harness, { logger, imageCacheDir, inferenceCallsDir, runReplayDir, imageCacheMaxBytes, imageCacheMaxAgeMs, downloadRetryMs, platform, preloadCurrentAgentModel, drives, borrowHarness, blobReadTimeoutMs, pdfRasterizer: pdfRasterizerOption }?: AssistantOptions);
|
|
97
101
|
private _requireDeviceId;
|
|
98
102
|
_open(): Promise<void>;
|
|
99
103
|
private _triggerModelWarm;
|
|
@@ -121,6 +125,7 @@ export declare class QvacAssistant extends ReadyResource {
|
|
|
121
125
|
private _ensureCapability;
|
|
122
126
|
private _reconcileDeviceProfile;
|
|
123
127
|
_close(): Promise<void>;
|
|
128
|
+
get mobileClass(): boolean;
|
|
124
129
|
get suspended(): boolean;
|
|
125
130
|
presuspend(): Promise<void>;
|
|
126
131
|
suspend(): Promise<void>;
|
|
@@ -138,6 +143,7 @@ export declare class QvacAssistant extends ReadyResource {
|
|
|
138
143
|
private _meshModelUsers;
|
|
139
144
|
private _runnableHost;
|
|
140
145
|
notifyModelCatalog(): void;
|
|
146
|
+
cachedModelsChanged(): void;
|
|
141
147
|
retryModelDownload(name: string): Promise<void>;
|
|
142
148
|
skills(agentId?: string | null, modelName?: string | null, options?: SkillListOptions): Promise<ReadonlyArray<Skill>>;
|
|
143
149
|
private _recordSkillReadiness;
|
|
@@ -151,7 +157,13 @@ export declare class QvacAssistant extends ReadyResource {
|
|
|
151
157
|
private _reconcileCompaction;
|
|
152
158
|
private _senderNames;
|
|
153
159
|
private _reconcileAttribution;
|
|
154
|
-
deleteChatKvCache(chatId: string): Promise<AssistantKvCacheDeletionResponse>;
|
|
160
|
+
deleteChatKvCache(chatId: string, holder?: string): Promise<AssistantKvCacheDeletionResponse>;
|
|
161
|
+
clearKvCache(): Promise<AssistantKvCacheDeletionResponse>;
|
|
162
|
+
private _clearPreReplayCaches;
|
|
163
|
+
private _inspectCall;
|
|
164
|
+
private _inspectSent;
|
|
165
|
+
private _sentRuns;
|
|
166
|
+
private _recordSentRun;
|
|
155
167
|
private _deleteChatKvCache;
|
|
156
168
|
private _watchMeshList;
|
|
157
169
|
private _watchAccount;
|
|
@@ -164,6 +176,8 @@ export declare class QvacAssistant extends ReadyResource {
|
|
|
164
176
|
private _pruneSeen;
|
|
165
177
|
private _lenderFor;
|
|
166
178
|
private _harnessFor;
|
|
179
|
+
private _holderOf;
|
|
180
|
+
private _holderHarness;
|
|
167
181
|
private _dispatch;
|
|
168
182
|
private _citeWebSources;
|
|
169
183
|
private _searchKnowledge;
|