-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgithub.copilot-sdk.tools.html
More file actions
41 lines (40 loc) · 10.8 KB
/
github.copilot-sdk.tools.html
File metadata and controls
41 lines (40 loc) · 10.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>github.copilot-sdk.tools documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name"></span> <span class="project-version"></span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 "><a href="API.html"><div class="inner"><span>API Reference</span></div></a></li><li class="depth-1 "><a href="azure-managed-identity.html"><div class="inner"><span>Azure Managed Identity with BYOK</span></div></a></li><li class="depth-1 "><a href="byok.html"><div class="inner"><span>BYOK (Bring Your Own Key)</span></div></a></li><li class="depth-1 "><a href="custom-agents.html"><div class="inner"><span>Custom Agents & Sub-Agent Orchestration</span></div></a></li><li class="depth-1 "><a href="debugging.html"><div class="inner"><span>MCP Server Debugging Guide</span></div></a></li><li class="depth-1 "><a href="getting-started.html"><div class="inner"><span>Getting Started with the Copilot SDK for Clojure</span></div></a></li><li class="depth-1 "><a href="index.html"><div class="inner"><span>Authentication</span></div></a></li><li class="depth-1 "><a href="index.html"><div class="inner"><span>Documentation</span></div></a></li><li class="depth-1 "><a href="overview.html"><div class="inner"><span>Using MCP Servers with the Copilot SDK for Clojure</span></div></a></li><li class="depth-1 "><a href="style.html"><div class="inner"><span>Documentation Style Guide</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>github</span></div></div></li><li class="depth-2"><a href="github.copilot-sdk.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>copilot-sdk</span></div></a></li><li class="depth-3 branch"><a href="github.copilot-sdk.client.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>client</span></div></a></li><li class="depth-3 branch"><a href="github.copilot-sdk.helpers.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>helpers</span></div></a></li><li class="depth-3 branch"><a href="github.copilot-sdk.instrument.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>instrument</span></div></a></li><li class="depth-3 branch"><a href="github.copilot-sdk.logging.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>logging</span></div></a></li><li class="depth-3 branch"><a href="github.copilot-sdk.process.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>process</span></div></a></li><li class="depth-3 branch"><a href="github.copilot-sdk.protocol.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>protocol</span></div></a></li><li class="depth-3 branch"><a href="github.copilot-sdk.session.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>session</span></div></a></li><li class="depth-3 branch"><a href="github.copilot-sdk.specs.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>specs</span></div></a></li><li class="depth-3 branch current"><a href="github.copilot-sdk.tools.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>tools</span></div></a></li><li class="depth-3"><a href="github.copilot-sdk.util.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>util</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="github.copilot-sdk.tools.html#var-convert-mcp-call-tool-result"><div class="inner"><span>convert-mcp-call-tool-result</span></div></a></li><li class="depth-1"><a href="github.copilot-sdk.tools.html#var-define-tool"><div class="inner"><span>define-tool</span></div></a></li><li class="depth-1"><a href="github.copilot-sdk.tools.html#var-define-tool-from-spec"><div class="inner"><span>define-tool-from-spec</span></div></a></li><li class="depth-1"><a href="github.copilot-sdk.tools.html#var-result-denied"><div class="inner"><span>result-denied</span></div></a></li><li class="depth-1"><a href="github.copilot-sdk.tools.html#var-result-failure"><div class="inner"><span>result-failure</span></div></a></li><li class="depth-1"><a href="github.copilot-sdk.tools.html#var-result-rejected"><div class="inner"><span>result-rejected</span></div></a></li><li class="depth-1"><a href="github.copilot-sdk.tools.html#var-result-success"><div class="inner"><span>result-success</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">github.copilot-sdk.tools</h1><div class="doc"><div class="markdown"><p>Helper functions for defining tools.</p>
</div></div><div class="public anchor" id="var-convert-mcp-call-tool-result"><h3>convert-mcp-call-tool-result</h3><div class="usage"><code>(convert-mcp-call-tool-result {:keys [content is-error]})</code></div><div class="doc"><div class="markdown"><p>Convert an MCP CallToolResult into the SDK’s ToolResultObject format.</p>
<p>The input map should have Clojure-idiomatic keys: - :content - vector of content blocks, each with :type and type-specific fields - :is-error - optional boolean, when true the result-type is “failure”</p>
<p>Content block types: - {:type “text” :text “…”} - {:type “image” :data “base64…” :mime-type “image/png”} - {:type “resource” :resource {:uri “…” :text “…” :blob “…” :mime-type “…”}}</p>
<p>Returns a ToolResultObject map with :text-result-for-llm, :result-type, and optionally :binary-results-for-llm.</p>
</div></div></div><div class="public anchor" id="var-define-tool"><h3>define-tool</h3><div class="usage"><code>(define-tool name {:keys [description parameters handler overrides-built-in-tool]})</code></div><div class="doc"><div class="markdown"><p>Define a tool with a handler function.</p>
<p>Arguments: - name - Tool name (string) - opts map: - :description - Tool description - :parameters - JSON schema for parameters (or nil) - :handler - Function (fn <a href="args invocation">args invocation</a> -> result) - :overrides-built-in-tool - When true, explicitly overrides a built-in tool of the same name. Without this flag, name clashes with built-in tools cause an error.</p>
<p>The handler receives: - args - The parsed arguments from the LLM (no key conversion) - invocation - Map with :session-id, :tool-call-id, :tool-name, :arguments</p>
<p>The handler should return one of: - A string (treated as success) - A map with :text-result-for-llm and :result-type - Any other value (JSON-encoded as success) - A core.async channel that will yield one of the above</p>
<p>Example:</p>
<pre><code class="language-clojure">(define-tool "get_weather"
{:description "Get weather for a location"
:parameters {:type "object"
:properties {:location {:type "string"}}
:required ["location"]}
:handler (fn [args _]
(str "Weather in " (:location args) ": Sunny, 72°F"))})
</code></pre>
</div></div></div><div class="public anchor" id="var-define-tool-from-spec"><h3>define-tool-from-spec</h3><div class="usage"><code>(define-tool-from-spec name {:keys [description spec handler overrides-built-in-tool]})</code></div><div class="doc"><div class="markdown"><p>Define a tool using a clojure.spec for parameter validation.</p>
<p>Parameters are validated against the spec at invocation time. Note: the spec is NOT auto-converted to JSON schema, so this tool has no parameter schema advertised to the model. For tools that need a parameter schema, use define-tool with an explicit JSON schema.</p>
<p>Arguments: - name - Tool name (string) - opts map: - :description - Tool description - :spec - A clojure.spec for the arguments - :handler - Function (fn <a href="args invocation">args invocation</a> -> result) - :overrides-built-in-tool - When true, overrides a built-in tool of the same name</p>
<p>Example:</p>
<pre><code class="language-clojure">(s/def ::location string?)
(s/def ::get-weather-args (s/keys :req-un [::location]))
(define-tool-from-spec "get_weather"
{:description "Get weather for a location"
:spec ::get-weather-args
:handler (fn [args _]
(if (s/valid? ::get-weather-args args)
(str "Weather: Sunny")
{:text-result-for-llm (str "Invalid args: " (s/explain-str ::get-weather-args args))
:result-type "failure"}))})
</code></pre>
</div></div></div><div class="public anchor" id="var-result-denied"><h3>result-denied</h3><div class="usage"><code>(result-denied text)</code><code>(result-denied text telemetry)</code></div><div class="doc"><div class="markdown"><p>Create a denied tool result (permission denied).</p>
</div></div></div><div class="public anchor" id="var-result-failure"><h3>result-failure</h3><div class="usage"><code>(result-failure text)</code><code>(result-failure text error)</code><code>(result-failure text error telemetry)</code></div><div class="doc"><div class="markdown"><p>Create a failed tool result.</p>
</div></div></div><div class="public anchor" id="var-result-rejected"><h3>result-rejected</h3><div class="usage"><code>(result-rejected text)</code><code>(result-rejected text telemetry)</code></div><div class="doc"><div class="markdown"><p>Create a rejected tool result (user rejected).</p>
</div></div></div><div class="public anchor" id="var-result-success"><h3>result-success</h3><div class="usage"><code>(result-success text)</code><code>(result-success text telemetry)</code></div><div class="doc"><div class="markdown"><p>Create a successful tool result.</p>
</div></div></div></div></body></html>