eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 1.92 kB
JavaScript
import{serializeOutputSchema}from"#tools/schema.js";import{isDynamicModelDefinition}from"#shared/agent-definition.js";import{normalizeAgentDefinition}from"#internal/authored-definition/core.js";import{resolveRuntimeModelSelection}from"#runtime/agent/resolve-model.js";async function normalizeDynamicSubagentAgentConfig(e){let t=`Dynamic subagent "${e.name}" must return defineAgent(...), defineRemoteAgent(...), or null.`,n=normalizeAgentDefinition(e.value,t);if(!n.description)throw Error(`${t} The "description" field is required.`);if(n.build!==void 0)throw Error(`${t} The "build" field cannot be selected at runtime.`);if(n.defaultTools!==void 0)throw Error(`${t} The "defaultTools" field cannot be selected at runtime.`);if(n.experimental!==void 0)throw Error(`${t} The "experimental" field cannot be selected at runtime.`);if(isDynamicModelDefinition(n.model))throw Error(`${t} The returned "model" must be static.`);let r={description:n.description,model:await normalizeDurableModelSelection({catalog:e.catalog,selection:{model:n.model,modelContextWindowTokens:n.modelContextWindowTokens,modelOptions:n.modelOptions},state:e.state})};if(n.compaction!==void 0){let t={};n.compaction.model!==void 0&&(t.model=await normalizeDurableModelSelection({catalog:e.catalog,selection:{model:n.compaction.model,modelContextWindowTokens:n.compaction.modelContextWindowTokens,modelOptions:n.modelOptions},state:e.state})),n.compaction.thresholdPercent!==void 0&&(t.thresholdPercent=n.compaction.thresholdPercent),r.compaction=t}return n.limits!==void 0&&(r.limits=n.limits),n.outputSchema!==void 0&&(r.outputSchema=serializeOutputSchema(n.outputSchema)),n.reasoning!==void 0&&(r.reasoning=n.reasoning),r}async function normalizeDurableModelSelection(e){return(await resolveRuntimeModelSelection({catalog:e.catalog,durability:`durable`,selection:e.selection,state:e.state})).reference}export{normalizeDynamicSubagentAgentConfig};