Module Structure
Thinkwell exports its API through two subpaths:Main Types (thinkwell:agent)
| Type | Produced By | Description |
|---|---|---|
Agent | Agent.connect() | Main entry point for connecting to AI agents |
Session | agent.createSession() | Manages multi-turn conversations with persistent context |
ThinkBuilder | agent.think() | Fluent API for building prompts with tools |
Connectors (thinkwell:connectors)
Architecture
Thinkwell follows a layered architecture:-
Agent - Establishes a connection to an AI agent via ACP. Create one with
Agent.connect(). -
Sessions - Agents support two interaction modes:
- Ephemeral: Use
agent.think()for single-turn interactions - Persistent: Use
agent.createSession()for multi-turn conversations
- Ephemeral: Use
-
ThinkBuilder - A fluent API for constructing prompts. Chain methods to build content, then call
.run()to execute.
Structured Output with @JSONSchema
Thinkwell uses the@JSONSchema JSDoc tag to define expected AI output structures. The CLI generates JSON Schemas from your TypeScript interfaces at build time:
description fields in the generated schema, helping the AI understand what each field should contain.
Next Steps
- Agent - Connecting to agents and managing sessions
- ThinkBuilder - Building prompts with the fluent API
- Connectors - Available agent connectors
- Sessions - Multi-turn conversations
