@deepstrike/sdk 0.2.20 → 0.2.21
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/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/memory/in-memory-store.d.ts +37 -0
- package/dist/memory/in-memory-store.js +50 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -60,6 +60,7 @@ export type { RegisteredTool } from "./tools/index.js";
|
|
|
60
60
|
export { scanSkillDir, readSkillFile } from "./skills/loader.js";
|
|
61
61
|
export type { SkillMetadata } from "./skills/loader.js";
|
|
62
62
|
export { WorkingMemory } from "./memory/working.js";
|
|
63
|
+
export { InMemoryDreamStore } from "./memory/in-memory-store.js";
|
|
63
64
|
export type { DreamStore, DreamResult, SessionData, SessionMessage, MemoryEntry, CurationResult, CurationStats, MemoryWriteRequest, MemoryQuery, MemoryRetrieval, MemoryMetadata, MemoryKind, } from "./memory/protocols.js";
|
|
64
65
|
export type { KnowledgeSource } from "./knowledge/source.js";
|
|
65
66
|
export { ScheduledPrompt } from "./signals/scheduled.js";
|
package/dist/index.js
CHANGED
|
@@ -42,6 +42,7 @@ export { tool, streamingTool, executeTools, readFile, validateToolArguments } fr
|
|
|
42
42
|
export { scanSkillDir, readSkillFile } from "./skills/loader.js";
|
|
43
43
|
// ── Memory ─────────────────────────────────────────────────────────────────
|
|
44
44
|
export { WorkingMemory } from "./memory/working.js";
|
|
45
|
+
export { InMemoryDreamStore } from "./memory/in-memory-store.js";
|
|
45
46
|
export { ScheduledPrompt } from "./signals/scheduled.js";
|
|
46
47
|
export { SignalGateway } from "./signals/gateway.js";
|
|
47
48
|
// ── Safety & Governance ────────────────────────────────────────────────────
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `InMemoryDreamStore` — a lightweight `DreamStore` implementation backed by per-agent `Map`s.
|
|
3
|
+
*
|
|
4
|
+
* Originally lived as `MockDreamStore` in the SDK's test helpers; promoted here so benchmarks,
|
|
5
|
+
* examples, and downstream consumers can use it without copying the boilerplate.
|
|
6
|
+
*
|
|
7
|
+
* Use cases:
|
|
8
|
+
* - Benchmark A/B variants where memory is on/off (preload via constructor).
|
|
9
|
+
* - Unit tests that exercise `Agent.dream()` or the `memory_query` path without disk I/O.
|
|
10
|
+
* - Local development / CI where a persistent memory store isn't needed.
|
|
11
|
+
*
|
|
12
|
+
* The `search()` impl is intentionally trivial — it returns the first `topK` memories for the
|
|
13
|
+
* agent regardless of `query`. The kernel ranks by score before deciding what to surface, so the
|
|
14
|
+
* order memories were inserted is what callers see. For semantic search, plug in a real store.
|
|
15
|
+
*/
|
|
16
|
+
import type { CurationResult, DreamStore, MemoryEntry, SessionData } from "./protocols.js";
|
|
17
|
+
export declare class InMemoryDreamStore implements DreamStore {
|
|
18
|
+
private readonly initialMemories;
|
|
19
|
+
private sessions;
|
|
20
|
+
private memories;
|
|
21
|
+
/** Sessions persisted via `saveSession`; exposed for test assertions. */
|
|
22
|
+
readonly savedSessions: SessionData[];
|
|
23
|
+
/**
|
|
24
|
+
* @param initialMemories Optional seed memories applied to every agent that asks for memories
|
|
25
|
+
* for the first time. Useful for benchmark scenarios that preload a fact.
|
|
26
|
+
*/
|
|
27
|
+
constructor(initialMemories?: MemoryEntry[]);
|
|
28
|
+
/** Pre-populate sessions for a specific agent (test/benchmark setup). */
|
|
29
|
+
addSession(agentId: string, session: SessionData): void;
|
|
30
|
+
/** Pre-populate memories for a specific agent (test/benchmark setup). */
|
|
31
|
+
addMemories(agentId: string, entries: MemoryEntry[]): void;
|
|
32
|
+
loadSessions(agentId: string): Promise<SessionData[]>;
|
|
33
|
+
loadMemories(agentId: string): Promise<MemoryEntry[]>;
|
|
34
|
+
commit(agentId: string, result: CurationResult, existing: MemoryEntry[]): Promise<void>;
|
|
35
|
+
search(agentId: string, _query: string, topK?: number): Promise<MemoryEntry[]>;
|
|
36
|
+
saveSession(data: SessionData): Promise<void>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export class InMemoryDreamStore {
|
|
2
|
+
initialMemories;
|
|
3
|
+
sessions = new Map();
|
|
4
|
+
memories = new Map();
|
|
5
|
+
/** Sessions persisted via `saveSession`; exposed for test assertions. */
|
|
6
|
+
savedSessions = [];
|
|
7
|
+
/**
|
|
8
|
+
* @param initialMemories Optional seed memories applied to every agent that asks for memories
|
|
9
|
+
* for the first time. Useful for benchmark scenarios that preload a fact.
|
|
10
|
+
*/
|
|
11
|
+
constructor(initialMemories = []) {
|
|
12
|
+
this.initialMemories = initialMemories;
|
|
13
|
+
}
|
|
14
|
+
/** Pre-populate sessions for a specific agent (test/benchmark setup). */
|
|
15
|
+
addSession(agentId, session) {
|
|
16
|
+
const list = this.sessions.get(agentId) ?? [];
|
|
17
|
+
list.push(session);
|
|
18
|
+
this.sessions.set(agentId, list);
|
|
19
|
+
}
|
|
20
|
+
/** Pre-populate memories for a specific agent (test/benchmark setup). */
|
|
21
|
+
addMemories(agentId, entries) {
|
|
22
|
+
this.memories.set(agentId, [...(this.memories.get(agentId) ?? []), ...entries]);
|
|
23
|
+
}
|
|
24
|
+
async loadSessions(agentId) {
|
|
25
|
+
return this.sessions.get(agentId) ?? [];
|
|
26
|
+
}
|
|
27
|
+
async loadMemories(agentId) {
|
|
28
|
+
if (this.memories.has(agentId))
|
|
29
|
+
return this.memories.get(agentId);
|
|
30
|
+
if (this.initialMemories.length > 0) {
|
|
31
|
+
this.memories.set(agentId, [...this.initialMemories]);
|
|
32
|
+
return this.memories.get(agentId);
|
|
33
|
+
}
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
async commit(agentId, result, existing) {
|
|
37
|
+
const kept = existing.filter((_, i) => !result.toRemoveIndices.includes(i));
|
|
38
|
+
this.memories.set(agentId, [...kept, ...result.toAdd]);
|
|
39
|
+
}
|
|
40
|
+
async search(agentId, _query, topK = 5) {
|
|
41
|
+
const all = await this.loadMemories(agentId);
|
|
42
|
+
return all.slice(0, topK);
|
|
43
|
+
}
|
|
44
|
+
async saveSession(data) {
|
|
45
|
+
this.savedSessions.push(data);
|
|
46
|
+
const list = this.sessions.get(data.agentId) ?? [];
|
|
47
|
+
list.push(data);
|
|
48
|
+
this.sessions.set(data.agentId, list);
|
|
49
|
+
}
|
|
50
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepstrike/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.21",
|
|
4
4
|
"description": "DeepStrike Node.js SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@anthropic-ai/sdk": "^0.99.0",
|
|
23
|
-
"@deepstrike/core": "0.2.
|
|
23
|
+
"@deepstrike/core": "0.2.21",
|
|
24
24
|
"@google/generative-ai": "^0.24.1",
|
|
25
25
|
"openai": "^5.23.2"
|
|
26
26
|
},
|