Skip to content

Commit 5f70fec

Browse files
committed
Refactor contents to be generic tools with source
1 parent 8e8632a commit 5f70fec

File tree

11 files changed

+60
-53
lines changed

11 files changed

+60
-53
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Unreleased
44

5-
- Add built-in tools: filesystem
5+
- Add native tools: filesystem
66
- Add MCP/tool support for ollama models.
77

88
## 0.1.0

docs/capabilities.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Capabilities
22

3-
## Built-in tools
3+
## Native tools
44

5-
ECA support built-in tools to avoid user extra installation and configuration, these tools are always included on models requests that support tools and can be disabled/configured via config `built-in-tools`.
5+
ECA support built-in tools to avoid user extra installation and configuration, these tools are always included on models requests that support tools and can be disabled/configured via config `nativeTools`.
66

77
### Filesystem
88

docs/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ interface Config {
117117
"openaiApiKey" : null,
118118
"anthropicApiKey" : null,
119119
"rules" : [ ],
120-
"builtInTools": {"filesystem": {"enabled": true}},
120+
"nativeTools": {"filesystem": {"enabled": true}},
121121
"mcpTimeoutSeconds" : 10,
122122
"mcpServers" : [ ],
123123
"ollama" : {

docs/protocol.md

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,9 @@ type ChatContent =
396396
| URLContent
397397
| ProgressContent
398398
| FileChangeContent
399-
| MCPToolCallPrepareContent
400-
| MCPToolCallRunContent
401-
| MCPToolCalledContent;
399+
| ToolCallPrepareContent
400+
| ToolCallRunContent
401+
| ToolCalledContent;
402402

403403
/**
404404
* Simple text message from the LLM
@@ -497,10 +497,12 @@ interface FileChangeContent {
497497
}
498498

499499
/**
500-
* MCP tool call that LLM is preparing to execute.
500+
* Tool call that LLM is preparing to execute.
501501
*/
502-
interface MCPToolCallPrepareContent {
503-
type: 'mcpToolCallPrepare';
502+
interface ToolCallPrepareContent {
503+
type: 'toolCallPrepare';
504+
505+
origin: ToolCallOrigin;
504506

505507
/**
506508
* id of the tool call
@@ -524,10 +526,12 @@ interface MCPToolCallPrepareContent {
524526
}
525527

526528
/**
527-
* MCP tool call final request that LLM may trigger.
529+
* Tool call final request that LLM may trigger.
528530
*/
529-
interface MCPToolCallRunContent {
530-
type: 'mcpToolCallRun';
531+
interface ToolCallRunContent {
532+
type: 'toolCallRun';
533+
534+
origin: ToolCallOrigin;
531535

532536
/**
533537
* id of the tool call
@@ -551,10 +555,12 @@ interface MCPToolCallRunContent {
551555
}
552556

553557
/**
554-
* MCP tool call result that LLM trigerred and was executed already.
558+
* Tool call result that LLM trigerred and was executed already.
555559
*/
556-
interface MCPToolCalledContent {
557-
type: 'mcpToolCalled';
560+
interface ToolCalledContent {
561+
type: 'toolCalled';
562+
563+
origin: ToolCallOrigin;
558564

559565
/**
560566
* id of the tool call
@@ -572,7 +578,7 @@ interface MCPToolCalledContent {
572578
arguments: string[];
573579

574580
/**
575-
* the result of the MCP tool call.
581+
* the result of the tool call.
576582
*/
577583
outputs: [{
578584
/*
@@ -591,6 +597,8 @@ interface MCPToolCalledContent {
591597
error: boolean;
592598
}];
593599
}
600+
601+
type ToolCallOrigin = 'mcp' | 'native';
594602
```
595603

596604
### Chat Query Context (↩️)

src/eca/config.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
{:openaiApiKey nil
2020
:anthropicApiKey nil
2121
:rules []
22-
:builtInTools {:filesystem {:enabled true}}
22+
:nativeTools {:filesystem {:enabled true}}
2323
:mcpTimeoutSeconds 60
2424
:mcpServers {}
2525
:ollama {:host "http://localhost"

src/eca/db.clj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
:chats {}
1010
:chat-behaviors ["agent" "chat"]
1111
:chat-default-behavior "chat"
12-
:models {"o4-mini" {:mcp-tools true
12+
:models {"o4-mini" {:tools true
1313
:web-search false}
14-
"o3" {:mcp-tools true
14+
"o3" {:tools true
1515
:web-search false}
16-
"gpt-4.1" {:mcp-tools true
16+
"gpt-4.1" {:tools true
1717
:web-search true}
18-
"claude-sonnet-4-0" {:mcp-tools true
18+
"claude-sonnet-4-0" {:tools true
1919
:web-search true}
20-
"claude-opus-4-0" {:mcp-tools true
20+
"claude-opus-4-0" {:tools true
2121
:web-search true}
22-
"claude-3-5-haiku-latest" {:mcp-tools true
22+
"claude-3-5-haiku-latest" {:tools true
2323
:web-search true}} ;; + ollama local models
2424
:default-model "o4-mini" ;; unless a ollama model is running.
2525
:mcp-clients {}})

src/eca/features/chat.clj

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@
9494
chosen-model (or model (default-model db))
9595
past-messages (get-in db [:chats chat-id :messages] [])
9696
user-prompt message
97-
mcp-tools (when (get-in db [:models chosen-model :mcp-tools])
98-
(f.tools/all-tools @db* config))
97+
all-tools (f.tools/all-tools @db* config)
9998
received-msgs* (atom "")]
10099
(swap! db* update-in [:chats chat-id :messages] (fnil conj []) {:role "user" :content user-prompt})
101100
(messenger/chat-content-received
@@ -113,7 +112,7 @@
113112
:context context-str
114113
:past-messages past-messages
115114
:config config
116-
:mcp-tools mcp-tools
115+
:tools all-tools
117116
:on-first-message-received (fn [_]
118117
(messenger/chat-content-received
119118
messenger
@@ -160,7 +159,7 @@
160159
{:chat-id chat-id
161160
:request-id request-id
162161
:role :assistant
163-
:content {:type :mcpToolCallPrepare
162+
:content {:type :toolCallPrepare
164163
:name name
165164
:argumentText argument
166165
:id id
@@ -171,7 +170,7 @@
171170
{:chat-id chat-id
172171
:request-id request-id
173172
:role :assistant
174-
:content {:type :mcpToolCallRun
173+
:content {:type :toolCallRun
175174
:name name
176175
:arguments arguments
177176
:id id
@@ -182,7 +181,7 @@
182181
{:chat-id chat-id
183182
:request-id request-id
184183
:role :assistant
185-
:content {:type :mcpToolCalled
184+
:content {:type :toolCalled
186185
:name name
187186
:arguments arguments
188187
:id id

src/eca/features/tools.clj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(ns eca.features.tools
22
"This ns centralizes all available tools for LLMs including
3-
eca built-in tools and MCP servers."
3+
eca native tools and MCP servers."
44
(:require
55
[eca.features.tools.filesystem :as f.tools.filesystem]
66
[eca.features.tools.mcp :as f.mcp])
@@ -9,22 +9,22 @@
99

1010
(set! *warn-on-reflection* true)
1111

12-
(defn built-in-definitions [config]
12+
(defn native-definitions [config]
1313
(merge {}
14-
(when (get-in config [:builtInTools :filesystem :enabled])
14+
(when (get-in config [:nativeTools :filesystem :enabled])
1515
f.tools.filesystem/definitions)))
1616

1717
(defn all-tools [db config]
18-
(let [built-in-tools (concat
19-
[]
20-
(mapv #(select-keys % [:name :description :parameters])
21-
(vals (built-in-definitions config))))
18+
(let [native-tools (concat
19+
[]
20+
(mapv #(select-keys % [:name :description :parameters])
21+
(vals (native-definitions config))))
2222
mcp-tools (f.mcp/all-tools db)]
2323
(concat
24-
(mapv #(assoc % :source :built-in) built-in-tools)
24+
(mapv #(assoc % :source :native) native-tools)
2525
(mapv #(assoc % :source :mcp) mcp-tools))))
2626

2727
(defn call-tool! [^String name ^Map arguments db config]
28-
(if-let [built-in-tool-handler (get-in (built-in-definitions config) [name :handler])]
29-
(built-in-tool-handler arguments db)
28+
(if-let [native-tool-handler (get-in (native-definitions config) [name :handler])]
29+
(native-tool-handler arguments db)
3030
(f.mcp/call-tool! name arguments db)))

src/eca/handlers.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
(swap! db* update :models merge
1616
(reduce
1717
(fn [models {:keys [model]}]
18-
(assoc models
19-
(str config/ollama-model-prefix model)
20-
{:mcp-tools (get-in config [:ollama :useTools] false)}))
18+
(assoc-in models
19+
(str config/ollama-model-prefix model)
20+
{:tools (get-in config [:ollama :useTools] false)}))
2121
{}
2222
ollama-models))))
2323

src/eca/llm_api.clj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
;; TODO ask LLM for the most relevant parts of the path
1818
(slurp path))
1919

20-
(defn ^:private mcp-tool->llm-tool [mcp-tool]
21-
(assoc (select-keys mcp-tool [:name :description :parameters])
20+
(defn ^:private tool->llm-tool [tool]
21+
(assoc (select-keys tool [:name :description :parameters])
2222
:type "function"))
2323

2424
(defn complete!
2525
[{:keys [model model-config context user-prompt config on-first-message-received
2626
on-message-received on-error on-prepare-tool-call on-tool-called on-reason
27-
past-messages mcp-tools]}]
27+
past-messages tools]}]
2828
(let [first-message-received* (atom false)
2929
on-message-received-wrapper (fn [& args]
3030
(when-not @first-message-received*
@@ -34,8 +34,8 @@
3434
on-error-wrapper (fn [& args]
3535
(apply logger/error args)
3636
(apply on-error args))
37-
tools (when (:mcp-tools model-config)
38-
(mapv mcp-tool->llm-tool mcp-tools))
37+
tools (when (:tools model-config)
38+
(mapv tool->llm-tool tools))
3939
web-search (:web-search model-config)]
4040
(cond
4141
(contains? #{"o4-mini"

0 commit comments

Comments
 (0)