@sema-agent/core
Version:
Stateless, task-oriented AI agent core
14 lines (13 loc) • 670 B
JavaScript
export function defineAgent(def) {
if (!def.name || !def.name.trim()) {
const e = new Error("defineAgent: `name` is required and must be a non-empty string.");
e.code = "config.agent.invalid";
throw e;
}
if (def.memoryPersistenceCapable !== undefined && typeof def.memoryPersistenceCapable !== "boolean") {
const e = new Error(`defineAgent("${def.name}"): memoryPersistenceCapable must be a boolean when present — got ${JSON.stringify(def.memoryPersistenceCapable)} (a string "false" would silently read as capable).`);
e.code = "config.agent.invalid";
throw e;
}
return Object.freeze({ ...def });
}