@lingjingai/lj-awb-cli 0.3.13 → 0.3.15

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 CHANGED
@@ -19,13 +19,14 @@ CLI 本身只负责平台调用、参数校验、精简输出和安全确认;
19
19
  | 认证 | `auth` | access key 状态、校验、保存、清空 |
20
20
  | 账号 | `account` | 用户、团队和登录上下文 |
21
21
  | 项目 | `project` | 项目组查询、切换、创建和更新 |
22
- | 积分 | `credits` | 团队 / 项目组积分、任务用量统计 |
22
+ | 积分 | `credits` | 可扣积分余额、项目组预算、任务用量统计 |
23
23
  | 模型 | `model` | 生图 / 生视频模型发现、模型参数白名单 |
24
24
  | 上传 | `upload` | 本地图片 / 视频 / 音频上传为平台可访问素材 |
25
25
  | 图片 | `image` | 生图估价、提交、批量提交、状态查询 |
26
26
  | 视频 | `video` | 生视频估价、提交、批量提交、状态查询、去字幕 |
27
27
  | 任务 | `task` | 任务列表、等待、任务台账和台账轮询 |
28
28
  | 资产 | `asset` | 素材库匹配、素材组、素材注册 |
29
+ | 最终产物 | `artifact` | Workbench 剧本、资产、视频最终产物 CRUD 与本地 JSON 导入 |
29
30
  | 主体 | `subject` | 可复用主体资产发布与查询 |
30
31
 
31
32
  ## 环境要求
@@ -37,7 +38,7 @@ CLI 本身只负责平台调用、参数校验、精简输出和安全确认;
37
38
  默认 API 地址由代码内置,也可以通过环境变量覆盖:
38
39
 
39
40
  ```bash
40
- export LINGJING_AWB_API_ORIGIN=https://animeworkbench-pre.lingjingai.cn
41
+ export LINGJING_AWB_API_ORIGIN=https://animeworkbench.lingjingai.cn
41
42
  export LINGJING_AWB_ACCESS_KEY=<access_key>
42
43
  ```
43
44
 
@@ -51,6 +52,7 @@ export LINGJING_AWB_ACCESS_KEY=<access_key>
51
52
  npm install -g @lingjingai/lj-awb-cli
52
53
  lj-awb --help
53
54
  lj-awb auth status
55
+ lj-awb auth verify
54
56
  ```
55
57
 
56
58
  安装包的 `postinstall` 会默认把随包分发的 `lj-awb` skill 安装到:
@@ -114,6 +116,7 @@ lj-awb doctor --verify
114
116
  lj-awb schema -f json
115
117
  lj-awb schema --domain video -f json
116
118
  lj-awb auth status
119
+ lj-awb auth verify
117
120
  lj-awb account info
118
121
  lj-awb account teams
119
122
  lj-awb project list
@@ -122,8 +125,12 @@ lj-awb credits balance
122
125
  lj-awb credits usage --project-group-no <no> --last-hours 24
123
126
  lj-awb model image-models --model Banana
124
127
  lj-awb model video-models --model Seedance
128
+ lj-awb model input-guide
125
129
  lj-awb model options --model-group-code <modelGroupCode>
126
130
  lj-awb model create-spec --model-group-code <modelGroupCode>
131
+ lj-awb artifact script import --project-id <projectId> --input-file 1_script/output/script.json --dry-run
132
+ lj-awb artifact asset import --project-id <projectId> --input-dir 2_asset/output --dry-run
133
+ lj-awb artifact video import-storyboard --project-id <projectId> --input-file 3_footage/output/ep001/ep001_storyboard.json --dry-run
127
134
  ```
128
135
 
129
136
  正式写入、切换上下文、批量和扣费命令都支持安全确认:
@@ -151,7 +158,7 @@ lj-awb schema --domain video --command create -f json
151
158
  lj-awb doctor --verify
152
159
  ```
153
160
 
154
- `doctor` 默认只做本地检查;追加 `--verify` 后会联网校验 access key、当前用户和项目组。`schema` 返回每个命令的 `options[].key`,Agent 应使用这些 key 生成 CLI 参数,而不是解析自然语言 help。
161
+ `auth status` 只检查本地是否配置 access key;`auth verify` 会联网校验 key 是否远端有效。`doctor` 默认只做本地检查;追加 `--verify` 后会联网校验 access key、当前用户和项目组。`schema` 返回每个命令的 `options[].key`,Agent 应使用这些 key 生成 CLI 参数,而不是解析自然语言 help。
155
162
 
156
163
  `schema` 还包含面向 Agent 的执行约束:
157
164
 
@@ -162,20 +169,22 @@ lj-awb doctor --verify
162
169
  - `safety.supportsDryRun`:正式执行前是否可以先 `--dry-run`。
163
170
  - `workflow.recommendedPreflight`:推荐前置步骤,例如 `doctor`、模型查询、估价和 dry-run。
164
171
 
165
- 创作任务前按两层读取模型信息:
172
+ 创作任务前按三层读取模型信息:
166
173
 
167
174
  ```bash
175
+ lj-awb model input-guide
168
176
  lj-awb model options --model-group-code <modelGroupCode>
169
177
  lj-awb model create-spec --model-group-code <modelGroupCode>
170
178
  ```
171
179
 
172
- `model options` 专门返回模型参数和资源媒体约束,例如 `params[].values`、`params[].defaultValue`、`resources[].mediaType`、`resources[].usage`、`resources[].fileTypes`、`resources[].maxFiles`、`resources[].minDurationMs/maxDurationMs`。`model create-spec` 专门返回如何创建任务,例如 `inputRequirement`、`supportedIntents`、`preflight` 和 `examples`。默认 text 已经覆盖常用决策字段;只有脚本严格解析或需要完整嵌套结构时才追加 `-f json`。Agent 应用 `options` 选参数值和校验素材,再用 `create-spec` 组装 `image create` / `video create`,不要直接把平台旧参数传给 create。上传音频是 `resources` 素材输入,具体 `audio:reference` 写法看 `create-spec`;`--need-audio` 只是输出音频 / 音效布尔开关。
180
+ `model input-guide` 返回跨模型统一参数、`resources` 字段和 `reference_key` 规则。`model options` 专门返回模型参数、资源媒体约束和条件约束,例如 `params[].values`、`params[].defaultValue`、`resources[].mediaType`、`resources[].usage`、`resources[].fileTypes`、`resources[].maxFiles`、`resources[].supportLastFrameOnly`、`resources[].minDurationMs/maxDurationMs`、`constraints[].target`、`constraints[].conditions`。`model create-spec` 专门返回如何创建任务,例如 `inputRequirement`、`supportedIntents`、`preflight` 和 `examples`。默认 text 已经覆盖常用决策字段;只有脚本严格解析或需要完整嵌套结构时才追加 `-f json`。Agent 应用 `options` 选参数值、校验素材并判断联动约束,再用 `create-spec` 组装 `image create` / `video create`,不要直接把平台旧参数传给 create。上传音频是 `resources` 素材输入,具体 `audio:reference` 写法看 `input-guide` / `create-spec`;是否需要输出音效才使用 `--need-audio true/false`。
173
181
 
174
182
  ## 示例:参考图生成视频
175
183
 
176
184
  ```bash
177
185
  lj-awb project current
178
186
  lj-awb model video-models --model Seedance
187
+ lj-awb model input-guide -f json
179
188
  lj-awb model options --model-group-code <modelGroupCode> -f json
180
189
  lj-awb model create-spec --model-group-code <modelGroupCode> -f json
181
190
 
@@ -206,7 +215,7 @@ lj-awb task wait \
206
215
  --wait-seconds 300
207
216
  ```
208
217
 
209
- 首尾帧也可以直接使用平台资产 ID:
218
+ 帧素材也可以直接使用平台资产 ID;是否可传尾帧以 `model options.resources[].usage` 是否包含 `last_frame` 为准:
210
219
 
211
220
  ```bash
212
221
  lj-awb video create \
@@ -251,7 +260,7 @@ lj-awb video create \
251
260
  "meta": {
252
261
  "command": "auth status",
253
262
  "elapsed_ms": 12,
254
- "api_origin": "https://animeworkbench-pre.lingjingai.cn"
263
+ "api_origin": "https://animeworkbench.lingjingai.cn"
255
264
  }
256
265
  }
257
266
  ```
@@ -269,7 +278,7 @@ lj-awb video create \
269
278
  "meta": {
270
279
  "command": "account info",
271
280
  "elapsed_ms": 1,
272
- "api_origin": "https://animeworkbench-pre.lingjingai.cn"
281
+ "api_origin": "https://animeworkbench.lingjingai.cn"
273
282
  }
274
283
  }
275
284
  ```
@@ -306,12 +315,13 @@ anime-cli/
306
315
  ## 开发命令
307
316
 
308
317
  ```bash
318
+ npm run check:local
309
319
  npm run check
310
320
  npm run smoke
311
321
  npm run version:sync -- 0.3.5
312
322
  ```
313
323
 
314
- `npm run check` 会做 Node 语法检查、shell wrapper 检查和 skill 元数据校验。`npm run smoke` 会运行帮助命令和无网络写入风险的认证状态检查。
324
+ `npm run check:local` 会做 Node 语法检查、shell wrapper 检查、skill 元数据和 schema 校验,不需要 access key。`npm run check` 会额外执行真实平台契约校验,需要本地或环境变量中有可用 access key。`npm run build:pre` / `npm run build:prod` 发布构建只自动执行 `check:local`,避免被本机过期平台凭据阻断;需要真实平台回归时单独运行 `npm run check:real`。`npm run smoke` 会运行帮助命令和无网络写入风险的认证状态检查。
315
325
 
316
326
  ## 文档索引
317
327
 
package/build/pre.mjs CHANGED
@@ -1,20 +1,29 @@
1
1
  #!/usr/bin/env node
2
2
  import { spawnSync } from 'node:child_process';
3
- import { mkdtempSync, rmSync } from 'node:fs';
3
+ import { cpSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
4
4
  import { tmpdir } from 'node:os';
5
5
  import path from 'node:path';
6
6
  import { fileURLToPath } from 'node:url';
7
7
 
8
8
  const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
9
+ const PRE_API_ORIGIN = 'https://animeworkbench-pre.lingjingai.cn';
9
10
  const dryRun = process.env.NPM_INSTALL_DRY_RUN === '1' || process.argv.slice(2).includes('--dry-run');
11
+ const forceInstall = process.env.NPM_INSTALL_FORCE === '1' || process.argv.slice(2).includes('--force');
12
+
13
+ function commandEnv(overrides = {}) {
14
+ return {
15
+ ...process.env,
16
+ LINGJING_AWB_API_ORIGIN: PRE_API_ORIGIN,
17
+ ...overrides,
18
+ };
19
+ }
10
20
 
11
21
  function run(command, args, options = {}) {
12
22
  process.stderr.write(`$ ${[command, ...args].join(' ')}\n`);
13
23
  const result = spawnSync(command, args, {
14
- cwd: repoRoot,
15
- env: process.env,
24
+ cwd: options.cwd || repoRoot,
25
+ env: commandEnv(options.env),
16
26
  stdio: 'inherit',
17
- ...options,
18
27
  });
19
28
 
20
29
  if (result.error) {
@@ -26,11 +35,61 @@ function run(command, args, options = {}) {
26
35
  }
27
36
  }
28
37
 
29
- function packToTempDir(packDir) {
38
+ function capture(command, args, options = {}) {
39
+ return spawnSync(command, args, {
40
+ cwd: options.cwd || repoRoot,
41
+ env: commandEnv(options.env),
42
+ encoding: 'utf8',
43
+ stdio: ['inherit', 'pipe', 'inherit'],
44
+ });
45
+ }
46
+
47
+ function packageFilePaths() {
48
+ const result = capture('npm', ['pack', '--dry-run', '--json']);
49
+ if (result.error) {
50
+ process.stderr.write(`${result.error.message}\n`);
51
+ process.exit(1);
52
+ }
53
+ if (result.status !== 0) {
54
+ process.exit(result.status || 1);
55
+ }
56
+ const packPlan = JSON.parse(result.stdout || '[]');
57
+ const files = packPlan[0]?.files?.map((item) => item.path).filter(Boolean) || [];
58
+ if (!files.length) {
59
+ process.stderr.write('npm pack --dry-run did not return package files.\n');
60
+ process.exit(1);
61
+ }
62
+ return files;
63
+ }
64
+
65
+ function copyPackageFiles(stageDir) {
66
+ for (const relativePath of packageFilePaths()) {
67
+ const sourcePath = path.join(repoRoot, relativePath);
68
+ const targetPath = path.join(stageDir, relativePath);
69
+ mkdirSync(path.dirname(targetPath), { recursive: true });
70
+ cpSync(sourcePath, targetPath, { recursive: true });
71
+ }
72
+ }
73
+
74
+ function patchDefaultApiOrigin(stageDir, apiOrigin) {
75
+ const commonPath = path.join(stageDir, 'packages/awb-core/src/common.js');
76
+ const source = readFileSync(commonPath, 'utf8');
77
+ const next = source.replace(
78
+ /export const DEFAULT_API_ORIGIN = '[^']+';/,
79
+ `export const DEFAULT_API_ORIGIN = '${apiOrigin}';`,
80
+ );
81
+ if (next === source) {
82
+ process.stderr.write(`Could not patch DEFAULT_API_ORIGIN in ${commonPath}.\n`);
83
+ process.exit(1);
84
+ }
85
+ writeFileSync(commonPath, next, 'utf8');
86
+ }
87
+
88
+ function packToTempDir(packDir, cwd = repoRoot) {
30
89
  process.stderr.write(`$ npm pack --pack-destination ${packDir} --silent\n`);
31
90
  const result = spawnSync('npm', ['pack', '--pack-destination', packDir, '--silent'], {
32
- cwd: repoRoot,
33
- env: process.env,
91
+ cwd,
92
+ env: commandEnv(),
34
93
  encoding: 'utf8',
35
94
  stdio: ['inherit', 'pipe', 'inherit'],
36
95
  });
@@ -52,17 +111,22 @@ function packToTempDir(packDir) {
52
111
  }
53
112
 
54
113
  if (process.env.SKIP_CHECK !== '1') {
55
- run('npm', ['run', 'check']);
114
+ run('npm', ['run', 'check:local']);
56
115
  }
57
116
 
58
117
  const packDir = mkdtempSync(path.join(tmpdir(), 'lj-awb-pack-'));
118
+ const stageDir = mkdtempSync(path.join(tmpdir(), 'lj-awb-pre-src-'));
59
119
  try {
60
- const tarballPath = packToTempDir(packDir);
120
+ process.stderr.write(`Preparing local pre build with default API origin ${PRE_API_ORIGIN}.\n`);
121
+ copyPackageFiles(stageDir);
122
+ patchDefaultApiOrigin(stageDir, PRE_API_ORIGIN);
123
+ const tarballPath = packToTempDir(packDir, stageDir);
61
124
  run('npm', [
62
125
  'install',
63
126
  '-g',
64
127
  tarballPath,
65
128
  '--registry=https://registry.npmjs.org/',
129
+ ...(forceInstall ? ['--force'] : []),
66
130
  ...(dryRun ? ['--dry-run'] : []),
67
131
  ]);
68
132
  if (dryRun) {
@@ -73,4 +137,5 @@ try {
73
137
  }
74
138
  } finally {
75
139
  rmSync(packDir, { recursive: true, force: true });
140
+ rmSync(stageDir, { recursive: true, force: true });
76
141
  }
package/build/prod.mjs CHANGED
@@ -9,6 +9,15 @@ const pkg = JSON.parse(readFileSync(path.join(repoRoot, 'package.json'), 'utf8')
9
9
  const passthroughArgs = process.argv.slice(2);
10
10
  const registry = findArgValue(passthroughArgs, '--registry') || process.env.NPM_CONFIG_REGISTRY || 'https://registry.npmjs.org/';
11
11
  const dryRun = process.env.NPM_PUBLISH_DRY_RUN === '1' || passthroughArgs.includes('--dry-run');
12
+ const PROD_API_ORIGIN = 'https://animeworkbench.lingjingai.cn';
13
+
14
+ function commandEnv(overrides = {}) {
15
+ return {
16
+ ...process.env,
17
+ LINGJING_AWB_API_ORIGIN: PROD_API_ORIGIN,
18
+ ...overrides,
19
+ };
20
+ }
12
21
 
13
22
  function findArgValue(args, name) {
14
23
  for (let index = 0; index < args.length; index += 1) {
@@ -23,7 +32,7 @@ function run(command, args, options = {}) {
23
32
  process.stderr.write(`$ ${[command, ...args].join(' ')}\n`);
24
33
  const result = spawnSync(command, args, {
25
34
  cwd: repoRoot,
26
- env: process.env,
35
+ env: commandEnv(options.env),
27
36
  stdio: 'inherit',
28
37
  ...options,
29
38
  });
@@ -40,12 +49,27 @@ function run(command, args, options = {}) {
40
49
  function capture(command, args) {
41
50
  return spawnSync(command, args, {
42
51
  cwd: repoRoot,
43
- env: process.env,
52
+ env: commandEnv(),
44
53
  encoding: 'utf8',
45
54
  stdio: ['inherit', 'pipe', 'pipe'],
46
55
  });
47
56
  }
48
57
 
58
+ function ensureProductionDefaultApiOrigin() {
59
+ const commonPath = path.join(repoRoot, 'packages/awb-core/src/common.js');
60
+ const source = readFileSync(commonPath, 'utf8');
61
+ const match = source.match(/export const DEFAULT_API_ORIGIN = '([^']+)';/);
62
+ const actual = match?.[1] || null;
63
+ if (actual !== PROD_API_ORIGIN) {
64
+ process.stderr.write([
65
+ `Refusing to publish prod build with DEFAULT_API_ORIGIN=${actual || '(missing)'}.`,
66
+ `Expected ${PROD_API_ORIGIN}.`,
67
+ '',
68
+ ].join('\n'));
69
+ process.exit(1);
70
+ }
71
+ }
72
+
49
73
  function ensureLoggedIn() {
50
74
  const result = capture('npm', ['whoami', `--registry=${registry}`]);
51
75
  if (result.status === 0) {
@@ -75,10 +99,12 @@ function ensureVersionNotPublished() {
75
99
  }
76
100
  }
77
101
 
78
- process.stderr.write(`Preparing ${pkg.name}@${pkg.version} for npm ${dryRun ? 'dry-run' : 'publish'}.\n`);
102
+ ensureProductionDefaultApiOrigin();
103
+
104
+ process.stderr.write(`Preparing ${pkg.name}@${pkg.version} for npm ${dryRun ? 'dry-run' : 'publish'} with default API origin ${PROD_API_ORIGIN}.\n`);
79
105
 
80
106
  if (process.env.SKIP_CHECK !== '1') {
81
- run('npm', ['run', 'check']);
107
+ run('npm', ['run', 'check:local']);
82
108
  }
83
109
 
84
110
  ensureVersionNotPublished();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingjingai/lj-awb-cli",
3
- "version": "0.3.13",
3
+ "version": "0.3.15",
4
4
  "description": "Lingjing AWB CLI monorepo with shared core, standalone CLI, and agent skills",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -17,7 +17,9 @@
17
17
  "build": "node build/build.mjs",
18
18
  "build:pre": "node build/pre.mjs",
19
19
  "build:prod": "node build/prod.mjs",
20
- "check": "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/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 && node scripts/validate-cli-output-contract.mjs && node scripts/validate-openapi-cli-examples.mjs",
20
+ "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",
22
+ "check:real": "node scripts/validate-cli-output-contract.mjs && node scripts/validate-openapi-cli-examples.mjs",
21
23
  "test:openapi-real": "node scripts/run-openapi-cli-examples-real.mjs",
22
24
  "smoke": "packages/awb-cli/bin/lj-awb --help && packages/awb-cli/bin/lj-awb auth status -f json",
23
25
  "postinstall": "node install.mjs",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingjingai/awb-cli-bin",
3
- "version": "0.3.13",
3
+ "version": "0.3.15",
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.13"
16
+ "@lingjingai/awb-core": "0.3.15"
17
17
  }
18
18
  }
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@lingjingai/awb-core",
3
- "version": "0.3.13",
3
+ "version": "0.3.15",
4
4
  "description": "Shared core runtime for Lingjing AWB CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  "./common.js": "./src/common.js",
9
9
  "./api.js": "./src/api.js",
10
+ "./artifact.js": "./src/artifact.js",
10
11
  "./auth.js": "./src/auth.js",
11
12
  "./output.js": "./src/output.js",
12
13
  "./services.js": "./src/services.js",