| 97 | return data.id as string; |
| 98 | } |
| 99 | async function retoolSendMessage( |
| 100 | acc: RetoolAccount, |
| 101 | agentId: string, |
| 102 | threadId: string, |
| 103 | text: string, |
| 104 | ) { |
| 105 | const url = |
| 106 | `https://${acc.domain_name}/api/agents/${agentId}/threads/${threadId}/messages`; |
| 107 | const r = await fetch(url, { |
| 108 | method: "POST", |
| 109 | headers: { |
| 110 | "x-xsrf-token": acc.x_xsrf_token, |
| 111 | "Cookie": `accessToken=${acc.accessToken}`, |
| 112 | "Content-Type": "application/json", |
| 113 | }, |
| 114 | body: JSON.stringify({ type: "text", text, timezone: "Asia/Shanghai" }), |
| 115 | }); |
| 116 | if (!r.ok) throw new Error(`send ${r.status}`); |
| 117 | const data = await r.json(); |
| 118 | return data.content.runId as string; |
| 119 | } |
| 120 | async function retoolGetMessage( |
| 121 | acc: RetoolAccount, |
| 122 | agentId: string, |