feat: expose AI page recipes
This commit is contained in:
@@ -62,6 +62,7 @@ import com.eip4.platform.metadata.schema.TypedPageSchemaIssue;
|
||||
import com.eip4.platform.metadata.schema.TypedPageSchemaReport;
|
||||
import com.eip4.platform.metadata.schema.TypedPageSchemaValidator;
|
||||
import com.eip4.platform.metadata.schema.blueprint.PageBlueprint;
|
||||
import com.eip4.platform.metadata.schema.blueprint.PageRecipeDefinition;
|
||||
import com.eip4.platform.metadata.schema.blueprint.PageRecipeRegistry;
|
||||
import com.eip4.platform.metadata.schema.blueprint.PageRecipeValidationReport;
|
||||
import com.eip4.platform.metadata.schema.blueprint.PageRecipeValidator;
|
||||
@@ -90,6 +91,7 @@ public class AiAgentService {
|
||||
private final ObjectMapper objectMapper;
|
||||
private final AiToolRegistry toolRegistry;
|
||||
private final TypedPageSchemaValidator typedSchemaValidator;
|
||||
private final PageRecipeRegistry pageRecipeRegistry;
|
||||
private final PageRecipeValidator pageRecipeValidator;
|
||||
|
||||
private static volatile SchemaGate sharedSchemaGate;
|
||||
@@ -127,7 +129,8 @@ public class AiAgentService {
|
||||
this.typedSchemaValidator = typedSchemaValidator == null
|
||||
? new TypedPageSchemaValidator(objectMapper, PageComponentRegistry.defaults())
|
||||
: typedSchemaValidator;
|
||||
this.pageRecipeValidator = new PageRecipeValidator(objectMapper, PageRecipeRegistry.defaults());
|
||||
this.pageRecipeRegistry = PageRecipeRegistry.defaults();
|
||||
this.pageRecipeValidator = new PageRecipeValidator(objectMapper, pageRecipeRegistry);
|
||||
}
|
||||
|
||||
public AiTask createTask(String objective) {
|
||||
@@ -760,6 +763,16 @@ public class AiAgentService {
|
||||
return toolRegistry.employees();
|
||||
}
|
||||
|
||||
public List<PageRecipeDefinition> listPageRecipes() {
|
||||
return pageRecipeRegistry.definitions();
|
||||
}
|
||||
|
||||
public PageRecipeDefinition getPageRecipe(String recipe) {
|
||||
return pageRecipeRegistry.find(recipe)
|
||||
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND,
|
||||
"页面 recipe 不存在: " + (recipe == null ? "" : recipe)));
|
||||
}
|
||||
|
||||
public AiToolAccessDecision checkToolAccess(AiToolAccessRequest request) {
|
||||
return toolRegistry.check(request);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,10 @@ public final class AiToolRegistry {
|
||||
"Validate AMIS and typed page schema before saving or packaging.",
|
||||
List.of("POST /api/ai/tools/validate-schema", "POST /api/page/schema/validate"),
|
||||
List.of("ai:schema:validate"), false, false);
|
||||
registerTool(tools, "page-recipe.read", "design-contract",
|
||||
"Read EIP4 page recipes and UI/UE constraints before generating page blueprints.",
|
||||
List.of("GET /api/ai/page-recipes", "GET /api/ai/page-recipes/{recipe}"),
|
||||
List.of("ai:page-recipe:read"), false, false);
|
||||
registerTool(tools, "local.apply", "local-gate",
|
||||
"Apply a change set to a local EIP4 environment only.",
|
||||
List.of("POST /api/ai/tasks/{taskId}/change-sets/{changeSetId}/local-apply"),
|
||||
@@ -56,9 +60,9 @@ public final class AiToolRegistry {
|
||||
Map<String, AiEmployeeDefinition> employees = new LinkedHashMap<>();
|
||||
registerEmployee(employees, "agent-developer", "Agent Developer",
|
||||
"Develops EIP4 feature packages in local environments.",
|
||||
List.of("feature.draft.generate", "schema.validate", "local.apply", "smoke.run",
|
||||
List.of("feature.draft.generate", "schema.validate", "page-recipe.read", "local.apply", "smoke.run",
|
||||
"feature.package", "release.prepare"),
|
||||
List.of("ai:feature:draft", "ai:schema:validate", "ai:local:apply", "ai:smoke:run",
|
||||
List.of("ai:feature:draft", "ai:schema:validate", "ai:page-recipe:read", "ai:local:apply", "ai:smoke:run",
|
||||
"ai:package:create", "ai:release:prepare"),
|
||||
List.of("Local apply only", "Production deployment requires human operator"));
|
||||
registerEmployee(employees, "release-auditor", "Release Auditor",
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.eip4.platform.ai.model.AiToolAccessRequest;
|
||||
import com.eip4.platform.ai.model.AiToolDefinition;
|
||||
import com.eip4.platform.ai.model.AiEmployeeDefinition;
|
||||
import com.eip4.platform.ai.service.AiAgentService;
|
||||
import com.eip4.platform.metadata.schema.blueprint.PageRecipeDefinition;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -207,6 +208,18 @@ public class AiAgentController {
|
||||
return service.listEmployees();
|
||||
}
|
||||
|
||||
@Operation(summary = "列出 AI 页面 recipe", description = "返回 Agent 生成页面前必须读取的 EIP4 UI/UE recipe 定义")
|
||||
@GetMapping("/page-recipes")
|
||||
public List<PageRecipeDefinition> pageRecipes() {
|
||||
return service.listPageRecipes();
|
||||
}
|
||||
|
||||
@Operation(summary = "查看 AI 页面 recipe", description = "按 recipe id 返回字段映射、门禁和版本信息")
|
||||
@GetMapping("/page-recipes/{recipe}")
|
||||
public PageRecipeDefinition pageRecipe(@PathVariable String recipe) {
|
||||
return service.getPageRecipe(recipe);
|
||||
}
|
||||
|
||||
@Operation(summary = "检查 AI 工具访问权限", description = "只做权限判定,不执行工具;生产写默认阻断")
|
||||
@PostMapping("/tools/access-check")
|
||||
public AiToolAccessDecision checkToolAccess(@RequestBody(required = false) AiToolAccessRequest request) {
|
||||
|
||||
Reference in New Issue
Block a user