@elizaos/plugin-mcp 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -593,7 +593,7 @@ ${K}`}}function _O6(q){if(!q)return;if(q.startsWith("image/"))return f5.IMAGE;if
|
|
|
593
593
|
Resource (${Z.uri}):
|
|
594
594
|
${Z.text}`;else if(Z&&"blob"in Z)j+=`
|
|
595
595
|
|
|
596
|
-
Resource (${Z.uri}): [Binary data]`}return{toolOutput:j,hasAttachments:f,attachments:J}}async function wK8(q,$,K,Y,P,j,f){await Fv(q,$,"resource",Y,P,{uri:K,isResourceAccess:!0});let J=HO6(K,$.content.text||"",P,j),z=await q.useModel(q1.TEXT_SMALL,{prompt:J});if(f)await f({text:z,thought:`I analyzed the content from the ${K} resource on ${Y} and crafted a thoughtful response that addresses the user's request while maintaining my conversational style.`,actions:["READ_MCP_RESOURCE"]})}async function AK8(q,$,K,Y,P,j,f,J,z,Z,A){await Fv(q,$,"tool",K,j,{toolName:Y,arguments:P,isToolCall:!0});let T=ZO6(z,Z,Y,K,$.content.text||"",j,f);L8.info("reasoning prompt: ",T);let v=await q.useModel(q1.TEXT_SMALL,{prompt:T});if(A)await A({text:v,thought:`I analyzed the output from the ${Y} tool on ${K} and crafted a thoughtful response that addresses the user's request while maintaining my conversational style.`,actions:["CALL_MCP_TOOL"],attachments:f&&J.length>0?J:void 0})}async function GK8(q){if(q)await q({thought:"The user is asking for information that can be found in an MCP resource. I will retrieve and analyze the appropriate resource.",text:"I'll retrieve that information for you. Let me access the resource...",actions:["READ_MCP_RESOURCE"]})}function HO6(q,$,K,Y){return Rq({state:{data:{},text:"",values:{uri:q,userMessage:$,resourceContent:K,resourceMeta:Y}},template:_K8})}function ZO6(q,$,K,Y,P,j,f){let J={...q,values:{...q.values,mcpProvider:$,toolName:K,serverName:Y,userMessage:P,toolOutput:j,hasAttachments:f}};return Rq({state:J,template:HK8})}var tj8=v6(pj8(),1),sj8=v6(aj8(),1);function ej8(q){let $=q.replace(/^```(?:json)?\s*|\s*```$/g,"").trim(),K=$.indexOf("{"),Y=$.lastIndexOf("}");if(K!==-1&&Y!==-1&&Y>K)$=$.substring(K,Y+1);return sj8.default.parse($)}var ZX6=new tj8.default({allErrors:!0,strict:!1});function zj(q,$){try{let K=ZX6.compile($);if(!K(q))return{success:!1,error:(K.errors||[]).map((j)=>{return`${j.instancePath?`${j.instancePath.replace(/^\//,"")}`:"value"}: ${j.message}`}).join(", ")};return{success:!0,data:q}}catch(K){return{success:!1,error:`Schema validation error: ${K instanceof Error?K.message:String(K)}`}}}async function w2({runtime:q,message:$,state:K,callback:Y,input:P,validationFn:j,createFeedbackPromptFn:f,failureMsg:J,retryCount:z=0}){let Z=XX6(q);try{L8.info(`[WITH-MODEL-RETRY] Raw selection input:
|
|
596
|
+
Resource (${Z.uri}): [Binary data]`}return{toolOutput:j,hasAttachments:f,attachments:J}}async function wK8(q,$,K,Y,P,j,f){await Fv(q,$,"resource",Y,P,{uri:K,isResourceAccess:!0});let J=HO6(K,$.content.text||"",P,j),z=await q.useModel(q1.TEXT_SMALL,{prompt:J});if(f)await f({text:z,thought:`I analyzed the content from the ${K} resource on ${Y} and crafted a thoughtful response that addresses the user's request while maintaining my conversational style.`,actions:["READ_MCP_RESOURCE"]})}async function AK8(q,$,K,Y,P,j,f,J,z,Z,A){await Fv(q,$,"tool",K,j,{toolName:Y,arguments:P,isToolCall:!0});let T=ZO6(z,Z,Y,K,$.content.text||"",j,f);L8.info("reasoning prompt: ",T);let v=await q.useModel(q1.TEXT_SMALL,{prompt:T}),N={entityId:$.agentId||q.agentId,roomId:$.roomId,worldId:$.worldId,content:{text:v,thought:`I analyzed the output from the ${Y} tool on ${K} and crafted a thoughtful response that addresses the user's request while maintaining my conversational style.`,actions:["CALL_MCP_TOOL"],attachments:f&&J.length>0?J:void 0}};if(await q.createMemory(N,"messages"),A)await A({text:v,thought:`I analyzed the output from the ${Y} tool on ${K} and crafted a thoughtful response that addresses the user's request while maintaining my conversational style.`,actions:["CALL_MCP_TOOL"],attachments:f&&J.length>0?J:void 0})}async function GK8(q){if(q)await q({thought:"The user is asking for information that can be found in an MCP resource. I will retrieve and analyze the appropriate resource.",text:"I'll retrieve that information for you. Let me access the resource...",actions:["READ_MCP_RESOURCE"]})}function HO6(q,$,K,Y){return Rq({state:{data:{},text:"",values:{uri:q,userMessage:$,resourceContent:K,resourceMeta:Y}},template:_K8})}function ZO6(q,$,K,Y,P,j,f){let J={...q,values:{...q.values,mcpProvider:$,toolName:K,serverName:Y,userMessage:P,toolOutput:j,hasAttachments:f}};return Rq({state:J,template:HK8})}var tj8=v6(pj8(),1),sj8=v6(aj8(),1);function ej8(q){let $=q.replace(/^```(?:json)?\s*|\s*```$/g,"").trim(),K=$.indexOf("{"),Y=$.lastIndexOf("}");if(K!==-1&&Y!==-1&&Y>K)$=$.substring(K,Y+1);return sj8.default.parse($)}var ZX6=new tj8.default({allErrors:!0,strict:!1});function zj(q,$){try{let K=ZX6.compile($);if(!K(q))return{success:!1,error:(K.errors||[]).map((j)=>{return`${j.instancePath?`${j.instancePath.replace(/^\//,"")}`:"value"}: ${j.message}`}).join(", ")};return{success:!0,data:q}}catch(K){return{success:!1,error:`Schema validation error: ${K instanceof Error?K.message:String(K)}`}}}async function w2({runtime:q,message:$,state:K,callback:Y,input:P,validationFn:j,createFeedbackPromptFn:f,failureMsg:J,retryCount:z=0}){let Z=XX6(q);try{L8.info(`[WITH-MODEL-RETRY] Raw selection input:
|
|
597
597
|
${P}`);let A=typeof P==="string"?ej8(P):P;L8.debug(`[WITH-MODEL-RETRY] Parsed selection input:
|
|
598
598
|
${JSON.stringify(A,null,2)}`);let T=j(A);if(T.success===!1)throw new Error(T.error);return T.data}catch(A){let T=A instanceof Error?A.message:"Unknown parsing error";if(L8.error(`[WITH-MODEL-RETRY] Failed to parse response: ${T}`),z<Z){L8.debug(`[WITH-MODEL-RETRY] Retrying (attempt ${z+1}/${Z})`);let v=f(P,T,K,$.content.text||""),V=await q.useModel(q1.OBJECT_LARGE,{prompt:v});return w2({runtime:q,input:V,validationFn:j,message:$,state:K,createFeedbackPromptFn:f,callback:Y,failureMsg:J,retryCount:z+1})}if(Y&&J)await Y({text:J,thought:"Failed to parse response after multiple retries. Requesting clarification from user.",actions:["REPLY"]});return null}}function XX6(q){try{let $=q.getSetting("mcp");if($&&"maxRetries"in $&&$.maxRetries!==void 0){let K=Number($.maxRetries);if(!Number.isNaN(K)&&K>=0)return L8.debug(`[WITH-MODEL-RETRY] Using configured selection retries: ${K}`),K}}catch($){L8.debug("[WITH-MODEL-RETRY] Error reading selection retries config:",$ instanceof Error?$.message:String($))}return YK8}var qf8=`
|
|
599
599
|
{{mcpProvider.text}}
|