Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

api.compaction-inspect.ts

22 lines792 Bytes

1import { createFileRoute } from '@tanstack/react-router'
2import { clearCompactions, getCompactions } from '@/lib/compaction-store'
3​
4/**
5 * Read side of the `/compaction` demo. GET returns the recorded compaction
6 * events for a thread; DELETE clears them (used by "New thread").
7 */
8export const Route = createFileRoute('/api/compaction-inspect')({
9 server: {
10 handlers: {
11 GET: async ({ request }) => {
12 const threadId = new URL(request.url).searchParams.get('threadId') ?? ''
13 return Response.json({ events: getCompactions(threadId) })
14 },
15 DELETE: async ({ request }) => {
16 const threadId = new URL(request.url).searchParams.get('threadId') ?? ''
17 clearCompactions(threadId)
18 return Response.json({ ok: true })
19 },
20 },
21 },
22})