@mengruo/dsh-vision-toolkit 0.0.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.
- package/LICENSE +21 -0
- package/README.i18n.yaml +6 -0
- package/README.md +356 -0
- package/README.zh.md +354 -0
- package/assets/community-group-qr.png +0 -0
- package/assets/dsh-conversation-artifact.png +0 -0
- package/assets/dsh-conversation-image-qa-top.png +0 -0
- package/assets/dsh-conversation-image-qa.png +0 -0
- package/assets/dsh-conversation-pixel-diff.png +0 -0
- package/assets/dsh-conversation-screenshot-debugging-top.png +0 -0
- package/assets/dsh-conversation-screenshot-debugging.png +0 -0
- package/assets/dsh-conversation-tool-call.png +0 -0
- package/assets/dsh-conversation-vision-trace.png +0 -0
- package/assets/dsh-view-example.png +0 -0
- package/assets/hero-v2.png +0 -0
- package/assets/logo_aihubmix.png +0 -0
- package/assets/python-bootstrap.json +48 -0
- package/assets/skill/SKILL.md +329 -0
- package/assets/skill/UPSTREAM.json +71 -0
- package/assets/skill/references/gui.md +88 -0
- package/assets/skill/references/long-screenshot-ocr.md +77 -0
- package/assets/skill/references/restore-graphic.md +84 -0
- package/assets/skill/references/restore-structure.md +45 -0
- package/assets/skill/references/restore-ui.md +202 -0
- package/assets/social-preview.png +0 -0
- package/assets/upstream/README.md +18 -0
- package/assets/upstream/focus-hint-comparison-1.webp +0 -0
- package/assets/upstream/focus-hint-comparison-2.webp +0 -0
- package/assets/upstream/infographic-reference.webp +0 -0
- package/assets/upstream/infographic-result.webp +0 -0
- package/assets/upstream/ui-fast-restore-reference.webp +0 -0
- package/assets/upstream/ui-fast-restore-result.webp +0 -0
- package/assets/upstream/ui-result.webp +0 -0
- package/assets/upstream/ui-sketch.webp +0 -0
- package/assets/vision-model-test.png +0 -0
- package/assets/vision-settings.png +0 -0
- package/assets/wechat-reward.png +0 -0
- package/cordis.patch.yml +6 -0
- package/docs/aihubmix-gemini-vision.i18n.yaml +6 -0
- package/docs/aihubmix-gemini-vision.md +138 -0
- package/docs/aihubmix-gemini-vision.zh.md +138 -0
- package/docs/assets/aihubmix-api-keys.png +0 -0
- package/docs/assets/aihubmix-create-key.png +0 -0
- package/docs/assets/aihubmix-free-vision-model.png +0 -0
- package/docs/assets/aihubmix-home.png +0 -0
- package/docs/assets/aihubmix-sign-up.png +0 -0
- package/docs/assets/groq-console-home.png +0 -0
- package/docs/assets/groq-console-keys-login.png +0 -0
- package/docs/assets/groq-docs-quickstart.png +0 -0
- package/docs/assets/groq-docs-qwen3.6.png +0 -0
- package/docs/assets/groq-docs-vision.png +0 -0
- package/docs/assets/vision-settings.png +0 -0
- package/docs/dsh-desktop-install.md +67 -0
- package/docs/dsh-desktop-install.zh.md +67 -0
- package/docs/groq-qwen3.6-vision.i18n.yaml +6 -0
- package/docs/groq-qwen3.6-vision.md +236 -0
- package/docs/groq-qwen3.6-vision.zh.md +236 -0
- package/docs/python-runtime.i18n.yaml +6 -0
- package/docs/python-runtime.md +89 -0
- package/docs/python-runtime.zh.md +89 -0
- package/docs/requirements-traceability/README.i18n.yaml +6 -0
- package/docs/requirements-traceability/README.md +75 -0
- package/docs/requirements-traceability/README.zh.md +75 -0
- package/examples/ui-restoration/README.i18n.yaml +6 -0
- package/examples/ui-restoration/README.md +70 -0
- package/examples/ui-restoration/README.zh.md +70 -0
- package/examples/ui-restoration/assets/final-heatmap.png +0 -0
- package/examples/ui-restoration/assets/final-report.json +83 -0
- package/examples/ui-restoration/assets/implementation.png +0 -0
- package/examples/ui-restoration/assets/initial-heatmap.png +0 -0
- package/examples/ui-restoration/assets/initial-report.json +83 -0
- package/examples/ui-restoration/assets/initial.png +0 -0
- package/examples/ui-restoration/assets/metrics.json +12 -0
- package/examples/ui-restoration/assets/reference.png +0 -0
- package/examples/ui-restoration/implementation.html +94 -0
- package/examples/ui-restoration/initial.html +57 -0
- package/lib/artifact-access.js +369 -0
- package/lib/artifact-access.js.map +1 -0
- package/lib/artifacts.js +56 -0
- package/lib/artifacts.js.map +1 -0
- package/lib/client.js +2099 -0
- package/lib/client.js.map +1 -0
- package/lib/config.js +172 -0
- package/lib/config.js.map +1 -0
- package/lib/defaults.js +6 -0
- package/lib/defaults.js.map +1 -0
- package/lib/errors.js +56 -0
- package/lib/errors.js.map +1 -0
- package/lib/evidence-cache.js +350 -0
- package/lib/evidence-cache.js.map +1 -0
- package/lib/exposure.js +247 -0
- package/lib/exposure.js.map +1 -0
- package/lib/image-input-variants.js +882 -0
- package/lib/image-input-variants.js.map +1 -0
- package/lib/index.js +105 -0
- package/lib/index.js.map +1 -0
- package/lib/paste-images.js +217 -0
- package/lib/paste-images.js.map +1 -0
- package/lib/paths.js +354 -0
- package/lib/paths.js.map +1 -0
- package/lib/plugin-update.js +1003 -0
- package/lib/plugin-update.js.map +1 -0
- package/lib/runtime-install.js +964 -0
- package/lib/runtime-install.js.map +1 -0
- package/lib/runtime-manager.js +133 -0
- package/lib/runtime-manager.js.map +1 -0
- package/lib/runtime.js +1678 -0
- package/lib/runtime.js.map +1 -0
- package/lib/skill.js +25 -0
- package/lib/skill.js.map +1 -0
- package/lib/tools.js +549 -0
- package/lib/tools.js.map +1 -0
- package/lib/types/artifact-access.d.ts +61 -0
- package/lib/types/artifact-access.d.ts.map +1 -0
- package/lib/types/artifacts.d.ts +42 -0
- package/lib/types/artifacts.d.ts.map +1 -0
- package/lib/types/client/display-config.d.ts +24 -0
- package/lib/types/client/display-config.d.ts.map +1 -0
- package/lib/types/client/index.d.ts +350 -0
- package/lib/types/client/index.d.ts.map +1 -0
- package/lib/types/client/model-variants-hider.d.ts +40 -0
- package/lib/types/client/model-variants-hider.d.ts.map +1 -0
- package/lib/types/client/paste-images.d.ts +126 -0
- package/lib/types/client/paste-images.d.ts.map +1 -0
- package/lib/types/config.d.ts +123 -0
- package/lib/types/config.d.ts.map +1 -0
- package/lib/types/defaults.d.ts +6 -0
- package/lib/types/defaults.d.ts.map +1 -0
- package/lib/types/errors.d.ts +35 -0
- package/lib/types/errors.d.ts.map +1 -0
- package/lib/types/evidence-cache.d.ts +91 -0
- package/lib/types/evidence-cache.d.ts.map +1 -0
- package/lib/types/exposure.d.ts +50 -0
- package/lib/types/exposure.d.ts.map +1 -0
- package/lib/types/image-input-variants.d.ts +144 -0
- package/lib/types/image-input-variants.d.ts.map +1 -0
- package/lib/types/index.d.ts +19 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/paste-images.d.ts +73 -0
- package/lib/types/paste-images.d.ts.map +1 -0
- package/lib/types/paths.d.ts +117 -0
- package/lib/types/paths.d.ts.map +1 -0
- package/lib/types/plugin-update.d.ts +119 -0
- package/lib/types/plugin-update.d.ts.map +1 -0
- package/lib/types/runtime-install.d.ts +92 -0
- package/lib/types/runtime-install.d.ts.map +1 -0
- package/lib/types/runtime-manager.d.ts +60 -0
- package/lib/types/runtime-manager.d.ts.map +1 -0
- package/lib/types/runtime.d.ts +412 -0
- package/lib/types/runtime.d.ts.map +1 -0
- package/lib/types/skill.d.ts +14 -0
- package/lib/types/skill.d.ts.map +1 -0
- package/lib/types/tools.d.ts +35 -0
- package/lib/types/tools.d.ts.map +1 -0
- package/lib/types/upstream.d.ts +233 -0
- package/lib/types/upstream.d.ts.map +1 -0
- package/lib/types/version.d.ts +15 -0
- package/lib/types/version.d.ts.map +1 -0
- package/lib/types/web-request.d.ts +11 -0
- package/lib/types/web-request.d.ts.map +1 -0
- package/lib/types/web.d.ts +118 -0
- package/lib/types/web.d.ts.map +1 -0
- package/lib/upstream.js +860 -0
- package/lib/upstream.js.map +1 -0
- package/lib/version.js +18 -0
- package/lib/version.js.map +1 -0
- package/lib/web-request.js +29 -0
- package/lib/web-request.js.map +1 -0
- package/lib/web.js +462 -0
- package/lib/web.js.map +1 -0
- package/package.json +149 -0
- package/patches/vision-tools-dsh.patch +970 -0
- package/runtime/requirements.lock +3 -0
- package/src/artifact-access.ts +386 -0
- package/src/artifacts.ts +85 -0
- package/src/client/display-config.ts +62 -0
- package/src/client/index.tsx +1580 -0
- package/src/client/model-variants-hider.ts +159 -0
- package/src/client/paste-images.tsx +747 -0
- package/src/config.ts +290 -0
- package/src/defaults.ts +5 -0
- package/src/errors.ts +62 -0
- package/src/evidence-cache.ts +418 -0
- package/src/exposure.ts +265 -0
- package/src/image-input-variants.ts +996 -0
- package/src/index.ts +141 -0
- package/src/paste-images.ts +286 -0
- package/src/paths.ts +383 -0
- package/src/plugin-update.ts +1143 -0
- package/src/runtime-install.ts +1161 -0
- package/src/runtime-manager.ts +174 -0
- package/src/runtime.ts +2189 -0
- package/src/skill.ts +35 -0
- package/src/tools.ts +691 -0
- package/src/upstream.ts +1078 -0
- package/src/version.ts +37 -0
- package/src/web-request.ts +27 -0
- package/src/web.ts +594 -0
- package/vendor/agent-vision-toolkit/CHANGELOG.md +30 -0
- package/vendor/agent-vision-toolkit/LICENSE +21 -0
- package/vendor/agent-vision-toolkit/README.md +405 -0
- package/vendor/agent-vision-toolkit/UPSTREAM_MANIFEST.json +94 -0
- package/vendor/agent-vision-toolkit/bin/crop +90 -0
- package/vendor/agent-vision-toolkit/bin/detect +13 -0
- package/vendor/agent-vision-toolkit/bin/glance +93 -0
- package/vendor/agent-vision-toolkit/bin/ground +13 -0
- package/vendor/agent-vision-toolkit/bin/trace +129 -0
- package/vendor/agent-vision-toolkit/detect.py +60 -0
- package/vendor/agent-vision-toolkit/ground.py +267 -0
- package/vendor/agent-vision-toolkit/skills/vision-tools/scripts/dominant_colors.py +224 -0
- package/vendor/agent-vision-toolkit/skills/vision-tools/scripts/extract_fg.py +278 -0
- package/vendor/agent-vision-toolkit/skills/vision-tools/scripts/html_shot.py +420 -0
- package/vendor/agent-vision-toolkit/skills/vision-tools/scripts/long_screenshot_ocr.py +1245 -0
- package/vendor/agent-vision-toolkit/skills/vision-tools/scripts/pixel_diff.py +88 -0
- package/vendor/agent-vision-toolkit/tests/test_vision_client.py +450 -0
- package/vendor/agent-vision-toolkit/vision_client.py +310 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transparent routing for the host model selector: when `imageInputVariants.hidden`
|
|
3
|
+
* is enabled, variant routes keep the upstream provider/model display names and
|
|
4
|
+
* the browser hides the upstream text-only entries that have a variant twin.
|
|
5
|
+
* Users then see one entry per model — the original name — while the session
|
|
6
|
+
* actually runs on the image-capable variant, so pasted images, history with
|
|
7
|
+
* images, and the built-in `read_image` tool all keep working on text-only
|
|
8
|
+
* models without exposing `(Vision Toolkit)` routes.
|
|
9
|
+
*
|
|
10
|
+
* The host selector renders one `[role=group]` per provider whose group title
|
|
11
|
+
* id is `:<react-radix>:-<providerId>`, and one `[role=menuitemradio]` per
|
|
12
|
+
* model. We key groups by that provider id (variant routes carry the
|
|
13
|
+
* `vision-toolkit-` prefix) and hide every upstream entry whose display name
|
|
14
|
+
* matches a variant twin, collapsing fully-hidden upstream groups.
|
|
15
|
+
*
|
|
16
|
+
* The hiding decision is purely DOM-local: transparent mode is exactly the
|
|
17
|
+
* case where a variant twin keeps the upstream display name, while explicit
|
|
18
|
+
* mode appends `(Vision Toolkit)` and therefore never matches. No display-config
|
|
19
|
+
* round-trip is needed before the selector can be tidied, so the first paint
|
|
20
|
+
* of an opened menu already shows the merged list instead of flashing the
|
|
21
|
+
* duplicate upstream group.
|
|
22
|
+
* @module dsh-vision-toolkit/model-variants-hider
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const VARIANT_PROVIDER_PREFIX = 'vision-toolkit-'
|
|
26
|
+
|
|
27
|
+
/** Elements we hid and their original inline display value, for restoration. */
|
|
28
|
+
const hiddenElements = new Map<HTMLElement, string>()
|
|
29
|
+
|
|
30
|
+
let active = false
|
|
31
|
+
let observer: MutationObserver | undefined
|
|
32
|
+
let tidyQueued = false
|
|
33
|
+
|
|
34
|
+
/** Derive the provider id from a group's `aria-labelledby` title id. */
|
|
35
|
+
function providerIdOf(group: Element): string | undefined {
|
|
36
|
+
const labelledBy = group.getAttribute('aria-labelledby')
|
|
37
|
+
if (labelledBy === null || labelledBy === '') return undefined
|
|
38
|
+
const titleId = document.getElementById(labelledBy)?.id ?? labelledBy
|
|
39
|
+
const reactPrefixed = /^:[^:]+:-(.+)$/u.exec(titleId)
|
|
40
|
+
if (reactPrefixed !== null) return reactPrefixed[1]
|
|
41
|
+
return titleId.replace(/^-/u, '')
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function modelNames(group: Element): string[] {
|
|
45
|
+
return [...group.querySelectorAll<HTMLElement>('[role="menuitemradio"]')]
|
|
46
|
+
.map(button => (button.title || (button.textContent ?? '')).trim())
|
|
47
|
+
.filter(Boolean)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function hideElement(element: HTMLElement): void {
|
|
51
|
+
if (!hiddenElements.has(element)) hiddenElements.set(element, element.style.display)
|
|
52
|
+
element.style.display = 'none'
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function restoreHidden(): void {
|
|
56
|
+
for (const [element, display] of hiddenElements) {
|
|
57
|
+
element.style.display = display
|
|
58
|
+
}
|
|
59
|
+
hiddenElements.clear()
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Hide upstream text-only entries that have a variant twin. Group keys come
|
|
64
|
+
* from `aria-labelledby` ids so provider identity is reliable even when the
|
|
65
|
+
* variant provider name equals the upstream name (transparent mode).
|
|
66
|
+
*/
|
|
67
|
+
export function tidyModelSelector(): void {
|
|
68
|
+
if (document.querySelector('[role="menu"]') === null) return
|
|
69
|
+
// The host re-renders selectors while sessions stay open; drop bookkeeping
|
|
70
|
+
// for entries that already left the DOM so the map cannot grow unboundedly.
|
|
71
|
+
for (const element of [...hiddenElements.keys()]) {
|
|
72
|
+
if (!element.isConnected) hiddenElements.delete(element)
|
|
73
|
+
}
|
|
74
|
+
const groups = [...document.querySelectorAll<HTMLElement>('[role="menu"] [role="group"]')]
|
|
75
|
+
const byProvider = new Map<string, HTMLElement[]>()
|
|
76
|
+
for (const group of groups) {
|
|
77
|
+
const provider = providerIdOf(group)
|
|
78
|
+
if (provider === undefined) continue
|
|
79
|
+
const entries = byProvider.get(provider)
|
|
80
|
+
if (entries === undefined) byProvider.set(provider, [group])
|
|
81
|
+
else entries.push(group)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const shouldHide = new Set<HTMLElement>()
|
|
85
|
+
for (const [provider, providerGroups] of byProvider) {
|
|
86
|
+
if (!provider.startsWith(VARIANT_PROVIDER_PREFIX)) continue
|
|
87
|
+
const upstream = provider.slice(VARIANT_PROVIDER_PREFIX.length)
|
|
88
|
+
const twinNames = new Set(providerGroups.flatMap(modelNames))
|
|
89
|
+
if (twinNames.size === 0) continue
|
|
90
|
+
for (const upstreamGroup of byProvider.get(upstream) ?? []) {
|
|
91
|
+
const buttons = [...upstreamGroup.querySelectorAll<HTMLElement>('[role="menuitemradio"]')]
|
|
92
|
+
const matched: HTMLElement[] = []
|
|
93
|
+
for (const button of buttons) {
|
|
94
|
+
const name = (button.title || (button.textContent ?? '')).trim()
|
|
95
|
+
if (twinNames.has(name)) matched.push(button)
|
|
96
|
+
}
|
|
97
|
+
if (matched.length === 0) continue
|
|
98
|
+
for (const button of matched) shouldHide.add(button)
|
|
99
|
+
// Collapse the whole group only when every model has a variant twin;
|
|
100
|
+
// otherwise a partially matched group keeps its unmatched entries.
|
|
101
|
+
if (matched.length === buttons.length) shouldHide.add(upstreamGroup)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Restore entries whose twin disappeared (e.g. transparent routing was
|
|
106
|
+
// disabled and the wrapper rebuilt with explicit `(Vision Toolkit)` names).
|
|
107
|
+
for (const [element, display] of [...hiddenElements]) {
|
|
108
|
+
if (!shouldHide.has(element)) {
|
|
109
|
+
element.style.display = display
|
|
110
|
+
hiddenElements.delete(element)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
for (const element of shouldHide) hideElement(element)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Install the transparent-routing integrator. It watches the document for
|
|
118
|
+
* model-selector renderings and re-tidies them whenever the host re-renders.
|
|
119
|
+
* Tidy runs in a microtask (before the browser paints) and is coalesced across
|
|
120
|
+
* the render batch, so opening the selector never shows the upstream twins.
|
|
121
|
+
* @returns the disposer that stops observation and restores hidden entries.
|
|
122
|
+
*/
|
|
123
|
+
export function installModelVariantsHider(): () => void {
|
|
124
|
+
if (observer !== undefined) {
|
|
125
|
+
// A previous install is still active; a duplicate effect must not tear
|
|
126
|
+
// down the integrator while its original owner still expects it.
|
|
127
|
+
return () => {}
|
|
128
|
+
}
|
|
129
|
+
let disposed = false
|
|
130
|
+
const tidySoon = (): void => {
|
|
131
|
+
if (tidyQueued || disposed) return
|
|
132
|
+
tidyQueued = true
|
|
133
|
+
queueMicrotask(() => {
|
|
134
|
+
tidyQueued = false
|
|
135
|
+
if (disposed) return
|
|
136
|
+
active = true
|
|
137
|
+
tidyModelSelector()
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
observer = new MutationObserver(tidySoon)
|
|
142
|
+
observer.observe(document.body, { childList: true, subtree: true })
|
|
143
|
+
active = true
|
|
144
|
+
tidyModelSelector()
|
|
145
|
+
|
|
146
|
+
return () => {
|
|
147
|
+
disposed = true
|
|
148
|
+
observer?.disconnect()
|
|
149
|
+
observer = undefined
|
|
150
|
+
tidyQueued = false
|
|
151
|
+
restoreHidden()
|
|
152
|
+
active = false
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Test seam: expose whether the integrator is currently installed. */
|
|
157
|
+
export function isModelVariantsHiderActive(): boolean {
|
|
158
|
+
return active
|
|
159
|
+
}
|