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

Method ExtractEngineConfig

pkg/workflow/engine.go:192–579  ·  view source on GitHub ↗

ExtractEngineConfig extracts engine configuration from frontmatter, supporting both string and object formats

(frontmatter map[string]any)

Source from the content-addressed store, hash-verified

190
191// ExtractEngineConfig extracts engine configuration from frontmatter, supporting both string and object formats
192func (c *Compiler) ExtractEngineConfig(frontmatter map[string]any) (string, *EngineConfig) {
193 topLevelMaxTurns := parseMaxTurnsValue(frontmatter["max-turns"])
194 topLevelMaxToolDenials := parseMaxToolDenialsValue(frontmatter["max-tool-denials"])
195 topLevelMaxAICredits := parseMaxAICreditsValue(frontmatter["max-ai-credits"])
196 topLevelMaxTurnCacheMisses := parseMaxTurnCacheMissesValue(frontmatter["max-turn-cache-misses"])
197 topLevelMaxRuns := parseMaxRunsValue(frontmatter["max-turns"])
198 if topLevelMaxRuns == 0 {
199 topLevelMaxRuns = parseMaxRunsValue(frontmatter["max-runs"])
200 }
201
202 if engine, exists := frontmatter["engine"]; exists {
203 engineLog.Print("Extracting engine configuration from frontmatter")
204
205 // Handle string format (backwards compatibility)
206 if engineStr, ok := engine.(string); ok {
207 engineLog.Printf("Found engine in string format: %s", engineStr)
208 return engineStr, &EngineConfig{
209 ID: engineStr,
210 MaxTurns: topLevelMaxTurns,
211 MaxToolDenials: topLevelMaxToolDenials,
212 MaxRuns: topLevelMaxRuns,
213 MaxTurnCacheMisses: topLevelMaxTurnCacheMisses,
214 MaxAICredits: topLevelMaxAICredits,
215 }
216 }
217
218 // Handle object format
219 if engineObj, ok := engine.(map[string]any); ok {
220 engineLog.Print("Found engine in object format, parsing configuration")
221 config := &EngineConfig{}
222
223 // Detect inline definition: engine.runtime sub-object present instead of engine.id
224 if runtime, hasRuntime := engineObj["runtime"]; hasRuntime {
225 engineLog.Print("Found inline engine definition (engine.runtime sub-object)")
226 config.IsInlineDefinition = true
227
228 if runtimeObj, ok := runtime.(map[string]any); ok {
229 if id, ok := runtimeObj["id"].(string); ok {
230 config.ID = id
231 engineLog.Printf("Inline engine runtime.id: %s", config.ID)
232 }
233 if version, hasVersion := runtimeObj["version"]; hasVersion {
234 config.Version = stringutil.ParseVersionValue(version)
235 }
236 }
237
238 // Extract optional provider sub-object
239 if provider, hasProvider := engineObj["provider"]; hasProvider {
240 if providerObj, ok := provider.(map[string]any); ok {
241 if id, ok := providerObj["id"].(string); ok {
242 config.InlineProviderID = id
243 }
244 if model, ok := providerObj["model"].(string); ok {
245 config.Model = model
246 }
247 if auth, hasAuth := providerObj["auth"]; hasAuth {
248 if authObj, ok := auth.(map[string]any); ok {
249 authDef := parseAuthDefinition(authObj)

Calls 15

ParseVersionValueFunction · 0.92
ParseIntValueFunction · 0.92
parseMaxTurnsValueFunction · 0.85
parseMaxToolDenialsValueFunction · 0.85
parseMaxAICreditsValueFunction · 0.85
parseMaxRunsValueFunction · 0.85
parseAuthDefinitionFunction · 0.85
parseRequestShapeFunction · 0.85
toEngineEnvValueStringFunction · 0.85
parseEngineAuthConfigFunction · 0.85
applyEngineAuthEnvFunction · 0.85