feat: plugin system

This commit is contained in:
leookun committed 2026-08-30 20:00:53 +08:00
1 parent 1609b57433
commit e6130e01a7
78 files changed
+9010 -643

No files matched your search

+49
View File
@@ -412,3 +412,52 @@ fn summary_from_row(row: sqlx::sqlite::SqliteRow) -> Result<LlmCallSummary> {
detailed: row.try_get("detailed")?,
})
}
#[cfg(test)]
mod tests {
use super::*;
/// 插件模型不在 model_configs 中,调用记录必须照常落库并可按其稳定 ID 筛选。
#[tokio::test]
async fn plugin_calls_record_without_a_model_config_row() {
let directory = tempfile::tempdir().unwrap();
let store = Store::connect(&format!(
"sqlite://{}",
directory.path().join("test.db").display()
))
.await
.unwrap();
let plugin_model = "plugin:dev.example/codex/gpt-test";
store
.start_llm_call(&NewLlmCall {
call_id: "plugin-call".into(),
run_id: "run".into(),
conversation_id: "conversation".into(),
provider_call_index: 0,
model_hash: plugin_model.into(),
provider_type: ProviderType::Plugin,
provider_url: "plugin://dev.example/codex".into(),
request_type: ProviderType::Plugin,
request_url: "plugin://dev.example/codex".into(),
model_id: "gpt-test".into(),
display_name: "GPT Test".into(),
reasoning_effort: None,
fast: false,
message_count: 1,
tool_count: 0,
detailed: false,
})
.await
.unwrap();
store
.finish_llm_call("plugin-call", "completed", None, 10, None, None)
.await
.unwrap();
let overview = store
.overview(None, None, Some(&format!("[\"{plugin_model}\"]")))
.await
.unwrap();
assert_eq!(overview.metrics.llm_calls, 1);
assert_eq!(overview.metrics.successful_calls, 1);
}
}
+1 -1
View File
@@ -446,7 +446,7 @@ mod tests {
.unwrap();
assert_eq!(checksum_after, checksum_before);
assert_eq!(versions, vec![1, 2, 3, 4, 5, 6]);
assert_eq!(versions, vec![1, 2, 3, 4, 5, 6, 7]);
assert_eq!(checkpoint_table_exists, 1);
}
}