@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,6 +1,6 @@
1
1
  export function abortOAuthLoopback(_credentialKey) {
2
2
  return Promise.resolve(false);
3
3
  }
4
- export function startOAuthLoopback(_port, _credentialKey) {
4
+ export function openOAuthLoopback(_port, _target) {
5
5
  return Promise.reject(new Error('OAuth loopback is unavailable in this runtime; inject createRedirect instead'));
6
6
  }
@@ -1,8 +1,10 @@
1
1
  type RandomBytes = (size: number) => Uint8Array;
2
- export type PkceChallenge = {
2
+ export interface PkceChallenge {
3
3
  readonly verifier: string;
4
4
  readonly challenge: string;
5
5
  readonly method: 'S256';
6
- };
6
+ }
7
7
  export declare function generatePkceChallenge(randomBytes?: RandomBytes): PkceChallenge;
8
+ export declare function base64url(bytes: Buffer | Uint8Array): string;
9
+ export declare function createPkce(randomBytes?: RandomBytes): PkceChallenge;
8
10
  export {};
@@ -1,6 +1,16 @@
1
+ import { createHash, randomBytes as defaultRandomBytes } from 'crypto';
1
2
  import { bytesToBase64Url, randomBase64Url, sha256Base64Url } from '@qvac/core/oauth/runtime/crypto';
3
+ import b4a from 'b4a';
2
4
  export function generatePkceChallenge(randomBytes) {
3
5
  const verifier = randomBytes ? bytesToBase64Url(randomBytes(32)) : randomBase64Url(32);
4
6
  const challenge = sha256Base64Url(verifier);
5
7
  return { verifier, challenge, method: 'S256' };
6
8
  }
9
+ export function base64url(bytes) {
10
+ return b4a.toString(b4a.from(bytes), 'base64url');
11
+ }
12
+ export function createPkce(randomBytes = defaultRandomBytes) {
13
+ const verifier = base64url(randomBytes(32));
14
+ const challenge = base64url(createHash('sha256').update(verifier).digest());
15
+ return { verifier, challenge, method: 'S256' };
16
+ }
@@ -6,13 +6,13 @@ export function buildProviderConfig(spec, credentials) {
6
6
  scopes: spec.scopes,
7
7
  credentialKey: spec.credentialKey,
8
8
  port: spec.port ?? 0,
9
- ...(spec.extraAuthParams ? { extraAuthParams: spec.extraAuthParams } : {}),
10
- ...(spec.registrationEndpoint
11
- ? { registrationEndpoint: spec.registrationEndpoint, dynamicRegistration: true }
12
- : {})
9
+ extraAuthParams: spec.extraAuthParams,
10
+ registrationEndpoint: spec.registrationEndpoint,
11
+ dynamicRegistration: Boolean(spec.registrationEndpoint)
13
12
  };
14
- if (spec.tokenAuth === 'pkce-only')
13
+ if (spec.tokenAuth === 'pkce-only') {
15
14
  return { ...base, tokenAuth: 'pkce-only' };
15
+ }
16
16
  return {
17
17
  ...base,
18
18
  tokenAuth: spec.tokenAuth,
@@ -1,20 +1,25 @@
1
- export type OAuthCallbackResult = {
1
+ export interface OAuthCallbackResult {
2
2
  readonly code: string;
3
3
  readonly state: string;
4
- };
5
- export type OAuthLoopbackServer = {
4
+ }
5
+ export interface OAuthLoopbackTarget {
6
+ readonly credentialKey: string;
7
+ readonly state: string;
8
+ }
9
+ export interface OAuthLoopbackServer {
6
10
  readonly redirectUri: string;
7
- readonly waitForCode: (timeoutMs?: number, expectedState?: string) => Promise<OAuthCallbackResult>;
11
+ readonly waitForCode: (timeoutMs?: number) => Promise<OAuthCallbackResult>;
8
12
  readonly close: () => void;
9
- };
10
- export type OAuthRedirect = {
13
+ }
14
+ export interface OAuthRedirect {
11
15
  readonly redirectUri: string;
12
16
  readonly authorize: (authUrl: string, timeoutMs?: number, expectedState?: string) => Promise<OAuthCallbackResult>;
13
17
  readonly close: () => void;
14
- };
18
+ }
15
19
  export type OAuthRedirectFactory = (target: {
16
20
  readonly port: number;
17
21
  readonly credentialKey: string;
22
+ readonly state: string;
18
23
  }, deps: {
19
24
  readonly openUrl: (url: string) => Promise<void>;
20
25
  }) => Promise<OAuthRedirect>;
@@ -24,10 +24,11 @@ export async function registerOAuthClient(config, redirectUri, fetchImpl = globa
24
24
  }
25
25
  return RegistrationResponseSchema.parse(await response.json()).client_id;
26
26
  }
27
- export async function resolveDynamicClientId(config, redirectUri, deps, fetchImpl = globalThis.fetch) {
27
+ export async function resolveDynamicClientId(config, redirectUri, deps, fetchImpl) {
28
28
  const cached = await deps.getClientId?.();
29
- if (cached)
29
+ if (cached) {
30
30
  return cached;
31
+ }
31
32
  const clientId = await registerOAuthClient(config, redirectUri, fetchImpl);
32
33
  await deps.saveClientId?.(clientId);
33
34
  return clientId;
@@ -1,10 +1,10 @@
1
1
  import { type OAuthKeySpec, type OAuthRouteLike } from './keys.ts';
2
- type SkillLike = {
2
+ interface SkillLike {
3
3
  readonly origin?: string;
4
4
  readonly setup?: {
5
5
  readonly routes?: ReadonlyArray<OAuthRouteLike> | null | undefined;
6
6
  } | null;
7
- };
7
+ }
8
8
  export declare function oauthSpecs(skills: ReadonlyArray<SkillLike>): ReadonlyArray<OAuthKeySpec>;
9
9
  export declare function oauthSpecFor(skills: ReadonlyArray<SkillLike>, credentialKey: string): OAuthKeySpec | null;
10
10
  export {};
@@ -6,8 +6,9 @@ export function oauthSpecs(skills) {
6
6
  continue;
7
7
  for (const route of skill.setup?.routes ?? []) {
8
8
  const spec = specFromRoute(route);
9
- if (spec && !byKey.has(spec.credentialKey))
9
+ if (spec && !byKey.has(spec.credentialKey)) {
10
10
  byKey.set(spec.credentialKey, spec);
11
+ }
11
12
  }
12
13
  }
13
14
  const claimed = new Set();
@@ -1,17 +1,37 @@
1
- import { type ConfigEngine, type Fetch, type OAuthTokens } from './common.ts';
1
+ import type { OAuthTokens } from './types.ts';
2
+ export declare const REFRESH_SKEW_MS = 60000;
3
+ export interface FetchResponse {
4
+ ok: boolean;
5
+ status: number;
6
+ text(): Promise<string>;
7
+ json(): Promise<unknown>;
8
+ }
9
+ export type Fetch = (url: string, init?: object) => Promise<FetchResponse>;
10
+ export interface ConfigEngine {
11
+ configGet(req: {
12
+ key: string;
13
+ }): Promise<{
14
+ value?: unknown;
15
+ }>;
16
+ configSet(req: {
17
+ key: string;
18
+ value: string;
19
+ }): Promise<unknown>;
20
+ }
2
21
  type RefreshFn = (opts: {
3
22
  clientId: string;
4
23
  clientSecret?: string;
5
24
  refreshToken: string;
6
25
  fetch?: Fetch;
7
26
  }) => Promise<OAuthTokens>;
8
- export declare function resolveOAuthCredential(opts: {
9
- engine: ConfigEngine;
10
- agentId?: string;
11
- credentialKey: string;
12
- stateKey: string;
13
- refresh: RefreshFn;
14
- requireClientSecret?: boolean;
15
- fetch?: Fetch;
16
- }): Promise<string | null>;
27
+ export interface ResolveOAuthCredentialOptions {
28
+ readonly engine: ConfigEngine;
29
+ readonly agentId?: string;
30
+ readonly credentialKey: string;
31
+ readonly stateKey: string;
32
+ readonly refresh: RefreshFn;
33
+ readonly requireClientSecret?: boolean;
34
+ readonly fetch?: Fetch;
35
+ }
36
+ export declare function resolveOAuthCredential(opts: ResolveOAuthCredentialOptions): Promise<string | null>;
17
37
  export {};
@@ -1,13 +1,16 @@
1
- import { REFRESH_SKEW_MS, scopedKey } from './common.js';
1
+ import { scopedKey } from './keys.js';
2
+ export const REFRESH_SKEW_MS = 60_000;
2
3
  const inFlightRefresh = new Map();
3
4
  export async function resolveOAuthCredential(opts) {
4
5
  const { engine, agentId, credentialKey, stateKey, refresh, requireClientSecret = false } = opts;
5
6
  const { value: token } = await engine.configGet({ key: scopedKey(agentId, credentialKey) });
6
- if (typeof token !== 'string')
7
+ if (typeof token !== 'string') {
7
8
  return null;
9
+ }
8
10
  const { value: raw } = await engine.configGet({ key: scopedKey(agentId, stateKey) });
9
- if (typeof raw !== 'string')
11
+ if (typeof raw !== 'string') {
10
12
  return token;
13
+ }
11
14
  let stored;
12
15
  try {
13
16
  stored = JSON.parse(raw);
@@ -16,12 +19,15 @@ export async function resolveOAuthCredential(opts) {
16
19
  return token;
17
20
  }
18
21
  const { refreshToken, expiresAt, clientId, clientSecret } = stored ?? {};
19
- if (!refreshToken || !clientId)
22
+ if (!refreshToken || !clientId) {
20
23
  return token;
21
- if (requireClientSecret && !clientSecret)
24
+ }
25
+ if (requireClientSecret && !clientSecret) {
22
26
  return token;
23
- if (typeof expiresAt !== 'number' || expiresAt - REFRESH_SKEW_MS > Date.now())
27
+ }
28
+ if (typeof expiresAt !== 'number' || expiresAt - REFRESH_SKEW_MS > Date.now()) {
24
29
  return token;
30
+ }
25
31
  const refreshKey = `${credentialKey}:${agentId ?? ''}`;
26
32
  try {
27
33
  let pending = inFlightRefresh.get(refreshKey);
@@ -1,6 +1,14 @@
1
1
  import type { OAuthFetch, OAuthFlowDeps, OAuthProviderConfig, OAuthTokens } from './types.ts';
2
- export declare function exchangeCodeWithFetch(config: OAuthProviderConfig, clientId: string, redirectUri: string, code: string, verifier: string, deps: OAuthFlowDeps, fetchImpl: OAuthFetch): Promise<OAuthTokens>;
2
+ export interface CodeExchange {
3
+ readonly clientId: string;
4
+ readonly redirectUri: string;
5
+ readonly code: string;
6
+ readonly verifier: string;
7
+ readonly deps: OAuthFlowDeps;
8
+ }
9
+ export interface CodeExchangeWithFetch extends CodeExchange {
10
+ readonly fetchImpl: OAuthFetch;
11
+ }
12
+ export declare function exchangeCodeWithFetch(config: OAuthProviderConfig, { clientId, redirectUri, code, verifier, deps, fetchImpl }: CodeExchangeWithFetch): Promise<OAuthTokens>;
3
13
  export declare function refreshOAuthTokensWithFetch(config: OAuthProviderConfig, refreshToken: string, fetchImpl: OAuthFetch): Promise<OAuthTokens>;
4
- export declare function isTokenExpired(record: {
5
- readonly expiresAt?: number;
6
- }, bufferMs?: number): boolean;
14
+ export declare function isTokenExpired(record: Pick<OAuthTokens, 'expiresAt'>, bufferMs?: number): boolean;
@@ -37,7 +37,7 @@ function toTokens(raw, fallbackRefresh) {
37
37
  scope: raw.scope
38
38
  };
39
39
  }
40
- export async function exchangeCodeWithFetch(config, clientId, redirectUri, code, verifier, deps, fetchImpl) {
40
+ export async function exchangeCodeWithFetch(config, { clientId, redirectUri, code, verifier, deps, fetchImpl }) {
41
41
  const body = new URLSearchParams({
42
42
  grant_type: 'authorization_code',
43
43
  code,
@@ -1,22 +1,22 @@
1
1
  import type { OAuthRedirectFactory } from './redirect-types.ts';
2
2
  export type OAuthProvider = string;
3
- export type OAuthTokens = {
3
+ export interface OAuthTokens {
4
4
  readonly accessToken: string;
5
5
  readonly refreshToken?: string;
6
6
  readonly expiresAt?: number;
7
7
  readonly scope?: string;
8
- };
8
+ }
9
9
  export type OAuthFetch = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
10
- export type OAuthRuntime = {
10
+ export interface OAuthRuntime {
11
11
  readonly fetch: OAuthFetch;
12
12
  readonly randomBase64Url: (size: number) => string;
13
13
  readonly sha256Base64Url: (value: string) => string | Promise<string>;
14
- };
15
- export type OAuthCredentials = {
14
+ }
15
+ export interface OAuthCredentials {
16
16
  readonly clientId: string;
17
17
  readonly clientSecret?: string;
18
- };
19
- type OAuthProviderConfigBase = {
18
+ }
19
+ interface OAuthProviderConfigBase {
20
20
  readonly clientId: string;
21
21
  readonly authUrl: string;
22
22
  readonly tokenUrl: string;
@@ -26,15 +26,15 @@ type OAuthProviderConfigBase = {
26
26
  readonly extraAuthParams?: Readonly<Record<string, string>>;
27
27
  readonly dynamicRegistration?: boolean;
28
28
  readonly registrationEndpoint?: string;
29
- };
30
- export type OAuthFlowDeps = {
29
+ }
30
+ export interface OAuthFlowDeps {
31
31
  readonly openUrl?: (url: string) => Promise<void>;
32
32
  readonly timeoutMs?: number;
33
33
  readonly getClientId?: () => Promise<string | undefined>;
34
34
  readonly saveClientId?: (clientId: string) => Promise<void>;
35
35
  readonly clearClientId?: () => Promise<void>;
36
36
  readonly createRedirect?: OAuthRedirectFactory;
37
- };
37
+ }
38
38
  export type PkceOnlyProviderConfig = OAuthProviderConfigBase & {
39
39
  readonly tokenAuth: 'pkce-only';
40
40
  };
@@ -47,8 +47,8 @@ export type SecretInBasicProviderConfig = OAuthProviderConfigBase & {
47
47
  readonly clientSecret: string;
48
48
  };
49
49
  export type OAuthProviderConfig = PkceOnlyProviderConfig | SecretInBodyProviderConfig | SecretInBasicProviderConfig;
50
- export type OAuthFlowResult = {
50
+ export interface OAuthFlowResult {
51
51
  readonly config: OAuthProviderConfig;
52
52
  readonly tokens: OAuthTokens;
53
- };
53
+ }
54
54
  export {};
@@ -1,12 +1,11 @@
1
- export { createPkce, scopedKey, type ConfigEngine, type Fetch, type FetchResponse, type OAuthTokens } from './oauth/common.ts';
2
1
  export { waitForOAuthCallback } from './oauth/browser-connect.ts';
3
2
  export { cancelOAuthFlow, runOAuthFlow } from './oauth/flow.ts';
4
- export { OAUTH_CALLBACK_PATH, OAUTH_WAIT_FOR_CODE_TIMEOUT_MS, oauthRedirectUri, specFromRoute, type OAuthKeySpec, type OAuthRouteLike } from './oauth/keys.ts';
3
+ export { OAUTH_CALLBACK_PATH, OAUTH_WAIT_FOR_CODE_TIMEOUT_MS, oauthRedirectUri, scopedKey, specFromRoute, type OAuthKeySpec, type OAuthRouteLike } from './oauth/keys.ts';
5
4
  export { oauthSpecFor, oauthSpecs } from './oauth/registry.ts';
6
- export { generatePkceChallenge, type PkceChallenge } from './oauth/pkce.ts';
5
+ export { createPkce, generatePkceChallenge, type PkceChallenge } from './oauth/pkce.ts';
7
6
  export { buildProviderConfig } from './oauth/providers.ts';
8
7
  export type { OAuthCallbackResult, OAuthRedirect, OAuthRedirectFactory } from './oauth/redirect-types.ts';
9
8
  export { registerOAuthClient, resolveDynamicClientId } from './oauth/register.ts';
10
- export { resolveOAuthCredential } from './oauth/resolve.ts';
9
+ export { resolveOAuthCredential, type ConfigEngine, type Fetch, type FetchResponse } from './oauth/resolve.ts';
11
10
  export { isTokenExpired, refreshOAuthTokens } from './oauth/token-exchange.ts';
12
- export type { OAuthCredentials, OAuthFlowDeps, OAuthFlowResult, OAuthProvider, OAuthProviderConfig } from './oauth/types.ts';
11
+ export type { OAuthCredentials, OAuthFlowDeps, OAuthFlowResult, OAuthProvider, OAuthProviderConfig, OAuthTokens } from './oauth/types.ts';
@@ -1,9 +1,8 @@
1
- export { createPkce, scopedKey } from './oauth/common.js';
2
1
  export { waitForOAuthCallback } from './oauth/browser-connect.js';
3
2
  export { cancelOAuthFlow, runOAuthFlow } from './oauth/flow.js';
4
- export { OAUTH_CALLBACK_PATH, OAUTH_WAIT_FOR_CODE_TIMEOUT_MS, oauthRedirectUri, specFromRoute } from './oauth/keys.js';
3
+ export { OAUTH_CALLBACK_PATH, OAUTH_WAIT_FOR_CODE_TIMEOUT_MS, oauthRedirectUri, scopedKey, specFromRoute } from './oauth/keys.js';
5
4
  export { oauthSpecFor, oauthSpecs } from './oauth/registry.js';
6
- export { generatePkceChallenge } from './oauth/pkce.js';
5
+ export { createPkce, generatePkceChallenge } from './oauth/pkce.js';
7
6
  export { buildProviderConfig } from './oauth/providers.js';
8
7
  export { registerOAuthClient, resolveDynamicClientId } from './oauth/register.js';
9
8
  export { resolveOAuthCredential } from './oauth/resolve.js';
@@ -1,2 +1,2 @@
1
1
  import type { WatchStream } from './api/index.ts';
2
- export default function reconnectingWatch<Frame>(open: () => WatchStream<Frame>, onDisconnect: (error: Error) => void): WatchStream<Frame>;
2
+ export declare function reconnectingWatch<Frame>(open: () => WatchStream<Frame>, onDisconnect: (error: Error) => void): WatchStream<Frame>;
@@ -1,7 +1,9 @@
1
1
  import { Readable } from 'streamx';
2
+ import { frameReadable } from './frame-readable.js';
3
+ import { asError } from './guards.js';
2
4
  const RETRY_MIN_MS = 250;
3
5
  const RETRY_MAX_MS = 5_000;
4
- export default function reconnectingWatch(open, onDisconnect) {
6
+ export function reconnectingWatch(open, onDisconnect) {
5
7
  let closeConnection = null;
6
8
  let retry = null;
7
9
  let retryMs = RETRY_MIN_MS;
@@ -62,8 +64,9 @@ export default function reconnectingWatch(open, onDisconnect) {
62
64
  cb(null);
63
65
  },
64
66
  destroy(cb) {
65
- if (retry)
67
+ if (retry) {
66
68
  clearTimeout(retry);
69
+ }
67
70
  retry = null;
68
71
  const close = closeConnection;
69
72
  closeConnection = null;
@@ -71,8 +74,5 @@ export default function reconnectingWatch(open, onDisconnect) {
71
74
  cb(null);
72
75
  }
73
76
  });
74
- return output;
75
- }
76
- function asError(error) {
77
- return error instanceof Error ? error : new Error(String(error));
77
+ return frameReadable(output);
78
78
  }
@@ -15,8 +15,9 @@ export class RetryBudget {
15
15
  for (const [name, readyAt] of this._readyAt) {
16
16
  if (!names.has(name) || readyAt <= now)
17
17
  continue;
18
- if (next === null || readyAt < next)
18
+ if (next === null || readyAt < next) {
19
19
  next = readyAt;
20
+ }
20
21
  }
21
22
  return next;
22
23
  }
@@ -25,9 +26,11 @@ export class RetryBudget {
25
26
  this._readyAt.delete(name);
26
27
  }
27
28
  retain(names) {
28
- for (const name of this._attempts.keys())
29
- if (!names.has(name))
29
+ for (const name of this._attempts.keys()) {
30
+ if (!names.has(name)) {
30
31
  this.reset(name);
32
+ }
33
+ }
31
34
  }
32
35
  fail(name, now) {
33
36
  const attempt = (this._attempts.get(name) ?? 0) + 1;
@@ -4,6 +4,7 @@ export declare const RUN_ABORT_REASONS: {
4
4
  readonly runSettled: 'run-settled';
5
5
  readonly runnerDied: 'runner-died';
6
6
  readonly runnerClosed: 'runner-closed';
7
+ readonly modelUnloaded: 'model-unloaded';
7
8
  };
8
9
  export type RunAbortReason = (typeof RUN_ABORT_REASONS)[keyof typeof RUN_ABORT_REASONS];
9
10
  export declare const RUN_FAILURE_REASONS: {
@@ -3,7 +3,8 @@ export const RUN_ABORT_REASONS = {
3
3
  ownershipLost: 'ownership-lost',
4
4
  runSettled: 'run-settled',
5
5
  runnerDied: 'runner-died',
6
- runnerClosed: 'runner-closed'
6
+ runnerClosed: 'runner-closed',
7
+ modelUnloaded: 'model-unloaded'
7
8
  };
8
9
  export const RUN_FAILURE_REASONS = {
9
10
  harnessDied: 'the model runtime died',
@@ -11,7 +12,9 @@ export const RUN_FAILURE_REASONS = {
11
12
  capabilityUnavailable: 'this device cannot run a capability without a model'
12
13
  };
13
14
  export function knownAbortOutcome(reason) {
14
- if (reason === RUN_ABORT_REASONS.suspended || reason === RUN_ABORT_REASONS.runnerClosed) {
15
+ if (reason === RUN_ABORT_REASONS.suspended ||
16
+ reason === RUN_ABORT_REASONS.runnerClosed ||
17
+ reason === RUN_ABORT_REASONS.modelUnloaded) {
15
18
  return { kind: 'replay' };
16
19
  }
17
20
  if (reason === RUN_ABORT_REASONS.ownershipLost || reason === RUN_ABORT_REASONS.runSettled) {
@@ -1,6 +1,7 @@
1
1
  import type { AssistantAppendChunkRequest, AssistantChunkId, AssistantChunkContentRunStatus } from '../spec/hyperschema/types.d.ts';
2
2
  import type { ScopedCapabilities } from './mesh-scoped-engine.ts';
3
3
  import type { Logger } from './log.ts';
4
+ import { type PendingScope } from './write-queue.ts';
4
5
  export type TranscriptChunk = Pick<AssistantAppendChunkRequest, 'type' | 'toolCall' | 'toolResult' | 'sources' | 'effect' | 'display' | 'rawCall'>;
5
6
  export interface RunTranscriptOptions {
6
7
  chatId: string;
@@ -26,10 +27,7 @@ export declare class RunTranscript {
26
27
  status(runStatus: AssistantChunkContentRunStatus): Promise<AssistantChunkId>;
27
28
  progress(id: string, runStatus: AssistantChunkContentRunStatus): Promise<unknown>;
28
29
  flush(): Promise<void>;
29
- pending(): Array<{
30
- scope: string;
31
- waiting: number;
32
- }>;
30
+ pending(): Array<PendingScope>;
33
31
  close(): void;
34
32
  private _announce;
35
33
  }
@@ -32,15 +32,17 @@ export class RunTranscript {
32
32
  }, FLUSH_INTERVAL_MS);
33
33
  }
34
34
  async text(type, text) {
35
- if (this._buffered && this._buffered.type !== type)
35
+ if (this._buffered && this._buffered.type !== type) {
36
36
  await this.flush();
37
+ }
37
38
  if (!this._buffered) {
38
39
  this._buffered = { type, text: '' };
39
40
  this._announce(type);
40
41
  }
41
42
  this._buffered.text += text;
42
- if (this._buffered.text.length >= COALESCE_CAP)
43
+ if (this._buffered.text.length >= COALESCE_CAP) {
43
44
  await this.flush();
45
+ }
44
46
  }
45
47
  chunk(chunk) {
46
48
  return this._writes.run(TRANSCRIPT, `append:${chunk.type}`, () => this._engine.appendChunk({
@@ -10,11 +10,13 @@ export function agentReadySkillNames(reported, agentId) {
10
10
  if (reported === null || reported === undefined)
11
11
  return null;
12
12
  const unscoped = reported.filter((name) => !name.startsWith(AGENT_PREFIX));
13
- if (!agentId || !reported.some((name) => name.startsWith(AGENT_PREFIX)))
13
+ if (!agentId || !reported.some((name) => name.startsWith(AGENT_PREFIX))) {
14
14
  return unscoped;
15
+ }
15
16
  const scoped = prefix(agentId);
16
- if (!reported.includes(scoped))
17
+ if (!reported.includes(scoped)) {
17
18
  return unscoped;
19
+ }
18
20
  return reported
19
21
  .filter((name) => name !== scoped && name.startsWith(scoped))
20
22
  .map((name) => name.slice(scoped.length));
@@ -1,6 +1,6 @@
1
1
  export type CapabilityProfile = 'tiny' | 'low' | 'mid' | 'high' | 'xhigh';
2
2
  export type SkillState = 'ready' | 'needs-setup' | 'failed' | 'disabled' | 'disconnected' | 'outdated' | 'incompatible-model' | 'unsupported';
3
- export type InstallStep = {
3
+ export interface InstallStep {
4
4
  readonly id: string;
5
5
  readonly kind: string;
6
6
  readonly formula?: string | undefined;
@@ -8,20 +8,20 @@ export type InstallStep = {
8
8
  readonly label: string;
9
9
  readonly command?: string | undefined;
10
10
  readonly manual?: boolean | undefined;
11
- };
12
- export type SkillTransport = {
11
+ }
12
+ export interface SkillTransport {
13
13
  readonly credentialKey: string;
14
14
  readonly name: string;
15
15
  readonly directive: string;
16
- };
17
- export type SkillSetupField = {
16
+ }
17
+ export interface SkillSetupField {
18
18
  readonly key: string;
19
19
  readonly label: string;
20
20
  readonly placeholder?: string | undefined;
21
21
  readonly secret?: boolean | undefined;
22
22
  readonly required?: boolean | undefined;
23
- };
24
- export type SkillOAuthConfig = {
23
+ }
24
+ export interface SkillOAuthConfig {
25
25
  readonly stateKey: string;
26
26
  readonly authUrl: string;
27
27
  readonly tokenUrl: string;
@@ -31,8 +31,8 @@ export type SkillOAuthConfig = {
31
31
  readonly registrationEndpoint?: string | undefined;
32
32
  readonly port?: number | undefined;
33
33
  readonly sharedIosSession?: boolean | undefined;
34
- };
35
- export type SkillSetupRoute = {
34
+ }
35
+ export interface SkillSetupRoute {
36
36
  readonly kind: 'oauth' | 'token' | 'install' | 'picker' | 'instructions';
37
37
  readonly label: string;
38
38
  readonly provider?: string | undefined;
@@ -44,12 +44,12 @@ export type SkillSetupRoute = {
44
44
  readonly fields?: ReadonlyArray<SkillSetupField> | undefined;
45
45
  readonly satisfied?: boolean | undefined;
46
46
  readonly oauth?: SkillOAuthConfig | undefined;
47
- };
48
- export type SkillSetup = {
47
+ }
48
+ export interface SkillSetup {
49
49
  readonly summary?: string | undefined;
50
50
  readonly routes?: ReadonlyArray<SkillSetupRoute> | undefined;
51
- };
52
- export type SkillMetadata = {
51
+ }
52
+ export interface SkillMetadata {
53
53
  readonly name: string;
54
54
  readonly description: string;
55
55
  readonly os?: ReadonlyArray<string> | undefined;
@@ -73,10 +73,10 @@ export type SkillMetadata = {
73
73
  readonly stub?: boolean | undefined;
74
74
  readonly tools?: ReadonlyArray<string> | undefined;
75
75
  readonly minCapabilityProfile?: CapabilityProfile | undefined;
76
- };
77
- export type SkillEntry = {
76
+ }
77
+ export interface SkillEntry {
78
78
  readonly metadata: SkillMetadata;
79
79
  readonly content: string;
80
80
  readonly available: boolean;
81
81
  readonly state: SkillState;
82
- };
82
+ }
@@ -1,17 +1,17 @@
1
1
  import Suspendify from 'suspendify';
2
2
  export declare const ASSISTANT_WAKEUP_LINGER_MS = 6000;
3
- type LifecycleSupervisor = {
3
+ interface LifecycleSupervisor {
4
4
  readonly opened: boolean;
5
5
  ready(): Promise<void>;
6
6
  presuspend(): Promise<void>;
7
7
  suspend(): Promise<void>;
8
8
  wakeup(): Promise<void>;
9
9
  resume(): Promise<void>;
10
- };
11
- export type AssistantSuspendLifecycleOptions = {
10
+ }
11
+ export interface AssistantSuspendLifecycleOptions {
12
12
  readonly wakeupLinger?: number;
13
13
  readonly pollLinger?: () => Promise<number> | number;
14
14
  readonly onSuspended?: () => void;
15
- };
15
+ }
16
16
  export declare function createAssistantSuspendLifecycle(supervisor: LifecycleSupervisor, options?: AssistantSuspendLifecycleOptions): Suspendify;
17
17
  export {};
@@ -6,25 +6,30 @@ export function createAssistantSuspendLifecycle(supervisor, options = {}) {
6
6
  wakeupLinger,
7
7
  pollLinger,
8
8
  presuspend: async () => {
9
- if (!supervisor.opened)
9
+ if (!supervisor.opened) {
10
10
  await supervisor.ready();
11
+ }
11
12
  await supervisor.presuspend();
12
13
  },
13
14
  suspend: async () => {
14
- if (!supervisor.opened)
15
+ if (!supervisor.opened) {
15
16
  await supervisor.ready();
17
+ }
16
18
  await supervisor.suspend();
17
- if (!lifecycle.interrupted)
19
+ if (!lifecycle.interrupted) {
18
20
  onSuspended();
21
+ }
19
22
  },
20
23
  wakeup: async () => {
21
- if (!supervisor.opened)
24
+ if (!supervisor.opened) {
22
25
  await supervisor.ready();
26
+ }
23
27
  await supervisor.wakeup();
24
28
  },
25
29
  resume: async () => {
26
- if (!supervisor.opened)
30
+ if (!supervisor.opened) {
27
31
  await supervisor.ready();
32
+ }
28
33
  await supervisor.resume();
29
34
  }
30
35
  });