@sema-agent/core
Version:
Stateless, task-oriented AI agent core
18 lines (17 loc) • 1.7 kB
TypeScript
import type { Tool, ToolCall } from "./types.js";
/** Finds the target tool and validates/coerces a model-emitted tool call. */
export declare function validateToolCall(tools: Tool[], toolCall: ToolCall): unknown;
/** The dispatcher's name resolution over one tool list, indexed once (for a caller resolving many names over the same list):
* canonical names first, then aliases (design/115 P0 order) — the first tool carrying a name, or an alias, owns it. */
export declare function toolNameIndex<T extends Tool>(tools: readonly T[] | undefined): (name: string) => T | undefined;
/** VENDORED EDIT (design/115 P0): resolve canonical tool names first, then legacy aliases ({@link toolNameIndex} for one name). */
export declare function findToolByName<T extends Tool>(tools: readonly T[] | undefined, name: string): T | undefined;
/**
* Validates tool arguments against TypeBox or plain JSON-schema parameters. A limit of the runtime met while the arguments are cloned, converted or
* checked ({@link runtimeLimitWords}) is a validation failure too — of the usual form, so every reader of the check treats it as one: the call was not
* run, and the sentence says the check ran into a limit of this runtime, not why (a deep value overflows the stack, a shallow one whose getter
* raises a length error ends the same way). The original rides on `cause` and the structured marks it carried (`details`, `errorKind`) stay on the
* error. No depth is refused: what validated before validates now. Every other error — any other class, a `RangeError` that is no limit — leaves as
* it was thrown.
*/
export declare function validateToolArguments(tool: Tool, toolCall: ToolCall): unknown;