Skip to main content

MemoryReceiptStore

@totemsdk/agent-policy


@totemsdk/agent-policy / MemoryReceiptStore

Class: MemoryReceiptStore

In-memory receipt store with optional JSON-file persistence.

Example​

// In-memory only
const store = new MemoryReceiptStore();

// With file persistence
const store = new MemoryReceiptStore({ filePath: './data/receipts.jsonl' });

Implements​

Constructors​

Constructor​

new MemoryReceiptStore(opts?): MemoryReceiptStore

Parameters​

opts?​
filePath?​

string

Returns​

MemoryReceiptStore

Methods​

count()​

count(): Promise<number>

Total number of stored receipts.

Returns​

Promise<number>

Implementation of​

ReceiptStore.count


get()​

get(receiptId): Promise<AgentReceipt | null>

Retrieve a receipt by receiptId.

Parameters​

receiptId​

string

Returns​

Promise<AgentReceipt | null>

Implementation of​

ReceiptStore.get


list()​

list(limit?, offset?): Promise<AgentReceipt[]>

List all receipts, newest first.

Parameters​

limit?​

number = 50

offset?​

number = 0

Returns​

Promise<AgentReceipt[]>

Implementation of​

ReceiptStore.list


save()​

save(receipt): Promise<string>

Persist a receipt. Returns a receiptId for retrieval.

Parameters​

receipt​

AgentReceipt

Returns​

Promise<string>

Implementation of​

ReceiptStore.save