@usewhisper/sdk 3.10.0 → 3.10.1

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.
@@ -0,0 +1,2434 @@
1
+ import { z } from 'zod';
2
+
3
+ type WhisperErrorCode = "INVALID_API_KEY" | "PROJECT_NOT_FOUND" | "PROJECT_AMBIGUOUS" | "RATE_LIMITED" | "TEMPORARY_UNAVAILABLE" | "NETWORK_ERROR" | "TIMEOUT" | "REQUEST_FAILED" | "MISSING_PROJECT" | "AUTH_IDENTITY_REQUIRED" | "AUTH_IDENTITY_INVALID" | "MISCONFIGURED_IDENTITY_MODE" | "VALIDATION_ERROR";
4
+ declare class WhisperError extends Error {
5
+ code: WhisperErrorCode;
6
+ status?: number;
7
+ retryable: boolean;
8
+ hint?: string;
9
+ requestId?: string;
10
+ details?: unknown;
11
+ constructor(args: {
12
+ code: WhisperErrorCode;
13
+ message: string;
14
+ status?: number;
15
+ retryable?: boolean;
16
+ hint?: string;
17
+ requestId?: string;
18
+ details?: unknown;
19
+ cause?: unknown;
20
+ });
21
+ }
22
+
23
+ type MemoryKind$1 = "factual" | "preference" | "event" | "relationship" | "opinion" | "goal" | "instruction" | "episodic" | "semantic" | "procedural";
24
+ interface MemoryLatencyBreakdown$1 {
25
+ cache_ms: number;
26
+ embed_ms: number;
27
+ vector_ms: number;
28
+ lexical_ms: number;
29
+ merge_ms: number;
30
+ total_ms: number;
31
+ }
32
+ interface MemorySearchResult {
33
+ memory: {
34
+ id: string;
35
+ content: string;
36
+ type: string;
37
+ entities?: string[];
38
+ confidence?: number;
39
+ version?: number;
40
+ temporal?: {
41
+ document_date?: string | null;
42
+ event_date?: string | null;
43
+ valid_from?: string | null;
44
+ valid_until?: string | null;
45
+ };
46
+ };
47
+ similarity: number;
48
+ relations?: Array<Record<string, unknown>>;
49
+ chunk?: {
50
+ id: string;
51
+ content: string;
52
+ metadata?: Record<string, unknown>;
53
+ };
54
+ }
55
+ interface MemorySearchResponse$1 {
56
+ results: MemorySearchResult[];
57
+ count: number;
58
+ query: string;
59
+ trace_id?: string;
60
+ latency_ms?: number;
61
+ latency_breakdown?: MemoryLatencyBreakdown$1;
62
+ fallback?: "vector" | "lexical";
63
+ mode?: "fast" | "balanced" | "quality";
64
+ profile?: "fast" | "balanced" | "quality";
65
+ include_pending?: boolean;
66
+ pending_overlay_count?: number;
67
+ cache_hit?: boolean;
68
+ }
69
+ interface MemoryWriteAck$1 {
70
+ success: boolean;
71
+ mode?: "async" | "sync";
72
+ trace_id?: string;
73
+ memory_id?: string;
74
+ job_id?: string;
75
+ status_url?: string;
76
+ accepted_at?: string;
77
+ visibility_sla_ms?: number;
78
+ pending_visibility?: boolean;
79
+ semantic_status?: "pending" | "ready";
80
+ queued?: boolean;
81
+ event_id?: string;
82
+ created?: number;
83
+ errors?: string[];
84
+ }
85
+ type LearnIngestionProfile = "auto" | "repo" | "web_docs" | "pdf_layout" | "video_transcript" | "plain_text";
86
+ type LearnStrategyOverride = "fixed" | "recursive" | "semantic" | "hierarchical" | "adaptive";
87
+ type LearnSourceType = "github" | "web" | "playwright" | "pdf" | "local" | "slack" | "video";
88
+ interface LearnConversationInput {
89
+ mode: "conversation";
90
+ project?: string;
91
+ user_id?: string;
92
+ session_id: string;
93
+ messages: Array<{
94
+ role: string;
95
+ content: string;
96
+ timestamp?: string;
97
+ }>;
98
+ }
99
+ interface LearnTextInput {
100
+ mode: "text";
101
+ project?: string;
102
+ title: string;
103
+ content: string;
104
+ metadata?: Record<string, unknown>;
105
+ tags?: string[];
106
+ namespace?: string;
107
+ options?: {
108
+ async?: boolean;
109
+ ingestion_profile?: LearnIngestionProfile;
110
+ strategy_override?: LearnStrategyOverride;
111
+ profile_config?: Record<string, unknown>;
112
+ };
113
+ }
114
+ interface LearnSourceInput {
115
+ mode: "source";
116
+ project?: string;
117
+ type: LearnSourceType;
118
+ name?: string;
119
+ metadata?: Record<string, string>;
120
+ owner?: string;
121
+ repo?: string;
122
+ branch?: string;
123
+ paths?: string[];
124
+ url?: string;
125
+ file_path?: string;
126
+ path?: string;
127
+ channel_ids?: string[];
128
+ since?: string;
129
+ token?: string;
130
+ auth_ref?: string;
131
+ platform?: "youtube" | "loom" | "generic";
132
+ language?: string;
133
+ options?: {
134
+ async?: boolean;
135
+ auto_index?: boolean;
136
+ ingestion_profile?: LearnIngestionProfile;
137
+ strategy_override?: LearnStrategyOverride;
138
+ profile_config?: Record<string, unknown>;
139
+ crawl_depth?: number;
140
+ include_paths?: string[];
141
+ exclude_paths?: string[];
142
+ glob?: string;
143
+ max_files?: number;
144
+ max_pages?: number;
145
+ extract_mode?: "text" | "structured" | "markdown";
146
+ workspace_id?: string;
147
+ allow_stt_fallback?: boolean;
148
+ max_duration_minutes?: number;
149
+ max_chunks?: number;
150
+ };
151
+ }
152
+ type LearnInput = LearnConversationInput | LearnTextInput | LearnSourceInput;
153
+ interface LearnConversationResult {
154
+ success: true;
155
+ mode: "conversation";
156
+ project: string;
157
+ scope_mode: "user_session" | "session_only";
158
+ memories_created: number;
159
+ relations_created: number;
160
+ memories_invalidated: number;
161
+ errors?: string[];
162
+ }
163
+ interface LearnTextResult {
164
+ success: true;
165
+ mode: "text";
166
+ project: string;
167
+ status: "processing" | "completed";
168
+ job_id?: string | null;
169
+ chunks_indexed?: number;
170
+ source_id?: string | null;
171
+ }
172
+ interface LearnSourceResult {
173
+ success: true;
174
+ mode: "source";
175
+ project: string;
176
+ source_id: string;
177
+ status: string;
178
+ job_id?: string | null;
179
+ index_started: boolean;
180
+ }
181
+ type LearnResult = LearnConversationResult | LearnTextResult | LearnSourceResult;
182
+
183
+ /**
184
+ * Whisper - Simple Memory Layer for AI Agents
185
+ *
186
+ * Two methods:
187
+ * - getContext(): Retrieve relevant context before LLM call
188
+ * - capture(): Extract and store memories after LLM response
189
+ *
190
+ * Zero magic - you control when to get context and when to capture
191
+ */
192
+
193
+ interface WhisperOptions extends WhisperConfig {
194
+ /**
195
+ * Maximum context results to retrieve.
196
+ * Default: 10
197
+ */
198
+ contextLimit?: number;
199
+ /**
200
+ * Which memory types to use.
201
+ * Default: all 7 types
202
+ */
203
+ memoryTypes?: Array<"factual" | "preference" | "event" | "relationship" | "opinion" | "goal" | "instruction">;
204
+ /**
205
+ * Prefix for context injection.
206
+ * Default: "Relevant context:"
207
+ */
208
+ contextPrefix?: string;
209
+ /**
210
+ * Extract structured memories before writing.
211
+ * Default: true
212
+ */
213
+ autoExtract?: boolean;
214
+ /**
215
+ * Minimum extraction confidence for auto-write.
216
+ * Default: 0.65
217
+ */
218
+ autoExtractMinConfidence?: number;
219
+ /**
220
+ * Maximum extracted memories to write per remember/capture call.
221
+ * Default: 5
222
+ */
223
+ maxMemoriesPerCapture?: number;
224
+ }
225
+ interface ContextResult {
226
+ context: string;
227
+ results: QueryResult["results"];
228
+ count: number;
229
+ }
230
+ interface RememberResult {
231
+ success: boolean;
232
+ memoryId?: string;
233
+ memoryIds?: string[];
234
+ extracted?: number;
235
+ }
236
+ /**
237
+ * Simple, transparent memory layer
238
+ *
239
+ * @example
240
+ * ```typescript
241
+ * import { Whisper } from '@usewhisper/sdk';
242
+ *
243
+ * const whisper = new Whisper({
244
+ * apiKey: process.env.WHISPER_KEY,
245
+ * project: 'my-app'
246
+ * });
247
+ *
248
+ * // BEFORE: Get relevant context
249
+ * const { context, results } = await whisper.getContext("What does user prefer?");
250
+ *
251
+ * // Inject context into your LLM prompt
252
+ * const prompt = `${context}\n\nUser: What does user prefer?`;
253
+ * const response = await llm.complete(prompt);
254
+ *
255
+ * // AFTER: Capture what happened
256
+ * await whisper.capture(response);
257
+ * // → Memories extracted & stored (async)
258
+ * ```
259
+ */
260
+ declare class Whisper {
261
+ private client;
262
+ private runtimeClient;
263
+ private options;
264
+ private sessionId?;
265
+ private userId?;
266
+ constructor(options: WhisperOptions);
267
+ /**
268
+ * Set session ID for conversation tracking
269
+ */
270
+ session(sessionId: string): this;
271
+ /**
272
+ * Set user ID for user-specific memories
273
+ */
274
+ user(userId: string): this;
275
+ /**
276
+ * Get relevant context BEFORE your LLM call
277
+ *
278
+ * @param query - What you want to know / user question
279
+ * @returns Context string and raw results
280
+ *
281
+ * @example
282
+ * ```typescript
283
+ * const { context, results, count } = await whisper.getContext(
284
+ * "What are user's preferences?",
285
+ * { userId: "user-123" }
286
+ * );
287
+ *
288
+ * // Results: [
289
+ * // { content: "User prefers dark mode", type: "preference", score: 0.95 },
290
+ * // { content: "Allergic to nuts", type: "factual", score: 0.89 }
291
+ * // ]
292
+ * ```
293
+ */
294
+ getContext(query: string, options?: {
295
+ userId?: string;
296
+ sessionId?: string;
297
+ project?: string;
298
+ limit?: number;
299
+ }): Promise<ContextResult>;
300
+ /**
301
+ * Remember what happened AFTER your LLM response
302
+ *
303
+ * Fire-and-forget - doesn't block your response
304
+ *
305
+ * @param content - What your LLM responded with
306
+ * @returns Promise that resolves when stored (or fails silently)
307
+ *
308
+ * @example
309
+ * ```typescript
310
+ * const llmResponse = "I've set your theme to dark mode and removed nuts from recommendations.";
311
+ *
312
+ * await whisper.remember(llmResponse, { userId: "user-123" });
313
+ * // → Auto-extracts: "theme set to dark mode", "nut allergy"
314
+ * // → Stored as preferences
315
+ * ```
316
+ */
317
+ remember(content: string, options?: {
318
+ userId?: string;
319
+ sessionId?: string;
320
+ project?: string;
321
+ }): Promise<RememberResult>;
322
+ /**
323
+ * Alias for remember() - same thing
324
+ */
325
+ capture(content: string, options?: {
326
+ userId?: string;
327
+ sessionId?: string;
328
+ project?: string;
329
+ }): Promise<RememberResult>;
330
+ /**
331
+ * Capture from multiple messages (e.g., full conversation)
332
+ */
333
+ captureSession(messages: Array<{
334
+ role: string;
335
+ content: string;
336
+ }>, options?: {
337
+ userId?: string;
338
+ sessionId?: string;
339
+ project?: string;
340
+ auto_learn?: boolean;
341
+ }): Promise<{
342
+ success: boolean;
343
+ extracted: number;
344
+ }>;
345
+ /**
346
+ * Run a full agent turn with automatic memory read (before) + write (after).
347
+ */
348
+ runTurn(params: {
349
+ userMessage: string;
350
+ generate: (prompt: string) => Promise<string>;
351
+ userId?: string;
352
+ sessionId?: string;
353
+ project?: string;
354
+ limit?: number;
355
+ auto_learn?: boolean;
356
+ }): Promise<{
357
+ response: string;
358
+ context: string;
359
+ count: number;
360
+ extracted: number;
361
+ }>;
362
+ learn(input: LearnInput): Promise<LearnResult>;
363
+ /**
364
+ * Direct access to WhisperContext for advanced usage
365
+ */
366
+ raw(): WhisperContext;
367
+ private extractMemoryIdsFromBulkResponse;
368
+ private fallbackCaptureViaAddMemory;
369
+ }
370
+
371
+ type CompatMode = "fallback" | "strict";
372
+ type OperationType = "search" | "writeAck" | "bulk" | "profile" | "session" | "query" | "get";
373
+ interface TimeoutBudgets {
374
+ searchMs: number;
375
+ writeAckMs: number;
376
+ bulkMs: number;
377
+ profileMs: number;
378
+ sessionMs: number;
379
+ }
380
+ interface RetryPolicy {
381
+ maxAttemptsByOperation?: Partial<Record<OperationType, number>>;
382
+ retryableStatusCodes?: number[];
383
+ retryOnNetworkError?: boolean;
384
+ maxBackoffMs?: number;
385
+ baseBackoffMs?: number;
386
+ }
387
+ interface RuntimeRequestOptions {
388
+ endpoint: string;
389
+ method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
390
+ body?: Record<string, unknown> | undefined;
391
+ headers?: Record<string, string> | undefined;
392
+ operation: OperationType;
393
+ idempotent?: boolean;
394
+ traceId?: string;
395
+ dedupeKeyExtra?: string;
396
+ }
397
+ interface RuntimeClientOptions {
398
+ apiKey: string;
399
+ baseUrl?: string;
400
+ sdkVersion?: string;
401
+ compatMode?: CompatMode;
402
+ timeouts?: Partial<TimeoutBudgets>;
403
+ retryPolicy?: RetryPolicy;
404
+ fetchImpl?: typeof fetch;
405
+ }
406
+ interface RuntimeResponse<T> {
407
+ data: T;
408
+ status: number;
409
+ traceId: string;
410
+ }
411
+ interface DiagnosticsRecord {
412
+ id: string;
413
+ startedAt: string;
414
+ endedAt: string;
415
+ traceId: string;
416
+ spanId: string;
417
+ operation: OperationType;
418
+ method: string;
419
+ endpoint: string;
420
+ status?: number;
421
+ durationMs: number;
422
+ success: boolean;
423
+ deduped?: boolean;
424
+ errorCode?: string;
425
+ errorMessage?: string;
426
+ }
427
+
428
+ type DiagnosticsSubscriber = (record: DiagnosticsRecord) => void;
429
+ declare class DiagnosticsStore {
430
+ private readonly maxEntries;
431
+ private readonly records;
432
+ private readonly subscribers;
433
+ constructor(maxEntries?: number);
434
+ add(record: DiagnosticsRecord): void;
435
+ getLast(limit?: number): DiagnosticsRecord[];
436
+ snapshot(): {
437
+ total: number;
438
+ success: number;
439
+ failure: number;
440
+ avgDurationMs: number;
441
+ lastTraceId?: string;
442
+ };
443
+ subscribe(fn: DiagnosticsSubscriber): () => void;
444
+ }
445
+
446
+ interface QueuedWrite {
447
+ eventId: string;
448
+ project: string;
449
+ userId?: string;
450
+ sessionId?: string;
451
+ payload: {
452
+ content: string;
453
+ memory_type?: string;
454
+ user_id?: string;
455
+ session_id?: string;
456
+ agent_id?: string;
457
+ importance?: number;
458
+ confidence?: number;
459
+ metadata?: Record<string, unknown>;
460
+ document_date?: string;
461
+ event_date?: string;
462
+ };
463
+ createdAt: string;
464
+ }
465
+ interface QueueStore {
466
+ load(): Promise<QueuedWrite[]>;
467
+ save(items: QueuedWrite[]): Promise<void>;
468
+ }
469
+ interface WriteQueueStatus {
470
+ queued: number;
471
+ flushing: boolean;
472
+ lastFlushAt?: string;
473
+ lastFlushCount: number;
474
+ }
475
+ type FlushHandler = (items: QueuedWrite[]) => Promise<void>;
476
+ declare class WriteQueue {
477
+ private readonly flushHandler;
478
+ private readonly store;
479
+ private readonly maxBatchSize;
480
+ private readonly flushIntervalMs;
481
+ private readonly maxAttempts;
482
+ private readonly queue;
483
+ private flushTimer;
484
+ private flushing;
485
+ private lastFlushAt?;
486
+ private lastFlushCount;
487
+ constructor(args: {
488
+ flushHandler: FlushHandler;
489
+ store?: QueueStore;
490
+ maxBatchSize?: number;
491
+ flushIntervalMs?: number;
492
+ maxAttempts?: number;
493
+ });
494
+ start(): Promise<void>;
495
+ stop(): Promise<void>;
496
+ status(): WriteQueueStatus;
497
+ enqueue(input: Omit<QueuedWrite, "eventId" | "createdAt"> & {
498
+ eventId?: string;
499
+ }): Promise<QueuedWrite>;
500
+ flush(): Promise<void>;
501
+ private makeEventId;
502
+ private bindProcessHooks;
503
+ }
504
+
505
+ declare class RuntimeClient {
506
+ private readonly apiKey;
507
+ private readonly baseUrl;
508
+ private readonly sdkVersion;
509
+ private readonly compatMode;
510
+ private readonly retryPolicy;
511
+ private readonly timeouts;
512
+ private readonly diagnostics;
513
+ private readonly inFlight;
514
+ private readonly sendApiKeyHeader;
515
+ private readonly fetchImpl;
516
+ constructor(options: RuntimeClientOptions, diagnostics?: DiagnosticsStore);
517
+ getDiagnosticsStore(): DiagnosticsStore;
518
+ getCompatMode(): CompatMode;
519
+ private timeoutFor;
520
+ private maxAttemptsFor;
521
+ private shouldRetryStatus;
522
+ private backoff;
523
+ private runtimeName;
524
+ private apiKeyOnlyPrefixes;
525
+ private shouldAttachApiKeyHeader;
526
+ private createRequestFingerprint;
527
+ request<T>(options: RuntimeRequestOptions): Promise<RuntimeResponse<T>>;
528
+ private performRequest;
529
+ }
530
+
531
+ interface SearchCacheKeyInput {
532
+ project: string;
533
+ userId?: string;
534
+ sessionId?: string;
535
+ query: string;
536
+ topK: number;
537
+ profile: string;
538
+ includePending: boolean;
539
+ }
540
+ declare class SearchResponseCache<T = unknown> {
541
+ private readonly ttlMs;
542
+ private readonly capacity;
543
+ private readonly byKey;
544
+ private readonly scopeIndex;
545
+ constructor(ttlMs?: number, capacity?: number);
546
+ makeScopeKey(project: string, userId?: string, sessionId?: string): string;
547
+ makeKey(input: SearchCacheKeyInput): string;
548
+ get(key: string): T | null;
549
+ set(key: string, scopeKey: string, value: T): void;
550
+ invalidateScope(scopeKey: string): number;
551
+ private evictIfNeeded;
552
+ private deleteByKey;
553
+ }
554
+
555
+ interface MemoryModuleOptions {
556
+ defaultProject?: string;
557
+ cacheEnabled?: boolean;
558
+ queueEnabled?: boolean;
559
+ }
560
+ declare class MemoryModule {
561
+ private readonly client;
562
+ private readonly cache;
563
+ private readonly queue;
564
+ private readonly options;
565
+ constructor(client: RuntimeClient, cache: SearchResponseCache<MemorySearchResponse$1>, queue: WriteQueue, options?: MemoryModuleOptions);
566
+ private resolveProject;
567
+ private invalidate;
568
+ add(params: {
569
+ project?: string;
570
+ content: string;
571
+ memory_type?: MemoryKind$1;
572
+ user_id?: string;
573
+ session_id?: string;
574
+ agent_id?: string;
575
+ importance?: number;
576
+ confidence?: number;
577
+ metadata?: Record<string, unknown>;
578
+ document_date?: string;
579
+ event_date?: string;
580
+ write_mode?: "async" | "sync";
581
+ async?: boolean;
582
+ }): Promise<MemoryWriteAck$1>;
583
+ addBulk(params: {
584
+ project?: string;
585
+ memories: Array<{
586
+ content: string;
587
+ memory_type?: MemoryKind$1;
588
+ user_id?: string;
589
+ session_id?: string;
590
+ agent_id?: string;
591
+ importance?: number;
592
+ confidence?: number;
593
+ metadata?: Record<string, unknown>;
594
+ document_date?: string;
595
+ event_date?: string;
596
+ }>;
597
+ write_mode?: "async" | "sync";
598
+ async?: boolean;
599
+ }): Promise<MemoryWriteAck$1>;
600
+ search(params: {
601
+ project?: string;
602
+ query: string;
603
+ user_id?: string;
604
+ session_id?: string;
605
+ top_k?: number;
606
+ memory_type?: MemoryKind$1;
607
+ profile?: "fast" | "balanced" | "quality";
608
+ include_pending?: boolean;
609
+ }): Promise<MemorySearchResponse$1>;
610
+ getUserProfile(params: {
611
+ project?: string;
612
+ user_id: string;
613
+ include_pending?: boolean;
614
+ memory_types?: string;
615
+ }): Promise<{
616
+ user_id: string;
617
+ memories: Array<Record<string, unknown>>;
618
+ count: number;
619
+ }>;
620
+ getSessionMemories(params: {
621
+ project?: string;
622
+ session_id: string;
623
+ include_pending?: boolean;
624
+ limit?: number;
625
+ }): Promise<{
626
+ memories: Array<Record<string, unknown>>;
627
+ count: number;
628
+ }>;
629
+ get(memoryId: string): Promise<{
630
+ memory: Record<string, unknown>;
631
+ }>;
632
+ update(memoryId: string, params: {
633
+ content: string;
634
+ reasoning?: string;
635
+ }): Promise<{
636
+ success: boolean;
637
+ }>;
638
+ delete(memoryId: string): Promise<{
639
+ success: boolean;
640
+ deleted: string;
641
+ }>;
642
+ flag(params: {
643
+ memoryId: string;
644
+ reason: string;
645
+ severity?: "low" | "medium" | "high";
646
+ }): Promise<{
647
+ success: boolean;
648
+ }>;
649
+ }
650
+
651
+ type SessionState = "created" | "active" | "suspended" | "resumed" | "ended" | "archived";
652
+ declare class SessionModule {
653
+ private readonly memory;
654
+ private readonly defaultProject?;
655
+ private readonly sessions;
656
+ constructor(memory: MemoryModule, defaultProject?: string | undefined);
657
+ private resolveProject;
658
+ private ensure;
659
+ start(params: {
660
+ userId: string;
661
+ project?: string;
662
+ sessionId?: string;
663
+ metadata?: Record<string, unknown>;
664
+ }): Promise<{
665
+ sessionId: string;
666
+ state: SessionState;
667
+ createdAt: string;
668
+ }>;
669
+ event(params: {
670
+ sessionId: string;
671
+ type: string;
672
+ content: string;
673
+ parentEventId?: string;
674
+ metadata?: Record<string, unknown>;
675
+ }): Promise<{
676
+ success: boolean;
677
+ eventId: string;
678
+ sequence: number;
679
+ }>;
680
+ suspend(params: {
681
+ sessionId: string;
682
+ }): Promise<{
683
+ sessionId: string;
684
+ state: SessionState;
685
+ }>;
686
+ resume(params: {
687
+ sessionId: string;
688
+ }): Promise<{
689
+ sessionId: string;
690
+ state: SessionState;
691
+ }>;
692
+ end(params: {
693
+ sessionId: string;
694
+ }): Promise<{
695
+ sessionId: string;
696
+ state: SessionState;
697
+ }>;
698
+ archive(params: {
699
+ sessionId: string;
700
+ }): Promise<{
701
+ sessionId: string;
702
+ state: SessionState;
703
+ }>;
704
+ }
705
+
706
+ declare class ProfileModule {
707
+ private readonly memory;
708
+ constructor(memory: MemoryModule);
709
+ getUserProfile(params: {
710
+ project?: string;
711
+ user_id: string;
712
+ include_pending?: boolean;
713
+ memory_types?: string;
714
+ }): Promise<{
715
+ user_id: string;
716
+ memories: Array<Record<string, unknown>>;
717
+ count: number;
718
+ }>;
719
+ getSessionMemories(params: {
720
+ project?: string;
721
+ session_id: string;
722
+ include_pending?: boolean;
723
+ limit?: number;
724
+ }): Promise<{
725
+ memories: Array<Record<string, unknown>>;
726
+ count: number;
727
+ }>;
728
+ }
729
+
730
+ declare class AnalyticsModule {
731
+ private readonly diagnostics;
732
+ private readonly queue;
733
+ constructor(diagnostics: DiagnosticsStore, queue: WriteQueue);
734
+ diagnosticsSnapshot(): {
735
+ total: number;
736
+ success: number;
737
+ failure: number;
738
+ avgDurationMs: number;
739
+ lastTraceId?: string;
740
+ };
741
+ queueStatus(): WriteQueueStatus;
742
+ }
743
+
744
+ interface AgentRunContext {
745
+ workspacePath?: string;
746
+ project?: string;
747
+ userId?: string;
748
+ sessionId?: string;
749
+ traceId?: string;
750
+ clientName?: string;
751
+ }
752
+ interface TurnInput {
753
+ userMessage: string;
754
+ taskSummary?: string;
755
+ touchedFiles?: string[];
756
+ toolContext?: string;
757
+ }
758
+ type WorkEventKind = "decision" | "constraint" | "outcome" | "failure" | "task_update" | "file_edit" | "tool_result";
759
+ type WorkEventSalience = "low" | "medium" | "high";
760
+ interface WorkEvent {
761
+ kind: WorkEventKind;
762
+ summary: string;
763
+ details?: string;
764
+ salience?: WorkEventSalience;
765
+ timestamp?: string;
766
+ filePaths?: string[];
767
+ toolName?: string;
768
+ success?: boolean;
769
+ }
770
+ interface PreparedTurn {
771
+ scope: AgentRunContext & {
772
+ project: string;
773
+ userId: string;
774
+ sessionId: string;
775
+ };
776
+ retrieval: {
777
+ primaryQuery: string;
778
+ taskFrameQuery: string | null;
779
+ warnings: string[];
780
+ degraded: boolean;
781
+ degradedReason?: string;
782
+ durationMs: number;
783
+ targetBudgetMs: number;
784
+ hardTimeoutMs: number;
785
+ branchStatus: Record<string, "ok" | "error" | "timeout" | "skipped">;
786
+ focusedScopeApplied: boolean;
787
+ focusedSourceIds: string[];
788
+ focusedFileHints: string[];
789
+ clientScoped: boolean;
790
+ fallbackUsed: boolean;
791
+ droppedBelowFloor: number;
792
+ dedupedCount: number;
793
+ };
794
+ context: string;
795
+ items: Array<{
796
+ id: string;
797
+ content: string;
798
+ type: "project" | "memory";
799
+ score: number;
800
+ sourceQuery: "primary" | "task_frame" | "bootstrap";
801
+ metadata?: Record<string, unknown>;
802
+ }>;
803
+ }
804
+ interface TurnCaptureResult {
805
+ success: boolean;
806
+ sessionIngested: boolean;
807
+ memoriesCreated: number;
808
+ relationsCreated: number;
809
+ invalidatedCount: number;
810
+ mergedCount: number;
811
+ droppedCount: number;
812
+ warnings: string[];
813
+ }
814
+ interface AgentRuntimeStatus {
815
+ clientName: string;
816
+ scope: {
817
+ project?: string;
818
+ userId?: string;
819
+ sessionId?: string;
820
+ source?: "explicit" | "workspace" | "config" | "generated";
821
+ warning?: string;
822
+ };
823
+ queue: {
824
+ queued: number;
825
+ flushing: boolean;
826
+ lastFlushAt?: string;
827
+ lastFlushCount: number;
828
+ };
829
+ retrieval: PreparedTurn["retrieval"] | null;
830
+ counters: {
831
+ mergedCount: number;
832
+ droppedCount: number;
833
+ bufferedLowSalience: number;
834
+ focusedPassHits: number;
835
+ fallbackTriggers: number;
836
+ floorDroppedCount: number;
837
+ injectedItemCount: number;
838
+ sourceScopedTurns: number;
839
+ broadScopedTurns: number;
840
+ totalTurns: number;
841
+ };
842
+ }
843
+ interface AgentRuntimeRankWeights {
844
+ focusedPassBonus?: number;
845
+ sourceMatchBonus?: number;
846
+ touchedFileBonus?: number;
847
+ clientMatchBonus?: number;
848
+ highSalienceBonus?: number;
849
+ mediumSalienceBonus?: number;
850
+ staleBroadPenalty?: number;
851
+ unrelatedClientPenalty?: number;
852
+ lowSaliencePenalty?: number;
853
+ }
854
+ interface AgentRuntimeSourceActivityOptions {
855
+ maxTurns?: number;
856
+ maxIdleMs?: number;
857
+ decayAfterTurns?: number;
858
+ decayAfterIdleMs?: number;
859
+ evictOnTaskSwitch?: boolean;
860
+ }
861
+ interface AgentRuntimeRetrievalOptions {
862
+ focusedTopK?: number;
863
+ broadTopK?: number;
864
+ minFocusedResults?: number;
865
+ minFocusedTopScore?: number;
866
+ minProjectScore?: number;
867
+ minMemoryScore?: number;
868
+ rankWeights?: AgentRuntimeRankWeights;
869
+ sourceActivity?: AgentRuntimeSourceActivityOptions;
870
+ }
871
+ interface AgentRuntimeOptions extends AgentRunContext {
872
+ topK?: number;
873
+ maxTokens?: number;
874
+ targetRetrievalMs?: number;
875
+ hardRetrievalTimeoutMs?: number;
876
+ bindingStorePath?: string;
877
+ recentWorkLimit?: number;
878
+ retrieval?: AgentRuntimeRetrievalOptions;
879
+ }
880
+ interface QueueStatus {
881
+ queued: number;
882
+ flushing: boolean;
883
+ lastFlushAt?: string;
884
+ lastFlushCount: number;
885
+ }
886
+ interface RuntimeAdapter {
887
+ resolveProject(project?: string): Promise<Project>;
888
+ query(params: QueryParams): Promise<QueryResult>;
889
+ ingestSession(params: {
890
+ project?: string;
891
+ session_id: string;
892
+ user_id?: string;
893
+ messages: Array<{
894
+ role: string;
895
+ content: string;
896
+ timestamp: string;
897
+ }>;
898
+ async?: boolean;
899
+ write_mode?: "async" | "sync";
900
+ }): Promise<{
901
+ success: boolean;
902
+ memories_created: number;
903
+ relations_created: number;
904
+ memories_invalidated: number;
905
+ errors?: string[];
906
+ } & MemoryWriteAck$1>;
907
+ getSessionMemories(params: {
908
+ project?: string;
909
+ session_id: string;
910
+ include_pending?: boolean;
911
+ limit?: number;
912
+ }): Promise<{
913
+ memories: Array<Record<string, unknown>>;
914
+ count: number;
915
+ }>;
916
+ getUserProfile(params: {
917
+ project?: string;
918
+ user_id: string;
919
+ include_pending?: boolean;
920
+ memory_types?: string;
921
+ }): Promise<{
922
+ user_id: string;
923
+ memories: Array<Record<string, unknown>>;
924
+ count: number;
925
+ }>;
926
+ searchMemories(params: {
927
+ project?: string;
928
+ query: string;
929
+ user_id?: string;
930
+ session_id?: string;
931
+ top_k?: number;
932
+ memory_type?: MemoryKind$1;
933
+ profile?: "fast" | "balanced" | "quality";
934
+ include_pending?: boolean;
935
+ }): Promise<MemorySearchResponse$1>;
936
+ addMemory(params: {
937
+ project?: string;
938
+ content: string;
939
+ memory_type?: MemoryKind$1;
940
+ user_id?: string;
941
+ session_id?: string;
942
+ importance?: number;
943
+ confidence?: number;
944
+ metadata?: Record<string, unknown>;
945
+ event_date?: string;
946
+ write_mode?: "async" | "sync";
947
+ async?: boolean;
948
+ }): Promise<MemoryWriteAck$1>;
949
+ queueStatus(): QueueStatus;
950
+ flushQueue(): Promise<void>;
951
+ }
952
+ declare class WhisperAgentRuntime {
953
+ private readonly args;
954
+ private readonly bindingStore;
955
+ private readonly focusedTopK;
956
+ private readonly broadTopK;
957
+ private readonly maxTokens;
958
+ private readonly targetRetrievalMs;
959
+ private readonly hardRetrievalTimeoutMs;
960
+ private readonly recentWorkLimit;
961
+ private readonly baseContext;
962
+ private readonly clientName;
963
+ private readonly minFocusedResults;
964
+ private readonly minFocusedTopScore;
965
+ private readonly minProjectScore;
966
+ private readonly minMemoryScore;
967
+ private readonly rankWeights;
968
+ private readonly sourceActivityOptions;
969
+ private bindings;
970
+ private touchedFiles;
971
+ private recentWork;
972
+ private recentSourceActivity;
973
+ private bufferedLowSalience;
974
+ private lastPreparedTurn;
975
+ private mergedCount;
976
+ private droppedCount;
977
+ private focusedPassHits;
978
+ private fallbackTriggers;
979
+ private floorDroppedCount;
980
+ private injectedItemCount;
981
+ private sourceScopedTurns;
982
+ private broadScopedTurns;
983
+ private totalTurns;
984
+ private currentTurn;
985
+ private lastTaskSummary;
986
+ private lastScope;
987
+ constructor(args: {
988
+ baseContext: AgentRunContext;
989
+ options: AgentRuntimeOptions;
990
+ adapter: RuntimeAdapter;
991
+ });
992
+ private getBindings;
993
+ private pushTouchedFiles;
994
+ private pushWorkEvent;
995
+ noteSourceActivity(sourceIds?: string[]): void;
996
+ private refreshTaskSummary;
997
+ private activeSourceIds;
998
+ private focusedScope;
999
+ private exactFileMetadataFilter;
1000
+ private makeTaskFrameQuery;
1001
+ private resolveScope;
1002
+ private runBranch;
1003
+ private contextItems;
1004
+ private memoryItems;
1005
+ private stableItemKey;
1006
+ private metadataStrings;
1007
+ private hasSourceMatch;
1008
+ private hasFileMatch;
1009
+ private hasClientMatch;
1010
+ private salienceAdjustment;
1011
+ private narrowFocusedMemories;
1012
+ private applyRelevanceFloor;
1013
+ private rerank;
1014
+ private buildContext;
1015
+ bootstrap(context?: Partial<AgentRunContext>): Promise<PreparedTurn>;
1016
+ beforeTurn(input: TurnInput, context?: Partial<AgentRunContext>): Promise<PreparedTurn>;
1017
+ recordWork(event: WorkEvent, context?: Partial<AgentRunContext>): Promise<MemoryWriteAck$1 | {
1018
+ success: true;
1019
+ buffered: true;
1020
+ }>;
1021
+ private resolveLearningScope;
1022
+ afterTurn(input: TurnInput & {
1023
+ assistantMessage: string;
1024
+ auto_learn?: boolean;
1025
+ }, context?: Partial<AgentRunContext>): Promise<TurnCaptureResult>;
1026
+ flush(reason?: string, context?: Partial<AgentRunContext>): Promise<AgentRuntimeStatus>;
1027
+ status(): AgentRuntimeStatus;
1028
+ }
1029
+
1030
+ type WhisperIdentityMode = "demo-local" | "app-identity";
1031
+ type WhisperEnvironment = "local" | "staging" | "production";
1032
+ interface WhisperResolvedIdentity {
1033
+ userId: string;
1034
+ sessionId?: string;
1035
+ }
1036
+ interface WhisperPreflightCheck {
1037
+ check: string;
1038
+ ok: boolean;
1039
+ message: string;
1040
+ hint?: string;
1041
+ }
1042
+ interface WhisperPreflightResult {
1043
+ ok: boolean;
1044
+ checks: WhisperPreflightCheck[];
1045
+ requestId: string;
1046
+ identityMode: WhisperIdentityMode;
1047
+ environment: WhisperEnvironment;
1048
+ }
1049
+ interface WhisperClientConfig {
1050
+ apiKey: string;
1051
+ baseUrl?: string;
1052
+ project?: string;
1053
+ identityMode?: WhisperIdentityMode;
1054
+ getIdentity?: () => WhisperResolvedIdentity | Promise<WhisperResolvedIdentity>;
1055
+ environment?: WhisperEnvironment;
1056
+ strictIdentityMode?: boolean;
1057
+ compatMode?: CompatMode;
1058
+ fetch?: typeof fetch;
1059
+ timeouts?: Partial<TimeoutBudgets>;
1060
+ retryPolicy?: RetryPolicy;
1061
+ cache?: {
1062
+ enabled?: boolean;
1063
+ ttlMs?: number;
1064
+ capacity?: number;
1065
+ };
1066
+ queue?: {
1067
+ enabled?: boolean;
1068
+ maxBatchSize?: number;
1069
+ flushIntervalMs?: number;
1070
+ maxAttempts?: number;
1071
+ persistence?: "memory" | "storage" | "file";
1072
+ filePath?: string;
1073
+ };
1074
+ telemetry?: {
1075
+ enabled?: boolean;
1076
+ maxEntries?: number;
1077
+ };
1078
+ }
1079
+ interface RunContext {
1080
+ project?: string;
1081
+ userId?: string;
1082
+ sessionId?: string;
1083
+ traceId?: string;
1084
+ }
1085
+ declare class WhisperClient {
1086
+ private readonly config;
1087
+ readonly diagnostics: {
1088
+ getLast: (limit?: number) => ReturnType<DiagnosticsStore["getLast"]>;
1089
+ subscribe: (fn: Parameters<DiagnosticsStore["subscribe"]>[0]) => ReturnType<DiagnosticsStore["subscribe"]>;
1090
+ snapshot: () => ReturnType<DiagnosticsStore["snapshot"]>;
1091
+ };
1092
+ readonly queue: {
1093
+ flush: () => Promise<void>;
1094
+ status: () => ReturnType<WriteQueue["status"]>;
1095
+ };
1096
+ readonly memory: {
1097
+ add: (params: Parameters<MemoryModule["add"]>[0]) => Promise<MemoryWriteAck$1>;
1098
+ addBulk: (params: Parameters<MemoryModule["addBulk"]>[0]) => Promise<MemoryWriteAck$1>;
1099
+ search: (params: Parameters<MemoryModule["search"]>[0]) => Promise<MemorySearchResponse$1>;
1100
+ get: (memoryId: string) => Promise<{
1101
+ memory: Record<string, unknown>;
1102
+ }>;
1103
+ getUserProfile: (params: Parameters<MemoryModule["getUserProfile"]>[0]) => ReturnType<MemoryModule["getUserProfile"]>;
1104
+ getSessionMemories: (params: Parameters<MemoryModule["getSessionMemories"]>[0]) => ReturnType<MemoryModule["getSessionMemories"]>;
1105
+ update: (memoryId: string, params: {
1106
+ content: string;
1107
+ reasoning?: string;
1108
+ }) => Promise<{
1109
+ success: boolean;
1110
+ }>;
1111
+ delete: (memoryId: string) => Promise<{
1112
+ success: boolean;
1113
+ deleted: string;
1114
+ }>;
1115
+ flag: (params: {
1116
+ memoryId: string;
1117
+ reason: string;
1118
+ severity?: "low" | "medium" | "high";
1119
+ }) => Promise<{
1120
+ success: boolean;
1121
+ }>;
1122
+ };
1123
+ readonly session: {
1124
+ start: (params: Parameters<SessionModule["start"]>[0]) => ReturnType<SessionModule["start"]>;
1125
+ event: (params: Parameters<SessionModule["event"]>[0]) => ReturnType<SessionModule["event"]>;
1126
+ suspend: (params: Parameters<SessionModule["suspend"]>[0]) => ReturnType<SessionModule["suspend"]>;
1127
+ resume: (params: Parameters<SessionModule["resume"]>[0]) => ReturnType<SessionModule["resume"]>;
1128
+ end: (params: Parameters<SessionModule["end"]>[0]) => ReturnType<SessionModule["end"]>;
1129
+ };
1130
+ readonly profile: {
1131
+ getUserProfile: (params: Parameters<ProfileModule["getUserProfile"]>[0]) => ReturnType<ProfileModule["getUserProfile"]>;
1132
+ getSessionMemories: (params: Parameters<ProfileModule["getSessionMemories"]>[0]) => ReturnType<ProfileModule["getSessionMemories"]>;
1133
+ };
1134
+ readonly analytics: {
1135
+ diagnosticsSnapshot: () => ReturnType<AnalyticsModule["diagnosticsSnapshot"]>;
1136
+ queueStatus: () => ReturnType<AnalyticsModule["queueStatus"]>;
1137
+ };
1138
+ private readonly runtimeClient;
1139
+ private readonly diagnosticsStore;
1140
+ private readonly searchCache;
1141
+ private readonly writeQueue;
1142
+ private readonly memoryModule;
1143
+ private readonly sessionModule;
1144
+ private readonly profileModule;
1145
+ private readonly analyticsModule;
1146
+ private readonly projectRefToId;
1147
+ private readonly identityMode;
1148
+ private readonly environment;
1149
+ private readonly strictIdentityMode;
1150
+ private readonly getIdentity?;
1151
+ private projectCache;
1152
+ private projectCacheExpiresAt;
1153
+ constructor(config: WhisperClientConfig);
1154
+ private enforceIdentityModeGuardrail;
1155
+ private toWhisperError;
1156
+ private runOrThrow;
1157
+ private resolveIdentityOverride;
1158
+ private withIdentity;
1159
+ private withSessionIdentity;
1160
+ static fromEnv(overrides?: Partial<WhisperClientConfig>): WhisperClient;
1161
+ private createQueueStore;
1162
+ private defaultQueuePersistence;
1163
+ private defaultQueueFilePath;
1164
+ private getRequiredProject;
1165
+ private refreshProjectCache;
1166
+ private fetchResolvedProject;
1167
+ resolveProject(projectRef?: string): Promise<Project>;
1168
+ preflight(options?: {
1169
+ project?: string;
1170
+ requireIdentity?: boolean;
1171
+ }): Promise<WhisperPreflightResult>;
1172
+ query(params: QueryParams): Promise<QueryResult>;
1173
+ ingestSession(params: {
1174
+ project?: string;
1175
+ session_id: string;
1176
+ user_id?: string;
1177
+ messages: Array<{
1178
+ role: string;
1179
+ content: string;
1180
+ timestamp: string;
1181
+ }>;
1182
+ async?: boolean;
1183
+ write_mode?: "async" | "sync";
1184
+ }): Promise<{
1185
+ success: boolean;
1186
+ memories_created: number;
1187
+ relations_created: number;
1188
+ memories_invalidated: number;
1189
+ errors?: string[];
1190
+ } & MemoryWriteAck$1>;
1191
+ learn(params: LearnInput): Promise<LearnResult>;
1192
+ createAgentRuntime(options?: AgentRuntimeOptions): WhisperAgentRuntime;
1193
+ withRunContext(context: RunContext): {
1194
+ memory: {
1195
+ add: (params: Omit<Parameters<MemoryModule["add"]>[0], "project" | "user_id" | "session_id"> & {
1196
+ project?: string;
1197
+ user_id?: string;
1198
+ session_id?: string;
1199
+ memory_type?: MemoryKind$1;
1200
+ }) => Promise<MemoryWriteAck$1>;
1201
+ search: (params: Omit<Parameters<MemoryModule["search"]>[0], "project" | "user_id" | "session_id"> & {
1202
+ project?: string;
1203
+ user_id?: string;
1204
+ session_id?: string;
1205
+ }) => Promise<MemorySearchResponse$1>;
1206
+ };
1207
+ session: {
1208
+ event: (params: Omit<Parameters<SessionModule["event"]>[0], "sessionId"> & {
1209
+ sessionId?: string;
1210
+ }) => Promise<{
1211
+ success: boolean;
1212
+ eventId: string;
1213
+ sequence: number;
1214
+ }>;
1215
+ };
1216
+ learn: (params: LearnInput) => Promise<LearnResult>;
1217
+ queue: {
1218
+ flush: () => Promise<void>;
1219
+ status: () => ReturnType<WriteQueue["status"]>;
1220
+ };
1221
+ diagnostics: {
1222
+ getLast: (limit?: number) => ReturnType<DiagnosticsStore["getLast"]>;
1223
+ subscribe: (fn: Parameters<DiagnosticsStore["subscribe"]>[0]) => ReturnType<DiagnosticsStore["subscribe"]>;
1224
+ snapshot: () => ReturnType<DiagnosticsStore["snapshot"]>;
1225
+ };
1226
+ };
1227
+ deleteSource(sourceId: string): Promise<{
1228
+ deleted: boolean;
1229
+ id: string;
1230
+ restore_until: string;
1231
+ }>;
1232
+ extractMemories(params: {
1233
+ project: string;
1234
+ message: string;
1235
+ }): Promise<{
1236
+ explicit: unknown[];
1237
+ implicit: unknown[];
1238
+ all: unknown[];
1239
+ }>;
1240
+ shutdown(): Promise<void>;
1241
+ }
1242
+
1243
+ interface AgentMiddlewareConfig extends WhisperOptions {
1244
+ /**
1245
+ * Build the prompt passed to the model.
1246
+ */
1247
+ promptBuilder?: (params: {
1248
+ context: string;
1249
+ userMessage: string;
1250
+ }) => string;
1251
+ }
1252
+ interface AgentTurnParams {
1253
+ userMessage: string;
1254
+ userId?: string;
1255
+ sessionId?: string;
1256
+ project?: string;
1257
+ contextLimit?: number;
1258
+ auto_learn?: boolean;
1259
+ }
1260
+ interface AgentTurnResult {
1261
+ prompt: string;
1262
+ context: string;
1263
+ contextCount: number;
1264
+ }
1265
+ interface WrappedGenerateResult {
1266
+ response: string;
1267
+ prompt: string;
1268
+ context: string;
1269
+ contextCount: number;
1270
+ extracted: number;
1271
+ }
1272
+ /**
1273
+ * Drop-in middleware for existing AI agents.
1274
+ *
1275
+ * Typical flow:
1276
+ * 1) beforeTurn -> retrieve context
1277
+ * 2) call your model
1278
+ * 3) afterTurn -> store memories
1279
+ */
1280
+ declare class WhisperAgentMiddleware {
1281
+ private readonly whisper;
1282
+ private readonly promptBuilder;
1283
+ constructor(config: AgentMiddlewareConfig);
1284
+ beforeTurn(params: AgentTurnParams): Promise<AgentTurnResult>;
1285
+ afterTurn(params: {
1286
+ userMessage: string;
1287
+ assistantMessage: string;
1288
+ userId?: string;
1289
+ sessionId?: string;
1290
+ project?: string;
1291
+ auto_learn?: boolean;
1292
+ }): Promise<{
1293
+ success: boolean;
1294
+ extracted: number;
1295
+ }>;
1296
+ wrapGenerate(params: AgentTurnParams & {
1297
+ generate: (prompt: string) => Promise<string>;
1298
+ }): Promise<WrappedGenerateResult>;
1299
+ raw(): Whisper;
1300
+ }
1301
+ declare function createAgentMiddleware(config: AgentMiddlewareConfig): WhisperAgentMiddleware;
1302
+
1303
+ interface LangChainMemoryAdapterOptions {
1304
+ project?: string;
1305
+ userId: string;
1306
+ sessionId?: string;
1307
+ memoryKey?: string;
1308
+ topK?: number;
1309
+ profile?: "fast" | "balanced" | "quality";
1310
+ }
1311
+ /**
1312
+ * Lightweight adapter matching LangChain memory contract shape.
1313
+ * Compatible with BaseMemory-style integrations:
1314
+ * - loadMemoryVariables
1315
+ * - saveContext
1316
+ * - clear
1317
+ */
1318
+ declare class LangChainMemoryAdapter {
1319
+ private readonly client;
1320
+ private readonly options;
1321
+ readonly memoryKeys: string[];
1322
+ private readonly memoryKey;
1323
+ constructor(client: WhisperClient, options: LangChainMemoryAdapterOptions);
1324
+ loadMemoryVariables(_inputValues: Record<string, unknown>): Promise<Record<string, string>>;
1325
+ saveContext(inputValues: Record<string, unknown>, outputValues: Record<string, unknown>): Promise<void>;
1326
+ clear(): Promise<void>;
1327
+ }
1328
+ declare function createLangChainMemoryAdapter(client: WhisperClient, options: LangChainMemoryAdapterOptions): LangChainMemoryAdapter;
1329
+
1330
+ interface LangGraphCheckpointConfig {
1331
+ configurable: {
1332
+ thread_id: string;
1333
+ checkpoint_ns?: string;
1334
+ checkpoint_id?: string;
1335
+ };
1336
+ }
1337
+ interface LangGraphCheckpointTuple {
1338
+ config: LangGraphCheckpointConfig;
1339
+ checkpoint: Record<string, unknown>;
1340
+ metadata?: Record<string, unknown>;
1341
+ parent_config?: LangGraphCheckpointConfig | null;
1342
+ }
1343
+ interface LangGraphCheckpointListOptions {
1344
+ limit?: number;
1345
+ before?: {
1346
+ checkpointId?: string;
1347
+ updatedAt?: string;
1348
+ };
1349
+ sort?: "asc" | "desc";
1350
+ filter?: {
1351
+ checkpointNs?: string;
1352
+ metadata?: Record<string, unknown>;
1353
+ };
1354
+ }
1355
+ interface LangGraphCheckpointSearchOptions {
1356
+ threadId: string;
1357
+ query: string;
1358
+ checkpointNs?: string;
1359
+ topK?: number;
1360
+ includePending?: boolean;
1361
+ profile?: "fast" | "balanced" | "quality";
1362
+ }
1363
+ interface LangGraphCheckpointAdapterOptions {
1364
+ project?: string;
1365
+ userIdPrefix?: string;
1366
+ defaultCheckpointNs?: string;
1367
+ }
1368
+ /**
1369
+ * LangGraph checkpoint adapter over Whisper memory APIs.
1370
+ * Phase 5a: get/put/list.
1371
+ * Phase 5b: checkpoint_ns fidelity, richer list/search filtering, schema-hard parsing.
1372
+ */
1373
+ declare class LangGraphCheckpointAdapter {
1374
+ private readonly client;
1375
+ private readonly localByKey;
1376
+ private readonly localByThread;
1377
+ private readonly options;
1378
+ constructor(client: WhisperClient, options?: LangGraphCheckpointAdapterOptions);
1379
+ private getUserId;
1380
+ private resolveCheckpointNs;
1381
+ private makeLocalKey;
1382
+ private normalizeTuple;
1383
+ private parseCheckpointTupleFromRow;
1384
+ private upsertLocal;
1385
+ private mergeWithLocal;
1386
+ private applyListFilters;
1387
+ private fetchThreadRecords;
1388
+ get(config: LangGraphCheckpointConfig): Promise<LangGraphCheckpointTuple | undefined>;
1389
+ put(config: LangGraphCheckpointConfig, checkpoint: Record<string, unknown>, metadata?: Record<string, unknown>, parentConfig?: LangGraphCheckpointConfig | null): Promise<LangGraphCheckpointConfig>;
1390
+ list(config: LangGraphCheckpointConfig, options?: LangGraphCheckpointListOptions): Promise<LangGraphCheckpointTuple[]>;
1391
+ search(params: LangGraphCheckpointSearchOptions): Promise<LangGraphCheckpointTuple[]>;
1392
+ }
1393
+ declare function createLangGraphCheckpointAdapter(client: WhisperClient, options?: LangGraphCheckpointAdapterOptions): LangGraphCheckpointAdapter;
1394
+
1395
+ interface WithWhisperOptions extends Partial<Omit<WhisperClientConfig, "apiKey">> {
1396
+ apiKey?: string;
1397
+ client?: WhisperClient;
1398
+ project?: string;
1399
+ topK?: number;
1400
+ contextPrefix?: string;
1401
+ bestEffort?: boolean;
1402
+ warn?: (message: string) => void;
1403
+ }
1404
+ /**
1405
+ * Framework adapter that augments model inputs with Whisper context.
1406
+ * Works with model objects exposing `generate` / `stream` / `doGenerate` / `doStream`.
1407
+ */
1408
+ declare function withWhisper<T extends Record<string, unknown> | ((...args: any[]) => any)>(model: T, options?: WithWhisperOptions): T;
1409
+
1410
+ interface WhisperToolsOptions extends Partial<Omit<WhisperClientConfig, "apiKey">> {
1411
+ apiKey?: string;
1412
+ client?: WhisperClient;
1413
+ project?: string;
1414
+ searchTopK?: number;
1415
+ }
1416
+ interface WhisperToolDefinition<TInput, TResult> {
1417
+ description: string;
1418
+ inputSchema: z.ZodType<TInput>;
1419
+ execute: (input: TInput) => Promise<TResult>;
1420
+ }
1421
+ type SearchInput = {
1422
+ q: string;
1423
+ project?: string;
1424
+ topK?: number;
1425
+ userId?: string;
1426
+ sessionId?: string;
1427
+ };
1428
+ type RememberInput = {
1429
+ content: string;
1430
+ project?: string;
1431
+ memoryType?: "factual" | "preference" | "event" | "relationship" | "opinion" | "goal" | "instruction";
1432
+ userId?: string;
1433
+ sessionId?: string;
1434
+ metadata?: Record<string, unknown>;
1435
+ };
1436
+ declare function whisperTools(config?: WhisperToolsOptions): {
1437
+ whisper_search: WhisperToolDefinition<SearchInput, {
1438
+ context: string;
1439
+ total: number;
1440
+ results: Array<{
1441
+ id: string;
1442
+ score: number;
1443
+ source: string;
1444
+ snippet: string;
1445
+ }>;
1446
+ }>;
1447
+ whisper_remember: WhisperToolDefinition<RememberInput, {
1448
+ success: boolean;
1449
+ }>;
1450
+ whisper_preflight: WhisperToolDefinition<{
1451
+ project?: string;
1452
+ requireIdentity?: boolean;
1453
+ }, WhisperPreflightResult>;
1454
+ };
1455
+
1456
+ type ChatMessage = {
1457
+ role: string;
1458
+ content: unknown;
1459
+ };
1460
+ type ChatCompletionPayload = {
1461
+ model?: string;
1462
+ messages?: ChatMessage[];
1463
+ user?: string;
1464
+ [key: string]: unknown;
1465
+ };
1466
+ type MemoryRouterFallbackReason = "none" | "no_user_prompt" | "memory_query_failed";
1467
+ interface MemoryRouterTrace {
1468
+ providerUrl: string;
1469
+ requestId: string;
1470
+ usedMemory: boolean;
1471
+ fallbackReason: MemoryRouterFallbackReason;
1472
+ providerStatus?: number;
1473
+ model?: string;
1474
+ }
1475
+ interface MemoryRouterResult<T = unknown> {
1476
+ status: number;
1477
+ data: T;
1478
+ trace: MemoryRouterTrace;
1479
+ }
1480
+ interface MemoryRouterConfig extends Partial<Omit<WhisperClientConfig, "apiKey">> {
1481
+ apiKey?: string;
1482
+ client?: WhisperClient;
1483
+ project?: string;
1484
+ providerBaseUrl: string;
1485
+ providerApiKey?: string;
1486
+ providerHeaders?: Record<string, string>;
1487
+ routePath?: string;
1488
+ beta?: boolean;
1489
+ bestEffort?: boolean;
1490
+ contextPrefix?: string;
1491
+ logger?: (trace: MemoryRouterTrace) => void;
1492
+ }
1493
+ declare class WhisperMemoryRouter {
1494
+ private readonly config;
1495
+ private readonly providerUrl;
1496
+ private readonly fetchImpl;
1497
+ private client;
1498
+ private lastTrace;
1499
+ constructor(config: MemoryRouterConfig);
1500
+ private getClient;
1501
+ getLastTrace(): MemoryRouterTrace | null;
1502
+ chatCompletions<T = unknown>(payload: ChatCompletionPayload): Promise<MemoryRouterResult<T>>;
1503
+ }
1504
+ declare function createMemoryRouter(config: MemoryRouterConfig): WhisperMemoryRouter;
1505
+
1506
+ interface MemoryGraphNode {
1507
+ id: string;
1508
+ label?: string;
1509
+ memory_type?: string;
1510
+ }
1511
+ interface MemoryGraphEdge {
1512
+ source: string;
1513
+ target: string;
1514
+ type?: string;
1515
+ }
1516
+ interface MemoryGraphPayload {
1517
+ nodes: MemoryGraphNode[];
1518
+ edges: MemoryGraphEdge[];
1519
+ }
1520
+ /**
1521
+ * Convert memory graph payload to Mermaid flowchart syntax.
1522
+ * Useful for quick visualization in docs/dashboards.
1523
+ */
1524
+ declare function memoryGraphToMermaid(graph: MemoryGraphPayload): string;
1525
+
1526
+ interface WhisperConfig {
1527
+ apiKey: string;
1528
+ baseUrl?: string;
1529
+ project?: string;
1530
+ timeoutMs?: number;
1531
+ retry?: {
1532
+ maxAttempts?: number;
1533
+ baseDelayMs?: number;
1534
+ maxDelayMs?: number;
1535
+ };
1536
+ }
1537
+ interface QueryParams {
1538
+ project?: string;
1539
+ query: string;
1540
+ top_k?: number;
1541
+ threshold?: number;
1542
+ chunk_types?: string[];
1543
+ source_ids?: string[];
1544
+ metadata_filter?: Record<string, any>;
1545
+ hybrid?: boolean;
1546
+ vector_weight?: number;
1547
+ bm25_weight?: number;
1548
+ rerank?: boolean;
1549
+ include_memories?: boolean;
1550
+ user_id?: string;
1551
+ session_id?: string;
1552
+ agent_id?: string;
1553
+ include_graph?: boolean;
1554
+ graph_depth?: number;
1555
+ max_tokens?: number;
1556
+ compress?: boolean;
1557
+ compression_strategy?: "summarize" | "extract" | "delta" | "adaptive";
1558
+ use_cache?: boolean;
1559
+ include_parent_content?: boolean;
1560
+ retrieval_profile?: "legacy" | "precision_v1";
1561
+ }
1562
+ interface QueryResult {
1563
+ results: Array<{
1564
+ id: string;
1565
+ content: string;
1566
+ score: number;
1567
+ metadata: Record<string, any>;
1568
+ source: string;
1569
+ document: string;
1570
+ type: string;
1571
+ retrieval_source: string;
1572
+ }>;
1573
+ context: string;
1574
+ meta: {
1575
+ query: string;
1576
+ total: number;
1577
+ latency_ms: number;
1578
+ cache_hit: boolean;
1579
+ tokens_used: number;
1580
+ context_hash: string;
1581
+ source_scope?: {
1582
+ mode: "none" | "explicit" | "auto";
1583
+ source_ids: string[];
1584
+ host?: string;
1585
+ matched_sources?: number;
1586
+ };
1587
+ profile?: string;
1588
+ retrieval_profile?: "legacy" | "precision_v1";
1589
+ compression?: any;
1590
+ timing?: {
1591
+ cache_check_ms?: number;
1592
+ embed_ms?: number;
1593
+ vector_ms?: number;
1594
+ fts_ms?: number;
1595
+ rerank_ms?: number;
1596
+ enrich_ms?: number;
1597
+ pack_ms?: number;
1598
+ cache_set_ms?: number;
1599
+ total_ms?: number;
1600
+ [key: string]: number | undefined;
1601
+ };
1602
+ };
1603
+ }
1604
+ interface Project {
1605
+ id: string;
1606
+ orgId: string;
1607
+ name: string;
1608
+ slug: string;
1609
+ description?: string;
1610
+ settings?: Record<string, any>;
1611
+ createdAt: string;
1612
+ updatedAt: string;
1613
+ }
1614
+ interface Source {
1615
+ id: string;
1616
+ projectId: string;
1617
+ name: string;
1618
+ connectorType: string;
1619
+ config: Record<string, any>;
1620
+ status: string;
1621
+ syncSchedule?: string;
1622
+ lastSyncAt?: string;
1623
+ syncError?: string;
1624
+ createdAt: string;
1625
+ updatedAt: string;
1626
+ }
1627
+ interface VideoSourceMetadata {
1628
+ source_kind: "video";
1629
+ video_url: string;
1630
+ platform: "youtube" | "loom" | "generic";
1631
+ duration_seconds?: number;
1632
+ published_at?: string;
1633
+ channel_or_author?: string;
1634
+ }
1635
+ interface VideoIngestionStatus {
1636
+ source_id: string;
1637
+ status: string;
1638
+ stage: "extracting" | "transcribing" | "segmenting" | "enriching" | "indexing" | "completed" | "failed";
1639
+ sync_job_id?: string | null;
1640
+ progress?: {
1641
+ current: number;
1642
+ total: number;
1643
+ message: string;
1644
+ } | null;
1645
+ duration_seconds?: number | null;
1646
+ chunks_indexed?: number | null;
1647
+ decisions_detected?: number | null;
1648
+ entities_extracted?: string[];
1649
+ last_error?: string | null;
1650
+ updated_at?: string;
1651
+ }
1652
+ type CanonicalSourceType = "github" | "web" | "playwright" | "pdf" | "local" | "slack" | "video";
1653
+ interface CanonicalSourceCreateParams {
1654
+ type: CanonicalSourceType;
1655
+ name?: string;
1656
+ auto_index?: boolean;
1657
+ metadata?: Record<string, string>;
1658
+ ingestion_profile?: "auto" | "repo" | "web_docs" | "pdf_layout" | "video_transcript" | "plain_text";
1659
+ strategy_override?: "fixed" | "recursive" | "semantic" | "hierarchical" | "adaptive";
1660
+ profile_config?: Record<string, any>;
1661
+ owner?: string;
1662
+ repo?: string;
1663
+ branch?: string;
1664
+ paths?: string[];
1665
+ url?: string;
1666
+ crawl_depth?: number;
1667
+ include_paths?: string[];
1668
+ exclude_paths?: string[];
1669
+ file_path?: string;
1670
+ path?: string;
1671
+ glob?: string;
1672
+ max_files?: number;
1673
+ max_pages?: number;
1674
+ extract_mode?: "text" | "structured" | "markdown";
1675
+ workspace_id?: string;
1676
+ channel_ids?: string[];
1677
+ since?: string;
1678
+ token?: string;
1679
+ auth_ref?: string;
1680
+ platform?: "youtube" | "loom" | "generic";
1681
+ language?: string;
1682
+ allow_stt_fallback?: boolean;
1683
+ max_duration_minutes?: number;
1684
+ max_chunks?: number;
1685
+ }
1686
+ interface CanonicalSourceCreateResult {
1687
+ source_id: string;
1688
+ status: "queued" | "indexing" | "ready" | "failed";
1689
+ job_id: string | null;
1690
+ index_started: boolean;
1691
+ warnings: string[];
1692
+ }
1693
+ interface Memory {
1694
+ id: string;
1695
+ projectId: string;
1696
+ content: string;
1697
+ memoryType: "factual" | "episodic" | "semantic" | "procedural";
1698
+ userId?: string;
1699
+ sessionId?: string;
1700
+ agentId?: string;
1701
+ importance: number;
1702
+ metadata: Record<string, any>;
1703
+ accessCount: number;
1704
+ createdAt: string;
1705
+ updatedAt: string;
1706
+ }
1707
+ type MemoryKind = "factual" | "preference" | "event" | "relationship" | "opinion" | "goal" | "instruction";
1708
+ interface ExtractedMemory {
1709
+ content: string;
1710
+ memoryType: MemoryKind;
1711
+ entityMentions: string[];
1712
+ eventDate: string | null;
1713
+ confidence: number;
1714
+ reasoning?: string;
1715
+ inferred?: boolean;
1716
+ }
1717
+ interface MemoryExtractionResult {
1718
+ explicit: ExtractedMemory[];
1719
+ implicit: ExtractedMemory[];
1720
+ all: ExtractedMemory[];
1721
+ extractionMethod: "pattern" | "inference" | "hybrid" | "skipped";
1722
+ latencyMs: number;
1723
+ }
1724
+ interface MemoryLatencyBreakdown {
1725
+ cache_ms: number;
1726
+ embed_ms: number;
1727
+ vector_ms: number;
1728
+ lexical_ms: number;
1729
+ merge_ms: number;
1730
+ total_ms: number;
1731
+ }
1732
+ interface MemorySearchResponse {
1733
+ results: Array<{
1734
+ memory: {
1735
+ id: string;
1736
+ content: string;
1737
+ type: string;
1738
+ entities?: string[];
1739
+ confidence?: number;
1740
+ version?: number;
1741
+ temporal?: {
1742
+ document_date?: string | null;
1743
+ event_date?: string | null;
1744
+ valid_from?: string | null;
1745
+ valid_until?: string | null;
1746
+ };
1747
+ };
1748
+ chunk?: {
1749
+ id: string;
1750
+ content: string;
1751
+ metadata?: Record<string, any>;
1752
+ };
1753
+ similarity: number;
1754
+ relations?: any[];
1755
+ }>;
1756
+ count: number;
1757
+ query: string;
1758
+ trace_id?: string;
1759
+ question_date?: string;
1760
+ latency_ms?: number;
1761
+ latency_breakdown?: MemoryLatencyBreakdown;
1762
+ fallback?: "vector" | "lexical";
1763
+ mode?: "fast" | "balanced" | "quality";
1764
+ profile?: "fast" | "balanced" | "quality";
1765
+ include_pending?: boolean;
1766
+ pending_overlay_count?: number;
1767
+ }
1768
+ interface MemoryWriteAck {
1769
+ success: boolean;
1770
+ mode?: "async" | "sync";
1771
+ trace_id?: string;
1772
+ job_id?: string;
1773
+ status_url?: string;
1774
+ accepted_at?: string;
1775
+ visibility_sla_ms?: number;
1776
+ pending_visibility?: boolean;
1777
+ [key: string]: any;
1778
+ }
1779
+ interface MemoryWriteResult {
1780
+ id: string;
1781
+ success: boolean;
1782
+ path: "sota" | "legacy";
1783
+ fallback_used: boolean;
1784
+ mode?: "async" | "sync";
1785
+ memory_id?: string;
1786
+ job_id?: string;
1787
+ status_url?: string;
1788
+ accepted_at?: string;
1789
+ visibility_sla_ms?: number;
1790
+ pending_visibility?: boolean;
1791
+ semantic_status?: "pending" | "ready";
1792
+ }
1793
+ declare class WhisperContext {
1794
+ private apiKey;
1795
+ private baseUrl;
1796
+ private defaultProject?;
1797
+ private timeoutMs;
1798
+ private retryConfig;
1799
+ private runtimeClient;
1800
+ private projectRefToId;
1801
+ private projectCache;
1802
+ private projectCacheExpiresAt;
1803
+ constructor(config: WhisperConfig);
1804
+ withProject(project: string): WhisperContext;
1805
+ private getRequiredProject;
1806
+ private refreshProjectCache;
1807
+ private fetchResolvedProject;
1808
+ resolveProject(projectRef?: string): Promise<Project>;
1809
+ private resolveProjectId;
1810
+ private getProjectRefCandidates;
1811
+ private withProjectRefFallback;
1812
+ private shouldRetryWithResolvedProjectId;
1813
+ private withProjectPathFallback;
1814
+ private classifyError;
1815
+ private isEndpointNotFoundError;
1816
+ private inferOperation;
1817
+ private request;
1818
+ query(params: QueryParams): Promise<QueryResult>;
1819
+ createProject(params: {
1820
+ name: string;
1821
+ description?: string;
1822
+ settings?: Record<string, any>;
1823
+ }): Promise<Project>;
1824
+ listProjects(): Promise<{
1825
+ projects: Project[];
1826
+ }>;
1827
+ getProject(id: string): Promise<Project & {
1828
+ sources: Source[];
1829
+ }>;
1830
+ listSources(project?: string): Promise<{
1831
+ project: {
1832
+ id: string;
1833
+ name: string;
1834
+ slug: string;
1835
+ };
1836
+ sources: Source[];
1837
+ }>;
1838
+ deleteProject(id: string): Promise<{
1839
+ deleted: boolean;
1840
+ }>;
1841
+ addSource(projectId: string, params: {
1842
+ name: string;
1843
+ connector_type: string;
1844
+ config: Record<string, any>;
1845
+ sync_schedule?: string;
1846
+ }): Promise<Source>;
1847
+ syncSource(sourceId: string): Promise<any>;
1848
+ addSourceByType(projectId: string, params: {
1849
+ type: "video";
1850
+ url: string;
1851
+ auto_sync?: boolean;
1852
+ tags?: string[];
1853
+ platform?: "youtube" | "loom" | "generic";
1854
+ language?: string;
1855
+ allow_stt_fallback?: boolean;
1856
+ max_duration_minutes?: number;
1857
+ name?: string;
1858
+ ingestion_profile?: "auto" | "repo" | "web_docs" | "pdf_layout" | "video_transcript" | "plain_text";
1859
+ strategy_override?: "fixed" | "recursive" | "semantic" | "hierarchical" | "adaptive";
1860
+ profile_config?: Record<string, any>;
1861
+ }): Promise<{
1862
+ source_id: string;
1863
+ sync_job_id?: string | null;
1864
+ status: "processing" | "queued" | "created";
1865
+ }>;
1866
+ getSourceStatus(sourceId: string): Promise<VideoIngestionStatus>;
1867
+ createCanonicalSource(project: string, params: CanonicalSourceCreateParams): Promise<CanonicalSourceCreateResult>;
1868
+ ingest(projectId: string, documents: Array<{
1869
+ id?: string;
1870
+ title: string;
1871
+ content: string;
1872
+ metadata?: Record<string, any>;
1873
+ file_path?: string;
1874
+ ingestion_profile?: "auto" | "repo" | "web_docs" | "pdf_layout" | "video_transcript" | "plain_text";
1875
+ strategy_override?: "fixed" | "recursive" | "semantic" | "hierarchical" | "adaptive";
1876
+ profile_config?: Record<string, any>;
1877
+ }>): Promise<{
1878
+ ingested: number;
1879
+ }>;
1880
+ addContext(params: {
1881
+ project?: string;
1882
+ content: string;
1883
+ title?: string;
1884
+ metadata?: Record<string, any>;
1885
+ }): Promise<{
1886
+ ingested: number;
1887
+ }>;
1888
+ learn(params: LearnInput): Promise<LearnResult>;
1889
+ listMemories(params: {
1890
+ project?: string;
1891
+ user_id?: string;
1892
+ session_id?: string;
1893
+ agent_id?: string;
1894
+ limit?: number;
1895
+ }): Promise<{
1896
+ memories: any[];
1897
+ }>;
1898
+ addMemory(params: {
1899
+ project?: string;
1900
+ content: string;
1901
+ memory_type?: "factual" | "episodic" | "semantic" | "procedural" | "preference" | "event" | "relationship" | "opinion" | "goal" | "instruction";
1902
+ user_id?: string;
1903
+ session_id?: string;
1904
+ agent_id?: string;
1905
+ importance?: number;
1906
+ metadata?: Record<string, any>;
1907
+ expires_in_seconds?: number;
1908
+ async?: boolean;
1909
+ write_mode?: "async" | "sync";
1910
+ allow_legacy_fallback?: boolean;
1911
+ }): Promise<MemoryWriteResult>;
1912
+ addMemoriesBulk(params: {
1913
+ project?: string;
1914
+ memories: Array<{
1915
+ content: string;
1916
+ memory_type?: MemoryKind | "episodic" | "semantic" | "procedural";
1917
+ user_id?: string;
1918
+ session_id?: string;
1919
+ agent_id?: string;
1920
+ importance?: number;
1921
+ confidence?: number;
1922
+ metadata?: Record<string, any>;
1923
+ entity_mentions?: string[];
1924
+ document_date?: string;
1925
+ event_date?: string;
1926
+ }>;
1927
+ namespace?: string;
1928
+ tags?: string[];
1929
+ async?: boolean;
1930
+ write_mode?: "async" | "sync";
1931
+ webhook_url?: string;
1932
+ }): Promise<any>;
1933
+ extractMemories(params: {
1934
+ project?: string;
1935
+ message: string;
1936
+ context?: string;
1937
+ session_id?: string;
1938
+ user_id?: string;
1939
+ enable_pattern?: boolean;
1940
+ enable_inference?: boolean;
1941
+ min_confidence?: number;
1942
+ }): Promise<MemoryExtractionResult>;
1943
+ extractSessionMemories(params: {
1944
+ project?: string;
1945
+ user_id?: string;
1946
+ messages: Array<{
1947
+ role: "user" | "assistant" | "system";
1948
+ content: string;
1949
+ timestamp?: string;
1950
+ }>;
1951
+ enable_pattern?: boolean;
1952
+ enable_inference?: boolean;
1953
+ }): Promise<{
1954
+ memories: ExtractedMemory[];
1955
+ count: number;
1956
+ latencyMs: number;
1957
+ }>;
1958
+ searchMemories(params: {
1959
+ project?: string;
1960
+ query: string;
1961
+ user_id?: string;
1962
+ session_id?: string;
1963
+ agent_id?: string;
1964
+ memory_type?: "factual" | "preference" | "event" | "relationship" | "opinion" | "goal" | "instruction";
1965
+ top_k?: number;
1966
+ profile?: "fast" | "balanced" | "quality";
1967
+ include_pending?: boolean;
1968
+ }): Promise<MemorySearchResponse>;
1969
+ createApiKey(params: {
1970
+ name: string;
1971
+ scopes?: string[];
1972
+ rate_limit?: number;
1973
+ expires_in_days?: number;
1974
+ }): Promise<{
1975
+ key: string;
1976
+ prefix: string;
1977
+ name: string;
1978
+ }>;
1979
+ listApiKeys(): Promise<{
1980
+ keys: any[];
1981
+ }>;
1982
+ getUsage(days?: number): Promise<any>;
1983
+ searchMemoriesSOTA(params: {
1984
+ query: string;
1985
+ project?: string;
1986
+ user_id?: string;
1987
+ session_id?: string;
1988
+ question_date?: string;
1989
+ top_k?: number;
1990
+ memory_types?: Array<"factual" | "preference" | "event" | "relationship" | "opinion" | "goal" | "instruction">;
1991
+ include_inactive?: boolean;
1992
+ include_chunks?: boolean;
1993
+ include_relations?: boolean;
1994
+ fast_mode?: boolean;
1995
+ profile?: "fast" | "balanced" | "quality";
1996
+ include_pending?: boolean;
1997
+ }): Promise<MemorySearchResponse>;
1998
+ ingestSession(params: {
1999
+ project?: string;
2000
+ session_id: string;
2001
+ user_id?: string;
2002
+ messages: Array<{
2003
+ role: string;
2004
+ content: string;
2005
+ timestamp: string;
2006
+ }>;
2007
+ async?: boolean;
2008
+ write_mode?: "async" | "sync";
2009
+ }): Promise<{
2010
+ success: boolean;
2011
+ memories_created: number;
2012
+ relations_created: number;
2013
+ memories_invalidated: number;
2014
+ errors?: string[];
2015
+ } & MemoryWriteAck>;
2016
+ getSessionMemories(params: {
2017
+ session_id: string;
2018
+ project?: string;
2019
+ limit?: number;
2020
+ since_date?: string;
2021
+ include_pending?: boolean;
2022
+ }): Promise<{
2023
+ memories: any[];
2024
+ count: number;
2025
+ }>;
2026
+ getUserProfile(params: {
2027
+ user_id: string;
2028
+ project?: string;
2029
+ memory_types?: string;
2030
+ include_pending?: boolean;
2031
+ }): Promise<{
2032
+ user_id: string;
2033
+ memories: any[];
2034
+ count: number;
2035
+ }>;
2036
+ getMemory(memoryId: string): Promise<{
2037
+ memory: any;
2038
+ }>;
2039
+ getMemoryVersions(memoryId: string): Promise<{
2040
+ memory_id: string;
2041
+ versions: any[];
2042
+ count: number;
2043
+ }>;
2044
+ updateMemory(memoryId: string, params: {
2045
+ content: string;
2046
+ reasoning?: string;
2047
+ }): Promise<{
2048
+ success: boolean;
2049
+ new_memory_id: string;
2050
+ old_memory_id: string;
2051
+ }>;
2052
+ deleteMemory(memoryId: string): Promise<{
2053
+ success: boolean;
2054
+ deleted: string;
2055
+ }>;
2056
+ getMemoryRelations(memoryId: string): Promise<{
2057
+ memory_id: string;
2058
+ relations: any[];
2059
+ count: number;
2060
+ }>;
2061
+ getMemoryGraph(params: {
2062
+ project?: string;
2063
+ user_id?: string;
2064
+ session_id?: string;
2065
+ include_inactive?: boolean;
2066
+ limit?: number;
2067
+ }): Promise<any>;
2068
+ getConversationGraph(params: {
2069
+ project?: string;
2070
+ session_id: string;
2071
+ include_inactive?: boolean;
2072
+ limit?: number;
2073
+ }): Promise<any>;
2074
+ oracleSearch(params: {
2075
+ query: string;
2076
+ project?: string;
2077
+ max_results?: number;
2078
+ mode?: "search" | "research";
2079
+ max_steps?: number;
2080
+ }): Promise<any>;
2081
+ autosubscribe(params: {
2082
+ project?: string;
2083
+ source: {
2084
+ type: "github" | "local";
2085
+ owner?: string;
2086
+ repo?: string;
2087
+ path?: string;
2088
+ };
2089
+ dependency_file?: "package.json" | "requirements.txt" | "Cargo.toml" | "go.mod" | "Gemfile";
2090
+ index_limit?: number;
2091
+ auto_sync?: boolean;
2092
+ }): Promise<{
2093
+ success: boolean;
2094
+ discovered: number;
2095
+ indexed: number;
2096
+ errors: string[];
2097
+ dependencies?: any[];
2098
+ auto_sync_enabled: boolean;
2099
+ }>;
2100
+ createSharedContext(params: {
2101
+ session_id: string;
2102
+ project?: string;
2103
+ title?: string;
2104
+ include_memories?: boolean;
2105
+ include_chunks?: boolean;
2106
+ expiry_days?: number;
2107
+ }): Promise<{
2108
+ success: boolean;
2109
+ share_id: string;
2110
+ share_url: string;
2111
+ title: string;
2112
+ memories_count: number;
2113
+ messages_count: number;
2114
+ expires_at: string;
2115
+ }>;
2116
+ loadSharedContext(shareId: string): Promise<{
2117
+ share_id: string;
2118
+ title: string;
2119
+ created_at: string;
2120
+ expires_at: string;
2121
+ memories: any[];
2122
+ messages: any[];
2123
+ chunks?: any[];
2124
+ metadata: any;
2125
+ }>;
2126
+ resumeFromSharedContext(params: {
2127
+ share_id: string;
2128
+ project?: string;
2129
+ new_session_id?: string;
2130
+ }): Promise<{
2131
+ success: boolean;
2132
+ session_id: string;
2133
+ memories_restored: number;
2134
+ messages_restored: number;
2135
+ chunks_restored: number;
2136
+ }>;
2137
+ consolidateMemories(params: {
2138
+ project?: string;
2139
+ similarity_threshold?: number;
2140
+ auto_merge?: boolean;
2141
+ dry_run?: boolean;
2142
+ }): Promise<any>;
2143
+ updateImportanceDecay(params: {
2144
+ project?: string;
2145
+ decay_function?: "exponential" | "linear" | "logarithmic";
2146
+ half_life_days?: number;
2147
+ access_boost?: number;
2148
+ auto_archive?: boolean;
2149
+ archive_threshold?: number;
2150
+ }): Promise<{
2151
+ success: boolean;
2152
+ memories_updated: number;
2153
+ average_importance: number;
2154
+ memories_archived: number;
2155
+ config: any;
2156
+ }>;
2157
+ getImportanceStats(project?: string): Promise<{
2158
+ project_id: string;
2159
+ statistics: any;
2160
+ }>;
2161
+ getCacheStats(): Promise<{
2162
+ cache_type: string;
2163
+ hit_rate: number;
2164
+ total_requests: number;
2165
+ hits: number;
2166
+ misses: number;
2167
+ size_bytes: number;
2168
+ keys_count: number;
2169
+ average_latency_ms: number;
2170
+ uptime_seconds: number;
2171
+ }>;
2172
+ warmCache(params: {
2173
+ project?: string;
2174
+ queries: string[];
2175
+ ttl_seconds?: number;
2176
+ }): Promise<{
2177
+ success: boolean;
2178
+ queries_warmed: number;
2179
+ errors: string[];
2180
+ cache_size_increase_bytes: number;
2181
+ }>;
2182
+ clearCache(params: {
2183
+ pattern?: string;
2184
+ clear_all?: boolean;
2185
+ }): Promise<{
2186
+ success: boolean;
2187
+ keys_cleared: number;
2188
+ bytes_freed: number;
2189
+ }>;
2190
+ getCostSummary(params?: {
2191
+ project?: string;
2192
+ start_date?: string;
2193
+ end_date?: string;
2194
+ }): Promise<any>;
2195
+ getCostBreakdown(params?: {
2196
+ project?: string;
2197
+ group_by?: "model" | "task" | "day" | "hour";
2198
+ start_date?: string;
2199
+ end_date?: string;
2200
+ }): Promise<any>;
2201
+ /**
2202
+ * Semantic search over raw documents without pre-indexing.
2203
+ * Send file contents/summaries directly — the API embeds them in-memory and ranks by similarity.
2204
+ * Perfect for AI agents to semantically explore a codebase on-the-fly.
2205
+ */
2206
+ semanticSearch(params: {
2207
+ query: string;
2208
+ documents: Array<{
2209
+ id: string;
2210
+ content: string;
2211
+ }>;
2212
+ top_k?: number;
2213
+ threshold?: number;
2214
+ }): Promise<{
2215
+ results: Array<{
2216
+ id: string;
2217
+ score: number;
2218
+ content: string;
2219
+ snippet: string;
2220
+ }>;
2221
+ total_searched: number;
2222
+ total_returned: number;
2223
+ query: string;
2224
+ latency_ms: number;
2225
+ }>;
2226
+ searchFiles(params: {
2227
+ query: string;
2228
+ path?: string;
2229
+ mode?: "content" | "filename" | "both";
2230
+ file_types?: string[];
2231
+ max_results?: number;
2232
+ context_lines?: number;
2233
+ case_sensitive?: boolean;
2234
+ }): Promise<{
2235
+ results: Array<{
2236
+ file: string;
2237
+ matches: Array<{
2238
+ line: number;
2239
+ content: string;
2240
+ context_before: string[];
2241
+ context_after: string[];
2242
+ }>;
2243
+ }>;
2244
+ total_files: number;
2245
+ total_matches: number;
2246
+ search_path: string;
2247
+ mode: string;
2248
+ latency_ms: number;
2249
+ engine: "ripgrep" | "node";
2250
+ }>;
2251
+ getCostSavings(params?: {
2252
+ project?: string;
2253
+ start_date?: string;
2254
+ end_date?: string;
2255
+ }): Promise<any>;
2256
+ readonly projects: {
2257
+ create: (params: {
2258
+ name: string;
2259
+ description?: string;
2260
+ settings?: Record<string, any>;
2261
+ }) => Promise<Project>;
2262
+ list: () => Promise<{
2263
+ projects: Project[];
2264
+ }>;
2265
+ get: (id: string) => Promise<Project & {
2266
+ sources: Source[];
2267
+ }>;
2268
+ delete: (id: string) => Promise<{
2269
+ deleted: boolean;
2270
+ }>;
2271
+ };
2272
+ readonly sources: {
2273
+ add: (projectId: string, params: {
2274
+ name: string;
2275
+ connector_type: string;
2276
+ config: Record<string, any>;
2277
+ sync_schedule?: string;
2278
+ }) => Promise<Source>;
2279
+ addSource: (projectId: string, params: {
2280
+ type: "video";
2281
+ url: string;
2282
+ auto_sync?: boolean;
2283
+ tags?: string[];
2284
+ platform?: "youtube" | "loom" | "generic";
2285
+ language?: string;
2286
+ allow_stt_fallback?: boolean;
2287
+ max_duration_minutes?: number;
2288
+ name?: string;
2289
+ }) => Promise<{
2290
+ source_id: string;
2291
+ sync_job_id?: string | null;
2292
+ status: "processing" | "queued" | "created";
2293
+ }>;
2294
+ sync: (sourceId: string) => Promise<any>;
2295
+ syncSource: (sourceId: string) => Promise<any>;
2296
+ status: (sourceId: string) => Promise<VideoIngestionStatus>;
2297
+ getStatus: (sourceId: string) => Promise<VideoIngestionStatus>;
2298
+ };
2299
+ readonly memory: {
2300
+ add: (params: Parameters<WhisperContext["addMemory"]>[0]) => Promise<MemoryWriteResult>;
2301
+ addBulk: (params: Parameters<WhisperContext["addMemoriesBulk"]>[0]) => Promise<any>;
2302
+ extract: (params: Parameters<WhisperContext["extractMemories"]>[0]) => Promise<MemoryExtractionResult>;
2303
+ extractSession: (params: Parameters<WhisperContext["extractSessionMemories"]>[0]) => Promise<{
2304
+ memories: ExtractedMemory[];
2305
+ count: number;
2306
+ latencyMs: number;
2307
+ }>;
2308
+ search: (params: Parameters<WhisperContext["searchMemories"]>[0]) => Promise<MemorySearchResponse>;
2309
+ searchSOTA: (params: Parameters<WhisperContext["searchMemoriesSOTA"]>[0]) => Promise<MemorySearchResponse>;
2310
+ ingestSession: (params: Parameters<WhisperContext["ingestSession"]>[0]) => Promise<{
2311
+ success: boolean;
2312
+ memories_created: number;
2313
+ relations_created: number;
2314
+ memories_invalidated: number;
2315
+ errors?: string[];
2316
+ } & MemoryWriteAck>;
2317
+ getSessionMemories: (params: Parameters<WhisperContext["getSessionMemories"]>[0]) => Promise<{
2318
+ memories: any[];
2319
+ count: number;
2320
+ }>;
2321
+ getUserProfile: (params: Parameters<WhisperContext["getUserProfile"]>[0]) => Promise<{
2322
+ user_id: string;
2323
+ memories: any[];
2324
+ count: number;
2325
+ }>;
2326
+ get: (memoryId: string) => Promise<{
2327
+ memory: any;
2328
+ }>;
2329
+ getVersions: (memoryId: string) => Promise<{
2330
+ memory_id: string;
2331
+ versions: any[];
2332
+ count: number;
2333
+ }>;
2334
+ update: (memoryId: string, params: Parameters<WhisperContext["updateMemory"]>[1]) => Promise<{
2335
+ success: boolean;
2336
+ new_memory_id: string;
2337
+ old_memory_id: string;
2338
+ }>;
2339
+ delete: (memoryId: string) => Promise<{
2340
+ success: boolean;
2341
+ deleted: string;
2342
+ }>;
2343
+ getRelations: (memoryId: string) => Promise<{
2344
+ memory_id: string;
2345
+ relations: any[];
2346
+ count: number;
2347
+ }>;
2348
+ getGraph: (params: Parameters<WhisperContext["getMemoryGraph"]>[0]) => Promise<any>;
2349
+ getConversationGraph: (params: Parameters<WhisperContext["getConversationGraph"]>[0]) => Promise<any>;
2350
+ consolidate: (params: Parameters<WhisperContext["consolidateMemories"]>[0]) => Promise<any>;
2351
+ updateDecay: (params: Parameters<WhisperContext["updateImportanceDecay"]>[0]) => Promise<{
2352
+ success: boolean;
2353
+ memories_updated: number;
2354
+ average_importance: number;
2355
+ memories_archived: number;
2356
+ config: any;
2357
+ }>;
2358
+ getImportanceStats: (project?: string) => Promise<{
2359
+ project_id: string;
2360
+ statistics: any;
2361
+ }>;
2362
+ };
2363
+ readonly keys: {
2364
+ create: (params: Parameters<WhisperContext["createApiKey"]>[0]) => Promise<{
2365
+ key: string;
2366
+ prefix: string;
2367
+ name: string;
2368
+ }>;
2369
+ list: () => Promise<{
2370
+ keys: any[];
2371
+ }>;
2372
+ getUsage: (days?: number) => Promise<any>;
2373
+ };
2374
+ readonly oracle: {
2375
+ search: (params: Parameters<WhisperContext["oracleSearch"]>[0]) => Promise<any>;
2376
+ };
2377
+ readonly context: {
2378
+ createShare: (params: Parameters<WhisperContext["createSharedContext"]>[0]) => Promise<{
2379
+ success: boolean;
2380
+ share_id: string;
2381
+ share_url: string;
2382
+ title: string;
2383
+ memories_count: number;
2384
+ messages_count: number;
2385
+ expires_at: string;
2386
+ }>;
2387
+ loadShare: (shareId: string) => Promise<{
2388
+ share_id: string;
2389
+ title: string;
2390
+ created_at: string;
2391
+ expires_at: string;
2392
+ memories: any[];
2393
+ messages: any[];
2394
+ chunks?: any[];
2395
+ metadata: any;
2396
+ }>;
2397
+ resumeShare: (params: Parameters<WhisperContext["resumeFromSharedContext"]>[0]) => Promise<{
2398
+ success: boolean;
2399
+ session_id: string;
2400
+ memories_restored: number;
2401
+ messages_restored: number;
2402
+ chunks_restored: number;
2403
+ }>;
2404
+ };
2405
+ readonly optimization: {
2406
+ getCacheStats: () => Promise<{
2407
+ cache_type: string;
2408
+ hit_rate: number;
2409
+ total_requests: number;
2410
+ hits: number;
2411
+ misses: number;
2412
+ size_bytes: number;
2413
+ keys_count: number;
2414
+ average_latency_ms: number;
2415
+ uptime_seconds: number;
2416
+ }>;
2417
+ warmCache: (params: Parameters<WhisperContext["warmCache"]>[0]) => Promise<{
2418
+ success: boolean;
2419
+ queries_warmed: number;
2420
+ errors: string[];
2421
+ cache_size_increase_bytes: number;
2422
+ }>;
2423
+ clearCache: (params: Parameters<WhisperContext["clearCache"]>[0]) => Promise<{
2424
+ success: boolean;
2425
+ keys_cleared: number;
2426
+ bytes_freed: number;
2427
+ }>;
2428
+ getCostSummary: (params?: Parameters<WhisperContext["getCostSummary"]>[0]) => Promise<any>;
2429
+ getCostBreakdown: (params?: Parameters<WhisperContext["getCostBreakdown"]>[0]) => Promise<any>;
2430
+ getCostSavings: (params?: Parameters<WhisperContext["getCostSavings"]>[0]) => Promise<any>;
2431
+ };
2432
+ }
2433
+
2434
+ export { type WhisperEnvironment as $, type AgentRunContext as A, type MemoryKind as B, type CanonicalSourceCreateParams as C, type MemoryLatencyBreakdown as D, type ExtractedMemory as E, type MemorySearchResponse as F, type MemoryWriteAck as G, type MemoryWriteResult as H, type Project as I, type QueryResult as J, type TurnInput as K, LangChainMemoryAdapter as L, type MemoryRouterConfig as M, type VideoSourceMetadata as N, Whisper as O, type PreparedTurn as P, type QueryParams as Q, type RunContext as R, type Source as S, type TurnCaptureResult as T, WhisperAgentMiddleware as U, type VideoIngestionStatus as V, type WhisperToolDefinition as W, type WithWhisperOptions, WhisperClient as X, type WhisperClientConfig as Y, type WhisperConfig as Z, WhisperContext as _, type WhisperToolsOptions as a, WhisperError as a0, type WhisperErrorCode as a1, type WhisperIdentityMode as a2, type WhisperPreflightCheck as a3, type WhisperPreflightResult as a4, type WhisperResolvedIdentity as a5, type WorkEvent as a6, type WorkEventKind as a7, type WorkEventSalience as a8, createAgentMiddleware as a9, createLangChainMemoryAdapter as aa, createLangGraphCheckpointAdapter as ab, memoryGraphToMermaid as ac, type MemoryRouterFallbackReason as b, type MemoryRouterResult as c, type MemoryRouterTrace as d, WhisperMemoryRouter as e, createMemoryRouter as f, type AgentRuntimeOptions as g, type AgentRuntimeRankWeights as h, type AgentRuntimeRetrievalOptions as i, type AgentRuntimeSourceActivityOptions as j, type AgentRuntimeStatus as k, type CanonicalSourceCreateResult as l, type CanonicalSourceType as m, LangGraphCheckpointAdapter as n, type LearnConversationInput as o, type LearnConversationResult as p, type LearnInput as q, type LearnResult as r, type LearnSourceInput as s, type LearnSourceResult as t, type LearnSourceType as u, type LearnTextInput as v, whisperTools as w, withWhisper, type LearnTextResult as x, type Memory as y, type MemoryExtractionResult as z };