@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.
- package/CHANGELOG.md +241 -3
- package/README.md +1 -0
- package/dist-lib/lib/api/attachments.d.ts +1 -1
- package/dist-lib/lib/api/attachments.js +11 -0
- package/dist-lib/lib/api/chunks.d.ts +4 -2
- package/dist-lib/lib/api/chunks.js +6 -3
- package/dist-lib/lib/api/device-routes.d.ts +6 -1
- package/dist-lib/lib/api/device-routes.js +20 -1
- package/dist-lib/lib/api/devices.js +6 -18
- package/dist-lib/lib/api/execution.d.ts +6 -2
- package/dist-lib/lib/api/execution.js +29 -3
- package/dist-lib/lib/api/host-run-log.d.ts +7 -1
- package/dist-lib/lib/api/host-run-log.js +3 -1
- package/dist-lib/lib/api/index.d.ts +3 -1
- package/dist-lib/lib/api/index.js +17 -6
- package/dist-lib/lib/api/members.js +13 -29
- package/dist-lib/lib/api/mesh.d.ts +2 -1
- package/dist-lib/lib/api/projects.d.ts +1 -1
- package/dist-lib/lib/api/projects.js +9 -5
- package/dist-lib/lib/api/rag-label.d.ts +4 -0
- package/dist-lib/lib/api/rag-label.js +21 -0
- package/dist-lib/lib/api/rag-lexical.d.ts +22 -0
- package/dist-lib/lib/api/rag-lexical.js +1058 -0
- package/dist-lib/lib/api/rag-manifest.d.ts +13 -0
- package/dist-lib/lib/api/rag-manifest.js +46 -0
- package/dist-lib/lib/api/rag-outline.d.ts +36 -0
- package/dist-lib/lib/api/rag-outline.js +426 -0
- package/dist-lib/lib/api/rag-plugin.d.ts +20 -0
- package/dist-lib/lib/api/rag-plugin.js +70 -0
- package/dist-lib/lib/api/rag-synthesis.d.ts +7 -0
- package/dist-lib/lib/api/rag-synthesis.js +102 -0
- package/dist-lib/lib/api/rag-targets.d.ts +23 -0
- package/dist-lib/lib/api/rag-targets.js +215 -0
- package/dist-lib/lib/api/rag-window.d.ts +5 -0
- package/dist-lib/lib/api/rag-window.js +46 -0
- package/dist-lib/lib/api/rag.d.ts +3 -2
- package/dist-lib/lib/api/rag.js +421 -184
- package/dist-lib/lib/api/served.js +8 -14
- package/dist-lib/lib/api/workspace.d.ts +8 -1
- package/dist-lib/lib/api/workspace.js +27 -13
- package/dist-lib/lib/assistant/harness.d.ts +9 -1
- package/dist-lib/lib/assistant/history.d.ts +11 -2
- package/dist-lib/lib/assistant/history.js +74 -4
- package/dist-lib/lib/assistant/media-round.d.ts +61 -0
- package/dist-lib/lib/assistant/media-round.js +111 -0
- package/dist-lib/lib/assistant/message.d.ts +7 -0
- package/dist-lib/lib/assistant/model-round.d.ts +19 -1
- package/dist-lib/lib/assistant/model-round.js +163 -28
- package/dist-lib/lib/assistant/pdf-pages.d.ts +16 -1
- package/dist-lib/lib/assistant/pdf-pages.js +67 -3
- package/dist-lib/lib/assistant/round-host.d.ts +22 -0
- package/dist-lib/lib/assistant/round-host.js +142 -8
- package/dist-lib/lib/assistant/upload.d.ts +12 -0
- package/dist-lib/lib/assistant/upload.js +36 -0
- package/dist-lib/lib/assistant-client.d.ts +1 -0
- package/dist-lib/lib/assistant-client.js +40 -19
- package/dist-lib/lib/assistant-tree.d.ts +2 -0
- package/dist-lib/lib/assistant-tree.js +48 -1
- package/dist-lib/lib/assistant.d.ts +18 -1
- package/dist-lib/lib/assistant.js +484 -95
- package/dist-lib/lib/client.d.ts +1 -0
- package/dist-lib/lib/client.js +4 -1
- package/dist-lib/lib/compaction.js +2 -2
- package/dist-lib/lib/core/agent.js +12 -45
- package/dist-lib/lib/core/approval-rules.js +1 -8
- package/dist-lib/lib/core/archived-mesh.d.ts +2 -1
- package/dist-lib/lib/core/archived-mesh.js +12 -8
- package/dist-lib/lib/core/chat-copy.d.ts +18 -3
- package/dist-lib/lib/core/chat-copy.js +74 -25
- package/dist-lib/lib/core/chat-fork.js +15 -6
- package/dist-lib/lib/core/chat-group.js +16 -24
- package/dist-lib/lib/core/chat-move.d.ts +9 -0
- package/dist-lib/lib/core/chat-move.js +94 -3
- package/dist-lib/lib/core/chat-order.js +12 -18
- package/dist-lib/lib/core/chat.js +38 -31
- package/dist-lib/lib/core/chunk.d.ts +2 -2
- package/dist-lib/lib/core/chunk.js +18 -25
- package/dist-lib/lib/core/collections.d.ts +2 -0
- package/dist-lib/lib/core/collections.js +2 -0
- package/dist-lib/lib/core/contract/activity.d.ts +4 -0
- package/dist-lib/lib/core/contract/activity.js +34 -4
- package/dist-lib/lib/core/contract/chat-group.d.ts +1 -0
- package/dist-lib/lib/core/contract/chat-group.js +21 -1
- package/dist-lib/lib/core/contract/chat.d.ts +9 -0
- package/dist-lib/lib/core/contract/chat.js +127 -5
- package/dist-lib/lib/core/contract/chunks.d.ts +1 -0
- package/dist-lib/lib/core/contract/chunks.js +37 -6
- package/dist-lib/lib/core/contract/features.d.ts +21 -0
- package/dist-lib/lib/core/contract/features.js +22 -0
- package/dist-lib/lib/core/contract/index.js +2 -0
- package/dist-lib/lib/core/contract/indexing.js +4 -2
- package/dist-lib/lib/core/contract/knowledge.js +5 -4
- package/dist-lib/lib/core/contract/members.js +16 -10
- package/dist-lib/lib/core/contract/mesh-kind.d.ts +1 -0
- package/dist-lib/lib/core/contract/mesh-kind.js +3 -1
- package/dist-lib/lib/core/contract/projects.d.ts +5 -0
- package/dist-lib/lib/core/contract/projects.js +13 -5
- package/dist-lib/lib/core/contract/roles.js +32 -4
- package/dist-lib/lib/core/contract/run-requests.d.ts +1 -0
- package/dist-lib/lib/core/contract/run-requests.js +35 -2
- package/dist-lib/lib/core/contract/seed-defaults.js +2 -2
- package/dist-lib/lib/core/contract/tool-configs.js +3 -2
- package/dist-lib/lib/core/contract/workspace.d.ts +2 -0
- package/dist-lib/lib/core/contract/workspace.js +40 -7
- package/dist-lib/lib/core/contract/writers.js +2 -2
- package/dist-lib/lib/core/departures.d.ts +3 -1
- package/dist-lib/lib/core/departures.js +3 -0
- package/dist-lib/lib/core/devices.js +1 -8
- package/dist-lib/lib/core/files/attachments.d.ts +2 -0
- package/dist-lib/lib/core/files/attachments.js +19 -1
- package/dist-lib/lib/core/files/index.d.ts +20 -4
- package/dist-lib/lib/core/files/index.js +132 -21
- package/dist-lib/lib/core/files/processing/document.d.ts +4 -0
- package/dist-lib/lib/core/files/processing/document.js +7 -0
- package/dist-lib/lib/core/files/processing/index.d.ts +13 -0
- package/dist-lib/lib/core/files/processing/index.js +144 -12
- package/dist-lib/lib/core/files/processing/protocol.js +13 -34
- package/dist-lib/lib/core/files/processing/state.d.ts +2 -0
- package/dist-lib/lib/core/files/rag/build.d.ts +19 -2
- package/dist-lib/lib/core/files/rag/build.js +123 -19
- package/dist-lib/lib/core/files/rag/failure.js +2 -1
- package/dist-lib/lib/core/files/rag/index.d.ts +11 -3
- package/dist-lib/lib/core/files/rag/index.js +13 -1
- package/dist-lib/lib/core/files/rag/load.d.ts +6 -3
- package/dist-lib/lib/core/files/rag/load.js +27 -6
- package/dist-lib/lib/core/files/rag/plugin-index.d.ts +32 -0
- package/dist-lib/lib/core/files/rag/plugin-index.js +127 -0
- package/dist-lib/lib/core/files/rag/produce.d.ts +5 -3
- package/dist-lib/lib/core/files/rag/produce.js +104 -16
- package/dist-lib/lib/core/files/rag/retrieval/full-text.d.ts +3 -1
- package/dist-lib/lib/core/files/rag/retrieval/full-text.js +62 -13
- package/dist-lib/lib/core/files/rag/text-cache.d.ts +28 -0
- package/dist-lib/lib/core/files/rag/text-cache.js +141 -0
- package/dist-lib/lib/core/files/records/knowledge.d.ts +1 -3
- package/dist-lib/lib/core/files/records/knowledge.js +7 -40
- package/dist-lib/lib/core/files/records/reclaim.js +5 -10
- package/dist-lib/lib/core/files/upload.js +68 -41
- package/dist-lib/lib/core/fs-drives.js +14 -26
- package/dist-lib/lib/core/invite.d.ts +1 -0
- package/dist-lib/lib/core/invite.js +4 -2
- package/dist-lib/lib/core/local/files.d.ts +1 -1
- package/dist-lib/lib/core/local/files.js +5 -5
- package/dist-lib/lib/core/local/index.d.ts +13 -6
- package/dist-lib/lib/core/local/index.js +103 -69
- package/dist-lib/lib/core/local/run-logs.d.ts +1 -1
- package/dist-lib/lib/core/local/run-logs.js +5 -5
- package/dist-lib/lib/core/mesh-processor.d.ts +19 -0
- package/dist-lib/lib/core/mesh-processor.js +87 -0
- package/dist-lib/lib/core/mesh.d.ts +48 -5
- package/dist-lib/lib/core/mesh.js +318 -129
- package/dist-lib/lib/core/migrations/agent-catalog.js +2 -8
- package/dist-lib/lib/core/migrations/agent-tools-scope.js +5 -11
- package/dist-lib/lib/core/migrations/workspace-from-0-21/index.d.ts +88 -0
- package/dist-lib/lib/core/migrations/workspace-from-0-21/index.js +731 -0
- package/dist-lib/lib/core/migrations/writer-links.d.ts +2 -0
- package/dist-lib/lib/core/migrations/writer-links.js +32 -0
- package/dist-lib/lib/core/project-keys.d.ts +6 -0
- package/dist-lib/lib/core/project-keys.js +11 -0
- package/dist-lib/lib/core/public-mesh.d.ts +3 -0
- package/dist-lib/lib/core/public-mesh.js +10 -8
- package/dist-lib/lib/core/run-requests.d.ts +3 -0
- package/dist-lib/lib/core/run-requests.js +21 -1
- package/dist-lib/lib/core/skill-availability.d.ts +33 -0
- package/dist-lib/lib/core/skill-availability.js +67 -0
- package/dist-lib/lib/core/sync/background.d.ts +0 -1
- package/dist-lib/lib/core/sync/background.js +2 -1
- package/dist-lib/lib/core/sync/changed.d.ts +4 -2
- package/dist-lib/lib/core/sync/changed.js +1 -1
- package/dist-lib/lib/core/sync/index.js +52 -10
- package/dist-lib/lib/core/sync/view-updates.d.ts +18 -12
- package/dist-lib/lib/core/sync/view-updates.js +82 -91
- package/dist-lib/lib/core/sync-status.js +97 -41
- package/dist-lib/lib/core/tool-activity.js +6 -12
- package/dist-lib/lib/core/tool-configs.js +17 -29
- package/dist-lib/lib/core/upgrade-summary.d.ts +19 -0
- package/dist-lib/lib/core/upgrade-summary.js +67 -0
- package/dist-lib/lib/core/view-read.d.ts +4 -0
- package/dist-lib/lib/core/view-read.js +23 -0
- package/dist-lib/lib/core/workspace-upgrade.d.ts +7 -0
- package/dist-lib/lib/core/workspace-upgrade.js +27 -16
- package/dist-lib/lib/core.d.ts +45 -42
- package/dist-lib/lib/core.js +675 -640
- package/dist-lib/lib/errors.d.ts +24 -0
- package/dist-lib/lib/errors.js +24 -0
- package/dist-lib/lib/llm-model-names.d.ts +1 -1
- package/dist-lib/lib/llm-model-names.js +1 -1
- package/dist-lib/lib/mesh-scoped-engine.js +4 -0
- package/dist-lib/lib/model-context.js +1 -2
- package/dist-lib/lib/model-download.d.ts +6 -1
- package/dist-lib/lib/model-download.js +16 -3
- package/dist-lib/lib/oauth/resolve.js +29 -8
- package/dist-lib/lib/oauth/token-exchange-core.js +11 -0
- package/dist-lib/lib/probe-rounds.d.ts +7 -2
- package/dist-lib/lib/probe-rounds.js +6 -1
- package/dist-lib/lib/run-transcript.d.ts +4 -1
- package/dist-lib/lib/run-transcript.js +15 -6
- package/dist-lib/schema/engine.js +83 -6
- package/dist-lib/schema/indexes.d.ts +3 -0
- package/dist-lib/schema/indexes.js +5 -0
- package/dist-lib/schema/local.js +11 -2
- package/dist-lib/schema/qvac.js +49 -5
- package/dist-lib/spec/bind.js +34 -0
- package/dist-lib/spec/calls.js +5 -0
- package/dist-lib/spec/capabilities.d.ts +17 -0
- package/dist-lib/spec/hrpc/hrpc.json +65 -0
- package/dist-lib/spec/hrpc/index.js +68 -5
- package/dist-lib/spec/hrpc/messages.js +260 -23
- package/dist-lib/spec/hyperschema/index.js +260 -23
- package/dist-lib/spec/hyperschema/schema.json +181 -0
- package/dist-lib/spec/hyperschema/types.d.ts +48 -0
- package/dist-lib/spec/local/hyperdb/messages.js +270 -224
- package/dist-lib/spec/local/hyperschema/index.js +73 -38
- package/dist-lib/spec/local/hyperschema/schema.json +31 -0
- package/dist-lib/spec/local/hyperschema/types.d.ts +8 -0
- package/dist-lib/spec/mesh/hyperdb/db.json +39 -2
- package/dist-lib/spec/mesh/hyperdb/index.js +120 -3
- package/dist-lib/spec/mesh/hyperdb/messages.js +1328 -838
- package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +30 -0
- package/dist-lib/spec/mesh/hyperdispatch/index.js +86 -1
- package/dist-lib/spec/mesh/hyperdispatch/messages.js +682 -287
- package/dist-lib/spec/mesh/hyperschema/index.js +682 -287
- package/dist-lib/spec/mesh/hyperschema/schema.json +201 -0
- package/dist-lib/spec/mesh/hyperschema/types.d.ts +52 -0
- package/package.json +82 -71
- package/tui/README.md +52 -0
- package/tui/app.mjs +69 -12
- package/tui/boot.mjs +27 -6
- package/tui/cli.mjs +93 -0
- package/tui/index.mjs +2 -87
- package/tui/lib/attachment-files.mjs +82 -0
- package/tui/lib/reopen-meshes.mjs +15 -0
- package/tui/lib/updater.mjs +86 -0
- package/tui/main.mjs +29 -57
- package/worker/assistant-sidecar.mjs +10 -3
- package/worker/stow-entry.mjs +3 -52
- package/dist-lib/lib/core/chat-project.d.ts +0 -2
- 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 =
|
|
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(
|
|
196
|
+
Bare.exit(code)
|
|
237
197
|
}
|
|
238
198
|
process.on('SIGINT', () => void shutdown())
|
|
239
199
|
process.on('SIGTERM', () => void shutdown())
|
|
240
|
-
|
|
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
|
-
|
|
91
|
-
|
|
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
|
}),
|
package/worker/stow-entry.mjs
CHANGED
|
@@ -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
|
|
3
|
+
import runtime from 'bare-stow-runtime/process'
|
|
4
4
|
|
|
5
|
-
const ipc =
|
|
5
|
+
const ipc = runtime.attach(Bare.IPC)
|
|
6
6
|
|
|
7
|
-
|
|
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,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
|
-
}
|