feat: add assistant mode, SSE streaming, and OpenCode server integration (#214)

This commit is contained in:
Chris Scott authored and GitHub committed 2026-05-02 21:51:37 -04:00
1 parent 3cc24288a6
commit c3d6549f01
133 files changed
+7284 -6293

No files matched your search

@@ -0,0 +1,19 @@
import { createMiddleware } from 'hono/factory'
import { timingSafeEqual } from 'node:crypto'
import type { Database } from 'bun:sqlite'
import { getOrCreateInternalToken } from '../services/internal-token'
export function createInternalTokenMiddleware(db: Database) {
return createMiddleware(async (c, next) => {
const header = c.req.header('authorization') ?? c.req.header('Authorization')
if (!header || !header.startsWith('Bearer ')) {
return c.json({ error: 'Unauthorized' }, 401)
}
const provided = Buffer.from(header.slice(7))
const expected = Buffer.from(getOrCreateInternalToken(db))
if (provided.length !== expected.length || !timingSafeEqual(provided, expected)) {
return c.json({ error: 'Unauthorized' }, 401)
}
await next()
})
}