@qvac/core 0.2.2 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/lib/api/agents.js +2 -3
- package/dist-lib/lib/api/chat.d.ts +3 -1
- package/dist-lib/lib/api/chat.js +9 -5
- package/dist-lib/lib/api/chunks.d.ts +1 -1
- package/dist-lib/lib/api/chunks.js +5 -15
- package/dist-lib/lib/api/current-mesh.d.ts +16 -1
- package/dist-lib/lib/api/current-mesh.js +18 -0
- package/dist-lib/lib/api/devices.js +6 -3
- package/dist-lib/lib/api/index.d.ts +2 -0
- package/dist-lib/lib/api/index.js +4 -2
- package/dist-lib/lib/api/inference-calls.d.ts +18 -0
- package/dist-lib/lib/api/inference-calls.js +15 -0
- package/dist-lib/lib/api/knowledge.js +11 -7
- package/dist-lib/lib/api/members.js +2 -3
- package/dist-lib/lib/api/rag.js +10 -2
- package/dist-lib/lib/api/sync.d.ts +1 -1
- package/dist-lib/lib/api/sync.js +2 -1
- package/dist-lib/lib/api/tool-activity.js +2 -2
- package/dist-lib/lib/api/tool-configs.js +2 -2
- package/dist-lib/lib/api/watchable.d.ts +6 -1
- package/dist-lib/lib/api/watchable.js +13 -2
- package/dist-lib/lib/assistant/harness.d.ts +1 -0
- package/dist-lib/lib/assistant/history.d.ts +1 -2
- package/dist-lib/lib/assistant/history.js +0 -6
- package/dist-lib/lib/assistant-tree.d.ts +2 -0
- package/dist-lib/lib/assistant-tree.js +11 -2
- package/dist-lib/lib/assistant.d.ts +17 -8
- package/dist-lib/lib/assistant.js +172 -125
- package/dist-lib/lib/core/chunk.d.ts +1 -0
- package/dist-lib/lib/core/chunk.js +32 -0
- package/dist-lib/lib/core/contract/devices.js +3 -2
- package/dist-lib/lib/core/files/rag/build.d.ts +1 -2
- package/dist-lib/lib/core/files/rag/build.js +1 -2
- package/dist-lib/lib/core/files/rag/extract/office-collabora.d.ts +1 -1
- package/dist-lib/lib/core/files/rag/index.d.ts +4 -24
- package/dist-lib/lib/core/files/rag/index.js +3 -17
- package/dist-lib/lib/core/files/rag/load.d.ts +1 -2
- package/dist-lib/lib/core/files/rag/load.js +1 -2
- package/dist-lib/lib/core/files/rag/produce.d.ts +1 -1
- package/dist-lib/lib/core/files/rag/produce.js +1 -3
- package/dist-lib/lib/core/files/rag/retrieval/full-text.d.ts +1 -1
- package/dist-lib/lib/core/files/rag/retrieval/full-text.js +1 -4
- package/dist-lib/lib/core/files/rag/similarity.d.ts +5 -0
- package/dist-lib/lib/core/files/rag/similarity.js +6 -0
- package/dist-lib/lib/core/files/upload.d.ts +1 -1
- package/dist-lib/lib/core/harness-loan.js +1 -1
- package/dist-lib/lib/core/inference-calls-handoff.d.ts +20 -0
- package/dist-lib/lib/core/inference-calls-handoff.js +37 -0
- package/dist-lib/lib/core/inference-calls-receiver.d.ts +14 -0
- package/dist-lib/lib/core/inference-calls-receiver.js +39 -0
- package/dist-lib/lib/core/local/index.js +6 -0
- package/dist-lib/lib/core/notification.js +5 -4
- package/dist-lib/lib/core.d.ts +9 -1
- package/dist-lib/lib/core.js +98 -16
- package/dist-lib/lib/fs-drive-bridge.js +1 -1
- package/dist-lib/lib/inference-calls.d.ts +40 -0
- package/dist-lib/lib/inference-calls.js +266 -0
- package/dist-lib/lib/mesh-scoped-engine.js +5 -0
- package/dist-lib/lib/model-download.d.ts +2 -0
- package/dist-lib/lib/model-download.js +20 -5
- package/dist-lib/lib/oauth/keys.js +1 -0
- package/dist-lib/lib/oauth/spotify.js +1 -0
- package/dist-lib/lib/oauth/verify.d.ts +8 -0
- package/dist-lib/lib/oauth/verify.js +58 -0
- package/dist-lib/lib/oauth.d.ts +1 -0
- package/dist-lib/lib/oauth.js +1 -0
- package/dist-lib/schema/content.js +5 -1
- package/dist-lib/schema/engine.js +42 -1
- package/dist-lib/schema/qvac.d.ts +3 -0
- package/dist-lib/schema/qvac.js +11 -2
- 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/hrpc/hrpc.json +13 -0
- package/dist-lib/spec/hrpc/index.js +15 -3
- package/dist-lib/spec/hrpc/messages.js +172 -49
- package/dist-lib/spec/hyperschema/index.js +172 -49
- package/dist-lib/spec/hyperschema/schema.json +127 -1
- package/dist-lib/spec/hyperschema/types.d.ts +34 -1
- package/dist-lib/spec/local/hyperdb/messages.js +64 -128
- package/dist-lib/spec/local/hyperschema/index.js +32 -64
- package/dist-lib/spec/local/hyperschema/schema.json +16 -0
- package/dist-lib/spec/mesh/hyperdb/messages.js +176 -311
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +132 -236
- package/dist-lib/spec/mesh/hyperschema/index.js +132 -236
- package/dist-lib/spec/mesh/hyperschema/schema.json +70 -1
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +3 -1
- package/package.json +14 -17
- package/tui/app.mjs +327 -46
- package/tui/lib/knowledge-import.mjs +1 -1
- package/tui/lib/render.mjs +17 -1
- package/tui/lib/selection.mjs +16 -0
- package/tui/lib/usage.mjs +54 -0
- package/.claude/skills/asana/SKILL.md +0 -86
- package/.claude/skills/compaction/SKILL.md +0 -132
- package/.claude/skills/device-mesh-debug/SKILL.md +0 -328
- package/.claude/skills/gh-stack/SKILL.md +0 -181
- package/.claude/skills/gh-stack/references/commands.md +0 -177
- package/.claude/skills/gh-stack/references/stack-design.md +0 -97
- package/.claude/skills/gh-stack/references/troubleshooting.md +0 -159
- package/.claude/skills/js-house-style/SKILL.md +0 -670
- package/.claude/skills/pr-create/SKILL.md +0 -201
- package/.claude/skills/pr-review/SKILL.md +0 -424
- package/CLAUDE.md +0 -43
- package/dist-lib/lib/core/files/rag/artifact/codec.d.ts +0 -3
- package/dist-lib/lib/core/files/rag/artifact/codec.js +0 -172
- package/dist-lib/lib/core/files/rag/artifact/id.d.ts +0 -10
- package/dist-lib/lib/core/files/rag/artifact/id.js +0 -39
- package/dist-lib/lib/core/files/rag/artifact/types.d.ts +0 -24
- package/dist-lib/lib/core/files/rag/artifact/types.js +0 -41
- package/dist-lib/lib/core/files/rag/chunk/chunking.d.ts +0 -12
- package/dist-lib/lib/core/files/rag/chunk/chunking.js +0 -117
- package/dist-lib/lib/core/files/rag/chunk/metadata.d.ts +0 -30
- package/dist-lib/lib/core/files/rag/chunk/metadata.js +0 -89
- package/dist-lib/lib/core/files/rag/chunk/tokenizer.d.ts +0 -7
- package/dist-lib/lib/core/files/rag/chunk/tokenizer.js +0 -18
- package/dist-lib/lib/core/files/rag/extract/csv-text.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/extract/csv-text.js +0 -117
- package/dist-lib/lib/core/files/rag/extract/document-types.d.ts +0 -22
- package/dist-lib/lib/core/files/rag/extract/document-types.js +0 -152
- package/dist-lib/lib/core/files/rag/extract/extract.d.ts +0 -17
- package/dist-lib/lib/core/files/rag/extract/extract.js +0 -81
- package/dist-lib/lib/core/files/rag/extract/html-table-text.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/extract/html-table-text.js +0 -125
- package/dist-lib/lib/core/files/rag/extract/html-text.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/extract/html-text.js +0 -132
- package/dist-lib/lib/core/files/rag/extract/pdf-platform.d.ts +0 -17
- package/dist-lib/lib/core/files/rag/extract/pdf-platform.js +0 -141
- package/dist-lib/lib/core/files/rag/extract/pdf-text.d.ts +0 -12
- package/dist-lib/lib/core/files/rag/extract/pdf-text.js +0 -43
- package/dist-lib/lib/core/files/rag/extract/rtf-text.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/extract/rtf-text.js +0 -15
- package/dist-lib/lib/core/files/rag/extract/text-decoding.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/extract/text-decoding.js +0 -91
- package/dist-lib/lib/core/files/rag/extract/types.d.ts +0 -36
- package/dist-lib/lib/core/files/rag/extract/types.js +0 -12
- package/dist-lib/lib/core/files/rag/extract/utf.d.ts +0 -2
- package/dist-lib/lib/core/files/rag/extract/utf.js +0 -18
- package/dist-lib/lib/core/files/rag/retrieval/citation-match.d.ts +0 -2
- package/dist-lib/lib/core/files/rag/retrieval/citation-match.js +0 -16
- package/dist-lib/lib/core/files/rag/retrieval/coverage.d.ts +0 -4
- package/dist-lib/lib/core/files/rag/retrieval/coverage.js +0 -48
- package/dist-lib/lib/core/files/rag/retrieval/diversity.d.ts +0 -10
- package/dist-lib/lib/core/files/rag/retrieval/diversity.js +0 -37
- package/dist-lib/lib/core/files/rag/retrieval/floor.d.ts +0 -5
- package/dist-lib/lib/core/files/rag/retrieval/floor.js +0 -21
- package/dist-lib/lib/core/files/rag/retrieval/format.d.ts +0 -6
- package/dist-lib/lib/core/files/rag/retrieval/format.js +0 -21
- package/dist-lib/lib/core/files/rag/retrieval/knowledge.d.ts +0 -2
- package/dist-lib/lib/core/files/rag/retrieval/knowledge.js +0 -54
- package/dist-lib/lib/core/files/rag/retrieval/notices.d.ts +0 -16
- package/dist-lib/lib/core/files/rag/retrieval/notices.js +0 -27
- package/dist-lib/lib/core/files/rag/retrieval/scoring.d.ts +0 -8
- package/dist-lib/lib/core/files/rag/retrieval/scoring.js +0 -82
- package/dist-lib/lib/core/files/rag/retrieval/search.d.ts +0 -3
- package/dist-lib/lib/core/files/rag/retrieval/search.js +0 -49
- package/dist-lib/lib/core/files/rag/retrieval/selection.d.ts +0 -11
- package/dist-lib/lib/core/files/rag/retrieval/selection.js +0 -93
- package/dist-lib/lib/core/files/rag/retrieval/source-tag-filter.d.ts +0 -6
- package/dist-lib/lib/core/files/rag/retrieval/source-tag-filter.js +0 -79
- package/dist-lib/lib/core/files/rag/retrieval/sources.d.ts +0 -13
- package/dist-lib/lib/core/files/rag/retrieval/sources.js +0 -20
- package/dist-lib/lib/core/files/rag/retrieval/target.d.ts +0 -13
- package/dist-lib/lib/core/files/rag/retrieval/target.js +0 -89
- package/dist-lib/lib/core/files/rag/retrieval/terms.d.ts +0 -8
- package/dist-lib/lib/core/files/rag/retrieval/terms.js +0 -70
- package/dist-lib/lib/core/files/rag/retrieval/types.d.ts +0 -29
- package/dist-lib/lib/core/files/rag/retrieval/types.js +0 -1
- package/dist-lib/lib/core/files/rag/retrieval/web-sources.d.ts +0 -8
- package/dist-lib/lib/core/files/rag/retrieval/web-sources.js +0 -41
- package/dist-lib/lib/core/files/rag/retrieval/whole-document-query.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/retrieval/whole-document-query.js +0 -96
- package/dist-lib/lib/core/files/rag/vector/memory.d.ts +0 -15
- package/dist-lib/lib/core/files/rag/vector/memory.js +0 -135
- package/dist-lib/lib/core/files/rag/vector/types.d.ts +0 -28
- package/dist-lib/lib/core/files/rag/vector/types.js +0 -1
package/dist-lib/lib/core.js
CHANGED
|
@@ -14,7 +14,7 @@ import { createApi } from './api/index.js';
|
|
|
14
14
|
import { NO_SUCH_MESH } from './api/current-mesh.js';
|
|
15
15
|
import { BLIND_PEER_KEYS, BLIND_RELAY_KEYS } from './core/blind-peers.js';
|
|
16
16
|
import { CoreBlobServer, parseBlobReferenceCoreKey, MemoryVectorIndex } from './core/files/index.js';
|
|
17
|
-
import { removeChatAttachments, removeChatKnowledge } from './core/chat.js';
|
|
17
|
+
import { getChat, removeChatAttachments, removeChatKnowledge } from './core/chat.js';
|
|
18
18
|
import { createFsDriveHost } from './core/fs-drives.js';
|
|
19
19
|
import { sweepDriveStaging } from './fs-drive-bridge.js';
|
|
20
20
|
import { closeCollaboraWorker } from './collabora/worker.js';
|
|
@@ -27,6 +27,8 @@ import { HarnessLoan } from './core/harness-loan.js';
|
|
|
27
27
|
import { duplexPair } from '@qvac/harness/transport';
|
|
28
28
|
import { MeshSeedHandoff } from './core/mesh-seed-handoff.js';
|
|
29
29
|
import { SecretHandoff } from './core/secret-handoff.js';
|
|
30
|
+
import { InferenceCallsHandoff } from './core/inference-calls-handoff.js';
|
|
31
|
+
import { createInferenceCallsReceiver, NO_RECORD_STORE } from './core/inference-calls-receiver.js';
|
|
30
32
|
import { SkillOverlayHandoff } from './core/skill-overlay-handoff.js';
|
|
31
33
|
import { createSkillOverlayReceiver } from './core/skill-overlay-receiver.js';
|
|
32
34
|
import { createSkillSecretReceiver, HOST_REVOKED, NO_SUCH_AGENT, NOT_THE_HOST } from './core/skill-secrets.js';
|
|
@@ -156,6 +158,7 @@ export class Core extends ReadyResource {
|
|
|
156
158
|
_following = new Set();
|
|
157
159
|
_secretHandoff;
|
|
158
160
|
_skillOverlayHandoff;
|
|
161
|
+
_inferenceCallsHandoff;
|
|
159
162
|
_minting;
|
|
160
163
|
_leaving;
|
|
161
164
|
_kicked;
|
|
@@ -163,6 +166,7 @@ export class Core extends ReadyResource {
|
|
|
163
166
|
_peers;
|
|
164
167
|
_statusListeners;
|
|
165
168
|
_diagnosticsProviders;
|
|
169
|
+
_inferenceCalls = null;
|
|
166
170
|
_systemInfo;
|
|
167
171
|
_statusError;
|
|
168
172
|
_upgradeRequired;
|
|
@@ -261,6 +265,9 @@ export class Core extends ReadyResource {
|
|
|
261
265
|
onrequest: (request, from) => this._serveMeshSeed(request, from)
|
|
262
266
|
});
|
|
263
267
|
this._harnessLoan = new HarnessLoan({ onborrow: (from) => this._lendHarness(from) });
|
|
268
|
+
this._inferenceCallsHandoff = new InferenceCallsHandoff({
|
|
269
|
+
onrequest: (request, from) => this._serveInferenceCalls(request, from)
|
|
270
|
+
});
|
|
264
271
|
this._minting = false;
|
|
265
272
|
this._leaving = false;
|
|
266
273
|
this._kicked = false;
|
|
@@ -328,13 +335,18 @@ export class Core extends ReadyResource {
|
|
|
328
335
|
await this._openOtaConfig();
|
|
329
336
|
await this._openBootMesh();
|
|
330
337
|
this._systemInfo = createSystemInfoSampler();
|
|
338
|
+
const meshStatus = this._meshStatusSource();
|
|
331
339
|
this._api = createApi({
|
|
332
340
|
state: this.local,
|
|
333
341
|
notificationLifetime: this,
|
|
334
|
-
mesh:
|
|
335
|
-
meshStatus
|
|
342
|
+
mesh: this._currentMeshAccessor(meshStatus),
|
|
343
|
+
meshStatus,
|
|
336
344
|
network: this._networkStatusSource(),
|
|
337
345
|
diagnostics: this._diagnosticsSource(),
|
|
346
|
+
inferenceCalls: {
|
|
347
|
+
list: (chatId) => this._listInferenceCalls(chatId),
|
|
348
|
+
forget: async (chatId) => void (await this._inferenceCalls?.forget(chatId))
|
|
349
|
+
},
|
|
338
350
|
logs: this._logSource(),
|
|
339
351
|
deviceId: this.devicePublicKey,
|
|
340
352
|
lifecycle: this._apiLifecycle,
|
|
@@ -1070,8 +1082,9 @@ export class Core extends ReadyResource {
|
|
|
1070
1082
|
const attestation = claimAttestation(mesh.publicKey, deviceId, mesh.localWriterKey);
|
|
1071
1083
|
const known = await this._knownMember(mesh);
|
|
1072
1084
|
if (known) {
|
|
1085
|
+
const displayName = (await this.local.readIdentity())?.displayName;
|
|
1073
1086
|
return {
|
|
1074
|
-
member: { id: known.id, name: known.name, joinedAt: now, updatedAt: now },
|
|
1087
|
+
member: { id: known.id, name: displayName ?? known.name, joinedAt: now, updatedAt: now },
|
|
1075
1088
|
proof: await attestMemberClaim(attestation, this._deviceKeyPair, known.proof)
|
|
1076
1089
|
};
|
|
1077
1090
|
}
|
|
@@ -1242,12 +1255,12 @@ export class Core extends ReadyResource {
|
|
|
1242
1255
|
continue;
|
|
1243
1256
|
const own = await entry.mesh.view
|
|
1244
1257
|
.get('@qvac/devices', { id: deviceId })
|
|
1245
|
-
.catch(
|
|
1258
|
+
.catch(noop);
|
|
1246
1259
|
if (!own?.memberId || !own.memberProof)
|
|
1247
1260
|
continue;
|
|
1248
1261
|
const member = await entry.mesh.view
|
|
1249
1262
|
.get('@qvac/members', { id: own.memberId })
|
|
1250
|
-
.catch(
|
|
1263
|
+
.catch(noop);
|
|
1251
1264
|
if (member)
|
|
1252
1265
|
return { id: member.id, name: member.name, proof: own.memberProof };
|
|
1253
1266
|
}
|
|
@@ -1662,7 +1675,7 @@ export class Core extends ReadyResource {
|
|
|
1662
1675
|
return null;
|
|
1663
1676
|
const home = await this._homeMeshKey();
|
|
1664
1677
|
const held = home ? this._currentMesh(home.toString('hex')) : null;
|
|
1665
|
-
const mesh = home ? await this._openPooledMesh(home.toString('hex')).catch(
|
|
1678
|
+
const mesh = home ? await this._openPooledMesh(home.toString('hex')).catch(noop) : null;
|
|
1666
1679
|
if (mesh && !mesh.writable) {
|
|
1667
1680
|
await Promise.race([mesh.waitForWritable(), this._closeSignal, after(ACCOUNT_WRITABLE_MS)]);
|
|
1668
1681
|
}
|
|
@@ -1963,6 +1976,9 @@ export class Core extends ReadyResource {
|
|
|
1963
1976
|
.catch((error) => this._log?.warn(['p2p', 'mesh'], 'chat-tombstone notification reclaim failed', error));
|
|
1964
1977
|
void removeChatAttachments(mesh, deviceId, chatId, deletedAt).catch((error) => this._log?.warn(['p2p', 'mesh'], 'chat-tombstone attachment reclaim failed', error));
|
|
1965
1978
|
void removeChatKnowledge(mesh, chatId, deletedAt).catch((error) => this._log?.warn(['p2p', 'mesh'], 'chat-tombstone knowledge reclaim failed', error));
|
|
1979
|
+
void this._inferenceCalls
|
|
1980
|
+
?.forget(chatId)
|
|
1981
|
+
.catch((error) => this._log?.warn(['p2p', 'mesh'], 'chat-tombstone inspector reclaim failed', error));
|
|
1966
1982
|
});
|
|
1967
1983
|
const sweepLock = new ScopeLock({ debounce: true });
|
|
1968
1984
|
const sweep = async () => {
|
|
@@ -2099,7 +2115,7 @@ export class Core extends ReadyResource {
|
|
|
2099
2115
|
for (const row of [...rows].sort((a, b) => preferred(b) - preferred(a))) {
|
|
2100
2116
|
const meshId = row.key.toString('hex');
|
|
2101
2117
|
const held = this._currentMesh(meshId);
|
|
2102
|
-
const mesh = await this._openPooledMesh(meshId).catch(
|
|
2118
|
+
const mesh = await this._openPooledMesh(meshId).catch(noop);
|
|
2103
2119
|
if (mesh?.writable)
|
|
2104
2120
|
return mesh;
|
|
2105
2121
|
if (mesh && !held)
|
|
@@ -2568,6 +2584,7 @@ export class Core extends ReadyResource {
|
|
|
2568
2584
|
this._harnessLoan.destroy();
|
|
2569
2585
|
this._secretHandoff.destroy();
|
|
2570
2586
|
this._skillOverlayHandoff.destroy();
|
|
2587
|
+
this._inferenceCallsHandoff.destroy();
|
|
2571
2588
|
if (!this._swarm)
|
|
2572
2589
|
return;
|
|
2573
2590
|
const swarm = this._swarm;
|
|
@@ -2692,7 +2709,7 @@ export class Core extends ReadyResource {
|
|
|
2692
2709
|
continue;
|
|
2693
2710
|
if (self && device.id.equals(self))
|
|
2694
2711
|
continue;
|
|
2695
|
-
const seed = await this._meshSeedHandoff.request(device.id, meshKey).catch(
|
|
2712
|
+
const seed = await this._meshSeedHandoff.request(device.id, meshKey).catch(noop);
|
|
2696
2713
|
if (seed)
|
|
2697
2714
|
return seed;
|
|
2698
2715
|
}
|
|
@@ -2746,7 +2763,7 @@ export class Core extends ReadyResource {
|
|
|
2746
2763
|
continue;
|
|
2747
2764
|
const device = await entry.mesh.view
|
|
2748
2765
|
.get('@qvac/devices', { id: deviceId })
|
|
2749
|
-
.catch(
|
|
2766
|
+
.catch(noop);
|
|
2750
2767
|
if (device && !device.revoked)
|
|
2751
2768
|
return true;
|
|
2752
2769
|
}
|
|
@@ -2770,9 +2787,7 @@ export class Core extends ReadyResource {
|
|
|
2770
2787
|
const ours = entry.mesh.ourMemberId;
|
|
2771
2788
|
if (!ours)
|
|
2772
2789
|
continue;
|
|
2773
|
-
const row = await entry.mesh.view
|
|
2774
|
-
.get(JOINED_MESHES, { meshKey })
|
|
2775
|
-
.catch(() => null);
|
|
2790
|
+
const row = await entry.mesh.view.get(JOINED_MESHES, { meshKey }).catch(noop);
|
|
2776
2791
|
if (row?.memberId.equals(ours) && !row.leftAt)
|
|
2777
2792
|
return true;
|
|
2778
2793
|
}
|
|
@@ -2786,7 +2801,7 @@ export class Core extends ReadyResource {
|
|
|
2786
2801
|
continue;
|
|
2787
2802
|
const device = await entry.mesh.view
|
|
2788
2803
|
.get('@qvac/devices', { id: deviceId })
|
|
2789
|
-
.catch(
|
|
2804
|
+
.catch(noop);
|
|
2790
2805
|
if (!device)
|
|
2791
2806
|
continue;
|
|
2792
2807
|
if (device.revoked)
|
|
@@ -2797,12 +2812,12 @@ export class Core extends ReadyResource {
|
|
|
2797
2812
|
return ourDevice;
|
|
2798
2813
|
}
|
|
2799
2814
|
async _skillOverlayOp(agentId, op) {
|
|
2800
|
-
const host = await this.
|
|
2815
|
+
const host = await this._resolveAgentHost(agentId);
|
|
2801
2816
|
if (!host)
|
|
2802
2817
|
return this._runLocalSkillOverlayOp(op);
|
|
2803
2818
|
return this._skillOverlayHandoff.send(host, { ...op, agentId });
|
|
2804
2819
|
}
|
|
2805
|
-
async
|
|
2820
|
+
async _resolveAgentHost(agentId) {
|
|
2806
2821
|
if (!agentId)
|
|
2807
2822
|
return null;
|
|
2808
2823
|
if (!this.opened)
|
|
@@ -2823,6 +2838,56 @@ export class Core extends ReadyResource {
|
|
|
2823
2838
|
throw new Error(HOST_REVOKED);
|
|
2824
2839
|
return agent.providerDeviceId;
|
|
2825
2840
|
}
|
|
2841
|
+
async _listInferenceCalls(chatId) {
|
|
2842
|
+
const mesh = await this._awaitMesh();
|
|
2843
|
+
const store = this._inferenceCalls;
|
|
2844
|
+
const own = store?.list(chatId) ?? { calls: [], truncated: false };
|
|
2845
|
+
const local = own.calls;
|
|
2846
|
+
const chat = mesh ? await getChat(mesh, chatId) : null;
|
|
2847
|
+
if (!chat)
|
|
2848
|
+
return own;
|
|
2849
|
+
const host = await this._resolveAgentHost(chat.agentId).catch((err) => {
|
|
2850
|
+
if (local.length === 0)
|
|
2851
|
+
throw err;
|
|
2852
|
+
this._log?.warn(['api'], 'inspector host unresolved, showing this device only', {
|
|
2853
|
+
chatId,
|
|
2854
|
+
err
|
|
2855
|
+
});
|
|
2856
|
+
return null;
|
|
2857
|
+
});
|
|
2858
|
+
if (!host) {
|
|
2859
|
+
if (!store)
|
|
2860
|
+
throw new Error(NO_RECORD_STORE);
|
|
2861
|
+
return own;
|
|
2862
|
+
}
|
|
2863
|
+
const answer = await this._inferenceCallsHandoff.send(host, { chatId });
|
|
2864
|
+
const calls = [
|
|
2865
|
+
...local,
|
|
2866
|
+
...answer.calls.flatMap((entry) => this._toInferenceEntry(entry))
|
|
2867
|
+
].sort((a, b) => a.at - b.at);
|
|
2868
|
+
return { calls, truncated: own.truncated || answer.truncated };
|
|
2869
|
+
}
|
|
2870
|
+
_toInferenceEntry(entry) {
|
|
2871
|
+
const call = entry.call;
|
|
2872
|
+
if (typeof call !== 'object' || call === null)
|
|
2873
|
+
return [];
|
|
2874
|
+
return [{ runId: entry.runId, at: entry.at, call: call }];
|
|
2875
|
+
}
|
|
2876
|
+
async _serveInferenceCalls(request, fromDeviceId) {
|
|
2877
|
+
const mesh = this._currentMesh();
|
|
2878
|
+
const deviceId = this.devicePublicKey;
|
|
2879
|
+
if (!mesh || !deviceId)
|
|
2880
|
+
throw new Error(NOT_THE_HOST);
|
|
2881
|
+
const store = this._inferenceCalls;
|
|
2882
|
+
if (!store)
|
|
2883
|
+
throw new Error(NO_RECORD_STORE);
|
|
2884
|
+
const receive = createInferenceCallsReceiver({
|
|
2885
|
+
mesh,
|
|
2886
|
+
deviceId,
|
|
2887
|
+
listLocal: (chatId) => store.list(chatId)
|
|
2888
|
+
});
|
|
2889
|
+
return receive(request, fromDeviceId);
|
|
2890
|
+
}
|
|
2826
2891
|
async _serveSkillOverlayOp(op, fromDeviceId) {
|
|
2827
2892
|
const mesh = this._currentMesh();
|
|
2828
2893
|
const deviceId = this.devicePublicKey;
|
|
@@ -2914,6 +2979,7 @@ export class Core extends ReadyResource {
|
|
|
2914
2979
|
this._skillOverlayHandoff.addStream(conn);
|
|
2915
2980
|
this._meshSeedHandoff.addStream(conn);
|
|
2916
2981
|
this._harnessLoan.addStream(conn);
|
|
2982
|
+
this._inferenceCallsHandoff.addStream(conn);
|
|
2917
2983
|
for (const entry of this._meshes.values()) {
|
|
2918
2984
|
entry.hostedAgents?.kick();
|
|
2919
2985
|
if (entry.mesh.ourMemberId)
|
|
@@ -2944,6 +3010,15 @@ export class Core extends ReadyResource {
|
|
|
2944
3010
|
});
|
|
2945
3011
|
this._notifyStatus();
|
|
2946
3012
|
}
|
|
3013
|
+
_currentMeshAccessor(status) {
|
|
3014
|
+
return Object.assign((meshId) => this._meshFor(meshId), {
|
|
3015
|
+
selection: {
|
|
3016
|
+
key: () => this._activeMeshKey,
|
|
3017
|
+
watch: (listener) => status.watch(listener),
|
|
3018
|
+
unwatch: (listener) => status.unwatch(listener)
|
|
3019
|
+
}
|
|
3020
|
+
});
|
|
3021
|
+
}
|
|
2947
3022
|
_meshStatusSource() {
|
|
2948
3023
|
return {
|
|
2949
3024
|
watch: (listener) => void this._statusListeners.add(listener),
|
|
@@ -3046,6 +3121,13 @@ export class Core extends ReadyResource {
|
|
|
3046
3121
|
this._diagnosticsProviders.add(provider);
|
|
3047
3122
|
return () => void this._diagnosticsProviders.delete(provider);
|
|
3048
3123
|
}
|
|
3124
|
+
registerInferenceCalls(source) {
|
|
3125
|
+
this._inferenceCalls = source;
|
|
3126
|
+
return () => {
|
|
3127
|
+
if (this._inferenceCalls === source)
|
|
3128
|
+
this._inferenceCalls = null;
|
|
3129
|
+
};
|
|
3130
|
+
}
|
|
3049
3131
|
registerListModels(hook) {
|
|
3050
3132
|
this._listModels = hook;
|
|
3051
3133
|
return () => {
|
|
@@ -13,7 +13,7 @@ export async function sweepDriveStaging(now = Date.now()) {
|
|
|
13
13
|
const names = await fs.promises.readdir(STAGING_DIR).catch(() => []);
|
|
14
14
|
await Promise.all(names.map(async (name) => {
|
|
15
15
|
const file = path.join(STAGING_DIR, name);
|
|
16
|
-
const stat = await fs.promises.stat(file).catch(
|
|
16
|
+
const stat = await fs.promises.stat(file).catch(noop);
|
|
17
17
|
if (stat && now - stat.mtimeMs > STAGING_MAX_AGE_MS) {
|
|
18
18
|
await fs.promises.unlink(file).catch(noop);
|
|
19
19
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface InferenceCallEntry {
|
|
2
|
+
runId: string;
|
|
3
|
+
at: number;
|
|
4
|
+
call: Record<string, unknown>;
|
|
5
|
+
}
|
|
6
|
+
export declare function defaultInferenceCallsDir(): string;
|
|
7
|
+
export declare const MAX_TOTAL_BYTES: number;
|
|
8
|
+
export declare const MAX_AGE_MS: number;
|
|
9
|
+
export declare class InferenceCallStore {
|
|
10
|
+
private readonly _dir;
|
|
11
|
+
private readonly _writes;
|
|
12
|
+
constructor(dir?: string);
|
|
13
|
+
record(chatId: string, entry: InferenceCallEntry): Promise<void>;
|
|
14
|
+
recordSent(chatId: string, sent: {
|
|
15
|
+
runId: string;
|
|
16
|
+
round: number;
|
|
17
|
+
messages: unknown;
|
|
18
|
+
tokens: unknown;
|
|
19
|
+
outcome: unknown;
|
|
20
|
+
reason: unknown;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
recordOutcome(chatId: string, verdict: {
|
|
23
|
+
runId: string;
|
|
24
|
+
outcome: string;
|
|
25
|
+
reason: string | null;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
list(chatId: string): {
|
|
28
|
+
calls: ReadonlyArray<InferenceCallEntry>;
|
|
29
|
+
truncated: boolean;
|
|
30
|
+
};
|
|
31
|
+
forget(chatId: string): Promise<void>;
|
|
32
|
+
sweep(limits?: {
|
|
33
|
+
maxTotalBytes?: number;
|
|
34
|
+
maxAgeMs?: number;
|
|
35
|
+
}): Promise<{
|
|
36
|
+
removed: number;
|
|
37
|
+
}>;
|
|
38
|
+
private _drop;
|
|
39
|
+
private _chatSizes;
|
|
40
|
+
}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { persistent } from 'bare-storage';
|
|
4
|
+
import { WriteQueue } from './write-queue.js';
|
|
5
|
+
export function defaultInferenceCallsDir() {
|
|
6
|
+
return join(persistent(), 'qvac', 'inspector');
|
|
7
|
+
}
|
|
8
|
+
const CALLS_FILE = 'calls.jsonl';
|
|
9
|
+
const BLOCKS_DIR = 'blocks';
|
|
10
|
+
const MAX_CALLS_BYTES = 8 * 1024 * 1024;
|
|
11
|
+
export const MAX_TOTAL_BYTES = 64 * 1024 * 1024;
|
|
12
|
+
export const MAX_AGE_MS = 30 * 24 * 60 * 60 * 1000;
|
|
13
|
+
const MAX_LINES_READ = 600;
|
|
14
|
+
export class InferenceCallStore {
|
|
15
|
+
_dir;
|
|
16
|
+
_writes;
|
|
17
|
+
constructor(dir = defaultInferenceCallsDir()) {
|
|
18
|
+
this._dir = dir;
|
|
19
|
+
this._writes = new WriteQueue();
|
|
20
|
+
}
|
|
21
|
+
record(chatId, entry) {
|
|
22
|
+
return this._writes.run(chatId, 'inference-call', async () => {
|
|
23
|
+
const { system, tools, promptPrefix, rest } = split(entry.call);
|
|
24
|
+
const chatDir = join(this._dir, safeName(chatId));
|
|
25
|
+
await fs.promises.mkdir(join(chatDir, BLOCKS_DIR), { recursive: true });
|
|
26
|
+
const callsPath = join(chatDir, CALLS_FILE);
|
|
27
|
+
if (((await sizeOf(callsPath)) ?? 0) > MAX_CALLS_BYTES)
|
|
28
|
+
return;
|
|
29
|
+
if (promptPrefix) {
|
|
30
|
+
const blockPath = join(chatDir, BLOCKS_DIR, `${safeName(promptPrefix)}.json`);
|
|
31
|
+
await fs.promises
|
|
32
|
+
.writeFile(blockPath, JSON.stringify({ system, tools }), { flag: 'wx' })
|
|
33
|
+
.catch(() => undefined);
|
|
34
|
+
}
|
|
35
|
+
const line = JSON.stringify({ runId: entry.runId, at: entry.at, ...rest });
|
|
36
|
+
await fs.promises.appendFile(callsPath, `${line}\n`);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
recordSent(chatId, sent) {
|
|
40
|
+
return this._writes.run(chatId, 'inference-sent', async () => {
|
|
41
|
+
const chatDir = join(this._dir, safeName(chatId));
|
|
42
|
+
const callsPath = join(chatDir, CALLS_FILE);
|
|
43
|
+
const size = await sizeOf(callsPath);
|
|
44
|
+
if (size === null || size > MAX_CALLS_BYTES)
|
|
45
|
+
return;
|
|
46
|
+
const line = JSON.stringify({
|
|
47
|
+
sentFor: sent.round,
|
|
48
|
+
sentRun: sent.runId,
|
|
49
|
+
sent: sent.messages,
|
|
50
|
+
tokens: sent.tokens,
|
|
51
|
+
outcome: sent.outcome,
|
|
52
|
+
reason: sent.reason
|
|
53
|
+
});
|
|
54
|
+
await fs.promises.appendFile(callsPath, `${line}\n`);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
recordOutcome(chatId, verdict) {
|
|
58
|
+
return this._writes.run(chatId, 'inference-outcome', async () => {
|
|
59
|
+
const callsPath = join(this._dir, safeName(chatId), CALLS_FILE);
|
|
60
|
+
const size = await sizeOf(callsPath);
|
|
61
|
+
if (size === null || size > MAX_CALLS_BYTES)
|
|
62
|
+
return;
|
|
63
|
+
const line = JSON.stringify({
|
|
64
|
+
outcomeFor: verdict.runId,
|
|
65
|
+
outcome: verdict.outcome,
|
|
66
|
+
reason: verdict.reason
|
|
67
|
+
});
|
|
68
|
+
await fs.promises.appendFile(callsPath, `${line}\n`);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
list(chatId) {
|
|
72
|
+
const chatDir = join(this._dir, safeName(chatId));
|
|
73
|
+
const all = readLines(join(chatDir, CALLS_FILE));
|
|
74
|
+
const lines = all.slice(-MAX_LINES_READ);
|
|
75
|
+
const blocks = new Map();
|
|
76
|
+
const entries = [];
|
|
77
|
+
for (const line of lines) {
|
|
78
|
+
const parsed = parseLine(line);
|
|
79
|
+
if (!parsed)
|
|
80
|
+
continue;
|
|
81
|
+
if ('sentFor' in parsed) {
|
|
82
|
+
foldSent(entries, parsed);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if ('outcomeFor' in parsed) {
|
|
86
|
+
foldOutcome(entries, parsed);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const { runId, at, ...rest } = parsed;
|
|
90
|
+
const prefix = typeof rest.promptPrefix === 'string' ? rest.promptPrefix : '';
|
|
91
|
+
const block = prefix ? readBlock(blocks, chatDir, prefix) : null;
|
|
92
|
+
const messages = Array.isArray(rest.messages) ? rest.messages : [];
|
|
93
|
+
entries.push({
|
|
94
|
+
runId: String(runId ?? ''),
|
|
95
|
+
at: Number(at ?? 0),
|
|
96
|
+
call: {
|
|
97
|
+
...rest,
|
|
98
|
+
tools: block ? block.tools : (rest.tools ?? null),
|
|
99
|
+
messages: block?.system
|
|
100
|
+
? [{ role: 'system', content: block.system }, ...messages]
|
|
101
|
+
: messages
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return { calls: entries, truncated: all.length > lines.length };
|
|
106
|
+
}
|
|
107
|
+
forget(chatId) {
|
|
108
|
+
return this._writes.run(chatId, 'inference-forget', () => fs.promises.rm(join(this._dir, safeName(chatId)), { recursive: true, force: true }));
|
|
109
|
+
}
|
|
110
|
+
async sweep(limits = {}) {
|
|
111
|
+
const maxTotalBytes = limits.maxTotalBytes ?? MAX_TOTAL_BYTES;
|
|
112
|
+
const maxAgeMs = limits.maxAgeMs ?? MAX_AGE_MS;
|
|
113
|
+
const chats = await this._chatSizes();
|
|
114
|
+
const cutoff = Date.now() - maxAgeMs;
|
|
115
|
+
const aged = chats.filter((chat) => chat.mtimeMs < cutoff);
|
|
116
|
+
let removed = 0;
|
|
117
|
+
for (const chat of aged) {
|
|
118
|
+
await this._drop(chat.name);
|
|
119
|
+
removed++;
|
|
120
|
+
}
|
|
121
|
+
const kept = chats
|
|
122
|
+
.filter((chat) => chat.mtimeMs >= cutoff)
|
|
123
|
+
.sort((a, b) => a.mtimeMs - b.mtimeMs);
|
|
124
|
+
let total = kept.reduce((sum, chat) => sum + chat.bytes, 0);
|
|
125
|
+
for (const chat of kept) {
|
|
126
|
+
if (total <= maxTotalBytes)
|
|
127
|
+
break;
|
|
128
|
+
await this._drop(chat.name);
|
|
129
|
+
total -= chat.bytes;
|
|
130
|
+
removed++;
|
|
131
|
+
}
|
|
132
|
+
return { removed };
|
|
133
|
+
}
|
|
134
|
+
async _drop(name) {
|
|
135
|
+
await fs.promises.rm(join(this._dir, name), { recursive: true, force: true });
|
|
136
|
+
}
|
|
137
|
+
async _chatSizes() {
|
|
138
|
+
let names;
|
|
139
|
+
try {
|
|
140
|
+
names = await fs.promises.readdir(this._dir);
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
return [];
|
|
144
|
+
}
|
|
145
|
+
const chats = [];
|
|
146
|
+
for (const name of names) {
|
|
147
|
+
const measured = await measureDir(join(this._dir, name));
|
|
148
|
+
if (measured)
|
|
149
|
+
chats.push({ name, ...measured });
|
|
150
|
+
}
|
|
151
|
+
return chats;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async function measureDir(dir) {
|
|
155
|
+
let bytes = 0;
|
|
156
|
+
let mtimeMs = 0;
|
|
157
|
+
const visit = async (path) => {
|
|
158
|
+
const stat = await fs.promises.stat(path);
|
|
159
|
+
if (stat.isDirectory()) {
|
|
160
|
+
for (const child of await fs.promises.readdir(path))
|
|
161
|
+
await visit(join(path, child));
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
bytes += stat.size;
|
|
165
|
+
mtimeMs = Math.max(mtimeMs, stat.mtimeMs);
|
|
166
|
+
};
|
|
167
|
+
try {
|
|
168
|
+
await visit(dir);
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
return { bytes, mtimeMs };
|
|
174
|
+
}
|
|
175
|
+
function foldSent(entries, parsed) {
|
|
176
|
+
const round = Number(parsed.sentFor ?? -1);
|
|
177
|
+
const runId = parsed.sentRun === undefined ? null : String(parsed.sentRun);
|
|
178
|
+
for (let index = entries.length - 1; index >= 0; index--) {
|
|
179
|
+
const entry = entries[index];
|
|
180
|
+
if (runId !== null && entry?.runId !== runId)
|
|
181
|
+
continue;
|
|
182
|
+
if (entry && Number(entry.call.round ?? -1) === round) {
|
|
183
|
+
entry.call.sent = parsed.sent ?? null;
|
|
184
|
+
entry.call.tokens = parsed.tokens ?? null;
|
|
185
|
+
entry.call.outcome = parsed.outcome ?? null;
|
|
186
|
+
entry.call.reason = parsed.reason ?? null;
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function foldOutcome(entries, parsed) {
|
|
192
|
+
const runId = String(parsed.outcomeFor ?? '');
|
|
193
|
+
for (const entry of entries) {
|
|
194
|
+
if (entry.runId !== runId || entry.call.outcome)
|
|
195
|
+
continue;
|
|
196
|
+
entry.call.outcome = parsed.outcome ?? null;
|
|
197
|
+
entry.call.reason = parsed.reason ?? null;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function split(call) {
|
|
201
|
+
const { messages, tools, ...rest } = call;
|
|
202
|
+
const turns = Array.isArray(messages) ? messages : [];
|
|
203
|
+
const promptPrefix = typeof rest.promptPrefix === 'string' ? rest.promptPrefix : '';
|
|
204
|
+
if (!promptPrefix) {
|
|
205
|
+
return { system: null, tools: null, promptPrefix, rest: { ...rest, messages: turns, tools } };
|
|
206
|
+
}
|
|
207
|
+
const system = turns.find((turn) => isSystemTurn(turn));
|
|
208
|
+
return {
|
|
209
|
+
system: system ? String(system.content) : null,
|
|
210
|
+
tools: tools ?? null,
|
|
211
|
+
promptPrefix,
|
|
212
|
+
rest: { ...rest, messages: turns.filter((turn) => !isSystemTurn(turn)) }
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function isSystemTurn(turn) {
|
|
216
|
+
return typeof turn === 'object' && turn !== null && 'role' in turn && turn.role === 'system';
|
|
217
|
+
}
|
|
218
|
+
function readBlock(cache, chatDir, prefix) {
|
|
219
|
+
const hit = cache.get(prefix);
|
|
220
|
+
if (hit)
|
|
221
|
+
return hit;
|
|
222
|
+
const raw = readFile(join(chatDir, BLOCKS_DIR, `${safeName(prefix)}.json`));
|
|
223
|
+
if (!raw)
|
|
224
|
+
return null;
|
|
225
|
+
const parsed = parseBlock(raw);
|
|
226
|
+
if (parsed)
|
|
227
|
+
cache.set(prefix, parsed);
|
|
228
|
+
return parsed;
|
|
229
|
+
}
|
|
230
|
+
function parseLine(line) {
|
|
231
|
+
try {
|
|
232
|
+
const value = JSON.parse(line);
|
|
233
|
+
return typeof value === 'object' && value !== null ? value : null;
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function parseBlock(raw) {
|
|
240
|
+
const parsed = parseLine(raw);
|
|
241
|
+
return parsed ? { system: parsed.system ?? null, tools: parsed.tools ?? null } : null;
|
|
242
|
+
}
|
|
243
|
+
function readLines(path) {
|
|
244
|
+
const raw = readFile(path);
|
|
245
|
+
return raw ? raw.split('\n').filter((line) => line.length > 0) : [];
|
|
246
|
+
}
|
|
247
|
+
function readFile(path) {
|
|
248
|
+
try {
|
|
249
|
+
return fs.readFileSync(path, 'utf8');
|
|
250
|
+
}
|
|
251
|
+
catch {
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
async function sizeOf(path) {
|
|
256
|
+
try {
|
|
257
|
+
return (await fs.promises.stat(path)).size;
|
|
258
|
+
}
|
|
259
|
+
catch {
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
function safeName(value) {
|
|
264
|
+
const fenced = value.replace(/[^A-Za-z0-9._-]/g, '_');
|
|
265
|
+
return /^\.*$/.test(fenced) ? `_${fenced}` : fenced;
|
|
266
|
+
}
|
|
@@ -13,6 +13,11 @@ export const MESH_SCOPED = new Set([
|
|
|
13
13
|
'listToolConfigs',
|
|
14
14
|
'ragSearch',
|
|
15
15
|
'fileStatusWatch',
|
|
16
|
+
'listKnowledge',
|
|
17
|
+
'knowledgeWatch',
|
|
18
|
+
'listIndexing',
|
|
19
|
+
'indexingWatch',
|
|
20
|
+
'indexingProgressWatch',
|
|
16
21
|
'fileRead',
|
|
17
22
|
'listDevices',
|
|
18
23
|
'devicesWatch',
|
|
@@ -152,6 +152,7 @@ export declare class ModelDownloadReconciler {
|
|
|
152
152
|
private _reset;
|
|
153
153
|
suspend(): Promise<void>;
|
|
154
154
|
resume(): void;
|
|
155
|
+
meshSelected(): void;
|
|
155
156
|
yieldToRuns(models: ReadonlyArray<string>): void;
|
|
156
157
|
observeImageProgress(observation: ImageDownloadObservation): void;
|
|
157
158
|
private _transfer;
|
|
@@ -161,6 +162,7 @@ export declare class ModelDownloadReconciler {
|
|
|
161
162
|
close(): Promise<void>;
|
|
162
163
|
private _watchConfig;
|
|
163
164
|
private _syncToolConfigsWatch;
|
|
165
|
+
private _swapToolConfigsWatch;
|
|
164
166
|
private _watchToolConfigs;
|
|
165
167
|
private _watchAgents;
|
|
166
168
|
private _restartWatch;
|
|
@@ -103,6 +103,17 @@ export class ModelDownloadReconciler {
|
|
|
103
103
|
this._paused = false;
|
|
104
104
|
this._kick();
|
|
105
105
|
}
|
|
106
|
+
meshSelected() {
|
|
107
|
+
if (this._closed)
|
|
108
|
+
return;
|
|
109
|
+
const agents = this._agentsStream;
|
|
110
|
+
this._agentsStream = null;
|
|
111
|
+
if (agents?.return)
|
|
112
|
+
void agents.return().catch(() => { });
|
|
113
|
+
this._watchAgents();
|
|
114
|
+
this._swapToolConfigsWatch(this._toolConfigsAgentId);
|
|
115
|
+
this._kick();
|
|
116
|
+
}
|
|
106
117
|
yieldToRuns(models) {
|
|
107
118
|
if (this._closed)
|
|
108
119
|
return;
|
|
@@ -162,11 +173,11 @@ export class ModelDownloadReconciler {
|
|
|
162
173
|
signal.aborted) {
|
|
163
174
|
return;
|
|
164
175
|
}
|
|
165
|
-
const rows = await this._harness.list({}).catch(
|
|
176
|
+
const rows = await this._harness.list({}).catch(noop);
|
|
166
177
|
if (this._closed || this._handled.has(model) || signal.aborted)
|
|
167
178
|
return;
|
|
168
179
|
let addon = 'llm';
|
|
169
|
-
if (rows
|
|
180
|
+
if (rows) {
|
|
170
181
|
const row = rows.find((entry) => entry.name === model);
|
|
171
182
|
if (!row || row.isCached)
|
|
172
183
|
return;
|
|
@@ -241,6 +252,9 @@ export class ModelDownloadReconciler {
|
|
|
241
252
|
const agentId = this._config?.activeAgentId ?? null;
|
|
242
253
|
if (agentId === this._toolConfigsAgentId)
|
|
243
254
|
return;
|
|
255
|
+
this._swapToolConfigsWatch(agentId);
|
|
256
|
+
}
|
|
257
|
+
_swapToolConfigsWatch(agentId) {
|
|
244
258
|
const previous = this._toolConfigsStream;
|
|
245
259
|
this._toolConfigsStream = null;
|
|
246
260
|
this._toolConfigsAgentId = null;
|
|
@@ -567,7 +581,7 @@ export class ModelDownloadReconciler {
|
|
|
567
581
|
const activeAgentId = this._config?.activeAgentId;
|
|
568
582
|
if (!activeAgentId)
|
|
569
583
|
return;
|
|
570
|
-
const agent = await this._engine.getAgent({ id: activeAgentId }).catch(
|
|
584
|
+
const agent = await this._engine.getAgent({ id: activeAgentId }).catch(noop);
|
|
571
585
|
if (!agent?.modelName)
|
|
572
586
|
return;
|
|
573
587
|
if (!agent.providerDeviceId?.equals(this._deviceId))
|
|
@@ -593,8 +607,8 @@ export class ModelDownloadReconciler {
|
|
|
593
607
|
const configs = await this._engine
|
|
594
608
|
.listToolConfigs({ agentId })
|
|
595
609
|
.then((result) => result.configs ?? [])
|
|
596
|
-
.catch(
|
|
597
|
-
if (configs
|
|
610
|
+
.catch(noop);
|
|
611
|
+
if (!configs)
|
|
598
612
|
return { ok: false };
|
|
599
613
|
const row = configs.find((entry) => entry?.toolName === GENERATE_MUSIC_TOOL);
|
|
600
614
|
const settings = row?.settings;
|
|
@@ -785,3 +799,4 @@ function shouldFlush(previous, percentage, at, intervalMs, percentageStep) {
|
|
|
785
799
|
at - previous.at >= intervalMs ||
|
|
786
800
|
percentage - previous.percentage >= percentageStep);
|
|
787
801
|
}
|
|
802
|
+
function noop() { }
|