@projectaria/cf-agents 0.1.1 → 0.1.2
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 +358 -253
- package/dist/AriaCFChatAgent.d.ts +37 -0
- package/dist/AriaCFChatAgent.d.ts.map +1 -0
- package/dist/AriaCFChatAgent.js +200 -0
- package/dist/AriaCFChatAgent.js.map +1 -0
- package/dist/CloudflareSessionStore.d.ts +37 -0
- package/dist/CloudflareSessionStore.d.ts.map +1 -0
- package/dist/CloudflareSessionStore.js +101 -0
- package/dist/CloudflareSessionStore.js.map +1 -0
- package/dist/aria-to-ui-stream.d.ts +21 -0
- package/dist/aria-to-ui-stream.d.ts.map +1 -0
- package/dist/aria-to-ui-stream.js +118 -0
- package/dist/aria-to-ui-stream.js.map +1 -0
- package/dist/index.d.ts +25 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -23
- package/dist/index.js.map +1 -1
- package/dist/message-format.d.ts +39 -0
- package/dist/message-format.d.ts.map +1 -0
- package/dist/message-format.js +124 -0
- package/dist/message-format.js.map +1 -0
- package/dist/types.d.ts +59 -146
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +8 -7
- package/dist/types.js.map +1 -1
- package/package.json +3 -2
- package/dist/AriaAgent.d.ts +0 -186
- package/dist/AriaAgent.d.ts.map +0 -1
- package/dist/AriaAgent.js +0 -756
- package/dist/AriaAgent.js.map +0 -1
- package/dist/aria-agent-integration.d.ts +0 -52
- package/dist/aria-agent-integration.d.ts.map +0 -1
- package/dist/aria-agent-integration.js +0 -186
- package/dist/aria-agent-integration.js.map +0 -1
- package/dist/message-converter.d.ts +0 -48
- package/dist/message-converter.d.ts.map +0 -1
- package/dist/message-converter.js +0 -138
- package/dist/message-converter.js.map +0 -1
package/dist/AriaAgent.d.ts
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ARIA Agent - Cloudflare Agents integration with proper memory primitives
|
|
3
|
-
*
|
|
4
|
-
* Memory Architecture:
|
|
5
|
-
* 1. Session: Current conversation thread with chronological messages
|
|
6
|
-
* 2. State: Temporary data within the current conversation (working memory)
|
|
7
|
-
* 3. Memory: Searchable, cross-session information (knowledge base)
|
|
8
|
-
*
|
|
9
|
-
* AI SDK 6.0 Message Types (matching agents@0.3.3):
|
|
10
|
-
* - UIMessage: Format with UI metadata (id, role, parts)
|
|
11
|
-
* - ModelMessage: Format expected by LLM models
|
|
12
|
-
* - convertToModelMessages: Converts UIMessage[] to ModelMessage[]
|
|
13
|
-
*/
|
|
14
|
-
import { AIChatAgent } from "agents/ai-chat-agent";
|
|
15
|
-
import { type AgentContext } from "agents";
|
|
16
|
-
import type { StreamTextOnFinishCallback, ToolSet } from "ai";
|
|
17
|
-
import type { AriaEnv, AriaMemory, AriaSession, AriaSessionState, FlowTransition, MemorySearchQuery, MemorySearchResult, WorkingMemory } from "./types";
|
|
18
|
-
/**
|
|
19
|
-
* ARIA Agent extending AIChatAgent
|
|
20
|
-
*
|
|
21
|
-
* Provides:
|
|
22
|
-
* - Session management with conversation history
|
|
23
|
-
* - State management (working memory) for session-local data
|
|
24
|
-
* - Memory layer for cross-session knowledge
|
|
25
|
-
* - Flow orchestration integration
|
|
26
|
-
* - Multi-turn conversation support
|
|
27
|
-
*/
|
|
28
|
-
export declare class AriaAgent extends AIChatAgent<AriaEnv, AriaSessionState> {
|
|
29
|
-
private config;
|
|
30
|
-
private flowDefinitions;
|
|
31
|
-
constructor(ctx: AgentContext, env: AriaEnv);
|
|
32
|
-
/**
|
|
33
|
-
* Initialize ARIA-specific database tables
|
|
34
|
-
*/
|
|
35
|
-
private initializeTables;
|
|
36
|
-
/**
|
|
37
|
-
* Initial state when no session exists
|
|
38
|
-
*/
|
|
39
|
-
initialState: AriaSessionState;
|
|
40
|
-
/**
|
|
41
|
-
* Get the current session
|
|
42
|
-
* Session = Current conversation thread with chronological messages
|
|
43
|
-
*/
|
|
44
|
-
getSession(): AriaSession;
|
|
45
|
-
/**
|
|
46
|
-
* Get session creation time from storage
|
|
47
|
-
*/
|
|
48
|
-
private getCreatedAt;
|
|
49
|
-
/**
|
|
50
|
-
* Record a session event for tracking
|
|
51
|
-
*/
|
|
52
|
-
private recordSessionEvent;
|
|
53
|
-
/**
|
|
54
|
-
* Get working memory (state within current conversation)
|
|
55
|
-
* Examples: shopping cart items, user preferences mentioned in this session
|
|
56
|
-
*/
|
|
57
|
-
getWorkingMemory(): WorkingMemory;
|
|
58
|
-
/**
|
|
59
|
-
* Set a value in working memory
|
|
60
|
-
*/
|
|
61
|
-
setWorkingMemory(key: string, value: unknown): void;
|
|
62
|
-
/**
|
|
63
|
-
* Clear all working memory
|
|
64
|
-
*/
|
|
65
|
-
clearWorkingMemory(): void;
|
|
66
|
-
/**
|
|
67
|
-
* Handle state updates (called by Cloudflare Agents framework)
|
|
68
|
-
* This is triggered whenever setState is called, either from the server or from a connected client.
|
|
69
|
-
*
|
|
70
|
-
* Use cases:
|
|
71
|
-
* - React state synchronization via useAgent hook
|
|
72
|
-
* - Logging state changes
|
|
73
|
-
* - Triggering side effects on state changes
|
|
74
|
-
*
|
|
75
|
-
* @param state - The updated state
|
|
76
|
-
* @param source - "server" if update came from the agent, or a Connection object if from a client
|
|
77
|
-
*/
|
|
78
|
-
onStateUpdate(state: AriaSessionState, source: "server" | unknown): void;
|
|
79
|
-
/**
|
|
80
|
-
* Store a memory for cross-session retrieval
|
|
81
|
-
* Memory = Searchable, cross-session information (knowledge base)
|
|
82
|
-
*/
|
|
83
|
-
storeMemory(memory: Omit<AriaMemory, "id" | "createdAt" | "lastAccessedAt" | "accessCount">): string;
|
|
84
|
-
/**
|
|
85
|
-
* Search memory by query
|
|
86
|
-
* Returns relevant memories across all sessions
|
|
87
|
-
*/
|
|
88
|
-
searchMemories(query: MemorySearchQuery): MemorySearchResult[];
|
|
89
|
-
/**
|
|
90
|
-
* Get a specific memory by key
|
|
91
|
-
*/
|
|
92
|
-
getMemory(key: string): AriaMemory | null;
|
|
93
|
-
/**
|
|
94
|
-
* Update memory access (increments access count and updates timestamp)
|
|
95
|
-
*/
|
|
96
|
-
private updateMemoryAccess;
|
|
97
|
-
/**
|
|
98
|
-
* Clean up old memories based on retention policy
|
|
99
|
-
*/
|
|
100
|
-
cleanupOldMemories(): void;
|
|
101
|
-
/**
|
|
102
|
-
* Register a flow definition
|
|
103
|
-
*/
|
|
104
|
-
registerFlow(flow: import("@projectaria/aria-agents").FlowDefinition): void;
|
|
105
|
-
/**
|
|
106
|
-
* Record a flow transition
|
|
107
|
-
*/
|
|
108
|
-
recordFlowTransition(flowId: string, fromNodeId: string | null, toNodeId: string, metadata?: Record<string, unknown>): void;
|
|
109
|
-
/**
|
|
110
|
-
* Get flow transition history
|
|
111
|
-
*/
|
|
112
|
-
getFlowHistory(flowId?: string, limit?: number): FlowTransition[];
|
|
113
|
-
/**
|
|
114
|
-
* Handle incoming chat messages
|
|
115
|
-
* This is where ARIA's flow orchestration would be integrated
|
|
116
|
-
*/
|
|
117
|
-
onChatMessage(onFinish: StreamTextOnFinishCallback<ToolSet>, options?: {
|
|
118
|
-
abortSignal?: AbortSignal;
|
|
119
|
-
clientTools?: Array<{
|
|
120
|
-
name: string;
|
|
121
|
-
description?: string;
|
|
122
|
-
parameters?: import("ai").JSONSchema7;
|
|
123
|
-
}>;
|
|
124
|
-
}): Promise<Response | undefined>;
|
|
125
|
-
/**
|
|
126
|
-
* Build system prompt with conversation context
|
|
127
|
-
*/
|
|
128
|
-
private buildSystemPrompt;
|
|
129
|
-
/**
|
|
130
|
-
* Run an ARIA agent with persistence
|
|
131
|
-
* This method allows you to use ARIA's createAgent() with persistent memory
|
|
132
|
-
*
|
|
133
|
-
* @param agent - The ARIA agent created via createAgent()
|
|
134
|
-
* @param input - The user input
|
|
135
|
-
* @returns The agent response with persisted session state
|
|
136
|
-
*/
|
|
137
|
-
runAriaAgent(agent: import("@projectaria/aria-agents").Agent, input: string): Promise<{
|
|
138
|
-
text: string;
|
|
139
|
-
session: import("@projectaria/aria-agents").AgentSession;
|
|
140
|
-
}>;
|
|
141
|
-
/**
|
|
142
|
-
* Stream an ARIA agent response with persistence
|
|
143
|
-
*
|
|
144
|
-
* @param agent - The ARIA agent created via createAgent()
|
|
145
|
-
* @param input - The user input
|
|
146
|
-
* @returns Stream result with session
|
|
147
|
-
*/
|
|
148
|
-
streamAriaAgent(agent: import("@projectaria/aria-agents").Agent, input: string): Promise<{
|
|
149
|
-
fullStream: AsyncIterable<import("@projectaria/aria-agents").AriaStreamPart>;
|
|
150
|
-
textStream: AsyncIterable<string>;
|
|
151
|
-
usage?: Promise<import("ai").LanguageModelUsage | undefined>;
|
|
152
|
-
}>;
|
|
153
|
-
/**
|
|
154
|
-
* Build ARIA agent prompt with context from session and memories
|
|
155
|
-
*/
|
|
156
|
-
private buildAriaAgentPrompt;
|
|
157
|
-
/**
|
|
158
|
-
* Extract and store memories from ARIA agent conversation
|
|
159
|
-
*/
|
|
160
|
-
private extractAndStoreMemories;
|
|
161
|
-
/**
|
|
162
|
-
* Extract preference key from message content
|
|
163
|
-
*/
|
|
164
|
-
private extractPreferenceKey;
|
|
165
|
-
/**
|
|
166
|
-
* Extract fact key from message content
|
|
167
|
-
*/
|
|
168
|
-
private extractFactKey;
|
|
169
|
-
/**
|
|
170
|
-
* Called when agent starts
|
|
171
|
-
*/
|
|
172
|
-
onStart(): Promise<void>;
|
|
173
|
-
/**
|
|
174
|
-
* Called when a client connects
|
|
175
|
-
*/
|
|
176
|
-
onConnect(connection: import("agents").Connection, ctx: import("agents").ConnectionContext): Promise<void>;
|
|
177
|
-
/**
|
|
178
|
-
* Cleanup when destroyed
|
|
179
|
-
*/
|
|
180
|
-
destroy(): Promise<void>;
|
|
181
|
-
/**
|
|
182
|
-
* Handle HTTP requests
|
|
183
|
-
*/
|
|
184
|
-
onRequest(request: Request): Promise<Response>;
|
|
185
|
-
}
|
|
186
|
-
//# sourceMappingURL=AriaAgent.d.ts.map
|
package/dist/AriaAgent.d.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