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
14 changes: 14 additions & 0 deletions apps/api/src/opendirector_api/localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@
from opendirector.domain.capability_messages import english_capability_message, missing_tool_model_message

ENGLISH_BY_CODE = {
"h3_timeline_guides_single_model": "Configure native timeline guides for one FastH3 model at a time.",
"h3_timeline_guides_mixed": "Use either generated-video guides or standalone keyframes for this segment.",
"workflow_assembly_busy": "This assembly run is already processing. Wait for its result.",
"workflow_media_invalid": "The source frames, geometry, or soundtrack do not match the assembly.",
"workflow_media_failed": "Media processing failed. Check FFmpeg and the source videos.",
"pipeline_assembly_changed": "The group assembly recipe changed during execution.",
"pipeline_assembly_invalid": "The group, timeline, or upstream job required for assembly is unavailable.",
"h3_timeline_guides_unsupported": "This deployment or video mode does not support H3 segment timeline guides.",
"h3_timeline_guides_deployment": "Native timeline guide settings require a compatible self-hosted FastH3 endpoint.",
"h3_timeline_guides_source_limit": "Use only one source video for an H3 segment.",
'keyframe_unsupported': 'This model or mode does not support keyframes. Clear the keyframe times or choose another model.',
'keyframe_mode': 'Keyframes work in Universal reference mode only, not with first/last frames, continuation or structure control.',
'keyframe_kind': 'A keyframe must be an image.',
Expand Down Expand Up @@ -210,6 +220,10 @@ def localized_error_for_language(
translated = english_capability_message(chinese)
if translated:
return translated
if code == 'reference_invalid':
segment = re.fullmatch(r'组装片段「(.+)」的生成任务缺少来源画布节点(originItemId)。', chinese, re.DOTALL)
if segment:
return f'The generation job for assembly segment “{segment[1]}” is missing its source canvas node (originItemId).'
# A generic operation code must not hide a more specific HTTP status.
generic = code in {"operation_rejected", "invalid_input"}
if generic and status in {413, 502, 504}:
Expand Down
6 changes: 6 additions & 0 deletions docs/guides/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,9 @@ Updates and resizes require the `canvas_item` revision returned by `show`. Recei
`canvas text show` reads `/api/creation/projects/{projectId}/assets/{assetId}/content` through a bounded HTTP stream on both CLI transports, retaining UTF-8 BOM and CRLF. Its cap is `MAX_CREATION_TEXT_BYTES` (1,048,576 bytes); the shared agent `read` tool still uses its original 64 KiB budget. The API address comes from `--url` or `OPENDIRECTOR_API_URL`, which the application launcher supplies to Agent Shell.

`canvas text show` 在两种 CLI 传输方式下都通过有界 HTTP 流读取 `/api/creation/projects/{projectId}/assets/{assetId}/content`,保留 UTF-8 BOM 和 CRLF。上限为 `MAX_CREATION_TEXT_BYTES`(1,048,576 字节);共用 Agent `read` 工具仍保留原有的 64 KiB 预算。API 地址来自 `--url` 或 `OPENDIRECTOR_API_URL`,应用启动器会将该环境变量传给 Agent Shell。

## Pipeline 分组组装 / Assemble a Pipeline group

使用 `group configure-assembly --file assembly.json` 保存分组、目标时间线、成片节点和各段保留区间,再用 `pipeline start` 启动分组。Pipeline 复用输入未变化的片段,组装已采用的结果,并保留时间线的原声音轨。使用回执的 `pipelineExecutionId` 调用 `query pipeline.execution.get --object-id EXECUTION_ID`,重开项目后可继续查看执行记录。

Use `group configure-assembly --file assembly.json` to save the group, target timeline, output node, and kept frame ranges. Start the group with `pipeline start`. The Pipeline reuses segments with unchanged inputs, assembles adopted outputs, and preserves the timeline soundtrack. Read the durable execution with `query pipeline.execution.get --object-id EXECUTION_ID` and the `pipelineExecutionId` from the start receipt.
Binary file added feature-assets/fasth3-segment-guide/fixture.mp4
Binary file not shown.
107 changes: 107 additions & 0 deletions feature-assets/fasth3-segment-guide/multipart-receipts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"provider": "in-process double returning the synthetic fixture bytes",
"runs": {
"anchor": {
"sourceFrames": null,
"requestFields": {
"model": "FastH3-Omni",
"prompt": "Preserve the motion of the synthetic test pattern.\nsource.mp4\ufffd\ufffd\ufffd<Video 1>",
"fps": "24",
"num_frames": "124",
"size": "832x480",
"num_inference_steps": "8",
"guidance_scale": "1",
"seed": "812",
"extra_params": "{\"task\": \"ref2va\", \"audio_flow_shift\": 3}"
},
"multipartFiles": [
[
"input_references",
"video_1.mp4",
"video/mp4"
]
],
"accepted": [
"video_gen_1"
]
},
"forward": {
"sourceFrames": [
0,
21
],
"requestFields": {
"model": "FastH3-Omni",
"prompt": "Preserve the motion of the synthetic test pattern.\nsource.mp4\ufffd\ufffd\ufffd<Video 1>",
"fps": "24",
"num_frames": "124",
"size": "832x480",
"num_inference_steps": "8",
"guidance_scale": "1",
"seed": "812",
"quality": "lossless",
"timeline_guides": "[{\"frame_index\": 0, \"image\": {\"upload_index\": 0}}, {\"frame_index\": 21, \"image\": {\"upload_index\": 1}}]",
"extra_params": "{\"task\": \"ref2va\", \"audio_flow_shift\": 3}"
},
"multipartFiles": [
[
"input_references",
"video_1.mp4",
"video/mp4"
],
[
"guide_files",
"guide_0.png",
"image/png"
],
[
"guide_files",
"guide_1.png",
"image/png"
]
],
"accepted": [
"video_gen_1"
]
},
"reverse": {
"sourceFrames": [
21,
0
],
"requestFields": {
"model": "FastH3-Omni",
"prompt": "Preserve the motion of the synthetic test pattern.\nsource.mp4\ufffd\ufffd\ufffd<Video 1>",
"fps": "24",
"num_frames": "124",
"size": "832x480",
"num_inference_steps": "8",
"guidance_scale": "1",
"seed": "812",
"quality": "lossless",
"timeline_guides": "[{\"frame_index\": 0, \"image\": {\"upload_index\": 0}}, {\"frame_index\": 21, \"image\": {\"upload_index\": 1}}]",
"extra_params": "{\"task\": \"ref2va\", \"audio_flow_shift\": 3}"
},
"multipartFiles": [
[
"input_references",
"video_1.mp4",
"video/mp4"
],
[
"guide_files",
"guide_0.png",
"image/png"
],
[
"guide_files",
"guide_1.png",
"image/png"
]
],
"accepted": [
"video_gen_1"
]
}
}
}
Binary file not shown.
Binary file not shown.
26 changes: 26 additions & 0 deletions feature-assets/pipeline-segment-assembly/pipeline-receipt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"executionId": "227b03d5-2eb1-4f37-94bf-2b961dcb3174",
"status": "succeeded",
"originalS2Job": "df4bcc70-de62-548c-9b50-643d1a4ea450",
"steps": [
{
"itemId": "ad2996f2-afa6-45af-8935-40b897a72a90",
"kind": "generation",
"status": "succeeded",
"jobId": "9d0b06f6-86c8-5b7a-86d1-881751f35da0"
},
{
"itemId": "e8b692e8-4dbe-4413-a70c-9149fb270fa0",
"kind": "generation",
"status": "cached",
"jobId": "df4bcc70-de62-548c-9b50-643d1a4ea450"
},
{
"itemId": "1e584d2f-b464-404c-b6f3-f572c5d2ee6f",
"kind": "assembly",
"status": "succeeded",
"jobId": null
}
],
"outputAsset": "cae91f9a-b21c-5335-9c27-e1c0b8745d83"
}
Binary file not shown.
40 changes: 27 additions & 13 deletions packages/core/src/opendirector/application/creation_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,31 +459,42 @@ def _relative_position(position, parent_id, lookup, item_id):
origin = canvas_origin(parent_id, lookup, item_id=item_id)
return Point(x=position.x - origin.x, y=position.y - origin.y).model_dump()

def _validate_timeline(self, document, snapshot):
@classmethod
def require_editable_owner(cls, data, object_id):
for item in data['canvasItems']:
binding = item['binding']
ref = binding.get('objectRef') or binding.get('draftSpec')
attached = any(str(editor['id']) == str(object_id) for editor in item.get('editors', []))
if (ref and str(ref.get('id')) == str(object_id)) or attached:
cls._editable(data, item['id'])

def _validate_timeline(self, document, snapshot, *, staged=frozenset()):
from .creation_timeline import validate_timeline_resources
validate_timeline_resources(document.data, snapshot, self.assets)
validate_timeline_resources(document.data, snapshot, self.assets, staged=staged)

def _publish_render(self, data, payload):
def publish_render(self, data, payload, *, staged=frozenset()):
from .creation_timeline import timeline_source_refs
from opendirector.domain.creation.editors import timeline_duration
item = self._editable(data, payload.itemId)
if item['kind'] != 'timeline' or item['binding']['objectRef']['id'] != str(payload.editorId):
raise ContractError('reference_invalid', '合成来源不是当前时间线。', payload.itemId)
snapshot = ProjectSnapshot.model_validate(data)
doc = next(d for d in snapshot.editorDocuments if d.id == payload.editorId)
self._validate_timeline(doc, snapshot)
self._validate_timeline(doc, snapshot, staged=staged)
output = self.assets._reference(snapshot, payload.asset)
if output.kind != 'video' or output.provenance.source != 'upload' or any(r.assetId == output.id for r in asset_references(snapshot)):
raise ContractError('role_restricted', '合成输出必须是尚未发布的视频素材。', output.id)
if any(r.assetId == output.id for record in self.projects.history(snapshot.project.id) for r in asset_references(record.snapshot)):
if output.id not in staged and any(r.assetId == output.id for record in self.projects.history(snapshot.project.id) for r in asset_references(record.snapshot)):
raise ContractError('role_restricted', '合成输出已有历史用途,不能改写来源。', output.id)
duration = timeline_duration(doc.data)
meta = output.metadata
if (meta.width, meta.height) != (doc.data.width, doc.data.height) or meta.durationSeconds is None or abs(meta.durationSeconds - duration) > max(.15, 2 / doc.data.fps):
raise ContractError('invalid_input', '合成视频的实际尺寸或时长与时间线不一致。', output.id)
sources = timeline_source_refs(doc.data)
for ref in (*sources, payload.asset):
self._available(self.assets._reference(snapshot, ref))
resolved = self.assets._reference(snapshot, ref)
if resolved.id not in staged:
self._available(resolved)
asset = self._get(data, 'asset', output.id)
existing = next((i for i in snapshot.canvasItems if i.id == payload.outputId), None)
if existing is not None:
Expand Down Expand Up @@ -512,7 +523,15 @@ def _mutate(self, data, kind, payload):
from .creation_media_publication import publish_media
publish_media(self, data, payload)
elif kind == 'timeline.publishRender':
self._publish_render(data, payload)
self.publish_render(data, payload)
elif kind == 'group.configureAssembly':
group = self._editable(data, payload.groupId)
if group['kind'] != 'group':
raise ContractError('role_restricted', '仅分组可以配置成片组装。', payload.groupId)
if payload.assembly is None:
group.pop('assembly', None)
else:
group['assembly'] = value['assembly']
elif kind == 'canvas.createGeneration':
self._mutate(data, 'generationSpec.create', SpecWrite(spec=payload.spec))
self._mutate(data, 'canvas.show', CanvasShow(item=payload.item, positionSpace=payload.positionSpace))
Expand All @@ -535,12 +554,7 @@ def _mutate(self, data, kind, payload):
immutable = ('kind', 'purpose', 'currentResultId') if key == 'spec' else ('kind',)
if any(obj[field] != old[field] for field in (*immutable, 'projectId')):
raise ContractError('role_restricted', '配置编辑不能修改对象角色或结果选择。', UUID(obj['id']))
for item in data['canvasItems']:
binding = item['binding']
ref = binding.get('objectRef') or binding.get('draftSpec')
attached = any(str(editor['id']) == str(obj['id']) for editor in item.get('editors', []))
if (ref and str(ref.get('id')) == str(obj['id'])) or attached:
self._editable(data, item['id'])
self.require_editable_owner(data, obj['id'])
old.update(obj)
elif kind in {'canvas.layoutRuns', 'canvas.layoutPipelines'}:
pass # The commit arranges the authoritative canvas after validating edits.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def execute(self, projects, command, *, session=None, source='ui', imported_from
return save_segment_plan(projects, command, session=session, source=source)
if command.type == 'group.publishRun':
return publish_segment_plan(projects, command, session=session, source=source)
if command.type == 'group.assemble':
from opendirector.application.creation_workflow_assembly import CreationWorkflowAssembly
return CreationWorkflowAssembly(projects).execute(command, session=session, source=source)
if command.type == 'project.create':
return projects._create(command, source)
if command.type in _HISTORY_COMMANDS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
from opendirector.domain.creation.base import ObjectVersion
from opendirector.domain.creation.commands import CommandReceipt, command_fingerprint
from opendirector.domain.creation.commands import parse_command
from opendirector.domain.creation.generation import (DEFAULT_MUSIC_SECONDS, InputSnapshot, Job, ResultVersion, execution_spec,
from opendirector.domain.creation.generation import (
resolve_h3_timeline_guide,DEFAULT_MUSIC_SECONDS, InputSnapshot, Job, ResultVersion, execution_spec,
reference_music_seconds, validate_generation)
from opendirector.domain.creation.models import ModelConfigPublic, ModelSnapshot
from opendirector.domain.creation.project import ProjectSnapshot
Expand Down Expand Up @@ -129,7 +130,14 @@ def task(self, job):
# Project accepted jobs without revalidating the current speech catalog.
profile = 'minimax-speech' if is_minimax_speech(config) else input_rules(config)['profile']
assets = {a.id: a for a in self.projects.snapshot(job.projectId).assets}
reference_ids = [str(asset_id) for asset_id in transmitted_assets(job.inputSnapshot.references)]
segment = spec.parameters.h3Segment if spec.kind == 'video' else None
guide = resolve_h3_timeline_guide(spec, job.inputSnapshot.references)
guide_inputs = {'h3Segment': True} if segment is not None else {}
if guide is not None:
guide_inputs['h3Guide'] = dict(assetId=str(guide.asset.assetId), frames=segment.sourceFrames)
references = tuple(item for item in job.inputSnapshot.references
if guide is None or item.referenceId != guide.referenceId)
reference_ids = [str(asset_id) for asset_id in transmitted_assets(references)]
content = None
kling_content = None
if spec.promptContent is not None:
Expand Down Expand Up @@ -169,7 +177,7 @@ def task(self, job):
externalTaskId=job.externalTaskId, assetId=str(job.asset.assetId) if job.asset else None,
adopted=job.adopted, error=None, errorDetails=job.errorDetails.model_dump(mode='json') if job.errorDetails else None,
inputSnapshot={'references': {str(r.asset.assetId): r.asset.fingerprint for r in job.inputSnapshot.references}},
technicalCheck=job.technicalCheck.model_dump(mode='json') if job.technicalCheck else None, **adapter_content)
technicalCheck=job.technicalCheck.model_dump(mode='json') if job.technicalCheck else None, **adapter_content, **guide_inputs)

def _parameters(self, spec, config, node, records):
params = {'text': {'thinking': 'auto', 'max_tokens': 8192},
Expand Down Expand Up @@ -225,13 +233,13 @@ def _parameters(self, spec, config, node, records):
control = rules['profile'] == 'fasth3-omni' and node.get('videoMode') == 'control'
if control:
params = control_parameters(node, records, resolution=str(intent.get('resolution', 'auto')).upper())
params['seed'] = new_seed()
params['seed'] = spec.parameters.seed if spec.parameters.seed is not None else new_seed()
seconds = None # The control video sets the length.
elif 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()
params['seed'] = spec.parameters.seed if spec.parameters.seed is not None else new_seed()
elif rules['profile'] == 'standard-video':
params = {}
if seconds is None and config.get('videoCapabilities') and not control:
Expand Down Expand Up @@ -266,7 +274,8 @@ def _parameters(self, spec, config, node, records):
else:
apply_video_resolution(params, node, records, config, output)
if rules['profile'] in {'vllm-omni-h3', 'fasth3-omni'} and 'duration' in params:
params.update(video_frame_parameters(params['duration'], params.get('fps', FPS)))
segment_frames = params.get('num_frames') if rules['profile'] == 'fasth3-omni' and spec.parameters.h3Segment is not None else None
params.update(video_frame_parameters(params['duration'], params.get('fps', FPS), segment_frames))
if spec.kind in {'image', 'video'} and config['protocol'] == 'volcengine':
params['watermark'] = not self.settings.get()['removeWatermark']
if spec.kind == 'image' and input_rules(config)['profile'] == 'moss-image':
Expand Down
Loading
Loading