@ariaflowagents/core 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +101 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,3 +37,104 @@ const run = async () => {
|
|
|
37
37
|
|
|
38
38
|
run();
|
|
39
39
|
```
|
|
40
|
+
|
|
41
|
+
## Related Packages
|
|
42
|
+
|
|
43
|
+
AriaFlow provides additional packages for specific deployment targets:
|
|
44
|
+
|
|
45
|
+
| Package | Description | Use When |
|
|
46
|
+
|---------|-------------|----------|
|
|
47
|
+
| [`@ariaflowagents/cf-agent`](https://www.npmjs.com/package/@ariaflowagents/cf-agent) | Cloudflare Durable Objects for Runtime and AgentFlowManager | Deploying to Cloudflare Workers |
|
|
48
|
+
| [`@ariaflowagents/hono-server`](https://www.npmjs.com/package/@ariaflowagents/hono-server) | Hono router for HTTP/WebSocket serving | Running a Node.js or Bun server |
|
|
49
|
+
|
|
50
|
+
### Cloudflare Workers
|
|
51
|
+
|
|
52
|
+
Use `@ariaflowagents/cf-agent` for serverless deployment on Cloudflare:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm install @ariaflowagents/cf-agent
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Runtime (multi-agent):**
|
|
59
|
+
```typescript
|
|
60
|
+
import { AriaFlowChatAgent } from '@ariaflowagents/cf-agent';
|
|
61
|
+
|
|
62
|
+
export class MyChatAgent extends AriaFlowChatAgent {
|
|
63
|
+
async createRuntime() {
|
|
64
|
+
return {
|
|
65
|
+
agents: [supportAgent],
|
|
66
|
+
defaultAgentId: 'support',
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Flow (structured conversation):**
|
|
73
|
+
```typescript
|
|
74
|
+
import { AriaFlowFlowAgent } from '@ariaflowagents/cf-agent';
|
|
75
|
+
|
|
76
|
+
export class ReservationAgent extends AriaFlowFlowAgent {
|
|
77
|
+
async createFlowConfig() {
|
|
78
|
+
return {
|
|
79
|
+
initialNode: 'greeting',
|
|
80
|
+
model: openai('gpt-4o-mini') as object,
|
|
81
|
+
nodes: [...],
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
See [`@ariaflowagents/cf-agent`](https://www.npmjs.com/package/@ariaflowagents/cf-agent) for full documentation.
|
|
88
|
+
|
|
89
|
+
### Hono Server
|
|
90
|
+
|
|
91
|
+
Use `@ariaflowagents/hono-server` for HTTP/WebSocket hosting:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
npm install @ariaflowagents/hono-server
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Runtime server:**
|
|
98
|
+
```typescript
|
|
99
|
+
import { Hono } from 'hono';
|
|
100
|
+
import { serve } from '@hono/node-server';
|
|
101
|
+
import { createNodeWebSocket } from '@hono/node-ws';
|
|
102
|
+
import { Runtime } from '@ariaflowagents/core';
|
|
103
|
+
import { createAriaChatRouter } from '@ariaflowagents/hono-server';
|
|
104
|
+
|
|
105
|
+
const runtime = new Runtime({ agents: [...] });
|
|
106
|
+
const app = new Hono();
|
|
107
|
+
app.route('/', createAriaChatRouter({ runtime }));
|
|
108
|
+
|
|
109
|
+
serve({ fetch: app.fetch, port: 3000 });
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Flow server:**
|
|
113
|
+
```typescript
|
|
114
|
+
import { AgentFlowManager } from '@ariaflowagents/core';
|
|
115
|
+
import { createAriaFlowRouter } from '@ariaflowagents/hono-server';
|
|
116
|
+
|
|
117
|
+
const flowManager = new AgentFlowManager({ nodes: [...] });
|
|
118
|
+
app.route('/', createAriaFlowRouter({ flowManager, sessionId: 'my-flow' }));
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
See [`@ariaflowagents/hono-server`](https://www.npmjs.com/package/@ariaflowagents/hono-server) for full documentation.
|
|
122
|
+
|
|
123
|
+
## Core Concepts
|
|
124
|
+
|
|
125
|
+
### Runtime (Multi-Agent)
|
|
126
|
+
|
|
127
|
+
The `Runtime` class orchestrates multiple agents with seamless handoffs:
|
|
128
|
+
|
|
129
|
+
- **TriageAgent**: Routes requests to the appropriate specialist
|
|
130
|
+
- **Agent Handoffs**: Transfer conversation context between agents
|
|
131
|
+
- **Session Persistence**: Maintains conversation state
|
|
132
|
+
|
|
133
|
+
### AgentFlowManager (Single Flow)
|
|
134
|
+
|
|
135
|
+
The `AgentFlowManager` class manages structured, node-based conversations:
|
|
136
|
+
|
|
137
|
+
- **Flow Nodes**: Each node has a specific purpose and tools
|
|
138
|
+
- **State Transitions**: Tools drive transitions via `createFlowTransition()`
|
|
139
|
+
- **Flow Hooks**: Observe lifecycle events (onFlowStart, onTransition, etc.)
|
|
140
|
+
- **Context Strategies**: Control memory management (append, reset, summarize)
|