module.exports=[495370,a=>{"use strict";var b=a.i(815429),c=a.i(761469),d=a.i(188139),e=a.i(496877);async function f(a){return c.db.label.findMany({where:{OR:[{isBuiltin:!0},{workspaceId:a}]},orderBy:[{isBuiltin:"desc"},{name:"asc"}]})}async function g(a){let b=e.createLabelSchema.parse(a),f=await c.db.label.create({data:{name:b.name,color:b.color,workspaceId:b.workspaceId}});return(0,d.revalidatePath)("/workspaces"),f}async function h(a){let b=await c.db.label.findUnique({where:{id:a}});if(!b)throw Error("Label not found");if(b.isBuiltin)throw Error("Cannot delete builtin labels");await c.db.label.delete({where:{id:a}}),(0,d.revalidatePath)("/workspaces")}async function i(a,b){await c.db.$transaction(async c=>{await c.taskLabel.deleteMany({where:{taskId:a}}),b.length>0&&await c.taskLabel.createMany({data:b.map(b=>({taskId:a,labelId:b}))})}),(0,d.revalidatePath)("/workspaces")}async function j(a){return(await c.db.taskLabel.findMany({where:{taskId:a},include:{label:!0}})).map(a=>a.label)}(0,a.i(630048).ensureServerEntryExports)([f,g,h,i,j]),(0,b.registerServerReference)(f,"401870399b89009a4502624938f15efc197a88ebec",null),(0,b.registerServerReference)(g,"40f571ce03adc188fe32ee860d48e55a1cf6b2a684",null),(0,b.registerServerReference)(h,"404ad1847b150ab1e558b855e3eece3b3315136889",null),(0,b.registerServerReference)(i,"60f2ad2f2ebd3461f369f7eff7cd52e082adaed75c",null),(0,b.registerServerReference)(j,"40997bc2676629966ee5b257ab6694e81c304b6ce7",null),a.s(["createLabel",0,g,"deleteLabel",0,h,"getLabelsForWorkspace",0,f,"getTaskLabels",0,j,"setTaskLabels",0,i])},287068,a=>{"use strict";var b=a.i(761469);function c(a,b){return{id:a.note_id,type:"note",title:a.title,subtitle:`${a.workspace_name} / ${a.project_name}`,navigateTo:`/workspaces/${a.workspaceId}/notes?projectId=${a.projectId}`,snippet:a.content?a.content.slice(0,b):void 0}}async function d(a,e="task",f){if(!a.trim())return[];let g=a.trim(),{resultLimit:h,allModeCap:i,snippetLength:j}=f;if("all"===e){let[a,b,c,e,h]=await Promise.allSettled([d(g,"task",f),d(g,"project",f),d(g,"repository",f),d(g,"note",f),d(g,"asset",f)]),j=a=>"fulfilled"===a.status?a.value.slice(0,i):[];return[...j(a),...j(b),...j(c),...j(e),...j(h)]}if("task"===e)return(await b.db.task.findMany({where:{OR:[{title:{contains:g}},{description:{contains:g}}]},include:{project:{include:{workspace:!0}}},take:h,orderBy:{updatedAt:"desc"}})).map(a=>{let b="DONE"===a.status||"CANCELLED"===a.status,c=a.project.workspaceId;return{id:a.id,type:"task",title:a.title,subtitle:`${a.project.workspace.name} / ${a.project.name}`,navigateTo:b?`/workspaces/${c}/archive?projectId=${a.projectId}`:`/workspaces/${c}?projectId=${a.projectId}`}});if("project"===e)return(await b.db.project.findMany({where:{OR:[{name:{contains:g}},{alias:{contains:g}},{description:{contains:g}}]},include:{workspace:!0},take:h,orderBy:{updatedAt:"desc"}})).map(a=>({id:a.id,type:"project",title:a.alias?`${a.name} (${a.alias})`:a.name,subtitle:a.workspace.name,navigateTo:`/workspaces/${a.workspaceId}?projectId=${a.id}`}));if("repository"===e)return(await b.db.repository.findMany({where:{OR:[{name:{contains:g}},{path:{contains:g}}]},include:{project:{include:{workspace:!0}}},take:h})).map(a=>({id:a.id,type:"repository",title:a.name,subtitle:`${a.project.workspace.name} / ${a.project.name} \xb7 ${a.branch}`,navigateTo:`/workspaces/${a.project.workspaceId}?projectId=${a.projectId}`}));if("note"===e){if(g.length<3)return(await b.db.$queryRawUnsafe(`SELECT n.id as note_id, n.title, n.content,
                n."projectId", p."workspaceId", p.name as project_name, w.name as workspace_name
         FROM "ProjectNote" n
         JOIN "Project" p ON p.id = n."projectId"
         JOIN "Workspace" w ON w.id = p."workspaceId"
         WHERE n.title LIKE ? OR n.content LIKE ?
         LIMIT ?`,`%${g}%`,`%${g}%`,h)).map(a=>c(a,j));try{return(await b.db.$queryRawUnsafe(`SELECT f.note_id, f.title, f.content,
                n."projectId", p."workspaceId", p.name as project_name, w.name as workspace_name
         FROM notes_fts f
         JOIN "ProjectNote" n ON n.id = f.note_id
         JOIN "Project" p ON p.id = n."projectId"
         JOIN "Workspace" w ON w.id = p."workspaceId"
         WHERE f.notes_fts MATCH ?
         ORDER BY rank
         LIMIT ?`,g,h)).map(a=>c(a,j))}catch{return(await b.db.$queryRawUnsafe(`SELECT n.id as note_id, n.title, n.content,
                n."projectId", p."workspaceId", p.name as project_name, w.name as workspace_name
         FROM "ProjectNote" n
         JOIN "Project" p ON p.id = n."projectId"
         JOIN "Workspace" w ON w.id = p."workspaceId"
         WHERE n.title LIKE ? OR n.content LIKE ?
         LIMIT ?`,`%${g}%`,`%${g}%`,h)).map(a=>c(a,j))}}return"asset"===e?(await b.db.projectAsset.findMany({where:{OR:[{filename:{contains:g}},{description:{contains:g}}]},include:{project:{include:{workspace:!0}}},take:h,orderBy:{createdAt:"desc"}})).map(a=>({id:a.id,type:"asset",title:a.filename,subtitle:`${a.project.workspace.name} / ${a.project.name}`,navigateTo:`/workspaces/${a.project.workspaceId}/assets?projectId=${a.projectId}`,snippet:a.description||void 0})):[]}a.s(["search",0,d])},396904,a=>a.a(async(b,c)=>{try{var d=a.i(815429),e=a.i(287068),f=a.i(980999),g=a.i(630048),h=b([f]);async function i(a,b="task"){let c=await (0,f.getConfigValues)(["search.resultLimit","search.allModeCap","search.snippetLength"]);return(0,e.search)(a,b,{resultLimit:c["search.resultLimit"]??20,allModeCap:c["search.allModeCap"]??5,snippetLength:c["search.snippetLength"]??80})}[f]=h.then?(await h)():h,(0,g.ensureServerEntryExports)([i]),(0,d.registerServerReference)(i,"605ee2e74b8c10c47e2334c9891fe5bdecbe23940c",null),a.s(["globalSearch",0,i]),c()}catch(a){c(a)}},!1),101844,a=>{"use strict";var b=a.i(815429),c=a.i(924868),d=a.i(522734),e=a.i(814747),f=a.i(761469),g=a.i(188139),h=a.i(630048);async function i(b){if(!b||"string"!=typeof b)return{safe:!1,reason:"无效的项目 ID"};let g=await f.db.project.findUnique({where:{id:b}});if(!g||!g.localPath)return{safe:!1,reason:"项目不存在或未设置本地路径"};if((await f.db.taskExecution.findMany({where:{task:{projectId:b},status:"RUNNING"},select:{id:!0}})).length>0)return{safe:!1,reason:"该项目有正在运行的任务执行，请先停止所有执行"};let h=await f.db.task.findMany({where:{projectId:b},select:{id:!0}}),{getSession:i}=await a.A(98813);for(let a of h)if(void 0!==i(a.id))return{safe:!1,reason:"该项目有活跃的终端会话，请先关闭"};let j=e.default.join(g.localPath,".worktrees");if((0,d.existsSync)(j))try{if((await (0,c.readdir)(j)).length>0)return{safe:!1,reason:"该项目有活跃的 Git Worktree，请先清理"}}catch{}return{safe:!0}}async function j(b,h){if(!b||"string"!=typeof b)return{success:!1,error:"无效的项目 ID"};if(!h||"string"!=typeof h||!e.default.isAbsolute(h))return{success:!1,error:"目标路径必须是非空的绝对路径"};let i=await f.db.project.findUnique({where:{id:b}});if(!i||!i.localPath)return{success:!1,error:"项目不存在或未设置本地路径"};let j=i.localPath;if(h===j)return{success:!1,error:"源路径和目标路径相同"};if((await f.db.taskExecution.findMany({where:{task:{projectId:b},status:"RUNNING"},select:{id:!0}})).length>0)return{success:!1,error:"该项目有正在运行的任务执行，请先停止所有执行"};let k=await f.db.task.findMany({where:{projectId:b},select:{id:!0}}),{getSession:l}=await a.A(98813);for(let a of k)if(void 0!==l(a.id))return{success:!1,error:"该项目有活跃的终端会话，请先关闭"};let m=e.default.join(j,".worktrees");if((0,d.existsSync)(m))try{if((await (0,c.readdir)(m)).length>0)return{success:!1,error:"该项目有活跃的 Git Worktree，请先清理"}}catch{}if((0,d.existsSync)(h))try{if((await (0,c.readdir)(h)).length>0)return{success:!1,error:"目标路径已存在且不为空"}}catch{return{success:!1,error:"目标路径已存在且不为空"}}let n=e.default.dirname(h);try{await (0,c.mkdir)(n,{recursive:!0})}catch(a){if("EACCES"===a.code||"EPERM"===a.code)return{success:!1,error:`无权限创建父目录 ${n} — 请检查 Git 路径映射规则的模板是否漏了 "~/" 前缀`};if("EROFS"===a.code)return{success:!1,error:`父目录所在文件系统只读：${n}`};return{success:!1,error:`创建父目录失败：${a.message||a.code||"未知错误"}`}}try{await (0,c.rename)(j,h)}catch(a){if("EXDEV"===a.code)return{success:!1,error:"源路径和目标路径不在同一文件系统，不支持跨设备迁移"};if("EACCES"===a.code||"EPERM"===a.code)return{success:!1,error:`无权限移动到 ${h}`};return{success:!1,error:a.message||"文件系统操作失败"}}return await f.db.project.update({where:{id:b},data:{localPath:h}}),(0,g.revalidatePath)("/workspaces"),{success:!0}}let k=`分析这个项目目录，生成一段简短的 Markdown 项目描述。

读取 package.json、README.md 等关键文件，然后概括：

**技术栈：** 一句话列出主要语言、框架、关键库
**定位：** 一句话说明项目是什么
**核心模块：** 2-3 个关键模块，每个一句话

要求：
- 总字数不超过 500 字
- 用简洁的 Markdown（加粗标签 + 短句），不要用 ## 大标题和表格
- 不要罗列每个文件/目录，只说关键信息
- 中文输出`,l=`Analyze this project directory and generate a brief Markdown project description.

Read package.json, README.md and other key files, then summarize:

**Tech Stack:** One sentence listing primary languages, frameworks, and key libraries
**Overview:** One sentence describing what this project is
**Core Modules:** 2-3 key modules, one sentence each

Requirements:
- Keep it under 1000 words
- Use concise Markdown (bold labels + short sentences), no ## headings or tables
- Don't list every file/directory, only key information
- Output in English`;async function m(b,c="zh"){if(!b||"string"!=typeof b)throw Error("无效的本地路径");if(b.startsWith("~"))throw Error("不支持 ~ 别名，请提供绝对路径");if(!e.default.isAbsolute(b))throw Error("本地路径必须为绝对路径");let{aiQuery:d}=await a.A(752453),f=await d("en"===c?l:k,b,{maxTurns:10,tools:["Read","Glob"],allowedTools:["Read","Glob"]});if(!f)throw Error("AI 分析未返回结果");return f.length>2e3?f.slice(0,2e3).trimEnd()+"\n\n...":f}(0,h.ensureServerEntryExports)([i,j,m]),(0,b.registerServerReference)(i,"404dcaf1dc95afc391344bd6d4c7d9daeda04835cd",null),(0,b.registerServerReference)(j,"604088b38ae055299d29dd4fe5af2eb8395b2b3d5f",null),(0,b.registerServerReference)(m,"60b1e9d8d102c97c9e03b5924b5744c3be4e5744e3",null),a.s(["analyzeProjectDirectory",0,m,"checkMigrationSafety",0,i,"migrateProjectPath",0,j])},52350,562278,a=>{"use strict";var b=a.i(902157),c=a.i(660526),d=a.i(750227),e=a.i(163812);function f(){return process.env.TOWER_PACKAGE_ROOT||process.cwd()}a.s(["getPackageRoot",0,f],562278);let g=["sonnet","opus","haiku","claude-sonnet-4-6","claude-opus-4-6","claude-haiku-4-5-20251001"];a.s(["ClaudeCliAdapter",0,class{buildSpawnArgs(a){let b=["--dangerously-skip-permissions"];a.extraArgs?.length&&b.push(...a.extraArgs),a.resumeSessionId?b.push("--resume",a.resumeSessionId):a.continueLatest?b.push("--continue"):a.prompt&&b.push(a.prompt);let c={...a.envOverrides??{}};return{command:this.resolveCommand(),args:b,env:c}}buildEnvOverrides(a){let b={TOWER_TASK_ID:a.taskId,TOWER_TASK_TITLE:a.taskTitle,TOWER_STARTED_AT:new Date().toISOString(),TOWER_API_URL:a.apiUrl};return a.callbackUrl&&(b.CALLBACK_URL=a.callbackUrl),b}async installHooks(a){try{let a=this.readSettings(),b=a.hooks??{},c=f().replace(/\\/g,"/"),e=d.join(c,"scripts","session-start-hook.js").replace(/\\/g,"/"),g=d.join(c,"scripts","post-tool-hook.js").replace(/\\/g,"/"),h=d.join(c,"scripts","stop-hook.js").replace(/\\/g,"/"),i=!1;return i=this.upsertHook(b,"SessionStart","session-start-hook.js",{hooks:[{command:`node "${e}"`,timeout:5,type:"command"}]})||i,i=this.upsertHook(b,"PostToolUse","post-tool-hook.js",{hooks:[{command:`node "${g}"`,timeout:10,type:"command"}],matcher:"Write|Edit|MultiEdit"})||i,(i=this.upsertHook(b,"Stop","stop-hook.js",{hooks:[{command:`node "${h}"`,timeout:5,type:"command"}]})||i)&&(a.hooks=b,this.writeSettings(a)),{ok:!0,method:"file",detail:this.getSettingsPath()}}catch(a){return{ok:!1,method:"file",detail:this.getSettingsPath(),error:a instanceof Error?a.message:String(a)}}}async repairHookPaths(){try{let a=this.readSettings(),b=a.hooks??{},c=f().replace(/\\/g,"/"),e=!1;for(let[a,f]of[["SessionStart","session-start-hook.js"],["PostToolUse","post-tool-hook.js"],["Stop","stop-hook.js"]]){let g=this.getHookArray(b,a),h=g.findIndex(a=>a?.hooks?.some?.(a=>a.command?.includes(f)));if(h<0)continue;let i=d.join(c,"scripts",f).replace(/\\/g,"/"),j=`node "${i}"`,k=g[h]?.hooks?.[0];k&&k.command!==j&&(k.command=j,b[a]=g,e=!0)}e&&(a.hooks=b,this.writeSettings(a))}catch{}}upsertHook(a,b,c,d){let e=this.getHookArray(a,b),f=d?.hooks?.[0]?.command,g=e.findIndex(a=>a?.hooks?.some?.(a=>a.command?.includes(c)));if(g>=0){if(e[g]?.hooks?.[0]?.command===f)return!1;e.splice(g,1)}return e.push(d),a[b]=e,!0}async uninstallHooks(){try{let a=this.readSettings(),b=a.hooks??{},c=["session-start-hook.js","post-tool-hook.js","stop-hook.js"];for(let a of["SessionStart","PostToolUse","Stop"]){let d=this.getHookArray(b,a);b[a]=d.filter(a=>!a.hooks?.some(a=>c.some(b=>a.command?.includes(b))))}return a.hooks=b,this.writeSettings(a),{ok:!0,method:"file",detail:this.getSettingsPath()}}catch(a){return{ok:!1,method:"file",detail:this.getSettingsPath(),error:a instanceof Error?a.message:String(a)}}}async isHooksInstalled(){let a=this.readSettings().hooks??{},b=this.getHookArray(a,"PostToolUse");return this.hasHook(b,"post-tool-hook.js")}async installMcp(a,b={}){let c=b.scope??"user",d={command:a.command,args:a.args};a.env&&Object.keys(a.env).length>0&&(d.env=a.env);let e=this.resolveCommand(),f=["mcp","add-json","-s",c,a.name,JSON.stringify(d)];try{return await this.runCli(e,["mcp","remove","-s",c,a.name],b.cwd).catch(()=>{}),await this.runCli(e,f,b.cwd),{ok:!0,method:"cli",detail:`${e} ${f.join(" ")}`}}catch(a){return{ok:!1,method:"cli",detail:`${e} ${f.join(" ")}`,error:a instanceof Error?a.message:String(a)}}}async uninstallMcp(a,b={}){let c=b.scope??"user",d=this.resolveCommand(),e=["mcp","remove","-s",c,a];try{return await this.runCli(d,e,b.cwd),{ok:!0,method:"cli",detail:`${d} ${e.join(" ")}`}}catch(a){return{ok:!1,method:"cli",detail:`${d} ${e.join(" ")}`,error:a instanceof Error?a.message:String(a)}}}async isMcpInstalled(a,b={}){let c=this.resolveCommand();try{return await this.runCli(c,["mcp","get",a],b.cwd,5e3),!0}catch{return!1}}async installSkill(a,c){let e=d.join(this.getConfigDir(),"skills",a);try{if(!b.existsSync(c))return{ok:!1,method:"symlink",detail:e,error:`Source skill dir does not exist: ${c}`};b.mkdirSync(d.dirname(e),{recursive:!0});let a=await b.promises.lstat(e).catch(()=>null);if(a)if(!(a.isSymbolicLink()||"win32"===process.platform&&a.isDirectory()))return{ok:!1,method:"symlink",detail:e,error:`Refusing to overwrite non-symlink at ${e}`};else try{let a=await b.promises.readlink(e);if(d.resolve(a)===d.resolve(c))return{ok:!0,method:"symlink",detail:`${e} → ${c} (already)`};await b.promises.unlink(e)}catch{if(!a.isSymbolicLink())return{ok:!1,method:"symlink",detail:e,error:`Refusing to overwrite non-symlink at ${e}`}}return await b.promises.symlink(c,e,"dir"),{ok:!0,method:"symlink",detail:`${e} → ${c}`}}catch(a){return{ok:!1,method:"symlink",detail:e,error:a instanceof Error?a.message:String(a)}}}async uninstallSkill(a){let c=d.join(this.getConfigDir(),"skills",a);try{let a=await b.promises.lstat(c).catch(()=>null);if(!a)return{ok:!0,method:"symlink",detail:`${c} (already absent)`};if(!a.isSymbolicLink())return{ok:!1,method:"symlink",detail:c,error:`Refusing to remove non-symlink at ${c}`};return await b.promises.unlink(c),{ok:!0,method:"symlink",detail:c}}catch(a){return{ok:!1,method:"symlink",detail:c,error:a instanceof Error?a.message:String(a)}}}async isSkillInstalled(a,c){let e=d.join(this.getConfigDir(),"skills",a);try{if(!(await b.promises.lstat(e)).isSymbolicLink())return!1;if(!c)return!0;let a=await b.promises.readlink(e),f=d.isAbsolute(a)?a:d.resolve(d.dirname(e),a);return d.resolve(f)===d.resolve(c)}catch{return!1}}async runCli(b,c,d,e=1e4){let{execFile:f}=await a.A(482848),{promisify:g}=await a.A(268548),h=g(f),{stdout:i}=await h(b,c,{cwd:d,timeout:e});return i}async isAvailable(){return null!==await this.getVersion()}async getVersion(){try{let{execFile:b}=await a.A(144264),{promisify:c}=await a.A(534777),{resolveSpawnTarget:d}=await a.A(889618),e=c(b),f=await d(this.resolveCommand(),["--version"]),{stdout:g}=await e(f.command,f.args,{timeout:5e3});return g.trim()||null}catch{return null}}async getModels(){return g}getConfigDir(){return d.join(c.homedir(),".claude")}getSettingsPath(){return d.join(this.getConfigDir(),"settings.json")}getSessionsDir(){return d.join(this.getConfigDir(),"projects")}getApiKeyInfo(){return{envVar:"ANTHROPIC_API_KEY",required:!1}}buildHelloProbeArgs(a){return{command:this.resolveCommand(),args:["--print",a,"--output-format","stream-json","--verbose"]}}resolveCommand(){return process.env.CLAUDE_CODE_PATH?process.env.CLAUDE_CODE_PATH:(0,e.resolveCommandPathSync)("claude")}readSettings(){try{return JSON.parse(b.readFileSync(this.getSettingsPath(),"utf-8"))}catch{return{}}}writeSettings(a){let c=this.getConfigDir();b.existsSync(c)||b.mkdirSync(c,{recursive:!0}),b.writeFileSync(this.getSettingsPath(),JSON.stringify(a,null,2),"utf-8")}getHookArray(a,b){let c=a[b];return Array.isArray(c)?c:[]}hasHook(a,b){return a.some(a=>a.hooks?.some(a=>a.command?.includes(b)))}}],52350)},196195,a=>{"use strict";var b=a.i(815429),c=a.i(233405),d=a.i(814747),e=a.i(446786);function f(a){return a.startsWith("~/")||"~"===a?d.default.join(e.default.homedir(),a.slice(1)):a}async function g(a){if(!a?.trim())return null;let b=d.default.resolve(f(a));try{return(0,c.execSync)("git rev-parse --abbrev-ref HEAD",{cwd:b,encoding:"utf-8",timeout:5e3}).trim()}catch{return null}}async function h(a){if(!a?.trim())return[];let b=d.default.resolve(f(a));try{let a,d;return a=new Set((0,c.execSync)("git branch --format='%(refname:short)'",{cwd:b,encoding:"utf-8",timeout:5e3}).trim().split("\n").filter(Boolean).map(a=>a.replace(/'/g,""))),d=(0,c.execSync)("git branch -r --format='%(refname:short)'",{cwd:b,encoding:"utf-8",timeout:5e3}).trim().split("\n").filter(Boolean).map(a=>a.replace(/'/g,"").replace(/^origin\//,"")).filter(b=>"HEAD"!==b&&!a.has(b)),[...a,...d]}catch{return[]}}async function i(a){if(!a?.trim())return;let b=d.default.resolve(f(a));try{(0,c.spawn)("git",["fetch","--prune"],{cwd:b,stdio:"ignore",detached:!0}).unref()}catch{}}(0,a.i(630048).ensureServerEntryExports)([g,h,i]),(0,b.registerServerReference)(g,"40bb845be3488b537749ce5903c8274735813d497e",null),(0,b.registerServerReference)(h,"401a31f33236fc2c607cdadafa503c1cb1e6fb3d20",null),(0,b.registerServerReference)(i,"40f194623f7775e9cf69a06393bc11e0dedad5ef16",null),a.s(["fetchRemoteBranches",0,i,"getCurrentBranch",0,g,"getProjectBranches",0,h])},925886,a=>{"use strict";var b=a.i(815429),c=a.i(761469),d=a.i(188139);async function e(a){return c.db.agentPrompt.findMany({where:a?{OR:[{workspaceId:a},{workspaceId:null}]}:{},orderBy:[{isDefault:"desc"},{name:"asc"}]})}async function f(a){return c.db.agentPrompt.findUnique({where:{id:a}})}async function g(a){if(a.content.length>1e5)throw Error("Prompt content exceeds maximum length of 100000 characters");let b=await c.db.agentPrompt.create({data:a});return(0,d.revalidatePath)("/workspaces"),(0,d.revalidatePath)("/settings"),b}async function h(a,b){if(void 0!==b.content&&b.content.length>1e5)throw Error("Prompt content exceeds maximum length of 100000 characters");let e=await c.db.agentPrompt.update({where:{id:a},data:b});return(0,d.revalidatePath)("/workspaces"),(0,d.revalidatePath)("/settings"),e}async function i(a){await c.db.agentPrompt.delete({where:{id:a}}),(0,d.revalidatePath)("/workspaces"),(0,d.revalidatePath)("/settings")}async function j(a,b){let e=await c.db.$transaction(async c=>(await c.agentPrompt.updateMany({where:b?{workspaceId:b,isDefault:!0}:{isDefault:!0},data:{isDefault:!1}}),c.agentPrompt.update({where:{id:a},data:{isDefault:!0}})));return(0,d.revalidatePath)("/workspaces"),(0,d.revalidatePath)("/settings"),e}(0,a.i(630048).ensureServerEntryExports)([e,f,g,h,i,j]),(0,b.registerServerReference)(e,"40ddcc435901faf48a2bf57bd435ad194387f4a497",null),(0,b.registerServerReference)(f,"40784642e225b060d507983980ad07385ba097ada0",null),(0,b.registerServerReference)(g,"403f3f7b7f15b0bf196ba3240c5fd4c3caf6a62d7d",null),(0,b.registerServerReference)(h,"609dd502e132f5174368d89228c7648f1203c2cc75",null),(0,b.registerServerReference)(i,"40b8daa5d11160670f0c3882e6bc355a7beac75f2b",null),(0,b.registerServerReference)(j,"605dc028fb65169f36b130e5321e525e8bff5b3266",null),a.s(["createPrompt",0,g,"deletePrompt",0,i,"getPrompts",0,e,"setDefaultPrompt",0,j,"updatePrompt",0,h])},835032,a=>{"use strict";async function b(a,b){await a.$executeRawUnsafe("DELETE FROM notes_fts WHERE note_id = ?",b.id),await a.$executeRawUnsafe("INSERT INTO notes_fts(note_id, title, content) VALUES (?, ?, ?)",b.id,b.title,b.content)}async function c(a,b){await a.$executeRawUnsafe("DELETE FROM notes_fts WHERE note_id = ?",b)}a.s(["deleteNoteFromFts",0,c,"syncNoteToFts",0,b])},392164,a=>{"use strict";var b=a.i(815429),c=a.i(75681),d=a.i(761469),e=a.i(188139),f=a.i(835032),g=a.i(630048);let h=c.z.object({title:c.z.string().min(1).max(200),content:c.z.string(),category:c.z.string().max(50).optional(),projectId:c.z.string().min(1),taskId:c.z.string().optional()}),i=c.z.object({title:c.z.string().min(1).max(200).optional(),content:c.z.string().optional(),category:c.z.string().max(50).optional()});async function j(a){let b=h.parse(a),c=await d.db.projectNote.create({data:{title:b.title,content:b.content,category:b.category??"备忘",projectId:b.projectId,taskId:b.taskId??null}});return await (0,f.syncNoteToFts)(d.db,{id:c.id,title:c.title,content:c.content}),(0,e.revalidatePath)("/workspace"),c}async function k(a,b){let c=i.parse(b),g=await d.db.projectNote.update({where:{id:a},data:c});return await (0,f.syncNoteToFts)(d.db,{id:g.id,title:g.title,content:g.content}),(0,e.revalidatePath)("/workspace"),g}async function l(a){await (0,f.deleteNoteFromFts)(d.db,a),await d.db.projectNote.delete({where:{id:a}}),(0,e.revalidatePath)("/workspace")}async function m(a){return d.db.projectNote.findUnique({where:{id:a}})}async function n(a,b){return d.db.projectNote.findMany({where:{projectId:a,taskId:null,...b?.category?{category:b.category}:{}},orderBy:[{updatedAt:"desc"},{id:"desc"}]})}async function o(a){return d.db.projectNote.findMany({where:{taskId:a},orderBy:[{updatedAt:"desc"},{id:"desc"}]})}(0,g.ensureServerEntryExports)([j,k,l,m,n,o]),(0,b.registerServerReference)(j,"402d73607318b2b1825b326e9d626c7ad65bf4e919",null),(0,b.registerServerReference)(k,"6051f18beb12112ccea6dba4903abf2c6f0e8f61f8",null),(0,b.registerServerReference)(l,"4061b5de7c68b5a524c0488434a920b12b3cd145ea",null),(0,b.registerServerReference)(m,"40cac3c475a5843feb9a43d3f3d477ea3585c992a8",null),(0,b.registerServerReference)(n,"60a8a64637923855f494a4860d21deb1513fba3fe5",null),(0,b.registerServerReference)(o,"4003a6d574d9f373c55d94ccf731f0012b5d2a4583",null),a.s(["createNote",0,j,"deleteNote",0,l,"getNoteById",0,m,"getProjectNotes",0,n,"getTaskNotes",0,o,"updateNote",0,k])},748383,a=>{"use strict";var b=a.i(815429),c=a.i(761469),d=a.i(188139),e=a.i(496877),f=a.i(233405);function g(a,b){if(!b||b.startsWith("-"))return null;try{return(0,f.execFileSync)("git",["rev-parse",b],{cwd:a,encoding:"utf-8",timeout:5e3}).trim()||null}catch(a){return null}}async function h(a){return c.db.version.findMany({where:{projectId:a},orderBy:[{targetDate:"desc"},{order:"desc"},{createdAt:"desc"}],include:{type:!0,tasks:{orderBy:[{order:"asc"},{createdAt:"desc"}],include:{labels:{include:{label:!0}},assets:{select:{id:!0,filename:!0,mimeType:!0,size:!0}},notes:{select:{id:!0,title:!0,category:!0}}}}}})}async function i(a){let b=e.createVersionSchema.parse(a),f=null;if(b.baseBranch){let a=await c.db.project.findUnique({where:{id:b.projectId},select:{localPath:!0}});a?.localPath&&(f=g(a.localPath,b.baseBranch))}let h=await c.db.version.create({data:{projectId:b.projectId,number:b.number,name:b.name,typeId:b.typeId??null,status:"PLANNED",baseBranch:b.baseBranch??null,baseCommit:f,startDate:b.startDate??null,targetDate:b.targetDate??null,description:b.description??null}});return b.setCurrent&&await q(h.id),(0,d.revalidatePath)("/workspaces"),h}async function j(a,b){let f=e.updateVersionSchema.parse(b);try{let b=await c.db.version.update({where:{id:a},data:f});return(0,d.revalidatePath)("/workspaces"),b}catch(a){if("object"==typeof a&&a&&"code"in a&&"P2025"===a.code)throw Error("版本不存在");throw a}}async function k(a){try{await c.db.version.delete({where:{id:a}})}catch(a){if("object"==typeof a&&a&&"code"in a&&"P2025"===a.code)throw Error("版本不存在");throw a}(0,d.revalidatePath)("/workspaces")}async function l(a,b){await c.db.task.updateMany({where:{id:a},data:{versionId:b}}),(0,d.revalidatePath)("/workspaces")}async function m(a,b){let e=await c.db.version.findUnique({where:{id:a},select:{id:!0,projectId:!0,status:!0,baseBranch:!0,project:{select:{localPath:!0}}}});if(!e)throw Error("版本不存在");if("RELEASED"===e.status)throw Error("该版本已发布");let f=null;e.baseBranch&&e.project?.localPath&&(f=g(e.project.localPath,e.baseBranch));let h=await c.db.version.findUnique({where:{id:b},select:{id:!0,projectId:!0,status:!0}});if(!h)throw Error("目标版本不存在");if(h.projectId!==e.projectId)throw Error("目标版本必须属于同一项目");if(h.id===a)throw Error("目标版本不能是正在发布的版本本身");if("RELEASED"===h.status)throw Error("目标版本已发布，不能作为下一个当前版本");await c.db.$transaction(async c=>{await c.version.update({where:{id:a},data:{status:"RELEASED",releasedAt:new Date,releaseCommit:f,isCurrent:!1}}),await c.task.updateMany({where:{versionId:a,status:{notIn:["DONE","CANCELLED"]}},data:{versionId:b}}),await c.version.updateMany({where:{projectId:e.projectId,isCurrent:!0},data:{isCurrent:!1}}),await c.version.update({where:{id:b},data:{isCurrent:!0,status:"ACTIVE"}})}),(0,d.revalidatePath)("/workspaces")}async function n(a){return c.db.version.findMany({where:{projectId:a,status:{not:"RELEASED"}},select:{id:!0,number:!0,name:!0,isCurrent:!0,status:!0},orderBy:[{isCurrent:"desc"},{targetDate:"desc"},{createdAt:"desc"}]})}async function o(a){let b=await c.db.version.findUnique({where:{id:a},select:{baseCommit:!0,releaseCommit:!0,baseBranch:!0,project:{select:{localPath:!0}}}});if(!b?.baseCommit||!b.project?.localPath)return null;let d=b.releaseCommit??(b.baseBranch?g(b.project.localPath,b.baseBranch):null);return d?function(a,b,c){try{let d=(0,f.execFileSync)("git",["diff","--numstat",`${b}..${c}`],{cwd:a,encoding:"utf-8",timeout:5e3}),e=0,g=0,h=0;for(let a of d.split("\n")){let b=a.trim();if(!b)continue;let[c,d]=b.split("	");e+=Number.parseInt(c,10)||0,g+=Number.parseInt(d,10)||0,h+=1}return{additions:e,deletions:g,files:h}}catch(a){return{additions:0,deletions:0,files:0}}}(b.project.localPath,b.baseCommit,d):null}async function p(a){let b=await c.db.version.findUnique({where:{id:a},select:{baseCommit:!0,releaseCommit:!0,baseBranch:!0,project:{select:{localPath:!0}}}});if(!b?.baseCommit||!b.project?.localPath)return null;let d=b.releaseCommit??(b.baseBranch?g(b.project.localPath,b.baseBranch):null);return d?{patch:function(a,b,c){try{return(0,f.execFileSync)("git",["diff",`${b}..${c}`],{cwd:a,encoding:"utf-8",timeout:15e3,maxBuffer:0x1400000})}catch(a){return""}}(b.project.localPath,b.baseCommit,d)}:null}async function q(a){let b=await c.db.version.findUnique({where:{id:a},select:{id:!0,projectId:!0}});if(!b)throw Error("版本不存在");await c.db.$transaction(async c=>{await c.version.updateMany({where:{projectId:b.projectId,isCurrent:!0},data:{isCurrent:!1}}),await c.version.update({where:{id:a},data:{isCurrent:!0,status:"ACTIVE"}})}),(0,d.revalidatePath)("/workspaces")}(0,a.i(630048).ensureServerEntryExports)([h,i,j,k,l,m,n,o,p,q]),(0,b.registerServerReference)(h,"4010541daba6184ef38e818a97c0f77fd6c3303a0f",null),(0,b.registerServerReference)(i,"4016567d1f043b8140165abda16ab493d4582b6234",null),(0,b.registerServerReference)(j,"60e767f5f919ba14399666a56333e2fc4aaad47d31",null),(0,b.registerServerReference)(k,"4083f21e3f81c7e84dccc658f58833904573a214fd",null),(0,b.registerServerReference)(l,"6033c05e69b77a5ecf9c80c35d1df27618bc95084f",null),(0,b.registerServerReference)(m,"604f081e6c4fffd9adc083598480edb837cd19b9bb",null),(0,b.registerServerReference)(n,"408fa13a43876365dca2d1770e4b1adbfe5eeaac74",null),(0,b.registerServerReference)(o,"400e3578153c7efe89135edc07da0d4e0f6208b90f",null),(0,b.registerServerReference)(p,"40f2280ff69fa36c03f6e989a78e8023a138ab01b3",null),(0,b.registerServerReference)(q,"40951ab9df7f1ec00cb14c83bbcfed64ff864c3c9b",null),a.s(["assignTaskVersion",0,l,"createVersion",0,i,"deleteVersion",0,k,"getProjectVersions",0,h,"getVersionDiff",0,p,"getVersionDiffStat",0,o,"getVersionsForPicker",0,n,"releaseVersion",0,m,"setCurrentVersion",0,q,"updateVersion",0,j],748383)},859071,a=>{"use strict";a.i(666680);var b=a.i(902157),c=a.i(750227),d=a.i(319997);a.s(["ensureAssetsDir",0,function(a){let e=function(a){let b=c.join((0,d.getStorageDir)(),"assets",a);if(!b.startsWith((0,d.getStorageDir)()+c.sep))throw Error("Path traversal detected");return b}(a);return b.mkdirSync(e,{recursive:!0}),e}])},97397,a=>a.a(async(b,c)=>{try{var d=a.i(815429),e=a.i(902157),f=a.i(750227),g=a.i(75681),h=a.i(761469),i=a.i(188139),j=a.i(859071),k=a.i(980999),l=a.i(630048),m=b([k]);[k]=m.then?(await m)():m;let t=g.z.object({filename:g.z.string().min(1).max(255),path:g.z.string().min(1),mimeType:g.z.string().max(100).optional(),size:g.z.number().int().nonnegative().optional(),projectId:g.z.string().min(1),description:g.z.string().max(500).optional(),taskId:g.z.string().optional()});async function n(a){let b=t.parse(a);(0,j.ensureAssetsDir)(b.projectId);let c=await h.db.projectAsset.create({data:{...b,taskId:b.taskId??null}});return(0,i.revalidatePath)("/workspaces"),c}async function o(a){let b=await h.db.projectAsset.findUnique({where:{id:a}});b?.path&&await e.promises.unlink(b.path).catch(()=>{}),await h.db.projectAsset.delete({where:{id:a}}),(0,i.revalidatePath)("/workspaces")}async function p(a){return h.db.projectAsset.findMany({where:{projectId:a},orderBy:{createdAt:"desc"},include:{task:{select:{id:!0,title:!0,status:!0,priority:!0,description:!0,createdAt:!0,labels:{include:{label:!0}},executions:{orderBy:{createdAt:"desc"},take:1,select:{summary:!0,status:!0,endedAt:!0}},_count:{select:{assets:!0}}}}}})}async function q(a){return h.db.projectAsset.findMany({where:{taskId:a},orderBy:{createdAt:"desc"}})}async function r(a){return h.db.projectAsset.findUnique({where:{id:a}})}async function s(a){let b=a.get("file"),c=a.get("projectId"),d=a.get("taskId")||void 0;if(!b||!c)throw Error("Missing file or projectId");let g=await (0,k.getConfigValue)("system.maxUploadBytes",0x3200000);if(b.size>g)throw Error(`File too large (max ${Math.round(g/1024/1024)} MB)`);let l=a.get("description")??"";if(!await h.db.project.findUnique({where:{id:c}}))throw Error("Invalid projectId");let m=Buffer.from(await b.arrayBuffer()),o=(0,j.ensureAssetsDir)(c),p=f.basename(b.name);p&&"."!==p&&".."!==p||(p=`upload-${Date.now()}`);let q=f.join(o,p);if(e.existsSync(q)){let a=f.extname(p),b=f.basename(p,a);p=`${b}-${Date.now()}${a}`}let r=f.join(o,p);if(!r.startsWith(o))throw Error("Invalid filename");await e.promises.writeFile(r,m);let s=await n({filename:p,path:r,mimeType:b.type||void 0,size:b.size,projectId:c,description:l||void 0,taskId:d});return(0,i.revalidatePath)("/workspaces"),s}(0,l.ensureServerEntryExports)([n,o,p,q,r,s]),(0,d.registerServerReference)(n,"40a9fc886bbc4785710d8ad2cdb2ea5b8f645a7f50",null),(0,d.registerServerReference)(o,"407e55df617138fbfecc54ee85adf946cfd20d91de",null),(0,d.registerServerReference)(p,"402f4fde0d1ad2df0ce6bcd69ba957c9c0c9eda802",null),(0,d.registerServerReference)(q,"40b6a2f1f07f2adcf3dbe3460b438699bf2223929e",null),(0,d.registerServerReference)(r,"401ad3aa8989aa22f1642ac0e513631c951719c3a9",null),(0,d.registerServerReference)(s,"409c7af9f3a775c32f9d8c3e38938c3df1dbf49a12",null),a.s(["createAsset",0,n,"deleteAsset",0,o,"getAssetById",0,r,"getProjectAssets",0,p,"getTaskAssets",0,q,"uploadAsset",0,s]),c()}catch(a){c(a)}},!1),408835,a=>a.a(async(b,c)=>{try{a.i(244256),a.i(495370);var d=a.i(396904),e=a.i(980999);a.i(101844),a.i(563736),a.i(4634),a.i(196195),a.i(536960),a.i(347427),a.i(689171),a.i(925886),a.i(392164);var f=a.i(97397);a.i(748383);var g=b([d,e,f]);[d,e,f]=g.then?(await g)():g,a.s([]),c()}catch(a){c(a)}},!1),590656,a=>a.a(async(b,c)=>{try{var d=a.i(408835),e=a.i(244256),f=a.i(495370),g=a.i(396904),h=a.i(980999),i=a.i(101844),j=a.i(563736),k=a.i(4634),l=a.i(196195),m=a.i(536960),n=a.i(347427),o=a.i(689171),p=a.i(925886),q=a.i(392164),r=a.i(97397),s=a.i(748383),t=b([d,g,h,r]);[d,g,h,r]=t.then?(await t)():t,a.s(["0008e048c31e099f5b0ff42ce909dfb635d13d86c4",()=>j.listAllExtensionStatus,"001f9f5f09a8ec4af5306467a95b9a884f1bd15610",()=>h.getActualWsPort,"00312df80b3c8208578a8b18cd0fa599e94ffdee48",()=>k.getOnboardingStatus,"4003a6d574d9f373c55d94ccf731f0012b5d2a4583",()=>q.getTaskNotes,"4003af4db97554807eaae82a1c1bfc1d44ee57c3f4",()=>e.deleteWorkspace,"40040f4fb9834d8b51a904ea8a6dc164a28474719d",()=>o.deleteTask,"4008d5df4a813b5da80654743c06cb9afd012aa47e",()=>j.installExtension,"400b85788c94fdf13b91ebd07c6b0c654b4639bd26",()=>m.openInTerminal,"401870399b89009a4502624938f15efc197a88ebec",()=>f.getLabelsForWorkspace,"40195180d5a2c9c2a056dd1ac9e6f01864b2897663",()=>k.dispatchTaskCompletionEvent,"401a31f33236fc2c607cdadafa503c1cb1e6fb3d20",()=>l.getProjectBranches,"40263d9083d759e6c0f7b43b32a9046b7104f50c87",()=>e.getRecentLocalProjects,"402d73607318b2b1825b326e9d626c7ad65bf4e919",()=>q.createNote,"4038c3cd963773f4277d255977443a81bf8f9f721e",()=>n.stopPtyExecution,"4047e75f6b563a057a25b3703e0157987da7ddef47",()=>o.checkWorktreeClean,"4048b6c9c8b9568f3f3e3221907e0b72c9133bdf3f",()=>j.uninstallExtension,"404ad1847b150ab1e558b855e3eece3b3315136889",()=>f.deleteLabel,"404da9d668d485be7c807d52a1cc6eaab6f32f7452",()=>o.createTask,"404dcaf1dc95afc391344bd6d4c7d9daeda04835cd",()=>i.checkMigrationSafety,"405a20394c27e462fbd04a26f4fa7c4ac51a0641cb",()=>n.getTaskExecutions,"405c786dfbbfbf2a43f72fc2209c040139c3e86a2a",()=>n.continueLatestPtyExecution,"4061b5de7c68b5a524c0488434a920b12b3cd145ea",()=>q.deleteNote,"406cdf547b9a5e97bd6adcfb5388440a2ea4d9a582",()=>e.createProject,"407dd144dadc927c501a20a311504bf49531c43078",()=>e.getOrCreateTowerTaskId,"407e55df617138fbfecc54ee85adf946cfd20d91de",()=>r.deleteAsset,"408c17cfecd963a980c178b4da5d44d388638100bd",()=>m.openInFileManager,"408fa13a43876365dca2d1770e4b1adbfe5eeaac74",()=>s.getVersionsForPicker,"4098a2e12f3bf84cda1b91fe6b63e5cd2f57a431c5",()=>h.getConfigValues,"40997bc2676629966ee5b257ab6694e81c304b6ce7",()=>f.getTaskLabels,"409c7af9f3a775c32f9d8c3e38938c3df1dbf49a12",()=>r.uploadAsset,"409fde2335dd72a0cc5f9fc4007807c90cf84ac587",()=>e.createWorkspace,"40ad6d9d9fc9f4271dc88f0a6f0ce0b998e9c1942a",()=>e.deleteProject,"40b6a2f1f07f2adcf3dbe3460b438699bf2223929e",()=>r.getTaskAssets,"40b7fbed759b8e664404cd676bc0471a8998532582",()=>k.setOnboardingProgress,"40bb845be3488b537749ce5903c8274735813d497e",()=>l.getCurrentBranch,"40c3ea6bef09de01a9e170315978f773338ae5cd08",()=>h.resolveGitLocalPath,"40cb4a6bb2aa8c3f18f26548a6a34c458196c45e81",()=>m.openInEditor,"40cf7c74a26a6b79d2db9f4952e321ba9ac217b7a0",()=>j.checkExtension,"40ddcc435901faf48a2bf57bd435ad194387f4a497",()=>p.getPrompts,"40eb42cee81987cdd889d4207810747489aa4ba222",()=>o.toggleTaskPinned,"40edef7a4c404a6cdd5a19f7e0ceca3abb693d1de4",()=>e.reorderWorkspaces,"40f194623f7775e9cf69a06393bc11e0dedad5ef16",()=>l.fetchRemoteBranches,"40f571ce03adc188fe32ee860d48e55a1cf6b2a684",()=>f.createLabel,"602b826b85b8bad56bcfd2c11aa0feb221cbdb4baa",()=>o.commitWorktreeChanges,"602ebb4afa308d031087f196c68af4b48c2c328910",()=>k.completeOnboarding,"604088b38ae055299d29dd4fe5af2eb8395b2b3d5f",()=>i.migrateProjectPath,"605ee2e74b8c10c47e2334c9891fe5bdecbe23940c",()=>g.globalSearch,"607a5fed773e92b7a633af89e870e87936de01057c",()=>h.setConfigValue,"60831f735faffaad311a7d171059867d5f617d013c",()=>e.updateWorkspace,"60833fa33531c02f00a1f5248eb271eabd3b1a0e25",()=>k.setOnboardingExtensions,"609ac8f0624cd6a8c30fb3077c4e46c8a57a589770",()=>h.getConfigValue,"609b9e6c7f4dca6892b28606deea0354cef7c0317c",()=>n.resumePtyExecution,"60a8b260c2dc2ba3ac88d62911a4d42430eca3c5f5",()=>o.updateTask,"60b1e9d8d102c97c9e03b5924b5744c3be4e5744e3",()=>i.analyzeProjectDirectory,"60e5bd011dc6a4e5a4e590212faf0b52070559e282",()=>e.updateProject,"60f2ad2f2ebd3461f369f7eff7cd52e082adaed75c",()=>f.setTaskLabels,"60f659e004fb16c8a128b886533dd5575184a09662",()=>o.updateTaskStatus,"7c8e51fe07ebab6fd60b08e0c47c7a8de499b4fb6d",()=>n.startPtyExecution,"7ccd4d36482371edd9ad1f9ad226f12625b995dbd6",()=>n.startPtyExecutionSafe]),c()}catch(a){c(a)}},!1),76052,a=>{a.v(b=>Promise.all(["server/chunks/ssr/src_lib_0yvdojq._.js"].map(b=>a.l(b))).then(()=>b(492067)))},98813,a=>{a.v(a=>Promise.resolve().then(()=>a(962620)))},507502,a=>{a.v(a=>Promise.resolve().then(()=>a(845427)))},752453,a=>{a.v(b=>Promise.all(["server/chunks/ssr/_0nbufo.._.js"].map(b=>a.l(b))).then(()=>b(897667)))},173855,a=>{a.v(b=>Promise.all(["server/chunks/ssr/src_lib_open-targets_ts_12a-_~u._.js"].map(b=>a.l(b))).then(()=>b(289288)))},889618,a=>{a.v(a=>Promise.resolve().then(()=>a(163812)))},482848,a=>{a.v(a=>Promise.resolve().then(()=>a(874533)))},268548,a=>{a.v(b=>Promise.all(["server/chunks/ssr/[externals]_node_util_0xr.y7p._.js"].map(b=>a.l(b))).then(()=>b(812057)))},144264,a=>{a.v(a=>Promise.resolve().then(()=>a(233405)))},534777,a=>{a.v(a=>Promise.resolve().then(()=>a(224361)))},662330,a=>{a.v(b=>Promise.all(["server/chunks/ssr/_0qkxdkn._.js"].map(b=>a.l(b))).then(()=>b(818992)))},610073,a=>{a.v(a=>Promise.resolve().then(()=>a(4634)))},260815,a=>{a.v(a=>Promise.resolve().then(()=>a(924868)))},323970,a=>{a.v(a=>Promise.resolve().then(()=>a(522734)))}];

//# sourceMappingURL=%5Broot-of-the-server%5D__0fzkdjl._.js.map