Unify model changes and shell command argument handling

This commit is contained in:
Ian Gulliver
2026-10-20 22:53:47 -07:00
parent ba675f9a5a
commit a2de021f3c
6 changed files with 43 additions and 55 deletions
+17 -9
View File
@@ -21,6 +21,20 @@ type bashArgs struct {
TimeoutMs *int `json:"timeout_ms"`
}
func (a bashArgs) timeout() (time.Duration, error) {
if strings.TrimSpace(a.Command) == "" {
return 0, errors.New("command is empty")
}
timeout := defaultBashTimeout
if a.TimeoutMs != nil {
timeout = time.Duration(*a.TimeoutMs) * time.Millisecond
}
if timeout <= 0 || timeout > maxBashTimeout {
return 0, fmt.Errorf("timeout_ms must be between 1 and %d", maxBashTimeout.Milliseconds())
}
return timeout, nil
}
func (m *Manager) bashTool(l *live) mcp.Tool {
return mcp.Tool{
Name: "bash",
@@ -47,15 +61,9 @@ func (m *Manager) bash(ctx context.Context, l *live, raw json.RawMessage) (strin
if err != nil {
return "", fmt.Errorf("malformed bash call: %w", err)
}
if strings.TrimSpace(args.Command) == "" {
return "", errors.New("command is empty")
}
timeout := defaultBashTimeout
if args.TimeoutMs != nil {
timeout = time.Duration(*args.TimeoutMs) * time.Millisecond
}
if timeout <= 0 || timeout > maxBashTimeout {
return "", fmt.Errorf("timeout_ms must be between 1 and %d", maxBashTimeout.Milliseconds())
timeout, err := args.timeout()
if err != nil {
return "", err
}
task, err := m.store.GetTask(ctx, l.taskID)
if err != nil {