(r: RunningServer)
| 92 | } |
| 93 | |
| 94 | async function createSession(r: RunningServer): Promise<string> { |
| 95 | const cwd = join(tmpDir, 'workspace'); |
| 96 | mkdirSync(cwd, { recursive: true }); |
| 97 | const res = await appOf(r).inject({ |
| 98 | method: 'POST', |
| 99 | url: '/api/v1/sessions', |
| 100 | payload: { metadata: { cwd } }, |
| 101 | }); |
| 102 | const env = envelopeOf<{ id: string }>(res.json()); |
| 103 | if (env.code !== 0 || env.data === null) { |
| 104 | throw new Error(`create session failed: ${JSON.stringify(env)}`); |
| 105 | } |
| 106 | return env.data.id; |
| 107 | } |
| 108 | |
| 109 | async function createTerminal(r: RunningServer, sid: string): Promise<Terminal> { |
| 110 | const env = envelopeOf<Terminal>( |
no test coverage detected