From 03ef3f1383a7152dc169f638ac338feb2de05860 Mon Sep 17 00:00:00 2001 From: Kilo Agent Date: Tue, 12 May 2026 14:24:35 +0000 Subject: [PATCH] feat: serve tui.json schema at app.kilo.ai/tui.json --- apps/web/src/app/tui.json/route.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 apps/web/src/app/tui.json/route.ts diff --git a/apps/web/src/app/tui.json/route.ts b/apps/web/src/app/tui.json/route.ts new file mode 100644 index 000000000..db74ef18e --- /dev/null +++ b/apps/web/src/app/tui.json/route.ts @@ -0,0 +1,30 @@ +import { NextResponse } from 'next/server'; + +/** + * Serves the Kilo CLI TUI config JSON Schema at `app.kilo.ai/tui.json`. + * + * Proxies the upstream opencode schema. Cached at the CDN edge for 1 hour + * with stale-while-revalidate, so the actual upstream fetch happens at most + * once per hour per region. + */ + +const UPSTREAM = 'https://opencode.ai/tui.json'; +const CACHE_SECONDS = 60 * 60; // 1 hour + +export async function GET() { + const res = await fetch(UPSTREAM, { next: { revalidate: CACHE_SECONDS } }); + if (!res.ok) { + return NextResponse.json( + { error: `upstream ${UPSTREAM} returned ${res.status}` }, + { status: 502 } + ); + } + const schema = await res.json(); + + return NextResponse.json(schema, { + headers: { + 'cache-control': `public, max-age=0, s-maxage=${CACHE_SECONDS}, stale-while-revalidate=${CACHE_SECONDS}`, + 'access-control-allow-origin': '*', + }, + }); +}