@sema-agent/core
Version:
Stateless, task-oriented AI agent core
43 lines (42 loc) • 2.22 kB
TypeScript
import type { EngineNotice } from "../engine-notice.js";
import { type ToolTurnRepair } from "../../internal/llm.js";
/** The notice's attribution ids — the same pair, for the same reason, as the fold seat's. */
export interface ToolTurnRepairSeatIds {
sessionId: string;
runId: string;
}
/** What the message says became of a turn that dropped calls: the run ended on it (`model_output_invalid`), or the next
* request asks the model to re-issue them. */
export type ToolTurnOutcome = "terminal" | "reissued";
/** One thing the person is told, per cause. A dropped-call cause carries the outcome when its message states one (else
* `undefined`: nothing is said about the run's fate); the others have none. */
export type ToolTurnIncompleteItem = {
cause: "truncated";
count: number;
outcome: ToolTurnOutcome | undefined;
} | {
cause: "unnamed";
count: number;
outcome: ToolTurnOutcome | undefined;
} | {
cause: "bad_frame";
count: number;
} | {
cause: "missing_result_synthesized";
count: number;
toolCallIds: readonly string[];
};
/** Does a turn's content carry a tool call? A tool-calling turn GUARANTEES a next request (its results go back to the
* model): the engine's one continuation fact — the harness's boundary gates and the dropped-call line read it here. */
export declare function turnCarriesToolCall(content: unknown): boolean;
/** The person's line for one cause — once per run per cause, whichever observer saw it first. */
export interface ToolTurnIncompleteSeat {
/** Announce `item` unless this run already said its cause. */
announce(item: ToolTurnIncompleteItem): void;
/** Observe one assistant message: announces each stream drop it reports (`streamDropsOf`), worded by what became of the turn. */
observe(message: {
readonly diagnostics?: unknown;
}): void;
}
export declare function createToolTurnIncompleteSeat(onNotice: ((notice: EngineNotice) => void) | undefined, ids: ToolTurnRepairSeatIds): ToolTurnIncompleteSeat;
export declare function createToolTurnRepairSeat(onNotice: ((notice: EngineNotice) => void) | undefined, ids: ToolTurnRepairSeatIds): (repairs: readonly ToolTurnRepair[]) => void;