mirror of
https://github.com/nexu-io/openmotion.git
synced 2026-12-06 23:17:22 +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>
100 lines
6.9 KiB
TypeScript
100 lines
6.9 KiB
TypeScript
import type { LibraryGeneration } from './asset-library.ts';
|
|
import type { GenerationOptions } from './generation-options.ts';
|
|
import { openDesignImageReferenceCap } from './opendesign-models.ts';
|
|
/** Public contract shared by the model gateway, MCP and Studio. Never contains credentials. */
|
|
export const modalities = ['image', 'video', 'audio'] as const;
|
|
export type Modality = typeof modalities[number];
|
|
export { mediaProviders } from './provider-registry.ts';
|
|
/** Built-in media IDs and service-registered compatible connections share one route identity. */
|
|
export type ProviderId = string;
|
|
export type Model = {
|
|
id: string; provider: ProviderId; modelId: string; label: string; modality: Modality;
|
|
source: 'builtin' | 'live' | 'custom'; mode: string;
|
|
defaults?: Record<string, unknown>; description?: string;
|
|
/** Cloud: true/false is explicit provider evidence; absent means editing capability is unknown. */
|
|
supportsImageReference?: boolean;
|
|
/** Most input images the provider accepts: edit references for images, a first frame for video. */
|
|
maxInputImages?: number;
|
|
/** Provider-published native options (durations, resolutions, ratios, quality, sizes) shown during discovery. */
|
|
nativeOptions?: Record<string, unknown>;
|
|
/** Maintained, provider-native controls, shared by Studio and MCP discovery. */
|
|
generationOptions?: GenerationOptions;
|
|
};
|
|
export type Agent = { id: string; label: string; installed: boolean; authenticated: boolean;
|
|
imageGeneration: boolean; available: boolean; reason: string };
|
|
/** Advisory hints for signed-in accounts only; absent for signed-out or expired sessions. */
|
|
export type AccountMediaEntitlement = { mediaEntitlement: 'included' | 'not-included' | 'unknown'; plan?: string; hasBalance?: boolean };
|
|
export type ProviderState = { id: ProviderId; label: string; enabled: boolean; configured: boolean;
|
|
available: boolean; credentialSource: 'stored' | 'environment' | 'local-agent' | 'account' | 'none';
|
|
verification: 'unverified' | 'verified' | 'rejected'; reason: string; checkedAt?: number; baseUrl?: string } & Partial<AccountMediaEntitlement>;
|
|
export type GatewayStatus = { providers: ProviderState[]; agents: Agent[];
|
|
routes: Partial<Record<Modality, string>>;
|
|
capabilities: { modality: Modality; available: boolean; modelIds: string[]; selectedModelId?: string }[];
|
|
consoleUrl?: string };
|
|
export type GenerateInput = { modality: Modality; prompt: string; model?: string;
|
|
mode?: string;
|
|
projectId?: string; parameters?: Record<string, unknown>; idempotencyKey?: string;
|
|
/** Workspace assets can be generated without creating or selecting a film project. */
|
|
library?: LibraryGeneration;
|
|
/** Project-relative input image. Supported only by explicitly capable adapters. */
|
|
referenceAsset?: string;
|
|
/** Reserved for editor consumers. Recorded only; does not silently edit a composition. */
|
|
usage?: { compositionId?: string; elementId?: string; property?: string } };
|
|
export type GeneratedAsset = { path: string; mimeType: string; bytes: number; available?: boolean };
|
|
export type GenerationJob = { id: string; projectId?: string; library?: LibraryGeneration & { assetId: string; createNew?: boolean }; libraryAssets?: { assetId: string; versionId: string }[]; state: 'queued' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
/** New generation results also belong to the local workspace library. */
|
|
saveToLibrary?: boolean;
|
|
/** Existing outputs are eligible for retry_save without another generation. */
|
|
savePending?: boolean;
|
|
providerOrigin?: string;
|
|
providerRevision?: string;
|
|
modality: Modality; prompt: string; model: Model; parameters: Record<string, unknown>;
|
|
usage?: GenerateInput['usage']; idempotencyKey?: string; requestHash: string;
|
|
reference?: { path: string; sha256: string; mimeType: string; bytes: number };
|
|
/** Every snapshotted input image in submission order; `reference` remains the first one for older readers. */
|
|
references?: { path: string; sha256: string; mimeType: string; bytes: number }[];
|
|
/** Provider result metadata kept with the job, such as speech timestamps. */
|
|
result?: Record<string, unknown>;
|
|
/** Cloud confirmed failure/cancellation; polling cannot recover this task. */
|
|
remoteTerminal?: boolean;
|
|
/** Original account image transfer; signed URLs and credentials are never persisted. */
|
|
download?: { assetId: string; receivedBytes: number; totalBytes: number };
|
|
createdAt: number; updatedAt: number; startedAt?: number; workerPid?: number;
|
|
phase: string; errorCode?: string; error?: string; remoteId?: string; assets: GeneratedAsset[] };
|
|
|
|
/** Effective adapter input contract, shared by service validation and existing Studio controls. */
|
|
export function modelReferenceLimit(model: Model): number {
|
|
if (model.modality === 'image' && model.supportsImageReference) {
|
|
if (model.provider === 'codex') return 1;
|
|
const cap = ['opendesign', 'account'].includes(model.provider) ? openDesignImageReferenceCap(model.modelId) : undefined;
|
|
// Earlier Cloud syncs persisted a synthetic maxInputImages: 1 when nativeOptions omitted max_input_images.
|
|
const syntheticCloudFallback = model.provider === 'opendesign' && model.maxInputImages === 1
|
|
&& Boolean(model.nativeOptions) && !(Number.isInteger(model.nativeOptions?.max_input_images) && (model.nativeOptions!.max_input_images as number) > 0);
|
|
const declared = syntheticCloudFallback ? undefined : model.maxInputImages;
|
|
// OpenDesign catalogues without an explicit max_input_images fall back to the measured limit (unknown models stay at 1).
|
|
return Math.min(declared ?? cap ?? 1, cap ?? Infinity);
|
|
}
|
|
return model.modality === 'video' ? Math.min(model.maxInputImages ?? 0, 1) : 0;
|
|
}
|
|
/** Local eligibility; the service additionally rechecks project, origin and credentials. */
|
|
export function resumableJob(job: GenerationJob): boolean {
|
|
return (job.model.provider === 'opendesign' || job.model.provider === 'account' && job.modality === 'image') && typeof job.remoteId === 'string' && /^[a-zA-Z0-9_-]{1,180}$/.test(job.remoteId)
|
|
&& job.state === 'failed' && !job.savePending && !job.remoteTerminal
|
|
&& !confirmedRemoteTerminal(job)
|
|
&& !legacyRemoteTerminal(job);
|
|
}
|
|
function confirmedRemoteTerminal(job: GenerationJob): boolean {
|
|
const err = job.result && typeof job.result === 'object' && !Array.isArray(job.result)
|
|
? (job.result as { error?: unknown }).error
|
|
: undefined;
|
|
return Boolean(err && typeof err === 'object' && !Array.isArray(err) && (err as { outcomeUnknown?: unknown }).outcomeUnknown === false);
|
|
}
|
|
/** Shared resume limitation reused across MCP tool descriptions, integration guides and the Studio handbook. */
|
|
export const CLOUD_RESUME_LIMITATION =
|
|
'Cancelled jobs, confirmed remote failures and failed Cloud audio tasks cannot resume.';
|
|
|
|
/** Earlier adapters recorded a Cloud-confirmed failure/cancellation only in the error message. */
|
|
export function legacyRemoteTerminal(job: GenerationJob): boolean {
|
|
return /^OpenDesign Cloud task (failed|cancelled)\b|^Account media task failed\./.test(job.error ?? '');
|
|
}
|