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 the PORTOS_ENV_PATH import that is currently red on main, and address review round 3
[._.]/ Adam Eivyb69b343e866c
diff --git a/scripts/update-headless-recovery.test.js b/scripts/update-headless-recovery.test.jsindex f086aeaae5..e8dfdd69fc 100644--- a/scripts/update-headless-recovery.test.js+++ b/scripts/update-headless-recovery.test.js@@ -94,6 +94,12 @@ if (${stallDelete} && args.startsWith('delete')) {writeFileSync(join(bin, shim), `#!/bin/sh\n${npmBody}\n`);chmodSync(join(bin, shim), 0o755);}+ // The success case is the only one that runs past trusted-rebuilds, so it+ // reaches update.sh's ffmpeg step — which on a machine without ffmpeg would+ // run a real `brew install`, or on Linux CI a passwordless `sudo apt-get+ // install` that mutates the runner. update.sh only probes `command -v`.+ writeFileSync(join(bin, 'ffmpeg'), '#!/bin/sh\nexit 0\n');+ chmodSync(join(bin, 'ffmpeg'), 0o755);// A pm2 the recovery can still reach after safe_install wipes the local one.if (pm2OnPath) {writeFileSync(join(bin, 'pm2'), `#!/bin/sh\nprintf '%s\\n' "$*" >> ${JSON.stringify(calls)}\n`);@@ -262,12 +268,20 @@ describe('update.ps1 headless-install guard', () => {expect([...new Set(exits.map(e => e.line))].sort()).toEqual([...SANCTIONED_EXITS].sort());});- it('forces the Resolve-Pm2Command result into an array', () => {- // PowerShell unrolls a single-element array into a bare string, and- // `$pm2 + @('start', …)` on a string concatenates into one garbage token- // instead of an argument list — so the PATH fallback would never start pm2.+ it('keeps every Resolve-Pm2Command branch a plain array collected by @()', () => {+ // `return` ENUMERATES an array into the output stream, so a single-element+ // branch arrives as a bare string and `$pm2 + @('start', …)` concatenates+ // into one garbage token — the PATH fallback would never start pm2. The+ // call-site @() fixes that, but only if every branch returns a PLAIN array:+ // a `,@(…)` wrapper emits the array as ONE stream item and @() nests rather+ // than flattens it, so $CmdArgs[0] is an object[] instead of the executable.expect(ps1.some(line => line.includes('$pm2 = @(Resolve-Pm2Command)'))).toBe(true);- expect(ps1.some(line => line.includes("return ,@('pm2')"))).toBe(true);++ const body = ps1.slice(lineOf('function Resolve-Pm2Command'), lineOf('function Restore-Pm2Apps'));+ const returns = body.map(line => line.trim()).filter(line => line.startsWith('return'));+ expect(returns.length).toBeGreaterThan(2);+ expect(returns.filter(line => /return\s*,/.test(line)), 'a ,@() return nests instead of flattening').toEqual([]);+ expect(returns.every(line => /^return\s+@\(/.test(line))).toBe(true);});it('arms the latch before the delete, not after', () => {diff --git a/server/lib/sglangQwenProject.js b/server/lib/sglangQwenProject.jsindex d76d1cc15c..44e69ddeb7 100644--- a/server/lib/sglangQwenProject.js+++ b/server/lib/sglangQwenProject.js@@ -47,12 +47,15 @@ import { homedir } from 'os';import { join } from 'path';import {- PORTOS_ENV_PATH,projectDirIsSettled,readRecordedProjectDir,recordProjectDir,resolveRecordedProjectDir,} from './recordedProjectDir.js';+// PORTOS_ENV_PATH is declared by portosEnv.js; recordedProjectDir.js imports it+// for its own defaults but does not re-export it — and it cannot, because both+// modules are `export *`'d from lib/index.js and a re-export would collide there.+import { PORTOS_ENV_PATH } from './portosEnv.js';/** Operator override for where the compose project was created. */export const SGLANG_PROJECT_DIR_ENV = 'SGLANG_QWEN_PROJECT_DIR';diff --git a/server/lib/vllmQwenProject.js b/server/lib/vllmQwenProject.jsindex 915a29bc57..bb5822fe93 100644--- a/server/lib/vllmQwenProject.js+++ b/server/lib/vllmQwenProject.js@@ -45,12 +45,15 @@ import { homedir } from 'os';import { join } from 'path';import {- PORTOS_ENV_PATH,projectDirIsSettled,readRecordedProjectDir,recordProjectDir,resolveRecordedProjectDir,} from './recordedProjectDir.js';+// PORTOS_ENV_PATH is declared by portosEnv.js; recordedProjectDir.js imports it+// for its own defaults but does not re-export it — and it cannot, because both+// modules are `export *`'d from lib/index.js and a re-export would collide there.+import { PORTOS_ENV_PATH } from './portosEnv.js';/** Operator override for where the compose project was cloned. */export const VLLM_PROJECT_DIR_ENV = 'VLLM_QWEN_PROJECT_DIR';diff --git a/update.ps1 b/update.ps1index fdc4afd20a..2d18856be8 100644--- a/update.ps1+++ b/update.ps1@@ -107,10 +107,7 @@ function Resolve-Pm2Command {return @('node', (Join-Path $RootDir 'node_modules/pm2/bin/pm2'))}if (Get-Command pm2 -ErrorAction SilentlyContinue) {- # `,` keeps PowerShell from unrolling this single-element array into a- # bare string — `$pm2 + @('start', …)` on a string concatenates into one- # garbage token instead of building an argument list.- return ,@('pm2')+ return @('pm2')}$pinned = try { (Get-Content "$RootDir\package.json" -Raw | ConvertFrom-Json).dependencies.pm2 } catch { $null }if ($pinned) { return @('npx', '--yes', "pm2@$pinned") }@@ -121,7 +118,12 @@ function Restore-Pm2Apps {if (-not $script:Pm2AppsDown) { return }$script:Pm2AppsDown = $falsetry {- # @() again at the call site, so no future branch can regress the shape.+ # @() at the call site is what keeps the shape right: `return` ENUMERATES+ # an array into the output stream, so a single-element branch would arrive+ # as a bare string and `$pm2 + @('start', …)` would concatenate into one+ # garbage token. @() collects the stream back into a flat array. Every+ # branch must therefore return a PLAIN array — a `,@(…)` wrapper would+ # emit the array as one item and @() would nest rather than flatten it.$pm2 = @(Resolve-Pm2Command)Write-SafeHost "⚠️ Update is exiting with PortOS's apps deleted — restarting them so the install isn't left headless." -ForegroundColor YellowStep "restart" "running" "Update failed — restarting PortOS so it isn't left down..."diff --git a/update.sh b/update.shindex e0903ccd4f..efba285c9e 100755--- a/update.sh+++ b/update.sh@@ -215,7 +215,11 @@ resolve_pm2_cmd() {restore_pm2_apps_on_exit() {local status=$?- trap - EXIT+ # Disarm every trap, not just EXIT: a second signal (Ctrl-C twice, an+ # escalating killer) arriving while the recovery's own `pm2 start` and health+ # probe are running would otherwise abort it mid-flight and leave the install+ # headless — exactly the state this function exists to prevent.+ trap - EXIT TERM INT HUPif [ "$PM2_APPS_DOWN" = "1" ]; thenPM2_APPS_DOWN=0resolve_pm2_cmd