dsh-image-gen 0.10.2 → 0.10.3
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.en.md +456 -454
- package/README.md +456 -454
- package/docs/assets/readme/canvas-edit.webp +0 -0
- package/docs/assets/readme/canvas-sketch.webp +0 -0
- package/docs/assets/readme/chat-batch.webp +0 -0
- package/docs/assets/readme/config.webp +0 -0
- package/docs/assets/readme/hero-batch.webp +0 -0
- package/docs/assets/readme/hero-canvas.webp +0 -0
- package/docs/assets/readme/studio-ref.webp +0 -0
- package/docs/assets/readme/studio.webp +0 -0
- package/lib/client.js +4871 -3658
- package/lib/index.js +2074 -140
- package/lib/types/client/browser-image-utils.d.ts +6 -0
- package/lib/types/client/datalist-scroll-fix.d.ts +32 -0
- package/lib/types/client/gallery-batch-bar.d.ts +8 -0
- package/lib/types/client/gallery-card.d.ts +21 -0
- package/lib/types/client/gallery-format.d.ts +7 -0
- package/lib/types/client/gallery-i18n.d.ts +236 -0
- package/lib/types/client/gallery-media.d.ts +46 -0
- package/lib/types/client/gallery-merge.d.ts +15 -0
- package/lib/types/client/gallery-store.d.ts +21 -2
- package/lib/types/client/gallery-thumbs.d.ts +24 -0
- package/lib/types/client/gallery-view.d.ts +0 -207
- package/lib/types/client/image-result-view.d.ts +24 -0
- package/lib/types/client/index.d.ts +1 -20
- package/lib/types/client/plugin-i18n.d.ts +375 -0
- package/lib/types/client/plugin-style.d.ts +1 -0
- package/lib/types/client/studio-helpers.d.ts +63 -0
- package/lib/types/client/studio-style.d.ts +1 -1
- package/lib/types/client/studio-view.d.ts +0 -7
- package/lib/types/client/tl/gallery-image-transfer.d.ts +1 -1
- package/lib/types/config.d.ts +12 -0
- package/lib/types/import-route.d.ts +11 -0
- package/lib/types/multipart.d.ts +29 -0
- package/lib/types/openai-compatible.d.ts +8 -0
- package/lib/types/request-cache.d.ts +41 -0
- package/lib/types/shared.d.ts +23 -0
- package/lib/types/storage-stats.d.ts +34 -0
- package/lib/types/thumb-route.d.ts +25 -0
- package/lib/types/vault-registry.d.ts +36 -0
- package/lib/types/vault-route.d.ts +8 -0
- package/lib/types/vault-store.d.ts +31 -0
- package/lib/types/zip-progress.d.ts +18 -0
- package/lib/types/zip-route.d.ts +25 -0
- package/lib/types/zip-stream.d.ts +43 -0
- package/package.json +139 -139
- package/skills/install-dsh-image-gen/SKILL.md +22 -22
- package/lib/types/client/tl/tl-trace-bridge.d.ts +0 -55
- package/lib/types/client/tl/trace-playback.d.ts +0 -101
- package/lib/types/trace-drawing.d.ts +0 -102
- package/lib/types/trace-route.d.ts +0 -12
- package/lib/types/trace-sketch.d.ts +0 -26
- package/lib/types/trace-store.d.ts +0 -23
- package/lib/types/vendor/drawai/raster.d.ts +0 -43
- package/lib/types/vendor/drawai/trace-image.d.ts +0 -257
package/package.json
CHANGED
|
@@ -1,139 +1,139 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "dsh-image-gen",
|
|
3
|
-
"version": "0.10.
|
|
4
|
-
"description": "Bring ChatGPT-like image generation to DeepSeek Harness — Gemini, OpenAI, Seedream, DashScope, local ComfyUI & more.",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"author": "shanliuling",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/shanliuling/dsh-image-gen.git"
|
|
10
|
-
},
|
|
11
|
-
"bugs": {
|
|
12
|
-
"url": "https://github.com/shanliuling/dsh-image-gen/issues"
|
|
13
|
-
},
|
|
14
|
-
"homepage": "https://github.com/shanliuling/dsh-image-gen#readme",
|
|
15
|
-
"main": "lib/index.js",
|
|
16
|
-
"types": "lib/types/index.d.ts",
|
|
17
|
-
"exports": {
|
|
18
|
-
".": {
|
|
19
|
-
"types": "./lib/types/index.d.ts",
|
|
20
|
-
"default": "./lib/index.js"
|
|
21
|
-
},
|
|
22
|
-
"./client": {
|
|
23
|
-
"types": "./lib/types/client/index.d.ts",
|
|
24
|
-
"default": "./lib/client.js"
|
|
25
|
-
},
|
|
26
|
-
"./package.json": "./package.json"
|
|
27
|
-
},
|
|
28
|
-
"files": [
|
|
29
|
-
"lib/index.js",
|
|
30
|
-
"lib/client.js",
|
|
31
|
-
"lib/types/**/*.d.ts",
|
|
32
|
-
"skills/**/*.md",
|
|
33
|
-
"cordis.patch.yml",
|
|
34
|
-
"README.md",
|
|
35
|
-
"README.en.md",
|
|
36
|
-
"docs/assets/readme/*.webp",
|
|
37
|
-
"LICENSE"
|
|
38
|
-
],
|
|
39
|
-
"dsh": {
|
|
40
|
-
"bundle": {
|
|
41
|
-
"patch": "./cordis.patch.yml"
|
|
42
|
-
},
|
|
43
|
-
"client": {
|
|
44
|
-
"inject": [
|
|
45
|
-
"@deepseek-ai/dsh-client-connection",
|
|
46
|
-
"@deepseek-ai/dsh-api-remotes",
|
|
47
|
-
"@deepseek-ai/dsh-client-ui-conversation",
|
|
48
|
-
"@deepseek-ai/dsh-client-ui-settings",
|
|
49
|
-
"@deepseek-ai/dsh-client-ui-settings-plugins",
|
|
50
|
-
"@deepseek-ai/dsh-client-ui-sidebar-right",
|
|
51
|
-
"@deepseek-ai/dsh-client-ui-tool",
|
|
52
|
-
"@deepseek-ai/dsh-client-locale"
|
|
53
|
-
],
|
|
54
|
-
"platform": "web"
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
"scripts": {
|
|
58
|
-
"typecheck": "tsc --noEmit",
|
|
59
|
-
"build": "tsc && tsdown",
|
|
60
|
-
"prepare": "pnpm run build",
|
|
61
|
-
"test": "vitest run",
|
|
62
|
-
"test:package": "node scripts/check-package.mjs",
|
|
63
|
-
"pack:check": "pnpm pack --dry-run"
|
|
64
|
-
},
|
|
65
|
-
"engines": {
|
|
66
|
-
"node": "^22.19.0 || >=24.0.0"
|
|
67
|
-
},
|
|
68
|
-
"license": "Apache-2.0",
|
|
69
|
-
"keywords": [
|
|
70
|
-
"deepseek",
|
|
71
|
-
"deepseek-harness",
|
|
72
|
-
"dsh",
|
|
73
|
-
"dsh-plugin",
|
|
74
|
-
"ai-agent",
|
|
75
|
-
"image-generation",
|
|
76
|
-
"ai-image-generation",
|
|
77
|
-
"multimodal",
|
|
78
|
-
"gemini",
|
|
79
|
-
"openai",
|
|
80
|
-
"openai-compatible",
|
|
81
|
-
"seedream",
|
|
82
|
-
"dashscope",
|
|
83
|
-
"comfyui",
|
|
84
|
-
"local-image-generation",
|
|
85
|
-
"wanx",
|
|
86
|
-
"aliyun",
|
|
87
|
-
"volcengine",
|
|
88
|
-
"byok",
|
|
89
|
-
"cordis"
|
|
90
|
-
],
|
|
91
|
-
"peerDependencies": {
|
|
92
|
-
"@deepseek-ai/cordis": ">=4.0.0 <5",
|
|
93
|
-
"@deepseek-ai/schemastery": ">=3.18.4 <4",
|
|
94
|
-
"react": ">=18.2.0 <19"
|
|
95
|
-
},
|
|
96
|
-
"peerDependenciesMeta": {
|
|
97
|
-
"@deepseek-ai/cordis": {
|
|
98
|
-
"optional": true
|
|
99
|
-
},
|
|
100
|
-
"@deepseek-ai/schemastery": {
|
|
101
|
-
"optional": true
|
|
102
|
-
},
|
|
103
|
-
"react": {
|
|
104
|
-
"optional": true
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
"devDependencies": {
|
|
108
|
-
"@deepseek-ai/cordis": "4.0.4",
|
|
109
|
-
"@deepseek-ai/dsh-agent": "0.1.7-rc.2",
|
|
110
|
-
"@deepseek-ai/dsh-api-remotes": "0.1.7-rc.2",
|
|
111
|
-
"@deepseek-ai/dsh-attachment": "0.1.7-rc.2",
|
|
112
|
-
"@deepseek-ai/dsh-client-connection": "0.1.7-rc.2",
|
|
113
|
-
"@deepseek-ai/dsh-client-ui-conversation": "0.1.7-rc.2",
|
|
114
|
-
"@deepseek-ai/dsh-client-ui-settings": "0.1.7-rc.2",
|
|
115
|
-
"@deepseek-ai/dsh-client-ui-settings-plugins": "0.1.7-rc.2",
|
|
116
|
-
"@deepseek-ai/dsh-client-ui-sidebar-right": "0.1.7-rc.2",
|
|
117
|
-
"@deepseek-ai/dsh-client-ui-slots": "0.1.7-rc.2",
|
|
118
|
-
"@deepseek-ai/dsh-client-ui-tool": "0.1.7-rc.2",
|
|
119
|
-
"@deepseek-ai/dsh-credentials": "0.1.7-rc.2",
|
|
120
|
-
"@deepseek-ai/dsh-host-webserver": "0.1.7-rc.2",
|
|
121
|
-
"@deepseek-ai/dsh-llm": "0.1.7-rc.2",
|
|
122
|
-
"@deepseek-ai/dsh-session": "0.1.7-rc.2",
|
|
123
|
-
"@deepseek-ai/dsh-settings": "0.1.7-rc.2",
|
|
124
|
-
"@deepseek-ai/dsh-tools": "0.1.7-rc.2",
|
|
125
|
-
"@deepseek-ai/dsh-workspace": "0.1.7-rc.2",
|
|
126
|
-
"@deepseek-ai/schemastery": "3.18.4",
|
|
127
|
-
"@types/node": "^22.20.0",
|
|
128
|
-
"@types/react": "~18.3.1",
|
|
129
|
-
"lucide-react": "^1.38.0",
|
|
130
|
-
"react": "^18.2.0",
|
|
131
|
-
"react-dom": "18.3.1",
|
|
132
|
-
"tldraw": "5.3.0",
|
|
133
|
-
"tsdown": "^0.22.2",
|
|
134
|
-
"typescript": "^6.0.3",
|
|
135
|
-
"unrun": "^0.3.1",
|
|
136
|
-
"vitest": "^4.1.8"
|
|
137
|
-
},
|
|
138
|
-
"packageManager": "pnpm@11.7.0"
|
|
139
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-image-gen",
|
|
3
|
+
"version": "0.10.3",
|
|
4
|
+
"description": "Bring ChatGPT-like image generation to DeepSeek Harness — Gemini, OpenAI, Seedream, DashScope, local ComfyUI & more.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"author": "shanliuling",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/shanliuling/dsh-image-gen.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/shanliuling/dsh-image-gen/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/shanliuling/dsh-image-gen#readme",
|
|
15
|
+
"main": "lib/index.js",
|
|
16
|
+
"types": "lib/types/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./lib/types/index.d.ts",
|
|
20
|
+
"default": "./lib/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./client": {
|
|
23
|
+
"types": "./lib/types/client/index.d.ts",
|
|
24
|
+
"default": "./lib/client.js"
|
|
25
|
+
},
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"lib/index.js",
|
|
30
|
+
"lib/client.js",
|
|
31
|
+
"lib/types/**/*.d.ts",
|
|
32
|
+
"skills/**/*.md",
|
|
33
|
+
"cordis.patch.yml",
|
|
34
|
+
"README.md",
|
|
35
|
+
"README.en.md",
|
|
36
|
+
"docs/assets/readme/*.webp",
|
|
37
|
+
"LICENSE"
|
|
38
|
+
],
|
|
39
|
+
"dsh": {
|
|
40
|
+
"bundle": {
|
|
41
|
+
"patch": "./cordis.patch.yml"
|
|
42
|
+
},
|
|
43
|
+
"client": {
|
|
44
|
+
"inject": [
|
|
45
|
+
"@deepseek-ai/dsh-client-connection",
|
|
46
|
+
"@deepseek-ai/dsh-api-remotes",
|
|
47
|
+
"@deepseek-ai/dsh-client-ui-conversation",
|
|
48
|
+
"@deepseek-ai/dsh-client-ui-settings",
|
|
49
|
+
"@deepseek-ai/dsh-client-ui-settings-plugins",
|
|
50
|
+
"@deepseek-ai/dsh-client-ui-sidebar-right",
|
|
51
|
+
"@deepseek-ai/dsh-client-ui-tool",
|
|
52
|
+
"@deepseek-ai/dsh-client-locale"
|
|
53
|
+
],
|
|
54
|
+
"platform": "web"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"scripts": {
|
|
58
|
+
"typecheck": "tsc --noEmit",
|
|
59
|
+
"build": "node scripts/clean-lib.mjs && tsc && tsdown",
|
|
60
|
+
"prepare": "pnpm run build",
|
|
61
|
+
"test": "vitest run",
|
|
62
|
+
"test:package": "node scripts/check-package.mjs",
|
|
63
|
+
"pack:check": "pnpm pack --dry-run"
|
|
64
|
+
},
|
|
65
|
+
"engines": {
|
|
66
|
+
"node": "^22.19.0 || >=24.0.0"
|
|
67
|
+
},
|
|
68
|
+
"license": "Apache-2.0",
|
|
69
|
+
"keywords": [
|
|
70
|
+
"deepseek",
|
|
71
|
+
"deepseek-harness",
|
|
72
|
+
"dsh",
|
|
73
|
+
"dsh-plugin",
|
|
74
|
+
"ai-agent",
|
|
75
|
+
"image-generation",
|
|
76
|
+
"ai-image-generation",
|
|
77
|
+
"multimodal",
|
|
78
|
+
"gemini",
|
|
79
|
+
"openai",
|
|
80
|
+
"openai-compatible",
|
|
81
|
+
"seedream",
|
|
82
|
+
"dashscope",
|
|
83
|
+
"comfyui",
|
|
84
|
+
"local-image-generation",
|
|
85
|
+
"wanx",
|
|
86
|
+
"aliyun",
|
|
87
|
+
"volcengine",
|
|
88
|
+
"byok",
|
|
89
|
+
"cordis"
|
|
90
|
+
],
|
|
91
|
+
"peerDependencies": {
|
|
92
|
+
"@deepseek-ai/cordis": ">=4.0.0 <5",
|
|
93
|
+
"@deepseek-ai/schemastery": ">=3.18.4 <4",
|
|
94
|
+
"react": ">=18.2.0 <19"
|
|
95
|
+
},
|
|
96
|
+
"peerDependenciesMeta": {
|
|
97
|
+
"@deepseek-ai/cordis": {
|
|
98
|
+
"optional": true
|
|
99
|
+
},
|
|
100
|
+
"@deepseek-ai/schemastery": {
|
|
101
|
+
"optional": true
|
|
102
|
+
},
|
|
103
|
+
"react": {
|
|
104
|
+
"optional": true
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"devDependencies": {
|
|
108
|
+
"@deepseek-ai/cordis": "4.0.4",
|
|
109
|
+
"@deepseek-ai/dsh-agent": "0.1.7-rc.2",
|
|
110
|
+
"@deepseek-ai/dsh-api-remotes": "0.1.7-rc.2",
|
|
111
|
+
"@deepseek-ai/dsh-attachment": "0.1.7-rc.2",
|
|
112
|
+
"@deepseek-ai/dsh-client-connection": "0.1.7-rc.2",
|
|
113
|
+
"@deepseek-ai/dsh-client-ui-conversation": "0.1.7-rc.2",
|
|
114
|
+
"@deepseek-ai/dsh-client-ui-settings": "0.1.7-rc.2",
|
|
115
|
+
"@deepseek-ai/dsh-client-ui-settings-plugins": "0.1.7-rc.2",
|
|
116
|
+
"@deepseek-ai/dsh-client-ui-sidebar-right": "0.1.7-rc.2",
|
|
117
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.1.7-rc.2",
|
|
118
|
+
"@deepseek-ai/dsh-client-ui-tool": "0.1.7-rc.2",
|
|
119
|
+
"@deepseek-ai/dsh-credentials": "0.1.7-rc.2",
|
|
120
|
+
"@deepseek-ai/dsh-host-webserver": "0.1.7-rc.2",
|
|
121
|
+
"@deepseek-ai/dsh-llm": "0.1.7-rc.2",
|
|
122
|
+
"@deepseek-ai/dsh-session": "0.1.7-rc.2",
|
|
123
|
+
"@deepseek-ai/dsh-settings": "0.1.7-rc.2",
|
|
124
|
+
"@deepseek-ai/dsh-tools": "0.1.7-rc.2",
|
|
125
|
+
"@deepseek-ai/dsh-workspace": "0.1.7-rc.2",
|
|
126
|
+
"@deepseek-ai/schemastery": "3.18.4",
|
|
127
|
+
"@types/node": "^22.20.0",
|
|
128
|
+
"@types/react": "~18.3.1",
|
|
129
|
+
"lucide-react": "^1.38.0",
|
|
130
|
+
"react": "^18.2.0",
|
|
131
|
+
"react-dom": "18.3.1",
|
|
132
|
+
"tldraw": "5.3.0",
|
|
133
|
+
"tsdown": "^0.22.2",
|
|
134
|
+
"typescript": "^6.0.3",
|
|
135
|
+
"unrun": "^0.3.1",
|
|
136
|
+
"vitest": "^4.1.8"
|
|
137
|
+
},
|
|
138
|
+
"packageManager": "pnpm@11.7.0"
|
|
139
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: install-dsh-image-gen
|
|
3
|
-
description: Install, configure, verify, or remove the dsh-image-gen Bundle in a DeepSeek Harness Web profile. Use when a user wants Google, OpenAI-compatible relay, Seedream, DashScope, or local ComfyUI image generation in DSH, cannot find the Image generation settings card, or needs help testing generate_image.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Install DSH Image Gen
|
|
7
|
-
|
|
8
|
-
1. Confirm `dsh` runs and record `dsh --version`.
|
|
9
|
-
2. Ask which Web profile to change if the user did not name one. Default to `web` only when that profile already exists.
|
|
10
|
-
3. Install the pinned package or repository spec the user provides:
|
|
11
|
-
|
|
12
|
-
```sh
|
|
13
|
-
dsh plugin --profile <profile> add <package-or-git-spec>
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
4. If pnpm blocks the Git dependency's `prepare` script, explain that the allowance executes repository code during installation. Add only the exact package key pnpm reports to the profile's `pnpm-workspace.yaml`, then retry after the user approves.
|
|
17
|
-
5. Verify `dsh --profile <profile> --dump-config` contains the `dsh-image-gen` layer and `image-gen` row.
|
|
18
|
-
6. Start the profile. If port 3080 is already in use, identify the existing DSH process before stopping anything.
|
|
19
|
-
7. Open the Plugins panel from the left sidebar, click dsh-image-gen under Installed, and configure Providers on the plugin's detail page (DSH 0.1.5 and earlier: Settings > Plugins > Plugin Configuration > Image generation). Select a cloud Provider and save its API key, or select Local ComfyUI, enter its URL, and import a ComfyUI API Format workflow JSON containing `{{prompt}}`. Never print, read back, or commit a key.
|
|
20
|
-
8. Test with “生成一张戴墨镜的赛博朋克猫图片”. Confirm one `generate_image` call succeeds and its image renders in the conversation.
|
|
21
|
-
|
|
22
|
-
For removal, run `dsh plugin --profile <profile> remove dsh-image-gen`. Do not delete the user's credentials unless they explicitly request it.
|
|
1
|
+
---
|
|
2
|
+
name: install-dsh-image-gen
|
|
3
|
+
description: Install, configure, verify, or remove the dsh-image-gen Bundle in a DeepSeek Harness Web profile. Use when a user wants Google, OpenAI-compatible relay, Seedream, DashScope, or local ComfyUI image generation in DSH, cannot find the Image generation settings card, or needs help testing generate_image.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Install DSH Image Gen
|
|
7
|
+
|
|
8
|
+
1. Confirm `dsh` runs and record `dsh --version`.
|
|
9
|
+
2. Ask which Web profile to change if the user did not name one. Default to `web` only when that profile already exists.
|
|
10
|
+
3. Install the pinned package or repository spec the user provides:
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
dsh plugin --profile <profile> add <package-or-git-spec>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
4. If pnpm blocks the Git dependency's `prepare` script, explain that the allowance executes repository code during installation. Add only the exact package key pnpm reports to the profile's `pnpm-workspace.yaml`, then retry after the user approves.
|
|
17
|
+
5. Verify `dsh --profile <profile> --dump-config` contains the `dsh-image-gen` layer and `image-gen` row.
|
|
18
|
+
6. Start the profile. If port 3080 is already in use, identify the existing DSH process before stopping anything.
|
|
19
|
+
7. Open the Plugins panel from the left sidebar, click dsh-image-gen under Installed, and configure Providers on the plugin's detail page (DSH 0.1.5 and earlier: Settings > Plugins > Plugin Configuration > Image generation). Select a cloud Provider and save its API key, or select Local ComfyUI, enter its URL, and import a ComfyUI API Format workflow JSON containing `{{prompt}}`. Never print, read back, or commit a key.
|
|
20
|
+
8. Test with “生成一张戴墨镜的赛博朋克猫图片”. Confirm one `generate_image` call succeeds and its image renders in the conversation.
|
|
21
|
+
|
|
22
|
+
For removal, run `dsh plugin --profile <profile> remove dsh-image-gen`. Do not delete the user's credentials unless they explicitly request it.
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Delivery of a drawing plan to the workbench canvases.
|
|
3
|
-
*
|
|
4
|
-
* The `draw_reference` tool cannot put path data inline: the plan is tens of
|
|
5
|
-
* kilobytes and the conversation is persisted, so the tool result carries only
|
|
6
|
-
* a `traceId` (see presentationMeta) and this bridge hands that id to whichever
|
|
7
|
-
* canvas is mounted. The canvas then fetches the plan from the trace-plan route
|
|
8
|
-
* and plays it.
|
|
9
|
-
*
|
|
10
|
-
* A trace that arrives while no canvas is mounted is held, not dropped: the
|
|
11
|
-
* canvas surfaces are tab-scoped and unmount when the user looks elsewhere, so
|
|
12
|
-
* dropping on absence would mean the drawing only ever plays if the user
|
|
13
|
-
* happened to be staring at the infinite canvas at that exact second. The
|
|
14
|
-
* queue holds the newest trace only — a drawing is a one-shot show, and an
|
|
15
|
-
* older plan is stale by the time a newer one exists.
|
|
16
|
-
*/
|
|
17
|
-
/** The identifying part of a trace result, as it arrives on a tool event. */
|
|
18
|
-
export interface TlTraceItem {
|
|
19
|
-
traceId: string;
|
|
20
|
-
/** Source pixel size, for the overlay's initial aspect box. */
|
|
21
|
-
sourceWidth: number;
|
|
22
|
-
sourceHeight: number;
|
|
23
|
-
/** Region count, for the "N blocks" caption. */
|
|
24
|
-
steps: number;
|
|
25
|
-
}
|
|
26
|
-
type TlTraceConsumer = (item: TlTraceItem) => void;
|
|
27
|
-
/** Whether any canvas is mounted to play a plan. */
|
|
28
|
-
export declare function hasTlTraceConsumer(): boolean;
|
|
29
|
-
/** The trace waiting for a canvas, if any. */
|
|
30
|
-
export declare function pendingTlTrace(): TlTraceItem | null;
|
|
31
|
-
/**
|
|
32
|
-
* Register a canvas surface; returns its disposer. A trace that arrived while
|
|
33
|
-
* nothing was mounted plays immediately, so opening the canvas after asking
|
|
34
|
-
* for a drawing still shows it.
|
|
35
|
-
*/
|
|
36
|
-
export declare function registerTlTraceConsumer(consumer: TlTraceConsumer): () => void;
|
|
37
|
-
/** Hand a plan to every mounted canvas, or hold the newest one until one is. */
|
|
38
|
-
export declare function pushTlTrace(item: TlTraceItem): void;
|
|
39
|
-
/** Test seam: clear every consumer and the pending slot. */
|
|
40
|
-
export declare function resetTlTraceBridge(): void;
|
|
41
|
-
/**
|
|
42
|
-
* Parse the plugin-owned trace metadata off a Tool result. Returns undefined
|
|
43
|
-
* for anything that is not a draw_reference result, so callers can share one
|
|
44
|
-
* event subscription with the image landings.
|
|
45
|
-
*/
|
|
46
|
-
export declare function traceResultFromMeta(value: unknown): TlTraceItem | undefined;
|
|
47
|
-
/**
|
|
48
|
-
* Recover a trace from a `tool/ptc-dispatch` event, when the model called
|
|
49
|
-
* draw_reference through run_code instead of directly.
|
|
50
|
-
*/
|
|
51
|
-
export declare function traceResultFromPtcDispatch(event: {
|
|
52
|
-
readonly type: string;
|
|
53
|
-
readonly data: Record<string, unknown>;
|
|
54
|
-
}): TlTraceItem | undefined;
|
|
55
|
-
export {};
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import type { Editor } from 'tldraw';
|
|
2
|
-
import type { ImageAttachmentRef } from '@deepseek-ai/dsh-attachment';
|
|
3
|
-
interface TraceStep {
|
|
4
|
-
layer: number;
|
|
5
|
-
d: string;
|
|
6
|
-
area: number;
|
|
7
|
-
}
|
|
8
|
-
interface TracePlan {
|
|
9
|
-
viewBox: [number, number, number, number];
|
|
10
|
-
fills: string[];
|
|
11
|
-
steps: TraceStep[];
|
|
12
|
-
}
|
|
13
|
-
export interface CanvasTraceProps {
|
|
14
|
-
editor: Editor;
|
|
15
|
-
traceId: string;
|
|
16
|
-
/** Region count reported by the tool, shown before the plan arrives. */
|
|
17
|
-
steps: number;
|
|
18
|
-
/**
|
|
19
|
-
* The absolutely-positioned host the surface is rendered into. Its rect is
|
|
20
|
-
* the origin this component must subtract from tldraw's window-relative
|
|
21
|
-
* screen coordinates.
|
|
22
|
-
*/
|
|
23
|
-
hostRef?: {
|
|
24
|
-
readonly current: HTMLDivElement | null;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Receives the finished drawing as a rail image plus the page rectangle it
|
|
28
|
-
* was drawn in, so the canvas can place it exactly where the playback was.
|
|
29
|
-
*/
|
|
30
|
-
onLand?: ((attachment: ImageAttachmentRef, placement: {
|
|
31
|
-
x: number;
|
|
32
|
-
y: number;
|
|
33
|
-
w: number;
|
|
34
|
-
h: number;
|
|
35
|
-
}) => void | Promise<void>) | undefined;
|
|
36
|
-
onClose: () => void;
|
|
37
|
-
lang?: 'zh' | 'en';
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Revealed region count at elapsed time `t`. Squaring the normalised time
|
|
41
|
-
* gives the first (largest) regions most of the screen time and then speeds up
|
|
42
|
-
* through the tiny ones, which is the same curve the drawai workbench uses.
|
|
43
|
-
*/
|
|
44
|
-
export declare function traceRevealCount(total: number, elapsedMs: number, durationMs: number): number;
|
|
45
|
-
/** Total playback time for a plan: short plans stay readable, long ones stay bounded. */
|
|
46
|
-
export declare function tracePlaybackDuration(total: number): number;
|
|
47
|
-
/** Paint order prefix: the first `count` steps accumulated per colour layer. */
|
|
48
|
-
export declare function traceLayerPaths(plan: TracePlan, count: number): string[];
|
|
49
|
-
/** Rebuild the finished SVG document from the plan, for download. */
|
|
50
|
-
export declare function tracePlanToSvg(plan: TracePlan): string;
|
|
51
|
-
/**
|
|
52
|
-
* Draw the finished SVG into a canvas and encode it as PNG.
|
|
53
|
-
*
|
|
54
|
-
* SVG reaches the document as a bitmap because tldraw's image shapes render
|
|
55
|
-
* through `<img>`, where an SVG with only a viewBox has no intrinsic size and
|
|
56
|
-
* collapses to the 300x150 default. Width and height are injected for the same
|
|
57
|
-
* reason: without them the browser has nothing to scale from.
|
|
58
|
-
*/
|
|
59
|
-
export declare function rasterizeSvg(svg: string, width: number, height: number): Promise<Blob>;
|
|
60
|
-
/** Upload rasterised bytes as a durable attachment so the canvas can land them. */
|
|
61
|
-
export declare function uploadDrawing(blob: Blob, name: string): Promise<ImageAttachmentRef>;
|
|
62
|
-
/** Rasterise one plan at a bounded resolution, then store it as an attachment. */
|
|
63
|
-
export declare function realizeDrawing(plan: TracePlan, name: string): Promise<ImageAttachmentRef>;
|
|
64
|
-
/** Page-space rectangle the drawing occupies, frozen when the trace starts. */
|
|
65
|
-
export interface TraceAnchor {
|
|
66
|
-
x: number;
|
|
67
|
-
y: number;
|
|
68
|
-
w: number;
|
|
69
|
-
h: number;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Pick the page rectangle for a drawing of `aspect` (w/h): centred on what the
|
|
73
|
-
* user is looking at right now, at 72% of the viewport. Frozen in page space so
|
|
74
|
-
* later panning and zooming move it like canvas content instead of resizing it
|
|
75
|
-
* to the window.
|
|
76
|
-
*/
|
|
77
|
-
export declare function anchorTraceInViewport(viewport: {
|
|
78
|
-
center: {
|
|
79
|
-
x: number;
|
|
80
|
-
y: number;
|
|
81
|
-
};
|
|
82
|
-
w: number;
|
|
83
|
-
h: number;
|
|
84
|
-
}, aspect: number): TraceAnchor;
|
|
85
|
-
export declare function CanvasTrace({ editor, traceId, steps, hostRef, onLand, onClose, lang }: CanvasTraceProps): import("react").JSX.Element;
|
|
86
|
-
/**
|
|
87
|
-
* Map a page rectangle into the surface's own coordinate space.
|
|
88
|
-
*
|
|
89
|
-
* tldraw's screen space is window-relative (`pageToScreen` returns client
|
|
90
|
-
* coordinates, which is why collaborator cursors need no offset), while the
|
|
91
|
-
* surface is an absolutely positioned child of the canvas host. Subtracting the
|
|
92
|
-
* host's own rect is what turns one into the other; without it the drawing is
|
|
93
|
-
* pushed off the panel and clipped.
|
|
94
|
-
*/
|
|
95
|
-
export declare function projectAnchor(editor: Editor, anchor: TraceAnchor, host: HTMLElement | null): {
|
|
96
|
-
left: number;
|
|
97
|
-
top: number;
|
|
98
|
-
width: number;
|
|
99
|
-
height: number;
|
|
100
|
-
};
|
|
101
|
-
export {};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/** Named trace styles exposed by the tool. */
|
|
2
|
-
export declare const TRACE_PRESET_NAMES: readonly ["default", "lineart", "photo", "simple"];
|
|
3
|
-
export type TracePresetName = (typeof TRACE_PRESET_NAMES)[number];
|
|
4
|
-
/** Fragment density tiers, mirroring the workbench's three calibrated档. */
|
|
5
|
-
export declare const TRACE_FRAGMENT_NAMES: readonly ["low", "medium", "high"];
|
|
6
|
-
export type TraceFragments = (typeof TRACE_FRAGMENT_NAMES)[number];
|
|
7
|
-
/** One connected region of one colour: a self-contained path plus its area. */
|
|
8
|
-
export interface TraceDrawingStep {
|
|
9
|
-
/** Index into `fills`; steps sharing a layer share a fill colour. */
|
|
10
|
-
layer: number;
|
|
11
|
-
/** SVG path data for this region, including its holes (nonzero winding). */
|
|
12
|
-
d: string;
|
|
13
|
-
/** Signed pixel area used for ordering; steps arrive largest first. */
|
|
14
|
-
area: number;
|
|
15
|
-
}
|
|
16
|
-
/** The replayable drawing: paint `steps` in order, grouped by `fills`. */
|
|
17
|
-
export interface TraceDrawingPlan {
|
|
18
|
-
viewBox: [number, number, number, number];
|
|
19
|
-
fills: string[];
|
|
20
|
-
steps: TraceDrawingStep[];
|
|
21
|
-
}
|
|
22
|
-
/** Numbers the model gets instead of the path data. */
|
|
23
|
-
export interface TraceSummary {
|
|
24
|
-
width: number;
|
|
25
|
-
height: number;
|
|
26
|
-
colors: number;
|
|
27
|
-
paths: number;
|
|
28
|
-
loops: number;
|
|
29
|
-
steps: number;
|
|
30
|
-
svgChars: number;
|
|
31
|
-
budget: number;
|
|
32
|
-
attempts: number;
|
|
33
|
-
drawnPixels: number | null;
|
|
34
|
-
exactPixelCoverage: boolean;
|
|
35
|
-
sourceWidth: number;
|
|
36
|
-
sourceHeight: number;
|
|
37
|
-
}
|
|
38
|
-
/** Everything one trace produces. */
|
|
39
|
-
export interface TraceOutcome {
|
|
40
|
-
/** Full SVG document, for export — never sent to the model verbatim. */
|
|
41
|
-
svg: string;
|
|
42
|
-
plan: TraceDrawingPlan;
|
|
43
|
-
/**
|
|
44
|
-
* Optional pencil pass derived from the same source, played before `plan`.
|
|
45
|
-
* Null when the caller asked for no sketch or the edge pass found nothing.
|
|
46
|
-
*/
|
|
47
|
-
sketch: TraceDrawingPlan | null;
|
|
48
|
-
summary: TraceSummary;
|
|
49
|
-
/** One-line tuning advice from upstream's own heuristics. */
|
|
50
|
-
hint: string;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* One complete drawing session: the contour pass an illustrator starts with,
|
|
54
|
-
* then the colour pass that fills it in.
|
|
55
|
-
*/
|
|
56
|
-
export interface TraceShow {
|
|
57
|
-
sketch?: TraceDrawingPlan;
|
|
58
|
-
colour: TraceDrawingPlan;
|
|
59
|
-
}
|
|
60
|
-
/** Trace knobs shared by the decoded-pixels and encoded-bytes entry points. */
|
|
61
|
-
export interface TraceOptions {
|
|
62
|
-
/** Required: keep or drop the background. There is no automatic answer. */
|
|
63
|
-
removeBg: boolean;
|
|
64
|
-
preset?: TracePresetName;
|
|
65
|
-
fragments?: TraceFragments;
|
|
66
|
-
/** Palette size, 2–24. Also caps the number of visible colour layers. */
|
|
67
|
-
colors?: number;
|
|
68
|
-
/** RDP tolerance in work pixels; lower keeps more contour fidelity. */
|
|
69
|
-
epsilon?: number;
|
|
70
|
-
/** Regions under this area are merged into a neighbour. */
|
|
71
|
-
minArea?: number;
|
|
72
|
-
/** Long side cap for the work image; defaults to the calibrated 887. */
|
|
73
|
-
maxLongSide?: number;
|
|
74
|
-
/** SVG character budget; upstream default is 248000. */
|
|
75
|
-
budget?: number;
|
|
76
|
-
/** Derive a pencil sketch to play first; defaults to true. */
|
|
77
|
-
sketch?: boolean;
|
|
78
|
-
}
|
|
79
|
-
/** One trace over an encoded image. */
|
|
80
|
-
export interface TraceRequest extends TraceOptions {
|
|
81
|
-
/** Encoded image bytes (PNG is dependency free; JPEG/WebP need sharp). */
|
|
82
|
-
bytes: Uint8Array;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Trace an encoded raster into an SVG plus its replayable drawing plan.
|
|
86
|
-
* @param request - image bytes and trace knobs.
|
|
87
|
-
* @returns the SVG, the ordered plan, a model-facing summary and a tuning hint.
|
|
88
|
-
*/
|
|
89
|
-
export declare function traceImageToDrawing(request: TraceRequest): Promise<TraceOutcome>;
|
|
90
|
-
/**
|
|
91
|
-
* Trace an already-decoded RGBA8 raster. Split out from `traceImageToDrawing`
|
|
92
|
-
* so tests can exercise the pipeline without encoding a PNG first.
|
|
93
|
-
*
|
|
94
|
-
* Produces the colour pass plus, unless disabled, a pencil pass derived from
|
|
95
|
-
* the same pixels. The sketch is best-effort: a picture with no edges worth
|
|
96
|
-
* drawing simply plays the colour pass alone.
|
|
97
|
-
*/
|
|
98
|
-
export declare function traceRasterToDrawing(raster: {
|
|
99
|
-
width: number;
|
|
100
|
-
height: number;
|
|
101
|
-
data: Uint8Array;
|
|
102
|
-
}, options: TraceOptions): TraceOutcome;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/** Read-only route that hands one stored trace plan to the canvas. */
|
|
2
|
-
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
|
-
import type { TracePlanStore } from './trace-store.js';
|
|
4
|
-
export interface TraceRouteDeps {
|
|
5
|
-
store: TracePlanStore;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Serve one drawing plan by id. GET only: the plan is produced by the
|
|
9
|
-
* `draw_reference` tool and never written from the browser, so there is
|
|
10
|
-
* nothing to accept here.
|
|
11
|
-
*/
|
|
12
|
-
export declare function serveTracePlan(req: IncomingMessage, res: ServerResponse, deps: TraceRouteDeps): Promise<void>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Derive a pencil-sketch raster from a reference image.
|
|
3
|
-
*
|
|
4
|
-
* The tracer can only reproduce what is in the pixels, so "先起稿再上色" needs
|
|
5
|
-
* an actual contour drawing to reproduce. Spending a model call on one would be
|
|
6
|
-
* slow, non-deterministic and — for a picture the model has already been given
|
|
7
|
-
* — redundant. Derive it locally instead: grayscale, Sobel magnitude, an
|
|
8
|
-
* adaptive threshold, then a one-pixel dilation so the lines survive the
|
|
9
|
-
* downsampling the tracer does internally.
|
|
10
|
-
*
|
|
11
|
-
* The result is a black-on-white line drawing: the contour pass an illustrator
|
|
12
|
-
* makes before blocking in colour.
|
|
13
|
-
*/
|
|
14
|
-
/** RGBA8 bitmap, the same shape the tracer consumes. */
|
|
15
|
-
export interface SketchRaster {
|
|
16
|
-
width: number;
|
|
17
|
-
height: number;
|
|
18
|
-
data: Uint8Array;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Build a line drawing from a raster.
|
|
22
|
-
* @param raster - source pixels (RGBA8).
|
|
23
|
-
* @param maxSide - long side to compute the edges at; defaults to 1200.
|
|
24
|
-
* @returns a black-on-white RGBA8 bitmap of the detected contours.
|
|
25
|
-
*/
|
|
26
|
-
export declare function sketchRaster(raster: SketchRaster, maxSide?: number): SketchRaster;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { TraceShow } from './trace-drawing.js';
|
|
2
|
-
export interface TracePlanStoreOptions {
|
|
3
|
-
/** Directory for restart-surviving copies; omit to stay memory-only. */
|
|
4
|
-
dir?: string | undefined;
|
|
5
|
-
}
|
|
6
|
-
export declare class TracePlanStore {
|
|
7
|
-
private readonly entries;
|
|
8
|
-
private readonly dir;
|
|
9
|
-
constructor(options?: TracePlanStoreOptions);
|
|
10
|
-
/** Store one show and return the id the browser will use. */
|
|
11
|
-
put(show: TraceShow): Promise<string>;
|
|
12
|
-
/** The show behind an id: memory first, then the disk copy, else undefined. */
|
|
13
|
-
get(id: string): Promise<TraceShow | undefined>;
|
|
14
|
-
/** Write the disk copy; failures are logged and otherwise ignored. */
|
|
15
|
-
private persist;
|
|
16
|
-
/** Read one disk copy, dropping it when expired or malformed. */
|
|
17
|
-
private read;
|
|
18
|
-
private remove;
|
|
19
|
-
/** Drop expired entries, then the oldest ones past the cap, in memory and on disk. */
|
|
20
|
-
private evict;
|
|
21
|
-
/** Delete disk copies left behind by a previous host process. */
|
|
22
|
-
private evictDisk;
|
|
23
|
-
}
|