@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.
Files changed (216) hide show
  1. package/LICENSE +21 -0
  2. package/README.i18n.yaml +6 -0
  3. package/README.md +356 -0
  4. package/README.zh.md +354 -0
  5. package/assets/community-group-qr.png +0 -0
  6. package/assets/dsh-conversation-artifact.png +0 -0
  7. package/assets/dsh-conversation-image-qa-top.png +0 -0
  8. package/assets/dsh-conversation-image-qa.png +0 -0
  9. package/assets/dsh-conversation-pixel-diff.png +0 -0
  10. package/assets/dsh-conversation-screenshot-debugging-top.png +0 -0
  11. package/assets/dsh-conversation-screenshot-debugging.png +0 -0
  12. package/assets/dsh-conversation-tool-call.png +0 -0
  13. package/assets/dsh-conversation-vision-trace.png +0 -0
  14. package/assets/dsh-view-example.png +0 -0
  15. package/assets/hero-v2.png +0 -0
  16. package/assets/logo_aihubmix.png +0 -0
  17. package/assets/python-bootstrap.json +48 -0
  18. package/assets/skill/SKILL.md +329 -0
  19. package/assets/skill/UPSTREAM.json +71 -0
  20. package/assets/skill/references/gui.md +88 -0
  21. package/assets/skill/references/long-screenshot-ocr.md +77 -0
  22. package/assets/skill/references/restore-graphic.md +84 -0
  23. package/assets/skill/references/restore-structure.md +45 -0
  24. package/assets/skill/references/restore-ui.md +202 -0
  25. package/assets/social-preview.png +0 -0
  26. package/assets/upstream/README.md +18 -0
  27. package/assets/upstream/focus-hint-comparison-1.webp +0 -0
  28. package/assets/upstream/focus-hint-comparison-2.webp +0 -0
  29. package/assets/upstream/infographic-reference.webp +0 -0
  30. package/assets/upstream/infographic-result.webp +0 -0
  31. package/assets/upstream/ui-fast-restore-reference.webp +0 -0
  32. package/assets/upstream/ui-fast-restore-result.webp +0 -0
  33. package/assets/upstream/ui-result.webp +0 -0
  34. package/assets/upstream/ui-sketch.webp +0 -0
  35. package/assets/vision-model-test.png +0 -0
  36. package/assets/vision-settings.png +0 -0
  37. package/assets/wechat-reward.png +0 -0
  38. package/cordis.patch.yml +6 -0
  39. package/docs/aihubmix-gemini-vision.i18n.yaml +6 -0
  40. package/docs/aihubmix-gemini-vision.md +138 -0
  41. package/docs/aihubmix-gemini-vision.zh.md +138 -0
  42. package/docs/assets/aihubmix-api-keys.png +0 -0
  43. package/docs/assets/aihubmix-create-key.png +0 -0
  44. package/docs/assets/aihubmix-free-vision-model.png +0 -0
  45. package/docs/assets/aihubmix-home.png +0 -0
  46. package/docs/assets/aihubmix-sign-up.png +0 -0
  47. package/docs/assets/groq-console-home.png +0 -0
  48. package/docs/assets/groq-console-keys-login.png +0 -0
  49. package/docs/assets/groq-docs-quickstart.png +0 -0
  50. package/docs/assets/groq-docs-qwen3.6.png +0 -0
  51. package/docs/assets/groq-docs-vision.png +0 -0
  52. package/docs/assets/vision-settings.png +0 -0
  53. package/docs/dsh-desktop-install.md +67 -0
  54. package/docs/dsh-desktop-install.zh.md +67 -0
  55. package/docs/groq-qwen3.6-vision.i18n.yaml +6 -0
  56. package/docs/groq-qwen3.6-vision.md +236 -0
  57. package/docs/groq-qwen3.6-vision.zh.md +236 -0
  58. package/docs/python-runtime.i18n.yaml +6 -0
  59. package/docs/python-runtime.md +89 -0
  60. package/docs/python-runtime.zh.md +89 -0
  61. package/docs/requirements-traceability/README.i18n.yaml +6 -0
  62. package/docs/requirements-traceability/README.md +75 -0
  63. package/docs/requirements-traceability/README.zh.md +75 -0
  64. package/examples/ui-restoration/README.i18n.yaml +6 -0
  65. package/examples/ui-restoration/README.md +70 -0
  66. package/examples/ui-restoration/README.zh.md +70 -0
  67. package/examples/ui-restoration/assets/final-heatmap.png +0 -0
  68. package/examples/ui-restoration/assets/final-report.json +83 -0
  69. package/examples/ui-restoration/assets/implementation.png +0 -0
  70. package/examples/ui-restoration/assets/initial-heatmap.png +0 -0
  71. package/examples/ui-restoration/assets/initial-report.json +83 -0
  72. package/examples/ui-restoration/assets/initial.png +0 -0
  73. package/examples/ui-restoration/assets/metrics.json +12 -0
  74. package/examples/ui-restoration/assets/reference.png +0 -0
  75. package/examples/ui-restoration/implementation.html +94 -0
  76. package/examples/ui-restoration/initial.html +57 -0
  77. package/lib/artifact-access.js +369 -0
  78. package/lib/artifact-access.js.map +1 -0
  79. package/lib/artifacts.js +56 -0
  80. package/lib/artifacts.js.map +1 -0
  81. package/lib/client.js +2099 -0
  82. package/lib/client.js.map +1 -0
  83. package/lib/config.js +172 -0
  84. package/lib/config.js.map +1 -0
  85. package/lib/defaults.js +6 -0
  86. package/lib/defaults.js.map +1 -0
  87. package/lib/errors.js +56 -0
  88. package/lib/errors.js.map +1 -0
  89. package/lib/evidence-cache.js +350 -0
  90. package/lib/evidence-cache.js.map +1 -0
  91. package/lib/exposure.js +247 -0
  92. package/lib/exposure.js.map +1 -0
  93. package/lib/image-input-variants.js +882 -0
  94. package/lib/image-input-variants.js.map +1 -0
  95. package/lib/index.js +105 -0
  96. package/lib/index.js.map +1 -0
  97. package/lib/paste-images.js +217 -0
  98. package/lib/paste-images.js.map +1 -0
  99. package/lib/paths.js +354 -0
  100. package/lib/paths.js.map +1 -0
  101. package/lib/plugin-update.js +1003 -0
  102. package/lib/plugin-update.js.map +1 -0
  103. package/lib/runtime-install.js +964 -0
  104. package/lib/runtime-install.js.map +1 -0
  105. package/lib/runtime-manager.js +133 -0
  106. package/lib/runtime-manager.js.map +1 -0
  107. package/lib/runtime.js +1678 -0
  108. package/lib/runtime.js.map +1 -0
  109. package/lib/skill.js +25 -0
  110. package/lib/skill.js.map +1 -0
  111. package/lib/tools.js +549 -0
  112. package/lib/tools.js.map +1 -0
  113. package/lib/types/artifact-access.d.ts +61 -0
  114. package/lib/types/artifact-access.d.ts.map +1 -0
  115. package/lib/types/artifacts.d.ts +42 -0
  116. package/lib/types/artifacts.d.ts.map +1 -0
  117. package/lib/types/client/display-config.d.ts +24 -0
  118. package/lib/types/client/display-config.d.ts.map +1 -0
  119. package/lib/types/client/index.d.ts +350 -0
  120. package/lib/types/client/index.d.ts.map +1 -0
  121. package/lib/types/client/model-variants-hider.d.ts +40 -0
  122. package/lib/types/client/model-variants-hider.d.ts.map +1 -0
  123. package/lib/types/client/paste-images.d.ts +126 -0
  124. package/lib/types/client/paste-images.d.ts.map +1 -0
  125. package/lib/types/config.d.ts +123 -0
  126. package/lib/types/config.d.ts.map +1 -0
  127. package/lib/types/defaults.d.ts +6 -0
  128. package/lib/types/defaults.d.ts.map +1 -0
  129. package/lib/types/errors.d.ts +35 -0
  130. package/lib/types/errors.d.ts.map +1 -0
  131. package/lib/types/evidence-cache.d.ts +91 -0
  132. package/lib/types/evidence-cache.d.ts.map +1 -0
  133. package/lib/types/exposure.d.ts +50 -0
  134. package/lib/types/exposure.d.ts.map +1 -0
  135. package/lib/types/image-input-variants.d.ts +144 -0
  136. package/lib/types/image-input-variants.d.ts.map +1 -0
  137. package/lib/types/index.d.ts +19 -0
  138. package/lib/types/index.d.ts.map +1 -0
  139. package/lib/types/paste-images.d.ts +73 -0
  140. package/lib/types/paste-images.d.ts.map +1 -0
  141. package/lib/types/paths.d.ts +117 -0
  142. package/lib/types/paths.d.ts.map +1 -0
  143. package/lib/types/plugin-update.d.ts +119 -0
  144. package/lib/types/plugin-update.d.ts.map +1 -0
  145. package/lib/types/runtime-install.d.ts +92 -0
  146. package/lib/types/runtime-install.d.ts.map +1 -0
  147. package/lib/types/runtime-manager.d.ts +60 -0
  148. package/lib/types/runtime-manager.d.ts.map +1 -0
  149. package/lib/types/runtime.d.ts +412 -0
  150. package/lib/types/runtime.d.ts.map +1 -0
  151. package/lib/types/skill.d.ts +14 -0
  152. package/lib/types/skill.d.ts.map +1 -0
  153. package/lib/types/tools.d.ts +35 -0
  154. package/lib/types/tools.d.ts.map +1 -0
  155. package/lib/types/upstream.d.ts +233 -0
  156. package/lib/types/upstream.d.ts.map +1 -0
  157. package/lib/types/version.d.ts +15 -0
  158. package/lib/types/version.d.ts.map +1 -0
  159. package/lib/types/web-request.d.ts +11 -0
  160. package/lib/types/web-request.d.ts.map +1 -0
  161. package/lib/types/web.d.ts +118 -0
  162. package/lib/types/web.d.ts.map +1 -0
  163. package/lib/upstream.js +860 -0
  164. package/lib/upstream.js.map +1 -0
  165. package/lib/version.js +18 -0
  166. package/lib/version.js.map +1 -0
  167. package/lib/web-request.js +29 -0
  168. package/lib/web-request.js.map +1 -0
  169. package/lib/web.js +462 -0
  170. package/lib/web.js.map +1 -0
  171. package/package.json +149 -0
  172. package/patches/vision-tools-dsh.patch +970 -0
  173. package/runtime/requirements.lock +3 -0
  174. package/src/artifact-access.ts +386 -0
  175. package/src/artifacts.ts +85 -0
  176. package/src/client/display-config.ts +62 -0
  177. package/src/client/index.tsx +1580 -0
  178. package/src/client/model-variants-hider.ts +159 -0
  179. package/src/client/paste-images.tsx +747 -0
  180. package/src/config.ts +290 -0
  181. package/src/defaults.ts +5 -0
  182. package/src/errors.ts +62 -0
  183. package/src/evidence-cache.ts +418 -0
  184. package/src/exposure.ts +265 -0
  185. package/src/image-input-variants.ts +996 -0
  186. package/src/index.ts +141 -0
  187. package/src/paste-images.ts +286 -0
  188. package/src/paths.ts +383 -0
  189. package/src/plugin-update.ts +1143 -0
  190. package/src/runtime-install.ts +1161 -0
  191. package/src/runtime-manager.ts +174 -0
  192. package/src/runtime.ts +2189 -0
  193. package/src/skill.ts +35 -0
  194. package/src/tools.ts +691 -0
  195. package/src/upstream.ts +1078 -0
  196. package/src/version.ts +37 -0
  197. package/src/web-request.ts +27 -0
  198. package/src/web.ts +594 -0
  199. package/vendor/agent-vision-toolkit/CHANGELOG.md +30 -0
  200. package/vendor/agent-vision-toolkit/LICENSE +21 -0
  201. package/vendor/agent-vision-toolkit/README.md +405 -0
  202. package/vendor/agent-vision-toolkit/UPSTREAM_MANIFEST.json +94 -0
  203. package/vendor/agent-vision-toolkit/bin/crop +90 -0
  204. package/vendor/agent-vision-toolkit/bin/detect +13 -0
  205. package/vendor/agent-vision-toolkit/bin/glance +93 -0
  206. package/vendor/agent-vision-toolkit/bin/ground +13 -0
  207. package/vendor/agent-vision-toolkit/bin/trace +129 -0
  208. package/vendor/agent-vision-toolkit/detect.py +60 -0
  209. package/vendor/agent-vision-toolkit/ground.py +267 -0
  210. package/vendor/agent-vision-toolkit/skills/vision-tools/scripts/dominant_colors.py +224 -0
  211. package/vendor/agent-vision-toolkit/skills/vision-tools/scripts/extract_fg.py +278 -0
  212. package/vendor/agent-vision-toolkit/skills/vision-tools/scripts/html_shot.py +420 -0
  213. package/vendor/agent-vision-toolkit/skills/vision-tools/scripts/long_screenshot_ocr.py +1245 -0
  214. package/vendor/agent-vision-toolkit/skills/vision-tools/scripts/pixel_diff.py +88 -0
  215. package/vendor/agent-vision-toolkit/tests/test_vision_client.py +450 -0
  216. package/vendor/agent-vision-toolkit/vision_client.py +310 -0
@@ -0,0 +1,73 @@
1
+ /** Workspace-local storage for images pasted into the DSH Web composer. */
2
+ import type { IncomingMessage, ServerResponse } from 'node:http';
3
+ import type { Context } from '@deepseek-ai/cordis';
4
+ /** Exact route used by the browser paste integration. */
5
+ export declare const PASTE_IMAGES_ROUTE = "/_dsh/vision-toolkit/paste-images";
6
+ /**
7
+ * Exact route the browser paste integration asks before taking a paste over:
8
+ * `GET ?sessionId=&model=&provider=&modelId=` answers the verdict from the
9
+ * live Session's model route.
10
+ */
11
+ export declare const PASTE_POLICY_ROUTE = "/_dsh/vision-toolkit/paste-policy";
12
+ /**
13
+ * One exact model route the browser should switch the Session to before the
14
+ * native attachment flow: the image-input variant of the current text-only
15
+ * model. The variant declares image input, so the paste keeps the composer
16
+ * thumbnail and the durable session image.
17
+ */
18
+ export interface PasteSwitchRoute {
19
+ /** The variant provider route (`vision-toolkit-` + upstream provider id). */
20
+ provider: string;
21
+ /** The model id, identical to the upstream text-only model's id. */
22
+ model: string;
23
+ /** The variant's selector display name (upstream name + variant suffix). */
24
+ label: string;
25
+ /** The upstream reasoning effort, when the selection carries one. */
26
+ reasoningEffort?: string;
27
+ }
28
+ /** The exact model route the browser read from the live model catalog. */
29
+ export interface PasteSelectionQuery {
30
+ provider: string;
31
+ model: string;
32
+ reasoningEffort?: string;
33
+ }
34
+ /** The paste-policy answer for one Session and model route. */
35
+ export interface PasteVerdict {
36
+ /** Whether the browser should turn the paste into workspace paths instead of attachments. */
37
+ takeOver: boolean;
38
+ /** When present, the browser switches to this route first, then lets the paste flow natively. */
39
+ autoSwitch?: PasteSwitchRoute;
40
+ }
41
+ /**
42
+ * Hard per-image upload ceiling for pastes. Files between the configured
43
+ * `maxImageBytes` (default 4 MiB) and this ceiling are stored as-is and
44
+ * auto-compressed by the runtime on first use; matching the browser-side
45
+ * safety cap keeps the two bundles in agreement.
46
+ */
47
+ export declare const MAX_PASTE_IMAGE_BYTES: number;
48
+ /** Convert an untrusted browser label into one portable leaf filename. */
49
+ export declare function safePastedImageName(raw: string, mediaType: string): string;
50
+ /** Reject a resolved path that is not rooted below the expected directory. */
51
+ export declare function ensurePathInside(root: string, target: string): void;
52
+ export interface PasteRoot {
53
+ writeRoot: string;
54
+ visibleRoot: string;
55
+ }
56
+ /**
57
+ * Resolve the managed per-session image directory used by both browser pastes
58
+ * and native attachment bridging. Keeping both flows under the same workspace
59
+ * root makes the resulting absolute path valid for the model's visual tools.
60
+ */
61
+ export declare function sessionPasteRoot(ctx: Context, sessionId: string): Promise<PasteRoot>;
62
+ /** Runtime limit face kept separate for focused backend tests. */
63
+ export interface PasteImageRuntime {
64
+ maxUploadBytes(): number;
65
+ }
66
+ /** Same-origin, live-Session-bound image upload endpoint. */
67
+ export declare class PastedImageBackend {
68
+ private readonly ctx;
69
+ private readonly runtime;
70
+ constructor(ctx: Context, runtime: PasteImageRuntime);
71
+ handle(req: IncomingMessage, res: ServerResponse): Promise<void>;
72
+ }
73
+ //# sourceMappingURL=paste-images.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paste-images.d.ts","sourceRoot":"","sources":["../../src/paste-images.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAI3E,OAAO,KAAK,EAAE,eAAe,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,MAAM,WAAW,iBAAiB;IAChC,cAAc,IAAI,MAAM,CAAA;CACzB;AAED,6DAA6D;AAC7D,qBAAa,kBAAkB;IAE3B,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBADP,GAAG,EAAE,OAAO,EACZ,OAAO,EAAE,iBAAiB;IAGvC,MAAM,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CA+BvE"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Path fence shared by every tool: inputs must live in the workspace, the
3
+ * platform temporary directory, or an explicitly authorized directory;
4
+ * outputs stay inside the plugin-managed output directory, and a symbolic
5
+ * link is allowed only when its real target stays inside the fence.
6
+ * @module dsh-vision-toolkit/paths
7
+ */
8
+ /** Supported input image extensions (the upstream client's allowlist). */
9
+ export declare const SUPPORTED_IMAGE_EXTENSIONS: readonly [".png", ".jpg", ".jpeg", ".gif", ".webp"];
10
+ /** Resolved path policy for one tool invocation. */
11
+ export interface PathPolicy {
12
+ /** Real workspace root. */
13
+ workspace: string;
14
+ /** Real platform temporary directory, authorized for transient inputs. */
15
+ tempDir: string;
16
+ /** Real allowed roots: workspace, platform temp, and configured directories. */
17
+ allowedDirs: string[];
18
+ /** Real plugin-managed output directory inside the fence. */
19
+ outputDir: string;
20
+ }
21
+ /** Whether `child` equals or lies under `parent` on the same path root. */
22
+ export declare function isWithin(parent: string, child: string): boolean;
23
+ /** Current platform temporary directory before realpath canonicalization. */
24
+ export declare function platformTempDirectory(platform?: NodeJS.Platform, environment?: NodeJS.ProcessEnv): string;
25
+ /**
26
+ * Translate the POSIX-shaped `/tmp/...` paths commonly emitted by models to
27
+ * the actual Windows temporary directory. Other paths and platforms are left
28
+ * unchanged, and the normal realpath fence still validates the result.
29
+ */
30
+ export declare function normalizePlatformTempPath(raw: string, platform?: NodeJS.Platform, tempDirectory?: string): string;
31
+ /**
32
+ * Build the per-invocation path policy: realpath the workspace, resolve and
33
+ * realpath the platform temp directory and allowed directories, and create
34
+ * the output directory inside the fence.
35
+ * @param workspaceRaw - session workspace (or process cwd fallback).
36
+ * @param allowedDirs - configured extra allowed roots.
37
+ * @param outputDirRaw - configured output directory (default `.dsh-vision-toolkit/artifacts`).
38
+ * @returns the resolved policy.
39
+ */
40
+ export declare function createPathPolicy(workspaceRaw: string, allowedDirs: readonly string[], outputDirRaw?: string): Promise<PathPolicy>;
41
+ /**
42
+ * Validate one input image path and return its fence-checked absolute path
43
+ * and byte size.
44
+ * @param raw - image path, resolved against the workspace.
45
+ * @param policy - active path fence.
46
+ * @returns absolute path and file size.
47
+ */
48
+ export declare function resolveInputFile(raw: string, policy: PathPolicy): Promise<{
49
+ path: string;
50
+ bytes: number;
51
+ }>;
52
+ /**
53
+ * Validate one authorized regular file against an explicit extension set.
54
+ * Realpath fencing makes local HTML and future non-image inputs follow the
55
+ * same symlink-safe policy as images.
56
+ * @param raw - path resolved against the workspace.
57
+ * @param policy - active path fence.
58
+ * @param extensions - accepted lowercase extensions including the leading dot.
59
+ * @param kind - user-facing noun used in stable errors.
60
+ * @returns absolute real path and file size.
61
+ */
62
+ export declare function resolveAuthorizedFile(raw: string, policy: PathPolicy, extensions: readonly string[], kind: string): Promise<{
63
+ path: string;
64
+ bytes: number;
65
+ }>;
66
+ /** Validate a local HTML document; URL and data-URI inputs never reach Chrome. */
67
+ export declare function resolveHtmlFile(raw: string, policy: PathPolicy): Promise<{
68
+ path: string;
69
+ bytes: number;
70
+ }>;
71
+ /**
72
+ * Resolve an optional user-supplied output filename inside the plugin output
73
+ * directory. Absolute paths, `..` segments, and wrong extensions are rejected.
74
+ * @param raw - output filename (workspace/outputDir-relative).
75
+ * @param policy - active path fence.
76
+ * @param defaultName - generated default filename.
77
+ * @param extensions - allowed extensions for this output kind.
78
+ * @returns absolute output path (not yet created).
79
+ */
80
+ export declare function resolveOutputFile(raw: string | undefined, policy: PathPolicy, defaultName: string, extensions: readonly string[]): string;
81
+ /**
82
+ * Reserve a random, non-user-controlled staging path inside the real output
83
+ * directory. Upstream writes here so an existing destination symlink can
84
+ * never redirect the write outside the fence.
85
+ * @param policy - active path fence.
86
+ * @param extension - output extension including the leading dot.
87
+ * @returns absent staging path inside {@link PathPolicy.outputDir}.
88
+ */
89
+ export declare function createStagedOutput(policy: PathPolicy, extension: string): string;
90
+ /** Resolve one direct child directory of the managed artifact root. */
91
+ export declare function resolveOutputDirectory(raw: string | undefined, policy: PathPolicy, defaultName: string): string;
92
+ /** Create a random staging directory that no upstream command can choose. */
93
+ export declare function createStagedDirectory(policy: PathPolicy): Promise<string>;
94
+ /**
95
+ * Copy an existing managed run into staging for an explicit resume operation.
96
+ * A missing destination is a normal first run; non-directory or symlink state
97
+ * fails closed instead of giving the upstream script an ambiguous workspace.
98
+ */
99
+ export declare function seedStagedDirectory(finalPath: string, staged: string, policy: PathPolicy): Promise<boolean>;
100
+ /**
101
+ * Atomically replace one managed artifact directory, restoring the previous
102
+ * complete run if the final rename fails. The upstream only ever writes the
103
+ * random staging path.
104
+ */
105
+ export declare function commitStagedDirectory(staged: string, finalPath: string, policy: PathPolicy): Promise<void>;
106
+ /**
107
+ * Validate a staged regular file and atomically place it at the resolved final
108
+ * filename. Replacing an existing symlink replaces the link itself; upstream
109
+ * never opens the user-selected destination.
110
+ * @param staged - random staging path returned by {@link createStagedOutput}.
111
+ * @param finalPath - final path returned by {@link resolveOutputFile}.
112
+ * @param policy - active path fence.
113
+ */
114
+ export declare function commitStagedOutput(staged: string, finalPath: string, policy: PathPolicy): Promise<void>;
115
+ /** Reject an output that would overwrite its own input file. */
116
+ export declare function assertDistinctOutput(input: string, output: string): void;
117
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/paths.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,0EAA0E;AAC1E,eAAO,MAAM,0BAA0B,qDAAsD,CAA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AI,CAIxE"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Profile-scoped self-update support for the Web Settings page.
3
+ *
4
+ * Only registry-installed copies are mutable. Local `link:`, `file:`, git,
5
+ * URL, and workspace installs stay developer-owned and are reported as
6
+ * unsupported instead of being replaced behind the user's back.
7
+ * @module dsh-vision-toolkit/plugin-update
8
+ */
9
+ import type { Context } from '@deepseek-ai/cordis';
10
+ export declare const VISION_TOOLKIT_PACKAGE = "@mengruo/dsh-vision-toolkit";
11
+ export type PluginUpdateUnavailableReason = 'profile-not-found' | 'not-direct-dependency' | 'unsupported-install-source' | 'profile-read-only' | 'pnpm-unavailable' | 'unsupported-platform' | 'restart-unmanaged' | 'restart-address-unavailable';
12
+ export interface PluginUpdateCapability {
13
+ supported: boolean;
14
+ checkSupported?: boolean;
15
+ profile?: string;
16
+ dependencySpec?: string;
17
+ reason?: PluginUpdateUnavailableReason;
18
+ }
19
+ export interface PluginUpdateCheck extends PluginUpdateCapability {
20
+ currentVersion: string;
21
+ latestVersion?: string;
22
+ updateAvailable: boolean;
23
+ checkedAt: string;
24
+ }
25
+ interface PluginUpdateResultBase {
26
+ fromVersion: string;
27
+ toVersion: string;
28
+ profile: string;
29
+ }
30
+ export type PluginUpdateResult = PluginUpdateResultBase & ({
31
+ restarting: true;
32
+ manualRestartRequired?: false;
33
+ retryAfterMs: number;
34
+ } | {
35
+ restarting: false;
36
+ manualRestartRequired: true;
37
+ retryAfterMs?: undefined;
38
+ });
39
+ export declare class PluginUpdateError extends Error {
40
+ readonly code: string;
41
+ constructor(code: string, message: string, options?: ErrorOptions);
42
+ }
43
+ export interface RestartRequest {
44
+ pid: number;
45
+ execPath: string;
46
+ args: readonly string[];
47
+ cwd: string;
48
+ logPath: string;
49
+ lockPath: string;
50
+ lockToken: string;
51
+ backupDir: string;
52
+ handoffPath: string;
53
+ profileDir: string;
54
+ pnpmPath: string;
55
+ packageName: string;
56
+ fromVersion: string;
57
+ toVersion: string;
58
+ healthUrl: string;
59
+ baselineRuntimeReady: boolean;
60
+ rollbackTimeoutMs: number;
61
+ processKillGraceMs: number;
62
+ readinessTimeoutMs: number;
63
+ oldProcessExitTimeoutMs: number;
64
+ }
65
+ export interface PluginUpdateServiceOptions {
66
+ packageRoot?: string;
67
+ profileDir?: string;
68
+ dshHome?: string;
69
+ argv?: readonly string[];
70
+ now?: () => Date;
71
+ prepareRestart?: (request: RestartRequest) => void | Promise<void>;
72
+ terminateCurrent?: () => void;
73
+ schedule?: (callback: () => void, delayMs: number) => void;
74
+ allowDetachedRestart?: boolean;
75
+ healthUrl?: string;
76
+ runtimeReady?: () => boolean;
77
+ platform?: NodeJS.Platform;
78
+ }
79
+ /** @internal Restart helper source exported for lifecycle integration tests. */
80
+ export declare const PLUGIN_RESTART_HELPER_SOURCE: string;
81
+ /** Compare two strict SemVer versions. */
82
+ export declare function compareVersions(left: string, right: string): number;
83
+ /** Profile-aware updater used by the same-origin Settings backend. */
84
+ export declare class VisionToolkitPluginUpdateService {
85
+ private readonly ctx;
86
+ private readonly currentVersion;
87
+ private readonly packageRoot;
88
+ private readonly profileDir;
89
+ private readonly dshHome;
90
+ private readonly argv;
91
+ private readonly now;
92
+ private readonly prepareRestart;
93
+ private readonly terminateCurrent;
94
+ private readonly schedule;
95
+ private readonly allowDetachedRestart;
96
+ private healthUrl;
97
+ private readonly runtimeReady;
98
+ private readonly platform;
99
+ private updating;
100
+ constructor(ctx: Pick<Context, 'subprocess'>, currentVersion: string, options?: PluginUpdateServiceOptions);
101
+ /** Bind readiness checks to the active WebServer and reject ports that cannot be reproduced on restart. */
102
+ configureWebServer(host: string, port: number): void;
103
+ private inspectProfile;
104
+ private locateProfile;
105
+ private profile;
106
+ private evaluate;
107
+ private checkContext;
108
+ /** Report whether the current installation can be safely replaced in place. */
109
+ capability(): Promise<PluginUpdateCapability>;
110
+ private runPnpm;
111
+ private rollbackInstall;
112
+ private acquireLock;
113
+ /** Query the configured npm registry without mutating the profile. */
114
+ check(): Promise<PluginUpdateCheck>;
115
+ /** Install the currently published version, then restart when this process can do so safely. */
116
+ installAndRestart(expectedVersion: string): Promise<PluginUpdateResult>;
117
+ }
118
+ export {};
119
+ //# sourceMappingURL=plugin-update.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-update.d.ts","sourceRoot":"","sources":["../../src/plugin-update.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAElD,eAAO,MAAM,sBAAsB,gCAAgC,CAAA;AAYnE,MAAM,MAAM,6BAA6B,GACrC,mBAAmB,GACnB,uBAAuB,GACvB,4BAA4B,GAC5B,mBAAmB,GACnB,kBAAkB,GAClB,sBAAsB,GACtB,mBAAmB,GACnB,6BAA6B,CAAA;AAEjC,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,OAAO,CAAA;IAClB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,6BAA6B,CAAA;CACvC;AAED,MAAM,WAAW,iBAAkB,SAAQ,sBAAsB;IAC/D,cAAc,EAAE,MAAM,CAAA;IACtB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,eAAe,EAAE,OAAO,CAAA;IACxB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,UAAU,sBAAsB;IAC9B,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,GAAG,CAAC;IACzD,UAAU,EAAE,IAAI,CAAA;IAChB,qBAAqB,CAAC,EAAE,KAAK,CAAA;IAC7B,YAAY,EAAE,MAAM,CAAA;CACrB,GAAG;IACF,UAAU,EAAE,KAAK,CAAA;IACjB,qBAAqB,EAAE,IAAI,CAAA;IAC3B,YAAY,C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A2G;IAC3G,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;YAYtC,cAAc;YAoBd,aAAa;YA+Bb,OAAO;YAIP,QAAQ;YAiDR,YAAY;IAiC1B,+EAA+E;IACzE,UAAU,IAAI,OAAO,CAAC,sBAAsB,CAAC;YAIrC,OAAO;YA8CP,eAAe;YAsBf,WAAW;IA+CzB,sEAAsE;IAChE,KAAK,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAqCzC,gGAAgG;IAC1F,iBAAiB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA0K9E"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Reproducible upstream runtime preparation. Managed mode uses the packaged,
3
+ * hash-verified agent-vision-toolkit snapshot plus an atomic isolated Python
4
+ * environment; external mode accepts only the pinned clean Git commit or an
5
+ * exact exported copy of the packaged snapshot.
6
+ * @module dsh-vision-toolkit/runtime-install
7
+ */
8
+ import type { Context } from '@deepseek-ai/cordis';
9
+ import type { ResolvedVisionToolkitConfig } from './config.ts';
10
+ /** One executable plus fixed prefix arguments (for example Windows `py -3`). */
11
+ export interface RuntimeCommand {
12
+ program: string;
13
+ prefix: string[];
14
+ display: string;
15
+ }
16
+ /** Prepared source and interpreter facts consumed by the upstream adapter. */
17
+ export interface PreparedUpstreamRuntime {
18
+ source: 'managed' | 'external';
19
+ root: string;
20
+ python: RuntimeCommand;
21
+ cleanHome: string;
22
+ pythonVersion: string;
23
+ dependencies: Record<string, string>;
24
+ }
25
+ interface UpstreamManifest {
26
+ schemaVersion: number;
27
+ repository: string;
28
+ version: string;
29
+ commit: string;
30
+ contentSha256: string;
31
+ files: Array<{
32
+ path: string;
33
+ bytes: number;
34
+ sha256: string;
35
+ }>;
36
+ }
37
+ /** Absolute root of the packaged upstream snapshot. */
38
+ export declare function bundledUpstreamRoot(): string;
39
+ /** Convert one command into a user-facing executable string. */
40
+ export declare function displayCommand(command: RuntimeCommand): string;
41
+ export declare function isolatedPythonEnvironment(home: string): NodeJS.ProcessEnv;
42
+ /** Verify every packaged upstream file against the committed content manifest. */
43
+ export declare function verifyBundledUpstream(): Promise<UpstreamManifest>;
44
+ interface PythonBootstrapArtifact {
45
+ url: string;
46
+ sha256: string;
47
+ size: number;
48
+ }
49
+ interface PythonBootstrapManifest {
50
+ schemaVersion: 1;
51
+ pythonVersion: string;
52
+ buildTag: string;
53
+ /** Optional domestic mirror base that replaces the GitHub download prefix. */
54
+ mirrorBaseUrl?: string;
55
+ artifacts: Record<string, PythonBootstrapArtifact>;
56
+ }
57
+ /** Map Node platform/arch to the pinned artifact name, including musl Linux. */
58
+ export declare function pythonBootstrapTarget(platform: string, arch: string, musl: boolean): string;
59
+ interface DownloadResponse {
60
+ statusCode: number;
61
+ headers: Record<string, string | string[] | undefined>;
62
+ body: NodeJS.ReadableStream;
63
+ close: () => Promise<void>;
64
+ }
65
+ type DownloadRequest = (url: string, signal: AbortSignal) => Promise<DownloadResponse>;
66
+ export declare function acquireBundledPython(ctx: Context, stateRoot: string, cwd: string, manifestOverride?: PythonBootstrapManifest, requestImpl?: DownloadRequest): Promise<{
67
+ command: RuntimeCommand;
68
+ version: string;
69
+ }>;
70
+ export declare function resolveBootstrapPython(ctx: Context, configured: string | undefined, cwd: string, manifestOverride?: PythonBootstrapManifest, requestImpl?: DownloadRequest): Promise<{
71
+ command: RuntimeCommand;
72
+ version: string;
73
+ major: number;
74
+ minor: number;
75
+ }>;
76
+ /** Persistent per-DSH-home cache root shared by runtime and Web support files. */
77
+ export declare function visionToolkitStateRoot(): string;
78
+ /**
79
+ * Rewrite a staged venv's `pyvenv.cfg` `home`/`executable` to point at a given
80
+ * base directory (the app execution alias directory for the Microsoft Store
81
+ * Python). Pure helper so the transformation is testable cross-platform.
82
+ */
83
+ export declare function rewriteVenvConfig(cfg: string, homeDir: string): string;
84
+ /**
85
+ * Build the Microsoft Store probe environment while preserving Python-variable
86
+ * tombstones; only the user-directory variables must fall back to the host.
87
+ */
88
+ export declare function storePythonProbeEnvironment(installEnv: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
89
+ /** Prepare the configured pinned runtime without making any vision API call. */
90
+ export declare function prepareUpstreamRuntime(ctx: Context, config: ResolvedVisionToolkitConfig): Promise<PreparedUpstreamRuntime>;
91
+ export {};
92
+ //# sourceMappingURL=runtime-install.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-install.d.ts","sourceRoot":"","sources":["../../src/runtime-install.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAwBH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAIlD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAI9D,gFAAgF;AAChF,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,8EAA8E;AAC9E,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,SAAS,GAAG,UAAU,CAAA;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,cAAc,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACrC;AASD,UAAU,gBAAgB;IACxB,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,MAAM,CAAA;IACrB,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC9D;AAsBD,uDAAuD;AACvD,wBAAgB,mBAAm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W,CAAC,EAAE,eAAe,GAC5B,OAAO,CAAC;IAAE,OAAO,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAmEvD;AAED,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,OAAO,EACZ,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,GAAG,EAAE,MAAM,EACX,gBAAgB,CAAC,EAAE,uBAAuB,EAC1C,WAAW,CAAC,EAAE,eAAe,GAC5B,OAAO,CAAC;IAAE,OAAO,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAwCrF;AAED,kFAAkF;AAClF,wBAAgB,sBAAsB,IAAI,MAAM,CAI/C;AAYD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAItE;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAI5F;AAgdD,gFAAgF;AAChF,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,2BAA2B,GAClC,OAAO,CAAC,uBAAuB,CAAC,CAKlC"}
@@ -0,0 +1,60 @@
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
+ import type { Context } from '@deepseek-ai/cordis';
8
+ import { type ResolvedVisionToolkitConfig, type VisionToolkitConfig } from './config.ts';
9
+ import { VisionToolkitRuntime } from './runtime.ts';
10
+ import { type UpstreamVersionInfo } from './upstream.ts';
11
+ /** One completely prepared configuration generation. */
12
+ export interface PreparedRuntimeGeneration {
13
+ config: ResolvedVisionToolkitConfig;
14
+ fingerprint: string;
15
+ runtime: VisionToolkitRuntime;
16
+ }
17
+ /** Public, secret-free status used by the Settings page. */
18
+ export interface RuntimeManagerStatus {
19
+ ready: boolean;
20
+ generation: number;
21
+ activeConfig?: ResolvedVisionToolkitConfig;
22
+ upstream?: UpstreamVersionInfo;
23
+ lastError?: string;
24
+ }
25
+ /** Test seam for preparing one generation. */
26
+ export type RuntimeGenerationFactory = (ctx: Context, config: ResolvedVisionToolkitConfig) => Promise<VisionToolkitRuntime>;
27
+ /** Internal runtime source with prepare-before-swap semantics. */
28
+ export declare class VisionToolkitRuntimeManager {
29
+ private readonly ctx;
30
+ private readonly factory;
31
+ private active;
32
+ private generation;
33
+ private reconfigureTicket;
34
+ private lastError;
35
+ constructor(ctx: Context, factory?: RuntimeGenerationFactory);
36
+ /** The currently serving runtime; unavailable until one generation prepares. */
37
+ current(): VisionToolkitRuntime;
38
+ /** Whether at least one generation is available. */
39
+ get ready(): boolean;
40
+ /** Resolve and fully prepare a candidate without changing the active runtime. */
41
+ prepareCandidate(raw: VisionToolkitConfig): Promise<PreparedRuntimeGeneration>;
42
+ /**
43
+ * Publish one already-prepared generation atomically.
44
+ * @param candidate - generation returned by {@link prepareCandidate}.
45
+ */
46
+ activateCandidate(candidate: PreparedRuntimeGeneration): void;
47
+ /** Prepare and publish the initial or explicitly validated generation. */
48
+ initialize(raw: VisionToolkitConfig): Promise<void>;
49
+ /**
50
+ * Apply an externally committed Settings generation. Concurrent edits are
51
+ * last-write-wins; a slower obsolete prepare can never overwrite a newer one.
52
+ * @returns whether this call published a new active generation.
53
+ */
54
+ reconfigure(raw: VisionToolkitConfig): Promise<boolean>;
55
+ /** Record a failed preflight while retaining the previous generation. */
56
+ recordFailure(error: unknown): void;
57
+ /** Secret-free status snapshot for health/configuration surfaces. */
58
+ status(): RuntimeManagerStatus;
59
+ }
60
+ //# sourceMappingURL=runtime-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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