-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathconfig.example.yaml
More file actions
153 lines (136 loc) · 5.74 KB
/
Copy pathconfig.example.yaml
File metadata and controls
153 lines (136 loc) · 5.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
server:
port: 8080
host: "0.0.0.0"
auth:
# "apikey" = use a pre-obtained API key directly
# "oauth" = use OAuth login flow (run `bun run src/index.ts auth login` first)
mode: apikey
# For apikey mode:
# Z.AI: "yourApiKey.yourSecretKey"
# Bigmodel: "yourApiKey"
apiKey: "YOUR_API_KEY_HERE"
# Key that clients must provide to use the proxy.
# Set to null/omit to disable client auth.
proxyApiKey: "your-proxy-secret"
# For oauth mode (path to stored credentials from login flow):
# oauthCredentialsPath: "~/.zcode-proxy/credentials.json"
# Which upstream provider to use: "zai" or "bigmodel"
provider: zai
# Which plan tier to use:
# "coding-plan" (default) — direct upstream endpoints, permanent API key
# "start-plan" — routes through zcode.z.ai with JWT auth (requires `auth login`)
plan: coding-plan
providers:
zai:
anthropicBase: "https://api.z.ai/api/anthropic"
openaiBase: "https://api.z.ai/api/coding/paas/v4"
bigmodel:
anthropicBase: "https://open.bigmodel.cn/api/anthropic"
openaiBase: "https://open.bigmodel.cn/api/coding/paas/v4"
defaultModel: glm-4.6
models:
- glm-4.5-air
- glm-4.6
- glm-4.6v
- glm-4.7
- glm-5
- glm-5-turbo
- glm-5v-turbo
- glm-5.1
- glm-5.2
- glm-5.3
# Configurable identity headers injected on every upstream request to mimic the
# ZCode desktop client (User-Agent, X-ZCode-App-Version, X-Title,
# X-ZCode-Agent, HTTP-Referer). Runtime platform headers (X-Platform,
# X-Os-Category, X-Os-Version) are detected dynamically and are not configured
# here. All fields below are optional; env vars override YAML, which overrides
# defaults.
identity:
# Mirrors process.env.ZCODE_APP_VERSION in the ZCode bundle.
# Must be printable ASCII; non-conforming values fall back to the default.
# Default: "3.8.1" (current ZCode release). Override to match your real client.
appVersion: "3.8.1"
# X-Title suffix → "Z Code@{sourceTitle}". Default "cli".
sourceTitle: "cli"
# HTTP-Referer URL. Default "https://zcode.z.ai".
refererOrigin: "https://zcode.z.ai"
# Device identity (X-Device-Mid) — random UUIDv4, generated ONCE and reused
# forever (mirrors ZCode's telemetry deviceMid; no hardware values involved).
# Auto-generated into this file at first `auth login` or config creation.
# Leave empty on Android — the app injects ZCODE_IDENTITY_DEVICE_MID instead.
deviceMid: ""
# Local client-session inference for cache-affinity experiments.
# "observe" (default) logs inferred sessions in debug mode but does not change
# upstream x-session-id. "enforce" reuses a stable x-session-id for inferred
# coding-plan sessions. "off" disables inference entirely.
clientIdentity:
mode: observe
ttlSeconds: 900
maxSessions: 1024
# Responses API (/v1/responses) — Codex CLI / OpenAI Agents SDK endpoint.
# Translates Responses requests to the GLM Chat Completions upstream.
# State (previous_response_id) is held in-memory (cleared on restart, 24h TTL).
responses:
enabled: true
store:
maxEntries: 1000
ttlMs: 86400000
# GLM MCP hosted-tool integration.
# Endpoints are derived from `provider`:
# zai → https://api.z.ai/api/mcp/{tool}/mcp
# bigmodel → https://open.bigmodel.cn/api/mcp/{tool}/mcp
# Auth reuses the upstream credential (auth.apiKey / OAuth) — no extra key needed.
mcp:
enabled: true
# Intercept `web_search`/`web_search_preview` hosted tools via GLM's
# `web_search_prime` MCP. Adds a one-shot agentic loop on /v1/responses.
webSearch: true
# Inject `webReader` as a function tool the model can call directly.
webReader: false
# Inject the three `zread` tools (search_doc/get_repo_structure/read_file).
zread: false
# Async (off-peak / "idle plan") bridge.
# When enabled, exposes POST /async/v1/messages and /async/v1/chat/completions
# that route through ZCode's off-peak ticket-queue backend — free compute when
# the GLM cluster has idle capacity. The proxy holds the connection open with
# SSE keepalives during queue wait, forwards the LLM stream once a ticket is
# ready, and auto-retries on ticket-expired (up to maxRetries).
#
# IMPORTANT: requires `auth.mode: oauth` (off-peak needs the JWT from login).
# apikey-only mode lacks the JWT and the route returns 400
# `async_credentials_unavailable`.
#
# Env overrides: ZCODE_ASYNC_ENABLED, ZCODE_ASYNC_ORIGIN.
async:
enabled: false
origin: "https://zcode.z.ai"
pollIntervalMs: 5000
keepAliveIntervalMs: 3000
# Maximum total wait for ticket to become ready, in ms. 0 = unlimited.
maxWaitMs: 0
maxRetries: 3
settleTimeoutMs: 8000
controlTimeoutMs: 15000
# Optional model override; empty uses the request's `model`.
defaultModel: ""
# Server-controlled upstream URL remapping (mirrors the ZCode client's
# ProviderEndpointRoutingService). The proxy periodically fetches
# {origin}/api/v1/agent/configs and rewrites matching upstream URLs per the
# returned proxyEndpoint.mapping table (currently the coding-plan Anthropic
# endpoints -> zcode.z.ai ultra endpoints). Fail-open: any fetch/parse error
# keeps the original URLs. Env override: ZCODE_ENDPOINT_ROUTING=false.
endpointRouting:
enabled: true
origin: "https://zcode.z.ai"
# Client request signing V4 (mirrors the ZCode 3.8.1 ClientRequestSigningV4Signer).
# When enabled, the proxy probes {origin}/api/v1/agent/configs (cached 1h) and,
# only if the server sets data.codingPlanSignature.enable=true, signs coding-plan
# requests: handshake against {provider}/api/paas/c1f3a7e2/v2/client, Ed25519
# signature + proof-of-work headers on every request, fail-open retry ladder
# (two 401 VERIFY rejections -> permanent unsigned bypass). Start-plan and
# off-peak paths are never signed. Env override: ZCODE_CLIENT_SIGNING=false.
clientSigning:
enabled: true
origin: "https://zcode.z.ai"
logging:
level: info