@qvac/core 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (383) hide show
  1. package/CHANGELOG.md +75 -1
  2. package/dist-lib/lib/api/agents.js +3 -2
  3. package/dist-lib/lib/api/app-config.d.ts +1 -1
  4. package/dist-lib/lib/api/app-config.js +54 -15
  5. package/dist-lib/lib/api/attachments.d.ts +6 -5
  6. package/dist-lib/lib/api/attachments.js +4 -2
  7. package/dist-lib/lib/api/chat.d.ts +7 -3
  8. package/dist-lib/lib/api/chat.js +4 -4
  9. package/dist-lib/lib/api/chunks.js +3 -3
  10. package/dist-lib/lib/api/config.js +2 -2
  11. package/dist-lib/lib/api/current-mesh.d.ts +3 -4
  12. package/dist-lib/lib/api/current-mesh.js +9 -4
  13. package/dist-lib/lib/api/custom-models.d.ts +8 -1
  14. package/dist-lib/lib/api/custom-models.js +53 -16
  15. package/dist-lib/lib/api/devices.d.ts +14 -5
  16. package/dist-lib/lib/api/devices.js +13 -8
  17. package/dist-lib/lib/api/diagnostics.d.ts +1 -0
  18. package/dist-lib/lib/api/diagnostics.js +1 -1
  19. package/dist-lib/lib/api/effective-ctx-size.d.ts +6 -1
  20. package/dist-lib/lib/api/effective-ctx-size.js +5 -3
  21. package/dist-lib/lib/api/execution.js +2 -1
  22. package/dist-lib/lib/api/files.js +2 -1
  23. package/dist-lib/lib/api/index.d.ts +5 -1
  24. package/dist-lib/lib/api/index.js +101 -102
  25. package/dist-lib/lib/api/instrument.js +29 -20
  26. package/dist-lib/lib/api/knowledge.d.ts +6 -5
  27. package/dist-lib/lib/api/knowledge.js +8 -6
  28. package/dist-lib/lib/api/local-files.js +1 -1
  29. package/dist-lib/lib/api/logs.js +6 -3
  30. package/dist-lib/lib/api/members.js +22 -13
  31. package/dist-lib/lib/api/mesh.js +3 -3
  32. package/dist-lib/lib/api/model-download.js +1 -1
  33. package/dist-lib/lib/api/network.d.ts +1 -0
  34. package/dist-lib/lib/api/network.js +1 -1
  35. package/dist-lib/lib/api/notifications.js +23 -13
  36. package/dist-lib/lib/api/rag.d.ts +6 -1
  37. package/dist-lib/lib/api/rag.js +20 -11
  38. package/dist-lib/lib/api/range.d.ts +2 -2
  39. package/dist-lib/lib/api/sync.js +1 -1
  40. package/dist-lib/lib/api/tool-activity.js +7 -3
  41. package/dist-lib/lib/api/tool-configs.js +2 -4
  42. package/dist-lib/lib/api/upload-frames.d.ts +7 -8
  43. package/dist-lib/lib/api/upload-frames.js +2 -1
  44. package/dist-lib/lib/api/watchable.d.ts +6 -1
  45. package/dist-lib/lib/api/watchable.js +23 -14
  46. package/dist-lib/lib/assistant/fetch-body.js +4 -2
  47. package/dist-lib/lib/assistant/harness.d.ts +48 -27
  48. package/dist-lib/lib/assistant/harness.js +40 -16
  49. package/dist-lib/lib/assistant/history.d.ts +9 -7
  50. package/dist-lib/lib/assistant/history.js +77 -42
  51. package/dist-lib/lib/assistant/message.d.ts +5 -3
  52. package/dist-lib/lib/assistant/message.js +4 -2
  53. package/dist-lib/lib/assistant/skill-encode.d.ts +3 -1
  54. package/dist-lib/lib/assistant/skill-encode.js +52 -62
  55. package/dist-lib/lib/assistant-client.js +7 -4
  56. package/dist-lib/lib/assistant-tree.js +27 -11
  57. package/dist-lib/lib/assistant.d.ts +30 -11
  58. package/dist-lib/lib/assistant.js +824 -378
  59. package/dist-lib/lib/audio-format.d.ts +1 -1
  60. package/dist-lib/lib/audio-format.js +1 -1
  61. package/dist-lib/lib/chat-title.js +9 -4
  62. package/dist-lib/lib/client.js +3 -2
  63. package/dist-lib/lib/collabora/convert.d.ts +2 -2
  64. package/dist-lib/lib/collabora/convert.js +6 -3
  65. package/dist-lib/lib/collabora/entry.js +9 -5
  66. package/dist-lib/lib/collabora/protocol.d.ts +2 -2
  67. package/dist-lib/lib/collabora/protocol.js +14 -7
  68. package/dist-lib/lib/collabora/worker.js +14 -7
  69. package/dist-lib/lib/compaction.d.ts +5 -6
  70. package/dist-lib/lib/compaction.js +14 -7
  71. package/dist-lib/lib/core/account-recovery.d.ts +4 -3
  72. package/dist-lib/lib/core/account-recovery.js +7 -4
  73. package/dist-lib/lib/core/agent.js +17 -15
  74. package/dist-lib/lib/core/approval-rules.d.ts +7 -6
  75. package/dist-lib/lib/core/approval-rules.js +12 -6
  76. package/dist-lib/lib/core/archived-mesh.d.ts +7 -5
  77. package/dist-lib/lib/core/archived-mesh.js +25 -22
  78. package/dist-lib/lib/core/async-iterable.js +10 -5
  79. package/dist-lib/lib/core/attachment-link.d.ts +2 -2
  80. package/dist-lib/lib/core/audio-attachment.js +1 -1
  81. package/dist-lib/lib/core/blind-peers.d.ts +2 -2
  82. package/dist-lib/lib/core/chat-activity.d.ts +2 -2
  83. package/dist-lib/lib/core/chat-activity.js +42 -21
  84. package/dist-lib/lib/core/chat-group.d.ts +8 -6
  85. package/dist-lib/lib/core/chat-group.js +17 -10
  86. package/dist-lib/lib/core/chat-order.d.ts +11 -9
  87. package/dist-lib/lib/core/chat-order.js +1 -3
  88. package/dist-lib/lib/core/chat-search.d.ts +4 -4
  89. package/dist-lib/lib/core/chat-search.js +38 -24
  90. package/dist-lib/lib/core/chat.d.ts +20 -14
  91. package/dist-lib/lib/core/chat.js +42 -28
  92. package/dist-lib/lib/core/chunk.d.ts +19 -23
  93. package/dist-lib/lib/core/chunk.js +27 -21
  94. package/dist-lib/lib/core/collections.d.ts +69 -0
  95. package/dist-lib/lib/core/collections.js +69 -0
  96. package/dist-lib/lib/core/contract/activity.d.ts +6 -2
  97. package/dist-lib/lib/core/contract/activity.js +15 -12
  98. package/dist-lib/lib/core/contract/agents.js +3 -2
  99. package/dist-lib/lib/core/contract/approval-rules.js +1 -1
  100. package/dist-lib/lib/core/contract/attestations.js +1 -1
  101. package/dist-lib/lib/core/contract/chat-group.js +1 -1
  102. package/dist-lib/lib/core/contract/chat.js +1 -1
  103. package/dist-lib/lib/core/contract/chunks.js +10 -9
  104. package/dist-lib/lib/core/contract/compute.js +2 -1
  105. package/dist-lib/lib/core/contract/devices.js +6 -5
  106. package/dist-lib/lib/core/contract/grant-order.js +5 -6
  107. package/dist-lib/lib/core/contract/index.js +4 -2
  108. package/dist-lib/lib/core/contract/indexing.js +3 -3
  109. package/dist-lib/lib/core/contract/invites.d.ts +8 -3
  110. package/dist-lib/lib/core/contract/invites.js +52 -26
  111. package/dist-lib/lib/core/contract/joined-meshes.js +3 -3
  112. package/dist-lib/lib/core/contract/knowledge.js +5 -5
  113. package/dist-lib/lib/core/contract/members.d.ts +13 -2
  114. package/dist-lib/lib/core/contract/members.js +46 -25
  115. package/dist-lib/lib/core/contract/mesh-kind.js +9 -8
  116. package/dist-lib/lib/core/contract/seal.js +1 -1
  117. package/dist-lib/lib/core/contract/seed-defaults.js +1 -3
  118. package/dist-lib/lib/core/contract/tool-activity.js +5 -5
  119. package/dist-lib/lib/core/contract/tool-configs.js +1 -2
  120. package/dist-lib/lib/core/contract/writers.d.ts +6 -1
  121. package/dist-lib/lib/core/contract/writers.js +55 -34
  122. package/dist-lib/lib/core/departures.js +16 -8
  123. package/dist-lib/lib/core/device-invites.js +3 -2
  124. package/dist-lib/lib/core/devices.js +6 -3
  125. package/dist-lib/lib/core/document-attachment.d.ts +20 -11
  126. package/dist-lib/lib/core/document-attachment.js +10 -5
  127. package/dist-lib/lib/core/files/attachments.d.ts +2 -5
  128. package/dist-lib/lib/core/files/attachments.js +6 -3
  129. package/dist-lib/lib/core/files/index.d.ts +44 -52
  130. package/dist-lib/lib/core/files/index.js +142 -93
  131. package/dist-lib/lib/core/files/knowledge.d.ts +2 -5
  132. package/dist-lib/lib/core/files/local-index.js +9 -5
  133. package/dist-lib/lib/core/files/preview/image.d.ts +0 -1
  134. package/dist-lib/lib/core/files/preview/image.js +9 -6
  135. package/dist-lib/lib/core/files/preview/index.d.ts +8 -11
  136. package/dist-lib/lib/core/files/preview/index.js +20 -15
  137. package/dist-lib/lib/core/files/processing/claims.d.ts +6 -5
  138. package/dist-lib/lib/core/files/processing/claims.js +16 -8
  139. package/dist-lib/lib/core/files/processing/document.d.ts +21 -50
  140. package/dist-lib/lib/core/files/processing/index.d.ts +18 -13
  141. package/dist-lib/lib/core/files/processing/index.js +65 -37
  142. package/dist-lib/lib/core/files/processing/ownership.d.ts +8 -1
  143. package/dist-lib/lib/core/files/processing/ownership.js +1 -1
  144. package/dist-lib/lib/core/files/processing/protocol.d.ts +19 -19
  145. package/dist-lib/lib/core/files/processing/protocol.js +5 -5
  146. package/dist-lib/lib/core/files/processing/settle.d.ts +10 -7
  147. package/dist-lib/lib/core/files/processing/settle.js +22 -11
  148. package/dist-lib/lib/core/files/processing/source.js +14 -8
  149. package/dist-lib/lib/core/files/processing/state.d.ts +13 -11
  150. package/dist-lib/lib/core/files/processing/state.js +19 -12
  151. package/dist-lib/lib/core/files/rag/build.d.ts +2 -2
  152. package/dist-lib/lib/core/files/rag/build.js +2 -1
  153. package/dist-lib/lib/core/files/rag/document-types.d.ts +4 -6
  154. package/dist-lib/lib/core/files/rag/index.d.ts +10 -13
  155. package/dist-lib/lib/core/files/rag/index.js +3 -2
  156. package/dist-lib/lib/core/files/rag/load.d.ts +10 -9
  157. package/dist-lib/lib/core/files/rag/load.js +26 -13
  158. package/dist-lib/lib/core/files/rag/policy.js +2 -1
  159. package/dist-lib/lib/core/files/rag/produce.js +33 -19
  160. package/dist-lib/lib/core/files/rag/retrieval/full-text.d.ts +5 -3
  161. package/dist-lib/lib/core/files/rag/retrieval/full-text.js +30 -10
  162. package/dist-lib/lib/core/files/records/chunks.js +4 -2
  163. package/dist-lib/lib/core/files/records/knowledge.d.ts +10 -11
  164. package/dist-lib/lib/core/files/records/knowledge.js +9 -8
  165. package/dist-lib/lib/core/files/records/linkage.js +6 -3
  166. package/dist-lib/lib/core/files/records/output.d.ts +5 -4
  167. package/dist-lib/lib/core/files/records/output.js +8 -4
  168. package/dist-lib/lib/core/files/records/reclaim.js +41 -25
  169. package/dist-lib/lib/core/files/records/routing.d.ts +4 -6
  170. package/dist-lib/lib/core/files/records/routing.js +15 -8
  171. package/dist-lib/lib/core/files/records/source.d.ts +5 -4
  172. package/dist-lib/lib/core/files/records/source.js +20 -14
  173. package/dist-lib/lib/core/files/records/sweep.js +1 -3
  174. package/dist-lib/lib/core/files/store/blob.d.ts +10 -10
  175. package/dist-lib/lib/core/files/store/blob.js +25 -19
  176. package/dist-lib/lib/core/files/store/index.d.ts +1 -6
  177. package/dist-lib/lib/core/files/store/index.js +4 -4
  178. package/dist-lib/lib/core/files/store/inline.d.ts +2 -2
  179. package/dist-lib/lib/core/files/store/inline.js +6 -3
  180. package/dist-lib/lib/core/files/store/reference.d.ts +6 -9
  181. package/dist-lib/lib/core/files/store/reference.js +25 -17
  182. package/dist-lib/lib/core/files/store/server.d.ts +7 -6
  183. package/dist-lib/lib/core/files/store/server.js +22 -11
  184. package/dist-lib/lib/core/files/store/sweep.js +13 -7
  185. package/dist-lib/lib/core/files/upload-input.d.ts +4 -12
  186. package/dist-lib/lib/core/files/upload-input.js +10 -5
  187. package/dist-lib/lib/core/files/upload.d.ts +27 -24
  188. package/dist-lib/lib/core/files/upload.js +74 -51
  189. package/dist-lib/lib/core/fs-drives.js +4 -2
  190. package/dist-lib/lib/core/grant-expiry.js +12 -7
  191. package/dist-lib/lib/core/handoff-channel.js +27 -13
  192. package/dist-lib/lib/core/harness-loan.js +35 -17
  193. package/dist-lib/lib/core/helpers/index.js +6 -2
  194. package/dist-lib/lib/core/hosted-agents.js +19 -12
  195. package/dist-lib/lib/core/id.js +1 -1
  196. package/dist-lib/lib/core/identity.js +6 -3
  197. package/dist-lib/lib/core/image/cache-sweep.d.ts +12 -10
  198. package/dist-lib/lib/core/image/cache-sweep.js +11 -6
  199. package/dist-lib/lib/core/image/normalize.d.ts +6 -0
  200. package/dist-lib/lib/core/image/normalize.js +12 -2
  201. package/dist-lib/lib/core/image/sniff.js +42 -21
  202. package/dist-lib/lib/core/inference-calls-receiver.js +7 -4
  203. package/dist-lib/lib/core/invite-grants.js +4 -2
  204. package/dist-lib/lib/core/invite.js +2 -1
  205. package/dist-lib/lib/core/local/files.js +20 -19
  206. package/dist-lib/lib/core/local/index.d.ts +69 -46
  207. package/dist-lib/lib/core/local/index.js +146 -129
  208. package/dist-lib/lib/core/membership.d.ts +12 -2
  209. package/dist-lib/lib/core/membership.js +55 -33
  210. package/dist-lib/lib/core/mesh-seed-handoff.js +7 -1
  211. package/dist-lib/lib/core/mesh.d.ts +37 -27
  212. package/dist-lib/lib/core/mesh.js +131 -73
  213. package/dist-lib/lib/core/migrations/agent-catalog.js +3 -2
  214. package/dist-lib/lib/core/migrations/agent-indexes.js +3 -3
  215. package/dist-lib/lib/core/migrations/file-index.js +7 -4
  216. package/dist-lib/lib/core/migrations/index.d.ts +4 -3
  217. package/dist-lib/lib/core/migrations/membership.js +9 -4
  218. package/dist-lib/lib/core/migrations/seal.js +3 -2
  219. package/dist-lib/lib/core/min-version.js +4 -2
  220. package/dist-lib/lib/core/next-frame.d.ts +5 -4
  221. package/dist-lib/lib/core/next-frame.js +6 -3
  222. package/dist-lib/lib/core/notification.d.ts +5 -1
  223. package/dist-lib/lib/core/notification.js +89 -77
  224. package/dist-lib/lib/core/ota-config.js +2 -1
  225. package/dist-lib/lib/core/pdf/rasterize.d.ts +18 -0
  226. package/dist-lib/lib/core/pdf/rasterize.js +57 -0
  227. package/dist-lib/lib/core/prompt-history.js +4 -2
  228. package/dist-lib/lib/core/range.d.ts +4 -4
  229. package/dist-lib/lib/core/range.js +12 -6
  230. package/dist-lib/lib/core/rank.d.ts +5 -4
  231. package/dist-lib/lib/core/rank.js +2 -1
  232. package/dist-lib/lib/core/send.d.ts +4 -4
  233. package/dist-lib/lib/core/send.js +6 -3
  234. package/dist-lib/lib/core/skill-overlay-receiver.js +7 -4
  235. package/dist-lib/lib/core/skill-secrets.js +16 -9
  236. package/dist-lib/lib/core/sync/chunks.js +2 -1
  237. package/dist-lib/lib/core/sync/devices.js +3 -1
  238. package/dist-lib/lib/core/sync/files.d.ts +2 -4
  239. package/dist-lib/lib/core/sync/files.js +28 -20
  240. package/dist-lib/lib/core/sync/index.d.ts +2 -5
  241. package/dist-lib/lib/core/sync/index.js +20 -15
  242. package/dist-lib/lib/core/sync-status.js +10 -7
  243. package/dist-lib/lib/core/system-info.js +4 -2
  244. package/dist-lib/lib/core/tool-activity.d.ts +4 -3
  245. package/dist-lib/lib/core/tool-activity.js +1 -1
  246. package/dist-lib/lib/core/tool-configs.js +12 -7
  247. package/dist-lib/lib/core.d.ts +38 -26
  248. package/dist-lib/lib/core.js +987 -539
  249. package/dist-lib/lib/credential-pusher.d.ts +12 -17
  250. package/dist-lib/lib/credential-pusher.js +61 -42
  251. package/dist-lib/lib/custom-model-pusher.d.ts +7 -3
  252. package/dist-lib/lib/custom-model-pusher.js +15 -7
  253. package/dist-lib/lib/custom-model-task.d.ts +1 -0
  254. package/dist-lib/lib/custom-model-task.js +12 -0
  255. package/dist-lib/lib/deadline.js +4 -2
  256. package/dist-lib/lib/diagnostics.d.ts +1 -5
  257. package/dist-lib/lib/frame-readable.d.ts +3 -0
  258. package/dist-lib/lib/frame-readable.js +3 -0
  259. package/dist-lib/lib/fs-drive-bridge.js +24 -14
  260. package/dist-lib/lib/fs-grants.js +13 -8
  261. package/dist-lib/lib/guards.d.ts +3 -0
  262. package/dist-lib/lib/guards.js +9 -0
  263. package/dist-lib/lib/inference-calls.d.ts +28 -23
  264. package/dist-lib/lib/inference-calls.js +25 -13
  265. package/dist-lib/lib/integrations/mcp-providers.d.ts +2 -2
  266. package/dist-lib/lib/integrations/setup-routes.d.ts +2 -2
  267. package/dist-lib/lib/knowledge-search.d.ts +6 -5
  268. package/dist-lib/lib/knowledge-search.js +26 -18
  269. package/dist-lib/lib/kv-cache-reclaim.js +4 -2
  270. package/dist-lib/lib/kv-cache.js +8 -4
  271. package/dist-lib/lib/legacy-core-domain.d.ts +42 -42
  272. package/dist-lib/lib/log-buffer.js +2 -1
  273. package/dist-lib/lib/log.js +25 -15
  274. package/dist-lib/lib/mesh-scoped-engine.js +12 -4
  275. package/dist-lib/lib/model-catalog-revision.js +6 -3
  276. package/dist-lib/lib/model-clamp.js +6 -3
  277. package/dist-lib/lib/model-context.d.ts +8 -3
  278. package/dist-lib/lib/model-context.js +13 -5
  279. package/dist-lib/lib/model-download-status.js +4 -2
  280. package/dist-lib/lib/model-download.d.ts +12 -4
  281. package/dist-lib/lib/model-download.js +200 -103
  282. package/dist-lib/lib/model-idle-pusher.d.ts +2 -2
  283. package/dist-lib/lib/model-idle-pusher.js +3 -4
  284. package/dist-lib/lib/oauth/browser-connect.d.ts +10 -8
  285. package/dist-lib/lib/oauth/browser-connect.js +33 -20
  286. package/dist-lib/lib/oauth/client.d.ts +2 -2
  287. package/dist-lib/lib/oauth/flow-core.js +23 -9
  288. package/dist-lib/lib/oauth/flow.d.ts +1 -3
  289. package/dist-lib/lib/oauth/flow.js +9 -5
  290. package/dist-lib/lib/oauth/keys.d.ts +4 -4
  291. package/dist-lib/lib/oauth/keys.js +18 -12
  292. package/dist-lib/lib/oauth/loopback.d.ts +2 -2
  293. package/dist-lib/lib/oauth/loopback.js +147 -107
  294. package/dist-lib/lib/oauth/loopback.stub.d.ts +2 -2
  295. package/dist-lib/lib/oauth/loopback.stub.js +1 -1
  296. package/dist-lib/lib/oauth/pkce.d.ts +4 -2
  297. package/dist-lib/lib/oauth/pkce.js +10 -0
  298. package/dist-lib/lib/oauth/providers.js +5 -5
  299. package/dist-lib/lib/oauth/redirect-types.d.ts +12 -7
  300. package/dist-lib/lib/oauth/register.js +3 -2
  301. package/dist-lib/lib/oauth/registry.d.ts +2 -2
  302. package/dist-lib/lib/oauth/registry.js +2 -1
  303. package/dist-lib/lib/oauth/resolve.d.ts +30 -10
  304. package/dist-lib/lib/oauth/resolve.js +12 -6
  305. package/dist-lib/lib/oauth/token-exchange-core.d.ts +12 -4
  306. package/dist-lib/lib/oauth/token-exchange-core.js +1 -1
  307. package/dist-lib/lib/oauth/types.d.ts +12 -12
  308. package/dist-lib/lib/oauth.d.ts +4 -5
  309. package/dist-lib/lib/oauth.js +2 -3
  310. package/dist-lib/lib/reconnecting-watch.d.ts +1 -1
  311. package/dist-lib/lib/reconnecting-watch.js +6 -6
  312. package/dist-lib/lib/retry-budget.js +6 -3
  313. package/dist-lib/lib/run-notices.d.ts +1 -0
  314. package/dist-lib/lib/run-notices.js +5 -2
  315. package/dist-lib/lib/run-transcript.d.ts +2 -4
  316. package/dist-lib/lib/run-transcript.js +4 -2
  317. package/dist-lib/lib/skill-readiness.js +4 -2
  318. package/dist-lib/lib/skill-types.d.ts +16 -16
  319. package/dist-lib/lib/suspend-lifecycle.d.ts +4 -4
  320. package/dist-lib/lib/suspend-lifecycle.js +10 -5
  321. package/dist-lib/lib/task.js +22 -12
  322. package/dist-lib/lib/unref.d.ts +3 -2
  323. package/dist-lib/lib/unref.js +2 -1
  324. package/dist-lib/lib/wav-duration.js +10 -5
  325. package/dist-lib/lib/write-queue.d.ts +5 -4
  326. package/dist-lib/lib/write-queue.js +2 -1
  327. package/dist-lib/schema/build.js +10 -6
  328. package/dist-lib/schema/config.d.ts +2 -3
  329. package/dist-lib/schema/content.d.ts +17 -2
  330. package/dist-lib/schema/content.js +2 -1
  331. package/dist-lib/schema/engine.d.ts +3 -2
  332. package/dist-lib/schema/engine.js +95 -6
  333. package/dist-lib/schema/field-order.js +22 -11
  334. package/dist-lib/schema/indexes.d.ts +22 -0
  335. package/dist-lib/schema/{helpers.js → indexes.js} +14 -57
  336. package/dist-lib/schema/local.d.ts +3 -2
  337. package/dist-lib/schema/local.js +7 -2
  338. package/dist-lib/schema/media-kind.d.ts +8 -0
  339. package/dist-lib/schema/media-kind.js +52 -0
  340. package/dist-lib/schema/qvac.d.ts +12 -9
  341. package/dist-lib/schema/qvac.js +8 -4
  342. package/dist-lib/spec/bind.js +12 -0
  343. package/dist-lib/spec/calls.js +4 -0
  344. package/dist-lib/spec/capabilities.d.ts +12 -4
  345. package/dist-lib/spec/hrpc/hrpc.json +54 -2
  346. package/dist-lib/spec/hrpc/index.js +53 -5
  347. package/dist-lib/spec/hrpc/messages.js +783 -494
  348. package/dist-lib/spec/hyperschema/index.js +783 -494
  349. package/dist-lib/spec/hyperschema/schema.json +247 -1
  350. package/dist-lib/spec/hyperschema/types.d.ts +69 -1
  351. package/dist-lib/spec/local/hyperdb/index.js +1 -1
  352. package/dist-lib/spec/local/hyperdb/messages.js +82 -14
  353. package/dist-lib/spec/local/hyperschema/index.js +42 -8
  354. package/dist-lib/spec/local/hyperschema/schema.json +27 -1
  355. package/dist-lib/spec/local/hyperschema/types.d.ts +6 -1
  356. package/dist-lib/spec/mesh/hyperdb/index.js +1 -1
  357. package/package.json +7 -3
  358. package/tui/app.mjs +2424 -941
  359. package/tui/boot.mjs +17 -46
  360. package/tui/index.mjs +10 -5
  361. package/tui/lib/boot-timing.mjs +8 -8
  362. package/tui/lib/busy-words.mjs +21 -22
  363. package/tui/lib/export.mjs +100 -32
  364. package/tui/lib/knowledge-command.mjs +64 -19
  365. package/tui/lib/knowledge-import.mjs +52 -18
  366. package/tui/lib/render.mjs +65 -33
  367. package/tui/lib/save-file.mjs +30 -13
  368. package/tui/lib/select.mjs +23 -5
  369. package/tui/lib/selection.mjs +6 -4
  370. package/tui/lib/setup.mjs +11 -19
  371. package/tui/lib/sidebar.mjs +23 -13
  372. package/tui/lib/splash.mjs +6 -7
  373. package/tui/lib/upload-frames.mjs +1 -2
  374. package/tui/lib/usage.mjs +13 -9
  375. package/tui/lib/wrap.mjs +35 -6
  376. package/tui/main.mjs +54 -78
  377. package/worker/assistant-sidecar.mjs +5 -10
  378. package/worker/stow-entry.mjs +7 -4
  379. package/dist-lib/lib/custom-model-source.d.ts +0 -15
  380. package/dist-lib/lib/custom-model-source.js +0 -46
  381. package/dist-lib/lib/oauth/common.d.ts +0 -38
  382. package/dist-lib/lib/oauth/common.js +0 -34
  383. package/dist-lib/schema/helpers.d.ts +0 -33
@@ -1,6 +1,10 @@
1
1
  import { diffusionDownloadName } from '@qvac/harness/lib/models/model-catalog.ts';
2
2
  import { RUN_FAILURE_REASONS } from '../run-notices.js';
3
3
  import { toEngineSkill } from './skill-encode.js';
4
+ import { isRecord } from '../guards.js';
5
+ export function isHarnessEvent(event, type) {
6
+ return event.type === type;
7
+ }
4
8
  export function harnessListModels(harness) {
5
9
  return async ({ type, cachedOnly, fullRegistry } = {}) => ({
6
10
  models: [
@@ -21,17 +25,34 @@ export function harnessClearKvCache(harness) {
21
25
  error: 'Harness does not support KV cache deletion'
22
26
  };
23
27
  }
28
+ export const PREVIEW_CONTRACT_MATCHES = true;
29
+ export const DELETE_CONTRACT_MATCHES = true;
30
+ export function harnessPreviewModelSource(harness) {
31
+ return async ({ src, mmprojSrc }) => {
32
+ if (!harness.previewModelSource) {
33
+ throw new Error('harness does not support previewModelSource');
34
+ }
35
+ const preview = await harness.previewModelSource({ src, mmprojSrc: mmprojSrc ?? undefined });
36
+ return {
37
+ ...preview,
38
+ files: preview.files ? [...preview.files] : undefined,
39
+ fitReasons: preview.fitReasons ? [...preview.fitReasons] : undefined
40
+ };
41
+ };
42
+ }
24
43
  export function harnessTranscribe(harness) {
25
44
  return async ({ audio, model }) => {
26
- if (!harness.transcribe)
45
+ if (!harness.transcribe) {
27
46
  throw new Error('harness does not support transcribe');
47
+ }
28
48
  return { text: await harness.transcribe({ audio, model: model ?? '' }) };
29
49
  };
30
50
  }
31
51
  export function harnessDetectLanguage(harness) {
32
52
  return async ({ text, topK }) => {
33
- if (!harness.detectLanguage)
53
+ if (!harness.detectLanguage) {
34
54
  throw new Error('harness does not support detectLanguage');
55
+ }
35
56
  const languages = await harness.detectLanguage({ text, topK: topK || undefined });
36
57
  return {
37
58
  languages: languages.map(({ code, language, probability }) => ({
@@ -52,8 +73,9 @@ export function harnessSpeak(harness) {
52
73
  }
53
74
  export function harnessSkillCatalog(harness, syncCredentials) {
54
75
  return async (agentId, modelName, options) => {
55
- if (options?.refresh)
76
+ if (options?.refresh) {
56
77
  await syncCredentials?.();
78
+ }
57
79
  return {
58
80
  skills: ((await harness.skills?.(agentId, modelName, options)) ?? []).map(toEngineSkill)
59
81
  };
@@ -75,8 +97,9 @@ export function harnessSkillManagement(harness) {
75
97
  return file ? { found: true, content: file.content, origin: file.origin } : { found: false };
76
98
  },
77
99
  async writeSkillFile(name, content) {
78
- if (!harness.writeSkillFile)
100
+ if (!harness.writeSkillFile) {
79
101
  return { ok: false };
102
+ }
80
103
  return harness.writeSkillFile(name, content);
81
104
  },
82
105
  async copySkillForEdit(name) {
@@ -108,8 +131,9 @@ export function toolReportEntry(tool) {
108
131
  }
109
132
  export function harnessSpeakStream(harness) {
110
133
  return async function* (text) {
111
- if (!harness.speakStream)
134
+ if (!harness.speakStream) {
112
135
  throw new Error('harness does not support speakStream');
136
+ }
113
137
  for await (const { audio, sampleRate } of harness.speakStream({ model: '', text })) {
114
138
  yield { audio, sampleRate };
115
139
  }
@@ -117,25 +141,24 @@ export function harnessSpeakStream(harness) {
117
141
  }
118
142
  export function harnessDeathReason(status) {
119
143
  const HARNESS_DIED = RUN_FAILURE_REASONS.harnessDied;
120
- if (typeof status !== 'object' || status === null)
144
+ if (typeof status !== 'object' || status === null) {
121
145
  return HARNESS_DIED;
122
- const record = status;
123
- const detail = typeof record.error === 'string' && record.error ? record.error : null;
124
- const code = typeof record.code === 'string' && record.code ? record.code : null;
125
- if (!detail)
146
+ }
147
+ const detail = 'error' in status && typeof status.error === 'string' && status.error ? status.error : null;
148
+ const code = 'code' in status && typeof status.code === 'string' && status.code ? status.code : null;
149
+ if (!detail) {
126
150
  return code ? `${HARNESS_DIED} (${code})` : HARNESS_DIED;
151
+ }
127
152
  return code ? `${HARNESS_DIED}: ${detail} (${code})` : `${HARNESS_DIED}: ${detail}`;
128
153
  }
129
154
  export function harnessDied(status) {
130
- if (typeof status !== 'object' || status === null || !('state' in status))
155
+ if (typeof status !== 'object' || status === null || !('state' in status)) {
131
156
  return false;
157
+ }
132
158
  return status.state === 'died';
133
159
  }
134
160
  export function modelCatalogChanged(state) {
135
- return (typeof state === 'object' &&
136
- state !== null &&
137
- 'catalogChanged' in state &&
138
- state.catalogChanged === true);
161
+ return isRecord(state) && state.catalogChanged === true;
139
162
  }
140
163
  export function imageDownloadProgress(state) {
141
164
  if (typeof state !== 'object' ||
@@ -156,8 +179,9 @@ export function imageDownloadProgress(state) {
156
179
  return null;
157
180
  }
158
181
  const model = diffusionDownloadName(state.model);
159
- if (!model)
182
+ if (!model) {
160
183
  return null;
184
+ }
161
185
  return {
162
186
  model,
163
187
  phase: state.status === 'downloading' ? 'downloading' : 'complete',
@@ -24,13 +24,15 @@ export interface CompactResult {
24
24
  readonly reason?: string;
25
25
  }
26
26
  export declare function couldNameSenders(chunks: ReadonlyArray<AssistantChunk>): boolean;
27
- export declare function senderNamesFrom(chunks: ReadonlyArray<AssistantChunk>, members: ReadonlyArray<{
28
- id: Buffer;
29
- name: string;
30
- }>, devices: ReadonlyArray<{
31
- id: Buffer;
32
- memberId?: Buffer | null;
33
- }>): ReadonlyMap<string, string>;
27
+ export interface SenderMember {
28
+ readonly id: Buffer;
29
+ readonly name: string;
30
+ }
31
+ export interface SenderDevice {
32
+ readonly id: Buffer;
33
+ readonly memberId?: Buffer | null;
34
+ }
35
+ export declare function senderNamesFrom(chunks: ReadonlyArray<AssistantChunk>, members: ReadonlyArray<SenderMember>, devices: ReadonlyArray<SenderDevice>): ReadonlyMap<string, string>;
34
36
  export declare function senderAttribution(names: ReadonlyMap<string, string>): string;
35
37
  export declare function historyFromChunks(chunks: ReadonlyArray<AssistantChunk>, stale?: Partial<StaleToolRuns>, senderNames?: ReadonlyMap<string, string>): ChatMessage[];
36
38
  export declare function inputAvailableToRun(chunk: AssistantChunk, requestSeq: number): boolean;
@@ -1,10 +1,12 @@
1
1
  import { attachmentTurn, skillLoadedTurn } from '@qvac/harness/lib/capabilities/tool-turns.ts';
2
2
  import { HISTORY_CHUNK_TYPES } from '../core/chunk.js';
3
3
  import { isAudioAttachment } from '../core/audio-attachment.js';
4
- import { isDocumentAttachment } from '../core/document-attachment.js';
4
+ import { isDocumentAttachment, isPdfAttachment } from '../core/document-attachment.js';
5
5
  import { groupAttachmentsByMessage } from '../core/files/index.js';
6
6
  import { IMAGE_MIMES } from '../core/image/normalize.js';
7
7
  import { compactionTurn, foldCompactedChunks } from '../compaction.js';
8
+ import b4a from 'b4a';
9
+ import { isRecord } from '../guards.js';
8
10
  export const TERMINAL_STATES = new Set(['completed', 'failed', 'canceled']);
9
11
  export const HISTORY_TYPES = HISTORY_CHUNK_TYPES;
10
12
  export const SKILL_TOOL = 'skill';
@@ -27,8 +29,9 @@ export function latestAttemptStarts(chunks) {
27
29
  continue;
28
30
  if (TERMINAL_STATES.has(chunk.runStatus?.state ?? ''))
29
31
  continue;
30
- if (chunk.runStatus?.progress?.phase === 'compacting')
32
+ if (chunk.runStatus?.progress?.phase === 'compacting') {
31
33
  continue;
34
+ }
32
35
  starts.set(chunk.runId, chunk.seq);
33
36
  }
34
37
  return starts;
@@ -44,25 +47,28 @@ export function couldNameSenders(chunks) {
44
47
  for (const chunk of chunks) {
45
48
  if (chunk.type !== 'user-message')
46
49
  continue;
47
- seen.add((chunk.senderMemberId ?? chunk.originDeviceId).toString('hex'));
48
- if (seen.size > 1)
50
+ seen.add(b4a.toHex(chunk.senderMemberId ?? chunk.originDeviceId));
51
+ if (seen.size > 1) {
49
52
  return true;
53
+ }
50
54
  }
51
55
  return false;
52
56
  }
53
57
  export function senderNamesFrom(chunks, members, devices) {
54
- if (members.length < 2)
58
+ if (members.length < 2) {
55
59
  return new Map();
56
- const byMember = new Map(members.map((member) => [member.id.toString('hex'), member.name]));
57
- const deviceMember = new Map(devices.map((device) => [device.id.toString('hex'), device.memberId]));
60
+ }
61
+ const byMember = new Map(members.map((member) => [b4a.toHex(member.id), member.name]));
62
+ const deviceMember = new Map(devices.map((device) => [b4a.toHex(device.id), device.memberId]));
58
63
  const names = new Map();
59
64
  for (const chunk of chunks) {
60
65
  if (chunk.type !== 'user-message')
61
66
  continue;
62
- const memberId = chunk.senderMemberId ?? deviceMember.get(chunk.originDeviceId.toString('hex'));
63
- const name = memberId ? byMember.get(memberId.toString('hex')) : undefined;
64
- if (name)
67
+ const memberId = chunk.senderMemberId ?? deviceMember.get(b4a.toHex(chunk.originDeviceId));
68
+ const name = memberId ? byMember.get(b4a.toHex(memberId)) : undefined;
69
+ if (name) {
65
70
  names.set(chunk.id, name);
71
+ }
66
72
  }
67
73
  return names;
68
74
  }
@@ -80,16 +86,19 @@ export function historyFromChunks(chunks, stale = {}, senderNames = new Map()) {
80
86
  const attachments = [];
81
87
  const userMessages = [];
82
88
  for (const chunk of source) {
83
- if (chunk.type === 'attachment')
89
+ if (chunk.type === 'attachment') {
84
90
  attachments.push(chunk);
85
- else if (chunk.userMessage)
91
+ }
92
+ else if (chunk.userMessage) {
86
93
  userMessages.push(chunk);
94
+ }
87
95
  }
88
96
  const byMessage = groupAttachmentsByMessage(attachments, userMessages);
89
97
  const history = [];
90
98
  const replayedSkills = new Set();
91
- if (folded.summary)
99
+ if (folded.summary) {
92
100
  history.push({ role: 'user', content: compactionTurn(folded.summary) });
101
+ }
93
102
  const byRun = new Map();
94
103
  const anchor = (runId) => {
95
104
  let turn = byRun.get(runId);
@@ -102,39 +111,52 @@ export function historyFromChunks(chunks, stale = {}, senderNames = new Map()) {
102
111
  };
103
112
  for (const chunk of source) {
104
113
  if (chunk.userMessage) {
105
- if (staleQuestionChunkIds.has(chunk.id))
114
+ if (staleQuestionChunkIds.has(chunk.id)) {
106
115
  continue;
116
+ }
107
117
  const sender = shared ? senderNames.get(chunk.id) : undefined;
108
118
  const turn = { role: 'user', content: chunk.userMessage.text };
109
- if (sender)
119
+ if (sender) {
110
120
  turn.sender = sender;
121
+ }
111
122
  const refs = (byMessage.get(chunk.id) ?? [])
112
- .map((attachmentChunk) => attachmentChunk.attachment)
123
+ .flatMap((attachmentChunk) => attachmentChunk.attachment ?? [])
113
124
  .filter((ref) => !ref.deletedAt);
114
125
  const images = refs.filter((ref) => IMAGE_MIMES.has(ref.mimeType.toLowerCase()));
115
126
  const audio = refs.filter((ref) => isAudioAttachment(ref.fileName, ref.mimeType));
116
127
  const documents = refs.filter((ref) => isDocumentAttachment(ref));
117
- if (images.length)
128
+ const pdfs = documents.filter(isPdfAttachment);
129
+ if (images.length) {
118
130
  turn.images = images;
119
- if (audio.length)
131
+ }
132
+ if (audio.length) {
120
133
  turn.audioAttachments = audio;
121
- if (documents.length)
134
+ }
135
+ if (documents.length) {
122
136
  turn.documents = documents;
137
+ }
138
+ if (pdfs.length) {
139
+ turn.pdfs = pdfs;
140
+ }
123
141
  history.push(turn);
124
142
  continue;
125
143
  }
126
- if (chunk.attachment)
144
+ if (chunk.attachment) {
127
145
  continue;
146
+ }
128
147
  if (chunk.type === 'run-request' && chunk.runId) {
129
148
  anchor(chunk.runId);
130
149
  continue;
131
150
  }
132
151
  if (chunk.toolResult?.name === SKILL_TOOL) {
133
- if (chunk.runId && staleRunIds.has(chunk.runId))
152
+ if (chunk.runId && staleRunIds.has(chunk.runId)) {
134
153
  continue;
135
- if (beforeLatestAttempt(chunk, attemptStarts))
154
+ }
155
+ if (beforeLatestAttempt(chunk, attemptStarts)) {
136
156
  continue;
137
- const loaded = chunk.toolResult.result?.name;
157
+ }
158
+ const { result } = chunk.toolResult;
159
+ const loaded = isRecord(result) ? result.name : undefined;
138
160
  if (typeof loaded === 'string' && !replayedSkills.has(loaded)) {
139
161
  replayedSkills.add(loaded);
140
162
  const at = history.indexOf(anchor(chunk.runId)) + 1;
@@ -143,21 +165,27 @@ export function historyFromChunks(chunks, stale = {}, senderNames = new Map()) {
143
165
  continue;
144
166
  }
145
167
  if (chunk.toolResult) {
146
- if (chunk.runId && staleRunIds.has(chunk.runId))
168
+ if (chunk.runId && staleRunIds.has(chunk.runId)) {
147
169
  continue;
148
- if (beforeLatestAttempt(chunk, attemptStarts))
170
+ }
171
+ if (beforeLatestAttempt(chunk, attemptStarts)) {
149
172
  continue;
173
+ }
150
174
  const produced = attachmentTurn(chunk.toolResult.name, chunk.toolResult.result);
151
- if (produced)
175
+ if (produced) {
152
176
  history.push({ role: 'tool', content: produced });
177
+ }
153
178
  continue;
154
179
  }
155
- if (!chunk.content)
180
+ if (!chunk.content) {
156
181
  continue;
157
- if (chunk.runId && staleRunIds.has(chunk.runId))
182
+ }
183
+ if (chunk.runId && staleRunIds.has(chunk.runId)) {
158
184
  continue;
159
- if (beforeLatestAttempt(chunk, attemptStarts))
185
+ }
186
+ if (beforeLatestAttempt(chunk, attemptStarts)) {
160
187
  continue;
188
+ }
161
189
  anchor(chunk.runId).content += chunk.content.text;
162
190
  }
163
191
  return history.filter((turn) => turn.role === 'user' || turn.content.length > 0);
@@ -205,12 +233,13 @@ export function staleToolRunIds(historyChunks, approvalChunks, currentRunId) {
205
233
  const empty = { runIds: new Set(), questionChunkIds: new Set() };
206
234
  const toolRuns = new Set();
207
235
  for (const chunk of approvalChunks) {
208
- if (chunk.runId)
236
+ if (chunk.runId) {
209
237
  toolRuns.add(chunk.runId);
238
+ }
210
239
  }
211
- if (!toolRuns.size)
240
+ if (!toolRuns.size) {
212
241
  return empty;
213
- const turnOrder = [];
242
+ }
214
243
  const turnText = new Map();
215
244
  const turnRuns = new Map();
216
245
  const runChunk = new Map();
@@ -223,7 +252,6 @@ export function staleToolRunIds(historyChunks, approvalChunks, currentRunId) {
223
252
  if (chunk.type === 'run-request' && chunk.runId && lastUser !== null) {
224
253
  const chunkId = lastUser.chunkId;
225
254
  if (!turnText.has(chunkId)) {
226
- turnOrder.push(chunkId);
227
255
  turnText.set(chunkId, lastUser.text);
228
256
  }
229
257
  turnRuns.set(chunkId, [...(turnRuns.get(chunkId) ?? []), chunk.runId]);
@@ -231,31 +259,38 @@ export function staleToolRunIds(historyChunks, approvalChunks, currentRunId) {
231
259
  }
232
260
  }
233
261
  const currentChunkId = runChunk.get(currentRunId) ?? lastUser?.chunkId;
234
- if (currentChunkId === undefined)
262
+ if (currentChunkId === undefined) {
235
263
  return empty;
264
+ }
236
265
  const currentText = turnText.get(currentChunkId) ?? lastUser?.text;
237
- if (currentText === undefined)
266
+ if (currentText === undefined) {
238
267
  return empty;
268
+ }
239
269
  const target = normalizeQuestion(currentText);
240
- if (isGenericAcknowledgement(target))
270
+ if (isGenericAcknowledgement(target)) {
241
271
  return empty;
242
- const currentIndex = turnOrder.indexOf(currentChunkId);
243
- const start = currentIndex === -1 ? turnOrder.length - 1 : currentIndex - 1;
272
+ }
273
+ const turns = [...turnText];
274
+ const currentIndex = turns.findIndex(([chunkId]) => chunkId === currentChunkId);
275
+ const start = currentIndex === -1 ? turns.length - 1 : currentIndex - 1;
244
276
  const runIds = new Set();
245
277
  const questionChunkIds = new Set();
246
278
  let blockHadApproval = false;
247
279
  for (let i = start; i >= 0; i--) {
248
- const chunkId = turnOrder[i];
249
- if (normalizeQuestion(turnText.get(chunkId)) !== target)
280
+ const [chunkId, text] = turns[i];
281
+ if (normalizeQuestion(text) !== target) {
250
282
  break;
283
+ }
251
284
  questionChunkIds.add(chunkId);
252
285
  for (const rid of turnRuns.get(chunkId) ?? []) {
253
286
  runIds.add(rid);
254
- if (toolRuns.has(rid))
287
+ if (toolRuns.has(rid)) {
255
288
  blockHadApproval = true;
289
+ }
256
290
  }
257
291
  }
258
- if (!blockHadApproval)
292
+ if (!blockHadApproval) {
259
293
  return empty;
294
+ }
260
295
  return { runIds, questionChunkIds };
261
296
  }
@@ -9,6 +9,7 @@ export interface ChatMessage {
9
9
  images?: AttachmentRef[];
10
10
  audioAttachments?: AttachmentRef[];
11
11
  documents?: DocumentAttachment[];
12
+ pdfs?: AttachmentRef[];
12
13
  }
13
14
  export declare const IMAGE_ONLY_USER_PROMPT = "The user sent one or more images without any accompanying text. Describe what the images show and respond to anything notable in them.";
14
15
  export declare const DOCUMENT_ONLY_USER_PROMPT = "The user sent one or more documents without any accompanying text. Summarize the attached documents.";
@@ -17,9 +18,10 @@ export declare function backfillDocumentOnlyTurn(messages: ChatMessage[]): void;
17
18
  export declare function backfillImageOnlyTurns(messages: ChatMessage[]): void;
18
19
  export declare function unreadableImagesNotice(fileNames: readonly string[]): string;
19
20
  export declare function annotateUnreadableImages(unreadable: ReadonlyMap<ChatMessage, string[]>): void;
20
- export declare function unheardAudioNotice(label: string, reason: string, opts?: {
21
- retryable?: boolean;
22
- }): string;
21
+ export interface UnheardAudioNoticeOptions {
22
+ readonly retryable?: boolean;
23
+ }
24
+ export declare function unheardAudioNotice(label: string, reason: string, opts?: UnheardAudioNoticeOptions): string;
23
25
  export declare function silentAudioNotice(fileName: string): string;
24
26
  export declare function audioTranscriptBlock(fileName: string, transcript: string): string;
25
27
  export interface AttachmentRef {
@@ -3,8 +3,9 @@ export const DOCUMENT_ONLY_USER_PROMPT = 'The user sent one or more documents wi
3
3
  export const IMAGE_AND_DOCUMENT_USER_PROMPT = 'The user sent one or more images together with one or more documents, and no accompanying text. Describe what the images show and summarize the attached documents.';
4
4
  export function backfillDocumentOnlyTurn(messages) {
5
5
  const last = messages.findLast((turn) => turn.role === 'user');
6
- if (!last || last.content.trim())
6
+ if (!last || last.content.trim()) {
7
7
  return;
8
+ }
8
9
  last.content = last.attachments?.length
9
10
  ? IMAGE_AND_DOCUMENT_USER_PROMPT
10
11
  : DOCUMENT_ONLY_USER_PROMPT;
@@ -13,8 +14,9 @@ export function backfillImageOnlyTurns(messages) {
13
14
  for (const turn of messages) {
14
15
  if (turn.role !== 'user' || turn.content.trim())
15
16
  continue;
16
- if (turn.attachments?.length)
17
+ if (turn.attachments?.length) {
17
18
  turn.content = IMAGE_ONLY_USER_PROMPT;
19
+ }
18
20
  }
19
21
  }
20
22
  export function unreadableImagesNotice(fileNames) {
@@ -18,4 +18,6 @@ export interface Skill {
18
18
  export declare function toEngineSkill(skill: Skill): AssistantSkill;
19
19
  export declare function toEngineSkillRequirements(requires: SkillRequires): NonNullable<AssistantSkill['requirements']>;
20
20
  export declare function toEngineInstallStep(step: InstallStep): NonNullable<AssistantSkill['install']>[number];
21
- export declare function toEngineSkillSetup(setup: SkillSetup): NonNullable<AssistantSkill['setup']>;
21
+ type EngineSetup = NonNullable<AssistantSkill['setup']>;
22
+ export declare function toEngineSkillSetup(setup: SkillSetup): EngineSetup;
23
+ export {};
@@ -10,12 +10,12 @@ export function toEngineSkill(skill) {
10
10
  allowList: [...skill.allowList],
11
11
  platforms: [...skill.platform],
12
12
  status: skill.status,
13
- ...(skill.requires ? { requirements: toEngineSkillRequirements(skill.requires) } : {}),
14
- ...(skill.install ? { install: skill.install.map(toEngineInstallStep) } : {}),
15
- ...(setup ? { setup: toEngineSkillSetup(setup) } : {}),
16
- ...(skill.stub !== undefined ? { stub: skill.stub } : {}),
17
- ...(skill.minCapabilityProfile ? { minCapabilityProfile: skill.minCapabilityProfile } : {}),
18
- ...(skill.emoji ? { emoji: skill.emoji } : {})
13
+ requirements: skill.requires ? toEngineSkillRequirements(skill.requires) : undefined,
14
+ install: skill.install?.map(toEngineInstallStep),
15
+ setup: setup ? toEngineSkillSetup(setup) : undefined,
16
+ stub: skill.stub,
17
+ minCapabilityProfile: skill.minCapabilityProfile,
18
+ emoji: skill.emoji
19
19
  };
20
20
  }
21
21
  export function toEngineSkillRequirements(requires) {
@@ -33,65 +33,55 @@ export function toEngineInstallStep(step) {
33
33
  id: step.id,
34
34
  kind: step.kind,
35
35
  label: step.label,
36
- ...(step.formula ? { formula: step.formula } : {}),
37
- ...(step.command ? { command: step.command } : {}),
38
- ...(step.manual !== undefined ? { manual: step.manual } : {}),
39
- ...(step.bins ? { bins: [...step.bins] } : {})
36
+ formula: step.formula,
37
+ command: step.command,
38
+ manual: step.manual,
39
+ bins: step.bins && [...step.bins]
40
40
  };
41
41
  }
42
42
  export function toEngineSkillSetup(setup) {
43
43
  return {
44
- ...(setup.summary ? { summary: setup.summary } : {}),
45
- ...(setup.routes
46
- ? {
47
- routes: setup.routes.map((route) => ({
48
- kind: route.kind,
49
- label: route.label,
50
- ...(route.provider ? { provider: route.provider } : {}),
51
- ...(route.credentialKey ? { credentialKey: route.credentialKey } : {}),
52
- ...(route.description ? { description: route.description } : {}),
53
- ...(route.helpUrl ? { helpUrl: route.helpUrl } : {}),
54
- ...(route.steps ? { steps: [...route.steps] } : {}),
55
- ...(route.configSteps ? { configSteps: [...route.configSteps] } : {}),
56
- ...(route.fields
57
- ? {
58
- fields: route.fields.map((field) => ({
59
- key: field.key,
60
- label: field.label,
61
- ...(field.placeholder ? { placeholder: field.placeholder } : {}),
62
- ...(field.secret !== undefined ? { secret: field.secret } : {}),
63
- ...(field.required !== undefined ? { required: field.required } : {})
64
- }))
65
- }
66
- : {}),
67
- ...(route.satisfied !== undefined ? { satisfied: route.satisfied } : {}),
68
- ...(route.oauth &&
69
- route.oauth.stateKey &&
70
- route.oauth.authUrl &&
71
- route.oauth.tokenUrl &&
72
- TOKEN_AUTH.includes(route.oauth.tokenAuth)
73
- ? {
74
- oauth: {
75
- stateKey: route.oauth.stateKey,
76
- authUrl: route.oauth.authUrl,
77
- tokenUrl: route.oauth.tokenUrl,
78
- tokenAuth: route.oauth.tokenAuth,
79
- scopes: [...(route.oauth.scopes ?? [])],
80
- ...(route.oauth.extraAuthParams
81
- ? { extraAuthParams: route.oauth.extraAuthParams }
82
- : {}),
83
- ...(route.oauth.registrationEndpoint
84
- ? { registrationEndpoint: route.oauth.registrationEndpoint }
85
- : {}),
86
- ...(route.oauth.port !== undefined ? { port: route.oauth.port } : {}),
87
- ...(route.oauth.sharedIosSession !== undefined
88
- ? { sharedIosSession: route.oauth.sharedIosSession }
89
- : {})
90
- }
91
- }
92
- : {})
93
- }))
94
- }
95
- : {})
44
+ summary: setup.summary,
45
+ routes: setup.routes?.map(toEngineRoute)
46
+ };
47
+ }
48
+ function toEngineRoute(route) {
49
+ return {
50
+ kind: route.kind,
51
+ label: route.label,
52
+ provider: route.provider,
53
+ credentialKey: route.credentialKey,
54
+ description: route.description,
55
+ helpUrl: route.helpUrl,
56
+ steps: route.steps && [...route.steps],
57
+ configSteps: route.configSteps && [...route.configSteps],
58
+ fields: route.fields?.map((field) => ({
59
+ key: field.key,
60
+ label: field.label,
61
+ placeholder: field.placeholder,
62
+ secret: field.secret,
63
+ required: field.required
64
+ })),
65
+ satisfied: route.satisfied,
66
+ oauth: toEngineOauth(route.oauth)
67
+ };
68
+ }
69
+ function toEngineOauth(oauth) {
70
+ if (!oauth?.stateKey || !oauth.authUrl || !oauth.tokenUrl)
71
+ return undefined;
72
+ const tokenAuth = TOKEN_AUTH.find((mode) => mode === oauth.tokenAuth);
73
+ if (!tokenAuth) {
74
+ return undefined;
75
+ }
76
+ return {
77
+ stateKey: oauth.stateKey,
78
+ authUrl: oauth.authUrl,
79
+ tokenUrl: oauth.tokenUrl,
80
+ tokenAuth,
81
+ scopes: [...(oauth.scopes ?? [])],
82
+ extraAuthParams: oauth.extraAuthParams,
83
+ registrationEndpoint: oauth.registrationEndpoint,
84
+ port: oauth.port,
85
+ sharedIosSession: oauth.sharedIosSession
96
86
  };
97
87
  }
@@ -5,8 +5,10 @@ export class AssistantClient extends Client {
5
5
  _inline;
6
6
  constructor({ sidecar: spawnSidecar = true, storagePath, device, meshSeed, meshKey, bootstrapNodes, entry, ...engineOptions }) {
7
7
  const inline = { core: null };
8
- if (spawnSidecar && !entry)
8
+ if (spawnSidecar && !entry) {
9
9
  throw new Error('sidecar mode needs a stowed bundle entry');
10
+ }
11
+ const sidecarEntry = spawnSidecar ? entry : undefined;
10
12
  const args = [
11
13
  storagePath,
12
14
  device?.name ?? '',
@@ -16,14 +18,15 @@ export class AssistantClient extends Client {
16
18
  meshKey ? b4a.toHex(meshKey) : '',
17
19
  (bootstrapNodes ?? []).map((node) => `${node.host}:${node.port}`).join(',')
18
20
  ];
19
- const transport = spawnSidecar
21
+ const transport = sidecarEntry
20
22
  ? async () => {
21
23
  const { default: sidecarRunner } = await import('bare-supervisor/runner/sidecar');
22
- const { ipc, exit } = sidecarRunner(entry, args, engineOptions.logger ?? null);
24
+ const { ipc, exit } = sidecarRunner(sidecarEntry, args, engineOptions.logger ?? null);
23
25
  const died = exit.then((code) => `sidecar exited (${code}) before ready`);
24
26
  const failure = await Promise.race([ipc.ready.then(() => null), died]);
25
- if (failure)
27
+ if (failure) {
26
28
  throw new Error(failure);
29
+ }
27
30
  return ipc;
28
31
  }
29
32
  : async () => {