@ai-zen/agents-sdk 0.5.7 → 0.6.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/CHANGELOG.md +26 -0
- package/dist/capabilities/implements/builtin/BatchEditTool.d.ts +2 -0
- package/dist/capabilities/implements/builtin/BatchEditTool.js +36 -38
- package/dist/capabilities/implements/builtin/CopyTool.d.ts +2 -0
- package/dist/capabilities/implements/builtin/CopyTool.js +23 -25
- package/dist/capabilities/implements/builtin/CwdTool.d.ts +2 -0
- package/dist/capabilities/implements/builtin/CwdTool.js +10 -12
- package/dist/capabilities/implements/builtin/DownloadFileTool.d.ts +3 -1
- package/dist/capabilities/implements/builtin/DownloadFileTool.js +32 -24
- package/dist/capabilities/implements/builtin/EditTool.d.ts +2 -0
- package/dist/capabilities/implements/builtin/EditTool.js +28 -30
- package/dist/capabilities/implements/builtin/ExecAsyncTool.d.ts +2 -0
- package/dist/capabilities/implements/builtin/ExecAsyncTool.js +23 -25
- package/dist/capabilities/implements/builtin/ExecTool.d.ts +3 -1
- package/dist/capabilities/implements/builtin/ExecTool.js +62 -29
- package/dist/capabilities/implements/builtin/ExistTool.d.ts +2 -0
- package/dist/capabilities/implements/builtin/ExistTool.js +15 -17
- package/dist/capabilities/implements/builtin/FindTextTool.d.ts +3 -1
- package/dist/capabilities/implements/builtin/FindTextTool.js +43 -35
- package/dist/capabilities/implements/builtin/GenerateImageTool.d.ts +3 -1
- package/dist/capabilities/implements/builtin/GenerateImageTool.js +39 -31
- package/dist/capabilities/implements/builtin/GlobTool.d.ts +3 -1
- package/dist/capabilities/implements/builtin/GlobTool.js +32 -28
- package/dist/capabilities/implements/builtin/LsTool.d.ts +2 -0
- package/dist/capabilities/implements/builtin/LsTool.js +15 -17
- package/dist/capabilities/implements/builtin/MkdirTool.d.ts +2 -0
- package/dist/capabilities/implements/builtin/MkdirTool.js +19 -21
- package/dist/capabilities/implements/builtin/ReadFileTool.d.ts +2 -0
- package/dist/capabilities/implements/builtin/ReadFileTool.js +15 -17
- package/dist/capabilities/implements/builtin/RenameTool.d.ts +2 -0
- package/dist/capabilities/implements/builtin/RenameTool.js +19 -21
- package/dist/capabilities/implements/builtin/RmTool.d.ts +2 -0
- package/dist/capabilities/implements/builtin/RmTool.js +19 -21
- package/dist/capabilities/implements/builtin/SleepTool.d.ts +3 -1
- package/dist/capabilities/implements/builtin/SleepTool.js +39 -19
- package/dist/capabilities/implements/builtin/WriteFileTool.d.ts +2 -0
- package/dist/capabilities/implements/builtin/WriteFileTool.js +19 -21
- package/dist/capabilities/implements/mcpTools.js +4 -6
- package/dist/capabilities/implements/skillTools.js +13 -3
- package/dist/capabilities/implements/subAgentTools.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/runtime/SdkCallbackTool.d.ts +14 -6
- package/dist/runtime/SdkCallbackTool.js +3 -2
- package/package.json +2 -2
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
import * as fsp from "fs/promises";
|
|
2
2
|
import { SdkCallbackTool } from "../../../runtime/SdkCallbackTool.js";
|
|
3
3
|
export class ExistTool extends SdkCallbackTool {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
type: "string",
|
|
14
|
-
description: "文件或目录路径",
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
required: ["path"],
|
|
18
|
-
additionalProperties: false,
|
|
4
|
+
function = {
|
|
5
|
+
name: "exist",
|
|
6
|
+
description: "检查文件或目录是否存在",
|
|
7
|
+
parameters: {
|
|
8
|
+
type: "object",
|
|
9
|
+
properties: {
|
|
10
|
+
path: {
|
|
11
|
+
type: "string",
|
|
12
|
+
description: "文件或目录路径",
|
|
19
13
|
},
|
|
20
14
|
},
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
required: ["path"],
|
|
16
|
+
additionalProperties: false,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
constructor(env) {
|
|
20
|
+
super({ env });
|
|
23
21
|
}
|
|
24
22
|
async call(input) {
|
|
25
23
|
return await fsp
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { SdkCallbackTool } from "../../../runtime/SdkCallbackTool.js";
|
|
2
2
|
import type { ToolEnv } from "../../../types/index.js";
|
|
3
|
+
import type { AgentNS, ToolCallContext } from "@ai-zen/agents-core";
|
|
3
4
|
export declare class FindTextTool extends SdkCallbackTool {
|
|
5
|
+
function: AgentNS.FunctionDefine;
|
|
4
6
|
constructor(env: ToolEnv);
|
|
5
7
|
call(input: {
|
|
6
8
|
path?: string;
|
|
@@ -8,5 +10,5 @@ export declare class FindTextTool extends SdkCallbackTool {
|
|
|
8
10
|
text?: string;
|
|
9
11
|
regex?: string;
|
|
10
12
|
exclude?: string[];
|
|
11
|
-
}): Promise<string>;
|
|
13
|
+
}, ctx?: ToolCallContext): Promise<string>;
|
|
12
14
|
}
|
|
@@ -2,45 +2,44 @@ import * as fsp from "fs/promises";
|
|
|
2
2
|
import * as path from "path";
|
|
3
3
|
import { SdkCallbackTool } from "../../../runtime/SdkCallbackTool.js";
|
|
4
4
|
export class FindTextTool extends SdkCallbackTool {
|
|
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
|
-
items: {
|
|
33
|
-
type: "string",
|
|
34
|
-
},
|
|
35
|
-
},
|
|
5
|
+
function = {
|
|
6
|
+
name: "findText",
|
|
7
|
+
description: "查找文本出现的位置,支持普通文本或正则匹配,返回文件名及具体行号、行内容",
|
|
8
|
+
parameters: {
|
|
9
|
+
type: "object",
|
|
10
|
+
properties: {
|
|
11
|
+
path: {
|
|
12
|
+
type: "string",
|
|
13
|
+
description: "glob cwd",
|
|
14
|
+
},
|
|
15
|
+
pattern: {
|
|
16
|
+
type: "string",
|
|
17
|
+
description: "glob pattern",
|
|
18
|
+
},
|
|
19
|
+
text: {
|
|
20
|
+
type: "string",
|
|
21
|
+
description: "要查找的文本(与 regex 二选一)",
|
|
22
|
+
},
|
|
23
|
+
regex: {
|
|
24
|
+
type: "string",
|
|
25
|
+
description: "正则表达式(与 text 二选一,例如 \\bconst\\s+\\w+)",
|
|
26
|
+
},
|
|
27
|
+
exclude: {
|
|
28
|
+
type: "array",
|
|
29
|
+
description: "要排除的 glob 模式数组",
|
|
30
|
+
items: {
|
|
31
|
+
type: "string",
|
|
36
32
|
},
|
|
37
|
-
required: ["path", "pattern"],
|
|
38
33
|
},
|
|
39
34
|
},
|
|
40
|
-
|
|
41
|
-
}
|
|
35
|
+
required: ["path", "pattern"],
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
constructor(env) {
|
|
39
|
+
super({ env });
|
|
42
40
|
}
|
|
43
|
-
async call(input) {
|
|
41
|
+
async call(input, ctx) {
|
|
42
|
+
const signal = ctx?.signal;
|
|
44
43
|
try {
|
|
45
44
|
const cwd = input.path ? this.resolve(input.path) : this.env.cwd;
|
|
46
45
|
const result = [];
|
|
@@ -54,10 +53,16 @@ export class FindTextTool extends SdkCallbackTool {
|
|
|
54
53
|
cwd,
|
|
55
54
|
exclude: input.exclude || ["**/node_modules/**"],
|
|
56
55
|
})) {
|
|
56
|
+
if (signal?.aborted)
|
|
57
|
+
break; // 中断:停止继续遍历/消费
|
|
57
58
|
const fullPath = path.join(cwd, file);
|
|
58
59
|
const stats = await fsp.stat(fullPath);
|
|
60
|
+
if (signal?.aborted)
|
|
61
|
+
break; // 中断:stat 后再次检查
|
|
59
62
|
if (stats.isFile()) {
|
|
60
63
|
const content = await fsp.readFile(fullPath, "utf-8");
|
|
64
|
+
if (signal?.aborted)
|
|
65
|
+
break; // 中断:readFile 后再次检查
|
|
61
66
|
const lines = content.split("\n");
|
|
62
67
|
const matches = [];
|
|
63
68
|
lines.forEach((lineContent, index) => {
|
|
@@ -83,6 +88,9 @@ export class FindTextTool extends SdkCallbackTool {
|
|
|
83
88
|
}
|
|
84
89
|
}
|
|
85
90
|
}
|
|
91
|
+
if (signal?.aborted) {
|
|
92
|
+
return JSON.stringify({ aborted: true, results: result });
|
|
93
|
+
}
|
|
86
94
|
return JSON.stringify(result);
|
|
87
95
|
}
|
|
88
96
|
catch (error) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AgentNS, ToolCallContext } from "@ai-zen/agents-core";
|
|
1
2
|
import { SdkCallbackTool } from "../../../runtime/SdkCallbackTool.js";
|
|
2
3
|
import type { ToolEnv } from "../../../types/index.js";
|
|
3
4
|
/**
|
|
@@ -11,11 +12,12 @@ import type { ToolEnv } from "../../../types/index.js";
|
|
|
11
12
|
* 不加入 BUILTIN_TOOL_CLASSES 静态注册表。
|
|
12
13
|
*/
|
|
13
14
|
export declare class GenerateImageTool extends SdkCallbackTool {
|
|
15
|
+
function: AgentNS.FunctionDefine;
|
|
14
16
|
constructor(env: ToolEnv);
|
|
15
17
|
call(input: {
|
|
16
18
|
prompt: string;
|
|
17
19
|
model?: string;
|
|
18
20
|
size?: string;
|
|
19
21
|
quality?: string;
|
|
20
|
-
}): Promise<string>;
|
|
22
|
+
}, ctx?: ToolCallContext): Promise<string>;
|
|
21
23
|
}
|
|
@@ -11,40 +11,39 @@ import { SdkCallbackTool } from "../../../runtime/SdkCallbackTool.js";
|
|
|
11
11
|
* 不加入 BUILTIN_TOOL_CLASSES 静态注册表。
|
|
12
12
|
*/
|
|
13
13
|
export class GenerateImageTool extends SdkCallbackTool {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
description: "图像质量。hd: 精细(约20秒), standard: 快速(约5-10秒)",
|
|
37
|
-
enum: ["hd", "standard"],
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
required: ["prompt"],
|
|
41
|
-
additionalProperties: false,
|
|
14
|
+
function = {
|
|
15
|
+
name: "generateImage",
|
|
16
|
+
description: "根据文字描述生成图片。返回图片 URL,可通过 downloadFile 工具保存到本地。",
|
|
17
|
+
parameters: {
|
|
18
|
+
type: "object",
|
|
19
|
+
properties: {
|
|
20
|
+
prompt: {
|
|
21
|
+
type: "string",
|
|
22
|
+
description: "所需图像的文本描述,应详细描述画面内容、风格、构图等",
|
|
23
|
+
},
|
|
24
|
+
model: {
|
|
25
|
+
type: "string",
|
|
26
|
+
description: "图片模型 ID,不指定则使用配置中的默认图片模型。配置中的图片模型可通过 'aiz config show' 查看。",
|
|
27
|
+
},
|
|
28
|
+
size: {
|
|
29
|
+
type: "string",
|
|
30
|
+
description: '图片尺寸。不指定则使用模型的默认尺寸。cogview系列: 1024x1024, 768x1344, 864x1152, 1344x768, 1152x864, 1440x720, 720x1440。glm-image: 1280x1280, 1568x1056, 1056x1568, 1472x1088, 1088x1472, 1728x960, 960x1728。',
|
|
31
|
+
},
|
|
32
|
+
quality: {
|
|
33
|
+
type: "string",
|
|
34
|
+
description: "图像质量。hd: 精细(约20秒), standard: 快速(约5-10秒)",
|
|
35
|
+
enum: ["hd", "standard"],
|
|
42
36
|
},
|
|
43
37
|
},
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
required: ["prompt"],
|
|
39
|
+
additionalProperties: false,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
constructor(env) {
|
|
43
|
+
super({ env });
|
|
46
44
|
}
|
|
47
|
-
async call(input) {
|
|
45
|
+
async call(input, ctx) {
|
|
46
|
+
const signal = ctx?.signal;
|
|
48
47
|
try {
|
|
49
48
|
const prompt = input.prompt;
|
|
50
49
|
if (!prompt || !prompt.trim()) {
|
|
@@ -95,6 +94,7 @@ export class GenerateImageTool extends SdkCallbackTool {
|
|
|
95
94
|
model: modelName,
|
|
96
95
|
size: input.size || imageModel.defaultSize || undefined,
|
|
97
96
|
quality: input.quality || imageModel.defaultQuality || undefined,
|
|
97
|
+
signal,
|
|
98
98
|
});
|
|
99
99
|
const images = result.data.map((img, i) => ({
|
|
100
100
|
index: i,
|
|
@@ -112,6 +112,14 @@ export class GenerateImageTool extends SdkCallbackTool {
|
|
|
112
112
|
}, null, 2);
|
|
113
113
|
}
|
|
114
114
|
catch (error) {
|
|
115
|
+
// 中断(abort)时返回明确的中断结果
|
|
116
|
+
if (signal?.aborted) {
|
|
117
|
+
return JSON.stringify({
|
|
118
|
+
success: false,
|
|
119
|
+
aborted: true,
|
|
120
|
+
error: "图片生成被中断(aborted)",
|
|
121
|
+
});
|
|
122
|
+
}
|
|
115
123
|
return JSON.stringify({
|
|
116
124
|
success: false,
|
|
117
125
|
error: error instanceof Error ? error.message : "图片生成失败",
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { SdkCallbackTool } from "../../../runtime/SdkCallbackTool.js";
|
|
2
2
|
import type { ToolEnv } from "../../../types/index.js";
|
|
3
|
+
import type { AgentNS, ToolCallContext } from "@ai-zen/agents-core";
|
|
3
4
|
export declare class GlobTool extends SdkCallbackTool {
|
|
5
|
+
function: AgentNS.FunctionDefine;
|
|
4
6
|
constructor(env: ToolEnv);
|
|
5
7
|
call(input: {
|
|
6
8
|
path?: string;
|
|
7
9
|
pattern: string;
|
|
8
10
|
exclude?: string[];
|
|
9
|
-
}): Promise<string>;
|
|
11
|
+
}, ctx?: ToolCallContext): Promise<string>;
|
|
10
12
|
}
|
|
@@ -1,38 +1,37 @@
|
|
|
1
1
|
import * as fsp from "fs/promises";
|
|
2
2
|
import { SdkCallbackTool } from "../../../runtime/SdkCallbackTool.js";
|
|
3
3
|
export class GlobTool extends SdkCallbackTool {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
items: {
|
|
24
|
-
type: "string",
|
|
25
|
-
},
|
|
26
|
-
},
|
|
4
|
+
function = {
|
|
5
|
+
name: "glob",
|
|
6
|
+
description: "使用 glob 模式递归扫描和查找文件。这是进行文件系统搜索的首选工具,功能远优于简单的 'ls' 列表命令。当你需要查找特定类型的文件、遍历目录树或需要排除特定文件时,请优先使用此函数。",
|
|
7
|
+
parameters: {
|
|
8
|
+
type: "object",
|
|
9
|
+
properties: {
|
|
10
|
+
path: {
|
|
11
|
+
type: "string",
|
|
12
|
+
description: "glob cwd",
|
|
13
|
+
},
|
|
14
|
+
pattern: {
|
|
15
|
+
type: "string",
|
|
16
|
+
description: "glob pattern",
|
|
17
|
+
},
|
|
18
|
+
exclude: {
|
|
19
|
+
type: "array",
|
|
20
|
+
description: "glob pattern to exclude",
|
|
21
|
+
items: {
|
|
22
|
+
type: "string",
|
|
27
23
|
},
|
|
28
|
-
required: ["pattern"],
|
|
29
|
-
additionalProperties: false,
|
|
30
24
|
},
|
|
31
25
|
},
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
required: ["pattern"],
|
|
27
|
+
additionalProperties: false,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
constructor(env) {
|
|
31
|
+
super({ env });
|
|
34
32
|
}
|
|
35
|
-
async call(input) {
|
|
33
|
+
async call(input, ctx) {
|
|
34
|
+
const signal = ctx?.signal;
|
|
36
35
|
try {
|
|
37
36
|
const cwd = input.path ? this.resolve(input.path) : this.env.cwd;
|
|
38
37
|
const result = [];
|
|
@@ -40,8 +39,13 @@ export class GlobTool extends SdkCallbackTool {
|
|
|
40
39
|
exclude: input.exclude || ["**/node_modules/**"],
|
|
41
40
|
cwd,
|
|
42
41
|
})) {
|
|
42
|
+
if (signal?.aborted)
|
|
43
|
+
break; // 中断:停止继续遍历/消费
|
|
43
44
|
result.push(file);
|
|
44
45
|
}
|
|
46
|
+
if (signal?.aborted) {
|
|
47
|
+
return JSON.stringify({ aborted: true, files: result });
|
|
48
|
+
}
|
|
45
49
|
return JSON.stringify(result);
|
|
46
50
|
}
|
|
47
51
|
catch (error) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { SdkCallbackTool } from "../../../runtime/SdkCallbackTool.js";
|
|
2
2
|
import type { ToolEnv } from "../../../types/index.js";
|
|
3
|
+
import type { AgentNS } from "@ai-zen/agents-core";
|
|
3
4
|
export declare class LsTool extends SdkCallbackTool {
|
|
5
|
+
function: AgentNS.FunctionDefine;
|
|
4
6
|
constructor(env: ToolEnv);
|
|
5
7
|
call(input: {
|
|
6
8
|
path: string;
|
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
import * as fsp from "fs/promises";
|
|
2
2
|
import { SdkCallbackTool } from "../../../runtime/SdkCallbackTool.js";
|
|
3
3
|
export class LsTool extends SdkCallbackTool {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
type: "string",
|
|
14
|
-
description: "目录路径",
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
required: ["path"],
|
|
18
|
-
additionalProperties: false,
|
|
4
|
+
function = {
|
|
5
|
+
name: "ls",
|
|
6
|
+
description: "列出目录",
|
|
7
|
+
parameters: {
|
|
8
|
+
type: "object",
|
|
9
|
+
properties: {
|
|
10
|
+
path: {
|
|
11
|
+
type: "string",
|
|
12
|
+
description: "目录路径",
|
|
19
13
|
},
|
|
20
14
|
},
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
required: ["path"],
|
|
16
|
+
additionalProperties: false,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
constructor(env) {
|
|
20
|
+
super({ env });
|
|
23
21
|
}
|
|
24
22
|
async call(input) {
|
|
25
23
|
try {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { SdkCallbackTool } from "../../../runtime/SdkCallbackTool.js";
|
|
2
2
|
import type { ToolEnv } from "../../../types/index.js";
|
|
3
|
+
import type { AgentNS } from "@ai-zen/agents-core";
|
|
3
4
|
export declare class MkdirTool extends SdkCallbackTool {
|
|
5
|
+
function: AgentNS.FunctionDefine;
|
|
4
6
|
constructor(env: ToolEnv);
|
|
5
7
|
call(input: {
|
|
6
8
|
path: string;
|
|
@@ -1,29 +1,27 @@
|
|
|
1
1
|
import * as fsp from "fs/promises";
|
|
2
2
|
import { SdkCallbackTool } from "../../../runtime/SdkCallbackTool.js";
|
|
3
3
|
export class MkdirTool extends SdkCallbackTool {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
type: "boolean",
|
|
18
|
-
description: "是否递归创建子目录",
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
required: ["path"],
|
|
22
|
-
additionalProperties: false,
|
|
4
|
+
function = {
|
|
5
|
+
name: "mkdir",
|
|
6
|
+
description: "创建目录",
|
|
7
|
+
parameters: {
|
|
8
|
+
type: "object",
|
|
9
|
+
properties: {
|
|
10
|
+
path: {
|
|
11
|
+
type: "string",
|
|
12
|
+
description: "目录路径",
|
|
13
|
+
},
|
|
14
|
+
recursive: {
|
|
15
|
+
type: "boolean",
|
|
16
|
+
description: "是否递归创建子目录",
|
|
23
17
|
},
|
|
24
18
|
},
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
required: ["path"],
|
|
20
|
+
additionalProperties: false,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
constructor(env) {
|
|
24
|
+
super({ env });
|
|
27
25
|
}
|
|
28
26
|
async call(input) {
|
|
29
27
|
try {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { SdkCallbackTool } from "../../../runtime/SdkCallbackTool.js";
|
|
2
2
|
import type { ToolEnv } from "../../../types/index.js";
|
|
3
|
+
import type { AgentNS } from "@ai-zen/agents-core";
|
|
3
4
|
export declare class ReadFileTool extends SdkCallbackTool {
|
|
5
|
+
function: AgentNS.FunctionDefine;
|
|
4
6
|
constructor(env: ToolEnv);
|
|
5
7
|
call(input: {
|
|
6
8
|
path: string;
|
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
import * as fsp from "fs/promises";
|
|
2
2
|
import { SdkCallbackTool } from "../../../runtime/SdkCallbackTool.js";
|
|
3
3
|
export class ReadFileTool extends SdkCallbackTool {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
type: "string",
|
|
14
|
-
description: "文件路径",
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
required: ["path"],
|
|
18
|
-
additionalProperties: false,
|
|
4
|
+
function = {
|
|
5
|
+
name: "readFile",
|
|
6
|
+
description: "读取文件",
|
|
7
|
+
parameters: {
|
|
8
|
+
type: "object",
|
|
9
|
+
properties: {
|
|
10
|
+
path: {
|
|
11
|
+
type: "string",
|
|
12
|
+
description: "文件路径",
|
|
19
13
|
},
|
|
20
14
|
},
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
required: ["path"],
|
|
16
|
+
additionalProperties: false,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
constructor(env) {
|
|
20
|
+
super({ env });
|
|
23
21
|
}
|
|
24
22
|
async call(input) {
|
|
25
23
|
try {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { SdkCallbackTool } from "../../../runtime/SdkCallbackTool.js";
|
|
2
2
|
import type { ToolEnv } from "../../../types/index.js";
|
|
3
|
+
import type { AgentNS } from "@ai-zen/agents-core";
|
|
3
4
|
export declare class RenameTool extends SdkCallbackTool {
|
|
5
|
+
function: AgentNS.FunctionDefine;
|
|
4
6
|
constructor(env: ToolEnv);
|
|
5
7
|
call(input: {
|
|
6
8
|
oldPath: string;
|
|
@@ -1,29 +1,27 @@
|
|
|
1
1
|
import * as fsp from "fs/promises";
|
|
2
2
|
import { SdkCallbackTool } from "../../../runtime/SdkCallbackTool.js";
|
|
3
3
|
export class RenameTool extends SdkCallbackTool {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
type: "string",
|
|
18
|
-
description: "新路径",
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
required: ["oldPath", "newPath"],
|
|
22
|
-
additionalProperties: false,
|
|
4
|
+
function = {
|
|
5
|
+
name: "rename",
|
|
6
|
+
description: "重命名或移动文件/目录(相当于 mv 命令)",
|
|
7
|
+
parameters: {
|
|
8
|
+
type: "object",
|
|
9
|
+
properties: {
|
|
10
|
+
oldPath: {
|
|
11
|
+
type: "string",
|
|
12
|
+
description: "原路径",
|
|
13
|
+
},
|
|
14
|
+
newPath: {
|
|
15
|
+
type: "string",
|
|
16
|
+
description: "新路径",
|
|
23
17
|
},
|
|
24
18
|
},
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
required: ["oldPath", "newPath"],
|
|
20
|
+
additionalProperties: false,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
constructor(env) {
|
|
24
|
+
super({ env });
|
|
27
25
|
}
|
|
28
26
|
async call(input) {
|
|
29
27
|
try {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { SdkCallbackTool } from "../../../runtime/SdkCallbackTool.js";
|
|
2
2
|
import type { ToolEnv } from "../../../types/index.js";
|
|
3
|
+
import type { AgentNS } from "@ai-zen/agents-core";
|
|
3
4
|
export declare class RmTool extends SdkCallbackTool {
|
|
5
|
+
function: AgentNS.FunctionDefine;
|
|
4
6
|
constructor(env: ToolEnv);
|
|
5
7
|
call(input: {
|
|
6
8
|
path: string;
|