@qvac/core 0.2.1 → 0.2.2

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 (263) hide show
  1. package/.claude/skills/compaction/SKILL.md +9 -4
  2. package/.claude/skills/pr-create/SKILL.md +24 -3
  3. package/.claude/skills/pr-review/SKILL.md +248 -40
  4. package/CLAUDE.md +1 -3
  5. package/README.md +3 -1
  6. package/dist-lib/client.js +1 -1
  7. package/dist-lib/index.js +8 -8
  8. package/dist-lib/lib/api/agents.d.ts +1 -1
  9. package/dist-lib/lib/api/agents.js +10 -9
  10. package/dist-lib/lib/api/app-config.js +1 -1
  11. package/dist-lib/lib/api/approval-rules.js +9 -5
  12. package/dist-lib/lib/api/attachments.js +25 -3
  13. package/dist-lib/lib/api/chat-groups.d.ts +1 -1
  14. package/dist-lib/lib/api/chat-groups.js +5 -4
  15. package/dist-lib/lib/api/chat.js +8 -8
  16. package/dist-lib/lib/api/chunks.js +11 -11
  17. package/dist-lib/lib/api/config.js +1 -1
  18. package/dist-lib/lib/api/custom-models.js +2 -2
  19. package/dist-lib/lib/api/devices.d.ts +1 -1
  20. package/dist-lib/lib/api/devices.js +9 -9
  21. package/dist-lib/lib/api/diagnostics.js +1 -1
  22. package/dist-lib/lib/api/effective-ctx-size.js +1 -1
  23. package/dist-lib/lib/api/execution.js +4 -4
  24. package/dist-lib/lib/api/files.js +2 -2
  25. package/dist-lib/lib/api/index.d.ts +1 -0
  26. package/dist-lib/lib/api/index.js +33 -33
  27. package/dist-lib/lib/api/instrument.js +1 -1
  28. package/dist-lib/lib/api/knowledge.js +4 -4
  29. package/dist-lib/lib/api/logs.js +1 -1
  30. package/dist-lib/lib/api/members.d.ts +4 -1
  31. package/dist-lib/lib/api/members.js +88 -18
  32. package/dist-lib/lib/api/mesh.d.ts +13 -3
  33. package/dist-lib/lib/api/mesh.js +25 -2
  34. package/dist-lib/lib/api/model-download.js +1 -1
  35. package/dist-lib/lib/api/network.js +1 -1
  36. package/dist-lib/lib/api/notifications.js +3 -3
  37. package/dist-lib/lib/api/rag.js +7 -7
  38. package/dist-lib/lib/api/sync.js +1 -1
  39. package/dist-lib/lib/api/tool-activity.js +4 -4
  40. package/dist-lib/lib/api/tool-configs.js +5 -5
  41. package/dist-lib/lib/api/watchable.js +1 -1
  42. package/dist-lib/lib/assistant/fetch-body.d.ts +5 -0
  43. package/dist-lib/lib/assistant/fetch-body.js +36 -0
  44. package/dist-lib/lib/assistant/harness.d.ts +225 -0
  45. package/dist-lib/lib/assistant/harness.js +154 -0
  46. package/dist-lib/lib/assistant/history.d.ts +32 -0
  47. package/dist-lib/lib/assistant/history.js +232 -0
  48. package/dist-lib/lib/assistant/message.d.ts +45 -0
  49. package/dist-lib/lib/assistant/message.js +47 -0
  50. package/dist-lib/lib/assistant/skill-encode.d.ts +21 -0
  51. package/dist-lib/lib/assistant/skill-encode.js +71 -0
  52. package/dist-lib/lib/assistant-client.js +2 -2
  53. package/dist-lib/lib/assistant-tree.js +10 -4
  54. package/dist-lib/lib/assistant.d.ts +25 -285
  55. package/dist-lib/lib/assistant.js +250 -637
  56. package/dist-lib/lib/audio-format.js +2 -2
  57. package/dist-lib/lib/client.js +2 -2
  58. package/dist-lib/lib/collabora/convert.js +1 -1
  59. package/dist-lib/lib/collabora/entry.js +1 -1
  60. package/dist-lib/lib/collabora/worker.js +1 -1
  61. package/dist-lib/lib/compaction.d.ts +1 -2
  62. package/dist-lib/lib/compaction.js +8 -6
  63. package/dist-lib/lib/constants.js +1 -1
  64. package/dist-lib/lib/core/account-recovery.d.ts +19 -0
  65. package/dist-lib/lib/core/account-recovery.js +50 -0
  66. package/dist-lib/lib/core/agent.js +8 -4
  67. package/dist-lib/lib/core/app-build.d.ts +1 -1
  68. package/dist-lib/lib/core/approval-rules.d.ts +1 -0
  69. package/dist-lib/lib/core/approval-rules.js +3 -1
  70. package/dist-lib/lib/core/archived-mesh.d.ts +25 -0
  71. package/dist-lib/lib/core/archived-mesh.js +162 -0
  72. package/dist-lib/lib/core/chat-activity.js +1 -1
  73. package/dist-lib/lib/core/chat-group.d.ts +1 -0
  74. package/dist-lib/lib/core/chat-group.js +24 -4
  75. package/dist-lib/lib/core/chat-search.js +2 -2
  76. package/dist-lib/lib/core/chat.js +5 -5
  77. package/dist-lib/lib/core/chunk.d.ts +1 -1
  78. package/dist-lib/lib/core/chunk.js +4 -4
  79. package/dist-lib/lib/core/contract/agents.js +1 -1
  80. package/dist-lib/lib/core/contract/approval-rules.js +6 -4
  81. package/dist-lib/lib/core/contract/attestations.js +1 -1
  82. package/dist-lib/lib/core/contract/chat-group.js +1 -1
  83. package/dist-lib/lib/core/contract/chat.js +1 -1
  84. package/dist-lib/lib/core/contract/chunks.js +2 -2
  85. package/dist-lib/lib/core/contract/compute.d.ts +11 -0
  86. package/dist-lib/lib/core/contract/compute.js +45 -0
  87. package/dist-lib/lib/core/contract/devices.js +16 -3
  88. package/dist-lib/lib/core/contract/index.d.ts +3 -1
  89. package/dist-lib/lib/core/contract/index.js +19 -16
  90. package/dist-lib/lib/core/contract/indexing.js +2 -2
  91. package/dist-lib/lib/core/contract/joined-meshes.js +1 -1
  92. package/dist-lib/lib/core/contract/knowledge.js +2 -2
  93. package/dist-lib/lib/core/contract/members.js +2 -2
  94. package/dist-lib/lib/core/contract/seal.d.ts +2 -0
  95. package/dist-lib/lib/core/contract/seal.js +8 -0
  96. package/dist-lib/lib/core/contract/seed-defaults.js +1 -1
  97. package/dist-lib/lib/core/contract/tool-activity.js +1 -1
  98. package/dist-lib/lib/core/contract/tool-configs.js +3 -3
  99. package/dist-lib/lib/core/contract/writers.js +66 -42
  100. package/dist-lib/lib/core/departures.js +1 -1
  101. package/dist-lib/lib/core/device-invites.js +1 -1
  102. package/dist-lib/lib/core/document-attachment.js +2 -2
  103. package/dist-lib/lib/core/files/attachments.js +3 -3
  104. package/dist-lib/lib/core/files/index.d.ts +2 -2
  105. package/dist-lib/lib/core/files/index.js +19 -19
  106. package/dist-lib/lib/core/files/knowledge.js +3 -3
  107. package/dist-lib/lib/core/files/preview/image.js +1 -1
  108. package/dist-lib/lib/core/files/preview/index.js +6 -6
  109. package/dist-lib/lib/core/files/processing/claims.js +1 -1
  110. package/dist-lib/lib/core/files/processing/document.js +5 -5
  111. package/dist-lib/lib/core/files/processing/index.js +8 -8
  112. package/dist-lib/lib/core/files/processing/ownership.js +1 -1
  113. package/dist-lib/lib/core/files/processing/protocol.js +3 -3
  114. package/dist-lib/lib/core/files/processing/source.js +1 -1
  115. package/dist-lib/lib/core/files/rag/artifact/codec.js +1 -1
  116. package/dist-lib/lib/core/files/rag/artifact/id.js +1 -1
  117. package/dist-lib/lib/core/files/rag/artifact/types.d.ts +4 -4
  118. package/dist-lib/lib/core/files/rag/build.js +2 -2
  119. package/dist-lib/lib/core/files/rag/chunk/chunking.js +2 -2
  120. package/dist-lib/lib/core/files/rag/document-types.d.ts +3 -3
  121. package/dist-lib/lib/core/files/rag/extract/document-types.d.ts +9 -9
  122. package/dist-lib/lib/core/files/rag/extract/extract.js +7 -7
  123. package/dist-lib/lib/core/files/rag/extract/html-text.js +1 -1
  124. package/dist-lib/lib/core/files/rag/extract/office-collabora.js +2 -2
  125. package/dist-lib/lib/core/files/rag/extract/pdf-platform.js +1 -1
  126. package/dist-lib/lib/core/files/rag/extract/pdf-text.js +1 -1
  127. package/dist-lib/lib/core/files/rag/extract/text-decoding.js +1 -1
  128. package/dist-lib/lib/core/files/rag/extract/types.d.ts +2 -2
  129. package/dist-lib/lib/core/files/rag/index.js +22 -22
  130. package/dist-lib/lib/core/files/rag/load.js +5 -5
  131. package/dist-lib/lib/core/files/rag/policy.js +2 -2
  132. package/dist-lib/lib/core/files/rag/produce.js +5 -5
  133. package/dist-lib/lib/core/files/rag/retrieval/coverage.js +2 -2
  134. package/dist-lib/lib/core/files/rag/retrieval/diversity.js +1 -1
  135. package/dist-lib/lib/core/files/rag/retrieval/floor.js +2 -2
  136. package/dist-lib/lib/core/files/rag/retrieval/format.js +1 -1
  137. package/dist-lib/lib/core/files/rag/retrieval/full-text.js +18 -11
  138. package/dist-lib/lib/core/files/rag/retrieval/knowledge.js +5 -5
  139. package/dist-lib/lib/core/files/rag/retrieval/scoring.js +2 -2
  140. package/dist-lib/lib/core/files/rag/retrieval/search.js +4 -4
  141. package/dist-lib/lib/core/files/rag/retrieval/selection.js +2 -2
  142. package/dist-lib/lib/core/files/rag/retrieval/sources.js +2 -2
  143. package/dist-lib/lib/core/files/rag/retrieval/terms.js +1 -1
  144. package/dist-lib/lib/core/files/rag/retrieval/web-sources.js +1 -1
  145. package/dist-lib/lib/core/files/records/chunks.js +1 -1
  146. package/dist-lib/lib/core/files/records/index.js +8 -8
  147. package/dist-lib/lib/core/files/records/knowledge.js +2 -2
  148. package/dist-lib/lib/core/files/records/output.js +1 -1
  149. package/dist-lib/lib/core/files/records/reclaim.js +5 -5
  150. package/dist-lib/lib/core/files/records/routing.js +7 -7
  151. package/dist-lib/lib/core/files/store/blob.js +2 -2
  152. package/dist-lib/lib/core/files/store/index.js +7 -7
  153. package/dist-lib/lib/core/files/store/reference.js +2 -2
  154. package/dist-lib/lib/core/files/store/server.js +1 -1
  155. package/dist-lib/lib/core/files/store/sweep.js +1 -1
  156. package/dist-lib/lib/core/files/upload-input.js +2 -2
  157. package/dist-lib/lib/core/files/upload.d.ts +1 -1
  158. package/dist-lib/lib/core/files/upload.js +6 -6
  159. package/dist-lib/lib/core/harness-loan.d.ts +29 -0
  160. package/dist-lib/lib/core/harness-loan.js +187 -0
  161. package/dist-lib/lib/core/helpers/index.d.ts +2 -1
  162. package/dist-lib/lib/core/helpers/index.js +4 -4
  163. package/dist-lib/lib/core/hosted-agents.js +2 -2
  164. package/dist-lib/lib/core/identity.d.ts +2 -0
  165. package/dist-lib/lib/core/identity.js +4 -2
  166. package/dist-lib/lib/core/invite.d.ts +1 -0
  167. package/dist-lib/lib/core/invite.js +4 -2
  168. package/dist-lib/lib/core/local/index.d.ts +12 -3
  169. package/dist-lib/lib/core/local/index.js +75 -16
  170. package/dist-lib/lib/core/membership.d.ts +3 -0
  171. package/dist-lib/lib/core/membership.js +15 -1
  172. package/dist-lib/lib/core/mesh-seed-handoff.js +1 -1
  173. package/dist-lib/lib/core/mesh.d.ts +9 -3
  174. package/dist-lib/lib/core/mesh.js +41 -26
  175. package/dist-lib/lib/core/migrations/agent-catalog.js +1 -1
  176. package/dist-lib/lib/core/migrations/index.js +5 -3
  177. package/dist-lib/lib/core/migrations/membership.js +2 -2
  178. package/dist-lib/lib/core/migrations/seal.d.ts +3 -0
  179. package/dist-lib/lib/core/migrations/seal.js +30 -0
  180. package/dist-lib/lib/core/next-frame.js +1 -1
  181. package/dist-lib/lib/core/notification.js +1 -1
  182. package/dist-lib/lib/core/ota-config.js +1 -1
  183. package/dist-lib/lib/core/secret-handoff.js +1 -1
  184. package/dist-lib/lib/core/send.js +3 -3
  185. package/dist-lib/lib/core/skill-overlay-handoff.js +1 -1
  186. package/dist-lib/lib/core/skill-overlay-receiver.js +2 -2
  187. package/dist-lib/lib/core/skill-secrets.js +3 -3
  188. package/dist-lib/lib/core/sync/devices.js +1 -1
  189. package/dist-lib/lib/core/sync/index.js +8 -5
  190. package/dist-lib/lib/core/sync-status.js +1 -1
  191. package/dist-lib/lib/core/system-info.js +1 -1
  192. package/dist-lib/lib/core/tool-activity.js +2 -2
  193. package/dist-lib/lib/core/tool-configs.js +2 -2
  194. package/dist-lib/lib/core.d.ts +41 -3
  195. package/dist-lib/lib/core.js +525 -90
  196. package/dist-lib/lib/credential-pusher.js +4 -4
  197. package/dist-lib/lib/deadline.js +1 -1
  198. package/dist-lib/lib/fs-drive-bridge.js +4 -2
  199. package/dist-lib/lib/integrations/index.js +3 -3
  200. package/dist-lib/lib/integrations/oauth-providers.js +1 -1
  201. package/dist-lib/lib/integrations/setup-routes.d.ts +5 -5
  202. package/dist-lib/lib/integrations/setup-routes.js +3 -3
  203. package/dist-lib/lib/knowledge-search.js +1 -1
  204. package/dist-lib/lib/log.js +3 -3
  205. package/dist-lib/lib/mesh-scoped-engine.d.ts +3 -0
  206. package/dist-lib/lib/mesh-scoped-engine.js +96 -0
  207. package/dist-lib/lib/model-context.d.ts +2 -2
  208. package/dist-lib/lib/model-context.js +1 -1
  209. package/dist-lib/lib/model-download.js +6 -6
  210. package/dist-lib/lib/oauth/asana.js +3 -3
  211. package/dist-lib/lib/oauth/browser-connect.js +1 -1
  212. package/dist-lib/lib/oauth/client.js +2 -2
  213. package/dist-lib/lib/oauth/common.d.ts +1 -1
  214. package/dist-lib/lib/oauth/common.js +1 -1
  215. package/dist-lib/lib/oauth/flow-core.js +3 -3
  216. package/dist-lib/lib/oauth/flow.js +2 -2
  217. package/dist-lib/lib/oauth/google.js +4 -4
  218. package/dist-lib/lib/oauth/host.js +3 -3
  219. package/dist-lib/lib/oauth/loopback.js +1 -1
  220. package/dist-lib/lib/oauth/notion.js +3 -3
  221. package/dist-lib/lib/oauth/providers.js +1 -1
  222. package/dist-lib/lib/oauth/resolve.js +1 -1
  223. package/dist-lib/lib/oauth/spotify.js +3 -3
  224. package/dist-lib/lib/oauth/token-exchange.js +1 -1
  225. package/dist-lib/lib/oauth.client.js +2 -2
  226. package/dist-lib/lib/oauth.js +12 -12
  227. package/dist-lib/lib/run-notices.d.ts +7 -7
  228. package/dist-lib/lib/run-transcript.js +1 -1
  229. package/dist-lib/schema/build.js +12 -6
  230. package/dist-lib/schema/content.d.ts +11 -11
  231. package/dist-lib/schema/engine.js +193 -30
  232. package/dist-lib/schema/field-order.js +2 -2
  233. package/dist-lib/schema/local.js +18 -4
  234. package/dist-lib/schema/qvac.js +15 -6
  235. package/dist-lib/spec/bind.js +41 -0
  236. package/dist-lib/spec/calls.js +12 -0
  237. package/dist-lib/spec/capabilities.d.ts +36 -12
  238. package/dist-lib/spec/hrpc/hrpc.json +161 -5
  239. package/dist-lib/spec/hrpc/index.js +154 -9
  240. package/dist-lib/spec/hrpc/messages.js +549 -129
  241. package/dist-lib/spec/hyperschema/index.js +549 -129
  242. package/dist-lib/spec/hyperschema/schema.json +370 -40
  243. package/dist-lib/spec/hyperschema/types.d.ts +85 -1
  244. package/dist-lib/spec/local/hyperdb/db.json +15 -0
  245. package/dist-lib/spec/local/hyperdb/index.js +70 -1
  246. package/dist-lib/spec/local/hyperdb/messages.js +300 -117
  247. package/dist-lib/spec/local/hyperschema/index.js +97 -4
  248. package/dist-lib/spec/local/hyperschema/schema.json +58 -1
  249. package/dist-lib/spec/local/hyperschema/types.d.ts +14 -0
  250. package/dist-lib/spec/mesh/hyperdb/messages.js +393 -288
  251. package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +6 -0
  252. package/dist-lib/spec/mesh/hyperdispatch/index.js +18 -1
  253. package/dist-lib/spec/mesh/hyperdispatch/messages.js +176 -85
  254. package/dist-lib/spec/mesh/hyperschema/index.js +176 -85
  255. package/dist-lib/spec/mesh/hyperschema/schema.json +71 -21
  256. package/dist-lib/spec/mesh/hyperschema/types.d.ts +14 -1
  257. package/package.json +15 -9
  258. package/tui/README.md +7 -0
  259. package/tui/app.mjs +311 -14
  260. package/tui/lib/busy-words.mjs +57 -5
  261. package/tui/lib/export.mjs +1 -0
  262. package/tui/lib/render.mjs +9 -2
  263. package/tui/main.mjs +5 -2
@@ -76,10 +76,15 @@ What makes the fold legal under the rule above:
76
76
 
77
77
  Triggers: proactively before a run on the previous round's numbers, at the end of
78
78
  a run that filled the window itself, and reactively once the harness overflow
79
- ladder is exhausted. All three announce a `compacting` phase, which clients must
80
- exempt from any restart rule that discards a streamed answer on a non-terminal
81
- status. Clearing the phase stays conditional — only the before-run fold does it,
82
- because its run carries on.
79
+ ladder is exhausted. The proactive share is tiered by window — 75% under 12k, 82%
80
+ under 16k, 85% under 32k, 90% under 64k, 95% from there — because the band has
81
+ to hold a whole thinking turn and `cacheTokens` reports a turn with its thinking
82
+ stripped. The end-of-run fold's `compacting` status is not an attempt start in
83
+ `historyFromChunks`; reading it as one drops the kept turn's answer. All three
84
+ announce a `compacting` phase, which clients must exempt from any restart rule
85
+ that discards a streamed answer on a non-terminal status. Clearing the phase
86
+ stays conditional — only the before-run fold does it, because its run carries
87
+ on.
83
88
 
84
89
  After the fact the fold is visible from its chunk (`thread.compactionMarkers`,
85
90
  anchored before the user message the fold precedes). Only the device that ran the
@@ -61,6 +61,26 @@ Optional, and taken from what the diff actually touches — `lib`, `tui`, `schem
61
61
  A scope that restates the type (`fix(fix)`) or names the whole repo adds
62
62
  nothing; leave it off.
63
63
 
64
+ ## Examples
65
+
66
+ `examples/` is where a consumer meets this library: `mesh-peer.mjs` stands a
67
+ Core and a Client up from nothing, `mesh-lab.mjs` drives scenarios against it.
68
+ They are read before `lib/` is.
69
+
70
+ **A PR that adds public API ships an example with it.** Public API means a new
71
+ entry in `package.json#exports`, a new export from `index.ts` or `client.ts`,
72
+ or a new capability that reaches the `Client` surface through `schema/`. Extend
73
+ an existing script or add one, whichever shows the capability in the fewest
74
+ lines someone can actually run.
75
+
76
+ An example is a runnable `.mjs` under `examples/` that imports the package the
77
+ way a consumer does. Give it a `package.json#scripts` entry when it is a
78
+ scenario run by name, and name it in the PR body.
79
+
80
+ Nothing else needs one — an internal module, a `tui/` command, a refactor, a
81
+ fix. Do not pad `examples/` to clear a checklist: one script a reader can run
82
+ beats three that restate the types.
83
+
64
84
  ## Decision records
65
85
 
66
86
  `docs/decisions/` holds the durable, non-obvious choices — why a boundary is
@@ -155,11 +175,12 @@ this is the only warning they get.
155
175
  each one is a change you would defend on its own. A trail of `wip`,
156
176
  `fixup` or `address review` commits is not history; reshape it before
157
177
  opening.
158
- 3. `bun run lint` and ``bun run test` (node, bare and addon lanes)` pass locally. CI runs the same lanes; a
178
+ 3. New public API? `examples/` shows it, and the body names the script.
179
+ 4. `bun run lint` and ``bun run test` (node, bare and addon lanes)` pass locally. CI runs the same lanes; a
159
180
  red PR wastes a reviewer's round trip.
160
- 4. Rebase on `main` rather than merging it in. A merge commit in the branch
181
+ 5. Rebase on `main` rather than merging it in. A merge commit in the branch
161
182
  makes the diff unreadable.
162
- 5. Open as a **draft** unless you are asking for review right now.
183
+ 6. Open as a **draft** unless you are asking for review right now.
163
184
 
164
185
  ```bash
165
186
  gh pr create --repo tetherto/qvac-core --draft --title "type(scope): subject" --body-file <path>
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: pr-review
3
- description: Deep-dive review of a pull request in @qvac/core, or of local uncommitted/branch changes when invoked with `local`. Checks CI, the commit type and title, code quality against the house style, contract and API mismatches, and missing tests. In PR mode it creates PENDING inline comments only after the user confirms them, and never submits the review event. In local mode it prints findings in chat and posts nothing. Use when reviewing a PR, given a PR link, or asked to review the working tree or current branch.
3
+ description: Deep-dive review of a pull request in @qvac/core, or of local uncommitted/branch changes when invoked with `local`. Checks CI and the base branch, the commit type and title, correctness and state/derived-data bugs, contract and API mismatches, security, code quality against the house style, and missing tests. In PR mode it creates PENDING inline comments only after the user confirms them, and never submits the review event. In local mode it prints findings in chat and posts nothing. Use when reviewing a PR, given a PR link, or asked to review the working tree or current branch.
4
4
  ---
5
5
 
6
6
  # PR review
@@ -41,14 +41,18 @@ PR mode:
41
41
 
42
42
  ```bash
43
43
  gh pr view <num> --repo tetherto/qvac-core \
44
- --json title,body,author,headRefName,headRefOid,baseRefName,files,additions,deletions,state,isDraft,mergeable
44
+ --json title,body,author,headRefName,headRefOid,baseRefName,files,additions,deletions,state,isDraft,mergeable,statusCheckRollup \
45
+ > /tmp/pr-<num>.json
45
46
  gh pr diff <num> --repo tetherto/qvac-core --patch > /tmp/pr-<num>.patch
46
47
  ```
47
48
 
48
- Read the patch from the file with Read/Grep rather than re-running `gh` — it is
49
- the same bytes every time and the file is greppable.
49
+ Two calls, then read both files with Read/Grep rather than re-running `gh` — it
50
+ is the same bytes every time and the files are greppable. `statusCheckRollup`
51
+ already carries every check, so **do not run `gh pr checks`**; it buys nothing
52
+ the JSON does not have.
50
53
 
51
- Local mode:
54
+ Local mode. The default scope is everything uncommitted — staged, unstaged and
55
+ untracked:
52
56
 
53
57
  ```bash
54
58
  git diff --staged > /tmp/local-staged.patch
@@ -57,8 +61,17 @@ git status --porcelain=v1
57
61
  git ls-files --others --exclude-standard # untracked, easy to miss
58
62
  ```
59
63
 
60
- For a branch rather than a working tree: `git diff main...HEAD` (three dots —
61
- the merge base, not the tip).
64
+ Scope overrides, when the user asks for one: `--staged` is `git diff --staged`
65
+ alone, `--unstaged` is `git diff` plus untracked, and `--branch [<base>]` is
66
+ `git diff <base>...HEAD` (three dots — the merge base, not the tip), with
67
+ `<base>` defaulting to `main`.
68
+
69
+ Untracked files are reviewed as wholly new content: read them from the working
70
+ tree, they appear in no patch.
71
+
72
+ **If the requested scope is empty, say so and stop.** An empty `--staged` is
73
+ not an invitation to review something else, and it is certainly not an
74
+ invitation to invent findings.
62
75
 
63
76
  ## CI
64
77
 
@@ -78,8 +91,10 @@ local `bun run test` does not:
78
91
  A PR that touches `schema/` and leaves `spec/` stale is the most common red
79
92
  here, and it looks nothing like a test failure.
80
93
 
94
+ Read the result from `statusCheckRollup` in `/tmp/pr-<num>.json`, and pull logs
95
+ only for a job that actually failed:
96
+
81
97
  ```bash
82
- gh pr checks <num> --repo tetherto/qvac-core
83
98
  gh run view --repo tetherto/qvac-core --log-failed --job <id> > /tmp/pr-<num>-<id>.log
84
99
  ```
85
100
 
@@ -87,6 +102,18 @@ A red `Integrate` is a blocking finding on its own. Read the failing job's log
87
102
  before writing a single line of review — half of what looks like a design
88
103
  problem is a lint rule.
89
104
 
105
+ ### Base branch
106
+
107
+ `baseRefName` is in the JSON you already fetched. Per CLAUDE.md a PR targets
108
+ `main`; the one exception is a stacked PR, which branches from the PR below it
109
+ and targets that branch.
110
+
111
+ So a base other than `main` is only a finding when the PR is **not** part of a
112
+ stack — check whether the base branch is itself an open PR before raising it.
113
+ If it is, the stack is correct and there is nothing to say. If it is not, that
114
+ is a `[P2]`: the diff will contain the base branch's commits and the PR cannot
115
+ merge as it stands.
116
+
90
117
  ## What to check, in order
91
118
 
92
119
  Stop at the first tier that produces findings worth the author's time; a review
@@ -97,7 +124,38 @@ end to end, including the error path. Look for: a promise not awaited, a
97
124
  listener never removed, a resource opened on one path and closed on another, an
98
125
  error swallowed into a default.
99
126
 
100
- **2. Contract and API.** This is a published package, so an exported signature
127
+ A **regression** belongs here too: a change that reads as additive but alters
128
+ what existing callers get — a signature widened, a default flipped, a branch
129
+ removed, a return value that is semantically different at the same type.
130
+
131
+ **2. State and derived data.** The class of bug a linter cannot see and a diff
132
+ skim misses. Walk any new stateful or arithmetic code against these four.
133
+
134
+ - **Two sources of truth.** The same value in two fields, or the same
135
+ expression computed twice, in one payload. Before writing the comment, read
136
+ the type declaration **and** the consumer: if the fields have distinct
137
+ documented meanings (per-item vs aggregate, raw vs normalised) and a reader
138
+ prefers one, this is a value written to the wrong channel — a contract
139
+ violation — not duplication. Say that, and cite the contract. Only call it
140
+ duplication when nothing distinguishes the fields. The two look identical in
141
+ a diff and have opposite fixes: one keeps both fields and moves a value, the
142
+ other deletes a field. Backwards, and you send the author to delete a channel
143
+ something depends on. `[P2]` either way.
144
+ - **Incremental accumulation.** A running total or offset advanced inside a
145
+ loop, where computing the whole table once would be correct by construction.
146
+ `[P2]` when a later edit could desynchronise it — and the fix shrinks the
147
+ code.
148
+ - **Closure over mutated state.** A callback capturing a variable a later step
149
+ reassigns, especially across an `await`. `[P1]` if a late or reordered
150
+ invocation yields a wrong value; say so plainly, because it will not
151
+ reproduce locally.
152
+ - **Laundered values.** `?? 0`, `|| 0`, `Math.max(x, 0)` turning an impossible
153
+ input into a plausible number instead of letting it fail. `[P2]` unless the
154
+ clamp buys a stated presentational guarantee. Watch an optional `uint` in
155
+ `schema/`: it decodes to `0`, not `null`, so `??` never sees the absent
156
+ value.
157
+
158
+ **3. Contract and API.** This is a published package, so an exported signature
101
159
  is a promise to a consumer.
102
160
 
103
161
  - Anything added to or changed in the export map, `index.ts`, `types/`, or
@@ -107,27 +165,56 @@ is a promise to a consumer.
107
165
  - Does the change match its own type declarations, and do callers in this repo
108
166
  still typecheck?
109
167
 
110
- **3. House style.** Run the changed files against **js-house-style** — that
111
- document, not your own taste. Layering, composition on primitives, module size
112
- and shape, no defensive programming, comment density.
168
+ **4. House style.** Load **js-house-style** and run the changed files against
169
+ it — that document, not your own taste or your memory of it. Layering,
170
+ composition on primitives, module size and shape, no defensive programming,
171
+ comment density. A style point the document does not back is not a finding.
113
172
 
114
- **4. Tests.** A behaviour change with no test is a finding. Name the missing
173
+ **5. Tests.** A behaviour change with no test is a finding. Name the missing
115
174
  case rather than asking for "more tests": the tests live under `test/`, run on
116
175
  both the node and bare lanes, and a fix without a regression guard will come
117
176
  back.
118
177
 
119
- **5. Commit type and title.** Per **pr-create**: is this really a `fix` (a
178
+ **6. Examples.** This is a library, and `examples/` is where a consumer learns
179
+ its surface — `mesh-peer.mjs` for standing up a Core and a Client,
180
+ `mesh-lab.mjs` for scenarios on top. New public API with nothing in `examples/`
181
+ is a finding: `[P2]` for a new entry in `package.json#exports` or a new export
182
+ from `index.ts` / `client.ts`, `[P3]` for a capability folded into an area an
183
+ existing script already covers. Name the script that should have changed and
184
+ the one thing it should show; anchor the comment on the new export line, since
185
+ the absence itself has no line.
186
+
187
+ Nothing else triggers this. An internal module, a `tui/` command, a refactor, a
188
+ fix, a test — no example, no finding. Do not ask for an example because a diff
189
+ is large.
190
+
191
+ **7. Commit type and title.** Per **pr-create**: is this really a `fix` (a
120
192
  defect a consumer of a released version could hit), or is it `chore` on code
121
193
  that never shipped? Is the title imperative and specific? Does the branch name
122
194
  avoid `codex` / `cursor` / `claude`?
123
195
 
124
- **6. Scope.** Does the PR do one thing? A behaviour change mixed with an
196
+ **8. Scope.** Does the PR do one thing? A behaviour change mixed with an
125
197
  unrelated rename is two PRs — say so, and say which commit to split out.
126
198
 
127
- **7. Decision records.** Does the change contradict something in
128
- `docs/decisions/`? If it does, the record is updated or superseded in the same
129
- PR, not left to rot. Does it settle something non-obvious with no record at all?
130
- Say which, and what the record would have to state.
199
+ **9. Security.** Not a sweep of the file — only what this diff introduces. A
200
+ secret or key material in code, a log line or an error message; a peer-supplied
201
+ value trusted without validation at a trust boundary; unsafe deserialization of
202
+ anything off the wire; crypto used in a way the primitive does not promise
203
+ (a reused nonce, a comparison that is not constant-time, a key derived from
204
+ something predictable); a new dependency pulled in for something small.
205
+
206
+ This is a P2P library, so "the input came from another device" is the normal
207
+ case, not the exceptional one. Where it matters, `[P1]`.
208
+
209
+ **10. Decision records.** Only when the diff **contradicts** a record in
210
+ `docs/decisions/` that you have actually read — then the record is updated or
211
+ superseded in the same PR rather than left to rot, and that is a `[P2]`.
212
+
213
+ A missing record is not a finding. Do not open `docs/decisions/INDEX.md`
214
+ looking for something to say, do not ask for an ADR because a change "feels
215
+ architectural", and never make "no decision record" the only thing a review
216
+ found. If you genuinely think a lasting choice went unrecorded, say it once in
217
+ the chat overview as a question, never inline.
131
218
 
132
219
  ### Do not over-engineer the review
133
220
 
@@ -155,17 +242,38 @@ corner nobody chose.
155
242
  Each finding: the file and line, what breaks, and the concrete scenario that
156
243
  breaks it. No finding without a failure mode you can state.
157
244
 
158
- Drop anything you cannot defend as changing the code, the reviewer's decision,
159
- or a consumer's experience. Style opinions the house style does not back are
160
- noise. Say so plainly when the diff is clean: "no `[P1]` or `[P2]`
161
- findings" is a complete review.
162
-
163
245
  Lead with the findings, ordered by severity.
164
246
 
247
+ ### Only raise what is worth the author's time
248
+
249
+ A review is not required to produce findings. **"Nothing to flag — the diff is
250
+ clean" is a complete, successful review**, and a good PR reviewed honestly is
251
+ the expected outcome most of the time. Never go hunting for something to say
252
+ because the output looks empty; an invented finding costs the author more than
253
+ a silent review ever could.
254
+
255
+ Every finding passes this bar before it is written down:
256
+
257
+ - You can name **what breaks**, and the concrete path that reaches it.
258
+ - Acting on it **changes the code, the reviewer's decision, or a consumer's
259
+ experience**.
260
+ - It is backed by the house style or a real contract, not your taste.
261
+
262
+ Drop everything else. Not "mention it as a `[P3]`" — **drop it**. A finding you
263
+ cannot defend at `[P2]` is not thereby a `[P3]`; it is noise wearing a smaller
264
+ tag. `[P3]` is for a real, small, correct observation, not a holding pen for
265
+ weak `[P1]`/`[P2]`s.
266
+
267
+ The failure mode this repo has actually seen: a clean PR comes back with four
268
+ `[P3]`s about naming, a speculative race nobody can reach, and a request for a
269
+ decision record. That review is worse than no review — it trains the author to
270
+ skim the next one, and the real finding gets skimmed with it.
271
+
165
272
  ### Severity tags
166
273
 
167
- Tag every finding `[P1]`, `[P2]` or `[P3]`. Use the tag, not a word, so two
168
- reviews of the same repo rank things the same way.
274
+ Tag every finding `[P1]`, `[P2]` or `[P3]` **in the chat overview**, using the
275
+ tag rather than a word, so two reviews of the same repo rank things the same
276
+ way. The tag never appears on the PR — see "Comment style".
169
277
 
170
278
  - `[P1]` — almost-certain bug, data corruption, security issue, CI breaker, or a
171
279
  break of behaviour a consumer relies on. In the overview, and **proposed inline
@@ -182,35 +290,135 @@ nits inline teaches the author to skim the next one.
182
290
 
183
291
  **Severity is what the code does today, not what it might do.** A finding whose
184
292
  only support is a scenario nobody has hit is not a `[P2]`: either find the path
185
- that reaches it, or drop it. Zero findings is a legitimate result.
293
+ that reaches it, or drop it — do not park it at `[P3]` instead. Zero findings is
294
+ a legitimate result.
186
295
 
187
296
  If the user says this is a re-review, say explicitly which earlier concerns are
188
297
  resolved and which still stand.
189
298
 
299
+ ### The overview
300
+
301
+ The user's checkout is usually on a different branch or commit than the PR, so
302
+ a bare line number is worth nothing to them. Every `[P1]` and `[P2]` in the
303
+ overview therefore carries two things: a **3–8 line excerpt read at the head
304
+ SHA**, and a **link to that line on the PR**.
305
+
306
+ The excerpt comes from
307
+ `gh api -H "Accept: application/vnd.github.raw" repos/tetherto/qvac-core/contents/<path>?ref=<headRefOid>`,
308
+ never from the local tree. The link is the file-diff anchor:
309
+
310
+ `https://github.com/tetherto/qvac-core/pull/<num>/files#diff-<sha256(path)>R<line>`
311
+
312
+ ```bash
313
+ printf '%s' 'lib/chat/compact.js' | shasum -a 256 | awk '{print $1}'
314
+ ```
315
+
316
+ If the anchor will not compute, fall back to
317
+ `https://github.com/tetherto/qvac-core/blob/<headRefOid>/<path>#L<line>`.
318
+
319
+ ````markdown
320
+ ## PR #<num> — review overview
321
+
322
+ <one line: what this PR does>
323
+
324
+ ### CI / base
325
+
326
+ <one line; omit entirely when both are clean>
327
+
328
+ ### Findings
329
+
330
+ - **[P1]** <short title> — [`<path>:<line>`](link)
331
+
332
+ <one sentence, plus the repro when there is one>
333
+
334
+ ```js
335
+ <3-8 line excerpt at the head SHA>
336
+ ```
337
+
338
+ - **[P3]** <short title> — [`<path>:<line>`](link) — <one sentence, no excerpt>
339
+
340
+ ### Re-review delta
341
+
342
+ <only when the user said this is a re-review>
343
+
344
+ - Resolved: <…>
345
+ - Still open: <…>
346
+ ````
347
+
348
+ One sentence per finding here; the inline comment carries the reasoning. A
349
+ clean review is this same block with `Findings` reading "nothing to flag".
350
+
351
+ Local mode uses the same shape, headed `## Local review — <scope>`, with plain
352
+ `path:line` instead of links and the excerpt read from the working tree.
353
+
354
+ ## Comment style
355
+
356
+ Write like a colleague leaving a note, not a static analyser filing a report.
357
+ If a human reviewer would not say it out loud, do not write it.
358
+
359
+ - **Brief.** A few lines, one point per comment. If it takes three paragraphs
360
+ to justify, it probably is not a finding.
361
+ - **Ask, don't lecture.** "Can this reuse the existing helper?" beats a
362
+ paragraph on why the new one duplicates knowledge the store already owns.
363
+ - **Link what you refer to.** An existing function, type or rule you want
364
+ reused gets a line link — `[name](<url>#L120)`. A reference the author has to
365
+ hunt for is one they skip.
366
+ - **Show the change in code.** A short before/after, or a `suggestion` block
367
+ whenever the fix is mechanical enough to apply as-is.
368
+ - **Never put a severity marker in a comment body.** No `[P1]`/`[P2]`/`[P3]`,
369
+ no "blocker", no "nit:". Severity is how _you_ decided what to raise; it
370
+ lives in the chat overview and nowhere else. On the PR it reads as grading
371
+ the author and it ages badly once the code moves. If something is minor, say
372
+ it in plain words — "not urgent", "while you're in there".
373
+ - One concrete repro line for a `[P1]`/`[P2]` when one exists. Not a test plan.
374
+ - No praise padding, no "LGTM but…", no restating what the diff does.
375
+ - **Sign off every comment with 🤖 on its own last line**, so it is
376
+ unmistakable that the review came from an AI. Every inline comment, no
377
+ exceptions — the emoji alone, nothing else on the line.
378
+
190
379
  ## Posting (PR mode only)
191
380
 
192
- 1. Print every proposed comment in chat first: file, line, severity, body.
193
- The default set is the `[P1]` and `[P2]` findings; name any `[P3]` you are
194
- holding back so the user can pull it in.
381
+ 1. Print every proposed comment in chat first, as it will be posted: file,
382
+ line, then the verbatim body. Carry the severity in the chat line **outside**
383
+ the body. The default set is the `[P1]` and `[P2]` findings; name any `[P3]`
384
+ you are holding back so the user can pull it in. If there is nothing at
385
+ `[P1]`/`[P2]`, say so and stop — never assemble a payload out of `[P3]`s to
386
+ have something to post.
195
387
  2. Ask the user to confirm the exact set. Wait for a clear yes.
196
- 3. Create the review as **PENDING**, with no event:
388
+ 3. Write `/tmp/pr-<num>-review.json` from the confirmed set **only**. If the
389
+ confirmed set is empty, stop — never post an empty review.
390
+ 4. Pre-flight, before the POST:
391
+ - The comment count matches the confirmed set **exactly**. If it does not,
392
+ stop and reconcile; do not post the larger set and mention it after.
393
+ - Every `line` is a **post-PR line** — the `+` side of the patch, as
394
+ numbered in the file at the head SHA. A line the patch does not touch is a
395
+ `422` that rejects the whole review, so anchor to a touched line or move
396
+ the point to the chat overview.
397
+ - Every body ends with a `🤖` line, and none contains `[P1]`, `[P2]`, `[P3]`,
398
+ "nit" or "blocker". Fix the bodies yourself; do not ask the user.
399
+ - Show the bodies as **rendered Markdown**, one per `file:line`, never raw
400
+ JSON — the user is approving what the author will read.
401
+ 5. Create the review as **PENDING**, with no event:
197
402
 
198
403
  ```bash
199
404
  gh api repos/tetherto/qvac-core/pulls/<num>/reviews \
200
- --method POST --input /tmp/review.json
405
+ --method POST --input /tmp/pr-<num>-review.json
201
406
  ```
202
407
 
203
- where `review.json` has `commit_id` (the `headRefOid` you fetched) and a
204
- `comments` array of `{path, line, side, body}`, and **no `event` field**. A body
205
- with `event` submits the review; leaving it out is what makes it pending.
408
+ where the payload has `commit_id` (the `headRefOid` you fetched) and a
409
+ `comments` array of `{path, line, side, body}`, and **no `event` field**. A
410
+ payload with `event` submits the review; leaving it out is what makes it
411
+ pending. No top-level `body` either, unless the user asks for one — the inline
412
+ comments are the review.
206
413
 
207
- 4. Hand the user the link and stop:
208
- `https://github.com/tetherto/qvac-core/pull/<num>#pullrequestreview-<id>`
414
+ If the user edits the selection after the preview, rewrite the file before
415
+ running the command.
209
416
 
210
- If a line is not in the diff, GitHub rejects the comment. Anchor to a line the
211
- patch actually touches, or raise it in the chat overview instead.
417
+ 6. Hand the user the link and stop:
418
+ `https://github.com/tetherto/qvac-core/pull/<num>#pullrequestreview-<id>`
212
419
 
213
420
  ## Sibling skills
214
421
 
215
422
  - Writing the PR being reviewed → **pr-create**.
216
- - The rules tier 3 reviews against → **js-house-style**.
423
+ - The rules tier 4 reviews against → **js-house-style**. Load it; do not review
424
+ from memory of it.
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
 
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,7 @@
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 { requireMesh } from './current-mesh.js';
3
+ import { watchable } from './watchable.js';
4
+ export function createAgentsApi(current, deviceId, computeLender = null) {
5
5
  const withOrphaned = async (mesh, agent) => ({
6
6
  ...agent,
7
7
  orphaned: await isOrphaned(mesh, agent)
@@ -18,19 +18,20 @@ export function createAgentsApi(current, deviceId) {
18
18
  return {
19
19
  createAgent: async (input) => {
20
20
  const mesh = await requireMesh(current, input.meshId);
21
- return withOrphaned(mesh, await createAgent(mesh, input));
21
+ const lenderDeviceId = input.lenderDeviceId ?? (await computeLender?.()) ?? undefined;
22
+ return withOrphaned(mesh, await createAgent(mesh, { ...input, lenderDeviceId }));
22
23
  },
23
24
  listAgents: async (request) => list(await requireMesh(current, request?.meshId)),
24
- getAgent: async ({ id }) => {
25
- const mesh = await requireMesh(current);
25
+ getAgent: async ({ id, meshId }) => {
26
+ const mesh = await requireMesh(current, meshId);
26
27
  return withOrphaned(mesh, await mustGetActiveAgent(mesh, id));
27
28
  },
28
29
  updateAgent: async (input) => {
29
30
  const mesh = await requireMesh(current);
30
31
  return withOrphaned(mesh, await updateAgent(mesh, input));
31
32
  },
32
- deleteAgent: async ({ id }) => {
33
- const mesh = await requireMesh(current);
33
+ deleteAgent: async ({ id, meshId }) => {
34
+ const mesh = await requireMesh(current, meshId);
34
35
  return withOrphaned(mesh, await deleteAgent(mesh, deviceId, id));
35
36
  },
36
37
  agentsWatch: watchable('agentsWatch', (request) => requireMesh(current, request?.meshId), (_request, mesh) => list(mesh))
@@ -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
  }