Interface Registry

All Known Implementing Classes:
DefaultRegistry

public interface Registry
Registry holds all registered actions and associated types, and provides methods to register, query, and look up actions.

The Registry is the central component for managing Genkit primitives. It provides:

  • Storage and lookup of actions by key
  • Plugin management
  • Value storage for configuration
  • Schema registration for JSON validation
  • Hierarchical registry support for scoped operations
  • Method Details

    • newChild

      Registry newChild()
      Creates a new child registry that inherits from this registry. Child registries are useful for scoped operations and will fall back to the parent for lookups if a value is not found in the child.
      Returns:
      a new child registry
    • isChild

      boolean isChild()
      Returns true if this registry is a child of another registry.
      Returns:
      true if this is a child registry
    • registerPlugin

      void registerPlugin(String name, Plugin plugin)
      Records the plugin in the registry.
      Parameters:
      name - the plugin name
      plugin - the plugin to register
      Throws:
      IllegalStateException - if a plugin with the same name is already registered
    • registerAction

      void registerAction(String key, Action<?,?,?> action)
      Records the action in the registry.
      Parameters:
      key - the action key (type + name)
      action - the action to register
      Throws:
      IllegalStateException - if an action with the same key is already registered
    • registerValue

      void registerValue(String name, Object value)
      Records an arbitrary value in the registry.
      Parameters:
      name - the value name
      value - the value to register
      Throws:
      IllegalStateException - if a value with the same name is already registered
    • registerSchema

      void registerSchema(String name, Map<String,Object> schema)
      Records a JSON schema in the registry.
      Parameters:
      name - the schema name
      schema - the schema as a map
      Throws:
      IllegalStateException - if a schema with the same name is already registered
    • lookupPlugin

      Plugin lookupPlugin(String name)
      Returns the plugin for the given name. It first checks the current registry, then falls back to the parent if not found.
      Parameters:
      name - the plugin name
      Returns:
      the plugin, or null if not found
    • lookupAction

      Action<?,?,?> lookupAction(String key)
      Returns the action for the given key. It first checks the current registry, then falls back to the parent if not found.
      Parameters:
      key - the action key
      Returns:
      the action, or null if not found
    • lookupAction

      default Action<?,?,?> lookupAction(ActionType type, String name)
      Returns the action for the given type and name.
      Parameters:
      type - the action type
      name - the action name
      Returns:
      the action, or null if not found
    • lookupValue

      Object lookupValue(String name)
      Returns the value for the given name. It first checks the current registry, then falls back to the parent if not found.
      Parameters:
      name - the value name
      Returns:
      the value, or null if not found
    • lookupSchema

      Map<String,Object> lookupSchema(String name)
      Returns a JSON schema for the given name. It first checks the current registry, then falls back to the parent if not found.
      Parameters:
      name - the schema name
      Returns:
      the schema as a map, or null if not found
    • resolveAction

      Action<?,?,?> resolveAction(String key)
      Looks up an action by key. If the action is not found, it attempts dynamic resolution through registered dynamic plugins.
      Parameters:
      key - the action key
      Returns:
      the action if found, or null if not found
    • resolveAction

      default Action<?,?,?> resolveAction(ActionType type, String name)
      Looks up an action by type and name with dynamic resolution support.
      Parameters:
      type - the action type
      name - the action name
      Returns:
      the action if found, or null if not found
    • listActions

      List<Action<?,?,?>> listActions()
      Returns a list of all registered actions. This includes actions from both the current registry and its parent hierarchy.
      Returns:
      list of all registered actions
    • listActions

      List<Action<?,?,?>> listActions(ActionType type)
      Returns a list of all registered actions of the specified type.
      Parameters:
      type - the action type to filter by
      Returns:
      list of actions of the specified type
    • registerAction

      default void registerAction(ActionType type, Action<?,?,?> action)
      Registers an action by type and action name.
      Parameters:
      type - the action type
      action - the action to register
    • listPlugins

      List<Plugin> listPlugins()
      Returns a list of all registered plugins.
      Returns:
      list of all registered plugins
    • listValues

      Map<String,Object> listValues()
      Returns a map of all registered values.
      Returns:
      map of all registered values
    • registerPartial

      void registerPartial(String name, String source)
      Registers a partial template for use with prompts.
      Parameters:
      name - the partial name
      source - the partial template source
    • registerHelper

      void registerHelper(String name, Object helper)
      Registers a helper function for use with prompts.
      Parameters:
      name - the helper name
      helper - the helper function
    • lookupPartial

      String lookupPartial(String name)
      Returns a registered partial by name.
      Parameters:
      name - the partial name
      Returns:
      the partial source, or null if not found
    • lookupHelper

      Object lookupHelper(String name)
      Returns a registered helper by name.
      Parameters:
      name - the helper name
      Returns:
      the helper function, or null if not found