foobara-agent 0.1.0 → 0.1.1

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: b2c6928861e690e60fc4df800ced4434015b64dc29fde57208299e4134126ce3
4
- data.tar.gz: f7cd28971c47aeab1f04b5646630615b30da5dd49bc8904f1ba4e7b5d8a51b85
3
+ metadata.gz: 3badca4e20c245c79d96447e515f356c9ec2a51c1965121002b363526fd7c8a9
4
+ data.tar.gz: 6e610aa1fad783ee72fafa1ce4b6588b21074c344c458ce08de64887b0e5a4f3
5
5
  SHA512:
6
- metadata.gz: 83c3cbdb2cd4efb990c15b935c468aa9d04f3410ff712d50d5b40bf2f8e1b0ae88b75b5a4d59ff11bf54f0eb0844a27e81f9f19f3b10cc97a0ed5e461f7d4bad
7
- data.tar.gz: d4f6719365a7f0a4374615a3bf61701c9fdcca3a3b730ef6bb3de97b9ebc3a139552efc377a34878bd06a5bf8b2918430ecc98cde36b7d703078dbe148366763
6
+ metadata.gz: d45afbcdb3fc6fa2f44e4167f00d6ac89f3dbb768cf6c35539dcd339430ed4dfb0a991cc48016bc192e7fcb681f7467b3b04150d601ee3aa708ea44bc12f737e
7
+ data.tar.gz: 42298c90e008cf8e77446b4595ca4a57f5d4ca3da62a0e38ee8ca778cd54feefe8206d5f78b7fa5bf27343f9059fb1b60fa43bf5198a67450807a946532f19c8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.1.1] - 2026-09-22
2
+
3
+ - Bump deps
4
+
1
5
  ## [0.1.0] - 2025-08-22
2
6
 
3
7
  - Allow killing the agent before setting a goal
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Foobara::Agent
2
2
 
3
+ WARNING!! This agent will just run whatever command it thinks it should run without asking!
4
+
3
5
  Accepts a list of Foobara commands and can then repeatedly accomplish goals you give it using those commands.
4
6
 
5
7
  If you want a cli tool that wraps this gem, checkout foobara-agent-cli
@@ -8,7 +10,7 @@ Works with Ollama, Anthropic, or OpenAI models
8
10
 
9
11
  ## Contributing
10
12
 
11
- I would love help with this and other Foobara gems! Feel free to hit me up at miles@foobara.com if you
13
+ I would love help with this and other Foobara gems! Feel free to hit me up at miles@foobara.org if you
12
14
  think helping out would be fun or interesting! I have tasks for all experience levels and am often free
13
15
  to pair on Foobara stuff.
14
16
 
@@ -9,7 +9,6 @@ module Foobara
9
9
 
10
10
  inputs do
11
11
  goal :string, :required, "What do you want the agent to attempt to accomplish?"
12
- # TODO: we should be able to specify a subclass as a type
13
12
  final_result_type :duck, "Specifies how the result of the goal is to be structured"
14
13
  include_message_to_user_in_result :boolean, default: true
15
14
  verbose :boolean, default: false
@@ -72,6 +71,7 @@ module Foobara
72
71
  self.next_command_name = ListCommands.full_command_name
73
72
  self.next_command_raw_inputs = nil
74
73
  self.next_command_inputs = nil
74
+
75
75
  fetch_next_command_class
76
76
 
77
77
  run_next_command
@@ -95,6 +95,7 @@ module Foobara
95
95
  self.next_command_name = DescribeCommand.full_command_name
96
96
  self.next_command_inputs = { command_name: }
97
97
  self.next_command_raw_inputs = next_command_inputs
98
+
98
99
  fetch_next_command_class
99
100
 
100
101
  run_next_command
@@ -107,7 +108,7 @@ module Foobara
107
108
 
108
109
  def simulate_describe_command_run_for_all_commands
109
110
  # TODO: currently not using this code path. Unclear if it is worth it.
110
- # :nocov:
111
+ # simplecov:disable
111
112
  return if context.command_log.size > 1
112
113
 
113
114
  ListCommands.run!(command_connector: agent)[:user_provided_commands].each do |full_command_name|
@@ -120,7 +121,7 @@ module Foobara
120
121
 
121
122
  run_next_command
122
123
  end
123
- # :nocov:
124
+ # simplecov:enable
124
125
  end
125
126
 
126
127
  RETRY_COUNT = 3
@@ -129,14 +130,14 @@ module Foobara
129
130
  return if killed
130
131
 
131
132
  if verbose? && retries != RETRY_COUNT
132
- # :nocov:
133
+ # simplecov:disable
133
134
  (io_err || $stderr).puts " !!! Retrying to determine next command and inputs. Retries left: #{retries}"
134
- # :nocov:
135
+ # simplecov:enable
135
136
  end
136
137
 
137
138
  if retries == 0
138
139
  # TODO: test this path by irreparably breaking the needed commands
139
- # :nocov:
140
+ # simplecov:disable
140
141
  self.next_command_name = GiveUp.full_command_name
141
142
  self.next_command_inputs = {
142
143
  message_to_user: "While trying to choose the next command and inputs, " \
@@ -146,7 +147,7 @@ module Foobara
146
147
  self.next_command_raw_inputs = next_command_inputs
147
148
 
148
149
  return
149
- # :nocov:
150
+ # simplecov:enable
150
151
  end
151
152
 
152
153
  compact_command_log
@@ -161,9 +162,9 @@ module Foobara
161
162
  record_llm_call_timestamp
162
163
  determine_command.run
163
164
  rescue CommandPatternImplementation::Concerns::Result::CouldNotProcessResult => e
164
- # :nocov:
165
+ # simplecov:disable
165
166
  Outcome.errors(e.errors)
166
- # :nocov:
167
+ # simplecov:enable
167
168
  end
168
169
 
169
170
  if outcome.success?
@@ -186,7 +187,7 @@ module Foobara
186
187
 
187
188
  unless outcome.success?
188
189
  # TODO: test this path
189
- # :nocov:
190
+ # simplecov:disable
190
191
  log_command_outcome(
191
192
  command_name: next_command_name,
192
193
  inputs: next_command_inputs,
@@ -196,7 +197,7 @@ module Foobara
196
197
  simulate_describe_command
197
198
 
198
199
  determine_next_command_and_inputs(retries - 1, outcome)
199
- # :nocov:
200
+ # simplecov:enable
200
201
  end
201
202
  else
202
203
  self.next_command_inputs = {}
@@ -239,9 +240,9 @@ module Foobara
239
240
 
240
241
  if outcome.success?
241
242
  # TODO: figure out a way to hit this path in the test suite
242
- # :nocov:
243
+ # simplecov:disable
243
244
  self.next_command_name = outcome.result
244
- # :nocov:
245
+ # simplecov:enable
245
246
  end
246
247
 
247
248
  outcome
@@ -324,13 +325,13 @@ module Foobara
324
325
 
325
326
  failure_indexes.each do |failure_index|
326
327
  # TODO: test this path
327
- # :nocov:
328
+ # simplecov:disable
328
329
  if failure_index < last_success
329
330
  indexes_to_delete << failure_index
330
331
  else
331
332
  break
332
333
  end
333
- # :nocov:
334
+ # simplecov:enable
334
335
  end
335
336
  end
336
337
 
@@ -401,17 +402,17 @@ module Foobara
401
402
  if verbose?
402
403
  if log_command_code
403
404
  # TODO: test this code path hmmm
404
- # :nocov:
405
+ # simplecov:disable
405
406
  self.log_command_code(command_name:, inputs:)
406
- # :nocov:
407
+ # simplecov:enable
407
408
  end
408
409
 
409
410
  unless log_entry.success?
410
- # :nocov:
411
+ # simplecov:disable
411
412
  (io_err || $stderr).puts(
412
413
  "Command #{log_entry.command_name} failed:\n#{log_entry.errors_hash}"
413
414
  )
414
- # :nocov:
415
+ # simplecov:enable
415
416
  end
416
417
  end
417
418
  end
@@ -426,9 +427,9 @@ module Foobara
426
427
  if s =~ /\A\{(.*)}\z/
427
428
  "(#{::Regexp.last_match(1)})"
428
429
  else
429
- # :nocov:
430
+ # simplecov:disable
430
431
  raise "Unexpected next_command_inputs: #{next_command_inputs}"
431
- # :nocov:
432
+ # simplecov:enable
432
433
  end
433
434
  end
434
435
 
@@ -439,9 +440,9 @@ module Foobara
439
440
  # Not setting an agent_name results in non-determinism in NotifyUser... command
440
441
  # namespace. This results in problems in the test suite making this code path a little
441
442
  # harder to test indirectly.
442
- # :nocov:
443
+ # simplecov:disable
443
444
  ""
444
- # :nocov:
445
+ # simplecov:enable
445
446
  end
446
447
 
447
448
  (io_out || $stdout).puts "#{prefix}#{next_command_name}.run#{args}"
@@ -490,10 +491,10 @@ module Foobara
490
491
  elsif given_up? || killed?
491
492
  final_result
492
493
  else
493
- # :nocov:
494
+ # simplecov:disable
494
495
  raise CommandPatternImplementation::Concerns::Result::CouldNotProcessResult,
495
496
  outcome.errors
496
- # :nocov:
497
+ # simplecov:enable
497
498
  end
498
499
  else
499
500
  final_result
@@ -13,9 +13,9 @@ module Foobara
13
13
 
14
14
  def cached_subclass(key)
15
15
  if subclass_cache.key?(key)
16
- # :nocov:
16
+ # simplecov:disable
17
17
  subclass_cache[key]
18
- # :nocov:
18
+ # simplecov:enable
19
19
  else
20
20
  subclass_cache[key] = yield
21
21
  end
@@ -22,9 +22,9 @@ module Foobara
22
22
  instructions += if description && !description.empty?
23
23
  " which has the following description:\n\n#{description}\n\n"
24
24
  else
25
- # :nocov:
25
+ # simplecov:disable
26
26
  ". "
27
- # :nocov:
27
+ # simplecov:enable
28
28
  end
29
29
 
30
30
  result_schema = result_json_schema(assistant_association_depth)
@@ -92,10 +92,10 @@ module Foobara
92
92
  "The user might issue a new goal."
93
93
  else
94
94
  # This should be unreachable actually
95
- # :nocov:
95
+ # simplecov:disable
96
96
  klass.description "Notifies the user that the current goal has been accomplished. " \
97
97
  "The user might issue a new goal."
98
- # :nocov:
98
+ # simplecov:enable
99
99
  end
100
100
 
101
101
  apply_result_data_transformer(klass, result_entity_depth)
@@ -112,9 +112,9 @@ module Foobara
112
112
  when AssociationDepth::ATOM
113
113
  CommandConnectors::Transformers::LoadAtomsTransformer
114
114
  else
115
- # :nocov:
115
+ # simplecov:disable
116
116
  raise "Unsupported result entity depth: #{result_entity_depth}"
117
- # :nocov:
117
+ # simplecov:enable
118
118
  end&.instance
119
119
  end
120
120
  end
@@ -18,9 +18,9 @@ module Foobara
18
18
 
19
19
  def errors_hash
20
20
  # TODO: test this path
21
- # :nocov:
21
+ # simplecov:disable
22
22
  outcome[:errors_hash]
23
- # :nocov:
23
+ # simplecov:enable
24
24
  end
25
25
  end
26
26
  end
data/src/foobara/agent.rb CHANGED
@@ -138,13 +138,13 @@ module Foobara
138
138
 
139
139
  if result_type && self.result_type != result_type
140
140
  if self.result_type
141
- # :nocov:
141
+ # simplecov:disable
142
142
  raise ArgumentError, "You can only specify a result type once"
143
- # :nocov:
143
+ # simplecov:enable
144
144
  elsif agent_commands_connected?
145
- # :nocov:
145
+ # simplecov:disable
146
146
  raise ArgumentError, "You can't specify a result type this late in the process"
147
- # :nocov:
147
+ # simplecov:enable
148
148
  else
149
149
  self.result_type = result_type
150
150
  end
@@ -182,7 +182,7 @@ module Foobara
182
182
  end
183
183
  end
184
184
  rescue
185
- # :nocov:
185
+ # simplecov:disable
186
186
  unless killed?
187
187
  state_machine.perform_transition!(:goal_errored) do
188
188
  context.current_goal.state = Goal::States::ERROR
@@ -190,7 +190,7 @@ module Foobara
190
190
  end
191
191
 
192
192
  raise
193
- # :nocov:
193
+ # simplecov:enable
194
194
  end
195
195
  end
196
196
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara-agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
@@ -15,7 +15,7 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 0.1.1
18
+ version: 0.6.4
19
19
  - - "<"
20
20
  - !ruby/object:Gem::Version
21
21
  version: 2.0.0
@@ -25,7 +25,7 @@ dependencies:
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: 0.1.1
28
+ version: 0.6.4
29
29
  - - "<"
30
30
  - !ruby/object:Gem::Version
31
31
  version: 2.0.0
@@ -35,7 +35,7 @@ dependencies:
35
35
  requirements:
36
36
  - - ">="
37
37
  - !ruby/object:Gem::Version
38
- version: 1.0.0
38
+ version: 1.0.4
39
39
  - - "<"
40
40
  - !ruby/object:Gem::Version
41
41
  version: 2.0.0
@@ -45,7 +45,7 @@ dependencies:
45
45
  requirements:
46
46
  - - ">="
47
47
  - !ruby/object:Gem::Version
48
- version: 1.0.0
48
+ version: 1.0.4
49
49
  - - "<"
50
50
  - !ruby/object:Gem::Version
51
51
  version: 2.0.0
@@ -89,13 +89,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
89
  - - ">="
90
90
  - !ruby/object:Gem::Version
91
91
  version: 3.4.0
92
+ - - "<"
93
+ - !ruby/object:Gem::Version
94
+ version: '4.1'
92
95
  required_rubygems_version: !ruby/object:Gem::Requirement
93
96
  requirements:
94
97
  - - ">="
95
98
  - !ruby/object:Gem::Version
96
99
  version: '0'
97
100
  requirements: []
98
- rubygems_version: 3.6.9
101
+ rubygems_version: 4.0.20
99
102
  specification_version: 4
100
103
  summary: An agent that uses whatever Foobara commands you wish to accomplish goals
101
104
  of your choosing!