Class: InMemorySpoolStore
In-memory "give bytes, get a reader" persistence layer keyed by callId.
Remarks
Stores the canonical UTF-8 string form of each value. Uint8Array inputs are decoded via TextDecoder once at write time — subsequent read() calls return a reader over the cached string with no further decoding.
Each write() and each read() returns a fresh InMemorySpoolReader — the store owns the bytes, the reader is a view. Mutating the store after handing out a reader does not invalidate the reader.
Example
const store = new InMemorySpoolStore();
const bytes = await tool.executor(ctx)(args);
const reader = store.write(callId, bytes);
const Ctor = tool.artifactConstructor?.() ?? SpooledArtifact;
const artifact = new Ctor(reader);Constructors
Constructor
new InMemorySpoolStore(): InMemorySpoolStore;Returns
InMemorySpoolStore
Accessors
size
Get Signature
get size(): number;Returns the number of entries currently in the store.
Returns
number
Methods
clear()
clear(): void;Removes every entry from the store.
Returns
void
Remarks
Existing readers handed out by prior write() / read() calls remain valid — they hold their own snapshot.
delete()
delete(callId: string): boolean;Removes the entry under callId.
Parameters
| Parameter | Type | Description |
|---|---|---|
callId | string | Identifier whose entry should be removed. |
Returns
boolean
true if an entry existed and was removed; false otherwise.
read()
read(callId: string): InMemorySpoolReader | undefined;Returns a reader over the bytes previously written under callId, or undefined if the entry has not been written or has been deleted.
Parameters
| Parameter | Type | Description |
|---|---|---|
callId | string | Identifier supplied to a prior InMemorySpoolStore.write call. |
Returns
InMemorySpoolReader | undefined
A fresh InMemorySpoolReader bound to the stored bytes, or undefined.
write()
write(callId: string, bytes: string | Uint8Array<ArrayBufferLike>): InMemorySpoolReader;Persists bytes under callId and returns a reader over them.
Parameters
| Parameter | Type | Description |
|---|---|---|
callId | string | Identifier used to retrieve the bytes via InMemorySpoolStore.read. |
bytes | string | Uint8Array<ArrayBufferLike> | The bytes to store, as a string or Uint8Array. |
Returns
A fresh InMemorySpoolReader bound to the stored bytes.
Remarks
Uint8Array inputs are decoded as UTF-8. Re-writing the same callId replaces the prior entry; readers handed out before the rewrite continue to view the old bytes (they hold their own snapshot via the InMemorySpoolReader constructor).