UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

16 lines (15 loc) • 1.05 kB
export const DEFINITION_ENTRY_CODE = "config.agent.unknown_tool"; export const DEFINITION_ENTRY_REASON = "grammar"; export function definitionEntryWarning(message, facts) { return Object.assign(new Error(message), { code: DEFINITION_ENTRY_CODE, detail: { reason: DEFINITION_ENTRY_REASON, where: facts.where, side: facts.side, entry: facts.entry }, identity: facts.identity }); } export function definitionEntryIdentity(warning) { const { code, detail, identity } = warning; return code === DEFINITION_ENTRY_CODE && detail?.reason === DEFINITION_ENTRY_REASON ? identity : undefined; } export function definitionEntryNotice(warning, sessionId) { const { code, detail } = warning; if (code !== DEFINITION_ENTRY_CODE || detail === undefined || detail.reason !== DEFINITION_ENTRY_REASON || typeof detail.where !== "string") return undefined; return { code: DEFINITION_ENTRY_CODE, message: warning.message, detail: { where: detail.where, side: detail.side, entry: detail.entry, reason: DEFINITION_ENTRY_REASON, sessionId } }; }