@qvac/core 0.5.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (399) hide show
  1. package/CHANGELOG.md +92 -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 +31 -11
  58. package/dist-lib/lib/assistant.js +846 -390
  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 +50 -31
  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 +70 -0
  95. package/dist-lib/lib/core/collections.js +70 -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.d.ts +2 -0
  103. package/dist-lib/lib/core/contract/chat.js +67 -1
  104. package/dist-lib/lib/core/contract/chunks.js +15 -9
  105. package/dist-lib/lib/core/contract/compute.d.ts +1 -1
  106. package/dist-lib/lib/core/contract/compute.js +4 -2
  107. package/dist-lib/lib/core/contract/devices.js +6 -5
  108. package/dist-lib/lib/core/contract/grant-order.js +5 -6
  109. package/dist-lib/lib/core/contract/index.js +4 -2
  110. package/dist-lib/lib/core/contract/indexing.js +3 -3
  111. package/dist-lib/lib/core/contract/invites.d.ts +8 -3
  112. package/dist-lib/lib/core/contract/invites.js +52 -26
  113. package/dist-lib/lib/core/contract/joined-meshes.js +3 -3
  114. package/dist-lib/lib/core/contract/knowledge.js +5 -5
  115. package/dist-lib/lib/core/contract/members.d.ts +13 -2
  116. package/dist-lib/lib/core/contract/members.js +46 -25
  117. package/dist-lib/lib/core/contract/mesh-kind.js +9 -8
  118. package/dist-lib/lib/core/contract/seal.js +1 -1
  119. package/dist-lib/lib/core/contract/seed-defaults.js +1 -3
  120. package/dist-lib/lib/core/contract/tool-activity.js +10 -5
  121. package/dist-lib/lib/core/contract/tool-configs.js +1 -2
  122. package/dist-lib/lib/core/contract/writers.d.ts +6 -1
  123. package/dist-lib/lib/core/contract/writers.js +55 -34
  124. package/dist-lib/lib/core/departures.js +16 -8
  125. package/dist-lib/lib/core/device-invites.js +3 -2
  126. package/dist-lib/lib/core/devices.js +6 -3
  127. package/dist-lib/lib/core/document-attachment.d.ts +20 -11
  128. package/dist-lib/lib/core/document-attachment.js +10 -5
  129. package/dist-lib/lib/core/files/attachments.d.ts +2 -5
  130. package/dist-lib/lib/core/files/attachments.js +6 -3
  131. package/dist-lib/lib/core/files/index.d.ts +46 -52
  132. package/dist-lib/lib/core/files/index.js +149 -94
  133. package/dist-lib/lib/core/files/knowledge.d.ts +2 -5
  134. package/dist-lib/lib/core/files/local-index.d.ts +4 -1
  135. package/dist-lib/lib/core/files/local-index.js +9 -5
  136. package/dist-lib/lib/core/files/preview/image.d.ts +0 -1
  137. package/dist-lib/lib/core/files/preview/image.js +9 -6
  138. package/dist-lib/lib/core/files/preview/index.d.ts +8 -11
  139. package/dist-lib/lib/core/files/preview/index.js +20 -15
  140. package/dist-lib/lib/core/files/processing/claims.d.ts +6 -5
  141. package/dist-lib/lib/core/files/processing/claims.js +16 -8
  142. package/dist-lib/lib/core/files/processing/document.d.ts +21 -50
  143. package/dist-lib/lib/core/files/processing/index.d.ts +21 -13
  144. package/dist-lib/lib/core/files/processing/index.js +74 -37
  145. package/dist-lib/lib/core/files/processing/ownership.d.ts +8 -1
  146. package/dist-lib/lib/core/files/processing/ownership.js +1 -1
  147. package/dist-lib/lib/core/files/processing/protocol.d.ts +19 -19
  148. package/dist-lib/lib/core/files/processing/protocol.js +5 -5
  149. package/dist-lib/lib/core/files/processing/settle.d.ts +10 -7
  150. package/dist-lib/lib/core/files/processing/settle.js +22 -11
  151. package/dist-lib/lib/core/files/processing/source.js +14 -8
  152. package/dist-lib/lib/core/files/processing/state.d.ts +14 -11
  153. package/dist-lib/lib/core/files/processing/state.js +24 -12
  154. package/dist-lib/lib/core/files/rag/build.d.ts +2 -2
  155. package/dist-lib/lib/core/files/rag/build.js +2 -1
  156. package/dist-lib/lib/core/files/rag/document-types.d.ts +4 -6
  157. package/dist-lib/lib/core/files/rag/index.d.ts +12 -13
  158. package/dist-lib/lib/core/files/rag/index.js +9 -2
  159. package/dist-lib/lib/core/files/rag/load.d.ts +10 -9
  160. package/dist-lib/lib/core/files/rag/load.js +26 -13
  161. package/dist-lib/lib/core/files/rag/policy.js +2 -1
  162. package/dist-lib/lib/core/files/rag/produce.js +33 -19
  163. package/dist-lib/lib/core/files/rag/retrieval/full-text.d.ts +5 -3
  164. package/dist-lib/lib/core/files/rag/retrieval/full-text.js +30 -10
  165. package/dist-lib/lib/core/files/records/chunks.js +4 -2
  166. package/dist-lib/lib/core/files/records/index.d.ts +1 -0
  167. package/dist-lib/lib/core/files/records/index.js +1 -0
  168. package/dist-lib/lib/core/files/records/knowledge.d.ts +10 -11
  169. package/dist-lib/lib/core/files/records/knowledge.js +9 -8
  170. package/dist-lib/lib/core/files/records/linkage.js +6 -3
  171. package/dist-lib/lib/core/files/records/output.d.ts +5 -4
  172. package/dist-lib/lib/core/files/records/output.js +8 -4
  173. package/dist-lib/lib/core/files/records/purge.d.ts +4 -0
  174. package/dist-lib/lib/core/files/records/purge.js +108 -0
  175. package/dist-lib/lib/core/files/records/reclaim.js +43 -25
  176. package/dist-lib/lib/core/files/records/routing.d.ts +4 -6
  177. package/dist-lib/lib/core/files/records/routing.js +15 -8
  178. package/dist-lib/lib/core/files/records/source.d.ts +5 -4
  179. package/dist-lib/lib/core/files/records/source.js +20 -14
  180. package/dist-lib/lib/core/files/records/sweep.js +1 -3
  181. package/dist-lib/lib/core/files/store/blob.d.ts +11 -10
  182. package/dist-lib/lib/core/files/store/blob.js +54 -19
  183. package/dist-lib/lib/core/files/store/index.d.ts +2 -6
  184. package/dist-lib/lib/core/files/store/index.js +10 -5
  185. package/dist-lib/lib/core/files/store/inline.d.ts +2 -2
  186. package/dist-lib/lib/core/files/store/inline.js +6 -3
  187. package/dist-lib/lib/core/files/store/reference.d.ts +6 -9
  188. package/dist-lib/lib/core/files/store/reference.js +25 -17
  189. package/dist-lib/lib/core/files/store/server.d.ts +7 -6
  190. package/dist-lib/lib/core/files/store/server.js +22 -11
  191. package/dist-lib/lib/core/files/store/sweep.js +13 -7
  192. package/dist-lib/lib/core/files/upload-input.d.ts +4 -12
  193. package/dist-lib/lib/core/files/upload-input.js +10 -5
  194. package/dist-lib/lib/core/files/upload.d.ts +27 -24
  195. package/dist-lib/lib/core/files/upload.js +74 -51
  196. package/dist-lib/lib/core/fs-drives.js +4 -2
  197. package/dist-lib/lib/core/grant-expiry.js +12 -7
  198. package/dist-lib/lib/core/handoff-channel.js +27 -13
  199. package/dist-lib/lib/core/harness-loan.js +35 -17
  200. package/dist-lib/lib/core/helpers/index.js +6 -2
  201. package/dist-lib/lib/core/hosted-agents.js +19 -12
  202. package/dist-lib/lib/core/id.js +1 -1
  203. package/dist-lib/lib/core/identity.js +6 -3
  204. package/dist-lib/lib/core/image/cache-sweep.d.ts +12 -10
  205. package/dist-lib/lib/core/image/cache-sweep.js +11 -6
  206. package/dist-lib/lib/core/image/normalize.d.ts +6 -0
  207. package/dist-lib/lib/core/image/normalize.js +12 -2
  208. package/dist-lib/lib/core/image/sniff.js +42 -21
  209. package/dist-lib/lib/core/inference-calls-receiver.js +7 -4
  210. package/dist-lib/lib/core/invite-grants.js +4 -2
  211. package/dist-lib/lib/core/invite.js +2 -1
  212. package/dist-lib/lib/core/local/files.d.ts +2 -0
  213. package/dist-lib/lib/core/local/files.js +51 -19
  214. package/dist-lib/lib/core/local/index.d.ts +69 -46
  215. package/dist-lib/lib/core/local/index.js +146 -129
  216. package/dist-lib/lib/core/membership.d.ts +12 -2
  217. package/dist-lib/lib/core/membership.js +55 -33
  218. package/dist-lib/lib/core/mesh-seed-handoff.js +7 -1
  219. package/dist-lib/lib/core/mesh.d.ts +37 -27
  220. package/dist-lib/lib/core/mesh.js +131 -73
  221. package/dist-lib/lib/core/migrations/agent-catalog.js +3 -2
  222. package/dist-lib/lib/core/migrations/agent-indexes.js +3 -3
  223. package/dist-lib/lib/core/migrations/file-index.js +7 -4
  224. package/dist-lib/lib/core/migrations/index.d.ts +4 -3
  225. package/dist-lib/lib/core/migrations/membership.js +9 -4
  226. package/dist-lib/lib/core/migrations/seal.js +3 -2
  227. package/dist-lib/lib/core/min-version.js +4 -2
  228. package/dist-lib/lib/core/next-frame.d.ts +5 -4
  229. package/dist-lib/lib/core/next-frame.js +6 -3
  230. package/dist-lib/lib/core/notification.d.ts +5 -1
  231. package/dist-lib/lib/core/notification.js +89 -77
  232. package/dist-lib/lib/core/ota-config.js +2 -1
  233. package/dist-lib/lib/core/pdf/rasterize.d.ts +18 -0
  234. package/dist-lib/lib/core/pdf/rasterize.js +57 -0
  235. package/dist-lib/lib/core/prompt-history.js +4 -2
  236. package/dist-lib/lib/core/range.d.ts +4 -4
  237. package/dist-lib/lib/core/range.js +12 -6
  238. package/dist-lib/lib/core/rank.d.ts +5 -4
  239. package/dist-lib/lib/core/rank.js +2 -1
  240. package/dist-lib/lib/core/send.d.ts +4 -4
  241. package/dist-lib/lib/core/send.js +6 -3
  242. package/dist-lib/lib/core/skill-overlay-receiver.js +7 -4
  243. package/dist-lib/lib/core/skill-secrets.js +16 -9
  244. package/dist-lib/lib/core/sync/chunks.js +2 -1
  245. package/dist-lib/lib/core/sync/devices.js +3 -1
  246. package/dist-lib/lib/core/sync/files.d.ts +2 -4
  247. package/dist-lib/lib/core/sync/files.js +28 -20
  248. package/dist-lib/lib/core/sync/index.d.ts +2 -5
  249. package/dist-lib/lib/core/sync/index.js +33 -15
  250. package/dist-lib/lib/core/sync-status.js +10 -7
  251. package/dist-lib/lib/core/system-info.js +4 -2
  252. package/dist-lib/lib/core/tool-activity.d.ts +4 -3
  253. package/dist-lib/lib/core/tool-activity.js +1 -1
  254. package/dist-lib/lib/core/tool-configs.js +12 -7
  255. package/dist-lib/lib/core.d.ts +38 -26
  256. package/dist-lib/lib/core.js +1009 -541
  257. package/dist-lib/lib/credential-pusher.d.ts +20 -20
  258. package/dist-lib/lib/credential-pusher.js +65 -43
  259. package/dist-lib/lib/custom-model-pusher.d.ts +7 -3
  260. package/dist-lib/lib/custom-model-pusher.js +15 -7
  261. package/dist-lib/lib/custom-model-task.d.ts +1 -0
  262. package/dist-lib/lib/custom-model-task.js +12 -0
  263. package/dist-lib/lib/deadline.js +4 -2
  264. package/dist-lib/lib/diagnostics.d.ts +1 -5
  265. package/dist-lib/lib/frame-readable.d.ts +3 -0
  266. package/dist-lib/lib/frame-readable.js +3 -0
  267. package/dist-lib/lib/fs-drive-bridge.js +24 -14
  268. package/dist-lib/lib/fs-grants.js +13 -8
  269. package/dist-lib/lib/guards.d.ts +3 -0
  270. package/dist-lib/lib/guards.js +9 -0
  271. package/dist-lib/lib/inference-calls.d.ts +28 -23
  272. package/dist-lib/lib/inference-calls.js +25 -13
  273. package/dist-lib/lib/integrations/mcp-providers.d.ts +2 -2
  274. package/dist-lib/lib/integrations/setup-routes.d.ts +2 -2
  275. package/dist-lib/lib/knowledge-search.d.ts +6 -5
  276. package/dist-lib/lib/knowledge-search.js +26 -18
  277. package/dist-lib/lib/kv-cache-reclaim.js +4 -2
  278. package/dist-lib/lib/kv-cache.js +8 -4
  279. package/dist-lib/lib/legacy-core-domain.d.ts +42 -42
  280. package/dist-lib/lib/log-buffer.js +2 -1
  281. package/dist-lib/lib/log.js +25 -15
  282. package/dist-lib/lib/mesh-scoped-engine.js +12 -4
  283. package/dist-lib/lib/model-catalog-revision.js +6 -3
  284. package/dist-lib/lib/model-clamp.js +6 -3
  285. package/dist-lib/lib/model-context.d.ts +8 -3
  286. package/dist-lib/lib/model-context.js +13 -5
  287. package/dist-lib/lib/model-download-status.js +4 -2
  288. package/dist-lib/lib/model-download.d.ts +12 -4
  289. package/dist-lib/lib/model-download.js +200 -103
  290. package/dist-lib/lib/model-idle-pusher.d.ts +2 -2
  291. package/dist-lib/lib/model-idle-pusher.js +3 -4
  292. package/dist-lib/lib/oauth/browser-connect.d.ts +10 -8
  293. package/dist-lib/lib/oauth/browser-connect.js +33 -20
  294. package/dist-lib/lib/oauth/client.d.ts +2 -2
  295. package/dist-lib/lib/oauth/flow-core.js +23 -9
  296. package/dist-lib/lib/oauth/flow.d.ts +1 -3
  297. package/dist-lib/lib/oauth/flow.js +9 -5
  298. package/dist-lib/lib/oauth/keys.d.ts +4 -4
  299. package/dist-lib/lib/oauth/keys.js +18 -12
  300. package/dist-lib/lib/oauth/loopback.d.ts +2 -2
  301. package/dist-lib/lib/oauth/loopback.js +147 -107
  302. package/dist-lib/lib/oauth/loopback.stub.d.ts +2 -2
  303. package/dist-lib/lib/oauth/loopback.stub.js +1 -1
  304. package/dist-lib/lib/oauth/pkce.d.ts +4 -2
  305. package/dist-lib/lib/oauth/pkce.js +10 -0
  306. package/dist-lib/lib/oauth/providers.js +5 -5
  307. package/dist-lib/lib/oauth/redirect-types.d.ts +12 -7
  308. package/dist-lib/lib/oauth/register.js +3 -2
  309. package/dist-lib/lib/oauth/registry.d.ts +2 -2
  310. package/dist-lib/lib/oauth/registry.js +2 -1
  311. package/dist-lib/lib/oauth/resolve.d.ts +30 -10
  312. package/dist-lib/lib/oauth/resolve.js +12 -6
  313. package/dist-lib/lib/oauth/token-exchange-core.d.ts +12 -4
  314. package/dist-lib/lib/oauth/token-exchange-core.js +1 -1
  315. package/dist-lib/lib/oauth/types.d.ts +12 -12
  316. package/dist-lib/lib/oauth.d.ts +4 -5
  317. package/dist-lib/lib/oauth.js +2 -3
  318. package/dist-lib/lib/reconnecting-watch.d.ts +1 -1
  319. package/dist-lib/lib/reconnecting-watch.js +6 -6
  320. package/dist-lib/lib/retry-budget.js +6 -3
  321. package/dist-lib/lib/run-notices.d.ts +1 -0
  322. package/dist-lib/lib/run-notices.js +5 -2
  323. package/dist-lib/lib/run-transcript.d.ts +2 -4
  324. package/dist-lib/lib/run-transcript.js +4 -2
  325. package/dist-lib/lib/skill-readiness.js +4 -2
  326. package/dist-lib/lib/skill-types.d.ts +16 -16
  327. package/dist-lib/lib/suspend-lifecycle.d.ts +4 -4
  328. package/dist-lib/lib/suspend-lifecycle.js +10 -5
  329. package/dist-lib/lib/task.js +22 -12
  330. package/dist-lib/lib/unref.d.ts +3 -2
  331. package/dist-lib/lib/unref.js +2 -1
  332. package/dist-lib/lib/wav-duration.js +10 -5
  333. package/dist-lib/lib/write-queue.d.ts +5 -4
  334. package/dist-lib/lib/write-queue.js +2 -1
  335. package/dist-lib/schema/build.js +10 -6
  336. package/dist-lib/schema/config.d.ts +2 -3
  337. package/dist-lib/schema/content.d.ts +17 -2
  338. package/dist-lib/schema/content.js +2 -1
  339. package/dist-lib/schema/engine.d.ts +3 -2
  340. package/dist-lib/schema/engine.js +95 -6
  341. package/dist-lib/schema/field-order.js +22 -11
  342. package/dist-lib/schema/indexes.d.ts +22 -0
  343. package/dist-lib/schema/{helpers.js → indexes.js} +14 -57
  344. package/dist-lib/schema/local.d.ts +3 -2
  345. package/dist-lib/schema/local.js +7 -2
  346. package/dist-lib/schema/media-kind.d.ts +8 -0
  347. package/dist-lib/schema/media-kind.js +52 -0
  348. package/dist-lib/schema/qvac.d.ts +12 -9
  349. package/dist-lib/schema/qvac.js +18 -4
  350. package/dist-lib/spec/bind.js +12 -0
  351. package/dist-lib/spec/calls.js +4 -0
  352. package/dist-lib/spec/capabilities.d.ts +12 -4
  353. package/dist-lib/spec/hrpc/hrpc.json +54 -2
  354. package/dist-lib/spec/hrpc/index.js +53 -5
  355. package/dist-lib/spec/hrpc/messages.js +783 -494
  356. package/dist-lib/spec/hyperschema/index.js +783 -494
  357. package/dist-lib/spec/hyperschema/schema.json +247 -1
  358. package/dist-lib/spec/hyperschema/types.d.ts +69 -1
  359. package/dist-lib/spec/local/hyperdb/index.js +1 -1
  360. package/dist-lib/spec/local/hyperdb/messages.js +82 -14
  361. package/dist-lib/spec/local/hyperschema/index.js +42 -8
  362. package/dist-lib/spec/local/hyperschema/schema.json +27 -1
  363. package/dist-lib/spec/local/hyperschema/types.d.ts +6 -1
  364. package/dist-lib/spec/mesh/hyperdb/db.json +16 -1
  365. package/dist-lib/spec/mesh/hyperdb/index.js +72 -3
  366. package/dist-lib/spec/mesh/hyperdb/messages.js +400 -221
  367. package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +7 -1
  368. package/dist-lib/spec/mesh/hyperdispatch/index.js +18 -1
  369. package/dist-lib/spec/mesh/hyperdispatch/messages.js +117 -2
  370. package/dist-lib/spec/mesh/hyperschema/index.js +117 -2
  371. package/dist-lib/spec/mesh/hyperschema/schema.json +65 -1
  372. package/dist-lib/spec/mesh/hyperschema/types.d.ts +19 -1
  373. package/package.json +8 -4
  374. package/tui/app.mjs +2424 -941
  375. package/tui/boot.mjs +18 -49
  376. package/tui/index.mjs +10 -5
  377. package/tui/lib/boot-timing.mjs +8 -8
  378. package/tui/lib/busy-words.mjs +21 -22
  379. package/tui/lib/export.mjs +100 -32
  380. package/tui/lib/knowledge-command.mjs +64 -19
  381. package/tui/lib/knowledge-import.mjs +52 -18
  382. package/tui/lib/render.mjs +65 -33
  383. package/tui/lib/save-file.mjs +30 -13
  384. package/tui/lib/select.mjs +23 -5
  385. package/tui/lib/selection.mjs +6 -4
  386. package/tui/lib/setup.mjs +11 -19
  387. package/tui/lib/sidebar.mjs +23 -13
  388. package/tui/lib/splash.mjs +6 -7
  389. package/tui/lib/upload-frames.mjs +1 -2
  390. package/tui/lib/usage.mjs +13 -9
  391. package/tui/lib/wrap.mjs +35 -6
  392. package/tui/main.mjs +54 -78
  393. package/worker/assistant-sidecar.mjs +5 -10
  394. package/worker/stow-entry.mjs +7 -4
  395. package/dist-lib/lib/custom-model-source.d.ts +0 -15
  396. package/dist-lib/lib/custom-model-source.js +0 -46
  397. package/dist-lib/lib/oauth/common.d.ts +0 -38
  398. package/dist-lib/lib/oauth/common.js +0 -34
  399. package/dist-lib/schema/helpers.d.ts +0 -33
@@ -1,10 +1,12 @@
1
- // The active agent and chat live in Core's device-local typed config, where the desktop app
2
- // keeps them too, so duck resumes where either app left off. setConfig replaces the whole
3
- // writable record, so the untouched fields ride along from the current read.
1
+ // setConfig replaces the whole writable record, so the untouched fields ride along from the read
4
2
  export async function rememberSelection(engine, { agentId, chatId }) {
5
3
  const current = await engine.getConfig({})
6
- if (current.activeAgentId === agentId && current.activeChatId === chatId) return current
4
+ if (current.activeAgentId === agentId && current.activeChatId === chatId) {
5
+ return current
6
+ }
7
+
7
8
  const { thinkingEnabled, ctxSize, onboardingCompleted, delegation } = current
9
+
8
10
  return engine.setConfig({
9
11
  activeAgentId: agentId,
10
12
  activeChatId: chatId,
package/tui/lib/setup.mjs CHANGED
@@ -1,8 +1,4 @@
1
- // What a skill still needs before it can run, expressed as something the TUI can
2
- // run for you: an OAuth route becomes /connect, a pasted-token route a /cred
3
- // stub, anything else its own steps. The routes themselves come from the shared
4
- // integrations registry, so the TUI and the desktop Settings UI agree on what
5
- // setting a skill up means.
1
+ // routes come from the shared integrations registry so the TUI and desktop agree on setup
6
2
  import { deriveSetupRoutes } from '../../dist-lib/lib/integrations/index.js'
7
3
 
8
4
  const STATUS_LABELS = {
@@ -31,23 +27,20 @@ export function connectSlug(credentialKey) {
31
27
  .replaceAll('_', '-')
32
28
  }
33
29
 
34
- // Every route a skill exposes, in manifest order. A skill can have more than
35
- // one way in — Obsidian is either the CLI or a vault folder — and the ones that
36
- // carry a credential key are also how it is RECONFIGURED later.
30
+ // the routes that carry a credential key are also how a skill is reconfigured later
37
31
  export function setupActions(skill) {
38
32
  return (deriveSetupRoutes(skillEntry(skill)).routes ?? []).map((route) =>
39
33
  routeAction(route, skill)
40
34
  )
41
35
  }
42
36
 
43
- // What to offer, and what else there is: `primary` is the first unsatisfied
44
- // route, preferring one the TUI can run over one that only prints instructions;
45
- // `others` are the remaining ways in, rendered as a one-line "or …" each.
37
+ // prefers a route the TUI can run over one that only prints instructions
46
38
  export function setupPlan(skill) {
47
39
  const actions = setupActions(skill)
48
40
  const open = actions.filter((action) => !action.satisfied)
49
41
  const primary = open.find((action) => action.command || action.prefill) ?? open[0] ?? null
50
42
  const others = actions.filter((action) => action !== primary)
43
+
51
44
  return { primary, others }
52
45
  }
53
46
 
@@ -55,10 +48,7 @@ export function setupAction(skill) {
55
48
  return setupPlan(skill).primary
56
49
  }
57
50
 
58
- // Every route the TUI can run, offered one first. A connected skill keeps
59
- // these: they are how it is pointed somewhere else (another Obsidian vault,
60
- // another GitHub token) — a route with a credential key is configuration, not
61
- // a one-time connect.
51
+ // a connected skill keeps these: a route with a credential key is configuration, not a one-off
62
52
  export function configureActions(skill) {
63
53
  const { primary, others } = setupPlan(skill)
64
54
  return [primary, ...others].filter((action) => action?.command || action?.prefill)
@@ -75,10 +65,14 @@ function routeAction(route, skill) {
75
65
  command: undefined,
76
66
  prefill: undefined
77
67
  }
78
- if (!route.credentialKey) return action
68
+ if (!route.credentialKey) {
69
+ return action
70
+ }
71
+
79
72
  if (route.kind === 'oauth') {
80
73
  return { ...action, kind: 'connect', command: `/connect ${connectSlug(route.credentialKey)}` }
81
74
  }
75
+
82
76
  return { ...action, kind: 'cred', prefill: `/cred ${route.credentialKey} ` }
83
77
  }
84
78
 
@@ -86,9 +80,7 @@ function installSteps(skill) {
86
80
  return (skill.install ?? []).map((s) => (s.command ? `${s.label} → ${s.command}` : s.label))
87
81
  }
88
82
 
89
- // The engine reports a skill flat (name, status, credentials, …); the route
90
- // registry reads a catalog entry. `a|b` credential slots list interchangeable
91
- // keys — each is its own candidate route.
83
+ // `a|b` credential slots list interchangeable keys, each its own candidate route
92
84
  function skillEntry(skill) {
93
85
  const credentials = (skill.requires?.credentials ?? skill.credentials ?? []).flatMap((slot) =>
94
86
  slot.split('|')
@@ -1,7 +1,4 @@
1
- // The chat sidebar's row model: chats under their groups, in the order core
2
- // presents them (groups first, each chat where it was dragged or else
3
- // newest-activity first). Rows are what the pane draws and what its cursor
4
- // walks; only `chat` rows are selectable.
1
+ // the chat sidebar's row model; only `chat` rows are selectable
5
2
 
6
3
  export const SIDEBAR_COLS = 26
7
4
 
@@ -11,32 +8,45 @@ export function sidebarRows(chats, groups, activeId) {
11
8
  for (const group of groups ?? []) {
12
9
  const held = live.filter((chat) => chat.groupId === group.id)
13
10
  rows.push({ kind: 'group', label: group.name })
14
- if (!held.length) rows.push({ kind: 'empty', label: '(empty)' })
15
- for (const chat of held) rows.push(chatRow(chat, activeId))
11
+ if (!held.length) {
12
+ rows.push({ kind: 'empty', label: '(empty)' })
13
+ }
14
+
15
+ for (const chat of held) {
16
+ rows.push(chatRow(chat, activeId))
17
+ }
16
18
  }
19
+
17
20
  const loose = live.filter((chat) => !chat.groupId)
18
- if (loose.length && rows.length) rows.push({ kind: 'group', label: '(ungrouped)' })
19
- for (const chat of loose) rows.push(chatRow(chat, activeId))
21
+ if (loose.length && rows.length) {
22
+ rows.push({ kind: 'group', label: '(ungrouped)' })
23
+ }
24
+
25
+ for (const chat of loose) {
26
+ rows.push(chatRow(chat, activeId))
27
+ }
28
+
20
29
  return rows
21
30
  }
22
31
 
23
- // The move picker's rows — every group, plus ungrouping, minus the one the chat
24
- // already sits in.
25
32
  export function moveRows(groups, groupId) {
26
33
  const rows = (groups ?? [])
27
34
  .filter((group) => group.id !== groupId)
28
35
  .map((group) => ({ kind: 'target', label: group.name, groupId: group.id }))
29
- if (groupId) rows.unshift({ kind: 'target', label: '(no group)', groupId: null })
36
+ if (groupId) {
37
+ rows.unshift({ kind: 'target', label: '(no group)', groupId: null })
38
+ }
39
+
30
40
  rows.push({ kind: 'new-group', label: 'New group…' })
41
+
31
42
  return rows
32
43
  }
33
44
 
34
- // The next row the cursor may land on, walking `delta` at a time; the headers
35
- // and the (empty) placeholders are skipped. Stays put at either end.
36
45
  export function nextSelectable(rows, from, delta) {
37
46
  for (let i = from + delta; i >= 0 && i < rows.length; i += delta) {
38
47
  if (selectable(rows[i])) return i
39
48
  }
49
+
40
50
  return selectable(rows[from]) ? from : firstSelectable(rows)
41
51
  }
42
52
 
@@ -1,19 +1,18 @@
1
1
  import { SIZES } from './splash-art.mjs'
2
2
 
3
- // The ducks, centered in a width x height box — the widest cut that fits, or
4
- // null when even the smallest doesn't. Rows carry their own SGR and reset, so
5
- // the caller can hand the result straight to wrapBlock: every row's visible
6
- // width is its cut's width, which fits by construction.
3
+ // rows carry their own SGR and reset, so the result goes straight to wrapBlock
7
4
  export function splash(width, height) {
8
5
  const art = SIZES.find((size) => size.width <= width && size.rows.length <= height)
9
- if (!art) return null
6
+ if (!art) {
7
+ return null
8
+ }
9
+
10
10
  const indent = ' '.repeat((width - art.width) >> 1)
11
11
  const above = '\n'.repeat((height - art.rows.length) >> 1)
12
+
12
13
  return above + art.rows.map((row) => indent + row).join('\n')
13
14
  }
14
15
 
15
- // Centered against the same box, so a caption sits under the art rather than
16
- // against the left edge.
17
16
  export function center(line, width, plainWidth = line.length) {
18
17
  return ' '.repeat(Math.max(0, (width - plainWidth) >> 1)) + line
19
18
  }
@@ -1,7 +1,6 @@
1
1
  import { Writable } from 'streamx'
2
2
 
3
- // A multi-megabyte frame never reaches the host — the wire drops it whole and
4
- // the upload ends with no response. Every blob upload goes up in these.
3
+ // the wire drops a multi-megabyte frame whole and the upload ends with no response
5
4
  export const UPLOAD_FRAME_BYTES = 64 * 1024
6
5
 
7
6
  export function writeFrame(stream, frame) {
package/tui/lib/usage.mjs CHANGED
@@ -1,7 +1,5 @@
1
1
  import b4a from 'b4a'
2
- // What the run itself reported, and nothing counted here: `ctxSize` is the window the device
3
- // that ran the turn had loaded, `cacheTokens` the SDK's occupancy reading, `usage` the
4
- // harness's attribution of the prompt it sent (docs/decisions in @qvac/harness).
2
+ // only what the run itself reported, nothing counted here
5
3
  const PROMPT_ROWS = [
6
4
  ['systemPrompt', 'System prompt'],
7
5
  ['agentInstructions', 'Agent instructions'],
@@ -10,15 +8,22 @@ const PROMPT_ROWS = [
10
8
  ]
11
9
 
12
10
  export function usageReport(statuses, folds = []) {
13
- // one row per run, its latest status — as turnsFromChunks reads them — so a run can never count twice
11
+ // one row per run, its latest status as turnsFromChunks reads them, so a run never counts twice
14
12
  const latest = new Map()
15
- for (const chunk of statuses) latest.set(chunk.runId, chunk)
13
+ for (const chunk of statuses) {
14
+ latest.set(chunk.runId, chunk)
15
+ }
16
+
16
17
  const completed = [...latest.values()].filter(
17
18
  (chunk) => chunk.runStatus?.state === 'completed' && chunk.runStatus.metrics
18
19
  )
19
- if (!completed.length) return null
20
+ if (!completed.length) {
21
+ return null
22
+ }
23
+
20
24
  const last = completed[completed.length - 1]
21
25
  const metrics = last.runStatus.metrics
26
+
22
27
  return {
23
28
  runs: completed.length,
24
29
  generated: completed.reduce(
@@ -39,9 +44,7 @@ export function usageReport(statuses, folds = []) {
39
44
  }
40
45
  }
41
46
 
42
- // Conversation is the remainder of the occupancy once the reported prompt rows are taken out,
43
- // so a cost no row authors — the template's turn wrappers, the reply just generated — lands on
44
- // the turns rather than skewing a prompt row; the rows shrink to fit when they exceed it.
47
+ // conversation is the remainder, so a cost no row authors lands on the turns, not a prompt row
45
48
  function promptRows(usage, occupied) {
46
49
  if (!usage || !occupied) return null
47
50
  const reported = PROMPT_ROWS.reduce((sum, [key]) => sum + usage[key], 0)
@@ -51,5 +54,6 @@ function promptRows(usage, occupied) {
51
54
  tokens: Math.floor(usage[key] * scale)
52
55
  }))
53
56
  const known = rows.reduce((sum, row) => sum + row.tokens, 0)
57
+
54
58
  return [{ label: 'Conversation', tokens: occupied - known }, ...rows]
55
59
  }
package/tui/lib/wrap.mjs CHANGED
@@ -22,10 +22,12 @@ export function cells(line) {
22
22
  continue
23
23
  }
24
24
  }
25
+
25
26
  const ch = String.fromCodePoint(line.codePointAt(i))
26
27
  out.push({ ch, w: charWidth(ch) })
27
28
  i += ch.length
28
29
  }
30
+
29
31
  return out
30
32
  }
31
33
 
@@ -34,20 +36,26 @@ function tokens(line) {
34
36
  let token = null
35
37
  for (const cell of cells(line)) {
36
38
  if (cell.esc) {
37
- if (!token) out.push((token = { raw: '', w: 0, space: false, cells: [] }))
39
+ if (!token) {
40
+ out.push((token = { raw: '', w: 0, space: false, cells: [] }))
41
+ }
42
+
38
43
  token.raw += cell.esc
39
44
  token.cells.push(cell)
40
45
  continue
41
46
  }
47
+
42
48
  const space = cell.ch === ' '
43
49
  if (!token || (token.w > 0 && token.space !== space)) {
44
50
  out.push((token = { raw: '', w: 0, space, cells: [] }))
45
51
  }
52
+
46
53
  token.space = space
47
54
  token.raw += cell.ch
48
55
  token.w += cell.w
49
56
  token.cells.push(cell)
50
57
  }
58
+
51
59
  return out
52
60
  }
53
61
 
@@ -56,6 +64,7 @@ function activeSgr(raw) {
56
64
  for (const match of raw.matchAll(SGR_ALL)) {
57
65
  open = match[0] === RESET || match[0] === '\x1b[m' ? '' : open + match[0]
58
66
  }
67
+
59
68
  return open
60
69
  }
61
70
 
@@ -65,7 +74,10 @@ function leadingSpaces(line) {
65
74
  }
66
75
 
67
76
  export function wrapLine(line, max) {
68
- if (max <= 0 || style.width(line) <= max) return [line]
77
+ if (max <= 0 || style.width(line) <= max) {
78
+ return [line]
79
+ }
80
+
69
81
  const indent = ' '.repeat(Math.min(leadingSpaces(line), Math.max(0, max - 1)))
70
82
  const rows = []
71
83
  let row = ''
@@ -82,27 +94,44 @@ export function wrapLine(line, max) {
82
94
  row += token.raw
83
95
  continue
84
96
  }
97
+
85
98
  if (col + token.w <= max) {
86
99
  row += token.raw
87
100
  col += token.w
88
101
  continue
89
102
  }
103
+
90
104
  if (token.space) {
91
- if (col > indent.length) breakRow()
105
+ if (col > indent.length) {
106
+ breakRow()
107
+ }
108
+
92
109
  continue
93
110
  }
94
- if (col > indent.length && indent.length + token.w <= max) breakRow()
111
+
112
+ if (col > indent.length && indent.length + token.w <= max) {
113
+ breakRow()
114
+ }
115
+
95
116
  for (const cell of token.cells) {
96
117
  if (cell.esc) {
97
118
  row += cell.esc
98
119
  continue
99
120
  }
100
- if (col + cell.w > max) breakRow()
121
+
122
+ if (col + cell.w > max) {
123
+ breakRow()
124
+ }
125
+
101
126
  row += cell.ch
102
127
  col += cell.w
103
128
  }
104
129
  }
105
- if (rows.length === 0 || style.width(row) > indent.length) rows.push(row)
130
+
131
+ if (rows.length === 0 || style.width(row) > indent.length) {
132
+ rows.push(row)
133
+ }
134
+
106
135
  return rows
107
136
  }
108
137
 
package/tui/main.mjs CHANGED
@@ -1,6 +1,4 @@
1
- // The TUI itself. index.mjs parses the CLI and imports this only when there is
2
- // something to run; this draws the first frame and then imports boot.mjs, the
3
- // engine side, behind it.
1
+ // the TUI itself: draws the first frame, then imports boot.mjs, the engine side, behind it
4
2
  import fs from 'bare-fs'
5
3
  import os from 'bare-os'
6
4
  import process from 'bare-process'
@@ -13,16 +11,10 @@ import b4a from 'b4a'
13
11
 
14
12
  const { Program } = tui
15
13
 
16
- // how long a lone esc waits to see whether it starts a sequence — the terminal
17
- // writes a real one in a single read, so this only has to beat human perception
14
+ // the terminal writes a real sequence in one read, so this only has to beat human perception
18
15
  const ESCAPE_TIMEOUT_MS = 50
19
16
 
20
- // @qvac/sdk writes its own [sdk:client]/[sdk:server] logs straight to
21
- // console — bare-tui's Program owns the terminal via cursor-tracked ANSI
22
- // output, so any other writer to the same fd corrupts the redraw. Silence
23
- // console output for the TUI's lifetime; errors after it exits still print.
24
- // (llama.cpp's own native stdout logs are a separate path, not covered by
25
- // this — see assistant-harness/lib/sdk-loader.ts.)
17
+ // any other writer to the tty corrupts bare-tui's redraw; errors after exit still print
26
18
  function withConsoleSuppressed(fn) {
27
19
  const original = {
28
20
  log: console.log,
@@ -39,22 +31,18 @@ function withConsoleSuppressed(fn) {
39
31
  error: noop,
40
32
  debug: noop
41
33
  })
34
+
42
35
  return fn().finally(() => Object.assign(console, original))
43
36
  }
44
37
 
45
- // llama.cpp writes some of its own init/inference logs straight to the real
46
- // stdout/stderr fd (see assistant-harness/lib/sdk-loader.ts) — that bypasses
47
- // both withConsoleSuppressed below AND bare-tui's Renderer, which only
48
- // repaints rows whose logical content changed and has no idea those rows got
49
- // clobbered by an external writer. Sending a synthetic resize forces the
50
- // same full repaint Program already does on a real terminal resize, wiping
51
- // any leaked lines. `getProgram` is a thunk because this is wired up before
52
- // Program exists.
38
+ // llama.cpp writes straight to the tty fd; a synthetic resize forces a full repaint over its lines
53
39
  function requestRepaint(getProgram) {
54
40
  const program = getProgram()
55
- if (!program) return
56
- // || not ??: a size-less pty reports 0 columns, and a 0-width resize turns
57
- // the style width math into repeat(-2) — 0 means "unknown", not a size
41
+ if (!program) {
42
+ return
43
+ }
44
+
45
+ // || not ??: a size-less pty reports 0 columns, and 0-width style math hits repeat(-2)
58
46
  program.send({
59
47
  type: 'resize',
60
48
  width: program.output.columns || 80,
@@ -62,26 +50,25 @@ function requestRepaint(getProgram) {
62
50
  })
63
51
  }
64
52
 
65
- // ctrl+y clipboard write via the platform's own pipe-to-clipboard command —
66
- // spawned per copy, nothing printed to the tty (safe alongside bare-tui's
67
- // renderer). Candidates tried in order; the first that exits 0 wins (linux
68
- // terminals vary on wayland vs x11).
53
+ const CLIPBOARD_COMMANDS = {
54
+ darwin: [['pbcopy', []]],
55
+ win32: [['clip', []]],
56
+ linux: [
57
+ ['wl-copy', []],
58
+ ['xclip', ['-selection', 'clipboard']]
59
+ ]
60
+ }
61
+
62
+ // piped to the platform clipboard command so nothing reaches the tty; first to exit 0 wins
69
63
  function copyToClipboard(text) {
70
- const commands =
71
- process.platform === 'darwin'
72
- ? [['pbcopy', []]]
73
- : process.platform === 'win32'
74
- ? [['clip', []]]
75
- : [
76
- ['wl-copy', []],
77
- ['xclip', ['-selection', 'clipboard']]
78
- ]
64
+ const commands = CLIPBOARD_COMMANDS[process.platform] ?? CLIPBOARD_COMMANDS.linux
79
65
  return new Promise((resolve, reject) => {
80
66
  const attempt = (i) => {
81
67
  if (i >= commands.length) {
82
68
  reject(new Error('no clipboard command available'))
83
69
  return
84
70
  }
71
+
85
72
  const [cmd, args] = commands[i]
86
73
  let child
87
74
  try {
@@ -90,9 +77,10 @@ function copyToClipboard(text) {
90
77
  attempt(i + 1)
91
78
  return
92
79
  }
80
+
93
81
  child.on('error', () => attempt(i + 1))
94
82
  child.on('exit', (code) => (code === 0 ? resolve() : attempt(i + 1)))
95
- child.stdin.write(Buffer.from(text))
83
+ child.stdin.write(b4a.from(text))
96
84
  child.stdin.end()
97
85
  }
98
86
  attempt(0)
@@ -113,6 +101,7 @@ function readClipboard() {
113
101
  reject(new Error('no clipboard command available'))
114
102
  return
115
103
  }
104
+
116
105
  const [cmd, args] = commands[i]
117
106
  let child
118
107
  try {
@@ -121,11 +110,12 @@ function readClipboard() {
121
110
  attempt(i + 1)
122
111
  return
123
112
  }
113
+
124
114
  const out = []
125
115
  child.stdout.on('data', (data) => out.push(data))
126
116
  child.on('error', () => attempt(i + 1))
127
117
  child.on('exit', (code) =>
128
- code === 0 ? resolve(Buffer.concat(out).toString()) : attempt(i + 1)
118
+ code === 0 ? resolve(b4a.concat(out).toString()) : attempt(i + 1)
129
119
  )
130
120
  }
131
121
  attempt(0)
@@ -148,14 +138,13 @@ const MIME_TYPES = new Map([
148
138
  // the engine's own cap (lib/core/files/attachments.ts); a lower one here refused files it takes
149
139
  const MAX_ATTACHMENT_BYTES = 100 * 1024 * 1024
150
140
 
151
- // ctrl+v resolver: a clipboard holding a file path (or file:// URL — what
152
- // "copy" in a file manager and drag-to-terminal produce) becomes an
153
- // attachment; anything else is null and the shortcut just says so. Raw
154
- // image DATA on the clipboard has no portable tty-side accessor — copy the
155
- // file, not the pixels.
141
+ // raw image data on the clipboard has no portable tty-side accessor, so only file paths attach
156
142
  async function resolvePastedFile() {
157
143
  const text = (await readClipboard()).trim()
158
- if (!text || text.includes('\n')) return null
144
+ if (!text || text.includes('\n')) {
145
+ return null
146
+ }
147
+
159
148
  const file = expandFilePath(text)
160
149
  let stat
161
150
  try {
@@ -163,7 +152,11 @@ async function resolvePastedFile() {
163
152
  } catch {
164
153
  return null
165
154
  }
166
- if (!stat.isFile()) return null
155
+
156
+ if (!stat.isFile()) {
157
+ return null
158
+ }
159
+
167
160
  return fileToAttachment(file, stat)
168
161
  }
169
162
 
@@ -182,6 +175,7 @@ function fileToAttachment(file, stat = fs.statSync(file)) {
182
175
  if (stat.size > MAX_ATTACHMENT_BYTES) {
183
176
  throw new Error(`file too large (${MAX_ATTACHMENT_BYTES / (1024 * 1024)}MB cap)`)
184
177
  }
178
+
185
179
  return {
186
180
  fileName: path.basename(file),
187
181
  mimeType: MIME_TYPES.get(path.extname(file).toLowerCase()) ?? 'application/octet-stream',
@@ -189,13 +183,7 @@ function fileToAttachment(file, stat = fs.statSync(file)) {
189
183
  }
190
184
  }
191
185
 
192
- // Storage precedence: --storage <dir> > QVAC_STORAGE > --temp/QVAC_TEMP=1
193
- // throwaway > the persistent global default. Joining a mesh is /join inside the
194
- // app — the engine takes an invite live, so it never needed to be a flag.
195
- // Boot-timing report (QVAC_BOOT_TIMING=1): per-stage stamps from the sidecar
196
- // bring-up (see lib/boot-timing.mjs), plus the host's own connect wall time.
197
- // The TUI calls this only once it has released the tty, so it never fights
198
- // bare-tui's live render.
186
+ // called only once the TUI released the tty, so it never fights bare-tui's live render
199
187
  function printBootTiming(booted) {
200
188
  if (process.env.QVAC_BOOT_TIMING !== '1' || !booted) return
201
189
  const lines = [
@@ -205,7 +193,7 @@ function printBootTiming(booted) {
205
193
  console.log(`\nboot timing:\n${lines.join('\n')}`)
206
194
  }
207
195
 
208
- export default function main(args) {
196
+ export function main(args) {
209
197
  run(args).catch((err) => {
210
198
  console.error(err)
211
199
  Bare.exit(1)
@@ -216,27 +204,18 @@ async function run(args) {
216
204
  let program
217
205
  // the engine side, once it is up: its teardown, and what the boot report prints
218
206
  let booted = null
219
- // The whole engine bring-up runs INSIDE the TUI (ChatApp calls this from
220
- // init()), so the terminal shows the app's own "starting up…" frame instead
221
- // of a pre-render status line — console is suppressed for run()'s lifetime
222
- // below, so the SDK's boot logs can't corrupt the render. boot.mjs and the
223
- // ~1200 modules behind it are imported here, after that frame, not before.
224
- // The app never mints an agent: a fresh mesh seeds its default at birth
225
- // (contract/seed-defaults.ts) and a joiner waits for it to replicate; the
226
- // provider applies the QVAC_MODEL override only when one is set.
207
+ // bring-up runs inside the TUI so its "starting up…" frame shows while ~1200 modules load
227
208
  const connect = async () => {
228
- const { default: boot } = await import('./boot.mjs')
209
+ const { boot } = await import('./boot.mjs')
229
210
  booted = await boot(args)
230
211
  const { engine, skills, deviceId, meshInvite, modelName } = booted
212
+
231
213
  return { engine, skills, deviceId, meshInvite, modelName }
232
214
  }
233
215
 
234
- // Headless: the same stack with no TUI at all. Bring the engine up, print the
235
- // invite another instance joins with, then park — the engine's own handles
236
- // hold the loop open and its logs stream to stdout until a signal arrives.
216
+ // the engine's own handles hold the loop open until a signal arrives
237
217
  if (args.headless) {
238
- // armed before connect, not after: a ctrl+C partway through a first-run
239
- // model download still unwinds cleanly (nothing to tear down until then)
218
+ // armed before connect so a ctrl+C during a first-run model download still unwinds cleanly
240
219
  const shutdown = async () => {
241
220
  await booted?.close()
242
221
  Bare.exit(0)
@@ -249,6 +228,7 @@ async function run(args) {
249
228
  console.log(`device ${booted.deviceName} ${b4a.toHex(deviceId)}`)
250
229
  console.log(`invite ${meshInvite ?? '(none — mesh not writable)'}`)
251
230
  printBootTiming(booted)
231
+
252
232
  return
253
233
  }
254
234
 
@@ -259,20 +239,18 @@ async function run(args) {
259
239
  resolvePastedFile,
260
240
  resolveFileAttachment
261
241
  })
262
- // wheel + drag reports (1002+1006) instead of the terminal turning the wheel
263
- // into ↑/↓ keys: the transcript scrolls, and it selects its own text (the
264
- // terminal can't while tracking is on) — see ChatApp._select
242
+ // the transcript selects its own text, since the terminal can't while mouse tracking is on
265
243
  program = new Program(app, { mouse: 'drag' })
266
- // bracketed paste: a paste arrives as one paste-start/…/paste-end block
267
- // instead of per-line key events submitting each pasted line
244
+ // bracketed paste, or each pasted line arrives as keys and submits itself
268
245
  program.output.write('\x1b[?2004h')
269
246
  try {
270
247
  await withConsoleSuppressed(() => {
271
248
  const running = program.run()
272
- // run() builds the key decoder synchronously, and bare-tui gives no way to
273
- // configure it: a lone esc waits out its 500ms sequence timeout, which is
274
- // the visible beat before an overlay closes.
275
- if (program._decoder) program._decoder._escapeDelay = ESCAPE_TIMEOUT_MS
249
+ // bare-tui cannot configure the decoder, whose 500ms esc timeout delays every overlay close
250
+ if (program._decoder) {
251
+ program._decoder._escapeDelay = ESCAPE_TIMEOUT_MS
252
+ }
253
+
276
254
  return running
277
255
  })
278
256
  } finally {
@@ -281,8 +259,6 @@ async function run(args) {
281
259
 
282
260
  await booted?.close()
283
261
  printBootTiming(booted)
284
- // Quitting is the goal — don't idle the terminal waiting for the child to
285
- // unwind a blocking native call (e.g. a model still loading) before its loop
286
- // drains; close() has already torn the sidecar down.
262
+ // don't wait for the child to unwind a blocking native call; close() already tore the sidecar down
287
263
  Bare.exit(0)
288
264
  }