@lingjingai/lj-awb-cli 0.4.8 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -2
- package/build/volta-pre.mjs +64 -0
- package/package.json +3 -3
- package/packages/awb-cli/package.json +2 -2
- package/packages/awb-core/package.json +1 -1
- package/packages/awb-core/src/api.js +10 -9
- package/packages/awb-core/src/commands.js +53 -46
- package/packages/awb-core/src/common.js +3 -5
- package/packages/awb-core/src/output.js +88 -20
- package/packages/awb-core/src/services.js +226 -59
- package/packages/awb-core/src/standalone.js +21 -25
- package/packages/awb-core/src/update.js +74 -3
- package/skills/lj-awb/SKILL.md +13 -4
- package/skills/lj-awb/VERSION +1 -1
- package/skills/lj-awb/compat.json +2 -2
- package/skills/lj-awb/modules/asset.md +1 -1
- package/skills/lj-awb/modules/create-contract.md +10 -8
- package/skills/lj-awb/modules/create.md +1 -1
- package/skills/lj-awb/modules/credits.md +18 -1
- package/skills/lj-awb/modules/driver.md +3 -0
- package/skills/lj-awb/modules/evals.md +2 -2
- package/skills/lj-awb/modules/image.md +6 -6
- package/skills/lj-awb/modules/model.md +50 -1
- package/skills/lj-awb/modules/task-manual.md +3 -3
- package/skills/lj-awb/modules/task.md +6 -5
- package/skills/lj-awb/modules/upload.md +10 -10
- package/skills/lj-awb/modules/video.md +11 -13
- package/skills/lj-awb/modules/workflows.md +2 -2
- package/skills/lj-awb/references/error-codes.md +1 -1
- package/skills/lj-awb/references/output-fields.md +8 -5
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
DEFAULT_API_ORIGIN,
|
|
13
13
|
STATE_PATH,
|
|
14
14
|
TASK_UPLOAD_SCENE,
|
|
15
|
+
CLI_TEMP_UPLOAD_SCENE,
|
|
15
16
|
LingjingAwbCliError,
|
|
16
17
|
buildCosAuthorization,
|
|
17
18
|
encodeObjectNamePath,
|
|
@@ -34,7 +35,6 @@ import {
|
|
|
34
35
|
sleep,
|
|
35
36
|
splitCsv,
|
|
36
37
|
taskStatusText,
|
|
37
|
-
taskTypeToStatusKind,
|
|
38
38
|
toBool,
|
|
39
39
|
toInt,
|
|
40
40
|
toNumberOrNull,
|
|
@@ -107,6 +107,7 @@ const PLATFORM_BACKEND_PATH_PREFIXES = [
|
|
|
107
107
|
'material-video-create/',
|
|
108
108
|
'default/workbench/',
|
|
109
109
|
'asset-review/',
|
|
110
|
+
'tmp/cli-upload/',
|
|
110
111
|
];
|
|
111
112
|
const CREATE_STANDARD_KWARG_KEYS = new Set([
|
|
112
113
|
'modelGroupCode',
|
|
@@ -915,6 +916,89 @@ export async function creditsBalance(kwargs = {}) {
|
|
|
915
916
|
};
|
|
916
917
|
}
|
|
917
918
|
|
|
919
|
+
const CREDIT_RECORD_QUERY_TYPES = new Set([1, 2, 3]);
|
|
920
|
+
|
|
921
|
+
export function resolveCreditsRecordQueryType(kwargs = {}) {
|
|
922
|
+
const raw = kwargs.queryType ?? kwargs.type ?? 1;
|
|
923
|
+
const queryType = toInt(raw, Number.NaN);
|
|
924
|
+
if (!CREDIT_RECORD_QUERY_TYPES.has(queryType)) {
|
|
925
|
+
throw argumentError('query-type 只支持 1、2、3', '1=全部明细,2=支出明细,3=收入明细。');
|
|
926
|
+
}
|
|
927
|
+
return queryType;
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
function normalizeCreditRecord(row = {}) {
|
|
931
|
+
const operation = String(row.operation || '').toLowerCase();
|
|
932
|
+
const sign = operation === 'expend' ? '-' : (operation === 'recharge' ? '+' : '');
|
|
933
|
+
const point = row.point === undefined || row.point === null || row.point === ''
|
|
934
|
+
? row.point
|
|
935
|
+
: `${sign}${row.point}`;
|
|
936
|
+
return compactRecord({
|
|
937
|
+
operationTime: row.operationTime,
|
|
938
|
+
title: row.title,
|
|
939
|
+
point,
|
|
940
|
+
projectGroupName: row.projectGroupName,
|
|
941
|
+
projectGroupNo: row.projectGroupNo,
|
|
942
|
+
userName: row.userName,
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
export function normalizeCreditsRecordsPayload(payload = {}, options = {}) {
|
|
947
|
+
const records = normalizeRows(payload.animeBenefitsDetailList ?? payload.records ?? payload.list)
|
|
948
|
+
.map((row) => normalizeCreditRecord(row));
|
|
949
|
+
return compactRecord({
|
|
950
|
+
remainPoint: payload.remainPoint,
|
|
951
|
+
dataPlanPoint: payload.dataPlanPoint,
|
|
952
|
+
topUpPoint: payload.topUpPoint,
|
|
953
|
+
queryType: options.queryType,
|
|
954
|
+
total: payload.total,
|
|
955
|
+
page: payload.current ?? payload.page,
|
|
956
|
+
size: payload.size,
|
|
957
|
+
pages: payload.pages,
|
|
958
|
+
creditRecords: records,
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
export async function creditsRecords(kwargs = {}) {
|
|
963
|
+
const queryType = resolveCreditsRecordQueryType(kwargs);
|
|
964
|
+
const page = Math.max(toInt(kwargs.page, 1), 1);
|
|
965
|
+
const size = Math.min(Math.max(toInt(kwargs.size ?? kwargs.pageSize, 10), 1), 100);
|
|
966
|
+
const payload = await awbApi.fetchPointRecords({ queryType, page, size });
|
|
967
|
+
return normalizeCreditsRecordsPayload(payload, { queryType });
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
const CREDIT_DETAIL_STATUS_TEXT = Object.freeze({
|
|
971
|
+
lock: '锁定',
|
|
972
|
+
locked: '锁定',
|
|
973
|
+
use: '核销',
|
|
974
|
+
used: '核销',
|
|
975
|
+
reget: '返还',
|
|
976
|
+
return: '返还',
|
|
977
|
+
returned: '返还',
|
|
978
|
+
});
|
|
979
|
+
|
|
980
|
+
export function normalizeCreditDetailStatusPayload(payload = {}) {
|
|
981
|
+
const status = trimToNull(payload.status);
|
|
982
|
+
return compactRecord({
|
|
983
|
+
detailId: payload.detailId,
|
|
984
|
+
status,
|
|
985
|
+
statusText: status ? (CREDIT_DETAIL_STATUS_TEXT[status.toLowerCase()] ?? status) : undefined,
|
|
986
|
+
lockTime: payload.lockTime,
|
|
987
|
+
lockPoint: payload.lockPoint,
|
|
988
|
+
useTime: payload.useTime,
|
|
989
|
+
usePoint: payload.usePoint,
|
|
990
|
+
regetTime: payload.regetTime,
|
|
991
|
+
regetPoint: payload.regetPoint,
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
export async function creditsDetailStatus(kwargs = {}) {
|
|
996
|
+
const detailId = trimToNull(kwargs.detailId ?? kwargs.detail_id);
|
|
997
|
+
if (!detailId) throw argumentError('缺少 detail-id', '传 --detail-id <detailId> 查询单个积分明细的锁定 / 核销 / 返还状态。');
|
|
998
|
+
const payload = await awbApi.fetchPointDetailStatus({ detailId });
|
|
999
|
+
return normalizeCreditDetailStatusPayload(payload);
|
|
1000
|
+
}
|
|
1001
|
+
|
|
918
1002
|
function parseTimeMs(value, fallback = null) {
|
|
919
1003
|
if (value === undefined || value === null || value === '') return fallback;
|
|
920
1004
|
const numeric = Number(value);
|
|
@@ -997,7 +1081,6 @@ function modelListMetadata(kind, paramKeys = [], rulesByKey = new Map()) {
|
|
|
997
1081
|
const controls = [];
|
|
998
1082
|
if (keys.has('ratio')) controls.push('ratio');
|
|
999
1083
|
if (keys.has('quality')) controls.push('quality');
|
|
1000
|
-
if (kind === 'image' && keys.has('generate_num')) controls.push('generateNum');
|
|
1001
1084
|
if (kind === 'video' && keys.has('generated_time')) controls.push('duration');
|
|
1002
1085
|
if (kind === 'video' && (keys.has('need_audio') || keys.has('audio'))) controls.push('needAudio');
|
|
1003
1086
|
return {
|
|
@@ -1032,6 +1115,14 @@ function modelSuccessRate(item = {}) {
|
|
|
1032
1115
|
);
|
|
1033
1116
|
}
|
|
1034
1117
|
|
|
1118
|
+
function modelParamEnumValues(rawOptions, paramKey) {
|
|
1119
|
+
const option = (Array.isArray(rawOptions) ? rawOptions : []).find((item) => item?.paramKey === paramKey);
|
|
1120
|
+
const list = Array.isArray(option?.optionList) ? option.optionList : [];
|
|
1121
|
+
return uniqueNonEmpty(list
|
|
1122
|
+
.filter((entry) => entry?.available !== false)
|
|
1123
|
+
.map((entry) => entry?.enumValue ?? entry?.value ?? entry?.enumName));
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1035
1126
|
function normalizeModelRows(payload, kind, options = {}) {
|
|
1036
1127
|
const includeRaw = Boolean(options.includeRaw);
|
|
1037
1128
|
const includeInternal = Boolean(options.includeInternal);
|
|
@@ -1058,6 +1149,10 @@ function normalizeModelRows(payload, kind, options = {}) {
|
|
|
1058
1149
|
feeCalcType: item?.feeCalcType ?? item?.feeType ?? null,
|
|
1059
1150
|
inputModes: metadata.inputModes,
|
|
1060
1151
|
params: metadata.controls,
|
|
1152
|
+
ratios: modelParamEnumValues(rawOptions, 'ratio'),
|
|
1153
|
+
qualities: modelParamEnumValues(rawOptions, 'quality'),
|
|
1154
|
+
durations: modelParamEnumValues(rawOptions, 'generated_time'),
|
|
1155
|
+
needAudio: metadata.controls.includes('needAudio'),
|
|
1061
1156
|
_searchText: JSON.stringify([
|
|
1062
1157
|
modelCode,
|
|
1063
1158
|
modelGroupCode,
|
|
@@ -1074,18 +1169,114 @@ function normalizeModelRows(payload, kind, options = {}) {
|
|
|
1074
1169
|
});
|
|
1075
1170
|
}
|
|
1076
1171
|
|
|
1172
|
+
const MODEL_USAGE_FAMILY = {
|
|
1173
|
+
image: { default: 'IMAGE_CREATE', allow: new Set(['IMAGE_CREATE', 'IMAGE_EDIT']) },
|
|
1174
|
+
video: { default: 'VIDEO_CREATE', allow: new Set(['VIDEO_CREATE']) },
|
|
1175
|
+
};
|
|
1176
|
+
|
|
1177
|
+
export function resolveModelUsage(kind, kwargs = {}) {
|
|
1178
|
+
const family = MODEL_USAGE_FAMILY[kind] ?? MODEL_USAGE_FAMILY.image;
|
|
1179
|
+
const explicit = trimToNull(kwargs.usage);
|
|
1180
|
+
if (!explicit) return family.default;
|
|
1181
|
+
const usage = explicit.toUpperCase();
|
|
1182
|
+
if (!family.allow.has(usage)) {
|
|
1183
|
+
throw argumentError(
|
|
1184
|
+
`不支持的 usage:${explicit}`,
|
|
1185
|
+
`${kind} 模型可选 usage:${[...family.allow].join(' / ')}。`,
|
|
1186
|
+
);
|
|
1187
|
+
}
|
|
1188
|
+
return usage;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
export function buildModelFilters(kwargs = {}) {
|
|
1192
|
+
const keyword = trimToNull(kwargs.model ?? kwargs.keyword)?.toLowerCase() ?? null;
|
|
1193
|
+
const provider = trimToNull(kwargs.provider)?.toLowerCase() ?? null;
|
|
1194
|
+
const inputMode = trimToNull(kwargs.inputMode) ?? null;
|
|
1195
|
+
const supports = trimToNull(kwargs.supports) ?? null;
|
|
1196
|
+
const quality = trimToNull(kwargs.quality) ?? null;
|
|
1197
|
+
const ratio = trimToNull(kwargs.ratio) ?? null;
|
|
1198
|
+
const duration = trimToNull(kwargs.duration) ?? null;
|
|
1199
|
+
const needAudio = toBool(kwargs.needAudio) ? true : null;
|
|
1200
|
+
const applied = [];
|
|
1201
|
+
if (keyword) applied.push('keyword');
|
|
1202
|
+
if (provider) applied.push('provider');
|
|
1203
|
+
if (inputMode) applied.push('inputMode');
|
|
1204
|
+
if (supports) applied.push('supports');
|
|
1205
|
+
if (quality) applied.push('quality');
|
|
1206
|
+
if (ratio) applied.push('ratio');
|
|
1207
|
+
if (duration) applied.push('duration');
|
|
1208
|
+
if (needAudio) applied.push('needAudio');
|
|
1209
|
+
return { keyword, provider, inputMode, supports, quality, ratio, duration, needAudio, applied };
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
function includesCI(haystack, needle) {
|
|
1213
|
+
return String(haystack ?? '').toLowerCase().includes(needle);
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
function memberCI(list, value) {
|
|
1217
|
+
const target = String(value).toLowerCase();
|
|
1218
|
+
return (Array.isArray(list) ? list : []).some((item) => String(item).toLowerCase() === target);
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
export function applyModelFilters(rows, filters = {}) {
|
|
1222
|
+
return (Array.isArray(rows) ? rows : []).filter((row) => {
|
|
1223
|
+
if (filters.keyword && !includesCI(row._searchText, filters.keyword)) return false;
|
|
1224
|
+
if (filters.provider && !includesCI(row.provider, filters.provider)) return false;
|
|
1225
|
+
if (filters.inputMode && !memberCI(row.inputModes, filters.inputMode)) return false;
|
|
1226
|
+
if (filters.supports && !memberCI(row.params, filters.supports)) return false;
|
|
1227
|
+
if (filters.quality && !memberCI(row.qualities, filters.quality)) return false;
|
|
1228
|
+
if (filters.ratio && !memberCI(row.ratios, filters.ratio)) return false;
|
|
1229
|
+
if (filters.duration && !memberCI(row.durations, filters.duration)) return false;
|
|
1230
|
+
if (filters.needAudio && row.needAudio !== true) return false;
|
|
1231
|
+
return true;
|
|
1232
|
+
});
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
export function availableFilterValues(rows) {
|
|
1236
|
+
const list = Array.isArray(rows) ? rows : [];
|
|
1237
|
+
const providers = new Set();
|
|
1238
|
+
const inputModes = new Set();
|
|
1239
|
+
const supports = new Set();
|
|
1240
|
+
const qualities = new Set();
|
|
1241
|
+
const ratios = new Set();
|
|
1242
|
+
const durations = new Set();
|
|
1243
|
+
for (const row of list) {
|
|
1244
|
+
if (row.provider) providers.add(row.provider);
|
|
1245
|
+
for (const mode of row.inputModes || []) inputModes.add(mode);
|
|
1246
|
+
for (const param of row.params || []) supports.add(param);
|
|
1247
|
+
for (const q of row.qualities || []) qualities.add(q);
|
|
1248
|
+
for (const r of row.ratios || []) ratios.add(r);
|
|
1249
|
+
for (const d of row.durations || []) durations.add(d);
|
|
1250
|
+
}
|
|
1251
|
+
return {
|
|
1252
|
+
providers: [...providers],
|
|
1253
|
+
inputModes: [...inputModes],
|
|
1254
|
+
supports: [...supports],
|
|
1255
|
+
qualities: [...qualities],
|
|
1256
|
+
ratios: [...ratios],
|
|
1257
|
+
durations: [...durations],
|
|
1258
|
+
};
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1077
1261
|
export async function listModels(kind, kwargs = {}) {
|
|
1078
|
-
const usage = kind
|
|
1262
|
+
const usage = resolveModelUsage(kind, kwargs);
|
|
1079
1263
|
const payload = await awbApi.fetchModelsByUsage(usage, {});
|
|
1080
|
-
const keyword = trimToNull(kwargs.model ?? kwargs.keyword)?.toLowerCase();
|
|
1081
1264
|
const includeRaw = toBool(kwargs.includeRaw);
|
|
1082
|
-
const
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1265
|
+
const allRows = normalizeModelRows(payload, kind, { includeRaw });
|
|
1266
|
+
const filters = buildModelFilters(kwargs);
|
|
1267
|
+
const matched = applyModelFilters(allRows, filters);
|
|
1268
|
+
const models = matched.map(({ _searchText, _modelCode, ...item }) => item);
|
|
1269
|
+
const result = {
|
|
1270
|
+
usage,
|
|
1271
|
+
models,
|
|
1272
|
+
matchedCount: models.length,
|
|
1273
|
+
totalCount: allRows.length,
|
|
1274
|
+
filtersApplied: filters.applied,
|
|
1275
|
+
};
|
|
1276
|
+
if (models.length === 0 && allRows.length > 0) {
|
|
1277
|
+
result.availableValues = availableFilterValues(allRows);
|
|
1278
|
+
}
|
|
1279
|
+
return result;
|
|
1089
1280
|
}
|
|
1090
1281
|
|
|
1091
1282
|
function requireAssetPlatform(value, options = {}) {
|
|
@@ -2830,7 +3021,7 @@ function defaultUploadSceneForFile(filePath, mimeType = '') {
|
|
|
2830
3021
|
return TASK_UPLOAD_SCENE.DEFAULT;
|
|
2831
3022
|
}
|
|
2832
3023
|
|
|
2833
|
-
async function collectFileSpecs(kwargs = {}
|
|
3024
|
+
async function collectFileSpecs(kwargs = {}) {
|
|
2834
3025
|
const specs = [];
|
|
2835
3026
|
for (const file of parseListArg(kwargs.file)) specs.push({ file });
|
|
2836
3027
|
for (const file of parseListArg(kwargs.files)) specs.push({ file });
|
|
@@ -2847,7 +3038,9 @@ async function collectFileSpecs(kwargs = {}, defaultSceneType = null) {
|
|
|
2847
3038
|
const file = trimToNull(item.file ?? item.path ?? item.filePath);
|
|
2848
3039
|
return {
|
|
2849
3040
|
file,
|
|
2850
|
-
|
|
3041
|
+
// upload files 是用户手动上传,统一走临时隔离场景(cli-upload-temp,独立、可定期清理);
|
|
3042
|
+
// 不受 --scene-type 影响。create 系列的自动上传不经过这里,仍走各自业务场景。
|
|
3043
|
+
sceneType: CLI_TEMP_UPLOAD_SCENE,
|
|
2851
3044
|
projectNo: trimToNull(item.projectNo ?? kwargs.projectNo) ?? '',
|
|
2852
3045
|
};
|
|
2853
3046
|
})
|
|
@@ -3621,7 +3814,7 @@ function validateAssetRemoteSource(assetPath) {
|
|
|
3621
3814
|
}
|
|
3622
3815
|
|
|
3623
3816
|
export async function uploadFilesCommand(kwargs = {}) {
|
|
3624
|
-
const specs = await collectFileSpecs(kwargs
|
|
3817
|
+
const specs = await collectFileSpecs(kwargs);
|
|
3625
3818
|
if (!specs.length) throw argumentError('缺少上传文件', '传 --file <path> 或 --files a.png,b.mp4。');
|
|
3626
3819
|
if (toBool(kwargs.dryRun)) {
|
|
3627
3820
|
const files = [];
|
|
@@ -4658,7 +4851,7 @@ export async function imageCreate(kwargs = {}) {
|
|
|
4658
4851
|
return {
|
|
4659
4852
|
...result,
|
|
4660
4853
|
nextCommand: result.taskId
|
|
4661
|
-
? `lj-awb task wait --task-id ${result.taskId}
|
|
4854
|
+
? `lj-awb task wait --task-id ${result.taskId} -f json`
|
|
4662
4855
|
: null,
|
|
4663
4856
|
};
|
|
4664
4857
|
}
|
|
@@ -4777,7 +4970,7 @@ export async function videoCreate(kwargs = {}) {
|
|
|
4777
4970
|
return {
|
|
4778
4971
|
...result,
|
|
4779
4972
|
nextCommand: result.taskId
|
|
4780
|
-
? `lj-awb task wait --task-id ${result.taskId}
|
|
4973
|
+
? `lj-awb task wait --task-id ${result.taskId} -f json`
|
|
4781
4974
|
: null,
|
|
4782
4975
|
};
|
|
4783
4976
|
}
|
|
@@ -4944,8 +5137,15 @@ async function appendTaskRecord(kwargs, record) {
|
|
|
4944
5137
|
return filePath;
|
|
4945
5138
|
}
|
|
4946
5139
|
|
|
4947
|
-
function
|
|
4948
|
-
const
|
|
5140
|
+
export function normalizeTaskPayload(payload, taskType = null, extra = {}) {
|
|
5141
|
+
const root = Array.isArray(payload) ? payload[0] : payload ?? {};
|
|
5142
|
+
const item = root?.task
|
|
5143
|
+
?? root?.taskInfo
|
|
5144
|
+
?? root?.taskDetail
|
|
5145
|
+
?? root?.record
|
|
5146
|
+
?? root?.detail
|
|
5147
|
+
?? root?.data
|
|
5148
|
+
?? root;
|
|
4949
5149
|
const resultFileList = Array.isArray(item?.resultFileList) ? item.resultFileList : [];
|
|
4950
5150
|
const resultFileDisplayList = Array.isArray(item?.resultFileDisplayList) ? item.resultFileDisplayList : [];
|
|
4951
5151
|
const taskExt = item?.taskExt && typeof item.taskExt === 'object' ? item.taskExt : null;
|
|
@@ -4968,6 +5168,8 @@ function normalizeTask(payload, taskType = null, extra = {}) {
|
|
|
4968
5168
|
isTerminal: isTerminalTaskStatus(taskStatus),
|
|
4969
5169
|
modelGroupCode: item?.modelGroupCode ?? null,
|
|
4970
5170
|
pointNo: item?.pointNo ?? null,
|
|
5171
|
+
benefitsId: item?.benefitsId ?? item?.benefits_id ?? item?.benefitId ?? item?.benefit_id
|
|
5172
|
+
?? root?.benefitsId ?? root?.benefits_id ?? root?.benefitId ?? root?.benefit_id ?? null,
|
|
4971
5173
|
gmtCreate: item?.gmtCreate ?? item?.createTime ?? item?.createdAt ?? null,
|
|
4972
5174
|
gmtModified: item?.gmtModified ?? item?.updateTime ?? item?.updatedAt ?? null,
|
|
4973
5175
|
promptSummary: taskPromptSummary({ prompt: item?.taskPrompt }),
|
|
@@ -4981,13 +5183,9 @@ function normalizeTask(payload, taskType = null, extra = {}) {
|
|
|
4981
5183
|
|
|
4982
5184
|
export async function taskStatus(kwargs = {}) {
|
|
4983
5185
|
const taskId = requireValue(kwargs, 'taskId', 'task-id');
|
|
4984
|
-
const
|
|
4985
|
-
|
|
4986
|
-
const payload = kind === 'video' ? await awbApi.fetchVideoTask(taskId) : await awbApi.fetchImageTask(taskId);
|
|
4987
|
-
return normalizeTask(payload, taskType, {
|
|
5186
|
+
const payload = await awbApi.fetchTaskInfo(taskId);
|
|
5187
|
+
return normalizeTaskPayload(payload, null, {
|
|
4988
5188
|
taskId,
|
|
4989
|
-
taskType,
|
|
4990
|
-
...(trimToNull(kwargs.projectGroupNo) ? { projectGroupNo: trimToNull(kwargs.projectGroupNo) } : {}),
|
|
4991
5189
|
});
|
|
4992
5190
|
}
|
|
4993
5191
|
|
|
@@ -5001,7 +5199,7 @@ export async function taskList(kwargs = {}) {
|
|
|
5001
5199
|
projectGroupNo,
|
|
5002
5200
|
};
|
|
5003
5201
|
const payload = await awbApi.fetchTaskFeed(request);
|
|
5004
|
-
const tasks = normalizeRows(payload).map((item) =>
|
|
5202
|
+
const tasks = normalizeRows(payload).map((item) => normalizeTaskPayload(item, item?.taskType ?? taskType, {
|
|
5005
5203
|
projectGroupNo,
|
|
5006
5204
|
}));
|
|
5007
5205
|
return {
|
|
@@ -5015,24 +5213,12 @@ export async function taskList(kwargs = {}) {
|
|
|
5015
5213
|
|
|
5016
5214
|
export async function waitTask(kwargs = {}) {
|
|
5017
5215
|
const taskId = requireValue(kwargs, 'taskId', 'task-id');
|
|
5018
|
-
const taskType = normalizeFeedTaskType(kwargs.taskType ?? 'IMAGE_CREATE');
|
|
5019
5216
|
const waitSeconds = Math.max(0, toInt(kwargs.waitSeconds, 300));
|
|
5020
5217
|
const pollIntervalMs = Math.max(500, toInt(kwargs.pollIntervalMs, 5000));
|
|
5021
5218
|
const deadline = Date.now() + waitSeconds * 1000;
|
|
5022
5219
|
let last = null;
|
|
5023
5220
|
while (true) {
|
|
5024
|
-
last = await taskStatus({ ...kwargs, taskId
|
|
5025
|
-
if (['network_error', 'auth_failed'].includes(error?.type)) {
|
|
5026
|
-
throw error;
|
|
5027
|
-
}
|
|
5028
|
-
const list = await taskList({ ...kwargs, taskId, taskType, pageSize: kwargs.pageSize ?? 100 }).catch((listError) => {
|
|
5029
|
-
if (['network_error', 'auth_failed'].includes(listError?.type)) {
|
|
5030
|
-
throw listError;
|
|
5031
|
-
}
|
|
5032
|
-
return { tasks: [] };
|
|
5033
|
-
});
|
|
5034
|
-
return list.tasks.find((item) => item.taskId === taskId) ?? null;
|
|
5035
|
-
});
|
|
5221
|
+
last = await taskStatus({ ...kwargs, taskId });
|
|
5036
5222
|
if (last?.isTerminal) {
|
|
5037
5223
|
return { ...last, timedOut: false, waitedMs: waitSeconds * 1000 - Math.max(0, deadline - Date.now()) };
|
|
5038
5224
|
}
|
|
@@ -5045,7 +5231,6 @@ export async function waitTask(kwargs = {}) {
|
|
|
5045
5231
|
hint: '稍后再次运行 task wait,或增大 --wait-seconds。',
|
|
5046
5232
|
details: {
|
|
5047
5233
|
taskId,
|
|
5048
|
-
taskType,
|
|
5049
5234
|
waitSeconds,
|
|
5050
5235
|
last,
|
|
5051
5236
|
},
|
|
@@ -5965,7 +6150,7 @@ export async function subtitleRemove(kwargs = {}) {
|
|
|
5965
6150
|
return {
|
|
5966
6151
|
...result,
|
|
5967
6152
|
nextCommand: result.taskId
|
|
5968
|
-
? `lj-awb task
|
|
6153
|
+
? `lj-awb task status --task-id ${result.taskId} -f json`
|
|
5969
6154
|
: null,
|
|
5970
6155
|
};
|
|
5971
6156
|
}
|
|
@@ -5994,24 +6179,6 @@ async function buildSubtitleRemovalRequest(kwargs = {}, options = {}) {
|
|
|
5994
6179
|
};
|
|
5995
6180
|
}
|
|
5996
6181
|
|
|
5997
|
-
export async function subtitleStatus(kwargs = {}) {
|
|
5998
|
-
const taskId = requireValue(kwargs, 'taskId', 'task-id');
|
|
5999
|
-
return taskStatus({
|
|
6000
|
-
...kwargs,
|
|
6001
|
-
taskId,
|
|
6002
|
-
taskType: 'VIDEO_SUBTITLE_REMOVAL',
|
|
6003
|
-
});
|
|
6004
|
-
}
|
|
6005
|
-
|
|
6006
|
-
export async function videoSuperResolutionStatus(kwargs = {}) {
|
|
6007
|
-
const taskId = requireValue(kwargs, 'taskId', 'task-id');
|
|
6008
|
-
return taskStatus({
|
|
6009
|
-
...kwargs,
|
|
6010
|
-
taskId,
|
|
6011
|
-
taskType: 'VIDEO_SUPER_RESOLUTION',
|
|
6012
|
-
});
|
|
6013
|
-
}
|
|
6014
|
-
|
|
6015
6182
|
async function buildVideoSuperResolutionRequest(kwargs = {}, options = {}) {
|
|
6016
6183
|
const objectName = trimToNull(kwargs.objectName);
|
|
6017
6184
|
if (!objectName) {
|
|
@@ -6094,7 +6261,7 @@ export async function videoSuperResolution(kwargs = {}) {
|
|
|
6094
6261
|
return {
|
|
6095
6262
|
...result,
|
|
6096
6263
|
nextCommand: result.taskId
|
|
6097
|
-
? `lj-awb task
|
|
6264
|
+
? `lj-awb task status --task-id ${result.taskId} -f json`
|
|
6098
6265
|
: null,
|
|
6099
6266
|
};
|
|
6100
6267
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import { LingjingAwbCliError, createEnvelope, toBool, toInt } from './common.js';
|
|
4
|
+
import { LingjingAwbCliError, createEnvelope, toBool, toInt, trimToNull } from './common.js';
|
|
5
5
|
import { registerAwbCommands } from './commands.js';
|
|
6
6
|
import { checkCliUpdate } from './update.js';
|
|
7
7
|
import {
|
|
@@ -196,7 +196,13 @@ function buildOutputContext(command, kwargs = {}, data = {}) {
|
|
|
196
196
|
confirmSet.autoConvert = true;
|
|
197
197
|
}
|
|
198
198
|
const isModelList = command.name === 'model image-models' || command.name === 'model video-models';
|
|
199
|
-
const
|
|
199
|
+
const hasModelFilter = isModelList && !toBool(kwargs.all) && Boolean(
|
|
200
|
+
trimToNull(kwargs.model) || trimToNull(kwargs.usage) || trimToNull(kwargs.provider)
|
|
201
|
+
|| trimToNull(kwargs.inputMode) || trimToNull(kwargs.supports)
|
|
202
|
+
|| trimToNull(kwargs.quality) || trimToNull(kwargs.ratio)
|
|
203
|
+
|| trimToNull(kwargs.duration) || toBool(kwargs.needAudio),
|
|
204
|
+
);
|
|
205
|
+
const modelListAll = isModelList && (toBool(kwargs.all) || hasModelFilter);
|
|
200
206
|
const modelListLimit = isModelList
|
|
201
207
|
? (modelListAll ? Number.POSITIVE_INFINITY : Math.max(1, toInt(kwargs.limit, 8)))
|
|
202
208
|
: undefined;
|
|
@@ -355,17 +361,13 @@ const RENAMED_COMMAND_HINTS = {
|
|
|
355
361
|
'image fee': 'create image-fee',
|
|
356
362
|
'image create': 'create image',
|
|
357
363
|
'image create-batch': 'create image-batch',
|
|
358
|
-
'image status': 'task image-status',
|
|
359
364
|
video: 'create video',
|
|
360
365
|
'video fee': 'create video-fee',
|
|
361
366
|
'video create': 'create video',
|
|
362
367
|
'video create-batch': 'create video-batch',
|
|
363
|
-
'video status': 'task video-status',
|
|
364
368
|
'video subtitle-remove': 'create video-subtitle-removal',
|
|
365
369
|
'video super-resolution': 'create video-super-resolution',
|
|
366
370
|
'video super-resolution-fee': 'create video-super-resolution-fee',
|
|
367
|
-
'video super-resolution-status': 'task video-super-resolution-status',
|
|
368
|
-
'video subtitle-status': 'task video-subtitle-status',
|
|
369
371
|
asset: 'create asset',
|
|
370
372
|
'asset match-actor': 'create asset-match-actor',
|
|
371
373
|
'asset groups': 'create asset-groups',
|
|
@@ -460,7 +462,7 @@ const GROUP_DESCRIPTIONS = {
|
|
|
460
462
|
auth: '认证:登录、查看和清空本地 access key',
|
|
461
463
|
account: '账号:查看账号和团队',
|
|
462
464
|
project: '项目:查看、切换、创建和更新项目组',
|
|
463
|
-
credits: '
|
|
465
|
+
credits: '积分:查询可扣积分余额、项目组预算、用量统计和积分明细',
|
|
464
466
|
model: '模型:查询生图 / 生视频模型、参数约束和创建用法',
|
|
465
467
|
create: '创建:统一提交图片、视频、主体、音色、素材和视频去字幕任务',
|
|
466
468
|
upload: '上传:把本地文件上传为平台可访问素材',
|
|
@@ -505,6 +507,7 @@ const GROUP_EXAMPLES = {
|
|
|
505
507
|
],
|
|
506
508
|
credits: [
|
|
507
509
|
'lj-awb credits balance',
|
|
510
|
+
'lj-awb credits records --query-type 2 --page 1 --size 20',
|
|
508
511
|
'lj-awb credits usage --project-group-no <no> --last-hours 24',
|
|
509
512
|
'lj-awb credits buy',
|
|
510
513
|
'lj-awb credits redeem',
|
|
@@ -534,11 +537,8 @@ const GROUP_EXAMPLES = {
|
|
|
534
537
|
],
|
|
535
538
|
task: [
|
|
536
539
|
'lj-awb task list --task-type IMAGE_CREATE --project-group-no <no>',
|
|
537
|
-
'lj-awb task
|
|
538
|
-
'lj-awb task
|
|
539
|
-
'lj-awb task video-subtitle-status --task-id <subtitleTaskId>',
|
|
540
|
-
'lj-awb task video-super-resolution-status --task-id <superResolutionTaskId>',
|
|
541
|
-
'lj-awb task wait --task-id <id> --task-type IMAGE_CREATE --wait-seconds 180',
|
|
540
|
+
'lj-awb task status --task-id <taskId>',
|
|
541
|
+
'lj-awb task wait --task-id <id> --wait-seconds 180',
|
|
542
542
|
'lj-awb task records --task-record-file .awb/tasks.jsonl',
|
|
543
543
|
],
|
|
544
544
|
};
|
|
@@ -552,16 +552,13 @@ const COMMAND_REQUIRED_OPTIONS = {
|
|
|
552
552
|
'create image-fee': ['modelGroupCode', 'prompt'],
|
|
553
553
|
'create image': ['modelGroupCode', 'prompt'],
|
|
554
554
|
'create image-batch': ['inputFile', 'modelGroupCode'],
|
|
555
|
-
'task image-status': ['taskId'],
|
|
556
555
|
'create video-fee': ['modelGroupCode'],
|
|
557
556
|
'create video': ['modelGroupCode'],
|
|
558
557
|
'create video-batch': ['inputFile', 'modelGroupCode'],
|
|
559
558
|
'create video-super-resolution-fee': ['objectName'],
|
|
560
559
|
'create video-super-resolution': ['objectName'],
|
|
561
|
-
'task
|
|
562
|
-
'task
|
|
563
|
-
'task video-super-resolution-status': ['taskId'],
|
|
564
|
-
'task wait': ['taskId', 'taskType'],
|
|
560
|
+
'task status': ['taskId'],
|
|
561
|
+
'task wait': ['taskId'],
|
|
565
562
|
'create asset-match-actor': ['description'],
|
|
566
563
|
'create asset-groups': ['platform'],
|
|
567
564
|
'create asset-group-get': ['groupId', 'platform'],
|
|
@@ -671,6 +668,8 @@ const OUTPUT_KIND_BY_COMMAND = {
|
|
|
671
668
|
'project current': 'project_summary',
|
|
672
669
|
'project users': 'project_user_list',
|
|
673
670
|
'credits balance': 'credits_balance',
|
|
671
|
+
'credits records': 'credits_records',
|
|
672
|
+
'credits detail-status': 'credit_detail_status',
|
|
674
673
|
'credits usage': 'credits_usage',
|
|
675
674
|
'credits buy': 'purchase_guide',
|
|
676
675
|
'credits redeem': 'redeem_result',
|
|
@@ -684,16 +683,13 @@ const OUTPUT_KIND_BY_COMMAND = {
|
|
|
684
683
|
'create image-fee': 'fee_estimate',
|
|
685
684
|
'create image': 'task_submission',
|
|
686
685
|
'create image-batch': 'batch_task_submission',
|
|
687
|
-
'task image-status': 'task_status',
|
|
688
686
|
'create video-fee': 'fee_estimate',
|
|
689
687
|
'create video': 'task_submission',
|
|
690
688
|
'create video-batch': 'batch_task_submission',
|
|
691
689
|
'create video-super-resolution-fee': 'fee_estimate',
|
|
692
690
|
'create video-super-resolution': 'task_submission',
|
|
693
|
-
'task video-status': 'task_status',
|
|
694
691
|
'create video-subtitle-removal': 'subtitle_task_submission',
|
|
695
|
-
'task
|
|
696
|
-
'task video-super-resolution-status': 'task_status',
|
|
692
|
+
'task status': 'task_status',
|
|
697
693
|
'task list': 'task_list',
|
|
698
694
|
'task wait': 'task_status',
|
|
699
695
|
'task records': 'local_task_records',
|
|
@@ -802,16 +798,16 @@ function buildCommandWorkflow(command) {
|
|
|
802
798
|
const outputKind = OUTPUT_KIND_BY_COMMAND[command.name] || 'generic';
|
|
803
799
|
const next = [];
|
|
804
800
|
if (command.name === 'create image') {
|
|
805
|
-
next.push('读取 data.taskId 和 data.nextCommand', '立即运行响应里的 nextCommand,或 task wait --task-
|
|
801
|
+
next.push('读取 data.taskId 和 data.nextCommand', '立即运行响应里的 nextCommand,或 task wait --task-id <id> 等待结果');
|
|
806
802
|
}
|
|
807
803
|
if (command.name === 'create video') {
|
|
808
|
-
next.push('读取 data.taskId 和 data.nextCommand', '立即运行响应里的 nextCommand,或 task wait --task-
|
|
804
|
+
next.push('读取 data.taskId 和 data.nextCommand', '立即运行响应里的 nextCommand,或 task wait --task-id <id> 等待结果');
|
|
809
805
|
}
|
|
810
806
|
if (command.name === 'create video-super-resolution') {
|
|
811
|
-
next.push('读取 data.taskId 和 data.nextCommand', '运行响应里的 task
|
|
807
|
+
next.push('读取 data.taskId 和 data.nextCommand', '运行响应里的 task status 命令查询结果');
|
|
812
808
|
}
|
|
813
809
|
if (command.name === 'create video-subtitle-removal') {
|
|
814
|
-
next.push('读取 data.taskId 和 data.nextCommand', '运行 task
|
|
810
|
+
next.push('读取 data.taskId 和 data.nextCommand', '运行 task status 或响应里的 nextCommand 等待结果');
|
|
815
811
|
}
|
|
816
812
|
if (command.name === 'create subject') {
|
|
817
813
|
next.push('读取 data.elementId / data.externalId', 'externalId 为空时立刻运行 create subject-wait 获取 nextRefSubject');
|