@ai-zen/agents-sdk 1.0.0-alpha.2 → 1.0.0-alpha.5

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,52 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.0.0-alpha.5] - 2026-10-13
4
+
5
+ ### 💥 Breaking Changes
6
+
7
+ - **All built-in tool names unified on `snake_case`** — the multi-word tools that used camelCase were renamed. A tool name is the API contract the model sees and is matched **verbatim** by the permission system, so any `permissions.allow` / `deny` list, skill `allowed-tools` entry or prompt that names a tool must be updated:
8
+
9
+ | old | new |
10
+ |---|---|
11
+ | `readFile` | `read` |
12
+ | `writeFile` | `write` |
13
+ | `inspectFile` | `inspect_file` |
14
+ | `findText` | `find_text` |
15
+ | `batchEdit` | `batch_edit` |
16
+ | `downloadFile` | `download_file` |
17
+ | `generateImage` | `generate_image` |
18
+ | `viewImage` | `view_image` |
19
+
20
+ Single-word tools (`cwd`, `edit`, `glob`, `ls`, `mkdir`, `rm`, `rename`, `copy`, `exec`, `exist`, `sleep`), the already-`snake_case` `exec_async`, the MCP / skill wrapper tools and core's `indexed_search` are unchanged. Tool descriptions and docs were updated in the same pass.
21
+
22
+ ### 🔧 Changed
23
+
24
+ - **Dependency `@ai-zen/agents-core` bumped to `^4.3.2`** (carries the `indexedSearch` → `indexed_search` rename).
25
+
26
+ ### 📄 Docs
27
+
28
+ - Current-version references in `docs/zh` and `docs/en` updated to `1.0.0-alpha.5`.
29
+
30
+ ## [1.0.0-alpha.4] - 2026-10-13
31
+
32
+ ### 🔧 Changed
33
+
34
+ - **Dependency `@ai-zen/agents-core` bumped to `^4.3.1`** (declared as `workspace:^`, expanded to `^4.3.1` at publish time). Pulls in core 4.3.1's fix for interrupted parallel tool rounds — the assistant message carrying `tool_calls` and its results now stay all-in or all-out, so an interrupted parallel tool call no longer leaves orphan `tool` results that the server rejects. `AgentContext` gains `abortedToolRoundStrategy` (default `"fill"`) and `abortedToolRoundReason`; set `agent.abortedToolRoundStrategy = "drop"` to drop the whole round instead
35
+
36
+ ### 📄 Docs
37
+
38
+ - Current-version references in `docs/zh` and `docs/en` updated to `1.0.0-alpha.4`.
39
+
40
+ ## [1.0.0-alpha.3] - 2026-10-03
41
+
42
+ ### 🔧 Fixed
43
+
44
+ - **`generateImage` `model` parameter description no longer points at a host-CLI command** — the description used to read "配置中的图片模型可通过 'aiz config show' 查看" (the configured image models can be viewed via `aiz config show`). Since tool descriptions ship inside every request's `tools` payload, that hint propagated into **every layer** of the agent stack: the model would `exec("aiz config show")`, but the CLI resolves a bare `aiz config show` invocation as stdio mode with the instruction `config show` — i.e. a **brand-new agent** — whose own `generateImage` description repeats the very same hint, producing a self-referential recursion that keeps spawning nested agents. The parameter now reads "若指定的模型不存在,本工具会返回当前可用的模型列表" (if the specified model does not exist, this tool returns the list of currently available models), which matches the actual `!imageModel` branch in `call()` and stops the model from shelling out to the host CLI.
45
+
46
+ ### 📄 Docs
47
+
48
+ - Current-version references in `docs/zh` and `docs/en` updated to `1.0.0-alpha.3`.
49
+
3
50
  ## [1.0.0-alpha.2] - 2026-10-03
4
51
 
5
52
  ### 🚀 New Features
package/README.md CHANGED
@@ -97,9 +97,9 @@ All built-in tools are classes (extending `SdkCallbackTool`), instantiated by th
97
97
  | Tool | Description |
98
98
  |------|-------------|
99
99
  | `cwd` | Get the current working directory |
100
- | `readFile` | Read a file (optional `range` for line/column slicing; oversized output warns and suggests batched reads) |
101
- | `inspectFile` | Inspect a file's structural overview (line count, column distribution, etc.); streamed scan, not limited by the 300KB read threshold |
102
- | `writeFile` | Write a file |
100
+ | `read` | Read a file (optional `range` for line/column slicing; oversized output warns and suggests batched reads) |
101
+ | `inspect_file` | Inspect a file's structural overview (line count, column distribution, etc.); streamed scan, not limited by the 300KB read threshold |
102
+ | `write` | Write a file |
103
103
  | `exec` | Execute a command (supports `timeout`; oversized stdout+stderr is dumped to `stdout.log` / `stderr.log`) |
104
104
  | `exec_async` | Execute a command asynchronously, returns immediately without waiting |
105
105
  | `mkdir` | Create a directory |
@@ -107,11 +107,11 @@ All built-in tools are classes (extending `SdkCallbackTool`), instantiated by th
107
107
  | `glob` | Scan and find files using glob patterns (oversized output dumped to `result.json`) |
108
108
  | `ls` | List directory contents (oversized output dumped to `result.json`) |
109
109
  | `exist` | Check whether a file or directory exists |
110
- | `findText` | Search for text or regex in files (oversized output dumped to `result.json`) |
111
- | `downloadFile` | Download a file from a URL and save it locally |
110
+ | `find_text` | Search for text or regex in files (oversized output dumped to `result.json`) |
111
+ | `download_file` | Download a file from a URL and save it locally |
112
112
  | `rename` | Rename or move a file/directory |
113
113
  | `copy` | Copy a file or directory |
114
- | `batchEdit` | Batch-edit file text (only unmatched items are echoed back; successful ones are counted) |
114
+ | `batch_edit` | Batch-edit file text (only unmatched items are echoed back; successful ones are counted) |
115
115
  | `edit` | Edit text in a file |
116
116
  | `sleep` | Wait for a specified number of milliseconds |
117
117
 
@@ -119,10 +119,10 @@ Conditionally injected based on the active model / config:
119
119
 
120
120
  | Tool | Injection Condition | Description |
121
121
  |------|---------------------|-------------|
122
- | `generateImage` | Only when `defaultImageModel` is configured | Generate an image from a text description |
123
- | `viewImage` | Only for vision models (the agent's `modelId` resolves to a model with `vision: true`) | View / analyze an image: local images are auto-uploaded via the Files API, network URLs are referenced directly |
122
+ | `generate_image` | Only when `defaultImageModel` is configured | Generate an image from a text description |
123
+ | `view_image` | Only for vision models (the agent's `modelId` resolves to a model with `vision: true`) | View / analyze an image: local images are auto-uploaded via the Files API, network URLs are referenced directly |
124
124
 
125
- Tool output protection: `AppConfig.maxToolOutput` (in characters, default 32768) is the unified ceiling for tool output. Each tool handles overflow itself — `exec` dumps `stdout.log` / `stderr.log` separately (returning head/tail previews per stream), `findText` / `glob` / `ls` dump `result.json` (returning a head preview), and `readFile` only warns and suggests batched reads via `range`. Dumps go to `<tmpdir>/ai-zen/tool-output/<tool>-<timestamp>-<random>/`, one directory per call, with no self-cleanup. See [`docs/sdk-design-v1.md` §12](docs/sdk-design-v1.md).
125
+ Tool output protection: `AppConfig.maxToolOutput` (in characters, default 32768) is the unified ceiling for tool output. Each tool handles overflow itself — `exec` dumps `stdout.log` / `stderr.log` separately (returning head/tail previews per stream), `find_text` / `glob` / `ls` dump `result.json` (returning a head preview), and `read` only warns and suggests batched reads via `range`. Dumps go to `<tmpdir>/ai-zen/tool-output/<tool>-<timestamp>-<random>/`, one directory per call, with no self-cleanup. See [`docs/sdk-design-v1.md` §12](docs/sdk-design-v1.md).
126
126
 
127
127
  ## Built-in Plugins
128
128
 
package/README.zh.md CHANGED
@@ -96,9 +96,9 @@ await scope.dispose(); // 断开 MCP、释放插件资源
96
96
  | 工具 | 说明 |
97
97
  |------|------|
98
98
  | `cwd` | 获取当前工作目录 |
99
- | `readFile` | 读取文件(可选 `range` 按行列范围读取;输出超限仅警告并提示用 `range` 分批) |
100
- | `inspectFile` | 勘察文件结构概况(行数、列数分布等),流式扫描不受 300KB 限制 |
101
- | `writeFile` | 写入文件 |
99
+ | `read` | 读取文件(可选 `range` 按行列范围读取;输出超限仅警告并提示用 `range` 分批) |
100
+ | `inspect_file` | 勘察文件结构概况(行数、列数分布等),流式扫描不受 300KB 限制 |
101
+ | `write` | 写入文件 |
102
102
  | `exec` | 执行命令(支持 `timeout` 超时参数;stdout+stderr 超限时分文件落盘 `stdout.log` / `stderr.log`) |
103
103
  | `exec_async` | 异步执行命令,启动后立即返回,不等待结果 |
104
104
  | `mkdir` | 创建目录 |
@@ -106,11 +106,11 @@ await scope.dispose(); // 断开 MCP、释放插件资源
106
106
  | `glob` | 使用 glob 模式扫描查找文件(输出超限落盘 `result.json`) |
107
107
  | `ls` | 列出目录内容(输出超限落盘 `result.json`) |
108
108
  | `exist` | 检查文件或目录是否存在 |
109
- | `findText` | 在文件中搜索文本或正则(输出超限落盘 `result.json`) |
110
- | `downloadFile` | 从 URL 下载文件并保存到本地 |
109
+ | `find_text` | 在文件中搜索文本或正则(输出超限落盘 `result.json`) |
110
+ | `download_file` | 从 URL 下载文件并保存到本地 |
111
111
  | `rename` | 重命名或移动文件/目录 |
112
112
  | `copy` | 复制文件或目录 |
113
- | `batchEdit` | 批量编辑文件文本(仅回显未匹配项,成功项只计数) |
113
+ | `batch_edit` | 批量编辑文件文本(仅回显未匹配项,成功项只计数) |
114
114
  | `edit` | 编辑文件中的文本 |
115
115
  | `sleep` | 等待指定毫秒数后继续 |
116
116
 
@@ -118,10 +118,10 @@ await scope.dispose(); // 断开 MCP、释放插件资源
118
118
 
119
119
  | 工具 | 注入条件 | 说明 |
120
120
  |------|----------|------|
121
- | `generateImage` | 配置了 `defaultImageModel` 才注册 | 根据文字描述生成图片 |
122
- | `viewImage` | 仅视觉模型可用(Agent 的 `modelId` 解析为 `vision: true` 的模型) | 查看/分析图片:本地图片自动经 Files API 上传,网络 URL 直接引用 |
121
+ | `generate_image` | 配置了 `defaultImageModel` 才注册 | 根据文字描述生成图片 |
122
+ | `view_image` | 仅视觉模型可用(Agent 的 `modelId` 解析为 `vision: true` 的模型) | 查看/分析图片:本地图片自动经 Files API 上传,网络 URL 直接引用 |
123
123
 
124
- 工具输出保护:`AppConfig.maxToolOutput`(字符数,缺省 32768)是工具输出的统一上限,超限时由各工具自行处置——`exec` 分文件落盘 `stdout.log` / `stderr.log`(返回各流头尾预览),`findText` / `glob` / `ls` 落盘 `result.json`(返回头部预览),`readFile` 仅警告并提示用 `range` 分批读取。落盘目录为 `<tmpdir>/ai-zen/tool-output/<工具名>-<时间戳>-<随机串>/`,每次调用独立、不自清理。详见 [`docs/sdk-design-v1.md` §12](docs/sdk-design-v1.md)。
124
+ 工具输出保护:`AppConfig.maxToolOutput`(字符数,缺省 32768)是工具输出的统一上限,超限时由各工具自行处置——`exec` 分文件落盘 `stdout.log` / `stderr.log`(返回各流头尾预览),`find_text` / `glob` / `ls` 落盘 `result.json`(返回头部预览),`read` 仅警告并提示用 `range` 分批读取。落盘目录为 `<tmpdir>/ai-zen/tool-output/<工具名>-<时间戳>-<随机串>/`,每次调用独立、不自清理。详见 [`docs/sdk-design-v1.md` §12](docs/sdk-design-v1.md)。
125
125
 
126
126
  ## 内置插件
127
127
 
@@ -2,7 +2,7 @@ import * as fsp from "fs/promises";
2
2
  import { SdkCallbackTool } from "./SdkCallbackTool.js";
3
3
  export class BatchEditTool extends SdkCallbackTool {
4
4
  function = {
5
- name: "batchEdit",
5
+ name: "batch_edit",
6
6
  description: "批量编辑文件文本,可以优先使用这个工具对文件进行编辑",
7
7
  parameters: {
8
8
  type: "object",
@@ -3,7 +3,7 @@ import * as path from "path";
3
3
  import { SdkCallbackTool } from "./SdkCallbackTool.js";
4
4
  export class DownloadFileTool extends SdkCallbackTool {
5
5
  function = {
6
- name: "downloadFile",
6
+ name: "download_file",
7
7
  description: "从 URL 下载文件(图片、PDF 等二进制文件)并保存到本地磁盘。自动从 URL 推断文件名,也可指定保存路径。",
8
8
  parameters: {
9
9
  type: "object",
@@ -98,7 +98,7 @@ export class ExecTool extends SdkCallbackTool {
98
98
  return JSON.stringify({
99
99
  outputTooLarge: true,
100
100
  warning: `输出过大:stdout + stderr 合计 ${result.stdout.length + result.stderr.length} 字符,` +
101
- `超过上限 ${limit} 字符。完整内容已分文件落盘(stdout.log / stderr.log),可用 readFile 分批读取。`,
101
+ `超过上限 ${limit} 字符。完整内容已分文件落盘(stdout.log / stderr.log),可用 read 分批读取。`,
102
102
  files: ctx.files,
103
103
  stdout: { chars: result.stdout.length, lines: countLines(result.stdout), ...stdout },
104
104
  stderr: { chars: result.stderr.length, lines: countLines(result.stderr), ...stderr },
@@ -10,7 +10,7 @@ const DEFAULT_MAX_FILE_SIZE = 300 * 1024;
10
10
  const DEFAULT_MAX_LINE_LENGTH = 200;
11
11
  export class FindTextTool extends SdkCallbackTool {
12
12
  function = {
13
- name: "findText",
13
+ name: "find_text",
14
14
  description: "查找文本出现的位置,支持普通文本或正则匹配,返回文件名及具体行号、行内容。为避免结果撑爆上下文,默认限制总匹配数、单文件大小与行内容长度,超限会截断并标记 truncated。",
15
15
  parameters: {
16
16
  type: "object",
@@ -94,7 +94,7 @@ export class FindTextTool extends SdkCallbackTool {
94
94
  continue;
95
95
  const content = await fsp.readFile(fullPath, "utf-8");
96
96
  if (signal?.aborted)
97
- break; // 中断:readFile 后再次检查
97
+ break; // 中断:read 后再次检查
98
98
  const lines = content.split("\n");
99
99
  const matches = [];
100
100
  for (let index = 0; index < lines.length; index++) {
@@ -145,7 +145,7 @@ export class FindTextTool extends SdkCallbackTool {
145
145
  async protect(json) {
146
146
  const limit = this.env.config.maxToolOutput ?? DEFAULT_MAX_TOOL_OUTPUT;
147
147
  return await guardOutput({
148
- tool: "findText",
148
+ tool: "find_text",
149
149
  content: json,
150
150
  isOverLimit: (text) => text.length > limit,
151
151
  dump: (_dir, text) => [{ name: "result.json", content: text }],
@@ -154,7 +154,7 @@ export class FindTextTool extends SdkCallbackTool {
154
154
  return JSON.stringify({
155
155
  outputTooLarge: true,
156
156
  warning: `输出过大:结果共 ${json.length} 字符,超过上限 ${limit} 字符。` +
157
- `完整结果已落盘(result.json),可用 readFile 分批读取。`,
157
+ `完整结果已落盘(result.json),可用 read 分批读取。`,
158
158
  files: ctx.files,
159
159
  chars: json.length,
160
160
  ...preview,
@@ -4,7 +4,7 @@ import type { AgentDefinition, AppConfig, ToolEnv } from "../../../types/index.j
4
4
  /**
5
5
  * 根据文字描述生成图片。**统一返回字符串**(JSON,含图片 URL 列表):
6
6
  * 生成结果如何处理(查看/下载/转发)由模型与上层自由决定——
7
- * 需要让模型看图时,模型可主动调用 viewImage(URL);需要保存时用 downloadFile。
7
+ * 需要让模型看图时,模型可主动调用 view_image(URL);需要保存时用 download_file。
8
8
  *
9
9
  * 依赖 AppConfig 中的 imageModels 和 defaultImageModel 配置(isAvailable 声明),
10
10
  * 未配置时由 buildTools 过滤,不暴露给 Agent。
@@ -3,7 +3,7 @@ import { SdkCallbackTool } from "./SdkCallbackTool.js";
3
3
  /**
4
4
  * 根据文字描述生成图片。**统一返回字符串**(JSON,含图片 URL 列表):
5
5
  * 生成结果如何处理(查看/下载/转发)由模型与上层自由决定——
6
- * 需要让模型看图时,模型可主动调用 viewImage(URL);需要保存时用 downloadFile。
6
+ * 需要让模型看图时,模型可主动调用 view_image(URL);需要保存时用 download_file。
7
7
  *
8
8
  * 依赖 AppConfig 中的 imageModels 和 defaultImageModel 配置(isAvailable 声明),
9
9
  * 未配置时由 buildTools 过滤,不暴露给 Agent。
@@ -14,8 +14,8 @@ export class GenerateImageTool extends SdkCallbackTool {
14
14
  return !!config.defaultImageModel;
15
15
  }
16
16
  function = {
17
- name: "generateImage",
18
- description: "根据文字描述生成图片,返回图片 URL 列表(JSON)。如需查看图片内容,请用 viewImage 工具(传入图片 URL);如需保存到本地,用 downloadFile 下载。",
17
+ name: "generate_image",
18
+ description: "根据文字描述生成图片,返回图片 URL 列表(JSON)。如需查看图片内容,请用 view_image 工具(传入图片 URL);如需保存到本地,用 download_file 下载。",
19
19
  parameters: {
20
20
  type: "object",
21
21
  properties: {
@@ -25,7 +25,7 @@ export class GenerateImageTool extends SdkCallbackTool {
25
25
  },
26
26
  model: {
27
27
  type: "string",
28
- description: "图片模型 ID,不指定则使用配置中的默认图片模型。配置中的图片模型可通过 'aiz config show' 查看。",
28
+ description: "图片模型 ID,不指定则使用配置中的默认图片模型;若指定的模型不存在,本工具会返回当前可用的模型列表。",
29
29
  },
30
30
  size: {
31
31
  type: "string",
@@ -99,15 +99,15 @@ export class GenerateImageTool extends SdkCallbackTool {
99
99
  .map((img) => img.url)
100
100
  .filter((url) => !!url);
101
101
  // 统一返回字符串(JSON):生成结果如何处理(查看/下载/转发)由模型与上层自由决定,
102
- // 不替模型做「看或不看」的假设。需要让模型看图 → 模型可主动调用 viewImage(URL);
103
- // 需要保存 → downloadFile 下载。
102
+ // 不替模型做「看或不看」的假设。需要让模型看图 → 模型可主动调用 view_image(URL);
103
+ // 需要保存 → download_file 下载。
104
104
  return JSON.stringify({
105
105
  success: true,
106
106
  model: imageModel.name,
107
107
  modelId: imageModel.id,
108
108
  created: result.created,
109
109
  images: urls.map((url, i) => ({ index: i, url })),
110
- note: "图片临时链接有效期为30天。如需查看图片内容,可用 viewImage 工具(传入图片 URL);如需保存,可用 downloadFile 下载。",
110
+ note: "图片临时链接有效期为30天。如需查看图片内容,可用 view_image 工具(传入图片 URL);如需保存,可用 download_file 下载。",
111
111
  }, null, 2);
112
112
  }
113
113
  catch (error) {
@@ -69,7 +69,7 @@ export class GlobTool extends SdkCallbackTool {
69
69
  return JSON.stringify({
70
70
  outputTooLarge: true,
71
71
  warning: `输出过大:匹配结果共 ${json.length} 字符,超过上限 ${limit} 字符。` +
72
- `完整结果已落盘(result.json),可用 readFile 分批读取;` +
72
+ `完整结果已落盘(result.json),可用 read 分批读取;` +
73
73
  `也可用更精确的 pattern 或 exclude 缩小范围后重新查找。`,
74
74
  files: ctx.files,
75
75
  chars: json.length,
@@ -4,8 +4,8 @@ import type { AgentNS } from "@ai-zen/agents-core";
4
4
  /**
5
5
  * 勘察文件结构概况(行数、每行列数等),不做内容读取。
6
6
  *
7
- * 定位与 readFile 的 range 配套:大文件先看结构(有多少行、每行多长),
8
- * 再决定 readFile 的读取范围。流式扫描,故不受 readFile 的 300KB 读取阈值限制。
7
+ * 定位与 read 的 range 配套:大文件先看结构(有多少行、每行多长),
8
+ * 再决定 read 的读取范围。流式扫描,故不受 read 的 300KB 读取阈值限制。
9
9
  */
10
10
  export declare class InspectFileTool extends SdkCallbackTool {
11
11
  function: AgentNS.FunctionDefine;
@@ -6,13 +6,13 @@ import { DEFAULT_MAX_TOOL_OUTPUT } from "./outputGuard.js";
6
6
  /**
7
7
  * 勘察文件结构概况(行数、每行列数等),不做内容读取。
8
8
  *
9
- * 定位与 readFile 的 range 配套:大文件先看结构(有多少行、每行多长),
10
- * 再决定 readFile 的读取范围。流式扫描,故不受 readFile 的 300KB 读取阈值限制。
9
+ * 定位与 read 的 range 配套:大文件先看结构(有多少行、每行多长),
10
+ * 再决定 read 的读取范围。流式扫描,故不受 read 的 300KB 读取阈值限制。
11
11
  */
12
12
  export class InspectFileTool extends SdkCallbackTool {
13
13
  function = {
14
- name: "inspectFile",
15
- description: "勘察文件的结构概况:总行数、总字符数、最长行的列数及其行索引、平均列数、行尾类型(LF/CRLF)。可选返回每行的列数映射。适用于在 readFile 之前先了解文件规模,再决定用 range 读取哪一段。仅做流式扫描,不受 readFile 的 300KB 读取阈值限制。",
14
+ name: "inspect_file",
15
+ description: "勘察文件的结构概况:总行数、总字符数、最长行的列数及其行索引、平均列数、行尾类型(LF/CRLF)。可选返回每行的列数映射。适用于在 read 之前先了解文件规模,再决定用 range 读取哪一段。仅做流式扫描,不受 read 的 300KB 读取阈值限制。",
16
16
  parameters: {
17
17
  type: "object",
18
18
  properties: {
@@ -63,7 +63,7 @@ export class InspectFileTool extends SdkCallbackTool {
63
63
  colCountMapOmitted: true,
64
64
  warning: `行长度明细过大:概况与 colCountMap 合计 ${payload.length} 字符,` +
65
65
  `超过上限 ${limit} 字符,未落盘返回。文件规模超出可处理范围,` +
66
- `建议改用 findText 定位后再按 range 分段读取。`,
66
+ `建议改用 find_text 定位后再按 range 分段读取。`,
67
67
  });
68
68
  }
69
69
  return payload;
@@ -36,7 +36,7 @@ export class LsTool extends SdkCallbackTool {
36
36
  return JSON.stringify({
37
37
  outputTooLarge: true,
38
38
  warning: `输出过大:目录条目共 ${entries.length} 项、${json.length} 字符,超过上限 ${limit} 字符。` +
39
- `完整列表已落盘(result.json),可用 readFile 分批读取;` +
39
+ `完整列表已落盘(result.json),可用 read 分批读取;` +
40
40
  `也可改用 glob 按模式筛选。`,
41
41
  files: ctx.files,
42
42
  chars: json.length,
@@ -3,7 +3,7 @@ import { SdkCallbackTool } from "./SdkCallbackTool.js";
3
3
  import { DEFAULT_MAX_TOOL_OUTPUT, guardOutput } from "./outputGuard.js";
4
4
  export class ReadFileTool extends SdkCallbackTool {
5
5
  function = {
6
- name: "readFile",
6
+ name: "read",
7
7
  description: "读取文件",
8
8
  parameters: {
9
9
  type: "object",
@@ -41,7 +41,7 @@ export class ReadFileTool extends SdkCallbackTool {
41
41
  // 输出保护:本次返回内容超过上限时只警告、不落盘,并提示用 range 分批读取
42
42
  const limit = this.env.config.maxToolOutput ?? DEFAULT_MAX_TOOL_OUTPUT;
43
43
  return await guardOutput({
44
- tool: "readFile",
44
+ tool: "read",
45
45
  content: output,
46
46
  isOverLimit: (text) => text.length > limit,
47
47
  buildWarning: () => `读取内容过大:本次输出 ${output.length} 字符,超过上限 ${limit} 字符,未落盘。` +
@@ -33,7 +33,7 @@ export class ViewImageTool extends SdkCallbackTool {
33
33
  return model?.vision === true;
34
34
  }
35
35
  function = {
36
- name: "viewImage",
36
+ name: "view_image",
37
37
  description: "查看一张图片并分析其内容。传入本地图片路径或 http(s) 图片 URL。本地图片会自动上传(Files API)后引用,网络图片直接引用。不支持本地 URL(如 file:// 协议、指向本机 localhost/127.0.0.1 的 http(s) 地址),本地图片请使用文件路径。适合识别图片文字、描述图片内容、分析图表等。",
38
38
  parameters: {
39
39
  type: "object",
@@ -54,7 +54,7 @@ export class ViewImageTool extends SdkCallbackTool {
54
54
  const signal = ctx?.signal;
55
55
  const target = input?.path_or_url;
56
56
  if (!target || !target.trim()) {
57
- return "viewImage 需要提供 path_or_url 参数(本地图片路径或 http(s) URL)。";
57
+ return "view_image 需要提供 path_or_url 参数(本地图片路径或 http(s) URL)。";
58
58
  }
59
59
  const value = target.trim();
60
60
  // 拒绝服务商无法访问的"本地 URL":file:// 等本地协议,或指向本机回环地址(localhost/127.0.0.1/[::1]/0.0.0.0)的 http(s) 地址
@@ -3,7 +3,7 @@ import * as path from "path";
3
3
  import { SdkCallbackTool } from "./SdkCallbackTool.js";
4
4
  export class WriteFileTool extends SdkCallbackTool {
5
5
  function = {
6
- name: "writeFile",
6
+ name: "write",
7
7
  description: "写入文件",
8
8
  parameters: {
9
9
  type: "object",
@@ -28,7 +28,7 @@ export interface OutputGuardOptions<T> {
28
28
  /** 超限判定:上限由工具自行从 config 读取,骨架不传参 */
29
29
  isOverLimit: (content: T) => boolean;
30
30
  /**
31
- * 落盘内容组织(可选)。缺省表示"只警告、不落盘"(如 readFile)。
31
+ * 落盘内容组织(可选)。缺省表示"只警告、不落盘"(如 read)。
32
32
  * 返回的文件按顺序写入本次调用专属的目录。
33
33
  */
34
34
  dump?: (dir: string, content: T) => GuardDumpFile[] | Promise<GuardDumpFile[]>;
@@ -61,7 +61,7 @@ export interface HeadPreview {
61
61
  /**
62
62
  * 生成头部预览:最多 size 字符。
63
63
  *
64
- * 适用于结果按出现顺序排列、尾部参考价值低的工具(如 findText)。
64
+ * 适用于结果按出现顺序排列、尾部参考价值低的工具(如 find_text)。
65
65
  */
66
66
  export declare function headPreview(text: string, size?: number): HeadPreview;
67
67
  /** 头尾预览 */
@@ -42,7 +42,7 @@ export async function guardOutput(options) {
42
42
  /**
43
43
  * 生成头部预览:最多 size 字符。
44
44
  *
45
- * 适用于结果按出现顺序排列、尾部参考价值低的工具(如 findText)。
45
+ * 适用于结果按出现顺序排列、尾部参考价值低的工具(如 find_text)。
46
46
  */
47
47
  export function headPreview(text, size = 1000) {
48
48
  if (text.length <= size)
@@ -36,7 +36,7 @@ export interface Model {
36
36
  /** 旧版字符数阈值(兼容迁移) */
37
37
  maxContextChars?: number;
38
38
  defaultParams?: Record<string, unknown>;
39
- /** 是否支持图片输入(视觉模型)。看图工具(viewImage)仅对视觉模型启用;generateImage 是否返回图片内容块也据此判断 */
39
+ /** 是否支持图片输入(视觉模型)。看图工具(view_image)仅对视觉模型启用;generate_image 是否返回图片内容块也据此判断 */
40
40
  vision?: boolean;
41
41
  description?: string;
42
42
  version?: number;
@@ -104,7 +104,7 @@ export interface AppConfig {
104
104
  *
105
105
  * 工具本次输出超过该值时,由工具自身的保护策略处置(落盘或仅警告),
106
106
  * 避免超长输出撑爆上下文。仅作用于"输出",与工具的读取阈值无关
107
- * (如 readFile/findText 对 300KB 文件的读取上限)。
107
+ * (如 read/find_text 对 300KB 文件的读取上限)。
108
108
  */
109
109
  maxToolOutput?: number;
110
110
  }
@@ -112,7 +112,7 @@ export interface AppConfig {
112
112
  * 工具环境 — Scope 的能力插件在实例化内置工具时注入的环境信息。
113
113
  *
114
114
  * cwd 是相对路径解析的基准(每个 Scope 对应一个工作目录);
115
- * config 供需要模型/端点配置的工具(如 generateImage)使用。
115
+ * config 供需要模型/端点配置的工具(如 generate_image)使用。
116
116
  */
117
117
  export interface ToolEnv {
118
118
  /** 当前工作目录 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-zen/agents-sdk",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.5",
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",
@@ -16,10 +16,10 @@
16
16
  "author": "LZQCN",
17
17
  "license": "MIT",
18
18
  "dependencies": {
19
+ "@ai-zen/agents-core": "^4.3.2",
19
20
  "@modelcontextprotocol/sdk": "^1.29.0",
20
21
  "dayjs": "^1.11.21",
21
- "openai": "^7.5.0",
22
- "@ai-zen/agents-core": "^4.3.0"
22
+ "openai": "^7.5.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/node": "^24.12.2",