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