(baseUrl: string)
| 57 | } |
| 58 | |
| 59 | async function postSession(baseUrl: string): Promise<string> { |
| 60 | const res = await fetch( |
| 61 | `${baseUrl}/api/v1/sessions`, |
| 62 | withAuth({ |
| 63 | method: 'POST', |
| 64 | headers: { 'content-type': 'application/json' }, |
| 65 | body: JSON.stringify({ metadata: { cwd: join(tmpDir, 'workspace') } }), |
| 66 | }), |
| 67 | ); |
| 68 | const env = (await res.json()) as { code: number; data: { id: string } | null }; |
| 69 | if (env.code !== 0 || env.data === null) throw new Error(`createSession failed: ${JSON.stringify(env)}`); |
| 70 | return env.data.id; |
| 71 | } |
| 72 | |
| 73 | async function fetchSnapshot(baseUrl: string, sid: string): Promise<{ |
| 74 | status: number; |
no test coverage detected