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
Messages: name the exact binary macOS Full Disk Access needs (#12927)
[._.]/704fbf5956c3
diff --git a/client/src/components/messages/ContactsTab.jsx b/client/src/components/messages/ContactsTab.jsxindex 008a54b5e6..692671bfa6 100644--- a/client/src/components/messages/ContactsTab.jsx+++ b/client/src/components/messages/ContactsTab.jsx@@ -5,6 +5,7 @@ import {Users, UserPlus, ExternalLink,} from 'lucide-react';import toast from '../ui/Toast';+import FullDiskAccessSteps from './FullDiskAccessSteps';import BrailleSpinner from '../BrailleSpinner';import { formatCount, formatDateTime } from '../../utils/formatters';import {@@ -163,7 +164,9 @@ export default function ContactsTab() {) : (<div className="text-sm text-gray-300 space-y-2"><p className="text-port-error">{setup.error}</p>- {setup.remediation && <p className="text-gray-400">{setup.remediation}</p>}+ {setup.fullDiskAccess+ ? <FullDiskAccessSteps target={setup.fullDiskAccess} onRecheck={handleCheck} rechecking={checking} />+ : setup.remediation && <p className="text-gray-400">{setup.remediation}</p>}</div>)}</div>diff --git a/client/src/components/messages/FullDiskAccessSteps.jsx b/client/src/components/messages/FullDiskAccessSteps.jsxnew file mode 100644index 0000000000..3c95641f98--- /dev/null+++ b/client/src/components/messages/FullDiskAccessSteps.jsx@@ -0,0 +1,50 @@+import { Copy, ExternalLink, Loader2, RefreshCw } from 'lucide-react';+import { copyToClipboard } from '../../lib/clipboard';++// Grant steps for a macOS Full Disk Access denial. macOS never prompts for it,+// so the server names the exact binary to add (`fullDiskAccess` from+// server/lib/fullDiskAccess.js); a pm2 LaunchAgent install needs its node+// binary, not the terminal app.+export default function FullDiskAccessSteps({ target, onRecheck, rechecking = false }) {+ const isApp = target.launchedBy === 'app';+ return (+ <div className="space-y-3">+ <p className="text-gray-300">Add {target.paths.length > 1 ? 'these' : 'this'} to Full Disk Access:</p>+ {target.paths.map((path) => (+ <div key={path} className="flex items-center gap-2">+ <code className="flex-1 min-w-0 break-all px-2 py-1.5 bg-port-bg border border-port-border rounded text-xs text-gray-200">{path}</code>+ <button+ type="button"+ onClick={() => copyToClipboard(path, 'Path copied')}+ aria-label={`Copy ${path}`}+ className="shrink-0 inline-flex items-center justify-center min-h-[40px] min-w-[40px] bg-port-bg border border-port-border hover:border-port-accent text-gray-200 rounded-lg"+ >+ <Copy size={14} />+ </button>+ </div>+ ))}+ <div className="flex flex-wrap gap-2">+ <a+ href={target.settingsUrl}+ className="inline-flex items-center justify-center gap-2 min-h-[40px] px-4 py-2 bg-port-accent/20 hover:bg-port-accent/30 text-port-accent rounded-lg text-sm"+ >+ <ExternalLink size={14} />+ Open Full Disk Access settings+ </a>+ <button+ type="button"+ onClick={onRecheck}+ disabled={rechecking}+ className="inline-flex items-center justify-center gap-2 min-h-[40px] px-4 py-2 bg-port-bg border border-port-border hover:border-port-accent text-gray-200 rounded-lg text-sm disabled:opacity-40"+ >+ {rechecking ? <Loader2 size={14} className="animate-spin" /> : <RefreshCw size={14} />}+ Recheck+ </button>+ </div>+ <p className="text-xs text-gray-500">+ Click +, press Cmd+Shift+G, paste the path. Still blocked after Recheck? Restart PortOS.+ {!isApp && ' Changing Node versions needs a new grant.'}+ </p>+ </div>+ );+}diff --git a/client/src/components/messages/IMessageSettingsPanel.jsx b/client/src/components/messages/IMessageSettingsPanel.jsxindex 68bc10943e..d1664af714 100644--- a/client/src/components/messages/IMessageSettingsPanel.jsx+++ b/client/src/components/messages/IMessageSettingsPanel.jsx@@ -3,6 +3,7 @@ import SettingsLoadError from '../ui/SettingsLoadError';import { Link } from 'react-router';import { Save, Loader2, MessageSquare, ShieldCheck, ShieldAlert, RefreshCw } from 'lucide-react';import toast from '../ui/Toast';+import FullDiskAccessSteps from './FullDiskAccessSteps';import BrailleSpinner from '../BrailleSpinner';import { formatDateTime } from '../../utils/formatters';import { useSyncSourceSettings } from '../../hooks/useSyncSourceSettings';@@ -152,7 +153,9 @@ export function IMessageSettingsPanel({ onSynced }) {) : (<div className="text-sm text-gray-300 space-y-2"><p className="text-port-error">{setup.error}</p>- {setup.remediation && <p className="text-gray-400">{setup.remediation}</p>}+ {setup.fullDiskAccess+ ? <FullDiskAccessSteps target={setup.fullDiskAccess} onRecheck={handleCheck} rechecking={checking} />+ : setup.remediation && <p className="text-gray-400">{setup.remediation}</p>}</div>)}</div>diff --git a/client/src/components/messages/IMessageSettingsPanel.test.jsx b/client/src/components/messages/IMessageSettingsPanel.test.jsxnew file mode 100644index 0000000000..8f10765154--- /dev/null+++ b/client/src/components/messages/IMessageSettingsPanel.test.jsx@@ -0,0 +1,53 @@+import { beforeEach, describe, expect, it, vi } from 'vitest';+import { fireEvent, render, screen, waitFor } from '@testing-library/react';+import { MemoryRouter } from 'react-router';++const api = vi.hoisted(() => ({+ checkImessageSetup: vi.fn(),+ getImessageStatus: vi.fn(),+ getSettings: vi.fn(),+ syncImessage: vi.fn(),+ updateSettings: vi.fn(),+}));+const toast = vi.hoisted(() => Object.assign(vi.fn(), { error: vi.fn(), success: vi.fn() }));+const clipboard = vi.hoisted(() => ({ copyToClipboard: vi.fn() }));++vi.mock('../../services/api', () => api);+vi.mock('../ui/Toast', () => ({ default: toast }));+vi.mock('../../lib/clipboard', () => clipboard);++const { IMessageSettingsPanel } = await import('./IMessageSettingsPanel');++const NODE = '/Users/example/.nvm/versions/node/v26.12.1/bin/node';+const SETTINGS_URL = 'x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles';++beforeEach(() => {+ vi.clearAllMocks();+ api.getSettings.mockResolvedValue({ imessage: { enabled: false, intervalMinutes: 30 } });+ api.getImessageStatus.mockResolvedValue({ state: {} });+});++describe('IMessageSettingsPanel Full Disk Access', () => {+ it('names the binary to grant, links the settings pane, and rechecks in place', async () => {+ api.syncImessage.mockResolvedValue({+ ok: false,+ error: 'unable to open database file',+ fullDiskAccessRequired: true,+ fullDiskAccess: { launchedBy: 'launchd', paths: [NODE], settingsUrl: SETTINGS_URL },+ });+ api.checkImessageSetup.mockResolvedValue({ ok: true, dbPath: '~/Library/Messages/chat.db', messageCount: 5 });+ render(<MemoryRouter><IMessageSettingsPanel /></MemoryRouter>);++ fireEvent.click(await screen.findByRole('button', { name: /Sync now/ }));+ expect(await screen.findByText(NODE)).toBeTruthy();+ expect(screen.getByRole('link', { name: /Open Full Disk Access settings/ }).getAttribute('href')).toBe(SETTINGS_URL);+ expect(screen.getByText(/Changing Node versions needs a new grant/)).toBeTruthy();++ fireEvent.click(screen.getByRole('button', { name: `Copy ${NODE}` }));+ expect(clipboard.copyToClipboard).toHaveBeenCalledWith(NODE, 'Path copied');++ fireEvent.click(screen.getByRole('button', { name: /Recheck/ }));+ await waitFor(() => expect(screen.getByText('Setup OK')).toBeTruthy());+ expect(api.checkImessageSetup).toHaveBeenCalledTimes(1);+ });+});diff --git a/server/lib/README.md b/server/lib/README.mdindex bbdeb5d1fa..f42232cfb5 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -451,6 +451,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `agentGuard/` | `agentGuardEnv(baseEnv?)` + `AGENT_GUARD_BIN` — env patch that prepends a guarded `pm2` shim (`bin/pm2`) to a spawned AI agent's PATH so a confused `--dangerously-skip-permissions` agent can't `pm2 kill` / `pm2 delete all` the shared daemon (which would down every app, incl. PortOS). Blocked-subcommand list mirrors `validatePm2Command` in `commandSecurity.js`. POSIX-only (no-op on Windows). || `bashResolver.js` | `resolveBashBinary()` — resolves the POSIX `bash` for running bundled `*.sh` scripts (e.g. `scripts/db.sh`). On Windows a bare `bash` often resolves (via PM2's PATH) to WSL, which mounts drives at `/mnt/h` and can't see a `H:/...` drive path (exit 127); this prefers Git Bash (PORTOS_BASH override → standard install dirs → derived from `git` on PATH → bare `bash`). No-op (`bash`) on non-Windows. `toBashPath(p)` — the companion path rule: bash reads backslashes as escapes, so a Windows path must reach it with forward slashes. || `interactiveShellResolver.js` | `resolveInteractiveShell()` — picks the shell binary a PTY session runs (Shell page, agent TUI shells). On Windows the old `COMSPEC` default meant `cmd.exe`, where no command a user would type reaches another drive: `cd I:` silently PRINTS that drive's cwd and stays put, a bare `I:\` is "not recognized as a command", and `cd 'I:\path'` is a syntax error (no single-quote quoting) — so a Windows install with its repos on a second drive was stuck on `C:`. Resolves PORTOS_SHELL → newest `pwsh.exe` under `%ProgramFiles%\PowerShell\<major>` (majors enumerated and sorted numerically, so a future 8 needs no code change) → any `pwsh.exe` on PATH via `findCommandOnPath` (scoop/choco/Store shim) → `powershell.exe` 5.1 (ships with Windows) → `cmd.exe` last. PowerShell crosses drives with every form. On POSIX: PORTOS_SHELL → existing `SHELL` → `/bin/bash` `/usr/bin/bash` `/bin/sh` `/usr/bin/sh` then zsh if present → bare `bash`/`sh` via `findCommandOnPath` → bare `sh` last — never a hard-coded missing `/bin/zsh` (PM2/containers often lack `SHELL` and zsh; node-pty then `execvp`s and the Shell page shows only `execvp(3) failed`). Memoized; `_resetInteractiveShellCache()` for tests. `resolveInteractiveShellWith({platform, env, exists, readdir, findOnPath})` is the un-memoized injectable form for tests. |+| `fullDiskAccess.js` | `fullDiskAccessDetails()` → `{ fullDiskAccess, remediation }` — names the exact binary macOS Full Disk Access must list (walks `ps` ancestry: a terminal `.app` when one started the server, else the server's own node binary plus a distinct pm2 daemon node under a LaunchAgent), with `FULL_DISK_ACCESS_SETTINGS_URL`. Used by the iMessage and Contacts setup checks. || `openFolder.js` | `openFolderInSystemExplorer(localPath)` — cross-platform "open in Finder/Explorer/Nautilus" via detached spawn; child `error` handler prevents spawn failures from crashing the process. || `childProcess.js` | Drop-in `child_process` replacement that defaults every spawn to `windowsHide: true` — `spawn` / `spawnSync` / `fork` / `exec` / `execSync` / `execFile` / `execFileSync`, plus a `ChildProcess` re-export. **Server runtime code must import from here, never from `child_process` directly** (enforced by `childProcess.guards.test.js`): a console-less PM2 fork spawning a console child without `CREATE_NO_WINDOW` makes Windows hand the new console to Windows Terminal, which flashes a focus-stealing window. `exec`/`execFile` carry `util.promisify.custom` so `promisify(execFile)` still resolves to `{ stdout, stderr }`. An explicit `windowsHide: false` is respected. Background: `docs/WINDOWS_CONSOLE.md`. || `bufferedSpawn.js` | `bufferedSpawn(cmd, args, opts)` (structured non-throwing result) + `bufferedSpawnOrThrow` (throwing adapter), plus `killProcessTree`, `terminateWithEscalation(child, { graceMs, label, processGroup })` (SIGTERM now, SIGKILL after the grace if the child is still running; returns a cancel for the caller's `close` handler — the one stop-escalation helper, used by the operator command runner's stop and by `bufferedSpawn`'s own timeout), `resolveWindowsExecutable`, `prepareWindowsSafeSpawn`, `prepareCliSpawn(command, args, env)` (composed resolve+wrap for a `spawn()`-safe pair), `needsShell`, `IS_WIN32`, `WIN_CMD_SHIMS`, `MAX_OUTPUT_BYTES`, `guardChildStdin(child)` (attach the no-op `stdin` `'error'` listener BEFORE any `stdin.write`/`stdin.end` — a child that dies before reading stdin makes the pipe emit `EPIPE`, and an unlistened stream `'error'` outside the Express request lifecycle takes the whole server process down; call it at every spawn that writes to a child's stdin) + `deliverChildStdin(child, payload, label)` (its other half: write-then-`end()` with a synchronously-throwing `write` caught, the pipe destroyed so a reading child sees EOF rather than hanging, and the failure logged so an empty-prompt run that exits 0 isn't filed as clean), `spawnFailureDetail(result, fallback)` (the most useful sentence from a failed result — prefers the spawn error, then a stderr line, then a stdout line that isn't bare JSON punctuation, because a `--json` CLI prints its payload to stdout even when it exits non-zero) — shared buffered-spawn machinery with capped stdout/stderr, timeout SIGTERM plus fire-and-forget SIGKILL escalation (`killGraceMs`, default 8s), Windows `.cmd`/`.bat` shim resolution, and `taskkill /T /F` tree-kill. `killProcessTree(child, signal, { processGroup })` takes the POSIX group down too when the child was spawned `detached` (Windows always tree-kills). A killable that is NOT a `ChildProcess` — a node-pty `IPty` TUI session — is killed through its own `.kill()`, with **no signal on Windows**: node-pty throws `Signals not supported on windows.` for any signal argument, so a signalled kill there killed nothing and threw past the caller. Used by `appBuilder.js`, `appUpdater.js`, the CoS agent spawners, and `setupScriptRunner.js`. |diff --git a/server/lib/fullDiskAccess.js b/server/lib/fullDiskAccess.jsnew file mode 100644index 0000000000..bf0623c227--- /dev/null+++ b/server/lib/fullDiskAccess.js@@ -0,0 +1,80 @@+import { runCliBounded } from './runCliBounded.js';++// macOS never prompts for Full Disk Access; the operator must add the exact+// binary TCC attributes the access to. Under a pm2 LaunchAgent that is the+// node binary itself (launchd is the parent, so no terminal app's grant+// applies); under a terminal-started server it is the terminal app. The grant+// is per binary path, so an nvm Node upgrade (new versions/node/vX path) needs+// a fresh grant.++export const FULL_DISK_ACCESS_SETTINGS_URL = 'x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles';++const MAX_ANCESTOR_HOPS = 12;+const APP_BUNDLE_RE = /^(.*?\.app)\/Contents\/MacOS\//;++// `ps -o ppid=,comm=` on macOS prints the parent pid and the full executable path.+function parsePsLine(stdout) {+ const m = String(stdout || '').trim().match(/^(\d+)\s+(.+)$/);+ return m ? { ppid: Number(m[1]), comm: m[2].trim() } : null;+}++async function defaultReadProcess(pid) {+ const { code, stdout } = await runCliBounded('ps', ['-o', 'ppid=,comm=', '-p', String(pid)], { timeoutMs: 2_000 });+ return code === 0 ? parsePsLine(stdout) : null;+}++/**+ * Pure: pick the grant target from the process ancestry (self first, nearest+ * parent next). The outermost `.app` bundle in the chain is what TCC credits+ * for a terminal-started server; with none, the chain ends at launchd and the+ * server's own binary (plus a distinct pm2 daemon binary) needs the grant.+ */+function resolveFullDiskAccessTarget({ execPath, ancestors = [] }) {+ let app = null;+ for (const comm of ancestors) {+ const m = comm.match(APP_BUNDLE_RE);+ if (m) app = m[1];+ }+ if (app) {+ return { launchedBy: 'app', paths: [app], hostApp: app.split('/').pop().replace(/\.app$/, '') };+ }+ const paths = [execPath];+ for (const comm of ancestors) {+ if (comm.startsWith('/') && /\/node$/.test(comm) && !paths.includes(comm)) paths.push(comm);+ }+ return { launchedBy: 'launchd', paths, hostApp: null };+}++function fullDiskAccessRemediation(target) {+ const what = target?.paths?.length ? target.paths.join(' and ') : 'the process running PortOS';+ return `Add ${what} to System Settings → Privacy & Security → Full Disk Access (+, then Cmd+Shift+G to paste the path), then restart PortOS.`;+}++// Never throws; off macOS (or when `ps` fails) it falls back to the server's own binary.+async function describeFullDiskAccessTarget({+ execPath = process.execPath,+ pid = process.pid,+ platform = process.platform,+ readProcess = defaultReadProcess,+} = {}) {+ const ancestors = [];+ if (platform === 'darwin') {+ let current = await readProcess(pid).catch(() => null);+ for (let hop = 0; current && current.ppid > 1 && hop < MAX_ANCESTOR_HOPS; hop += 1) {+ current = await readProcess(current.ppid).catch(() => null);+ if (current?.comm) ancestors.push(current.comm);+ }+ }+ const target = resolveFullDiskAccessTarget({ execPath, ancestors });+ return { ...target, settingsUrl: FULL_DISK_ACCESS_SETTINGS_URL, nodeVersion: process.version };+}++/**+ * Spread into a setup/sync failure report: `{ fullDiskAccess, remediation }`+ * naming which binary needs Full Disk Access on this machine. Options are+ * injectable for tests.+ */+export async function fullDiskAccessDetails(options) {+ const fullDiskAccess = await describeFullDiskAccessTarget(options);+ return { fullDiskAccess, remediation: fullDiskAccessRemediation(fullDiskAccess) };+}diff --git a/server/lib/fullDiskAccess.test.js b/server/lib/fullDiskAccess.test.jsnew file mode 100644index 0000000000..ec69ee4a88--- /dev/null+++ b/server/lib/fullDiskAccess.test.js@@ -0,0 +1,59 @@+import { describe, it, expect } from 'vitest';+import { fullDiskAccessDetails, FULL_DISK_ACCESS_SETTINGS_URL } from './fullDiskAccess.js';++const describeFullDiskAccessTarget = async (options) => (await fullDiskAccessDetails(options)).fullDiskAccess;++const NODE = '/Users/example/.nvm/versions/node/v26.12.1/bin/node';++// Fake process table: pid → { ppid, comm }.+const reader = (table) => async (pid) => table[pid] ?? null;++describe('fullDiskAccessDetails', () => {+ it('names the node binary when a pm2 LaunchAgent (launchd) owns the server', async () => {+ const target = await describeFullDiskAccessTarget({+ execPath: NODE,+ pid: 300,+ platform: 'darwin',+ readProcess: reader({ 300: { ppid: 200, comm: NODE }, 200: { ppid: 1, comm: NODE } }),+ });+ expect(target).toMatchObject({ launchedBy: 'launchd', paths: [NODE], settingsUrl: FULL_DISK_ACCESS_SETTINGS_URL });+ });++ it('puts the exact path in the remediation text', async () => {+ const { remediation } = await fullDiskAccessDetails({ execPath: NODE, platform: 'linux' });+ expect(remediation).toContain(`Add ${NODE} to System Settings`);+ });++ it('also names a pm2 daemon running on a different node binary', async () => {+ const daemon = '/opt/homebrew/Cellar/node/26.0.0/bin/node';+ const target = await describeFullDiskAccessTarget({+ execPath: NODE,+ pid: 300,+ platform: 'darwin',+ readProcess: reader({ 300: { ppid: 200, comm: NODE }, 200: { ppid: 1, comm: daemon } }),+ });+ expect(target.paths).toEqual([NODE, daemon]);+ });++ it('names the terminal app when one started the server', async () => {+ const target = await describeFullDiskAccessTarget({+ execPath: NODE,+ pid: 400,+ platform: 'darwin',+ readProcess: reader({+ 400: { ppid: 350, comm: NODE },+ 350: { ppid: 340, comm: '/bin/zsh' },+ 340: { ppid: 1, comm: '/Applications/iTerm.app/Contents/MacOS/iTerm2' },+ }),+ });+ expect(target).toMatchObject({ launchedBy: 'app', paths: ['/Applications/iTerm.app'], hostApp: 'iTerm' });+ });++ it('falls back to the server binary off macOS or when ps fails', async () => {+ const failing = async () => { throw new Error('ps missing'); };+ const target = await describeFullDiskAccessTarget({ execPath: NODE, pid: 1, platform: 'darwin', readProcess: failing });+ expect(target.paths).toEqual([NODE]);+ const linux = await describeFullDiskAccessTarget({ execPath: NODE, platform: 'linux', readProcess: failing });+ expect(linux.paths).toEqual([NODE]);+ });+});diff --git a/server/lib/index.js b/server/lib/index.jsindex c3706358b8..45e123a36f 100644--- a/server/lib/index.js+++ b/server/lib/index.js@@ -378,6 +378,7 @@ export * from './zipStream.js';export * from './zipWriter.js';// === Process execution ===+export * from './fullDiskAccess.js';export * from './agentGuard/index.js';export * from './agentFinalVerdict.js';export * from './agentOutcome.js';diff --git a/server/services/contactsSync.js b/server/services/contactsSync.jsindex e822d79b07..c61a9d95f4 100644--- a/server/services/contactsSync.js+++ b/server/services/contactsSync.js@@ -16,6 +16,7 @@ import { join } from 'node:path';import { expandHome, dataPath, atomicWrite, tryReadFile, safeJSONParse } from '../lib/fileUtils.js';import { identityFromHandle, normalizeIdentifier, normalizePhone } from '../lib/tribeMatch.js';+import { fullDiskAccessDetails } from '../lib/fullDiskAccess.js';const DEFAULT_AB_ROOT = '~/Library/Application Support/AddressBook';const CACHE_FILE = 'contacts-cache.json';@@ -370,14 +371,15 @@ export async function checkSetup() {try {paths = discoverAddressBookPaths(root);} catch (err) {+ const fullDiskAccessRequired = isPermissionError(err);return {ok: false,root,error: err?.message || 'Failed to scan AddressBook directory',- fullDiskAccessRequired: isPermissionError(err),- remediation: isPermissionError(err)- ? 'Grant Full Disk Access to the process running PortOS (System Settings → Privacy & Security → Full Disk Access), then restart PortOS.'- : `Could not scan ${root}: ${err?.message || 'unknown error'}`,+ fullDiskAccessRequired,+ ...(fullDiskAccessRequired+ ? await fullDiskAccessDetails()+ : { remediation: `Could not scan ${root}: ${err?.message || 'unknown error'}` }),};}if (paths.length === 0) {@@ -405,9 +407,7 @@ export async function checkSetup() {paths,error: probe.error,fullDiskAccessRequired: probe.permission,- remediation: probe.permission- ? 'Grant Full Disk Access to the process running PortOS (System Settings → Privacy & Security → Full Disk Access), then restart PortOS.'- : probe.error,+ ...(probe.permission ? await fullDiskAccessDetails() : { remediation: probe.error }),};}// Count across all sources (cheap open).diff --git a/server/services/imessageSync.js b/server/services/imessageSync.jsindex 482c0a351b..6b2a2af28d 100644--- a/server/services/imessageSync.js+++ b/server/services/imessageSync.js@@ -29,6 +29,7 @@ import { getUserTimezone } from './userTimezone.js';import { identityFromHandle } from '../lib/tribeMatch.js';import { shortSummary, localDayKey } from './humanActivity.js';import { getSettings } from './settings.js';+import { fullDiskAccessDetails } from '../lib/fullDiskAccess.js';// ---------------------------------------------------------------------------// Constants@@ -285,8 +286,6 @@ function isFullDiskAccessError(err) {}}-const FDA_REMEDIATION = 'Grant Full Disk Access to the process running PortOS (node or the PM2 daemon): System Settings → Privacy & Security → Full Disk Access → enable your terminal / node / pm2, then restart PortOS.';-/*** Attempt to open chat.db read-only and run a trivial probe query. Returns a* structured report — never throws — so the setup-check route can render an@@ -306,7 +305,9 @@ export async function checkSetup() {dbPath: path,error: err?.message || 'Failed to open chat.db',fullDiskAccessRequired,- remediation: fullDiskAccessRequired ? FDA_REMEDIATION : `Could not read ${path}: ${err?.message || 'unknown error'}`,+ ...(fullDiskAccessRequired+ ? await fullDiskAccessDetails()+ : { remediation: `Could not read ${path}: ${err?.message || 'unknown error'}` }),};} finally {try { db?.close(); } catch { /* already closed / never opened */ }@@ -417,7 +418,7 @@ async function doRunSync() {ok: false,error: err?.message || 'Failed to open chat.db',fullDiskAccessRequired,- remediation: fullDiskAccessRequired ? FDA_REMEDIATION : undefined,+ ...(fullDiskAccessRequired ? await fullDiskAccessDetails() : {}),};} finally {try { db?.close(); } catch { /* noop */ }