Module Structure
Thinkwell exports everything from a single package:| Export | Description |
|---|---|
open() | Main entry point — opens a connection to a named agent |
Agent | The agent interface returned by open() |
Session | Manages multi-turn conversations with persistent context |
Plan | Fluent API for building prompts with tools |
Architecture
Thinkwell follows a layered architecture:-
Agent - Establishes a connection to an AI agent via ACP. Create one with
open(). -
Sessions - Agents support two interaction modes:
- Ephemeral: Use
agent.think()for single-turn interactions - Persistent: Use
agent.createSession()for multi-turn conversations
- Ephemeral: Use
-
Plan - 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.
