@qvac/core 0.2.1 → 0.3.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 (278) hide show
  1. package/.claude/skills/compaction/SKILL.md +15 -6
  2. package/.claude/skills/js-house-style/SKILL.md +1 -0
  3. package/.claude/skills/pr-create/SKILL.md +66 -3
  4. package/.claude/skills/pr-review/SKILL.md +252 -40
  5. package/.claude/skills/release/SKILL.md +122 -0
  6. package/CLAUDE.md +8 -5
  7. package/README.md +3 -1
  8. package/dist-lib/client.js +1 -1
  9. package/dist-lib/index.js +8 -8
  10. package/dist-lib/lib/api/agents.d.ts +1 -1
  11. package/dist-lib/lib/api/agents.js +10 -10
  12. package/dist-lib/lib/api/app-config.js +1 -1
  13. package/dist-lib/lib/api/approval-rules.js +9 -5
  14. package/dist-lib/lib/api/attachments.js +25 -3
  15. package/dist-lib/lib/api/chat-groups.d.ts +1 -1
  16. package/dist-lib/lib/api/chat-groups.js +5 -4
  17. package/dist-lib/lib/api/chat.js +10 -10
  18. package/dist-lib/lib/api/chunks.d.ts +1 -1
  19. package/dist-lib/lib/api/chunks.js +11 -21
  20. package/dist-lib/lib/api/config.js +1 -1
  21. package/dist-lib/lib/api/current-mesh.d.ts +16 -1
  22. package/dist-lib/lib/api/current-mesh.js +18 -0
  23. package/dist-lib/lib/api/custom-models.js +2 -2
  24. package/dist-lib/lib/api/devices.d.ts +1 -1
  25. package/dist-lib/lib/api/devices.js +12 -9
  26. package/dist-lib/lib/api/diagnostics.js +1 -1
  27. package/dist-lib/lib/api/effective-ctx-size.js +1 -1
  28. package/dist-lib/lib/api/execution.js +4 -4
  29. package/dist-lib/lib/api/files.js +2 -2
  30. package/dist-lib/lib/api/index.d.ts +1 -0
  31. package/dist-lib/lib/api/index.js +34 -34
  32. package/dist-lib/lib/api/instrument.js +1 -1
  33. package/dist-lib/lib/api/knowledge.js +13 -9
  34. package/dist-lib/lib/api/logs.js +1 -1
  35. package/dist-lib/lib/api/members.d.ts +4 -1
  36. package/dist-lib/lib/api/members.js +87 -18
  37. package/dist-lib/lib/api/mesh.d.ts +13 -3
  38. package/dist-lib/lib/api/mesh.js +25 -2
  39. package/dist-lib/lib/api/model-download.js +1 -1
  40. package/dist-lib/lib/api/network.js +1 -1
  41. package/dist-lib/lib/api/notifications.js +3 -3
  42. package/dist-lib/lib/api/rag.js +7 -7
  43. package/dist-lib/lib/api/sync.d.ts +1 -1
  44. package/dist-lib/lib/api/sync.js +3 -2
  45. package/dist-lib/lib/api/tool-activity.js +5 -5
  46. package/dist-lib/lib/api/tool-configs.js +5 -5
  47. package/dist-lib/lib/api/watchable.d.ts +6 -1
  48. package/dist-lib/lib/api/watchable.js +14 -3
  49. package/dist-lib/lib/assistant/fetch-body.d.ts +5 -0
  50. package/dist-lib/lib/assistant/fetch-body.js +36 -0
  51. package/dist-lib/lib/assistant/harness.d.ts +225 -0
  52. package/dist-lib/lib/assistant/harness.js +154 -0
  53. package/dist-lib/lib/assistant/history.d.ts +31 -0
  54. package/dist-lib/lib/assistant/history.js +226 -0
  55. package/dist-lib/lib/assistant/message.d.ts +45 -0
  56. package/dist-lib/lib/assistant/message.js +47 -0
  57. package/dist-lib/lib/assistant/skill-encode.d.ts +21 -0
  58. package/dist-lib/lib/assistant/skill-encode.js +71 -0
  59. package/dist-lib/lib/assistant-client.js +2 -2
  60. package/dist-lib/lib/assistant-tree.js +10 -4
  61. package/dist-lib/lib/assistant.d.ts +28 -292
  62. package/dist-lib/lib/assistant.js +284 -716
  63. package/dist-lib/lib/audio-format.js +2 -2
  64. package/dist-lib/lib/client.js +2 -2
  65. package/dist-lib/lib/collabora/convert.js +1 -1
  66. package/dist-lib/lib/collabora/entry.js +1 -1
  67. package/dist-lib/lib/collabora/worker.js +1 -1
  68. package/dist-lib/lib/compaction.d.ts +1 -2
  69. package/dist-lib/lib/compaction.js +8 -6
  70. package/dist-lib/lib/constants.js +1 -1
  71. package/dist-lib/lib/core/account-recovery.d.ts +19 -0
  72. package/dist-lib/lib/core/account-recovery.js +50 -0
  73. package/dist-lib/lib/core/agent.js +8 -4
  74. package/dist-lib/lib/core/app-build.d.ts +1 -1
  75. package/dist-lib/lib/core/approval-rules.d.ts +1 -0
  76. package/dist-lib/lib/core/approval-rules.js +3 -1
  77. package/dist-lib/lib/core/archived-mesh.d.ts +25 -0
  78. package/dist-lib/lib/core/archived-mesh.js +162 -0
  79. package/dist-lib/lib/core/chat-activity.js +1 -1
  80. package/dist-lib/lib/core/chat-group.d.ts +1 -0
  81. package/dist-lib/lib/core/chat-group.js +24 -4
  82. package/dist-lib/lib/core/chat-search.js +2 -2
  83. package/dist-lib/lib/core/chat.js +5 -5
  84. package/dist-lib/lib/core/chunk.d.ts +2 -1
  85. package/dist-lib/lib/core/chunk.js +31 -4
  86. package/dist-lib/lib/core/contract/agents.js +1 -1
  87. package/dist-lib/lib/core/contract/approval-rules.js +6 -4
  88. package/dist-lib/lib/core/contract/attestations.js +1 -1
  89. package/dist-lib/lib/core/contract/chat-group.js +1 -1
  90. package/dist-lib/lib/core/contract/chat.js +1 -1
  91. package/dist-lib/lib/core/contract/chunks.js +2 -2
  92. package/dist-lib/lib/core/contract/compute.d.ts +11 -0
  93. package/dist-lib/lib/core/contract/compute.js +45 -0
  94. package/dist-lib/lib/core/contract/devices.js +19 -5
  95. package/dist-lib/lib/core/contract/index.d.ts +3 -1
  96. package/dist-lib/lib/core/contract/index.js +19 -16
  97. package/dist-lib/lib/core/contract/indexing.js +2 -2
  98. package/dist-lib/lib/core/contract/joined-meshes.js +1 -1
  99. package/dist-lib/lib/core/contract/knowledge.js +2 -2
  100. package/dist-lib/lib/core/contract/members.js +2 -2
  101. package/dist-lib/lib/core/contract/seal.d.ts +2 -0
  102. package/dist-lib/lib/core/contract/seal.js +8 -0
  103. package/dist-lib/lib/core/contract/seed-defaults.js +1 -1
  104. package/dist-lib/lib/core/contract/tool-activity.js +1 -1
  105. package/dist-lib/lib/core/contract/tool-configs.js +3 -3
  106. package/dist-lib/lib/core/contract/writers.js +66 -42
  107. package/dist-lib/lib/core/departures.js +1 -1
  108. package/dist-lib/lib/core/device-invites.js +1 -1
  109. package/dist-lib/lib/core/document-attachment.js +2 -2
  110. package/dist-lib/lib/core/files/attachments.js +3 -3
  111. package/dist-lib/lib/core/files/index.d.ts +2 -2
  112. package/dist-lib/lib/core/files/index.js +19 -19
  113. package/dist-lib/lib/core/files/knowledge.js +3 -3
  114. package/dist-lib/lib/core/files/preview/image.js +1 -1
  115. package/dist-lib/lib/core/files/preview/index.js +6 -6
  116. package/dist-lib/lib/core/files/processing/claims.js +1 -1
  117. package/dist-lib/lib/core/files/processing/document.js +5 -5
  118. package/dist-lib/lib/core/files/processing/index.js +8 -8
  119. package/dist-lib/lib/core/files/processing/ownership.js +1 -1
  120. package/dist-lib/lib/core/files/processing/protocol.js +3 -3
  121. package/dist-lib/lib/core/files/processing/source.js +1 -1
  122. package/dist-lib/lib/core/files/rag/artifact/codec.js +1 -1
  123. package/dist-lib/lib/core/files/rag/artifact/id.js +1 -1
  124. package/dist-lib/lib/core/files/rag/artifact/types.d.ts +4 -4
  125. package/dist-lib/lib/core/files/rag/build.js +2 -2
  126. package/dist-lib/lib/core/files/rag/chunk/chunking.js +2 -2
  127. package/dist-lib/lib/core/files/rag/document-types.d.ts +3 -3
  128. package/dist-lib/lib/core/files/rag/extract/document-types.d.ts +9 -9
  129. package/dist-lib/lib/core/files/rag/extract/extract.js +7 -7
  130. package/dist-lib/lib/core/files/rag/extract/html-text.js +1 -1
  131. package/dist-lib/lib/core/files/rag/extract/office-collabora.js +2 -2
  132. package/dist-lib/lib/core/files/rag/extract/pdf-platform.js +1 -1
  133. package/dist-lib/lib/core/files/rag/extract/pdf-text.js +1 -1
  134. package/dist-lib/lib/core/files/rag/extract/text-decoding.js +1 -1
  135. package/dist-lib/lib/core/files/rag/extract/types.d.ts +2 -2
  136. package/dist-lib/lib/core/files/rag/index.js +22 -22
  137. package/dist-lib/lib/core/files/rag/load.js +5 -5
  138. package/dist-lib/lib/core/files/rag/policy.js +2 -2
  139. package/dist-lib/lib/core/files/rag/produce.js +5 -5
  140. package/dist-lib/lib/core/files/rag/retrieval/coverage.js +2 -2
  141. package/dist-lib/lib/core/files/rag/retrieval/diversity.js +1 -1
  142. package/dist-lib/lib/core/files/rag/retrieval/floor.js +2 -2
  143. package/dist-lib/lib/core/files/rag/retrieval/format.js +1 -1
  144. package/dist-lib/lib/core/files/rag/retrieval/full-text.js +18 -11
  145. package/dist-lib/lib/core/files/rag/retrieval/knowledge.js +5 -5
  146. package/dist-lib/lib/core/files/rag/retrieval/scoring.js +2 -2
  147. package/dist-lib/lib/core/files/rag/retrieval/search.js +4 -4
  148. package/dist-lib/lib/core/files/rag/retrieval/selection.js +2 -2
  149. package/dist-lib/lib/core/files/rag/retrieval/sources.js +2 -2
  150. package/dist-lib/lib/core/files/rag/retrieval/terms.js +1 -1
  151. package/dist-lib/lib/core/files/rag/retrieval/web-sources.js +1 -1
  152. package/dist-lib/lib/core/files/records/chunks.js +1 -1
  153. package/dist-lib/lib/core/files/records/index.js +8 -8
  154. package/dist-lib/lib/core/files/records/knowledge.js +2 -2
  155. package/dist-lib/lib/core/files/records/output.js +1 -1
  156. package/dist-lib/lib/core/files/records/reclaim.js +5 -5
  157. package/dist-lib/lib/core/files/records/routing.js +7 -7
  158. package/dist-lib/lib/core/files/store/blob.js +2 -2
  159. package/dist-lib/lib/core/files/store/index.js +7 -7
  160. package/dist-lib/lib/core/files/store/reference.js +2 -2
  161. package/dist-lib/lib/core/files/store/server.js +1 -1
  162. package/dist-lib/lib/core/files/store/sweep.js +1 -1
  163. package/dist-lib/lib/core/files/upload-input.js +2 -2
  164. package/dist-lib/lib/core/files/upload.d.ts +1 -1
  165. package/dist-lib/lib/core/files/upload.js +6 -6
  166. package/dist-lib/lib/core/harness-loan.d.ts +29 -0
  167. package/dist-lib/lib/core/harness-loan.js +187 -0
  168. package/dist-lib/lib/core/helpers/index.d.ts +2 -1
  169. package/dist-lib/lib/core/helpers/index.js +4 -4
  170. package/dist-lib/lib/core/hosted-agents.js +2 -2
  171. package/dist-lib/lib/core/identity.d.ts +2 -0
  172. package/dist-lib/lib/core/identity.js +4 -2
  173. package/dist-lib/lib/core/invite.d.ts +1 -0
  174. package/dist-lib/lib/core/invite.js +4 -2
  175. package/dist-lib/lib/core/local/index.d.ts +12 -3
  176. package/dist-lib/lib/core/local/index.js +81 -16
  177. package/dist-lib/lib/core/membership.d.ts +3 -0
  178. package/dist-lib/lib/core/membership.js +15 -1
  179. package/dist-lib/lib/core/mesh-seed-handoff.js +1 -1
  180. package/dist-lib/lib/core/mesh.d.ts +9 -3
  181. package/dist-lib/lib/core/mesh.js +41 -26
  182. package/dist-lib/lib/core/migrations/agent-catalog.js +1 -1
  183. package/dist-lib/lib/core/migrations/index.js +5 -3
  184. package/dist-lib/lib/core/migrations/membership.js +2 -2
  185. package/dist-lib/lib/core/migrations/seal.d.ts +3 -0
  186. package/dist-lib/lib/core/migrations/seal.js +30 -0
  187. package/dist-lib/lib/core/next-frame.js +1 -1
  188. package/dist-lib/lib/core/notification.js +1 -1
  189. package/dist-lib/lib/core/ota-config.js +1 -1
  190. package/dist-lib/lib/core/secret-handoff.js +1 -1
  191. package/dist-lib/lib/core/send.js +3 -3
  192. package/dist-lib/lib/core/skill-overlay-handoff.js +1 -1
  193. package/dist-lib/lib/core/skill-overlay-receiver.js +2 -2
  194. package/dist-lib/lib/core/skill-secrets.js +3 -3
  195. package/dist-lib/lib/core/sync/devices.js +1 -1
  196. package/dist-lib/lib/core/sync/index.js +8 -5
  197. package/dist-lib/lib/core/sync-status.js +1 -1
  198. package/dist-lib/lib/core/system-info.js +1 -1
  199. package/dist-lib/lib/core/tool-activity.js +2 -2
  200. package/dist-lib/lib/core/tool-configs.js +2 -2
  201. package/dist-lib/lib/core.d.ts +42 -3
  202. package/dist-lib/lib/core.js +543 -100
  203. package/dist-lib/lib/credential-pusher.js +4 -4
  204. package/dist-lib/lib/deadline.js +1 -1
  205. package/dist-lib/lib/fs-drive-bridge.js +5 -3
  206. package/dist-lib/lib/integrations/index.js +3 -3
  207. package/dist-lib/lib/integrations/oauth-providers.js +1 -1
  208. package/dist-lib/lib/integrations/setup-routes.d.ts +5 -5
  209. package/dist-lib/lib/integrations/setup-routes.js +3 -3
  210. package/dist-lib/lib/knowledge-search.js +1 -1
  211. package/dist-lib/lib/log.js +3 -3
  212. package/dist-lib/lib/mesh-scoped-engine.d.ts +3 -0
  213. package/dist-lib/lib/mesh-scoped-engine.js +101 -0
  214. package/dist-lib/lib/model-context.d.ts +2 -2
  215. package/dist-lib/lib/model-context.js +1 -1
  216. package/dist-lib/lib/model-download.d.ts +2 -0
  217. package/dist-lib/lib/model-download.js +26 -11
  218. package/dist-lib/lib/oauth/asana.js +3 -3
  219. package/dist-lib/lib/oauth/browser-connect.js +1 -1
  220. package/dist-lib/lib/oauth/client.js +2 -2
  221. package/dist-lib/lib/oauth/common.d.ts +1 -1
  222. package/dist-lib/lib/oauth/common.js +1 -1
  223. package/dist-lib/lib/oauth/flow-core.js +3 -3
  224. package/dist-lib/lib/oauth/flow.js +2 -2
  225. package/dist-lib/lib/oauth/google.js +4 -4
  226. package/dist-lib/lib/oauth/host.js +3 -3
  227. package/dist-lib/lib/oauth/keys.js +1 -0
  228. package/dist-lib/lib/oauth/loopback.js +1 -1
  229. package/dist-lib/lib/oauth/notion.js +3 -3
  230. package/dist-lib/lib/oauth/providers.js +1 -1
  231. package/dist-lib/lib/oauth/resolve.js +1 -1
  232. package/dist-lib/lib/oauth/spotify.js +4 -3
  233. package/dist-lib/lib/oauth/token-exchange.js +1 -1
  234. package/dist-lib/lib/oauth/verify.d.ts +8 -0
  235. package/dist-lib/lib/oauth/verify.js +58 -0
  236. package/dist-lib/lib/oauth.client.js +2 -2
  237. package/dist-lib/lib/oauth.d.ts +1 -0
  238. package/dist-lib/lib/oauth.js +13 -12
  239. package/dist-lib/lib/run-notices.d.ts +7 -7
  240. package/dist-lib/lib/run-transcript.js +1 -1
  241. package/dist-lib/schema/build.js +12 -6
  242. package/dist-lib/schema/content.d.ts +11 -11
  243. package/dist-lib/schema/engine.js +193 -30
  244. package/dist-lib/schema/field-order.js +2 -2
  245. package/dist-lib/schema/local.js +18 -4
  246. package/dist-lib/schema/qvac.d.ts +3 -0
  247. package/dist-lib/schema/qvac.js +22 -6
  248. package/dist-lib/spec/bind.js +41 -0
  249. package/dist-lib/spec/calls.js +12 -0
  250. package/dist-lib/spec/capabilities.d.ts +36 -12
  251. package/dist-lib/spec/hrpc/hrpc.json +161 -5
  252. package/dist-lib/spec/hrpc/index.js +154 -9
  253. package/dist-lib/spec/hrpc/messages.js +549 -129
  254. package/dist-lib/spec/hyperschema/index.js +549 -129
  255. package/dist-lib/spec/hyperschema/schema.json +370 -40
  256. package/dist-lib/spec/hyperschema/types.d.ts +85 -1
  257. package/dist-lib/spec/local/hyperdb/db.json +15 -0
  258. package/dist-lib/spec/local/hyperdb/index.js +70 -1
  259. package/dist-lib/spec/local/hyperdb/messages.js +300 -117
  260. package/dist-lib/spec/local/hyperschema/index.js +97 -4
  261. package/dist-lib/spec/local/hyperschema/schema.json +58 -1
  262. package/dist-lib/spec/local/hyperschema/types.d.ts +14 -0
  263. package/dist-lib/spec/mesh/hyperdb/messages.js +393 -288
  264. package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +6 -0
  265. package/dist-lib/spec/mesh/hyperdispatch/index.js +18 -1
  266. package/dist-lib/spec/mesh/hyperdispatch/messages.js +176 -85
  267. package/dist-lib/spec/mesh/hyperschema/index.js +176 -85
  268. package/dist-lib/spec/mesh/hyperschema/schema.json +71 -21
  269. package/dist-lib/spec/mesh/hyperschema/types.d.ts +14 -1
  270. package/package.json +14 -8
  271. package/tui/README.md +7 -0
  272. package/tui/app.mjs +633 -55
  273. package/tui/lib/busy-words.mjs +57 -5
  274. package/tui/lib/export.mjs +1 -0
  275. package/tui/lib/render.mjs +25 -2
  276. package/tui/lib/selection.mjs +16 -0
  277. package/tui/lib/usage.mjs +54 -0
  278. package/tui/main.mjs +5 -2
package/CLAUDE.md CHANGED
@@ -10,9 +10,7 @@ A P2P, multi-device AI workbench core. Three pieces, one duplex stream:
10
10
  through the Client's capability surface, like any other client. **The only
11
11
  place inference happens.**
12
12
 
13
- The library runs on both Bare and Node, and both test lanes are real — anything
14
- that works on only one is a bug. `tui/` is the exception: it imports `bare-tui`
15
- directly and is Bare-only.
13
+ The library runs on both Bare and Node; the test suite runs under Bare only.
16
14
 
17
15
  ## Durable invariants
18
16
 
@@ -33,10 +31,15 @@ directly and is Bare-only.
33
31
 
34
32
  ## Always
35
33
 
36
- - **Comment only what the code cannot say.** Why, not what. One or two lines,
37
- never more. Most code needs none — do not narrate it.
34
+ - **Comment only what the code cannot say.** Why, not what. One line, never two.
35
+ Most code needs none — do not narrate it. If one line cannot carry it, the code
36
+ needs reshaping, not a longer comment.
38
37
  - **Commits read as if a human wrote them.** No `Co-Authored-By` trailer and no
39
38
  AI or agent attribution, in a commit message or a PR.
39
+ - **Route behaviour is in `docs/api/`**, one file per api module, each with a
40
+ changelog. Read the one for a route before changing it, and add to its
41
+ changelog when you do. A module without a file yet gets one when a change
42
+ needs it.
40
43
  - **Durable decisions are in `docs/decisions/`.** Read `INDEX.md` when touching an
41
44
  area it lists, and open a record only on a path or keyword match — they are
42
45
  reference, not rules. Add one when a change makes a non-obvious lasting choice.
package/README.md CHANGED
@@ -60,7 +60,9 @@ duck --help
60
60
  The library is the three pieces above — start at
61
61
  [Integrating a harness](#integrating-a-harness). `duck` is the fastest way to
62
62
  watch them work, and what the examples here drive; it has its own section at
63
- [The duck TUI](#the-duck-tui).
63
+ [The duck TUI](#the-duck-tui). Runnable examples live in
64
+ [`examples/`](./examples/README.md); `bun run mesh-two-people` is the shortest
65
+ one, and shows what a device invite does that a member invite does not.
64
66
 
65
67
  ## Integrating a harness
66
68
 
@@ -1 +1 @@
1
- export { Client } from "./lib/client.js";
1
+ export { Client } from './lib/client.js';
package/dist-lib/index.js CHANGED
@@ -1,10 +1,10 @@
1
- export { setLogger } from "./lib/logger.js";
2
- export { Core } from "./lib/core.js";
3
- export { Client } from "./lib/client.js";
4
- export { AssistantClient } from "./lib/assistant-client.js";
5
- export { harnessDeleteModel, harnessListModels, harnessSkillCatalog, harnessTools, QvacAssistant } from "./lib/assistant.js";
6
- export { assistantChild, assistantTree } from "./lib/assistant-tree.js";
7
- export { ASSISTANT_WAKEUP_LINGER_MS, createAssistantSuspendLifecycle } from "./lib/suspend-lifecycle.js";
1
+ export { setLogger } from './lib/logger.js';
2
+ export { Core } from './lib/core.js';
3
+ export { Client } from './lib/client.js';
4
+ export { AssistantClient } from './lib/assistant-client.js';
5
+ export { harnessDeleteModel, harnessListModels, harnessSkillCatalog, harnessTools, QvacAssistant } from './lib/assistant.js';
6
+ export { assistantChild, assistantTree } from './lib/assistant-tree.js';
7
+ export { ASSISTANT_WAKEUP_LINGER_MS, createAssistantSuspendLifecycle } from './lib/suspend-lifecycle.js';
8
8
  export { default as Supervisor } from 'bare-supervisor';
9
9
  export { clientSessions, duplexPair } from '@qvac/harness/transport';
10
- export { groupAttachmentsByMessage, replyMessageId, REPLY_MESSAGE_PREFIX } from "./lib/core/files/records/linkage.js";
10
+ export { groupAttachmentsByMessage, replyMessageId, REPLY_MESSAGE_PREFIX } from './lib/core/files/records/linkage.js';
@@ -1,5 +1,5 @@
1
1
  import { type CurrentMesh } from './current-mesh.ts';
2
2
  import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
3
3
  type AgentCapabilities = Pick<CapabilityHandlers, 'createAgent' | 'listAgents' | 'getAgent' | 'updateAgent' | 'deleteAgent' | 'agentsWatch'>;
4
- export declare function createAgentsApi(current: CurrentMesh, deviceId: Buffer | null): AgentCapabilities;
4
+ export declare function createAgentsApi(current: CurrentMesh, deviceId: Buffer | null, computeLender?: (() => Promise<Buffer | null>) | null): AgentCapabilities;
5
5
  export {};
@@ -1,7 +1,6 @@
1
- import { createAgent, deleteAgent, isOrphaned, listAgents, liveProviderIds, mustGetActiveAgent, updateAgent } from "../core/agent.js";
2
- import { requireMesh } from "./current-mesh.js";
3
- import { watchable } from "./watchable.js";
4
- export function createAgentsApi(current, deviceId) {
1
+ import { createAgent, deleteAgent, isOrphaned, listAgents, liveProviderIds, mustGetActiveAgent, updateAgent } from '../core/agent.js';
2
+ import { meshWatchable, requireMesh } from './current-mesh.js';
3
+ export function createAgentsApi(current, deviceId, computeLender = null) {
5
4
  const withOrphaned = async (mesh, agent) => ({
6
5
  ...agent,
7
6
  orphaned: await isOrphaned(mesh, agent)
@@ -18,21 +17,22 @@ export function createAgentsApi(current, deviceId) {
18
17
  return {
19
18
  createAgent: async (input) => {
20
19
  const mesh = await requireMesh(current, input.meshId);
21
- return withOrphaned(mesh, await createAgent(mesh, input));
20
+ const lenderDeviceId = input.lenderDeviceId ?? (await computeLender?.()) ?? undefined;
21
+ return withOrphaned(mesh, await createAgent(mesh, { ...input, lenderDeviceId }));
22
22
  },
23
23
  listAgents: async (request) => list(await requireMesh(current, request?.meshId)),
24
- getAgent: async ({ id }) => {
25
- const mesh = await requireMesh(current);
24
+ getAgent: async ({ id, meshId }) => {
25
+ const mesh = await requireMesh(current, meshId);
26
26
  return withOrphaned(mesh, await mustGetActiveAgent(mesh, id));
27
27
  },
28
28
  updateAgent: async (input) => {
29
29
  const mesh = await requireMesh(current);
30
30
  return withOrphaned(mesh, await updateAgent(mesh, input));
31
31
  },
32
- deleteAgent: async ({ id }) => {
33
- const mesh = await requireMesh(current);
32
+ deleteAgent: async ({ id, meshId }) => {
33
+ const mesh = await requireMesh(current, meshId);
34
34
  return withOrphaned(mesh, await deleteAgent(mesh, deviceId, id));
35
35
  },
36
- agentsWatch: watchable('agentsWatch', (request) => requireMesh(current, request?.meshId), (_request, mesh) => list(mesh))
36
+ agentsWatch: meshWatchable('agentsWatch', current, (_request, mesh) => list(mesh))
37
37
  };
38
38
  }
@@ -1,4 +1,4 @@
1
- import { watchable } from "./watchable.js";
1
+ import { watchable } from './watchable.js';
2
2
  const EMPTY_CAPABILITIES = {
3
3
  chat: false,
4
4
  transcription: false,
@@ -1,9 +1,13 @@
1
- import { listApprovalRules } from "../core/approval-rules.js";
2
- import { requireMesh } from "./current-mesh.js";
1
+ import { listApprovalRules } from '../core/approval-rules.js';
2
+ import { requireMesh } from './current-mesh.js';
3
3
  export function createApprovalRulesApi(current) {
4
4
  return {
5
- listApprovalRules: async () => ({
6
- rules: await listApprovalRules(await requireMesh(current))
7
- })
5
+ listApprovalRules: async (request) => {
6
+ const mesh = await requireMesh(current, request?.meshId);
7
+ return {
8
+ rules: await listApprovalRules(mesh),
9
+ ourMemberId: mesh.ourMemberId ?? undefined
10
+ };
11
+ }
8
12
  };
9
13
  }
@@ -1,9 +1,31 @@
1
- import { requireMesh } from "./current-mesh.js";
2
- export { MAX_ATTACHMENT_BYTES } from "../core/files/attachments.js";
1
+ import { toAsyncIterable } from '../core/async-iterable.js';
2
+ import { requireMesh } from './current-mesh.js';
3
+ function rejoin(frames, first, rest) {
4
+ const replayed = (async function* () {
5
+ yield first;
6
+ while (true) {
7
+ const next = await rest.next();
8
+ if (next.done)
9
+ return;
10
+ yield next.value;
11
+ }
12
+ })();
13
+ return 'writeStream' in frames
14
+ ? Object.assign(replayed, { writeStream: frames.writeStream })
15
+ : replayed;
16
+ }
17
+ export { MAX_ATTACHMENT_BYTES } from '../core/files/attachments.js';
3
18
  export function createAttachmentsApi(current, options = {}) {
4
19
  return {
5
20
  async *uploadAttachment(frames) {
6
- yield* (await requireMesh(current)).files.attachments(options).uploadAttachment(frames);
21
+ const rest = toAsyncIterable(frames)[Symbol.asyncIterator]();
22
+ const first = await rest.next();
23
+ if (first.done)
24
+ return;
25
+ const mesh = await requireMesh(current, first.value.meshId);
26
+ yield* mesh.files
27
+ .attachments(options)
28
+ .uploadAttachment(rejoin(frames, first.value, rest));
7
29
  },
8
30
  async *downloadAttachment(request) {
9
31
  yield* (await requireMesh(current)).files.attachments(options).downloadAttachment(request);
@@ -1,5 +1,5 @@
1
1
  import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
2
2
  import { type CurrentMesh } from './current-mesh.ts';
3
- type ChatGroupCapabilities = Pick<CapabilityHandlers, 'createChatGroup' | 'listChatGroups' | 'renameChatGroup' | 'deleteChatGroup' | 'setChatGroup' | 'moveChat' | 'moveChatGroup'>;
3
+ type ChatGroupCapabilities = Pick<CapabilityHandlers, 'createChatGroup' | 'listChatGroups' | 'renameChatGroup' | 'deleteChatGroup' | 'setChatGroup' | 'moveChat' | 'moveChatGroup' | 'sortChatGroupsByName'>;
4
4
  export declare function createChatGroupsApi(current: CurrentMesh): ChatGroupCapabilities;
5
5
  export {};
@@ -1,6 +1,6 @@
1
- import { createChatGroup, deleteChatGroup, listChatGroups, moveChatGroup, renameChatGroup } from "../core/chat-group.js";
2
- import { moveChat, setChatGroup } from "../core/chat.js";
3
- import { requireMesh } from "./current-mesh.js";
1
+ import { createChatGroup, deleteChatGroup, listChatGroups, moveChatGroup, renameChatGroup, sortChatGroupsByName } from '../core/chat-group.js';
2
+ import { moveChat, setChatGroup } from '../core/chat.js';
3
+ import { requireMesh } from './current-mesh.js';
4
4
  export function createChatGroupsApi(current) {
5
5
  return {
6
6
  createChatGroup: async ({ name }) => createChatGroup(await requireMesh(current), { name }),
@@ -9,6 +9,7 @@ export function createChatGroupsApi(current) {
9
9
  deleteChatGroup: async ({ id }) => deleteChatGroup(await requireMesh(current), id),
10
10
  setChatGroup: async ({ id, groupId }) => setChatGroup(await requireMesh(current), id, groupId),
11
11
  moveChat: async ({ id, groupId, afterId }) => moveChat(await requireMesh(current), id, { groupId, afterId }),
12
- moveChatGroup: async ({ id, afterId }) => moveChatGroup(await requireMesh(current), id, { afterId })
12
+ moveChatGroup: async ({ id, afterId }) => moveChatGroup(await requireMesh(current), id, { afterId }),
13
+ sortChatGroupsByName: async () => sortChatGroupsByName(await requireMesh(current)).then((groups) => ({ groups }))
13
14
  };
14
15
  }
@@ -1,9 +1,9 @@
1
1
  import { AbortController } from 'bare-abort-controller';
2
- import { createChat, deleteChat, listSidebar, mustGetActiveChatListing, renameChat, setChatRagEnabled, setChatWebSearchEnabled } from "../core/chat.js";
3
- import { listChatActivity } from "../core/chat-activity.js";
4
- import { searchChats } from "../core/chat-search.js";
5
- import { requireMesh } from "./current-mesh.js";
6
- import { watchable } from "./watchable.js";
2
+ import { createChat, deleteChat, listSidebar, mustGetActiveChatListing, renameChat, setChatRagEnabled, setChatWebSearchEnabled } from '../core/chat.js';
3
+ import { listChatActivity } from '../core/chat-activity.js';
4
+ import { searchChats } from '../core/chat-search.js';
5
+ import { meshWatchable, requireMesh, selectionPin } from './current-mesh.js';
6
+ import { watchable } from './watchable.js';
7
7
  const SEARCH_SUPERSEDED_ABORT = 'superseded by a newer chat search';
8
8
  export function createChatApi(current, deviceId) {
9
9
  let searchAbort = null;
@@ -12,14 +12,14 @@ export function createChatApi(current, deviceId) {
12
12
  return {
13
13
  createChat: async (input) => createChat(await requireMesh(current), input),
14
14
  listChats: async (request) => chatList(await requireMesh(current, request?.meshId)),
15
- getChat: async ({ id }) => mustGetActiveChatListing(await requireMesh(current), id),
16
- renameChat: async ({ id, title }) => renameChat(await requireMesh(current), id, title),
15
+ getChat: async ({ id, meshId }) => mustGetActiveChatListing(await requireMesh(current, meshId), id),
16
+ renameChat: async ({ id, title, meshId }) => renameChat(await requireMesh(current, meshId), id, title),
17
17
  setChatRagEnabled: async ({ id, enabled }) => setChatRagEnabled(await requireMesh(current), id, enabled ?? false),
18
18
  setChatWebSearchEnabled: async ({ id, enabled }) => setChatWebSearchEnabled(await requireMesh(current), id, enabled ?? false),
19
- deleteChat: async ({ id }) => deleteChat(await requireMesh(current), deviceId, id),
20
- chatsWatch: watchable('chatsWatch', (request) => requireMesh(current, request?.meshId), (_request, store) => chatList(store)),
19
+ deleteChat: async ({ id, meshId }) => deleteChat(await requireMesh(current, meshId), deviceId, id),
20
+ chatsWatch: meshWatchable('chatsWatch', current, (_request, store) => chatList(store)),
21
21
  listChatActivity: async (input) => chatActivity(await requireMesh(current), input?.chatIds),
22
- chatActivityWatch: watchable('chatActivityWatch', () => requireMesh(current), (request, store) => chatActivity(store, request?.chatIds)),
22
+ chatActivityWatch: watchable('chatActivityWatch', () => requireMesh(current), (request, store) => chatActivity(store, request?.chatIds), () => selectionPin(current)),
23
23
  searchChats: async (input) => {
24
24
  searchAbort?.abort(SEARCH_SUPERSEDED_ABORT);
25
25
  const controller = new AbortController();
@@ -1,5 +1,5 @@
1
1
  import { type CurrentMesh } from './current-mesh.ts';
2
2
  import type { CapabilityHandlers } from '../../spec/capabilities.d.ts';
3
3
  type ChunkCapabilities = Pick<CapabilityHandlers, 'appendChunk' | 'updateChunk' | 'resolveApproval' | 'listChunks' | 'listAttachmentsByKind' | 'chunksWatch' | 'runRequestsWatch'>;
4
- export declare function createChunksApi(current: CurrentMesh): ChunkCapabilities;
4
+ export declare function createChunksApi(current: CurrentMesh, deviceId: Buffer | null): ChunkCapabilities;
5
5
  export {};
@@ -1,15 +1,14 @@
1
- import { appendChunk, listAttachmentsByKind, listChunks, resolveApproval, updateChunk } from "../core/chunk.js";
2
- import { requireMesh } from "./current-mesh.js";
3
- import { watchable } from "./watchable.js";
4
- export function createChunksApi(current) {
1
+ import { appendChunk, listAttachmentsByKind, listChunks, listRunRequests, resolveApproval, updateChunk } from '../core/chunk.js';
2
+ import { meshWatchable, requireMesh } from './current-mesh.js';
3
+ export function createChunksApi(current, deviceId) {
5
4
  return {
6
- appendChunk: async (input) => appendChunk(await requireMesh(current), input),
7
- updateChunk: async (input) => {
8
- await updateChunk(await requireMesh(current), input);
5
+ appendChunk: async ({ meshId, ...input }) => appendChunk(await requireMesh(current, meshId), input),
6
+ updateChunk: async ({ meshId, ...input }) => {
7
+ await updateChunk(await requireMesh(current, meshId), input);
9
8
  return { ok: true };
10
9
  },
11
10
  resolveApproval: async (input) => {
12
- await resolveApproval(await requireMesh(current), {
11
+ await resolveApproval(await requireMesh(current, input.meshId), {
13
12
  id: input.id,
14
13
  approved: input.approved === true,
15
14
  scope: input.scope ?? undefined,
@@ -18,8 +17,8 @@ export function createChunksApi(current) {
18
17
  });
19
18
  return { ok: true };
20
19
  },
21
- listChunks: async ({ chatId, type, types, fromSeq, reverse, limit }) => ({
22
- chunks: await listChunks(await requireMesh(current), {
20
+ listChunks: async ({ chatId, type, types, fromSeq, reverse, limit, meshId }) => ({
21
+ chunks: await listChunks(await requireMesh(current, meshId), {
23
22
  chatId,
24
23
  type: type ?? undefined,
25
24
  types: types ?? undefined,
@@ -37,7 +36,7 @@ export function createChunksApi(current) {
37
36
  limit: limit || undefined
38
37
  })
39
38
  }),
40
- chunksWatch: watchable('chunksWatch', () => requireMesh(current), async ({ chatId, type, types, fromSeq, reverse, limit }, mesh) => ({
39
+ chunksWatch: meshWatchable('chunksWatch', current, async ({ chatId, type, types, fromSeq, reverse, limit }, mesh) => ({
41
40
  chunks: await listChunks(mesh, {
42
41
  chatId,
43
42
  type: type ?? undefined,
@@ -47,15 +46,6 @@ export function createChunksApi(current) {
47
46
  limit: limit || undefined
48
47
  })
49
48
  })),
50
- runRequestsWatch: watchable('runRequestsWatch', () => requireMesh(current), async (_request, mesh) => {
51
- const snap = mesh.view.snapshot();
52
- try {
53
- const chunks = await snap.find('@qvac/run-requests').toArray();
54
- return { chunks };
55
- }
56
- finally {
57
- await snap.close();
58
- }
59
- })
49
+ runRequestsWatch: meshWatchable('runRequestsWatch', current, async (_request, mesh) => ({ chunks: await listRunRequests(mesh, deviceId) }))
60
50
  };
61
51
  }
@@ -1,4 +1,4 @@
1
- import { watchable } from "./watchable.js";
1
+ import { watchable } from './watchable.js';
2
2
  export function createConfigApi(state) {
3
3
  return {
4
4
  async configGet({ key }) {
@@ -1,6 +1,21 @@
1
1
  import type { Mesh } from '../core/mesh.ts';
2
- export type CurrentMesh = (meshId?: string | null) => Mesh | null | Promise<Mesh | null>;
2
+ import { type WatchPin } from './watchable.ts';
3
+ export interface CurrentMesh {
4
+ (meshId?: string | null): Mesh | null | Promise<Mesh | null>;
5
+ readonly selection?: MeshSelection;
6
+ }
7
+ export interface MeshSelection {
8
+ key(): string | null;
9
+ watch(listener: () => void): void;
10
+ unwatch(listener: () => void): void;
11
+ }
3
12
  export declare const NO_ACTIVE_MESH = "no active mesh";
4
13
  export declare const NO_SUCH_MESH = "no such mesh";
5
14
  export declare function requireMesh(current: CurrentMesh, meshId?: string | null): Promise<Mesh>;
6
15
  export declare function isMeshTransition(err: unknown): boolean;
16
+ export declare function meshWatchable<TRequest extends MeshScoped | undefined, TResult>(name: string, current: CurrentMesh, query: (request: TRequest, mesh: Mesh) => Promise<TResult>): (request: TRequest) => import("streamx").Readable<import("streamx").ReadableEvents> & AsyncIterable<TResult>;
17
+ export declare function selectionPin(current: CurrentMesh, meshId?: string | null): WatchPin | null;
18
+ interface MeshScoped {
19
+ readonly meshId?: string | null;
20
+ }
21
+ export {};
@@ -1,3 +1,4 @@
1
+ import { watchable } from './watchable.js';
1
2
  export const NO_ACTIVE_MESH = 'no active mesh';
2
3
  export const NO_SUCH_MESH = 'no such mesh';
3
4
  export async function requireMesh(current, meshId) {
@@ -11,3 +12,20 @@ export async function requireMesh(current, meshId) {
11
12
  export function isMeshTransition(err) {
12
13
  return err instanceof Error && err.message === NO_ACTIVE_MESH;
13
14
  }
15
+ export function meshWatchable(name, current, query) {
16
+ return watchable(name, (request) => requireMesh(current, request?.meshId), query, (request) => selectionPin(current, request?.meshId));
17
+ }
18
+ export function selectionPin(current, meshId) {
19
+ const selection = current.selection;
20
+ if (meshId || !selection)
21
+ return null;
22
+ const opened = selection.key();
23
+ return {
24
+ stale: () => {
25
+ const now = selection.key();
26
+ return now !== null && now !== opened;
27
+ },
28
+ watch: (listener) => selection.watch(listener),
29
+ unwatch: (listener) => selection.unwatch(listener)
30
+ };
31
+ }
@@ -1,5 +1,5 @@
1
- import { watchable } from "./watchable.js";
2
- import { normalizeModelSource, probeModelSource } from "../custom-model-source.js";
1
+ import { watchable } from './watchable.js';
2
+ import { normalizeModelSource, probeModelSource } from '../custom-model-source.js';
3
3
  async function readCustomModels(state) {
4
4
  const rows = await state.getCustomModelRows();
5
5
  return {
@@ -5,4 +5,4 @@ export declare function createDevicesApi(current: CurrentMesh, deviceId: Buffer,
5
5
  capabilityProfile: AssistantCapabilityProfile;
6
6
  recommendedModelName: string;
7
7
  platform?: string;
8
- } | null): Pick<CapabilityHandlers, 'listDevices' | 'devicesWatch' | 'deviceInfo' | 'saveDeviceCapabilities' | 'saveDeviceProfile' | 'removeDevice' | 'renameDevice'>;
8
+ } | null, computeLender?: (() => Promise<Buffer | null>) | null): Pick<CapabilityHandlers, 'listDevices' | 'devicesWatch' | 'deviceInfo' | 'saveDeviceCapabilities' | 'saveDeviceProfile' | 'removeDevice' | 'renameDevice'>;
@@ -1,6 +1,6 @@
1
- import { saveDeviceCapabilities } from "../core/devices.js";
2
- import { requireMesh } from "./current-mesh.js";
3
- import { watchable } from "./watchable.js";
1
+ import { MAX_DEVICE_NAME_CHARS, deviceNameWithinBounds } from '../../schema/qvac.js';
2
+ import { saveDeviceCapabilities } from '../core/devices.js';
3
+ import { meshWatchable, requireMesh } from './current-mesh.js';
4
4
  const DEVICES = '@qvac/devices';
5
5
  function toEngineDevice(device, overrides = {}) {
6
6
  return {
@@ -24,7 +24,7 @@ function toEngineDevice(device, overrides = {}) {
24
24
  ...overrides
25
25
  };
26
26
  }
27
- export function createDevicesApi(current, deviceId, removeWriter, renameLocal, saveProfileLocal, readLocalProfile) {
27
+ export function createDevicesApi(current, deviceId, removeWriter, renameLocal, saveProfileLocal, readLocalProfile, computeLender = null) {
28
28
  const mustGetDevice = async (mesh, id) => {
29
29
  const snap = mesh.view.snapshot();
30
30
  try {
@@ -37,8 +37,7 @@ export function createDevicesApi(current, deviceId, removeWriter, renameLocal, s
37
37
  await snap.close();
38
38
  }
39
39
  };
40
- const list = async () => {
41
- const mesh = await requireMesh(current);
40
+ const list = async (mesh) => {
42
41
  const snap = mesh.view.snapshot();
43
42
  try {
44
43
  const devices = await snap.find(DEVICES).toArray();
@@ -49,11 +48,12 @@ export function createDevicesApi(current, deviceId, removeWriter, renameLocal, s
49
48
  }
50
49
  };
51
50
  return {
52
- listDevices: list,
53
- devicesWatch: watchable('devicesWatch', () => requireMesh(current), list),
51
+ listDevices: async (request) => list(await requireMesh(current, request?.meshId)),
52
+ devicesWatch: meshWatchable('devicesWatch', current, (_request, mesh) => list(mesh)),
54
53
  deviceInfo: async () => {
55
54
  logger.info(['api', 'devices'], 'deviceInfo handler reached');
56
- return { id: deviceId, supportsKvCacheDeletion: true };
55
+ const computeLenderId = (await computeLender?.()) ?? undefined;
56
+ return { id: deviceId, supportsKvCacheDeletion: true, computeLenderId };
57
57
  },
58
58
  saveDeviceCapabilities: async (input) => {
59
59
  await saveDeviceCapabilities(await requireMesh(current), {
@@ -85,6 +85,9 @@ export function createDevicesApi(current, deviceId, removeWriter, renameLocal, s
85
85
  const trimmed = name.trim();
86
86
  if (!trimmed)
87
87
  throw new Error('device name must not be empty');
88
+ if (!deviceNameWithinBounds(trimmed)) {
89
+ throw new Error(`device name must be at most ${MAX_DEVICE_NAME_CHARS} characters`);
90
+ }
88
91
  const mesh = await requireMesh(current);
89
92
  const device = await mustGetDevice(mesh, id);
90
93
  await renameLocal(trimmed);
@@ -1,4 +1,4 @@
1
- import { watchable } from "./watchable.js";
1
+ import { watchable } from './watchable.js';
2
2
  export function createDiagnosticsApi(source) {
3
3
  return {
4
4
  diagnostics: async () => ({ stats: source.snapshot() }),
@@ -1,4 +1,4 @@
1
- import { defaultContextForModel, MOBILE_CONTEXT_SIZE, MODEL_CONTEXT_TARGET, modelContextTargetForPlatform } from "../model-context.js";
1
+ import { defaultContextForModel, MOBILE_CONTEXT_SIZE, MODEL_CONTEXT_TARGET, modelContextTargetForPlatform } from '../model-context.js';
2
2
  export function effectiveCtxSize(agent, appCtxSize, platform) {
3
3
  const configured = agent?.ctxSize || appCtxSize;
4
4
  if (configured)
@@ -1,7 +1,7 @@
1
- import { appendChunk, listChunks } from "../core/chunk.js";
2
- import { randomId } from "../core/id.js";
3
- import { parentRequestId, sendMessage } from "../core/send.js";
4
- import { requireMesh } from "./current-mesh.js";
1
+ import { appendChunk, listChunks } from '../core/chunk.js';
2
+ import { randomId } from '../core/id.js';
3
+ import { parentRequestId, sendMessage } from '../core/send.js';
4
+ import { requireMesh } from './current-mesh.js';
5
5
  const TERMINAL_STATES = new Set(['completed', 'failed', 'canceled']);
6
6
  export function createExecutionApi(current, deviceId) {
7
7
  return {
@@ -1,6 +1,6 @@
1
1
  import { AbortController } from 'bare-abort-controller';
2
2
  import { Readable } from 'streamx';
3
- import { requireMesh } from "./current-mesh.js";
3
+ import { requireMesh } from './current-mesh.js';
4
4
  export function createFilesApi(current) {
5
5
  return {
6
6
  async filePreview(request) {
@@ -13,7 +13,7 @@ export function createFilesApi(current) {
13
13
  fileRead(request) {
14
14
  const abort = new AbortController();
15
15
  async function* read() {
16
- const mesh = await requireMesh(current);
16
+ const mesh = await requireMesh(current, request.meshId);
17
17
  const close = () => stream.destroy();
18
18
  mesh.files.once('close', close);
19
19
  try {
@@ -44,6 +44,7 @@ interface ApiDeps {
44
44
  ragIndex?: (() => VectorIndex | null) | null;
45
45
  ragEmbed?: (() => IndexingEmbedder | null) | null;
46
46
  platform?: (() => string | null) | null;
47
+ computeLender?: (() => Promise<Buffer | null>) | null;
47
48
  pushSkillSecret?: ((request: AssistantPushSkillSecretRequest) => Promise<void>) | null;
48
49
  skills?: ((agentId?: string | null, modelName?: string | null, options?: {
49
50
  readonly refresh?: boolean;
@@ -1,33 +1,33 @@
1
- import { toAsyncIterable } from "../core/async-iterable.js";
2
- import { normalizeImageForModel } from "../core/image/normalize.js";
3
- import { detectImageMime } from "../core/image/sniff.js";
4
- import { createAgentsApi } from "./agents.js";
5
- import { createApprovalRulesApi } from "./approval-rules.js";
6
- import { createAttachmentsApi } from "./attachments.js";
7
- import { createChatApi } from "./chat.js";
8
- import { createChatGroupsApi } from "./chat-groups.js";
9
- import { createChunksApi } from "./chunks.js";
10
- import { createAppConfigApi } from "./app-config.js";
11
- import { createConfigApi } from "./config.js";
12
- import { createDevicesApi } from "./devices.js";
13
- import { createDiagnosticsApi } from "./diagnostics.js";
14
- import { createExecutionApi } from "./execution.js";
15
- import { createKnowledgeApi } from "./knowledge.js";
16
- import { createFilesApi } from "./files.js";
17
- import { createLogsApi } from "./logs.js";
18
- import { instrument } from "./instrument.js";
19
- import { watchable } from "./watchable.js";
20
- import { createMembersApi } from "./members.js";
21
- import { createMeshApi } from "./mesh.js";
22
- import { createNetworkApi } from "./network.js";
23
- import { createNotificationsApi } from "./notifications.js";
24
- import { createModelDownloadApi } from "./model-download.js";
25
- import { createCustomModelApi } from "./custom-models.js";
26
- import { createRagApi } from "./rag.js";
27
- import { createSyncApi } from "./sync.js";
28
- import { createToolActivityApi } from "./tool-activity.js";
29
- import { createToolConfigsApi } from "./tool-configs.js";
30
- import { effectiveCtxSize } from "./effective-ctx-size.js";
1
+ import { toAsyncIterable } from '../core/async-iterable.js';
2
+ import { normalizeImageForModel } from '../core/image/normalize.js';
3
+ import { detectImageMime } from '../core/image/sniff.js';
4
+ import { createAgentsApi } from './agents.js';
5
+ import { createApprovalRulesApi } from './approval-rules.js';
6
+ import { createAttachmentsApi } from './attachments.js';
7
+ import { createChatApi } from './chat.js';
8
+ import { createChatGroupsApi } from './chat-groups.js';
9
+ import { createChunksApi } from './chunks.js';
10
+ import { createAppConfigApi } from './app-config.js';
11
+ import { createConfigApi } from './config.js';
12
+ import { createDevicesApi } from './devices.js';
13
+ import { createDiagnosticsApi } from './diagnostics.js';
14
+ import { createExecutionApi } from './execution.js';
15
+ import { createKnowledgeApi } from './knowledge.js';
16
+ import { createFilesApi } from './files.js';
17
+ import { createLogsApi } from './logs.js';
18
+ import { instrument } from './instrument.js';
19
+ import { watchable } from './watchable.js';
20
+ import { createMembersApi } from './members.js';
21
+ import { createMeshApi } from './mesh.js';
22
+ import { createNetworkApi } from './network.js';
23
+ import { createNotificationsApi } from './notifications.js';
24
+ import { createModelDownloadApi } from './model-download.js';
25
+ import { createCustomModelApi } from './custom-models.js';
26
+ import { createRagApi } from './rag.js';
27
+ import { createSyncApi } from './sync.js';
28
+ import { createToolActivityApi } from './tool-activity.js';
29
+ import { createToolConfigsApi } from './tool-configs.js';
30
+ import { effectiveCtxSize } from './effective-ctx-size.js';
31
31
  export function createApi(deps = {}) {
32
32
  const mesh = deps.mesh ?? null;
33
33
  const retryModelDownload = deps.retryModelDownload;
@@ -37,13 +37,13 @@ export function createApi(deps = {}) {
37
37
  ...(state ? createAppConfigApi(state) : null),
38
38
  ...(state ? createModelDownloadApi(state) : null),
39
39
  ...(state ? createCustomModelApi(state) : null),
40
- ...(mesh ? createAgentsApi(mesh, deps.deviceId ?? null) : null),
40
+ ...(mesh ? createAgentsApi(mesh, deps.deviceId ?? null, deps.computeLender ?? null) : null),
41
41
  ...(mesh ? createChatApi(mesh, deps.deviceId ?? null) : null),
42
42
  ...(mesh ? createChatGroupsApi(mesh) : null),
43
43
  ...(mesh ? createApprovalRulesApi(mesh) : null),
44
- ...(mesh ? createChunksApi(mesh) : null),
44
+ ...(mesh ? createChunksApi(mesh, deps.deviceId ?? null) : null),
45
45
  ...(mesh && deps.deviceId && deps.deviceHost
46
- ? createDevicesApi(mesh, deps.deviceId, deps.deviceHost.removeWriter, deps.deviceHost.renameLocal, deps.deviceHost.saveProfileLocal, deps.deviceHost.readLocalProfile)
46
+ ? createDevicesApi(mesh, deps.deviceId, deps.deviceHost.removeWriter, deps.deviceHost.renameLocal, deps.deviceHost.saveProfileLocal, deps.deviceHost.readLocalProfile, deps.computeLender ?? null)
47
47
  : null),
48
48
  ...(mesh ? createAttachmentsApi(mesh, { deviceId: deps.deviceId }) : null),
49
49
  ...(mesh ? createKnowledgeApi(mesh, { deviceId: deps.deviceId }) : null),
@@ -65,7 +65,7 @@ export function createApi(deps = {}) {
65
65
  })
66
66
  : null),
67
67
  ...(deps.meshStatus ? createMeshApi(deps.meshStatus) : null),
68
- ...(mesh ? createMembersApi(mesh) : null),
68
+ ...(mesh ? createMembersApi(mesh, state) : null),
69
69
  ...(deps.network ? createNetworkApi(deps.network) : null),
70
70
  ...(deps.diagnostics ? createDiagnosticsApi(deps.diagnostics) : null),
71
71
  ...(deps.logs ? createLogsApi(deps.logs) : null),
@@ -1,5 +1,5 @@
1
1
  import b4a from 'b4a';
2
- import "../logger.js";
2
+ import '../logger.js';
3
3
  const SCOPE = ['api'];
4
4
  const MAX_STRING = 40;
5
5
  export function instrument(handlers) {