@sema-agent/core
Version:
Stateless, task-oriented AI agent core
30 lines (29 loc) • 2.64 kB
TypeScript
import type { MaybeCompactOptions } from "../auto-compaction.js";
import type { Prepared, RunnerDepsSeat } from "./contracts.js";
/**
* The cost-optimization compaction options threaded into BOTH `maybeCompact` call
* sites (within-task turn boundary + `finish()`). All three fields come from `RunnerDeps` (a trusted
* FUNCTION seam — never `TaskSpec`, which is serializable/durable-resumable/untrusted-caller). The
* Runner OWNS the consecutive-reuse counter (`prepared.compactionReuseRef`) so the
* `maxConsecutiveProviderReuse` drift guard spans the whole task across both sites: it FEEDS the current
* count in as `consecutiveProviderReuse`, and {@link recordCompactionReuse} updates it from the result.
* The provider half is absent when no provider is wired (byte-identical to the prior behavior at every
* call site); the #1036 `onCommitted` effect sink rides unconditionally, which is why the
* function itself always returns an object.
*/
export declare function seamCCompactionOptions(runner: RunnerDepsSeat, prepared: Prepared): Pick<MaybeCompactOptions, "summaryProvider" | "onCompaction" | "maxConsecutiveProviderReuse" | "consecutiveProviderReuse" | "onCommitted">;
/** The pre/postCompact stations threaded into maybeCompact: `classic.PreCompact` and `classic.PostCompact` raised on the
* leg's bus (a station is wired only when a handler hangs on its event). Their failure and abort columns are the
* bus's — a handler that throws or runs past its budget is skipped and reported, so a failed gate is "no block, no
* instructions" and the compaction that was already deemed necessary proceeds. A `block` answered under a "forced"
* trigger is reported as ignored (maybeCompact enforces the ignore — blocking a compaction the provider/trim layer
* already demanded would kill the run). `signal` is the pass's abort (absent ⇒ each handler's own budget is the
* whole bound). */
export declare function compactionHookOptions(runner: RunnerDepsSeat, prepared: Pick<Prepared, "modBus" | "hookIdentity" | "sessionId">, trigger: "auto" | "manual" | "forced", signal: AbortSignal | undefined): Pick<MaybeCompactOptions, "trigger" | "preCompact" | "postCompact">;
/** Fold a finished compaction's `reused` flag into the run-scoped consecutive-reuse
* counter: a reused (provider) summary increments it, a real (LLM) summary resets it to 0. A no-op
* compaction (`compacted:false`) leaves the counter untouched. No-op when no provider is wired. */
export declare function recordCompactionReuse(runner: RunnerDepsSeat, prepared: Prepared, comp: {
compacted: boolean;
reused?: boolean;
}): void;