refactor(server): move the team runtime into a postponed package (P1.1)
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).
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type { Job } from 'bullmq';
|
||||
import type { JobData } from '../job-processor.js';
|
||||
import type { Db } from '../../../server/src/db/connection.js';
|
||||
import type { Db } from '../../../team-server/src/db/connection.js';
|
||||
import { runAgentLoop } from '@waggle/agent';
|
||||
import { createWorkerExecutionContext } from '../execution-policy.js';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Job } from 'bullmq';
|
||||
import type { Db } from '../../../server/src/db/connection.js';
|
||||
import type { Db } from '../../../team-server/src/db/connection.js';
|
||||
import type { JobData, JobHandler } from '../job-processor.js';
|
||||
|
||||
const DELEGATABLE_JOB_TYPES = new Set(['chat', 'task', 'waggle', 'group']);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { Job } from 'bullmq';
|
||||
import type { JobData } from '../job-processor.js';
|
||||
import type { Db } from '../../../server/src/db/connection.js';
|
||||
import { agentGroups, agentGroupMembers, agents } from '../../../server/src/db/schema.js';
|
||||
import type { Db } from '../../../team-server/src/db/connection.js';
|
||||
import { agentGroups, agentGroupMembers, agents } from '../../../team-server/src/db/schema.js';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import { executeParallel, type ExecutionDeps } from '../execution/parallel.js';
|
||||
import { executeSequential } from '../execution/sequential.js';
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
import type { Job } from 'bullmq';
|
||||
import type { JobData } from '../job-processor.js';
|
||||
import type { Db } from '../../../server/src/db/connection.js';
|
||||
import { tasks } from '../../../server/src/db/schema.js';
|
||||
import type { Db } from '../../../team-server/src/db/connection.js';
|
||||
import { tasks } from '../../../team-server/src/db/schema.js';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import { runAgentLoop } from '@waggle/agent';
|
||||
import { createWorkerExecutionContext } from '../execution-policy.js';
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
import type { Job } from 'bullmq';
|
||||
import type { JobData } from '../job-processor.js';
|
||||
import type { Db } from '../../../server/src/db/connection.js';
|
||||
import { teamEntities, tasks } from '../../../server/src/db/schema.js';
|
||||
import type { Db } from '../../../team-server/src/db/connection.js';
|
||||
import { teamEntities, tasks } from '../../../team-server/src/db/schema.js';
|
||||
import { sql } from 'drizzle-orm';
|
||||
import { WaggleDanceDispatcher } from '@waggle/waggle-dance';
|
||||
import type { WaggleMessage } from '@waggle/shared';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Worker } from 'bullmq';
|
||||
import { resolve } from 'node:path';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
import { createDb } from '../../server/src/db/connection.js';
|
||||
import { agentJobs } from '../../server/src/db/schema.js';
|
||||
import { createDb } from '../../team-server/src/db/connection.js';
|
||||
import { agentJobs } from '../../team-server/src/db/schema.js';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import { JobProcessor, type JobData } from './job-processor.js';
|
||||
import Redis from 'ioredis';
|
||||
@@ -11,7 +11,7 @@ import { taskHandler } from './handlers/task-handler.js';
|
||||
import { groupHandler } from './handlers/group-handler.js';
|
||||
import { createCronHandler } from './handlers/cron-handler.js';
|
||||
import { createWaggleHandler } from './handlers/waggle-handler.js';
|
||||
import { JobService } from '../../server/src/services/job-service.js';
|
||||
import { JobService } from '../../team-server/src/services/job-service.js';
|
||||
|
||||
const REDIS_URL = process.env.REDIS_URL ?? 'redis://localhost:6381';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Job } from 'bullmq';
|
||||
import type { Db } from '../../server/src/db/connection.js';
|
||||
import type { Db } from '../../team-server/src/db/connection.js';
|
||||
|
||||
export interface JobData {
|
||||
jobId: string;
|
||||
|
||||
@@ -7,7 +7,7 @@ import { installShutdownHandlers, isDirectModule } from '../src/index.js';
|
||||
const REPO_ROOT = fileURLToPath(new URL('../../../', import.meta.url));
|
||||
|
||||
describe('cloud worker production entrypoint', () => {
|
||||
it('builds a standalone compiled worker after its server dependency', () => {
|
||||
it('keeps a standalone compiled build outside the community-edition package build', () => {
|
||||
const rootPackage = JSON.parse(readFileSync(resolve(REPO_ROOT, 'package.json'), 'utf8')) as {
|
||||
scripts: Record<string, string>;
|
||||
};
|
||||
@@ -21,8 +21,8 @@ describe('cloud worker production entrypoint', () => {
|
||||
};
|
||||
const build = rootPackage.scripts['build:packages'];
|
||||
|
||||
expect(build.indexOf('../worker')).toBeGreaterThan(build.indexOf('../server'));
|
||||
expect(build).toContain('cd ../worker && npm run build');
|
||||
// Team mode, the worker included, is postponed and not built (ADR-0003).
|
||||
expect(build).not.toContain('../worker');
|
||||
expect(workerPackage.scripts?.build).toContain('tsc --build --force');
|
||||
expect(workerPackage.scripts?.build).toContain('--bundle');
|
||||
expect(workerPackage.main).toBe('dist/index.js');
|
||||
|
||||
@@ -3,7 +3,7 @@ import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import type { Job } from 'bullmq';
|
||||
import type { Db } from '../../../server/src/db/connection.js';
|
||||
import type { Db } from '../../../team-server/src/db/connection.js';
|
||||
import type { JobData } from '../../src/job-processor.js';
|
||||
|
||||
/** Build a minimal Job<JobData> mock — only `.data` is exercised by handlers. */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import type { Job } from 'bullmq';
|
||||
import type { Db } from '../../../server/src/db/connection.js';
|
||||
import type { Db } from '../../../team-server/src/db/connection.js';
|
||||
import type { JobData } from '../../src/job-processor.js';
|
||||
import { createCronHandler } from '../../src/handlers/cron-handler.js';
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import type { Job } from 'bullmq';
|
||||
import type { Db } from '../../../server/src/db/connection.js';
|
||||
import type { Db } from '../../../team-server/src/db/connection.js';
|
||||
import type { JobData } from '../../src/job-processor.js';
|
||||
|
||||
/** Build a minimal Job<JobData> mock — only `.data` is exercised by handlers. */
|
||||
@@ -30,7 +30,7 @@ vi.mock('drizzle-orm', () => ({
|
||||
}));
|
||||
|
||||
// ── Mock server DB schema ───────────────────────────────────────────────
|
||||
vi.mock('../../../server/src/db/schema.js', () => ({
|
||||
vi.mock('../../../team-server/src/db/schema.js', () => ({
|
||||
tasks: {
|
||||
id: 'tasks.id',
|
||||
teamId: 'tasks.teamId',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import type { Job } from 'bullmq';
|
||||
import type { Db } from '../../../server/src/db/connection.js';
|
||||
import type { Db } from '../../../team-server/src/db/connection.js';
|
||||
import type { JobData } from '../../src/job-processor.js';
|
||||
import { createWaggleHandler } from '../../src/handlers/waggle-handler.js';
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
|
||||
import type { Job } from 'bullmq';
|
||||
import { createWorker } from '../src/index.js';
|
||||
import { JobService } from '../../server/src/services/job-service.js';
|
||||
import { createDb } from '../../server/src/db/connection.js';
|
||||
import { users, teams, teamMembers, agentJobs } from '../../server/src/db/schema.js';
|
||||
import { JobService } from '../../team-server/src/services/job-service.js';
|
||||
import { createDb } from '../../team-server/src/db/connection.js';
|
||||
import { users, teams, teamMembers, agentJobs } from '../../team-server/src/db/schema.js';
|
||||
import { eq, sql } from 'drizzle-orm';
|
||||
import type { JobData } from '../src/job-processor.js';
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
},
|
||||
"references": [
|
||||
{ "path": "../shared" },
|
||||
{ "path": "../server" }
|
||||
{ "path": "../team-server" }
|
||||
],
|
||||
"include": ["src/**/*.ts"],
|
||||
"exclude": ["node_modules", "dist", "tests"]
|
||||
|
||||
Reference in New Issue
Block a user