Skip to content

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

address review: fix task override semantics, harden drill cache, secure BTW endpoint

Adam Eivy5e54e15b54b7
diff --git a/client/src/components/apps/tabs/AutomationTab.jsx b/client/src/components/apps/tabs/AutomationTab.jsx
index 487912ec9c..dfa57f0665 100644
--- a/client/src/components/apps/tabs/AutomationTab.jsx
+++ b/client/src/components/apps/tabs/AutomationTab.jsx
@@ -124,7 +124,7 @@ export default function AutomationTab({ appId, appName }) {
{taskTypes.map(taskType => {
const override = overrides[taskType] || {};
const globalConfig = schedule.tasks[taskType] || {};
- const isEnabled = override.enabled === true;
+ const isEnabled = override.enabled !== false;
const overrideInterval = override.interval || null;
return (
diff --git a/server/cos-runner/index.js b/server/cos-runner/index.js
index 606bca814c..a407b80651 100644
--- a/server/cos-runner/index.js
+++ b/server/cos-runner/index.js
@@ -472,7 +472,8 @@ app.post('/spawn', async (req, res) => {
startedAt: Date.now(),
outputBuffer: '',
rawStreamBuffer: '',
- streamParser
+ streamParser,
+ workspacePath: cwd
});
// Send prompt via stdin
@@ -690,7 +691,7 @@ app.post('/terminate-all', async (req, res) => {
*/
app.post('/btw/:agentId', async (req, res) => {
const { agentId } = req.params;
- const { message, workspacePath } = req.body;
+ const { message } = req.body;
const agent = activeAgents.get(agentId);
if (!agent) {
@@ -701,13 +702,15 @@ app.post('/btw/:agentId', async (req, res) => {
return res.status(400).json({ error: 'Missing or invalid message' });
}
- if (!workspacePath || typeof workspacePath !== 'string') {
- return res.status(400).json({ error: 'Missing workspacePath' });
+ // Derive workspace from the agent's known record, not from request body
+ const agentWorkspace = agent.workspacePath;
+ if (!agentWorkspace || typeof agentWorkspace !== 'string') {
+ return res.status(400).json({ error: 'Agent has no known workspacePath' });
}
const timestamp = new Date().toISOString();
const entry = `\n---\n**[${timestamp}]** ${message}\n`;
- const btwPath = join(workspacePath, 'BTW.md');
+ const btwPath = join(agentWorkspace, 'BTW.md');
// Append to BTW.md (create if first message)
const existing = await readFile(btwPath, 'utf-8').catch(() => '');
diff --git a/server/routes/meatspace.js b/server/routes/meatspace.js
index 72d0855d1a..588a30e029 100644
--- a/server/routes/meatspace.js
+++ b/server/routes/meatspace.js
@@ -1,5 +1,6 @@
import { Router } from 'express';
import { join } from 'path';
+import crypto from 'node:crypto';
import { asyncHandler, ServerError } from '../lib/errorHandler.js';
import { validateRequest } from '../lib/validation.js';
import { PATHS, readJSONFile } from '../lib/fileUtils.js';
diff --git a/server/services/apps.js b/server/services/apps.js
index 38ecdaae81..84370ef01c 100644
--- a/server/services/apps.js
+++ b/server/services/apps.js
@@ -310,7 +310,8 @@ export async function getAppTaskTypeOverrides(id) {
*/
export async function isTaskTypeEnabledForApp(id, taskType) {
const overrides = await getAppTaskTypeOverrides(id);
- return overrides[taskType]?.enabled === true;
+ // No override means inherit global (enabled); only disabled when explicitly false
+ return overrides[taskType]?.enabled !== false;
}
/**
@@ -346,8 +347,8 @@ export async function updateAppTaskTypeOverride(id, taskType, { enabled, interva
}
}
- // If override matches defaults (disabled, no interval, no metadata), remove the entry
- if (!updated.enabled && !updated.interval && !updated.taskMetadata) {
+ // Remove entry when all fields are inherit (enabled undefined, no interval, no metadata)
+ if (updated.enabled === undefined && !updated.interval && !updated.taskMetadata) {
delete overrides[taskType];
} else {
overrides[taskType] = updated;
diff --git a/server/services/cos.js b/server/services/cos.js
index 6270947491..568c77b5ab 100644
--- a/server/services/cos.js
+++ b/server/services/cos.js
@@ -2570,7 +2570,7 @@ export async function sendBtwToAgent(agentId, message) {
// Send to runner to write the BTW.md file
const { sendBtwToAgent: sendViaRunner } = await import('./cosRunnerClient.js');
- const result = await sendViaRunner(agentId, message, agentInfo.workspacePath);
+ const result = await sendViaRunner(agentId, message);
// Track in agent state (cap at 50 messages)
const timestamp = new Date().toISOString();
diff --git a/server/services/cosRunnerClient.js b/server/services/cosRunnerClient.js
index 5cc2130fa9..89c7cf8da9 100644
--- a/server/services/cosRunnerClient.js
+++ b/server/services/cosRunnerClient.js
@@ -223,11 +223,11 @@ export async function terminateAllAgentsViaRunner() {
/**
* Send a BTW (additional context) message to a running agent via the runner
*/
-export async function sendBtwToAgent(agentId, message, workspacePath) {
+export async function sendBtwToAgent(agentId, message) {
const response = await fetchWithTimeout(`${COS_RUNNER_URL}/btw/${agentId}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ message, workspacePath }),
+ body: JSON.stringify({ message }),
}, 30000);
if (!response.ok) {
const error = await response.json();
diff --git a/server/services/meatspacePostDrillCache.js b/server/services/meatspacePostDrillCache.js
index c8d4ca5a8c..d5ca7b9d17 100644
--- a/server/services/meatspacePostDrillCache.js
+++ b/server/services/meatspacePostDrillCache.js
@@ -5,9 +5,9 @@
* background replenishment kicks in. Cache persists to disk.
*/
-import { readFile, writeFile } from 'fs/promises';
-import { join } from 'path';
-import { PATHS } from '../lib/fileUtils.js';
+import { readFile, writeFile, mkdir } from 'fs/promises';
+import { join, dirname } from 'path';
+import { PATHS, safeJSONParse } from '../lib/fileUtils.js';
import { generateLlmDrill } from './meatspacePostLlm.js';
const CACHE_FILE = join(PATHS.data, 'meatspace', 'post-drill-cache.json');
@@ -25,13 +25,14 @@ let saveQueued = false;
async function loadCache() {
const raw = await readFile(CACHE_FILE, 'utf-8').catch(() => '{}');
- cache = JSON.parse(raw);
+ cache = safeJSONParse(raw, {});
for (const type of CACHEABLE_TYPES) {
if (!Array.isArray(cache[type])) cache[type] = [];
}
}
async function saveCache() {
+ await mkdir(dirname(CACHE_FILE), { recursive: true });
await writeFile(CACHE_FILE, JSON.stringify(cache, null, 2));
}