@aidejs/tools 0.1.0-alpha.0 → 0.1.0-alpha.2
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 +4 -0
- package/LICENSE +21 -0
- package/README.md +107 -0
- package/package.json +35 -25
- package/src/browser/index.js +3 -0
- package/src/browser/open.js +47 -0
- package/src/disk/copyDisk.js +26 -0
- package/src/disk/deleteDisk.js +22 -0
- package/src/disk/index.js +8 -0
- package/src/disk/linkDisk.js +26 -0
- package/src/disk/moveDisk.js +26 -0
- package/src/index.js +12 -6
- package/types/index.d.ts +10 -1
- /package/src/{readPlain.js → disk/readPlain.js} +0 -0
- /package/src/{writePlain.js → disk/writePlain.js} +0 -0
package/CHANGELOG
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) zxl20070701 走一步,再走一步
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<img src="./docs/images/logo.png" />
|
|
2
|
+
|
|
3
|
+
# [Aidejs](https://github.com/NN-Studio/Aidejs)
|
|
4
|
+
一个用于构建人工智能代理的JavaScript框架,它提供了一组工具和库,使创建智能应用程序变得轻松和高效
|
|
5
|
+
|
|
6
|
+
## 功能列表
|
|
7
|
+
|
|
8
|
+
通过类似拼积木的方式,你可以轻松地组合各个模块完成个性化的 AI 应用开发。
|
|
9
|
+
|
|
10
|
+
下面是可用模块:
|
|
11
|
+
|
|
12
|
+
<p>
|
|
13
|
+
<a href="https://github.com/NN-Studio/Aidejs/issues">
|
|
14
|
+
<img src="https://img.shields.io/github/issues/NN-Studio/Aidejs" alt="issue">
|
|
15
|
+
</a>
|
|
16
|
+
<a href="https://github.com/NN-Studio/Aidejs" target='_blank'>
|
|
17
|
+
<img alt="GitHub repo stars" src="https://img.shields.io/github/stars/NN-Studio/Aidejs?style=social">
|
|
18
|
+
</a>
|
|
19
|
+
<a href="https://github.com/NN-Studio/Aidejs">
|
|
20
|
+
<img src="https://img.shields.io/github/forks/NN-Studio/Aidejs" alt="forks">
|
|
21
|
+
</a>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
<table>
|
|
25
|
+
<thead>
|
|
26
|
+
<tr>
|
|
27
|
+
<td>名称</td>
|
|
28
|
+
<td>简介</td>
|
|
29
|
+
<td>地址</td>
|
|
30
|
+
</tr>
|
|
31
|
+
</thead>
|
|
32
|
+
<tbody>
|
|
33
|
+
<tr>
|
|
34
|
+
<td>@aidejs/core</td>
|
|
35
|
+
<td>必选项,基础库,提供了最核心的LLM交互功能和插件系统</td>
|
|
36
|
+
<td>
|
|
37
|
+
<a href="https://www.npmjs.com/package/@aidejs/core" target="_blank">访问</a>
|
|
38
|
+
</td>
|
|
39
|
+
</tr>
|
|
40
|
+
<tr>
|
|
41
|
+
<td>@aidejs/tools</td>
|
|
42
|
+
<td>非必选,工具库,提供了各种实用的工具函数</td>
|
|
43
|
+
<td>
|
|
44
|
+
<a href="https://www.npmjs.com/package/@aidejs/tools" target="_blank">访问</a>
|
|
45
|
+
</td>
|
|
46
|
+
</tr>
|
|
47
|
+
</tbody>
|
|
48
|
+
</table>
|
|
49
|
+
|
|
50
|
+
更多模块我们将持续维护,你也可以[ 提issue ](https://github.com/NN-Studio/Aidejs/issues)告诉我们你希望提供或丰富优化的。
|
|
51
|
+
|
|
52
|
+
## 如何使用?
|
|
53
|
+
|
|
54
|
+
比如我们希望智能体告诉我们 ./mailmap 文件中的内容,怎么办?
|
|
55
|
+
|
|
56
|
+
首先,安装必要的依赖:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npm i @aidejs/core @aidejs/tools
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
然后在文件index.js中写入如下代码:
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
const Aidejs = require("@aidejs/core");
|
|
66
|
+
const Tools = require("@aidejs/tools");
|
|
67
|
+
|
|
68
|
+
// 注册插件
|
|
69
|
+
Aidejs.use(Tools);
|
|
70
|
+
|
|
71
|
+
let agent = new Aidejs({
|
|
72
|
+
model: "qwen3",
|
|
73
|
+
url: "http://localhost:11434/v1",
|
|
74
|
+
apiKey: ""
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
agent.task("告诉我文件./.mailmap中的内容是什么", function (message) {
|
|
78
|
+
process.stdout.write(message);
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
然后直接运行:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
node ./index.js
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
运行以后,就可以看见智能体的回答了:
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
文件 `./.mailmap` 的内容如下:
|
|
92
|
+
|
|
93
|
+
` ` `
|
|
94
|
+
zxl20070701 <1904314465@qq.com>
|
|
95
|
+
` ` `
|
|
96
|
+
|
|
97
|
+
这通常是一个邮件映射配置文件,用于将作者名(`zxl20070701`)映射到具体的邮箱地址(`1904314465@qq.com`),
|
|
98
|
+
常见于 Git 等工具的签名配置中。需要我帮你修改或解释吗?
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
更多细节,你可以访问[ 《Aidejs官方文档》 ](https://NN-Studio.github.io/Aidejs/)进行了解或学习。
|
|
102
|
+
|
|
103
|
+
## 版权
|
|
104
|
+
|
|
105
|
+
MIT License
|
|
106
|
+
|
|
107
|
+
Copyright (c) [zxl20070701](https://zxl20070701.github.io/notebook/home.html) 走一步,再走一步
|
package/package.json
CHANGED
|
@@ -1,26 +1,36 @@
|
|
|
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
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@aidejs/tools",
|
|
3
|
+
"version": "0.1.0-alpha.2",
|
|
4
|
+
"description": "@aidejs/tools",
|
|
5
|
+
"main": "./src/index.js",
|
|
6
|
+
"typings": "./types/index.d.ts",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"scripts": {},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/NN-Studio/Aidejs.git",
|
|
12
|
+
"directory": "packages/tools"
|
|
13
|
+
},
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "zxl20070701",
|
|
16
|
+
"url": "https://zxl20070701.github.io/notebook/home.html"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/NN-Studio/Aidejs/issues"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/NN-Studio/Aidejs",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"oipage": "^2.0.0"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"AI",
|
|
28
|
+
"Agent",
|
|
29
|
+
"ChatGPT",
|
|
30
|
+
"Aidejs",
|
|
31
|
+
"OpenClaw",
|
|
32
|
+
"skills",
|
|
33
|
+
"MCP",
|
|
34
|
+
"tools"
|
|
35
|
+
]
|
|
26
36
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const { exec } = require('child_process');
|
|
2
|
+
const os = require('os');
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
"description": {
|
|
6
|
+
"type": "function",
|
|
7
|
+
"function": {
|
|
8
|
+
"name": "open",
|
|
9
|
+
"description": "用浏览器打开指定网页",
|
|
10
|
+
"parameters": {
|
|
11
|
+
"type": "object",
|
|
12
|
+
"properties": {
|
|
13
|
+
"url": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "需要打开的网页地址",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
"required": ["url"],
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
"valueOf": function (args) {
|
|
23
|
+
const platform = os.platform();
|
|
24
|
+
let command;
|
|
25
|
+
|
|
26
|
+
switch (platform) {
|
|
27
|
+
case 'win32': // Windows
|
|
28
|
+
command = `start ${args.url}`;
|
|
29
|
+
break;
|
|
30
|
+
case 'darwin': // macOS
|
|
31
|
+
command = `open ${args.url}`;
|
|
32
|
+
break;
|
|
33
|
+
default: // Linux及其他
|
|
34
|
+
command = `xdg-open ${args.url}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return new Promise(function (resolve, reject) {
|
|
38
|
+
exec(command, (error) => {
|
|
39
|
+
if (error) {
|
|
40
|
+
reject(`无法打开浏览器: ${error}`);
|
|
41
|
+
} else {
|
|
42
|
+
resolve("成功打开了网页");
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"description": {
|
|
3
|
+
"type": "function",
|
|
4
|
+
"function": {
|
|
5
|
+
"name": "copyDisk",
|
|
6
|
+
"description": "复制文件或文件夹",
|
|
7
|
+
"parameters": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"sourcePath": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "需要复制的文件或文件夹的源路径",
|
|
13
|
+
},
|
|
14
|
+
"targetPath": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "准备把文件或文件夹复制到的目标路径",
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"required": ["sourcePath", "targetPath"],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
"valueOf": function (args) {
|
|
24
|
+
return require("oipage/nodejs/disk/index.js").copyDisk(args.sourcePath, args.targetPath, true);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"description": {
|
|
3
|
+
"type": "function",
|
|
4
|
+
"function": {
|
|
5
|
+
"name": "deleteDisk",
|
|
6
|
+
"description": "删除文件或文件夹",
|
|
7
|
+
"parameters": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"diskPath": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "需要删除的文件或文件夹的路径",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
"required": ["diskPath"],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
"valueOf": function (args) {
|
|
20
|
+
return require("oipage/nodejs/disk/index.js").deleteDisk(args.diskPath, true);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"description": {
|
|
3
|
+
"type": "function",
|
|
4
|
+
"function": {
|
|
5
|
+
"name": "linkDisk",
|
|
6
|
+
"description": "创建文件或文件夹的软链接或快捷方式",
|
|
7
|
+
"parameters": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"sourcePath": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "需要创建软链接的文件或文件夹的源路径",
|
|
13
|
+
},
|
|
14
|
+
"targetPath": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "准备把文件或文件夹软链接到的目标路径",
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"required": ["sourcePath", "targetPath"],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
"valueOf": function (args) {
|
|
24
|
+
return require("oipage/nodejs/disk/index.js").linkDisk(args.sourcePath, args.targetPath, true);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"description": {
|
|
3
|
+
"type": "function",
|
|
4
|
+
"function": {
|
|
5
|
+
"name": "moveDisk",
|
|
6
|
+
"description": "移动文件或文件夹",
|
|
7
|
+
"parameters": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"sourcePath": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "需要移动的文件或文件夹的源路径",
|
|
13
|
+
},
|
|
14
|
+
"targetPath": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "准备把文件或文件夹移动到的目标路径",
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"required": ["sourcePath", "targetPath"],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
"valueOf": function (args) {
|
|
24
|
+
return require("oipage/nodejs/disk/index.js").moveDisk(args.sourcePath, args.targetPath, true);
|
|
25
|
+
}
|
|
26
|
+
};
|
package/src/index.js
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
install(Aidejs) {
|
|
2
|
+
install(Aidejs, options) {
|
|
3
3
|
|
|
4
4
|
// 工具列表
|
|
5
5
|
const tools = {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
disk: require("./disk/index.js"), // 磁盘操作
|
|
7
|
+
browser: require("./browser/index.js"), // 浏览器
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
// 注册工具
|
|
11
|
-
for (let
|
|
12
|
-
|
|
11
|
+
for (let toolType in tools) {
|
|
12
|
+
for (let toolItem of tools[toolType]) {
|
|
13
|
+
let functionName = toolItem.description.function.name;
|
|
14
|
+
if (!options.exclude || !options.exclude(toolType, functionName)) {
|
|
15
|
+
let toolName = `aidejs_${toolType}_` + functionName;
|
|
16
|
+
toolItem.description.function.name = toolName;
|
|
17
|
+
Aidejs.registerTool(toolName, toolItem);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
13
20
|
}
|
|
14
|
-
|
|
15
21
|
}
|
|
16
22
|
};
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type Aidejs from "@aidejs/core"
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
|
-
install(Aidejs: Aidejs
|
|
4
|
+
install(Aidejs: Aidejs, options?: {
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 过滤若干不希望安装的工具
|
|
8
|
+
* @param toolType <string> 工具类型
|
|
9
|
+
* @param toolName <string> 工具名称
|
|
10
|
+
* @returns boolean 如果返回true,就表示当前工具不希望安装
|
|
11
|
+
*/
|
|
12
|
+
exclude?: (toolType: string, toolName: string) => boolean
|
|
13
|
+
}): void
|
|
5
14
|
}
|
|
File without changes
|
|
File without changes
|