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
+5 -12
View File
@@ -256,9 +256,8 @@ func (m *Manager) listClients() string {
}
type clientBashArgs struct {
Client string `json:"client"`
Command string `json:"command"`
TimeoutMs *int `json:"timeout_ms"`
Client string `json:"client"`
bashArgs
}
func (m *Manager) clientBash(ctx context.Context, raw json.RawMessage) (string, error) {
@@ -267,15 +266,9 @@ func (m *Manager) clientBash(ctx context.Context, raw json.RawMessage) (string,
if err != nil {
return "", fmt.Errorf("malformed client_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
}
exitCode, output, err := m.runClientBash(ctx, args.Client, args.Command, timeout)