@qvac/core 0.2.2 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/dist-lib/lib/api/agents.js +2 -3
  2. package/dist-lib/lib/api/chat.d.ts +3 -1
  3. package/dist-lib/lib/api/chat.js +9 -5
  4. package/dist-lib/lib/api/chunks.d.ts +1 -1
  5. package/dist-lib/lib/api/chunks.js +5 -15
  6. package/dist-lib/lib/api/current-mesh.d.ts +16 -1
  7. package/dist-lib/lib/api/current-mesh.js +18 -0
  8. package/dist-lib/lib/api/devices.js +6 -3
  9. package/dist-lib/lib/api/index.d.ts +2 -0
  10. package/dist-lib/lib/api/index.js +4 -2
  11. package/dist-lib/lib/api/inference-calls.d.ts +18 -0
  12. package/dist-lib/lib/api/inference-calls.js +15 -0
  13. package/dist-lib/lib/api/knowledge.js +11 -7
  14. package/dist-lib/lib/api/members.js +2 -3
  15. package/dist-lib/lib/api/rag.js +10 -2
  16. package/dist-lib/lib/api/sync.d.ts +1 -1
  17. package/dist-lib/lib/api/sync.js +2 -1
  18. package/dist-lib/lib/api/tool-activity.js +2 -2
  19. package/dist-lib/lib/api/tool-configs.js +2 -2
  20. package/dist-lib/lib/api/watchable.d.ts +6 -1
  21. package/dist-lib/lib/api/watchable.js +13 -2
  22. package/dist-lib/lib/assistant/harness.d.ts +1 -0
  23. package/dist-lib/lib/assistant/history.d.ts +1 -2
  24. package/dist-lib/lib/assistant/history.js +0 -6
  25. package/dist-lib/lib/assistant-tree.d.ts +2 -0
  26. package/dist-lib/lib/assistant-tree.js +11 -2
  27. package/dist-lib/lib/assistant.d.ts +17 -8
  28. package/dist-lib/lib/assistant.js +172 -125
  29. package/dist-lib/lib/core/chunk.d.ts +1 -0
  30. package/dist-lib/lib/core/chunk.js +32 -0
  31. package/dist-lib/lib/core/contract/devices.js +3 -2
  32. package/dist-lib/lib/core/files/rag/build.d.ts +1 -2
  33. package/dist-lib/lib/core/files/rag/build.js +1 -2
  34. package/dist-lib/lib/core/files/rag/extract/office-collabora.d.ts +1 -1
  35. package/dist-lib/lib/core/files/rag/index.d.ts +4 -24
  36. package/dist-lib/lib/core/files/rag/index.js +3 -17
  37. package/dist-lib/lib/core/files/rag/load.d.ts +1 -2
  38. package/dist-lib/lib/core/files/rag/load.js +1 -2
  39. package/dist-lib/lib/core/files/rag/produce.d.ts +1 -1
  40. package/dist-lib/lib/core/files/rag/produce.js +1 -3
  41. package/dist-lib/lib/core/files/rag/retrieval/full-text.d.ts +1 -1
  42. package/dist-lib/lib/core/files/rag/retrieval/full-text.js +1 -4
  43. package/dist-lib/lib/core/files/rag/similarity.d.ts +5 -0
  44. package/dist-lib/lib/core/files/rag/similarity.js +6 -0
  45. package/dist-lib/lib/core/files/upload.d.ts +1 -1
  46. package/dist-lib/lib/core/harness-loan.js +1 -1
  47. package/dist-lib/lib/core/inference-calls-handoff.d.ts +20 -0
  48. package/dist-lib/lib/core/inference-calls-handoff.js +37 -0
  49. package/dist-lib/lib/core/inference-calls-receiver.d.ts +14 -0
  50. package/dist-lib/lib/core/inference-calls-receiver.js +39 -0
  51. package/dist-lib/lib/core/local/index.js +6 -0
  52. package/dist-lib/lib/core/notification.js +5 -4
  53. package/dist-lib/lib/core.d.ts +9 -1
  54. package/dist-lib/lib/core.js +98 -16
  55. package/dist-lib/lib/fs-drive-bridge.js +1 -1
  56. package/dist-lib/lib/inference-calls.d.ts +40 -0
  57. package/dist-lib/lib/inference-calls.js +266 -0
  58. package/dist-lib/lib/mesh-scoped-engine.js +5 -0
  59. package/dist-lib/lib/model-download.d.ts +2 -0
  60. package/dist-lib/lib/model-download.js +20 -5
  61. package/dist-lib/lib/oauth/keys.js +1 -0
  62. package/dist-lib/lib/oauth/spotify.js +1 -0
  63. package/dist-lib/lib/oauth/verify.d.ts +8 -0
  64. package/dist-lib/lib/oauth/verify.js +58 -0
  65. package/dist-lib/lib/oauth.d.ts +1 -0
  66. package/dist-lib/lib/oauth.js +1 -0
  67. package/dist-lib/schema/content.js +5 -1
  68. package/dist-lib/schema/engine.js +42 -1
  69. package/dist-lib/schema/qvac.d.ts +3 -0
  70. package/dist-lib/schema/qvac.js +11 -2
  71. package/dist-lib/spec/bind.js +3 -0
  72. package/dist-lib/spec/calls.js +1 -0
  73. package/dist-lib/spec/capabilities.d.ts +2 -0
  74. package/dist-lib/spec/hrpc/hrpc.json +13 -0
  75. package/dist-lib/spec/hrpc/index.js +15 -3
  76. package/dist-lib/spec/hrpc/messages.js +172 -49
  77. package/dist-lib/spec/hyperschema/index.js +172 -49
  78. package/dist-lib/spec/hyperschema/schema.json +127 -1
  79. package/dist-lib/spec/hyperschema/types.d.ts +34 -1
  80. package/dist-lib/spec/local/hyperdb/messages.js +64 -128
  81. package/dist-lib/spec/local/hyperschema/index.js +32 -64
  82. package/dist-lib/spec/local/hyperschema/schema.json +16 -0
  83. package/dist-lib/spec/mesh/hyperdb/messages.js +176 -311
  84. package/dist-lib/spec/mesh/hyperdispatch/messages.js +132 -236
  85. package/dist-lib/spec/mesh/hyperschema/index.js +132 -236
  86. package/dist-lib/spec/mesh/hyperschema/schema.json +70 -1
  87. package/dist-lib/spec/mesh/hyperschema/types.d.ts +3 -1
  88. package/package.json +14 -17
  89. package/tui/app.mjs +327 -46
  90. package/tui/lib/knowledge-import.mjs +1 -1
  91. package/tui/lib/render.mjs +17 -1
  92. package/tui/lib/selection.mjs +16 -0
  93. package/tui/lib/usage.mjs +54 -0
  94. package/.claude/skills/asana/SKILL.md +0 -86
  95. package/.claude/skills/compaction/SKILL.md +0 -132
  96. package/.claude/skills/device-mesh-debug/SKILL.md +0 -328
  97. package/.claude/skills/gh-stack/SKILL.md +0 -181
  98. package/.claude/skills/gh-stack/references/commands.md +0 -177
  99. package/.claude/skills/gh-stack/references/stack-design.md +0 -97
  100. package/.claude/skills/gh-stack/references/troubleshooting.md +0 -159
  101. package/.claude/skills/js-house-style/SKILL.md +0 -670
  102. package/.claude/skills/pr-create/SKILL.md +0 -201
  103. package/.claude/skills/pr-review/SKILL.md +0 -424
  104. package/CLAUDE.md +0 -43
  105. package/dist-lib/lib/core/files/rag/artifact/codec.d.ts +0 -3
  106. package/dist-lib/lib/core/files/rag/artifact/codec.js +0 -172
  107. package/dist-lib/lib/core/files/rag/artifact/id.d.ts +0 -10
  108. package/dist-lib/lib/core/files/rag/artifact/id.js +0 -39
  109. package/dist-lib/lib/core/files/rag/artifact/types.d.ts +0 -24
  110. package/dist-lib/lib/core/files/rag/artifact/types.js +0 -41
  111. package/dist-lib/lib/core/files/rag/chunk/chunking.d.ts +0 -12
  112. package/dist-lib/lib/core/files/rag/chunk/chunking.js +0 -117
  113. package/dist-lib/lib/core/files/rag/chunk/metadata.d.ts +0 -30
  114. package/dist-lib/lib/core/files/rag/chunk/metadata.js +0 -89
  115. package/dist-lib/lib/core/files/rag/chunk/tokenizer.d.ts +0 -7
  116. package/dist-lib/lib/core/files/rag/chunk/tokenizer.js +0 -18
  117. package/dist-lib/lib/core/files/rag/extract/csv-text.d.ts +0 -1
  118. package/dist-lib/lib/core/files/rag/extract/csv-text.js +0 -117
  119. package/dist-lib/lib/core/files/rag/extract/document-types.d.ts +0 -22
  120. package/dist-lib/lib/core/files/rag/extract/document-types.js +0 -152
  121. package/dist-lib/lib/core/files/rag/extract/extract.d.ts +0 -17
  122. package/dist-lib/lib/core/files/rag/extract/extract.js +0 -81
  123. package/dist-lib/lib/core/files/rag/extract/html-table-text.d.ts +0 -1
  124. package/dist-lib/lib/core/files/rag/extract/html-table-text.js +0 -125
  125. package/dist-lib/lib/core/files/rag/extract/html-text.d.ts +0 -1
  126. package/dist-lib/lib/core/files/rag/extract/html-text.js +0 -132
  127. package/dist-lib/lib/core/files/rag/extract/pdf-platform.d.ts +0 -17
  128. package/dist-lib/lib/core/files/rag/extract/pdf-platform.js +0 -141
  129. package/dist-lib/lib/core/files/rag/extract/pdf-text.d.ts +0 -12
  130. package/dist-lib/lib/core/files/rag/extract/pdf-text.js +0 -43
  131. package/dist-lib/lib/core/files/rag/extract/rtf-text.d.ts +0 -1
  132. package/dist-lib/lib/core/files/rag/extract/rtf-text.js +0 -15
  133. package/dist-lib/lib/core/files/rag/extract/text-decoding.d.ts +0 -1
  134. package/dist-lib/lib/core/files/rag/extract/text-decoding.js +0 -91
  135. package/dist-lib/lib/core/files/rag/extract/types.d.ts +0 -36
  136. package/dist-lib/lib/core/files/rag/extract/types.js +0 -12
  137. package/dist-lib/lib/core/files/rag/extract/utf.d.ts +0 -2
  138. package/dist-lib/lib/core/files/rag/extract/utf.js +0 -18
  139. package/dist-lib/lib/core/files/rag/retrieval/citation-match.d.ts +0 -2
  140. package/dist-lib/lib/core/files/rag/retrieval/citation-match.js +0 -16
  141. package/dist-lib/lib/core/files/rag/retrieval/coverage.d.ts +0 -4
  142. package/dist-lib/lib/core/files/rag/retrieval/coverage.js +0 -48
  143. package/dist-lib/lib/core/files/rag/retrieval/diversity.d.ts +0 -10
  144. package/dist-lib/lib/core/files/rag/retrieval/diversity.js +0 -37
  145. package/dist-lib/lib/core/files/rag/retrieval/floor.d.ts +0 -5
  146. package/dist-lib/lib/core/files/rag/retrieval/floor.js +0 -21
  147. package/dist-lib/lib/core/files/rag/retrieval/format.d.ts +0 -6
  148. package/dist-lib/lib/core/files/rag/retrieval/format.js +0 -21
  149. package/dist-lib/lib/core/files/rag/retrieval/knowledge.d.ts +0 -2
  150. package/dist-lib/lib/core/files/rag/retrieval/knowledge.js +0 -54
  151. package/dist-lib/lib/core/files/rag/retrieval/notices.d.ts +0 -16
  152. package/dist-lib/lib/core/files/rag/retrieval/notices.js +0 -27
  153. package/dist-lib/lib/core/files/rag/retrieval/scoring.d.ts +0 -8
  154. package/dist-lib/lib/core/files/rag/retrieval/scoring.js +0 -82
  155. package/dist-lib/lib/core/files/rag/retrieval/search.d.ts +0 -3
  156. package/dist-lib/lib/core/files/rag/retrieval/search.js +0 -49
  157. package/dist-lib/lib/core/files/rag/retrieval/selection.d.ts +0 -11
  158. package/dist-lib/lib/core/files/rag/retrieval/selection.js +0 -93
  159. package/dist-lib/lib/core/files/rag/retrieval/source-tag-filter.d.ts +0 -6
  160. package/dist-lib/lib/core/files/rag/retrieval/source-tag-filter.js +0 -79
  161. package/dist-lib/lib/core/files/rag/retrieval/sources.d.ts +0 -13
  162. package/dist-lib/lib/core/files/rag/retrieval/sources.js +0 -20
  163. package/dist-lib/lib/core/files/rag/retrieval/target.d.ts +0 -13
  164. package/dist-lib/lib/core/files/rag/retrieval/target.js +0 -89
  165. package/dist-lib/lib/core/files/rag/retrieval/terms.d.ts +0 -8
  166. package/dist-lib/lib/core/files/rag/retrieval/terms.js +0 -70
  167. package/dist-lib/lib/core/files/rag/retrieval/types.d.ts +0 -29
  168. package/dist-lib/lib/core/files/rag/retrieval/types.js +0 -1
  169. package/dist-lib/lib/core/files/rag/retrieval/web-sources.d.ts +0 -8
  170. package/dist-lib/lib/core/files/rag/retrieval/web-sources.js +0 -41
  171. package/dist-lib/lib/core/files/rag/retrieval/whole-document-query.d.ts +0 -1
  172. package/dist-lib/lib/core/files/rag/retrieval/whole-document-query.js +0 -96
  173. package/dist-lib/lib/core/files/rag/vector/memory.d.ts +0 -15
  174. package/dist-lib/lib/core/files/rag/vector/memory.js +0 -135
  175. package/dist-lib/lib/core/files/rag/vector/types.d.ts +0 -28
  176. package/dist-lib/lib/core/files/rag/vector/types.js +0 -1
@@ -58,4 +58,5 @@ export declare function resolveApproval(store: Mesh, { id, approved, scope, expi
58
58
  expiresAt?: number;
59
59
  agentId?: string;
60
60
  }): Promise<QvacChunk>;
61
+ export declare function listRunRequests(store: Mesh, deviceId: Buffer | null): Promise<QvacChunk[]>;
61
62
  export {};
@@ -144,6 +144,8 @@ export async function appendChunk(store, { id = randomId(), chatId, runId, type,
144
144
  if (type === 'sources' && !ragSourcesWithinBounds(payload.sources)) {
145
145
  throw new Error('chunk payload invalid: a sources chunk exceeds its wire bounds');
146
146
  }
147
+ if (type === 'user-message' && !store.ourMemberId)
148
+ await store.refreshOurMember();
147
149
  if (parentId) {
148
150
  const parent = await getChunk(store, parentId);
149
151
  if (!parent || parent.chatId !== chatId) {
@@ -162,6 +164,9 @@ export async function appendChunk(store, { id = randomId(), chatId, runId, type,
162
164
  display,
163
165
  rawCall,
164
166
  createdAt: Date.now(),
167
+ ...(type === 'user-message' && store.ourMemberId && store.ourDeviceId?.equals(originDeviceId)
168
+ ? { senderMemberId: store.ourMemberId }
169
+ : undefined),
165
170
  ...payload
166
171
  };
167
172
  await into.dispatch('append-chunk', op);
@@ -210,3 +215,30 @@ export async function resolveApproval(store, { id, approved, scope, expiresAt, a
210
215
  }
211
216
  return resolved;
212
217
  }
218
+ export async function listRunRequests(store, deviceId) {
219
+ if (!deviceId)
220
+ return [];
221
+ const snap = store.view.snapshot();
222
+ try {
223
+ const requests = await snap.find('@qvac/run-requests').toArray();
224
+ const providers = new Map();
225
+ const mine = [];
226
+ for (const request of requests) {
227
+ if (store.closing)
228
+ return mine;
229
+ const agentId = request.runRequest?.agentId;
230
+ if (!agentId)
231
+ continue;
232
+ if (!providers.has(agentId)) {
233
+ const agent = await snap.get('@qvac/agents', { id: agentId });
234
+ providers.set(agentId, agent?.providerDeviceId);
235
+ }
236
+ if (providers.get(agentId)?.equals(deviceId))
237
+ mine.push(request);
238
+ }
239
+ return mine;
240
+ }
241
+ finally {
242
+ await snap.close();
243
+ }
244
+ }
@@ -1,3 +1,4 @@
1
+ import { capDeviceName } from '../../../schema/qvac.js';
1
2
  import { trackActivity } from './activity.js';
2
3
  import { sealed } from './seal.js';
3
4
  import { verifyWriterClaim } from '../device-attestation.js';
@@ -21,7 +22,7 @@ export function registerDeviceRoutes(router) {
21
22
  }
22
23
  const registered = {
23
24
  id: device.id,
24
- name: device.name,
25
+ name: capDeviceName(device.name),
25
26
  joinedAt: device.joinedAt,
26
27
  capabilityProfile: device.capabilityProfile,
27
28
  recommendedModelName: device.recommendedModelName,
@@ -55,7 +56,7 @@ export function registerDeviceRoutes(router) {
55
56
  });
56
57
  return;
57
58
  }
58
- const next = { ...existing, name: device.name };
59
+ const next = { ...existing, name: capDeviceName(device.name) };
59
60
  await tx.insert(DEVICES, next);
60
61
  return next;
61
62
  }));
@@ -1,7 +1,6 @@
1
1
  import type { AbortSignal } from 'bare-abort-controller';
2
2
  import type { QvacKnowledge } from '../../../../spec/mesh/hyperschema/types.d.ts';
3
- import { type RagExtractors } from './extract/extract.ts';
4
- import type { RagArtifactPayload } from './artifact/types.ts';
3
+ import { type RagArtifactPayload, type RagExtractors } from 'rag-extract';
5
4
  export type BuildEmbedder = {
6
5
  model: string;
7
6
  embed(input: {
@@ -1,5 +1,4 @@
1
- import { chunkRagDocuments } from './chunk/chunking.js';
2
- import { extractRagDocumentFromBytes } from './extract/extract.js';
1
+ import { chunkRagDocuments, extractRagDocumentFromBytes } from 'rag-extract';
3
2
  import { AbortedError } from '@qvac/harness/race-abort';
4
3
  const EMBED_BATCH = 8;
5
4
  export class EmbedderFailure extends Error {
@@ -1,2 +1,2 @@
1
- import type { RagFileExtractor } from './extract.ts';
1
+ import type { RagFileExtractor } from 'rag-extract';
2
2
  export declare const extractOfficeText: RagFileExtractor;
@@ -1,7 +1,6 @@
1
1
  import type { AbortSignal } from 'bare-abort-controller';
2
2
  import type { QvacKnowledge } from '../../../../spec/mesh/hyperschema/types.d.ts';
3
- import type { RagExtractors } from './extract/extract.ts';
4
- import type { VectorIndex } from './vector/types.ts';
3
+ import { type RagExtractors, type VectorIndex } from 'rag-extract';
5
4
  import { type IndexingEmbedder } from './produce.ts';
6
5
  import type { Mesh } from '../../mesh.ts';
7
6
  import type { FileDocument, FileProcessor } from '../processing/index.ts';
@@ -27,28 +26,9 @@ export declare class RagProcessor implements FileProcessor {
27
26
  produce(document: FileDocument, signal: AbortSignal): Promise<void>;
28
27
  close(): Promise<boolean>;
29
28
  }
30
- export { encodeRagArtifact } from './artifact/codec.ts';
31
- export type { RagArtifactPayload } from './artifact/types.ts';
32
- export { isSupportedRagDocument } from './extract/document-types.ts';
33
- export type { RagExtractors } from './extract/extract.ts';
34
29
  export { MAX_KNOWLEDGE_BYTES } from './limits.ts';
35
30
  export { canIndexChat } from './policy.ts';
36
31
  export type { IndexingEmbedder, IndexingProgress } from './produce.ts';
37
- export { citedByPhraseOverlap } from './retrieval/citation-match.ts';
38
- export { formatRagContext } from './retrieval/format.ts';
39
- export { formatFullDocumentContext, isFullTextHit, isTruncatedFullTextHit } from './retrieval/full-text.ts';
40
- export { RAG_KNOWLEDGE_OFF_NOTICE, RAG_TRUNCATED_NOTICE, RAG_UNAVAILABLE_NOTICE, chooseRagNotice } from './retrieval/notices.ts';
41
- export { createRagSourceTagFilter } from './retrieval/source-tag-filter.ts';
42
- export { sourcesFromHits } from './retrieval/sources.ts';
43
- export type { RagSource } from './retrieval/sources.ts';
44
- export { WEB_TOOLS, webSourcesFromToolResult, withoutDataChannel } from './retrieval/web-sources.ts';
45
- export { MemoryVectorIndex } from './vector/memory.ts';
46
- export type { VectorIndex } from './vector/types.ts';
47
- export { fullTextBudgetChars, fullTextHits } from './retrieval/full-text.ts';
48
- export { retrieveRagKnowledge } from './retrieval/knowledge.ts';
49
- export { searchRagChunks } from './retrieval/search.ts';
50
- export { referencesPendingFile } from './retrieval/target.ts';
51
- export type { RagDocumentRef } from './retrieval/target.ts';
52
- export type { VectorHit } from './vector/types.ts';
53
- export { isWholeDocumentQuery } from './retrieval/whole-document-query.ts';
54
- export { referencedDocuments } from './retrieval/target.ts';
32
+ export { formatFullDocumentContext, fullTextBudgetChars, fullTextHits, isFullTextHit, isTruncatedFullTextHit } from './retrieval/full-text.ts';
33
+ export { MemoryVectorIndex, RAG_KNOWLEDGE_OFF_NOTICE, RAG_TRUNCATED_NOTICE, RAG_UNAVAILABLE_NOTICE, WEB_TOOLS, chooseRagNotice, citedByPhraseOverlap, createRagSourceTagFilter, encodeRagArtifact, formatRagContext, isSupportedRagDocument, isWholeDocumentQuery, referencedDocuments, referencesPendingFile, retrieveRagKnowledge, searchRagChunks, sourcesFromHits, webSourcesFromToolResult, withoutDataChannel } from 'rag-extract';
34
+ export type { RagArtifactPayload, RagDocumentRef, RagExtractors, RagSource, VectorHit, VectorIndex } from 'rag-extract';
@@ -1,5 +1,5 @@
1
1
  import ScopeLock from 'scope-lock';
2
- import { pipelineVersionFor } from './artifact/id.js';
2
+ import { pipelineVersionFor } from 'rag-extract';
3
3
  import { AbortedError } from '@qvac/harness/race-abort';
4
4
  import { IndexingPass } from './produce.js';
5
5
  import { HydratePass } from './load.js';
@@ -59,21 +59,7 @@ export class RagProcessor {
59
59
  }
60
60
  }
61
61
  }
62
- export { encodeRagArtifact } from './artifact/codec.js';
63
- export { isSupportedRagDocument } from './extract/document-types.js';
64
62
  export { MAX_KNOWLEDGE_BYTES } from './limits.js';
65
63
  export { canIndexChat } from './policy.js';
66
- export { citedByPhraseOverlap } from './retrieval/citation-match.js';
67
- export { formatRagContext } from './retrieval/format.js';
68
- export { formatFullDocumentContext, isFullTextHit, isTruncatedFullTextHit } from './retrieval/full-text.js';
69
- export { RAG_KNOWLEDGE_OFF_NOTICE, RAG_TRUNCATED_NOTICE, RAG_UNAVAILABLE_NOTICE, chooseRagNotice } from './retrieval/notices.js';
70
- export { createRagSourceTagFilter } from './retrieval/source-tag-filter.js';
71
- export { sourcesFromHits } from './retrieval/sources.js';
72
- export { WEB_TOOLS, webSourcesFromToolResult, withoutDataChannel } from './retrieval/web-sources.js';
73
- export { MemoryVectorIndex } from './vector/memory.js';
74
- export { fullTextBudgetChars, fullTextHits } from './retrieval/full-text.js';
75
- export { retrieveRagKnowledge } from './retrieval/knowledge.js';
76
- export { searchRagChunks } from './retrieval/search.js';
77
- export { referencesPendingFile } from './retrieval/target.js';
78
- export { isWholeDocumentQuery } from './retrieval/whole-document-query.js';
79
- export { referencedDocuments } from './retrieval/target.js';
64
+ export { formatFullDocumentContext, fullTextBudgetChars, fullTextHits, isFullTextHit, isTruncatedFullTextHit } from './retrieval/full-text.js';
65
+ export { MemoryVectorIndex, RAG_KNOWLEDGE_OFF_NOTICE, RAG_TRUNCATED_NOTICE, RAG_UNAVAILABLE_NOTICE, WEB_TOOLS, chooseRagNotice, citedByPhraseOverlap, createRagSourceTagFilter, encodeRagArtifact, formatRagContext, isSupportedRagDocument, isWholeDocumentQuery, referencedDocuments, referencesPendingFile, retrieveRagKnowledge, searchRagChunks, sourcesFromHits, webSourcesFromToolResult, withoutDataChannel } from 'rag-extract';
@@ -1,9 +1,8 @@
1
1
  import type { QvacKnowledgeArtifact } from '../../../../spec/mesh/hyperschema/types.d.ts';
2
- import type { VectorIndex } from './vector/types.ts';
2
+ import { type RagExtractors, type VectorIndex } from 'rag-extract';
3
3
  import type { FileDocument } from '../processing/index.ts';
4
4
  import type { AbortSignal } from 'bare-abort-controller';
5
5
  import { type BuildEmbedder } from './build.ts';
6
- import type { RagExtractors } from './extract/extract.ts';
7
6
  export type HydratePassOptions = {
8
7
  model: string;
9
8
  index: VectorIndex;
@@ -1,5 +1,4 @@
1
- import { decodeRagArtifact } from './artifact/codec.js';
2
- import { pipelineVersionFor, contentHash } from './artifact/id.js';
1
+ import { contentHash, decodeRagArtifact, pipelineVersionFor } from 'rag-extract';
3
2
  import { compareBlobReferences } from '../store/index.js';
4
3
  import { buildArtifactPayload, EmbedderFailure } from './build.js';
5
4
  import { EMBED_RETRY_LIMIT } from './produce.js';
@@ -1,5 +1,5 @@
1
1
  import type { AbortSignal } from 'bare-abort-controller';
2
- import type { RagExtractors } from './extract/extract.ts';
2
+ import { type RagExtractors } from 'rag-extract';
3
3
  import { type BuildEmbedder } from './build.ts';
4
4
  import { type FileDocument } from '../processing/index.ts';
5
5
  export interface IndexingEmbedder extends BuildEmbedder {
@@ -1,6 +1,4 @@
1
- import { encodeRagArtifact } from './artifact/codec.js';
2
- import { contentHash, documentIndexArtifactId, pipelineVersionFor } from './artifact/id.js';
3
- import { classifyRagDocument, RAG_DOCUMENT_KIND } from './extract/document-types.js';
1
+ import { classifyRagDocument, contentHash, documentIndexArtifactId, encodeRagArtifact, pipelineVersionFor, RAG_DOCUMENT_KIND } from 'rag-extract';
4
2
  import { buildArtifactPayload, EmbedderFailure } from './build.js';
5
3
  import { isClaimLive } from '../processing/index.js';
6
4
  import { AbortedError } from '@qvac/harness/race-abort';
@@ -1,6 +1,6 @@
1
1
  import type { QvacKnowledge } from '../../../../../spec/mesh/hyperschema/types.d.ts';
2
2
  import type { Mesh } from '../../../mesh.ts';
3
- import type { VectorHit } from '../vector/types.ts';
3
+ import { type VectorHit } from 'rag-extract';
4
4
  export declare function fullTextBudgetChars(ctxSize: number): number;
5
5
  export declare function isFullTextHit(hit: {
6
6
  readonly id: string;
@@ -1,7 +1,4 @@
1
- import { parseRagMetadata } from '../chunk/metadata.js';
2
- import { classifyRagDocument, RAG_DOCUMENT_KIND } from '../extract/document-types.js';
3
- import { extractRagDocumentFromBytes } from '../extract/extract.js';
4
- import { extractPdfHead } from '../extract/pdf-text.js';
1
+ import { classifyRagDocument, extractPdfHead, extractRagDocumentFromBytes, parseRagMetadata, RAG_DOCUMENT_KIND } from 'rag-extract';
5
2
  const DEFAULT_FULL_TEXT_BUDGET_TOKENS = 4096;
6
3
  const CHARS_PER_TOKEN = 4;
7
4
  const FULL_TEXT_KINDS = new Set([
@@ -0,0 +1,5 @@
1
+ import '../../../logger.ts';
2
+ import { applySimilarityFloor, RAG_MIN_SIMILARITY } from 'rag-extract/retrieval';
3
+ import type { VectorHit } from 'rag-extract/vector';
4
+ export { applySimilarityFloor, RAG_MIN_SIMILARITY };
5
+ export declare function logSimilarityScores(candidates: ReadonlyArray<VectorHit>, kept: ReadonlyArray<VectorHit>): void;
@@ -0,0 +1,6 @@
1
+ import '../../../logger.js';
2
+ import { applySimilarityFloor, logSimilarityScores as traceSimilarityScores, RAG_MIN_SIMILARITY } from 'rag-extract/retrieval';
3
+ export { applySimilarityFloor, RAG_MIN_SIMILARITY };
4
+ export function logSimilarityScores(candidates, kept) {
5
+ traceSimilarityScores(candidates, kept, (message) => logger.debug('rag', message));
6
+ }
@@ -7,8 +7,8 @@ export declare function uploadFile(mesh: Mesh, frames: AsyncIterable<AssistantUp
7
7
  deviceId?: Buffer | null;
8
8
  inactivityMs?: number;
9
9
  }): AsyncGenerator<{
10
- attachment?: undefined;
11
10
  bytesWritten: number;
11
+ attachment?: undefined;
12
12
  knowledge?: undefined;
13
13
  } | {
14
14
  bytesWritten: number;
@@ -145,7 +145,7 @@ export class HarnessLoan {
145
145
  if (!peer || peer.served.has(id))
146
146
  return;
147
147
  const stream = this._attach(peer, id, false);
148
- const served = await this._opts.onborrow(peer.remoteKey).catch(() => null);
148
+ const served = await this._opts.onborrow(peer.remoteKey).catch(noop);
149
149
  if (!served) {
150
150
  stream.destroy();
151
151
  return;
@@ -0,0 +1,20 @@
1
+ import { ACK_TIMEOUT_MS, HOST_SILENT, HOST_UNREACHABLE, type HandoffStream } from './handoff-channel.ts';
2
+ import type { AssistantInferenceCallEntry, AssistantInferenceCallsRequest } from '../../spec/hyperschema/types.d.ts';
3
+ export { ACK_TIMEOUT_MS, HOST_SILENT, HOST_UNREACHABLE, type HandoffStream };
4
+ export type InferenceCallsRequest = AssistantInferenceCallsRequest;
5
+ export interface InferenceCallsAnswer {
6
+ readonly calls: ReadonlyArray<AssistantInferenceCallEntry>;
7
+ readonly truncated: boolean;
8
+ }
9
+ export type InferenceCallsHandler = (request: InferenceCallsRequest, fromDeviceId: Uint8Array) => Promise<InferenceCallsAnswer>;
10
+ export interface InferenceCallsHandoffOptions {
11
+ readonly onrequest: InferenceCallsHandler;
12
+ readonly ackTimeoutMs?: number;
13
+ }
14
+ export declare class InferenceCallsHandoff {
15
+ private readonly _channel;
16
+ constructor(opts: InferenceCallsHandoffOptions);
17
+ addStream(stream: HandoffStream): void;
18
+ send(hostDeviceId: Uint8Array, request: InferenceCallsRequest): Promise<InferenceCallsAnswer>;
19
+ destroy(): void;
20
+ }
@@ -0,0 +1,37 @@
1
+ import { getStruct } from '../../spec/hyperschema/index.js';
2
+ import { ACK_TIMEOUT_MS, HandoffChannel, HOST_SILENT, HOST_UNREACHABLE } from './handoff-channel.js';
3
+ const PROTOCOL = 'qvac/inference-calls-handoff';
4
+ export { ACK_TIMEOUT_MS, HOST_SILENT, HOST_UNREACHABLE };
5
+ const handoff = getStruct('@assistant/inference-calls-handoff');
6
+ const handoffAck = getStruct('@assistant/inference-calls-handoff-ack');
7
+ export class InferenceCallsHandoff {
8
+ _channel;
9
+ constructor(opts) {
10
+ this._channel = new HandoffChannel({
11
+ protocol: PROTOCOL,
12
+ requestEncoding: handoff,
13
+ ackEncoding: handoffAck,
14
+ onrequest: opts.onrequest,
15
+ buildAck: (id, error, result) => ({
16
+ id,
17
+ error,
18
+ calls: result ? [...result.calls] : undefined,
19
+ truncated: result?.truncated
20
+ }),
21
+ readAck: (ack) => ({
22
+ error: ack.error ?? '',
23
+ result: { calls: ack.calls ?? [], truncated: ack.truncated ?? false }
24
+ }),
25
+ ackTimeoutMs: opts.ackTimeoutMs
26
+ });
27
+ }
28
+ addStream(stream) {
29
+ this._channel.addStream(stream);
30
+ }
31
+ send(hostDeviceId, request) {
32
+ return this._channel.send(hostDeviceId, request);
33
+ }
34
+ destroy() {
35
+ this._channel.destroy();
36
+ }
37
+ }
@@ -0,0 +1,14 @@
1
+ import type { Mesh } from './mesh.ts';
2
+ import type { InferenceCallsHandler } from './inference-calls-handoff.ts';
3
+ import type { AssistantInferenceCallEntry } from '../../spec/hyperschema/types.d.ts';
4
+ export declare const NO_SUCH_CHAT = "no such chat on the device hosting this agent";
5
+ export declare const NO_RECORD_STORE = "the device hosting this agent is not recording prompts right now";
6
+ export interface InferenceCallsReceiverOptions {
7
+ readonly mesh: Mesh;
8
+ readonly deviceId: Uint8Array;
9
+ readonly listLocal: (chatId: string) => {
10
+ calls: ReadonlyArray<AssistantInferenceCallEntry>;
11
+ truncated: boolean;
12
+ };
13
+ }
14
+ export declare function createInferenceCallsReceiver(opts: InferenceCallsReceiverOptions): InferenceCallsHandler;
@@ -0,0 +1,39 @@
1
+ import b4a from 'b4a';
2
+ import { getAgent } from './agent.js';
3
+ import { getChat } from './chat.js';
4
+ import { NO_SUCH_AGENT, NOT_THE_HOST, SENDER_REVOKED } from './skill-secrets.js';
5
+ const DEVICES = '@qvac/devices';
6
+ export const NO_SUCH_CHAT = 'no such chat on the device hosting this agent';
7
+ export const NO_RECORD_STORE = 'the device hosting this agent is not recording prompts right now';
8
+ const MAX_ANSWER_BYTES = 2 * 1024 * 1024;
9
+ export function createInferenceCallsReceiver(opts) {
10
+ return async (request, fromDeviceId) => {
11
+ const sender = await opts.mesh.view.get(DEVICES, { id: fromDeviceId });
12
+ if (!sender || sender.revoked)
13
+ throw new Error(SENDER_REVOKED);
14
+ const chat = await getChat(opts.mesh, request.chatId);
15
+ if (!chat)
16
+ throw new Error(NO_SUCH_CHAT);
17
+ const agent = await getAgent(opts.mesh, chat.agentId);
18
+ if (!agent)
19
+ throw new Error(NO_SUCH_AGENT);
20
+ if (!agent.providerDeviceId || !b4a.equals(agent.providerDeviceId, opts.deviceId)) {
21
+ throw new Error(NOT_THE_HOST);
22
+ }
23
+ const own = opts.listLocal(request.chatId);
24
+ const answer = capped(own.calls);
25
+ return { ...answer, truncated: answer.truncated || own.truncated };
26
+ };
27
+ }
28
+ function capped(calls) {
29
+ const kept = [];
30
+ let bytes = 0;
31
+ for (const entry of [...calls].reverse()) {
32
+ bytes += b4a.byteLength(JSON.stringify(entry.call));
33
+ if (bytes > MAX_ANSWER_BYTES && kept.length > 0) {
34
+ return { calls: kept.reverse(), truncated: true };
35
+ }
36
+ kept.push(entry);
37
+ }
38
+ return { calls: kept.reverse(), truncated: false };
39
+ }
@@ -2,6 +2,7 @@ import CorestoreStorage from 'hypercore-storage';
2
2
  import HyperDB from 'hyperdb';
3
3
  import crypto from 'hypercore-crypto';
4
4
  import ScopeLock from 'scope-lock';
5
+ import { MAX_DEVICE_NAME_CHARS, deviceNameWithinBounds } from '../../../schema/qvac.js';
5
6
  import { generateMnemonic, mintIdentity } from '../identity.js';
6
7
  import LocalDatabaseSpec from '../../../spec/local/hyperdb/index.js';
7
8
  const CONFIG = '@local/config';
@@ -238,6 +239,11 @@ class LocalStore {
238
239
  }
239
240
  if (!seed)
240
241
  return null;
242
+ const name = seed.name.trim();
243
+ if (!deviceNameWithinBounds(name)) {
244
+ throw new Error(`device name must be at most ${MAX_DEVICE_NAME_CHARS} characters`);
245
+ }
246
+ seed = { ...seed, name };
241
247
  const tx = this._db.transaction();
242
248
  await tx.insert(DEVICE, { publicKey, ...seed });
243
249
  await tx.flush();
@@ -35,10 +35,11 @@ export async function deriveNotifications(mesh, local, requestedLimit, deviceId)
35
35
  if (isDiagramRepairPrompt(text))
36
36
  continue;
37
37
  const sender = await snap.get('@qvac/devices', { id: chunk.originDeviceId });
38
- if (own?.memberId && sender?.memberId?.equals(own.memberId))
38
+ const senderMemberId = chunk.senderMemberId ?? sender?.memberId;
39
+ if (own?.memberId && senderMemberId?.equals(own.memberId))
39
40
  continue;
40
- const member = sender?.memberId
41
- ? await snap.get('@qvac/members', { id: sender.memberId })
41
+ const member = senderMemberId
42
+ ? await snap.get('@qvac/members', { id: senderMemberId })
42
43
  : null;
43
44
  candidates.push({
44
45
  chatId: chat.id,
@@ -48,7 +49,7 @@ export async function deriveNotifications(mesh, local, requestedLimit, deviceId)
48
49
  seq: chunk.seq,
49
50
  createdAt: chunk.createdAt,
50
51
  senderDeviceId: chunk.originDeviceId,
51
- senderMemberId: sender?.memberId,
52
+ senderMemberId,
52
53
  senderName: member?.name ?? sender?.name,
53
54
  chatTitle: chat.title,
54
55
  preview: Array.from(text).slice(0, PREVIEW_LIMIT).join('') || undefined
@@ -5,6 +5,7 @@ import ReadyGuard from 'ready-guard';
5
5
  import ReadyResource from 'ready-resource';
6
6
  import type { Logger } from '../index.ts';
7
7
  import type { AssistantArchivedMeshList, AssistantCompactChatResponse, AssistantCopySkillResponse, AssistantDeleteModelRequest, AssistantDeleteModelResponse, AssistantDeleteSkillResponse, AssistantKvCacheDeletionResponse, AssistantListModelsRequest, AssistantManagedSkillsResponse, AssistantMeshList, AssistantModelCatalogRevision, AssistantModelInfoList, AssistantOkResponse, AssistantSkillCatalogResponse, AssistantSkillFileResponse, AssistantSpeakRequest, AssistantSpeakResponse, AssistantToolCatalogResponse, AssistantTranscribeRequest, AssistantTranscribeResponse } from '../spec/index.d.ts';
8
+ import type { InferenceCallSource } from './api/inference-calls.ts';
8
9
  import { type BlindPeeringOpts } from './core/blind-peers.ts';
9
10
  import { type IndexingEmbedder, type RagExtractors, type VectorIndex } from './core/files/index.ts';
10
11
  import { type DriveHost } from './core/fs-drives.ts';
@@ -165,6 +166,7 @@ export declare class Core extends ReadyResource {
165
166
  private readonly _following;
166
167
  private readonly _secretHandoff;
167
168
  private readonly _skillOverlayHandoff;
169
+ private readonly _inferenceCallsHandoff;
168
170
  private _minting;
169
171
  private _leaving;
170
172
  private _kicked;
@@ -172,6 +174,7 @@ export declare class Core extends ReadyResource {
172
174
  private readonly _peers;
173
175
  private readonly _statusListeners;
174
176
  private readonly _diagnosticsProviders;
177
+ private _inferenceCalls;
175
178
  private _systemInfo;
176
179
  private _statusError;
177
180
  private _upgradeRequired;
@@ -351,7 +354,10 @@ export declare class Core extends ReadyResource {
351
354
  private _isJoinedRoomKey;
352
355
  private _isOwnMemberDevice;
353
356
  private _skillOverlayOp;
354
- private _resolveSkillOverlayHost;
357
+ private _resolveAgentHost;
358
+ private _listInferenceCalls;
359
+ private _toInferenceEntry;
360
+ private _serveInferenceCalls;
355
361
  private _serveSkillOverlayOp;
356
362
  private _runLocalSkillOverlayOp;
357
363
  private _setupFields;
@@ -359,6 +365,7 @@ export declare class Core extends ReadyResource {
359
365
  private _onConnection;
360
366
  private _trackPeerConnection;
361
367
  private _onPeerChange;
368
+ private _currentMeshAccessor;
362
369
  private _meshStatusSource;
363
370
  private _networkStatusSource;
364
371
  private _networkSnapshot;
@@ -366,6 +373,7 @@ export declare class Core extends ReadyResource {
366
373
  private _logSource;
367
374
  compact(force?: boolean): Promise<void>;
368
375
  registerDiagnostics(provider: () => object): () => void;
376
+ registerInferenceCalls(source: InferenceCallSource): () => void;
369
377
  registerListModels(hook: (options: AssistantListModelsRequest) => Promise<AssistantModelInfoList>): () => void;
370
378
  registerDeleteModel(hook: (options: AssistantDeleteModelRequest) => Promise<AssistantDeleteModelResponse>): () => void;
371
379
  registerClearKvCache(hook: () => Promise<AssistantKvCacheDeletionResponse>): () => void;