UNPKG

eve

Version:

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

1 lines 2.49 kB
import{stripLogicalPathExtension}from"#discover/filesystem.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";import{readWorkflowFunctionId}from"#internal/workflow/reference.js";import{normalizeToolDefinition}from"#internal/authored-definition/schema-backed.js";async function compileToolEntry(e,t,n){let r=normalizeToolDefinition(await loadModuleBackedDefinition({binding:n.binding,kind:`tool`,loadNamespace:n.loadNamespace,source:t}),`Expected the tool export "${t.exportName??`default`}" from "${t.logicalPath}" to match the public eve shape.`),i=stripLogicalPathExtension(t.logicalPath).replace(/^tools\//,``).replaceAll(`/`,`-`);if(r.kind===`disabled`)return{kind:`disabled`,name:i};if(r.kind===`workflow-tool`)return{kind:`workflow-tool`,maxSubagents:r.maxSubagents};if(r.kind===`web-search-tool`){if(i!==`web_search`)throw Error(`The webSearch() definition must be exported from "tools/web_search.ts", not "${t.logicalPath}".`);return{definition:{behavior:{availability:[],handling:{kind:`provider-tool`,provider:r.provider}},description:`Search the web for real-time information. Use this to find up-to-date information about current events, recent developments, or topics that may have changed since the knowledge cutoff.`,exportName:t.exportName,hasExecute:!1,hasModelOutputProjection:!1,inputSchema:null,logicalPath:t.logicalPath,name:i,sourceId:t.sourceId,sourceKind:`module`,requiresApproval:!1},kind:`web-search-tool`}}if(r.kind===`dynamic-tool`)return{kind:`dynamic-tool`,definition:{eventNames:[...r.eventNames],exportName:t.exportName,logicalPath:t.logicalPath,rebindMissingCallbacks:r.rebindMissingCallbacks||void 0,slug:i,sourceId:t.sourceId,sourceKind:`module`}};let a=readWorkflowFunctionId(r.definition.execute),o={lifetime:r.definition.execution===`background`?`task`:`step`,suspend:a===void 0?`none`:`workflow`};return{kind:`tool`,definition:{behavior:a===void 0?r.definition.behavior===void 0?{availability:[],shape:o}:{...r.definition.behavior,shape:o}:{availability:[],handling:{kind:`workflow-tool`,workflowId:a},shape:o},description:r.definition.description,execution:r.definition.execution,exportName:t.exportName,hasExecute:r.definition.hasExecute,hasModelOutputProjection:r.definition.hasModelOutputProjection,inputSchema:r.definition.inputSchema??null,logicalPath:t.logicalPath,name:i,outputSchema:r.definition.outputSchema,requiresApproval:r.definition.hasApproval,sourceId:t.sourceId,sourceKind:`module`}}}export{compileToolEntry};