Team mode stays in the repository but is not built or shipped (ADR-0003). - The team server (index.ts, config, db, daemons, plugins, proactive, routes, scheduler, services, ws, drizzle migrations) and its tests move from @waggle/server to packages/team-server (@waggle/team-server, private). It keeps its own copies of the logger and the agent-group executor, so it does not import @waggle/server. @clerk/fastify, bullmq, ioredis, postgres, drizzle-orm, drizzle-kit, cron-parser and @waggle/waggle-dance leave @waggle/server; the launcher drops the same team-only dependencies. - build:packages no longer builds waggle-dance or the worker: nothing in the community edition imports them, and the worker's project reference would otherwise build the team server. The worker now imports from team-server; the team Dockerfile builds both explicitly. - The sidecar no longer starts the team server when DATABASE_URL is set, and loses the team routes (/api/team/*, /api/teams), the WaggleDance routes and bridge (/api/waggle-dance/*), the Team server binding and egress guard, the WebSocket team client, the TeamSync cache and pushes, team audit forwarding, team workspace registration and the team capability-policy lookup in chat. The in-process room signal bus stays: agent groups, fleet runs and external tool runs use it. middleware/audit.ts was dead and is deleted. - @waggle/core loses TeamSync and the teamServer part of WaggleConfig. A teamServer key in config.json is ignored and kept on save, as P0.1 does for the tier keys. Workspaces lose teamServerUrl and teamUserId; teamId and teamRole stay because workspaces from a shared data directory still carry them and the viewer write guards read them. POST /api/workspaces ignores team fields. - The sidecar bundle no longer marks the team packages as external. The agent still references the TeamSync type in orchestrator.ts and pattern-write-back.ts; those files are being rewritten in P1.5 and drop it there. Logs UF-030 and UF-031 (team sync and team policy defects found while removing the code).
92 lines
2.4 KiB
TypeScript
92 lines
2.4 KiB
TypeScript
import { eq, and } from 'drizzle-orm';
|
|
import { tasks } from '../db/schema.js';
|
|
import type { Db } from '../db/connection.js';
|
|
|
|
export interface TaskFilters {
|
|
status?: string;
|
|
assignee?: string;
|
|
priority?: string;
|
|
}
|
|
|
|
export class TaskService {
|
|
constructor(private db: Db) {}
|
|
|
|
async create(
|
|
teamId: string,
|
|
userId: string,
|
|
data: { title: string; description?: string; priority?: string; parentTaskId?: string },
|
|
) {
|
|
const [task] = await this.db.insert(tasks).values({
|
|
teamId,
|
|
title: data.title,
|
|
description: data.description,
|
|
priority: data.priority ?? 'normal',
|
|
createdBy: userId,
|
|
parentTaskId: data.parentTaskId,
|
|
}).returning();
|
|
return task;
|
|
}
|
|
|
|
async list(teamId: string, filters?: TaskFilters) {
|
|
const conditions = [eq(tasks.teamId, teamId)];
|
|
|
|
if (filters?.status) {
|
|
conditions.push(eq(tasks.status, filters.status));
|
|
}
|
|
if (filters?.assignee) {
|
|
conditions.push(eq(tasks.assignedTo, filters.assignee));
|
|
}
|
|
if (filters?.priority) {
|
|
conditions.push(eq(tasks.priority, filters.priority));
|
|
}
|
|
|
|
return this.db
|
|
.select()
|
|
.from(tasks)
|
|
.where(and(...conditions));
|
|
}
|
|
|
|
async get(taskId: string) {
|
|
const [task] = await this.db
|
|
.select()
|
|
.from(tasks)
|
|
.where(eq(tasks.id, taskId))
|
|
.limit(1);
|
|
return task ?? null;
|
|
}
|
|
|
|
async update(
|
|
taskId: string,
|
|
data: {
|
|
title?: string;
|
|
description?: string;
|
|
status?: string;
|
|
priority?: string;
|
|
assignedTo?: string | null;
|
|
},
|
|
) {
|
|
const setData: Record<string, unknown> = { updatedAt: new Date() };
|
|
if (data.title !== undefined) setData.title = data.title;
|
|
if (data.description !== undefined) setData.description = data.description;
|
|
if (data.status !== undefined) setData.status = data.status;
|
|
if (data.priority !== undefined) setData.priority = data.priority;
|
|
if (data.assignedTo !== undefined) setData.assignedTo = data.assignedTo;
|
|
|
|
const [updated] = await this.db
|
|
.update(tasks)
|
|
.set(setData)
|
|
.where(eq(tasks.id, taskId))
|
|
.returning();
|
|
return updated ?? null;
|
|
}
|
|
|
|
async claim(taskId: string, userId: string) {
|
|
const [updated] = await this.db
|
|
.update(tasks)
|
|
.set({ assignedTo: userId, status: 'claimed', updatedAt: new Date() })
|
|
.where(eq(tasks.id, taskId))
|
|
.returning();
|
|
return updated ?? null;
|
|
}
|
|
}
|