@plume-canvas/cloud-server 0.0.0-stage → 0.1.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/builtin-manifest.json +28 -0
- package/dist/cli.js +81 -0
- package/dist/index.d.ts +3555 -0
- package/dist/index.js +38 -0
- package/package.json +56 -4
- package/providers/seed-audio-volc.js +402 -0
- package/providers/seed-audio.js +376 -0
- package/providers/web2api-audio.js +500 -0
- package/providers/web2api-image.js +497 -0
- package/providers/web2api-video.js +490 -0
- package/README.md +0 -3
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* web2api · 图片生成(provider,自包含单文件)
|
|
3
|
+
*
|
|
4
|
+
* 直接调 web2api 的 HTTP 任务接口(不再走 MCP):
|
|
5
|
+
* POST /api/tasks -> { code, message, data: task }
|
|
6
|
+
* GET /api/tasks/:id -> { code, message, data: task }
|
|
7
|
+
* POST /api/tasks/:id/cancel -> { code, message, data: { cancelled } }
|
|
8
|
+
*
|
|
9
|
+
* 动作 id 与原前端插件保持一致(web2api:...),旧画布里存过的 actionId 继续有效。
|
|
10
|
+
*
|
|
11
|
+
* 环境变量:
|
|
12
|
+
* WEB2API_BASE 服务地址,默认 http://localhost:8033
|
|
13
|
+
* WEB2API_API_KEY 可选;服务端设了 API_KEY 时填同一个
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 服务地址与密钥:优先「平台管理」页存的配置(__mcProviderConfig,装载时注入),
|
|
18
|
+
* 回落环境变量(老部署兼容),再回落默认值。
|
|
19
|
+
* 多账号:submit 按动作参数里选中的账号 id 取对应那套值(见 accountValues)。
|
|
20
|
+
*/
|
|
21
|
+
function injected() {
|
|
22
|
+
return typeof __mcProviderConfig === 'undefined' ? { accounts: [], values: {}, byId: {} } : __mcProviderConfig
|
|
23
|
+
}
|
|
24
|
+
/** 这次任务用哪个账号的值:values.__accountId 优先,没选就第一账号 */
|
|
25
|
+
function accountValues(values) {
|
|
26
|
+
const inj = injected()
|
|
27
|
+
const preferred = values && typeof values.__accountId === 'string' ? values.__accountId : ''
|
|
28
|
+
if (preferred && inj.byId && inj.byId[preferred]) return inj.byId[preferred]
|
|
29
|
+
const accounts = inj.accounts || []
|
|
30
|
+
if (accounts.length > 0) return accounts[0].values || {}
|
|
31
|
+
return inj.values || {}
|
|
32
|
+
}
|
|
33
|
+
function baseOf(values) {
|
|
34
|
+
const b = values && typeof values.baseUrl === 'string' && values.baseUrl.trim()
|
|
35
|
+
? values.baseUrl.trim()
|
|
36
|
+
: (process.env.WEB2API_BASE || 'http://localhost:8033')
|
|
37
|
+
return String(b).replace(/\/+$/, '')
|
|
38
|
+
}
|
|
39
|
+
const BASE = baseOf(injected().values || {})
|
|
40
|
+
|
|
41
|
+
/** 一次 HTTP 调用:统一解 code / 超时 / 人话错误 */
|
|
42
|
+
async function api(path, init = {}, timeoutMs = 60000, values) {
|
|
43
|
+
const ac = new AbortController()
|
|
44
|
+
const timer = setTimeout(() => ac.abort(), timeoutMs)
|
|
45
|
+
try {
|
|
46
|
+
const headers = { 'Content-Type': 'application/json', Accept: 'application/json', ...(init.headers || {}) }
|
|
47
|
+
const key = values && values.apiKey ? values.apiKey : process.env.WEB2API_API_KEY
|
|
48
|
+
if (key) headers.Authorization = 'Bearer ' + key
|
|
49
|
+
const res = await fetch(baseOf(values) + path, { ...init, headers, signal: ac.signal })
|
|
50
|
+
const text = await res.text()
|
|
51
|
+
let body
|
|
52
|
+
try {
|
|
53
|
+
body = text ? JSON.parse(text) : {}
|
|
54
|
+
} catch {
|
|
55
|
+
throw new Error('web2api 返回的不是 JSON(HTTP ' + res.status + ')')
|
|
56
|
+
}
|
|
57
|
+
if (body && typeof body.code === 'number' && body.code !== 0) {
|
|
58
|
+
throw new Error(body.message || 'web2api 错误 ' + body.code)
|
|
59
|
+
}
|
|
60
|
+
if (!res.ok) throw new Error(body?.message || 'web2api HTTP ' + res.status)
|
|
61
|
+
return body
|
|
62
|
+
} catch (err) {
|
|
63
|
+
const msg = err instanceof Error ? err.message : String(err)
|
|
64
|
+
if (err instanceof Error && err.name === 'AbortError') {
|
|
65
|
+
throw new Error('web2api 请求超时(' + baseOf(values) + ')')
|
|
66
|
+
}
|
|
67
|
+
if (/fetch failed|ECONNREFUSED|Failed to fetch|NetworkError/i.test(msg)) {
|
|
68
|
+
throw new Error('连不上 web2api(' + baseOf(values) + ')。请先启动它,或在「平台」页配置服务地址')
|
|
69
|
+
}
|
|
70
|
+
throw new Error(msg || 'web2api 调用失败')
|
|
71
|
+
} finally {
|
|
72
|
+
clearTimeout(timer)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** 空值不发,免得覆盖服务端默认 */
|
|
77
|
+
function cleanValues(values) {
|
|
78
|
+
const out = {}
|
|
79
|
+
for (const [k, v] of Object.entries(values || {})) {
|
|
80
|
+
if (v === undefined || v === null || v === '') continue
|
|
81
|
+
out[k] = v
|
|
82
|
+
}
|
|
83
|
+
return out
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** 值 -> 前缀里的字面量:数字原样,字符串加引号 */
|
|
87
|
+
function literalOf(value) {
|
|
88
|
+
if (value === undefined || value === null || value === '') return undefined
|
|
89
|
+
if (typeof value === 'number') return Number.isFinite(value) ? String(value) : undefined
|
|
90
|
+
if (typeof value === 'boolean') return String(value)
|
|
91
|
+
const s = String(value).trim()
|
|
92
|
+
return s === '' ? undefined : '"' + s.replace(/"/g, '') + '"'
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** 拼 chat-auto 前缀:/image(model:"Seedream 4.5", ratio:"16:9") 正文 */
|
|
96
|
+
function buildChatAutoPrompt(mode, model, values, body) {
|
|
97
|
+
const parts = []
|
|
98
|
+
const modelLit = literalOf(model)
|
|
99
|
+
if (modelLit !== undefined) parts.push('model:' + modelLit)
|
|
100
|
+
const ratioLit = literalOf(values.ratio)
|
|
101
|
+
if (ratioLit !== undefined) parts.push('ratio:' + ratioLit)
|
|
102
|
+
const styleLit = literalOf(values.style)
|
|
103
|
+
if (styleLit !== undefined) parts.push('style:' + styleLit)
|
|
104
|
+
const head = '/' + mode + (parts.length > 0 ? '(' + parts.join(', ') + ')' : '')
|
|
105
|
+
const text = String(body || '').trim()
|
|
106
|
+
return text ? head + ' ' + text : head
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 上游文本素材 -> 带名字的标签块。
|
|
111
|
+
*
|
|
112
|
+
* 用户口径(2026-11-08):文本要能**按名字引用**,不要糊成一大段。
|
|
113
|
+
* 连进来的文本给一个名字(节点标题优先,没有就 文本1 / 文本2…),
|
|
114
|
+
* 正文包进 <text name="…"> 里;用户在自己的提示词里写 @标题内容 / @文本1 就能指到它。
|
|
115
|
+
*/
|
|
116
|
+
/** 资源在数组里的位置就是它的引用索引(从 1 开始);平台只认序号,不认节点名 */
|
|
117
|
+
function refLabel(resource, index) {
|
|
118
|
+
const kind = resource && typeof resource.kind === 'string' ? resource.kind : ''
|
|
119
|
+
const prefix =
|
|
120
|
+
kind === 'image' ? '图片'
|
|
121
|
+
: kind === 'video' ? '视频'
|
|
122
|
+
: kind === 'audio' ? '音频'
|
|
123
|
+
: kind === 'text' ? '文本'
|
|
124
|
+
: '资源'
|
|
125
|
+
return prefix + (index + 1)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function textBlocks(input) {
|
|
129
|
+
const out = []
|
|
130
|
+
const resources = input.resources || []
|
|
131
|
+
resources.forEach((r, i) => {
|
|
132
|
+
if (!r || r.kind !== 'text') return
|
|
133
|
+
const value = typeof r.value === 'string' ? r.value : ''
|
|
134
|
+
out.push('<text name="' + refLabel(r, i) + '">\n' + value + '\n</text>')
|
|
135
|
+
})
|
|
136
|
+
return out
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** 提示词分段 → 平台要的一段文字(标签按资源在数组里的「类型+序号」展开) */
|
|
140
|
+
function promptText(input) {
|
|
141
|
+
const labels = new Map()
|
|
142
|
+
const resources = input.resources || []
|
|
143
|
+
resources.forEach((r, i) => {
|
|
144
|
+
if (r && typeof r.id === 'string' && r.id) labels.set(r.id, refLabel(r, i))
|
|
145
|
+
})
|
|
146
|
+
let out = ''
|
|
147
|
+
for (const seg of input.prompts || []) {
|
|
148
|
+
if (!seg || typeof seg.value !== 'string') continue
|
|
149
|
+
if (seg.type === 'tag') {
|
|
150
|
+
out += '@' + (labels.get(seg.value) || seg.value)
|
|
151
|
+
} else {
|
|
152
|
+
out += seg.value
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return out
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* 参考素材 -> 参数(按动作自己声明的 refFields 分发)。
|
|
160
|
+
*
|
|
161
|
+
* refFields 是这份 provider 的「这个平台收什么」:
|
|
162
|
+
* { image: 'referenceImages' }
|
|
163
|
+
* 没声明的类型 = 这台平台不收,跳过并打一条日志(让用户知道为什么没生效)。
|
|
164
|
+
* 以后接「图/文/视频/音频全收」的模型:给那条动作补 refFields 即可,分发逻辑不动。
|
|
165
|
+
* 注意:web2api 目前**只有**图片与音频两个参考字段,没有视频参考字段。
|
|
166
|
+
*/
|
|
167
|
+
function attachRefs(action, input, params) {
|
|
168
|
+
const map = action.refFields || {}
|
|
169
|
+
const buckets = {}
|
|
170
|
+
const skipped = []
|
|
171
|
+
for (const r of input.resources || []) {
|
|
172
|
+
if (r.kind === 'text') continue
|
|
173
|
+
const field = map[r.kind]
|
|
174
|
+
if (!field || typeof r.url !== 'string' || !r.url) {
|
|
175
|
+
if (r.kind) skipped.push(r.kind)
|
|
176
|
+
continue
|
|
177
|
+
}
|
|
178
|
+
if (!buckets[field]) buckets[field] = []
|
|
179
|
+
buckets[field].push(r.url)
|
|
180
|
+
}
|
|
181
|
+
for (const [field, urls] of Object.entries(buckets)) {
|
|
182
|
+
const limit = field === 'referenceAudios' ? 3 : 16
|
|
183
|
+
if (urls.length > limit) {
|
|
184
|
+
console.warn('[web2api-image] ' + action.id + ' 的 ' + field + ' 最多 ' + limit + ' 个,已截断')
|
|
185
|
+
}
|
|
186
|
+
params[field] = urls.slice(0, limit)
|
|
187
|
+
}
|
|
188
|
+
if (skipped.length > 0) {
|
|
189
|
+
console.warn(
|
|
190
|
+
'[web2api-image] ' + action.id + ' 不收这些素材,已忽略:' + [...new Set(skipped)].join('、') +
|
|
191
|
+
'(当前平台只收:' + (Object.keys(map).join('、') || '无') + ')',
|
|
192
|
+
)
|
|
193
|
+
}
|
|
194
|
+
return params
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** 组一次下单参数 */
|
|
198
|
+
function buildParams(action, input) {
|
|
199
|
+
const values = (input.values || {})
|
|
200
|
+
const body = [promptText(input), ...textBlocks(input)].filter((s) => String(s).trim() !== '').join('\n')
|
|
201
|
+
|
|
202
|
+
if (action.promptMode === 'chat-auto') {
|
|
203
|
+
const params = { prompt: buildChatAutoPrompt(action.mediaMode || 'image', action.model, values, body) }
|
|
204
|
+
return attachRefs(action, input, params)
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const params = cleanValues(values)
|
|
208
|
+
if (action.model !== undefined && action.model !== '') params.model = action.model
|
|
209
|
+
params.prompt = body
|
|
210
|
+
return attachRefs(action, input, params)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** 任务结果里的产物地址(兼容数组 / 嵌套对象) */
|
|
214
|
+
function collectUrls(result) {
|
|
215
|
+
const out = []
|
|
216
|
+
const push = (v) => {
|
|
217
|
+
if (typeof v === 'string') {
|
|
218
|
+
if (/^(https?:|data:|\/)/i.test(v)) out.push(v)
|
|
219
|
+
} else if (Array.isArray(v)) {
|
|
220
|
+
for (const item of v) push(item)
|
|
221
|
+
} else if (v && typeof v === 'object') {
|
|
222
|
+
push(v.url)
|
|
223
|
+
push(v.uri)
|
|
224
|
+
push(v.src)
|
|
225
|
+
push(v.urls)
|
|
226
|
+
push(v.downloadUrl)
|
|
227
|
+
push(v.resource)
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
push(result)
|
|
231
|
+
return [...new Set(out)]
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** 相对地址补成 web2api 的绝对地址 */
|
|
235
|
+
function absolutize(u) {
|
|
236
|
+
const s = String(u || '').trim()
|
|
237
|
+
if (!s) return ''
|
|
238
|
+
if (/^(https?:|data:|blob:)/i.test(s)) return s
|
|
239
|
+
return BASE + (s.startsWith('/') ? s : '/' + s)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** 提交一次任务,返回 taskId */
|
|
243
|
+
async function submitTask(action, input) {
|
|
244
|
+
const values = accountValues(input.values)
|
|
245
|
+
const body = await api('/api/tasks', {
|
|
246
|
+
method: 'POST',
|
|
247
|
+
body: JSON.stringify({ platform: action.platform, operation: action.operation, params: buildParams(action, input) }),
|
|
248
|
+
}, 60000, values)
|
|
249
|
+
const task = body && body.data
|
|
250
|
+
if (!task || typeof task.id !== 'string' || !task.id) throw new Error('web2api 没有返回任务 id')
|
|
251
|
+
return task.id
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** 查一次任务 */
|
|
255
|
+
async function pollTask(taskId) {
|
|
256
|
+
// 轮询沿用注入的默认账号地址(任务从属关系由 taskId 保证,账号只决定打到哪台服务)
|
|
257
|
+
const body = await api('/api/tasks/' + encodeURIComponent(taskId), {}, 60000, accountValues())
|
|
258
|
+
const t = body && body.data
|
|
259
|
+
if (!t || typeof t !== 'object') return { status: 'running', message: '任务查询返回空', taskId }
|
|
260
|
+
const status = String(t.status || '')
|
|
261
|
+
|
|
262
|
+
if (status === 'completed' || status === 'success' || status === 'done') {
|
|
263
|
+
const urls = collectUrls(t.result).map(absolutize).filter(Boolean)
|
|
264
|
+
if (urls.length === 0) return { status: 'error', error: '任务完成但没有产出资源', taskId }
|
|
265
|
+
return { status: 'done', urls, taskId }
|
|
266
|
+
}
|
|
267
|
+
if (status === 'failed') return { status: 'error', error: t.message || '任务执行失败', taskId }
|
|
268
|
+
if (status === 'cancelled') return { status: 'error', error: t.message || '任务已取消', taskId }
|
|
269
|
+
|
|
270
|
+
// paused(等验证码)/ retrying / pending(换号重排):都在自己往前走,不算失败、不占超时。
|
|
271
|
+
const waiting = status === 'paused' || status === 'retrying' || status === 'pending'
|
|
272
|
+
return {
|
|
273
|
+
status: 'running',
|
|
274
|
+
message: t.message || '生成中…',
|
|
275
|
+
...(typeof t.progress === 'number' ? { progress: t.progress } : {}),
|
|
276
|
+
taskId,
|
|
277
|
+
...(waiting ? { waiting: true } : {}),
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/** 取消服务端任务 */
|
|
282
|
+
async function cancelTask(taskId) {
|
|
283
|
+
try {
|
|
284
|
+
await api('/api/tasks/' + encodeURIComponent(taskId) + '/cancel', { method: 'POST' }, 15000, accountValues())
|
|
285
|
+
} catch {
|
|
286
|
+
/* 已是终态 / 服务端不认:本机已取消,不算错 */
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
const ratio_doubao = {
|
|
292
|
+
key: 'ratio', kind: 'ratio', label: '比例', type: 'select', default: '16:9',
|
|
293
|
+
options: [
|
|
294
|
+
{ label: '1:1', value: '1:1' },
|
|
295
|
+
{ label: '3:4', value: '3:4' },
|
|
296
|
+
{ label: '4:3', value: '4:3' },
|
|
297
|
+
{ label: '9:16', value: '9:16' },
|
|
298
|
+
{ label: '16:9', value: '16:9' },
|
|
299
|
+
{ label: '3:2', value: '3:2' },
|
|
300
|
+
],
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const ratio_dola = {
|
|
304
|
+
key: 'ratio', kind: 'ratio', label: '比例', type: 'select', default: '1:1',
|
|
305
|
+
options: [
|
|
306
|
+
{ label: '1:1', value: '1:1' },
|
|
307
|
+
{ label: '2:3', value: '2:3' },
|
|
308
|
+
{ label: '3:4', value: '3:4' },
|
|
309
|
+
{ label: '4:3', value: '4:3' },
|
|
310
|
+
{ label: '9:16', value: '9:16' },
|
|
311
|
+
{ label: '16:9', value: '16:9' },
|
|
312
|
+
],
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
const ratio_chatgpt = {
|
|
316
|
+
key: 'ratio', kind: 'ratio', label: '比例', type: 'select', default: '1:1',
|
|
317
|
+
options: [
|
|
318
|
+
{ label: '1:1', value: '1:1' },
|
|
319
|
+
{ label: '2:3', value: '2:3' },
|
|
320
|
+
{ label: '3:4', value: '3:4' },
|
|
321
|
+
{ label: '4:3', value: '4:3' },
|
|
322
|
+
{ label: '9:16', value: '9:16' },
|
|
323
|
+
{ label: '16:9', value: '16:9' },
|
|
324
|
+
],
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const ratio_apimart = {
|
|
328
|
+
key: 'ratio', kind: 'ratio', label: '比例', type: 'select', default: '1:1',
|
|
329
|
+
options: [
|
|
330
|
+
{ label: '1:1', value: '1:1' },
|
|
331
|
+
{ label: '3:2', value: '3:2' },
|
|
332
|
+
{ label: '2:3', value: '2:3' },
|
|
333
|
+
{ label: '4:3', value: '4:3' },
|
|
334
|
+
{ label: '3:4', value: '3:4' },
|
|
335
|
+
{ label: '5:4', value: '5:4' },
|
|
336
|
+
{ label: '4:5', value: '4:5' },
|
|
337
|
+
{ label: '16:9', value: '16:9' },
|
|
338
|
+
{ label: '9:16', value: '9:16' },
|
|
339
|
+
{ label: '2:1', value: '2:1' },
|
|
340
|
+
{ label: '1:2', value: '1:2' },
|
|
341
|
+
{ label: '3:1', value: '3:1' },
|
|
342
|
+
{ label: '1:3', value: '1:3' },
|
|
343
|
+
{ label: '21:9', value: '21:9' },
|
|
344
|
+
{ label: '9:21', value: '9:21' },
|
|
345
|
+
],
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const resolution_apimart = {
|
|
349
|
+
key: 'resolution', label: '分辨率', type: 'grid', default: '1k',
|
|
350
|
+
options: [
|
|
351
|
+
{ label: '1K (标清)', value: '1k' },
|
|
352
|
+
{ label: '2K (高清)', value: '2k' },
|
|
353
|
+
{ label: '4K (超清)', value: '4k' },
|
|
354
|
+
],
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/** 数量是「1~10 档」,滑块比按钮更好用(10 个按钮排成两行) */
|
|
358
|
+
const count_apimart = { key: 'n', label: '数量', type: 'number', default: 1, min: 1, max: 10, step: 1 }
|
|
359
|
+
|
|
360
|
+
const provider = {
|
|
361
|
+
id: 'web2api-image',
|
|
362
|
+
// 平台展示信息(管理页显示;icon 也作为该平台模型的兜底图标)
|
|
363
|
+
title: 'Web2API · 图片',
|
|
364
|
+
description: '豆包 / Dola / Seedream 网页自动化生图',
|
|
365
|
+
icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><defs><linearGradient id="wcImg" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#22d3ee"/><stop offset="1" stop-color="#0891b2"/></linearGradient></defs><rect width="32" height="32" rx="9" fill="url(#wcImg)"/><path d="M9 22V10h4.2c3 0 4.8 1.6 4.8 4.1 0 2.2-1.4 3.7-3.7 4l4.2 3.9h-3.2l-4-3.9V22H9zm3-6.1h1.5c1.3 0 2-.6 2-1.8s-.7-1.8-2-1.8H12v3.6z" fill="#fff"/></svg>',
|
|
366
|
+
// 平台管理页据此渲染配置表单(多账号每套一份;secret 只写不回读)
|
|
367
|
+
config: [
|
|
368
|
+
{ key: 'baseUrl', label: '服务地址', type: 'string', default: 'http://localhost:8033',
|
|
369
|
+
placeholder: 'http://localhost:8033', description: 'web2api 服务的根地址。留空 = 用默认地址。' },
|
|
370
|
+
{ key: 'apiKey', label: 'API Key', type: 'secret', description: 'web2api 开了 API_KEY 校验时才需要。留空 = 不带鉴权头。' },
|
|
371
|
+
],
|
|
372
|
+
actions: [
|
|
373
|
+
{
|
|
374
|
+
id: 'web2api:doubao-image-seedream45',
|
|
375
|
+
title: '豆包 Seedream 4.5',
|
|
376
|
+
description: '豆包网页 UI 自动化生图(Seedream 4.5):比例可选;风格写在提示词里',
|
|
377
|
+
group: 'web2api · 图片',
|
|
378
|
+
nodeTypes: ['image'],
|
|
379
|
+
needsPrompt: true,
|
|
380
|
+
order: 10,
|
|
381
|
+
platform: 'doubao', operation: 'chat-auto',
|
|
382
|
+
promptMode: 'chat-auto', mediaMode: 'image', model: 'Seedream 4.5',
|
|
383
|
+
fields: [ratio_doubao],
|
|
384
|
+
refFields: { image: 'referenceImages' },
|
|
385
|
+
pollIntervalMs: 1500, pollTimeoutMs: 600000,
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
id: 'web2api:doubao-image-seedream50lite',
|
|
389
|
+
title: '豆包 Seedream 5.0 Lite',
|
|
390
|
+
description: '豆包网页 UI 自动化生图(Seedream 5.0 Lite):比例可选;风格写在提示词里',
|
|
391
|
+
group: 'web2api · 图片',
|
|
392
|
+
nodeTypes: ['image'],
|
|
393
|
+
needsPrompt: true,
|
|
394
|
+
order: 11,
|
|
395
|
+
platform: 'doubao', operation: 'chat-auto',
|
|
396
|
+
promptMode: 'chat-auto', mediaMode: 'image', model: 'Seedream 5.0 Lite',
|
|
397
|
+
fields: [ratio_doubao],
|
|
398
|
+
refFields: { image: 'referenceImages' },
|
|
399
|
+
pollIntervalMs: 1500, pollTimeoutMs: 600000,
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
id: 'web2api:doubao-image-seedream40',
|
|
403
|
+
title: '豆包 Seedream 4.0',
|
|
404
|
+
description: '豆包网页 UI 自动化生图(Seedream 4.0):比例可选;风格写在提示词里',
|
|
405
|
+
group: 'web2api · 图片',
|
|
406
|
+
nodeTypes: ['image'],
|
|
407
|
+
needsPrompt: true,
|
|
408
|
+
order: 12,
|
|
409
|
+
platform: 'doubao', operation: 'chat-auto',
|
|
410
|
+
promptMode: 'chat-auto', mediaMode: 'image', model: 'Seedream 4.0',
|
|
411
|
+
fields: [ratio_doubao],
|
|
412
|
+
refFields: { image: 'referenceImages' },
|
|
413
|
+
pollIntervalMs: 1500, pollTimeoutMs: 600000,
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
id: 'web2api:dola-image-seedream50pro',
|
|
417
|
+
title: 'Dola Seedream 5.0 Pro',
|
|
418
|
+
description: 'Dola 网页 UI 自动化生图(Seedream 5.0 Pro);需海外网络',
|
|
419
|
+
group: 'web2api · 图片',
|
|
420
|
+
nodeTypes: ['image'],
|
|
421
|
+
needsPrompt: true,
|
|
422
|
+
order: 13,
|
|
423
|
+
platform: 'dola', operation: 'chat-auto',
|
|
424
|
+
promptMode: 'chat-auto', mediaMode: 'image', model: 'Seedream 5.0 Pro',
|
|
425
|
+
fields: [ratio_dola],
|
|
426
|
+
refFields: { image: 'referenceImages' },
|
|
427
|
+
pollIntervalMs: 1500, pollTimeoutMs: 600000,
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
id: 'web2api:dola-image-seedream45',
|
|
431
|
+
title: 'Dola Seedream 4.5',
|
|
432
|
+
description: 'Dola 网页 UI 自动化生图(Seedream 4.5);需海外网络',
|
|
433
|
+
group: 'web2api · 图片',
|
|
434
|
+
nodeTypes: ['image'],
|
|
435
|
+
needsPrompt: true,
|
|
436
|
+
order: 14,
|
|
437
|
+
platform: 'dola', operation: 'chat-auto',
|
|
438
|
+
promptMode: 'chat-auto', mediaMode: 'image', model: 'Seedream 4.5',
|
|
439
|
+
fields: [ratio_dola],
|
|
440
|
+
refFields: { image: 'referenceImages' },
|
|
441
|
+
pollIntervalMs: 1500, pollTimeoutMs: 600000,
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
id: 'web2api:chatgpt-image',
|
|
445
|
+
title: 'ChatGPT 官方',
|
|
446
|
+
description: 'ChatGPT 官方渠道(image_gen,需登录态):比例可选;风格写在提示词里',
|
|
447
|
+
group: 'web2api · 图片',
|
|
448
|
+
nodeTypes: ['image'],
|
|
449
|
+
needsPrompt: true,
|
|
450
|
+
order: 15,
|
|
451
|
+
platform: 'chatgpt', operation: 'generate-image',
|
|
452
|
+
promptMode: 'plain',
|
|
453
|
+
fields: [ratio_chatgpt],
|
|
454
|
+
refFields: { image: 'referenceImages' },
|
|
455
|
+
pollIntervalMs: 1500, pollTimeoutMs: 600000,
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
id: 'web2api:apimart-image',
|
|
459
|
+
title: 'GPT Image 2(API)',
|
|
460
|
+
description: 'APIMart 中转(GPT Image 2):比例 / 分辨率 / 张数可选',
|
|
461
|
+
group: 'web2api · 图片',
|
|
462
|
+
nodeTypes: ['image'],
|
|
463
|
+
needsPrompt: true,
|
|
464
|
+
order: 16,
|
|
465
|
+
platform: 'apimart', operation: 'generate-image',
|
|
466
|
+
promptMode: 'plain',
|
|
467
|
+
fields: [ratio_apimart, resolution_apimart, count_apimart],
|
|
468
|
+
refFields: { image: 'referenceImages' },
|
|
469
|
+
pollIntervalMs: 1500, pollTimeoutMs: 600000,
|
|
470
|
+
},
|
|
471
|
+
],
|
|
472
|
+
|
|
473
|
+
async submit(action, input) {
|
|
474
|
+
try {
|
|
475
|
+
return { taskId: await submitTask(action, input) }
|
|
476
|
+
} catch (err) {
|
|
477
|
+
return { error: err instanceof Error ? err.message : String(err) }
|
|
478
|
+
}
|
|
479
|
+
},
|
|
480
|
+
|
|
481
|
+
async poll(taskId) {
|
|
482
|
+
try {
|
|
483
|
+
return await pollTask(taskId)
|
|
484
|
+
} catch (err) {
|
|
485
|
+
// 查不到不是终态:报给用户,由任务的超时兜底
|
|
486
|
+
return { status: 'running', message: err instanceof Error ? err.message : '任务查询失败', taskId }
|
|
487
|
+
}
|
|
488
|
+
},
|
|
489
|
+
|
|
490
|
+
async cancel(taskId) {
|
|
491
|
+
await cancelTask(taskId)
|
|
492
|
+
},
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
export default provider
|
|
496
|
+
|
|
497
|
+
|