chore: bump deps

This commit is contained in:
DarkSky
2026-07-11 06:43:04 +08:00
parent b22bc17bd0
commit aea128f0b9
10 changed files with 183 additions and 63 deletions
@@ -1,6 +1,6 @@
use jsonschema::Draft;
use napi::{Error, Result, Status};
use schemars::{JsonSchema, r#gen::SchemaSettings};
use schemars::{JsonSchema, generate::SchemaSettings};
use serde_json::Value;
use super::{
@@ -61,15 +61,18 @@ fn mark_property_nullable(schema: &mut Value, property: &str) {
}
fn mark_definition_property_nullable(schema: &mut Value, definition: &str, property: &str) {
if let Some(property_schema) = schema
.get_mut("definitions")
.and_then(Value::as_object_mut)
.and_then(|definitions| definitions.get_mut(definition))
.and_then(|schema| schema.get_mut("properties"))
.and_then(Value::as_object_mut)
.and_then(|properties| properties.get_mut(property))
{
mark_schema_nullable(property_schema);
for definitions_key in ["definitions", "$defs"] {
if let Some(property_schema) = schema
.get_mut(definitions_key)
.and_then(Value::as_object_mut)
.and_then(|definitions| definitions.get_mut(definition))
.and_then(|schema| schema.get_mut("properties"))
.and_then(Value::as_object_mut)
.and_then(|properties| properties.get_mut(property))
{
mark_schema_nullable(property_schema);
return;
}
}
}
@@ -319,7 +319,7 @@ pub struct RequestedModelMatchResponse {
pub struct ModelRegistryResolveRequest {
#[napi(
ts_type = "'openai_chat' | 'openai_responses' | 'anthropic' | 'cloudflare_workers_ai' | 'gemini_api' | \
'gemini_vertex' | 'fal' | 'anthropic_vertex'"
'gemini_vertex' | 'fal' | 'anthropic_vertex' | 'deepseek' | 'kimi' | 'opencode_go' | 'opencode_zen'"
)]
#[serde(skip_serializing_if = "Option::is_none")]
pub backend_kind: Option<String>,
@@ -333,7 +333,7 @@ pub struct ModelRegistryResolveRequest {
pub struct ModelRegistryMatchRequest {
#[napi(
ts_type = "'openai_chat' | 'openai_responses' | 'anthropic' | 'cloudflare_workers_ai' | 'gemini_api' | \
'gemini_vertex' | 'fal' | 'anthropic_vertex'"
'gemini_vertex' | 'fal' | 'anthropic_vertex' | 'deepseek' | 'kimi' | 'opencode_go' | 'opencode_zen'"
)]
pub backend_kind: String,
pub cond: ModelConditionsContract,
@@ -346,7 +346,7 @@ pub struct ModelRegistryMatchRequest {
pub struct ModelRegistryVariantContract {
#[napi(
ts_type = "'openai_chat' | 'openai_responses' | 'anthropic' | 'cloudflare_workers_ai' | 'gemini_api' | \
'gemini_vertex' | 'fal' | 'anthropic_vertex'"
'gemini_vertex' | 'fal' | 'anthropic_vertex' | 'deepseek' | 'kimi' | 'opencode_go' | 'opencode_zen'"
)]
pub backend_kind: String,
pub canonical_key: String,
@@ -361,8 +361,8 @@ pub struct ModelRegistryVariantContract {
#[serde(skip_serializing_if = "Option::is_none")]
pub protocol: Option<String>,
#[napi(
ts_type = "'anthropic' | 'chat_completions' | 'cloudflare_workers_ai' | 'responses' | 'openai_images' | 'fal' | \
'vertex' | 'vertex_anthropic' | 'gemini_api' | 'gemini_vertex'"
ts_type = "'anthropic' | 'chat_completions' | 'chat_completions_no_v1' | 'cloudflare_workers_ai' | 'responses' | \
'openai_images' | 'fal' | 'vertex' | 'vertex_anthropic' | 'gemini_api' | 'gemini_vertex'"
)]
#[serde(skip_serializing_if = "Option::is_none")]
pub request_layer: Option<String>,
@@ -381,8 +381,8 @@ pub struct ModelRegistryRouteContract {
#[serde(skip_serializing_if = "Option::is_none")]
pub protocol: Option<String>,
#[napi(
ts_type = "'anthropic' | 'chat_completions' | 'cloudflare_workers_ai' | 'responses' | 'openai_images' | 'fal' | \
'vertex' | 'vertex_anthropic' | 'gemini_api' | 'gemini_vertex'"
ts_type = "'anthropic' | 'chat_completions' | 'chat_completions_no_v1' | 'cloudflare_workers_ai' | 'responses' | \
'openai_images' | 'fal' | 'vertex' | 'vertex_anthropic' | 'gemini_api' | 'gemini_vertex'"
)]
#[serde(skip_serializing_if = "Option::is_none")]
pub request_layer: Option<String>,
@@ -111,6 +111,80 @@ mod tests {
assert_eq!(response.variant.unwrap().raw_model_id, "gemini-embedding-001");
}
#[test]
fn should_resolve_deepseek_provider_variants() {
let response = llm_resolve_model_registry_variant(ModelRegistryResolveRequest {
backend_kind: Some("deepseek".to_string()),
model_id: "deepseek-v4-pro".to_string(),
})
.unwrap();
let variant = response.variant.unwrap();
assert_eq!(variant.raw_model_id, "deepseek-v4-pro");
assert_eq!(variant.request_layer.as_deref(), Some("chat_completions_no_v1"));
let legacy = llm_resolve_model_registry_variant(ModelRegistryResolveRequest {
backend_kind: Some("deepseek".to_string()),
model_id: "deepseek-chat".to_string(),
})
.unwrap();
assert_eq!(legacy.matched_by.as_deref(), Some("legacy_alias"));
assert_eq!(legacy.variant.unwrap().raw_model_id, "deepseek-v4-flash");
}
#[test]
fn should_resolve_kimi_provider_default_model() {
let response = llm_resolve_model_registry_variant(ModelRegistryResolveRequest {
backend_kind: Some("kimi".to_string()),
model_id: "kimi-k2.7-code-highspeed".to_string(),
})
.unwrap();
let variant = response.variant.unwrap();
assert_eq!(variant.raw_model_id, "kimi-k2.7-code-highspeed");
assert_eq!(variant.protocol.as_deref(), Some("openai_chat"));
assert_eq!(variant.request_layer.as_deref(), Some("chat_completions"));
assert_eq!(
variant.behavior_flags.as_deref(),
Some(&["omit_tool_choice".to_string(), "reasoning_supported".to_string()][..])
);
}
#[test]
fn should_resolve_opencode_go_prefixed_alias() {
let response = llm_resolve_model_registry_variant(ModelRegistryResolveRequest {
backend_kind: Some("opencode_go".to_string()),
model_id: "opencode-go/kimi-k2.7-code".to_string(),
})
.unwrap();
let variant = response.variant.unwrap();
assert_eq!(response.matched_by.as_deref(), Some("alias"));
assert_eq!(variant.backend_kind, "opencode_go");
assert_eq!(variant.raw_model_id, "kimi-k2.7-code");
}
#[test]
fn should_match_opencode_zen_default_variant() {
let response = llm_match_model_registry(ModelRegistryMatchRequest {
backend_kind: "opencode_zen".to_string(),
cond: ModelConditionsContract {
input_types: Some(vec!["text".to_string()]),
attachment_kinds: None,
attachment_source_kinds: None,
has_remote_attachments: None,
model_id: None,
output_type: Some("text".to_string()),
},
})
.unwrap();
let variant = response.variant.unwrap();
assert_eq!(variant.raw_model_id, "kimi-k2.7-code");
assert_eq!(variant.backend_kind, "opencode_zen");
}
#[test]
fn should_resolve_gemini_embedding_2() {
let response = llm_resolve_model_registry_variant(ModelRegistryResolveRequest {