UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 3.29 kB
import{t as formatErrorMessage}from"./errors-D37BJTfI.mjs";import{r as withPluginRuntimeGenerationRegistryScope}from"./generation-state-Bed3DvwS.mjs";import{i as getPluginToolMeta}from"./tool-metadata-Cb5nBZYD.mjs";import{r as inspectRuntimeToolInputSchemas}from"./tool-schema-projection-B9L3KtZf.mjs";import{n as normalizeAgentRuntimeTools}from"./tools-CXr38coz.mjs";import{t as buildReadableToolsByName}from"./tools-effective-inventory-build-2_q6gwYU.mjs"; //!src/flows/doctor-tool-schema-projection.ts function collectNormalizedToolSchemaFindings(e){const t=[];const n=buildReadableToolsByName(e.tools);const projectDiagnostics=(t,n,r)=>n.map(n=>{const i=e.agentId;let a;try{a=t[n.toolIndex]}catch{a=void 0}const o=r?.get(n.toolName);const s=(a?getPluginToolMeta(a)?.pluginId:void 0)??(o?getPluginToolMeta(o)?.pluginId:void 0);const c=s?` from plugin ${s}`:``;const l=`Agent ${i} `;const u=s===`bundle-mcp`?`mcp.servers`:s?`plugins.entries.${s}`:`tools.${n.toolName}`;const d=s===`bundle-mcp`?`Disable or update the offending MCP server/tool so its parameters are a JSON object schema, then rerun doctor.`:`Disable or update the offending plugin/tool so its parameters are a JSON object schema, then rerun doctor.`;return{checkId:`core/doctor/runtime-tool-schemas`,severity:`error`,message:`${l}tool ${n.toolName}${c} has an unsupported input schema for runtime projection.`,path:u,target:n.toolName,requirement:n.violations.join(`, `),fixHint:d}});let r;try{r=normalizeAgentRuntimeTools({tools:e.tools,provider:e.modelRef.provider,config:e.cfg,workspaceDir:e.workspaceDir,env:process.env,modelId:e.modelRef.model,modelApi:e.model.api,model:e.model,onPreNormalizationSchemaDiagnostics:(e,n)=>{t.push(...projectDiagnostics(n,e))}})}catch(n){return[...t,e.normalizationFailureFinding(n)]}return[...t,...projectDiagnostics(r,inspectRuntimeToolInputSchemas(r),n)]}function agentRuntimeToolFailureFinding(e){return{checkId:`core/doctor/runtime-tool-schemas`,severity:`error`,message:`Agent ${e.agentId} runtime tool schema validation could not ${e.phase} the runtime tool set.`,path:`agents.${e.agentId}.tools`,requirement:formatErrorMessage(e.error),fixHint:e.phase===`load`?`Fix provider/plugin tool loading errors, then rerun doctor before relying on assistant tool startup.`:`Fix provider/plugin schema normalization errors, then rerun doctor before relying on assistant tool startup.`}}async function collectAgentRuntimeToolSchemaFindings(e){let t;try{const{createOpenClawCodingTools:n}=await import(`./agent-tools-BDMgqK0y.mjs`);t=withPluginRuntimeGenerationRegistryScope(e.toolRegistry,()=>n({agentId:e.agentId,agentDir:e.agentDir,conversationCapabilityProfile:e.capabilityProfile,workspaceDir:e.workspaceDir,config:e.cfg,modelProvider:e.modelRef.provider,modelId:e.modelRef.model,modelApi:e.model.api,modelCompat:e.model.compat,modelContextWindowTokens:e.model.contextWindow,allowGatewaySubagentBinding:true,emitBeforeToolCallDiagnostics:false}))}catch(t){return[agentRuntimeToolFailureFinding({agentId:e.agentId,error:t,phase:`load`})]}return collectNormalizedToolSchemaFindings({...e,tools:t,normalizationFailureFinding:t=>agentRuntimeToolFailureFinding({agentId:e.agentId,error:t,phase:`normalize`})})}export{collectAgentRuntimeToolSchemaFindings,collectNormalizedToolSchemaFindings};