@projectaria/cf-agents 0.1.0

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.
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Core types for ARIA Cloudflare Agents integration
3
+ *
4
+ * Memory Primitives:
5
+ * - Session: Current conversation thread with chronological messages
6
+ * - State: Temporary data within the current conversation
7
+ * - Memory: Searchable, cross-session information
8
+ */
9
+ import type { WorkingMemory } from "@projectaria/aria-agents";
10
+ export type { UIMessage } from "ai";
11
+ /**
12
+ * Session represents a single, ongoing interaction between a user and the agent.
13
+ * Contains the chronological sequence of messages and actions during that specific interaction.
14
+ */
15
+ export interface AriaSession {
16
+ /** Unique session identifier (agent name) */
17
+ id: string;
18
+ /** Chronological message history */
19
+ messages: AriaMessage[];
20
+ /** Current active flow */
21
+ activeFlow?: AriaFlowState;
22
+ /** Message history limit (default: 50) */
23
+ historyLimit: number;
24
+ /** Session timestamp */
25
+ createdAt: number;
26
+ updatedAt: number;
27
+ }
28
+ /**
29
+ * State (session.state): Data within the current conversation
30
+ * Used to manage information relevant only to the current active conversation.
31
+ * Examples: shopping cart items, user preferences mentioned in this session.
32
+ */
33
+ export interface AriaSessionState {
34
+ /** Working memory - temporary data for current conversation */
35
+ workingMemory: WorkingMemory;
36
+ /** Current flow being executed */
37
+ activeFlowId?: string;
38
+ /** Current node within the flow */
39
+ activeNodeId?: string;
40
+ /** Message history limit */
41
+ historyLimit: number;
42
+ /** Session metadata */
43
+ metadata?: Record<string, unknown>;
44
+ }
45
+ /**
46
+ * Flow state tracking
47
+ */
48
+ export interface AriaFlowState {
49
+ flowId: string;
50
+ currentNodeId: string;
51
+ enteredAt: number;
52
+ }
53
+ /**
54
+ * Message format compatible with both ARIA and AI SDK
55
+ */
56
+ export interface AriaMessage {
57
+ role: "system" | "user" | "assistant" | "tool";
58
+ content: string;
59
+ timestamp: number;
60
+ /** Optional tool call information */
61
+ toolCall?: {
62
+ toolName: string;
63
+ toolCallId: string;
64
+ input?: Record<string, unknown>;
65
+ output?: unknown;
66
+ };
67
+ /** Optional metadata */
68
+ metadata?: Record<string, unknown>;
69
+ }
70
+ /**
71
+ * Flow transition record for tracking execution history
72
+ */
73
+ export interface FlowTransition {
74
+ id: string;
75
+ flowId: string;
76
+ fromNodeId: string | null;
77
+ toNodeId: string;
78
+ transitionedAt: number;
79
+ metadata?: Record<string, unknown>;
80
+ }
81
+ /**
82
+ * Memory represents searchable, cross-session information.
83
+ * Acts as a knowledge base the agent can search beyond the immediate conversation.
84
+ */
85
+ export interface AriaMemory {
86
+ /** Unique memory identifier */
87
+ id: string;
88
+ /** Session this memory belongs to (null if cross-session) */
89
+ sessionId: string | null;
90
+ /** Memory content/key for retrieval */
91
+ key: string;
92
+ /** Memory value */
93
+ value: unknown;
94
+ /** Memory type for categorization */
95
+ type: "preference" | "fact" | "context" | "entity" | "custom";
96
+ /** Timestamp when memory was created */
97
+ createdAt: number;
98
+ /** Timestamp when memory was last accessed */
99
+ lastAccessedAt: number;
100
+ /** Access frequency for relevance scoring */
101
+ accessCount: number;
102
+ /** Optional embedding vector for semantic search */
103
+ embedding?: number[];
104
+ /** Additional metadata */
105
+ metadata?: Record<string, unknown>;
106
+ }
107
+ /**
108
+ * Memory search query
109
+ */
110
+ export interface MemorySearchQuery {
111
+ /** Search query text */
112
+ query?: string;
113
+ /** Memory types to search */
114
+ types?: Array<"preference" | "fact" | "context" | "entity" | "custom">;
115
+ /** Session filter (null = all sessions) */
116
+ sessionId?: string | null;
117
+ /** Maximum results */
118
+ limit?: number;
119
+ /** Minimum relevance score (0-1) */
120
+ minScore?: number;
121
+ }
122
+ /**
123
+ * Memory search result
124
+ */
125
+ export interface MemorySearchResult {
126
+ memory: AriaMemory;
127
+ score: number;
128
+ relevance: string;
129
+ }
130
+ /**
131
+ * Configuration for ARIA Agent
132
+ */
133
+ export interface AriaAgentConfig {
134
+ /** Maximum messages in session history */
135
+ historyLimit?: number;
136
+ /** Whether to enable cross-session memory */
137
+ enableMemory?: boolean;
138
+ /** Memory retention period (milliseconds) */
139
+ memoryRetentionMs?: number;
140
+ /** Whether to track flow transitions */
141
+ trackTransitions?: boolean;
142
+ /** Custom session ID generator */
143
+ generateSessionId?: () => string;
144
+ }
145
+ /**
146
+ * Agent environment bindings
147
+ */
148
+ export type AriaEnv = Cloudflare.Env & {
149
+ /** AI model API key */
150
+ OPENAI_API_KEY?: string;
151
+ /** Optional: Anthropic API key */
152
+ ANTHROPIC_API_KEY?: string;
153
+ };
154
+ /**
155
+ * Re-export WorkingMemory from ARIA agents
156
+ */
157
+ export type { WorkingMemory } from "@projectaria/aria-agents";
158
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAA+B,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAG3F,YAAY,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAEpC;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,6CAA6C;IAC7C,EAAE,EAAE,MAAM,CAAC;IAEX,oCAAoC;IACpC,QAAQ,EAAE,WAAW,EAAE,CAAC;IAExB,0BAA0B;IAC1B,UAAU,CAAC,EAAE,aAAa,CAAC;IAE3B,0CAA0C;IAC1C,YAAY,EAAE,MAAM,CAAC;IAErB,wBAAwB;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+DAA+D;IAC/D,aAAa,EAAE,aAAa,CAAC;IAE7B,kCAAkC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,mCAAmC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,4BAA4B;IAC5B,YAAY,EAAE,MAAM,CAAC;IAErB,uBAAuB;IACvB,QAAQ,CAAC,EAAE,MA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AM,CAAC;IAExB,kCAAkC;IAClC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF;;GAEG;AACH,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Core types for ARIA Cloudflare Agents integration
3
+ *
4
+ * Memory Primitives:
5
+ * - Session: Current conversation thread with chronological messages
6
+ * - State: Temporary data within the current conversation
7
+ * - Memory: Searchable, cross-session information
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@projectaria/cf-agents",
3
+ "version": "0.1.0",
4
+ "description": "ARIA Cloudflare Agents integration with proper memory primitives for meaningful multi-turn conversations",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "dev": "tsc --watch",
20
+ "test": "bun test",
21
+ "typecheck": "tsc --noEmit",
22
+ "prepublishOnly": "bun run build"
23
+ },
24
+ "peerDependencies": {
25
+ "agents": "^0.3.3",
26
+ "@cloudflare/ai-chat": ">=0.0.3",
27
+ "ai": "^6.0.0"
28
+ },
29
+ "dependencies": {
30
+ "ai": "^6.0.0",
31
+ "nanoid": "^3.3.7"
32
+ },
33
+ "devDependencies": {
34
+ "@cloudflare/ai-chat": "^0.0.3",
35
+ "@cloudflare/workers-types": "^4.20260103.0",
36
+ "@projectaria/aria-agents": "workspace:*",
37
+ "@types/nanoid": "^3.0.0",
38
+ "agents": "^0.3.3",
39
+ "typescript": "^5.7.2"
40
+ },
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "https://github.com/projectaria/aria"
44
+ },
45
+ "license": "MIT",
46
+ "keywords": [
47
+ "aria",
48
+ "cloudflare",
49
+ "agents",
50
+ "ai",
51
+ "conversational",
52
+ "memory",
53
+ "sessions",
54
+ "durable-objects",
55
+ "workers"
56
+ ]
57
+ }