From c96fe77c45d0d2baf5ff050b6886f3842cbddb49 Mon Sep 17 00:00:00 2001 From: DoSun Date: Mon, 11 May 2026 14:33:37 +0800 Subject: [PATCH] =?UTF-8?q?fix(server):=20=E4=BF=AE=E5=A4=8D=20strict=20?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=8B=E7=B1=BB=E5=9E=8B=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - errors.ts: status 转为 ContentfulStatusCode - server.ts: BunServer 泛型参数修正 - transcriptReader.ts: 补充 compactMetadata 类型声明 --- src/server/errors.ts | 7 ++++--- src/server/server.ts | 2 +- src/server/transcriptReader.ts | 4 ++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/server/errors.ts b/src/server/errors.ts index af56c4584..e1ed18936 100644 --- a/src/server/errors.ts +++ b/src/server/errors.ts @@ -1,4 +1,5 @@ import type { Context } from 'hono' +import type { ContentfulStatusCode } from 'hono/utils/http-status' import { HTTPException } from 'hono/http-exception' export class ServeError extends Error { @@ -42,18 +43,18 @@ export function sessionError(message: string): ServeError { export function errorHandler(err: Error, c: Context) { if (err instanceof ServeError) { - return c.json(err.json(), { status: err.status }) + return c.json(err.json(), { status: err.status as ContentfulStatusCode }) } if (err instanceof HTTPException) { return c.json( { error: 'HTTP_ERROR', message: err.message }, - { status: err.status }, + { status: err.status as ContentfulStatusCode }, ) } const message = err instanceof Error && err.stack ? err.stack : err.toString() return c.json( { error: 'INTERNAL', message }, - { status: 500 }, + { status: 500 as ContentfulStatusCode }, ) } diff --git a/src/server/server.ts b/src/server/server.ts index 7599c965d..3140570b3 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -20,7 +20,7 @@ export function startServer( config: ServerConfig, sessionManager: SessionManager, eventBus: EventBus, -): BunServer & { port?: number } { +): BunServer & { port?: number } { eventBus.startHeartbeat() const app = new Hono() diff --git a/src/server/transcriptReader.ts b/src/server/transcriptReader.ts index 4c48a92bc..7d00a82d4 100644 --- a/src/server/transcriptReader.ts +++ b/src/server/transcriptReader.ts @@ -21,6 +21,10 @@ type TranscriptEntry = { content?: unknown } content?: unknown + compactMetadata?: { + preservedSegment?: unknown + [key: string]: unknown + } [key: string]: unknown }