@qvac/core 0.11.0 → 0.11.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/CHANGELOG.md +80 -1
- package/dist-lib/index.d.ts +1 -0
- package/dist-lib/index.js +1 -0
- package/dist-lib/lib/api/chunk-delta.d.ts +6 -2
- package/dist-lib/lib/api/chunk-delta.js +69 -7
- package/dist-lib/lib/api/chunks.js +6 -2
- package/dist-lib/lib/api/config.d.ts +4 -1
- package/dist-lib/lib/api/config.js +23 -4
- package/dist-lib/lib/api/devices.js +3 -1
- package/dist-lib/lib/api/rag.js +4 -2
- package/dist-lib/lib/assistant/harness.d.ts +3 -1
- package/dist-lib/lib/assistant/harness.js +10 -0
- package/dist-lib/lib/assistant/history.js +25 -3
- package/dist-lib/lib/assistant/message.js +2 -2
- package/dist-lib/lib/assistant-tree.js +1 -1
- package/dist-lib/lib/assistant.d.ts +1 -0
- package/dist-lib/lib/assistant.js +14 -4
- package/dist-lib/lib/client.js +10 -1
- package/dist-lib/lib/core/archived-mesh.js +1 -0
- package/dist-lib/lib/core/chunk.d.ts +5 -2
- package/dist-lib/lib/core/chunk.js +74 -18
- package/dist-lib/lib/core/collections.d.ts +1 -0
- package/dist-lib/lib/core/collections.js +1 -0
- package/dist-lib/lib/core/config-value.d.ts +6 -0
- package/dist-lib/lib/core/config-value.js +14 -0
- package/dist-lib/lib/core/contract/chat.d.ts +1 -0
- package/dist-lib/lib/core/contract/chat.js +8 -1
- package/dist-lib/lib/core/contract/chunks.js +20 -6
- 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/devices.js +3 -2
- package/dist-lib/lib/core/departures.js +1 -0
- package/dist-lib/lib/core/devices.d.ts +2 -1
- package/dist-lib/lib/core/devices.js +4 -2
- package/dist-lib/lib/core/files/index.d.ts +1 -1
- package/dist-lib/lib/core/files/index.js +1 -1
- package/dist-lib/lib/core/files/rag/index.d.ts +1 -1
- package/dist-lib/lib/core/files/rag/index.js +1 -1
- package/dist-lib/lib/core/files/rag/retrieval/full-text.d.ts +1 -0
- package/dist-lib/lib/core/files/rag/retrieval/full-text.js +4 -1
- package/dist-lib/lib/core/inference-calls-receiver.js +2 -2
- package/dist-lib/lib/core/known-sender.d.ts +3 -0
- package/dist-lib/lib/core/known-sender.js +26 -0
- package/dist-lib/lib/core/local/index.d.ts +2 -0
- package/dist-lib/lib/core/local/index.js +17 -10
- package/dist-lib/lib/core/mesh.d.ts +5 -1
- package/dist-lib/lib/core/mesh.js +6 -6
- package/dist-lib/lib/core/migrations/chat-chunks.d.ts +4 -0
- package/dist-lib/lib/core/migrations/chat-chunks.js +43 -0
- package/dist-lib/lib/core/skill-overlay-receiver.js +2 -2
- package/dist-lib/lib/core/skill-secrets.js +2 -2
- package/dist-lib/lib/core.d.ts +11 -1
- package/dist-lib/lib/core.js +50 -5
- package/dist-lib/lib/device-tree.d.ts +18 -0
- package/dist-lib/lib/device-tree.js +32 -0
- package/dist-lib/schema/engine.js +20 -3
- package/dist-lib/schema/field-order.js +8 -1
- package/dist-lib/schema/local.js +7 -3
- package/dist-lib/schema/qvac.js +19 -2
- package/dist-lib/spec/hrpc/messages.js +1236 -1184
- package/dist-lib/spec/hyperschema/index.js +1236 -1184
- package/dist-lib/spec/hyperschema/schema.json +47 -0
- package/dist-lib/spec/hyperschema/types.d.ts +11 -0
- package/dist-lib/spec/local/hyperdb/messages.js +70 -20
- package/dist-lib/spec/local/hyperschema/index.js +36 -11
- package/dist-lib/spec/local/hyperschema/schema.json +21 -1
- package/dist-lib/spec/local/hyperschema/types.d.ts +5 -1
- package/dist-lib/spec/mesh/hyperdb/db.json +17 -1
- package/dist-lib/spec/mesh/hyperdb/index.js +83 -2
- package/dist-lib/spec/mesh/hyperdb/messages.js +573 -255
- package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +7 -1
- package/dist-lib/spec/mesh/hyperdispatch/index.js +18 -1
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +121 -8
- package/dist-lib/spec/mesh/hyperschema/index.js +121 -8
- package/dist-lib/spec/mesh/hyperschema/schema.json +69 -1
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +19 -1
- package/package.json +9 -8
package/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,84 @@ release.
|
|
|
13
13
|
|
|
14
14
|
## [Unreleased]
|
|
15
15
|
|
|
16
|
+
## [0.11.1] - 2026-10-26
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- `deviceTree(transport, { core, assistant, office, logger })` boots Core and
|
|
21
|
+
the assistant under one supervisor, the way the app does. (#544)
|
|
22
|
+
- The `reindex-chat-chunks` op copies a chat written before this release into
|
|
23
|
+
`@qvac/chat-chunks`. A build older than this one halts on it, so a device
|
|
24
|
+
sends it only once the published version floor shuts out every app release
|
|
25
|
+
before 0.21.0, the first whose core applies it. A build under the floor opens
|
|
26
|
+
no mesh, so none can halt on it; publish `>=0.21.0` once that release is in
|
|
27
|
+
both stores. (#491)
|
|
28
|
+
- A device's row in the account carries `customModels`: the label, task type
|
|
29
|
+
and size of each custom model it has. A paired desktop showed a custom model
|
|
30
|
+
added on the phone by its `custom:…` id, as Other and of unknown size, and
|
|
31
|
+
counted it outside the phone's LLMs. `saveDeviceCapabilities` takes the field,
|
|
32
|
+
and the assistant reports it again when a custom model is renamed. (#556)
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
- `chunksDeltaWatch` reads only the rows that changed after its opening reset,
|
|
37
|
+
so an update no longer costs the whole chat. Frames are unchanged; a
|
|
38
|
+
selection with `limit` is still read whole. (#538)
|
|
39
|
+
- Injection-mode `ragSearch` sizes its excerpts to a quarter of the agent's
|
|
40
|
+
context window, capped at the 3072-token default, so a small window gets
|
|
41
|
+
fewer excerpts instead of overflowing. (#588)
|
|
42
|
+
- `hypercore` 11.39 and `hypercore-storage` 3.4, for a working purge. (#539)
|
|
43
|
+
- `hypercore-blob-server` 1.15.1 keeps its socket listening across a suspend,
|
|
44
|
+
so resume keeps the port and every minted link, and replaces the local patch.
|
|
45
|
+
(#561)
|
|
46
|
+
|
|
47
|
+
### Fixed
|
|
48
|
+
|
|
49
|
+
- A member whose only device in a shared mesh comes back far behind
|
|
50
|
+
fast-forwards instead of replaying everything it missed (183 s to 3.9 s on a
|
|
51
|
+
mesh about 6,900 flushes ahead): a shared mesh trusts every member's live
|
|
52
|
+
devices, not only this member's own, and never a device admitted unlinked. A
|
|
53
|
+
compute mesh still trusts only its own member's devices. (#492)
|
|
54
|
+
- Opening a chat on a device that does not hold the mesh no longer downloads most
|
|
55
|
+
of the mesh. Each chunk is also kept in `@qvac/chat-chunks`, keyed by chat and
|
|
56
|
+
`seq`, and a chat read is one range of it: a 1,100-chunk chat fetched about
|
|
57
|
+
1,000 blocks instead of 100,000. Once the published floor is at app 0.21.0 or
|
|
58
|
+
later, the chats written before this release are copied in the background, one
|
|
59
|
+
op per chat; until then, or while an older build still writes to a chat, it
|
|
60
|
+
reads the way it did before. A chat an older build purged also loses the rows
|
|
61
|
+
that build left in `@qvac/chat-chunks`. (#490, #491)
|
|
62
|
+
- `configGet` and `configWatch` return a stored `false`, `0` or `''` as written
|
|
63
|
+
instead of `null`. A device on 0.11.0 or earlier, a value one of those
|
|
64
|
+
releases wrote, and a downgrade to one still read them as `null`. (#546)
|
|
65
|
+
- A message's audio attachment is presented to the model as a transcript of its
|
|
66
|
+
speech only, so a tool that reads the audio itself, such as music
|
|
67
|
+
transcription, is used again. (#337)
|
|
68
|
+
- The assistant reports an agent it hosts in a shared mesh as soon as this
|
|
69
|
+
device has joined it. A device still joining had its report refused and never
|
|
70
|
+
reported again. (#324)
|
|
71
|
+
- `removeDevice` on the account revokes the device in a shared mesh whose row
|
|
72
|
+
for it arrives after the removal. Before, it stayed a writer there. (#547)
|
|
73
|
+
- `inferenceCalls` and the skill routes (`pushSkillSecret`,
|
|
74
|
+
`listManagedSkills`, `readSkillFile`, `writeSkillFile`, `copySkillForEdit`,
|
|
75
|
+
`deleteOverlaySkill`) from a device that has just paired no longer fail with
|
|
76
|
+
`PEER_SENDER_REVOKED`: the host waits up to 30 s for the new device's row.
|
|
77
|
+
(#544)
|
|
78
|
+
- Core no longer dies of an unhandled `REQUEST_CANCELLED` when a fast-forward
|
|
79
|
+
cancels the read that follows a joined mesh's shared meshes. (#474)
|
|
80
|
+
- A device restarted while its `joinMesh` is still `joining` boots the mesh
|
|
81
|
+
from the head its invite carried, instead of replaying it from its first
|
|
82
|
+
block, which on a big mesh took minutes. (#515)
|
|
83
|
+
- `meshInvite` on a device that just recovered with `recoverAccount` waits for
|
|
84
|
+
its member link instead of failing with "This device cannot reach its account
|
|
85
|
+
to check". (#540)
|
|
86
|
+
- A question sent while the previous run was still answering is shown to the
|
|
87
|
+
model after that answer, not before it, once compaction folds the earlier
|
|
88
|
+
turns. The run's reply and its file turns were sorted behind the new question,
|
|
89
|
+
and the model answered as if they came later (QVAC-24502). A file a run
|
|
90
|
+
produced is now replayed right behind that run's answer instead of at the end
|
|
91
|
+
of the chat; an existing chat with such a turn re-reads once after the update.
|
|
92
|
+
(#584)
|
|
93
|
+
|
|
16
94
|
## [0.11.0] - 2026-10-23
|
|
17
95
|
|
|
18
96
|
### Added
|
|
@@ -1925,7 +2003,8 @@ Published under the `release-0.1` dist-tag.
|
|
|
1925
2003
|
await assistant.ready()
|
|
1926
2004
|
```
|
|
1927
2005
|
|
|
1928
|
-
[Unreleased]: https://github.com/tetherto/qvac-core/compare/v0.11.
|
|
2006
|
+
[Unreleased]: https://github.com/tetherto/qvac-core/compare/v0.11.1...HEAD
|
|
2007
|
+
[0.11.1]: https://github.com/tetherto/qvac-core/compare/v0.11.0...v0.11.1
|
|
1929
2008
|
[0.11.0]: https://github.com/tetherto/qvac-core/compare/v0.10.4...v0.11.0
|
|
1930
2009
|
[0.10.4]: https://github.com/tetherto/qvac-core/compare/v0.10.3...v0.10.4
|
|
1931
2010
|
[0.10.3]: https://github.com/tetherto/qvac-core/compare/v0.10.2...v0.10.3
|
package/dist-lib/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { Client } from './lib/client.ts';
|
|
|
5
5
|
export { AssistantClient } from './lib/assistant-client.ts';
|
|
6
6
|
export { harnessDeleteModel, harnessListModels, harnessSkillCatalog, harnessTools, QvacAssistant, type Harness, type ListModelsOptions, type ModelInfo, type ModelType, type Skill, type ToolCatalogEntry } from './lib/assistant.ts';
|
|
7
7
|
export { assistantChild, assistantTree, type AssistantChildOptions, type AssistantTreeOptions, type EmbedderFactory, type HarnessContext, type HarnessFactory } from './lib/assistant-tree.ts';
|
|
8
|
+
export { deviceTree, type DeviceTree, type DeviceTreeOptions } from './lib/device-tree.ts';
|
|
8
9
|
export { ASSISTANT_WAKEUP_LINGER_MS, createAssistantSuspendLifecycle, type AssistantSuspendLifecycleOptions } from './lib/suspend-lifecycle.ts';
|
|
9
10
|
export { default as Supervisor } from 'bare-supervisor';
|
|
10
11
|
export type { AssistantDiagnostics, DiagnosticsSlice, HarnessDiagnostics, RunSummary } from './lib/diagnostics.ts';
|
package/dist-lib/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export { Client } from './lib/client.js';
|
|
|
3
3
|
export { AssistantClient } from './lib/assistant-client.js';
|
|
4
4
|
export { harnessDeleteModel, harnessListModels, harnessSkillCatalog, harnessTools, QvacAssistant } from './lib/assistant.js';
|
|
5
5
|
export { assistantChild, assistantTree } from './lib/assistant-tree.js';
|
|
6
|
+
export { deviceTree } from './lib/device-tree.js';
|
|
6
7
|
export { ASSISTANT_WAKEUP_LINGER_MS, createAssistantSuspendLifecycle } from './lib/suspend-lifecycle.js';
|
|
7
8
|
export { default as Supervisor } from 'bare-supervisor';
|
|
8
9
|
export { clientSessions, duplexPair } from '@qvac/harness/transport';
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { type Readable } from 'streamx';
|
|
2
|
-
import type {
|
|
2
|
+
import type { LoggerInterface } from '@qvac/logging';
|
|
3
|
+
import type { AssistantChunk, AssistantChunkDelta } from '../../spec/hyperschema/types.d.ts';
|
|
3
4
|
import type { WatchStream } from '../../spec/capabilities.d.ts';
|
|
5
|
+
import { type ListChunksInput } from '../core/chunk.ts';
|
|
6
|
+
import type { Mesh } from '../core/mesh.ts';
|
|
4
7
|
type Rows = ReadonlyMap<string, AssistantChunk>;
|
|
5
8
|
export declare function chunkDelta(prev: Rows | null, next: ReadonlyArray<AssistantChunk>): AssistantChunkDelta;
|
|
6
|
-
export declare function
|
|
9
|
+
export declare function chunkDeltas(selection: ListChunksInput, log: LoggerInterface | null): (mesh: Mesh) => Promise<AssistantChunkDelta>;
|
|
10
|
+
export declare function chunkDeltaStream(frames: Readable & AsyncIterable<AssistantChunkDelta>): Readable & WatchStream<AssistantChunkDelta>;
|
|
7
11
|
export {};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import b4a from 'b4a';
|
|
1
2
|
import { pipeline, Transform } from 'streamx';
|
|
3
|
+
import { linkChunks, listChunks, recordLinks, selectsChunk } from '../core/chunk.js';
|
|
4
|
+
import { CHUNKS } from '../core/collections.js';
|
|
2
5
|
import { frameReadable } from '../frame-readable.js';
|
|
3
6
|
import { snapshotEquals } from './watchable.js';
|
|
4
7
|
export function chunkDelta(prev, next) {
|
|
@@ -14,13 +17,72 @@ export function chunkDelta(prev, next) {
|
|
|
14
17
|
}
|
|
15
18
|
return { reset: false, chunks: upserts, removed, count };
|
|
16
19
|
}
|
|
17
|
-
export function
|
|
18
|
-
let
|
|
20
|
+
export function chunkDeltas(selection, log) {
|
|
21
|
+
let rows = null;
|
|
22
|
+
let head = null;
|
|
23
|
+
return async (mesh) => {
|
|
24
|
+
const current = mesh.view.db.head();
|
|
25
|
+
const from = head && current && b4a.equals(head.key, current.key) ? head : null;
|
|
26
|
+
head = current;
|
|
27
|
+
const changed = rows && from && selection.limit === undefined
|
|
28
|
+
? await changedRows(mesh, { from, selection, rows, log })
|
|
29
|
+
: null;
|
|
30
|
+
if (rows === null || changed === null) {
|
|
31
|
+
const next = await listChunks(mesh, selection);
|
|
32
|
+
const delta = chunkDelta(rows, next);
|
|
33
|
+
const sent = new Set(delta.chunks?.map((chunk) => chunk.id));
|
|
34
|
+
rows = new Map(next.map((chunk) => [chunk.id, chunk]));
|
|
35
|
+
await recordLinks(mesh, next.filter((chunk) => sent.has(chunk.id)));
|
|
36
|
+
return delta;
|
|
37
|
+
}
|
|
38
|
+
const delta = applyChanged(rows, changed, selection.reverse === true);
|
|
39
|
+
await recordLinks(mesh, delta.chunks);
|
|
40
|
+
return delta;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function applyChanged(rows, { upserts, removed }, reverse) {
|
|
44
|
+
for (const id of removed) {
|
|
45
|
+
rows.delete(id);
|
|
46
|
+
}
|
|
47
|
+
for (const chunk of upserts) {
|
|
48
|
+
rows.set(chunk.id, chunk);
|
|
49
|
+
}
|
|
50
|
+
const count = rows.size;
|
|
51
|
+
const reset = upserts.length + removed.length > count / 2;
|
|
52
|
+
const chunks = (reset ? [...rows.values()] : upserts).sort((a, b) => reverse ? b.seq - a.seq : a.seq - b.seq);
|
|
53
|
+
return { reset, chunks, removed: reset ? [] : removed, count };
|
|
54
|
+
}
|
|
55
|
+
async function changedRows(mesh, { from, selection, rows, log }) {
|
|
56
|
+
const snap = mesh.view.snapshot();
|
|
57
|
+
const upserts = [];
|
|
58
|
+
const removed = [];
|
|
59
|
+
try {
|
|
60
|
+
for await (const change of snap.changes({ from })) {
|
|
61
|
+
if (change.collection !== CHUNKS)
|
|
62
|
+
continue;
|
|
63
|
+
if (change.type === 'insert' && selectsChunk(selection, change.value)) {
|
|
64
|
+
upserts.push(change.value);
|
|
65
|
+
}
|
|
66
|
+
else if (rows.has(change.value.id)) {
|
|
67
|
+
removed.push(change.value.id);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
log?.warn(['api', 'watch'], 'chunk diff from the held head failed, reading in full', err);
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
await snap.close();
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
upserts: linkChunks(mesh, upserts).filter((chunk) => !snapshotEquals(chunk, rows.get(chunk.id))),
|
|
80
|
+
removed
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export function chunkDeltaStream(frames) {
|
|
19
84
|
const deltas = new Transform({
|
|
20
|
-
transform(
|
|
21
|
-
const next = list.chunks ?? [];
|
|
22
|
-
const delta = chunkDelta(prev, next);
|
|
23
|
-
prev = new Map(next.map((chunk) => [chunk.id, chunk]));
|
|
85
|
+
transform(delta, cb) {
|
|
24
86
|
if (!delta.reset && delta.chunks?.length === 0 && delta.removed?.length === 0) {
|
|
25
87
|
cb(null);
|
|
26
88
|
return;
|
|
@@ -28,6 +90,6 @@ export function chunkDeltaStream(lists) {
|
|
|
28
90
|
cb(null, delta);
|
|
29
91
|
}
|
|
30
92
|
});
|
|
31
|
-
return frameReadable(pipeline(
|
|
93
|
+
return frameReadable(pipeline(frames, deltas, noop));
|
|
32
94
|
}
|
|
33
95
|
function noop() { }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { appendChunk, listAttachmentsByKind, listChunks, listRunRequests, recordLinks, resolveApproval, updateChunk } from '../core/chunk.js';
|
|
2
|
-
import { chunkDeltaStream } from './chunk-delta.js';
|
|
2
|
+
import { chunkDeltaStream, chunkDeltas } from './chunk-delta.js';
|
|
3
3
|
import { meshWatchable, requireMesh } from './current-mesh.js';
|
|
4
4
|
import { bounds } from './range.js';
|
|
5
5
|
export function createChunksApi(pool, deviceId, log) {
|
|
@@ -36,7 +36,11 @@ export function createChunksApi(pool, deviceId, log) {
|
|
|
36
36
|
return { chunks: await recordLinks(mesh, chunks) };
|
|
37
37
|
},
|
|
38
38
|
chunksWatch,
|
|
39
|
-
chunksDeltaWatch: (request) =>
|
|
39
|
+
chunksDeltaWatch: (request) => {
|
|
40
|
+
const deltas = chunkDeltas(chunkSelection(request), log);
|
|
41
|
+
const watch = meshWatchable(pool, (_request, mesh) => deltas(mesh), { name: 'chunksDeltaWatch', log });
|
|
42
|
+
return chunkDeltaStream(watch(request));
|
|
43
|
+
},
|
|
40
44
|
runRequestsWatch: meshWatchable(pool, async (_request, mesh) => ({ chunks: await listRunRequests(mesh, deviceId) }), { name: 'runRequestsWatch', log })
|
|
41
45
|
};
|
|
42
46
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { LoggerInterface } from '@qvac/logging';
|
|
2
|
+
import type { AssistantConfigValue } from '../../spec/hyperschema/types.d.ts';
|
|
2
3
|
import type { openLocalStore } from '../core/local/index.ts';
|
|
3
|
-
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
4
|
+
import type { CapabilityHandlers, WatchStream } from '../../spec/capabilities.d.ts';
|
|
4
5
|
type LocalStore = Awaited<ReturnType<typeof openLocalStore>>;
|
|
6
|
+
export declare function readConfigAnswer(answer: AssistantConfigValue): AssistantConfigValue;
|
|
7
|
+
export declare function readConfigFrames(source: WatchStream<AssistantConfigValue>): WatchStream<AssistantConfigValue>;
|
|
5
8
|
export declare function createConfigApi(state: LocalStore, log: LoggerInterface | null): Pick<CapabilityHandlers, 'configGet' | 'configSet' | 'configWatch'>;
|
|
6
9
|
export {};
|
|
@@ -1,15 +1,34 @@
|
|
|
1
|
+
import { Readable } from 'streamx';
|
|
1
2
|
import { watchable } from './watchable.js';
|
|
3
|
+
import { frameReadable } from '../frame-readable.js';
|
|
4
|
+
import { configValue, readConfigValue } from '../core/config-value.js';
|
|
5
|
+
export function readConfigAnswer(answer) {
|
|
6
|
+
return { value: readConfigValue(answer) };
|
|
7
|
+
}
|
|
8
|
+
export function readConfigFrames(source) {
|
|
9
|
+
const output = new Readable({
|
|
10
|
+
destroy(cb) {
|
|
11
|
+
source.destroy();
|
|
12
|
+
cb(null);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
output.on('error', noop);
|
|
16
|
+
source.on('data', (frame) => output.push(readConfigAnswer(frame)));
|
|
17
|
+
source.on('error', (err) => output.destroy(err));
|
|
18
|
+
source.on('end', () => output.push(null));
|
|
19
|
+
source.on('close', () => output.destroy());
|
|
20
|
+
return frameReadable(output);
|
|
21
|
+
}
|
|
2
22
|
export function createConfigApi(state, log) {
|
|
3
23
|
return {
|
|
4
24
|
async configGet({ key }) {
|
|
5
|
-
return
|
|
25
|
+
return configValue(await state.get(key));
|
|
6
26
|
},
|
|
7
27
|
async configSet({ key, value }) {
|
|
8
28
|
await state.set(key, value);
|
|
9
29
|
return { ok: true };
|
|
10
30
|
},
|
|
11
|
-
configWatch: watchable(() => state, async ({ key }) => ({
|
|
12
|
-
value: await state.get(key)
|
|
13
|
-
}), { name: 'configWatch', log })
|
|
31
|
+
configWatch: watchable(() => state, async ({ key }) => configValue(await state.get(key)), { name: 'configWatch', log })
|
|
14
32
|
};
|
|
15
33
|
}
|
|
34
|
+
function noop() { }
|
|
@@ -14,6 +14,7 @@ function toEngineDevice(device, overrides = {}) {
|
|
|
14
14
|
installedSkillNames: device.installedSkillNames ?? [],
|
|
15
15
|
readySkillNames: device.readySkillNames,
|
|
16
16
|
toolCatalog: device.toolCatalog,
|
|
17
|
+
customModels: device.customModels,
|
|
17
18
|
installedModelNames: device.installedModelNames ?? [],
|
|
18
19
|
cachedModelNames: device.cachedModelNames ?? [],
|
|
19
20
|
capabilityProfile: device.capabilityProfile,
|
|
@@ -67,7 +68,8 @@ export function createDevicesApi(pool, { deviceId, log, removeWriter, renameLoca
|
|
|
67
68
|
installedModelNames: input.installedModelNames ?? [],
|
|
68
69
|
cachedModelNames: input.cachedModelNames ?? [],
|
|
69
70
|
readySkillNames: input.readySkillNames ?? null,
|
|
70
|
-
toolCatalog: input.toolCatalog ?? null
|
|
71
|
+
toolCatalog: input.toolCatalog ?? null,
|
|
72
|
+
customModels: input.customModels ?? null
|
|
71
73
|
}, isAccount);
|
|
72
74
|
return { ok: true };
|
|
73
75
|
},
|
package/dist-lib/lib/api/rag.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { toolsetEnabled } from '@qvac/harness/lib/tools/toolsets.ts';
|
|
2
2
|
import { getAgent } from '../core/agent.js';
|
|
3
3
|
import { getChat } from '../core/chat.js';
|
|
4
|
-
import { isKnowledgeRoutedAttachment, fullTextBudgetChars, fullTextHits, retrieveRagKnowledge, searchRagChunks, referencesPendingFile, referencedDocuments } from '../core/files/index.js';
|
|
4
|
+
import { isKnowledgeRoutedAttachment, fullTextBudgetChars, fullTextHits, retrievalBudgetTokens, retrieveRagKnowledge, searchRagChunks, referencesPendingFile, referencedDocuments } from '../core/files/index.js';
|
|
5
5
|
import { requireMesh } from './current-mesh.js';
|
|
6
6
|
import { errorMessage } from '../guards.js';
|
|
7
7
|
export const MAX_RAG_SEARCH_LIMIT = 20;
|
|
@@ -169,12 +169,14 @@ export function createRagApi(pool, { index, embedder, effectiveCtxSize = null })
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
try {
|
|
172
|
+
const ctxSize = effectiveCtxSize ? await effectiveCtxSize(agent) : 0;
|
|
172
173
|
const result = await retrieveRagKnowledge({
|
|
173
174
|
query,
|
|
174
175
|
chatId,
|
|
175
176
|
documents: hydratedDocuments,
|
|
176
177
|
liveSourceIds: rows.map((row) => row.id),
|
|
177
|
-
scopeDocumentIds: scopeDocumentIds.length > 0 ? scopeDocumentIds : undefined
|
|
178
|
+
scopeDocumentIds: scopeDocumentIds.length > 0 ? scopeDocumentIds : undefined,
|
|
179
|
+
chunkBudgetTokens: retrievalBudgetTokens(ctxSize)
|
|
178
180
|
}, {
|
|
179
181
|
index: vectorIndex,
|
|
180
182
|
embed: (texts) => embed.embed({ texts }),
|
|
@@ -3,7 +3,7 @@ import type { ApprovalCall, CompletionEvent, DeleteModelSummary, MemoryBudget, M
|
|
|
3
3
|
import type { ManagedSkill, SkillFileContent } from '@qvac/harness/lib/tools/skills/overlay-crud.ts';
|
|
4
4
|
import type { SkillCatalogOptions, SkillManagementHooks } from '../core.ts';
|
|
5
5
|
import type { DriveOpFn, GrantedDrive } from '@qvac/harness/lib/tools/fs/remote.ts';
|
|
6
|
-
import type { AssistantAgent, AssistantCapabilityProfile, AssistantChunkContentAttachment, AssistantCustomModelPreview, AssistantDeleteModelRequest, AssistantDetectLanguageRequest, AssistantDetectLanguageResponse, AssistantDeleteModelResponse, AssistantEnhanceMode, AssistantKvCacheDeletionResponse, AssistantListModelsRequest, AssistantModelInfoList, AssistantPreviewCustomModelRequest, AssistantSkillCatalogResponse, AssistantSpeakRequest, AssistantSpeakResponse, AssistantToolCatalogResponse, AssistantToolReportEntry, AssistantTranscribeRequest, AssistantTranscribeResponse } from '../../spec/hyperschema/types.d.ts';
|
|
6
|
+
import type { AssistantAgent, AssistantCapabilityProfile, AssistantChunkContentAttachment, AssistantCustomModelPreview, AssistantCustomModelReportEntry, AssistantDeleteModelRequest, AssistantDetectLanguageRequest, AssistantDetectLanguageResponse, AssistantDeleteModelResponse, AssistantEnhanceMode, AssistantKvCacheDeletionResponse, AssistantListModelsRequest, AssistantModelInfoList, AssistantPreviewCustomModelRequest, AssistantSkillCatalogResponse, AssistantSpeakRequest, AssistantSpeakResponse, AssistantToolCatalogResponse, AssistantToolReportEntry, AssistantTranscribeRequest, AssistantTranscribeResponse } from '../../spec/hyperschema/types.d.ts';
|
|
7
7
|
import type { HarnessDiagnostics } from '../diagnostics.ts';
|
|
8
8
|
import type { DownloadArgs, DownloadEventStream, ImageDownloadObservation } from '../model-download.ts';
|
|
9
9
|
import type { AttachInput, AttachmentMeta, ChatMessage, FetchedAttachment } from './message.ts';
|
|
@@ -50,6 +50,7 @@ export interface ModelInfo {
|
|
|
50
50
|
actualSize?: number;
|
|
51
51
|
taskType?: string;
|
|
52
52
|
memoryBytes?: number;
|
|
53
|
+
label?: string;
|
|
53
54
|
}
|
|
54
55
|
export interface ListModelsOptions {
|
|
55
56
|
type?: ModelType;
|
|
@@ -277,6 +278,7 @@ export declare function harnessSkillCatalog(harness: Pick<Harness, 'skills'>, sy
|
|
|
277
278
|
export declare function harnessSkillManagement(harness: Pick<Harness, 'listManagedSkills' | 'readSkillFile' | 'writeSkillFile' | 'copyBaseForEdit' | 'deleteOverlaySkill'>): SkillManagementHooks;
|
|
278
279
|
export declare function harnessTools(harness: Pick<Harness, 'tools'>): () => Promise<AssistantToolCatalogResponse>;
|
|
279
280
|
export declare function toolReportEntry(tool: ToolCatalogEntry): AssistantToolReportEntry;
|
|
281
|
+
export declare function customModelReportEntries(models: ReadonlyArray<ModelInfo>): AssistantCustomModelReportEntry[];
|
|
280
282
|
export declare function harnessSpeakStream(harness: Pick<Harness, 'speakStream'>): (text: AsyncIterable<string>) => AsyncIterable<AssistantSpeakResponse>;
|
|
281
283
|
export declare function harnessDeathReason(status: unknown): string;
|
|
282
284
|
export declare function harnessDied(status: unknown): boolean;
|
|
@@ -135,6 +135,16 @@ export function toolReportEntry(tool) {
|
|
|
135
135
|
writeRootsRequired: tool.writeRootsRequired === true
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
|
+
export function customModelReportEntries(models) {
|
|
139
|
+
return models
|
|
140
|
+
.filter((model) => model.registrySource === 'custom')
|
|
141
|
+
.map((model) => ({
|
|
142
|
+
name: model.name,
|
|
143
|
+
label: model.label || model.name,
|
|
144
|
+
taskType: model.taskType ?? null,
|
|
145
|
+
expectedSize: model.expectedSize
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
138
148
|
export function harnessSpeakStream(harness) {
|
|
139
149
|
return async function* (text) {
|
|
140
150
|
if (!harness.speakStream) {
|
|
@@ -136,6 +136,19 @@ export function historyFromChunks(chunks, stale = {}, { senderNames = new Map(),
|
|
|
136
136
|
}
|
|
137
137
|
return turn;
|
|
138
138
|
};
|
|
139
|
+
const foldedRequests = foldedRequestRuns(chunks, source);
|
|
140
|
+
for (const chunk of source) {
|
|
141
|
+
if (chunk.runId && foldedRequests.has(chunk.runId) && (chunk.content || chunk.toolResult)) {
|
|
142
|
+
anchor(chunk.runId);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const afterRun = (runId) => {
|
|
146
|
+
let at = history.indexOf(anchor(runId)) + 1;
|
|
147
|
+
while (history[at]?.role === 'tool') {
|
|
148
|
+
at++;
|
|
149
|
+
}
|
|
150
|
+
return at;
|
|
151
|
+
};
|
|
139
152
|
for (const chunk of source) {
|
|
140
153
|
if (chunk.userMessage) {
|
|
141
154
|
if (staleQuestionChunkIds.has(chunk.id)) {
|
|
@@ -198,8 +211,7 @@ export function historyFromChunks(chunks, stale = {}, { senderNames = new Map(),
|
|
|
198
211
|
const loaded = isRecord(result) ? result.name : undefined;
|
|
199
212
|
if (typeof loaded === 'string' && !replayedSkills.has(loaded)) {
|
|
200
213
|
replayedSkills.add(loaded);
|
|
201
|
-
|
|
202
|
-
history.splice(at, 0, { role: 'tool', content: skillLoadedTurn(loaded) });
|
|
214
|
+
history.splice(afterRun(chunk.runId), 0, { role: 'tool', content: skillLoadedTurn(loaded) });
|
|
203
215
|
}
|
|
204
216
|
continue;
|
|
205
217
|
}
|
|
@@ -212,7 +224,7 @@ export function historyFromChunks(chunks, stale = {}, { senderNames = new Map(),
|
|
|
212
224
|
}
|
|
213
225
|
const produced = attachmentTurn(chunk.toolResult.name, chunk.toolResult.result);
|
|
214
226
|
if (produced) {
|
|
215
|
-
history.
|
|
227
|
+
history.splice(afterRun(chunk.runId), 0, { role: 'tool', content: produced });
|
|
216
228
|
}
|
|
217
229
|
continue;
|
|
218
230
|
}
|
|
@@ -229,6 +241,16 @@ export function historyFromChunks(chunks, stale = {}, { senderNames = new Map(),
|
|
|
229
241
|
}
|
|
230
242
|
return history.filter((turn) => turn.role === 'user' || turn.content.length > 0 || kept.has(turn));
|
|
231
243
|
}
|
|
244
|
+
function foldedRequestRuns(chunks, kept) {
|
|
245
|
+
const keptIds = new Set(kept.map((chunk) => chunk.id));
|
|
246
|
+
const folded = new Set();
|
|
247
|
+
for (const chunk of chunks) {
|
|
248
|
+
if (chunk.type === 'run-request' && chunk.runId && !keptIds.has(chunk.id)) {
|
|
249
|
+
folded.add(chunk.runId);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return folded;
|
|
253
|
+
}
|
|
232
254
|
export function inputAvailableToRun(chunk, requestSeq) {
|
|
233
255
|
const userInput = Boolean(chunk.userMessage || (chunk.attachment && !chunk.runId));
|
|
234
256
|
return !userInput || chunk.seq < requestSeq;
|
|
@@ -42,8 +42,8 @@ export function silentAudioNotice(fileName) {
|
|
|
42
42
|
}
|
|
43
43
|
export function audioTranscriptBlock(fileName, transcript) {
|
|
44
44
|
return [
|
|
45
|
-
`The audio file "${fileName}" has already been transcribed on-device. You cannot open the file itself
|
|
46
|
-
'Transcript:',
|
|
45
|
+
`The audio file "${fileName}" has already been transcribed on-device for its speech. You cannot open the file itself, but a tool that takes an audio attachment still reads the audio.`,
|
|
46
|
+
'Transcript of the speech in it, which is its words and not any music:',
|
|
47
47
|
transcript
|
|
48
48
|
].join('\n');
|
|
49
49
|
}
|
|
@@ -98,7 +98,7 @@ export function assistantTree(opts) {
|
|
|
98
98
|
offModelCatalogWatch = core.registerModelCatalogWatch(() => assistant.modelCatalogWatch());
|
|
99
99
|
offCustomModels = startCustomModelPusher(harness, core.local, {
|
|
100
100
|
logger,
|
|
101
|
-
onPushed: () => assistant.
|
|
101
|
+
onPushed: () => assistant.cachedModelsChanged()
|
|
102
102
|
});
|
|
103
103
|
offModelIdle = startModelIdlePusher(harness, core.local, logger);
|
|
104
104
|
modelMemoryCap = assistant.mobileClass
|
|
@@ -43,7 +43,7 @@ import { searchKnowledge } from './knowledge-search.js';
|
|
|
43
43
|
import { isLifecycleTeardown, knownAbortOutcome, RUN_ABORT_REASONS, RUN_FAILURE_REASONS, runFailureNotice } from './run-notices.js';
|
|
44
44
|
import { unref } from './unref.js';
|
|
45
45
|
import { encodeAgentSkillReadiness } from './skill-readiness.js';
|
|
46
|
-
import { harnessClearKvCache, harnessDeathReason, harnessDeleteModel, harnessDied, harnessListModels, harnessPreviewModelSource, harnessSkillCatalog, harnessSkillManagement, harnessDetectLanguage, harnessSpeak, harnessSpeakStream, harnessTools, harnessTranscribe, heldLoadModel, droppedHeldLoadModel, imageDownloadProgress, isHarnessEvent, modelCatalogChanged, toolReportEntry } from './assistant/harness.js';
|
|
46
|
+
import { harnessClearKvCache, harnessDeathReason, harnessDeleteModel, harnessDied, harnessListModels, harnessPreviewModelSource, harnessSkillCatalog, harnessSkillManagement, harnessDetectLanguage, harnessSpeak, harnessSpeakStream, harnessTools, harnessTranscribe, heldLoadModel, droppedHeldLoadModel, imageDownloadProgress, isHarnessEvent, modelCatalogChanged, customModelReportEntries, toolReportEntry } from './assistant/harness.js';
|
|
47
47
|
import { annotateUnreadableImages, audioTranscriptBlock, backfillDocumentOnlyTurn, backfillImageOnlyTurns, silentAudioNotice, unheardAudioNotice, nameSenders, restoreSentContent, hiddenVideoNotice, lentVideoNotice, unreadVideoNotice, unsyncedVideoNotice, VIDEO_NO_AUDIO, VIDEO_SILENT, videoAnnotation, videoTranscriptBlock } from './assistant/message.js';
|
|
48
48
|
import { frameTimes, probeVideo, sampleFrames } from './core/video/frames.js';
|
|
49
49
|
import { packVideoDigest, parseVideoDigestHeader, unpackVideoDigest, VIDEO_DIGEST_MIME, videoDigestFileName } from './core/video/digest.js';
|
|
@@ -233,6 +233,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
233
233
|
_info;
|
|
234
234
|
_lastCapabilities = new Map();
|
|
235
235
|
_sharedMeshes = new Set();
|
|
236
|
+
_writableMeshes = new Set();
|
|
236
237
|
_hostedIn = new Map();
|
|
237
238
|
_accountHosted = [];
|
|
238
239
|
_readySkills;
|
|
@@ -624,6 +625,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
624
625
|
}
|
|
625
626
|
const installedModelNames = models.map((model) => model.name);
|
|
626
627
|
const cachedModelNames = models.filter((model) => model.isCached).map((model) => model.name);
|
|
628
|
+
const customModels = customModelReportEntries(models);
|
|
627
629
|
let toolCatalog = null;
|
|
628
630
|
if (this._harness.tools) {
|
|
629
631
|
try {
|
|
@@ -639,7 +641,8 @@ export class QvacAssistant extends ReadyResource {
|
|
|
639
641
|
installedModelNames,
|
|
640
642
|
cachedModelNames,
|
|
641
643
|
this._readySkills,
|
|
642
|
-
toolCatalog
|
|
644
|
+
toolCatalog,
|
|
645
|
+
customModels
|
|
643
646
|
]);
|
|
644
647
|
const meshId = this._accountMeshId;
|
|
645
648
|
if (!meshId) {
|
|
@@ -652,14 +655,15 @@ export class QvacAssistant extends ReadyResource {
|
|
|
652
655
|
installedModelNames,
|
|
653
656
|
cachedModelNames,
|
|
654
657
|
readySkillNames: readySkillNames ?? undefined,
|
|
655
|
-
toolCatalog: toolCatalog ?? undefined
|
|
658
|
+
toolCatalog: toolCatalog ?? undefined,
|
|
659
|
+
customModels
|
|
656
660
|
};
|
|
657
661
|
await this._reportInto(meshId, key, report);
|
|
658
662
|
if (!readySkillNames) {
|
|
659
663
|
return;
|
|
660
664
|
}
|
|
661
665
|
for (const [shared, hosted] of this._hostedIn) {
|
|
662
|
-
if (shared === meshId)
|
|
666
|
+
if (shared === meshId || !this._writableMeshes.has(shared))
|
|
663
667
|
continue;
|
|
664
668
|
await this._reportInto(shared, JSON.stringify([readySkillNames, hosted]), report);
|
|
665
669
|
}
|
|
@@ -1362,6 +1366,12 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1362
1366
|
this._hostedIn.delete(meshId);
|
|
1363
1367
|
this._lastCapabilities.delete(meshId);
|
|
1364
1368
|
}
|
|
1369
|
+
const writable = new Set(meshes.filter((mesh) => mesh.writable).map((mesh) => mesh.meshId));
|
|
1370
|
+
const joined = [...this._hostedIn.keys()].some((meshId) => writable.has(meshId) && !this._writableMeshes.has(meshId));
|
|
1371
|
+
this._writableMeshes = writable;
|
|
1372
|
+
if (joined) {
|
|
1373
|
+
void this._reportHosted().catch(noop);
|
|
1374
|
+
}
|
|
1365
1375
|
for (const [meshId, consumer] of this._meshConsumers) {
|
|
1366
1376
|
if (open.has(meshId))
|
|
1367
1377
|
continue;
|
package/dist-lib/lib/client.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import ReadyResource from 'ready-resource';
|
|
2
2
|
import { reconnectingWatch } from './reconnecting-watch.js';
|
|
3
|
+
import { readConfigAnswer, readConfigFrames } from './api/config.js';
|
|
3
4
|
import { openLocalEngineSpec } from './spec-loader.js';
|
|
4
5
|
import { settleOnClose } from '@qvac/harness/rpc';
|
|
5
6
|
export class Client extends ReadyResource {
|
|
@@ -28,7 +29,15 @@ export class Client extends ReadyResource {
|
|
|
28
29
|
const modelDownloadsWatch = this._reconnecting(capabilities.modelDownloadsWatch, 'model-download');
|
|
29
30
|
const modelCatalogWatch = this._reconnecting(capabilities.modelCatalogWatch, 'model-catalog');
|
|
30
31
|
const modelsWatch = this._reconnecting(capabilities.modelsWatch, 'models');
|
|
31
|
-
|
|
32
|
+
const config = {
|
|
33
|
+
configGet: async (input) => readConfigAnswer(await capabilities.configGet(input)),
|
|
34
|
+
configWatch: (input) => readConfigFrames(capabilities.configWatch(input))
|
|
35
|
+
};
|
|
36
|
+
Object.assign(this, capabilities, config, {
|
|
37
|
+
modelCatalogWatch,
|
|
38
|
+
modelDownloadsWatch,
|
|
39
|
+
modelsWatch
|
|
40
|
+
});
|
|
32
41
|
this._log?.info('lifecycle', 'client open');
|
|
33
42
|
}
|
|
34
43
|
_reconnecting(open, scope) {
|
|
@@ -23,8 +23,9 @@ export type ReadChunk = QvacChunk & {
|
|
|
23
23
|
readonly url?: string;
|
|
24
24
|
}) | null;
|
|
25
25
|
};
|
|
26
|
+
export declare function linkChunks(store: Mesh, chunks: QvacChunk[]): ReadChunk[];
|
|
26
27
|
export declare function recordLinks(store: Mesh, chunks: ReadChunk[]): Promise<ReadChunk[]>;
|
|
27
|
-
type ListChunksInput = Bounds & {
|
|
28
|
+
export type ListChunksInput = Bounds & {
|
|
28
29
|
chatId: string;
|
|
29
30
|
type?: QvacChunk['type'];
|
|
30
31
|
types?: ReadonlyArray<QvacChunk['type']>;
|
|
@@ -34,8 +35,10 @@ export interface FindChunksOfTypeInput extends Bounds {
|
|
|
34
35
|
readonly type: QvacChunk['type'];
|
|
35
36
|
}
|
|
36
37
|
export declare function findChunksOfType(snap: HyperDB, { chatId, type, ...bounds }: FindChunksOfTypeInput): Promise<QvacChunk[]>;
|
|
37
|
-
export declare function listChunks(store: Mesh,
|
|
38
|
+
export declare function listChunks(store: Mesh, input: ListChunksInput): Promise<ReadChunk[]>;
|
|
39
|
+
export declare function readChunks(db: HyperDB, { chatId, type, types, ...bounds }: ListChunksInput): Promise<QvacChunk[]>;
|
|
38
40
|
export declare function listAttachmentsByKind(store: Mesh, { kind, origin, ...bounds }: ListAttachmentsByKindInput): Promise<ReadChunk[]>;
|
|
41
|
+
export declare function selectsChunk({ chatId, type, types, gt, gte, lt, lte }: ListChunksInput, chunk: QvacChunk): boolean;
|
|
39
42
|
export declare function getChunk(store: Mesh, id: string): Promise<QvacChunk | null>;
|
|
40
43
|
export interface AppendedChunk {
|
|
41
44
|
readonly id: string;
|