extractEngineConfigFromFile parses a workflow file and returns the engine ID and config. Returns ("", nil) when the file cannot be read or parsed.
(filePath string)
| 95 | // extractEngineConfigFromFile parses a workflow file and returns the engine ID and config. |
| 96 | // Returns ("", nil) when the file cannot be read or parsed. |
| 97 | func extractEngineConfigFromFile(filePath string) (string, *workflow.EngineConfig, map[string]any) { |
| 98 | content, err := readWorkflowFileContent(filePath) |
| 99 | if err != nil { |
| 100 | return "", nil, nil |
| 101 | } |
| 102 | |
| 103 | result, err := parser.ExtractFrontmatterFromContent(content) |
| 104 | if err != nil { |
| 105 | return "", nil, nil |
| 106 | } |
| 107 | |
| 108 | compiler := &workflow.Compiler{} |
| 109 | engineSetting, engineConfig := compiler.ExtractEngineConfig(result.Frontmatter) |
| 110 | |
| 111 | if engineConfig != nil && engineConfig.ID != "" { |
| 112 | return engineConfig.ID, engineConfig, result.Frontmatter |
| 113 | } |
| 114 | if engineSetting != "" { |
| 115 | return engineSetting, engineConfig, result.Frontmatter |
| 116 | } |
| 117 | return "copilot", engineConfig, result.Frontmatter // Default engine |
| 118 | } |
| 119 | |
| 120 | func hasCopilotRequestsWritePermission(frontmatter map[string]any) bool { |
| 121 | if frontmatter == nil { |
no test coverage detected