feat: add requiresApproval flag to support HITL workflows
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user