@usewhisper/sdk 2.2.1 → 3.0.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/index.d.mts +648 -5
- package/index.d.ts +648 -5
- package/index.js +2020 -156
- package/index.mjs +2004 -156
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -182,6 +182,559 @@ declare class Whisper {
|
|
|
182
182
|
private fallbackCaptureViaAddMemory;
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
+
type CompatMode = "fallback" | "strict";
|
|
186
|
+
type OperationType = "search" | "writeAck" | "bulk" | "profile" | "session" | "query" | "get";
|
|
187
|
+
interface TimeoutBudgets {
|
|
188
|
+
searchMs: number;
|
|
189
|
+
writeAckMs: number;
|
|
190
|
+
bulkMs: number;
|
|
191
|
+
profileMs: number;
|
|
192
|
+
sessionMs: number;
|
|
193
|
+
}
|
|
194
|
+
interface RetryPolicy {
|
|
195
|
+
maxAttemptsByOperation?: Partial<Record<OperationType, number>>;
|
|
196
|
+
retryableStatusCodes?: number[];
|
|
197
|
+
retryOnNetworkError?: boolean;
|
|
198
|
+
maxBackoffMs?: number;
|
|
199
|
+
baseBackoffMs?: number;
|
|
200
|
+
}
|
|
201
|
+
interface RuntimeRequestOptions {
|
|
202
|
+
endpoint: string;
|
|
203
|
+
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
204
|
+
body?: Record<string, unknown> | undefined;
|
|
205
|
+
headers?: Record<string, string> | undefined;
|
|
206
|
+
operation: OperationType;
|
|
207
|
+
idempotent?: boolean;
|
|
208
|
+
traceId?: string;
|
|
209
|
+
dedupeKeyExtra?: string;
|
|
210
|
+
}
|
|
211
|
+
interface RuntimeClientOptions {
|
|
212
|
+
apiKey: string;
|
|
213
|
+
baseUrl?: string;
|
|
214
|
+
sdkVersion?: string;
|
|
215
|
+
compatMode?: CompatMode;
|
|
216
|
+
timeouts?: Partial<TimeoutBudgets>;
|
|
217
|
+
retryPolicy?: RetryPolicy;
|
|
218
|
+
}
|
|
219
|
+
interface RuntimeResponse<T> {
|
|
220
|
+
data: T;
|
|
221
|
+
status: number;
|
|
222
|
+
traceId: string;
|
|
223
|
+
}
|
|
224
|
+
interface DiagnosticsRecord {
|
|
225
|
+
id: string;
|
|
226
|
+
startedAt: string;
|
|
227
|
+
endedAt: string;
|
|
228
|
+
traceId: string;
|
|
229
|
+
spanId: string;
|
|
230
|
+
operation: OperationType;
|
|
231
|
+
method: string;
|
|
232
|
+
endpoint: string;
|
|
233
|
+
status?: number;
|
|
234
|
+
durationMs: number;
|
|
235
|
+
success: boolean;
|
|
236
|
+
deduped?: boolean;
|
|
237
|
+
errorCode?: string;
|
|
238
|
+
errorMessage?: string;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
type DiagnosticsSubscriber = (record: DiagnosticsRecord) => void;
|
|
242
|
+
declare class DiagnosticsStore {
|
|
243
|
+
private readonly maxEntries;
|
|
244
|
+
private readonly records;
|
|
245
|
+
private readonly subscribers;
|
|
246
|
+
constructor(maxEntries?: number);
|
|
247
|
+
add(record: DiagnosticsRecord): void;
|
|
248
|
+
getLast(limit?: number): DiagnosticsRecord[];
|
|
249
|
+
snapshot(): {
|
|
250
|
+
total: number;
|
|
251
|
+
success: number;
|
|
252
|
+
failure: number;
|
|
253
|
+
avgDurationMs: number;
|
|
254
|
+
lastTraceId?: string;
|
|
255
|
+
};
|
|
256
|
+
subscribe(fn: DiagnosticsSubscriber): () => void;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
interface QueuedWrite {
|
|
260
|
+
eventId: string;
|
|
261
|
+
project: string;
|
|
262
|
+
userId?: string;
|
|
263
|
+
sessionId?: string;
|
|
264
|
+
payload: {
|
|
265
|
+
content: string;
|
|
266
|
+
memory_type?: string;
|
|
267
|
+
user_id?: string;
|
|
268
|
+
session_id?: string;
|
|
269
|
+
agent_id?: string;
|
|
270
|
+
importance?: number;
|
|
271
|
+
confidence?: number;
|
|
272
|
+
metadata?: Record<string, unknown>;
|
|
273
|
+
document_date?: string;
|
|
274
|
+
event_date?: string;
|
|
275
|
+
};
|
|
276
|
+
createdAt: string;
|
|
277
|
+
}
|
|
278
|
+
interface QueueStore {
|
|
279
|
+
load(): Promise<QueuedWrite[]>;
|
|
280
|
+
save(items: QueuedWrite[]): Promise<void>;
|
|
281
|
+
}
|
|
282
|
+
interface WriteQueueStatus {
|
|
283
|
+
queued: number;
|
|
284
|
+
flushing: boolean;
|
|
285
|
+
lastFlushAt?: string;
|
|
286
|
+
lastFlushCount: number;
|
|
287
|
+
}
|
|
288
|
+
type FlushHandler = (items: QueuedWrite[]) => Promise<void>;
|
|
289
|
+
declare class WriteQueue {
|
|
290
|
+
private readonly flushHandler;
|
|
291
|
+
private readonly store;
|
|
292
|
+
private readonly maxBatchSize;
|
|
293
|
+
private readonly flushIntervalMs;
|
|
294
|
+
private readonly maxAttempts;
|
|
295
|
+
private readonly queue;
|
|
296
|
+
private flushTimer;
|
|
297
|
+
private flushing;
|
|
298
|
+
private lastFlushAt?;
|
|
299
|
+
private lastFlushCount;
|
|
300
|
+
constructor(args: {
|
|
301
|
+
flushHandler: FlushHandler;
|
|
302
|
+
store?: QueueStore;
|
|
303
|
+
maxBatchSize?: number;
|
|
304
|
+
flushIntervalMs?: number;
|
|
305
|
+
maxAttempts?: number;
|
|
306
|
+
});
|
|
307
|
+
start(): Promise<void>;
|
|
308
|
+
stop(): Promise<void>;
|
|
309
|
+
status(): WriteQueueStatus;
|
|
310
|
+
enqueue(input: Omit<QueuedWrite, "eventId" | "createdAt"> & {
|
|
311
|
+
eventId?: string;
|
|
312
|
+
}): Promise<QueuedWrite>;
|
|
313
|
+
flush(): Promise<void>;
|
|
314
|
+
private makeEventId;
|
|
315
|
+
private bindProcessHooks;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
declare class RuntimeClient {
|
|
319
|
+
private readonly apiKey;
|
|
320
|
+
private readonly baseUrl;
|
|
321
|
+
private readonly sdkVersion;
|
|
322
|
+
private readonly compatMode;
|
|
323
|
+
private readonly retryPolicy;
|
|
324
|
+
private readonly timeouts;
|
|
325
|
+
private readonly diagnostics;
|
|
326
|
+
private readonly inFlight;
|
|
327
|
+
constructor(options: RuntimeClientOptions, diagnostics?: DiagnosticsStore);
|
|
328
|
+
getDiagnosticsStore(): DiagnosticsStore;
|
|
329
|
+
getCompatMode(): CompatMode;
|
|
330
|
+
private timeoutFor;
|
|
331
|
+
private maxAttemptsFor;
|
|
332
|
+
private shouldRetryStatus;
|
|
333
|
+
private backoff;
|
|
334
|
+
private runtimeName;
|
|
335
|
+
private createRequestFingerprint;
|
|
336
|
+
request<T>(options: RuntimeRequestOptions): Promise<RuntimeResponse<T>>;
|
|
337
|
+
private performRequest;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
interface SearchCacheKeyInput {
|
|
341
|
+
project: string;
|
|
342
|
+
userId?: string;
|
|
343
|
+
sessionId?: string;
|
|
344
|
+
query: string;
|
|
345
|
+
topK: number;
|
|
346
|
+
profile: string;
|
|
347
|
+
includePending: boolean;
|
|
348
|
+
}
|
|
349
|
+
declare class SearchResponseCache<T = unknown> {
|
|
350
|
+
private readonly ttlMs;
|
|
351
|
+
private readonly capacity;
|
|
352
|
+
private readonly byKey;
|
|
353
|
+
private readonly scopeIndex;
|
|
354
|
+
constructor(ttlMs?: number, capacity?: number);
|
|
355
|
+
makeScopeKey(project: string, userId?: string, sessionId?: string): string;
|
|
356
|
+
makeKey(input: SearchCacheKeyInput): string;
|
|
357
|
+
get(key: string): T | null;
|
|
358
|
+
set(key: string, scopeKey: string, value: T): void;
|
|
359
|
+
invalidateScope(scopeKey: string): number;
|
|
360
|
+
private evictIfNeeded;
|
|
361
|
+
private deleteByKey;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
type MemoryKind$1 = "factual" | "preference" | "event" | "relationship" | "opinion" | "goal" | "instruction" | "episodic" | "semantic" | "procedural";
|
|
365
|
+
interface MemoryLatencyBreakdown$1 {
|
|
366
|
+
cache_ms: number;
|
|
367
|
+
embed_ms: number;
|
|
368
|
+
vector_ms: number;
|
|
369
|
+
lexical_ms: number;
|
|
370
|
+
merge_ms: number;
|
|
371
|
+
total_ms: number;
|
|
372
|
+
}
|
|
373
|
+
interface MemorySearchResult {
|
|
374
|
+
memory: {
|
|
375
|
+
id: string;
|
|
376
|
+
content: string;
|
|
377
|
+
type: string;
|
|
378
|
+
entities?: string[];
|
|
379
|
+
confidence?: number;
|
|
380
|
+
version?: number;
|
|
381
|
+
temporal?: {
|
|
382
|
+
document_date?: string | null;
|
|
383
|
+
event_date?: string | null;
|
|
384
|
+
valid_from?: string | null;
|
|
385
|
+
valid_until?: string | null;
|
|
386
|
+
};
|
|
387
|
+
};
|
|
388
|
+
similarity: number;
|
|
389
|
+
relations?: Array<Record<string, unknown>>;
|
|
390
|
+
chunk?: {
|
|
391
|
+
id: string;
|
|
392
|
+
content: string;
|
|
393
|
+
metadata?: Record<string, unknown>;
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
interface MemorySearchResponse$1 {
|
|
397
|
+
results: MemorySearchResult[];
|
|
398
|
+
count: number;
|
|
399
|
+
query: string;
|
|
400
|
+
trace_id?: string;
|
|
401
|
+
latency_ms?: number;
|
|
402
|
+
latency_breakdown?: MemoryLatencyBreakdown$1;
|
|
403
|
+
fallback?: "vector" | "lexical";
|
|
404
|
+
mode?: "fast" | "balanced" | "quality";
|
|
405
|
+
profile?: "fast" | "balanced" | "quality";
|
|
406
|
+
include_pending?: boolean;
|
|
407
|
+
pending_overlay_count?: number;
|
|
408
|
+
cache_hit?: boolean;
|
|
409
|
+
}
|
|
410
|
+
interface MemoryWriteAck$1 {
|
|
411
|
+
success: boolean;
|
|
412
|
+
mode?: "async" | "sync";
|
|
413
|
+
trace_id?: string;
|
|
414
|
+
job_id?: string;
|
|
415
|
+
status_url?: string;
|
|
416
|
+
accepted_at?: string;
|
|
417
|
+
visibility_sla_ms?: number;
|
|
418
|
+
pending_visibility?: boolean;
|
|
419
|
+
queued?: boolean;
|
|
420
|
+
event_id?: string;
|
|
421
|
+
created?: number;
|
|
422
|
+
errors?: string[];
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
interface MemoryModuleOptions {
|
|
426
|
+
defaultProject?: string;
|
|
427
|
+
cacheEnabled?: boolean;
|
|
428
|
+
queueEnabled?: boolean;
|
|
429
|
+
}
|
|
430
|
+
declare class MemoryModule {
|
|
431
|
+
private readonly client;
|
|
432
|
+
private readonly cache;
|
|
433
|
+
private readonly queue;
|
|
434
|
+
private readonly options;
|
|
435
|
+
constructor(client: RuntimeClient, cache: SearchResponseCache<MemorySearchResponse$1>, queue: WriteQueue, options?: MemoryModuleOptions);
|
|
436
|
+
private resolveProject;
|
|
437
|
+
private invalidate;
|
|
438
|
+
add(params: {
|
|
439
|
+
project?: string;
|
|
440
|
+
content: string;
|
|
441
|
+
memory_type?: MemoryKind$1;
|
|
442
|
+
user_id?: string;
|
|
443
|
+
session_id?: string;
|
|
444
|
+
agent_id?: string;
|
|
445
|
+
importance?: number;
|
|
446
|
+
confidence?: number;
|
|
447
|
+
metadata?: Record<string, unknown>;
|
|
448
|
+
document_date?: string;
|
|
449
|
+
event_date?: string;
|
|
450
|
+
write_mode?: "async" | "sync";
|
|
451
|
+
async?: boolean;
|
|
452
|
+
}): Promise<MemoryWriteAck$1>;
|
|
453
|
+
addBulk(params: {
|
|
454
|
+
project?: string;
|
|
455
|
+
memories: Array<{
|
|
456
|
+
content: string;
|
|
457
|
+
memory_type?: MemoryKind$1;
|
|
458
|
+
user_id?: string;
|
|
459
|
+
session_id?: string;
|
|
460
|
+
agent_id?: string;
|
|
461
|
+
importance?: number;
|
|
462
|
+
confidence?: number;
|
|
463
|
+
metadata?: Record<string, unknown>;
|
|
464
|
+
document_date?: string;
|
|
465
|
+
event_date?: string;
|
|
466
|
+
}>;
|
|
467
|
+
write_mode?: "async" | "sync";
|
|
468
|
+
async?: boolean;
|
|
469
|
+
}): Promise<MemoryWriteAck$1>;
|
|
470
|
+
search(params: {
|
|
471
|
+
project?: string;
|
|
472
|
+
query: string;
|
|
473
|
+
user_id?: string;
|
|
474
|
+
session_id?: string;
|
|
475
|
+
top_k?: number;
|
|
476
|
+
memory_type?: MemoryKind$1;
|
|
477
|
+
profile?: "fast" | "balanced" | "quality";
|
|
478
|
+
include_pending?: boolean;
|
|
479
|
+
}): Promise<MemorySearchResponse$1>;
|
|
480
|
+
getUserProfile(params: {
|
|
481
|
+
project?: string;
|
|
482
|
+
user_id: string;
|
|
483
|
+
include_pending?: boolean;
|
|
484
|
+
memory_types?: string;
|
|
485
|
+
}): Promise<{
|
|
486
|
+
user_id: string;
|
|
487
|
+
memories: Array<Record<string, unknown>>;
|
|
488
|
+
count: number;
|
|
489
|
+
}>;
|
|
490
|
+
getSessionMemories(params: {
|
|
491
|
+
project?: string;
|
|
492
|
+
session_id: string;
|
|
493
|
+
include_pending?: boolean;
|
|
494
|
+
limit?: number;
|
|
495
|
+
}): Promise<{
|
|
496
|
+
memories: Array<Record<string, unknown>>;
|
|
497
|
+
count: number;
|
|
498
|
+
}>;
|
|
499
|
+
update(memoryId: string, params: {
|
|
500
|
+
content: string;
|
|
501
|
+
reasoning?: string;
|
|
502
|
+
}): Promise<{
|
|
503
|
+
success: boolean;
|
|
504
|
+
}>;
|
|
505
|
+
delete(memoryId: string): Promise<{
|
|
506
|
+
success: boolean;
|
|
507
|
+
deleted: string;
|
|
508
|
+
}>;
|
|
509
|
+
flag(params: {
|
|
510
|
+
memoryId: string;
|
|
511
|
+
reason: string;
|
|
512
|
+
severity?: "low" | "medium" | "high";
|
|
513
|
+
}): Promise<{
|
|
514
|
+
success: boolean;
|
|
515
|
+
}>;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
type SessionState = "created" | "active" | "suspended" | "resumed" | "ended" | "archived";
|
|
519
|
+
declare class SessionModule {
|
|
520
|
+
private readonly memory;
|
|
521
|
+
private readonly defaultProject?;
|
|
522
|
+
private readonly sessions;
|
|
523
|
+
constructor(memory: MemoryModule, defaultProject?: string | undefined);
|
|
524
|
+
private resolveProject;
|
|
525
|
+
private ensure;
|
|
526
|
+
start(params: {
|
|
527
|
+
userId: string;
|
|
528
|
+
project?: string;
|
|
529
|
+
sessionId?: string;
|
|
530
|
+
metadata?: Record<string, unknown>;
|
|
531
|
+
}): Promise<{
|
|
532
|
+
sessionId: string;
|
|
533
|
+
state: SessionState;
|
|
534
|
+
createdAt: string;
|
|
535
|
+
}>;
|
|
536
|
+
event(params: {
|
|
537
|
+
sessionId: string;
|
|
538
|
+
type: string;
|
|
539
|
+
content: string;
|
|
540
|
+
parentEventId?: string;
|
|
541
|
+
metadata?: Record<string, unknown>;
|
|
542
|
+
}): Promise<{
|
|
543
|
+
success: boolean;
|
|
544
|
+
eventId: string;
|
|
545
|
+
sequence: number;
|
|
546
|
+
}>;
|
|
547
|
+
suspend(params: {
|
|
548
|
+
sessionId: string;
|
|
549
|
+
}): Promise<{
|
|
550
|
+
sessionId: string;
|
|
551
|
+
state: SessionState;
|
|
552
|
+
}>;
|
|
553
|
+
resume(params: {
|
|
554
|
+
sessionId: string;
|
|
555
|
+
}): Promise<{
|
|
556
|
+
sessionId: string;
|
|
557
|
+
state: SessionState;
|
|
558
|
+
}>;
|
|
559
|
+
end(params: {
|
|
560
|
+
sessionId: string;
|
|
561
|
+
}): Promise<{
|
|
562
|
+
sessionId: string;
|
|
563
|
+
state: SessionState;
|
|
564
|
+
}>;
|
|
565
|
+
archive(params: {
|
|
566
|
+
sessionId: string;
|
|
567
|
+
}): Promise<{
|
|
568
|
+
sessionId: string;
|
|
569
|
+
state: SessionState;
|
|
570
|
+
}>;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
declare class ProfileModule {
|
|
574
|
+
private readonly memory;
|
|
575
|
+
constructor(memory: MemoryModule);
|
|
576
|
+
getUserProfile(params: {
|
|
577
|
+
project?: string;
|
|
578
|
+
user_id: string;
|
|
579
|
+
include_pending?: boolean;
|
|
580
|
+
memory_types?: string;
|
|
581
|
+
}): Promise<{
|
|
582
|
+
user_id: string;
|
|
583
|
+
memories: Array<Record<string, unknown>>;
|
|
584
|
+
count: number;
|
|
585
|
+
}>;
|
|
586
|
+
getSessionMemories(params: {
|
|
587
|
+
project?: string;
|
|
588
|
+
session_id: string;
|
|
589
|
+
include_pending?: boolean;
|
|
590
|
+
limit?: number;
|
|
591
|
+
}): Promise<{
|
|
592
|
+
memories: Array<Record<string, unknown>>;
|
|
593
|
+
count: number;
|
|
594
|
+
}>;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
declare class AnalyticsModule {
|
|
598
|
+
private readonly diagnostics;
|
|
599
|
+
private readonly queue;
|
|
600
|
+
constructor(diagnostics: DiagnosticsStore, queue: WriteQueue);
|
|
601
|
+
diagnosticsSnapshot(): {
|
|
602
|
+
total: number;
|
|
603
|
+
success: number;
|
|
604
|
+
failure: number;
|
|
605
|
+
avgDurationMs: number;
|
|
606
|
+
lastTraceId?: string;
|
|
607
|
+
};
|
|
608
|
+
queueStatus(): WriteQueueStatus;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
interface WhisperClientConfig {
|
|
612
|
+
apiKey: string;
|
|
613
|
+
baseUrl?: string;
|
|
614
|
+
project?: string;
|
|
615
|
+
compatMode?: CompatMode;
|
|
616
|
+
timeouts?: Partial<TimeoutBudgets>;
|
|
617
|
+
retryPolicy?: RetryPolicy;
|
|
618
|
+
cache?: {
|
|
619
|
+
enabled?: boolean;
|
|
620
|
+
ttlMs?: number;
|
|
621
|
+
capacity?: number;
|
|
622
|
+
};
|
|
623
|
+
queue?: {
|
|
624
|
+
enabled?: boolean;
|
|
625
|
+
maxBatchSize?: number;
|
|
626
|
+
flushIntervalMs?: number;
|
|
627
|
+
maxAttempts?: number;
|
|
628
|
+
persistence?: "memory" | "storage" | "file";
|
|
629
|
+
filePath?: string;
|
|
630
|
+
};
|
|
631
|
+
telemetry?: {
|
|
632
|
+
enabled?: boolean;
|
|
633
|
+
maxEntries?: number;
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
interface RunContext {
|
|
637
|
+
project?: string;
|
|
638
|
+
userId?: string;
|
|
639
|
+
sessionId?: string;
|
|
640
|
+
traceId?: string;
|
|
641
|
+
}
|
|
642
|
+
declare class WhisperClient {
|
|
643
|
+
private readonly config;
|
|
644
|
+
readonly diagnostics: {
|
|
645
|
+
getLast: (limit?: number) => ReturnType<DiagnosticsStore["getLast"]>;
|
|
646
|
+
subscribe: (fn: Parameters<DiagnosticsStore["subscribe"]>[0]) => ReturnType<DiagnosticsStore["subscribe"]>;
|
|
647
|
+
snapshot: () => ReturnType<DiagnosticsStore["snapshot"]>;
|
|
648
|
+
};
|
|
649
|
+
readonly queue: {
|
|
650
|
+
flush: () => Promise<void>;
|
|
651
|
+
status: () => ReturnType<WriteQueue["status"]>;
|
|
652
|
+
};
|
|
653
|
+
readonly memory: {
|
|
654
|
+
add: (params: Parameters<MemoryModule["add"]>[0]) => Promise<MemoryWriteAck$1>;
|
|
655
|
+
addBulk: (params: Parameters<MemoryModule["addBulk"]>[0]) => Promise<MemoryWriteAck$1>;
|
|
656
|
+
search: (params: Parameters<MemoryModule["search"]>[0]) => Promise<MemorySearchResponse$1>;
|
|
657
|
+
getUserProfile: (params: Parameters<MemoryModule["getUserProfile"]>[0]) => ReturnType<MemoryModule["getUserProfile"]>;
|
|
658
|
+
getSessionMemories: (params: Parameters<MemoryModule["getSessionMemories"]>[0]) => ReturnType<MemoryModule["getSessionMemories"]>;
|
|
659
|
+
update: (memoryId: string, params: {
|
|
660
|
+
content: string;
|
|
661
|
+
reasoning?: string;
|
|
662
|
+
}) => Promise<{
|
|
663
|
+
success: boolean;
|
|
664
|
+
}>;
|
|
665
|
+
delete: (memoryId: string) => Promise<{
|
|
666
|
+
success: boolean;
|
|
667
|
+
deleted: string;
|
|
668
|
+
}>;
|
|
669
|
+
flag: (params: {
|
|
670
|
+
memoryId: string;
|
|
671
|
+
reason: string;
|
|
672
|
+
severity?: "low" | "medium" | "high";
|
|
673
|
+
}) => Promise<{
|
|
674
|
+
success: boolean;
|
|
675
|
+
}>;
|
|
676
|
+
};
|
|
677
|
+
readonly session: {
|
|
678
|
+
start: (params: Parameters<SessionModule["start"]>[0]) => ReturnType<SessionModule["start"]>;
|
|
679
|
+
event: (params: Parameters<SessionModule["event"]>[0]) => ReturnType<SessionModule["event"]>;
|
|
680
|
+
suspend: (params: Parameters<SessionModule["suspend"]>[0]) => ReturnType<SessionModule["suspend"]>;
|
|
681
|
+
resume: (params: Parameters<SessionModule["resume"]>[0]) => ReturnType<SessionModule["resume"]>;
|
|
682
|
+
end: (params: Parameters<SessionModule["end"]>[0]) => ReturnType<SessionModule["end"]>;
|
|
683
|
+
};
|
|
684
|
+
readonly profile: {
|
|
685
|
+
getUserProfile: (params: Parameters<ProfileModule["getUserProfile"]>[0]) => ReturnType<ProfileModule["getUserProfile"]>;
|
|
686
|
+
getSessionMemories: (params: Parameters<ProfileModule["getSessionMemories"]>[0]) => ReturnType<ProfileModule["getSessionMemories"]>;
|
|
687
|
+
};
|
|
688
|
+
readonly analytics: {
|
|
689
|
+
diagnosticsSnapshot: () => ReturnType<AnalyticsModule["diagnosticsSnapshot"]>;
|
|
690
|
+
queueStatus: () => ReturnType<AnalyticsModule["queueStatus"]>;
|
|
691
|
+
};
|
|
692
|
+
private readonly runtimeClient;
|
|
693
|
+
private readonly diagnosticsStore;
|
|
694
|
+
private readonly searchCache;
|
|
695
|
+
private readonly writeQueue;
|
|
696
|
+
private readonly memoryModule;
|
|
697
|
+
private readonly sessionModule;
|
|
698
|
+
private readonly profileModule;
|
|
699
|
+
private readonly analyticsModule;
|
|
700
|
+
constructor(config: WhisperClientConfig);
|
|
701
|
+
static fromEnv(overrides?: Partial<WhisperClientConfig>): WhisperClient;
|
|
702
|
+
withRunContext(context: RunContext): {
|
|
703
|
+
memory: {
|
|
704
|
+
add: (params: Omit<Parameters<MemoryModule["add"]>[0], "project" | "user_id" | "session_id"> & {
|
|
705
|
+
project?: string;
|
|
706
|
+
user_id?: string;
|
|
707
|
+
session_id?: string;
|
|
708
|
+
memory_type?: MemoryKind$1;
|
|
709
|
+
}) => Promise<MemoryWriteAck$1>;
|
|
710
|
+
search: (params: Omit<Parameters<MemoryModule["search"]>[0], "project" | "user_id" | "session_id"> & {
|
|
711
|
+
project?: string;
|
|
712
|
+
user_id?: string;
|
|
713
|
+
session_id?: string;
|
|
714
|
+
}) => Promise<MemorySearchResponse$1>;
|
|
715
|
+
};
|
|
716
|
+
session: {
|
|
717
|
+
event: (params: Omit<Parameters<SessionModule["event"]>[0], "sessionId"> & {
|
|
718
|
+
sessionId?: string;
|
|
719
|
+
}) => Promise<{
|
|
720
|
+
success: boolean;
|
|
721
|
+
eventId: string;
|
|
722
|
+
sequence: number;
|
|
723
|
+
}>;
|
|
724
|
+
};
|
|
725
|
+
queue: {
|
|
726
|
+
flush: () => Promise<void>;
|
|
727
|
+
status: () => ReturnType<WriteQueue["status"]>;
|
|
728
|
+
};
|
|
729
|
+
diagnostics: {
|
|
730
|
+
getLast: (limit?: number) => ReturnType<DiagnosticsStore["getLast"]>;
|
|
731
|
+
subscribe: (fn: Parameters<DiagnosticsStore["subscribe"]>[0]) => ReturnType<DiagnosticsStore["subscribe"]>;
|
|
732
|
+
snapshot: () => ReturnType<DiagnosticsStore["snapshot"]>;
|
|
733
|
+
};
|
|
734
|
+
};
|
|
735
|
+
shutdown(): Promise<void>;
|
|
736
|
+
}
|
|
737
|
+
|
|
185
738
|
interface AgentMiddlewareConfig extends WhisperOptions {
|
|
186
739
|
/**
|
|
187
740
|
* Build the prompt passed to the model.
|
|
@@ -240,6 +793,98 @@ declare class WhisperAgentMiddleware {
|
|
|
240
793
|
}
|
|
241
794
|
declare function createAgentMiddleware(config: AgentMiddlewareConfig): WhisperAgentMiddleware;
|
|
242
795
|
|
|
796
|
+
interface LangChainMemoryAdapterOptions {
|
|
797
|
+
project?: string;
|
|
798
|
+
userId: string;
|
|
799
|
+
sessionId?: string;
|
|
800
|
+
memoryKey?: string;
|
|
801
|
+
topK?: number;
|
|
802
|
+
profile?: "fast" | "balanced" | "quality";
|
|
803
|
+
}
|
|
804
|
+
/**
|
|
805
|
+
* Lightweight adapter matching LangChain memory contract shape.
|
|
806
|
+
* Compatible with BaseMemory-style integrations:
|
|
807
|
+
* - loadMemoryVariables
|
|
808
|
+
* - saveContext
|
|
809
|
+
* - clear
|
|
810
|
+
*/
|
|
811
|
+
declare class LangChainMemoryAdapter {
|
|
812
|
+
private readonly client;
|
|
813
|
+
private readonly options;
|
|
814
|
+
readonly memoryKeys: string[];
|
|
815
|
+
private readonly memoryKey;
|
|
816
|
+
constructor(client: WhisperClient, options: LangChainMemoryAdapterOptions);
|
|
817
|
+
loadMemoryVariables(_inputValues: Record<string, unknown>): Promise<Record<string, string>>;
|
|
818
|
+
saveContext(inputValues: Record<string, unknown>, outputValues: Record<string, unknown>): Promise<void>;
|
|
819
|
+
clear(): Promise<void>;
|
|
820
|
+
}
|
|
821
|
+
declare function createLangChainMemoryAdapter(client: WhisperClient, options: LangChainMemoryAdapterOptions): LangChainMemoryAdapter;
|
|
822
|
+
|
|
823
|
+
interface LangGraphCheckpointConfig {
|
|
824
|
+
configurable: {
|
|
825
|
+
thread_id: string;
|
|
826
|
+
checkpoint_ns?: string;
|
|
827
|
+
checkpoint_id?: string;
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
interface LangGraphCheckpointTuple {
|
|
831
|
+
config: LangGraphCheckpointConfig;
|
|
832
|
+
checkpoint: Record<string, unknown>;
|
|
833
|
+
metadata?: Record<string, unknown>;
|
|
834
|
+
parent_config?: LangGraphCheckpointConfig | null;
|
|
835
|
+
}
|
|
836
|
+
interface LangGraphCheckpointListOptions {
|
|
837
|
+
limit?: number;
|
|
838
|
+
before?: {
|
|
839
|
+
checkpointId?: string;
|
|
840
|
+
updatedAt?: string;
|
|
841
|
+
};
|
|
842
|
+
sort?: "asc" | "desc";
|
|
843
|
+
filter?: {
|
|
844
|
+
checkpointNs?: string;
|
|
845
|
+
metadata?: Record<string, unknown>;
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
interface LangGraphCheckpointSearchOptions {
|
|
849
|
+
threadId: string;
|
|
850
|
+
query: string;
|
|
851
|
+
checkpointNs?: string;
|
|
852
|
+
topK?: number;
|
|
853
|
+
includePending?: boolean;
|
|
854
|
+
profile?: "fast" | "balanced" | "quality";
|
|
855
|
+
}
|
|
856
|
+
interface LangGraphCheckpointAdapterOptions {
|
|
857
|
+
project?: string;
|
|
858
|
+
userIdPrefix?: string;
|
|
859
|
+
defaultCheckpointNs?: string;
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* LangGraph checkpoint adapter over Whisper memory APIs.
|
|
863
|
+
* Phase 5a: get/put/list.
|
|
864
|
+
* Phase 5b: checkpoint_ns fidelity, richer list/search filtering, schema-hard parsing.
|
|
865
|
+
*/
|
|
866
|
+
declare class LangGraphCheckpointAdapter {
|
|
867
|
+
private readonly client;
|
|
868
|
+
private readonly localByKey;
|
|
869
|
+
private readonly localByThread;
|
|
870
|
+
private readonly options;
|
|
871
|
+
constructor(client: WhisperClient, options?: LangGraphCheckpointAdapterOptions);
|
|
872
|
+
private getUserId;
|
|
873
|
+
private resolveCheckpointNs;
|
|
874
|
+
private makeLocalKey;
|
|
875
|
+
private normalizeTuple;
|
|
876
|
+
private parseCheckpointTupleFromRow;
|
|
877
|
+
private upsertLocal;
|
|
878
|
+
private mergeWithLocal;
|
|
879
|
+
private applyListFilters;
|
|
880
|
+
private fetchThreadRecords;
|
|
881
|
+
get(config: LangGraphCheckpointConfig): Promise<LangGraphCheckpointTuple | undefined>;
|
|
882
|
+
put(config: LangGraphCheckpointConfig, checkpoint: Record<string, unknown>, metadata?: Record<string, unknown>, parentConfig?: LangGraphCheckpointConfig | null): Promise<LangGraphCheckpointConfig>;
|
|
883
|
+
list(config: LangGraphCheckpointConfig, options?: LangGraphCheckpointListOptions): Promise<LangGraphCheckpointTuple[]>;
|
|
884
|
+
search(params: LangGraphCheckpointSearchOptions): Promise<LangGraphCheckpointTuple[]>;
|
|
885
|
+
}
|
|
886
|
+
declare function createLangGraphCheckpointAdapter(client: WhisperClient, options?: LangGraphCheckpointAdapterOptions): LangGraphCheckpointAdapter;
|
|
887
|
+
|
|
243
888
|
interface MemoryGraphNode {
|
|
244
889
|
id: string;
|
|
245
890
|
label?: string;
|
|
@@ -260,10 +905,6 @@ interface MemoryGraphPayload {
|
|
|
260
905
|
*/
|
|
261
906
|
declare function memoryGraphToMermaid(graph: MemoryGraphPayload): string;
|
|
262
907
|
|
|
263
|
-
/**
|
|
264
|
-
* Whisper Context SDK
|
|
265
|
-
* TypeScript SDK for the Whisper Context API
|
|
266
|
-
*/
|
|
267
908
|
interface WhisperConfig {
|
|
268
909
|
apiKey: string;
|
|
269
910
|
baseUrl?: string;
|
|
@@ -461,6 +1102,7 @@ declare class WhisperContext {
|
|
|
461
1102
|
private defaultProject?;
|
|
462
1103
|
private timeoutMs;
|
|
463
1104
|
private retryConfig;
|
|
1105
|
+
private runtimeClient;
|
|
464
1106
|
private projectRefToId;
|
|
465
1107
|
private projectCache;
|
|
466
1108
|
private projectCacheExpiresAt;
|
|
@@ -473,6 +1115,7 @@ declare class WhisperContext {
|
|
|
473
1115
|
private withProjectRefFallback;
|
|
474
1116
|
private classifyError;
|
|
475
1117
|
private isEndpointNotFoundError;
|
|
1118
|
+
private inferOperation;
|
|
476
1119
|
private request;
|
|
477
1120
|
query(params: QueryParams): Promise<QueryResult>;
|
|
478
1121
|
createProject(params: {
|
|
@@ -1036,4 +1679,4 @@ declare class WhisperContext {
|
|
|
1036
1679
|
};
|
|
1037
1680
|
}
|
|
1038
1681
|
|
|
1039
|
-
export { type ExtractedMemory, type Memory, type MemoryExtractionResult, type MemoryKind, type MemoryLatencyBreakdown, type MemorySearchResponse, type MemoryWriteAck, type Project, type QueryParams, type QueryResult, type Source, Whisper, WhisperAgentMiddleware, type WhisperConfig, WhisperContext, Whisper as WhisperDefault, WhisperError, type WhisperErrorCode, createAgentMiddleware, WhisperContext as default, memoryGraphToMermaid };
|
|
1682
|
+
export { type ExtractedMemory, LangChainMemoryAdapter, LangGraphCheckpointAdapter, type Memory, type MemoryExtractionResult, type MemoryKind, type MemoryLatencyBreakdown, type MemorySearchResponse, type MemoryWriteAck, type Project, type QueryParams, type QueryResult, type Source, Whisper, WhisperAgentMiddleware, WhisperClient, type WhisperConfig, WhisperContext, Whisper as WhisperDefault, WhisperError, type WhisperErrorCode, WhisperClient as WhisperRuntimeClient, createAgentMiddleware, createLangChainMemoryAdapter, createLangGraphCheckpointAdapter, WhisperContext as default, memoryGraphToMermaid };
|