diff --git a/src-tauri/recipes.json b/src-tauri/recipes.json index f1eec82..ed3144d 100644 --- a/src-tauri/recipes.json +++ b/src-tauri/recipes.json @@ -3,7 +3,7 @@ { "id": "dedicated-channel-agent", "name": "Create dedicated Agent for Channel", - "description": "Create an independent agent, set its identity, bind it to a Discord channel, and configure persona", + "description": "Create an agent, optionally independent with its own identity and persona, and bind it to a Discord channel", "version": "1.0.0", "tags": ["discord", "agent", "persona"], "difficulty": "easy", @@ -11,12 +11,13 @@ { "id": "agent_id", "label": "Agent ID", "type": "string", "required": true, "placeholder": "e.g. my-bot" }, { "id": "guild_id", "label": "Guild", "type": "discord_guild", "required": true }, { "id": "channel_id", "label": "Channel", "type": "discord_channel", "required": true }, - { "id": "name", "label": "Display Name", "type": "string", "required": false, "placeholder": "e.g. MyBot" }, - { "id": "emoji", "label": "Emoji", "type": "string", "required": false, "placeholder": "e.g. \ud83e\udd16" }, - { "id": "persona", "label": "Persona", "type": "textarea", "required": false, "placeholder": "You are..." } + { "id": "independent", "label": "Create independent agent", "type": "boolean", "required": false }, + { "id": "name", "label": "Display Name", "type": "string", "required": false, "placeholder": "e.g. MyBot", "dependsOn": "independent" }, + { "id": "emoji", "label": "Emoji", "type": "string", "required": false, "placeholder": "e.g. \ud83e\udd16", "dependsOn": "independent" }, + { "id": "persona", "label": "Persona", "type": "textarea", "required": false, "placeholder": "You are...", "dependsOn": "independent" } ], "steps": [ - { "action": "create_agent", "label": "Create independent agent", "args": { "agentId": "{{agent_id}}", "independent": true } }, + { "action": "create_agent", "label": "Create agent", "args": { "agentId": "{{agent_id}}", "independent": "{{independent}}" } }, { "action": "setup_identity", "label": "Set agent identity", "args": { "agentId": "{{agent_id}}", "name": "{{name}}", "emoji": "{{emoji}}" } }, { "action": "bind_channel", "label": "Bind channel to agent", "args": { "channelType": "discord", "peerId": "{{channel_id}}", "agentId": "{{agent_id}}" } }, { "action": "config_patch", "label": "Set channel persona", "args": { "patchTemplate": "{\"channels\":{\"discord\":{\"guilds\":{\"{{guild_id}}\":{\"channels\":{\"{{channel_id}}\":{\"systemPrompt\":\"{{persona}}\"}}}}}}}" } } diff --git a/src-tauri/src/recipe.rs b/src-tauri/src/recipe.rs index c467569..0227cf1 100644 --- a/src-tauri/src/recipe.rs +++ b/src-tauri/src/recipe.rs @@ -28,6 +28,8 @@ pub struct RecipeParam { pub max_length: Option, #[serde(skip_serializing_if = "Option::is_none")] pub placeholder: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub depends_on: Option, } #[derive(Debug, Serialize, Deserialize, Clone)] diff --git a/src/components/ParamForm.tsx b/src/components/ParamForm.tsx index 922b271..57a818e 100644 --- a/src/components/ParamForm.tsx +++ b/src/components/ParamForm.tsx @@ -5,6 +5,7 @@ import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; import { Label } from "@/components/ui/label"; import { Button } from "@/components/ui/button"; +import { Checkbox } from "@/components/ui/checkbox"; import { Select, SelectContent, @@ -91,9 +92,15 @@ export function ParamForm({ return discordGuildChannels.filter((gc) => gc.guildId === guildId); }, [discordGuildChannels, values]); + const isParamVisible = (param: RecipeParam) => { + if (!param.dependsOn) return true; + return values[param.dependsOn] === "true"; + }; + const errors = useMemo(() => { const next: Record = {}; for (const param of recipe.params) { + if (!isParamVisible(param)) continue; const err = validateField(param, values[param.id] || ""); if (err) { next[param.id] = err; @@ -104,6 +111,21 @@ export function ParamForm({ const hasError = Object.keys(errors).length > 0; function renderParam(param: RecipeParam) { + if (param.type === "boolean") { + return ( +
+ { + onChange(param.id, checked === true ? "true" : "false"); + }} + /> + +
+ ); + } + if (param.type === "discord_guild") { return (