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 MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ include build_backend.py setup.py pyproject.toml README.md README.zh-CN.md
include package.json package-lock.json index.html tsconfig.json vite.config.ts .nvmrc
recursive-include src *
recursive-include packages/core/src *.py
recursive-include packages/core/src/opendirector/application/motion_runtime *
recursive-include apps/api/src *.py
include apps/api/src/opendirector_api/example-canvases.json
recursive-include packages/agent/skills *
recursive-include packages/agent/motion-skills *
prune packages/core/src/opendirector/_bundled
prune node_modules
prune dist
Expand Down
6 changes: 6 additions & 0 deletions apps/api/src/opendirector_api/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from opendirector.domain.timeline_errors import timeline_error, timeline_error_message
from opendirector.infrastructure.creation_projects import CreationProjects
from opendirector.media.fonts import MAX_FONT_BYTES, inspect_font
from opendirector.media.system_fonts import list_local_system_fonts
from opendirector_api.models import AssetSource, Session, UrlSource
from opendirector_api.localization import localized_receipt

Expand Down Expand Up @@ -104,6 +105,11 @@ def localized_video_task(request: Request, task: VideoConversionTask) -> VideoCo
),
})

@router.get('/fonts/local')
def local_system_fonts(response: Response):
response.headers['Cache-Control'] = 'private, max-age=300'
return {'fonts': list(list_local_system_fonts())}

@router.post('/fonts/inspect', response_model=FontCoverageResponse)
async def inspect_preview_font(request: Request, response: Response,
content_length: int | None = Header(default=None, ge=0)):
Expand Down
34 changes: 34 additions & 0 deletions apps/api/src/opendirector_api/localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,42 @@
"antigravity_denied": "Antigravity requested a tool outside OpenDirector's allowed scope. It was denied and this turn has no reply.",
"antigravity_empty": "Antigravity returned no reply for this turn. Check the native trace.",
"agent_dependency_unavailable": "Bundled Agent is unavailable. Reinstall with pip install --force-reinstall opendirector; for a source checkout, use pip install -e .",
"motion_model_missing": "No chat/agent model is configured. Add an Agent model in Model Settings first.",
"motion_media_missing": "One or more connected media assets referenced by this composition are missing or unreadable. Reconnect the media node and try again.",
"motion_chrome_not_found": "Chrome or Chromium is required for Web Motion MP4 export. Install Google Chrome or set OPENDIRECTOR_CHROME_BIN.",
"motion_ffmpeg_not_found": "FFmpeg is required for Web Motion MP4 export. Install ffmpeg and ensure it is on PATH.",
"motion_render_not_found": "Render job not found.",
"motion_render_not_ready": "Render job is not finished yet.",
"motion_render_missing": "Rendered video file is missing.",
"motion_render_failed": "Web Motion MP4 render failed.",
"motion_render_cancelled": "Web Motion MP4 render was cancelled.",
"motion_render_project_mismatch": "Render job does not belong to the target project.",
"motion_inspect_failed": "Frame inspection failed. Please try again.",
"motion_inspect_cancelled": "Frame inspection was cancelled.",
"motion_inspect_timeout": "Frame inspection timed out. Please try again.",
"motion_chat_failed": "Motion Director chat failed. Please try again.",
"motion_api_unavailable": "Motion commands require a running API. Start the API and check OPENDIRECTOR_API_URL.",
"motion_provider_input": "The model service rejected the input or parameters. Check your request and model capabilities.",
"motion_provider_reference": "The model service rejected the reference media. Replace the reference asset and try again.",
"motion_provider_authentication": "Model service authentication failed. Check the API key in Model Settings.",
"motion_provider_permission": "The model service denied access. Check your API key, model permissions, and safety policy.",
"motion_provider_quota": "Model account balance or quota is insufficient. Check your account quota and try again.",
"motion_provider_rate_limit": "The model service is busy or rate-limited. Wait a moment and try again.",
"motion_provider_temporary": "The model service is temporarily unavailable. Please try again later.",
"motion_provider_protocol": "The model service returned an invalid response. Check the model configuration and try again.",
"motion_provider_error": "The model service could not complete the request. Please try again.",
"motion_empty_message": "Enter a motion instruction before sending.",
"motion_output_length_limit": "The generated motion code exceeded the model's single-turn output limit and was truncated. Try lowering Thinking effort (or turning it off), or break the request into smaller steps.",
"motion_thinking_length_limit": "Model reasoning exhausted the single-turn output limit before producing motion code. Lower Thinking effort to Off or Low and try again.",
"chat_thinking_length_limit": "The model's reasoning exhausted the maximum output token limit before producing a reply. Increase the max output tokens or lower the thinking effort and try again.",
"chat_output_length_limit": "The model response reached the maximum output token limit and was truncated. Increase the max output tokens and try again.",
"chat_content_filtered": "The model response was blocked by the provider's content safety rules. Adjust the prompt and try again.",
"chat_incomplete_response": "The model response did not finish normally (it may have hit a length limit or content filter). Any generated content has been preserved.",
"invalid_input": "The request is invalid. Check the required fields and their formats.",
"invalid_project": "The project or asset identifier is invalid.",
"missing_object": "The requested item no longer exists.",
"not_found": "The requested item no longer exists.",
"command_conflict": "This identifier was already used with different input. Use a new identifier.",
"revision_conflict": "This item changed since it was loaded. Reload it and try again.",
"preview_expired": "The preview expired. Generate it again.",
"reference_invalid": "A reference is no longer valid. Select it again and retry.",
Expand Down Expand Up @@ -224,6 +256,8 @@ def localized_error_for_language(
return 'The trim ends after the source video. Choose an end time within the source duration.'
if status == 409 and chinese == '此视频裁切正在进行,请等待结果。':
return 'This trim is already running. Wait for its result.'
if status == 409 and chinese == '此动效发布正在进行,请等待结果。':
return 'This motion publication is already running. Wait for its result.'
if code == 'reference_invalid':
chat = re.fullmatch(r'聊天引用 ([0-9a-f-]+) 的来源或素材版本已失效,请重新选择此引用。', chinese)
if chat:
Expand Down
16 changes: 14 additions & 2 deletions apps/api/src/opendirector_api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
from opendirector.application.model_availability import ModelAvailability
from opendirector.application.preferences import Preferences
from opendirector.application.prompt_optimization import PromptOptimization
from opendirector.application.motion_generation import MotionGeneration
from opendirector.application.motion_web_render import motion_web_render_manager
from opendirector.application.tool_tasks import ToolTasks
from opendirector.application.creation_tool_assets import CreationToolAssets
from opendirector.infrastructure.local_projects import LocalProjects
Expand All @@ -29,6 +31,7 @@
from opendirector.integrations.chat_completions import ChatCompletions
from opendirector_api.creation import creation_routes, preview_until_disconnect
from opendirector_api.agent import agent_routes
from opendirector_api.motion import motion_routes
from opendirector_api.library import library_routes
from opendirector_api.voices import voice_routes
from opendirector_api.examples import router as example_routes
Expand Down Expand Up @@ -67,6 +70,7 @@ def create_app(store: LocalProjects | None = None, chat_provider=None, generatio
creation_tools = ToolTasks(store, model_configs, CreationToolAssets(creation_projects), projects=creation_projects, availability=availability)
creation_generation.tool_tasks = creation_tools
catalog = ModelCatalog(model_configs, chat_provider or ChatCompletions(), availability)
motion_generation = MotionGeneration(model_configs, chat_provider or ChatCompletions())

active_agents = {}

Expand All @@ -86,6 +90,7 @@ async def lifespan(app):
await pipelines.close()
await creation_tools.close()
finally:
motion_web_render_manager.shutdown()
await creation_generation.close()
availability.probe.close()

Expand All @@ -94,12 +99,13 @@ async def lifespan(app):
PromptOptimization(creation_projects, model_configs, chat_provider or ChatCompletions(),
cli_rewrite=_cli_prompt_rewrite)))
app.include_router(agent_routes(creation_projects, creation_generation, model_configs, chat_provider, active=active_agents))
app.include_router(motion_routes(motion_generation, projects=creation_projects))
app.include_router(library_routes(creation_projects))
app.include_router(voice_routes(creation_generation.voices))
app.include_router(example_routes)
app.state.desktop_activity = lambda: dict(
agents=len(active_agents), generations=sum(not job.future.done() for job in creation_generation.jobs.values()),
tools=sum(not job.done() for job in creation_tools.jobs.values()))
tools=sum(not job.done() for job in creation_tools.jobs.values()) + motion_web_render_manager.active_job_count())


@app.exception_handler(RequestValidationError)
Expand Down Expand Up @@ -348,7 +354,13 @@ def placement(project_id: UUID, task_id: UUID, value: ToolPlacement, x_opendirec
# StaticFiles confines reads to this directory and rejects escaping symlinks.
font_root = dist / "fonts"
if font_root.is_dir() and not font_root.is_symlink() and font_root.resolve().is_relative_to(dist.resolve()):
app.mount("/fonts", StaticFiles(directory=font_root), name="fonts")
class _CorsFontStaticFiles(StaticFiles):
async def get_response(self, path: str, scope):
response = await super().get_response(path, scope)
response.headers["Access-Control-Allow-Origin"] = "*"
return response

app.mount("/fonts", _CorsFontStaticFiles(directory=font_root), name="fonts")

@app.get("/")
def index():
Expand Down
Loading
Loading