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:
shumeiko.it
2026-10-24 11:53:23 +02:00
parent 0cbde468a9
commit c25efe6c44
136 changed files with 450 additions and 4990 deletions

View File

@@ -2,7 +2,7 @@ import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { WaggleConfig, type ProviderEntry, type TeamServerConfig } from '../src/config.js';
import { WaggleConfig, type ProviderEntry } from '../src/config.js';
describe('WaggleConfig', () => {
const tempDirs: string[] = [];
@@ -100,58 +100,23 @@ describe('WaggleConfig', () => {
expect(config.getConfigDir()).toBe(configDir);
});
describe('team server config', () => {
it('returns null when no team server configured', () => {
describe('commercial-edition keys', () => {
it('ignores a teamServer key and keeps it in config.json on save', () => {
const configDir = makeTempDir();
const teamServer = { url: 'https://team.waggle.dev', token: 'clerk-jwt-token' };
fs.writeFileSync(
path.join(configDir, 'config.json'),
JSON.stringify({ defaultModel: 'claude-sonnet-4-6', providers: {}, teamServer }),
);
const config = new WaggleConfig(configDir);
expect(config.getTeamServer()).toBeNull();
expect(config.isTeamConnected()).toBe(false);
});
it('sets and gets team server config', () => {
const configDir = makeTempDir();
const config = new WaggleConfig(configDir);
const teamConfig: TeamServerConfig = {
url: 'https://team.waggle.dev',
token: 'clerk-jwt-token',
userId: 'user-123',
displayName: 'Marko',
};
config.setTeamServer(teamConfig);
expect('getTeamServer' in config).toBe(false);
config.setDefaultModel('gpt-4o');
config.save();
const config2 = new WaggleConfig(configDir);
const loaded = config2.getTeamServer();
expect(loaded).toEqual(teamConfig);
expect(config2.isTeamConnected()).toBe(true);
});
it('clears team server config', () => {
const configDir = makeTempDir();
const config = new WaggleConfig(configDir);
config.setTeamServer({ url: 'https://team.waggle.dev' });
config.clearTeamServer();
config.save();
const config2 = new WaggleConfig(configDir);
expect(config2.getTeamServer()).toBeNull();
expect(config2.isTeamConnected()).toBe(false);
});
it('persists team server through save/load cycle', () => {
const configDir = makeTempDir();
const config = new WaggleConfig(configDir);
config.setTeamServer({ url: 'https://example.com', userId: 'u1' });
config.save();
const config2 = new WaggleConfig(configDir);
expect(config2.getTeamServer()!.url).toBe('https://example.com');
expect(config2.getTeamServer()!.userId).toBe('u1');
const raw = JSON.parse(fs.readFileSync(path.join(configDir, 'config.json'), 'utf-8'));
expect(raw.defaultModel).toBe('gpt-4o');
expect(raw.teamServer).toEqual(teamServer);
});
});