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(e){if(e.id!==BOOTSTRAP_RUNTIME_MODEL_ID)return null;let t=bootstrapRuntimeModels.get(e.id);if(t!==void 0)return t;let n=new MockLanguageModelV3({doGenerate:async t=>createBootstrapModelResult(t.prompt,e.id),doStream:async t=>createBootstrapStreamResult(createBootstrapModelResult(t.prompt,e.id)),modelId:e.id,provider:`eve-bootstrap`});return bootstrapRuntimeModels.set(e.id,n),n}function createBootstrapModelResult(e,t){let n=`Bootstrap reply: ${getLastUserPromptText(e)??`Hello from eve`}`;return createBootstrapGenerateResult({inputTokens:estimateTokenCount(getPromptText(e)),modelId:t,outputTokens:estimateTokenCount(n),text:n})}export{resolveBootstrapRuntimeModel};