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([shared-tolerant-fetch-json-helper]): remove from PLAN.md and log to changelog
[._.]/ Adam Eivya841bc677749
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex adc6d62752..45e37bcfeb 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -34,6 +34,7 @@- **[data-versioning-centralize-cosagents-settings] Saving settings is now crash-safe and serialized.** `settings.json` is written through the shared atomic temp-file/rename writer and overlapping saves run one at a time, so a mid-write crash can no longer truncate the file and two near-simultaneous settings changes can no longer clobber each other (no user-facing change).- **[setup-data-import-drift-tables-from-migrations]** The setup script's "a prompt migration is pending" warning now derives its hash tables directly from the migration files instead of a hand-maintained copy, so the warning can't silently fall out of sync when a new prompt migration ships (no user-facing change).- **[cos-on-demand-mark-app-review-started-dedupe]** When several on-demand improvement requests for the same app are processed in one CoS dispatch cycle, the app's activity record is now marked review-started once instead of once per request (no user-facing change).+- **[shared-tolerant-fetch-json-helper]** Hardened the HTTP clients that talk to local model backends, the managed browser, and the background agent runner: a non-JSON/HTML error response now surfaces the real error instead of crashing with "Unexpected token <", via one shared tolerant JSON-body reader (no user-facing change).## Fixeddiff --git a/PLAN.md b/PLAN.mdindex 9acd382ef5..819f9f0a05 100644--- a/PLAN.md+++ b/PLAN.md@@ -6,7 +6,6 @@ For project goals, see [GOALS.md](./GOALS.md). For completed work, see [.changelClaimable, well-specified, no decision needed — `/claim`-able. Unordered.-- [ ] [shared-tolerant-fetch-json-helper] **Extract a shared tolerant `response.text()`→JSON parser and adopt it across the other fetch-based clients.** `cosRunnerClient.js` now reads runner bodies via a local `readRunnerJson` (delegating to `safeJSONParse`) so a non-JSON error page no longer crashes with `Unexpected token <`. The same unguarded `await response.json()` crash risk remains in other fetch-based clients: `server/lib/aiProvider.js` (~146), `server/services/browserService.js` (~111/207/216/269/291), `server/services/memoryEmbeddings.js`, `huggingFaceCatalog.js`, `messageTokenExtractor.js`, `ollamaManager.js`, and `server/lib/aiToolkit/providers.js` (the `.catch(() => ({ data: [] }))` band-aids). Promote a `fetchJsonTolerant(response)` / `readResponseJson(response)` helper (adjacent to `server/lib/fetchWithTimeout.js`, registered in the lib barrel + README) and migrate these call sites. Deferred from the `[cos-runner-client-non-json-response-handling]` PR (out of its stated single-file scope); surfaced by /simplify altitude (2026-06-01).- [ ] [cos-agent-output-write-amplification] **`appendAgentOutput` write-amplification — already batched via `appendAgentOutputLines`, audit non-runner producers.** CLAUDE.md documents the streaming-producers convention (batched variant + ~250ms debounce + drain on completion); the runner path uses it. Verify every producer that calls `appendAgentOutput` directly (`server/services/cosAgents.js:216`) is human-pace, not a hot loop. If any hot producer is still calling the per-line variant, migrate it. Likely a no-op audit; capture it so the convention doesn't silently drift.- [ ] [subagent-spawner-top-level-side-effects] **`subAgentSpawner.js` top-level side effects — move init into an explicit `initSpawner()`.** Module-load (`server/services/subAgentSpawner.js:153`) wires event listeners + timers, which interferes with test isolation (each test import re-arms them). Wrap the init block in `export function initSpawner()` and call it from `server/index.js` after dependencies are ready. Treat as a refactor — needs care that no consumer relies on the import-time wiring.- [ ] [conflict-journal-media-collections] **Conflict journal does not cover media-collection scalar overwrites.** `mergeMediaCollectionsFromSync` (`server/services/mediaCollections.js`) LWW-overwrites scalars (name/description/coverKey/universeId/seriesId) when `remoteWins`; items are union-merged (never lost). v1 hooks only universe + series merges because the whole-record content hash used by `conflictJournal.detectConflict` would false-positive on collections whenever items differ. Doing it right needs scalar-subset hashing that stays consistent with the sender-side base hash. Low value (scalar loss is minor), deferred.