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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
let users pick the MuScriptor MIDI model size (small/medium/large) per request
[._.]/ Adam Eivy6d74a06dd929
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 85fadf1c79..621e60d170 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -34,6 +34,8 @@- **Layered Intelligence now learns from its own results — the feedback loop is closed (#2428).** The LI reasoner used to file improvement proposals as tracker issues and then never read back whether they were merged, rejected, or abandoned, so it proposed in a vacuum (re-suggesting scopes with a 0% adoption rate). LI now records every filed proposal in a lightweight per-app outcome store (`data/cos/li-outcomes/`, a `createCollectionStore` collection with per-slug records and 30-day auto-GC), reconciles each proposal's outcome from the live tracker state on the next run (GitHub `stateReason` maps *not-planned* → rejected, any other close → merged; still-open stays unresolved), and folds a merge-rate report — totals, per-scope adoption, common rejection reasons — back into the reasoning prompt with guidance to prefer higher-merge scopes and justify low-merge ones. Gated behind a new `Proposal outcomes` telemetry source toggle in the per-app LI config (default **on** for the PortOS install, **off** for managed apps). No migration needed — the store is created on first use and existing LI behavior is unchanged when the toggle is off.+- **Audio → MIDI transcription now lets you pick the MuScriptor model size (small / medium / large) per request.** The transcribe controls always ran the `medium` weights because the client never sent a size, even though the server route, Zod schema, and sidecar already accepted an optional `model`. Both trigger points — *Transcribe MIDI* on a Rounds reference audio and *MIDI* on a Music Video source track — now show a size selector next to the button. Larger tiers give higher-quality transcriptions but are slower and pull a bigger weight file on first use; `medium` stays the default so existing behavior is unchanged, and the chosen size is threaded straight into the existing `transcribe-midi` endpoints. The selector disables while a transcription is in flight.+- **Audio → MIDI transcription now installs its runtime automatically on first use.** Clicking *Transcribe MIDI* (Rounds reference audio) or *MIDI* (Music Video source track) used to dead-end on a toast telling you to run `INSTALL_MUSCRIPTOR=1 bash scripts/setup-image-video.sh` in a terminal. Now, when the MuScriptor venv isn't provisioned yet, PortOS opens an in-app installer that streams the setup line-by-line — the same experience as the image and video model runtimes — and, on completion, automatically runs the transcription you originally asked for. A new `GET /api/midi-runtime/install` endpoint reuses the shared `RuntimeInstallModal`/SSE-install path (in-flight singleton, detached process group so a cancel kills pip/git children, post-install venv re-probe); `useMidiTranscription` catches the `503 MIDI_RUNTIME_MISSING` kickoff, gates the modal, and retries once installed (with a loop guard so a genuinely-failed install surfaces its error instead of relooping).- **PortOS now installs a service worker for offline app-shell loading and low-bandwidth caching** — the modern replacement for the long-deprecated AppCache manifest. After the first online visit, the built app shell (`index.html`) and the content-hashed JS/CSS chunks are cached, so the UI loads instantly on repeat visits, keeps rendering when the server is briefly unreachable (flaky Tailnet links), and stops re-pulling megabytes of vendor JS on every navigation over a slow connection. Google Fonts and static public assets (icons, textures, manifest) are cached too. Real-time and large/dynamic routes — `/api/*`, `/socket.io/*`, and `/data/*` media — are **never** cached, so live data and streamed assets always hit the network (HTTP Range preserved for `/data`). Navigations stay network-first so a fresh build is always picked up when online, and the existing build-id / stale-chunk-reload machinery still handles "the server rebuilt while a tab was open." The worker registers only in a production **secure context** (HTTPS, or `localhost`) — it is a progressive enhancement that silently no-ops over a plain-HTTP Tailnet hostname and in the Vite dev server (where it also tears down any stale worker). Implemented as a hand-rolled worker (`client/public/sw.js`) with no new dependency; registration lives in `client/src/lib/registerServiceWorker.js`. The PWA manifest gained explicit `id`/`scope` for a deterministic installed-app identity.diff --git a/client/src/components/songs/ReferenceAnalysis.jsx b/client/src/components/songs/ReferenceAnalysis.jsxindex f576251525..8c15426253 100644--- a/client/src/components/songs/ReferenceAnalysis.jsx+++ b/client/src/components/songs/ReferenceAnalysis.jsx@@ -42,6 +42,7 @@ import { startMemoRecording, arrayBufferToBase64 } from '../../lib/audioRecorderimport { proposeSegmentScore, proposeStackedSegmentScore, diffScoreBars, PITCH_CLASS_NAMES } from '../../lib/referenceAnalysis';import { scoreHasMusic, parseScore } from '../../lib/scoreNotation';import { harmonyPartLabel } from '../../lib/songCraft';+import { MUSCRIPTOR_MODELS, DEFAULT_MUSCRIPTOR_MODEL } from '../../lib/muscriptorModels.js';// Client-side guard for the base64-JSON upload path: the server body limit is// 55 MB and base64 inflates ~4/3, so cap the raw file well under that.@@ -99,6 +100,10 @@ export function ReferenceAudioAttach({ reference, onUpdate }) {const [busy, setBusy] = useState(false);const [recording, setRecording] = useState(false);const [url, setUrl] = useState('');+ // MuScriptor model size for the next transcription (default balances+ // quality/speed). Read fresh inside startRequest — useSseJobSlot invokes the+ // latest closure each kickoff, so a change here applies to the next run.+ const [midiModel, setMidiModel] = useState(DEFAULT_MUSCRIPTOR_MODEL);const fileRef = useRef(null);const handleRef = useRef(null);@@ -114,7 +119,7 @@ export function ReferenceAudioAttach({ reference, onUpdate }) {// .mid. Same explicit-save model as the other reference fields: the returned// uploads filename lands on the draft; the user Saves to keep it.const midiJob = useMidiTranscription({- startRequest: (filename) => transcribeReferenceMidi(filename, undefined, { silent: true }),+ startRequest: (filename) => transcribeReferenceMidi(filename, midiModel, { silent: true }),eventsUrl: referenceMidiTranscriptionEventsUrl,cancelRequest: cancelReferenceMidiTranscription,onComplete: ({ filename }, sourceAudio) => {@@ -214,14 +219,25 @@ export function ReferenceAudioAttach({ reference, onUpdate }) {</button></span>) : (- <button- type="button"- onClick={() => midiJob.start(reference.audioFilename)}- title="Transcribe this audio to MIDI with MuScriptor (local — installs automatically on first use)"- className="flex items-center gap-1 px-2 py-1 text-xs rounded-lg border border-port-border text-gray-300 hover:text-white hover:bg-port-border/50"- >- <Music size={13} /> Transcribe MIDI- </button>+ <>+ <select+ value={midiModel}+ onChange={(e) => setMidiModel(e.target.value)}+ aria-label="MuScriptor model size"+ title="MuScriptor model size — larger is higher quality but slower and a bigger first-use download"+ className="bg-port-bg border border-port-border rounded-lg px-1.5 py-1 text-xs text-white capitalize focus:border-port-accent focus:outline-none"+ >+ {MUSCRIPTOR_MODELS.map((m) => <option key={m} value={m}>{m}</option>)}+ </select>+ <button+ type="button"+ onClick={() => midiJob.start(reference.audioFilename)}+ title={`Transcribe this audio to MIDI with MuScriptor (${midiModel} model, local — installs automatically on first use)`}+ className="flex items-center gap-1 px-2 py-1 text-xs rounded-lg border border-port-border text-gray-300 hover:text-white hover:bg-port-border/50"+ >+ <Music size={13} /> Transcribe MIDI+ </button>+ </>)}<buttontype="button"diff --git a/client/src/lib/README.md b/client/src/lib/README.mdindex cae386ffa5..9cfc31b1a1 100644--- a/client/src/lib/README.md+++ b/client/src/lib/README.md@@ -55,6 +55,7 @@ grep -i "what you want to do" client/src/lib/README.md| `imageGenDefaults.js` | Shared `DEFAULT_NEGATIVE_PROMPT` used by the Image Gen form and quick-submit entry points. Mirrors server-side default. || `imageGenResolutions.js` | Shared resolution presets for image generation. || `importerDeepLink.js` | The Importer deep-link contract both ways: `buildImporterLink({ universeId, seriesId, seriesName })` builds the `/importer?…` URL a Series Pipeline page navigates to; `resolveImporterDeepLink(...)` reads those params back into the universe + series names the importer matches on. |+| `muscriptorModels.js` | `MUSCRIPTOR_MODELS` (audio → MIDI size tiers `small`/`medium`/`large`) + `DEFAULT_MUSCRIPTOR_MODEL`. Single source consumed by the transcribe `<select>`s in `MusicVideo.jsx` and `ReferenceAnalysis.jsx`. Mirrors the server's `MUSCRIPTOR_MODELS` in `server/services/audioMidiTranscription.js`. || `videoGenResolutions.js` | Shared resolution presets for video generation (companion to image side; LTX-2 latent-friendly sizes) + `snapAspectToImage()` to pick the closest-aspect preset for an I2V source. || `videoTilingOptions.js` | `VIDEO_TILING_OPTIONS` (the `<select>` rows) + `VIDEO_TILING_ENUM_SET` (the value-only Set). Single source consumed by `VideoGen.jsx` and the Remix URL builder in `useMediaPreviewActions`. Mirrors the server's `z.enum` in `server/routes/videoGen.js`. |diff --git a/client/src/lib/index.js b/client/src/lib/index.jsindex c31883e0b4..e6ce7b58a5 100644--- a/client/src/lib/index.js+++ b/client/src/lib/index.js@@ -31,6 +31,7 @@ export * from './imageGenResolutions.js';export * from './importerDeepLink.js';export * from './letteringDensity.js';export * from './issueLength.js';+export * from './muscriptorModels.js';export * from './pipelineImageDefaults.js';export * from './reverseOutlineGrid.js';export * from './runnerFamilies.js';diff --git a/client/src/lib/muscriptorModels.js b/client/src/lib/muscriptorModels.jsnew file mode 100644index 0000000000..1c5604a71c--- /dev/null+++ b/client/src/lib/muscriptorModels.js@@ -0,0 +1,13 @@+// Single source of truth for the MuScriptor audio → MIDI model-size tiers.+// Consumed by the two transcription trigger points:+// - pages/MusicVideo.jsx — the source-track `MIDI` button's size <select>.+// - components/songs/ReferenceAnalysis.jsx — the reference-audio Transcribe+// MIDI button's size <select>.+// Larger tiers are higher quality but slower and pull a bigger weight file on+// first use; `medium` is the balanced default. The server's z.enum in+// server/lib/musicVideoValidation.js and MUSCRIPTOR_MODELS in+// server/services/audioMidiTranscription.js must match these values — add a+// tier here and to the server set together.+export const MUSCRIPTOR_MODELS = ['small', 'medium', 'large'];++export const DEFAULT_MUSCRIPTOR_MODEL = 'medium';diff --git a/client/src/pages/MusicVideo.jsx b/client/src/pages/MusicVideo.jsxindex 13b4755e9c..bd700ace31 100644--- a/client/src/pages/MusicVideo.jsx+++ b/client/src/pages/MusicVideo.jsx@@ -33,6 +33,7 @@ import useSceneRenderLifecycle from '../hooks/useSceneRenderLifecycle.js';import useYoutubeTrackImport from '../hooks/useYoutubeTrackImport.js';import { useSseProgress, isTerminalSseFrame } from '../hooks/useSseProgress.js';import { formatDurationSec } from '../utils/formatters.js';+import { MUSCRIPTOR_MODELS, DEFAULT_MUSCRIPTOR_MODEL } from '../lib/muscriptorModels.js';const MODES = ['director', 'autonomous'];@@ -267,8 +268,12 @@ export default function MusicVideo() {// misattribute the result. `midiTargetsSelected` gates the track-change// controls, since the .mid being produced is of the CURRENT audio (mirrors// renderTargetsSelected).+ // MuScriptor model size for the next transcription (default balances+ // quality/speed). Read fresh inside startRequest — useSseJobSlot invokes the+ // latest closure each kickoff, so a change here applies to the next run.+ const [midiModel, setMidiModel] = useState(DEFAULT_MUSCRIPTOR_MODEL);const midiJob = useMidiTranscription({- startRequest: (projectId) => transcribeMusicVideoMidi(projectId, {}, { silent: true }),+ startRequest: (projectId) => transcribeMusicVideoMidi(projectId, { model: midiModel }, { silent: true }),eventsUrl: musicVideoMidiEventsUrl,cancelRequest: cancelMusicVideoMidiTranscription,onComplete: (frame, projectId) => {@@ -648,14 +653,23 @@ export default function MusicVideo() {<Activity size={15} className="animate-spin" /> MIDI · Cancel</button>) : (- <button onClick={() => midiJob.start(selected.id)}- disabled={midiJob.active || (!selected.trackId && !selected.uploadedAudioFilename)}- title={!selected.trackId && !selected.uploadedAudioFilename- ? 'Link a track first'- : 'Transcribe the track to MIDI with MuScriptor (local — installs automatically on first use)'}- className="flex items-center gap-1 bg-port-bg border border-port-border rounded px-2 py-1.5 text-sm min-h-[40px] sm:min-h-0 disabled:opacity-50">- <Music size={15} /> MIDI- </button>+ <>+ <select value={midiModel} onChange={(e) => setMidiModel(e.target.value)}+ disabled={midiJob.active}+ aria-label="MuScriptor model size"+ title="MuScriptor model size — larger is higher quality but slower and a bigger first-use download"+ className="bg-port-bg border border-port-border rounded px-1.5 py-1.5 text-sm capitalize disabled:opacity-50">+ {MUSCRIPTOR_MODELS.map((m) => <option key={m} value={m}>{m}</option>)}+ </select>+ <button onClick={() => midiJob.start(selected.id)}+ disabled={midiJob.active || (!selected.trackId && !selected.uploadedAudioFilename)}+ title={!selected.trackId && !selected.uploadedAudioFilename+ ? 'Link a track first'+ : `Transcribe the track to MIDI with MuScriptor (${midiModel} model, local — installs automatically on first use)`}+ className="flex items-center gap-1 bg-port-bg border border-port-border rounded px-2 py-1.5 text-sm min-h-[40px] sm:min-h-0 disabled:opacity-50">+ <Music size={15} /> MIDI+ </button>+ </>)}<button onClick={handlePlan} disabled={planning || !selected.audioAnalysis}title={!selected.audioAnalysis ? 'Analyze the track first' : 'AI-propose a scene per song section'}diff --git a/client/src/pages/MusicVideo.test.jsx b/client/src/pages/MusicVideo.test.jsxindex 2177cda50b..6ad72ceace 100644--- a/client/src/pages/MusicVideo.test.jsx+++ b/client/src/pages/MusicVideo.test.jsx@@ -201,12 +201,19 @@ describe('MusicVideo audio → MIDI transcription (MuScriptor)', () => {expect(btn).toHaveProperty('disabled', true);});- it('kicks off a transcription for the selected project', async () => {+ it('kicks off a transcription for the selected project with the default model', async () => {await openProject(PROJECT_WITH_CLIP);const btn = await screen.findByRole('button', { name: /^MIDI$/ });expect(btn).toHaveProperty('disabled', false);fireEvent.click(btn);- await waitFor(() => expect(transcribeMusicVideoMidi).toHaveBeenCalledWith('mv-1', {}, { silent: true }));+ await waitFor(() => expect(transcribeMusicVideoMidi).toHaveBeenCalledWith('mv-1', { model: 'medium' }, { silent: true }));+ });++ it('kicks off a transcription with the chosen model size', async () => {+ await openProject(PROJECT_WITH_CLIP);+ fireEvent.change(await screen.findByLabelText('MuScriptor model size'), { target: { value: 'large' } });+ fireEvent.click(await screen.findByRole('button', { name: /^MIDI$/ }));+ await waitFor(() => expect(transcribeMusicVideoMidi).toHaveBeenCalledWith('mv-1', { model: 'large' }, { silent: true }));});it('shows the MIDI download link once the project carries a transcription pointer', async () => {