UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

16 lines (15 loc) • 682 B
import { BaseSessionStorage } from "./storage-base.js"; import { uuidv7 } from "./uuid.js"; export class InMemorySessionStorage extends BaseSessionStorage { constructor(options) { super(options?.metadata ?? { id: uuidv7(), createdAt: new Date().toISOString() }, options?.entries ? [...options.entries] : [], undefined, options?.floorEntryId !== undefined ? { floorEntryId: options.floorEntryId } : undefined); } async setLeafId(leafId, opts) { this.assertExpectedLeaf(opts); this.recordEntry(this.createLeafEntry(leafId)); } async appendEntry(entry, opts) { this.assertExpectedLeaf(opts); this.recordEntry(entry); } }