@lingjingai/lj-awb-cli 0.3.15 → 0.4.1
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 +46 -27
- package/build/_shared.mjs +130 -0
- package/build/build.mjs +3 -0
- package/build/pre-publish.mjs +57 -0
- package/build/pre.mjs +8 -107
- package/build/prod.mjs +9 -78
- package/install.mjs +1 -0
- package/package.json +8 -3
- package/packages/awb-cli/README.md +0 -3
- package/packages/awb-cli/package.json +2 -2
- package/packages/awb-core/package.json +6 -2
- package/packages/awb-core/src/api.js +33 -64
- package/packages/awb-core/src/artifact.js +75 -6
- package/packages/awb-core/src/auth.js +1 -1
- package/packages/awb-core/src/commands.js +316 -120
- package/packages/awb-core/src/common.js +3 -2
- package/packages/awb-core/src/output.js +2353 -105
- package/packages/awb-core/src/services.js +1311 -135
- package/packages/awb-core/src/standalone.js +908 -247
- package/packages/awb-core/src/update.js +327 -0
- package/skills/lj-awb/SKILL.md +105 -76
- package/skills/lj-awb/VERSION +1 -1
- package/skills/lj-awb/compat.json +3 -3
- package/skills/lj-awb/modules/account.md +20 -7
- package/skills/lj-awb/modules/artifact/asset.md +64 -0
- package/skills/lj-awb/modules/artifact/clip.md +65 -0
- package/skills/lj-awb/modules/artifact/script.md +37 -0
- package/skills/lj-awb/modules/artifact/video.md +65 -0
- package/skills/lj-awb/modules/artifact.md +31 -52
- package/skills/lj-awb/modules/asset.md +50 -11
- package/skills/lj-awb/modules/auth.md +10 -4
- package/skills/lj-awb/modules/create-contract.md +25 -13
- package/skills/lj-awb/modules/create.md +37 -0
- package/skills/lj-awb/modules/credits.md +6 -0
- package/skills/lj-awb/modules/driver.md +126 -0
- package/skills/lj-awb/modules/evals.md +84 -36
- package/skills/lj-awb/modules/image.md +22 -13
- package/skills/lj-awb/modules/model.md +34 -33
- package/skills/lj-awb/modules/project.md +7 -0
- package/skills/lj-awb/modules/subject.md +28 -7
- package/skills/lj-awb/modules/task-manual.md +32 -28
- package/skills/lj-awb/modules/task.md +70 -8
- package/skills/lj-awb/modules/upload.md +16 -2
- package/skills/lj-awb/modules/video.md +33 -29
- package/skills/lj-awb/modules/workflows.md +232 -169
- package/skills/lj-awb/references/error-codes.md +109 -0
- package/skills/lj-awb/references/model-options-read.md +25 -17
- package/skills/lj-awb/references/output-fields.md +119 -0
- package/skills/lj-awb/scripts/resolve-lj-awb-cmd.sh +106 -4
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { Chalk } from 'chalk';
|
|
2
|
+
import Table from 'cli-table3';
|
|
3
|
+
|
|
4
|
+
const CHALK = new Chalk({ level: 1 });
|
|
5
|
+
|
|
1
6
|
function isPlainObject(value) {
|
|
2
7
|
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
3
8
|
}
|
|
@@ -47,6 +52,7 @@ function requestSummary(request = {}) {
|
|
|
47
52
|
const promptParams = request.promptParams || {};
|
|
48
53
|
return compactRecord({
|
|
49
54
|
requestSource: request.requestSource,
|
|
55
|
+
modelCode: request.modelCode,
|
|
50
56
|
modelGroupCode: request.modelGroupCode,
|
|
51
57
|
projectGroupNo: request.projectGroupNo,
|
|
52
58
|
customBizId: request.customBizId,
|
|
@@ -185,8 +191,17 @@ function normalizeTaskSubmission(data = {}) {
|
|
|
185
191
|
function normalizeSubtitleSubmission(data = {}) {
|
|
186
192
|
return compactRecord({
|
|
187
193
|
submitted: data.submitted,
|
|
188
|
-
|
|
189
|
-
|
|
194
|
+
taskId: data.taskId,
|
|
195
|
+
taskType: data.taskType,
|
|
196
|
+
sourceTaskId: data.sourceTaskId,
|
|
197
|
+
projectGroupNo: data.projectGroupNo,
|
|
198
|
+
pointCost: data.pointCost,
|
|
199
|
+
billingPointBalance: data.billingPointBalance ?? data.teamPointBalance,
|
|
200
|
+
billingPointRemainingAfter: data.billingPointRemainingAfter ?? data.teamPointRemainingAfter,
|
|
201
|
+
projectBudgetBalance: data.projectBudgetBalance ?? data.projectPointBalance,
|
|
202
|
+
projectBudgetMax: data.projectBudgetMax ?? data.projectPointMax,
|
|
203
|
+
projectBudgetRemainingAfter: data.projectBudgetRemainingAfter ?? data.projectPointRemainingAfter,
|
|
204
|
+
nextCommand: rewriteCommandPrefix(data.nextCommand),
|
|
190
205
|
});
|
|
191
206
|
}
|
|
192
207
|
|
|
@@ -293,11 +308,31 @@ function normalizeSubject(data = {}) {
|
|
|
293
308
|
elementId: data.elementId,
|
|
294
309
|
subjectId: data.subjectId,
|
|
295
310
|
externalId: data.externalId,
|
|
311
|
+
modelCode: data.modelCode ?? data.request?.modelCode ?? data.subject?.modelCode,
|
|
296
312
|
status: data.status,
|
|
313
|
+
taskStatus: data.taskStatus ?? data.subject?.taskStatus,
|
|
314
|
+
errorMessage: data.errorMessage ?? data.subject?.errorMessage,
|
|
315
|
+
isTerminal: data.isTerminal ?? data.subject?.isTerminal,
|
|
297
316
|
nextRefSubject: data.nextRefSubject,
|
|
298
317
|
});
|
|
299
318
|
}
|
|
300
319
|
|
|
320
|
+
function normalizeSubjectVoice(data = {}) {
|
|
321
|
+
return compactRecord({
|
|
322
|
+
created: data.created,
|
|
323
|
+
name: data.name,
|
|
324
|
+
voiceRecordId: data.voiceRecordId,
|
|
325
|
+
reqTaskId: data.reqTaskId,
|
|
326
|
+
voiceId: data.voiceId ?? data.externalId,
|
|
327
|
+
externalId: data.externalId,
|
|
328
|
+
status: data.status,
|
|
329
|
+
taskStatus: data.taskStatus ?? data.voice?.taskStatus,
|
|
330
|
+
errorMessage: data.errorMessage ?? data.voice?.errorMessage,
|
|
331
|
+
isTerminal: data.isTerminal ?? data.voice?.isTerminal,
|
|
332
|
+
nextVoiceArg: data.nextVoiceArg,
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
|
|
301
336
|
function normalizeAsset(data = {}) {
|
|
302
337
|
return compactRecord({
|
|
303
338
|
created: data.created,
|
|
@@ -305,6 +340,7 @@ function normalizeAsset(data = {}) {
|
|
|
305
340
|
registered: data.registered,
|
|
306
341
|
groupId: data.groupId,
|
|
307
342
|
assetId: data.assetId,
|
|
343
|
+
platform: data.platform,
|
|
308
344
|
name: data.name,
|
|
309
345
|
projectName: data.projectName,
|
|
310
346
|
assetPath: data.assetPath,
|
|
@@ -323,26 +359,156 @@ function normalizeList(data = {}, keys) {
|
|
|
323
359
|
});
|
|
324
360
|
}
|
|
325
361
|
|
|
362
|
+
function normalizeArtifactList(commandName, data) {
|
|
363
|
+
if (Array.isArray(data)) {
|
|
364
|
+
return compactRecord({ count: data.length, items: cleanNested(data) });
|
|
365
|
+
}
|
|
366
|
+
if (!isPlainObject(data)) return cleanNested(data);
|
|
367
|
+
const arrayKey = Object.keys(data).find((key) => Array.isArray(data[key]));
|
|
368
|
+
if (arrayKey) {
|
|
369
|
+
return compactRecord({
|
|
370
|
+
count: data.count ?? data[arrayKey].length,
|
|
371
|
+
[arrayKey]: cleanNested(data[arrayKey]),
|
|
372
|
+
...Object.fromEntries(
|
|
373
|
+
Object.entries(data)
|
|
374
|
+
.filter(([key]) => key !== arrayKey && key !== 'raw')
|
|
375
|
+
.map(([key, value]) => [key, cleanNested(value)]),
|
|
376
|
+
),
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
return cleanNested(data);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function normalizeArtifactRecord(data) {
|
|
383
|
+
if (!isPlainObject(data)) return cleanNested(data);
|
|
384
|
+
const out = compactRecord({
|
|
385
|
+
id: data.id,
|
|
386
|
+
projectId: data.projectId,
|
|
387
|
+
rowKind: data.rowKind,
|
|
388
|
+
entityKey: data.entityKey,
|
|
389
|
+
parentKey: data.parentKey,
|
|
390
|
+
sortOrder: data.sortOrder,
|
|
391
|
+
actorKey: data.actorKey,
|
|
392
|
+
propKey: data.propKey,
|
|
393
|
+
locationKey: data.locationKey,
|
|
394
|
+
stateKey: data.stateKey,
|
|
395
|
+
episodeId: data.episodeId,
|
|
396
|
+
sceneId: data.sceneId,
|
|
397
|
+
clipId: data.clipId,
|
|
398
|
+
videoEpisodeId: data.videoEpisodeId,
|
|
399
|
+
status: data.status,
|
|
400
|
+
title: data.title,
|
|
401
|
+
name: data.name,
|
|
402
|
+
displayName: data.displayName,
|
|
403
|
+
description: data.description,
|
|
404
|
+
});
|
|
405
|
+
for (const [key, value] of Object.entries(data)) {
|
|
406
|
+
if (key in out) continue;
|
|
407
|
+
if (Array.isArray(value)) out[`${key}Count`] = value.length;
|
|
408
|
+
else if (!isPlainObject(value)) out[key] = value;
|
|
409
|
+
}
|
|
410
|
+
return cleanNested(out);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
function normalizeArtifactFull(data) {
|
|
414
|
+
if (!isPlainObject(data)) return cleanNested(data);
|
|
415
|
+
const out = compactRecord({
|
|
416
|
+
projectId: data.projectId,
|
|
417
|
+
id: data.id,
|
|
418
|
+
title: data.title,
|
|
419
|
+
status: data.status,
|
|
420
|
+
});
|
|
421
|
+
for (const [key, value] of Object.entries(data)) {
|
|
422
|
+
if (Array.isArray(value)) out[`${key}Count`] = value.length;
|
|
423
|
+
else if (isPlainObject(value)) {
|
|
424
|
+
const innerKey = Object.keys(value).find((k) => Array.isArray(value[k]));
|
|
425
|
+
if (innerKey) out[`${key}.${innerKey}Count`] = value[innerKey].length;
|
|
426
|
+
} else if (!(key in out)) out[key] = value;
|
|
427
|
+
}
|
|
428
|
+
return out;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
function normalizeArtifactImport(data = {}) {
|
|
432
|
+
if (!isPlainObject(data)) return cleanNested(data);
|
|
433
|
+
return compactRecord({
|
|
434
|
+
imported: data.imported,
|
|
435
|
+
dryRun: data.dryRun,
|
|
436
|
+
action: data.action,
|
|
437
|
+
projectId: data.projectId,
|
|
438
|
+
sourceFile: data.sourceFile,
|
|
439
|
+
inputDir: data.inputDir,
|
|
440
|
+
inputFile: data.inputFile,
|
|
441
|
+
rowCount: data.rowCount,
|
|
442
|
+
actorCount: data.actorCount,
|
|
443
|
+
propCount: data.propCount,
|
|
444
|
+
locationCount: data.locationCount,
|
|
445
|
+
episodeCount: data.episodeCount,
|
|
446
|
+
sceneCount: data.sceneCount,
|
|
447
|
+
clipCount: data.clipCount,
|
|
448
|
+
batchCount: Array.isArray(data.batch) ? data.batch.length : undefined,
|
|
449
|
+
rowsByKind: data.rowsByKind,
|
|
450
|
+
files: isPlainObject(data.files)
|
|
451
|
+
? compactRecord({
|
|
452
|
+
actors: data.files.actorsFile,
|
|
453
|
+
props: data.files.propsFile,
|
|
454
|
+
locations: data.files.locationsFile,
|
|
455
|
+
})
|
|
456
|
+
: undefined,
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function normalizeArtifactWrite(data) {
|
|
461
|
+
if (!isPlainObject(data)) return cleanNested(data);
|
|
462
|
+
return normalizeArtifactRecord(data);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
function normalizeArtifactDelete(data) {
|
|
466
|
+
if (!isPlainObject(data)) return cleanNested(data);
|
|
467
|
+
return compactRecord({
|
|
468
|
+
deleted: data.deleted ?? true,
|
|
469
|
+
action: data.action,
|
|
470
|
+
projectId: data.projectId,
|
|
471
|
+
key: data.key,
|
|
472
|
+
stateKey: data.stateKey,
|
|
473
|
+
episodeId: data.episodeId,
|
|
474
|
+
sceneId: data.sceneId,
|
|
475
|
+
clipId: data.clipId,
|
|
476
|
+
videoEpisodeId: data.videoEpisodeId,
|
|
477
|
+
rowKind: data.rowKind,
|
|
478
|
+
entityKey: data.entityKey,
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
function normalizeArtifactStatus(data) {
|
|
483
|
+
if (!isPlainObject(data)) return cleanNested(data);
|
|
484
|
+
return compactRecord({
|
|
485
|
+
updated: data.updated ?? true,
|
|
486
|
+
videoEpisodeId: data.videoEpisodeId ?? data.id,
|
|
487
|
+
status: data.status,
|
|
488
|
+
messageCount: Array.isArray(data.messages) ? data.messages.length : undefined,
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
|
|
326
492
|
export function normalizeOutputData(commandName, data) {
|
|
327
493
|
if (!isPlainObject(data)) return cleanNested(data);
|
|
328
494
|
switch (commandName) {
|
|
329
495
|
case 'auth status':
|
|
330
496
|
case 'auth verify':
|
|
331
497
|
return normalizeAuthStatus(data);
|
|
332
|
-
case 'auth login
|
|
498
|
+
case 'auth login':
|
|
333
499
|
return normalizeAuthLogin(data);
|
|
334
500
|
default:
|
|
335
501
|
break;
|
|
336
502
|
}
|
|
337
503
|
if (data.dryRun) return normalizeDryRun(data);
|
|
338
504
|
switch (commandName) {
|
|
339
|
-
case 'image
|
|
340
|
-
case 'video
|
|
505
|
+
case 'create image':
|
|
506
|
+
case 'create video':
|
|
341
507
|
return normalizeTaskSubmission(data);
|
|
342
|
-
case 'video
|
|
508
|
+
case 'create video-subtitle-removal':
|
|
343
509
|
return normalizeSubtitleSubmission(data);
|
|
344
|
-
case 'image
|
|
345
|
-
case 'video
|
|
510
|
+
case 'create image-fee':
|
|
511
|
+
case 'create video-fee':
|
|
346
512
|
return normalizeFee(data);
|
|
347
513
|
case 'account info':
|
|
348
514
|
return normalizeAccountInfo(data);
|
|
@@ -356,20 +522,24 @@ export function normalizeOutputData(commandName, data) {
|
|
|
356
522
|
return normalizeProjectSummary(data);
|
|
357
523
|
case 'credits usage':
|
|
358
524
|
return normalizeCreditsUsage(data);
|
|
359
|
-
case 'image
|
|
360
|
-
case 'video
|
|
525
|
+
case 'task image-status':
|
|
526
|
+
case 'task video-status':
|
|
361
527
|
case 'task wait':
|
|
362
|
-
case 'video
|
|
528
|
+
case 'task video-subtitle-status':
|
|
363
529
|
return normalizeTaskStatus(data);
|
|
364
|
-
case 'subject
|
|
365
|
-
case 'subject
|
|
530
|
+
case 'create subject':
|
|
531
|
+
case 'create subject-wait':
|
|
366
532
|
return normalizeSubject(data);
|
|
367
|
-
case '
|
|
368
|
-
case '
|
|
369
|
-
|
|
533
|
+
case 'create subject-voice':
|
|
534
|
+
case 'create subject-voice-wait':
|
|
535
|
+
return normalizeSubjectVoice(data);
|
|
536
|
+
case 'create asset-group':
|
|
537
|
+
case 'create asset-group-update':
|
|
538
|
+
case 'create asset':
|
|
370
539
|
return normalizeAsset(data);
|
|
371
540
|
case 'model image-models':
|
|
372
541
|
case 'model video-models':
|
|
542
|
+
case 'model asset-review-models':
|
|
373
543
|
return normalizeList(data, ['models', 'items', 'rows']);
|
|
374
544
|
case 'account teams':
|
|
375
545
|
return normalizeList(data, ['teams']);
|
|
@@ -381,15 +551,118 @@ export function normalizeOutputData(commandName, data) {
|
|
|
381
551
|
return normalizeList(data, ['tasks']);
|
|
382
552
|
case 'task records':
|
|
383
553
|
return normalizeList(data, ['records']);
|
|
384
|
-
case 'asset
|
|
554
|
+
case 'create asset-groups':
|
|
385
555
|
return normalizeList(data, ['groups']);
|
|
386
|
-
case 'asset
|
|
556
|
+
case 'create asset-match-actor':
|
|
387
557
|
return normalizeList(data, ['matches']);
|
|
388
|
-
case 'subject
|
|
558
|
+
case 'create subject-list':
|
|
389
559
|
return normalizeList(data, ['subjects']);
|
|
560
|
+
case 'create subject-voice-list':
|
|
561
|
+
return normalizeList(data, ['voices']);
|
|
562
|
+
case 'update':
|
|
563
|
+
return normalizeUpdateResult(data);
|
|
390
564
|
default:
|
|
391
|
-
|
|
565
|
+
break;
|
|
392
566
|
}
|
|
567
|
+
if (commandName?.startsWith('artifact ')) {
|
|
568
|
+
return normalizeArtifactByCommand(commandName, data);
|
|
569
|
+
}
|
|
570
|
+
return cleanNested(data);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
const ARTIFACT_LIST_COMMANDS = new Set([
|
|
574
|
+
'artifact script rows',
|
|
575
|
+
'artifact script children',
|
|
576
|
+
'artifact asset actors',
|
|
577
|
+
'artifact asset props',
|
|
578
|
+
'artifact asset locations',
|
|
579
|
+
'artifact video episodes',
|
|
580
|
+
'artifact video scenes',
|
|
581
|
+
'artifact video clips',
|
|
582
|
+
'artifact clip episodes',
|
|
583
|
+
]);
|
|
584
|
+
|
|
585
|
+
const ARTIFACT_RECORD_COMMANDS = new Set([
|
|
586
|
+
'artifact script document',
|
|
587
|
+
'artifact script row',
|
|
588
|
+
'artifact asset actor',
|
|
589
|
+
'artifact asset prop',
|
|
590
|
+
'artifact asset location',
|
|
591
|
+
'artifact video episode',
|
|
592
|
+
'artifact video scene',
|
|
593
|
+
'artifact video clip',
|
|
594
|
+
'artifact clip episode',
|
|
595
|
+
'artifact clip episode-by-id',
|
|
596
|
+
]);
|
|
597
|
+
|
|
598
|
+
const ARTIFACT_FULL_COMMANDS = new Set([
|
|
599
|
+
'artifact script get',
|
|
600
|
+
'artifact asset get',
|
|
601
|
+
'artifact video get',
|
|
602
|
+
'artifact clip get',
|
|
603
|
+
]);
|
|
604
|
+
|
|
605
|
+
const ARTIFACT_IMPORT_COMMANDS = new Set([
|
|
606
|
+
'artifact script import',
|
|
607
|
+
'artifact asset import',
|
|
608
|
+
'artifact video import-storyboard',
|
|
609
|
+
'artifact clip upsert-batch',
|
|
610
|
+
]);
|
|
611
|
+
|
|
612
|
+
const ARTIFACT_WRITE_COMMANDS = new Set([
|
|
613
|
+
'artifact script upsert-row',
|
|
614
|
+
'artifact asset upsert-actor',
|
|
615
|
+
'artifact asset upsert-prop',
|
|
616
|
+
'artifact asset upsert-location',
|
|
617
|
+
'artifact asset upsert-actor-state',
|
|
618
|
+
'artifact asset upsert-prop-state',
|
|
619
|
+
'artifact asset upsert-location-state',
|
|
620
|
+
'artifact video upsert-episode',
|
|
621
|
+
'artifact video upsert-scene',
|
|
622
|
+
'artifact video upsert-clip',
|
|
623
|
+
'artifact video update-clip-urls',
|
|
624
|
+
'artifact clip upsert-episode',
|
|
625
|
+
]);
|
|
626
|
+
|
|
627
|
+
const ARTIFACT_DELETE_COMMANDS = new Set([
|
|
628
|
+
'artifact script delete-row',
|
|
629
|
+
'artifact asset delete-actor',
|
|
630
|
+
'artifact asset delete-prop',
|
|
631
|
+
'artifact asset delete-location',
|
|
632
|
+
'artifact asset delete-actor-state',
|
|
633
|
+
'artifact asset delete-prop-state',
|
|
634
|
+
'artifact asset delete-location-state',
|
|
635
|
+
'artifact video delete-episode',
|
|
636
|
+
'artifact video delete-scene',
|
|
637
|
+
'artifact video delete-clip',
|
|
638
|
+
'artifact clip delete-episode',
|
|
639
|
+
]);
|
|
640
|
+
|
|
641
|
+
function normalizeArtifactByCommand(commandName, data) {
|
|
642
|
+
if (ARTIFACT_LIST_COMMANDS.has(commandName)) return normalizeArtifactList(commandName, data);
|
|
643
|
+
if (ARTIFACT_RECORD_COMMANDS.has(commandName)) return normalizeArtifactRecord(data);
|
|
644
|
+
if (ARTIFACT_FULL_COMMANDS.has(commandName)) return normalizeArtifactFull(data);
|
|
645
|
+
if (ARTIFACT_IMPORT_COMMANDS.has(commandName)) return normalizeArtifactImport(data);
|
|
646
|
+
if (ARTIFACT_WRITE_COMMANDS.has(commandName)) return normalizeArtifactWrite(data);
|
|
647
|
+
if (ARTIFACT_DELETE_COMMANDS.has(commandName)) return normalizeArtifactDelete(data);
|
|
648
|
+
if (commandName === 'artifact clip update-status') return normalizeArtifactStatus(data);
|
|
649
|
+
return cleanNested(data);
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
function normalizeUpdateResult(data = {}) {
|
|
653
|
+
return compactRecord({
|
|
654
|
+
checked: data.checked,
|
|
655
|
+
updated: data.updated,
|
|
656
|
+
updateAvailable: data.updateAvailable,
|
|
657
|
+
packageName: data.packageName,
|
|
658
|
+
previousVersion: data.previousVersion,
|
|
659
|
+
currentVersion: data.currentVersion,
|
|
660
|
+
latestVersion: data.latestVersion,
|
|
661
|
+
command: rewriteCommandPrefix(data.command),
|
|
662
|
+
skillUpdated: data.skillUpdated,
|
|
663
|
+
restartRecommended: data.restartRecommended,
|
|
664
|
+
message: data.message,
|
|
665
|
+
});
|
|
393
666
|
}
|
|
394
667
|
|
|
395
668
|
export function normalizeJsonData(commandName, data) {
|
|
@@ -409,6 +682,21 @@ function shortValue(value) {
|
|
|
409
682
|
return text.length > 120 ? `${text.slice(0, 117)}...` : text;
|
|
410
683
|
}
|
|
411
684
|
|
|
685
|
+
function formatPercent(value) {
|
|
686
|
+
if (value === undefined || value === null || value === '') return '';
|
|
687
|
+
const number = Number(value);
|
|
688
|
+
if (!Number.isFinite(number)) return '';
|
|
689
|
+
const percent = number > 1 ? number : number * 100;
|
|
690
|
+
const rounded = Math.round(percent * 10) / 10;
|
|
691
|
+
const text = Number.isInteger(rounded) ? String(rounded) : rounded.toFixed(1);
|
|
692
|
+
return `${text}%`;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
function shortRecordValue(key, value) {
|
|
696
|
+
if (key === 'successRate') return formatPercent(value) || shortValue(value);
|
|
697
|
+
return shortValue(value);
|
|
698
|
+
}
|
|
699
|
+
|
|
412
700
|
function valueList(values, limit = 12) {
|
|
413
701
|
if (!Array.isArray(values) || !values.length) return undefined;
|
|
414
702
|
const items = values
|
|
@@ -428,7 +716,43 @@ function renderRecord(record, preferredKeys = [], excludedKeys = []) {
|
|
|
428
716
|
...preferredKeys.filter((key) => !excluded.has(key) && record[key] !== undefined),
|
|
429
717
|
...Object.keys(record).filter((key) => !excluded.has(key) && !preferredKeys.includes(key) && !Array.isArray(record[key]) && !isPlainObject(record[key])),
|
|
430
718
|
];
|
|
431
|
-
return keys.map((key) => `${key}=${
|
|
719
|
+
return keys.map((key) => `${key}=${shortRecordValue(key, record[key])}`).join(' ');
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
function recordScalarKeys(record, preferredKeys = [], excludedKeys = []) {
|
|
723
|
+
const excluded = new Set(excludedKeys);
|
|
724
|
+
return [
|
|
725
|
+
...preferredKeys.filter((key) => !excluded.has(key) && record[key] !== undefined),
|
|
726
|
+
...Object.keys(record).filter((key) => !excluded.has(key) && !preferredKeys.includes(key) && !Array.isArray(record[key]) && !isPlainObject(record[key])),
|
|
727
|
+
];
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
function pushSectionRecord(lines, title, record, preferredKeys = []) {
|
|
731
|
+
const compacted = compactRecord(record);
|
|
732
|
+
lines.push(`${title}:`);
|
|
733
|
+
for (const key of recordScalarKeys(compacted, preferredKeys)) {
|
|
734
|
+
lines.push(` ${key}=${shortRecordValue(key, compacted[key])}`);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
function pushSectionCount(lines, title, count) {
|
|
739
|
+
lines.push(`${title}:`);
|
|
740
|
+
lines.push(` count=${count}`);
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
function pushSectionKeyValue(lines, key, value) {
|
|
744
|
+
if (value === undefined || value === null || value === '') return;
|
|
745
|
+
lines.push(` ${key}=${value}`);
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
function pushSectionItem(lines, index, value) {
|
|
749
|
+
if (value === undefined || value === null || value === '') return;
|
|
750
|
+
lines.push(` [${index}]=${value}`);
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
function pushSectionRecordItem(lines, index, record, preferredKeys = []) {
|
|
754
|
+
const rendered = renderRecord(compactRecord(record), preferredKeys);
|
|
755
|
+
if (rendered) lines.push(` [${index}]: ${rendered}`);
|
|
432
756
|
}
|
|
433
757
|
|
|
434
758
|
function firstList(data) {
|
|
@@ -448,10 +772,13 @@ function rowSummary(row) {
|
|
|
448
772
|
'remoteTaskId',
|
|
449
773
|
'taskType',
|
|
450
774
|
'modelGroupCode',
|
|
775
|
+
'platform',
|
|
451
776
|
'provider',
|
|
452
777
|
'displayName',
|
|
778
|
+
'modelDesc',
|
|
453
779
|
'modelStatus',
|
|
454
780
|
'taskQueueNum',
|
|
781
|
+
'successRate',
|
|
455
782
|
'feeCalcType',
|
|
456
783
|
'inputModes',
|
|
457
784
|
'params',
|
|
@@ -508,7 +835,10 @@ function rowSummary(row) {
|
|
|
508
835
|
'imageUrl',
|
|
509
836
|
'subjectId',
|
|
510
837
|
'elementId',
|
|
838
|
+
'voiceRecordId',
|
|
839
|
+
'voiceId',
|
|
511
840
|
'externalId',
|
|
841
|
+
'nextVoiceArg',
|
|
512
842
|
'label',
|
|
513
843
|
'assetPath',
|
|
514
844
|
'isPrimary',
|
|
@@ -580,11 +910,11 @@ function rowSummary(row) {
|
|
|
580
910
|
if (Array.isArray(value) && value.length === 0) return false;
|
|
581
911
|
return true;
|
|
582
912
|
})
|
|
583
|
-
.map((key) => `${key}=${
|
|
913
|
+
.map((key) => `${key}=${shortRecordValue(key, row[key])}`)
|
|
584
914
|
.join(' ');
|
|
585
915
|
}
|
|
586
916
|
|
|
587
|
-
function
|
|
917
|
+
function textValueShapes(values = []) {
|
|
588
918
|
const names = {
|
|
589
919
|
local_file: 'file',
|
|
590
920
|
http_url: 'url',
|
|
@@ -617,8 +947,30 @@ function textItemCount(item = {}) {
|
|
|
617
947
|
return undefined;
|
|
618
948
|
}
|
|
619
949
|
|
|
950
|
+
function textCountRange(item = {}) {
|
|
951
|
+
if (item.minCount != null && item.maxCount != null && item.minCount === item.maxCount) return String(item.maxCount);
|
|
952
|
+
if (item.minCount != null && item.maxCount != null) return `${item.minCount}..${item.maxCount}`;
|
|
953
|
+
if (item.minCount != null) return `>=${item.minCount}`;
|
|
954
|
+
if (item.maxCount != null) return `<=${item.maxCount}`;
|
|
955
|
+
return item.value;
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
function textLimitSummary(item = {}) {
|
|
959
|
+
if (!isPlainObject(item)) return undefined;
|
|
960
|
+
const parts = [];
|
|
961
|
+
const files = textFileCount(item);
|
|
962
|
+
const duration = textDurationRange(item);
|
|
963
|
+
const items = textItemCount(item);
|
|
964
|
+
if (files) parts.push(`files${files}`);
|
|
965
|
+
if (duration) parts.push(`durationMs${duration}`);
|
|
966
|
+
if (item.maxTotalDurationMs != null) parts.push(`totalDurationMs<=${item.maxTotalDurationMs}`);
|
|
967
|
+
if (item.maxSizeKB != null) parts.push(`maxSizeKB<=${item.maxSizeKB}`);
|
|
968
|
+
if (items) parts.push(`items${items}`);
|
|
969
|
+
return parts.length ? parts.join('|') : undefined;
|
|
970
|
+
}
|
|
971
|
+
|
|
620
972
|
function textAllowValues(values = []) {
|
|
621
|
-
return Array.isArray(values) && values.length ? valueList(values) :
|
|
973
|
+
return Array.isArray(values) && values.length ? valueList(values) : undefined;
|
|
622
974
|
}
|
|
623
975
|
|
|
624
976
|
function textConditionValue(value) {
|
|
@@ -632,6 +984,7 @@ function textConstraintConditions(conditions = []) {
|
|
|
632
984
|
return conditions
|
|
633
985
|
.map((item) => {
|
|
634
986
|
const key = item.key || item.configCode;
|
|
987
|
+
if (item.meaning === 'count') return key ? `${key}=${textCountRange(item)}` : null;
|
|
635
988
|
return key ? `${key}=${textConditionValue(item.value)}` : null;
|
|
636
989
|
})
|
|
637
990
|
.filter(Boolean)
|
|
@@ -670,70 +1023,72 @@ function formatModelOptionsOutput(data = {}) {
|
|
|
670
1023
|
const resources = Array.isArray(data.resources) ? data.resources : [];
|
|
671
1024
|
const constraints = Array.isArray(data.constraints) ? data.constraints : [];
|
|
672
1025
|
const lines = ['ok model options'];
|
|
673
|
-
lines
|
|
1026
|
+
pushSectionRecord(lines, 'summary', {
|
|
674
1027
|
modelGroupCode: data.modelGroupCode,
|
|
675
1028
|
taskKind: data.taskKind,
|
|
676
|
-
}
|
|
677
|
-
lines
|
|
1029
|
+
}, ['modelGroupCode', 'taskKind']);
|
|
1030
|
+
pushSectionCount(lines, 'params', params.length);
|
|
678
1031
|
for (const [index, param] of params.entries()) {
|
|
679
|
-
lines
|
|
1032
|
+
pushSectionRecordItem(lines, index, {
|
|
680
1033
|
key: param.key,
|
|
681
1034
|
type: param.valueType,
|
|
682
1035
|
values: valueList(param.values),
|
|
683
1036
|
default: param.defaultValue,
|
|
684
1037
|
maxLength: param.maxLength,
|
|
685
1038
|
required: param.required,
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
if (resources.length) {
|
|
689
|
-
lines.push(`resources.count=${resources.length}`);
|
|
690
|
-
for (const [index, item] of resources.entries()) {
|
|
691
|
-
lines.push(`resource[${index}]: ${renderRecord(compactRecord({
|
|
692
|
-
mode: item.mode,
|
|
693
|
-
media: item.mediaType,
|
|
694
|
-
usage: item.usage,
|
|
695
|
-
sources: textSources(item.sources),
|
|
696
|
-
formats: textResourceFormats(item),
|
|
697
|
-
webpInput: textWebpInput(item),
|
|
698
|
-
autoConvert: textResourceAutoConvert(item),
|
|
699
|
-
files: textFileCount(item),
|
|
700
|
-
maxSizeKB: item.maxSizeKB,
|
|
701
|
-
durationMs: textDurationRange(item),
|
|
702
|
-
totalDurationMs: item.maxTotalDurationMs != null ? `<=${item.maxTotalDurationMs}` : undefined,
|
|
703
|
-
items: textItemCount(item),
|
|
704
|
-
maxPromptLength: item.maxPromptLength,
|
|
705
|
-
lastFrameOnly: item.supportLastFrameOnly,
|
|
706
|
-
}), [
|
|
707
|
-
'mode',
|
|
708
|
-
'media',
|
|
709
|
-
'usage',
|
|
710
|
-
'sources',
|
|
711
|
-
'formats',
|
|
712
|
-
'webpInput',
|
|
713
|
-
'autoConvert',
|
|
714
|
-
'files',
|
|
715
|
-
'maxSizeKB',
|
|
716
|
-
'durationMs',
|
|
717
|
-
'totalDurationMs',
|
|
718
|
-
'items',
|
|
719
|
-
'maxPromptLength',
|
|
720
|
-
'lastFrameOnly',
|
|
721
|
-
])}`);
|
|
722
|
-
}
|
|
1039
|
+
}, ['key', 'type', 'values', 'default', 'maxLength', 'required']);
|
|
723
1040
|
}
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
1041
|
+
pushSectionCount(lines, 'resources', resources.length);
|
|
1042
|
+
for (const [index, item] of resources.entries()) {
|
|
1043
|
+
pushSectionRecordItem(lines, index, {
|
|
1044
|
+
mode: item.mode,
|
|
1045
|
+
media: item.mediaType,
|
|
1046
|
+
usage: item.usage,
|
|
1047
|
+
valueShapes: textValueShapes(item.valueShapes),
|
|
1048
|
+
formats: textResourceFormats(item),
|
|
1049
|
+
webpInput: textWebpInput(item),
|
|
1050
|
+
autoConvert: textResourceAutoConvert(item),
|
|
1051
|
+
files: textFileCount(item),
|
|
1052
|
+
maxSizeKB: item.maxSizeKB,
|
|
1053
|
+
durationMs: textDurationRange(item),
|
|
1054
|
+
totalDurationMs: item.maxTotalDurationMs != null ? `<=${item.maxTotalDurationMs}` : undefined,
|
|
1055
|
+
items: textItemCount(item),
|
|
1056
|
+
maxPromptLength: item.maxPromptLength,
|
|
1057
|
+
lastFrameOnly: item.supportLastFrameOnly,
|
|
1058
|
+
}, [
|
|
1059
|
+
'mode',
|
|
1060
|
+
'media',
|
|
1061
|
+
'usage',
|
|
1062
|
+
'valueShapes',
|
|
1063
|
+
'formats',
|
|
1064
|
+
'webpInput',
|
|
1065
|
+
'autoConvert',
|
|
1066
|
+
'files',
|
|
1067
|
+
'maxSizeKB',
|
|
1068
|
+
'durationMs',
|
|
1069
|
+
'totalDurationMs',
|
|
1070
|
+
'items',
|
|
1071
|
+
'maxPromptLength',
|
|
1072
|
+
'lastFrameOnly',
|
|
1073
|
+
]);
|
|
1074
|
+
}
|
|
1075
|
+
pushSectionCount(lines, 'constraints', constraints.length);
|
|
1076
|
+
for (const [index, item] of constraints.entries()) {
|
|
1077
|
+
pushSectionRecordItem(lines, index, {
|
|
1078
|
+
target: item.target,
|
|
1079
|
+
targetConfig: item.targetConfigCode && item.targetConfigCode !== item.target ? item.targetConfigCode : undefined,
|
|
1080
|
+
allowedValues: textAllowValues(item.allowValues),
|
|
1081
|
+
when: textConstraintConditions(item.conditions),
|
|
1082
|
+
effect: item.effect,
|
|
1083
|
+
limits: textLimitSummary(item.limits),
|
|
1084
|
+
priority: item.priority,
|
|
1085
|
+
name: item.name,
|
|
1086
|
+
}, ['target', 'targetConfig', 'allowedValues', 'when', 'effect', 'limits', 'priority', 'name']);
|
|
1087
|
+
}
|
|
1088
|
+
if (data.modelGroupCode) {
|
|
1089
|
+
lines.push('next:');
|
|
1090
|
+
pushSectionKeyValue(lines, 'createSpec', `${commandPrefix()} model create-spec --model-group-code ${data.modelGroupCode}`);
|
|
1091
|
+
pushSectionKeyValue(lines, 'reason', '读取创建命令写法、资源语法、fee/dry-run 前置步骤和示例');
|
|
737
1092
|
}
|
|
738
1093
|
return `${lines.join('\n')}\n`;
|
|
739
1094
|
}
|
|
@@ -745,44 +1100,146 @@ function textKeyBinding(value) {
|
|
|
745
1100
|
return value;
|
|
746
1101
|
}
|
|
747
1102
|
|
|
1103
|
+
function localizedIntentMode(value, taskKind = '') {
|
|
1104
|
+
const mode = String(value || '');
|
|
1105
|
+
const labels = {
|
|
1106
|
+
prompt_only: taskKind === 'video' ? '文本生成视频' : '文本生成图片',
|
|
1107
|
+
reference: taskKind === 'video' ? '参考素材生成' : '参考图生成',
|
|
1108
|
+
frames: '首帧/尾帧生成',
|
|
1109
|
+
storyboard: '关键帧/故事板生成',
|
|
1110
|
+
keyframe: '关键帧生成',
|
|
1111
|
+
};
|
|
1112
|
+
return labels[mode] || localizedInputMode(mode, taskKind);
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
function localizedIntentText(value, mode, taskKind = '') {
|
|
1116
|
+
const text = String(value || '');
|
|
1117
|
+
if (!text) return localizedIntentMode(mode, taskKind);
|
|
1118
|
+
const normalized = text.trim();
|
|
1119
|
+
if (normalized === '参考模式') return taskKind === 'video' ? '参考素材生成' : '参考图生成';
|
|
1120
|
+
if (normalized === 'frames 模式') return '首帧/尾帧生成';
|
|
1121
|
+
if (normalized === 'prompt_only 模式') return localizedIntentMode('prompt_only', taskKind);
|
|
1122
|
+
if (normalized === '多帧 / 故事板模式') return '关键帧/故事板生成';
|
|
1123
|
+
return normalized
|
|
1124
|
+
.replaceAll('frames', '首帧/尾帧')
|
|
1125
|
+
.replaceAll('first_frame', '首帧')
|
|
1126
|
+
.replaceAll('last_frame', '尾帧')
|
|
1127
|
+
.replaceAll('reference', '参考素材')
|
|
1128
|
+
.replaceAll('prompt_only', '纯文本');
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
function localizedPromptBinding(value) {
|
|
1132
|
+
const labels = {
|
|
1133
|
+
key_required: '必须绑定 key',
|
|
1134
|
+
required: '必须绑定 key',
|
|
1135
|
+
optional_key: '可选 key',
|
|
1136
|
+
optional: '可选 key',
|
|
1137
|
+
none: '不需要',
|
|
1138
|
+
};
|
|
1139
|
+
return labels[value] || prettyValue(value);
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
function localizedModeList(values = [], taskKind = '') {
|
|
1143
|
+
if (!Array.isArray(values) || !values.length) return '';
|
|
1144
|
+
return values.map((item) => localizedIntentMode(item, taskKind)).join('、');
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
function localizedCreateSpecSummary(value) {
|
|
1148
|
+
return String(value || '')
|
|
1149
|
+
.replaceAll('prompt_only', '纯文本')
|
|
1150
|
+
.replaceAll('reference', '参考素材')
|
|
1151
|
+
.replaceAll('frames', '首帧/尾帧')
|
|
1152
|
+
.replaceAll('storyboard', '关键帧/故事板');
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
function localizedGuideValues(row = {}) {
|
|
1156
|
+
const values = Array.isArray(row.values) ? row.values : [];
|
|
1157
|
+
if (!values.length) return '';
|
|
1158
|
+
if (row.field === 'resources[].usage') {
|
|
1159
|
+
return values.map((value) => `${value}(${localizedUsage(value)})`).join('、');
|
|
1160
|
+
}
|
|
1161
|
+
if (row.field === 'resources[].type') {
|
|
1162
|
+
return values.map((value) => `${value}(${localizedMedia(value)})`).join('、');
|
|
1163
|
+
}
|
|
1164
|
+
if (row.field === 'resources[].source.kind') {
|
|
1165
|
+
const labels = { url: '文件/URL/平台素材路径', asset_id: '资产 ID' };
|
|
1166
|
+
return values.map((value) => `${value}(${labels[value] || value})`).join('、');
|
|
1167
|
+
}
|
|
1168
|
+
return joinValueList(values, 8);
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
function commandArgLines(values = []) {
|
|
1172
|
+
if (!Array.isArray(values) || !values.length) return '';
|
|
1173
|
+
return values.map((value) => prettyValue(value)).join('\n');
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
function modelFeeNextCommand(data = {}) {
|
|
1177
|
+
if (!data.feeCommand || !data.modelGroupCode) return null;
|
|
1178
|
+
const args = [
|
|
1179
|
+
`${commandPrefix()} ${data.feeCommand}`,
|
|
1180
|
+
`--model-group-code ${data.modelGroupCode}`,
|
|
1181
|
+
'--prompt "<prompt>"',
|
|
1182
|
+
];
|
|
1183
|
+
if (data.taskKind === 'video') args.push('--duration <duration>', '--ratio <ratio>', '--quality <quality>');
|
|
1184
|
+
if (data.taskKind === 'image') args.push('--ratio <ratio>', '--quality <quality>');
|
|
1185
|
+
return args.join(' ');
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
function modelCreateExampleWithCode(example, modelGroupCode) {
|
|
1189
|
+
if (!example || !modelGroupCode) return rewriteCommandPrefix(example);
|
|
1190
|
+
return rewriteCommandPrefix(String(example).replaceAll('--model-group-code <code>', `--model-group-code ${modelGroupCode}`));
|
|
1191
|
+
}
|
|
1192
|
+
|
|
748
1193
|
function formatModelCreateSpecOutput(data = {}) {
|
|
749
1194
|
const intents = Array.isArray(data.supportedIntents) ? data.supportedIntents : [];
|
|
750
1195
|
const examples = Array.isArray(data.examples) ? data.examples : [];
|
|
751
1196
|
const lines = ['ok model create-spec'];
|
|
752
|
-
lines
|
|
1197
|
+
pushSectionRecord(lines, 'summary', {
|
|
753
1198
|
modelGroupCode: data.modelGroupCode,
|
|
754
1199
|
taskKind: data.taskKind,
|
|
755
1200
|
create: data.createCommand,
|
|
756
1201
|
fee: data.feeCommand,
|
|
757
1202
|
statusTaskType: data.statusCommandTaskType,
|
|
758
|
-
}
|
|
759
|
-
lines
|
|
760
|
-
|
|
1203
|
+
}, ['modelGroupCode', 'taskKind', 'create', 'fee', 'statusTaskType']);
|
|
1204
|
+
pushSectionRecord(lines, 'input', {
|
|
1205
|
+
summary: data.inputRequirement?.summary,
|
|
761
1206
|
acceptedModes: valueList(data.inputRequirement?.acceptedModes),
|
|
762
|
-
}
|
|
763
|
-
lines
|
|
1207
|
+
}, ['summary', 'acceptedModes']);
|
|
1208
|
+
pushSectionCount(lines, 'intents', intents.length);
|
|
764
1209
|
for (const [index, intent] of intents.entries()) {
|
|
765
|
-
lines
|
|
1210
|
+
pushSectionRecordItem(lines, index, {
|
|
766
1211
|
mode: intent.mode,
|
|
767
1212
|
intent: intent.intent,
|
|
768
1213
|
args: valueList(intent.requiredArgs),
|
|
769
1214
|
usage: valueList(intent.resourceUsages),
|
|
770
1215
|
resources: valueList(intent.resourceSyntax),
|
|
771
1216
|
key: textKeyBinding(intent.promptBinding),
|
|
772
|
-
}
|
|
1217
|
+
}, ['mode', 'intent', 'args', 'usage', 'resources', 'key']);
|
|
773
1218
|
}
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
1219
|
+
pushSectionCount(lines, 'examples', examples.length);
|
|
1220
|
+
for (const [index, example] of examples.entries()) pushSectionItem(lines, index, rewriteCommandPrefix(example));
|
|
1221
|
+
const userParams = Array.isArray(data.parameterControls?.userParams) ? data.parameterControls.userParams : [];
|
|
1222
|
+
pushSectionCount(lines, 'params', userParams.length);
|
|
1223
|
+
for (const [index, param] of userParams.entries()) {
|
|
1224
|
+
pushSectionRecordItem(lines, index, {
|
|
1225
|
+
key: param.key,
|
|
1226
|
+
cliArg: param.cliArg,
|
|
1227
|
+
values: valueList(param.allowedValues),
|
|
1228
|
+
generic: param.genericModelParam,
|
|
1229
|
+
}, ['key', 'cliArg', 'values', 'generic']);
|
|
777
1230
|
}
|
|
778
|
-
|
|
1231
|
+
lines.push('next:');
|
|
1232
|
+
if (data.optionsCommand) pushSectionKeyValue(lines, 'options', `${commandPrefix()} ${data.optionsCommand}`);
|
|
1233
|
+
const feeNext = modelFeeNextCommand(data);
|
|
1234
|
+
if (feeNext) pushSectionKeyValue(lines, 'fee', feeNext);
|
|
1235
|
+
if (examples.length) pushSectionKeyValue(lines, 'dryRun', modelCreateExampleWithCode(examples[0], data.modelGroupCode));
|
|
779
1236
|
return `${lines.join('\n')}\n`;
|
|
780
1237
|
}
|
|
781
1238
|
|
|
782
1239
|
function formatGuideTableRows(rows = []) {
|
|
783
1240
|
return (Array.isArray(rows) ? rows : []).map((item, index) => {
|
|
784
1241
|
const values = valueList(item.values);
|
|
785
|
-
return `
|
|
1242
|
+
return ` [${index}]: ${renderRecord(compactRecord({
|
|
786
1243
|
name: item.field,
|
|
787
1244
|
values,
|
|
788
1245
|
desc: item.description,
|
|
@@ -792,20 +1249,20 @@ function formatGuideTableRows(rows = []) {
|
|
|
792
1249
|
|
|
793
1250
|
function formatModelInputGuideOutput(data = {}) {
|
|
794
1251
|
const lines = ['ok model input-guide'];
|
|
795
|
-
lines
|
|
1252
|
+
pushSectionCount(lines, 'commonFields', Array.isArray(data.commonFields) ? data.commonFields.length : 0);
|
|
796
1253
|
lines.push(...formatGuideTableRows(data.commonFields));
|
|
797
|
-
lines
|
|
1254
|
+
pushSectionCount(lines, 'resourceFields', Array.isArray(data.resourceFields) ? data.resourceFields.length : 0);
|
|
798
1255
|
lines.push(...formatGuideTableRows(data.resourceFields));
|
|
799
1256
|
const rules = Array.isArray(data.resourceRules) ? data.resourceRules : [];
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
for (const [index, rule] of rules.entries()) lines.push(`rule[${index}]=${rule}`);
|
|
803
|
-
}
|
|
1257
|
+
pushSectionCount(lines, 'resourceRules', rules.length);
|
|
1258
|
+
for (const [index, rule] of rules.entries()) pushSectionItem(lines, index, rule);
|
|
804
1259
|
const referenceKeyGuide = Array.isArray(data.referenceKeyGuide) ? data.referenceKeyGuide : [];
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
}
|
|
1260
|
+
pushSectionCount(lines, 'referenceKey', referenceKeyGuide.length);
|
|
1261
|
+
for (const [index, item] of referenceKeyGuide.entries()) pushSectionItem(lines, index, item);
|
|
1262
|
+
lines.push('next:');
|
|
1263
|
+
pushSectionKeyValue(lines, 'imageModels', `${commandPrefix()} model image-models --model <keyword>`);
|
|
1264
|
+
pushSectionKeyValue(lines, 'videoModels', `${commandPrefix()} model video-models --model <keyword>`);
|
|
1265
|
+
pushSectionKeyValue(lines, 'options', `${commandPrefix()} model options --model-group-code <modelGroupCode>`);
|
|
809
1266
|
return `${lines.join('\n')}\n`;
|
|
810
1267
|
}
|
|
811
1268
|
|
|
@@ -817,19 +1274,1793 @@ function modelListNextCommand(commandName) {
|
|
|
817
1274
|
if (commandName === 'model image-models' || commandName === 'model video-models') {
|
|
818
1275
|
return `${commandPrefix()} model options --model-group-code <modelGroupCode>`;
|
|
819
1276
|
}
|
|
1277
|
+
if (commandName === 'model asset-review-models') {
|
|
1278
|
+
return `${commandPrefix()} create asset-groups --platform <platform> --name "<keyword>"`;
|
|
1279
|
+
}
|
|
820
1280
|
return null;
|
|
821
1281
|
}
|
|
822
1282
|
|
|
1283
|
+
function modelListAgentHint(commandName) {
|
|
1284
|
+
if (commandName !== 'model image-models' && commandName !== 'model video-models') return null;
|
|
1285
|
+
return '对每个候选运行 model options,并把候选模型、参数取值、默认值和资源能力展示给用户后再推荐或进入 fee/dry-run。';
|
|
1286
|
+
}
|
|
1287
|
+
|
|
823
1288
|
function statusNextCommand(commandName, normalized) {
|
|
824
1289
|
if (!isPlainObject(normalized) || normalized.isTerminal !== false || !normalized.taskId) return null;
|
|
825
|
-
const taskType = normalized.taskType || (commandName === 'video
|
|
1290
|
+
const taskType = normalized.taskType || (commandName === 'task video-status' ? 'VIDEO_GROUP' : 'IMAGE_CREATE');
|
|
826
1291
|
return `${commandPrefix()} task wait --task-id ${normalized.taskId} --task-type ${taskType} --wait-seconds 180`;
|
|
827
1292
|
}
|
|
828
1293
|
|
|
829
1294
|
function subtitleRemoveNextCommand(commandName, normalized) {
|
|
830
|
-
if (commandName !== 'video
|
|
831
|
-
if (!
|
|
832
|
-
|
|
1295
|
+
if (commandName !== 'task video-status' && commandName !== 'task wait') return null;
|
|
1296
|
+
if (!normalized.taskId || normalized.taskStatus !== 'SUCCESS') return null;
|
|
1297
|
+
const taskType = String(normalized.taskType || '');
|
|
1298
|
+
if (taskType && taskType !== 'VIDEO_GROUP' && !taskType.startsWith('VIDEO_') && !taskType.startsWith('LIP_SYNC')) return null;
|
|
1299
|
+
const projectGroupPart = normalized.projectGroupNo ? ` --project-group-no ${normalized.projectGroupNo}` : '';
|
|
1300
|
+
return `${commandPrefix()} create video-subtitle-removal --source-task-id ${normalized.taskId}${projectGroupPart} --dry-run`;
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
const OUTPUT_KIND_BY_COMMAND = {
|
|
1304
|
+
doctor: 'environment_report',
|
|
1305
|
+
schema: 'command_schema',
|
|
1306
|
+
'auth status': 'auth_status',
|
|
1307
|
+
'auth verify': 'auth_status',
|
|
1308
|
+
'auth login': 'auth_result',
|
|
1309
|
+
'auth clear': 'generic',
|
|
1310
|
+
'account info': 'account_summary',
|
|
1311
|
+
'account teams': 'team_list',
|
|
1312
|
+
'account switch-team': 'generic',
|
|
1313
|
+
'project list': 'project_list',
|
|
1314
|
+
'project current': 'project_summary',
|
|
1315
|
+
'project use': 'generic',
|
|
1316
|
+
'project users': 'project_user_list',
|
|
1317
|
+
'project create': 'generic',
|
|
1318
|
+
'project update': 'generic',
|
|
1319
|
+
'project ensure': 'generic',
|
|
1320
|
+
'credits balance': 'credits_balance',
|
|
1321
|
+
'credits usage': 'credits_usage',
|
|
1322
|
+
'model image-models': 'model_list',
|
|
1323
|
+
'model video-models': 'model_list',
|
|
1324
|
+
'model asset-review-models': 'asset_review_model_list',
|
|
1325
|
+
'model options': 'model_options',
|
|
1326
|
+
'model create-spec': 'model_create_spec',
|
|
1327
|
+
'model input-guide': 'model_input_guide',
|
|
1328
|
+
'upload files': 'upload_result',
|
|
1329
|
+
'create image-fee': 'fee_estimate',
|
|
1330
|
+
'create image': 'task_submission',
|
|
1331
|
+
'create image-batch': 'batch_task_submission',
|
|
1332
|
+
'task image-status': 'task_status',
|
|
1333
|
+
'create video-fee': 'fee_estimate',
|
|
1334
|
+
'create video': 'task_submission',
|
|
1335
|
+
'create video-batch': 'batch_task_submission',
|
|
1336
|
+
'task video-status': 'task_status',
|
|
1337
|
+
'create video-subtitle-removal': 'subtitle_task_submission',
|
|
1338
|
+
'task video-subtitle-status': 'subtitle_task_status',
|
|
1339
|
+
'task list': 'task_list',
|
|
1340
|
+
'task wait': 'task_status',
|
|
1341
|
+
'task records': 'local_task_records',
|
|
1342
|
+
'task record-poll': 'batch_task_status',
|
|
1343
|
+
'create asset-match-actor': 'asset_match_list',
|
|
1344
|
+
'create asset-groups': 'asset_group_list',
|
|
1345
|
+
'create asset-group-get': 'asset_group_detail',
|
|
1346
|
+
'create asset-group': 'asset_group_write_result',
|
|
1347
|
+
'create asset-group-update': 'asset_group_write_result',
|
|
1348
|
+
'create asset': 'asset_register_result',
|
|
1349
|
+
'artifact script get': 'artifact_full',
|
|
1350
|
+
'artifact script document': 'artifact_record',
|
|
1351
|
+
'artifact script rows': 'artifact_list',
|
|
1352
|
+
'artifact script row': 'artifact_record',
|
|
1353
|
+
'artifact script children': 'artifact_list',
|
|
1354
|
+
'artifact script upsert-row': 'artifact_write_result',
|
|
1355
|
+
'artifact script delete-row': 'artifact_delete_result',
|
|
1356
|
+
'artifact script import': 'artifact_import_result',
|
|
1357
|
+
'artifact asset get': 'artifact_full',
|
|
1358
|
+
'artifact asset actors': 'artifact_list',
|
|
1359
|
+
'artifact asset actor': 'artifact_record',
|
|
1360
|
+
'artifact asset props': 'artifact_list',
|
|
1361
|
+
'artifact asset prop': 'artifact_record',
|
|
1362
|
+
'artifact asset locations': 'artifact_list',
|
|
1363
|
+
'artifact asset location': 'artifact_record',
|
|
1364
|
+
'artifact asset upsert-actor': 'artifact_write_result',
|
|
1365
|
+
'artifact asset upsert-prop': 'artifact_write_result',
|
|
1366
|
+
'artifact asset upsert-location': 'artifact_write_result',
|
|
1367
|
+
'artifact asset upsert-actor-state': 'artifact_write_result',
|
|
1368
|
+
'artifact asset upsert-prop-state': 'artifact_write_result',
|
|
1369
|
+
'artifact asset upsert-location-state': 'artifact_write_result',
|
|
1370
|
+
'artifact asset delete-actor': 'artifact_delete_result',
|
|
1371
|
+
'artifact asset delete-prop': 'artifact_delete_result',
|
|
1372
|
+
'artifact asset delete-location': 'artifact_delete_result',
|
|
1373
|
+
'artifact asset delete-actor-state': 'artifact_delete_result',
|
|
1374
|
+
'artifact asset delete-prop-state': 'artifact_delete_result',
|
|
1375
|
+
'artifact asset delete-location-state': 'artifact_delete_result',
|
|
1376
|
+
'artifact asset import': 'artifact_import_result',
|
|
1377
|
+
'artifact video get': 'artifact_full',
|
|
1378
|
+
'artifact video episodes': 'artifact_list',
|
|
1379
|
+
'artifact video episode': 'artifact_record',
|
|
1380
|
+
'artifact video scenes': 'artifact_list',
|
|
1381
|
+
'artifact video scene': 'artifact_record',
|
|
1382
|
+
'artifact video clips': 'artifact_list',
|
|
1383
|
+
'artifact video clip': 'artifact_record',
|
|
1384
|
+
'artifact video upsert-episode': 'artifact_write_result',
|
|
1385
|
+
'artifact video upsert-scene': 'artifact_write_result',
|
|
1386
|
+
'artifact video upsert-clip': 'artifact_write_result',
|
|
1387
|
+
'artifact video update-clip-urls': 'artifact_write_result',
|
|
1388
|
+
'artifact video delete-episode': 'artifact_delete_result',
|
|
1389
|
+
'artifact video delete-scene': 'artifact_delete_result',
|
|
1390
|
+
'artifact video delete-clip': 'artifact_delete_result',
|
|
1391
|
+
'artifact video import-storyboard': 'artifact_import_result',
|
|
1392
|
+
'artifact clip get': 'artifact_full',
|
|
1393
|
+
'artifact clip episodes': 'artifact_list',
|
|
1394
|
+
'artifact clip episode': 'artifact_record',
|
|
1395
|
+
'artifact clip episode-by-id': 'artifact_record',
|
|
1396
|
+
'artifact clip upsert-episode': 'artifact_write_result',
|
|
1397
|
+
'artifact clip upsert-batch': 'artifact_import_result',
|
|
1398
|
+
'artifact clip update-status': 'artifact_status_update',
|
|
1399
|
+
'artifact clip delete-episode': 'artifact_delete_result',
|
|
1400
|
+
'create subject-list': 'subject_list',
|
|
1401
|
+
'create subject': 'subject_publish_result',
|
|
1402
|
+
'create subject-wait': 'subject_status',
|
|
1403
|
+
'create subject-voice-list': 'subject_voice_list',
|
|
1404
|
+
'create subject-voice': 'subject_voice_create_result',
|
|
1405
|
+
'create subject-voice-wait': 'subject_voice_status',
|
|
1406
|
+
'create subject-batch': 'batch_subject_publish_result',
|
|
1407
|
+
update: 'update_result',
|
|
1408
|
+
};
|
|
1409
|
+
|
|
1410
|
+
const KIND_TITLES = {
|
|
1411
|
+
account_summary: '账号概览',
|
|
1412
|
+
artifact_delete_result: '最终产物删除结果',
|
|
1413
|
+
artifact_full: '最终产物详情',
|
|
1414
|
+
artifact_import_result: '最终产物导入结果',
|
|
1415
|
+
artifact_list: '最终产物列表',
|
|
1416
|
+
artifact_record: '最终产物记录',
|
|
1417
|
+
artifact_status_update: '剪辑状态更新结果',
|
|
1418
|
+
artifact_write_result: '最终产物写入结果',
|
|
1419
|
+
asset_group_detail: '素材组详情',
|
|
1420
|
+
asset_group_list: '素材组列表',
|
|
1421
|
+
asset_group_write_result: '素材组写入结果',
|
|
1422
|
+
asset_match_list: '素材匹配结果',
|
|
1423
|
+
asset_review_model_list: '素材审核模型',
|
|
1424
|
+
asset_register_result: '素材注册结果',
|
|
1425
|
+
auth_result: '认证结果',
|
|
1426
|
+
auth_status: '认证状态',
|
|
1427
|
+
batch_subject_publish_result: '批量主体提交结果',
|
|
1428
|
+
batch_task_status: '批量任务状态',
|
|
1429
|
+
batch_task_submission: '批量任务提交结果',
|
|
1430
|
+
command_schema: '命令 Schema',
|
|
1431
|
+
credits_balance: '积分余额',
|
|
1432
|
+
credits_usage: '积分用量',
|
|
1433
|
+
environment_report: '环境体检',
|
|
1434
|
+
fee_estimate: '费用预估',
|
|
1435
|
+
generic: '命令结果',
|
|
1436
|
+
local_task_records: '本地任务台账',
|
|
1437
|
+
model_create_spec: '模型创建写法',
|
|
1438
|
+
model_input_guide: '模型输入指南',
|
|
1439
|
+
model_list: '模型列表',
|
|
1440
|
+
model_options: '模型参数与素材约束',
|
|
1441
|
+
project_list: '项目组列表',
|
|
1442
|
+
project_summary: '项目组摘要',
|
|
1443
|
+
project_user_list: '项目组成员',
|
|
1444
|
+
subject_list: '主体列表',
|
|
1445
|
+
subject_publish_result: '主体创建结果',
|
|
1446
|
+
subject_status: '主体状态',
|
|
1447
|
+
subject_voice_create_result: '主体音色创建结果',
|
|
1448
|
+
subject_voice_list: '主体音色列表',
|
|
1449
|
+
subject_voice_status: '主体音色状态',
|
|
1450
|
+
subtitle_task_status: '去字幕任务状态',
|
|
1451
|
+
subtitle_task_submission: '去字幕任务提交结果',
|
|
1452
|
+
task_list: '任务列表',
|
|
1453
|
+
task_status: '任务状态',
|
|
1454
|
+
task_submission: '任务提交结果',
|
|
1455
|
+
team_list: '团队列表',
|
|
1456
|
+
update_result: 'CLI 更新',
|
|
1457
|
+
upload_result: '上传结果',
|
|
1458
|
+
};
|
|
1459
|
+
|
|
1460
|
+
const COMMAND_TITLES = {
|
|
1461
|
+
doctor: '环境体检',
|
|
1462
|
+
schema: '命令 Schema',
|
|
1463
|
+
update: 'CLI 更新',
|
|
1464
|
+
'auth clear': '清空认证结果',
|
|
1465
|
+
'account switch-team': '团队切换结果',
|
|
1466
|
+
'project use': '项目组切换结果',
|
|
1467
|
+
'project create': '项目组创建结果',
|
|
1468
|
+
'project update': '项目组更新结果',
|
|
1469
|
+
'project ensure': '项目组确保结果',
|
|
1470
|
+
'create image': '生图任务提交结果',
|
|
1471
|
+
'create video': '生视频任务提交结果',
|
|
1472
|
+
'create image-batch': '批量生图提交结果',
|
|
1473
|
+
'create video-batch': '批量生视频提交结果',
|
|
1474
|
+
'create video-subtitle-removal': '去字幕任务提交结果',
|
|
1475
|
+
'create subject': '主体创建结果',
|
|
1476
|
+
'create subject-wait': '主体状态',
|
|
1477
|
+
'create subject-voice': '主体音色创建结果',
|
|
1478
|
+
'create subject-voice-wait': '主体音色状态',
|
|
1479
|
+
};
|
|
1480
|
+
|
|
1481
|
+
const FIELD_LABELS = {
|
|
1482
|
+
acceptedModes: '可用输入模式',
|
|
1483
|
+
accessKey: 'Access Key',
|
|
1484
|
+
action: '动作',
|
|
1485
|
+
actorCount: '角色数',
|
|
1486
|
+
actorKey: '角色 Key',
|
|
1487
|
+
arch: '架构',
|
|
1488
|
+
assetCount: '素材数',
|
|
1489
|
+
assetId: '素材 ID',
|
|
1490
|
+
assetKey: '素材 Key',
|
|
1491
|
+
assetKind: '素材类型',
|
|
1492
|
+
assetName: '素材名',
|
|
1493
|
+
assetPath: '素材路径',
|
|
1494
|
+
authType: '认证方式',
|
|
1495
|
+
backendPath: '后端路径',
|
|
1496
|
+
batchCount: '批次数',
|
|
1497
|
+
billingPointBalance: '可扣积分余额',
|
|
1498
|
+
billingPointRemainingAfter: '扣除后可扣积分',
|
|
1499
|
+
checkedAt: '检查时间',
|
|
1500
|
+
cleared: '已清空',
|
|
1501
|
+
clipCount: 'Clip 数',
|
|
1502
|
+
clipId: 'Clip ID',
|
|
1503
|
+
command: '命令',
|
|
1504
|
+
configured: '已配置',
|
|
1505
|
+
count: '数量',
|
|
1506
|
+
created: '已创建',
|
|
1507
|
+
createCommand: '创建命令',
|
|
1508
|
+
customBizId: '业务追踪 ID',
|
|
1509
|
+
deleted: '已删除',
|
|
1510
|
+
description: '描述',
|
|
1511
|
+
displayName: '展示名',
|
|
1512
|
+
taskKind: '任务类型',
|
|
1513
|
+
doctorStatus: '体检状态',
|
|
1514
|
+
dryRun: '预览模式',
|
|
1515
|
+
duration: '时长',
|
|
1516
|
+
elementId: '主体元素 ID',
|
|
1517
|
+
enabled: '启用',
|
|
1518
|
+
entityKey: '实体 Key',
|
|
1519
|
+
episodeCount: '集数',
|
|
1520
|
+
episodeId: '集 ID',
|
|
1521
|
+
errorMessage: '错误信息',
|
|
1522
|
+
externalId: '外部 ID',
|
|
1523
|
+
fileCount: '文件数',
|
|
1524
|
+
feeCommand: '估价命令',
|
|
1525
|
+
format: '格式',
|
|
1526
|
+
generateNum: '生成数量',
|
|
1527
|
+
gmtCreate: '创建时间',
|
|
1528
|
+
groupId: '团队 ID',
|
|
1529
|
+
groupName: '团队名称',
|
|
1530
|
+
id: 'ID',
|
|
1531
|
+
imported: '已导入',
|
|
1532
|
+
inputDir: '输入目录',
|
|
1533
|
+
inputFile: '输入文件',
|
|
1534
|
+
inputSummary: '输入摘要',
|
|
1535
|
+
isSelected: '当前选中',
|
|
1536
|
+
isTerminal: '终态',
|
|
1537
|
+
key: 'Key',
|
|
1538
|
+
localFileCount: '本地文件数',
|
|
1539
|
+
locationCount: '场景数',
|
|
1540
|
+
locationKey: '场景 Key',
|
|
1541
|
+
memberCount: '成员数',
|
|
1542
|
+
messageCount: '消息数',
|
|
1543
|
+
modelCode: '模型编码',
|
|
1544
|
+
modelDesc: '模型说明',
|
|
1545
|
+
modelGroupCode: '模型组编码',
|
|
1546
|
+
modelStatus: '模型状态',
|
|
1547
|
+
name: '名称',
|
|
1548
|
+
needAudio: '需要音频',
|
|
1549
|
+
nextCommand: '下一步命令',
|
|
1550
|
+
nextRefSubject: '主体引用参数',
|
|
1551
|
+
nextVoiceArg: '音色参数',
|
|
1552
|
+
originUrls: '原始素材',
|
|
1553
|
+
parentKey: '父级 Key',
|
|
1554
|
+
platform: '平台',
|
|
1555
|
+
point: '预算点数',
|
|
1556
|
+
pointCost: '预计消耗积分',
|
|
1557
|
+
pointNo: '积分规格',
|
|
1558
|
+
pointTotal: '积分合计',
|
|
1559
|
+
projectBudgetBalance: '项目预算余额',
|
|
1560
|
+
projectBudgetMax: '项目预算上限',
|
|
1561
|
+
projectBudgetRemainingAfter: '扣除后项目预算',
|
|
1562
|
+
projectGroupName: '项目组名称',
|
|
1563
|
+
projectGroupNo: '项目组编号',
|
|
1564
|
+
projectId: 'AWB 项目 ID',
|
|
1565
|
+
prompt: '提示词',
|
|
1566
|
+
propCount: '道具数',
|
|
1567
|
+
propKey: '道具 Key',
|
|
1568
|
+
publicId: '公开任务 ID',
|
|
1569
|
+
quality: '清晰度',
|
|
1570
|
+
ratio: '宽高比',
|
|
1571
|
+
registered: '已注册',
|
|
1572
|
+
remoteTaskId: '远端任务 ID',
|
|
1573
|
+
requestSource: '请求来源',
|
|
1574
|
+
resourceConversion: '素材转换',
|
|
1575
|
+
resourceConversionCount: '素材转换数',
|
|
1576
|
+
resourceCount: '素材数',
|
|
1577
|
+
resultCount: '结果数',
|
|
1578
|
+
resultUrls: '结果链接',
|
|
1579
|
+
reused: '已复用',
|
|
1580
|
+
rowCount: '行数',
|
|
1581
|
+
rowKind: '行类型',
|
|
1582
|
+
saved: '已保存',
|
|
1583
|
+
sceneCount: '场数',
|
|
1584
|
+
sceneId: '场 ID',
|
|
1585
|
+
selected: '已选择',
|
|
1586
|
+
sortOrder: '排序',
|
|
1587
|
+
source: '来源',
|
|
1588
|
+
sourceFile: '来源文件',
|
|
1589
|
+
sourceTaskId: '来源任务 ID',
|
|
1590
|
+
stateKey: '状态 Key',
|
|
1591
|
+
status: '状态',
|
|
1592
|
+
statusCommandTaskType: '状态任务类型',
|
|
1593
|
+
submitted: '已提交',
|
|
1594
|
+
successRate: '成功率',
|
|
1595
|
+
subjectId: '主体 ID',
|
|
1596
|
+
taskCount: '任务数',
|
|
1597
|
+
taskId: '任务 ID',
|
|
1598
|
+
taskQueueNum: '排队数',
|
|
1599
|
+
taskStatus: '任务状态',
|
|
1600
|
+
taskType: '任务类型',
|
|
1601
|
+
timedOut: '已超时',
|
|
1602
|
+
title: '标题',
|
|
1603
|
+
updated: '已更新',
|
|
1604
|
+
userId: '用户 ID',
|
|
1605
|
+
userName: '用户名',
|
|
1606
|
+
verification: '验证方式',
|
|
1607
|
+
verified: '已验证',
|
|
1608
|
+
verify: '联网验证',
|
|
1609
|
+
verifyCommand: '验证命令',
|
|
1610
|
+
videoEpisodeId: '视频集 ID',
|
|
1611
|
+
voiceId: '音色 ID',
|
|
1612
|
+
voiceName: '音色名称',
|
|
1613
|
+
voiceRecordId: '音色记录 ID',
|
|
1614
|
+
voiceUrl: '音频地址',
|
|
1615
|
+
apiOrigin: 'API 地址',
|
|
1616
|
+
authState: '认证状态',
|
|
1617
|
+
cli: 'CLI',
|
|
1618
|
+
commandCount: '命令数',
|
|
1619
|
+
commandFilter: '命令过滤',
|
|
1620
|
+
commonFieldCount: '通用字段数',
|
|
1621
|
+
currentVersion: '当前版本',
|
|
1622
|
+
domainFilter: '领域过滤',
|
|
1623
|
+
latestVersion: '最新版本',
|
|
1624
|
+
nodeVersion: 'Node 版本',
|
|
1625
|
+
packageName: '包名',
|
|
1626
|
+
previousVersion: '更新前版本',
|
|
1627
|
+
resourceFieldCount: '资源字段数',
|
|
1628
|
+
resourceRuleCount: '资源规则数',
|
|
1629
|
+
restartRecommended: '建议重启',
|
|
1630
|
+
schemaVersion: 'Schema 版本',
|
|
1631
|
+
skillUpdated: 'Skill 已更新',
|
|
1632
|
+
updateAvailable: '有新版本',
|
|
1633
|
+
version: '版本',
|
|
1634
|
+
type: '类型',
|
|
1635
|
+
message: '消息',
|
|
1636
|
+
hint: '提示',
|
|
1637
|
+
unknownOptions: '未知参数',
|
|
1638
|
+
note: '说明',
|
|
1639
|
+
commandPrefix: '命令前缀',
|
|
1640
|
+
elementDescription: '主体描述',
|
|
1641
|
+
elementFrontalImage: '主体正面图',
|
|
1642
|
+
elementName: '主体名称',
|
|
1643
|
+
referenceType: '引用类型',
|
|
1644
|
+
remoteUpload: '远程上传',
|
|
1645
|
+
remoteUrl: '远程地址',
|
|
1646
|
+
};
|
|
1647
|
+
|
|
1648
|
+
const DETAIL_FIELDS_BY_KIND = {
|
|
1649
|
+
account_summary: ['userId', 'userName', 'groupId', 'groupName', 'currentProjectGroupNo', 'currentProjectGroupName', 'billingPointBalance', 'projectBudgetBalance', 'projectBudgetMax'],
|
|
1650
|
+
artifact_delete_result: ['deleted', 'action', 'projectId', 'rowKind', 'entityKey', 'key', 'stateKey', 'episodeId', 'sceneId', 'clipId', 'videoEpisodeId'],
|
|
1651
|
+
artifact_full: ['projectId', 'id', 'title', 'status', 'rowCount', 'actorCount', 'propCount', 'locationCount', 'episodeCount', 'sceneCount', 'clipCount'],
|
|
1652
|
+
artifact_import_result: ['imported', 'dryRun', 'action', 'projectId', 'sourceFile', 'inputDir', 'inputFile', 'rowCount', 'actorCount', 'propCount', 'locationCount', 'episodeCount', 'sceneCount', 'clipCount', 'batchCount'],
|
|
1653
|
+
artifact_record: ['id', 'projectId', 'rowKind', 'entityKey', 'parentKey', 'actorKey', 'propKey', 'locationKey', 'stateKey', 'episodeId', 'sceneId', 'clipId', 'videoEpisodeId', 'status', 'title', 'name', 'displayName', 'description'],
|
|
1654
|
+
artifact_status_update: ['updated', 'videoEpisodeId', 'status', 'messageCount'],
|
|
1655
|
+
artifact_write_result: ['id', 'projectId', 'rowKind', 'entityKey', 'parentKey', 'actorKey', 'propKey', 'locationKey', 'stateKey', 'episodeId', 'sceneId', 'clipId', 'videoEpisodeId', 'status', 'title', 'name', 'displayName'],
|
|
1656
|
+
asset_group_detail: ['groupId', 'platform', 'name', 'projectName', 'description', 'status', 'assetCount'],
|
|
1657
|
+
asset_group_write_result: ['created', 'updated', 'groupId', 'platform', 'name', 'projectName', 'assetPath'],
|
|
1658
|
+
asset_register_result: ['created', 'updated', 'registered', 'assetId', 'groupId', 'platform', 'name', 'projectName', 'assetPath', 'uploadBackendPath', 'uploadUrl'],
|
|
1659
|
+
auth_result: ['saved', 'verified', 'accessKey', 'source', 'dryRun', 'userId', 'userName', 'groupId', 'groupName'],
|
|
1660
|
+
auth_status: ['configured', 'authType', 'accessKey', 'source', 'verified', 'verification', 'verifyCommand', 'userId', 'userName', 'groupId', 'groupName'],
|
|
1661
|
+
batch_subject_publish_result: ['dryRun', 'submitted', 'count', 'successCount', 'failureCount', 'modelCode', 'projectGroupNo'],
|
|
1662
|
+
batch_task_status: ['count', 'taskCount', 'successTaskCount', 'resultCount', 'pointTotal', 'timedOut', 'waitedMs'],
|
|
1663
|
+
batch_task_submission: ['dryRun', 'submitted', 'count', 'taskCount', 'successCount', 'failureCount', 'modelGroupCode', 'projectGroupNo', 'pointCost', 'billingPointBalance', 'projectBudgetBalance'],
|
|
1664
|
+
credits_balance: ['billingPointBalance', 'currentProjectGroupNo', 'currentProjectGroupName', 'projectBudgetBalance', 'projectBudgetMax'],
|
|
1665
|
+
credits_usage: ['projectGroupNo', 'sinceText', 'untilText', 'scannedTaskCount', 'pointTotal'],
|
|
1666
|
+
environment_report: ['doctorStatus', 'verify'],
|
|
1667
|
+
fee_estimate: ['modelGroupCode', 'projectGroupNo', 'pointCost', 'billingPointBalance', 'billingPointRemainingAfter', 'projectBudgetBalance', 'projectBudgetMax', 'projectBudgetRemainingAfter'],
|
|
1668
|
+
generic: ['cleared', 'selected', 'created', 'updated', 'reused', 'dryRun', 'action', 'projectGroupNo', 'projectGroupName', 'groupId', 'groupName', 'projectGroupName', 'point', 'memberCount', 'note'],
|
|
1669
|
+
local_task_records: ['count', 'taskCount', 'successTaskCount', 'resultCount', 'pointTotal'],
|
|
1670
|
+
project_summary: ['selected', 'created', 'updated', 'reused', 'projectGroupNo', 'projectGroupName', 'isSelected', 'projectBudgetBalance', 'projectBudgetMax', 'memberCount'],
|
|
1671
|
+
subject_publish_result: ['created', 'name', 'elementId', 'subjectId', 'externalId', 'modelCode', 'status', 'taskStatus', 'errorMessage', 'nextRefSubject'],
|
|
1672
|
+
subject_status: ['name', 'elementId', 'subjectId', 'externalId', 'modelCode', 'status', 'taskStatus', 'errorMessage', 'isTerminal', 'nextRefSubject'],
|
|
1673
|
+
subject_voice_create_result: ['created', 'name', 'voiceRecordId', 'reqTaskId', 'voiceId', 'externalId', 'status', 'taskStatus', 'errorMessage', 'nextVoiceArg'],
|
|
1674
|
+
subject_voice_status: ['name', 'voiceRecordId', 'reqTaskId', 'voiceId', 'externalId', 'status', 'taskStatus', 'errorMessage', 'isTerminal', 'nextVoiceArg'],
|
|
1675
|
+
subtitle_task_status: ['taskId', 'publicId', 'remoteTaskId', 'taskType', 'taskStatus', 'isTerminal', 'projectGroupNo', 'resultCount', 'errorMessage', 'timedOut', 'waitedMs'],
|
|
1676
|
+
subtitle_task_submission: ['submitted', 'taskId', 'taskType', 'sourceTaskId', 'projectGroupNo', 'pointCost', 'billingPointBalance', 'billingPointRemainingAfter', 'projectBudgetBalance', 'projectBudgetMax', 'projectBudgetRemainingAfter', 'nextCommand'],
|
|
1677
|
+
task_status: ['taskId', 'publicId', 'remoteTaskId', 'taskType', 'taskStatus', 'isTerminal', 'modelGroupCode', 'projectGroupNo', 'pointNo', 'gmtCreate', 'resultCount', 'errorMessage', 'timedOut', 'waitedMs'],
|
|
1678
|
+
task_submission: ['taskId', 'taskType', 'modelGroupCode', 'projectGroupNo', 'pointNo', 'points', 'pointCost', 'billingPointBalance', 'billingPointRemainingAfter', 'projectBudgetBalance', 'projectBudgetMax', 'projectBudgetRemainingAfter', 'uploadCount', 'nextCommand'],
|
|
1679
|
+
update_result: ['checked', 'updated', 'updateAvailable', 'packageName', 'previousVersion', 'currentVersion', 'latestVersion', 'command', 'skillUpdated', 'restartRecommended', 'message'],
|
|
1680
|
+
upload_result: ['dryRun', 'fileCount', 'assetCount', 'localFileCount', 'resourceConversionCount'],
|
|
1681
|
+
};
|
|
1682
|
+
|
|
1683
|
+
const DRY_RUN_FIELDS_BY_COMMAND = {
|
|
1684
|
+
'auth login': ['dryRun', 'saved', 'verified', 'accessKey'],
|
|
1685
|
+
'auth clear': ['dryRun', 'action', 'cleared'],
|
|
1686
|
+
'account switch-team': ['dryRun', 'action', 'groupId', 'selected'],
|
|
1687
|
+
'project use': ['dryRun', 'action', 'projectGroupNo', 'selected'],
|
|
1688
|
+
'project create': ['dryRun', 'action', 'projectGroupName', 'point', 'memberCount', 'note'],
|
|
1689
|
+
'project update': ['dryRun', 'action', 'projectGroupNo', 'projectGroupName', 'point', 'memberCount'],
|
|
1690
|
+
'project ensure': ['dryRun', 'action', 'projectGroupName', 'point', 'memberCount', 'note'],
|
|
1691
|
+
'upload files': ['dryRun', 'fileCount', 'localFileCount', 'resourceConversionCount'],
|
|
1692
|
+
'create image': ['dryRun', 'action', 'modelGroupCode', 'projectGroupNo', 'prompt', 'ratio', 'quality', 'generateNum', 'resourceCount', 'localFileCount', 'assetCount'],
|
|
1693
|
+
'create video': ['dryRun', 'action', 'modelGroupCode', 'projectGroupNo', 'prompt', 'duration', 'ratio', 'quality', 'needAudio', 'resourceCount', 'localFileCount', 'assetCount'],
|
|
1694
|
+
'create image-batch': ['dryRun', 'count', 'modelGroupCode', 'projectGroupNo'],
|
|
1695
|
+
'create video-batch': ['dryRun', 'count', 'modelGroupCode', 'projectGroupNo'],
|
|
1696
|
+
'create video-subtitle-removal': ['dryRun', 'action', 'sourceTaskId', 'projectGroupNo'],
|
|
1697
|
+
'create asset-group': ['dryRun', 'action', 'platform', 'name', 'projectName'],
|
|
1698
|
+
'create asset-group-update': ['dryRun', 'action', 'groupId', 'platform', 'name', 'projectName'],
|
|
1699
|
+
'create asset': ['dryRun', 'action', 'groupId', 'platform', 'name', 'assetPath', 'localFileCount', 'fileCount'],
|
|
1700
|
+
'create subject': ['dryRun', 'action', 'name', 'modelCode', 'elementFrontalImage', 'assetCount', 'localFileCount', 'nextRefSubject'],
|
|
1701
|
+
'create subject-voice': ['dryRun', 'action', 'name', 'voiceName', 'voiceUrl', 'remoteUrl', 'remoteUpload', 'localFileCount', 'nextVoiceArg'],
|
|
1702
|
+
'create subject-batch': ['dryRun', 'count', 'modelCode'],
|
|
1703
|
+
'artifact script import': ['dryRun', 'action', 'projectId', 'sourceFile', 'inputFile', 'rowCount', 'actorCount', 'episodeCount', 'sceneCount', 'clipCount'],
|
|
1704
|
+
'artifact asset import': ['dryRun', 'action', 'projectId', 'inputDir', 'actorCount', 'propCount', 'locationCount'],
|
|
1705
|
+
'artifact video import-storyboard': ['dryRun', 'action', 'projectId', 'inputFile', 'episodeId', 'sceneCount', 'clipCount'],
|
|
1706
|
+
'artifact clip upsert-batch': ['dryRun', 'action', 'projectId', 'episodeCount'],
|
|
1707
|
+
'artifact clip update-status': ['dryRun', 'action', 'projectId', 'videoEpisodeId', 'status', 'messageCount'],
|
|
1708
|
+
};
|
|
1709
|
+
|
|
1710
|
+
const LIST_KEY_BY_KIND = {
|
|
1711
|
+
artifact_list: 'items',
|
|
1712
|
+
asset_group_list: 'groups',
|
|
1713
|
+
asset_match_list: 'matches',
|
|
1714
|
+
asset_review_model_list: 'models',
|
|
1715
|
+
batch_subject_publish_result: 'results',
|
|
1716
|
+
batch_task_status: 'records',
|
|
1717
|
+
batch_task_submission: 'results',
|
|
1718
|
+
command_schema: 'commands',
|
|
1719
|
+
credits_usage: 'buckets',
|
|
1720
|
+
local_task_records: 'records',
|
|
1721
|
+
model_list: 'models',
|
|
1722
|
+
project_list: 'projectGroups',
|
|
1723
|
+
project_user_list: 'users',
|
|
1724
|
+
subject_list: 'subjects',
|
|
1725
|
+
subject_voice_list: 'voices',
|
|
1726
|
+
task_list: 'tasks',
|
|
1727
|
+
team_list: 'teams',
|
|
1728
|
+
upload_result: 'files',
|
|
1729
|
+
};
|
|
1730
|
+
|
|
1731
|
+
const PRETTY_KIND_PROFILES = Object.fromEntries(Object.keys(KIND_TITLES).map((kind) => [kind, {
|
|
1732
|
+
title: KIND_TITLES[kind],
|
|
1733
|
+
fields: DETAIL_FIELDS_BY_KIND[kind] || [],
|
|
1734
|
+
listKey: LIST_KEY_BY_KIND[kind],
|
|
1735
|
+
}]));
|
|
1736
|
+
|
|
1737
|
+
export const PRETTY_OUTPUT_KIND_COVERAGE = Object.freeze(Object.keys(PRETTY_KIND_PROFILES));
|
|
1738
|
+
|
|
1739
|
+
function outputKindForCommand(commandName, context = {}) {
|
|
1740
|
+
return context.outputKind || OUTPUT_KIND_BY_COMMAND[commandName] || 'generic';
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
function prettyTitle(commandName, kind, data) {
|
|
1744
|
+
const base = COMMAND_TITLES[commandName] || PRETTY_KIND_PROFILES[kind]?.title || KIND_TITLES[kind] || '命令结果';
|
|
1745
|
+
const title = commandName === 'schema' && data?.kind === 'agent_brief' ? 'Agent 能力摘要' : base;
|
|
1746
|
+
return titleText(data?.dryRun ? `${title}(预览)` : title);
|
|
1747
|
+
}
|
|
1748
|
+
|
|
1749
|
+
function stripAnsi(value) {
|
|
1750
|
+
return String(value ?? '').replace(/\u001b\[[0-9;]*m/g, '');
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1753
|
+
function charDisplayWidth(char) {
|
|
1754
|
+
const code = char.codePointAt(0);
|
|
1755
|
+
if (code === 0) return 0;
|
|
1756
|
+
if (code < 32 || (code >= 0x7f && code < 0xa0)) return 0;
|
|
1757
|
+
return (
|
|
1758
|
+
code >= 0x1100
|
|
1759
|
+
&& (code <= 0x115f
|
|
1760
|
+
|| code === 0x2329
|
|
1761
|
+
|| code === 0x232a
|
|
1762
|
+
|| (code >= 0x2e80 && code <= 0xa4cf && code !== 0x303f)
|
|
1763
|
+
|| (code >= 0xac00 && code <= 0xd7a3)
|
|
1764
|
+
|| (code >= 0xf900 && code <= 0xfaff)
|
|
1765
|
+
|| (code >= 0xfe10 && code <= 0xfe19)
|
|
1766
|
+
|| (code >= 0xfe30 && code <= 0xfe6f)
|
|
1767
|
+
|| (code >= 0xff00 && code <= 0xff60)
|
|
1768
|
+
|| (code >= 0xffe0 && code <= 0xffe6))
|
|
1769
|
+
) ? 2 : 1;
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
function displayWidth(value) {
|
|
1773
|
+
let width = 0;
|
|
1774
|
+
for (const char of stripAnsi(value)) width += charDisplayWidth(char);
|
|
1775
|
+
return width;
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
function truncateDisplay(value, maxWidth = 32) {
|
|
1779
|
+
const text = String(value ?? '');
|
|
1780
|
+
if (displayWidth(text) <= maxWidth) return text;
|
|
1781
|
+
const marker = '...';
|
|
1782
|
+
const markerWidth = displayWidth(marker);
|
|
1783
|
+
let width = 0;
|
|
1784
|
+
let out = '';
|
|
1785
|
+
for (const char of text) {
|
|
1786
|
+
const charWidth = charDisplayWidth(char);
|
|
1787
|
+
if (width + charWidth + markerWidth > maxWidth) break;
|
|
1788
|
+
out += char;
|
|
1789
|
+
width += charWidth;
|
|
1790
|
+
}
|
|
1791
|
+
return `${out}${marker}`;
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
function wrapDisplay(value, width) {
|
|
1795
|
+
const maxWidth = Math.max(1, width);
|
|
1796
|
+
const text = String(value ?? '');
|
|
1797
|
+
const lines = [];
|
|
1798
|
+
const pushHardWrapped = (chunk, state) => {
|
|
1799
|
+
for (const char of chunk) {
|
|
1800
|
+
const charWidth = charDisplayWidth(char);
|
|
1801
|
+
if (state.lineWidth > 0 && state.lineWidth + charWidth > maxWidth) {
|
|
1802
|
+
lines.push(state.line);
|
|
1803
|
+
state.line = char;
|
|
1804
|
+
state.lineWidth = charWidth;
|
|
1805
|
+
} else {
|
|
1806
|
+
state.line += char;
|
|
1807
|
+
state.lineWidth += charWidth;
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
};
|
|
1811
|
+
const tokenBoundary = (char) => /[\s、,,;;|/\\_-]/u.test(char);
|
|
1812
|
+
for (const segment of text.split(/\r?\n/)) {
|
|
1813
|
+
if (!segment) {
|
|
1814
|
+
lines.push('');
|
|
1815
|
+
continue;
|
|
1816
|
+
}
|
|
1817
|
+
const state = { line: '', lineWidth: 0 };
|
|
1818
|
+
let token = '';
|
|
1819
|
+
const flushToken = () => {
|
|
1820
|
+
if (!token) return;
|
|
1821
|
+
const tokenWidth = displayWidth(token);
|
|
1822
|
+
if (tokenWidth > maxWidth) {
|
|
1823
|
+
pushHardWrapped(token, state);
|
|
1824
|
+
} else if (state.lineWidth > 0 && state.lineWidth + tokenWidth > maxWidth) {
|
|
1825
|
+
lines.push(state.line);
|
|
1826
|
+
state.line = token.trimStart();
|
|
1827
|
+
state.lineWidth = displayWidth(state.line);
|
|
1828
|
+
} else {
|
|
1829
|
+
state.line += token;
|
|
1830
|
+
state.lineWidth += tokenWidth;
|
|
1831
|
+
}
|
|
1832
|
+
token = '';
|
|
1833
|
+
};
|
|
1834
|
+
for (const char of segment) {
|
|
1835
|
+
token += char;
|
|
1836
|
+
if (tokenBoundary(char)) flushToken();
|
|
1837
|
+
}
|
|
1838
|
+
flushToken();
|
|
1839
|
+
lines.push(state.line);
|
|
1840
|
+
}
|
|
1841
|
+
return lines.length ? lines : [''];
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
function padDisplay(value, width) {
|
|
1845
|
+
const text = String(value ?? '');
|
|
1846
|
+
return `${text}${' '.repeat(Math.max(0, width - displayWidth(text)))}`;
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1849
|
+
function shouldColorOutput() {
|
|
1850
|
+
if (String(process.env.LINGJING_AWB_COLOR || '').toLowerCase() === '0') return false;
|
|
1851
|
+
if (String(process.env.LINGJING_AWB_COLOR || '').toLowerCase() === 'false') return false;
|
|
1852
|
+
if (String(process.env.FORCE_COLOR || '').trim() && process.env.FORCE_COLOR !== '0') return true;
|
|
1853
|
+
if (String(process.env.LINGJING_AWB_COLOR || '').toLowerCase() === '1') return true;
|
|
1854
|
+
if (String(process.env.LINGJING_AWB_COLOR || '').toLowerCase() === 'true') return true;
|
|
1855
|
+
if (process.env.NO_COLOR) return false;
|
|
1856
|
+
return Boolean(process.stdout.isTTY);
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
function colorText(value, code) {
|
|
1860
|
+
const text = String(value ?? '');
|
|
1861
|
+
if (!shouldColorOutput() || !text) return text;
|
|
1862
|
+
const colorMatch = String(code).match(/38;5;(\d+)/);
|
|
1863
|
+
let rendered = colorMatch ? CHALK.ansi256(Number(colorMatch[1]))(text) : text;
|
|
1864
|
+
if (String(code).includes('36')) rendered = CHALK.cyan(text);
|
|
1865
|
+
if (String(code).split(';').includes('1')) rendered = CHALK.bold(rendered);
|
|
1866
|
+
if (String(code).split(';').includes('2')) rendered = CHALK.dim(rendered);
|
|
1867
|
+
return rendered;
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
const COLOR = {
|
|
1871
|
+
title: '1;38;5;39',
|
|
1872
|
+
accent: '1;38;5;208',
|
|
1873
|
+
section: '1;38;5;75',
|
|
1874
|
+
border: '38;5;238',
|
|
1875
|
+
header: '1;38;5;81',
|
|
1876
|
+
label: '38;5;215',
|
|
1877
|
+
value: '38;5;250',
|
|
1878
|
+
command: '38;5;82',
|
|
1879
|
+
code: '38;5;111',
|
|
1880
|
+
success: '38;5;82',
|
|
1881
|
+
warning: '38;5;220',
|
|
1882
|
+
danger: '38;5;203',
|
|
1883
|
+
muted: '2;38;5;245',
|
|
1884
|
+
};
|
|
1885
|
+
|
|
1886
|
+
function titleText(value) {
|
|
1887
|
+
if (!shouldColorOutput()) return String(value ?? '');
|
|
1888
|
+
return `${colorText('◆', COLOR.accent)} ${colorText(value, COLOR.title)}`;
|
|
1889
|
+
}
|
|
1890
|
+
|
|
1891
|
+
function errorTitleText(value) {
|
|
1892
|
+
if (!shouldColorOutput()) return String(value ?? '');
|
|
1893
|
+
return `${colorText('◆', COLOR.danger)} ${colorText(value, '1;38;5;203')}`;
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
function sectionText(value) {
|
|
1897
|
+
if (!shouldColorOutput()) return String(value ?? '');
|
|
1898
|
+
return `${colorText('▸', COLOR.accent)} ${colorText(value, COLOR.section)}`;
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
function borderText(value) {
|
|
1902
|
+
return colorText(value, COLOR.border);
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1905
|
+
function headerText(value) {
|
|
1906
|
+
return colorText(value, COLOR.header);
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1909
|
+
function labelText(value) {
|
|
1910
|
+
return colorText(value, COLOR.label);
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
function mutedText(value) {
|
|
1914
|
+
return colorText(value, COLOR.muted);
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
function commandText(value) {
|
|
1918
|
+
return colorText(value, COLOR.command);
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
function codeText(value) {
|
|
1922
|
+
return colorText(value, COLOR.code);
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
function semanticText(value) {
|
|
1926
|
+
const text = String(value ?? '');
|
|
1927
|
+
if (!shouldColorOutput() || !text) return text;
|
|
1928
|
+
const plain = stripAnsi(text).trim().toLowerCase();
|
|
1929
|
+
if (/^(是|true|success|succeeded|completed|done|ok|healthy|passed|enabled|active|已配置|已登录|成功)$/.test(plain)) {
|
|
1930
|
+
return colorText(text, COLOR.success);
|
|
1931
|
+
}
|
|
1932
|
+
if (/^(否|false|pending|running|processing|queued|warning|warn|dry-run|dryrun|预览|缓存过期|未登录|未选择|未知)$/.test(plain)) {
|
|
1933
|
+
return colorText(text, COLOR.warning);
|
|
1934
|
+
}
|
|
1935
|
+
if (/^(failed|failure|error|errored|fatal|invalid|denied|rejected|deleted|失败|错误|无效|删除)$/.test(plain)) {
|
|
1936
|
+
return colorText(text, COLOR.danger);
|
|
1937
|
+
}
|
|
1938
|
+
return text;
|
|
1939
|
+
}
|
|
1940
|
+
|
|
1941
|
+
function prettyCellText(value, columnInfo = {}) {
|
|
1942
|
+
const text = String(value ?? '');
|
|
1943
|
+
if (!shouldColorOutput() || !text) return text;
|
|
1944
|
+
const header = stripAnsi(columnInfo.header || '');
|
|
1945
|
+
if (header === '#' || columnInfo.index) return mutedText(text);
|
|
1946
|
+
if (['状态', '当前', '必填', '验证', 'WebP'].includes(header)) return semanticText(text);
|
|
1947
|
+
if (['CLI', '命令', '继续查询', '生成创建写法'].includes(header) || stripAnsi(text).startsWith('--')) return codeText(text);
|
|
1948
|
+
if (stripAnsi(text).startsWith(commandPrefix())) return commandText(text);
|
|
1949
|
+
if (['队列', '排队数', '成功率', '结果数', '任务数', '积分', '数量', '文件数'].includes(header)) return colorText(text, COLOR.accent);
|
|
1950
|
+
return text;
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
function prettyDetailValue(value, label = '') {
|
|
1954
|
+
const text = String(value ?? '');
|
|
1955
|
+
if (!shouldColorOutput() || !text) return text;
|
|
1956
|
+
if (/命令|写法|CLI|JSON|Agent|Dry-run|继续|确认|执行/.test(label) || stripAnsi(text).startsWith(commandPrefix())) {
|
|
1957
|
+
return commandText(text);
|
|
1958
|
+
}
|
|
1959
|
+
if (/状态|验证|当前|必填|已/.test(label)) return semanticText(text);
|
|
1960
|
+
return colorText(text, COLOR.value);
|
|
1961
|
+
}
|
|
1962
|
+
|
|
1963
|
+
function humanizeKey(key) {
|
|
1964
|
+
if (FIELD_LABELS[key]) return FIELD_LABELS[key];
|
|
1965
|
+
return String(key || '')
|
|
1966
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
1967
|
+
.replace(/[_-]+/g, ' ')
|
|
1968
|
+
.replace(/\b\w/g, (char) => char.toUpperCase());
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1971
|
+
function prettyBoolean(value) {
|
|
1972
|
+
return value ? '是' : '否';
|
|
1973
|
+
}
|
|
1974
|
+
|
|
1975
|
+
function prettyValue(value, options = {}) {
|
|
1976
|
+
if (value === undefined || value === null || value === '') return '';
|
|
1977
|
+
if (typeof value === 'boolean') return prettyBoolean(value);
|
|
1978
|
+
if (Array.isArray(value)) {
|
|
1979
|
+
if (!value.length) return '无';
|
|
1980
|
+
if (value.every((item) => !isPlainObject(item) && !Array.isArray(item))) return value.map((item) => prettyValue(item)).join('、');
|
|
1981
|
+
return `${value.length} 项`;
|
|
1982
|
+
}
|
|
1983
|
+
if (isPlainObject(value)) {
|
|
1984
|
+
const summary = renderRecord(compactRecord(value), options.objectKeys || []);
|
|
1985
|
+
return summary || JSON.stringify(value);
|
|
1986
|
+
}
|
|
1987
|
+
return rewriteCommandPrefix(value);
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
function resolveColumnValue(row, column) {
|
|
1991
|
+
if (typeof column.value === 'function') return column.value(row);
|
|
1992
|
+
if (typeof column.key === 'function') return column.key(row);
|
|
1993
|
+
if (Array.isArray(column.key)) {
|
|
1994
|
+
for (const key of column.key) {
|
|
1995
|
+
if (row?.[key] !== undefined && row?.[key] !== null && row?.[key] !== '') return row[key];
|
|
1996
|
+
}
|
|
1997
|
+
return undefined;
|
|
1998
|
+
}
|
|
1999
|
+
return row?.[column.key];
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
function column(header, key, options = {}) {
|
|
2003
|
+
return { header, key, ...options };
|
|
2004
|
+
}
|
|
2005
|
+
|
|
2006
|
+
function joinValueList(value, limit = 6) {
|
|
2007
|
+
if (!Array.isArray(value)) return prettyValue(value);
|
|
2008
|
+
return valueList(value, limit)?.replaceAll('|', '、') || '';
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
const TABLE_COLUMNS = {
|
|
2012
|
+
assets: [
|
|
2013
|
+
column('标签', 'label', { maxWidth: 14 }),
|
|
2014
|
+
column('引用类型', ['referenceType', 'type'], { maxWidth: 16 }),
|
|
2015
|
+
column('用途', 'usage', { maxWidth: 16 }),
|
|
2016
|
+
column('路径', 'assetPath', { maxWidth: 42 }),
|
|
2017
|
+
column('素材 ID', 'assetId', { maxWidth: 22 }),
|
|
2018
|
+
],
|
|
2019
|
+
buckets: [
|
|
2020
|
+
column('任务类型', 'taskType', { maxWidth: 24 }),
|
|
2021
|
+
column('任务数', 'taskCount', { maxWidth: 10 }),
|
|
2022
|
+
column('成功数', 'successTaskCount', { maxWidth: 10 }),
|
|
2023
|
+
column('结果数', 'resultCount', { maxWidth: 10 }),
|
|
2024
|
+
column('积分', 'pointTotal', { maxWidth: 10 }),
|
|
2025
|
+
],
|
|
2026
|
+
checks: [
|
|
2027
|
+
column('检查项', 'name', { maxWidth: 18 }),
|
|
2028
|
+
column('状态', 'status', { maxWidth: 12 }),
|
|
2029
|
+
column('说明', 'message', { maxWidth: 58 }),
|
|
2030
|
+
],
|
|
2031
|
+
commands: [
|
|
2032
|
+
column('命令', 'name', { maxWidth: 34 }),
|
|
2033
|
+
column('领域', 'domain', { maxWidth: 12 }),
|
|
2034
|
+
column('输出', (row) => row.workflow?.outputKind, { maxWidth: 24 }),
|
|
2035
|
+
column('安全', (row) => (row.safety?.safeToAutoRun ? '可自动运行' : '需确认/写入'), { maxWidth: 14 }),
|
|
2036
|
+
column('说明', 'summary', { maxWidth: 44 }),
|
|
2037
|
+
],
|
|
2038
|
+
domains: [
|
|
2039
|
+
column('领域', 'name', { maxWidth: 14 }),
|
|
2040
|
+
column('命令数', 'commandCount', { maxWidth: 10 }),
|
|
2041
|
+
column('说明', 'description', { maxWidth: 60 }),
|
|
2042
|
+
],
|
|
2043
|
+
files: [
|
|
2044
|
+
column('文件', ['filePath', 'path', 'fileName'], { maxWidth: 38 }),
|
|
2045
|
+
column('场景', 'sceneType', { maxWidth: 24 }),
|
|
2046
|
+
column('类型', ['mimeType', 'mime'], { maxWidth: 18 }),
|
|
2047
|
+
column('大小', 'size', { maxWidth: 10 }),
|
|
2048
|
+
column('后端路径', ['backendPath', 'url'], { maxWidth: 42 }),
|
|
2049
|
+
],
|
|
2050
|
+
groups: [
|
|
2051
|
+
column('组 ID', 'groupId', { maxWidth: 24 }),
|
|
2052
|
+
column('平台', 'platform', { maxWidth: 12 }),
|
|
2053
|
+
column('名称', 'name', { maxWidth: 24 }),
|
|
2054
|
+
column('项目名', 'projectName', { maxWidth: 24 }),
|
|
2055
|
+
column('状态', 'status', { maxWidth: 14 }),
|
|
2056
|
+
],
|
|
2057
|
+
items: [
|
|
2058
|
+
column('ID', ['id', 'entityKey', 'key'], { maxWidth: 24 }),
|
|
2059
|
+
column('类型', ['rowKind', 'assetKind'], { maxWidth: 16 }),
|
|
2060
|
+
column('名称', ['title', 'name', 'displayName'], { maxWidth: 30 }),
|
|
2061
|
+
column('父级', 'parentKey', { maxWidth: 22 }),
|
|
2062
|
+
column('状态', 'status', { maxWidth: 16 }),
|
|
2063
|
+
column('说明', 'description', { maxWidth: 42 }),
|
|
2064
|
+
],
|
|
2065
|
+
localFiles: [
|
|
2066
|
+
column('文件', ['path', 'filePath', 'fileName'], { maxWidth: 42 }),
|
|
2067
|
+
column('存在', 'exists', { maxWidth: 8 }),
|
|
2068
|
+
column('类型', ['mimeType', 'mime'], { maxWidth: 18 }),
|
|
2069
|
+
column('大小', 'size', { maxWidth: 10 }),
|
|
2070
|
+
],
|
|
2071
|
+
matches: [
|
|
2072
|
+
column('素材 ID', 'assetId', { maxWidth: 22 }),
|
|
2073
|
+
column('名称', ['name', 'assetName'], { maxWidth: 24 }),
|
|
2074
|
+
column('分数', 'score', { maxWidth: 8 }),
|
|
2075
|
+
column('图片', 'imageUrl', { maxWidth: 42 }),
|
|
2076
|
+
],
|
|
2077
|
+
models: [
|
|
2078
|
+
column('模型组', 'modelGroupCode', { maxWidth: 34 }),
|
|
2079
|
+
column('名称', ['displayName', 'modelName'], { maxWidth: 24 }),
|
|
2080
|
+
column('说明', 'modelDesc', { maxWidth: 34 }),
|
|
2081
|
+
column('排队数', 'taskQueueNum', { maxWidth: 8 }),
|
|
2082
|
+
column('成功率', (row) => formatPercent(row.successRate), { maxWidth: 8 }),
|
|
2083
|
+
column('输入', (row) => joinValueList(row.inputModes), { maxWidth: 28 }),
|
|
2084
|
+
column('参数', (row) => joinValueList(row.params), { maxWidth: 24 }),
|
|
2085
|
+
column('素材', (row) => joinValueList(row.resourceParams), { maxWidth: 24 }),
|
|
2086
|
+
],
|
|
2087
|
+
params: [
|
|
2088
|
+
column('参数', 'key', { maxWidth: 22 }),
|
|
2089
|
+
column('类型', 'valueType', { maxWidth: 12 }),
|
|
2090
|
+
column('可选值', (row) => joinValueList(row.values, 8), { maxWidth: 42 }),
|
|
2091
|
+
column('默认', 'defaultValue', { maxWidth: 14 }),
|
|
2092
|
+
column('必填', 'required', { maxWidth: 8 }),
|
|
2093
|
+
],
|
|
2094
|
+
projectGroups: [
|
|
2095
|
+
column('项目组编号', 'projectGroupNo', { maxWidth: 24 }),
|
|
2096
|
+
column('名称', 'projectGroupName', { maxWidth: 28 }),
|
|
2097
|
+
column('当前', 'isSelected', { maxWidth: 8 }),
|
|
2098
|
+
column('预算余额', ['projectBudgetBalance', 'projectPointBalance'], { maxWidth: 12 }),
|
|
2099
|
+
column('成员', 'memberCount', { maxWidth: 8 }),
|
|
2100
|
+
],
|
|
2101
|
+
records: [
|
|
2102
|
+
column('任务 ID', ['taskId', 'publicId', 'remoteTaskId'], { maxWidth: 28 }),
|
|
2103
|
+
column('类型', 'taskType', { maxWidth: 20 }),
|
|
2104
|
+
column('状态', ['taskStatus', 'status'], { maxWidth: 16 }),
|
|
2105
|
+
column('模型', 'modelGroupCode', { maxWidth: 30 }),
|
|
2106
|
+
column('结果数', 'resultCount', { maxWidth: 8 }),
|
|
2107
|
+
column('记录时间', ['recordedAt', 'gmtCreate', 'createdAt'], { maxWidth: 22 }),
|
|
2108
|
+
],
|
|
2109
|
+
resources: [
|
|
2110
|
+
column('模式', 'mode', { maxWidth: 16 }),
|
|
2111
|
+
column('媒体', 'mediaType', { maxWidth: 10 }),
|
|
2112
|
+
column('用途', (row) => joinValueList(row.usage), { maxWidth: 26 }),
|
|
2113
|
+
column('输入形态', (row) => textValueShapes(row.valueShapes)?.replaceAll('|', '、'), { maxWidth: 28 }),
|
|
2114
|
+
column('格式', (row) => textResourceFormats(row)?.replaceAll('|', '、'), { maxWidth: 28 }),
|
|
2115
|
+
column('文件数', (row) => textFileCount(row), { maxWidth: 10 }),
|
|
2116
|
+
column('WebP', (row) => textWebpInput(row), { maxWidth: 18 }),
|
|
2117
|
+
],
|
|
2118
|
+
results: [
|
|
2119
|
+
column('序号', 'inputIndex', { maxWidth: 8 }),
|
|
2120
|
+
column('状态', ['status', 'taskStatus'], { maxWidth: 16 }),
|
|
2121
|
+
column('任务 ID', 'taskId', { maxWidth: 28 }),
|
|
2122
|
+
column('模型/主体', ['modelGroupCode', 'modelCode', 'name'], { maxWidth: 30 }),
|
|
2123
|
+
column('说明', ['message', 'errorMessage', 'prompt'], { maxWidth: 42 }),
|
|
2124
|
+
],
|
|
2125
|
+
subjects: [
|
|
2126
|
+
column('主体 ID', ['elementId', 'subjectId'], { maxWidth: 24 }),
|
|
2127
|
+
column('名称', 'name', { maxWidth: 24 }),
|
|
2128
|
+
column('模型', 'modelCode', { maxWidth: 14 }),
|
|
2129
|
+
column('外部 ID', 'externalId', { maxWidth: 24 }),
|
|
2130
|
+
column('状态', ['status', 'taskStatus'], { maxWidth: 14 }),
|
|
2131
|
+
],
|
|
2132
|
+
tasks: [
|
|
2133
|
+
column('任务 ID', ['taskId', 'publicId', 'remoteTaskId'], { maxWidth: 28 }),
|
|
2134
|
+
column('类型', 'taskType', { maxWidth: 20 }),
|
|
2135
|
+
column('状态', 'taskStatus', { maxWidth: 16 }),
|
|
2136
|
+
column('模型', 'modelGroupCode', { maxWidth: 30 }),
|
|
2137
|
+
column('结果数', 'resultCount', { maxWidth: 8 }),
|
|
2138
|
+
column('创建时间', 'gmtCreate', { maxWidth: 22 }),
|
|
2139
|
+
],
|
|
2140
|
+
teams: [
|
|
2141
|
+
column('团队 ID', 'groupId', { maxWidth: 22 }),
|
|
2142
|
+
column('团队名称', 'groupName', { maxWidth: 28 }),
|
|
2143
|
+
column('当前', ['currentGroup', 'isSelected'], { maxWidth: 8 }),
|
|
2144
|
+
column('角色', 'role', { maxWidth: 14 }),
|
|
2145
|
+
],
|
|
2146
|
+
users: [
|
|
2147
|
+
column('用户 ID', 'userId', { maxWidth: 22 }),
|
|
2148
|
+
column('用户名', 'userName', { maxWidth: 24 }),
|
|
2149
|
+
column('角色', 'role', { maxWidth: 14 }),
|
|
2150
|
+
column('当前', ['currentGroup', 'isCheck'], { maxWidth: 8 }),
|
|
2151
|
+
],
|
|
2152
|
+
voices: [
|
|
2153
|
+
column('音色记录 ID', ['voiceRecordId', 'reqTaskId'], { maxWidth: 26 }),
|
|
2154
|
+
column('名称', 'name', { maxWidth: 24 }),
|
|
2155
|
+
column('音色 ID', ['voiceId', 'externalId'], { maxWidth: 24 }),
|
|
2156
|
+
column('状态', ['status', 'taskStatus'], { maxWidth: 14 }),
|
|
2157
|
+
],
|
|
2158
|
+
};
|
|
2159
|
+
|
|
2160
|
+
function inferTableColumns(rows = []) {
|
|
2161
|
+
const first = rows.find((row) => isPlainObject(row));
|
|
2162
|
+
if (!first) return [column('值', (row) => prettyValue(row), { maxWidth: 70 })];
|
|
2163
|
+
const preferred = [
|
|
2164
|
+
'id',
|
|
2165
|
+
'taskId',
|
|
2166
|
+
'publicId',
|
|
2167
|
+
'modelGroupCode',
|
|
2168
|
+
'projectGroupNo',
|
|
2169
|
+
'projectId',
|
|
2170
|
+
'rowKind',
|
|
2171
|
+
'entityKey',
|
|
2172
|
+
'name',
|
|
2173
|
+
'displayName',
|
|
2174
|
+
'title',
|
|
2175
|
+
'status',
|
|
2176
|
+
'taskStatus',
|
|
2177
|
+
'resultCount',
|
|
2178
|
+
'errorMessage',
|
|
2179
|
+
];
|
|
2180
|
+
const keys = [
|
|
2181
|
+
...preferred.filter((key) => first[key] !== undefined),
|
|
2182
|
+
...Object.keys(first).filter((key) => !preferred.includes(key) && !Array.isArray(first[key]) && !isPlainObject(first[key])),
|
|
2183
|
+
].slice(0, 6);
|
|
2184
|
+
return keys.map((key) => column(humanizeKey(key), key, { maxWidth: key.toLowerCase().includes('url') ? 42 : 28 }));
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2187
|
+
function renderPrettyTable(rows = [], columns = [], options = {}) {
|
|
2188
|
+
const tableRows = Array.isArray(rows) ? rows : [];
|
|
2189
|
+
if (!tableRows.length) return [` ${mutedText(options.emptyText || '无记录')}`];
|
|
2190
|
+
const rawCols = columns.length ? columns : inferTableColumns(tableRows);
|
|
2191
|
+
const rawRows = tableRows.map((row, index) => rawCols.map((col) => {
|
|
2192
|
+
const raw = col.index ? index + 1 : resolveColumnValue(row, col);
|
|
2193
|
+
const value = String(prettyValue(raw)).replace(/\r\n/g, '\n');
|
|
2194
|
+
return value;
|
|
2195
|
+
}));
|
|
2196
|
+
const visibleColumnIndexes = rawCols
|
|
2197
|
+
.map((col, index) => ({ col, index }))
|
|
2198
|
+
.filter(({ col, index }) => col.always || rawCols.length === 1 || rawRows.some((row) => row[index] !== ''))
|
|
2199
|
+
.map(({ index }) => index);
|
|
2200
|
+
if (!visibleColumnIndexes.length) {
|
|
2201
|
+
visibleColumnIndexes.push(...rawCols.map((_, index) => index));
|
|
2202
|
+
}
|
|
2203
|
+
const cols = visibleColumnIndexes.map((index) => rawCols[index]);
|
|
2204
|
+
const headerCells = cols.map((col) => col.header);
|
|
2205
|
+
const bodyRows = rawRows.map((row) => visibleColumnIndexes.map((index) => row[index]));
|
|
2206
|
+
const widths = cols.map((col, colIndex) => {
|
|
2207
|
+
const values = [headerCells[colIndex], ...bodyRows.map((row) => row[colIndex])];
|
|
2208
|
+
const max = Math.max(...values.map(displayWidth));
|
|
2209
|
+
return Math.max(col.minWidth || 4, Math.min(col.maxWidth || 30, max));
|
|
2210
|
+
});
|
|
2211
|
+
const renderedRows = bodyRows.map((row, rowIndex) => row.map((cell, colIndex) => {
|
|
2212
|
+
const wrapped = wrapDisplay(cell, widths[colIndex]).join('\n');
|
|
2213
|
+
return prettyCellText(wrapped, { ...cols[colIndex], rowIndex });
|
|
2214
|
+
}));
|
|
2215
|
+
const table = new Table({
|
|
2216
|
+
head: headerCells.map((cell) => headerText(cell)),
|
|
2217
|
+
colWidths: widths.map((width) => width + 2),
|
|
2218
|
+
wordWrap: false,
|
|
2219
|
+
truncate: '',
|
|
2220
|
+
style: {
|
|
2221
|
+
head: [],
|
|
2222
|
+
border: [],
|
|
2223
|
+
compact: false,
|
|
2224
|
+
'padding-left': 1,
|
|
2225
|
+
'padding-right': 1,
|
|
2226
|
+
},
|
|
2227
|
+
});
|
|
2228
|
+
table.push(...renderedRows);
|
|
2229
|
+
return table.toString()
|
|
2230
|
+
.split('\n')
|
|
2231
|
+
.map((line) => line.replace(/[┌┬┐├┼┤└┴┘│─]/g, (char) => borderText(char)));
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2234
|
+
function sectionTitle(lines, title) {
|
|
2235
|
+
if (lines.length && lines[lines.length - 1] !== '') lines.push('');
|
|
2236
|
+
lines.push(sectionText(title));
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2239
|
+
function detailRows(record, preferredKeys = [], excludedKeys = [], options = {}) {
|
|
2240
|
+
if (!isPlainObject(record)) return [];
|
|
2241
|
+
const excluded = new Set(excludedKeys);
|
|
2242
|
+
const preferred = preferredKeys.filter((key) => !excluded.has(key) && record[key] !== undefined && record[key] !== null && record[key] !== '');
|
|
2243
|
+
const fallback = options.includeRest
|
|
2244
|
+
? Object.keys(record).filter((key) => {
|
|
2245
|
+
if (excluded.has(key) || preferredKeys.includes(key)) return false;
|
|
2246
|
+
const value = record[key];
|
|
2247
|
+
if (value === undefined || value === null || value === '') return false;
|
|
2248
|
+
if (Array.isArray(value) || isPlainObject(value)) return false;
|
|
2249
|
+
return true;
|
|
2250
|
+
})
|
|
2251
|
+
: [];
|
|
2252
|
+
const keys = [...preferred, ...fallback];
|
|
2253
|
+
return keys.map((key) => ({ label: humanizeKey(key), value: record[key] }));
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2256
|
+
function renderDetails(lines, title, record, preferredKeys = [], excludedKeys = [], options = {}) {
|
|
2257
|
+
const rows = detailRows(record, preferredKeys, excludedKeys, options);
|
|
2258
|
+
if (!rows.length) return;
|
|
2259
|
+
sectionTitle(lines, title);
|
|
2260
|
+
const labelWidth = Math.min(22, Math.max(...rows.map((row) => displayWidth(row.label))));
|
|
2261
|
+
for (const row of rows) {
|
|
2262
|
+
const value = String(prettyValue(row.value)).replace(/\s*\r?\n\s*/g, ' ');
|
|
2263
|
+
const valueLines = wrapDisplay(value, options.valueWidth || 96);
|
|
2264
|
+
for (const [index, valueLine] of valueLines.entries()) {
|
|
2265
|
+
const label = index === 0 ? row.label : '';
|
|
2266
|
+
lines.push(` ${labelText(padDisplay(label, labelWidth))} ${prettyDetailValue(valueLine, row.label)}`);
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
|
|
2271
|
+
function renderArraySection(lines, title, rows, listKey, limit = Number.POSITIVE_INFINITY) {
|
|
2272
|
+
if (!Array.isArray(rows) || !rows.length) return;
|
|
2273
|
+
const visibleRows = rows.slice(0, Number.isFinite(limit) ? limit : rows.length);
|
|
2274
|
+
sectionTitle(lines, `${title}(${rows.length})`);
|
|
2275
|
+
const columns = Array.isArray(listKey) ? listKey : (TABLE_COLUMNS[listKey] || inferTableColumns(visibleRows));
|
|
2276
|
+
lines.push(...renderPrettyTable(visibleRows, columns));
|
|
2277
|
+
if (rows.length > visibleRows.length) lines.push(` ${mutedText(`还有 ${rows.length - visibleRows.length} 条未展示;使用 --all 或 -f json 查看完整数据。`)}`);
|
|
2278
|
+
}
|
|
2279
|
+
|
|
2280
|
+
function renderScalarList(lines, title, values = [], limit = 8) {
|
|
2281
|
+
if (!Array.isArray(values) || !values.length) return;
|
|
2282
|
+
sectionTitle(lines, `${title}(${values.length})`);
|
|
2283
|
+
for (const [index, value] of values.slice(0, limit).entries()) {
|
|
2284
|
+
lines.push(` ${mutedText(`${index + 1}.`)} ${prettyDetailValue(prettyValue(value), title)}`);
|
|
2285
|
+
}
|
|
2286
|
+
if (values.length > limit) lines.push(` ${mutedText(`还有 ${values.length - limit} 项未展示;使用 -f json 查看完整数据。`)}`);
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2289
|
+
function namedListTitle(listKey) {
|
|
2290
|
+
return {
|
|
2291
|
+
assets: '素材',
|
|
2292
|
+
buckets: '用量分组',
|
|
2293
|
+
checks: '检查结果',
|
|
2294
|
+
commands: '命令',
|
|
2295
|
+
domains: '命令领域',
|
|
2296
|
+
files: '文件',
|
|
2297
|
+
groups: '素材组',
|
|
2298
|
+
items: '记录',
|
|
2299
|
+
localFiles: '本地文件',
|
|
2300
|
+
matches: '匹配项',
|
|
2301
|
+
models: '模型',
|
|
2302
|
+
params: '参数',
|
|
2303
|
+
projectGroups: '项目组',
|
|
2304
|
+
records: '记录',
|
|
2305
|
+
resources: '素材约束',
|
|
2306
|
+
results: '结果',
|
|
2307
|
+
subjects: '主体',
|
|
2308
|
+
tasks: '任务',
|
|
2309
|
+
teams: '团队',
|
|
2310
|
+
users: '成员',
|
|
2311
|
+
voices: '音色',
|
|
2312
|
+
}[listKey] || humanizeKey(listKey);
|
|
2313
|
+
}
|
|
2314
|
+
|
|
2315
|
+
function localizedTaskKind(value) {
|
|
2316
|
+
if (value === 'image' || value === 'IMAGE_CREATE') return '图片生成';
|
|
2317
|
+
if (value === 'video' || value === 'VIDEO_CREATE') return '视频生成';
|
|
2318
|
+
return prettyValue(value);
|
|
2319
|
+
}
|
|
2320
|
+
|
|
2321
|
+
function localizedInputMode(value, taskKind = '') {
|
|
2322
|
+
const mode = String(value || '');
|
|
2323
|
+
const isVideo = taskKind === 'video' || taskKind === 'VIDEO_CREATE';
|
|
2324
|
+
const labels = {
|
|
2325
|
+
prompt_only: isVideo ? '文本生成视频' : '文本生成图片',
|
|
2326
|
+
reference: isVideo ? '参考素材生成' : '参考图生成',
|
|
2327
|
+
frames: '首帧/尾帧生成',
|
|
2328
|
+
storyboard: '分镜多镜头',
|
|
2329
|
+
keyframe: '关键帧生成',
|
|
2330
|
+
};
|
|
2331
|
+
return labels[mode] || mode;
|
|
2332
|
+
}
|
|
2333
|
+
|
|
2334
|
+
function localizedParamKey(value) {
|
|
2335
|
+
const labels = {
|
|
2336
|
+
ratio: '宽高比',
|
|
2337
|
+
quality: '清晰度',
|
|
2338
|
+
generateNum: '生成数量',
|
|
2339
|
+
generate_num: '生成数量',
|
|
2340
|
+
duration: '时长',
|
|
2341
|
+
generated_time: '时长',
|
|
2342
|
+
needAudio: '生成音频',
|
|
2343
|
+
need_audio: '生成音频',
|
|
2344
|
+
prompt_optimizer: '提示词增强',
|
|
2345
|
+
};
|
|
2346
|
+
return labels[value] || value;
|
|
2347
|
+
}
|
|
2348
|
+
|
|
2349
|
+
function localizedParamType(value) {
|
|
2350
|
+
const labels = {
|
|
2351
|
+
enum: '枚举选择',
|
|
2352
|
+
text: '文本',
|
|
2353
|
+
string: '文本',
|
|
2354
|
+
number: '数字',
|
|
2355
|
+
integer: '整数',
|
|
2356
|
+
boolean: '开关',
|
|
2357
|
+
bool: '开关',
|
|
2358
|
+
};
|
|
2359
|
+
return labels[String(value || '').toLowerCase()] || value;
|
|
2360
|
+
}
|
|
2361
|
+
|
|
2362
|
+
function cliFlagForParam(key) {
|
|
2363
|
+
const flags = {
|
|
2364
|
+
ratio: '--ratio',
|
|
2365
|
+
quality: '--quality',
|
|
2366
|
+
generateNum: '--generate-num',
|
|
2367
|
+
generate_num: '--generate-num',
|
|
2368
|
+
duration: '--duration',
|
|
2369
|
+
generated_time: '--duration',
|
|
2370
|
+
needAudio: '--need-audio',
|
|
2371
|
+
need_audio: '--need-audio',
|
|
2372
|
+
prompt: '--prompt',
|
|
2373
|
+
};
|
|
2374
|
+
return flags[key] || (key ? `--model-param ${key}=...` : '');
|
|
2375
|
+
}
|
|
2376
|
+
|
|
2377
|
+
function localizedResourceParam(value) {
|
|
2378
|
+
const labels = {
|
|
2379
|
+
iref: '参考图',
|
|
2380
|
+
cref: '角色参考',
|
|
2381
|
+
sref: '风格参考',
|
|
2382
|
+
resources: '统一素材',
|
|
2383
|
+
frames: '首帧/尾帧',
|
|
2384
|
+
multi_param: '多帧参数',
|
|
2385
|
+
multi_prompt: '多段提示词',
|
|
2386
|
+
};
|
|
2387
|
+
return labels[value] || value;
|
|
2388
|
+
}
|
|
2389
|
+
|
|
2390
|
+
function localizedMedia(value) {
|
|
2391
|
+
const labels = {
|
|
2392
|
+
IMAGE: '图片',
|
|
2393
|
+
VIDEO: '视频',
|
|
2394
|
+
AUDIO: '音频',
|
|
2395
|
+
SUBJECT: '主体',
|
|
2396
|
+
};
|
|
2397
|
+
return labels[String(value || '').toUpperCase()] || prettyValue(value);
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2400
|
+
function localizedUsage(value) {
|
|
2401
|
+
const labels = {
|
|
2402
|
+
reference: '参考素材',
|
|
2403
|
+
first_frame: '首帧',
|
|
2404
|
+
last_frame: '尾帧',
|
|
2405
|
+
keyframe: '关键帧',
|
|
2406
|
+
prompt_only: '纯文本',
|
|
2407
|
+
storyboard: '故事板',
|
|
2408
|
+
};
|
|
2409
|
+
if (Array.isArray(value)) return value.map((item) => localizedUsage(item)).join('、');
|
|
2410
|
+
return labels[value] || prettyValue(value);
|
|
2411
|
+
}
|
|
2412
|
+
|
|
2413
|
+
function localizedResourcePurpose(item = {}, taskKind = '') {
|
|
2414
|
+
const modeText = localizedInputMode(item.mode, taskKind);
|
|
2415
|
+
const usageText = localizedUsage(item.usage);
|
|
2416
|
+
if (!usageText || usageText === '参考素材') return modeText;
|
|
2417
|
+
if (!modeText) return usageText;
|
|
2418
|
+
return `${modeText}(${usageText})`;
|
|
2419
|
+
}
|
|
2420
|
+
|
|
2421
|
+
function localizedResourceTarget(value, limits = {}) {
|
|
2422
|
+
const text = String(value || '');
|
|
2423
|
+
const match = text.match(/^resource\.([^.]+)\.([^.]+)(?:\.count)?$/);
|
|
2424
|
+
if (!match) return '';
|
|
2425
|
+
const [, media, usage] = match;
|
|
2426
|
+
const mediaType = String(limits.mediaType || media).toUpperCase();
|
|
2427
|
+
const usageText = localizedUsage(limits.usage || usage);
|
|
2428
|
+
const mediaText = localizedMedia(mediaType);
|
|
2429
|
+
if (usage === 'first_frame' || usage === 'last_frame') return `${usageText}${mediaText}`;
|
|
2430
|
+
if (usage === 'frame') return `首帧/尾帧${mediaText}`;
|
|
2431
|
+
if (usage === 'reference') return `参考${mediaText}`;
|
|
2432
|
+
return `${usageText}${mediaText}`;
|
|
2433
|
+
}
|
|
2434
|
+
|
|
2435
|
+
function localizedValueShape(value) {
|
|
2436
|
+
const labels = {
|
|
2437
|
+
local_file: '本地文件',
|
|
2438
|
+
file: '本地文件',
|
|
2439
|
+
http_url: 'URL',
|
|
2440
|
+
url: 'URL',
|
|
2441
|
+
backendPath: '平台素材路径',
|
|
2442
|
+
platformPath: '平台素材路径',
|
|
2443
|
+
asset_id: '资产 ID',
|
|
2444
|
+
asset: '资产 ID',
|
|
2445
|
+
};
|
|
2446
|
+
return labels[value] || value;
|
|
2447
|
+
}
|
|
2448
|
+
|
|
2449
|
+
function localizedInputShapes(values = []) {
|
|
2450
|
+
const items = Array.isArray(values) ? values : [];
|
|
2451
|
+
if (!items.length) return '';
|
|
2452
|
+
return items.map(localizedValueShape).join('、');
|
|
2453
|
+
}
|
|
2454
|
+
|
|
2455
|
+
function localizedFormats(item = {}) {
|
|
2456
|
+
const formats = textResourceFormats(item);
|
|
2457
|
+
return formats ? formats.replaceAll('|', '、') : '';
|
|
2458
|
+
}
|
|
2459
|
+
|
|
2460
|
+
function localizedFileCount(item = {}) {
|
|
2461
|
+
const value = textFileCount(item);
|
|
2462
|
+
if (!value) return '';
|
|
2463
|
+
if (value.startsWith('<=')) return `最多 ${value.slice(2)} 个`;
|
|
2464
|
+
if (value.startsWith('>=')) return `至少 ${value.slice(2)} 个`;
|
|
2465
|
+
if (value.includes('..')) return `${value.replace('..', '-')} 个`;
|
|
2466
|
+
return `${value} 个`;
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2469
|
+
function localizedItemCount(item = {}) {
|
|
2470
|
+
const value = textItemCount(item);
|
|
2471
|
+
if (!value) return '';
|
|
2472
|
+
if (value.startsWith('<=')) return `最多 ${value.slice(2)} 项`;
|
|
2473
|
+
if (value.startsWith('>=')) return `至少 ${value.slice(2)} 项`;
|
|
2474
|
+
if (value.includes('..')) return `${value.replace('..', '-')} 项`;
|
|
2475
|
+
return `${value} 项`;
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
function formatKb(value) {
|
|
2479
|
+
const kb = Number(value);
|
|
2480
|
+
if (!Number.isFinite(kb)) return '';
|
|
2481
|
+
if (kb >= 1024) {
|
|
2482
|
+
const mb = kb / 1024;
|
|
2483
|
+
return `${Number.isInteger(mb) ? mb : mb.toFixed(1)} MB`;
|
|
2484
|
+
}
|
|
2485
|
+
return `${kb} KB`;
|
|
2486
|
+
}
|
|
2487
|
+
|
|
2488
|
+
function formatMs(value) {
|
|
2489
|
+
const ms = Number(value);
|
|
2490
|
+
if (!Number.isFinite(ms)) return '';
|
|
2491
|
+
const seconds = ms / 1000;
|
|
2492
|
+
if (seconds >= 1) return `${Number.isInteger(seconds) ? seconds : seconds.toFixed(1)} 秒`;
|
|
2493
|
+
return `${ms} 毫秒`;
|
|
2494
|
+
}
|
|
2495
|
+
|
|
2496
|
+
function localizedDurationRange(item = {}) {
|
|
2497
|
+
if (item.minDurationMs != null && item.maxDurationMs != null) return `${formatMs(item.minDurationMs)}-${formatMs(item.maxDurationMs)}`;
|
|
2498
|
+
if (item.maxDurationMs != null) return `最多 ${formatMs(item.maxDurationMs)}`;
|
|
2499
|
+
if (item.minDurationMs != null) return `至少 ${formatMs(item.minDurationMs)}`;
|
|
2500
|
+
return '';
|
|
2501
|
+
}
|
|
2502
|
+
|
|
2503
|
+
function localizedTotalDuration(item = {}) {
|
|
2504
|
+
if (item.maxTotalDurationMs == null) return '';
|
|
2505
|
+
return `最多 ${formatMs(item.maxTotalDurationMs)}`;
|
|
2506
|
+
}
|
|
2507
|
+
|
|
2508
|
+
function localizedWebpPolicy(item = {}) {
|
|
2509
|
+
const value = textWebpInput(item);
|
|
2510
|
+
if (value === 'accepted') return '支持 WebP';
|
|
2511
|
+
if (String(value || '').startsWith('autoConvertTo')) return `WebP 自动转 ${String(value).replace('autoConvertTo', '')}`;
|
|
2512
|
+
if (value === 'unsupported') return '不支持 WebP';
|
|
2513
|
+
return '';
|
|
2514
|
+
}
|
|
2515
|
+
|
|
2516
|
+
function localizedConditionKey(value) {
|
|
2517
|
+
const resourceTarget = localizedResourceTarget(value);
|
|
2518
|
+
if (resourceTarget && String(value || '').endsWith('.count')) return `${resourceTarget}数量`;
|
|
2519
|
+
if (resourceTarget) return resourceTarget;
|
|
2520
|
+
const labels = {
|
|
2521
|
+
'resource.image.frame': '使用首帧/尾帧图片',
|
|
2522
|
+
generatedMode: '生成方式',
|
|
2523
|
+
ratio: '宽高比',
|
|
2524
|
+
quality: '清晰度',
|
|
2525
|
+
duration: '时长',
|
|
2526
|
+
generated_time: '时长',
|
|
2527
|
+
};
|
|
2528
|
+
return labels[value] || localizedParamKey(value);
|
|
2529
|
+
}
|
|
2530
|
+
|
|
2531
|
+
function localizedConditionValue(value) {
|
|
2532
|
+
if (value === '__NOT_EMPTY__') return '已提供';
|
|
2533
|
+
if (value === '__EMPTY__') return '未提供';
|
|
2534
|
+
const labels = {
|
|
2535
|
+
multi_param: '参考素材生成',
|
|
2536
|
+
frames: '首帧/尾帧生成',
|
|
2537
|
+
multi_prompt: '分镜多镜头',
|
|
2538
|
+
prompt_only: '纯文本生成',
|
|
2539
|
+
};
|
|
2540
|
+
if (labels[value]) return labels[value];
|
|
2541
|
+
return prettyValue(value);
|
|
2542
|
+
}
|
|
2543
|
+
|
|
2544
|
+
function localizedCountRange(item = {}) {
|
|
2545
|
+
const value = textCountRange(item);
|
|
2546
|
+
if (!value) return '';
|
|
2547
|
+
if (String(value).startsWith('>=')) return `至少 ${String(value).slice(2)} 个`;
|
|
2548
|
+
if (String(value).startsWith('<=')) return `最多 ${String(value).slice(2)} 个`;
|
|
2549
|
+
if (String(value).includes('..')) return `${String(value).replace('..', '-')} 个`;
|
|
2550
|
+
return `${value} 个`;
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
function localizedConditions(conditions = []) {
|
|
2554
|
+
if (!Array.isArray(conditions) || !conditions.length) return '';
|
|
2555
|
+
return conditions
|
|
2556
|
+
.map((item) => {
|
|
2557
|
+
const key = item.key || item.configCode;
|
|
2558
|
+
if (!key) return null;
|
|
2559
|
+
if (item.meaning === 'count') return `${localizedConditionKey(key)}:${localizedCountRange(item)}`;
|
|
2560
|
+
if (key === 'resource.image.frame' && item.meaning === 'present') return '首尾帧模式';
|
|
2561
|
+
if (key === 'generatedMode' && item.value === 'multi_param') return '参考素材生成模式';
|
|
2562
|
+
if (key === 'generatedMode' && item.value === 'frames') return '首帧/尾帧模式';
|
|
2563
|
+
if (key === 'generatedMode' && item.value === 'multi_prompt') return '分镜多镜头模式';
|
|
2564
|
+
return `${localizedConditionKey(key)}${localizedConditionValue(item.value) ? `:${localizedConditionValue(item.value)}` : ''}`;
|
|
2565
|
+
})
|
|
2566
|
+
.filter(Boolean)
|
|
2567
|
+
.join(';');
|
|
2568
|
+
}
|
|
2569
|
+
|
|
2570
|
+
function constraintHasCondition(item = {}, key, value = undefined) {
|
|
2571
|
+
const conditions = Array.isArray(item.conditions) ? item.conditions : [];
|
|
2572
|
+
return conditions.some((condition) => (
|
|
2573
|
+
(condition.key || condition.configCode) === key
|
|
2574
|
+
&& (value === undefined || condition.value === value)
|
|
2575
|
+
));
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2578
|
+
function localizedConstraintResult(item = {}) {
|
|
2579
|
+
const target = item.target || item.targetConfigCode;
|
|
2580
|
+
const flag = cliFlagForParam(target);
|
|
2581
|
+
if (item.effect === 'resource_limit_overrides') {
|
|
2582
|
+
const limits = item.limits || {};
|
|
2583
|
+
const subject = localizedResourceTarget(target, limits) || '素材';
|
|
2584
|
+
const parts = [];
|
|
2585
|
+
const count = localizedFileCount(limits);
|
|
2586
|
+
const duration = localizedDurationRange(limits);
|
|
2587
|
+
const totalDuration = localizedTotalDuration(limits);
|
|
2588
|
+
const itemCount = localizedItemCount(limits);
|
|
2589
|
+
if (count) parts.push(`${subject}${count}`);
|
|
2590
|
+
if (duration) parts.push(`${subject}单个素材${duration}`);
|
|
2591
|
+
if (totalDuration) parts.push(`${subject}总时长${totalDuration}`);
|
|
2592
|
+
if (limits.maxSizeKB != null) parts.push(`${subject}单文件最多 ${formatKb(limits.maxSizeKB)}`);
|
|
2593
|
+
if (itemCount) parts.push(`${subject}${itemCount}`);
|
|
2594
|
+
return parts.join(';') || '素材限制随条件变化';
|
|
2595
|
+
}
|
|
2596
|
+
if (item.effect === 'no_selectable_values') {
|
|
2597
|
+
if (target === 'ratio' && constraintHasCondition(item, 'resource.image.frame')) {
|
|
2598
|
+
return `首尾帧模式不能手选比例;比例由输入图片决定,勿传 ${flag || localizedParamKey(target)}。`;
|
|
2599
|
+
}
|
|
2600
|
+
if (target === 'ratio') return `${flag || localizedParamKey(target)} 由素材决定,创建命令里不要再传。`;
|
|
2601
|
+
return `${flag || localizedParamKey(target)} 触发后没有可选值,创建命令里不要再传。`;
|
|
2602
|
+
}
|
|
2603
|
+
if (Array.isArray(item.allowValues) && item.allowValues.length) {
|
|
2604
|
+
if (target === 'ratio' && constraintHasCondition(item, 'generatedMode', 'multi_param')) {
|
|
2605
|
+
return `比例只能选:${item.allowValues.join('、')}`;
|
|
2606
|
+
}
|
|
2607
|
+
return `只能选择:${item.allowValues.join('、')}`;
|
|
2608
|
+
}
|
|
2609
|
+
return item.effect;
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2612
|
+
function localizedList(values = [], mapper = (value) => value) {
|
|
2613
|
+
if (!Array.isArray(values) || !values.length) return '';
|
|
2614
|
+
return values.map(mapper).filter(Boolean).join('、');
|
|
2615
|
+
}
|
|
2616
|
+
|
|
2617
|
+
function pushReadableRecord(lines, record = {}, fields = [], options = {}) {
|
|
2618
|
+
const rows = fields
|
|
2619
|
+
.map(([label, value]) => [label, value])
|
|
2620
|
+
.filter(([, value]) => value !== undefined && value !== null && value !== '');
|
|
2621
|
+
if (!rows.length) return;
|
|
2622
|
+
const labelWidth = Math.max(...rows.map(([label]) => displayWidth(label)));
|
|
2623
|
+
const indent = options.indent || ' ';
|
|
2624
|
+
for (const [label, value] of rows) {
|
|
2625
|
+
lines.push(`${indent}${padDisplay(label, labelWidth)} ${prettyValue(value)}`);
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
|
|
2629
|
+
function formatPrettyModelList(commandName, data = {}, context = {}) {
|
|
2630
|
+
const normalized = normalizeOutputData(commandName, data);
|
|
2631
|
+
const rows = Array.isArray(normalized.models) ? normalized.models : [];
|
|
2632
|
+
const taskKind = commandName === 'model video-models' ? 'video' : 'image';
|
|
2633
|
+
const limit = listLimitFor(commandName, context, rows);
|
|
2634
|
+
const visibleRows = rows.slice(0, Number.isFinite(limit) ? limit : rows.length);
|
|
2635
|
+
const lines = [prettyTitle(commandName, 'model_list', normalized), ''];
|
|
2636
|
+
sectionTitle(lines, `模型(${rows.length})`);
|
|
2637
|
+
if (!visibleRows.length) {
|
|
2638
|
+
lines.push(` ${mutedText('无匹配模型')}`);
|
|
2639
|
+
} else {
|
|
2640
|
+
const tableRows = visibleRows.map((row, index) => ({
|
|
2641
|
+
index: index + 1,
|
|
2642
|
+
displayName: row.displayName,
|
|
2643
|
+
note: row.modelDesc && row.modelDesc !== row.displayName ? row.modelDesc : row.provider,
|
|
2644
|
+
modelGroupCode: row.modelGroupCode,
|
|
2645
|
+
inputModesText: localizedList(row.inputModes, (item) => localizedInputMode(item, taskKind)),
|
|
2646
|
+
paramsText: localizedList(row.params, localizedParamKey),
|
|
2647
|
+
resourceText: localizedList(row.resourceParams, localizedResourceParam),
|
|
2648
|
+
queue: row.taskQueueNum ?? '',
|
|
2649
|
+
successRateText: formatPercent(row.successRate),
|
|
2650
|
+
}));
|
|
2651
|
+
lines.push(...renderPrettyTable(tableRows, [
|
|
2652
|
+
column('#', 'index', { minWidth: 1, maxWidth: 2, always: true }),
|
|
2653
|
+
column('模型', 'displayName', { minWidth: 10, maxWidth: 18, always: true }),
|
|
2654
|
+
column('来源/备注', 'note', { minWidth: 10, maxWidth: 20 }),
|
|
2655
|
+
column('模型组编码', 'modelGroupCode', { minWidth: 24, maxWidth: 36, always: true }),
|
|
2656
|
+
column('支持生成', 'inputModesText', { minWidth: 12, maxWidth: 22 }),
|
|
2657
|
+
column('可调参数', 'paramsText', { minWidth: 12, maxWidth: 22 }),
|
|
2658
|
+
column('素材能力', 'resourceText', { minWidth: 8, maxWidth: 16 }),
|
|
2659
|
+
column('排队数', 'queue', { minWidth: 4, maxWidth: 6 }),
|
|
2660
|
+
column('成功率', 'successRateText', { minWidth: 4, maxWidth: 8 }),
|
|
2661
|
+
]));
|
|
2662
|
+
}
|
|
2663
|
+
if (rows.length > visibleRows.length) {
|
|
2664
|
+
lines.push(` ${mutedText(`还有 ${rows.length - visibleRows.length} 个模型未展示;运行 ${context.moreCommand || `${commandPrefix()} ${commandName} --all`} 查看全部。`)}`);
|
|
2665
|
+
}
|
|
2666
|
+
renderNextActions(lines, collectPrettyActions(commandName, normalized, context), '先查看候选模型参数和素材约束,再推荐或进入 fee/dry-run。');
|
|
2667
|
+
return `${lines.join('\n')}\n`;
|
|
2668
|
+
}
|
|
2669
|
+
|
|
2670
|
+
function renderModelParams(lines, params = []) {
|
|
2671
|
+
const rows = Array.isArray(params) ? params : [];
|
|
2672
|
+
sectionTitle(lines, `参数(${rows.length})`);
|
|
2673
|
+
if (!rows.length) {
|
|
2674
|
+
lines.push(` ${mutedText('无可调参数')}`);
|
|
2675
|
+
return;
|
|
2676
|
+
}
|
|
2677
|
+
const tableRows = rows.map((param) => ({
|
|
2678
|
+
name: param.label || param.name || localizedParamKey(param.key),
|
|
2679
|
+
flag: cliFlagForParam(param.key),
|
|
2680
|
+
type: localizedParamType(param.valueType || param.type),
|
|
2681
|
+
values: Array.isArray(param.values) ? param.values.join('、') : '',
|
|
2682
|
+
defaultValue: param.defaultValue,
|
|
2683
|
+
required: param.required === undefined ? '' : prettyBoolean(param.required),
|
|
2684
|
+
limit: param.maxLength ? `最长 ${param.maxLength} 字符` : '',
|
|
2685
|
+
}));
|
|
2686
|
+
lines.push(...renderPrettyTable(tableRows, [
|
|
2687
|
+
column('参数', 'name', { minWidth: 8, maxWidth: 18, always: true }),
|
|
2688
|
+
column('CLI', 'flag', { minWidth: 8, maxWidth: 16 }),
|
|
2689
|
+
column('类型', 'type', { maxWidth: 10 }),
|
|
2690
|
+
column('可选值', 'values', { minWidth: 12, maxWidth: 36 }),
|
|
2691
|
+
column('默认', 'defaultValue', { maxWidth: 12 }),
|
|
2692
|
+
column('必填', 'required', { maxWidth: 6 }),
|
|
2693
|
+
column('限制', 'limit', { maxWidth: 16 }),
|
|
2694
|
+
]));
|
|
2695
|
+
}
|
|
2696
|
+
|
|
2697
|
+
function renderModelResources(lines, resources = [], taskKind = '') {
|
|
2698
|
+
const rows = Array.isArray(resources) ? resources : [];
|
|
2699
|
+
sectionTitle(lines, `素材约束(${rows.length})`);
|
|
2700
|
+
if (!rows.length) {
|
|
2701
|
+
lines.push(` ${mutedText('不需要素材')}`);
|
|
2702
|
+
return;
|
|
2703
|
+
}
|
|
2704
|
+
const tableRows = rows.map((item, index) => ({
|
|
2705
|
+
index: index + 1,
|
|
2706
|
+
purpose: localizedResourcePurpose(item, taskKind),
|
|
2707
|
+
media: localizedMedia(item.mediaType),
|
|
2708
|
+
input: localizedInputShapes(item.valueShapes || item.sources),
|
|
2709
|
+
formats: localizedFormats(item),
|
|
2710
|
+
count: localizedFileCount(item),
|
|
2711
|
+
limits: [
|
|
2712
|
+
item.maxSizeKB != null ? `单文件最多 ${formatKb(item.maxSizeKB)}` : '',
|
|
2713
|
+
localizedDurationRange(item) ? `单个素材 ${localizedDurationRange(item)}` : '',
|
|
2714
|
+
localizedTotalDuration(item) ? `总时长 ${localizedTotalDuration(item)}` : '',
|
|
2715
|
+
localizedItemCount(item) ? `条目 ${localizedItemCount(item)}` : '',
|
|
2716
|
+
localizedWebpPolicy(item),
|
|
2717
|
+
item.supportLastFrameOnly === undefined ? '' : `仅尾帧:${prettyBoolean(item.supportLastFrameOnly)}`,
|
|
2718
|
+
].filter(Boolean).join(';'),
|
|
2719
|
+
}));
|
|
2720
|
+
lines.push(...renderPrettyTable(tableRows, [
|
|
2721
|
+
column('#', 'index', { minWidth: 1, maxWidth: 2, always: true }),
|
|
2722
|
+
column('用途', 'purpose', { minWidth: 14, maxWidth: 24, always: true }),
|
|
2723
|
+
column('媒体', 'media', { maxWidth: 6, always: true }),
|
|
2724
|
+
column('输入方式', 'input', { minWidth: 16, maxWidth: 40 }),
|
|
2725
|
+
column('文件格式', 'formats', { minWidth: 10, maxWidth: 28 }),
|
|
2726
|
+
column('数量', 'count', { maxWidth: 10 }),
|
|
2727
|
+
column('其他限制', 'limits', { minWidth: 12, maxWidth: 30 }),
|
|
2728
|
+
]));
|
|
2729
|
+
}
|
|
2730
|
+
|
|
2731
|
+
function renderModelConstraints(lines, constraints = []) {
|
|
2732
|
+
const rows = Array.isArray(constraints) ? constraints : [];
|
|
2733
|
+
sectionTitle(lines, `联动约束(${rows.length})`);
|
|
2734
|
+
if (!rows.length) {
|
|
2735
|
+
lines.push(` ${mutedText('无联动约束')}`);
|
|
2736
|
+
return;
|
|
2737
|
+
}
|
|
2738
|
+
const tableRows = rows.map((item, index) => ({
|
|
2739
|
+
index: index + 1,
|
|
2740
|
+
target: localizedResourceTarget(item.target, item.limits) || localizedParamKey(item.target || item.targetConfigCode || '约束'),
|
|
2741
|
+
condition: localizedConditions(item.conditions),
|
|
2742
|
+
result: localizedConstraintResult(item),
|
|
2743
|
+
note: item.name,
|
|
2744
|
+
}));
|
|
2745
|
+
lines.push(...renderPrettyTable(tableRows, [
|
|
2746
|
+
column('#', 'index', { minWidth: 1, maxWidth: 2, always: true }),
|
|
2747
|
+
column('影响参数', 'target', { minWidth: 8, maxWidth: 14, always: true }),
|
|
2748
|
+
column('条件', 'condition', { minWidth: 16, maxWidth: 28 }),
|
|
2749
|
+
column('结果', 'result', { minWidth: 18, maxWidth: 42, always: true }),
|
|
2750
|
+
column('说明', 'note', { maxWidth: 24 }),
|
|
2751
|
+
]));
|
|
2752
|
+
}
|
|
2753
|
+
|
|
2754
|
+
function listLimitFor(commandName, context, rows) {
|
|
2755
|
+
if (context.listLimit === Number.POSITIVE_INFINITY) return rows.length;
|
|
2756
|
+
if (Number.isFinite(context.listLimit)) return Math.max(0, context.listLimit);
|
|
2757
|
+
if (commandName === 'schema') return Number.POSITIVE_INFINITY;
|
|
2758
|
+
return Number.POSITIVE_INFINITY;
|
|
2759
|
+
}
|
|
2760
|
+
|
|
2761
|
+
function collectListKeys(normalized, primaryKey) {
|
|
2762
|
+
const keys = [];
|
|
2763
|
+
if (primaryKey && Array.isArray(normalized?.[primaryKey])) keys.push(primaryKey);
|
|
2764
|
+
for (const [key, value] of Object.entries(normalized || {})) {
|
|
2765
|
+
if (keys.includes(key)) continue;
|
|
2766
|
+
if (['resultUrls', 'originUrls'].includes(key)) continue;
|
|
2767
|
+
if (Array.isArray(value)) keys.push(key);
|
|
2768
|
+
}
|
|
2769
|
+
return keys;
|
|
2770
|
+
}
|
|
2771
|
+
|
|
2772
|
+
function collectPrettyActions(commandName, normalized, context = {}) {
|
|
2773
|
+
const actions = [];
|
|
2774
|
+
const add = (label, value) => {
|
|
2775
|
+
if (value === undefined || value === null || value === '') return;
|
|
2776
|
+
actions.push({ label, value: rewriteCommandPrefix(value) });
|
|
2777
|
+
};
|
|
2778
|
+
if (normalized?.nextCommand) add('继续查询', normalized.nextCommand);
|
|
2779
|
+
if (normalized?.nextRefSubject) add('主体引用', normalized.nextRefSubject);
|
|
2780
|
+
if (normalized?.nextVoiceArg) add('音色参数', normalized.nextVoiceArg);
|
|
2781
|
+
if (normalized?.dryRun && context.confirmCommand) add('确认执行', context.confirmCommand);
|
|
2782
|
+
if (normalized?.dryRun && !context.confirmCommand && context.executeCommand) add('正式执行', context.executeCommand);
|
|
2783
|
+
const modelNext = modelListNextCommand(commandName);
|
|
2784
|
+
if (modelNext) add(commandName === 'model asset-review-models' ? '查询素材组' : '查看参数', modelNext);
|
|
2785
|
+
const waitNext = statusNextCommand(commandName, normalized);
|
|
2786
|
+
if (waitNext) add('继续等待', waitNext);
|
|
2787
|
+
const subtitleNext = subtitleRemoveNextCommand(commandName, normalized);
|
|
2788
|
+
if (subtitleNext) add('去字幕预览', subtitleNext);
|
|
2789
|
+
if (context.moreCommand) add('显示更多', context.moreCommand);
|
|
2790
|
+
return actions;
|
|
2791
|
+
}
|
|
2792
|
+
|
|
2793
|
+
function renderNextActions(lines, actions = [], hint = null) {
|
|
2794
|
+
if (!actions.length && !hint) return;
|
|
2795
|
+
sectionTitle(lines, '下一步');
|
|
2796
|
+
const labelWidth = actions.length ? Math.max(...actions.map((item) => displayWidth(item.label))) : 0;
|
|
2797
|
+
for (const item of actions) {
|
|
2798
|
+
lines.push(` ${labelText(padDisplay(item.label, labelWidth))} ${commandText(prettyValue(item.value))}`);
|
|
2799
|
+
}
|
|
2800
|
+
if (hint) lines.push(` ${labelText(padDisplay('提示', labelWidth || 2))} ${mutedText(hint)}`);
|
|
2801
|
+
}
|
|
2802
|
+
|
|
2803
|
+
function renderUrlLists(lines, normalized) {
|
|
2804
|
+
renderScalarList(lines, '结果链接', normalized?.resultUrls, 6);
|
|
2805
|
+
renderScalarList(lines, '原始素材', normalized?.originUrls, 6);
|
|
2806
|
+
}
|
|
2807
|
+
|
|
2808
|
+
function formatPrettySchema(data = {}, context = {}) {
|
|
2809
|
+
const lines = [prettyTitle('schema', 'command_schema', data), ''];
|
|
2810
|
+
const isBrief = data.kind === 'agent_brief';
|
|
2811
|
+
renderDetails(lines, '摘要', {
|
|
2812
|
+
schemaVersion: data.schemaVersion,
|
|
2813
|
+
kind: data.kind,
|
|
2814
|
+
cli: data.cli?.name,
|
|
2815
|
+
version: data.cli?.version,
|
|
2816
|
+
commandPrefix: data.cli?.commandPrefix,
|
|
2817
|
+
domainFilter: data.filters?.domain,
|
|
2818
|
+
commandFilter: data.filters?.command,
|
|
2819
|
+
commandCount: data.commandCount ?? (Array.isArray(data.commands) ? data.commands.length : undefined),
|
|
2820
|
+
}, ['schemaVersion', 'kind', 'cli', 'version', 'commandPrefix', 'domainFilter', 'commandFilter', 'commandCount']);
|
|
2821
|
+
renderArraySection(lines, '命令领域', data.domains, 'domains');
|
|
2822
|
+
if (!isBrief) renderArraySection(lines, '命令', data.commands, 'commands');
|
|
2823
|
+
renderNextActions(lines, [
|
|
2824
|
+
...(isBrief ? [
|
|
2825
|
+
{ label: '精确 Schema', value: `${commandPrefix()} schema --domain <domain> --command <command> -f json` },
|
|
2826
|
+
{ label: '完整 Schema', value: `${commandPrefix()} schema -f json` },
|
|
2827
|
+
] : [
|
|
2828
|
+
{ label: 'Agent Brief', value: `${commandPrefix()} schema --brief -f json` },
|
|
2829
|
+
{ label: 'Schema JSON', value: `${commandPrefix()} schema -f json` },
|
|
2830
|
+
]),
|
|
2831
|
+
...(context.jsonCommand ? [{ label: '当前筛选 JSON', value: context.jsonCommand }] : []),
|
|
2832
|
+
], isBrief ? '先读 brief 建立能力地图;执行具体命令前按需读取精确 schema。' : undefined);
|
|
2833
|
+
return `${lines.join('\n')}\n`;
|
|
2834
|
+
}
|
|
2835
|
+
|
|
2836
|
+
function formatPrettyEnvironment(data = {}, context = {}) {
|
|
2837
|
+
const lines = [prettyTitle('doctor', 'environment_report', data), ''];
|
|
2838
|
+
renderDetails(lines, '摘要', {
|
|
2839
|
+
doctorStatus: data.doctorStatus,
|
|
2840
|
+
verify: data.verify,
|
|
2841
|
+
nodeVersion: data.runtime?.nodeVersion,
|
|
2842
|
+
platform: data.runtime?.platform,
|
|
2843
|
+
arch: data.runtime?.arch,
|
|
2844
|
+
apiOrigin: data.origins?.apiOrigin,
|
|
2845
|
+
authState: data.auth?.loginState,
|
|
2846
|
+
authType: data.auth?.authType,
|
|
2847
|
+
accessKey: data.auth?.accessKey,
|
|
2848
|
+
currentProjectGroupNo: data.projectGroup?.projectGroupNo,
|
|
2849
|
+
currentProjectGroupName: data.projectGroup?.projectGroupName,
|
|
2850
|
+
}, ['doctorStatus', 'verify', 'nodeVersion', 'platform', 'arch', 'apiOrigin', 'authState', 'authType', 'accessKey', 'currentProjectGroupNo', 'currentProjectGroupName']);
|
|
2851
|
+
renderArraySection(lines, '检查结果', data.checks, 'checks');
|
|
2852
|
+
renderNextActions(lines, collectPrettyActions('doctor', data, context));
|
|
2853
|
+
return `${lines.join('\n')}\n`;
|
|
2854
|
+
}
|
|
2855
|
+
|
|
2856
|
+
function formatPrettyModelOptions(data = {}, context = {}) {
|
|
2857
|
+
const lines = [prettyTitle('model options', 'model_options', data), ''];
|
|
2858
|
+
renderDetails(lines, '摘要', {
|
|
2859
|
+
modelGroupCode: data.modelGroupCode,
|
|
2860
|
+
taskKind: localizedTaskKind(data.taskKind),
|
|
2861
|
+
displayName: data.model?.displayName,
|
|
2862
|
+
modelDesc: data.model?.modelDesc,
|
|
2863
|
+
}, ['modelGroupCode', 'displayName', 'taskKind', 'modelDesc']);
|
|
2864
|
+
renderModelParams(lines, data.params);
|
|
2865
|
+
renderModelResources(lines, data.resources, data.taskKind);
|
|
2866
|
+
renderModelConstraints(lines, data.constraints);
|
|
2867
|
+
renderNextActions(lines, [
|
|
2868
|
+
{ label: '生成创建写法', value: `${commandPrefix()} model create-spec --model-group-code ${data.modelGroupCode || '<modelGroupCode>'}` },
|
|
2869
|
+
...(context.textCommand ? [{ label: 'Agent 读取', value: context.textCommand }] : []),
|
|
2870
|
+
...(context.jsonCommand ? [{ label: '完整 JSON', value: context.jsonCommand }] : []),
|
|
2871
|
+
]);
|
|
2872
|
+
return `${lines.join('\n')}\n`;
|
|
2873
|
+
}
|
|
2874
|
+
|
|
2875
|
+
function formatPrettyModelCreateSpec(data = {}, context = {}) {
|
|
2876
|
+
const taskKind = data.taskKind;
|
|
2877
|
+
const lines = [prettyTitle('model create-spec', 'model_create_spec', data), ''];
|
|
2878
|
+
renderDetails(lines, '摘要', {
|
|
2879
|
+
modelGroupCode: data.modelGroupCode,
|
|
2880
|
+
taskKind: localizedTaskKind(data.taskKind),
|
|
2881
|
+
createCommand: data.createCommand,
|
|
2882
|
+
feeCommand: data.feeCommand,
|
|
2883
|
+
statusCommandTaskType: data.statusCommandTaskType,
|
|
2884
|
+
inputSummary: localizedCreateSpecSummary(data.inputRequirement?.summary),
|
|
2885
|
+
acceptedModes: localizedModeList(data.inputRequirement?.acceptedModes, taskKind),
|
|
2886
|
+
}, ['modelGroupCode', 'taskKind', 'createCommand', 'feeCommand', 'statusCommandTaskType', 'inputSummary', 'acceptedModes']);
|
|
2887
|
+
renderArraySection(lines, '支持意图', data.supportedIntents, [
|
|
2888
|
+
column('输入方式', (row) => localizedIntentMode(row.mode, taskKind), { minWidth: 12, maxWidth: 22 }),
|
|
2889
|
+
column('意图', (row) => localizedIntentText(row.intent, row.mode, taskKind), { minWidth: 10, maxWidth: 24 }),
|
|
2890
|
+
column('必需写法', (row) => commandArgLines(row.requiredArgs), { minWidth: 22, maxWidth: 62 }),
|
|
2891
|
+
column('素材用途', (row) => localizedList(row.resourceUsages, localizedUsage), { minWidth: 10, maxWidth: 24 }),
|
|
2892
|
+
column('Prompt 绑定', (row) => localizedPromptBinding(row.promptBinding), { maxWidth: 14 }),
|
|
2893
|
+
]);
|
|
2894
|
+
renderArraySection(lines, '可控参数', data.parameterControls?.userParams, [
|
|
2895
|
+
column('参数', (row) => localizedParamKey(row.key), { minWidth: 10, maxWidth: 20 }),
|
|
2896
|
+
column('写法', 'cliArg', { minWidth: 12, maxWidth: 34 }),
|
|
2897
|
+
column('可选值', (row) => Array.isArray(row.allowedValues) ? row.allowedValues.join('、') : '', { minWidth: 12, maxWidth: 36 }),
|
|
2898
|
+
]);
|
|
2899
|
+
renderScalarList(lines, '示例', (data.examples || []).map((example) => modelCreateExampleWithCode(example, data.modelGroupCode)).map((item) => item.replaceAll('--model-group-code <code>', `--model-group-code ${data.modelGroupCode || '<code>'}`)), 8);
|
|
2900
|
+
const actions = [];
|
|
2901
|
+
if (data.optionsCommand) actions.push({ label: '查看参数', value: `${commandPrefix()} ${data.optionsCommand}` });
|
|
2902
|
+
const feeNext = modelFeeNextCommand(data);
|
|
2903
|
+
if (feeNext) actions.push({ label: '费用预估', value: feeNext });
|
|
2904
|
+
if (data.examples?.[0]) actions.push({ label: 'Dry-run', value: modelCreateExampleWithCode(data.examples[0], data.modelGroupCode) });
|
|
2905
|
+
if (context.textCommand) actions.push({ label: 'Agent 读取', value: context.textCommand });
|
|
2906
|
+
if (context.jsonCommand) actions.push({ label: '完整 JSON', value: context.jsonCommand });
|
|
2907
|
+
renderNextActions(lines, actions);
|
|
2908
|
+
return `${lines.join('\n')}\n`;
|
|
2909
|
+
}
|
|
2910
|
+
|
|
2911
|
+
function formatPrettyModelInputGuide(data = {}, context = {}) {
|
|
2912
|
+
const lines = [prettyTitle('model input-guide', 'model_input_guide', data), ''];
|
|
2913
|
+
renderDetails(lines, '摘要', {
|
|
2914
|
+
schemaVersion: data.schemaVersion,
|
|
2915
|
+
commonFieldCount: Array.isArray(data.commonFields) ? data.commonFields.length : undefined,
|
|
2916
|
+
resourceFieldCount: Array.isArray(data.resourceFields) ? data.resourceFields.length : undefined,
|
|
2917
|
+
resourceRuleCount: Array.isArray(data.resourceRules) ? data.resourceRules.length : undefined,
|
|
2918
|
+
}, ['schemaVersion', 'commonFieldCount', 'resourceFieldCount', 'resourceRuleCount']);
|
|
2919
|
+
const guideColumns = [
|
|
2920
|
+
column('字段', 'field', { maxWidth: 32 }),
|
|
2921
|
+
column('可选值', localizedGuideValues, { maxWidth: 46 }),
|
|
2922
|
+
column('说明', 'description', { maxWidth: 70 }),
|
|
2923
|
+
];
|
|
2924
|
+
renderArraySection(lines, '通用字段', data.commonFields, guideColumns);
|
|
2925
|
+
renderArraySection(lines, '资源字段', data.resourceFields, guideColumns);
|
|
2926
|
+
renderScalarList(lines, '资源规则', data.resourceRules, 12);
|
|
2927
|
+
renderScalarList(lines, 'Reference Key 指南', data.referenceKeyGuide, 12);
|
|
2928
|
+
renderNextActions(lines, [
|
|
2929
|
+
{ label: '生图模型', value: `${commandPrefix()} model image-models --model <keyword>` },
|
|
2930
|
+
{ label: '生视频模型', value: `${commandPrefix()} model video-models --model <keyword>` },
|
|
2931
|
+
{ label: '模型参数', value: `${commandPrefix()} model options --model-group-code <modelGroupCode>` },
|
|
2932
|
+
...(context.textCommand ? [{ label: 'Agent 读取', value: context.textCommand }] : []),
|
|
2933
|
+
...(context.jsonCommand ? [{ label: '完整 JSON', value: context.jsonCommand }] : []),
|
|
2934
|
+
]);
|
|
2935
|
+
return `${lines.join('\n')}\n`;
|
|
2936
|
+
}
|
|
2937
|
+
|
|
2938
|
+
function formatPrettyGeneric(commandName, data, context = {}) {
|
|
2939
|
+
const normalized = normalizeOutputData(commandName, data);
|
|
2940
|
+
const kind = outputKindForCommand(commandName, context);
|
|
2941
|
+
if (!isPlainObject(normalized)) {
|
|
2942
|
+
const lines = [prettyTitle(commandName, kind, data), ''];
|
|
2943
|
+
renderDetails(lines, '结果', { value: normalized }, ['value']);
|
|
2944
|
+
return `${lines.join('\n')}\n`;
|
|
2945
|
+
}
|
|
2946
|
+
const profile = PRETTY_KIND_PROFILES[kind] || PRETTY_KIND_PROFILES.generic;
|
|
2947
|
+
const lines = [prettyTitle(commandName, kind, normalized), ''];
|
|
2948
|
+
const listKeys = collectListKeys(normalized, profile.listKey);
|
|
2949
|
+
const excluded = new Set(['raw', ...listKeys, 'resultUrls', 'originUrls', 'waited']);
|
|
2950
|
+
const summaryFields = normalized.dryRun
|
|
2951
|
+
? (DRY_RUN_FIELDS_BY_COMMAND[commandName] || ['dryRun', 'action', ...(profile.fields || [])])
|
|
2952
|
+
: (profile.fields || []);
|
|
2953
|
+
renderDetails(lines, normalized.dryRun ? '预览摘要' : '摘要', normalized, summaryFields, [...excluded]);
|
|
2954
|
+
if (normalized.waited) {
|
|
2955
|
+
renderDetails(lines, '等待结果', normalized.waited, DETAIL_FIELDS_BY_KIND.task_status || []);
|
|
2956
|
+
}
|
|
2957
|
+
for (const key of listKeys) {
|
|
2958
|
+
const rows = normalized[key];
|
|
2959
|
+
if (!Array.isArray(rows)) continue;
|
|
2960
|
+
const limit = listLimitFor(commandName, context, rows);
|
|
2961
|
+
renderArraySection(lines, namedListTitle(key), rows, key, limit);
|
|
2962
|
+
}
|
|
2963
|
+
renderUrlLists(lines, normalized);
|
|
2964
|
+
renderNextActions(lines, collectPrettyActions(commandName, normalized, context), modelListAgentHint(commandName));
|
|
2965
|
+
return `${lines.join('\n')}\n`;
|
|
2966
|
+
}
|
|
2967
|
+
|
|
2968
|
+
export function formatPrettyOutput(commandName, data, context = {}) {
|
|
2969
|
+
if (commandName === 'schema') return formatPrettySchema(data, context);
|
|
2970
|
+
if (commandName === 'doctor') return formatPrettyEnvironment(data, context);
|
|
2971
|
+
if (commandName === 'model image-models' || commandName === 'model video-models') return formatPrettyModelList(commandName, data, context);
|
|
2972
|
+
if (commandName === 'model options') return formatPrettyModelOptions(data, context);
|
|
2973
|
+
if (commandName === 'model create-spec') return formatPrettyModelCreateSpec(data, context);
|
|
2974
|
+
if (commandName === 'model input-guide') return formatPrettyModelInputGuide(data, context);
|
|
2975
|
+
return formatPrettyGeneric(commandName, data, context);
|
|
2976
|
+
}
|
|
2977
|
+
|
|
2978
|
+
function yamlScalar(value) {
|
|
2979
|
+
if (value === null) return 'null';
|
|
2980
|
+
if (typeof value === 'number' || typeof value === 'boolean') return String(value);
|
|
2981
|
+
const text = String(value ?? '');
|
|
2982
|
+
return JSON.stringify(text);
|
|
2983
|
+
}
|
|
2984
|
+
|
|
2985
|
+
function formatYamlValue(value, indent = 0) {
|
|
2986
|
+
const pad = ' '.repeat(indent);
|
|
2987
|
+
if (Array.isArray(value)) {
|
|
2988
|
+
if (!value.length) return '[]';
|
|
2989
|
+
return value.map((item) => {
|
|
2990
|
+
if (isPlainObject(item) || Array.isArray(item)) {
|
|
2991
|
+
const rendered = formatYamlValue(item, indent + 2);
|
|
2992
|
+
return `${pad}- ${rendered.includes('\n') ? `\n${rendered}` : rendered}`;
|
|
2993
|
+
}
|
|
2994
|
+
return `${pad}- ${yamlScalar(item)}`;
|
|
2995
|
+
}).join('\n');
|
|
2996
|
+
}
|
|
2997
|
+
if (isPlainObject(value)) {
|
|
2998
|
+
const entries = Object.entries(value).filter(([, item]) => item !== undefined);
|
|
2999
|
+
if (!entries.length) return '{}';
|
|
3000
|
+
return entries.map(([key, item]) => {
|
|
3001
|
+
if (isPlainObject(item) || Array.isArray(item)) {
|
|
3002
|
+
return `${pad}${key}:\n${formatYamlValue(item, indent + 2)}`;
|
|
3003
|
+
}
|
|
3004
|
+
return `${pad}${key}: ${yamlScalar(item)}`;
|
|
3005
|
+
}).join('\n');
|
|
3006
|
+
}
|
|
3007
|
+
return yamlScalar(value);
|
|
3008
|
+
}
|
|
3009
|
+
|
|
3010
|
+
export function formatYamlEnvelope(payload) {
|
|
3011
|
+
return `${formatYamlValue(rewriteNested(payload), 0)}\n`;
|
|
3012
|
+
}
|
|
3013
|
+
|
|
3014
|
+
function csvEscape(value) {
|
|
3015
|
+
const text = String(prettyValue(value));
|
|
3016
|
+
return /[",\n\r]/.test(text) ? `"${text.replaceAll('"', '""')}"` : text;
|
|
3017
|
+
}
|
|
3018
|
+
|
|
3019
|
+
function csvColumnsForRows(rows = []) {
|
|
3020
|
+
const cols = inferTableColumns(rows);
|
|
3021
|
+
return cols.map((col) => ({
|
|
3022
|
+
header: col.header,
|
|
3023
|
+
key: col.key,
|
|
3024
|
+
value: col.value,
|
|
3025
|
+
}));
|
|
3026
|
+
}
|
|
3027
|
+
|
|
3028
|
+
export function formatCsvOutput(commandName, data, context = {}) {
|
|
3029
|
+
const normalized = normalizeJsonData(commandName, data);
|
|
3030
|
+
const kind = outputKindForCommand(commandName, context);
|
|
3031
|
+
const primaryKey = LIST_KEY_BY_KIND[kind];
|
|
3032
|
+
const list = primaryKey && Array.isArray(normalized?.[primaryKey])
|
|
3033
|
+
? { key: primaryKey, rows: normalized[primaryKey] }
|
|
3034
|
+
: firstList(normalized);
|
|
3035
|
+
const rows = list?.rows?.length ? list.rows : (isPlainObject(normalized) ? [normalized] : [{ value: normalized }]);
|
|
3036
|
+
const columns = TABLE_COLUMNS[list?.key] || csvColumnsForRows(rows);
|
|
3037
|
+
const headers = columns.map((col) => col.header);
|
|
3038
|
+
const lines = [headers.map(csvEscape).join(',')];
|
|
3039
|
+
for (const row of rows) {
|
|
3040
|
+
lines.push(columns.map((col) => csvEscape(resolveColumnValue(row, col))).join(','));
|
|
3041
|
+
}
|
|
3042
|
+
return `${lines.join('\n')}\n`;
|
|
3043
|
+
}
|
|
3044
|
+
|
|
3045
|
+
export function formatPrettyError(error) {
|
|
3046
|
+
const lines = [errorTitleText('命令失败'), ''];
|
|
3047
|
+
renderDetails(lines, '错误', {
|
|
3048
|
+
type: error.type || 'error',
|
|
3049
|
+
message: error.message || String(error),
|
|
3050
|
+
hint: error.hint ? rewriteCommandPrefix(error.hint) : undefined,
|
|
3051
|
+
}, ['type', 'message', 'hint']);
|
|
3052
|
+
if (isPlainObject(error.details)) {
|
|
3053
|
+
const payload = isPlainObject(error.details.payload) ? error.details.payload : {};
|
|
3054
|
+
renderDetails(lines, '详情', compactRecord({
|
|
3055
|
+
status: error.details.status ?? payload.status,
|
|
3056
|
+
code: error.details.code ?? payload.code,
|
|
3057
|
+
msg: error.details.msg ?? payload.msg ?? payload.message,
|
|
3058
|
+
traceId: error.details.traceId ?? payload.traceId,
|
|
3059
|
+
causeCode: error.details.causeCode,
|
|
3060
|
+
unknownOptions: Array.isArray(error.details.unknownOptions) ? error.details.unknownOptions.join(', ') : undefined,
|
|
3061
|
+
}), ['status', 'code', 'msg', 'traceId', 'causeCode', 'unknownOptions']);
|
|
3062
|
+
}
|
|
3063
|
+
return `${lines.join('\n')}\n`;
|
|
833
3064
|
}
|
|
834
3065
|
|
|
835
3066
|
export function formatTextOutput(commandName, data, context = {}) {
|
|
@@ -855,27 +3086,39 @@ export function formatTextOutput(commandName, data, context = {}) {
|
|
|
855
3086
|
'taskId',
|
|
856
3087
|
'publicId',
|
|
857
3088
|
'remoteTaskId',
|
|
3089
|
+
'pointNo',
|
|
858
3090
|
'taskType',
|
|
859
3091
|
'taskStatus',
|
|
3092
|
+
'modelCode',
|
|
860
3093
|
'modelGroupCode',
|
|
3094
|
+
'platform',
|
|
861
3095
|
'projectGroupNo',
|
|
862
3096
|
'projectId',
|
|
863
3097
|
'groupId',
|
|
864
3098
|
'groupName',
|
|
865
3099
|
'assetId',
|
|
866
3100
|
'elementId',
|
|
3101
|
+
'voiceRecordId',
|
|
3102
|
+
'voiceId',
|
|
867
3103
|
'externalId',
|
|
868
3104
|
'status',
|
|
869
3105
|
'imported',
|
|
3106
|
+
'updated',
|
|
3107
|
+
'deleted',
|
|
870
3108
|
'sourceFile',
|
|
871
3109
|
'inputDir',
|
|
3110
|
+
'inputFile',
|
|
872
3111
|
'count',
|
|
873
3112
|
'rowCount',
|
|
874
3113
|
'actorCount',
|
|
875
3114
|
'propCount',
|
|
876
3115
|
'locationCount',
|
|
3116
|
+
'episodeCount',
|
|
877
3117
|
'sceneCount',
|
|
878
3118
|
'clipCount',
|
|
3119
|
+
'batchCount',
|
|
3120
|
+
'id',
|
|
3121
|
+
'videoEpisodeId',
|
|
879
3122
|
'episodeId',
|
|
880
3123
|
'rowKind',
|
|
881
3124
|
'entityKey',
|
|
@@ -888,6 +3131,9 @@ export function formatTextOutput(commandName, data, context = {}) {
|
|
|
888
3131
|
'stateKey',
|
|
889
3132
|
'sceneId',
|
|
890
3133
|
'clipId',
|
|
3134
|
+
'name',
|
|
3135
|
+
'displayName',
|
|
3136
|
+
'title',
|
|
891
3137
|
'resultCount',
|
|
892
3138
|
'resourceConversionCount',
|
|
893
3139
|
'resourceConversion',
|
|
@@ -933,6 +3179,8 @@ export function formatTextOutput(commandName, data, context = {}) {
|
|
|
933
3179
|
if (normalized.dryRun && !context.confirmCommand && context.executeCommand) lines.push(`next=${context.executeCommand}`);
|
|
934
3180
|
const modelNext = modelListNextCommand(commandName);
|
|
935
3181
|
if (modelNext) lines.push(`next=${modelNext}`);
|
|
3182
|
+
const modelHint = modelListAgentHint(commandName);
|
|
3183
|
+
if (modelHint) lines.push(`agentHint=${shortValue(modelHint)}`);
|
|
936
3184
|
const waitNext = statusNextCommand(commandName, normalized);
|
|
937
3185
|
if (waitNext) lines.push(`next=${waitNext}`);
|
|
938
3186
|
const subtitleNext = subtitleRemoveNextCommand(commandName, normalized);
|