@sovant/sdk 1.1.1 → 1.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.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Sovant AI
3
+ Copyright (c) 2025 Sovant
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,6 +1,24 @@
1
- # Sovant JavaScript/TypeScript SDK
1
+ # Sovant TypeScript SDK
2
2
 
3
- Official JavaScript/TypeScript SDK for the Sovant Memory API - Universal memory layer for AI applications.
3
+ **AI Infrastructure: Memory-as-a-Service for AI systems.**
4
+ The official TypeScript/JavaScript client for the Sovant Memory API.
5
+
6
+ [![npm version](https://img.shields.io/npm/v/@sovant/sdk)](https://www.npmjs.com/package/@sovant/sdk)
7
+ [![Documentation](https://img.shields.io/badge/docs-sovant.ai-blue)](https://sovant.ai/docs)
8
+ [![GitHub](https://img.shields.io/badge/github-sovant-lightgrey)](https://github.com/sovant-ai/sovant)
9
+
10
+ ---
11
+
12
+ ## What is Sovant?
13
+
14
+ Sovant is an **AI infrastructure company** providing the **memory layer for AI systems**.
15
+ Our platform makes it simple to persist, search, and manage conversational and contextual data securely across sessions, channels, and applications.
16
+
17
+ - **Problem:** Most AI systems forget everything once a session ends. This causes compliance risks, knowledge loss, and poor user experience.
18
+ - **Solution:** Sovant provides a **Memory-as-a-Service API** — a single SDK and API key that lets you store, retrieve, and search memories with audit-ready controls.
19
+ - **Target audience:** Developers, startups, and enterprises building AI agents, copilots, or compliance-driven apps who need context persistence.
20
+
21
+ ---
4
22
 
5
23
  ## Installation
6
24
 
@@ -12,450 +30,82 @@ yarn add @sovant/sdk
12
30
  pnpm add @sovant/sdk
13
31
  ```
14
32
 
15
- ## Quick Start
33
+ ## 60-Second Quickstart
16
34
 
17
35
  ```typescript
18
- import { Sovant } from '@sovant/sdk';
36
+ import { Sovant } from "@sovant/sdk";
19
37
 
20
- // Initialize the client
21
- const sovant = new Sovant({
22
- apiKey: 'sk_live_your_api_key_here',
23
- baseUrl: 'https://sovant.ai', // Optional, defaults to https://sovant.ai
24
- });
38
+ const sv = new Sovant({ apiKey: process.env.SOVANT_API_KEY! });
25
39
 
26
40
  // Create a memory
27
- const memory = await sovant.memory.create({
28
- content: 'User prefers dark mode interfaces',
29
- type: 'preference',
30
- tags: ['ui', 'settings'],
41
+ await sv.memory.create({
42
+ data: { note: "User prefers morning meetings" },
43
+ type: "preference"
31
44
  });
32
45
 
33
46
  // Search memories
34
- const results = await sovant.memory.search({
35
- query: 'user preferences',
36
- limit: 10,
37
- });
38
-
39
- // Update a memory
40
- const updated = await sovant.memory.update(memory.id, {
41
- tags: ['ui', 'settings', 'theme'],
42
- });
43
-
44
- // Delete a memory
45
- await sovant.memory.delete(memory.id);
46
- ```
47
-
48
- ## Chat in 60 Seconds
49
-
50
- Stream real-time chat responses with memory context:
51
-
52
- ```typescript
53
- import { Sovant } from '@sovant/sdk';
54
-
55
- const client = new Sovant({ apiKey: process.env.SOVANT_API_KEY, baseUrl: 'https://sovant.ai' });
56
-
57
- // Create a chat session
58
- const session = await client.chat.createSession({ title: 'Demo' });
59
-
60
- // Stream a response
61
- const stream = await client.chat.sendMessage(session.id, {
62
- message: 'hello',
63
- provider: 'openai',
64
- model: 'gpt-4o-mini',
65
- stream: true,
66
- useMemory: true,
67
- });
68
-
69
- for await (const ev of stream) {
70
- if (ev.type === 'delta') process.stdout.write(ev.data || '');
71
- }
72
-
73
- // Get chat history
74
- const messages = await client.chat.getMessages(session.id);
75
- ```
76
-
77
- ## Profile Recall Helpers
78
-
79
- Save and recall user profile facts with canonical patterns:
80
-
81
- ```typescript
82
- // Extract profile entity from text
83
- const fact = await client.recall.extractProfile("i'm from kuching");
84
- // -> { entity: 'location', value: 'kuching' } | null
85
-
86
- if (fact) {
87
- await client.recall.saveProfileFact(fact); // canonicalizes and persists
88
- }
89
-
90
- // Get all profile facts
91
- const profile = await client.recall.getProfileFacts();
92
- // -> { name?: string, age?: string|number, location?: string, preferences?: string[] }
93
- ```
94
-
95
- ## Configuration
96
-
97
- ```typescript
98
- const sovant = new Sovant({
99
- apiKey: 'sk_live_your_api_key_here', // Required
100
- baseUrl: 'https://sovant.ai', // Optional, API endpoint
101
- timeout: 30000, // Optional, request timeout in ms (default: 30000)
102
- maxRetries: 3, // Optional, max retry attempts (default: 3)
103
- debug: false, // Optional, enable debug logging (default: false)
104
- });
105
- ```
106
-
107
- ## API Reference
108
-
109
- ### Memory Operations
110
-
111
- #### Create Memory
112
-
113
- ```typescript
114
- const memory = await sovant.memory.create({
115
- content: 'Customer contacted support about billing',
116
- type: 'observation', // 'journal' | 'insight' | 'observation' | 'task' | 'preference'
117
- tags: ['support', 'billing'],
118
- metadata: { ticketId: '12345' },
119
- thread_id: 'thread_abc123', // Optional thread association
120
- importance_score: 0.8, // 0-1 importance rating
121
- emotional_tone: 'frustrated',
122
- source: 'zendesk',
123
- });
124
- ```
125
-
126
- #### List Memories
127
-
128
- ```typescript
129
- const list = await sovant.memory.list({
130
- limit: 20, // Max items per page (default: 20)
131
- offset: 0, // Pagination offset
132
- tags: ['billing'], // Filter by tags
133
- type: 'observation', // Filter by type
134
- is_archived: false, // Filter archived status
135
- });
136
-
137
- console.log(list.memories); // Array of memories
138
- console.log(list.total); // Total count
139
- console.log(list.has_more); // More pages available
140
- ```
141
-
142
- #### Get Memory by ID
143
-
144
- ```typescript
145
- const memory = await sovant.memory.get('mem_123abc');
146
- ```
147
-
148
- #### Update Memory (Partial)
149
-
150
- ```typescript
151
- const updated = await sovant.memory.update('mem_123abc', {
152
- tags: ['support', 'billing', 'resolved'],
153
- metadata: {
154
- ...memory.metadata,
155
- resolved: true,
156
- },
157
- is_archived: true,
158
- });
159
- ```
160
-
161
- #### Replace Memory (Full)
162
-
163
- ```typescript
164
- const replaced = await sovant.memory.put('mem_123abc', {
165
- content: 'Updated content here', // Required for PUT
166
- type: 'observation',
167
- tags: ['updated'],
168
- });
169
- ```
170
-
171
- #### Delete Memory
172
-
173
- ```typescript
174
- await sovant.memory.delete('mem_123abc');
175
- ```
176
-
177
- #### Search Memories
178
-
179
- ```typescript
180
- // Semantic search
181
- const semanticResults = await sovant.memory.search({
182
- query: 'customer preferences about notifications',
183
- limit: 10,
184
- type: 'preference',
47
+ const results = await sv.memory.search({
48
+ query: "meeting preferences",
49
+ topK: 3
185
50
  });
186
51
 
187
- // Filter-based search
188
- const filterResults = await sovant.memory.search({
189
- tags: ['settings', 'notifications'],
190
- from_date: '2024-01-01',
191
- to_date: '2024-12-31',
192
- emotional_tone: 'positive',
193
- limit: 20,
194
- });
195
- ```
196
-
197
- #### Batch Operations
198
-
199
- ```typescript
200
- const batch = await sovant.memory.batch({
201
- operations: [
202
- {
203
- op: 'create',
204
- data: {
205
- content: 'First memory',
206
- type: 'journal',
207
- },
208
- },
209
- {
210
- op: 'update',
211
- id: 'mem_123abc',
212
- data: {
213
- tags: ['updated'],
214
- },
215
- },
216
- {
217
- op: 'delete',
218
- id: 'mem_456def',
219
- },
220
- ],
221
- });
222
-
223
- console.log(batch.ok); // All operations succeeded
224
- console.log(batch.results); // Individual operation results
225
- console.log(batch.summary); // Summary statistics
226
- ```
227
-
228
- ## Memory Types
229
-
230
- - **journal** - Chronological entries and logs
231
- - **insight** - Derived patterns and conclusions
232
- - **observation** - Factual, observed information
233
- - **task** - Action items and todos
234
- - **preference** - User preferences and settings
235
-
236
- ## Error Handling
237
-
238
- The SDK provides typed errors for better error handling:
239
-
240
- ```typescript
241
- import { Sovant, SovantError, NetworkError, TimeoutError } from '@sovant/sdk';
242
-
243
- try {
244
- const memory = await sovant.memory.get('invalid_id');
245
- } catch (error) {
246
- if (error instanceof SovantError) {
247
- console.error('API Error:', error.message);
248
- console.error('Error Code:', error.code);
249
- console.error('Status:', error.status);
250
- console.error('Request ID:', error.requestId);
251
-
252
- switch (error.status) {
253
- case 401:
254
- // Handle authentication error
255
- break;
256
- case 404:
257
- // Handle not found
258
- break;
259
- case 429:
260
- // Handle rate limiting
261
- break;
262
- }
263
- } else if (error instanceof TimeoutError) {
264
- console.error('Request timed out');
265
- } else if (error instanceof NetworkError) {
266
- console.error('Network error:', error.message);
267
- }
268
- }
52
+ console.log(results);
269
53
  ```
270
54
 
271
- ## Thread Management
55
+ ## Features
272
56
 
273
- Associate memories with conversation threads:
57
+ - **Memory CRUD** create, retrieve, update, delete memories
58
+ - **Semantic Search** — query memories with filters and topK ranking
59
+ - **Threads** — link related memories via thread_id (REST API)
60
+ - **Batch Operations (Beta)** — atomic multi-operation support
61
+ - **Compliance-ready** — audit trails, PDPA/GDPR-friendly by design
62
+ - **SDKs** — official TypeScript and Python SDKs, with REST API reference
274
63
 
275
- ```typescript
276
- // Create memories within a thread
277
- const memory1 = await sovant.memory.create({
278
- content: 'User asked about pricing',
279
- thread_id: 'thread_conversation_123',
280
- });
64
+ ## SDKs and Documentation
281
65
 
282
- const memory2 = await sovant.memory.create({
283
- content: 'User selected enterprise plan',
284
- thread_id: 'thread_conversation_123',
285
- });
66
+ - [TypeScript SDK Documentation](https://sovant.ai/docs/sdk/typescript)
67
+ - [Python SDK on PyPI](https://pypi.org/project/sovant/)
68
+ - [REST API Reference](https://sovant.ai/docs/api)
69
+ - [Full Documentation](https://sovant.ai/docs)
286
70
 
287
- // List memories in a thread
288
- const threadMemories = await sovant.memory.list({
289
- thread_id: 'thread_conversation_123',
290
- });
291
- ```
292
-
293
- ## API Key Management
294
-
295
- Manage API keys programmatically:
296
-
297
- ```typescript
298
- // List all API keys
299
- const keys = await client.keys.list();
300
- console.log(keys); // Array of key objects
301
-
302
- // Create a new API key
303
- const newKey = await client.keys.create({ name: 'CI key' });
304
- console.log(newKey.key); // The actual secret key (only shown once!)
305
-
306
- // Update key metadata
307
- await client.keys.update(newKey.id, { name: 'Production key' });
308
-
309
- // Revoke a key
310
- await client.keys.revoke(newKey.id);
311
- ```
312
-
313
- ## Advanced Features
314
-
315
- ### Retry Configuration
316
-
317
- The SDK automatically retries failed requests with exponential backoff:
318
-
319
- ```typescript
320
- const sovant = new Sovant({
321
- apiKey: 'sk_live_...',
322
- maxRetries: 5, // Increase retry attempts
323
- timeout: 60000, // Increase timeout for slow connections
324
- });
325
- ```
71
+ ## API Overview
326
72
 
327
- ### Debug Mode
73
+ ### Endpoints Summary
74
+ - `POST /api/v1/memory` — Create memory
75
+ - `GET /api/v1/memory` — List memories
76
+ - `GET /api/v1/memories/{id}` — Get memory by ID
77
+ - `PATCH|PUT /api/v1/memories/{id}` — Update memory
78
+ - `DELETE /api/v1/memories/{id}` — Delete memory
79
+ - `GET /api/v1/memory/search` — Search memories
80
+ - `POST /api/v1/memory/batch` — Batch operations (Beta)
328
81
 
329
- Enable debug logging to see detailed request/response information:
330
-
331
- ```typescript
332
- const sovant = new Sovant({
333
- apiKey: 'sk_live_...',
334
- debug: true, // Enable debug output
335
- });
336
- ```
337
-
338
- ### Custom Base URL
339
-
340
- Connect to different environments:
341
-
342
- ```typescript
343
- const client = new Sovant({
344
- apiKey: 'sk_live_...',
345
- baseUrl: 'https://staging.sovant.ai',
346
- });
347
- ```
348
-
349
- ## TypeScript Support
350
-
351
- The SDK is written in TypeScript and provides full type definitions:
352
-
353
- ```typescript
354
- import type {
355
- Memory,
356
- MemoryType,
357
- CreateMemoryInput,
358
- SearchParams,
359
- SearchResults,
360
- BatchRequest,
361
- BatchResponse,
362
- } from '@sovant/sdk';
363
-
364
- // All types are fully typed
365
- const createInput: CreateMemoryInput = {
366
- content: 'Typed content',
367
- type: 'journal',
368
- tags: ['typed'],
369
- };
370
-
371
- const memory: Memory = await sovant.memory.create(createInput);
372
- ```
373
-
374
- ## Best Practices
375
-
376
- 1. **Use appropriate memory types** - Choose the correct type for your use case
377
- 2. **Add meaningful tags** - Tags improve searchability and organization
378
- 3. **Set importance scores** - Help prioritize critical memories
379
- 4. **Use threads** - Group related memories together
380
- 5. **Handle errors gracefully** - Implement proper error handling
381
- 6. **Batch operations** - Use batch API for multiple operations
382
- 7. **Archive don't delete** - Consider archiving instead of deleting
383
-
384
- ## Examples
385
-
386
- ### Customer Support Integration
387
-
388
- ```typescript
389
- // Track customer interaction
390
- const interaction = await sovant.memory.create({
391
- content: 'Customer reported slow dashboard loading',
392
- type: 'observation',
393
- thread_id: `ticket_${ticketId}`,
394
- tags: ['support', 'performance', 'dashboard'],
395
- metadata: {
396
- ticketId,
397
- customerId,
398
- priority: 'high',
399
- },
400
- emotional_tone: 'frustrated',
401
- source: 'zendesk',
402
- });
403
-
404
- // Record resolution
405
- const resolution = await sovant.memory.create({
406
- content: 'Resolved by clearing cache and upgrading plan',
407
- type: 'insight',
408
- thread_id: `ticket_${ticketId}`,
409
- tags: ['support', 'resolved'],
410
- metadata: {
411
- ticketId,
412
- resolutionTime: '2h',
413
- },
414
- });
415
- ```
416
-
417
- ### User Preference Tracking
418
-
419
- ```typescript
420
- // Store preference
421
- const preference = await sovant.memory.create({
422
- content: 'User prefers email notifications over SMS',
423
- type: 'preference',
424
- tags: ['notifications', 'email', 'settings'],
425
- metadata: {
426
- userId,
427
- setting: 'notification_channel',
428
- value: 'email',
429
- },
430
- importance_score: 0.9,
431
- });
432
-
433
- // Query preferences
434
- const preferences = await sovant.memory.search({
435
- type: 'preference',
436
- tags: ['notifications'],
437
- });
438
- ```
82
+ ## Field Mapping Note
439
83
 
440
- ## Rate Limiting
84
+ - **SDK level:** accepts `data`
85
+ - **API level:** expects `content`
86
+ - SDK automatically converts `data` → `content`.
87
+ - `subject` is deprecated (ignored by API). Use `thread_id`, `tags`, or `metadata` for grouping.
441
88
 
442
- The API implements rate limiting. The SDK automatically handles rate limit responses with retries. Rate limit headers are included in responses:
89
+ ## Status of Advanced Features
443
90
 
444
- - `X-RateLimit-Limit` - Request limit per window
445
- - `X-RateLimit-Remaining` - Remaining requests
446
- - `X-RateLimit-Reset` - Reset timestamp
91
+ - **Batch API:** Available, marked Beta.
92
+ - **Threads:** Fully supported via REST API.
93
+ - **Webhooks, personalization, multi-channel sync:** Coming soon.
447
94
 
448
- ## Support
95
+ ## Versioning & Changelog
449
96
 
450
- - Documentation: [https://docs.sovant.ai](https://docs.sovant.ai)
451
- - API Reference: [https://docs.sovant.ai/api](https://docs.sovant.ai/api)
452
- - Issues: [GitHub Issues](https://github.com/sovant-ai/javascript-sdk/issues)
453
- - Support: support@sovant.ai
97
+ - **Stable release:** 1.0.5
98
+ - Version 1.0.4 fixed critical API endpoint bugs
99
+ - Earlier builds (1.0.0-1.0.3) are deprecated
100
+ - See [CHANGELOG.md](./CHANGELOG.md) for details.
454
101
 
455
- ## Changelog
102
+ ## License & Use
456
103
 
457
- See [CHANGELOG.md](./CHANGELOG.md) for a detailed history of changes.
104
+ - This SDK is MIT-licensed for integration convenience.
105
+ - The Sovant API and platform are proprietary to Sovant Technologies Sdn. Bhd.
106
+ - You may use this SDK to integrate with Sovant's hosted API.
107
+ - Hosting/redistributing the Sovant backend or any proprietary components is not permitted.
458
108
 
459
109
  ## License
460
110
 
461
- MIT - See [LICENSE](LICENSE) file for details.
111
+ MIT © Sovant AI