Package com.google.genkit.core
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 Summary
Modifier and TypeMethodDescriptionbooleanisChild()Returns true if this registry is a child of another registry.Returns a list of all registered actions.listActions(ActionType type) Returns a list of all registered actions of the specified type.Returns a list of all registered plugins.Returns a map of all registered values.default Action<?, ?, ?> lookupAction(ActionType type, String name) Returns the action for the given type and name.Action<?, ?, ?> lookupAction(String key) Returns the action for the given key.lookupHelper(String name) Returns a registered helper by name.lookupPartial(String name) Returns a registered partial by name.lookupPlugin(String name) Returns the plugin for the given name.lookupSchema(String name) Returns a JSON schema for the given name.lookupValue(String name) Returns the value for the given name.newChild()Creates a new child registry that inherits from this registry.default voidregisterAction(ActionType type, Action<?, ?, ?> action) Registers an action by type and action name.voidregisterAction(String key, Action<?, ?, ?> action) Records the action in the registry.voidregisterHelper(String name, Object helper) Registers a helper function for use with prompts.voidregisterPartial(String name, String source) Registers a partial template for use with prompts.voidregisterPlugin(String name, Plugin plugin) Records the plugin in the registry.voidregisterSchema(String name, Map<String, Object> schema) Records a JSON schema in the registry.voidregisterValue(String name, Object value) Records an arbitrary value in the registry.default Action<?, ?, ?> resolveAction(ActionType type, String name) Looks up an action by type and name with dynamic resolution support.Action<?, ?, ?> resolveAction(String key) Looks up an action by key.
-
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
Records the plugin in the registry.- Parameters:
name- the plugin nameplugin- the plugin to register- Throws:
IllegalStateException- if a plugin with the same name is already registered
-
registerAction
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
Records an arbitrary value in the registry.- Parameters:
name- the value namevalue- the value to register- Throws:
IllegalStateException- if a value with the same name is already registered
-
registerSchema
Records a JSON schema in the registry.- Parameters:
name- the schema nameschema- the schema as a map- Throws:
IllegalStateException- if a schema with the same name is already registered
-
lookupPlugin
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
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
Returns the action for the given type and name.- Parameters:
type- the action typename- the action name- Returns:
- the action, or null if not found
-
lookupValue
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
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
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
Looks up an action by type and name with dynamic resolution support.- Parameters:
type- the action typename- the action name- Returns:
- the action if found, or null if not found
-
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
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
Registers an action by type and action name.- Parameters:
type- the action typeaction- the action to register
-
listPlugins
Returns a list of all registered plugins.- Returns:
- list of all registered plugins
-
listValues
Returns a map of all registered values.- Returns:
- map of all registered values
-
registerPartial
Registers a partial template for use with prompts.- Parameters:
name- the partial namesource- the partial template source
-
registerHelper
Registers a helper function for use with prompts.- Parameters:
name- the helper namehelper- the helper function
-
lookupPartial
Returns a registered partial by name.- Parameters:
name- the partial name- Returns:
- the partial source, or null if not found
-
lookupHelper
Returns a registered helper by name.- Parameters:
name- the helper name- Returns:
- the helper function, or null if not found
-