@sovant/sdk 1.1.2 → 1.3.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,26 @@
1
- # Sovant JavaScript/TypeScript SDK
1
+ # @sovant/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
+ **Sovant is a governed AI memory layer for LLM applications.**
4
+ It gives your apps hybrid recall, profile-aware context, and a structured memory store you can audit, inspect, and control.
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
+ The official **JavaScript and TypeScript** SDK for the Sovant Memory API.
7
+
8
+ [![npm version](https://img.shields.io/npm/v/@sovant/sdk)](https://www.npmjs.com/package/@sovant/sdk)
9
+ [![Documentation](https://img.shields.io/badge/docs-sovant.ai-blue)](https://sovant.ai/docs)
10
+ [![GitHub](https://img.shields.io/badge/github-sovant-lightgrey)](https://github.com/sovant-ai/sovant)
11
+
12
+ ---
13
+
14
+ ## What is Sovant?
15
+
16
+ Sovant is an **AI infrastructure company** providing the **memory layer for AI systems**.
17
+ Our platform makes it simple to persist, search, and manage conversational and contextual data securely across sessions, channels, and applications.
18
+
19
+ - **Problem:** Most AI systems forget everything once a session ends. This causes compliance risks, knowledge loss, and poor user experience.
20
+ - **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.
21
+ - **Target audience:** Developers, startups, and enterprises building AI agents, copilots, or compliance-driven apps who need context persistence.
22
+
23
+ ---
7
24
 
8
25
  ## Installation
9
26
 
@@ -15,450 +32,143 @@ yarn add @sovant/sdk
15
32
  pnpm add @sovant/sdk
16
33
  ```
17
34
 
18
- ## Quick Start
35
+ ## 60-Second Quickstart
36
+
37
+ ### TypeScript
19
38
 
20
39
  ```typescript
21
- import { Sovant } from '@sovant/sdk';
40
+ import { Sovant } from "@sovant/sdk";
22
41
 
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
- });
42
+ const sv = new Sovant({ apiKey: process.env.SOVANT_API_KEY! });
28
43
 
29
44
  // Create a memory
30
- const memory = await sovant.memory.create({
31
- content: 'User prefers dark mode interfaces',
32
- type: 'preference',
33
- tags: ['ui', 'settings'],
45
+ await sv.memory.create({
46
+ data: { note: "User prefers morning meetings" },
47
+ type: "preference"
34
48
  });
35
49
 
36
50
  // 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'],
45
- });
46
-
47
- // Delete a memory
48
- await sovant.memory.delete(memory.id);
49
- ```
50
-
51
- ## Chat in 60 Seconds
52
-
53
- Stream real-time chat responses with memory context:
54
-
55
- ```typescript
56
- import { Sovant } from '@sovant/sdk';
57
-
58
- const client = new Sovant({ apiKey: process.env.SOVANT_API_KEY, baseUrl: 'https://sovant.ai' });
59
-
60
- // Create a chat session
61
- const session = await client.chat.createSession({ title: 'Demo' });
62
-
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
- });
71
-
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
88
-
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'],
51
+ const results = await sv.memory.search({
52
+ query: "meeting preferences",
53
+ limit: 3
171
54
  });
172
- ```
173
-
174
- #### Delete Memory
175
55
 
176
- ```typescript
177
- await sovant.memory.delete('mem_123abc');
56
+ console.log(results);
178
57
  ```
179
58
 
180
- #### Search Memories
59
+ ### JavaScript (ESM)
181
60
 
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
- ```
61
+ ```javascript
62
+ import { Sovant } from "@sovant/sdk";
199
63
 
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
- });
64
+ const sv = new Sovant({ apiKey: process.env.SOVANT_API_KEY });
225
65
 
226
- console.log(batch.ok); // All operations succeeded
227
- console.log(batch.results); // Individual operation results
228
- console.log(batch.summary); // Summary statistics
229
- ```
230
-
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',
66
+ // Create a memory
67
+ await sv.memory.create({
68
+ data: "User prefers morning meetings",
69
+ type: "preference"
283
70
  });
284
71
 
285
- const memory2 = await sovant.memory.create({
286
- content: 'User selected enterprise plan',
287
- thread_id: 'thread_conversation_123',
72
+ // Search memories
73
+ const results = await sv.memory.search({
74
+ query: "meeting preferences",
75
+ limit: 3
288
76
  });
289
77
 
290
- // List memories in a thread
291
- const threadMemories = await sovant.memory.list({
292
- thread_id: 'thread_conversation_123',
293
- });
78
+ console.log(results);
294
79
  ```
295
80
 
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
81
+ ### JavaScript (CommonJS)
304
82
 
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!)
83
+ ```javascript
84
+ const { Sovant } = require("@sovant/sdk");
308
85
 
309
- // Update key metadata
310
- await client.keys.update(newKey.id, { name: 'Production key' });
86
+ const sv = new Sovant({ apiKey: process.env.SOVANT_API_KEY });
311
87
 
312
- // Revoke a key
313
- await client.keys.revoke(newKey.id);
88
+ // Works the same as ESM
89
+ sv.memory.create({ data: "User likes coffee", type: "preference" })
90
+ .then(() => console.log("Memory saved!"));
314
91
  ```
315
92
 
316
- ## Advanced Features
93
+ ## Recall vs Search
317
94
 
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
- ```
95
+ Sovant provides two ways to query memories:
329
96
 
330
- ### Debug Mode
97
+ - **`memory.recall()`** – Hybrid recall, profile-aware
98
+ Best for conversational AI queries like "What do you know about me?" or "What happened on Project X?".
99
+ Uses Sovant's hybrid pipeline (profile fast-path + thread-scoped lexical + vector semantic search) and prioritizes profile facts (name/age/location) when available.
331
100
 
332
- Enable debug logging to see detailed request/response information:
101
+ - **`memory.search()`** Semantic search
102
+ Best for topic-based lookup and discovery, e.g., "hiking", "Q1 marketing plan".
103
+ Pure vector similarity search without profile logic. Behavior unchanged from previous versions.
333
104
 
334
105
  ```typescript
335
- const sovant = new Sovant({
336
- apiKey: 'sk_live_...',
337
- debug: true, // Enable debug output
106
+ // Recall for conversational queries
107
+ const context = await sv.memory.recall({
108
+ query: "what do you know about me?",
109
+ limit: 10
338
110
  });
339
- ```
340
-
341
- ### Custom Base URL
342
111
 
343
- Connect to different environments:
344
-
345
- ```typescript
346
- const client = new Sovant({
347
- apiKey: 'sk_live_...',
348
- baseUrl: 'https://staging.sovant.ai',
112
+ // Search for topic discovery
113
+ const topics = await sv.memory.search({
114
+ query: "project updates",
115
+ limit: 5
349
116
  });
350
117
  ```
351
118
 
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
119
+ ## Features
378
120
 
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
121
+ - **Memory CRUD** create, retrieve, update, delete memories
122
+ - **Semantic Search** query memories with filters and topK ranking
123
+ - **Threads** link related memories via thread_id (REST API)
124
+ - **Batch Operations (Beta)** atomic multi-operation support
125
+ - **Compliance-ready** audit trails, PDPA/GDPR-friendly by design
126
+ - **SDKs** official TypeScript and Python SDKs, with REST API reference
386
127
 
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
- });
128
+ ## SDKs and Documentation
406
129
 
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
- ```
130
+ - [TypeScript SDK Documentation](https://sovant.ai/docs/sdk/typescript)
131
+ - [Python SDK on PyPI](https://pypi.org/project/sovant/)
132
+ - [REST API Reference](https://sovant.ai/docs/api)
133
+ - [Full Documentation](https://sovant.ai/docs)
419
134
 
420
- ### User Preference Tracking
135
+ ## API Overview
421
136
 
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
- });
137
+ ### Endpoints Summary
138
+ - `POST /api/v1/memory` — Create memory
139
+ - `GET /api/v1/memory` List memories
140
+ - `GET /api/v1/memories/{id}` Get memory by ID
141
+ - `PATCH|PUT /api/v1/memories/{id}` — Update memory
142
+ - `DELETE /api/v1/memories/{id}` — Delete memory
143
+ - `GET /api/v1/memory/search` — Search memories
144
+ - `POST /api/v1/memory/batch` — Batch operations (Beta)
435
145
 
436
- // Query preferences
437
- const preferences = await sovant.memory.search({
438
- type: 'preference',
439
- tags: ['notifications'],
440
- });
441
- ```
146
+ ## Field Mapping Note
442
147
 
443
- ## Rate Limiting
148
+ - **SDK level:** accepts `data`
149
+ - **API level:** expects `content`
150
+ - SDK automatically converts `data` → `content`.
151
+ - `subject` is deprecated (ignored by API). Use `thread_id`, `tags`, or `metadata` for grouping.
444
152
 
445
- The API implements rate limiting. The SDK automatically handles rate limit responses with retries. Rate limit headers are included in responses:
153
+ ## Status of Advanced Features
446
154
 
447
- - `X-RateLimit-Limit` - Request limit per window
448
- - `X-RateLimit-Remaining` - Remaining requests
449
- - `X-RateLimit-Reset` - Reset timestamp
155
+ - **Batch API:** Available, marked Beta.
156
+ - **Threads:** Fully supported via REST API.
157
+ - **Webhooks, personalization, multi-channel sync:** Coming soon.
450
158
 
451
- ## Support
159
+ ## Versioning & Changelog
452
160
 
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
161
+ - **Current release:** 1.3.0
162
+ - Version 1.3.0 adds hybrid recall with profile awareness
163
+ - See [CHANGELOG.md](./CHANGELOG.md) for details.
457
164
 
458
- ## Changelog
165
+ ## License & Use
459
166
 
460
- See [CHANGELOG.md](./CHANGELOG.md) for a detailed history of changes.
167
+ - This SDK is MIT-licensed for integration convenience.
168
+ - The Sovant API and platform are proprietary to Sovant Technologies Sdn. Bhd.
169
+ - You may use this SDK to integrate with Sovant's hosted API.
170
+ - Hosting/redistributing the Sovant backend or any proprietary components is not permitted.
461
171
 
462
172
  ## License
463
173
 
464
- MIT - See [LICENSE](LICENSE) file for details.
174
+ MIT © Sovant AI