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
docs([issue-1836]): changelog entries for socket extraction + avatar envelope fix
[._.]/ Adam Eivy2ecfd9884112
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 6d8ef7da2c..7c55f4a528 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -28,9 +28,12 @@- **Absent-vs-cleared merge bugs that silently restored values the user just cleared** — three spots conflated "field absent" with "field intentionally cleared to empty". A memory content edit now regenerates the summary and (file backend) reindexes BM25 via a shape-based gate (`typeof content === 'string'` / `Array.isArray(tags)`) instead of a falsy one that skipped both on an empty value and could crash `generateSummary` on a null/undefined content — fixed in both the file backend (`memory.js`) and the production Postgres backend (`memoryDB.js`) so they stay mirrored. (Empty memory content stays blocked at the API by `memoryUpdateSchema`'s `min(1)`, consistent with create.) A genuinely empty-body email refresh now overwrites the cached body instead of `||` collapsing back to the stale text (`messageSync.js`, both the thread-match and original-message paths). And clearing a CoS task's legacy direct field (`context`/`model`/`provider`/`app`) to `""` now persists as `""` rather than `|| undefined` deleting the key — `null` still drops it (`cosTaskStore.js`). (#1826)- **Unguarded async `child_process` handlers can no longer crash the Node process** — several `close`/`error` event handlers were `async` and `await`ed disk writes / completion bookkeeping with no `try/catch`, so a single failed write (e.g. a full disk) or a throwing completion hook surfaced as an unhandled rejection and took down the whole server. Wrapped the at-risk handler bodies in `server/services/runner.js` (both `close` and `error`), `videoTimeline/local.js`, `agentCliSpawning.js` (both `close` and `error`), and both the CLI `close` handler and the detached `processStream().catch` in `aiToolkit/runner.js`. The recovery paths now still settle callers waiting on `onComplete` with failure metadata (so a finalization failure surfaces as a failed run instead of hanging forever), with the completion hook isolated from `onComplete` so a throwing `onRunFailed` can't block the caller from settling. Also replaced the two silent recovery-critical `.catch(() => {})` swallows in `cos-runner/index.js` with logged failures so a lost completion-metadata write is visible instead of silently dropping a finished task. (#1825)- Catalog "Appears in" panel no longer renders dangling chips that deep-link to soft-deleted universe/series/creative-director targets — the detail page filters refs to live targets only (the orphan stays recoverable via the "Orphaned" album). Also fixed a stale resolver bug where soft-deleted Creative Director projects (#1564) wrongly resolved as live, and extended orphan-bucket detection so a deleted CD project's ex-cast surfaces as orphaned rather than unlinked. (#1812)+- **[issue-1836] Avatar GLB stream errors now return the standard error envelope** — when `GET /api/avatar/model.glb` hits a read error mid-stream (e.g. the file is removed after the existence check), the 404/500 JSON response carried a bare `{ error }` instead of the `{ error, code, timestamp }` shape every other PortOS endpoint stamps via `errorMiddleware`. Since the stream `error` event fires outside the request promise chain (where a throw would crash the process), the handler now stamps `code` + `timestamp` directly, so clients see a consistent error shape. (#1836)## Internal+- **[issue-1836] Moved socket-handler orchestration into services** — the `standardize:start` and `app:deploy` Socket.IO handlers (`server/services/socket.js`) implemented their multi-step flows inline in the socket layer, where they couldn't be unit-tested or reused from an HTTP route. The PM2 standardization flow (analyze → git backup → apply) is now `pm2Standardizer.runStandardizeFlow()` and the deploy flow (resolve app → check deploy script → run) is now `appDeployer.runDeployFlow()`; each takes progress callbacks and returns a terminal outcome, so the socket handler is a thin adapter. Both are covered by new unit tests. Behavior-preserving. (#1836)+- **Replaced aiToolkit runner monkey-patching with declared extension points** — `server/index.js` previously reached into the toolkit runner's private surface, overwriting `executeCliRun`/`executeTuiRun` and re-wrapping `stopRun`/`isRunActive`/`deleteRun` to consult an ad-hoc `_portosActiveRuns` map, plus inlining a 34-line update-marker IIFE in bootstrap. The toolkit runner (`server/lib/aiToolkit/runner.js`) now exposes `setCliRunner()`/`setTuiRunner()` and an external-run registry (`registerExternalRun`/`unregisterExternalRun`/`hasExternalRun`) that its own `stopRun`/`isRunActive`/`deleteRun` consult first — so the host registers its CLI/TUI runners through a documented contract instead of mutating private props, and adding a new lifecycle method no longer requires a matching monkey-patch. `server/services/runner.js` tracks its child processes via the registry, and the update-marker read/validate/record/cleanup lifecycle moved into a unit-tested `processUpdateMarker()` in `server/services/updateChecker.js`. Behavior-preserving; the aiToolkit override contract (`server/lib/aiToolkit/CLAUDE.md`) is updated to match. (#1834)- **Decomposed two remaining large files: `server/routes/meatspace.js` + `server/services/videoGen/local.js`** — the 1,069-line `meatspace.js` router (14 health sub-domains, each backed by its own service import) is split one concern per file (`meatspaceCoreRoutes.js` overview/config/birth-date/death-clock/LEV, `meatspaceAlcoholRoutes.js`, `meatspaceNicotineRoutes.js`, `meatspaceHealthRoutes.js` blood/body/BP/workouts/epigenetic/eyes, `meatspacePostRoutes.js` POST drills + training + memory builder, `meatspaceCalendarRoutes.js` life calendar/activities/events, `meatspaceExportRoutes.js` MortalLoom export), assembled by a thin `meatspace.js` barrel that mounts each under `/api/meatspace` — the same pattern `routes/cos.js`/`routes/brain.js` use; the split is wiring-only (the 70-route surface is byte-identical, verified). The 1,805-line `videoGen/local.js` had its BYOV runtime management (venv/helper-script path constants, `BYOV_RUNTIME_INFO`, install/ready/fingerprint probes) extracted to `videoGen/runtimes.js` and its render-history I/O (`loadHistory`/`saveHistory`) to `videoGen/history.js`; `local.js` keeps generation + post-processing and re-exports the extracted surface so every existing deep import (`from '../videoGen/local.js'`) keeps resolving unchanged (all 30 prior exports preserved, verified). (#1833)- **Decomposed `server/routes/brain.js` (1,149-line router covering 13 sub-domains)** — the monolithic Brain router that mixed capture/inbox, four entity CRUD collections + memories, digest/review, settings/summary, links + buckets, graph, federation sync, and the daily log is now split one concern per file (`brainCapture.js`, `brainCrud.js`, `brainDigest.js`, `brainSettings.js`, `brainLinks.js`, `brainGraph.js`, `brainSync.js`, `brainDailyLog.js`), assembled by a thin `brain.js` barrel that mounts each sub-router under `/api/brain` — the same pattern `routes/cos.js` already uses. The split is wiring-only: route paths, ordering (literal-before-`:id` routes stay within their owning sub-router), validation, and the barrel's default export are unchanged, so `server/index.js` and the existing `brain.test.js` (105 tests) pass without edits. (#1832)