(action: string, payload: Record<string, any>)
| 488 | } |
| 489 | |
| 490 | async function agentRequest(action: string, payload: Record<string, any>): Promise<any> { |
| 491 | const socket = await ensureAgentSocket(); |
| 492 | const id = `a${++agentReqId}`; |
| 493 | |
| 494 | return await new Promise((resolve, reject) => { |
| 495 | agentPending.set(id, { resolve, reject }); |
| 496 | writeJsonLine(socket, { id, action, ...payload }); |
| 497 | setTimeout(() => { |
| 498 | if (!agentPending.has(id)) return; |
| 499 | agentPending.delete(id); |
| 500 | reject(new Error("Timed out waiting for agent-browser response")); |
| 501 | }, REQUEST_TIMEOUT_MS); |
| 502 | }); |
| 503 | } |
| 504 | |
| 505 | async function agentCommand(action: string, payload: Record<string, any>): Promise<any> { |
| 506 | return await agentRequest(action, payload); |
no test coverage detected