UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

28 lines (27 loc) • 1.85 kB
import type { ThinkingLevel } from "../internal/harness-types.js"; import type { AssistantMessage, Model } from "../internal/llm.js"; import type { ReasoningCarriage } from "./reasoning-request.js"; /** * What one request carried for its tier, as its builder hands it to the stream engine (`SSERequest.reasoning`): the tier the * request was built for and what its thinking keys say. A request built with no tier carries none — there is nothing to * resolve, so the type has no absent tier. */ export interface RequestReasoning { readonly level: ThinkingLevel; readonly carried: ReasoningCarriage; } /** * The reasoning stamp on a request's terminal message: the {@link RequestReasoning} of the request the engine committed to * send, and the catalog entry it was for — the `Model` object the engine was handed, or the entry a request's own reading of * it was made from (`modelEntryOf`: an entry whose `headers` is read once per request). A reader judges whose request it was by * that object, never by an id (two catalog entries may share a wire id). */ export interface ReasoningStamp extends RequestReasoning { readonly model: Model; } /** The request's reasoning, when the request was built with a tier; `undefined` when it was built with none. */ export declare function requestReasoning(level: ThinkingLevel | undefined, carried: ReasoningCarriage): RequestReasoning | undefined; /** Stamp a terminal message with the reasoning of the request that produced it (the stream engine's one stamping point). */ export declare function stampReasoning(message: AssistantMessage, stamp: ReasoningStamp): void; /** The reasoning stamp a message carries, if any: only a terminal message the stream engine produced, as that very object. */ export declare function reasoningStampOf(message: unknown): ReasoningStamp | undefined;