mirror of
https://github.com/nexu-io/openmotion.git
synced 2026-12-07 00:27:17 +08:00
* [OPEND-5723] fix(cloud): stop offering checks for settled Cloud audio tasks A failed Cloud audio task never changes: the media API settles it once and never resubmits it, including when the outcome is audio_outcome_unknown. OpenMotion still treated that unknown outcome as resumable, so "Check original task" re-polled the same failed task and failed again, while the failure copy told users to inspect the task. - Mark failed or cancelled Cloud audio poll results as remote-terminal and persist that flag, so Studio hides the action and the resume API rejects it. - Explain that the original audio task cannot be checked again and that generating again creates a new request. - Replace the developer-facing resume refusal with a user-facing message that Studio localizes instead of the generic retry toast. - Document the resume boundary in the MCP descriptions and guides. * [OPEND-5742] fix(studio): limit Eleven Music duration to five minutes The Eleven Music v2 profile allowed 3-600 s because the ElevenLabs API documents a 600 s maximum. The OpenDesign media gateway gives each music request 360 s, so 599 s and 600 s requests ended with an unknown outcome and no track. - Cap music_length_ms at 300000 (five minutes, the length the ElevenLabs Music overview documents). Studio, MCP and REST share this profile, so longer values are corrected or rejected before any paid request. - Show the allowed range in the Sound Studio custom duration field. - Build on the OPEND-5721/5725 duration handling and update its tests. * [OPEND-5743] fix(studio): hide speech speed for Eleven v3 Studio offered 0.7-1.2x speed for Eleven v3 and the adapter forwarded it as voice_settings.speed, but ElevenLabs does not apply speed to Eleven v3: QA generated the same text at 0.8x and 1.2x with matching durations in three pairs (16/17 s, 45/45 s, 21/21 s). - Remove the speed field from the Eleven v3 profile so Studio no longer offers a control that has no effect. Kokoro keeps its speed control. - Note in the generation-options guide and the media skill that Eleven v3 ignores speed. A speed supplied in advanced parameters is still sent as voice_settings.speed. * [OPEND-5723] fix(cloud,studio): settle older audio failures and report check results QA retested on the assets page: failed BytePlus TTS 2.0 cards saved before this branch still offered "Check original task", and a check that ended in the same failure left the card unchanged, so users could not tell whether it had run. - Treat stored audio_outcome_unknown failures as settled when serializing and resuming jobs, and return the current message, so cards saved before audio failures recorded remoteTerminal stop offering the check. - Show "Checking original task…" while a check is queued, and report the original task's latest state in a toast once the check settles, including when nothing changed. - Localize the new results in every interface language. * [OPEND-5723] fix(cloud,studio): split resume errors, align mock gateway, handbook and i18n - Return reason-specific 409 guidance from resumeJob for non-failed jobs, savePending (pointing at retry_save), terminal remote failures (keeping regenerate), and missing remoteId, with matching translations across all interface locales. - Share buildGatewayPollError between OpenDesignModelGateway and MockModelGateway so mock audio failures mirror the remoteTerminal rule. - Share CLOUD_RESUME_LIMITATION across MCP tool descriptions, integration guidance and the Studio MCP handbook (library capability and recovery FAQ) with translations in all interface languages. - Translate Check original task and Checking original task... across all 10 non-English locales and extend locale regression tests. * [OPEND-5723] fix(studio): keep mcp-ui.json under 1 MiB by storing new handbook i18n in mcp-tools-ui.json --------- Co-authored-by: heggria <bshengtao@gmail.com>
62 lines
8.8 KiB
TypeScript
62 lines
8.8 KiB
TypeScript
import { brandKitToolArguments } from './brand-kit-tool.ts';
|
|
import { MAX_GENERATION_PROMPT_LENGTH } from './asset-limits.ts';
|
|
import { CLOUD_RESUME_LIMITATION } from './gateway.ts';
|
|
import { transcriptToolArguments, transcriptToolDescription } from './transcript-tool.ts';
|
|
import { scenarioToolArguments, scenarioToolDescription } from './scenario-runs.ts';
|
|
|
|
const id = { type: 'string', pattern: '^[a-f0-9]{8}(-[a-f0-9]{4}){3}-[a-f0-9]{12}$' };
|
|
const object = <T extends Record<string, unknown>>(properties: T, required: string[] = []) => ({ type: 'object', properties, required, additionalProperties: false });
|
|
const reference = object({ assetId: id, versionId: id }, ['assetId', 'versionId']);
|
|
export const assetLibraryTool = {
|
|
name: 'openmotion_assets', title: 'OpenMotion · Asset Library',
|
|
description: `Manage reusable workspace assets independently of film projects. list/get read images, video and audio, immutable versions and generation provenance. import copies a real local file (max 500 MB); generate uses the configured Model Gateway and returns a job, not finished media. First inspect providers/models through openmotion_media_use. Use stable requestId for import/generate/import_to_project, poll the original job with status, and never automatically resubmit a paid request. Project media generation also saves to this library. jobs/status include those new tasks. When savePending is true, retry_save with jobId and a stable requestId retries saving the existing outputs without submitting another generation. assetId + parentVersionId creates another version; references pin exact versions: image models with supportsImageReference edit with up to maxInputImages references (default one; local Codex and OpenDesign account editing take one), and video models that publish maxInputImages take one first-frame reference. update can rename, move to trash, restore from trash or select a current version; older bytes remain. import_to_project copies a pinned version into an explicit project using its normal import/history protections; it never places it on the timeline. Use resume with the original jobId and a stable requestId to check a failed/interrupted Cloud task or account image task with a known remoteId, without uploading inputs or submitting another paid generation. ${CLOUD_RESUME_LIMITATION} In Cloud, retry_save retrieves the original result while it is still available from the gateway. Regeneration is a separate paid request requiring authorization. Studio offers Check original task for Cloud jobs and Continue download for account images. Account image recovery reuses the original prompt/model and remote task; draft edits apply only to a new generation. Partial files resume only with verified asset identity, local checksum and strong ETag; otherwise the same image downloads from zero. Account video/audio recovery is not supported. Reference counts follow the selected model before any reference file is read; there is no fixed library count ceiling. Local Codex/account editing remains one image, video remains one first frame, and project referenceAsset remains image-only. Generated assets, imported project media and composition edits remain separate.`,
|
|
inputSchema: object({
|
|
action: { enum: ['list', 'get', 'import', 'update', 'generate', 'jobs', 'status', 'cancel', 'retry_save', 'resume', 'import_to_project'] },
|
|
requestId: { type: 'string', pattern: '^[\\w-]{1,100}$' }, assetId: id, versionId: id, parentVersionId: id, jobId: id,
|
|
projectId: { type: 'string', pattern: '^(project|[a-f0-9]{8}(-[a-f0-9]{4}){3}-[a-f0-9]{12})$' },
|
|
name: { type: 'string', minLength: 1, maxLength: 200, description: 'Readable display name: preserve meaningful user/source names; for generated, derived or unnamed media use content plus optional purpose, in the project namingLanguage. Supply with generate/import; import_to_project defaults to the saved library name and accepts a name only for explicit renames or missing-name repairs. Keep UUIDs in IDs and the full prompt in prompt.' }, sourcePath: { type: 'string', minLength: 1, maxLength: 4096 },
|
|
modality: { enum: ['image', 'video', 'audio'] }, audioKind: { enum: ['music', 'sfx', 'speech', 'upload'] }, source: { enum: ['upload', 'generated'] }, query: { type: 'string', maxLength: 200 },
|
|
trash: { type: 'boolean' }, sort: { enum: ['newest', 'oldest', 'name'] }, offset: { type: 'integer', minimum: 0 }, limit: { type: 'integer', minimum: 1, maximum: 100 },
|
|
model: { type: 'string', minLength: 1, maxLength: 300 }, prompt: { type: 'string', minLength: 1, maxLength: MAX_GENERATION_PROMPT_LENGTH },
|
|
mode: { enum: ['text-to-image', 'text-to-video', 'text-to-audio', 'text-to-speech'] }, parameters: { type: 'object', additionalProperties: true },
|
|
references: { type: 'array', items: reference, description: 'Pinned image versions in prompt order. The selected model limits the count: image edits up to its maxInputImages; video models with maxInputImages take one first frame.' }, conversationId: id,
|
|
changes: object({ name: { type: 'string', minLength: 1, maxLength: 200 }, trashed: { type: 'boolean' }, currentVersionId: id }),
|
|
}, ['action']),
|
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
};
|
|
|
|
export const assetUseTool = {
|
|
...assetLibraryTool, name: 'openmotion_assets_use', title: 'OpenMotion · Assets Use',
|
|
description: 'Preferred Agent route for new media: discover providers and full model IDs through openmotion_media_use inspect/reference/models, then generate, track the original job, inspect fixed versions and import only selected versions into a film project. No carrier project is needed. ' + assetLibraryTool.description + ' action=read requires assetId and versionId and returns bounded image previews, timestamped video frames or a mono 16 kHz WAV audio clip. get remains metadata-only. Read does not generate, create a project or change asset versions; retained trash is readable. Media interpretation/playback depends on the host.',
|
|
inputSchema: { ...assetLibraryTool.inputSchema, properties: { ...assetLibraryTool.inputSchema.properties,
|
|
action: { enum: [...assetLibraryTool.inputSchema.properties.action.enum, 'read'] },
|
|
timestamps: { type: 'array', minItems: 1, maxItems: 4, items: { type: 'number', minimum: 0 }, description: 'read video only: at most four frame times in seconds. Defaults to the first frame.' },
|
|
start: { type: 'number', minimum: 0, description: 'read audio only: clip start in seconds, default 0.' },
|
|
duration: { type: 'number', minimum: 0.1, maximum: 15, description: 'read audio only: clip length in seconds, default 10 (clipped to available audio), maximum 15.' },
|
|
}, oneOf: Object.entries({ list: [], get: ['assetId'], import: ['requestId', 'sourcePath'], update: ['assetId', 'changes'],
|
|
generate: ['requestId', 'model', 'modality', 'prompt'], jobs: [], status: ['jobId'], cancel: ['jobId'], retry_save: ['jobId', 'requestId'], resume: ['jobId', 'requestId'],
|
|
import_to_project: ['projectId', 'requestId', 'assetId', 'versionId'], read: ['assetId', 'versionId'] })
|
|
.map(([action, required]) => ({ type: 'object', properties: { action: { enum: [action] } }, required, additionalProperties: true })),
|
|
},
|
|
};
|
|
const workspaceActions = {
|
|
brand_kit: ['brandKit'],
|
|
transcript: ['transcript'],
|
|
scenario: ['scenario'],
|
|
list_components: [],
|
|
install_component: ['projectId', 'requestId', 'name'],
|
|
};
|
|
export const workspaceAssetUseTool = {
|
|
...assetUseTool,
|
|
description: assetUseTool.description + ' Use action=brand_kit with a brandKit command to browse, extract and manage style-only Brand Kits. Use get to read job status and expectedUpdatedAt for package or edits. Brand Kits never determine the film timeline.' + transcriptToolDescription + scenarioToolDescription + ' In cloud Studio, list_components searches motion effects by query (offset and limit paginate). install_component takes the selected name, projectId and requestId, preserves existing files, and returns project-relative paths. To install and place in one undo step, provide hostFile with the host path, observed baseVersion and edited content mounting the listed compositionFile. Omit hostFile to install for later use.',
|
|
annotations: { ...assetUseTool.annotations, destructiveHint: true },
|
|
inputSchema: {
|
|
...assetUseTool.inputSchema, properties: { ...assetUseTool.inputSchema.properties,
|
|
hostFile: object({ path: { type: 'string' }, baseVersion: { type: 'string' }, content: { type: 'string' } }, ['path', 'baseVersion', 'content']),
|
|
action: { enum: [...assetUseTool.inputSchema.properties.action.enum, ...Object.keys(workspaceActions)] }, brandKit: brandKitToolArguments, transcript: transcriptToolArguments, scenario: scenarioToolArguments },
|
|
oneOf: [...assetUseTool.inputSchema.oneOf, ...Object.entries(workspaceActions).map(([action, required]) => ({
|
|
type: 'object', properties: { action: { enum: [action] } }, required, additionalProperties: true,
|
|
}))],
|
|
},
|
|
};
|