@usewhisper/sdk 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.mts +56 -1
- package/index.d.ts +56 -1
- package/index.js +68 -15
- package/index.mjs +68 -15
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -170,16 +170,19 @@ declare class WhisperContext {
|
|
|
170
170
|
addMemory(params: {
|
|
171
171
|
project?: string;
|
|
172
172
|
content: string;
|
|
173
|
-
memory_type?: "factual" | "preference" | "event" | "relationship" | "opinion" | "goal" | "instruction";
|
|
173
|
+
memory_type?: "factual" | "episodic" | "semantic" | "procedural" | "preference" | "event" | "relationship" | "opinion" | "goal" | "instruction";
|
|
174
174
|
user_id?: string;
|
|
175
175
|
session_id?: string;
|
|
176
176
|
agent_id?: string;
|
|
177
177
|
importance?: number;
|
|
178
178
|
metadata?: Record<string, any>;
|
|
179
179
|
expires_in_seconds?: number;
|
|
180
|
+
allow_legacy_fallback?: boolean;
|
|
180
181
|
}): Promise<{
|
|
181
182
|
id: string;
|
|
182
183
|
success: boolean;
|
|
184
|
+
path: "sota" | "legacy";
|
|
185
|
+
fallback_used: boolean;
|
|
183
186
|
}>;
|
|
184
187
|
searchMemories(params: {
|
|
185
188
|
project?: string;
|
|
@@ -399,6 +402,56 @@ declare class WhisperContext {
|
|
|
399
402
|
start_date?: string;
|
|
400
403
|
end_date?: string;
|
|
401
404
|
}): Promise<any>;
|
|
405
|
+
/**
|
|
406
|
+
* Semantic search over raw documents without pre-indexing.
|
|
407
|
+
* Send file contents/summaries directly — the API embeds them in-memory and ranks by similarity.
|
|
408
|
+
* Perfect for AI agents to semantically explore a codebase on-the-fly.
|
|
409
|
+
*/
|
|
410
|
+
semanticSearch(params: {
|
|
411
|
+
query: string;
|
|
412
|
+
documents: Array<{
|
|
413
|
+
id: string;
|
|
414
|
+
content: string;
|
|
415
|
+
}>;
|
|
416
|
+
top_k?: number;
|
|
417
|
+
threshold?: number;
|
|
418
|
+
}): Promise<{
|
|
419
|
+
results: Array<{
|
|
420
|
+
id: string;
|
|
421
|
+
score: number;
|
|
422
|
+
content: string;
|
|
423
|
+
snippet: string;
|
|
424
|
+
}>;
|
|
425
|
+
total_searched: number;
|
|
426
|
+
total_returned: number;
|
|
427
|
+
query: string;
|
|
428
|
+
latency_ms: number;
|
|
429
|
+
}>;
|
|
430
|
+
searchFiles(params: {
|
|
431
|
+
query: string;
|
|
432
|
+
path?: string;
|
|
433
|
+
mode?: "content" | "filename" | "both";
|
|
434
|
+
file_types?: string[];
|
|
435
|
+
max_results?: number;
|
|
436
|
+
context_lines?: number;
|
|
437
|
+
case_sensitive?: boolean;
|
|
438
|
+
}): Promise<{
|
|
439
|
+
results: Array<{
|
|
440
|
+
file: string;
|
|
441
|
+
matches: Array<{
|
|
442
|
+
line: number;
|
|
443
|
+
content: string;
|
|
444
|
+
context_before: string[];
|
|
445
|
+
context_after: string[];
|
|
446
|
+
}>;
|
|
447
|
+
}>;
|
|
448
|
+
total_files: number;
|
|
449
|
+
total_matches: number;
|
|
450
|
+
search_path: string;
|
|
451
|
+
mode: string;
|
|
452
|
+
latency_ms: number;
|
|
453
|
+
engine: "ripgrep" | "node";
|
|
454
|
+
}>;
|
|
402
455
|
getCostSavings(params?: {
|
|
403
456
|
project?: string;
|
|
404
457
|
start_date?: string;
|
|
@@ -434,6 +487,8 @@ declare class WhisperContext {
|
|
|
434
487
|
add: (params: Parameters<WhisperContext["addMemory"]>[0]) => Promise<{
|
|
435
488
|
id: string;
|
|
436
489
|
success: boolean;
|
|
490
|
+
path: "sota" | "legacy";
|
|
491
|
+
fallback_used: boolean;
|
|
437
492
|
}>;
|
|
438
493
|
search: (params: Parameters<WhisperContext["searchMemories"]>[0]) => Promise<any>;
|
|
439
494
|
searchSOTA: (params: Parameters<WhisperContext["searchMemoriesSOTA"]>[0]) => Promise<any>;
|
package/index.d.ts
CHANGED
|
@@ -170,16 +170,19 @@ declare class WhisperContext {
|
|
|
170
170
|
addMemory(params: {
|
|
171
171
|
project?: string;
|
|
172
172
|
content: string;
|
|
173
|
-
memory_type?: "factual" | "preference" | "event" | "relationship" | "opinion" | "goal" | "instruction";
|
|
173
|
+
memory_type?: "factual" | "episodic" | "semantic" | "procedural" | "preference" | "event" | "relationship" | "opinion" | "goal" | "instruction";
|
|
174
174
|
user_id?: string;
|
|
175
175
|
session_id?: string;
|
|
176
176
|
agent_id?: string;
|
|
177
177
|
importance?: number;
|
|
178
178
|
metadata?: Record<string, any>;
|
|
179
179
|
expires_in_seconds?: number;
|
|
180
|
+
allow_legacy_fallback?: boolean;
|
|
180
181
|
}): Promise<{
|
|
181
182
|
id: string;
|
|
182
183
|
success: boolean;
|
|
184
|
+
path: "sota" | "legacy";
|
|
185
|
+
fallback_used: boolean;
|
|
183
186
|
}>;
|
|
184
187
|
searchMemories(params: {
|
|
185
188
|
project?: string;
|
|
@@ -399,6 +402,56 @@ declare class WhisperContext {
|
|
|
399
402
|
start_date?: string;
|
|
400
403
|
end_date?: string;
|
|
401
404
|
}): Promise<any>;
|
|
405
|
+
/**
|
|
406
|
+
* Semantic search over raw documents without pre-indexing.
|
|
407
|
+
* Send file contents/summaries directly — the API embeds them in-memory and ranks by similarity.
|
|
408
|
+
* Perfect for AI agents to semantically explore a codebase on-the-fly.
|
|
409
|
+
*/
|
|
410
|
+
semanticSearch(params: {
|
|
411
|
+
query: string;
|
|
412
|
+
documents: Array<{
|
|
413
|
+
id: string;
|
|
414
|
+
content: string;
|
|
415
|
+
}>;
|
|
416
|
+
top_k?: number;
|
|
417
|
+
threshold?: number;
|
|
418
|
+
}): Promise<{
|
|
419
|
+
results: Array<{
|
|
420
|
+
id: string;
|
|
421
|
+
score: number;
|
|
422
|
+
content: string;
|
|
423
|
+
snippet: string;
|
|
424
|
+
}>;
|
|
425
|
+
total_searched: number;
|
|
426
|
+
total_returned: number;
|
|
427
|
+
query: string;
|
|
428
|
+
latency_ms: number;
|
|
429
|
+
}>;
|
|
430
|
+
searchFiles(params: {
|
|
431
|
+
query: string;
|
|
432
|
+
path?: string;
|
|
433
|
+
mode?: "content" | "filename" | "both";
|
|
434
|
+
file_types?: string[];
|
|
435
|
+
max_results?: number;
|
|
436
|
+
context_lines?: number;
|
|
437
|
+
case_sensitive?: boolean;
|
|
438
|
+
}): Promise<{
|
|
439
|
+
results: Array<{
|
|
440
|
+
file: string;
|
|
441
|
+
matches: Array<{
|
|
442
|
+
line: number;
|
|
443
|
+
content: string;
|
|
444
|
+
context_before: string[];
|
|
445
|
+
context_after: string[];
|
|
446
|
+
}>;
|
|
447
|
+
}>;
|
|
448
|
+
total_files: number;
|
|
449
|
+
total_matches: number;
|
|
450
|
+
search_path: string;
|
|
451
|
+
mode: string;
|
|
452
|
+
latency_ms: number;
|
|
453
|
+
engine: "ripgrep" | "node";
|
|
454
|
+
}>;
|
|
402
455
|
getCostSavings(params?: {
|
|
403
456
|
project?: string;
|
|
404
457
|
start_date?: string;
|
|
@@ -434,6 +487,8 @@ declare class WhisperContext {
|
|
|
434
487
|
add: (params: Parameters<WhisperContext["addMemory"]>[0]) => Promise<{
|
|
435
488
|
id: string;
|
|
436
489
|
success: boolean;
|
|
490
|
+
path: "sota" | "legacy";
|
|
491
|
+
fallback_used: boolean;
|
|
437
492
|
}>;
|
|
438
493
|
search: (params: Parameters<WhisperContext["searchMemories"]>[0]) => Promise<any>;
|
|
439
494
|
searchSOTA: (params: Parameters<WhisperContext["searchMemoriesSOTA"]>[0]) => Promise<any>;
|
package/index.js
CHANGED
|
@@ -332,13 +332,40 @@ var WhisperContext = class _WhisperContext {
|
|
|
332
332
|
async addMemory(params) {
|
|
333
333
|
const projectRef = this.getRequiredProject(params.project);
|
|
334
334
|
return this.withProjectRefFallback(projectRef, async (project) => {
|
|
335
|
+
const toSotaType = (memoryType) => {
|
|
336
|
+
switch (memoryType) {
|
|
337
|
+
case "episodic":
|
|
338
|
+
return "event";
|
|
339
|
+
case "semantic":
|
|
340
|
+
return "factual";
|
|
341
|
+
case "procedural":
|
|
342
|
+
return "instruction";
|
|
343
|
+
default:
|
|
344
|
+
return memoryType;
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
const toLegacyType = (memoryType) => {
|
|
348
|
+
switch (memoryType) {
|
|
349
|
+
case "event":
|
|
350
|
+
return "episodic";
|
|
351
|
+
case "instruction":
|
|
352
|
+
return "procedural";
|
|
353
|
+
case "preference":
|
|
354
|
+
case "relationship":
|
|
355
|
+
case "opinion":
|
|
356
|
+
case "goal":
|
|
357
|
+
return "semantic";
|
|
358
|
+
default:
|
|
359
|
+
return memoryType;
|
|
360
|
+
}
|
|
361
|
+
};
|
|
335
362
|
try {
|
|
336
363
|
const direct = await this.request("/v1/memory", {
|
|
337
364
|
method: "POST",
|
|
338
365
|
body: JSON.stringify({
|
|
339
366
|
project,
|
|
340
367
|
content: params.content,
|
|
341
|
-
memory_type: params.memory_type,
|
|
368
|
+
memory_type: toSotaType(params.memory_type),
|
|
342
369
|
user_id: params.user_id,
|
|
343
370
|
session_id: params.session_id,
|
|
344
371
|
agent_id: params.agent_id,
|
|
@@ -346,28 +373,37 @@ var WhisperContext = class _WhisperContext {
|
|
|
346
373
|
metadata: params.metadata
|
|
347
374
|
})
|
|
348
375
|
});
|
|
349
|
-
const
|
|
350
|
-
if (
|
|
351
|
-
return { id, success: true };
|
|
376
|
+
const id2 = direct?.memory?.id || direct?.id || direct?.memory_id;
|
|
377
|
+
if (id2) {
|
|
378
|
+
return { id: id2, success: true, path: "sota", fallback_used: false };
|
|
379
|
+
}
|
|
380
|
+
} catch (error) {
|
|
381
|
+
if (params.allow_legacy_fallback === false) {
|
|
382
|
+
throw error;
|
|
352
383
|
}
|
|
353
|
-
} catch {
|
|
354
384
|
}
|
|
355
|
-
await this.request("/v1/
|
|
385
|
+
const legacy = await this.request("/v1/memories", {
|
|
356
386
|
method: "POST",
|
|
357
387
|
body: JSON.stringify({
|
|
358
388
|
project,
|
|
359
|
-
|
|
389
|
+
content: params.content,
|
|
390
|
+
memory_type: toLegacyType(params.memory_type),
|
|
360
391
|
user_id: params.user_id,
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
}
|
|
367
|
-
]
|
|
392
|
+
session_id: params.session_id,
|
|
393
|
+
agent_id: params.agent_id,
|
|
394
|
+
importance: params.importance,
|
|
395
|
+
metadata: params.metadata,
|
|
396
|
+
expires_in_seconds: params.expires_in_seconds
|
|
368
397
|
})
|
|
369
398
|
});
|
|
370
|
-
|
|
399
|
+
const id = legacy?.memory?.id || legacy?.id || legacy?.memory_id;
|
|
400
|
+
if (!id) {
|
|
401
|
+
throw new WhisperError({
|
|
402
|
+
code: "REQUEST_FAILED",
|
|
403
|
+
message: "Memory create succeeded but no memory id was returned by the API"
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
return { id, success: true, path: "legacy", fallback_used: true };
|
|
371
407
|
});
|
|
372
408
|
}
|
|
373
409
|
async searchMemories(params) {
|
|
@@ -526,6 +562,23 @@ var WhisperContext = class _WhisperContext {
|
|
|
526
562
|
});
|
|
527
563
|
return this.request(`/v1/cost/breakdown?${query}`);
|
|
528
564
|
}
|
|
565
|
+
/**
|
|
566
|
+
* Semantic search over raw documents without pre-indexing.
|
|
567
|
+
* Send file contents/summaries directly — the API embeds them in-memory and ranks by similarity.
|
|
568
|
+
* Perfect for AI agents to semantically explore a codebase on-the-fly.
|
|
569
|
+
*/
|
|
570
|
+
async semanticSearch(params) {
|
|
571
|
+
return this.request("/v1/search/semantic", {
|
|
572
|
+
method: "POST",
|
|
573
|
+
body: JSON.stringify(params)
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
async searchFiles(params) {
|
|
577
|
+
return this.request("/v1/search/files", {
|
|
578
|
+
method: "POST",
|
|
579
|
+
body: JSON.stringify(params)
|
|
580
|
+
});
|
|
581
|
+
}
|
|
529
582
|
async getCostSavings(params = {}) {
|
|
530
583
|
const resolvedProject = params.project ? await this.resolveProjectId(params.project) : void 0;
|
|
531
584
|
const query = new URLSearchParams({
|
package/index.mjs
CHANGED
|
@@ -306,13 +306,40 @@ var WhisperContext = class _WhisperContext {
|
|
|
306
306
|
async addMemory(params) {
|
|
307
307
|
const projectRef = this.getRequiredProject(params.project);
|
|
308
308
|
return this.withProjectRefFallback(projectRef, async (project) => {
|
|
309
|
+
const toSotaType = (memoryType) => {
|
|
310
|
+
switch (memoryType) {
|
|
311
|
+
case "episodic":
|
|
312
|
+
return "event";
|
|
313
|
+
case "semantic":
|
|
314
|
+
return "factual";
|
|
315
|
+
case "procedural":
|
|
316
|
+
return "instruction";
|
|
317
|
+
default:
|
|
318
|
+
return memoryType;
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
const toLegacyType = (memoryType) => {
|
|
322
|
+
switch (memoryType) {
|
|
323
|
+
case "event":
|
|
324
|
+
return "episodic";
|
|
325
|
+
case "instruction":
|
|
326
|
+
return "procedural";
|
|
327
|
+
case "preference":
|
|
328
|
+
case "relationship":
|
|
329
|
+
case "opinion":
|
|
330
|
+
case "goal":
|
|
331
|
+
return "semantic";
|
|
332
|
+
default:
|
|
333
|
+
return memoryType;
|
|
334
|
+
}
|
|
335
|
+
};
|
|
309
336
|
try {
|
|
310
337
|
const direct = await this.request("/v1/memory", {
|
|
311
338
|
method: "POST",
|
|
312
339
|
body: JSON.stringify({
|
|
313
340
|
project,
|
|
314
341
|
content: params.content,
|
|
315
|
-
memory_type: params.memory_type,
|
|
342
|
+
memory_type: toSotaType(params.memory_type),
|
|
316
343
|
user_id: params.user_id,
|
|
317
344
|
session_id: params.session_id,
|
|
318
345
|
agent_id: params.agent_id,
|
|
@@ -320,28 +347,37 @@ var WhisperContext = class _WhisperContext {
|
|
|
320
347
|
metadata: params.metadata
|
|
321
348
|
})
|
|
322
349
|
});
|
|
323
|
-
const
|
|
324
|
-
if (
|
|
325
|
-
return { id, success: true };
|
|
350
|
+
const id2 = direct?.memory?.id || direct?.id || direct?.memory_id;
|
|
351
|
+
if (id2) {
|
|
352
|
+
return { id: id2, success: true, path: "sota", fallback_used: false };
|
|
353
|
+
}
|
|
354
|
+
} catch (error) {
|
|
355
|
+
if (params.allow_legacy_fallback === false) {
|
|
356
|
+
throw error;
|
|
326
357
|
}
|
|
327
|
-
} catch {
|
|
328
358
|
}
|
|
329
|
-
await this.request("/v1/
|
|
359
|
+
const legacy = await this.request("/v1/memories", {
|
|
330
360
|
method: "POST",
|
|
331
361
|
body: JSON.stringify({
|
|
332
362
|
project,
|
|
333
|
-
|
|
363
|
+
content: params.content,
|
|
364
|
+
memory_type: toLegacyType(params.memory_type),
|
|
334
365
|
user_id: params.user_id,
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}
|
|
341
|
-
]
|
|
366
|
+
session_id: params.session_id,
|
|
367
|
+
agent_id: params.agent_id,
|
|
368
|
+
importance: params.importance,
|
|
369
|
+
metadata: params.metadata,
|
|
370
|
+
expires_in_seconds: params.expires_in_seconds
|
|
342
371
|
})
|
|
343
372
|
});
|
|
344
|
-
|
|
373
|
+
const id = legacy?.memory?.id || legacy?.id || legacy?.memory_id;
|
|
374
|
+
if (!id) {
|
|
375
|
+
throw new WhisperError({
|
|
376
|
+
code: "REQUEST_FAILED",
|
|
377
|
+
message: "Memory create succeeded but no memory id was returned by the API"
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
return { id, success: true, path: "legacy", fallback_used: true };
|
|
345
381
|
});
|
|
346
382
|
}
|
|
347
383
|
async searchMemories(params) {
|
|
@@ -500,6 +536,23 @@ var WhisperContext = class _WhisperContext {
|
|
|
500
536
|
});
|
|
501
537
|
return this.request(`/v1/cost/breakdown?${query}`);
|
|
502
538
|
}
|
|
539
|
+
/**
|
|
540
|
+
* Semantic search over raw documents without pre-indexing.
|
|
541
|
+
* Send file contents/summaries directly — the API embeds them in-memory and ranks by similarity.
|
|
542
|
+
* Perfect for AI agents to semantically explore a codebase on-the-fly.
|
|
543
|
+
*/
|
|
544
|
+
async semanticSearch(params) {
|
|
545
|
+
return this.request("/v1/search/semantic", {
|
|
546
|
+
method: "POST",
|
|
547
|
+
body: JSON.stringify(params)
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
async searchFiles(params) {
|
|
551
|
+
return this.request("/v1/search/files", {
|
|
552
|
+
method: "POST",
|
|
553
|
+
body: JSON.stringify(params)
|
|
554
|
+
});
|
|
555
|
+
}
|
|
503
556
|
async getCostSavings(params = {}) {
|
|
504
557
|
const resolvedProject = params.project ? await this.resolveProjectId(params.project) : void 0;
|
|
505
558
|
const query = new URLSearchParams({
|