@qvac/core 1.0.0-rc.2 → 1.0.0-rc.3
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 +158 -2
- package/dist-lib/index.d.ts +1 -0
- package/dist-lib/index.js +1 -0
- package/dist-lib/lib/api/chunk-delta.d.ts +7 -2
- package/dist-lib/lib/api/chunk-delta.js +89 -7
- package/dist-lib/lib/api/chunks.js +14 -8
- package/dist-lib/lib/api/config.d.ts +4 -1
- package/dist-lib/lib/api/config.js +45 -4
- package/dist-lib/lib/api/custom-models.js +3 -5
- package/dist-lib/lib/api/devices.js +3 -1
- package/dist-lib/lib/api/files.d.ts +1 -1
- package/dist-lib/lib/api/files.js +65 -8
- package/dist-lib/lib/api/instrument.js +12 -4
- package/dist-lib/lib/api/members.js +7 -13
- package/dist-lib/lib/api/mesh.d.ts +1 -3
- package/dist-lib/lib/api/mesh.js +2 -2
- package/dist-lib/lib/api/notifications.js +8 -4
- package/dist-lib/lib/api/projects.js +5 -1
- package/dist-lib/lib/api/rag.js +32 -19
- package/dist-lib/lib/api/served.js +2 -1
- package/dist-lib/lib/api/workspace.js +0 -1
- package/dist-lib/lib/assistant/harness.d.ts +8 -2
- package/dist-lib/lib/assistant/harness.js +17 -4
- package/dist-lib/lib/assistant/history.d.ts +1 -1
- package/dist-lib/lib/assistant/history.js +19 -13
- package/dist-lib/lib/assistant/message.d.ts +6 -1
- package/dist-lib/lib/assistant/message.js +22 -2
- package/dist-lib/lib/assistant/model-round.d.ts +5 -0
- package/dist-lib/lib/assistant/model-round.js +46 -18
- package/dist-lib/lib/assistant/pdf-budget.d.ts +10 -2
- package/dist-lib/lib/assistant/pdf-budget.js +10 -11
- package/dist-lib/lib/assistant/pdf-pages.d.ts +25 -0
- package/dist-lib/lib/assistant/pdf-pages.js +75 -0
- package/dist-lib/lib/assistant/round-host.js +5 -3
- package/dist-lib/lib/assistant-client.d.ts +2 -1
- package/dist-lib/lib/assistant-client.js +24 -6
- package/dist-lib/lib/assistant-tree.d.ts +2 -0
- package/dist-lib/lib/assistant-tree.js +8 -5
- package/dist-lib/lib/assistant.d.ts +20 -7
- package/dist-lib/lib/assistant.js +468 -240
- package/dist-lib/lib/client.js +10 -1
- package/dist-lib/lib/compaction.d.ts +3 -1
- package/dist-lib/lib/compaction.js +18 -4
- package/dist-lib/lib/constants.d.ts +3 -0
- package/dist-lib/lib/constants.js +3 -0
- package/dist-lib/lib/core/chat-activity.js +13 -16
- package/dist-lib/lib/core/chat-copy.js +1 -1
- package/dist-lib/lib/core/chat-fork.js +2 -1
- package/dist-lib/lib/core/chat-move.d.ts +4 -0
- package/dist-lib/lib/core/chat-move.js +42 -11
- package/dist-lib/lib/core/chat.d.ts +0 -1
- package/dist-lib/lib/core/chat.js +1 -1
- package/dist-lib/lib/core/chunk.d.ts +14 -3
- package/dist-lib/lib/core/chunk.js +112 -22
- package/dist-lib/lib/core/collections.d.ts +12 -1
- package/dist-lib/lib/core/collections.js +12 -1
- package/dist-lib/lib/core/config-value.d.ts +6 -0
- package/dist-lib/lib/core/config-value.js +14 -0
- package/dist-lib/lib/core/contract/activity.d.ts +3 -2
- package/dist-lib/lib/core/contract/activity.js +39 -21
- package/dist-lib/lib/core/contract/agent-join.js +15 -19
- package/dist-lib/lib/core/contract/agents.js +8 -7
- package/dist-lib/lib/core/contract/chat.d.ts +3 -0
- package/dist-lib/lib/core/contract/chat.js +12 -1
- package/dist-lib/lib/core/contract/chunks.js +16 -6
- package/dist-lib/lib/core/contract/devices.js +6 -4
- package/dist-lib/lib/core/contract/index.js +2 -1
- package/dist-lib/lib/core/contract/invites.js +12 -31
- package/dist-lib/lib/core/contract/joined-meshes.js +2 -1
- package/dist-lib/lib/core/contract/mesh-rules.js +4 -0
- package/dist-lib/lib/core/contract/model-requests.js +7 -6
- package/dist-lib/lib/core/contract/project-device-keys.js +15 -6
- package/dist-lib/lib/core/contract/project-host-keys.js +5 -4
- package/dist-lib/lib/core/contract/projects.js +12 -13
- package/dist-lib/lib/core/contract/public-seeds.js +5 -5
- package/dist-lib/lib/core/contract/roles.js +2 -1
- package/dist-lib/lib/core/contract/run-requests.d.ts +1 -1
- package/dist-lib/lib/core/contract/run-requests.js +19 -13
- package/dist-lib/lib/core/contract/shipped-rows.d.ts +2 -0
- package/dist-lib/lib/core/contract/shipped-rows.js +22 -0
- package/dist-lib/lib/core/contract/workspace.js +4 -10
- package/dist-lib/lib/core/contract/writers.js +20 -6
- package/dist-lib/lib/core/devices.d.ts +2 -1
- package/dist-lib/lib/core/devices.js +4 -2
- package/dist-lib/lib/core/document-attachment.d.ts +6 -3
- package/dist-lib/lib/core/document-attachment.js +10 -5
- package/dist-lib/lib/core/files/attachments.js +3 -3
- package/dist-lib/lib/core/files/index.d.ts +8 -5
- package/dist-lib/lib/core/files/index.js +109 -18
- package/dist-lib/lib/core/files/processing/index.d.ts +1 -1
- package/dist-lib/lib/core/files/processing/index.js +8 -2
- package/dist-lib/lib/core/files/processing/source.d.ts +1 -0
- package/dist-lib/lib/core/files/processing/source.js +3 -0
- package/dist-lib/lib/core/files/processing/state.d.ts +1 -0
- package/dist-lib/lib/core/files/processing/state.js +7 -0
- package/dist-lib/lib/core/files/rag/build.d.ts +1 -0
- package/dist-lib/lib/core/files/rag/build.js +14 -1
- package/dist-lib/lib/core/files/rag/index.d.ts +1 -1
- package/dist-lib/lib/core/files/rag/index.js +1 -1
- package/dist-lib/lib/core/files/rag/produce.js +1 -0
- package/dist-lib/lib/core/files/rag/retrieval/full-text.d.ts +2 -0
- package/dist-lib/lib/core/files/rag/retrieval/full-text.js +7 -1
- package/dist-lib/lib/core/first-event.d.ts +6 -0
- package/dist-lib/lib/core/first-event.js +13 -0
- package/dist-lib/lib/core/invite.d.ts +2 -2
- package/dist-lib/lib/core/invite.js +5 -4
- package/dist-lib/lib/core/local/index.d.ts +10 -1
- package/dist-lib/lib/core/local/index.js +105 -10
- package/dist-lib/lib/core/mesh.d.ts +15 -4
- package/dist-lib/lib/core/mesh.js +128 -57
- package/dist-lib/lib/core/migrations/chat-chunks.d.ts +4 -0
- package/dist-lib/lib/core/migrations/chat-chunks.js +47 -0
- package/dist-lib/lib/core/migrations/file-index.d.ts +1 -1
- package/dist-lib/lib/core/migrations/file-index.js +6 -2
- package/dist-lib/lib/core/migrations/index.d.ts +2 -1
- package/dist-lib/lib/core/migrations/index.js +66 -9
- package/dist-lib/lib/core/notification.js +96 -23
- package/dist-lib/lib/core/pdf/figure.d.ts +22 -0
- package/dist-lib/lib/core/pdf/figure.js +64 -0
- package/dist-lib/lib/core/pdf/rasterize.d.ts +10 -1
- package/dist-lib/lib/core/pdf/rasterize.js +72 -22
- package/dist-lib/lib/core/peer-duplex.js +57 -5
- package/dist-lib/lib/core/public-mesh.js +8 -2
- package/dist-lib/lib/core/run-requests.js +2 -3
- package/dist-lib/lib/core/senders.d.ts +7 -6
- package/dist-lib/lib/core/senders.js +23 -30
- package/dist-lib/lib/core/shared-agents.d.ts +1 -0
- package/dist-lib/lib/core/shared-agents.js +47 -19
- package/dist-lib/lib/core/sync/background.d.ts +3 -15
- package/dist-lib/lib/core/sync/background.js +25 -102
- package/dist-lib/lib/core/sync/devices.js +6 -3
- package/dist-lib/lib/core/sync/index.js +12 -2
- package/dist-lib/lib/core/sync-status.js +3 -3
- package/dist-lib/lib/core.d.ts +59 -10
- package/dist-lib/lib/core.js +706 -174
- package/dist-lib/lib/credential-pusher.d.ts +11 -7
- package/dist-lib/lib/credential-pusher.js +40 -8
- package/dist-lib/lib/device-tree.d.ts +18 -0
- package/dist-lib/lib/device-tree.js +32 -0
- package/dist-lib/lib/doctor/redact.js +1 -1
- package/dist-lib/lib/errors.d.ts +4 -0
- package/dist-lib/lib/errors.js +4 -0
- package/dist-lib/lib/fs-drive-bridge.d.ts +7 -0
- package/dist-lib/lib/fs-drive-bridge.js +308 -30
- package/dist-lib/lib/integrations/setup-routes.js +7 -5
- package/dist-lib/lib/knowledge-search.d.ts +1 -1
- package/dist-lib/lib/knowledge-search.js +5 -46
- package/dist-lib/lib/kv-cache-retention.d.ts +35 -0
- package/dist-lib/lib/kv-cache-retention.js +98 -0
- package/dist-lib/lib/latest-frame.d.ts +10 -0
- package/dist-lib/lib/latest-frame.js +48 -0
- package/dist-lib/lib/model-download.d.ts +6 -1
- package/dist-lib/lib/model-download.js +32 -17
- package/dist-lib/lib/oauth/resolve.js +13 -5
- package/dist-lib/lib/reconnecting-watch.js +19 -11
- package/dist-lib/lib/run-notices.d.ts +2 -0
- package/dist-lib/lib/run-notices.js +5 -0
- package/dist-lib/lib/run-replay.d.ts +13 -1
- package/dist-lib/lib/run-replay.js +58 -21
- package/dist-lib/schema/build.js +66 -57
- package/dist-lib/schema/content.js +2 -1
- package/dist-lib/schema/engine.js +37 -5
- package/dist-lib/schema/field-order.js +7 -1
- package/dist-lib/schema/indexes.d.ts +4 -0
- package/dist-lib/schema/indexes.js +18 -0
- package/dist-lib/schema/local.js +9 -2
- package/dist-lib/schema/qvac.js +112 -4
- package/dist-lib/spec/bind.js +3 -0
- package/dist-lib/spec/calls.js +1 -0
- package/dist-lib/spec/capabilities.d.ts +2 -0
- package/dist-lib/spec/hrpc/hrpc.json +13 -0
- package/dist-lib/spec/hrpc/index.js +15 -3
- package/dist-lib/spec/hrpc/messages.js +1475 -1392
- package/dist-lib/spec/hyperschema/index.js +1475 -1392
- package/dist-lib/spec/hyperschema/schema.json +86 -1
- package/dist-lib/spec/hyperschema/types.d.ts +21 -1
- package/dist-lib/spec/local/hyperdb/messages.js +110 -54
- package/dist-lib/spec/local/hyperschema/index.js +56 -28
- package/dist-lib/spec/local/hyperschema/schema.json +55 -20
- package/dist-lib/spec/local/hyperschema/types.d.ts +8 -1
- package/dist-lib/spec/mesh/hyperdb/db.json +255 -51
- package/dist-lib/spec/mesh/hyperdb/index.js +1063 -404
- package/dist-lib/spec/mesh/hyperdb/messages.js +1647 -1214
- package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +62 -56
- package/dist-lib/spec/mesh/hyperdispatch/index.js +156 -139
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +787 -629
- package/dist-lib/spec/mesh/hyperschema/index.js +787 -629
- package/dist-lib/spec/mesh/hyperschema/schema.json +283 -174
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +29 -1
- package/package.json +23 -17
- package/worker/assistant-sidecar.mjs +3 -0
- package/dist-lib/lib/core/files/processing/settle.d.ts +0 -13
- package/dist-lib/lib/core/files/processing/settle.js +0 -86
- package/dist-lib/lib/core/migrations/device-indexes.d.ts +0 -2
- package/dist-lib/lib/core/migrations/device-indexes.js +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,23 @@ release.
|
|
|
15
15
|
|
|
16
16
|
### Added
|
|
17
17
|
|
|
18
|
+
- A completed run that primed the chat cache after Core deleted it says so on its
|
|
19
|
+
`run-status.metrics`: `cacheRebuild` carries Core's deletion reason and the prompt tokens of the
|
|
20
|
+
run's first round on the key, as its `metrics.rounds` counts them, null when that round has no
|
|
21
|
+
count. A run whose first round was taken on another device reports nothing, since that device
|
|
22
|
+
keeps its own cache. A run that reused the cache carries no key.
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
const { runStatus } = chunk
|
|
26
|
+
if (runStatus.state === 'completed' && runStatus.metrics?.cacheRebuild) {
|
|
27
|
+
const { reason, tokens } = runStatus.metrics.cacheRebuild
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- The last agent to stop running a loaded model on a device — deleted, moved to another device or
|
|
32
|
+
switched to another model — unloads it there, so the memory is freed without waiting for the idle
|
|
33
|
+
sweep. A model loaded by hand that no agent runs stays loaded.
|
|
34
|
+
|
|
18
35
|
- `@qvac/core/sidecar-entry` names the script a host spawns as Core's sidecar, so a host
|
|
19
36
|
resolves it by name instead of a path into the package. `test/basic/entry-weight.ts` holds
|
|
20
37
|
every named entry to a ceiling on the files importing it loads, so an app that imports a
|
|
@@ -50,11 +67,36 @@ release.
|
|
|
50
67
|
without fetching the default models. A sidecar that fails to start also writes
|
|
51
68
|
the reason to stderr, since the host may not be listening yet.
|
|
52
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
|
+
|
|
53
83
|
### Changed
|
|
54
84
|
|
|
55
|
-
-
|
|
85
|
+
- The KV cache retention sweep runs every 12 hours instead of every hour, besides when a mesh opens
|
|
86
|
+
and when `kvCache.retentionDays` changes, so a cache can outlive its retention by up to 12 hours
|
|
87
|
+
on a host that stays up. ([config.md](docs/api/config.md#kv-cache-retention))
|
|
88
|
+
|
|
89
|
+
- Core depends on `@qvac/harness` 1.0.0-rc.12 from npm instead of a git commit, so a consumer installs
|
|
56
90
|
the published harness with its named entries.
|
|
57
91
|
|
|
92
|
+
- Wipe a store written by 1.0.0-rc.0 to rc.2 before running this build. The collection, route and
|
|
93
|
+
field ids those prereleases gave the 1.0 additions moved up by one to keep 0.11.1's in place, so
|
|
94
|
+
this build misreads their rows without an error. A store from 0.11.1 or earlier upgrades as is.
|
|
95
|
+
Nor does the wipe carry over a mesh an rc wrote to, minted there or a 0.11 mesh an rc device
|
|
96
|
+
held writable, since an rc raises the rules on each: other peers and the blind peers still hold
|
|
97
|
+
its rc-numbered ops, so a device that rejoins it, by a recovery from the phrase too, misreads
|
|
98
|
+
them again. Start a new account on this build instead.
|
|
99
|
+
|
|
58
100
|
- The baked version floor is `>=0.21.0`: one build per mesh, since v0.21 changes
|
|
59
101
|
what apply admits. Each mesh now holds a rules row, `@qvac/mesh-rules`, first
|
|
60
102
|
in a new mesh's genesis and appended once when this build first holds an
|
|
@@ -71,6 +113,24 @@ release.
|
|
|
71
113
|
update prompt with the code `MESH_RULES_FROM_A_NEWER_BUILD`, instead of being
|
|
72
114
|
applied.
|
|
73
115
|
|
|
116
|
+
- A `mesh write` or `mesh drain` stall now keeps reporting while it lasts. Each `… still pending`
|
|
117
|
+
line carries `reports` (1, 2, 3 …), and the wait doubles between reports. It also names:
|
|
118
|
+
- `fastForwarding`: the head a fast-forward is booting onto, with how much of that core this
|
|
119
|
+
device and its peers hold, or `null`.
|
|
120
|
+
- `peerLength` and `peerHeld` on every `missing` core: how far the furthest connected peer
|
|
121
|
+
knows that core, and how much of it that peer holds from block 0.
|
|
122
|
+
- `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
|
+
- `core opening` is the first line of a launch. It names the app's `version`, `build` and
|
|
126
|
+
`channel`, and the mesh `schema` this core applies. A mesh's own `opening` line names the
|
|
127
|
+
`schema` too.
|
|
128
|
+
- `migrations ran` follows each pass on open. It lists the steps that wrote, each step's `ms`,
|
|
129
|
+
and the step that threw as `failed`. A pass still going after 15 s logs
|
|
130
|
+
`migrations still running` with its current step, again after 30 s, 60 s, and so on.
|
|
131
|
+
- `copied chats into chat-chunks` and `recorded the files the mesh already held` give each
|
|
132
|
+
backfill's count and `ms`.
|
|
133
|
+
|
|
74
134
|
### Removed
|
|
75
135
|
|
|
76
136
|
- The `duck` terminal UI and its bin; the terminal app lives in its own repo.
|
|
@@ -79,6 +139,101 @@ release.
|
|
|
79
139
|
|
|
80
140
|
- A resume whose announce reached no DHT node retries that topic within
|
|
81
141
|
seconds, instead of leaving the device unfindable for ten minutes.
|
|
142
|
+
- Chat activity no longer diffs across a fast-forward it has not counted yet. It
|
|
143
|
+
dropped its cached view head only once `fastForwards` moved, which can be
|
|
144
|
+
after the view has landed on another core, and a diff from the old head read
|
|
145
|
+
every node of the new view. It now drops the head whenever the view is on
|
|
146
|
+
another core, as `chunksDeltaWatch` does.
|
|
147
|
+
- A device that does not hold a mesh no longer downloads most of it to show chat
|
|
148
|
+
activity and notifications. Both read a few chunk types per chat, each through
|
|
149
|
+
its type index and then row by row from `@qvac/chunks`; they now read the
|
|
150
|
+
chat's range of `@qvac/chat-chunks` once and keep those types, where that
|
|
151
|
+
range is whole. A member joining a 170-chat mesh with both open downloaded
|
|
152
|
+
about 39,000 blocks (155 MB) instead of 258,000 (640 MB), and on a device that
|
|
153
|
+
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
|
+
- The assistant no longer logs `saveDeviceCapabilities failed` while the account mesh is still
|
|
156
|
+
joining. Core refuses the report with `MESH_STILL_JOINING` until this device is a writer, and the
|
|
157
|
+
assistant already reports again once the account turns writable, so the refusal was never a
|
|
158
|
+
failure.
|
|
159
|
+
|
|
160
|
+
## [0.11.1] - 2026-10-26
|
|
161
|
+
|
|
162
|
+
### Added
|
|
163
|
+
|
|
164
|
+
- `deviceTree(transport, { core, assistant, office, logger })` boots Core and
|
|
165
|
+
the assistant under one supervisor, the way the app does. (#544)
|
|
166
|
+
- The `reindex-chat-chunks` op copies a chat written before this release into
|
|
167
|
+
`@qvac/chat-chunks`. A build older than this one halts on it, so a device
|
|
168
|
+
sends it only once the published version floor shuts out every app release
|
|
169
|
+
before 0.21.0, the first whose core applies it. A build under the floor opens
|
|
170
|
+
no mesh, so none can halt on it; publish `>=0.21.0` once that release is in
|
|
171
|
+
both stores. (#491)
|
|
172
|
+
- A device's row in the account carries `customModels`: the label, task type
|
|
173
|
+
and size of each custom model it has. A paired desktop showed a custom model
|
|
174
|
+
added on the phone by its `custom:…` id, as Other and of unknown size, and
|
|
175
|
+
counted it outside the phone's LLMs. `saveDeviceCapabilities` takes the field,
|
|
176
|
+
and the assistant reports it again when a custom model is renamed. (#556)
|
|
177
|
+
|
|
178
|
+
### Changed
|
|
179
|
+
|
|
180
|
+
- `chunksDeltaWatch` reads only the rows that changed after its opening reset,
|
|
181
|
+
so an update no longer costs the whole chat. Frames are unchanged; a
|
|
182
|
+
selection with `limit` is still read whole. (#538)
|
|
183
|
+
- Injection-mode `ragSearch` sizes its excerpts to a quarter of the agent's
|
|
184
|
+
context window, capped at the 3072-token default, so a small window gets
|
|
185
|
+
fewer excerpts instead of overflowing. (#588)
|
|
186
|
+
- `hypercore` 11.39 and `hypercore-storage` 3.4, for a working purge. (#539)
|
|
187
|
+
- `hypercore-blob-server` 1.15.1 keeps its socket listening across a suspend,
|
|
188
|
+
so resume keeps the port and every minted link, and replaces the local patch.
|
|
189
|
+
(#561)
|
|
190
|
+
|
|
191
|
+
### Fixed
|
|
192
|
+
|
|
193
|
+
- A member whose only device in a shared mesh comes back far behind
|
|
194
|
+
fast-forwards instead of replaying everything it missed (183 s to 3.9 s on a
|
|
195
|
+
mesh about 6,900 flushes ahead): a shared mesh trusts every member's live
|
|
196
|
+
devices, not only this member's own, and never a device admitted unlinked. A
|
|
197
|
+
compute mesh still trusts only its own member's devices. (#492)
|
|
198
|
+
- Opening a chat on a device that does not hold the mesh no longer downloads most
|
|
199
|
+
of the mesh. Each chunk is also kept in `@qvac/chat-chunks`, keyed by chat and
|
|
200
|
+
`seq`, and a chat read is one range of it: a 1,100-chunk chat fetched about
|
|
201
|
+
1,000 blocks instead of 100,000. Once the published floor is at app 0.21.0 or
|
|
202
|
+
later, the chats written before this release are copied in the background, one
|
|
203
|
+
op per chat; until then, or while an older build still writes to a chat, it
|
|
204
|
+
reads the way it did before. A chat an older build purged also loses the rows
|
|
205
|
+
that build left in `@qvac/chat-chunks`. (#490, #491)
|
|
206
|
+
- `configGet` and `configWatch` return a stored `false`, `0` or `''` as written
|
|
207
|
+
instead of `null`. A device on 0.11.0 or earlier, a value one of those
|
|
208
|
+
releases wrote, and a downgrade to one still read them as `null`. (#546)
|
|
209
|
+
- A message's audio attachment is presented to the model as a transcript of its
|
|
210
|
+
speech only, so a tool that reads the audio itself, such as music
|
|
211
|
+
transcription, is used again. (#337)
|
|
212
|
+
- The assistant reports an agent it hosts in a shared mesh as soon as this
|
|
213
|
+
device has joined it. A device still joining had its report refused and never
|
|
214
|
+
reported again. (#324)
|
|
215
|
+
- `removeDevice` on the account revokes the device in a shared mesh whose row
|
|
216
|
+
for it arrives after the removal. Before, it stayed a writer there. (#547)
|
|
217
|
+
- `inferenceCalls` and the skill routes (`pushSkillSecret`,
|
|
218
|
+
`listManagedSkills`, `readSkillFile`, `writeSkillFile`, `copySkillForEdit`,
|
|
219
|
+
`deleteOverlaySkill`) from a device that has just paired no longer fail with
|
|
220
|
+
`PEER_SENDER_REVOKED`: the host waits up to 30 s for the new device's row.
|
|
221
|
+
(#544)
|
|
222
|
+
- Core no longer dies of an unhandled `REQUEST_CANCELLED` when a fast-forward
|
|
223
|
+
cancels the read that follows a joined mesh's shared meshes. (#474)
|
|
224
|
+
- A device restarted while its `joinMesh` is still `joining` boots the mesh
|
|
225
|
+
from the head its invite carried, instead of replaying it from its first
|
|
226
|
+
block, which on a big mesh took minutes. (#515)
|
|
227
|
+
- `meshInvite` on a device that just recovered with `recoverAccount` waits for
|
|
228
|
+
its member link instead of failing with "This device cannot reach its account
|
|
229
|
+
to check". (#540)
|
|
230
|
+
- A question sent while the previous run was still answering is shown to the
|
|
231
|
+
model after that answer, not before it, once compaction folds the earlier
|
|
232
|
+
turns. The run's reply and its file turns were sorted behind the new question,
|
|
233
|
+
and the model answered as if they came later (QVAC-24502). A file a run
|
|
234
|
+
produced is now replayed right behind that run's answer instead of at the end
|
|
235
|
+
of the chat; an existing chat with such a turn re-reads once after the update.
|
|
236
|
+
(#584)
|
|
82
237
|
|
|
83
238
|
## [0.11.0] - 2026-10-23
|
|
84
239
|
|
|
@@ -1992,7 +2147,8 @@ Published under the `release-0.1` dist-tag.
|
|
|
1992
2147
|
await assistant.ready()
|
|
1993
2148
|
```
|
|
1994
2149
|
|
|
1995
|
-
[Unreleased]: https://github.com/tetherto/qvac-core/compare/v0.11.
|
|
2150
|
+
[Unreleased]: https://github.com/tetherto/qvac-core/compare/v0.11.1...HEAD
|
|
2151
|
+
[0.11.1]: https://github.com/tetherto/qvac-core/compare/v0.11.0...v0.11.1
|
|
1996
2152
|
[0.11.0]: https://github.com/tetherto/qvac-core/compare/v0.10.4...v0.11.0
|
|
1997
2153
|
[0.10.4]: https://github.com/tetherto/qvac-core/compare/v0.10.3...v0.10.4
|
|
1998
2154
|
[0.10.3]: https://github.com/tetherto/qvac-core/compare/v0.10.2...v0.10.3
|
package/dist-lib/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { Client } from './lib/client.ts';
|
|
|
5
5
|
export { AssistantClient } from './lib/assistant-client.ts';
|
|
6
6
|
export { harnessDeleteModel, harnessListModels, harnessSkillCatalog, harnessTools, QvacAssistant, type Harness, type ListModelsOptions, type ModelInfo, type ModelType, type Skill, type ToolCatalogEntry } from './lib/assistant.ts';
|
|
7
7
|
export { assistantChild, assistantTree, type AssistantChildOptions, type AssistantTreeOptions, type EmbedderFactory, type HarnessContext, type HarnessFactory } from './lib/assistant-tree.ts';
|
|
8
|
+
export { deviceTree, type DeviceTree, type DeviceTreeOptions } from './lib/device-tree.ts';
|
|
8
9
|
export { ASSISTANT_WAKEUP_LINGER_MS, createAssistantSuspendLifecycle, type AssistantSuspendLifecycleOptions } from './lib/suspend-lifecycle.ts';
|
|
9
10
|
export { default as Supervisor } from 'bare-supervisor';
|
|
10
11
|
export type { AssistantDiagnostics, DiagnosticsSlice, HarnessDiagnostics, RunSummary } from './lib/diagnostics.ts';
|
package/dist-lib/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export { Client } from './lib/client.js';
|
|
|
3
3
|
export { AssistantClient } from './lib/assistant-client.js';
|
|
4
4
|
export { harnessDeleteModel, harnessListModels, harnessSkillCatalog, harnessTools, QvacAssistant } from './lib/assistant.js';
|
|
5
5
|
export { assistantChild, assistantTree } from './lib/assistant-tree.js';
|
|
6
|
+
export { deviceTree } from './lib/device-tree.js';
|
|
6
7
|
export { ASSISTANT_WAKEUP_LINGER_MS, createAssistantSuspendLifecycle } from './lib/suspend-lifecycle.js';
|
|
7
8
|
export { default as Supervisor } from 'bare-supervisor';
|
|
8
9
|
export { clientSessions, duplexPair } from '@qvac/harness/transport';
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { type Readable } from 'streamx';
|
|
2
|
-
import type {
|
|
2
|
+
import type { LoggerInterface } from '@qvac/logging';
|
|
3
|
+
import type { AssistantChunk, AssistantChunkDelta } from '../../spec/hyperschema/types.d.ts';
|
|
3
4
|
import type { WatchStream } from '../../spec/capabilities.d.ts';
|
|
5
|
+
import { type ListChunksInput } from '../core/chunk.ts';
|
|
6
|
+
import type { Mesh } from '../core/mesh.ts';
|
|
7
|
+
import { type Senders } from '../core/senders.ts';
|
|
4
8
|
type Rows = ReadonlyMap<string, AssistantChunk>;
|
|
5
9
|
export declare function chunkDelta(prev: Rows | null, next: ReadonlyArray<AssistantChunk>): AssistantChunkDelta;
|
|
6
|
-
export declare function
|
|
10
|
+
export declare function chunkDeltas(selection: ListChunksInput, log: LoggerInterface | null, lookup?: () => Promise<Senders | null>): (mesh: Mesh) => Promise<AssistantChunkDelta>;
|
|
11
|
+
export declare function chunkDeltaStream(frames: Readable & AsyncIterable<AssistantChunkDelta>): Readable & WatchStream<AssistantChunkDelta>;
|
|
7
12
|
export {};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import b4a from 'b4a';
|
|
1
2
|
import { pipeline, Transform } from 'streamx';
|
|
3
|
+
import { linkChunks, listChunks, recordLinks, selectsChunk } from '../core/chunk.js';
|
|
4
|
+
import { CHUNKS } from '../core/collections.js';
|
|
5
|
+
import { withSenders } from '../core/senders.js';
|
|
2
6
|
import { frameReadable } from '../frame-readable.js';
|
|
3
7
|
import { snapshotEquals } from './watchable.js';
|
|
4
8
|
export function chunkDelta(prev, next) {
|
|
@@ -14,13 +18,91 @@ export function chunkDelta(prev, next) {
|
|
|
14
18
|
}
|
|
15
19
|
return { reset: false, chunks: upserts, removed, count };
|
|
16
20
|
}
|
|
17
|
-
export function
|
|
18
|
-
let
|
|
21
|
+
export function chunkDeltas(selection, log, lookup = async () => null) {
|
|
22
|
+
let rows = null;
|
|
23
|
+
let head = null;
|
|
24
|
+
let named = null;
|
|
25
|
+
return async (mesh) => {
|
|
26
|
+
const current = mesh.view.db.head();
|
|
27
|
+
const from = head && current && b4a.equals(head.key, current.key) ? head : null;
|
|
28
|
+
head = current;
|
|
29
|
+
const senders = await lookup();
|
|
30
|
+
const renamed = (await sendersKey(senders, rows)) !== named;
|
|
31
|
+
const changed = rows && from && !renamed && selection.limit === undefined
|
|
32
|
+
? await changedRows(mesh, { from, selection, rows, log })
|
|
33
|
+
: null;
|
|
34
|
+
if (rows === null || changed === null) {
|
|
35
|
+
const next = await withSenders(await listChunks(mesh, selection), senders);
|
|
36
|
+
const delta = chunkDelta(rows, next);
|
|
37
|
+
const sent = new Set(delta.chunks?.map((chunk) => chunk.id));
|
|
38
|
+
rows = new Map(next.map((chunk) => [chunk.id, chunk]));
|
|
39
|
+
named = await sendersKey(senders, rows);
|
|
40
|
+
await recordLinks(mesh, next.filter((chunk) => sent.has(chunk.id)));
|
|
41
|
+
return delta;
|
|
42
|
+
}
|
|
43
|
+
const upserts = await withSenders(changed.upserts, senders);
|
|
44
|
+
const delta = applyChanged(rows, { ...changed, upserts }, selection.reverse === true);
|
|
45
|
+
named = await sendersKey(senders, rows);
|
|
46
|
+
await recordLinks(mesh, delta.chunks);
|
|
47
|
+
return delta;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
async function sendersKey(senders, rows) {
|
|
51
|
+
if (!senders || !rows) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const ids = new Set();
|
|
55
|
+
for (const chunk of rows.values()) {
|
|
56
|
+
const id = chunk.type === 'user-message' ? (chunk.senderMemberId ?? chunk.requesterMemberId) : null;
|
|
57
|
+
if (id) {
|
|
58
|
+
ids.add(b4a.toHex(id));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return JSON.stringify(await Promise.all([...ids].sort().map((hex) => senders(b4a.from(hex, 'hex')))));
|
|
62
|
+
}
|
|
63
|
+
function applyChanged(rows, { upserts, removed }, reverse) {
|
|
64
|
+
for (const id of removed) {
|
|
65
|
+
rows.delete(id);
|
|
66
|
+
}
|
|
67
|
+
for (const chunk of upserts) {
|
|
68
|
+
rows.set(chunk.id, chunk);
|
|
69
|
+
}
|
|
70
|
+
const count = rows.size;
|
|
71
|
+
const reset = upserts.length + removed.length > count / 2;
|
|
72
|
+
const chunks = (reset ? [...rows.values()] : upserts).sort((a, b) => reverse ? b.seq - a.seq : a.seq - b.seq);
|
|
73
|
+
return { reset, chunks, removed: reset ? [] : removed, count };
|
|
74
|
+
}
|
|
75
|
+
async function changedRows(mesh, { from, selection, rows, log }) {
|
|
76
|
+
const snap = mesh.view.snapshot();
|
|
77
|
+
const upserts = [];
|
|
78
|
+
const removed = [];
|
|
79
|
+
try {
|
|
80
|
+
for await (const change of snap.changes({ from })) {
|
|
81
|
+
if (change.collection !== CHUNKS)
|
|
82
|
+
continue;
|
|
83
|
+
if (change.type === 'insert' && selectsChunk(selection, change.value)) {
|
|
84
|
+
upserts.push(change.value);
|
|
85
|
+
}
|
|
86
|
+
else if (rows.has(change.value.id)) {
|
|
87
|
+
removed.push(change.value.id);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
log?.warn(['api', 'watch'], 'chunk diff from the held head failed, reading in full', err);
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
await snap.close();
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
upserts: linkChunks(mesh, upserts).filter((chunk) => !snapshotEquals(chunk, rows.get(chunk.id))),
|
|
100
|
+
removed
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export function chunkDeltaStream(frames) {
|
|
19
104
|
const deltas = new Transform({
|
|
20
|
-
transform(
|
|
21
|
-
const next = list.chunks ?? [];
|
|
22
|
-
const delta = chunkDelta(prev, next);
|
|
23
|
-
prev = new Map(next.map((chunk) => [chunk.id, chunk]));
|
|
105
|
+
transform(delta, cb) {
|
|
24
106
|
if (!delta.reset && delta.chunks?.length === 0 && delta.removed?.length === 0) {
|
|
25
107
|
cb(null);
|
|
26
108
|
return;
|
|
@@ -28,6 +110,6 @@ export function chunkDeltaStream(lists) {
|
|
|
28
110
|
cb(null, delta);
|
|
29
111
|
}
|
|
30
112
|
});
|
|
31
|
-
return frameReadable(pipeline(
|
|
113
|
+
return frameReadable(pipeline(frames, deltas, noop));
|
|
32
114
|
}
|
|
33
115
|
function noop() { }
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { answersRound, appendChunk, listAttachmentsByKind, listChunks, listRunRequests, othersApproval, recordLinks, requireChatIn, requireOwnRun, requireProjectMember, resolveApproval, updateChunk } from '../core/chunk.js';
|
|
1
|
+
import { answersRound, appendChunk, listAttachmentsByKind, listChunks, listRunRequests, othersApproval, readChunk, recordLinks, requireChatIn, requireOwnRun, requireProjectMember, resolveApproval, updateChunk } from '../core/chunk.js';
|
|
2
2
|
import { cancelModelRequest, listModelRequests, reopenModelRequest, settleModelRequest, takeModelRequest } from '../core/model-requests.js';
|
|
3
3
|
import { takeRunRequest } from '../core/run-requests.js';
|
|
4
4
|
import { accountPicks } from '../core/shared-agents.js';
|
|
5
|
-
import { chunkDeltaStream } from './chunk-delta.js';
|
|
5
|
+
import { chunkDeltaStream, chunkDeltas } from './chunk-delta.js';
|
|
6
6
|
import { ourSenderName, withSenders } from '../core/senders.js';
|
|
7
7
|
import { meshWatchable, requireMesh } from './current-mesh.js';
|
|
8
8
|
import { bounds } from './range.js';
|
|
@@ -14,7 +14,7 @@ export function createChunksApi(pool, deviceId, { log, account = null, agents =
|
|
|
14
14
|
listChunks(mesh, chunkSelection(input)),
|
|
15
15
|
senders?.lookup(meshId) ?? null
|
|
16
16
|
]);
|
|
17
|
-
return { chunks: withSenders(await recordLinks(mesh, chunks), named) };
|
|
17
|
+
return { chunks: await withSenders(await recordLinks(mesh, chunks), named) };
|
|
18
18
|
};
|
|
19
19
|
const chunksWatch = meshWatchable(pool, transcript, { name: 'chunksWatch', log, changes: senders?.changes });
|
|
20
20
|
return {
|
|
@@ -61,9 +61,15 @@ export function createChunksApi(pool, deviceId, { log, account = null, agents =
|
|
|
61
61
|
return { chunks: await recordLinks(mesh, chunks) };
|
|
62
62
|
},
|
|
63
63
|
chunksWatch,
|
|
64
|
-
chunksDeltaWatch: (request) =>
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
chunksDeltaWatch: (request) => {
|
|
65
|
+
const deltas = chunkDeltas(chunkSelection(request), log, async () => senders ? senders.lookup(request.meshId) : null);
|
|
66
|
+
const watch = meshWatchable(pool, (_request, mesh) => deltas(mesh), { name: 'chunksDeltaWatch', log, changes: senders?.changes });
|
|
67
|
+
return chunkDeltaStream(watch(request));
|
|
68
|
+
},
|
|
69
|
+
runRequestsWatch: meshWatchable(pool, async (_request, mesh) => ({
|
|
70
|
+
chunks: (await listRunRequests(mesh, deviceId)).map(readChunk)
|
|
71
|
+
}), { name: 'runRequestsWatch', log }),
|
|
72
|
+
takeModelRequest: async ({ meshId, chunkId }) => readChunk(await takeModelRequest(await requireMesh(pool, meshId, { chunkId }), chunkId)),
|
|
67
73
|
settleModelRequest: async ({ meshId, chunkId, state, result, reason }) => {
|
|
68
74
|
if (state !== 'done' && state !== 'failed') {
|
|
69
75
|
throw new CoreError('CHUNK_PAYLOAD_INVALID', ['a model-request settles done or failed']);
|
|
@@ -84,8 +90,8 @@ export function createChunksApi(pool, deviceId, { log, account = null, agents =
|
|
|
84
90
|
await reopenModelRequest(await requireMesh(pool, meshId, { chunkId }), chunkId);
|
|
85
91
|
return { ok: true };
|
|
86
92
|
},
|
|
87
|
-
modelRequestsWatch: meshWatchable(pool, async (_request, mesh) => ({ chunks: await listModelRequests(mesh) }), { name: 'modelRequestsWatch', log }),
|
|
88
|
-
takeRunRequest: async ({ meshId, chunkId }) => takeRunRequest(await requireMesh(pool, meshId), chunkId)
|
|
93
|
+
modelRequestsWatch: meshWatchable(pool, async (_request, mesh) => ({ chunks: (await listModelRequests(mesh)).map(readChunk) }), { name: 'modelRequestsWatch', log }),
|
|
94
|
+
takeRunRequest: async ({ meshId, chunkId }) => readChunk(await takeRunRequest(await requireMesh(pool, meshId), chunkId))
|
|
89
95
|
};
|
|
90
96
|
}
|
|
91
97
|
function chunkSelection({ chatId, type, types, ...rest }) {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { LoggerInterface } from '@qvac/logging';
|
|
2
|
+
import type { AssistantConfigValue } from '../../spec/hyperschema/types.d.ts';
|
|
2
3
|
import type { openLocalStore } from '../core/local/index.ts';
|
|
3
|
-
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
4
|
+
import type { CapabilityHandlers, WatchStream } from '../../spec/capabilities.d.ts';
|
|
4
5
|
type LocalStore = Awaited<ReturnType<typeof openLocalStore>>;
|
|
6
|
+
export declare function readConfigAnswer(answer: AssistantConfigValue): AssistantConfigValue;
|
|
7
|
+
export declare function readConfigFrames(source: WatchStream<AssistantConfigValue>): WatchStream<AssistantConfigValue>;
|
|
5
8
|
export declare function createConfigApi(state: LocalStore, log: LoggerInterface | null, onset?: ((key: string) => void) | null): Pick<CapabilityHandlers, 'configGet' | 'configSet' | 'configWatch'>;
|
|
6
9
|
export {};
|
|
@@ -1,16 +1,57 @@
|
|
|
1
|
+
import { Readable } from 'streamx';
|
|
1
2
|
import { watchable } from './watchable.js';
|
|
3
|
+
import { frameReadable } from '../frame-readable.js';
|
|
4
|
+
import { latestFrame } from '../latest-frame.js';
|
|
5
|
+
import { configValue, readConfigValue } from '../core/config-value.js';
|
|
6
|
+
export function readConfigAnswer(answer) {
|
|
7
|
+
return { value: readConfigValue(answer) };
|
|
8
|
+
}
|
|
9
|
+
export function readConfigFrames(source) {
|
|
10
|
+
let stopped = false;
|
|
11
|
+
let output;
|
|
12
|
+
const frames = latestFrame((frame) => output.push(frame));
|
|
13
|
+
const onData = (frame) => frames.offer(readConfigAnswer(frame));
|
|
14
|
+
const onError = (err) => output.destroy(err);
|
|
15
|
+
const onEnd = () => frames.end();
|
|
16
|
+
const stop = () => {
|
|
17
|
+
if (stopped)
|
|
18
|
+
return;
|
|
19
|
+
stopped = true;
|
|
20
|
+
source.off('data', onData);
|
|
21
|
+
source.off('error', onError);
|
|
22
|
+
source.off('end', onEnd);
|
|
23
|
+
source.off('close', onEnd);
|
|
24
|
+
source.destroy();
|
|
25
|
+
frames.release();
|
|
26
|
+
};
|
|
27
|
+
output = new Readable({
|
|
28
|
+
read(callback) {
|
|
29
|
+
frames.read(callback);
|
|
30
|
+
},
|
|
31
|
+
predestroy: stop,
|
|
32
|
+
destroy(cb) {
|
|
33
|
+
stop();
|
|
34
|
+
cb(null);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
output.on('error', noop);
|
|
38
|
+
source.on('data', onData);
|
|
39
|
+
source.on('error', onError);
|
|
40
|
+
source.on('end', onEnd);
|
|
41
|
+
source.on('close', onEnd);
|
|
42
|
+
return frameReadable(output);
|
|
43
|
+
}
|
|
2
44
|
export function createConfigApi(state, log, onset = null) {
|
|
3
45
|
return {
|
|
4
46
|
async configGet({ key }) {
|
|
5
|
-
return
|
|
47
|
+
return configValue(await state.get(key));
|
|
6
48
|
},
|
|
7
49
|
async configSet({ key, value }) {
|
|
8
50
|
await state.set(key, value);
|
|
9
51
|
onset?.(key);
|
|
10
52
|
return { ok: true };
|
|
11
53
|
},
|
|
12
|
-
configWatch: watchable(() => state, async ({ key }) => ({
|
|
13
|
-
value: await state.get(key)
|
|
14
|
-
}), { name: 'configWatch', log })
|
|
54
|
+
configWatch: watchable(() => state, async ({ key }) => configValue(await state.get(key)), { name: 'configWatch', log })
|
|
15
55
|
};
|
|
16
56
|
}
|
|
57
|
+
function noop() { }
|
|
@@ -50,10 +50,6 @@ export function createCustomModelApi(state, { preview, deleteFiles, log }) {
|
|
|
50
50
|
}
|
|
51
51
|
const id = customModelId(checked.src);
|
|
52
52
|
const label = input.label.trim();
|
|
53
|
-
const taken = (await state.getCustomModelRows()).find((row) => (row.label || row.name) === label && row.name !== id);
|
|
54
|
-
if (taken) {
|
|
55
|
-
throw new CoreError('CUSTOM_MODEL_LABEL_TAKEN', [label]);
|
|
56
|
-
}
|
|
57
53
|
const row = {
|
|
58
54
|
name: id,
|
|
59
55
|
label,
|
|
@@ -70,7 +66,9 @@ export function createCustomModelApi(state, { preview, deleteFiles, log }) {
|
|
|
70
66
|
taskType: checked.taskType ?? null,
|
|
71
67
|
license: checked.license ?? null
|
|
72
68
|
};
|
|
73
|
-
await state.
|
|
69
|
+
if (!(await state.putCustomModelRowIfLabelAvailable(row))) {
|
|
70
|
+
throw new CoreError('CUSTOM_MODEL_LABEL_TAKEN', [label]);
|
|
71
|
+
}
|
|
74
72
|
return { id };
|
|
75
73
|
},
|
|
76
74
|
removeCustomModel: async ({ name }) => {
|
|
@@ -16,6 +16,7 @@ function toEngineDevice(device, overrides = {}) {
|
|
|
16
16
|
installedSkillNames: device.installedSkillNames ?? [],
|
|
17
17
|
readySkillNames: device.readySkillNames,
|
|
18
18
|
toolCatalog: device.toolCatalog,
|
|
19
|
+
customModels: device.customModels,
|
|
19
20
|
installedModelNames: device.installedModelNames ?? [],
|
|
20
21
|
cachedModelNames: device.cachedModelNames ?? [],
|
|
21
22
|
capabilityProfile: device.capabilityProfile,
|
|
@@ -68,7 +69,8 @@ export function createDevicesApi(pool, { deviceId, log, removeWriter, renameLoca
|
|
|
68
69
|
installedModelNames: input.installedModelNames ?? [],
|
|
69
70
|
cachedModelNames: input.cachedModelNames ?? [],
|
|
70
71
|
readySkillNames: input.readySkillNames ?? null,
|
|
71
|
-
toolCatalog: input.toolCatalog ?? null
|
|
72
|
+
toolCatalog: input.toolCatalog ?? null,
|
|
73
|
+
customModels: input.customModels ?? null
|
|
72
74
|
}, isAccount);
|
|
73
75
|
return { ok: true };
|
|
74
76
|
},
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
|
|
2
2
|
import { type MeshPool } from './current-mesh.ts';
|
|
3
|
-
export declare function createFilesApi(pool: MeshPool): Pick<CapabilityHandlers, 'fileRead' | 'filePreview' | 'fileRetry'>;
|
|
3
|
+
export declare function createFilesApi(pool: MeshPool): Pick<CapabilityHandlers, 'fileRead' | 'filePreview' | 'fileRetry' | 'filesReady'>;
|
|
@@ -4,6 +4,9 @@ import { requireMesh } from './current-mesh.js';
|
|
|
4
4
|
import { frameReadable } from '../frame-readable.js';
|
|
5
5
|
export function createFilesApi(pool) {
|
|
6
6
|
return {
|
|
7
|
+
async filesReady({ meshId, chatId, fileIds }) {
|
|
8
|
+
return (await requireMesh(pool, meshId)).files.ready(chatId, fileIds);
|
|
9
|
+
},
|
|
7
10
|
async filePreview(request) {
|
|
8
11
|
return (await requireMesh(pool, request.meshId)).files.preview(request);
|
|
9
12
|
},
|
|
@@ -14,7 +17,10 @@ export function createFilesApi(pool) {
|
|
|
14
17
|
fileRead(request) {
|
|
15
18
|
const abort = new AbortController();
|
|
16
19
|
async function* read() {
|
|
17
|
-
const mesh = await requireMesh(pool, request.meshId);
|
|
20
|
+
const mesh = await abortable(requireMesh(pool, request.meshId), abort.signal);
|
|
21
|
+
if (!mesh || abort.signal.aborted) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
18
24
|
const close = () => stream.destroy();
|
|
19
25
|
mesh.files.once('close', close);
|
|
20
26
|
try {
|
|
@@ -25,25 +31,76 @@ export function createFilesApi(pool) {
|
|
|
25
31
|
}
|
|
26
32
|
}
|
|
27
33
|
const iterator = read();
|
|
34
|
+
let reading = false;
|
|
35
|
+
let pendingRead = null;
|
|
36
|
+
let stopped = false;
|
|
37
|
+
const stop = () => {
|
|
38
|
+
if (stopped)
|
|
39
|
+
return;
|
|
40
|
+
stopped = true;
|
|
41
|
+
abort.abort('file read closed');
|
|
42
|
+
const next = pendingRead;
|
|
43
|
+
pendingRead = null;
|
|
44
|
+
reading = false;
|
|
45
|
+
next?.(null);
|
|
46
|
+
void iterator.return(undefined).catch(noop);
|
|
47
|
+
};
|
|
28
48
|
const stream = new Readable({
|
|
29
49
|
read(callback) {
|
|
50
|
+
if (reading)
|
|
51
|
+
return;
|
|
52
|
+
reading = true;
|
|
53
|
+
pendingRead = callback;
|
|
54
|
+
const settle = (error) => {
|
|
55
|
+
reading = false;
|
|
56
|
+
const next = pendingRead;
|
|
57
|
+
pendingRead = null;
|
|
58
|
+
next?.(error);
|
|
59
|
+
};
|
|
30
60
|
iterator
|
|
31
61
|
.next()
|
|
32
62
|
.then((frame) => {
|
|
63
|
+
if (stream.destroying) {
|
|
64
|
+
return settle(null);
|
|
65
|
+
}
|
|
33
66
|
stream.push(frame.done ? null : frame.value);
|
|
34
|
-
|
|
67
|
+
settle(null);
|
|
35
68
|
})
|
|
36
|
-
.catch(
|
|
69
|
+
.catch((err) => {
|
|
70
|
+
settle(stream.destroying ? null : err);
|
|
71
|
+
});
|
|
37
72
|
},
|
|
38
|
-
predestroy:
|
|
73
|
+
predestroy: stop,
|
|
39
74
|
destroy(callback) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
.then(() => callback(null))
|
|
43
|
-
.catch(callback);
|
|
75
|
+
stop();
|
|
76
|
+
callback(null);
|
|
44
77
|
}
|
|
45
78
|
});
|
|
46
79
|
return frameReadable(stream);
|
|
47
80
|
}
|
|
48
81
|
};
|
|
49
82
|
}
|
|
83
|
+
function abortable(promise, signal) {
|
|
84
|
+
if (signal.aborted) {
|
|
85
|
+
return Promise.resolve(null);
|
|
86
|
+
}
|
|
87
|
+
return new Promise((resolve, reject) => {
|
|
88
|
+
let settled = false;
|
|
89
|
+
const finish = (value, err) => {
|
|
90
|
+
if (settled)
|
|
91
|
+
return;
|
|
92
|
+
settled = true;
|
|
93
|
+
signal.removeEventListener('abort', onAbort);
|
|
94
|
+
if (err) {
|
|
95
|
+
reject(err);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
resolve(value);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const onAbort = () => finish(null);
|
|
102
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
103
|
+
promise.then((value) => finish(value), (err) => finish(null, err));
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function noop() { }
|