@qvac/core 1.0.0-rc.11 → 1.0.0-rc.12

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 CHANGED
@@ -13,6 +13,51 @@ release.
13
13
 
14
14
  ## [Unreleased]
15
15
 
16
+ ## [1.0.0-rc.12] - 2026-11-13
17
+
18
+ Since 1.0.0-rc.11.
19
+
20
+ ### Added
21
+
22
+ - `listKnowledgeBase` and `knowledgeBaseWatch`: an entry carries `progress`, the chunks embedded
23
+ so far and the total, while this device holds the file's indexing claim and is embedding it. It
24
+ is device-local, so other members see only `status`. See
25
+ [knowledge](docs/api/knowledge.md#listknowledgebase). (#808)
26
+ - `duck` runs up to four agent replies on one loaded model at once. The sidecar's own default is
27
+ unchanged. (#861)
28
+
29
+ ### Changed
30
+
31
+ - Needs `@qvac/harness` 1.0.0-rc.22 and `@qvac/skills` ^0.4.0, up from 1.0.0-rc.20 and ^0.3.0.
32
+ The skills' diagrams skill calls the harness's `draw_diagram`. (#817)
33
+ - A write that a mesh's close drops now refuses with `MESH_CLOSED_BEFORE_WRITE` (100133) and leaves
34
+ nothing in the log, where it used to resolve as if it had landed. Send it again once the mesh is
35
+ open. See [mesh](docs/api/mesh.md). (#838)
36
+ - hypercore 11.40.4, hyperbee2 2.22.0, compact-encoding 3.7.0 and protomux 3.13.1.
37
+ compact-encoding's `float32` and `float64` now throw a `TypeError` on a non-number instead of
38
+ writing NaN. (#857)
39
+
40
+ ### Fixed
41
+
42
+ - A project's knowledge files that another device indexed no longer stay "Not available here"
43
+ behind a file this device is rebuilding locally while one of its runs lasts. (#860)
44
+ - A run a tool answered, such as a diagram from `draw_diagram`, is replayed on later turns with
45
+ that call before its reply, so a follow-up edits the diagram rather than rewriting it by hand.
46
+ (#817)
47
+ - A PDF page of fewer than 12 words, such as a chapter divider or a contents page, is no longer a
48
+ chunk of its own that matched almost any short prompt: its text opens the next page and cites
49
+ it. A PDF indexed before this keeps its chunks. (#841)
50
+ - A 0.21 device that fast-forwarded onto its sibling's 1.0 account and halted boots on 1.0 with no
51
+ peer again, where `ready()` used to hang. (#838)
52
+ - A logout, a leave or a shutdown no longer waits on a mesh's drain, which hung a logout beside a
53
+ mesh still joining. (#838)
54
+ - A `joinMesh` refused with `MESH_VIEW_UNAVAILABLE` leaves nothing behind, so the same invite joins
55
+ once the row reads; the next `joinMesh` of it used to never return. (#838)
56
+
57
+ ## [1.0.0-rc.11] - 2026-11-12
58
+
59
+ Everything since 0.11.4, across the 1.0.0 prereleases up to this one.
60
+
16
61
  ### Added
17
62
 
18
63
  - `continueRunHere({ meshId, chunkId })`: the device a run was sent from takes back a run another
@@ -2341,7 +2386,9 @@ Published under the `release-0.1` dist-tag.
2341
2386
  await assistant.ready()
2342
2387
  ```
2343
2388
 
2344
- [Unreleased]: https://github.com/tetherto/qvac-core/compare/v0.11.4...HEAD
2389
+ [Unreleased]: https://github.com/tetherto/qvac-core/compare/v1.0.0-rc.12...HEAD
2390
+ [1.0.0-rc.12]: https://github.com/tetherto/qvac-core/compare/v1.0.0-rc.11...v1.0.0-rc.12
2391
+ [1.0.0-rc.11]: https://github.com/tetherto/qvac-core/compare/v0.11.4...v1.0.0-rc.11
2345
2392
  [0.11.4]: https://github.com/tetherto/qvac-core/compare/v0.11.3...v0.11.4
2346
2393
  [0.11.3]: https://github.com/tetherto/qvac-core/compare/v0.11.2...v0.11.3
2347
2394
  [0.11.2]: https://github.com/tetherto/qvac-core/compare/v0.11.1...v0.11.2
@@ -1,5 +1,5 @@
1
1
  import type { AbortSignal } from 'bare-abort-controller';
2
- import type { ApprovalCall, CompletionEvent, DeleteModelSummary, DriveOpFn, GrantedDrive, HostRunLog, KnowledgeArtifact, KnowledgeHit, KnowledgeQuery, KnowledgeRemoved, KnowledgeStatus, KnowledgeUpsertResult, ManagedSkill, MemoryBudget, ModelRoundIo, ModelRoundPort, ModelRoundRequest, ModelRoundResult, ModelSourcePreview, OcrReadContext, PreviewModelSourceContext, SkillFileContent } from '@qvac/harness';
2
+ import type { ApprovalCall, CompletionEvent, DeleteModelSummary, DriveOpFn, GrantedDrive, HostRunLog, KnowledgeArtifact, KnowledgeHit, KnowledgeQuery, KnowledgeRemoved, KnowledgeStatus, KnowledgeUpsertResult, ManagedSkill, MemoryBudget, ModelRoundIo, ModelRoundPort, ModelRoundRequest, ModelRoundResult, ModelSourcePreview, OcrPage, OcrReadContext, PreviewModelSourceContext, SkillFileContent } from '@qvac/harness';
3
3
  import type { MediaRoundIo, MediaRoundPort, MediaRoundRequest, MediaRoundResult } from '@qvac/harness/lib/contract/index.ts';
4
4
  import type { SkillCatalogOptions, SkillManagementHooks } from '../core.ts';
5
5
  import type { AssistantAgent, AssistantCapabilityProfile, AssistantChunkContentAttachment, AssistantCustomModelPreview, AssistantCustomModelReportEntry, AssistantDeleteModelRequest, AssistantDetectLanguageRequest, AssistantDetectLanguageResponse, AssistantDeleteModelResponse, AssistantEnhanceMode, AssistantKvCacheDeletionResponse, AssistantListModelsRequest, AssistantModelInfoList, AssistantPreviewCustomModelRequest, AssistantSkillCatalogResponse, AssistantSpeakRequest, AssistantSpeakResponse, AssistantToolCatalogResponse, AssistantToolReportEntry, AssistantTranscribeRequest, AssistantTranscribeResponse } from '../../spec/hyperschema/types.d.ts';
@@ -191,7 +191,7 @@ export interface Harness {
191
191
  knowledgeRemove?(artifactId: string): Promise<KnowledgeRemoved>;
192
192
  knowledgeSearch?(query: KnowledgeQuery): Promise<KnowledgeHit[]>;
193
193
  knowledgeStatus?(): Promise<KnowledgeStatus>;
194
- ocrRead?(context: OcrReadContext): Promise<string>;
194
+ ocrRead?(context: OcrReadContext): Promise<OcrPage>;
195
195
  detectLanguage?(context: {
196
196
  text: string;
197
197
  topK?: number;
@@ -1,4 +1,4 @@
1
- import { attachmentTurn, skillLoadedTurn } from '@qvac/harness/lib/capabilities/tool-turns.ts';
1
+ import { answeredToolTurns, attachmentTurn, isAnswer, skillLoadedTurn } from '@qvac/harness/lib/capabilities/tool-turns.ts';
2
2
  import { HISTORY_CHUNK_TYPES } from '../core/chunk.js';
3
3
  import { isAudioAttachment } from '../core/audio-attachment.js';
4
4
  import { isDocumentAttachment, isPdfAttachment } from '../core/document-attachment.js';
@@ -23,12 +23,20 @@ export async function listHistoryChunks(engine, chatId) {
23
23
  engine.listChunks({ chatId, type: 'tool-result' }),
24
24
  engine.listChunks({ chatId, type: 'run-status' })
25
25
  ]);
26
+ const answered = new Set((toolResults.chunks ?? []).flatMap((chunk) => isAnswer(chunk.toolResult?.result) ? [callKey(chunk)] : []));
27
+ const calls = answered.size
28
+ ? ((await engine.listChunks({ chatId, type: 'tool-call' })).chunks ?? [])
29
+ : [];
26
30
  return [
27
31
  ...(history.chunks ?? []),
28
32
  ...(toolResults.chunks ?? []),
29
- ...(runStatuses.chunks ?? [])
33
+ ...(runStatuses.chunks ?? []),
34
+ ...calls.filter((chunk) => answered.has(callKey(chunk)))
30
35
  ].sort((a, b) => a.seq - b.seq);
31
36
  }
37
+ function callKey(chunk) {
38
+ return `${chunk.runId ?? ''}:${chunk.callId ?? ''}`;
39
+ }
32
40
  export function latestAttemptStarts(chunks) {
33
41
  return attemptStarts(chunks);
34
42
  }
@@ -88,6 +96,7 @@ export function historyFromChunks(chunks, stale = {}, { sentRuns = new Map(), as
88
96
  const history = [];
89
97
  const replayedSkills = new Set();
90
98
  const answeredCalls = new Set();
99
+ const calls = new Map();
91
100
  if (folded.summary) {
92
101
  history.push({ role: 'user', content: compactionTurn(folded.summary) });
93
102
  }
@@ -175,7 +184,26 @@ export function historyFromChunks(chunks, stale = {}, { sentRuns = new Map(), as
175
184
  anchor(chunk.runId);
176
185
  continue;
177
186
  }
187
+ if (chunk.toolCall) {
188
+ calls.set(callKey(chunk), chunk);
189
+ continue;
190
+ }
178
191
  if (chunk.toolResult && chunk.runId && sentRuns.has(chunk.runId)) {
192
+ const call = calls.get(callKey(chunk))?.toolCall;
193
+ const live = !staleRunIds.has(chunk.runId) && !beforeLatestAttempt(chunk, attemptStarts);
194
+ if (call &&
195
+ chunk.callId &&
196
+ isAnswer(chunk.toolResult.result) &&
197
+ live &&
198
+ !repeatedCall(chunk, answeredCalls)) {
199
+ const turns = answeredToolTurns({
200
+ name: call.name,
201
+ id: chunk.callId,
202
+ arguments: isRecord(call.arguments) ? call.arguments : {}
203
+ });
204
+ history.splice(history.indexOf(anchor(chunk.runId)), 0, ...turns);
205
+ turns.forEach((turn) => kept.add(turn));
206
+ }
179
207
  continue;
180
208
  }
181
209
  if (chunk.toolResult?.name === SKILL_TOOL) {
@@ -79,6 +79,7 @@ export declare class Files extends EventEmitter {
79
79
  knowledge(options?: Parameters<typeof knowledgeFiles>[1]): import("./knowledge.ts").KnowledgeFiles;
80
80
  listKnowledge(chatId: string): Promise<QvacKnowledge[]>;
81
81
  knowledgeBase(): Promise<AssistantKnowledgeBaseList>;
82
+ private _embedding;
82
83
  record(id: string): Promise<QvacKnowledge | null>;
83
84
  resolve(request: ChatFileKey): Promise<FileRecord | null>;
84
85
  fileRead(request: Omit<AssistantFileReadRequest, 'meshId'>, options?: FileReadOptions): AsyncGenerator<AssistantFileReadFrame>;
@@ -125,7 +125,8 @@ export class Files extends EventEmitter {
125
125
  error: failure?.detail,
126
126
  loaded: !!this.state.get(knowledge.id)?.loaded,
127
127
  reason: failure?.reason,
128
- failedOn: device?.name
128
+ failedOn: device?.name,
129
+ progress: status?.status === 'ready' ? undefined : this._embedding(knowledge.id, rag)
129
130
  });
130
131
  }
131
132
  return {
@@ -138,6 +139,15 @@ export class Files extends EventEmitter {
138
139
  await snap.close();
139
140
  }
140
141
  }
142
+ _embedding(knowledgeId, attempts) {
143
+ const progress = this.state.get(knowledgeId)?.progress;
144
+ const now = Date.now();
145
+ const claimed = attempts.some((row) => isClaimLive(row, now) && b4a.equals(row.claimedBy, this._mesh.localWriterKey));
146
+ if (progress?.stage !== 'embedding' || !claimed) {
147
+ return undefined;
148
+ }
149
+ return chunkProgress(progress);
150
+ }
141
151
  record(id) {
142
152
  return getKnowledge(this._mesh, id);
143
153
  }
@@ -684,11 +694,7 @@ export class Files extends EventEmitter {
684
694
  if (local?.progress &&
685
695
  processor.state !== 'not-applicable' &&
686
696
  (!claim || b4a.equals(claim.claimedBy, this._mesh.localWriterKey))) {
687
- processor.progress = {
688
- completed: local.progress.processedChunks,
689
- total: local.progress.totalChunks || undefined,
690
- unit: 'chunks'
691
- };
697
+ processor.progress = chunkProgress(local.progress);
692
698
  }
693
699
  const readyForChat = applicable
694
700
  ? processor.state === 'ready'
@@ -797,6 +803,13 @@ export class Files extends EventEmitter {
797
803
  await this._store.close();
798
804
  }
799
805
  }
806
+ function chunkProgress(progress) {
807
+ return {
808
+ completed: progress.processedChunks,
809
+ total: progress.totalChunks || undefined,
810
+ unit: 'chunks'
811
+ };
812
+ }
800
813
  function settledFile(file) {
801
814
  return file.readyForChat || file.state === 'failed';
802
815
  }
@@ -246,7 +246,10 @@ export class FileProcessing {
246
246
  _pump(lane) {
247
247
  while (lane.queue.size && !this._closed && !this._paused && !this._mesh.closing) {
248
248
  const busy = [...lane.jobs];
249
- if (busy.length && (lane.stage !== 'produce' || busy.length > 1 || !busy[0].admitted)) {
249
+ const full = lane.stage === 'produce'
250
+ ? busy.length > 1 || (busy.length === 1 && !busy[0].admitted)
251
+ : busy.some((job) => !job.admitted);
252
+ if (full) {
250
253
  return;
251
254
  }
252
255
  const next = [...lane.queue].find(([queued]) => !busy.some((job) => job.id === queued));
@@ -76,9 +76,31 @@ async function pageChunks(input, pdfPages) {
76
76
  mimeType: knowledge.mimeType,
77
77
  content: ''
78
78
  };
79
- const chunks = pages.flatMap(({ page, text }) => chunkRagDocuments([{ ...document, content: text }], {}).map((chunk) => ({ chunk, page })));
79
+ const chunks = withoutShortPages(pages).flatMap(({ page, text }) => chunkRagDocuments([{ ...document, content: text }], {}).map((chunk) => ({ chunk, page })));
80
80
  return chunks.map(({ chunk, page }, index) => numbered(chunk, { page, index }));
81
81
  }
82
+ const SHORT_PAGE_WORDS = 12;
83
+ const UNSPACED = /[\p{sc=Han}\p{sc=Hiragana}\p{sc=Katakana}\p{sc=Thai}\p{sc=Lao}\p{sc=Khmer}\p{sc=Myanmar}]/gu;
84
+ const wordsIn = (text) => text.split(/\s+/).filter(Boolean).length + (text.match(UNSPACED)?.length ?? 0);
85
+ const oneParagraph = (text) => text.trim().replace(/\n\s*\n/g, '\n');
86
+ function withoutShortPages(pages) {
87
+ const out = [];
88
+ let held = '';
89
+ for (const { page, text } of pages) {
90
+ const short = wordsIn(text) < SHORT_PAGE_WORDS;
91
+ held = [held, short ? oneParagraph(text) : text].filter(Boolean).join('\n');
92
+ if (short && wordsIn(held) < SHORT_PAGE_WORDS) {
93
+ continue;
94
+ }
95
+ out.push({ page, text: held });
96
+ held = '';
97
+ }
98
+ const last = out.pop();
99
+ if (!last) {
100
+ return pages;
101
+ }
102
+ return [...out, { page: last.page, text: [last.text, held].filter(Boolean).join('\n') }];
103
+ }
82
104
  function numbered(chunk, { page, index }) {
83
105
  const parsed = JSON.parse(chunk.metadataJson);
84
106
  const metadata = isRecord(parsed) ? parsed : {};
@@ -22,7 +22,10 @@ export declare class HydratePass {
22
22
  private readonly _index;
23
23
  private readonly _embedder;
24
24
  private readonly _extractors;
25
+ private _rebuilding;
26
+ private readonly _rebuildWaiters;
25
27
  constructor(opts: HydratePassOptions);
26
28
  run(document: FileDocument, signal: AbortSignal): Promise<void>;
27
29
  private _rebuild;
30
+ private _rebuildOne;
28
31
  }
@@ -21,6 +21,8 @@ export class HydratePass {
21
21
  _index;
22
22
  _embedder;
23
23
  _extractors;
24
+ _rebuilding = false;
25
+ _rebuildWaiters = new Map();
24
26
  constructor(opts) {
25
27
  this._model = opts.model;
26
28
  this._index = opts.index;
@@ -165,13 +167,32 @@ export class HydratePass {
165
167
  }
166
168
  }
167
169
  async _rebuild(document, artifact, signal) {
170
+ const embedder = this._embedder;
171
+ if (!embedder || (document.artifact(artifact.id).rebuildFailures ?? 0) > EMBED_RETRY_LIMIT) {
172
+ return;
173
+ }
174
+ if (this._rebuilding) {
175
+ this._rebuildWaiters.set(document.record.id, () => document.schedule(Date.now()));
176
+ return;
177
+ }
178
+ this._rebuilding = true;
179
+ document.admit();
180
+ try {
181
+ await this._rebuildOne(document, { artifact, embedder, signal });
182
+ }
183
+ finally {
184
+ this._rebuilding = false;
185
+ const waiters = [...this._rebuildWaiters.values()];
186
+ this._rebuildWaiters.clear();
187
+ for (const wake of waiters) {
188
+ wake();
189
+ }
190
+ }
191
+ }
192
+ async _rebuildOne(document, { artifact, embedder, signal }) {
168
193
  const knowledge = document.record;
169
194
  const local = document.artifact(artifact.id);
170
- if (!this._embedder ||
171
- (local.rebuildFailures ?? 0) > EMBED_RETRY_LIMIT ||
172
- document.paused() ||
173
- document.closed() ||
174
- signal.aborted) {
195
+ if (document.paused() || document.closed() || signal.aborted) {
175
196
  return;
176
197
  }
177
198
  const retryAt = document.output(knowledge.id, knowledge.blobId).blockedUntil();
@@ -200,7 +221,7 @@ export class HydratePass {
200
221
  }
201
222
  document.load({ state: 'running', reason: 'rebuilding local index' });
202
223
  const payload = await buildArtifactPayload({
203
- embedder: this._embedder,
224
+ embedder,
204
225
  extractors: this._extractors,
205
226
  knowledge,
206
227
  artifactId: artifact.id,
@@ -255,6 +255,7 @@ export declare class Mesh extends ReadyResource {
255
255
  _autobeeIsTrusted(key: Buffer, reference: MeshView): Promise<boolean>;
256
256
  _autobeeMostRecentTrusted(target: MeshView, reference: MeshView | null): Promise<AutobeeOplogRef | null>;
257
257
  private _newestLinked;
258
+ private _trustedIndex;
258
259
  private _newestTrustedOf;
259
260
  private _trusts;
260
261
  _autobeeOpen(bee: unknown): MeshView;
@@ -532,9 +532,6 @@ export class Mesh extends ReadyResource {
532
532
  this._background.stop();
533
533
  this._ownWriterSession?.destroy();
534
534
  await this._files?.close();
535
- if (!this.autobee.closing) {
536
- await this.autobee.update();
537
- }
538
535
  await Promise.all([this.autobee.close(), this.blobs.close()]);
539
536
  await this.view.close();
540
537
  this._blindPeering = null;
@@ -587,6 +584,7 @@ export class Mesh extends ReadyResource {
587
584
  assertJoined(this.autobee, opts);
588
585
  const write = this.autobee.append(encode(`@qvac/${name}`, versionedOp(name, payload)), opts);
589
586
  await this._watchStall(write, { what: 'mesh write', op: name, ms: this._slowWriteMs });
587
+ assertWritten(this.autobee);
590
588
  }
591
589
  async _watchStall(pending, watch) {
592
590
  const started = Date.now();
@@ -946,13 +944,15 @@ export class Mesh extends ReadyResource {
946
944
  }
947
945
  }
948
946
  _newestLinked(db) {
949
- const index = this.ourMemberId ? LINKED_WRITERS_BY_MOST_RECENT : LIVE_WRITERS_BY_MOST_RECENT;
950
- return db.findOne(index, { reverse: true });
947
+ return db.findOne(this._trustedIndex(), { reverse: true });
948
+ }
949
+ _trustedIndex() {
950
+ return this.ourMemberId ? LINKED_WRITERS_BY_MOST_RECENT : LIVE_WRITERS_BY_MOST_RECENT;
951
951
  }
952
952
  async _newestTrustedOf(candidate, ours) {
953
953
  const held = this._heldOrServed(ours);
954
954
  try {
955
- for await (const writer of candidate.find(LIVE_WRITERS_BY_MOST_RECENT, {
955
+ for await (const writer of candidate.find(this._trustedIndex(), {
956
956
  reverse: true
957
957
  })) {
958
958
  if (await isTrustedWriter(held, writer.writerKey, this)) {
@@ -987,24 +987,25 @@ export class Mesh extends ReadyResource {
987
987
  const read = view.db.snapshot();
988
988
  snap = read;
989
989
  const tail = { reverse: true, limit: WARMUP_TAIL };
990
- const [own, byId, name, rules, writers, linked, chats, groups] = await Promise.all([
990
+ const [own, byId, name, rules, live, linked, chats, groups] = await Promise.all([
991
991
  liveDeviceForWriter(read, this.localWriterKey),
992
992
  this._deviceId ? read.get(DEVICES, { id: this._deviceId }) : null,
993
993
  read.get(MESH_NAMES, { id: MESH_NAME_ROW }),
994
994
  read.get(MESH_RULES, { id: MESH_RULES_ROW }),
995
- read.find(LIVE_WRITERS_BY_MOST_RECENT, tail).toArray(),
996
- read.find(LINKED_WRITERS_BY_MOST_RECENT, tail).toArray(),
995
+ read.findOne(LIVE_WRITERS_BY_MOST_RECENT, { reverse: true }),
996
+ read.findOne(LINKED_WRITERS_BY_MOST_RECENT, { reverse: true }),
997
997
  this._sidebarTop(read),
998
998
  read.find(ACTIVE_CHAT_GROUPS, tail).toArray()
999
999
  ]);
1000
1000
  const memberId = byId?.memberId ?? own?.memberId ?? null;
1001
+ const newest = [live, linked].filter((row) => row !== null);
1001
1002
  const [member, counters, devices] = await Promise.all([
1002
1003
  memberId ? read.get(MEMBERS, { id: memberId }) : null,
1003
1004
  sidebarRows(read, chats, memberId),
1004
- Promise.all(writers.map((writer) => liveDeviceForWriter(read, writer.writerKey)))
1005
+ Promise.all(newest.map((writer) => liveDeviceForWriter(read, writer.writerKey)))
1005
1006
  ]);
1006
- const rows = [own, byId, name, rules, member, ...counters, ...devices].filter((row) => row !== null);
1007
- const warmed = rows.length + writers.length + linked.length + chats.length + groups.length;
1007
+ const rows = [own, byId, name, rules, ...newest, member, ...devices, ...counters].filter((row) => row !== null);
1008
+ const warmed = rows.length + chats.length + groups.length;
1008
1009
  this._log?.info(this._scope, 'warmed candidate view', {
1009
1010
  warmed,
1010
1011
  length: view.db.db.head()?.length ?? 0,
@@ -1251,6 +1252,12 @@ export class MeshBatch {
1251
1252
  this._ops = [];
1252
1253
  this._names = [];
1253
1254
  await this._watch(names.join(','), this._autobee.append(ops, opts));
1255
+ assertWritten(this._autobee);
1256
+ }
1257
+ }
1258
+ function assertWritten(autobee) {
1259
+ if (autobee.closing && autobee.appending) {
1260
+ throw new CoreError('MESH_CLOSED_BEFORE_WRITE');
1254
1261
  }
1255
1262
  }
1256
1263
  function noop() { }
@@ -1,3 +1,2 @@
1
1
  import type { Mesh } from '../mesh.ts';
2
- export declare const REINDEX_WRITERS_FROM_APP_VERSION = "0.23.0";
3
2
  export declare function backfillWriterLinks(mesh: Mesh): Promise<number>;
@@ -1,23 +1,25 @@
1
1
  import { LIVE_WRITERS_BY_MOST_RECENT } from '../collections.js';
2
2
  import { linkedTo, liveDeviceForWriter } from '../contract/activity.js';
3
- export const REINDEX_WRITERS_FROM_APP_VERSION = '0.23.0';
4
- const BACKFILL_TAIL = 64;
3
+ const PAGE = 64;
5
4
  export async function backfillWriterLinks(mesh) {
6
5
  const due = await unmarkedLinkedWriters(mesh.view);
7
- if (due.length === 0 || mesh.closing || !mesh.writable) {
8
- return 0;
6
+ let sent = 0;
7
+ for (let i = 0; i < due.length; i += PAGE) {
8
+ if (mesh.closing || !mesh.writable)
9
+ break;
10
+ const writerKeys = due.slice(i, i + PAGE);
11
+ await mesh.dispatch('reindex-writers', { writerKeys });
12
+ sent += writerKeys.length;
9
13
  }
10
- await mesh.dispatch('reindex-writers', { writerKeys: due });
11
- return due.length;
14
+ return sent;
12
15
  }
13
16
  async function unmarkedLinkedWriters(db) {
14
17
  const snap = db.snapshot();
15
18
  try {
16
19
  const due = [];
17
- const newest = { reverse: true, limit: BACKFILL_TAIL };
18
- for (const row of await snap
19
- .find(LIVE_WRITERS_BY_MOST_RECENT, newest)
20
- .toArray()) {
20
+ for await (const row of snap.find(LIVE_WRITERS_BY_MOST_RECENT, {
21
+ reverse: true
22
+ })) {
21
23
  if (!row.linked && linkedTo(await liveDeviceForWriter(snap, row.writerKey))) {
22
24
  due.push(row.writerKey);
23
25
  }
@@ -71,7 +71,7 @@ import { claimOwnMembership, legacyNameStamp, namedAt, renameFoundedMember } fro
71
71
  import { runMigrations } from './core/migrations/index.js';
72
72
  import { backfillFileIndex } from './core/migrations/file-index.js';
73
73
  import { REINDEX_FROM_APP_VERSION, backfillChatChunks, floorExcludesBefore } from './core/migrations/chat-chunks.js';
74
- import { REINDEX_WRITERS_FROM_APP_VERSION, backfillWriterLinks } from './core/migrations/writer-links.js';
74
+ import { backfillWriterLinks } from './core/migrations/writer-links.js';
75
75
  import { advertiseDeviceVersion, retractInventory } from './core/devices.js';
76
76
  import { DeviceControl } from './core/device-control.js';
77
77
  import { forwardToDevices, servedToSiblings } from './api/device-routes.js';
@@ -746,7 +746,8 @@ export class Core extends ReadyResource {
746
746
  const mesh = await this._switchToMesh({
747
747
  seed: this._meshSeed,
748
748
  baseKey: this._meshKey,
749
- account: true
749
+ account: true,
750
+ boot: true
750
751
  });
751
752
  }
752
753
  catch (err) {
@@ -942,7 +943,6 @@ export class Core extends ReadyResource {
942
943
  }
943
944
  for (const { mesh } of this._meshes.values()) {
944
945
  void this._backfillChatChunks(mesh);
945
- void this._backfillWriterLinks(mesh);
946
946
  }
947
947
  return;
948
948
  }
@@ -1266,13 +1266,18 @@ export class Core extends ReadyResource {
1266
1266
  throw halted;
1267
1267
  }
1268
1268
  await this._adoptAccount(mesh);
1269
+ const late = mesh.interrupted;
1270
+ if (late) {
1271
+ this._withdrawFromMesh(mesh, late);
1272
+ throw late;
1273
+ }
1269
1274
  return mesh;
1270
1275
  }
1271
1276
  async _openMesh(opts = {}) {
1272
1277
  const session = await this.local.resolveSession(this._requireDeviceKeyPair().publicKey, opts);
1273
1278
  return this._openMeshSession(session, opts);
1274
1279
  }
1275
- async _openMeshSession(session, { blindPeerKeys, account, initial, sharing, workspace, project } = {}) {
1280
+ async _openMeshSession(session, { blindPeerKeys, account, initial, sharing, workspace, project, boot } = {}) {
1276
1281
  this._refuseClosing();
1277
1282
  const deviceId = this._requireDeviceKeyPair().publicKey;
1278
1283
  const mesh = this._newMesh(session, session.role ?? (account ? 'account' : 'project'), blindPeerKeys);
@@ -1297,7 +1302,8 @@ export class Core extends ReadyResource {
1297
1302
  initial,
1298
1303
  sharing,
1299
1304
  workspace,
1300
- project
1305
+ project,
1306
+ boot
1301
1307
  });
1302
1308
  }
1303
1309
  this._refuseClosing();
@@ -1334,7 +1340,12 @@ export class Core extends ReadyResource {
1334
1340
  });
1335
1341
  return mesh;
1336
1342
  }
1337
- async _appendOwnBirth(mesh, session, { deviceId, account, initial, sharing, workspace, project }) {
1343
+ async _appendOwnBirth(mesh, session, { deviceId, account, initial, sharing, workspace, project, boot }) {
1344
+ if (boot && mesh.localLength > 0) {
1345
+ await this.local.recordMesh(mesh.key, session, { deviceId, account, initial });
1346
+ void this._appendJoinLater(mesh, () => Promise.resolve(undefined), sharing);
1347
+ return;
1348
+ }
1338
1349
  await raceResource(mesh.autobee, (async () => {
1339
1350
  const birth = sharing
1340
1351
  ? await this._accountBirthMember(mesh, session)
@@ -2773,14 +2784,15 @@ export class Core extends ReadyResource {
2773
2784
  if (this._joinCancellation) {
2774
2785
  this._joinCancellation.accepting = false;
2775
2786
  }
2787
+ let member;
2776
2788
  try {
2789
+ member = await this._candidateBirthMember(candidate, invite);
2777
2790
  await this.local.recordMesh(candidate.key, session, { deviceId });
2778
2791
  }
2779
2792
  catch (error) {
2780
2793
  await this._discardCandidateMesh();
2781
2794
  throw error;
2782
2795
  }
2783
- const member = await this._candidateBirthMember(candidate, invite);
2784
2796
  const appended = this._appendJoinLater(candidate, async () => member);
2785
2797
  return this._landJoinedMesh(candidate, {
2786
2798
  source,
@@ -3832,7 +3844,7 @@ export class Core extends ReadyResource {
3832
3844
  async _settlePublicMeshes(account) {
3833
3845
  let settled = true;
3834
3846
  try {
3835
- await this._settleOwnWorkspace(account);
3847
+ settled = await this._settleOwnWorkspace(account);
3836
3848
  }
3837
3849
  catch (err) {
3838
3850
  settled = false;
@@ -3859,7 +3871,7 @@ export class Core extends ReadyResource {
3859
3871
  }
3860
3872
  async _settleOwnWorkspace(account) {
3861
3873
  if (this._localDevice && !account.ourMemberId) {
3862
- return;
3874
+ return true;
3863
3875
  }
3864
3876
  const local = (await this.local.listMeshes()).filter((row) => !b4a.equals(row.key, account.key) &&
3865
3877
  !row.workspaceKey &&
@@ -3869,11 +3881,14 @@ export class Core extends ReadyResource {
3869
3881
  const own = ours
3870
3882
  .filter((row) => row.initial && !row.kicked)
3871
3883
  .sort((a, b) => (b.joinedAt || Infinity) - (a.joinedAt || Infinity))[0];
3884
+ if (!own && !account.joined) {
3885
+ return false;
3886
+ }
3872
3887
  const mints = !own &&
3873
3888
  !(await this._markDerivedInitial(account, rows)) &&
3874
3889
  (await this._mintsOwnWorkspace(account, { rows, local: ours }));
3875
3890
  if (!this._isAccount(account)) {
3876
- return;
3891
+ return true;
3877
3892
  }
3878
3893
  this._setOwnWorkspace(own ? b4a.toHex(own.key) : null);
3879
3894
  if (mints) {
@@ -3883,6 +3898,7 @@ export class Core extends ReadyResource {
3883
3898
  this._ownDecided = account;
3884
3899
  this._notifyStatus();
3885
3900
  }
3901
+ return true;
3886
3902
  }
3887
3903
  async _mintsOwnWorkspace(account, { rows, local }) {
3888
3904
  if (!rows.length && !local.length) {
@@ -4494,9 +4510,6 @@ export class Core extends ReadyResource {
4494
4510
  return this._meshes.get(meshKey)?.mesh ?? null;
4495
4511
  }
4496
4512
  async _backfillWriterLinks(mesh) {
4497
- if (!floorExcludesBefore(this._minSupportedVersion, REINDEX_WRITERS_FROM_APP_VERSION)) {
4498
- return;
4499
- }
4500
4513
  try {
4501
4514
  await mesh.waitForWritable();
4502
4515
  await mesh.autobee.update();
@@ -143,6 +143,10 @@ declare const DEFINITIONS: {
143
143
  readonly code: 100132;
144
144
  readonly message: () => string;
145
145
  };
146
+ readonly MESH_CLOSED_BEFORE_WRITE: {
147
+ readonly code: 100133;
148
+ readonly message: () => string;
149
+ };
146
150
  readonly INVITE_INVALID: {
147
151
  readonly code: 100201;
148
152
  readonly message: () => string;
@@ -117,6 +117,10 @@ const DEFINITIONS = {
117
117
  code: 100132,
118
118
  message: () => 'This mesh is still syncing: the rows this read needs have not reached this device'
119
119
  },
120
+ MESH_CLOSED_BEFORE_WRITE: {
121
+ code: 100133,
122
+ message: () => 'The mesh closed before this write reached its log; nothing was written'
123
+ },
120
124
  INVITE_INVALID: { code: 100201, message: () => 'Invalid mesh invite' },
121
125
  MESH_JOIN_CANCELED: { code: 100202, message: () => 'Mesh join canceled' },
122
126
  JOIN_NOT_PERMITTED: {
@@ -963,7 +963,8 @@ export function registerEngineTypes(ns) {
963
963
  { name: 'error', type: 'string' },
964
964
  { name: 'loaded', type: 'bool', required: true },
965
965
  { name: 'reason', type: '@assistant/indexing-failure' },
966
- { name: 'failedOn', type: 'string' }
966
+ { name: 'failedOn', type: 'string' },
967
+ { name: 'progress', type: '@assistant/file-progress' }
967
968
  ]
968
969
  });
969
970
  ns.register({
@@ -6057,14 +6057,20 @@ const encoding150 = {
6057
6057
  preencode(state, m) {
6058
6058
  encoding150_0.preencode(state, m.knowledge)
6059
6059
  encoding146.preencode(state, m.status)
6060
- state.end++ // max flag is 8 so always one byte
6060
+ state.end++ // max flag is 16 so always one byte
6061
6061
 
6062
6062
  if (m.error) c.string.preencode(state, m.error)
6063
6063
  if (m.reason) encoding149.preencode(state, m.reason)
6064
6064
  if (m.failedOn) c.string.preencode(state, m.failedOn)
6065
+ if (m.progress) encoding150_6.preencode(state, m.progress)
6065
6066
  },
6066
6067
  encode(state, m) {
6067
- const flags = (m.error ? 1 : 0) | (m.loaded ? 2 : 0) | (m.reason ? 4 : 0) | (m.failedOn ? 8 : 0)
6068
+ const flags =
6069
+ (m.error ? 1 : 0) |
6070
+ (m.loaded ? 2 : 0) |
6071
+ (m.reason ? 4 : 0) |
6072
+ (m.failedOn ? 8 : 0) |
6073
+ (m.progress ? 16 : 0)
6068
6074
 
6069
6075
  encoding150_0.encode(state, m.knowledge)
6070
6076
  encoding146.encode(state, m.status)
@@ -6073,6 +6079,7 @@ const encoding150 = {
6073
6079
  if (m.error) c.string.encode(state, m.error)
6074
6080
  if (m.reason) encoding149.encode(state, m.reason)
6075
6081
  if (m.failedOn) c.string.encode(state, m.failedOn)
6082
+ if (m.progress) encoding150_6.encode(state, m.progress)
6076
6083
  },
6077
6084
  decode(state) {
6078
6085
  const r0 = encoding150_0.decode(state)
@@ -6085,7 +6092,8 @@ const encoding150 = {
6085
6092
  error: (flags & 1) !== 0 ? c.string.decode(state) : null,
6086
6093
  loaded: (flags & 2) !== 0,
6087
6094
  reason: (flags & 4) !== 0 ? encoding149.decode(state) : null,
6088
- failedOn: (flags & 8) !== 0 ? c.string.decode(state) : null
6095
+ failedOn: (flags & 8) !== 0 ? c.string.decode(state) : null,
6096
+ progress: (flags & 16) !== 0 ? encoding150_6.decode(state) : null
6089
6097
  }
6090
6098
  }
6091
6099
  }
@@ -9764,9 +9772,6 @@ const encoding259 = {
9764
9772
  }
9765
9773
  }
9766
9774
 
9767
- // @assistant/file-processor-status.progress
9768
- const encoding260_7 = c.frame(encoding259)
9769
-
9770
9775
  // @assistant/file-processor-status
9771
9776
  const encoding260 = {
9772
9777
  preencode(state, m) {
@@ -9835,8 +9840,6 @@ const encoding260 = {
9835
9840
  }
9836
9841
  }
9837
9842
 
9838
- // @assistant/file-status.uploadProgress
9839
- const encoding261_6 = encoding260_7
9840
9843
  // @assistant/file-status.processors
9841
9844
  const encoding261_7 = c.array(c.frame(encoding260))
9842
9845
 
@@ -12774,8 +12777,14 @@ const encoding367 = {
12774
12777
  }
12775
12778
  }
12776
12779
 
12780
+ // @assistant/knowledge-base-entry.progress, deferred due to recusive use
12781
+ const encoding150_6 = c.frame(encoding259)
12777
12782
  // @assistant/model-info-list.memory, deferred due to recusive use
12778
12783
  const encoding175_1 = c.frame(encoding322)
12784
+ // @assistant/file-processor-status.progress, deferred due to recusive use
12785
+ const encoding260_7 = encoding150_6
12786
+ // @assistant/file-status.uploadProgress, deferred due to recusive use
12787
+ const encoding261_6 = encoding150_6
12779
12788
 
12780
12789
  function setVersion(v) {
12781
12790
  version = v
@@ -6057,14 +6057,20 @@ const encoding150 = {
6057
6057
  preencode(state, m) {
6058
6058
  encoding150_0.preencode(state, m.knowledge)
6059
6059
  encoding146.preencode(state, m.status)
6060
- state.end++ // max flag is 8 so always one byte
6060
+ state.end++ // max flag is 16 so always one byte
6061
6061
 
6062
6062
  if (m.error) c.string.preencode(state, m.error)
6063
6063
  if (m.reason) encoding149.preencode(state, m.reason)
6064
6064
  if (m.failedOn) c.string.preencode(state, m.failedOn)
6065
+ if (m.progress) encoding150_6.preencode(state, m.progress)
6065
6066
  },
6066
6067
  encode(state, m) {
6067
- const flags = (m.error ? 1 : 0) | (m.loaded ? 2 : 0) | (m.reason ? 4 : 0) | (m.failedOn ? 8 : 0)
6068
+ const flags =
6069
+ (m.error ? 1 : 0) |
6070
+ (m.loaded ? 2 : 0) |
6071
+ (m.reason ? 4 : 0) |
6072
+ (m.failedOn ? 8 : 0) |
6073
+ (m.progress ? 16 : 0)
6068
6074
 
6069
6075
  encoding150_0.encode(state, m.knowledge)
6070
6076
  encoding146.encode(state, m.status)
@@ -6073,6 +6079,7 @@ const encoding150 = {
6073
6079
  if (m.error) c.string.encode(state, m.error)
6074
6080
  if (m.reason) encoding149.encode(state, m.reason)
6075
6081
  if (m.failedOn) c.string.encode(state, m.failedOn)
6082
+ if (m.progress) encoding150_6.encode(state, m.progress)
6076
6083
  },
6077
6084
  decode(state) {
6078
6085
  const r0 = encoding150_0.decode(state)
@@ -6085,7 +6092,8 @@ const encoding150 = {
6085
6092
  error: (flags & 1) !== 0 ? c.string.decode(state) : null,
6086
6093
  loaded: (flags & 2) !== 0,
6087
6094
  reason: (flags & 4) !== 0 ? encoding149.decode(state) : null,
6088
- failedOn: (flags & 8) !== 0 ? c.string.decode(state) : null
6095
+ failedOn: (flags & 8) !== 0 ? c.string.decode(state) : null,
6096
+ progress: (flags & 16) !== 0 ? encoding150_6.decode(state) : null
6089
6097
  }
6090
6098
  }
6091
6099
  }
@@ -9764,9 +9772,6 @@ const encoding259 = {
9764
9772
  }
9765
9773
  }
9766
9774
 
9767
- // @assistant/file-processor-status.progress
9768
- const encoding260_7 = c.frame(encoding259)
9769
-
9770
9775
  // @assistant/file-processor-status
9771
9776
  const encoding260 = {
9772
9777
  preencode(state, m) {
@@ -9835,8 +9840,6 @@ const encoding260 = {
9835
9840
  }
9836
9841
  }
9837
9842
 
9838
- // @assistant/file-status.uploadProgress
9839
- const encoding261_6 = encoding260_7
9840
9843
  // @assistant/file-status.processors
9841
9844
  const encoding261_7 = c.array(c.frame(encoding260))
9842
9845
 
@@ -12774,8 +12777,14 @@ const encoding367 = {
12774
12777
  }
12775
12778
  }
12776
12779
 
12780
+ // @assistant/knowledge-base-entry.progress, deferred due to recusive use
12781
+ const encoding150_6 = c.frame(encoding259)
12777
12782
  // @assistant/model-info-list.memory, deferred due to recusive use
12778
12783
  const encoding175_1 = c.frame(encoding322)
12784
+ // @assistant/file-processor-status.progress, deferred due to recusive use
12785
+ const encoding260_7 = encoding150_6
12786
+ // @assistant/file-status.uploadProgress, deferred due to recusive use
12787
+ const encoding261_6 = encoding150_6
12779
12788
 
12780
12789
  function setVersion(v) {
12781
12790
  version = v
@@ -4727,6 +4727,11 @@
4727
4727
  "name": "failedOn",
4728
4728
  "type": "string",
4729
4729
  "version": 1
4730
+ },
4731
+ {
4732
+ "name": "progress",
4733
+ "type": "@assistant/file-progress",
4734
+ "version": 1
4730
4735
  }
4731
4736
  ]
4732
4737
  },
@@ -964,6 +964,7 @@ export interface AssistantKnowledgeBaseEntry {
964
964
  loaded?: boolean
965
965
  reason?: AssistantIndexingFailure | null
966
966
  failedOn?: string | null
967
+ progress?: AssistantFileProgress | null
967
968
  }
968
969
 
969
970
  export interface AssistantKnowledgeBaseList {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qvac/core",
3
- "version": "1.0.0-rc.11",
3
+ "version": "1.0.0-rc.12",
4
4
  "upgrade": "pear://56h5xtm7xjjpkbj1ubbuffcjastpxri11n6wr6zy8ikzmyq7ctey",
5
5
  "type": "module",
6
6
  "description": "Peer-to-peer AI across your devices",
@@ -257,9 +257,9 @@
257
257
  },
258
258
  "dependencies": {
259
259
  "@qvac/error": "^0.2.0",
260
- "@qvac/harness": "1.0.0-rc.20",
260
+ "@qvac/harness": "1.0.0-rc.22",
261
261
  "@qvac/logging": "^0.2.0",
262
- "@qvac/skills": "^0.3.0",
262
+ "@qvac/skills": "^0.4.0",
263
263
  "asenion": "^0.1.0",
264
264
  "autobee": "^2.13.3",
265
265
  "b4a": "^1.9.0",
@@ -298,7 +298,7 @@
298
298
  "bare-worker": "^4.5.3",
299
299
  "blind-peer": "^3.18.1",
300
300
  "blind-peering": "2.13.1",
301
- "compact-encoding": "^3.6.0",
301
+ "compact-encoding": "^3.7.0",
302
302
  "corestore": "^7.16.1",
303
303
  "fs-native-lock": "^1.2.0",
304
304
  "hrpc": "^4.3.1",
@@ -318,7 +318,7 @@
318
318
  "paparam": "^1.15.0",
319
319
  "pear-runtime-updater": "^3.4.0",
320
320
  "process-top": "^1.8.0",
321
- "protomux": "^3.13.0",
321
+ "protomux": "^3.13.1",
322
322
  "protomux-wakeup": "^2.9.0",
323
323
  "rache": "^1.0.1",
324
324
  "rag-extract": "^0.2.2",
@@ -399,8 +399,8 @@
399
399
  "lodash": "4.18.1",
400
400
  "hyperschema": "1.26.2",
401
401
  "hyperdb": "^6.11.1",
402
- "hypercore": "^11.40.3",
403
- "hyperbee2": "^2.21.4",
402
+ "hypercore": "^11.40.4",
403
+ "hyperbee2": "^2.22.0",
404
404
  "localwatch": "^1.4.4",
405
405
  "tar": "^7.5.22",
406
406
  "bare-tls": "^3.2.0"
package/tui/README.md CHANGED
@@ -87,7 +87,8 @@ root, and only the first duck running holds the updater.
87
87
  stages them together to the `duck` namespace with
88
88
  [pear-ci](https://docs.pears.com/pear/reference/ci-and-release/pear-ci-action/),
89
89
  which keeps `ci/snapshot.json` on `main` in step with the drive, so it runs only
90
- once the workflow and that file are on `main`. A dry run prints the drive's key
90
+ once the workflow and that file are on `main`. Every publish runs it after npm
91
+ takes the package, staging that version. A dry run prints the drive's key
91
92
  after `starting stage for key`: that `pear://` link is the `upgrade` to commit,
92
93
  and `pear seed` on it must be running before a real stage.
93
94
 
package/tui/boot.mjs CHANGED
@@ -141,6 +141,8 @@ export async function boot(args, entries = null) {
141
141
  },
142
142
  skillsDir,
143
143
  harnessEntry,
144
+ // replaces the sidecar's default, so its cache types are restated; 4 replies decode at once
145
+ llm: { kvCacheK: 'q8_0', kvCacheV: 'q8_0', slots: 4 },
144
146
  fakeModels: args.fakeModels || process.env.QVAC_FAKE_MODELS === '1',
145
147
  // only the image keys cross: the arg is argv, readable by anything that can list processes
146
148
  imageEnv: Object.fromEntries(