dsh-vision-router 3.2.0 → 3.3.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/README.md +6 -6
- package/README.zh.md +21 -6
- package/THIRD_PARTY_NOTICES.md +167 -0
- package/assets/licenses/apache-2.0.txt +202 -0
- package/assets/licenses/llvm-mingw-LICENSE.txt +279 -0
- package/assets/licenses/mingw-w64-runtime-COPYING.txt +265 -0
- package/assets/licenses/moxcms-BSD-3-Clause.txt +26 -0
- package/assets/licenses/ncnn-LICENSE.txt +86 -0
- package/assets/licenses/roots-BSD-2-Clause.txt +24 -0
- package/assets/licenses/unicode-ident-Unicode-3.0.txt +39 -0
- package/assets/licenses/vtracer-MIT.txt +25 -0
- package/assets/licenses/zlib-rs-Zlib.txt +19 -0
- package/docs/architecture/dsh-support-window.md +25 -6
- package/docs/compatibility/dsh-0.2.2-rc2-audit.md +40 -0
- package/docs/compatibility/dsh-0.2.2-rc3-audit.md +131 -0
- package/docs/compliance/vtracer-alpha4-provenance.md +47 -0
- package/docs/compliance/vtracer-alpha4-reconstructed-Cargo.lock +567 -0
- package/docs/compliance/vtracer-alpha4-rust-inventory.json +421 -0
- package/docs/compliance/vtracer-alpha4-rust-license-texts.md +13018 -0
- package/docs/releases/v3.2.1.md +21 -0
- package/docs/releases/v3.2.2.md +25 -0
- package/docs/releases/v3.3.0.md +34 -0
- package/docs/remote-settings.md +83 -8
- package/index.js +280 -169
- package/lib/client.js +17 -17
- package/lib/core-primitives.js +155 -214
- package/lib/dsh-support-window.js +6 -3
- package/lib/native-ocr-annotation-risk.js +33 -0
- package/lib/native-ocr-canary.js +156 -0
- package/lib/native-ocr-chemistry-review.js +37 -0
- package/lib/native-ocr-document.js +243 -0
- package/lib/native-ocr-installation.js +17 -0
- package/lib/native-ocr-integrity.js +93 -0
- package/lib/native-ocr-question-labels.js +167 -0
- package/lib/native-ocr-supervisor.js +268 -0
- package/lib/remote-settings-bridge.js +93 -57
- package/lib/remote-settings-risk-client-boundary.js +2 -2
- package/lib/runtime-reliability.js +7 -0
- package/lib/session-query-readers.js +8 -2
- package/lib/session-vision-attachment-index.js +61 -14
- package/lib/settings-client-017-compat.js +4 -2
- package/lib/settings-ia-client-prelude.js +26 -10
- package/lib/tesseract-image-preprocess.js +35 -0
- package/lib/trace-vtracer-process-runtime.js +133 -0
- package/lib/trace-vtracer-process.js +43 -0
- package/lib/trace-vtracer-worker.js +163 -0
- package/lib/vision-attachment-handle-runtime.js +11 -2
- package/lib/vision-backend-runtime-policy.js +5 -3
- package/lib/vision-image-input-reader.js +67 -0
- package/lib/vision-image-input-verdict.js +24 -3
- package/lib/vision-tool-runtime-boundary.js +7 -10
- package/lib/vision-tool-stage.js +58 -0
- package/lib/web/dsh-settings-017-root-transport.js +52 -6
- package/lib/web-capability-boundary.js +6 -0
- package/package.json +10 -6
- package/scripts/install-native-ocr.mjs +144 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { parentPort, workerData } from 'node:worker_threads'
|
|
2
|
+
import { createRequire } from 'node:module'
|
|
3
|
+
|
|
4
|
+
const require = createRequire(import.meta.url)
|
|
5
|
+
const vtracer = require('@visioncortex/vtracer')
|
|
6
|
+
const MAX_TRACE_PIXELS = 1_000_000
|
|
7
|
+
|
|
8
|
+
function assertDimensions(width, height, byteLength) {
|
|
9
|
+
if (
|
|
10
|
+
!Number.isSafeInteger(width) || !Number.isSafeInteger(height) ||
|
|
11
|
+
width < 1 || height < 1 || width * height > MAX_TRACE_PIXELS ||
|
|
12
|
+
byteLength !== width * height * 4
|
|
13
|
+
) throw new RangeError('invalid trace RGBA dimensions')
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function grayPalette(gray, channels, width, height, steps) {
|
|
17
|
+
const histogram = new Float64Array(256)
|
|
18
|
+
const pixels = width * height
|
|
19
|
+
for (let i = 0; i < pixels; i++) histogram[gray[i * channels]]++
|
|
20
|
+
const count = Math.min(17, Math.max(2, steps + 1))
|
|
21
|
+
const quantile = (fraction) => {
|
|
22
|
+
let seen = 0
|
|
23
|
+
for (let i = 0; i < 256; i++) {
|
|
24
|
+
seen += histogram[i]
|
|
25
|
+
if (seen >= fraction * pixels) return i
|
|
26
|
+
}
|
|
27
|
+
return 255
|
|
28
|
+
}
|
|
29
|
+
let centers = Array.from({ length: count }, (_, i) => quantile((i + 0.5) / count))
|
|
30
|
+
for (let pass = 0; pass < 15; pass++) {
|
|
31
|
+
const sums = new Float64Array(count)
|
|
32
|
+
const sizes = new Float64Array(count)
|
|
33
|
+
for (let value = 0; value < 256; value++) {
|
|
34
|
+
const frequency = histogram[value]
|
|
35
|
+
if (!frequency) continue
|
|
36
|
+
let closest = 0
|
|
37
|
+
let distance = Infinity
|
|
38
|
+
for (let j = 0; j < count; j++) {
|
|
39
|
+
const delta = Math.abs(value - centers[j])
|
|
40
|
+
if (delta < distance) { closest = j; distance = delta }
|
|
41
|
+
}
|
|
42
|
+
sums[closest] += value * frequency
|
|
43
|
+
sizes[closest] += frequency
|
|
44
|
+
}
|
|
45
|
+
centers = centers.map((v, j) => sizes[j] ? sums[j] / sizes[j] : v)
|
|
46
|
+
}
|
|
47
|
+
const values = [...new Set(centers.map((v) => Math.max(0, Math.min(255, Math.round(v)))))]
|
|
48
|
+
if (values.length === 1) values.push(values[0] < 128 ? 255 : 0)
|
|
49
|
+
return values.sort((a, b) => a - b).map((v) => '#' + v.toString(16).padStart(2, '0').repeat(3))
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function colorPalette(palette) {
|
|
53
|
+
if (!Array.isArray(palette) || palette.length > 16 ||
|
|
54
|
+
palette.some((p) => !p || typeof p.hex !== 'string' || !/^#[0-9a-f]{6}$/i.test(p.hex))) {
|
|
55
|
+
throw new RangeError('invalid trace color palette')
|
|
56
|
+
}
|
|
57
|
+
// Exact-palette callers own their color choices. Never silently append
|
|
58
|
+
// white (which could exceed the 16-color contract); alpha is still composited
|
|
59
|
+
// against white before tracing.
|
|
60
|
+
return [...new Set(palette.map((p) => p.hex.toLowerCase()))]
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function grayscaleTrace(bytes, steps) {
|
|
64
|
+
if (!Number.isInteger(steps) || steps < 1 || steps > 16) {
|
|
65
|
+
throw new RangeError('trace steps must be an integer between 1 and 16')
|
|
66
|
+
}
|
|
67
|
+
const sharpModule = await import(workerData.sharpUrl)
|
|
68
|
+
const sharp = sharpModule.default ?? sharpModule
|
|
69
|
+
const image = sharp(bytes, { failOn: 'error', limitInputPixels: MAX_TRACE_PIXELS })
|
|
70
|
+
const { data, info } = await image.flatten({ background: '#ffffff' }).greyscale()
|
|
71
|
+
.raw().toBuffer({ resolveWithObject: true })
|
|
72
|
+
const { width, height, channels } = info
|
|
73
|
+
if (width * height > MAX_TRACE_PIXELS || !channels) throw new RangeError('trace image exceeds pixel budget')
|
|
74
|
+
const rgba = Buffer.alloc(width * height * 4)
|
|
75
|
+
for (let i = 0; i < width * height; i++) {
|
|
76
|
+
const gray = data[i * channels]
|
|
77
|
+
const offset = i * 4
|
|
78
|
+
rgba[offset] = gray
|
|
79
|
+
rgba[offset + 1] = gray
|
|
80
|
+
rgba[offset + 2] = gray
|
|
81
|
+
rgba[offset + 3] = 255
|
|
82
|
+
}
|
|
83
|
+
const palette = grayPalette(data, channels, width, height, steps)
|
|
84
|
+
// VTracer's palette option constrains color *selection* but does not force
|
|
85
|
+
// grayscale pixel clustering. Without quantizing the raster itself,
|
|
86
|
+
// smooth black-to-white gradients can collapse to a single solid path.
|
|
87
|
+
// Explicitly posterize each input pixel to the nearest adaptive level.
|
|
88
|
+
const paletteValues = palette.map((hex) => Number.parseInt(hex.slice(1, 3), 16))
|
|
89
|
+
const lookup = new Uint8Array(256)
|
|
90
|
+
for (let gray = 0; gray < 256; gray++) {
|
|
91
|
+
let closest = paletteValues[0]
|
|
92
|
+
let distance = Infinity
|
|
93
|
+
for (const candidate of paletteValues) {
|
|
94
|
+
const delta = Math.abs(candidate - gray)
|
|
95
|
+
if (delta < distance) { distance = delta; closest = candidate }
|
|
96
|
+
}
|
|
97
|
+
lookup[gray] = closest
|
|
98
|
+
}
|
|
99
|
+
for (let i = 0; i < rgba.length; i += 4) {
|
|
100
|
+
const q = lookup[rgba[i]]
|
|
101
|
+
rgba[i] = q
|
|
102
|
+
rgba[i + 1] = q
|
|
103
|
+
rgba[i + 2] = q
|
|
104
|
+
}
|
|
105
|
+
return vtracer.convertPixels(rgba, width, height, {
|
|
106
|
+
preset: 'poster', mode: 'spline', hierarchical: 'cutout',
|
|
107
|
+
palette, maxColors: palette.length, simplify: 0.5, optimize: 1,
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function colorTrace(data, width, height, palette, colorLimit) {
|
|
112
|
+
assertDimensions(width, height, data.length)
|
|
113
|
+
const explicit = Array.isArray(palette)
|
|
114
|
+
const colors = explicit ? colorPalette(palette) : undefined
|
|
115
|
+
const maxColors = explicit ? Math.max(1, colors.length) : colorLimit
|
|
116
|
+
if (!Number.isInteger(maxColors) || maxColors < 1 || maxColors > 16) {
|
|
117
|
+
throw new RangeError('invalid trace color limit')
|
|
118
|
+
}
|
|
119
|
+
const raw = Buffer.from(data)
|
|
120
|
+
for (let i = 0; i < raw.length; i += 4) {
|
|
121
|
+
const alpha = raw[i + 3]
|
|
122
|
+
// Preserve existing DVR's opaque-white SVG artifact background.
|
|
123
|
+
if (alpha === 0) {
|
|
124
|
+
raw[i] = 255; raw[i + 1] = 255; raw[i + 2] = 255
|
|
125
|
+
} else if (alpha < 255) {
|
|
126
|
+
const a = alpha / 255
|
|
127
|
+
raw[i] = Math.round(raw[i] * a + 255 * (1 - a))
|
|
128
|
+
raw[i + 1] = Math.round(raw[i + 1] * a + 255 * (1 - a))
|
|
129
|
+
raw[i + 2] = Math.round(raw[i + 2] * a + 255 * (1 - a))
|
|
130
|
+
}
|
|
131
|
+
raw[i + 3] = 255
|
|
132
|
+
}
|
|
133
|
+
if (explicit && colors.length === 0) {
|
|
134
|
+
return '<svg xmlns="http://www.w3.org/2000/svg" width="' + width +
|
|
135
|
+
'" height="' + height + '" viewBox="0 0 ' + width + ' ' + height +
|
|
136
|
+
'"><rect width="' + width + '" height="' + height + '" fill="#ffffff"/></svg>'
|
|
137
|
+
}
|
|
138
|
+
return vtracer.convertPixels(raw, width, height, {
|
|
139
|
+
preset: 'poster', mode: 'spline', hierarchical: 'cutout',
|
|
140
|
+
...(explicit ? { palette: colors } : {}),
|
|
141
|
+
maxColors, simplify: 0.5, optimize: 1,
|
|
142
|
+
})
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async function main() {
|
|
146
|
+
const { mode } = workerData
|
|
147
|
+
let svg
|
|
148
|
+
if (mode === 'grayscale') {
|
|
149
|
+
svg = await grayscaleTrace(Buffer.from(workerData.bytes), workerData.steps)
|
|
150
|
+
} else if (mode === 'color') {
|
|
151
|
+
svg = colorTrace(workerData.data, workerData.width, workerData.height,
|
|
152
|
+
workerData.palette, workerData.colors)
|
|
153
|
+
} else {
|
|
154
|
+
throw new RangeError('unsupported trace mode')
|
|
155
|
+
}
|
|
156
|
+
if (typeof svg !== 'string' || !/<svg[\s>]/.test(svg) || svg.length > 16 * 1024 * 1024) {
|
|
157
|
+
throw new Error('vectorizer returned an invalid or oversized SVG')
|
|
158
|
+
}
|
|
159
|
+
// VTracer writes uppercase RGB hex codes; preserve DVR's lowercase palette contract.
|
|
160
|
+
parentPort.postMessage({ ok: true, svg: svg.replace(/#[a-fA-F0-9]{6}\b/g, (hex) => hex.toLowerCase()) })
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
main().catch((error) => parentPort.postMessage({ error: String(error?.message ?? error) }))
|
|
@@ -64,9 +64,18 @@ function collectImageRefsFromMessages(messages, out) {
|
|
|
64
64
|
collectImageRefsFromBlocks(objectRecord(message)?.content, out);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
/**
|
|
68
|
+
* The current Session's derived image blocks are already authorized as that
|
|
69
|
+
* Session's content. Reuse this same collector for projected short handles
|
|
70
|
+
* and target-only cold attachment recovery; neither may scan other Sessions.
|
|
71
|
+
*/
|
|
72
|
+
export function sessionImageAttachmentRefs(session) {
|
|
68
73
|
const refs = [];
|
|
69
|
-
collectImageRefsFromMessages(sessionMessages(
|
|
74
|
+
collectImageRefsFromMessages(sessionMessages(session), refs);
|
|
75
|
+
return refs;
|
|
76
|
+
}
|
|
77
|
+
function authorizedRefs(agent) {
|
|
78
|
+
const refs = sessionImageAttachmentRefs(agent?.session);
|
|
70
79
|
collectImageRefsFromMessages(agent?.inbox?.nextTurn, refs);
|
|
71
80
|
collectImageRefsFromMessages(agent?.inbox?.nextStep, refs);
|
|
72
81
|
const unique = new Map();
|
|
@@ -132,7 +132,7 @@ function contentHasImage(_core, messages) {
|
|
|
132
132
|
return (messages ?? []).some((message) => blocksHaveRetainedImage(message?.content))
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
async function toOpenAIMessages(ctx, messages) {
|
|
135
|
+
async function toOpenAIMessages(ctx, messages, signal) {
|
|
136
136
|
const attachments = ctx?.get?.('attachments')
|
|
137
137
|
if (!attachments || typeof attachments.readImage !== 'function') {
|
|
138
138
|
const error = new Error('vision preflight bridge unavailable: attachment service is not registered')
|
|
@@ -152,7 +152,9 @@ async function toOpenAIMessages(ctx, messages) {
|
|
|
152
152
|
converted.push({ type: 'text', text: offloadedImagePlaceholder(block) })
|
|
153
153
|
continue
|
|
154
154
|
}
|
|
155
|
-
|
|
155
|
+
if (signal?.aborted) throw signal.reason ?? new Error('vision delivery aborted')
|
|
156
|
+
const stored = await attachments.readImage(block.attachment, signal)
|
|
157
|
+
if (signal?.aborted) throw signal.reason ?? new Error('vision delivery aborted')
|
|
156
158
|
const mediaType = block.attachment.mediaType || stored?.mediaType || 'image/png'
|
|
157
159
|
const data = Buffer.from(stored.data).toString('base64')
|
|
158
160
|
converted.push({ type: 'image_url', image_url: { url: `data:${mediaType};base64,${data}` } })
|
|
@@ -235,7 +237,7 @@ function directStream(ctx, core, plan, call, logger, source, providerTransport)
|
|
|
235
237
|
if (typeof plan.transport?.apiKeyEnv === 'string' && plan.transport.apiKeyEnv !== '' && !apiKey) {
|
|
236
238
|
throw new Error('vision preflight bridge unavailable: channel credential could not be resolved')
|
|
237
239
|
}
|
|
238
|
-
const messages = await toOpenAIMessages(ctx, call.messages)
|
|
240
|
+
const messages = await toOpenAIMessages(ctx, call.messages, call.signal)
|
|
239
241
|
if (messages.length === 0) {
|
|
240
242
|
throw new Error('vision preflight bridge unavailable: no representable image request content')
|
|
241
243
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { combineSignals } from './vision-resilience.js'
|
|
2
|
+
import { currentVisionTurnBudgetSignal } from './turn-budget-context.js'
|
|
3
|
+
import { isAttachmentIdInput, sniffMediaType, mediaTypeOf } from './core-primitives.js'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* One authorized image-source reader for all Vision Router tools.
|
|
7
|
+
* Source identity belongs to the caller's Session, not to the global
|
|
8
|
+
* content-addressed attachment store. Neither the Host's private path nor
|
|
9
|
+
* untrusted model-facing short attachment aliases become filesystem inputs.
|
|
10
|
+
*/
|
|
11
|
+
export function createVisionImageInputReader(ctx, resolveAttachment, throwIfVisionTaskAborted) {
|
|
12
|
+
return async function readImageBytes(exec, imagePath, resolvedAttachmentRefs, attachmentInput = false) {
|
|
13
|
+
const input = String(imagePath ?? '')
|
|
14
|
+
const signal = combineSignals(currentVisionTurnBudgetSignal(), exec?.signal)
|
|
15
|
+
throwIfVisionTaskAborted(signal)
|
|
16
|
+
let bytes
|
|
17
|
+
let storedMediaType
|
|
18
|
+
if (attachmentInput || isAttachmentIdInput(input)) {
|
|
19
|
+
// Uploaded images reach the tool arguments as durable attachment ids
|
|
20
|
+
// ("sha256:..."); resolve them through the session's recorded upload
|
|
21
|
+
// index instead of treating the id as a filesystem path.
|
|
22
|
+
const attachments = ctx.get('attachments')
|
|
23
|
+
if (attachments === undefined) {
|
|
24
|
+
throw new Error('vision-router: the attachment service is not available in this deployment')
|
|
25
|
+
}
|
|
26
|
+
const session = exec && exec.agent && exec.agent.session
|
|
27
|
+
const canonicalInput = input.trim()
|
|
28
|
+
const ref = resolvedAttachmentRefs instanceof Map
|
|
29
|
+
? resolvedAttachmentRefs.get(canonicalInput)
|
|
30
|
+
: await resolveAttachment(session, canonicalInput, signal)
|
|
31
|
+
if (ref === undefined) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
`vision-router: unknown attachment id "${input}" (it must come from an image uploaded in this conversation)`,
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
throwIfVisionTaskAborted(signal)
|
|
37
|
+
let stored
|
|
38
|
+
try {
|
|
39
|
+
stored = await attachments.readImage(ref, signal)
|
|
40
|
+
throwIfVisionTaskAborted(signal)
|
|
41
|
+
} catch (error) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
`vision-router: failed to read attachment ${input} (${error && error.message ? error.message : String(error)})`,
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
bytes = stored.data
|
|
47
|
+
if (stored.ref && typeof stored.ref.mediaType === 'string') {
|
|
48
|
+
storedMediaType = stored.ref.mediaType
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
const fs = ctx.get('fs')
|
|
52
|
+
if (fs === undefined) throw new Error('vision-router: the fs service is not available')
|
|
53
|
+
const target = await fs.resolve(input)
|
|
54
|
+
throwIfVisionTaskAborted(signal)
|
|
55
|
+
bytes = await fs.readBytes(target, signal, 20 * 1024 * 1024)
|
|
56
|
+
throwIfVisionTaskAborted(signal)
|
|
57
|
+
}
|
|
58
|
+
// Attachments are stored as content-addressed files without an
|
|
59
|
+
// extension: sniff the format from the bytes, and fall back to the
|
|
60
|
+
// stored ref / extension only when sniffing cannot decide.
|
|
61
|
+
const mediaType = sniffMediaType(bytes) ?? storedMediaType ?? mediaTypeOf(input)
|
|
62
|
+
if (mediaType === undefined) {
|
|
63
|
+
throw new Error(`unsupported image format ${input} (png/jpeg/webp/gif only)`)
|
|
64
|
+
}
|
|
65
|
+
return { bytes, mediaType }
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto'
|
|
2
|
-
import { mkdir, readFile, rename, writeFile } from 'node:fs/promises'
|
|
2
|
+
import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises'
|
|
3
3
|
import path from 'node:path'
|
|
4
4
|
import process from 'node:process'
|
|
5
5
|
import { resolveDshHome } from './doctor.js'
|
|
@@ -74,8 +74,28 @@ async function save(file, records, fsOps) {
|
|
|
74
74
|
const temporary = `${file}.${process.pid}.${Date.now()}.${randomUUID()}.tmp`
|
|
75
75
|
const verdicts = selectRetainedVerdicts(records.values())
|
|
76
76
|
await fsOps.mkdir(path.dirname(file), { recursive: true })
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
try {
|
|
78
|
+
await fsOps.writeFile(temporary, JSON.stringify({ version: CACHE_VERSION, verdicts }), { encoding: 'utf8', mode: 0o600 })
|
|
79
|
+
// Windows antivirus/indexing and concurrent writers can temporarily lock
|
|
80
|
+
// an existing destination during replace. Keep the unique temporary file
|
|
81
|
+
// and retry only transient filesystem errors; never unlink the destination.
|
|
82
|
+
const delays = [5, 10, 20, 40, 80, 160]
|
|
83
|
+
for (let attempt = 0; ; attempt += 1) {
|
|
84
|
+
try {
|
|
85
|
+
await fsOps.rename(temporary, file)
|
|
86
|
+
break
|
|
87
|
+
} catch (error) {
|
|
88
|
+
if (!['EACCES', 'EBUSY', 'EPERM'].includes(error?.code) || attempt >= delays.length) {
|
|
89
|
+
throw error
|
|
90
|
+
}
|
|
91
|
+
await new Promise((resolve) => setTimeout(resolve, delays[attempt]))
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
} catch (error) {
|
|
95
|
+
// On a permanent error, don't accumulate orphaned cache snapshots.
|
|
96
|
+
try { await fsOps.rm(temporary, { force: true }) } catch {}
|
|
97
|
+
throw error
|
|
98
|
+
}
|
|
79
99
|
}
|
|
80
100
|
|
|
81
101
|
export function createImageInputVerdictStore(options = {}) {
|
|
@@ -85,6 +105,7 @@ export function createImageInputVerdictStore(options = {}) {
|
|
|
85
105
|
mkdir: options.fsOps?.mkdir ?? mkdir,
|
|
86
106
|
writeFile: options.fsOps?.writeFile ?? writeFile,
|
|
87
107
|
rename: options.fsOps?.rename ?? rename,
|
|
108
|
+
rm: options.fsOps?.rm ?? rm,
|
|
88
109
|
}
|
|
89
110
|
const logger = options.logger
|
|
90
111
|
let records = new Map()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { randomUUID } from 'node:crypto'
|
|
1
|
+
import { createHash, randomUUID } from 'node:crypto'
|
|
2
2
|
import { AsyncLocalStorage } from 'node:async_hooks'
|
|
3
3
|
import { retainArtifactRun } from './artifact-retention.js'
|
|
4
4
|
import {
|
|
@@ -100,16 +100,13 @@ function sessionCwd(exec) {
|
|
|
100
100
|
function stableRuntimeConfigSignature(value) {
|
|
101
101
|
if (!value || typeof value !== 'object') return '{}'
|
|
102
102
|
try {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
httpProviders: value.httpProviders,
|
|
108
|
-
proxy: value.proxy,
|
|
109
|
-
proxyHosts: value.proxyHosts,
|
|
110
|
-
})
|
|
103
|
+
// Every live setting may change the tool's answer (model pairs, fallback
|
|
104
|
+
// order, downscale policy, prompt mode, etc.). Hash the full configuration
|
|
105
|
+
// rather than retaining its secrets or relying on a partial field whitelist.
|
|
106
|
+
return createHash('sha256').update(JSON.stringify(value)).digest('hex')
|
|
111
107
|
} catch {
|
|
112
|
-
|
|
108
|
+
// Cyclic/unserializable settings must never keep a stale cache revision.
|
|
109
|
+
return randomUUID()
|
|
113
110
|
}
|
|
114
111
|
}
|
|
115
112
|
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Per-invocation, privacy-safe stage timings. Never log paths, attachment IDs,
|
|
5
|
+
* prompt text, response contents, headers or credentials. A pending Host
|
|
6
|
+
* Promise gets an abort-stage log even if its own operation never settles.
|
|
7
|
+
*/
|
|
8
|
+
export function createVisionToolStageTrace(logger, toolName, signal) {
|
|
9
|
+
const traceId = randomUUID().slice(0, 12)
|
|
10
|
+
const report = (level, phase, status, elapsed) => {
|
|
11
|
+
try {
|
|
12
|
+
logger?.[level]?.(
|
|
13
|
+
'vision-router: tool=%s trace=%s stage=%s status=%s elapsedMs=%d',
|
|
14
|
+
toolName, traceId, phase, status, elapsed,
|
|
15
|
+
)
|
|
16
|
+
} catch {
|
|
17
|
+
// Diagnostics cannot change the outcome of an image/tool operation.
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return async (phase, operation) => {
|
|
22
|
+
const started = Date.now()
|
|
23
|
+
let completed = false
|
|
24
|
+
let abortReported = false
|
|
25
|
+
let rejectAborted
|
|
26
|
+
const canceled = signal && new Promise((_, reject) => { rejectAborted = reject })
|
|
27
|
+
// Pre-aborted signals can reject before Promise.race attaches a handler.
|
|
28
|
+
// Keep that intentional cancellation rejection observed in every race.
|
|
29
|
+
if (canceled) void canceled.catch(() => {})
|
|
30
|
+
const onAbort = () => {
|
|
31
|
+
if (completed || abortReported) return
|
|
32
|
+
abortReported = true
|
|
33
|
+
report('warn', phase, 'aborted', Date.now() - started)
|
|
34
|
+
rejectAborted?.(signal?.reason ?? new Error('vision stage aborted'))
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
report('info', phase, 'begin', 0)
|
|
38
|
+
if (signal?.aborted) onAbort()
|
|
39
|
+
else signal?.addEventListener?.('abort', onAbort, { once: true })
|
|
40
|
+
try {
|
|
41
|
+
if (signal?.aborted) throw signal.reason ?? new Error('vision stage aborted')
|
|
42
|
+
// A legacy or broken Host Promise may ignore AbortSignal indefinitely.
|
|
43
|
+
// Race the stage *without* publishing its late result, while still
|
|
44
|
+
// observing the detached Promise and releasing our abort listener.
|
|
45
|
+
const running = Promise.resolve(operation())
|
|
46
|
+
const value = await (canceled ? Promise.race([running, canceled]) : running)
|
|
47
|
+
if (signal?.aborted) throw signal.reason ?? new Error('vision stage aborted')
|
|
48
|
+
report('info', phase, 'ok', Date.now() - started)
|
|
49
|
+
return value
|
|
50
|
+
} catch (error) {
|
|
51
|
+
if (!abortReported) report('warn', phase, 'error', Date.now() - started)
|
|
52
|
+
throw error
|
|
53
|
+
} finally {
|
|
54
|
+
completed = true
|
|
55
|
+
signal?.removeEventListener?.('abort', onAbort)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
DSH_017_SETTINGS_COMPAT_MARK,
|
|
3
3
|
LOCAL_SETTINGS_PATH,
|
|
4
4
|
} from '../dsh-settings-017-compat.js'
|
|
5
|
+
import { isLocalUiRequest } from '../web-capability-boundary.js'
|
|
5
6
|
|
|
6
7
|
const BODY_LIMIT_BYTES = 256 * 1024
|
|
7
8
|
const ROOT_TRANSPORT_REGISTRY_KEY = Symbol.for('dsh-vision-router.settings-017-root-local-transport')
|
|
@@ -67,8 +68,13 @@ function serviceOf(ctx, name) {
|
|
|
67
68
|
|
|
68
69
|
function compatibleSettings(ctx) {
|
|
69
70
|
const settings = serviceOf(ctx, 'settings')
|
|
70
|
-
if (settings?.
|
|
71
|
-
|
|
71
|
+
if (typeof settings?.describe !== 'function' || typeof settings.mutate !== 'function') return undefined
|
|
72
|
+
// Modern Hosts can expose both native SettingsProvider.register() and
|
|
73
|
+
// configForms. Their browser uses the local bridge even without our
|
|
74
|
+
// ConfigEditor compatibility facade/marker. Keep legacy Hosts without
|
|
75
|
+
// configForms on their original settings path.
|
|
76
|
+
const forms = serviceOf(ctx, 'configForms')
|
|
77
|
+
if (settings[DSH_017_SETTINGS_COMPAT_MARK] !== true && typeof forms?.get !== 'function') return undefined
|
|
72
78
|
return settings
|
|
73
79
|
}
|
|
74
80
|
|
|
@@ -153,11 +159,33 @@ function beginSlowMutationWatch(root, requestId) {
|
|
|
153
159
|
}, SLOW_MUTATION_MS)
|
|
154
160
|
}
|
|
155
161
|
|
|
156
|
-
function
|
|
162
|
+
function allowLocalSettingsRequest(req, res, connection) {
|
|
163
|
+
// This root-owned route bypasses DVR's usual child-Context WebServer wrapper.
|
|
164
|
+
// Check *both* transport locality and the Host's authenticated browser
|
|
165
|
+
// session before reading or mutating the complete settings namespace.
|
|
166
|
+
let denied = !isLocalUiRequest(req) ? 403 : undefined
|
|
167
|
+
if (denied === undefined) {
|
|
168
|
+
try {
|
|
169
|
+
if (typeof connection?.requestRejection !== 'function') denied = 403
|
|
170
|
+
else {
|
|
171
|
+
const rejection = connection.requestRejection(req)
|
|
172
|
+
if (rejection !== undefined && rejection !== null) {
|
|
173
|
+
denied = rejection === 401 ? 401 : 403
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
} catch { denied = 403 }
|
|
177
|
+
}
|
|
178
|
+
if (denied === undefined) return true
|
|
179
|
+
sendJson(res, denied, { ok: false, error: { code: 'access-denied', message: 'Local settings require an authenticated local DSH browser' } })
|
|
180
|
+
return false
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function routeFor(root, state, getConnection) {
|
|
157
184
|
return {
|
|
158
185
|
kind: 'exact',
|
|
159
186
|
path: LOCAL_SETTINGS_PATH,
|
|
160
187
|
async handler(req, res) {
|
|
188
|
+
if (!allowLocalSettingsRequest(req, res, getConnection())) return
|
|
161
189
|
const requestId = ++state.requestSequence
|
|
162
190
|
trace('handler-enter', { requestId, method: req.method, generation: state.current?.id })
|
|
163
191
|
const settings = currentSettings(state)
|
|
@@ -230,14 +258,16 @@ function ensureRootRoute(root, state) {
|
|
|
230
258
|
|
|
231
259
|
state.routeInstalling = true
|
|
232
260
|
try {
|
|
233
|
-
const owner = root.inject(['webServer'], (webCtx) => {
|
|
261
|
+
const owner = root.inject(['webServer', 'connection'], (webCtx) => {
|
|
234
262
|
if (!webCtx?.webServer || typeof webCtx.webServer.register !== 'function' || typeof webCtx.effect !== 'function') {
|
|
235
263
|
throw new Error('Vision Router requires WebServer route registration on DSH 0.1.7')
|
|
236
264
|
}
|
|
237
265
|
trace('route-register', {})
|
|
238
266
|
webCtx.effect(
|
|
239
267
|
() => {
|
|
240
|
-
const dispose = webCtx.webServer.register(routeFor(root, state)
|
|
268
|
+
const dispose = webCtx.webServer.register(routeFor(root, state, () => {
|
|
269
|
+
try { return webCtx.connection } catch { return undefined }
|
|
270
|
+
}))
|
|
241
271
|
return () => {
|
|
242
272
|
trace('route-dispose', {})
|
|
243
273
|
dispose()
|
|
@@ -270,7 +300,7 @@ export function installDsh017RootLocalSettingsTransport(ctx) {
|
|
|
270
300
|
if (!objectLike(root)) return
|
|
271
301
|
const state = stateFor(root)
|
|
272
302
|
|
|
273
|
-
|
|
303
|
+
const mountGeneration = (settingsCtx) => {
|
|
274
304
|
const mounted = compatibleSettings(settingsCtx)
|
|
275
305
|
if (!mounted) return
|
|
276
306
|
|
|
@@ -310,5 +340,21 @@ export function installDsh017RootLocalSettingsTransport(ctx) {
|
|
|
310
340
|
disposeGeneration()
|
|
311
341
|
throw error
|
|
312
342
|
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// The 0.1.7 facade needs only settings and must continue to work when the
|
|
346
|
+
// modern configForms service does not exist.
|
|
347
|
+
ctx.inject(['settings'], (settingsCtx) => {
|
|
348
|
+
const settings = serviceOf(settingsCtx, 'settings')
|
|
349
|
+
if (settings?.[DSH_017_SETTINGS_COMPAT_MARK] === true) mountGeneration(settingsCtx)
|
|
350
|
+
})
|
|
351
|
+
|
|
352
|
+
// Native SettingsProvider + configForms is a two-service capability.
|
|
353
|
+
// Depending only on "settings" can observe it before configForms starts and
|
|
354
|
+
// permanently skip the route. Cordis reinvokes a multi-service inject when
|
|
355
|
+
// configForms becomes ready and disposes it if either service disappears.
|
|
356
|
+
ctx.inject(['settings', 'configForms'], (servicesCtx) => {
|
|
357
|
+
const settings = serviceOf(servicesCtx, 'settings')
|
|
358
|
+
if (settings?.[DSH_017_SETTINGS_COMPAT_MARK] !== true) mountGeneration(servicesCtx)
|
|
313
359
|
})
|
|
314
360
|
}
|
|
@@ -14,6 +14,12 @@ export const WEB_ROUTE_REMOTE_CAPABILITY = Object.freeze({
|
|
|
14
14
|
// callers that use isLocalMutationRoute(); local-only GET capabilities such as
|
|
15
15
|
// test-connection are intentionally not reclassified as mutations.
|
|
16
16
|
const ROUTE_CAPABILITY_POLICIES = new Map([
|
|
17
|
+
// The ConfigEditor-backed root route has its own explicit transport and
|
|
18
|
+
// BrowserAuth fence; declare its local-only semantics here as well.
|
|
19
|
+
['/_dsh/vision-router/local-settings', new Map([
|
|
20
|
+
['GET', { remote: WEB_ROUTE_REMOTE_CAPABILITY.LOCAL_ONLY }],
|
|
21
|
+
['POST', { remote: WEB_ROUTE_REMOTE_CAPABILITY.LOCAL_ONLY, legacyMutation: true }],
|
|
22
|
+
])],
|
|
17
23
|
['/_dsh/vision-router/self-update', new Map([
|
|
18
24
|
['POST', { remote: WEB_ROUTE_REMOTE_CAPABILITY.LOCAL_ONLY, legacyMutation: true }],
|
|
19
25
|
])],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-vision-router",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Eyes for text-only DeepSeek Harness agents: built-in free vision chain + pixel-level tools. Remote vision providers, including the default free fallback, receive image content unless strict local-only use is configured.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,8 +26,10 @@
|
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
28
|
"LICENSE",
|
|
29
|
+
"THIRD_PARTY_NOTICES.md",
|
|
29
30
|
"README.md",
|
|
30
31
|
"README.zh.md",
|
|
32
|
+
"scripts/install-native-ocr.mjs",
|
|
31
33
|
"assets",
|
|
32
34
|
"cordis.patch.yml",
|
|
33
35
|
"docs",
|
|
@@ -54,7 +56,7 @@
|
|
|
54
56
|
],
|
|
55
57
|
"dependencies": {
|
|
56
58
|
"@deepseek-ai/schemastery": ">=3.18.0",
|
|
57
|
-
"
|
|
59
|
+
"@visioncortex/vtracer": "1.0.0-alpha.4",
|
|
58
60
|
"puppeteer-core": "^25.16.0",
|
|
59
61
|
"semver": "7.7.3",
|
|
60
62
|
"undici": "^7.30.1",
|
|
@@ -84,8 +86,8 @@
|
|
|
84
86
|
"typescript": "6.0.3"
|
|
85
87
|
},
|
|
86
88
|
"scripts": {
|
|
87
|
-
"test": "node --test tests/dsh-alpha-pin.test.js tests/dsh-rc1-pin.test.js tests/agent-prestep-model-routing.test.js tests/native-plugin-icons.test.js tests/optional-peer-import-contract.test.js tests/index-modularization.test.js tests/adapter-prepare-call-compat.test.js tests/core.test.js tests/issue-374-delegated-call-config.test.js tests/grounding-coordinate-frame.test.js tests/grounding-coordinate-runtime.test.js tests/desktop-e2e-watchdog.test.js tests/capability-advisory.test.js tests/vision-execution-policy.test.js tests/vision-backend-diagnostics.test.js tests/live-model-discovery.test.js tests/cache-atomic-write-concurrency.test.js tests/live-model-credential-resolution.test.js tests/vision-model-registry.test.js tests/live-model-client-stability.test.js tests/providers-persistence.test.js tests/provider-directory-fallback.test.js tests/model-catalog-policy.test.js tests/settings-ia-client-prelude.test.js tests/settings-ia-fj.test.js tests/settings-ia-acceptance-regression.test.js tests/settings-migration.test.js tests/settings-section-order.test.js tests/attachment-admission-policy.test.js tests/vision-resilience.test.js tests/degraded-local-evidence.test.js tests/vision-resilience-lifecycle.test.js tests/vision-breaker-readonly.test.js tests/alpha1-browser-lifecycle-integration.test.js tests/issue-367-remote-session-inject.test.js tests/vision-mode-toggle-injection.test.js tests/dev-staged-build.test.js tests/dev-web-reload.test.js tests/client.test.js tests/issue-307-regression.test.js tests/issue-284-vision-mode-toggle.test.js tests/issue-284-vision-mode-hardening.test.js tests/issue-284-attachment-id-hint.test.js tests/issue-284-model-visibility.test.js tests/issue-284-vision-selection-effort.test.js tests/client-presentation-boundary.test.js tests/clipboard-image-paste-compat.test.js tests/remote-settings-bridge.test.js tests/remote-settings-v2-contract.test.js tests/remote-settings-risk-confirmation.test.js tests/local-remote-settings-permission.test.js tests/artifact-path-security.test.js tests/http-compat.test.js tests/catalog-corrections.test.js tests/release-registry-identity.test.js tests/update-check.test.js tests/update-check-signal-lifecycle.test.js tests/self-update.test.js tests/doctor.test.js tests/doctor-cli.test.js tests/legacy-session-repair.test.js tests/profile-pnpm-diagnostics.test.js tests/doctor-v2.test.js tests/doctor-cli-v2.test.js tests/doctor-runtime.test.js tests/dsh-host-capabilities.test.js tests/doctor-host-capabilities.test.js tests/session-repair-v2.test.js tests/activation-shim-contract.test.js tests/bundle-defaults.test.js tests/required-ci-contract.test.js tests/ci-electron-download-retry.test.js tests/file-logger.test.js tests/official-deepseek-catalog.test.js tests/replay-delegation.test.js tests/twin-image-capability-fallback.test.js tests/twin-image-custom-wrapper.test.js tests/adversarial-hardening.test.js tests/vision-adversarial-hardening-v2.test.js tests/vision-capability-benchmark-visual-proof.test.js tests/wrapper-directory.test.js tests/logging-ui.test.js tests/manifest-dependencies.test.js tests/provider-transport-threading.test.js tests/architecture-2.3-gate.test.js tests/host-settings-seam.test.js tests/drift-canary-settings-seam.test.js tests/esm-cycle-audit.test.js tests/structured-bootstrap.test.js tests/structured-bootstrap-gate.test.js tests/vision-model-guidance-contract.test.js tests/local-ollama.test.js tests/local-only-vision.test.js tests/ollama-cold-start.test.js tests/ollama-cold-start-loaded.test.js tests/zero-regression-gate.test.js tests/runtime-e2e.test.js tests/local-vision-stabilizer.test.js tests/local-connection-probe.test.js tests/vision-diagnostics-routes.test.js tests/repetition-guard.test.js tests/guide-scroll-gate.test.js tests/settings-scroll-jank-regression.test.js tests/free-cloud-first.test.js tests/dsh-host-compat.test.js tests/native-image-coexistence.test.js tests/issue-276-session-image-ownership.test.js tests/issue-276-entry-policy-bridge.test.js tests/issue-276-policy-hardening.test.js tests/issue-289-native-nonintervention.test.js tests/issue-512-tool-restriction.test.js tests/issue-606-session-source-ownership.test.js tests/pi-ai-bridge-wire-compat.test.js tests/fetch-wrapper-lifecycle.test.js tests/fetch-wrapper-composition.test.js tests/provider-probe-proxy-scope.test.js tests/lifecycle-invariants.test.js tests/vision-tool-settings-generation.test.js tests/release-package-content-identity.test.js tests/release-state-machine.test.js tests/mixed-router.test.js tests/depth-tier.test.js tests/depth-quota-behavior.test.js tests/structured-flow-hardening.test.js tests/structured-flow-adversarial.test.js tests/vision-budget-activation.test.js tests/runtime-boundary-fixes.test.js tests/vision-stream-iterator-cancellation.test.js tests/security-resource-boundaries.test.js tests/security-property-fuzz.test.js tests/security-adversarial-fuzz-contract.test.js tests/runtime-i18n.test.js tests/long-ocr-empty-retry.test.js tests/tesseract-adaptive-ocr.test.js tests/tesseract-node24-boot.test.js tests/session-vision-state.test.js tests/session-vision-state-integration.test.js tests/session-vision-event-feed.test.js tests/session-vision-policy.test.js tests/session-vision-policy-domain.test.js tests/session-vision-delegation.test.js tests/session-vision-delegation-boundary.test.js tests/subagent-vision-inheritance-characterization.test.js tests/subagent-vision-runtime-integration.test.js tests/subagent-vision-cold-resume.test.js tests/image-resource-governor.test.js tests/resource-retention-lifecycle.test.js tests/pixel-diff-stream.test.js tests/large-image-resource-integration.test.js tests/structured-guard-idempotency.test.js tests/vision-routing-product.test.js tests/vision-runtime-performance.test.js tests/vision-routing-settings-prelude.test.js tests/v2-settings-ia-integration.test.js tests/vision-capability-router.test.js tests/vision-capability-reference.test.js tests/vision-capability-benchmark.test.js tests/vision-capability-grounding-proof-contract.test.js tests/vision-capability-probe.test.js tests/vision-capability-axis-freshness.test.js tests/vision-capability-shadow-health.test.js tests/vision-capability-benchmark-service.test.js tests/vision-capability-preflight-hardening.test.js tests/vision-capability-benchmark-contract.test.js tests/vision-capability-benchmark-client.test.js tests/vision-capability-benchmark-client-productization.test.js tests/vision-capability-adapter-route.test.js tests/vision-background-benchmark.test.js tests/vision-background-lifecycle.test.js tests/vision-background-benchmark-productization.test.js tests/vision-capability-benchmark-budget.test.js tests/vision-image-input-verdict.test.js tests/vision-capability-failure-classification.test.js tests/vision-capability-gate-client.test.js tests/v2-product-review-fixes.test.js tests/qa-top5-reliability.test.js tests/qa-screenshot-runtime.test.js tests/qa-runtime-identity.test.js tests/qa-turn-budget-cancellation.test.js tests/qa-cancellation-publication.test.js tests/qa-reliability-tail.test.js tests/qa-endpoint-route-alias.test.js tests/settings-native-card-semantics.test.js tests/settings-native-card-lazy-data.test.js tests/settings-invalid-staged-dirty.test.js tests/vision-toggle-root-hardening.test.js && pnpm test:regression-closure && node --test tests/vision-backend-runtime-policy.test.js tests/vision-router-adversarial-review-fixes.test.js tests/web-panel-delegation.test.js",
|
|
88
|
-
"test:core": "node --test tests/core.test.js tests/degraded-local-evidence.test.js tests/runtime-e2e.test.js tests/structured-bootstrap.test.js tests/structured-flow-hardening.test.js tests/structured-flow-adversarial.test.js tests/vision-execution-policy.test.js tests/vision-backend-runtime-policy.test.js",
|
|
89
|
+
"test": "node --test tests/dsh-alpha-pin.test.js tests/dsh-rc1-pin.test.js tests/dsh-rc2-pin.test.js tests/dsh-rc3-pin.test.js tests/agent-prestep-model-routing.test.js tests/native-plugin-icons.test.js tests/optional-peer-import-contract.test.js tests/index-modularization.test.js tests/adapter-prepare-call-compat.test.js tests/core.test.js tests/issue-374-delegated-call-config.test.js tests/grounding-coordinate-frame.test.js tests/grounding-coordinate-runtime.test.js tests/desktop-e2e-watchdog.test.js tests/capability-advisory.test.js tests/vision-execution-policy.test.js tests/vision-backend-diagnostics.test.js tests/live-model-discovery.test.js tests/cache-atomic-write-concurrency.test.js tests/live-model-credential-resolution.test.js tests/vision-model-registry.test.js tests/live-model-client-stability.test.js tests/providers-persistence.test.js tests/provider-directory-fallback.test.js tests/model-catalog-policy.test.js tests/settings-ia-client-prelude.test.js tests/settings-ia-fj.test.js tests/settings-ia-acceptance-regression.test.js tests/settings-migration.test.js tests/settings-section-order.test.js tests/attachment-admission-policy.test.js tests/vision-resilience.test.js tests/degraded-local-evidence.test.js tests/vision-resilience-lifecycle.test.js tests/vision-breaker-readonly.test.js tests/alpha1-browser-lifecycle-integration.test.js tests/issue-367-remote-session-inject.test.js tests/vision-mode-toggle-injection.test.js tests/dev-staged-build.test.js tests/dev-web-reload.test.js tests/client.test.js tests/issue-307-regression.test.js tests/issue-284-vision-mode-toggle.test.js tests/issue-284-vision-mode-hardening.test.js tests/issue-284-attachment-id-hint.test.js tests/issue-284-model-visibility.test.js tests/issue-284-vision-selection-effort.test.js tests/client-presentation-boundary.test.js tests/clipboard-image-paste-compat.test.js tests/remote-settings-bridge.test.js tests/remote-settings-v2-contract.test.js tests/remote-settings-risk-confirmation.test.js tests/local-remote-settings-permission.test.js tests/artifact-path-security.test.js tests/http-compat.test.js tests/catalog-corrections.test.js tests/release-registry-identity.test.js tests/update-check.test.js tests/update-check-signal-lifecycle.test.js tests/self-update.test.js tests/doctor.test.js tests/doctor-cli.test.js tests/legacy-session-repair.test.js tests/profile-pnpm-diagnostics.test.js tests/doctor-v2.test.js tests/doctor-cli-v2.test.js tests/doctor-runtime.test.js tests/dsh-host-capabilities.test.js tests/doctor-host-capabilities.test.js tests/session-repair-v2.test.js tests/activation-shim-contract.test.js tests/bundle-defaults.test.js tests/required-ci-contract.test.js tests/ci-electron-download-retry.test.js tests/file-logger.test.js tests/official-deepseek-catalog.test.js tests/replay-delegation.test.js tests/twin-image-capability-fallback.test.js tests/twin-image-custom-wrapper.test.js tests/adversarial-hardening.test.js tests/vision-adversarial-hardening-v2.test.js tests/vision-capability-benchmark-visual-proof.test.js tests/wrapper-directory.test.js tests/logging-ui.test.js tests/manifest-dependencies.test.js tests/provider-transport-threading.test.js tests/architecture-2.3-gate.test.js tests/host-settings-seam.test.js tests/drift-canary-settings-seam.test.js tests/esm-cycle-audit.test.js tests/structured-bootstrap.test.js tests/structured-bootstrap-gate.test.js tests/vision-model-guidance-contract.test.js tests/local-ollama.test.js tests/local-only-vision.test.js tests/ollama-cold-start.test.js tests/ollama-cold-start-loaded.test.js tests/zero-regression-gate.test.js tests/runtime-e2e.test.js tests/local-vision-stabilizer.test.js tests/local-connection-probe.test.js tests/vision-diagnostics-routes.test.js tests/repetition-guard.test.js tests/guide-scroll-gate.test.js tests/settings-scroll-jank-regression.test.js tests/free-cloud-first.test.js tests/dsh-host-compat.test.js tests/native-image-coexistence.test.js tests/issue-276-session-image-ownership.test.js tests/issue-276-entry-policy-bridge.test.js tests/issue-276-policy-hardening.test.js tests/issue-289-native-nonintervention.test.js tests/issue-512-tool-restriction.test.js tests/issue-606-session-source-ownership.test.js tests/pi-ai-bridge-wire-compat.test.js tests/fetch-wrapper-lifecycle.test.js tests/fetch-wrapper-composition.test.js tests/provider-probe-proxy-scope.test.js tests/lifecycle-invariants.test.js tests/vision-tool-settings-generation.test.js tests/release-package-content-identity.test.js tests/release-state-machine.test.js tests/mixed-router.test.js tests/depth-tier.test.js tests/depth-quota-behavior.test.js tests/structured-flow-hardening.test.js tests/structured-flow-adversarial.test.js tests/vision-budget-activation.test.js tests/runtime-boundary-fixes.test.js tests/vision-stream-iterator-cancellation.test.js tests/security-resource-boundaries.test.js tests/security-property-fuzz.test.js tests/security-adversarial-fuzz-contract.test.js tests/runtime-i18n.test.js tests/long-ocr-empty-retry.test.js tests/tesseract-adaptive-ocr.test.js tests/tesseract-node24-boot.test.js tests/session-vision-state.test.js tests/session-vision-state-integration.test.js tests/session-vision-event-feed.test.js tests/session-vision-policy.test.js tests/session-vision-policy-domain.test.js tests/session-vision-delegation.test.js tests/session-vision-delegation-boundary.test.js tests/subagent-vision-inheritance-characterization.test.js tests/subagent-vision-runtime-integration.test.js tests/subagent-vision-cold-resume.test.js tests/image-resource-governor.test.js tests/resource-retention-lifecycle.test.js tests/pixel-diff-stream.test.js tests/large-image-resource-integration.test.js tests/structured-guard-idempotency.test.js tests/vision-routing-product.test.js tests/vision-runtime-performance.test.js tests/vision-routing-settings-prelude.test.js tests/v2-settings-ia-integration.test.js tests/vision-capability-router.test.js tests/vision-capability-reference.test.js tests/vision-capability-benchmark.test.js tests/vision-capability-grounding-proof-contract.test.js tests/vision-capability-probe.test.js tests/vision-capability-axis-freshness.test.js tests/vision-capability-shadow-health.test.js tests/vision-capability-benchmark-service.test.js tests/vision-capability-preflight-hardening.test.js tests/vision-capability-benchmark-contract.test.js tests/vision-capability-benchmark-client.test.js tests/vision-capability-benchmark-client-productization.test.js tests/vision-capability-adapter-route.test.js tests/vision-background-benchmark.test.js tests/vision-background-lifecycle.test.js tests/vision-background-benchmark-productization.test.js tests/vision-capability-benchmark-budget.test.js tests/vision-image-input-verdict.test.js tests/vision-capability-failure-classification.test.js tests/vision-capability-gate-client.test.js tests/v2-product-review-fixes.test.js tests/qa-top5-reliability.test.js tests/qa-screenshot-runtime.test.js tests/qa-runtime-identity.test.js tests/qa-turn-budget-cancellation.test.js tests/qa-cancellation-publication.test.js tests/vision-tool-stage.test.js tests/vision-image-input-reader.test.js tests/qa-reliability-tail.test.js tests/qa-endpoint-route-alias.test.js tests/settings-native-card-semantics.test.js tests/settings-native-card-lazy-data.test.js tests/settings-invalid-staged-dirty.test.js tests/vision-toggle-root-hardening.test.js && pnpm test:regression-closure && node --test tests/vision-backend-runtime-policy.test.js tests/vision-router-adversarial-review-fixes.test.js tests/web-panel-delegation.test.js && node --test tests/vision-trace-vtracer.test.js tests/vision-trace-image-quality.test.js && pnpm license:check && node --test tests/native-ocr-annotation-risk.test.js tests/native-ocr-bundle.test.js tests/native-ocr-canary.test.js tests/native-ocr-chemistry-review.test.js tests/native-ocr-document.test.js tests/native-ocr-host-canary.test.js tests/native-ocr-installation.test.js tests/native-ocr-integrity.test.js tests/native-ocr-provenance.test.js tests/native-ocr-question-labels.test.js tests/native-ocr-supervisor.test.js tests/issue-836-ocr-regression.test.js",
|
|
90
|
+
"test:core": "node --test tests/vision-image-input-reader.test.js tests/vision-tool-stage.test.js tests/core.test.js tests/degraded-local-evidence.test.js tests/runtime-e2e.test.js tests/structured-bootstrap.test.js tests/structured-flow-hardening.test.js tests/structured-flow-adversarial.test.js tests/vision-execution-policy.test.js tests/vision-backend-runtime-policy.test.js",
|
|
89
91
|
"test:routing": "node --test tests/issue-374-delegated-call-config.test.js tests/twin-image-capability-fallback.test.js tests/twin-image-custom-wrapper.test.js tests/vision-routing-product.test.js tests/vision-capability-router.test.js tests/vision-capability-probe.test.js tests/vision-capability-shadow-health.test.js tests/vision-runtime-performance.test.js tests/vision-background-benchmark.test.js tests/vision-image-input-verdict.test.js",
|
|
90
92
|
"test:session": "node --test tests/session-vision-state.test.js tests/session-vision-state-integration.test.js tests/session-vision-policy.test.js tests/session-vision-delegation.test.js tests/session-vision-delegation-boundary.test.js tests/subagent-vision-inheritance-characterization.test.js tests/subagent-vision-runtime-integration.test.js tests/subagent-vision-cold-resume.test.js tests/session-vision-policy-domain.test.js tests/replay-delegation.test.js tests/legacy-session-repair.test.js tests/session-repair-v2.test.js tests/issue-276-session-image-ownership.test.js",
|
|
91
93
|
"test:resources": "node --test tests/artifact-path-security.test.js tests/image-resource-governor.test.js tests/resource-retention-lifecycle.test.js tests/pixel-diff-stream.test.js tests/large-image-resource-integration.test.js tests/qa-turn-budget-cancellation.test.js tests/qa-cancellation-publication.test.js",
|
|
@@ -113,10 +115,12 @@
|
|
|
113
115
|
"typecheck:declaration": "tsc -p tsconfig.declaration.json",
|
|
114
116
|
"typecheck": "pnpm typecheck:host && pnpm typecheck:client && pnpm typecheck:declaration",
|
|
115
117
|
"prepare": "pnpm build",
|
|
116
|
-
"prepack": "pnpm build",
|
|
118
|
+
"prepack": "pnpm license:check && pnpm build",
|
|
117
119
|
"lint": "node scripts/lint-source-ownership.mjs && node scripts/lint-lifecycle-invariants.mjs",
|
|
118
120
|
"source:artifact:check": "node scripts/verify-source-artifact-map.mjs",
|
|
119
|
-
"test:regression-closure": "node --test tests/auto-wrap-model-removal.test.js tests/guard-stop-surface-shadow.test.js tests/release-package-content-identity.test.js tests/settings-card-race-safety.test.js tests/settings-guide-replay-safety.test.js tests/settings-ia-targeted-adversarial.test.js tests/v2-release-acceptance-regressions.test.js tests/vision-turn-budget-client-prelude.test.js tests/wrapper-scope-client-prelude.test.js"
|
|
121
|
+
"test:regression-closure": "node --test tests/auto-wrap-model-removal.test.js tests/guard-stop-surface-shadow.test.js tests/release-package-content-identity.test.js tests/settings-card-race-safety.test.js tests/settings-guide-replay-safety.test.js tests/settings-ia-targeted-adversarial.test.js tests/v2-release-acceptance-regressions.test.js tests/vision-turn-budget-client-prelude.test.js tests/wrapper-scope-client-prelude.test.js",
|
|
122
|
+
"test:trace": "node --test tests/vision-trace-vtracer.test.js tests/vision-trace-image-quality.test.js",
|
|
123
|
+
"license:check": "node scripts/verify-runtime-licenses.mjs && node scripts/verify-native-ocr-licenses.mjs"
|
|
120
124
|
},
|
|
121
125
|
"dsh": {
|
|
122
126
|
"client": {
|