@lingjingai/lj-awb-cli 0.4.8 → 0.5.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.
@@ -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',
@@ -479,10 +480,10 @@ function sanitizeRedeemCode(value) {
479
480
  return String(value ?? '').replace(/\s+/g, '');
480
481
  }
481
482
 
482
- export async function creditsBuy() {
483
+ export async function creditsRecharge() {
483
484
  const { purchaseUrl } = resolvePurchaseUrl();
484
485
  return {
485
- action: 'credits buy',
486
+ action: 'credits recharge',
486
487
  purchaseUrl,
487
488
  };
488
489
  }
@@ -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 === 'image' ? 'IMAGE_CREATE' : 'VIDEO_CREATE';
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 models = normalizeModelRows(payload, kind, { includeRaw })
1083
- .filter((item) => {
1084
- if (!keyword) return true;
1085
- return String(item._searchText ?? '').toLowerCase().includes(keyword);
1086
- })
1087
- .map(({ _searchText, _modelCode, ...item }) => item);
1088
- return { usage, models };
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 = {}, defaultSceneType = null) {
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
- sceneType: trimToNull(item.sceneType ?? kwargs.sceneType) ?? defaultSceneType ?? defaultUploadSceneForFile(file),
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, trimToNull(kwargs.sceneType));
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} --task-type IMAGE_CREATE --project-group-no ${built.projectGroupNo} -f json`
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} --task-type VIDEO_GROUP --project-group-no ${built.projectGroupNo} -f json`
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 normalizeTask(payload, taskType = null, extra = {}) {
4948
- const item = Array.isArray(payload) ? payload[0] : payload ?? {};
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 taskType = normalizeFeedTaskType(kwargs.taskType ?? 'IMAGE_CREATE');
4985
- const kind = taskTypeToStatusKind(taskType);
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) => normalizeTask(item, item?.taskType ?? taskType, {
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, taskType }).catch(async (error) => {
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 video-subtitle-status --task-id ${result.taskId}${built.projectGroupNo ? ` --project-group-no ${built.projectGroupNo}` : ''} -f json`
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 video-super-resolution-status --task-id ${result.taskId}${built.projectGroupNo ? ` --project-group-no ${built.projectGroupNo}` : ''} -f json`
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 {
@@ -124,7 +124,7 @@ const HELP_COLOR = {
124
124
  title: '1;38;5;39',
125
125
  accent: '1;38;5;208',
126
126
  heading: '1;38;5;75',
127
- command: '38;5;82',
127
+ command: '38;5;71',
128
128
  group: '38;5;215',
129
129
  muted: '2;38;5;245',
130
130
  option: '38;5;111',
@@ -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 modelListAll = isModelList && toBool(kwargs.all);
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',
@@ -394,6 +396,7 @@ const RENAMED_COMMAND_HINTS = {
394
396
  'workspace project-group-ensure': 'project ensure',
395
397
  'billing points': 'credits balance',
396
398
  'billing usage-summary': 'credits usage',
399
+ 'credits buy': 'credits recharge',
397
400
  };
398
401
 
399
402
  const MODEL_LIST_GUESS_HINT = `按任务类型分开查询:生图候选用 ${'`'}lj-awb model image-models${'`'},生视频候选用 ${'`'}lj-awb model video-models${'`'}。运行 lj-awb model -h 查看 model 域全部命令。`;
@@ -460,7 +463,7 @@ const GROUP_DESCRIPTIONS = {
460
463
  auth: '认证:登录、查看和清空本地 access key',
461
464
  account: '账号:查看账号和团队',
462
465
  project: '项目:查看、切换、创建和更新项目组',
463
- credits: '积分:查询可扣积分余额、项目组预算和用量统计',
466
+ credits: '积分:查询可扣积分余额、项目组预算、用量统计和积分明细',
464
467
  model: '模型:查询生图 / 生视频模型、参数约束和创建用法',
465
468
  create: '创建:统一提交图片、视频、主体、音色、素材和视频去字幕任务',
466
469
  upload: '上传:把本地文件上传为平台可访问素材',
@@ -505,8 +508,9 @@ const GROUP_EXAMPLES = {
505
508
  ],
506
509
  credits: [
507
510
  'lj-awb credits balance',
511
+ 'lj-awb credits records --query-type 2 --page 1 --size 20',
508
512
  'lj-awb credits usage --project-group-no <no> --last-hours 24',
509
- 'lj-awb credits buy',
513
+ 'lj-awb credits recharge',
510
514
  'lj-awb credits redeem',
511
515
  'lj-awb credits redeem --code <code>',
512
516
  ],
@@ -534,11 +538,8 @@ const GROUP_EXAMPLES = {
534
538
  ],
535
539
  task: [
536
540
  'lj-awb task list --task-type IMAGE_CREATE --project-group-no <no>',
537
- 'lj-awb task image-status --task-id <imageTaskId>',
538
- 'lj-awb task video-status --task-id <videoTaskId>',
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',
541
+ 'lj-awb task status --task-id <taskId>',
542
+ 'lj-awb task wait --task-id <id> --wait-seconds 180',
542
543
  'lj-awb task records --task-record-file .awb/tasks.jsonl',
543
544
  ],
544
545
  };
@@ -552,16 +553,13 @@ const COMMAND_REQUIRED_OPTIONS = {
552
553
  'create image-fee': ['modelGroupCode', 'prompt'],
553
554
  'create image': ['modelGroupCode', 'prompt'],
554
555
  'create image-batch': ['inputFile', 'modelGroupCode'],
555
- 'task image-status': ['taskId'],
556
556
  'create video-fee': ['modelGroupCode'],
557
557
  'create video': ['modelGroupCode'],
558
558
  'create video-batch': ['inputFile', 'modelGroupCode'],
559
559
  'create video-super-resolution-fee': ['objectName'],
560
560
  'create video-super-resolution': ['objectName'],
561
- 'task video-status': ['taskId'],
562
- 'task video-subtitle-status': ['taskId'],
563
- 'task video-super-resolution-status': ['taskId'],
564
- 'task wait': ['taskId', 'taskType'],
561
+ 'task status': ['taskId'],
562
+ 'task wait': ['taskId'],
565
563
  'create asset-match-actor': ['description'],
566
564
  'create asset-groups': ['platform'],
567
565
  'create asset-group-get': ['groupId', 'platform'],
@@ -654,7 +652,7 @@ const LOCAL_STATE_WRITE_COMMANDS = new Set([
654
652
 
655
653
  const DESTRUCTIVE_COMMANDS = new Set(['auth clear']);
656
654
  const LONG_RUNNING_COMMANDS = new Set(['auth login', 'credits redeem', 'task wait', 'task record-poll', 'create subject-wait', 'create subject-voice-wait']);
657
- const NETWORK_NONE_COMMANDS = new Set(['schema', 'auth status', 'auth clear', 'auth logout', 'credits buy', 'model input-guide', 'task records']);
655
+ const NETWORK_NONE_COMMANDS = new Set(['schema', 'auth status', 'auth clear', 'auth logout', 'credits recharge', 'model input-guide', 'task records']);
658
656
  const NETWORK_CONDITIONAL_COMMANDS = new Set(['doctor', 'auth login']);
659
657
 
660
658
  const OUTPUT_KIND_BY_COMMAND = {
@@ -671,8 +669,10 @@ const OUTPUT_KIND_BY_COMMAND = {
671
669
  'project current': 'project_summary',
672
670
  'project users': 'project_user_list',
673
671
  'credits balance': 'credits_balance',
672
+ 'credits records': 'credits_records',
673
+ 'credits detail-status': 'credit_detail_status',
674
674
  'credits usage': 'credits_usage',
675
- 'credits buy': 'purchase_guide',
675
+ 'credits recharge': 'purchase_guide',
676
676
  'credits redeem': 'redeem_result',
677
677
  'model image-models': 'model_list',
678
678
  'model video-models': 'model_list',
@@ -684,16 +684,13 @@ const OUTPUT_KIND_BY_COMMAND = {
684
684
  'create image-fee': 'fee_estimate',
685
685
  'create image': 'task_submission',
686
686
  'create image-batch': 'batch_task_submission',
687
- 'task image-status': 'task_status',
688
687
  'create video-fee': 'fee_estimate',
689
688
  'create video': 'task_submission',
690
689
  'create video-batch': 'batch_task_submission',
691
690
  'create video-super-resolution-fee': 'fee_estimate',
692
691
  'create video-super-resolution': 'task_submission',
693
- 'task video-status': 'task_status',
694
692
  'create video-subtitle-removal': 'subtitle_task_submission',
695
- 'task video-subtitle-status': 'subtitle_task_status',
696
- 'task video-super-resolution-status': 'task_status',
693
+ 'task status': 'task_status',
697
694
  'task list': 'task_list',
698
695
  'task wait': 'task_status',
699
696
  'task records': 'local_task_records',
@@ -802,16 +799,16 @@ function buildCommandWorkflow(command) {
802
799
  const outputKind = OUTPUT_KIND_BY_COMMAND[command.name] || 'generic';
803
800
  const next = [];
804
801
  if (command.name === 'create image') {
805
- next.push('读取 data.taskId 和 data.nextCommand', '立即运行响应里的 nextCommand,或 task wait --task-type IMAGE_CREATE 等待结果');
802
+ next.push('读取 data.taskId 和 data.nextCommand', '立即运行响应里的 nextCommand,或 task wait --task-id <id> 等待结果');
806
803
  }
807
804
  if (command.name === 'create video') {
808
- next.push('读取 data.taskId 和 data.nextCommand', '立即运行响应里的 nextCommand,或 task wait --task-type VIDEO_GROUP 等待结果');
805
+ next.push('读取 data.taskId 和 data.nextCommand', '立即运行响应里的 nextCommand,或 task wait --task-id <id> 等待结果');
809
806
  }
810
807
  if (command.name === 'create video-super-resolution') {
811
- next.push('读取 data.taskId 和 data.nextCommand', '运行响应里的 task video-super-resolution-status 命令查询结果');
808
+ next.push('读取 data.taskId 和 data.nextCommand', '运行响应里的 task status 命令查询结果');
812
809
  }
813
810
  if (command.name === 'create video-subtitle-removal') {
814
- next.push('读取 data.taskId 和 data.nextCommand', '运行 task video-subtitle-status 或响应里的 nextCommand 等待结果');
811
+ next.push('读取 data.taskId 和 data.nextCommand', '运行 task status 或响应里的 nextCommand 等待结果');
815
812
  }
816
813
  if (command.name === 'create subject') {
817
814
  next.push('读取 data.elementId / data.externalId', 'externalId 为空时立刻运行 create subject-wait 获取 nextRefSubject');
@@ -1171,7 +1168,7 @@ function printRootHelp(commands, version) {
1171
1168
  const lines = [
1172
1169
  helpTitle(`lj-awb v${version}`),
1173
1170
  '',
1174
- '灵境 AWB 命令行工具。默认输出人类友好的 pretty 视图;Agent 建议显式传 -f text,脚本严格解析用 -f json。',
1171
+ '灵境 AWB 命令行工具 — 生图 / 生视频 / 积分 / 任务。',
1175
1172
  '',
1176
1173
  helpHeading('Usage:'),
1177
1174
  helpCommand(` ${commandPrefix()} <domain> <command> [options]`),