Docs/TypeScript/Agent Module
Agentagent/README
Agent Module
The agent module provides a turn-based loop that streams assistant messages, executes tool calls, and emits structured events.
It builds on the AI module (indusagi/ai) and keeps all conversation context in AgentMessage format.
Entry point: indusagi/agent.
Source Map
The public entry indusagi/agent resolves to src/facade/agent.ts, which re-exports src/facade/bot/index.ts. The pieces live in src/facade/bot/:
src/facade/bot/agent.ts— theAgentclass andAgentOptions.src/facade/bot/agent-loop.ts— the core loop:agentLoopandagentLoopContinue.src/facade/bot/types.ts— types and theAgentEventmodel.src/facade/bot/state-manager.ts—AgentStateManager.src/facade/bot/event-bus.ts—AgentEventBus.src/facade/bot/proxy.ts—streamProxy, a remote streamingStreamFn.src/facade/bot/messages.ts— the defaultconvertToLlmand custom-message helpers.src/facade/bot/session-manager.ts—SessionManagerfor on-disk session persistence.src/facade/bot/actions/— the built-in tools/actions (read, write, edit, bash, grep, find, ls, process, todo, websearch, webfetch, composio).
Highlights
- Manages state, tool calls, and streaming in one place via the
Agentclass. - Supports steering and follow-up messages while a run is in progress.
- Emits
AgentEventvalues through a subscribe/unsubscribeAgentEventBus. - Accepts a custom
streamFn(e.g.streamProxy) in place of the defaultstreamSimple.
Default Model
The default model is getModel("google", "gemini-2.5-flash"). Swap it with agent.setModel(...) or by passing initialState.model.
Clean-room Equivalents
src/facade/bot is the established facade surface. The clean-room rebuild also ships two newer layers with their own subpath exports:
indusagi/runtime(src/runtime/index.ts) —createAgent, theAgenthandle, and theRunSnapshot/RunEvent/AgentConfigvocabulary, plus the purestep/cadencestate machine.indusagi/capabilities(src/capabilities/index.ts) —defineTool,ToolRegistry, the eleven built-in tools, and the assembledbuiltinRegistry/toolBox.
Next Docs
- Agent API Reference — exact public symbols of
indusagi/agent. - Agent Loop and Tools — the agent loop and tool-calling pipeline.
- Tools Reference — the built-in tool/action reference.
- Background Process Tool — the background
processtool.
