From 24ae4be98b31e8c769e3de7323cbeacb1c2d6900 Mon Sep 17 00:00:00 2001 From: Tilak Patel Date: Sun, 12 Apr 2026 17:23:13 -0400 Subject: [PATCH] added skip permission from main sdk to port --- include/copilot/types.hpp | 17 +++++++++++++++++ src/client.cpp | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/include/copilot/types.hpp b/include/copilot/types.hpp index 2bac8e3..a7b5f59 100644 --- a/include/copilot/types.hpp +++ b/include/copilot/types.hpp @@ -901,6 +901,23 @@ struct Tool std::string description; json parameters_schema; ToolHandler handler; + + /// When true, this tool executes without triggering a permission prompt. + /// Use for read-only or otherwise safe tools. + bool skip_permission = false; + + /// When true, allows this tool to replace a built-in CLI tool + /// (e.g. edit_file, read_file). Without this flag, registering a tool + /// with a built-in name will cause an error. + bool overrides_built_in_tool = false; + + /// Fluent setter — mark this tool as not requiring permission prompts + Tool& with_skip_permission(bool value = true) & { skip_permission = value; return *this; } + Tool with_skip_permission(bool value = true) && { skip_permission = value; return std::move(*this); } + + /// Fluent setter — mark this tool as replacing a built-in CLI tool + Tool& with_overrides_built_in_tool(bool value = true) & { overrides_built_in_tool = value; return *this; } + Tool with_overrides_built_in_tool(bool value = true) && { overrides_built_in_tool = value; return std::move(*this); } }; // ============================================================================= diff --git a/src/client.cpp b/src/client.cpp index 166cc08..7ea833c 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -56,6 +56,10 @@ json build_session_create_request(const SessionConfig& config) def["description"] = tool.description; if (!tool.parameters_schema.is_null()) def["parameters"] = tool.parameters_schema; + if (tool.skip_permission) + def["skipPermission"] = true; + if (tool.overrides_built_in_tool) + def["overridesBuiltInTool"] = true; tool_defs.push_back(def); } request["tools"] = tool_defs; @@ -125,6 +129,10 @@ json build_session_resume_request(const std::string& session_id, const ResumeSes def["description"] = tool.description; if (!tool.parameters_schema.is_null()) def["parameters"] = tool.parameters_schema; + if (tool.skip_permission) + def["skipPermission"] = true; + if (tool.overrides_built_in_tool) + def["overridesBuiltInTool"] = true; tool_defs.push_back(def); } request["tools"] = tool_defs;