parseAgentSessionConfig handles create-agent-session configuration
(outputMap map[string]any)
| 16 | |
| 17 | // parseAgentSessionConfig handles create-agent-session configuration |
| 18 | func (c *Compiler) parseAgentSessionConfig(outputMap map[string]any) *CreateAgentSessionConfig { |
| 19 | // Try new key first |
| 20 | if configData, exists := outputMap["create-agent-session"]; exists { |
| 21 | createAgentSessionLog.Print("Parsing create-agent-session configuration") |
| 22 | agentSessionConfig := &CreateAgentSessionConfig{} |
| 23 | |
| 24 | if configMap, ok := configData.(map[string]any); ok { |
| 25 | // Parse base branch |
| 26 | if base, exists := configMap["base"]; exists { |
| 27 | if baseStr, ok := base.(string); ok { |
| 28 | agentSessionConfig.Base = baseStr |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | // Parse target-repo using shared helper with validation |
| 33 | targetRepoSlug, isInvalid := parseTargetRepoWithValidation(configMap) |
| 34 | if isInvalid { |
| 35 | return nil // Invalid configuration, return nil to cause validation error |
| 36 | } |
| 37 | agentSessionConfig.TargetRepoSlug = targetRepoSlug |
| 38 | |
| 39 | // Parse common base fields with default max of 1 |
| 40 | c.parseBaseSafeOutputConfig(configMap, &agentSessionConfig.BaseSafeOutputConfig, 1) |
| 41 | } else { |
| 42 | // If configData is nil or not a map (e.g., "create-agent-session:" with no value), |
| 43 | // still set the default max |
| 44 | agentSessionConfig.Max = defaultIntStr(1) |
| 45 | } |
| 46 | |
| 47 | return agentSessionConfig |
| 48 | } |
| 49 | |
| 50 | // Fall back to deprecated key for backward compatibility |
| 51 | if configData, exists := outputMap["create-agent-task"]; exists { |
| 52 | createAgentSessionLog.Print("WARNING: Using deprecated 'create-agent-task' configuration. Please migrate to 'create-agent-session' using 'gh aw fix'") |
| 53 | agentSessionConfig := &CreateAgentSessionConfig{} |
| 54 | |
| 55 | if configMap, ok := configData.(map[string]any); ok { |
| 56 | // Parse base branch |
| 57 | if base, exists := configMap["base"]; exists { |
| 58 | if baseStr, ok := base.(string); ok { |
| 59 | agentSessionConfig.Base = baseStr |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | // Parse target-repo using shared helper with validation |
| 64 | targetRepoSlug, isInvalid := parseTargetRepoWithValidation(configMap) |
| 65 | if isInvalid { |
| 66 | return nil // Invalid configuration, return nil to cause validation error |
| 67 | } |
| 68 | agentSessionConfig.TargetRepoSlug = targetRepoSlug |
| 69 | |
| 70 | // Parse common base fields with default max of 1 |
| 71 | c.parseBaseSafeOutputConfig(configMap, &agentSessionConfig.BaseSafeOutputConfig, 1) |
| 72 | } else { |
| 73 | // If configData is nil or not a map (e.g., "create-agent-task:" with no value), |
| 74 | // still set the default max |
| 75 | agentSessionConfig.Max = defaultIntStr(1) |