Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

7.3 KB
Raw Blame
import { request } from './apiCore.js';

export const listCodeAnimationProjects = ({ cursor, signal, limit = 50 } = {}) =>
  request(`/code-animation/projects?limit=${limit}${cursor ? `&cursor=${encodeURIComponent(cursor)}` : ''}`, { signal, silent: true });
export const createCodeAnimationProject = (input, options) => request('/code-animation/projects', { method: 'POST', body: JSON.stringify(input), ...options });
export const getCodeAnimationProject = (id, options) => request(`/code-animation/projects/${encodeURIComponent(id)}`, options);
export const updateCodeAnimationProject = (id, input, options) => request(`/code-animation/projects/${encodeURIComponent(id)}`, { method: 'PATCH', body: JSON.stringify(input), ...options });
export const importCodeAnimationPackage = (id, pkg, options) => request(`/code-animation/projects/${encodeURIComponent(id)}/import`, { method: 'POST', body: JSON.stringify(pkg), ...options });
export const acceptCodeAnimationSource = (id, revisionId, options) => request(`/code-animation/projects/${encodeURIComponent(id)}/accept`, { method: 'POST', body: JSON.stringify({ revisionId }), ...options });
export const getCodeAnimationProjectBrief = (id, options) => request(`/code-animation/projects/${encodeURIComponent(id)}/brief`, options);
export const getCodeAnimationRevisionPackage = (id, revisionId, options) => request(`/code-animation/projects/${encodeURIComponent(id)}/revisions/${encodeURIComponent(revisionId)}/package`, options);
export const listCodeAnimationProjectHistory = (id, { cursor, signal, limit = 50 } = {}) =>
  request(`/code-animation/projects/${encodeURIComponent(id)}/history?limit=${limit}${cursor ? `&cursor=${encodeURIComponent(cursor)}` : ''}`, { signal, silent: true });

// Code Animation — build an LLM prompt for a procedurally coded animation film
// styled by a universe (plus mood board, references, audio), and optionally run
// it on a provider to get the film's HTML. `options` is forwarded to the
// request helper so callers owning their error UI can pass `{ silent: true }`.

export const getCodeAnimationOptions = (options) => request('/code-animation/options', options);

// The vendored three.js modules (path + source) a three-renderer preview inlines.
export const getCodeAnimationThreeVendor = (options) => request('/code-animation/vendor/three', options);

// Ask a model to WRITE the brief from the chosen universe's bible and canon cast.
export const generateCodeAnimationBrief = (input, options) => request('/code-animation/brief', {
  method: 'POST',
  body: JSON.stringify(input),
  ...options,
});

export const buildCodeAnimationPrompt = (brief, options) => request('/code-animation/prompt', {
  method: 'POST',
  body: JSON.stringify(brief),
  ...options,
});

export const startCodeAnimationGeneration = (brief, options) => request('/code-animation/generate', {
  method: 'POST',
  body: JSON.stringify(brief),
  ...options,
});

export const listCodeAnimationJobPage = ({ cursor, signal, limit = 50 } = {}) =>
  request(`/code-animation/jobs?limit=${limit}${cursor ? `&cursor=${encodeURIComponent(cursor)}` : ''}`,
    { signal, silent: true });

// `version` is the poster's mtime from the jobs page; the server caches each URL forever.
export const codeAnimationPosterUrl = (id, version) =>
  `/api/code-animation/jobs/${encodeURIComponent(id)}/poster?v=${encodeURIComponent(version)}`;

// Resolves { posterVersion } once captured (null when the page drew nothing); captures run one at a time.
export const requestCodeAnimationPoster = (id, options) =>
  request(`/code-animation/jobs/${encodeURIComponent(id)}/poster`, { method: 'POST', ...options });

// Its HTML and poster go to the system Trash; Media History exports stay.
export const deleteCodeAnimationJob = (id, options) =>
  request(`/code-animation/jobs/${encodeURIComponent(id)}`, { method: 'DELETE', ...options });

export const getCodeAnimationJob = (id, options) =>
  request(`/code-animation/generate/${encodeURIComponent(id)}`, options);

export const getCodeAnimationPackage = (id, options) =>
  request(`/code-animation/${encodeURIComponent(id)}/package`, options);

// Queue a frame-exact MP4 export; returns { jobId, notes }. Progress streams
// from /api/html-composition/:jobId/events.
export const exportCodeAnimation = (id, options) => request(`/code-animation/${encodeURIComponent(id)}/export`, {
  method: 'POST',
  ...options,
});

// Cancel a queued/running export; the renderer removes its partial output.
export const cancelCodeAnimationExport = (exportJobId, options) => request(`/html-composition/${encodeURIComponent(exportJobId)}/cancel`, {
  method: 'POST',
  ...options,
});

export const preflightCodeAnimationProject = (id, options) => request(`/code-animation/projects/${encodeURIComponent(id)}/preflight`, options);

// Contained production execution (#9388): capability report, operator tool
// paths, and the on-demand adversarial containment check.
export const startCodeAnimationStageRun = (id, input, options) => request(`/code-animation/projects/${encodeURIComponent(id)}/stage-runs`, { method: 'POST', body: JSON.stringify(input ?? {}), ...options });
export const cancelCodeAnimationStageRun = (id, runId, options) => request(`/code-animation/projects/${encodeURIComponent(id)}/stage-runs/${encodeURIComponent(runId)}/cancel`, { method: 'POST', ...options });
export const getCodeAnimationExecution = (options) => request('/code-animation/execution', options);
export const updateCodeAnimationExecutionTools = (tools, options) => request('/code-animation/execution/tools', { method: 'PUT', body: JSON.stringify(tools), ...options });
export const probeCodeAnimationExecution = (options) => request('/code-animation/execution/probe', { method: 'POST', ...options });

// Explicit production workflows. Preview and final use the stored soundtrack artifact.

export const getCodeAnimationBlenderStarter = options => request('/code-animation/packages/starter/blender', options);

// Production acceptance (#9392): the accepted output with live freshness, side-by-side run
// evidence, and explicit promotion of one passing run.
export const getCodeAnimationAcceptance = (id, options) => request(`/code-animation/projects/${encodeURIComponent(id)}/acceptance`, options);
export const acceptCodeAnimationOutput = (id, runId, options) => request(`/code-animation/projects/${encodeURIComponent(id)}/accepted-output`, { method: 'POST', body: JSON.stringify({ runId }), ...options });

// Film style grammar catalog (#10253). The list is the picker projection; the
// full record carries each native move's "fits content like" examples.
export const listFilmStyles = (options) => request('/film-styles', options);
export const getFilmStyle = (id, options) => request(`/film-styles/${encodeURIComponent(id)}`, options);

// Render a soundtrack for a finished animation with a local music engine,
// without re-running the animation. body: { prompt, engine, modelId?,
// instrumentalOnly } → the job's `soundtrack` record (watch `mediaJobId`).
export const generateCodeAnimationSoundtrack = (id, body, options) => request(`/code-animation/${encodeURIComponent(id)}/soundtrack`, {
  method: 'POST',
  body: JSON.stringify(body),
  ...options,
});
// The soundtrack track a coded score saves its take onto (created on first use).
export const ensureCodeAnimationSoundtrackTrack = (id, options) => request(`/code-animation/${encodeURIComponent(id)}/soundtrack/track`, {
  method: 'POST',
  ...options,
});