( ctx context.Context, p *Server, currentChat database.Chat, rawSubagentType string, )
| 213 | } |
| 214 | |
| 215 | func resolveSubagentDefinition( |
| 216 | ctx context.Context, |
| 217 | p *Server, |
| 218 | currentChat database.Chat, |
| 219 | rawSubagentType string, |
| 220 | ) (subagentDefinition, error) { |
| 221 | subagentType := strings.TrimSpace(rawSubagentType) |
| 222 | def, ok := lookupSubagentDefinition(subagentType) |
| 223 | if !ok { |
| 224 | return subagentDefinition{}, xerrors.Errorf( |
| 225 | "type must be one of: %s", |
| 226 | strings.Join(availableSubagentTypeIDs(ctx, p, currentChat), ", "), |
| 227 | ) |
| 228 | } |
| 229 | if reason := def.unavailableReasonText(ctx, p, currentChat); reason != "" { |
| 230 | return subagentDefinition{}, xerrors.New(reason) |
| 231 | } |
| 232 | return def, nil |
| 233 | } |
| 234 | |
| 235 | func validateSubagentSpawnParent(currentChat database.Chat) error { |
| 236 | if currentChat.ParentChatID.Valid { |
no test coverage detected