glm-acp-agent 1.1.4 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # glm-acp-agent
2
2
 
3
- An [Agent Client Protocol (ACP)](https://agentclientprotocol.com) agent written in TypeScript that uses the **Z.AI / Zhipu AI GLM** model family (GLM-5.1, GLM-4.7, GLM-4.6, …) as its reasoning core.
3
+ An [Agent Client Protocol (ACP)](https://agentclientprotocol.com) agent written in TypeScript that uses the **Z.AI / Zhipu AI GLM** model family (GLM-5.2, GLM-5.1, GLM-4.7, …) as its reasoning core.
4
4
 
5
5
  The agent connects to any ACP-compatible IDE or client over **stdio**, streams responses back in real time, and can call a rich set of tools to interact with the user's file system, terminal, and the web.
6
6
 
@@ -139,7 +139,7 @@ The agent reads its configuration from environment variables, plus an optional c
139
139
  | Variable | Required | Default | Description |
140
140
  |----------|----------|---------|-------------|
141
141
  | `Z_AI_API_KEY` | One of env / `--setup` | — | API key for the Z.AI / Zhipu AI service. If unset, the credentials file is consulted. |
142
- | `ACP_GLM_MODEL` | No | `glm-5.1` | Default GLM model for new sessions |
142
+ | `ACP_GLM_MODEL` | No | `glm-5.2` | Default GLM model for new sessions |
143
143
  | `ACP_GLM_AVAILABLE_MODELS` | No | built-in list | Comma-separated list of model ids advertised in `session/set_model` |
144
144
  | `ACP_GLM_BASE_URL` | No | `https://api.z.ai/api/coding/paas/v4` | Override the API base URL |
145
145
  | `ACP_GLM_MAX_TOKENS` | No | `8192` | Cap on `max_tokens` for each completion |
@@ -170,7 +170,8 @@ The agent advertises only the models on the current Z.AI Coding Plan allowlist:
170
170
 
171
171
  | Model | Notes |
172
172
  |-------|-------|
173
- | `glm-5.1` | **Default.** Long-horizon coding model; thinking mode auto-enabled |
173
+ | `glm-5.2` | **Default.** Newest 1M-context coding model; thinking mode auto-enabled |
174
+ | `glm-5.1` | Long-horizon coding model; thinking mode auto-enabled |
174
175
  | `glm-5-turbo` | Faster Coding Plan reasoning model |
175
176
  | `glm-5v-turbo` | Multimodal Coding Plan model; native image understanding for jpg / jpeg / png inputs |
176
177
  | `glm-4.7` | 200K-context reasoning model |
@@ -182,6 +183,17 @@ Vision-only chat models (`glm-4v-plus` etc.) are **not** advertised. The multimo
182
183
 
183
184
  When the model name matches `glm-4.5`, `glm-4.6`, `glm-4.7`, or the `glm-5` family, the agent enables Z.AI's `thinking: { type: "enabled" }` extension and forwards reasoning tokens to the client as `agent_thought_chunk` blocks. This includes `glm-5v-turbo`. Override with `ACP_GLM_THINKING=false` if you want plain completions only.
184
185
 
186
+ #### Thought level (reasoning effort)
187
+
188
+ The agent advertises a `thought_level` [SessionConfigOption](https://agentclientprotocol.com) so clients that support config options (e.g. a "Thinking" selector) can control reasoning effort per session. The available levels depend on the active model:
189
+
190
+ | Model | Levels | Mapping to the Z.AI request |
191
+ |-------|--------|-----------------------------|
192
+ | `glm-5.2` | `Off` / `High` / `Max` | `Off` → `thinking: { type: "disabled" }`; `High`/`Max` → `thinking: { type: "enabled" }` + `reasoning_effort: "high"` / `"max"` |
193
+ | other thinking-capable models | `Off` / `On` | `Off` → `thinking: { type: "disabled" }`; `On` → `thinking: { type: "enabled" }` |
194
+
195
+ `reasoning_effort` is a GLM-5.2 extra — other models never receive it. New sessions default to the model's own default effort (`Max` on GLM-5.2, which is also Z.AI's default when the field is omitted), so out-of-the-box behaviour is unchanged. Switching models re-clamps the level (e.g. a `High` selection reverts to `On` when you move off GLM-5.2) and pushes a `config_option_update`. The `ACP_GLM_THINKING` env override still wins: `false` forces thinking off regardless of the selected level. Clients that don't support config options simply ignore the advertised option and get the default behaviour.
196
+
185
197
  `ACP_GLM_PROMPT_IMAGES=false` still hides the image-attachment capability at session startup. With that flag set, users can pick `glm-5v-turbo` for text work but clients should not offer image attachments.
186
198
 
187
199
  ### Vision MCP
@@ -314,7 +326,7 @@ If `Z_AI_API_KEY` is set in the environment **and** a credentials file exists, t
314
326
  2. Open the **agent panel** (use the command palette: `agent panel: toggle focus`).
315
327
  3. In the agent picker, select **glm** — Zed labels external agents by their `agent_servers` key.
316
328
  4. Start a new thread and send a small prompt that exercises a tool, e.g. `Read package.json and tell me the project name.`
317
- 5. You should see streaming text, a `read_file` tool call awaiting permission, and (with a thinking-capable model like `glm-5.1`) reasoning surfaced as a separate thought block.
329
+ 5. You should see streaming text, a `read_file` tool call awaiting permission, and (with a thinking-capable model like `glm-5.2`) reasoning surfaced as a separate thought block.
318
330
 
319
331
  #### 5. Iterating on the agent
320
332
 
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@
9
9
  * Environment variables:
10
10
  * Z_AI_API_KEY - API key for the Z.AI / Zhipu AI service. If unset,
11
11
  * falls back to the credentials file written by --setup.
12
- * ACP_GLM_MODEL - (optional) Override the default model (default: glm-5.1)
12
+ * ACP_GLM_MODEL - (optional) Override the default model (default: glm-5.2)
13
13
  */
14
14
  import { startConnection } from "./protocol/connection.js";
15
15
  import { runSetup } from "./setup.js";
@@ -34,7 +34,7 @@ else if (args.includes("--help") || args.includes("-h")) {
34
34
  "",
35
35
  "Environment variables:",
36
36
  " Z_AI_API_KEY API key (overrides the stored credentials)",
37
- " ACP_GLM_MODEL Default model id (e.g. glm-5.1)",
37
+ " ACP_GLM_MODEL Default model id (e.g. glm-5.2)",
38
38
  " ACP_GLM_AVAILABLE_MODELS Comma-separated list of advertised models",
39
39
  " ACP_GLM_BASE_URL Override the Z.AI API base URL",
40
40
  " ACP_GLM_MAX_TOKENS Per-call max output tokens (default 8192)",
@@ -1,6 +1,32 @@
1
1
  import type { ChatCompletionMessageParam } from "openai/resources/index.js";
2
2
  import type { ModelInfo, Usage } from "@agentclientprotocol/sdk";
3
3
  import { type ToolDefinition } from "../tools/definitions.js";
4
+ /**
5
+ * Reasoning effort levels exposed to ACP clients via the `thought_level`
6
+ * SessionConfigOption. These map onto Z.AI's `thinking` / `reasoning_effort`
7
+ * request parameters (see {@link buildThinkingParams}).
8
+ *
9
+ * GLM-5.2 supports three levels: `none`, `high`, `max`. Other thinking-capable
10
+ * models (GLM-5.1, 5-turbo, 4.7, …) only distinguish thinking on vs. off, so
11
+ * they use `none` and `on`.
12
+ */
13
+ export type ThoughtLevel = "none" | "on" | "high" | "max";
14
+ /** Type guard: whether an arbitrary string is a known ThoughtLevel. */
15
+ export declare function isThoughtLevel(value: string): value is ThoughtLevel;
16
+ /**
17
+ * Resolve which thought-level options a model supports.
18
+ *
19
+ * `reasoning_effort` is a GLM-5.2 exclusive per the Z.AI docs — other models
20
+ * accept the field but it has no effect, so we only expose high/max for 5.2.
21
+ */
22
+ export declare function getThoughtLevels(model: string): ThoughtLevel[];
23
+ /**
24
+ * Resolve a stored ThoughtLevel to one that's valid for the given model.
25
+ * Used when switching models or restoring a persisted session: if the old
26
+ * level isn't in the new model's option list, fall back to the model's
27
+ * default (max for 5.2, on for everything else — the last entry in the list).
28
+ */
29
+ export declare function resolveThoughtLevel(model: string, level: ThoughtLevel): ThoughtLevel;
4
30
  /**
5
31
  * A single message in the GLM conversation history.
6
32
  */
@@ -32,9 +58,11 @@ export interface StreamChatOptions {
32
58
  model: string;
33
59
  /** Tool schemas available in this specific session. */
34
60
  tools?: ToolDefinition[];
61
+ /** Reasoning effort for this call, or undefined to use the model defaults. */
62
+ reasoningEffort?: ThoughtLevel;
35
63
  }
36
64
  /** Default GLM model when neither client nor user has chosen one. */
37
- export declare const DEFAULT_MODEL = "glm-5.1";
65
+ export declare const DEFAULT_MODEL = "glm-5.2";
38
66
  /**
39
67
  * Z.AI / Zhipu AI error code returned when the total prompt length (messages +
40
68
  * tools) exceeds the model's context window.
@@ -74,4 +102,23 @@ export declare class GlmClient {
74
102
  */
75
103
  streamChat(messages: GlmMessage[], signal?: AbortSignal, options?: StreamChatOptions): AsyncGenerator<GlmStreamChunk>;
76
104
  }
105
+ /**
106
+ * Build the Z.AI `thinking` / `reasoning_effort` extra-body params for a call.
107
+ *
108
+ * Z.AI exposes two parameters:
109
+ * - `thinking` — an on/off gate: `{"type":"enabled"}` or `{"type":"disabled"}`
110
+ * - `reasoning_effort` — GLM-5.2 only; controls thinking depth (`high`/`max`,
111
+ * defaulting to `max` when omitted).
112
+ *
113
+ * {@link ThoughtLevel} values map as follows:
114
+ * - `none` → thinking disabled
115
+ * - `on` → thinking enabled (no reasoning_effort)
116
+ * - `high` → thinking enabled + reasoning_effort=high (5.2 only)
117
+ * - `max` → thinking enabled + reasoning_effort=max (5.2 only)
118
+ *
119
+ * The `ACP_GLM_THINKING` env override still wins: `false` forces thinking off,
120
+ * `true` forces it on (ignoring a `none` level). When `effort` is unset the
121
+ * model defaults are used, preserving the pre-thought-level behaviour.
122
+ */
123
+ export declare function buildThinkingParams(model: string, effort?: ThoughtLevel): Record<string, unknown>;
77
124
  //# sourceMappingURL=glm-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"glm-client.d.ts","sourceRoot":"","sources":["../../src/llm/glm-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAsB,MAAM,2BAA2B,CAAC;AAChG,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAoB,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAIhF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,0BAA0B,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,iCAAiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE;QACT,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,oDAAoD;IACpD,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,kCAAkC;IAClC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,4B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;AAED,uEAAuE;AACvE,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;;;;;;GAOG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAS;;IAgB1B;;;;;;OAMG;IACI,UAAU,CACf,QAAQ,EAAE,UAAU,EAAE,EACtB,MAAM,CAAC,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,cAAc,CAAC,cAAc,CAAC;CA0IlC;AA+BD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,YAAY,GACpB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAiCzB"}
@@ -2,10 +2,43 @@ import OpenAI from "openai";
2
2
  import { TOOL_DEFINITIONS } from "../tools/definitions.js";
3
3
  import { resolveApiKey } from "./credentials.js";
4
4
  import { debug, error } from "./logger.js";
5
+ /** Levels shown when the selected model is GLM-5.2. */
6
+ const LEVELS_52 = ["none", "high", "max"];
7
+ /** Levels shown for every other thinking-capable model. */
8
+ const LEVELS_DEFAULT = ["none", "on"];
9
+ /** Whether a model id is in the GLM-5.2 family (case-insensitive). */
10
+ function isGlm52(model) {
11
+ return model.toLowerCase().startsWith("glm-5.2");
12
+ }
13
+ /** The complete set of thought levels the agent understands. */
14
+ const ALL_THOUGHT_LEVELS = ["none", "on", "high", "max"];
15
+ /** Type guard: whether an arbitrary string is a known ThoughtLevel. */
16
+ export function isThoughtLevel(value) {
17
+ return ALL_THOUGHT_LEVELS.includes(value);
18
+ }
19
+ /**
20
+ * Resolve which thought-level options a model supports.
21
+ *
22
+ * `reasoning_effort` is a GLM-5.2 exclusive per the Z.AI docs — other models
23
+ * accept the field but it has no effect, so we only expose high/max for 5.2.
24
+ */
25
+ export function getThoughtLevels(model) {
26
+ return isGlm52(model) ? LEVELS_52 : LEVELS_DEFAULT;
27
+ }
28
+ /**
29
+ * Resolve a stored ThoughtLevel to one that's valid for the given model.
30
+ * Used when switching models or restoring a persisted session: if the old
31
+ * level isn't in the new model's option list, fall back to the model's
32
+ * default (max for 5.2, on for everything else — the last entry in the list).
33
+ */
34
+ export function resolveThoughtLevel(model, level) {
35
+ const valid = getThoughtLevels(model);
36
+ return valid.includes(level) ? level : valid[valid.length - 1];
37
+ }
5
38
  /** Default base URL for the Z.AI / Zhipu OpenAI-compatible API (Coding endpoint). */
6
39
  const DEFAULT_BASE_URL = "https://api.z.ai/api/coding/paas/v4";
7
40
  /** Default GLM model when neither client nor user has chosen one. */
8
- export const DEFAULT_MODEL = "glm-5.1";
41
+ export const DEFAULT_MODEL = "glm-5.2";
9
42
  /**
10
43
  * Curated list of GLM models the agent advertises to ACP clients via
11
44
  * `SessionModelState.availableModels`. Users can override this list via the
@@ -15,10 +48,15 @@ export const DEFAULT_MODEL = "glm-5.1";
15
48
  * model pickers.
16
49
  */
17
50
  const BUILTIN_AVAILABLE_MODELS = [
51
+ {
52
+ modelId: "glm-5.2",
53
+ name: "GLM-5.2",
54
+ description: "Newest 1M-context coding model with thinking mode",
55
+ },
18
56
  {
19
57
  modelId: "glm-5.1",
20
58
  name: "GLM-5.1",
21
- description: "Latest GLM reasoning model with thinking mode",
59
+ description: "Long-horizon coding model with thinking mode",
22
60
  },
23
61
  {
24
62
  modelId: "glm-5-turbo",
@@ -50,6 +88,7 @@ export const ERR_CONTEXT_OVERFLOW = 1261;
50
88
  * Context window sizes (in tokens) for GLM series models.
51
89
  */
52
90
  const MODEL_METADATA = {
91
+ "glm-5.2": { contextWindow: 1_000_000 },
53
92
  "glm-5.1": { contextWindow: 128_000 },
54
93
  "glm-5-turbo": { contextWindow: 128_000 },
55
94
  "glm-5v-turbo": { contextWindow: 200_000 },
@@ -120,7 +159,7 @@ export class GlmClient {
120
159
  */
121
160
  async *streamChat(messages, signal, options) {
122
161
  const model = options?.model ?? getDefaultModel();
123
- const thinkingEnabled = parseThinking(model);
162
+ const thinkingParams = buildThinkingParams(model, options?.reasoningEffort);
124
163
  const tools = (options?.tools ?? TOOL_DEFINITIONS).map((t) => ({
125
164
  type: "function",
126
165
  function: {
@@ -129,13 +168,10 @@ export class GlmClient {
129
168
  parameters: t.function.parameters,
130
169
  },
131
170
  }));
132
- debug(`streamChat: model=${model} baseURL=${this.client.baseURL} messages=${messages.length} tools=${tools.length} thinking=${thinkingEnabled}`);
171
+ debug(`streamChat: model=${model} baseURL=${this.client.baseURL} messages=${messages.length} tools=${tools.length} thinking=${JSON.stringify(thinkingParams)}`);
133
172
  // The OpenAI SDK forwards unknown extra body fields verbatim, so we use
134
- // that to pass GLM-specific fields like `thinking`.
135
- const extraBody = {};
136
- if (thinkingEnabled) {
137
- extraBody["thinking"] = { type: "enabled" };
138
- }
173
+ // that to pass GLM-specific fields like `thinking` and `reasoning_effort`.
174
+ const extraBody = { ...thinkingParams };
139
175
  let stream;
140
176
  try {
141
177
  stream = await this.client.chat.completions.create({
@@ -233,17 +269,69 @@ function parseIntEnv(name, fallback) {
233
269
  return Number.isFinite(n) && n > 0 ? n : fallback;
234
270
  }
235
271
  /**
236
- * Decide whether to enable GLM "thinking" mode for a given model name.
237
- *
238
- * The user can force on/off via `ACP_GLM_THINKING=true|false`. Otherwise,
239
- * we enable thinking for any model whose name suggests it supports it
272
+ * Decide whether a model supports GLM "thinking" mode based on its name
240
273
  * (the GLM-4.5 / GLM-4.6 / GLM-4.7 / GLM-5.x families).
241
274
  */
242
- function parseThinking(model) {
275
+ function modelSupportsThinking(model) {
276
+ return /^glm-(?:4\.[567]|5)/i.test(model);
277
+ }
278
+ /**
279
+ * Parse the `ACP_GLM_THINKING` env override into an explicit boolean, or
280
+ * `undefined` when the variable is unset. `true`/`1` force thinking on;
281
+ * anything else forces it off.
282
+ */
283
+ function thinkingOverride() {
243
284
  const override = process.env["ACP_GLM_THINKING"];
244
285
  if (override !== undefined) {
245
286
  return override.toLowerCase() === "true" || override === "1";
246
287
  }
247
- return /^glm-(?:4\.[567]|5)/i.test(model);
288
+ return undefined;
289
+ }
290
+ /**
291
+ * Build the Z.AI `thinking` / `reasoning_effort` extra-body params for a call.
292
+ *
293
+ * Z.AI exposes two parameters:
294
+ * - `thinking` — an on/off gate: `{"type":"enabled"}` or `{"type":"disabled"}`
295
+ * - `reasoning_effort` — GLM-5.2 only; controls thinking depth (`high`/`max`,
296
+ * defaulting to `max` when omitted).
297
+ *
298
+ * {@link ThoughtLevel} values map as follows:
299
+ * - `none` → thinking disabled
300
+ * - `on` → thinking enabled (no reasoning_effort)
301
+ * - `high` → thinking enabled + reasoning_effort=high (5.2 only)
302
+ * - `max` → thinking enabled + reasoning_effort=max (5.2 only)
303
+ *
304
+ * The `ACP_GLM_THINKING` env override still wins: `false` forces thinking off,
305
+ * `true` forces it on (ignoring a `none` level). When `effort` is unset the
306
+ * model defaults are used, preserving the pre-thought-level behaviour.
307
+ */
308
+ export function buildThinkingParams(model, effort) {
309
+ const params = {};
310
+ const override = thinkingOverride();
311
+ const modelCanThink = modelSupportsThinking(model);
312
+ // Explicit env override to disable wins over everything.
313
+ if (override === false) {
314
+ if (modelCanThink)
315
+ params["thinking"] = { type: "disabled" };
316
+ return params;
317
+ }
318
+ const canThink = override === true || modelCanThink;
319
+ // A `none` level disables thinking, unless the env override forces it on.
320
+ if (effort === "none" && override !== true) {
321
+ if (canThink)
322
+ params["thinking"] = { type: "disabled" };
323
+ return params;
324
+ }
325
+ if (!canThink)
326
+ return params;
327
+ params["thinking"] = { type: "enabled" };
328
+ // reasoning_effort is only meaningful for GLM-5.2 per the Z.AI docs, and Z.AI
329
+ // only accepts the "high"/"max" values there. Other levels ("on", and "none"
330
+ // when thinking is force-enabled via the env override) carry no valid
331
+ // reasoning_effort, so we omit the field entirely.
332
+ if ((effort === "high" || effort === "max") && isGlm52(model)) {
333
+ params["reasoning_effort"] = effort;
334
+ }
335
+ return params;
248
336
  }
249
337
  //# sourceMappingURL=glm-client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"glm-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AS,CAAC;AACnB,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAa,EACb,MAAqB;IAErB,MAAM,MAAM,GAA4B,EAAE,CAAC;IAE3C,MAAM,QAAQ,GAAG,gBAAgB,EAAE,CAAC;IACpC,MAAM,aAAa,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAEnD,yDAAyD;IACzD,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;QACvB,IAAI,aAAa;YAAE,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;QAC7D,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,QAAQ,GAAG,QAAQ,KAAK,IAAI,IAAI,aAAa,CAAC;IAEpD,0EAA0E;IAC1E,IAAI,MAAM,KAAK,MAAM,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QAC3C,IAAI,QAAQ;YAAE,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;QACxD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,CAAC,QAAQ;QAAE,OAAO,MAAM,CAAC;IAE7B,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IAEzC,8EAA8E;IAC9E,6EAA6E;IAC7E,sEAAsE;IACtE,mDAAmD;IACnD,IAAI,CAAC,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,KAAK,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9D,MAAM,CAAC,kBAAkB,CAAC,GAAG,MAAM,CAAC;IACtC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { Agent, AgentSideConnection, InitializeRequest, InitializeResponse, NewSessionRequest, NewSessionResponse, PromptRequest, PromptResponse, CancelNotification, AuthenticateRequest, AuthenticateResponse, SetSessionModeRequest, SetSessionModeResponse, CloseSessionRequest, ListSessionsRequest, ListSessionsResponse, LoadSessionRequest, LoadSessionResponse, ForkSessionRequest, ForkSessionResponse, ResumeSessionRequest, ResumeSessionResponse, SetSessionModelRequest, SetSessionModelResponse } from "@agentclientprotocol/sdk";
1
+ import type { Agent, AgentSideConnection, InitializeRequest, InitializeResponse, NewSessionRequest, NewSessionResponse, PromptRequest, PromptResponse, CancelNotification, AuthenticateRequest, AuthenticateResponse, SetSessionModeRequest, SetSessionModeResponse, CloseSessionRequest, ListSessionsRequest, ListSessionsResponse, LoadSessionRequest, LoadSessionResponse, ForkSessionRequest, ForkSessionResponse, ResumeSessionRequest, ResumeSessionResponse, SetSessionModelRequest, SetSessionModelResponse, SetSessionConfigOptionRequest, SetSessionConfigOptionResponse } from "@agentclientprotocol/sdk";
2
2
  import { type GlmMessage, type GlmStreamChunk, type StreamChatOptions } from "../llm/glm-client.js";
3
3
  import { SessionStore } from "./session-store.js";
4
4
  import { type VisionMcpClient } from "../tools/vision-mcp-client.js";
@@ -55,6 +55,12 @@ export declare class GlmAcpAgent implements Agent {
55
55
  authenticate(params: AuthenticateRequest): Promise<AuthenticateResponse>;
56
56
  newSession(params: NewSessionRequest): Promise<NewSessionResponse>;
57
57
  unstable_setSessionModel(params: SetSessionModelRequest): Promise<SetSessionModelResponse>;
58
+ /**
59
+ * Build the `thought_level` SessionConfigOption for the given model. The
60
+ * available levels depend on the model (see {@link getThoughtLevels}).
61
+ */
62
+ private configOptionsState;
63
+ setSessionConfigOption(params: SetSessionConfigOptionRequest): Promise<SetSessionConfigOptionResponse>;
58
64
  /** Build the SessionModelState we advertise on session create/load/resume/fork. */
59
65
  private modelsState;
60
66
  /** Build the SessionModeState we advertise on session create/load/resume/fork. */
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/protocol/agent.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,KAAK,EACL,mBAAmB,EAEnB,iBAA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I,CAAC;IAKjD,YAAY,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAaxD,YAAY,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAqDxE,WAAW,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAmCrE,oBAAoB,CACxB,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,mBAAmB,CAAC;IAoCzB,aAAa,CACjB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,qBAAqB,CAAC;IAkCjC,OAAO,CAAC,QAAQ;IAahB,OAAO,CAAC,cAAc;IAYtB,OAAO,CAAC,gBAAgB;YAWV,cAAc;IAiD5B;;;;OAIG;YACW,aAAa;IA2J3B,OAAO,CAAC,aAAa;IAiBrB,iFAAiF;IACjF,OAAO,CAAC,wBAAwB;CAWjC"}
@@ -2,7 +2,7 @@ import { randomUUID } from "node:crypto";
2
2
  import { readFileSync } from "node:fs";
3
3
  import { join as pathJoin } from "node:path";
4
4
  import { PROTOCOL_VERSION as VERSION } from "@agentclientprotocol/sdk";
5
- import { GlmClient, getAvailableModels, getDefaultModel, getContextWindow, isVisionNativeModel, ERR_CONTEXT_OVERFLOW, } from "../llm/glm-client.js";
5
+ import { GlmClient, getAvailableModels, getDefaultModel, getContextWindow, isVisionNativeModel, ERR_CONTEXT_OVERFLOW, getThoughtLevels, resolveThoughtLevel, isThoughtLevel, } from "../llm/glm-client.js";
6
6
  import { ToolExecutor } from "../tools/executor.js";
7
7
  import { TOOL_DEFINITIONS } from "../tools/definitions.js";
8
8
  import { connectSessionMcpServers } from "../tools/session-mcp-client.js";
@@ -157,6 +157,10 @@ export class GlmAcpAgent {
157
157
  }),
158
158
  };
159
159
  const model = getDefaultModel();
160
+ // Default to the model's own default effort ("max" for 5.2, "on"
161
+ // otherwise) so out-of-the-box behaviour matches the pre-thought-level
162
+ // default (thinking on, no explicit reasoning_effort).
163
+ const thoughtLevel = resolveThoughtLevel(model, "max");
160
164
  this.sessions.set(sessionId, {
161
165
  cwd: params.cwd,
162
166
  messages: [systemPrompt],
@@ -168,11 +172,13 @@ export class GlmAcpAgent {
168
172
  toolDefinitions,
169
173
  mcpTools,
170
174
  mode: "default",
175
+ thoughtLevel,
171
176
  });
172
177
  return {
173
178
  sessionId,
174
179
  models: this.modelsState(model),
175
180
  modes: this.modesState("default"),
181
+ configOptions: this.configOptionsState(model, thoughtLevel),
176
182
  };
177
183
  }
178
184
  async unstable_setSessionModel(params) {
@@ -188,7 +194,14 @@ export class GlmAcpAgent {
188
194
  process.stderr.write(`[glm-acp-agent] warning: model "${params.modelId}" is not in the advertised list; using as-is.\n`);
189
195
  }
190
196
  session.model = params.modelId;
197
+ // The valid thought levels differ per model (e.g. 5.2 offers high/max
198
+ // while others only offer none/on), so clamp the current level to what
199
+ // the new model supports.
200
+ session.thoughtLevel = resolveThoughtLevel(params.modelId, session.thoughtLevel);
191
201
  session.updatedAt = new Date().toISOString();
202
+ // Persist immediately so a fork/reload before the next prompt doesn't
203
+ // resurrect the previous model or thought level (matches setSessionConfigOption).
204
+ this.persistSession(params.sessionId, session);
192
205
  // Notify clients so any UI that displays the active model refreshes
193
206
  // immediately, instead of waiting for the next prompt to complete.
194
207
  await safeSessionUpdate(this.connection, {
@@ -198,8 +211,66 @@ export class GlmAcpAgent {
198
211
  updatedAt: session.updatedAt,
199
212
  },
200
213
  });
214
+ // Push updated thought_level options — the set of valid levels may
215
+ // differ between models (e.g. switching from 5.2 to 4.7 drops "high").
216
+ await safeSessionUpdate(this.connection, {
217
+ sessionId: params.sessionId,
218
+ update: {
219
+ sessionUpdate: "config_option_update",
220
+ configOptions: this.configOptionsState(session.model, session.thoughtLevel),
221
+ },
222
+ });
201
223
  return {};
202
224
  }
225
+ /**
226
+ * Build the `thought_level` SessionConfigOption for the given model. The
227
+ * available levels depend on the model (see {@link getThoughtLevels}).
228
+ */
229
+ configOptionsState(model, thoughtLevel) {
230
+ const levels = getThoughtLevels(model);
231
+ return [
232
+ {
233
+ id: "thought_level",
234
+ name: "Thinking",
235
+ description: "Reasoning effort",
236
+ category: "thought_level",
237
+ type: "select",
238
+ currentValue: thoughtLevel,
239
+ options: levels.map((level) => ({
240
+ value: level,
241
+ name: level === "none"
242
+ ? "Off"
243
+ : level === "on"
244
+ ? "On"
245
+ : level.charAt(0).toUpperCase() + level.slice(1),
246
+ })),
247
+ },
248
+ ];
249
+ }
250
+ async setSessionConfigOption(params) {
251
+ const session = this.sessions.get(params.sessionId);
252
+ if (!session) {
253
+ throw new Error(`Session not found: ${params.sessionId}`);
254
+ }
255
+ if (params.configId !== "thought_level") {
256
+ throw new Error(`Unknown config option: ${params.configId}`);
257
+ }
258
+ // Reject values that aren't a thought level at all (typos, stale ids from
259
+ // another agent version) rather than silently coercing them.
260
+ if (typeof params.value !== "string" || !isThoughtLevel(params.value)) {
261
+ throw new Error(`Invalid thought_level value: ${String(params.value)}`);
262
+ }
263
+ // Auto-resolve a *known* level that isn't valid for the current model to
264
+ // that model's default. This happens when a client caches a thoughtLevel
265
+ // from a previous session (or model) and re-sends it for a model with a
266
+ // different level set (e.g. "max" from glm-5.2 sent while on glm-4.7).
267
+ session.thoughtLevel = resolveThoughtLevel(session.model, params.value);
268
+ session.updatedAt = new Date().toISOString();
269
+ this.persistSession(params.sessionId, session);
270
+ return {
271
+ configOptions: this.configOptionsState(session.model, session.thoughtLevel),
272
+ };
273
+ }
203
274
  /** Build the SessionModelState we advertise on session create/load/resume/fork. */
204
275
  modelsState(currentModelId) {
205
276
  return {
@@ -453,6 +524,7 @@ export class GlmAcpAgent {
453
524
  toolDefinitions,
454
525
  mcpTools,
455
526
  mode: persisted.mode,
527
+ thoughtLevel: resolveThoughtLevel(persisted.model, persisted.thoughtLevel ?? "max"),
456
528
  };
457
529
  this.sessions.set(params.sessionId, restored);
458
530
  // Replay user/assistant text turns so the client can rehydrate its UI.
@@ -462,6 +534,7 @@ export class GlmAcpAgent {
462
534
  return {
463
535
  models: this.modelsState(persisted.model),
464
536
  modes: this.modesState(persisted.mode),
537
+ configOptions: this.configOptionsState(restored.model, restored.thoughtLevel),
465
538
  };
466
539
  }
467
540
  async unstable_forkSession(params) {
@@ -485,6 +558,7 @@ export class GlmAcpAgent {
485
558
  toolDefinitions,
486
559
  mcpTools,
487
560
  mode: persisted.mode,
561
+ thoughtLevel: resolveThoughtLevel(persisted.model, persisted.thoughtLevel ?? "max"),
488
562
  };
489
563
  this.sessions.set(newSessionId, forked);
490
564
  this.persistSession(newSessionId, forked);
@@ -492,6 +566,7 @@ export class GlmAcpAgent {
492
566
  sessionId: newSessionId,
493
567
  models: this.modelsState(forked.model),
494
568
  modes: this.modesState(forked.mode),
569
+ configOptions: this.configOptionsState(forked.model, forked.thoughtLevel),
495
570
  };
496
571
  }
497
572
  async resumeSession(params) {
@@ -510,6 +585,7 @@ export class GlmAcpAgent {
510
585
  toolDefinitions,
511
586
  mcpTools,
512
587
  mode: persisted.mode,
588
+ thoughtLevel: resolveThoughtLevel(persisted.model, persisted.thoughtLevel ?? "max"),
513
589
  };
514
590
  this.sessions.set(params.sessionId, restored);
515
591
  // Resume does NOT replay history — the client keeps its own UI state and
@@ -517,6 +593,7 @@ export class GlmAcpAgent {
517
593
  return {
518
594
  models: this.modelsState(persisted.model),
519
595
  modes: this.modesState(persisted.mode),
596
+ configOptions: this.configOptionsState(restored.model, restored.thoughtLevel),
520
597
  };
521
598
  }
522
599
  // ---------------------------------------------------------------------------
@@ -531,6 +608,7 @@ export class GlmAcpAgent {
531
608
  updatedAt: session.updatedAt,
532
609
  model: session.model,
533
610
  mode: session.mode,
611
+ thoughtLevel: session.thoughtLevel,
534
612
  };
535
613
  }
536
614
  persistSession(sessionId, session) {
@@ -628,6 +706,7 @@ export class GlmAcpAgent {
628
706
  for await (const chunk of this.glm.streamChat(session.messages, signal, {
629
707
  model: session.model,
630
708
  tools: session.toolDefinitions,
709
+ reasoningEffort: session.thoughtLevel,
631
710
  })) {
632
711
  if (signal.aborted)
633
712
  return { stopReason: "cancelled" };