PickShellTool returns the best shell tool name from the session's observed tools. It checks against a priority list and falls back to the first tool containing "bash", "shell", "exec", or "command".
(sess *Session)
| 22 | // PickShellTool returns the best shell tool name from the session's observed tools. |
| 23 | // It checks against a priority list and falls back to the first tool containing "bash", "shell", "exec", or "command". |
| 24 | func PickShellTool(sess *Session) string { |
| 25 | result := pickToolByPriority(sess, shellToolPriority, func(lower string) bool { |
| 26 | return strings.Contains(lower, "bash") || strings.Contains(lower, "shell") || |
| 27 | strings.Contains(lower, "exec") || strings.Contains(lower, "command") |
| 28 | }) |
| 29 | if sess != nil { |
| 30 | sess.mu.Lock() |
| 31 | toolCount := len(sess.Tools) |
| 32 | names := make([]string, toolCount) |
| 33 | for i, t := range sess.Tools { |
| 34 | names[i] = t.Name |
| 35 | } |
| 36 | sess.mu.Unlock() |
| 37 | if result == "" { |
| 38 | log.Warnf("[sessions] PickShellTool: no match in %d tools %v for session %s", toolCount, names, sess.ID) |
| 39 | } else { |
| 40 | log.Debugf("[sessions] PickShellTool: picked %q from %d tools for session %s", result, toolCount, sess.ID) |
| 41 | } |
| 42 | } |
| 43 | return result |
| 44 | } |
| 45 | |
| 46 | // BuildCommandArguments constructs the arguments map for a shell tool invocation. |
| 47 | // It inspects the tool's schema to determine the correct parameter name. |