module.exports=[283373,e=>{"use strict";var t=e.i(233405),r=e.i(522734),n=e.i(843793);let l=new(e.i(472129)).ClaudeCliAdapter;async function a(t,r,n={}){let i="";try{let{query:a}=await e.A(145135),s=l.resolveCommand();for await(let e of a({prompt:t,options:{tools:n.tools??[],allowedTools:n.allowedTools??[],maxTurns:n.maxTurns??1,cwd:r,pathToClaudeCodeExecutable:s,sessionPersistence:!1}}))if("assistant"===e.type){let t=e.message.content.filter(e=>"text"===e.type);i+=t.map(e=>e.text??"").join("")}else if("result"===e.type){let t="string"==typeof e.result?e.result:"";t&&!i&&(i=t)}return i.trim()||null}catch(e){if(e.message?.includes("maximum number of turns")&&i.trim())return i.trim();return console.error("[aiQuery] Failed:",e.message,e.stack?.slice(0,300)),null}}async function i(e,t){let r=`以下是一次AI编程助手的终端会话记录。请用一句简短的中文总结这次会话做了什么（不超过50字，只回答总结内容，不要加引号或前缀）：

\`\`\`
${e.slice(-5e3)}
\`\`\``,n=await a(r,t);return n&&n.replace(/^[#*\->"'\s]+/,"").trim()||null}function s(e,r){return(0,t.execFileSync)("git",e,{cwd:r,timeout:1e4,encoding:"utf-8",stdio:["pipe","pipe","pipe"]}).trim()}function u(e){for(let t of["main","master","develop"])try{return s(["merge-base","HEAD",t],e)}catch{}return null}function o(e){if(!e)return null;let t=e.split("\n").filter(Boolean);if(0===t.length)return null;let r=t[0].replace(/^[a-f0-9]+\s+/,"");return 1===t.length?r:`${t.length} commits: ${r}`}async function c(e,t,l,a,c){try{let t;console.error(`[captureExecutionSummary] Starting: exec=${e.slice(0,8)} exit=${l} buffer=${a.length}chars worktree=${c}`);let m=null,f=null,p=null;if(c&&(0,r.existsSync)(c))try{if(s(["rev-parse","--git-dir"],c),m=function(e){try{let t=u(e);if(t){let r=s(["log","--oneline",`${t}..HEAD`],e);if(r)return r}return s(["log","--oneline","-3"],e)||null}catch{return null}}(c),(f=function(e){try{let t,r=u(e);if(!(t=r?s(["diff","--stat",`${r}..HEAD`],e):s(["diff","--stat","HEAD~20","HEAD"],e)))return null;return function(e){let t=e.split("\n"),r=t[t.length-1];if(!r)return null;let n=r.match(/(\d+)\s+files?\s+changed/),l=r.match(/(\d+)\s+insertions?\(\+\)/),a=r.match(/(\d+)\s+deletions?\(-\)/);return n||l||a?{commits:0,filesChanged:n?parseInt(n[1],10):0,insertions:l?parseInt(l[1],10):0,deletions:a?parseInt(a[1],10):0}:null}(t)}catch{return null}}(c))&&m){let e=m.split("\n").filter(Boolean).length;f={...f,commits:e}}p=o(m)}catch{}let d=(t=a.replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g,"").replace(/\x1b\[[0-9;?]*[A-Za-z]/g,"").replace(/\x1b[^[\]()][^\x1b]*/g,"").replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g,"").replace(/\n{3,}/g,"\n\n").trim()).length<=10240?t:t.slice(t.length-10240);await n.db.taskExecution.update({where:{id:e},data:{summary:p??(m?o(m):null),gitLog:m??null,gitStats:f?JSON.stringify(f):null,exitCode:l,terminalLog:d||null}}),d&&c&&(console.error("[captureExecutionSummary] Starting background AI summary..."),i(d,c).then(async t=>{t&&(console.error(`[captureExecutionSummary] AI summary ready: ${t.slice(0,80)}`),await n.db.taskExecution.update({where:{id:e},data:{summary:t}}))}).catch(e=>{console.error("[captureExecutionSummary] Background AI summary failed:",e)}))}catch(e){console.error("[captureExecutionSummary] Failed to capture summary:",e)}}e.s(["captureExecutionSummary",0,c],283373)},145135,e=>{e.v(t=>Promise.all(["server/chunks/[externals]__0lhlhz4._.js","server/chunks/07-d_@anthropic-ai_claude-agent-sdk_sdk_mjs_0.721uk._.js"].map(t=>e.l(t))).then(()=>t(217040)))}];

//# sourceMappingURL=_0_eodxe._.js.map