dsh-vision-router 3.1.5 → 3.2.1

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 (47) hide show
  1. package/README.md +6 -6
  2. package/README.zh.md +6 -6
  3. package/THIRD_PARTY_NOTICES.md +107 -0
  4. package/assets/licenses/apache-2.0.txt +202 -0
  5. package/assets/licenses/moxcms-BSD-3-Clause.txt +26 -0
  6. package/assets/licenses/roots-BSD-2-Clause.txt +24 -0
  7. package/assets/licenses/unicode-ident-Unicode-3.0.txt +39 -0
  8. package/assets/licenses/vtracer-MIT.txt +25 -0
  9. package/assets/licenses/zlib-rs-Zlib.txt +19 -0
  10. package/cordis.patch.yml +8 -15
  11. package/docs/architecture/dsh-support-window-3.1-historical.md +98 -0
  12. package/docs/architecture/dsh-support-window.md +30 -83
  13. package/docs/architecture/dvr32-host-retirement.md +194 -0
  14. package/docs/ci-archive/README.md +3 -0
  15. package/docs/ci-archive/minimum-host-settings-persistence.legacy.js +118 -0
  16. package/docs/compatibility/dsh-0.2.2-rc2-audit.md +40 -0
  17. package/docs/compliance/vtracer-alpha4-provenance.md +47 -0
  18. package/docs/compliance/vtracer-alpha4-reconstructed-Cargo.lock +567 -0
  19. package/docs/compliance/vtracer-alpha4-rust-inventory.json +421 -0
  20. package/docs/compliance/vtracer-alpha4-rust-license-texts.md +13018 -0
  21. package/docs/progressive-tools-cache.md +4 -0
  22. package/docs/releases/v3.2.0-rc.0.md +16 -0
  23. package/docs/releases/v3.2.0.md +38 -0
  24. package/docs/releases/v3.2.1.md +21 -0
  25. package/docs/remote-settings.md +83 -8
  26. package/index.js +55 -57
  27. package/lib/client.js +13 -13
  28. package/lib/core-primitives.js +69 -187
  29. package/lib/doctor-cli-p0.js +14 -1
  30. package/lib/doctor-cli.js +70 -2
  31. package/lib/doctor-runtime.js +8 -3
  32. package/lib/doctor.js +57 -1
  33. package/lib/dsh-support-window.js +80 -31
  34. package/lib/grounding-box-recovery.js +76 -0
  35. package/lib/grounding-coordinate-runtime.js +10 -0
  36. package/lib/remote-settings-bridge.js +93 -57
  37. package/lib/remote-settings-risk-client-boundary.js +2 -2
  38. package/lib/runtime-i18n.js +4 -4
  39. package/lib/settings-client-017-compat.js +4 -2
  40. package/lib/settings-ia-client-prelude.js +26 -10
  41. package/lib/trace-vtracer-worker.js +163 -0
  42. package/lib/web/dsh-settings-017-root-transport.js +52 -6
  43. package/lib/web-capability-boundary.js +6 -0
  44. package/package.json +21 -26
  45. package/presets/README.md +0 -9
  46. package/presets/web-connection-ready/index.mjs +0 -48
  47. package/presets/web-connection-ready/package.json +0 -6
@@ -1191,215 +1191,97 @@ function isVisionAbort(error, signal) {
1191
1191
  return signal?.aborted === true || error?.name === 'AbortError' || error?.code === 'ABORT_ERR'
1192
1192
  }
1193
1193
 
1194
- /** Vectorize an image buffer into an SVG string via potrace posterization. */
1195
- export function posterizeSvg(bytes, steps = 4, fillStrategy = 'dominant', timeoutMs = 60000, options = {}) {
1196
- // potrace is CPU-bound and runs its computation in long synchronous
1197
- // chunks: on the main thread it blocks the whole dsh process (other
1198
- // sessions time out) and a setTimeout-based timeout can NEVER fire while
1199
- // the loop is blocked. Run it in a worker thread instead — the main loop
1200
- // stays responsive, and a timeout hard-terminates the worker.
1201
- const signal = options?.signal
1194
+ /** Shared hard-timeout and cancellation boundary for local VTracer SVG workers. */
1195
+ function runTraceWorker(mode, payload, timeoutMs, signal) {
1196
+ const aborted = () => visionAbortReason(signal, 'vector trace aborted')
1197
+ if (signal?.aborted) return Promise.reject(aborted())
1202
1198
  return new Promise((resolve, reject) => {
1203
- let settled = false
1204
1199
  let worker
1205
1200
  let timer
1206
- let abortListener
1201
+ let finished = false
1207
1202
  const finish = (error, svg) => {
1208
- if (settled) return
1209
- settled = true
1203
+ if (finished) return
1204
+ finished = true
1210
1205
  if (timer !== undefined) clearTimeout(timer)
1211
- if (signal && abortListener) signal.removeEventListener?.('abort', abortListener)
1212
- void worker?.terminate()
1206
+ signal?.removeEventListener?.('abort', onAbort)
1207
+ if (worker) void worker.terminate().catch(() => {})
1213
1208
  if (error) reject(error)
1214
1209
  else resolve(svg)
1215
1210
  }
1216
- abortListener = () => finish(visionAbortReason(signal, 'potrace aborted'))
1217
- if (signal?.aborted) {
1218
- finish(visionAbortReason(signal, 'potrace aborted'))
1211
+ const onAbort = () => finish(aborted())
1212
+ signal?.addEventListener?.('abort', onAbort, { once: true })
1213
+ if (signal?.aborted) { finish(aborted()); return }
1214
+ if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
1215
+ finish(new Error('vector trace timed out'))
1219
1216
  return
1220
1217
  }
1221
- signal?.addEventListener?.('abort', abortListener, { once: true })
1222
- timer = setTimeout(() => {
1223
- finish(
1224
- new Error(
1225
- 'potrace timed out — the image is too large or too complex; crop it to the target region first',
1226
- ),
1227
- )
1228
- }, timeoutMs)
1218
+ timer = setTimeout(() => finish(new Error(
1219
+ 'vector trace timed out — crop the image or reduce its complexity',
1220
+ )), timeoutMs)
1229
1221
  try {
1230
- // Resolve potrace's entry to an absolute file URL the worker can import
1231
- // regardless of the dsh process cwd or the worker's module mode.
1232
- const potraceUrl = pathToFileURL(createRequire(import.meta.url).resolve('potrace')).href
1233
- const source = `
1234
- import('node:worker_threads').then(({ parentPort, workerData }) => {
1235
- import(workerData.potraceUrl).then((mod) => {
1236
- const potrace = mod.default ?? mod
1237
- potrace.posterize(Buffer.from(workerData.bytes), {
1238
- steps: workerData.steps,
1239
- fillStrategy: workerData.fillStrategy,
1240
- }, (error, svg) => {
1241
- parentPort.postMessage(error ? { error: String((error && error.message) || error) } : { svg })
1242
- })
1243
- }).catch((error) => {
1244
- parentPort.postMessage({ error: String((error && error.message) || error) })
1245
- })
1246
- })
1247
- `
1248
- worker = new Worker(source, {
1249
- eval: true,
1250
- workerData: { potraceUrl, bytes, steps, fillStrategy },
1222
+ // This file-backed runtime worker uses only published JavaScript and
1223
+ // absolute peer imports; it never needs Host CLI, eval, test or loader
1224
+ // flags. Inheriting them can fail or run unwanted diagnostic hooks.
1225
+ worker = new Worker(new URL('./trace-vtracer-worker.js', import.meta.url), {
1226
+ execArgv: [],
1227
+ workerData: { mode, ...payload },
1228
+ resourceLimits: { maxOldGenerationSizeMb: 192, maxYoungGenerationSizeMb: 32 },
1251
1229
  })
1252
1230
  worker.once('message', (message) => {
1253
- if (message && message.error) finish(new Error(message.error))
1254
- else finish(undefined, message && message.svg)
1231
+ if (message?.ok === true && typeof message.svg === 'string') finish(undefined, message.svg)
1232
+ else finish(new Error(String(message?.error || 'vector trace worker returned invalid output')))
1255
1233
  })
1256
1234
  worker.once('error', (error) => finish(error))
1257
1235
  worker.once('exit', (code) => {
1258
- if (code !== 0 && !settled) finish(new Error(`potrace worker exited with code ${code}`))
1236
+ if (!finished) finish(new Error('vector trace worker exited before producing SVG (code ' + code + ')'))
1259
1237
  })
1260
- } catch (error) {
1261
- finish(error)
1262
- }
1238
+ } catch (error) { finish(error) }
1263
1239
  })
1264
1240
  }
1265
1241
 
1242
+ /** Compatible export: grayscale trace in an isolated Worker with adaptive posterized levels. */
1243
+ export function posterizeSvg(bytes, steps = 4, fillStrategy = 'dominant', timeoutMs = 60000, options = {}) {
1244
+ if (options?.signal?.aborted) return Promise.reject(visionAbortReason(options.signal, 'vector trace aborted'))
1245
+ if (!(bytes instanceof Uint8Array) || bytes.byteLength === 0 || bytes.byteLength > 32 * 1024 * 1024) {
1246
+ return Promise.reject(new RangeError('invalid trace image byte length'))
1247
+ }
1248
+ if (!Number.isInteger(steps) || steps < 1 || steps > 16) {
1249
+ return Promise.reject(new RangeError('trace steps must be an integer between 1 and 16'))
1250
+ }
1251
+ if (fillStrategy !== 'dominant') {
1252
+ return Promise.reject(new RangeError('unsupported grayscale fill strategy'))
1253
+ }
1254
+ const sharpUrl = pathToFileURL(createRequire(import.meta.url).resolve('sharp')).href
1255
+ return runTraceWorker('grayscale', { bytes: Buffer.from(bytes), steps, sharpUrl }, timeoutMs, options?.signal)
1256
+ }
1257
+
1266
1258
  /**
1267
- * Color-preserving vectorization: quantize the image into its top colors
1268
- * (the caller supplies the palette), build one 1-bit mask per color, trace
1269
- * each mask with potrace, and emit a real colored SVG — one <path> per color
1270
- * with fill="#rrggbb" — instead of potrace posterize's grayscale
1271
- * black + fill-opacity layers. Runs in a worker with the same hard timeout
1272
- * and termination semantics as posterizeSvg.
1273
- *
1274
- * @param data - raw RGBA pixel buffer the tool decoded (already downscaled
1275
- * to the trace budget).
1276
- * @param info - { width, height } of that buffer.
1277
- * @param palette - [{ hex, count, share }] from quantizeColors, ordered by
1278
- * share descending.
1259
+ * Local color SVG tracing.
1260
+ * An explicit palette array must be honored exactly (VTracer palette option);
1261
+ * an integer 1..16 requests automatic colors with that strict maximum.
1262
+ * The public vision_trace tool uses the integer form for higher visual fidelity.
1279
1263
  */
1280
- export function posterizeSvgColor(data, info, palette, timeoutMs = 60000, options = {}) {
1281
- const signal = options?.signal
1282
- return new Promise((resolve, reject) => {
1283
- let settled = false
1284
- let worker
1285
- let timer
1286
- let abortListener
1287
- const finish = (error, svg) => {
1288
- if (settled) return
1289
- settled = true
1290
- if (timer !== undefined) clearTimeout(timer)
1291
- if (signal && abortListener) signal.removeEventListener?.('abort', abortListener)
1292
- void worker?.terminate()
1293
- if (error) reject(error)
1294
- else resolve(svg)
1295
- }
1296
- abortListener = () => finish(visionAbortReason(signal, 'color trace aborted'))
1297
- if (signal?.aborted) {
1298
- finish(visionAbortReason(signal, 'color trace aborted'))
1299
- return
1300
- }
1301
- signal?.addEventListener?.('abort', abortListener, { once: true })
1302
- timer = setTimeout(() => {
1303
- finish(
1304
- new Error(
1305
- 'color trace timed out — the image is too large or too complex; crop it to the target region first',
1306
- ),
1307
- )
1308
- }, timeoutMs)
1309
- try {
1310
- const sharpUrl = pathToFileURL(createRequire(import.meta.url).resolve('sharp')).href
1311
- const potraceUrl = pathToFileURL(createRequire(import.meta.url).resolve('potrace')).href
1312
- const source = `
1313
- import('node:worker_threads').then(({ parentPort, workerData }) => {
1314
- Promise.all([import(workerData.sharpUrl), import(workerData.potraceUrl)]).then(([sharpMod, potraceMod]) => {
1315
- const sharp = sharpMod.default ?? sharpMod
1316
- const potrace = potraceMod.default ?? potraceMod
1317
- const { width, height, palette } = workerData
1318
- const raw = Buffer.from(workerData.raw)
1319
- const hexRgb = (hex) => {
1320
- const n = parseInt(hex.slice(1), 16)
1321
- return [(n >> 16) & 255, (n >> 8) & 255, n & 255]
1322
- }
1323
- const paletteRgb = palette.map((p) => hexRgb(p.hex))
1324
- const pixels = width * height
1325
- const masks = palette.map(() => Buffer.alloc(pixels))
1326
- for (let p = 0; p < pixels; p++) {
1327
- const o = p * 4
1328
- if (raw[o + 3] < 128) continue
1329
- let best = 0
1330
- let bestD = Infinity
1331
- for (let c = 0; c < paletteRgb.length; c++) {
1332
- const dr = raw[o] - paletteRgb[c][0]
1333
- const dg = raw[o + 1] - paletteRgb[c][1]
1334
- const db = raw[o + 2] - paletteRgb[c][2]
1335
- const d = dr * dr + dg * dg + db * db
1336
- if (d < bestD) { bestD = d; best = c }
1337
- }
1338
- masks[best][p] = 1
1339
- }
1340
- const paths = []
1341
- let pending = palette.length
1342
- const maybeDone = () => {
1343
- if (pending > 0) return
1344
- const pathSvg = paths.map((p) => '<path fill="' + p.hex + '" d="' + p.d + '"/>').join('')
1345
- parentPort.postMessage({
1346
- ok: true,
1347
- svg: '<svg xmlns="http://www.w3.org/2000/svg" width="' + width + '" height="' + height +
1348
- '" viewBox="0 0 ' + width + ' ' + height + '"><rect width="' + width + '" height="' + height +
1349
- '" fill="#ffffff"/>' + pathSvg + '</svg>',
1350
- })
1351
- }
1352
- if (pending === 0) { maybeDone(); return }
1353
- palette.forEach((entry, index) => {
1354
- const gray = Buffer.alloc(pixels)
1355
- const mask = masks[index]
1356
- for (let p = 0; p < pixels; p++) gray[p] = mask[p] ? 0 : 255
1357
- sharp(gray, { raw: { width, height, channels: 1 } })
1358
- .png()
1359
- .toBuffer()
1360
- .then((pngBuf) => {
1361
- potrace.trace(pngBuf, (err, svg) => {
1362
- pending -= 1
1363
- if (!err && svg) {
1364
- const found = [...svg.matchAll(/d="([^"]+)"/g)].map((m) => m[1])
1365
- for (const d of found) paths.push({ hex: entry.hex, d })
1366
- }
1367
- maybeDone()
1368
- })
1369
- })
1370
- .catch(() => {
1371
- pending -= 1
1372
- maybeDone()
1373
- })
1374
- })
1375
- }).catch((error) => {
1376
- parentPort.postMessage({ error: String((error && error.message) || error) })
1377
- })
1378
- })
1379
- `
1380
- worker = new Worker(source, {
1381
- eval: true,
1382
- workerData: {
1383
- sharpUrl,
1384
- potraceUrl,
1385
- width: info.width,
1386
- height: info.height,
1387
- palette,
1388
- raw: data,
1389
- },
1390
- })
1391
- worker.once('message', (message) => {
1392
- if (message && message.error) finish(new Error(message.error))
1393
- else finish(undefined, message && message.svg)
1394
- })
1395
- worker.once('error', (error) => finish(error))
1396
- worker.once('exit', (code) => {
1397
- if (code !== 0 && !settled) finish(new Error(`color-trace worker exited with code ${code}`))
1398
- })
1399
- } catch (error) {
1400
- finish(error)
1401
- }
1402
- })
1264
+ export function posterizeSvgColor(data, info, paletteOrColors, timeoutMs = 60000, options = {}) {
1265
+ if (options?.signal?.aborted) return Promise.reject(visionAbortReason(options.signal, 'color trace aborted'))
1266
+ const width = info?.width
1267
+ const height = info?.height
1268
+ if (
1269
+ !Number.isSafeInteger(width) || !Number.isSafeInteger(height) ||
1270
+ width < 1 || height < 1 || width * height > 1_000_000 ||
1271
+ !(data instanceof Uint8Array) || data.byteLength !== width * height * 4
1272
+ ) return Promise.reject(new RangeError('invalid color trace RGBA dimensions'))
1273
+ const explicit = Array.isArray(paletteOrColors)
1274
+ if (explicit
1275
+ ? (paletteOrColors.length > 16 || paletteOrColors.some((p) =>
1276
+ !p || typeof p.hex !== 'string' || !/^#[a-f0-9]{6}$/i.test(p.hex)))
1277
+ : (!Number.isInteger(paletteOrColors) || paletteOrColors < 1 || paletteOrColors > 16)
1278
+ ) return Promise.reject(new RangeError('invalid trace color palette or color limit'))
1279
+ return runTraceWorker('color', {
1280
+ data: Buffer.from(data), width, height,
1281
+ ...(explicit
1282
+ ? { palette: paletteOrColors.map((p) => ({ hex: p.hex.toLowerCase() })) }
1283
+ : { colors: paletteOrColors }),
1284
+ }, timeoutMs, options?.signal)
1403
1285
  }
1404
1286
 
1405
1287
  /** Resolve the effective vision_ocr engine without hiding explicit user/model intent. */
@@ -179,7 +179,20 @@ export async function run(argv = process.argv.slice(2), io = console, env = proc
179
179
  report.hostCapabilitiesSource = probe.source
180
180
  report.hostSupportWindow = DSH_SUPPORT_WINDOW
181
181
  report.hostVerificationEvidence = DSH_VERIFICATION_EVIDENCE
182
- report.hostSupportAdvice = supportWindowUpgradeAdvice(probe.capabilities)
182
+ // An old feature-rich Host must not be admitted based on attachments alone.
183
+ // Multiple profiles with mismatched or absent Host versions stay unknown.
184
+ const rows = report.platform?.hostPackages ?? []
185
+ const detected = rows.map((row) => row.packages?.['@deepseek-ai/dsh'])
186
+ const hostVersion = detected.length > 0 && detected.every((value) =>
187
+ typeof value === 'string' && value === detected[0])
188
+ ? detected[0] : undefined
189
+ report.hostSupportVersionEvidence = {
190
+ source: hostVersion ? 'installed-profile-package' : 'unverified',
191
+ version: hostVersion ?? null,
192
+ }
193
+ report.hostSupportAdvice = supportWindowUpgradeAdvice(probe.capabilities, {
194
+ nodeVersion: process.versions.node, hostVersion,
195
+ })
183
196
  io.log(JSON.stringify(report, null, 2))
184
197
  return code
185
198
  } catch {
package/lib/doctor-cli.js CHANGED
@@ -8,7 +8,7 @@ import { inspectDoctorVisionLimits, formatDoctorVisionLimits } from './doctor-vi
8
8
  import { repairLegacySessionLogs } from './legacy-session-repair.js'
9
9
 
10
10
  function usage() {
11
- return `dsh-vision-router doctor [--profile <name>] [--json | --issue-template] [--sessions] [--runtime-url <url>] [--no-runtime] [--fix]\ndsh-vision-router repair [--profile <name>]\ndsh-vision-router repair-sessions\n\nChecks installation, profile composition, runtime routes, recent settings-save failures and local vision capabilities.\n\nCommands:\n doctor Read-only health report by default. --fix is kept for compatibility but prefer the explicit repair command.\n repair Safely remove a leading UTF-8 BOM and rewrite stale version-pinned minimumReleaseAgeExclude entries.\n repair-sessions Offline repair for exact known Vision Router session corruptions, including the legacy missing-id reminder and duplicate structured guard-stop messages. Stop DSH first.\n\nOptions:\n --profile <name> Check only one profile (for example: web).\n --json Emit a shareable, secret-minimized JSON diagnostic report.\n --issue-template Print a safe, Markdown issue template with diagnostics and fill-in reproduction fields. Read-only.\n --sessions Also scan session logs for exact known Vision Router corruption signatures (read-only; may take longer).\n --runtime-url <url> Probe a running DSH web instance (default: DSH_WEB_URL or http://127.0.0.1:3080).\n --no-runtime Skip the read-only runtime route probe.\n --fix Backward-compatible doctor repair mode; prefer \`repair\`.\n --help Show this help.\n`
11
+ return `dsh-vision-router doctor [--profile <name>] [--json | --issue-template] [--sessions] [--runtime-url <url>] [--no-runtime] [--upgrade-preflight] [--fix]\ndsh-vision-router repair [--profile <name>]\ndsh-vision-router repair-sessions\n\nChecks installation, profile composition, runtime routes, recent settings-save failures and local vision capabilities.\n\nCommands:\n doctor Read-only health report by default. --fix is kept for compatibility but prefer the explicit repair command.\n repair Safely remove a leading UTF-8 BOM and rewrite stale version-pinned minimumReleaseAgeExclude entries.\n repair-sessions Offline repair for exact known Vision Router session corruptions, including the legacy missing-id reminder and duplicate structured guard-stop messages. Stop DSH first.\n\nOptions:\n --profile <name> Check only one profile (for example: web).\n --json Emit a shareable, secret-minimized JSON diagnostic report.\n --issue-template Print a safe, Markdown issue template with diagnostics and fill-in reproduction fields. Read-only.\n --sessions Also scan session logs for exact known Vision Router corruption signatures (read-only; may take longer).\n --runtime-url <url> Probe a running DSH web instance (default: DSH_WEB_URL or http://127.0.0.1:3080).\n --no-runtime Skip the read-only runtime route probe.\n --upgrade-preflight Read-only gate for known 3.2 profile migration hazards; not a full release approval.\n --fix Backward-compatible doctor repair mode; prefer \`repair\`.\n --help Show this help.\n`
12
12
  }
13
13
 
14
14
  function parseArgs(argv) {
@@ -20,6 +20,7 @@ function parseArgs(argv) {
20
20
  let json = false
21
21
  let issueTemplate = false
22
22
  let sessions = false
23
+ let upgradePreflight = false
23
24
  let runtime = command === 'doctor'
24
25
  let runtimeUrl
25
26
 
@@ -41,6 +42,11 @@ function parseArgs(argv) {
41
42
  issueTemplate = true
42
43
  continue
43
44
  }
45
+ if (value === '--upgrade-preflight') {
46
+ if (command !== 'doctor') throw new Error('--upgrade-preflight is only used with doctor')
47
+ upgradePreflight = true
48
+ continue
49
+ }
44
50
  if (value === '--sessions') {
45
51
  if (command !== 'doctor') throw new Error('--sessions is only used with doctor')
46
52
  sessions = true
@@ -83,6 +89,8 @@ function parseArgs(argv) {
83
89
  if (!['doctor', 'repair', 'repair-sessions'].includes(command)) throw new Error(`unknown command: ${command}`)
84
90
  if (issueTemplate && json) throw new Error('--issue-template and --json cannot be combined')
85
91
  if (issueTemplate && fix) throw new Error('--issue-template is read-only and cannot be combined with --fix')
92
+ if (upgradePreflight && fix) throw new Error('--upgrade-preflight is read-only and cannot be combined with --fix')
93
+ if (upgradePreflight && issueTemplate) throw new Error('--upgrade-preflight is not an issue template; use --json instead')
86
94
  if (profile && (!/^[A-Za-z0-9._-]+$/.test(profile) || profile === '.' || profile === '..')) {
87
95
  throw new Error(`invalid profile name: ${profile}`)
88
96
  }
@@ -91,7 +99,7 @@ function parseArgs(argv) {
91
99
  try { parsed = new URL(runtimeUrl) } catch { throw new Error(`invalid runtime URL: ${runtimeUrl}`) }
92
100
  if (!['http:', 'https:'].includes(parsed.protocol)) throw new Error(`invalid runtime URL protocol: ${parsed.protocol}`)
93
101
  }
94
- return { command, profile, fix, json, issueTemplate, sessions, runtime, runtimeUrl }
102
+ return { command, profile, fix, json, issueTemplate, sessions, upgradePreflight, runtime, runtimeUrl }
95
103
  }
96
104
 
97
105
  /**
@@ -130,6 +138,8 @@ function formatIssueTemplate(report) {
130
138
  `- Vision Router profiles: ${applicable.length} applicable; ${failed.length} installation/problem profile(s)`,
131
139
  `- Install modes: ${modes}`,
132
140
  `- Offline Host core advisories: ${applicable.filter((profile) => (profile.hostCore?.advisoryCount ?? 0) > 0).length} profile(s), unverified (no Host resolution test)`,
141
+ `- Profile-owned Connection overrides: ${applicable.filter((profile) => (profile.patch?.connectionOverrideRows ?? 0) > 0).length} profile(s), manual review required`,
142
+ `- Retired private Connection-bridge references: ${applicable.filter((profile) => (profile.patch?.retiredReadyBridgeRows ?? 0) + (profile.patch?.retiredReadyInjectionRows ?? 0) > 0).length} profile(s)`,
133
143
  `- Runtime: ${runtimeState}`,
134
144
  `- Settings save failures: ${number(report.log?.currentSettingsFailureCount)} current / ${number(report.log?.historicalSettingsFailureCount)} historical`,
135
145
  `- Known session issues: ${sessionState}`,
@@ -190,6 +200,52 @@ function printProfileDetails(profile, io) {
190
200
  for (const warning of profile.installation?.warnings ?? []) io.log(` ! ${warning}`)
191
201
  }
192
202
 
203
+ /** Source refs are classified without dereferencing credentials or Git.
204
+ * A lockfile contains a resolved commit today, but lockfile regeneration can
205
+ * still follow the mutable manifest source.
206
+ */
207
+ export function isFloatingDvrGitSource(spec) {
208
+ if (typeof spec !== 'string') return false
209
+ const source = spec.trim()
210
+ if (!/^(?:github:|git\+|git@|https?:\/\/(?:www\.)?github\.com\/)/i.test(source)) return false
211
+ const anchor = source.indexOf('#')
212
+ if (anchor < 0 || anchor === source.length - 1) return true
213
+ const ref = source.slice(anchor + 1)
214
+ if (/^[0-9a-f]{40}$/i.test(ref)) return false
215
+ if (/^v?\d+\.\d+\.\d+(?:-[0-9a-z.-]+)?$/i.test(ref)) return false
216
+ // Branch names, semver ranges, HEAD and unconventional tags need
217
+ // review before the 3.2 Host floor becomes user-facing.
218
+ return true
219
+ }
220
+
221
+ /** Read-only, intentionally narrow upgrade fence. This reports only known
222
+ * profile-owned composition blockers. It does not establish the running
223
+ * Desktop Host version or prove image/transport/session functionality.
224
+ * Counts only: no user paths, hostnames, credentials or patch bodies.
225
+ */
226
+ export function assessUpgradeProfileRisk(profileReport, platform) {
227
+ const applicable = (profileReport?.profiles ?? []).filter((item) => item.installation?.applicable)
228
+ const count = (predicate) => applicable.filter(predicate).length
229
+ const blockers = []
230
+ const add = (code, n) => { if (n > 0) blockers.push({ code, affectedProfiles: n }) }
231
+ add('PROFILE_CONNECTION_OVERRIDE', count((p) => (p.patch?.connectionOverrideRows ?? 0) > 0))
232
+ add('RETIRED_READY_BRIDGE_REFERENCE', count((p) =>
233
+ (p.patch?.retiredReadyBridgeRows ?? 0) + (p.patch?.retiredReadyInjectionRows ?? 0) > 0))
234
+ add('STALE_WORKSPACE_RELEASE_AGE_PIN', count((p) =>
235
+ (p.workspace?.pinned?.length ?? 0) > 0 && p.workspace?.rewritten !== true))
236
+ add('FLOATING_GITHUB_DVR_SOURCE', count((p) => isFloatingDvrGitSource(p.pluginDependency)))
237
+ if (platform?.nodeSupported === false) add('NODE_BELOW_3_2_MINIMUM', 1)
238
+ return Object.freeze({
239
+ scope: 'known-profile-risks-only',
240
+ profileCount: applicable.length,
241
+ pass: Boolean(profileReport?.ok) && blockers.length === 0,
242
+ blockers,
243
+ actualDesktopHostVersionVerified: false,
244
+ runtimeAndHistoricalDataVerified: false,
245
+ fullReleaseApproval: false,
246
+ })
247
+ }
248
+
193
249
  function runSessionRepair(dshHome, io) {
194
250
  let report
195
251
  try {
@@ -274,13 +330,17 @@ export async function run(argv = process.argv.slice(2), io = console, env = proc
274
330
  let sessions
275
331
  if (options.sessions) sessions = repairLegacySessionLogs({ dshHome, fix: false })
276
332
 
333
+ const upgradePreflight = options.upgradePreflight
334
+ ? assessUpgradeProfileRisk(profileReport, platform) : undefined
277
335
  const overallOk = profileReport.ok
278
336
  && (runtime?.ok ?? true)
279
337
  && (!sessions || (sessions.affected === 0 && sessions.errors.length === 0))
338
+ && (!upgradePreflight || upgradePreflight.pass)
280
339
 
281
340
  if (options.json || options.issueTemplate) {
282
341
  const report = supportReport({ profileReport, runtime, platform, sessions })
283
342
  report.visionLimits = visionLimits
343
+ if (upgradePreflight) report.upgradePreflight = upgradePreflight
284
344
  report.ok = overallOk
285
345
  io.log(options.issueTemplate ? formatIssueTemplate(report) : JSON.stringify(report, null, 2))
286
346
  return overallOk ? 0 : 1
@@ -288,6 +348,14 @@ export async function run(argv = process.argv.slice(2), io = console, env = proc
288
348
 
289
349
  io.log(`DSH home: ${profileReport.dshHome}`)
290
350
  for (const profile of profileReport.profiles) printProfileDetails(profile, io)
351
+ if (upgradePreflight) {
352
+ if (upgradePreflight.pass) io.log('✓ Upgrade profile preflight: known overlay/workspace hazards not detected. Not full release approval.')
353
+ else {
354
+ io.error('✗ Upgrade profile preflight: blocked; do not upgrade this profile without resolving the following.')
355
+ for (const item of upgradePreflight.blockers) io.error(` ✗ ${item.code}: ${item.affectedProfiles} affected profile(s)`)
356
+ }
357
+ io.log('! Upgrade preflight does not verify the running Desktop Host, runtime routes, or historical data.')
358
+ }
291
359
  if (profileReport.applicableProfiles === 0) io.error('✗ Vision Router is not installed or mounted in any discovered profile.')
292
360
 
293
361
  if (profileReport.log?.settingsSaveFailures?.length > 0) {
@@ -227,11 +227,13 @@ const HOST_PACKAGES = [
227
227
  '@deepseek-ai/dsh-client-ui-settings-plugins',
228
228
  '@deepseek-ai/dsh-attachment-local',
229
229
  '@deepseek-ai/dsh-llm-deepseek',
230
+ '@deepseek-ai/dsh',
230
231
  ]
231
232
 
232
233
  function supportedNodeVersion(version = process.versions.node) {
233
- const [major, minor] = String(version).split('.').map(Number)
234
- return (major === 22 && minor >= 19) || major >= 24
234
+ const [major, minor, patch] = String(version).replace(/^v/, '').split('.').map(Number)
235
+ return Number.isInteger(major) && Number.isInteger(minor) && Number.isInteger(patch)
236
+ && (major > 24 || (major === 24 && minor >= 9))
235
237
  }
236
238
 
237
239
  export function inspectPlatform({ profileDirs = [], env = process.env } = {}) {
@@ -247,7 +249,7 @@ export function inspectPlatform({ profileDirs = [], env = process.env } = {}) {
247
249
  arch: process.arch,
248
250
  node: process.version,
249
251
  nodeSupported: supportedNodeVersion(),
250
- nodeRequirement: '^22.19.0 || >=24.0.0',
252
+ nodeRequirement: '>=24.9.0',
251
253
  release: os.release(),
252
254
  tesseract: tesseract ?? { available: false },
253
255
  chromium: chromium ?? { available: false },
@@ -348,6 +350,9 @@ export function supportReport({ profileReport, runtime, platform, sessions }) {
348
350
  workspacePinnedCount: item.workspace?.pinned?.length ?? 0,
349
351
  patch: item.patch ? {
350
352
  visionRouterRows: item.patch.visionRouterRows,
353
+ connectionOverrideRows: item.patch.connectionOverrideRows ?? 0,
354
+ retiredReadyBridgeRows: item.patch.retiredReadyBridgeRows ?? 0,
355
+ retiredReadyInjectionRows: item.patch.retiredReadyInjectionRows ?? 0,
351
356
  manualVisionRouter: item.patch.manualVisionRouter,
352
357
  disablesOfficialDeepSeek: item.patch.disablesOfficialDeepSeek,
353
358
  } : undefined,
package/lib/doctor.js CHANGED
@@ -414,6 +414,51 @@ function inspectVisionRouterPatchRows(lines) {
414
414
  return { mountRows, overrideRows }
415
415
  }
416
416
 
417
+ /**
418
+ * Read-only advisory for profile-owned DSH Connection overrides.
419
+ * The supported DSH 0.2.1+ Web Host owns this row; a user patch is applied
420
+ * after bundle patches and can silently resurrect the retired dependency.
421
+ * This deliberately reads only structure, not trust values or secrets.
422
+ */
423
+ function inspectRetiredConnectionPatchRows(lines) {
424
+ let connectionOverrideRows = 0
425
+ let retiredReadyBridgeRows = 0
426
+ let retiredReadyInjectionRows = 0
427
+ for (let index = 0; index < lines.length; index += 1) {
428
+ const line = lines[index]
429
+ const id = /^\s*-\s+id\s*:\s*['"]?([^'"\s]+)['"]?\s*$/.exec(line)?.[1]
430
+ if (id === 'connection') connectionOverrideRows += 1
431
+ if (id === 'vision-router-web-connection-ready') retiredReadyBridgeRows += 1
432
+ const name = /^\s*name\s*:\s*['"]?([^'"\s]+)['"]?\s*$/.exec(line)?.[1]
433
+ if (name === './presets/web-connection-ready/index.mjs'
434
+ || name === 'vision-router-web-connection-ready') {
435
+ // Count named bridge rows even if an alias id is used, but not twice.
436
+ const previous = lines.slice(Math.max(0, index - 5), index)
437
+ if (!previous.some((item) => /^\s*-\s+id:\s*['"]?vision-router-web-connection-ready['"]?\s*$/.test(item))) {
438
+ retiredReadyBridgeRows += 1
439
+ }
440
+ }
441
+ const inject = /^(\s*)inject\s*:\s*(.*)$/.exec(line)
442
+ if (!inject) continue
443
+ const matchService = (value) => /(?:^|[^A-Za-z0-9_])visionRouterWebConnectionReady(?:$|[^A-Za-z0-9_])/.test(value)
444
+ if (matchService(inject[2])) {
445
+ retiredReadyInjectionRows += 1
446
+ } else if (inject[2].trim() === '') {
447
+ const indent = inject[1].length
448
+ for (let cursor = index + 1; cursor < lines.length; cursor += 1) {
449
+ const row = lines[cursor]
450
+ if (!row.trim()) continue
451
+ if (yamlIndent(row) <= indent) break
452
+ if (/^\s*-\s+visionRouterWebConnectionReady\s*$/.test(row)) {
453
+ retiredReadyInjectionRows += 1
454
+ break
455
+ }
456
+ }
457
+ }
458
+ }
459
+ return { connectionOverrideRows, retiredReadyBridgeRows, retiredReadyInjectionRows }
460
+ }
461
+
417
462
  export function inspectProfilePatch(patchPath) {
418
463
  if (!existsSync(patchPath)) {
419
464
  return {
@@ -421,6 +466,9 @@ export function inspectProfilePatch(patchPath) {
421
466
  exists: false,
422
467
  visionRouterRows: 0,
423
468
  visionRouterOverrideRows: 0,
469
+ connectionOverrideRows: 0,
470
+ retiredReadyBridgeRows: 0,
471
+ retiredReadyInjectionRows: 0,
424
472
  manualVisionRouter: false,
425
473
  disablesOfficialDeepSeek: false,
426
474
  }
@@ -429,10 +477,11 @@ export function inspectProfilePatch(patchPath) {
429
477
  try {
430
478
  text = readFileBounded(patchPath).toString('utf8')
431
479
  } catch (error) {
432
- return { path: patchPath, exists: true, visionRouterRows: 0, visionRouterOverrideRows: 0, manualVisionRouter: false, disablesOfficialDeepSeek: false, error: error instanceof Error ? error.message : String(error), oversized: error?.code === 'DOCTOR_INPUT_TOO_LARGE' }
480
+ return { path: patchPath, exists: true, visionRouterRows: 0, visionRouterOverrideRows: 0, connectionOverrideRows: 0, retiredReadyBridgeRows: 0, retiredReadyInjectionRows: 0, manualVisionRouter: false, disablesOfficialDeepSeek: false, error: error instanceof Error ? error.message : String(error), oversized: error?.code === 'DOCTOR_INPUT_TOO_LARGE' }
433
481
  }
434
482
  const lines = text.split(/\r?\n/).map(stripYamlComment)
435
483
  const { mountRows: visionRouterRows, overrideRows: visionRouterOverrideRows } = inspectVisionRouterPatchRows(lines)
484
+ const retiredConnection = inspectRetiredConnectionPatchRows(lines)
436
485
  let disablesOfficialDeepSeek = false
437
486
  for (let index = 0; index < lines.length; index += 1) {
438
487
  const line = lines[index]
@@ -450,6 +499,7 @@ export function inspectProfilePatch(patchPath) {
450
499
  exists: true,
451
500
  visionRouterRows,
452
501
  visionRouterOverrideRows,
502
+ ...retiredConnection,
453
503
  manualVisionRouter: visionRouterRows > 0,
454
504
  disablesOfficialDeepSeek,
455
505
  }
@@ -525,6 +575,12 @@ export function classifyProfileInstallation(profile, { requested = false } = {})
525
575
  if (profile?.patch?.disablesOfficialDeepSeek) {
526
576
  warnings.push('cordis.patch.yml statically disables llm-deepseek; legacy stealth patches can make the official model disappear when Vision Router is disabled')
527
577
  }
578
+ if (profile?.patch?.connectionOverrideRows > 0) {
579
+ warnings.push('Profile-owned Connection override detected: DSH 0.2.1+ owns this Host row. Review/remove the obsolete override manually after backing up your profile; Doctor does not modify authentication or trustedHosts.')
580
+ }
581
+ if (profile?.patch?.retiredReadyBridgeRows > 0 || profile?.patch?.retiredReadyInjectionRows > 0) {
582
+ warnings.push('Profile still references retired visionRouterWebConnectionReady bridge: verify and migrate this custom overlay manually. DVR 3.2 no longer provides that service; Doctor changes no profile data.')
583
+ }
528
584
  for (const item of profile?.hostCore?.advisories ?? []) {
529
585
  if (item.kind === 'profile-local-host-core') {
530
586
  warnings.push('Possible Host core shadowing (unverified): profile-local '