flux-agent
Version:
FluxAgent - 一个可灵活插拔的AI Agent系统框架,基于TypeScript开发,支持流式执行、事件系统、插件系统、知识库管理等功能 (Protected Release) (Protected Release) (Protected Release) (Protected Release) (Protected Release) (Protected Release) (Protected Release) (Protected Release) (Protected Release) (
81 lines (80 loc) • 2.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SystemTools = exports.AskUserInputTool = exports.EndPhaseTool = void 0;
const BaseTool_1 = require("../core/tools/BaseTool");
const Phases_1 = require("../core/Phases");
class EndPhaseTool extends BaseTool_1.AbstractTool {
constructor() {
super('EndPhaseTool', `结束当前阶段,进入下一个阶段,当你判断当前阶段的任务已经完成时,可以调用该工具`);
this.phase = Phases_1.PhaseType.ALL;
this.isSystemTool = true;
}
getDefinition() {
return {
type: 'function',
function: {
name: this.getName(),
description: this.getDescription(),
parameters: {
type: 'object',
properties: {
reason: {
type: 'string',
description: '为什么要结束当前阶段'
}
},
required: ['reason']
}
}
};
}
async execute(args, context) {
context.logger?.(`阶段结束工具被调用`, {
phase: context.phase,
reason: args.reason
});
return this.createSuccessResult(args);
}
cancel() {
// 取消工具调用
}
}
exports.EndPhaseTool = EndPhaseTool;
class AskUserInputTool extends BaseTool_1.AbstractTool {
constructor() {
super('AskUserInputTool', `当你希望等待用户回复时,可以调用该工具,但是你得说话`);
this.isSystemTool = true;
this.phase = [Phases_1.PhaseType.CONFIRM];
}
getDefinition() {
return {
type: 'function',
function: {
name: this.getName(),
description: this.getDescription(),
parameters: {}
}
};
}
async execute(args) {
return this.createPauseResult(args);
}
cancel() {
// 取消工具调用
}
getContextRecordText() {
return `正在等待用户输入`;
}
}
exports.AskUserInputTool = AskUserInputTool;
// 保持向后兼容的静态方法
class SystemTools {
// 新增:获取系统工具实例
static getSystemToolInstances() {
return [
new EndPhaseTool(),
new AskUserInputTool()
];
}
}
exports.SystemTools = SystemTools;