feat: 完善 Agent 标准交互与安全运行时

- 接入 AG-UI 运行投影、Turn 时间线和审批隔离

- 增加 Agent Skill 冻结绑定与运行时消费闭环

- 增加受控工作区、内置工具和私有 Artifact 生命周期
This commit is contained in:
2026-08-19 22:13:41 +08:00
parent 91d66e636d
commit 4e8640dcaf
241 changed files with 24382 additions and 2777 deletions

View File

@@ -73,6 +73,34 @@ public class XFIleStorageServiceImpl implements FileStorageService {
return fileInfo.getUrl();
}
/**
* 使用指定前置目录上传后端本地文件。
*
* @param file 后端本地文件
* @param prePath 前置目录
* @return 文件 URL
* @throws IllegalArgumentException 文件不存在或不是普通文件时抛出
*/
@Override
public String save(File file, String prePath) {
if (file == null || !file.isFile()) {
throw new IllegalArgumentException("待上传的本地文件不存在");
}
String uploadPath = PathGeneratorUtil.generateUserPath("");
if (StringUtils.hasText(prePath)) {
String normalized = prePath.replaceAll("^/+", "").replaceAll("/+$", "");
uploadPath = "/" + normalized + uploadPath;
}
FileInfo fileInfo = fileStorageService.of(file)
.setPath(uploadPath)
.setSaveFilename(file.getName())
.upload();
if (fileInfo == null || !StringUtils.hasText(fileInfo.getUrl())) {
throw new RuntimeException("文件上传失败");
}
return fileInfo.getUrl();
}
/**
* 幂等删除指定文件;物理文件已不存在时同步清理残留记录。
*

View File

@@ -35,6 +35,26 @@ import static org.junit.Assert.assertTrue;
*/
public class XFIleStorageServiceImplTest {
/**
* 验证后端生成的本地文件可以通过统一 x-file-storage 路由上传。
*
* @throws Exception 创建临时文件或注入测试替身失败
*/
@Test
public void localFileSaveUsesRequestedPathAndFilename() throws Exception {
RecoverablePlatform platform = new RecoverablePlatform("minio-main", "attachment", "https://files/");
RecoverableStorageService delegate = new RecoverableStorageService(platform);
XFIleStorageServiceImpl service = createService(delegate);
File file = Files.createTempFile("generated-skill-", ".zip").toFile();
String url = service.save(file, "skill-imports/tenant-1");
assertEquals(file.getName(), delegate.uploadFilename);
assertTrue(delegate.uploadPath.startsWith("/skill-imports/tenant-1/"));
assertEquals("https://files/attachment" + delegate.uploadPath + file.getName(), url);
assertTrue(platform.exists);
}
/**
* 验证底层明确返回 false 时抛出带有效消息的异常。
*