Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

feat: add DELETE /api/machines/:machineId endpoint to hook server and CLI proxy

0xken15b8a6a3c087b0
diff --git a/cli/src/cli.ts b/cli/src/cli.ts
index 8c751f11e..1937ce119 100644
--- a/cli/src/cli.ts
+++ b/cli/src/cli.ts
@@ -2361,6 +2361,7 @@ async function runForeground(session: AuthSession): Promise<void> {
onStop: () => { setTimeout(() => process.kill(process.pid, 'SIGTERM'), 50) }, // let the 200 flush first
onMachinesList: () => proxyBackend('GET', '/api/machines'),
onMachineRename: (machineId, name) => proxyBackend('PATCH', `/api/machines/${encodeURIComponent(machineId)}`, { name }),
+ onMachineDelete: (machineId) => proxyBackend('DELETE', `/api/machines/${encodeURIComponent(machineId)}`),
onAuthMe: () => proxyBackend('GET', '/api/auth/me'),
})
// Same on-disk identity `harness link create`/`import` use (E2eeStore.init() is idempotent per file,
diff --git a/cli/src/hookServer.ts b/cli/src/hookServer.ts
index 91fe988b9..011bbc695 100644
--- a/cli/src/hookServer.ts
+++ b/cli/src/hookServer.ts
@@ -94,6 +94,8 @@ export interface HookServerHandlers {
onMachinesList?: () => Promise<PairOutcome>
/** PATCH /api/machines/:machineId — proxy a rename to backend the same way. */
onMachineRename?: (machineId: string, name: string) => Promise<PairOutcome>
+ /** DELETE /api/machines/:machineId — proxy a delete to backend the same way. */
+ onMachineDelete?: (machineId: string) => Promise<PairOutcome>
/** GET /api/auth/me — proxy the signed-in user's profile from backend. */
onAuthMe?: () => Promise<PairOutcome>
}
@@ -516,10 +518,10 @@ export function startHookServer(
const out = handlers.onSetupLink(); json(out.status, out.body); return
}
- // Local GUI clients (e.g. the desktop app): read the full machine list / rename one / read the
- // signed-in profile through this daemon's own SSO session, so the local caller never holds a
- // bearer token itself — loopback trust does the authenticating. Reads are ungated (same tier as
- // /api/status); the rename mutation is CSRF-guarded like every other local write.
+ // Local GUI clients (e.g. the desktop app): read the full machine list / rename or delete one /
+ // read the signed-in profile through this daemon's own SSO session, so the local caller never
+ // holds a bearer token itself — loopback trust does the authenticating. Reads are ungated (same
+ // tier as /api/status); the rename/delete mutations are CSRF-guarded like every other local write.
if (req.method === 'GET' && url === '/api/machines') {
if (!handlers.onMachinesList) { json(503, { error: 'UNAVAILABLE' }); return }
const out = await handlers.onMachinesList(); json(out.status, out.body); return
@@ -538,6 +540,13 @@ export function startHookServer(
if (!body.name) { json(400, { error: 'MISSING_NAME' }); return }
const out = await handlers.onMachineRename(machineId, body.name); json(out.status, out.body); return
}
+ if (req.method === 'DELETE' && url.startsWith('/api/machines/')) {
+ if (!localOk) { json(403, { error: 'FORBIDDEN' }); return }
+ if (!handlers.onMachineDelete) { json(503, { error: 'UNAVAILABLE' }); return }
+ const machineId = decodeURIComponent(url.slice('/api/machines/'.length))
+ if (!machineId) { json(400, { error: 'MISSING_MACHINE_ID' }); return }
+ const out = await handlers.onMachineDelete(machineId); json(out.status, out.body); return
+ }
// `harness pairings` — list paired browsers.
if (req.method === 'GET' && url === '/api/pairs') {