| 37 | } |
| 38 | |
| 39 | func pickShellParam(paramsJSON json.RawMessage) string { |
| 40 | if len(paramsJSON) == 0 { |
| 41 | return "command" |
| 42 | } |
| 43 | var schema struct { |
| 44 | Properties map[string]any `json:"properties"` |
| 45 | } |
| 46 | if err := json.Unmarshal(paramsJSON, &schema); err != nil || schema.Properties == nil { |
| 47 | return "command" |
| 48 | } |
| 49 | for _, cand := range ShellParamCandidates { |
| 50 | if _, ok := schema.Properties[cand]; ok { |
| 51 | return cand |
| 52 | } |
| 53 | } |
| 54 | return "command" |
| 55 | } |
| 56 | |
| 57 | // RecoverFromText 兜底:从已输出的纯文本里扫描 JSON 对象,抽出 |
| 58 | // (a) {"name":..., "arguments":...} 或 |