(plan) convert original implement plan to mock api

This commit is contained in:
Story Crater Bot
2026-08-19 09:47:14 -07:00
parent c42040319f
commit 0aef2281bc
65 changed files with 307 additions and 627 deletions
+50
View File
@@ -0,0 +1,50 @@
/**
* Mock stand-in for the real atlas `POST /api/chat`. Streams the same SSE event shape
* (`queue` → `reasoning` → `content` → `done`) as the real endpoint would, but replays a
* canned reply instead of calling vLLM — no rate limiting, no budget, no real model.
*/
const REPLY_REASONING =
'The user is asking about a gap in the wave column display. Argo CD sync waves are integers used purely for ordering; there is no requirement that they be contiguous. The cluster uses 0,1,2,3,5,6,7,8. This is normal and usually happens when a wave is retired or intentionally reserved.'
const REPLY =
'Wave 4 is empty. Waves are sort keys, not a sequence — Argo orders by value and skips gaps, so 3 is followed directly by 5. Nothing is missing.'
const wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))
export async function POST() {
const encoder = new TextEncoder()
const stream = new ReadableStream({
async start(controller) {
const send = (type: string, payload: Record<string, unknown> = {}) => {
controller.enqueue(encoder.encode(`data: ${JSON.stringify({ type, ...payload })}\n\n`))
}
for (let position = 3; position > 0; position--) {
send('queue', { position })
await wait(500)
}
send('reasoning', { text: REPLY_REASONING })
await wait(200)
let i = 0
while (i < REPLY.length) {
i += 3
send('content', { text: REPLY.slice(0, i) })
await wait(40)
}
send('done')
controller.close()
},
})
return new Response(stream, {
headers: {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache',
Connection: 'keep-alive',
},
})
}