Commit a2547ec
Changed files (7)
lib
elelem
lib/elelem/states/working.rb
@@ -19,18 +19,7 @@ module Elelem
state = state.run(message)
end
- break if state.nil?
- break if agent.conversation.history.last[:role] == :assistant && agent.conversation.history.last[:content]&.strip&.end_with?("I am finished with the task.")
-
- # For simple responses, check if we should return to idle
- if done && agent.conversation.history.last[:role] == :assistant &&
- !agent.conversation.history.last[:content]&.strip&.end_with?("I am finished with the task.")
- # Check if this looks like a simple response (no pending tools/reasoning)
- last_message = agent.conversation.history.last[:content]&.strip
- if last_message && !last_message.empty?
- break
- end
- end
+ break if state.nil? || done
end
agent.transition_to(States::Idle.new)
lib/elelem/toolbox/bash.rb → lib/elelem/toolbox/exec.rb
@@ -2,15 +2,18 @@
module Elelem
module Toolbox
- class Bash < ::Elelem::Tool
+ class Exec < ::Elelem::Tool
attr_reader :tui
def initialize(configuration)
@tui = configuration.tui
- super("bash", "Run commands in /bin/bash -c. Full access to filesystem, network, processes, and all Unix tools.", {
+ super("exec", "Execute shell commands with pipe support", {
type: "object",
properties: {
- command: { type: "string" }
+ command: {
+ type: "string",
+ description: "Shell command to execute (supports pipes, redirects, etc.)"
+ }
},
required: ["command"]
})
@@ -21,7 +24,7 @@ module Elelem
output_buffer = []
tui.say(command, newline: true)
- Open3.popen3("/bin/bash", "-c", command) do |stdin, stdout, stderr, wait_thread|
+ Open3.popen3(command) do |stdin, stdout, stderr, wait_thread|
stdin.close
streams = [stdout, stderr]
lib/elelem/toolbox/search.rb
@@ -36,9 +36,9 @@ module Elelem
command = "grep -rnw '#{pattern}' #{path} | head -20"
end
- # Delegate to bash tool for consistent logging and streaming
- bash_tool = Elelem::Toolbox::Bash.new(@configuration)
- bash_tool.call({ "command" => command })
+ # Delegate to exec tool for consistent logging and streaming
+ exec_tool = Elelem::Toolbox::Exec.new(@configuration)
+ exec_tool.call({ "command" => command })
end
end
end
lib/elelem/configuration.rb
@@ -20,7 +20,12 @@ module Elelem
end
def logger
- @logger ||= Logger.new(debug ? "#{Time.now.strftime("%Y-%m-%d")}-elelem.log" : "/dev/null").tap do |logger|
+ @logger ||= Logger.new("#{Time.now.strftime("%Y-%m-%d")}-elelem.log").tap do |logger|
+ if debug
+ logger.level = :debug
+ else
+ logger.level = ENV.fetch("LOG_LEVEL", "warn")
+ end
logger.formatter = ->(_, _, _, message) { "#{message.to_s.strip}\n" }
end
end
@@ -39,10 +44,10 @@ module Elelem
def tools
@tools ||= Tools.new(self,
[
- Toolbox::Bash.new(self),
- Toolbox::File.new(self),
- Toolbox::Git.new(self),
- Toolbox::Prompt.new(self),
+ Toolbox::Exec.new(self),
+ # Toolbox::File.new(self),
+ # Toolbox::Git.new(self),
+ # Toolbox::Prompt.new(self),
Toolbox::Search.new(self),
] + mcp_tools
)
lib/elelem/toolbox.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require_relative "toolbox/bash"
+require_relative "toolbox/exec"
require_relative "toolbox/file"
require_relative "toolbox/git"
require_relative "toolbox/mcp"
lib/elelem/tools.rb
@@ -19,6 +19,7 @@ module Elelem
return "Invalid function arguments: #{args}" unless tool.valid?(args)
CLI::UI::Frame.open(name) do
+ configuration.logger.debug("Calling tool: #{tool} with #{args}")
tool.call(args)
end
end
elelem.gemspec
@@ -51,7 +51,7 @@ Gem::Specification.new do |spec|
"lib/elelem/system_prompt.erb",
"lib/elelem/tool.rb",
"lib/elelem/toolbox.rb",
- "lib/elelem/toolbox/bash.rb",
+ "lib/elelem/toolbox/exec.rb",
"lib/elelem/toolbox/file.rb",
"lib/elelem/toolbox/git.rb",
"lib/elelem/toolbox/mcp.rb",