museav-cli 2.0.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/.github/workflows/ci.yml +19 -0
- package/.github/workflows/publish.yml +79 -0
- package/AGENTS.md +90 -0
- package/CHANGELOG.md +49 -0
- package/LICENSE +21 -0
- package/README.md +490 -0
- package/SECURITY.md +11 -0
- package/dist/client.d.ts +387 -0
- package/dist/client.js +372 -0
- package/dist/commands/assets.d.ts +14 -0
- package/dist/commands/assets.js +30 -0
- package/dist/commands/balance.d.ts +3 -0
- package/dist/commands/balance.js +11 -0
- package/dist/commands/bind-feishu.d.ts +3 -0
- package/dist/commands/bind-feishu.js +63 -0
- package/dist/commands/gen.d.ts +16 -0
- package/dist/commands/gen.js +88 -0
- package/dist/commands/image-to-template.d.ts +24 -0
- package/dist/commands/image-to-template.js +111 -0
- package/dist/commands/jobs.d.ts +11 -0
- package/dist/commands/jobs.js +27 -0
- package/dist/commands/login.d.ts +3 -0
- package/dist/commands/login.js +67 -0
- package/dist/commands/models.d.ts +3 -0
- package/dist/commands/models.js +9 -0
- package/dist/commands/products.d.ts +9 -0
- package/dist/commands/products.js +16 -0
- package/dist/commands/reverse.d.ts +3 -0
- package/dist/commands/reverse.js +16 -0
- package/dist/commands/skills.d.ts +5 -0
- package/dist/commands/skills.js +22 -0
- package/dist/commands/templates.d.ts +28 -0
- package/dist/commands/templates.js +79 -0
- package/dist/commands/upload.d.ts +9 -0
- package/dist/commands/upload.js +8 -0
- package/dist/commands/video-templates.d.ts +21 -0
- package/dist/commands/video-templates.js +71 -0
- package/dist/commands/welcome.d.ts +6 -0
- package/dist/commands/welcome.js +93 -0
- package/dist/commands/whoami.d.ts +3 -0
- package/dist/commands/whoami.js +14 -0
- package/dist/config.d.ts +31 -0
- package/dist/config.js +93 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +292 -0
- package/dist/tenant-client.d.ts +31 -0
- package/dist/tenant-client.js +84 -0
- package/package.json +55 -0
- package/src/client.ts +636 -0
- package/src/commands/assets.ts +47 -0
- package/src/commands/balance.ts +12 -0
- package/src/commands/bind-feishu.ts +77 -0
- package/src/commands/gen.ts +111 -0
- package/src/commands/image-to-template.ts +150 -0
- package/src/commands/jobs.ts +37 -0
- package/src/commands/login.ts +80 -0
- package/src/commands/models.ts +12 -0
- package/src/commands/products.ts +38 -0
- package/src/commands/reverse.ts +21 -0
- package/src/commands/skills.ts +29 -0
- package/src/commands/templates.ts +98 -0
- package/src/commands/upload.ts +18 -0
- package/src/commands/video-templates.ts +89 -0
- package/src/commands/welcome.ts +108 -0
- package/src/commands/whoami.ts +19 -0
- package/src/config.ts +114 -0
- package/src/index.ts +318 -0
- package/src/tenant-client.ts +90 -0
- package/src/types/update-notifier.d.ts +31 -0
- package/tsconfig.json +19 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
export interface GenerateOptions {
|
|
2
|
+
/** 自己写完整提示词。与 skill_slug / template_id 三选一 */
|
|
3
|
+
prompt?: string;
|
|
4
|
+
/**
|
|
5
|
+
* 用中台技能出图(技能黑盒):提示词正文在服务端展开,不下发。
|
|
6
|
+
* 查找顺序:自己的私有技能 → 所属租户的专属模板 → 公共技能库。
|
|
7
|
+
* 与 prompt / template_id 三选一。
|
|
8
|
+
*/
|
|
9
|
+
skill_slug?: string;
|
|
10
|
+
/** 配合 skill_slug 的一句业务描述,如「米白色针织衫」。不给则按技能规范自由发挥 */
|
|
11
|
+
input?: string;
|
|
12
|
+
/**
|
|
13
|
+
* 用图片模板出图(模板黑盒):提示词模板在服务端展开,确定性字符串替换,不经模型、
|
|
14
|
+
* 不产生 chat 成本。模板清单用 museav templates 查。与 prompt / skill_slug 三选一。
|
|
15
|
+
*/
|
|
16
|
+
template_id?: string;
|
|
17
|
+
/** 配合 template_id 的占位符取值,如 {artist:'王嘉尔', city:'南京'};模板没有占位符则不用传 */
|
|
18
|
+
template_fields?: Record<string, string>;
|
|
19
|
+
ratio?: string;
|
|
20
|
+
model?: string;
|
|
21
|
+
reference_image?: string;
|
|
22
|
+
quality?: 'low' | 'medium' | 'high';
|
|
23
|
+
}
|
|
24
|
+
/** 图片/文字模板清单项(GET /api/templates,template_type=image|article) */
|
|
25
|
+
export interface TemplateOption {
|
|
26
|
+
id: string;
|
|
27
|
+
category: string;
|
|
28
|
+
zh_name: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
ratio: string;
|
|
31
|
+
/** image=图片模板 / article=文字模板(视频模板在 videoTemplates()) */
|
|
32
|
+
template_type?: string;
|
|
33
|
+
sample_images?: string[] | null;
|
|
34
|
+
/** 视频模板专用:参考视频/封面(video-templates 接口返回,租户后台和 CLI 都靠它看参考) */
|
|
35
|
+
sample_video_url?: string | null;
|
|
36
|
+
sample_cover_image?: string | null;
|
|
37
|
+
/** 归属:自己租户建的 vs 平台共享的(tenant_id 为空) */
|
|
38
|
+
tenant_id: string | null;
|
|
39
|
+
generation_configs: Array<{
|
|
40
|
+
model: string;
|
|
41
|
+
prompt_template: string;
|
|
42
|
+
ref_slots?: string[];
|
|
43
|
+
params_json?: {
|
|
44
|
+
fields?: Array<{
|
|
45
|
+
key: string;
|
|
46
|
+
label: string;
|
|
47
|
+
placeholder?: string;
|
|
48
|
+
}>;
|
|
49
|
+
};
|
|
50
|
+
is_default?: boolean;
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 新建模板入参(POST /api/templates)。不传 tenant_id —— 归属完全由服务端根据
|
|
55
|
+
* 调用者身份决定:租户 apiKey 自动打自己的 tenant_id,平台管理员 JWT 建的是
|
|
56
|
+
* tenant_id=null 的平台共享模板,个人账号(无租户、非管理员)会被服务端拒绝(401)。
|
|
57
|
+
*/
|
|
58
|
+
export interface CreateTemplateInput {
|
|
59
|
+
zh_name: string;
|
|
60
|
+
category?: string;
|
|
61
|
+
description?: string;
|
|
62
|
+
ratio?: string;
|
|
63
|
+
/** image=图片模板 / article=文字模板(不传默认 image,跟中台一致) */
|
|
64
|
+
template_type?: 'image' | 'article';
|
|
65
|
+
generation_configs: Array<{
|
|
66
|
+
model: string;
|
|
67
|
+
prompt_template: string;
|
|
68
|
+
quality?: string;
|
|
69
|
+
/** 表单字段声明——按中台契约放 config 顶层(不是 params_json 里),服务端校验/渲染都读这里 */
|
|
70
|
+
fields?: Array<{
|
|
71
|
+
key: string;
|
|
72
|
+
label: string;
|
|
73
|
+
}>;
|
|
74
|
+
is_default?: boolean;
|
|
75
|
+
}>;
|
|
76
|
+
}
|
|
77
|
+
/** 新建视频模板入参(POST /api/video-templates)。视频模板字段跟图片不同:
|
|
78
|
+
* ratio/duration/model 放在 generation_configs 每项里。 */
|
|
79
|
+
export interface CreateVideoTemplateInput {
|
|
80
|
+
zh_name: string;
|
|
81
|
+
category?: string;
|
|
82
|
+
description?: string;
|
|
83
|
+
sample_video_url?: string | null;
|
|
84
|
+
sample_cover_image?: string | null;
|
|
85
|
+
generation_configs: Array<{
|
|
86
|
+
model?: string;
|
|
87
|
+
duration?: number;
|
|
88
|
+
aspect_ratio?: string;
|
|
89
|
+
prompt_template?: string;
|
|
90
|
+
is_default?: boolean;
|
|
91
|
+
}>;
|
|
92
|
+
}
|
|
93
|
+
/** 技能清单项(GET /api/skills) */
|
|
94
|
+
export interface SkillOption {
|
|
95
|
+
slug: string;
|
|
96
|
+
zh_name?: string;
|
|
97
|
+
description?: string;
|
|
98
|
+
genre?: string;
|
|
99
|
+
ratio?: string;
|
|
100
|
+
ref_required?: boolean;
|
|
101
|
+
/** 私有技能(自己建的) */
|
|
102
|
+
private?: boolean;
|
|
103
|
+
/** 所属租户的专属模板 */
|
|
104
|
+
agency?: boolean;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* 任务进度里的业务阶段。中台的口径(别自己重新发明):
|
|
108
|
+
* job.status 只有 pending / done / failed —— 业务阶段**不在 status 里**,在 steps 里。
|
|
109
|
+
* 每步 status:running=正在做(可以直接拿来渲染「正在解析图片…」)、ok=做完、fail=卡在这步。
|
|
110
|
+
* 任务结束后不会再有 running。
|
|
111
|
+
*/
|
|
112
|
+
export interface JobStep {
|
|
113
|
+
name: string;
|
|
114
|
+
status: 'running' | 'ok' | 'fail';
|
|
115
|
+
ms: number | null;
|
|
116
|
+
}
|
|
117
|
+
export interface Job {
|
|
118
|
+
id: string;
|
|
119
|
+
status: 'pending' | 'processing' | 'done' | 'failed';
|
|
120
|
+
cdn_url: string | null;
|
|
121
|
+
error: string | null;
|
|
122
|
+
trace_id?: string;
|
|
123
|
+
model?: string;
|
|
124
|
+
elapsed_ms?: number;
|
|
125
|
+
created_at?: string;
|
|
126
|
+
/** 业务阶段进度(中台 sanitizeSteps 脱敏后下发),image-to-template 这类多阶段任务才有 */
|
|
127
|
+
steps?: JobStep[];
|
|
128
|
+
}
|
|
129
|
+
export interface ReverseResult {
|
|
130
|
+
ok: boolean;
|
|
131
|
+
sculpt: Record<string, string>;
|
|
132
|
+
prompt: string;
|
|
133
|
+
prompt_cn: string;
|
|
134
|
+
style_tags: string[];
|
|
135
|
+
aspect_ratio: string;
|
|
136
|
+
zh_name?: string;
|
|
137
|
+
description?: string;
|
|
138
|
+
}
|
|
139
|
+
/** 图上一处文字的逆向结果(POST /api/image-to-template 的 text_layers 每项) */
|
|
140
|
+
export interface TextLayer {
|
|
141
|
+
role?: string;
|
|
142
|
+
content?: string;
|
|
143
|
+
position?: string;
|
|
144
|
+
font_category?: string;
|
|
145
|
+
font_weight?: string;
|
|
146
|
+
size_ratio?: number;
|
|
147
|
+
color?: string;
|
|
148
|
+
treatment?: string;
|
|
149
|
+
alignment?: string;
|
|
150
|
+
is_variable?: boolean;
|
|
151
|
+
variable?: string | null;
|
|
152
|
+
}
|
|
153
|
+
/** 模板表单字段声明(中台 7.3 的 fields 契约) */
|
|
154
|
+
export interface TemplateField {
|
|
155
|
+
key: string;
|
|
156
|
+
label: string;
|
|
157
|
+
type?: string;
|
|
158
|
+
placeholder?: string;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* POST /api/image-to-template 的结果本体(同步返回,或异步 job 完成后的 result)。
|
|
162
|
+
*
|
|
163
|
+
* 它是「读图结果 + 文字层 + 模板」三段的叠加:ReverseResult 那几个 key 照常给,
|
|
164
|
+
* 后面几个是这个接口独有的。中台的降级口径:文字层逆向 / 变量化 / 建模板任一步失败,
|
|
165
|
+
* 都只是 prompt_template=null + template_error=<原因>,sculpt / prompt_cn 照常返回——
|
|
166
|
+
* 所以 template 为 null **不等于** 整件事失败,要看 template_error。
|
|
167
|
+
*/
|
|
168
|
+
export interface ImageToTemplateResult extends ReverseResult {
|
|
169
|
+
image_category?: string;
|
|
170
|
+
text_layers?: TextLayer[];
|
|
171
|
+
/** 变量化后的提示词模具(含 {key} 占位符)。null = 这一步降级了,原因在 template_error */
|
|
172
|
+
prompt_template: string | null;
|
|
173
|
+
fields?: TemplateField[];
|
|
174
|
+
/** create_template=true 且建成时非空 */
|
|
175
|
+
template: {
|
|
176
|
+
id: string;
|
|
177
|
+
slug: string;
|
|
178
|
+
zh_name: string;
|
|
179
|
+
tenant_id: string | null;
|
|
180
|
+
reference_image?: string | null;
|
|
181
|
+
} | null;
|
|
182
|
+
/** 非 null = 模板没建成(读图结果仍然有效) */
|
|
183
|
+
template_error: string | null;
|
|
184
|
+
template_warnings?: string[];
|
|
185
|
+
reference_image?: string | null;
|
|
186
|
+
}
|
|
187
|
+
/** 异步提交后的回执(create_template=true 或 async=true 时中台返回这个,不是结果本体) */
|
|
188
|
+
export interface ImageToTemplateJob {
|
|
189
|
+
ok: boolean;
|
|
190
|
+
jobId: string;
|
|
191
|
+
status: string;
|
|
192
|
+
async: boolean;
|
|
193
|
+
}
|
|
194
|
+
/** GET /api/image-to-template?job_id=<uuid> 的返回 */
|
|
195
|
+
export interface ImageToTemplateJobResult {
|
|
196
|
+
ok: boolean;
|
|
197
|
+
job_id: string;
|
|
198
|
+
status: 'pending' | 'done' | 'failed';
|
|
199
|
+
error: string | null;
|
|
200
|
+
elapsed_ms: number | null;
|
|
201
|
+
result: ImageToTemplateResult | null;
|
|
202
|
+
}
|
|
203
|
+
/** image-to-template 入参(除图片外都可选,字段名与中台契约 §7.6 一一对应) */
|
|
204
|
+
export interface ImageToTemplateInput {
|
|
205
|
+
/** 本地文件路径,与 imageUrl 二选一 */
|
|
206
|
+
file?: string;
|
|
207
|
+
/** 图片 URL,与 file 二选一 */
|
|
208
|
+
imageUrl?: string;
|
|
209
|
+
/** 允许出现的变量白名单,可收窄。不允许模型发明白名单外的变量 */
|
|
210
|
+
variables?: string[];
|
|
211
|
+
/** 变量 → 你自己的业务叫法,只影响 fields[].label;key 永远是中台通用语义 */
|
|
212
|
+
variableLabels?: Record<string, string>;
|
|
213
|
+
/** true = 直接建好模板(走异步);false/不传 = 只回模板草稿 */
|
|
214
|
+
createTemplate?: boolean;
|
|
215
|
+
/** 模板元信息,缺省由中台生成。slug 全局唯一,撞了报错不覆盖 */
|
|
216
|
+
template?: {
|
|
217
|
+
zh_name?: string;
|
|
218
|
+
slug?: string;
|
|
219
|
+
category?: string;
|
|
220
|
+
domain?: string;
|
|
221
|
+
};
|
|
222
|
+
/** 强制异步(createTemplate=true 时本来就是异步) */
|
|
223
|
+
async?: boolean;
|
|
224
|
+
}
|
|
225
|
+
export interface ModelOption {
|
|
226
|
+
value: string;
|
|
227
|
+
label: string;
|
|
228
|
+
description?: string;
|
|
229
|
+
}
|
|
230
|
+
export interface Balance {
|
|
231
|
+
/** 数值单位是 ¥(人民币)。字段名带 usd 是历史遗留命名,不代表美元——中台侧不存在汇率换算 */
|
|
232
|
+
balance_usd: number;
|
|
233
|
+
/** 租户加价率(0.2 = 加价 20%) */
|
|
234
|
+
markup_pct: number;
|
|
235
|
+
checked_at: string;
|
|
236
|
+
}
|
|
237
|
+
export interface MeInfo {
|
|
238
|
+
id: string;
|
|
239
|
+
email: string;
|
|
240
|
+
nickname?: string;
|
|
241
|
+
role: string;
|
|
242
|
+
/** 邀请码注册的账户,若该邀请码归属某个租户,这里带出该租户的白标品牌;平台用户(无归属)为 null */
|
|
243
|
+
brand: {
|
|
244
|
+
name: string;
|
|
245
|
+
logo: string | null;
|
|
246
|
+
} | null;
|
|
247
|
+
gen_total: number;
|
|
248
|
+
gen_done: number;
|
|
249
|
+
skill_count: number;
|
|
250
|
+
generation_used: number | null;
|
|
251
|
+
generation_remaining: number | null;
|
|
252
|
+
creation_credits: number;
|
|
253
|
+
/** 租户 Key(apiKey)调用 /api/me 时返回:identity='tenant' + tenant 信息(2026-08-15) */
|
|
254
|
+
identity?: 'tenant';
|
|
255
|
+
tenant?: {
|
|
256
|
+
id: string;
|
|
257
|
+
name: string;
|
|
258
|
+
nickname: string;
|
|
259
|
+
logo: string | null;
|
|
260
|
+
};
|
|
261
|
+
/** 飞书绑定 open_id(已绑定飞书时存在,welcome 提示 agent 能认出你) */
|
|
262
|
+
feishu_open_id?: string | null;
|
|
263
|
+
}
|
|
264
|
+
export declare class StudioClient {
|
|
265
|
+
private baseUrl;
|
|
266
|
+
private authHeader;
|
|
267
|
+
constructor(opts: {
|
|
268
|
+
baseUrl: string;
|
|
269
|
+
apiKey?: string;
|
|
270
|
+
token?: string;
|
|
271
|
+
});
|
|
272
|
+
private headers;
|
|
273
|
+
private request;
|
|
274
|
+
/** 可用技能清单:私有 + 所属租户专属模板 + 公共库,服务端已按调用者权限过滤 */
|
|
275
|
+
skills(): Promise<SkillOption[]>;
|
|
276
|
+
/** 可用图片/文字模板清单:自己租户建的 + 平台共享的,服务端已按调用者权限过滤。
|
|
277
|
+
* type=image|article 二选一(不传则图片+文字都返回,跟中台默认一致)。 */
|
|
278
|
+
templates(type?: 'image' | 'article'): Promise<TemplateOption[]>;
|
|
279
|
+
/** 视频模板清单(POST /api/videos 用 template_id)。结构同图片模板的 generation_configs 形态 */
|
|
280
|
+
videoTemplates(): Promise<TemplateOption[]>;
|
|
281
|
+
/** 新建图片模板。归属(是否关联租户)由服务端根据鉴权身份决定,见 CreateTemplateInput 注释 */
|
|
282
|
+
createTemplate(input: CreateTemplateInput): Promise<TemplateOption>;
|
|
283
|
+
/** 新建视频模板。归属同图片模板:租户 apiKey 自动归租户,平台管理员归平台共享 */
|
|
284
|
+
createVideoTemplate(input: CreateVideoTemplateInput): Promise<TemplateOption>;
|
|
285
|
+
/** 提交出图任务,立即返回 jobId */
|
|
286
|
+
generate(opts: GenerateOptions): Promise<{
|
|
287
|
+
jobId: string;
|
|
288
|
+
trace_id?: string;
|
|
289
|
+
}>;
|
|
290
|
+
/** 查单个任务状态 */
|
|
291
|
+
getJob(id: string): Promise<Job>;
|
|
292
|
+
/**
|
|
293
|
+
* 列出当前身份名下的出图工作流(不传 id,走同一个 jobs 端点的集合语义)。
|
|
294
|
+
* 范围由鉴权凭证决定:个人 token 只看得到自己出的图;租户 apiKey 看得到自己业务下的全部记录。
|
|
295
|
+
*
|
|
296
|
+
* 服务端 GET /api/jobs 目前只认 id / all 两个 query 参数,固定按 created_at
|
|
297
|
+
* 倒序返回最近 50 条,不支持 limit/status 这类过滤——传了也会被忽略。
|
|
298
|
+
* 所以 limit/status 在这里做客户端过滤:先拿到这最多 50 条,再本地按 status
|
|
299
|
+
* 筛、按 limit 截断。这意味着 --limit 只能在这 50 条以内选,选不到更早的历史。
|
|
300
|
+
*/
|
|
301
|
+
listJobs(opts?: {
|
|
302
|
+
limit?: number;
|
|
303
|
+
status?: Job['status'];
|
|
304
|
+
}): Promise<Job[]>;
|
|
305
|
+
/**
|
|
306
|
+
/** 提交出图 + 自动轮询直到完成/失败。
|
|
307
|
+
* onProgress 可选,每次轮询回调一次(用于 CLI 显示进度)。
|
|
308
|
+
*/
|
|
309
|
+
generateAndWait(opts: GenerateOptions, onProgress?: (status: string) => void, intervalMs?: number, maxAttempts?: number): Promise<Job>;
|
|
310
|
+
/** 提交视频任务(POST /api/videos)——video 走独立链路,不走图片 queue */
|
|
311
|
+
generateVideo(opts: {
|
|
312
|
+
prompt?: string;
|
|
313
|
+
model?: string;
|
|
314
|
+
ratio?: string;
|
|
315
|
+
duration?: number;
|
|
316
|
+
/** 图生视频:首帧/参考图 URL(中台内部自动上传垫图后拿到 URL 再传这里) */
|
|
317
|
+
image_url?: string;
|
|
318
|
+
template_id?: string;
|
|
319
|
+
input?: string | Record<string, string>;
|
|
320
|
+
callback_url?: string;
|
|
321
|
+
}): Promise<{
|
|
322
|
+
jobId: string;
|
|
323
|
+
upstreamTaskId?: string;
|
|
324
|
+
}>;
|
|
325
|
+
/** 轮询视频任务直到完成/失败。返回 { cdn_url, status } */
|
|
326
|
+
waitVideo(jobId: string, onProgress?: (status: string) => void, intervalMs?: number, maxAttempts?: number): Promise<{
|
|
327
|
+
cdn_url: string | null;
|
|
328
|
+
status: string;
|
|
329
|
+
error?: string;
|
|
330
|
+
}>;
|
|
331
|
+
/**
|
|
332
|
+
* 图片逆向(**纯读图**):传文件路径或图片 URL,拿回 SCULPT 六要素与出图 prompt。
|
|
333
|
+
*
|
|
334
|
+
* ⚠️ 这里只发图片,一个别的字段都不发。2026-08-16 中台把「读图」和「把图做成模板」
|
|
335
|
+
* 拆成两个接口后,/api/reverse 见到 variablize / variables / variable_labels /
|
|
336
|
+
* create_template / template / async 任何一个都会直接 400(不是静默忽略)。
|
|
337
|
+
* 要做模板走 imageToTemplate()。
|
|
338
|
+
*/
|
|
339
|
+
reverse(input: {
|
|
340
|
+
file?: string;
|
|
341
|
+
imageUrl?: string;
|
|
342
|
+
}): Promise<ReverseResult>;
|
|
343
|
+
/**
|
|
344
|
+
* 上传素材(POST /api/upload-ref),返回公网直链。
|
|
345
|
+
*
|
|
346
|
+
* 图片 / 音频 / 视频都收:中台按**字节魔数**判真实类型(不信客户端声明的 MIME),
|
|
347
|
+
* 分类型限大小——图片 8MB / 音频 20MB / 视频 50MB。认不出类型直接 400。
|
|
348
|
+
* 同一归属每小时 120 个的防滥用刹车在服务端,超了返回 429。
|
|
349
|
+
*/
|
|
350
|
+
uploadRef(filePath: string): Promise<{
|
|
351
|
+
url: string;
|
|
352
|
+
media_type?: string;
|
|
353
|
+
mime?: string;
|
|
354
|
+
}>;
|
|
355
|
+
/**
|
|
356
|
+
* 图片转模板(POST /api/image-to-template):一张图 → 一个可复用的图片模板。
|
|
357
|
+
*
|
|
358
|
+
* 同步还是异步**由入参决定,不要猜**(中台契约 §7.6):
|
|
359
|
+
* createTemplate=true 或 async=true → 返回 { jobId }(这里是 ImageToTemplateJob)
|
|
360
|
+
* 两者都不给 → 直接返回结果本体(ImageToTemplateResult)
|
|
361
|
+
* 调用方用返回值里有没有 jobId 区分,见 isAsyncJob()。
|
|
362
|
+
*
|
|
363
|
+
* 这个接口没有 variablize 开关:调它本身就是「我要模板」这个意图。
|
|
364
|
+
*/
|
|
365
|
+
imageToTemplate(input: ImageToTemplateInput): Promise<ImageToTemplateResult | ImageToTemplateJob>;
|
|
366
|
+
/** 取 image-to-template 异步任务的**结果本体**(进度看 getJob 的 steps,结果在这里) */
|
|
367
|
+
getImageToTemplateResult(jobId: string): Promise<ImageToTemplateJobResult>;
|
|
368
|
+
/**
|
|
369
|
+
* 轮询 image-to-template 异步任务直到终态,返回结果本体。
|
|
370
|
+
*
|
|
371
|
+
* 进度和结果是两条通道(中台刻意分开的):阶段在 GET /api/jobs?id= 的 steps 里,
|
|
372
|
+
* 结果在 GET /api/image-to-template?job_id= 里。所以这里每轮先拉 job 看阶段
|
|
373
|
+
* (回调给 CLI 打「正在解析图片…」),到终态再去取结果。
|
|
374
|
+
*/
|
|
375
|
+
waitImageToTemplate(jobId: string, onStep?: (steps: JobStep[]) => void, intervalMs?: number, maxAttempts?: number): Promise<ImageToTemplateResult>;
|
|
376
|
+
/** 查当前登录账户信息(含租户归属品牌)。仅个人 token 鉴权可用,apiKey 调用会 401。 */
|
|
377
|
+
me(): Promise<MeInfo>;
|
|
378
|
+
/** 查可用模型列表 */
|
|
379
|
+
models(): Promise<ModelOption[]>;
|
|
380
|
+
/** 查上游余额 */
|
|
381
|
+
balance(): Promise<Balance>;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* 区分 imageToTemplate() 拿到的是异步回执还是结果本体。
|
|
385
|
+
* 判据是有没有 jobId —— 跟中台契约一致,不靠 status 字符串猜。
|
|
386
|
+
*/
|
|
387
|
+
export declare function isAsyncJob(r: ImageToTemplateResult | ImageToTemplateJob): r is ImageToTemplateJob;
|