@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
@@ -0,0 +1,224 @@
1
+ import { CilowConfig, CreateMemoryOptions, SearchResult, Memory, UpdateMemoryOptions, PaginatedResponse, MemorySummary, SearchQuery, AdvancedSearchOptions, ContextResult, ConversationTurn, GraphNode, GraphEdge, GraphTraversalOptions, GraphSubgraph, MemoryStats, TagCount, UserStats, HealthCheck } from './types.mjs';
2
+
3
+ /**
4
+ * Cilow Client - Core HTTP Client for Cilow API
5
+ *
6
+ * Provides a clean, type-safe interface for interacting with the Cilow
7
+ * memory system API.
8
+ */
9
+
10
+ /**
11
+ * Custom error class for Cilow API errors
12
+ */
13
+ declare class CilowApiError extends Error {
14
+ readonly code: string;
15
+ readonly statusCode: number;
16
+ readonly details?: Record<string, unknown> | undefined;
17
+ constructor(message: string, code: string, statusCode: number, details?: Record<string, unknown> | undefined);
18
+ }
19
+ /**
20
+ * CilowClient - Main client class for interacting with the Cilow API
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const client = new CilowClient({
25
+ * apiUrl: 'https://api.cilow.ai',
26
+ * apiKey: 'your-api-key'
27
+ * });
28
+ *
29
+ * // Store a memory
30
+ * const memoryId = await client.remember("User prefers dark mode", {
31
+ * tags: ["preference", "ui"]
32
+ * });
33
+ *
34
+ * // Search memories
35
+ * const results = await client.recall("user preferences");
36
+ *
37
+ * // Delete memories
38
+ * await client.forget({ tags: ["old"] });
39
+ * ```
40
+ */
41
+ declare class CilowClient {
42
+ private readonly baseUrl;
43
+ private readonly apiKey;
44
+ private readonly timeout;
45
+ private readonly retries;
46
+ private readonly headers;
47
+ private readonly debug;
48
+ constructor(config: CilowConfig);
49
+ /**
50
+ * Make an API request
51
+ */
52
+ private request;
53
+ /**
54
+ * Store a memory (simple API)
55
+ *
56
+ * @param content - The content to remember
57
+ * @param options - Optional configuration
58
+ * @returns The created memory ID
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * await cilow.remember("User prefers dark mode", {
63
+ * tags: ["preference"],
64
+ * userId: "user-123"
65
+ * });
66
+ * ```
67
+ */
68
+ remember(content: string, options?: CreateMemoryOptions): Promise<string>;
69
+ /**
70
+ * Search memories (simple API)
71
+ *
72
+ * @param query - Search query text
73
+ * @param options - Search options
74
+ * @returns Array of search results
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * const memories = await cilow.recall("user preferences", {
79
+ * limit: 10,
80
+ * tags: ["preference"]
81
+ * });
82
+ * ```
83
+ */
84
+ recall(query: string, options?: {
85
+ limit?: number;
86
+ minRelevance?: number;
87
+ tags?: string[];
88
+ userId?: string;
89
+ }): Promise<SearchResult[]>;
90
+ /**
91
+ * Delete memories (simple API)
92
+ *
93
+ * @param filter - Filter criteria for deletion
94
+ * @returns Number of memories deleted
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * // Delete by tags
99
+ * await cilow.forget({ tags: ["temporary"] });
100
+ *
101
+ * // Delete by user
102
+ * await cilow.forget({ userId: "user-123" });
103
+ *
104
+ * // Delete specific memory
105
+ * await cilow.forget({ memoryId: "mem-abc" });
106
+ * ```
107
+ */
108
+ forget(filter: {
109
+ memoryId?: string;
110
+ tags?: string[];
111
+ userId?: string;
112
+ sessionId?: string;
113
+ olderThan?: string;
114
+ }): Promise<number>;
115
+ /**
116
+ * Create a new memory
117
+ */
118
+ createMemory(content: string, options?: CreateMemoryOptions): Promise<Memory>;
119
+ /**
120
+ * Get a memory by ID
121
+ */
122
+ getMemory(memoryId: string): Promise<Memory>;
123
+ /**
124
+ * Update a memory
125
+ */
126
+ updateMemory(memoryId: string, updates: UpdateMemoryOptions): Promise<Memory>;
127
+ /**
128
+ * Delete a memory
129
+ */
130
+ deleteMemory(memoryId: string): Promise<void>;
131
+ /**
132
+ * List memories with pagination
133
+ */
134
+ listMemories(options?: {
135
+ limit?: number;
136
+ offset?: number;
137
+ userId?: string;
138
+ sessionId?: string;
139
+ tags?: string[];
140
+ tier?: string;
141
+ }): Promise<PaginatedResponse<MemorySummary>>;
142
+ /**
143
+ * Search memories with full options
144
+ */
145
+ searchMemories(query: SearchQuery): Promise<SearchResult[]>;
146
+ /**
147
+ * Advanced search with reranking and boosts
148
+ */
149
+ advancedSearch(query: AdvancedSearchOptions): Promise<SearchResult[]>;
150
+ /**
151
+ * Get context for AI applications
152
+ */
153
+ getContext(query: string, options?: {
154
+ maxTokens?: number;
155
+ userId?: string;
156
+ tags?: string[];
157
+ }): Promise<ContextResult>;
158
+ /**
159
+ * Store a conversation turn
160
+ */
161
+ storeConversation(turn: ConversationTurn & {
162
+ userId: string;
163
+ }): Promise<string>;
164
+ /**
165
+ * Get conversation history for a session
166
+ */
167
+ getConversationHistory(sessionId: string, options?: {
168
+ limit?: number;
169
+ offset?: number;
170
+ }): Promise<MemorySummary[]>;
171
+ /**
172
+ * Get a graph node
173
+ */
174
+ getGraphNode(nodeId: string): Promise<GraphNode>;
175
+ /**
176
+ * Create a graph node
177
+ */
178
+ createGraphNode(type: string, name: string, properties?: Record<string, unknown>): Promise<GraphNode>;
179
+ /**
180
+ * Create a graph edge
181
+ */
182
+ createGraphEdge(sourceId: string, targetId: string, type: string, properties?: Record<string, unknown>): Promise<GraphEdge>;
183
+ /**
184
+ * Traverse the graph from a starting node
185
+ */
186
+ traverseGraph(options: GraphTraversalOptions): Promise<GraphSubgraph>;
187
+ /**
188
+ * Get related nodes for a memory
189
+ */
190
+ getRelatedNodes(memoryId: string): Promise<GraphNode[]>;
191
+ /**
192
+ * Get memory statistics
193
+ */
194
+ getStats(): Promise<MemoryStats>;
195
+ /**
196
+ * Get all tags with counts
197
+ */
198
+ getTags(): Promise<TagCount[]>;
199
+ /**
200
+ * Get user statistics
201
+ */
202
+ getUserStats(userId: string): Promise<UserStats>;
203
+ /**
204
+ * Health check
205
+ */
206
+ healthCheck(): Promise<HealthCheck>;
207
+ /**
208
+ * Batch create memories
209
+ */
210
+ batchCreate(items: Array<{
211
+ content: string;
212
+ options?: CreateMemoryOptions;
213
+ }>): Promise<string[]>;
214
+ /**
215
+ * Batch delete memories
216
+ */
217
+ batchDelete(memoryIds: string[]): Promise<number>;
218
+ }
219
+ /**
220
+ * Create a Cilow client instance (convenience function)
221
+ */
222
+ declare function createClient(config: CilowConfig): CilowClient;
223
+
224
+ export { CilowApiError, CilowClient, createClient };
@@ -0,0 +1,224 @@
1
+ import { CilowConfig, CreateMemoryOptions, SearchResult, Memory, UpdateMemoryOptions, PaginatedResponse, MemorySummary, SearchQuery, AdvancedSearchOptions, ContextResult, ConversationTurn, GraphNode, GraphEdge, GraphTraversalOptions, GraphSubgraph, MemoryStats, TagCount, UserStats, HealthCheck } from './types.js';
2
+
3
+ /**
4
+ * Cilow Client - Core HTTP Client for Cilow API
5
+ *
6
+ * Provides a clean, type-safe interface for interacting with the Cilow
7
+ * memory system API.
8
+ */
9
+
10
+ /**
11
+ * Custom error class for Cilow API errors
12
+ */
13
+ declare class CilowApiError extends Error {
14
+ readonly code: string;
15
+ readonly statusCode: number;
16
+ readonly details?: Record<string, unknown> | undefined;
17
+ constructor(message: string, code: string, statusCode: number, details?: Record<string, unknown> | undefined);
18
+ }
19
+ /**
20
+ * CilowClient - Main client class for interacting with the Cilow API
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const client = new CilowClient({
25
+ * apiUrl: 'https://api.cilow.ai',
26
+ * apiKey: 'your-api-key'
27
+ * });
28
+ *
29
+ * // Store a memory
30
+ * const memoryId = await client.remember("User prefers dark mode", {
31
+ * tags: ["preference", "ui"]
32
+ * });
33
+ *
34
+ * // Search memories
35
+ * const results = await client.recall("user preferences");
36
+ *
37
+ * // Delete memories
38
+ * await client.forget({ tags: ["old"] });
39
+ * ```
40
+ */
41
+ declare class CilowClient {
42
+ private readonly baseUrl;
43
+ private readonly apiKey;
44
+ private readonly timeout;
45
+ private readonly retries;
46
+ private readonly headers;
47
+ private readonly debug;
48
+ constructor(config: CilowConfig);
49
+ /**
50
+ * Make an API request
51
+ */
52
+ private request;
53
+ /**
54
+ * Store a memory (simple API)
55
+ *
56
+ * @param content - The content to remember
57
+ * @param options - Optional configuration
58
+ * @returns The created memory ID
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * await cilow.remember("User prefers dark mode", {
63
+ * tags: ["preference"],
64
+ * userId: "user-123"
65
+ * });
66
+ * ```
67
+ */
68
+ remember(content: string, options?: CreateMemoryOptions): Promise<string>;
69
+ /**
70
+ * Search memories (simple API)
71
+ *
72
+ * @param query - Search query text
73
+ * @param options - Search options
74
+ * @returns Array of search results
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * const memories = await cilow.recall("user preferences", {
79
+ * limit: 10,
80
+ * tags: ["preference"]
81
+ * });
82
+ * ```
83
+ */
84
+ recall(query: string, options?: {
85
+ limit?: number;
86
+ minRelevance?: number;
87
+ tags?: string[];
88
+ userId?: string;
89
+ }): Promise<SearchResult[]>;
90
+ /**
91
+ * Delete memories (simple API)
92
+ *
93
+ * @param filter - Filter criteria for deletion
94
+ * @returns Number of memories deleted
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * // Delete by tags
99
+ * await cilow.forget({ tags: ["temporary"] });
100
+ *
101
+ * // Delete by user
102
+ * await cilow.forget({ userId: "user-123" });
103
+ *
104
+ * // Delete specific memory
105
+ * await cilow.forget({ memoryId: "mem-abc" });
106
+ * ```
107
+ */
108
+ forget(filter: {
109
+ memoryId?: string;
110
+ tags?: string[];
111
+ userId?: string;
112
+ sessionId?: string;
113
+ olderThan?: string;
114
+ }): Promise<number>;
115
+ /**
116
+ * Create a new memory
117
+ */
118
+ createMemory(content: string, options?: CreateMemoryOptions): Promise<Memory>;
119
+ /**
120
+ * Get a memory by ID
121
+ */
122
+ getMemory(memoryId: string): Promise<Memory>;
123
+ /**
124
+ * Update a memory
125
+ */
126
+ updateMemory(memoryId: string, updates: UpdateMemoryOptions): Promise<Memory>;
127
+ /**
128
+ * Delete a memory
129
+ */
130
+ deleteMemory(memoryId: string): Promise<void>;
131
+ /**
132
+ * List memories with pagination
133
+ */
134
+ listMemories(options?: {
135
+ limit?: number;
136
+ offset?: number;
137
+ userId?: string;
138
+ sessionId?: string;
139
+ tags?: string[];
140
+ tier?: string;
141
+ }): Promise<PaginatedResponse<MemorySummary>>;
142
+ /**
143
+ * Search memories with full options
144
+ */
145
+ searchMemories(query: SearchQuery): Promise<SearchResult[]>;
146
+ /**
147
+ * Advanced search with reranking and boosts
148
+ */
149
+ advancedSearch(query: AdvancedSearchOptions): Promise<SearchResult[]>;
150
+ /**
151
+ * Get context for AI applications
152
+ */
153
+ getContext(query: string, options?: {
154
+ maxTokens?: number;
155
+ userId?: string;
156
+ tags?: string[];
157
+ }): Promise<ContextResult>;
158
+ /**
159
+ * Store a conversation turn
160
+ */
161
+ storeConversation(turn: ConversationTurn & {
162
+ userId: string;
163
+ }): Promise<string>;
164
+ /**
165
+ * Get conversation history for a session
166
+ */
167
+ getConversationHistory(sessionId: string, options?: {
168
+ limit?: number;
169
+ offset?: number;
170
+ }): Promise<MemorySummary[]>;
171
+ /**
172
+ * Get a graph node
173
+ */
174
+ getGraphNode(nodeId: string): Promise<GraphNode>;
175
+ /**
176
+ * Create a graph node
177
+ */
178
+ createGraphNode(type: string, name: string, properties?: Record<string, unknown>): Promise<GraphNode>;
179
+ /**
180
+ * Create a graph edge
181
+ */
182
+ createGraphEdge(sourceId: string, targetId: string, type: string, properties?: Record<string, unknown>): Promise<GraphEdge>;
183
+ /**
184
+ * Traverse the graph from a starting node
185
+ */
186
+ traverseGraph(options: GraphTraversalOptions): Promise<GraphSubgraph>;
187
+ /**
188
+ * Get related nodes for a memory
189
+ */
190
+ getRelatedNodes(memoryId: string): Promise<GraphNode[]>;
191
+ /**
192
+ * Get memory statistics
193
+ */
194
+ getStats(): Promise<MemoryStats>;
195
+ /**
196
+ * Get all tags with counts
197
+ */
198
+ getTags(): Promise<TagCount[]>;
199
+ /**
200
+ * Get user statistics
201
+ */
202
+ getUserStats(userId: string): Promise<UserStats>;
203
+ /**
204
+ * Health check
205
+ */
206
+ healthCheck(): Promise<HealthCheck>;
207
+ /**
208
+ * Batch create memories
209
+ */
210
+ batchCreate(items: Array<{
211
+ content: string;
212
+ options?: CreateMemoryOptions;
213
+ }>): Promise<string[]>;
214
+ /**
215
+ * Batch delete memories
216
+ */
217
+ batchDelete(memoryIds: string[]): Promise<number>;
218
+ }
219
+ /**
220
+ * Create a Cilow client instance (convenience function)
221
+ */
222
+ declare function createClient(config: CilowConfig): CilowClient;
223
+
224
+ export { CilowApiError, CilowClient, createClient };