UNPKG

eve

Version:

Filesystem-first framework for durable backend AI agents that run anywhere.

1 lines 1.02 kB
import{MockLanguageModelV3}from"ai/test";import{BOOTSTRAP_RUNTIME_MODEL_ID}from"#runtime/agent/bootstrap.js";import{createBootstrapGenerateResult,createBootstrapStreamResult,estimateTokenCount,getLastUserPromptText,getPromptText}from"#runtime/agent/bootstrap-model-utils.js";const bootstrapRuntimeModels=new Map;function resolveBootstrapRuntimeModel(n){if(n.id!==BOOTSTRAP_RUNTIME_MODEL_ID)return null;let i=bootstrapRuntimeModels.get(n.id);if(i!==void 0)return i;let a=new MockLanguageModelV3({doGenerate:async e=>createBootstrapModelResult(e.prompt,n.id),doStream:async e=>createBootstrapStreamResult(createBootstrapModelResult(e.prompt,n.id)),modelId:n.id,provider:`eve-bootstrap`});return bootstrapRuntimeModels.set(n.id,a),a}function createBootstrapModelResult(e,t){let r=`Bootstrap reply: ${getLastUserPromptText(e)??`Hello from eve`}`;return createBootstrapGenerateResult({inputTokens:estimateTokenCount(getPromptText(e)),modelId:t,outputTokens:estimateTokenCount(r),text:r})}export{resolveBootstrapRuntimeModel};