Canvas: Support Anthropic Claude based AI agents
Change-Id: Ib74c9672da9a80a4f20d63741a471c728a435b8e
diff --git a/apps/canvas/front/src/lib/config.ts b/apps/canvas/front/src/lib/config.ts
index e2ad19d..1736916 100644
--- a/apps/canvas/front/src/lib/config.ts
+++ b/apps/canvas/front/src/lib/config.ts
@@ -396,11 +396,38 @@
function AgentApiKeyValidator(nodes: AppNode[], env: Env): Message[] {
return nodes
.filter((n): n is ServiceNode => n.type === "app" && n.data.type === "sketch:latest")
- .filter((n) => n.data.agent?.geminiApiKey == null && !env.integrations.gemini)
- .map((n) => ({
- id: `${n.id}-no-agent-api-key`,
- type: "FATAL",
- nodeId: n.id,
- message: "Configure Gemini API key either on the service or in the project integrations",
- }));
+ .flatMap((n) => {
+ const messages: Message[] = [];
+ const model = n.data.model;
+
+ if (!model || !model.name) {
+ messages.push({
+ id: `${n.id}-no-agent-model`,
+ type: "FATAL",
+ nodeId: n.id,
+ message: "Select an AI model for the agent (Gemini or Claude).",
+ });
+ return messages;
+ }
+
+ if (model.name === "gemini" && !model.apiKey && !env.integrations.gemini) {
+ messages.push({
+ id: `${n.id}-no-gemini-api-key`,
+ type: "FATAL",
+ nodeId: n.id,
+ message: "Configure Gemini API key either on the service or in the project integrations.",
+ });
+ }
+
+ if (model.name === "claude" && !model.apiKey && !env.integrations.anthropic) {
+ messages.push({
+ id: `${n.id}-no-anthropic-api-key`,
+ type: "FATAL",
+ nodeId: n.id,
+ message: "Configure Anthropic API key either on the service or in the project integrations.",
+ });
+ }
+
+ return messages;
+ });
}