UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

55 lines (54 loc) • 2.46 kB
import { type MemoryEntryConfidence } from "./header-hints.js"; /** One entry as a caller states it: the frontmatter's three lines and the body, and optionally what the entry rests on, how sure * its writer is and when it was last confirmed (each written as its own header line and read back with `readV2HeaderHints`). */ export interface MemoryEntryDraft { name: string; description: string; type: string; body: string; /** One line of plain text: what the entry rests on (`evidence:` header line). */ evidence?: string; /** `low` | `medium` | `high` (`confidence:` header line). */ confidence?: MemoryEntryConfidence; /** A calendar date `YYYY-MM-DD`, optionally with an ISO time `T…` (`last-confirmed:` header line). */ lastConfirmedAt?: string; } /** The port's answer: the entry was linked into the write home (`path`); a rule or the gate refused it (`code` is the gate's * code, or `invalid_name` / `invalid_header` / `exists` / `write_failed` for the port's own rules); or the leg has no engine * memory session to write into. */ export type MemoryEntryCreateOutcome = { kind: "created"; path: string; } | { kind: "refused"; code: string; reason: string; } | { kind: "unavailable"; reason: string; }; /** The memory write gate's answer for one write (the file tools' hook shape, read over the canonical key and the final text). */ export type MemoryEntryGate = (w: { key: string; content: string; }) => Promise<{ ok: true; } | { ok: false; code: string; reason: string; } | undefined>; /** The write port a Runner hands a caller tool over a leg's memory session, read at the call (a session mounted later in prepare is * the one written); a leg with no engine memory session answers `unavailable`. */ export declare function memoryEntryPortOf(session: () => { readonly createEntry: (draft: MemoryEntryDraft) => Promise<MemoryEntryCreateOutcome>; } | undefined): (draft: MemoryEntryDraft) => Promise<MemoryEntryCreateOutcome>; /** Create `draft` in `home` (`null` when the session has no write face; the target is then placed under `domain`, where the gate * refuses it with the read-only layering's own reason). */ export declare function createMemoryEntry(o: { home: string | null; domain: string; gate: MemoryEntryGate; draft: MemoryEntryDraft; boundAtMount?: (path: string) => boolean; }): Promise<MemoryEntryCreateOutcome>;