Add live PTY dashboard terminal

This commit is contained in:
Mark McKeen
2026-04-08 15:13:13 -06:00
parent 523cd02430
commit d8232f1ad9
5 changed files with 6726 additions and 189 deletions
+39
View File
@@ -0,0 +1,39 @@
import { NextResponse } from 'next/server'
const TERMINAL_SERVER_URL = process.env.TERMINAL_SERVER_URL || 'http://127.0.0.1:3011'
export async function POST(request: Request) {
try {
const body = await request.json()
const response = await fetch(`${TERMINAL_SERVER_URL}/session`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
sandboxId: body?.sandboxId,
sessionId: body?.sessionId,
}),
cache: 'no-store',
})
const result = await response.json()
if (!response.ok) {
return NextResponse.json({ ok: false, error: result.error || 'Failed to initialize live terminal session.' }, { status: 502 })
}
const wsBase = TERMINAL_SERVER_URL.replace(/^http/, 'ws')
return NextResponse.json({
ok: true,
sessionId: result.sessionId,
sandboxId: result.sandboxId,
replay: result.replay,
websocketUrl: `${wsBase}/ws?sessionId=${encodeURIComponent(result.sessionId)}&sandboxId=${encodeURIComponent(result.sandboxId)}`,
})
} catch (error) {
return NextResponse.json({
ok: false,
error: error instanceof Error ? error.message : 'Failed to reach terminal server.',
}, { status: 500 })
}
}