The micro-VM for AI agents — light enough to embed on your laptop, elastic enough to power an agentic cloud.
/** `POST /v1/apps/:app/envs/:env/open-ticket`: a one-time link into the env's origin (what `boxlite app status --open` uses). */
import { Hono } from 'hono'
import { z } from 'zod'
import type { Vars } from '../auth'
import type { Ctx } from '../ctx'
import { createOpenTicket } from '../proxy/gate'
import { requireAppScope } from '../platform-principal'
import { body, envOf } from './util'
/** `/v1/apps/:app/envs/:env/open-ticket` is used by `boxlite app status --open`. */
export function openTicketRoutes(ctx: Ctx) {
const r = new Hono<{ Variables: Vars }>()
r.post('/envs/:env/open-ticket', async (c) => {
const b = c.req.header('content-type')?.includes('json')
? await body(
c,
z.object({
next: z.string().max(2000).optional(),
as: z
.string()
.regex(/^[^\s@]+@[^\s@]+$/, 'must be an email address')
.max(254)
.optional(),
role: z.enum(['owner', 'user']).optional(),
}),
)
: {}
const as = b.as ? { email: b.as, role: b.role ?? ('user' as const) } : undefined
requireAppScope(as ? 'write:apps' : 'read:apps')
const env = await envOf(ctx, c)
return c.json(
await createOpenTicket(ctx, c.get('app'), env, b.next ?? c.req.query('next'), c.get('actor'), as),
201,
)
})
return r
}