LensStudio:ChatTool.ChatTool
ClassBase class for AI-invokable operations; extend this to implement a tool that the AI can call via execute().
Index
Properties
Methods
Example
// ChatTool is the base class for building AI-invokable tools in Lens Studio.
// Override execute(parameters) to handle invocation from a ChatAssistant.
//
// Properties:
// pluginSystem (readonly) — Editor.PluginSystem for resolving interfaces
//
// Methods:
// execute(parameters: Parameters): Promise<Result>
// parameters.data contains parsed arguments matching the Descriptor's schema.
// Return a Result with data on success or error on failure.
export class LensStudioChatToolChatToolExampleTool extends ChatTool {
connections: any[];
static descriptor() {
const d = new Descriptor();
d.id = 'com.docs.LensStudioChatToolChatToolExample';
d.name = 'List Scene Objects';
d.description = 'Lists root scene objects in the current project';
d.dependencies = [Editor.Model.IModel];
d.schema = {
type: 'object',
properties: {
maxCount: { type: 'number', description: 'Maximum number of objects to return' },
},
};
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 maxCount = parameters?.data?.maxCount ?? 10;
const model = this.pluginSystem.findInterface(Editor.Model.IModel) as unknown as Editor.Model.IModel;
const scene = model.project.scene;
const names = scene.rootSceneObjects
.slice(0, maxCount)
.map((obj: Editor.Model.SceneObject) => obj.name);
result.data = { objects: names, total: scene.rootSceneObjects.length };
} catch (e: any) {
result.error = `Failed: ${e?.message ?? e}`;
}
return result;
}
}
Extends
Constructors
Constructor
new ChatTool(
pluginSystem,descriptor?):ChatTool
Constructs a ChatTool plugin instance with the given plugin system and optional descriptor.
Parameters
| Parameter | Type |
|---|---|
pluginSystem | PluginSystem |
descriptor? | Descriptor |
Returns
ChatTool
Overrides
Editor.IPlugin.constructor
Properties
id
readonlyid:string
Unique string identifier of the plugin instance.
Inherited from
pluginSystem
readonlypluginSystem:PluginSystem
The PluginSystem instance used to access shared Editor interfaces via findInterface().
Methods
execute()
execute(
parameters):Promise<Result>
Executes the tool with the given parameters and returns a Result containing output data or an error string.
Parameters
| Parameter | Type |
|---|---|
parameters | Parameters |
Returns
Promise<Result>
getTypeName()
staticgetTypeName():string
Returns the type name of this class.
Returns
string
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object is of the specified type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object refers to the same instance as the given object.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean