@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/app.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// the bare-tui chat model, split from the host so it can be driven headlessly with a fake engine
|
|
2
2
|
import tui from 'bare-tui'
|
|
3
|
+
import updateBanner from 'bare-tui-updater'
|
|
3
4
|
import { spawn } from 'child_process'
|
|
4
5
|
import fs from 'fs'
|
|
5
6
|
import { TOOLSETS } from '@qvac/harness/lib/tools/toolsets.ts'
|
|
@@ -37,6 +38,7 @@ import {
|
|
|
37
38
|
turnDone,
|
|
38
39
|
turnsFromChunks
|
|
39
40
|
} from './lib/render.mjs'
|
|
41
|
+
import { skippedLine } from './lib/attachment-files.mjs'
|
|
40
42
|
import { exportMarkdown } from './lib/export.mjs'
|
|
41
43
|
import { paintSelection, selectionText } from './lib/select.mjs'
|
|
42
44
|
import { center, splash } from './lib/splash.mjs'
|
|
@@ -232,7 +234,11 @@ const COMMANDS = [
|
|
|
232
234
|
desc: "the agent's toolset switches and the tools in each; space toggles a set"
|
|
233
235
|
},
|
|
234
236
|
{ name: 'permissions', desc: "the agent's approval mode; space toggles" },
|
|
235
|
-
{
|
|
237
|
+
{
|
|
238
|
+
name: 'attach',
|
|
239
|
+
desc: "attach local files, or a directory's document files, to this chat by path",
|
|
240
|
+
palette: true
|
|
241
|
+
},
|
|
236
242
|
{
|
|
237
243
|
name: 'save',
|
|
238
244
|
desc: 'download the latest (or n-th) attachment to ~/Downloads',
|
|
@@ -1892,6 +1898,7 @@ export class ChatApp {
|
|
|
1892
1898
|
copyToClipboard,
|
|
1893
1899
|
resolvePastedFile,
|
|
1894
1900
|
resolveFileAttachment,
|
|
1901
|
+
applyUpdate,
|
|
1895
1902
|
saveDir,
|
|
1896
1903
|
skills,
|
|
1897
1904
|
openUrl
|
|
@@ -1918,8 +1925,10 @@ export class ChatApp {
|
|
|
1918
1925
|
// clipboard access is host plumbing, not app logic; null disables the shortcut
|
|
1919
1926
|
this._copyToClipboard = copyToClipboard || null
|
|
1920
1927
|
this._resolvePastedFile = resolvePastedFile || null
|
|
1921
|
-
// `/attach <path>` resolver: named path -> attachment, or throws.
|
|
1922
1928
|
this._resolveFileAttachment = resolveFileAttachment || null
|
|
1929
|
+
this.updateBanner = applyUpdate
|
|
1930
|
+
? updateBanner.create({ onAccept: applyUpdate, acceptKey: 'ctrl+u' })
|
|
1931
|
+
: null
|
|
1923
1932
|
this._selection = null // { anchor, focus, edge } in content cells, while a drag selects text
|
|
1924
1933
|
this._dragToken = 0 // stale-guards the edge auto-scroll beats
|
|
1925
1934
|
this._saveDir = saveDir || path.join(os.homedir(), 'Downloads')
|
|
@@ -2549,7 +2558,7 @@ export class ChatApp {
|
|
|
2549
2558
|
' /files — show upload progress, local readiness, and failures for this chat',
|
|
2550
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',
|
|
2551
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)',
|
|
2552
|
-
|
|
2561
|
+
" /attach <path> [<path> …] — attach local files, or a directory's document files, to this chat (quote paths that contain spaces)",
|
|
2553
2562
|
' /save [n] — download the latest (or n-th) attachment to ~/Downloads',
|
|
2554
2563
|
' /export [n] — write the last run (or last n) to a markdown file: prompt, thinking, answer, tools',
|
|
2555
2564
|
'',
|
|
@@ -3249,12 +3258,29 @@ export class ChatApp {
|
|
|
3249
3258
|
return run(async () => {
|
|
3250
3259
|
const lines = []
|
|
3251
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
|
|
3252
3264
|
try {
|
|
3253
|
-
|
|
3254
|
-
await app._uploadAttachment(file)
|
|
3255
|
-
lines.push(`attached ${file.fileName} (${file.data.length}B) ✓`)
|
|
3265
|
+
resolved = app._resolveFileAttachment(p)
|
|
3256
3266
|
} catch (err) {
|
|
3257
|
-
|
|
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)
|
|
3258
3284
|
}
|
|
3259
3285
|
}
|
|
3260
3286
|
|
|
@@ -7385,6 +7411,15 @@ export class ChatApp {
|
|
|
7385
7411
|
return [this, null]
|
|
7386
7412
|
}
|
|
7387
7413
|
|
|
7414
|
+
if (
|
|
7415
|
+
this.updateBanner &&
|
|
7416
|
+
(msg.type.startsWith('update.') ||
|
|
7417
|
+
(msg.type === 'spinner.tick' && msg.id === this.updateBanner.spinner.id))
|
|
7418
|
+
) {
|
|
7419
|
+
const [, cmd] = this.updateBanner.update(msg)
|
|
7420
|
+
return [this, cmd]
|
|
7421
|
+
}
|
|
7422
|
+
|
|
7388
7423
|
if (msg.type === 'spinner.tick') {
|
|
7389
7424
|
const [s, cmd] = this.spin.update(msg)
|
|
7390
7425
|
this.spin = s
|
|
@@ -7514,6 +7549,12 @@ export class ChatApp {
|
|
|
7514
7549
|
return this._toggleToolOutput()
|
|
7515
7550
|
}
|
|
7516
7551
|
|
|
7552
|
+
// only the accept chord reaches the banner: its own u/enter/esc are typing here
|
|
7553
|
+
if (this.updateBanner && key.matches(msg, 'ctrl+u')) {
|
|
7554
|
+
const [, cmd] = this.updateBanner.update(msg)
|
|
7555
|
+
return [this, cmd]
|
|
7556
|
+
}
|
|
7557
|
+
|
|
7517
7558
|
// typing dismisses an overlay into the input; other keys are swallowed so they can't leak through
|
|
7518
7559
|
if (this._models || this._selector || this.overlay || this._menu) {
|
|
7519
7560
|
const handled = this._overlayKey(msg)
|
|
@@ -7559,6 +7600,11 @@ export class ChatApp {
|
|
|
7559
7600
|
|
|
7560
7601
|
return [this, null]
|
|
7561
7602
|
}
|
|
7603
|
+
|
|
7604
|
+
if (['ready', 'applied', 'error'].includes(this.updateBanner?.state)) {
|
|
7605
|
+
this.updateBanner.update({ type: 'update.dismiss' })
|
|
7606
|
+
return [this, null]
|
|
7607
|
+
}
|
|
7562
7608
|
}
|
|
7563
7609
|
|
|
7564
7610
|
if (this.pendingApproval) {
|
|
@@ -8097,9 +8143,8 @@ export class ChatApp {
|
|
|
8097
8143
|
return rows.slice(start, start + max)
|
|
8098
8144
|
}
|
|
8099
8145
|
|
|
8100
|
-
|
|
8101
|
-
|
|
8102
|
-
const height = Math.max(1, this.height - CHROME_ROWS - (inputRows - 1))
|
|
8146
|
+
_fitViewport(inputRows, bannerRows = 0) {
|
|
8147
|
+
const height = Math.max(1, this.height - CHROME_ROWS - (inputRows - 1) - bannerRows)
|
|
8103
8148
|
if (this.vp.height === height) {
|
|
8104
8149
|
return
|
|
8105
8150
|
}
|
|
@@ -8235,7 +8280,17 @@ export class ChatApp {
|
|
|
8235
8280
|
.render(title.slice(0, Math.max(0, this.width - 4)))
|
|
8236
8281
|
|
|
8237
8282
|
const inputRows = this._inputRows()
|
|
8238
|
-
this.
|
|
8283
|
+
if (this.updateBanner) {
|
|
8284
|
+
this.updateBanner.width = this.width - 4
|
|
8285
|
+
}
|
|
8286
|
+
|
|
8287
|
+
let banner = this.updateBanner?.view() ?? ''
|
|
8288
|
+
const bannerRows = banner ? banner.split('\n').length : 0
|
|
8289
|
+
if (this.height - CHROME_ROWS - (inputRows.length - 1) - bannerRows < 1) {
|
|
8290
|
+
banner = ''
|
|
8291
|
+
}
|
|
8292
|
+
|
|
8293
|
+
this._fitViewport(inputRows.length, banner ? bannerRows : 0)
|
|
8239
8294
|
const lines = this._viewLines()
|
|
8240
8295
|
const vpLines =
|
|
8241
8296
|
this._selection?.region === 'transcript'
|
|
@@ -8275,7 +8330,9 @@ export class ChatApp {
|
|
|
8275
8330
|
// a wrapped footer row shifts the whole frame and scrolls the header off — never let it wrap
|
|
8276
8331
|
const footer = fg.dim.render(hints.slice(0, Math.max(0, this.width - 1)))
|
|
8277
8332
|
|
|
8278
|
-
return [header, body, this._skillsLine(), inputBox, footer].join(
|
|
8333
|
+
return [header, body, this._skillsLine(), inputBox, ...(banner ? [banner] : []), footer].join(
|
|
8334
|
+
'\n'
|
|
8335
|
+
)
|
|
8279
8336
|
}
|
|
8280
8337
|
}
|
|
8281
8338
|
|
package/tui/boot.mjs
CHANGED
|
@@ -10,12 +10,30 @@ import { Logger, toLoggerOptions } from '../dist-lib/lib/log.js'
|
|
|
10
10
|
import { configureSdkStorage } from '@qvac/harness/sdk-storage'
|
|
11
11
|
import { MODEL_CACHE_PATH_ENV, releaseChannel, resolveStorage } from '@qvac/harness/storage'
|
|
12
12
|
import sidecarRunner from 'bare-supervisor/runner/sidecar'
|
|
13
|
-
import { skillsDir } from '@qvac/skills'
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
async function resolvePaths(entries) {
|
|
15
|
+
if (entries) {
|
|
16
|
+
return {
|
|
17
|
+
// make stages the skills tree beside release.json
|
|
18
|
+
skillsDir: path.join(path.dirname(fileURLToPath(entries.release)), 'skills'),
|
|
19
|
+
harnessEntry: fileURLToPath(entries.harness),
|
|
20
|
+
sidecarEntry: fileURLToPath(entries.sidecar)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const harnessSpecifier = '@qvac/harness/worker/stow-entry.mjs'
|
|
25
|
+
const sidecarEntry = fileURLToPath(new URL('../worker/stow-entry.mjs', import.meta.url))
|
|
26
|
+
if (!fs.existsSync(sidecarEntry)) {
|
|
27
|
+
throw new Error(`assistant sidecar entry missing at ${sidecarEntry}`)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
// imported here, as at load it reads a path from import.meta.url, which a bundle does not have
|
|
32
|
+
skillsDir: (await import('@qvac/skills')).skillsDir,
|
|
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)),
|
|
35
|
+
sidecarEntry
|
|
36
|
+
}
|
|
19
37
|
}
|
|
20
38
|
|
|
21
39
|
// its stdout/stderr are pipes so native model logs reach the logger rather than this tty
|
|
@@ -82,8 +100,9 @@ async function joined(engine) {
|
|
|
82
100
|
}
|
|
83
101
|
|
|
84
102
|
// --join and --device-join are the headless way in, /join the interactive one
|
|
85
|
-
export async function boot(args) {
|
|
103
|
+
export async function boot(args, entries = null) {
|
|
86
104
|
const joining = bootInvite(args)
|
|
105
|
+
const { skillsDir, harnessEntry, sidecarEntry } = await resolvePaths(entries)
|
|
87
106
|
const connectStart = Date.now()
|
|
88
107
|
// only an explicit QVAC_MODEL overrides, or resuming a shared mesh rewrites the desktop's agent
|
|
89
108
|
const modelOverride = process.env.QVAC_MODEL || null
|
|
@@ -122,6 +141,8 @@ export async function boot(args) {
|
|
|
122
141
|
},
|
|
123
142
|
skillsDir,
|
|
124
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 },
|
|
125
146
|
fakeModels: args.fakeModels || process.env.QVAC_FAKE_MODELS === '1',
|
|
126
147
|
// only the image keys cross: the arg is argv, readable by anything that can list processes
|
|
127
148
|
imageEnv: Object.fromEntries(
|
package/tui/cli.mjs
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import fs from 'bare-fs'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import { fileURLToPath } from 'bare-url'
|
|
4
|
+
import { arg, command, description, flag, summary } from 'paparam'
|
|
5
|
+
|
|
6
|
+
const pluginsCommand = (name, info, ...modifiers) =>
|
|
7
|
+
command(name, summary(info), ...modifiers, async ({ args }) => {
|
|
8
|
+
const api = await import('./plugins.mjs')
|
|
9
|
+
try {
|
|
10
|
+
await api[name](...Object.values(args))
|
|
11
|
+
} catch (err) {
|
|
12
|
+
console.error(err.message)
|
|
13
|
+
Bare.exitCode = 1
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const plugins = command(
|
|
18
|
+
'plugins',
|
|
19
|
+
summary('list, enable, disable and install userland plugins in ~/.config/qv-ac'),
|
|
20
|
+
pluginsCommand('list', 'installed plugins and whether config.json loads them'),
|
|
21
|
+
pluginsCommand('enable', 'list a plugin in config.json', arg('<name>', 'plugin folder name')),
|
|
22
|
+
pluginsCommand(
|
|
23
|
+
'disable',
|
|
24
|
+
'drop a plugin from config.json, keeping its options',
|
|
25
|
+
arg('<name>', 'plugin folder name')
|
|
26
|
+
),
|
|
27
|
+
pluginsCommand(
|
|
28
|
+
'install',
|
|
29
|
+
'fetch a plugin folder from a git URL or a hyper:// drive key',
|
|
30
|
+
arg('<source>', 'git URL or hyper://<key>'),
|
|
31
|
+
arg('[name]', 'folder name; defaults to the repo name, required for hyper://')
|
|
32
|
+
)
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
const cmd = command(
|
|
36
|
+
'duck',
|
|
37
|
+
summary('the qvac assistant in your terminal'),
|
|
38
|
+
description(
|
|
39
|
+
"Storage defaults to the desktop app's release root, so duck resumes the mesh and chats it persists there. Environment variables are documented in tui/README.md."
|
|
40
|
+
),
|
|
41
|
+
flag('--storage|-s [dir]', 'a self-contained root, its own corestore and SDK home'),
|
|
42
|
+
flag('--temp', 'the same, in a throwaway dir'),
|
|
43
|
+
flag('--headless', 'no TUI: print the device invite and stream logs until ctrl+C'),
|
|
44
|
+
flag('--join|-j <invite>', 'join a mesh as a new member at boot (a member invite)'),
|
|
45
|
+
flag(
|
|
46
|
+
'--device-join <invite>',
|
|
47
|
+
'pair this device into the inviter’s account at boot (a device invite)'
|
|
48
|
+
),
|
|
49
|
+
flag('--fake-models', 'adds the quack model: a deterministic fake LLM for testing without AI'),
|
|
50
|
+
flag('--version|-v', 'versions of core, harness and the SDK'),
|
|
51
|
+
plugins
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
function versions(entries) {
|
|
55
|
+
const resolved = entries
|
|
56
|
+
? Object.entries(JSON.parse(fs.readFileSync(fileURLToPath(entries.release), 'utf8')).versions)
|
|
57
|
+
: [
|
|
58
|
+
['@qvac/core', packageVersion(fileURLToPath(new URL('../package.json', import.meta.url)))],
|
|
59
|
+
['@qvac/harness', resolvedVersion('@qvac/harness')],
|
|
60
|
+
['@qvac/sdk', resolvedVersion('@qvac/sdk')]
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
return resolved.map(([name, version]) => `${name.padEnd(14)} ${version}`).join('\n')
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function resolvedVersion(specifier) {
|
|
67
|
+
const entry = fileURLToPath(import.meta.resolve(specifier))
|
|
68
|
+
for (let dir = path.dirname(entry); dir !== path.dirname(dir); dir = path.dirname(dir)) {
|
|
69
|
+
const manifest = path.join(dir, 'package.json')
|
|
70
|
+
if (fs.existsSync(manifest)) {
|
|
71
|
+
return packageVersion(manifest)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return 'unknown'
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function packageVersion(manifest) {
|
|
79
|
+
return JSON.parse(fs.readFileSync(manifest, 'utf8')).version
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export async function cli({ argv, standalone = false, entries = null } = {}) {
|
|
83
|
+
const parsed = cmd.parse(argv)
|
|
84
|
+
if (parsed !== cmd) {
|
|
85
|
+
return
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (parsed.flags.version) {
|
|
89
|
+
console.log(versions(entries))
|
|
90
|
+
} else {
|
|
91
|
+
;(await import('./main.mjs')).main(parsed.flags, { standalone, entries })
|
|
92
|
+
}
|
|
93
|
+
}
|
package/tui/index.mjs
CHANGED
|
@@ -1,89 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env bare
|
|
2
|
-
|
|
3
|
-
import fs from 'bare-fs'
|
|
4
|
-
import path from 'path'
|
|
5
|
-
import { arg, command, description, flag, summary } from 'paparam'
|
|
2
|
+
import { cli } from './cli.mjs'
|
|
6
3
|
|
|
7
|
-
|
|
8
|
-
command(name, summary(info), ...modifiers, async ({ args }) => {
|
|
9
|
-
const api = await import('./plugins.mjs')
|
|
10
|
-
try {
|
|
11
|
-
await api[name](...Object.values(args))
|
|
12
|
-
} catch (err) {
|
|
13
|
-
console.error(err.message)
|
|
14
|
-
Bare.exitCode = 1
|
|
15
|
-
}
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
const plugins = command(
|
|
19
|
-
'plugins',
|
|
20
|
-
summary('list, enable, disable and install userland plugins in ~/.config/qv-ac'),
|
|
21
|
-
pluginsCommand('list', 'installed plugins and whether config.json loads them'),
|
|
22
|
-
pluginsCommand('enable', 'list a plugin in config.json', arg('<name>', 'plugin folder name')),
|
|
23
|
-
pluginsCommand(
|
|
24
|
-
'disable',
|
|
25
|
-
'drop a plugin from config.json, keeping its options',
|
|
26
|
-
arg('<name>', 'plugin folder name')
|
|
27
|
-
),
|
|
28
|
-
pluginsCommand(
|
|
29
|
-
'install',
|
|
30
|
-
'fetch a plugin folder from a git URL or a hyper:// drive key',
|
|
31
|
-
arg('<source>', 'git URL or hyper://<key>'),
|
|
32
|
-
arg('[name]', 'folder name; defaults to the repo name, required for hyper://')
|
|
33
|
-
)
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
const cmd = command(
|
|
37
|
-
'duck',
|
|
38
|
-
summary('the qvac assistant in your terminal'),
|
|
39
|
-
description(
|
|
40
|
-
"Storage defaults to the desktop app's release root, so duck resumes the mesh and chats it persists there. Environment variables are documented in tui/README.md."
|
|
41
|
-
),
|
|
42
|
-
flag('--storage|-s [dir]', 'a self-contained root, its own corestore and SDK home'),
|
|
43
|
-
flag('--temp', 'the same, in a throwaway dir'),
|
|
44
|
-
flag('--headless', 'no TUI: print the device invite and stream logs until ctrl+C'),
|
|
45
|
-
flag('--join|-j <invite>', 'join a mesh as a new member at boot (a member invite)'),
|
|
46
|
-
flag(
|
|
47
|
-
'--device-join <invite>',
|
|
48
|
-
'pair this device into the inviter’s account at boot (a device invite)'
|
|
49
|
-
),
|
|
50
|
-
flag('--fake-models', 'adds the quack model: a deterministic fake LLM for testing without AI'),
|
|
51
|
-
flag('--version|-v', 'versions of core, harness and the SDK'),
|
|
52
|
-
plugins
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
function versions() {
|
|
56
|
-
return [
|
|
57
|
-
['@qvac/core', packageVersion(new URL('../package.json', import.meta.url).pathname)],
|
|
58
|
-
['@qvac/harness', resolvedVersion('@qvac/harness')],
|
|
59
|
-
['@qvac/sdk', resolvedVersion('@qvac/sdk')]
|
|
60
|
-
]
|
|
61
|
-
.map(([name, version]) => `${name.padEnd(14)} ${version}`)
|
|
62
|
-
.join('\n')
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function resolvedVersion(specifier) {
|
|
66
|
-
const entry = new URL(import.meta.resolve(specifier)).pathname
|
|
67
|
-
for (let dir = path.dirname(entry); dir !== path.dirname(dir); dir = path.dirname(dir)) {
|
|
68
|
-
const manifest = path.join(dir, 'package.json')
|
|
69
|
-
if (fs.existsSync(manifest)) {
|
|
70
|
-
return packageVersion(manifest)
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return 'unknown'
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function packageVersion(manifest) {
|
|
78
|
-
return JSON.parse(fs.readFileSync(manifest, 'utf8')).version
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const cli = cmd.parse()
|
|
82
|
-
|
|
83
|
-
if (cli === cmd) {
|
|
84
|
-
if (cli.flags.version) {
|
|
85
|
-
console.log(versions())
|
|
86
|
-
} else {
|
|
87
|
-
;(await import('./main.mjs')).main(cli.flags)
|
|
88
|
-
}
|
|
89
|
-
}
|
|
4
|
+
await cli()
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import fs from 'bare-fs'
|
|
2
|
+
import os from 'bare-os'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
import Corestore from 'corestore'
|
|
5
|
+
import Hyperswarm from 'hyperswarm'
|
|
6
|
+
import PearRuntimeUpdater from 'pear-runtime-updater'
|
|
7
|
+
|
|
8
|
+
export async function startUpdater(entries) {
|
|
9
|
+
const { version, upgrade } = JSON.parse(fs.readFileSync(new URL(entries.release), 'utf8'))
|
|
10
|
+
if (!upgrade) {
|
|
11
|
+
return null
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const dir = appDir()
|
|
15
|
+
fs.mkdirSync(dir, { recursive: true })
|
|
16
|
+
|
|
17
|
+
const { default: LockFile } = await import('fs-native-lock')
|
|
18
|
+
const lock = new LockFile(path.join(dir, 'duck.lock'))
|
|
19
|
+
try {
|
|
20
|
+
await lock.lock()
|
|
21
|
+
} catch {
|
|
22
|
+
return null
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const store = new Corestore(path.join(dir, 'pear-runtime', 'corestore'))
|
|
26
|
+
const swarm = new Hyperswarm()
|
|
27
|
+
swarm.on('connection', (connection) => store.replicate(connection))
|
|
28
|
+
|
|
29
|
+
const app = os.execPath()
|
|
30
|
+
const updater = new PearRuntimeUpdater({
|
|
31
|
+
// the next build is swapped in by rename, so it downloads onto the executable's own volume
|
|
32
|
+
dir: path.join(path.dirname(app), '.duck-update'),
|
|
33
|
+
store,
|
|
34
|
+
version,
|
|
35
|
+
upgrade,
|
|
36
|
+
app,
|
|
37
|
+
name: os.platform() === 'win32' ? 'duck.exe' : 'duck'
|
|
38
|
+
})
|
|
39
|
+
updater.on('error', () => {})
|
|
40
|
+
|
|
41
|
+
// updater.close() waits out a download that can no longer finish once the swarm is gone
|
|
42
|
+
const close = async () => {
|
|
43
|
+
await swarm.destroy()
|
|
44
|
+
await store.close()
|
|
45
|
+
await lock.unlock()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
await updater.ready()
|
|
50
|
+
} catch (err) {
|
|
51
|
+
await close()
|
|
52
|
+
throw err
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
swarm.join(updater.drive.core.discoveryKey)
|
|
56
|
+
|
|
57
|
+
return { updater, close }
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function applyUnattended(updater, log, onInstalled) {
|
|
61
|
+
// closing the store on shutdown cancels a download in flight, which is not a failed update
|
|
62
|
+
const fail = (err) => err.code === 'REQUEST_CANCELLED' || log(`update failed: ${err.message}`)
|
|
63
|
+
const apply = () =>
|
|
64
|
+
updater.applyUpdate().then(() => {
|
|
65
|
+
log(`update v${updater.nextVersion} installed, exiting for the supervisor to restart`)
|
|
66
|
+
onInstalled()
|
|
67
|
+
}, fail)
|
|
68
|
+
|
|
69
|
+
updater.on('updated', apply)
|
|
70
|
+
updater.on('error', fail)
|
|
71
|
+
if (updater.updated) {
|
|
72
|
+
apply()
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function appDir() {
|
|
77
|
+
const home = os.homedir()
|
|
78
|
+
switch (os.platform()) {
|
|
79
|
+
case 'win32':
|
|
80
|
+
return path.join(home, 'AppData', 'Roaming', 'duck')
|
|
81
|
+
case 'darwin':
|
|
82
|
+
return path.join(home, 'Library', 'Application Support', 'duck')
|
|
83
|
+
default:
|
|
84
|
+
return path.join(home, '.config', 'duck')
|
|
85
|
+
}
|
|
86
|
+
}
|