()
| 11 | } from "../exclude-models.js"; |
| 12 | |
| 13 | export function createExcludeCommand(): OpenClawPluginCommandDefinition { |
| 14 | return { |
| 15 | name: "exclude", |
| 16 | description: "Manage excluded models — /exclude add|remove|clear <model>", |
| 17 | acceptsArgs: true, |
| 18 | requireAuth: true, |
| 19 | handler: async (ctx: PluginCommandContext) => { |
| 20 | const args = ctx.args?.trim() || ""; |
| 21 | const parts = args.split(/\s+/); |
| 22 | const subcommand = parts[0]?.toLowerCase() || ""; |
| 23 | const modelArg = parts.slice(1).join(" ").trim(); |
| 24 | |
| 25 | // /exclude (no args) — show current list |
| 26 | if (!subcommand) { |
| 27 | const list = loadExcludeList(); |
| 28 | if (list.size === 0) { |
| 29 | return { |
| 30 | text: "No models excluded.\n\nUsage:\n /exclude add <model> — block a model\n /exclude remove <model> — unblock\n /exclude clear — remove all", |
| 31 | }; |
| 32 | } |
| 33 | const models = [...list] |
| 34 | .sort() |
| 35 | .map((m) => ` • ${m}`) |
| 36 | .join("\n"); |
| 37 | return { |
| 38 | text: `Excluded models (${list.size}):\n${models}\n\nUse /exclude remove <model> to unblock.`, |
| 39 | }; |
| 40 | } |
| 41 | |
| 42 | // /exclude add <model> |
| 43 | if (subcommand === "add") { |
| 44 | if (!modelArg) { |
| 45 | return { |
| 46 | text: "Usage: /exclude add <model>\nExample: /exclude add nvidia/gpt-oss-120b", |
| 47 | isError: true, |
| 48 | }; |
| 49 | } |
| 50 | const resolved = addExclusion(modelArg); |
| 51 | const list = loadExcludeList(); |
| 52 | return { |
| 53 | text: `Excluded: ${resolved}\n\nActive exclusions (${list.size}):\n${[...list] |
| 54 | .sort() |
| 55 | .map((m) => ` • ${m}`) |
| 56 | .join("\n")}`, |
| 57 | }; |
| 58 | } |
| 59 | |
| 60 | // /exclude remove <model> |
| 61 | if (subcommand === "remove") { |
| 62 | if (!modelArg) { |
| 63 | return { text: "Usage: /exclude remove <model>", isError: true }; |
| 64 | } |
| 65 | const removed = removeExclusion(modelArg); |
| 66 | if (!removed) { |
| 67 | return { text: `Model "${modelArg}" was not in the exclude list.` }; |
| 68 | } |
| 69 | const list = loadExcludeList(); |
| 70 | return { |
no test coverage detected