@qvac/core 0.4.1 → 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 (417) hide show
  1. package/CHANGELOG.md +262 -1
  2. package/README.md +1 -1
  3. package/dist-lib/lib/api/agents.js +3 -2
  4. package/dist-lib/lib/api/app-config.d.ts +1 -1
  5. package/dist-lib/lib/api/app-config.js +54 -15
  6. package/dist-lib/lib/api/attachments.d.ts +6 -5
  7. package/dist-lib/lib/api/attachments.js +4 -2
  8. package/dist-lib/lib/api/chat.d.ts +7 -3
  9. package/dist-lib/lib/api/chat.js +4 -4
  10. package/dist-lib/lib/api/chunks.js +3 -3
  11. package/dist-lib/lib/api/config.js +2 -2
  12. package/dist-lib/lib/api/current-mesh.d.ts +3 -4
  13. package/dist-lib/lib/api/current-mesh.js +9 -4
  14. package/dist-lib/lib/api/custom-models.d.ts +8 -1
  15. package/dist-lib/lib/api/custom-models.js +53 -16
  16. package/dist-lib/lib/api/devices.d.ts +14 -5
  17. package/dist-lib/lib/api/devices.js +14 -9
  18. package/dist-lib/lib/api/diagnostics.d.ts +1 -0
  19. package/dist-lib/lib/api/diagnostics.js +1 -1
  20. package/dist-lib/lib/api/effective-ctx-size.d.ts +6 -1
  21. package/dist-lib/lib/api/effective-ctx-size.js +5 -3
  22. package/dist-lib/lib/api/execution.js +9 -2
  23. package/dist-lib/lib/api/files.js +2 -1
  24. package/dist-lib/lib/api/index.d.ts +7 -1
  25. package/dist-lib/lib/api/index.js +101 -101
  26. package/dist-lib/lib/api/instrument.js +29 -20
  27. package/dist-lib/lib/api/knowledge.d.ts +6 -5
  28. package/dist-lib/lib/api/knowledge.js +8 -6
  29. package/dist-lib/lib/api/local-files.js +1 -1
  30. package/dist-lib/lib/api/logs.js +6 -3
  31. package/dist-lib/lib/api/members.js +22 -13
  32. package/dist-lib/lib/api/mesh.d.ts +7 -2
  33. package/dist-lib/lib/api/mesh.js +10 -5
  34. package/dist-lib/lib/api/model-download.js +1 -1
  35. package/dist-lib/lib/api/network.d.ts +1 -0
  36. package/dist-lib/lib/api/network.js +1 -1
  37. package/dist-lib/lib/api/notifications.js +23 -13
  38. package/dist-lib/lib/api/rag.d.ts +6 -1
  39. package/dist-lib/lib/api/rag.js +20 -11
  40. package/dist-lib/lib/api/range.d.ts +2 -2
  41. package/dist-lib/lib/api/sync.js +1 -1
  42. package/dist-lib/lib/api/tool-activity.js +7 -3
  43. package/dist-lib/lib/api/tool-configs.js +2 -4
  44. package/dist-lib/lib/api/upload-frames.d.ts +7 -8
  45. package/dist-lib/lib/api/upload-frames.js +2 -1
  46. package/dist-lib/lib/api/watchable.d.ts +6 -1
  47. package/dist-lib/lib/api/watchable.js +23 -14
  48. package/dist-lib/lib/assistant/fetch-body.js +4 -2
  49. package/dist-lib/lib/assistant/harness.d.ts +72 -24
  50. package/dist-lib/lib/assistant/harness.js +53 -15
  51. package/dist-lib/lib/assistant/history.d.ts +9 -7
  52. package/dist-lib/lib/assistant/history.js +77 -42
  53. package/dist-lib/lib/assistant/message.d.ts +5 -3
  54. package/dist-lib/lib/assistant/message.js +4 -2
  55. package/dist-lib/lib/assistant/skill-encode.d.ts +3 -1
  56. package/dist-lib/lib/assistant/skill-encode.js +52 -62
  57. package/dist-lib/lib/assistant-client.js +7 -4
  58. package/dist-lib/lib/assistant-tree.js +36 -11
  59. package/dist-lib/lib/assistant.d.ts +37 -12
  60. package/dist-lib/lib/assistant.js +977 -373
  61. package/dist-lib/lib/audio-format.d.ts +1 -1
  62. package/dist-lib/lib/audio-format.js +1 -1
  63. package/dist-lib/lib/chat-title.js +9 -4
  64. package/dist-lib/lib/client.js +3 -2
  65. package/dist-lib/lib/collabora/convert.d.ts +2 -2
  66. package/dist-lib/lib/collabora/convert.js +6 -3
  67. package/dist-lib/lib/collabora/entry.js +9 -5
  68. package/dist-lib/lib/collabora/protocol.d.ts +2 -2
  69. package/dist-lib/lib/collabora/protocol.js +14 -7
  70. package/dist-lib/lib/collabora/worker.js +14 -7
  71. package/dist-lib/lib/compaction.d.ts +5 -6
  72. package/dist-lib/lib/compaction.js +14 -7
  73. package/dist-lib/lib/constants.d.ts +2 -0
  74. package/dist-lib/lib/constants.js +4 -0
  75. package/dist-lib/lib/core/account-recovery.d.ts +4 -3
  76. package/dist-lib/lib/core/account-recovery.js +7 -4
  77. package/dist-lib/lib/core/agent.d.ts +0 -1
  78. package/dist-lib/lib/core/agent.js +18 -16
  79. package/dist-lib/lib/core/approval-rules.d.ts +7 -6
  80. package/dist-lib/lib/core/approval-rules.js +12 -6
  81. package/dist-lib/lib/core/archived-mesh.d.ts +7 -5
  82. package/dist-lib/lib/core/archived-mesh.js +25 -22
  83. package/dist-lib/lib/core/async-iterable.js +10 -5
  84. package/dist-lib/lib/core/attachment-link.d.ts +2 -2
  85. package/dist-lib/lib/core/audio-attachment.js +1 -1
  86. package/dist-lib/lib/core/blind-peers.d.ts +2 -2
  87. package/dist-lib/lib/core/chat-activity.d.ts +2 -2
  88. package/dist-lib/lib/core/chat-activity.js +42 -21
  89. package/dist-lib/lib/core/chat-group.d.ts +8 -6
  90. package/dist-lib/lib/core/chat-group.js +17 -10
  91. package/dist-lib/lib/core/chat-order.d.ts +11 -9
  92. package/dist-lib/lib/core/chat-order.js +1 -3
  93. package/dist-lib/lib/core/chat-search.d.ts +4 -4
  94. package/dist-lib/lib/core/chat-search.js +38 -24
  95. package/dist-lib/lib/core/chat.d.ts +20 -14
  96. package/dist-lib/lib/core/chat.js +42 -28
  97. package/dist-lib/lib/core/chunk.d.ts +20 -24
  98. package/dist-lib/lib/core/chunk.js +34 -22
  99. package/dist-lib/lib/core/collections.d.ts +69 -0
  100. package/dist-lib/lib/core/collections.js +69 -0
  101. package/dist-lib/lib/core/contract/activity.d.ts +8 -2
  102. package/dist-lib/lib/core/contract/activity.js +39 -11
  103. package/dist-lib/lib/core/contract/agents.js +3 -2
  104. package/dist-lib/lib/core/contract/approval-rules.js +1 -1
  105. package/dist-lib/lib/core/contract/attestations.js +1 -1
  106. package/dist-lib/lib/core/contract/chat-group.js +1 -1
  107. package/dist-lib/lib/core/contract/chat.js +1 -1
  108. package/dist-lib/lib/core/contract/chunks.js +16 -9
  109. package/dist-lib/lib/core/contract/compute.js +2 -1
  110. package/dist-lib/lib/core/contract/devices.js +10 -6
  111. package/dist-lib/lib/core/contract/grant-order.d.ts +5 -0
  112. package/dist-lib/lib/core/contract/grant-order.js +20 -0
  113. package/dist-lib/lib/core/contract/index.d.ts +1 -1
  114. package/dist-lib/lib/core/contract/index.js +27 -2
  115. package/dist-lib/lib/core/contract/indexing.js +3 -3
  116. package/dist-lib/lib/core/contract/invites.d.ts +16 -0
  117. package/dist-lib/lib/core/contract/invites.js +256 -0
  118. package/dist-lib/lib/core/contract/joined-meshes.js +22 -22
  119. package/dist-lib/lib/core/contract/knowledge.js +5 -5
  120. package/dist-lib/lib/core/contract/members.d.ts +15 -0
  121. package/dist-lib/lib/core/contract/members.js +116 -31
  122. package/dist-lib/lib/core/contract/mesh-kind.d.ts +6 -0
  123. package/dist-lib/lib/core/contract/mesh-kind.js +49 -0
  124. package/dist-lib/lib/core/contract/seal.js +1 -1
  125. package/dist-lib/lib/core/contract/seed-defaults.js +1 -3
  126. package/dist-lib/lib/core/contract/tool-activity.js +5 -5
  127. package/dist-lib/lib/core/contract/tool-configs.js +1 -2
  128. package/dist-lib/lib/core/contract/writers.d.ts +13 -0
  129. package/dist-lib/lib/core/contract/writers.js +181 -24
  130. package/dist-lib/lib/core/departures.js +16 -8
  131. package/dist-lib/lib/core/device-attestation.d.ts +5 -0
  132. package/dist-lib/lib/core/device-attestation.js +24 -0
  133. package/dist-lib/lib/core/device-invites.d.ts +2 -0
  134. package/dist-lib/lib/core/device-invites.js +29 -7
  135. package/dist-lib/lib/core/devices.d.ts +2 -1
  136. package/dist-lib/lib/core/devices.js +52 -2
  137. package/dist-lib/lib/core/document-attachment.d.ts +20 -11
  138. package/dist-lib/lib/core/document-attachment.js +10 -5
  139. package/dist-lib/lib/core/files/attachments.d.ts +2 -5
  140. package/dist-lib/lib/core/files/attachments.js +6 -3
  141. package/dist-lib/lib/core/files/index.d.ts +44 -52
  142. package/dist-lib/lib/core/files/index.js +142 -93
  143. package/dist-lib/lib/core/files/knowledge.d.ts +2 -5
  144. package/dist-lib/lib/core/files/local-index.js +9 -5
  145. package/dist-lib/lib/core/files/preview/image.d.ts +0 -1
  146. package/dist-lib/lib/core/files/preview/image.js +9 -6
  147. package/dist-lib/lib/core/files/preview/index.d.ts +8 -11
  148. package/dist-lib/lib/core/files/preview/index.js +20 -15
  149. package/dist-lib/lib/core/files/processing/claims.d.ts +6 -5
  150. package/dist-lib/lib/core/files/processing/claims.js +16 -8
  151. package/dist-lib/lib/core/files/processing/document.d.ts +21 -50
  152. package/dist-lib/lib/core/files/processing/index.d.ts +18 -13
  153. package/dist-lib/lib/core/files/processing/index.js +65 -37
  154. package/dist-lib/lib/core/files/processing/ownership.d.ts +8 -1
  155. package/dist-lib/lib/core/files/processing/ownership.js +1 -1
  156. package/dist-lib/lib/core/files/processing/protocol.d.ts +19 -19
  157. package/dist-lib/lib/core/files/processing/protocol.js +5 -5
  158. package/dist-lib/lib/core/files/processing/settle.d.ts +10 -7
  159. package/dist-lib/lib/core/files/processing/settle.js +22 -11
  160. package/dist-lib/lib/core/files/processing/source.js +14 -8
  161. package/dist-lib/lib/core/files/processing/state.d.ts +13 -11
  162. package/dist-lib/lib/core/files/processing/state.js +19 -12
  163. package/dist-lib/lib/core/files/rag/build.d.ts +2 -2
  164. package/dist-lib/lib/core/files/rag/build.js +2 -1
  165. package/dist-lib/lib/core/files/rag/document-types.d.ts +4 -6
  166. package/dist-lib/lib/core/files/rag/index.d.ts +10 -13
  167. package/dist-lib/lib/core/files/rag/index.js +3 -2
  168. package/dist-lib/lib/core/files/rag/load.d.ts +10 -9
  169. package/dist-lib/lib/core/files/rag/load.js +26 -13
  170. package/dist-lib/lib/core/files/rag/policy.js +2 -1
  171. package/dist-lib/lib/core/files/rag/produce.js +33 -19
  172. package/dist-lib/lib/core/files/rag/retrieval/full-text.d.ts +5 -3
  173. package/dist-lib/lib/core/files/rag/retrieval/full-text.js +30 -10
  174. package/dist-lib/lib/core/files/records/chunks.js +4 -2
  175. package/dist-lib/lib/core/files/records/knowledge.d.ts +10 -11
  176. package/dist-lib/lib/core/files/records/knowledge.js +9 -8
  177. package/dist-lib/lib/core/files/records/linkage.js +6 -3
  178. package/dist-lib/lib/core/files/records/output.d.ts +5 -4
  179. package/dist-lib/lib/core/files/records/output.js +8 -4
  180. package/dist-lib/lib/core/files/records/reclaim.js +41 -25
  181. package/dist-lib/lib/core/files/records/routing.d.ts +4 -6
  182. package/dist-lib/lib/core/files/records/routing.js +15 -8
  183. package/dist-lib/lib/core/files/records/source.d.ts +5 -4
  184. package/dist-lib/lib/core/files/records/source.js +20 -14
  185. package/dist-lib/lib/core/files/records/sweep.js +1 -3
  186. package/dist-lib/lib/core/files/store/blob.d.ts +10 -10
  187. package/dist-lib/lib/core/files/store/blob.js +25 -19
  188. package/dist-lib/lib/core/files/store/index.d.ts +1 -6
  189. package/dist-lib/lib/core/files/store/index.js +4 -4
  190. package/dist-lib/lib/core/files/store/inline.d.ts +2 -2
  191. package/dist-lib/lib/core/files/store/inline.js +6 -3
  192. package/dist-lib/lib/core/files/store/reference.d.ts +6 -9
  193. package/dist-lib/lib/core/files/store/reference.js +25 -17
  194. package/dist-lib/lib/core/files/store/server.d.ts +7 -6
  195. package/dist-lib/lib/core/files/store/server.js +22 -11
  196. package/dist-lib/lib/core/files/store/sweep.js +13 -7
  197. package/dist-lib/lib/core/files/upload-input.d.ts +4 -12
  198. package/dist-lib/lib/core/files/upload-input.js +10 -5
  199. package/dist-lib/lib/core/files/upload.d.ts +27 -24
  200. package/dist-lib/lib/core/files/upload.js +74 -51
  201. package/dist-lib/lib/core/fs-drives.js +4 -2
  202. package/dist-lib/lib/core/grant-expiry.d.ts +11 -0
  203. package/dist-lib/lib/core/grant-expiry.js +66 -0
  204. package/dist-lib/lib/core/handoff-channel.d.ts +2 -1
  205. package/dist-lib/lib/core/handoff-channel.js +36 -15
  206. package/dist-lib/lib/core/harness-loan.js +35 -17
  207. package/dist-lib/lib/core/helpers/index.d.ts +2 -1
  208. package/dist-lib/lib/core/helpers/index.js +11 -6
  209. package/dist-lib/lib/core/hosted-agents.js +19 -12
  210. package/dist-lib/lib/core/id.js +1 -1
  211. package/dist-lib/lib/core/identity.d.ts +1 -0
  212. package/dist-lib/lib/core/identity.js +11 -3
  213. package/dist-lib/lib/core/image/cache-sweep.d.ts +12 -10
  214. package/dist-lib/lib/core/image/cache-sweep.js +11 -6
  215. package/dist-lib/lib/core/image/normalize.d.ts +6 -0
  216. package/dist-lib/lib/core/image/normalize.js +12 -2
  217. package/dist-lib/lib/core/image/sniff.js +42 -21
  218. package/dist-lib/lib/core/inference-calls-receiver.js +7 -4
  219. package/dist-lib/lib/core/invite-grants.d.ts +20 -0
  220. package/dist-lib/lib/core/invite-grants.js +46 -0
  221. package/dist-lib/lib/core/invite.d.ts +3 -0
  222. package/dist-lib/lib/core/invite.js +6 -3
  223. package/dist-lib/lib/core/local/files.js +20 -19
  224. package/dist-lib/lib/core/local/index.d.ts +70 -45
  225. package/dist-lib/lib/core/local/index.js +157 -126
  226. package/dist-lib/lib/core/membership.d.ts +15 -2
  227. package/dist-lib/lib/core/membership.js +95 -20
  228. package/dist-lib/lib/core/mesh-seed-handoff.d.ts +12 -4
  229. package/dist-lib/lib/core/mesh-seed-handoff.js +23 -5
  230. package/dist-lib/lib/core/mesh.d.ts +57 -30
  231. package/dist-lib/lib/core/mesh.js +232 -78
  232. package/dist-lib/lib/core/migrations/agent-catalog.js +3 -2
  233. package/dist-lib/lib/core/migrations/agent-indexes.js +3 -3
  234. package/dist-lib/lib/core/migrations/device-indexes.d.ts +2 -0
  235. package/dist-lib/lib/core/migrations/device-indexes.js +7 -0
  236. package/dist-lib/lib/core/migrations/file-index.js +7 -4
  237. package/dist-lib/lib/core/migrations/index.d.ts +4 -3
  238. package/dist-lib/lib/core/migrations/index.js +3 -1
  239. package/dist-lib/lib/core/migrations/membership.js +9 -4
  240. package/dist-lib/lib/core/migrations/seal.js +3 -2
  241. package/dist-lib/lib/core/min-version.js +4 -2
  242. package/dist-lib/lib/core/next-frame.d.ts +5 -4
  243. package/dist-lib/lib/core/next-frame.js +6 -3
  244. package/dist-lib/lib/core/notification.d.ts +5 -1
  245. package/dist-lib/lib/core/notification.js +89 -77
  246. package/dist-lib/lib/core/ota-config.js +2 -1
  247. package/dist-lib/lib/core/pdf/rasterize.d.ts +18 -0
  248. package/dist-lib/lib/core/pdf/rasterize.js +57 -0
  249. package/dist-lib/lib/core/prompt-history.js +4 -2
  250. package/dist-lib/lib/core/range.d.ts +4 -4
  251. package/dist-lib/lib/core/range.js +12 -6
  252. package/dist-lib/lib/core/rank.d.ts +5 -4
  253. package/dist-lib/lib/core/rank.js +2 -1
  254. package/dist-lib/lib/core/send.d.ts +8 -5
  255. package/dist-lib/lib/core/send.js +9 -3
  256. package/dist-lib/lib/core/skill-overlay-receiver.js +7 -4
  257. package/dist-lib/lib/core/skill-secrets.js +16 -9
  258. package/dist-lib/lib/core/sync/chunks.js +2 -1
  259. package/dist-lib/lib/core/sync/devices.js +3 -1
  260. package/dist-lib/lib/core/sync/files.d.ts +2 -4
  261. package/dist-lib/lib/core/sync/files.js +28 -20
  262. package/dist-lib/lib/core/sync/index.d.ts +2 -5
  263. package/dist-lib/lib/core/sync/index.js +33 -17
  264. package/dist-lib/lib/core/sync-status.js +10 -7
  265. package/dist-lib/lib/core/system-info.js +4 -2
  266. package/dist-lib/lib/core/tool-activity.d.ts +4 -3
  267. package/dist-lib/lib/core/tool-activity.js +1 -1
  268. package/dist-lib/lib/core/tool-configs.js +12 -7
  269. package/dist-lib/lib/core.d.ts +107 -45
  270. package/dist-lib/lib/core.js +1765 -595
  271. package/dist-lib/lib/credential-pusher.d.ts +12 -17
  272. package/dist-lib/lib/credential-pusher.js +61 -42
  273. package/dist-lib/lib/custom-model-pusher.d.ts +7 -3
  274. package/dist-lib/lib/custom-model-pusher.js +15 -7
  275. package/dist-lib/lib/custom-model-task.d.ts +1 -0
  276. package/dist-lib/lib/custom-model-task.js +12 -0
  277. package/dist-lib/lib/deadline.js +4 -2
  278. package/dist-lib/lib/diagnostics.d.ts +1 -5
  279. package/dist-lib/lib/frame-readable.d.ts +3 -0
  280. package/dist-lib/lib/frame-readable.js +3 -0
  281. package/dist-lib/lib/fs-drive-bridge.js +24 -14
  282. package/dist-lib/lib/fs-grants.js +13 -8
  283. package/dist-lib/lib/guards.d.ts +3 -0
  284. package/dist-lib/lib/guards.js +9 -0
  285. package/dist-lib/lib/inference-calls.d.ts +28 -23
  286. package/dist-lib/lib/inference-calls.js +25 -13
  287. package/dist-lib/lib/integrations/mcp-providers.d.ts +2 -2
  288. package/dist-lib/lib/integrations/setup-routes.d.ts +2 -2
  289. package/dist-lib/lib/knowledge-search.d.ts +6 -5
  290. package/dist-lib/lib/knowledge-search.js +26 -18
  291. package/dist-lib/lib/kv-cache-reclaim.js +4 -2
  292. package/dist-lib/lib/kv-cache.js +8 -4
  293. package/dist-lib/lib/legacy-core-domain.d.ts +42 -42
  294. package/dist-lib/lib/log-buffer.js +2 -1
  295. package/dist-lib/lib/log.js +25 -15
  296. package/dist-lib/lib/mesh-scoped-engine.js +14 -4
  297. package/dist-lib/lib/model-catalog-revision.js +6 -3
  298. package/dist-lib/lib/model-clamp.js +6 -3
  299. package/dist-lib/lib/model-context.d.ts +8 -3
  300. package/dist-lib/lib/model-context.js +13 -5
  301. package/dist-lib/lib/model-download-status.js +4 -2
  302. package/dist-lib/lib/model-download.d.ts +12 -4
  303. package/dist-lib/lib/model-download.js +200 -103
  304. package/dist-lib/lib/model-idle-pusher.d.ts +10 -0
  305. package/dist-lib/lib/model-idle-pusher.js +41 -0
  306. package/dist-lib/lib/oauth/browser-connect.d.ts +10 -8
  307. package/dist-lib/lib/oauth/browser-connect.js +33 -20
  308. package/dist-lib/lib/oauth/client.d.ts +2 -2
  309. package/dist-lib/lib/oauth/flow-core.js +23 -9
  310. package/dist-lib/lib/oauth/flow.d.ts +1 -3
  311. package/dist-lib/lib/oauth/flow.js +9 -5
  312. package/dist-lib/lib/oauth/keys.d.ts +4 -4
  313. package/dist-lib/lib/oauth/keys.js +18 -12
  314. package/dist-lib/lib/oauth/loopback.d.ts +2 -2
  315. package/dist-lib/lib/oauth/loopback.js +147 -107
  316. package/dist-lib/lib/oauth/loopback.stub.d.ts +2 -2
  317. package/dist-lib/lib/oauth/loopback.stub.js +1 -1
  318. package/dist-lib/lib/oauth/pkce.d.ts +4 -2
  319. package/dist-lib/lib/oauth/pkce.js +10 -0
  320. package/dist-lib/lib/oauth/providers.js +5 -5
  321. package/dist-lib/lib/oauth/redirect-types.d.ts +12 -7
  322. package/dist-lib/lib/oauth/register.js +3 -2
  323. package/dist-lib/lib/oauth/registry.d.ts +2 -2
  324. package/dist-lib/lib/oauth/registry.js +2 -1
  325. package/dist-lib/lib/oauth/resolve.d.ts +30 -10
  326. package/dist-lib/lib/oauth/resolve.js +12 -6
  327. package/dist-lib/lib/oauth/token-exchange-core.d.ts +12 -4
  328. package/dist-lib/lib/oauth/token-exchange-core.js +1 -1
  329. package/dist-lib/lib/oauth/types.d.ts +12 -12
  330. package/dist-lib/lib/oauth.d.ts +4 -5
  331. package/dist-lib/lib/oauth.js +2 -3
  332. package/dist-lib/lib/reconnecting-watch.d.ts +1 -1
  333. package/dist-lib/lib/reconnecting-watch.js +6 -6
  334. package/dist-lib/lib/retry-budget.js +6 -3
  335. package/dist-lib/lib/run-notices.d.ts +2 -0
  336. package/dist-lib/lib/run-notices.js +7 -3
  337. package/dist-lib/lib/run-transcript.d.ts +2 -4
  338. package/dist-lib/lib/run-transcript.js +4 -2
  339. package/dist-lib/lib/skill-readiness.d.ts +1 -0
  340. package/dist-lib/lib/skill-readiness.js +17 -2
  341. package/dist-lib/lib/skill-types.d.ts +16 -16
  342. package/dist-lib/lib/suspend-lifecycle.d.ts +4 -4
  343. package/dist-lib/lib/suspend-lifecycle.js +10 -5
  344. package/dist-lib/lib/task.d.ts +5 -1
  345. package/dist-lib/lib/task.js +29 -12
  346. package/dist-lib/lib/unref.d.ts +3 -2
  347. package/dist-lib/lib/unref.js +2 -1
  348. package/dist-lib/lib/wav-duration.js +10 -5
  349. package/dist-lib/lib/write-queue.d.ts +5 -4
  350. package/dist-lib/lib/write-queue.js +2 -1
  351. package/dist-lib/schema/build.js +16 -8
  352. package/dist-lib/schema/config.d.ts +3 -4
  353. package/dist-lib/schema/config.js +1 -1
  354. package/dist-lib/schema/content.d.ts +18 -2
  355. package/dist-lib/schema/content.js +4 -1
  356. package/dist-lib/schema/engine.d.ts +3 -2
  357. package/dist-lib/schema/engine.js +192 -12
  358. package/dist-lib/schema/field-order.js +22 -11
  359. package/dist-lib/schema/indexes.d.ts +22 -0
  360. package/dist-lib/schema/{helpers.js → indexes.js} +19 -57
  361. package/dist-lib/schema/local.d.ts +3 -2
  362. package/dist-lib/schema/local.js +9 -3
  363. package/dist-lib/schema/media-kind.d.ts +8 -0
  364. package/dist-lib/schema/media-kind.js +52 -0
  365. package/dist-lib/schema/qvac.d.ts +12 -9
  366. package/dist-lib/schema/qvac.js +132 -7
  367. package/dist-lib/spec/bind.js +21 -0
  368. package/dist-lib/spec/calls.js +7 -0
  369. package/dist-lib/spec/capabilities.d.ts +18 -4
  370. package/dist-lib/spec/config/hyperconf/index.js +1 -1
  371. package/dist-lib/spec/hrpc/hrpc.json +93 -2
  372. package/dist-lib/spec/hrpc/index.js +89 -5
  373. package/dist-lib/spec/hrpc/messages.js +1568 -941
  374. package/dist-lib/spec/hyperschema/index.js +1568 -941
  375. package/dist-lib/spec/hyperschema/schema.json +531 -1
  376. package/dist-lib/spec/hyperschema/types.d.ts +145 -1
  377. package/dist-lib/spec/local/hyperdb/index.js +1 -1
  378. package/dist-lib/spec/local/hyperdb/messages.js +92 -20
  379. package/dist-lib/spec/local/hyperschema/index.js +47 -11
  380. package/dist-lib/spec/local/hyperschema/schema.json +32 -1
  381. package/dist-lib/spec/local/hyperschema/types.d.ts +7 -1
  382. package/dist-lib/spec/mesh/hyperdb/db.json +131 -3
  383. package/dist-lib/spec/mesh/hyperdb/index.js +548 -5
  384. package/dist-lib/spec/mesh/hyperdb/messages.js +2444 -893
  385. package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +37 -1
  386. package/dist-lib/spec/mesh/hyperdispatch/index.js +104 -2
  387. package/dist-lib/spec/mesh/hyperdispatch/messages.js +1035 -11
  388. package/dist-lib/spec/mesh/hyperschema/index.js +1035 -11
  389. package/dist-lib/spec/mesh/hyperschema/schema.json +553 -1
  390. package/dist-lib/spec/mesh/hyperschema/types.d.ts +143 -1
  391. package/package.json +11 -5
  392. package/tui/app.mjs +2624 -986
  393. package/tui/boot.mjs +17 -46
  394. package/tui/index.mjs +10 -5
  395. package/tui/lib/boot-timing.mjs +8 -8
  396. package/tui/lib/busy-words.mjs +21 -22
  397. package/tui/lib/export.mjs +100 -32
  398. package/tui/lib/knowledge-command.mjs +64 -19
  399. package/tui/lib/knowledge-import.mjs +52 -18
  400. package/tui/lib/render.mjs +65 -33
  401. package/tui/lib/save-file.mjs +30 -13
  402. package/tui/lib/select.mjs +23 -5
  403. package/tui/lib/selection.mjs +6 -4
  404. package/tui/lib/setup.mjs +11 -19
  405. package/tui/lib/sidebar.mjs +23 -13
  406. package/tui/lib/splash.mjs +6 -7
  407. package/tui/lib/upload-frames.mjs +1 -2
  408. package/tui/lib/usage.mjs +13 -9
  409. package/tui/lib/wrap.mjs +35 -6
  410. package/tui/main.mjs +54 -78
  411. package/worker/assistant-sidecar.mjs +5 -10
  412. package/worker/stow-entry.mjs +7 -4
  413. package/dist-lib/lib/custom-model-source.d.ts +0 -15
  414. package/dist-lib/lib/custom-model-source.js +0 -46
  415. package/dist-lib/lib/oauth/common.d.ts +0 -38
  416. package/dist-lib/lib/oauth/common.js +0 -34
  417. package/dist-lib/schema/helpers.d.ts +0 -32
@@ -1,20 +1,20 @@
1
1
  import type { Harness } from './assistant.ts';
2
2
  import { type ConfigEngine } from './oauth.ts';
3
3
  import type { OAuthRouteLike } from './oauth/keys.ts';
4
- export type CredentialEntry = {
4
+ export interface CredentialEntry {
5
5
  key: string;
6
6
  token?: string | null;
7
7
  expiresAt?: number | null;
8
8
  agentId?: string | null;
9
9
  skill?: string | null;
10
- };
11
- export type SettingEntry = {
10
+ }
11
+ export interface SettingEntry {
12
12
  skill: string;
13
13
  key: string;
14
14
  value: string;
15
15
  agentId?: string | null;
16
- };
17
- export type PusherSkill = {
16
+ }
17
+ export interface PusherSkill {
18
18
  name: string;
19
19
  credentials?: readonly string[];
20
20
  requires?: {
@@ -28,7 +28,7 @@ export type PusherSkill = {
28
28
  }>;
29
29
  }>;
30
30
  };
31
- };
31
+ }
32
32
  export interface CredentialEngine extends ConfigEngine {
33
33
  configWatch(req: {
34
34
  key: string;
@@ -41,26 +41,21 @@ export interface CredentialEngine extends ConfigEngine {
41
41
  }>;
42
42
  }>;
43
43
  }
44
- export type CredentialTarget = {
44
+ export interface CredentialTarget {
45
45
  setCredentials: NonNullable<Harness['setCredentials']>;
46
46
  setSkillSettings?: (entries: ReadonlyArray<SettingEntry>) => void | Promise<void>;
47
47
  skills?: (agentId?: string | null, modelName?: string | null, options?: {
48
48
  readonly skipCredentialProbe?: boolean;
49
49
  }) => Promise<ReadonlyArray<PusherSkill>>;
50
- };
51
- export type CredentialPusherLogger = {
50
+ }
51
+ export interface CredentialPusherLogger {
52
52
  warn(...args: unknown[]): void;
53
- };
53
+ }
54
54
  export type CredentialPusherHandle = (() => Promise<void>) & {
55
55
  sync(): Promise<void>;
56
56
  };
57
- export declare function nextRefreshDelay(entries: ReadonlyArray<{
58
- expiresAt?: number | null;
59
- }>, now?: number): number;
57
+ export declare function nextRefreshDelay(entries: ReadonlyArray<Pick<CredentialEntry, 'expiresAt'>>, now?: number): number;
60
58
  export declare function credentialOwners(catalog: ReadonlyArray<PusherSkill>): ReadonlyMap<string, readonly string[]>;
61
- export declare function settingFields(catalog: ReadonlyArray<PusherSkill>): ReadonlyArray<{
62
- skill: string;
63
- key: string;
64
- }>;
59
+ export declare function settingFields(catalog: ReadonlyArray<PusherSkill>): ReadonlyArray<Pick<SettingEntry, 'skill' | 'key'>>;
65
60
  export declare function settingConfigKey(agentId: string | undefined, skill: string, key: string): string;
66
61
  export declare function startCredentialPusher(harness: CredentialTarget, engine: CredentialEngine, logger?: CredentialPusherLogger | null): CredentialPusherHandle;
@@ -1,12 +1,12 @@
1
1
  import { OBSIDIAN_VAULT_PATH_CREDENTIAL_KEY } from './obsidian-key.js';
2
2
  import { scopedKey } from './oauth.js';
3
3
  import { oauthSpecs } from './oauth/registry.js';
4
- import { resolveOAuthCredential } from './oauth/resolve.js';
4
+ import { REFRESH_SKEW_MS, resolveOAuthCredential } from './oauth/resolve.js';
5
5
  import { buildProviderConfig } from './oauth/providers.js';
6
6
  import { refreshOAuthTokens } from './oauth/token-exchange.js';
7
7
  import ScopeLock from 'scope-lock';
8
8
  import { credentialSlots } from '@qvac/harness/lib/tools/skills/credential-slots.ts';
9
- import { REFRESH_SKEW_MS } from './oauth/common.js';
9
+ import { errorMessage } from './guards.js';
10
10
  const PLAIN_KEYS = ['github_access_token', OBSIDIAN_VAULT_PATH_CREDENTIAL_KEY];
11
11
  const REFRESH_INTERVAL = 10 * 60 * 1000;
12
12
  const MIN_REFRESH_DELAY = 30_000;
@@ -17,12 +17,14 @@ export function nextRefreshDelay(entries, now = Date.now()) {
17
17
  let nearest = null;
18
18
  for (const entry of entries) {
19
19
  if (typeof entry.expiresAt === 'number' && entry.expiresAt > 0) {
20
- if (nearest === null || entry.expiresAt < nearest)
20
+ if (nearest === null || entry.expiresAt < nearest) {
21
21
  nearest = entry.expiresAt;
22
+ }
22
23
  }
23
24
  }
24
- if (nearest === null)
25
+ if (nearest === null) {
25
26
  return REFRESH_INTERVAL;
27
+ }
26
28
  return Math.min(REFRESH_INTERVAL, Math.max(MIN_REFRESH_DELAY, nearest - now - REFRESH_SKEW_MS));
27
29
  }
28
30
  async function oauthEntry(engine, spec, agentId) {
@@ -35,8 +37,9 @@ async function oauthEntry(engine, spec, agentId) {
35
37
  requireClientSecret: spec.tokenAuth !== 'pkce-only',
36
38
  refresh: (args) => refreshOAuthTokens(buildProviderConfig(spec, { clientId: args.clientId, clientSecret: args.clientSecret }), args.refreshToken)
37
39
  });
38
- if (!token)
40
+ if (!token) {
39
41
  return null;
42
+ }
40
43
  const { value } = await engine.configGet({
41
44
  key: scopedKey(agentId, stateKey)
42
45
  });
@@ -49,18 +52,19 @@ async function oauthEntry(engine, spec, agentId) {
49
52
  return {
50
53
  key: credentialKey,
51
54
  token,
52
- ...(expiresAt === undefined ? {} : { expiresAt }),
53
- ...(agentId ? { agentId } : {})
55
+ expiresAt,
56
+ agentId
54
57
  };
55
58
  }
56
59
  async function plainEntry(engine, key, agentId) {
57
60
  const { value } = await engine.configGet({ key: scopedKey(agentId, key) });
58
- if (typeof value !== 'string' || value === '')
61
+ if (typeof value !== 'string' || value === '') {
59
62
  return null;
63
+ }
60
64
  return {
61
65
  key,
62
66
  token: value,
63
- ...(agentId ? { agentId } : {})
67
+ agentId
64
68
  };
65
69
  }
66
70
  export function credentialOwners(catalog) {
@@ -68,8 +72,9 @@ export function credentialOwners(catalog) {
68
72
  for (const skill of catalog) {
69
73
  for (const key of credentialSlots(skill).flat()) {
70
74
  const list = owners.get(key) ?? [];
71
- if (!list.includes(skill.name))
75
+ if (!list.includes(skill.name)) {
72
76
  list.push(skill.name);
77
+ }
73
78
  owners.set(key, list);
74
79
  }
75
80
  }
@@ -78,14 +83,13 @@ export function credentialOwners(catalog) {
78
83
  export function settingFields(catalog) {
79
84
  const fields = [];
80
85
  for (const skill of catalog) {
81
- for (const route of skill.setup?.routes ?? []) {
82
- for (const field of route.fields ?? []) {
83
- if (field.secret === true)
84
- continue;
85
- if (fields.some((f) => f.skill === skill.name && f.key === field.key))
86
- continue;
87
- fields.push({ skill: skill.name, key: field.key });
86
+ for (const field of (skill.setup?.routes ?? []).flatMap((route) => route.fields ?? [])) {
87
+ if (field.secret === true)
88
+ continue;
89
+ if (fields.some((f) => f.skill === skill.name && f.key === field.key)) {
90
+ continue;
88
91
  }
92
+ fields.push({ skill: skill.name, key: field.key });
89
93
  }
90
94
  }
91
95
  return fields;
@@ -97,7 +101,7 @@ function fanOut(entry, owners) {
97
101
  const skills = owners.get(entry.key) ?? [];
98
102
  return skills.length > 0 ? skills.map((skill) => ({ ...entry, skill })) : [entry];
99
103
  }
100
- async function resolveScope(engine, agentId, last, owners, specs, logger) {
104
+ async function resolveScope(agentId, { engine, last, owners, specs, logger }) {
101
105
  const entries = [];
102
106
  for (const spec of specs) {
103
107
  const mk = storeKey(spec.credentialKey, agentId);
@@ -114,8 +118,9 @@ async function resolveScope(engine, agentId, last, owners, specs, logger) {
114
118
  catch (err) {
115
119
  logger?.warn('credential-pusher', `credential resolve failed for ${spec.credentialKey}`, errorMessage(err));
116
120
  const kept = last.get(mk);
117
- if (kept)
121
+ if (kept) {
118
122
  entries.push(...fanOut(kept, owners));
123
+ }
119
124
  }
120
125
  }
121
126
  const specKeys = new Set(specs.map((spec) => spec.credentialKey));
@@ -136,22 +141,25 @@ async function resolveScope(engine, agentId, last, owners, specs, logger) {
136
141
  catch (err) {
137
142
  logger?.warn('credential-pusher', `credential read failed for ${key}`, errorMessage(err));
138
143
  const kept = last.get(mk);
139
- if (kept)
144
+ if (kept) {
140
145
  entries.push(...fanOut(kept, owners));
146
+ }
141
147
  }
142
148
  }
143
149
  return entries;
144
150
  }
145
- async function resolveSettings(engine, scopes, catalog, logger) {
151
+ async function resolveSettings(engine, scopes, { catalog, logger }) {
146
152
  const fields = settingFields(catalog);
147
- if (fields.length === 0)
153
+ if (fields.length === 0) {
148
154
  return [];
155
+ }
149
156
  const resolved = await Promise.all(scopes.flatMap((agentId) => fields.map(async ({ skill, key }) => {
150
157
  try {
151
158
  const { value } = await engine.configGet({ key: settingConfigKey(agentId, skill, key) });
152
- if (typeof value !== 'string' || value === '')
159
+ if (typeof value !== 'string' || value === '') {
153
160
  return null;
154
- return { skill, key, value, ...(agentId ? { agentId } : {}) };
161
+ }
162
+ return { skill, key, value, agentId };
155
163
  }
156
164
  catch (err) {
157
165
  logger?.warn('credential-pusher', `setting read failed for ${skill}.${key}`, errorMessage(err));
@@ -160,8 +168,9 @@ async function resolveSettings(engine, scopes, catalog, logger) {
160
168
  })));
161
169
  const entries = [];
162
170
  for (const entry of resolved) {
163
- if (entry)
171
+ if (entry) {
164
172
  entries.push(entry);
173
+ }
165
174
  }
166
175
  return entries;
167
176
  }
@@ -175,10 +184,12 @@ export function startCredentialPusher(harness, engine, logger) {
175
184
  const stream = engine.configWatch({ key: scopedKey(undefined, key) });
176
185
  watches.set(key, stream);
177
186
  (async () => {
178
- for await (const _ of stream)
187
+ for await (const _ of stream) {
179
188
  schedule();
180
- if (disposed || watches.get(key) !== stream)
189
+ }
190
+ if (disposed || watches.get(key) !== stream) {
181
191
  return;
192
+ }
182
193
  logger?.warn('credential-pusher', `credential watch ended for ${key}, change propagation degrades to the interval until restart`);
183
194
  })().catch((err) => {
184
195
  if (disposed || watches.get(key) !== stream)
@@ -200,20 +211,23 @@ export function startCredentialPusher(harness, engine, logger) {
200
211
  watches.delete(key);
201
212
  }
202
213
  for (const key of wanted) {
203
- if (!watches.has(key))
214
+ if (!watches.has(key)) {
204
215
  watch(key);
216
+ }
205
217
  }
206
218
  for (const mk of last.keys()) {
207
219
  const key = mk.includes('\0') ? mk.slice(mk.indexOf('\0') + 1) : mk;
208
- if (!wanted.has(key))
220
+ if (!wanted.has(key)) {
209
221
  last.delete(mk);
222
+ }
210
223
  }
211
224
  };
212
225
  const armTimer = (delay) => {
213
226
  if (disposed)
214
227
  return;
215
- if (timer)
228
+ if (timer) {
216
229
  clearTimeout(timer);
230
+ }
217
231
  timer = setTimeout(() => {
218
232
  timer = null;
219
233
  schedule();
@@ -234,26 +248,30 @@ export function startCredentialPusher(harness, engine, logger) {
234
248
  const entries = [];
235
249
  try {
236
250
  const skills = await catalog();
237
- if (skills === null)
251
+ if (skills === null) {
238
252
  return;
253
+ }
239
254
  const owners = credentialOwners(skills);
240
255
  const specs = oauthSpecs(skills);
241
256
  syncWatches(specs.map((spec) => spec.credentialKey));
242
257
  const ids = (await engine.listAgents({})).agents.map((agent) => agent.id);
243
258
  const scopes = [undefined, ...ids];
259
+ const resolution = { engine, last, owners, specs, logger };
244
260
  for (const agentId of scopes) {
245
- entries.push(...(await resolveScope(engine, agentId, last, owners, specs, logger)));
261
+ entries.push(...(await resolveScope(agentId, resolution)));
246
262
  }
247
- if (disposed)
263
+ if (disposed) {
248
264
  return;
265
+ }
249
266
  await harness.setCredentials(entries);
250
267
  if (harness.setSkillSettings) {
251
- await harness.setSkillSettings(await resolveSettings(engine, scopes, skills, logger));
268
+ await harness.setSkillSettings(await resolveSettings(engine, scopes, { catalog: skills, logger }));
252
269
  }
253
270
  }
254
271
  finally {
255
- if (!disposed)
272
+ if (!disposed) {
256
273
  armTimer(nextRefreshDelay(entries));
274
+ }
257
275
  }
258
276
  };
259
277
  const schedule = async () => {
@@ -262,8 +280,9 @@ export function startCredentialPusher(harness, engine, logger) {
262
280
  if (!(await pushLock.lock()))
263
281
  return;
264
282
  try {
265
- if (!disposed)
283
+ if (!disposed) {
266
284
  await pushAll();
285
+ }
267
286
  }
268
287
  catch (err) {
269
288
  logger?.warn('credential-pusher', 'credential push failed', errorMessage(err));
@@ -276,15 +295,17 @@ export function startCredentialPusher(harness, engine, logger) {
276
295
  if (disposed)
277
296
  return;
278
297
  await pushLock.flush();
279
- if (disposed)
298
+ if (disposed) {
280
299
  return;
300
+ }
281
301
  if (!(await pushLock.lock())) {
282
302
  await pushLock.flush();
283
303
  return;
284
304
  }
285
305
  try {
286
- if (!disposed)
306
+ if (!disposed) {
287
307
  await pushAll();
308
+ }
288
309
  }
289
310
  catch (err) {
290
311
  logger?.warn('credential-pusher', 'credential sync failed', errorMessage(err));
@@ -298,8 +319,9 @@ export function startCredentialPusher(harness, engine, logger) {
298
319
  if (disposed)
299
320
  return;
300
321
  disposed = true;
301
- if (timer)
322
+ if (timer) {
302
323
  clearTimeout(timer);
324
+ }
303
325
  timer = null;
304
326
  for (const stream of watches.values()) {
305
327
  try {
@@ -313,6 +335,3 @@ export function startCredentialPusher(harness, engine, logger) {
313
335
  };
314
336
  return Object.assign(stop, { sync });
315
337
  }
316
- function errorMessage(error) {
317
- return error instanceof Error ? error.message : String(error);
318
- }
@@ -1,9 +1,13 @@
1
1
  import type { Harness } from './assistant.ts';
2
2
  import type { openLocalStore } from './core/local/index.ts';
3
3
  type LocalStore = Awaited<ReturnType<typeof openLocalStore>>;
4
- type Logger = {
4
+ interface Logger {
5
5
  warn(...args: unknown[]): void;
6
- };
6
+ }
7
7
  export type CustomModelTarget = Pick<Harness, 'setCustomModels'>;
8
- export declare function startCustomModelPusher(harness: CustomModelTarget, state: LocalStore, logger?: Logger | null): () => Promise<void>;
8
+ export interface CustomModelPusherOptions {
9
+ logger?: Logger | null;
10
+ onPushed?: () => void;
11
+ }
12
+ export declare function startCustomModelPusher(harness: CustomModelTarget, state: LocalStore, opts?: CustomModelPusherOptions): () => Promise<void>;
9
13
  export {};
@@ -1,16 +1,26 @@
1
- export function startCustomModelPusher(harness, state, logger) {
1
+ import { errorMessage } from './guards.js';
2
+ export function startCustomModelPusher(harness, state, opts = {}) {
3
+ const { logger, onPushed } = opts;
2
4
  let disposed = false;
3
5
  let tail = Promise.resolve();
4
6
  let queued = false;
5
7
  const push = async () => {
6
8
  const rows = await state.getCustomModelRows();
7
- if (disposed)
9
+ if (disposed) {
8
10
  return;
11
+ }
9
12
  await harness.setCustomModels?.(rows.map((row) => ({
10
13
  name: row.name,
11
14
  src: row.src,
12
- projectionSrc: row.mmprojSrc ?? undefined
15
+ projectionSrc: row.mmprojSrc ?? undefined,
16
+ taskType: row.taskType ?? undefined,
17
+ expectedSize: row.expectedSize || undefined,
18
+ label: row.label || undefined,
19
+ contextLength: row.contextLength || undefined
13
20
  })));
21
+ if (!disposed) {
22
+ onPushed?.();
23
+ }
14
24
  };
15
25
  const schedule = () => {
16
26
  if (disposed || queued)
@@ -18,8 +28,9 @@ export function startCustomModelPusher(harness, state, logger) {
18
28
  queued = true;
19
29
  tail = tail.then(async () => {
20
30
  queued = false;
21
- if (disposed)
31
+ if (disposed) {
22
32
  return;
33
+ }
23
34
  try {
24
35
  await push();
25
36
  }
@@ -37,6 +48,3 @@ export function startCustomModelPusher(harness, state, logger) {
37
48
  await tail;
38
49
  };
39
50
  }
40
- function errorMessage(error) {
41
- return error instanceof Error ? error.message : String(error);
42
- }
@@ -0,0 +1 @@
1
+ export declare function customModelTaskRefusal(taskType: string | null | undefined): string | null;
@@ -0,0 +1,12 @@
1
+ const TASK_NAMES = {
2
+ embeddings: 'embedding',
3
+ 'speech-to-text': 'speech-to-text',
4
+ 'text-to-speech': 'text-to-speech',
5
+ 'image-generation': 'image-generation'
6
+ };
7
+ export function customModelTaskRefusal(taskType) {
8
+ if (!taskType || taskType === 'llm')
9
+ return null;
10
+ const task = TASK_NAMES[taskType] ?? taskType;
11
+ return `This is ${/^[aeiou]/i.test(task) ? 'an' : 'a'} ${task} model. Custom models run as the assistant's text model only.`;
12
+ }
@@ -11,8 +11,9 @@ export class DeadlineScheduler {
11
11
  }
12
12
  schedule(deadline) {
13
13
  const at = deadline + 1;
14
- if (this._at !== null && this._at <= at)
14
+ if (this._at !== null && this._at <= at) {
15
15
  return;
16
+ }
16
17
  this.clear();
17
18
  this._at = at;
18
19
  this._timer = setTimeout(() => {
@@ -23,8 +24,9 @@ export class DeadlineScheduler {
23
24
  unref(this._timer);
24
25
  }
25
26
  clear() {
26
- if (this._timer)
27
+ if (this._timer) {
27
28
  clearTimeout(this._timer);
29
+ }
28
30
  this._timer = null;
29
31
  this._at = null;
30
32
  }
@@ -28,8 +28,4 @@ export interface DiagnosticsSlice {
28
28
  mobileClass: boolean;
29
29
  memoryBudget: MemoryBudget | null;
30
30
  }
31
- export declare function summarizeRuns(runs: Iterable<{
32
- runId: string;
33
- chatId: string;
34
- model: string;
35
- }>, suspended: boolean): AssistantDiagnostics;
31
+ export declare function summarizeRuns(runs: Iterable<RunSummary>, suspended: boolean): AssistantDiagnostics;
@@ -0,0 +1,3 @@
1
+ import type { Readable } from 'streamx';
2
+ import type { WatchStream } from '../spec/capabilities.d.ts';
3
+ export declare function frameReadable<Frame>(stream: Readable): Readable & WatchStream<Frame>;
@@ -0,0 +1,3 @@
1
+ export function frameReadable(stream) {
2
+ return stream;
3
+ }
@@ -5,6 +5,7 @@ import { AbortController } from 'bare-abort-controller';
5
5
  import { STAGING_DIR as HARNESS_STAGING_DIR } from '@qvac/harness/lib/staging.ts';
6
6
  import { userTmpPath } from '@qvac/harness/lib/tmp-path.ts';
7
7
  import { MAX_DRIVE_BYTES } from '@qvac/harness/lib/tools/fs/remote.ts';
8
+ import { errorMessage } from './guards.js';
8
9
  export const DRIVE_OP_TIMEOUT_MS = 15_000;
9
10
  const STAGING_DIR = userTmpPath('qvac-fs-drive-host');
10
11
  const STAGING_MAX_AGE_MS = 60 * 60 * 1000;
@@ -42,11 +43,9 @@ async function stagedPath(prefix) {
42
43
  return path.join(STAGING_DIR, `${prefix}-${unique}`);
43
44
  }
44
45
  function stripMetadata(entry) {
45
- if (!entry)
46
- return null;
47
46
  return { ...entry, value: { ...entry.value, metadata: null } };
48
47
  }
49
- async function pipeCapped(source, target, cap, signal) {
48
+ async function pipeCapped(source, target, { cap, signal }) {
50
49
  const sink = fs.createWriteStream(target, { mode: 0o600 });
51
50
  let sinkError = null;
52
51
  sink.on('error', (err) => {
@@ -68,15 +67,17 @@ async function pipeCapped(source, target, cap, signal) {
68
67
  const slice = chunk.byteLength > room ? chunk.subarray(0, room) : chunk;
69
68
  sink.write(slice);
70
69
  written += slice.byteLength;
71
- if (slice.byteLength < chunk.byteLength)
70
+ if (slice.byteLength < chunk.byteLength) {
72
71
  truncated = true;
72
+ }
73
73
  }
74
74
  }
75
75
  finally {
76
76
  await new Promise((resolve) => sink.end(resolve));
77
77
  }
78
- if (sinkError)
78
+ if (sinkError) {
79
79
  throw sinkError;
80
+ }
80
81
  return truncated;
81
82
  }
82
83
  function folderRange(folder) {
@@ -88,18 +89,20 @@ async function handleRequest(acquired, request, signal) {
88
89
  switch (request.op) {
89
90
  case 'entry': {
90
91
  const entry = await drive.entry(request.key, { timeout: DRIVE_OP_TIMEOUT_MS, wait: true });
91
- return { entry: stripMetadata(entry) };
92
+ return { entry: entry ? stripMetadata(entry) : null };
92
93
  }
93
94
  case 'get': {
94
95
  const entry = await drive.entry(request.key, { timeout: DRIVE_OP_TIMEOUT_MS, wait: true });
95
- if (!entry)
96
+ if (!entry) {
96
97
  return { path: null };
98
+ }
97
99
  if ((entry.value.blob?.byteLength ?? 0) > MAX_DRIVE_BYTES) {
98
100
  return { error: `get exceeds ${MAX_DRIVE_BYTES} bytes: ${request.key}` };
99
101
  }
100
102
  const buffer = await drive.get(request.key, { timeout: DRIVE_OP_TIMEOUT_MS, wait: true });
101
- if (!buffer)
103
+ if (!buffer) {
102
104
  return { path: null };
105
+ }
103
106
  const target = await stagedPath('drive-get');
104
107
  signal.addEventListener('abort', () => void fs.promises.unlink(target).catch(noop), {
105
108
  once: true
@@ -112,7 +115,10 @@ async function handleRequest(acquired, request, signal) {
112
115
  signal.addEventListener('abort', () => void fs.promises.unlink(target).catch(noop), {
113
116
  once: true
114
117
  });
115
- const truncated = await pipeCapped(drive.createReadStream(request.key), target, MAX_DRIVE_BYTES, signal);
118
+ const truncated = await pipeCapped(drive.createReadStream(request.key), target, {
119
+ cap: MAX_DRIVE_BYTES,
120
+ signal
121
+ });
116
122
  return { path: target, truncated };
117
123
  }
118
124
  case 'list': {
@@ -132,8 +138,9 @@ async function handleRequest(acquired, request, signal) {
132
138
  return { entries, cursor };
133
139
  }
134
140
  case 'write': {
135
- if (!acquired.writable)
141
+ if (!acquired.writable) {
136
142
  return { error: `drive is read-only: cannot write ${request.key}` };
143
+ }
137
144
  const resolvedPath = path.resolve(request.path);
138
145
  if (path.relative(HARNESS_STAGING_DIR, resolvedPath).startsWith('..')) {
139
146
  return { error: `write path is outside the staging directory: ${request.path}` };
@@ -153,13 +160,14 @@ async function handleRequest(acquired, request, signal) {
153
160
  export function createDriveOp(drives) {
154
161
  return async (request) => {
155
162
  const acquired = drives.get(request.driveKey);
156
- if (!acquired)
163
+ if (!acquired) {
157
164
  return { error: `drive not granted for this run: ${request.driveKey}` };
165
+ }
158
166
  try {
159
167
  return await withDeadline(request.op, DRIVE_OP_TIMEOUT_MS, (signal) => handleRequest(acquired, request, signal));
160
168
  }
161
169
  catch (err) {
162
- return { error: err instanceof Error ? err.message : String(err) };
170
+ return { error: errorMessage(err) };
163
171
  }
164
172
  };
165
173
  }
@@ -168,8 +176,9 @@ export async function resolveFsGrants(grants, driveHost, onDropped) {
168
176
  .filter((grant) => grant.kind === 'local')
169
177
  .map((grant) => grant.path);
170
178
  const hyperGrants = grants.filter((grant) => grant.kind === 'hyper');
171
- if (!driveHost || hyperGrants.length === 0)
179
+ if (!driveHost || hyperGrants.length === 0) {
172
180
  return { grantedDirs, grantedDrives: [] };
181
+ }
173
182
  const drives = new Map();
174
183
  const grantedDrives = [];
175
184
  for (const grant of hyperGrants) {
@@ -182,7 +191,8 @@ export async function resolveFsGrants(grants, driveHost, onDropped) {
182
191
  onDropped?.(grant.key, err);
183
192
  }
184
193
  }
185
- if (drives.size === 0)
194
+ if (drives.size === 0) {
186
195
  return { grantedDirs, grantedDrives: [] };
196
+ }
187
197
  return { grantedDirs, grantedDrives, driveOp: createDriveOp(drives) };
188
198
  }
@@ -14,25 +14,30 @@ function parseHyperKey(value) {
14
14
  export function fsGrantsFrom(value) {
15
15
  if (!Array.isArray(value))
16
16
  return [];
17
+ const items = value;
17
18
  const grants = [];
18
- for (const item of value) {
19
+ for (const item of items) {
19
20
  if (typeof item === 'string') {
20
- if (path.isAbsolute(item))
21
+ if (path.isAbsolute(item)) {
21
22
  grants.push({ kind: 'local', path: item });
23
+ }
22
24
  continue;
23
25
  }
24
- if (!item || typeof item !== 'object')
26
+ if (!item || typeof item !== 'object') {
25
27
  continue;
26
- const kind = item.kind;
28
+ }
29
+ const kind = 'kind' in item ? item.kind : undefined;
27
30
  if (kind === 'local') {
28
- const dir = item.path;
29
- if (typeof dir === 'string' && path.isAbsolute(dir))
31
+ const dir = 'path' in item ? item.path : undefined;
32
+ if (typeof dir === 'string' && path.isAbsolute(dir)) {
30
33
  grants.push({ kind: 'local', path: dir });
34
+ }
31
35
  }
32
36
  else if (kind === 'hyper') {
33
- const key = parseHyperKey(item.key);
34
- if (key)
37
+ const key = parseHyperKey('key' in item ? item.key : undefined);
38
+ if (key) {
35
39
  grants.push({ kind: 'hyper', key });
40
+ }
36
41
  }
37
42
  }
38
43
  return grants;
@@ -0,0 +1,3 @@
1
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
2
+ export declare function errorMessage(err: unknown): string;
3
+ export declare function asError(err: unknown): Error;
@@ -0,0 +1,9 @@
1
+ export function isRecord(value) {
2
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
3
+ }
4
+ export function errorMessage(err) {
5
+ return err instanceof Error ? err.message : String(err);
6
+ }
7
+ export function asError(err) {
8
+ return err instanceof Error ? err : new Error(String(err));
9
+ }