UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

58 lines (57 loc) • 5.5 kB
import { type MemoryControlObjectKind } from "./types.js"; import { CONTROL_OBJECT_STAGE_DIR, type QuarantineCapture } from "./layout.js"; export { CONTROL_OBJECT_STAGE_DIR }; /** A control-object kind's directory under a File store's control plane. A kind outside * {@link MEMORY_CONTROL_OBJECT_KINDS} is refused (`memory.control_object_unknown`) — never given a directory of its own. */ export declare function fileControlObjectDirOf(kind: MemoryControlObjectKind): string; /** A name a store keeps an object under: one opaque, non-empty segment of at most 255 UTF-8 bytes — never `.` / `..`, never a * separator or a NUL. */ export declare function isControlObjectName(name: unknown): name is string; /** The filesystem code behind a File control-object refusal: the refusal's own `code` when it is the filesystem's, else * the code of the filesystem error it was raised over (`cause`) — `undefined` when neither names one. */ export declare function fileControlObjectFaultCode(err: unknown): string | undefined; /** * The open judge of a File governance store over `controlDir` (#3512): the store publishes every object with `link` * ({@link putFileControlObject}, {@link moveFileControlObject}), so on a file system that cannot make a hard link every * object write would fail — and a containment whose copy fails still takes the suspect off the plane (its copy is * lost, not kept). One link is tried, at the open, between two files at the control plane's top level (named with * `LINK_PROBE_PREFIX`), and both are removed; a link the file system refuses is refused here * (`memory.control_plane_links_unsupported`, `controlPlaneLinksRefusal`, `detail.path` = `controlDir`). Not judged — the * open proceeds as before — when the first file cannot be created (a control plane that is read-only, full or not * writable: what was not tried is not claimed) or when the link's name already stands. Asked at each open, never * cached. The callers are the two holders of a File store: the File backend's construction and an engine whose backend * carries no store of its own. `controlDir` stands when it is asked. */ export declare function probeControlPlaneLinks(controlDir: string): void; /** Write `(kind, name)` once ({@link import("./types.js").MemoryGovernanceStore.putObject}): `"existed"` only when the name already * holds these same bytes; a name holding other bytes is refused, never answered as written. */ export declare function putFileControlObject(controlDir: string, kind: MemoryControlObjectKind, name: string, bytes: Uint8Array): "created" | "existed"; /** A control object's bytes ({@link import("./types.js").MemoryGovernanceStore.getObject}). */ export declare function getFileControlObject(controlDir: string, kind: MemoryControlObjectKind, name: string): Uint8Array | undefined; /** Every name standing in a kind's directory, sorted — the objects and whatever else stands there (a subdirectory, a dangling link, * a name no writer could have used). For the readers that must see damage rather than be spared it: the adoption of a replica * refuses each such entry by name and withholds the documents behind it, and the strays reader counts them — an entry standing * where an object's record belongs is a fact, never an absence. {@link listFileControlObjects} is the store's verb: objects only. */ export declare function standingFileControlObjectNames(controlDir: string, kind: MemoryControlObjectKind): string[]; /** Every name of `kind`, sorted ({@link import("./types.js").MemoryGovernanceStore.listObjects}): the regular files under a legal * name — the entries {@link getFileControlObject} reads. A subdirectory or a dangling link in a kind's directory is no object and * is not named here; the verbs that meet it refuse it, and {@link standingFileControlObjectNames} still names it. */ export declare function listFileControlObjects(controlDir: string, kind: MemoryControlObjectKind): string[]; /** Move one object, never overwriting ({@link import("./types.js").MemoryGovernanceStore.moveObject}). */ export declare function moveFileControlObject(controlDir: string, from: { readonly kind: MemoryControlObjectKind; readonly name: string; }, to: { readonly kind: MemoryControlObjectKind; readonly name: string; }): "moved" | "already-moved"; /** {@link putFileControlObject} for a writer whose record is the first one under the name — the synchronous twin of * `putControlObjectOnce` (`layout.ts`), one law: `"existed"` ⇔ an object stands there that reads back (the same bytes, * or other bytes the put refused); a refusal no readable object explains is the put's own and is thrown. */ export declare function putFileControlObjectOnce(controlDir: string, kind: MemoryControlObjectKind, name: string, bytes: Uint8Array): "created" | "existed"; /** The File store's capture of one suspect copy into its `quarantine` objects — the synchronous twin of * `captureIntoQuarantine` (`layout.ts`) for the File backend's own synchronous paths: the same names, and the same * answer for a name already holding these bytes (the copy is kept; nothing is written again). */ export declare function captureIntoFileQuarantine(controlDir: string, source: string, content: string): QuarantineCapture; /** Delete one object ({@link import("./types.js").MemoryGovernanceStore.deleteObject}). */ export declare function deleteFileControlObject(controlDir: string, kind: MemoryControlObjectKind, name: string): boolean;