diff --git a/docs/README.md b/docs/README.md index cc14c4725..df87fa0d9 100644 --- a/docs/README.md +++ b/docs/README.md @@ -24,7 +24,7 @@ This directory is the entry point for the repository's shared documentation. The | [Python installation and packaging](development/packaging.md) | Installation, platform wheel builds, and isolated verification | Packaging, resource paths, or build process changes | | [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) | Declaring output specifications supported by a service | Configuration fields or capability integration changes | +| [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 | | [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 | | [Kling video](guides/kling-video.md) ([中文](guides/kling-video.zh-CN.md)) | Optional Kling 4.0 and Flash setup, model-specific inputs, and recovery limits | Kling inputs, model declarations, or recovery behavior change | | [BigModel video](guides/bigmodel-video.md) ([中文](guides/bigmodel-video.zh-CN.md)) | CogVideoX-3 text, single-image and first/last-frame generation, task recovery and adoption | BigModel protocol, inputs, output sizes or recovery behavior change | diff --git a/docs/architecture/agent-runtime.md b/docs/architecture/agent-runtime.md index 3f86072af..32d2cd924 100644 --- a/docs/architecture/agent-runtime.md +++ b/docs/architecture/agent-runtime.md @@ -69,4 +69,8 @@ Default 的模型网关在 `agent-runs/.model.jsonl` 记录实际转发 工具允许列表与操作系统沙箱提供不同约束。业务工具独立校验工程范围和输入;原生文件访问权限不授予直接改写工程存储的业务权限。 +Windows 上的 Codex 启动显式设置 `windows.sandbox="elevated"`,避免隔离启动忽略用户配置后,`workspace-write` 降为只读并拦截 Shell。保留沙箱约束,不绕过审批或沙箱。PowerShell 使用 `Get-Command opendirector` 发现 CLI,POSIX Shell 使用 `command -v opendirector`。 + +On Windows, Codex explicitly sets `windows.sandbox="elevated"` so ignoring user configuration does not downgrade `workspace-write` to read-only and block Shell execution. Sandbox restrictions remain enabled. Discover the CLI with `Get-Command opendirector` in PowerShell or `command -v opendirector` in POSIX shells. + CLI 通过环境变量中的本轮本地 Socket 地址连接业务网关,不使用连接令牌或凭据文件。网关继续校验工程范围、轮次生命周期及业务输入。 diff --git a/docs/guides/user-guide.md b/docs/guides/user-guide.md index a5847eb70..11597b2f2 100644 --- a/docs/guides/user-guide.md +++ b/docs/guides/user-guide.md @@ -39,7 +39,7 @@ example vLLM's 4096 default) rejects every request with HTTP 400. For vLLM-Omni video connections, enter fractional seconds directly, for example `6.583333`. The CLI accepts `opendirector video create --duration 6.583333` together with the other required options. Read `opendirector video create --help` and `opendirector model list` first; `inputRules.fractionalDuration` identifies support, and each output's duration list defines the allowed range. H3 can align output to its supported frame count, so inspect the actual result duration before assembling segments. -For detailed video settings, see [Video model capability configuration (Chinese)](video-model-capabilities.md). When no explicit output specification is provided, use **Auto** or **Service default duration**. +For detailed video settings, see [Video model capability configuration](video-model-capabilities.md). When no explicit output specification is provided, use **Auto** or **Service default duration**. Automatic region selection in images and video matting require a model with segmentation capabilities. Image generation and editing still require the corresponding generation or editing model. diff --git a/docs/guides/user-guide.zh-CN.md b/docs/guides/user-guide.zh-CN.md index 2f795b38a..a5fd095e2 100644 --- a/docs/guides/user-guide.zh-CN.md +++ b/docs/guides/user-guide.zh-CN.md @@ -37,7 +37,7 @@ Kimi 对话助手有两种计费方式,各自使用独立的 Key 和服务地 若服务端的 `--max-model-len` 更小(例如 vLLM 的 4096 默认值),每次请求都会返回 HTTP 400。 -视频模型的详细配置见 [视频模型能力配置](video-model-capabilities.md)。未提供明确输出规格时,使用“自动”或“服务默认时长”。 +视频模型的详细配置见 [视频模型能力配置](video-model-capabilities.zh-CN.md)。未提供明确输出规格时,使用“自动”或“服务默认时长”。 自动识别图片选区或视频抠像需要具备分割能力的模型;生成图片、编辑图片仍需选择对应的生成或编辑模型。 diff --git a/docs/guides/video-model-capabilities.md b/docs/guides/video-model-capabilities.md index a581ae04f..fac4eff75 100644 --- a/docs/guides/video-model-capabilities.md +++ b/docs/guides/video-model-capabilities.md @@ -1,28 +1,30 @@ -# 视频模型能力配置 +# Video model capability configuration -模型接入信息与输出能力分别保存于本机后端。能力是声明数据,不包含脚本,也不会修改模型权重、推理步数或服务器显存。当前实现独立于其他产品的代码。 +Model connection details and output capabilities are stored separately in the local backend. Capabilities are declarative data: they contain no scripts and do not modify model weights, sampling steps or server memory. This implementation is independent of other products' code. -## 界面操作 +Generation history shows the requested video duration and the measured result duration separately. A 4-second FastH3 request that preserves the last anchor may produce 107 frames at 24 fps, displayed as a 4.458-second result. -1. 打开“模型接入”,添加或编辑视频模型,填写地址、Model ID 和鉴权信息。 -2. 点击默认折叠的“视频适配方式”展开高级配置。对 `/videos` 接口选择适配方式。FastH3 使用八步和多素材参考,每次生成使用新的随机种子并随任务保存,恢复任务时沿用;原生 H3 支持首帧、素材参考及接续;通用适配仅发送文本和单张首帧,不携带 H3 专属的采样参数。模型使用自定义名称时,应明确选择适配方式。 -3. 已知模型可点击“载入适配预设”。未声明能力的模型只显示“自动”和“服务默认时长”。 -4. 开启“自定义输出规格”,每档填写分辨率、支持时长和可选横屏像素宽高。时长支持 `4-10,15`,即 4 至 10 秒以及 15 秒。不同档位可填写不同的时长集合。 -5. 设置默认分辨率、默认时长和像素对齐步长,保存。是否需要填写像素尺寸取决于提交参数:发送明确宽高的适配需要配置尺寸;发送分辨率档位、由服务端确定宽高的适配可以留空。已知 H3 档位也可使用适配器内置的尺寸。H3 使用 32 像素对齐,现有适配仍限定 4–15 秒。 +## Interface -切换模型后使用新模型的默认分辨率;兼容的已选时长保留,否则采用新模型的默认时长。改变时长后,界面仅显示该时长支持的分辨率;不适用的原选项回到默认值或自动。后端在接受任务前再次校验,不会将不支持的组合悄悄改成其他时长。 +1. Open "Model connections", add or edit a video model, and fill in the base URL, Model ID and authentication. +2. Expand the collapsed "Video adapter" section for advanced settings. Choose the adapter for the `/videos` API. FastH3 uses eight steps and multi-asset references; each generation draws a new seed, keeps it with the job and reuses it when the job is recovered. FastH3 first/last frames (`fasth3_dual`) offers two generation modes on one model: its reference mode matches FastH3, while first/last-frame mode takes at most one first-frame and one last-frame anchor image, submits `fl2va` with `res_multistep` at 20 steps, and lands on the native 17n+5 frame grid, keeping the tail anchor at the grid's last frame instead of trimming to the requested duration. First/last-frame mode requires both anchors, rejects video and audio references, and is not combined with multi-asset references. Native H3 supports a first frame, asset references and continuation. The generic adapter sends only text and a single first frame, without H3 sampling parameters. When a model uses a custom name, choose the adapter explicitly. +3. Known models offer "Load adapter preset". Models without a declared capability show only "Auto" and "Service default duration". +4. Enable "Custom output specs" and fill in the resolution, supported durations and optional landscape pixel width and height for each tier. Durations accept `4-10,15`, meaning 4 to 10 seconds plus 15 seconds; tiers may declare different duration sets. +5. Set the default resolution, default duration and pixel alignment step, then save. Whether pixel sizes are required depends on the submitted parameters: adapters that send an explicit width and height need sizes, while adapters that send a resolution tier and let the service decide may leave them empty. Known H3 tiers may also use the adapter's built-in sizes. H3 aligns to 32 pixels and existing adapters stay within 4–15 seconds. -参考素材决定画幅,显式分辨率决定输出尺寸;接续保留上一段的尺寸,仅使用自动。已有供应商的模式限制继续生效,例如 Seedance 图片参考模式的分辨率限制。自定义能力不能改变上传协议、开放未实现的参考模式,或突破原生适配的限制。 +Switching models applies the new model's default resolution; a compatible selected duration is kept, otherwise the new default applies. After a duration change, the interface lists only resolutions that support it and resets inapplicable choices to default or auto. The backend validates again before accepting a job and never silently changes an unsupported combination into another duration. -关闭“自定义输出规格”并保存可恢复适配预设。编辑时密钥留空会保留已保存的密钥,能力信息中不包含密钥。已有配置读取时保留此前适配方式,不会因为模型别名而自动切换请求格式;新增未知模型则采用通用方式。 +Reference material decides the frame; an explicit resolution decides the output size; continuation keeps the previous clip's size and uses only auto. Existing provider mode restrictions still apply, such as the resolution limits of Seedance image-reference mode. Custom capabilities cannot change the upload protocol, enable unimplemented reference modes, or exceed a native adapter's limits. -## 读取服务声明 +Disabling "Custom output specs" and saving restores the adapter presets. Leaving the key empty while editing keeps the saved key; capability information never contains keys. Existing configurations keep their previous adapter and do not switch request formats because of a model alias; a new unknown model uses the generic adapter. -“读取服务声明”只请求配置服务的 `GET /models`(基础地址通常已含 `/v1`),不创建生成任务,不保存配置。用户确认并保存后才应用。它要求模型列表中对应 **精确 Model ID** 的条目包含 `videoCapabilities`。 +## Reading a service declaration -这是 OpenDirector 的可选扩展约定,并非 OpenAI 或 vLLM 标准保证的字段。普通 `/models` 列表只有模型名称时,不会据此推断分辨率或时长,仍需手动填写。无需为了使用本功能修改推理服务器;也可完全使用本机配置。 +"Read service declaration" only requests `GET /models` from the configured service (the base URL usually already ends with `/v1`); it creates no generation job and saves nothing. It applies only after the user confirms and saves. It requires the entry with the exact Model ID to include `videoCapabilities`. -声明示例(仅演示格式,需替换成服务真实支持的参数): +This is an optional OpenDirector extension, not a field guaranteed by OpenAI or vLLM. When the `/models` list only has model names, no resolution or duration is inferred and manual entry is still required. No inference server change is needed to use this feature, and local configuration alone is also fine. + +Declaration example (format only; replace it with the parameters the service really supports): ```json { @@ -43,38 +45,38 @@ } ``` -每份声明最多 20 档;时长为 1–60 秒内的整数,具体可用范围取决于适配和服务。宽高须同时填写或留空;横屏宽不小于高,边长 64–8192,且满足对齐步长。默认分辨率和时长必须构成有效组合,分辨率名称不能重复。 +Each declaration allows at most 20 tiers; durations are integers from 1 to 60, and the usable range depends on the adapter and the service. Width and height are filled together or left empty; landscape width is not smaller than height, edges are 64–8192, and the values match the alignment step. The default resolution and duration must form a valid combination, and resolution names must not repeat. -读取失败、字段无效或服务未提供声明时保留原配置。已保存的密钥只会在基础地址完全一致时复用;读取新地址需要重新输入密钥。 +A failed read, invalid fields or a missing declaration keeps the current configuration. A saved key is reused only when the base URL is identical; reading a new address requires the key again. -## 扩展边界 +## Extension boundary -已有适配协议下接入新模型、修改输出档位,只需配置。全新服务若使用不同的上传、提交、轮询或结果下载协议,仍需开发独立适配器。界面声明不会保证远端模型、账户权限或硬件能完成所配置的请求。 +Adding a model under an existing adapter protocol, or changing output tiers, only needs configuration. A brand-new service that uses different upload, submit, poll or result-download protocols still needs its own adapter. Interface declarations do not guarantee that the remote model, account permissions or hardware can complete the configured request. -## MiniMax 官方视频 V2 +## MiniMax official video V2 -添加视频服务时选择“MiniMax 官方视频 V2”,基础地址填写 `https://api.minimax.cn/v2`,使用 Bearer API Key。模型列表来自内置声明,载入列表不验证密钥或账户权限。连接继续由 `providerId` 管理,工程引用模型配置自身的 `id`;同名自部署模型使用独立连接与 `vllm_omni` 协议。 +When adding a video service, choose "MiniMax official video V2", enter `https://api.minimax.cn/v2` as the base URL and use a Bearer API key. The model list comes from built-in declarations; loading the list does not verify the key or account permissions. The connection is still managed by `providerId`, while the project references the model configuration's own `id`; a self-hosted model with the same name uses a separate connection and the `vllm_omni` protocol. -该适配接入 `MiniMax-H3`、`MiniMax-H3-Highspeed`、`MiniMax-H3-Lite` 和 `MiniMax-H3-Max`,按各型号限制输出档位与整数时长。首尾帧模式支持明确选择首帧、尾帧或两者;不选择帧时按文本生成。参考模式支持图片、视频和音频,包括单独音频参考。首尾帧不能与多模态参考混用。首尾帧输出比例由服务按输入决定;文本生成的自动比例解析为 `16:9`。不接受自定义像素尺寸或缓存续接。 +This adapter serves `MiniMax-H3`, `MiniMax-H3-Highspeed`, `MiniMax-H3-Lite` and `MiniMax-H3-Max`, limiting output tiers and integer durations per model. First/last-frame mode lets you choose a first frame, a last frame or both; with no frame selected it generates from text. Reference mode supports images, video and audio, including a standalone audio reference. First/last frames cannot be mixed with multimodal references. The first/last-frame output ratio is decided by the service from the inputs; text-generation auto resolves to `16:9`. Custom pixel sizes and cached continuation are not accepted. -本地素材按实际字节编码为 Base64,不上传到额外托管服务,也不自动压缩。支持 PNG、JPEG、WEBP 图片,MP4、MOV 视频和 WAV、MP3 音频;尺寸、数量、单文件大小、时长、视频帧率与编码在提交前检查。编码后的请求不得超过官方请求预算,超限明确拒绝。URL 与 `mm_file://` 输入、HEIC/HEIF 和回调通知不属于此适配范围。 +Local assets are encoded as Base64 from their actual bytes, are not uploaded to any extra hosting service, and are not compressed automatically. PNG, JPEG and WEBP images, MP4 and MOV video, and WAV and MP3 audio are supported; dimensions, counts, per-file size, duration, frame rate and codec are checked before submission. The encoded request must stay within the official request budget, and an over-budget request is rejected explicitly. URL and `mm_file://` inputs, HEIC/HEIF and callback notifications are outside this adapter's scope. -任务接受后固定模型、参数、素材和参考用途。已知远端任务恢复时继续查询原任务;提交结果未知时不自动重发。结果下载为本地素材并进入既有候选与采用流程,CDN 下载不携带 API Key。停止本地执行不代表远端取消成功;本适配未接入远端取消,任务可能继续执行并计费。 +An accepted job freezes its model, parameters, media and reference purposes. For a known remote task, recovery keeps querying the original task; an unknown submission is not resent automatically. Results download as local assets and enter the existing candidate and adoption flow; CDN downloads do not carry the API key. Stopping local execution does not mean the remote task was cancelled — this adapter does not implement remote cancellation, so the task may keep running and billing. -协议依据:[创建任务](https://platform.minimax.cn/docs/api-reference/video-generation-v2-create)、[查询任务](https://platform.minimax.cn/docs/api-reference/video-generation-v2-query)。真实服务调用和生成质量需要使用已配置账户单独验证。 +Protocol references: [create task](https://platform.minimax.cn/docs/api-reference/video-generation-v2-create), [query task](https://platform.minimax.cn/docs/api-reference/video-generation-v2-query). Real service calls and generation quality need to be verified separately with a configured account. -## 提供商与逐模型设置 +## Providers and per-model settings -可灵 4.0 使用独立的 `kling_video` 协议,按文生、首尾帧和图片参考选择对应官方提交路径,共用现有任务查询、恢复和结果采用流程。固定能力由后端发布。`kling-4.0` 支持 720P / 1080P、3–30 秒及首尾帧;`kling-4.0-flash` 支持 720P、3–20 秒和首帧,不支持尾帧。两个型号均支持图片参考与原生音频,不填写自定义像素尺寸。接入与输入限制见[中文指南](kling-video.zh-CN.md)和[English guide](kling-video.md)。 +Kling 4.0 uses the separate `kling_video` protocol and picks the official submit path for text, first/last frames and image references, sharing the existing task query, recovery and result-adoption flow. Its fixed capabilities are published by the backend. `kling-4.0` supports 720P / 1080P, 3–30 seconds and first/last frames; `kling-4.0-flash` supports 720P, 3–20 seconds and a first frame, without a last frame. Both models support image references and native audio, and do not accept custom pixel sizes. Setup and input limits are in the [English guide](kling-video.md) and the [Chinese guide](kling-video.zh-CN.md). -MiniMax 官方视频提供四个型号,新增服务时默认全部勾选,保存后才启用;编辑已有服务时保留原有勾选。标准 H3 支持 768P / 2K、4—15 秒;Highspeed 和 Lite 支持 480P / 768P、4—15 秒;Max 支持 480P / 768P、5—15 秒。各型号的输出档位与时长由后端分别校验。 +MiniMax official video offers four models; adding a service selects all of them by default, and they become active after saving. Editing an existing service keeps the previous selection. Standard H3 supports 768P / 2K and 4–15 seconds; Highspeed and Lite support 480P / 768P and 4–15 seconds; Max supports 480P / 768P and 5–15 seconds. Output tiers and durations are validated per model by the backend. -添加服务时先选择提供商。提供商列表分为“自定义 API”和“vLLM-Omni 兼容”两组,各组只列出自身支持的接入类型。视频页列出 MiniMax 官方视频、可灵官方视频、火山方舟 / Agent Plan,以及 “vLLM-Omni 兼容”分组;“vLLM-Omni 兼容”分组内细分视频接口、分割接口和深度接口。选中后确定协议与接入方式,表单不再提供全局协议列表进行二次分类。高级连接设置用于填写地址等连接参数;自部署地址由用户填写。MiniMax 对话预设使用 [官方 OpenAI 兼容地址](https://platform.minimax.cn/docs/api-reference/text-openai-api),视频预设使用视频 V2 协议。 +When adding a service, choose a provider first. The provider list is split into "Custom API" and "vLLM-Omni compatible", and each group lists only the connection types it supports. The video page lists MiniMax official video, Kling official video, Volcengine Ark / Agent Plan, and the "vLLM-Omni compatible" group, which contains video, segmentation and depth APIs. Selecting an entry fixes the protocol and connection type, so the form no longer offers a global protocol list for a second classification. Advanced connection settings hold parameters such as the address; self-hosted addresses are entered by the user. The MiniMax chat preset uses the [official OpenAI-compatible endpoint](https://platform.minimax.cn/docs/api-reference/text-openai-api), and the video preset uses the video V2 protocol. -同类别、同地址与协议下存在已保存连接时,可以明确选择复用,以保留密钥和模型身份;不复用则新建独立连接。手动添加和获取列表可以交替使用,获取结果仍需勾选,已有选择不会因列表刷新消失。 +When a saved connection already exists for the same category, address and protocol, you may explicitly reuse it to keep the key and model identity; otherwise a separate connection is created. Manual entries and fetched lists can be mixed, fetched results still need to be selected, and existing selections survive a list refresh. -图片页的 “vLLM-Omni 兼容”分组包含图片接口和分割接口;音频页包含语音合成、音乐生成和扒谱接口。各项直接确定对应协议,不再显示全局协议选择。对话、图片、音频页的“OpenAI 兼容”统一位于“自定义 API”分组首项,合并官方 OpenAI 与兼容服务接入;默认填写官方地址,地址与鉴权可编辑。 +The image page's "vLLM-Omni compatible" group holds image and segmentation APIs; the audio page holds speech synthesis, music generation and transcription APIs. Each entry fixes its protocol, so no global protocol choice is shown. "OpenAI compatible" on the chat, image and audio pages sits first in the "Custom API" group and merges official OpenAI with compatible services; it defaults to the official address, and both address and authentication are editable. -已选模型各自显示能力卡片。对话模型独立声明图片理解;视频模型独立配置适配方式和输出规格,官方 H3 与可灵展示后端发布的固定能力。编辑一个模型不会批量覆盖其他模型的能力。保存只保存配置,不执行推理测试,也不自动切换当前创作模型;对话模型可单独执行连通性测试。 +Each selected model shows its own capability card. Chat models declare image understanding independently; video models configure the adapter and output specs per model, while official H3 and Kling show fixed backend capabilities. Editing one model never overwrites the capabilities of another. Saving stores configuration only: it runs no inference test and does not switch the current creation model; chat models can run a connectivity test separately. -首尾帧引用使用图片素材与 `role=first_frame` / `last_frame`,不填写 `subjectRole`。`subjectRole` 表示主体素材槽位,不表示视频首帧。明确指定的首尾帧若会被引用策略过滤,提交会返回 `reference_invalid`,不接受任务或退化为文生视频;未配置首尾帧的文生视频仍然允许。 +First/last-frame references use image assets with `role=first_frame` / `last_frame` and do not fill `subjectRole`, which marks a subject-media slot rather than a video's first frame. If an explicitly assigned frame would be filtered by the reference policy, submission returns `reference_invalid` and neither accepts the task nor degrades it to text-to-video; text-to-video without frames is still allowed. `fasth3_dual`'s first/last-frame mode requires both anchors: a missing anchor, or an attached audio or video reference, is rejected without creating a job. diff --git a/docs/guides/video-model-capabilities.zh-CN.md b/docs/guides/video-model-capabilities.zh-CN.md new file mode 100644 index 000000000..fa2f62a34 --- /dev/null +++ b/docs/guides/video-model-capabilities.zh-CN.md @@ -0,0 +1,82 @@ +# 视频模型能力配置 + +模型接入信息与输出能力分别保存于本机后端。能力是声明数据,不包含脚本,也不会修改模型权重、推理步数或服务器显存。当前实现独立于其他产品的代码。 + +生成历史会分别显示请求时长和成片实测时长。例如,FastH3 请求 4 秒时,为保留尾帧锚点可能生成 24 fps 的 107 帧,成片时长显示为 4.458 秒。 + +## 界面操作 + +1. 打开“模型接入”,添加或编辑视频模型,填写地址、Model ID 和鉴权信息。 +2. 点击默认折叠的“视频适配方式”展开高级配置。对 `/videos` 接口选择适配方式。FastH3 使用八步和多素材参考,每次生成使用新的随机种子并随任务保存,恢复任务时沿用;FastH3 首尾帧(`fasth3_dual`)在同一模型上提供两种生成方式:参考模式与 FastH3 相同,首尾帧模式最多使用首帧、尾帧两张锚点图片,按 `fl2va`、`res_multistep` 采样、20 步提交,帧数落在 17n+5 网格上,尾帧锚点保留原生网格最后一帧、不按所选时长裁剪;首尾帧模式必须同时提供首帧和尾帧,不接受视频或音频参考,也不与多素材参考同时使用。原生 H3 支持首帧、素材参考及接续;通用适配仅发送文本和单张首帧,不携带 H3 专属的采样参数。模型使用自定义名称时,应明确选择适配方式。 +3. 已知模型可点击“载入适配预设”。未声明能力的模型只显示“自动”和“服务默认时长”。 +4. 开启“自定义输出规格”,每档填写分辨率、支持时长和可选横屏像素宽高。时长支持 `4-10,15`,即 4 至 10 秒以及 15 秒。不同档位可填写不同的时长集合。 +5. 设置默认分辨率、默认时长和像素对齐步长,保存。是否需要填写像素尺寸取决于提交参数:发送明确宽高的适配需要配置尺寸;发送分辨率档位、由服务端确定宽高的适配可以留空。已知 H3 档位也可使用适配器内置的尺寸。H3 使用 32 像素对齐,现有适配仍限定 4–15 秒。 + +切换模型后使用新模型的默认分辨率;兼容的已选时长保留,否则采用新模型的默认时长。改变时长后,界面仅显示该时长支持的分辨率;不适用的原选项回到默认值或自动。后端在接受任务前再次校验,不会将不支持的组合悄悄改成其他时长。 + +参考素材决定画幅,显式分辨率决定输出尺寸;接续保留上一段的尺寸,仅使用自动。已有供应商的模式限制继续生效,例如 Seedance 图片参考模式的分辨率限制。自定义能力不能改变上传协议、开放未实现的参考模式,或突破原生适配的限制。 + +关闭“自定义输出规格”并保存可恢复适配预设。编辑时密钥留空会保留已保存的密钥,能力信息中不包含密钥。已有配置读取时保留此前适配方式,不会因为模型别名而自动切换请求格式;新增未知模型则采用通用方式。 + +## 读取服务声明 + +“读取服务声明”只请求配置服务的 `GET /models`(基础地址通常已含 `/v1`),不创建生成任务,不保存配置。用户确认并保存后才应用。它要求模型列表中对应 **精确 Model ID** 的条目包含 `videoCapabilities`。 + +这是 OpenDirector 的可选扩展约定,并非 OpenAI 或 vLLM 标准保证的字段。普通 `/models` 列表只有模型名称时,不会据此推断分辨率或时长,仍需手动填写。无需为了使用本功能修改推理服务器;也可完全使用本机配置。 + +声明示例(仅演示格式,需替换成服务真实支持的参数): + +```json +{ + "data": [ + { + "id": "custom-video", + "videoCapabilities": { + "outputs": [ + { "resolution": "540P", "durations": [3, 5], "width": 960, "height": 540 }, + { "resolution": "720P", "durations": [5, 7], "width": 1280, "height": 720 } + ], + "defaultResolution": "720P", + "defaultDuration": 7, + "dimensionStep": 2 + } + } + ] +} +``` + +每份声明最多 20 档;时长为 1–60 秒内的整数,具体可用范围取决于适配和服务。宽高须同时填写或留空;横屏宽不小于高,边长 64–8192,且满足对齐步长。默认分辨率和时长必须构成有效组合,分辨率名称不能重复。 + +读取失败、字段无效或服务未提供声明时保留原配置。已保存的密钥只会在基础地址完全一致时复用;读取新地址需要重新输入密钥。 + +## 扩展边界 + +已有适配协议下接入新模型、修改输出档位,只需配置。全新服务若使用不同的上传、提交、轮询或结果下载协议,仍需开发独立适配器。界面声明不会保证远端模型、账户权限或硬件能完成所配置的请求。 + +## MiniMax 官方视频 V2 + +添加视频服务时选择“MiniMax 官方视频 V2”,基础地址填写 `https://api.minimax.cn/v2`,使用 Bearer API Key。模型列表来自内置声明,载入列表不验证密钥或账户权限。连接继续由 `providerId` 管理,工程引用模型配置自身的 `id`;同名自部署模型使用独立连接与 `vllm_omni` 协议。 + +该适配接入 `MiniMax-H3`、`MiniMax-H3-Highspeed`、`MiniMax-H3-Lite` 和 `MiniMax-H3-Max`,按各型号限制输出档位与整数时长。首尾帧模式支持明确选择首帧、尾帧或两者;不选择帧时按文本生成。参考模式支持图片、视频和音频,包括单独音频参考。首尾帧不能与多模态参考混用。首尾帧输出比例由服务按输入决定;文本生成的自动比例解析为 `16:9`。不接受自定义像素尺寸或缓存续接。 + +本地素材按实际字节编码为 Base64,不上传到额外托管服务,也不自动压缩。支持 PNG、JPEG、WEBP 图片,MP4、MOV 视频和 WAV、MP3 音频;尺寸、数量、单文件大小、时长、视频帧率与编码在提交前检查。编码后的请求不得超过官方请求预算,超限明确拒绝。URL 与 `mm_file://` 输入、HEIC/HEIF 和回调通知不属于此适配范围。 + +任务接受后固定模型、参数、素材和参考用途。已知远端任务恢复时继续查询原任务;提交结果未知时不自动重发。结果下载为本地素材并进入既有候选与采用流程,CDN 下载不携带 API Key。停止本地执行不代表远端取消成功;本适配未接入远端取消,任务可能继续执行并计费。 + +协议依据:[创建任务](https://platform.minimax.cn/docs/api-reference/video-generation-v2-create)、[查询任务](https://platform.minimax.cn/docs/api-reference/video-generation-v2-query)。真实服务调用和生成质量需要使用已配置账户单独验证。 + +## 提供商与逐模型设置 + +可灵 4.0 使用独立的 `kling_video` 协议,按文生、首尾帧和图片参考选择对应官方提交路径,共用现有任务查询、恢复和结果采用流程。固定能力由后端发布。`kling-4.0` 支持 720P / 1080P、3–30 秒及首尾帧;`kling-4.0-flash` 支持 720P、3–20 秒和首帧,不支持尾帧。两个型号均支持图片参考与原生音频,不填写自定义像素尺寸。接入与输入限制见[中文指南](kling-video.zh-CN.md)和[English guide](kling-video.md)。 + +MiniMax 官方视频提供四个型号,新增服务时默认全部勾选,保存后才启用;编辑已有服务时保留原有勾选。标准 H3 支持 768P / 2K、4—15 秒;Highspeed 和 Lite 支持 480P / 768P、4—15 秒;Max 支持 480P / 768P、5—15 秒。各型号的输出档位与时长由后端分别校验。 + +添加服务时先选择提供商。提供商列表分为“自定义 API”和“vLLM-Omni 兼容”两组,各组只列出自身支持的接入类型。视频页列出 MiniMax 官方视频、可灵官方视频、火山方舟 / Agent Plan,以及 “vLLM-Omni 兼容”分组;“vLLM-Omni 兼容”分组内细分视频接口、分割接口和深度接口。选中后确定协议与接入方式,表单不再提供全局协议列表进行二次分类。高级连接设置用于填写地址等连接参数;自部署地址由用户填写。MiniMax 对话预设使用 [官方 OpenAI 兼容地址](https://platform.minimax.cn/docs/api-reference/text-openai-api),视频预设使用视频 V2 协议。 + +同类别、同地址与协议下存在已保存连接时,可以明确选择复用,以保留密钥和模型身份;不复用则新建独立连接。手动添加和获取列表可以交替使用,获取结果仍需勾选,已有选择不会因列表刷新消失。 + +图片页的 “vLLM-Omni 兼容”分组包含图片接口和分割接口;音频页包含语音合成、音乐生成和扒谱接口。各项直接确定对应协议,不再显示全局协议选择。对话、图片、音频页的“OpenAI 兼容”统一位于“自定义 API”分组首项,合并官方 OpenAI 与兼容服务接入;默认填写官方地址,地址与鉴权可编辑。 + +已选模型各自显示能力卡片。对话模型独立声明图片理解;视频模型独立配置适配方式和输出规格,官方 H3 与可灵展示后端发布的固定能力。编辑一个模型不会批量覆盖其他模型的能力。保存只保存配置,不执行推理测试,也不自动切换当前创作模型;对话模型可单独执行连通性测试。 + +首尾帧引用使用图片素材与 `role=first_frame` / `last_frame`,不填写 `subjectRole`。`subjectRole` 表示主体素材槽位,不表示视频首帧。明确指定的首尾帧若会被引用策略过滤,提交会返回 `reference_invalid`,不接受任务或退化为文生视频;未配置首尾帧的文生视频仍然允许。`fasth3_dual` 的首尾帧模式要求首帧和尾帧同时存在:缺少任一锚点或附带音频、视频参考时,提交被拒绝且不创建任务。 diff --git a/packages/core/src/opendirector/agent/native.py b/packages/core/src/opendirector/agent/native.py index a8e6b1c42..d2321b5b2 100644 --- a/packages/core/src/opendirector/agent/native.py +++ b/packages/core/src/opendirector/agent/native.py @@ -122,6 +122,10 @@ def command(runtime: str, work: Path, socket: str, token: str, model: str | None settings = ['features.shell_tool=true', 'features.apply_patch_freeform=false', 'web_search="disabled"', 'sandbox_workspace_write.network_access=true', 'skills.bundled.enabled=false', f'developer_instructions={json.dumps(SYSTEM)}'] + if sys.platform == 'win32': + # --ignore-user-config also removes windows.sandbox. Without a + # Windows backend Codex downgrades workspace-write to read-only. + settings.append('windows.sandbox="elevated"') args = [binary, 'exec', '--json', '--skip-git-repo-check', *codex_isolation_flags(binary), '--sandbox', 'workspace-write'] for setting in settings: args += ['-c', setting] @@ -246,7 +250,7 @@ async def stream(self, run: RunContext, gateway: ToolGateway): args += ['--session' if runtime == 'opencode' else '--resume', session_id] execution_context = (f'Execution directory: {work}\nNative session directory: {native_work}\n' 'Set the native shell workdir to this execution directory for file and media operations. ' - 'Use inherited PATH to discover installed programs with command -v. ' + 'Use inherited PATH to discover installed programs with Get-Command in PowerShell or command -v in POSIX shells. ' 'Read source assets at their supplied absolute paths; do not move or modify them. ' 'Write all intermediate files and outputs into the execution directory. ' 'Use opendirector --help to discover OpenDirector commands and opendirector --help for usage. Use opendirector for project changes.') diff --git a/packages/core/src/opendirector/agent/tools.py b/packages/core/src/opendirector/agent/tools.py index c5bdac8b4..414f20642 100644 --- a/packages/core/src/opendirector/agent/tools.py +++ b/packages/core/src/opendirector/agent/tools.py @@ -58,7 +58,7 @@ def query_guidance(failure): SYSTEM = '''You are OpenDirector, a video creation assistant. Respond directly when the user's request can be answered without project state or tool execution. When the task needs project capabilities, use the harness's native shell tool to discover and run the opendirector executable on PATH. -Before using the project CLI, execute command -v opendirector through the shell, then execute opendirector --help. +Before using the project CLI, locate opendirector through the shell (Get-Command opendirector in PowerShell, command -v opendirector in POSIX shells), then execute opendirector --help. Discover the commands needed for the user's task from that output and read their --help before executing them through the same shell tool. After performing requested creative work, summarize the delivered result and material limitations. Keep execution IDs, revisions and receipts in tool details unless requested. Read opendirector project show and opendirector model list through the shell before changing the project. Use exact current object revisions. diff --git a/packages/core/src/opendirector/application/creation_generation.py b/packages/core/src/opendirector/application/creation_generation.py index 6c924d607..5e3471a5e 100644 --- a/packages/core/src/opendirector/application/creation_generation.py +++ b/packages/core/src/opendirector/application/creation_generation.py @@ -199,6 +199,8 @@ def _parameters(self, spec, config, node, records): seconds = intent.get('durationSeconds') if rules['profile'] == 'fasth3-omni': params = video_parameters(node, records, duration_seconds=seconds) + if config.get('videoAdapter') == 'fasth3_dual' and node.get('videoMode') == 'first_frame': + params['num_inference_steps'] = 20 params['seed'] = new_seed() elif rules['profile'] == 'standard-video': params = {} @@ -374,7 +376,7 @@ def accept(before): spec, resolved = current_generation_inputs(intermediate, spec, public.inputRules) spec = execution_spec(spec, resolved, public.inputRules) try: - validate_generation(spec, public, resolved) + validate_generation(spec, public, resolved, submitting=True) if spec.kind == 'audio' and spec.parameters.creationType == 'audio': if old != voice_spec or config != voice_config: raise ContractError('revision_conflict', '音色验证期间生成配置或模型服务已变化,请重新提交。', spec.id) diff --git a/packages/core/src/opendirector/domain/creation/canvas.py b/packages/core/src/opendirector/domain/creation/canvas.py index b4f61d738..74cac41a2 100644 --- a/packages/core/src/opendirector/domain/creation/canvas.py +++ b/packages/core/src/opendirector/domain/creation/canvas.py @@ -243,7 +243,7 @@ def node_capabilities(item: CanvasItem, *, spec: GenerationSpec | None = None, generate = False if configure and matching and model is not None: try: - validate_generation(spec, model, references) + validate_generation(spec, model, references, submitting=True) generate = True except (ValueError, ProjectError): pass diff --git a/packages/core/src/opendirector/domain/creation/generation.py b/packages/core/src/opendirector/domain/creation/generation.py index aab8d9ef7..77bc2471a 100644 --- a/packages/core/src/opendirector/domain/creation/generation.py +++ b/packages/core/src/opendirector/domain/creation/generation.py @@ -371,7 +371,8 @@ def implicit_text_prompt(spec: GenerationSpec, references: tuple[ResolvedReferen ref.asset.kind == 'text' and ref.transmission == 'content' for ref in references) -def validate_generation(spec: GenerationSpec, model: ModelConfigPublic, references: tuple[ResolvedReference, ...] = ()): +def validate_generation(spec: GenerationSpec, model: ModelConfigPublic, references: tuple[ResolvedReference, ...] = (), + *, submitting: bool = False): """Pure shared validation; it never submits, uploads or changes a project.""" if spec.modelConfigId != model.id or model.kind != ('agent' if spec.kind == 'text' else spec.kind): raise ValueError('所选模型与生成类型不匹配。') @@ -462,6 +463,15 @@ def validate_generation(spec: GenerationSpec, model: ModelConfigPublic, referenc raise ValueError(f'首尾帧模式最多连接 {FRAME_IMAGE_LIMIT} 个图片节点,请先断开多余连线。') if params.videoMode not in rules.videoModes: raise ValueError(f"当前模型不支持视频模式 {params.videoMode};允许值:{', '.join(rules.videoModes)}。") + if submitting and model.videoAdapter == 'fasth3_dual' and params.videoMode == 'first_frame': + # Both anchors are the point of this adapter; a lone anchor or a + # text-to-video request belongs to another adapter or mode. Auxiliary + # media would otherwise be filtered to context_only without a word. + if any(ref.asset.kind in {'audio', 'video'} for ref in references): + raise ValueError('FastH3 首尾帧模式不接受音频或视频参考,请移除后再生成。') + slots = {ref.role for ref in references if ref.asset.kind == 'image'} + if slots != {'first_frame', 'last_frame'}: + raise ValueError('FastH3 首尾帧需要同时提供首帧和尾帧,请补齐两个槽位后再生成。') if params.videoMode == 'continuation': continuation = [ref for ref in references if ref.role == 'continuation'] if len(continuation) != 1 or continuation[0].asset.kind != 'video' or kinds.count('video') != 1: diff --git a/packages/core/src/opendirector/domain/input_rules.py b/packages/core/src/opendirector/domain/input_rules.py index c927c466e..f2f2f2fbf 100644 --- a/packages/core/src/opendirector/domain/input_rules.py +++ b/packages/core/src/opendirector/domain/input_rules.py @@ -98,10 +98,12 @@ def _adapter_rules(config): imageBytes=30 * 1024 * 1024, requestBytes=64 * 1024 * 1024, videoModes=['first_frame', 'reference', 'continuation'], outputResolutions=['480P', '768P']) return rules - if kind == 'video' and config.get('protocol') == 'vllm_omni' and adapter == 'fasth3': + if kind == 'video' and config.get('protocol') == 'vllm_omni' and adapter in {'fasth3', 'fasth3_dual'}: rules.update(profile='fasth3-omni', allowedKinds=['text', 'image', 'video', 'audio'], maxImages=9, maxVideos=3, maxAudios=3, imageBytes=30 * 1024 * 1024, requestBytes=160 * 1024 * 1024, videoModes=['reference'], outputResolutions=['480P', '768P']) + if adapter == 'fasth3_dual': + rules.update(videoModes=['reference', 'first_frame'], frameRoles=['first_frame', 'last_frame']) return rules if kind == 'video' and config.get('protocol') == 'vllm_omni': rules.update(profile='standard-video', maxImages=1, videoModes=['first_frame']) diff --git a/packages/core/src/opendirector/domain/video_capabilities.py b/packages/core/src/opendirector/domain/video_capabilities.py index 751160693..50ad25292 100644 --- a/packages/core/src/opendirector/domain/video_capabilities.py +++ b/packages/core/src/opendirector/domain/video_capabilities.py @@ -10,7 +10,7 @@ from opendirector.domain.kling_models import kling_capabilities from opendirector.domain.bigmodel_video import cogvideo_capabilities, validate_cogvideo_outputs -VideoAdapter = Literal['auto', 'fasth3', 'minimax_h3', 'standard'] +VideoAdapter = Literal['auto', 'fasth3', 'fasth3_dual', 'minimax_h3', 'standard'] Second = Annotated[StrictInt, Field(ge=1, le=60)] @@ -114,7 +114,7 @@ def validate_kling_outputs(capabilities, model_id='kling-4.0'): def check_video_config(kind, protocol, adapter, capabilities): - if adapter not in {'auto', 'fasth3', 'minimax_h3', 'standard'}: + if adapter not in {'auto', 'fasth3', 'fasth3_dual', 'minimax_h3', 'standard'}: raise ProjectError('无效的视频适配方式。') if kind != 'video' and (adapter != 'auto' or capabilities is not None): raise ProjectError('输出能力配置仅适用于视频模型。') @@ -141,14 +141,14 @@ def check_video_config(kind, protocol, adapter, capabilities): item.get('width') is not None or item.get('height') is not None for item in capabilities['outputs']): raise ProjectError('MiniMax-H3 官方接口支持 480P、768P、2K 和 4—15 秒,具体取决于型号,不接受自定义像素尺寸。') return capabilities - if adapter in {'fasth3', 'minimax_h3'}: + if adapter in {'fasth3', 'fasth3_dual', 'minimax_h3'}: if any(not 4 <= second <= 15 for item in capabilities['outputs'] for second in item['durations']): raise ProjectError('当前 H3 适配支持 4–15 秒,不能通过能力配置扩大此范围。') if capabilities['dimensionStep'] != 32: raise ProjectError('H3 输出宽高必须按 32 像素对齐(像素对齐步长须为 32)。') # The /videos resolver needs explicit pixels, except for the two H3 buckets # it derives itself; saving an unusable declaration would only fail later. - derived = {'480P', '768P'} if adapter in {'fasth3', 'minimax_h3'} else set() + derived = {'480P', '768P'} if adapter in {'fasth3', 'fasth3_dual', 'minimax_h3'} else set() if any(item.get('width') is None and item['resolution'] not in derived for item in capabilities['outputs']): raise ProjectError('该适配方式需要为每个输出规格填写像素宽高(H3 的 480P、768P 可按档位推算)。') return capabilities diff --git a/packages/core/src/opendirector/integrations/providers.py b/packages/core/src/opendirector/integrations/providers.py index ae83e67f8..46187c4e3 100644 --- a/packages/core/src/opendirector/integrations/providers.py +++ b/packages/core/src/opendirector/integrations/providers.py @@ -19,7 +19,7 @@ from opendirector.integrations.minimax_video import MinimaxVideoGeneration from opendirector.integrations.kling_video import KlingVideoGeneration from opendirector.integrations.bigmodel_video import BigModelVideoGeneration -from opendirector.integrations.vllm_omni import FPS, VllmOmniGeneration, video_frame_parameters +from opendirector.integrations.vllm_omni import FPS, VllmOmniGeneration, _upload, video_frame_parameters from opendirector.integrations.vllm_omni_image import VllmOmniImageGeneration from opendirector.integrations.model_adapters import BigModelImages, MinimaxH3Images, MinimaxSpeech, MossImages, MossSpeech, OpenAISpeech, VllmOmniMusic, VllmOmniScore, ZhipuSpeech from opendirector.domain.capabilities import ImageRequest, MusicRequest, ScoreRequest, SpeechRequest @@ -175,9 +175,14 @@ async def generate(self, config, task, submitted, *, result_ready=None): prepared = await asyncio.to_thread(generation_references, self.store, task, config) files = [] fast = input_rules(config)['profile'] == 'fasth3-omni' - for data, meta, source_kind in references(self.store, task['projectId'], task['referenceIds']): - if source_kind in {'image', 'video', 'audio'}: - files.append(('input_references' if fast else 'input_reference', (meta['name'], data, image_type(data) if source_kind == 'image' else meta['type']))) + frame_indices = prepared.get('frameIndices') + if frame_indices is not None: + files = [('input_references', _upload(image, 'first_frame' if index == 0 else 'last_frame')) + for index, image in zip(frame_indices, prepared['images'], strict=True)] + else: + for data, meta, source_kind in references(self.store, task['projectId'], task['referenceIds']): + if source_kind in {'image', 'video', 'audio'}: + files.append(('input_references' if fast else 'input_reference', (meta['name'], data, image_type(data) if source_kind == 'image' else meta['type']))) parameters = task['parameters'] form = {'model': config['modelId'], 'prompt': prepared['prompt']} if fast: @@ -192,11 +197,18 @@ async def generate(self, config, task, submitted, *, result_ready=None): form['seconds'] = str(int(seconds)) if float(seconds).is_integer() else str(seconds) if 'size' in parameters: form['size'] = parameters['size'] if fast: + extra = {'task': 'ref2va', 'audio_flow_shift': 3} + steps = 8 + if frame_indices is not None: + # Validation requires both anchors, so this is + # always a first/last-frame submission. + extra.update(task='fl2va', sampler='res_multistep', frame_indices=frame_indices) + steps = parameters.get('num_inference_steps', 20) form.update({ 'size': parameters.get('size', '832x480'), - 'num_inference_steps': '8', 'guidance_scale': '1', 'fps': '24', + 'num_inference_steps': str(steps), 'guidance_scale': '1', 'fps': '24', 'seed': str(parameters.get('seed', 1234)), - 'extra_params': json.dumps({'task': 'ref2va', 'audio_flow_shift': 3})}) + 'extra_params': json.dumps(extra)}) # Force multipart even for an empty reference list. value = await self._json(client, 'POST', url, config, data=form, files=files or {'_multipart': (None, '1')}) external_id = value['id'] diff --git a/packages/core/src/opendirector/integrations/reference_inputs.py b/packages/core/src/opendirector/integrations/reference_inputs.py index 5296b704c..63ab3dfa1 100644 --- a/packages/core/src/opendirector/integrations/reference_inputs.py +++ b/packages/core/src/opendirector/integrations/reference_inputs.py @@ -121,10 +121,13 @@ def generation_references(store, task, config, *, complete=True, overrides=None) if kind == 'video' and mode not in rules['videoModes']: raise ProjectError('当前模型不支持接续生成,请选择 vLLM-Omni MiniMax-H3。' if mode == 'continuation' else '当前模型接口尚未接通素材参考模式,请选择该模型支持的生成方式。') + dual_frames = kind == 'video' and mode == 'first_frame' and config.get('videoAdapter') == 'fasth3_dual' total_audio_ms, total_video_ms, media_bytes = 0, 0, 0 source_metadata, text_context = [], [] mentioned = {str(part['assetId']) for part in task.get('promptContent') or () if part['type'] == 'reference'} - role_by_asset = {str(value['assetId']): value['role'] for value in task.get('referenceRoles') or []} + roles_by_asset: dict[str, list[str]] = {} + for value in task.get('referenceRoles') or []: + roles_by_asset.setdefault(str(value['assetId']), []).append(value['role']) slot_roles = set() for index, (data, meta, source_kind) in enumerate(references(store, task['projectId'], task['referenceIds'], overrides), 1): entry = {'assetId': meta['id'], 'fingerprint': meta['fingerprint'], 'kind': source_kind, 'transmission': 'content'} @@ -171,23 +174,31 @@ def generation_references(store, task, config, *, complete=True, overrides=None) raise ProjectError(f'“{meta["name"]}”不符合当前图片模型的参考尺寸要求。') if rules['profile'] == 'minimax-h3-image': validate_minimax_image_reference(mime, width, height) - role = 'reference_image' + roles = ['reference_image'] if kind == 'video' and mode == 'first_frame': # Frame slots are per-slot: one image each, and the slot the # caller asked for is kept so Ark receives last_frame as such. # A plain 'reference' role is a first frame, matching what a # single image meant before last_frame existed; it never turns - # into a last frame implicitly. - requested = role_by_asset.get(str(meta['id'])) - role = requested if requested in {'first_frame', 'last_frame'} else 'first_frame' - if role in slot_roles: - raise ProjectError('首尾帧每个槽位只能使用一张图片,请在画布上明确指定首帧和尾帧。') - slot_roles.add(role) - result['images'].append(data_uri(data, mime)) - result['imageRoles'].append(role) - number = len(result['images']) - result['prompt'] += f'\n参考{index}:{meta["name"]},对应第{number}张参考图片(图片{number},)。' - entry.update(role=role, number=number) + # into a last frame implicitly. One asset may fill both slots, + # so every requested role is emitted as its own anchor. + requested = [role for role in roles_by_asset.get(str(meta['id']), ()) + if role in {'first_frame', 'last_frame'}] + roles = requested or ['first_frame'] + uri = data_uri(data, mime) + for role in roles: + if kind == 'video' and mode == 'first_frame': + if role in slot_roles: + raise ProjectError('首尾帧每个槽位只能使用一张图片,请在画布上明确指定首帧和尾帧。') + slot_roles.add(role) + result['images'].append(uri) + result['imageRoles'].append(role) + number = len(result['images']) + # Dual-frame anchors travel as uploads, so the prompt stays plain. + if not dual_frames: + result['prompt'] += f'\n参考{index}:{meta["name"]},对应第{number}张参考图片(图片{number},)。' + result['manifest'].append({**entry, 'role': role, 'number': number}) + continue elif source_kind == 'video': duration = meta.get('durationMs') if meta['type'] not in {'video/mp4', 'video/quicktime'} or len(data) > rules['videoBytes']: @@ -217,6 +228,14 @@ def generation_references(store, task, config, *, complete=True, overrides=None) # first frame stay at one. frame_limit = 2 if 'last_frame' in (rules.get('frameRoles') or ()) else 1 maximum = frame_limit if kind == 'video' and mode == 'first_frame' else rules['maxImages'] + if dual_frames: + # The service takes the anchors in first/last order whatever order the + # canvas listed them, and records which upload is the tail anchor. + order = [i for i, role in enumerate(result['imageRoles']) if role == 'first_frame'] + order += [i for i, role in enumerate(result['imageRoles']) if role != 'first_frame'] + result['images'] = [result['images'][i] for i in order] + result['imageRoles'] = [result['imageRoles'][i] for i in order] + result['frameIndices'] = [0 if role == 'first_frame' else -1 for role in result['imageRoles']] if result['images'] and not maximum: raise ProjectError('当前模型只按文字生成,不支持参考图片;请移除图片参考,或把外观要求写进提示词。当前输入已保留。') if len(result['images']) > maximum: @@ -233,7 +252,7 @@ def generation_references(store, task, config, *, complete=True, overrides=None) raise ProjectError('参考素材合计超过 100 MB,请缩小文件。', 413) if complete and result['audios'] and not (result['images'] or result['videos']) and mode != 'continuation': raise ProjectError('音频参考须搭配至少一张参考图片或一段参考视频。') - if rules['profile'] == 'fasth3-omni': + if rules['profile'] == 'fasth3-omni' and not dual_frames: from opendirector.integrations.fasth3 import native_prompt result['prompt'] = native_prompt(task, source_metadata) + ''.join(text_context) if not prompt.strip(): diff --git a/src/backend/creationJobs.ts b/src/backend/creationJobs.ts index 88e40baf9..cb2c561e2 100644 --- a/src/backend/creationJobs.ts +++ b/src/backend/creationJobs.ts @@ -55,6 +55,14 @@ export function creationJobs( createdAt: job.createdAt ? Date.parse(job.createdAt) : undefined, durationKey: `generate:${spec.kind}:${job.inputSnapshot.model.modelConfigId}`, outputKind: spec.kind, + videoDuration: job.execution.kind === "video" + ? { + requestedSeconds: job.execution.durationSeconds ?? undefined, + resultSeconds: asset?.kind === "video" + ? asset.metadata.durationSeconds ?? undefined + : undefined, + } + : undefined, activityPhase: phase ?? undefined, preview: preview ?? diff --git a/src/backend/rules.ts b/src/backend/rules.ts index d1a81f517..ad3429cfb 100644 --- a/src/backend/rules.ts +++ b/src/backend/rules.ts @@ -21,7 +21,7 @@ import type { MessageKey } from "../i18n/types.ts"; /** Model configurations and input rules published by the local API. */ export type ModelKind = "agent" | "image" | "video" | "audio" | "vision"; export type BackendVideoMode = "first_frame" | "reference" | "continuation"; -export type VideoAdapter = "auto" | "fasth3" | "minimax_h3" | "standard"; +export type VideoAdapter = "auto" | "fasth3" | "fasth3_dual" | "minimax_h3" | "standard"; export interface VideoCapabilities { outputs: { resolution: string; diff --git a/src/backend/videoCapabilities.ts b/src/backend/videoCapabilities.ts index ed3d844e0..965035ecd 100644 --- a/src/backend/videoCapabilities.ts +++ b/src/backend/videoCapabilities.ts @@ -59,7 +59,7 @@ export function createVideoCapabilities( // The /videos resolver needs pixels except for the two H3 buckets it // derives itself; saving anything else would only fail at generation. const derived = - (adapter === "fasth3" || adapter === "minimax_h3") && + (adapter === "fasth3" || adapter === "fasth3_dual" || adapter === "minimax_h3") && (resolution === "480P" || resolution === "768P"); if (!derived) throw new Error( diff --git a/src/canvas/GenerationHistoryPanel.tsx b/src/canvas/GenerationHistoryPanel.tsx index 1a000fe38..afa2dc4da 100644 --- a/src/canvas/GenerationHistoryPanel.tsx +++ b/src/canvas/GenerationHistoryPanel.tsx @@ -27,6 +27,7 @@ export function GenerationHistoryPanel({ authoritative?: boolean; }) { const { t, locale } = useI18n(); + const durationFormat = new Intl.NumberFormat(locale, { maximumFractionDigits: 3 }); const [filter, setFilter] = useState("all"); const [selected, setSelected] = useState([]); const [pending, setPending] = useState([]); @@ -162,6 +163,16 @@ export function GenerationHistoryPanel({ : labels[job.status]} {job.message && {job.message}} + {job.videoDuration?.requestedSeconds !== undefined && ( + {t("generation.history.requestedDuration", { + seconds: durationFormat.format(job.videoDuration.requestedSeconds), + })} + )} + {job.videoDuration?.resultSeconds !== undefined && ( + {t("generation.history.resultDuration", { + seconds: durationFormat.format(job.videoDuration.resultSeconds), + })} + )} {job.preview?.state === "pending" && {t("generation.history.readingPreview")}}
{job.outputs?.map((output, i) => diff --git a/src/canvas/ModelCapabilityCard.tsx b/src/canvas/ModelCapabilityCard.tsx index 0093ef769..41d66824c 100644 --- a/src/canvas/ModelCapabilityCard.tsx +++ b/src/canvas/ModelCapabilityCard.tsx @@ -228,6 +228,9 @@ export function ModelCapabilityCard({ + diff --git a/src/canvas/VideoCapabilitiesEditor.tsx b/src/canvas/VideoCapabilitiesEditor.tsx index 04baf9f8b..e59df4d2e 100644 --- a/src/canvas/VideoCapabilitiesEditor.tsx +++ b/src/canvas/VideoCapabilitiesEditor.tsx @@ -36,7 +36,7 @@ export function VideoCapabilitiesEditor({ onChange: (value: VideoCapabilityDraft) => void; }) { const t = useT(); - const h3 = adapter === "fasth3" || adapter === "minimax_h3"; + const h3 = adapter === "fasth3" || adapter === "fasth3_dual" || adapter === "minimax_h3"; const update = (patch: Partial) => onChange({ ...value, ...patch }); const rowChange = (index: number, patch: Partial) => diff --git a/src/canvas/generationHistory.ts b/src/canvas/generationHistory.ts index c70daaa61..028c0c736 100644 --- a/src/canvas/generationHistory.ts +++ b/src/canvas/generationHistory.ts @@ -32,6 +32,7 @@ export interface GenerationJob { finishedAt?: number; durationKey?: string; outputKind?: "text" | "image" | "video" | "audio"; + videoDuration?: { requestedSeconds?: number; resultSeconds?: number }; activityPhase?: import("./generationActivity.ts").GenerationPhase; message?: string; /** Service-reported reason for a failed or interrupted execution. */ diff --git a/src/contracts/creation.schema.json b/src/contracts/creation.schema.json index 2b43c2294..aa9856710 100644 --- a/src/contracts/creation.schema.json +++ b/src/contracts/creation.schema.json @@ -8230,6 +8230,7 @@ "enum": [ "auto", "fasth3", + "fasth3_dual", "minimax_h3", "standard" ], @@ -8387,6 +8388,7 @@ "enum": [ "auto", "fasth3", + "fasth3_dual", "minimax_h3", "standard" ], @@ -8533,6 +8535,7 @@ "enum": [ "auto", "fasth3", + "fasth3_dual", "minimax_h3", "standard" ], @@ -8660,6 +8663,7 @@ "enum": [ "auto", "fasth3", + "fasth3_dual", "minimax_h3", "standard" ], @@ -23727,6 +23731,7 @@ "enum": [ "auto", "fasth3", + "fasth3_dual", "minimax_h3", "standard" ], @@ -23874,6 +23879,7 @@ "enum": [ "auto", "fasth3", + "fasth3_dual", "minimax_h3", "standard" ], @@ -24025,6 +24031,7 @@ "enum": [ "auto", "fasth3", + "fasth3_dual", "minimax_h3", "standard" ], @@ -24156,6 +24163,7 @@ "enum": [ "auto", "fasth3", + "fasth3_dual", "minimax_h3", "standard" ], diff --git a/src/contracts/generated.ts b/src/contracts/generated.ts index f89212756..8cf9b8972 100644 --- a/src/contracts/generated.ts +++ b/src/contracts/generated.ts @@ -835,7 +835,7 @@ export interface ModelConnectionInput extends ContractInput { readonly authMode: "none" | "bearer"; readonly proxyMode?: "system" | "direct"; readonly inputModalities?: ReadonlyArray<"text" | "image"> | null; - readonly videoAdapter?: "auto" | "fasth3" | "minimax_h3" | "standard"; + readonly videoAdapter?: "auto" | "fasth3" | "fasth3_dual" | "minimax_h3" | "standard"; readonly videoCapabilities?: VideoCapabilitiesInput | null; } @@ -848,7 +848,7 @@ export interface ModelSnapshotInput extends ContractInput { readonly connectionType: "api" | "self_hosted"; readonly proxyMode?: "system" | "direct"; readonly inputModalities?: ReadonlyArray<"text" | "image"> | null; - readonly videoAdapter?: "auto" | "fasth3" | "minimax_h3" | "standard"; + readonly videoAdapter?: "auto" | "fasth3" | "fasth3_dual" | "minimax_h3" | "standard"; readonly inputRules?: InputRulesInput | null; } @@ -2414,7 +2414,7 @@ export interface ModelConnection extends Contract { readonly authMode: "none" | "bearer"; readonly proxyMode: "system" | "direct"; readonly inputModalities: ReadonlyArray<"text" | "image"> | null; - readonly videoAdapter: "auto" | "fasth3" | "minimax_h3" | "standard"; + readonly videoAdapter: "auto" | "fasth3" | "fasth3_dual" | "minimax_h3" | "standard"; readonly videoCapabilities: VideoCapabilities | null; } @@ -2427,7 +2427,7 @@ export interface ModelSnapshot extends Contract { readonly connectionType: "api" | "self_hosted"; readonly proxyMode?: "system" | "direct"; readonly inputModalities?: ReadonlyArray<"text" | "image"> | null; - readonly videoAdapter: "auto" | "fasth3" | "minimax_h3" | "standard"; + readonly videoAdapter: "auto" | "fasth3" | "fasth3_dual" | "minimax_h3" | "standard"; readonly inputRules: InputRules | null; } diff --git a/src/i18n/messages/en-US/generation.ts b/src/i18n/messages/en-US/generation.ts index a95ad14a8..dcea08a65 100644 --- a/src/i18n/messages/en-US/generation.ts +++ b/src/i18n/messages/en-US/generation.ts @@ -187,6 +187,8 @@ export const generation = { "generation.history.empty": "No generation history of this type.", "generation.history.selectJob": "Select history {title}", "generation.history.readingPreview": "Reading result preview…", + "generation.history.requestedDuration": "Requested duration: {seconds} s", + "generation.history.resultDuration": "Result duration: {seconds} s", "generation.history.query": "Check the original task again", "generation.history.cancelCloud": "Cancel cloud task", "generation.history.cancelTool": "Stop tool task", diff --git a/src/i18n/messages/en-US/models.ts b/src/i18n/messages/en-US/models.ts index f7caa6f4c..a9105d70a 100644 --- a/src/i18n/messages/en-US/models.ts +++ b/src/i18n/messages/en-US/models.ts @@ -108,6 +108,8 @@ export const models = { "Auto-detect known models; use the generic first-frame API for others", "models.service.adapterFastH3": "FastH3-Omni (8 steps, multi-asset reference)", + "models.service.adapterFastH3Dual": + "FastH3-Omni (first/last keyframe anchors)", "models.service.adapterMiniMaxH3": "Native MiniMax-H3 (first frame, asset references, continuation)", "models.service.adapterStandard": diff --git a/src/i18n/messages/zh-CN/generation.ts b/src/i18n/messages/zh-CN/generation.ts index f3370278c..bf276ba5d 100644 --- a/src/i18n/messages/zh-CN/generation.ts +++ b/src/i18n/messages/zh-CN/generation.ts @@ -175,6 +175,8 @@ export const generation = { "generation.history.empty": "暂无此类型的生成历史。", "generation.history.selectJob": "选择历史{title}", "generation.history.readingPreview": "正在读取结果预览…", + "generation.history.requestedDuration": "请求时长:{seconds} 秒", + "generation.history.resultDuration": "成片时长:{seconds} 秒", "generation.history.query": "继续查询原任务", "generation.history.cancelCloud": "取消云端任务", "generation.history.cancelTool": "停止工具任务", diff --git a/src/i18n/messages/zh-CN/models.ts b/src/i18n/messages/zh-CN/models.ts index 103862969..1390cacc3 100644 --- a/src/i18n/messages/zh-CN/models.ts +++ b/src/i18n/messages/zh-CN/models.ts @@ -92,6 +92,7 @@ export const models = { "models.service.videoAdapter": "视频适配方式", "models.service.adapterAuto": "自动识别已知模型;其他使用通用首帧接口", "models.service.adapterFastH3": "FastH3-Omni(8 步、多素材参考)", + "models.service.adapterFastH3Dual": "FastH3-Omni(首尾帧锚点)", "models.service.adapterMiniMaxH3": "原生 MiniMax-H3(首帧、素材参考、接续)", "models.service.adapterStandard": "通用 /videos(文本、单张首帧)", "models.service.loadPreset": "载入适配预设", diff --git a/tests/creationJobs.test.ts b/tests/creationJobs.test.ts index 64fd1554d..a35c4e1d5 100644 --- a/tests/creationJobs.test.ts +++ b/tests/creationJobs.test.ts @@ -160,3 +160,42 @@ test("a failed job carries its service reason so the toast can show it", () => { }).find((j) => j.id === active.id)!; assert.equal(done.failure, undefined); }); + +test("video history shows measured duration separately before the preview loads", () => { + const { snapshot } = fixture(); + const job = snapshot.jobs[0]!; + const assetId = snapshot.results[0]!.asset.assetId; + const completed = { + ...snapshot, + jobs: [{ + ...job, + inputSnapshot: { + ...job.inputSnapshot, + spec: { + ...job.inputSnapshot.spec, + kind: "video" as const, + parameters: { + generateAudio: true, videoMode: "first_frame" as const, + durationSeconds: 4, aspectRatio: "16:9", resolution: "480P", + }, + }, + }, + execution: { + kind: "video" as const, durationSeconds: 4, + size: "832x480", resolution: "480P", fps: 24, numFrames: 107, + numInferenceSteps: 20, guidanceScale: null, seed: null, + watermark: null, generateAudio: null, + }, + }], + assets: snapshot.assets.map((asset) => asset.id === assetId ? { + ...asset, + kind: "video" as const, + metadata: { ...asset.metadata, mimeType: "video/mp4", durationSeconds: 107 / 24 }, + } : asset), + }; + const [row] = creationJobs(completed); + assert.equal(row?.preview?.state, "pending"); + assert.deepEqual(row?.videoDuration, { requestedSeconds: 4, resultSeconds: 107 / 24 }); + const [withoutResult] = creationJobs({ ...completed, results: [] }); + assert.deepEqual(withoutResult?.videoDuration, { requestedSeconds: 4, resultSeconds: undefined }); +}); diff --git a/tests/test_fasth3_inputs.py b/tests/test_fasth3_inputs.py index 6b4b113d6..f6c9f5a78 100644 --- a/tests/test_fasth3_inputs.py +++ b/tests/test_fasth3_inputs.py @@ -4,6 +4,11 @@ import pytest +from opendirector.domain.creation.assets import AssetRef, MediaMetadata +from opendirector.domain.creation.generation import (ResolvedReference, VideoGenerationSpec, VideoParameters, + validate_generation) +from opendirector.domain.creation.models import ModelConfigPublic +from opendirector.domain.input_rules import input_rules from opendirector.domain.projects import ProjectError from opendirector.integrations.fasth3 import native_prompt, video_parameters @@ -111,3 +116,145 @@ async def submitted(value): assert value == 'verified-wire' provider = GenerationProviders(store, httpx.MockTransport(handle), poll_interval=0) assert asyncio.run(provider.generate(config, task, submitted)) == ('mp4', b'generated') + + +@pytest.mark.parametrize('slots,indices', [ + (('first_frame',), [0]), + (('last_frame',), [-1]), + (('last_frame', 'first_frame'), [0, -1]), +]) +def test_dual_h3_frame_slots_bind_actual_multipart(slots, indices): + import asyncio + from email.parser import BytesParser + from email.policy import default + import httpx + from opendirector.integrations.providers import GenerationProviders + + images = {role: source('image', role + '.png', fingerprint='fixture') for role in slots} + data = {image['id']: (b'\x89PNG\r\n\x1a\n' + role.encode(), image) for role, image in images.items()} + store = SimpleNamespace(asset=lambda owner, key: data[key]) + task = {'kind': 'video', 'projectId': 'owner', 'prompt': 'Animate the transition', + 'referenceIds': list(data), 'videoMode': 'first_frame', 'parameters': {'duration': 4}, + 'referenceRoles': [{'assetId': image['id'], 'role': role} for role, image in images.items()]} + config = {'kind': 'video', 'protocol': 'vllm_omni', 'url': 'http://localhost:18091/v1', + 'modelId': 'FastH3-Omni-INT8', 'videoAdapter': 'fasth3_dual', 'apiKey': '', 'authMode': 'none'} + + def handle(request): + if request.method == 'POST': + prefix = 'Content-Type: ' + request.headers['content-type'] + '\r\n\r\n' + message = BytesParser(policy=default).parsebytes(prefix.encode() + request.content) + fields, uploads = {}, [] + for part in message.iter_parts(): + field = part.get_param('name', header='content-disposition') + payload = part.get_payload(decode=True) + if part.get_filename(): + assert field == 'input_references' + uploads.append((part.get_filename(), payload.split(b'\n')[-1].decode())) + else: + fields[field] = payload + # The uploaded filename states the slot, so it must agree with the + # frame index recorded in extra_params, including a lone tail anchor. + assert uploads == [(role + '.png', role) for role in ('first_frame', 'last_frame') if role in slots] + assert fields['prompt'] == b'Animate the transition' + assert fields['num_inference_steps'] == b'20' + extra = json.loads(fields['extra_params']) + assert (extra['task'], extra['frame_indices'], extra['sampler']) == ('fl2va', indices, 'res_multistep') + return httpx.Response(200, json={'id': 'verified-frame-job'}) + if request.url.path.endswith('/content'): + return httpx.Response(200, content=b'generated') + return httpx.Response(200, json={'status': 'completed'}) + + async def submitted(value): + assert value == 'verified-frame-job' + + provider = GenerationProviders(store, httpx.MockTransport(handle), poll_interval=0) + assert asyncio.run(provider.generate(config, task, submitted)) == ('mp4', b'generated') + + +def test_dual_h3_same_asset_fills_both_frame_slots(): + import asyncio + from email.parser import BytesParser + from email.policy import default + import httpx + from opendirector.integrations.providers import GenerationProviders + + asset_id = str(uuid4()) + image = source('image', 'anchor.png', fingerprint='fixture') + image['id'] = asset_id + store = SimpleNamespace(asset=lambda owner, key: (b'\x89PNG\r\n\x1a\n', image)) + task = {'kind': 'video', 'projectId': 'owner', 'prompt': 'Loop the still', + 'referenceIds': [asset_id], 'videoMode': 'first_frame', 'parameters': {'duration': 4}, + 'referenceRoles': [{'assetId': asset_id, 'role': 'first_frame'}, + {'assetId': asset_id, 'role': 'last_frame'}]} + config = {'kind': 'video', 'protocol': 'vllm_omni', 'url': 'http://localhost:18091/v1', + 'modelId': 'FastH3-Omni-INT8', 'videoAdapter': 'fasth3_dual', 'apiKey': '', 'authMode': 'none'} + + def handle(request): + if request.method == 'POST': + prefix = 'Content-Type: ' + request.headers['content-type'] + '\r\n\r\n' + message = BytesParser(policy=default).parsebytes(prefix.encode() + request.content) + fields, uploads = {}, [] + for part in message.iter_parts(): + if part.get_filename(): + assert part.get_param('name', header='content-disposition') == 'input_references' + uploads.append(part.get_filename()) + else: + fields[part.get_param('name', header='content-disposition')] = part.get_payload(decode=True) + # One asset may fill both slots; both roles still reach the wire. + assert uploads == ['first_frame.png', 'last_frame.png'] + extra = json.loads(fields['extra_params']) + assert (extra['task'], extra['frame_indices'], extra['sampler']) == ('fl2va', [0, -1], 'res_multistep') + return httpx.Response(200, json={'id': 'verified-same-asset-job'}) + if request.url.path.endswith('/content'): + return httpx.Response(200, content=b'generated') + return httpx.Response(200, json={'status': 'completed'}) + + async def submitted(value): + assert value == 'verified-same-asset-job' + + provider = GenerationProviders(store, httpx.MockTransport(handle), poll_interval=0) + assert asyncio.run(provider.generate(config, task, submitted)) == ('mp4', b'generated') + + +def dual_model(): + config = {'kind': 'video', 'url': 'http://model.test/v1', 'modelId': 'FastH3-Omni-INT8', + 'connectionType': 'self_hosted', 'protocol': 'vllm_omni', 'authMode': 'none', + 'videoAdapter': 'fasth3_dual'} + return ModelConfigPublic(id=uuid4(), inputRules=input_rules(config), **config) + + +def dual_spec(model, mode='first_frame'): + return VideoGenerationSpec(id=uuid4(), projectId=uuid4(), kind='video', purpose='generation', + modelConfigId=model.id, prompt='Animate the transition', + parameters=VideoParameters(videoMode=mode, durationSeconds=4)) + + +def frame_reference(role, kind='image', duration=None): + return ResolvedReference(referenceId=uuid4(), role=role, + asset=AssetRef(assetId=uuid4(), revision=1, fingerprint='sha256:' + '0' * 64, kind=kind), + metadata=MediaMetadata(mimeType='image/png', size=10, width=32, height=24, durationSeconds=duration)) + + +def test_dual_h3_requires_both_anchors_at_submission(): + model = dual_model() + spec = dual_spec(model) + anchors = (frame_reference('first_frame'), frame_reference('last_frame')) + validate_generation(spec, model, anchors, submitting=True) + for references in ((), (frame_reference('first_frame'),), (frame_reference('last_frame'),)): + with pytest.raises(ValueError, match='首帧和尾帧'): + validate_generation(spec, model, references, submitting=True) + # Editing a draft still allows the mode before both anchors exist. + validate_generation(spec, model, (), submitting=False) + + +def test_dual_h3_rejects_auxiliary_media_at_submission(): + model = dual_model() + spec = dual_spec(model) + references = (frame_reference('first_frame'), frame_reference('last_frame'), + frame_reference('reference', kind='audio')) + with pytest.raises(ValueError, match='不接受音频或视频参考'): + validate_generation(spec, model, references, submitting=True) + # Reference mode keeps its existing omnimodal semantics. + validate_generation(dual_spec(model, 'reference'), model, + (frame_reference('reference'), frame_reference('reference', kind='audio', duration=3)), + submitting=True) diff --git a/tests/test_native_runtime.py b/tests/test_native_runtime.py index 3592b7a05..280491a3d 100644 --- a/tests/test_native_runtime.py +++ b/tests/test_native_runtime.py @@ -284,6 +284,17 @@ def test_codex_inherits_windows_system_proxy_without_overriding_explicit_proxy(m assert native.codex_environment()['HTTPS_PROXY'] == 'http://127.0.0.1:8002' +@pytest.mark.parametrize('platform', ['win32', 'linux', 'darwin']) +def test_codex_isolation_preserves_windows_workspace_sandbox(tmp_path, monkeypatch, platform): + monkeypatch.setattr(native, 'sys', SimpleNamespace(platform=platform)) + monkeypatch.setattr(native, 'executable', lambda _: 'codex') + monkeypatch.setattr(native, 'codex_isolation_flags', lambda _: ('--ignore-user-config', '--ignore-rules')) + args, _ = native.command('codex', tmp_path, '', '', None, '', []) + assert ('windows.sandbox="elevated"' in args) == (platform == 'win32') + assert args[args.index('--sandbox') + 1] == 'workspace-write' + assert '--dangerously-bypass-approvals-and-sandbox' not in args + + def test_codex_reconnect_does_not_end_turn(): assert native.text_events('codex', {'type': 'error', 'message': 'Reconnecting...'}) == [] assert native.text_events('codex', {'type': 'item.completed', 'item': {