H.1: Product registration - Added 12 clawcowork feature flags to platform-service flags/seed.ts (sandbox, plugins, mcp, scheduling, computer_use, parallel_agents, marketplace, wasm, llm_multi_model, audit, platform_auth, dispatch_api) H.2: cowork-service scaffold (services/cowork-service/) - @lysnrai/cowork-service on port 4009, productId clawcowork - createServiceApp + startService from @bytelyst/fastify-core - Modules: health (dependency check), tasks (submit/list/get/cancel) - Zod-validated config, Swagger, readiness endpoint - 8 tests passing (1 bootstrap + 7 task routes), typecheck clean
53 lines
1.6 KiB
TypeScript
53 lines
1.6 KiB
TypeScript
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
|
|
|
const createServiceAppMock = vi.fn();
|
|
const startServiceMock = vi.fn(async () => undefined);
|
|
|
|
const appMock = {
|
|
register: vi.fn(async () => undefined),
|
|
inject: vi.fn(),
|
|
};
|
|
|
|
vi.mock('@bytelyst/fastify-core', () => ({
|
|
createServiceApp: createServiceAppMock,
|
|
startService: startServiceMock,
|
|
}));
|
|
|
|
vi.mock('./modules/health/routes.js', () => ({ healthRoutes: vi.fn() }));
|
|
vi.mock('./modules/tasks/routes.js', () => ({ taskRoutes: vi.fn() }));
|
|
vi.mock('./lib/config.js', () => ({
|
|
config: {
|
|
PORT: 4009,
|
|
HOST: '0.0.0.0',
|
|
CORS_ORIGIN: undefined,
|
|
SERVICE_NAME: 'cowork-service',
|
|
PRODUCT_ID: 'clawcowork',
|
|
PLATFORM_SERVICE_URL: 'http://localhost:4003',
|
|
RUST_RUNTIME_BIN: 'cowork-orchestrator',
|
|
RUST_RUNTIME_TIMEOUT_MS: 300_000,
|
|
},
|
|
}));
|
|
|
|
describe('cowork-service bootstrap', () => {
|
|
beforeEach(() => {
|
|
vi.resetModules();
|
|
vi.clearAllMocks();
|
|
createServiceAppMock.mockResolvedValue(appMock);
|
|
appMock.register.mockReset();
|
|
appMock.register.mockResolvedValue(undefined);
|
|
});
|
|
|
|
it('creates app, registers routes, and starts on port 4009', async () => {
|
|
await import('./server.js');
|
|
|
|
expect(createServiceAppMock).toHaveBeenCalledOnce();
|
|
const opts = createServiceAppMock.mock.calls[0][0];
|
|
expect(opts.name).toBe('cowork-service');
|
|
expect(opts.version).toBe('0.1.0');
|
|
expect(opts.readiness).toBe(true);
|
|
|
|
expect(appMock.register).toHaveBeenCalledTimes(2);
|
|
expect(startServiceMock).toHaveBeenCalledWith(appMock, { port: 4009, host: '0.0.0.0' });
|
|
});
|
|
});
|