deepfish-ai 1.0.20 → 1.0.21
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deepfish-ai",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.21",
|
|
4
4
|
"description": "This is an AI-driven command-line tool built on Node.js, equipped with AI agent and workflow capabilities. It is compatible with a wide range of AI models, can convert natural language into cross-system terminal and file operation commands, and features high extensibility. It supports complex tasks such as translation, content creation, and format conversion, while allowing custom extensions to be automatically generated via AI.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -261,7 +261,7 @@ class BaseAgentRobot {
|
|
|
261
261
|
const id = this.id
|
|
262
262
|
const name = this.name
|
|
263
263
|
return `
|
|
264
|
-
你叫${name}, 编号${id},
|
|
264
|
+
你叫${name}, 编号${id}, 是一个严格按规则执行任务的智能体,不能违反任何系统限制,具有INTJ人格,高冷、做事以及回复问题精简、准确、不废话。
|
|
265
265
|
### 基础环境信息
|
|
266
266
|
当前工作目录:${workspace}
|
|
267
267
|
操作系统类型:${osType}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Author: Roman 306863030@qq.com
|
|
3
3
|
* @Date: 2026-03-17 11:59:19
|
|
4
4
|
* @LastEditors: Roman 306863030@qq.com
|
|
5
|
-
* @LastEditTime: 2026-04-
|
|
5
|
+
* @LastEditTime: 2026-04-21 21:08:34
|
|
6
6
|
* @FilePath: \deepfish\src\AgentRobot\BaseAgentRobot\tools\SystemTools.js
|
|
7
7
|
* @Description: 默认扩展函数
|
|
8
8
|
* @
|
|
@@ -83,7 +83,13 @@ async function requestAI(
|
|
|
83
83
|
async function executeJSCode(code) {
|
|
84
84
|
aiConsole.logSuccess('Executing JavaScript code: ')
|
|
85
85
|
aiConsole.logSuccess(code)
|
|
86
|
-
|
|
86
|
+
// 检测code最后一行代码包含return,如果不包含,则返回一个错误信息,提示agent需要使用return返回结果
|
|
87
|
+
const codeLines = code.trim().split('\n')
|
|
88
|
+
const lastLine = codeLines[codeLines.length - 1].trim()
|
|
89
|
+
if (!lastLine.startsWith('return')) {
|
|
90
|
+
const error = new Error('The last line of the code must contain a return statement.')
|
|
91
|
+
throw error
|
|
92
|
+
}
|
|
87
93
|
try {
|
|
88
94
|
const functions = this.agentRobot.getTools()
|
|
89
95
|
const Func = new Function(
|
|
@@ -97,9 +103,12 @@ async function executeJSCode(code) {
|
|
|
97
103
|
this.logMessages.push(Array.from(arguments).join(' '))
|
|
98
104
|
}
|
|
99
105
|
console.log = newLog.bind(this)
|
|
100
|
-
|
|
106
|
+
function __main() {
|
|
107
|
+
${code}
|
|
108
|
+
}
|
|
109
|
+
const result = await __main()
|
|
101
110
|
console.log = originalLog
|
|
102
|
-
return this.logMessages.join('\\n')
|
|
111
|
+
return result || this.logMessages.join('\\n')
|
|
103
112
|
})()`,
|
|
104
113
|
)
|
|
105
114
|
const originalRequire = require
|
|
@@ -191,7 +200,7 @@ const descriptions = [
|
|
|
191
200
|
function: {
|
|
192
201
|
name: 'executeJSCode',
|
|
193
202
|
description:
|
|
194
|
-
'执行JavaScript代码,返回代码执行结果。代码中可通过Tools命名空间直接调用其他工具函数(如await Tools.createFile(),注意:不需要使用require引入),Tools中引入了一些常用库可直接调用(Tools.fs="fs-extra", Tools.dayjs="dayjs", Tools.axios="axios", Tools.lodash="lodash", Tools.echarts="echarts", Tools.canvas="canvas" Tools.cheerio="cheerio" Tools.puppeteer="puppeteer"),支持引入自定义模块(需使用绝对路径)。注意:1.代码中不要使用__dirname获取当前目录,请使用path.resolve(".")来获取当前目录。2.执行失败时会抛出错误,成功时返回代码执行结果或空字符串。3.使用require(module_path)函数引入自定义模块,module_path为模块路径字符串,支持相对路径(如"./myModule.js")和绝对路径,返回引入的模块内容。',
|
|
203
|
+
'执行JavaScript代码,返回代码执行结果。代码中可通过Tools命名空间直接调用其他工具函数(如await Tools.createFile(),注意:不需要使用require引入),Tools中引入了一些常用库可直接调用(Tools.fs="fs-extra", Tools.dayjs="dayjs", Tools.axios="axios", Tools.lodash="lodash", Tools.echarts="echarts", Tools.canvas="canvas" Tools.cheerio="cheerio" Tools.puppeteer="puppeteer"),支持引入自定义模块(需使用绝对路径)。注意:1.代码中不要使用__dirname获取当前目录,请使用path.resolve(".")来获取当前目录。2.执行失败时会抛出错误,成功时返回代码执行结果或空字符串。3.使用require(module_path)函数引入自定义模块,module_path为模块路径字符串,支持相对路径(如"./myModule.js")和绝对路径,返回引入的模块内容。4.执行主函数必须使用return返回,如return main()',
|
|
195
204
|
parameters: {
|
|
196
205
|
type: 'object',
|
|
197
206
|
properties: {
|