@qvac/core 0.3.5 → 0.4.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 +177 -9
- package/README.md +19 -17
- package/dist-lib/lib/api/agents.d.ts +3 -3
- package/dist-lib/lib/api/agents.js +31 -20
- package/dist-lib/lib/api/approval-rules.d.ts +2 -2
- package/dist-lib/lib/api/approval-rules.js +2 -2
- package/dist-lib/lib/api/attachments.d.ts +2 -2
- package/dist-lib/lib/api/attachments.js +14 -25
- package/dist-lib/lib/api/chat-groups.d.ts +2 -2
- package/dist-lib/lib/api/chat-groups.js +9 -9
- package/dist-lib/lib/api/chat.d.ts +4 -2
- package/dist-lib/lib/api/chat.js +18 -18
- package/dist-lib/lib/api/chunks.d.ts +2 -2
- package/dist-lib/lib/api/chunks.js +27 -36
- package/dist-lib/lib/api/current-mesh.d.ts +7 -15
- package/dist-lib/lib/api/current-mesh.js +7 -22
- package/dist-lib/lib/api/devices.d.ts +4 -3
- package/dist-lib/lib/api/devices.js +18 -18
- package/dist-lib/lib/api/execution.d.ts +2 -2
- package/dist-lib/lib/api/execution.js +6 -6
- package/dist-lib/lib/api/files.d.ts +2 -2
- package/dist-lib/lib/api/files.js +4 -4
- package/dist-lib/lib/api/index.d.ts +12 -11
- package/dist-lib/lib/api/index.js +15 -13
- package/dist-lib/lib/api/inference-calls.d.ts +1 -1
- package/dist-lib/lib/api/inference-calls.js +2 -2
- package/dist-lib/lib/api/knowledge.d.ts +2 -2
- package/dist-lib/lib/api/knowledge.js +22 -11
- package/dist-lib/lib/api/local-files.d.ts +3 -0
- package/dist-lib/lib/api/local-files.js +23 -0
- package/dist-lib/lib/api/members.d.ts +6 -2
- package/dist-lib/lib/api/members.js +24 -17
- package/dist-lib/lib/api/mesh.d.ts +4 -5
- package/dist-lib/lib/api/mesh.js +7 -9
- package/dist-lib/lib/api/notifications.d.ts +2 -13
- package/dist-lib/lib/api/notifications.js +20 -52
- package/dist-lib/lib/api/rag.d.ts +2 -2
- package/dist-lib/lib/api/rag.js +4 -4
- package/dist-lib/lib/api/range.d.ts +11 -0
- package/dist-lib/lib/api/range.js +10 -0
- package/dist-lib/lib/api/sync.d.ts +2 -2
- package/dist-lib/lib/api/sync.js +3 -3
- package/dist-lib/lib/api/tool-activity.d.ts +2 -2
- package/dist-lib/lib/api/tool-activity.js +11 -10
- package/dist-lib/lib/api/tool-configs.d.ts +2 -2
- package/dist-lib/lib/api/tool-configs.js +6 -7
- package/dist-lib/lib/api/upload-frames.d.ts +9 -0
- package/dist-lib/lib/api/upload-frames.js +17 -0
- package/dist-lib/lib/api/watchable.d.ts +1 -6
- package/dist-lib/lib/api/watchable.js +4 -13
- package/dist-lib/lib/assistant/history.d.ts +3 -3
- package/dist-lib/lib/assistant-client.js +3 -2
- package/dist-lib/lib/assistant-tree.js +1 -1
- package/dist-lib/lib/assistant.d.ts +16 -14
- package/dist-lib/lib/assistant.js +166 -137
- package/dist-lib/lib/collabora/convert.js +1 -1
- package/dist-lib/lib/core/agent.d.ts +5 -7
- package/dist-lib/lib/core/agent.js +26 -6
- package/dist-lib/lib/core/archived-mesh.js +1 -0
- package/dist-lib/lib/core/chat-order.d.ts +20 -0
- package/dist-lib/lib/core/chat-order.js +96 -0
- package/dist-lib/lib/core/chat.d.ts +0 -5
- package/dist-lib/lib/core/chat.js +1 -3
- package/dist-lib/lib/core/chunk.d.ts +7 -14
- package/dist-lib/lib/core/chunk.js +17 -35
- package/dist-lib/lib/core/contract/agents.js +8 -0
- package/dist-lib/lib/core/contract/compute.d.ts +1 -1
- package/dist-lib/lib/core/contract/compute.js +1 -0
- package/dist-lib/lib/core/contract/joined-meshes.js +4 -3
- package/dist-lib/lib/core/contract/members.js +4 -3
- package/dist-lib/lib/core/contract/writers.js +5 -4
- package/dist-lib/lib/core/departures.js +5 -4
- package/dist-lib/lib/core/device-invites.js +2 -1
- package/dist-lib/lib/core/files/attachments.d.ts +8 -1
- package/dist-lib/lib/core/files/index.d.ts +4 -4
- package/dist-lib/lib/core/files/index.js +18 -8
- package/dist-lib/lib/core/files/local-index.d.ts +16 -0
- package/dist-lib/lib/core/files/local-index.js +38 -0
- package/dist-lib/lib/core/files/processing/document.js +2 -1
- package/dist-lib/lib/core/files/processing/ownership.js +6 -3
- package/dist-lib/lib/core/files/records/chunks.js +1 -0
- package/dist-lib/lib/core/files/records/reclaim.js +1 -0
- package/dist-lib/lib/core/files/records/routing.js +2 -1
- package/dist-lib/lib/core/files/store/blob.d.ts +1 -1
- package/dist-lib/lib/core/files/store/blob.js +6 -3
- package/dist-lib/lib/core/files/store/index.d.ts +1 -1
- package/dist-lib/lib/core/files/store/reference.js +4 -3
- package/dist-lib/lib/core/files/store/server.d.ts +8 -4
- package/dist-lib/lib/core/files/store/server.js +16 -12
- package/dist-lib/lib/core/files/store/sweep.js +2 -1
- package/dist-lib/lib/core/files/upload.d.ts +1 -1
- package/dist-lib/lib/core/hosted-agents.js +1 -1
- package/dist-lib/lib/core/image/cache-sweep.d.ts +1 -0
- package/dist-lib/lib/core/image/cache-sweep.js +7 -3
- package/dist-lib/lib/core/local/files.d.ts +24 -0
- package/dist-lib/lib/core/local/files.js +154 -0
- package/dist-lib/lib/core/local/index.d.ts +21 -5
- package/dist-lib/lib/core/local/index.js +75 -45
- package/dist-lib/lib/core/membership.d.ts +4 -1
- package/dist-lib/lib/core/membership.js +17 -2
- package/dist-lib/lib/core/mesh.d.ts +5 -0
- package/dist-lib/lib/core/mesh.js +10 -5
- package/dist-lib/lib/core/migrations/agent-indexes.d.ts +2 -0
- package/dist-lib/lib/core/migrations/agent-indexes.js +30 -0
- package/dist-lib/lib/core/migrations/file-index.d.ts +2 -0
- package/dist-lib/lib/core/migrations/file-index.js +27 -0
- package/dist-lib/lib/core/migrations/index.js +3 -1
- package/dist-lib/lib/core/notification.js +5 -5
- package/dist-lib/lib/core/range.d.ts +18 -0
- package/dist-lib/lib/core/range.js +17 -0
- package/dist-lib/lib/core/sync/index.js +39 -32
- package/dist-lib/lib/core/sync-status.js +3 -2
- package/dist-lib/lib/core/tool-activity.d.ts +2 -5
- package/dist-lib/lib/core/tool-activity.js +4 -7
- package/dist-lib/lib/core.d.ts +48 -29
- package/dist-lib/lib/core.js +465 -359
- package/dist-lib/lib/knowledge-search.d.ts +2 -2
- package/dist-lib/lib/kv-cache.js +1 -1
- package/dist-lib/lib/log.js +2 -3
- package/dist-lib/lib/mesh-scoped-engine.d.ts +8 -1
- package/dist-lib/lib/mesh-scoped-engine.js +62 -15
- package/dist-lib/lib/model-download.d.ts +14 -5
- package/dist-lib/lib/model-download.js +25 -17
- package/dist-lib/lib/oauth/browser-connect.d.ts +0 -14
- package/dist-lib/lib/oauth/browser-connect.js +1 -26
- package/dist-lib/lib/oauth/token-exchange.d.ts +1 -2
- package/dist-lib/lib/oauth/token-exchange.js +1 -4
- package/dist-lib/lib/run-transcript.d.ts +2 -2
- package/dist-lib/lib/run-transcript.js +3 -2
- package/dist-lib/lib/task.d.ts +1 -0
- package/dist-lib/lib/task.js +3 -2
- package/dist-lib/schema/build.js +4 -10
- package/dist-lib/schema/engine.js +261 -91
- package/dist-lib/schema/field-order.js +1 -4
- package/dist-lib/schema/helpers.d.ts +4 -0
- package/dist-lib/schema/helpers.js +20 -0
- package/dist-lib/schema/local.d.ts +1 -1
- package/dist-lib/schema/local.js +70 -2
- package/dist-lib/schema/qvac.js +30 -0
- package/dist-lib/spec/bind.js +20 -3
- package/dist-lib/spec/calls.js +19 -15
- package/dist-lib/spec/capabilities.d.ts +42 -34
- package/dist-lib/spec/hrpc/hrpc.json +82 -30
- package/dist-lib/spec/hrpc/index.js +106 -57
- package/dist-lib/spec/hrpc/messages.js +5420 -5019
- package/dist-lib/spec/hyperschema/index.js +5424 -5023
- package/dist-lib/spec/hyperschema/schema.json +3202 -2666
- package/dist-lib/spec/hyperschema/types.d.ts +455 -319
- package/dist-lib/spec/local/hyperdb/db.json +119 -1
- package/dist-lib/spec/local/hyperdb/index.js +414 -2
- package/dist-lib/spec/local/hyperdb/messages.js +505 -124
- package/dist-lib/spec/local/hyperschema/index.js +203 -5
- package/dist-lib/spec/local/hyperschema/schema.json +136 -1
- package/dist-lib/spec/local/hyperschema/types.d.ts +32 -1
- package/dist-lib/spec/mesh/hyperdb/db.json +55 -3
- package/dist-lib/spec/mesh/hyperdb/index.js +119 -3
- package/dist-lib/spec/mesh/hyperdb/messages.js +244 -172
- 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 +74 -2
- package/dist-lib/spec/mesh/hyperschema/index.js +74 -2
- package/dist-lib/spec/mesh/hyperschema/schema.json +27 -1
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +9 -1
- package/package.json +15 -9
- package/tui/app.mjs +376 -151
- package/tui/boot.mjs +2 -1
- package/tui/lib/busy-words.mjs +2 -1
- package/tui/lib/knowledge-command.mjs +11 -10
- package/tui/lib/knowledge-import.mjs +7 -5
- package/tui/lib/render.mjs +4 -3
- package/tui/lib/usage.mjs +2 -1
- package/tui/main.mjs +2 -1
- package/tui/lib/projection-env.mjs +0 -24
package/CHANGELOG.md
CHANGED
|
@@ -13,13 +13,13 @@ release.
|
|
|
13
13
|
|
|
14
14
|
## [Unreleased]
|
|
15
15
|
|
|
16
|
-
## [0.
|
|
16
|
+
## [0.4.1] - 2026-09-25
|
|
17
17
|
|
|
18
18
|
### Changed
|
|
19
19
|
|
|
20
|
-
- `autobee` 2.11.
|
|
21
|
-
|
|
22
|
-
`
|
|
20
|
+
- `autobee` 2.11.5, which also reindexes its system view on boot, alongside the
|
|
21
|
+
strict reindex 0.4.0 brought in. `hyperbee2` is pinned to 2.18.0 and
|
|
22
|
+
`hyperdb` needs 6.9. (#230)
|
|
23
23
|
|
|
24
24
|
### Fixed
|
|
25
25
|
|
|
@@ -27,7 +27,7 @@ release.
|
|
|
27
27
|
this package's imports map, so `#abort-controller` did not resolve. Token
|
|
28
28
|
refresh now uses the runtime's own `AbortController`, and
|
|
29
29
|
`bare-abort-controller` only on Bare, which has none. React Native's `fetch`
|
|
30
|
-
gets a native signal too. (#231)
|
|
30
|
+
gets a native signal too. 0.4.0 and 0.3.4 are affected. (#231)
|
|
31
31
|
|
|
32
32
|
```js
|
|
33
33
|
// mobile: bundles again, nothing else changes
|
|
@@ -37,10 +37,178 @@ release.
|
|
|
37
37
|
const tokens = await oauth.refreshOAuthTokens(config, refreshToken)
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
## [0.
|
|
40
|
+
## [0.4.0] - 2026-09-24
|
|
41
|
+
|
|
42
|
+
### Added
|
|
43
|
+
|
|
44
|
+
- `account` and `accountWatch`: the account's `meshId`, whether it is writable,
|
|
45
|
+
and the user's display name, so a host no longer picks the account out of the
|
|
46
|
+
mesh list. The watch emits again after a kick or leave mints a new account.
|
|
47
|
+
(#155)
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
const { meshId, writable, displayName } = await engine.account({})
|
|
51
|
+
|
|
52
|
+
for await (const account of engine.accountWatch({})) {
|
|
53
|
+
showAccount(account.meshId, account.displayName)
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
- `listChats` and `chatsWatch` take `limit` and `cursor`, and the list carries
|
|
58
|
+
`nextCursor`. A limit returns the newest page, oldest-first inside it, and
|
|
59
|
+
`nextCursor` is set only while an older page exists. Leaving `limit` out
|
|
60
|
+
returns the whole list, as before. (#168)
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
let page = await engine.listChats({ meshId, limit: 50 })
|
|
64
|
+
render(page.chats)
|
|
65
|
+
while (page.nextCursor) {
|
|
66
|
+
page = await engine.listChats({ meshId, limit: 50, cursor: page.nextCursor })
|
|
67
|
+
renderAbove(page.chats)
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
- A device-local index of the files a device holds, served by `listLocalFiles`.
|
|
72
|
+
`Core.clearOldFiles({ olderThanMs, includeOwn })` clears the bytes of files
|
|
73
|
+
not read since a cutoff and resolves with how many it cleared. A later read
|
|
74
|
+
fetches them back. Your own uploads are kept unless `includeOwn` is `true`.
|
|
75
|
+
The `fileGc` Core option runs the same sweep on an interval, and is off
|
|
76
|
+
unless set. Files an older build left behind are backfilled once per mesh,
|
|
77
|
+
so they can be reclaimed too. (#183)
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
const DAY = 24 * 60 * 60 * 1000
|
|
81
|
+
const core = new Core(() => server, {
|
|
82
|
+
storagePath,
|
|
83
|
+
device,
|
|
84
|
+
fileGc: { maxAgeMs: 30 * DAY, intervalMs: DAY }
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
const cleared = await core.clearOldFiles({ olderThanMs: 30 * DAY })
|
|
88
|
+
const { files } = await engine.listLocalFiles({ meshId })
|
|
89
|
+
const held = files.filter((file) => !file.cleared)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
- `getDefaultAgent` and `getDevice` read one row off an index, where a caller
|
|
93
|
+
used to list and search. `listAgents` and `agentsWatch` take an optional
|
|
94
|
+
`providerDeviceId`. (#183)
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
const { id: deviceId } = await engine.deviceInfo({})
|
|
98
|
+
const { agent } = await engine.getDefaultAgent({ meshId, providerDeviceId: deviceId })
|
|
99
|
+
const device = await engine.getDevice({ meshId, deviceId })
|
|
100
|
+
const { agents } = await engine.listAgents({ meshId, providerDeviceId: deviceId })
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Changed
|
|
104
|
+
|
|
105
|
+
- **Breaking:** every mesh-backed route takes a required `meshId`, and Core
|
|
106
|
+
holds a pool of meshes rather than a selected one. A route opens a mesh this
|
|
107
|
+
device belongs to on demand, and a watch ends with the mesh it names.
|
|
108
|
+
`selectMesh` is gone, and which mesh a window shows is the host's own state.
|
|
109
|
+
`meshStatusWatch` loses `writable`, `meshKey` and `discoveryKey`, a
|
|
110
|
+
`listMeshes` row loses `active`, `meshEntry.home` is now `account`, and `wasHome` is now
|
|
111
|
+
`wasAccount`. `leaveMesh` names the mesh it leaves, and `meshInvite` with no
|
|
112
|
+
`meshId` is a device invite for the account. hrpc route ids after
|
|
113
|
+
`selectMesh` shift down by one, so Client and Core ship together. (#155)
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
// 0.3
|
|
117
|
+
await engine.selectMesh({ meshId: room.meshId })
|
|
118
|
+
const { chats } = await engine.listChats({})
|
|
119
|
+
const { meshes } = await engine.listMeshes({})
|
|
120
|
+
const home = meshes.find((mesh) => mesh.home)
|
|
121
|
+
for await (const { writable } of engine.meshStatusWatch({})) showWritable(writable)
|
|
122
|
+
await engine.leaveMesh({})
|
|
123
|
+
|
|
124
|
+
// 0.4
|
|
125
|
+
const { chats } = await engine.listChats({ meshId: room.meshId })
|
|
126
|
+
const { meshId: accountId } = await engine.account({})
|
|
127
|
+
for await (const { meshes } of engine.meshesWatch({})) {
|
|
128
|
+
showWritable(meshes.find((mesh) => mesh.meshId === room.meshId)?.writable)
|
|
129
|
+
}
|
|
130
|
+
await engine.leaveMesh({ meshId: room.meshId })
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
- **Breaking:** `listChunks`, `chunksWatch`, `listAttachmentsByKind`,
|
|
134
|
+
`listToolActivity` and `toolActivityWatch` take a `gt`/`gte`/`lt`/`lte` range
|
|
135
|
+
in place of `fromSeq`, `fromCreatedAt` and `beforeSeq`. `fromSeq` and
|
|
136
|
+
`fromCreatedAt` were inclusive floors, so they become `gte`, and `beforeSeq`
|
|
137
|
+
was an exclusive ceiling, so it becomes `lt`. A `0` bound arrives as absent
|
|
138
|
+
on the wire, so ask for the adjacent bound instead (`gt: 0` is `gte: 1`).
|
|
139
|
+
(#168)
|
|
140
|
+
|
|
141
|
+
```js
|
|
142
|
+
// 0.3
|
|
143
|
+
await engine.listChunks({ chatId, fromSeq: 40 })
|
|
144
|
+
await engine.listAttachmentsByKind({ kind: 'image', fromCreatedAt: since })
|
|
145
|
+
await engine.listToolActivity({ agentId, beforeSeq: oldest.seq })
|
|
146
|
+
|
|
147
|
+
// 0.4
|
|
148
|
+
await engine.listChunks({ meshId, chatId, gte: 40 })
|
|
149
|
+
await engine.listAttachmentsByKind({ meshId, kind: 'image', gte: since })
|
|
150
|
+
await engine.listToolActivity({ meshId, agentId, lt: oldest.seq })
|
|
151
|
+
|
|
152
|
+
// a page of history older than seq 120, newest first
|
|
153
|
+
await engine.listChunks({ meshId, chatId, lt: 120, reverse: true, limit: 50 })
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
- **Breaking:** a request names each entity by kind (`agentId`, `chatId`,
|
|
157
|
+
`groupId`, `deviceId`, `memberId`, `chunkId`) instead of `id`, and every
|
|
158
|
+
create, update and rename takes what it sets under `config`. Response rows
|
|
159
|
+
keep `id`. `renameDevice` always renames the calling device. `updateMember`
|
|
160
|
+
takes no id or `meshId`: it renames the caller's own member in the account,
|
|
161
|
+
and every other mesh picks the name up. (#178)
|
|
162
|
+
|
|
163
|
+
```js
|
|
164
|
+
// 0.3
|
|
165
|
+
await engine.createChat({ agentId, title: 'Plans' })
|
|
166
|
+
await engine.renameChat({ id: chatId, title: 'Trip plans' })
|
|
167
|
+
await engine.updateAgent({ id: agentId, modelName: 'Qwen3.5-9B' })
|
|
168
|
+
await engine.setChatGroup({ id: chatId, groupId })
|
|
169
|
+
await engine.resolveApproval({ id: approvalChunkId, approved: true })
|
|
170
|
+
await engine.renameDevice({ id: deviceId, name: 'Laptop' })
|
|
171
|
+
await engine.updateMember({ id: memberId, name: 'Ada', meshId })
|
|
172
|
+
await engine.createRoom({ compute: true })
|
|
173
|
+
|
|
174
|
+
// 0.4
|
|
175
|
+
await engine.createChat({ meshId, agentId, config: { title: 'Plans' } })
|
|
176
|
+
await engine.renameChat({ meshId, chatId, config: { title: 'Trip plans' } })
|
|
177
|
+
await engine.updateAgent({ meshId, agentId, config: { modelName: 'Qwen3.5-9B' } })
|
|
178
|
+
await engine.setChatGroup({ meshId, chatId, groupId })
|
|
179
|
+
await engine.resolveApproval({ meshId, chunkId: approvalChunkId, approved: true })
|
|
180
|
+
await engine.renameDevice({ meshId, config: { name: 'Laptop' } })
|
|
181
|
+
await engine.updateMember({ config: { name: 'Ada' } })
|
|
182
|
+
await engine.createRoom({ config: { compute: true } })
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
- `autobee` 2.11.4 with `strictReindex`: the boot reindex rewrites views still
|
|
186
|
+
on a version 1 manifest, which autobee 2.11 will no longer append to. (#205)
|
|
187
|
+
|
|
188
|
+
### Deprecated
|
|
189
|
+
|
|
190
|
+
- The `setDisplayName` route now calls `updateMember`, and will be removed.
|
|
191
|
+
(#178)
|
|
192
|
+
|
|
193
|
+
```js
|
|
194
|
+
// instead of engine.setDisplayName({ name: 'Ada' })
|
|
195
|
+
await engine.updateMember({ config: { name: 'Ada' } })
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Removed
|
|
199
|
+
|
|
200
|
+
- `Core.selectMesh` and `Core.setDisplayName`, for a host embedding Core.
|
|
201
|
+
`Core.mesh` is the account. (#155, #178)
|
|
41
202
|
|
|
42
203
|
### Fixed
|
|
43
204
|
|
|
205
|
+
- `ragSearch` could search the selected mesh's vectors for a chat in another
|
|
206
|
+
mesh. Every open mesh now indexes against its own vector index. (#155)
|
|
207
|
+
- A member renamed on one device could be renamed back by another device of
|
|
208
|
+
the same member that held an older name. The newest name now wins. (#180)
|
|
209
|
+
- While one chat's image or music model was sampling, another chat's model
|
|
210
|
+
load or a background download reset its phase, so its sidebar row and thread
|
|
211
|
+
placeholder flickered back to running. (#202)
|
|
44
212
|
- OAuth token refresh failed on Node 24, including Electron 42, because the
|
|
45
213
|
request carried a non-native `AbortSignal`. Calendar, Spotify and other
|
|
46
214
|
connected skills stopped working an hour after connecting. (#207)
|
|
@@ -612,9 +780,9 @@ Published under the `release-0.1` dist-tag.
|
|
|
612
780
|
await assistant.ready()
|
|
613
781
|
```
|
|
614
782
|
|
|
615
|
-
[Unreleased]: https://github.com/tetherto/qvac-core/compare/v0.
|
|
616
|
-
[0.
|
|
617
|
-
[0.
|
|
783
|
+
[Unreleased]: https://github.com/tetherto/qvac-core/compare/v0.4.1...HEAD
|
|
784
|
+
[0.4.1]: https://github.com/tetherto/qvac-core/compare/v0.4.0...v0.4.1
|
|
785
|
+
[0.4.0]: https://github.com/tetherto/qvac-core/compare/v0.3.3...v0.4.0
|
|
618
786
|
[0.3.3]: https://github.com/tetherto/qvac-core/compare/v0.3.2...v0.3.3
|
|
619
787
|
[0.3.2]: https://github.com/tetherto/qvac-core/compare/v0.3.1...v0.3.2
|
|
620
788
|
[0.3.1]: https://github.com/tetherto/qvac-core/compare/v0.3.0...v0.3.1
|
package/README.md
CHANGED
|
@@ -182,7 +182,7 @@ Because every part of a run is a replicated chunk, the assistant inherits the
|
|
|
182
182
|
whole multi-device story without any harness code:
|
|
183
183
|
|
|
184
184
|
- **Delegation** — agents live on the mesh with a `providerDeviceId`. Any
|
|
185
|
-
device asks (`engine.runAgent({ chatId, agentId })` appends a `run-request`
|
|
185
|
+
device asks (`engine.runAgent({ meshId, chatId, agentId })` appends a `run-request`
|
|
186
186
|
chunk); the device that _provides_ the agent executes; every chunk streams
|
|
187
187
|
back to everyone. A request made while the provider is offline runs when it
|
|
188
188
|
returns. Asking requires no harness at all.
|
|
@@ -212,7 +212,7 @@ bookkeeping — and resolves once the run settles:
|
|
|
212
212
|
```js
|
|
213
213
|
import { runTask } from 'qvac-core/task'
|
|
214
214
|
|
|
215
|
-
const result = await runTask(engine, { agentId: agent.id, prompt: 'Say hi' })
|
|
215
|
+
const result = await runTask(engine, { meshId, agentId: agent.id, prompt: 'Say hi' })
|
|
216
216
|
|
|
217
217
|
result.state // 'completed' | 'failed' | 'canceled'
|
|
218
218
|
result.text // the answer: content after the last tool result, trimmed
|
|
@@ -244,10 +244,12 @@ One skill per task: the mention is the first token of the message.
|
|
|
244
244
|
The engine exposes a snapshot chat catalog:
|
|
245
245
|
|
|
246
246
|
```js
|
|
247
|
-
const { chats } = await engine.listChats()
|
|
247
|
+
const { chats } = await engine.listChats({ meshId })
|
|
248
248
|
```
|
|
249
249
|
|
|
250
|
-
|
|
250
|
+
Every mesh-backed route names the mesh it acts on: a device holds several at once
|
|
251
|
+
and Core keeps no current one. It returns that mesh's chat rows in sidebar order,
|
|
252
|
+
bottom first
|
|
251
253
|
(clients reverse to render): a chat sits where the user last dragged it
|
|
252
254
|
(`moveChat`) until a chunk lands in it, then most-recently-active wins; `id`
|
|
253
255
|
breaks ties. Groups ride the same frame, top first (`moveChatGroup` orders
|
|
@@ -266,7 +268,7 @@ Derived per-chat run state rides its own lean stream so it never churns the
|
|
|
266
268
|
metadata list:
|
|
267
269
|
|
|
268
270
|
```js
|
|
269
|
-
const { activities } = await engine.listChatActivity() // or engine.chatActivityWatch()
|
|
271
|
+
const { activities } = await engine.listChatActivity({ meshId }) // or engine.chatActivityWatch({ meshId })
|
|
270
272
|
```
|
|
271
273
|
|
|
272
274
|
Each row is just `{ id, activityState }` — a small state machine over the chat's
|
|
@@ -337,7 +339,7 @@ A chat IS its chunk stream — one watch drives the whole view, and every
|
|
|
337
339
|
device renders the same thing because they all see the same chunks:
|
|
338
340
|
|
|
339
341
|
```js
|
|
340
|
-
for await (const { chunks } of engine.chunksWatch({ chatId })) render(chunks)
|
|
342
|
+
for await (const { chunks } of engine.chunksWatch({ meshId, chatId })) render(chunks)
|
|
341
343
|
```
|
|
342
344
|
|
|
343
345
|
Each frame is the full chat in seq order. To render it, group chunks into
|
|
@@ -359,22 +361,22 @@ must sort before the reply that follows it).
|
|
|
359
361
|
| `thinking` | collapsed/dimmed reasoning segment (`chunk.thinking.text`) |
|
|
360
362
|
| `tool-call` | `→ name(arguments)` line from `chunk.toolCall` |
|
|
361
363
|
| `tool-result` | `← name: result` line from `chunk.toolResult` (collapse long results) |
|
|
362
|
-
| `attachment` | file card from `chunk.attachment` (`fileName`, `mimeType`, `byteLength`); fetch bytes with `engine.downloadAttachment({ blobId })`
|
|
364
|
+
| `attachment` | file card from `chunk.attachment` (`fileName`, `mimeType`, `byteLength`); fetch bytes with `engine.downloadAttachment({ meshId, blobId })` |
|
|
363
365
|
| `approval-request` | **the chunk IS the approval state**, in the typed `chunk.approvalRequest` struct. `status === 'pending'` → show the ask (prefer `resource` — e.g. `host wttr.in` — over raw arguments) with allow / always-allow / deny; any other status → a resolved badge |
|
|
364
366
|
| `run-status` | turn lifecycle, in the typed `chunk.runStatus` struct: `executing` with a `progress` sub-struct (`phase` `loading`/`downloading`, `model`, `percentage` — edited in place on the one executing chunk, labelled by the chunk's `originDeviceId`); `failed` → error with `reason`; `completed` → done, `metrics` (tokens, tok/s, ttft) |
|
|
365
367
|
|
|
366
|
-
**Approval answers** go through `engine.resolveApproval({
|
|
367
|
-
scope, expiresAt })` from ANY device — first decision wins, the flipped
|
|
368
|
+
**Approval answers** go through `engine.resolveApproval({ chunkId, approved,
|
|
369
|
+
scope, expiresAt, meshId })` from ANY device — first decision wins, the flipped
|
|
368
370
|
chunk replicates to everyone. `scope: 'always'` also mints a standing
|
|
369
371
|
approval-rule from the request's tool + resource, so matching future calls
|
|
370
372
|
don't prompt anywhere until the rule expires — one hour by default; pass
|
|
371
373
|
`expiresAt` (ms since epoch) to grant longer or shorter
|
|
372
|
-
(`engine.listApprovalRules({})` shows what's remembered).
|
|
374
|
+
(`engine.listApprovalRules({ meshId })` shows what's remembered).
|
|
373
375
|
|
|
374
376
|
**Busy state** derives from the stream, not local flags: if the last
|
|
375
377
|
assistant turn has no terminal `run-status` (`completed`/`failed`/
|
|
376
378
|
`canceled`), a run is in flight somewhere — show the spinner on every device
|
|
377
|
-
and offer `engine.stopRun({ chatId, runId })`.
|
|
379
|
+
and offer `engine.stopRun({ meshId, chatId, runId })`.
|
|
378
380
|
|
|
379
381
|
**Stopping** is a right of any device, not a request to the executor:
|
|
380
382
|
`stopRun` appends the terminal `canceled` run-status itself, so it settles a
|
|
@@ -386,7 +388,7 @@ first terminal status in seq order is always the run's one outcome.
|
|
|
386
388
|
**Orphaned agents.** Every agent from `listAgents`/`getAgent`/`agentsWatch`
|
|
387
389
|
carries a derived `orphaned` flag: its provider device row is gone or
|
|
388
390
|
revoked, so nobody can execute its runs until it's re-homed
|
|
389
|
-
(`updateAgent({
|
|
391
|
+
(`updateAgent({ meshId, agentId, config: { providerDeviceId } })`). Render it as "waiting for
|
|
390
392
|
provider" — on the agent itself, and on a busy turn whose agent is orphaned
|
|
391
393
|
(that spinner will never resolve by itself). Device removal deliberately
|
|
392
394
|
does NOT delete the device's agents: their chats survive, and re-homing
|
|
@@ -432,7 +434,7 @@ Documents whose full text already fits the prompt need no index wait.
|
|
|
432
434
|
See the [cache and processing decision](docs/decisions/2026-07-15-vector-index-session-cache.md).
|
|
433
435
|
|
|
434
436
|
```ts
|
|
435
|
-
const statuses = engine.fileStatusWatch({ chatId })
|
|
437
|
+
const statuses = engine.fileStatusWatch({ meshId, chatId })
|
|
436
438
|
statuses.on('data', ({ files }) => renderFileStates(files))
|
|
437
439
|
|
|
438
440
|
const upload = engine.uploadKnowledge()
|
|
@@ -563,7 +565,7 @@ evented; `T` is the hyperschema frame type), so both idioms typecheck:
|
|
|
563
565
|
**Loop** — `break`/`return` unsubscribes:
|
|
564
566
|
|
|
565
567
|
```js
|
|
566
|
-
for await (const { agents } of engine.agentsWatch({})) {
|
|
568
|
+
for await (const { agents } of engine.agentsWatch({ meshId })) {
|
|
567
569
|
render(agents)
|
|
568
570
|
if (done) break // break IS the unsubscribe
|
|
569
571
|
}
|
|
@@ -573,7 +575,7 @@ for await (const { agents } of engine.agentsWatch({})) {
|
|
|
573
575
|
`destroy()`; this is plain streamx, nothing layered on top:
|
|
574
576
|
|
|
575
577
|
```js
|
|
576
|
-
const stream = engine.chunksWatch({ chatId }) // opening the chat
|
|
578
|
+
const stream = engine.chunksWatch({ meshId, chatId }) // opening the chat
|
|
577
579
|
stream.on('data', ({ chunks }) => render(chunks))
|
|
578
580
|
// ...closing the chat:
|
|
579
581
|
stream.destroy() // the unsubscribe
|
|
@@ -586,7 +588,7 @@ race, because frame one is the snapshot:
|
|
|
586
588
|
async function once(stream) {
|
|
587
589
|
for await (const frame of stream) return frame // break-on-return unsubscribes
|
|
588
590
|
}
|
|
589
|
-
const { devices } = await once(engine.devicesWatch({}))
|
|
591
|
+
const { devices } = await once(engine.devicesWatch({ meshId }))
|
|
590
592
|
```
|
|
591
593
|
|
|
592
594
|
**Errors end the stream, they never hang it.** A server-side query failure
|
|
@@ -597,7 +599,7 @@ is a re-arm loop, not error plumbing:
|
|
|
597
599
|
```js
|
|
598
600
|
while (!closing) {
|
|
599
601
|
try {
|
|
600
|
-
for await (const { chunks } of engine.chunksWatch({ chatId })) render(chunks)
|
|
602
|
+
for await (const { chunks } of engine.chunksWatch({ meshId, chatId })) render(chunks)
|
|
601
603
|
break // server ended the stream deliberately
|
|
602
604
|
} catch {
|
|
603
605
|
await delay(1000) // transport blip — resubscribe (frame one re-syncs you)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type MeshPool } from './current-mesh.ts';
|
|
2
2
|
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
3
|
-
type AgentCapabilities = Pick<CapabilityHandlers, 'createAgent' | 'listAgents' | 'getAgent' | 'updateAgent' | 'deleteAgent' | 'agentsWatch'>;
|
|
4
|
-
export declare function createAgentsApi(
|
|
3
|
+
type AgentCapabilities = Pick<CapabilityHandlers, 'createAgent' | 'listAgents' | 'getAgent' | 'getDefaultAgent' | 'updateAgent' | 'deleteAgent' | 'agentsWatch'>;
|
|
4
|
+
export declare function createAgentsApi(pool: MeshPool, deviceId: Buffer | null, computeLender?: (() => Promise<Buffer | null>) | null): AgentCapabilities;
|
|
5
5
|
export {};
|
|
@@ -1,38 +1,49 @@
|
|
|
1
|
-
import { createAgent, deleteAgent, isOrphaned, listAgents, liveProviderIds, mustGetActiveAgent, updateAgent } from '../core/agent.js';
|
|
1
|
+
import { createAgent, deleteAgent, getDefaultAgent, isOrphaned, listAgents, liveProviderIds, mustGetActiveAgent, updateAgent } from '../core/agent.js';
|
|
2
2
|
import { meshWatchable, requireMesh } from './current-mesh.js';
|
|
3
|
-
|
|
3
|
+
import b4a from 'b4a';
|
|
4
|
+
export function createAgentsApi(pool, deviceId, computeLender = null) {
|
|
4
5
|
const withOrphaned = async (mesh, agent) => ({
|
|
5
6
|
...agent,
|
|
6
7
|
orphaned: await isOrphaned(mesh, agent)
|
|
7
8
|
});
|
|
8
|
-
const list = async (mesh) => {
|
|
9
|
-
const [agents, live] = await Promise.all([
|
|
9
|
+
const list = async (mesh, providerDeviceId) => {
|
|
10
|
+
const [agents, live] = await Promise.all([
|
|
11
|
+
listAgents(mesh, providerDeviceId),
|
|
12
|
+
liveProviderIds(mesh)
|
|
13
|
+
]);
|
|
10
14
|
return {
|
|
11
15
|
agents: agents.map((agent) => ({
|
|
12
16
|
...agent,
|
|
13
|
-
orphaned: !live.has(agent.providerDeviceId
|
|
17
|
+
orphaned: !live.has(b4a.toHex(agent.providerDeviceId))
|
|
14
18
|
}))
|
|
15
19
|
};
|
|
16
20
|
};
|
|
17
21
|
return {
|
|
18
|
-
createAgent: async (
|
|
19
|
-
const mesh = await requireMesh(
|
|
20
|
-
const lenderDeviceId =
|
|
21
|
-
return withOrphaned(mesh, await createAgent(mesh, { ...
|
|
22
|
+
createAgent: async ({ meshId, config }) => {
|
|
23
|
+
const mesh = await requireMesh(pool, meshId);
|
|
24
|
+
const lenderDeviceId = config.lenderDeviceId ?? (await computeLender?.()) ?? undefined;
|
|
25
|
+
return withOrphaned(mesh, await createAgent(mesh, { ...config, lenderDeviceId }));
|
|
22
26
|
},
|
|
23
|
-
listAgents: async (
|
|
24
|
-
getAgent: async ({
|
|
25
|
-
const mesh = await requireMesh(
|
|
26
|
-
return withOrphaned(mesh, await mustGetActiveAgent(mesh,
|
|
27
|
+
listAgents: async ({ meshId, providerDeviceId }) => list(await requireMesh(pool, meshId), providerDeviceId ?? undefined),
|
|
28
|
+
getAgent: async ({ agentId, meshId }) => {
|
|
29
|
+
const mesh = await requireMesh(pool, meshId);
|
|
30
|
+
return withOrphaned(mesh, await mustGetActiveAgent(mesh, agentId));
|
|
27
31
|
},
|
|
28
|
-
|
|
29
|
-
const mesh = await requireMesh(
|
|
30
|
-
|
|
32
|
+
getDefaultAgent: async ({ meshId, providerDeviceId }) => {
|
|
33
|
+
const mesh = await requireMesh(pool, meshId);
|
|
34
|
+
const agent = await getDefaultAgent(mesh, providerDeviceId ?? undefined);
|
|
35
|
+
if (!agent)
|
|
36
|
+
return {};
|
|
37
|
+
return { agent: await withOrphaned(mesh, agent) };
|
|
31
38
|
},
|
|
32
|
-
|
|
33
|
-
const mesh = await requireMesh(
|
|
34
|
-
return withOrphaned(mesh, await
|
|
39
|
+
updateAgent: async ({ agentId, meshId, config }) => {
|
|
40
|
+
const mesh = await requireMesh(pool, meshId);
|
|
41
|
+
return withOrphaned(mesh, await updateAgent(mesh, agentId, config));
|
|
35
42
|
},
|
|
36
|
-
|
|
43
|
+
deleteAgent: async ({ agentId, meshId }) => {
|
|
44
|
+
const mesh = await requireMesh(pool, meshId);
|
|
45
|
+
return withOrphaned(mesh, await deleteAgent(mesh, deviceId, agentId));
|
|
46
|
+
},
|
|
47
|
+
agentsWatch: meshWatchable('agentsWatch', pool, (request, mesh) => list(mesh, request.providerDeviceId ?? undefined))
|
|
37
48
|
};
|
|
38
49
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type MeshPool } from './current-mesh.ts';
|
|
2
2
|
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
3
|
-
export declare function createApprovalRulesApi(
|
|
3
|
+
export declare function createApprovalRulesApi(pool: MeshPool): Pick<CapabilityHandlers, 'listApprovalRules'>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { listApprovalRules } from '../core/approval-rules.js';
|
|
2
2
|
import { requireMesh } from './current-mesh.js';
|
|
3
|
-
export function createApprovalRulesApi(
|
|
3
|
+
export function createApprovalRulesApi(pool) {
|
|
4
4
|
return {
|
|
5
5
|
listApprovalRules: async (request) => {
|
|
6
|
-
const mesh = await requireMesh(
|
|
6
|
+
const mesh = await requireMesh(pool, request.meshId);
|
|
7
7
|
return {
|
|
8
8
|
rules: await listApprovalRules(mesh),
|
|
9
9
|
ourMemberId: mesh.ourMemberId ?? undefined
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
2
|
-
import { type
|
|
2
|
+
import { type MeshPool } from './current-mesh.ts';
|
|
3
3
|
export { MAX_ATTACHMENT_BYTES } from '../core/files/attachments.ts';
|
|
4
|
-
export declare function createAttachmentsApi(
|
|
4
|
+
export declare function createAttachmentsApi(pool: MeshPool, options?: {
|
|
5
5
|
maxBytes?: number;
|
|
6
6
|
deviceId?: Buffer | null;
|
|
7
7
|
inactivityMs?: number;
|
|
@@ -1,37 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { openUpload, UPLOAD_NAMES_NO_MESH } from './upload-frames.js';
|
|
2
2
|
import { requireMesh } from './current-mesh.js';
|
|
3
|
-
function rejoin(frames, first, rest) {
|
|
4
|
-
const replayed = (async function* () {
|
|
5
|
-
yield first;
|
|
6
|
-
while (true) {
|
|
7
|
-
const next = await rest.next();
|
|
8
|
-
if (next.done)
|
|
9
|
-
return;
|
|
10
|
-
yield next.value;
|
|
11
|
-
}
|
|
12
|
-
})();
|
|
13
|
-
return 'writeStream' in frames
|
|
14
|
-
? Object.assign(replayed, { writeStream: frames.writeStream })
|
|
15
|
-
: replayed;
|
|
16
|
-
}
|
|
17
3
|
export { MAX_ATTACHMENT_BYTES } from '../core/files/attachments.js';
|
|
18
|
-
export function createAttachmentsApi(
|
|
4
|
+
export function createAttachmentsApi(pool, options = {}) {
|
|
19
5
|
return {
|
|
20
6
|
async *uploadAttachment(frames) {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
if (first.done)
|
|
7
|
+
const upload = await openUpload(frames);
|
|
8
|
+
if (!upload)
|
|
24
9
|
return;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
10
|
+
if (!upload.first.meshId)
|
|
11
|
+
throw new Error(UPLOAD_NAMES_NO_MESH);
|
|
12
|
+
const mesh = await requireMesh(pool, upload.first.meshId);
|
|
13
|
+
yield* mesh.files.attachments(options).uploadAttachment(upload.rest);
|
|
29
14
|
},
|
|
30
15
|
async *downloadAttachment(request) {
|
|
31
|
-
yield* (await requireMesh(
|
|
16
|
+
yield* (await requireMesh(pool, request.meshId)).files
|
|
17
|
+
.attachments(options)
|
|
18
|
+
.downloadAttachment(request);
|
|
32
19
|
},
|
|
33
20
|
async deleteAttachment(request) {
|
|
34
|
-
return (await requireMesh(
|
|
21
|
+
return (await requireMesh(pool, request.meshId)).files
|
|
22
|
+
.attachments(options)
|
|
23
|
+
.deleteAttachment(request);
|
|
35
24
|
}
|
|
36
25
|
};
|
|
37
26
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
2
|
-
import { type
|
|
2
|
+
import { type MeshPool } from './current-mesh.ts';
|
|
3
3
|
type ChatGroupCapabilities = Pick<CapabilityHandlers, 'createChatGroup' | 'listChatGroups' | 'renameChatGroup' | 'deleteChatGroup' | 'setChatGroup' | 'moveChat' | 'moveChatGroup' | 'sortChatGroupsByName'>;
|
|
4
|
-
export declare function createChatGroupsApi(
|
|
4
|
+
export declare function createChatGroupsApi(pool: MeshPool): ChatGroupCapabilities;
|
|
5
5
|
export {};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { createChatGroup, deleteChatGroup, listChatGroups, moveChatGroup, renameChatGroup, sortChatGroupsByName } from '../core/chat-group.js';
|
|
2
2
|
import { moveChat, setChatGroup } from '../core/chat.js';
|
|
3
3
|
import { requireMesh } from './current-mesh.js';
|
|
4
|
-
export function createChatGroupsApi(
|
|
4
|
+
export function createChatGroupsApi(pool) {
|
|
5
5
|
return {
|
|
6
|
-
createChatGroup: async ({
|
|
7
|
-
listChatGroups: async () => listChatGroups(await requireMesh(
|
|
8
|
-
renameChatGroup: async ({
|
|
9
|
-
deleteChatGroup: async ({
|
|
10
|
-
setChatGroup: async ({
|
|
11
|
-
moveChat: async ({
|
|
12
|
-
moveChatGroup: async ({
|
|
13
|
-
sortChatGroupsByName: async () => sortChatGroupsByName(await requireMesh(
|
|
6
|
+
createChatGroup: async ({ meshId, config }) => createChatGroup(await requireMesh(pool, meshId), { name: config.name }),
|
|
7
|
+
listChatGroups: async ({ meshId }) => listChatGroups(await requireMesh(pool, meshId)).then((groups) => ({ groups })),
|
|
8
|
+
renameChatGroup: async ({ groupId, meshId, config }) => renameChatGroup(await requireMesh(pool, meshId), groupId, config.name),
|
|
9
|
+
deleteChatGroup: async ({ groupId, meshId }) => deleteChatGroup(await requireMesh(pool, meshId), groupId),
|
|
10
|
+
setChatGroup: async ({ chatId, groupId, meshId }) => setChatGroup(await requireMesh(pool, meshId), chatId, groupId),
|
|
11
|
+
moveChat: async ({ chatId, groupId, afterId, meshId }) => moveChat(await requireMesh(pool, meshId), chatId, { groupId, afterId }),
|
|
12
|
+
moveChatGroup: async ({ groupId, afterId, meshId }) => moveChatGroup(await requireMesh(pool, meshId), groupId, { afterId }),
|
|
13
|
+
sortChatGroupsByName: async ({ meshId }) => sortChatGroupsByName(await requireMesh(pool, meshId)).then((groups) => ({ groups }))
|
|
14
14
|
};
|
|
15
15
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
2
|
-
import {
|
|
2
|
+
import type { openLocalStore } from '../core/local/index.ts';
|
|
3
|
+
import { type MeshPool } from './current-mesh.ts';
|
|
4
|
+
type LocalStore = ReturnType<typeof openLocalStore>;
|
|
3
5
|
type ChatCapabilities = Pick<CapabilityHandlers, 'createChat' | 'listChats' | 'getChat' | 'renameChat' | 'setChatRagEnabled' | 'setChatWebSearchEnabled' | 'deleteChat' | 'chatsWatch' | 'listChatActivity' | 'chatActivityWatch' | 'searchChats'>;
|
|
4
|
-
export declare function createChatApi(
|
|
6
|
+
export declare function createChatApi(pool: MeshPool, deviceId: Buffer | null, local: LocalStore, inferenceCalls?: {
|
|
5
7
|
forget(chatId: string): Promise<void>;
|
|
6
8
|
} | null): ChatCapabilities;
|
|
7
9
|
export {};
|
package/dist-lib/lib/api/chat.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import { AbortController } from 'bare-abort-controller';
|
|
2
|
-
import { createChat, deleteChat,
|
|
2
|
+
import { createChat, deleteChat, mustGetActiveChatListing, renameChat, setChatRagEnabled, setChatWebSearchEnabled } from '../core/chat.js';
|
|
3
3
|
import { listChatActivity } from '../core/chat-activity.js';
|
|
4
|
+
import { listChatPage } from '../core/chat-order.js';
|
|
4
5
|
import { searchChats } from '../core/chat-search.js';
|
|
5
|
-
import { meshWatchable, requireMesh
|
|
6
|
-
import { watchable } from './watchable.js';
|
|
6
|
+
import { meshWatchable, requireMesh } from './current-mesh.js';
|
|
7
7
|
const SEARCH_SUPERSEDED_ABORT = 'superseded by a newer chat search';
|
|
8
|
-
export function createChatApi(
|
|
8
|
+
export function createChatApi(pool, deviceId, local, inferenceCalls = null) {
|
|
9
9
|
let searchAbort = null;
|
|
10
|
-
const chatList = (mesh) =>
|
|
10
|
+
const chatList = (mesh, { limit, cursor }) => listChatPage(mesh, local, { limit: limit || undefined, cursor: cursor ?? undefined });
|
|
11
11
|
const chatActivity = (mesh, chatIds) => listChatActivity(mesh, chatIds ?? undefined).then((activities) => ({ activities }));
|
|
12
12
|
return {
|
|
13
|
-
createChat: async (
|
|
14
|
-
listChats: async (request) => chatList(await requireMesh(
|
|
15
|
-
getChat: async ({
|
|
16
|
-
renameChat: async ({
|
|
17
|
-
setChatRagEnabled: async ({
|
|
18
|
-
setChatWebSearchEnabled: async ({
|
|
19
|
-
deleteChat: async ({
|
|
20
|
-
const deleted = await deleteChat(await requireMesh(
|
|
21
|
-
await inferenceCalls?.forget(
|
|
13
|
+
createChat: async ({ meshId, agentId, config }) => createChat(await requireMesh(pool, meshId), { agentId, title: config.title }),
|
|
14
|
+
listChats: async (request) => chatList(await requireMesh(pool, request.meshId), request),
|
|
15
|
+
getChat: async ({ chatId, meshId }) => mustGetActiveChatListing(await requireMesh(pool, meshId), chatId),
|
|
16
|
+
renameChat: async ({ chatId, meshId, config }) => renameChat(await requireMesh(pool, meshId), chatId, config.title),
|
|
17
|
+
setChatRagEnabled: async ({ chatId, enabled, meshId }) => setChatRagEnabled(await requireMesh(pool, meshId), chatId, enabled ?? false),
|
|
18
|
+
setChatWebSearchEnabled: async ({ chatId, enabled, meshId }) => setChatWebSearchEnabled(await requireMesh(pool, meshId), chatId, enabled ?? false),
|
|
19
|
+
deleteChat: async ({ chatId, meshId }) => {
|
|
20
|
+
const deleted = await deleteChat(await requireMesh(pool, meshId), deviceId, chatId);
|
|
21
|
+
await inferenceCalls?.forget(chatId);
|
|
22
22
|
return deleted;
|
|
23
23
|
},
|
|
24
|
-
chatsWatch: meshWatchable('chatsWatch',
|
|
25
|
-
listChatActivity: async (input) => chatActivity(await requireMesh(
|
|
26
|
-
chatActivityWatch:
|
|
24
|
+
chatsWatch: meshWatchable('chatsWatch', pool, (request, store) => chatList(store, request), local),
|
|
25
|
+
listChatActivity: async (input) => chatActivity(await requireMesh(pool, input.meshId), input.chatIds),
|
|
26
|
+
chatActivityWatch: meshWatchable('chatActivityWatch', pool, (request, store) => chatActivity(store, request.chatIds)),
|
|
27
27
|
searchChats: async (input) => {
|
|
28
28
|
searchAbort?.abort(SEARCH_SUPERSEDED_ABORT);
|
|
29
29
|
const controller = new AbortController();
|
|
30
30
|
searchAbort = controller;
|
|
31
31
|
return {
|
|
32
32
|
hits: [
|
|
33
|
-
...(await searchChats(await requireMesh(
|
|
33
|
+
...(await searchChats(await requireMesh(pool, input.meshId), {
|
|
34
34
|
query: input.query,
|
|
35
35
|
limit: input.limit,
|
|
36
36
|
signal: controller.signal
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type MeshPool } from './current-mesh.ts';
|
|
2
2
|
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
3
3
|
type ChunkCapabilities = Pick<CapabilityHandlers, 'appendChunk' | 'updateChunk' | 'resolveApproval' | 'listChunks' | 'listAttachmentsByKind' | 'chunksWatch' | 'runRequestsWatch'>;
|
|
4
|
-
export declare function createChunksApi(
|
|
4
|
+
export declare function createChunksApi(pool: MeshPool, deviceId: Buffer | null): ChunkCapabilities;
|
|
5
5
|
export {};
|