@qvac/core 0.6.3 → 0.6.5
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 +78 -1
- package/README.md +24 -16
- package/dist-lib/lib/api/chat-move.d.ts +3 -0
- package/dist-lib/lib/api/chat-move.js +7 -0
- package/dist-lib/lib/api/chat.d.ts +1 -1
- package/dist-lib/lib/api/chat.js +2 -1
- package/dist-lib/lib/api/chunk-delta.d.ts +7 -0
- package/dist-lib/lib/api/chunk-delta.js +33 -0
- package/dist-lib/lib/api/chunks.d.ts +1 -1
- package/dist-lib/lib/api/chunks.js +6 -3
- package/dist-lib/lib/api/index.d.ts +2 -0
- package/dist-lib/lib/api/index.js +2 -0
- package/dist-lib/lib/api/mesh.d.ts +2 -1
- package/dist-lib/lib/api/mesh.js +4 -0
- package/dist-lib/lib/assistant/harness.d.ts +8 -10
- package/dist-lib/lib/assistant.js +1 -1
- package/dist-lib/lib/constants.d.ts +1 -0
- package/dist-lib/lib/constants.js +1 -0
- package/dist-lib/lib/core/archived-mesh.js +3 -42
- package/dist-lib/lib/core/chat-activity.js +23 -10
- package/dist-lib/lib/core/chat-copy.d.ts +24 -0
- package/dist-lib/lib/core/chat-copy.js +115 -0
- package/dist-lib/lib/core/chat-move.d.ts +65 -0
- package/dist-lib/lib/core/chat-move.js +525 -0
- package/dist-lib/lib/core/chat.d.ts +6 -0
- package/dist-lib/lib/core/chat.js +11 -3
- package/dist-lib/lib/core/collections.d.ts +2 -0
- package/dist-lib/lib/core/collections.js +2 -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 +2 -0
- package/dist-lib/lib/core/contract/invites.d.ts +1 -0
- package/dist-lib/lib/core/contract/invites.js +1 -1
- package/dist-lib/lib/core/contract/mesh-name.d.ts +3 -0
- package/dist-lib/lib/core/contract/mesh-name.js +26 -0
- package/dist-lib/lib/core/contract/writers.js +10 -3
- 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/preview/index.js +4 -1
- package/dist-lib/lib/core/files/processing/source.js +4 -1
- package/dist-lib/lib/core/files/rag/limits.d.ts +0 -1
- package/dist-lib/lib/core/files/rag/limits.js +0 -1
- package/dist-lib/lib/core/files/store/index.d.ts +2 -1
- package/dist-lib/lib/core/files/store/index.js +2 -1
- package/dist-lib/lib/core/files/store/reference.d.ts +3 -0
- package/dist-lib/lib/core/files/store/reference.js +8 -0
- package/dist-lib/lib/core/files/store/sweep.js +3 -1
- package/dist-lib/lib/core/local/index.d.ts +4 -1
- package/dist-lib/lib/core/local/index.js +14 -1
- package/dist-lib/lib/core/mesh-seed-handoff.d.ts +3 -1
- package/dist-lib/lib/core/mesh-seed-handoff.js +1 -0
- package/dist-lib/lib/core/mesh.d.ts +5 -1
- package/dist-lib/lib/core/mesh.js +16 -1
- package/dist-lib/lib/core/sync/index.js +9 -1
- package/dist-lib/lib/core.d.ts +9 -0
- package/dist-lib/lib/core.js +156 -32
- package/dist-lib/lib/custom-model-pusher.js +9 -5
- package/dist-lib/lib/mesh-scoped-engine.js +5 -0
- package/dist-lib/schema/config.d.ts +1 -1
- package/dist-lib/schema/config.js +1 -1
- package/dist-lib/schema/engine.js +80 -1
- package/dist-lib/schema/local.js +17 -0
- package/dist-lib/schema/qvac.d.ts +2 -0
- package/dist-lib/schema/qvac.js +16 -0
- package/dist-lib/spec/bind.js +25 -0
- package/dist-lib/spec/calls.js +5 -0
- package/dist-lib/spec/capabilities.d.ts +10 -0
- package/dist-lib/spec/config/hyperconf/index.js +1 -1
- package/dist-lib/spec/hrpc/hrpc.json +65 -0
- package/dist-lib/spec/hrpc/index.js +66 -4
- package/dist-lib/spec/hrpc/messages.js +1398 -1154
- package/dist-lib/spec/hyperschema/index.js +1398 -1154
- package/dist-lib/spec/hyperschema/schema.json +204 -0
- package/dist-lib/spec/hyperschema/types.d.ts +47 -0
- package/dist-lib/spec/local/hyperdb/db.json +17 -1
- package/dist-lib/spec/local/hyperdb/index.js +83 -2
- package/dist-lib/spec/local/hyperdb/messages.js +340 -136
- package/dist-lib/spec/local/hyperschema/index.js +107 -2
- package/dist-lib/spec/local/hyperschema/schema.json +78 -1
- package/dist-lib/spec/local/hyperschema/types.d.ts +18 -1
- 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 +454 -228
- 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 +150 -2
- package/dist-lib/spec/mesh/hyperschema/index.js +150 -2
- package/dist-lib/spec/mesh/hyperschema/schema.json +76 -1
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +21 -1
- package/package.json +5 -8
- package/tui/app.mjs +89 -3
- package/tui/lib/move-command.mjs +17 -0
- package/dist-lib/lib/collabora/convert.d.ts +0 -9
- package/dist-lib/lib/collabora/convert.js +0 -65
- package/dist-lib/lib/collabora/entry.d.ts +0 -1
- package/dist-lib/lib/collabora/entry.js +0 -42
- package/dist-lib/lib/collabora/protocol.d.ts +0 -15
- package/dist-lib/lib/collabora/protocol.js +0 -31
- package/dist-lib/lib/collabora/worker.d.ts +0 -5
- package/dist-lib/lib/collabora/worker.js +0 -177
- package/dist-lib/lib/core/files/rag/extract/office-collabora.d.ts +0 -2
- package/dist-lib/lib/core/files/rag/extract/office-collabora.js +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,81 @@ release.
|
|
|
13
13
|
|
|
14
14
|
## [Unreleased]
|
|
15
15
|
|
|
16
|
+
## [0.6.5] - 2026-10-01
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- `setMeshName` names a mesh for every member in it. `setMeshLabel` only
|
|
21
|
+
names it for the member who set it, so someone who joined a shared mesh read
|
|
22
|
+
it unnamed. `listMeshes` and `meshesWatch` rows carry the shared name as
|
|
23
|
+
`name`, and `meshesWatch` emits when another member renames the mesh. A build
|
|
24
|
+
older than this one halts on the new `name-mesh` op, so every member's devices
|
|
25
|
+
need this release before a mesh is named.
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
await engine.setMeshName({ meshId, name: 'Design team' })
|
|
29
|
+
const { meshes } = await engine.listMeshes({})
|
|
30
|
+
meshes.find((mesh) => mesh.meshId === meshId).name // 'Design team', on every member
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
(#310)
|
|
34
|
+
|
|
35
|
+
- `moveChatToMesh` moves a chat to another mesh with its files and its running
|
|
36
|
+
turn: the copy lands at once under `targetChatId`, the turn is retried there,
|
|
37
|
+
and the source is purged once every file has arrived. `chatMoveWatch` reports
|
|
38
|
+
the move, and `setChatAgent` hands a chat to another agent of its mesh. Until
|
|
39
|
+
its bytes arrive, a moved attachment's `blobId` is `PENDING_BLOB_REFERENCE`,
|
|
40
|
+
which `downloadAttachment` rejects with `blob unavailable`. (#312)
|
|
41
|
+
- `chunksDeltaWatch` streams an open chat as changes: a `reset` with the whole
|
|
42
|
+
selection first, then only the rows appended, edited or reordered, and the ids
|
|
43
|
+
of rows that left. A transcript that re-rendered the whole chat on every
|
|
44
|
+
streamed chunk pays for one row per chunk instead; `chunksWatch` is
|
|
45
|
+
unchanged. (#314)
|
|
46
|
+
|
|
47
|
+
### Changed
|
|
48
|
+
|
|
49
|
+
- The consensus floor, `VENDORED_MIN_SUPPORTED_VERSION`, is `>=0.20.0`. How a
|
|
50
|
+
re-paired device's removal is weighed changed in apply, so a device on an
|
|
51
|
+
older build would read a shared mesh differently. Ship the 0.20 app before
|
|
52
|
+
publishing this floor to the lane cores. (#308)
|
|
53
|
+
- `@qvac/harness` is `^0.7.2`. `web_fetch` attaches a plain-text file it
|
|
54
|
+
fetched to the chat beside returning its text, and devices on the `mid`
|
|
55
|
+
profile and up speak with `Supertonic3-FP16` at 16 steps instead of
|
|
56
|
+
`Supertonic3-Q8_0` at 5, so a host that prefetches the infra models downloads
|
|
57
|
+
the FP16 model once. (#311)
|
|
58
|
+
|
|
59
|
+
### Fixed
|
|
60
|
+
|
|
61
|
+
- A device unpaired and paired back gets every project back, however its
|
|
62
|
+
removal synced, and one that left a shared mesh on its own comes back as soon
|
|
63
|
+
as it asks; only another member's removal still needs a grant. A re-paired
|
|
64
|
+
device still live on its old writer is moved onto its new one instead of
|
|
65
|
+
staying a reader, and a late leave no longer turns a kick into a leave. A
|
|
66
|
+
consensus change, covered by the `>=0.20.0` floor. (#308)
|
|
67
|
+
- A member re-invited to a mesh it left brings every device back, not only the
|
|
68
|
+
one that redeemed the invite. A device asking its siblings to admit it asks
|
|
69
|
+
again, about once a second for up to a minute, while they are mid-join,
|
|
70
|
+
instead of waiting as a reader until the next restart. (#307)
|
|
71
|
+
- `leaveMesh` on the account is no longer refused while this device holds
|
|
72
|
+
another mesh: it departs each of them as this device alone, then leaves the
|
|
73
|
+
account. Unpairing a device that held a project did nothing. (#306)
|
|
74
|
+
- `chatActivityWatch` no longer fails on every tick after a fast-forward leaves
|
|
75
|
+
its cached view head undiffable. It rebuilds from the current view instead;
|
|
76
|
+
before, the error repeated until restart. (#301)
|
|
77
|
+
- `modelCatalogWatch` bumps only when the custom-model set changed. It bumped on
|
|
78
|
+
every device-local write, several times a second while a reply streamed. (#300)
|
|
79
|
+
- A typed harness can ask `fetchAttachment` for the newest audio. (#309)
|
|
80
|
+
- PDF extraction works on Android again: `bare-pdfium` 1.5.5 links its C++
|
|
81
|
+
runtime into the addon, which 1.5.4's prebuilds left undefined. (#305)
|
|
82
|
+
|
|
83
|
+
## [0.6.4] - 2026-09-30
|
|
84
|
+
|
|
85
|
+
### Removed
|
|
86
|
+
|
|
87
|
+
- The collabora office adapter and its `@qvac/core/rag/extract/office` export.
|
|
88
|
+
Office extraction is `extractOfficeText` from `@qvac/harness/office`, passed
|
|
89
|
+
through the `extractors.office` option. (#285)
|
|
90
|
+
|
|
16
91
|
## [0.6.3] - 2026-09-30
|
|
17
92
|
|
|
18
93
|
### Changed
|
|
@@ -1151,7 +1226,9 @@ Published under the `release-0.1` dist-tag.
|
|
|
1151
1226
|
await assistant.ready()
|
|
1152
1227
|
```
|
|
1153
1228
|
|
|
1154
|
-
[Unreleased]: https://github.com/tetherto/qvac-core/compare/v0.6.
|
|
1229
|
+
[Unreleased]: https://github.com/tetherto/qvac-core/compare/v0.6.5...HEAD
|
|
1230
|
+
[0.6.5]: https://github.com/tetherto/qvac-core/compare/v0.6.4...v0.6.5
|
|
1231
|
+
[0.6.4]: https://github.com/tetherto/qvac-core/compare/v0.6.3...v0.6.4
|
|
1155
1232
|
[0.6.3]: https://github.com/tetherto/qvac-core/compare/v0.6.2...v0.6.3
|
|
1156
1233
|
[0.6.2]: https://github.com/tetherto/qvac-core/compare/v0.6.1...v0.6.2
|
|
1157
1234
|
[0.6.1]: https://github.com/tetherto/qvac-core/compare/v0.6.0...v0.6.1
|
package/README.md
CHANGED
|
@@ -339,11 +339,25 @@ A chat IS its chunk stream — one watch drives the whole view, and every
|
|
|
339
339
|
device renders the same thing because they all see the same chunks:
|
|
340
340
|
|
|
341
341
|
```js
|
|
342
|
-
|
|
342
|
+
const rows = new Map()
|
|
343
|
+
for await (const { reset, chunks = [], removed = [] } of engine.chunksDeltaWatch({
|
|
344
|
+
meshId,
|
|
345
|
+
chatId
|
|
346
|
+
})) {
|
|
347
|
+
if (reset) rows.clear()
|
|
348
|
+
for (const id of removed) rows.delete(id)
|
|
349
|
+
for (const chunk of chunks) rows.set(chunk.id, chunk)
|
|
350
|
+
render([...rows.values()].sort((a, b) => a.seq - b.seq))
|
|
351
|
+
}
|
|
343
352
|
```
|
|
344
353
|
|
|
345
|
-
|
|
346
|
-
|
|
354
|
+
The first frame is the whole chat; after that each frame carries only the rows
|
|
355
|
+
that changed, so a long streamed answer costs one row per chunk rather than the
|
|
356
|
+
whole chat each time. `chunksWatch` takes the same request and sends the full
|
|
357
|
+
list on every change, for a reader that wants it that way. A view over a long
|
|
358
|
+
chat also opens on a page and watches from its floor — see
|
|
359
|
+
[`chunksDeltaWatch`](docs/api/chunks.md#chunksdeltawatch). To render the rows,
|
|
360
|
+
group chunks into turns, then map each chunk type:
|
|
347
361
|
|
|
348
362
|
**Grouping.** A `user-message` (and an `attachment`) is its own user turn —
|
|
349
363
|
label it by `originDeviceId`, resolved to a name via `devicesWatch`. Every
|
|
@@ -551,7 +565,9 @@ contract:
|
|
|
551
565
|
the fetch — there is no fetch-then-subscribe race to paper over, ever.
|
|
552
566
|
- **Later frames arrive only on real change** (identical snapshots are
|
|
553
567
|
deduped server-side), and each frame is the full current result, not a
|
|
554
|
-
delta.
|
|
568
|
+
delta. The one exception says so in its name: `chunksDeltaWatch` sends a
|
|
569
|
+
`reset` first and the changed rows after it, and its reset is still the
|
|
570
|
+
snapshot.
|
|
555
571
|
- **`destroy()` is the unsubscribe** (ending a `for await` does the same
|
|
556
572
|
thing). Nothing else to call, no registry to clean up — in any process,
|
|
557
573
|
over any transport.
|
|
@@ -687,18 +703,10 @@ feature checklist vs core v1.
|
|
|
687
703
|
|
|
688
704
|
### Office documents
|
|
689
705
|
|
|
690
|
-
Word-processor documents (`.docx`, `.doc`,
|
|
691
|
-
`.
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
fetch the one for this machine before exercising `/knowledge add report.docx`:
|
|
695
|
-
|
|
696
|
-
```sh
|
|
697
|
-
bun run engine:collabora
|
|
698
|
-
```
|
|
699
|
-
|
|
700
|
-
**There is no equivalent for an installed `duck`.** Nothing fetches the engine
|
|
701
|
-
for you, so those formats fail to index outside this repo, even though
|
|
706
|
+
Core ships no office decoder. Word-processor documents (`.docx`, `.doc`,
|
|
707
|
+
`.odt`, …) index only when the host passes one through the `extractors.office`
|
|
708
|
+
option — the app injects `extractOfficeText` from `@qvac/harness/office`.
|
|
709
|
+
`duck` injects none, so those formats fail to index there even though
|
|
702
710
|
`/knowledge add` accepts them. Everything else it accepts — `.pdf`, `.txt`,
|
|
703
711
|
`.md`, `.rtf`, `.html`, `.csv`, `.json` and the rest — works from any install.
|
|
704
712
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { watchable } from './watchable.js';
|
|
2
|
+
export function createChatMoveApi(moves) {
|
|
3
|
+
return {
|
|
4
|
+
moveChatToMesh: (request) => moves.move(request),
|
|
5
|
+
chatMoveWatch: watchable(() => moves, (request, store) => store.status(request), { name: 'chatMoveWatch' })
|
|
6
|
+
};
|
|
7
|
+
}
|
|
@@ -2,7 +2,7 @@ import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
|
2
2
|
import type { openLocalStore } from '../core/local/index.ts';
|
|
3
3
|
import { type MeshPool } from './current-mesh.ts';
|
|
4
4
|
type LocalStore = ReturnType<typeof openLocalStore>;
|
|
5
|
-
type ChatCapabilities = Pick<CapabilityHandlers, 'createChat' | 'listChats' | 'getChat' | 'renameChat' | 'markChatRead' | 'setChatRagEnabled' | 'setChatWebSearchEnabled' | 'deleteChat' | 'chatsWatch' | 'listChatActivity' | 'chatActivityWatch' | 'searchChats'>;
|
|
5
|
+
type ChatCapabilities = Pick<CapabilityHandlers, 'createChat' | 'listChats' | 'getChat' | 'renameChat' | 'markChatRead' | 'setChatAgent' | 'setChatRagEnabled' | 'setChatWebSearchEnabled' | 'deleteChat' | 'chatsWatch' | 'listChatActivity' | 'chatActivityWatch' | 'searchChats'>;
|
|
6
6
|
export interface CreateChatApiOptions {
|
|
7
7
|
readonly deviceId: Buffer | null;
|
|
8
8
|
readonly inferenceCalls?: {
|
package/dist-lib/lib/api/chat.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbortController } from 'bare-abort-controller';
|
|
2
|
-
import { createChat, deleteChat, markChatRead, mustGetActiveChatListing, renameChat, setChatRagEnabled, setChatWebSearchEnabled } from '../core/chat.js';
|
|
2
|
+
import { createChat, deleteChat, markChatRead, mustGetActiveChatListing, renameChat, setChatAgent, setChatRagEnabled, setChatWebSearchEnabled } from '../core/chat.js';
|
|
3
3
|
import { listChatActivity } from '../core/chat-activity.js';
|
|
4
4
|
import { listChatPage } from '../core/chat-order.js';
|
|
5
5
|
import { searchChats } from '../core/chat-search.js';
|
|
@@ -15,6 +15,7 @@ export function createChatApi(pool, local, { deviceId, inferenceCalls = null })
|
|
|
15
15
|
getChat: async ({ chatId, meshId }) => mustGetActiveChatListing(await requireMesh(pool, meshId), chatId),
|
|
16
16
|
renameChat: async ({ chatId, meshId, config }) => renameChat(await requireMesh(pool, meshId), chatId, config.title),
|
|
17
17
|
markChatRead: async ({ chatId, meshId }) => markChatRead(await requireMesh(pool, meshId), chatId),
|
|
18
|
+
setChatAgent: async ({ chatId, agentId, meshId }) => setChatAgent(await requireMesh(pool, meshId), chatId, agentId),
|
|
18
19
|
setChatRagEnabled: async ({ chatId, enabled, meshId }) => setChatRagEnabled(await requireMesh(pool, meshId), chatId, { ragEnabled: enabled ?? false }),
|
|
19
20
|
setChatWebSearchEnabled: async ({ chatId, enabled, meshId }) => setChatWebSearchEnabled(await requireMesh(pool, meshId), chatId, enabled ?? false),
|
|
20
21
|
deleteChat: async ({ chatId, meshId }) => {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Readable } from 'streamx';
|
|
2
|
+
import type { AssistantChunk, AssistantChunkDelta, AssistantChunkList } from '../../spec/hyperschema/types.d.ts';
|
|
3
|
+
import type { WatchStream } from '../../spec/capabilities.d.ts';
|
|
4
|
+
type Rows = ReadonlyMap<string, AssistantChunk>;
|
|
5
|
+
export declare function chunkDelta(prev: Rows | null, next: ReadonlyArray<AssistantChunk>): AssistantChunkDelta;
|
|
6
|
+
export declare function chunkDeltaStream(lists: Readable & AsyncIterable<AssistantChunkList>): Readable & WatchStream<AssistantChunkDelta>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { pipeline, Transform } from 'streamx';
|
|
2
|
+
import { frameReadable } from '../frame-readable.js';
|
|
3
|
+
import { snapshotEquals } from './watchable.js';
|
|
4
|
+
export function chunkDelta(prev, next) {
|
|
5
|
+
const count = next.length;
|
|
6
|
+
if (prev === null) {
|
|
7
|
+
return { reset: true, chunks: [...next], removed: [], count };
|
|
8
|
+
}
|
|
9
|
+
const upserts = next.filter((chunk) => !snapshotEquals(chunk, prev.get(chunk.id)));
|
|
10
|
+
const kept = new Set(next.map((chunk) => chunk.id));
|
|
11
|
+
const removed = [...prev.keys()].filter((id) => !kept.has(id));
|
|
12
|
+
if (upserts.length + removed.length > count / 2) {
|
|
13
|
+
return { reset: true, chunks: [...next], removed: [], count };
|
|
14
|
+
}
|
|
15
|
+
return { reset: false, chunks: upserts, removed, count };
|
|
16
|
+
}
|
|
17
|
+
export function chunkDeltaStream(lists) {
|
|
18
|
+
let prev = null;
|
|
19
|
+
const deltas = new Transform({
|
|
20
|
+
transform(list, cb) {
|
|
21
|
+
const next = list.chunks ?? [];
|
|
22
|
+
const delta = chunkDelta(prev, next);
|
|
23
|
+
prev = new Map(next.map((chunk) => [chunk.id, chunk]));
|
|
24
|
+
if (!delta.reset && delta.chunks?.length === 0 && delta.removed?.length === 0) {
|
|
25
|
+
cb(null);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
cb(null, delta);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return frameReadable(pipeline(lists, deltas, noop));
|
|
32
|
+
}
|
|
33
|
+
function noop() { }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type MeshPool } from './current-mesh.ts';
|
|
2
2
|
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
3
|
-
type ChunkCapabilities = Pick<CapabilityHandlers, 'appendChunk' | 'updateChunk' | 'resolveApproval' | 'listChunks' | 'listAttachmentsByKind' | 'chunksWatch' | 'runRequestsWatch'>;
|
|
3
|
+
type ChunkCapabilities = Pick<CapabilityHandlers, 'appendChunk' | 'updateChunk' | 'resolveApproval' | 'listChunks' | 'listAttachmentsByKind' | 'chunksWatch' | 'chunksDeltaWatch' | 'runRequestsWatch'>;
|
|
4
4
|
export declare function createChunksApi(pool: MeshPool, deviceId: Buffer | null): ChunkCapabilities;
|
|
5
5
|
export {};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { appendChunk, listAttachmentsByKind, listChunks, listRunRequests, recordLinks, resolveApproval, updateChunk } from '../core/chunk.js';
|
|
2
|
+
import { chunkDeltaStream } from './chunk-delta.js';
|
|
2
3
|
import { meshWatchable, requireMesh } from './current-mesh.js';
|
|
3
4
|
import { bounds } from './range.js';
|
|
4
5
|
export function createChunksApi(pool, deviceId) {
|
|
6
|
+
const chunksWatch = meshWatchable(pool, async ({ meshId, ...input }, mesh) => ({
|
|
7
|
+
chunks: await recordLinks(mesh, await listChunks(mesh, chunkSelection(input)))
|
|
8
|
+
}), { name: 'chunksWatch' });
|
|
5
9
|
return {
|
|
6
10
|
appendChunk: async ({ meshId, ...input }) => appendChunk(await requireMesh(pool, meshId), input),
|
|
7
11
|
updateChunk: async ({ meshId, chunkId, runStatus }) => {
|
|
@@ -31,9 +35,8 @@ export function createChunksApi(pool, deviceId) {
|
|
|
31
35
|
});
|
|
32
36
|
return { chunks: await recordLinks(mesh, chunks) };
|
|
33
37
|
},
|
|
34
|
-
chunksWatch
|
|
35
|
-
|
|
36
|
-
}), { name: 'chunksWatch' }),
|
|
38
|
+
chunksWatch,
|
|
39
|
+
chunksDeltaWatch: (request) => chunkDeltaStream(chunksWatch(request)),
|
|
37
40
|
runRequestsWatch: meshWatchable(pool, async (_request, mesh) => ({ chunks: await listRunRequests(mesh, deviceId) }), { name: 'runRequestsWatch' })
|
|
38
41
|
};
|
|
39
42
|
}
|
|
@@ -3,6 +3,7 @@ import type { AssistantCapabilityProfile, AssistantClearModelDownloadRequest, As
|
|
|
3
3
|
import type { openLocalStore } from '../core/local/index.ts';
|
|
4
4
|
import type { Mesh } from '../core/mesh.ts';
|
|
5
5
|
import type { MeshPool } from './current-mesh.ts';
|
|
6
|
+
import type { ChatMoves } from '../core/chat-move.ts';
|
|
6
7
|
import { type DiagnosticsSource } from './diagnostics.ts';
|
|
7
8
|
import { type InferenceCallReader } from './inference-calls.ts';
|
|
8
9
|
import { type LogSource } from './logs.ts';
|
|
@@ -17,6 +18,7 @@ interface ApiDeps {
|
|
|
17
18
|
network?: NetworkSource | null;
|
|
18
19
|
diagnostics?: DiagnosticsSource | null;
|
|
19
20
|
inferenceCalls?: InferenceCallReader | null;
|
|
21
|
+
chatMoves?: ChatMoves | null;
|
|
20
22
|
logs?: LogSource | null;
|
|
21
23
|
deviceId?: Buffer | null;
|
|
22
24
|
lifecycle?: {
|
|
@@ -5,6 +5,7 @@ import { createAgentsApi } from './agents.js';
|
|
|
5
5
|
import { createApprovalRulesApi } from './approval-rules.js';
|
|
6
6
|
import { createAttachmentsApi } from './attachments.js';
|
|
7
7
|
import { createChatApi } from './chat.js';
|
|
8
|
+
import { createChatMoveApi } from './chat-move.js';
|
|
8
9
|
import { createChatGroupsApi } from './chat-groups.js';
|
|
9
10
|
import { createChunksApi } from './chunks.js';
|
|
10
11
|
import { createAppConfigApi } from './app-config.js';
|
|
@@ -50,6 +51,7 @@ export function createApi(deps = {}) {
|
|
|
50
51
|
inferenceCalls: deps.inferenceCalls ?? null
|
|
51
52
|
})
|
|
52
53
|
: null),
|
|
54
|
+
...(deps.chatMoves ? createChatMoveApi(deps.chatMoves) : null),
|
|
53
55
|
...(mesh ? createChatGroupsApi(mesh) : null),
|
|
54
56
|
...(mesh ? createApprovalRulesApi(mesh) : null),
|
|
55
57
|
...(mesh ? createChunksApi(mesh, deps.deviceId ?? null) : null),
|
|
@@ -24,6 +24,7 @@ export interface MeshStatusSource {
|
|
|
24
24
|
open(meshId: string): Promise<void>;
|
|
25
25
|
close(meshId: string): Promise<void>;
|
|
26
26
|
label(meshId: string, label: string): Promise<void>;
|
|
27
|
+
name(meshId: string, name: string): Promise<void>;
|
|
27
28
|
createMesh(opts?: {
|
|
28
29
|
compute?: boolean;
|
|
29
30
|
}): Promise<string>;
|
|
@@ -35,4 +36,4 @@ export interface MeshStatusSource {
|
|
|
35
36
|
recover(phrase: string, timeout?: number): Promise<void>;
|
|
36
37
|
displayName(): Promise<string | null>;
|
|
37
38
|
}
|
|
38
|
-
export declare function createMeshApi(status: MeshStatusSource, updateMember: CapabilityHandlers['updateMember']): Pick<CapabilityHandlers, 'meshStatusWatch' | 'listMeshes' | 'meshesWatch' | 'account' | 'accountWatch' | 'openMesh' | 'closeMesh' | 'leaveMesh' | 'acknowledgeKicked' | 'joinMesh' | 'cancelMeshJoin' | 'meshInvite' | 'previewMeshInvite' | 'setMeshLabel' | 'createMesh' | 'createRoom' | 'listArchivedMeshes' | 'archivedMeshContents' | 'migrateArchivedMesh' | 'accountRecoverable' | 'recoveryPublish' | 'recoverAccount' | 'displayName' | 'setDisplayName'>;
|
|
39
|
+
export declare function createMeshApi(status: MeshStatusSource, updateMember: CapabilityHandlers['updateMember']): Pick<CapabilityHandlers, 'meshStatusWatch' | 'listMeshes' | 'meshesWatch' | 'account' | 'accountWatch' | 'openMesh' | 'closeMesh' | 'leaveMesh' | 'acknowledgeKicked' | 'joinMesh' | 'cancelMeshJoin' | 'meshInvite' | 'previewMeshInvite' | 'setMeshLabel' | 'setMeshName' | 'createMesh' | 'createRoom' | 'listArchivedMeshes' | 'archivedMeshContents' | 'migrateArchivedMesh' | 'accountRecoverable' | 'recoveryPublish' | 'recoverAccount' | 'displayName' | 'setDisplayName'>;
|
package/dist-lib/lib/api/mesh.js
CHANGED
|
@@ -37,6 +37,10 @@ export function createMeshApi(status, updateMember) {
|
|
|
37
37
|
await status.label(meshId, label ?? '');
|
|
38
38
|
return { ok: true };
|
|
39
39
|
},
|
|
40
|
+
setMeshName: async ({ meshId, name }) => {
|
|
41
|
+
await status.name(meshId, name ?? '');
|
|
42
|
+
return { ok: true };
|
|
43
|
+
},
|
|
40
44
|
createMesh: async (request) => ({
|
|
41
45
|
meshId: await status.createMesh({ compute: request?.config?.compute })
|
|
42
46
|
}),
|
|
@@ -74,6 +74,12 @@ export interface DeviceCapability {
|
|
|
74
74
|
export interface ImageProgress {
|
|
75
75
|
readonly percentage: number;
|
|
76
76
|
}
|
|
77
|
+
export interface FetchAttachmentOptions {
|
|
78
|
+
readonly attachmentId?: string;
|
|
79
|
+
readonly kind?: 'image' | 'audio';
|
|
80
|
+
readonly signal?: AbortSignal;
|
|
81
|
+
readonly meta?: boolean;
|
|
82
|
+
}
|
|
77
83
|
export interface Harness {
|
|
78
84
|
completion(context: {
|
|
79
85
|
model: string;
|
|
@@ -111,11 +117,7 @@ export interface Harness {
|
|
|
111
117
|
};
|
|
112
118
|
approve?: (call: ApprovalCall) => Promise<boolean>;
|
|
113
119
|
attach?: (input: AttachInput) => Promise<AssistantChunkContentAttachment>;
|
|
114
|
-
fetchAttachment?: (query:
|
|
115
|
-
attachmentId?: string;
|
|
116
|
-
signal?: AbortSignal;
|
|
117
|
-
meta?: boolean;
|
|
118
|
-
}) => Promise<FetchedAttachment | AttachmentMeta | null>;
|
|
120
|
+
fetchAttachment?: (query: FetchAttachmentOptions) => Promise<FetchedAttachment | AttachmentMeta | null>;
|
|
119
121
|
ragSearch?: (input: {
|
|
120
122
|
query: string;
|
|
121
123
|
limit?: number;
|
|
@@ -140,11 +142,7 @@ export interface Harness {
|
|
|
140
142
|
enhance?: AssistantEnhanceMode;
|
|
141
143
|
agent?: AssistantAgent;
|
|
142
144
|
attach?: (input: AttachInput) => Promise<AssistantChunkContentAttachment>;
|
|
143
|
-
fetchAttachment?: (query:
|
|
144
|
-
attachmentId?: string;
|
|
145
|
-
signal?: AbortSignal;
|
|
146
|
-
meta?: boolean;
|
|
147
|
-
}) => Promise<FetchedAttachment | AttachmentMeta | null>;
|
|
145
|
+
fetchAttachment?: (query: FetchAttachmentOptions) => Promise<FetchedAttachment | AttachmentMeta | null>;
|
|
148
146
|
progress?: (update: ImageProgress | null) => void;
|
|
149
147
|
signal?: AbortSignal;
|
|
150
148
|
}): AsyncIterable<HarnessEvent>;
|
|
@@ -987,7 +987,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
987
987
|
_dropDeletedChat(chatId) {
|
|
988
988
|
for (const run of this._runs.values()) {
|
|
989
989
|
if (run.chatId === chatId) {
|
|
990
|
-
|
|
990
|
+
run.controller.abort(RUN_SETTLED);
|
|
991
991
|
}
|
|
992
992
|
}
|
|
993
993
|
this._reconciledCompactions.delete(chatId);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { COMPACTION_MIN_CTX_SIZE, contextOptionsForModel, DEFAULT_CONTEXT_SIZE, defaultContextForModel, formatTokenCount, MODEL_CONTEXT_TARGET, type ModelContextTarget, maxContextForModel, modelContextTargetForPlatform } from './model-context.ts';
|
|
2
|
+
export declare const PENDING_BLOB_REFERENCE = "{\"pending\":true}";
|
|
2
3
|
export declare const CANCELED_CHAT_MESSAGE = "Stopped the current run. Send a follow-up to steer the next step.";
|
|
3
4
|
export declare const HOMEBREW_BIN_DIRS: ReadonlyArray<string>;
|
|
4
5
|
export declare const SAFE_BIN_NAME: RegExp;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { COMPACTION_MIN_CTX_SIZE, contextOptionsForModel, DEFAULT_CONTEXT_SIZE, defaultContextForModel, formatTokenCount, MODEL_CONTEXT_TARGET, maxContextForModel, modelContextTargetForPlatform } from './model-context.js';
|
|
2
|
+
export const PENDING_BLOB_REFERENCE = '{"pending":true}';
|
|
2
3
|
export const CANCELED_CHAT_MESSAGE = 'Stopped the current run. Send a follow-up to steer the next step.';
|
|
3
4
|
export const HOMEBREW_BIN_DIRS = ['/opt/homebrew/bin', '/usr/local/bin'];
|
|
4
5
|
export const SAFE_BIN_NAME = /^[A-Za-z0-9._-]+$/;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import crypto from 'hypercore-crypto';
|
|
2
|
-
import {
|
|
2
|
+
import { copyBlob, copyChunks, stripped } from './chat-copy.js';
|
|
3
3
|
import { Mesh } from './mesh.js';
|
|
4
|
-
import { ACTIVE_AGENTS, ACTIVE_CHATS, ACTIVE_CHAT_GROUPS, ACTIVE_TOOL_CONFIGS_BY_AGENT, AGENTS,
|
|
4
|
+
import { ACTIVE_AGENTS, ACTIVE_CHATS, ACTIVE_CHAT_GROUPS, ACTIVE_TOOL_CONFIGS_BY_AGENT, AGENTS, KNOWLEDGE } from './collections.js';
|
|
5
5
|
const MIGRATED_SUFFIX = ' (migrated)';
|
|
6
6
|
export const NO_ARCHIVE_HELD = 'No archive is held for this mesh';
|
|
7
7
|
export async function withArchivedMesh(row, opts, fn) {
|
|
@@ -68,7 +68,7 @@ export async function migrateContents(from, into) {
|
|
|
68
68
|
}
|
|
69
69
|
await batch.flush();
|
|
70
70
|
for (const chat of chats) {
|
|
71
|
-
await
|
|
71
|
+
await copyChunks(snap, chat.id, { from, into });
|
|
72
72
|
}
|
|
73
73
|
let carried = 0;
|
|
74
74
|
for (const row of knowledge) {
|
|
@@ -114,45 +114,6 @@ async function migrateAgents(snap, into, batch) {
|
|
|
114
114
|
async function alreadyHeld(into, row) {
|
|
115
115
|
return !!(await into.view.get(AGENTS, { id: row.id }));
|
|
116
116
|
}
|
|
117
|
-
async function migrateChunks(snap, chatId, { from, into }) {
|
|
118
|
-
const chunks = await snap
|
|
119
|
-
.find(CHUNKS_BY_CHAT, { gte: { chatId }, lte: { chatId } })
|
|
120
|
-
.toArray();
|
|
121
|
-
const batch = into.batch();
|
|
122
|
-
for (const chunk of chunks) {
|
|
123
|
-
if (await into.view.get(CHUNKS, { id: chunk.id }))
|
|
124
|
-
continue;
|
|
125
|
-
const { seq, updatedAt, attachment, ...op } = stripped(chunk);
|
|
126
|
-
if (!attachment) {
|
|
127
|
-
batch.dispatch('append-chunk', op);
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
const blobId = await copyBlob(from, into, attachment.blobId);
|
|
131
|
-
if (!blobId) {
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
batch.dispatch('append-chunk', { ...op, attachment: { ...attachment, blobId } });
|
|
135
|
-
await batch.flush();
|
|
136
|
-
await into.fileIndex?.record([{ ...chunk, attachment: { ...attachment, blobId } }]);
|
|
137
|
-
}
|
|
138
|
-
await batch.flush();
|
|
139
|
-
}
|
|
140
|
-
async function copyBlob(from, into, reference) {
|
|
141
|
-
if (parseBlobReferenceCoreKey(reference) === undefined)
|
|
142
|
-
return reference;
|
|
143
|
-
let bytes;
|
|
144
|
-
try {
|
|
145
|
-
bytes = await from.files.readBytes(reference, { wait: false });
|
|
146
|
-
}
|
|
147
|
-
catch {
|
|
148
|
-
return null;
|
|
149
|
-
}
|
|
150
|
-
return (await into.files.put(bytes)).reference;
|
|
151
|
-
}
|
|
152
|
-
function stripped(row) {
|
|
153
|
-
const { version: _version, ...rest } = row;
|
|
154
|
-
return rest;
|
|
155
|
-
}
|
|
156
117
|
async function liveKnowledge(snap) {
|
|
157
118
|
const rows = await snap.find(KNOWLEDGE).toArray();
|
|
158
119
|
return rows.filter((row) => !row.deletedAt);
|
|
@@ -25,15 +25,22 @@ class ChatActivityCatalog {
|
|
|
25
25
|
_lock;
|
|
26
26
|
_chats;
|
|
27
27
|
_head;
|
|
28
|
+
_forwards;
|
|
28
29
|
constructor() {
|
|
29
30
|
this._lock = new ScopeLock();
|
|
30
31
|
this._chats = new Map();
|
|
31
32
|
this._head = null;
|
|
33
|
+
this._forwards = 0;
|
|
32
34
|
}
|
|
33
35
|
async list(store, chatIds) {
|
|
34
36
|
await this._lock.lock();
|
|
35
37
|
try {
|
|
36
38
|
const head = store.view.db.head();
|
|
39
|
+
const forwards = store.autobee.stats.fastForwards;
|
|
40
|
+
if (forwards !== this._forwards) {
|
|
41
|
+
this._head = null;
|
|
42
|
+
}
|
|
43
|
+
this._forwards = forwards;
|
|
37
44
|
const snap = store.view.snapshot();
|
|
38
45
|
try {
|
|
39
46
|
const chats = await snap.find(ACTIVE_CHATS).toArray();
|
|
@@ -95,17 +102,23 @@ class ChatActivityCatalog {
|
|
|
95
102
|
}
|
|
96
103
|
async _applyChanges(snap, from, activeChatIds) {
|
|
97
104
|
const chunksByChat = new Map();
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
try {
|
|
106
|
+
for await (const change of snap.changes({ from })) {
|
|
107
|
+
if (change.collection !== CHUNKS)
|
|
108
|
+
continue;
|
|
109
|
+
if (change.type === 'delete')
|
|
110
|
+
return false;
|
|
111
|
+
if (!activeChatIds.has(change.value.chatId)) {
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
const chunks = chunksByChat.get(change.value.chatId) ?? [];
|
|
115
|
+
chunks.push(change.value);
|
|
116
|
+
chunksByChat.set(change.value.chatId, chunks);
|
|
105
117
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
118
|
+
}
|
|
119
|
+
catch (err) {
|
|
120
|
+
logger.warn('chat-activity', 'diff from the cached head failed, rebuilding', err);
|
|
121
|
+
return false;
|
|
109
122
|
}
|
|
110
123
|
for (const [chatId, chunks] of chunksByChat) {
|
|
111
124
|
const activity = this._chats.get(chatId);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type HyperDB from 'hyperdb';
|
|
2
|
+
import type { Mesh } from './mesh.ts';
|
|
3
|
+
export interface MeshCopy {
|
|
4
|
+
readonly from: Mesh;
|
|
5
|
+
readonly into: Mesh;
|
|
6
|
+
}
|
|
7
|
+
export interface ChatMoveCopy extends MeshCopy {
|
|
8
|
+
readonly chatId: string;
|
|
9
|
+
readonly originDeviceId: Buffer;
|
|
10
|
+
readonly references: Map<string, string>;
|
|
11
|
+
}
|
|
12
|
+
export declare const CHUNK_IN_ANOTHER_CHAT = "the target already holds this chat under another id";
|
|
13
|
+
export declare function copyChunks(snap: HyperDB, chatId: string, { from, into }: MeshCopy): Promise<void>;
|
|
14
|
+
export declare function copyMovedChunks(snap: HyperDB, chatId: string, copy: ChatMoveCopy): Promise<number>;
|
|
15
|
+
export declare function copyMovedKnowledge(snap: HyperDB, chatId: string, copy: ChatMoveCopy): Promise<void>;
|
|
16
|
+
export declare function movedBlob({ from, into, references }: ChatMoveCopy, { blobId }: BlobHolder): Promise<string>;
|
|
17
|
+
interface BlobHolder {
|
|
18
|
+
readonly blobId: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function copyBlob(from: Mesh, into: Mesh, reference: string): Promise<string | null>;
|
|
21
|
+
export declare function stripped<T extends {
|
|
22
|
+
version?: number;
|
|
23
|
+
}>(row: T): Omit<T, 'version'>;
|
|
24
|
+
export {};
|