@cilow/sdk 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.
Files changed (45) hide show
  1. package/README.md +412 -199
  2. package/dist/client.d.mts +224 -0
  3. package/dist/client.d.ts +224 -0
  4. package/dist/client.js +509 -0
  5. package/dist/client.js.map +1 -0
  6. package/dist/client.mjs +505 -0
  7. package/dist/client.mjs.map +1 -0
  8. package/dist/index.d.mts +94 -390
  9. package/dist/index.d.ts +94 -390
  10. package/dist/index.js +745 -350
  11. package/dist/index.js.map +1 -0
  12. package/dist/index.mjs +732 -318
  13. package/dist/index.mjs.map +1 -0
  14. package/dist/providers/langchain.js +821 -0
  15. package/dist/providers/langchain.js.map +1 -0
  16. package/dist/providers/langchain.mjs +816 -0
  17. package/dist/providers/langchain.mjs.map +1 -0
  18. package/dist/providers/openai.js +737 -0
  19. package/dist/providers/openai.js.map +1 -0
  20. package/dist/providers/openai.mjs +732 -0
  21. package/dist/providers/openai.mjs.map +1 -0
  22. package/dist/providers/vercel.js +866 -0
  23. package/dist/providers/vercel.js.map +1 -0
  24. package/dist/providers/vercel.mjs +860 -0
  25. package/dist/providers/vercel.mjs.map +1 -0
  26. package/dist/react/hooks.d.mts +327 -0
  27. package/dist/react/hooks.d.ts +327 -0
  28. package/dist/react/hooks.js +1183 -0
  29. package/dist/react/hooks.js.map +1 -0
  30. package/dist/react/hooks.mjs +1172 -0
  31. package/dist/react/hooks.mjs.map +1 -0
  32. package/dist/types.d.mts +494 -0
  33. package/dist/types.d.ts +494 -0
  34. package/dist/types.js +18 -0
  35. package/dist/types.js.map +1 -0
  36. package/dist/types.mjs +14 -0
  37. package/dist/types.mjs.map +1 -0
  38. package/dist/websocket.d.mts +160 -0
  39. package/dist/websocket.d.ts +160 -0
  40. package/dist/websocket.js +342 -0
  41. package/dist/websocket.js.map +1 -0
  42. package/dist/websocket.mjs +339 -0
  43. package/dist/websocket.mjs.map +1 -0
  44. package/package.json +90 -31
  45. package/LICENSE +0 -21
package/README.md CHANGED
@@ -1,16 +1,6 @@
1
1
  # @cilow/sdk
2
2
 
3
- TypeScript/JavaScript SDK for the Cilow AI Agent Platform - Production-ready memory system for AI agents with unlimited context.
4
-
5
- ## Features
6
-
7
- - **Semantic Memory Storage** - Store and retrieve memories using vector embeddings
8
- - **Multi-tier Storage** - Hot/Warm/Cold tiers with automatic optimization
9
- - **Tag-based Organization** - Organize memories with flexible tagging
10
- - **Full-text + Semantic Search** - Hybrid search combining BM25 and embeddings
11
- - **Knowledge Graph** - Entity extraction and relationship mapping
12
- - **Multi-tenant Support** - User isolation for secure multi-user apps
13
- - **TypeScript First** - Full type safety with comprehensive types
3
+ Complete TypeScript SDK for Cilow - AI Memory Infrastructure with multi-framework support.
14
4
 
15
5
  ## Installation
16
6
 
@@ -25,297 +15,520 @@ pnpm add @cilow/sdk
25
15
  ## Quick Start
26
16
 
27
17
  ```typescript
28
- import { CilowClient } from '@cilow/sdk';
18
+ import { Cilow } from '@cilow/sdk';
29
19
 
30
- // Initialize with API key
31
- const client = new CilowClient({
32
- apiKey: 'cilow_your_api_key',
33
- baseUrl: 'https://api.cilow.ai', // or your self-hosted URL
20
+ const cilow = new Cilow({
21
+ apiUrl: 'https://api.cilow.ai',
22
+ apiKey: 'your-api-key'
34
23
  });
35
24
 
36
- // Add a memory
37
- const { memoryId } = await client.addMemory({
38
- content: 'User prefers TypeScript over JavaScript for backend development',
39
- tags: ['preference', 'programming', 'backend'],
40
- });
25
+ // Store a memory
26
+ await cilow.remember("User prefers dark mode", { tags: ["preference", "ui"] });
41
27
 
42
- // Search memories semantically
43
- const results = await client.searchMemories({
44
- query: 'What programming languages does the user prefer?',
45
- limit: 5,
46
- });
28
+ // Search memories
29
+ const memories = await cilow.recall("user preferences");
47
30
 
48
- console.log(results);
49
- // [
50
- // {
51
- // memoryId: 'mem_xxx',
52
- // content: 'User prefers TypeScript over JavaScript...',
53
- // similarity: 0.92,
54
- // score: 0.18,
55
- // tags: ['preference', 'programming', 'backend']
56
- // }
57
- // ]
31
+ // Delete memories
32
+ await cilow.forget({ tags: ["temporary"] });
58
33
  ```
59
34
 
60
- ## Authentication
35
+ ## Features
61
36
 
62
- ### API Key Authentication (Recommended for backends)
37
+ - **Simple API**: `remember`, `recall`, `forget` for easy memory management
38
+ - **Full TypeScript Support**: Complete type definitions for all APIs
39
+ - **Framework Integrations**: Vercel AI SDK, OpenAI, LangChain
40
+ - **React Hooks**: `useMemory`, `useRecall`, `useMemoryContext`
41
+ - **WebSocket Support**: Real-time memory updates and graph changes
42
+ - **Multi-tier Memory**: Hot, warm, cold memory tiers for optimal performance
63
43
 
64
- ```typescript
65
- const client = new CilowClient({
66
- apiKey: 'cilow_your_api_key',
67
- });
68
- ```
44
+ ## Core Client
69
45
 
70
- ### JWT Authentication (For frontend apps)
46
+ ### Basic Operations
71
47
 
72
48
  ```typescript
73
- const client = new CilowClient({
74
- baseUrl: 'https://api.cilow.ai',
49
+ import { Cilow } from '@cilow/sdk';
50
+
51
+ const cilow = new Cilow({
52
+ apiUrl: 'https://api.cilow.ai',
53
+ apiKey: 'your-api-key'
75
54
  });
76
55
 
77
- // Login to get access token
78
- const auth = await client.login('user@example.com', 'password');
79
- console.log(`Logged in as: ${auth.user.email}`);
56
+ // Store a memory
57
+ const memoryId = await cilow.remember("Important information", {
58
+ tags: ["important"],
59
+ userId: "user-123",
60
+ metadata: { source: "chat" }
61
+ });
80
62
 
81
- // Token is automatically set for subsequent requests
82
- ```
63
+ // Search memories with semantic similarity
64
+ const results = await cilow.recall("important information", {
65
+ limit: 10,
66
+ minRelevance: 0.5,
67
+ tags: ["important"]
68
+ });
83
69
 
84
- ## Memory Operations
70
+ // Delete memories
71
+ await cilow.forget({ memoryId: "mem-123" });
72
+ await cilow.forget({ tags: ["old"], userId: "user-123" });
73
+ ```
85
74
 
86
- ### Add Memory
75
+ ### Advanced Operations
87
76
 
88
77
  ```typescript
89
- const { memoryId } = await client.addMemory({
90
- content: 'Meeting notes: Q4 planning discussed roadmap priorities',
91
- tags: ['meeting', 'planning', 'q4'],
92
- metadata: {
93
- source: 'meeting-notes',
94
- date: '2024-01-15',
95
- },
78
+ // Get a specific memory
79
+ const memory = await cilow.getMemory("mem-123");
80
+
81
+ // Update a memory
82
+ const updated = await cilow.updateMemory("mem-123", {
83
+ content: "Updated content",
84
+ tags: ["updated"]
96
85
  });
97
- ```
98
86
 
99
- ### Search Memories
87
+ // List memories with pagination
88
+ const list = await cilow.listMemories({
89
+ limit: 20,
90
+ offset: 0,
91
+ userId: "user-123",
92
+ tags: ["preference"]
93
+ });
100
94
 
101
- ```typescript
102
- // Semantic search
103
- const results = await client.searchMemories({
104
- query: 'What were the Q4 priorities?',
105
- limit: 10,
106
- minScore: 0.5,
95
+ // Get context for AI prompts
96
+ const context = await cilow.getContext("recent discussions", {
97
+ maxTokens: 2000,
98
+ userId: "user-123"
107
99
  });
108
100
 
109
- // Search with tag filtering
110
- const taggedResults = await client.searchMemories({
111
- query: 'planning discussions',
112
- tags: ['meeting', 'planning'],
113
- tagMode: 'all', // 'all' = AND, 'any' = OR
101
+ // Store conversation turns
102
+ await cilow.storeConversation({
103
+ userMessage: "What's the weather?",
104
+ assistantResponse: "The weather is sunny today.",
105
+ userId: "user-123",
106
+ sessionId: "session-abc"
114
107
  });
108
+
109
+ // Get statistics
110
+ const stats = await cilow.getStats();
111
+ console.log(`Total memories: ${stats.totalMemories}`);
115
112
  ```
116
113
 
117
- ### Update Memory
114
+ ### Graph Operations
118
115
 
119
116
  ```typescript
120
- await client.updateMemory(memoryId, {
121
- content: 'Updated content with new information',
122
- tags: ['updated', 'important'],
117
+ // Create graph nodes
118
+ const node = await cilow.createGraphNode("Person", "John Doe", {
119
+ email: "john@example.com"
120
+ });
121
+
122
+ // Create relationships
123
+ const edge = await cilow.createGraphEdge(
124
+ node.id,
125
+ "other-node-id",
126
+ "KNOWS",
127
+ { since: "2024" }
128
+ );
129
+
130
+ // Traverse the graph
131
+ const subgraph = await cilow.traverseGraph({
132
+ startNodeId: node.id,
133
+ maxDepth: 3,
134
+ relationshipTypes: ["KNOWS", "WORKS_WITH"]
123
135
  });
124
136
  ```
125
137
 
126
- ### Delete Memory
138
+ ## Vercel AI SDK Integration
127
139
 
128
140
  ```typescript
129
- await client.deleteMemory(memoryId);
130
- ```
141
+ import { createCilowTools, createCilowContext } from '@cilow/sdk/providers/vercel';
142
+ import { streamText } from 'ai';
143
+ import { anthropic } from '@ai-sdk/anthropic';
144
+
145
+ // Create tools for AI to use
146
+ const tools = createCilowTools({
147
+ apiUrl: 'https://api.cilow.ai',
148
+ apiKey: 'your-key',
149
+ defaultUserId: 'user-123'
150
+ });
131
151
 
132
- ### List Memories
152
+ // Use with streamText
153
+ const result = await streamText({
154
+ model: anthropic('claude-sonnet-4-20250514'),
155
+ tools,
156
+ messages: [
157
+ { role: 'user', content: 'What do you remember about me?' }
158
+ ]
159
+ });
133
160
 
134
- ```typescript
135
- // List all memories
136
- const memories = await client.listMemories();
161
+ // Or use context injection
162
+ const getContext = createCilowContext({
163
+ apiUrl: 'https://api.cilow.ai',
164
+ apiKey: 'your-key',
165
+ maxTokens: 2000
166
+ });
137
167
 
138
- // Filter by tier
139
- const hotMemories = await client.listMemories({
140
- tier: 'hot',
141
- limit: 50,
142
- offset: 0,
168
+ const context = await getContext('previous discussions');
169
+
170
+ const response = await streamText({
171
+ model: anthropic('claude-sonnet-4-20250514'),
172
+ system: `You are a helpful assistant.\n\nContext:\n${context.context}`,
173
+ prompt: 'Continue our discussion'
143
174
  });
144
175
  ```
145
176
 
146
- ### Get Statistics
177
+ ### Context Middleware
147
178
 
148
179
  ```typescript
149
- const stats = await client.getMemoryStats();
150
- console.log(stats);
151
- // {
152
- // totalMemories: 1500,
153
- // hotTier: 200,
154
- // warmTier: 800,
155
- // coldTier: 500,
156
- // totalTokens: 45000,
157
- // avgSalience: 0.65
158
- // }
180
+ import { createContextMiddleware } from '@cilow/sdk/providers/vercel';
181
+
182
+ const withMemory = createContextMiddleware({
183
+ apiUrl: 'https://api.cilow.ai',
184
+ apiKey: 'your-key'
185
+ });
186
+
187
+ // Automatically inject memory context
188
+ const messagesWithContext = await withMemory(originalMessages, {
189
+ userId: 'user-123',
190
+ maxTokens: 2000
191
+ });
159
192
  ```
160
193
 
161
- ## Tag Management
194
+ ## OpenAI SDK Integration
162
195
 
163
196
  ```typescript
164
- // Add tags to a memory
165
- await client.addTags(memoryId, ['important', 'follow-up']);
197
+ import OpenAI from 'openai';
198
+ import { createCilowOpenAI } from '@cilow/sdk/providers/openai';
166
199
 
167
- // Remove tags
168
- await client.removeTags(memoryId, ['follow-up']);
200
+ const openai = new OpenAI();
169
201
 
170
- // Replace all tags
171
- await client.setTags(memoryId, ['new-tag-set']);
202
+ const cilowAI = createCilowOpenAI(openai, {
203
+ apiUrl: 'https://api.cilow.ai',
204
+ apiKey: 'cilow-key',
205
+ autoStore: true // Automatically store conversations
206
+ });
172
207
 
173
- // Filter memories by tags
174
- const tagged = await client.filterByTags(['important'], 'any');
208
+ // Memory context is automatically injected
209
+ const { completion, memoriesUsed } = await cilowAI.chat.completions.create({
210
+ model: 'gpt-4',
211
+ messages: [
212
+ { role: 'user', content: 'Based on our previous discussions, what should I focus on?' }
213
+ ]
214
+ });
175
215
 
176
- // List all tags with counts
177
- const allTags = await client.listAllTags();
216
+ console.log(`Used ${memoriesUsed} memories for context`);
217
+ console.log(completion.choices[0].message.content);
178
218
 
179
- // Get tag statistics
180
- const tagStats = await client.getTagStats();
219
+ // Direct memory access
220
+ await cilowAI.remember("Important insight", { tags: ["insight"] });
221
+ const memories = await cilowAI.recall("insights");
181
222
  ```
182
223
 
183
- ## Agent Operations
224
+ ## LangChain Integration
225
+
226
+ ### Memory Class
184
227
 
185
228
  ```typescript
186
- // Create an agent
187
- const agentId = await client.createAgent({
188
- name: 'research-assistant',
189
- model: 'gpt-4',
190
- systemPrompt: 'You are a helpful research assistant.',
229
+ import { CilowMemory } from '@cilow/sdk/providers/langchain';
230
+ import { ConversationChain } from 'langchain/chains';
231
+ import { ChatOpenAI } from '@langchain/openai';
232
+
233
+ const memory = new CilowMemory({
234
+ apiUrl: 'https://api.cilow.ai',
235
+ apiKey: 'cilow-key',
236
+ userId: 'user-123',
237
+ sessionId: 'session-abc'
191
238
  });
192
239
 
193
- // Execute a task
194
- const result = await client.executeTask(agentId, {
195
- task: 'Summarize the key points from recent meetings',
196
- context: 'User is preparing for Q1 planning',
240
+ const chain = new ConversationChain({
241
+ llm: new ChatOpenAI(),
242
+ memory
197
243
  });
198
244
 
199
- // Get agent status
200
- const agent = await client.getAgent(agentId);
201
-
202
- // List all agents
203
- const agents = await client.listAgents();
204
-
205
- // Delete agent
206
- await client.deleteAgent(agentId);
245
+ const response = await chain.call({
246
+ input: 'What did we discuss last time?'
247
+ });
207
248
  ```
208
249
 
209
- ## API Key Management
250
+ ### Retriever for RAG
210
251
 
211
252
  ```typescript
212
- // Create a new API key
213
- const apiKey = await client.createApiKey({
214
- name: 'Production API Key',
215
- expiresAt: new Date('2025-01-01'),
216
- });
253
+ import { CilowRetriever } from '@cilow/sdk/providers/langchain';
254
+ import { RetrievalQAChain } from 'langchain/chains';
217
255
 
218
- // List API keys
219
- const keys = await client.listApiKeys();
256
+ const retriever = new CilowRetriever({
257
+ apiUrl: 'https://api.cilow.ai',
258
+ apiKey: 'cilow-key',
259
+ topK: 5
260
+ });
220
261
 
221
- // Revoke an API key
222
- await client.revokeApiKey(keyId);
262
+ const chain = RetrievalQAChain.fromLLM(
263
+ new ChatOpenAI(),
264
+ retriever
265
+ );
223
266
 
224
- // Delete an API key
225
- await client.deleteApiKey(keyId);
267
+ const answer = await chain.call({
268
+ query: 'What are the key points from our meetings?'
269
+ });
226
270
  ```
227
271
 
228
- ## Session Management
272
+ ### Vector Store
229
273
 
230
274
  ```typescript
231
- // List active sessions
232
- const sessions = await client.listSessions();
275
+ import { CilowVectorStore } from '@cilow/sdk/providers/langchain';
233
276
 
234
- // Revoke a specific session
235
- await client.revokeSession(sessionId);
277
+ const vectorStore = new CilowVectorStore({
278
+ apiUrl: 'https://api.cilow.ai',
279
+ apiKey: 'cilow-key'
280
+ });
281
+
282
+ // Add documents
283
+ await vectorStore.addDocuments([
284
+ { pageContent: 'Meeting notes from Monday', metadata: { topic: 'standup' } },
285
+ { pageContent: 'Product requirements document', metadata: { topic: 'product' } }
286
+ ]);
236
287
 
237
- // Revoke all other sessions
238
- await client.revokeOtherSessions();
288
+ // Similarity search
289
+ const results = await vectorStore.similaritySearch('standup notes', 5);
239
290
 
240
- // Revoke all sessions (logout everywhere)
241
- await client.revokeAllSessions();
291
+ // With scores
292
+ const resultsWithScores = await vectorStore.similaritySearchWithScore('standup notes');
242
293
  ```
243
294
 
244
- ## Error Handling
295
+ ## React Hooks
245
296
 
246
- ```typescript
297
+ ```tsx
247
298
  import {
248
- CilowError,
249
- AuthenticationError,
250
- NotFoundError,
251
- RateLimitError
252
- } from '@cilow/sdk';
299
+ CilowProvider,
300
+ useMemory,
301
+ useRecall,
302
+ useMemoryContext,
303
+ useMemorySubscription,
304
+ useDebouncedSearch
305
+ } from '@cilow/sdk/react';
306
+
307
+ // Wrap your app with the provider
308
+ function App() {
309
+ return (
310
+ <CilowProvider
311
+ apiUrl="https://api.cilow.ai"
312
+ apiKey="your-key"
313
+ userId="user-123"
314
+ enableWebSocket={true}
315
+ >
316
+ <YourApp />
317
+ </CilowProvider>
318
+ );
319
+ }
253
320
 
254
- try {
255
- await client.searchMemories({ query: 'test' });
256
- } catch (error) {
257
- if (error instanceof AuthenticationError) {
258
- console.error('Invalid API key');
259
- } else if (error instanceof NotFoundError) {
260
- console.error('Resource not found');
261
- } else if (error instanceof RateLimitError) {
262
- console.error('Rate limited, retry later');
263
- } else if (error instanceof CilowError) {
264
- console.error(`API error: ${error.message}`);
265
- }
321
+ // Use memory operations
322
+ function MemoryManager() {
323
+ const { remember, forget, isLoading, error } = useMemory();
324
+
325
+ const handleSave = async () => {
326
+ await remember("Important note", { tags: ["note"] });
327
+ };
328
+
329
+ return (
330
+ <button onClick={handleSave} disabled={isLoading}>
331
+ Save Memory
332
+ </button>
333
+ );
334
+ }
335
+
336
+ // Search memories
337
+ function SearchComponent() {
338
+ const { data, search, isLoading } = useRecall();
339
+
340
+ const handleSearch = () => {
341
+ search("user preferences", { limit: 10 });
342
+ };
343
+
344
+ return (
345
+ <div>
346
+ <button onClick={handleSearch}>Search</button>
347
+ {data.map(result => (
348
+ <div key={result.memory.id}>
349
+ <p>{result.memory.content}</p>
350
+ <span>Score: {(result.score * 100).toFixed(0)}%</span>
351
+ </div>
352
+ ))}
353
+ </div>
354
+ );
355
+ }
356
+
357
+ // Debounced search
358
+ function LiveSearch() {
359
+ const { query, setQuery, results, isLoading } = useDebouncedSearch({
360
+ delay: 300,
361
+ minLength: 2
362
+ });
363
+
364
+ return (
365
+ <div>
366
+ <input
367
+ value={query}
368
+ onChange={e => setQuery(e.target.value)}
369
+ placeholder="Search memories..."
370
+ />
371
+ {isLoading && <p>Searching...</p>}
372
+ {results.map(r => (
373
+ <div key={r.memory.id}>{r.memory.content}</div>
374
+ ))}
375
+ </div>
376
+ );
377
+ }
378
+
379
+ // Get context for AI
380
+ function ChatWithContext() {
381
+ const { getContext, isLoading } = useMemoryContext();
382
+
383
+ const sendMessage = async (message: string) => {
384
+ const { context, memoriesUsed } = await getContext(message);
385
+
386
+ // Use context with your AI provider
387
+ const response = await callAI({
388
+ system: `Context:\n${context}`,
389
+ message
390
+ });
391
+ };
392
+
393
+ return <ChatUI onSend={sendMessage} />;
394
+ }
395
+
396
+ // Real-time updates
397
+ function LiveMemoryFeed() {
398
+ const { latestEvent, events, isConnected } = useMemorySubscription({
399
+ userId: 'user-123',
400
+ eventTypes: ['memory.created', 'memory.updated']
401
+ });
402
+
403
+ useEffect(() => {
404
+ if (latestEvent?.type === 'memory.created') {
405
+ console.log('New memory:', latestEvent.memory);
406
+ }
407
+ }, [latestEvent]);
408
+
409
+ return (
410
+ <div>
411
+ <p>Status: {isConnected ? 'Connected' : 'Disconnected'}</p>
412
+ <p>Events: {events.length}</p>
413
+ </div>
414
+ );
266
415
  }
267
416
  ```
268
417
 
269
- ## Configuration Options
418
+ ## WebSocket Support
270
419
 
271
420
  ```typescript
272
- const client = new CilowClient({
273
- // API base URL (default: http://localhost:8080)
274
- baseUrl: 'https://api.cilow.ai',
421
+ import { CilowWebSocket } from '@cilow/sdk/websocket';
422
+
423
+ const ws = new CilowWebSocket({
424
+ apiUrl: 'https://api.cilow.ai',
425
+ apiKey: 'your-key',
426
+ reconnectAttempts: 5,
427
+ heartbeatInterval: 30000
428
+ });
275
429
 
276
- // API key for authentication
277
- apiKey: 'cilow_your_api_key',
430
+ // Connect
431
+ await ws.connect();
278
432
 
279
- // JWT access token (alternative to API key)
280
- accessToken: 'eyJhbGc...',
433
+ // Subscribe to events
434
+ ws.subscribe({ userId: 'user-123' });
281
435
 
282
- // Request timeout in milliseconds (default: 30000)
283
- timeout: 60000,
436
+ // Listen for memory events
437
+ ws.onMemoryCreated((event) => {
438
+ console.log('New memory:', event.memory);
284
439
  });
440
+
441
+ ws.onMemoryUpdated((event) => {
442
+ console.log('Updated memory:', event.memory);
443
+ });
444
+
445
+ ws.onMemoryDeleted((event) => {
446
+ console.log('Deleted memory ID:', event.memoryId);
447
+ });
448
+
449
+ // Listen for graph events
450
+ ws.onGraphNodeCreated((event) => {
451
+ console.log('New node:', event.node);
452
+ });
453
+
454
+ // Connection status
455
+ ws.onConnectionStatus((event) => {
456
+ console.log('Connection:', event.status, event.reason);
457
+ });
458
+
459
+ // Wait for specific event
460
+ const event = await ws.once('memory.created', 5000);
461
+
462
+ // Disconnect
463
+ ws.disconnect();
285
464
  ```
286
465
 
287
- ## Types
466
+ ## TypeScript Types
288
467
 
289
- All types are fully exported for TypeScript users:
468
+ The SDK exports comprehensive TypeScript types:
290
469
 
291
470
  ```typescript
292
471
  import type {
472
+ // Core types
293
473
  Memory,
294
- MemoryStats,
474
+ MemorySummary,
475
+ MemoryTier,
295
476
  SearchResult,
296
- Agent,
297
- User,
298
- ApiKey,
299
- AddMemoryOptions,
300
- SearchMemoriesOptions,
477
+
478
+ // Graph types
479
+ GraphNode,
480
+ GraphEdge,
481
+ GraphSubgraph,
482
+
483
+ // Event types
484
+ CilowEvent,
485
+ MemoryCreatedEvent,
486
+ MemoryUpdatedEvent,
487
+
488
+ // Configuration
489
+ CilowConfig,
490
+ WebSocketConfig,
491
+
492
+ // API types
493
+ PaginatedResponse,
494
+ ContextResult,
301
495
  } from '@cilow/sdk';
302
496
  ```
303
497
 
304
- ## Self-Hosting
305
-
306
- Cilow can be self-hosted. Point the SDK to your instance:
498
+ ## Error Handling
307
499
 
308
500
  ```typescript
309
- const client = new CilowClient({
310
- baseUrl: 'http://localhost:8080',
311
- apiKey: 'your-local-api-key',
312
- });
501
+ import { CilowApiError, isApiError } from '@cilow/sdk';
502
+
503
+ try {
504
+ await cilow.getMemory('invalid-id');
505
+ } catch (error) {
506
+ if (error instanceof CilowApiError) {
507
+ console.log('API Error:', error.message);
508
+ console.log('Code:', error.code);
509
+ console.log('Status:', error.statusCode);
510
+ console.log('Details:', error.details);
511
+ }
512
+ }
313
513
  ```
314
514
 
315
- ## Requirements
515
+ ## Configuration Options
316
516
 
317
- - Node.js >= 18.0.0
318
- - ES2020+ or modern browser with fetch support
517
+ ```typescript
518
+ const cilow = new Cilow({
519
+ // Required
520
+ apiUrl: 'https://api.cilow.ai',
521
+ apiKey: 'your-api-key',
522
+
523
+ // Optional
524
+ timeout: 30000, // Request timeout (ms)
525
+ retries: 3, // Retry attempts
526
+ debug: false, // Enable debug logging
527
+ headers: { // Custom headers
528
+ 'X-Custom-Header': 'value'
529
+ }
530
+ });
531
+ ```
319
532
 
320
533
  ## License
321
534