( info: DaemonInfo, command: string, )
| 67 | } |
| 68 | |
| 69 | async function callCommandRpc( |
| 70 | info: DaemonInfo, |
| 71 | command: string, |
| 72 | ): Promise<{ status: number; body: any }> { |
| 73 | const response = await fetch(`http://127.0.0.1:${info.httpPort}/rpc`, { |
| 74 | method: 'POST', |
| 75 | headers: { 'content-type': 'application/json' }, |
| 76 | body: JSON.stringify({ |
| 77 | jsonrpc: '2.0', |
| 78 | id: `rpc-${Date.now()}`, |
| 79 | method: 'agent_device.command', |
| 80 | params: { |
| 81 | token: info.token, |
| 82 | session: 'default', |
| 83 | command, |
| 84 | positionals: [], |
| 85 | flags: {}, |
| 86 | }, |
| 87 | }), |
| 88 | }); |
| 89 | return { |
| 90 | status: response.status, |
| 91 | body: await response.json(), |
| 92 | }; |
| 93 | } |
| 94 | |
| 95 | async function stopDaemonForStateDir(stateDir: string): Promise<void> { |
| 96 | try { |
no outgoing calls
no test coverage detected