Skip to content

Function: resolveGenieSpaces()

resolveGenieSpaces(config, context): Record<string, GenieSpaceConfig>

Discover Genie space aliases from every supported source and merge them into a single record. Precedence (highest first):

  1. MastraPluginConfig.genieSpaces on the mastra(...) call. Explicit Mastra wiring always wins so users can override AppKit’s defaults per-agent.
  2. AppKit genie({ spaces: { ... } }) plugin instance. Lets users keep using the existing AppKit config format (genie({ spaces: { sales: "...", ops: "..." } })) without restating the same record on the Mastra plugin. Read off the live plugin instance via a structural cast since Plugin.config is TS-protected (not runtime-private).
  3. DATABRICKS_GENIE_SPACE_ID env var (registered under the well-known default alias). Matches the AppKit genie() plugin’s fallback behavior so a bare mastra() + genie() pair just works.

Aliases collide cleanly: a higher-precedence source’s value replaces a lower one’s wholesale. A source that contributes zero aliases is skipped; a source that names an alias without a space id fails through normalizeGenieSpaces.

MastraPluginConfig

PluginContextLike | undefined

Record<string, GenieSpaceConfig>