@cilow/sdk 0.2.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,407 @@
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
+ }
180
+
181
+ /**
182
+ * Cilow TypeScript SDK Client
183
+ * Async-first client for the Cilow AI Agent Platform
184
+ */
185
+
186
+ /**
187
+ * CilowClient - TypeScript client for Cilow AI Agent Platform
188
+ *
189
+ * @example
190
+ * ```typescript
191
+ * const client = new CilowClient({ apiKey: 'cilow_xxx' });
192
+ *
193
+ * // Add a memory
194
+ * const memoryId = await client.addMemory({ content: 'User prefers Python' });
195
+ *
196
+ * // Search memories
197
+ * const results = await client.searchMemories({ query: 'programming' });
198
+ *
199
+ * // Create an agent
200
+ * const agentId = await client.createAgent({ name: 'assistant' });
201
+ * ```
202
+ */
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>;
380
+ }
381
+
382
+ /**
383
+ * Cilow SDK Error Classes
384
+ */
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
+ }
406
+
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 };