definePlugin( )
Helper function to define a plugin with full type inference.
function definePlugin<T extends QvacPlugin>(plugin: T): T;
| Name | Type | Required? | Description |
|---|
| plugin | QvacPlugin | ✓ | The plugin definition |
| Field | Type | Required? | Description |
|---|
| modelType | string | ✓ | Unique identifier for the model type this plugin handles |
| displayName | string | ✓ | Human-readable name for the plugin |
| addonPackage | string | ✓ | The npm package name of the addon this plugin wraps |
| createModel | (params: CreateModelParams) => PluginModelResult | ✓ | Factory function that creates a model instance |
| handlers | Record<string, PluginHandlerDefinition> | ✓ | Map of handler names to handler definitions |
| logging | PluginLogging | ✗ | Optional logging configuration |
| Field | Type | Required? | Description |
|---|
| modelId | string | ✓ | The model identifier |
| modelPath | string | ✓ | Path to the model file |
| modelConfig | Record<string, unknown> | ✗ | Model-specific configuration |
| modelName | string | ✗ | Human-readable model name |
| artifacts | Record<string, string> | ✗ | Additional file paths (e.g., projectionModelPath, vadModelPath, ttsConfigModelPath) |
| Field | Type | Description |
|---|
| model | PluginModel | The model instance |
| loader | unknown | Engine-specific loader reference |
| Method | Signature | Required? | Description |
|---|
| load | (force?: boolean) => Promise<void> | ✓ | Loads the model into memory |
| unload | () => void | Promise<void> | ✗ | Releases model resources |
| Field | Type | Required? | Description |
|---|
| module | unknown | ✓ | The addon logging module |
| namespace | string | ✓ | Logger namespace |
T — The same plugin object, with full type inference applied. This is an identity function used for type checking.
See the Write a custom plugin guide for a full walkthrough.