@qvac/core 0.5.0 → 0.6.0

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 (383) hide show
  1. package/CHANGELOG.md +75 -1
  2. package/dist-lib/lib/api/agents.js +3 -2
  3. package/dist-lib/lib/api/app-config.d.ts +1 -1
  4. package/dist-lib/lib/api/app-config.js +54 -15
  5. package/dist-lib/lib/api/attachments.d.ts +6 -5
  6. package/dist-lib/lib/api/attachments.js +4 -2
  7. package/dist-lib/lib/api/chat.d.ts +7 -3
  8. package/dist-lib/lib/api/chat.js +4 -4
  9. package/dist-lib/lib/api/chunks.js +3 -3
  10. package/dist-lib/lib/api/config.js +2 -2
  11. package/dist-lib/lib/api/current-mesh.d.ts +3 -4
  12. package/dist-lib/lib/api/current-mesh.js +9 -4
  13. package/dist-lib/lib/api/custom-models.d.ts +8 -1
  14. package/dist-lib/lib/api/custom-models.js +53 -16
  15. package/dist-lib/lib/api/devices.d.ts +14 -5
  16. package/dist-lib/lib/api/devices.js +13 -8
  17. package/dist-lib/lib/api/diagnostics.d.ts +1 -0
  18. package/dist-lib/lib/api/diagnostics.js +1 -1
  19. package/dist-lib/lib/api/effective-ctx-size.d.ts +6 -1
  20. package/dist-lib/lib/api/effective-ctx-size.js +5 -3
  21. package/dist-lib/lib/api/execution.js +2 -1
  22. package/dist-lib/lib/api/files.js +2 -1
  23. package/dist-lib/lib/api/index.d.ts +5 -1
  24. package/dist-lib/lib/api/index.js +101 -102
  25. package/dist-lib/lib/api/instrument.js +29 -20
  26. package/dist-lib/lib/api/knowledge.d.ts +6 -5
  27. package/dist-lib/lib/api/knowledge.js +8 -6
  28. package/dist-lib/lib/api/local-files.js +1 -1
  29. package/dist-lib/lib/api/logs.js +6 -3
  30. package/dist-lib/lib/api/members.js +22 -13
  31. package/dist-lib/lib/api/mesh.js +3 -3
  32. package/dist-lib/lib/api/model-download.js +1 -1
  33. package/dist-lib/lib/api/network.d.ts +1 -0
  34. package/dist-lib/lib/api/network.js +1 -1
  35. package/dist-lib/lib/api/notifications.js +23 -13
  36. package/dist-lib/lib/api/rag.d.ts +6 -1
  37. package/dist-lib/lib/api/rag.js +20 -11
  38. package/dist-lib/lib/api/range.d.ts +2 -2
  39. package/dist-lib/lib/api/sync.js +1 -1
  40. package/dist-lib/lib/api/tool-activity.js +7 -3
  41. package/dist-lib/lib/api/tool-configs.js +2 -4
  42. package/dist-lib/lib/api/upload-frames.d.ts +7 -8
  43. package/dist-lib/lib/api/upload-frames.js +2 -1
  44. package/dist-lib/lib/api/watchable.d.ts +6 -1
  45. package/dist-lib/lib/api/watchable.js +23 -14
  46. package/dist-lib/lib/assistant/fetch-body.js +4 -2
  47. package/dist-lib/lib/assistant/harness.d.ts +48 -27
  48. package/dist-lib/lib/assistant/harness.js +40 -16
  49. package/dist-lib/lib/assistant/history.d.ts +9 -7
  50. package/dist-lib/lib/assistant/history.js +77 -42
  51. package/dist-lib/lib/assistant/message.d.ts +5 -3
  52. package/dist-lib/lib/assistant/message.js +4 -2
  53. package/dist-lib/lib/assistant/skill-encode.d.ts +3 -1
  54. package/dist-lib/lib/assistant/skill-encode.js +52 -62
  55. package/dist-lib/lib/assistant-client.js +7 -4
  56. package/dist-lib/lib/assistant-tree.js +27 -11
  57. package/dist-lib/lib/assistant.d.ts +30 -11
  58. package/dist-lib/lib/assistant.js +824 -378
  59. package/dist-lib/lib/audio-format.d.ts +1 -1
  60. package/dist-lib/lib/audio-format.js +1 -1
  61. package/dist-lib/lib/chat-title.js +9 -4
  62. package/dist-lib/lib/client.js +3 -2
  63. package/dist-lib/lib/collabora/convert.d.ts +2 -2
  64. package/dist-lib/lib/collabora/convert.js +6 -3
  65. package/dist-lib/lib/collabora/entry.js +9 -5
  66. package/dist-lib/lib/collabora/protocol.d.ts +2 -2
  67. package/dist-lib/lib/collabora/protocol.js +14 -7
  68. package/dist-lib/lib/collabora/worker.js +14 -7
  69. package/dist-lib/lib/compaction.d.ts +5 -6
  70. package/dist-lib/lib/compaction.js +14 -7
  71. package/dist-lib/lib/core/account-recovery.d.ts +4 -3
  72. package/dist-lib/lib/core/account-recovery.js +7 -4
  73. package/dist-lib/lib/core/agent.js +17 -15
  74. package/dist-lib/lib/core/approval-rules.d.ts +7 -6
  75. package/dist-lib/lib/core/approval-rules.js +12 -6
  76. package/dist-lib/lib/core/archived-mesh.d.ts +7 -5
  77. package/dist-lib/lib/core/archived-mesh.js +25 -22
  78. package/dist-lib/lib/core/async-iterable.js +10 -5
  79. package/dist-lib/lib/core/attachment-link.d.ts +2 -2
  80. package/dist-lib/lib/core/audio-attachment.js +1 -1
  81. package/dist-lib/lib/core/blind-peers.d.ts +2 -2
  82. package/dist-lib/lib/core/chat-activity.d.ts +2 -2
  83. package/dist-lib/lib/core/chat-activity.js +42 -21
  84. package/dist-lib/lib/core/chat-group.d.ts +8 -6
  85. package/dist-lib/lib/core/chat-group.js +17 -10
  86. package/dist-lib/lib/core/chat-order.d.ts +11 -9
  87. package/dist-lib/lib/core/chat-order.js +1 -3
  88. package/dist-lib/lib/core/chat-search.d.ts +4 -4
  89. package/dist-lib/lib/core/chat-search.js +38 -24
  90. package/dist-lib/lib/core/chat.d.ts +20 -14
  91. package/dist-lib/lib/core/chat.js +42 -28
  92. package/dist-lib/lib/core/chunk.d.ts +19 -23
  93. package/dist-lib/lib/core/chunk.js +27 -21
  94. package/dist-lib/lib/core/collections.d.ts +69 -0
  95. package/dist-lib/lib/core/collections.js +69 -0
  96. package/dist-lib/lib/core/contract/activity.d.ts +6 -2
  97. package/dist-lib/lib/core/contract/activity.js +15 -12
  98. package/dist-lib/lib/core/contract/agents.js +3 -2
  99. package/dist-lib/lib/core/contract/approval-rules.js +1 -1
  100. package/dist-lib/lib/core/contract/attestations.js +1 -1
  101. package/dist-lib/lib/core/contract/chat-group.js +1 -1
  102. package/dist-lib/lib/core/contract/chat.js +1 -1
  103. package/dist-lib/lib/core/contract/chunks.js +10 -9
  104. package/dist-lib/lib/core/contract/compute.js +2 -1
  105. package/dist-lib/lib/core/contract/devices.js +6 -5
  106. package/dist-lib/lib/core/contract/grant-order.js +5 -6
  107. package/dist-lib/lib/core/contract/index.js +4 -2
  108. package/dist-lib/lib/core/contract/indexing.js +3 -3
  109. package/dist-lib/lib/core/contract/invites.d.ts +8 -3
  110. package/dist-lib/lib/core/contract/invites.js +52 -26
  111. package/dist-lib/lib/core/contract/joined-meshes.js +3 -3
  112. package/dist-lib/lib/core/contract/knowledge.js +5 -5
  113. package/dist-lib/lib/core/contract/members.d.ts +13 -2
  114. package/dist-lib/lib/core/contract/members.js +46 -25
  115. package/dist-lib/lib/core/contract/mesh-kind.js +9 -8
  116. package/dist-lib/lib/core/contract/seal.js +1 -1
  117. package/dist-lib/lib/core/contract/seed-defaults.js +1 -3
  118. package/dist-lib/lib/core/contract/tool-activity.js +5 -5
  119. package/dist-lib/lib/core/contract/tool-configs.js +1 -2
  120. package/dist-lib/lib/core/contract/writers.d.ts +6 -1
  121. package/dist-lib/lib/core/contract/writers.js +55 -34
  122. package/dist-lib/lib/core/departures.js +16 -8
  123. package/dist-lib/lib/core/device-invites.js +3 -2
  124. package/dist-lib/lib/core/devices.js +6 -3
  125. package/dist-lib/lib/core/document-attachment.d.ts +20 -11
  126. package/dist-lib/lib/core/document-attachment.js +10 -5
  127. package/dist-lib/lib/core/files/attachments.d.ts +2 -5
  128. package/dist-lib/lib/core/files/attachments.js +6 -3
  129. package/dist-lib/lib/core/files/index.d.ts +44 -52
  130. package/dist-lib/lib/core/files/index.js +142 -93
  131. package/dist-lib/lib/core/files/knowledge.d.ts +2 -5
  132. package/dist-lib/lib/core/files/local-index.js +9 -5
  133. package/dist-lib/lib/core/files/preview/image.d.ts +0 -1
  134. package/dist-lib/lib/core/files/preview/image.js +9 -6
  135. package/dist-lib/lib/core/files/preview/index.d.ts +8 -11
  136. package/dist-lib/lib/core/files/preview/index.js +20 -15
  137. package/dist-lib/lib/core/files/processing/claims.d.ts +6 -5
  138. package/dist-lib/lib/core/files/processing/claims.js +16 -8
  139. package/dist-lib/lib/core/files/processing/document.d.ts +21 -50
  140. package/dist-lib/lib/core/files/processing/index.d.ts +18 -13
  141. package/dist-lib/lib/core/files/processing/index.js +65 -37
  142. package/dist-lib/lib/core/files/processing/ownership.d.ts +8 -1
  143. package/dist-lib/lib/core/files/processing/ownership.js +1 -1
  144. package/dist-lib/lib/core/files/processing/protocol.d.ts +19 -19
  145. package/dist-lib/lib/core/files/processing/protocol.js +5 -5
  146. package/dist-lib/lib/core/files/processing/settle.d.ts +10 -7
  147. package/dist-lib/lib/core/files/processing/settle.js +22 -11
  148. package/dist-lib/lib/core/files/processing/source.js +14 -8
  149. package/dist-lib/lib/core/files/processing/state.d.ts +13 -11
  150. package/dist-lib/lib/core/files/processing/state.js +19 -12
  151. package/dist-lib/lib/core/files/rag/build.d.ts +2 -2
  152. package/dist-lib/lib/core/files/rag/build.js +2 -1
  153. package/dist-lib/lib/core/files/rag/document-types.d.ts +4 -6
  154. package/dist-lib/lib/core/files/rag/index.d.ts +10 -13
  155. package/dist-lib/lib/core/files/rag/index.js +3 -2
  156. package/dist-lib/lib/core/files/rag/load.d.ts +10 -9
  157. package/dist-lib/lib/core/files/rag/load.js +26 -13
  158. package/dist-lib/lib/core/files/rag/policy.js +2 -1
  159. package/dist-lib/lib/core/files/rag/produce.js +33 -19
  160. package/dist-lib/lib/core/files/rag/retrieval/full-text.d.ts +5 -3
  161. package/dist-lib/lib/core/files/rag/retrieval/full-text.js +30 -10
  162. package/dist-lib/lib/core/files/records/chunks.js +4 -2
  163. package/dist-lib/lib/core/files/records/knowledge.d.ts +10 -11
  164. package/dist-lib/lib/core/files/records/knowledge.js +9 -8
  165. package/dist-lib/lib/core/files/records/linkage.js +6 -3
  166. package/dist-lib/lib/core/files/records/output.d.ts +5 -4
  167. package/dist-lib/lib/core/files/records/output.js +8 -4
  168. package/dist-lib/lib/core/files/records/reclaim.js +41 -25
  169. package/dist-lib/lib/core/files/records/routing.d.ts +4 -6
  170. package/dist-lib/lib/core/files/records/routing.js +15 -8
  171. package/dist-lib/lib/core/files/records/source.d.ts +5 -4
  172. package/dist-lib/lib/core/files/records/source.js +20 -14
  173. package/dist-lib/lib/core/files/records/sweep.js +1 -3
  174. package/dist-lib/lib/core/files/store/blob.d.ts +10 -10
  175. package/dist-lib/lib/core/files/store/blob.js +25 -19
  176. package/dist-lib/lib/core/files/store/index.d.ts +1 -6
  177. package/dist-lib/lib/core/files/store/index.js +4 -4
  178. package/dist-lib/lib/core/files/store/inline.d.ts +2 -2
  179. package/dist-lib/lib/core/files/store/inline.js +6 -3
  180. package/dist-lib/lib/core/files/store/reference.d.ts +6 -9
  181. package/dist-lib/lib/core/files/store/reference.js +25 -17
  182. package/dist-lib/lib/core/files/store/server.d.ts +7 -6
  183. package/dist-lib/lib/core/files/store/server.js +22 -11
  184. package/dist-lib/lib/core/files/store/sweep.js +13 -7
  185. package/dist-lib/lib/core/files/upload-input.d.ts +4 -12
  186. package/dist-lib/lib/core/files/upload-input.js +10 -5
  187. package/dist-lib/lib/core/files/upload.d.ts +27 -24
  188. package/dist-lib/lib/core/files/upload.js +74 -51
  189. package/dist-lib/lib/core/fs-drives.js +4 -2
  190. package/dist-lib/lib/core/grant-expiry.js +12 -7
  191. package/dist-lib/lib/core/handoff-channel.js +27 -13
  192. package/dist-lib/lib/core/harness-loan.js +35 -17
  193. package/dist-lib/lib/core/helpers/index.js +6 -2
  194. package/dist-lib/lib/core/hosted-agents.js +19 -12
  195. package/dist-lib/lib/core/id.js +1 -1
  196. package/dist-lib/lib/core/identity.js +6 -3
  197. package/dist-lib/lib/core/image/cache-sweep.d.ts +12 -10
  198. package/dist-lib/lib/core/image/cache-sweep.js +11 -6
  199. package/dist-lib/lib/core/image/normalize.d.ts +6 -0
  200. package/dist-lib/lib/core/image/normalize.js +12 -2
  201. package/dist-lib/lib/core/image/sniff.js +42 -21
  202. package/dist-lib/lib/core/inference-calls-receiver.js +7 -4
  203. package/dist-lib/lib/core/invite-grants.js +4 -2
  204. package/dist-lib/lib/core/invite.js +2 -1
  205. package/dist-lib/lib/core/local/files.js +20 -19
  206. package/dist-lib/lib/core/local/index.d.ts +69 -46
  207. package/dist-lib/lib/core/local/index.js +146 -129
  208. package/dist-lib/lib/core/membership.d.ts +12 -2
  209. package/dist-lib/lib/core/membership.js +55 -33
  210. package/dist-lib/lib/core/mesh-seed-handoff.js +7 -1
  211. package/dist-lib/lib/core/mesh.d.ts +37 -27
  212. package/dist-lib/lib/core/mesh.js +131 -73
  213. package/dist-lib/lib/core/migrations/agent-catalog.js +3 -2
  214. package/dist-lib/lib/core/migrations/agent-indexes.js +3 -3
  215. package/dist-lib/lib/core/migrations/file-index.js +7 -4
  216. package/dist-lib/lib/core/migrations/index.d.ts +4 -3
  217. package/dist-lib/lib/core/migrations/membership.js +9 -4
  218. package/dist-lib/lib/core/migrations/seal.js +3 -2
  219. package/dist-lib/lib/core/min-version.js +4 -2
  220. package/dist-lib/lib/core/next-frame.d.ts +5 -4
  221. package/dist-lib/lib/core/next-frame.js +6 -3
  222. package/dist-lib/lib/core/notification.d.ts +5 -1
  223. package/dist-lib/lib/core/notification.js +89 -77
  224. package/dist-lib/lib/core/ota-config.js +2 -1
  225. package/dist-lib/lib/core/pdf/rasterize.d.ts +18 -0
  226. package/dist-lib/lib/core/pdf/rasterize.js +57 -0
  227. package/dist-lib/lib/core/prompt-history.js +4 -2
  228. package/dist-lib/lib/core/range.d.ts +4 -4
  229. package/dist-lib/lib/core/range.js +12 -6
  230. package/dist-lib/lib/core/rank.d.ts +5 -4
  231. package/dist-lib/lib/core/rank.js +2 -1
  232. package/dist-lib/lib/core/send.d.ts +4 -4
  233. package/dist-lib/lib/core/send.js +6 -3
  234. package/dist-lib/lib/core/skill-overlay-receiver.js +7 -4
  235. package/dist-lib/lib/core/skill-secrets.js +16 -9
  236. package/dist-lib/lib/core/sync/chunks.js +2 -1
  237. package/dist-lib/lib/core/sync/devices.js +3 -1
  238. package/dist-lib/lib/core/sync/files.d.ts +2 -4
  239. package/dist-lib/lib/core/sync/files.js +28 -20
  240. package/dist-lib/lib/core/sync/index.d.ts +2 -5
  241. package/dist-lib/lib/core/sync/index.js +20 -15
  242. package/dist-lib/lib/core/sync-status.js +10 -7
  243. package/dist-lib/lib/core/system-info.js +4 -2
  244. package/dist-lib/lib/core/tool-activity.d.ts +4 -3
  245. package/dist-lib/lib/core/tool-activity.js +1 -1
  246. package/dist-lib/lib/core/tool-configs.js +12 -7
  247. package/dist-lib/lib/core.d.ts +38 -26
  248. package/dist-lib/lib/core.js +987 -539
  249. package/dist-lib/lib/credential-pusher.d.ts +12 -17
  250. package/dist-lib/lib/credential-pusher.js +61 -42
  251. package/dist-lib/lib/custom-model-pusher.d.ts +7 -3
  252. package/dist-lib/lib/custom-model-pusher.js +15 -7
  253. package/dist-lib/lib/custom-model-task.d.ts +1 -0
  254. package/dist-lib/lib/custom-model-task.js +12 -0
  255. package/dist-lib/lib/deadline.js +4 -2
  256. package/dist-lib/lib/diagnostics.d.ts +1 -5
  257. package/dist-lib/lib/frame-readable.d.ts +3 -0
  258. package/dist-lib/lib/frame-readable.js +3 -0
  259. package/dist-lib/lib/fs-drive-bridge.js +24 -14
  260. package/dist-lib/lib/fs-grants.js +13 -8
  261. package/dist-lib/lib/guards.d.ts +3 -0
  262. package/dist-lib/lib/guards.js +9 -0
  263. package/dist-lib/lib/inference-calls.d.ts +28 -23
  264. package/dist-lib/lib/inference-calls.js +25 -13
  265. package/dist-lib/lib/integrations/mcp-providers.d.ts +2 -2
  266. package/dist-lib/lib/integrations/setup-routes.d.ts +2 -2
  267. package/dist-lib/lib/knowledge-search.d.ts +6 -5
  268. package/dist-lib/lib/knowledge-search.js +26 -18
  269. package/dist-lib/lib/kv-cache-reclaim.js +4 -2
  270. package/dist-lib/lib/kv-cache.js +8 -4
  271. package/dist-lib/lib/legacy-core-domain.d.ts +42 -42
  272. package/dist-lib/lib/log-buffer.js +2 -1
  273. package/dist-lib/lib/log.js +25 -15
  274. package/dist-lib/lib/mesh-scoped-engine.js +12 -4
  275. package/dist-lib/lib/model-catalog-revision.js +6 -3
  276. package/dist-lib/lib/model-clamp.js +6 -3
  277. package/dist-lib/lib/model-context.d.ts +8 -3
  278. package/dist-lib/lib/model-context.js +13 -5
  279. package/dist-lib/lib/model-download-status.js +4 -2
  280. package/dist-lib/lib/model-download.d.ts +12 -4
  281. package/dist-lib/lib/model-download.js +200 -103
  282. package/dist-lib/lib/model-idle-pusher.d.ts +2 -2
  283. package/dist-lib/lib/model-idle-pusher.js +3 -4
  284. package/dist-lib/lib/oauth/browser-connect.d.ts +10 -8
  285. package/dist-lib/lib/oauth/browser-connect.js +33 -20
  286. package/dist-lib/lib/oauth/client.d.ts +2 -2
  287. package/dist-lib/lib/oauth/flow-core.js +23 -9
  288. package/dist-lib/lib/oauth/flow.d.ts +1 -3
  289. package/dist-lib/lib/oauth/flow.js +9 -5
  290. package/dist-lib/lib/oauth/keys.d.ts +4 -4
  291. package/dist-lib/lib/oauth/keys.js +18 -12
  292. package/dist-lib/lib/oauth/loopback.d.ts +2 -2
  293. package/dist-lib/lib/oauth/loopback.js +147 -107
  294. package/dist-lib/lib/oauth/loopback.stub.d.ts +2 -2
  295. package/dist-lib/lib/oauth/loopback.stub.js +1 -1
  296. package/dist-lib/lib/oauth/pkce.d.ts +4 -2
  297. package/dist-lib/lib/oauth/pkce.js +10 -0
  298. package/dist-lib/lib/oauth/providers.js +5 -5
  299. package/dist-lib/lib/oauth/redirect-types.d.ts +12 -7
  300. package/dist-lib/lib/oauth/register.js +3 -2
  301. package/dist-lib/lib/oauth/registry.d.ts +2 -2
  302. package/dist-lib/lib/oauth/registry.js +2 -1
  303. package/dist-lib/lib/oauth/resolve.d.ts +30 -10
  304. package/dist-lib/lib/oauth/resolve.js +12 -6
  305. package/dist-lib/lib/oauth/token-exchange-core.d.ts +12 -4
  306. package/dist-lib/lib/oauth/token-exchange-core.js +1 -1
  307. package/dist-lib/lib/oauth/types.d.ts +12 -12
  308. package/dist-lib/lib/oauth.d.ts +4 -5
  309. package/dist-lib/lib/oauth.js +2 -3
  310. package/dist-lib/lib/reconnecting-watch.d.ts +1 -1
  311. package/dist-lib/lib/reconnecting-watch.js +6 -6
  312. package/dist-lib/lib/retry-budget.js +6 -3
  313. package/dist-lib/lib/run-notices.d.ts +1 -0
  314. package/dist-lib/lib/run-notices.js +5 -2
  315. package/dist-lib/lib/run-transcript.d.ts +2 -4
  316. package/dist-lib/lib/run-transcript.js +4 -2
  317. package/dist-lib/lib/skill-readiness.js +4 -2
  318. package/dist-lib/lib/skill-types.d.ts +16 -16
  319. package/dist-lib/lib/suspend-lifecycle.d.ts +4 -4
  320. package/dist-lib/lib/suspend-lifecycle.js +10 -5
  321. package/dist-lib/lib/task.js +22 -12
  322. package/dist-lib/lib/unref.d.ts +3 -2
  323. package/dist-lib/lib/unref.js +2 -1
  324. package/dist-lib/lib/wav-duration.js +10 -5
  325. package/dist-lib/lib/write-queue.d.ts +5 -4
  326. package/dist-lib/lib/write-queue.js +2 -1
  327. package/dist-lib/schema/build.js +10 -6
  328. package/dist-lib/schema/config.d.ts +2 -3
  329. package/dist-lib/schema/content.d.ts +17 -2
  330. package/dist-lib/schema/content.js +2 -1
  331. package/dist-lib/schema/engine.d.ts +3 -2
  332. package/dist-lib/schema/engine.js +95 -6
  333. package/dist-lib/schema/field-order.js +22 -11
  334. package/dist-lib/schema/indexes.d.ts +22 -0
  335. package/dist-lib/schema/{helpers.js → indexes.js} +14 -57
  336. package/dist-lib/schema/local.d.ts +3 -2
  337. package/dist-lib/schema/local.js +7 -2
  338. package/dist-lib/schema/media-kind.d.ts +8 -0
  339. package/dist-lib/schema/media-kind.js +52 -0
  340. package/dist-lib/schema/qvac.d.ts +12 -9
  341. package/dist-lib/schema/qvac.js +8 -4
  342. package/dist-lib/spec/bind.js +12 -0
  343. package/dist-lib/spec/calls.js +4 -0
  344. package/dist-lib/spec/capabilities.d.ts +12 -4
  345. package/dist-lib/spec/hrpc/hrpc.json +54 -2
  346. package/dist-lib/spec/hrpc/index.js +53 -5
  347. package/dist-lib/spec/hrpc/messages.js +783 -494
  348. package/dist-lib/spec/hyperschema/index.js +783 -494
  349. package/dist-lib/spec/hyperschema/schema.json +247 -1
  350. package/dist-lib/spec/hyperschema/types.d.ts +69 -1
  351. package/dist-lib/spec/local/hyperdb/index.js +1 -1
  352. package/dist-lib/spec/local/hyperdb/messages.js +82 -14
  353. package/dist-lib/spec/local/hyperschema/index.js +42 -8
  354. package/dist-lib/spec/local/hyperschema/schema.json +27 -1
  355. package/dist-lib/spec/local/hyperschema/types.d.ts +6 -1
  356. package/dist-lib/spec/mesh/hyperdb/index.js +1 -1
  357. package/package.json +7 -3
  358. package/tui/app.mjs +2424 -941
  359. package/tui/boot.mjs +17 -46
  360. package/tui/index.mjs +10 -5
  361. package/tui/lib/boot-timing.mjs +8 -8
  362. package/tui/lib/busy-words.mjs +21 -22
  363. package/tui/lib/export.mjs +100 -32
  364. package/tui/lib/knowledge-command.mjs +64 -19
  365. package/tui/lib/knowledge-import.mjs +52 -18
  366. package/tui/lib/render.mjs +65 -33
  367. package/tui/lib/save-file.mjs +30 -13
  368. package/tui/lib/select.mjs +23 -5
  369. package/tui/lib/selection.mjs +6 -4
  370. package/tui/lib/setup.mjs +11 -19
  371. package/tui/lib/sidebar.mjs +23 -13
  372. package/tui/lib/splash.mjs +6 -7
  373. package/tui/lib/upload-frames.mjs +1 -2
  374. package/tui/lib/usage.mjs +13 -9
  375. package/tui/lib/wrap.mjs +35 -6
  376. package/tui/main.mjs +54 -78
  377. package/worker/assistant-sidecar.mjs +5 -10
  378. package/worker/stow-entry.mjs +7 -4
  379. package/dist-lib/lib/custom-model-source.d.ts +0 -15
  380. package/dist-lib/lib/custom-model-source.js +0 -46
  381. package/dist-lib/lib/oauth/common.d.ts +0 -38
  382. package/dist-lib/lib/oauth/common.js +0 -34
  383. package/dist-lib/schema/helpers.d.ts +0 -33
package/CHANGELOG.md CHANGED
@@ -13,6 +13,79 @@ release.
13
13
 
14
14
  ## [Unreleased]
15
15
 
16
+ ## [0.6.0] - 2026-09-28
17
+
18
+ ### Added
19
+
20
+ - Loading and unloading a model by hand, for a Models screen. `loadModel` loads
21
+ a downloaded model under the settings of the agent on this device that runs
22
+ it, so that agent's next reply finds it loaded; it never downloads, and returns
23
+ `loaded: false` with `reason: 'memory'` when it would not fit beside what is
24
+ loaded. Chat models loaded this way stay loaded side by side. `unloadModel`
25
+ puts a reply this device is generating with the model back in the queue, and it
26
+ completes once the model has been loaded again. Both bump `modelCatalogWatch`,
27
+ and `isLoaded` in `listModels` is right for chat, embedding, speech and
28
+ transcription models. A harness older than `@qvac/harness` 0.6 refuses both.
29
+
30
+ ```js
31
+ const { loaded, reason } = await engine.loadModel({ name: 'Qwen3.5-4B-Q4_K_M' })
32
+ await engine.unloadModel({ name: 'Qwen3.5-4B-Q4_K_M' })
33
+ ```
34
+
35
+ (#242)
36
+
37
+ - `previewCustomModel` checks a link or path through the harness before
38
+ anything is added, and returns the resolved link, size, context window,
39
+ architecture, size label, task type, license and fit, a file list for a
40
+ repository with several weights, or a refusal with its reason.
41
+ `customModelsWatch` rows carry `contextLength`, `taskType`, `license` and
42
+ `label`. (#215)
43
+ - An attached PDF's scanned, figure and text-less pages reach a vision model as
44
+ images, at most 10 per message, alongside the PDF as a document. A PDF whose
45
+ pages rendered is no longer reported as unread. Core now depends on
46
+ `bare-pdfium`. (#94)
47
+ - `setModelReleased({ name, released })` and `releasedModels` on the app
48
+ config: the models this device does not fetch ahead of need. (#189)
49
+
50
+ ### Changed
51
+
52
+ - A custom model is named by an id derived from its file (`custom:…`), not by
53
+ what the caller typed. `addCustomModel` takes a `label` in place of `name` and
54
+ returns `{ id }`, and `removeCustomModel`, `deleteModel` and an agent's
55
+ `modelName` take that id. `addCustomModel` runs the preview first and rejects
56
+ a refused source, a multi-weight repository or a model that is not a text
57
+ model, storing nothing; with no harness that can preview, it rejects.
58
+ `removeCustomModel` also frees the downloaded copy and answers with the
59
+ `deleteModel` summary in place of `{ ok }`. Needs `@qvac/harness` 0.6. See
60
+ [custom models](docs/api/custom-models.md). (#215)
61
+
62
+ ```js
63
+ // 0.5.0
64
+ await engine.addCustomModel({ name: 'Qwen3 small', src })
65
+ await engine.removeCustomModel({ name: 'Qwen3 small' })
66
+ // 0.6.0
67
+ const { id } = await engine.addCustomModel({ label: 'Qwen3 small', src })
68
+ await engine.removeCustomModel({ name: id })
69
+ ```
70
+
71
+ - `deleteModel` no longer has the model downloaded again straight away. It
72
+ stops an in-flight transfer and releases the model, which is fetched again
73
+ only when a run needs it or on `retryModelDownload`. (#189)
74
+ - `@qvac/harness` 0.6.0, with `@qvac/inference` 0.20.0. (#215)
75
+ - For a host embedding Core, `startOAuthLoopback` is now
76
+ `openOAuthLoopback(port, { credentialKey, state })`, and `waitForCode` no
77
+ longer takes the state. One server per fixed port is shared by every flow
78
+ redirecting to it. (#181)
79
+
80
+ ### Fixed
81
+
82
+ - Two OAuth flows landing on the same loopback port superseded each other, so
83
+ sibling skills of one provider could not connect at the same time. A callback
84
+ is now routed to the flow whose `state` it carries. (#181)
85
+ - `networkWatch` and `diagnosticsWatch` logged two churn lines a second on an
86
+ idle device. A sampled watch that wakes with the same answer is no longer
87
+ counted as churn, and a real burst is reported once per window. (#145)
88
+
16
89
  ## [0.5.0] - 2026-09-26
17
90
 
18
91
  ### Added
@@ -963,7 +1036,8 @@ Published under the `release-0.1` dist-tag.
963
1036
  await assistant.ready()
964
1037
  ```
965
1038
 
966
- [Unreleased]: https://github.com/tetherto/qvac-core/compare/v0.5.0...HEAD
1039
+ [Unreleased]: https://github.com/tetherto/qvac-core/compare/v0.6.0...HEAD
1040
+ [0.6.0]: https://github.com/tetherto/qvac-core/compare/v0.5.0...v0.6.0
967
1041
  [0.5.0]: https://github.com/tetherto/qvac-core/compare/v0.4.1...v0.5.0
968
1042
  [0.4.1]: https://github.com/tetherto/qvac-core/compare/v0.4.0...v0.4.1
969
1043
  [0.4.0]: https://github.com/tetherto/qvac-core/compare/v0.3.3...v0.4.0
@@ -32,8 +32,9 @@ export function createAgentsApi(pool, deviceId, computeLender = null) {
32
32
  getDefaultAgent: async ({ meshId, providerDeviceId }) => {
33
33
  const mesh = await requireMesh(pool, meshId);
34
34
  const agent = await getDefaultAgent(mesh, providerDeviceId ?? undefined);
35
- if (!agent)
35
+ if (!agent) {
36
36
  return {};
37
+ }
37
38
  return { agent: await withOrphaned(mesh, agent) };
38
39
  },
39
40
  updateAgent: async ({ agentId, meshId, config }) => {
@@ -44,6 +45,6 @@ export function createAgentsApi(pool, deviceId, computeLender = null) {
44
45
  const mesh = await requireMesh(pool, meshId);
45
46
  return withOrphaned(mesh, await deleteAgent(mesh, deviceId, agentId));
46
47
  },
47
- agentsWatch: meshWatchable('agentsWatch', pool, (request, mesh) => list(mesh, request.providerDeviceId ?? undefined))
48
+ agentsWatch: meshWatchable(pool, (request, mesh) => list(mesh, request.providerDeviceId ?? undefined), { name: 'agentsWatch' })
48
49
  };
49
50
  }
@@ -1,5 +1,5 @@
1
1
  import type { openLocalStore } from '../core/local/index.ts';
2
2
  import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
3
3
  type LocalStore = Awaited<ReturnType<typeof openLocalStore>>;
4
- export declare function createAppConfigApi(state: LocalStore): Pick<CapabilityHandlers, 'getConfig' | 'setConfig' | 'setModelPaused' | 'configWatchTyped'>;
4
+ export declare function createAppConfigApi(state: LocalStore): Pick<CapabilityHandlers, 'getConfig' | 'setConfig' | 'setModelPaused' | 'setModelReleased' | 'configWatchTyped'>;
5
5
  export {};
@@ -1,3 +1,4 @@
1
+ import * as z from 'zod';
1
2
  import { watchable } from './watchable.js';
2
3
  const EMPTY_CAPABILITIES = {
3
4
  chat: false,
@@ -20,14 +21,30 @@ const DEFAULT_CONFIG = {
20
21
  lastModelName: null,
21
22
  onboardingCompleted: false,
22
23
  delegation: EMPTY_DELEGATION,
23
- pausedModels: []
24
+ pausedModels: [],
25
+ releasedModels: []
24
26
  };
27
+ const DelegationSchema = z.object({
28
+ enabled: z.boolean().optional(),
29
+ targetDeviceId: z.string().nullish(),
30
+ targetAgentId: z.string().nullish(),
31
+ capabilities: z
32
+ .object({
33
+ chat: z.boolean().optional(),
34
+ transcription: z.boolean().optional(),
35
+ tts: z.boolean().optional(),
36
+ embeddings: z.boolean().optional(),
37
+ knowledge: z.boolean().optional()
38
+ })
39
+ .nullish()
40
+ });
25
41
  function normalizeDelegation(raw) {
26
- if (!raw || typeof raw !== 'object') {
42
+ const parsed = DelegationSchema.safeParse(raw);
43
+ if (!parsed.success) {
27
44
  return { ...EMPTY_DELEGATION, capabilities: { ...EMPTY_CAPABILITIES } };
28
45
  }
29
- const d = raw;
30
- const c = (d.capabilities ?? {});
46
+ const d = parsed.data;
47
+ const c = d.capabilities ?? EMPTY_CAPABILITIES;
31
48
  return {
32
49
  enabled: d.enabled ?? false,
33
50
  targetDeviceId: d.targetDeviceId ?? null,
@@ -42,8 +59,9 @@ function normalizeDelegation(raw) {
42
59
  };
43
60
  }
44
61
  function toConfig(row) {
45
- if (!row)
62
+ if (!row) {
46
63
  return { ...DEFAULT_CONFIG, delegation: normalizeDelegation(null) };
64
+ }
47
65
  return {
48
66
  activeAgentId: row.activeAgentId ?? null,
49
67
  activeChatId: row.activeChatId ?? null,
@@ -52,7 +70,8 @@ function toConfig(row) {
52
70
  lastModelName: row.lastModelName ?? null,
53
71
  onboardingCompleted: row.onboardingCompleted ?? false,
54
72
  delegation: normalizeDelegation(row.delegation),
55
- pausedModels: row.pausedModels ?? []
73
+ pausedModels: row.pausedModels ?? [],
74
+ releasedModels: row.releasedModels ?? []
56
75
  };
57
76
  }
58
77
  function applyWrite(current, update) {
@@ -64,9 +83,20 @@ function applyWrite(current, update) {
64
83
  lastModelName: current.lastModelName,
65
84
  onboardingCompleted: update.onboardingCompleted ?? false,
66
85
  delegation: normalizeDelegation(update.delegation),
67
- pausedModels: current.pausedModels
86
+ pausedModels: current.pausedModels,
87
+ releasedModels: current.releasedModels
68
88
  };
69
89
  }
90
+ function toggled(names, name, on) {
91
+ const set = new Set(names);
92
+ if (on) {
93
+ set.add(name);
94
+ }
95
+ else {
96
+ set.delete(name);
97
+ }
98
+ return [...set];
99
+ }
70
100
  async function readConfig(state) {
71
101
  return toConfig(await state.getAppConfigRow());
72
102
  }
@@ -79,7 +109,8 @@ function toRow(config) {
79
109
  lastModelName: config.lastModelName,
80
110
  onboardingCompleted: config.onboardingCompleted,
81
111
  delegation: config.delegation,
82
- pausedModels: config.pausedModels
112
+ pausedModels: config.pausedModels,
113
+ releasedModels: config.releasedModels
83
114
  };
84
115
  }
85
116
  export function createAppConfigApi(state) {
@@ -94,15 +125,23 @@ export function createAppConfigApi(state) {
94
125
  async setModelPaused(input) {
95
126
  const row = await state.updateAppConfigRow((current) => {
96
127
  const config = toConfig(current);
97
- const paused = new Set(config.pausedModels);
98
- if (input.paused)
99
- paused.add(input.name);
100
- else
101
- paused.delete(input.name);
102
- return toRow({ ...config, pausedModels: [...paused] });
128
+ return toRow({
129
+ ...config,
130
+ pausedModels: toggled(config.pausedModels ?? [], input.name, input.paused ?? false)
131
+ });
132
+ });
133
+ return toConfig(row);
134
+ },
135
+ async setModelReleased(input) {
136
+ const row = await state.updateAppConfigRow((current) => {
137
+ const config = toConfig(current);
138
+ return toRow({
139
+ ...config,
140
+ releasedModels: toggled(config.releasedModels ?? [], input.name, input.released ?? false)
141
+ });
103
142
  });
104
143
  return toConfig(row);
105
144
  },
106
- configWatchTyped: watchable('configWatchTyped', () => state, () => readConfig(state))
145
+ configWatchTyped: watchable(() => state, () => readConfig(state), { name: 'configWatchTyped' })
107
146
  };
108
147
  }
@@ -1,8 +1,9 @@
1
1
  import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
2
2
  import { type MeshPool } from './current-mesh.ts';
3
3
  export { MAX_ATTACHMENT_BYTES } from '../core/files/attachments.ts';
4
- export declare function createAttachmentsApi(pool: MeshPool, options?: {
5
- maxBytes?: number;
6
- deviceId?: Buffer | null;
7
- inactivityMs?: number;
8
- }): Pick<CapabilityHandlers, 'uploadAttachment' | 'downloadAttachment' | 'deleteAttachment'>;
4
+ export interface CreateAttachmentsApiOptions {
5
+ readonly maxBytes?: number;
6
+ readonly deviceId?: Buffer | null;
7
+ readonly inactivityMs?: number;
8
+ }
9
+ export declare function createAttachmentsApi(pool: MeshPool, options?: CreateAttachmentsApiOptions): Pick<CapabilityHandlers, 'uploadAttachment' | 'downloadAttachment' | 'deleteAttachment'>;
@@ -5,10 +5,12 @@ export function createAttachmentsApi(pool, options = {}) {
5
5
  return {
6
6
  async *uploadAttachment(frames) {
7
7
  const upload = await openUpload(frames);
8
- if (!upload)
8
+ if (!upload) {
9
9
  return;
10
- if (!upload.first.meshId)
10
+ }
11
+ if (!upload.first.meshId) {
11
12
  throw new Error(UPLOAD_NAMES_NO_MESH);
13
+ }
12
14
  const mesh = await requireMesh(pool, upload.first.meshId);
13
15
  yield* mesh.files.attachments(options).uploadAttachment(upload.rest);
14
16
  },
@@ -3,7 +3,11 @@ import type { openLocalStore } from '../core/local/index.ts';
3
3
  import { type MeshPool } from './current-mesh.ts';
4
4
  type LocalStore = ReturnType<typeof openLocalStore>;
5
5
  type ChatCapabilities = Pick<CapabilityHandlers, 'createChat' | 'listChats' | 'getChat' | 'renameChat' | 'setChatRagEnabled' | 'setChatWebSearchEnabled' | 'deleteChat' | 'chatsWatch' | 'listChatActivity' | 'chatActivityWatch' | 'searchChats'>;
6
- export declare function createChatApi(pool: MeshPool, deviceId: Buffer | null, local: LocalStore, inferenceCalls?: {
7
- forget(chatId: string): Promise<void>;
8
- } | null): ChatCapabilities;
6
+ export interface CreateChatApiOptions {
7
+ readonly deviceId: Buffer | null;
8
+ readonly inferenceCalls?: {
9
+ forget(chatId: string): Promise<void>;
10
+ } | null;
11
+ }
12
+ export declare function createChatApi(pool: MeshPool, local: LocalStore, { deviceId, inferenceCalls }: CreateChatApiOptions): ChatCapabilities;
9
13
  export {};
@@ -5,7 +5,7 @@ import { listChatPage } from '../core/chat-order.js';
5
5
  import { searchChats } from '../core/chat-search.js';
6
6
  import { meshWatchable, requireMesh } from './current-mesh.js';
7
7
  const SEARCH_SUPERSEDED_ABORT = 'superseded by a newer chat search';
8
- export function createChatApi(pool, deviceId, local, inferenceCalls = null) {
8
+ export function createChatApi(pool, local, { deviceId, inferenceCalls = null }) {
9
9
  let searchAbort = null;
10
10
  const chatList = (mesh, { limit, cursor }) => listChatPage(mesh, local, { limit: limit || undefined, cursor: cursor ?? undefined });
11
11
  const chatActivity = (mesh, chatIds) => listChatActivity(mesh, chatIds ?? undefined).then((activities) => ({ activities }));
@@ -14,16 +14,16 @@ export function createChatApi(pool, deviceId, local, inferenceCalls = null) {
14
14
  listChats: async (request) => chatList(await requireMesh(pool, request.meshId), request),
15
15
  getChat: async ({ chatId, meshId }) => mustGetActiveChatListing(await requireMesh(pool, meshId), chatId),
16
16
  renameChat: async ({ chatId, meshId, config }) => renameChat(await requireMesh(pool, meshId), chatId, config.title),
17
- setChatRagEnabled: async ({ chatId, enabled, meshId }) => setChatRagEnabled(await requireMesh(pool, meshId), chatId, enabled ?? false),
17
+ setChatRagEnabled: async ({ chatId, enabled, meshId }) => setChatRagEnabled(await requireMesh(pool, meshId), chatId, { ragEnabled: enabled ?? false }),
18
18
  setChatWebSearchEnabled: async ({ chatId, enabled, meshId }) => setChatWebSearchEnabled(await requireMesh(pool, meshId), chatId, enabled ?? false),
19
19
  deleteChat: async ({ chatId, meshId }) => {
20
20
  const deleted = await deleteChat(await requireMesh(pool, meshId), deviceId, chatId);
21
21
  await inferenceCalls?.forget(chatId);
22
22
  return deleted;
23
23
  },
24
- chatsWatch: meshWatchable('chatsWatch', pool, (request, store) => chatList(store, request), local),
24
+ chatsWatch: meshWatchable(pool, (request, store) => chatList(store, request), { name: 'chatsWatch', changes: local }),
25
25
  listChatActivity: async (input) => chatActivity(await requireMesh(pool, input.meshId), input.chatIds),
26
- chatActivityWatch: meshWatchable('chatActivityWatch', pool, (request, store) => chatActivity(store, request.chatIds)),
26
+ chatActivityWatch: meshWatchable(pool, (request, store) => chatActivity(store, request.chatIds), { name: 'chatActivityWatch' }),
27
27
  searchChats: async (input) => {
28
28
  searchAbort?.abort(SEARCH_SUPERSEDED_ABORT);
29
29
  const controller = new AbortController();
@@ -31,10 +31,10 @@ export function createChunksApi(pool, deviceId) {
31
31
  });
32
32
  return { chunks: await recordLinks(mesh, chunks) };
33
33
  },
34
- chunksWatch: meshWatchable('chunksWatch', pool, async ({ meshId, ...input }, mesh) => ({
34
+ chunksWatch: meshWatchable(pool, async ({ meshId, ...input }, mesh) => ({
35
35
  chunks: await recordLinks(mesh, await listChunks(mesh, chunkSelection(input)))
36
- })),
37
- runRequestsWatch: meshWatchable('runRequestsWatch', pool, async (_request, mesh) => ({ chunks: await listRunRequests(mesh, deviceId) }))
36
+ }), { name: 'chunksWatch' }),
37
+ runRequestsWatch: meshWatchable(pool, async (_request, mesh) => ({ chunks: await listRunRequests(mesh, deviceId) }), { name: 'runRequestsWatch' })
38
38
  };
39
39
  }
40
40
  function chunkSelection({ chatId, type, types, ...rest }) {
@@ -8,8 +8,8 @@ export function createConfigApi(state) {
8
8
  await state.set(key, value);
9
9
  return { ok: true };
10
10
  },
11
- configWatch: watchable('configWatch', () => state, async ({ key }) => ({
11
+ configWatch: watchable(() => state, async ({ key }) => ({
12
12
  value: await state.get(key)
13
- }))
13
+ }), { name: 'configWatch' })
14
14
  };
15
15
  }
@@ -1,12 +1,11 @@
1
+ import type { Readable } from 'streamx';
1
2
  import type { Mesh } from '../core/mesh.ts';
3
+ import { type WatchableOptions } from './watchable.ts';
2
4
  export type MeshPool = (meshId: string) => Mesh | null | Promise<Mesh | null>;
3
5
  export declare const NO_SUCH_MESH = "no such mesh";
4
6
  export declare function requireMesh(pool: MeshPool, meshId: string): Promise<Mesh>;
5
7
  export declare function isMissingMesh(err: unknown): boolean;
6
- export declare function meshWatchable<TRequest extends MeshScoped, TResult>(name: string, pool: MeshPool, query: (request: TRequest, mesh: Mesh) => Promise<TResult>, changes?: {
7
- watch(listener: () => void): void;
8
- unwatch(listener: () => void): void;
9
- }): (request: TRequest) => import("streamx").Readable<import("streamx").ReadableEvents> & AsyncIterable<TResult>;
8
+ export declare function meshWatchable<TRequest extends MeshScoped, TResult>(pool: MeshPool, query: (request: TRequest, mesh: Mesh) => Promise<TResult>, { name, changes }: WatchableOptions): (request: TRequest) => Readable & AsyncIterable<TResult>;
10
9
  interface MeshScoped {
11
10
  readonly meshId: string;
12
11
  }
@@ -2,15 +2,20 @@ import { watchable } from './watchable.js';
2
2
  export const NO_SUCH_MESH = 'no such mesh';
3
3
  export async function requireMesh(pool, meshId) {
4
4
  const mesh = await pool(meshId);
5
- if (!mesh)
5
+ if (!mesh) {
6
6
  throw new Error(`${NO_SUCH_MESH}: ${meshId}`);
7
- if (!mesh.opened)
7
+ }
8
+ if (!mesh.opened) {
8
9
  await mesh.ready();
10
+ }
9
11
  return mesh;
10
12
  }
11
13
  export function isMissingMesh(err) {
12
14
  return err instanceof Error && err.message.startsWith(`${NO_SUCH_MESH}: `);
13
15
  }
14
- export function meshWatchable(name, pool, query, changes) {
15
- return watchable(name, (request) => requireMesh(pool, request.meshId), query, changes);
16
+ export function meshWatchable(pool, query, { name, changes }) {
17
+ return watchable((request) => requireMesh(pool, request.meshId), query, {
18
+ name,
19
+ changes
20
+ });
16
21
  }
@@ -1,5 +1,12 @@
1
+ import type { AssistantCustomModelPreview, AssistantDeleteModelResponse, AssistantPreviewCustomModelRequest } from '../../spec/hyperschema/types.d.ts';
1
2
  import type { openLocalStore } from '../core/local/index.ts';
2
3
  import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
3
4
  type LocalStore = Awaited<ReturnType<typeof openLocalStore>>;
4
- export declare function createCustomModelApi(state: LocalStore): Pick<CapabilityHandlers, 'customModelsWatch' | 'addCustomModel' | 'removeCustomModel'>;
5
+ export declare const CUSTOM_MODEL_ID_PREFIX = "custom:";
6
+ export declare function customModelId(src: string): string;
7
+ export type CustomModelFileDelete = (request: {
8
+ name: string;
9
+ }) => Promise<AssistantDeleteModelResponse>;
10
+ export type CustomModelPreviewSource = (request: AssistantPreviewCustomModelRequest) => Promise<AssistantCustomModelPreview>;
11
+ export declare function createCustomModelApi(state: LocalStore, preview: CustomModelPreviewSource | null, deleteFiles?: CustomModelFileDelete | null): Pick<CapabilityHandlers, 'customModelsWatch' | 'addCustomModel' | 'removeCustomModel' | 'previewCustomModel'>;
5
12
  export {};
@@ -1,5 +1,11 @@
1
+ import b4a from 'b4a';
2
+ import crypto from 'hypercore-crypto';
1
3
  import { watchable } from './watchable.js';
2
- import { normalizeModelSource, probeModelSource } from '../custom-model-source.js';
4
+ import { customModelTaskRefusal } from '../custom-model-task.js';
5
+ export const CUSTOM_MODEL_ID_PREFIX = 'custom:';
6
+ export function customModelId(src) {
7
+ return CUSTOM_MODEL_ID_PREFIX + b4a.toHex(crypto.hash(b4a.from(src))).slice(0, 12);
8
+ }
3
9
  async function readCustomModels(state) {
4
10
  const rows = await state.getCustomModelRows();
5
11
  return {
@@ -11,35 +17,66 @@ async function readCustomModels(state) {
11
17
  supportsThinking: row.supportsThinking ?? false,
12
18
  supportsVision: row.supportsVision ?? false,
13
19
  expectedSize: row.expectedSize ?? 0,
14
- createdAt: row.createdAt
20
+ createdAt: row.createdAt,
21
+ contextLength: row.contextLength ?? 0,
22
+ taskType: row.taskType ?? null,
23
+ license: row.license ?? null,
24
+ label: row.label || row.name
15
25
  }))
16
26
  };
17
27
  }
18
- export function createCustomModelApi(state) {
28
+ export function createCustomModelApi(state, preview, deleteFiles = null) {
29
+ const previewSource = async (request) => {
30
+ if (!preview)
31
+ throw new Error('no model source preview bound');
32
+ return await preview(request);
33
+ };
19
34
  return {
20
- customModelsWatch: watchable('customModelsWatch', () => state, () => readCustomModels(state)),
35
+ customModelsWatch: watchable(() => state, () => readCustomModels(state), { name: 'customModelsWatch' }),
36
+ previewCustomModel: previewSource,
21
37
  addCustomModel: async (input) => {
22
- const src = normalizeModelSource(input.src);
23
- const mmprojSrc = input.mmprojSrc ? normalizeModelSource(input.mmprojSrc) : null;
24
- const expectedSize = input.expectedSize && input.expectedSize > 0
25
- ? input.expectedSize
26
- : await probeModelSource(src);
38
+ const checked = await previewSource({ src: input.src, mmprojSrc: input.mmprojSrc });
39
+ if (!checked.ok) {
40
+ throw new Error(checked.reason || 'The model source was refused.');
41
+ }
42
+ if (!checked.src) {
43
+ throw new Error('This repository holds several models; add one of its files.');
44
+ }
45
+ const unrunnable = customModelTaskRefusal(checked.taskType);
46
+ if (unrunnable) {
47
+ throw new Error(unrunnable);
48
+ }
49
+ const id = customModelId(checked.src);
50
+ const label = input.label.trim();
51
+ const taken = (await state.getCustomModelRows()).find((row) => (row.label || row.name) === label && row.name !== id);
52
+ if (taken) {
53
+ throw new Error(`${label} is already the name of another model you added.`);
54
+ }
27
55
  const row = {
28
- name: input.name,
29
- src,
30
- mmprojSrc,
56
+ name: id,
57
+ label,
58
+ src: checked.src,
59
+ mmprojSrc: checked.mmprojSrc ?? null,
31
60
  supportsTools: input.supportsTools ?? false,
32
61
  supportsThinking: input.supportsThinking ?? false,
33
62
  supportsVision: input.supportsVision ?? false,
34
- expectedSize,
35
- createdAt: Date.now()
63
+ expectedSize: input.expectedSize && input.expectedSize > 0
64
+ ? input.expectedSize
65
+ : (checked.sizeBytes ?? 0),
66
+ createdAt: Date.now(),
67
+ contextLength: checked.contextLength ?? 0,
68
+ taskType: checked.taskType ?? null,
69
+ license: checked.license ?? null
36
70
  };
37
71
  await state.putCustomModelRow(row);
38
- return { ok: true };
72
+ return { id };
39
73
  },
40
74
  removeCustomModel: async ({ name }) => {
75
+ const rows = await state.getCustomModelRows();
76
+ const custom = rows.some((row) => row.name === name);
77
+ const freed = deleteFiles && custom ? await deleteFiles({ name }) : { name, removed: 0, freedBytes: 0 };
41
78
  await state.deleteCustomModelRow(name);
42
- return { ok: true };
79
+ return freed;
43
80
  }
44
81
  };
45
82
  }
@@ -2,8 +2,17 @@ import type { AssistantCapabilityProfile } from '../../spec/hyperschema/types.d.
2
2
  import type { Mesh } from '../core/mesh.ts';
3
3
  import { type MeshPool } from './current-mesh.ts';
4
4
  import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
5
- export declare function createDevicesApi(pool: MeshPool, deviceId: Buffer, removeWriter: (writerKey: Buffer, deviceId: Buffer, mesh: Mesh) => Promise<void>, renameLocal: (name: string) => Promise<void>, saveProfileLocal: (capabilityProfile: AssistantCapabilityProfile, recommendedModelName: string, platform?: string) => Promise<void>, readLocalProfile: () => {
6
- capabilityProfile: AssistantCapabilityProfile;
7
- recommendedModelName: string;
8
- platform?: string;
9
- } | null, isAccount: (mesh: Mesh) => boolean, computeLender?: (() => Promise<Buffer | null>) | null): Pick<CapabilityHandlers, 'listDevices' | 'getDevice' | 'devicesWatch' | 'deviceInfo' | 'saveDeviceCapabilities' | 'saveDeviceProfile' | 'removeDevice' | 'renameDevice'>;
5
+ export interface CreateDevicesApiOptions {
6
+ readonly deviceId: Buffer;
7
+ readonly removeWriter: (writerKey: Buffer, deviceId: Buffer, mesh: Mesh) => Promise<void>;
8
+ readonly renameLocal: (name: string) => Promise<void>;
9
+ readonly saveProfileLocal: (capabilityProfile: AssistantCapabilityProfile, recommendedModelName: string, platform?: string) => Promise<void>;
10
+ readonly readLocalProfile: () => {
11
+ capabilityProfile: AssistantCapabilityProfile;
12
+ recommendedModelName: string;
13
+ platform?: string;
14
+ } | null;
15
+ readonly isAccount: (mesh: Mesh) => boolean;
16
+ readonly computeLender?: (() => Promise<Buffer | null>) | null;
17
+ }
18
+ export declare function createDevicesApi(pool: MeshPool, { deviceId, removeWriter, renameLocal, saveProfileLocal, readLocalProfile, isAccount, computeLender }: CreateDevicesApiOptions): Pick<CapabilityHandlers, 'listDevices' | 'getDevice' | 'devicesWatch' | 'deviceInfo' | 'saveDeviceCapabilities' | 'saveDeviceProfile' | 'removeDevice' | 'renameDevice'>;
@@ -2,7 +2,7 @@ import { MAX_DEVICE_NAME_CHARS, deviceNameWithinBounds } from '../../schema/qvac
2
2
  import { saveDeviceCapabilities } from '../core/devices.js';
3
3
  import { meshWatchable, requireMesh } from './current-mesh.js';
4
4
  import b4a from 'b4a';
5
- const DEVICES = '@qvac/devices';
5
+ import { DEVICES } from '../core/collections.js';
6
6
  function toEngineDevice(device, overrides = {}) {
7
7
  return {
8
8
  id: device.id,
@@ -25,13 +25,14 @@ function toEngineDevice(device, overrides = {}) {
25
25
  ...overrides
26
26
  };
27
27
  }
28
- export function createDevicesApi(pool, deviceId, removeWriter, renameLocal, saveProfileLocal, readLocalProfile, isAccount, computeLender = null) {
28
+ export function createDevicesApi(pool, { deviceId, removeWriter, renameLocal, saveProfileLocal, readLocalProfile, isAccount, computeLender = null }) {
29
29
  const mustGetDevice = async (mesh, id) => {
30
30
  const snap = mesh.view.snapshot();
31
31
  try {
32
32
  const device = await snap.get(DEVICES, { id });
33
- if (!device)
33
+ if (!device) {
34
34
  throw new Error(`device not found: ${b4a.toHex(id)}`);
35
+ }
35
36
  return device;
36
37
  }
37
38
  finally {
@@ -51,7 +52,7 @@ export function createDevicesApi(pool, deviceId, removeWriter, renameLocal, save
51
52
  return {
52
53
  listDevices: async (request) => list(await requireMesh(pool, request.meshId)),
53
54
  getDevice: async ({ deviceId: id, meshId }) => toEngineDevice(await mustGetDevice(await requireMesh(pool, meshId), id)),
54
- devicesWatch: meshWatchable('devicesWatch', pool, (_request, mesh) => list(mesh)),
55
+ devicesWatch: meshWatchable(pool, (_request, mesh) => list(mesh), { name: 'devicesWatch' }),
55
56
  deviceInfo: async () => {
56
57
  logger.info(['api', 'devices'], 'deviceInfo handler reached');
57
58
  const computeLenderId = (await computeLender?.()) ?? undefined;
@@ -70,21 +71,25 @@ export function createDevicesApi(pool, deviceId, removeWriter, renameLocal, save
70
71
  return { ok: true };
71
72
  },
72
73
  removeDevice: async ({ deviceId: target, meshId }) => {
73
- if (target.equals(deviceId))
74
+ if (b4a.equals(target, deviceId)) {
74
75
  throw new Error('cannot remove own device, use leaveMesh');
76
+ }
75
77
  const mesh = await requireMesh(pool, meshId);
76
78
  const device = await mustGetDevice(mesh, target);
77
- if (device.revoked)
79
+ if (device.revoked) {
78
80
  return { ok: true };
79
- if (!device.writerKey)
81
+ }
82
+ if (!device.writerKey) {
80
83
  throw new Error('device has no writer key, cannot remove');
84
+ }
81
85
  await removeWriter(device.writerKey, target, mesh);
82
86
  return { ok: true };
83
87
  },
84
88
  renameDevice: async ({ meshId, config }) => {
85
89
  const trimmed = config.name.trim();
86
- if (!trimmed)
90
+ if (!trimmed) {
87
91
  throw new Error('device name must not be empty');
92
+ }
88
93
  if (!deviceNameWithinBounds(trimmed)) {
89
94
  throw new Error(`device name must be at most ${MAX_DEVICE_NAME_CHARS} characters`);
90
95
  }
@@ -3,5 +3,6 @@ export interface DiagnosticsSource {
3
3
  watch(listener: () => void): void;
4
4
  unwatch(listener: () => void): void;
5
5
  snapshot(): Record<string, unknown>;
6
+ readonly sampled: true;
6
7
  }
7
8
  export declare function createDiagnosticsApi(source: DiagnosticsSource): Pick<CapabilityHandlers, 'diagnostics' | 'diagnosticsWatch'>;
@@ -2,6 +2,6 @@ import { watchable } from './watchable.js';
2
2
  export function createDiagnosticsApi(source) {
3
3
  return {
4
4
  diagnostics: async () => ({ stats: source.snapshot() }),
5
- diagnosticsWatch: watchable('diagnosticsWatch', () => source, async () => ({ stats: source.snapshot() }))
5
+ diagnosticsWatch: watchable(() => source, async () => ({ stats: source.snapshot() }), { name: 'diagnosticsWatch' })
6
6
  };
7
7
  }
@@ -1,2 +1,7 @@
1
1
  import type { QvacAgent } from '../../spec/mesh/hyperschema/types.d.ts';
2
- export declare function effectiveCtxSize(agent: Pick<QvacAgent, 'ctxSize' | 'modelName'> | null, appCtxSize: number, platform: string | null): number;
2
+ import { type ModelContextOptions } from '../model-context.ts';
3
+ export interface EffectiveCtxSizeOptions extends ModelContextOptions {
4
+ readonly appCtxSize: number;
5
+ readonly platform: string | null;
6
+ }
7
+ export declare function effectiveCtxSize(agent: Pick<QvacAgent, 'ctxSize' | 'modelName'> | null, opts: EffectiveCtxSizeOptions): number;
@@ -1,10 +1,12 @@
1
1
  import { defaultContextForModel, MOBILE_CONTEXT_SIZE, MODEL_CONTEXT_TARGET, modelContextTargetForPlatform } from '../model-context.js';
2
- export function effectiveCtxSize(agent, appCtxSize, platform) {
2
+ export function effectiveCtxSize(agent, opts) {
3
+ const { appCtxSize, platform, custom } = opts;
3
4
  const configured = agent?.ctxSize || appCtxSize;
4
- if (configured)
5
+ if (configured) {
5
6
  return configured;
7
+ }
6
8
  if (modelContextTargetForPlatform(platform) === MODEL_CONTEXT_TARGET.mobile) {
7
9
  return MOBILE_CONTEXT_SIZE;
8
10
  }
9
- return defaultContextForModel(agent?.modelName ?? '');
11
+ return defaultContextForModel(agent?.modelName ?? '', MODEL_CONTEXT_TARGET.desktop, { custom });
10
12
  }
@@ -36,8 +36,9 @@ export function createExecutionApi(pool, deviceId) {
36
36
  const mesh = await requireMesh(pool, meshId);
37
37
  const statuses = await listChunks(mesh, { chatId, type: 'run-status' });
38
38
  const settled = statuses.some((c) => c.runId === runId && TERMINAL_STATES.has(c.runStatus?.state ?? ''));
39
- if (settled)
39
+ if (settled) {
40
40
  return { ok: true };
41
+ }
41
42
  await appendChunk(mesh, {
42
43
  chatId,
43
44
  runId,