Implement agent node functionality in canvas, including connection policies and UI updates. Add support for agent node type in node catalog, templates, and connection validation. Update documentation to reflect new agent capabilities and ensure proper handling of input sources. Enhance adjustment preview to include crop node. Add tests for agent connection policies.

This commit is contained in:
2026-04-09 10:06:53 +02:00
parent b7f24223f2
commit 6d0c7b1ff6
18 changed files with 749 additions and 5 deletions

View File

@@ -0,0 +1,22 @@
import { describe, expect, it } from "vitest";
import { AGENT_TEMPLATES, getAgentTemplate } from "@/lib/agent-templates";
describe("agent templates", () => {
it("registers the campaign distributor template", () => {
expect(AGENT_TEMPLATES.map((template) => template.id)).toEqual([
"campaign-distributor",
]);
});
it("exposes normalized metadata needed by the canvas node", () => {
const template = getAgentTemplate("campaign-distributor");
expect(template?.name).toBe("Campaign Distributor");
expect(template?.color).toBe("yellow");
expect(template?.tools).toContain("WebFetch");
expect(template?.channels).toContain("Instagram Feed");
expect(template?.expectedInputs).toContain("Render-Node-Export");
expect(template?.expectedOutputs).toContain("Caption-Pakete");
});
});

View File

@@ -0,0 +1,32 @@
import { describe, expect, it } from "vitest";
import { nodeTypes } from "@/components/canvas/node-types";
import { CANVAS_NODE_TEMPLATES } from "@/lib/canvas-node-templates";
import { NODE_CATALOG, isNodePaletteEnabled } from "@/lib/canvas-node-catalog";
import { NODE_DEFAULTS, NODE_HANDLE_MAP } from "@/lib/canvas-utils";
describe("canvas agent config", () => {
it("registers the agent node type", () => {
expect(nodeTypes.agent).toBeTypeOf("function");
});
it("adds a campaign distributor palette template", () => {
expect(CANVAS_NODE_TEMPLATES.find((template) => template.type === "agent")?.label).toBe(
"Campaign Distributor",
);
});
it("enables the agent in the catalog", () => {
const entry = NODE_CATALOG.find((item) => item.type === "agent");
expect(entry).toBeDefined();
expect(entry && isNodePaletteEnabled(entry)).toBe(true);
});
it("keeps the agent input-only in MVP", () => {
expect(NODE_HANDLE_MAP.agent?.target).toBe("agent-in");
expect(NODE_HANDLE_MAP.agent?.source).toBeUndefined();
expect(NODE_DEFAULTS.agent?.data).toMatchObject({
templateId: "campaign-distributor",
});
});
});