@usewhisper/sdk 2.1.0 → 2.2.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 +37 -1
- package/index.d.ts +37 -1
- package/index.js +51 -2
- package/index.mjs +49 -1
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -239,6 +239,26 @@ declare class WhisperAgentMiddleware {
|
|
|
239
239
|
}
|
|
240
240
|
declare function createAgentMiddleware(config: AgentMiddlewareConfig): WhisperAgentMiddleware;
|
|
241
241
|
|
|
242
|
+
interface MemoryGraphNode {
|
|
243
|
+
id: string;
|
|
244
|
+
label?: string;
|
|
245
|
+
memory_type?: string;
|
|
246
|
+
}
|
|
247
|
+
interface MemoryGraphEdge {
|
|
248
|
+
source: string;
|
|
249
|
+
target: string;
|
|
250
|
+
type?: string;
|
|
251
|
+
}
|
|
252
|
+
interface MemoryGraphPayload {
|
|
253
|
+
nodes: MemoryGraphNode[];
|
|
254
|
+
edges: MemoryGraphEdge[];
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Convert memory graph payload to Mermaid flowchart syntax.
|
|
258
|
+
* Useful for quick visualization in docs/dashboards.
|
|
259
|
+
*/
|
|
260
|
+
declare function memoryGraphToMermaid(graph: MemoryGraphPayload): string;
|
|
261
|
+
|
|
242
262
|
/**
|
|
243
263
|
* Whisper Context SDK
|
|
244
264
|
* TypeScript SDK for the Whisper Context API
|
|
@@ -519,6 +539,7 @@ declare class WhisperContext {
|
|
|
519
539
|
include_inactive?: boolean;
|
|
520
540
|
include_chunks?: boolean;
|
|
521
541
|
include_relations?: boolean;
|
|
542
|
+
fast_mode?: boolean;
|
|
522
543
|
}): Promise<any>;
|
|
523
544
|
ingestSession(params: {
|
|
524
545
|
project?: string;
|
|
@@ -576,6 +597,19 @@ declare class WhisperContext {
|
|
|
576
597
|
relations: any[];
|
|
577
598
|
count: number;
|
|
578
599
|
}>;
|
|
600
|
+
getMemoryGraph(params: {
|
|
601
|
+
project?: string;
|
|
602
|
+
user_id?: string;
|
|
603
|
+
session_id?: string;
|
|
604
|
+
include_inactive?: boolean;
|
|
605
|
+
limit?: number;
|
|
606
|
+
}): Promise<any>;
|
|
607
|
+
getConversationGraph(params: {
|
|
608
|
+
project?: string;
|
|
609
|
+
session_id: string;
|
|
610
|
+
include_inactive?: boolean;
|
|
611
|
+
limit?: number;
|
|
612
|
+
}): Promise<any>;
|
|
579
613
|
oracleSearch(params: {
|
|
580
614
|
query: string;
|
|
581
615
|
project?: string;
|
|
@@ -835,6 +869,8 @@ declare class WhisperContext {
|
|
|
835
869
|
relations: any[];
|
|
836
870
|
count: number;
|
|
837
871
|
}>;
|
|
872
|
+
getGraph: (params: Parameters<WhisperContext["getMemoryGraph"]>[0]) => Promise<any>;
|
|
873
|
+
getConversationGraph: (params: Parameters<WhisperContext["getConversationGraph"]>[0]) => Promise<any>;
|
|
838
874
|
consolidate: (params: Parameters<WhisperContext["consolidateMemories"]>[0]) => Promise<any>;
|
|
839
875
|
updateDecay: (params: Parameters<WhisperContext["updateImportanceDecay"]>[0]) => Promise<{
|
|
840
876
|
success: boolean;
|
|
@@ -919,4 +955,4 @@ declare class WhisperContext {
|
|
|
919
955
|
};
|
|
920
956
|
}
|
|
921
957
|
|
|
922
|
-
export { type ExtractedMemory, type Memory, type MemoryExtractionResult, type MemoryKind, type Project, type QueryParams, type QueryResult, type Source, Whisper, WhisperAgentMiddleware, type WhisperConfig, WhisperContext, Whisper as WhisperDefault, WhisperError, type WhisperErrorCode, createAgentMiddleware, WhisperContext as default };
|
|
958
|
+
export { type ExtractedMemory, type Memory, type MemoryExtractionResult, type MemoryKind, type Project, type QueryParams, type QueryResult, type Source, Whisper, WhisperAgentMiddleware, type WhisperConfig, WhisperContext, Whisper as WhisperDefault, WhisperError, type WhisperErrorCode, createAgentMiddleware, WhisperContext as default, memoryGraphToMermaid };
|
package/index.d.ts
CHANGED
|
@@ -239,6 +239,26 @@ declare class WhisperAgentMiddleware {
|
|
|
239
239
|
}
|
|
240
240
|
declare function createAgentMiddleware(config: AgentMiddlewareConfig): WhisperAgentMiddleware;
|
|
241
241
|
|
|
242
|
+
interface MemoryGraphNode {
|
|
243
|
+
id: string;
|
|
244
|
+
label?: string;
|
|
245
|
+
memory_type?: string;
|
|
246
|
+
}
|
|
247
|
+
interface MemoryGraphEdge {
|
|
248
|
+
source: string;
|
|
249
|
+
target: string;
|
|
250
|
+
type?: string;
|
|
251
|
+
}
|
|
252
|
+
interface MemoryGraphPayload {
|
|
253
|
+
nodes: MemoryGraphNode[];
|
|
254
|
+
edges: MemoryGraphEdge[];
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Convert memory graph payload to Mermaid flowchart syntax.
|
|
258
|
+
* Useful for quick visualization in docs/dashboards.
|
|
259
|
+
*/
|
|
260
|
+
declare function memoryGraphToMermaid(graph: MemoryGraphPayload): string;
|
|
261
|
+
|
|
242
262
|
/**
|
|
243
263
|
* Whisper Context SDK
|
|
244
264
|
* TypeScript SDK for the Whisper Context API
|
|
@@ -519,6 +539,7 @@ declare class WhisperContext {
|
|
|
519
539
|
include_inactive?: boolean;
|
|
520
540
|
include_chunks?: boolean;
|
|
521
541
|
include_relations?: boolean;
|
|
542
|
+
fast_mode?: boolean;
|
|
522
543
|
}): Promise<any>;
|
|
523
544
|
ingestSession(params: {
|
|
524
545
|
project?: string;
|
|
@@ -576,6 +597,19 @@ declare class WhisperContext {
|
|
|
576
597
|
relations: any[];
|
|
577
598
|
count: number;
|
|
578
599
|
}>;
|
|
600
|
+
getMemoryGraph(params: {
|
|
601
|
+
project?: string;
|
|
602
|
+
user_id?: string;
|
|
603
|
+
session_id?: string;
|
|
604
|
+
include_inactive?: boolean;
|
|
605
|
+
limit?: number;
|
|
606
|
+
}): Promise<any>;
|
|
607
|
+
getConversationGraph(params: {
|
|
608
|
+
project?: string;
|
|
609
|
+
session_id: string;
|
|
610
|
+
include_inactive?: boolean;
|
|
611
|
+
limit?: number;
|
|
612
|
+
}): Promise<any>;
|
|
579
613
|
oracleSearch(params: {
|
|
580
614
|
query: string;
|
|
581
615
|
project?: string;
|
|
@@ -835,6 +869,8 @@ declare class WhisperContext {
|
|
|
835
869
|
relations: any[];
|
|
836
870
|
count: number;
|
|
837
871
|
}>;
|
|
872
|
+
getGraph: (params: Parameters<WhisperContext["getMemoryGraph"]>[0]) => Promise<any>;
|
|
873
|
+
getConversationGraph: (params: Parameters<WhisperContext["getConversationGraph"]>[0]) => Promise<any>;
|
|
838
874
|
consolidate: (params: Parameters<WhisperContext["consolidateMemories"]>[0]) => Promise<any>;
|
|
839
875
|
updateDecay: (params: Parameters<WhisperContext["updateImportanceDecay"]>[0]) => Promise<{
|
|
840
876
|
success: boolean;
|
|
@@ -919,4 +955,4 @@ declare class WhisperContext {
|
|
|
919
955
|
};
|
|
920
956
|
}
|
|
921
957
|
|
|
922
|
-
export { type ExtractedMemory, type Memory, type MemoryExtractionResult, type MemoryKind, type Project, type QueryParams, type QueryResult, type Source, Whisper, WhisperAgentMiddleware, type WhisperConfig, WhisperContext, Whisper as WhisperDefault, WhisperError, type WhisperErrorCode, createAgentMiddleware, WhisperContext as default };
|
|
958
|
+
export { type ExtractedMemory, type Memory, type MemoryExtractionResult, type MemoryKind, type Project, type QueryParams, type QueryResult, type Source, Whisper, WhisperAgentMiddleware, type WhisperConfig, WhisperContext, Whisper as WhisperDefault, WhisperError, type WhisperErrorCode, createAgentMiddleware, WhisperContext as default, memoryGraphToMermaid };
|
package/index.js
CHANGED
|
@@ -26,7 +26,8 @@ __export(index_exports, {
|
|
|
26
26
|
WhisperDefault: () => whisper_agent_default,
|
|
27
27
|
WhisperError: () => WhisperError,
|
|
28
28
|
createAgentMiddleware: () => createAgentMiddleware,
|
|
29
|
-
default: () => index_default
|
|
29
|
+
default: () => index_default,
|
|
30
|
+
memoryGraphToMermaid: () => memoryGraphToMermaid
|
|
30
31
|
});
|
|
31
32
|
module.exports = __toCommonJS(index_exports);
|
|
32
33
|
|
|
@@ -346,6 +347,31 @@ function createAgentMiddleware(config) {
|
|
|
346
347
|
return new WhisperAgentMiddleware(config);
|
|
347
348
|
}
|
|
348
349
|
|
|
350
|
+
// ../src/sdk/graph-utils.ts
|
|
351
|
+
function sanitizeId(id) {
|
|
352
|
+
return `n_${id.replace(/[^a-zA-Z0-9_]/g, "_")}`;
|
|
353
|
+
}
|
|
354
|
+
function shortLabel(input, max = 48) {
|
|
355
|
+
const text = (input || "").replace(/\s+/g, " ").trim();
|
|
356
|
+
if (text.length <= max) return text;
|
|
357
|
+
return `${text.slice(0, max - 3)}...`;
|
|
358
|
+
}
|
|
359
|
+
function memoryGraphToMermaid(graph) {
|
|
360
|
+
const lines = ["flowchart LR"];
|
|
361
|
+
for (const node of graph.nodes || []) {
|
|
362
|
+
const sid = sanitizeId(node.id);
|
|
363
|
+
const label = shortLabel(node.label || node.id);
|
|
364
|
+
lines.push(` ${sid}["${label.replace(/"/g, '\\"')}"]`);
|
|
365
|
+
}
|
|
366
|
+
for (const edge of graph.edges || []) {
|
|
367
|
+
const s = sanitizeId(edge.source);
|
|
368
|
+
const t = sanitizeId(edge.target);
|
|
369
|
+
const rel = shortLabel(edge.type || "rel", 18).replace(/"/g, '\\"');
|
|
370
|
+
lines.push(` ${s} -->|${rel}| ${t}`);
|
|
371
|
+
}
|
|
372
|
+
return lines.join("\n");
|
|
373
|
+
}
|
|
374
|
+
|
|
349
375
|
// ../src/sdk/index.ts
|
|
350
376
|
var WhisperError = class extends Error {
|
|
351
377
|
code;
|
|
@@ -847,6 +873,26 @@ var WhisperContext = class _WhisperContext {
|
|
|
847
873
|
async getMemoryRelations(memoryId) {
|
|
848
874
|
return this.request(`/v1/memory/${memoryId}/relations`);
|
|
849
875
|
}
|
|
876
|
+
async getMemoryGraph(params) {
|
|
877
|
+
const project = await this.resolveProjectId(this.getRequiredProject(params.project));
|
|
878
|
+
const query = new URLSearchParams({
|
|
879
|
+
project,
|
|
880
|
+
...params.user_id && { user_id: params.user_id },
|
|
881
|
+
...params.session_id && { session_id: params.session_id },
|
|
882
|
+
...params.include_inactive !== void 0 && { include_inactive: String(params.include_inactive) },
|
|
883
|
+
...params.limit !== void 0 && { limit: String(params.limit) }
|
|
884
|
+
});
|
|
885
|
+
return this.request(`/v1/memory/graph?${query}`);
|
|
886
|
+
}
|
|
887
|
+
async getConversationGraph(params) {
|
|
888
|
+
const project = await this.resolveProjectId(this.getRequiredProject(params.project));
|
|
889
|
+
const query = new URLSearchParams({
|
|
890
|
+
project,
|
|
891
|
+
...params.include_inactive !== void 0 && { include_inactive: String(params.include_inactive) },
|
|
892
|
+
...params.limit !== void 0 && { limit: String(params.limit) }
|
|
893
|
+
});
|
|
894
|
+
return this.request(`/v1/memory/graph/conversation/${params.session_id}?${query}`);
|
|
895
|
+
}
|
|
850
896
|
async oracleSearch(params) {
|
|
851
897
|
const project = await this.resolveProjectId(this.getRequiredProject(params.project));
|
|
852
898
|
return this.request("/v1/oracle/search", {
|
|
@@ -983,6 +1029,8 @@ var WhisperContext = class _WhisperContext {
|
|
|
983
1029
|
update: (memoryId, params) => this.updateMemory(memoryId, params),
|
|
984
1030
|
delete: (memoryId) => this.deleteMemory(memoryId),
|
|
985
1031
|
getRelations: (memoryId) => this.getMemoryRelations(memoryId),
|
|
1032
|
+
getGraph: (params) => this.getMemoryGraph(params),
|
|
1033
|
+
getConversationGraph: (params) => this.getConversationGraph(params),
|
|
986
1034
|
consolidate: (params) => this.consolidateMemories(params),
|
|
987
1035
|
updateDecay: (params) => this.updateImportanceDecay(params),
|
|
988
1036
|
getImportanceStats: (project) => this.getImportanceStats(project)
|
|
@@ -1017,5 +1065,6 @@ var index_default = WhisperContext;
|
|
|
1017
1065
|
WhisperContext,
|
|
1018
1066
|
WhisperDefault,
|
|
1019
1067
|
WhisperError,
|
|
1020
|
-
createAgentMiddleware
|
|
1068
|
+
createAgentMiddleware,
|
|
1069
|
+
memoryGraphToMermaid
|
|
1021
1070
|
});
|
package/index.mjs
CHANGED
|
@@ -314,6 +314,31 @@ function createAgentMiddleware(config) {
|
|
|
314
314
|
return new WhisperAgentMiddleware(config);
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
+
// ../src/sdk/graph-utils.ts
|
|
318
|
+
function sanitizeId(id) {
|
|
319
|
+
return `n_${id.replace(/[^a-zA-Z0-9_]/g, "_")}`;
|
|
320
|
+
}
|
|
321
|
+
function shortLabel(input, max = 48) {
|
|
322
|
+
const text = (input || "").replace(/\s+/g, " ").trim();
|
|
323
|
+
if (text.length <= max) return text;
|
|
324
|
+
return `${text.slice(0, max - 3)}...`;
|
|
325
|
+
}
|
|
326
|
+
function memoryGraphToMermaid(graph) {
|
|
327
|
+
const lines = ["flowchart LR"];
|
|
328
|
+
for (const node of graph.nodes || []) {
|
|
329
|
+
const sid = sanitizeId(node.id);
|
|
330
|
+
const label = shortLabel(node.label || node.id);
|
|
331
|
+
lines.push(` ${sid}["${label.replace(/"/g, '\\"')}"]`);
|
|
332
|
+
}
|
|
333
|
+
for (const edge of graph.edges || []) {
|
|
334
|
+
const s = sanitizeId(edge.source);
|
|
335
|
+
const t = sanitizeId(edge.target);
|
|
336
|
+
const rel = shortLabel(edge.type || "rel", 18).replace(/"/g, '\\"');
|
|
337
|
+
lines.push(` ${s} -->|${rel}| ${t}`);
|
|
338
|
+
}
|
|
339
|
+
return lines.join("\n");
|
|
340
|
+
}
|
|
341
|
+
|
|
317
342
|
// ../src/sdk/index.ts
|
|
318
343
|
var WhisperError = class extends Error {
|
|
319
344
|
code;
|
|
@@ -815,6 +840,26 @@ var WhisperContext = class _WhisperContext {
|
|
|
815
840
|
async getMemoryRelations(memoryId) {
|
|
816
841
|
return this.request(`/v1/memory/${memoryId}/relations`);
|
|
817
842
|
}
|
|
843
|
+
async getMemoryGraph(params) {
|
|
844
|
+
const project = await this.resolveProjectId(this.getRequiredProject(params.project));
|
|
845
|
+
const query = new URLSearchParams({
|
|
846
|
+
project,
|
|
847
|
+
...params.user_id && { user_id: params.user_id },
|
|
848
|
+
...params.session_id && { session_id: params.session_id },
|
|
849
|
+
...params.include_inactive !== void 0 && { include_inactive: String(params.include_inactive) },
|
|
850
|
+
...params.limit !== void 0 && { limit: String(params.limit) }
|
|
851
|
+
});
|
|
852
|
+
return this.request(`/v1/memory/graph?${query}`);
|
|
853
|
+
}
|
|
854
|
+
async getConversationGraph(params) {
|
|
855
|
+
const project = await this.resolveProjectId(this.getRequiredProject(params.project));
|
|
856
|
+
const query = new URLSearchParams({
|
|
857
|
+
project,
|
|
858
|
+
...params.include_inactive !== void 0 && { include_inactive: String(params.include_inactive) },
|
|
859
|
+
...params.limit !== void 0 && { limit: String(params.limit) }
|
|
860
|
+
});
|
|
861
|
+
return this.request(`/v1/memory/graph/conversation/${params.session_id}?${query}`);
|
|
862
|
+
}
|
|
818
863
|
async oracleSearch(params) {
|
|
819
864
|
const project = await this.resolveProjectId(this.getRequiredProject(params.project));
|
|
820
865
|
return this.request("/v1/oracle/search", {
|
|
@@ -951,6 +996,8 @@ var WhisperContext = class _WhisperContext {
|
|
|
951
996
|
update: (memoryId, params) => this.updateMemory(memoryId, params),
|
|
952
997
|
delete: (memoryId) => this.deleteMemory(memoryId),
|
|
953
998
|
getRelations: (memoryId) => this.getMemoryRelations(memoryId),
|
|
999
|
+
getGraph: (params) => this.getMemoryGraph(params),
|
|
1000
|
+
getConversationGraph: (params) => this.getConversationGraph(params),
|
|
954
1001
|
consolidate: (params) => this.consolidateMemories(params),
|
|
955
1002
|
updateDecay: (params) => this.updateImportanceDecay(params),
|
|
956
1003
|
getImportanceStats: (project) => this.getImportanceStats(project)
|
|
@@ -985,5 +1032,6 @@ export {
|
|
|
985
1032
|
whisper_agent_default as WhisperDefault,
|
|
986
1033
|
WhisperError,
|
|
987
1034
|
createAgentMiddleware,
|
|
988
|
-
index_default as default
|
|
1035
|
+
index_default as default,
|
|
1036
|
+
memoryGraphToMermaid
|
|
989
1037
|
};
|