Unify model changes and shell command argument handling
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user