@lingjingai/lj-awb-cli 0.3.15 → 0.4.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.
Files changed (47) hide show
  1. package/README.md +28 -27
  2. package/build/_shared.mjs +130 -0
  3. package/build/build.mjs +3 -0
  4. package/build/pre-publish.mjs +57 -0
  5. package/build/pre.mjs +8 -107
  6. package/build/prod.mjs +9 -78
  7. package/install.mjs +1 -0
  8. package/package.json +8 -3
  9. package/packages/awb-cli/README.md +0 -3
  10. package/packages/awb-cli/package.json +2 -2
  11. package/packages/awb-core/package.json +6 -2
  12. package/packages/awb-core/src/api.js +33 -64
  13. package/packages/awb-core/src/artifact.js +75 -6
  14. package/packages/awb-core/src/auth.js +1 -1
  15. package/packages/awb-core/src/commands.js +279 -118
  16. package/packages/awb-core/src/common.js +3 -2
  17. package/packages/awb-core/src/output.js +2310 -106
  18. package/packages/awb-core/src/services.js +855 -113
  19. package/packages/awb-core/src/standalone.js +841 -242
  20. package/skills/lj-awb/SKILL.md +84 -74
  21. package/skills/lj-awb/VERSION +1 -1
  22. package/skills/lj-awb/compat.json +3 -3
  23. package/skills/lj-awb/modules/account.md +20 -7
  24. package/skills/lj-awb/modules/artifact/asset.md +64 -0
  25. package/skills/lj-awb/modules/artifact/clip.md +65 -0
  26. package/skills/lj-awb/modules/artifact/script.md +37 -0
  27. package/skills/lj-awb/modules/artifact/video.md +65 -0
  28. package/skills/lj-awb/modules/artifact.md +31 -52
  29. package/skills/lj-awb/modules/asset.md +50 -11
  30. package/skills/lj-awb/modules/auth.md +10 -4
  31. package/skills/lj-awb/modules/create-contract.md +21 -12
  32. package/skills/lj-awb/modules/create.md +37 -0
  33. package/skills/lj-awb/modules/credits.md +6 -0
  34. package/skills/lj-awb/modules/driver.md +125 -0
  35. package/skills/lj-awb/modules/evals.md +84 -36
  36. package/skills/lj-awb/modules/image.md +19 -12
  37. package/skills/lj-awb/modules/model.md +31 -31
  38. package/skills/lj-awb/modules/project.md +7 -0
  39. package/skills/lj-awb/modules/subject.md +28 -7
  40. package/skills/lj-awb/modules/task-manual.md +32 -28
  41. package/skills/lj-awb/modules/task.md +70 -8
  42. package/skills/lj-awb/modules/upload.md +16 -2
  43. package/skills/lj-awb/modules/video.md +30 -28
  44. package/skills/lj-awb/modules/workflows.md +232 -169
  45. package/skills/lj-awb/references/error-codes.md +109 -0
  46. package/skills/lj-awb/references/model-options-read.md +19 -12
  47. package/skills/lj-awb/references/output-fields.md +118 -0
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "@lingjingai/lj-awb-cli",
3
- "version": "0.3.15",
3
+ "version": "0.4.0",
4
4
  "description": "Lingjing AWB CLI monorepo with shared core, standalone CLI, and agent skills",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "bin": {
8
8
  "lj-awb": "packages/awb-cli/bin/lj-awb"
9
9
  },
10
+ "dependencies": {
11
+ "chalk": "^5.6.2",
12
+ "cli-table3": "^0.6.5"
13
+ },
10
14
  "engines": {
11
15
  "node": ">=20"
12
16
  },
@@ -16,12 +20,13 @@
16
20
  "scripts": {
17
21
  "build": "node build/build.mjs",
18
22
  "build:pre": "node build/pre.mjs",
23
+ "build:pre-publish": "node build/pre-publish.mjs",
19
24
  "build:prod": "node build/prod.mjs",
20
25
  "check": "npm run check:local && npm run check:real",
21
- "check:local": "node --check install.mjs && node --check packages/awb-core/src/common.js && node --check packages/awb-core/src/api.js && node --check packages/awb-core/src/artifact.js && node --check packages/awb-core/src/auth.js && node --check packages/awb-core/src/output.js && node --check packages/awb-core/src/services.js && node --check packages/awb-core/src/commands.js && node --check packages/awb-core/src/standalone.js && sh -n packages/awb-cli/bin/lj-awb && node --check packages/awb-cli/bin/lj-awb.js && node --check build/build.mjs && node --check build/pre.mjs && node --check build/prod.mjs && node --check scripts/run-openapi-cli-examples-real.mjs && node --check scripts/validate-cli-schema.mjs && node --check scripts/validate-cli-output-contract.mjs && node scripts/validate-skill-meta.mjs && node scripts/validate-cli-schema.mjs",
26
+ "check:local": "node --check install.mjs && node --check packages/awb-core/src/common.js && node --check packages/awb-core/src/api.js && node --check packages/awb-core/src/artifact.js && node --check packages/awb-core/src/auth.js && node --check packages/awb-core/src/output.js && node --check packages/awb-core/src/services.js && node --check packages/awb-core/src/commands.js && node --check packages/awb-core/src/standalone.js && sh -n packages/awb-cli/bin/lj-awb && node --check packages/awb-cli/bin/lj-awb.js && node --check build/build.mjs && node --check build/_shared.mjs && node --check build/pre.mjs && node --check build/pre-publish.mjs && node --check build/prod.mjs && node --check scripts/run-openapi-cli-examples-real.mjs && node --check scripts/validate-cli-schema.mjs && node --check scripts/validate-cli-output-contract.mjs && node --check scripts/validate-cli-command-coverage.mjs && node scripts/validate-skill-meta.mjs && node scripts/validate-cli-schema.mjs && node scripts/validate-cli-command-coverage.mjs",
22
27
  "check:real": "node scripts/validate-cli-output-contract.mjs && node scripts/validate-openapi-cli-examples.mjs",
23
28
  "test:openapi-real": "node scripts/run-openapi-cli-examples-real.mjs",
24
- "smoke": "packages/awb-cli/bin/lj-awb --help && packages/awb-cli/bin/lj-awb auth status -f json",
29
+ "smoke": "packages/awb-cli/bin/lj-awb --help && packages/awb-cli/bin/lj-awb auth status -f json && packages/awb-cli/bin/lj-awb system && packages/awb-cli/bin/lj-awb auth && packages/awb-cli/bin/lj-awb account && packages/awb-cli/bin/lj-awb project && packages/awb-cli/bin/lj-awb credits && packages/awb-cli/bin/lj-awb upload && packages/awb-cli/bin/lj-awb model && packages/awb-cli/bin/lj-awb create && packages/awb-cli/bin/lj-awb task && packages/awb-cli/bin/lj-awb artifact && packages/awb-cli/bin/lj-awb schema -f json >/dev/null",
25
30
  "postinstall": "node install.mjs",
26
31
  "version:sync": "node scripts/sync-versions.mjs"
27
32
  },
@@ -13,7 +13,4 @@ node bin/lj-awb.js auth status -f json
13
13
 
14
14
  ```bash
15
15
  export LINGJING_AWB_ACCESS_KEY=<access_key>
16
- # 兼容 AWB 既有变量:
17
- export AWB_ACCESS_KEY=<access_key>
18
- export AWB_CODE=<access_key>
19
16
  ```
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingjingai/awb-cli-bin",
3
- "version": "0.3.15",
3
+ "version": "0.4.0",
4
4
  "description": "Standalone CLI for Lingjing AWB",
5
5
  "private": true,
6
6
  "license": "MIT",
@@ -13,6 +13,6 @@
13
13
  "README.md"
14
14
  ],
15
15
  "dependencies": {
16
- "@lingjingai/awb-core": "0.3.15"
16
+ "@lingjingai/awb-core": "0.4.0"
17
17
  }
18
18
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingjingai/awb-core",
3
- "version": "0.3.15",
3
+ "version": "0.4.0",
4
4
  "description": "Shared core runtime for Lingjing AWB CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -17,5 +17,9 @@
17
17
  "files": [
18
18
  "src",
19
19
  "README.md"
20
- ]
20
+ ],
21
+ "dependencies": {
22
+ "chalk": "^5.6.2",
23
+ "cli-table3": "^0.6.5"
24
+ }
21
25
  }
@@ -1,12 +1,6 @@
1
1
  import { API_ORIGIN, LingjingAwbCliError } from './common.js';
2
2
  import { resolveAuthContext } from './auth.js';
3
3
 
4
- export const ASSET_EDIT_ORIGIN = (
5
- process.env.LINGJING_AWB_ASSET_EDIT_ORIGIN
6
- || process.env.ASSET_EDIT_ORIGIN
7
- || 'https://asset-edit.lingjingai.cn'
8
- ).replace(/\/+$/, '');
9
-
10
4
  function buildHeaders(authContext, extraHeaders = {}) {
11
5
  const contextHeaders = {};
12
6
  for (const [headerName, envNames] of Object.entries({
@@ -183,6 +177,10 @@ export async function fetchModelGroupInfoAll(modelGroupCode) {
183
177
  return await apiFetch(`/api/resource/model/info/group/${encodeURIComponent(modelGroupCode)}/all`, { method: 'GET' });
184
178
  }
185
179
 
180
+ export async function fetchAssetReviewModels() {
181
+ return await apiFetch('/api/material/creation/model/asset-review/list', { method: 'GET' });
182
+ }
183
+
186
184
  export async function fetchUploadSecret(payload = {}) {
187
185
  return await apiFetch('/api/anime/workbench/TencentCloud/getSecret', { body: payload });
188
186
  }
@@ -224,6 +222,14 @@ export async function fetchVideoTask(taskId) {
224
222
  });
225
223
  }
226
224
 
225
+ export async function fetchVideoSubtitleRemovalFee(payload = {}) {
226
+ return await apiFetch('/api/material/creation/videoSubtitleRemovalFeeCalc', { body: payload });
227
+ }
228
+
229
+ export async function createVideoSubtitleRemovalTask(payload = {}) {
230
+ return await apiFetch('/api/material/creation/videoSubtitleRemoval', { body: payload });
231
+ }
232
+
227
233
  export async function fetchTaskFeed(payload = {}) {
228
234
  return await apiFetch('/api/material/creation/task/feedPull', {
229
235
  query: payload,
@@ -239,8 +245,11 @@ export async function listAssetGroups(payload = {}) {
239
245
  return await apiFetch('/api/material/asset-groups/list', { body: payload });
240
246
  }
241
247
 
242
- export async function getAssetGroup(groupId) {
243
- return await apiFetch(`/api/material/asset-groups/${encodeURIComponent(groupId)}`, { method: 'GET' });
248
+ export async function getAssetGroup(groupId, payload = {}) {
249
+ return await apiFetch(`/api/material/asset-groups/${encodeURIComponent(groupId)}`, {
250
+ method: 'GET',
251
+ query: payload,
252
+ });
244
253
  }
245
254
 
246
255
  export async function createAssetGroup(payload = {}) {
@@ -283,67 +292,27 @@ export async function listElementsByName(elementName) {
283
292
  });
284
293
  }
285
294
 
286
- export async function assetEditFetch(pathname, options = {}) {
287
- const {
288
- method = 'GET',
289
- body,
295
+ export async function listVoices(query = {}) {
296
+ return await apiFetch('/api/material/creation/listVoices', {
297
+ method: 'GET',
290
298
  query,
291
- headers = {},
292
- } = options;
293
- const url = new URL(pathname, ASSET_EDIT_ORIGIN);
294
- for (const [key, value] of Object.entries(query || {})) {
295
- if (value === undefined || value === null || value === '') continue;
296
- url.searchParams.set(key, String(value));
297
- }
298
- let response;
299
- try {
300
- response = await fetch(url, {
301
- method,
302
- headers: {
303
- 'content-type': 'application/json',
304
- ...headers,
305
- },
306
- body: method.toUpperCase() === 'GET' || body === undefined ? undefined : stringifyJsonBody(body),
307
- });
308
- } catch (error) {
309
- throw new LingjingAwbCliError(`请求去字幕服务失败:${error.message}`, {
310
- type: 'network_error',
311
- exitCode: 30,
312
- details: { url: url.toString() },
313
- });
314
- }
315
- const rawText = await response.text();
316
- let payload = null;
317
- try {
318
- payload = rawText ? JSON.parse(rawText) : null;
319
- } catch {
320
- throw new LingjingAwbCliError('去字幕服务返回了无效 JSON', {
321
- type: 'invalid_json',
322
- exitCode: 30,
323
- details: { status: response.status, body: rawText.slice(0, 500) },
324
- });
325
- }
326
- if (!response.ok) {
327
- throw new LingjingAwbCliError(payload?.message || payload?.msg || `${response.status} ${response.statusText}`, {
328
- type: 'http_error',
329
- exitCode: 30,
330
- details: { status: response.status, payload },
331
- });
332
- }
333
- return payload && typeof payload === 'object' && 'data' in payload ? payload.data : payload;
299
+ });
334
300
  }
335
301
 
336
- export async function createSubtitleRemoveTask(payload = {}) {
337
- return await assetEditFetch('/api/watermark/tasks', {
338
- method: 'POST',
339
- body: payload,
340
- });
302
+ export async function createVoice(payload = {}) {
303
+ return await apiFetch('/api/material/creation/createVoice', { body: payload });
341
304
  }
342
305
 
343
- export async function fetchSubtitleTaskByPublicId(publicId) {
344
- return await assetEditFetch(`/api/watermark/tasks/${encodeURIComponent(publicId)}`);
306
+ export async function getVoiceByReqTaskId(reqTaskId) {
307
+ return await apiFetch('/api/material/creation/getVoiceByReqTaskId', {
308
+ method: 'GET',
309
+ query: { reqTaskId },
310
+ });
345
311
  }
346
312
 
347
- export async function fetchSubtitleTaskByRemoteId(remoteTaskId) {
348
- return await assetEditFetch(`/api/watermark/remote/${encodeURIComponent(remoteTaskId)}`);
313
+ export async function listVoicesByName(voiceName) {
314
+ return await apiFetch('/api/material/creation/listVoicesByName', {
315
+ method: 'GET',
316
+ query: { voiceName },
317
+ });
349
318
  }
@@ -47,6 +47,12 @@ function requireProjectId(kwargs) {
47
47
  return projectId;
48
48
  }
49
49
 
50
+ function requireNumericValue(kwargs, key, label = key) {
51
+ const value = requireValue(kwargs, key, label);
52
+ if (!/^\d+$/.test(String(value))) throw argumentError(`--${label.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`)} 必须是数字`);
53
+ return value;
54
+ }
55
+
50
56
  function artifactPath(kind, projectId, suffix = '') {
51
57
  return `${WORKBENCH_PREFIX}/${kind}-output/projects/${encodeURIComponent(projectId)}${suffix}`;
52
58
  }
@@ -213,16 +219,16 @@ function scriptSpeakerRows(script) {
213
219
  const speakers = Array.isArray(script.speakers) ? script.speakers : [];
214
220
  return speakers
215
221
  .map((speaker, index) => {
216
- const speakerKey = textValue(speaker, 'speakerKey', 'speaker_key', 'id', 'key');
222
+ const speakerKey = textValue(speaker, 'speakerKey', 'speaker_key', 'speakerId', 'speaker_id', 'id', 'key');
217
223
  if (!speakerKey) return null;
218
224
  return compactRecord({
219
225
  rowKind: 'speaker',
220
226
  entityKey: speakerKey,
221
227
  sortOrder: index + 1,
222
228
  speakerKey,
223
- speakerDisplayName: textValue(speaker, 'speakerDisplayName', 'speaker_display_name', 'displayName', 'name'),
224
- speakerSourceKind: textValue(speaker, 'speakerSourceKind', 'speaker_source_kind'),
225
- speakerSourceKey: textValue(speaker, 'speakerSourceKey', 'speaker_source_key'),
229
+ speakerDisplayName: textValue(speaker, 'speakerDisplayName', 'speaker_display_name', 'displayName', 'display_name', 'name'),
230
+ speakerSourceKind: textValue(speaker, 'speakerSourceKind', 'speaker_source_kind', 'sourceKind', 'source_kind'),
231
+ speakerSourceKey: textValue(speaker, 'speakerSourceKey', 'speaker_source_key', 'sourceKey', 'source_key', 'sourceId', 'source_id'),
226
232
  voiceDesc: textValue(speaker, 'voiceDesc', 'voice_desc'),
227
233
  compat: speaker,
228
234
  });
@@ -825,8 +831,8 @@ export async function artifactVideoUpdateClipVideoUrls(kwargs = {}) {
825
831
  }
826
832
  if (!Array.isArray(videoUrls)) throw argumentError('--video-urls-json 必须是 JSON 数组');
827
833
  const body = { videoUrls };
828
- if (toBool(kwargs.dryRun)) return { dryRun: true, action: 'artifact video update-clip-video-urls', projectId, episodeId, sceneId, clipId, request: body };
829
- ensureConfirmed(kwargs, '回写 clip 视频链接需要确认', { action: 'artifact video update-clip-video-urls', projectId, episodeId, sceneId, clipId });
834
+ if (toBool(kwargs.dryRun)) return { dryRun: true, action: 'artifact video update-clip-urls', projectId, episodeId, sceneId, clipId, request: body };
835
+ ensureConfirmed(kwargs, '回写 clip 视频链接需要确认', { action: 'artifact video update-clip-urls', projectId, episodeId, sceneId, clipId });
830
836
  return await apiFetch(artifactPath('video', projectId, `/episodes/${encodeURIComponent(episodeId)}/scenes/${encodeURIComponent(sceneId)}/clips/${encodeURIComponent(clipId)}/video-urls`), { body });
831
837
  }
832
838
 
@@ -865,3 +871,66 @@ export async function artifactVideoImportStoryboard(kwargs = {}) {
865
871
  }
866
872
  return { imported: true, ...summary, result };
867
873
  }
874
+
875
+ export async function artifactClipGet(kwargs = {}) {
876
+ return await apiFetch(artifactPath('clip', requireProjectId(kwargs)), { method: 'GET' });
877
+ }
878
+
879
+ export async function artifactClipEpisodes(kwargs = {}) {
880
+ return await apiFetch(artifactPath('clip', requireProjectId(kwargs), '/episodes'), { method: 'GET' });
881
+ }
882
+
883
+ export async function artifactClipEpisode(kwargs = {}) {
884
+ const projectId = requireProjectId(kwargs);
885
+ const videoEpisodeId = requireNumericValue(kwargs, 'videoEpisodeId', 'video-episode-id');
886
+ return await apiFetch(artifactPath('clip', projectId, `/episodes/${encodeURIComponent(videoEpisodeId)}`), { method: 'GET' });
887
+ }
888
+
889
+ export async function artifactClipEpisodeById(kwargs = {}) {
890
+ const projectId = requireProjectId(kwargs);
891
+ const episodeId = requireValue(kwargs, 'episodeId', 'episode-id');
892
+ return await apiFetch(artifactPath('clip', projectId, `/episode-id/${encodeURIComponent(episodeId)}`), { method: 'GET' });
893
+ }
894
+
895
+ export async function artifactClipUpsertEpisode(kwargs = {}) {
896
+ const projectId = requireProjectId(kwargs);
897
+ const body = await readBodyPayload(kwargs);
898
+ if (toBool(kwargs.dryRun)) return { dryRun: true, action: 'artifact clip upsert-episode', projectId, request: body };
899
+ ensureConfirmed(kwargs, '写入剪辑最终产物需要确认', { action: 'artifact clip upsert-episode', projectId, videoEpisodeId: body?.videoEpisodeId });
900
+ return await apiFetch(artifactPath('clip', projectId, '/episodes'), { body });
901
+ }
902
+
903
+ export async function artifactClipUpsertBatch(kwargs = {}) {
904
+ const projectId = requireProjectId(kwargs);
905
+ const body = await readBodyPayload(kwargs);
906
+ if (!Array.isArray(body)) throw argumentError('剪辑批量写入请求体必须是 JSON 数组');
907
+ if (toBool(kwargs.dryRun)) return { dryRun: true, action: 'artifact clip upsert-batch', projectId, episodeCount: body.length, request: body };
908
+ ensureConfirmed(kwargs, '批量写入剪辑最终产物需要确认', { action: 'artifact clip upsert-batch', projectId, episodeCount: body.length });
909
+ return await apiFetch(artifactPath('clip', projectId, '/episodes/batch'), { body });
910
+ }
911
+
912
+ export async function artifactClipUpdateStatus(kwargs = {}) {
913
+ const projectId = requireProjectId(kwargs);
914
+ const videoEpisodeId = requireNumericValue(kwargs, 'videoEpisodeId', 'video-episode-id');
915
+ const status = requireValue(kwargs, 'status');
916
+ let messages;
917
+ if (trimToNull(kwargs.messagesJson)) {
918
+ try {
919
+ messages = parseJsonArg(kwargs.messagesJson);
920
+ } catch (error) {
921
+ throw argumentError('--messages-json 不是有效 JSON', error.message);
922
+ }
923
+ }
924
+ const body = compactRecord({ status, messages });
925
+ if (toBool(kwargs.dryRun)) return { dryRun: true, action: 'artifact clip update-status', projectId, videoEpisodeId, request: body };
926
+ ensureConfirmed(kwargs, '更新剪辑最终产物状态需要确认', { action: 'artifact clip update-status', projectId, videoEpisodeId, status });
927
+ return await apiFetch(artifactPath('clip', projectId, `/episodes/${encodeURIComponent(videoEpisodeId)}/status`), { body });
928
+ }
929
+
930
+ export async function artifactClipDeleteEpisode(kwargs = {}) {
931
+ const projectId = requireProjectId(kwargs);
932
+ const videoEpisodeId = requireNumericValue(kwargs, 'videoEpisodeId', 'video-episode-id');
933
+ if (toBool(kwargs.dryRun)) return { dryRun: true, action: 'artifact clip delete-episode', projectId, videoEpisodeId };
934
+ ensureConfirmed(kwargs, '删除剪辑最终产物需要确认', { action: 'artifact clip delete-episode', projectId, videoEpisodeId });
935
+ return await apiFetch(artifactPath('clip', projectId, `/episodes/${encodeURIComponent(videoEpisodeId)}`), { method: 'DELETE' });
936
+ }
@@ -37,7 +37,7 @@ export async function resolveAuthContext({ required = true } = {}) {
37
37
  throw new LingjingAwbCliError('缺少 access key', {
38
38
  type: 'auth_required',
39
39
  exitCode: 3,
40
- hint: '请设置 LINGJING_AWB_ACCESS_KEY / AWB_ACCESS_KEY,或运行 lj-awb auth login-key。',
40
+ hint: '请设置 LINGJING_AWB_ACCESS_KEY,或运行 lj-awb auth login。',
41
41
  });
42
42
  }
43
43
  return {