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(cos): use runId from createRun in task enhancer
Adam Eivy6497f3608f92
diff --git a/.changelog/v0.10.x.md b/.changelog/v0.10.x.mdindex f1fb627192..15eccf94b2 100644--- a/.changelog/v0.10.x.md+++ b/.changelog/v0.10.x.md@@ -199,6 +199,10 @@ This release introduces a structured changelog documentation system for creating## 🐛 Bug Fixes+### Task Enhancer Directory Not Found Error+- **Fixed ENOENT error in task prompt enhancement**: The `taskEnhancer.js` was creating its own runId (`enhance-xxx`) and passing it to `createRun`, but the AI Toolkit's `createRun` ignores passed IDs and generates UUIDs. When `executeApiRun` was then called with the original `enhance-xxx` ID, the directory didn't exist.+- **Solution**: Now uses the `runId` returned from `createRun({ ... })` instead of generating a separate ID+### Critical: Fixed "Unexpected end of JSON input" Errors- **Safe JSON Parsing**: Added comprehensive JSON parsing utilities to `server/lib/fileUtils.js`:- `isValidJSON(str)` - Pre-validates JSON structure before parsing (supports both objects and arrays)diff --git a/package-lock.json b/package-lock.jsonindex 1832ec99fe..28b517dee8 100644--- a/package-lock.json+++ b/package-lock.json@@ -15,7 +15,7 @@],"dependencies": {"express": "^5.2.1",- "portos-ai-toolkit": "github:atomantic/portos-ai-toolkit#v0.1.3"+ "portos-ai-toolkit": "github:atomantic/portos-ai-toolkit#v0.2.0"},"devDependencies": {"concurrently": "^8.2.2"@@ -44,6 +44,40 @@"vite": "^6.0.6"}},+ "client/node_modules/portos-ai-toolkit": {+ "version": "0.1.2",+ "resolved": "https://registry.npmjs.org/portos-ai-toolkit/-/portos-ai-toolkit-0.1.2.tgz",+ "integrity": "sha512-EU3m/eNf91dXj1K4VjEK0G1Fuf3eLGL+O8Nc0ZybRBVlNrCj1Cu+7I0eCJYJlr8RyvPwRimBY760MmBEPLI4Nw==",+ "license": "MIT",+ "dependencies": {+ "uuid": "^11.0.3",+ "zod": "^3.24.1"+ },+ "peerDependencies": {+ "express": "^4.21.2 || ^5.2.1",+ "react": "^18.3.1",+ "react-dom": "^18.3.1",+ "socket.io": "^4.8.3",+ "socket.io-client": "^4.8.3"+ },+ "peerDependenciesMeta": {+ "express": {+ "optional": true+ },+ "react": {+ "optional": true+ },+ "react-dom": {+ "optional": true+ },+ "socket.io": {+ "optional": true+ },+ "socket.io-client": {+ "optional": true+ }+ }+ },"node_modules/@alloc/quick-lru": {"version": "5.2.0","resolved": "https://registry.npmjs.org/@alloc/quick-lru/-/quick-lru-5.2.0.tgz",@@ -4521,8 +4555,8 @@}},"node_modules/portos-ai-toolkit": {- "version": "0.1.3",- "resolved": "git+ssh://[email protected]/atomantic/portos-ai-toolkit.git#17b84c13011d66a9b53c97b865126f77dca13e72",+ "version": "0.2.0",+ "resolved": "git+ssh://[email protected]/atomantic/portos-ai-toolkit.git#54c33f88be85b1fa301c5ccb4ca099bfda4199e2","license": "MIT","dependencies": {"uuid": "^11.0.3",@@ -6441,7 +6475,7 @@"cors": "^2.8.5","express": "^4.21.2","pm2": "^5.4.3",- "portos-ai-toolkit": "^0.1.0",+ "portos-ai-toolkit": "github:atomantic/portos-ai-toolkit#v0.2.0","socket.io": "^4.8.3","socket.io-client": "^4.8.3","uuid": "^11.0.3",diff --git a/server/services/taskEnhancer.js b/server/services/taskEnhancer.jsindex cddbf2843f..126a4971b1 100644--- a/server/services/taskEnhancer.js+++ b/server/services/taskEnhancer.js@@ -74,14 +74,11 @@ export async function enhanceTaskPrompt(description, context = '') {.replace('{contextSection}', contextSection);// Create a run for this enhancement- const runId = `enhance-${Date.now().toString(36)}`;- await createRun({- id: runId,+ const { runId } = await createRun({providerId: provider.id,model,prompt: fullPrompt,- source: 'task-enhancement',- status: 'running'+ source: 'task-enhancement'});// Collect the response