Skip to content

HostExports

Defined in: gadgets/types.ts:860

Host llmist exports provided to external gadgets via ExecutionContext.

This ensures external gadgets use the same class instances as the host CLI, enabling proper tree sharing and avoiding the “dual-package problem” where different versions of llmist have incompatible classes.

AgentBuilder: typeof AgentBuilder

Defined in: gadgets/types.ts:862

AgentBuilder for creating subagents with proper tree sharing


createGadget: <TSchema>(config) => AbstractGadget

Defined in: gadgets/types.ts:866

createGadget for functional gadget definitions

Creates a gadget from a function (simpler than class-based approach).

This is perfect for simple gadgets where you don’t need the full power of a class. Parameters are automatically typed from the schema.

TSchema extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>

CreateGadgetConfig<TSchema>

Configuration with execute function and schema

AbstractGadget

Gadget instance ready to be registered

import { z } from 'zod';
import { createGadget } from 'llmist';
// Simple calculator gadget
const calculator = createGadget({
description: "Performs arithmetic operations",
schema: z.object({
operation: z.enum(["add", "subtract", "multiply", "divide"]),
a: z.number().describe("First number"),
b: z.number().describe("Second number"),
}),
execute: ({ operation, a, b }) => {
// Parameters are automatically typed!
switch (operation) {
case "add": return String(a + b);
case "subtract": return String(a - b);
case "multiply": return String(a * b);
case "divide": return String(a / b);
}
},
});
// Async gadget with custom name and timeout
const weather = createGadget({
name: "weather",
description: "Fetches current weather for a city",
schema: z.object({
city: z.string().min(1).describe("City name"),
}),
timeoutMs: 10000,
execute: async ({ city }) => {
const response = await fetch(`https://api.weather.com/${city}`);
const data = await response.json();
return `Weather in ${city}: ${data.description}, ${data.temp}°C`;
},
});
// Use with agent
const agent = LLMist.createAgent()
.withGadgets(calculator, weather)
.ask("What's the weather in Paris and what's 10 + 5?");

ExecutionTree: typeof ExecutionTree

Defined in: gadgets/types.ts:868

ExecutionTree for tree operations


Gadget: <TSchema>(config) => () => GadgetBase<TSchema> & object

Defined in: gadgets/types.ts:864

Gadget factory for defining gadgets

Factory function to create a typed gadget base class.

The returned class automatically infers parameter types from the Zod schema, eliminating the need for manual type assertions in the execute method.

TSchema extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>

GadgetConfig<TSchema>

Configuration with description and schema

Base class to extend with typed execute method

(): GadgetBase<TSchema> & object

GadgetBase<TSchema> & object

import { z } from 'zod';
import { Gadget } from 'llmist';
class Calculator extends Gadget({
description: "Performs arithmetic operations",
schema: z.object({
operation: z.enum(["add", "subtract", "multiply", "divide"]),
a: z.number().describe("First number"),
b: z.number().describe("Second number"),
}),
}) {
execute(params: this['params']): string {
// params is automatically typed as:
// { operation: "add" | "subtract" | "multiply" | "divide"; a: number; b: number }
const { operation, a, b } = params;
switch (operation) {
case "add": return String(a + b);
case "subtract": return String(a - b);
case "multiply": return String(a * b);
case "divide": return String(a / b);
}
}
}
// With async execution
class WeatherGadget extends Gadget({
description: "Fetches weather for a city",
schema: z.object({
city: z.string().min(1).describe("City name"),
}),
timeoutMs: 10000,
}) {
async execute(params: this['params']): Promise<string> {
const { city } = params; // Automatically typed as { city: string }
const weather = await fetchWeather(city);
return `Weather in ${city}: ${weather}`;
}
}

LLMist: typeof LLMist

Defined in: gadgets/types.ts:870

LLMist client


z: __module

Defined in: gadgets/types.ts:872

Zod schema builder