From a660e920b6061c4268d0738e6626dcf9f32e67b8 Mon Sep 17 00:00:00 2001 From: m3tam3re
Date: Fri, 25 Sep 2026 08:19:52 +0200 Subject: [PATCH] feat(agents): z.ai GLM coding plan provider + paperclip env passthrough MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - opencode.nix: add zai-coding-plan provider (OpenAI-compatible coding-plan endpoint, apiKey via {env:ZAI_API_KEY}) with glm-5.3 (1M ctx) and glm-5-turbo — resolves in OpenCode itself, so Paperclip's opencode-harness agents can run on the GLM flat rate - paperclip.nix: optional EnvironmentFile=%h/.config/paperclip.env so agents spawned by the service inherit provider keys --- profiles/sets/coding/agents/opencode.nix | 32 +++++++++++++++++++++++ profiles/sets/coding/agents/paperclip.nix | 4 +++ 2 files changed, 36 insertions(+) diff --git a/profiles/sets/coding/agents/opencode.nix b/profiles/sets/coding/agents/opencode.nix index 4c7ce45..bd4874c 100644 --- a/profiles/sets/coding/agents/opencode.nix +++ b/profiles/sets/coding/agents/opencode.nix @@ -168,6 +168,38 @@ # AZ-Gruppe LiteLLM endpoint + available models provider = { + # Z.AI GLM Coding Plan (flat-rate subscription). + # OpenAI-compatible endpoint; API key from the z.ai console is + # injected via {env:...} so it never lands in the store. Consumed by + # interactive opencode2 sessions (shell env) and by agents spawned + # through Paperclip's opencode harness (service EnvironmentFile). + zai-coding-plan = { + npm = "@ai-sdk/openai-compatible"; + name = "Z.AI Coding Plan"; + options = { + baseURL = "https://api.z.ai/api/coding/paas/v4"; + apiKey = "{env:ZAI_API_KEY}"; + }; + models = { + # Primary worker: 1M ctx flat-rate model. + "glm-5.3" = { + name = "GLM-5.3"; + limit = { + context = 1000000; + output = 128000; + }; + }; + # High-volume parallel scans: speed-tuned GLM on flat rate. + "glm-5-turbo" = { + name = "GLM-5 Turbo"; + limit = { + context = 200000; + output = 128000; + }; + }; + }; + }; + litellm = { npm = "@ai-sdk/openai-compatible"; name = "LiteLLM (AZ-Gruppe)"; diff --git a/profiles/sets/coding/agents/paperclip.nix b/profiles/sets/coding/agents/paperclip.nix index cefd268..79d861e 100644 --- a/profiles/sets/coding/agents/paperclip.nix +++ b/profiles/sets/coding/agents/paperclip.nix @@ -40,6 +40,10 @@ "PAPERCLIP_INSTANCE_ID=default" "PAPERCLIP_HOME=%h/.paperclip" ]; + # Optional per-user env file (e.g. ZAI_API_KEY for the GLM coding + # plan) — inherited by agent harnesses spawned from the service. + # Leading '-' keeps the unit working when the file is absent. + EnvironmentFile = "-%h/.config/paperclip.env"; WorkingDirectory = "%h"; Restart = "always"; RestartSec = 5;