@usewhisper/sdk 0.1.0 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs CHANGED
@@ -109,6 +109,199 @@ var WhisperContext = class {
109
109
  async getUsage(days = 30) {
110
110
  return this.request(`/v1/usage?days=${days}`);
111
111
  }
112
+ // ─── SOTA Memory System ─────────────────────────────────────────
113
+ /**
114
+ * SOTA Memory Search - Search memories with temporal and type filtering
115
+ */
116
+ async searchMemoriesSOTA(params) {
117
+ return this.request("/v1/memory/search", {
118
+ method: "POST",
119
+ body: JSON.stringify(params)
120
+ });
121
+ }
122
+ /**
123
+ * Ingest Session - Create memories from a conversation
124
+ */
125
+ async ingestSession(params) {
126
+ return this.request("/v1/memory/ingest/session", {
127
+ method: "POST",
128
+ body: JSON.stringify(params)
129
+ });
130
+ }
131
+ /**
132
+ * Get Session Memories - Recent memories from a session
133
+ */
134
+ async getSessionMemories(params) {
135
+ const query = new URLSearchParams({
136
+ project: params.project,
137
+ ...params.limit && { limit: params.limit.toString() },
138
+ ...params.since_date && { since_date: params.since_date }
139
+ });
140
+ return this.request(`/v1/memory/session/${params.session_id}?${query}`);
141
+ }
142
+ /**
143
+ * Get User Profile - Long-term user preferences and facts
144
+ */
145
+ async getUserProfile(params) {
146
+ const query = new URLSearchParams({
147
+ project: params.project,
148
+ ...params.memory_types && { memory_types: params.memory_types }
149
+ });
150
+ return this.request(`/v1/memory/profile/${params.user_id}?${query}`);
151
+ }
152
+ /**
153
+ * Get Memory Versions - Version chain history
154
+ */
155
+ async getMemoryVersions(memoryId) {
156
+ return this.request(`/v1/memory/${memoryId}/versions`);
157
+ }
158
+ /**
159
+ * Update Memory - Create a new version
160
+ */
161
+ async updateMemory(memoryId, params) {
162
+ return this.request(`/v1/memory/${memoryId}`, {
163
+ method: "PUT",
164
+ body: JSON.stringify(params)
165
+ });
166
+ }
167
+ /**
168
+ * Delete Memory - Soft delete
169
+ */
170
+ async deleteMemory(memoryId) {
171
+ return this.request(`/v1/memory/${memoryId}`, { method: "DELETE" });
172
+ }
173
+ /**
174
+ * Get Memory Relations - Graph connections
175
+ */
176
+ async getMemoryRelations(memoryId) {
177
+ return this.request(`/v1/memory/${memoryId}/relations`);
178
+ }
179
+ // ─── Context Layer ──────────────────────────────────────────────
180
+ /**
181
+ * Oracle Search - Tree-guided document navigation with research mode
182
+ */
183
+ async oracleSearch(params) {
184
+ return this.request("/v1/oracle/search", {
185
+ method: "POST",
186
+ body: JSON.stringify(params)
187
+ });
188
+ }
189
+ /**
190
+ * Autosubscribe - Auto-index project dependencies
191
+ */
192
+ async autosubscribe(params) {
193
+ return this.request("/v1/autosubscribe", {
194
+ method: "POST",
195
+ body: JSON.stringify(params)
196
+ });
197
+ }
198
+ /**
199
+ * Create Shared Context - Save and share a conversation
200
+ */
201
+ async createSharedContext(params) {
202
+ return this.request("/v1/context/share", {
203
+ method: "POST",
204
+ body: JSON.stringify(params)
205
+ });
206
+ }
207
+ /**
208
+ * Load Shared Context - View shared context (public endpoint)
209
+ */
210
+ async loadSharedContext(shareId) {
211
+ return this.request(`/v1/context/shared/${shareId}`);
212
+ }
213
+ /**
214
+ * Resume from Shared Context - Fork shared context to new session
215
+ */
216
+ async resumeFromSharedContext(params) {
217
+ return this.request("/v1/context/resume", {
218
+ method: "POST",
219
+ body: JSON.stringify(params)
220
+ });
221
+ }
222
+ // ─── Optimization ───────────────────────────────────────────────
223
+ /**
224
+ * Consolidate Memories - Find and merge duplicates
225
+ */
226
+ async consolidateMemories(params) {
227
+ return this.request("/v1/memory/consolidate", {
228
+ method: "POST",
229
+ body: JSON.stringify(params)
230
+ });
231
+ }
232
+ /**
233
+ * Update Importance Decay - Apply time-based relevance scoring
234
+ */
235
+ async updateImportanceDecay(params) {
236
+ return this.request("/v1/memory/decay/update", {
237
+ method: "POST",
238
+ body: JSON.stringify(params)
239
+ });
240
+ }
241
+ /**
242
+ * Get Importance Statistics
243
+ */
244
+ async getImportanceStats(project) {
245
+ return this.request(`/v1/memory/decay/stats?project=${project}`);
246
+ }
247
+ /**
248
+ * Get Cache Statistics
249
+ */
250
+ async getCacheStats() {
251
+ return this.request("/v1/cache/stats");
252
+ }
253
+ /**
254
+ * Warm Cache - Preload common queries
255
+ */
256
+ async warmCache(params) {
257
+ return this.request("/v1/cache/warm", {
258
+ method: "POST",
259
+ body: JSON.stringify(params)
260
+ });
261
+ }
262
+ /**
263
+ * Clear Cache Pattern
264
+ */
265
+ async clearCache(params) {
266
+ return this.request("/v1/cache/clear", {
267
+ method: "DELETE",
268
+ body: JSON.stringify(params)
269
+ });
270
+ }
271
+ /**
272
+ * Get Cost Summary - Cost tracking overview
273
+ */
274
+ async getCostSummary(params) {
275
+ const query = new URLSearchParams({
276
+ ...params.project && { project: params.project },
277
+ ...params.start_date && { start_date: params.start_date },
278
+ ...params.end_date && { end_date: params.end_date }
279
+ });
280
+ return this.request(`/v1/cost/summary?${query}`);
281
+ }
282
+ /**
283
+ * Get Cost Breakdown - Detailed cost analysis
284
+ */
285
+ async getCostBreakdown(params) {
286
+ const query = new URLSearchParams({
287
+ ...params.project && { project: params.project },
288
+ ...params.group_by && { group_by: params.group_by },
289
+ ...params.start_date && { start_date: params.start_date },
290
+ ...params.end_date && { end_date: params.end_date }
291
+ });
292
+ return this.request(`/v1/cost/breakdown?${query}`);
293
+ }
294
+ /**
295
+ * Get Savings Report - Compare actual vs always-Opus costs
296
+ */
297
+ async getCostSavings(params) {
298
+ const query = new URLSearchParams({
299
+ ...params.project && { project: params.project },
300
+ ...params.start_date && { start_date: params.start_date },
301
+ ...params.end_date && { end_date: params.end_date }
302
+ });
303
+ return this.request(`/v1/cost/savings?${query}`);
304
+ }
112
305
  };
113
306
  var index_default = WhisperContext;
114
307
  // Annotate the CommonJS export names for ESM import in node:
package/index.d.cts CHANGED
@@ -161,6 +161,272 @@ declare class WhisperContext {
161
161
  keys: any[];
162
162
  }>;
163
163
  getUsage(days?: number): Promise<any>;
164
+ /**
165
+ * SOTA Memory Search - Search memories with temporal and type filtering
166
+ */
167
+ searchMemoriesSOTA(params: {
168
+ query: string;
169
+ project: string;
170
+ user_id?: string;
171
+ session_id?: string;
172
+ question_date?: string;
173
+ top_k?: number;
174
+ memory_types?: Array<"factual" | "preference" | "event" | "relationship" | "opinion" | "goal" | "instruction">;
175
+ include_inactive?: boolean;
176
+ include_chunks?: boolean;
177
+ include_relations?: boolean;
178
+ }): Promise<any>;
179
+ /**
180
+ * Ingest Session - Create memories from a conversation
181
+ */
182
+ ingestSession(params: {
183
+ project: string;
184
+ session_id: string;
185
+ user_id?: string;
186
+ messages: Array<{
187
+ role: string;
188
+ content: string;
189
+ timestamp: string;
190
+ }>;
191
+ }): Promise<{
192
+ success: boolean;
193
+ memories_created: number;
194
+ relations_created: number;
195
+ memories_invalidated: number;
196
+ errors?: string[];
197
+ }>;
198
+ /**
199
+ * Get Session Memories - Recent memories from a session
200
+ */
201
+ getSessionMemories(params: {
202
+ session_id: string;
203
+ project: string;
204
+ limit?: number;
205
+ since_date?: string;
206
+ }): Promise<{
207
+ memories: any[];
208
+ count: number;
209
+ }>;
210
+ /**
211
+ * Get User Profile - Long-term user preferences and facts
212
+ */
213
+ getUserProfile(params: {
214
+ user_id: string;
215
+ project: string;
216
+ memory_types?: string;
217
+ }): Promise<{
218
+ user_id: string;
219
+ memories: any[];
220
+ count: number;
221
+ }>;
222
+ /**
223
+ * Get Memory Versions - Version chain history
224
+ */
225
+ getMemoryVersions(memoryId: string): Promise<{
226
+ memory_id: string;
227
+ versions: any[];
228
+ count: number;
229
+ }>;
230
+ /**
231
+ * Update Memory - Create a new version
232
+ */
233
+ updateMemory(memoryId: string, params: {
234
+ content: string;
235
+ reasoning?: string;
236
+ }): Promise<{
237
+ success: boolean;
238
+ new_memory_id: string;
239
+ old_memory_id: string;
240
+ }>;
241
+ /**
242
+ * Delete Memory - Soft delete
243
+ */
244
+ deleteMemory(memoryId: string): Promise<{
245
+ success: boolean;
246
+ deleted: string;
247
+ }>;
248
+ /**
249
+ * Get Memory Relations - Graph connections
250
+ */
251
+ getMemoryRelations(memoryId: string): Promise<{
252
+ memory_id: string;
253
+ relations: any[];
254
+ count: number;
255
+ }>;
256
+ /**
257
+ * Oracle Search - Tree-guided document navigation with research mode
258
+ */
259
+ oracleSearch(params: {
260
+ query: string;
261
+ project: string;
262
+ max_results?: number;
263
+ mode?: "search" | "research";
264
+ max_steps?: number;
265
+ }): Promise<any>;
266
+ /**
267
+ * Autosubscribe - Auto-index project dependencies
268
+ */
269
+ autosubscribe(params: {
270
+ project: string;
271
+ source: {
272
+ type: "github" | "local";
273
+ owner?: string;
274
+ repo?: string;
275
+ path?: string;
276
+ };
277
+ dependency_file?: "package.json" | "requirements.txt" | "Cargo.toml" | "go.mod" | "Gemfile";
278
+ index_limit?: number;
279
+ auto_sync?: boolean;
280
+ }): Promise<{
281
+ success: boolean;
282
+ discovered: number;
283
+ indexed: number;
284
+ errors: string[];
285
+ dependencies?: any[];
286
+ auto_sync_enabled: boolean;
287
+ }>;
288
+ /**
289
+ * Create Shared Context - Save and share a conversation
290
+ */
291
+ createSharedContext(params: {
292
+ session_id: string;
293
+ project: string;
294
+ title?: string;
295
+ include_memories?: boolean;
296
+ include_chunks?: boolean;
297
+ expiry_days?: number;
298
+ }): Promise<{
299
+ success: boolean;
300
+ share_id: string;
301
+ share_url: string;
302
+ title: string;
303
+ memories_count: number;
304
+ messages_count: number;
305
+ expires_at: string;
306
+ }>;
307
+ /**
308
+ * Load Shared Context - View shared context (public endpoint)
309
+ */
310
+ loadSharedContext(shareId: string): Promise<{
311
+ share_id: string;
312
+ title: string;
313
+ created_at: string;
314
+ expires_at: string;
315
+ memories: any[];
316
+ messages: any[];
317
+ chunks?: any[];
318
+ metadata: any;
319
+ }>;
320
+ /**
321
+ * Resume from Shared Context - Fork shared context to new session
322
+ */
323
+ resumeFromSharedContext(params: {
324
+ share_id: string;
325
+ project: string;
326
+ new_session_id?: string;
327
+ }): Promise<{
328
+ success: boolean;
329
+ session_id: string;
330
+ memories_restored: number;
331
+ messages_restored: number;
332
+ chunks_restored: number;
333
+ }>;
334
+ /**
335
+ * Consolidate Memories - Find and merge duplicates
336
+ */
337
+ consolidateMemories(params: {
338
+ project: string;
339
+ similarity_threshold?: number;
340
+ auto_merge?: boolean;
341
+ dry_run?: boolean;
342
+ }): Promise<any>;
343
+ /**
344
+ * Update Importance Decay - Apply time-based relevance scoring
345
+ */
346
+ updateImportanceDecay(params: {
347
+ project: string;
348
+ decay_function?: "exponential" | "linear" | "logarithmic";
349
+ half_life_days?: number;
350
+ access_boost?: number;
351
+ auto_archive?: boolean;
352
+ archive_threshold?: number;
353
+ }): Promise<{
354
+ success: boolean;
355
+ memories_updated: number;
356
+ average_importance: number;
357
+ memories_archived: number;
358
+ config: any;
359
+ }>;
360
+ /**
361
+ * Get Importance Statistics
362
+ */
363
+ getImportanceStats(project: string): Promise<{
364
+ project_id: string;
365
+ statistics: any;
366
+ }>;
367
+ /**
368
+ * Get Cache Statistics
369
+ */
370
+ getCacheStats(): Promise<{
371
+ cache_type: string;
372
+ hit_rate: number;
373
+ total_requests: number;
374
+ hits: number;
375
+ misses: number;
376
+ size_bytes: number;
377
+ keys_count: number;
378
+ average_latency_ms: number;
379
+ uptime_seconds: number;
380
+ }>;
381
+ /**
382
+ * Warm Cache - Preload common queries
383
+ */
384
+ warmCache(params: {
385
+ project: string;
386
+ queries: string[];
387
+ ttl_seconds?: number;
388
+ }): Promise<{
389
+ success: boolean;
390
+ queries_warmed: number;
391
+ errors: string[];
392
+ cache_size_increase_bytes: number;
393
+ }>;
394
+ /**
395
+ * Clear Cache Pattern
396
+ */
397
+ clearCache(params: {
398
+ pattern?: string;
399
+ clear_all?: boolean;
400
+ }): Promise<{
401
+ success: boolean;
402
+ keys_cleared: number;
403
+ bytes_freed: number;
404
+ }>;
405
+ /**
406
+ * Get Cost Summary - Cost tracking overview
407
+ */
408
+ getCostSummary(params: {
409
+ project?: string;
410
+ start_date?: string;
411
+ end_date?: string;
412
+ }): Promise<any>;
413
+ /**
414
+ * Get Cost Breakdown - Detailed cost analysis
415
+ */
416
+ getCostBreakdown(params: {
417
+ project?: string;
418
+ group_by?: "model" | "task" | "day" | "hour";
419
+ start_date?: string;
420
+ end_date?: string;
421
+ }): Promise<any>;
422
+ /**
423
+ * Get Savings Report - Compare actual vs always-Opus costs
424
+ */
425
+ getCostSavings(params: {
426
+ project?: string;
427
+ start_date?: string;
428
+ end_date?: string;
429
+ }): Promise<any>;
164
430
  }
165
431
 
166
432
  export { type Memory, type Project, type QueryParams, type QueryResult, type Source, type WhisperConfig, WhisperContext, WhisperContext as default };
package/index.d.ts CHANGED
@@ -123,6 +123,24 @@ declare class WhisperContext {
123
123
  }>): Promise<{
124
124
  ingested: number;
125
125
  }>;
126
+ /**
127
+ * Add Context - Quick method to inject context without full document format
128
+ * Ideal for agents to add context on the fly
129
+ *
130
+ * @example
131
+ * await client.addContext({
132
+ * project: "my-app",
133
+ * content: "User prefers dark mode and TypeScript over JavaScript"
134
+ * });
135
+ */
136
+ addContext(params: {
137
+ project: string;
138
+ content: string;
139
+ title?: string;
140
+ metadata?: Record<string, any>;
141
+ }): Promise<{
142
+ ingested: number;
143
+ }>;
126
144
  addMemory(params: {
127
145
  project: string;
128
146
  content: string;
@@ -161,6 +179,272 @@ declare class WhisperContext {
161
179
  keys: any[];
162
180
  }>;
163
181
  getUsage(days?: number): Promise<any>;
182
+ /**
183
+ * SOTA Memory Search - Search memories with temporal and type filtering
184
+ */
185
+ searchMemoriesSOTA(params: {
186
+ query: string;
187
+ project: string;
188
+ user_id?: string;
189
+ session_id?: string;
190
+ question_date?: string;
191
+ top_k?: number;
192
+ memory_types?: Array<"factual" | "preference" | "event" | "relationship" | "opinion" | "goal" | "instruction">;
193
+ include_inactive?: boolean;
194
+ include_chunks?: boolean;
195
+ include_relations?: boolean;
196
+ }): Promise<any>;
197
+ /**
198
+ * Ingest Session - Create memories from a conversation
199
+ */
200
+ ingestSession(params: {
201
+ project: string;
202
+ session_id: string;
203
+ user_id?: string;
204
+ messages: Array<{
205
+ role: string;
206
+ content: string;
207
+ timestamp: string;
208
+ }>;
209
+ }): Promise<{
210
+ success: boolean;
211
+ memories_created: number;
212
+ relations_created: number;
213
+ memories_invalidated: number;
214
+ errors?: string[];
215
+ }>;
216
+ /**
217
+ * Get Session Memories - Recent memories from a session
218
+ */
219
+ getSessionMemories(params: {
220
+ session_id: string;
221
+ project: string;
222
+ limit?: number;
223
+ since_date?: string;
224
+ }): Promise<{
225
+ memories: any[];
226
+ count: number;
227
+ }>;
228
+ /**
229
+ * Get User Profile - Long-term user preferences and facts
230
+ */
231
+ getUserProfile(params: {
232
+ user_id: string;
233
+ project: string;
234
+ memory_types?: string;
235
+ }): Promise<{
236
+ user_id: string;
237
+ memories: any[];
238
+ count: number;
239
+ }>;
240
+ /**
241
+ * Get Memory Versions - Version chain history
242
+ */
243
+ getMemoryVersions(memoryId: string): Promise<{
244
+ memory_id: string;
245
+ versions: any[];
246
+ count: number;
247
+ }>;
248
+ /**
249
+ * Update Memory - Create a new version
250
+ */
251
+ updateMemory(memoryId: string, params: {
252
+ content: string;
253
+ reasoning?: string;
254
+ }): Promise<{
255
+ success: boolean;
256
+ new_memory_id: string;
257
+ old_memory_id: string;
258
+ }>;
259
+ /**
260
+ * Delete Memory - Soft delete
261
+ */
262
+ deleteMemory(memoryId: string): Promise<{
263
+ success: boolean;
264
+ deleted: string;
265
+ }>;
266
+ /**
267
+ * Get Memory Relations - Graph connections
268
+ */
269
+ getMemoryRelations(memoryId: string): Promise<{
270
+ memory_id: string;
271
+ relations: any[];
272
+ count: number;
273
+ }>;
274
+ /**
275
+ * Oracle Search - Tree-guided document navigation with research mode
276
+ */
277
+ oracleSearch(params: {
278
+ query: string;
279
+ project: string;
280
+ max_results?: number;
281
+ mode?: "search" | "research";
282
+ max_steps?: number;
283
+ }): Promise<any>;
284
+ /**
285
+ * Autosubscribe - Auto-index project dependencies
286
+ */
287
+ autosubscribe(params: {
288
+ project: string;
289
+ source: {
290
+ type: "github" | "local";
291
+ owner?: string;
292
+ repo?: string;
293
+ path?: string;
294
+ };
295
+ dependency_file?: "package.json" | "requirements.txt" | "Cargo.toml" | "go.mod" | "Gemfile";
296
+ index_limit?: number;
297
+ auto_sync?: boolean;
298
+ }): Promise<{
299
+ success: boolean;
300
+ discovered: number;
301
+ indexed: number;
302
+ errors: string[];
303
+ dependencies?: any[];
304
+ auto_sync_enabled: boolean;
305
+ }>;
306
+ /**
307
+ * Create Shared Context - Save and share a conversation
308
+ */
309
+ createSharedContext(params: {
310
+ session_id: string;
311
+ project: string;
312
+ title?: string;
313
+ include_memories?: boolean;
314
+ include_chunks?: boolean;
315
+ expiry_days?: number;
316
+ }): Promise<{
317
+ success: boolean;
318
+ share_id: string;
319
+ share_url: string;
320
+ title: string;
321
+ memories_count: number;
322
+ messages_count: number;
323
+ expires_at: string;
324
+ }>;
325
+ /**
326
+ * Load Shared Context - View shared context (public endpoint)
327
+ */
328
+ loadSharedContext(shareId: string): Promise<{
329
+ share_id: string;
330
+ title: string;
331
+ created_at: string;
332
+ expires_at: string;
333
+ memories: any[];
334
+ messages: any[];
335
+ chunks?: any[];
336
+ metadata: any;
337
+ }>;
338
+ /**
339
+ * Resume from Shared Context - Fork shared context to new session
340
+ */
341
+ resumeFromSharedContext(params: {
342
+ share_id: string;
343
+ project: string;
344
+ new_session_id?: string;
345
+ }): Promise<{
346
+ success: boolean;
347
+ session_id: string;
348
+ memories_restored: number;
349
+ messages_restored: number;
350
+ chunks_restored: number;
351
+ }>;
352
+ /**
353
+ * Consolidate Memories - Find and merge duplicates
354
+ */
355
+ consolidateMemories(params: {
356
+ project: string;
357
+ similarity_threshold?: number;
358
+ auto_merge?: boolean;
359
+ dry_run?: boolean;
360
+ }): Promise<any>;
361
+ /**
362
+ * Update Importance Decay - Apply time-based relevance scoring
363
+ */
364
+ updateImportanceDecay(params: {
365
+ project: string;
366
+ decay_function?: "exponential" | "linear" | "logarithmic";
367
+ half_life_days?: number;
368
+ access_boost?: number;
369
+ auto_archive?: boolean;
370
+ archive_threshold?: number;
371
+ }): Promise<{
372
+ success: boolean;
373
+ memories_updated: number;
374
+ average_importance: number;
375
+ memories_archived: number;
376
+ config: any;
377
+ }>;
378
+ /**
379
+ * Get Importance Statistics
380
+ */
381
+ getImportanceStats(project: string): Promise<{
382
+ project_id: string;
383
+ statistics: any;
384
+ }>;
385
+ /**
386
+ * Get Cache Statistics
387
+ */
388
+ getCacheStats(): Promise<{
389
+ cache_type: string;
390
+ hit_rate: number;
391
+ total_requests: number;
392
+ hits: number;
393
+ misses: number;
394
+ size_bytes: number;
395
+ keys_count: number;
396
+ average_latency_ms: number;
397
+ uptime_seconds: number;
398
+ }>;
399
+ /**
400
+ * Warm Cache - Preload common queries
401
+ */
402
+ warmCache(params: {
403
+ project: string;
404
+ queries: string[];
405
+ ttl_seconds?: number;
406
+ }): Promise<{
407
+ success: boolean;
408
+ queries_warmed: number;
409
+ errors: string[];
410
+ cache_size_increase_bytes: number;
411
+ }>;
412
+ /**
413
+ * Clear Cache Pattern
414
+ */
415
+ clearCache(params: {
416
+ pattern?: string;
417
+ clear_all?: boolean;
418
+ }): Promise<{
419
+ success: boolean;
420
+ keys_cleared: number;
421
+ bytes_freed: number;
422
+ }>;
423
+ /**
424
+ * Get Cost Summary - Cost tracking overview
425
+ */
426
+ getCostSummary(params: {
427
+ project?: string;
428
+ start_date?: string;
429
+ end_date?: string;
430
+ }): Promise<any>;
431
+ /**
432
+ * Get Cost Breakdown - Detailed cost analysis
433
+ */
434
+ getCostBreakdown(params: {
435
+ project?: string;
436
+ group_by?: "model" | "task" | "day" | "hour";
437
+ start_date?: string;
438
+ end_date?: string;
439
+ }): Promise<any>;
440
+ /**
441
+ * Get Savings Report - Compare actual vs always-Opus costs
442
+ */
443
+ getCostSavings(params: {
444
+ project?: string;
445
+ start_date?: string;
446
+ end_date?: string;
447
+ }): Promise<any>;
164
448
  }
165
449
 
166
450
  export { type Memory, type Project, type QueryParams, type QueryResult, type Source, type WhisperConfig, WhisperContext, WhisperContext as default };
package/index.js CHANGED
@@ -1,4 +1,29 @@
1
- // src/sdk/index.ts
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // ../src/sdk/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ WhisperContext: () => WhisperContext,
24
+ default: () => index_default
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
2
27
  var WhisperContext = class {
3
28
  apiKey;
4
29
  baseUrl;
@@ -60,6 +85,32 @@ var WhisperContext = class {
60
85
  body: JSON.stringify({ documents })
61
86
  });
62
87
  }
88
+ /**
89
+ * Add Context - Quick method to inject context without full document format
90
+ * Ideal for agents to add context on the fly
91
+ *
92
+ * @example
93
+ * await client.addContext({
94
+ * project: "my-app",
95
+ * content: "User prefers dark mode and TypeScript over JavaScript"
96
+ * });
97
+ */
98
+ async addContext(params) {
99
+ const projectData = await this.listProjects();
100
+ const project = projectData.projects.find(
101
+ (p) => p.name === params.project || p.slug === params.project
102
+ );
103
+ if (!project) {
104
+ throw new Error(`Project '${params.project}' not found`);
105
+ }
106
+ return this.ingest(project.id, [
107
+ {
108
+ title: params.title || "Context",
109
+ content: params.content,
110
+ metadata: params.metadata || { source: "addContext" }
111
+ }
112
+ ]);
113
+ }
63
114
  async addMemory(params) {
64
115
  return this.request("/v1/memories", {
65
116
  method: "POST",
@@ -84,9 +135,202 @@ var WhisperContext = class {
84
135
  async getUsage(days = 30) {
85
136
  return this.request(`/v1/usage?days=${days}`);
86
137
  }
138
+ // ─── SOTA Memory System ─────────────────────────────────────────
139
+ /**
140
+ * SOTA Memory Search - Search memories with temporal and type filtering
141
+ */
142
+ async searchMemoriesSOTA(params) {
143
+ return this.request("/v1/memory/search", {
144
+ method: "POST",
145
+ body: JSON.stringify(params)
146
+ });
147
+ }
148
+ /**
149
+ * Ingest Session - Create memories from a conversation
150
+ */
151
+ async ingestSession(params) {
152
+ return this.request("/v1/memory/ingest/session", {
153
+ method: "POST",
154
+ body: JSON.stringify(params)
155
+ });
156
+ }
157
+ /**
158
+ * Get Session Memories - Recent memories from a session
159
+ */
160
+ async getSessionMemories(params) {
161
+ const query = new URLSearchParams({
162
+ project: params.project,
163
+ ...params.limit && { limit: params.limit.toString() },
164
+ ...params.since_date && { since_date: params.since_date }
165
+ });
166
+ return this.request(`/v1/memory/session/${params.session_id}?${query}`);
167
+ }
168
+ /**
169
+ * Get User Profile - Long-term user preferences and facts
170
+ */
171
+ async getUserProfile(params) {
172
+ const query = new URLSearchParams({
173
+ project: params.project,
174
+ ...params.memory_types && { memory_types: params.memory_types }
175
+ });
176
+ return this.request(`/v1/memory/profile/${params.user_id}?${query}`);
177
+ }
178
+ /**
179
+ * Get Memory Versions - Version chain history
180
+ */
181
+ async getMemoryVersions(memoryId) {
182
+ return this.request(`/v1/memory/${memoryId}/versions`);
183
+ }
184
+ /**
185
+ * Update Memory - Create a new version
186
+ */
187
+ async updateMemory(memoryId, params) {
188
+ return this.request(`/v1/memory/${memoryId}`, {
189
+ method: "PUT",
190
+ body: JSON.stringify(params)
191
+ });
192
+ }
193
+ /**
194
+ * Delete Memory - Soft delete
195
+ */
196
+ async deleteMemory(memoryId) {
197
+ return this.request(`/v1/memory/${memoryId}`, { method: "DELETE" });
198
+ }
199
+ /**
200
+ * Get Memory Relations - Graph connections
201
+ */
202
+ async getMemoryRelations(memoryId) {
203
+ return this.request(`/v1/memory/${memoryId}/relations`);
204
+ }
205
+ // ─── Context Layer ──────────────────────────────────────────────
206
+ /**
207
+ * Oracle Search - Tree-guided document navigation with research mode
208
+ */
209
+ async oracleSearch(params) {
210
+ return this.request("/v1/oracle/search", {
211
+ method: "POST",
212
+ body: JSON.stringify(params)
213
+ });
214
+ }
215
+ /**
216
+ * Autosubscribe - Auto-index project dependencies
217
+ */
218
+ async autosubscribe(params) {
219
+ return this.request("/v1/autosubscribe", {
220
+ method: "POST",
221
+ body: JSON.stringify(params)
222
+ });
223
+ }
224
+ /**
225
+ * Create Shared Context - Save and share a conversation
226
+ */
227
+ async createSharedContext(params) {
228
+ return this.request("/v1/context/share", {
229
+ method: "POST",
230
+ body: JSON.stringify(params)
231
+ });
232
+ }
233
+ /**
234
+ * Load Shared Context - View shared context (public endpoint)
235
+ */
236
+ async loadSharedContext(shareId) {
237
+ return this.request(`/v1/context/shared/${shareId}`);
238
+ }
239
+ /**
240
+ * Resume from Shared Context - Fork shared context to new session
241
+ */
242
+ async resumeFromSharedContext(params) {
243
+ return this.request("/v1/context/resume", {
244
+ method: "POST",
245
+ body: JSON.stringify(params)
246
+ });
247
+ }
248
+ // ─── Optimization ───────────────────────────────────────────────
249
+ /**
250
+ * Consolidate Memories - Find and merge duplicates
251
+ */
252
+ async consolidateMemories(params) {
253
+ return this.request("/v1/memory/consolidate", {
254
+ method: "POST",
255
+ body: JSON.stringify(params)
256
+ });
257
+ }
258
+ /**
259
+ * Update Importance Decay - Apply time-based relevance scoring
260
+ */
261
+ async updateImportanceDecay(params) {
262
+ return this.request("/v1/memory/decay/update", {
263
+ method: "POST",
264
+ body: JSON.stringify(params)
265
+ });
266
+ }
267
+ /**
268
+ * Get Importance Statistics
269
+ */
270
+ async getImportanceStats(project) {
271
+ return this.request(`/v1/memory/decay/stats?project=${project}`);
272
+ }
273
+ /**
274
+ * Get Cache Statistics
275
+ */
276
+ async getCacheStats() {
277
+ return this.request("/v1/cache/stats");
278
+ }
279
+ /**
280
+ * Warm Cache - Preload common queries
281
+ */
282
+ async warmCache(params) {
283
+ return this.request("/v1/cache/warm", {
284
+ method: "POST",
285
+ body: JSON.stringify(params)
286
+ });
287
+ }
288
+ /**
289
+ * Clear Cache Pattern
290
+ */
291
+ async clearCache(params) {
292
+ return this.request("/v1/cache/clear", {
293
+ method: "DELETE",
294
+ body: JSON.stringify(params)
295
+ });
296
+ }
297
+ /**
298
+ * Get Cost Summary - Cost tracking overview
299
+ */
300
+ async getCostSummary(params) {
301
+ const query = new URLSearchParams({
302
+ ...params.project && { project: params.project },
303
+ ...params.start_date && { start_date: params.start_date },
304
+ ...params.end_date && { end_date: params.end_date }
305
+ });
306
+ return this.request(`/v1/cost/summary?${query}`);
307
+ }
308
+ /**
309
+ * Get Cost Breakdown - Detailed cost analysis
310
+ */
311
+ async getCostBreakdown(params) {
312
+ const query = new URLSearchParams({
313
+ ...params.project && { project: params.project },
314
+ ...params.group_by && { group_by: params.group_by },
315
+ ...params.start_date && { start_date: params.start_date },
316
+ ...params.end_date && { end_date: params.end_date }
317
+ });
318
+ return this.request(`/v1/cost/breakdown?${query}`);
319
+ }
320
+ /**
321
+ * Get Savings Report - Compare actual vs always-Opus costs
322
+ */
323
+ async getCostSavings(params) {
324
+ const query = new URLSearchParams({
325
+ ...params.project && { project: params.project },
326
+ ...params.start_date && { start_date: params.start_date },
327
+ ...params.end_date && { end_date: params.end_date }
328
+ });
329
+ return this.request(`/v1/cost/savings?${query}`);
330
+ }
87
331
  };
88
332
  var index_default = WhisperContext;
89
- export {
90
- WhisperContext,
91
- index_default as default
92
- };
333
+ // Annotate the CommonJS export names for ESM import in node:
334
+ 0 && (module.exports = {
335
+ WhisperContext
336
+ });
package/package.json CHANGED
@@ -1,15 +1,19 @@
1
1
  {
2
2
  "name": "@usewhisper/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.2.5",
4
+ "scripts": {
5
+ "build": "tsup ../src/sdk/index.ts --format esm,cjs --dts --out-dir .",
6
+ "prepublishOnly": "npm run build"
7
+ },
4
8
  "description": "TypeScript SDK for Whisper Context API - Add reliable context to your AI agents",
5
9
  "main": "index.cjs",
6
10
  "module": "index.js",
7
11
  "types": "index.d.ts",
8
12
  "exports": {
9
13
  ".": {
14
+ "types": "./index.d.ts",
10
15
  "import": "./index.js",
11
- "require": "./index.cjs",
12
- "types": "./index.d.ts"
16
+ "require": "./index.cjs"
13
17
  }
14
18
  },
15
19
  "files": [