@usewhisper/sdk 2.2.1 → 3.1.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 (6) hide show
  1. package/README.md +2 -2
  2. package/index.d.mts +753 -5
  3. package/index.d.ts +753 -5
  4. package/index.js +2126 -148
  5. package/index.mjs +2110 -148
  6. package/package.json +2 -1
package/index.d.mts CHANGED
@@ -182,6 +182,568 @@ 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
+ private readonly sendApiKeyHeader;
328
+ constructor(options: RuntimeClientOptions, diagnostics?: DiagnosticsStore);
329
+ getDiagnosticsStore(): DiagnosticsStore;
330
+ getCompatMode(): CompatMode;
331
+ private timeoutFor;
332
+ private maxAttemptsFor;
333
+ private shouldRetryStatus;
334
+ private backoff;
335
+ private runtimeName;
336
+ private apiKeyOnlyPrefixes;
337
+ private shouldAttachApiKeyHeader;
338
+ private createRequestFingerprint;
339
+ request<T>(options: RuntimeRequestOptions): Promise<RuntimeResponse<T>>;
340
+ private performRequest;
341
+ }
342
+
343
+ interface SearchCacheKeyInput {
344
+ project: string;
345
+ userId?: string;
346
+ sessionId?: string;
347
+ query: string;
348
+ topK: number;
349
+ profile: string;
350
+ includePending: boolean;
351
+ }
352
+ declare class SearchResponseCache<T = unknown> {
353
+ private readonly ttlMs;
354
+ private readonly capacity;
355
+ private readonly byKey;
356
+ private readonly scopeIndex;
357
+ constructor(ttlMs?: number, capacity?: number);
358
+ makeScopeKey(project: string, userId?: string, sessionId?: string): string;
359
+ makeKey(input: SearchCacheKeyInput): string;
360
+ get(key: string): T | null;
361
+ set(key: string, scopeKey: string, value: T): void;
362
+ invalidateScope(scopeKey: string): number;
363
+ private evictIfNeeded;
364
+ private deleteByKey;
365
+ }
366
+
367
+ type MemoryKind$1 = "factual" | "preference" | "event" | "relationship" | "opinion" | "goal" | "instruction" | "episodic" | "semantic" | "procedural";
368
+ interface MemoryLatencyBreakdown$1 {
369
+ cache_ms: number;
370
+ embed_ms: number;
371
+ vector_ms: number;
372
+ lexical_ms: number;
373
+ merge_ms: number;
374
+ total_ms: number;
375
+ }
376
+ interface MemorySearchResult {
377
+ memory: {
378
+ id: string;
379
+ content: string;
380
+ type: string;
381
+ entities?: string[];
382
+ confidence?: number;
383
+ version?: number;
384
+ temporal?: {
385
+ document_date?: string | null;
386
+ event_date?: string | null;
387
+ valid_from?: string | null;
388
+ valid_until?: string | null;
389
+ };
390
+ };
391
+ similarity: number;
392
+ relations?: Array<Record<string, unknown>>;
393
+ chunk?: {
394
+ id: string;
395
+ content: string;
396
+ metadata?: Record<string, unknown>;
397
+ };
398
+ }
399
+ interface MemorySearchResponse$1 {
400
+ results: MemorySearchResult[];
401
+ count: number;
402
+ query: string;
403
+ trace_id?: string;
404
+ latency_ms?: number;
405
+ latency_breakdown?: MemoryLatencyBreakdown$1;
406
+ fallback?: "vector" | "lexical";
407
+ mode?: "fast" | "balanced" | "quality";
408
+ profile?: "fast" | "balanced" | "quality";
409
+ include_pending?: boolean;
410
+ pending_overlay_count?: number;
411
+ cache_hit?: boolean;
412
+ }
413
+ interface MemoryWriteAck$1 {
414
+ success: boolean;
415
+ mode?: "async" | "sync";
416
+ trace_id?: string;
417
+ job_id?: string;
418
+ status_url?: string;
419
+ accepted_at?: string;
420
+ visibility_sla_ms?: number;
421
+ pending_visibility?: boolean;
422
+ queued?: boolean;
423
+ event_id?: string;
424
+ created?: number;
425
+ errors?: string[];
426
+ }
427
+
428
+ interface MemoryModuleOptions {
429
+ defaultProject?: string;
430
+ cacheEnabled?: boolean;
431
+ queueEnabled?: boolean;
432
+ }
433
+ declare class MemoryModule {
434
+ private readonly client;
435
+ private readonly cache;
436
+ private readonly queue;
437
+ private readonly options;
438
+ constructor(client: RuntimeClient, cache: SearchResponseCache<MemorySearchResponse$1>, queue: WriteQueue, options?: MemoryModuleOptions);
439
+ private resolveProject;
440
+ private invalidate;
441
+ add(params: {
442
+ project?: string;
443
+ content: string;
444
+ memory_type?: MemoryKind$1;
445
+ user_id?: string;
446
+ session_id?: string;
447
+ agent_id?: string;
448
+ importance?: number;
449
+ confidence?: number;
450
+ metadata?: Record<string, unknown>;
451
+ document_date?: string;
452
+ event_date?: string;
453
+ write_mode?: "async" | "sync";
454
+ async?: boolean;
455
+ }): Promise<MemoryWriteAck$1>;
456
+ addBulk(params: {
457
+ project?: string;
458
+ memories: Array<{
459
+ content: string;
460
+ memory_type?: MemoryKind$1;
461
+ user_id?: string;
462
+ session_id?: string;
463
+ agent_id?: string;
464
+ importance?: number;
465
+ confidence?: number;
466
+ metadata?: Record<string, unknown>;
467
+ document_date?: string;
468
+ event_date?: string;
469
+ }>;
470
+ write_mode?: "async" | "sync";
471
+ async?: boolean;
472
+ }): Promise<MemoryWriteAck$1>;
473
+ search(params: {
474
+ project?: string;
475
+ query: string;
476
+ user_id?: string;
477
+ session_id?: string;
478
+ top_k?: number;
479
+ memory_type?: MemoryKind$1;
480
+ profile?: "fast" | "balanced" | "quality";
481
+ include_pending?: boolean;
482
+ }): Promise<MemorySearchResponse$1>;
483
+ getUserProfile(params: {
484
+ project?: string;
485
+ user_id: string;
486
+ include_pending?: boolean;
487
+ memory_types?: string;
488
+ }): Promise<{
489
+ user_id: string;
490
+ memories: Array<Record<string, unknown>>;
491
+ count: number;
492
+ }>;
493
+ getSessionMemories(params: {
494
+ project?: string;
495
+ session_id: string;
496
+ include_pending?: boolean;
497
+ limit?: number;
498
+ }): Promise<{
499
+ memories: Array<Record<string, unknown>>;
500
+ count: number;
501
+ }>;
502
+ get(memoryId: string): Promise<{
503
+ memory: Record<string, unknown>;
504
+ }>;
505
+ update(memoryId: string, params: {
506
+ content: string;
507
+ reasoning?: string;
508
+ }): Promise<{
509
+ success: boolean;
510
+ }>;
511
+ delete(memoryId: string): Promise<{
512
+ success: boolean;
513
+ deleted: string;
514
+ }>;
515
+ flag(params: {
516
+ memoryId: string;
517
+ reason: string;
518
+ severity?: "low" | "medium" | "high";
519
+ }): Promise<{
520
+ success: boolean;
521
+ }>;
522
+ }
523
+
524
+ type SessionState = "created" | "active" | "suspended" | "resumed" | "ended" | "archived";
525
+ declare class SessionModule {
526
+ private readonly memory;
527
+ private readonly defaultProject?;
528
+ private readonly sessions;
529
+ constructor(memory: MemoryModule, defaultProject?: string | undefined);
530
+ private resolveProject;
531
+ private ensure;
532
+ start(params: {
533
+ userId: string;
534
+ project?: string;
535
+ sessionId?: string;
536
+ metadata?: Record<string, unknown>;
537
+ }): Promise<{
538
+ sessionId: string;
539
+ state: SessionState;
540
+ createdAt: string;
541
+ }>;
542
+ event(params: {
543
+ sessionId: string;
544
+ type: string;
545
+ content: string;
546
+ parentEventId?: string;
547
+ metadata?: Record<string, unknown>;
548
+ }): Promise<{
549
+ success: boolean;
550
+ eventId: string;
551
+ sequence: number;
552
+ }>;
553
+ suspend(params: {
554
+ sessionId: string;
555
+ }): Promise<{
556
+ sessionId: string;
557
+ state: SessionState;
558
+ }>;
559
+ resume(params: {
560
+ sessionId: string;
561
+ }): Promise<{
562
+ sessionId: string;
563
+ state: SessionState;
564
+ }>;
565
+ end(params: {
566
+ sessionId: string;
567
+ }): Promise<{
568
+ sessionId: string;
569
+ state: SessionState;
570
+ }>;
571
+ archive(params: {
572
+ sessionId: string;
573
+ }): Promise<{
574
+ sessionId: string;
575
+ state: SessionState;
576
+ }>;
577
+ }
578
+
579
+ declare class ProfileModule {
580
+ private readonly memory;
581
+ constructor(memory: MemoryModule);
582
+ getUserProfile(params: {
583
+ project?: string;
584
+ user_id: string;
585
+ include_pending?: boolean;
586
+ memory_types?: string;
587
+ }): Promise<{
588
+ user_id: string;
589
+ memories: Array<Record<string, unknown>>;
590
+ count: number;
591
+ }>;
592
+ getSessionMemories(params: {
593
+ project?: string;
594
+ session_id: string;
595
+ include_pending?: boolean;
596
+ limit?: number;
597
+ }): Promise<{
598
+ memories: Array<Record<string, unknown>>;
599
+ count: number;
600
+ }>;
601
+ }
602
+
603
+ declare class AnalyticsModule {
604
+ private readonly diagnostics;
605
+ private readonly queue;
606
+ constructor(diagnostics: DiagnosticsStore, queue: WriteQueue);
607
+ diagnosticsSnapshot(): {
608
+ total: number;
609
+ success: number;
610
+ failure: number;
611
+ avgDurationMs: number;
612
+ lastTraceId?: string;
613
+ };
614
+ queueStatus(): WriteQueueStatus;
615
+ }
616
+
617
+ interface WhisperClientConfig {
618
+ apiKey: string;
619
+ baseUrl?: string;
620
+ project?: string;
621
+ compatMode?: CompatMode;
622
+ timeouts?: Partial<TimeoutBudgets>;
623
+ retryPolicy?: RetryPolicy;
624
+ cache?: {
625
+ enabled?: boolean;
626
+ ttlMs?: number;
627
+ capacity?: number;
628
+ };
629
+ queue?: {
630
+ enabled?: boolean;
631
+ maxBatchSize?: number;
632
+ flushIntervalMs?: number;
633
+ maxAttempts?: number;
634
+ persistence?: "memory" | "storage" | "file";
635
+ filePath?: string;
636
+ };
637
+ telemetry?: {
638
+ enabled?: boolean;
639
+ maxEntries?: number;
640
+ };
641
+ }
642
+ interface RunContext {
643
+ project?: string;
644
+ userId?: string;
645
+ sessionId?: string;
646
+ traceId?: string;
647
+ }
648
+ declare class WhisperClient {
649
+ private readonly config;
650
+ readonly diagnostics: {
651
+ getLast: (limit?: number) => ReturnType<DiagnosticsStore["getLast"]>;
652
+ subscribe: (fn: Parameters<DiagnosticsStore["subscribe"]>[0]) => ReturnType<DiagnosticsStore["subscribe"]>;
653
+ snapshot: () => ReturnType<DiagnosticsStore["snapshot"]>;
654
+ };
655
+ readonly queue: {
656
+ flush: () => Promise<void>;
657
+ status: () => ReturnType<WriteQueue["status"]>;
658
+ };
659
+ readonly memory: {
660
+ add: (params: Parameters<MemoryModule["add"]>[0]) => Promise<MemoryWriteAck$1>;
661
+ addBulk: (params: Parameters<MemoryModule["addBulk"]>[0]) => Promise<MemoryWriteAck$1>;
662
+ search: (params: Parameters<MemoryModule["search"]>[0]) => Promise<MemorySearchResponse$1>;
663
+ get: (memoryId: string) => Promise<{
664
+ memory: Record<string, unknown>;
665
+ }>;
666
+ getUserProfile: (params: Parameters<MemoryModule["getUserProfile"]>[0]) => ReturnType<MemoryModule["getUserProfile"]>;
667
+ getSessionMemories: (params: Parameters<MemoryModule["getSessionMemories"]>[0]) => ReturnType<MemoryModule["getSessionMemories"]>;
668
+ update: (memoryId: string, params: {
669
+ content: string;
670
+ reasoning?: string;
671
+ }) => Promise<{
672
+ success: boolean;
673
+ }>;
674
+ delete: (memoryId: string) => Promise<{
675
+ success: boolean;
676
+ deleted: string;
677
+ }>;
678
+ flag: (params: {
679
+ memoryId: string;
680
+ reason: string;
681
+ severity?: "low" | "medium" | "high";
682
+ }) => Promise<{
683
+ success: boolean;
684
+ }>;
685
+ };
686
+ readonly session: {
687
+ start: (params: Parameters<SessionModule["start"]>[0]) => ReturnType<SessionModule["start"]>;
688
+ event: (params: Parameters<SessionModule["event"]>[0]) => ReturnType<SessionModule["event"]>;
689
+ suspend: (params: Parameters<SessionModule["suspend"]>[0]) => ReturnType<SessionModule["suspend"]>;
690
+ resume: (params: Parameters<SessionModule["resume"]>[0]) => ReturnType<SessionModule["resume"]>;
691
+ end: (params: Parameters<SessionModule["end"]>[0]) => ReturnType<SessionModule["end"]>;
692
+ };
693
+ readonly profile: {
694
+ getUserProfile: (params: Parameters<ProfileModule["getUserProfile"]>[0]) => ReturnType<ProfileModule["getUserProfile"]>;
695
+ getSessionMemories: (params: Parameters<ProfileModule["getSessionMemories"]>[0]) => ReturnType<ProfileModule["getSessionMemories"]>;
696
+ };
697
+ readonly analytics: {
698
+ diagnosticsSnapshot: () => ReturnType<AnalyticsModule["diagnosticsSnapshot"]>;
699
+ queueStatus: () => ReturnType<AnalyticsModule["queueStatus"]>;
700
+ };
701
+ private readonly runtimeClient;
702
+ private readonly diagnosticsStore;
703
+ private readonly searchCache;
704
+ private readonly writeQueue;
705
+ private readonly memoryModule;
706
+ private readonly sessionModule;
707
+ private readonly profileModule;
708
+ private readonly analyticsModule;
709
+ constructor(config: WhisperClientConfig);
710
+ static fromEnv(overrides?: Partial<WhisperClientConfig>): WhisperClient;
711
+ withRunContext(context: RunContext): {
712
+ memory: {
713
+ add: (params: Omit<Parameters<MemoryModule["add"]>[0], "project" | "user_id" | "session_id"> & {
714
+ project?: string;
715
+ user_id?: string;
716
+ session_id?: string;
717
+ memory_type?: MemoryKind$1;
718
+ }) => Promise<MemoryWriteAck$1>;
719
+ search: (params: Omit<Parameters<MemoryModule["search"]>[0], "project" | "user_id" | "session_id"> & {
720
+ project?: string;
721
+ user_id?: string;
722
+ session_id?: string;
723
+ }) => Promise<MemorySearchResponse$1>;
724
+ };
725
+ session: {
726
+ event: (params: Omit<Parameters<SessionModule["event"]>[0], "sessionId"> & {
727
+ sessionId?: string;
728
+ }) => Promise<{
729
+ success: boolean;
730
+ eventId: string;
731
+ sequence: number;
732
+ }>;
733
+ };
734
+ queue: {
735
+ flush: () => Promise<void>;
736
+ status: () => ReturnType<WriteQueue["status"]>;
737
+ };
738
+ diagnostics: {
739
+ getLast: (limit?: number) => ReturnType<DiagnosticsStore["getLast"]>;
740
+ subscribe: (fn: Parameters<DiagnosticsStore["subscribe"]>[0]) => ReturnType<DiagnosticsStore["subscribe"]>;
741
+ snapshot: () => ReturnType<DiagnosticsStore["snapshot"]>;
742
+ };
743
+ };
744
+ shutdown(): Promise<void>;
745
+ }
746
+
185
747
  interface AgentMiddlewareConfig extends WhisperOptions {
186
748
  /**
187
749
  * Build the prompt passed to the model.
@@ -240,6 +802,98 @@ declare class WhisperAgentMiddleware {
240
802
  }
241
803
  declare function createAgentMiddleware(config: AgentMiddlewareConfig): WhisperAgentMiddleware;
242
804
 
805
+ interface LangChainMemoryAdapterOptions {
806
+ project?: string;
807
+ userId: string;
808
+ sessionId?: string;
809
+ memoryKey?: string;
810
+ topK?: number;
811
+ profile?: "fast" | "balanced" | "quality";
812
+ }
813
+ /**
814
+ * Lightweight adapter matching LangChain memory contract shape.
815
+ * Compatible with BaseMemory-style integrations:
816
+ * - loadMemoryVariables
817
+ * - saveContext
818
+ * - clear
819
+ */
820
+ declare class LangChainMemoryAdapter {
821
+ private readonly client;
822
+ private readonly options;
823
+ readonly memoryKeys: string[];
824
+ private readonly memoryKey;
825
+ constructor(client: WhisperClient, options: LangChainMemoryAdapterOptions);
826
+ loadMemoryVariables(_inputValues: Record<string, unknown>): Promise<Record<string, string>>;
827
+ saveContext(inputValues: Record<string, unknown>, outputValues: Record<string, unknown>): Promise<void>;
828
+ clear(): Promise<void>;
829
+ }
830
+ declare function createLangChainMemoryAdapter(client: WhisperClient, options: LangChainMemoryAdapterOptions): LangChainMemoryAdapter;
831
+
832
+ interface LangGraphCheckpointConfig {
833
+ configurable: {
834
+ thread_id: string;
835
+ checkpoint_ns?: string;
836
+ checkpoint_id?: string;
837
+ };
838
+ }
839
+ interface LangGraphCheckpointTuple {
840
+ config: LangGraphCheckpointConfig;
841
+ checkpoint: Record<string, unknown>;
842
+ metadata?: Record<string, unknown>;
843
+ parent_config?: LangGraphCheckpointConfig | null;
844
+ }
845
+ interface LangGraphCheckpointListOptions {
846
+ limit?: number;
847
+ before?: {
848
+ checkpointId?: string;
849
+ updatedAt?: string;
850
+ };
851
+ sort?: "asc" | "desc";
852
+ filter?: {
853
+ checkpointNs?: string;
854
+ metadata?: Record<string, unknown>;
855
+ };
856
+ }
857
+ interface LangGraphCheckpointSearchOptions {
858
+ threadId: string;
859
+ query: string;
860
+ checkpointNs?: string;
861
+ topK?: number;
862
+ includePending?: boolean;
863
+ profile?: "fast" | "balanced" | "quality";
864
+ }
865
+ interface LangGraphCheckpointAdapterOptions {
866
+ project?: string;
867
+ userIdPrefix?: string;
868
+ defaultCheckpointNs?: string;
869
+ }
870
+ /**
871
+ * LangGraph checkpoint adapter over Whisper memory APIs.
872
+ * Phase 5a: get/put/list.
873
+ * Phase 5b: checkpoint_ns fidelity, richer list/search filtering, schema-hard parsing.
874
+ */
875
+ declare class LangGraphCheckpointAdapter {
876
+ private readonly client;
877
+ private readonly localByKey;
878
+ private readonly localByThread;
879
+ private readonly options;
880
+ constructor(client: WhisperClient, options?: LangGraphCheckpointAdapterOptions);
881
+ private getUserId;
882
+ private resolveCheckpointNs;
883
+ private makeLocalKey;
884
+ private normalizeTuple;
885
+ private parseCheckpointTupleFromRow;
886
+ private upsertLocal;
887
+ private mergeWithLocal;
888
+ private applyListFilters;
889
+ private fetchThreadRecords;
890
+ get(config: LangGraphCheckpointConfig): Promise<LangGraphCheckpointTuple | undefined>;
891
+ put(config: LangGraphCheckpointConfig, checkpoint: Record<string, unknown>, metadata?: Record<string, unknown>, parentConfig?: LangGraphCheckpointConfig | null): Promise<LangGraphCheckpointConfig>;
892
+ list(config: LangGraphCheckpointConfig, options?: LangGraphCheckpointListOptions): Promise<LangGraphCheckpointTuple[]>;
893
+ search(params: LangGraphCheckpointSearchOptions): Promise<LangGraphCheckpointTuple[]>;
894
+ }
895
+ declare function createLangGraphCheckpointAdapter(client: WhisperClient, options?: LangGraphCheckpointAdapterOptions): LangGraphCheckpointAdapter;
896
+
243
897
  interface MemoryGraphNode {
244
898
  id: string;
245
899
  label?: string;
@@ -260,10 +914,6 @@ interface MemoryGraphPayload {
260
914
  */
261
915
  declare function memoryGraphToMermaid(graph: MemoryGraphPayload): string;
262
916
 
263
- /**
264
- * Whisper Context SDK
265
- * TypeScript SDK for the Whisper Context API
266
- */
267
917
  interface WhisperConfig {
268
918
  apiKey: string;
269
919
  baseUrl?: string;
@@ -355,6 +1005,62 @@ interface Source {
355
1005
  createdAt: string;
356
1006
  updatedAt: string;
357
1007
  }
1008
+ interface VideoSourceMetadata {
1009
+ source_kind: "video";
1010
+ video_url: string;
1011
+ platform: "youtube" | "loom" | "generic";
1012
+ duration_seconds?: number;
1013
+ published_at?: string;
1014
+ channel_or_author?: string;
1015
+ }
1016
+ interface VideoIngestionStatus {
1017
+ source_id: string;
1018
+ status: string;
1019
+ stage: "extracting" | "transcribing" | "segmenting" | "enriching" | "indexing" | "completed" | "failed";
1020
+ sync_job_id?: string | null;
1021
+ progress?: {
1022
+ current: number;
1023
+ total: number;
1024
+ message: string;
1025
+ } | null;
1026
+ duration_seconds?: number | null;
1027
+ chunks_indexed?: number | null;
1028
+ decisions_detected?: number | null;
1029
+ entities_extracted?: string[];
1030
+ last_error?: string | null;
1031
+ updated_at?: string;
1032
+ }
1033
+ type CanonicalSourceType = "github" | "web" | "pdf" | "local" | "slack";
1034
+ interface CanonicalSourceCreateParams {
1035
+ type: CanonicalSourceType;
1036
+ name?: string;
1037
+ auto_index?: boolean;
1038
+ metadata?: Record<string, string>;
1039
+ owner?: string;
1040
+ repo?: string;
1041
+ branch?: string;
1042
+ paths?: string[];
1043
+ url?: string;
1044
+ crawl_depth?: number;
1045
+ include_paths?: string[];
1046
+ exclude_paths?: string[];
1047
+ file_path?: string;
1048
+ path?: string;
1049
+ glob?: string;
1050
+ max_files?: number;
1051
+ workspace_id?: string;
1052
+ channel_ids?: string[];
1053
+ since?: string;
1054
+ token?: string;
1055
+ auth_ref?: string;
1056
+ }
1057
+ interface CanonicalSourceCreateResult {
1058
+ source_id: string;
1059
+ status: "queued" | "indexing" | "ready" | "failed";
1060
+ job_id: string | null;
1061
+ index_started: boolean;
1062
+ warnings: string[];
1063
+ }
358
1064
  interface Memory {
359
1065
  id: string;
360
1066
  projectId: string;
@@ -461,6 +1167,7 @@ declare class WhisperContext {
461
1167
  private defaultProject?;
462
1168
  private timeoutMs;
463
1169
  private retryConfig;
1170
+ private runtimeClient;
464
1171
  private projectRefToId;
465
1172
  private projectCache;
466
1173
  private projectCacheExpiresAt;
@@ -473,6 +1180,7 @@ declare class WhisperContext {
473
1180
  private withProjectRefFallback;
474
1181
  private classifyError;
475
1182
  private isEndpointNotFoundError;
1183
+ private inferOperation;
476
1184
  private request;
477
1185
  query(params: QueryParams): Promise<QueryResult>;
478
1186
  createProject(params: {
@@ -496,6 +1204,23 @@ declare class WhisperContext {
496
1204
  sync_schedule?: string;
497
1205
  }): Promise<Source>;
498
1206
  syncSource(sourceId: string): Promise<any>;
1207
+ addSourceByType(projectId: string, params: {
1208
+ type: "video";
1209
+ url: string;
1210
+ auto_sync?: boolean;
1211
+ tags?: string[];
1212
+ platform?: "youtube" | "loom" | "generic";
1213
+ language?: string;
1214
+ allow_stt_fallback?: boolean;
1215
+ max_duration_minutes?: number;
1216
+ name?: string;
1217
+ }): Promise<{
1218
+ source_id: string;
1219
+ sync_job_id?: string | null;
1220
+ status: "processing" | "queued" | "created";
1221
+ }>;
1222
+ getSourceStatus(sourceId: string): Promise<VideoIngestionStatus>;
1223
+ createCanonicalSource(project: string, params: CanonicalSourceCreateParams): Promise<CanonicalSourceCreateResult>;
499
1224
  ingest(projectId: string, documents: Array<{
500
1225
  id?: string;
501
1226
  title: string;
@@ -656,6 +1381,9 @@ declare class WhisperContext {
656
1381
  memories: any[];
657
1382
  count: number;
658
1383
  }>;
1384
+ getMemory(memoryId: string): Promise<{
1385
+ memory: any;
1386
+ }>;
659
1387
  getMemoryVersions(memoryId: string): Promise<{
660
1388
  memory_id: string;
661
1389
  versions: any[];
@@ -896,8 +1624,25 @@ declare class WhisperContext {
896
1624
  config: Record<string, any>;
897
1625
  sync_schedule?: string;
898
1626
  }) => Promise<Source>;
1627
+ addSource: (projectId: string, params: {
1628
+ type: "video";
1629
+ url: string;
1630
+ auto_sync?: boolean;
1631
+ tags?: string[];
1632
+ platform?: "youtube" | "loom" | "generic";
1633
+ language?: string;
1634
+ allow_stt_fallback?: boolean;
1635
+ max_duration_minutes?: number;
1636
+ name?: string;
1637
+ }) => Promise<{
1638
+ source_id: string;
1639
+ sync_job_id?: string | null;
1640
+ status: "processing" | "queued" | "created";
1641
+ }>;
899
1642
  sync: (sourceId: string) => Promise<any>;
900
1643
  syncSource: (sourceId: string) => Promise<any>;
1644
+ status: (sourceId: string) => Promise<VideoIngestionStatus>;
1645
+ getStatus: (sourceId: string) => Promise<VideoIngestionStatus>;
901
1646
  };
902
1647
  readonly memory: {
903
1648
  add: (params: Parameters<WhisperContext["addMemory"]>[0]) => Promise<{
@@ -931,6 +1676,9 @@ declare class WhisperContext {
931
1676
  memories: any[];
932
1677
  count: number;
933
1678
  }>;
1679
+ get: (memoryId: string) => Promise<{
1680
+ memory: any;
1681
+ }>;
934
1682
  getVersions: (memoryId: string) => Promise<{
935
1683
  memory_id: string;
936
1684
  versions: any[];
@@ -1036,4 +1784,4 @@ declare class WhisperContext {
1036
1784
  };
1037
1785
  }
1038
1786
 
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 };
1787
+ export { type CanonicalSourceCreateParams, type CanonicalSourceCreateResult, type CanonicalSourceType, type ExtractedMemory, LangChainMemoryAdapter, LangGraphCheckpointAdapter, type Memory, type MemoryExtractionResult, type MemoryKind, type MemoryLatencyBreakdown, type MemorySearchResponse, type MemoryWriteAck, type Project, type QueryParams, type QueryResult, type Source, type VideoIngestionStatus, type VideoSourceMetadata, Whisper, WhisperAgentMiddleware, WhisperClient, type WhisperConfig, WhisperContext, Whisper as WhisperDefault, WhisperError, type WhisperErrorCode, WhisperClient as WhisperRuntimeClient, createAgentMiddleware, createLangChainMemoryAdapter, createLangGraphCheckpointAdapter, WhisperContext as default, memoryGraphToMermaid };