Skip to content

Commit 0e3ef68

Browse files
committed
Auto-approve eca__read_file for tool call output cache files (~/.cache/eca/toolCallOutputs).
1 parent fcfe91d commit 0e3ef68

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
- Fix MCP server initialization crash (`String cannot be cast to IPersistentCollection`) when OAuth metadata endpoint returns a non-JSON or error response.
6+
- Auto-approve `eca__read_file` for tool call output cache files (`~/.cache/eca/toolCallOutputs`).
67

78
## 0.110.3
89

src/eca/features/tools/util.clj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,14 @@
6969

7070
(defn path-outside-workspace?
7171
"Returns true if `path` is outside any workspace root in `db`.
72+
Paths inside the ECA tool-call-outputs cache dir are always considered 'inside'.
7273
Works for existing or non-existing paths by absolutizing."
7374
[db path]
7475
(let [p (when path (str (fs/absolutize path)))
7576
roots (workspace-root-paths db)]
76-
(and p (not-any? #(fs/starts-with? p %) roots))))
77+
(and p
78+
(not (fs/starts-with? p (str (cache/tool-call-outputs-dir))))
79+
(not-any? #(fs/starts-with? p %) roots))))
7780

7881
(defn require-approval-when-outside-workspace
7982
"Returns a function suitable for tool `:require-approval-fn` that triggers

test/eca/features/tools/util_test.clj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
[clojure.test :refer [deftest is testing use-fixtures]]
77
[eca.cache :as cache]
88
[eca.features.tools.util :as tools.util]
9+
[eca.test-helper :as h]
910
[matcher-combinators.test :refer [match?]]))
1011

1112
(def ^:private test-tool-call-id "test-truncation-call-1")
@@ -146,3 +147,12 @@
146147
(let [result (make-result "")
147148
config (config-with-truncation 5 10)]
148149
(is (= result (tools.util/maybe-truncate-output result config "call-empty"))))))
150+
151+
(deftest path-outside-workspace-allows-tool-call-outputs-dir-test
152+
(testing "path inside tool-call-outputs cache dir is not considered outside workspace"
153+
(let [db {:workspace-folders [{:uri (h/file-uri "file:///home/user/project") :name "project"}]}
154+
cache-path (str (cache/tool-call-outputs-dir) "/some-call-id.txt")]
155+
(is (false? (tools.util/path-outside-workspace? db cache-path)))))
156+
(testing "path outside workspace and not in cache dir is still outside"
157+
(let [db {:workspace-folders [{:uri (h/file-uri "file:///home/user/project") :name "project"}]}]
158+
(is (true? (tools.util/path-outside-workspace? db (h/file-path "/tmp/random/file.txt")))))))

0 commit comments

Comments
 (0)