feat(providers): add Z.AI coding plan (global + China)

Providers 17-18 (20th & 21st registry variants), sourced authoritatively
from Pi (earendil-works/pi), the open-source agent whose provider list is
being mirrored. Pi's zai.ts / zai-coding-cn.ts use plain openAICompletionsApi
(NO special thinking dialect — overturns the matrix's 'thinking:{type} → new
dialect' concern), so Kigi maps them to Passthrough. Global: api.z.ai/api/
coding/paas/v4, ZAI_API_KEY, models.dev zai-coding-plan. China (Zhipu
BigModel): open.bigmodel.cn/api/coding/paas/v4, ZAI_CODING_CN_API_KEY,
models.dev zhipuai-coding-plan. Both Bearer + OpenAI listing + ChatCompletions
+ restrict_to_enriched; /models is auth-gated → validator.

id-match is PROVEN (not just assumed like Qwen): Pi's static model ids
[glm-4.5-air, glm-4.7, glm-5-turbo, glm-5.1, glm-5.2, glm-5v-turbo] are
byte-identical to the models.dev zai-coding-plan keys, all tool_call=true, so
restrict keeps every model with no silent-empty risk. Review found no defects.
GLM thinking is not lost (reasoning_content is parsed regardless of dialect).

Tests: e2e proves enrichment-supplied context + non-vacuous restrict (a
non-enriched wire model is dropped) + Passthrough; both variants' validation
tests hit /models and assert the per-variant console host (z.ai vs
open.bigmodel.cn). Registry at 21; picker 22 rows.

Also fixes the welcome login-picker test for the now-taller menu (renders at
a taller viewport to verify content coverage) and logs the real menu-overflow
UX debt: the picker clips rows past the fold with no scroll (q/l shortcuts
still work; only shown when unauthenticated) — deferred to its own cycle.
This commit is contained in:
2026-07-21 19:32:58 -04:00
parent c02b4b1ed7
commit 010f6c3be3
5 changed files with 243 additions and 11 deletions
+68 -2
View File
@@ -716,6 +716,62 @@ const KIMI_CODING_SPEC: PlatformSpec = PlatformSpec {
strip_listing_id_prefix: None,
};
pub const ZAI_BASE_URL_ENV: &str = "KIGI_ZAI_BASE_URL";
const ZAI_SPEC: PlatformSpec = PlatformSpec {
id: "zai",
display_name: "Z.AI",
// Z.AI coding plan (GLM). Per Pi (earendil-works/pi) this is plain
// OpenAI-compatible chat completions — no special thinking dialect.
base_url: BaseUrlSource::EnvOr {
env: ZAI_BASE_URL_ENV,
default: "https://api.z.ai/api/coding/paas/v4",
},
uses_oauth: false,
allowed_model_prefixes: None,
api_key_envs: &["ZAI_API_KEY"],
vendor: "Z.AI",
console_host: Some("z.ai"),
login_label: Some("Z.AI (API key)"),
models_dev_id: Some("zai-coding-plan"),
// /models auth-gated → validator; enrichment from models.dev; restrict to
// tool-calling GLM chat models. Live ids match the snapshot keys
// (glm-4.7, glm-5-turbo, glm-5.2, ...) byte-for-byte (verified vs Pi).
wire_serves_metadata: false,
wire_api: PlatformWireApi::ChatCompletions,
listing: ListingDialect::OpenAi,
chat_compat: PlatformChatCompat::Passthrough,
key_header: PlatformKeyHeader::Bearer,
key_validation_path: None,
strip_listing_id_prefix: None,
restrict_to_enriched: true,
};
pub const ZAI_CODING_CN_BASE_URL_ENV: &str = "KIGI_ZAI_CODING_CN_BASE_URL";
const ZAI_CODING_CN_SPEC: PlatformSpec = PlatformSpec {
id: "zai-coding-cn",
display_name: "Z.AI Coding (China)",
// Zhipu/BigModel-hosted CN coding plan; same OpenAI-compatible shape.
base_url: BaseUrlSource::EnvOr {
env: ZAI_CODING_CN_BASE_URL_ENV,
default: "https://open.bigmodel.cn/api/coding/paas/v4",
},
uses_oauth: false,
allowed_model_prefixes: None,
api_key_envs: &["ZAI_CODING_CN_API_KEY"],
vendor: "Z.AI",
console_host: Some("open.bigmodel.cn"),
login_label: Some("Z.AI Coding China (API key)"),
models_dev_id: Some("zhipuai-coding-plan"),
wire_serves_metadata: false,
wire_api: PlatformWireApi::ChatCompletions,
listing: ListingDialect::OpenAi,
chat_compat: PlatformChatCompat::Passthrough,
key_header: PlatformKeyHeader::Bearer,
key_validation_path: None,
strip_listing_id_prefix: None,
restrict_to_enriched: true,
};
/// The platform registry. Platforms are compiled-in spec rows; there is no
/// dynamic provider registration (PRD F2).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
@@ -758,12 +814,16 @@ pub enum PlatformId {
QwenTokenPlanCn,
/// Kimi For Coding via a static KIMI_API_KEY (same endpoint as `KimiCode`).
KimiCoding,
/// Z.AI coding plan, global (API key, OpenAI-compatible GLM).
Zai,
/// Z.AI coding plan, China / Zhipu BigModel (API key, OpenAI-compatible).
ZaiCodingCn,
}
impl PlatformId {
/// All platforms, in catalog precedence order: the subscription channel
/// first so "default model = first list item" favors it when present.
pub const ALL: [PlatformId; 19] = [
pub const ALL: [PlatformId; 21] = [
Self::KimiCode,
Self::MoonshotCn,
Self::MoonshotAi,
@@ -783,6 +843,8 @@ impl PlatformId {
Self::QwenTokenPlan,
Self::QwenTokenPlanCn,
Self::KimiCoding,
Self::Zai,
Self::ZaiCodingCn,
];
/// The registry row backing this platform (single source of per-platform
@@ -808,6 +870,8 @@ impl PlatformId {
Self::QwenTokenPlan => &QWEN_TOKEN_PLAN_SPEC,
Self::QwenTokenPlanCn => &QWEN_TOKEN_PLAN_CN_SPEC,
Self::KimiCoding => &KIMI_CODING_SPEC,
Self::Zai => &ZAI_SPEC,
Self::ZaiCodingCn => &ZAI_CODING_CN_SPEC,
}
}
@@ -1567,9 +1631,11 @@ mod tests {
PlatformId::QwenTokenPlan => 16,
PlatformId::QwenTokenPlanCn => 17,
PlatformId::KimiCoding => 18,
PlatformId::Zai => 19,
PlatformId::ZaiCodingCn => 20,
}
}
const VARIANT_COUNT: usize = 19; // update together with `ordinal`
const VARIANT_COUNT: usize = 21; // update together with `ordinal`
let mut seen: Vec<usize> = PlatformId::ALL.iter().map(|&p| ordinal(p)).collect();
seen.sort_unstable();
seen.dedup();