LensStudio:ChatTool
ModuleModule providing base classes and interfaces for building AI-invokable ChatTool plugins in Lens Studio.
Example
// The LensStudio:ChatTool module provides the ChatTool plugin pattern for
// building tools that a ChatAssistant can invoke.
//
// Module exports:
// ChatTool — base class (extends IPlugin); override execute(parameters)
// Descriptor — extends BaseDescriptor; adds schema (JSON Schema object)
// Parameters — wrapper with data: any (parsed args matching the schema)
// Result — wrapper with data: any and error: string
//
// Flow: ChatAssistant -> IChatToolRegistry -> ChatTool.execute(parameters) -> Result
export class LensStudioChatToolExampleTool extends ChatTool {
connections: any[];
static descriptor() {
const d = new Descriptor();
d.id = 'com.docs.LensStudioChatToolExample';
d.name = 'ChatTool Overview';
d.description = 'Demonstrates a minimal ChatTool that echoes its input';
d.dependencies = [Editor.Model.IModel];
d.schema = {
type: 'object',
properties: {
message: { type: 'string', description: 'Message to echo' },
},
required: ['message'],
};
return d;
}
constructor(pluginSystem: Editor.PluginSystem, descriptor?: Descriptor) {
super(pluginSystem, descriptor);
this.connections = [];
}
async execute(parameters: any): Promise<any> {
const result = new Result();
try {
const msg = parameters?.data?.message ?? '(no message)';
const model = this.pluginSystem.findInterface(Editor.Model.IModel) as unknown as Editor.Model.IModel;
const assetCount = model.project.assetManager.assets.length;
result.data = { echo: msg, assetCount };
} catch (e: any) {
result.error = `Failed: ${e?.message ?? e}`;
}
return result;
}
}
Classes
| Class | Description |
|---|---|
| ChatTool | Base class for AI-invokable operations; extend this to implement a tool that the AI can call via execute(). |
| Descriptor | Defines a ChatTool's identity and metadata, including id, name, description, and dependencies. |
| IChatToolRegistry | Interface for registering and discovering ChatTool instances within the plugin system. |
| Parameters | Holds the input parameters passed to a ChatTool's execute() call. |
| Result | Holds the outcome of a ChatTool execution, with data on success or an error string on failure. |