@pyxmate/memory 0.0.4-beta → 0.1.0-beta
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/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
SDK for **pyx-memory** — Memory as a Service for AI agents.
|
|
4
4
|
|
|
5
|
-
Provides an HTTP client, shared types, and optional dashboard + React hooks for interacting with
|
|
5
|
+
Provides an HTTP client, shared types, and optional dashboard + React hooks for interacting with the pyx-memory managed cloud.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -16,7 +16,7 @@ npm install @pyxmate/memory
|
|
|
16
16
|
import { MemoryClient } from '@pyxmate/memory';
|
|
17
17
|
import type { MemoryEntry } from '@pyxmate/memory';
|
|
18
18
|
|
|
19
|
-
const client = new MemoryClient('
|
|
19
|
+
const client = new MemoryClient('https://your-pyx-memory-endpoint');
|
|
20
20
|
await client.initialize();
|
|
21
21
|
|
|
22
22
|
// Store a memory
|
|
@@ -25,7 +25,7 @@ await client.store({
|
|
|
25
25
|
agentId: 'my-agent',
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
// Search memories
|
|
28
|
+
// Search memories — smart retrieval picks the best strategy
|
|
29
29
|
const results = await client.search({ query: 'deadline', limit: 5 });
|
|
30
30
|
```
|
|
31
31
|
|
|
@@ -37,12 +37,9 @@ const results = await client.search({ query: 'deadline', limit: 5 });
|
|
|
37
37
|
| `@pyxmate/memory/dashboard` | Headless dashboard utilities — `DashboardClient`, aggregations, graph transforms (no React) |
|
|
38
38
|
| `@pyxmate/memory/react` | React hooks — `useMemoryStats`, `useMemoryHealth`, `useKnowledgeGraph`, etc. (requires React >= 18) |
|
|
39
39
|
|
|
40
|
-
##
|
|
40
|
+
## Managed Cloud
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
docker pull ghcr.io/fysoul17/pyx-memory:latest
|
|
44
|
-
docker run -p 7822:7822 ghcr.io/fysoul17/pyx-memory:latest
|
|
45
|
-
```
|
|
42
|
+
pyx-memory is deployed exclusively as a managed cloud service at **[memory.pyxmate.com](https://memory.pyxmate.com)**.
|
|
46
43
|
|
|
47
44
|
## Requirements
|
|
48
45
|
|
|
@@ -29,13 +29,7 @@ var MemoryClient = class {
|
|
|
29
29
|
async store(entry) {
|
|
30
30
|
return this.fetchApi("/api/memory/ingest", {
|
|
31
31
|
method: "POST",
|
|
32
|
-
body: JSON.stringify(
|
|
33
|
-
content: entry.content,
|
|
34
|
-
type: entry.type,
|
|
35
|
-
metadata: entry.metadata,
|
|
36
|
-
agentId: entry.agentId,
|
|
37
|
-
sessionId: entry.sessionId
|
|
38
|
-
})
|
|
32
|
+
body: JSON.stringify(entry)
|
|
39
33
|
});
|
|
40
34
|
}
|
|
41
35
|
async search(params) {
|
|
@@ -44,6 +38,11 @@ var MemoryClient = class {
|
|
|
44
38
|
if (params.type) searchParams.set("type", params.type);
|
|
45
39
|
if (params.agentId) searchParams.set("agentId", params.agentId);
|
|
46
40
|
if (params.strategy) searchParams.set("strategy", params.strategy);
|
|
41
|
+
if (params.eventTimeRange) {
|
|
42
|
+
searchParams.set("eventTimeStart", params.eventTimeRange[0]);
|
|
43
|
+
searchParams.set("eventTimeEnd", params.eventTimeRange[1]);
|
|
44
|
+
}
|
|
45
|
+
if (params.asOf) searchParams.set("asOf", params.asOf);
|
|
47
46
|
return this.fetchApi(`/api/memory/search?${searchParams}`);
|
|
48
47
|
}
|
|
49
48
|
async get(id) {
|
|
@@ -168,6 +167,28 @@ var MemoryClient = class {
|
|
|
168
167
|
);
|
|
169
168
|
return result.deleted;
|
|
170
169
|
}
|
|
170
|
+
async queryAsOf(asOfDate, filters = {}) {
|
|
171
|
+
const params = new URLSearchParams({ asOf: asOfDate });
|
|
172
|
+
if (filters.type) params.set("type", filters.type);
|
|
173
|
+
if (filters.agentId) params.set("agentId", filters.agentId);
|
|
174
|
+
if (filters.source) params.set("source", filters.source);
|
|
175
|
+
if (filters.limit) params.set("limit", String(filters.limit));
|
|
176
|
+
const result = await this.fetchApi(
|
|
177
|
+
`/api/memory/query-as-of?${params}`
|
|
178
|
+
);
|
|
179
|
+
return result.entries;
|
|
180
|
+
}
|
|
181
|
+
async queryByEventTime(startTime, endTime, filters = {}) {
|
|
182
|
+
const params = new URLSearchParams({ startTime, endTime });
|
|
183
|
+
if (filters.type) params.set("type", filters.type);
|
|
184
|
+
if (filters.agentId) params.set("agentId", filters.agentId);
|
|
185
|
+
if (filters.source) params.set("source", filters.source);
|
|
186
|
+
if (filters.limit) params.set("limit", String(filters.limit));
|
|
187
|
+
const result = await this.fetchApi(
|
|
188
|
+
`/api/memory/query-by-event-time?${params}`
|
|
189
|
+
);
|
|
190
|
+
return result.entries;
|
|
191
|
+
}
|
|
171
192
|
async fetchApi(path, options) {
|
|
172
193
|
const res = await fetch(`${this.baseUrl}${path}`, {
|
|
173
194
|
...options,
|
package/dist/dashboard.mjs
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MemoryEntry as MemoryEntry$1, MemorySearchParams as MemorySearchParams$1, MemorySearchResult as MemorySearchResult$1, MemoryType as MemoryType$1, MemoryStats as MemoryStats$1, GraphNode as GraphNode$1, GraphTraversalResult as GraphTraversalResult$1 } from '@pyx-memory/shared';
|
|
1
|
+
import { StoreInput as StoreInput$1, MemoryEntry as MemoryEntry$1, MemorySearchParams as MemorySearchParams$1, MemorySearchResult as MemorySearchResult$1, MemoryType as MemoryType$1, MemoryStats as MemoryStats$1, GraphNode as GraphNode$1, GraphTraversalResult as GraphTraversalResult$1 } from '@pyx-memory/shared';
|
|
2
2
|
|
|
3
3
|
/** Parameters for paginated entry listing. */
|
|
4
4
|
interface MemoryListParams {
|
|
@@ -18,13 +18,17 @@ interface MemoryListResult {
|
|
|
18
18
|
page: number;
|
|
19
19
|
limit: number;
|
|
20
20
|
}
|
|
21
|
+
/** Filters for temporal queries (queryAsOf, queryByEventTime). */
|
|
22
|
+
interface TemporalQueryFilters {
|
|
23
|
+
type?: MemoryType$1;
|
|
24
|
+
agentId?: string;
|
|
25
|
+
source?: string;
|
|
26
|
+
limit?: number;
|
|
27
|
+
}
|
|
21
28
|
/** Abstract interface for memory systems (local or remote). */
|
|
22
29
|
interface MemoryInterface {
|
|
23
30
|
initialize(): Promise<void>;
|
|
24
|
-
store(entry:
|
|
25
|
-
id?: string;
|
|
26
|
-
createdAt?: string;
|
|
27
|
-
}): Promise<MemoryEntry$1>;
|
|
31
|
+
store(entry: StoreInput$1): Promise<MemoryEntry$1>;
|
|
28
32
|
search(params: MemorySearchParams$1): Promise<MemorySearchResult$1>;
|
|
29
33
|
/** List entries with SQL LIMIT/OFFSET pagination. */
|
|
30
34
|
list(params?: MemoryListParams): Promise<MemoryListResult>;
|
|
@@ -32,6 +36,10 @@ interface MemoryInterface {
|
|
|
32
36
|
delete(id: string): Promise<boolean>;
|
|
33
37
|
clearSession(sessionId: string): Promise<number>;
|
|
34
38
|
stats(): Promise<MemoryStats$1>;
|
|
39
|
+
/** Query entries as they existed at a point in time (by ingest time). */
|
|
40
|
+
queryAsOf(asOfDate: string, filters?: TemporalQueryFilters): Promise<MemoryEntry$1[]>;
|
|
41
|
+
/** Query entries by event time range (when things actually happened). */
|
|
42
|
+
queryByEventTime(startTime: string, endTime: string, filters?: TemporalQueryFilters): Promise<MemoryEntry$1[]>;
|
|
35
43
|
shutdown(): Promise<void>;
|
|
36
44
|
}
|
|
37
45
|
/** Consolidation run result. */
|
|
@@ -59,7 +67,9 @@ interface ExtendedMemoryInterface extends MemoryInterface {
|
|
|
59
67
|
|
|
60
68
|
interface IngestionResult {
|
|
61
69
|
filename: string;
|
|
70
|
+
fileType: string;
|
|
62
71
|
chunks: number;
|
|
72
|
+
entryIds: string[];
|
|
63
73
|
totalCharacters: number;
|
|
64
74
|
}
|
|
65
75
|
|
|
@@ -76,10 +86,7 @@ declare class MemoryClient implements ExtendedMemoryInterface {
|
|
|
76
86
|
/** Encode a path segment to prevent URL injection */
|
|
77
87
|
private encodePathSegment;
|
|
78
88
|
initialize(): Promise<void>;
|
|
79
|
-
store(entry:
|
|
80
|
-
id?: string;
|
|
81
|
-
createdAt?: string;
|
|
82
|
-
}): Promise<MemoryEntry$1>;
|
|
89
|
+
store(entry: StoreInput$1): Promise<MemoryEntry$1>;
|
|
83
90
|
search(params: MemorySearchParams$1): Promise<MemorySearchResult$1>;
|
|
84
91
|
get(id: string): Promise<MemoryEntry$1 | null>;
|
|
85
92
|
delete(id: string): Promise<boolean>;
|
|
@@ -110,13 +117,14 @@ declare class MemoryClient implements ExtendedMemoryInterface {
|
|
|
110
117
|
runDecay(): Promise<number>;
|
|
111
118
|
reindex(): Promise<void>;
|
|
112
119
|
deleteBySource(source: string): Promise<number>;
|
|
120
|
+
queryAsOf(asOfDate: string, filters?: TemporalQueryFilters): Promise<MemoryEntry$1[]>;
|
|
121
|
+
queryByEventTime(startTime: string, endTime: string, filters?: TemporalQueryFilters): Promise<MemoryEntry$1[]>;
|
|
113
122
|
protected fetchApi<T>(path: string, options?: RequestInit): Promise<T>;
|
|
114
123
|
}
|
|
115
124
|
|
|
116
125
|
declare const DEFAULTS: {
|
|
117
126
|
readonly DATA_DIR: "./data";
|
|
118
127
|
readonly VECTOR_PROVIDER: "lancedb";
|
|
119
|
-
readonly EMBEDDING_PROVIDER: "stub";
|
|
120
128
|
readonly MEMORY_SERVER_PORT: 7822;
|
|
121
129
|
};
|
|
122
130
|
|
|
@@ -148,12 +156,13 @@ declare const RAGStrategy: {
|
|
|
148
156
|
type RAGStrategy = (typeof RAGStrategy)[keyof typeof RAGStrategy];
|
|
149
157
|
declare const VectorProvider: {
|
|
150
158
|
readonly LANCEDB: "lancedb";
|
|
151
|
-
readonly QDRANT: "qdrant";
|
|
152
159
|
};
|
|
153
160
|
type VectorProvider = (typeof VectorProvider)[keyof typeof VectorProvider];
|
|
154
161
|
declare const EmbeddingProviderName: {
|
|
155
162
|
readonly STUB: "stub";
|
|
163
|
+
/** @deprecated Vestigial — pyx-memory uses internal BGE-M3 embeddings. */
|
|
156
164
|
readonly ANTHROPIC: "anthropic";
|
|
165
|
+
/** @deprecated Vestigial — pyx-memory uses internal BGE-M3 embeddings. */
|
|
157
166
|
readonly OPENAI: "openai";
|
|
158
167
|
readonly LOCAL: "local";
|
|
159
168
|
};
|
|
@@ -165,6 +174,7 @@ interface MemoryEntry {
|
|
|
165
174
|
agentId?: AgentId;
|
|
166
175
|
sessionId?: string;
|
|
167
176
|
metadata: Record<string, unknown>;
|
|
177
|
+
/** @deprecated Vestigial — embeddings are managed internally by the vector store. */
|
|
168
178
|
embedding?: number[];
|
|
169
179
|
createdAt: Timestamp;
|
|
170
180
|
/** SHA-256 hash of content for deduplication. */
|
|
@@ -184,30 +194,16 @@ interface MemoryEntry {
|
|
|
184
194
|
/** When this entry was ingested into the system. */
|
|
185
195
|
ingestTime?: string;
|
|
186
196
|
}
|
|
187
|
-
interface SearchFilters {
|
|
188
|
-
/** Filter by source identifier. */
|
|
189
|
-
source?: string;
|
|
190
|
-
/** Minimum importance score. */
|
|
191
|
-
importanceMin?: number;
|
|
192
|
-
/** Event time range [start, end] as ISO timestamps. */
|
|
193
|
-
eventTimeRange?: [string, string];
|
|
194
|
-
/** Filter by parent entry ID. */
|
|
195
|
-
parentId?: string;
|
|
196
|
-
/** Filter by content type in metadata. */
|
|
197
|
-
contentType?: string;
|
|
198
|
-
}
|
|
199
197
|
interface MemorySearchParams {
|
|
200
198
|
query: string;
|
|
201
199
|
type?: MemoryType;
|
|
202
200
|
agentId?: AgentId;
|
|
203
201
|
limit?: number;
|
|
204
202
|
strategy?: RAGStrategy;
|
|
205
|
-
/**
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
|
|
209
|
-
/** Enable reranking of results. */
|
|
210
|
-
enableRerank?: boolean;
|
|
203
|
+
/** Filter results to entries whose eventTime falls within [start, end] (ISO 8601). */
|
|
204
|
+
eventTimeRange?: [string, string];
|
|
205
|
+
/** Filter results to entries ingested before this cutoff (ISO 8601). Falls back to createdAt when ingestTime is null. */
|
|
206
|
+
asOf?: string;
|
|
211
207
|
}
|
|
212
208
|
interface MemorySearchResult {
|
|
213
209
|
entries: MemoryEntry[];
|
|
@@ -219,11 +215,67 @@ interface MemorySearchResult {
|
|
|
219
215
|
score: number;
|
|
220
216
|
}>;
|
|
221
217
|
}
|
|
218
|
+
declare const StoreTarget: {
|
|
219
|
+
readonly SQLITE: "sqlite";
|
|
220
|
+
readonly VECTOR: "vector";
|
|
221
|
+
readonly GRAPH: "graph";
|
|
222
|
+
};
|
|
223
|
+
type StoreTarget = (typeof StoreTarget)[keyof typeof StoreTarget];
|
|
224
|
+
/** Agent-provided entity for graph storage. */
|
|
225
|
+
interface IngestEntity {
|
|
226
|
+
/** Entity name (e.g., "Alice", "TypeScript"). */
|
|
227
|
+
name: string;
|
|
228
|
+
/** Entity type — freeform, agent decides (e.g., "PERSON", "TOOL"). */
|
|
229
|
+
type: string;
|
|
230
|
+
/** Optional properties to attach to the graph node. */
|
|
231
|
+
properties?: Record<string, unknown>;
|
|
232
|
+
}
|
|
233
|
+
/** Agent-provided relationship for graph storage. */
|
|
234
|
+
interface IngestRelationship {
|
|
235
|
+
/** Source entity name (must match an entity in the entities array). */
|
|
236
|
+
source: string;
|
|
237
|
+
/** Target entity name (must match an entity in the entities array). */
|
|
238
|
+
target: string;
|
|
239
|
+
/** Relationship type — freeform, agent decides (e.g., "WORKS_AT", "USES"). */
|
|
240
|
+
type: string;
|
|
241
|
+
/** Optional properties to attach to the graph edge. */
|
|
242
|
+
properties?: Record<string, unknown>;
|
|
243
|
+
}
|
|
244
|
+
/** Store input: what the agent sends to Memory.store(). */
|
|
245
|
+
type StoreInput = Omit<MemoryEntry, 'id' | 'createdAt'> & {
|
|
246
|
+
id?: string;
|
|
247
|
+
createdAt?: string;
|
|
248
|
+
/** Storage targets. Default: ["sqlite", "vector"]. */
|
|
249
|
+
targets?: StoreTarget[];
|
|
250
|
+
/** Agent-provided entities for graph storage. Required when targets includes "graph". */
|
|
251
|
+
entities?: IngestEntity[];
|
|
252
|
+
/** Agent-provided relationships for graph storage. */
|
|
253
|
+
relationships?: IngestRelationship[];
|
|
254
|
+
};
|
|
222
255
|
interface MemoryIngestRequest {
|
|
223
256
|
content?: string;
|
|
224
257
|
type?: MemoryType;
|
|
225
|
-
fileType?: 'pdf' | 'csv' | 'txt';
|
|
226
258
|
metadata?: Record<string, unknown>;
|
|
259
|
+
agentId?: string;
|
|
260
|
+
sessionId?: string;
|
|
261
|
+
/** Storage targets. Default: ["sqlite", "vector"]. */
|
|
262
|
+
targets?: StoreTarget[];
|
|
263
|
+
/** Agent-provided entities for graph storage. Required when targets includes "graph". */
|
|
264
|
+
entities?: IngestEntity[];
|
|
265
|
+
/** Agent-provided relationships for graph storage. */
|
|
266
|
+
relationships?: IngestRelationship[];
|
|
267
|
+
/** Importance score (1-10). */
|
|
268
|
+
importance?: number;
|
|
269
|
+
/** Source identifier (e.g., filename, URL). */
|
|
270
|
+
source?: string;
|
|
271
|
+
/** When the event occurred (ISO timestamp). */
|
|
272
|
+
eventTime?: string;
|
|
273
|
+
/** Optional deterministic ID for the entry (agent-provided). */
|
|
274
|
+
id?: string;
|
|
275
|
+
/** Parent entry ID for hierarchical storage (e.g., doc → section → chunk). */
|
|
276
|
+
parentId?: string;
|
|
277
|
+
/** When this entry was ingested (ISO timestamp). Default: now. */
|
|
278
|
+
ingestTime?: string;
|
|
227
279
|
}
|
|
228
280
|
interface MemoryStats {
|
|
229
281
|
totalEntries: number;
|
|
@@ -235,14 +287,6 @@ interface MemoryStats {
|
|
|
235
287
|
/** Whether the memory service is connected. False when using DisabledMemory. */
|
|
236
288
|
connected?: boolean;
|
|
237
289
|
}
|
|
238
|
-
interface GraphEdge {
|
|
239
|
-
id: string;
|
|
240
|
-
sourceEntity: string;
|
|
241
|
-
targetEntity: string;
|
|
242
|
-
relation: string;
|
|
243
|
-
weight: number;
|
|
244
|
-
memoryEntryId: string;
|
|
245
|
-
}
|
|
246
290
|
interface GraphNode {
|
|
247
291
|
id: string;
|
|
248
292
|
name: string;
|
|
@@ -267,4 +311,4 @@ interface GraphTraversalResult {
|
|
|
267
311
|
}>;
|
|
268
312
|
}
|
|
269
313
|
|
|
270
|
-
export { type AgentId, type ApiResponse, type ConsolidationRunResult, DEFAULTS, EmbeddingProviderName, type ExtendedMemoryInterface, type
|
|
314
|
+
export { type AgentId, type ApiResponse, type ConsolidationRunResult, DEFAULTS, EmbeddingProviderName, type ExtendedMemoryInterface, type GraphNode, type GraphRelationship, type GraphTraversalResult, type IngestEntity, type IngestRelationship, type IngestionResult, MemoryClient, type MemoryEntry, type MemoryIngestRequest, type MemoryInterface, type MemoryListParams, type MemoryListResult, type MemorySearchParams, type MemorySearchResult, MemoryServerError, type MemoryStats, MemoryType, RAGStrategy, type StoreInput, StoreTarget, type TemporalQueryFilters, type Timestamp, VectorProvider };
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MemoryClient,
|
|
3
3
|
MemoryServerError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-VJGRAIVX.mjs";
|
|
5
5
|
|
|
6
6
|
// ../shared/src/constants/defaults.ts
|
|
7
7
|
var DEFAULTS = {
|
|
8
8
|
DATA_DIR: "./data",
|
|
9
9
|
VECTOR_PROVIDER: "lancedb",
|
|
10
|
-
EMBEDDING_PROVIDER: "stub",
|
|
11
10
|
MEMORY_SERVER_PORT: 7822
|
|
12
11
|
};
|
|
13
12
|
|
|
@@ -26,15 +25,21 @@ var RAGStrategy = {
|
|
|
26
25
|
HYBRID: "hybrid"
|
|
27
26
|
};
|
|
28
27
|
var VectorProvider = {
|
|
29
|
-
LANCEDB: "lancedb"
|
|
30
|
-
QDRANT: "qdrant"
|
|
28
|
+
LANCEDB: "lancedb"
|
|
31
29
|
};
|
|
32
30
|
var EmbeddingProviderName = {
|
|
33
31
|
STUB: "stub",
|
|
32
|
+
/** @deprecated Vestigial — pyx-memory uses internal BGE-M3 embeddings. */
|
|
34
33
|
ANTHROPIC: "anthropic",
|
|
34
|
+
/** @deprecated Vestigial — pyx-memory uses internal BGE-M3 embeddings. */
|
|
35
35
|
OPENAI: "openai",
|
|
36
36
|
LOCAL: "local"
|
|
37
37
|
};
|
|
38
|
+
var StoreTarget = {
|
|
39
|
+
SQLITE: "sqlite",
|
|
40
|
+
VECTOR: "vector",
|
|
41
|
+
GRAPH: "graph"
|
|
42
|
+
};
|
|
38
43
|
export {
|
|
39
44
|
DEFAULTS,
|
|
40
45
|
EmbeddingProviderName,
|
|
@@ -42,5 +47,6 @@ export {
|
|
|
42
47
|
MemoryServerError,
|
|
43
48
|
MemoryType,
|
|
44
49
|
RAGStrategy,
|
|
50
|
+
StoreTarget,
|
|
45
51
|
VectorProvider
|
|
46
52
|
};
|
package/dist/react.mjs
CHANGED
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
toGraphologyFormat,
|
|
12
12
|
transformGraphData,
|
|
13
13
|
unreachableHealth
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-ACMIMR43.mjs";
|
|
15
|
+
import "./chunk-VJGRAIVX.mjs";
|
|
16
16
|
|
|
17
17
|
// ../dashboard/src/hooks/use-consolidation-log.ts
|
|
18
18
|
import { useCallback as useCallback2, useMemo } from "react";
|