@qvac/core 1.0.0-rc.8 → 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 +234 -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/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 -181
- 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 +12 -0
- package/dist-lib/lib/assistant/model-round.js +130 -17
- 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 +41 -1
- package/dist-lib/lib/assistant.d.ts +15 -0
- package/dist-lib/lib/assistant.js +474 -89
- 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 +39 -42
- package/dist-lib/lib/core.js +661 -639
- package/dist-lib/lib/errors.d.ts +20 -0
- package/dist-lib/lib/errors.js +20 -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/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 +75 -70
- package/tui/README.md +2 -1
- package/tui/app.mjs +28 -7
- package/tui/boot.mjs +5 -1
- package/tui/lib/attachment-files.mjs +82 -0
- package/tui/lib/reopen-meshes.mjs +15 -0
- package/tui/main.mjs +4 -43
- package/worker/assistant-sidecar.mjs +10 -3
- package/worker/stow-entry.mjs +3 -52
package/tui/app.mjs
CHANGED
|
@@ -38,6 +38,7 @@ import {
|
|
|
38
38
|
turnDone,
|
|
39
39
|
turnsFromChunks
|
|
40
40
|
} from './lib/render.mjs'
|
|
41
|
+
import { skippedLine } from './lib/attachment-files.mjs'
|
|
41
42
|
import { exportMarkdown } from './lib/export.mjs'
|
|
42
43
|
import { paintSelection, selectionText } from './lib/select.mjs'
|
|
43
44
|
import { center, splash } from './lib/splash.mjs'
|
|
@@ -233,7 +234,11 @@ const COMMANDS = [
|
|
|
233
234
|
desc: "the agent's toolset switches and the tools in each; space toggles a set"
|
|
234
235
|
},
|
|
235
236
|
{ name: 'permissions', desc: "the agent's approval mode; space toggles" },
|
|
236
|
-
{
|
|
237
|
+
{
|
|
238
|
+
name: 'attach',
|
|
239
|
+
desc: "attach local files, or a directory's document files, to this chat by path",
|
|
240
|
+
palette: true
|
|
241
|
+
},
|
|
237
242
|
{
|
|
238
243
|
name: 'save',
|
|
239
244
|
desc: 'download the latest (or n-th) attachment to ~/Downloads',
|
|
@@ -1920,7 +1925,6 @@ export class ChatApp {
|
|
|
1920
1925
|
// clipboard access is host plumbing, not app logic; null disables the shortcut
|
|
1921
1926
|
this._copyToClipboard = copyToClipboard || null
|
|
1922
1927
|
this._resolvePastedFile = resolvePastedFile || null
|
|
1923
|
-
// `/attach <path>` resolver: named path -> attachment, or throws.
|
|
1924
1928
|
this._resolveFileAttachment = resolveFileAttachment || null
|
|
1925
1929
|
this.updateBanner = applyUpdate
|
|
1926
1930
|
? updateBanner.create({ onAccept: applyUpdate, acceptKey: 'ctrl+u' })
|
|
@@ -2554,7 +2558,7 @@ export class ChatApp {
|
|
|
2554
2558
|
' /files — show upload progress, local readiness, and failures for this chat',
|
|
2555
2559
|
' /compact — fold the older turns of this chat into a summary now (what a full context window triggers on its own); the notice shows the summary or why the fold was refused',
|
|
2556
2560
|
' /usage — this chat’s context usage as the last run reported it: the window, how much of it is in use, and what the prompt spends it on (conversation, system prompt, agent instructions, skills, tools)',
|
|
2557
|
-
|
|
2561
|
+
" /attach <path> [<path> …] — attach local files, or a directory's document files, to this chat (quote paths that contain spaces)",
|
|
2558
2562
|
' /save [n] — download the latest (or n-th) attachment to ~/Downloads',
|
|
2559
2563
|
' /export [n] — write the last run (or last n) to a markdown file: prompt, thinking, answer, tools',
|
|
2560
2564
|
'',
|
|
@@ -3254,12 +3258,29 @@ export class ChatApp {
|
|
|
3254
3258
|
return run(async () => {
|
|
3255
3259
|
const lines = []
|
|
3256
3260
|
for (const p of paths) {
|
|
3261
|
+
const failure = (label, err) =>
|
|
3262
|
+
lines.push(`✗ ${label} — ${err.code === 'ENOENT' ? 'no such file' : err.message}`)
|
|
3263
|
+
let resolved
|
|
3257
3264
|
try {
|
|
3258
|
-
|
|
3259
|
-
await app._uploadAttachment(file)
|
|
3260
|
-
lines.push(`attached ${file.fileName} (${file.data.length}B) ✓`)
|
|
3265
|
+
resolved = app._resolveFileAttachment(p)
|
|
3261
3266
|
} catch (err) {
|
|
3262
|
-
|
|
3267
|
+
failure(p, err)
|
|
3268
|
+
continue
|
|
3269
|
+
}
|
|
3270
|
+
|
|
3271
|
+
for (const { path: source, read } of resolved.files) {
|
|
3272
|
+
try {
|
|
3273
|
+
const file = read()
|
|
3274
|
+
await app._uploadAttachment(file)
|
|
3275
|
+
lines.push(`attached ${file.fileName} (${file.data.length}B) ✓`)
|
|
3276
|
+
} catch (err) {
|
|
3277
|
+
failure(source, err)
|
|
3278
|
+
}
|
|
3279
|
+
}
|
|
3280
|
+
|
|
3281
|
+
const skipped = skippedLine(resolved.skipped)
|
|
3282
|
+
if (skipped) {
|
|
3283
|
+
lines.push(skipped)
|
|
3263
3284
|
}
|
|
3264
3285
|
}
|
|
3265
3286
|
|
package/tui/boot.mjs
CHANGED
|
@@ -21,6 +21,7 @@ async function resolvePaths(entries) {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
const harnessSpecifier = '@qvac/harness/worker/stow-entry.mjs'
|
|
24
25
|
const sidecarEntry = fileURLToPath(new URL('../worker/stow-entry.mjs', import.meta.url))
|
|
25
26
|
if (!fs.existsSync(sidecarEntry)) {
|
|
26
27
|
throw new Error(`assistant sidecar entry missing at ${sidecarEntry}`)
|
|
@@ -29,7 +30,8 @@ async function resolvePaths(entries) {
|
|
|
29
30
|
return {
|
|
30
31
|
// imported here, as at load it reads a path from import.meta.url, which a bundle does not have
|
|
31
32
|
skillsDir: (await import('@qvac/skills')).skillsDir,
|
|
32
|
-
|
|
33
|
+
// a variable, as bare-pack follows a literal and would bundle the harness graph into duck again
|
|
34
|
+
harnessEntry: fileURLToPath(import.meta.resolve(harnessSpecifier)),
|
|
33
35
|
sidecarEntry
|
|
34
36
|
}
|
|
35
37
|
}
|
|
@@ -139,6 +141,8 @@ export async function boot(args, entries = null) {
|
|
|
139
141
|
},
|
|
140
142
|
skillsDir,
|
|
141
143
|
harnessEntry,
|
|
144
|
+
// replaces the sidecar's default, so its cache types are restated; 4 replies decode at once
|
|
145
|
+
llm: { kvCacheK: 'q8_0', kvCacheV: 'q8_0', slots: 4 },
|
|
142
146
|
fakeModels: args.fakeModels || process.env.QVAC_FAKE_MODELS === '1',
|
|
143
147
|
// only the image keys cross: the arg is argv, readable by anything that can list processes
|
|
144
148
|
imageEnv: Object.fromEntries(
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import { RAG_ACCEPT_EXTENSIONS } from '../../dist-lib/lib/core/files/rag/document-types.js'
|
|
4
|
+
import { resolveLocalPath } from './local-path.mjs'
|
|
5
|
+
|
|
6
|
+
const OPENXML = 'application/vnd.openxmlformats-officedocument'
|
|
7
|
+
const MIME_TYPES = new Map([
|
|
8
|
+
['.png', 'image/png'],
|
|
9
|
+
['.jpg', 'image/jpeg'],
|
|
10
|
+
['.jpeg', 'image/jpeg'],
|
|
11
|
+
['.gif', 'image/gif'],
|
|
12
|
+
['.webp', 'image/webp'],
|
|
13
|
+
['.heic', 'image/heic'],
|
|
14
|
+
['.heif', 'image/heif'],
|
|
15
|
+
['.pdf', 'application/pdf'],
|
|
16
|
+
['.mov', 'video/quicktime'],
|
|
17
|
+
['.mp4', 'video/mp4'],
|
|
18
|
+
['.m4v', 'video/x-m4v'],
|
|
19
|
+
['.webm', 'video/webm'],
|
|
20
|
+
['.mkv', 'video/x-matroska'],
|
|
21
|
+
['.m4a', 'audio/mp4'],
|
|
22
|
+
['.mp3', 'audio/mpeg'],
|
|
23
|
+
['.wav', 'audio/wav'],
|
|
24
|
+
['.txt', 'text/plain'],
|
|
25
|
+
['.md', 'text/markdown'],
|
|
26
|
+
['.json', 'application/json'],
|
|
27
|
+
['.csv', 'text/csv'],
|
|
28
|
+
['.rtf', 'application/rtf'],
|
|
29
|
+
['.docx', `${OPENXML}.wordprocessingml.document`],
|
|
30
|
+
['.xlsx', `${OPENXML}.spreadsheetml.sheet`],
|
|
31
|
+
['.pptx', `${OPENXML}.presentationml.presentation`]
|
|
32
|
+
])
|
|
33
|
+
const DIRECTORY_EXTENSIONS = new Set([...RAG_ACCEPT_EXTENSIONS, '.docx', '.xlsx', '.pptx'])
|
|
34
|
+
const MAX_ATTACHMENT_BYTES = 100 * 1024 * 1024
|
|
35
|
+
|
|
36
|
+
export function fileToAttachment(file, stat = fs.statSync(file)) {
|
|
37
|
+
if (!stat.isFile()) throw new Error('not a regular file')
|
|
38
|
+
if (stat.size > MAX_ATTACHMENT_BYTES) {
|
|
39
|
+
throw new Error(`file too large (${MAX_ATTACHMENT_BYTES / (1024 * 1024)}MB cap)`)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
fileName: path.basename(file),
|
|
44
|
+
mimeType: MIME_TYPES.get(path.extname(file).toLowerCase()) ?? 'application/octet-stream',
|
|
45
|
+
data: fs.readFileSync(file)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const MAX_SKIPPED_LISTED = 10
|
|
50
|
+
|
|
51
|
+
export function resolveFileAttachment(pathString) {
|
|
52
|
+
const target = resolveLocalPath(pathString)
|
|
53
|
+
const stat = fs.statSync(target)
|
|
54
|
+
if (!stat.isDirectory()) {
|
|
55
|
+
return { files: [{ path: target, read: () => fileToAttachment(target, stat) }], skipped: [] }
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const entries = fs
|
|
59
|
+
.readdirSync(target, { withFileTypes: true })
|
|
60
|
+
.filter((entry) => !entry.name.startsWith('.') && !entry.isDirectory())
|
|
61
|
+
.sort((a, b) => (a.name < b.name ? -1 : 1))
|
|
62
|
+
const supported = (entry) => DIRECTORY_EXTENSIONS.has(path.extname(entry.name).toLowerCase())
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
files: entries.filter(supported).map((entry) => {
|
|
66
|
+
const file = path.join(target, entry.name)
|
|
67
|
+
|
|
68
|
+
return { path: file, read: () => fileToAttachment(file) }
|
|
69
|
+
}),
|
|
70
|
+
skipped: entries.filter((entry) => !supported(entry)).map((entry) => entry.name)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function skippedLine(skipped) {
|
|
75
|
+
if (skipped.length === 0) {
|
|
76
|
+
return null
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const listed = skipped.slice(0, MAX_SKIPPED_LISTED).join(', ')
|
|
80
|
+
|
|
81
|
+
return `skipped ${skipped.length} unsupported: ${listed}${skipped.length > MAX_SKIPPED_LISTED ? ', …' : ''}`
|
|
82
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Core opens a saved mesh only when a route names it, and a headless duck names none
|
|
2
|
+
export async function reopenMeshes(engine, log) {
|
|
3
|
+
const { meshes } = await engine.listMeshes({})
|
|
4
|
+
await Promise.all(
|
|
5
|
+
(meshes ?? [])
|
|
6
|
+
.filter((mesh) => !mesh.open)
|
|
7
|
+
.map(async ({ meshId }) => {
|
|
8
|
+
try {
|
|
9
|
+
await engine.openMesh({ meshId })
|
|
10
|
+
} catch (error) {
|
|
11
|
+
log(`could not reopen mesh ${meshId.slice(0, 8)}: ${error.message}`)
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
)
|
|
15
|
+
}
|
package/tui/main.mjs
CHANGED
|
@@ -6,7 +6,9 @@ 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'
|
|
9
10
|
import { resolveLocalPath } from './lib/local-path.mjs'
|
|
11
|
+
import { reopenMeshes } from './lib/reopen-meshes.mjs'
|
|
10
12
|
import { applyUnattended, startUpdater } from './lib/updater.mjs'
|
|
11
13
|
import { ChatApp } from './app.mjs'
|
|
12
14
|
import b4a from 'b4a'
|
|
@@ -132,30 +134,6 @@ function readClipboard() {
|
|
|
132
134
|
})
|
|
133
135
|
}
|
|
134
136
|
|
|
135
|
-
const MIME_TYPES = new Map([
|
|
136
|
-
['.png', 'image/png'],
|
|
137
|
-
['.jpg', 'image/jpeg'],
|
|
138
|
-
['.jpeg', 'image/jpeg'],
|
|
139
|
-
['.gif', 'image/gif'],
|
|
140
|
-
['.webp', 'image/webp'],
|
|
141
|
-
['.heic', 'image/heic'],
|
|
142
|
-
['.heif', 'image/heif'],
|
|
143
|
-
['.pdf', 'application/pdf'],
|
|
144
|
-
['.mov', 'video/quicktime'],
|
|
145
|
-
['.mp4', 'video/mp4'],
|
|
146
|
-
['.m4v', 'video/x-m4v'],
|
|
147
|
-
['.webm', 'video/webm'],
|
|
148
|
-
['.mkv', 'video/x-matroska'],
|
|
149
|
-
['.m4a', 'audio/mp4'],
|
|
150
|
-
['.mp3', 'audio/mpeg'],
|
|
151
|
-
['.wav', 'audio/wav'],
|
|
152
|
-
['.txt', 'text/plain'],
|
|
153
|
-
['.md', 'text/markdown'],
|
|
154
|
-
['.json', 'application/json']
|
|
155
|
-
])
|
|
156
|
-
// the engine's own cap (lib/core/files/attachments.ts); a lower one here refused files it takes
|
|
157
|
-
const MAX_ATTACHMENT_BYTES = 100 * 1024 * 1024
|
|
158
|
-
|
|
159
137
|
// raw image data on the clipboard has no portable tty-side accessor, so only file paths attach
|
|
160
138
|
async function resolvePastedFile() {
|
|
161
139
|
const text = (await readClipboard()).trim()
|
|
@@ -178,24 +156,6 @@ async function resolvePastedFile() {
|
|
|
178
156
|
return fileToAttachment(file, stat)
|
|
179
157
|
}
|
|
180
158
|
|
|
181
|
-
// `/attach` resolver: a named path -> attachment; throws on a bad path.
|
|
182
|
-
function resolveFileAttachment(pathString) {
|
|
183
|
-
return fileToAttachment(resolveLocalPath(pathString))
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function fileToAttachment(file, stat = fs.statSync(file)) {
|
|
187
|
-
if (!stat.isFile()) throw new Error('not a regular file')
|
|
188
|
-
if (stat.size > MAX_ATTACHMENT_BYTES) {
|
|
189
|
-
throw new Error(`file too large (${MAX_ATTACHMENT_BYTES / (1024 * 1024)}MB cap)`)
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
return {
|
|
193
|
-
fileName: path.basename(file),
|
|
194
|
-
mimeType: MIME_TYPES.get(path.extname(file).toLowerCase()) ?? 'application/octet-stream',
|
|
195
|
-
data: fs.readFileSync(file)
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
159
|
// called only once the TUI released the tty, so it never fights bare-tui's live render
|
|
200
160
|
function printBootTiming(booted) {
|
|
201
161
|
if (process.env.QVAC_BOOT_TIMING !== '1' || !booted) return
|
|
@@ -242,7 +202,8 @@ async function run(args, standalone, entries) {
|
|
|
242
202
|
applyUnattended(updates.updater, console.log, () => void shutdown(75))
|
|
243
203
|
}
|
|
244
204
|
|
|
245
|
-
const { deviceId, meshInvite } = await connect()
|
|
205
|
+
const { engine, deviceId, meshInvite } = await connect()
|
|
206
|
+
await reopenMeshes(engine, console.log)
|
|
246
207
|
console.log(`storage ${booted.storagePath}`)
|
|
247
208
|
console.log(`log ${booted.logFile}`)
|
|
248
209
|
console.log(`device ${booted.deviceName} ${b4a.toHex(deviceId)}`)
|
|
@@ -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)
|