UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

25 lines (24 loc) • 2.27 kB
import type { MemoryBackend, NotePatch, PatchReport } from "./types.js"; /** The answer for an update or an add whose entry names a scope outside the set. */ export declare const PATCH_TARGET_OUTSIDE = "target scope outside the permitted scopes (refused)"; /** The set as the call carries it, read once: absent ⇒ `undefined`; not a list of non-empty names ⇒ refused, nothing written. */ export declare function readPatchScopeSet(opts: { readonly expectedScopes?: unknown; } | undefined): ReadonlySet<string> | undefined; /** * The seat's one judgment for one update or delete: the conflict to report, or `undefined` when the patch is the caller's. * `owner` is the scope that owns the patch's id in the store (`undefined` ⇔ the store does not hold it); `notHeld` is the * backend's own reason for an id it does not hold. */ export declare function patchScopeRefusal(set: ReadonlySet<string>, patch: NotePatch, owner: string | undefined, notHeld: string): PatchReport["conflicts"][number] | undefined; /** The engine's write: `scopes` (the writer's own) ride as `expectedScopes` to a backend that declares the seat; any other * backend — and a writer whose scope is a name the set cannot carry (the empty name an older row may hold) — is called with * exactly the arguments it was called with before. */ export declare function applyPatchesWithin(backend: Pick<MemoryBackend, "applyPatches" | "judgesPatchScopes">, patches: readonly NotePatch[], scopes: readonly string[], opts?: Parameters<MemoryBackend["applyPatches"]>[1]): Promise<PatchReport>; /** * Whether `id` stands in any of `dirs` (the scope directories outside the caller's set) — the occupancy question of an update or a delete of an id the account holds no row for (a row without a binding is outside), asked of every * entry file whatever its account says, by one walk that fails closed: a directory that exists but cannot be listed (at any * depth), a name that cannot be inspected, or a file whose bytes cannot be read counts as holding the id. Symbolic links, * dot-names, the index file and names past the entry depth are not entries (the store's own scan rule). The answer is one bit. */ export declare function idStandsIn(dirs: readonly string[], id: string): boolean;