Preparing search index...

    Base class for AI-invokable operations; extend this to implement a tool that the AI can call via execute().

    // 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;
    }
    }

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    id: string
    pluginSystem: PluginSystem

    The PluginSystem instance used to access shared Editor interfaces via findInterface().

    Methods

    • Executes the tool with the given parameters and returns a Result containing output data or an error string.

      Parameters

      Returns Promise<Result>

    • Returns the name of this object's type.

      Returns string

    • Returns true if the object is of the specified type.

      Parameters

      • type: string

      Returns boolean

    • Returns true if this object refers to the same instance as the given object.

      Parameters

      Returns boolean