TypeScript types
@poolot/lily-web is written in TypeScript and ships .d.ts definitions, so every export is typed. This page lists the types you'll use most; import them directly from the package.
import {
createLilyAgent,
setInputHandler,
loadLily,
type CreateAgentOptions,
type LilyAgentHandle,
type LilyMessage,
type LilyContentPart,
type LilyEvent,
type LilyRunOptions,
type LilyRunResult,
type LilyUsage,
} from '@poolot/lily-web'
Core types
CreateAgentOptions— the options bag forcreateLilyAgent. Extends the engineLoadOptions.LilyAgentHandle— the objectcreateLilyAgentresolves to; see the method list.LilyMessage/LilyContentPart— the conversation types; see Events and messages.LilyEvent— the streaming event union; see the event table.LilyRunOptions— per-run limits and callbacks.LilyRunResult— whatrunDetailedandcontinuereturn.LilyUsage—{ inputTokens; outputTokens; cachedInputTokens; calls }.
Typed events
Because LilyEvent is a discriminated union, a switch on event.type narrows the payload:
function handle(event: LilyEvent) {
if (event.type === 'tool_call') {
// event.name and event.arguments are available here
} else if (event.type === 'usage') {
// event.usage and event.cumulative are LilyUsage
}
}
Top-level functions
function createLilyAgent(opts?: CreateAgentOptions): Promise<LilyAgentHandle>
function loadLily(opts?: LoadOptions): Promise<unknown> // preload the engine (optional)
function setInputHandler(
fn: ((question: string, placeholder: string, id: string) => string | null | Promise<string | null>) | null,
): unknown // returns the previous handler
loadLilywarms the engine ahead of time;createLilyAgentcalls it internally, so you only need it to preload.setInputHandlerregisters how the agent'sask_userquestions are answered — see Answering the agent's questions.
Beyond the basics
The package also exports helpers for structured output (@poolot/lily-web/structured), custom tools, approval rules, hooks, sessions, and environment detection (detectEnvironment, listModels, and more). Reach for these once the basics are in place; the shipped .d.ts files are the source of truth for their exact signatures.