A TypeScript implementation demonstrating a sophisticated prompt chaining system with specialized AI agents.
This system implements a multi-agent architecture where each agent specializes in a specific task:
graph TD
A[User Query] --> B[User Query Receiver]
B --> C[Summarizer]
C --> D[Pain Identifier]
D --> E[Plan Creator]
E --> F[AI Spawner]
F --> G[Specialized Agents]
G --> H[Responder]
C -.Summary.-> H
D -.Pain Points.-> H
E -.Plan.-> H
F -.Execution Results.-> H
H --> I[Final Response to User]
style A fill:#e1f5ff
style H fill:#fff4e1
style I fill:#e8f5e9
- User Query Receiver: Entry point that receives user queries and coordinates the chain
- Summarizer: Extracts key findings from the user query
- Pain Identifier: Identifies top pain points from the summary
- Plan Creator: Creates a step-by-step plan using available tools
- AI Spawner: Dynamically spawns specialized agents based on the plan
- Responder: Aggregates results and responds to the user
npm installCreate a .env file use env.example for reference.
Start the interactive terminal chat:
npm run dev
# or
npm startThis starts an interactive CLI where you can chat with the system. Available commands:
help- Show available commandsclear- Clear screenreset- Reset the systemhistory- Show chain execution historyexit- Exit the program
Run the built-in demonstration:
npm run demoThis processes example queries and shows the complete chain execution.
src/
├── types/ # TypeScript interfaces and types
├── agents/ # Specialized agent implementations
├── tools/ # Available tools for agents
├── orchestrator/ # Chain orchestration logic
├── cli.ts # Interactive CLI (npm start/dev)
└── index.ts # Demo examples (npm run demo)
- User submits a query
- Query is summarized to extract key information
- Pain points are identified from the summary
- A plan is created based on available tools
- Specialized agents are dynamically spawned to execute the plan
- Results are aggregated and returned to the user