UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

59 lines (58 loc) • 3.91 kB
import { IMAGE_REFUSAL_KIND } from "./media-removed.js"; export { IMAGE_REFUSAL_KIND }; /** The `errorKind` a provider's refusal of one tool's input schema carries (`AssistantMessage.errorKind`, beside * `refusedTool`). */ export declare const TOOL_SCHEMA_REFUSAL_KIND = "tool_schema_refused"; /** The schema a tool whose input schema the provider refused travels with: an object that names no parameter (the * reference's replacement, `X5t` (cli309.js:264190)). */ export declare const REFUSED_TOOL_SCHEMA: Readonly<{ type: "object"; }>; /** How many tools of one transcript the tool view sends without their schema (the reference's bound, the same coordinate). */ export declare const REFUSED_TOOL_SCHEMAS_MAX = 8; /** Is this message a turn the provider failed because an image in the request could not be processed — the live * failure or its persisted record? */ export declare function isImageRefusal(message: unknown): boolean; /** The tool a turn the provider failed over that tool's input schema names (the live failure or its persisted record); * undefined for any other message. */ export declare function refusedToolOf(message: unknown): string | undefined; /** The `errorKind` of a provider's refusal of the request over its media blocks: its marker removes nothing else. */ export declare const MEDIA_ITEMS_REFUSAL_KIND = "media_items_refused"; /** Is this message a marker of a refused part — what leaves the message view? */ export declare function isRequestPartRefusal(message: unknown): boolean; /** One carrier whose images a marker removed: the marker, the carrier (both the view's input objects), how many, and * the refusal's own time — the one identity a refusal keeps across its live failure, its persisted record and every * rebuilt copy of either (the record is minted with the failure's timestamp). */ export interface RejectedImageRemoval { readonly marker: object; readonly carrier: object; readonly images: number; readonly refusalAt: number; } /** A refusal's identity ({@link RejectedImageRemoval.refusalAt}). */ export declare function imageRefusalAt(message: unknown): number; /** * The message view of `messages` under every refusal marker they hold ({@link isRequestPartRefusal}): each marker removed, * and the images of an image marker's carrier replaced. `removals` lists, in order, the carriers emptied — empty when no * image marker found an image to remove. */ export declare function removeRefusedRequestParts<T>(messages: readonly T[]): { messages: T[]; removals: RejectedImageRemoval[]; }; /** Does `marker`, standing in `messages`, remove images in their request view — was there a carrier left for it? */ export declare function imageRefusalRemoves(messages: readonly unknown[], marker: object): boolean; /** The tools whose schemas `messages` refused and the tool view replaces: in the order the transcript refused them, each * once, external-protocol tools only, at most {@link REFUSED_TOOL_SCHEMAS_MAX}. */ export declare function refusedToolSchemas(messages: readonly unknown[]): string[]; /** The tool view of `tools` under `messages`' tool-schema refusals: each refused tool ({@link refusedToolSchemas}) with * {@link REFUSED_TOOL_SCHEMA} for its parameters, every other tool the same object; with nothing refused, the same array. */ export declare function withoutRefusedToolSchemas<T extends { readonly name: string; readonly parameters: unknown; }>(tools: readonly T[] | undefined, messages: readonly unknown[]): T[] | undefined; /** Does `marker`, standing in `messages`, change the tool view of `tools` — does it name a mounted tool whose schema no * earlier marker already replaced, within the transcript's bound? */ export declare function toolSchemaRefusalReplaces(messages: readonly unknown[], marker: object, tools: readonly { readonly name: string; }[] | undefined): boolean;