@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,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Atomic live configuration owner for the plugin's internal runtime. A new
|
|
3
|
+
* upstream adapter is fully prepared before it replaces the currently serving
|
|
4
|
+
* runtime, so failed Settings edits never interrupt in-flight or later calls.
|
|
5
|
+
* @module dsh-vision-toolkit/runtime-manager
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { Context } from '@deepseek-ai/cordis'
|
|
9
|
+
import { resolveConfig, type ResolvedVisionToolkitConfig, type VisionToolkitConfig } from './config.ts'
|
|
10
|
+
import { VisionToolkitRuntime } from './runtime.ts'
|
|
11
|
+
import { UpstreamAdapter, type UpstreamVersionInfo } from './upstream.ts'
|
|
12
|
+
|
|
13
|
+
/** One completely prepared configuration generation. */
|
|
14
|
+
export interface PreparedRuntimeGeneration {
|
|
15
|
+
config: ResolvedVisionToolkitConfig
|
|
16
|
+
fingerprint: string
|
|
17
|
+
runtime: VisionToolkitRuntime
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Public, secret-free status used by the Settings page. */
|
|
21
|
+
export interface RuntimeManagerStatus {
|
|
22
|
+
ready: boolean
|
|
23
|
+
generation: number
|
|
24
|
+
activeConfig?: ResolvedVisionToolkitConfig
|
|
25
|
+
upstream?: UpstreamVersionInfo
|
|
26
|
+
lastError?: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Test seam for preparing one generation. */
|
|
30
|
+
export type RuntimeGenerationFactory = (
|
|
31
|
+
ctx: Context,
|
|
32
|
+
config: ResolvedVisionToolkitConfig,
|
|
33
|
+
) => Promise<VisionToolkitRuntime>
|
|
34
|
+
|
|
35
|
+
async function defaultFactory(ctx: Context, config: ResolvedVisionToolkitConfig): Promise<VisionToolkitRuntime> {
|
|
36
|
+
const adapter = new UpstreamAdapter(ctx, config)
|
|
37
|
+
await adapter.prepare()
|
|
38
|
+
return new VisionToolkitRuntime(ctx, config, adapter)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function fingerprint(config: ResolvedVisionToolkitConfig): string {
|
|
42
|
+
// Transparent routing is a display/policy flag: toggling it must not rebuild
|
|
43
|
+
// or re-verify the vision runtime, only reconcile the model-selector routes.
|
|
44
|
+
return JSON.stringify({
|
|
45
|
+
...config,
|
|
46
|
+
imageInputVariants: { ...config.imageInputVariants, hidden: false },
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function messageOf(error: unknown): string {
|
|
51
|
+
return error instanceof Error ? error.message : String(error)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Internal runtime source with prepare-before-swap semantics. */
|
|
55
|
+
export class VisionToolkitRuntimeManager {
|
|
56
|
+
private active: PreparedRuntimeGeneration | undefined
|
|
57
|
+
private generation = 0
|
|
58
|
+
private reconfigureTicket = 0
|
|
59
|
+
private lastError: string | undefined
|
|
60
|
+
|
|
61
|
+
constructor(
|
|
62
|
+
private readonly ctx: Context,
|
|
63
|
+
private readonly factory: RuntimeGenerationFactory = defaultFactory,
|
|
64
|
+
) {}
|
|
65
|
+
|
|
66
|
+
/** The currently serving runtime; unavailable until one generation prepares. */
|
|
67
|
+
current(): VisionToolkitRuntime {
|
|
68
|
+
if (this.active === undefined) throw new Error('dsh-vision-toolkit runtime is not ready')
|
|
69
|
+
return this.active.runtime
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Whether at least one generation is available. */
|
|
73
|
+
get ready(): boolean {
|
|
74
|
+
return this.active !== undefined
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Resolve and fully prepare a candidate without changing the active runtime. */
|
|
78
|
+
async prepareCandidate(raw: VisionToolkitConfig): Promise<PreparedRuntimeGeneration> {
|
|
79
|
+
const config = resolveConfig(raw)
|
|
80
|
+
const resolvedFingerprint = fingerprint(config)
|
|
81
|
+
if (this.active?.fingerprint === resolvedFingerprint) {
|
|
82
|
+
return { ...this.active, config }
|
|
83
|
+
}
|
|
84
|
+
const runtime = await this.factory(this.ctx, config)
|
|
85
|
+
return { config, fingerprint: resolvedFingerprint, runtime }
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Publish one already-prepared generation atomically.
|
|
90
|
+
* @param candidate - generation returned by {@link prepareCandidate}.
|
|
91
|
+
*/
|
|
92
|
+
activateCandidate(candidate: PreparedRuntimeGeneration): void {
|
|
93
|
+
if (this.active?.fingerprint === candidate.fingerprint) {
|
|
94
|
+
this.active = candidate
|
|
95
|
+
this.lastError = undefined
|
|
96
|
+
return
|
|
97
|
+
}
|
|
98
|
+
this.reconfigureTicket += 1
|
|
99
|
+
this.active = candidate
|
|
100
|
+
this.generation += 1
|
|
101
|
+
this.lastError = undefined
|
|
102
|
+
this.ctx.logger.info(
|
|
103
|
+
'dsh-vision-toolkit runtime generation=%d active (upstream %s @ %s, checkout %s)',
|
|
104
|
+
this.generation,
|
|
105
|
+
candidate.runtime.upstreamVersion.version,
|
|
106
|
+
candidate.runtime.upstreamVersion.commit,
|
|
107
|
+
candidate.runtime.upstreamVersion.path,
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Prepare and publish the initial or explicitly validated generation. */
|
|
112
|
+
async initialize(raw: VisionToolkitConfig): Promise<void> {
|
|
113
|
+
try {
|
|
114
|
+
this.activateCandidate(await this.prepareCandidate(raw))
|
|
115
|
+
} catch (error) {
|
|
116
|
+
this.lastError = messageOf(error)
|
|
117
|
+
throw error
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Apply an externally committed Settings generation. Concurrent edits are
|
|
123
|
+
* last-write-wins; a slower obsolete prepare can never overwrite a newer one.
|
|
124
|
+
* @returns whether this call published a new active generation.
|
|
125
|
+
*/
|
|
126
|
+
async reconfigure(raw: VisionToolkitConfig): Promise<boolean> {
|
|
127
|
+
const ticket = ++this.reconfigureTicket
|
|
128
|
+
let candidate: PreparedRuntimeGeneration
|
|
129
|
+
try {
|
|
130
|
+
candidate = await this.prepareCandidate(raw)
|
|
131
|
+
} catch (error) {
|
|
132
|
+
if (ticket === this.reconfigureTicket) this.lastError = messageOf(error)
|
|
133
|
+
throw error
|
|
134
|
+
}
|
|
135
|
+
if (ticket !== this.reconfigureTicket) return false
|
|
136
|
+
const changed = this.active?.fingerprint !== candidate.fingerprint
|
|
137
|
+
this.active = candidate
|
|
138
|
+
if (changed) {
|
|
139
|
+
this.generation += 1
|
|
140
|
+
this.ctx.logger.info(
|
|
141
|
+
'dsh-vision-toolkit Settings activated runtime generation=%d (upstream %s @ %s, checkout %s)',
|
|
142
|
+
this.generation,
|
|
143
|
+
candidate.runtime.upstreamVersion.version,
|
|
144
|
+
candidate.runtime.upstreamVersion.commit,
|
|
145
|
+
candidate.runtime.upstreamVersion.path,
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
this.lastError = undefined
|
|
149
|
+
return changed
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Record a failed preflight while retaining the previous generation. */
|
|
153
|
+
recordFailure(error: unknown): void {
|
|
154
|
+
this.lastError = messageOf(error)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Secret-free status snapshot for health/configuration surfaces. */
|
|
158
|
+
status(): RuntimeManagerStatus {
|
|
159
|
+
if (this.active === undefined) {
|
|
160
|
+
return {
|
|
161
|
+
ready: false,
|
|
162
|
+
generation: this.generation,
|
|
163
|
+
...(this.lastError === undefined ? {} : { lastError: this.lastError }),
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
ready: true,
|
|
168
|
+
generation: this.generation,
|
|
169
|
+
activeConfig: this.active.config,
|
|
170
|
+
upstream: this.active.runtime.upstreamVersion,
|
|
171
|
+
...(this.lastError === undefined ? {} : { lastError: this.lastError }),
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|