( acc: RetoolAccount, agentId: string, threadId: string, text: string, )
| 114 | return data.id as string; |
| 115 | } |
| 116 | async function retoolSendMessage( |
| 117 | acc: RetoolAccount, |
| 118 | agentId: string, |
| 119 | threadId: string, |
| 120 | text: string, |
| 121 | ) { |
| 122 | const url = |
| 123 | `https://${acc.domain_name}/api/agents/${agentId}/threads/${threadId}/messages`; |
| 124 | const resp = await fetch(url, { |
| 125 | method: "POST", |
| 126 | headers: { |
| 127 | "x-xsrf-token": acc.x_xsrf_token, |
| 128 | "Cookie": `accessToken=${acc.accessToken}`, |
| 129 | "Content-Type": "application/json", |
| 130 | }, |
| 131 | body: JSON.stringify({ type: "text", text, timezone: "Asia/Shanghai" }), |
| 132 | }); |
| 133 | if (!resp.ok) throw new Error(`send message failed ${resp.status}`); |
| 134 | const data = await resp.json(); |
| 135 | return data.content.runId as string; |
| 136 | } |
| 137 | async function retoolGetMessage( |
| 138 | acc: RetoolAccount, |
| 139 | agentId: string, |
no test coverage detected