@usewhisper/sdk 2.2.0 → 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.
Files changed (5) hide show
  1. package/index.d.mts +735 -11
  2. package/index.d.ts +735 -11
  3. package/index.js +2181 -121
  4. package/index.mjs +2165 -121
  5. package/package.json +1 -1
package/index.d.mts CHANGED
@@ -179,6 +179,560 @@ declare class Whisper {
179
179
  */
180
180
  raw(): WhisperContext;
181
181
  private extractMemoryIdsFromBulkResponse;
182
+ private fallbackCaptureViaAddMemory;
183
+ }
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>;
182
736
  }
183
737
 
184
738
  interface AgentMiddlewareConfig extends WhisperOptions {
@@ -239,6 +793,98 @@ declare class WhisperAgentMiddleware {
239
793
  }
240
794
  declare function createAgentMiddleware(config: AgentMiddlewareConfig): WhisperAgentMiddleware;
241
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
+
242
888
  interface MemoryGraphNode {
243
889
  id: string;
244
890
  label?: string;
@@ -259,10 +905,6 @@ interface MemoryGraphPayload {
259
905
  */
260
906
  declare function memoryGraphToMermaid(graph: MemoryGraphPayload): string;
261
907
 
262
- /**
263
- * Whisper Context SDK
264
- * TypeScript SDK for the Whisper Context API
265
- */
266
908
  interface WhisperConfig {
267
909
  apiKey: string;
268
910
  baseUrl?: string;
@@ -315,7 +957,20 @@ interface QueryResult {
315
957
  cache_hit: boolean;
316
958
  tokens_used: number;
317
959
  context_hash: string;
960
+ profile?: string;
318
961
  compression?: any;
962
+ timing?: {
963
+ cache_check_ms?: number;
964
+ embed_ms?: number;
965
+ vector_ms?: number;
966
+ fts_ms?: number;
967
+ rerank_ms?: number;
968
+ enrich_ms?: number;
969
+ pack_ms?: number;
970
+ cache_set_ms?: number;
971
+ total_ms?: number;
972
+ [key: string]: number | undefined;
973
+ };
319
974
  };
320
975
  }
321
976
  interface Project {
@@ -372,6 +1027,61 @@ interface MemoryExtractionResult {
372
1027
  extractionMethod: "pattern" | "inference" | "hybrid" | "skipped";
373
1028
  latencyMs: number;
374
1029
  }
1030
+ interface MemoryLatencyBreakdown {
1031
+ cache_ms: number;
1032
+ embed_ms: number;
1033
+ vector_ms: number;
1034
+ lexical_ms: number;
1035
+ merge_ms: number;
1036
+ total_ms: number;
1037
+ }
1038
+ interface MemorySearchResponse {
1039
+ results: Array<{
1040
+ memory: {
1041
+ id: string;
1042
+ content: string;
1043
+ type: string;
1044
+ entities?: string[];
1045
+ confidence?: number;
1046
+ version?: number;
1047
+ temporal?: {
1048
+ document_date?: string | null;
1049
+ event_date?: string | null;
1050
+ valid_from?: string | null;
1051
+ valid_until?: string | null;
1052
+ };
1053
+ };
1054
+ chunk?: {
1055
+ id: string;
1056
+ content: string;
1057
+ metadata?: Record<string, any>;
1058
+ };
1059
+ similarity: number;
1060
+ relations?: any[];
1061
+ }>;
1062
+ count: number;
1063
+ query: string;
1064
+ trace_id?: string;
1065
+ question_date?: string;
1066
+ latency_ms?: number;
1067
+ latency_breakdown?: MemoryLatencyBreakdown;
1068
+ fallback?: "vector" | "lexical";
1069
+ mode?: "fast" | "balanced" | "quality";
1070
+ profile?: "fast" | "balanced" | "quality";
1071
+ include_pending?: boolean;
1072
+ pending_overlay_count?: number;
1073
+ }
1074
+ interface MemoryWriteAck {
1075
+ success: boolean;
1076
+ mode?: "async" | "sync";
1077
+ trace_id?: string;
1078
+ job_id?: string;
1079
+ status_url?: string;
1080
+ accepted_at?: string;
1081
+ visibility_sla_ms?: number;
1082
+ pending_visibility?: boolean;
1083
+ [key: string]: any;
1084
+ }
375
1085
  type WhisperErrorCode = "INVALID_API_KEY" | "PROJECT_NOT_FOUND" | "PROJECT_AMBIGUOUS" | "RATE_LIMITED" | "TEMPORARY_UNAVAILABLE" | "NETWORK_ERROR" | "TIMEOUT" | "REQUEST_FAILED" | "MISSING_PROJECT";
376
1086
  declare class WhisperError extends Error {
377
1087
  code: WhisperErrorCode;
@@ -392,6 +1102,7 @@ declare class WhisperContext {
392
1102
  private defaultProject?;
393
1103
  private timeoutMs;
394
1104
  private retryConfig;
1105
+ private runtimeClient;
395
1106
  private projectRefToId;
396
1107
  private projectCache;
397
1108
  private projectCacheExpiresAt;
@@ -403,6 +1114,8 @@ declare class WhisperContext {
403
1114
  private getProjectRefCandidates;
404
1115
  private withProjectRefFallback;
405
1116
  private classifyError;
1117
+ private isEndpointNotFoundError;
1118
+ private inferOperation;
406
1119
  private request;
407
1120
  query(params: QueryParams): Promise<QueryResult>;
408
1121
  createProject(params: {
@@ -453,6 +1166,8 @@ declare class WhisperContext {
453
1166
  importance?: number;
454
1167
  metadata?: Record<string, any>;
455
1168
  expires_in_seconds?: number;
1169
+ async?: boolean;
1170
+ write_mode?: "async" | "sync";
456
1171
  allow_legacy_fallback?: boolean;
457
1172
  }): Promise<{
458
1173
  id: string;
@@ -478,6 +1193,7 @@ declare class WhisperContext {
478
1193
  namespace?: string;
479
1194
  tags?: string[];
480
1195
  async?: boolean;
1196
+ write_mode?: "async" | "sync";
481
1197
  webhook_url?: string;
482
1198
  }): Promise<any>;
483
1199
  extractMemories(params: {
@@ -513,7 +1229,9 @@ declare class WhisperContext {
513
1229
  agent_id?: string;
514
1230
  memory_type?: "factual" | "preference" | "event" | "relationship" | "opinion" | "goal" | "instruction";
515
1231
  top_k?: number;
516
- }): Promise<any>;
1232
+ profile?: "fast" | "balanced" | "quality";
1233
+ include_pending?: boolean;
1234
+ }): Promise<MemorySearchResponse>;
517
1235
  createApiKey(params: {
518
1236
  name: string;
519
1237
  scopes?: string[];
@@ -540,7 +1258,9 @@ declare class WhisperContext {
540
1258
  include_chunks?: boolean;
541
1259
  include_relations?: boolean;
542
1260
  fast_mode?: boolean;
543
- }): Promise<any>;
1261
+ profile?: "fast" | "balanced" | "quality";
1262
+ include_pending?: boolean;
1263
+ }): Promise<MemorySearchResponse>;
544
1264
  ingestSession(params: {
545
1265
  project?: string;
546
1266
  session_id: string;
@@ -550,18 +1270,21 @@ declare class WhisperContext {
550
1270
  content: string;
551
1271
  timestamp: string;
552
1272
  }>;
1273
+ async?: boolean;
1274
+ write_mode?: "async" | "sync";
553
1275
  }): Promise<{
554
1276
  success: boolean;
555
1277
  memories_created: number;
556
1278
  relations_created: number;
557
1279
  memories_invalidated: number;
558
1280
  errors?: string[];
559
- }>;
1281
+ } & MemoryWriteAck>;
560
1282
  getSessionMemories(params: {
561
1283
  session_id: string;
562
1284
  project?: string;
563
1285
  limit?: number;
564
1286
  since_date?: string;
1287
+ include_pending?: boolean;
565
1288
  }): Promise<{
566
1289
  memories: any[];
567
1290
  count: number;
@@ -570,6 +1293,7 @@ declare class WhisperContext {
570
1293
  user_id: string;
571
1294
  project?: string;
572
1295
  memory_types?: string;
1296
+ include_pending?: boolean;
573
1297
  }): Promise<{
574
1298
  user_id: string;
575
1299
  memories: any[];
@@ -832,15 +1556,15 @@ declare class WhisperContext {
832
1556
  count: number;
833
1557
  latencyMs: number;
834
1558
  }>;
835
- search: (params: Parameters<WhisperContext["searchMemories"]>[0]) => Promise<any>;
836
- searchSOTA: (params: Parameters<WhisperContext["searchMemoriesSOTA"]>[0]) => Promise<any>;
1559
+ search: (params: Parameters<WhisperContext["searchMemories"]>[0]) => Promise<MemorySearchResponse>;
1560
+ searchSOTA: (params: Parameters<WhisperContext["searchMemoriesSOTA"]>[0]) => Promise<MemorySearchResponse>;
837
1561
  ingestSession: (params: Parameters<WhisperContext["ingestSession"]>[0]) => Promise<{
838
1562
  success: boolean;
839
1563
  memories_created: number;
840
1564
  relations_created: number;
841
1565
  memories_invalidated: number;
842
1566
  errors?: string[];
843
- }>;
1567
+ } & MemoryWriteAck>;
844
1568
  getSessionMemories: (params: Parameters<WhisperContext["getSessionMemories"]>[0]) => Promise<{
845
1569
  memories: any[];
846
1570
  count: number;
@@ -955,4 +1679,4 @@ declare class WhisperContext {
955
1679
  };
956
1680
  }
957
1681
 
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 };
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 };