v0.1.0 / ALPHA
A lightweight TypeScript AI agent framework
Lean core. Ready to use. Built to extend.
$ npm install @yong_xie/lighterhello.tsTypeScript
import { Agent, Model, OpenAIProvider,
UserMessage } from "@yong_xie/lighter";
// Connect your model provider
const provider = new OpenAIProvider(
process.env.OPENAI_API_KEY!,
process.env.OPENAI_MODEL!
);
const agent = new Agent({
model: new Model(provider)
});
// Run your first agent
const result = await agent.run({
messages: [new UserMessage("Name a bookstore on the moon.")]
});
console.log(result.messages.at(-1));Example output
Moonlight BooksRequires an API key. Tool examples use Zod 4. Outputs are illustrative.
02 / UNDER THE HOOD
A lean, reliable core loop.
02 / LIGHTER COREModel
Reply or call tools
03 / YOUR CAPABILITIESTool
Execute and return results
03 / MAKE IT YOURS
Make it your own.
TOOLS01
Add tools
new Tool({
name: "search",
parametersZodSchema,
func: search
})View example↗
STREAMING02
Streaming
for await (const event of
agent.stream({ messages })) {
// Handle text deltas
}View example↗
LIFECYCLE HOOKS03
Lifecycle hooks
new BeforeModelHook({
hookName: "log-request",
hookFunction: (request) => {
console.log(request);
}
})View example↗
What do I need?
Node.js 22+, an ESM project, and an API key and model ID for your provider.
What does my app handle?
Conversation storage, loop limits, permissions, and tool isolation. See runtime limits.
Is the current version stable?
Lighter is in alpha. Breaking API changes are possible.