import{fa as A}from"./cli-0.5.3-t456sxjr.mjs";import{D5 as H,V5 as P}from"./cli-0.5.3-vpcrbd8n.mjs";import{H6 as F,o6 as $,p6 as y,x6 as q,y6 as z}from"./cli-0.5.3-t65dek0m.mjs";import{$ea as N,Dfa as C,Nfa as X,Qfa as E,_ea as _,afa as B,cfa as W,qfa as O,vfa as w,zfa as V}from"./cli-0.5.3-n3cxyxpg.mjs";import{gma as L,pia as Z}from"./cli-0.5.3-qrvd6cmy.mjs";P();L();N();y();W();E();C();F();w();import{dirname as I,join as x}from"path";var T=q(new Date);function D(){return x($.errors(),T+".jsonl")}function J(G){return x($.mcpLogs(G),T+".jsonl")}function S(G){let K=_(G);return{write(Q){K.write(O(Q)+`
`)},flush:K.flush,dispose:K.dispose}}var R=new Map;function M(G){let K=R.get(G);if(!K){let Q=I(G);K=S({writeFn:(U)=>{try{V().appendFileSync(G,U)}catch{V().mkdirSync(Q),V().appendFileSync(G,U)}},flushIntervalMs:1000,maxBufferSize:50}),R.set(G,K),B(async()=>K?.dispose())}return K}function f(G,K){}function v(G){if(typeof G==="string")return G;if(G&&typeof G==="object"){let K=G;if(typeof K.message==="string")return K.message;if(typeof K.error==="object"&&K.error&&"message"in K.error&&typeof K.error.message==="string")return K.error.message}return}function j(G){let K=G.stack||G.message,Q="";if(H.isAxiosError(G)&&G.config?.url){let U=[`url=${G.config.url}`];if(G.response?.status!==void 0)U.push(`status=${G.response.status}`);let Y=v(G.response?.data);if(Y)U.push(`body=${Y}`);Q=`[${U.join(",")}] `}X(`${G.name}: ${Q}${K}`,{level:"error"}),f(D(),{error:`${Q}${K}`})}function b(G,K){X(`MCP server "${G}" ${K}`,{level:"error"});let Q=J(G),Y={error:K instanceof Error?K.stack||K.message:String(K),timestamp:new Date().toISOString(),sessionId:Z(),cwd:V().cwd()};M(Q).write(Y)}function u(G,K){X(`MCP server "${G}": ${K}`);let Q=J(G),U={debug:K,timestamp:new Date().toISOString(),sessionId:Z(),cwd:V().cwd()};M(Q).write(U)}function k(){z({logError:j,logMCPError:b,logMCPDebug:u,getErrorsPath:D,getMCPLogsPath:J}),X("Error log sink initialized")}function e(){k(),A()}
export{e as da};
