@qvac/core 1.0.0-rc.2 → 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.
Files changed (213) hide show
  1. package/CHANGELOG.md +238 -12
  2. package/dist-lib/index.d.ts +3 -1
  3. package/dist-lib/index.js +1 -0
  4. package/dist-lib/lib/api/approval-rules.d.ts +1 -1
  5. package/dist-lib/lib/api/approval-rules.js +5 -1
  6. package/dist-lib/lib/api/chunk-delta.d.ts +7 -2
  7. package/dist-lib/lib/api/chunk-delta.js +89 -7
  8. package/dist-lib/lib/api/chunks.js +14 -8
  9. package/dist-lib/lib/api/config.d.ts +10 -3
  10. package/dist-lib/lib/api/config.js +51 -6
  11. package/dist-lib/lib/api/custom-models.js +3 -5
  12. package/dist-lib/lib/api/devices.js +3 -1
  13. package/dist-lib/lib/api/files.d.ts +1 -1
  14. package/dist-lib/lib/api/files.js +65 -8
  15. package/dist-lib/lib/api/index.d.ts +12 -2
  16. package/dist-lib/lib/api/index.js +6 -1
  17. package/dist-lib/lib/api/instrument.js +12 -4
  18. package/dist-lib/lib/api/members.js +7 -13
  19. package/dist-lib/lib/api/mesh.d.ts +1 -3
  20. package/dist-lib/lib/api/mesh.js +2 -2
  21. package/dist-lib/lib/api/notifications.js +8 -4
  22. package/dist-lib/lib/api/projects.js +5 -1
  23. package/dist-lib/lib/api/rag.js +32 -19
  24. package/dist-lib/lib/api/served.js +2 -1
  25. package/dist-lib/lib/api/workspace.js +0 -1
  26. package/dist-lib/lib/assistant/harness.d.ts +8 -2
  27. package/dist-lib/lib/assistant/harness.js +17 -4
  28. package/dist-lib/lib/assistant/history.d.ts +1 -1
  29. package/dist-lib/lib/assistant/history.js +19 -13
  30. package/dist-lib/lib/assistant/message.d.ts +6 -1
  31. package/dist-lib/lib/assistant/message.js +22 -2
  32. package/dist-lib/lib/assistant/model-round.d.ts +5 -0
  33. package/dist-lib/lib/assistant/model-round.js +47 -19
  34. package/dist-lib/lib/assistant/pdf-budget.d.ts +10 -2
  35. package/dist-lib/lib/assistant/pdf-budget.js +10 -11
  36. package/dist-lib/lib/assistant/pdf-pages.d.ts +25 -0
  37. package/dist-lib/lib/assistant/pdf-pages.js +75 -0
  38. package/dist-lib/lib/assistant/round-host.js +5 -3
  39. package/dist-lib/lib/assistant-client.d.ts +2 -1
  40. package/dist-lib/lib/assistant-client.js +24 -6
  41. package/dist-lib/lib/assistant-tree.d.ts +2 -0
  42. package/dist-lib/lib/assistant-tree.js +8 -5
  43. package/dist-lib/lib/assistant.d.ts +21 -7
  44. package/dist-lib/lib/assistant.js +481 -244
  45. package/dist-lib/lib/client.js +10 -1
  46. package/dist-lib/lib/compaction.d.ts +3 -1
  47. package/dist-lib/lib/compaction.js +18 -4
  48. package/dist-lib/lib/constants.d.ts +3 -0
  49. package/dist-lib/lib/constants.js +3 -0
  50. package/dist-lib/lib/core/agent-copies.js +7 -1
  51. package/dist-lib/lib/core/agent.js +1 -0
  52. package/dist-lib/lib/core/approval-rules.d.ts +5 -1
  53. package/dist-lib/lib/core/approval-rules.js +16 -1
  54. package/dist-lib/lib/core/chat-activity.js +13 -16
  55. package/dist-lib/lib/core/chat-copy.js +1 -1
  56. package/dist-lib/lib/core/chat-fork.js +2 -1
  57. package/dist-lib/lib/core/chat-move.d.ts +4 -0
  58. package/dist-lib/lib/core/chat-move.js +42 -11
  59. package/dist-lib/lib/core/chat.d.ts +0 -1
  60. package/dist-lib/lib/core/chat.js +1 -1
  61. package/dist-lib/lib/core/chunk.d.ts +14 -3
  62. package/dist-lib/lib/core/chunk.js +116 -25
  63. package/dist-lib/lib/core/collections.d.ts +12 -1
  64. package/dist-lib/lib/core/collections.js +12 -1
  65. package/dist-lib/lib/core/config-value.d.ts +7 -0
  66. package/dist-lib/lib/core/config-value.js +15 -0
  67. package/dist-lib/lib/core/contract/activity.d.ts +3 -2
  68. package/dist-lib/lib/core/contract/activity.js +39 -21
  69. package/dist-lib/lib/core/contract/agent-join.js +15 -19
  70. package/dist-lib/lib/core/contract/agents.js +8 -7
  71. package/dist-lib/lib/core/contract/chat.d.ts +3 -0
  72. package/dist-lib/lib/core/contract/chat.js +12 -1
  73. package/dist-lib/lib/core/contract/chunks.js +16 -6
  74. package/dist-lib/lib/core/contract/devices.js +6 -4
  75. package/dist-lib/lib/core/contract/index.js +2 -1
  76. package/dist-lib/lib/core/contract/invites.js +12 -31
  77. package/dist-lib/lib/core/contract/joined-meshes.js +2 -1
  78. package/dist-lib/lib/core/contract/mesh-rules.js +4 -0
  79. package/dist-lib/lib/core/contract/model-requests.js +7 -6
  80. package/dist-lib/lib/core/contract/project-device-keys.js +15 -6
  81. package/dist-lib/lib/core/contract/project-host-keys.js +5 -4
  82. package/dist-lib/lib/core/contract/projects.js +12 -13
  83. package/dist-lib/lib/core/contract/public-seeds.js +5 -5
  84. package/dist-lib/lib/core/contract/roles.js +2 -1
  85. package/dist-lib/lib/core/contract/run-requests.d.ts +1 -1
  86. package/dist-lib/lib/core/contract/run-requests.js +19 -13
  87. package/dist-lib/lib/core/contract/shipped-rows.d.ts +2 -0
  88. package/dist-lib/lib/core/contract/shipped-rows.js +22 -0
  89. package/dist-lib/lib/core/contract/workspace.js +6 -12
  90. package/dist-lib/lib/core/contract/writers.js +20 -6
  91. package/dist-lib/lib/core/deleted-agent-runs.d.ts +7 -0
  92. package/dist-lib/lib/core/deleted-agent-runs.js +46 -0
  93. package/dist-lib/lib/core/devices.d.ts +2 -1
  94. package/dist-lib/lib/core/devices.js +4 -2
  95. package/dist-lib/lib/core/document-attachment.d.ts +6 -3
  96. package/dist-lib/lib/core/document-attachment.js +10 -5
  97. package/dist-lib/lib/core/files/attachments.js +3 -3
  98. package/dist-lib/lib/core/files/index.d.ts +8 -5
  99. package/dist-lib/lib/core/files/index.js +111 -18
  100. package/dist-lib/lib/core/files/processing/index.d.ts +1 -1
  101. package/dist-lib/lib/core/files/processing/index.js +8 -2
  102. package/dist-lib/lib/core/files/processing/source.d.ts +1 -0
  103. package/dist-lib/lib/core/files/processing/source.js +3 -0
  104. package/dist-lib/lib/core/files/processing/state.d.ts +1 -0
  105. package/dist-lib/lib/core/files/processing/state.js +7 -0
  106. package/dist-lib/lib/core/files/rag/build.d.ts +1 -0
  107. package/dist-lib/lib/core/files/rag/build.js +14 -1
  108. package/dist-lib/lib/core/files/rag/index.d.ts +1 -1
  109. package/dist-lib/lib/core/files/rag/index.js +1 -1
  110. package/dist-lib/lib/core/files/rag/produce.js +1 -0
  111. package/dist-lib/lib/core/files/rag/retrieval/full-text.d.ts +2 -0
  112. package/dist-lib/lib/core/files/rag/retrieval/full-text.js +7 -1
  113. package/dist-lib/lib/core/first-event.d.ts +6 -0
  114. package/dist-lib/lib/core/first-event.js +13 -0
  115. package/dist-lib/lib/core/invite.d.ts +2 -2
  116. package/dist-lib/lib/core/invite.js +5 -4
  117. package/dist-lib/lib/core/local/index.d.ts +16 -1
  118. package/dist-lib/lib/core/local/index.js +119 -10
  119. package/dist-lib/lib/core/mesh.d.ts +14 -3
  120. package/dist-lib/lib/core/mesh.js +127 -54
  121. package/dist-lib/lib/core/migrations/chat-chunks.d.ts +4 -0
  122. package/dist-lib/lib/core/migrations/chat-chunks.js +47 -0
  123. package/dist-lib/lib/core/migrations/file-index.d.ts +1 -1
  124. package/dist-lib/lib/core/migrations/file-index.js +6 -2
  125. package/dist-lib/lib/core/migrations/index.d.ts +2 -1
  126. package/dist-lib/lib/core/migrations/index.js +66 -9
  127. package/dist-lib/lib/core/notification.js +96 -23
  128. package/dist-lib/lib/core/pdf/figure.d.ts +22 -0
  129. package/dist-lib/lib/core/pdf/figure.js +64 -0
  130. package/dist-lib/lib/core/pdf/rasterize.d.ts +10 -1
  131. package/dist-lib/lib/core/pdf/rasterize.js +72 -22
  132. package/dist-lib/lib/core/peer-duplex.js +57 -5
  133. package/dist-lib/lib/core/public-mesh.js +8 -2
  134. package/dist-lib/lib/core/run-requests.js +2 -3
  135. package/dist-lib/lib/core/senders.d.ts +7 -6
  136. package/dist-lib/lib/core/senders.js +23 -30
  137. package/dist-lib/lib/core/shared-agents.d.ts +1 -0
  138. package/dist-lib/lib/core/shared-agents.js +47 -19
  139. package/dist-lib/lib/core/skill-secrets.d.ts +3 -2
  140. package/dist-lib/lib/core/skill-secrets.js +4 -1
  141. package/dist-lib/lib/core/sync/background.d.ts +3 -15
  142. package/dist-lib/lib/core/sync/background.js +25 -102
  143. package/dist-lib/lib/core/sync/devices.js +6 -3
  144. package/dist-lib/lib/core/sync/index.js +25 -3
  145. package/dist-lib/lib/core/sync-status.js +3 -3
  146. package/dist-lib/lib/core/vault-managed-skills.d.ts +18 -0
  147. package/dist-lib/lib/core/vault-managed-skills.js +105 -0
  148. package/dist-lib/lib/core.d.ts +66 -10
  149. package/dist-lib/lib/core.js +768 -179
  150. package/dist-lib/lib/credential-pusher.d.ts +11 -7
  151. package/dist-lib/lib/credential-pusher.js +40 -8
  152. package/dist-lib/lib/device-tree.d.ts +18 -0
  153. package/dist-lib/lib/device-tree.js +32 -0
  154. package/dist-lib/lib/doctor/redact.js +1 -1
  155. package/dist-lib/lib/errors.d.ts +12 -0
  156. package/dist-lib/lib/errors.js +12 -0
  157. package/dist-lib/lib/fs-drive-bridge.d.ts +7 -0
  158. package/dist-lib/lib/fs-drive-bridge.js +308 -30
  159. package/dist-lib/lib/integrations/setup-routes.js +7 -5
  160. package/dist-lib/lib/knowledge-search.d.ts +1 -1
  161. package/dist-lib/lib/knowledge-search.js +5 -46
  162. package/dist-lib/lib/kv-cache-retention.d.ts +35 -0
  163. package/dist-lib/lib/kv-cache-retention.js +98 -0
  164. package/dist-lib/lib/latest-frame.d.ts +10 -0
  165. package/dist-lib/lib/latest-frame.js +48 -0
  166. package/dist-lib/lib/mesh-scoped-engine.js +1 -0
  167. package/dist-lib/lib/model-download.d.ts +6 -1
  168. package/dist-lib/lib/model-download.js +32 -17
  169. package/dist-lib/lib/oauth/resolve.js +13 -5
  170. package/dist-lib/lib/reconnecting-watch.js +19 -11
  171. package/dist-lib/lib/run-notices.d.ts +2 -0
  172. package/dist-lib/lib/run-notices.js +5 -0
  173. package/dist-lib/lib/run-replay.d.ts +13 -1
  174. package/dist-lib/lib/run-replay.js +58 -21
  175. package/dist-lib/schema/build.js +66 -57
  176. package/dist-lib/schema/config.d.ts +1 -1
  177. package/dist-lib/schema/config.js +1 -1
  178. package/dist-lib/schema/content.js +2 -1
  179. package/dist-lib/schema/engine.js +70 -6
  180. package/dist-lib/schema/field-order.js +7 -1
  181. package/dist-lib/schema/indexes.d.ts +4 -0
  182. package/dist-lib/schema/indexes.js +18 -0
  183. package/dist-lib/schema/local.js +9 -2
  184. package/dist-lib/schema/qvac.js +116 -6
  185. package/dist-lib/spec/bind.js +15 -0
  186. package/dist-lib/spec/calls.js +5 -0
  187. package/dist-lib/spec/capabilities.d.ts +10 -0
  188. package/dist-lib/spec/config/hyperconf/index.js +1 -1
  189. package/dist-lib/spec/hrpc/hrpc.json +65 -0
  190. package/dist-lib/spec/hrpc/index.js +63 -3
  191. package/dist-lib/spec/hrpc/messages.js +1537 -1395
  192. package/dist-lib/spec/hyperschema/index.js +1537 -1395
  193. package/dist-lib/spec/hyperschema/schema.json +126 -1
  194. package/dist-lib/spec/hyperschema/types.d.ts +33 -1
  195. package/dist-lib/spec/local/hyperdb/messages.js +110 -54
  196. package/dist-lib/spec/local/hyperschema/index.js +56 -28
  197. package/dist-lib/spec/local/hyperschema/schema.json +55 -20
  198. package/dist-lib/spec/local/hyperschema/types.d.ts +8 -1
  199. package/dist-lib/spec/mesh/hyperdb/db.json +255 -51
  200. package/dist-lib/spec/mesh/hyperdb/index.js +1063 -404
  201. package/dist-lib/spec/mesh/hyperdb/messages.js +1673 -1202
  202. package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +62 -56
  203. package/dist-lib/spec/mesh/hyperdispatch/index.js +156 -139
  204. package/dist-lib/spec/mesh/hyperdispatch/messages.js +809 -632
  205. package/dist-lib/spec/mesh/hyperschema/index.js +809 -632
  206. package/dist-lib/spec/mesh/hyperschema/schema.json +293 -174
  207. package/dist-lib/spec/mesh/hyperschema/types.d.ts +31 -1
  208. package/package.json +32 -26
  209. package/worker/assistant-sidecar.mjs +3 -0
  210. package/dist-lib/lib/core/files/processing/settle.d.ts +0 -13
  211. package/dist-lib/lib/core/files/processing/settle.js +0 -86
  212. package/dist-lib/lib/core/migrations/device-indexes.d.ts +0 -2
  213. package/dist-lib/lib/core/migrations/device-indexes.js +0 -7
@@ -1,6 +1,6 @@
1
1
  import { CoreError } from '../../errors.js';
2
2
  import { linkAttachment } from '../attachment-link.js';
3
- import { getChunk, updateChunk } from '../chunk.js';
3
+ import { getChunk, readChunk, updateChunk } from '../chunk.js';
4
4
  import { uploadFile } from './upload.js';
5
5
  import b4a from 'b4a';
6
6
  export const MAX_ATTACHMENT_BYTES = 100 * 1024 * 1024;
@@ -39,7 +39,7 @@ export function attachmentFiles(mesh, { maxBytes = MAX_ATTACHMENT_BYTES, deviceI
39
39
  }
40
40
  const attachment = chunk.attachment;
41
41
  if (attachment.deletedAt) {
42
- return chunk;
42
+ return readChunk(chunk);
43
43
  }
44
44
  const updated = await updateChunk(mesh, {
45
45
  id: chunkId,
@@ -48,7 +48,7 @@ export function attachmentFiles(mesh, { maxBytes = MAX_ATTACHMENT_BYTES, deviceI
48
48
  if (!updated.attachment?.deletedAt) {
49
49
  throw new CoreError('ATTACHMENT_DELETE_DROPPED');
50
50
  }
51
- return updated;
51
+ return readChunk(updated);
52
52
  }
53
53
  };
54
54
  }
@@ -1,6 +1,6 @@
1
1
  import type { AbortSignal } from 'bare-abort-controller';
2
2
  import EventEmitter from 'bare-events';
3
- import type { AssistantFileStatusList, AssistantFileReadRequest, AssistantFileReadFrame, AssistantFilePreviewResponse, AssistantIndexingStatusList, AssistantKnowledgeBaseList } from '../../../spec/hyperschema/types.d.ts';
3
+ import type { AssistantFileStatus, AssistantFileStatusList, AssistantFileReadRequest, AssistantFileReadFrame, AssistantFilePreviewResponse, AssistantIndexingStatusList, AssistantKnowledgeBaseList } from '../../../spec/hyperschema/types.d.ts';
4
4
  import type { QvacChunk, QvacKnowledge, QvacKnowledgeArtifact } from '../../../spec/mesh/hyperschema/types.d.ts';
5
5
  import { attachmentFiles } from './attachments.ts';
6
6
  import { addKnowledgeArtifact, type FileRecord } from './records/index.ts';
@@ -11,8 +11,7 @@ import { BlobStore } from './store/index.ts';
11
11
  import { type IndexingDevice, type IndexingProgress, type IndexingEmbedder, type RagExtractors, type VectorIndex } from './rag/index.ts';
12
12
  import type { Mesh } from '../mesh.ts';
13
13
  import type { ChatFileKey } from './records/source.ts';
14
- import type { SettleOptions } from './processing/settle.ts';
15
- export { fullTextBudgetChars, fullTextHits, joinedIndex, retrieveRagKnowledge, searchRagChunks, referencesPendingFile, type VectorHit, type RagDocumentRef } from './rag/index.ts';
14
+ export { fullTextBudgetChars, fullTextHits, joinedIndex, retrievalBudgetTokens, retrieveRagKnowledge, searchRagChunks, referencesPendingFile, type VectorHit, type RagDocumentRef } from './rag/index.ts';
16
15
  export { isKnowledgeRoutedAttachment } from './records/index.ts';
17
16
  export { assertRemovableAt } from './records/index.ts';
18
17
  export { assertArtifactOutput } from './records/index.ts';
@@ -115,7 +114,11 @@ export declare class Files extends EventEmitter {
115
114
  load(id: string, state: LocalWork, options?: FileLoadOptions): void;
116
115
  clearLoaded(processorId?: string): void;
117
116
  hydratedArtifact(id: string): string | null;
118
- settle(ids: string[], options?: SettleOptions): Promise<void>;
117
+ ready(chatId: string, ids: string[]): Promise<AssistantFileStatusList>;
118
+ indexingHere(chatId: string, ids: string[]): Promise<void>;
119
+ indexesHere(file: AssistantFileStatus): boolean;
120
+ private _until;
121
+ private _changes;
119
122
  reconnect(): void;
120
123
  report: (update: Parameters<IndexingProgress>[0], processorId?: string) => void;
121
124
  progress(chatId: string): import("./processing/state.ts").ChatProgressEntry[];
@@ -131,7 +134,7 @@ export declare class Files extends EventEmitter {
131
134
  private _processorStatus;
132
135
  close(): Promise<void>;
133
136
  }
134
- export { MemoryVectorIndex, RAG_KNOWLEDGE_OFF_NOTICE, RAG_TRUNCATED_NOTICE, RAG_UNAVAILABLE_NOTICE, WEB_TOOLS, chooseRagNotice, citedByPhraseOverlap, createRagSourceTagFilter, formatFullDocumentContext, formatRagContext, isFullTextHit, isWholeDocumentQuery, referencedDocuments, isTruncatedFullTextHit, sourcesFromHits, webSourcesFromToolResult, withoutDataChannel } from './rag/index.ts';
137
+ export { MemoryVectorIndex, RAG_KNOWLEDGE_OFF_NOTICE, RAG_TRUNCATED_NOTICE, RAG_UNAVAILABLE_NOTICE, WEB_TOOLS, chooseRagNotice, citedByPhraseOverlap, createRagSourceTagFilter, formatFullDocumentContext, formatRagContext, fullTextAttachmentId, isFullTextHit, isWholeDocumentQuery, referencedDocuments, isTruncatedFullTextHit, sourcesFromHits, webSourcesFromToolResult, withoutDataChannel } from './rag/index.ts';
135
138
  export type { IndexingDevice, IndexingEmbedder, RagExtractors, RagSource, VectorIndex } from './rag/index.ts';
136
139
  export { attachTurnDocumentIds, groupAttachmentsByMessage } from './records/index.ts';
137
140
  export { CoreBlobServer, PENDING_BLOB_REFERENCE, isPendingBlobReference, parseBlobReferenceCoreKey } from './store/index.ts';
@@ -1,14 +1,16 @@
1
1
  import b4a from 'b4a';
2
2
  import EventEmitter from 'bare-events';
3
+ import { Readable } from 'streamx';
3
4
  import { attachmentFiles } from './attachments.js';
4
5
  import { isKnowledgeRoutedAttachment, getKnowledge, listKnowledge, getKnowledgeArtifact, listKnowledgeArtifactsByKnowledge, addKnowledgeArtifact, hasLiveSource, syncAttachmentChunk, syncKnowledgeTombstone, syncArtifactArrival, sweepTombstonedBlobs, reclaimPurgedFiles, referencedBlobs, scopedFile, attachmentRecord, isProcessorOutput, isProcessorArtifactId, knowledgeCapBytes, usedKnowledgeBytes } from './records/index.js';
5
6
  import { knowledgeFiles } from './knowledge.js';
6
7
  import { randomId } from '../id.js';
7
8
  import { findChunksOfType, getChunk, listChunks } from '../chunk.js';
8
- import { settleFiles, isClaimLive, listIndexingByChat, listIndexingByKnowledge, FileState, FileProcessing } from './processing/index.js';
9
+ import { isClaimLive, listIndexingByChat, listIndexingByKnowledge, FileState, FileProcessing } from './processing/index.js';
9
10
  import { DeadlineScheduler } from '../../deadline.js';
10
11
  import { liveDeviceForWriter } from '../contract/activity.js';
11
12
  import { runDefinition } from '../shared-agents.js';
13
+ import { toolsetEnabled } from '@qvac/harness/lib/tools/toolsets.ts';
12
14
  import { BlobStore, parseBlobReference } from './store/index.js';
13
15
  import { AbortedError } from '@qvac/harness/race-abort';
14
16
  import { RagProcessor } from './rag/index.js';
@@ -17,7 +19,7 @@ import { parseFailure } from './rag/failure.js';
17
19
  import { CoreError } from '../../errors.js';
18
20
  import { errorMessage } from '../../guards.js';
19
21
  import { ACTIVE_KNOWLEDGE_BASE, ACTIVE_KNOWLEDGE_BY_CHAT, AGENTS, CHATS, INDEXING_STATUS_BY_CHAT, INDEXING_STATUS_BY_KNOWLEDGE, KNOWLEDGE, KNOWLEDGE_ARTIFACTS_BY_KNOWLEDGE } from '../collections.js';
20
- export { fullTextBudgetChars, fullTextHits, joinedIndex, retrieveRagKnowledge, searchRagChunks, referencesPendingFile } from './rag/index.js';
22
+ export { fullTextBudgetChars, fullTextHits, joinedIndex, retrievalBudgetTokens, retrieveRagKnowledge, searchRagChunks, referencesPendingFile } from './rag/index.js';
21
23
  export { isKnowledgeRoutedAttachment } from './records/index.js';
22
24
  export { assertRemovableAt } from './records/index.js';
23
25
  export { assertArtifactOutput } from './records/index.js';
@@ -395,18 +397,83 @@ export class Files extends EventEmitter {
395
397
  hydratedArtifact(id) {
396
398
  return this.state.get(id)?.loaded?.artifactId ?? null;
397
399
  }
398
- async settle(ids, options = {}) {
399
- if (!this._processing)
400
- return;
401
- await settleFiles(this, {
402
- ...options,
403
- ids,
404
- processing: this._processing,
405
- chatIds: async () => {
406
- const rows = await Promise.all(ids.map((id) => getKnowledge(this._mesh, id)));
407
- return [...new Set(rows.flatMap((row) => (row?.chatId ? [row.chatId] : [])))];
400
+ ready(chatId, ids) {
401
+ const wanted = new Set(ids);
402
+ this._processing?.prioritize(ids);
403
+ return this._until(chatId, (all) => {
404
+ const files = all.filter((file) => wanted.has(file.fileId));
405
+ return files.every(settledFile) ? files : null;
406
+ });
407
+ }
408
+ async indexingHere(chatId, ids) {
409
+ const wanted = new Set(ids);
410
+ this._processing?.prioritize(ids);
411
+ await this._until(chatId, (files) => files.some((file) => wanted.has(file.fileId) && this.indexesHere(file)) ? null : files);
412
+ }
413
+ indexesHere(file) {
414
+ const rag = file.processors.find((entry) => entry.processorId === 'rag');
415
+ if (!this._processing?.active || settledFile(file) || rag?.state === 'not-applicable') {
416
+ return false;
417
+ }
418
+ if (this._processing.awaitsBytes(file.fileId)) {
419
+ return false;
420
+ }
421
+ if (rag?.claimedBy) {
422
+ return b4a.equals(rag.claimedBy, this._mesh.localWriterKey);
423
+ }
424
+ return this._processing.pending(file.fileId);
425
+ }
426
+ async _until(chatId, settle) {
427
+ let all = [];
428
+ for await (const _ of this._changes()) {
429
+ all = (await this.status(chatId)).files;
430
+ const files = settle(all);
431
+ if (files || this.closed) {
432
+ return { files: files ?? all };
433
+ }
434
+ }
435
+ return { files: all };
436
+ }
437
+ _changes() {
438
+ let due = true;
439
+ let pending = null;
440
+ const deliver = () => {
441
+ const cb = pending;
442
+ if (!due || !cb) {
443
+ return;
444
+ }
445
+ due = false;
446
+ pending = null;
447
+ changes.push(true);
448
+ cb(null);
449
+ };
450
+ const onUpdate = () => {
451
+ due = true;
452
+ deliver();
453
+ };
454
+ const onClose = () => {
455
+ changes.push(true);
456
+ changes.push(null);
457
+ pending?.(null);
458
+ };
459
+ const changes = new Readable({
460
+ read(cb) {
461
+ pending = cb;
462
+ deliver();
463
+ },
464
+ predestroy() {
465
+ pending?.(null);
466
+ pending = null;
467
+ },
468
+ destroy: (cb) => {
469
+ this.unwatch(onUpdate);
470
+ this.off('close', onClose);
471
+ cb(null);
408
472
  }
409
473
  });
474
+ this.watch(onUpdate);
475
+ this.once('close', onClose);
476
+ return changes;
410
477
  }
411
478
  reconnect() {
412
479
  for (const { work } of this._processors.values()) {
@@ -529,9 +596,11 @@ export class Files extends EventEmitter {
529
596
  return { files: [] };
530
597
  }
531
598
  const agent = await runDefinition(this._mesh, await snap.get(AGENTS, { id: chat.agentId }));
599
+ const knowledgeOn = toolsetEnabled('knowledge', agent?.disabledToolsets);
532
600
  const knowledge = await snap.find(ACTIVE_KNOWLEDGE_BY_CHAT, range).toArray();
533
601
  const chunks = await findChunksOfType(snap, { chatId, type: 'attachment' });
534
602
  const statuses = await snap.find(INDEXING_STATUS_BY_CHAT, range).toArray();
603
+ const statusesByKnowledge = groupBy(statuses, (row) => row.knowledgeId);
535
604
  const sources = new Map(knowledge.map((row) => [row.id, row]));
536
605
  const ragIds = new Set(sources.keys());
537
606
  for (const chunk of chunks) {
@@ -565,12 +634,12 @@ export class Files extends EventEmitter {
565
634
  lte: { knowledgeId: id }
566
635
  })
567
636
  .toArray();
568
- const applicable = ragIds.has(id);
637
+ const applicable = knowledgeOn && ragIds.has(id);
569
638
  const local = this.state.get(id);
570
639
  const output = rows.find((row) => !isProcessorOutput(row.embedderVersion) &&
571
640
  (!this._model || row.embedderVersion.startsWith(`${this._model}|`)));
572
641
  const published = !!output;
573
- const attempts = statuses.filter((row) => row.knowledgeId === id && !isProcessorArtifactId(row.id));
642
+ const attempts = (statusesByKnowledge.get(id) ?? []).filter((row) => !isProcessorArtifactId(row.id));
574
643
  const claim = attempts.find((row) => isClaimLive(row, Date.now()));
575
644
  const failures = attempts.some((row) => row.status === 'ready')
576
645
  ? []
@@ -585,6 +654,7 @@ export class Files extends EventEmitter {
585
654
  processor.outputId = local?.loaded?.artifactId ?? output?.id;
586
655
  if (!applicable) {
587
656
  processor.state = 'not-applicable';
657
+ processor.reason = ragIds.has(id) ? 'knowledge off' : undefined;
588
658
  }
589
659
  else if (local?.loaded) {
590
660
  processor.state = 'ready';
@@ -625,7 +695,12 @@ export class Files extends EventEmitter {
625
695
  : await this._store.available(source.blobId);
626
696
  const processors = [
627
697
  processor,
628
- ...(await this._extraProcessorStatuses(id, { chunks, knowledge, rows, statuses }))
698
+ ...(await this._extraProcessorStatuses(id, {
699
+ chunks,
700
+ knowledge,
701
+ rows,
702
+ statusesByKnowledge
703
+ }))
629
704
  ];
630
705
  const uploadProgress = this._uploads.get(id)?.status.uploadProgress;
631
706
  result.set(id, {
@@ -655,7 +730,7 @@ export class Files extends EventEmitter {
655
730
  processor.agentId = agent.id;
656
731
  }
657
732
  }
658
- async _extraProcessorStatuses(id, { chunks, knowledge, rows, statuses }) {
733
+ async _extraProcessorStatuses(id, { chunks, knowledge, rows, statusesByKnowledge }) {
659
734
  const processors = [];
660
735
  for (const { processor: descriptor } of this._processors.values()) {
661
736
  if (descriptor.id === 'rag')
@@ -667,7 +742,10 @@ export class Files extends EventEmitter {
667
742
  const input = record ? { ...record, kind: descriptor.input } : null;
668
743
  processors.push(!input || !descriptor.applies(input)
669
744
  ? { processorId: descriptor.id, state: 'not-applicable', published: false }
670
- : await this._processorStatus(descriptor, input, { rows, attempts: statuses }));
745
+ : await this._processorStatus(descriptor, input, {
746
+ rows,
747
+ attempts: statusesByKnowledge.get(id) ?? []
748
+ }));
671
749
  }
672
750
  return processors;
673
751
  }
@@ -719,6 +797,9 @@ export class Files extends EventEmitter {
719
797
  await this._store.close();
720
798
  }
721
799
  }
800
+ function settledFile(file) {
801
+ return file.readyForChat || file.state === 'failed';
802
+ }
722
803
  function yieldsToVerdict(work) {
723
804
  return work.state === 'pending' || (work.state === 'failed' && work.retryAt === undefined);
724
805
  }
@@ -731,6 +812,18 @@ function fileState(processor, opts) {
731
812
  }
732
813
  return { state: 'pending', reason: 'source unavailable on this device' };
733
814
  }
734
- export { MemoryVectorIndex, RAG_KNOWLEDGE_OFF_NOTICE, RAG_TRUNCATED_NOTICE, RAG_UNAVAILABLE_NOTICE, WEB_TOOLS, chooseRagNotice, citedByPhraseOverlap, createRagSourceTagFilter, formatFullDocumentContext, formatRagContext, isFullTextHit, isWholeDocumentQuery, referencedDocuments, isTruncatedFullTextHit, sourcesFromHits, webSourcesFromToolResult, withoutDataChannel } from './rag/index.js';
815
+ function groupBy(items, key) {
816
+ const groups = new Map();
817
+ for (const item of items) {
818
+ const id = key(item);
819
+ let group = groups.get(id);
820
+ if (!group) {
821
+ groups.set(id, (group = []));
822
+ }
823
+ group.push(item);
824
+ }
825
+ return groups;
826
+ }
827
+ export { MemoryVectorIndex, RAG_KNOWLEDGE_OFF_NOTICE, RAG_TRUNCATED_NOTICE, RAG_UNAVAILABLE_NOTICE, WEB_TOOLS, chooseRagNotice, citedByPhraseOverlap, createRagSourceTagFilter, formatFullDocumentContext, formatRagContext, fullTextAttachmentId, isFullTextHit, isWholeDocumentQuery, referencedDocuments, isTruncatedFullTextHit, sourcesFromHits, webSourcesFromToolResult, withoutDataChannel } from './rag/index.js';
735
828
  export { attachTurnDocumentIds, groupAttachmentsByMessage } from './records/index.js';
736
829
  export { CoreBlobServer, PENDING_BLOB_REFERENCE, isPendingBlobReference, parseBlobReferenceCoreKey } from './store/index.js';
@@ -67,6 +67,7 @@ export declare class FileProcessing {
67
67
  private _enqueue;
68
68
  get active(): boolean;
69
69
  pending(id: string): boolean;
70
+ awaitsBytes(id: string): boolean;
70
71
  prioritize(ids: string[]): void;
71
72
  private _shutdown;
72
73
  private _stop;
@@ -85,4 +86,3 @@ export type { FileDocument } from './document.ts';
85
86
  export { isClaimLive, listIndexingByChat, listIndexingByKnowledge } from './protocol.ts';
86
87
  export { FileState } from './state.ts';
87
88
  export type { IndexingProgressEntry, LocalWork } from './state.ts';
88
- export { settleFiles } from './settle.ts';
@@ -130,12 +130,19 @@ export class FileProcessing {
130
130
  this._source.pending((key) => key === id) ||
131
131
  this._output.pending((key) => this._mesh.files.processorState(this._processor.id).artifact(key).knowledgeId === id)));
132
132
  }
133
+ awaitsBytes(id) {
134
+ return (this._source.awaitsBytes((key) => key === id) ||
135
+ this._output.awaitsBytes((key) => this._mesh.files.processorState(this._processor.id).artifact(key).knowledgeId === id));
136
+ }
133
137
  prioritize(ids) {
134
138
  for (const lane of this._lanes) {
135
139
  const queued = new Map(lane.queue);
136
140
  lane.queue.clear();
137
141
  for (const id of ids) {
138
- lane.queue.set(id, queued.get(id) ?? []);
142
+ const wakes = queued.get(id);
143
+ if (wakes) {
144
+ lane.queue.set(id, wakes);
145
+ }
139
146
  }
140
147
  for (const [id, wakes] of queued) {
141
148
  if (!lane.queue.has(id)) {
@@ -349,4 +356,3 @@ export class FileProcessing {
349
356
  }
350
357
  export { isClaimLive, listIndexingByChat, listIndexingByKnowledge } from './protocol.js';
351
358
  export { FileState } from './state.js';
352
- export { settleFiles } from './settle.js';
@@ -35,5 +35,6 @@ export declare class IndexingSource {
35
35
  read(id: string, blobRef: string, signal?: AbortSignal): Promise<SourceRead>;
36
36
  cancel(matches?: (id: string) => boolean): Promise<void>;
37
37
  pending(matches: (id: string) => boolean): boolean;
38
+ awaitsBytes(matches: (id: string) => boolean): boolean;
38
39
  private _fetch;
39
40
  }
@@ -70,6 +70,9 @@ export class IndexingSource {
70
70
  }
71
71
  return false;
72
72
  }
73
+ awaitsBytes(matches) {
74
+ return this.pending(matches) || this.retry.missing(matches);
75
+ }
73
76
  _fetch(id, reference) {
74
77
  const download = this._download;
75
78
  if (!download) {
@@ -45,6 +45,7 @@ export declare class FileRetries {
45
45
  blockedUntil(id: string, now: number): number | null;
46
46
  miss(id: string, now: number, retryMs: number): number;
47
47
  markMissing(id: string): void;
48
+ missing(matches: (id: string) => boolean): boolean;
48
49
  markFound(id: string): void;
49
50
  clear(id?: string): void;
50
51
  reconnect(onRetry?: (id: string, deadline: number) => void): number | null;
@@ -15,6 +15,13 @@ export class FileRetries {
15
15
  markMissing(id) {
16
16
  this._missing.add(id);
17
17
  }
18
+ missing(matches) {
19
+ for (const id of this._missing) {
20
+ if (matches(id))
21
+ return true;
22
+ }
23
+ return false;
24
+ }
18
25
  markFound(id) {
19
26
  this._missing.delete(id);
20
27
  }
@@ -20,6 +20,7 @@ export interface ArtifactBuildInput {
20
20
  bytes: Buffer;
21
21
  signal: AbortSignal;
22
22
  onProgress?: BuildProgress;
23
+ onExtracting?: (pages: number, totalPages: number) => Promise<void>;
23
24
  onExtracted?: () => void | Promise<void>;
24
25
  extractors?: RagExtractors;
25
26
  }
@@ -15,8 +15,19 @@ export async function yieldTurn(signal) {
15
15
  throw new AbortedError();
16
16
  }
17
17
  }
18
+ function pageProgress(onExtracting) {
19
+ let chain = Promise.resolve();
20
+ return {
21
+ report: ({ pages, total }) => {
22
+ chain = chain.then(() => onExtracting?.(pages, total));
23
+ chain.catch(noop);
24
+ },
25
+ settled: () => chain
26
+ };
27
+ }
18
28
  export async function buildArtifactPayload(input) {
19
29
  const { embedder, knowledge, artifactId, bytes, signal, onProgress, onExtracted, extractors } = input;
30
+ const pages = pageProgress(input.onExtracting);
20
31
  const document = await extractRagDocumentFromBytes({
21
32
  id: artifactId,
22
33
  artifactId,
@@ -26,7 +37,8 @@ export async function buildArtifactPayload(input) {
26
37
  fileName: knowledge.fileName,
27
38
  mimeType: knowledge.mimeType,
28
39
  bytes
29
- }, { extractors, signal });
40
+ }, { extractors, signal, onProgress: pages.report });
41
+ await pages.settled();
30
42
  await yieldTurn(signal);
31
43
  await onExtracted?.();
32
44
  const chunks = chunkRagDocuments([document], {});
@@ -69,3 +81,4 @@ export async function buildArtifactPayload(input) {
69
81
  }))
70
82
  };
71
83
  }
84
+ function noop() { }
@@ -39,6 +39,6 @@ export { joinedIndex } from './joined-index.ts';
39
39
  export { canIndexKnowledge } from './policy.ts';
40
40
  export type { IndexingDevice } from './policy.ts';
41
41
  export type { IndexingEmbedder, IndexingProgress } from './produce.ts';
42
- export { formatFullDocumentContext, fullTextBudgetChars, fullTextHits, isFullTextHit, isTruncatedFullTextHit } from './retrieval/full-text.ts';
42
+ export { formatFullDocumentContext, fullTextBudgetChars, fullTextHits, fullTextAttachmentId, isFullTextHit, isTruncatedFullTextHit, retrievalBudgetTokens } from './retrieval/full-text.ts';
43
43
  export { MemoryVectorIndex, RAG_DOCUMENT_KIND, RAG_KNOWLEDGE_OFF_NOTICE, RAG_TRUNCATED_NOTICE, RAG_UNAVAILABLE_NOTICE, WEB_TOOLS, chooseRagNotice, citedByPhraseOverlap, classifyRagDocument, createRagSourceTagFilter, encodeRagArtifact, formatRagContext, isSupportedRagDocument, isWholeDocumentQuery, referencedDocuments, referencesPendingFile, retrieveRagKnowledge, searchRagChunks, sourcesFromHits, webSourcesFromToolResult, withoutDataChannel } from 'rag-extract';
44
44
  export type { RagArtifactPayload, RagDocumentRef, RagExtractors, RagSource, VectorHit, VectorIndex } from 'rag-extract';
@@ -90,5 +90,5 @@ export class RagProcessor {
90
90
  export { MAX_KNOWLEDGE_BYTES } from './limits.js';
91
91
  export { joinedIndex } from './joined-index.js';
92
92
  export { canIndexKnowledge } from './policy.js';
93
- export { formatFullDocumentContext, fullTextBudgetChars, fullTextHits, isFullTextHit, isTruncatedFullTextHit } from './retrieval/full-text.js';
93
+ export { formatFullDocumentContext, fullTextBudgetChars, fullTextHits, fullTextAttachmentId, isFullTextHit, isTruncatedFullTextHit, retrievalBudgetTokens } from './retrieval/full-text.js';
94
94
  export { MemoryVectorIndex, RAG_DOCUMENT_KIND, RAG_KNOWLEDGE_OFF_NOTICE, RAG_TRUNCATED_NOTICE, RAG_UNAVAILABLE_NOTICE, WEB_TOOLS, chooseRagNotice, citedByPhraseOverlap, classifyRagDocument, createRagSourceTagFilter, encodeRagArtifact, formatRagContext, isSupportedRagDocument, isWholeDocumentQuery, referencedDocuments, referencesPendingFile, retrieveRagKnowledge, searchRagChunks, sourcesFromHits, webSourcesFromToolResult, withoutDataChannel } from 'rag-extract';
@@ -134,6 +134,7 @@ export class IndexingPass {
134
134
  artifactId,
135
135
  bytes,
136
136
  signal,
137
+ onExtracting: (pages) => lease.keep(pages === 1),
137
138
  onExtracted: async () => {
138
139
  document.admit();
139
140
  await lease.keep(true);
@@ -2,10 +2,12 @@ import type { QvacKnowledge } from '../../../../../spec/mesh/hyperschema/types.d
2
2
  import type { Mesh } from '../../../mesh.ts';
3
3
  import { type VectorHit } from 'rag-extract';
4
4
  export declare function fullTextBudgetChars(ctxSize: number): number;
5
+ export declare function retrievalBudgetTokens(ctxSize: number): number | undefined;
5
6
  export interface IdentifiedHit {
6
7
  readonly id: string;
7
8
  }
8
9
  export declare function isFullTextHit(hit: IdentifiedHit): boolean;
10
+ export declare function fullTextAttachmentId(hit: IdentifiedHit): string | null;
9
11
  export type FullTextCoverage = {
10
12
  readonly unit: 'pages';
11
13
  readonly included: number;
@@ -1,5 +1,5 @@
1
1
  import * as z from 'zod';
2
- import { classifyRagDocument, extractPdfHead, extractRagDocumentFromBytes, parseRagMetadata, RAG_DOCUMENT_KIND } from 'rag-extract';
2
+ import { classifyRagDocument, DEFAULT_CHUNK_BUDGET_TOKENS, extractPdfHead, extractRagDocumentFromBytes, parseRagMetadata, RAG_DOCUMENT_KIND } from 'rag-extract';
3
3
  const DEFAULT_FULL_TEXT_BUDGET_TOKENS = 4096;
4
4
  const CHARS_PER_TOKEN = 4;
5
5
  const FULL_TEXT_KINDS = new Set([
@@ -14,10 +14,16 @@ export function fullTextBudgetChars(ctxSize) {
14
14
  const tokens = ctxSize > 0 ? Math.floor(ctxSize / 2) : DEFAULT_FULL_TEXT_BUDGET_TOKENS;
15
15
  return tokens * CHARS_PER_TOKEN;
16
16
  }
17
+ export function retrievalBudgetTokens(ctxSize) {
18
+ return ctxSize > 0 ? Math.min(DEFAULT_CHUNK_BUDGET_TOKENS, Math.floor(ctxSize / 4)) : undefined;
19
+ }
17
20
  const FULL_TEXT_HIT_PREFIX = 'full-text-';
18
21
  export function isFullTextHit(hit) {
19
22
  return hit.id.startsWith(FULL_TEXT_HIT_PREFIX);
20
23
  }
24
+ export function fullTextAttachmentId(hit) {
25
+ return isFullTextHit(hit) ? hit.id.slice(FULL_TEXT_HIT_PREFIX.length) : null;
26
+ }
21
27
  const FullTextExtrasSchema = z.object({
22
28
  truncated: z.boolean().optional().catch(undefined),
23
29
  coverage: z
@@ -0,0 +1,6 @@
1
+ interface Emitter {
2
+ once(name: string, listener: () => void): unknown;
3
+ off(name: string, listener: () => void): unknown;
4
+ }
5
+ export declare function firstEvent(sources: ReadonlyArray<readonly [Emitter, string]>): Promise<void>;
6
+ export {};
@@ -0,0 +1,13 @@
1
+ export function firstEvent(sources) {
2
+ return new Promise((resolve) => {
3
+ const done = () => {
4
+ for (const [emitter, name] of sources) {
5
+ emitter.off(name, done);
6
+ }
7
+ resolve();
8
+ };
9
+ for (const [emitter, name] of sources) {
10
+ emitter.once(name, done);
11
+ }
12
+ });
13
+ }
@@ -1,4 +1,4 @@
1
- import type { QvacAutobeeHead } from '../../spec/mesh/hyperschema/types.d.ts';
1
+ import type { QvacAutobeeHead, QvacInvitePublicHead } from '../../spec/mesh/hyperschema/types.d.ts';
2
2
  import type { RecoveryProof } from './mesh.ts';
3
3
  export interface MeshInviteNode {
4
4
  readonly host: string;
@@ -13,13 +13,13 @@ export interface MeshInvite {
13
13
  readonly memberInvite?: boolean;
14
14
  readonly memberId?: Buffer;
15
15
  readonly inviteNonce?: Buffer;
16
- readonly compute?: boolean;
17
16
  readonly recovery?: RecoveryProof;
18
17
  readonly inviterName?: string;
19
18
  readonly deviceSeed?: Buffer;
20
19
  readonly deviceProof?: Buffer;
21
20
  readonly workspace?: boolean;
22
21
  readonly workspaceName?: string;
22
+ readonly publicHeads?: ReadonlyArray<QvacInvitePublicHead>;
23
23
  }
24
24
  export declare function encodeMeshInvite(invite: MeshInvite): string;
25
25
  export declare function decodeMeshInvite(raw: string): MeshInvite | null;
@@ -15,12 +15,13 @@ export function encodeMeshInvite(invite) {
15
15
  memberInvite: invite.memberInvite ?? false,
16
16
  memberId: invite.memberId ?? null,
17
17
  inviteNonce: invite.inviteNonce ?? null,
18
- compute: invite.compute ?? false,
18
+ compute: false,
19
19
  inviterName: invite.inviterName ?? null,
20
20
  deviceSeed: invite.deviceSeed ?? null,
21
21
  deviceProof: invite.deviceProof ?? null,
22
22
  workspace: invite.workspace ?? false,
23
- workspaceName: invite.workspaceName ?? null
23
+ workspaceName: invite.workspaceName ?? null,
24
+ publicHeads: [...(invite.publicHeads ?? [])]
24
25
  };
25
26
  const prefix = invite.memberInvite ? MEMBER_INVITE_PREFIX : DEVICE_INVITE_PREFIX;
26
27
  return prefix + z32.encode(encodeStruct(INVITE_STRUCT, payload));
@@ -50,11 +51,11 @@ export function decodeMeshInvite(raw) {
50
51
  memberInvite: payload.memberInvite ?? false,
51
52
  memberId: payload.memberId ?? undefined,
52
53
  inviteNonce: payload.inviteNonce ?? undefined,
53
- compute: payload.compute ?? false,
54
54
  inviterName: payload.inviterName ?? undefined,
55
55
  deviceSeed: payload.deviceSeed ?? undefined,
56
56
  deviceProof: payload.deviceProof ?? undefined,
57
57
  workspace: payload.workspace ?? false,
58
- workspaceName: payload.workspaceName ?? undefined
58
+ workspaceName: payload.workspaceName ?? undefined,
59
+ publicHeads: payload.publicHeads ?? []
59
60
  };
60
61
  }
@@ -1,6 +1,7 @@
1
1
  import CorestoreStorage from 'hypercore-storage';
2
2
  import HyperDB from 'hyperdb';
3
3
  import type { LocalAccountRecovery, LocalAppConfig, LocalCapabilityProfile, LocalChatMove, LocalMeshUpdate, LocalMeshName, LocalChatNotify, LocalChatOrder, LocalCustomModel, LocalIdentity, LocalMemberProof, LocalMeshDeparture, LocalMeshMembership, LocalMeshPurge, LocalModelDownload, LocalModelNotify } from '../../../spec/local/hyperschema/types.d.ts';
4
+ import type { QvacAutobeeHead } from '../../../spec/mesh/hyperschema/types.d.ts';
4
5
  import type { DeviceMetadata } from '../mesh.ts';
5
6
  import type { MeshRole } from '../contract/roles.ts';
6
7
  import { LocalFiles } from './files.ts';
@@ -46,10 +47,16 @@ export interface ResolvedSession {
46
47
  readonly writerSeed: string | undefined;
47
48
  readonly role?: MeshRole;
48
49
  readonly workspaceKey?: Buffer;
50
+ readonly bootFrom?: QvacAutobeeHead | null;
49
51
  }
50
52
  export interface ArchivedMeshMembership extends LocalMeshMembership {
51
53
  readonly leftAt: number;
52
54
  }
55
+ export interface ConfigChange<T> {
56
+ readonly result: T;
57
+ readonly set: ReadonlyArray<ConfigEntry>;
58
+ readonly delete: ReadonlyArray<string>;
59
+ }
53
60
  export interface ConfigEntry {
54
61
  readonly key: string;
55
62
  readonly value: unknown;
@@ -127,6 +134,7 @@ declare class LocalStore {
127
134
  setAll(entries: ReadonlyArray<ConfigEntry>): Promise<void>;
128
135
  rekey(fromKey: string, toKey: string): Promise<unknown>;
129
136
  deleteAll(keys: ReadonlyArray<string>): Promise<void>;
137
+ change<T>(plan: (get: (key: string) => Promise<unknown>) => Promise<ConfigChange<T>>): Promise<T>;
130
138
  deletePrefix(prefix: string): Promise<void>;
131
139
  listPrefix(prefix: string): Promise<ConfigEntry[]>;
132
140
  getAppConfigRow(): Promise<LocalAppConfig | null>;
@@ -146,7 +154,7 @@ declare class LocalStore {
146
154
  putModelDownloadRow(row: LocalModelDownload): Promise<void>;
147
155
  deleteModelDownloadRow(name: string): Promise<void>;
148
156
  getCustomModelRows(): Promise<LocalCustomModel[]>;
149
- putCustomModelRow(row: LocalCustomModel): Promise<void>;
157
+ putCustomModelRowIfLabelAvailable(row: LocalCustomModel): Promise<boolean>;
150
158
  deleteCustomModelRow(name: string): Promise<void>;
151
159
  ensureDevice(publicKey: Buffer, seed?: DeviceMetadata): Promise<DeviceMetadata | null>;
152
160
  renameDevice(publicKey: Buffer, name: string): Promise<void>;
@@ -164,6 +172,7 @@ declare class LocalStore {
164
172
  meshNames(): Promise<LocalMeshName[]>;
165
173
  keepMeshName(row: LocalMeshName): Promise<void>;
166
174
  recordChatMove(row: LocalChatMove): Promise<void>;
175
+ dropChatMove({ meshKey, chatId }: LocalChatMove): Promise<void>;
167
176
  recordAccountRecovery(row: LocalAccountRecovery): Promise<void>;
168
177
  replaceIdentity(identity: Omit<LocalIdentity, 'id'>): Promise<void>;
169
178
  ensureIdentity(devicePublicKey: Buffer, createdAt: number): Promise<EnsuredIdentity>;
@@ -180,6 +189,10 @@ declare class LocalStore {
180
189
  departureRole(departure: LocalMeshDeparture): Promise<MeshRole>;
181
190
  deleteDeparture(key: Buffer): Promise<void>;
182
191
  archiveMesh(key: Buffer): Promise<void>;
192
+ markRetired(keys: Buffer[], accountKey: Buffer): Promise<void>;
193
+ unretire(accountKey: Buffer): Promise<Buffer[]>;
194
+ markKicked(key: Buffer): Promise<void>;
195
+ restoreMesh(key: Buffer): Promise<void>;
183
196
  readPurge(key: Buffer): Promise<LocalMeshPurge | null>;
184
197
  pendingPurges(): Promise<LocalMeshPurge[]>;
185
198
  dropMesh(key: Buffer, opts?: DropMeshOptions): Promise<boolean>;
@@ -189,6 +202,8 @@ declare class LocalStore {
189
202
  private _dropMeshConfig;
190
203
  private _dropRows;
191
204
  markAwaitingAdmission(key: Buffer, opts: MarkAwaitingAdmissionOptions): Promise<void>;
205
+ markJoinedUnder(key: Buffer, joinedAt: number): Promise<void>;
206
+ joinedUnder(key: Buffer): Promise<number | null>;
192
207
  setMeshRole(key: Buffer, role: MeshRole): Promise<void>;
193
208
  awaitsAdmission(key: Buffer): Promise<boolean>;
194
209
  markMeshMigrated(key: Buffer, migratedAt: number): Promise<void>;