feat: 支持智能体可见范围管理
- 未分类智能体按可见范围绕过分类白名单 - 提供个人、部门、公开范围配置及列表状态标签
This commit is contained in:
@@ -35,6 +35,15 @@ public interface AgentService extends IService<Agent> {
|
||||
*/
|
||||
Agent updateDraft(Agent agent);
|
||||
|
||||
/**
|
||||
* 更新 Agent 的可见范围。
|
||||
*
|
||||
* @param agentId Agent ID
|
||||
* @param visibilityScope 可见范围编码
|
||||
* @return 更新后的 Agent
|
||||
*/
|
||||
Agent updateVisibilityScope(BigInteger agentId, String visibilityScope);
|
||||
|
||||
/**
|
||||
* 获取已发布运行视图。
|
||||
*
|
||||
|
||||
@@ -114,6 +114,29 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Agent updateVisibilityScope(BigInteger agentId, String visibilityScope) {
|
||||
if (agentId == null) {
|
||||
throw new BusinessException("Agent ID 不能为空");
|
||||
}
|
||||
VisibilityScope scope = parseVisibilityScope(visibilityScope);
|
||||
return agentBindingLockExecutor.execute(agentId, () -> {
|
||||
Agent existing = requireAgentForUpdate(agentId);
|
||||
resourceAccessService.assertAccess(
|
||||
CategoryResourceType.AGENT, existing, ResourceAction.MANAGE, "无权限管理该 Agent");
|
||||
LoginAccount account = requireCurrentLoginAccount();
|
||||
existing.setVisibilityScope(scope.name());
|
||||
existing.setModified(new Date());
|
||||
existing.setModifiedBy(account.getId());
|
||||
updateById(existing);
|
||||
return getDetail(existing.getId());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -244,6 +267,20 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
|
||||
agent.setExecutionConfigJson(normalizeExecutionConfig(agent.getExecutionConfigJson()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析并校验 Agent 可见范围。
|
||||
*
|
||||
* @param visibilityScope 可见范围编码
|
||||
* @return 标准化后的可见范围
|
||||
*/
|
||||
private VisibilityScope parseVisibilityScope(String visibilityScope) {
|
||||
try {
|
||||
return VisibilityScope.from(visibilityScope);
|
||||
} catch (IllegalArgumentException error) {
|
||||
throw new BusinessException(error.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 规范并校验 Agent 运行配置中的文档上下文预算。
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user