@falai/agent docs
@falai/agent is a TypeScript library for building chat assistants. The AI understands what the customer wrote; your code decides what happens next. One agent.turn() takes a message, a timer, an event from your system or a manual start, and returns the messages to send and the timers to set. Your program, the host, sends and schedules them.
Tutorial
Five pages that build one agent from install to production. Start at Install.
Guides
One page per task. Each shows the code you write and what the framework does with it. Open Triggers first, since every flow starts with one; the rest stand alone.
- Triggers — message, mention, silence, event, manual start
- Conditions —
when(the model) versusif(your code) - Branching — forks while a step is asking
- Flow control —
then,else,onEnd,while, chaining flows - Actions and events — what your code does and what it reports
- Instructions — rules the model follows at agent, flow or step level
- Error handling — what throws, what stays put and retries on a timer, what you replay
- Persistence —
Store, the version check on save, the seven built-in stores - Streaming —
turnStreamand its chunks - Compaction — trimming long histories once per turn
- Flows from JSON —
FlowSpec,fromSpec,validateFlow - Testing — a fake clock, an in-memory store, a scripted provider
Concepts
Four pages explain the design. Start with Architecture.
- Architecture — agent, flow, trigger, step, field, run, turn
- Pipeline — the eight phases of one turn and what each costs
- Runs and waits — who is speaking (the floor), timers (wakes), keys and claims
- Collection — how fields get filled
Reference
One page per public type, with every field, its type and its default, taken from the code. Start at Agent, which covers falai(), the agent options, turn() and its result.
- Agent · Flow · Step · Trigger · Fields · Branches
- Actions, events, conditions · Instruction · Tool
- Session · Stores · Flow spec · Outcomes · Errors · Providers
Upgrading from 3.x? v4 is a clean break: nothing old compiles. The v3 → v4 migration guide has the before and after for every change.