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

fix: address PR review feedback

Adam Eivy106bba869ee4
diff --git a/client/src/components/cos/tabs/TasksTab.jsx b/client/src/components/cos/tabs/TasksTab.jsx
index b8f96892e5..2f58493cf8 100644
--- a/client/src/components/cos/tabs/TasksTab.jsx
+++ b/client/src/components/cos/tabs/TasksTab.jsx
@@ -1,5 +1,5 @@
import { useState, useEffect, useRef, useMemo, useCallback } from 'react';
-import { Plus, Play, Image, X, ChevronDown, ChevronRight, Sparkles, Loader2, Paperclip, FileText, Zap, Bookmark, Trash2 } from 'lucide-react';
+import { Plus, Play, Image, X, ChevronDown, ChevronRight, Sparkles, Loader2, Paperclip, FileText, Zap, Bookmark } from 'lucide-react';
import toast from 'react-hot-toast';
import {
DndContext,
diff --git a/server/cos-runner/index.js b/server/cos-runner/index.js
index 7d028b1215..0313819080 100644
--- a/server/cos-runner/index.js
+++ b/server/cos-runner/index.js
@@ -94,6 +94,10 @@ function summarizeToolInput(toolName, input) {
}
}
+function safeParse(str) {
+ try { return JSON.parse(str); } catch { return null; }
+}
+
/**
* Create a Claude stream-json parser that extracts human-readable text from JSON stream events.
* Returns a stateful parser with a `processChunk(data)` method that returns extracted text lines.
@@ -116,7 +120,7 @@ function createStreamJsonParser() {
if (!trimmed || !trimmed.startsWith('{')) continue;
let parsed;
- parsed = JSON.parse(trimmed);
+ parsed = safeParse(trimmed);
if (!parsed) continue;
if (parsed.type === 'stream_event') {
@@ -149,11 +153,12 @@ function createStreamJsonParser() {
const idx = event.index;
const tool = activeTools.get(idx);
if (tool && tool.inputJson) {
- let input;
- input = JSON.parse(tool.inputJson);
- const detail = summarizeToolInput(tool.name, input);
- if (detail) {
- lines.push(` → ${detail}`);
+ const input = safeParse(tool.inputJson);
+ if (input) {
+ const detail = summarizeToolInput(tool.name, input);
+ if (detail) {
+ lines.push(` → ${detail}`);
+ }
}
activeTools.delete(idx);
}
@@ -464,8 +469,11 @@ app.post('/spawn', async (req, res) => {
const agent = activeAgents.get(agentId);
if (agent?.streamParser) {
- // Parse stream-json and emit extracted text lines
+ // Parse stream-json and emit extracted text lines (cap buffer at 512KB for error analysis)
agent.rawStreamBuffer += text;
+ if (agent.rawStreamBuffer.length > 512 * 1024) {
+ agent.rawStreamBuffer = agent.rawStreamBuffer.slice(-512 * 1024);
+ }
const lines = agent.streamParser.processChunk(text);
for (const line of lines) {
agent.outputBuffer += line + '\n';
diff --git a/server/lib/digitalTwinValidation.js b/server/lib/digitalTwinValidation.js
index b5418653ef..f883de5897 100644
--- a/server/lib/digitalTwinValidation.js
+++ b/server/lib/digitalTwinValidation.js
@@ -207,7 +207,7 @@ export const enrichmentQuestionInputSchema = z.object({
category: enrichmentCategoryEnum,
providerOverride: z.string().optional(),
modelOverride: z.string().optional(),
- skipIndices: z.array(z.number().int().min(0)).optional()
+ skipIndices: z.array(z.number().int()).optional()
});
// Enrichment answer input
@@ -225,6 +225,9 @@ export const enrichmentAnswerInputSchema = z.object({
data => (data.questionType === 'text' && data.answer) ||
(data.questionType === 'scale' && data.scaleValue != null),
{ message: 'Text questions require answer; scale questions require scaleValue' }
+).refine(
+ data => data.questionType !== 'scale' || data.scaleQuestionId,
+ { message: 'Scale questions require scaleQuestionId' }
);
// Export input
diff --git a/server/routes/cos.js b/server/routes/cos.js
index 236c905f77..e5f178df33 100644
--- a/server/routes/cos.js
+++ b/server/routes/cos.js
@@ -733,14 +733,14 @@ router.post('/jobs/:id/trigger', asyncHandler(async (req, res) => {
throw new ServerError('Job not found', { status: 404, code: 'NOT_FOUND' });
}
- // Generate task and add to CoS task queue
+ // Generate task and add to CoS internal task queue
const task = autonomousJobs.generateTaskFromJob(job);
const result = await cos.addTask({
description: task.description,
priority: task.priority,
context: `Manually triggered autonomous job: ${job.name}`,
- ...task.metadata
- }, 'cos');
+ approvalRequired: !task.autoApprove
+ }, 'internal');
await autonomousJobs.recordJobExecution(job.id);
res.json({ success: true, task: result });
diff --git a/server/services/autonomousJobs.js b/server/services/autonomousJobs.js
index dd247eea24..7171a33709 100644
--- a/server/services/autonomousJobs.js
+++ b/server/services/autonomousJobs.js
@@ -50,8 +50,6 @@ const DEFAULT_JOBS = [
You are acting as my Chief of Staff, maintaining my GitHub repositories.
-My GitHub username is: atomantic
-
Tasks to perform:
1. Check my local git repositories for uncommitted changes or stale branches
2. Look for repositories that haven't been updated recently
diff --git a/server/services/brain.js b/server/services/brain.js
index 878e0c12ae..c92d5ec2ee 100644
--- a/server/services/brain.js
+++ b/server/services/brain.js
@@ -184,7 +184,8 @@ export async function captureThought(text, providerOverride, modelOverride) {
console.log(`🧠 Thought captured, classifying in background: ${inboxEntry.id}`);
// Run AI classification in background (don't await)
- classifyInBackground(inboxEntry.id, text, meta, providerOverride, modelOverride);
+ classifyInBackground(inboxEntry.id, text, meta, providerOverride, modelOverride)
+ .catch(err => console.error(`❌ Background classification failed for ${inboxEntry.id}: ${err.message}`));
return {
inboxLog: inboxEntry,
diff --git a/server/services/runner.js b/server/services/runner.js
index c26f9c9628..f0b7fe0202 100644
--- a/server/services/runner.js
+++ b/server/services/runner.js
@@ -33,17 +33,19 @@ export async function executeCliRun(runId, provider, prompt, workspacePath, onDa
const startTime = Date.now();
let output = '';
- // Build command with args - NO shell: true
- const args = [...(provider.args || []), prompt];
- console.log(`🚀 Executing CLI: ${provider.command} ${args.join(' ')}`);
- console.log(`📝 Prompt length: ${prompt.length} chars, first 100: ${prompt.substring(0, 100)}`);
+ // Build command with args - prompt passed via stdin to avoid argv limits
+ const args = [...(provider.args || []), '-p', '-'];
+ console.log(`🚀 Executing CLI: ${provider.command} (${prompt.length} chars via stdin)`);
const childProcess = spawn(provider.command, args, {
cwd: workspacePath,
env: { ...process.env, ...provider.envVars }
- // Removed shell: true - this fixes the security warning and ensures proper argument handling
});
+ // Pass prompt via stdin to avoid OS argv limits
+ childProcess.stdin.write(prompt);
+ childProcess.stdin.end();
+
// Track active run (store on the runner service itself for stopRun to access)
if (!aiToolkitInstance.services.runner._portosActiveRuns) {
aiToolkitInstance.services.runner._portosActiveRuns = new Map();
diff --git a/server/services/subAgentSpawner.js b/server/services/subAgentSpawner.js
index 63cd061320..71e80d7f17 100644
--- a/server/services/subAgentSpawner.js
+++ b/server/services/subAgentSpawner.js
@@ -1488,8 +1488,11 @@ async function spawnDirectly(agentId, task, prompt, workspacePath, model, provid
}
if (streamParser) {
- // Parse stream-json and emit extracted text lines
+ // Parse stream-json and emit extracted text lines (cap buffer at 512KB for error analysis)
rawStreamBuffer += text;
+ if (rawStreamBuffer.length > 512 * 1024) {
+ rawStreamBuffer = rawStreamBuffer.slice(-512 * 1024);
+ }
const lines = streamParser.processChunk(text);
for (const line of lines) {
outputBuffer += line + '\n';
@@ -1679,6 +1682,10 @@ function summarizeToolInput(toolName, input) {
}
}
+function safeParse(str) {
+ try { return JSON.parse(str); } catch { return null; }
+}
+
/**
* Create a Claude stream-json parser that extracts human-readable text from JSON stream events.
* Returns a stateful parser with a `processChunk(data)` method that returns extracted text lines.
@@ -1712,7 +1719,7 @@ function createStreamJsonParser() {
let parsed;
// Skip non-JSON lines (stderr mixed in, etc.)
if (!trimmed.startsWith('{')) continue;
- parsed = JSON.parse(trimmed);
+ parsed = safeParse(trimmed);
if (!parsed) continue;
// Extract text from streaming deltas
@@ -1748,12 +1755,12 @@ function createStreamJsonParser() {
const idx = event.index;
const tool = activeTools.get(idx);
if (tool && tool.inputJson) {
- let input;
- // Parse accumulated JSON - may be incomplete for very large inputs
- input = JSON.parse(tool.inputJson);
- const detail = summarizeToolInput(tool.name, input);
- if (detail) {
- lines.push(` → ${detail}`);
+ const input = safeParse(tool.inputJson);
+ if (input) {
+ const detail = summarizeToolInput(tool.name, input);
+ if (detail) {
+ lines.push(` → ${detail}`);
+ }
}
activeTools.delete(idx);
}