@evolvingmachines/sdk 0.0.12 → 0.0.14
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.cjs +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
`)].filter(r=>r.length>0);await c.files.write(s,l.join(`
|
|
4
4
|
|
|
5
5
|
`)+`
|
|
6
|
-
`);}async function Ce(c,e,n,s){if(!(!s||Object.keys(s).length===0))switch(c){case "claude":await Q(e,n,s);break;case "codex":await te(e,s);break;case "gemini":await X(e,s);break;case "qwen":await ee(e,s);break;default:throw new Error(`Unknown agent type for MCP config: ${c}`)}}function ne(){let c={};return function(p){let t;try{t=JSON.parse(p);}catch{return null}if(t._meta||t._prompt)return null;let u=t.session_id;switch(t.type){case "system":return null;case "assistant":return e(t.message?.content,"assistant",u);case "user":{let d=t.message?.content;return typeof d=="string"||Array.isArray(d)&&d.length===1&&d[0].type==="text"?null:e(d,"user",u)}case "result":return null;default:return null}};function e(r,p,t){if(typeof r=="string")return p==="user"?null:[{sessionId:t,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:r}}}];if(!r||!Array.isArray(r))return null;let u=[];for(let d of r){let m=null;switch(d.type){case "text":case "text_delta":if(p==="user")break;m={sessionUpdate:"agent_message_chunk",content:{type:"text",text:d.text}};break;case "image":if(p==="user")break;m={sessionUpdate:"agent_message_chunk",content:{type:"image",data:d.source?.type==="base64"?d.source.data:"",mimeType:d.source?.type==="base64"?d.source.media_type:"",uri:d.source?.type==="url"?d.source.url:void 0}};break;case "thinking":case "thinking_delta":m={sessionUpdate:"agent_thought_chunk",content:{type:"text",text:d.thinking}};break;case "tool_use":case "server_tool_use":case "mcp_tool_use":{if(c[d.id]=d,d.name==="TodoWrite")Array.isArray(d.input?.todos)&&(m={sessionUpdate:"plan",entries:o(d.input)});else {let f=n(d);m={sessionUpdate:"tool_call",toolCallId:d.id,status:"pending",...f};}break}case "tool_result":case "tool_search_tool_result":case "web_fetch_tool_result":case "web_search_tool_result":case "code_execution_tool_result":case "bash_code_execution_tool_result":case "text_editor_code_execution_tool_result":case "mcp_tool_result":{let f=c[d.tool_use_id];if(!f||(delete c[d.tool_use_id],f.name==="TodoWrite"))break;m={sessionUpdate:"tool_call_update",toolCallId:d.tool_use_id,status:"is_error"in d&&d.is_error?"failed":"completed",...s(d,f)};break}}m&&u.push({sessionId:t,update:m});}return u.length>0?u:null}function n(r){let p=r.name,t=r.input||{};switch(p){case "Task":return {title:t.description||"Task",kind:"think",content:t.prompt?[{type:"content",content:{type:"text",text:t.prompt}}]:[],rawInput:t};case "NotebookRead":return {title:t.notebook_path?`Read Notebook ${t.notebook_path}`:"Read Notebook",kind:"read",content:[],locations:t.notebook_path?[{path:t.notebook_path}]:[],rawInput:t};case "NotebookEdit":return {title:t.notebook_path?`Edit Notebook ${t.notebook_path}`:"Edit Notebook",kind:"edit",content:t.new_source?[{type:"content",content:{type:"text",text:t.new_source}}]:[],locations:t.notebook_path?[{path:t.notebook_path}]:[],rawInput:t};case "Bash":return {title:t.command?"`"+t.command.replaceAll("`","\\`")+"`":"Terminal",kind:"execute",content:t.description?[{type:"content",content:{type:"text",text:t.description}}]:[],rawInput:t};case "BashOutput":return {title:"Tail Logs",kind:"execute",content:[],rawInput:t};case "KillShell":return {title:"Kill Process",kind:"execute",content:[],rawInput:t};case "Read":{let u="";return t.limit?u=" ("+((t.offset??0)+1)+" - "+((t.offset??0)+t.limit)+")":t.offset&&(u=" (from line "+(t.offset+1)+")"),{title:"Read "+(t.file_path??"File")+u,kind:"read",content:[],locations:t.file_path?[{path:t.file_path,line:t.offset??0}]:[],rawInput:t}}case "LS":return {title:t.path?`List \`${t.path}\` directory`:"List current directory",kind:"search",content:[],locations:[],rawInput:t};case "Edit":{let u=t.file_path;return {title:u?`Edit \`${u}\``:"Edit",kind:"edit",content:u?[{type:"diff",path:u,oldText:t.old_string??null,newText:t.new_string??""}]:[],locations:u?[{path:u}]:[],rawInput:t}}case "Write":return {title:t.file_path?`Write ${t.file_path}`:"Write",kind:"edit",content:t.file_path?[{type:"diff",path:t.file_path,oldText:null,newText:t.content??""}]:[],locations:t.file_path?[{path:t.file_path}]:[],rawInput:t};case "Glob":{let u="Find";return t.path&&(u+=` \`${t.path}\``),t.pattern&&(u+=` \`${t.pattern}\``),{title:u,kind:"search",content:[],locations:t.path?[{path:t.path}]:[],rawInput:t}}case "Grep":{let u="grep";return t["-i"]&&(u+=" -i"),t["-n"]&&(u+=" -n"),t["-A"]!==void 0&&(u+=` -A ${t["-A"]}`),t["-B"]!==void 0&&(u+=` -B ${t["-B"]}`),t["-C"]!==void 0&&(u+=` -C ${t["-C"]}`),t.output_mode==="files_with_matches"?u+=" -l":t.output_mode==="count"&&(u+=" -c"),t.head_limit!==void 0&&(u+=` | head -${t.head_limit}`),t.glob&&(u+=` --include="${t.glob}"`),t.type&&(u+=` --type=${t.type}`),t.multiline&&(u+=" -P"),u+=` "${t.pattern??""}"`,t.path&&(u+=` ${t.path}`),{title:u,kind:"search",content:[],rawInput:t}}case "WebFetch":return {title:t.url?`Fetch ${t.url}`:"Fetch",kind:"fetch",content:t.prompt?[{type:"content",content:{type:"text",text:t.prompt}}]:[],rawInput:t};case "WebSearch":{let u=`"${t.query??""}"`;return t.allowed_domains?.length>0&&(u+=` (allowed: ${t.allowed_domains.join(", ")})`),t.blocked_domains?.length>0&&(u+=` (blocked: ${t.blocked_domains.join(", ")})`),{title:u,kind:"fetch",content:[],rawInput:t}}case "TodoWrite":return {title:Array.isArray(t.todos)?`Update TODOs: ${t.todos.map(u=>u.content).join(", ")}`:"Update TODOs",kind:"think",content:[],rawInput:t};case "ExitPlanMode":return {title:"Ready to code?",kind:"switch_mode",content:t.plan?[{type:"content",content:{type:"text",text:t.plan}}]:[],rawInput:t};default:if(p?.startsWith("mcp__")){let u=p.split("__"),d=u[1]||"mcp",m=u.slice(2).join("__")||p;return {title:`${d}: ${m}`,kind:"other",content:[],rawInput:t}}return {title:p||"Unknown Tool",kind:"other",content:[],rawInput:t}}}function s(r,p){let t=r.content;switch(p?.name){case "Read":return Array.isArray(t)&&t.length>0?{content:t.map(u=>({type:"content",content:u.type==="text"?{type:"text",text:l(u.text)}:i(u,false)}))}:typeof t=="string"&&t.length>0?{content:[{type:"content",content:{type:"text",text:l(t)}}]}:{};case "Edit":case "Write":case "Bash":return
|
|
6
|
+
`);}async function Ce(c,e,n,s){if(!(!s||Object.keys(s).length===0))switch(c){case "claude":await Q(e,n,s);break;case "codex":await te(e,s);break;case "gemini":await X(e,s);break;case "qwen":await ee(e,s);break;default:throw new Error(`Unknown agent type for MCP config: ${c}`)}}function ne(){let c={};return function(p){let t;try{t=JSON.parse(p);}catch{return null}if(t._meta||t._prompt)return null;let u=t.session_id;switch(t.type){case "system":return null;case "assistant":return e(t.message?.content,"assistant",u);case "user":{let d=t.message?.content;return typeof d=="string"||Array.isArray(d)&&d.length===1&&d[0].type==="text"?null:e(d,"user",u)}case "result":return null;default:return null}};function e(r,p,t){if(typeof r=="string")return p==="user"?null:[{sessionId:t,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:r}}}];if(!r||!Array.isArray(r))return null;let u=[];for(let d of r){let m=null;switch(d.type){case "text":case "text_delta":if(p==="user")break;m={sessionUpdate:"agent_message_chunk",content:{type:"text",text:d.text}};break;case "image":if(p==="user")break;m={sessionUpdate:"agent_message_chunk",content:{type:"image",data:d.source?.type==="base64"?d.source.data:"",mimeType:d.source?.type==="base64"?d.source.media_type:"",uri:d.source?.type==="url"?d.source.url:void 0}};break;case "thinking":case "thinking_delta":m={sessionUpdate:"agent_thought_chunk",content:{type:"text",text:d.thinking}};break;case "tool_use":case "server_tool_use":case "mcp_tool_use":{if(c[d.id]=d,d.name==="TodoWrite")Array.isArray(d.input?.todos)&&(m={sessionUpdate:"plan",entries:o(d.input)});else {let f=n(d);m={sessionUpdate:"tool_call",toolCallId:d.id,status:"pending",...f};}break}case "tool_result":case "tool_search_tool_result":case "web_fetch_tool_result":case "web_search_tool_result":case "code_execution_tool_result":case "bash_code_execution_tool_result":case "text_editor_code_execution_tool_result":case "mcp_tool_result":{let f=c[d.tool_use_id];if(!f||(delete c[d.tool_use_id],f.name==="TodoWrite"))break;m={sessionUpdate:"tool_call_update",toolCallId:d.tool_use_id,status:"is_error"in d&&d.is_error?"failed":"completed",...s(d,f)};break}}m&&u.push({sessionId:t,update:m});}return u.length>0?u:null}function n(r){let p=r.name,t=r.input||{};switch(p){case "Task":return {title:t.description||"Task",kind:"think",content:t.prompt?[{type:"content",content:{type:"text",text:t.prompt}}]:[],rawInput:t};case "NotebookRead":return {title:t.notebook_path?`Read Notebook ${t.notebook_path}`:"Read Notebook",kind:"read",content:[],locations:t.notebook_path?[{path:t.notebook_path}]:[],rawInput:t};case "NotebookEdit":return {title:t.notebook_path?`Edit Notebook ${t.notebook_path}`:"Edit Notebook",kind:"edit",content:t.new_source?[{type:"content",content:{type:"text",text:t.new_source}}]:[],locations:t.notebook_path?[{path:t.notebook_path}]:[],rawInput:t};case "Bash":return {title:t.command?"`"+t.command.replaceAll("`","\\`")+"`":"Terminal",kind:"execute",content:t.description?[{type:"content",content:{type:"text",text:t.description}}]:[],rawInput:t};case "BashOutput":return {title:"Tail Logs",kind:"execute",content:[],rawInput:t};case "KillShell":return {title:"Kill Process",kind:"execute",content:[],rawInput:t};case "Read":{let u="";return t.limit?u=" ("+((t.offset??0)+1)+" - "+((t.offset??0)+t.limit)+")":t.offset&&(u=" (from line "+(t.offset+1)+")"),{title:"Read "+(t.file_path??"File")+u,kind:"read",content:[],locations:t.file_path?[{path:t.file_path,line:t.offset??0}]:[],rawInput:t}}case "LS":return {title:t.path?`List \`${t.path}\` directory`:"List current directory",kind:"search",content:[],locations:[],rawInput:t};case "Edit":{let u=t.file_path;return {title:u?`Edit \`${u}\``:"Edit",kind:"edit",content:u?[{type:"diff",path:u,oldText:t.old_string??null,newText:t.new_string??""}]:[],locations:u?[{path:u}]:[],rawInput:t}}case "Write":return {title:t.file_path?`Write ${t.file_path}`:"Write",kind:"edit",content:t.file_path?[{type:"diff",path:t.file_path,oldText:null,newText:t.content??""}]:[],locations:t.file_path?[{path:t.file_path}]:[],rawInput:t};case "Glob":{let u="Find";return t.path&&(u+=` \`${t.path}\``),t.pattern&&(u+=` \`${t.pattern}\``),{title:u,kind:"search",content:[],locations:t.path?[{path:t.path}]:[],rawInput:t}}case "Grep":{let u="grep";return t["-i"]&&(u+=" -i"),t["-n"]&&(u+=" -n"),t["-A"]!==void 0&&(u+=` -A ${t["-A"]}`),t["-B"]!==void 0&&(u+=` -B ${t["-B"]}`),t["-C"]!==void 0&&(u+=` -C ${t["-C"]}`),t.output_mode==="files_with_matches"?u+=" -l":t.output_mode==="count"&&(u+=" -c"),t.head_limit!==void 0&&(u+=` | head -${t.head_limit}`),t.glob&&(u+=` --include="${t.glob}"`),t.type&&(u+=` --type=${t.type}`),t.multiline&&(u+=" -P"),u+=` "${t.pattern??""}"`,t.path&&(u+=` ${t.path}`),{title:u,kind:"search",content:[],rawInput:t}}case "WebFetch":return {title:t.url?`Fetch ${t.url}`:"Fetch",kind:"fetch",content:t.prompt?[{type:"content",content:{type:"text",text:t.prompt}}]:[],rawInput:t};case "WebSearch":{let u=`"${t.query??""}"`;return t.allowed_domains?.length>0&&(u+=` (allowed: ${t.allowed_domains.join(", ")})`),t.blocked_domains?.length>0&&(u+=` (blocked: ${t.blocked_domains.join(", ")})`),{title:u,kind:"fetch",content:[],rawInput:t}}case "TodoWrite":return {title:Array.isArray(t.todos)?`Update TODOs: ${t.todos.map(u=>u.content).join(", ")}`:"Update TODOs",kind:"think",content:[],rawInput:t};case "ExitPlanMode":return {title:"Ready to code?",kind:"switch_mode",content:t.plan?[{type:"content",content:{type:"text",text:t.plan}}]:[],rawInput:t};default:if(p?.startsWith("mcp__")){let u=p.split("__"),d=u[1]||"mcp",m=u.slice(2).join("__")||p;return {title:`${d}: ${m}`,kind:"other",content:[],rawInput:t}}return {title:p||"Unknown Tool",kind:"other",content:[],rawInput:t}}}function s(r,p){let t=r.content;switch(p?.name){case "Read":return Array.isArray(t)&&t.length>0?{content:t.map(u=>({type:"content",content:u.type==="text"?{type:"text",text:l(u.text)}:i(u,false)}))}:typeof t=="string"&&t.length>0?{content:[{type:"content",content:{type:"text",text:l(t)}}]}:{};case "Edit":case "Write":case "Bash":return a(t,r.is_error||false);case "ExitPlanMode":return {title:"Exited Plan Mode"};default:return a(t,"is_error"in r?r.is_error:false)}}function a(r,p=false){return Array.isArray(r)&&r.length>0?{content:r.map(t=>({type:"content",content:i(t,p)}))}:typeof r=="string"&&r.length>0?{content:[{type:"content",content:{type:"text",text:p?"```\n"+r+"\n```":r}}]}:{}}function i(r,p){if(r.type==="text")return p?{type:"text",text:"```\n"+r.text+"\n```"}:{type:"text",text:r.text};if(r.type==="image"){if(r.data&&r.mimeType)return {type:"image",data:r.data,mimeType:r.mimeType};if(r.source?.type==="base64")return {type:"image",data:r.source.data||"",mimeType:r.source.media_type||""};if(r.source?.type==="url")return {type:"image",data:"",mimeType:"",uri:r.source.url}}return r}function o(r){return r.todos.map(p=>({content:p.content,status:p.status||"pending",priority:"medium"}))}function l(r){let p="```",t=Array.from(r.matchAll(/^```+/gm));for(let[u]of t)for(;u.length>=p.length;)p+="`";return p+`
|
|
7
7
|
`+r+(r.endsWith(`
|
|
8
8
|
`)?"":`
|
|
9
9
|
`)+p}}function se(){return function(r){let p;try{p=JSON.parse(r);}catch{return null}if(p._meta||p._prompt)return null;let t=[];switch(p.type){case "thread.started":case "turn.started":case "turn.completed":return null;case "item.started":{let u=p.item;if(!u)return null;let d=e(u);d&&t.push({update:d});break}case "item.updated":{let u=p.item;if(!u)return null;let d=n(u);d&&t.push({update:d});break}case "item.completed":{let u=p.item;if(!u)return null;let d=s(u);d&&t.push({update:d});break}default:return null}return t.length>0?t:null};function e(l){let r=l.id;switch(l.type){case "mcp_tool_call":return {type:"mcp_tool_call",name:`${l.server}:${l.tool}`},{sessionUpdate:"tool_call",toolCallId:r,title:`${l.server}: ${l.tool}`,kind:"other",status:"in_progress",rawInput:l.arguments,content:[]};case "command_execution":return {type:"command_execution",name:l.command},{sessionUpdate:"tool_call",toolCallId:r,title:l.command?`\`${l.command}\``:"Execute Command",kind:"execute",status:"in_progress",rawInput:{command:l.command},content:[]};case "web_search":return {type:"web_search",name:l.query},{sessionUpdate:"tool_call",toolCallId:r,title:`Search: ${l.query??""}`,kind:"fetch",status:"in_progress",content:[]};case "todo_list":return {sessionUpdate:"plan",entries:o(l.items)};default:return null}}function n(l){return l.type==="todo_list"?{sessionUpdate:"plan",entries:o(l.items)}:null}function s(l){let r=l.id;switch(l.type){case "reasoning":return {sessionUpdate:"agent_thought_chunk",content:{type:"text",text:l.text??l.summary?.join(`
|
|
@@ -19,7 +19,7 @@ ${h}
|
|
|
19
19
|
\`\`\``:h}});}}return {sessionUpdate:"tool_call_update",toolCallId:t,status:u?"failed":"completed",content:m}}function r(p,t){let u=Mt[p]||"other",d=[],m=[],f=p;switch(p){case "Read":case "read_file":f=`Read ${t.file_path||t.absolute_path||"file"}`,(t.file_path||t.absolute_path)&&m.push({path:t.file_path||t.absolute_path});break;case "Write":case "write_file":f=`Write ${t.file_path||"file"}`,t.file_path&&(m.push({path:t.file_path}),d.push({type:"diff",path:t.file_path,oldText:null,newText:t.content||""}));break;case "Edit":case "edit_file":f=`Edit ${t.file_path||"file"}`,t.file_path&&m.push({path:t.file_path});break;case "Bash":case "shell":case "run_shell_command":f=t.command?`\`${t.command}\``:"Run command",t.description&&d.push({type:"content",content:{type:"text",text:t.description}});break;case "WebFetch":f=t.url?`Fetch ${t.url}`:"Web fetch";break;case "WebSearch":case "brave_web_search":f=t.query?`"${t.query}"`:"Web search";break;case "Glob":f=`Find ${t.pattern||"files"}`,t.path&&m.push({path:t.path});break;case "Grep":f=`grep "${t.pattern||""}"`;break;case "LS":case "list_directory":f=`List ${t.path||"directory"}`,t.path&&m.push({path:t.path});break;case "Task":f=t.description||"Subagent task";break;case "TodoWrite":f="Update todos";break;case "ExitPlanMode":f="Exit plan mode";break;default:f=p;}return {title:f,kind:u,content:d,locations:m}}}function Le(c){return oe()(c)}function O(c){switch(c){case "claude":return ne();case "codex":return se();case "gemini":return ie();case "qwen":return oe();default:return ()=>null}}function Ot(c,e){let n=e.trim();return n?O(c)(n):null}function It(c,e){let n=[],s=e.split(`
|
|
20
20
|
`),a=O(c);for(let i of s){let o=i.trim();if(!o)continue;let l=a(o);l&&n.push(...l);}return n}function K(){return process.env.EVOLVE_GATEWAY_URL||"https://swarmkit-gateway-692833842999.us-central1.run.app"}function je(){return `${K()}`}function Ve(){return `${K()}/e2b`}function Ke(c){return {"browser-use":{type:"http",url:`${K()}/browser_use/mcp`,headers:{"x-litellm-api-key":`Bearer ${c}`}}}}var I="EVOLVE_API_KEY",re="E2B_API_KEY",ae="DAYTONA_API_KEY",ce="MODAL_TOKEN_ID",Se="MODAL_TOKEN_SECRET",We="claude",W=36e5,Je=4,ke=100,Ye="/home/user/workspace",J="https://dashboard.evolvingmachines.ai",Ge=".evolve-sdk/observability/sessions",ze=100,He=5e3,le=3,Te=1e3;function E(c){return c!==null&&typeof c=="object"&&"safeParse"in c&&typeof c.safeParse=="function"}function N(c){return JSON.stringify(At__default.default(c,{target:"jsonSchema7"}),null,2)}function B(c){return JSON.stringify(c,null,2)}function qe(c,e=false){let n={};function s(a,i){for(let o of P__namespace.readdirSync(a)){let l=Y__namespace.join(a,o),r=i?`${i}/${o}`:o;P__namespace.statSync(l).isDirectory()?e&&s(l,r):n[r]=P__namespace.readFileSync(l);}}return s(c,""),n}function Ze(c,e){for(let[n,s]of Object.entries(e)){let a=Y__namespace.join(c,n),i=Y__namespace.dirname(a);P__namespace.mkdirSync(i,{recursive:true});let o;s instanceof ArrayBuffer||s instanceof Uint8Array?o=Buffer.from(s):o=s,P__namespace.writeFileSync(a,o);}}function Dt(c){let e=c.replace(/^~/,process.env.HOME||"");if(!P__namespace.existsSync(e))throw new Error(`OAuth file not found: ${e}`);return P__namespace.readFileSync(e,"utf-8")}function _e(c){let e=c?.type??We,n=M(e);if(c?.oauthToken){if(e!=="claude")throw new Error(`oauthToken is only supported for claude agent (Claude Max subscription), not ${e}. Use providerApiKey for ${e} instead.`);return {type:e,apiKey:c.oauthToken,isDirectMode:true,isOAuth:true,model:c.model,reasoningEffort:c.reasoningEffort,betas:c.betas}}if(c?.providerApiKey){let o=c.providerBaseUrl??process.env[n.baseUrlEnv]??n.defaultBaseUrl;return {type:e,apiKey:c.providerApiKey,baseUrl:o,isDirectMode:true,model:c.model,reasoningEffort:c.reasoningEffort,betas:c.betas}}if(c?.apiKey)return {type:e,apiKey:c.apiKey,isDirectMode:false,model:c.model,reasoningEffort:c.reasoningEffort,betas:c.betas};let s=process.env[I];if(s)return {type:e,apiKey:s,isDirectMode:false,model:c?.model,reasoningEffort:c?.reasoningEffort,betas:c?.betas};let a=process.env[n.apiKeyEnv];if(a){let o=process.env[n.baseUrlEnv]??n.defaultBaseUrl;return {type:e,apiKey:a,baseUrl:o,isDirectMode:true,model:c?.model,reasoningEffort:c?.reasoningEffort,betas:c?.betas}}if(n.oauthEnv){let o=process.env[n.oauthEnv];if(o){if(n.oauthFileName){let l=Dt(o);return {type:e,apiKey:"__oauth_file__",isDirectMode:true,isOAuth:true,oauthFileContent:l,model:c?.model,reasoningEffort:c?.reasoningEffort,betas:c?.betas}}return {type:e,apiKey:o,isDirectMode:true,isOAuth:true,model:c?.model,reasoningEffort:c?.reasoningEffort,betas:c?.betas}}}let i=n.oauthEnv?n.oauthFileName?`, or ${n.oauthEnv}`:`, oauthToken, or ${n.oauthEnv}`:"";throw new Error(`No API key found for ${e}. Set apiKey (gateway), providerApiKey (direct)${i}, or ${I} / ${n.apiKeyEnv} env var.`)}async function Ee(){let c=process.env[re];if(c)try{let{createE2BProvider:i}=await import('@evolvingmachines/e2b');return i({apiKey:c})}catch(i){let o=i;throw o.message?.includes("Cannot find module")||o.message?.includes("MODULE_NOT_FOUND")?new Error(`${re} is set but @evolvingmachines/e2b failed to load.
|
|
21
21
|
Try reinstalling: npm install @evolvingmachines/sdk`):o}let e=process.env[ae];if(e)try{let{createDaytonaProvider:i}=await import('@evolvingmachines/daytona');return i({apiKey:e})}catch(i){let o=i;throw o.message?.includes("Cannot find module")||o.message?.includes("MODULE_NOT_FOUND")?new Error(`${ae} is set but @evolvingmachines/daytona failed to load.
|
|
22
|
-
Try installing: npm install @evolvingmachines/daytona`):o}let n=process.env[ce],s=process.env[Se];if(n&&s)try{let{createModalProvider:i}=await import('@evolvingmachines/modal');return i()}catch(i){let o=i;throw o.message?.includes("Cannot find module")||o.message?.includes("MODULE_NOT_FOUND")?new Error(`${ce} is set but @evolvingmachines/modal failed to load.
|
|
22
|
+
Try installing: npm install @evolvingmachines/daytona`):o}let n=process.env[ce],s=process.env[Se];if(n&&s)try{let{createModalProvider:i}=await import('@evolvingmachines/modal');return i({tokenId:n,tokenSecret:s})}catch(i){let o=i;throw o.message?.includes("Cannot find module")||o.message?.includes("MODULE_NOT_FOUND")?new Error(`${ce} is set but @evolvingmachines/modal failed to load.
|
|
23
23
|
Try installing: npm install @evolvingmachines/modal`):o}let a=process.env[I];if(a)try{let{createE2BProvider:i}=await import('@evolvingmachines/e2b');return process.env.E2B_API_URL=Ve(),i({apiKey:a})}catch(i){let o=i;throw o.message?.includes("Cannot find module")||o.message?.includes("MODULE_NOT_FOUND")?new Error(`${I} is set but @evolvingmachines/e2b failed to load.
|
|
24
24
|
Try reinstalling: npm install @evolvingmachines/sdk`):o}throw new Error(`No sandbox provider configured. Either:
|
|
25
25
|
1. Set ${I} environment variable (recommended, get key at https://dashboard.evolvingmachines.ai)
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import {EventEmitter}from'events';import tn from'ajv';import At from'zod-to-json
|
|
|
3
3
|
`)].filter(r=>r.length>0);await c.files.write(s,l.join(`
|
|
4
4
|
|
|
5
5
|
`)+`
|
|
6
|
-
`);}async function Ce(c,e,n,s){if(!(!s||Object.keys(s).length===0))switch(c){case "claude":await Q(e,n,s);break;case "codex":await te(e,s);break;case "gemini":await X(e,s);break;case "qwen":await ee(e,s);break;default:throw new Error(`Unknown agent type for MCP config: ${c}`)}}function ne(){let c={};return function(p){let t;try{t=JSON.parse(p);}catch{return null}if(t._meta||t._prompt)return null;let u=t.session_id;switch(t.type){case "system":return null;case "assistant":return e(t.message?.content,"assistant",u);case "user":{let d=t.message?.content;return typeof d=="string"||Array.isArray(d)&&d.length===1&&d[0].type==="text"?null:e(d,"user",u)}case "result":return null;default:return null}};function e(r,p,t){if(typeof r=="string")return p==="user"?null:[{sessionId:t,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:r}}}];if(!r||!Array.isArray(r))return null;let u=[];for(let d of r){let m=null;switch(d.type){case "text":case "text_delta":if(p==="user")break;m={sessionUpdate:"agent_message_chunk",content:{type:"text",text:d.text}};break;case "image":if(p==="user")break;m={sessionUpdate:"agent_message_chunk",content:{type:"image",data:d.source?.type==="base64"?d.source.data:"",mimeType:d.source?.type==="base64"?d.source.media_type:"",uri:d.source?.type==="url"?d.source.url:void 0}};break;case "thinking":case "thinking_delta":m={sessionUpdate:"agent_thought_chunk",content:{type:"text",text:d.thinking}};break;case "tool_use":case "server_tool_use":case "mcp_tool_use":{if(c[d.id]=d,d.name==="TodoWrite")Array.isArray(d.input?.todos)&&(m={sessionUpdate:"plan",entries:o(d.input)});else {let f=n(d);m={sessionUpdate:"tool_call",toolCallId:d.id,status:"pending",...f};}break}case "tool_result":case "tool_search_tool_result":case "web_fetch_tool_result":case "web_search_tool_result":case "code_execution_tool_result":case "bash_code_execution_tool_result":case "text_editor_code_execution_tool_result":case "mcp_tool_result":{let f=c[d.tool_use_id];if(!f||(delete c[d.tool_use_id],f.name==="TodoWrite"))break;m={sessionUpdate:"tool_call_update",toolCallId:d.tool_use_id,status:"is_error"in d&&d.is_error?"failed":"completed",...s(d,f)};break}}m&&u.push({sessionId:t,update:m});}return u.length>0?u:null}function n(r){let p=r.name,t=r.input||{};switch(p){case "Task":return {title:t.description||"Task",kind:"think",content:t.prompt?[{type:"content",content:{type:"text",text:t.prompt}}]:[],rawInput:t};case "NotebookRead":return {title:t.notebook_path?`Read Notebook ${t.notebook_path}`:"Read Notebook",kind:"read",content:[],locations:t.notebook_path?[{path:t.notebook_path}]:[],rawInput:t};case "NotebookEdit":return {title:t.notebook_path?`Edit Notebook ${t.notebook_path}`:"Edit Notebook",kind:"edit",content:t.new_source?[{type:"content",content:{type:"text",text:t.new_source}}]:[],locations:t.notebook_path?[{path:t.notebook_path}]:[],rawInput:t};case "Bash":return {title:t.command?"`"+t.command.replaceAll("`","\\`")+"`":"Terminal",kind:"execute",content:t.description?[{type:"content",content:{type:"text",text:t.description}}]:[],rawInput:t};case "BashOutput":return {title:"Tail Logs",kind:"execute",content:[],rawInput:t};case "KillShell":return {title:"Kill Process",kind:"execute",content:[],rawInput:t};case "Read":{let u="";return t.limit?u=" ("+((t.offset??0)+1)+" - "+((t.offset??0)+t.limit)+")":t.offset&&(u=" (from line "+(t.offset+1)+")"),{title:"Read "+(t.file_path??"File")+u,kind:"read",content:[],locations:t.file_path?[{path:t.file_path,line:t.offset??0}]:[],rawInput:t}}case "LS":return {title:t.path?`List \`${t.path}\` directory`:"List current directory",kind:"search",content:[],locations:[],rawInput:t};case "Edit":{let u=t.file_path;return {title:u?`Edit \`${u}\``:"Edit",kind:"edit",content:u?[{type:"diff",path:u,oldText:t.old_string??null,newText:t.new_string??""}]:[],locations:u?[{path:u}]:[],rawInput:t}}case "Write":return {title:t.file_path?`Write ${t.file_path}`:"Write",kind:"edit",content:t.file_path?[{type:"diff",path:t.file_path,oldText:null,newText:t.content??""}]:[],locations:t.file_path?[{path:t.file_path}]:[],rawInput:t};case "Glob":{let u="Find";return t.path&&(u+=` \`${t.path}\``),t.pattern&&(u+=` \`${t.pattern}\``),{title:u,kind:"search",content:[],locations:t.path?[{path:t.path}]:[],rawInput:t}}case "Grep":{let u="grep";return t["-i"]&&(u+=" -i"),t["-n"]&&(u+=" -n"),t["-A"]!==void 0&&(u+=` -A ${t["-A"]}`),t["-B"]!==void 0&&(u+=` -B ${t["-B"]}`),t["-C"]!==void 0&&(u+=` -C ${t["-C"]}`),t.output_mode==="files_with_matches"?u+=" -l":t.output_mode==="count"&&(u+=" -c"),t.head_limit!==void 0&&(u+=` | head -${t.head_limit}`),t.glob&&(u+=` --include="${t.glob}"`),t.type&&(u+=` --type=${t.type}`),t.multiline&&(u+=" -P"),u+=` "${t.pattern??""}"`,t.path&&(u+=` ${t.path}`),{title:u,kind:"search",content:[],rawInput:t}}case "WebFetch":return {title:t.url?`Fetch ${t.url}`:"Fetch",kind:"fetch",content:t.prompt?[{type:"content",content:{type:"text",text:t.prompt}}]:[],rawInput:t};case "WebSearch":{let u=`"${t.query??""}"`;return t.allowed_domains?.length>0&&(u+=` (allowed: ${t.allowed_domains.join(", ")})`),t.blocked_domains?.length>0&&(u+=` (blocked: ${t.blocked_domains.join(", ")})`),{title:u,kind:"fetch",content:[],rawInput:t}}case "TodoWrite":return {title:Array.isArray(t.todos)?`Update TODOs: ${t.todos.map(u=>u.content).join(", ")}`:"Update TODOs",kind:"think",content:[],rawInput:t};case "ExitPlanMode":return {title:"Ready to code?",kind:"switch_mode",content:t.plan?[{type:"content",content:{type:"text",text:t.plan}}]:[],rawInput:t};default:if(p?.startsWith("mcp__")){let u=p.split("__"),d=u[1]||"mcp",m=u.slice(2).join("__")||p;return {title:`${d}: ${m}`,kind:"other",content:[],rawInput:t}}return {title:p||"Unknown Tool",kind:"other",content:[],rawInput:t}}}function s(r,p){let t=r.content;switch(p?.name){case "Read":return Array.isArray(t)&&t.length>0?{content:t.map(u=>({type:"content",content:u.type==="text"?{type:"text",text:l(u.text)}:i(u,false)}))}:typeof t=="string"&&t.length>0?{content:[{type:"content",content:{type:"text",text:l(t)}}]}:{};case "Edit":case "Write":case "Bash":return
|
|
6
|
+
`);}async function Ce(c,e,n,s){if(!(!s||Object.keys(s).length===0))switch(c){case "claude":await Q(e,n,s);break;case "codex":await te(e,s);break;case "gemini":await X(e,s);break;case "qwen":await ee(e,s);break;default:throw new Error(`Unknown agent type for MCP config: ${c}`)}}function ne(){let c={};return function(p){let t;try{t=JSON.parse(p);}catch{return null}if(t._meta||t._prompt)return null;let u=t.session_id;switch(t.type){case "system":return null;case "assistant":return e(t.message?.content,"assistant",u);case "user":{let d=t.message?.content;return typeof d=="string"||Array.isArray(d)&&d.length===1&&d[0].type==="text"?null:e(d,"user",u)}case "result":return null;default:return null}};function e(r,p,t){if(typeof r=="string")return p==="user"?null:[{sessionId:t,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:r}}}];if(!r||!Array.isArray(r))return null;let u=[];for(let d of r){let m=null;switch(d.type){case "text":case "text_delta":if(p==="user")break;m={sessionUpdate:"agent_message_chunk",content:{type:"text",text:d.text}};break;case "image":if(p==="user")break;m={sessionUpdate:"agent_message_chunk",content:{type:"image",data:d.source?.type==="base64"?d.source.data:"",mimeType:d.source?.type==="base64"?d.source.media_type:"",uri:d.source?.type==="url"?d.source.url:void 0}};break;case "thinking":case "thinking_delta":m={sessionUpdate:"agent_thought_chunk",content:{type:"text",text:d.thinking}};break;case "tool_use":case "server_tool_use":case "mcp_tool_use":{if(c[d.id]=d,d.name==="TodoWrite")Array.isArray(d.input?.todos)&&(m={sessionUpdate:"plan",entries:o(d.input)});else {let f=n(d);m={sessionUpdate:"tool_call",toolCallId:d.id,status:"pending",...f};}break}case "tool_result":case "tool_search_tool_result":case "web_fetch_tool_result":case "web_search_tool_result":case "code_execution_tool_result":case "bash_code_execution_tool_result":case "text_editor_code_execution_tool_result":case "mcp_tool_result":{let f=c[d.tool_use_id];if(!f||(delete c[d.tool_use_id],f.name==="TodoWrite"))break;m={sessionUpdate:"tool_call_update",toolCallId:d.tool_use_id,status:"is_error"in d&&d.is_error?"failed":"completed",...s(d,f)};break}}m&&u.push({sessionId:t,update:m});}return u.length>0?u:null}function n(r){let p=r.name,t=r.input||{};switch(p){case "Task":return {title:t.description||"Task",kind:"think",content:t.prompt?[{type:"content",content:{type:"text",text:t.prompt}}]:[],rawInput:t};case "NotebookRead":return {title:t.notebook_path?`Read Notebook ${t.notebook_path}`:"Read Notebook",kind:"read",content:[],locations:t.notebook_path?[{path:t.notebook_path}]:[],rawInput:t};case "NotebookEdit":return {title:t.notebook_path?`Edit Notebook ${t.notebook_path}`:"Edit Notebook",kind:"edit",content:t.new_source?[{type:"content",content:{type:"text",text:t.new_source}}]:[],locations:t.notebook_path?[{path:t.notebook_path}]:[],rawInput:t};case "Bash":return {title:t.command?"`"+t.command.replaceAll("`","\\`")+"`":"Terminal",kind:"execute",content:t.description?[{type:"content",content:{type:"text",text:t.description}}]:[],rawInput:t};case "BashOutput":return {title:"Tail Logs",kind:"execute",content:[],rawInput:t};case "KillShell":return {title:"Kill Process",kind:"execute",content:[],rawInput:t};case "Read":{let u="";return t.limit?u=" ("+((t.offset??0)+1)+" - "+((t.offset??0)+t.limit)+")":t.offset&&(u=" (from line "+(t.offset+1)+")"),{title:"Read "+(t.file_path??"File")+u,kind:"read",content:[],locations:t.file_path?[{path:t.file_path,line:t.offset??0}]:[],rawInput:t}}case "LS":return {title:t.path?`List \`${t.path}\` directory`:"List current directory",kind:"search",content:[],locations:[],rawInput:t};case "Edit":{let u=t.file_path;return {title:u?`Edit \`${u}\``:"Edit",kind:"edit",content:u?[{type:"diff",path:u,oldText:t.old_string??null,newText:t.new_string??""}]:[],locations:u?[{path:u}]:[],rawInput:t}}case "Write":return {title:t.file_path?`Write ${t.file_path}`:"Write",kind:"edit",content:t.file_path?[{type:"diff",path:t.file_path,oldText:null,newText:t.content??""}]:[],locations:t.file_path?[{path:t.file_path}]:[],rawInput:t};case "Glob":{let u="Find";return t.path&&(u+=` \`${t.path}\``),t.pattern&&(u+=` \`${t.pattern}\``),{title:u,kind:"search",content:[],locations:t.path?[{path:t.path}]:[],rawInput:t}}case "Grep":{let u="grep";return t["-i"]&&(u+=" -i"),t["-n"]&&(u+=" -n"),t["-A"]!==void 0&&(u+=` -A ${t["-A"]}`),t["-B"]!==void 0&&(u+=` -B ${t["-B"]}`),t["-C"]!==void 0&&(u+=` -C ${t["-C"]}`),t.output_mode==="files_with_matches"?u+=" -l":t.output_mode==="count"&&(u+=" -c"),t.head_limit!==void 0&&(u+=` | head -${t.head_limit}`),t.glob&&(u+=` --include="${t.glob}"`),t.type&&(u+=` --type=${t.type}`),t.multiline&&(u+=" -P"),u+=` "${t.pattern??""}"`,t.path&&(u+=` ${t.path}`),{title:u,kind:"search",content:[],rawInput:t}}case "WebFetch":return {title:t.url?`Fetch ${t.url}`:"Fetch",kind:"fetch",content:t.prompt?[{type:"content",content:{type:"text",text:t.prompt}}]:[],rawInput:t};case "WebSearch":{let u=`"${t.query??""}"`;return t.allowed_domains?.length>0&&(u+=` (allowed: ${t.allowed_domains.join(", ")})`),t.blocked_domains?.length>0&&(u+=` (blocked: ${t.blocked_domains.join(", ")})`),{title:u,kind:"fetch",content:[],rawInput:t}}case "TodoWrite":return {title:Array.isArray(t.todos)?`Update TODOs: ${t.todos.map(u=>u.content).join(", ")}`:"Update TODOs",kind:"think",content:[],rawInput:t};case "ExitPlanMode":return {title:"Ready to code?",kind:"switch_mode",content:t.plan?[{type:"content",content:{type:"text",text:t.plan}}]:[],rawInput:t};default:if(p?.startsWith("mcp__")){let u=p.split("__"),d=u[1]||"mcp",m=u.slice(2).join("__")||p;return {title:`${d}: ${m}`,kind:"other",content:[],rawInput:t}}return {title:p||"Unknown Tool",kind:"other",content:[],rawInput:t}}}function s(r,p){let t=r.content;switch(p?.name){case "Read":return Array.isArray(t)&&t.length>0?{content:t.map(u=>({type:"content",content:u.type==="text"?{type:"text",text:l(u.text)}:i(u,false)}))}:typeof t=="string"&&t.length>0?{content:[{type:"content",content:{type:"text",text:l(t)}}]}:{};case "Edit":case "Write":case "Bash":return a(t,r.is_error||false);case "ExitPlanMode":return {title:"Exited Plan Mode"};default:return a(t,"is_error"in r?r.is_error:false)}}function a(r,p=false){return Array.isArray(r)&&r.length>0?{content:r.map(t=>({type:"content",content:i(t,p)}))}:typeof r=="string"&&r.length>0?{content:[{type:"content",content:{type:"text",text:p?"```\n"+r+"\n```":r}}]}:{}}function i(r,p){if(r.type==="text")return p?{type:"text",text:"```\n"+r.text+"\n```"}:{type:"text",text:r.text};if(r.type==="image"){if(r.data&&r.mimeType)return {type:"image",data:r.data,mimeType:r.mimeType};if(r.source?.type==="base64")return {type:"image",data:r.source.data||"",mimeType:r.source.media_type||""};if(r.source?.type==="url")return {type:"image",data:"",mimeType:"",uri:r.source.url}}return r}function o(r){return r.todos.map(p=>({content:p.content,status:p.status||"pending",priority:"medium"}))}function l(r){let p="```",t=Array.from(r.matchAll(/^```+/gm));for(let[u]of t)for(;u.length>=p.length;)p+="`";return p+`
|
|
7
7
|
`+r+(r.endsWith(`
|
|
8
8
|
`)?"":`
|
|
9
9
|
`)+p}}function se(){return function(r){let p;try{p=JSON.parse(r);}catch{return null}if(p._meta||p._prompt)return null;let t=[];switch(p.type){case "thread.started":case "turn.started":case "turn.completed":return null;case "item.started":{let u=p.item;if(!u)return null;let d=e(u);d&&t.push({update:d});break}case "item.updated":{let u=p.item;if(!u)return null;let d=n(u);d&&t.push({update:d});break}case "item.completed":{let u=p.item;if(!u)return null;let d=s(u);d&&t.push({update:d});break}default:return null}return t.length>0?t:null};function e(l){let r=l.id;switch(l.type){case "mcp_tool_call":return {type:"mcp_tool_call",name:`${l.server}:${l.tool}`},{sessionUpdate:"tool_call",toolCallId:r,title:`${l.server}: ${l.tool}`,kind:"other",status:"in_progress",rawInput:l.arguments,content:[]};case "command_execution":return {type:"command_execution",name:l.command},{sessionUpdate:"tool_call",toolCallId:r,title:l.command?`\`${l.command}\``:"Execute Command",kind:"execute",status:"in_progress",rawInput:{command:l.command},content:[]};case "web_search":return {type:"web_search",name:l.query},{sessionUpdate:"tool_call",toolCallId:r,title:`Search: ${l.query??""}`,kind:"fetch",status:"in_progress",content:[]};case "todo_list":return {sessionUpdate:"plan",entries:o(l.items)};default:return null}}function n(l){return l.type==="todo_list"?{sessionUpdate:"plan",entries:o(l.items)}:null}function s(l){let r=l.id;switch(l.type){case "reasoning":return {sessionUpdate:"agent_thought_chunk",content:{type:"text",text:l.text??l.summary?.join(`
|
|
@@ -19,7 +19,7 @@ ${h}
|
|
|
19
19
|
\`\`\``:h}});}}return {sessionUpdate:"tool_call_update",toolCallId:t,status:u?"failed":"completed",content:m}}function r(p,t){let u=Mt[p]||"other",d=[],m=[],f=p;switch(p){case "Read":case "read_file":f=`Read ${t.file_path||t.absolute_path||"file"}`,(t.file_path||t.absolute_path)&&m.push({path:t.file_path||t.absolute_path});break;case "Write":case "write_file":f=`Write ${t.file_path||"file"}`,t.file_path&&(m.push({path:t.file_path}),d.push({type:"diff",path:t.file_path,oldText:null,newText:t.content||""}));break;case "Edit":case "edit_file":f=`Edit ${t.file_path||"file"}`,t.file_path&&m.push({path:t.file_path});break;case "Bash":case "shell":case "run_shell_command":f=t.command?`\`${t.command}\``:"Run command",t.description&&d.push({type:"content",content:{type:"text",text:t.description}});break;case "WebFetch":f=t.url?`Fetch ${t.url}`:"Web fetch";break;case "WebSearch":case "brave_web_search":f=t.query?`"${t.query}"`:"Web search";break;case "Glob":f=`Find ${t.pattern||"files"}`,t.path&&m.push({path:t.path});break;case "Grep":f=`grep "${t.pattern||""}"`;break;case "LS":case "list_directory":f=`List ${t.path||"directory"}`,t.path&&m.push({path:t.path});break;case "Task":f=t.description||"Subagent task";break;case "TodoWrite":f="Update todos";break;case "ExitPlanMode":f="Exit plan mode";break;default:f=p;}return {title:f,kind:u,content:d,locations:m}}}function Le(c){return oe()(c)}function O(c){switch(c){case "claude":return ne();case "codex":return se();case "gemini":return ie();case "qwen":return oe();default:return ()=>null}}function Ot(c,e){let n=e.trim();return n?O(c)(n):null}function It(c,e){let n=[],s=e.split(`
|
|
20
20
|
`),a=O(c);for(let i of s){let o=i.trim();if(!o)continue;let l=a(o);l&&n.push(...l);}return n}function K(){return process.env.EVOLVE_GATEWAY_URL||"https://swarmkit-gateway-692833842999.us-central1.run.app"}function je(){return `${K()}`}function Ve(){return `${K()}/e2b`}function Ke(c){return {"browser-use":{type:"http",url:`${K()}/browser_use/mcp`,headers:{"x-litellm-api-key":`Bearer ${c}`}}}}var I="EVOLVE_API_KEY",re="E2B_API_KEY",ae="DAYTONA_API_KEY",ce="MODAL_TOKEN_ID",Se="MODAL_TOKEN_SECRET",We="claude",W=36e5,Je=4,ke=100,Ye="/home/user/workspace",J="https://dashboard.evolvingmachines.ai",Ge=".evolve-sdk/observability/sessions",ze=100,He=5e3,le=3,Te=1e3;function E(c){return c!==null&&typeof c=="object"&&"safeParse"in c&&typeof c.safeParse=="function"}function N(c){return JSON.stringify(At(c,{target:"jsonSchema7"}),null,2)}function B(c){return JSON.stringify(c,null,2)}function qe(c,e=false){let n={};function s(a,i){for(let o of P.readdirSync(a)){let l=Y.join(a,o),r=i?`${i}/${o}`:o;P.statSync(l).isDirectory()?e&&s(l,r):n[r]=P.readFileSync(l);}}return s(c,""),n}function Ze(c,e){for(let[n,s]of Object.entries(e)){let a=Y.join(c,n),i=Y.dirname(a);P.mkdirSync(i,{recursive:true});let o;s instanceof ArrayBuffer||s instanceof Uint8Array?o=Buffer.from(s):o=s,P.writeFileSync(a,o);}}function Dt(c){let e=c.replace(/^~/,process.env.HOME||"");if(!P.existsSync(e))throw new Error(`OAuth file not found: ${e}`);return P.readFileSync(e,"utf-8")}function _e(c){let e=c?.type??We,n=M(e);if(c?.oauthToken){if(e!=="claude")throw new Error(`oauthToken is only supported for claude agent (Claude Max subscription), not ${e}. Use providerApiKey for ${e} instead.`);return {type:e,apiKey:c.oauthToken,isDirectMode:true,isOAuth:true,model:c.model,reasoningEffort:c.reasoningEffort,betas:c.betas}}if(c?.providerApiKey){let o=c.providerBaseUrl??process.env[n.baseUrlEnv]??n.defaultBaseUrl;return {type:e,apiKey:c.providerApiKey,baseUrl:o,isDirectMode:true,model:c.model,reasoningEffort:c.reasoningEffort,betas:c.betas}}if(c?.apiKey)return {type:e,apiKey:c.apiKey,isDirectMode:false,model:c.model,reasoningEffort:c.reasoningEffort,betas:c.betas};let s=process.env[I];if(s)return {type:e,apiKey:s,isDirectMode:false,model:c?.model,reasoningEffort:c?.reasoningEffort,betas:c?.betas};let a=process.env[n.apiKeyEnv];if(a){let o=process.env[n.baseUrlEnv]??n.defaultBaseUrl;return {type:e,apiKey:a,baseUrl:o,isDirectMode:true,model:c?.model,reasoningEffort:c?.reasoningEffort,betas:c?.betas}}if(n.oauthEnv){let o=process.env[n.oauthEnv];if(o){if(n.oauthFileName){let l=Dt(o);return {type:e,apiKey:"__oauth_file__",isDirectMode:true,isOAuth:true,oauthFileContent:l,model:c?.model,reasoningEffort:c?.reasoningEffort,betas:c?.betas}}return {type:e,apiKey:o,isDirectMode:true,isOAuth:true,model:c?.model,reasoningEffort:c?.reasoningEffort,betas:c?.betas}}}let i=n.oauthEnv?n.oauthFileName?`, or ${n.oauthEnv}`:`, oauthToken, or ${n.oauthEnv}`:"";throw new Error(`No API key found for ${e}. Set apiKey (gateway), providerApiKey (direct)${i}, or ${I} / ${n.apiKeyEnv} env var.`)}async function Ee(){let c=process.env[re];if(c)try{let{createE2BProvider:i}=await import('@evolvingmachines/e2b');return i({apiKey:c})}catch(i){let o=i;throw o.message?.includes("Cannot find module")||o.message?.includes("MODULE_NOT_FOUND")?new Error(`${re} is set but @evolvingmachines/e2b failed to load.
|
|
21
21
|
Try reinstalling: npm install @evolvingmachines/sdk`):o}let e=process.env[ae];if(e)try{let{createDaytonaProvider:i}=await import('@evolvingmachines/daytona');return i({apiKey:e})}catch(i){let o=i;throw o.message?.includes("Cannot find module")||o.message?.includes("MODULE_NOT_FOUND")?new Error(`${ae} is set but @evolvingmachines/daytona failed to load.
|
|
22
|
-
Try installing: npm install @evolvingmachines/daytona`):o}let n=process.env[ce],s=process.env[Se];if(n&&s)try{let{createModalProvider:i}=await import('@evolvingmachines/modal');return i()}catch(i){let o=i;throw o.message?.includes("Cannot find module")||o.message?.includes("MODULE_NOT_FOUND")?new Error(`${ce} is set but @evolvingmachines/modal failed to load.
|
|
22
|
+
Try installing: npm install @evolvingmachines/daytona`):o}let n=process.env[ce],s=process.env[Se];if(n&&s)try{let{createModalProvider:i}=await import('@evolvingmachines/modal');return i({tokenId:n,tokenSecret:s})}catch(i){let o=i;throw o.message?.includes("Cannot find module")||o.message?.includes("MODULE_NOT_FOUND")?new Error(`${ce} is set but @evolvingmachines/modal failed to load.
|
|
23
23
|
Try installing: npm install @evolvingmachines/modal`):o}let a=process.env[I];if(a)try{let{createE2BProvider:i}=await import('@evolvingmachines/e2b');return process.env.E2B_API_URL=Ve(),i({apiKey:a})}catch(i){let o=i;throw o.message?.includes("Cannot find module")||o.message?.includes("MODULE_NOT_FOUND")?new Error(`${I} is set but @evolvingmachines/e2b failed to load.
|
|
24
24
|
Try reinstalling: npm install @evolvingmachines/sdk`):o}throw new Error(`No sandbox provider configured. Either:
|
|
25
25
|
1. Set ${I} environment variable (recommended, get key at https://dashboard.evolvingmachines.ai)
|