MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / parseAgentTimeoutSeconds

Function parseAgentTimeoutSeconds

agent/agent_tool.go:188–222  ·  view source on GitHub ↗
(raw any)

Source from the content-addressed store, hash-verified

186}
187
188func parseAgentTimeoutSeconds(raw any) (int, string) {
189 if raw == nil {
190 return DefaultSubagentTimeoutSeconds, ""
191 }
192 switch v := raw.(type) {
193 case int:
194 return validateAgentTimeoutSeconds(v)
195 case int32:
196 return validateAgentTimeoutSeconds(int(v))
197 case int64:
198 return validateAgentTimeoutSeconds(int(v))
199 case float32:
200 return validateAgentTimeoutSeconds(int(v))
201 case float64:
202 return validateAgentTimeoutSeconds(int(v))
203 case json.Number:
204 n, err := v.Int64()
205 if err != nil {
206 return 0, "timeout_seconds must be an integer number of seconds."
207 }
208 return validateAgentTimeoutSeconds(int(n))
209 case string:
210 text := strings.TrimSpace(strings.TrimSuffix(v, "s"))
211 if text == "" {
212 return 0, "timeout_seconds must not be empty."
213 }
214 n, err := strconv.Atoi(text)
215 if err != nil {
216 return 0, "timeout_seconds must be an integer number of seconds."
217 }
218 return validateAgentTimeoutSeconds(n)
219 default:
220 return 0, fmt.Sprintf("timeout_seconds must be an integer number of seconds, got %T.", raw)
221 }
222}
223
224func validateAgentTimeoutSeconds(seconds int) (int, string) {
225 if seconds <= 0 {

Callers 1

agentTimeoutSecondsFunction · 0.85

Calls 2

Int64Method · 0.80

Tested by

no test coverage detected