feat: OpenAI-kompatible API mit Keys, Registry und serve-Befehl (M2.3)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-09 17:27:46 +01:00
parent ada5745c53
commit 4d53d5afa3
35 changed files with 3434 additions and 21 deletions

View File

@ -10,13 +10,19 @@ use std::path::Path;
use nexus_core::{Error, Result};
use rusqlite::Connection;
mod keys;
mod registry;
pub use keys::{ApiKeyRecord, Rights};
pub use registry::{ModelEntry, NewLlm, StartPlan};
/// Alle Migrationen in Reihenfolge. Index 0 ergibt Schema-Version 1.
const MIGRATIONS: &[&str] = &[include_str!("../migrations/0001_init.sql")];
/// Schema-Version, die dieses Crate erzeugt.
pub const LATEST_SCHEMA_VERSION: i64 = MIGRATIONS.len() as i64;
fn db(e: rusqlite::Error) -> Error {
pub(crate) fn db(e: rusqlite::Error) -> Error {
Error::Db(e.to_string())
}
@ -49,6 +55,10 @@ impl Store {
Ok(store)
}
pub(crate) fn transaction(&mut self) -> rusqlite::Result<rusqlite::Transaction<'_>> {
self.conn.transaction()
}
fn migrate(&mut self) -> Result<()> {
let current = self.schema_version()?;
if current > LATEST_SCHEMA_VERSION {