@sema-agent/core
Version:
Stateless, task-oriented AI agent core
19 lines (18 loc) • 877 B
JavaScript
export const UNMATCHED_TOOL_NAMES_CODE = "config.toolpolicy.unmatched_names";
export function unmatchedNameIdentity(warning) {
const { code, unmatched } = warning;
return code === UNMATCHED_TOOL_NAMES_CODE ? unmatched?.identity : undefined;
}
export function unmatchedNameWarning(message, unmatched) {
return Object.assign(new Error(message), { code: UNMATCHED_TOOL_NAMES_CODE, unmatched });
}
export function unmatchedNamesNotice(warning, sessionId) {
const { code, unmatched } = warning;
if (code !== UNMATCHED_TOOL_NAMES_CODE || unmatched === undefined)
return undefined;
return {
code: UNMATCHED_TOOL_NAMES_CODE,
message: warning.message,
detail: { where: unmatched.where, side: unmatched.side, entry: unmatched.entry, ...(unmatched.nearest !== undefined ? { nearest: unmatched.nearest } : {}), sessionId },
};
}