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
address review: 3 Copilot findings on v1.54.0 PR (iter 9)
[._.]/ Adam Eivyf76d6b0cc897
diff --git a/server/index.js b/server/index.jsindex 78e7921a1f..f0eb43155e 100644--- a/server/index.js+++ b/server/index.js@@ -234,10 +234,10 @@ try {// invocation conventions, not for security.import { executeCliRun as executeCliRunFixed } from './services/runner.js';aiToolkit.services.runner.executeCliRun = executeCliRunFixed;-// Also patch stopRun so it can terminate child processes started by the-// PortOS variant — those are tracked in `_portosActiveRuns`, not the-// toolkit's internal `activeRuns` map, so the stock stopRun returns false-// for live CLI runs.+// Also patch stopRun + isRunActive so they consult `_portosActiveRuns`+// (where the PortOS CLI variant tracks child processes), not just the+// toolkit's internal `activeRuns` map. Without this, the runs router+// would report live CLI runs as inactive and refuse to stop them.const originalStopRun = aiToolkit.services.runner.stopRun.bind(aiToolkit.services.runner);aiToolkit.services.runner.stopRun = async (runId) => {const portosActive = aiToolkit.services.runner._portosActiveRuns?.get(runId);@@ -248,7 +248,12 @@ aiToolkit.services.runner.stopRun = async (runId) => {}return originalStopRun(runId);};-console.log('🔧 Patched aiToolkit runner.executeCliRun + stopRun with PortOS CLI variants');+const originalIsRunActive = aiToolkit.services.runner.isRunActive.bind(aiToolkit.services.runner);+aiToolkit.services.runner.isRunActive = (runId) => {+ if (aiToolkit.services.runner._portosActiveRuns?.has(runId)) return true;+ return originalIsRunActive(runId);+};+console.log('🔧 Patched aiToolkit runner.executeCliRun + stopRun + isRunActive with PortOS CLI variants');// Note: prompts service is initialized automatically by createAIToolkit()diff --git a/server/routes/providers.js b/server/routes/providers.jsindex c9eada6adc..dd93845c6b 100644--- a/server/routes/providers.js+++ b/server/routes/providers.js@@ -134,12 +134,22 @@ export function createPortOSProviderRoutes(aiToolkit) {res.json(sanitizeProvider(provider));}));- // PUT /:id — intercept to preserve redacted secrets before passing to toolkit+ // PUT /:id — intercept to (a) validate the body via a partial provider+ // schema (PUT can be a partial update; only the fields the client sent are+ // re-validated), and (b) preserve redacted secrets before passing to the+ // toolkit. Without partial validation, an `updateProvider` call could+ // still persist invalid types (timeout: "abc", non-object envVars) the+ // POST path now blocks.router.put('/:id', asyncHandler(async (req, res) => {const existing = await providerService.getProviderById(req.params.id);if (!existing) return res.status(404).json({ error: 'Provider not found' });- const updates = { ...req.body };+ const validation = validate(providerSchema.partial(), req.body);+ if (!validation.success) {+ return res.status(400).json({ error: 'Invalid provider data', details: validation.errors });+ }++ const updates = { ...validation.data };// Preserve existing apiKey if client didn't send a new oneif (!('apiKey' in updates)) {diff --git a/server/services/worldBuilderRefine.js b/server/services/worldBuilderRefine.jsindex 8e89ac8603..c2f61b139e 100644--- a/server/services/worldBuilderRefine.js+++ b/server/services/worldBuilderRefine.js@@ -307,14 +307,23 @@ const mergeCategoriesWithLocks = (originalCategories, llmCategories) => {const fresh = (llmCategories && typeof llmCategories === "object") ? llmCategories : {};const merged = {};- const allKeys = new Set([- ...Object.keys(orig).map((k) => normalizeCategoryKey(k) || k),- ...Object.keys(fresh).map((k) => normalizeCategoryKey(k) || k),- ]);+ // Build normalized-key lookups so the merge can find a fresh entry whose+ // raw key is e.g. "Secret Rituals" via the normalized form "secret_rituals"+ // (the LLM may not echo back the exact snake_case the schema uses).+ const buildLookup = (obj) => {+ const out = {};+ for (const [rawKey, value] of Object.entries(obj)) {+ out[normalizeCategoryKey(rawKey) || rawKey] = value;+ }+ return out;+ };+ const origByNorm = buildLookup(orig);+ const freshByNorm = buildLookup(fresh);+ const allKeys = new Set([...Object.keys(origByNorm), ...Object.keys(freshByNorm)]);for (const key of allKeys) {- const origVars = Array.isArray(orig?.[key]?.variations) ? orig[key].variations : [];- const llmVars = Array.isArray(fresh?.[key]?.variations) ? fresh[key].variations : [];+ const origVars = Array.isArray(origByNorm[key]?.variations) ? origByNorm[key].variations : [];+ const llmVars = Array.isArray(freshByNorm[key]?.variations) ? freshByNorm[key].variations : [];const lockedOrig = origVars.filter((v) => v?.locked === true);const lockedLabels = new Set(lockedOrig.map((v) => normalizeLabelKey(v.label)));