@qvac/core 1.0.0-rc.7 → 1.0.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 (237) hide show
  1. package/CHANGELOG.md +241 -3
  2. package/README.md +1 -0
  3. package/dist-lib/lib/api/attachments.d.ts +1 -1
  4. package/dist-lib/lib/api/attachments.js +11 -0
  5. package/dist-lib/lib/api/chunks.d.ts +4 -2
  6. package/dist-lib/lib/api/chunks.js +6 -3
  7. package/dist-lib/lib/api/device-routes.d.ts +6 -1
  8. package/dist-lib/lib/api/device-routes.js +20 -1
  9. package/dist-lib/lib/api/devices.js +6 -18
  10. package/dist-lib/lib/api/execution.d.ts +6 -2
  11. package/dist-lib/lib/api/execution.js +29 -3
  12. package/dist-lib/lib/api/host-run-log.d.ts +7 -1
  13. package/dist-lib/lib/api/host-run-log.js +3 -1
  14. package/dist-lib/lib/api/index.d.ts +3 -1
  15. package/dist-lib/lib/api/index.js +17 -6
  16. package/dist-lib/lib/api/members.js +13 -29
  17. package/dist-lib/lib/api/mesh.d.ts +2 -1
  18. package/dist-lib/lib/api/projects.d.ts +1 -1
  19. package/dist-lib/lib/api/projects.js +9 -5
  20. package/dist-lib/lib/api/rag-label.d.ts +4 -0
  21. package/dist-lib/lib/api/rag-label.js +21 -0
  22. package/dist-lib/lib/api/rag-lexical.d.ts +22 -0
  23. package/dist-lib/lib/api/rag-lexical.js +1058 -0
  24. package/dist-lib/lib/api/rag-manifest.d.ts +13 -0
  25. package/dist-lib/lib/api/rag-manifest.js +46 -0
  26. package/dist-lib/lib/api/rag-outline.d.ts +36 -0
  27. package/dist-lib/lib/api/rag-outline.js +426 -0
  28. package/dist-lib/lib/api/rag-plugin.d.ts +20 -0
  29. package/dist-lib/lib/api/rag-plugin.js +70 -0
  30. package/dist-lib/lib/api/rag-synthesis.d.ts +7 -0
  31. package/dist-lib/lib/api/rag-synthesis.js +102 -0
  32. package/dist-lib/lib/api/rag-targets.d.ts +23 -0
  33. package/dist-lib/lib/api/rag-targets.js +215 -0
  34. package/dist-lib/lib/api/rag-window.d.ts +5 -0
  35. package/dist-lib/lib/api/rag-window.js +46 -0
  36. package/dist-lib/lib/api/rag.d.ts +3 -2
  37. package/dist-lib/lib/api/rag.js +421 -184
  38. package/dist-lib/lib/api/served.js +8 -14
  39. package/dist-lib/lib/api/workspace.d.ts +8 -1
  40. package/dist-lib/lib/api/workspace.js +27 -13
  41. package/dist-lib/lib/assistant/harness.d.ts +9 -1
  42. package/dist-lib/lib/assistant/history.d.ts +11 -2
  43. package/dist-lib/lib/assistant/history.js +74 -4
  44. package/dist-lib/lib/assistant/media-round.d.ts +61 -0
  45. package/dist-lib/lib/assistant/media-round.js +111 -0
  46. package/dist-lib/lib/assistant/message.d.ts +7 -0
  47. package/dist-lib/lib/assistant/model-round.d.ts +19 -1
  48. package/dist-lib/lib/assistant/model-round.js +163 -28
  49. package/dist-lib/lib/assistant/pdf-pages.d.ts +16 -1
  50. package/dist-lib/lib/assistant/pdf-pages.js +67 -3
  51. package/dist-lib/lib/assistant/round-host.d.ts +22 -0
  52. package/dist-lib/lib/assistant/round-host.js +142 -8
  53. package/dist-lib/lib/assistant/upload.d.ts +12 -0
  54. package/dist-lib/lib/assistant/upload.js +36 -0
  55. package/dist-lib/lib/assistant-client.d.ts +1 -0
  56. package/dist-lib/lib/assistant-client.js +40 -19
  57. package/dist-lib/lib/assistant-tree.d.ts +2 -0
  58. package/dist-lib/lib/assistant-tree.js +48 -1
  59. package/dist-lib/lib/assistant.d.ts +18 -1
  60. package/dist-lib/lib/assistant.js +484 -95
  61. package/dist-lib/lib/client.d.ts +1 -0
  62. package/dist-lib/lib/client.js +4 -1
  63. package/dist-lib/lib/compaction.js +2 -2
  64. package/dist-lib/lib/core/agent.js +12 -45
  65. package/dist-lib/lib/core/approval-rules.js +1 -8
  66. package/dist-lib/lib/core/archived-mesh.d.ts +2 -1
  67. package/dist-lib/lib/core/archived-mesh.js +12 -8
  68. package/dist-lib/lib/core/chat-copy.d.ts +18 -3
  69. package/dist-lib/lib/core/chat-copy.js +74 -25
  70. package/dist-lib/lib/core/chat-fork.js +15 -6
  71. package/dist-lib/lib/core/chat-group.js +16 -24
  72. package/dist-lib/lib/core/chat-move.d.ts +9 -0
  73. package/dist-lib/lib/core/chat-move.js +94 -3
  74. package/dist-lib/lib/core/chat-order.js +12 -18
  75. package/dist-lib/lib/core/chat.js +38 -31
  76. package/dist-lib/lib/core/chunk.d.ts +2 -2
  77. package/dist-lib/lib/core/chunk.js +18 -25
  78. package/dist-lib/lib/core/collections.d.ts +2 -0
  79. package/dist-lib/lib/core/collections.js +2 -0
  80. package/dist-lib/lib/core/contract/activity.d.ts +4 -0
  81. package/dist-lib/lib/core/contract/activity.js +34 -4
  82. package/dist-lib/lib/core/contract/chat-group.d.ts +1 -0
  83. package/dist-lib/lib/core/contract/chat-group.js +21 -1
  84. package/dist-lib/lib/core/contract/chat.d.ts +9 -0
  85. package/dist-lib/lib/core/contract/chat.js +127 -5
  86. package/dist-lib/lib/core/contract/chunks.d.ts +1 -0
  87. package/dist-lib/lib/core/contract/chunks.js +37 -6
  88. package/dist-lib/lib/core/contract/features.d.ts +21 -0
  89. package/dist-lib/lib/core/contract/features.js +22 -0
  90. package/dist-lib/lib/core/contract/index.js +2 -0
  91. package/dist-lib/lib/core/contract/indexing.js +4 -2
  92. package/dist-lib/lib/core/contract/knowledge.js +5 -4
  93. package/dist-lib/lib/core/contract/members.js +16 -10
  94. package/dist-lib/lib/core/contract/mesh-kind.d.ts +1 -0
  95. package/dist-lib/lib/core/contract/mesh-kind.js +3 -1
  96. package/dist-lib/lib/core/contract/projects.d.ts +5 -0
  97. package/dist-lib/lib/core/contract/projects.js +13 -5
  98. package/dist-lib/lib/core/contract/roles.js +32 -4
  99. package/dist-lib/lib/core/contract/run-requests.d.ts +1 -0
  100. package/dist-lib/lib/core/contract/run-requests.js +35 -2
  101. package/dist-lib/lib/core/contract/seed-defaults.js +2 -2
  102. package/dist-lib/lib/core/contract/tool-configs.js +3 -2
  103. package/dist-lib/lib/core/contract/workspace.d.ts +2 -0
  104. package/dist-lib/lib/core/contract/workspace.js +40 -7
  105. package/dist-lib/lib/core/contract/writers.js +2 -2
  106. package/dist-lib/lib/core/departures.d.ts +3 -1
  107. package/dist-lib/lib/core/departures.js +3 -0
  108. package/dist-lib/lib/core/devices.js +1 -8
  109. package/dist-lib/lib/core/files/attachments.d.ts +2 -0
  110. package/dist-lib/lib/core/files/attachments.js +19 -1
  111. package/dist-lib/lib/core/files/index.d.ts +20 -4
  112. package/dist-lib/lib/core/files/index.js +132 -21
  113. package/dist-lib/lib/core/files/processing/document.d.ts +4 -0
  114. package/dist-lib/lib/core/files/processing/document.js +7 -0
  115. package/dist-lib/lib/core/files/processing/index.d.ts +13 -0
  116. package/dist-lib/lib/core/files/processing/index.js +144 -12
  117. package/dist-lib/lib/core/files/processing/protocol.js +13 -34
  118. package/dist-lib/lib/core/files/processing/state.d.ts +2 -0
  119. package/dist-lib/lib/core/files/rag/build.d.ts +19 -2
  120. package/dist-lib/lib/core/files/rag/build.js +123 -19
  121. package/dist-lib/lib/core/files/rag/failure.js +2 -1
  122. package/dist-lib/lib/core/files/rag/index.d.ts +11 -3
  123. package/dist-lib/lib/core/files/rag/index.js +13 -1
  124. package/dist-lib/lib/core/files/rag/load.d.ts +6 -3
  125. package/dist-lib/lib/core/files/rag/load.js +27 -6
  126. package/dist-lib/lib/core/files/rag/plugin-index.d.ts +32 -0
  127. package/dist-lib/lib/core/files/rag/plugin-index.js +127 -0
  128. package/dist-lib/lib/core/files/rag/produce.d.ts +5 -3
  129. package/dist-lib/lib/core/files/rag/produce.js +104 -16
  130. package/dist-lib/lib/core/files/rag/retrieval/full-text.d.ts +3 -1
  131. package/dist-lib/lib/core/files/rag/retrieval/full-text.js +62 -13
  132. package/dist-lib/lib/core/files/rag/text-cache.d.ts +28 -0
  133. package/dist-lib/lib/core/files/rag/text-cache.js +141 -0
  134. package/dist-lib/lib/core/files/records/knowledge.d.ts +1 -3
  135. package/dist-lib/lib/core/files/records/knowledge.js +7 -40
  136. package/dist-lib/lib/core/files/records/reclaim.js +5 -10
  137. package/dist-lib/lib/core/files/upload.js +68 -41
  138. package/dist-lib/lib/core/fs-drives.js +14 -26
  139. package/dist-lib/lib/core/invite.d.ts +1 -0
  140. package/dist-lib/lib/core/invite.js +4 -2
  141. package/dist-lib/lib/core/local/files.d.ts +1 -1
  142. package/dist-lib/lib/core/local/files.js +5 -5
  143. package/dist-lib/lib/core/local/index.d.ts +13 -6
  144. package/dist-lib/lib/core/local/index.js +103 -69
  145. package/dist-lib/lib/core/local/run-logs.d.ts +1 -1
  146. package/dist-lib/lib/core/local/run-logs.js +5 -5
  147. package/dist-lib/lib/core/mesh-processor.d.ts +19 -0
  148. package/dist-lib/lib/core/mesh-processor.js +87 -0
  149. package/dist-lib/lib/core/mesh.d.ts +48 -5
  150. package/dist-lib/lib/core/mesh.js +318 -129
  151. package/dist-lib/lib/core/migrations/agent-catalog.js +2 -8
  152. package/dist-lib/lib/core/migrations/agent-tools-scope.js +5 -11
  153. package/dist-lib/lib/core/migrations/workspace-from-0-21/index.d.ts +88 -0
  154. package/dist-lib/lib/core/migrations/workspace-from-0-21/index.js +731 -0
  155. package/dist-lib/lib/core/migrations/writer-links.d.ts +2 -0
  156. package/dist-lib/lib/core/migrations/writer-links.js +32 -0
  157. package/dist-lib/lib/core/project-keys.d.ts +6 -0
  158. package/dist-lib/lib/core/project-keys.js +11 -0
  159. package/dist-lib/lib/core/public-mesh.d.ts +3 -0
  160. package/dist-lib/lib/core/public-mesh.js +10 -8
  161. package/dist-lib/lib/core/run-requests.d.ts +3 -0
  162. package/dist-lib/lib/core/run-requests.js +21 -1
  163. package/dist-lib/lib/core/skill-availability.d.ts +33 -0
  164. package/dist-lib/lib/core/skill-availability.js +67 -0
  165. package/dist-lib/lib/core/sync/background.d.ts +0 -1
  166. package/dist-lib/lib/core/sync/background.js +2 -1
  167. package/dist-lib/lib/core/sync/changed.d.ts +4 -2
  168. package/dist-lib/lib/core/sync/changed.js +1 -1
  169. package/dist-lib/lib/core/sync/index.js +52 -10
  170. package/dist-lib/lib/core/sync/view-updates.d.ts +18 -12
  171. package/dist-lib/lib/core/sync/view-updates.js +82 -91
  172. package/dist-lib/lib/core/sync-status.js +97 -41
  173. package/dist-lib/lib/core/tool-activity.js +6 -12
  174. package/dist-lib/lib/core/tool-configs.js +17 -29
  175. package/dist-lib/lib/core/upgrade-summary.d.ts +19 -0
  176. package/dist-lib/lib/core/upgrade-summary.js +67 -0
  177. package/dist-lib/lib/core/view-read.d.ts +4 -0
  178. package/dist-lib/lib/core/view-read.js +23 -0
  179. package/dist-lib/lib/core/workspace-upgrade.d.ts +7 -0
  180. package/dist-lib/lib/core/workspace-upgrade.js +27 -16
  181. package/dist-lib/lib/core.d.ts +45 -42
  182. package/dist-lib/lib/core.js +675 -640
  183. package/dist-lib/lib/errors.d.ts +24 -0
  184. package/dist-lib/lib/errors.js +24 -0
  185. package/dist-lib/lib/llm-model-names.d.ts +1 -1
  186. package/dist-lib/lib/llm-model-names.js +1 -1
  187. package/dist-lib/lib/mesh-scoped-engine.js +4 -0
  188. package/dist-lib/lib/model-context.js +1 -2
  189. package/dist-lib/lib/model-download.d.ts +6 -1
  190. package/dist-lib/lib/model-download.js +16 -3
  191. package/dist-lib/lib/oauth/resolve.js +29 -8
  192. package/dist-lib/lib/oauth/token-exchange-core.js +11 -0
  193. package/dist-lib/lib/probe-rounds.d.ts +7 -2
  194. package/dist-lib/lib/probe-rounds.js +6 -1
  195. package/dist-lib/lib/run-transcript.d.ts +4 -1
  196. package/dist-lib/lib/run-transcript.js +15 -6
  197. package/dist-lib/schema/engine.js +83 -6
  198. package/dist-lib/schema/indexes.d.ts +3 -0
  199. package/dist-lib/schema/indexes.js +5 -0
  200. package/dist-lib/schema/local.js +11 -2
  201. package/dist-lib/schema/qvac.js +49 -5
  202. package/dist-lib/spec/bind.js +34 -0
  203. package/dist-lib/spec/calls.js +5 -0
  204. package/dist-lib/spec/capabilities.d.ts +17 -0
  205. package/dist-lib/spec/hrpc/hrpc.json +65 -0
  206. package/dist-lib/spec/hrpc/index.js +68 -5
  207. package/dist-lib/spec/hrpc/messages.js +260 -23
  208. package/dist-lib/spec/hyperschema/index.js +260 -23
  209. package/dist-lib/spec/hyperschema/schema.json +181 -0
  210. package/dist-lib/spec/hyperschema/types.d.ts +48 -0
  211. package/dist-lib/spec/local/hyperdb/messages.js +270 -224
  212. package/dist-lib/spec/local/hyperschema/index.js +73 -38
  213. package/dist-lib/spec/local/hyperschema/schema.json +31 -0
  214. package/dist-lib/spec/local/hyperschema/types.d.ts +8 -0
  215. package/dist-lib/spec/mesh/hyperdb/db.json +39 -2
  216. package/dist-lib/spec/mesh/hyperdb/index.js +120 -3
  217. package/dist-lib/spec/mesh/hyperdb/messages.js +1328 -838
  218. package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +30 -0
  219. package/dist-lib/spec/mesh/hyperdispatch/index.js +86 -1
  220. package/dist-lib/spec/mesh/hyperdispatch/messages.js +682 -287
  221. package/dist-lib/spec/mesh/hyperschema/index.js +682 -287
  222. package/dist-lib/spec/mesh/hyperschema/schema.json +201 -0
  223. package/dist-lib/spec/mesh/hyperschema/types.d.ts +52 -0
  224. package/package.json +82 -71
  225. package/tui/README.md +52 -0
  226. package/tui/app.mjs +69 -12
  227. package/tui/boot.mjs +27 -6
  228. package/tui/cli.mjs +93 -0
  229. package/tui/index.mjs +2 -87
  230. package/tui/lib/attachment-files.mjs +82 -0
  231. package/tui/lib/reopen-meshes.mjs +15 -0
  232. package/tui/lib/updater.mjs +86 -0
  233. package/tui/main.mjs +29 -57
  234. package/worker/assistant-sidecar.mjs +10 -3
  235. package/worker/stow-entry.mjs +3 -52
  236. package/dist-lib/lib/core/chat-project.d.ts +0 -2
  237. package/dist-lib/lib/core/chat-project.js +0 -15
package/tui/main.mjs CHANGED
@@ -1,15 +1,20 @@
1
1
  // the TUI itself: draws the first frame, then imports boot.mjs, the engine side, behind it
2
2
  import fs from 'bare-fs'
3
- import os from 'bare-os'
4
3
  import process from 'bare-process'
5
4
  import tui from 'bare-tui'
5
+ import pear from 'bare-tui-updater/pear'
6
6
  import { spawn } from 'child_process'
7
7
  import path from 'path'
8
8
  import { readBootTiming } from './lib/boot-timing.mjs'
9
+ import { fileToAttachment, resolveFileAttachment } from './lib/attachment-files.mjs'
10
+ import { resolveLocalPath } from './lib/local-path.mjs'
11
+ import { reopenMeshes } from './lib/reopen-meshes.mjs'
12
+ import { applyUnattended, startUpdater } from './lib/updater.mjs'
9
13
  import { ChatApp } from './app.mjs'
10
14
  import b4a from 'b4a'
11
15
 
12
16
  const { Program } = tui
17
+ const { wire } = pear
13
18
 
14
19
  // the terminal writes a real sequence in one read, so this only has to beat human perception
15
20
  const ESCAPE_TIMEOUT_MS = 50
@@ -129,30 +134,6 @@ function readClipboard() {
129
134
  })
130
135
  }
131
136
 
132
- const MIME_TYPES = new Map([
133
- ['.png', 'image/png'],
134
- ['.jpg', 'image/jpeg'],
135
- ['.jpeg', 'image/jpeg'],
136
- ['.gif', 'image/gif'],
137
- ['.webp', 'image/webp'],
138
- ['.heic', 'image/heic'],
139
- ['.heif', 'image/heif'],
140
- ['.pdf', 'application/pdf'],
141
- ['.mov', 'video/quicktime'],
142
- ['.mp4', 'video/mp4'],
143
- ['.m4v', 'video/x-m4v'],
144
- ['.webm', 'video/webm'],
145
- ['.mkv', 'video/x-matroska'],
146
- ['.m4a', 'audio/mp4'],
147
- ['.mp3', 'audio/mpeg'],
148
- ['.wav', 'audio/wav'],
149
- ['.txt', 'text/plain'],
150
- ['.md', 'text/markdown'],
151
- ['.json', 'application/json']
152
- ])
153
- // the engine's own cap (lib/core/files/attachments.ts); a lower one here refused files it takes
154
- const MAX_ATTACHMENT_BYTES = 100 * 1024 * 1024
155
-
156
137
  // raw image data on the clipboard has no portable tty-side accessor, so only file paths attach
157
138
  async function resolvePastedFile() {
158
139
  const text = (await readClipboard()).trim()
@@ -160,7 +141,7 @@ async function resolvePastedFile() {
160
141
  return null
161
142
  }
162
143
 
163
- const file = expandFilePath(text)
144
+ const file = resolveLocalPath(text)
164
145
  let stat
165
146
  try {
166
147
  stat = fs.statSync(file)
@@ -175,29 +156,6 @@ async function resolvePastedFile() {
175
156
  return fileToAttachment(file, stat)
176
157
  }
177
158
 
178
- // `/attach` resolver: a named path -> attachment; throws on a bad path.
179
- function resolveFileAttachment(pathString) {
180
- return fileToAttachment(expandFilePath(pathString))
181
- }
182
-
183
- function expandFilePath(text) {
184
- const file = text.startsWith('file://') ? decodeURI(text.slice('file://'.length)) : text
185
- return file.startsWith('~/') ? path.join(os.homedir(), file.slice(2)) : file
186
- }
187
-
188
- function fileToAttachment(file, stat = fs.statSync(file)) {
189
- if (!stat.isFile()) throw new Error('not a regular file')
190
- if (stat.size > MAX_ATTACHMENT_BYTES) {
191
- throw new Error(`file too large (${MAX_ATTACHMENT_BYTES / (1024 * 1024)}MB cap)`)
192
- }
193
-
194
- return {
195
- fileName: path.basename(file),
196
- mimeType: MIME_TYPES.get(path.extname(file).toLowerCase()) ?? 'application/octet-stream',
197
- data: fs.readFileSync(file)
198
- }
199
- }
200
-
201
159
  // called only once the TUI released the tty, so it never fights bare-tui's live render
202
160
  function printBootTiming(booted) {
203
161
  if (process.env.QVAC_BOOT_TIMING !== '1' || !booted) return
@@ -208,21 +166,22 @@ function printBootTiming(booted) {
208
166
  console.log(`\nboot timing:\n${lines.join('\n')}`)
209
167
  }
210
168
 
211
- export function main(args) {
212
- run(args).catch((err) => {
169
+ export function main(args, { standalone = false, entries = null } = {}) {
170
+ run(args, standalone, entries).catch((err) => {
213
171
  console.error(err)
214
172
  Bare.exit(1)
215
173
  })
216
174
  }
217
175
 
218
- async function run(args) {
176
+ async function run(args, standalone, entries) {
177
+ const updates = standalone ? await startUpdater(entries) : null
219
178
  let program
220
179
  // the engine side, once it is up: its teardown, and what the boot report prints
221
180
  let booted = null
222
181
  // bring-up runs inside the TUI so its "starting up…" frame shows while ~1200 modules load
223
182
  const connect = async () => {
224
183
  const { boot } = await import('./boot.mjs')
225
- booted = await boot(args)
184
+ booted = await boot(args, entries)
226
185
  const { engine, skills, deviceId, meshInvite, modelName } = booted
227
186
 
228
187
  return { engine, skills, deviceId, meshInvite, modelName }
@@ -231,13 +190,20 @@ async function run(args) {
231
190
  // the engine's own handles hold the loop open until a signal arrives
232
191
  if (args.headless) {
233
192
  // armed before connect so a ctrl+C during a first-run model download still unwinds cleanly
234
- const shutdown = async () => {
193
+ const shutdown = async (code = 0) => {
194
+ await updates?.close()
235
195
  await booted?.close()
236
- Bare.exit(0)
196
+ Bare.exit(code)
237
197
  }
238
198
  process.on('SIGINT', () => void shutdown())
239
199
  process.on('SIGTERM', () => void shutdown())
240
- const { deviceId, meshInvite } = await connect()
200
+ if (updates) {
201
+ // 75 (EX_TEMPFAIL): non-zero, so Restart=on-failure brings the new build up too
202
+ applyUnattended(updates.updater, console.log, () => void shutdown(75))
203
+ }
204
+
205
+ const { engine, deviceId, meshInvite } = await connect()
206
+ await reopenMeshes(engine, console.log)
241
207
  console.log(`storage ${booted.storagePath}`)
242
208
  console.log(`log ${booted.logFile}`)
243
209
  console.log(`device ${booted.deviceName} ${b4a.toHex(deviceId)}`)
@@ -252,10 +218,15 @@ async function run(args) {
252
218
  requestRepaint: () => requestRepaint(() => program),
253
219
  copyToClipboard: (text) => copyToClipboard(text).catch(() => copyViaTerminal(program, text)),
254
220
  resolvePastedFile,
255
- resolveFileAttachment
221
+ resolveFileAttachment,
222
+ applyUpdate: updates ? () => updates.updater.applyUpdate() : null
256
223
  })
257
224
  // the transcript selects its own text, since the terminal can't while mouse tracking is on
258
225
  program = new Program(app, { mouse: 'drag' })
226
+ if (updates) {
227
+ wire(app.updateBanner, { updater: updates.updater, send: (msg) => program.send(msg) })
228
+ }
229
+
259
230
  // bracketed paste, or each pasted line arrives as keys and submits itself
260
231
  program.output.write('\x1b[?2004h')
261
232
  try {
@@ -272,6 +243,7 @@ async function run(args) {
272
243
  program.output.write('\x1b[?2004l')
273
244
  }
274
245
 
246
+ await updates?.close()
275
247
  await booted?.close()
276
248
  printBootTiming(booted)
277
249
  // don't wait for the child to unwind a blocking native call; close() already tore the sidecar down
@@ -37,7 +37,9 @@ export default stowEntry((ipc) => {
37
37
  eager = true,
38
38
  // undefined keeps Core's own choice; false lets a host start without fetching default models
39
39
  autoDownloadModels = undefined,
40
- fakeModels = false
40
+ fakeModels = false,
41
+ // the harness's knowledge plugin holds the index; false keeps core's own, rebuilt each start
42
+ harnessKnowledge = true
41
43
  } = JSON.parse(Bare.argv[2] || '{}')
42
44
 
43
45
  const bootstrapNodes = bootstrapJson ? JSON.parse(bootstrapJson) : undefined
@@ -87,8 +89,10 @@ export default stowEntry((ipc) => {
87
89
 
88
90
  // the host resets the session when its renderer reloads: same Core, a fresh client over one pipe
89
91
  ipc.on('session-reset', () => {
90
- core
91
- .connect(sessions.reset())
92
+ const stream = sessions.reset()
93
+ ipc
94
+ .send('session-reset')
95
+ .then(() => core.connect(stream))
92
96
  .catch((err) => logger.warn('assistant-sidecar', 'session reset failed', err?.message))
93
97
  })
94
98
 
@@ -123,6 +127,9 @@ export default stowEntry((ipc) => {
123
127
  imageClamps,
124
128
  musicModel,
125
129
  llm: { ...llm },
130
+ knowledge: harnessKnowledge
131
+ ? { dir: `${storage.root}/knowledge`, model: DEFAULT_RAG_MODEL }
132
+ : undefined,
126
133
  logger,
127
134
  eager
128
135
  }),
@@ -1,56 +1,7 @@
1
1
  /* global Bare */
2
2
  // bare-stow's bundle shim as a plain file, so the sidecar can be spawned without stowing
3
- import protocol from 'bare-stow/protocol'
3
+ import runtime from 'bare-stow-runtime/process'
4
4
 
5
- const ipc = protocol.attach(Bare.IPC)
5
+ const ipc = runtime.attach(Bare.IPC)
6
6
 
7
- let stop = null
8
- let readied = false
9
- let exited = false
10
-
11
- function ready() {
12
- if (readied) return
13
- readied = true
14
-
15
- ipc.send('ready')
16
- }
17
-
18
- async function shutdown(code, err = null) {
19
- if (exited) return
20
- exited = true
21
-
22
- try {
23
- if (stop) {
24
- await stop()
25
- }
26
- } catch (e) {
27
- err = err || e
28
- }
29
-
30
- if (err) {
31
- // the host may not be listening yet, so the reason also lands in the log
32
- console.error(err.stack || err.message || err)
33
- ipc.send('error', { message: err.message, stack: err.stack })
34
- }
35
-
36
- await ipc.send('exit', { code })
37
-
38
- Bare.exit(code)
39
- }
40
-
41
- ipc.on('terminate', () => shutdown(0))
42
-
43
- Bare.on('beforeExit', (exitCode) => shutdown(exitCode))
44
- .on('uncaughtException', (err) => shutdown(1, err))
45
- .on('unhandledRejection', (err) => shutdown(1, err))
46
-
47
- try {
48
- const entry = await import('./assistant-sidecar.mjs')
49
- const start = entry.default
50
-
51
- stop = (await start(ipc, ready)) || null
52
-
53
- ready()
54
- } catch (err) {
55
- shutdown(1, err)
56
- }
7
+ ipc.run(() => import('./assistant-sidecar.mjs'), ipc)
@@ -1,2 +0,0 @@
1
- import type { Mesh } from './mesh.ts';
2
- export declare function chatProject(chatMesh: Mesh, chatId: string, open: (projectId: string) => Promise<Mesh | null>): Promise<Mesh | null>;
@@ -1,15 +0,0 @@
1
- import { CHATS } from './collections.js';
2
- import { accountMember } from './contract/members.js';
3
- import { inProject } from './contract/projects.js';
4
- export async function chatProject(chatMesh, chatId, open) {
5
- if (chatMesh.role === 'project') {
6
- return chatMesh;
7
- }
8
- const chat = await chatMesh.view.get(CHATS, { id: chatId });
9
- const owner = chat?.projectId ? await accountMember(chatMesh.view) : null;
10
- const project = owner && chat?.projectId ? await open(chat.projectId) : null;
11
- if (!owner || project?.role !== 'project' || !(await inProject(project.view, owner))) {
12
- return null;
13
- }
14
- return project;
15
- }