UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

19 lines (18 loc) • 1.19 kB
import type { SessionTreeEntry } from "../../internal/harness-types.js"; import type { PromptHashScope } from "../trace.js"; export declare const PROMPT_HASH_SALT_CUSTOM_TYPE = "engine:prompt-hash-salt"; export interface PromptHashSalt { readonly salt: Uint8Array; /** How far the digests taken under the salt compare: across the session, or within this leg only (the store could not keep it). */ readonly scope: PromptHashScope; } /** The salt the session's branch holds, newest first; undefined when none is readable. */ export declare function storedPromptHashSalt(branch: ReadonlyArray<SessionTreeEntry>): Uint8Array | undefined; /** * Resolve the session's salt: the stored one, else a fresh one written to the session. `onFailure` hears a read or write that * failed (the result is then a fresh key for this leg only); it must be loud — the host's digests stop comparing across runs. */ export declare function resolvePromptHashSalt(session: { getBranch(): Promise<ReadonlyArray<SessionTreeEntry>>; appendCustomEntry(customType: string, data?: unknown): Promise<string>; }, onFailure: (error: unknown, step: "read" | "write") => void): Promise<PromptHashSalt>;