🎉 AStack v0.1.1-beta.0 is now available! Try it today with npm install @astack-tech/core
AStackA composable framework for building AI applications.
Everything is a component. Build powerful agent workflows with a pure functional programming approach using AStack's composable architecture.
1import { Pipeline } from "@astack-tech/core";
2import { Agent } from "@astack-tech/components";
3import { Deepseek } from "@astack-tech/integrations/model-provider";
4import { PromptTemplate } from "@astack-tech/components";
5
6// Create a simple pipeline with components
7const pipeline = new Pipeline();
8
9// Add components to the pipeline
10pipeline.addComponent('template', new PromptTemplate({
11 template: "Answer this question: {{question}}"
12}));
13pipeline.addComponent('model', new Deepseek({
14 apiKey: process.env.DEEPSEEK_API_KEY,
15 model: "deepseek-chat"
16}));
17pipeline.addComponent('agent', new Agent());
18
19// Run the pipeline
20const response = await pipeline.run('template.input', {
21 question: "What is functional programming?"
22});
23
24console.log(response);
Core Features
AStack implements a modern, component-based approach to building AI agents and workflows, with a focus on functional programming principles and composability.
Everything is a Component
All elements inherit from the Component base class, with input and output ports for data flow, enabling both standalone and pipeline execution.
Zero Adaptation Layer
Agents directly accept any model provider component and tools without middleware adapters, creating a cleaner and more intuitive API.
Dual Run Modes
Run components independently with run() or compose them into pipelines with _transform() - same interface, maximum flexibility.
Type-Safe Ports
Components communicate through a port system that ensures type safety and transparent data flow between components.
Modular Package Design
Organized into core abstractions, domain-specific components, and external integrations for maximum code reuse and extensibility.
External Ecosystem Integration
Leverage OpenAI-compatible interfaces to integrate external model providers without requiring specialized SDKs.
Computation Model
AStack implements a sophisticated computation model based on the HLang monadic functional programming paradigm, combining the flexibility of functional programming with the practical advantages of component-based development.
Operator Composition
Key Features
- Each component is a composable transformation operator
- Maintains function purity with clear inputs and outputs
- Ensures type safety and transparent data flow through the port system
1// Component as transformation operator
2const textProcessor = new Pipeline();
3
4// Adding components with proper names
5textProcessor.addComponent('splitter', new TextSplitter());
6textProcessor.addComponent('embedder', new Embedder());
7textProcessor.addComponent('vectorStore', new VectorStore());
8
9// Function-style pipeline execution
10const result = await textProcessor.run('splitter.input', document);
Workflow Orchestration
Key Features
- Supports complex workflows with branching and merging
- Provides dynamic routing and parallel processing
Reactive Data Flow
Key Features
- Implements event-driven asynchronous processing
- Supports backpressure and hot/cold data streams
Inter-Agent Communication
Key Features
- Supports complex interactions between agents
- Maintains context continuity across multiple exchanges
- Enables multi-agent coordination and tool integration
1// Inter-agent communication example
2const coordinator = new AgentCoordinator();
3
4// Register multiple specialized agents
5coordinator.register([
6 new ResearchAgent({ name: 'researcher' }),
7 new AnalysisAgent({ name: 'analyst' }),
8 new WriterAgent({ name: 'writer' })
9]);
10
11// Start collaboration process
12const report = await coordinator.collaborate({
13 task: "Analyze market trends and generate a report"
14});
Core Featuresof the Monadic Design Pattern
State Encapsulation
Encapsulates state, ensuring data immutability and predictable transformations
Chained Operations
Chain operations seamlessly, simplifying complex workflows and data pipelines
Composable Transformations
Create reusable components that can be composed in different ways to form complex systems
Error Propagation
Control error propagation in a predictable way, enhancing system stability and reliability
Quick Start
Follow these steps to start building component-based AI applications with AStack.
Install AStack
Install AStack core and components packages using npm or yarn
1npm install @astack-tech/core @astack-tech/components
2# yarn
3yarn add @astack-tech/core @astack-tech/components
4# pnpm
5pnpm add @astack-tech/core @astack-tech/components
Create Your First Component
Extend the Component base class to create custom components
1import { Component } from '@astack-tech/core';
2
3class TextProcessor extends Component {
4 constructor() {
5 super({});
6 // Each component has default 'in' and 'out' ports
7 // We can customize them with Component.Port.I and Component.Port.O
8 Component.Port.I('text').attach(this); // Customize input port
9 }
10
11 // Standalone mode: direct processing
12 run(input: unknown): string {
13 const text = typeof input === 'string' ? input : String(input);
14 return text.toUpperCase();
15 }
16
17 // Pipeline mode: processing via port system
18 _transform($i: any, $o: any) {
19 $i('text').receive((input: unknown) => {
20 const output = this.run(input);
21 $o('out').send(output);
22 });
23 }
24}
Use Built-in Components
Leverage AStack's built-in components to quickly build functionality
1import { Pipeline } from '@astack-tech/core';
2import { TextSplitter, Embedder } from '@astack-tech/components';
3
4// Create text processing pipeline
5const pipeline = new Pipeline();
6
7// Add components to pipeline
8pipeline.addComponent('splitter', new TextSplitter({ chunkSize: 1000 }));
9pipeline.addComponent('embedder', new Embedder({ model: 'text-embedding-ada-002' }));
Run Components and Pipelines
Process data using two running modes
1// Method 1: Run component independently
2const splitter = new TextSplitter({ chunkSize: 1000 });
3const chunks = await splitter.run("This is a long text...");
4
5// Method 2: Run through pipeline
6const result = await pipeline.run('splitter.text', "This is another long text...");
7console.log(result);
Build an Agent
Create intelligent agents using the zero adaptation layer design
1import { Agent } from '@astack-tech/components';
2import { Deepseek } from '@astack-tech/integrations/model-provider';
3import { createTool } from '@astack-tech/tools';
4
5// Create a tool
6const searchTool = createTool(
7 'search',
8 'Search the internet for information',
9 async (args) => {
10 // Implement search functionality
11 const query = args.query;
12 return { results: ["Search results for: " + query] };
13 },
14 {
15 type: 'object',
16 properties: {
17 query: { type: 'string', description: 'The search query' }
18 },
19 required: ['query']
20 }
21);
22
23// Create model provider
24const deepseek = new Deepseek({
25 apiKey: process.env.DEEPSEEK_API_KEY,
26 model: 'deepseek-chat'
27});
28
29// Create agent with model and tools
30const agent = new Agent({
31 model: deepseek,
32 tools: [searchTool],
33 systemPrompt: 'You are a helpful assistant that can search for information.',
34 verbose: true,
35 maxIterations: 3
36});
37
38// Run the agent
39const result = await agent.run("Help me research recent AI advances");
Technical Independence
AStack is a 100% original framework with completely independent technical implementation and architectural design, inspired only by Haystack's API design style.
This comparison is based on Haystack v2.0 (May 2025 version). Both frameworks are continuously evolving, and specific features may change over time.
Why Emphasize This Distinction?
Clearly communicating AStack's originality and unique value is crucial. We want users to understand that AStack is not a derivative of Haystack, but a completely independent framework with its own unique technical architecture and design philosophy.
Feature | AStack | Haystack |
---|---|---|
Technical Implementation | 100% Original Code | Independent Implementation |
Design Philosophy | "Everything is a Component" | Pipeline and Node Model |
Adaptation Layer | Zero Adaptation Layer | Multi-layer Adaptation |
Execution Model | Dual Run Modes | Pipeline Mode |
Component Communication | Port System | Connector System |
Primary Focus | General AI application framework | Primarily NLP and RAG applications |
Component Interface | Unified component interface | Different interfaces based on component type |
Agent Support | Low-overhead multi-round tool execution | LangGraph-integrated agent framework |
Memory Management | Built-in memory abstractions | Memory implemented through specialized components |
Tool Integration | Standardized tool interface | Various integration patterns depending on use case |
Model Integration | Direct model provider integration | Provider-specific adapters |
Learning Curve | Minimalist API focused on simplicity | Comprehensive but more complex API |
Customization | High flexibility with minimal boilerplate | Flexible but requires more implementation code |
Programming Language | TypeScript | Python |
Chinese Support | Complete Chinese documentation | Limited Chinese documentation |
Relationship with Haystack
AStack maintains compatibility with Haystack's API style, making it easy for developers familiar with Haystack to get started, but its underlying technical implementation, architectural design, and component model are completely original work.
AStack adheres to an independently innovative technical approach, providing developers with a more concise and flexible component-based AI framework.
Real-World Use Cases
Explore how AStack is used to build sophisticated AI applications with its component-based architecture
Agent with Tools
View on GitHubCreate an agent that can use tools to perform real-world tasks like file operations. Showcases the zero-adaptation layer design principle where components work together without intermediate layers.
Explore ExampleMulti-Round Tool Execution
View on GitHubHandle multi-round tool execution, where the agent processes multiple tool calls within a single conversation, maintaining context throughout the interaction.
Explore ExampleResearch Pipeline
View on GitHubA sophisticated research pipeline that automatically searches for information, analyzes content, and generates comprehensive research reports using AI.
Explore ExampleReactive Data Flow
View on GitHubImplement dynamic systems with reactive data flows where components respond automatically to upstream changes, creating responsive AI applications.
Explore ExampleComponent Composition
View on GitHubCreate and compose reusable AI components that can be combined in different ways to build complex applications without duplicating code.
Explore ExampleWorkflow Orchestration
View on GitHubOrchestrate complex AI workflows with multiple stages, conditional branching, and parallel execution for advanced use cases.
Explore Example