feat: Add torch MCP tools for multi-browser control

- Add torchHandlers.ts with 5 tools:
  - list_torch_clients: list connected browsers with metadata
  - get_torch_status: show current torch holder
  - transfer_torch: transfer control to another browser
  - request_torch: request MCP control
  - release_torch: release MCP control
- Add 'transfer' message type to server torch-handler
- Add torch category to all pages
- Export helper functions from torch.ts
This commit is contained in:
2026-02-14 17:52:16 -06:00
parent 210e15d8d1
commit 1a51b34228
6 changed files with 252 additions and 16 deletions

View File

@@ -144,6 +144,40 @@ export async function releaseTorch(): Promise<boolean> {
return true
}
/**
* Transfer the torch to a specific client
*/
export async function transferTorch(targetId: string): Promise<boolean> {
if (!torchWs || torchWs.readyState !== WebSocket.OPEN) {
console.error('[Torch] Not connected to server')
return false
}
torchWs.send(JSON.stringify({ type: 'transfer', targetId }))
return true
}
/**
* Get list of connected clients
*/
export function getTorchClients() {
const torchStore = useTorchStore()
return torchStore.clients
}
/**
* Get current torch status
*/
export function getTorchStatus() {
const torchStore = useTorchStore()
return {
clientId: torchStore.clientId,
hasTorch: torchStore.hasTorch,
torchHolderId: torchStore.torchHolderId,
clientCount: torchStore.clients.length
}
}
/**
* Connect to MCP (when we have the torch)
*/