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

Merge remote-tracking branch 'origin/main' into claim/issue-2463

Adam Eivy60817a3a98fe
diff --cc .changelog/NEXT.md
index 687714d321,67c002ba41..7c9f236423
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@@ -2,8 -2,12 +2,14 @@@
## Changes
+- **Media-gen marker parsers converged onto `createLineReader` too (#2463, follow-up to #2392).** The two remaining hand-copied per-chunk splitters — `imageGen/local.js` (stderr + stdout) and `videoGen/local.js` (stderr, plus a stdout `'\n'`-carry that never flushed the last line and decoded each chunk independently) — parsed `STAGE:`/`STATUS:`/`DOWNLOAD:` protocol markers with no carry buffer, so a marker or multibyte char split across a pipe chunk boundary could tear a progress event. Both services now route line parsing through `server/lib/streamLines.js#createLineReader` (StringDecoder-backed, carry across chunks, `flush()` on `close`), while the render-critical machinery is left exactly as-is: idle-stall + completion watchdogs still fire on the same signals (`resetIdleStallTimer` stays in the per-chunk `data` handler; the videoGen flush runs *before* the watchdog clears so a final result-JSON line can't re-arm a stray SIGKILL), the imageGen `stderrBuffer` error tail keeps accumulating raw chunk text, and the stdout JSON `video_path`/result capture is unchanged. Behavior-preserving; adds a chunk-boundary test proving a marker split across two chunks parses as one event.
+
+ - **CoS investigation tasks now use a human-facing "What happened / What to approve / What unblocks" template with a redacted failure snippet (#2442).** When a CoS agent failure is classified as *actionable*, `createInvestigationTask()` filed a fixed 6-field stub (Failed Agent / Original Task / Error Category / Suggested Fix / Model) that read identically for every category, while the useful diagnostic context stayed buried in `learning.json` telemetry. The body is now restructured into three sections — **What happened** (plain-language category + provider/model attribution + a short captured failure snippet), **What to approve** (the concrete decision/action to take), and **What unblocks** (which original task resumes) — and each `ERROR_PATTERN` may optionally supply category-specific escalation prose so the note varies by failure kind (model-not-found, context-length, spawn-error, task-rejected, content-filtered, etc.) instead of being uniform. The folded-in snippet and task description are passed through a new `redactFailureSnippet()` helper that strips OS usernames from home paths, emails, IPs, Tailscale/mDNS hostnames, and bearer/secret tokens before anything lands in the human-facing (and potentially federated) task body. Additive copy/structure change to one function plus optional per-pattern fields — no status-model change.
+
+ - **A CoS sub-agent can now challenge a wrong reviewer rejection instead of silently fixing it or getting blocked (#2441).** When a review-loop reviewer rejects work — common with noisy local/CLI reviewers — the task can be parked in a new `challenged` status with the worker's case attached (`reason` + optional `evidence` + which `reviewer` is disputed) via `POST /api/cos/tasks/:id/challenge`. Disputes are bounded to exactly one per task (a second is refused with `409 CHALLENGE_EXHAUSTED`), so an agent can't loop forever. Resolving via `POST /api/cos/tasks/:id/challenge/resolve` either **overturns** the rejection (`upheld` → task re-queues to pending) or **escalates** the unresolved dispute to the single PortOS user (`escalated` → task blocked with a `challenge-escalation` reason AND an approval-required arbitration task filed into `COS-TASKS.md`) — surfacing a sustained disagreement rather than quietly fixing or blocking. The full challenge trio (case + resolution + count) rides task metadata, so it round-trips the TASKS.md store, is auditable in the CoS task UI, and federates + converges across sync peers: `challenged` is wired into the claim-aware merge rank (above `in_progress`, below the terminal states), the peer-sync wire status vocab, and a `cosTasks` schema bump (v1→v2) so an older peer gently pauses cos-task sync instead of choking on the unknown status. Partial slice of the Conductor↔CoS challenge protocol — the automatic reviewer re-check and the agent-side auto-invocation land in a follow-up.
+
+ - **The dashboard's Quick Image widget now offers custom output dimensions and no longer shows a blank size dropdown for off-preset sizes (#2437).** The quick widget had its own inline resolution `<select>` over the universal presets and never gained the **Custom…** option added to the full Image Gen page, so its size picker was inconsistent — and a remix/off-preset size (any width/height not on the preset list) rendered a blank dropdown because no matching `<option>` existed. It now reuses the shared `ResolutionField` control, so selecting **Custom…** reveals Width/Height inputs (any edge 64–3840px, total ≤ 8,294,400px, matching the server's `imageEdgeSchema` + pixel cap), and an off-preset size auto-opens those inputs with the exact dimensions visible instead of collapsing to a blank select. No behavior change to the presets themselves.
+
- **Duplicated child-process stream/discovery helpers converged into shared lib modules (#2392).** Three hand-copied "split a stdout/stderr chunk stream into lines with a carry buffer" implementations (`ytdlpAudioImport.js`, `videoDownload.js`, `hfDownload.js`) had already drifted — only hfDownload's copy flushed the final unterminated line. They now share `server/lib/streamLines.js#createLineReader(onLine, {splitRe?, maxCarry?})`, which carries the partial trailing line across chunks, exposes a `flush()` for the last newline-less line (so the two yt-dlp paths stop dropping it — and skip the flush on cancel so a partial marker can't fire a stray progress frame), clamps the carry buffer against a newline-less runaway stream, and takes a `splitRe: /[\r\n]+/` option for bare-`\r` torch/tqdm progress redraws. The four bare-`\r` progress-splitter siblings (`midiRuntime.js`, `videoGen.js`, `music.js` install-log routes, and `pythonSetup.js#streamSpawn`) are converged onto the same reader with that option, so a progress line split across a chunk boundary is no longer torn. Separately, the inline `which`/`where` PATH probes in `ytdlp.js`, `ffmpeg.js` (×2), `pythonSetup.js`, and voice `bootstrap.js` are replaced by a single `whichFirst(name)` in `server/lib/processEnv.js` (Malloc-stripped env, 5s timeout, first-line result). The vendored `aiToolkit/providers.js` copy is intentionally left alone (self-contained by design). Behavior-preserving; both new helpers are unit-tested.
- **Runtime/venv install SSE flows now log to the server console too, matching the HF model-download logging (#2432).** The image/video/MuScriptor runtime installers (spawning `setup-image-video.sh`), the FLUX.2 venv bootstrap, and the local image-gen pip installer streamed multi-GB pip/git progress only to the browser via SSE — a headless / PM2 log had no record the install ever ran (the same gap `startHfDownloadStream` had already closed for HF model downloads). A new shared `createInstallLogger` chokepoint (`server/lib/installLogger.js`) now emits a single-line START, throttled heartbeats + `stage` milestones, and the OUTCOME (success/fail/cancel) with installer name, target, and elapsed time — without echoing every raw pip/bash line. Wired into all five install spawn sites in `music.js`, `videoGen.js`, `imageGen.js` (FLUX.2 venv + local pip install), and `midiRuntime.js`.