@qvac/core 0.6.6 → 0.7.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 (123) hide show
  1. package/CHANGELOG.md +185 -1
  2. package/README.md +2 -0
  3. package/dist-lib/lib/api/app-config.d.ts +3 -1
  4. package/dist-lib/lib/api/app-config.js +15 -4
  5. package/dist-lib/lib/assistant/fake-models.d.ts +22 -0
  6. package/dist-lib/lib/assistant/fake-models.js +112 -0
  7. package/dist-lib/lib/assistant/harness.d.ts +10 -0
  8. package/dist-lib/lib/assistant/harness.js +26 -0
  9. package/dist-lib/lib/assistant/history.d.ts +5 -1
  10. package/dist-lib/lib/assistant/history.js +14 -2
  11. package/dist-lib/lib/assistant-tree.d.ts +4 -0
  12. package/dist-lib/lib/assistant-tree.js +45 -7
  13. package/dist-lib/lib/assistant.d.ts +16 -2
  14. package/dist-lib/lib/assistant.js +184 -44
  15. package/dist-lib/lib/constants.d.ts +6 -0
  16. package/dist-lib/lib/constants.js +6 -0
  17. package/dist-lib/lib/core/chat-activity.d.ts +1 -1
  18. package/dist-lib/lib/core/chat-activity.js +3 -0
  19. package/dist-lib/lib/core/collections.d.ts +1 -0
  20. package/dist-lib/lib/core/collections.js +1 -0
  21. package/dist-lib/lib/core/contract/compute.d.ts +1 -1
  22. package/dist-lib/lib/core/contract/compute.js +2 -1
  23. package/dist-lib/lib/core/contract/index.js +6 -1
  24. package/dist-lib/lib/core/contract/invites.d.ts +1 -11
  25. package/dist-lib/lib/core/contract/invites.js +3 -3
  26. package/dist-lib/lib/core/contract/mesh-seeds.d.ts +2 -0
  27. package/dist-lib/lib/core/contract/mesh-seeds.js +26 -0
  28. package/dist-lib/lib/core/contract/open-join.d.ts +2 -0
  29. package/dist-lib/lib/core/contract/open-join.js +57 -0
  30. package/dist-lib/lib/core/departures.d.ts +3 -0
  31. package/dist-lib/lib/core/departures.js +44 -1
  32. package/dist-lib/lib/core/fs-drives.js +9 -6
  33. package/dist-lib/lib/core/handoff-channel.d.ts +1 -0
  34. package/dist-lib/lib/core/handoff-channel.js +7 -2
  35. package/dist-lib/lib/core/harness-loan.d.ts +1 -0
  36. package/dist-lib/lib/core/harness-loan.js +7 -2
  37. package/dist-lib/lib/core/identity.d.ts +1 -1
  38. package/dist-lib/lib/core/identity.js +6 -4
  39. package/dist-lib/lib/core/invite.d.ts +2 -0
  40. package/dist-lib/lib/core/invite.js +6 -2
  41. package/dist-lib/lib/core/membership.d.ts +1 -12
  42. package/dist-lib/lib/core/membership.js +1 -94
  43. package/dist-lib/lib/core/mesh.d.ts +8 -13
  44. package/dist-lib/lib/core/mesh.js +41 -87
  45. package/dist-lib/lib/core/protocol-pairing.d.ts +11 -0
  46. package/dist-lib/lib/core/protocol-pairing.js +22 -0
  47. package/dist-lib/lib/core/sync/index.js +2 -16
  48. package/dist-lib/lib/core.d.ts +43 -49
  49. package/dist-lib/lib/core.js +451 -909
  50. package/dist-lib/lib/diagnostics.d.ts +7 -0
  51. package/dist-lib/lib/diagnostics.js +22 -0
  52. package/dist-lib/lib/doctor/checks.d.ts +15 -0
  53. package/dist-lib/lib/doctor/checks.js +269 -0
  54. package/dist-lib/lib/doctor/redact.d.ts +4 -0
  55. package/dist-lib/lib/doctor/redact.js +31 -0
  56. package/dist-lib/lib/doctor/render.d.ts +8 -0
  57. package/dist-lib/lib/doctor/render.js +83 -0
  58. package/dist-lib/lib/doctor/tree.d.ts +5 -0
  59. package/dist-lib/lib/doctor/tree.js +167 -0
  60. package/dist-lib/lib/downloads-allowed-pusher.d.ts +10 -0
  61. package/dist-lib/lib/downloads-allowed-pusher.js +37 -0
  62. package/dist-lib/lib/guards.d.ts +1 -0
  63. package/dist-lib/lib/guards.js +4 -0
  64. package/dist-lib/lib/inference-calls.js +1 -5
  65. package/dist-lib/lib/kv-cache-reclaim.d.ts +2 -1
  66. package/dist-lib/lib/kv-cache-reclaim.js +24 -0
  67. package/dist-lib/lib/mesh-scoped-engine.js +1 -0
  68. package/dist-lib/lib/model-download-status.d.ts +1 -1
  69. package/dist-lib/lib/model-download.d.ts +9 -1
  70. package/dist-lib/lib/model-download.js +48 -3
  71. package/dist-lib/lib/model-memory-cap.d.ts +29 -0
  72. package/dist-lib/lib/model-memory-cap.js +69 -0
  73. package/dist-lib/lib/models-watch.d.ts +1 -1
  74. package/dist-lib/lib/models-watch.js +4 -4
  75. package/dist-lib/lib/oauth/flow.js +1 -1
  76. package/dist-lib/lib/oauth/loopback.js +16 -2
  77. package/dist-lib/lib/oauth/redirect-types.d.ts +1 -0
  78. package/dist-lib/lib/run-replay.d.ts +26 -0
  79. package/dist-lib/lib/run-replay.js +107 -0
  80. package/dist-lib/schema/config.d.ts +1 -1
  81. package/dist-lib/schema/config.js +1 -1
  82. package/dist-lib/schema/content.js +9 -1
  83. package/dist-lib/schema/engine.js +30 -5
  84. package/dist-lib/schema/local.js +3 -2
  85. package/dist-lib/schema/qvac.js +18 -1
  86. package/dist-lib/spec/bind.js +3 -0
  87. package/dist-lib/spec/calls.js +1 -0
  88. package/dist-lib/spec/capabilities.d.ts +2 -0
  89. package/dist-lib/spec/config/hyperconf/index.js +1 -1
  90. package/dist-lib/spec/hrpc/hrpc.json +13 -0
  91. package/dist-lib/spec/hrpc/index.js +15 -3
  92. package/dist-lib/spec/hrpc/messages.js +646 -557
  93. package/dist-lib/spec/hyperschema/index.js +646 -557
  94. package/dist-lib/spec/hyperschema/schema.json +80 -0
  95. package/dist-lib/spec/hyperschema/types.d.ts +20 -3
  96. package/dist-lib/spec/local/hyperdb/messages.js +22 -10
  97. package/dist-lib/spec/local/hyperschema/index.js +16 -7
  98. package/dist-lib/spec/local/hyperschema/schema.json +10 -1
  99. package/dist-lib/spec/local/hyperschema/types.d.ts +3 -2
  100. package/dist-lib/spec/mesh/hyperdb/db.json +16 -1
  101. package/dist-lib/spec/mesh/hyperdb/index.js +71 -2
  102. package/dist-lib/spec/mesh/hyperdb/messages.js +477 -240
  103. package/dist-lib/spec/mesh/hyperdispatch/dispatch.json +13 -1
  104. package/dist-lib/spec/mesh/hyperdispatch/index.js +35 -1
  105. package/dist-lib/spec/mesh/hyperdispatch/messages.js +180 -7
  106. package/dist-lib/spec/mesh/hyperschema/index.js +180 -7
  107. package/dist-lib/spec/mesh/hyperschema/schema.json +98 -1
  108. package/dist-lib/spec/mesh/hyperschema/types.d.ts +26 -2
  109. package/package.json +9 -17
  110. package/tui/README.md +7 -1
  111. package/tui/app.mjs +245 -11
  112. package/tui/boot.mjs +1 -0
  113. package/tui/index.mjs +1 -0
  114. package/tui/lib/render.mjs +25 -1
  115. package/worker/assistant-sidecar.mjs +5 -2
  116. package/dist-lib/lib/core/device-invites.d.ts +0 -11
  117. package/dist-lib/lib/core/device-invites.js +0 -63
  118. package/dist-lib/lib/core/grant-expiry.d.ts +0 -11
  119. package/dist-lib/lib/core/grant-expiry.js +0 -66
  120. package/dist-lib/lib/core/mesh-seed-handoff.d.ts +0 -27
  121. package/dist-lib/lib/core/mesh-seed-handoff.js +0 -53
  122. package/dist-lib/lib/oauth/loopback.stub.d.ts +0 -3
  123. package/dist-lib/lib/oauth/loopback.stub.js +0 -6
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": 13,
2
+ "version": 14,
3
3
  "schema": [
4
4
  {
5
5
  "name": "chunk-type",
@@ -145,6 +145,10 @@
145
145
  {
146
146
  "key": "compacting",
147
147
  "version": 5
148
+ },
149
+ {
150
+ "key": "awaiting-download",
151
+ "version": 14
148
152
  }
149
153
  ],
150
154
  "strings": true
@@ -2095,6 +2099,16 @@
2095
2099
  "name": "inviterName",
2096
2100
  "type": "string",
2097
2101
  "version": 10
2102
+ },
2103
+ {
2104
+ "name": "deviceSeed",
2105
+ "type": "fixed32",
2106
+ "version": 14
2107
+ },
2108
+ {
2109
+ "name": "deviceProof",
2110
+ "type": "buffer",
2111
+ "version": 14
2098
2112
  }
2099
2113
  ]
2100
2114
  },
@@ -4156,6 +4170,89 @@
4156
4170
  "version": 1
4157
4171
  }
4158
4172
  ]
4173
+ },
4174
+ {
4175
+ "name": "open-join-v1",
4176
+ "namespace": "qvac",
4177
+ "compact": false,
4178
+ "flagsPosition": 1,
4179
+ "fields": [
4180
+ {
4181
+ "name": "signature",
4182
+ "required": true,
4183
+ "type": "buffer",
4184
+ "version": 14
4185
+ },
4186
+ {
4187
+ "name": "device",
4188
+ "type": "@qvac/device",
4189
+ "version": 14
4190
+ },
4191
+ {
4192
+ "name": "deviceId",
4193
+ "type": "fixed32",
4194
+ "version": 14
4195
+ },
4196
+ {
4197
+ "name": "deviceSignature",
4198
+ "type": "buffer",
4199
+ "version": 14
4200
+ },
4201
+ {
4202
+ "name": "member",
4203
+ "type": "@qvac/member",
4204
+ "version": 14
4205
+ },
4206
+ {
4207
+ "name": "memberClaim",
4208
+ "type": "buffer",
4209
+ "version": 14
4210
+ }
4211
+ ]
4212
+ },
4213
+ {
4214
+ "name": "open-join",
4215
+ "namespace": "qvac",
4216
+ "framed": false,
4217
+ "versions": [
4218
+ {
4219
+ "type": "@qvac/open-join-v1",
4220
+ "map": null,
4221
+ "version": 1
4222
+ }
4223
+ ]
4224
+ },
4225
+ {
4226
+ "name": "mesh-seed-v1",
4227
+ "namespace": "qvac",
4228
+ "compact": false,
4229
+ "flagsPosition": -1,
4230
+ "fields": [
4231
+ {
4232
+ "name": "meshKey",
4233
+ "required": true,
4234
+ "type": "fixed32",
4235
+ "version": 14
4236
+ },
4237
+ {
4238
+ "name": "seed",
4239
+ "required": true,
4240
+ "type": "fixed32",
4241
+ "version": 14
4242
+ }
4243
+ ]
4244
+ },
4245
+ {
4246
+ "name": "mesh-seed",
4247
+ "namespace": "qvac",
4248
+ "framed": false,
4249
+ "versions": [
4250
+ {
4251
+ "type": "@qvac/mesh-seed-v1",
4252
+ "map": null,
4253
+ "version": 1
4254
+ }
4255
+ ]
4159
4256
  }
4160
4257
  ]
4161
4258
  }
@@ -1,5 +1,5 @@
1
1
  // This file is autogenerated by hyperschema-ts
2
- // Schema version: 13
2
+ // Schema version: 14
3
3
  // Do not edit manually.
4
4
 
5
5
  export type QvacChunkType = "user-message" | "content" | "thinking" | "tool-call" | "tool-result" | "attachment" | "approval-request" | "run-status" | "run-request" | "sources" | "compaction"
@@ -13,7 +13,7 @@ export interface QvacResourceDescriptor {
13
13
  label: string
14
14
  }
15
15
 
16
- export type QvacProgressPhase = "loading" | "downloading" | "queued" | "generating" | "transcribing" | "compacting"
16
+ export type QvacProgressPhase = "loading" | "downloading" | "queued" | "generating" | "transcribing" | "compacting" | "awaiting-download"
17
17
 
18
18
  export interface QvacRunProgress {
19
19
  phase: QvacProgressPhase
@@ -399,6 +399,8 @@ export interface QvacMeshInviteV1 {
399
399
  inviteNonce?: Buffer | null
400
400
  compute?: boolean
401
401
  inviterName?: string | null
402
+ deviceSeed?: Buffer | null
403
+ deviceProof?: Buffer | null
402
404
  }
403
405
 
404
406
  export type QvacMeshInvite = (QvacMeshInviteV1 & { version?: number })
@@ -824,6 +826,24 @@ export interface QvacNameMeshOperationV1 {
824
826
 
825
827
  export type QvacNameMeshOperation = (QvacNameMeshOperationV1 & { version?: number })
826
828
 
829
+ export interface QvacOpenJoinV1 {
830
+ signature: Buffer
831
+ device?: QvacDevice | null
832
+ deviceId?: Buffer | null
833
+ deviceSignature?: Buffer | null
834
+ member?: QvacMember | null
835
+ memberClaim?: Buffer | null
836
+ }
837
+
838
+ export type QvacOpenJoin = (QvacOpenJoinV1 & { version?: number })
839
+
840
+ export interface QvacMeshSeedV1 {
841
+ meshKey: Buffer
842
+ seed: Buffer
843
+ }
844
+
845
+ export type QvacMeshSeed = (QvacMeshSeedV1 & { version?: number })
846
+
827
847
  export interface SchemaTypes {
828
848
  "@qvac/chunk-type": QvacChunkType
829
849
  "@qvac/run-state": QvacRunState
@@ -999,4 +1019,8 @@ export interface SchemaTypes {
999
1019
  "@qvac/mesh-name": QvacMeshName
1000
1020
  "@qvac/name-mesh-operation-v1": QvacNameMeshOperationV1
1001
1021
  "@qvac/name-mesh-operation": QvacNameMeshOperation
1022
+ "@qvac/open-join-v1": QvacOpenJoinV1
1023
+ "@qvac/open-join": QvacOpenJoin
1024
+ "@qvac/mesh-seed-v1": QvacMeshSeedV1
1025
+ "@qvac/mesh-seed": QvacMeshSeed
1002
1026
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qvac/core",
3
- "version": "0.6.6",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "description": "Peer-to-peer AI across your devices",
6
6
  "engines": {
@@ -105,14 +105,8 @@
105
105
  "default": "./dist-lib/lib/oauth/fetch-platform.js"
106
106
  },
107
107
  "./oauth/runtime/loopback": {
108
- "bare": {
109
- "types": "./dist-lib/lib/oauth/loopback.stub.d.ts",
110
- "default": "./dist-lib/lib/oauth/loopback.stub.js"
111
- },
112
- "default": {
113
- "types": "./dist-lib/lib/oauth/loopback.d.ts",
114
- "default": "./dist-lib/lib/oauth/loopback.js"
115
- }
108
+ "types": "./dist-lib/lib/oauth/loopback.d.ts",
109
+ "default": "./dist-lib/lib/oauth/loopback.js"
116
110
  },
117
111
  "./credential-pusher": {
118
112
  "types": "./dist-lib/lib/credential-pusher.d.ts",
@@ -151,10 +145,12 @@
151
145
  "mesh-lend-a-model": "bare examples/mesh-lend-a-model.mjs",
152
146
  "mesh-capability-run": "bare examples/mesh-capability-run.mjs",
153
147
  "model-idle-limit": "bare examples/model-idle-limit.mjs",
148
+ "model-memory-cap": "bare examples/model-memory-cap.mjs",
154
149
  "model-load-unload": "bare examples/model-load-unload.mjs",
155
150
  "model-users": "bare examples/model-users.mjs",
156
151
  "models-by-task": "bare examples/models-by-task.mjs",
157
152
  "models-watch": "bare examples/models-watch.mjs",
153
+ "model-downloads-held": "bare examples/model-downloads-held.mjs",
158
154
  "chunks-delta-watch": "bare examples/chunks-delta-watch.mjs",
159
155
  "mesh-pair-and-migrate": "bare examples/mesh-pair-and-migrate.mjs",
160
156
  "mesh-scoped-catalog": "bare examples/mesh-scoped-catalog.mjs",
@@ -167,7 +163,7 @@
167
163
  "mesh-recover-account": "bare examples/mesh-recover-account.mjs",
168
164
  "mesh-user-names": "bare examples/mesh-user-names.mjs",
169
165
  "test": "npm run test:bare && npm run bench:rag:test",
170
- "test:bare": "QVAC_NO_SKILL_BIN_PROBE=1 brittle-jobs -j 2 --retries 1 --timeout 600000 'test/*.ts' 'test/{api,basic,rag}/**/*.ts' 'test/tui/**/!(helpers).ts'",
166
+ "test:bare": "QVAC_NO_SKILL_BIN_PROBE=1 brittle-jobs -j 2 --retries 1 --timeout 600000 'test/*.ts' 'test/{api,basic,host,rag}/**/*.ts' 'test/tui/**/!(helpers).ts'",
171
167
  "test:model": "QVAC_TEST_MODELS=1 npm run test:bare",
172
168
  "format": "prettier . --write",
173
169
  "lint": "prettier . --check && lunte && tsc --noEmit",
@@ -225,10 +221,6 @@
225
221
  "bare": "bare-worker",
226
222
  "default": "worker_threads"
227
223
  },
228
- "#oauth-loopback": {
229
- "bare": "./dist-lib/lib/oauth/loopback.stub.js",
230
- "default": "./dist-lib/lib/oauth/loopback.js"
231
- },
232
224
  "#cpu-info": {
233
225
  "bare": "bare-cpu-info",
234
226
  "default": "./dist-lib/lib/core/cpu-info-node.js"
@@ -239,8 +231,8 @@
239
231
  }
240
232
  },
241
233
  "dependencies": {
242
- "@qvac/harness": "^0.7.2",
243
- "@qvac/skills": "^0.1.11",
234
+ "@qvac/harness": "^0.8.6",
235
+ "@qvac/skills": "0.1.12",
244
236
  "asenion": "^0.1.0",
245
237
  "autobee": "^2.11.8",
246
238
  "b4a": "^1.9.0",
@@ -343,7 +335,7 @@
343
335
  "pyodide@314.0.2": "patches/pyodide@314.0.2.patch",
344
336
  "localwatch@1.4.3": "patches/localwatch@1.4.3.patch",
345
337
  "bare-stow@0.1.5": "patches/bare-stow@0.1.5.patch",
346
- "@qvac/inference@0.20.0": "patches/@qvac%2Finference@0.20.0.patch",
338
+ "@qvac/inference@0.21.0": "patches/@qvac%2Finference@0.21.0.patch",
347
339
  "hyperdb@6.9.0": "patches/hyperdb@6.9.0.patch"
348
340
  },
349
341
  "overrides": {
package/tui/README.md CHANGED
@@ -42,7 +42,7 @@ Bare's native TTY; the TUI will not run under node.
42
42
  ## Usage
43
43
 
44
44
  ```
45
- duck [--storage <dir>] [--temp] [--headless]
45
+ duck [--storage <dir>] [--temp] [--headless] [--fake-models]
46
46
  ```
47
47
 
48
48
  Flags may appear in any order. Joining a mesh is `/join qvac://mesh/…` inside
@@ -55,6 +55,11 @@ the app, not a boot argument.
55
55
  then streams logs (including the sidecar child's own output) to stdout until
56
56
  ctrl+C. A mesh peer to point other instances at, and the only live view of
57
57
  the boot the TUI hides.
58
+ - `--fake-models` — adds the `quack` model, a fake LLM that runs no inference:
59
+ it replies with `quack` repeated a number of times taken from a hash of the
60
+ prompt, so the same prompt always gets the same reply. Pick it with
61
+ `/models use quack`, or boot an agent on it with `QVAC_MODEL=quack`.
62
+ `QVAC_FAKE_MODELS=1` is the env fallback.
58
63
 
59
64
  Storage defaults to the desktop app's release root (`resolveStorage`, i.e.
60
65
  `<platform-persistent>/qvac/dev`), so the TUI resumes the same mesh and chats
@@ -81,6 +86,7 @@ for the full command set.
81
86
  | `QVAC_IMAGE_LLM`, `QVAC_IMAGE_VAE`, `QVAC_IMAGE_PREDICTION` | FLUX.2 is a companion set: the Qwen3 text encoder, the VAE, and `flux2_flow` (required for img2img) |
82
87
  | `QVAC_LOG_FILE`, `QVAC_LOG_LEVEL` | Move the log file / pick the level (`debug` \| `info` \| `warn` \| `error`, default `info`) |
83
88
  | `QVAC_BOOT_TIMING=1` | Prints the total connect time after the TUI exits |
89
+ | `QVAC_FAKE_MODELS=1` | Adds the deterministic `quack` model, as `--fake-models` does |
84
90
 
85
91
  ```sh
86
92
  QVAC_MODEL=~/.qvac/models/3a65a2a3c6a30a47_Qwen3.5-4B-Q4_K_M.gguf \
package/tui/app.mjs CHANGED
@@ -18,6 +18,9 @@ import {
18
18
  MODEL_CONTEXT_TARGET,
19
19
  maxContextForModel
20
20
  } from '../dist-lib/lib/model-context.js'
21
+ import { runChecks } from '../dist-lib/lib/doctor/checks.js'
22
+ import { checkLines, summarize } from '../dist-lib/lib/doctor/render.js'
23
+ import { diagnosticsLines, headerLine } from '../dist-lib/lib/doctor/tree.js'
21
24
  import {
22
25
  busyStatus,
23
26
  findPendingApproval,
@@ -99,7 +102,7 @@ const COMMANDS = [
99
102
  { name: 'rename', desc: '<name> — rename the active agent' },
100
103
  {
101
104
  name: 'use',
102
- desc: '<name|id> — switch the active agent (same chat; re-targets the next run)'
105
+ desc: '<name|id> — switch the active agent and hand it the open chat'
103
106
  },
104
107
  { name: 'borrow', desc: '[none] — borrow the model from the compute mesh, or stop borrowing' }
105
108
  ]
@@ -253,6 +256,12 @@ const COMMANDS = [
253
256
  name: 'my-device',
254
257
  desc: 'CPU/GPU inventory for this device (manufacturer, cores, drivers, …)'
255
258
  },
259
+ {
260
+ name: 'doctor',
261
+ desc: 'health checks for this device, with secrets redacted for pasting',
262
+ palette: true,
263
+ sub: [{ name: 'debug', desc: 'the raw diagnostics frame behind the checks' }]
264
+ },
256
265
  {
257
266
  name: 'models',
258
267
  desc: 'browse the SDK registry (optional type filter), or check and add your own GGUF',
@@ -373,11 +382,28 @@ export const fg = {
373
382
  cyan: style().foreground('brightcyan'),
374
383
  dim: style().foreground('gray').italic(true),
375
384
  white: style(),
385
+ green: style().foreground('brightgreen'),
376
386
  amber: style().foreground('brightyellow'),
377
387
  magenta: style().foreground('brightmagenta').bold(true),
378
388
  err: style().foreground('brightred')
379
389
  }
380
390
 
391
+ // long enough for the engine's sampler to tick, so flushes/delay can move
392
+ const DOCTOR_SAMPLE_GAP_MS = 1500
393
+
394
+ // the glyph carries the severity and the titles the structure, so only those are coloured
395
+ const DOCTOR_PAINT = {
396
+ pass: fg.green,
397
+ warn: fg.amber,
398
+ fail: fg.err,
399
+ declared: fg.dim,
400
+ pending: fg.dim,
401
+ title: fg.cyan,
402
+ explain: fg.dim
403
+ }
404
+
405
+ const paintDoctor = (text, kind) => (DOCTOR_PAINT[kind] ?? fg.white).render(text)
406
+
381
407
  // an IEEE-float WAV header (format tag 3) so the engine's raw PCM plays in any player
382
408
  export function floatPcmToWav(pcm, sampleRate) {
383
409
  const blockAlign = 4
@@ -1506,6 +1532,11 @@ const isOwnDefault = (agent, deviceId) =>
1506
1532
  b4a.equals(agent.providerDeviceId, deviceId)
1507
1533
  const ownDefault = (agents, deviceId) => agents.find((agent) => isOwnDefault(agent, deviceId))
1508
1534
 
1535
+ // deviceInfo carries no model: the recommendation lives on the device's own row in the mesh
1536
+ async function recommendedModel(engine, meshId, deviceId) {
1537
+ return (await engine.getDevice({ meshId, deviceId })).recommendedModelName
1538
+ }
1539
+
1509
1540
  // mints one on timeout: an unbounded wait blocks the composer, and an account may hold no agent
1510
1541
  async function firstAgent(engine, meshId, { deviceId, modelName, remembered, account }) {
1511
1542
  const watch = engine.agentsWatch({ meshId })[Symbol.asyncIterator]()
@@ -1552,7 +1583,7 @@ async function firstAgent(engine, meshId, { deviceId, modelName, remembered, acc
1552
1583
  name: 'QV.AC',
1553
1584
  bio: 'You are a helpful local assistant. Be clear, practical, and concise.',
1554
1585
  providerDeviceId: deviceId,
1555
- modelName: modelName || (await engine.deviceInfo({})).recommendedModelName,
1586
+ modelName: modelName || (await recommendedModel(engine, meshId, deviceId)),
1556
1587
  isDefault: true
1557
1588
  }
1558
1589
  })
@@ -1691,6 +1722,8 @@ export class ChatApp {
1691
1722
  this._customModels = new Map()
1692
1723
  this._pickableFiles = []
1693
1724
  this._statusIterator = null
1725
+ this._downloadsIterator = null
1726
+ this.modelDownloads = new Map()
1694
1727
  this.meshStatus = null // last meshStatusWatch frame — rendered in the header
1695
1728
  this._devicesIterator = null
1696
1729
  this.deviceLabels = new Map() // hex device id → name, from devicesWatch
@@ -1700,6 +1733,8 @@ export class ChatApp {
1700
1733
  this._diagnosticsIterator = null
1701
1734
  this.overlay = null
1702
1735
  this._pinnedOverlay = null
1736
+ // { overlay, text } for ctrl+y, keyed on overlay identity so any other overlay invalidates it
1737
+ this._doctorReport = null
1703
1738
  // apart from `overlay` because its rows respond to ↑/↓ and enter
1704
1739
  this._models = null
1705
1740
  this._selector = null
@@ -1743,6 +1778,7 @@ export class ChatApp {
1743
1778
  _engineWatches() {
1744
1779
  return [
1745
1780
  this._watchNextStatus(),
1781
+ this._watchNextDownloads(),
1746
1782
  this._watchNextDiagnostics(),
1747
1783
  this._watchNextMeshes(),
1748
1784
  this._enterMesh()
@@ -2035,6 +2071,24 @@ export class ChatApp {
2035
2071
  }
2036
2072
  }
2037
2073
 
2074
+ _watchNextDownloads() {
2075
+ const gen = this.gen
2076
+ if (!this._downloadsIterator) {
2077
+ this._downloadsIterator = this.engine.modelDownloadsWatch({})[Symbol.asyncIterator]()
2078
+ }
2079
+
2080
+ const it = this._downloadsIterator
2081
+
2082
+ return async () => {
2083
+ const { value, done } = await it.next()
2084
+ if (done) {
2085
+ return { type: 'model-downloads.done', gen }
2086
+ }
2087
+
2088
+ return { type: 'model-downloads', gen, downloads: value.downloads ?? [] }
2089
+ }
2090
+ }
2091
+
2038
2092
  _setTranscript(chunks) {
2039
2093
  this._turns = turnsFromChunks(chunks)
2040
2094
  this.pendingApproval = findPendingApproval(this._turns)
@@ -2072,7 +2126,11 @@ export class ChatApp {
2072
2126
  if (this.pendingApproval) return null
2073
2127
  if (!this.busy) return null
2074
2128
  const runTurn = runningAgentTurn(this._turns)
2075
- const { text, on } = busyStatus(this.modelState, runTurn, Date.now() - this._busySince)
2129
+ const { text, on } = busyStatus(this.modelState, runTurn, {
2130
+ elapsed: Date.now() - this._busySince,
2131
+ selfId: this.originDeviceId ? b4a.toHex(this.originDeviceId) : '',
2132
+ downloads: this.modelDownloads
2133
+ })
2076
2134
  const where = this._busyDevice(on, runTurn)
2077
2135
 
2078
2136
  return fg.dim.render(`${this.spin.view()} ${text}${where ? ` (on ${where})` : ''}`)
@@ -2266,7 +2324,9 @@ export class ChatApp {
2266
2324
  ' /meshes - list the meshes this device belongs to, numbered, marking account / shared / active / open / writable',
2267
2325
  ' /mesh use <n|id> - make one of them active; its agent, chat and roster replace the ones on screen',
2268
2326
  ' /mesh move <n|id> [chat] - move this chat (or the named one) into another mesh, its files and running turn with it · /mesh moved [chat] - how that move is going',
2269
- ' /my-device — dump this device\u2019s CPU/GPU inventory (manufacturer, cores, drivers, …)'
2327
+ ' /my-device — dump this device\u2019s CPU/GPU inventory (manufacturer, cores, drivers, …)',
2328
+ ' /doctor — check this device: hardware, engine, model backends, mesh, network. ctrl+y copies the report, secrets redacted',
2329
+ ' /doctor debug — the raw diagnostics frame behind those checks'
2270
2330
  ].join('\n')
2271
2331
 
2272
2332
  const notice = (t) => [this, async () => ({ type: 'notice', text: t })]
@@ -2336,6 +2396,19 @@ export class ChatApp {
2336
2396
  return this._showDiagnostics()
2337
2397
  }
2338
2398
 
2399
+ if (cmd === 'doctor') {
2400
+ const action = rest[0]?.toLowerCase()
2401
+ if (!action) {
2402
+ return this._runDoctor()
2403
+ }
2404
+
2405
+ if (action === 'debug') {
2406
+ return this._showDoctor()
2407
+ }
2408
+
2409
+ return notice('usage: /doctor [debug] — checks, or the raw diagnostics frame')
2410
+ }
2411
+
2339
2412
  if (cmd === 'usage') {
2340
2413
  if (rawArgs.trim()) {
2341
2414
  return notice('usage: /usage')
@@ -2655,11 +2728,13 @@ export class ChatApp {
2655
2728
  name: arg,
2656
2729
  bio: `${arg} — test agent`,
2657
2730
  providerDeviceId: this.originDeviceId,
2658
- modelName: agent?.modelName ?? (await engine.deviceInfo({})).recommendedModelName
2731
+ modelName:
2732
+ agent?.modelName ??
2733
+ this._modelName ??
2734
+ (await recommendedModel(engine, this.meshId, this.originDeviceId))
2659
2735
  }
2660
2736
  })
2661
- this.agent = created
2662
- await this._persistSelection()
2737
+ await this._handChatTo(created)
2663
2738
 
2664
2739
  return `created + selected ${created.name} (${created.id.slice(0, 8)}) · no skills/tools enabled`
2665
2740
  })
@@ -2722,8 +2797,7 @@ export class ChatApp {
2722
2797
  return `no agent matching: ${arg}`
2723
2798
  }
2724
2799
 
2725
- this.agent = found
2726
- await this._persistSelection()
2800
+ await this._handChatTo(found)
2727
2801
 
2728
2802
  return `selected ${found.name} (${found.id.slice(0, 8)})`
2729
2803
  })
@@ -3979,6 +4053,20 @@ export class ChatApp {
3979
4053
  }
3980
4054
  }
3981
4055
 
4056
+ // the chat row names its agent, or reopening the chat or another device hands it back to the old one
4057
+ async _handChatTo(agent) {
4058
+ if (this.chatId) {
4059
+ await this.engine.setChatAgent({
4060
+ meshId: this.meshId,
4061
+ chatId: this.chatId,
4062
+ agentId: agent.id
4063
+ })
4064
+ }
4065
+
4066
+ this.agent = agent
4067
+ await this._persistSelection()
4068
+ }
4069
+
3982
4070
  // kept in Core's device-local config, the same record the desktop app resumes from
3983
4071
  async _persistSelection() {
3984
4072
  if (!this.engine.getConfig || !this.agent || !this.chatId) return
@@ -4148,6 +4236,77 @@ export class ChatApp {
4148
4236
  ]
4149
4237
  }
4150
4238
 
4239
+ // every verdict but the deltas answers from one frame, so the report renders before the gap
4240
+ _runDoctor() {
4241
+ const { engine } = this
4242
+ return [
4243
+ this,
4244
+ async () => {
4245
+ try {
4246
+ const first = (await engine.diagnostics({})).stats
4247
+ return { type: 'doctor.checks', samples: { first } }
4248
+ } catch (error) {
4249
+ return { type: 'doctor.checks', error }
4250
+ }
4251
+ }
4252
+ ]
4253
+ }
4254
+
4255
+ // only the movement rows are still open, so this re-renders over the report on screen
4256
+ _settleDoctor(first, overlay) {
4257
+ const { engine } = this
4258
+ return async () => {
4259
+ try {
4260
+ // lunte-disable-next-line qvac/no-sleep -- a sampling interval: the deltas need frames apart
4261
+ await new Promise((resolve) => setTimeout(resolve, DOCTOR_SAMPLE_GAP_MS))
4262
+ const second = (await engine.diagnostics({})).stats
4263
+ return { type: 'doctor.checks', samples: { first, second }, overlay }
4264
+ } catch (error) {
4265
+ return { type: 'doctor.checks', error, overlay }
4266
+ }
4267
+ }
4268
+ }
4269
+
4270
+ // a fresh snapshot, not this.diagnostics: the watch only runs while the footer is live
4271
+ _showDoctor() {
4272
+ const { engine } = this
4273
+ return [
4274
+ this,
4275
+ async () => {
4276
+ try {
4277
+ const { stats } = await engine.diagnostics({})
4278
+ return { type: 'doctor.result', stats }
4279
+ } catch (error) {
4280
+ return { type: 'doctor.result', error }
4281
+ }
4282
+ }
4283
+ ]
4284
+ }
4285
+
4286
+ // null when no doctor report is on screen, so ctrl+y falls through to the invite
4287
+ _copyReport() {
4288
+ const report = this._doctorReport
4289
+ if (!report || report.overlay !== this.overlay || !this._copyToClipboard) {
4290
+ return null
4291
+ }
4292
+
4293
+ const { text } = report
4294
+ const copy = this._copyToClipboard
4295
+ const token = ++this._statusToken
4296
+
4297
+ return [
4298
+ this,
4299
+ async () => {
4300
+ try {
4301
+ await copy(text)
4302
+ return { type: 'transient-status', token, text: 'report copied ✓' }
4303
+ } catch (err) {
4304
+ return { type: 'transient-status', token, text: `copy failed: ${err.message}` }
4305
+ }
4306
+ }
4307
+ ]
4308
+ }
4309
+
4151
4310
  // /usage: the chat's run statuses carry the last run's own numbers; the folds say why they dropped
4152
4311
  _showUsage() {
4153
4312
  const { engine, chatId } = this
@@ -5905,6 +6064,26 @@ export class ChatApp {
5905
6064
  return [this, this._watchNextStatus()]
5906
6065
  }
5907
6066
 
6067
+ if (msg.type === 'model-downloads') {
6068
+ if (msg.gen !== this.gen) {
6069
+ return [this, null]
6070
+ }
6071
+
6072
+ this.modelDownloads = new Map(msg.downloads.map((row) => [row.name, row]))
6073
+
6074
+ return [this, this._watchNextDownloads()]
6075
+ }
6076
+
6077
+ if (msg.type === 'model-downloads.done') {
6078
+ if (msg.gen !== this.gen) {
6079
+ return [this, null]
6080
+ }
6081
+
6082
+ this.modelDownloads = new Map()
6083
+
6084
+ return [this, null]
6085
+ }
6086
+
5908
6087
  if (msg.type === 'mesh-status.done') {
5909
6088
  if (msg.gen !== this.gen) {
5910
6089
  return [this, null]
@@ -5980,6 +6159,60 @@ export class ChatApp {
5980
6159
  return [this, null]
5981
6160
  }
5982
6161
 
6162
+ if (msg.type === 'doctor.checks') {
6163
+ // a settle pass belongs to the report it started from; esc or another overlay since drops it
6164
+ if (msg.overlay && msg.overlay !== this.overlay) {
6165
+ return [this, null]
6166
+ }
6167
+
6168
+ this._models = null
6169
+ this._selector = null
6170
+ if (msg.error) {
6171
+ this.overlay = [fg.err.render(`/doctor failed: ${msg.error.message}`)]
6172
+ this._render()
6173
+ return [this, null]
6174
+ }
6175
+
6176
+ const { first, second } = msg.samples
6177
+ const checks = runChecks(msg.samples)
6178
+ const head = [headerLine(second ?? first), summarize(checks)]
6179
+ this.overlay = [
6180
+ fg.dim.render('Doctor — ctrl+y copies · /doctor debug for the raw frame · esc to return'),
6181
+ '',
6182
+ ...head,
6183
+ ...checkLines(checks, { paint: paintDoctor })
6184
+ ]
6185
+ // the clipboard gets the same report without escape codes
6186
+ this._doctorReport = {
6187
+ overlay: this.overlay,
6188
+ text: [...head, ...checkLines(checks)].join('\n')
6189
+ }
6190
+ this._render()
6191
+
6192
+ return [this, second === undefined ? this._settleDoctor(first, this.overlay) : null]
6193
+ }
6194
+
6195
+ if (msg.type === 'doctor.result') {
6196
+ this._models = null
6197
+ this._selector = null
6198
+ if (msg.error) {
6199
+ this.overlay = [fg.err.render(`/doctor failed: ${msg.error.message}`)]
6200
+ this._render()
6201
+ return [this, null]
6202
+ }
6203
+
6204
+ const report = diagnosticsLines(msg.stats)
6205
+ this.overlay = [
6206
+ fg.dim.render('Doctor — raw diagnostics — ctrl+y copies · esc to return'),
6207
+ '',
6208
+ ...report
6209
+ ]
6210
+ this._doctorReport = { overlay: this.overlay, text: report.join('\n') }
6211
+ this._render()
6212
+
6213
+ return [this, null]
6214
+ }
6215
+
5983
6216
  if (msg.type === 'usage.result') {
5984
6217
  this._models = null
5985
6218
  this._selector = null
@@ -6236,7 +6469,7 @@ export class ChatApp {
6236
6469
 
6237
6470
  // modifier keys never collide with typing or the y/n approval answers
6238
6471
  if (key.matches(msg, 'ctrl+y')) {
6239
- return this._copyInvite()
6472
+ return this._copyReport() ?? this._copyInvite()
6240
6473
  }
6241
6474
 
6242
6475
  if (key.matches(msg, 'ctrl+v')) {
@@ -6789,7 +7022,8 @@ export class ChatApp {
6789
7022
  }
6790
7023
 
6791
7024
  if (this.overlay) {
6792
- return 'esc: back · ↑/↓: scroll · ctrl+c: quit'
7025
+ const copy = this._doctorReport?.overlay === this.overlay ? ' · ctrl+y: copy report' : ''
7026
+ return `esc: back · ↑/↓: scroll${copy} · ctrl+c: quit`
6793
7027
  }
6794
7028
 
6795
7029
  if (this._menu) {