MCPcopy Create free account
hub / github.com/github/gh-aw / extractWorkflowDomainConfig

Function extractWorkflowDomainConfig

pkg/cli/domains_command.go:199–229  ·  view source on GitHub ↗

extractWorkflowDomainConfig reads a workflow file and returns its engine ID, network permissions, tools, and runtimes configuration.

(filePath string)

Source from the content-addressed store, hash-verified

197// extractWorkflowDomainConfig reads a workflow file and returns its engine ID,
198// network permissions, tools, and runtimes configuration.
199func extractWorkflowDomainConfig(filePath string) (engineID string, network *workflow.NetworkPermissions, tools map[string]any, runtimes map[string]any) {
200 content, err := os.ReadFile(filePath)
201 if err != nil {
202 domainsCommandLog.Printf("Failed to read workflow file %s: %v", filePath, err)
203 return "copilot", nil, nil, nil
204 }
205
206 result, err := parser.ExtractFrontmatterFromContent(string(content))
207 if err != nil || result.Frontmatter == nil {
208 domainsCommandLog.Printf("Failed to parse frontmatter from %s: %v", filePath, err)
209 return "copilot", nil, nil, nil
210 }
211
212 // Reuse the existing engine ID extraction helper which handles both string and object formats
213 engineID = extractEngineIDFromFrontmatter(result.Frontmatter)
214
215 // Parse structured frontmatter config to get NetworkPermissions and runtimes
216 config, err := workflow.ParseFrontmatterConfig(result.Frontmatter)
217 if err != nil {
218 domainsCommandLog.Printf("Failed to parse frontmatter config from %s: %v", filePath, err)
219 return engineID, nil, nil, nil
220 }
221
222 // Extract tools map from raw frontmatter (tools is kept as map[string]any)
223 var toolsMap map[string]any
224 if toolsRaw, ok := result.Frontmatter["tools"]; ok {
225 toolsMap, _ = toolsRaw.(map[string]any)
226 }
227
228 return engineID, config.Network, toolsMap, config.Runtimes
229}
230
231// computeAllowedDomains returns the effective allowed domains for an engine + network config.
232// It mirrors the logic used during workflow compilation.

Callers 3

RunListDomainsFunction · 0.85
RunWorkflowDomainsFunction · 0.85

Calls 4

ParseFrontmatterConfigFunction · 0.92
PrintfMethod · 0.45

Tested by 1