Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apps/api/src/opendirector_api/localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
'higgsfield_frames': 'Each frame slot accepts one image. A last frame requires a first frame.',
'higgsfield_references': 'Reference mode requires at least one image, video, or audio clip. Check the reference roles.',
'higgsfield_prompt': 'MAGI-2 prompts allow up to 15,000 characters. Text-to-video requires a prompt.',
'nextlabs_token': 'The NextLabs upload token is invalid.',
'opendev_magi_model': 'Choose OpenDev MAGI-2 with the official API address.',
'opendev_magi_key': 'Enter your OpenDev API key.',
'opendev_magi_prompt': 'Enter a MAGI-2 prompt of up to 15,000 characters.',
'opendev_magi_url': 'Enter a public HTTPS media URL readable without signing in.',
'opendev_magi_reference_count': 'MAGI-2 accepts up to 10 images (local images and links combined), 5 video links, and 5 audio links.',
'opendev_magi_local_reference': 'Configure a NextLabs upload token in the model service for local images. Use public links for video and audio references.',
'opendev_magi_reference_model': 'This video model does not support media links.',
"desktop_auth_required": "The desktop connection has expired. Reopen the application.",
'prompt_optimization_empty': 'Enter a prompt to optimize.',
'prompt_optimization_refs': 'Prompt references changed. Try again.',
Expand Down
7 changes: 5 additions & 2 deletions apps/api/src/opendirector_api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ def save_model_batch(value: ModelBatchInput):
video_capabilities=video_capabilities(value), input_modalities=value.inputModalities,
model_options=model_options(value),
capabilities_supplied='videoCapabilities' in value.model_fields_set, capability_auto_check=value.capabilityAutoCheck,
next_labs_token=value.nextLabsToken.get_secret_value() if value.nextLabsToken is not None else None,
storage=value.storage.model_dump() if value.storage is not None else None)

@app.post('/api/model-configs/discover')
Expand All @@ -304,7 +305,8 @@ def create_model_config(value: ModelConfigInput):
return catalog.save(value.kind, value.url, value.modelId, value.apiKey.get_secret_value(), connection_type=value.connectionType, protocol=value.protocol, auth_mode=value.authMode, proxy_mode=value.proxyMode,
video_adapter=value.videoAdapter, video_capabilities=video_capabilities(value),
capabilities_supplied='videoCapabilities' in value.model_fields_set, input_modalities=value.inputModalities,
capability_auto_check=value.capabilityAutoCheck)
capability_auto_check=value.capabilityAutoCheck,
next_labs_token=value.nextLabsToken.get_secret_value() if value.nextLabsToken is not None else None)

@app.post('/api/model-configs/capabilities')
async def model_capabilities(value: ModelCapabilityRequest):
Expand All @@ -319,7 +321,8 @@ def update_model_config(config_id: UUID, value: ModelConfigInput):
return catalog.save(value.kind, value.url, value.modelId, value.apiKey.get_secret_value(), str(config_id), connection_type=value.connectionType, protocol=value.protocol, auth_mode=value.authMode, proxy_mode=value.proxyMode,
video_adapter=value.videoAdapter, video_capabilities=video_capabilities(value),
capabilities_supplied='videoCapabilities' in value.model_fields_set, input_modalities=value.inputModalities,
capability_auto_check=value.capabilityAutoCheck)
capability_auto_check=value.capabilityAutoCheck,
next_labs_token=value.nextLabsToken.get_secret_value() if value.nextLabsToken is not None else None)

@app.delete("/api/model-configs/{config_id}", status_code=204)
def delete_model_config(config_id: UUID):
Expand Down
3 changes: 2 additions & 1 deletion apps/api/src/opendirector_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class UrlSource(Model):

class ModelConnection(Model):
connectionType: Literal['api', 'self_hosted'] = 'api'
protocol: Literal['openai', 'volcengine', 'higgsfield_open', 'bigmodel_video', 'kling_video', 'minimax_video_v2', 'vllm_omni', 'vllm_omni_segmentation', 'vllm_omni_music', 'vllm_omni_depth', 'vllm_omni_score', 'vllm_omni_bodies'] | None = None
protocol: Literal['openai', 'volcengine', 'higgsfield_open', 'opendev_magi', 'bigmodel_video', 'kling_video', 'minimax_video_v2', 'vllm_omni', 'vllm_omni_segmentation', 'vllm_omni_music', 'vllm_omni_depth', 'vllm_omni_score', 'vllm_omni_bodies'] | None = None
authMode: Literal['none', 'bearer'] | None = None
proxyMode: Literal['system', 'direct'] | None = None
capabilityAutoCheck: bool | None = Field(default=None, strict=True, exclude_if=lambda value: value is None)
Expand All @@ -45,6 +45,7 @@ class ModelConfigInput(ModelConnection):
url: str = Field(max_length=2048)
modelId: str = Field(max_length=200)
apiKey: SecretStr = SecretStr("")
nextLabsToken: SecretStr | None = Field(default=None, max_length=8192)
inputModalities: list[AgentInputModality] | None = Field(default=None, min_length=1, max_length=4)
videoAdapter: VideoAdapter | None = None
videoCapabilities: VideoCapabilities | None = None
Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ This directory is the entry point for the repository's shared documentation. The
| [Business CLI](guides/cli.md) | Querying, editing, and generating through a terminal or Agent Shell | Commands, authorization, or receipt semantics change |
| [DeepSeek Harness plugin](../plugins/deepseek-harness/README.md) | Installing the DSH bundle and editing an OpenDirector project from DSH | Plugin setup, tools, or creation workflows change |
| [Video model capabilities](guides/video-model-capabilities.md) ([中文](guides/video-model-capabilities.zh-CN.md)) | Declaring output specifications supported by a service | Configuration fields or capability integration changes |
| [OpenDev video services](guides/opendev-video.md) ([中文](guides/opendev-video.zh-CN.md)) | MAGI-2, Seedance and NextLabs local image uploads | Provider setup or reference upload changes |
| [Video gateway](guides/video-gateway.md) ([中文](guides/video-gateway.zh-CN.md)) | Serving several H3 LoRA variants from one vLLM-Omni server through the gateway started with the application | Gateway configuration keys, startup, or rewrite behavior change |
| [Model availability / 模型可用状态](guides/model-availability.md) | Optional runtime declarations, automatic checks, shared admission and API/CLI/Agent queries | Capability protocol, refresh, or acceptance rules change |
| [OpenAI Images](guides/openai-images.md) | Wiring gpt-image as an optional image service, request shape and failures | Integration fields, capability scope, or the OpenAI interface change |
Expand Down
7 changes: 7 additions & 0 deletions docs/development/lessons.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ When implementing or reviewing a change, trace the affected behavior from its en

When work exposes a consequential risk or a recurring problem, add a lesson or update an existing one with the trigger, failure, suggested check, and a verifiable issue, PR, or commit. Add evidence when a problem recurs. Move requirements proven durable in practice into the validation guide, and revise or remove outdated lessons. Do not count distinct defects as repetitions of the same problem, or add a lesson for every routine fix.

## Passing local tests does not register them in CI

- **Trigger / 触发:** Adding, renaming or deleting Python test modules when CI selects files through shard rules. / CI 通过分片规则选择文件时,新增、重命名或删除 Python 测试模块。
- **Evidence / 证据:** [PR #685 review](https://github.com/ThinkFlowLab/OpenDirector/pull/685#discussion_r4809603999) found that `test_nextlabs_upload.py` and `test_opendev_magi.py` passed locally but were absent from `scripts/ci/python_shards.json`. Focused execution and pytest collection did not prove that CI selected them. / 两个模块本地通过,但未登记进分片清单;定向测试通过或成功收集用例不能证明 CI 会执行它们。
- **Check / 检查:** After [PR #700](https://github.com/ThinkFlowLab/OpenDirector/pull/700), unlisted modules are discovered into default core. Maintain explicit agent-cli/media assignments and renamed or deleted listed paths according to dependencies and responsibility, preserving alphabetical ordering. Run the full module inventory assertion and inspect the selected shard using the [validation commands](validation.md#python-shard-registration). Each module must occur exactly once in the resolved inventory. Compare unrelated failures against the target base and link their tracking issue; do not weaken the assertion or report a failing inventory as passed. / PR #700 后未列出的模块自动归入默认 core;按依赖和职责维护 agent-cli/media 的显式登记及已登记路径的重命名或删除,保持字母排序;运行完整模块清单断言并检查分片选择结果,确保每个模块恰好登记一次。无关失败需对照目标基线并链接跟踪记录,不能放宽断言或把失败报告为通过。

## Parameter IDs can encode the environment rather than the scenario

- **Trigger:** Comparing collected test IDs or per-test timing evidence across platforms or dependency versions.
Expand Down Expand Up @@ -35,6 +41,7 @@ When work exposes a consequential risk or a recurring problem, add a lesson or u
- **Preview follow-up:** [PR #465](https://github.com/ThinkFlowLab/OpenDirector/pull/465) initially opened the project for a prompt rewrite, which could contend with the browser's edit lease. A rewrite reads the saved snapshot and has no durable job to recover. Verify it can finish under a separate session and that a browser disconnect closes the server-side request.
- **Async projection follow-up:** PR #193's structured-editor CI failure prompted a real-browser delayed-read regression. An older background projection could finish after an acknowledged editor save and restore an obsolete CAS basis, making the next save/publication fail. Recheck the editor transaction and captured snapshot at completion before installing either changed or apparently identical content. Keep publication versions fixed, test the actual save/retry/provenance path with a deterministic interleaving, and retain the original CI failure rather than treating a longer timeout or a rerun as its explanation.
- **Publication lock follow-up:** [#562](https://github.com/ThinkFlowLab/OpenDirector/pull/562) exposed task polling failing during publication. [#539](https://github.com/ThinkFlowLab/OpenDirector/actions/runs/46222060697/job/141218914874) exposed the same contention in upload staging before a timeline save. While a same-project publication is paused after journaling, exercise task reads and upload staging through HTTP. Staging uses its own handle lock and still validates the edit lease. Asset registration and timeline saves continue to use the project write rules. / **发布锁补充:** 在同一工程写入日志后暂停发布,经 HTTP 检查工具任务读取与素材暂存。暂存使用独立的句柄锁并验证编辑租约,素材登记和时间线保存仍走工程写入规则。
- **Generation recovery follow-up:** [PR #685](https://github.com/ThinkFlowLab/OpenDirector/pull/685) exposed a read-only directory lookup in accepted-job recovery taking the writable catalog path while another job published. Pause an actual publication after journaling and recover an already accepted job; require the directory read to use the published manifest and the resumed job to produce exactly one result. Keep write-side locking and version checks intact. / **生成恢复补充:** 已接受任务恢复时的只读目录查询曾误走可写目录路径,与其他任务发布争锁。暂停已写入日志的真实发布,再恢复已接受任务;检查其读取已发布清单并且只生成一次结果,同时保留写入锁及版本校验。
- **Media representation follow-up:** [Issue #282](https://github.com/ThinkFlowLab/OpenDirector/issues/282) exposed copy/export paths that read displayed pixels and archive imports that displayed unsupported original bytes. A browser preview and an original asset need distinct read paths while retaining the same asset identity. Verify original bytes through download, fresh publication, cross-project paste fallback and archive round trips, including the first display after import. [PR #287 review](https://github.com/ThinkFlowLab/OpenDirector/pull/287#pullrequestreview-5857373679) also exposed missing MIME-extension mappings and a fallback that could name preview PNG bytes as HEIC. Carry the expected original type into readers, reject a missing original, and check timeline/FCPXML packages as well as canvas archives.

- **Upload acknowledgement follow-up:** Investigating [PR #287's camera sample](https://github.com/ThinkFlowLab/OpenDirector/pull/287#pullrequestreview-5868923062) reproduced a failed preview being swallowed into a successfully saved empty generation item. Require a usable preview before completing a HEIF import, and assert the failure leaves the original registered without creating an empty item. Slow uploads also crossed the first save acknowledgement: default expansion and model display labels were mistaken for user edits. Compare effective settings while retaining actual content, model, frame-selection and lock conflicts; exercise upload into a newly created node and its reference composer before the first save finishes.
Expand Down
25 changes: 25 additions & 0 deletions docs/development/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,23 @@ Local checks verify workflow syntax, trigger/permission boundaries and rejection

## Python 分层与迁移 / Python layers and transition

<a id="python-shard-registration"></a>

### Python 分片登记 / Python shard registration

新增、重命名或删除 `tests/test_*.py` 时,检查 [`scripts/ci/python_shards.json`](../../scripts/ci/python_shards.json) 解析后的分片归属。未显式列出的模块自动归入默认 `core` 分片;需要 `agent-cli` 或 `media` 的模块应按依赖和职责显式登记。更新已登记模块的重命名或删除,并保持文件路径按字母排序。在已安装测试依赖的环境中,从仓库根目录运行以下检查;`core` 应替换为实际受影响的分片。

When adding, renaming or deleting `tests/test_*.py`, check the resolved assignments from [`scripts/ci/python_shards.json`](../../scripts/ci/python_shards.json). Unlisted modules are discovered into the default `core` shard. Explicitly list modules requiring `agent-cli` or `media` according to dependencies and responsibility; update listed paths when renaming or deleting them and keep paths alphabetically ordered. Run these checks from the repository root with test dependencies installed; replace `core` with the affected shard.

```sh
python -m pytest tests/test_ci_layers.py::test_repo_python_shards_manifest_covers_every_test_module_once -q --tb=short
python scripts/ci/check_test_layers.py --list-shard core
```

第一条检查解析后的清单是否恰好包含每个模块一次;第二条显示 CI 分片实际选择的文件,需确认目标模块出现在预期分片。继续执行受影响的测试;清单检查通过不代表测试通过,本地测试通过也不代表已登记进 CI。如果完整清单检查失败,对照目标基线区分本次遗漏与已有缺口,修复本次遗漏并为其他缺口附上跟踪记录,保留失败结论。

The first command checks that the resolved inventory contains every module exactly once; the second shows the files selected for a CI shard, which must include the intended modules. Also execute the affected tests: inventory success does not prove test success, and local test success does not prove CI registration. If the inventory fails, compare with the target base, fix omissions introduced by the change, link tracking records for other gaps, and retain the failed result.

### 耗时证据 / Timing evidence

Python CI 为全量套件和独立 bundled OpenCode 回归分别保存 JUnit XML、`--durations=50` 日志,以及 `--ci-profile` 生成的 JSON/Markdown;从运行的 `python-test-evidence-<attempt>` artifact 下载,保存 14 天。JSON 记录 SHA、系统、Python/pytest 版本、筛选条件、逐用例 setup/call/teardown 耗时、结果、显式层级与未标记默认归属,不记录 stdout、失败正文或局部变量。
Expand Down Expand Up @@ -734,3 +751,11 @@ Timing JSON includes per-case hardware and aggregate hardware counts.
Ark duration normalization is shared by capability admission and the submitted JSON through `normalize_ark_parameters`. Verify actual serialized POST values against admission for integral floats, integers, fractional values, booleans, strings and omitted duration in `tests/test_ark_availability.py`; do not round fractional durations or mutate saved intent.

Ark 能力检查和发送 JSON 共用 `normalize_ark_parameters` 归一化时长。在 `tests/test_ark_availability.py` 中比对实际 POST 序列化参数与检查参数,覆盖整数浮点数、整数、小数、布尔值、字符串及省略时长;不对小数时长取整,不修改原始生成意图。

### OpenDev MAGI-2 local image uploads

Run `python -m pytest tests/test_opendev_magi.py tests/test_nextlabs_upload.py tests/test_model_configs.py -q`. These checks use actual image bytes, persisted commands and mocked provider HTTP, not paid generation. They cover token secrecy, local and linked image limits, upload destination/header validation, completion validation, one submission, adoption and reopening.

For both interface languages, run `python tests/browser/nextlabs_server.py --port 8507`, Vite with `OPENDIRECTOR_API_URL=http://127.0.0.1:8507 npm run dev -- --port 5507`, and `node tests/browser/nextlabs_upload.mjs`. The isolated fixture checks service configuration, file-picker import, followed image references, generation, retained input snapshots and reopening. Screenshots and receipts go to `output/playwright/nextlabs`. No real upload credential or paid model call is used.

上述 Python 测试使用真实图片字节、持久化命令和模拟服务 HTTP,验证令牌保密、混合图片数量限制、上传地址及请求头检查、上传确认、单次提交、结果采用和重开。浏览器夹具在隔离工程中验证中英文服务配置、文件选择器导入、跟随图片参考、生成和重开后的输入快照,截图与回执保存在 `output/playwright/nextlabs`。这些检查不使用真实上传凭据,也不调用付费生成服务。
Loading