@nebula-ai/sdk 0.0.21 → 0.0.27

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.
package/dist/index.d.ts CHANGED
@@ -1,8 +1,3 @@
1
- declare enum RetrievalType {
2
- BASIC = "basic",
3
- ADVANCED = "advanced",
4
- CUSTOM = "custom"
5
- }
6
1
  declare enum GraphSearchResultType {
7
2
  ENTITY = "entity",
8
3
  RELATIONSHIP = "relationship",
@@ -39,6 +34,11 @@ interface SearchResult {
39
34
  score: number;
40
35
  metadata: Record<string, any>;
41
36
  source?: string;
37
+ timestamp?: string;
38
+ display_name?: string;
39
+ source_role?: string;
40
+ document_id?: string;
41
+ owner_id?: string;
42
42
  content?: string;
43
43
  graph_result_type?: GraphSearchResultType;
44
44
  graph_entity?: GraphEntityResult;
@@ -78,17 +78,17 @@ interface AgentResponse {
78
78
  interface SearchOptions {
79
79
  limit: number;
80
80
  filters?: Record<string, any>;
81
- retrieval_type: RetrievalType;
81
+ search_mode?: 'fast' | 'super';
82
82
  }
83
- interface NebulaSDKConfig {
83
+ interface NebulaClientConfig {
84
84
  apiKey: string;
85
85
  baseUrl?: string;
86
86
  timeout?: number;
87
87
  }
88
88
  declare class NebulaException extends Error {
89
89
  statusCode?: number | undefined;
90
- details?: any;
91
- constructor(message: string, statusCode?: number | undefined, details?: any);
90
+ details?: any | undefined;
91
+ constructor(message: string, statusCode?: number | undefined, details?: any | undefined);
92
92
  }
93
93
  declare class NebulaClientException extends NebulaException {
94
94
  cause?: Error | undefined;
@@ -101,122 +101,221 @@ declare class NebulaRateLimitException extends NebulaException {
101
101
  constructor(message?: string);
102
102
  }
103
103
  declare class NebulaValidationException extends NebulaException {
104
- details?: any;
105
- constructor(message?: string, details?: any);
104
+ details?: any | undefined;
105
+ constructor(message?: string, details?: any | undefined);
106
106
  }
107
107
  declare class NebulaClusterNotFoundException extends NebulaException {
108
108
  constructor(message?: string);
109
109
  }
110
110
 
111
111
  /**
112
- * Official Nebula Cloud JavaScript/TypeScript SDK
112
+ * Official Nebula JavaScript/TypeScript SDK
113
113
  * Mirrors the exact Nebula Python SDK client.py implementation
114
114
  */
115
- declare class NebulaSDK {
115
+ declare class NebulaClient {
116
116
  private apiKey;
117
117
  private baseUrl;
118
118
  private timeout;
119
- constructor(config: NebulaSDKConfig);
120
- /**
121
- * Check if API key is set
122
- */
119
+ constructor(config: NebulaClientConfig);
120
+ setApiKey(next: string): void;
121
+ setBaseUrl(next: string): void;
122
+ setCorsProxy(_next: string): void;
123
+ /** Check if API key is set */
123
124
  isApiKeySet(): boolean;
124
- /**
125
- * Detect if a token looks like a Nebula API key (public.raw)
126
- */
125
+ /** Detect if a token looks like a Nebula API key (public.raw) */
127
126
  private _isNebulaApiKey;
128
- /**
129
- * Build authentication headers
130
- */
127
+ /** Build authentication headers */
131
128
  private _buildAuthHeaders;
132
- /**
133
- * Make an HTTP request to the Nebula API
134
- */
129
+ /** Make an HTTP request to the Nebula API */
135
130
  private _makeRequest;
136
- /**
137
- * Create a new cluster
138
- */
139
- createCluster(name: string, description?: string, metadata?: Record<string, any>): Promise<Cluster>;
140
- /**
141
- * Get a specific cluster by ID
142
- */
131
+ /** Create a new cluster */
132
+ createCluster(options: {
133
+ name: string;
134
+ description?: string;
135
+ metadata?: Record<string, any>;
136
+ }): Promise<Cluster>;
137
+ /** Get a specific cluster by ID */
143
138
  getCluster(clusterId: string): Promise<Cluster>;
144
- /**
145
- * Get a specific cluster by name
146
- */
139
+ /** Get a specific cluster by name */
147
140
  getClusterByName(name: string): Promise<Cluster>;
148
- /**
149
- * Get all clusters
150
- */
151
- listClusters(limit?: number, offset?: number): Promise<Cluster[]>;
152
- /**
153
- * List conversations for the authenticated user
154
- */
155
- listConversations(limit?: number, offset?: number): Promise<any[]>;
156
- /**
157
- * Update a cluster
158
- */
159
- updateCluster(clusterId: string, name?: string, description?: string, metadata?: Record<string, any>): Promise<Cluster>;
160
- /**
161
- * Delete a cluster
162
- */
141
+ /** Get all clusters */
142
+ listClusters(options?: {
143
+ limit?: number;
144
+ offset?: number;
145
+ }): Promise<Cluster[]>;
146
+ /** List conversations for the authenticated user */
147
+ listConversations(options?: {
148
+ limit?: number;
149
+ offset?: number;
150
+ cluster_ids?: string[];
151
+ }): Promise<any[]>;
152
+ /** Get conversation messages directly from the conversations API */
153
+ getConversationMessages(conversationId: string): Promise<MemoryResponse[]>;
154
+ getConversationMessages(conversationIds: string[]): Promise<Record<string, MemoryResponse[]>>;
155
+ /** Helper method to transform conversation messages to MemoryResponse format */
156
+ private _transformConversationMessages;
157
+ /** Update a cluster */
158
+ updateCluster(options: {
159
+ clusterId: string;
160
+ name?: string;
161
+ description?: string;
162
+ metadata?: Record<string, any>;
163
+ }): Promise<Cluster>;
164
+ /** Delete a cluster */
163
165
  deleteCluster(clusterId: string): Promise<boolean>;
164
166
  /**
165
- * Store a single memory
167
+ * Legacy convenience: store raw text content into a cluster as a document
166
168
  */
169
+ store(content: string, clusterId: string, metadata?: Record<string, any>): Promise<MemoryResponse>;
170
+ /** Store a single memory */
167
171
  storeMemory(memory: Memory | Record<string, any>): Promise<string>;
168
- /**
169
- * Store multiple memories
170
- */
172
+ /** Store multiple memories */
171
173
  storeMemories(memories: Memory[]): Promise<string[]>;
172
- /**
173
- * Delete a specific memory
174
- */
175
- delete(memoryId: string): Promise<boolean>;
176
- /**
177
- * Delete a conversation and all its messages
178
- */
174
+ /** Delete one or more memories */
175
+ delete(memoryIds: string | string[]): Promise<boolean | {
176
+ message: string;
177
+ results: {
178
+ successful: string[];
179
+ failed: Array<{
180
+ id: string;
181
+ error: string;
182
+ }>;
183
+ summary: {
184
+ total: number;
185
+ succeeded: number;
186
+ failed: number;
187
+ };
188
+ };
189
+ }>;
190
+ /** Delete a conversation and all its messages */
179
191
  deleteConversation(conversationId: string): Promise<boolean>;
180
- /**
181
- * Get all memories from specific clusters
182
- */
183
- listMemories(clusterIds: string[], limit?: number, offset?: number): Promise<MemoryResponse[]>;
184
- /**
185
- * Get a specific memory by ID
186
- */
192
+ /** Get all memories from specific clusters */
193
+ listMemories(options: {
194
+ cluster_ids: string | string[];
195
+ limit?: number;
196
+ offset?: number;
197
+ }): Promise<MemoryResponse[]>;
198
+ /** Get a specific memory by ID */
187
199
  getMemory(memoryId: string): Promise<MemoryResponse>;
188
200
  /**
189
- * Search within specific clusters
201
+ * Search within specific clusters with optional metadata filtering.
202
+ *
203
+ * @param options - Search configuration
204
+ * @param options.query - Search query string
205
+ * @param options.cluster_ids - One or more cluster IDs to search within
206
+ * @param options.limit - Maximum number of results to return (default: 10)
207
+ * @param options.retrieval_type - Retrieval strategy (default: ADVANCED)
208
+ * @param options.filters - Optional filters to apply to the search. Supports comprehensive metadata filtering
209
+ * with MongoDB-like operators for both vector/chunk search and graph search.
210
+ * @param options.searchSettings - Optional search configuration
211
+ *
212
+ * @returns Promise resolving to array of SearchResult objects containing both vector/chunk and graph search results
213
+ *
214
+ * @example
215
+ * // Basic equality filter
216
+ * await client.search({
217
+ * query: "machine learning",
218
+ * cluster_ids: ["research-cluster"],
219
+ * filters: {
220
+ * "metadata.category": { $eq: "research" },
221
+ * "metadata.verified": true // Shorthand for $eq
222
+ * }
223
+ * });
224
+ *
225
+ * @example
226
+ * // Numeric comparisons
227
+ * await client.search({
228
+ * query: "high priority",
229
+ * cluster_ids: ["tasks"],
230
+ * filters: {
231
+ * "metadata.priority": { $gte: 8 },
232
+ * "metadata.score": { $lt: 100 }
233
+ * }
234
+ * });
235
+ *
236
+ * @example
237
+ * // String matching
238
+ * await client.search({
239
+ * query: "employees",
240
+ * cluster_ids: ["team"],
241
+ * filters: {
242
+ * "metadata.email": { $ilike: "%@company.com" } // Case-insensitive
243
+ * }
244
+ * });
245
+ *
246
+ * @example
247
+ * // Array operations
248
+ * await client.search({
249
+ * query: "developers",
250
+ * cluster_ids: ["team"],
251
+ * filters: {
252
+ * "metadata.skills": { $overlap: ["python", "typescript"] } // Has any
253
+ * }
254
+ * });
255
+ *
256
+ * @example
257
+ * // Nested paths
258
+ * await client.search({
259
+ * query: "users",
260
+ * cluster_ids: ["profiles"],
261
+ * filters: {
262
+ * "metadata.user.preferences.theme": { $eq: "dark" }
263
+ * }
264
+ * });
265
+ *
266
+ * @example
267
+ * // Complex logical combinations
268
+ * await client.search({
269
+ * query: "candidates",
270
+ * cluster_ids: ["hiring"],
271
+ * filters: {
272
+ * $and: [
273
+ * { "metadata.verified": true },
274
+ * { "metadata.level": { $gte: 5 } },
275
+ * {
276
+ * $or: [
277
+ * { "metadata.skills": { $overlap: ["python", "go"] } },
278
+ * { "metadata.years_experience": { $gte: 8 } }
279
+ * ]
280
+ * }
281
+ * ]
282
+ * }
283
+ * });
284
+ *
285
+ * @remarks
286
+ * Supported Operators:
287
+ * - Comparison: $eq, $ne, $lt, $lte, $gt, $gte
288
+ * - String: $like (case-sensitive), $ilike (case-insensitive)
289
+ * - Array: $in, $nin, $overlap, $contains
290
+ * - JSONB: $json_contains
291
+ * - Logical: $and, $or
292
+ *
293
+ * For comprehensive filtering documentation, see the Metadata Filtering Guide:
294
+ * https://docs.nebulacloud.app/guides/metadata-filtering
190
295
  */
191
- search(query: string, clusterIds: string[], limit?: number, retrievalType?: RetrievalType | string, filters?: Record<string, any>, searchSettings?: Record<string, any>): Promise<SearchResult[]>;
296
+ search(options: {
297
+ query: string;
298
+ cluster_ids: string | string[];
299
+ limit?: number;
300
+ filters?: Record<string, any>;
301
+ search_mode?: 'fast' | 'super';
302
+ searchSettings?: Record<string, any>;
303
+ }): Promise<SearchResult[]>;
192
304
  /**
193
- * Check the health of the Nebula API
305
+ * Legacy wrapper: store a two-message conversation turn as a document
194
306
  */
195
- healthCheck(): Promise<Record<string, any>>;
307
+ storeConversation(userMessage: string, assistantMessage: string, clusterId: string, sessionId: string): Promise<MemoryResponse>;
196
308
  /**
197
- * Convert cluster dict to Cluster object
309
+ * Legacy wrapper: search conversations optionally scoped by session
198
310
  */
311
+ searchConversations(query: string, clusterId: string, sessionId?: string, includeAllSessions?: boolean): Promise<SearchResult[]>;
312
+ healthCheck(): Promise<Record<string, any>>;
199
313
  private _clusterFromDict;
200
- /**
201
- * Convert memory dict to MemoryResponse object
202
- */
203
314
  private _memoryResponseFromDict;
204
- /**
205
- * Convert search result dict to SearchResult object
206
- */
207
315
  private _searchResultFromDict;
208
- /**
209
- * Convert graph search result dict to SearchResult object
210
- */
211
316
  private _searchResultFromGraphDict;
212
- /**
213
- * SHA-256 hash function
214
- */
215
317
  private _sha256;
216
- /**
217
- * Convert object to FormData
218
- */
219
318
  private _formDataFromObject;
220
319
  }
221
320
 
222
- export { type AgentResponse, type Cluster, type GraphCommunityResult, type GraphEntityResult, type GraphRelationshipResult, GraphSearchResultType, type Memory, type MemoryResponse, NebulaAuthenticationException, NebulaClientException, NebulaClusterNotFoundException, NebulaException, NebulaRateLimitException, NebulaSDK, type NebulaSDKConfig, NebulaValidationException, RetrievalType, type SearchOptions, type SearchResult, NebulaSDK as default };
321
+ export { type AgentResponse, type Cluster, type GraphCommunityResult, type GraphEntityResult, type GraphRelationshipResult, GraphSearchResultType, type Memory, type MemoryResponse, NebulaAuthenticationException, NebulaClient, type NebulaClientConfig, NebulaClientException, NebulaClusterNotFoundException, NebulaException, NebulaRateLimitException, NebulaValidationException, type SearchOptions, type SearchResult };