UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

29 lines (28 loc) • 1.81 kB
import type { SessionTreeEntry } from "../../internal/harness.js"; /** Who asks for the landing — the words its refusals name the target by. */ export type RewindAsker = "resumeAt" | "Runner.rewindConversation"; /** The judged target: the entry; for "at" the entry the run continues from (`start` — the entry itself, or the entry a leaf move moved * to); for "before" the leaf the rewind lands on (the target's parent — never null: a root is refused). */ export type RewindTarget = { readonly mode: "at"; readonly entry: SessionTreeEntry; readonly start: SessionTreeEntry; } | { readonly mode: "before"; readonly entry: SessionTreeEntry; readonly landing: string; }; /** The subject every refusal of a landing names: the target, in the words of the entry that asked. */ export declare function rewindTargetNamed(target: string, asker: RewindAsker): string; /** Whether "before" takes `entry` — the "before" checks of {@link judgeRewindTarget}, read without throwing: a person's words with a parent. * The one reading of "a target that mode takes", for a refusal that names "before" as a way out. */ export declare function beforeTakes(entry: SessionTreeEntry): boolean; /** Judge `target` on the session `read` holds (see the module header); answers the entry and its start ("at") or its landing ("before"). */ export declare function judgeRewindTarget(read: { getEntry(id: string): Promise<SessionTreeEntry | undefined>; }, target: string, mode: "before", sessionId: string, asker: RewindAsker): Promise<Extract<RewindTarget, { mode: "before"; }>>; export declare function judgeRewindTarget(read: { getEntry(id: string): Promise<SessionTreeEntry | undefined>; }, target: string, mode: "at" | "before", sessionId: string, asker: RewindAsker): Promise<RewindTarget>;