@sema-agent/core
Version:
Stateless, task-oriented AI agent core
27 lines (26 loc) • 2.96 kB
TypeScript
import type { SessionStorage } from "../../internal/harness.js";
import type { SessionTreeEntry } from "../../internal/harness-types.js";
import { type RewindAsker } from "./rewind-target.js";
/**
* Where the inclusive mode (`at`) lands when it continues from `start` (the entry `resumeAt` names, or the entry a leaf move it names moved
* to): the last of the attachment frames under it — from the start, each step takes the first child, in log order, that is an attachment
* frame (a person's attachments, the instruction files a load delivered, a compaction's restore), whatever input it belongs to; no such child
* ⇒ the entry it stands on. An assistant message and a custom message are not read for successors: the engine never appends a frame directly
* under either, so the start is the landing. Successors are read from the store's stored log when it has that read (`SessionStorage.getChildren`
* — so the landing is the log's, whatever window the handle loaded), else among `held` (the handle's entries) when they hold the start; with
* neither the answer is `undefined` — where the frames end is not known, and {@link refuseBranchOutsideWindow} refuses it. A chain that loops
* back is refused as a damaged log (`corrupt_session`). `held` is read only when it is the successors' source (the store has no
* `getChildren` and the start is read for successors) — never otherwise.
*/
export declare function atLanding(start: SessionTreeEntry, held: () => Promise<readonly SessionTreeEntry[]>, storage: Pick<SessionStorage, "getChildren">): Promise<string | undefined>;
/**
* Judge the landing; answers the leaf it holds. `landing` is the leaf `at` / `before` would set, `undefined` when its frames could not be
* read ({@link atLanding}; `start` is then the entry it continues from). `asker` is the entry that asks (a run's `resumeAt`, or
* `Runner.rewindConversation`): the words the sentence names the target by. `takesBefore`: the target is one `resumeAtMode: "before"` takes
* (`beforeTakes`, the "before" judgment read without throwing) — only then does the frames refusal name that mode as a way out.
*/
export declare function refuseBranchOutsideWindow(storage: Pick<SessionStorage, "getPathToRoot">, landing: string | null | undefined, target: string, sessionId: string, asker: RewindAsker, start?: string, takesBefore?: boolean): Promise<string | null>;
/** Where `entryId` sits on `branch` — the store's path read from the session's leaf, root first: its index, or -1 when the branch does not
* hold it. When the read stops at the floor (its top has a parent the walk did not require) and does not hold the entry, whether the entry is
* on the branch below the floor cannot be read: refused `resume_at.outside_window` (`branch_not_held`). `named` is the sentence's subject. */
export declare function indexOnBranch(branch: readonly SessionTreeEntry[], entryId: string, named: string, sessionId: string): number;