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: reconcile bounded task routes with store imports
atomanticagent598a8b300cb1
diff --cc server/routes/cosTaskRoutes.jsindex a6e8dcb8da,a6bf77fc6c..966c10263e--- a/server/routes/cosTaskRoutes.js+++ b/server/routes/cosTaskRoutes.js@@@ -6,7 -6,10 +6,10 @@@ import { Router } from 'express'import { z } from 'zod';import { existsSync } from 'fs';import { isRepo, notGitRepoMessage } from '../services/git.js';- import * as cos from '../services/cos.js';-import { addTask, approveTask, challengeTask, deleteTask, findTaskWithSource, getAllTasks, getCosTasks, getTaskById, getTaskView, getUserTasks, reorderTasks, resolveTaskChallenge, resolveTaskChallengeWithRecheck, updateTask } from '../services/cosTaskStore.js';++import { addTask, approveTask, challengeTask, deleteTask, findTaskWithSource, getAllTasks, getTaskById, getTaskView, reorderTasks, resolveTaskChallenge, resolveTaskChallengeWithRecheck, updateTask } from '../services/cosTaskStore.js';+ import { evaluateTasks } from '../services/cosTaskGenerator.js';+ import { forceSpawnTask } from '../services/cos.js';+ import { getAgents } from '../services/cosAgentLifecycle.js';import { enhanceTaskPrompt } from '../services/taskEnhancer.js';import { buildClaimWorkTask, buildIssueReplanTask, buildJiraTicketTask } from '../services/cosTaskClaimWork.js';import { getAppById, getAppWorkTracker, PORTOS_APP_ID } from '../services/apps.js';@@@ -233,15 -236,16 +236,15 @@@ router.get('/tasks', asyncHandler(asyn});}));- // GET /api/cos/tasks/user and /internal - one source's bounded view: open tasks- // whole, completed history reduced to the first page + `completedCount`- // (page on with `/tasks?view=completed`); the raw store is `/tasks?view=full` (#12997).-// GET /api/cos/tasks/user - Get user tasks++// Source-specific bounded views: open tasks plus the first completed page.++// Further history is available through /tasks?view=completed; raw data through /tasks?view=full.router.get('/tasks/user', asyncHandler(async (req, res) => {- res.json((await cos.getTaskView({ kind: 'bare' })).user);- const tasks = await getUserTasks();- res.json(tasks);++ res.json((await getTaskView({ kind: 'bare' })).user);}));+ // GET /api/cos/tasks/internal - Get CoS internal tasksrouter.get('/tasks/internal', asyncHandler(async (req, res) => {- res.json((await cos.getTaskView({ kind: 'bare' })).cos);- const tasks = await getCosTasks();- res.json(tasks);++ res.json((await getTaskView({ kind: 'bare' })).cos);}));// GET /api/cos/tasks/:id - One task with the queue it lives in. The Chief ofdiff --cc server/routes/cosTaskRoutes.test.jsindex a1cad199c1,38330dff4a..414ae6f199--- a/server/routes/cosTaskRoutes.test.js+++ b/server/routes/cosTaskRoutes.test.js@@@ -71,7 -77,9 +77,9 @@@ vi.mock('../services/instances.js', ()vi.mock('../services/managedAppRepositories.js', () => ({ resolveManagedAppIssueTarget: vi.fn() }));vi.mock('../services/goalFidelityCalibration.js', () => ({ reportGoalFidelityFalsePositive: vi.fn() }));- import * as cos from '../services/cos.js';-import { addTask, approveTask, deleteTask, findTaskWithSource, getAllTasks, getTaskById, getTaskView, getUserTasks, updateTask } from '../services/cosTaskStore.js';++import { addTask, approveTask, deleteTask, findTaskWithSource, getAllTasks, getCosTasks, getTaskById, getTaskView, getUserTasks, updateTask } from '../services/cosTaskStore.js';+ import { forceSpawnTask } from '../services/cos.js';+ import { getAgents } from '../services/cosAgentLifecycle.js';import { getAssignableInstances } from '../services/instances.js';import { getAppById, getAppWorkTracker } from '../services/apps.js';import { resolveManagedAppIssueTarget } from '../services/managedAppRepositories.js';@@@ -159,8 -167,8 +167,8 @@@ describe('GET /api/cos/tasks/:id', () =});it('is a 404 for an unknown id and never shadows the literal list routes', async () => {- cos.findTaskWithSource.mockResolvedValue(null);- cos.getTaskView.mockResolvedValue({ user: { tasks: [] }, cos: { tasks: [] } });+ findTaskWithSource.mockResolvedValue(null);- getUserTasks.mockResolvedValue({ tasks: [] });++ getTaskView.mockResolvedValue({ user: { tasks: [] }, cos: { tasks: [] } });const missing = await request(buildApp()).get('/api/cos/tasks/no-such-task');expect(missing.status).toBe(404);@@@ -655,22 -663,12 +663,26 @@@ describe('GET /api/cos/tasks — boundeexpect(res.body.user.grouped.in_progress.map(t => t.id)).toEqual(['user/1']);});- it.each([['user', 'user'], ['internal', 'cos']])('/tasks/%s serves that source from the bounded reader (#12997)', async (route, key) => {- cos.getTaskView.mockResolvedValue({ user: { ...open(), completedCount: 40 }, cos: { ...empty, type: 'internal', completedCount: 3 } });++ it.each([['user', 'user'], ['internal', 'cos']])('/tasks/%s serves bounded completed history (#12997)', async (route, key) => {++ const views = {++ user: { ...open(), completedCount: 40, completedNextCursor: 'user-cursor' },++ cos: { ...empty, type: 'internal', completedCount: 3, completedNextCursor: 'cos-cursor' },++ };++ getTaskView.mockResolvedValue(views);+ const res = await request(buildApp()).get(`/api/cos/tasks/${route}`);- expect(cos.getTaskView).toHaveBeenCalledWith({ kind: 'bare' });- expect(cos.getUserTasks).not.toHaveBeenCalled();- expect(cos.getCosTasks).not.toHaveBeenCalled();- expect(res.body.completedCount).toBe(key === 'user' ? 40 : 3);- expect(res.body.user).toBeUndefined();++ expect(res.status).toBe(200);++ expect(res.body).toEqual(views[key]);++ expect(getTaskView).toHaveBeenCalledWith({ kind: 'bare' });++ expect(getUserTasks).not.toHaveBeenCalled();++ expect(getCosTasks).not.toHaveBeenCalled();+ });+it('queue view summarizes the derived lists and forwards the selected id', async () => {- cos.getTaskView.mockResolvedValue({ user: { ...open(), completedCount: 9,+ getTaskView.mockResolvedValue({ user: { ...open(), completedCount: 9,grouped: { pending: [{ id: 'user/1', status: 'pending', description: 'x' }], completed: [{ id: 'user/old', status: 'completed', description: 'y' }] } }, cos: empty });- cos.getAgents.mockResolvedValue([live('user/1')]);+ getAgents.mockResolvedValue([live('user/1')]);const res = await request(buildApp()).get('/api/cos/tasks?view=queue&selected=user/old');- expect(cos.getTaskView).toHaveBeenCalledWith({ kind: 'queue', selected: 'user/old' });+ expect(getTaskView).toHaveBeenCalledWith({ kind: 'queue', selected: 'user/old' });expect(res.body.user.completedCount).toBe(9);expect(res.body.user.grouped).toEqual({pending: [], in_progress: [{ id: 'user/1', status: 'pending', spawning: true }],