()
| 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; |
nothing calls this directly
no test coverage detected