| 12 | await mkdir(".opencode", { recursive: true }); |
| 13 | |
| 14 | async function appendToLog(label: string, data?: unknown): Promise<void> { |
| 15 | const timestamp = new Date().toISOString(); |
| 16 | const line = data !== undefined |
| 17 | ? `[${timestamp}] ${label} | ${JSON.stringify(data)}\n` |
| 18 | : `[${timestamp}] ${label}\n`; |
| 19 | |
| 20 | const file = Bun.file(LOG_FILE); |
| 21 | const existing = (await file.exists()) ? await file.text() : ""; |
| 22 | await Bun.write(LOG_FILE, existing + line); |
| 23 | } |
| 24 | |
| 25 | const corsHeaders = { |
| 26 | "Access-Control-Allow-Origin": "*", |