test: remove the Windows external-agent lane

The lane drove real Claude Code, Codex, Hermes and OpenClaw installs
through Waggle Room runs, the coding-agent hooks and the hive-mind CLI,
none of which is in the community edition.

- scripts/test-windows-external-agents.ps1 and
  scripts/test-windows-official-auth-canaries.ps1 (the runners and their
  receipt sealing), scripts/verify-codex-tool-denial.mjs
- tests/e2e/launcher-real-hook-lifecycle.spec.ts and
  tests/e2e/launcher-real-tool-lifecycle.spec.ts (Windows-only, skipped
  unless the runner set them up)
- tests/integration/external-agent-collaboration.live.test.ts
- the tauri-config tests that pinned those scripts
This commit is contained in:
shumeiko.it
2026-11-01 11:13:35 +01:00
parent 25f95c584b
commit 6d187c8da7
7 changed files with 0 additions and 8672 deletions

View File

@@ -1,221 +0,0 @@
import { expect, test } from '@playwright/test';
import fs from 'node:fs';
import path from 'node:path';
type HookEnvelope = {
ok: boolean;
action: 'install' | 'verify' | 'uninstall';
packageName: string;
stdout: string;
stderr: string;
code: number;
error?: string;
};
type HookToolCase = {
id: 'claude-code' | 'claude-desktop' | 'codex' | 'codex-desktop' | 'cursor' | 'hermes' | 'openclaw';
packageName: string;
configPath: string;
pointerPath: string;
cleanupDirs: string[];
precreateConfig?: string;
managedHookDir?: string;
};
const HOOK_TOOL_CASES: HookToolCase[] = [
{
id: 'claude-code',
packageName: '@waggle/hive-mind-hooks-claude-code',
configPath: path.join('.claude', 'settings.json'),
pointerPath: path.join('.claude', 'hive-mind-install.json'),
cleanupDirs: ['.claude'],
precreateConfig: '{}\n',
},
{
id: 'claude-desktop',
packageName: '@waggle/hive-mind-hooks-claude-desktop',
configPath: path.join('AppData', 'Roaming', 'Claude', 'claude_desktop_config.json'),
pointerPath: path.join('.waggle', 'claude-desktop', 'hive-mind-install.json'),
cleanupDirs: [path.join('AppData', 'Roaming', 'Claude'), path.join('.waggle', 'claude-desktop')],
precreateConfig: '{}\n',
},
{
id: 'codex',
packageName: '@waggle/hive-mind-hooks-codex',
configPath: path.join('.codex', 'hooks.json'),
pointerPath: path.join('.codex', 'hive-mind-install.json'),
cleanupDirs: ['.codex'],
},
{
id: 'codex-desktop',
packageName: '@waggle/hive-mind-hooks-codex-desktop',
configPath: path.join('.codex', 'hooks.json'),
pointerPath: path.join('.codex', 'hive-mind-install.json'),
cleanupDirs: ['.codex'],
},
{
id: 'cursor',
packageName: '@waggle/hive-mind-hooks-cursor',
configPath: path.join('.cursor', 'hooks.json'),
pointerPath: path.join('.cursor', 'hive-mind-install.json'),
cleanupDirs: ['.cursor'],
},
{
id: 'hermes',
packageName: '@waggle/hive-mind-hooks-hermes',
configPath: path.join('.hermes', 'config.yaml'),
pointerPath: path.join('.hermes', 'hive-mind-install.json'),
cleanupDirs: ['.hermes'],
},
{
id: 'openclaw',
packageName: '@waggle/hive-mind-hooks-openclaw',
configPath: path.join('.openclaw', 'openclaw.json'),
pointerPath: path.join('.openclaw', 'hive-mind-install.json'),
cleanupDirs: ['.openclaw'],
managedHookDir: path.join('.openclaw', 'hooks', 'hive-mind'),
},
];
function selectRequestedHookTools(tools: readonly HookToolCase[]): HookToolCase[] {
const raw = process.env.WAGGLE_E2E_HOST_IDS;
if (raw === undefined) return [...tools];
const rawIds = raw.split(',');
if (rawIds.some(id => id.trim().length === 0)) {
throw new Error('Invalid WAGGLE_E2E_HOST_IDS: empty host ID.');
}
const requestedIds = rawIds.map(id => id.trim());
const duplicateIds = requestedIds.filter(
(id, index) => requestedIds.indexOf(id) !== index,
);
if (duplicateIds.length > 0) {
throw new Error(`Duplicate WAGGLE_E2E_HOST_IDS: ${[...new Set(duplicateIds)].join(', ')}`);
}
const availableIds = new Set(tools.map(tool => tool.id));
const unknownIds = requestedIds.filter(
id => !availableIds.has(id as HookToolCase['id']),
);
if (unknownIds.length > 0) {
throw new Error(`Unknown WAGGLE_E2E_HOST_IDS: ${unknownIds.join(', ')}`);
}
const requested = new Set(requestedIds);
return tools.filter(tool => requested.has(tool.id));
}
function normalized(value: string): string {
return path.resolve(value).toLowerCase();
}
function inside(root: string, relativePath: string): string {
const candidate = path.resolve(root, relativePath);
const relative = path.relative(path.resolve(root), candidate);
if (!relative || relative.startsWith('..') || path.isAbsolute(relative)) {
throw new Error(`Refusing path outside isolated hook profile: ${candidate}`);
}
return candidate;
}
function safeRemove(root: string, relativePath: string): void {
fs.rmSync(inside(root, relativePath), { recursive: true, force: true });
}
function assertIsolatedWindowsProfile(hookHome: string): void {
const guardedRoot = process.env.WAGGLE_E2E_TEMP_ROOT;
expect(guardedRoot, 'guarded runner must issue WAGGLE_E2E_TEMP_ROOT').toBeTruthy();
const relativeToRoot = path.relative(path.resolve(guardedRoot!), path.resolve(hookHome));
expect(relativeToRoot, 'hook profile must be a child of the guarded temp root').not.toMatch(/^\.\.|^[\\/]/);
expect(relativeToRoot, 'hook profile must not be the guarded temp root itself').not.toBe('');
expect(normalized(process.env.USERPROFILE ?? ''), 'isolated USERPROFILE').toBe(normalized(hookHome));
expect(normalized(process.env.HOME ?? ''), 'isolated HOME').toBe(normalized(hookHome));
expect(normalized(process.env.APPDATA ?? ''), 'isolated APPDATA').toBe(
normalized(path.join(hookHome, 'AppData', 'Roaming')),
);
expect(normalized(process.env.LOCALAPPDATA ?? ''), 'isolated LOCALAPPDATA').toBe(
normalized(path.join(hookHome, 'AppData', 'Local')),
);
}
test.describe('Launcher real Windows hook lifecycle', () => {
test('runs requested packaged hook routes with server-owned CLI wiring and reversible temp-profile cleanup', async ({ request }, testInfo) => {
test.setTimeout(240_000);
test.skip(process.platform !== 'win32', 'This real-host safety lane is Windows-specific.');
test.skip(
process.env.WAGGLE_E2E_REAL_HOOKS !== '1' || !process.env.WAGGLE_E2E_HOOK_HOME,
'Use scripts/test-windows-external-agents.ps1 to provide a throwaway Windows profile.',
);
const hookToolCases = selectRequestedHookTools(HOOK_TOOL_CASES);
const hookHome = path.resolve(process.env.WAGGLE_E2E_HOOK_HOME!);
assertIsolatedWindowsProfile(hookHome);
fs.mkdirSync(hookHome, { recursive: true });
const completed: Array<{ id: HookToolCase['id']; actions: string[]; packagedCli: string }> = [];
const postHook = async (tool: HookToolCase, action: HookEnvelope['action']) => {
const response = await request.post('/api/tools/hooks', {
data: { id: tool.id, action },
});
expect(response.status(), await response.text()).toBe(200);
const body = await response.json() as HookEnvelope;
expect(body, body.error ?? body.stderr).toMatchObject({
ok: true,
action,
packageName: tool.packageName,
code: 0,
});
return body;
};
try {
for (const tool of hookToolCases) {
const configPath = inside(hookHome, tool.configPath);
const pointerPath = inside(hookHome, tool.pointerPath);
const managedHookDir = tool.managedHookDir ? inside(hookHome, tool.managedHookDir) : null;
await test.step(`${tool.id} hook install -> verify -> uninstall`, async () => {
for (const cleanupDir of tool.cleanupDirs) safeRemove(hookHome, cleanupDir);
if (tool.precreateConfig !== undefined) {
fs.mkdirSync(path.dirname(configPath), { recursive: true });
fs.writeFileSync(configPath, tool.precreateConfig, 'utf8');
}
const install = await postHook(tool, 'install');
expect(install.stdout).toContain('install');
expect(fs.existsSync(configPath)).toBe(true);
expect(fs.existsSync(pointerPath)).toBe(true);
if (managedHookDir) expect(fs.existsSync(managedHookDir)).toBe(true);
const pointer = JSON.parse(fs.readFileSync(pointerPath, 'utf8')) as { cli_path?: unknown };
expect(pointer.cli_path, 'route pins the packaged hive-mind CLI').toEqual(expect.any(String));
const packagedCli = path.resolve(String(pointer.cli_path));
expect(fs.existsSync(packagedCli), `packaged CLI exists: ${packagedCli}`).toBe(true);
expect(packagedCli.replace(/\\/g, '/')).toMatch(/hive-mind-cli\/dist\/index\.js$/);
const verify = await postHook(tool, 'verify');
expect(verify.stdout).toContain('All checks passed.');
const uninstall = await postHook(tool, 'uninstall');
expect(uninstall.stdout).toContain('uninstall');
expect(fs.existsSync(pointerPath)).toBe(false);
if (tool.precreateConfig !== undefined) {
expect(fs.readFileSync(configPath, 'utf8')).toBe(tool.precreateConfig);
} else {
expect(fs.existsSync(configPath)).toBe(false);
}
if (managedHookDir) expect(fs.existsSync(managedHookDir)).toBe(false);
completed.push({ id: tool.id, actions: ['install', 'verify', 'uninstall'], packagedCli });
});
}
await testInfo.attach('windows-hook-route-summary', {
body: Buffer.from(JSON.stringify({ hookHome, completed }, null, 2)),
contentType: 'application/json',
});
expect(completed.map(item => item.id)).toEqual(hookToolCases.map(tool => tool.id));
} finally {
for (const tool of hookToolCases) {
for (const cleanupDir of tool.cleanupDirs) safeRemove(hookHome, cleanupDir);
}
}
});
});

View File

@@ -1,357 +0,0 @@
import { expect, test, type APIRequestContext } from '@playwright/test';
import { SUPPORTED_TOOLS } from '@waggle/shared';
import { randomUUID } from 'node:crypto';
import path from 'node:path';
const SKIP_PARAMS = 'skipOnboarding=true&skipBoot=true&skipBriefing=true&tier=power';
type ToolId = typeof SUPPORTED_TOOLS[number];
const SAFE_VERSION_ARGS: Partial<Record<ToolId, string[]>> = {
'claude-code': ['--version'],
codex: ['--version'],
hermes: ['--version'],
openclaw: ['--version'],
};
const SECRET_ENV_NAMES = [
'ANTHROPIC_API_KEY',
'ANTHROPIC_AUTH_TOKEN',
'CLAUDE_CODE_OAUTH_TOKEN',
'OPENAI_API_KEY',
'OPENAI_ACCESS_TOKEN',
'OPENROUTER_API_KEY',
'GOOGLE_API_KEY',
'GEMINI_API_KEY',
'GROQ_API_KEY',
'XAI_API_KEY',
'MISTRAL_API_KEY',
'COHERE_API_KEY',
'DEEPSEEK_API_KEY',
'AZURE_OPENAI_API_KEY',
'AWS_ACCESS_KEY_ID',
'AWS_SECRET_ACCESS_KEY',
'AWS_SESSION_TOKEN',
'AWS_PROFILE',
'AWS_CONFIG_FILE',
'AWS_SHARED_CREDENTIALS_FILE',
'GOOGLE_APPLICATION_CREDENTIALS',
'CLOUDSDK_CONFIG',
'AZURE_CONFIG_DIR',
'KUBECONFIG',
'DOCKER_CONFIG',
'DOCKER_HOST',
'GITHUB_TOKEN',
'GH_TOKEN',
'STRIPE_SECRET_KEY',
'DATABASE_URL',
'NPM_TOKEN',
'HF_TOKEN',
'HUGGING_FACE_HUB_TOKEN',
'RENDER_API_KEY',
'SSH_AUTH_SOCK',
'GIT_ASKPASS',
'SSH_ASKPASS',
'GIT_SSH_COMMAND',
'HTTP_PROXY',
'HTTPS_PROXY',
'ALL_PROXY',
'NODE_OPTIONS',
] as const;
function selectRequestedToolIds(tools: readonly ToolId[]): ToolId[] {
const raw = process.env.WAGGLE_E2E_HOST_IDS;
if (raw === undefined) return [...tools];
const rawIds = raw.split(',');
if (rawIds.some(id => id.trim().length === 0)) {
throw new Error('Invalid WAGGLE_E2E_HOST_IDS: empty host ID.');
}
const requestedIds = rawIds.map(id => id.trim());
const duplicateIds = requestedIds.filter(
(id, index) => requestedIds.indexOf(id) !== index,
);
if (duplicateIds.length > 0) {
throw new Error(`Duplicate WAGGLE_E2E_HOST_IDS: ${[...new Set(duplicateIds)].join(', ')}`);
}
const unknownIds = requestedIds.filter(id => !tools.includes(id as ToolId));
if (unknownIds.length > 0) {
throw new Error(`Unknown WAGGLE_E2E_HOST_IDS: ${unknownIds.join(', ')}`);
}
const requested = new Set(requestedIds);
return tools.filter(tool => requested.has(tool));
}
type DetectedTool = {
id: string;
displayName: string;
installed: boolean;
installedPath: string | null;
launchable?: boolean;
builtin?: boolean;
capabilities?: {
interactiveLaunch: boolean;
headlessTask: boolean;
};
};
type DetectionEnvelope = {
platform: string;
tools: DetectedTool[];
};
type LaunchEnvelope = {
ok: boolean;
pid: number | null;
roomId?: string;
runId?: string;
error?: string;
};
type WorkspaceEnvelope = {
id?: string;
name?: string;
storageType?: string;
};
type RouteResult = {
id: string;
displayName: string;
status: 'unavailable' | 'safe-version-exit' | 'interactive-only-rejected';
installedPath: string | null;
exitCode?: number | null;
output?: string;
route?: string;
};
function routeWithSkip(route: string): string {
const sep = route.includes('?') ? '&' : '?';
return `${route}${sep}${SKIP_PARAMS}`;
}
function assertTemporaryDataDir(): void {
const dataDir = process.env.WAGGLE_E2E_DATA_DIR;
const guardedRoot = process.env.WAGGLE_E2E_TEMP_ROOT;
expect(dataDir, 'WAGGLE_E2E_DATA_DIR must be explicitly isolated').toBeTruthy();
expect(guardedRoot, 'guarded runner must issue WAGGLE_E2E_TEMP_ROOT').toBeTruthy();
const relative = path.relative(path.resolve(guardedRoot!), path.resolve(dataDir!));
expect(relative, 'E2E data dir must be a child of the guarded temp root').not.toMatch(/^\.\.|^[\\/]/);
expect(relative, 'E2E data dir must not be the guarded temp root itself').not.toBe('');
}
async function createManagedWorkspace(request: APIRequestContext): Promise<WorkspaceEnvelope & { id: string }> {
const createResponse = await request.post('/api/workspaces', {
data: {
name: `Windows external-agent route ${randomUUID().slice(0, 8)}`,
group: 'external-agent-e2e',
icon: 'Terminal',
tone: 'technical',
storageType: 'virtual',
},
});
expect(createResponse.status(), await createResponse.text()).toBe(201);
const created = await createResponse.json() as WorkspaceEnvelope;
expect(created.id, 'managed workspace id from POST /api/workspaces').toMatch(/\S/);
const persistedResponse = await request.get(`/api/workspaces/${encodeURIComponent(created.id!)}`);
expect(persistedResponse.status(), await persistedResponse.text()).toBe(200);
const persisted = await persistedResponse.json() as WorkspaceEnvelope;
expect(persisted).toMatchObject({ id: created.id, name: created.name });
return { ...created, id: created.id! };
}
async function readObservedStream(
baseURL: string,
pid: number,
): Promise<{ lines: string[]; exitCode: number | null | undefined }> {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 30_000);
const lines: string[] = [];
let exitCode: number | null | undefined;
try {
const response = await fetch(new URL(`/api/tools/stream?pid=${pid}`, baseURL), {
signal: controller.signal,
});
expect(response.ok).toBe(true);
expect(response.body).toBeTruthy();
const reader = response.body!.getReader();
const decoder = new TextDecoder();
let buffer = '';
while (exitCode === undefined) {
const chunk = await reader.read();
if (chunk.done) break;
buffer += decoder.decode(chunk.value, { stream: true }).replace(/\r\n/g, '\n');
let eventEnd = buffer.indexOf('\n\n');
while (eventEnd >= 0) {
const rawEvent = buffer.slice(0, eventEnd);
buffer = buffer.slice(eventEnd + 2);
eventEnd = buffer.indexOf('\n\n');
let event = 'message';
let data = '';
for (const line of rawEvent.split('\n')) {
if (line.startsWith('event:')) event = line.slice('event:'.length).trim();
if (line.startsWith('data:')) data += line.slice('data:'.length).trim();
}
if (event === 'line') lines.push((JSON.parse(data) as { line: string }).line);
if (event === 'exit') {
exitCode = (JSON.parse(data) as { code: number | null }).code;
break;
}
}
}
} finally {
clearTimeout(timeout);
}
return { lines, exitCode };
}
async function waitForProcessClear(request: APIRequestContext, pid: number): Promise<void> {
await expect.poll(async () => {
const processesResponse = await request.get('/api/tools/processes');
expect(processesResponse.ok()).toBe(true);
const body = await processesResponse.json() as { processes: Array<{ pid: number }> };
return body.processes.some(process => process.pid === pid);
}, { timeout: 10_000 }).toBe(false);
}
test.describe('Launcher real Windows supported-route lifecycle', () => {
test('covers requested built-in tools without credentials, unsafe GUI launch, or fabricated workspace ids', async ({ baseURL, page, request }, testInfo) => {
test.setTimeout(240_000);
test.skip(process.platform !== 'win32', 'This real-host route lane is Windows-specific.');
test.skip(
process.env.WAGGLE_E2E_REAL_TOOLS !== '1',
'Use scripts/test-windows-external-agents.ps1 to run the guarded real-tool lane.',
);
assertTemporaryDataDir();
expect(
process.env.WAGGLE_E2E_REUSE_EXISTING_SERVER,
'guarded runner must forbid reuse of a pre-existing app server',
).toBe('0');
expect(
SECRET_ENV_NAMES.filter(name => Boolean(process.env[name])),
'provider and cloud credentials must be scrubbed by the guarded runner',
).toEqual([]);
const toolIds = selectRequestedToolIds(SUPPORTED_TOOLS);
const root = baseURL ?? process.env.WAGGLE_E2E_BASE_URL ?? 'http://127.0.0.1:3333';
const detectionResponse = await request.get('/api/tools/detect');
expect(detectionResponse.ok()).toBe(true);
const detection = await detectionResponse.json() as DetectionEnvelope;
expect(detection.platform).toBe('win32');
expect(
detection.tools.filter(tool => tool.builtin === true).map(tool => tool.id),
).toEqual(SUPPORTED_TOOLS);
await page.goto(routeWithSkip('/launcher?watch=1'), { waitUntil: 'domcontentloaded' });
await expect(page.getByText('Tool Launcher', { exact: true })).toBeVisible({ timeout: 15_000 });
for (const tool of detection.tools) {
await expect(page.getByText(tool.displayName, { exact: true }).first()).toBeVisible({ timeout: 10_000 });
}
const workspace = await createManagedWorkspace(request);
const activePids = new Set<number>();
const results: RouteResult[] = [];
try {
for (const toolId of toolIds) {
const tool = detection.tools.find(candidate => candidate.id === toolId)!;
if (!tool.installed || !tool.installedPath) {
results.push({
id: tool.id,
displayName: tool.displayName,
status: 'unavailable',
installedPath: null,
});
testInfo.annotations.push({ type: 'tool-unavailable', description: tool.displayName });
continue;
}
await test.step(`${tool.displayName} supported route`, async () => {
if (tool.capabilities?.headlessTask !== true) {
const unsupported = await request.post('/api/tools/run', {
data: {
toolId: tool.id,
workspaceIds: [workspace.id],
prompt: 'Do not run. This request must be rejected as interactive-only.',
timeoutMs: 10_000,
},
});
expect(unsupported.status(), await unsupported.text()).toBe(409);
expect(await unsupported.json()).toMatchObject({
error: 'TOOL_NOT_HEADLESS',
toolId: tool.id,
});
results.push({
id: tool.id,
displayName: tool.displayName,
status: 'interactive-only-rejected',
installedPath: tool.installedPath,
route: '/api/tools/run',
});
return;
}
const args = SAFE_VERSION_ARGS[tool.id as ToolId];
expect(args, `${tool.displayName} must have an audited no-network version command`).toBeTruthy();
const launchResponse = await request.post('/api/tools/launch', {
data: {
id: tool.id,
args,
workspaceId: workspace.id,
observe: true,
},
});
expect(launchResponse.status(), await launchResponse.text()).toBe(202);
const launch = await launchResponse.json() as LaunchEnvelope;
expect(launch, launch.error).toMatchObject({ ok: true });
expect(launch.pid).toEqual(expect.any(Number));
expect(launch.roomId).toMatch(/\S/);
expect(launch.runId).toMatch(/\S/);
activePids.add(launch.pid!);
const stream = await readObservedStream(root, launch.pid!);
expect(stream.exitCode).toBe(0);
expect(stream.lines.join('\n').trim().length).toBeGreaterThan(0);
await waitForProcessClear(request, launch.pid!);
activePids.delete(launch.pid!);
results.push({
id: tool.id,
displayName: tool.displayName,
status: 'safe-version-exit',
installedPath: tool.installedPath,
exitCode: stream.exitCode,
output: stream.lines.join('\n').trim(),
route: '/api/tools/launch',
});
});
}
expect(results.map(result => result.id)).toEqual(toolIds);
if (process.env.WAGGLE_E2E_HOST_IDS) {
expect(
results.filter(result => result.status === 'unavailable').map(result => result.id),
'every explicitly requested host must be installed and healthy',
).toEqual([]);
} else {
expect(results.some(result => result.status !== 'unavailable'), 'at least one real installed tool route').toBe(true);
}
} finally {
try {
await testInfo.attach('windows-external-tool-route-summary', {
body: Buffer.from(JSON.stringify({ workspace, results }, null, 2)),
contentType: 'application/json',
});
} finally {
for (const pid of activePids) {
await request.post('/api/tools/kill', { data: { pid } }).catch(() => null);
}
const deleteResponse = await request.delete(`/api/workspaces/${encodeURIComponent(workspace.id)}`).catch(() => null);
if (deleteResponse) expect([204, 404]).toContain(deleteResponse.status());
}
}
});
});