(acc: RetoolAccount)
| 68 | * Retool API helpers |
| 69 | * ------------------------------------------------------------------------------------------------ */ |
| 70 | async function retoolQueryAgents(acc: RetoolAccount) { |
| 71 | const url = `https://${acc.domain_name}/api/agents`; |
| 72 | const r = await fetch(url, { |
| 73 | headers: { |
| 74 | "x-xsrf-token": acc.x_xsrf_token, |
| 75 | "Cookie": `accessToken=${acc.accessToken}`, |
| 76 | "User-Agent": "Rever-Worker/1.0", |
| 77 | Accept: "application/json", |
| 78 | }, |
| 79 | }); |
| 80 | if (!r.ok) throw new Error(`agent query ${r.status}`); |
| 81 | const data = await r.json(); |
| 82 | return data.agents as any[]; |
| 83 | } |
| 84 | async function retoolGetThreadId(acc: RetoolAccount, agentId: string) { |
| 85 | const url = `https://${acc.domain_name}/api/agents/${agentId}/threads`; |
| 86 | const r = await fetch(url, { |
no test coverage detected