LuaTool is the interface every tool implements: a name, a description the model reads to decide when to call it, a Zod inputSchema, and an async execute. Tools live inside a LuaSkill; lua compile bundles each tool as its own artifact, and the runtime parses the model’s arguments with inputSchema before execute runs. LuaTool is a type-only export; ToolFlag is a runtime enum.
Verified against lua-cli 3.33.0.
Quick example
The class form the project scaffold uses.src/skills/tools/LookupOrderTool.ts
tools: [new LookupOrderTool()], with no constructor arguments; the compiler drops any arguments and warns lua/constructor-args-dropped. Run it with the tool name and its own fields as JSON.
Output
Members
Fields ofLuaTool<TInput extends ZodType = ZodType>, in declaration order.
name
string
required
Identifier the model calls. Letters, digits,
-, and _ only; a skill throws when it contains anything else. Convention is snake_case, and lua compile warns unless the name matches ^[a-z][a-z0-9-_]*$. Also the value of --name for lua test skill.description
string
required
What the tool does and when to use it. Sent to the model together with the schema.
inputSchema
ZodType
required
Zod schema for the arguments. The compiler converts it to JSON Schema for the model, and the runtime parses the arguments with it before
execute runs. .describe() text reaches the model.execute()
Runs the tool with validated arguments.input as z.infer<typeof this.inputSchema> to get the schema’s static type.
z.infer<typeof inputSchema>
required
The arguments, parsed by
inputSchema.LuaToolCtx
undefined outside a voice session. In a voice session it carries toolCallId and voice.say(text), which speaks text to the caller while the tool keeps running.Error to fail the call.
Errors — none beyond what your code throws.
condition()
Decides whether the tool is offered on a turn.false removes the tool from the model’s list for that turn; the skill’s context stays in the prompt, so the model can still mention what the tool does. A throw or a 30-second timeout disables the tool for that turn. To hide the whole skill, use LuaSkill.condition.
Example
voice
{ flags?: ToolFlag[] }
Flags applied when the tool is offered inside a voice session. Tools without it behave the same in chat and voice.
Authoring forms
Two shapes compile as a tool.- Class form:
class X implements LuaTool, or a class that extends one. The compiler walks theextendschain, so a shared base class works, and a field initializer on the subclass overrides the base. Register withnew X(). - Object form: a plain object with a string
name, anexecute, and at least one ofdescription,inputSchema, or aLuaToolannotation (: LuaTool,as LuaTool,satisfies LuaTool). Register by reference.
src/skills/tools/cancelOrder.ts
lua compile fails with Tool must have an execute function when execute is missing and warns Tool should have an inputSchema for type safety when inputSchema is. Voice-only tools use the LuaVoiceTool class instead; see defineVoice.
Types
enum
Values for
voice.flags.interface
The second argument of
execute. Not exported by name; derive it with NonNullable<Parameters<LuaTool['execute']>[1]>.
