| 221 | } |
| 222 | |
| 223 | export async function openSessionEventStream( |
| 224 | sessionId: string, |
| 225 | key: string, |
| 226 | options: RequestOptions = {}, |
| 227 | ): Promise<ReadableStream<Uint8Array>> { |
| 228 | const response = await fetch(`${API_BASE}/sessions/${encodeURIComponent(sessionId)}/events`, { |
| 229 | headers: { authorization: `Bearer ${key}` }, |
| 230 | signal: options.signal, |
| 231 | }); |
| 232 | if (!response.ok || !response.body) { |
| 233 | throw new Error(`event stream failed: HTTP ${response.status}`); |
| 234 | } |
| 235 | return response.body; |
| 236 | } |
| 237 | |
| 238 | export function getShare(token: string) { |
| 239 | return fetch(`${API_BASE}/share/${encodeURIComponent(token)}`).then(async (response) => { |