act_as_agent 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c1f235fc878725f6c3171a8f23c1b90000db60bb4d88c3ca84b6ce33aac6d61
4
- data.tar.gz: 223764bae1ff0c0c039d920b06fe5d1fd442877c548ccbae469fc12702ce8b99
3
+ metadata.gz: 7f0a2fea9ab22df1f6420509ac58b4e666fe2b935fa4a452a651f366a50b9201
4
+ data.tar.gz: 1b1b554adc81bbfbcb325fa7abbaf2b7b06e06428e61123aabbb264fc718bc2f
5
5
  SHA512:
6
- metadata.gz: 1c7dcee71ac11e8ae1c0d4d06a30a3cbe6a83706d463fca301cd1f40de128d9310ea404873d96dc7f1df064251a209005ce43f628dc533753c89975f058aa1e0
7
- data.tar.gz: ad1b0a4662ba854654d46ea920549f74a4d6579bffb20b59b13340e13057ac4ac088233199e9e1a187edbcacc9ccdc619730508e6dcc3f6ebb21b6349d37f7ac
6
+ metadata.gz: dc8afbb5eb5106ca85c1fe5f65199fd21f25e0450064b8fd519d545ac88d92120c07b18ba4cdfc87b5c28ee33c326233ca6442305b95e0cab1c939d470f5367a
7
+ data.tar.gz: a8311e8f892629d8d8b51e62c322e77e1ab989ae45bedc41286c9805327ed3f892e5f66d6be77c75e96a17329d4651ca021a2e89c1d4e7048fc4a1f1b477c671
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- act_as_agent (0.1.0)
4
+ act_as_agent (0.2.0)
5
5
  act_as_api_client (~> 1.3.1)
6
6
 
7
7
  GEM
@@ -37,22 +37,22 @@ module ActAsAgent
37
37
  end
38
38
  end
39
39
 
40
- tool_responses = []
40
+ return response if response["stop_reason"] == "end_turn"
41
41
 
42
- response["content"].each do |message|
43
- next unless message["type"] == "tool_use"
42
+ tool_responses = response["content"].each_with_object([]) do |message, memo|
43
+ next memo unless message["type"] == "tool_use"
44
44
 
45
45
  @tools.each do |tool|
46
46
  next unless tool.name == message["name"]
47
47
 
48
- tool_responses << {
48
+ memo << {
49
49
  "role" => "assistant",
50
50
  "content" => [
51
51
  message
52
52
  ]
53
53
  }
54
54
 
55
- tool_responses << {
55
+ memo << {
56
56
  role: "user",
57
57
  content: [
58
58
  {
@@ -66,8 +66,6 @@ module ActAsAgent
66
66
  end
67
67
 
68
68
  request(content: content + tool_responses) unless tool_responses.empty?
69
-
70
- response["content"]
71
69
  end
72
70
  # rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
73
71
 
@@ -33,7 +33,7 @@ module ActAsAgent
33
33
  end
34
34
 
35
35
  def call(args = {})
36
- path = args.fetch(:path, nil)
36
+ path = args.fetch("path", nil)
37
37
 
38
38
  return Dir.glob(path) unless path.nil? || path.chomp == ""
39
39
  return Dir.glob(root_folder) unless root_folder.nil?
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "act_as_agent/errors/tool_incorrect_args_error"
4
+
5
+ module ActAsAgent
6
+ module Tools
7
+ class ReadFile
8
+ ERROR = ActAsAgent::Errors::ToolIncorrectArgsError
9
+
10
+ attr_reader :file_path
11
+
12
+ def initialize(file_path: nil)
13
+ @file_path = file_path
14
+ end
15
+
16
+ def name
17
+ self.class.to_s.gsub("::", "__")
18
+ end
19
+
20
+ def description
21
+ "Read file by the given path"
22
+ end
23
+
24
+ def input_schema
25
+ {
26
+ type: "object",
27
+ properties: {
28
+ file_path: { type: "string",
29
+ description: "File path to read" }
30
+ },
31
+ required: []
32
+ }
33
+ end
34
+
35
+ def call(args = {})
36
+ path = args.fetch("file_path", nil)
37
+
38
+ return File.read(path) unless path.nil? || path.chomp == ""
39
+ return File.read(file_path) unless file_path.nil?
40
+
41
+ ERROR.new("Incorrect params have been given to list files tool")
42
+ end
43
+ end
44
+ end
45
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: act_as_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Rukomoynikov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-11-16 00:00:00.000000000 Z
11
+ date: 2025-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: act_as_api_client
@@ -53,6 +53,7 @@ files:
53
53
  - lib/act_as_agent/errors/tool_incorrect_args_error.rb
54
54
  - lib/act_as_agent/providers/anthropic.rb
55
55
  - lib/act_as_agent/tools/list_files.rb
56
+ - lib/act_as_agent/tools/read_file.rb
56
57
  - sig/act_as_agent.rbs
57
58
  homepage: https://github.com/Rukomoynikov/act_as_agent
58
59
  licenses: