feat: 先进智能体运行时基座 v1

- 支持高层调用进行可配置智能体业务开发
- 封装基于 agentscope-java
- 支持 tool、skill、知识库等封装
- 支持 tool 审批
- 支持智能体事件回传
- 等等
This commit is contained in:
2026-05-19 17:30:42 +08:00
parent 787ca328f9
commit 8356560c26
82 changed files with 9760 additions and 0 deletions

View File

@@ -0,0 +1,269 @@
package com.easyagents.agent.runtime;
import com.easyagents.agent.runtime.knowledge.AgentKnowledgeSpec;
import com.easyagents.agent.runtime.memory.AgentMemoryPolicy;
import com.easyagents.agent.runtime.model.AgentGenerationOptions;
import com.easyagents.agent.runtime.model.AgentModelSpec;
import com.easyagents.agent.runtime.persistence.AgentPersistencePolicy;
import com.easyagents.agent.runtime.skill.AgentSkillBoxSpec;
import com.easyagents.agent.runtime.tool.AgentToolSpec;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* 主入口
* ReAct 智能体的声明式定义
*/
public class AgentDefinition {
private String agentId;
private String agentName;
private String description;
private String systemPrompt;
private AgentModelSpec modelSpec;
private AgentGenerationOptions generationOptions = new AgentGenerationOptions();
private AgentExecutionOptions executionOptions = new AgentExecutionOptions();
private List<AgentToolSpec> toolSpecs = new ArrayList<>();
private List<AgentKnowledgeSpec> knowledgeSpecs = new ArrayList<>();
private AgentMemoryPolicy memoryPolicy = AgentMemoryPolicy.autoContext();
private AgentPersistencePolicy persistencePolicy = AgentPersistencePolicy.disabled();
private AgentSkillBoxSpec skillBoxSpec;
private Map<String, Object> metadata = new LinkedHashMap<>();
/**
* 获取agent id。
*
* @return 智能体ID
*/
public String getAgentId() {
return agentId;
}
/**
* 设置agent id。
*
* @param agentId 智能体ID
*/
public void setAgentId(String agentId) {
this.agentId = agentId;
}
/**
* 获取agent name。
*
* @return 智能体名称
*/
public String getAgentName() {
return agentName;
}
/**
* 设置agent name。
*
* @param agentName 智能体名称
*/
public void setAgentName(String agentName) {
this.agentName = agentName;
}
/**
* 获取agent description。
*
* @return 智能体描述
*/
public String getDescription() {
return description;
}
/**
* 设置agent description。
*
* @param description 智能体描述
*/
public void setDescription(String description) {
this.description = description;
}
/**
* 获取system prompt。
*
* @return 系统提示词
*/
public String getSystemPrompt() {
return systemPrompt;
}
/**
* 设置system prompt。
*
* @param systemPrompt 系统提示词
*/
public void setSystemPrompt(String systemPrompt) {
this.systemPrompt = systemPrompt;
}
/**
* 获取模型设置。
*
* @return 模型设置
*/
public AgentModelSpec getModelSpec() {
return modelSpec;
}
/**
* 设置模型设置。
*
* @param modelSpec 模型设置
*/
public void setModelSpec(AgentModelSpec modelSpec) {
this.modelSpec = modelSpec;
}
/**
* 获取生成参数。
*
* @return 生成参数
*/
public AgentGenerationOptions getGenerationOptions() {
return generationOptions;
}
/**
* 设置生成参数。
*
* @param generationOptions 生成参数
*/
public void setGenerationOptions(AgentGenerationOptions generationOptions) {
this.generationOptions = generationOptions == null ? new AgentGenerationOptions() : generationOptions;
}
/**
* 获取执行参数。
*
* @return 执行参数
*/
public AgentExecutionOptions getExecutionOptions() {
return executionOptions;
}
/**
* 设置执行参数。
*
* @param executionOptions 执行参数
*/
public void setExecutionOptions(AgentExecutionOptions executionOptions) {
this.executionOptions = executionOptions == null ? new AgentExecutionOptions() : executionOptions;
}
/**
* 获取工具定义。
*
* @return 工具定义
*/
public List<AgentToolSpec> getToolSpecs() {
return toolSpecs;
}
/**
* 设置工具定义。
*
* @param toolSpecs 工具定义
*/
public void setToolSpecs(List<AgentToolSpec> toolSpecs) {
this.toolSpecs = toolSpecs == null ? new ArrayList<>() : new ArrayList<>(toolSpecs);
}
/**
* 获取知识库定义。
*
* @return 知识库定义
*/
public List<AgentKnowledgeSpec> getKnowledgeSpecs() {
return knowledgeSpecs;
}
/**
* 设置知识库定义。
*
* @param knowledgeSpecs 知识库定义
*/
public void setKnowledgeSpecs(List<AgentKnowledgeSpec> knowledgeSpecs) {
this.knowledgeSpecs = knowledgeSpecs == null ? new ArrayList<>() : new ArrayList<>(knowledgeSpecs);
}
/**
* 获取记忆策略。
*
* @return 记忆策略
*/
public AgentMemoryPolicy getMemoryPolicy() {
return memoryPolicy;
}
/**
* 设置记忆策略。
*
* @param memoryPolicy 记忆策略
*/
public void setMemoryPolicy(AgentMemoryPolicy memoryPolicy) {
this.memoryPolicy = memoryPolicy == null ? AgentMemoryPolicy.autoContext() : memoryPolicy;
}
/**
* 获取持久化策略。
*
* @return 持久化策略
*/
public AgentPersistencePolicy getPersistencePolicy() {
return persistencePolicy;
}
/**
* 设置持久化策略。
*
* @param persistencePolicy 持久化策略
*/
public void setPersistencePolicy(AgentPersistencePolicy persistencePolicy) {
this.persistencePolicy = persistencePolicy == null ? AgentPersistencePolicy.disabled() : persistencePolicy;
}
/**
* 获取SkillBox 设置。
*
* @return SkillBox 设置
*/
public AgentSkillBoxSpec getSkillBoxSpec() {
return skillBoxSpec;
}
/**
* 设置SkillBox 设置。
*
* @param skillBoxSpec SkillBox 设置
*/
public void setSkillBoxSpec(AgentSkillBoxSpec skillBoxSpec) {
this.skillBoxSpec = skillBoxSpec;
}
/**
* 获取元数据。
*
* @return 元数据
*/
public Map<String, Object> getMetadata() {
return metadata;
}
/**
* 设置元数据。
*
* @param metadata 元数据
*/
public void setMetadata(Map<String, Object> metadata) {
this.metadata = metadata == null ? new LinkedHashMap<>() : metadata;
}
}