The card's follow-ups now reach the media job RPCs, and it only offers what the space can run. - media.capabilities answers which operations the actor's space can run (booleans only). The card asks once per minute per space, and only when it shows finished video or audio, so other cards cost nothing. - Export and Transcribe call media.jobs.start with the card's message, so the same bot posts the new card; Cancel calls media.jobs.cancel. A refused start shows the server's message under the card. - New files use top-level import type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MRtGG9ARfqqhma3t85Ro2u
30 lines
1.2 KiB
TypeScript
30 lines
1.2 KiB
TypeScript
import type { MediaCapabilities, MediaRuntime } from "@rakazo/adapter-kit";
|
|
import type { PrismaClient } from "@rakazo/db";
|
|
import { ensureStudioBot } from "@rakazo/db";
|
|
import { getLogger } from "@rakazo/logging";
|
|
|
|
/**
|
|
* Generation or transcription only run once the deployment owner set up a media server; local
|
|
* edits (ffmpeg, image tools) are always there and alone do not call for a specialist.
|
|
*/
|
|
export function mediaBackendsConfigured(capabilities: MediaCapabilities): boolean {
|
|
return capabilities.generate_image || capabilities.generate_video || capabilities.transcribe;
|
|
}
|
|
|
|
/**
|
|
* Creates the user's Studio specialist the first time their main bot runs with a media server
|
|
* configured, so the specialist directory lists it from that run on. Never fails the run.
|
|
*/
|
|
export async function ensureStudioWhenMediaConfigured(
|
|
deps: { prisma: PrismaClient; media?: Pick<MediaRuntime, "capabilities"> },
|
|
run: { userId: string; spaceId: string },
|
|
): Promise<void> {
|
|
if (!deps.media) return;
|
|
try {
|
|
if (!mediaBackendsConfigured(await deps.media.capabilities(run.spaceId))) return;
|
|
await ensureStudioBot(deps.prisma, run.userId);
|
|
} catch (error) {
|
|
getLogger().error("studio specialist", error);
|
|
}
|
|
}
|