@usewhisper/sdk 2.0.0 → 2.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/README.md +2 -2
- package/index.d.mts +204 -11
- package/index.d.ts +204 -11
- package/index.js +277 -16
- package/index.mjs +273 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ npm install @usewhisper/sdk
|
|
|
14
14
|
import { WhisperContext } from '@usewhisper/sdk';
|
|
15
15
|
|
|
16
16
|
const whisper = new WhisperContext({
|
|
17
|
-
apiKey: '
|
|
17
|
+
apiKey: 'wsk_your_api_key_here'
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
// Create a project
|
|
@@ -48,7 +48,7 @@ Get your API key from the [Whisper dashboard](https://usewhisper.dev/dashboard):
|
|
|
48
48
|
|
|
49
49
|
```typescript
|
|
50
50
|
const whisper = new WhisperContext({
|
|
51
|
-
apiKey: '
|
|
51
|
+
apiKey: 'wsk_...', // Your API key
|
|
52
52
|
baseUrl: 'https://context.usewhisper.dev' // Optional, defaults to production
|
|
53
53
|
});
|
|
54
54
|
```
|
package/index.d.mts
CHANGED
|
@@ -24,12 +24,33 @@ interface WhisperOptions extends WhisperConfig {
|
|
|
24
24
|
* Default: "Relevant context:"
|
|
25
25
|
*/
|
|
26
26
|
contextPrefix?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Extract structured memories before writing.
|
|
29
|
+
* Default: true
|
|
30
|
+
*/
|
|
31
|
+
autoExtract?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Minimum extraction confidence for auto-write.
|
|
34
|
+
* Default: 0.65
|
|
35
|
+
*/
|
|
36
|
+
autoExtractMinConfidence?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Maximum extracted memories to write per remember/capture call.
|
|
39
|
+
* Default: 5
|
|
40
|
+
*/
|
|
41
|
+
maxMemoriesPerCapture?: number;
|
|
27
42
|
}
|
|
28
43
|
interface ContextResult {
|
|
29
44
|
context: string;
|
|
30
45
|
results: QueryResult["results"];
|
|
31
46
|
count: number;
|
|
32
47
|
}
|
|
48
|
+
interface RememberResult {
|
|
49
|
+
success: boolean;
|
|
50
|
+
memoryId?: string;
|
|
51
|
+
memoryIds?: string[];
|
|
52
|
+
extracted?: number;
|
|
53
|
+
}
|
|
33
54
|
/**
|
|
34
55
|
* Simple, transparent memory layer
|
|
35
56
|
*
|
|
@@ -114,10 +135,7 @@ declare class Whisper {
|
|
|
114
135
|
userId?: string;
|
|
115
136
|
sessionId?: string;
|
|
116
137
|
project?: string;
|
|
117
|
-
}): Promise<
|
|
118
|
-
success: boolean;
|
|
119
|
-
memoryId?: string;
|
|
120
|
-
}>;
|
|
138
|
+
}): Promise<RememberResult>;
|
|
121
139
|
/**
|
|
122
140
|
* Alias for remember() - same thing
|
|
123
141
|
*/
|
|
@@ -125,10 +143,7 @@ declare class Whisper {
|
|
|
125
143
|
userId?: string;
|
|
126
144
|
sessionId?: string;
|
|
127
145
|
project?: string;
|
|
128
|
-
}): Promise<
|
|
129
|
-
success: boolean;
|
|
130
|
-
memoryId?: string;
|
|
131
|
-
}>;
|
|
146
|
+
}): Promise<RememberResult>;
|
|
132
147
|
/**
|
|
133
148
|
* Capture from multiple messages (e.g., full conversation)
|
|
134
149
|
*/
|
|
@@ -143,11 +158,106 @@ declare class Whisper {
|
|
|
143
158
|
success: boolean;
|
|
144
159
|
extracted: number;
|
|
145
160
|
}>;
|
|
161
|
+
/**
|
|
162
|
+
* Run a full agent turn with automatic memory read (before) + write (after).
|
|
163
|
+
*/
|
|
164
|
+
runTurn(params: {
|
|
165
|
+
userMessage: string;
|
|
166
|
+
generate: (prompt: string) => Promise<string>;
|
|
167
|
+
userId?: string;
|
|
168
|
+
sessionId?: string;
|
|
169
|
+
project?: string;
|
|
170
|
+
limit?: number;
|
|
171
|
+
}): Promise<{
|
|
172
|
+
response: string;
|
|
173
|
+
context: string;
|
|
174
|
+
count: number;
|
|
175
|
+
extracted: number;
|
|
176
|
+
}>;
|
|
146
177
|
/**
|
|
147
178
|
* Direct access to WhisperContext for advanced usage
|
|
148
179
|
*/
|
|
149
180
|
raw(): WhisperContext;
|
|
181
|
+
private extractMemoryIdsFromBulkResponse;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
interface AgentMiddlewareConfig extends WhisperOptions {
|
|
185
|
+
/**
|
|
186
|
+
* Build the prompt passed to the model.
|
|
187
|
+
*/
|
|
188
|
+
promptBuilder?: (params: {
|
|
189
|
+
context: string;
|
|
190
|
+
userMessage: string;
|
|
191
|
+
}) => string;
|
|
192
|
+
}
|
|
193
|
+
interface AgentTurnParams {
|
|
194
|
+
userMessage: string;
|
|
195
|
+
userId?: string;
|
|
196
|
+
sessionId?: string;
|
|
197
|
+
project?: string;
|
|
198
|
+
contextLimit?: number;
|
|
199
|
+
}
|
|
200
|
+
interface AgentTurnResult {
|
|
201
|
+
prompt: string;
|
|
202
|
+
context: string;
|
|
203
|
+
contextCount: number;
|
|
204
|
+
}
|
|
205
|
+
interface WrappedGenerateResult {
|
|
206
|
+
response: string;
|
|
207
|
+
prompt: string;
|
|
208
|
+
context: string;
|
|
209
|
+
contextCount: number;
|
|
210
|
+
extracted: number;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Drop-in middleware for existing AI agents.
|
|
214
|
+
*
|
|
215
|
+
* Typical flow:
|
|
216
|
+
* 1) beforeTurn -> retrieve context
|
|
217
|
+
* 2) call your model
|
|
218
|
+
* 3) afterTurn -> store memories
|
|
219
|
+
*/
|
|
220
|
+
declare class WhisperAgentMiddleware {
|
|
221
|
+
private readonly whisper;
|
|
222
|
+
private readonly promptBuilder;
|
|
223
|
+
constructor(config: AgentMiddlewareConfig);
|
|
224
|
+
beforeTurn(params: AgentTurnParams): Promise<AgentTurnResult>;
|
|
225
|
+
afterTurn(params: {
|
|
226
|
+
userMessage: string;
|
|
227
|
+
assistantMessage: string;
|
|
228
|
+
userId?: string;
|
|
229
|
+
sessionId?: string;
|
|
230
|
+
project?: string;
|
|
231
|
+
}): Promise<{
|
|
232
|
+
success: boolean;
|
|
233
|
+
extracted: number;
|
|
234
|
+
}>;
|
|
235
|
+
wrapGenerate(params: AgentTurnParams & {
|
|
236
|
+
generate: (prompt: string) => Promise<string>;
|
|
237
|
+
}): Promise<WrappedGenerateResult>;
|
|
238
|
+
raw(): Whisper;
|
|
150
239
|
}
|
|
240
|
+
declare function createAgentMiddleware(config: AgentMiddlewareConfig): WhisperAgentMiddleware;
|
|
241
|
+
|
|
242
|
+
interface MemoryGraphNode {
|
|
243
|
+
id: string;
|
|
244
|
+
label?: string;
|
|
245
|
+
memory_type?: string;
|
|
246
|
+
}
|
|
247
|
+
interface MemoryGraphEdge {
|
|
248
|
+
source: string;
|
|
249
|
+
target: string;
|
|
250
|
+
type?: string;
|
|
251
|
+
}
|
|
252
|
+
interface MemoryGraphPayload {
|
|
253
|
+
nodes: MemoryGraphNode[];
|
|
254
|
+
edges: MemoryGraphEdge[];
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Convert memory graph payload to Mermaid flowchart syntax.
|
|
258
|
+
* Useful for quick visualization in docs/dashboards.
|
|
259
|
+
*/
|
|
260
|
+
declare function memoryGraphToMermaid(graph: MemoryGraphPayload): string;
|
|
151
261
|
|
|
152
262
|
/**
|
|
153
263
|
* Whisper Context SDK
|
|
@@ -157,7 +267,6 @@ interface WhisperConfig {
|
|
|
157
267
|
apiKey: string;
|
|
158
268
|
baseUrl?: string;
|
|
159
269
|
project?: string;
|
|
160
|
-
orgId?: string;
|
|
161
270
|
timeoutMs?: number;
|
|
162
271
|
retry?: {
|
|
163
272
|
maxAttempts?: number;
|
|
@@ -246,6 +355,23 @@ interface Memory {
|
|
|
246
355
|
createdAt: string;
|
|
247
356
|
updatedAt: string;
|
|
248
357
|
}
|
|
358
|
+
type MemoryKind = "factual" | "preference" | "event" | "relationship" | "opinion" | "goal" | "instruction";
|
|
359
|
+
interface ExtractedMemory {
|
|
360
|
+
content: string;
|
|
361
|
+
memoryType: MemoryKind;
|
|
362
|
+
entityMentions: string[];
|
|
363
|
+
eventDate: string | null;
|
|
364
|
+
confidence: number;
|
|
365
|
+
reasoning?: string;
|
|
366
|
+
inferred?: boolean;
|
|
367
|
+
}
|
|
368
|
+
interface MemoryExtractionResult {
|
|
369
|
+
explicit: ExtractedMemory[];
|
|
370
|
+
implicit: ExtractedMemory[];
|
|
371
|
+
all: ExtractedMemory[];
|
|
372
|
+
extractionMethod: "pattern" | "inference" | "hybrid" | "skipped";
|
|
373
|
+
latencyMs: number;
|
|
374
|
+
}
|
|
249
375
|
type WhisperErrorCode = "INVALID_API_KEY" | "PROJECT_NOT_FOUND" | "PROJECT_AMBIGUOUS" | "RATE_LIMITED" | "TEMPORARY_UNAVAILABLE" | "NETWORK_ERROR" | "TIMEOUT" | "REQUEST_FAILED" | "MISSING_PROJECT";
|
|
250
376
|
declare class WhisperError extends Error {
|
|
251
377
|
code: WhisperErrorCode;
|
|
@@ -264,7 +390,6 @@ declare class WhisperContext {
|
|
|
264
390
|
private apiKey;
|
|
265
391
|
private baseUrl;
|
|
266
392
|
private defaultProject?;
|
|
267
|
-
private orgId?;
|
|
268
393
|
private timeoutMs;
|
|
269
394
|
private retryConfig;
|
|
270
395
|
private projectRefToId;
|
|
@@ -335,6 +460,51 @@ declare class WhisperContext {
|
|
|
335
460
|
path: "sota" | "legacy";
|
|
336
461
|
fallback_used: boolean;
|
|
337
462
|
}>;
|
|
463
|
+
addMemoriesBulk(params: {
|
|
464
|
+
project?: string;
|
|
465
|
+
memories: Array<{
|
|
466
|
+
content: string;
|
|
467
|
+
memory_type?: MemoryKind | "episodic" | "semantic" | "procedural";
|
|
468
|
+
user_id?: string;
|
|
469
|
+
session_id?: string;
|
|
470
|
+
agent_id?: string;
|
|
471
|
+
importance?: number;
|
|
472
|
+
confidence?: number;
|
|
473
|
+
metadata?: Record<string, any>;
|
|
474
|
+
entity_mentions?: string[];
|
|
475
|
+
document_date?: string;
|
|
476
|
+
event_date?: string;
|
|
477
|
+
}>;
|
|
478
|
+
namespace?: string;
|
|
479
|
+
tags?: string[];
|
|
480
|
+
async?: boolean;
|
|
481
|
+
webhook_url?: string;
|
|
482
|
+
}): Promise<any>;
|
|
483
|
+
extractMemories(params: {
|
|
484
|
+
project?: string;
|
|
485
|
+
message: string;
|
|
486
|
+
context?: string;
|
|
487
|
+
session_id?: string;
|
|
488
|
+
user_id?: string;
|
|
489
|
+
enable_pattern?: boolean;
|
|
490
|
+
enable_inference?: boolean;
|
|
491
|
+
min_confidence?: number;
|
|
492
|
+
}): Promise<MemoryExtractionResult>;
|
|
493
|
+
extractSessionMemories(params: {
|
|
494
|
+
project?: string;
|
|
495
|
+
user_id?: string;
|
|
496
|
+
messages: Array<{
|
|
497
|
+
role: "user" | "assistant" | "system";
|
|
498
|
+
content: string;
|
|
499
|
+
timestamp?: string;
|
|
500
|
+
}>;
|
|
501
|
+
enable_pattern?: boolean;
|
|
502
|
+
enable_inference?: boolean;
|
|
503
|
+
}): Promise<{
|
|
504
|
+
memories: ExtractedMemory[];
|
|
505
|
+
count: number;
|
|
506
|
+
latencyMs: number;
|
|
507
|
+
}>;
|
|
338
508
|
searchMemories(params: {
|
|
339
509
|
project?: string;
|
|
340
510
|
query: string;
|
|
@@ -369,6 +539,7 @@ declare class WhisperContext {
|
|
|
369
539
|
include_inactive?: boolean;
|
|
370
540
|
include_chunks?: boolean;
|
|
371
541
|
include_relations?: boolean;
|
|
542
|
+
fast_mode?: boolean;
|
|
372
543
|
}): Promise<any>;
|
|
373
544
|
ingestSession(params: {
|
|
374
545
|
project?: string;
|
|
@@ -426,6 +597,19 @@ declare class WhisperContext {
|
|
|
426
597
|
relations: any[];
|
|
427
598
|
count: number;
|
|
428
599
|
}>;
|
|
600
|
+
getMemoryGraph(params: {
|
|
601
|
+
project?: string;
|
|
602
|
+
user_id?: string;
|
|
603
|
+
session_id?: string;
|
|
604
|
+
include_inactive?: boolean;
|
|
605
|
+
limit?: number;
|
|
606
|
+
}): Promise<any>;
|
|
607
|
+
getConversationGraph(params: {
|
|
608
|
+
project?: string;
|
|
609
|
+
session_id: string;
|
|
610
|
+
include_inactive?: boolean;
|
|
611
|
+
limit?: number;
|
|
612
|
+
}): Promise<any>;
|
|
429
613
|
oracleSearch(params: {
|
|
430
614
|
query: string;
|
|
431
615
|
project?: string;
|
|
@@ -641,6 +825,13 @@ declare class WhisperContext {
|
|
|
641
825
|
path: "sota" | "legacy";
|
|
642
826
|
fallback_used: boolean;
|
|
643
827
|
}>;
|
|
828
|
+
addBulk: (params: Parameters<WhisperContext["addMemoriesBulk"]>[0]) => Promise<any>;
|
|
829
|
+
extract: (params: Parameters<WhisperContext["extractMemories"]>[0]) => Promise<MemoryExtractionResult>;
|
|
830
|
+
extractSession: (params: Parameters<WhisperContext["extractSessionMemories"]>[0]) => Promise<{
|
|
831
|
+
memories: ExtractedMemory[];
|
|
832
|
+
count: number;
|
|
833
|
+
latencyMs: number;
|
|
834
|
+
}>;
|
|
644
835
|
search: (params: Parameters<WhisperContext["searchMemories"]>[0]) => Promise<any>;
|
|
645
836
|
searchSOTA: (params: Parameters<WhisperContext["searchMemoriesSOTA"]>[0]) => Promise<any>;
|
|
646
837
|
ingestSession: (params: Parameters<WhisperContext["ingestSession"]>[0]) => Promise<{
|
|
@@ -678,6 +869,8 @@ declare class WhisperContext {
|
|
|
678
869
|
relations: any[];
|
|
679
870
|
count: number;
|
|
680
871
|
}>;
|
|
872
|
+
getGraph: (params: Parameters<WhisperContext["getMemoryGraph"]>[0]) => Promise<any>;
|
|
873
|
+
getConversationGraph: (params: Parameters<WhisperContext["getConversationGraph"]>[0]) => Promise<any>;
|
|
681
874
|
consolidate: (params: Parameters<WhisperContext["consolidateMemories"]>[0]) => Promise<any>;
|
|
682
875
|
updateDecay: (params: Parameters<WhisperContext["updateImportanceDecay"]>[0]) => Promise<{
|
|
683
876
|
success: boolean;
|
|
@@ -762,4 +955,4 @@ declare class WhisperContext {
|
|
|
762
955
|
};
|
|
763
956
|
}
|
|
764
957
|
|
|
765
|
-
export { type Memory, type Project, type QueryParams, type QueryResult, type Source, Whisper, type WhisperConfig, WhisperContext, Whisper as WhisperDefault, WhisperError, type WhisperErrorCode, WhisperContext as default };
|
|
958
|
+
export { type ExtractedMemory, type Memory, type MemoryExtractionResult, type MemoryKind, type Project, type QueryParams, type QueryResult, type Source, Whisper, WhisperAgentMiddleware, type WhisperConfig, WhisperContext, Whisper as WhisperDefault, WhisperError, type WhisperErrorCode, createAgentMiddleware, WhisperContext as default, memoryGraphToMermaid };
|
package/index.d.ts
CHANGED
|
@@ -24,12 +24,33 @@ interface WhisperOptions extends WhisperConfig {
|
|
|
24
24
|
* Default: "Relevant context:"
|
|
25
25
|
*/
|
|
26
26
|
contextPrefix?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Extract structured memories before writing.
|
|
29
|
+
* Default: true
|
|
30
|
+
*/
|
|
31
|
+
autoExtract?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Minimum extraction confidence for auto-write.
|
|
34
|
+
* Default: 0.65
|
|
35
|
+
*/
|
|
36
|
+
autoExtractMinConfidence?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Maximum extracted memories to write per remember/capture call.
|
|
39
|
+
* Default: 5
|
|
40
|
+
*/
|
|
41
|
+
maxMemoriesPerCapture?: number;
|
|
27
42
|
}
|
|
28
43
|
interface ContextResult {
|
|
29
44
|
context: string;
|
|
30
45
|
results: QueryResult["results"];
|
|
31
46
|
count: number;
|
|
32
47
|
}
|
|
48
|
+
interface RememberResult {
|
|
49
|
+
success: boolean;
|
|
50
|
+
memoryId?: string;
|
|
51
|
+
memoryIds?: string[];
|
|
52
|
+
extracted?: number;
|
|
53
|
+
}
|
|
33
54
|
/**
|
|
34
55
|
* Simple, transparent memory layer
|
|
35
56
|
*
|
|
@@ -114,10 +135,7 @@ declare class Whisper {
|
|
|
114
135
|
userId?: string;
|
|
115
136
|
sessionId?: string;
|
|
116
137
|
project?: string;
|
|
117
|
-
}): Promise<
|
|
118
|
-
success: boolean;
|
|
119
|
-
memoryId?: string;
|
|
120
|
-
}>;
|
|
138
|
+
}): Promise<RememberResult>;
|
|
121
139
|
/**
|
|
122
140
|
* Alias for remember() - same thing
|
|
123
141
|
*/
|
|
@@ -125,10 +143,7 @@ declare class Whisper {
|
|
|
125
143
|
userId?: string;
|
|
126
144
|
sessionId?: string;
|
|
127
145
|
project?: string;
|
|
128
|
-
}): Promise<
|
|
129
|
-
success: boolean;
|
|
130
|
-
memoryId?: string;
|
|
131
|
-
}>;
|
|
146
|
+
}): Promise<RememberResult>;
|
|
132
147
|
/**
|
|
133
148
|
* Capture from multiple messages (e.g., full conversation)
|
|
134
149
|
*/
|
|
@@ -143,11 +158,106 @@ declare class Whisper {
|
|
|
143
158
|
success: boolean;
|
|
144
159
|
extracted: number;
|
|
145
160
|
}>;
|
|
161
|
+
/**
|
|
162
|
+
* Run a full agent turn with automatic memory read (before) + write (after).
|
|
163
|
+
*/
|
|
164
|
+
runTurn(params: {
|
|
165
|
+
userMessage: string;
|
|
166
|
+
generate: (prompt: string) => Promise<string>;
|
|
167
|
+
userId?: string;
|
|
168
|
+
sessionId?: string;
|
|
169
|
+
project?: string;
|
|
170
|
+
limit?: number;
|
|
171
|
+
}): Promise<{
|
|
172
|
+
response: string;
|
|
173
|
+
context: string;
|
|
174
|
+
count: number;
|
|
175
|
+
extracted: number;
|
|
176
|
+
}>;
|
|
146
177
|
/**
|
|
147
178
|
* Direct access to WhisperContext for advanced usage
|
|
148
179
|
*/
|
|
149
180
|
raw(): WhisperContext;
|
|
181
|
+
private extractMemoryIdsFromBulkResponse;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
interface AgentMiddlewareConfig extends WhisperOptions {
|
|
185
|
+
/**
|
|
186
|
+
* Build the prompt passed to the model.
|
|
187
|
+
*/
|
|
188
|
+
promptBuilder?: (params: {
|
|
189
|
+
context: string;
|
|
190
|
+
userMessage: string;
|
|
191
|
+
}) => string;
|
|
192
|
+
}
|
|
193
|
+
interface AgentTurnParams {
|
|
194
|
+
userMessage: string;
|
|
195
|
+
userId?: string;
|
|
196
|
+
sessionId?: string;
|
|
197
|
+
project?: string;
|
|
198
|
+
contextLimit?: number;
|
|
199
|
+
}
|
|
200
|
+
interface AgentTurnResult {
|
|
201
|
+
prompt: string;
|
|
202
|
+
context: string;
|
|
203
|
+
contextCount: number;
|
|
204
|
+
}
|
|
205
|
+
interface WrappedGenerateResult {
|
|
206
|
+
response: string;
|
|
207
|
+
prompt: string;
|
|
208
|
+
context: string;
|
|
209
|
+
contextCount: number;
|
|
210
|
+
extracted: number;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Drop-in middleware for existing AI agents.
|
|
214
|
+
*
|
|
215
|
+
* Typical flow:
|
|
216
|
+
* 1) beforeTurn -> retrieve context
|
|
217
|
+
* 2) call your model
|
|
218
|
+
* 3) afterTurn -> store memories
|
|
219
|
+
*/
|
|
220
|
+
declare class WhisperAgentMiddleware {
|
|
221
|
+
private readonly whisper;
|
|
222
|
+
private readonly promptBuilder;
|
|
223
|
+
constructor(config: AgentMiddlewareConfig);
|
|
224
|
+
beforeTurn(params: AgentTurnParams): Promise<AgentTurnResult>;
|
|
225
|
+
afterTurn(params: {
|
|
226
|
+
userMessage: string;
|
|
227
|
+
assistantMessage: string;
|
|
228
|
+
userId?: string;
|
|
229
|
+
sessionId?: string;
|
|
230
|
+
project?: string;
|
|
231
|
+
}): Promise<{
|
|
232
|
+
success: boolean;
|
|
233
|
+
extracted: number;
|
|
234
|
+
}>;
|
|
235
|
+
wrapGenerate(params: AgentTurnParams & {
|
|
236
|
+
generate: (prompt: string) => Promise<string>;
|
|
237
|
+
}): Promise<WrappedGenerateResult>;
|
|
238
|
+
raw(): Whisper;
|
|
150
239
|
}
|
|
240
|
+
declare function createAgentMiddleware(config: AgentMiddlewareConfig): WhisperAgentMiddleware;
|
|
241
|
+
|
|
242
|
+
interface MemoryGraphNode {
|
|
243
|
+
id: string;
|
|
244
|
+
label?: string;
|
|
245
|
+
memory_type?: string;
|
|
246
|
+
}
|
|
247
|
+
interface MemoryGraphEdge {
|
|
248
|
+
source: string;
|
|
249
|
+
target: string;
|
|
250
|
+
type?: string;
|
|
251
|
+
}
|
|
252
|
+
interface MemoryGraphPayload {
|
|
253
|
+
nodes: MemoryGraphNode[];
|
|
254
|
+
edges: MemoryGraphEdge[];
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Convert memory graph payload to Mermaid flowchart syntax.
|
|
258
|
+
* Useful for quick visualization in docs/dashboards.
|
|
259
|
+
*/
|
|
260
|
+
declare function memoryGraphToMermaid(graph: MemoryGraphPayload): string;
|
|
151
261
|
|
|
152
262
|
/**
|
|
153
263
|
* Whisper Context SDK
|
|
@@ -157,7 +267,6 @@ interface WhisperConfig {
|
|
|
157
267
|
apiKey: string;
|
|
158
268
|
baseUrl?: string;
|
|
159
269
|
project?: string;
|
|
160
|
-
orgId?: string;
|
|
161
270
|
timeoutMs?: number;
|
|
162
271
|
retry?: {
|
|
163
272
|
maxAttempts?: number;
|
|
@@ -246,6 +355,23 @@ interface Memory {
|
|
|
246
355
|
createdAt: string;
|
|
247
356
|
updatedAt: string;
|
|
248
357
|
}
|
|
358
|
+
type MemoryKind = "factual" | "preference" | "event" | "relationship" | "opinion" | "goal" | "instruction";
|
|
359
|
+
interface ExtractedMemory {
|
|
360
|
+
content: string;
|
|
361
|
+
memoryType: MemoryKind;
|
|
362
|
+
entityMentions: string[];
|
|
363
|
+
eventDate: string | null;
|
|
364
|
+
confidence: number;
|
|
365
|
+
reasoning?: string;
|
|
366
|
+
inferred?: boolean;
|
|
367
|
+
}
|
|
368
|
+
interface MemoryExtractionResult {
|
|
369
|
+
explicit: ExtractedMemory[];
|
|
370
|
+
implicit: ExtractedMemory[];
|
|
371
|
+
all: ExtractedMemory[];
|
|
372
|
+
extractionMethod: "pattern" | "inference" | "hybrid" | "skipped";
|
|
373
|
+
latencyMs: number;
|
|
374
|
+
}
|
|
249
375
|
type WhisperErrorCode = "INVALID_API_KEY" | "PROJECT_NOT_FOUND" | "PROJECT_AMBIGUOUS" | "RATE_LIMITED" | "TEMPORARY_UNAVAILABLE" | "NETWORK_ERROR" | "TIMEOUT" | "REQUEST_FAILED" | "MISSING_PROJECT";
|
|
250
376
|
declare class WhisperError extends Error {
|
|
251
377
|
code: WhisperErrorCode;
|
|
@@ -264,7 +390,6 @@ declare class WhisperContext {
|
|
|
264
390
|
private apiKey;
|
|
265
391
|
private baseUrl;
|
|
266
392
|
private defaultProject?;
|
|
267
|
-
private orgId?;
|
|
268
393
|
private timeoutMs;
|
|
269
394
|
private retryConfig;
|
|
270
395
|
private projectRefToId;
|
|
@@ -335,6 +460,51 @@ declare class WhisperContext {
|
|
|
335
460
|
path: "sota" | "legacy";
|
|
336
461
|
fallback_used: boolean;
|
|
337
462
|
}>;
|
|
463
|
+
addMemoriesBulk(params: {
|
|
464
|
+
project?: string;
|
|
465
|
+
memories: Array<{
|
|
466
|
+
content: string;
|
|
467
|
+
memory_type?: MemoryKind | "episodic" | "semantic" | "procedural";
|
|
468
|
+
user_id?: string;
|
|
469
|
+
session_id?: string;
|
|
470
|
+
agent_id?: string;
|
|
471
|
+
importance?: number;
|
|
472
|
+
confidence?: number;
|
|
473
|
+
metadata?: Record<string, any>;
|
|
474
|
+
entity_mentions?: string[];
|
|
475
|
+
document_date?: string;
|
|
476
|
+
event_date?: string;
|
|
477
|
+
}>;
|
|
478
|
+
namespace?: string;
|
|
479
|
+
tags?: string[];
|
|
480
|
+
async?: boolean;
|
|
481
|
+
webhook_url?: string;
|
|
482
|
+
}): Promise<any>;
|
|
483
|
+
extractMemories(params: {
|
|
484
|
+
project?: string;
|
|
485
|
+
message: string;
|
|
486
|
+
context?: string;
|
|
487
|
+
session_id?: string;
|
|
488
|
+
user_id?: string;
|
|
489
|
+
enable_pattern?: boolean;
|
|
490
|
+
enable_inference?: boolean;
|
|
491
|
+
min_confidence?: number;
|
|
492
|
+
}): Promise<MemoryExtractionResult>;
|
|
493
|
+
extractSessionMemories(params: {
|
|
494
|
+
project?: string;
|
|
495
|
+
user_id?: string;
|
|
496
|
+
messages: Array<{
|
|
497
|
+
role: "user" | "assistant" | "system";
|
|
498
|
+
content: string;
|
|
499
|
+
timestamp?: string;
|
|
500
|
+
}>;
|
|
501
|
+
enable_pattern?: boolean;
|
|
502
|
+
enable_inference?: boolean;
|
|
503
|
+
}): Promise<{
|
|
504
|
+
memories: ExtractedMemory[];
|
|
505
|
+
count: number;
|
|
506
|
+
latencyMs: number;
|
|
507
|
+
}>;
|
|
338
508
|
searchMemories(params: {
|
|
339
509
|
project?: string;
|
|
340
510
|
query: string;
|
|
@@ -369,6 +539,7 @@ declare class WhisperContext {
|
|
|
369
539
|
include_inactive?: boolean;
|
|
370
540
|
include_chunks?: boolean;
|
|
371
541
|
include_relations?: boolean;
|
|
542
|
+
fast_mode?: boolean;
|
|
372
543
|
}): Promise<any>;
|
|
373
544
|
ingestSession(params: {
|
|
374
545
|
project?: string;
|
|
@@ -426,6 +597,19 @@ declare class WhisperContext {
|
|
|
426
597
|
relations: any[];
|
|
427
598
|
count: number;
|
|
428
599
|
}>;
|
|
600
|
+
getMemoryGraph(params: {
|
|
601
|
+
project?: string;
|
|
602
|
+
user_id?: string;
|
|
603
|
+
session_id?: string;
|
|
604
|
+
include_inactive?: boolean;
|
|
605
|
+
limit?: number;
|
|
606
|
+
}): Promise<any>;
|
|
607
|
+
getConversationGraph(params: {
|
|
608
|
+
project?: string;
|
|
609
|
+
session_id: string;
|
|
610
|
+
include_inactive?: boolean;
|
|
611
|
+
limit?: number;
|
|
612
|
+
}): Promise<any>;
|
|
429
613
|
oracleSearch(params: {
|
|
430
614
|
query: string;
|
|
431
615
|
project?: string;
|
|
@@ -641,6 +825,13 @@ declare class WhisperContext {
|
|
|
641
825
|
path: "sota" | "legacy";
|
|
642
826
|
fallback_used: boolean;
|
|
643
827
|
}>;
|
|
828
|
+
addBulk: (params: Parameters<WhisperContext["addMemoriesBulk"]>[0]) => Promise<any>;
|
|
829
|
+
extract: (params: Parameters<WhisperContext["extractMemories"]>[0]) => Promise<MemoryExtractionResult>;
|
|
830
|
+
extractSession: (params: Parameters<WhisperContext["extractSessionMemories"]>[0]) => Promise<{
|
|
831
|
+
memories: ExtractedMemory[];
|
|
832
|
+
count: number;
|
|
833
|
+
latencyMs: number;
|
|
834
|
+
}>;
|
|
644
835
|
search: (params: Parameters<WhisperContext["searchMemories"]>[0]) => Promise<any>;
|
|
645
836
|
searchSOTA: (params: Parameters<WhisperContext["searchMemoriesSOTA"]>[0]) => Promise<any>;
|
|
646
837
|
ingestSession: (params: Parameters<WhisperContext["ingestSession"]>[0]) => Promise<{
|
|
@@ -678,6 +869,8 @@ declare class WhisperContext {
|
|
|
678
869
|
relations: any[];
|
|
679
870
|
count: number;
|
|
680
871
|
}>;
|
|
872
|
+
getGraph: (params: Parameters<WhisperContext["getMemoryGraph"]>[0]) => Promise<any>;
|
|
873
|
+
getConversationGraph: (params: Parameters<WhisperContext["getConversationGraph"]>[0]) => Promise<any>;
|
|
681
874
|
consolidate: (params: Parameters<WhisperContext["consolidateMemories"]>[0]) => Promise<any>;
|
|
682
875
|
updateDecay: (params: Parameters<WhisperContext["updateImportanceDecay"]>[0]) => Promise<{
|
|
683
876
|
success: boolean;
|
|
@@ -762,4 +955,4 @@ declare class WhisperContext {
|
|
|
762
955
|
};
|
|
763
956
|
}
|
|
764
957
|
|
|
765
|
-
export { type Memory, type Project, type QueryParams, type QueryResult, type Source, Whisper, type WhisperConfig, WhisperContext, Whisper as WhisperDefault, WhisperError, type WhisperErrorCode, WhisperContext as default };
|
|
958
|
+
export { type ExtractedMemory, type Memory, type MemoryExtractionResult, type MemoryKind, type Project, type QueryParams, type QueryResult, type Source, Whisper, WhisperAgentMiddleware, type WhisperConfig, WhisperContext, Whisper as WhisperDefault, WhisperError, type WhisperErrorCode, createAgentMiddleware, WhisperContext as default, memoryGraphToMermaid };
|