@qvac/core 1.0.0-rc.3 → 1.0.0-rc.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 +106 -36
- package/dist-lib/index.d.ts +2 -1
- package/dist-lib/lib/api/approval-rules.d.ts +1 -1
- package/dist-lib/lib/api/approval-rules.js +5 -1
- package/dist-lib/lib/api/config.d.ts +6 -2
- package/dist-lib/lib/api/config.js +9 -5
- package/dist-lib/lib/api/index.d.ts +12 -2
- package/dist-lib/lib/api/index.js +6 -1
- package/dist-lib/lib/api/rag.js +5 -5
- package/dist-lib/lib/assistant/model-round.js +2 -2
- package/dist-lib/lib/assistant.d.ts +1 -0
- package/dist-lib/lib/assistant.js +16 -7
- package/dist-lib/lib/core/agent-copies.js +7 -1
- package/dist-lib/lib/core/agent.js +1 -0
- package/dist-lib/lib/core/approval-rules.d.ts +5 -1
- package/dist-lib/lib/core/approval-rules.js +16 -1
- package/dist-lib/lib/core/chunk.js +4 -3
- package/dist-lib/lib/core/config-value.d.ts +1 -0
- package/dist-lib/lib/core/config-value.js +1 -0
- package/dist-lib/lib/core/contract/workspace.js +2 -2
- package/dist-lib/lib/core/deleted-agent-runs.d.ts +7 -0
- package/dist-lib/lib/core/deleted-agent-runs.js +46 -0
- package/dist-lib/lib/core/files/index.d.ts +1 -1
- package/dist-lib/lib/core/files/index.js +4 -2
- package/dist-lib/lib/core/local/index.d.ts +6 -0
- package/dist-lib/lib/core/local/index.js +14 -0
- package/dist-lib/lib/core/mesh.d.ts +1 -1
- package/dist-lib/lib/core/mesh.js +3 -1
- package/dist-lib/lib/core/skill-secrets.d.ts +3 -2
- package/dist-lib/lib/core/skill-secrets.js +4 -1
- package/dist-lib/lib/core/sync/index.js +13 -1
- package/dist-lib/lib/core/vault-managed-skills.d.ts +18 -0
- package/dist-lib/lib/core/vault-managed-skills.js +105 -0
- package/dist-lib/lib/core.d.ts +8 -1
- package/dist-lib/lib/core.js +63 -6
- package/dist-lib/lib/errors.d.ts +8 -0
- package/dist-lib/lib/errors.js +8 -0
- package/dist-lib/lib/mesh-scoped-engine.js +1 -0
- package/dist-lib/schema/config.d.ts +1 -1
- package/dist-lib/schema/config.js +1 -1
- package/dist-lib/schema/engine.js +33 -1
- package/dist-lib/schema/qvac.js +4 -2
- package/dist-lib/spec/bind.js +12 -0
- package/dist-lib/spec/calls.js +4 -0
- package/dist-lib/spec/capabilities.d.ts +8 -0
- package/dist-lib/spec/config/hyperconf/index.js +1 -1
- package/dist-lib/spec/hrpc/hrpc.json +52 -0
- package/dist-lib/spec/hrpc/index.js +51 -3
- package/dist-lib/spec/hrpc/messages.js +1013 -954
- package/dist-lib/spec/hyperschema/index.js +1013 -954
- package/dist-lib/spec/hyperschema/schema.json +40 -0
- package/dist-lib/spec/hyperschema/types.d.ts +12 -0
- package/dist-lib/spec/mesh/hyperdb/messages.js +539 -501
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +319 -300
- package/dist-lib/spec/mesh/hyperschema/index.js +319 -300
- package/dist-lib/spec/mesh/hyperschema/schema.json +188 -178
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +3 -1
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -67,26 +67,13 @@ release.
|
|
|
67
67
|
without fetching the default models. A sidecar that fails to start also writes
|
|
68
68
|
the reason to stderr, since the host may not be listening yet.
|
|
69
69
|
|
|
70
|
-
- A chat's KV cache is deleted once the chat has been idle for the retention, so a device no
|
|
71
|
-
longer keeps the cache of every chat it ever ran. The chat itself is untouched; its next message
|
|
72
|
-
primes from history. An app sets its default with `kvCacheRetentionMs` on `assistantChild` (14
|
|
73
|
-
days without it, `0` for Never), and a device overrides it with `kvCache.retentionDays`.
|
|
74
|
-
|
|
75
|
-
```js
|
|
76
|
-
import { assistantChild } from '@qvac/core'
|
|
77
|
-
import { KV_CACHE_RETENTION_KEY } from '@qvac/core/constants'
|
|
78
|
-
|
|
79
|
-
assistantChild({ harness, kvCacheRetentionMs: 30 * 24 * 60 * 60_000 })
|
|
80
|
-
await engine.configSet({ key: KV_CACHE_RETENTION_KEY, value: 7 })
|
|
81
|
-
```
|
|
82
|
-
|
|
83
70
|
### Changed
|
|
84
71
|
|
|
85
72
|
- The KV cache retention sweep runs every 12 hours instead of every hour, besides when a mesh opens
|
|
86
73
|
and when `kvCache.retentionDays` changes, so a cache can outlive its retention by up to 12 hours
|
|
87
74
|
on a host that stays up. ([config.md](docs/api/config.md#kv-cache-retention))
|
|
88
75
|
|
|
89
|
-
- Core depends on `@qvac/harness` 1.0.0-rc.
|
|
76
|
+
- Core depends on `@qvac/harness` 1.0.0-rc.16 from npm instead of a git commit, so a consumer installs
|
|
90
77
|
the published harness with its named entries.
|
|
91
78
|
|
|
92
79
|
- Wipe a store written by 1.0.0-rc.0 to rc.2 before running this build. The collection, route and
|
|
@@ -97,31 +84,45 @@ release.
|
|
|
97
84
|
its rc-numbered ops, so a device that rejoins it, by a recovery from the phrase too, misreads
|
|
98
85
|
them again. Start a new account on this build instead.
|
|
99
86
|
|
|
100
|
-
- The baked version floor is `>=0.
|
|
101
|
-
what apply admits.
|
|
102
|
-
in a new mesh's genesis and
|
|
103
|
-
|
|
104
|
-
0.7.x replica that applies
|
|
87
|
+
- The baked version floor is `>=0.22.0`: one build per mesh, since this release
|
|
88
|
+
changes what apply admits and app 0.22 is the first to ship it. Each mesh now
|
|
89
|
+
holds a rules row, `@qvac/mesh-rules`, first in a new mesh's genesis and
|
|
90
|
+
appended once when this build first holds an existing mesh writable, and apply
|
|
91
|
+
holds new rules to ops after it only. A 0.7.x or 0.11.x replica that applies
|
|
92
|
+
the row halts into its update prompt.
|
|
105
93
|
|
|
106
|
-
**Operator step:** publish `>=0.
|
|
107
|
-
on each lane (dev, staging, prod) only once app 0.
|
|
94
|
+
**Operator step:** publish `>=0.22.0` with `qvac-app → scripts/ota-config.mjs`
|
|
95
|
+
on each lane (dev, staging, prod) only once app 0.22 is live on that lane, and
|
|
108
96
|
never before: a floor above the installed release withholds every device on
|
|
109
|
-
the lane.
|
|
110
|
-
|
|
97
|
+
the lane. Not `>=0.21.0`, which admits app 0.21 and its core 0.11.1, from
|
|
98
|
+
before the row. Until it is published, an old replica that fast-forwards past
|
|
99
|
+
the row applies later ops under the old rules.
|
|
111
100
|
|
|
112
101
|
- A rules row raised above the rules this build knows halts apply into its
|
|
113
102
|
update prompt with the code `MESH_RULES_FROM_A_NEWER_BUILD`, instead of being
|
|
114
103
|
applied.
|
|
115
104
|
|
|
116
|
-
|
|
105
|
+
### Removed
|
|
106
|
+
|
|
107
|
+
- The `duck` terminal UI and its bin; the terminal app lives in its own repo.
|
|
108
|
+
|
|
109
|
+
### Fixed
|
|
110
|
+
|
|
111
|
+
- A resume whose announce reached no DHT node retries that topic within
|
|
112
|
+
seconds, instead of leaving the device unfindable for ten minutes.
|
|
113
|
+
|
|
114
|
+
## [0.11.4] - 2026-10-30
|
|
115
|
+
|
|
116
|
+
### Changed
|
|
117
|
+
|
|
118
|
+
- A `mesh write` or `mesh drain` stall now keeps reporting while it lasts (#649). Each `… still pending`
|
|
117
119
|
line carries `reports` (1, 2, 3 …), and the wait doubles between reports. It also names:
|
|
118
120
|
- `fastForwarding`: the head a fast-forward is booting onto, with how much of that core this
|
|
119
121
|
device and its peers hold, or `null`.
|
|
120
122
|
- `peerLength` and `peerHeld` on every `missing` core: how far the furthest connected peer
|
|
121
123
|
knows that core, and how much of it that peer holds from block 0.
|
|
122
124
|
- `writers` on a mesh still joining: each writer it knows, with the same holdings.
|
|
123
|
-
|
|
124
|
-
- The logs now name the build and what an open did to an older mesh:
|
|
125
|
+
- The logs now name the build and what an open did to an older mesh (#650):
|
|
125
126
|
- `core opening` is the first line of a launch. It names the app's `version`, `build` and
|
|
126
127
|
`channel`, and the mesh `schema` this core applies. A mesh's own `opening` line names the
|
|
127
128
|
`schema` too.
|
|
@@ -131,19 +132,79 @@ release.
|
|
|
131
132
|
- `copied chats into chat-chunks` and `recorded the files the mesh already held` give each
|
|
132
133
|
backfill's count and `ms`.
|
|
133
134
|
|
|
135
|
+
### Fixed
|
|
136
|
+
|
|
137
|
+
- The assistant no longer logs `saveDeviceCapabilities failed` while the account mesh is still
|
|
138
|
+
joining. Core refuses the report with `MESH_STILL_JOINING` until this device is a writer, and the
|
|
139
|
+
assistant already reports again once the account turns writable, so the refusal was never a
|
|
140
|
+
failure. (#648)
|
|
141
|
+
|
|
142
|
+
## [0.11.3] - 2026-10-28
|
|
143
|
+
|
|
144
|
+
### Added
|
|
145
|
+
|
|
146
|
+
- The first run to complete stores which pictures of a PDF it sent, as an attachment chunk whose
|
|
147
|
+
`sourceId` is the PDF's attachment id, so later turns and other devices send the same ones. Do
|
|
148
|
+
not render an attachment chunk that carries a `sourceId`. (#640)
|
|
149
|
+
|
|
150
|
+
### Changed
|
|
151
|
+
|
|
152
|
+
- A PDF's pictures reach a vision model cut to each figure and its caption, named by page and
|
|
153
|
+
figure, instead of as whole pages, and white pages are no longer sent. The PDF's text and its
|
|
154
|
+
pictures now share half the context window, less what the chat already holds, where each took
|
|
155
|
+
half before: a PDF whose whole text fit filled the window and compacted on the next message.
|
|
156
|
+
(#640)
|
|
157
|
+
- `bare-pdfium` is required at `^1.8.0`, for `imageBounds` and `pageBox`; a host that packages the
|
|
158
|
+
addon ships that version. (#640)
|
|
159
|
+
|
|
160
|
+
## [0.11.2] - 2026-10-28
|
|
161
|
+
|
|
162
|
+
### Added
|
|
163
|
+
|
|
164
|
+
- A chat's KV cache is deleted once the chat has been idle for the retention, so a device no
|
|
165
|
+
longer keeps the cache of every chat it ever ran. The chat itself is untouched; its next message
|
|
166
|
+
primes from history. An app sets its default with `kvCacheRetentionMs` on `assistantChild` (14
|
|
167
|
+
days without it, `0` for Never), and a device overrides it with `kvCache.retentionDays`. (#589)
|
|
168
|
+
|
|
169
|
+
```js
|
|
170
|
+
import { assistantChild } from '@qvac/core'
|
|
171
|
+
import { KV_CACHE_RETENTION_KEY } from '@qvac/core/constants'
|
|
172
|
+
|
|
173
|
+
assistantChild({ harness, kvCacheRetentionMs: 30 * 24 * 60 * 60_000 })
|
|
174
|
+
await engine.configSet({ key: KV_CACHE_RETENTION_KEY, value: 7 })
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
- Every credential a skill declares is pushed to the harness, not only the built-in keys and
|
|
178
|
+
OAuth tokens, so a skill with its own key no longer reads needs-setup for good and needs no core
|
|
179
|
+
release. Where a value may be sent is unchanged, and an overlay skill gets no credential. (#596)
|
|
180
|
+
- A credential with no setup block and no token provider gets a one-field token route named after
|
|
181
|
+
its key, so any setup UI can set it. (#591)
|
|
182
|
+
- `duck` sets a skill up through one sheet, opened by `/skill <name>`. (#592)
|
|
183
|
+
|
|
184
|
+
### Changed
|
|
185
|
+
|
|
186
|
+
- `toolResult.result` is required on the wire, so a tool result of `false`, `0` or `''` reads
|
|
187
|
+
back as written from `listChunks` and `chunksWatch` instead of `null`. A device on 0.11.0 or
|
|
188
|
+
earlier, and a result one of those releases wrote, still read `null`. (#559)
|
|
189
|
+
|
|
190
|
+
```js
|
|
191
|
+
// 0.11.1
|
|
192
|
+
{ type: 'tool-result', toolResult: { name } }
|
|
193
|
+
// 0.11.2
|
|
194
|
+
{ type: 'tool-result', toolResult: { name, result: null } }
|
|
195
|
+
```
|
|
196
|
+
|
|
134
197
|
### Removed
|
|
135
198
|
|
|
136
|
-
-
|
|
199
|
+
- `duck`'s `/cred`: every value is set through its skill's sheet. (#593)
|
|
137
200
|
|
|
138
201
|
### Fixed
|
|
139
202
|
|
|
140
|
-
- A resume whose announce reached no DHT node retries that topic within
|
|
141
|
-
seconds, instead of leaving the device unfindable for ten minutes.
|
|
142
203
|
- Chat activity no longer diffs across a fast-forward it has not counted yet. It
|
|
143
204
|
dropped its cached view head only once `fastForwards` moved, which can be
|
|
144
205
|
after the view has landed on another core, and a diff from the old head read
|
|
145
206
|
every node of the new view. It now drops the head whenever the view is on
|
|
146
|
-
another core, as `chunksDeltaWatch` does.
|
|
207
|
+
another core, as `chunksDeltaWatch` does. (#623)
|
|
147
208
|
- A device that does not hold a mesh no longer downloads most of it to show chat
|
|
148
209
|
activity and notifications. Both read a few chunk types per chat, each through
|
|
149
210
|
its type index and then row by row from `@qvac/chunks`; they now read the
|
|
@@ -151,11 +212,17 @@ release.
|
|
|
151
212
|
range is whole. A member joining a 170-chat mesh with both open downloaded
|
|
152
213
|
about 39,000 blocks (155 MB) instead of 258,000 (640 MB), and on a device that
|
|
153
214
|
holds the mesh their first frames take 2.2 s and 3.7 s instead of 5.8 s and
|
|
154
|
-
9.8 s.
|
|
155
|
-
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
215
|
+
9.8 s. (#624)
|
|
216
|
+
- `compactChat` folds whole turns, so a chat whose messages were queued no longer keeps answers
|
|
217
|
+
without their questions. (#607)
|
|
218
|
+
- A run whose injected excerpts overflow the model window, with no older turns to fold, is retried
|
|
219
|
+
with half the excerpts instead of failing. (#599)
|
|
220
|
+
- `ragSearch` on a remote agent host waits for an attached file still replicating to it instead of
|
|
221
|
+
answering that the file is still being indexed. (#562)
|
|
222
|
+
- A chat whose first message carries a document is titled from the words the user typed, not the
|
|
223
|
+
document text. (#516)
|
|
224
|
+
- A re-homed agent's skill values are retried until the new host takes them; a host that refused
|
|
225
|
+
before it replicated the re-home left them unset. (#478)
|
|
159
226
|
|
|
160
227
|
## [0.11.1] - 2026-10-26
|
|
161
228
|
|
|
@@ -2147,7 +2214,10 @@ Published under the `release-0.1` dist-tag.
|
|
|
2147
2214
|
await assistant.ready()
|
|
2148
2215
|
```
|
|
2149
2216
|
|
|
2150
|
-
[Unreleased]: https://github.com/tetherto/qvac-core/compare/v0.11.
|
|
2217
|
+
[Unreleased]: https://github.com/tetherto/qvac-core/compare/v0.11.4...HEAD
|
|
2218
|
+
[0.11.4]: https://github.com/tetherto/qvac-core/compare/v0.11.3...v0.11.4
|
|
2219
|
+
[0.11.3]: https://github.com/tetherto/qvac-core/compare/v0.11.2...v0.11.3
|
|
2220
|
+
[0.11.2]: https://github.com/tetherto/qvac-core/compare/v0.11.1...v0.11.2
|
|
2151
2221
|
[0.11.1]: https://github.com/tetherto/qvac-core/compare/v0.11.0...v0.11.1
|
|
2152
2222
|
[0.11.0]: https://github.com/tetherto/qvac-core/compare/v0.10.4...v0.11.0
|
|
2153
2223
|
[0.10.4]: https://github.com/tetherto/qvac-core/compare/v0.10.3...v0.10.4
|
package/dist-lib/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type { AssistantAgent, AssistantAgentList, AssistantConfigValue } from './spec/hyperschema/types.d.ts';
|
|
2
2
|
export type { Logger } from './lib/logger-type.ts';
|
|
3
|
-
export { Core } from './lib/core.ts';
|
|
3
|
+
export { Core, type CoreOptions } from './lib/core.ts';
|
|
4
|
+
export type { VaultManagedSkillField, VaultManagedSkills } from './lib/core/vault-managed-skills.ts';
|
|
4
5
|
export { Client } from './lib/client.ts';
|
|
5
6
|
export { AssistantClient } from './lib/assistant-client.ts';
|
|
6
7
|
export { harnessDeleteModel, harnessListModels, harnessSkillCatalog, harnessTools, QvacAssistant, type Harness, type ListModelsOptions, type ModelInfo, type ModelType, type Skill, type ToolCatalogEntry } from './lib/assistant.ts';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type MeshPool } from './current-mesh.ts';
|
|
2
2
|
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
3
|
-
export declare function createApprovalRulesApi(pool: MeshPool): Pick<CapabilityHandlers, 'listApprovalRules'>;
|
|
3
|
+
export declare function createApprovalRulesApi(pool: MeshPool): Pick<CapabilityHandlers, 'listApprovalRules' | 'removeApprovalRule'>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { listApprovalRules } from '../core/approval-rules.js';
|
|
1
|
+
import { listApprovalRules, removeApprovalRule } from '../core/approval-rules.js';
|
|
2
2
|
import { requireMesh } from './current-mesh.js';
|
|
3
3
|
export function createApprovalRulesApi(pool) {
|
|
4
4
|
return {
|
|
@@ -8,6 +8,10 @@ export function createApprovalRulesApi(pool) {
|
|
|
8
8
|
rules: await listApprovalRules(mesh),
|
|
9
9
|
ourMemberId: mesh.ourMemberId ?? undefined
|
|
10
10
|
};
|
|
11
|
+
},
|
|
12
|
+
removeApprovalRule: async ({ meshId, ruleId }) => {
|
|
13
|
+
await removeApprovalRule(await requireMesh(pool, meshId, { route: 'put-approval-rule' }), ruleId);
|
|
14
|
+
return { ok: true };
|
|
11
15
|
}
|
|
12
16
|
};
|
|
13
17
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { LoggerInterface } from '@qvac/logging';
|
|
2
2
|
import type { AssistantConfigValue } from '../../spec/hyperschema/types.d.ts';
|
|
3
|
-
import type { openLocalStore } from '../core/local/index.ts';
|
|
3
|
+
import type { ConfigEntry, openLocalStore } from '../core/local/index.ts';
|
|
4
4
|
import type { CapabilityHandlers, WatchStream } from '../../spec/capabilities.d.ts';
|
|
5
5
|
type LocalStore = Awaited<ReturnType<typeof openLocalStore>>;
|
|
6
6
|
export declare function readConfigAnswer(answer: AssistantConfigValue): AssistantConfigValue;
|
|
7
7
|
export declare function readConfigFrames(source: WatchStream<AssistantConfigValue>): WatchStream<AssistantConfigValue>;
|
|
8
|
-
|
|
8
|
+
interface ConfigWriteHooks {
|
|
9
|
+
readonly onset?: ((entry: ConfigEntry) => void | Promise<void>) | null;
|
|
10
|
+
readonly beforeSet?: ((entry: ConfigEntry) => void) | null;
|
|
11
|
+
}
|
|
12
|
+
export declare function createConfigApi(state: LocalStore, log: LoggerInterface | null, { onset, beforeSet }?: ConfigWriteHooks): Pick<CapabilityHandlers, 'configGet' | 'configSet' | 'configWatch'>;
|
|
9
13
|
export {};
|
|
@@ -2,7 +2,10 @@ import { Readable } from 'streamx';
|
|
|
2
2
|
import { watchable } from './watchable.js';
|
|
3
3
|
import { frameReadable } from '../frame-readable.js';
|
|
4
4
|
import { latestFrame } from '../latest-frame.js';
|
|
5
|
-
import { configValue, readConfigValue } from '../core/config-value.js';
|
|
5
|
+
import { QUARANTINE_PREFIX, configValue, readConfigValue } from '../core/config-value.js';
|
|
6
|
+
function readable(state, key) {
|
|
7
|
+
return key.startsWith(QUARANTINE_PREFIX) ? Promise.resolve(null) : state.get(key);
|
|
8
|
+
}
|
|
6
9
|
export function readConfigAnswer(answer) {
|
|
7
10
|
return { value: readConfigValue(answer) };
|
|
8
11
|
}
|
|
@@ -41,17 +44,18 @@ export function readConfigFrames(source) {
|
|
|
41
44
|
source.on('close', onEnd);
|
|
42
45
|
return frameReadable(output);
|
|
43
46
|
}
|
|
44
|
-
export function createConfigApi(state, log, onset = null) {
|
|
47
|
+
export function createConfigApi(state, log, { onset = null, beforeSet = null } = {}) {
|
|
45
48
|
return {
|
|
46
49
|
async configGet({ key }) {
|
|
47
|
-
return configValue(await state
|
|
50
|
+
return configValue(await readable(state, key));
|
|
48
51
|
},
|
|
49
52
|
async configSet({ key, value }) {
|
|
53
|
+
beforeSet?.({ key, value });
|
|
50
54
|
await state.set(key, value);
|
|
51
|
-
onset?.(key);
|
|
55
|
+
await onset?.({ key, value });
|
|
52
56
|
return { ok: true };
|
|
53
57
|
},
|
|
54
|
-
configWatch: watchable(() => state, async ({ key }) => configValue(await state
|
|
58
|
+
configWatch: watchable(() => state, async ({ key }) => configValue(await readable(state, key)), { name: 'configWatch', log })
|
|
55
59
|
};
|
|
56
60
|
}
|
|
57
61
|
function noop() { }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LoggerInterface } from '@qvac/logging';
|
|
2
2
|
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
3
|
-
import type { AssistantCapabilityProfile, AssistantClearModelDownloadRequest, AssistantDeleteModelRequest, AssistantDeleteModelResponse, AssistantCompactChatResponse, AssistantKvCacheDeletionResponse, AssistantListModelsRequest, AssistantLoadModelRequest, AssistantLoadModelResponse, AssistantModelCatalogRevision, AssistantCopySkillResponse, AssistantDeleteSkillResponse, AssistantManagedSkillsResponse, AssistantModelInfoList, AssistantOkResponse, AssistantPushSkillSecretRequest, AssistantSkillCatalogResponse, AssistantSkillFileResponse, AssistantSpeakRequest, AssistantSpeakResponse, AssistantToolCatalogResponse, AssistantDetectLanguageRequest, AssistantDetectLanguageResponse, AssistantTranscribeRequest, AssistantTranscribeResponse, AssistantUnloadModelRequest, AssistantUnloadModelResponse, AssistantModelUsers, AssistantModelUsersRequest } from '../../spec/hyperschema/types.d.ts';
|
|
3
|
+
import type { AssistantCapabilityProfile, AssistantClearModelDownloadRequest, AssistantDeleteModelRequest, AssistantDeleteModelResponse, AssistantCompactChatResponse, AssistantKvCacheDeletionResponse, AssistantQuarantinedSkillKeys, AssistantListModelsRequest, AssistantLoadModelRequest, AssistantLoadModelResponse, AssistantModelCatalogRevision, AssistantCopySkillResponse, AssistantDeleteSkillResponse, AssistantManagedSkillsResponse, AssistantModelInfoList, AssistantOkResponse, AssistantPushSkillSecretRequest, AssistantSkillCatalogResponse, AssistantSkillFileResponse, AssistantSpeakRequest, AssistantSpeakResponse, AssistantToolCatalogResponse, AssistantDetectLanguageRequest, AssistantDetectLanguageResponse, AssistantTranscribeRequest, AssistantTranscribeResponse, AssistantUnloadModelRequest, AssistantUnloadModelResponse, AssistantModelUsers, AssistantModelUsersRequest } from '../../spec/hyperschema/types.d.ts';
|
|
4
4
|
import type { openLocalStore } from '../core/local/index.ts';
|
|
5
5
|
import type { Mesh } from '../core/mesh.ts';
|
|
6
6
|
import { type MeshPool } from './current-mesh.ts';
|
|
@@ -78,7 +78,17 @@ interface ApiDeps {
|
|
|
78
78
|
nameOf?: NameOf | null;
|
|
79
79
|
workspaceOf?: ((projectId: string) => Promise<string | null>) | null;
|
|
80
80
|
pushSkillSecret?: ((request: AssistantPushSkillSecretRequest) => Promise<void>) | null;
|
|
81
|
-
|
|
81
|
+
listQuarantinedSkills?: (() => Promise<AssistantQuarantinedSkillKeys>) | null;
|
|
82
|
+
retryQuarantinedSkills?: (() => Promise<AssistantQuarantinedSkillKeys>) | null;
|
|
83
|
+
discardQuarantinedSkills?: ((input: AssistantQuarantinedSkillKeys) => Promise<AssistantQuarantinedSkillKeys>) | null;
|
|
84
|
+
beforeConfigSet?: ((entry: {
|
|
85
|
+
readonly key: string;
|
|
86
|
+
readonly value: unknown;
|
|
87
|
+
}) => void) | null;
|
|
88
|
+
onConfigSet?: ((entry: {
|
|
89
|
+
readonly key: string;
|
|
90
|
+
readonly value: unknown;
|
|
91
|
+
}) => void | Promise<void>) | null;
|
|
82
92
|
storageRoot?: string | null;
|
|
83
93
|
skills?: ((agentId?: string | null, modelName?: string | null, options?: SkillOptions) => Promise<unknown>) | null;
|
|
84
94
|
skillCatalog?: ((agentId?: string | null, modelName?: string | null, options?: {
|
|
@@ -46,7 +46,9 @@ export function createApi(deps = {}) {
|
|
|
46
46
|
const members = mesh && deps.meshStatus ? createMembersApi(mesh, deps.meshStatus, { state, log }) : null;
|
|
47
47
|
const folders = state && deps.storageRoot ? new AgentFolders(state, { storageRoot: deps.storageRoot }) : null;
|
|
48
48
|
const handlers = {
|
|
49
|
-
...(state
|
|
49
|
+
...(state
|
|
50
|
+
? createConfigApi(state, log, { onset: deps.onConfigSet, beforeSet: deps.beforeConfigSet })
|
|
51
|
+
: null),
|
|
50
52
|
...(state ? createAppConfigApi(state, log) : null),
|
|
51
53
|
...(state ? createModelDownloadApi(state, log) : null),
|
|
52
54
|
...(state
|
|
@@ -183,6 +185,9 @@ export function createApi(deps = {}) {
|
|
|
183
185
|
unloadModel: deps.unloadModel ?? undefined,
|
|
184
186
|
modelUsers: deps.modelUsers ?? undefined,
|
|
185
187
|
clearKvCache: deps.clearKvCache ?? undefined,
|
|
188
|
+
listQuarantinedSkills: deps.listQuarantinedSkills ?? undefined,
|
|
189
|
+
retryQuarantinedSkills: deps.retryQuarantinedSkills ?? undefined,
|
|
190
|
+
discardQuarantinedSkills: deps.discardQuarantinedSkills ?? undefined,
|
|
186
191
|
deleteChatKvCache: deleteChatKvCache
|
|
187
192
|
? ({ chatId }) => deleteChatKvCache(chatId)
|
|
188
193
|
: undefined,
|
package/dist-lib/lib/api/rag.js
CHANGED
|
@@ -41,13 +41,14 @@ export function createRagApi(pool, { index, embedder, effectiveCtxSize = null })
|
|
|
41
41
|
const kept = (id) => !off.has('chat') || scopeIds.has(id);
|
|
42
42
|
const chatKnowledge = async () => (await mesh.files.listKnowledge(chatId)).filter((row) => kept(row.id));
|
|
43
43
|
const chatFiles = async () => (await mesh.files.status(chatId)).files.filter((file) => kept(file.fileId));
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
const indexingHere = (files) => files.filter((file) => scopeIds.has(file.fileId) && mesh.files.indexesHere(file)).length;
|
|
45
|
+
if (!immediate && scopeIds.size > 0) {
|
|
46
|
+
await mesh.files.indexingHere(chatId, [...scopeIds]);
|
|
46
47
|
}
|
|
47
48
|
const chatRows = await chatKnowledge();
|
|
48
49
|
const initialFiles = await chatFiles();
|
|
49
50
|
pendingFiles = pendingFileNames(initialFiles);
|
|
50
|
-
chatFilesIndexingHere = initialFiles
|
|
51
|
+
chatFilesIndexingHere = indexingHere(initialFiles);
|
|
51
52
|
const scopeRows = chatRows.filter((row) => scopeIds.has(row.id));
|
|
52
53
|
const project = off.has('project')
|
|
53
54
|
? null
|
|
@@ -63,10 +64,9 @@ export function createRagApi(pool, { index, embedder, effectiveCtxSize = null })
|
|
|
63
64
|
});
|
|
64
65
|
if (fullText) {
|
|
65
66
|
const read = new Set(scopeRows.map((row) => row.id));
|
|
66
|
-
const unread = initialFiles.filter((file) => !read.has(file.fileId));
|
|
67
67
|
return respond({
|
|
68
68
|
pendingFiles: pendingFileNames(initialFiles, read),
|
|
69
|
-
chatFilesIndexingHere:
|
|
69
|
+
chatFilesIndexingHere: 0,
|
|
70
70
|
searchedCount: fullText.length,
|
|
71
71
|
indexEmpty: false,
|
|
72
72
|
hasKnowledge: true,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import b4a from 'b4a';
|
|
2
|
-
import { ToolSets } from '@qvac/harness';
|
|
2
|
+
import { renderedTools, ToolSets } from '@qvac/harness';
|
|
3
3
|
import { AbortedError } from '@qvac/harness/race-abort';
|
|
4
4
|
import * as z from 'zod';
|
|
5
5
|
import { errorMessage, isRecord } from '../guards.js';
|
|
@@ -94,7 +94,7 @@ export class OwnerRounds {
|
|
|
94
94
|
round,
|
|
95
95
|
modelId,
|
|
96
96
|
messages: history,
|
|
97
|
-
tools,
|
|
97
|
+
tools: renderedTools(tools, history),
|
|
98
98
|
generationParams,
|
|
99
99
|
responseFormat,
|
|
100
100
|
toolDialect,
|
|
@@ -165,6 +165,7 @@ export declare class QvacAssistant extends ReadyResource {
|
|
|
165
165
|
private _unloadModel;
|
|
166
166
|
modelUsers(name: string): Promise<AssistantModelUsers>;
|
|
167
167
|
private _meshModelUsers;
|
|
168
|
+
private _runModel;
|
|
168
169
|
private _runnableHost;
|
|
169
170
|
notifyModelCatalog(): void;
|
|
170
171
|
cachedModelsChanged(): void;
|
|
@@ -1108,6 +1108,11 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1108
1108
|
}));
|
|
1109
1109
|
return perAgent.flat();
|
|
1110
1110
|
}
|
|
1111
|
+
async _runModel(agent, deviceId) {
|
|
1112
|
+
if (!b4a.equals(agent.providerDeviceId, deviceId))
|
|
1113
|
+
return agent.modelName;
|
|
1114
|
+
return runnableModelName(agent.modelName, await this._runnableHost());
|
|
1115
|
+
}
|
|
1111
1116
|
async _runnableHost() {
|
|
1112
1117
|
const capability = await this._ensureCapability();
|
|
1113
1118
|
return capability && { ...capability, mobile: this._mobileClass };
|
|
@@ -1882,7 +1887,8 @@ export class QvacAssistant extends ReadyResource {
|
|
|
1882
1887
|
await this._deleteChatKvCache(chatId, 'superseding run');
|
|
1883
1888
|
}
|
|
1884
1889
|
}
|
|
1885
|
-
const
|
|
1890
|
+
const servedElsewhere = !b4a.equals(agent.providerDeviceId, deviceId);
|
|
1891
|
+
const model = await this._runModel(agent, deviceId);
|
|
1886
1892
|
if (model !== agent.modelName) {
|
|
1887
1893
|
this._log?.warn('runs', 'model clamped to what this device can run', {
|
|
1888
1894
|
runId,
|
|
@@ -2024,11 +2030,13 @@ export class QvacAssistant extends ReadyResource {
|
|
|
2024
2030
|
held.status.then(({ id }) => transcript.progress(id, runStatus)).catch(noop);
|
|
2025
2031
|
};
|
|
2026
2032
|
try {
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2033
|
+
if (!servedElsewhere) {
|
|
2034
|
+
await this._downloads?.waitUntilCached(model, controller.signal, {
|
|
2035
|
+
onHold: () => showWait({ phase: 'awaiting-download', model }),
|
|
2036
|
+
onProgress: (percentage) => showWait(downloadingProgress(model, percentage)),
|
|
2037
|
+
onStall: () => showWait(null)
|
|
2038
|
+
});
|
|
2039
|
+
}
|
|
2032
2040
|
}
|
|
2033
2041
|
catch (err) {
|
|
2034
2042
|
readinessError = err instanceof Error ? err : new Error(String(err));
|
|
@@ -3482,7 +3490,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
3482
3490
|
if (!agent || !(options.run || b4a.equals(agent.providerDeviceId, deviceId))) {
|
|
3483
3491
|
return { compacted: false, reason: 'not the provider device' };
|
|
3484
3492
|
}
|
|
3485
|
-
const model =
|
|
3493
|
+
const model = await this._runModel(agent, deviceId);
|
|
3486
3494
|
const config = await engine.getConfig({}).catch(noop);
|
|
3487
3495
|
const ctxSize = agent.ctxSize || config?.ctxSize || undefined;
|
|
3488
3496
|
if (ctxSize !== undefined && !canCompact(ctxSize)) {
|
|
@@ -3861,6 +3869,7 @@ export class QvacAssistant extends ReadyResource {
|
|
|
3861
3869
|
toolName: call.name,
|
|
3862
3870
|
resource: call.resource,
|
|
3863
3871
|
agentId,
|
|
3872
|
+
chatId,
|
|
3864
3873
|
memberId: ourMemberId
|
|
3865
3874
|
});
|
|
3866
3875
|
if (rule) {
|
|
@@ -23,9 +23,15 @@ export async function followAgentCopies(account, into, { deviceId, agentId }) {
|
|
|
23
23
|
if (!copy || into.closing)
|
|
24
24
|
continue;
|
|
25
25
|
const agent = await putNewer(account, into, { id: copy.id, copy });
|
|
26
|
-
if (agent?.deletedAt
|
|
26
|
+
if (!agent?.deletedAt || copy.deletedAt) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (agent.chatRetention === 'delete') {
|
|
27
30
|
await softDeleteChatsForAgent(into, deviceId, agent.id);
|
|
28
31
|
}
|
|
32
|
+
else if (deviceId) {
|
|
33
|
+
await cancelRunsForAgent(into, deviceId, agent.id);
|
|
34
|
+
}
|
|
29
35
|
}
|
|
30
36
|
}
|
|
31
37
|
export async function keepCopyChats(into, agent, deviceId) {
|
|
@@ -212,6 +212,7 @@ export async function deleteAgent(store, deviceId, { id, keepChats, keepCopies }
|
|
|
212
212
|
const updated = {
|
|
213
213
|
...current,
|
|
214
214
|
deletedAt,
|
|
215
|
+
chatRetention: keepChats ? 'retain' : 'delete',
|
|
215
216
|
updatedAt: Math.max(deletedAt, current.updatedAt + 1)
|
|
216
217
|
};
|
|
217
218
|
if (keepChats) {
|
|
@@ -4,13 +4,17 @@ export interface ResourceDescriptor {
|
|
|
4
4
|
kind: string;
|
|
5
5
|
label: string;
|
|
6
6
|
}
|
|
7
|
-
type PutApprovalRuleInput = Pick<QvacApprovalRule, 'toolName' | 'resourceKind' | 'resourcePattern' | 'decision' | 'expiresAt' | 'agentId' | 'effect'
|
|
7
|
+
type PutApprovalRuleInput = Pick<QvacApprovalRule, 'toolName' | 'resourceKind' | 'resourcePattern' | 'decision' | 'expiresAt' | 'agentId' | 'effect' | 'chatId'> & {
|
|
8
|
+
readonly id?: string;
|
|
9
|
+
};
|
|
8
10
|
export declare function listApprovalRules(store: Mesh): Promise<QvacApprovalRule[]>;
|
|
9
11
|
export declare function putApprovalRule(store: Mesh, input: PutApprovalRuleInput): Promise<QvacApprovalRule>;
|
|
12
|
+
export declare function removeApprovalRule(store: Mesh, id: string): Promise<void>;
|
|
10
13
|
export interface ApprovalRuleQuery {
|
|
11
14
|
readonly toolName: string;
|
|
12
15
|
readonly resource?: ResourceDescriptor | null;
|
|
13
16
|
readonly agentId?: string;
|
|
17
|
+
readonly chatId?: string;
|
|
14
18
|
readonly memberId?: Buffer | null;
|
|
15
19
|
}
|
|
16
20
|
export declare function matchApprovalRule(rules: ReadonlyArray<QvacApprovalRule>, input: ApprovalRuleQuery, now?: number): QvacApprovalRule | null;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { randomId } from './id.js';
|
|
2
2
|
import b4a from 'b4a';
|
|
3
3
|
import { APPROVAL_RULES } from './collections.js';
|
|
4
|
+
import { CoreError } from '../errors.js';
|
|
4
5
|
export async function listApprovalRules(store) {
|
|
5
6
|
const snap = store.view.snapshot();
|
|
6
7
|
try {
|
|
@@ -13,10 +14,21 @@ export async function listApprovalRules(store) {
|
|
|
13
14
|
}
|
|
14
15
|
export async function putApprovalRule(store, input) {
|
|
15
16
|
const now = Date.now();
|
|
16
|
-
const rule = {
|
|
17
|
+
const rule = { id: randomId(), ...input, createdAt: now, updatedAt: now };
|
|
17
18
|
await store.dispatch('put-approval-rule', { rule });
|
|
18
19
|
return rule;
|
|
19
20
|
}
|
|
21
|
+
export async function removeApprovalRule(store, id) {
|
|
22
|
+
const rule = await store.view.get(APPROVAL_RULES, { id });
|
|
23
|
+
const ours = !!rule?.memberId && !!store.ourMemberId && b4a.equals(rule.memberId, store.ourMemberId);
|
|
24
|
+
if (!rule || !ours) {
|
|
25
|
+
throw new CoreError('APPROVAL_RULE_NOT_FOUND', [id]);
|
|
26
|
+
}
|
|
27
|
+
const now = Date.now();
|
|
28
|
+
await store.dispatch('put-approval-rule', {
|
|
29
|
+
rule: { ...rule, expiresAt: now, updatedAt: Math.max(now, rule.updatedAt + 1) }
|
|
30
|
+
});
|
|
31
|
+
}
|
|
20
32
|
export function matchApprovalRule(rules, input, now = Date.now()) {
|
|
21
33
|
for (const rule of rules) {
|
|
22
34
|
if (!input.memberId || !rule.memberId || !b4a.equals(rule.memberId, input.memberId)) {
|
|
@@ -30,6 +42,9 @@ export function matchApprovalRule(rules, input, now = Date.now()) {
|
|
|
30
42
|
if (rule.agentId && rule.agentId !== input.agentId) {
|
|
31
43
|
continue;
|
|
32
44
|
}
|
|
45
|
+
if (rule.chatId && rule.chatId !== input.chatId) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
33
48
|
if (!matchesResource(rule, input.resource ?? null)) {
|
|
34
49
|
continue;
|
|
35
50
|
}
|
|
@@ -388,7 +388,6 @@ export function updateOp(chunk, { id, runStatus, attachment }) {
|
|
|
388
388
|
'a run-status edits runStatus, an attachment edits attachment'
|
|
389
389
|
]);
|
|
390
390
|
}
|
|
391
|
-
const DEFAULT_APPROVAL_RULE_TTL_MS = 60 * 60 * 1000;
|
|
392
391
|
export async function othersApproval(store, id) {
|
|
393
392
|
const ask = await getChunk(store, id);
|
|
394
393
|
return !!ask && (await projectRun(store)) && !(await ownedByUs(store, ask));
|
|
@@ -402,13 +401,15 @@ export async function resolveApproval(store, { id, approved, scope, expiresAt, a
|
|
|
402
401
|
const ask = resolved.approvalRequest;
|
|
403
402
|
if (ask && (ask.status === 'approved' || ask.status === 'denied')) {
|
|
404
403
|
await putApprovalRule(rules, {
|
|
404
|
+
id,
|
|
405
405
|
toolName: ask.name,
|
|
406
406
|
resourceKind: ask.resource?.kind ?? undefined,
|
|
407
407
|
resourcePattern: ask.resource?.label ?? undefined,
|
|
408
408
|
decision: ask.status === 'approved' ? 'allow' : 'deny',
|
|
409
|
-
expiresAt
|
|
409
|
+
expiresAt,
|
|
410
410
|
agentId: ask.agentId ?? agentId,
|
|
411
|
-
effect: resolved.effect ?? undefined
|
|
411
|
+
effect: resolved.effect ?? undefined,
|
|
412
|
+
chatId: resolved.chatId
|
|
412
413
|
});
|
|
413
414
|
}
|
|
414
415
|
}
|
|
@@ -245,7 +245,7 @@ async function putMemberKey(op, context) {
|
|
|
245
245
|
await tx.insert(MEMBER_KEYS, row);
|
|
246
246
|
return row;
|
|
247
247
|
}
|
|
248
|
-
async function upgradeToWorkspace(
|
|
248
|
+
async function upgradeToWorkspace(_op, context) {
|
|
249
249
|
const { tx, log } = context;
|
|
250
250
|
const kind = await meshKind(tx);
|
|
251
251
|
const onRules = (await rulesVersion(tx)) >= WORKSPACES_RULES;
|
|
@@ -270,7 +270,7 @@ async function upgradeToWorkspace({ upgradedAt }, context) {
|
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
272
|
await tx.insert(MESH_KINDS, { id: 'mesh', kind: 'workspace' });
|
|
273
|
-
const row = { id: WORKSPACE_ROW, updatedAt:
|
|
273
|
+
const row = { id: WORKSPACE_ROW, updatedAt: 0, upgradeMemberIds };
|
|
274
274
|
await tx.insert(WORKSPACE, row);
|
|
275
275
|
log?.info('contract', 'shared mesh upgraded to a workspace');
|
|
276
276
|
return row;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { QvacChunk } from '../../spec/mesh/hyperschema/types.d.ts';
|
|
2
|
+
import type { Mesh } from './mesh.ts';
|
|
3
|
+
export interface LandedRuns {
|
|
4
|
+
readonly requests: QvacChunk[];
|
|
5
|
+
readonly deletedAgents: Set<string>;
|
|
6
|
+
}
|
|
7
|
+
export declare function cancelDeletedAgentRuns(mesh: Mesh, deviceId: Buffer, landed: LandedRuns | null): Promise<void>;
|