@sema-agent/core
Version:
Stateless, task-oriented AI agent core
31 lines (30 loc) • 1.38 kB
JavaScript
export { StoredSession } from "../internal/harness.js";
export { InMemorySessionRepo, InMemorySessionStorage, uuidv7, validateEntriesForImport, StreamingImportValidator, } from "../internal/harness.js";
export { BaseSessionStorage, leafIdAfterEntry, } from "../internal/harness.js";
export { SessionError } from "../internal/harness.js";
import { SessionError } from "../internal/harness.js";
import { readMember, thrownIs } from "./thrown-value.js";
export function isSessionConflict(err) {
return thrownIs(err, SessionError) && readMember(err, "code") === "conflict";
}
export function hasSessionFork(store) {
return typeof store.fork === "function";
}
export function boundedTail(pathEntries) {
let lastCompaction;
for (const e of pathEntries) {
if (e.type === "compaction")
lastCompaction = e;
}
if (!lastCompaction)
return { tail: [...pathEntries], floorEntryId: null };
const floorEntryId = lastCompaction.firstKeptEntryId;
const floorIdx = pathEntries.findIndex((e) => e.id === floorEntryId);
if (floorIdx < 0) {
return { tail: [...pathEntries], floorEntryId: null };
}
return { tail: pathEntries.slice(floorIdx), floorEntryId };
}
export function hasConversationContent(branch) {
return branch.some((e) => e.type === "message" || e.type === "custom_message" || e.type === "compaction");
}