dsh-image-gen 0.1.6 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +171 -166
- package/README.md +187 -169
- package/README.zh-CN.md +171 -169
- package/lib/client.js +80 -1
- package/lib/client.js.map +1 -1
- package/lib/index.js +799 -192
- package/lib/types/client/index.d.ts +2 -0
- package/lib/types/config.d.ts +6 -0
- package/lib/types/dashscope.d.ts +12 -3
- package/lib/types/google.d.ts +14 -3
- package/lib/types/index.d.ts +0 -3
- package/lib/types/openai-compatible.d.ts +15 -3
- package/lib/types/reference-image.d.ts +38 -0
- package/lib/types/seedream.d.ts +17 -0
- package/lib/types/shared.d.ts +1 -1
- package/lib/types/workspace-save.d.ts +52 -0
- package/package.json +37 -34
package/README.zh-CN.md
CHANGED
|
@@ -1,169 +1,171 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
|
|
3
|
-
<img src="docs/assets/hero-poster.webp" alt="dsh-image-gen 宣传海报" width="100%" style="max-width: 860px; border-radius: 12px;" />
|
|
4
|
-
|
|
5
|
-
<br /><br />
|
|
6
|
-
|
|
7
|
-
# 🎨 dsh-image-gen
|
|
8
|
-
|
|
9
|
-
**让 DeepSeek Harness 像 ChatGPT 一样在对话中直接生成图片,支持画廊汇总,全屏预览、快捷复制与一键下载。**
|
|
10
|
-
|
|
11
|
-
[](https://www.npmjs.com/package/dsh-image-gen)
|
|
12
|
-
[](https://github.com/deepseek-ai)
|
|
13
|
-
[](https://www.npmjs.com/package/dsh-image-gen)
|
|
14
|
-
[](LICENSE)
|
|
15
|
-
|
|
16
|
-
[English](README.en.md) | **简体中文**
|
|
17
|
-
|
|
18
|
-
<br />
|
|
19
|
-
|
|
20
|
-
<p align="center">💬 <b>直接对你的 DeepSeek Harness Agent 发送以下提示词:</b></p>
|
|
21
|
-
|
|
22
|
-
```text
|
|
23
|
-
帮我安装生图插件,执行命令:pnpm dsh plugin --profile web add dsh-image-gen@latest
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
<p align="center"><sub>(也可以手动在终端执行:<code>pnpm dsh plugin --profile web add dsh-image-gen@latest</code>)</sub></p>
|
|
27
|
-
|
|
28
|
-
<br />
|
|
29
|
-
|
|
30
|
-
<p align="center">安装完成后,在 DSH 设置中填入自己的 API Key,就可以直接对 Agent 说:</p>
|
|
31
|
-
|
|
32
|
-
```text
|
|
33
|
-
帮我画一张雨夜霓虹街头的赛博朋克猫咪。
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
<p align="center">Agent 会自动调用 <code>generate_image</code>,生成图片并直接显示在当前对话中。</p>
|
|
37
|
-
|
|
38
|
-
<br />
|
|
39
|
-
|
|
40
|
-
<img src="docs/assets/chat-preview.png" alt="对话生图效果预览" width="820" />
|
|
41
|
-
|
|
42
|
-
</div>
|
|
43
|
-
|
|
44
|
-
---
|
|
45
|
-
|
|
46
|
-
## 💡 它解决什么问题?
|
|
47
|
-
|
|
48
|
-
**`dsh-image-gen` 是专为 DeepSeek Harness (DSH) 打造的开源图像生成插件。**
|
|
49
|
-
|
|
50
|
-
DeepSeek Harness 已经可以让 Agent 调用不同工具完成任务,本项目为它补上了原生的**多模态生图能力**:
|
|
51
|
-
|
|
52
|
-
```mermaid
|
|
53
|
-
graph LR
|
|
54
|
-
A[用户 Prompt] --> B[DeepSeek Harness Agent]
|
|
55
|
-
B --> C[generate_image 工具]
|
|
56
|
-
C --> D[Gemini / OpenAI / Seedream / DashScope]
|
|
57
|
-
D --> E[图片数据]
|
|
58
|
-
E --> F[当前 Conversation 对话流]
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
---
|
|
62
|
-
|
|
63
|
-
## 🚀 快速安装与使用
|
|
64
|
-
|
|
65
|
-
### 1. 安装插件
|
|
66
|
-
|
|
67
|
-
在你的 DeepSeek Harness 项目根目录下运行:
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
# 推荐方式:安装或升级到最新版本
|
|
71
|
-
pnpm dsh plugin --profile web add dsh-image-gen@latest
|
|
72
|
-
|
|
73
|
-
# 若已将 dsh 安装为系统全局命令:
|
|
74
|
-
dsh plugin --profile web add dsh-image-gen@latest
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
<details>
|
|
78
|
-
<summary><b>🛠️ 其他安装方式(Git 仓库直装 / 本地调试)</b></summary>
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
# 方式 B:从 GitHub 仓库直接安装最新代码
|
|
82
|
-
pnpm dsh plugin --profile web add git+https://github.com/shanliuling/dsh-image-gen.git
|
|
83
|
-
|
|
84
|
-
# 方式 C:本地克隆源码开发安装
|
|
85
|
-
git clone https://github.com/shanliuling/dsh-image-gen.git
|
|
86
|
-
pnpm dsh plugin --profile web add ./dsh-image-gen
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
</details>
|
|
90
|
-
|
|
91
|
-
### 2. 配置 API Key
|
|
92
|
-
|
|
93
|
-
打开 DSH Web 页面(默认 `http://localhost:3080`):
|
|
94
|
-
|
|
95
|
-
1. 进入 **Settings → Plugins → Image generation**。
|
|
96
|
-
2. 选择 Provider,填写 API Key
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
-
|
|
126
|
-
-
|
|
127
|
-
-
|
|
128
|
-
-
|
|
129
|
-
-
|
|
130
|
-
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
|
139
|
-
|
|
|
140
|
-
| **
|
|
141
|
-
| **
|
|
142
|
-
| **
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
pnpm
|
|
157
|
-
pnpm run
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<img src="docs/assets/hero-poster.webp" alt="dsh-image-gen 宣传海报" width="100%" style="max-width: 860px; border-radius: 12px;" />
|
|
4
|
+
|
|
5
|
+
<br /><br />
|
|
6
|
+
|
|
7
|
+
# 🎨 dsh-image-gen
|
|
8
|
+
|
|
9
|
+
**让 DeepSeek Harness 像 ChatGPT 一样在对话中直接生成图片,支持画廊汇总,全屏预览、快捷复制与一键下载。**
|
|
10
|
+
|
|
11
|
+
[](https://www.npmjs.com/package/dsh-image-gen)
|
|
12
|
+
[](https://github.com/deepseek-ai)
|
|
13
|
+
[](https://www.npmjs.com/package/dsh-image-gen)
|
|
14
|
+
[](LICENSE)
|
|
15
|
+
|
|
16
|
+
[English](README.en.md) | **简体中文**
|
|
17
|
+
|
|
18
|
+
<br />
|
|
19
|
+
|
|
20
|
+
<p align="center">💬 <b>直接对你的 DeepSeek Harness Agent 发送以下提示词:</b></p>
|
|
21
|
+
|
|
22
|
+
```text
|
|
23
|
+
帮我安装生图插件,执行命令:pnpm dsh plugin --profile web add dsh-image-gen@latest
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
<p align="center"><sub>(也可以手动在终端执行:<code>pnpm dsh plugin --profile web add dsh-image-gen@latest</code>)</sub></p>
|
|
27
|
+
|
|
28
|
+
<br />
|
|
29
|
+
|
|
30
|
+
<p align="center">安装完成后,在 DSH 设置中填入自己的 API Key,就可以直接对 Agent 说:</p>
|
|
31
|
+
|
|
32
|
+
```text
|
|
33
|
+
帮我画一张雨夜霓虹街头的赛博朋克猫咪。
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
<p align="center">Agent 会自动调用 <code>generate_image</code>,生成图片并直接显示在当前对话中。</p>
|
|
37
|
+
|
|
38
|
+
<br />
|
|
39
|
+
|
|
40
|
+
<img src="docs/assets/chat-preview.png" alt="对话生图效果预览" width="820" />
|
|
41
|
+
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## 💡 它解决什么问题?
|
|
47
|
+
|
|
48
|
+
**`dsh-image-gen` 是专为 DeepSeek Harness (DSH) 打造的开源图像生成插件。**
|
|
49
|
+
|
|
50
|
+
DeepSeek Harness 已经可以让 Agent 调用不同工具完成任务,本项目为它补上了原生的**多模态生图能力**:
|
|
51
|
+
|
|
52
|
+
```mermaid
|
|
53
|
+
graph LR
|
|
54
|
+
A[用户 Prompt] --> B[DeepSeek Harness Agent]
|
|
55
|
+
B --> C[generate_image 工具]
|
|
56
|
+
C --> D[Gemini / OpenAI / Seedream / DashScope]
|
|
57
|
+
D --> E[图片数据]
|
|
58
|
+
E --> F[当前 Conversation 对话流]
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## 🚀 快速安装与使用
|
|
64
|
+
|
|
65
|
+
### 1. 安装插件
|
|
66
|
+
|
|
67
|
+
在你的 DeepSeek Harness 项目根目录下运行:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# 推荐方式:安装或升级到最新版本
|
|
71
|
+
pnpm dsh plugin --profile web add dsh-image-gen@latest
|
|
72
|
+
|
|
73
|
+
# 若已将 dsh 安装为系统全局命令:
|
|
74
|
+
dsh plugin --profile web add dsh-image-gen@latest
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
<details>
|
|
78
|
+
<summary><b>🛠️ 其他安装方式(Git 仓库直装 / 本地调试)</b></summary>
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# 方式 B:从 GitHub 仓库直接安装最新代码
|
|
82
|
+
pnpm dsh plugin --profile web add git+https://github.com/shanliuling/dsh-image-gen.git
|
|
83
|
+
|
|
84
|
+
# 方式 C:本地克隆源码开发安装
|
|
85
|
+
git clone https://github.com/shanliuling/dsh-image-gen.git
|
|
86
|
+
pnpm dsh plugin --profile web add ./dsh-image-gen
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
</details>
|
|
90
|
+
|
|
91
|
+
### 2. 配置 API Key 与工作区设置
|
|
92
|
+
|
|
93
|
+
打开 DSH Web 页面(默认 `http://localhost:3080`):
|
|
94
|
+
|
|
95
|
+
1. 进入 **Settings → Plugins → Image generation**。
|
|
96
|
+
2. 选择 Provider,填写 API Key。
|
|
97
|
+
3. 可按需开启 **保存到工作区**(默认开启)并自定义子目录,点击 **保存** 即可。
|
|
98
|
+
|
|
99
|
+
<div align="center">
|
|
100
|
+
<img src="docs/assets/settings-preview.png?v=0.1.7" alt="设置面板预览" width="720" />
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
### 3. 开始对话生图
|
|
104
|
+
|
|
105
|
+
现在直接在聊天框输入:
|
|
106
|
+
|
|
107
|
+
```text
|
|
108
|
+
生成一张极简主义的现代建筑客厅插画。
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
当前 Agent 就会自动调用 `generate_image` 工具并在对话流中返回图片。
|
|
112
|
+
|
|
113
|
+
### 4. 查看原生生图画廊
|
|
114
|
+
|
|
115
|
+
点击会话顶栏的 **`[画廊]`** Tab,即可集中查看和搜索所有对话生成的历史图片:
|
|
116
|
+
|
|
117
|
+
<div align="center">
|
|
118
|
+
<img src="docs/assets/gallery-preview.png" alt="原生生图画廊预览" width="820" />
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## ✨ 主要能力
|
|
124
|
+
|
|
125
|
+
- 💬 **对话中直接生图**:不需要切换到其他网站,也不需要手动复制 Prompt,直接告诉 Agent 你想画什么即可。
|
|
126
|
+
- 🖼️ **历史生图画廊**:顶栏自带「画廊」Tab,自动汇总所有历史生成的图片,支持关键词搜索、厂商筛选、单张删除(带防误触确认与持久化墓碑)与一键复制/下载。
|
|
127
|
+
- 🔍 **交互式图片工具**:支持点击全屏大图预览、一键复制图片到剪贴板、本地下载与新标签页打开。
|
|
128
|
+
- 🎨 **多 Provider 支持**:支持 Google Gemini、OpenAI Images、OpenAI Compatible API、ByteDance Seedream / 火山方舟以及阿里云 DashScope(通义万相 / Qwen-Image)。Provider、模型和 Endpoint 均可在设置中自由定制。
|
|
129
|
+
- 🔑 **BYOK (自带 Key)**:插件使用你自己的 API Key。API Key 通过 DeepSeek Harness 的 `credentials` 服务管理,采用写保护隔离,不需要写进项目源码或配置文件,前端不存明文。
|
|
130
|
+
- 🖼️ **图片跟随会话保存**:生成结果会接入 DeepSeek Harness 的 Attachment / Conversation 体系,重新打开历史会话后,仍然可以看到之前生成的图片。
|
|
131
|
+
- 💾 **生成图片自动落盘到工作区**:默认在每次生成后把图片文件保存到当前会话工作区,工具结果会返回文件的绝对路径;可在设置中关闭或修改保存目录。
|
|
132
|
+
- ⚙️ **原生设置界面**:Provider、API Key、模型和 Endpoint 都可以直接在 DSH Web 设置中修改,不需要手动编辑配置文件。
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## 📦 支持的 Provider
|
|
137
|
+
|
|
138
|
+
| Provider | 默认模型 | 默认 Endpoint / Base URL |
|
|
139
|
+
| :--- | :--- | :--- |
|
|
140
|
+
| **Google Gemini** | `gemini-3.1-flash-image` | `https://generativelanguage.googleapis.com/v1beta/interactions` |
|
|
141
|
+
| **OpenAI Images** | `gpt-image-2` | `https://api.openai.com/v1` |
|
|
142
|
+
| **OpenAI Compatible** | 自定义 | 自定义 Base URL |
|
|
143
|
+
| **ByteDance Seedream / 火山方舟** | `doubao-seedream-5-0-260128` | `https://ark.cn-beijing.volces.com/api/v3` |
|
|
144
|
+
| **Aliyun DashScope / 通义万相** | `wanx2.1-t2i-turbo` | `https://dashscope.aliyuncs.com/api/v1` |
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 🛠️ 本地开发 (Development)
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# 克隆仓库
|
|
152
|
+
git clone https://github.com/shanliuling/dsh-image-gen.git
|
|
153
|
+
cd dsh-image-gen
|
|
154
|
+
|
|
155
|
+
# 安装依赖与构建
|
|
156
|
+
pnpm install
|
|
157
|
+
pnpm run typecheck
|
|
158
|
+
pnpm run test
|
|
159
|
+
pnpm run build
|
|
160
|
+
|
|
161
|
+
# 检查 npm 打包内容
|
|
162
|
+
pnpm run pack:check
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## 📄 开源协议 (License)
|
|
168
|
+
|
|
169
|
+
本项目基于 [MIT License](LICENSE) 开源。
|
|
170
|
+
|
|
171
|
+
如果这个插件对你有用,欢迎点一个 ⭐️ **Star** 支持!
|
package/lib/client.js
CHANGED
|
@@ -21,7 +21,7 @@ window.__ModuleLoader__.load({
|
|
|
21
21
|
google: "gemini-3.1-flash-image",
|
|
22
22
|
openai: "gpt-image-2",
|
|
23
23
|
seedream: "doubao-seedream-5-0-260128",
|
|
24
|
-
dashscope: "
|
|
24
|
+
dashscope: "qwen-image-3.0"
|
|
25
25
|
};
|
|
26
26
|
const DEFAULT_BASE_URLS = {
|
|
27
27
|
google: DEFAULT_GOOGLE_ENDPOINT,
|
|
@@ -917,9 +917,14 @@ window.__ModuleLoader__.load({
|
|
|
917
917
|
endpointHintSeedream: "火山方舟兼容的 /api/v3 地址。",
|
|
918
918
|
endpointHintDashScope: "阿里云百炼 DashScope 官方接口地址。",
|
|
919
919
|
model: "模型",
|
|
920
|
+
saveToWorkspace: "保存到工作区",
|
|
921
|
+
saveToWorkspaceHint: "每次生成后,把图片文件保存到当前会话工作区。",
|
|
922
|
+
folder: "工作区文件夹",
|
|
923
|
+
folderHint: "相对当前会话工作区的子目录;留空表示工作区根目录。",
|
|
920
924
|
saving: "保存中…",
|
|
921
925
|
save: "保存",
|
|
922
926
|
saved: "已保存",
|
|
927
|
+
savedToPath: "已保存到",
|
|
923
928
|
checkingKey: "正在检查 API Key…",
|
|
924
929
|
keyConfigured: "已配置 API Key",
|
|
925
930
|
keyNotConfigured: "尚未配置 API Key",
|
|
@@ -952,9 +957,14 @@ window.__ModuleLoader__.load({
|
|
|
952
957
|
endpointHintSeedream: "Volcengine Ark compatible /api/v3 base URL.",
|
|
953
958
|
endpointHintDashScope: "Official Aliyun DashScope endpoint.",
|
|
954
959
|
model: "Model",
|
|
960
|
+
saveToWorkspace: "Save to workspace",
|
|
961
|
+
saveToWorkspaceHint: "Write each generated image as a file into the session workspace.",
|
|
962
|
+
folder: "Workspace folder",
|
|
963
|
+
folderHint: "Subdirectory of the session workspace; empty means the workspace root.",
|
|
955
964
|
saving: "Saving…",
|
|
956
965
|
save: "Save",
|
|
957
966
|
saved: "Saved",
|
|
967
|
+
savedToPath: "Saved to",
|
|
958
968
|
checkingKey: "Checking API Key…",
|
|
959
969
|
keyConfigured: "API Key configured",
|
|
960
970
|
keyNotConfigured: "API Key not configured",
|
|
@@ -990,6 +1000,9 @@ window.__ModuleLoader__.load({
|
|
|
990
1000
|
.dsh-ig-btn-reset:hover{background:var(--dsw-alias-bg-layer-2,#edf0f3);border-color:var(--dsw-alias-label-dimmed,#9ca3af)}
|
|
991
1001
|
.dsh-ig-hint,.dsh-ig-status{margin:0;color:var(--dsw-alias-label-tertiary,#7b818b);font-size:12px;line-height:1.4}
|
|
992
1002
|
.dsh-ig-actions{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:16px;padding-top:12px;border-top:1px solid var(--dsw-alias-border-l2,#eee)}
|
|
1003
|
+
.dsh-ig-check-row{display:flex;align-items:center;gap:8px;cursor:pointer}
|
|
1004
|
+
.dsh-ig-check-row input[type=checkbox]{width:15px;height:15px;accent-color:var(--dsw-alias-brand-primary,#4c78ff);margin:0}
|
|
1005
|
+
.dsh-ig-savedto{font-size:12px;line-height:1.5;color:var(--dsw-alias-label-tertiary,#7b818b);word-break:break-all}
|
|
993
1006
|
.dsh-ig-save{appearance:none;border:0;border-radius:8px;padding:6px 16px;background:var(--dsw-alias-label-primary,#111827);color:var(--dsw-alias-bg-layer-3,#fff);font:inherit;font-size:13px;font-weight:500;cursor:pointer;transition:opacity .15s}
|
|
994
1007
|
.dsh-ig-save:disabled{opacity:.4;cursor:default}
|
|
995
1008
|
|
|
@@ -1099,6 +1112,11 @@ window.__ModuleLoader__.load({
|
|
|
1099
1112
|
key: "generate_image",
|
|
1100
1113
|
inject: () => ({ locale })
|
|
1101
1114
|
}, GeneratedImageCard));
|
|
1115
|
+
ctx.slots.inject("tool.call.toolview", () => register({
|
|
1116
|
+
name: "tool.call.toolview",
|
|
1117
|
+
key: "edit_image",
|
|
1118
|
+
inject: () => ({ locale })
|
|
1119
|
+
}, GeneratedImageCard));
|
|
1102
1120
|
ctx.slots.inject("conversation.view", () => register({
|
|
1103
1121
|
name: "conversation.view",
|
|
1104
1122
|
id: "gallery",
|
|
@@ -1117,6 +1135,8 @@ window.__ModuleLoader__.load({
|
|
|
1117
1135
|
const [provider, setProvider] = (0, react.useState)("google");
|
|
1118
1136
|
const [model, setModel] = (0, react.useState)("");
|
|
1119
1137
|
const [baseURL, setBaseURL] = (0, react.useState)("");
|
|
1138
|
+
const [saveToWorkspace, setSaveToWorkspace] = (0, react.useState)(true);
|
|
1139
|
+
const [workspaceFolder, setWorkspaceFolder] = (0, react.useState)("dsh-image-gen");
|
|
1120
1140
|
const [key, setKey] = (0, react.useState)("");
|
|
1121
1141
|
const [configured, setConfigured] = (0, react.useState)();
|
|
1122
1142
|
const [saving, setSaving] = (0, react.useState)(false);
|
|
@@ -1146,6 +1166,8 @@ window.__ModuleLoader__.load({
|
|
|
1146
1166
|
setProvider(next);
|
|
1147
1167
|
setModel(modelOf(next, value));
|
|
1148
1168
|
setBaseURL(baseURLOf(next, value));
|
|
1169
|
+
setSaveToWorkspace(value?.saveToWorkspace ?? true);
|
|
1170
|
+
setWorkspaceFolder(value?.workspaceFolder ?? "dsh-image-gen");
|
|
1149
1171
|
}, [snapshot]);
|
|
1150
1172
|
(0, react.useEffect)(() => {
|
|
1151
1173
|
let active = true;
|
|
@@ -1166,6 +1188,8 @@ window.__ModuleLoader__.load({
|
|
|
1166
1188
|
await props.scope.set("provider", provider);
|
|
1167
1189
|
await props.scope.set(provider === "google" ? "googleModel" : provider === "openai" ? "openaiModel" : provider === "seedream" ? "seedreamModel" : "dashscopeModel", model);
|
|
1168
1190
|
await props.scope.set(provider === "google" ? "googleEndpoint" : provider === "openai" ? "openaiBaseURL" : provider === "seedream" ? "seedreamBaseURL" : "dashscopeEndpoint", baseURL);
|
|
1191
|
+
await props.scope.set("saveToWorkspace", saveToWorkspace);
|
|
1192
|
+
await props.scope.set("workspaceFolder", workspaceFolder.trim());
|
|
1169
1193
|
if (key.trim().length > 0) {
|
|
1170
1194
|
const response = await props.credentials.set({
|
|
1171
1195
|
ref: KEY_REF[provider],
|
|
@@ -1334,6 +1358,46 @@ window.__ModuleLoader__.load({
|
|
|
1334
1358
|
required: true
|
|
1335
1359
|
})]
|
|
1336
1360
|
}),
|
|
1361
|
+
(0, react_jsx_runtime.jsxs)("div", {
|
|
1362
|
+
className: "dsh-ig-field",
|
|
1363
|
+
children: [(0, react_jsx_runtime.jsxs)("label", {
|
|
1364
|
+
className: "dsh-ig-check-row",
|
|
1365
|
+
children: [(0, react_jsx_runtime.jsx)("input", {
|
|
1366
|
+
type: "checkbox",
|
|
1367
|
+
checked: saveToWorkspace,
|
|
1368
|
+
onChange: (event) => {
|
|
1369
|
+
setSaveToWorkspace(event.target.checked);
|
|
1370
|
+
}
|
|
1371
|
+
}), (0, react_jsx_runtime.jsx)("span", {
|
|
1372
|
+
className: "dsh-ig-label",
|
|
1373
|
+
children: t("saveToWorkspace")
|
|
1374
|
+
})]
|
|
1375
|
+
}), (0, react_jsx_runtime.jsx)("span", {
|
|
1376
|
+
className: "dsh-ig-hint",
|
|
1377
|
+
children: t("saveToWorkspaceHint")
|
|
1378
|
+
})]
|
|
1379
|
+
}),
|
|
1380
|
+
saveToWorkspace ? (0, react_jsx_runtime.jsxs)("label", {
|
|
1381
|
+
className: "dsh-ig-field",
|
|
1382
|
+
children: [
|
|
1383
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
1384
|
+
className: "dsh-ig-label",
|
|
1385
|
+
children: t("folder")
|
|
1386
|
+
}),
|
|
1387
|
+
(0, react_jsx_runtime.jsx)("input", {
|
|
1388
|
+
className: "dsh-ig-input",
|
|
1389
|
+
value: workspaceFolder,
|
|
1390
|
+
onChange: (event) => {
|
|
1391
|
+
setWorkspaceFolder(event.target.value);
|
|
1392
|
+
},
|
|
1393
|
+
placeholder: "dsh-image-gen"
|
|
1394
|
+
}),
|
|
1395
|
+
(0, react_jsx_runtime.jsx)("span", {
|
|
1396
|
+
className: "dsh-ig-hint",
|
|
1397
|
+
children: t("folderHint")
|
|
1398
|
+
})
|
|
1399
|
+
]
|
|
1400
|
+
}) : null,
|
|
1337
1401
|
(0, react_jsx_runtime.jsxs)("div", {
|
|
1338
1402
|
className: "dsh-ig-actions",
|
|
1339
1403
|
children: [(0, react_jsx_runtime.jsx)("p", {
|
|
@@ -1354,6 +1418,7 @@ window.__ModuleLoader__.load({
|
|
|
1354
1418
|
/** Render the durable attachment referenced by a completed image tool call. */
|
|
1355
1419
|
function GeneratedImageCard(props) {
|
|
1356
1420
|
const attachment = imageRef(props.block);
|
|
1421
|
+
const savedTo = imageSavedTo(props.block);
|
|
1357
1422
|
const [url, setUrl] = (0, react.useState)();
|
|
1358
1423
|
const [blob, setBlob] = (0, react.useState)();
|
|
1359
1424
|
const [error, setError] = (0, react.useState)();
|
|
@@ -1457,6 +1522,14 @@ window.__ModuleLoader__.load({
|
|
|
1457
1522
|
className: "dsh-ig-result-title",
|
|
1458
1523
|
children: t("generatedTitle")
|
|
1459
1524
|
}),
|
|
1525
|
+
savedTo !== void 0 ? (0, react_jsx_runtime.jsxs)("div", {
|
|
1526
|
+
className: "dsh-ig-savedto",
|
|
1527
|
+
children: [
|
|
1528
|
+
t("savedToPath"),
|
|
1529
|
+
": ",
|
|
1530
|
+
savedTo
|
|
1531
|
+
]
|
|
1532
|
+
}) : null,
|
|
1460
1533
|
error !== void 0 ? (0, react_jsx_runtime.jsx)("div", {
|
|
1461
1534
|
className: "dsh-ig-error",
|
|
1462
1535
|
children: error
|
|
@@ -1595,6 +1668,12 @@ window.__ModuleLoader__.load({
|
|
|
1595
1668
|
const image = block.resultView.content?.find((item) => item.type === "image");
|
|
1596
1669
|
return image?.type === "image" ? image.attachment : void 0;
|
|
1597
1670
|
}
|
|
1671
|
+
/** The workspace file path a completed image call saved, when the result meta carries one. */
|
|
1672
|
+
function imageSavedTo(block) {
|
|
1673
|
+
if (!("kind" in block)) return void 0;
|
|
1674
|
+
const meta = block.meta ?? block.resultView?.meta;
|
|
1675
|
+
return typeof meta?.savedTo === "string" ? meta.savedTo : void 0;
|
|
1676
|
+
}
|
|
1598
1677
|
//#endregion
|
|
1599
1678
|
exports.GeneratedImageCard = GeneratedImageCard;
|
|
1600
1679
|
exports.ImageGenerationSettingsCard = ImageGenerationSettingsCard;
|