foobara-agent 0.0.10 → 0.0.11
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/foobara/agent.rb +1 -1
- data/src/foobara/agent/notify_user_that_current_goal_has_been_accomplished.rb +51 -17
- data/src/foobara/agent.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e0f6302247bbcc56ed93f61ec3a5d39e5041029e03b20cadea2d1dd0ebd04b6
|
4
|
+
data.tar.gz: baca677e1ea555bcdc908fd2b37dc2d8b016df9888f8f7a69c8cff73774756b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 350feb6d9058009889a342a5dcc4f44befed8a25be71ebc7673bf75b7ceb1f95adcec3a52d2eb53ba9301d0ef2312919a4496a53f2146423dd36c17b122856af
|
7
|
+
data.tar.gz: a91ec6608bc3001f06d3c17562321d2c1a52a537372347593293d57d9d6312126f5116853c8b32b649d7c65a050bbb67bd03b2dbc50247cdc7260013b6d8f3ec
|
data/CHANGELOG.md
CHANGED
data/lib/foobara/agent.rb
CHANGED
@@ -4,7 +4,7 @@ module Foobara
|
|
4
4
|
extend Concerns::SubclassCacheable
|
5
5
|
|
6
6
|
class << self
|
7
|
-
attr_accessor :command_class
|
7
|
+
attr_accessor :command_class, :returns_message_to_user, :returns_result_data, :result_is_attributes
|
8
8
|
|
9
9
|
def for(agent_id: nil, result_type: nil, include_message_to_user_in_result: true)
|
10
10
|
agent_id ||= "Anon#{SecureRandom.hex(2)}"
|
@@ -19,26 +19,36 @@ module Foobara
|
|
19
19
|
"The user might issue a new goal."
|
20
20
|
|
21
21
|
if result_type
|
22
|
+
klass.returns_result_data = true
|
23
|
+
|
22
24
|
# TODO: fix this... agent backed command sets these via its own result type.
|
23
25
|
# check if message_to_user is already here and also search/fix result_data to be result for consistency.
|
24
26
|
if include_message_to_user_in_result
|
25
|
-
klass.
|
26
|
-
result result_type, :required
|
27
|
-
message_to_user :string, :required, "Message to the user about what was done"
|
28
|
-
end
|
27
|
+
klass.returns_message_to_user = true
|
29
28
|
|
30
29
|
klass.result do
|
31
30
|
result result_type, :required
|
32
31
|
message_to_user :string, :required, "Message to the user about what was done"
|
33
32
|
end
|
34
33
|
|
34
|
+
klass.add_inputs klass.result_type
|
35
|
+
|
35
36
|
klass.description "Notifies the user that the current goal has been accomplished and returns a final " \
|
36
37
|
"result formatted according to the " \
|
37
38
|
"result schema and a message to the user. " \
|
38
39
|
"The user might issue a new goal."
|
39
40
|
else
|
40
|
-
|
41
|
-
|
41
|
+
unless result_type.is_a?(Types::Type)
|
42
|
+
result_type = Domain.current.foobara_type_from_declaration(result_type)
|
43
|
+
end
|
44
|
+
|
45
|
+
if result_type.extends?(BuiltinTypes[:attributes])
|
46
|
+
klass.result_is_attributes = true
|
47
|
+
klass.add_inputs result_type
|
48
|
+
else
|
49
|
+
klass.add_inputs do
|
50
|
+
result result_type, :required
|
51
|
+
end
|
42
52
|
end
|
43
53
|
|
44
54
|
klass.result result_type
|
@@ -49,6 +59,8 @@ module Foobara
|
|
49
59
|
"The user might issue a new goal."
|
50
60
|
end
|
51
61
|
elsif include_message_to_user_in_result
|
62
|
+
klass.returns_message_to_user = true
|
63
|
+
|
52
64
|
klass.add_inputs do
|
53
65
|
message_to_user :string, :required, "Message to the user about what was done"
|
54
66
|
end
|
@@ -81,24 +93,46 @@ module Foobara
|
|
81
93
|
end
|
82
94
|
|
83
95
|
def execute
|
96
|
+
build_result
|
84
97
|
mark_mission_accomplished
|
85
98
|
|
86
|
-
|
99
|
+
built_result
|
87
100
|
end
|
88
101
|
|
102
|
+
attr_accessor :built_result
|
103
|
+
|
89
104
|
def mark_mission_accomplished
|
90
|
-
|
105
|
+
result, message_to_user = if returns_message_to_user?
|
106
|
+
[built_result[:result], built_result[:message_to_user]]
|
107
|
+
elsif returns_result_data?
|
108
|
+
[built_result, nil]
|
109
|
+
end
|
110
|
+
|
111
|
+
command_connector.mark_mission_accomplished(result, message_to_user)
|
91
112
|
end
|
92
113
|
|
93
|
-
def
|
94
|
-
|
95
|
-
|
114
|
+
def build_result
|
115
|
+
self.built_result = if returns_message_to_user?
|
116
|
+
inputs.slice(:result, :message_to_user)
|
117
|
+
elsif returns_result_data?
|
118
|
+
if result_is_attributes?
|
119
|
+
inputs.slice(*self.class.result_type.element_types.keys)
|
120
|
+
else
|
121
|
+
inputs[:result]
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
96
125
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
126
|
+
def returns_message_to_user?
|
127
|
+
self.class.returns_message_to_user
|
128
|
+
end
|
129
|
+
|
130
|
+
def returns_result_data?
|
131
|
+
self.class.returns_result_data
|
132
|
+
end
|
133
|
+
|
134
|
+
def result_is_attributes?
|
135
|
+
self.class.result_is_attributes
|
102
136
|
end
|
103
137
|
end
|
104
138
|
end
|
data/src/foobara/agent.rb
CHANGED
@@ -41,7 +41,7 @@ module Foobara
|
|
41
41
|
# TODO: shouldn't have to pass command_log here since it has a default, debug that
|
42
42
|
self.context = context
|
43
43
|
self.agent_name = agent_name || "Anon#{SecureRandom.hex(2)}"
|
44
|
-
self.llm_model = llm_model
|
44
|
+
self.llm_model = llm_model || "claude-opus-4-20250514"
|
45
45
|
self.result_type = result_type
|
46
46
|
self.include_message_to_user_in_result = include_message_to_user_in_result
|
47
47
|
self.verbose = verbose
|