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
fix: invert the standardize gate to a non-Node deny list and guard static detection (#4137)
Adam Eivy5752a35af159
diff --git a/client/src/components/apps/constants.js b/client/src/components/apps/constants.jsindex 575721c66f..38ac3aa3b4 100644--- a/client/src/components/apps/constants.js+++ b/client/src/components/apps/constants.js@@ -44,18 +44,20 @@ export function resolveLaunchPanelProcess(app, result) {return result?.results?.[processName]?.success === false ? null : processName;}-// Mirrors STANDARDIZABLE_TYPES in server/services/streamingDetect.js (a parity-// test asserts the two Sets match). POSITIVE list: the PM2 standardizer writes a-// NODE ecosystem config from a prompt that opens "You are analyzing a Node.js-// application", so a Python/Go/Docker/static repo must not be offered the flow.-// `express` (appSchema's default), `unknown`, and `desktop` stay in for-// continuity with already-persisted app records — see the server's rationale.-export const STANDARDIZABLE_TYPES = new Set([- 'vite+express', 'vite', 'single-node-server', 'nextjs', 'express', 'desktop', 'unknown'-]);+// Mirrors NON_NODE_TYPES / NON_STANDARDIZABLE_TYPES in+// server/services/streamingDetect.js (parity tests assert the Sets match). The+// PM2 standardizer writes a NODE ecosystem config from a prompt that opens "You+// are analyzing a Node.js application", so a Python/Go/Docker/static repo must+// not be offered the flow. It's a DENY list, not an allowlist of Node types:+// `type` is a free-form string persisted on the app record, so records in the+// wild carry legacy values this file has never heard of, and an allowlist would+// silently withdraw the button from all of them. See the server's rationale.+export const NON_NODE_TYPES = new Set(['python', 'go', 'docker', 'static']);++export const NON_STANDARDIZABLE_TYPES = new Set([...NON_PM2_TYPES, ...NON_NODE_TYPES]);/** Whether the PM2 standardizer (which writes a NODE ecosystem config) applies. */-export const isStandardizable = (type) => STANDARDIZABLE_TYPES.has(type || 'unknown');+export const isStandardizable = (type) => !NON_STANDARDIZABLE_TYPES.has(type);// Every app type that can reach a UI label. Kept TOTAL (with a raw-type// fallback) rather than a ternary chain ending in '🔨 Xcode' — that defaultdiff --git a/server/services/streamingDetect.js b/server/services/streamingDetect.jsindex 2936436596..ac76864c81 100644--- a/server/services/streamingDetect.js+++ b/server/services/streamingDetect.js@@ -19,12 +19,19 @@ export const NON_PM2_TYPES = new Set(['ios-native', 'macos-native', 'xcode', 'swconst NON_NODE_MARKERS = [['python', ['pyproject.toml', 'requirements.txt', 'setup.py', 'Pipfile']],['go', ['go.mod']],- ['docker', ['docker-compose.yml', 'docker-compose.yaml', 'compose.yml', 'compose.yaml', 'Dockerfile']],- ['static', ['index.html']]+ ['docker', ['docker-compose.yml', 'docker-compose.yaml', 'compose.yml', 'compose.yaml', 'Dockerfile']]];+/**+ * Files meaning "something SERVES this directory". A package-less repo holding+ * one of these is a served app, not a static site, so `static` must not claim+ * it. `index.js` is deliberately absent: next to an `index.html` it is far more+ * often a client-side script than a server entry point.+ */+const SERVER_ENTRY_MARKERS = ['server.js', 'app.js', 'ecosystem.config.js', 'ecosystem.config.cjs'];+/** The non-Node app types `classifyNonNodeType` can emit. */-export const NON_NODE_TYPES = new Set(NON_NODE_MARKERS.map(([type]) => type));+export const NON_NODE_TYPES = new Set([...NON_NODE_MARKERS.map(([type]) => type), 'static']);/*** Classify a repo's runtime from its top-level filenames, for repos that@@ -39,34 +46,38 @@ export function classifyNonNodeType(files) {for (const [type, markers] of NON_NODE_MARKERS) {if (markers.some(marker => present.has(marker))) return type;}+ // `static` is the last resort and the only rule carrying a negative+ // condition — "an index.html with no server". An index.html sitting beside a+ // server entry point is a served app, so fall through to `unknown` (which+ // stays standardizable) rather than wrongly withdrawing the flow.+ if (present.has('index.html') && !SERVER_ENTRY_MARKERS.some(marker => present.has(marker))) {+ return 'static';+ }return null;}/**- * App types the PM2 standardizer may run against — a POSITIVE list, because the- * standardizer's prompt opens with "You are analyzing a Node.js application"- * and a negative list (`!NON_PM2_TYPES.has(type)`) silently swept in every- * unrecognized repo. On a Python/Go/Docker/static repo the LLM doesn't fail, it- * confidently writes a Node ecosystem config into someone else's project.+ * App types the PM2 standardizer must REFUSE: the Apple types (never PM2 at+ * all) plus the non-Node runtimes above. The standardizer's prompt opens with+ * "You are analyzing a Node.js application" — on a Python/Go/Docker/static repo+ * it doesn't fail, it confidently writes a Node ecosystem config into someone+ * else's project. That is what this predicate exists to stop.*- * The list has to cover every type an install can have PERSISTED, not just the- * ones detection emits today — `type` lives on the app record and other installs- * upgrade on their own schedule:- * - `express` is `appSchema`'s default (`server/lib/validation.js`) and the- * type of PortOS's own app entry, so it's the most common stored value.- * - `unknown` is what every app imported before this classification existed- * kept — and most of those really are Node apps.- * - `desktop` (a Godot game binary) was always offered the flow; those repos- * commonly carry a Node web process alongside the game.- * A missing/blank type normalizes to `unknown`, so an unrecognized legacy value- * degrades to "offer it" rather than silently hiding the button.+ * It is a DENY list rather than an allowlist of Node types because `type` is a+ * free-form string (`appSchema` in `server/lib/validation.js` defaults it to+ * `express` and accepts any value) PERSISTED on the app record. Installs+ * upgrade on their own schedule, so app records in the wild carry values this+ * file has never heard of — `unknown` from before this classification existed,+ * `node`/`react`/`web` from older detection, whatever a user typed. An+ * allowlist would silently withdraw standardization from every one of them.+ * Only a type we have positively identified as non-Node is refused; anything+ * unrecognized degrades to the previous behavior (offer it, and let the user+ * decide) instead of a button that quietly disappears on upgrade.*/-export const STANDARDIZABLE_TYPES = new Set([- 'vite+express', 'vite', 'single-node-server', 'nextjs', 'express', 'desktop', 'unknown'-]);+export const NON_STANDARDIZABLE_TYPES = new Set([...NON_PM2_TYPES, ...NON_NODE_TYPES]);/** Whether the PM2 standardizer (which writes a NODE ecosystem config) applies. */-export const isStandardizable = (type) => STANDARDIZABLE_TYPES.has(type || 'unknown');+export const isStandardizable = (type) => !NON_STANDARDIZABLE_TYPES.has(type);/*** App types that run a GUI/desktop process with no HTTP port (e.g. a Godotdiff --git a/server/services/streamingDetect.test.js b/server/services/streamingDetect.test.jsindex d612f84a76..60d0063de2 100644--- a/server/services/streamingDetect.test.js+++ b/server/services/streamingDetect.test.js@@ -2,7 +2,7 @@ import { describe, it, expect, afterEach, vi } from 'vitest';import { mkdirSync, mkdtempSync, writeFileSync, readFileSync, rmSync } from 'fs';import { tmpdir } from 'os';import { join } from 'path';-import { detectGodotNativeLaunch, parseEcosystemConfig, resolveViteConfigPortForProcess, rewriteEcosystemPorts, rewriteEcosystemPortsByProcess, writeEcosystemPorts, writeEcosystemPortsByProcess, writeEcosystemPortEdits, streamDetection, classifyNonNodeType, isStandardizable, usesPm2, DESKTOP_TYPES, NON_PM2_TYPES, NON_NODE_TYPES, STANDARDIZABLE_TYPES } from './streamingDetect.js';+import { detectGodotNativeLaunch, parseEcosystemConfig, resolveViteConfigPortForProcess, rewriteEcosystemPorts, rewriteEcosystemPortsByProcess, writeEcosystemPorts, writeEcosystemPortsByProcess, writeEcosystemPortEdits, streamDetection, classifyNonNodeType, isStandardizable, usesPm2, DESKTOP_TYPES, NON_PM2_TYPES, NON_NODE_TYPES, NON_STANDARDIZABLE_TYPES } from './streamingDetect.js';// streamDetection shells out to PM2 and scans for an app icon; neither is under// test here and both are slow/environment-dependent.@@ -1028,9 +1028,14 @@ describe('client mirror of the app-type sets', () => {expect([...client.NON_PM2_TYPES].sort()).toEqual([...NON_PM2_TYPES].sort());});- it('matches STANDARDIZABLE_TYPES', async () => {+ it('matches NON_NODE_TYPES', async () => {const client = await import('../../client/src/components/apps/constants.js');- expect([...client.STANDARDIZABLE_TYPES].sort()).toEqual([...STANDARDIZABLE_TYPES].sort());+ expect([...client.NON_NODE_TYPES].sort()).toEqual([...NON_NODE_TYPES].sort());+ });++ it('matches NON_STANDARDIZABLE_TYPES', async () => {+ const client = await import('../../client/src/components/apps/constants.js');+ expect([...client.NON_STANDARDIZABLE_TYPES].sort()).toEqual([...NON_STANDARDIZABLE_TYPES].sort());});});@@ -1074,6 +1079,15 @@ describe('streamDetection app-type classification', () => {expect(result.type).toBe('static');});+ it('keeps a served repo standardizable even when it ships an index.html', async () => {+ const { result } = await detect({+ 'index.html': '<!doctype html>',+ 'server.js': 'require("http").createServer().listen(3000);\n'+ });+ expect(result.type).toBe('unknown');+ expect(isStandardizable(result.type)).toBe(true);+ });+it('leaves a package.json repo alone — Node tooling owns it, so `unknown` stays honest', async () => {// A Node repo whose deps PortOS doesn't recognize must NOT be relabelled// `static` just because it also ships an index.html; `unknown` remains@@ -1121,6 +1135,21 @@ describe('classifyNonNodeType', () => {expect(classifyNonNodeType(['index.html', 'style.css'])).toBe('static');});+ it('does not call an index.html beside a server entry point static', () => {+ // "index.html with NO server" is the rule. A served app that happens to+ // have an index.html must fall through to `unknown` (still standardizable)+ // rather than have the flow withdrawn from it.+ for (const server of ['server.js', 'app.js', 'ecosystem.config.js', 'ecosystem.config.cjs']) {+ expect(classifyNonNodeType(['index.html', server])).toBeNull();+ }+ });++ it('still treats a client-side index.js as static, not a server', () => {+ // In a static site an `index.js` is a browser script far more often than a+ // server entry point, so it must not suppress the classification.+ expect(classifyNonNodeType(['index.html', 'index.js', 'style.css'])).toBe('static');+ });+it('prefers the language over the packaging when both markers are present', () => {// A Python service that also ships a Dockerfile is a python repo, not a// docker stack — the language is the more useful classification, and both@@ -1145,7 +1174,7 @@ describe('classifyNonNodeType', () => {describe('isStandardizable', () => {it('allows the Node app types', () => {- for (const type of ['vite+express', 'vite', 'single-node-server', 'nextjs']) {+ for (const type of ['vite+express', 'vite', 'single-node-server', 'nextjs', 'desktop']) {expect(isStandardizable(type)).toBe(true);}});@@ -1157,6 +1186,17 @@ describe('isStandardizable', () => {expect(isStandardizable('')).toBe(true);});+ it('stays permissive for legacy/custom persisted types', () => {+ // `type` is a free-form string on the app record (appSchema accepts any+ // value) and installs upgrade independently, so records in the wild carry+ // values this file never emitted. Only a POSITIVELY identified non-Node+ // type is refused — anything else keeps the pre-change behavior instead of+ // the button silently vanishing on upgrade.+ for (const type of ['express', 'node', 'react', 'web', 'anything-a-user-typed']) {+ expect(isStandardizable(type)).toBe(true);+ }+ });+it("covers appSchema's default type — the most common PERSISTED value", async () => {// `type` lives on the app record, and an app created without one defaults to// this. A positive gate that missed it would silently hide the standardize