// Model-lineage compat for "glm"; regenerated from the frozen census using class taxonomy selectors.

class "glm" {
	// Replaces provider-keyed GLM 5+ coding-plan stream-idle dispatch.
	on "zhipu-coding-plan" "opencode-go" "opencode-zen" {
		revision ">=5" {
			stream-idle-timeout-ms 600000
		}
	}
	// GLM-5.2 exposes the default lower tiers plus a genuine max on generic
	// OpenAI-compatible hosts; the zai-dialect and Anthropic-route hosts
	// (Z.ai, Zhipu, Umans, Ollama Cloud, Baseten) serve only high/max.
	// priority breaks the intentional overlap with provider-level blanket GLM
	// ladders authored for the pre-5.2 census (e.g. alibaba-coding-plan.kdl),
	// so the 5.2 lineage ladder wins on generic hosts that lack a 5.2 residue.
	revision ">=5.2 <5.3" priority=10 {
		thinking-efforts "minimal" "low" "medium" "high" "max"
	}
	on "zai" "zhipu-coding-plan" {
		revision ">=5.2 <5.3" {
			zai-reasoning-effort-dialect #true
			clamp-output-to-model-max #true
		}
	}
	on "zai" "zhipu-coding-plan" "umans" "ollama-cloud" "baseten" {
		revision ">=5.2 <5.3" {
			thinking-efforts "high" "max"
		}
	}
	// Vercel fronts GLM 5.2 on its Anthropic route with the generic ladder.
	on "vercel-ai-gateway" {
		revision ">=5.2 <5.3" {
			thinking-efforts "minimal" "low" "medium" "high" "xhigh"
		}
	}
	// Abliteration serves abliterated GLM deployments behind opaque product ids
	// (docs.abliteration.ai/capabilities/thinking, 2026-09). The large models
	// run fewer modes than the six-level ladder they accept, rounding aliases
	// UP at the midpoint (medium → high, xhigh → max). Those aliases stay in
	// the ladder so a request is never clamped down past its documented mode,
	// and the map sends the native mode on the wire.
	on "abliteration" {
		// Base `abliterated-model`: distinct depths; Responses rejects `max`.
		thinking-efforts "minimal" "low" "medium" "high" "xhigh"
		// Large (GLM-5.2): high/max, default high; minimal..high → high.
		revision ">=5.2 <5.3" {
			thinking-default-level "high"
			thinking-efforts "high" "xhigh" "max"
			reasoning-effort-map {
				xhigh "max"
			}
		}
		// Large V2 (GLM-5.3): low/high/max, default max; reasoning cannot be
		// disabled (disable-shaped controls run at hidden low).
		revision ">=5.3" {
			thinking-default-level "max"
			thinking-efforts "low" "medium" "high" "xhigh" "max"
			thinking-requires-effort #true
			reasoning-effort-map {
				medium "high"
				xhigh "max"
			}
		}
	}
	// GLM Coding Plan: the selectable 1M-context served ids; pin them so
	// endpoint discovery or older bundled fallbacks cannot regress to 200k.
	on "zai" "zhipu-coding-plan" {
		models "glm-5.2" "glm-5.3" "glm-5.3-flash" "glm-5.3-flashx" {
			limits-patch {
				context-window 1000000
				max-tokens 131072
			}
		}
	}
	// glm-5.3-flash: keep the permanent documented list price, not the
	// stencil.so launch promotion (expires 2026-09-09).
	on "zai" {
		models "glm-5.3-flash" {
			cost-patch {
				input 0.15
				output 0.5
				cache-read 0.03
				cache-write 0.0
			}
		}
	}
	// GLM-5.3 Flash and FlashX accept native image input on their coding routes.
	on "zai" "zhipu-coding-plan" {
		models "glm-5.3-flash" "glm-5.3-flashx" {
			input-modalities "text" "image"
		}
	}
	on "alibaba-coding-plan" "alibaba-token-plan" "wafer-serverless" {
		supports-developer-role #false
	}
	on "openrouter" "zhipu-coding-plan" {
		family "air" {
			thinking-efforts "minimal" "low" "medium" "high"
		}
	}
	// GLM-5.3+ coding SKUs (base/air/turbo/flash/flashx) expose a uniform
	// wire-exact low/high/max reasoning-effort ladder on every host, thinking
	// can no longer be disabled, and the default effort is max.
	// residue: taxonomy ranks cannot separate these ids from the vision (`…v`)
	// and preview shapes that keep host dialects; the explicit priority resolves
	// the intentional overlap with census host-dialect residues such as
	// baseten's `zai-org/GLM-5*`.
	models "*glm-5.3" "*glm-5.3-air" "*glm-5.3-turbo" "*glm-5.3-flash" "*glm-5.3-flashx" "*glm-5.3:*" \
		"*glm-5.3-flash-uncensored" "*glm-5.3-free" "*glm-5.3-highspeed" "*glm-5.3-fast" "*glm-5.3-flash-lab" priority=10 {
		thinking-default-level "max"
		thinking-efforts "low" "high" "max"
		thinking-requires-effort #true
	}
	// GLM 5+ reasoning reaches omp as its plaintext trace on every host, and
	// family plus revision pin the weights (glm-5.2, glm-5.3-flash, ...). GLM 4
	// classifies too coarsely to carry: 4.0 also matches glm-4.5v and glm-4.6v.
	revision ">=5" {
		portable-reasoning #true
		// residue: fine-tuned weights that classify as the base GLM revision.
		models "*-uncensored" "*-cybersecurity" {
			portable-reasoning #false
		}
	}
}
