@ai-zen/agents-sdk 1.0.0-alpha.0 → 1.0.0-alpha.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.0.0-alpha.1] - 2026-10-03
4
+
5
+ ### 💥 Breaking Changes
6
+
7
+ - **Factory model catalog refreshed (verified against vendor sources on 2026-10-03)** — every stale or retired model ID in `DEFAULT_APP_CONFIG.models` is replaced:
8
+ - **OpenAI**: `gpt-5.5` → `gpt-6-astra` / `gpt-6.1-sol` / `gpt-6-luna`
9
+ - **Zhipu**: `glm-5.1` / `glm-5v-turbo` → `glm-5.3` / `glm-5.3-flash` / `glm-5.3-flashx`
10
+ - **DeepSeek**: `deepseek-v4-pro` / `deepseek-v4-flash` / `deepseek-v4-flash-vision-exp` → `deepseek-flash`. The two V4-Flash variants were retired by the vendor, and V4-Pro requests are routed to V4.1-Flash.
11
+ - Defaults: `defaultModel` / `defaultMigrationModel` move from `deepseek-v4-flash` to `deepseek-flash`.
12
+ - **`Model.maxContextTokens` semantics clarified — it is the task-migration (handoff) trigger threshold, not the model context window** — `AutoMigratePlugin` does not estimate or learn: it only compares `usage.prompt_tokens` from the API response against this value. The previous comment read "上下文窗口 token 上限" ("context window token limit"), which is why values had been filled in with raw window sizes. Values are now ~25% of the real window (250K for ≥1M-window models), except `glm-4.7-flash` (200K window) which uses 100K.
13
+
14
+ ### 🚀 New Features
15
+
16
+ - **Managed model catalog sync (`custom` opt-out)** — `ConfigManager.ensureDefaultConfig()` now reconciles the factory catalog on every `bootstrap()`. Entries in `models` / `imageModels` that do **not** carry `custom: true` are dropped and replaced by the latest `DEFAULT_APP_CONFIG` definitions; entries marked `custom: true` are treated as user-owned and kept verbatim (user wins on id collision, no duplicates). A dangling `defaultModel` / `defaultImageModel` / `defaultMigrationModel` falls back to the factory default, so no reference is ever left pointing at a removed model. `endpoints` are never managed. The sync is idempotent — it only writes when something actually changed. Implemented in `ConfigManager.syncManagedModels`.
17
+ - **`Model` / `ImageModel` gained an optional `custom?: boolean` field** — marks an entry as user-owned so the factory sync leaves it untouched.
18
+
19
+ ### ✅ Tests
20
+
21
+ - Added coverage for the model catalog sync: stale non-custom entries replaced, `custom: true` entries preserved, user version winning on id collision without duplication, image models reconciled, dangling default IDs falling back, and idempotency across repeated calls.
22
+ - E2E model IDs updated to the current vendor names (`deepseek-flash`).
23
+
24
+ ### 📄 Docs
25
+
26
+ - Current-version references in `docs/zh` and `docs/en` updated to `1.0.0-alpha.1`.
27
+ - `DEFAULT_APP_CONFIG` row in `sdk-design-v0.md` updated to the new model catalog.
28
+
3
29
  ## [1.0.0-alpha.0] - 2026-09-30
4
30
 
5
31
  ### 💥 Breaking Changes
@@ -18,6 +18,11 @@ export declare class ConfigManager {
18
18
  ensureDirs(): Promise<void>;
19
19
  /**
20
20
  * 确保 config.json 存在。不存在时写入出厂默认配置 DSL。
21
+ *
22
+ * 已存在时执行「出厂模型清单同步」(见 syncManagedModels):
23
+ * models / imageModels 中凡是**没有** `custom: true` 的条目一律视为出厂托管,
24
+ * 会被移除并替换为 DEFAULT_APP_CONFIG 中的最新定义;标了 `custom: true` 的
25
+ * 条目视为用户自有,原样保留。同步结果与磁盘内容一致时不写盘。
21
26
  */
22
27
  ensureDefaultConfig(): Promise<AppConfig>;
23
28
  /**
@@ -70,4 +75,16 @@ export declare class ConfigManager {
70
75
  /** 原子写 JSON 文件(先写 .tmp 再 rename,避免半成品)。 */
71
76
  private writeJson;
72
77
  }
78
+ /**
79
+ * 同步出厂托管的模型清单(与默认 Agent 的 custom 机制一致)。
80
+ *
81
+ * 规则:
82
+ * - 未标 `custom: true` 的条目 → 由 SDK 托管,从结果中移除,改用 defaults 中的最新定义;
83
+ * - 标了 `custom: true` 的条目 → 用户自有,原样保留;与出厂定义同 id 时用户版本优先;
84
+ * - 默认模型 ID(defaultModel / defaultImageModel / defaultMigrationModel)
85
+ * 在合并后若已不存在 → 回退到出厂默认,避免悬空引用。
86
+ *
87
+ * 端点(endpoints)不参与托管,始终保持用户配置。
88
+ */
89
+ export declare function syncManagedModels(config: AppConfig): AppConfig;
73
90
  export { DEFAULT_AGENT_ID, DEFAULT_AGENT_DEFINITION, DEFAULT_SUBAGENT_ID, DEFAULT_SUBAGENT_DEFINITION, DEFAULT_APP_CONFIG, DEFAULT_MCP_CONFIG, CONFIG_SUB_DIRS, } from "./constants.js";
@@ -54,17 +54,28 @@ export class ConfigManager {
54
54
  }
55
55
  /**
56
56
  * 确保 config.json 存在。不存在时写入出厂默认配置 DSL。
57
+ *
58
+ * 已存在时执行「出厂模型清单同步」(见 syncManagedModels):
59
+ * models / imageModels 中凡是**没有** `custom: true` 的条目一律视为出厂托管,
60
+ * 会被移除并替换为 DEFAULT_APP_CONFIG 中的最新定义;标了 `custom: true` 的
61
+ * 条目视为用户自有,原样保留。同步结果与磁盘内容一致时不写盘。
57
62
  */
58
63
  async ensureDefaultConfig() {
64
+ let existing;
59
65
  try {
60
66
  await fs.access(this.configPath);
61
- return await this.read();
67
+ existing = await this.read();
62
68
  }
63
69
  catch {
64
70
  await this.ensureDirs();
65
71
  await this.write(DEFAULT_APP_CONFIG);
66
72
  return { ...DEFAULT_APP_CONFIG };
67
73
  }
74
+ const synced = syncManagedModels(existing);
75
+ if (JSON.stringify(synced) !== JSON.stringify(existing)) {
76
+ await this.write(synced);
77
+ }
78
+ return synced;
68
79
  }
69
80
  /**
70
81
  * 确保 basePath/agents/default.json 存在。
@@ -234,6 +245,38 @@ export class ConfigManager {
234
245
  await fs.rename(tmpPath, path);
235
246
  }
236
247
  }
248
+ /**
249
+ * 同步出厂托管的模型清单(与默认 Agent 的 custom 机制一致)。
250
+ *
251
+ * 规则:
252
+ * - 未标 `custom: true` 的条目 → 由 SDK 托管,从结果中移除,改用 defaults 中的最新定义;
253
+ * - 标了 `custom: true` 的条目 → 用户自有,原样保留;与出厂定义同 id 时用户版本优先;
254
+ * - 默认模型 ID(defaultModel / defaultImageModel / defaultMigrationModel)
255
+ * 在合并后若已不存在 → 回退到出厂默认,避免悬空引用。
256
+ *
257
+ * 端点(endpoints)不参与托管,始终保持用户配置。
258
+ */
259
+ export function syncManagedModels(config) {
260
+ const pick = (existing, defaults) => {
261
+ const kept = (existing ?? []).filter((m) => m.custom === true);
262
+ const keptIds = new Set(kept.map((m) => m.id));
263
+ // 出厂定义在前,用户自有条目随后;同 id 时用户版本胜出(出厂侧已剔除)
264
+ return [...defaults.filter((m) => !keptIds.has(m.id)), ...kept];
265
+ };
266
+ const models = pick(config.models, DEFAULT_APP_CONFIG.models);
267
+ const imageModels = pick(config.imageModels, DEFAULT_APP_CONFIG.imageModels ?? []);
268
+ const modelIds = new Set(models.map((m) => m.id));
269
+ const imageIds = new Set(imageModels.map((m) => m.id));
270
+ const resolve = (id, ids, fallback) => id && ids.has(id) ? id : fallback;
271
+ return {
272
+ ...config,
273
+ models,
274
+ imageModels,
275
+ defaultModel: resolve(config.defaultModel, modelIds, DEFAULT_APP_CONFIG.defaultModel),
276
+ defaultImageModel: resolve(config.defaultImageModel, imageIds, DEFAULT_APP_CONFIG.defaultImageModel),
277
+ defaultMigrationModel: resolve(config.defaultMigrationModel, modelIds, DEFAULT_APP_CONFIG.defaultMigrationModel),
278
+ };
279
+ }
237
280
  /**
238
281
  * 比较两段消息列表的提示词内容是否一致。
239
282
  *
@@ -85,71 +85,101 @@ export const DEFAULT_APP_CONFIG = {
85
85
  description: "DeepSeek API 端点",
86
86
  },
87
87
  ],
88
+ // 模型清单(2026-10-03 依据各厂商官方来源核对):
89
+ // OpenAI → openai.com 发布公告 / API 目录(platform 文档站对脚本有访问限制)
90
+ // 智谱 → docs.bigmodel.cn 模型概览/定价 + open.bigmodel.cn/api/paas/v4/models
91
+ // DeepSeek → api-docs.deepseek.com 定价页与 News + api.deepseek.com/v1/models
92
+ //
93
+ // 更新策略:本清单为「出厂托管」清单。用户 config.json 中凡未标 `custom: true`
94
+ // 的模型(含 imageModels)在初始化时一律被移除并替换为本清单中的最新定义;
95
+ // 标了 `custom: true` 的条目视为用户自有,原样保留。实现见
96
+ // ConfigManager.syncManagedModels。
97
+ //
98
+ // maxContextTokens 是「任务迁移(交接)触发阈值」,不是模型的真实上下文窗口:
99
+ // 迁移判断只看 API 响应返回的 usage.prompt_tokens。窗口 ≥1M 的模型统一取 250K
100
+ // (约 25%),glm-4.7-flash 窗口仅 200K,取 100K。
88
101
  models: [
102
+ // ---------- OpenAI ----------
89
103
  {
90
- id: "gpt-5.5",
91
- name: "GPT-5.5",
104
+ id: "gpt-6-astra",
105
+ name: "GPT-6 Astra",
92
106
  endpointId: "openai",
93
- modelName: "gpt-5.5",
107
+ modelName: "gpt-6-astra",
94
108
  maxContextTokens: 250_000,
95
109
  defaultParams: {},
96
- description: "OpenAI 最新旗舰模型,擅长编程与代码调试、在线研究、数据分析",
110
+ vision: true,
111
+ description: "OpenAI 最强旗舰(2026-09):高级分析、软件工程、深度研究与科学工作",
97
112
  },
98
113
  {
99
- id: "glm-5.1",
100
- name: "GLM-5.1",
101
- endpointId: "bigmodelcn",
102
- modelName: "glm-5.1",
114
+ id: "gpt-6.1-sol",
115
+ name: "GPT-6.1 Sol",
116
+ endpointId: "openai",
117
+ modelName: "gpt-6.1-sol",
103
118
  maxContextTokens: 250_000,
104
119
  defaultParams: {},
105
- description: "智谱AI 最新旗舰模型,支持8小时长程Agent任务",
120
+ vision: true,
121
+ description: "OpenAI 最新旗舰(2026-09-29):Agentic Coding、计算机操作与文档密集型专业任务",
106
122
  },
107
123
  {
108
- id: "glm-5v-turbo",
109
- name: "GLM-5V-Turbo",
110
- endpointId: "bigmodelcn",
111
- modelName: "glm-5v-turbo",
124
+ id: "gpt-6-luna",
125
+ name: "GPT-6 Luna",
126
+ endpointId: "openai",
127
+ modelName: "gpt-6-luna",
112
128
  maxContextTokens: 250_000,
113
129
  defaultParams: {},
114
130
  vision: true,
115
- description: "智谱AI 多模态Coding基座(支持图片输入)",
131
+ description: "OpenAI GPT-6 系列快速低成本模型:适合高吞吐、低延迟场景",
116
132
  },
133
+ // ---------- 智谱 BigModel ----------
117
134
  {
118
- id: "glm-4.7-flash",
119
- name: "GLM-4.7-Flash",
135
+ id: "glm-5.3",
136
+ name: "GLM-5.3",
120
137
  endpointId: "bigmodelcn",
121
- modelName: "glm-4.7-flash",
138
+ modelName: "glm-5.3",
122
139
  maxContextTokens: 250_000,
123
- defaultParams: {},
124
- description: "智谱AI 免费轻量模型",
140
+ defaultParams: { thinking: { type: "enabled" }, reasoning_effort: "max" },
141
+ description: "智谱最新旗舰:复杂软件工程与长程 Agent 任务(强制开启思考,1M 上下文)",
125
142
  },
126
143
  {
127
- id: "deepseek-v4-pro",
128
- name: "DeepSeek-V4-Pro",
129
- endpointId: "deepseek",
130
- modelName: "deepseek-v4-pro",
144
+ id: "glm-5.3-flash",
145
+ name: "GLM-5.3-Flash",
146
+ endpointId: "bigmodelcn",
147
+ modelName: "glm-5.3-flash",
131
148
  maxContextTokens: 250_000,
132
- defaultParams: { thinking: { type: "disabled" } },
133
- description: "DeepSeek 旗舰模型,Agentic Coding开源第一",
149
+ defaultParams: { thinking: { type: "enabled" }, reasoning_effort: "max" },
150
+ vision: true,
151
+ description: "智谱原生多模态模型(图片/视频/文件):视觉 Coding,1M 上下文",
134
152
  },
135
153
  {
136
- id: "deepseek-v4-flash",
137
- name: "DeepSeek-V4-Flash",
138
- endpointId: "deepseek",
139
- modelName: "deepseek-v4-flash",
154
+ id: "glm-5.3-flashx",
155
+ name: "GLM-5.3-FlashX",
156
+ endpointId: "bigmodelcn",
157
+ modelName: "glm-5.3-flashx",
140
158
  maxContextTokens: 250_000,
141
- defaultParams: { thinking: { type: "enabled" } },
142
- description: "DeepSeek 经济高效模型",
159
+ defaultParams: { thinking: { type: "enabled" }, reasoning_effort: "max" },
160
+ vision: true,
161
+ description: "GLM-5.3-Flash 高速版(200 tokens/s),原生多模态",
162
+ },
163
+ {
164
+ id: "glm-4.7-flash",
165
+ name: "GLM-4.7-Flash",
166
+ endpointId: "bigmodelcn",
167
+ modelName: "glm-4.7-flash",
168
+ // 该模型真实窗口仅 200K,阈值下调至 100K(约窗口的 50%),留足 response 空间
169
+ maxContextTokens: 100_000,
170
+ defaultParams: {},
171
+ description: "智谱免费文本模型:200K 上下文,适合轻量任务",
143
172
  },
173
+ // ---------- DeepSeek ----------
144
174
  {
145
- id: "deepseek-v4-flash-vision-exp",
146
- name: "DeepSeek-V4-Flash-Vision-Exp",
175
+ id: "deepseek-flash",
176
+ name: "DeepSeek-V4.1-Flash",
147
177
  endpointId: "deepseek",
148
- modelName: "deepseek-v4-flash-vision-exp",
178
+ modelName: "deepseek-flash",
149
179
  maxContextTokens: 250_000,
150
180
  defaultParams: { thinking: { type: "enabled" } },
151
181
  vision: true,
152
- description: "DeepSeek 视觉实验模型(支持图片/文件输入)",
182
+ description: "DeepSeek 旗舰(2026-09-10):552B MoE 非对称架构,原生多模态,1M 上下文",
153
183
  },
154
184
  ],
155
185
  imageModels: [
@@ -176,10 +206,10 @@ export const DEFAULT_APP_CONFIG = {
176
206
  defaultSize: "1024x1024",
177
207
  },
178
208
  ],
179
- defaultModel: "deepseek-v4-flash",
209
+ defaultModel: "deepseek-flash",
180
210
  defaultImageModel: "cogview-4",
181
211
  defaultAgent: "default",
182
- defaultMigrationModel: "deepseek-v4-flash",
212
+ defaultMigrationModel: "deepseek-flash",
183
213
  // 工具输出上限(字符数),与 DEFAULT_MAX_TOOL_OUTPUT 保持一致
184
214
  maxToolOutput: 32_768,
185
215
  };
@@ -26,13 +26,27 @@ export interface Model {
26
26
  name: string;
27
27
  endpointId: string;
28
28
  modelName?: string;
29
+ /**
30
+ * 任务迁移(交接)触发阈值 —— **不是**模型的真实上下文窗口。
31
+ *
32
+ * AutoMigratePlugin 不估算、不学习:只在 API 响应返回后,用 `usage.prompt_tokens`
33
+ * 与该值比较,超过即触发交接迁移。建议取模型真实窗口的约 25%,为 response 留出空间。
34
+ */
29
35
  maxContextTokens: number;
36
+ /** 旧版字符数阈值(兼容迁移) */
30
37
  maxContextChars?: number;
31
38
  defaultParams?: Record<string, unknown>;
32
39
  /** 是否支持图片输入(视觉模型)。看图工具(viewImage)仅对视觉模型启用;generateImage 是否返回图片内容块也据此判断 */
33
40
  vision?: boolean;
34
41
  description?: string;
35
42
  version?: number;
43
+ /**
44
+ * 是否用户自定义。
45
+ *
46
+ * 为 true 时 SDK 初始化不会用出厂定义替换该模型;缺省(或 false)视为出厂托管,
47
+ * 初始化时会与 DEFAULT_APP_CONFIG.models 同步(出厂清单为准)。
48
+ */
49
+ custom?: boolean;
36
50
  }
37
51
  /** Agent 定义,有 function 字段时为 SubAgent */
38
52
  export interface AgentDefinition {
@@ -64,6 +78,13 @@ export interface ImageModel {
64
78
  defaultSize?: string;
65
79
  defaultQuality?: string;
66
80
  version?: number;
81
+ /**
82
+ * 是否用户自定义。
83
+ *
84
+ * 为 true 时 SDK 初始化不会用出厂定义替换该模型;缺省(或 false)视为出厂托管,
85
+ * 初始化时会与 DEFAULT_APP_CONFIG.imageModels 同步(出厂清单为准)。
86
+ */
87
+ custom?: boolean;
67
88
  }
68
89
  /** config.json 结构 */
69
90
  export interface AppConfig {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-zen/agents-sdk",
3
- "version": "1.0.0-alpha.0",
3
+ "version": "1.0.0-alpha.1",
4
4
  "description": "AI-Zen Agents SDK — shared business logic for CLI and Desktop",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",