ask-agent 0.4.2 → 0.4.4
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/lib/ask/agent/chat.rb +14 -6
- data/lib/ask/agent/tool_executor.rb +17 -2
- data/lib/ask/agent/version.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: 6f7551eb8363ce20ed2ff19787553ddfc28dc1815236d42c905213dcffad520a
|
|
4
|
+
data.tar.gz: 7347fad9ea7f88713c9de21d501d656418b12b5d479a85c3b91e06f682cf918c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 29a170ef718d85603ce3a418e59f6b333aab3138cbd1e1702f78509adb268de512495b17341baf406b8e8ccfb0d89eff3b918d0a206b567a3a71385d57396685
|
|
7
|
+
data.tar.gz: 86907835ee0101ecdf499811f13ff5c23e29d6a8ed8e3e8ab293e968bdf45018abcdf2055e65a19239da24a0946100f0f27891fb4fa23123684e71c53293c38d
|
data/lib/ask/agent/chat.rb
CHANGED
|
@@ -119,13 +119,21 @@ module Ask
|
|
|
119
119
|
end
|
|
120
120
|
|
|
121
121
|
def provider_config(slug)
|
|
122
|
-
# Try
|
|
123
|
-
#
|
|
124
|
-
#
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
122
|
+
# Try credential names from most to least specific:
|
|
123
|
+
# 1. Flat key with full slug (opencode_go_api_key)
|
|
124
|
+
# 2. Nested path with full slug ([:opencode, :go, :api_key])
|
|
125
|
+
# 3. Flat key with base slug (opencode_api_key)
|
|
126
|
+
# 4. Nested path with base slug ([:opencode, :api_key])
|
|
127
|
+
slug_s = slug.to_s
|
|
128
|
+
base_s = slug_s.include?("_") ? slug_s.split("_").first : nil
|
|
129
|
+
|
|
130
|
+
cred_names = [:"#{slug_s}_api_key"]
|
|
131
|
+
cred_names << slug_s.split("_").map(&:to_sym).push(:api_key) if slug_s.include?("_")
|
|
132
|
+
if base_s
|
|
133
|
+
cred_names << :"#{base_s}_api_key"
|
|
134
|
+
cred_names << [base_s.to_sym, :api_key]
|
|
128
135
|
end
|
|
136
|
+
|
|
129
137
|
key = Ask::Auth.resolve(*cred_names) rescue nil
|
|
130
138
|
|
|
131
139
|
base_url = Ask::Auth.resolve(:"#{slug}_api_base") rescue nil
|
|
@@ -55,6 +55,10 @@ module Ask
|
|
|
55
55
|
if result[:critical_failure]
|
|
56
56
|
sibling_abort.abort!
|
|
57
57
|
end
|
|
58
|
+
|
|
59
|
+
if result[:halted]
|
|
60
|
+
sibling_abort.abort!
|
|
61
|
+
end
|
|
58
62
|
rescue => e
|
|
59
63
|
mutex.synchronize do
|
|
60
64
|
results[id] = {
|
|
@@ -79,6 +83,7 @@ module Ask
|
|
|
79
83
|
result = execute_single_tool(tool_call, tools, hooks, event_emitter, sibling_abort)
|
|
80
84
|
results << result
|
|
81
85
|
break if result[:critical_failure]
|
|
86
|
+
break if result[:halted]
|
|
82
87
|
end
|
|
83
88
|
results
|
|
84
89
|
end
|
|
@@ -128,6 +133,11 @@ module Ask
|
|
|
128
133
|
|
|
129
134
|
is_error = result[:is_error] == true
|
|
130
135
|
critical = is_error && critical_error?(result[:error])
|
|
136
|
+
halted = result[:halted] == true
|
|
137
|
+
|
|
138
|
+
if halted
|
|
139
|
+
abort_controller&.abort!
|
|
140
|
+
end
|
|
131
141
|
|
|
132
142
|
if is_error && @telemetry
|
|
133
143
|
@telemetry.log(:tool_error, session_id: @session_id, tool_name: tool_call.name, error_class: result[:error] || "RuntimeError", error_message: result[:result].to_s)
|
|
@@ -156,7 +166,8 @@ module Ask
|
|
|
156
166
|
message: message,
|
|
157
167
|
status: is_error ? "error" : "success",
|
|
158
168
|
result: result,
|
|
159
|
-
critical_failure: critical
|
|
169
|
+
critical_failure: critical,
|
|
170
|
+
halted: halted
|
|
160
171
|
}
|
|
161
172
|
end
|
|
162
173
|
|
|
@@ -176,7 +187,11 @@ module Ask
|
|
|
176
187
|
|
|
177
188
|
def try_call(tool, args, abort_controller = nil)
|
|
178
189
|
result = tool.call(args, abort_controller: abort_controller)
|
|
179
|
-
{ result: result, is_error: false }
|
|
190
|
+
hash = { result: result, is_error: false }
|
|
191
|
+
if result.respond_to?(:metadata) && result.metadata&.dig(:halted)
|
|
192
|
+
hash[:halted] = true
|
|
193
|
+
end
|
|
194
|
+
hash
|
|
180
195
|
rescue => e
|
|
181
196
|
{ result: e.message, is_error: true, error: e.class.name }
|
|
182
197
|
end
|
data/lib/ask/agent/version.rb
CHANGED