npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ariaflowagents/cf-agent

v0.5.0

Published

Cloudflare Agents base class for hosting AriaFlow Runtime on Durable Objects

Downloads

1,786

Readme

@ariaflowagents/cf-agent

Cloudflare Durable Object base classes for hosting AriaFlow on the edge.

Two Primitive Classes

This package provides two separate base classes for different use cases:

| Class | Use When | Config Returns | |-------|----------|----------------| | AriaFlowChatAgent | Multi-agent systems with handoffs | HarnessConfig or Runtime | | AriaFlowFlowAgent | Structured single-flow conversations | AriaFlowFlowConfig or AgentFlowManager |


AriaFlowChatAgent - Multi-Agent Runtime

Use for multi-agent systems where agents can hand off to each other.

import { AriaFlowChatAgent } from '@ariaflowagents/cf-agent';
import { Runtime, type AgentConfig } from '@ariaflowagents/core';

export class SupportAgent extends AriaFlowChatAgent {
  async createRuntimeConfig() {
    const triage: AgentConfig = {
      id: 'triage',
      name: 'Triage',
      type: 'triage',
      systemPrompt: 'Route customers to specialists.',
      routes: [
        { agentId: 'orders', description: 'Order questions' },
        { agentId: 'billing', description: 'Billing questions' },
      ],
    };

    const orders: AgentConfig = {
      id: 'orders',
      name: 'Orders',
      type: 'llm',
      systemPrompt: 'Help with order questions.',
    };

    return {
      agents: [triage, orders],
      defaultAgentId: 'triage',
    };
  }
}

State (Runtime mode):

state = {
  activeAgentId: 'orders',      // Current agent
  lastHandoffReason: 'Order inquiry',
  updatedAt: 1234567890,
}

AriaFlowFlowAgent - Structured Flow

Use for structured, multi-step flows with guided conversations.

import { AriaFlowFlowAgent } from '@ariaflowagents/cf-agent';
import { AriaFlowFlowConfig } from '@ariaflowagents/cf-agent';
import { tool } from 'ai';
import { z } from 'zod';
import { createFlowTransition } from '@ariaflowagents/core';

export class ReservationAgent extends AriaFlowFlowAgent {
  async createFlowConfig(): Promise<AriaFlowFlowConfig> {
    return {
      initialNode: 'greeting',
      model: this.env.AI as any,
      defaultRolePrompt: 'You are a reservation assistant.',
      nodes: [
        {
          name: 'greeting',
          taskPrompt: 'Greet warmly and ask for party size.',
          tools: {
            collect_party_size: tool({
              description: 'Record party size',
              inputSchema: z.object({ 
                partySize: z.number().min(1).max(20) 
              }),
              execute: async ({ partySize }) => 
                createFlowTransition('collect_date', { partySize }),
            }),
          },
        },
        {
          name: 'collect_date',
          taskPrompt: 'Ask for reservation date.',
        },
      ],
    };
  }
}

State (Flow mode):

state = {
  currentNode: 'collect_date',   // Current node
  nodeHistory: ['greeting', 'collect_party_size', 'collect_date'],
  updatedAt: 1234567890,
}

Context Strategies

Control conversation history behavior:

{
  name: 'confirmation',
  taskPrompt: 'Confirm details.',
  contextStrategy: { 
    strategy: 'reset_with_summary'  // Summarize instead of full history
  },
}

| Strategy | Behavior | |----------|----------| | append | Keep all messages (default) | | reset | Clear messages on node entry | | reset_with_summary | Summarize and replace messages |


Endpoints (Both Classes)

| Endpoint | Returns | |----------|---------| | GET /info | Agent metadata, mode, readiness | | GET /state | Full agent state | | WS / | WebSocket for streaming |

AriaFlowFlowAgent additional: | GET /flow-state | Flow-specific state (currentNode, nodeHistory, collectedData) |


Quick Reference

| Question | Answer | |----------|--------| | Need multiple agents with handoffs? | Use AriaFlowChatAgent | | Need structured step-by-step flow? | Use AriaFlowFlowAgent | | State persists? | Yes, via Durable Object storage | | WebSocket streaming? | Yes, automatic | | Can switch modes? | No - choose the right class for your use case |


Example: Cloudflare Worker

// Runtime Mode (Multi-Agent)
import { AriaFlowChatAgent } from '@ariaflowagents/cf-agent';

export class MyAgent extends AriaFlowChatAgent {
  async createRuntimeConfig() {
    return {
      agents: [{ id: 'assistant', name: 'Assistant', systemPrompt: 'Helpful.' }],
      defaultAgentId: 'assistant',
    };
  }
}

// OR Flow Mode (Single Flow)
import { AriaFlowFlowAgent } from '@ariaflowagents/cf-agent';

export class MyFlowAgent extends AriaFlowFlowAgent {
  async createFlowConfig() {
    return {
      initialNode: 'greeting',
      model: this.env.AI as any,
      nodes: [{ name: 'greeting', taskPrompt: 'Hi!' }],
    };
  }
}

export default {
  async fetch(request: Request, env: Env): Promise<Response> {
    return MyAgent.fetch(request, env);  // or MyFlowAgent
  },
};