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

Method registerInlineEngineDefinition

pkg/workflow/engine_validation.go:267–307  ·  view source on GitHub ↗

registerInlineEngineDefinition registers an inline engine definition in the session catalog. If the runtime ID already exists in the catalog (e.g. a built-in), the existing display name and description are preserved while provider overrides are applied.

(config *EngineConfig)

Source from the content-addressed store, hash-verified

265// catalog. If the runtime ID already exists in the catalog (e.g. a built-in), the
266// existing display name and description are preserved while provider overrides are applied.
267func (c *Compiler) registerInlineEngineDefinition(config *EngineConfig) {
268 def := &EngineDefinition{
269 ID: config.ID,
270 RuntimeID: config.ID,
271 DisplayName: config.ID,
272 Description: "Inline engine definition from workflow frontmatter",
273 }
274
275 // Preserve display name and description from existing built-in entry if available.
276 if existing := c.engineCatalog.Get(config.ID); existing != nil {
277 def.DisplayName = existing.DisplayName
278 def.Description = existing.Description
279 def.Models = existing.Models
280 // Copy existing provider/auth as defaults; inline values below fully replace them
281 // when present (replacement, not merge).
282 def.Provider = existing.Provider
283 }
284
285 // Apply inline provider overrides.
286 if config.InlineProviderID != "" {
287 def.Provider = ProviderSelection{Name: config.InlineProviderID}
288 }
289
290 // Prefer the full AuthDefinition over the legacy simple-secret path.
291 if config.InlineProviderAuth != nil {
292 // Normalise strategy: treat empty strategy as api-key when a secret is set.
293 auth := config.InlineProviderAuth
294 if auth.Strategy == "" && auth.Secret != "" {
295 auth.Strategy = AuthStrategyAPIKey
296 }
297 def.Provider.Auth = auth
298 }
299
300 if config.InlineProviderRequest != nil {
301 def.Provider.Request = config.InlineProviderRequest
302 }
303
304 engineValidationLog.Printf("Registering inline engine definition in session catalog: id=%s, runtimeID=%s, providerID=%s",
305 def.ID, def.RuntimeID, def.Provider.Name)
306 c.engineCatalog.Register(def)
307}
308
309// validateEngineAuthDefinition validates AuthDefinition fields for an inline engine definition.
310// Returns an error describing the first (or all, in non-fail-fast mode) validation problems found.

Calls 3

GetMethod · 0.45
PrintfMethod · 0.45
RegisterMethod · 0.45