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

feat: offer agent-composed launch video music without installed engines

[._.]/ Adam Eivy14e51a76b7f6
diff --git a/client/src/components/apps/LaunchVideoPanel.jsx b/client/src/components/apps/LaunchVideoPanel.jsx
index 4e41eaa791..1adac35351 100644
--- a/client/src/components/apps/LaunchVideoPanel.jsx
+++ b/client/src/components/apps/LaunchVideoPanel.jsx
@@ -29,6 +29,7 @@ function LaunchVideoForm({ appId, onQueued }) {
const [motionGraphics, setMotionGraphics] = useState(false);
const [music, setMusic] = useState(false);
const [generateMusic, setGenerateMusic] = useState(false);
+ const [musicMethod, setMusicMethod] = useState('agent');
const [musicTrack, setMusicTrack] = useState('');
const [tracks, setTracks] = useState(null);
const [error, setError] = useState('');
@@ -48,7 +49,7 @@ function LaunchVideoForm({ appId, onQueued }) {
submitting.current = true;
await createAppLaunchVideo(appId, {
tone, direction, format, targetDurationSec: duration, motionGraphics,
- ...(music ? (generateMusic ? { generateMusic: true } : { musicTrack }) : {}),
+ ...(music ? (generateMusic ? { generateMusic: true, musicMethod } : { musicTrack }) : {}),
...picker.pin,
}, { silent: true }).then(onQueued).finally(() => { submitting.current = false; });
});
@@ -65,7 +66,15 @@ function LaunchVideoForm({ appId, onQueued }) {
<div><label htmlFor="launch-duration">Duration (15–120 seconds)</label><input id="launch-duration" type="number" min={15} max={120} step={1} required className={inputClass} value={duration} onChange={event => setDuration(event.target.value === '' ? '' : Number(event.target.value))} /></div>
<div><label htmlFor="launch-motion-graphics"><input id="launch-motion-graphics" type="checkbox" checked={motionGraphics} onChange={event => setMotionGraphics(event.target.checked)} /> Dynamic motion graphics</label><p className="text-sm text-port-text-muted">Beat-cut showreel style: kinetic type, color-field swaps and generative shapes around the key flow.</p></div>
<div><label htmlFor="launch-music"><input id="launch-music" type="checkbox" checked={music} onChange={event => setMusic(event.target.checked)} /> Include music</label></div>
- {music && <div><label htmlFor="launch-generate-music"><input id="launch-generate-music" type="checkbox" checked={generateMusic} onChange={event => setGenerateMusic(event.target.checked)} /> Generate original music</label><p className="text-sm text-port-text-muted">The agent uses your configured music engine; provider charges may apply.</p></div>}
+ {music && <div><label htmlFor="launch-generate-music"><input id="launch-generate-music" type="checkbox" checked={generateMusic} onChange={event => setGenerateMusic(event.target.checked)} /> Generate original music</label><p className="text-sm text-port-text-muted">Choose how the original soundtrack is made.</p></div>}
+ {music && generateMusic && <div>
+ <label htmlFor="launch-music-method">Music creation</label>
+ <select id="launch-music-method" className={inputClass} value={musicMethod} onChange={event => setMusicMethod(event.target.value)}>
+ <option value="agent">Agent composition (no music model required)</option>
+ <option value="service">Configured music service</option>
+ </select>
+ <p className="text-sm text-port-text-muted">{musicMethod === 'agent' ? 'The agent writes an instrumental score using available synthesis tools, such as Web Audio or Tone.js.' : 'Uses a ready PortOS music engine. Setup and provider charges may apply.'}</p>
+ </div>}
{music && !generateMusic && <fieldset className="space-y-2">
<legend>Music-library track</legend>
{tracks === null && <p className="text-sm text-port-text-muted">Loading tracks…</p>}
diff --git a/client/src/components/apps/LaunchVideoPanel.test.jsx b/client/src/components/apps/LaunchVideoPanel.test.jsx
index 7683d9f5f9..2a91f3b7dc 100644
--- a/client/src/components/apps/LaunchVideoPanel.test.jsx
+++ b/client/src/components/apps/LaunchVideoPanel.test.jsx
@@ -47,7 +47,7 @@ describe('launch video drawer', () => {
expect(createAppLaunchVideo).toHaveBeenCalledTimes(1);
});
- it('queues generated music and motion graphics without requiring a library track for a longer video', async () => {
+ it.each(['agent', 'service'])('queues %s music without requiring a library track or installed engine', async musicMethod => {
createAppLaunchVideo.mockReset().mockResolvedValue({ taskId: 'task-generated' });
renderPanel('/?launchVideo=true');
fireEvent.click(screen.getByLabelText('Dynamic motion graphics'));
@@ -55,8 +55,10 @@ describe('launch video drawer', () => {
fireEvent.click(screen.getByLabelText('Include music'));
expect(screen.getByLabelText('Generate original music').checked).toBe(false);
fireEvent.click(screen.getByLabelText('Generate original music'));
+ expect(screen.getByLabelText('Music creation').value).toBe('agent');
+ fireEvent.change(screen.getByLabelText('Music creation'), { target: { value: musicMethod } });
fireEvent.click(screen.getByRole('button', { name: 'Queue launch video' }));
- await waitFor(() => expect(createAppLaunchVideo).toHaveBeenCalledWith('example', expect.objectContaining({ targetDurationSec: 90, generateMusic: true, motionGraphics: true }), { silent: true }));
+ await waitFor(() => expect(createAppLaunchVideo).toHaveBeenCalledWith('example', expect.objectContaining({ targetDurationSec: 90, generateMusic: true, musicMethod, motionGraphics: true }), { silent: true }));
expect(createAppLaunchVideo.mock.calls[0][1].musicTrack).toBeUndefined();
});
diff --git a/docs/HTML_COMPOSITIONS.md b/docs/HTML_COMPOSITIONS.md
index b949f99bb4..32ab6c74dd 100644
--- a/docs/HTML_COMPOSITIONS.md
+++ b/docs/HTML_COMPOSITIONS.md
@@ -37,6 +37,19 @@ Submit `POST /api/html-composition/render` with:
shorter than the video, is trimmed to duration, and fades out over the final half
second. A missing requested track fails the job.
+For procedural music, submit `synthesizeMusic: true` instead of `musicTrack`.
+Define `async portosComposition.renderAudio({ sampleRate, durationSec })` to return
+an ordinary array containing exactly `Math.round(sampleRate * durationSec)` mono
+PCM samples. The renderer supplies 24000 Hz and the video duration; every sample
+must be finite and between -1 and 1, and the soundtrack must not be silent.
+Use native `OfflineAudioContext`, deterministic JavaScript synthesis, or locally
+available Tone.js/Strudel code capable of returning this contract. Convert an
+AudioBuffer channel with `Array.from(buffer.getChannelData(0))`. Live browser
+playback is not captured. The renderer writes temporary PCM WAV audio, muxes it
+with the same tail fade, and removes the temporary file after completion or
+failure. No music model, Python runtime, downloaded samples or music-library
+write is required. Missing or invalid audio fails the job.
+
The 202 response contains the media queue's `jobId`. Subscribe to
`GET /api/html-composition/:jobId/events` for the usual queued, started, progress,
complete, error and canceled SSE frames. Cancel through
@@ -78,9 +91,13 @@ provider/model/effort pin (Auto uses the normal CoS provider selection).
Closing its drawer does not cancel the run; use CoS agents to follow or cancel it.
Overlapping submissions for the same app are refused until its task settles.
No schedule or boot-time provider call is installed. Generated music is explicitly
-opted into for this run: the agent selects a ready music engine, writes an
-instrumental prompt, waits for its media job, and passes the resulting library
-filename to the renderer. Shorter music beds loop to fill the video. A generation
+opted into for this run. **Music creation** offers **Agent composition**
+(`musicMethod: "agent"`, the default) and **Configured music service**
+(`musicMethod: "service"`). Agent composition writes an instrumental score using
+the PCM contract above, so absent music engines do not block it. The service
+option selects a ready music engine, writes an instrumental prompt, waits for its
+media job, and passes the resulting library filename to the renderer. An explicit
+service choice still reports missing setup rather than silently changing methods. Shorter music beds loop to fill the video. A generation
failure is reported instead of silently dropping the soundtrack.
Dynamic motion graphics (`motionGraphics: true`, off by default) asks the agent for
diff --git a/server/lib/validation.js b/server/lib/validation.js
index 59f2eb31d0..4a0e2dc749 100644
--- a/server/lib/validation.js
+++ b/server/lib/validation.js
@@ -2454,6 +2454,7 @@ export const appLaunchVideoRequestSchema = z.object({
format: z.enum(['landscape', 'vertical', 'square']).default('landscape'),
targetDurationSec: z.number().int().min(15).max(120).default(20),
generateMusic: z.boolean().default(false),
+ musicMethod: z.enum(['agent', 'service']).default('agent'),
motionGraphics: z.boolean().default(false),
musicTrack: z.string().min(1).max(255).regex(/^[^/\\]+$/).optional(),
}).strict();
@@ -2479,9 +2480,10 @@ export const launchVideoStoryboardSchema = z.object({
// HTML composition inputs are local, editable assets, never provider prompts.
export const htmlCompositionRenderSchema = z.object({
launchVideo: launchVideoOptionsSchema.optional(),
+ synthesizeMusic: z.boolean().optional(),
directory: z.string().min(1).max(1024).refine(value => !value.startsWith('/') && !value.includes('\\') && !value.includes(':') && !value.split('/').some(part => part === '..' || part === '.' || !part), 'directory must be a relative path inside data'),
musicTrack: z.string().min(1).max(255).regex(/^[^/\\]+$/, 'musicTrack must be a Music-library filename').optional(),
-});
+}).refine(value => !(value.synthesizeMusic && value.musicTrack), 'Choose synthesized music or a library track, not both');
export const htmlCompositionContractSchema = z.object({
durationSec: z.number().min(1).max(120),
diff --git a/server/routes/apps/launchVideos.js b/server/routes/apps/launchVideos.js
index 278968b393..7eaee442d6 100644
--- a/server/routes/apps/launchVideos.js
+++ b/server/routes/apps/launchVideos.js
@@ -76,6 +76,7 @@ router.post('/:id/launch-videos', loadApp, asyncHandler(async (req, res) => {
const runId = `${Date.now()}-${randomUUID()}`;
const directory = `launch-videos/${app.id}/${runId}/composition`;
const payload = { directory, musicTrack: options.musicTrack,
+ ...(options.generateMusic && options.musicMethod === 'agent' ? { synthesizeMusic: true } : {}),
launchVideo: { appId: app.id, runId, targetDurationSec: options.targetDurationSec } };
// addTask's state lock makes the stable description + app identity atomic
// across overlapping requests, including requests with different options.
diff --git a/server/routes/apps/launchVideos.test.js b/server/routes/apps/launchVideos.test.js
index db446582d3..3ffde2db9f 100644
--- a/server/routes/apps/launchVideos.test.js
+++ b/server/routes/apps/launchVideos.test.js
@@ -65,6 +65,8 @@ describe('user-triggered launch videos', () => {
expect(task.prompt).toContain('"name":"Example Product"');
expect(task.prompt).toContain('"port":4321');
expect(task.prompt).toContain('"generateMusic":true');
+ expect(task.prompt).toContain('"musicMethod":"agent"');
+ expect(task.prompt).toContain('Never require a music engine for the agent method');
expect(task.prompt).toContain('"motionGraphics":true');
expect(task.prompt).toContain('When motionGraphics is true');
expect(task.prompt).toContain('"targetDurationSec":120');
@@ -77,6 +79,12 @@ describe('user-triggered launch videos', () => {
expect(addTask).toHaveBeenCalledTimes(1);
});
+ it('preserves an explicit service choice and rejects unknown music methods', async () => {
+ expect((await submit({ generateMusic: true, musicMethod: 'service' })).status).toBe(202);
+ expect(addTask.mock.calls[0][0].prompt).toContain('"musicMethod":"service"');
+ expect((await submit({ generateMusic: true, musicMethod: 'unknown' })).status).toBe(400);
+ });
+
it('refuses invalid options, missing music, and unavailable CoS before queuing', async () => {
expect((await submit({ targetDurationSec: 4 })).status).toBe(400);
expect((await submit({ tone: 'unknown' })).status).toBe(400);
diff --git a/server/routes/htmlComposition.test.js b/server/routes/htmlComposition.test.js
index a2e5c785bd..b3ea54203c 100644
--- a/server/routes/htmlComposition.test.js
+++ b/server/routes/htmlComposition.test.js
@@ -24,7 +24,7 @@ describe('HTML composition admission', () => {
expect(enqueueJob).toHaveBeenCalledWith({ kind: 'html-composition', params });
});
- it.each([{ directory: '../private' }, { directory: '/etc' }, { directory: 'C:\\private' }, { directory: 'valid', musicTrack: '../track.wav' }, {}])('rejects invalid paths before queue admission: %j', async body => {
+ it.each([{ directory: 'valid', synthesizeMusic: true, musicTrack: 'example.wav' }, { directory: '../private' }, { directory: '/etc' }, { directory: 'C:\\private' }, { directory: 'valid', musicTrack: '../track.wav' }, {}])('rejects invalid paths before queue admission: %j', async body => {
enqueueJob.mockClear();
const response = await request(app).post('/api/html-composition/render').send(body);
expect(response.status).toBe(400);
diff --git a/server/services/htmlComposition/encode.js b/server/services/htmlComposition/encode.js
index 9aa5cd014d..e83d880427 100644
--- a/server/services/htmlComposition/encode.js
+++ b/server/services/htmlComposition/encode.js
@@ -1,3 +1,4 @@
+import { pcmToWavBuffer } from '../../lib/chiptuneRender.js';
import { spawn } from '../../lib/childProcess.js';
import { safeChildProcessOptions } from '../../lib/processEnv.js';
import { killWithEscalation } from '../../lib/killWithEscalation.js';
@@ -61,3 +62,22 @@ export async function encodeComposition(page, contract, outputPath, { musicPath,
if (!exited) await new Promise(resolve => proc.once('close', resolve));
}
}
+
+// Source remains subject to the composition sandbox and launch privacy gate;
+// only bounded PCM leaves the browser, never arbitrary paths or encoded files.
+export async function synthesizeCompositionMusic(page, durationSec) {
+ const sampleRate = 24000;
+ const length = Math.round(sampleRate * durationSec);
+ const samples = await page.evaluate(`(async () => {
+ const renderAudio = globalThis.portosComposition.renderAudio;
+ if (typeof renderAudio !== 'function') throw new Error('portosComposition.renderAudio is required for synthesized music');
+ const samples = await renderAudio({ sampleRate: ${sampleRate}, durationSec: ${durationSec} });
+ if (!Array.isArray(samples) || samples.length !== ${length}) throw new Error('renderAudio must return exactly ${length} mono PCM samples');
+ return samples;
+ })()`);
+ if (!Array.isArray(samples) || samples.length !== length || samples.some(value => !Number.isFinite(value) || value < -1 || value > 1)) {
+ throw new Error('renderAudio must return finite mono PCM samples in [-1, 1]');
+ }
+ if (!samples.some(value => Math.abs(value) > 0.0001)) throw new Error('renderAudio returned a silent soundtrack');
+ return pcmToWavBuffer(Float32Array.from(samples), { sampleRate });
+}
diff --git a/server/services/htmlComposition/index.js b/server/services/htmlComposition/index.js
index b437759165..1e5be46bcf 100644
--- a/server/services/htmlComposition/index.js
+++ b/server/services/htmlComposition/index.js
@@ -1,5 +1,6 @@
import { join, resolve } from 'node:path';
-import { open, realpath } from 'node:fs/promises';
+import { mkdtemp, open, realpath, rm, writeFile } from 'node:fs/promises';
+import { tmpdir } from 'node:os';
import { createReadStream } from 'node:fs';
import { pipeline } from 'node:stream/promises';
import { PATHS, ensureDir, unlinkGuarded } from '../../lib/fileUtils.js';
@@ -9,7 +10,7 @@ import { videoGenEvents } from '../videoGen/events.js';
import { mutateVideoHistory } from '../videoGen/history.js';
import { resolveMusicTrackPath } from '../pipeline/audioMux.js';
import { openComposition } from './browser.js';
-import { encodeComposition } from './encode.js';
+import { encodeComposition, synthesizeCompositionMusic } from './encode.js';
import { validateLaunchVideoAssets } from '../../lib/launchVideoValidation.js';
const active = new Map();
@@ -28,6 +29,7 @@ export async function renderComposition({ jobId, ...input }) {
const filename = `composition-${jobId}.mp4`;
const outputPath = join(PATHS.videos, filename);
let page;
+ let audioDirectory;
let success = false;
let result;
let failure;
@@ -39,8 +41,8 @@ export async function renderComposition({ jobId, ...input }) {
try { await write(handle); } finally { await handle.close(); }
};
try {
- const { directory, musicTrack, launchVideo } = validateRequest(htmlCompositionRenderSchema, input);
- const musicPath = musicTrack ? await resolveMusicTrackPath(musicTrack) : null;
+ const { directory, musicTrack, launchVideo, synthesizeMusic } = validateRequest(htmlCompositionRenderSchema, input);
+ let musicPath = musicTrack ? await resolveMusicTrackPath(musicTrack) : null;
if (musicTrack && !musicPath) throw new Error('musicTrack is missing from the Music library');
signal.throwIfAborted();
let launchPlan;
@@ -68,6 +70,13 @@ export async function renderComposition({ jobId, ...input }) {
if (launchPlan && Math.abs(contract.durationSec - launchPlan.durationSec) > 1e-8) {
throw new Error('Composition durationSec must match storyboard.json');
}
+ if (synthesizeMusic) {
+ const wav = await synthesizeCompositionMusic(page, contract.durationSec);
+ page.check();
+ audioDirectory = await mkdtemp(join(tmpdir(), 'portos-composition-audio-'));
+ musicPath = join(audioDirectory, 'score.wav');
+ await writeFile(musicPath, wav, { flag: 'wx' });
+ }
await ensureDir(PATHS.videos);
await encodeComposition(page, contract, outputPath, { musicPath, signal, onProgress: progress => {
videoGenEvents.emit('progress', { generationId: jobId, progress: progress * 0.95 });
@@ -111,6 +120,7 @@ export async function renderComposition({ jobId, ...input }) {
failure = error;
} finally {
await page?.close();
+ if (audioDirectory) await rm(audioDirectory, { recursive: true, force: true });
if (!success) {
for (const path of deliveredPaths) await unlinkGuarded(path).catch(() => {});
await unlinkGuarded(outputPath).catch(() => {});
diff --git a/server/services/htmlComposition/index.test.js b/server/services/htmlComposition/index.test.js
index 74451258f2..f70ef793ba 100644
--- a/server/services/htmlComposition/index.test.js
+++ b/server/services/htmlComposition/index.test.js
@@ -135,6 +135,17 @@ describe.skipIf(!chrome || !ffmpeg)('HTML composition with real Chrome and ffmpe
expect(await loadHistory()).not.toContainEqual(expect.objectContaining({ id: input.jobId }));
});
+ it('muxes agent-composed PCM without a music engine and refuses missing or invalid scores', async () => {
+ const input = await composition(fixture('', `renderAudio: async ({ sampleRate, durationSec }) =>
+ Array.from({ length: Math.round(sampleRate * durationSec) }, (_, n) => 0.2 * Math.sin(2 * Math.PI * 440 * n / sampleRate)),`));
+ const result = await renderComposition({ ...input, synthesizeMusic: true });
+ const pcm = execFileSync(ffmpeg, ['-v', 'error', '-i', join(PATHS.videos, result.filename), '-vn', '-f', 'f32le', '-ac', '1', '-ar', '24000', '-']);
+ expect(pcm.length).toBeGreaterThanOrEqual(24000 * 4);
+ expect(Array.from({ length: 1000 }, (_, n) => Math.abs(pcm.readFloatLE(n * 4))).some(value => value > 0.05)).toBe(true);
+ await expect(renderComposition({ ...await composition(), synthesizeMusic: true })).rejects.toThrow('renderAudio is required');
+ await expect(renderComposition({ ...await composition(fixture('', 'renderAudio: async () => Array(24000).fill(2),')), synthesizeMusic: true })).rejects.toThrow('finite mono PCM');
+ }, 30000);
+
it('loops and trims library music to the video with a half-second tail fade', async () => {
await mkdir(PATHS.music, { recursive: true });
execFileSync(ffmpeg, ['-v', 'error', '-f', 'lavfi', '-i', 'sine=frequency=440:duration=0.3', '-y', join(PATHS.music, 'example.wav')]);
diff --git a/server/services/taskPromptDefaults/appLaunchVideo.js b/server/services/taskPromptDefaults/appLaunchVideo.js
index 256b114f78..308df20d4b 100644
--- a/server/services/taskPromptDefaults/appLaunchVideo.js
+++ b/server/services/taskPromptDefaults/appLaunchVideo.js
@@ -9,6 +9,8 @@ Write only to the supplied output directory (plus the runner's completion sentin
Every scene has durationSec; every visible text element has text, its exact whitespace-separated wordCount, and holdSec. Total 15–120 seconds and within two seconds of the chosen target. Each hold is at least max(0.8, 0.3 * wordCount) and fits its scene. Implement those holds faithfully, including transitions. Choose posterSec at the strongest settled beat.
- index.html and local assets: globalThis.portosComposition = {durationSec, fps:24, width, height, async seek(t){...}}. Use dimensions 1920x1080 (landscape), 1080x1920 (vertical), or 1080x1080 (square). Seek deterministically from t; await fonts and any asynchronous work. No wall-clock animations, external URLs, popups, workers or browser storage. Keep HTML/CSS/JS/SVG/JSON/Markdown/text UTF-8. No raster screenshots or footage.
When motionGraphics is true, make a dynamic motion-graphics piece: a designer's showreel built around this product, not a slideshow of recreated screens. Cut on a steady beat (a new beat every one to two seconds, landing on bar boundaries when music is present) and give each beat a distinct technique: bold color-field swaps drawn from the app's palette, oversized kinetic typography (scale, mask and slide reveals; repeated-word patterns), easing-curve showcases (expo, back, elastic, bounce), generative geometry computed from t (tiling patterns, radial bursts, particle fields, wireframe forms), shape morphs, and a logo/name lockup endcard. A thin HUD overlay (corner crop marks, timecode, beat counter) may frame the piece. Keep the recreated key flow as one or two punchy beats so the evidence-backed claim still lands. All motion stays a pure function of t: seeded pseudo-randomness only, never Math.random or timers. Every word shown, including repeated kinetic words and HUD labels, is a storyboard line whose hold meets the reading-time gate; keep HUD text to digits and symbols. When motionGraphics is false, favor a clear, paced product walkthrough.
-When generateMusic is true, the user explicitly requests original instrumental music. Compose a music prompt matching the storyboard and tone, using only fictional/public product context. First GET /api/music/engines from the supplied PortOS service API base. Select a ready, platformSupported engine (prefer defaultEngine when ready), using its ready default model or a model marked ready in modelReadyById. If none is ready, report the setup requirement and stop. POST {"prompt":"<your musical direction>","instrumentalOnly":true,"engine":"<selected engine id>","modelId":"<selected model id>","durationSec":<duration within the engine limits>} to the supplied PortOS service API base + /api/music/generate with the same Authorization header as rendering. Aim for targetDurationSec within the engine duration limits; a shorter music bed is looped and faded by the renderer to fill the video. Do not install models or change provider settings. Subscribe to /api/html-composition/<jobId>/events (the shared media queue stream) until complete; take result.filename from that completed job as musicTrack in the render JSON. Cancel that job via /api/html-composition/<jobId>/cancel if canceled. If generation fails, report the failure rather than silently rendering without music. This API may write its generated track to the Music library; do not write arbitrary files there yourself. When generateMusic is false, never generate music; preserve the supplied library musicTrack, if any.
-Render using the supplied POST URL and JSON payload (adding only the completed generated musicTrack when requested) with the agent's Authorization: Bearer credential from PORTOS_API_TOKEN; never print or persist the credential. Privacy and readability checks fail closed and name the file/pattern or scene/line. Replace offending content, never bypass the gates. A queued job is not success: subscribe to its /events SSE endpoint until complete, error or canceled. Do not poll. On cancellation, cancel the media job with its /cancel endpoint. Keep the CoS run active through rendering. Only report success after complete. The server copies the validated plan, storyboard and caption plus MP4 and poster into the run directory and registers the video in Media History.
+When generateMusic is true, the user explicitly requests original instrumental music. musicMethod chooses how: "agent" (the default) means compose and synthesize it yourself; "service" means use a configured PortOS music engine. Never require a music engine for the agent method.
+For the agent method, implement async globalThis.portosComposition.renderAudio({sampleRate, durationSec}) returning a plain array of exactly Math.round(sampleRate * durationSec) finite mono PCM samples in [-1, 1]. The renderer supplies sampleRate=24000 and the video duration, writes a temporary soundtrack and muxes it into the MP4. Compose a deliberate instrumental arrangement matching the storyboard, with melody, harmony, rhythm, dynamics and an ending; document tempo and musical direction in plan.md. Use native OfflineAudioContext, deterministic sample synthesis, or locally available Tone.js/Strudel code that can export this PCM contract. Use only procedural synthesis, no recordings or fetched samples. Keep all source in composition/ as inspectable UTF-8 JavaScript. No installs, CDN imports, network calls, live playback or binary audio assets. Do not assume Tone.js or Strudel is installed; native Web Audio or plain JavaScript synthesis requires no additional music runtime. Add synthesizeMusic:true to the render JSON; do not set musicTrack or call /api/music/engines or /api/music/generate. Audio played by the page is NOT captured: renderAudio is required. A failed audio render is a failed task, never silently omit requested music.
+For the service method only: Compose a music prompt matching the storyboard and tone, using only fictional/public product context. First GET /api/music/engines from the supplied PortOS service API base. Select a ready, platformSupported engine (prefer defaultEngine when ready), using its ready default model or a model marked ready in modelReadyById. If none is ready, report the setup requirement and stop. POST {"prompt":"<your musical direction>","instrumentalOnly":true,"engine":"<selected engine id>","modelId":"<selected model id>","durationSec":<duration within the engine limits>} to the supplied PortOS service API base + /api/music/generate with the same Authorization header as rendering. Aim for targetDurationSec within the engine duration limits; a shorter music bed is looped and faded by the renderer to fill the video. Do not install models or change provider settings. Subscribe to /api/html-composition/<jobId>/events (the shared media queue stream) until complete; take result.filename from that completed job as musicTrack in the render JSON. Cancel that job via /api/html-composition/<jobId>/cancel if canceled. If generation fails, report the failure rather than silently rendering without music. This API may write its generated track to the Music library; do not write arbitrary files there yourself. When generateMusic is false, never generate music; preserve the supplied library musicTrack, if any.
+Render using the supplied POST URL and JSON payload (adding synthesizeMusic:true for agent composition or the completed generated musicTrack for the service method) with the agent's Authorization: Bearer credential from PORTOS_API_TOKEN; never print or persist the credential. Privacy and readability checks fail closed and name the file/pattern or scene/line. Replace offending content, never bypass the gates. A queued job is not success: subscribe to its /events SSE endpoint until complete, error or canceled. Do not poll. On cancellation, cancel the media job with its /cancel endpoint. Keep the CoS run active through rendering. Only report success after complete. The server copies the validated plan, storyboard and caption plus MP4 and poster into the run directory and registers the video in Media History.
`;
diff --git a/server/services/taskPromptDefaults/integrity.snapshot.json b/server/services/taskPromptDefaults/integrity.snapshot.json
index ccedbe5ecd..a52e4c83cc 100644
--- a/server/services/taskPromptDefaults/integrity.snapshot.json
+++ b/server/services/taskPromptDefaults/integrity.snapshot.json
@@ -2,7 +2,7 @@
"DEFAULT_TASK_PROMPTS": {
"accessibility": "46f628a44a919bb788de8761e86ca0e1",
"api-contract": "d52e00ec53eb5618df1a769efccc08f3",
- "app-launch-video": "71962a1f6f902d93f2c8840e3281301b",
+ "app-launch-video": "f1aee8c3de778663a5ba44a4f3486ce5",
"better-cognitive-load": "a1fe22f6ef936131456c55a6b0623204",
"better-complexity": "c99f67b43ff54a1c8cf0176c721d9c06",
"better-dependency-freedom": "8a79c8be829f926bbc7720ee29818d53",
@@ -64,7 +64,7 @@
"PROMPT_VERSIONS": {
"accessibility": 5,
"api-contract": 2,
- "app-launch-video": 3,
+ "app-launch-video": 4,
"better-cognitive-load": 1,
"better-complexity": 2,
"better-dependency-freedom": 1,
@@ -132,7 +132,8 @@
],
"app-launch-video": [
"fa15ea11b4cf49f31ae17513ff780421",
- "0247e82d4ae6e812dbd666d3bd75ad62"
+ "0247e82d4ae6e812dbd666d3bd75ad62",
+ "71962a1f6f902d93f2c8840e3281301b"
],
"better-complexity": [
"c92b99080d0453d70bb26a412fb48ce9"
diff --git a/server/services/taskPromptDefaults/versions.js b/server/services/taskPromptDefaults/versions.js
index 17668c67c4..dbf78c3fe1 100644
--- a/server/services/taskPromptDefaults/versions.js
+++ b/server/services/taskPromptDefaults/versions.js
@@ -7,7 +7,7 @@
// Prompt versions — bump when a default prompt changes so existing instances auto-upgrade.
// Only non-customized prompts (promptCustomized !== true) are upgraded.
export const PROMPT_VERSIONS = {
- 'app-launch-video': 3,
+ 'app-launch-video': 4,
'model-comparison-refresh': 4, // v4: installed inventory, sourced composite estimates and authenticated import
// Current claim-flow bumps retire the Copilot fallback, drive local reviewers
// fail closed, verify the remote merge state, and clean up without force-delete.