Monadic component system
The Component class extends HLang’s TransformNode and uses its monadic composition laws. Agents and tools use the same component interface. Pipelines connect them.
class Agent extends ComponentThe composable framework for AI applications. Connect components with typed ports and Observable streams. Use HLang's monadic FBP model.
npm install @astack-tech/core@betainput.in Receive research promptagent.tools Connect model and tools · search → collect → writeagent.out Ready to composeCOMPONENTS, PORTS, AND PIPELINES
Connect them through ports. AStack uses HLang's monadic composition model.
The Component class extends HLang’s TransformNode and uses its monadic composition laws. Agents and tools use the same component interface. Pipelines connect them.
class Agent extends ComponentFlow-Based Programming treats LLMs as stateless generators. Define the data dependencies between components. The runtime sends data through their ports.
input → transform → outputIndependent execution with run() or reactive pipeline mode with _transform(). The same component works in both.
run(data) / _transform($i, $o)Port.I() and Port.O() define input and output ports. TypeScript describes the data contracts. The HLang runtime connects the ports.
Port.I('in') → Port.O('out')Core, components, integrations, and tools as separate packages. Choose the pieces your application needs.
@astack-tech/{core,components,…}Use OpenAI-compatible model interfaces. Connect your model provider and business logic through the component contract.
model.chatCompletion(messages)THE COMPUTATION MODEL
The computation model uses HLang's monadic composition rules. Use the same components for workflows, reactive streams, and agent communication.
Built on HLang’s TransformNode with monadic composition laws. Clear input/output contracts keep individual transformations reusable.
import { Component, type Port } from '@astack-tech/core';
class Uppercase extends Component {
constructor() { super({}); }
run(data: string): string {
return data.toUpperCase();
}
_transform($i: Port, $o: Port): void {
$i('in').receive<string>((data) => {
$o('out').send(this.run(data));
});
}
}
const result = new Uppercase().run('hello');HLang defines the monadic composition laws that AStack components use.
Port-to-port data flow without intermediate adaptation layers.
Observable-based processing with backpressure and flow-control patterns for real-time applications.
QUICK START
Install the packages. Create an agent with a model provider. Run the agent from your terminal.
Node.js 18+ · npm, pnpm, or Yarn
Read Documentation View Examplesnpm install @astack-tech/core@beta @astack-tech/components@beta @astack-tech/integrations@betaimport { Agent } from '@astack-tech/components';
import { Deepseek } from '@astack-tech/integrations/model-provider';
const apiKey = process.env.DEEPSEEK_API_KEY;
if (!apiKey) throw new Error('Set DEEPSEEK_API_KEY');
const agent = new Agent({
model: new Deepseek({ apiKey, model: 'deepseek-chat' }),
systemPrompt: 'Explain ideas clearly and precisely.',
maxIterations: 10,
});
const result = await agent.run('Explain flow-based programming');
console.log(result.message);Set DEEPSEEK_API_KEY in your shell, then run your TypeScript file. Keep API keys on the server.
npx tsx agent.tsDESIGN DECISIONS
Built in TypeScript, AStack has its own implementation and architecture. Its API style takes inspiration from Haystack's API style.
| Design choice | AStack | Traditional approach |
|---|---|---|
| Data flow paradigm | Flow-Based Programming with monadic composition | Control flow loops |
| Dual run modes | run() + _transform() | Single mode |
| Type-safe ports | TypeScript contracts and HLang port system | Runtime checks |
| Language | TypeScript | Python |
This is an architectural contrast, not a benchmark or a claim about every framework. Ecosystems evolve; choose the implementation that fits your application.
AStack uses a shared component interface for agents, tools, and models. Connect their ports to define how data moves through your application.
BUILT WITH ASTACK
Examples you can run. Components you can reuse. Compose the same primitives into different kinds of AI systems.
agent.run(task)Create agents that use tools for real-world tasks. Read files, write results, and handle multi-round tool execution.
View on GitHubsearch → analyze → reportAutomated research pipelines with web search, content analysis, and structured reports.
View on GitHubsplit → embed → retrieveRetrieval-augmented generation with vector stores. Connect splitting, embedding, retrieval, and generation components.
View on GitHubagent.out → agent.inCoordinate multiple agents for complex tasks through component composition and agent-to-agent events.
View on GitHubbranch → transform → joinComplex workflows with branching and parallel execution. Express routing through data dependencies.
View on GitHubcontext → query → recurseExplore large contexts programmatically with RLMAgent, recursive subqueries, and FileSystemContext.
View on GitHubInside AStack's recursive language model implementation.