@lingjingai/lj-awb-cli 0.3.13 → 0.3.14
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.md +10 -7
- package/build/pre.mjs +2 -0
- package/package.json +1 -1
- package/packages/awb-cli/package.json +2 -2
- package/packages/awb-core/package.json +1 -1
- package/packages/awb-core/src/commands.js +21 -8
- package/packages/awb-core/src/common.js +1 -1
- package/packages/awb-core/src/output.js +160 -23
- package/packages/awb-core/src/services.js +907 -128
- package/packages/awb-core/src/standalone.js +46 -12
- package/skills/lj-awb/SKILL.md +15 -10
- package/skills/lj-awb/VERSION +1 -1
- package/skills/lj-awb/compat.json +3 -3
- package/skills/lj-awb/modules/create-contract.md +23 -17
- package/skills/lj-awb/modules/credits.md +6 -4
- package/skills/lj-awb/modules/evals.md +42 -8
- package/skills/lj-awb/modules/image.md +10 -2
- package/skills/lj-awb/modules/model.md +16 -9
- package/skills/lj-awb/modules/project.md +1 -1
- package/skills/lj-awb/modules/task-manual.md +48 -13
- package/skills/lj-awb/modules/video.md +24 -14
- package/skills/lj-awb/modules/workflows.md +26 -14
- package/skills/lj-awb/references/model-options-read.md +15 -9
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ CLI 本身只负责平台调用、参数校验、精简输出和安全确认;
|
|
|
19
19
|
| 认证 | `auth` | access key 状态、校验、保存、清空 |
|
|
20
20
|
| 账号 | `account` | 用户、团队和登录上下文 |
|
|
21
21
|
| 项目 | `project` | 项目组查询、切换、创建和更新 |
|
|
22
|
-
| 积分 | `credits` |
|
|
22
|
+
| 积分 | `credits` | 可扣积分余额、项目组预算、任务用量统计 |
|
|
23
23
|
| 模型 | `model` | 生图 / 生视频模型发现、模型参数白名单 |
|
|
24
24
|
| 上传 | `upload` | 本地图片 / 视频 / 音频上传为平台可访问素材 |
|
|
25
25
|
| 图片 | `image` | 生图估价、提交、批量提交、状态查询 |
|
|
@@ -37,7 +37,7 @@ CLI 本身只负责平台调用、参数校验、精简输出和安全确认;
|
|
|
37
37
|
默认 API 地址由代码内置,也可以通过环境变量覆盖:
|
|
38
38
|
|
|
39
39
|
```bash
|
|
40
|
-
export LINGJING_AWB_API_ORIGIN=https://animeworkbench
|
|
40
|
+
export LINGJING_AWB_API_ORIGIN=https://animeworkbench.lingjingai.cn
|
|
41
41
|
export LINGJING_AWB_ACCESS_KEY=<access_key>
|
|
42
42
|
```
|
|
43
43
|
|
|
@@ -122,6 +122,7 @@ lj-awb credits balance
|
|
|
122
122
|
lj-awb credits usage --project-group-no <no> --last-hours 24
|
|
123
123
|
lj-awb model image-models --model Banana
|
|
124
124
|
lj-awb model video-models --model Seedance
|
|
125
|
+
lj-awb model input-guide
|
|
125
126
|
lj-awb model options --model-group-code <modelGroupCode>
|
|
126
127
|
lj-awb model create-spec --model-group-code <modelGroupCode>
|
|
127
128
|
```
|
|
@@ -162,20 +163,22 @@ lj-awb doctor --verify
|
|
|
162
163
|
- `safety.supportsDryRun`:正式执行前是否可以先 `--dry-run`。
|
|
163
164
|
- `workflow.recommendedPreflight`:推荐前置步骤,例如 `doctor`、模型查询、估价和 dry-run。
|
|
164
165
|
|
|
165
|
-
|
|
166
|
+
创作任务前按三层读取模型信息:
|
|
166
167
|
|
|
167
168
|
```bash
|
|
169
|
+
lj-awb model input-guide
|
|
168
170
|
lj-awb model options --model-group-code <modelGroupCode>
|
|
169
171
|
lj-awb model create-spec --model-group-code <modelGroupCode>
|
|
170
172
|
```
|
|
171
173
|
|
|
172
|
-
`model options`
|
|
174
|
+
`model input-guide` 返回跨模型统一参数、`resources` 字段和 `reference_key` 规则。`model options` 专门返回模型参数、资源媒体约束和条件约束,例如 `params[].values`、`params[].defaultValue`、`resources[].mediaType`、`resources[].usage`、`resources[].fileTypes`、`resources[].maxFiles`、`resources[].supportLastFrameOnly`、`resources[].minDurationMs/maxDurationMs`、`constraints[].target`、`constraints[].conditions`。`model create-spec` 专门返回如何创建任务,例如 `inputRequirement`、`supportedIntents`、`preflight` 和 `examples`。默认 text 已经覆盖常用决策字段;只有脚本严格解析或需要完整嵌套结构时才追加 `-f json`。Agent 应用 `options` 选参数值、校验素材并判断联动约束,再用 `create-spec` 组装 `image create` / `video create`,不要直接把平台旧参数传给 create。上传音频是 `resources` 素材输入,具体 `audio:reference` 写法看 `input-guide` / `create-spec`;是否需要输出音效才使用 `--need-audio true/false`。
|
|
173
175
|
|
|
174
176
|
## 示例:参考图生成视频
|
|
175
177
|
|
|
176
178
|
```bash
|
|
177
179
|
lj-awb project current
|
|
178
180
|
lj-awb model video-models --model Seedance
|
|
181
|
+
lj-awb model input-guide -f json
|
|
179
182
|
lj-awb model options --model-group-code <modelGroupCode> -f json
|
|
180
183
|
lj-awb model create-spec --model-group-code <modelGroupCode> -f json
|
|
181
184
|
|
|
@@ -206,7 +209,7 @@ lj-awb task wait \
|
|
|
206
209
|
--wait-seconds 300
|
|
207
210
|
```
|
|
208
211
|
|
|
209
|
-
|
|
212
|
+
帧素材也可以直接使用平台资产 ID;是否可传尾帧以 `model options.resources[].usage` 是否包含 `last_frame` 为准:
|
|
210
213
|
|
|
211
214
|
```bash
|
|
212
215
|
lj-awb video create \
|
|
@@ -251,7 +254,7 @@ lj-awb video create \
|
|
|
251
254
|
"meta": {
|
|
252
255
|
"command": "auth status",
|
|
253
256
|
"elapsed_ms": 12,
|
|
254
|
-
"api_origin": "https://animeworkbench
|
|
257
|
+
"api_origin": "https://animeworkbench.lingjingai.cn"
|
|
255
258
|
}
|
|
256
259
|
}
|
|
257
260
|
```
|
|
@@ -269,7 +272,7 @@ lj-awb video create \
|
|
|
269
272
|
"meta": {
|
|
270
273
|
"command": "account info",
|
|
271
274
|
"elapsed_ms": 1,
|
|
272
|
-
"api_origin": "https://animeworkbench
|
|
275
|
+
"api_origin": "https://animeworkbench.lingjingai.cn"
|
|
273
276
|
}
|
|
274
277
|
}
|
|
275
278
|
```
|
package/build/pre.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
7
7
|
|
|
8
8
|
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
9
9
|
const dryRun = process.env.NPM_INSTALL_DRY_RUN === '1' || process.argv.slice(2).includes('--dry-run');
|
|
10
|
+
const forceInstall = process.env.NPM_INSTALL_FORCE === '1' || process.argv.slice(2).includes('--force');
|
|
10
11
|
|
|
11
12
|
function run(command, args, options = {}) {
|
|
12
13
|
process.stderr.write(`$ ${[command, ...args].join(' ')}\n`);
|
|
@@ -63,6 +64,7 @@ try {
|
|
|
63
64
|
'-g',
|
|
64
65
|
tarballPath,
|
|
65
66
|
'--registry=https://registry.npmjs.org/',
|
|
67
|
+
...(forceInstall ? ['--force'] : []),
|
|
66
68
|
...(dryRun ? ['--dry-run'] : []),
|
|
67
69
|
]);
|
|
68
70
|
if (dryRun) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingjingai/awb-cli-bin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.14",
|
|
4
4
|
"description": "Standalone CLI for Lingjing AWB",
|
|
5
5
|
"private": true,
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,6 +13,6 @@
|
|
|
13
13
|
"README.md"
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@lingjingai/awb-core": "0.3.
|
|
16
|
+
"@lingjingai/awb-core": "0.3.14"
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
listModels,
|
|
23
23
|
modelOptions,
|
|
24
24
|
modelCreateSpec,
|
|
25
|
+
modelInputGuide,
|
|
25
26
|
listProjectGroups,
|
|
26
27
|
normalizeRows,
|
|
27
28
|
normalizeUserInfo,
|
|
@@ -234,7 +235,7 @@ export function registerAwbCommands(cli) {
|
|
|
234
235
|
|
|
235
236
|
cli({
|
|
236
237
|
name: 'project current',
|
|
237
|
-
description: commandHelp('
|
|
238
|
+
description: commandHelp('查看云端当前项目组和项目组预算', {
|
|
238
239
|
examples: ['lj-awb project current'],
|
|
239
240
|
}),
|
|
240
241
|
args: [PROJECT_GROUP_ARG],
|
|
@@ -321,7 +322,7 @@ export function registerAwbCommands(cli) {
|
|
|
321
322
|
|
|
322
323
|
cli({
|
|
323
324
|
name: 'credits balance',
|
|
324
|
-
description: commandHelp('
|
|
325
|
+
description: commandHelp('查看可扣积分余额和项目组预算', {
|
|
325
326
|
examples: ['lj-awb credits balance', 'lj-awb credits balance --project-group-no <no>'],
|
|
326
327
|
}),
|
|
327
328
|
args: [PROJECT_GROUP_ARG],
|
|
@@ -369,12 +370,12 @@ export function registerAwbCommands(cli) {
|
|
|
369
370
|
|
|
370
371
|
cli({
|
|
371
372
|
name: 'model options',
|
|
372
|
-
description: commandHelp('查询指定模型支持的 CLI
|
|
373
|
+
description: commandHelp('查询指定模型支持的 CLI 参数、枚举值、素材约束和条件约束', {
|
|
373
374
|
examples: [
|
|
374
375
|
'lj-awb model options --model-group-code <code>',
|
|
375
376
|
'lj-awb model options --model-group-code <code> --selected-configs-json \'{"quality":"720"}\'',
|
|
376
377
|
],
|
|
377
|
-
hint: '用 options 判断 values、fileTypes、maxFiles、duration 等约束;如何组装 create 命令看 model create-spec。',
|
|
378
|
+
hint: '用 options 判断 values、fileTypes、maxFiles、duration、constraints 等约束;如何组装 create 命令看 model create-spec。',
|
|
378
379
|
}),
|
|
379
380
|
args: [
|
|
380
381
|
MODEL_GROUP_ARG,
|
|
@@ -386,11 +387,11 @@ export function registerAwbCommands(cli) {
|
|
|
386
387
|
|
|
387
388
|
cli({
|
|
388
389
|
name: 'model create-spec',
|
|
389
|
-
description: commandHelp('
|
|
390
|
+
description: commandHelp('查看指定模型如何创建任务:输入模式、素材绑定规则、示例和前置步骤', {
|
|
390
391
|
examples: [
|
|
391
392
|
'lj-awb model create-spec --model-group-code <code>',
|
|
392
393
|
],
|
|
393
|
-
hint: '创建前先用 model options
|
|
394
|
+
hint: '创建前先用 model input-guide 理解统一参数,再用 model options 查具体枚举和素材限制,最后按 create-spec 组装 image create / video create。',
|
|
394
395
|
}),
|
|
395
396
|
args: [
|
|
396
397
|
MODEL_GROUP_ARG,
|
|
@@ -399,6 +400,18 @@ export function registerAwbCommands(cli) {
|
|
|
399
400
|
func: async (_ctx, kwargs) => modelCreateSpec(kwargs),
|
|
400
401
|
});
|
|
401
402
|
|
|
403
|
+
cli({
|
|
404
|
+
name: 'model input-guide',
|
|
405
|
+
description: commandHelp('查看统一创建参数和 resources 素材绑定的通用说明', {
|
|
406
|
+
examples: [
|
|
407
|
+
'lj-awb model input-guide',
|
|
408
|
+
],
|
|
409
|
+
hint: '这是跨模型的统一参数说明;具体枚举值、文件类型、数量和条件约束仍以 model options 为准。',
|
|
410
|
+
}),
|
|
411
|
+
args: [],
|
|
412
|
+
func: async () => modelInputGuide(),
|
|
413
|
+
});
|
|
414
|
+
|
|
402
415
|
cli({
|
|
403
416
|
name: 'upload files',
|
|
404
417
|
description: commandHelp('上传本地图片 / 视频 / 音频到平台 COS,并返回 backendPath / URL', {
|
|
@@ -506,7 +519,7 @@ export function registerAwbCommands(cli) {
|
|
|
506
519
|
{ name: 'ratio', valueName: 'ratio', description: '视频比例' },
|
|
507
520
|
{ name: 'quality', valueName: 'quality', description: '清晰度,如 720' },
|
|
508
521
|
{ name: 'duration', valueName: 'seconds', description: '生成时长秒数' },
|
|
509
|
-
{ name: 'need-audio', valueName: 'bool', description: '
|
|
522
|
+
{ name: 'need-audio', valueName: 'bool', description: '是否需要输出音效;不是上传音频入口,音频素材用 --resource audio:reference=...' },
|
|
510
523
|
RESOURCE_ARG,
|
|
511
524
|
RESOURCES_JSON_ARG,
|
|
512
525
|
FEE_DRY_RUN_ARG,
|
|
@@ -532,7 +545,7 @@ export function registerAwbCommands(cli) {
|
|
|
532
545
|
{ name: 'ratio', valueName: 'ratio', description: '视频比例' },
|
|
533
546
|
{ name: 'quality', valueName: 'quality', description: '清晰度' },
|
|
534
547
|
{ name: 'duration', valueName: 'seconds', description: '生成时长秒数' },
|
|
535
|
-
{ name: 'need-audio', valueName: 'bool', description: '
|
|
548
|
+
{ name: 'need-audio', valueName: 'bool', description: '是否需要输出音效;不是上传音频入口,音频素材用 --resource audio:reference=...' },
|
|
536
549
|
RESOURCE_ARG,
|
|
537
550
|
RESOURCES_JSON_ARG,
|
|
538
551
|
TASK_RECORD_ARG,
|
|
@@ -4,7 +4,7 @@ import crypto from 'node:crypto';
|
|
|
4
4
|
import os from 'node:os';
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
|
|
7
|
-
export const DEFAULT_API_ORIGIN = 'https://animeworkbench
|
|
7
|
+
export const DEFAULT_API_ORIGIN = 'https://animeworkbench.lingjingai.cn';
|
|
8
8
|
export const API_ORIGIN = (
|
|
9
9
|
process.env.LINGJING_AWB_API_ORIGIN
|
|
10
10
|
|| process.env.ANIME_API_ORIGIN
|
|
@@ -134,6 +134,7 @@ function normalizeDryRunResult(row = {}) {
|
|
|
134
134
|
|
|
135
135
|
function normalizeDryRun(data = {}) {
|
|
136
136
|
const localFiles = Array.isArray(data.localFiles) ? data.localFiles : (data.localFile ? [data.localFile] : undefined);
|
|
137
|
+
const resourceConversions = Array.isArray(data.resourceConversions) ? data.resourceConversions : undefined;
|
|
137
138
|
return compactRecord({
|
|
138
139
|
dryRun: true,
|
|
139
140
|
action: data.action,
|
|
@@ -141,6 +142,10 @@ function normalizeDryRun(data = {}) {
|
|
|
141
142
|
...scalarRequestSummary(data.request),
|
|
142
143
|
...requestSummary(data.request),
|
|
143
144
|
localFileCount: Array.isArray(localFiles) ? localFiles.length : undefined,
|
|
145
|
+
resourceConversionCount: Array.isArray(resourceConversions) ? resourceConversions.length : undefined,
|
|
146
|
+
resourceConversion: Array.isArray(resourceConversions) && resourceConversions.length === 1
|
|
147
|
+
? `${resourceConversions[0].resource || 'resource'} ${resourceConversions[0].fromFormat}->${resourceConversions[0].toFormat}`
|
|
148
|
+
: undefined,
|
|
144
149
|
fileCount: Array.isArray(data.files) ? data.files.length : undefined,
|
|
145
150
|
assetCount: Array.isArray(data.assets) ? data.assets.length : undefined,
|
|
146
151
|
files: data.files,
|
|
@@ -159,6 +164,12 @@ function normalizeTaskSubmission(data = {}) {
|
|
|
159
164
|
projectGroupNo: data.projectGroupNo,
|
|
160
165
|
pointNo: data.pointNo,
|
|
161
166
|
points: data.points ?? data.point ?? data.costPoint ?? data.estimatePoint,
|
|
167
|
+
pointCost: data.pointCost,
|
|
168
|
+
billingPointBalance: data.billingPointBalance ?? data.teamPointBalance,
|
|
169
|
+
billingPointRemainingAfter: data.billingPointRemainingAfter ?? data.teamPointRemainingAfter,
|
|
170
|
+
projectBudgetBalance: data.projectBudgetBalance ?? data.projectPointBalance,
|
|
171
|
+
projectBudgetMax: data.projectBudgetMax ?? data.projectPointMax,
|
|
172
|
+
projectBudgetRemainingAfter: data.projectBudgetRemainingAfter ?? data.projectPointRemainingAfter,
|
|
162
173
|
uploadCount: Array.isArray(data.uploads) ? data.uploads.length : undefined,
|
|
163
174
|
nextCommand: rewriteCommandPrefix(data.nextCommand),
|
|
164
175
|
waited: data.waited ? normalizeTaskStatus(data.waited) : undefined,
|
|
@@ -178,11 +189,11 @@ function normalizeFee(data = {}) {
|
|
|
178
189
|
modelGroupCode: data.modelGroupCode,
|
|
179
190
|
projectGroupNo: data.projectGroupNo,
|
|
180
191
|
pointCost: data.pointCost,
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
192
|
+
billingPointBalance: data.billingPointBalance ?? data.teamPointBalance,
|
|
193
|
+
billingPointRemainingAfter: data.billingPointRemainingAfter ?? data.teamPointRemainingAfter,
|
|
194
|
+
projectBudgetBalance: data.projectBudgetBalance ?? data.projectPointBalance,
|
|
195
|
+
projectBudgetMax: data.projectBudgetMax ?? data.projectPointMax,
|
|
196
|
+
projectBudgetRemainingAfter: data.projectBudgetRemainingAfter ?? data.projectPointRemainingAfter,
|
|
186
197
|
});
|
|
187
198
|
}
|
|
188
199
|
|
|
@@ -194,19 +205,34 @@ function normalizeAccountInfo(data = {}) {
|
|
|
194
205
|
groupName: data.groupName,
|
|
195
206
|
currentProjectGroupNo: data.currentProjectGroupNo,
|
|
196
207
|
currentProjectGroupName: data.currentProjectGroupName,
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
208
|
+
billingPointBalance: data.billingPointBalance ?? data.teamPointBalance,
|
|
209
|
+
projectBudgetBalance: data.projectBudgetBalance ?? data.projectPointBalance,
|
|
210
|
+
projectBudgetMax: data.projectBudgetMax ?? data.projectPointMax,
|
|
200
211
|
});
|
|
201
212
|
}
|
|
202
213
|
|
|
203
214
|
function normalizeCredits(data = {}) {
|
|
204
215
|
return compactRecord({
|
|
205
|
-
|
|
216
|
+
billingPointBalance: data.billingPointBalance ?? data.teamPointBalance,
|
|
206
217
|
currentProjectGroupNo: data.currentProjectGroupNo,
|
|
207
218
|
currentProjectGroupName: data.currentProjectGroupName,
|
|
208
|
-
|
|
209
|
-
|
|
219
|
+
projectBudgetBalance: data.projectBudgetBalance ?? data.projectPointBalance,
|
|
220
|
+
projectBudgetMax: data.projectBudgetMax ?? data.projectPointMax,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function normalizeProjectSummary(data = {}) {
|
|
225
|
+
return compactRecord({
|
|
226
|
+
selected: data.selected,
|
|
227
|
+
created: data.created,
|
|
228
|
+
updated: data.updated,
|
|
229
|
+
reused: data.reused,
|
|
230
|
+
projectGroupNo: data.projectGroupNo,
|
|
231
|
+
projectGroupName: data.projectGroupName,
|
|
232
|
+
isSelected: data.isSelected,
|
|
233
|
+
projectBudgetBalance: data.projectBudgetBalance ?? data.projectPointBalance,
|
|
234
|
+
projectBudgetMax: data.projectBudgetMax ?? data.projectPointMax,
|
|
235
|
+
memberCount: data.memberCount,
|
|
210
236
|
});
|
|
211
237
|
}
|
|
212
238
|
|
|
@@ -315,6 +341,12 @@ export function normalizeOutputData(commandName, data) {
|
|
|
315
341
|
return normalizeAccountInfo(data);
|
|
316
342
|
case 'credits balance':
|
|
317
343
|
return normalizeCredits(data);
|
|
344
|
+
case 'project current':
|
|
345
|
+
case 'project use':
|
|
346
|
+
case 'project create':
|
|
347
|
+
case 'project update':
|
|
348
|
+
case 'project ensure':
|
|
349
|
+
return normalizeProjectSummary(data);
|
|
318
350
|
case 'credits usage':
|
|
319
351
|
return normalizeCreditsUsage(data);
|
|
320
352
|
case 'image status':
|
|
@@ -355,14 +387,8 @@ export function normalizeOutputData(commandName, data) {
|
|
|
355
387
|
|
|
356
388
|
export function normalizeJsonData(commandName, data) {
|
|
357
389
|
if (!isPlainObject(data)) return rewriteNested(data);
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
return normalizeAuthStatus(data);
|
|
361
|
-
case 'auth login-key':
|
|
362
|
-
return normalizeAuthLogin(data);
|
|
363
|
-
default:
|
|
364
|
-
return rewriteNested(data);
|
|
365
|
-
}
|
|
390
|
+
if (data.dryRun) return rewriteNested(data);
|
|
391
|
+
return normalizeOutputData(commandName, data);
|
|
366
392
|
}
|
|
367
393
|
|
|
368
394
|
function shortValue(value) {
|
|
@@ -451,6 +477,11 @@ function rowSummary(row) {
|
|
|
451
477
|
'taskCount',
|
|
452
478
|
'successTaskCount',
|
|
453
479
|
'pointTotal',
|
|
480
|
+
'billingPointBalance',
|
|
481
|
+
'billingPointRemainingAfter',
|
|
482
|
+
'projectBudgetBalance',
|
|
483
|
+
'projectBudgetMax',
|
|
484
|
+
'projectBudgetRemainingAfter',
|
|
454
485
|
'projectPointBalance',
|
|
455
486
|
'projectPointMax',
|
|
456
487
|
'teamPointBalance',
|
|
@@ -544,9 +575,58 @@ function textItemCount(item = {}) {
|
|
|
544
575
|
return undefined;
|
|
545
576
|
}
|
|
546
577
|
|
|
578
|
+
function textAllowValues(values = []) {
|
|
579
|
+
return Array.isArray(values) && values.length ? valueList(values) : '<none>';
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
function textConditionValue(value) {
|
|
583
|
+
if (value === '__NOT_EMPTY__') return 'present';
|
|
584
|
+
if (value === '__EMPTY__') return 'empty';
|
|
585
|
+
return value;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
function textConstraintConditions(conditions = []) {
|
|
589
|
+
if (!Array.isArray(conditions) || !conditions.length) return undefined;
|
|
590
|
+
return conditions
|
|
591
|
+
.map((item) => {
|
|
592
|
+
const key = item.key || item.configCode;
|
|
593
|
+
return key ? `${key}=${textConditionValue(item.value)}` : null;
|
|
594
|
+
})
|
|
595
|
+
.filter(Boolean)
|
|
596
|
+
.join('&');
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
const NORMAL_IMAGE_FORMATS = ['jpg', 'jpeg', 'png', 'jfif'];
|
|
600
|
+
|
|
601
|
+
function textImageFormats(item = {}) {
|
|
602
|
+
const policy = String(item.formatPolicy || '');
|
|
603
|
+
if (policy === 'normal_plus_webp') return valueList([...NORMAL_IMAGE_FORMATS, 'webp']);
|
|
604
|
+
if (policy === 'normal_without_webp') return valueList(NORMAL_IMAGE_FORMATS);
|
|
605
|
+
return valueList(item.fileTypes);
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
function textResourceFormats(item = {}) {
|
|
609
|
+
if (item.mediaType === 'IMAGE') return textImageFormats(item);
|
|
610
|
+
return valueList(item.fileTypes);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
function textWebpInput(item = {}) {
|
|
614
|
+
if (item.mediaType !== 'IMAGE') return undefined;
|
|
615
|
+
const policy = String(item.formatPolicy || '');
|
|
616
|
+
if (policy === 'normal_plus_webp') return 'accepted';
|
|
617
|
+
if (policy === 'normal_without_webp') return item.autoConvertTo ? `autoConvertTo${String(item.autoConvertTo).toUpperCase()}` : 'unsupported';
|
|
618
|
+
return undefined;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
function textResourceAutoConvert(item = {}) {
|
|
622
|
+
if (item.mediaType === 'IMAGE' && ['normal_plus_webp', 'normal_without_webp'].includes(String(item.formatPolicy || ''))) return undefined;
|
|
623
|
+
return item.autoConvertTo;
|
|
624
|
+
}
|
|
625
|
+
|
|
547
626
|
function formatModelOptionsOutput(data = {}) {
|
|
548
627
|
const params = Array.isArray(data.params) ? data.params : [];
|
|
549
628
|
const resources = Array.isArray(data.resources) ? data.resources : [];
|
|
629
|
+
const constraints = Array.isArray(data.constraints) ? data.constraints : [];
|
|
550
630
|
const lines = ['ok model options'];
|
|
551
631
|
lines.push(renderRecord(compactRecord({
|
|
552
632
|
modelGroupCode: data.modelGroupCode,
|
|
@@ -571,30 +651,48 @@ function formatModelOptionsOutput(data = {}) {
|
|
|
571
651
|
media: item.mediaType,
|
|
572
652
|
usage: item.usage,
|
|
573
653
|
sources: textSources(item.sources),
|
|
574
|
-
formats:
|
|
654
|
+
formats: textResourceFormats(item),
|
|
655
|
+
webpInput: textWebpInput(item),
|
|
656
|
+
autoConvert: textResourceAutoConvert(item),
|
|
575
657
|
files: textFileCount(item),
|
|
576
658
|
maxSizeKB: item.maxSizeKB,
|
|
577
659
|
durationMs: textDurationRange(item),
|
|
578
660
|
totalDurationMs: item.maxTotalDurationMs != null ? `<=${item.maxTotalDurationMs}` : undefined,
|
|
579
661
|
items: textItemCount(item),
|
|
580
662
|
maxPromptLength: item.maxPromptLength,
|
|
581
|
-
|
|
663
|
+
lastFrameOnly: item.supportLastFrameOnly,
|
|
582
664
|
}), [
|
|
583
665
|
'mode',
|
|
584
666
|
'media',
|
|
585
667
|
'usage',
|
|
586
668
|
'sources',
|
|
587
669
|
'formats',
|
|
670
|
+
'webpInput',
|
|
671
|
+
'autoConvert',
|
|
588
672
|
'files',
|
|
589
673
|
'maxSizeKB',
|
|
590
674
|
'durationMs',
|
|
591
675
|
'totalDurationMs',
|
|
592
676
|
'items',
|
|
593
677
|
'maxPromptLength',
|
|
594
|
-
'
|
|
678
|
+
'lastFrameOnly',
|
|
595
679
|
])}`);
|
|
596
680
|
}
|
|
597
681
|
}
|
|
682
|
+
if (constraints.length) {
|
|
683
|
+
lines.push(`constraints.count=${constraints.length}`);
|
|
684
|
+
for (const [index, item] of constraints.entries()) {
|
|
685
|
+
lines.push(`constraint[${index}]: ${renderRecord(compactRecord({
|
|
686
|
+
target: item.target,
|
|
687
|
+
targetConfig: item.targetConfigCode && item.targetConfigCode !== item.target ? item.targetConfigCode : undefined,
|
|
688
|
+
allowedValues: textAllowValues(item.allowValues),
|
|
689
|
+
when: textConstraintConditions(item.conditions),
|
|
690
|
+
effect: item.effect,
|
|
691
|
+
priority: item.priority,
|
|
692
|
+
name: item.name,
|
|
693
|
+
}), ['target', 'targetConfig', 'allowedValues', 'when', 'effect', 'priority', 'name'])}`);
|
|
694
|
+
}
|
|
695
|
+
}
|
|
598
696
|
return `${lines.join('\n')}\n`;
|
|
599
697
|
}
|
|
600
698
|
|
|
@@ -626,9 +724,10 @@ function formatModelCreateSpecOutput(data = {}) {
|
|
|
626
724
|
mode: intent.mode,
|
|
627
725
|
intent: intent.intent,
|
|
628
726
|
args: valueList(intent.requiredArgs),
|
|
727
|
+
usage: valueList(intent.resourceUsages),
|
|
629
728
|
resources: valueList(intent.resourceSyntax),
|
|
630
729
|
key: textKeyBinding(intent.promptBinding),
|
|
631
|
-
}), ['mode', 'intent', 'args', 'resources', 'key'])}`);
|
|
730
|
+
}), ['mode', 'intent', 'args', 'usage', 'resources', 'key'])}`);
|
|
632
731
|
}
|
|
633
732
|
if (examples.length) {
|
|
634
733
|
lines.push(`examples.count=${examples.length}`);
|
|
@@ -638,6 +737,36 @@ function formatModelCreateSpecOutput(data = {}) {
|
|
|
638
737
|
return `${lines.join('\n')}\n`;
|
|
639
738
|
}
|
|
640
739
|
|
|
740
|
+
function formatGuideTableRows(rows = []) {
|
|
741
|
+
return (Array.isArray(rows) ? rows : []).map((item, index) => {
|
|
742
|
+
const values = valueList(item.values);
|
|
743
|
+
return `field[${index}]: ${renderRecord(compactRecord({
|
|
744
|
+
name: item.field,
|
|
745
|
+
values,
|
|
746
|
+
desc: item.description,
|
|
747
|
+
}), ['name', 'values', 'desc'])}`;
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
function formatModelInputGuideOutput(data = {}) {
|
|
752
|
+
const lines = ['ok model input-guide'];
|
|
753
|
+
lines.push('commonFields.count=' + (Array.isArray(data.commonFields) ? data.commonFields.length : 0));
|
|
754
|
+
lines.push(...formatGuideTableRows(data.commonFields));
|
|
755
|
+
lines.push('resourceFields.count=' + (Array.isArray(data.resourceFields) ? data.resourceFields.length : 0));
|
|
756
|
+
lines.push(...formatGuideTableRows(data.resourceFields));
|
|
757
|
+
const rules = Array.isArray(data.resourceRules) ? data.resourceRules : [];
|
|
758
|
+
if (rules.length) {
|
|
759
|
+
lines.push(`resourceRules.count=${rules.length}`);
|
|
760
|
+
for (const [index, rule] of rules.entries()) lines.push(`rule[${index}]=${rule}`);
|
|
761
|
+
}
|
|
762
|
+
const referenceKeyGuide = Array.isArray(data.referenceKeyGuide) ? data.referenceKeyGuide : [];
|
|
763
|
+
if (referenceKeyGuide.length) {
|
|
764
|
+
lines.push(`referenceKey.count=${referenceKeyGuide.length}`);
|
|
765
|
+
for (const [index, item] of referenceKeyGuide.entries()) lines.push(`referenceKey[${index}]=${item}`);
|
|
766
|
+
}
|
|
767
|
+
return `${lines.join('\n')}\n`;
|
|
768
|
+
}
|
|
769
|
+
|
|
641
770
|
function defaultJsonCommand(commandName) {
|
|
642
771
|
return `${commandPrefix()} ${commandName} -f json`;
|
|
643
772
|
}
|
|
@@ -664,6 +793,7 @@ function subtitleRemoveNextCommand(commandName, normalized) {
|
|
|
664
793
|
export function formatTextOutput(commandName, data, context = {}) {
|
|
665
794
|
if (commandName === 'model options') return formatModelOptionsOutput(data);
|
|
666
795
|
if (commandName === 'model create-spec') return formatModelCreateSpecOutput(data);
|
|
796
|
+
if (commandName === 'model input-guide') return formatModelInputGuideOutput(data);
|
|
667
797
|
const normalized = normalizeOutputData(commandName, data);
|
|
668
798
|
if (!isPlainObject(normalized)) return `ok ${commandName}\nvalue=${shortValue(normalized)}\n`;
|
|
669
799
|
const lines = [`ok ${commandName}`];
|
|
@@ -689,7 +819,14 @@ export function formatTextOutput(commandName, data, context = {}) {
|
|
|
689
819
|
'status',
|
|
690
820
|
'count',
|
|
691
821
|
'resultCount',
|
|
822
|
+
'resourceConversionCount',
|
|
823
|
+
'resourceConversion',
|
|
692
824
|
'pointCost',
|
|
825
|
+
'billingPointBalance',
|
|
826
|
+
'billingPointRemainingAfter',
|
|
827
|
+
'projectBudgetBalance',
|
|
828
|
+
'projectBudgetMax',
|
|
829
|
+
'projectBudgetRemainingAfter',
|
|
693
830
|
'pointTotal',
|
|
694
831
|
'dryRun',
|
|
695
832
|
'action',
|