@lingjingai/lj-awb-cli 0.4.6 → 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 +14 -7
- package/build/volta-pre.mjs +64 -0
- package/install.mjs +11 -3
- package/package.json +4 -3
- package/packages/awb-cli/package.json +2 -2
- package/packages/awb-core/package.json +1 -2
- package/packages/awb-core/src/api.js +14 -12
- package/packages/awb-core/src/commands.js +55 -506
- package/packages/awb-core/src/common.js +3 -5
- package/packages/awb-core/src/output.js +92 -306
- package/packages/awb-core/src/services.js +263 -64
- package/packages/awb-core/src/standalone.js +33 -207
- package/packages/awb-core/src/update.js +74 -3
- package/skills/lj-awb/SKILL.md +15 -8
- package/skills/lj-awb/VERSION +1 -1
- package/skills/lj-awb/compat.json +3 -3
- package/skills/lj-awb/modules/account.md +5 -3
- 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 +4 -10
- 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/project.md +2 -2
- 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 -77
- package/skills/lj-awb/references/error-codes.md +2 -2
- package/skills/lj-awb/references/output-fields.md +11 -15
- package/packages/awb-core/src/artifact.js +0 -936
- package/skills/lj-awb/modules/artifact/asset.md +0 -64
- package/skills/lj-awb/modules/artifact/clip.md +0 -65
- package/skills/lj-awb/modules/artifact/script.md +0 -37
- package/skills/lj-awb/modules/artifact/video.md +0 -65
- package/skills/lj-awb/modules/artifact.md +0 -65
|
@@ -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',
|
|
@@ -704,9 +705,41 @@ export async function selectTeam(kwargs = {}) {
|
|
|
704
705
|
action: 'account switch-team',
|
|
705
706
|
groupId,
|
|
706
707
|
});
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
708
|
+
// userId 取当前登录用户(与 account info 同源:fetchUserInfo)
|
|
709
|
+
const userId = normalizeUserInfo(await awbApi.fetchUserInfo()).userId;
|
|
710
|
+
if (!userId) {
|
|
711
|
+
throw new LingjingAwbCliError('无法获取当前用户 userId,切换团队失败', {
|
|
712
|
+
type: 'api_error',
|
|
713
|
+
exitCode: 1,
|
|
714
|
+
hint: '请先确认已登录(lj-awb auth status),再重试。',
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
// 用 userId + 目标 groupId 换取该团队的 accessKey
|
|
718
|
+
const accessKey = trimSecret(await awbApi.fetchGroupAccessKey({ userId, groupId }));
|
|
719
|
+
if (!accessKey) {
|
|
720
|
+
throw new LingjingAwbCliError('切换团队失败:未返回该团队的 accessKey', {
|
|
721
|
+
type: 'api_error',
|
|
722
|
+
exitCode: 1,
|
|
723
|
+
hint: '请确认该 groupId 属于当前用户可访问的团队;若持续失败请联系平台。',
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
// 刷新本地认证文件(等同登录写入),并用新 key 校验,拿到切换后的用户 / 团队上下文
|
|
727
|
+
const saved = await saveVerifiedAccessKey(accessKey, { loginMethod: 'switch-team' });
|
|
728
|
+
const switchedGroupId = saved.user?.groupId ?? groupId;
|
|
729
|
+
await saveState({
|
|
730
|
+
currentGroupId: switchedGroupId,
|
|
731
|
+
currentGroupName: saved.user?.groupName ?? null,
|
|
732
|
+
currentUserId: saved.user?.userId ?? userId,
|
|
733
|
+
}).catch(() => {});
|
|
734
|
+
return {
|
|
735
|
+
selected: true,
|
|
736
|
+
action: 'account switch-team',
|
|
737
|
+
groupId: switchedGroupId,
|
|
738
|
+
groupName: saved.user?.groupName ?? null,
|
|
739
|
+
userId: saved.user?.userId ?? userId,
|
|
740
|
+
userName: saved.user?.userName ?? null,
|
|
741
|
+
accessKey: saved.accessKey,
|
|
742
|
+
};
|
|
710
743
|
}
|
|
711
744
|
|
|
712
745
|
export async function selectProjectGroupCommand(kwargs = {}) {
|
|
@@ -714,13 +747,13 @@ export async function selectProjectGroupCommand(kwargs = {}) {
|
|
|
714
747
|
if (toBool(kwargs.dryRun)) {
|
|
715
748
|
return {
|
|
716
749
|
dryRun: true,
|
|
717
|
-
action: 'project
|
|
750
|
+
action: 'project switch',
|
|
718
751
|
selected: false,
|
|
719
752
|
request: { projectGroupNo },
|
|
720
753
|
};
|
|
721
754
|
}
|
|
722
755
|
ensureConfirmed(kwargs, '切换项目组会改变后续生成任务归属,需要确认', {
|
|
723
|
-
action: 'project
|
|
756
|
+
action: 'project switch',
|
|
724
757
|
projectGroupNo,
|
|
725
758
|
});
|
|
726
759
|
await awbApi.selectProjectGroup(projectGroupNo);
|
|
@@ -883,6 +916,89 @@ export async function creditsBalance(kwargs = {}) {
|
|
|
883
916
|
};
|
|
884
917
|
}
|
|
885
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
|
+
|
|
886
1002
|
function parseTimeMs(value, fallback = null) {
|
|
887
1003
|
if (value === undefined || value === null || value === '') return fallback;
|
|
888
1004
|
const numeric = Number(value);
|
|
@@ -965,7 +1081,6 @@ function modelListMetadata(kind, paramKeys = [], rulesByKey = new Map()) {
|
|
|
965
1081
|
const controls = [];
|
|
966
1082
|
if (keys.has('ratio')) controls.push('ratio');
|
|
967
1083
|
if (keys.has('quality')) controls.push('quality');
|
|
968
|
-
if (kind === 'image' && keys.has('generate_num')) controls.push('generateNum');
|
|
969
1084
|
if (kind === 'video' && keys.has('generated_time')) controls.push('duration');
|
|
970
1085
|
if (kind === 'video' && (keys.has('need_audio') || keys.has('audio'))) controls.push('needAudio');
|
|
971
1086
|
return {
|
|
@@ -1000,6 +1115,14 @@ function modelSuccessRate(item = {}) {
|
|
|
1000
1115
|
);
|
|
1001
1116
|
}
|
|
1002
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
|
+
|
|
1003
1126
|
function normalizeModelRows(payload, kind, options = {}) {
|
|
1004
1127
|
const includeRaw = Boolean(options.includeRaw);
|
|
1005
1128
|
const includeInternal = Boolean(options.includeInternal);
|
|
@@ -1026,6 +1149,10 @@ function normalizeModelRows(payload, kind, options = {}) {
|
|
|
1026
1149
|
feeCalcType: item?.feeCalcType ?? item?.feeType ?? null,
|
|
1027
1150
|
inputModes: metadata.inputModes,
|
|
1028
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'),
|
|
1029
1156
|
_searchText: JSON.stringify([
|
|
1030
1157
|
modelCode,
|
|
1031
1158
|
modelGroupCode,
|
|
@@ -1042,18 +1169,114 @@ function normalizeModelRows(payload, kind, options = {}) {
|
|
|
1042
1169
|
});
|
|
1043
1170
|
}
|
|
1044
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
|
+
|
|
1045
1261
|
export async function listModels(kind, kwargs = {}) {
|
|
1046
|
-
const usage = kind
|
|
1262
|
+
const usage = resolveModelUsage(kind, kwargs);
|
|
1047
1263
|
const payload = await awbApi.fetchModelsByUsage(usage, {});
|
|
1048
|
-
const keyword = trimToNull(kwargs.model ?? kwargs.keyword)?.toLowerCase();
|
|
1049
1264
|
const includeRaw = toBool(kwargs.includeRaw);
|
|
1050
|
-
const
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
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;
|
|
1057
1280
|
}
|
|
1058
1281
|
|
|
1059
1282
|
function requireAssetPlatform(value, options = {}) {
|
|
@@ -2798,7 +3021,7 @@ function defaultUploadSceneForFile(filePath, mimeType = '') {
|
|
|
2798
3021
|
return TASK_UPLOAD_SCENE.DEFAULT;
|
|
2799
3022
|
}
|
|
2800
3023
|
|
|
2801
|
-
async function collectFileSpecs(kwargs = {}
|
|
3024
|
+
async function collectFileSpecs(kwargs = {}) {
|
|
2802
3025
|
const specs = [];
|
|
2803
3026
|
for (const file of parseListArg(kwargs.file)) specs.push({ file });
|
|
2804
3027
|
for (const file of parseListArg(kwargs.files)) specs.push({ file });
|
|
@@ -2815,7 +3038,9 @@ async function collectFileSpecs(kwargs = {}, defaultSceneType = null) {
|
|
|
2815
3038
|
const file = trimToNull(item.file ?? item.path ?? item.filePath);
|
|
2816
3039
|
return {
|
|
2817
3040
|
file,
|
|
2818
|
-
|
|
3041
|
+
// upload files 是用户手动上传,统一走临时隔离场景(cli-upload-temp,独立、可定期清理);
|
|
3042
|
+
// 不受 --scene-type 影响。create 系列的自动上传不经过这里,仍走各自业务场景。
|
|
3043
|
+
sceneType: CLI_TEMP_UPLOAD_SCENE,
|
|
2819
3044
|
projectNo: trimToNull(item.projectNo ?? kwargs.projectNo) ?? '',
|
|
2820
3045
|
};
|
|
2821
3046
|
})
|
|
@@ -3589,7 +3814,7 @@ function validateAssetRemoteSource(assetPath) {
|
|
|
3589
3814
|
}
|
|
3590
3815
|
|
|
3591
3816
|
export async function uploadFilesCommand(kwargs = {}) {
|
|
3592
|
-
const specs = await collectFileSpecs(kwargs
|
|
3817
|
+
const specs = await collectFileSpecs(kwargs);
|
|
3593
3818
|
if (!specs.length) throw argumentError('缺少上传文件', '传 --file <path> 或 --files a.png,b.mp4。');
|
|
3594
3819
|
if (toBool(kwargs.dryRun)) {
|
|
3595
3820
|
const files = [];
|
|
@@ -4626,7 +4851,7 @@ export async function imageCreate(kwargs = {}) {
|
|
|
4626
4851
|
return {
|
|
4627
4852
|
...result,
|
|
4628
4853
|
nextCommand: result.taskId
|
|
4629
|
-
? `lj-awb task wait --task-id ${result.taskId}
|
|
4854
|
+
? `lj-awb task wait --task-id ${result.taskId} -f json`
|
|
4630
4855
|
: null,
|
|
4631
4856
|
};
|
|
4632
4857
|
}
|
|
@@ -4745,7 +4970,7 @@ export async function videoCreate(kwargs = {}) {
|
|
|
4745
4970
|
return {
|
|
4746
4971
|
...result,
|
|
4747
4972
|
nextCommand: result.taskId
|
|
4748
|
-
? `lj-awb task wait --task-id ${result.taskId}
|
|
4973
|
+
? `lj-awb task wait --task-id ${result.taskId} -f json`
|
|
4749
4974
|
: null,
|
|
4750
4975
|
};
|
|
4751
4976
|
}
|
|
@@ -4912,8 +5137,15 @@ async function appendTaskRecord(kwargs, record) {
|
|
|
4912
5137
|
return filePath;
|
|
4913
5138
|
}
|
|
4914
5139
|
|
|
4915
|
-
function
|
|
4916
|
-
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;
|
|
4917
5149
|
const resultFileList = Array.isArray(item?.resultFileList) ? item.resultFileList : [];
|
|
4918
5150
|
const resultFileDisplayList = Array.isArray(item?.resultFileDisplayList) ? item.resultFileDisplayList : [];
|
|
4919
5151
|
const taskExt = item?.taskExt && typeof item.taskExt === 'object' ? item.taskExt : null;
|
|
@@ -4936,6 +5168,8 @@ function normalizeTask(payload, taskType = null, extra = {}) {
|
|
|
4936
5168
|
isTerminal: isTerminalTaskStatus(taskStatus),
|
|
4937
5169
|
modelGroupCode: item?.modelGroupCode ?? null,
|
|
4938
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,
|
|
4939
5173
|
gmtCreate: item?.gmtCreate ?? item?.createTime ?? item?.createdAt ?? null,
|
|
4940
5174
|
gmtModified: item?.gmtModified ?? item?.updateTime ?? item?.updatedAt ?? null,
|
|
4941
5175
|
promptSummary: taskPromptSummary({ prompt: item?.taskPrompt }),
|
|
@@ -4949,13 +5183,9 @@ function normalizeTask(payload, taskType = null, extra = {}) {
|
|
|
4949
5183
|
|
|
4950
5184
|
export async function taskStatus(kwargs = {}) {
|
|
4951
5185
|
const taskId = requireValue(kwargs, 'taskId', 'task-id');
|
|
4952
|
-
const
|
|
4953
|
-
|
|
4954
|
-
const payload = kind === 'video' ? await awbApi.fetchVideoTask(taskId) : await awbApi.fetchImageTask(taskId);
|
|
4955
|
-
return normalizeTask(payload, taskType, {
|
|
5186
|
+
const payload = await awbApi.fetchTaskInfo(taskId);
|
|
5187
|
+
return normalizeTaskPayload(payload, null, {
|
|
4956
5188
|
taskId,
|
|
4957
|
-
taskType,
|
|
4958
|
-
...(trimToNull(kwargs.projectGroupNo) ? { projectGroupNo: trimToNull(kwargs.projectGroupNo) } : {}),
|
|
4959
5189
|
});
|
|
4960
5190
|
}
|
|
4961
5191
|
|
|
@@ -4969,7 +5199,7 @@ export async function taskList(kwargs = {}) {
|
|
|
4969
5199
|
projectGroupNo,
|
|
4970
5200
|
};
|
|
4971
5201
|
const payload = await awbApi.fetchTaskFeed(request);
|
|
4972
|
-
const tasks = normalizeRows(payload).map((item) =>
|
|
5202
|
+
const tasks = normalizeRows(payload).map((item) => normalizeTaskPayload(item, item?.taskType ?? taskType, {
|
|
4973
5203
|
projectGroupNo,
|
|
4974
5204
|
}));
|
|
4975
5205
|
return {
|
|
@@ -4983,24 +5213,12 @@ export async function taskList(kwargs = {}) {
|
|
|
4983
5213
|
|
|
4984
5214
|
export async function waitTask(kwargs = {}) {
|
|
4985
5215
|
const taskId = requireValue(kwargs, 'taskId', 'task-id');
|
|
4986
|
-
const taskType = normalizeFeedTaskType(kwargs.taskType ?? 'IMAGE_CREATE');
|
|
4987
5216
|
const waitSeconds = Math.max(0, toInt(kwargs.waitSeconds, 300));
|
|
4988
5217
|
const pollIntervalMs = Math.max(500, toInt(kwargs.pollIntervalMs, 5000));
|
|
4989
5218
|
const deadline = Date.now() + waitSeconds * 1000;
|
|
4990
5219
|
let last = null;
|
|
4991
5220
|
while (true) {
|
|
4992
|
-
last = await taskStatus({ ...kwargs, taskId
|
|
4993
|
-
if (['network_error', 'auth_failed'].includes(error?.type)) {
|
|
4994
|
-
throw error;
|
|
4995
|
-
}
|
|
4996
|
-
const list = await taskList({ ...kwargs, taskId, taskType, pageSize: kwargs.pageSize ?? 100 }).catch((listError) => {
|
|
4997
|
-
if (['network_error', 'auth_failed'].includes(listError?.type)) {
|
|
4998
|
-
throw listError;
|
|
4999
|
-
}
|
|
5000
|
-
return { tasks: [] };
|
|
5001
|
-
});
|
|
5002
|
-
return list.tasks.find((item) => item.taskId === taskId) ?? null;
|
|
5003
|
-
});
|
|
5221
|
+
last = await taskStatus({ ...kwargs, taskId });
|
|
5004
5222
|
if (last?.isTerminal) {
|
|
5005
5223
|
return { ...last, timedOut: false, waitedMs: waitSeconds * 1000 - Math.max(0, deadline - Date.now()) };
|
|
5006
5224
|
}
|
|
@@ -5013,7 +5231,6 @@ export async function waitTask(kwargs = {}) {
|
|
|
5013
5231
|
hint: '稍后再次运行 task wait,或增大 --wait-seconds。',
|
|
5014
5232
|
details: {
|
|
5015
5233
|
taskId,
|
|
5016
|
-
taskType,
|
|
5017
5234
|
waitSeconds,
|
|
5018
5235
|
last,
|
|
5019
5236
|
},
|
|
@@ -5933,7 +6150,7 @@ export async function subtitleRemove(kwargs = {}) {
|
|
|
5933
6150
|
return {
|
|
5934
6151
|
...result,
|
|
5935
6152
|
nextCommand: result.taskId
|
|
5936
|
-
? `lj-awb task
|
|
6153
|
+
? `lj-awb task status --task-id ${result.taskId} -f json`
|
|
5937
6154
|
: null,
|
|
5938
6155
|
};
|
|
5939
6156
|
}
|
|
@@ -5962,24 +6179,6 @@ async function buildSubtitleRemovalRequest(kwargs = {}, options = {}) {
|
|
|
5962
6179
|
};
|
|
5963
6180
|
}
|
|
5964
6181
|
|
|
5965
|
-
export async function subtitleStatus(kwargs = {}) {
|
|
5966
|
-
const taskId = requireValue(kwargs, 'taskId', 'task-id');
|
|
5967
|
-
return taskStatus({
|
|
5968
|
-
...kwargs,
|
|
5969
|
-
taskId,
|
|
5970
|
-
taskType: 'VIDEO_SUBTITLE_REMOVAL',
|
|
5971
|
-
});
|
|
5972
|
-
}
|
|
5973
|
-
|
|
5974
|
-
export async function videoSuperResolutionStatus(kwargs = {}) {
|
|
5975
|
-
const taskId = requireValue(kwargs, 'taskId', 'task-id');
|
|
5976
|
-
return taskStatus({
|
|
5977
|
-
...kwargs,
|
|
5978
|
-
taskId,
|
|
5979
|
-
taskType: 'VIDEO_SUPER_RESOLUTION',
|
|
5980
|
-
});
|
|
5981
|
-
}
|
|
5982
|
-
|
|
5983
6182
|
async function buildVideoSuperResolutionRequest(kwargs = {}, options = {}) {
|
|
5984
6183
|
const objectName = trimToNull(kwargs.objectName);
|
|
5985
6184
|
if (!objectName) {
|
|
@@ -6062,7 +6261,7 @@ export async function videoSuperResolution(kwargs = {}) {
|
|
|
6062
6261
|
return {
|
|
6063
6262
|
...result,
|
|
6064
6263
|
nextCommand: result.taskId
|
|
6065
|
-
? `lj-awb task
|
|
6264
|
+
? `lj-awb task status --task-id ${result.taskId} -f json`
|
|
6066
6265
|
: null,
|
|
6067
6266
|
};
|
|
6068
6267
|
}
|