Files
zooqueen ae80da5998 refactor(media-use): resolve every media type through api.hanzo.ai
Voice is POST /v1/audio/speech and word timings come from
POST /v1/audio/transcriptions over the rendered audio. Music, sound
effects, images, and video generate through /v1/audio/music,
/v1/audio/foley, /v1/images/generations, and /v1/videos/generations. The
shared catalog is a listing under media/<type>/ in our own object store,
browsed through /v1/s3 — an empty prefix reports itself as empty rather
than reading as a bad query.

One client (scripts/lib/api.mjs) holds every route and the one credential:
a Hanzo IAM token in $HANZO_API_KEY, read from Hanzo KMS. No credential
file, no per-repo .env, no per-provider CLI to install or keep current.
$HANZO_BASE_URL points the same code at a local Hanzo Engine.

Word timings are passed through, never interpolated: a caption cut on
invented boundaries reads as correct and drifts against the voice. When
the service returns text without them, the word array is empty and the
caller is told.

Deletes the provider cascade this replaces, its model ladders, and the
account linking in telemetry — the install id stands alone.
2026-08-13 17:18:37 -07:00

31 lines
916 B
JavaScript

import { tmpdir } from "node:os";
import { join } from "node:path";
import { image, write } from "./api.mjs";
import { asResult, find } from "./catalog.mjs";
const catalogSearch = (kind) => async (intent) => {
const hit = await find(kind, intent);
if (!hit || hit.empty) return null;
return asResult(hit, intent, kind);
};
export const imageProvider = {
search: catalogSearch("image"),
async generate(intent, ctx) {
const localPath = join(tmpdir(), `media-use-image-${process.pid}-${Date.now()}.png`);
write(await image({ prompt: intent, size: ctx?.size }), localPath);
return {
localPath,
ext: ".png",
source: "generated",
metadata: {
description: intent,
provider: "hanzo.image",
provenance: { prompt: intent, ...(ctx?.size ? { size: ctx.size } : {}) },
},
};
},
};
export const iconProvider = { search: catalogSearch("icon") };