asset-import

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Asset Import

资产导入

Check
browse_assets
first when a file may already be imported.
如果某个文件可能已经导入,请先检查
browse_assets
。

Same-machine editor import (preferred)

同一机器上的编辑器导入(首选)

  1. Open the target project using the clean
    editorUrl
    (the user can open it, or the browser agent may open it when asked). Keep exactly one editor tab for this project open, on the same machine/network namespace as your shell. A remote sandbox's localhost is not the user's localhost.
  2. Start the bundled server using an available Node.js 18+ runtime, and the origin of the actual editor URL:
bash
"<bundled-or-global-node>" <this-skill-dir>/scripts/serve-local-media.mjs --origin <editor-origin> /path/to/source.mp4
Keep this process alive using the host's background-process support while calling MCP. It prints one JSON line and automatically exits after 900 seconds. It serves only the listed files over loopback URLs without an access token. URLs use the public
chatcut-local-media-v1
path prefix to remain compatible with existing editors. Legacy token-prefixed URLs remain supported; the JSON
token
field contains that public prefix, not a credential.
  1. Import multiple files in one
    import_media
    call:
    {"action":"from_editor","files":[...]}
    . Copy each file's
    assetId
    ,
    url
    ,
    filename
    , and
    sizeBytes
    from the printed
    imports
    array into
    files
    , omitting its per-file
    action
    . Each URL may come from a different running helper. Send 1–16 files per call; for larger sets, submit successive batches of 16. Up to eight files are processed concurrently; the editor streams each one straight into its local store, so a card with transfer progress appears as soon as the download starts. There is no loopback-specific file-size cap. The original top-level single-file arguments still work.
  2. Inspect every entry in
    results
    : successful entries have
    ok:true
    and
    status:"locally_imported"
    ; failed entries have an
    error
    . Results preserve input order and include
    assetId
    and
    filename
    , with top-level
    succeeded
    /
    failed
    counts. Retry only failed files with the same asset IDs. Success means the editor has persisted local bytes and registered the asset locally. Stop the helpers only after all files succeed. Keep the editor open for server sync, background upload and transcription.
  3. Use the returned asset IDs for timeline work. Wait on
    track_progress target:"transcription"
    before transcript/caption work. Browser-renderable timelines defer original-file uploads; cloud-only or unsupported timelines upload automatically. Check
    browse_assets
    before waiting on
    target:"upload"
    ; a deferred upload is not in progress. Use the editor's Upload action when cloud bytes are needed, preserving the same asset ID. If server sync is still catching up, retry the asset lookup.
On timeout, check
browse_assets
and retry with the same assetId; the import may still be running, and a retry resumes an interrupted download from where it stopped rather than starting over. Keep the same ID even if restarting the helper changes its URL. Do not blindly start a second import. Allow the editor's browser local-network permission if prompted. If the editor cannot reach the helper or the bridge is unavailable, use the fallback. A host-policy denial is not permission to try another transfer route.
For visual analysis, inspect readable original files locally rather than waiting for cloud upload. Import original source assets; do not flatten an edit into a local pre-render.
  1. 使用干净的
    editorUrl
    打开目标项目(用户可以自行打开,也可以在收到要求时由 browser agent 打开)。确保仅为此项目打开一个编辑器标签页,并且该标签页与 shell 位于同一台机器/网络命名空间。远程 sandbox 的 localhost 不是用户的 localhost。
  2. 使用可用的 Node.js 18+ runtime 和实际编辑器 URL 的 origin 启动 bundled server:
bash
"<bundled-or-global-node>" <this-skill-dir>/scripts/serve-local-media.mjs --origin <editor-origin> /path/to/source.mp4
在调用 MCP 期间,使用宿主的后台进程支持使此进程保持运行。它会打印一行 JSON,并在 900 秒后自动退出。它仅通过 loopback URL 提供所列文件,不使用 access token。URL 使用公开的
chatcut-local-media-v1
path prefix,以保持与现有编辑器兼容。旧版带 token 前缀的 URL 仍受支持;JSON 中的
token
字段包含该公开前缀,而不是凭据。
  1. 在一次
    import_media
    调用中导入多个文件:
    {"action":"from_editor","files":[...]}
    。从打印的
    imports
    数组中将每个文件的
    assetId
    、
    url
    、
    filename
    和
    sizeBytes
    复制到
    files
    中,并省略每个文件自身的
    action
    。每个 URL 可以来自不同的运行中 helper。每次调用发送 1–16 个文件;更大的文件集应连续提交大小为 16 的批次。最多同时处理八个文件;编辑器会将每个文件直接以流式方式写入其本地存储,因此下载一开始就会出现带传输进度的卡片。loopback 专用路径没有文件大小上限。原有的顶层单文件参数仍然有效。
  2. 检查
    results
    中的每个条目:成功条目具有
    ok:true
    和
    status:"locally_imported"
    ;失败条目具有
    error
    。结果保持输入顺序,并包含
    assetId
    和
    filename
    ,同时在顶层提供
    succeeded
    /
    failed
    计数。仅使用相同的 asset ID 重试失败文件。成功意味着编辑器已持久化本地字节,并在本地注册该资产。仅在所有文件都成功后才能停止 helper。保持编辑器打开,以完成服务器同步、后台上传和转录。
  3. 使用返回的 asset ID 进行时间线工作。在进行转录/字幕工作之前,等待
    track_progress target:"transcription"
    。可由浏览器渲染的时间线会推迟原始文件上传;仅云端可用或不受支持的时间线会自动上传。在等待
    target:"upload"
    之前检查
    browse_assets
    ;推迟的上传并不表示上传正在进行。需要云端字节时,使用编辑器的 Upload 操作,同时保留相同的 asset ID。如果服务器同步仍在追赶进度,请重试资产查询。
超时后,检查
browse_assets
并使用相同的 assetId 重试;导入可能仍在运行,重试会从中断处恢复下载,而不会从头开始。即使重启 helper 改变了 URL,也要保持相同的 ID。不要盲目启动第二次导入。如果出现提示,请允许编辑器的浏览器本地网络权限。如果编辑器无法访问 helper 或 bridge 不可用,请使用 fallback。宿主策略拒绝并不表示可以尝试其他传输路径。
对于视觉分析,请在本地检查可读取的原始文件,而不要等待云端上传。导入原始源资产;不要将剪辑内容扁平化为本地预渲染文件。

Relink an existing asset

重新关联现有资产

For missing local media, preserve the existing asset and its timeline references:
  1. Get the existing
    assetId
    from
    browse_assets
    and locate its corresponding original source file.
  2. Serve that file with the same loopback helper above.
  3. Call
    import_media
    with the helper's
    url
    ,
    filename
    , and
    sizeBytes
    , but set
    action: "relink_from_editor"
    and replace the generated
    assetId
    with the existing assetId. For multiple files, use the same
    files
    array form, with an existing asset ID in every entry.
  4. Wait for
    status: "locally_relinked"
    before stopping the helper. Upload/transcription may still be pending; keep the editor open.
Relink always reads the supplied file, even if the editor has cached bytes. The media type must match. Use the corresponding original, not a different replacement clip: relink preserves existing edits and transcripts. If the target is missing from the editor, let project sync finish and retry. A failed relink must not fall back to creating a new asset.
对于缺失的本地媒体,请保留现有资产及其时间线引用关系:
  1. 从
    browse_assets
    获取现有
    assetId
    ,并找到对应的原始源文件。
  2. 使用上述同一个 loopback helper 提供该文件。
  3. 使用 helper 的
    url
    、
    filename
    和
    sizeBytes
    调用
    import_media
    ,但将
    action
    设置为
    "relink_from_editor"
    ,并将生成的
    assetId
    替换为现有 assetId。 对于多个文件,使用相同的
    files
    数组格式,并在每个条目中使用现有资产 ID。
  4. 等待
    status: "locally_relinked"
    ,然后再停止 helper。上传/转录可能仍处于待处理状态;保持编辑器打开。
重新关联始终会读取所提供的文件,即使编辑器已缓存字节。媒体类型必须匹配。请使用对应的原始素材,而不是不同的替代片段:重新关联会保留现有编辑和转录。如果编辑器中缺少目标资产,请等待项目同步完成后再重试。重新关联失败时,不得回退为创建新资产。

Upload-helper fallback

Upload-helper fallback

For a remote sandbox, unavailable editor, or blocked browser connection:
  1. Call
    import_media
    with
    {"action":"create_session"}
    .
  2. Run the bundled helper in the foreground, using the returned token and endpoint and at most four paths:
bash
"<bundled-or-global-node>" <this-skill-dir>/scripts/upload-media.mjs --token <token> --endpoint <endpoint> /path/to/source.mp4
Resolve scripts relative to this skill. Do not replace the helper with handwritten upload/transcode commands. MCP OAuth stays inside the MCP client; only the short-lived import token goes to the helper. Larger batches need a fresh session per four files.
The helper registers placeholders early but prints its final JSON after uploads complete. Read
imports[].result.assetId
. On an error with
retry
, obtain a fresh session and rerun the returned arguments to resume the same asset.
If host policy denies transfer, stop and ask the user to upload through the editor or grant permission. Do not work around the denial. Public URLs can be downloaded locally and then imported through the appropriate route above.
对于远程 sandbox、编辑器不可用或浏览器连接被阻止的情况:
  1. 使用
    {"action":"create_session"}
    调用
    import_media
    。
  2. 使用返回的 token 和 endpoint 在前台运行 bundled helper,每次最多传入四个路径:
bash
"<bundled-or-global-node>" <this-skill-dir>/scripts/upload-media.mjs --token <token> --endpoint <endpoint> /path/to/source.mp4
脚本路径应相对于此 skill 解析。不要用手写的上传/转码命令替换 helper。MCP OAuth 始终在 MCP client 内部处理;只有短期 import token 会传给 helper。较大的批次中,每四个文件需要使用新的 session。
helper 会尽早注册 placeholder,但在上传完成后才打印最终 JSON。读取
imports[].result.assetId
。遇到包含
retry
的错误时,获取新的 session,并按返回的参数重新运行,以继续处理同一资产。
如果宿主策略拒绝传输,请停止操作,并请用户通过编辑器上传或授予权限。不要绕过该拒绝。公共 URL 可以先下载到本地,再通过上述适当的路径导入。