@aswless_854771076/ai_short_studio_cli 0.1.108 → 0.1.112

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
@@ -31,7 +31,7 @@ Agent 代操作时,用户已在当前会话明确提供的密码只能直接
31
31
 
32
32
  CLI 只把 refresh token 保存到系统钥匙串。短期 access token 会写入权限为 `0600` 的本机 session 缓存;同一 profile 的并发进程通过跨进程锁共享刷新结果,只有缓存缺失或确实需要刷新时才访问钥匙串,从而避免 Agent 批量操作反复触发 macOS Keychain。退出登录会清除该缓存,CI 可用 `VVICAT_ACCESS_TOKEN` 直接注入临时令牌。未配置服务地址时默认连接 `https://ai-short-studio.vvicat.dev`,`--base-url`、`VVICAT_BASE_URL` 和当前 profile 可依次覆盖。首次登录会从服务端 bootstrap 取得 Supabase 公共配置,也可用 `VVICAT_SUPABASE_URL`、`VVICAT_SUPABASE_PUBLISHABLE_KEY` 显式覆盖。Google 登录在 Windows 上直接调用系统 URL Handler,确保带 `&` 的 PKCE 授权参数完整传给浏览器。服务地址和非敏感 profile 写入系统配置目录;切换环境时必须使用独立的 `--profile`,避免复用旧认证。
33
33
 
34
- 创作前运行 `ai-short-studio preflight --json`。CLI 会通过公开的 `/api/v1/bootstrap` 检查服务连通性、取得 Supabase 公共配置、读取 npm `latest` 稳定版本并默认更新当前全局包,再检查登录态和文本、人物、场景、故事版、视频模型配置。npm registry 暂时不可用时服务端使用配置版本降级。更新后必须按输出重跑;明确不允许全局写入时使用 `--no-update`。
34
+ 创作前运行 `ai-short-studio preflight --json`。CLI 会通过公开的 `/api/v1/bootstrap` 检查服务连通性、取得 Supabase 公共配置、读取 npm `latest` 稳定版本并报告 `updateAvailable`,默认只检查、不修改全局包。需要更新时显式传 `--update`,更新成功后按输出重跑。随后预检检查登录态和文本、人物、场景、故事版、视频模型配置。npm registry 暂时不可用时服务端使用配置版本降级。
35
35
 
36
36
  ## 命令范围
37
37
 
@@ -45,7 +45,7 @@ CLI 只把 refresh token 保存到系统钥匙串。短期 access token 会写
45
45
  - `ai-short-studio canvas asset`:资产列表、上传、版本选择和下载。
46
46
  - `ai-short-studio canvas folder`:画布资产目录管理(5 预设 + 用户子目录 + 软删 + 跨项目复制)。
47
47
  - `ai-short-studio canvas episode`:列出或创建无限画布分集。其他画布命令用 `--episode <ID|集数>` 选择分集。
48
- - `ai-short-studio task`:异步任务读取、批量等待和取消。
48
+ - `ai-short-studio task`:项目任务列表、读取、受限批量等待和取消。
49
49
  - `ai-short-studio config`:读取管理员发布的全局模型,管理个人默认模型、能力默认值和并发配置;CLI 会拒绝写入 Provider 或模型目录。
50
50
 
51
51
  CLI 不提供分集删除或任务人工复核提交;这两类需要确认生产资产或保留范围的操作继续在网页端完成。
@@ -107,15 +107,16 @@ ai-short-studio canvas asset upload ./reference.wav --project "$PROJECT_ID" --js
107
107
  ai-short-studio canvas node add audio --project "$PROJECT_ID" --asset-id <assetId> --json
108
108
  # --asset-id 只允许 image、video、audio 节点,其他节点会在写入前拒绝
109
109
  ai-short-studio canvas node add recreation-shot-extract --project "$PROJECT_ID" --config ./shot.json --json
110
- ai-short-studio canvas node run --project "$PROJECT_ID" --node <node1> --node <node2> --concurrency 4 --wait --json
111
- ai-short-studio task wait --task <task1> --task <task2> --concurrency 4 --json
110
+ ai-short-studio canvas node run --project "$PROJECT_ID" --node <node1> --node <node2> --concurrency 4 --json
111
+ ai-short-studio task list --project "$PROJECT_ID" --status running --json
112
+ ai-short-studio task wait --task <task1> --task <task2> --concurrency 4 --timeout 600 --max-interval 15000 --json
112
113
  ```
113
114
 
114
- `canvas node update` 的 `--set key=<JSON>`、`--unset key`、`--title`、`--x` 和 `--y` 只修改指定字段;旧 `--config` 仍兼容。`update-many` 在一次画布版本校验中原子更新多个节点。结构化生成资源仍必须使用 `edit-resource` 或 `edit-shot`,不能通过字段更新改写 artifact。批量执行与等待默认并发为 4、上限为 16;Agent 应优先单进程批处理,避免为每个节点启动一个 CLI 进程。
115
+ `canvas node update` 的 `--set key=<JSON>`、`--unset key`、`--title`、`--x` 和 `--y` 只修改指定字段;旧 `--config` 仍兼容。`update-many` 在一次画布版本校验中原子更新多个节点。结构化生成资源仍必须使用 `edit-resource` 或 `edit-shot`,不能通过字段更新改写 artifact。批量执行与等待默认并发为 4、上限为 16。`task list` 默认返回精简状态,`--full` 才返回完整 payload/result;`task wait` 默认 600 秒超时,并对无变化状态使用 1 秒到 15 秒指数退避。Agent 应优先单进程批处理,避免为每个节点启动一个 CLI 进程。
115
116
 
116
- 使用 `canvas node edit-shot <nodeId> --project <projectId> --file shot.json` 编辑镜头。命令会追加并选中不可变的人工 DOCUMENT 版本,不允许修改 `shotKey`、`shotIndex` 或来源身份,旧版本继续可选。
117
+ 使用 `canvas node edit-shot <nodeId> --project <projectId> --file shot.json` 编辑镜头。命令会追加并选中不可变的人工 DOCUMENT 版本,不允许修改 `shotKey`、`shotIndex` 或来源身份,旧版本继续可选。重复提交同一节点、同一基线与同一载荷,或当前选版内容已等于目标结果时,返回已有版本并标记 `idempotent: true`。画布版本冲突会刷新画布和当前选版后重试一次;资产版本竞争因事务已回滚,会刷新画布并保留原基线重试一次。身份错误不会重试。
117
118
 
118
- 使用 `canvas node edit-resource <nodeId> --project <projectId> --file resource.json` 编辑剧本、人物、人物视觉、场景、子场景或道具结构化资源。命令只替换完整父文档中的目标实体,追加并选中人工版本;名称、资源键、ID 和所属关系不可修改,兄弟资源节点保持原选版。资源版本写入不属于 `canvas apply` 图补丁,409 后需重新读取画布与当前选版。
119
+ 使用 `canvas node edit-resource <nodeId> --project <projectId> --file resource.json` 编辑剧本、人物、人物视觉、场景、子场景或道具结构化资源。命令只替换完整父文档中的目标实体,追加并选中人工版本;名称、资源键、ID 和所属关系不可修改,兄弟资源节点保持原选版。资源版本写入不属于 `canvas apply` 图补丁;它与 `edit-shot` 使用相同的幂等、当前结果无操作和一次冲突恢复规则。
119
120
 
120
121
  CLI 通过 `/api/v1/bootstrap` 完成版本、连通性与 Supabase 公共配置预检,并直接使用现有 `/api/projects`、`/api/canvas/node-types`、项目画布与资产路由。
121
122
 
@@ -127,7 +128,7 @@ CLI 通过 `/api/v1/bootstrap` 完成版本、连通性与 Supabase 公共配置
127
128
 
128
129
  专业 Markdown 剧本可在 `storyboard-breakdown` 配置中显式使用 `storyboardPipelineVersion: 2`、`sourceFormat: screenplay-markdown.v1`、任意规范 BCP 47 `targetLanguage`(如 `en`、`ar`、`fr`、`pt-BR` 或 `zh-Hant`)、`platform: TikTok` 和 `aspectRatio: 9:16`。CLI 通过现有通用节点配置写入这些字段。该模式只生成分镜文本和镜头资产,不自动运行声音、TTS、图片、音频或视频节点。
129
130
 
130
- `storyboard-breakdown` 还可按实时 schema 写入 `targetDurationSeconds`、`pacingPreset` 和 `maxShotCount`。它们是镜头规划预算,超出只提示而不阻塞源文完整覆盖;留空时不限制镜头数,也不启用时长硬门禁。生成链采用滚动异步调度:单镜分镜图完成后立即进入视频提示词,提示词通过审计后立即提交该镜视频,可恢复失败不阻塞其他镜头。内置 Skill 同时补全字幕、人物/场景首次介绍角标、有动机的镜头衔接、声音平衡和成片验收流程。
131
+ `storyboard-breakdown` 还可按实时 schema 写入 `targetDurationSeconds`、`pacingPreset` 和 `maxShotCount`。结构化剧本会先生成固定镜号、顺序和来源的确定性骨架;其中 `maxShotCount` 是硬预算,无法完整覆盖来源时会在模型调用前明确失败。纯文本旧链路仍按软提醒处理镜头数,`targetDurationSeconds` 始终是柔性时长目标。留空时不限制镜头数,也不启用时长硬门禁。生成链采用滚动异步调度:单镜分镜图完成后立即进入视频提示词,提示词通过审计后立即提交该镜视频,可恢复失败不阻塞其他镜头。内置 Skill 同时补全字幕、人物/场景首次介绍角标、有动机的镜头衔接、声音平衡和成片验收流程。
131
132
 
132
133
  标准短剧制作读取主 Skill `references/short-drama/` 与 `references/humanizer/`:先生成和复核专业剧本,再审计模板化台词、虚浮修辞与机械节奏,最后检查剧情连贯性。hypit 视频制作流程读取 `references/hypit/`。Humanizer 只润色表达,不改剧情事实、人物关系、专有名词、数字、时间线、世界观规则、场次结构或拍摄标记。剧本确认后再选择目标集数、创建或复用项目,并只建立目标集实际出现的人物、场景、道具和可选音色设定。拆镜前必须完成资产—剧情匹配审计;拆镜后逐镜全量检查重复、无效、缺失、冲突、穿帮、连续性、道具交互朝向、语言和来源身份。P0/P1 未清零时不得进入图片、声音或视频生产。
133
134
 
@@ -135,7 +136,7 @@ CLI 通过 `/api/v1/bootstrap` 完成版本、连通性与 Supabase 公共配置
135
136
 
136
137
  `canvas settings set` 支持项目级 `imageResolution`、`imageQuality`、`videoResolution`,未覆盖的图片、图片编辑和视频节点会继承这些默认值。候选值来自 `settings get` 对应字段的实时 `options`;节点仅在需要偏离项目默认时,按当前模型 `capabilities` 写入 `resolution`、`quality` 覆盖。
137
138
 
138
- 项目交付语言在创建时用 `ai-short-studio project create --language pt-BR` 固定,接受任意规范 BCP 47 标签;剧本、拆镜、台词、配音、画面文字和字幕都沿用该值。`canvas settings get` 只回读项目语言,画布设置接口不能清空或修改它。交付时只下载每镜 selected 原始 MP4,按 `S001.mp4` 顺序命名,并用 manifest 记录镜号、节点、资产、版本和文件名;字幕单独交付,不烧录进原始视频。
139
+ 项目交付语言在创建时用 `ai-short-studio project create --language pt-BR` 固定,接受任意规范 BCP 47 标签;剧本、拆镜、台词、配音、画面文字和字幕都沿用该值。`canvas settings get` 只回读项目语言,画布设置接口不能清空或修改它。CLI `--locale` 只影响界面消息;文本与短剧节点按项目 `outputLanguage` 选择模板并追加强制语言合同。节点 `prompt` 作为附加指令执行,但不得覆盖主 schema、必填字段或语言合同。短剧结构化节点会校验 JSON 主合同,散文不会落库;数据库旧模板缺少 JSON 或关键 schema 字段时会告警并回退仓库模板。空白模型结果按 `EMPTY_RESPONSE` 失败重试,不生成空资产。交付时只下载每镜 selected 原始 MP4,按 `S001.mp4` 顺序命名,并用 manifest 记录镜号、节点、资产、版本和文件名;字幕单独交付,不烧录进原始视频。
139
140
 
140
141
  百炼 CosyVoice 的 `tts` 节点通过实时 schema 提供音色、语言、格式、采样率、音量、语速、音调和声音指令。先用 `canvas settings get` 确认最终 `audioModel`,再从 `canvas node types` 返回的 `tts.configSchema` 选择字段和值;CLI 会在写入前校验必填字段、类型、整数、枚举和数值上下限。
141
142
 
@@ -8,4 +8,10 @@ export declare function commandApi(flags: Parameters<typeof createRuntime>[0]):
8
8
  client: import("./client/api-client.js").ApiClient;
9
9
  }>;
10
10
  export declare function readJsonInput(file?: string): Promise<Record<string, unknown>>;
11
+ export type CanvasEditConflictReason = 'CANVAS_VERSION_CONFLICT' | 'ASSET_VERSION_RACE';
12
+ export declare function canvasEditConflictReason(error: unknown): CanvasEditConflictReason | null;
13
+ export declare function resolveCanvasNodeVersionId(api: Pick<VvicatApi, 'asset'>, projectId: string, node: {
14
+ refId?: unknown;
15
+ data: Record<string, unknown>;
16
+ }): Promise<string>;
11
17
  export declare function mapConcurrent<T, R>(values: T[], concurrency: number, transform: (value: T, index: number) => Promise<R>): Promise<R[]>;
@@ -1,5 +1,6 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import { Flags } from '@oclif/core';
3
+ import { CliApiError } from './client/errors.js';
3
4
  import { createRuntime } from './runtime.js';
4
5
  import { VvicatApi } from './domain/vvicat-api.js';
5
6
  export const projectFlag = Flags.string({ description: '无限画布项目 ID', required: true });
@@ -14,6 +15,25 @@ export async function readJsonInput(file) {
14
15
  throw new Error('输入必须是 JSON 对象');
15
16
  return value;
16
17
  }
18
+ export function canvasEditConflictReason(error) {
19
+ if (!(error instanceof CliApiError) || error.status !== 409)
20
+ return null;
21
+ const reason = error.details.reason;
22
+ return reason === 'CANVAS_VERSION_CONFLICT' || reason === 'ASSET_VERSION_RACE' ? reason : null;
23
+ }
24
+ export async function resolveCanvasNodeVersionId(api, projectId, node) {
25
+ const selectedOutputVersionId = node.data.selectedOutputVersionId;
26
+ if (typeof selectedOutputVersionId === 'string' && selectedOutputVersionId) {
27
+ return selectedOutputVersionId;
28
+ }
29
+ if (typeof node.refId !== 'string' || !node.refId)
30
+ return '';
31
+ const payload = await api.asset(projectId, node.refId);
32
+ const asset = payload.asset && typeof payload.asset === 'object' && !Array.isArray(payload.asset)
33
+ ? payload.asset
34
+ : {};
35
+ return typeof asset.selectedVersionId === 'string' ? asset.selectedVersionId : '';
36
+ }
17
37
  export async function mapConcurrent(values, concurrency, transform) {
18
38
  const results = new Array(values.length);
19
39
  let cursor = 0;
@@ -1,6 +1,6 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
2
  import { BaseCommand } from '../../../base-command.js';
3
- import { commandApi, projectFlag, readJsonInput } from '../../../command-helpers.js';
3
+ import { canvasEditConflictReason, commandApi, projectFlag, readJsonInput, resolveCanvasNodeVersionId, } from '../../../command-helpers.js';
4
4
  export default class CanvasNodeEditResource extends BaseCommand {
5
5
  static args = { nodeId: Args.string({ required: true }) };
6
6
  static flags = {
@@ -11,35 +11,52 @@ export default class CanvasNodeEditResource extends BaseCommand {
11
11
  async run() {
12
12
  const { args, flags } = await this.parse(CanvasNodeEditResource);
13
13
  const { api } = await commandApi(flags);
14
- const canvas = await api.canvas(flags.project);
15
- const node = canvas.nodes.find((candidate) => candidate.id === args.nodeId);
16
- const rawArtifact = node?.data.artifact;
14
+ const resource = await readJsonInput(flags.file);
15
+ let canvas = await api.canvas(flags.project);
16
+ const initialNode = canvas.nodes.find((candidate) => candidate.id === args.nodeId);
17
+ const rawArtifact = initialNode?.data.artifact;
17
18
  const artifact = rawArtifact && typeof rawArtifact === 'object' && !Array.isArray(rawArtifact)
18
19
  ? rawArtifact
19
20
  : null;
20
- if (!node || !artifact
21
+ if (!initialNode || !artifact
21
22
  || artifact.type !== 'GENERATED_RESOURCE'
22
23
  || typeof artifact.operation !== 'string' || !artifact.operation
23
24
  || typeof artifact.resourceKey !== 'string' || !artifact.resourceKey
24
25
  || typeof artifact.resourceType !== 'string' || !artifact.resourceType) {
25
26
  throw new Error(`结构化资源节点不可编辑:${args.nodeId}`);
26
27
  }
27
- let basedOnVersionId = typeof node.data.selectedOutputVersionId === 'string'
28
- ? node.data.selectedOutputVersionId
29
- : '';
30
- if (!basedOnVersionId && typeof node.refId === 'string') {
31
- const payload = await api.asset(flags.project, node.refId);
32
- const asset = payload.asset && typeof payload.asset === 'object' && !Array.isArray(payload.asset)
33
- ? payload.asset
34
- : {};
35
- basedOnVersionId = typeof asset.selectedVersionId === 'string' ? asset.selectedVersionId : '';
36
- }
28
+ let basedOnVersionId = await resolveCanvasNodeVersionId(api, flags.project, initialNode);
37
29
  if (!basedOnVersionId)
38
30
  throw new Error('结构化资源当前版本不存在');
39
- this.print(await api.updateStructuredResource(flags.project, args.nodeId, {
40
- expectedCanvasVersion: canvas.version,
41
- basedOnVersionId,
42
- resource: await readJsonInput(flags.file),
43
- }));
31
+ for (let attempt = 0;; attempt += 1) {
32
+ try {
33
+ this.print(await api.updateStructuredResource(flags.project, args.nodeId, {
34
+ expectedCanvasVersion: canvas.version,
35
+ basedOnVersionId,
36
+ resource,
37
+ }));
38
+ return;
39
+ }
40
+ catch (error) {
41
+ const reason = canvasEditConflictReason(error);
42
+ if (attempt >= 1 || !reason)
43
+ throw error;
44
+ canvas = await api.canvas(flags.project);
45
+ if (reason === 'CANVAS_VERSION_CONFLICT') {
46
+ const currentNode = canvas.nodes.find((candidate) => candidate.id === args.nodeId);
47
+ if (!currentNode)
48
+ throw new Error(`结构化资源节点不可编辑:${args.nodeId}`);
49
+ const rawCurrentArtifact = currentNode.data.artifact;
50
+ const currentArtifact = rawCurrentArtifact && typeof rawCurrentArtifact === 'object'
51
+ && !Array.isArray(rawCurrentArtifact)
52
+ ? rawCurrentArtifact
53
+ : null;
54
+ if (currentArtifact?.type !== 'GENERATED_RESOURCE') {
55
+ throw new Error(`结构化资源节点不可编辑:${args.nodeId}`);
56
+ }
57
+ basedOnVersionId = await resolveCanvasNodeVersionId(api, flags.project, currentNode);
58
+ }
59
+ }
60
+ }
44
61
  }
45
62
  }
@@ -1,6 +1,6 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
2
  import { BaseCommand } from '../../../base-command.js';
3
- import { commandApi, projectFlag, readJsonInput } from '../../../command-helpers.js';
3
+ import { canvasEditConflictReason, commandApi, projectFlag, readJsonInput, resolveCanvasNodeVersionId, } from '../../../command-helpers.js';
4
4
  export default class CanvasNodeEditShot extends BaseCommand {
5
5
  static args = { nodeId: Args.string({ required: true }) };
6
6
  static flags = {
@@ -11,26 +11,37 @@ export default class CanvasNodeEditShot extends BaseCommand {
11
11
  async run() {
12
12
  const { args, flags } = await this.parse(CanvasNodeEditShot);
13
13
  const { api } = await commandApi(flags);
14
- const canvas = await api.canvas(flags.project);
15
- const node = canvas.nodes.find((candidate) => candidate.id === args.nodeId);
16
- if (!node || node.kind !== 'storyboard-shot')
14
+ const shot = await readJsonInput(flags.file);
15
+ let canvas = await api.canvas(flags.project);
16
+ const initialNode = canvas.nodes.find((candidate) => candidate.id === args.nodeId);
17
+ if (!initialNode || initialNode.kind !== 'storyboard-shot') {
17
18
  throw new Error(`镜头节点不存在:${args.nodeId}`);
18
- let basedOnVersionId = typeof node.data.selectedOutputVersionId === 'string'
19
- ? node.data.selectedOutputVersionId
20
- : '';
21
- if (!basedOnVersionId && typeof node.refId === 'string') {
22
- const payload = await api.asset(flags.project, node.refId);
23
- const asset = payload.asset && typeof payload.asset === 'object' && !Array.isArray(payload.asset)
24
- ? payload.asset
25
- : {};
26
- basedOnVersionId = typeof asset.selectedVersionId === 'string' ? asset.selectedVersionId : '';
27
19
  }
20
+ let basedOnVersionId = await resolveCanvasNodeVersionId(api, flags.project, initialNode);
28
21
  if (!basedOnVersionId)
29
22
  throw new Error('镜头当前版本不存在');
30
- this.print(await api.updateStoryboardShot(flags.project, args.nodeId, {
31
- expectedCanvasVersion: canvas.version,
32
- basedOnVersionId,
33
- shot: await readJsonInput(flags.file),
34
- }));
23
+ for (let attempt = 0;; attempt += 1) {
24
+ try {
25
+ this.print(await api.updateStoryboardShot(flags.project, args.nodeId, {
26
+ expectedCanvasVersion: canvas.version,
27
+ basedOnVersionId,
28
+ shot,
29
+ }));
30
+ return;
31
+ }
32
+ catch (error) {
33
+ const reason = canvasEditConflictReason(error);
34
+ if (attempt >= 1 || !reason)
35
+ throw error;
36
+ canvas = await api.canvas(flags.project);
37
+ if (reason === 'CANVAS_VERSION_CONFLICT') {
38
+ const currentNode = canvas.nodes.find((candidate) => candidate.id === args.nodeId);
39
+ if (!currentNode || currentNode.kind !== 'storyboard-shot') {
40
+ throw new Error(`镜头节点不存在:${args.nodeId}`);
41
+ }
42
+ basedOnVersionId = await resolveCanvasNodeVersionId(api, flags.project, currentNode);
43
+ }
44
+ }
45
+ }
35
46
  }
36
47
  }
@@ -9,6 +9,8 @@ export default class CanvasNodeRun extends BaseCommand {
9
9
  concurrency: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
10
10
  wait: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
11
  interval: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
12
+ 'max-interval': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
13
+ timeout: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
12
14
  'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
15
  json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
16
  locale: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
@@ -1,6 +1,9 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
2
  import { BaseCommand } from '../../../base-command.js';
3
3
  import { commandApi, mapConcurrent, projectFlag } from '../../../command-helpers.js';
4
+ function submittedTaskId(result) {
5
+ return result.task?.taskId || result.task?.id;
6
+ }
4
7
  export default class CanvasNodeRun extends BaseCommand {
5
8
  static args = { nodeId: Args.string({ required: false }) };
6
9
  static flags = {
@@ -8,8 +11,10 @@ export default class CanvasNodeRun extends BaseCommand {
8
11
  project: projectFlag,
9
12
  node: Flags.string({ description: '节点 ID,可重复指定以批量运行', multiple: true }),
10
13
  concurrency: Flags.integer({ description: '批量提交并发数', default: 4, min: 1, max: 16 }),
11
- wait: Flags.boolean({ default: false }),
12
- interval: Flags.integer({ default: 1000 }),
14
+ wait: Flags.boolean({ description: '兼容显式单批等待;滚动流水线应使用 task list 调度', default: false }),
15
+ interval: Flags.integer({ description: '初始轮询间隔(毫秒)', default: 1_000, min: 1, max: 60_000 }),
16
+ 'max-interval': Flags.integer({ description: '无状态变化时的最大轮询间隔(毫秒)', default: 15_000, min: 1, max: 60_000 }),
17
+ timeout: Flags.integer({ description: '等待超时(秒)', default: 600, min: 1, max: 86_400 }),
13
18
  };
14
19
  async run() {
15
20
  const { args, flags } = await this.parse(CanvasNodeRun);
@@ -25,10 +30,17 @@ export default class CanvasNodeRun extends BaseCommand {
25
30
  this.print(nodeIds.length === 1 ? submissions[0].result : { submissions });
26
31
  return;
27
32
  }
28
- const tasks = submissions.filter((item) => item.result.task?.id);
33
+ const tasks = submissions.flatMap((item) => {
34
+ const taskId = submittedTaskId(item.result);
35
+ return taskId ? [{ nodeId: item.nodeId, taskId }] : [];
36
+ });
29
37
  const completed = await mapConcurrent(tasks, flags.concurrency, async (item) => ({
30
38
  nodeId: item.nodeId,
31
- task: await api.waitTask(item.result.task.id, flags.interval),
39
+ task: await api.waitTask(item.taskId, {
40
+ interval: flags.interval,
41
+ maxInterval: flags['max-interval'],
42
+ timeoutMs: flags.timeout * 1_000,
43
+ }),
32
44
  }));
33
45
  this.print(nodeIds.length === 1 ? completed[0]?.task ?? submissions[0].result : { submissions, tasks: completed });
34
46
  if (completed.some((item) => item.task.status !== 'completed'))
@@ -8,14 +8,17 @@ export default class Preflight extends BaseCommand {
8
8
  static description = '创作前检查 CLI、服务连接、认证和模型配置';
9
9
  static flags = {
10
10
  ...BaseCommand.baseFlags,
11
- update: Flags.boolean({ description: '发现新版本时更新全局 CLI', default: true, allowNo: true }),
11
+ update: Flags.boolean({ description: '发现新版本时更新全局 CLI(默认仅检查)', default: false, allowNo: true }),
12
12
  };
13
13
  async run() {
14
14
  const { flags } = await this.parse(Preflight);
15
15
  const profiles = new ProfileStore();
16
16
  const selected = flags.profile ? await profiles.get(flags.profile) : await profiles.current();
17
17
  const baseUrl = (flags['base-url'] || process.env.VVICAT_BASE_URL || selected?.baseUrl || DEFAULT_BASE_URL).replace(/\/+$/, '');
18
- const bootstrap = await fetchBootstrap(baseUrl);
18
+ const bootstrap = await fetchBootstrap(baseUrl).catch((error) => {
19
+ const message = error instanceof Error ? error.message : String(error);
20
+ throw new Error(`${message};当前 profile:${selected?.name ?? '(default)'}`);
21
+ });
19
22
  const current = await readCurrentPackageIdentity();
20
23
  const hasUpdate = compareStableVersions(current.version, bootstrap.cli.latestVersion) < 0;
21
24
  const version = flags.update
@@ -27,12 +30,27 @@ export default class Preflight extends BaseCommand {
27
30
  latestVersion: bootstrap.cli.latestVersion,
28
31
  };
29
32
  if (version.restartRequired) {
30
- this.print({ connected: true, version, ready: false, nextAction: '重新运行 ai-short-studio preflight --json' });
33
+ this.print({
34
+ connected: true,
35
+ profile: selected?.name ?? null,
36
+ baseUrl,
37
+ version,
38
+ ready: false,
39
+ nextAction: '重新运行 ai-short-studio preflight --json',
40
+ });
31
41
  return;
32
42
  }
33
43
  const runtime = await createRuntime(flags);
34
44
  await runtime.client.request('/api/auth/session');
35
45
  const readiness = inspectCreationConfig(await new VvicatApi(runtime.client).config());
36
- this.print({ connected: true, authenticated: true, updateAvailable: hasUpdate, version, ...readiness });
46
+ this.print({
47
+ connected: true,
48
+ profile: selected?.name ?? null,
49
+ baseUrl,
50
+ authenticated: true,
51
+ updateAvailable: hasUpdate,
52
+ version,
53
+ ...readiness,
54
+ });
37
55
  }
38
56
  }
@@ -0,0 +1,19 @@
1
+ import { BaseCommand } from '../../base-command.js';
2
+ export default class TaskList extends BaseCommand {
3
+ static description: string;
4
+ static flags: {
5
+ project: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
6
+ 'target-type': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ 'target-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ status: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ type: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ limit: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
11
+ full: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
+ 'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
+ locale: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
15
+ profile: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
+ episode: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ };
18
+ run(): Promise<void>;
19
+ }
@@ -0,0 +1,30 @@
1
+ import { Flags } from '@oclif/core';
2
+ import { BaseCommand } from '../../base-command.js';
3
+ import { commandApi } from '../../command-helpers.js';
4
+ export default class TaskList extends BaseCommand {
5
+ static description = '按项目和状态查询当前用户的任务';
6
+ static flags = {
7
+ ...BaseCommand.baseFlags,
8
+ project: Flags.string({ description: '无限画布项目 ID' }),
9
+ 'target-type': Flags.string({ description: '任务目标类型' }),
10
+ 'target-id': Flags.string({ description: '任务目标 ID' }),
11
+ status: Flags.string({ description: '任务状态,可重复指定', multiple: true }),
12
+ type: Flags.string({ description: '任务类型,可重复指定', multiple: true }),
13
+ limit: Flags.integer({ description: '最多返回任务数', default: 50, min: 1, max: 200 }),
14
+ full: Flags.boolean({ description: '返回完整任务载荷和结果', default: false }),
15
+ };
16
+ async run() {
17
+ const { flags } = await this.parse(TaskList);
18
+ const { api } = await commandApi(flags);
19
+ const tasks = await api.listTasks({
20
+ projectId: flags.project,
21
+ targetType: flags['target-type'],
22
+ targetId: flags['target-id'],
23
+ statuses: flags.status,
24
+ types: flags.type,
25
+ limit: flags.limit,
26
+ summary: !flags.full,
27
+ });
28
+ this.print({ tasks });
29
+ }
30
+ }
@@ -7,6 +7,8 @@ export default class TaskWait extends BaseCommand {
7
7
  task: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
8
  concurrency: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
9
9
  interval: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
10
+ 'max-interval': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
11
+ timeout: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
10
12
  'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
13
  json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
14
  locale: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
@@ -7,7 +7,9 @@ export default class TaskWait extends BaseCommand {
7
7
  ...BaseCommand.baseFlags,
8
8
  task: Flags.string({ description: '任务 ID,可重复指定以批量等待', multiple: true }),
9
9
  concurrency: Flags.integer({ description: '批量轮询并发数', default: 4, min: 1, max: 16 }),
10
- interval: Flags.integer({ default: 1000 }),
10
+ interval: Flags.integer({ description: '初始轮询间隔(毫秒)', default: 1_000, min: 1, max: 60_000 }),
11
+ 'max-interval': Flags.integer({ description: '无状态变化时的最大轮询间隔(毫秒)', default: 15_000, min: 1, max: 60_000 }),
12
+ timeout: Flags.integer({ description: '等待超时(秒)', default: 600, min: 1, max: 86_400 }),
11
13
  };
12
14
  async run() {
13
15
  const { args, flags } = await this.parse(TaskWait);
@@ -15,7 +17,11 @@ export default class TaskWait extends BaseCommand {
15
17
  if (!taskIds.length)
16
18
  throw new Error('请提供 taskId 或至少一个 --task');
17
19
  const { api } = await commandApi(flags);
18
- const tasks = await mapConcurrent(taskIds, flags.concurrency, async (taskId) => await api.waitTask(taskId, flags.interval));
20
+ const tasks = await mapConcurrent(taskIds, flags.concurrency, async (taskId) => await api.waitTask(taskId, {
21
+ interval: flags.interval,
22
+ maxInterval: flags['max-interval'],
23
+ timeoutMs: flags.timeout * 1_000,
24
+ }));
19
25
  this.print(tasks.length === 1 ? tasks[0] : { tasks });
20
26
  if (tasks.some((task) => task.status !== 'completed'))
21
27
  this.error('部分任务未成功完成', { exit: 8 });
@@ -37,6 +37,20 @@ export interface CanvasInspectOptions {
37
37
  resourceType?: string;
38
38
  producerNodeId?: string;
39
39
  }
40
+ export interface TaskListOptions {
41
+ projectId?: string;
42
+ targetType?: string;
43
+ targetId?: string;
44
+ statuses?: string[];
45
+ types?: string[];
46
+ limit?: number;
47
+ summary?: boolean;
48
+ }
49
+ export interface TaskWaitOptions {
50
+ interval?: number;
51
+ maxInterval?: number;
52
+ timeoutMs?: number;
53
+ }
40
54
  export interface NodeFieldUpdate {
41
55
  nodeId: string;
42
56
  set?: JsonObject;
@@ -132,8 +146,9 @@ export declare class VvicatApi {
132
146
  status: string;
133
147
  };
134
148
  }>;
149
+ listTasks(options?: TaskListOptions): Promise<JsonObject[]>;
135
150
  cancelTask(taskId: string): Promise<JsonObject>;
136
- waitTask(taskId: string, interval?: number): Promise<JsonObject & {
151
+ waitTask(taskId: string, options?: TaskWaitOptions | number): Promise<JsonObject & {
137
152
  status: string;
138
153
  }>;
139
154
  config(): Promise<JsonObject>;
@@ -336,16 +336,53 @@ export class VvicatApi {
336
336
  task(taskId) {
337
337
  return this.client.request(`/api/tasks/${taskId}`);
338
338
  }
339
+ async listTasks(options = {}) {
340
+ const query = new URLSearchParams();
341
+ if (options.projectId)
342
+ query.set('projectId', options.projectId);
343
+ if (options.targetType)
344
+ query.set('targetType', options.targetType);
345
+ if (options.targetId)
346
+ query.set('targetId', options.targetId);
347
+ for (const status of options.statuses ?? [])
348
+ query.append('status', status);
349
+ for (const type of options.types ?? [])
350
+ query.append('type', type);
351
+ if (options.limit !== undefined)
352
+ query.set('limit', String(options.limit));
353
+ if (options.summary)
354
+ query.set('summary', '1');
355
+ const serialized = query.toString();
356
+ const suffix = serialized ? `?${serialized}` : '';
357
+ const payload = await this.client.request(`/api/tasks${suffix}`);
358
+ return payload.tasks;
359
+ }
339
360
  // CLI 只读取、等待或取消任务;人工复核结果仍由网页端提交,避免自动化误选生产资产。
340
361
  cancelTask(taskId) {
341
362
  return this.client.request(`/api/tasks/${taskId}`, { method: 'DELETE' });
342
363
  }
343
- async waitTask(taskId, interval = 1_000) {
364
+ async waitTask(taskId, options = {}) {
365
+ const normalized = typeof options === 'number' ? { interval: options } : options;
366
+ const initialInterval = Math.max(1, Math.floor(normalized.interval ?? 1_000));
367
+ const maxInterval = Math.max(initialInterval, Math.floor(normalized.maxInterval ?? 15_000));
368
+ const timeoutMs = Math.max(0, Math.floor(normalized.timeoutMs ?? 0));
369
+ const deadline = timeoutMs > 0 ? Date.now() + timeoutMs : null;
370
+ let delay = initialInterval;
371
+ let signature = '';
344
372
  while (true) {
345
373
  const { task } = await this.task(taskId);
346
374
  if (['completed', 'failed', 'canceled', 'dismissed'].includes(task.status))
347
375
  return task;
348
- await this.sleep(interval);
376
+ const nextSignature = [task.status, task.progress, task.stage, task.flowStageIndex].join(':');
377
+ delay = nextSignature === signature
378
+ ? Math.min(maxInterval, Math.ceil(delay * 1.5))
379
+ : initialInterval;
380
+ signature = nextSignature;
381
+ if (deadline !== null && Date.now() >= deadline) {
382
+ throw new Error(`TASK_WAIT_TIMEOUT:${taskId}:${task.status}`);
383
+ }
384
+ const remaining = deadline === null ? delay : Math.min(delay, Math.max(0, deadline - Date.now()));
385
+ await this.sleep(remaining);
349
386
  }
350
387
  }
351
388
  config() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aswless_854771076/ai_short_studio_cli",
3
- "version": "0.1.108",
3
+ "version": "0.1.112",
4
4
  "description": "VVICAT 无限画布项目命令行工具",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -8,7 +8,8 @@
8
8
  2. 每个形象候选使用独立输入、独立三视图节点和独立图片资产;`count` 的多个结果也不能拼图。视觉素材未另行指定时使用 16:9,并按实时 schema 显式写入。
9
9
  3. 真/假、原版/复制、成年/童年等成对资源必须先生成基础版并确认,再把基础版 `image-resource` 作为 reference 生成派生版;prompt 只枚举允许差异,其余保持一致。
10
10
  4. 每个分镜拆解节点只连接一条目标集剧本,以及该集全部确认人物、场景和道具。素材缺失、未选版、映射歧义或连线不足时禁止执行。
11
- 5. 拆镜成功后刷新画布并复用自动创建的 shot/image/prompt 节点;按 `parentAssetId`、`producerNodeId` 和集号核对归属,不按任务提交顺序猜测。
11
+ 5. 结构化剧本的镜号、顺序和来源由服务端确定性编译,模型只补摄影、表演和画面。显式 `maxShotCount` 是硬预算;任务在模型调用前报 `STORYBOARD_SHOT_BUDGET_INFEASIBLE` 时必须放宽预算或缩短剧本,不得反复提交同一任务碰运气。
12
+ 6. 拆镜成功后刷新画布并复用自动创建的 shot/image/prompt 节点;按 `parentAssetId`、`producerNodeId` 和集号核对归属,不按任务提交顺序猜测。
12
13
 
13
14
  ## 拆镜语言匹配门禁
14
15
 
@@ -15,10 +15,11 @@ ai-short-studio canvas asset download <assetId> --project <projectId> --output <
15
15
  ## 执行和等待
16
16
 
17
17
  ```bash
18
- ai-short-studio canvas node run --project <projectId> --node <node1> --node <node2> --concurrency 4 --wait --json
18
+ ai-short-studio canvas node run --project <projectId> --node <node1> --node <node2> --concurrency 4 --json
19
+ ai-short-studio task list --project <projectId> --status running --json
19
20
  ai-short-studio task get <taskId> --json
20
- ai-short-studio task wait --task <task1> --task <task2> --concurrency 4 --json
21
+ ai-short-studio task wait --task <task1> --task <task2> --concurrency 4 --timeout 600 --max-interval 15000 --json
21
22
  ai-short-studio task cancel <taskId> --yes --json
22
23
  ```
23
24
 
24
- 互不依赖的节点在一个 CLI 进程内批量运行;有依赖时分批。任务成功后仍需回读资产并查看真实产物,不能把成功状态当作质量验收。
25
+ 互不依赖的节点在一个 CLI 进程内批量运行;有依赖时按滚动流水线分批。`task list` 默认返回精简状态,排查时才使用 `--full`。`task wait` 默认 600 秒超时,并对无变化状态指数退避;不要用整批等待替代滚动调度。任务成功后仍需回读资产并查看真实产物,不能把成功状态当作质量验收。
@@ -24,7 +24,7 @@ ai-short-studio canvas node edit-resource <nodeId> --project <projectId> --file
24
24
  ai-short-studio canvas node delete <nodeId> --project <projectId> --yes --json
25
25
  ```
26
26
 
27
- `update` 只改普通 config、标题和坐标;结构化 artifact 必须用 `edit-shot` / `edit-resource` 追加版本。身份字段不可修改,409 后重新读取当前选版。
27
+ `update` 只改普通 config、标题和坐标;结构化 artifact 必须用 `edit-shot` / `edit-resource` 追加版本。身份字段不可修改。两类编辑对同节点、同基线、同载荷重复提交或当前选版已满足目标时幂等;画布冲突刷新当前选版后重试一次,资产版本竞争保留原基线重试一次,其他 409 直接停止核对。
28
28
 
29
29
  `--asset-id` 仅用于 `image`、`video`、`audio` 媒体节点,把已有资产的 selected 版本绑定为节点输出;CLI 会先按实时节点目录拒绝非媒体节点,资产类型仍由服务端校验。上传资产后先用 `canvas asset list` 或上传响应取得资产 ID,再创建媒体节点并连线。
30
30
 
@@ -8,7 +8,7 @@
8
8
  - 滚动提交与任务恢复策略:[async-pipeline.md](async-pipeline.md)
9
9
  - 剪辑、字幕、声音和最终渲染:[editing-delivery.md](editing-delivery.md)
10
10
 
11
- 所有命令支持 `--base-url`、`--profile`、`--locale zh|en` 和 `--json`。`--locale` 只控制 CLI 消息,不控制剧本、拆镜、H3 人声或字幕语言。
11
+ 所有命令支持 `--base-url`、`--profile`、`--locale zh|en` 和 `--json`。`--locale` 只控制 CLI 消息,不控制剧本、拆镜、H3 人声或字幕语言。画布文本与短剧节点按项目 `outputLanguage` 选择提示词模板并追加强制语言合同;节点 `prompt` 只能作为附加指令,不得覆盖主 schema 或语言合同。短剧结构化节点校验 JSON 主合同,不得接受散文;数据库旧模板缺少 JSON 或关键 schema 字段时会记录漂移并回退仓库模板。模型返回空白文本按 `EMPTY_RESPONSE` 失败重试,不得接受空资产。
12
12
 
13
13
  ## 跨流程硬规则
14
14
 
@@ -15,7 +15,7 @@
15
15
 
16
16
  - 常规查询先用一次 `canvas inspect`,通过 `--include`、`--kind`、`--status`、`--search`、`--operation`、`--resource-type`、`--producer-node` 表达;现有命令不能表达时才写临时脚本。
17
17
  - 同阶段两个及以上图变更用一次 `canvas apply --canvas-id ... --expected-version ...`。只改 config/title/位置时,单节点用 `node update`,多节点用 `node update-many`。
18
- - 同批已就绪的独立节点用一次 `node run` 提交;跨阶段生成按 [滚动异步流水线](async-pipeline.md) 由单个调度器轮询并即时触发下游,不用一次 `task wait` 阻塞整批。不要 shell 并发多个相互竞争的 CLI 调度进程。
18
+ - 同批已就绪的独立节点用一次 `node run` 提交;跨阶段生成按 [滚动异步流水线](async-pipeline.md) 由单个调度器轮询并即时触发下游。项目状态用一次 `task list --project <id> --status running` 获取,不为每个节点单独查询。不要用一次 `task wait` 阻塞整批,也不要 shell 并发多个相互竞争的 CLI 调度进程。
19
19
  - 批量命令缺失或合法批量请求因粒度失败时,只回退尚未生效的单项。不得用单项调用绕过权限、schema、业务或付费门禁。
20
20
 
21
21
  ## 资产目录
@@ -32,7 +32,7 @@
32
32
 
33
33
  - `canvas node edit-shot` 只编辑镜头内容,不能改 `shotKey`、`shotIndex` 或来源身份。
34
34
  - `canvas node edit-resource` 只替换完整父文档中的目标实体,不能改名称、资源键、ID 或所属关系;兄弟资源保持原选版。
35
- - 两类编辑都基于当前 `selectedOutputVersionId` 追加版本并使下游 stale。409 后重读画布和选版,不覆盖历史。
35
+ - 两类编辑都基于当前 `selectedOutputVersionId` 追加版本并使下游 stale。同节点、同基线、同载荷重复提交或当前选版已满足目标时返回已有版本;画布冲突刷新当前选版后重试一次,资产版本竞争保留原基线重试一次,身份错误和其他 409 直接停止核对。
36
36
  - `canvas apply` 只处理节点、边、删除和视口,不代替 settings 或结构化 artifact 编辑。
37
37
 
38
38
  ## 安全边界