@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/dist/index.d.mts CHANGED
@@ -1,407 +1,111 @@
1
- /**
2
- * Cilow SDK Type Definitions
3
- */
4
- declare enum MemoryTier {
5
- HOT = "hot",
6
- WARM = "warm",
7
- COLD = "cold"
8
- }
9
- declare enum FactType {
10
- PERSONAL = "Personal",
11
- PREFERENCE = "Preference",
12
- SKILL = "Skill",
13
- GOAL = "Goal",
14
- RELATIONSHIP = "Relationship",
15
- CONTEXTUAL = "Contextual",
16
- TEMPORAL = "Temporal",
17
- CAUSAL = "Causal"
18
- }
19
- declare enum EntityType {
20
- PERSON = "Person",
21
- PLACE = "Place",
22
- ORGANIZATION = "Organization",
23
- OBJECT = "Object",
24
- CONCEPT = "Concept",
25
- EVENT = "Event",
26
- TIME = "Time",
27
- SKILL = "Skill",
28
- PREFERENCE = "Preference"
29
- }
30
- interface Entity {
31
- name: string;
32
- entityType: EntityType;
33
- confidence: number;
34
- attributes?: Record<string, string>;
35
- }
36
- interface Relationship {
37
- source: string;
38
- relationshipType: string;
39
- target: string;
40
- confidence: number;
41
- context?: string;
42
- }
43
- interface ExtractedFact {
44
- id: string;
45
- statement: string;
46
- confidence: number;
47
- factType: FactType;
48
- entities: Entity[];
49
- relationships: Relationship[];
50
- extractedAt?: string;
51
- }
52
- interface Memory {
53
- id: string;
54
- content: string;
55
- compressedContent?: string;
56
- createdAt?: string;
57
- updatedAt?: string;
58
- tier: MemoryTier;
59
- salience: number;
60
- accessCount: number;
61
- tags: string[];
62
- metadata: Record<string, unknown>;
63
- facts?: ExtractedFact[];
64
- embedding?: number[];
65
- userId?: string;
66
- }
67
- interface MemoryStats {
68
- totalMemories: number;
69
- hotTierCount: number;
70
- warmTierCount: number;
71
- coldTierCount: number;
72
- avgSalience: number;
73
- totalTokens: number;
74
- totalEmbeddings: number;
75
- }
76
- interface SearchResult {
77
- memory: Memory;
78
- score: number;
79
- rank: number;
80
- }
81
- interface HealthStatus {
82
- status: string;
83
- version: string;
84
- uptimeSeconds?: number;
85
- memoryUsageMb?: number;
86
- agentsActive?: number;
87
- }
88
- interface AgentConfig {
89
- name: string;
90
- agentType?: string;
91
- model?: string;
92
- temperature?: number;
93
- maxTokens?: number;
94
- contextLimit?: number;
95
- }
96
- interface Agent {
97
- id: string;
98
- name: string;
99
- agentType: string;
100
- createdAt: string;
101
- config: Record<string, unknown>;
102
- }
103
- interface AgentExecutionResult {
104
- success: boolean;
105
- response: string;
106
- reasoning?: string;
107
- memoriesUsed: string[];
108
- tokensUsed: number;
109
- executionTimeMs: number;
110
- }
111
- interface User {
112
- id: string;
113
- email: string;
114
- name?: string;
115
- avatarUrl?: string;
116
- emailVerified: boolean;
117
- createdAt?: string;
118
- }
119
- interface AuthResponse {
120
- accessToken: string;
121
- tokenType: string;
122
- expiresIn: number;
123
- refreshToken?: string;
124
- user: User;
125
- }
126
- interface ApiKey {
127
- keyId: string;
128
- name: string;
129
- key?: string;
130
- permissions: string[];
131
- createdAt?: string;
132
- expiresAt?: string;
133
- lastUsedAt?: string;
134
- ipWhitelist?: string[];
135
- isActive: boolean;
136
- }
137
- interface Session {
138
- sessionId: string;
139
- deviceInfo?: string;
140
- ipAddress?: string;
141
- createdAt?: string;
142
- lastActiveAt?: string;
143
- }
144
- interface AddMemoryOptions {
145
- content: string;
146
- metadata?: Record<string, unknown>;
147
- tags?: string[];
148
- userId?: string;
149
- }
150
- interface SearchMemoriesOptions {
151
- query: string;
152
- limit?: number;
153
- tags?: string[];
154
- tagMode?: 'any' | 'all';
155
- minRelevance?: number;
156
- userId?: string;
157
- }
158
- interface CreateAgentOptions {
159
- name: string;
160
- agentType?: string;
161
- config?: AgentConfig;
162
- }
163
- interface ExecuteTaskOptions {
164
- task: string;
165
- contextLimit?: number;
166
- includeReasoning?: boolean;
167
- }
168
- interface CreateApiKeyOptions {
169
- name: string;
170
- permissions?: string[];
171
- expiresInDays?: number;
172
- ipWhitelist?: string[];
173
- }
174
- interface CilowClientConfig {
175
- baseUrl?: string;
176
- apiKey?: string;
177
- accessToken?: string;
178
- timeout?: number;
179
- }
1
+ import { CilowClient } from './client.mjs';
2
+ export { CilowApiError, createClient } from './client.mjs';
3
+ import { CilowConfig } from './types.mjs';
4
+ export { AdvancedSearchOptions, ApiError, BaseEvent, BatchResult, CilowEvent, ConnectionStatusEvent, ContextResult, ConversationTurn, CreateMemoryOptions, FullCilowConfig, GraphEdge, GraphEdgeCreatedEvent, GraphNode, GraphNodeCreatedEvent, GraphSubgraph, GraphTraversalOptions, HealthCheck, Memory, MemoryCreatedEvent, MemoryDeletedEvent, MemoryStats, MemoryStatus, MemorySummary, MemoryTier, MemoryTierChangedEvent, MemoryUpdatedEvent, PaginatedResponse, PaginationParams, SearchQuery, SearchResult, TagCount, UpdateMemoryOptions, UserStats, WebSocketConfig, isApiError, isGraphEvent, isMemoryEvent } from './types.mjs';
5
+ export { CilowWebSocket, ConnectionState, EventListener, SubscriptionFilter, createWebSocket } from './websocket.mjs';
180
6
 
181
7
  /**
182
- * Cilow TypeScript SDK Client
183
- * Async-first client for the Cilow AI Agent Platform
8
+ * @cilow/sdk - Complete TypeScript SDK for Cilow AI Memory Infrastructure
9
+ *
10
+ * Cilow provides a multi-tier memory system for AI applications, enabling
11
+ * persistent context, semantic search, and knowledge graph capabilities.
12
+ *
13
+ * @packageDocumentation
14
+ *
15
+ * @example Basic Usage
16
+ * ```typescript
17
+ * import { Cilow } from '@cilow/sdk';
18
+ *
19
+ * const cilow = new Cilow({
20
+ * apiUrl: 'https://api.cilow.ai',
21
+ * apiKey: 'your-api-key'
22
+ * });
23
+ *
24
+ * // Store a memory
25
+ * await cilow.remember("User prefers dark mode", { tags: ["preference"] });
26
+ *
27
+ * // Search memories
28
+ * const memories = await cilow.recall("user preferences");
29
+ *
30
+ * // Delete memories
31
+ * await cilow.forget({ tags: ["old"] });
32
+ * ```
33
+ *
34
+ * @example Vercel AI SDK Integration
35
+ * ```typescript
36
+ * import { createCilowTools } from '@cilow/sdk/providers/vercel';
37
+ * import { streamText } from 'ai';
38
+ *
39
+ * const tools = createCilowTools({
40
+ * apiUrl: 'https://api.cilow.ai',
41
+ * apiKey: 'your-key'
42
+ * });
43
+ *
44
+ * const result = await streamText({
45
+ * model: anthropic('claude-sonnet-4-20250514'),
46
+ * tools,
47
+ * prompt: 'What do you remember about me?'
48
+ * });
49
+ * ```
50
+ *
51
+ * @example React Integration
52
+ * ```typescript
53
+ * import { CilowProvider, useMemory, useRecall } from '@cilow/sdk/react';
54
+ *
55
+ * function App() {
56
+ * return (
57
+ * <CilowProvider apiUrl="https://api.cilow.ai" apiKey="your-key">
58
+ * <MemoryComponent />
59
+ * </CilowProvider>
60
+ * );
61
+ * }
62
+ * ```
184
63
  */
185
64
 
186
65
  /**
187
- * CilowClient - TypeScript client for Cilow AI Agent Platform
66
+ * Cilow - Main entry point for the Cilow SDK
67
+ *
68
+ * This is an alias for CilowClient with a simpler name for common usage.
188
69
  *
189
70
  * @example
190
71
  * ```typescript
191
- * const client = new CilowClient({ apiKey: 'cilow_xxx' });
72
+ * import { Cilow } from '@cilow/sdk';
192
73
  *
193
- * // Add a memory
194
- * const memoryId = await client.addMemory({ content: 'User prefers Python' });
74
+ * const cilow = new Cilow({
75
+ * apiUrl: 'https://api.cilow.ai',
76
+ * apiKey: 'your-api-key'
77
+ * });
195
78
  *
196
- * // Search memories
197
- * const results = await client.searchMemories({ query: 'programming' });
79
+ * // Simple API
80
+ * await cilow.remember("User prefers dark mode", { tags: ["preference"] });
81
+ * const memories = await cilow.recall("user preferences");
82
+ * await cilow.forget({ tags: ["old"] });
198
83
  *
199
- * // Create an agent
200
- * const agentId = await client.createAgent({ name: 'assistant' });
84
+ * // Full API
85
+ * const memory = await cilow.getMemory("mem-123");
86
+ * const stats = await cilow.getStats();
87
+ * const context = await cilow.getContext("recent discussions");
201
88
  * ```
202
89
  */
203
- declare class CilowClient {
204
- private readonly baseUrl;
205
- private readonly apiKey?;
206
- private accessToken?;
207
- private readonly timeout;
208
- constructor(config?: CilowClientConfig);
209
- /**
210
- * Set the JWT access token for Bearer authentication
211
- */
212
- setAccessToken(token: string): void;
213
- /**
214
- * Make API request with error handling
215
- */
216
- private request;
217
- /**
218
- * Check API server health
219
- */
220
- healthCheck(): Promise<HealthStatus>;
221
- /**
222
- * Add a new memory to the system
223
- */
224
- addMemory(options: AddMemoryOptions): Promise<string>;
225
- /**
226
- * Get a memory by ID
227
- */
228
- getMemory(memoryId: string, userId?: string): Promise<Memory>;
229
- /**
230
- * Update an existing memory
231
- */
232
- updateMemory(memoryId: string, options: Partial<AddMemoryOptions>): Promise<{
233
- memoryId: string;
234
- message: string;
235
- }>;
236
- /**
237
- * Delete a memory
238
- */
239
- deleteMemory(memoryId: string): Promise<boolean>;
240
- /**
241
- * Search memories with semantic similarity
242
- */
243
- searchMemories(options: SearchMemoriesOptions): Promise<SearchResult[]>;
244
- /**
245
- * Get memory system statistics
246
- */
247
- getMemoryStats(): Promise<MemoryStats>;
248
- /**
249
- * List memories with pagination
250
- */
251
- listMemories(options?: {
252
- limit?: number;
253
- offset?: number;
254
- tags?: string[];
255
- userId?: string;
256
- }): Promise<Memory[]>;
257
- /**
258
- * Store a vector embedding directly
259
- */
260
- storeVector(options: {
261
- embedding: number[];
262
- metadata?: Record<string, unknown>;
263
- content?: string;
264
- }): Promise<string>;
265
- /**
266
- * Search for similar vectors
267
- */
268
- searchVectors(options: {
269
- embedding: number[];
270
- limit?: number;
271
- minScore?: number;
272
- }): Promise<Array<{
273
- id: string;
274
- score: number;
275
- metadata?: Record<string, unknown>;
276
- }>>;
277
- /**
278
- * Get a vector by ID
279
- */
280
- getVector(vectorId: string): Promise<{
281
- id: string;
282
- embedding: number[];
283
- metadata?: Record<string, unknown>;
284
- }>;
285
- /**
286
- * Delete a vector
287
- */
288
- deleteVector(vectorId: string): Promise<boolean>;
289
- /**
290
- * Query the knowledge graph with natural language
291
- */
292
- queryGraph(query: string, limit?: number): Promise<unknown[]>;
293
- /**
294
- * Add a node to the knowledge graph
295
- */
296
- addGraphNode(options: {
297
- label: string;
298
- properties: Record<string, unknown>;
299
- nodeType?: string;
300
- }): Promise<string>;
301
- /**
302
- * Get a graph node by ID
303
- */
304
- getGraphNode(nodeId: string): Promise<{
305
- id: string;
306
- label: string;
307
- properties: Record<string, unknown>;
308
- }>;
309
- /**
310
- * Delete a graph node
311
- */
312
- deleteGraphNode(nodeId: string): Promise<boolean>;
313
- /**
314
- * Get knowledge graph statistics
315
- */
316
- getGraphStats(): Promise<{
317
- nodeCount: number;
318
- edgeCount: number;
319
- }>;
320
- /**
321
- * Create a new AI agent
322
- */
323
- createAgent(options: CreateAgentOptions): Promise<string>;
324
- /**
325
- * Get agent details
326
- */
327
- getAgent(agentId: string): Promise<Agent>;
328
- /**
329
- * Execute a task with an AI agent
330
- */
331
- executeTask(agentId: string, options: ExecuteTaskOptions): Promise<AgentExecutionResult>;
332
- /**
333
- * Extract facts from content using intelligent extraction
334
- */
335
- extractFacts(content: string, sourceContext?: string): Promise<ExtractedFact[]>;
336
- /**
337
- * Register a new user account
338
- */
339
- register(email: string, password: string, name?: string): Promise<AuthResponse>;
340
- /**
341
- * Login with email and password
342
- */
343
- login(email: string, password: string): Promise<AuthResponse>;
344
- /**
345
- * Refresh the current access token
346
- */
347
- refreshToken(): Promise<AuthResponse>;
348
- /**
349
- * Get the currently authenticated user
350
- */
351
- getCurrentUser(): Promise<User>;
352
- /**
353
- * Logout and invalidate current session
354
- */
355
- logout(): Promise<boolean>;
356
- /**
357
- * Create a new API key for programmatic access
358
- */
359
- createApiKey(options: CreateApiKeyOptions): Promise<ApiKey>;
360
- /**
361
- * List all API keys for the current user
362
- */
363
- listApiKeys(): Promise<ApiKey[]>;
364
- /**
365
- * Revoke an API key
366
- */
367
- revokeApiKey(keyId: string): Promise<boolean>;
368
- /**
369
- * List all active sessions for the current user
370
- */
371
- listSessions(): Promise<Session[]>;
372
- /**
373
- * Revoke a specific session
374
- */
375
- revokeSession(sessionId: string): Promise<boolean>;
376
- /**
377
- * Revoke all sessions except the current one
378
- */
379
- revokeAllSessions(): Promise<boolean>;
90
+ declare class Cilow extends CilowClient {
91
+ constructor(config: CilowConfig);
380
92
  }
381
-
382
93
  /**
383
- * Cilow SDK Error Classes
94
+ * Create a Cilow instance (convenience function)
95
+ *
96
+ * @param config - Configuration options
97
+ * @returns Cilow client instance
98
+ *
99
+ * @example
100
+ * ```typescript
101
+ * import { createCilow } from '@cilow/sdk';
102
+ *
103
+ * const cilow = createCilow({
104
+ * apiUrl: 'https://api.cilow.ai',
105
+ * apiKey: 'your-api-key'
106
+ * });
107
+ * ```
384
108
  */
385
- declare class CilowError extends Error {
386
- readonly statusCode?: number;
387
- readonly details?: unknown;
388
- constructor(message: string, statusCode?: number, details?: unknown);
389
- }
390
- declare class ConnectionError extends CilowError {
391
- constructor(message: string, details?: unknown);
392
- }
393
- declare class AuthenticationError extends CilowError {
394
- constructor(message?: string, details?: unknown);
395
- }
396
- declare class NotFoundError extends CilowError {
397
- constructor(message?: string, details?: unknown);
398
- }
399
- declare class ValidationError extends CilowError {
400
- constructor(message?: string, details?: unknown);
401
- }
402
- declare class RateLimitError extends CilowError {
403
- readonly retryAfter?: number;
404
- constructor(message?: string, retryAfter?: number, details?: unknown);
405
- }
109
+ declare function createCilow(config: CilowConfig): Cilow;
406
110
 
407
- export { type AddMemoryOptions, type Agent, type AgentConfig, type AgentExecutionResult, type ApiKey, type AuthResponse, AuthenticationError, CilowClient, type CilowClientConfig, CilowError, ConnectionError, type CreateAgentOptions, type CreateApiKeyOptions, type Entity, EntityType, type ExecuteTaskOptions, type ExtractedFact, FactType, type HealthStatus, type Memory, type MemoryStats, MemoryTier, NotFoundError, RateLimitError, type Relationship, type SearchMemoriesOptions, type SearchResult, type Session, type User, ValidationError };
111
+ export { Cilow, CilowClient, CilowConfig, createCilow, Cilow as default };