Skip to content

Commit 31a48fa

Browse files
committed
Support manual approval for specific tools.
Fixes #44
1 parent 57cf6ba commit 31a48fa

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Support manual approval for specific tools. #44
6+
57
## 0.25.0
68

79
- Improve plan-mode to do file changes with diffs.

docs/configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ interface Config {
205205
};
206206
disabledTools: string[],
207207
toolCall?: {
208-
manualApproval?: boolean,
208+
manualApproval?: boolean | string[], // manual approve all tools or the specified tools
209209
};
210210
mcpTimeoutSeconds: number;
211211
mcpServers: {[key: string]: {
@@ -255,7 +255,7 @@ interface Config {
255255
"excludeCommands": []}},
256256
"disabledTools": [],
257257
"toolCall": {
258-
"manualApproval": false,
258+
"manualApproval": null,
259259
},
260260
"mcpTimeoutSeconds" : 10,
261261
"mcpServers" : [],

src/eca/features/chat.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@
107107
:state :running
108108
:text "Parsing given context"}))
109109
(let [db @db*
110-
manual-approval? (get-in config [:toolCall :manualApproval] false)
111110
all-models (models/all)
112111
provider (get-in all-models [model :provider])
113112
rules (f.rules/all config (:workspace-folders db))
@@ -175,7 +174,7 @@
175174
:origin (tool-name->origin name all-tools)
176175
:arguments-text (get-in @tool-call-by-id* [id :args])
177176
:id id
178-
:manual-approval manual-approval?}
177+
:manual-approval (f.tools/manual-approval? name config)}
179178
:summary (f.tools/tool-call-summary all-tools name nil))))
180179
:on-tools-called (fn [tool-calls]
181180
(assert-chat-not-stopped! chat-ctx)
@@ -188,7 +187,8 @@
188187
(let [approved?* (promise)
189188
details (f.tools/get-tool-call-details name arguments)
190189
summary (f.tools/tool-call-summary all-tools name arguments)
191-
origin (tool-name->origin name all-tools)]
190+
origin (tool-name->origin name all-tools)
191+
manual-approval? (f.tools/manual-approval? name config)]
192192
;; Inform UI the tool is about to run and store approval promise
193193
(send-content! chat-ctx :assistant
194194
(assoc-some

src/eca/features/tools.clj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@
112112
(assoc :type :mcp)
113113
(update :tools #(mapv with-tool-status %)))))})))
114114

115+
(defn manual-approval? [name config]
116+
(let [manual-approval? (get-in config [:toolCall :manualApproval] nil)]
117+
(logger/info manual-approval?
118+
(coll? manual-approval?)
119+
name)
120+
(if (coll? manual-approval?)
121+
(some #(= name (str %)) manual-approval?)
122+
manual-approval?)))
123+
115124
(defn tool-call-summary [all-tools name args]
116125
(when-let [summary-fn (:summary-fn (first (filter #(= name (:name %))
117126
all-tools)))]

0 commit comments

Comments
 (0)