Add session-level bridge model settings (#811)

This commit is contained in:
ekko
2026-05-17 12:20:53 +08:00
committed by GitHub
parent fa035f348e
commit 5e8f8bd4a1
35 changed files with 697 additions and 60 deletions
+1
View File
@@ -34,6 +34,7 @@ export const SESSIONS_SCHEMA: Record<string, string> = {
source: 'TEXT NOT NULL DEFAULT \'api_server\'',
user_id: 'TEXT',
model: 'TEXT NOT NULL DEFAULT \'\'',
provider: 'TEXT NOT NULL DEFAULT \'\'',
title: 'TEXT',
started_at: 'INTEGER NOT NULL',
ended_at: 'INTEGER',
@@ -12,6 +12,7 @@ export interface HermesSessionRow {
source: string
user_id: string | null
model: string
provider: string
title: string | null
started_at: number
ended_at: number | null
@@ -85,6 +86,7 @@ function mapSessionRow(row: Record<string, unknown>): HermesSessionRow {
source: String(row.source || 'api_server'),
user_id: row.user_id != null ? String(row.user_id) : null,
model: String(row.model || ''),
provider: String(row.provider || ''),
title,
started_at: Number(row.started_at || 0),
ended_at: row.ended_at != null ? Number(row.ended_at) : null,
@@ -131,6 +133,7 @@ export function createSession(data: {
profile?: string
source?: string
model?: string
provider?: string
title?: string
workspace?: string
}): HermesSessionRow {
@@ -139,7 +142,7 @@ export function createSession(data: {
if (!isSqliteAvailable()) {
return {
id: data.id, profile: data.profile || 'default', source,
user_id: null, model: data.model || '', title: data.title || null,
user_id: null, model: data.model || '', provider: data.provider || '', title: data.title || null,
started_at: now, ended_at: null, end_reason: null,
message_count: 0, tool_call_count: 0,
input_tokens: 0, output_tokens: 0, cache_read_tokens: 0, cache_write_tokens: 0, reasoning_tokens: 0,
@@ -149,9 +152,9 @@ export function createSession(data: {
}
const db = getDb()!
db.prepare(
`INSERT INTO ${SESSIONS_TABLE} (id, profile, source, model, title, started_at, last_active, workspace)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
).run(data.id, data.profile || 'default', source, data.model || '', data.title || null, now, now, data.workspace || null)
`INSERT INTO ${SESSIONS_TABLE} (id, profile, source, model, provider, title, started_at, last_active, workspace)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
).run(data.id, data.profile || 'default', source, data.model || '', data.provider || '', data.title || null, now, now, data.workspace || null)
return getSession(data.id)!
}