JSPM

  • Created
  • Published
  • Downloads 170
  • Score
    100M100P100Q103620F

A framework for structured conversational AI agents

Package Exports

  • @ariaflowagents/core
  • @ariaflowagents/core/agents
  • @ariaflowagents/core/flows
  • @ariaflowagents/core/guards
  • @ariaflowagents/core/hooks
  • @ariaflowagents/core/runtime
  • @ariaflowagents/core/session
  • @ariaflowagents/core/tools
  • @ariaflowagents/core/types

Readme

@ariaflowagents/core

AriaFlow core runtime and agent primitives for building structured, multi-agent conversations.

Install

npm install @ariaflowagents/core

Quick start

import { Runtime, type AgentConfig } from '@ariaflowagents/core';
import { openai } from '@ai-sdk/openai';

const supportAgent: AgentConfig = {
  id: 'support',
  name: 'Support Agent',
  systemPrompt: 'You are a helpful support agent.',
  model: openai('gpt-4o-mini') as any,
};

const runtime = new Runtime({
  agents: [supportAgent],
  defaultAgentId: 'support',
  defaultModel: openai('gpt-4o-mini') as any,
});

const run = async () => {
  for await (const part of runtime.stream({ input: 'Hello there' })) {
    if (part.type === 'text-delta') {
      process.stdout.write(part.text);
    }
  }
};

run();

AriaFlow provides additional packages for specific deployment targets:

Package Description Use When
@ariaflowagents/cf-agent Cloudflare Durable Objects for Runtime and AgentFlowManager Deploying to Cloudflare Workers
@ariaflowagents/hono-server Hono router for HTTP/WebSocket serving Running a Node.js or Bun server

Cloudflare Workers

Use @ariaflowagents/cf-agent for serverless deployment on Cloudflare:

npm install @ariaflowagents/cf-agent

Runtime (multi-agent):

import { AriaFlowChatAgent } from '@ariaflowagents/cf-agent';

export class MyChatAgent extends AriaFlowChatAgent {
  async createRuntime() {
    return {
      agents: [supportAgent],
      defaultAgentId: 'support',
    };
  }
}

Flow (structured conversation):

import { AriaFlowFlowAgent } from '@ariaflowagents/cf-agent';

export class ReservationAgent extends AriaFlowFlowAgent {
  async createFlowConfig() {
    return {
      initialNode: 'greeting',
      model: openai('gpt-4o-mini') as object,
      nodes: [...],
    };
  }
}

See @ariaflowagents/cf-agent for full documentation.

Hono Server

Use @ariaflowagents/hono-server for HTTP/WebSocket hosting:

npm install @ariaflowagents/hono-server

Runtime server:

import { Hono } from 'hono';
import { serve } from '@hono/node-server';
import { createNodeWebSocket } from '@hono/node-ws';
import { Runtime } from '@ariaflowagents/core';
import { createAriaChatRouter } from '@ariaflowagents/hono-server';

const runtime = new Runtime({ agents: [...] });
const app = new Hono();
app.route('/', createAriaChatRouter({ runtime }));

serve({ fetch: app.fetch, port: 3000 });

Flow server:

import { AgentFlowManager } from '@ariaflowagents/core';
import { createAriaFlowRouter } from '@ariaflowagents/hono-server';

const flowManager = new AgentFlowManager({ nodes: [...] });
app.route('/', createAriaFlowRouter({ flowManager, sessionId: 'my-flow' }));

See @ariaflowagents/hono-server for full documentation.

Core Concepts

Runtime (Multi-Agent)

The Runtime class orchestrates multiple agents with seamless handoffs:

  • TriageAgent: Routes requests to the appropriate specialist
  • Agent Handoffs: Transfer conversation context between agents
  • Session Persistence: Maintains conversation state

AgentFlowManager (Single Flow)

The AgentFlowManager class manages structured, node-based conversations:

  • Flow Nodes: Each node has a specific purpose and tools
  • State Transitions: Tools drive transitions via createFlowTransition()
  • Flow Hooks: Observe lifecycle events (onFlowStart, onTransition, etc.)
  • Context Strategies: Control memory management (append, reset, summarize)