feat: add requiresApproval flag to support HITL workflows

This commit is contained in:
jade
2026-07-10 11:44:38 +09:00
parent 79ce26fafc
commit 749d942049
8 changed files with 47 additions and 3 deletions

View File

@@ -62,6 +62,10 @@ public class ToolMetadata {
@Builder.Default
private Boolean isRegistered = true;
// 2-6. HITL 승인 필요 여부
@Builder.Default
private Boolean requiresApproval = false;
public boolean isVisible() {
return visible != null ? visible : true;
}
@@ -74,6 +78,10 @@ public class ToolMetadata {
this.isRegistered = isRegistered;
}
public boolean isRequiresApproval() {
return requiresApproval != null ? requiresApproval : false;
}
// 3. 연동 아키텍처 구분 (DIRECT / MCI_EAI)
private String integrationType; // 연동 타입: "DIRECT" 또는 "MCI_EAI"

View File

@@ -190,7 +190,8 @@ public class ToolScaffolder {
description = "%s",
prompt = "%s",
mappingId = "%s",
register = %s
register = %s,
requiresApproval = false
)
public Object execute(%sReq req) {
return executeLegacy("%s", "%s", req);

View File

@@ -12,7 +12,7 @@ import java.util.stream.Stream;
public class ToolSourceUpdater {
public static void updateToolSource(String toolName, String domainGroup, String description, boolean register) throws Exception {
public static void updateToolSource(String toolName, String domainGroup, String description, boolean register, Boolean requiresApproval) throws Exception {
// 1. Find all *Service.java files in axhub-tool-* directories
String envSourceDir = System.getenv("AXHUB_SOURCE_DIR");
Path rootDir = envSourceDir != null ? Paths.get(envSourceDir) : Paths.get(".");
@@ -87,6 +87,21 @@ public class ToolSourceUpdater {
}
}
// 5.5 Update requiresApproval flag
if (requiresApproval != null) {
Pattern appPattern = Pattern.compile("(@McpFunction\\s*\\([^)]*name\\s*=\\s*\"" + Pattern.quote(toolName) + "\"[^)]*requiresApproval\\s*=\\s*)(true|false)([^a-zA-Z0-9])", Pattern.DOTALL);
Matcher appMatcher = appPattern.matcher(content);
if (appMatcher.find()) {
content = appMatcher.replaceFirst("$1" + requiresApproval + "$3");
} else {
Pattern addAppPattern = Pattern.compile("(@McpFunction\\s*\\([^)]*name\\s*=\\s*\"" + Pattern.quote(toolName) + "\")", Pattern.DOTALL);
Matcher addAppMatcher = addAppPattern.matcher(content);
if (addAppMatcher.find()) {
content = addAppMatcher.replaceFirst("$1, requiresApproval = " + requiresApproval);
}
}
}
// 6. Write back to file
Files.writeString(targetFile, content);
}