"use strict";exports.id=3895,exports.ids=[3895],exports.modules={16672:(e,r,t)=>{t.d(r,{ZP:()=>o}),t(92048);var n=t(55315);function o(){let e=(0,n.dirname)(__dirname);return e.includes("/lib/node_modules/")||e.includes("\\node_modules\\")||e.includes("/node_modules/commandmate")}t(19801)},43753:(e,r,t)=>{t.d(r,{F:()=>o});let n=["/etc","/usr","/bin","/sbin","/var","/tmp","/dev","/sys","/proc"];function o(e){return n.some(r=>e.startsWith(r))}},78679:(e,r,t)=>{t.d(r,{Bl:()=>l,O3:()=>c});var n=t(55315),o=t.n(n),i=t(19801),s=t(16672),a=t(43753);function l(){return(0,s.ZP)()?o().join((0,i.homedir)(),".commandmate","data","cm.db"):o().resolve(process.cwd(),"data","cm.db")}function c(e){let r=o().resolve(e);if((0,s.ZP)()){let e=(0,i.homedir)();if(!r.startsWith(e))throw Error(`Security error: DB path must be within home directory: ${r}`)}else if((0,a.F)(r))throw Error(`Security error: DB path cannot be in system directory: ${r}`);return r}},98838:(e,r,t)=>{t.d(r,{dU:()=>u,Hb:()=>l,LI:()=>d});var n=t(55315),o=t.n(n),i=t(78679);let s={CM_ROOT_DIR:"MCBD_ROOT_DIR",CM_PORT:"MCBD_PORT",CM_BIND:"MCBD_BIND",CM_LOG_LEVEL:"MCBD_LOG_LEVEL",CM_LOG_FORMAT:"MCBD_LOG_FORMAT",CM_LOG_DIR:"MCBD_LOG_DIR",CM_DB_PATH:"MCBD_DB_PATH"},a=new Set;function l(e){return function(e,r){let t=process.env[e];if(void 0!==t)return t;let n=process.env[r];if(void 0!==n)return a.has(r)||(console.warn(`[DEPRECATED] ${r} is deprecated, use ${e} instead`),a.add(r)),n}(e,s[e])}let c=!1;function d(){let e=l("CM_LOG_LEVEL")?.toLowerCase(),r=l("CM_LOG_FORMAT")?.toLowerCase();return{level:void 0!==e&&["debug","info","warn","error"].includes(e)?e:"info",format:"json"===r?"json":"text"}}function u(){let e;let r=l("CM_ROOT_DIR")||process.cwd(),t=parseInt(l("CM_PORT")||"3000",10),n=l("CM_BIND")||"127.0.0.1",s=l("CM_DB_PATH")||function(){let e=process.env.DATABASE_PATH;return e&&!c&&(console.warn("[DEPRECATED] DATABASE_PATH is deprecated. Use CM_DB_PATH instead."),c=!0),e}()||(0,i.Bl)();if(!r)throw Error("CM_ROOT_DIR (or MCBD_ROOT_DIR) is required");if(isNaN(t)||t<1||t>65535)throw Error(`Invalid CM_PORT: ${l("CM_PORT")}. Must be between 1 and 65535.`);if("127.0.0.1"!==n&&"0.0.0.0"!==n&&"localhost"!==n)throw Error(`Invalid CM_BIND: ${n}. Must be '127.0.0.1', '0.0.0.0', or 'localhost'.`);try{e=(0,i.O3)(s)}catch{console.warn(`[Security] Invalid DB path "${s}", using default.`),e=(0,i.O3)((0,i.Bl)())}return{CM_ROOT_DIR:o().resolve(r),CM_PORT:t,CM_BIND:n,CM_DB_PATH:e}}},43895:(e,r,t)=>{t.d(r,{Y:()=>l,h:()=>c});var n=t(98838);let o=[{pattern:/Bearer\s+[A-Za-z0-9\-._~+/]+=*/gi,replacement:"Bearer [REDACTED]"},{pattern:/(password|passwd|pwd)[=:]\s*\S+/gi,replacement:"$1=[REDACTED]"},{pattern:/(token|secret|api_key|apikey|auth)[=:]\s*\S+/gi,replacement:"$1=[REDACTED]"},{pattern:/Authorization:\s*\S+/gi,replacement:"Authorization: [REDACTED]"},{pattern:/-----BEGIN\s+\w+\s+PRIVATE\s+KEY-----[\s\S]*?-----END\s+\w+\s+PRIVATE\s+KEY-----/g,replacement:"[SSH_KEY_REDACTED]"}],i=/password|secret|token|key|auth/i,s={debug:0,info:1,warn:2,error:3};function a(e,r,t,a,l){let c=(0,n.LI)().level;if(s[e]<s[c])return;let d=a?function e(r){if("string"==typeof r){let e=r;for(let{pattern:r,replacement:t}of o)e=e.replace(r,t);return e}if("object"==typeof r&&null!==r){if(Array.isArray(r))return r.map(e);let t={};for(let[n,o]of Object.entries(r))i.test(n)?t[n]="[REDACTED]":t[n]=e(o);return t}return r}(a):void 0,u=function(e){if("json"===(0,n.LI)().format)return JSON.stringify(e);let{timestamp:r,level:t,module:o,action:i,data:s,worktreeId:a,cliToolId:l,requestId:c}=e,d=[a,l].filter(Boolean),u=d.length>0?` [${d.join(":")}]`:"",_=c?` (${c.slice(0,8)})`:"",D=s?` ${JSON.stringify(s)}`:"";return`[${r}] [${t.toUpperCase()}] [${o}]${u}${_} ${i}${D}`}({level:e,module:r,action:t,timestamp:new Date().toISOString(),...l,...d&&{data:d}});switch(e){case"error":console.error(u);break;case"warn":console.warn(u);break;default:console.log(u)}}function l(){return"undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let r=16*Math.random()|0;return("x"===e?r:3&r|8).toString(16)})}function c(e){let r=t=>({debug:(r,n)=>a("debug",e,r,n,t),info:(r,n)=>a("info",e,r,n,t),warn:(r,n)=>a("warn",e,r,n,t),error:(r,n)=>a("error",e,r,n,t),withContext:e=>r({...t,...e})});return r()}}};