MCPcopy
hub / github.com/BuilderIO/agent-native / handleAdd

Function handleAdd

packages/dispatch/src/components/agents-panel.tsx:49–88  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47 const builtinAgents = agents.filter((agent) => agent.source === "builtin");
48
49 const handleAdd = async () => {
50 const trimmedName = name.trim();
51 const trimmedUrl = url.trim();
52 if (!trimmedName || !trimmedUrl) return;
53
54 const id = trimmedName.toLowerCase().replace(/[^a-z0-9-]/g, "-");
55 const agentJson = JSON.stringify(
56 {
57 id,
58 name: trimmedName,
59 description: description.trim() || undefined,
60 url: trimmedUrl,
61 color: "#6B7280",
62 },
63 null,
64 2,
65 );
66
67 setSaving(true);
68 try {
69 const res = await fetch(agentNativePath("/_agent-native/resources"), {
70 method: "POST",
71 headers: { "Content-Type": "application/json" },
72 body: JSON.stringify({
73 path: `remote-agents/${id}.json`,
74 content: agentJson,
75 shared: true,
76 }),
77 });
78 if (res.ok) {
79 setName("");
80 setUrl("");
81 setDescription("");
82 onRefresh();
83 nameRef.current?.focus();
84 }
85 } finally {
86 setSaving(false);
87 }
88 };
89
90 const handleDelete = async (resourceId?: string) => {
91 if (!resourceId) return;

Callers

nothing calls this directly

Calls 3

agentNativePathFunction · 0.90
focusMethod · 0.80
fetchFunction · 0.50

Tested by

no test coverage detected