Overview
The Registry is an internal system created by createRegistry() that manages the storage and retrieval of plugin features (credentials, models, tools). It is used internally by the plugin instance and typically not accessed directly by plugin developers.
Type Definition
interface Registry {
plugin : PluginRegistry
register ( type : FeatureType , feature : Feature ) : void
resolve ( type : FeatureType , featureName : string ) : Feature
serialize () : SerializedRegistry
}
type FeatureType = 'credential' | 'model' | 'tool'
Function Signature
function createRegistry ( plugin : PluginRegistry ) : Registry
Parameters
The plugin definition object (excluding transporter options)
Properties
plugin
The plugin metadata and definitions, excluding transporter options.
Methods
register
Registers a feature (credential, model, or tool) into the registry.
register ( type : 'credential' , feature : CredentialDefinition ): void
register ( type : 'model' , feature : ModelDefinition ): void
register ( type : 'tool' , feature : ToolDefinition ): void
Parameters
type
'credential' | 'model' | 'tool'
required
The type of feature to register
feature
CredentialDefinition | ModelDefinition | ToolDefinition
required
The feature definition to register. Must match the type specified.
Example
const registry = createRegistry ({
name: 'my-plugin' ,
description: 'My plugin' ,
author: 'John Doe' ,
email: '[email protected] ' ,
version: '1.0.0'
})
registry . register ( 'tool' , {
name: 'my-tool' ,
description: 'Does something useful' ,
parameters: { query: { type: 'string' } },
invoke : async ({ parameters }) => ({ result: 'success' })
})
resolve
Resolves and retrieves a registered feature by its type and name.
resolve ( type : 'credential' , featureName : string ): CredentialDefinition
resolve ( type : 'model' , featureName : string ): ModelDefinition
resolve ( type : 'tool' , featureName : string ): ToolDefinition
Parameters
type
'credential' | 'model' | 'tool'
required
The type of feature to resolve
The name of the feature to retrieve
Returns
feature
CredentialDefinition | ModelDefinition | ToolDefinition
The resolved feature definition
Throws
Error if the feature with the specified name is not registered
Example
const toolDefinition = registry . resolve ( 'tool' , 'my-tool' )
console . log ( toolDefinition . description ) // 'Does something useful'
// Throws error if not found
try {
registry . resolve ( 'tool' , 'non-existent-tool' )
} catch ( error ) {
console . error ( error . message ) // 'Feature "non-existent-tool" not registered'
}
serialize
Serializes the entire registry into a JSON-compatible object format.
serialize (): {
plugin: PluginRegistry & {
credentials: Array < Record < string , JsonValue>>
models: Array < Record < string , JsonValue>>
tools: Array < Record < string , JsonValue>>
}
}
Returns
The serialized registry The plugin metadata with all registered features credentials
Array<Record<string, JsonValue>>
Array of serialized credential definitions
models
Array<Record<string, JsonValue>>
Array of serialized model definitions
tools
Array<Record<string, JsonValue>>
Array of serialized tool definitions
Throws
Error if the plugin is not registered (should never happen in normal usage)
Example
const serialized = registry . serialize ()
console . log ( JSON . stringify ( serialized , null , 2 ))
// {
// "plugin": {
// "name": "my-plugin",
// "description": "My plugin",
// "author": "John Doe",
// "email": "[email protected] ",
// "version": "1.0.0",
// "credentials": [],
// "models": [],
// "tools": [
// {
// "name": "my-tool",
// "description": "Does something useful",
// "parameters": { "query": { "type": "string" } }
// }
// ]
// }
// }
Internal Storage
The registry uses Map objects internally to store features:
interface RegistryStore {
plugin : PluginRegistry
credential : Map < string , CredentialDefinition >
model : Map < string , ModelDefinition >
tool : Map < string , ToolDefinition >
}
Each feature is stored with its name as the key, ensuring unique feature names per type.
Usage in Plugin Instance
The registry is created automatically when you call createPlugin() and is used internally by the plugin instance methods:
plugin.addCredential() calls registry.register('credential', ...)
plugin.addTool() calls registry.register('tool', ...)
plugin.addModel() calls registry.register('model', ...)
Event handlers use registry.resolve() to retrieve feature definitions
Debug mode uses registry.serialize() to write definition.json