Skip to content
Merged
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
2 changes: 2 additions & 0 deletions apps/api/src/opendirector_api/localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ def localized_error_for_language(
return translated
if code == 'command_conflict' and chinese == '该工程标识已经使用。':
return 'This project ID is already in use.'
if code == 'invalid_input' and chinese == '对象标识已存在。':
return 'This object ID is already in use.'
if code == 'invalid_input' and chinese == '聊天引用超过数量上限,请移除部分引用。':
return 'The chat reference limit was exceeded. Remove some references and retry.'
if code == 'invalid_input' and chinese == '视频裁切需要视频来源节点。':
Expand Down
8 changes: 8 additions & 0 deletions docs/guides/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ Agent 的 Shell 通过 PATH 使用同一个 `opendirector`。宿主提供受令

## 可编辑时间线文字与跨工程包

用 `opendirector timeline create --file timeline.json` 一次创建可编辑时间线及其画布节点。文件的 `payload.document` 保存完整时间线,`payload.itemId` 指定独立的新节点 ID。可选的 `title` 和 `position` 指定节点标题与画布位置。回执列出文档和节点。重试时保留相同的 `--operation-id` 和输入。仅需创建文档时使用 `editor create`。

写入 `timeline.create` 历史后,请使用支持该命令的版本打开工程。若需要切回旧版,请使用执行该命令前的工程备份。

时间线文字与媒体使用同一 `editor.create` / `editor.save` 文档,正文、时间、样式、层次和字体资产均保存在工程中。先通过 `query object.get` 读取文档,保留完整文档结构并携带当前 `editor_document` 版本提交;不要直接修改项目文件。`editor save --help` / `--help-field payload.document` 提供正式契约。正文来源是可选的不可变文本资产引用,不会随着来源后续变化自动改写文字。

```bash
Expand Down Expand Up @@ -125,6 +129,10 @@ Agent 执行上下文可使用相同命令,路径须位于本轮执行目录

### Editable timeline text and portable packages

Run `opendirector timeline create --file timeline.json` to create an editable timeline and its canvas node in one command. Set `payload.document` to the complete timeline and `payload.itemId` to a fresh node ID. Use the optional `title` and `position` fields to place and name the node. The receipt lists both objects. Reuse the same `--operation-id` and inputs on retry. Use `editor create` when you only need a document.

After `timeline.create` is recorded in the project history, open the project in a version that supports the command. To return to an older version, use a project backup from before the command ran.

Text uses the same complete `editor.create` / `editor.save` document as media. Read the current document with `query object.get`, preserve its structure, and submit its current `editor_document` revision. The schema and nested fields are available through `editor save --help` and `--help-field payload.document`. `timeline default-font` finds the bundled offline font without opening a project; import that file into the target project before referencing its AssetRef. Text-source references retain immutable provenance and do not automatically refresh the wording.

The commands above export an exact saved revision, import it as a new timeline, or explicitly replace a target with `--replace-editor` and `--expected-revision`. Export destinations must not already exist. Native `.timeline.zip` packages include all retained font, clip, media-library and text-source resources plus the bundled font license; target resources belong to the target project. The package limit is 512 MiB. Unknown versions/capabilities, missing resources, and fingerprint mismatches reject import. Only an `applied` receipt confirms the completed timeline write; retry incomplete operations with the same operation ID, file, and arguments. Replacement rechecks the current revision and owner/parent locks.
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/opendirector/agent/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def query_guidance(failure):
Use opendirector asset download with the saved asset ID and revision to inspect original bytes in the execution directory.
Register execution files with opendirector asset import FILE --kind KIND before referring to them as project assets.
For independently processed clips, register each execution file and add a material node. The video trim command publishes its own output asset and node. For Motion canvas nodes, publish rendered MP4s with opendirector motion render --publish-item-id so the video node stays linked to its source Motion node.
Use opendirector timeline create to deliver a new editable timeline on the canvas.
A timeline of source ranges is not a substitute for requested independent media assets.
Successful generation results are already registered project assets. Inspect them using their existing asset identity and canvas item. Do not publish inspection copies or extracted inspection frames, or add another canvas item for the same delivery unless the user requests it. Publish newly created deliverables after editing or processing.
A command receipt is execution evidence, not quality approval. Preserve user constraints.
Expand Down Expand Up @@ -285,6 +286,9 @@ def invalid_path(level: str, node: dict, requested: str) -> ProjectError:
spec['purpose'] = 'generation'
item['kind'] = spec['kind']
item['binding'] = {'role': 'generation', 'objectRef': {'id': spec['id']}}
if command == 'timeline.create':
example['payload']['document']['id'] = str(uuid5(project_id, 'example:timeline-document'))
example['payload']['itemId'] = str(uuid5(project_id, 'example:timeline-node'))
if command == 'generation.submit':
example['payload']['originItemId'] = str(project_id)
model = COMMANDS[command]
Expand Down
12 changes: 10 additions & 2 deletions packages/core/src/opendirector/application/creation_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

from opendirector.domain.creation.assets import AssetRef
from opendirector.domain.creation.base import CanvasItemVersion, ObjectVersion, Point
from opendirector.domain.creation.commands import CanvasShow, Query, ReferenceWrite, SpecWrite
from opendirector.domain.creation.commands import CanvasShow, EditorWrite, Query, ReferenceWrite, SpecWrite
from opendirector.domain.creation.generation import FollowingSource, ResolvedReference
from opendirector.domain.creation.canvas import CanvasReferenceSources, canvas_origin, FollowingReferenceSource, PinnedReferenceSource, media_card_size, node_capabilities, VideoCanvasItem
from opendirector.domain.creation.canvas import CanvasReferenceSources, canvas_origin, FollowingReferenceSource, PinnedReferenceSource, media_card_size, node_capabilities, TimelineCanvasItem, VideoCanvasItem
from opendirector.domain.creation.models import ModelConfigPublic
from opendirector.domain.creation.project import ProjectSnapshot, asset_references
from opendirector.domain.creation.index import object_index
Expand Down Expand Up @@ -520,6 +520,14 @@ def _mutate(self, data, kind, payload):
if kind == 'canvas.publishMedia':
from .creation_media_publication import publish_media
publish_media(self, data, payload)
elif kind == 'timeline.create':
if any(item['id'] == str(payload.itemId) for item in data['canvasItems']):
raise ContractError('invalid_input', '对象标识已存在。', payload.itemId)
self._mutate(data, 'editor.create', EditorWrite(document=payload.document))
item = TimelineCanvasItem(id=payload.itemId, projectId=payload.document.projectId,
kind='timeline', title=payload.title, position=payload.position,
binding=dict(role='editor', objectRef=dict(id=payload.document.id, kind='timeline')))
self._mutate(data, 'canvas.show', CanvasShow(item=item))
elif kind == 'timeline.publishRender':
self._publish_render(data, payload)
elif kind == 'canvas.createGeneration':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

EDITABLE = {'canvasItems', 'generationSpecs', 'references', 'editorDocuments'}
ABSENT = object()
UNDOABLE = {'canvas.createGeneration', 'creation.batch', 'canvas.show', 'canvas.hide', 'canvas.move', 'canvas.update', 'canvas.layoutRuns', 'canvas.layoutPipelines', 'canvas.configure',
UNDOABLE = {'canvas.createGeneration', 'timeline.create', 'creation.batch', 'canvas.show', 'canvas.hide', 'canvas.move', 'canvas.update', 'canvas.layoutRuns', 'canvas.layoutPipelines', 'canvas.configure',
'canvas.materialize', 'canvas.applyEdit', 'timeline.publishRender', 'canvas.publishMedia', 'canvas.applyVersion', 'canvas.exportVersion', 'canvas.attachEditor', 'canvas.detachEditor', 'generationSpec.update', 'generationSpec.restore',
'reference.add', 'reference.update', 'reference.restore', 'reference.remove', 'result.select', 'editor.save', 'generationSpec.setPrompt'}

Expand Down
14 changes: 11 additions & 3 deletions packages/core/src/opendirector/domain/creation/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from .segment_run import SegmentRunPlan
from .canvas import GroupAssembly, CanvasItem
from .contract_messages import contract_error, contract_text, kebab
from .editors import EditorDocument
from .editors import EditorDocument, TimelineDocument
from .pipeline import PipelineCachePolicy, PipelineScope
from opendirector.domain.rule_facts import PROMPT_MAX_LENGTH
from .generation import GenerationSpec, Job, PromptPart, Reference
Expand Down Expand Up @@ -276,6 +276,13 @@ class PipelineAdopt(Contract):
jobId: UUID = Field(description='Succeeded candidate job ID to adopt.')


class TimelineCreate(Contract):
document: TimelineDocument = Field(description='New editable timeline document. Assign a fresh document ID.')
itemId: UUID = Field(description='Fresh canvas node ID, distinct from the document ID.')
title: str = Field(default='', max_length=255, description='User-visible canvas node title.')
position: Point = Field(default_factory=Point, description='Position on the root canvas.')


class TimelinePublishRender(Contract):
itemId: UUID = Field(description='Canvas item ID.')
editorId: UUID = Field(description='Editable document ID.')
Expand Down Expand Up @@ -523,6 +530,7 @@ def missing_versions_message(self, supplied) -> str:
('CanvasApplyEditCommand', 'canvas.applyEdit', CanvasApplyEdit, 'Apply an editor result to a canvas item.'),
('VideoTrimCommand', 'video.trim', VideoTrim, 'Trim a source canvas video using its exact asset version, then publish a new video node and its edit snapshot.'),
('CanvasPublishMediaCommand', 'canvas.publishMedia', CanvasPublishMedia, 'Publish edited media outputs with their editor snapshot.'),
('TimelineCreateCommand', 'timeline.create', TimelineCreate, 'Create an editable timeline and its visible canvas node in one command.'),
('TimelinePublishRenderCommand', 'timeline.publishRender', TimelinePublishRender, 'Publish a rendered timeline result.'),
('PipelineStartCommand', 'pipeline.start', PipelineStart, 'Compile and start a durable concurrent Pipeline execution in the background.'),
('PipelinePauseCommand', 'pipeline.pause', PipelineControl, 'Pause an active Pipeline execution after its in-flight steps finish.'),
Expand All @@ -548,7 +556,7 @@ def missing_versions_message(self, supplied) -> str:
('JobRecoverCommand', 'job.recover', JobControl, 'Recover an existing job without creating a new attempt.'),
('JobCheckpointCommand', 'job.checkpoint', JobCheckpoint, 'Persist a job execution checkpoint.'),
('ResultSelectCommand', 'result.select', ResultSelect, 'Adopt an existing generation result.'),
('EditorCreateCommand', 'editor.create', EditorWrite, 'Create an editable document.'),
('EditorCreateCommand', 'editor.create', EditorWrite, 'Create an editable document only. Use timeline create for a visible timeline.'),
('EditorSaveCommand', 'editor.save', EditorWrite, 'Save an editable document.'),
('HistoryUndoCommand', 'history.undo', HistoryReplay, 'Undo a recorded reversible command.'),
('HistoryRedoCommand', 'history.redo', HistoryReplay, 'Reapply an undone command.'),
Expand All @@ -560,7 +568,7 @@ def missing_versions_message(self, supplied) -> str:
COMMAND_MODELS[_type] = _model
globals()[_name] = _model

_BATCH_TYPES = {'canvas.createGeneration', 'canvas.show', 'canvas.move', 'canvas.update', 'canvas.layoutRuns', 'canvas.layoutPipelines', 'canvas.hide', 'canvas.materialize', 'canvas.applyEdit',
_BATCH_TYPES = {'canvas.createGeneration', 'timeline.create', 'canvas.show', 'canvas.move', 'canvas.update', 'canvas.layoutRuns', 'canvas.layoutPipelines', 'canvas.hide', 'canvas.materialize', 'canvas.applyEdit',
'canvas.configure', 'canvas.attachEditor', 'canvas.detachEditor', 'generationSpec.create', 'generationSpec.update',
'reference.add', 'reference.update', 'reference.restore', 'reference.remove', 'editor.create', 'editor.save', 'result.select', 'generationSpec.setPrompt'}
_OPERATIONS = tuple(create_model(name + 'Operation', __base__=Contract,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def _canvas_placements(command, snapshot):
payload = operation.payload
if operation.type in {'canvas.show', 'canvas.createGeneration'} and payload.positionSpace is not None:
target_ids[payload.item.id] = None
elif operation.type == 'timeline.create':
target_ids[payload.itemId] = None
elif operation.type == 'canvas.move':
target_ids.update(dict.fromkeys(move.itemId for move in payload.items if move.positionSpace is not None))
elif operation.type == 'canvas.update' and (payload.position is not None or payload.preserveCanvasPosition):
Expand Down
Loading
Loading