@skein-js/storage-memory 0.2.0 → 0.3.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/README.md +2 -2
- package/dist/index.d.ts +15 -9
- package/dist/index.js +17 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> In-memory `SkeinStore` + run queue + event bus for development and tests.
|
|
4
4
|
|
|
5
|
-
Part of **[skein-js](
|
|
5
|
+
Part of **[skein-js](../../README.md)** — a TypeScript [Agent Protocol](https://github.com/langchain-ai/agent-protocol) server for [LangGraph.js](https://github.com/langchain-ai/langgraphjs), and a drop-in replacement for the LangGraph CLI.
|
|
6
6
|
|
|
7
7
|
**Status:** 🚧 Pre-alpha — implemented; passes the shared `SkeinStore` conformance suite.
|
|
8
8
|
|
|
@@ -86,7 +86,7 @@ only Agent Protocol _resources_, never graph state.
|
|
|
86
86
|
## Learn more
|
|
87
87
|
|
|
88
88
|
- [Storage](../../docs/storage.md) · [Runs & Redis](../../docs/runs-and-redis.md)
|
|
89
|
-
- [skein-js overview](../../docs/index.md) · [Reuse-first architecture](../../docs/reuse.md)
|
|
89
|
+
- [skein-js overview](../../docs/index.md) · [Reuse-first architecture](../../docs/reuse.md) · [Root README](../../README.md)
|
|
90
90
|
|
|
91
91
|
## License
|
|
92
92
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SkeinStore, AssistantRepo, ThreadRepo, RunRepo, StoreRepo,
|
|
1
|
+
import { SkeinStore, AssistantRepo, ThreadRepo, RunRepo, StoreRepo, SkeinStoreSnapshot, RunEventBus, RunFrame, RunQueue, QueuedRun, RunProcessor, RunConsumerOptions, RunConsumer } from '@skein-js/core';
|
|
2
2
|
|
|
3
3
|
/** In-process SkeinStore for development and tests. */
|
|
4
4
|
declare class MemorySkeinStore implements SkeinStore {
|
|
@@ -14,15 +14,21 @@ declare class MemorySkeinStore implements SkeinStore {
|
|
|
14
14
|
snapshot(): MemoryStoreSnapshot;
|
|
15
15
|
/** Replace all rows with a {@link snapshot}. Used by `skein dev` to restore persisted dev state. */
|
|
16
16
|
hydrate(snapshot: MemoryStoreSnapshot): void;
|
|
17
|
+
/**
|
|
18
|
+
* Bulk-load rows from a snapshot, preserving ids + timestamps and *without* clearing what's
|
|
19
|
+
* already here: existing ids are left untouched (insert-if-absent). Unlike {@link hydrate} (a
|
|
20
|
+
* full replace for cross-restart persistence), this is the additive, lossless sink used by
|
|
21
|
+
* migration tooling — see `@skein-js/express`'s LangGraph importer. `loadSnapshotIntoStore`
|
|
22
|
+
* feature-detects this method, so the memory and Postgres drivers import identically.
|
|
23
|
+
*/
|
|
24
|
+
restore(snapshot: SkeinStoreSnapshot): Promise<void>;
|
|
17
25
|
}
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
items: [string, Item][];
|
|
25
|
-
}
|
|
26
|
+
/**
|
|
27
|
+
* A JSON-serializable copy of a {@link MemorySkeinStore}'s rows. An alias of the driver-agnostic
|
|
28
|
+
* {@link SkeinStoreSnapshot} (identical shape); the name predates the shared type and is kept so
|
|
29
|
+
* the dev-persistence snapshot format reads the same.
|
|
30
|
+
*/
|
|
31
|
+
type MemoryStoreSnapshot = SkeinStoreSnapshot;
|
|
26
32
|
|
|
27
33
|
/**
|
|
28
34
|
* In-memory FIFO of background runs, drained by a single-process consumer — all `skein dev` needs.
|
package/dist/index.js
CHANGED
|
@@ -208,6 +208,23 @@ var MemorySkeinStore = class {
|
|
|
208
208
|
fill(this.#runKwargs, snapshot.runKwargs);
|
|
209
209
|
fill(this.#items, snapshot.items);
|
|
210
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Bulk-load rows from a snapshot, preserving ids + timestamps and *without* clearing what's
|
|
213
|
+
* already here: existing ids are left untouched (insert-if-absent). Unlike {@link hydrate} (a
|
|
214
|
+
* full replace for cross-restart persistence), this is the additive, lossless sink used by
|
|
215
|
+
* migration tooling — see `@skein-js/express`'s LangGraph importer. `loadSnapshotIntoStore`
|
|
216
|
+
* feature-detects this method, so the memory and Postgres drivers import identically.
|
|
217
|
+
*/
|
|
218
|
+
async restore(snapshot) {
|
|
219
|
+
const add = (map, rows) => {
|
|
220
|
+
for (const [id, row] of rows) if (!map.has(id)) map.set(id, clone(row));
|
|
221
|
+
};
|
|
222
|
+
add(this.#assistants, snapshot.assistants);
|
|
223
|
+
add(this.#threads, snapshot.threads);
|
|
224
|
+
add(this.#runs, snapshot.runs);
|
|
225
|
+
add(this.#runKwargs, snapshot.runKwargs);
|
|
226
|
+
add(this.#items, snapshot.items);
|
|
227
|
+
}
|
|
211
228
|
};
|
|
212
229
|
|
|
213
230
|
// src/memory-queue.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skein-js/storage-memory",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "In-memory SkeinStore + queue driver for development and tests.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Maina Wycliffe <wmmaina7@gmail.com>",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"node": ">=20"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@skein-js/core": "0.
|
|
43
|
+
"@skein-js/core": "0.3.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@skein-js/test-support": "0.
|
|
46
|
+
"@skein-js/test-support": "0.3.0"
|
|
47
47
|
},
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|